Skip to content
Snippets Groups Projects
Commit b810654a authored by Stéphane Del Pino's avatar Stéphane Del Pino
Browse files

Add tests for DataVariant (AggregateDataVariant actually)

parent 6259a6a5
No related branches found
No related tags found
1 merge request!37Feature/language
......@@ -43,6 +43,7 @@ add_executable (unit_tests
test_ContinueProcessor.cpp
test_ConcatExpressionProcessor.cpp
test_CRSMatrix.cpp
test_DataVariant.cpp
test_DoWhileProcessor.cpp
test_ExecutionPolicy.cpp
test_FakeProcessor.cpp
......
#include <catch2/catch.hpp>
#include <DataVariant.hpp>
#include <sstream>
TEST_CASE("DataVariant", "[language]")
{
SECTION("AggregateDataVariant")
{
AggregateDataVariant aggregate{std::vector<DataVariant>{double{1.3}, int64_t{-3}}};
SECTION("size")
{
REQUIRE(aggregate.size() == 2);
}
SECTION("output")
{
std::stringstream aggregate_output;
aggregate_output << aggregate;
std::stringstream expected_output;
expected_output << '(' << double{1.3} << ", " << int64_t{-3} << ')';
REQUIRE(aggregate_output.str() == expected_output.str());
}
SECTION("values")
{
REQUIRE(std::get<double>(aggregate[0]) == double{1.3});
REQUIRE(std::get<int64_t>(aggregate[1]) == int64_t{-3});
}
SECTION("Copy")
{
AggregateDataVariant aggregate_copy{aggregate};
REQUIRE(aggregate.size() == aggregate_copy.size());
for (size_t i = 0; i < aggregate.size(); ++i) {
REQUIRE(aggregate[i].index() == aggregate_copy[i].index());
}
REQUIRE(std::get<double>(aggregate[0]) == std::get<double>(aggregate_copy[0]));
REQUIRE(std::get<int64_t>(aggregate[1]) == std::get<int64_t>(aggregate_copy[1]));
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment