diff --git a/test/test_data_type.cpp b/test/test_data_type.cpp index 9ab4ac01d7761c77460697a7b264fa7d7b9a8401..44347b3a221542c8c0e0603753446b0786b4ecfa 100644 --- a/test/test_data_type.cpp +++ b/test/test_data_type.cpp @@ -48,6 +48,7 @@ TEST(test_data_type, test_atomic) { for (int i = 1; i < 6; i++) { Entity entity; entity.SetRole(Role::PROPERTY); + // the different AtomicDataType are associated with integers entity.SetDataType(static_cast<AtomicDataType>(i)); EXPECT_TRUE(entity.GetDataType().IsAtomic()); EXPECT_EQ(entity.GetDataType().AsAtomic(), static_cast<AtomicDataType>(i)); @@ -57,6 +58,7 @@ TEST(test_data_type, test_atomic) { entity.SetDataType(data_type); EXPECT_FALSE(data_type.IsReference()); + EXPECT_EQ(data_type.AsReference().GetName(), std::basic_string<char>("")); EXPECT_FALSE(data_type.IsList()); EXPECT_TRUE(data_type.IsAtomic()); EXPECT_EQ(data_type.AsAtomic(), static_cast<AtomicDataType>(i)); @@ -95,6 +97,7 @@ TEST(test_data_type, test_list_of_atomic) { EXPECT_FALSE(data_type.IsAtomic()); EXPECT_TRUE(data_type.IsList()); const auto &list_data_type = data_type.AsList(); + EXPECT_EQ(list_data_type.GetReferenceDataType().GetName(), std::basic_string<char>("")); EXPECT_TRUE(list_data_type.IsListOfAtomic()); EXPECT_FALSE(list_data_type.IsListOfReference()); EXPECT_EQ(list_data_type.GetAtomicDataType(), diff --git a/test/test_entity.cpp b/test/test_entity.cpp index f38f14457bf0b9a3fc5ddf21820615b55fd6f484..9d09e45b45580808768a8ca38528a4cbfc1988e7 100644 --- a/test/test_entity.cpp +++ b/test/test_entity.cpp @@ -30,12 +30,14 @@ #include "caosdb/status_code.h" // for StatusCode, FILE_DO... #include "caosdb/transaction.h" // for Transaction #include "caosdb/value.h" // for Value +#include <exception> #include <google/protobuf/arena.h> // for Arena #include <gtest/gtest-message.h> // for Message #include <gtest/gtest-test-part.h> // for TestPartResult, Sui... #include <gtest/gtest_pred_impl.h> // for Test, EXPECT_EQ #include <iostream> #include <memory> // for allocator, shared_ptr +#include <stdexcept> #include <string> // for operator+, string namespace caosdb::entity { @@ -100,7 +102,10 @@ TEST(test_entity, test_append_property) { entity.AppendProperty(prop); EXPECT_EQ(entity.GetProperties().size(), 1); + // also test RepeatedPtrFieldWrapper.at() const auto &same_prop = entity.GetProperties().at(0); + EXPECT_THROW((void) entity.GetProperties().at(2), std::out_of_range); + EXPECT_THROW((void) entity.GetProperties().at(-1), std::out_of_range); EXPECT_EQ(prop.GetName(), same_prop.GetName()); EXPECT_EQ(prop.GetId(), same_prop.GetId());