summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArne H Juul <arnej@yahooinc.com>2022-04-01 10:10:46 +0000
committerArne H Juul <arnej@yahooinc.com>2022-04-01 10:10:46 +0000
commit4a45acf132960283f9d487e07916c65a7e3aee66 (patch)
tree3a8a6e11782e7e47181b6a7c3cb77556579f9302
parent7b64d618dc6def24bd4d424714b4004f7640e871 (diff)
extend test
-rw-r--r--document/src/tests/repo/doctype_config_test.cpp21
1 files changed, 20 insertions, 1 deletions
diff --git a/document/src/tests/repo/doctype_config_test.cpp b/document/src/tests/repo/doctype_config_test.cpp
index 5bb879b4e38..84ec1414fcc 100644
--- a/document/src/tests/repo/doctype_config_test.cpp
+++ b/document/src/tests/repo/doctype_config_test.cpp
@@ -42,7 +42,6 @@ const string header_name_2 = type_name_2 + ".header";
const string field_name = "field_name";
const string derived_name = "derived";
-using ::document::config::DocumenttypesConfig;
using ::document::config::DocumenttypesConfigBuilder;
using BDocType = DocumenttypesConfigBuilder::Doctype;
@@ -494,6 +493,26 @@ TEST("requireThatBuildFromConfigWorks") {
ASSERT_TRUE(repo.getDocumentType("types"));
}
+TEST("requireThatStructsCanInheritFields") {
+ BuilderHelper builder;
+ auto & doc = builder.document(type_name);
+ auto & st1 = builder.addStruct(doc, "sa");
+ auto & st2 = builder.addStruct(doc, "sb");
+ auto & st3 = builder.addStruct(doc, "sc");
+ builder.addField(st1, "fa").type = builder.builtin(DataType::T_INT);
+ builder.addField(st2, "fb").type = builder.builtin(DataType::T_LONG);
+ builder.addField(st3, "fc").type = builder.builtin(DataType::T_STRING);
+ st1.inherits.emplace_back().type = st2.idx;
+ st2.inherits.emplace_back().type = st3.idx;
+ builder.addField(doc, field_name).type = st1.idx;
+ DocumentTypeRepo repo(builder.config());
+ const StructDataType &s = getFieldDataType<StructDataType>(repo);
+ EXPECT_EQUAL(3u, s.getFieldCount());
+ ASSERT_TRUE(s.hasField("fa"));
+ ASSERT_TRUE(s.hasField("fb"));
+ ASSERT_TRUE(s.hasField("fc"));
+}
+
TEST("requireThatStructsCanBeRecursive") {
BuilderHelper builder;
auto & doc = builder.document(type_name);