Skip to content

Commit

Permalink
Add unit test for ArrayDataSetConfig
Browse files Browse the repository at this point in the history
  • Loading branch information
oruebel committed Feb 22, 2025
1 parent 5ff4a17 commit cf67eea
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/io/BaseIO.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,12 @@ class BaseDataType
static const BaseDataType DSTR; ///< Accessor for dynamic string.
static BaseDataType STR(
SizeType size); ///< Accessor for string with specified size.

// Define the equality operator
bool operator==(const BaseDataType& other) const
{
return type == other.type && typeSize == other.typeSize;
}
};

class DataBlockGeneric;
Expand Down
42 changes: 42 additions & 0 deletions tests/testBaseIO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,48 @@

using namespace AQNWB::IO;

TEST_CASE("Test ArrayDataSetConfig", "[BaseIO]")
{
SECTION("Test constructor")
{
ArrayDataSetConfig config(BaseDataType::I32, SizeArray {10}, SizeArray {5});
REQUIRE(config.getType() == BaseDataType::I32);
REQUIRE(config.getShape() == SizeArray {10});
REQUIRE(config.getChunking() == SizeArray {5});
}
}

TEST_CASE("BaseDataType equality operator", "[BaseIO]")
{
SECTION("Same type and size")
{
BaseDataType type1(BaseDataType::T_I32, 4);
BaseDataType type2(BaseDataType::T_I32, 4);
REQUIRE(type1 == type2);
}

SECTION("Different type")
{
BaseDataType type1(BaseDataType::T_I32, 4);
BaseDataType type2(BaseDataType::T_F32, 4);
REQUIRE(!(type1 == type2));
}

SECTION("Different size")
{
BaseDataType type1(BaseDataType::T_I32, 4);
BaseDataType type2(BaseDataType::T_I32, 8);
REQUIRE(!(type1 == type2));
}

SECTION("Different type and size")
{
BaseDataType type1(BaseDataType::T_I32, 4);
BaseDataType type2(BaseDataType::T_F32, 8);
REQUIRE(!(type1 == type2));
}
}

TEST_CASE("Test findTypes functionality", "[BaseIO]")
{
std::string filename = getTestFilePath("test_findTypes.h5");
Expand Down

0 comments on commit cf67eea

Please sign in to comment.