// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include #include #include #include #include using vespalib::string; using namespace document::config_builder; using namespace document; namespace { const string type_name = "test"; const int32_t doc_type_id = 787121340; const string header_name = type_name + ".header"; const string body_name = type_name + ".body"; std::shared_ptr makeDocumentTypesConfig(const string &field_name) { document::config_builder::DocumenttypesConfigBuilderHelper builder; builder.document(doc_type_id, type_name, Struct(header_name), Struct(body_name).addField(field_name, DataType::T_STRING)); return std::make_shared(builder.config()); } TEST("require that equal configs gives same repo") { auto config1 = makeDocumentTypesConfig("a"); auto config2 = makeDocumentTypesConfig("b"); auto config3 = std::make_shared(*config1); auto config4 = std::make_shared(*config2); auto repo1 = DocumentTypeRepoFactory::make(*config1); auto repo2 = DocumentTypeRepoFactory::make(*config2); auto repo3 = DocumentTypeRepoFactory::make(*config3); auto repo4 = DocumentTypeRepoFactory::make(*config4); EXPECT_NOT_EQUAL(repo1, repo2); EXPECT_EQUAL(repo1, repo3); EXPECT_NOT_EQUAL(repo1, repo4); EXPECT_NOT_EQUAL(repo2, repo3); EXPECT_EQUAL(repo2, repo4); EXPECT_NOT_EQUAL(repo3, repo4); } } TEST_MAIN() { TEST_RUN_ALL(); }