Skip to content

Commit

Permalink
[test] test for bitfield2bool converter
Browse files Browse the repository at this point in the history
  • Loading branch information
gicmo authored and jgrewe committed Nov 21, 2016
1 parent 5810714 commit a2f5409
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions test/hdf5/TestH5.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include <iterator>
#include <stdexcept>
#include <limits>
#include <cstring>


unsigned int & TestH5::open_mode()
Expand Down Expand Up @@ -265,6 +266,34 @@ void TestH5::testDataType() {
etlb.insert("FALSE", 0UL);
etlb.insert("TRUE", 1UL);
CPPUNIT_ASSERT(etlb.enum_equal(etib));

h5x::DataType blt = nix::hdf5::data_type_to_h5_memtype(nix::DataType::Bool);

struct ConverTest {
char input;
bool output;
} cttests[] = {
{0, false},
{1, true},
{2, true}
};

char buf[sizeof(bool)];

for (size_t i = 0; i < (sizeof(cttests)/sizeof(ConverTest)); i++) {
ConverTest tt = cttests[i];

buf[0] = tt.input;
nix::hdf5::HErr res = H5Tconvert(H5T_STD_B8LE, blt.h5id(), 1, buf, nullptr, H5P_DEFAULT);
CPPUNIT_ASSERT(!res.isError());
memcpy(&b, buf, sizeof(bool));
bool lvout = tt.output;

int eq = memcmp(&buf, &lvout, sizeof(bool));
CPPUNIT_ASSERT_EQUAL(0, eq);
}

//const bool lvfalse = 0;
}

void TestH5::testDataSpace() {
Expand Down

0 comments on commit a2f5409

Please sign in to comment.