diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2020-08-04 14:03:49 +0000 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2020-08-04 14:03:49 +0000 |
commit | db49d6d264873e7faf0e5df0a6dec42cc94888e8 (patch) | |
tree | d3a3df7f4d5f9c912489aa61d53efd9200e7ebed /document | |
parent | bdc43e2dda007965b770cd0a778d6a2f2634d276 (diff) |
Use named constants instead of strings sprinkled all over.
Diffstat (limited to 'document')
-rw-r--r-- | document/src/tests/fieldsettest.cpp | 28 | ||||
-rw-r--r-- | document/src/vespa/document/fieldset/fieldsetrepo.cpp | 7 |
2 files changed, 17 insertions, 18 deletions
diff --git a/document/src/tests/fieldsettest.cpp b/document/src/tests/fieldsettest.cpp index f77bd9bfb09..b82cca86ce7 100644 --- a/document/src/tests/fieldsettest.cpp +++ b/document/src/tests/fieldsettest.cpp @@ -40,9 +40,9 @@ TEST_F(FieldSetTest, testParsing) FieldSetRepo repo; - (void) dynamic_cast<AllFields&>(*repo.parse(docRepo, "[all]")); - (void) dynamic_cast<NoFields&>(*repo.parse(docRepo, "[none]")); - (void) dynamic_cast<DocIdOnly&>(*repo.parse(docRepo, "[id]")); + (void) dynamic_cast<AllFields&>(*repo.parse(docRepo, AllFields::NAME)); + (void) dynamic_cast<NoFields&>(*repo.parse(docRepo, NoFields::NAME)); + (void) dynamic_cast<DocIdOnly&>(*repo.parse(docRepo, DocIdOnly::NAME)); FieldSet::UP set = repo.parse(docRepo, "testdoctype1:headerval,content"); FieldCollection& coll = dynamic_cast<FieldCollection&>(*set); @@ -195,11 +195,11 @@ TEST_F(FieldSetTest, testCopyDocumentFields) Document::UP src(createTestDocument(testDocMan)); EXPECT_EQ(std::string(""), - doCopyFields(*src, repo, "[none]")); + doCopyFields(*src, repo, NoFields::NAME)); EXPECT_EQ(std::string("content: megafoo megabar\n" "headerval: 5678\n" "hstringval: hello fantastic world\n"), - doCopyFields(*src, repo, "[all]")); + doCopyFields(*src, repo, AllFields::NAME)); EXPECT_EQ(std::string("content: megafoo megabar\n" "hstringval: hello fantastic world\n"), doCopyFields(*src, repo, "testdoctype1:hstringval,content")); @@ -236,13 +236,13 @@ TEST_F(FieldSetTest, testDocumentSubsetCopy) EXPECT_TRUE(doc.get()); EXPECT_EQ(src->getId(), doc->getId()); EXPECT_EQ(src->getType(), doc->getType()); - EXPECT_EQ(doCopyFields(*src, repo, "[all]"), + EXPECT_EQ(doCopyFields(*src, repo, AllFields::NAME), stringifyFields(*doc)); } const char* fieldSets[] = { - "[all]", - "[none]", + AllFields::NAME, + NoFields::NAME, "testdoctype1:hstringval,content" }; for (size_t i = 0; i < sizeof(fieldSets) / sizeof(fieldSets[0]); ++i) { @@ -257,9 +257,9 @@ TEST_F(FieldSetTest, testSerialize) const DocumentTypeRepo& docRepo = testDocMan.getTypeRepo(); const char* fieldSets[] = { - "[all]", - "[none]", - "[docid]", + AllFields::NAME, + NoFields::NAME, + DocIdOnly::NAME, "testdoctype1:content", "testdoctype1:content,hstringval" }; @@ -278,13 +278,13 @@ TEST_F(FieldSetTest, testStripFields) Document::UP src(createTestDocument(testDocMan)); EXPECT_EQ(std::string(""), - doStripFields(*src, repo, "[none]")); + doStripFields(*src, repo, NoFields::NAME)); EXPECT_EQ(std::string(""), - doStripFields(*src, repo, "[id]")); + doStripFields(*src, repo, DocIdOnly::NAME)); EXPECT_EQ(std::string("content: megafoo megabar\n" "headerval: 5678\n" "hstringval: hello fantastic world\n"), - doStripFields(*src, repo, "[all]")); + doStripFields(*src, repo, AllFields::NAME)); EXPECT_EQ(std::string("content: megafoo megabar\n" "hstringval: hello fantastic world\n"), doStripFields(*src, repo, "testdoctype1:hstringval,content")); diff --git a/document/src/vespa/document/fieldset/fieldsetrepo.cpp b/document/src/vespa/document/fieldset/fieldsetrepo.cpp index c7d91ec5175..e3212f3bd25 100644 --- a/document/src/vespa/document/fieldset/fieldsetrepo.cpp +++ b/document/src/vespa/document/fieldset/fieldsetrepo.cpp @@ -85,7 +85,6 @@ FieldSetRepo::serialize(const FieldSet& fieldSet) switch (fieldSet.getType()) { case FieldSet::FIELD: return static_cast<const Field&>(fieldSet).getName(); - break; case FieldSet::SET: { const FieldCollection& collection = static_cast<const FieldCollection&>(fieldSet); @@ -105,11 +104,11 @@ FieldSetRepo::serialize(const FieldSet& fieldSet) return stream.str(); } case FieldSet::ALL: - return "[all]"; + return AllFields::NAME; case FieldSet::NONE: - return "[none]"; + return NoFields::NAME; case FieldSet::DOCID: - return "[docid]"; + return DocIdOnly::NAME; default: return ""; } |