Skip to content

Instantly share code, notes, and snippets.

@sudoankit
Last active March 23, 2016 18:58
Show Gist options
  • Save sudoankit/8e7db0b989d86f85f22a to your computer and use it in GitHub Desktop.
Save sudoankit/8e7db0b989d86f85f22a to your computer and use it in GitHub Desktop.
sample test case for NIX npylib backend.
class npyExampleTestSuite : public Test::Suite
{
public:
npyExampleTestSuite()
{
TEST_ADD(ExampleTestSuite::f_test)
TEST_ADD(ExampleTestSuite::s_test)
}
private:
void f_test();
void s_test();
void sometest();
};
void npyExampleTestSuite::f_test()
{
TEST_ASSERT(1 + 1 == 2)
TEST_ASSERT(0 == 1);
}
void npyExampleTestSuite::s_test()
{
TEST_ASSERT_DELTA(0.5, 0.7, 0.3); //pass
TEST_ASSERT_DELTA(0.5, 0.7, 0.1); //fail
}
/* Add more gradually like */
void npyExampleSuite::sometest(){
assert(np_arr.word_size == sizeof(std::complex<double>));
assert(np_arr.shape.size() == 3 && np_arr.shape[0] == Nz && np_arr.shape[1] == Ny && np_arr.shape[2] == Nx);
for(int i = 0; i < Nx*Ny*Nz;i++) assert(data[i] == loaded_data[i]);
}
// Nx, Ny, Nz are the dimensions declared
// loaded_data[] is the data entered through python, and data[] is data entered through C++.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment