diff options
author | Tor Brede Vekterli <vekterli@yahoo-inc.com> | 2017-01-31 15:34:36 +0100 |
---|---|---|
committer | Tor Brede Vekterli <vekterli@yahoo-inc.com> | 2017-02-02 15:18:36 +0100 |
commit | 140da1c8d693ee646fdd6bad4619a6e7b94b19ee (patch) | |
tree | 251f23b10978c9a9bf21dde16f5e2a8f968fb152 /document/src/tests/repo | |
parent | a689ebd4f603357473d5587aecd3bb2d9f1b1270 (diff) |
Support reference data types in type repo
Diffstat (limited to 'document/src/tests/repo')
-rw-r--r-- | document/src/tests/repo/documenttyperepo_test.cpp | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/document/src/tests/repo/documenttyperepo_test.cpp b/document/src/tests/repo/documenttyperepo_test.cpp index b3ff4ce098e..38ae51b980f 100644 --- a/document/src/tests/repo/documenttyperepo_test.cpp +++ b/document/src/tests/repo/documenttyperepo_test.cpp @@ -500,4 +500,34 @@ TEST("Require that Array can have nested DocumentType") { ASSERT_TRUE(type); } +TEST("Reference fields are resolved to correct reference type") { + const int doc_with_refs_id = 5678; + const int type_2_id = doc_type_id + 1; + const int ref1_id = 777; + const int ref2_id = 888; + DocumenttypesConfigBuilderHelper builder; + builder.document(doc_type_id, type_name, + Struct(header_name), Struct(body_name)); + builder.document(type_2_id, type_name_2, + Struct(header_name_2), Struct(body_name_2)); + builder.document(doc_with_refs_id, "doc_with_refs", + Struct("doc_with_refs.header") + .addField("ref1", ref1_id), + Struct("doc_with_refs.body") + .addField("ref2", ref2_id) + .addField("ref3", ref1_id)) + .referenceType(ref1_id, doc_type_id) + .referenceType(ref2_id, type_2_id); + + DocumentTypeRepo repo(builder.config()); + const DocumentType *type = repo.getDocumentType(doc_with_refs_id); + ASSERT_TRUE(type != nullptr); + const auto* ref1_type(repo.getDataType(*type, ref1_id)); + const auto* ref2_type(repo.getDataType(*type, ref2_id)); + + EXPECT_EQUAL(*ref1_type, type->getFieldsType().getField("ref1").getDataType()); + EXPECT_EQUAL(*ref2_type, type->getFieldsType().getField("ref2").getDataType()); + EXPECT_EQUAL(*ref1_type, type->getFieldsType().getField("ref3").getDataType()); +} + TEST_MAIN() { TEST_RUN_ALL(); } |