diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2020-08-07 06:00:30 +0000 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2020-08-07 06:33:27 +0000 |
commit | 66ef24209da35593d08ba9f3df8cb24f827bc14b (patch) | |
tree | 36ce32eef66d5c6c0fbfaf8880f345bc36376402 /document/src/tests/fieldsettest.cpp | |
parent | e483631af3d65e217234455fe68ce840fca989a3 (diff) |
- Use modern enum class.
- Add hash method to FieldCollection.
Diffstat (limited to 'document/src/tests/fieldsettest.cpp')
-rw-r--r-- | document/src/tests/fieldsettest.cpp | 28 |
1 files changed, 23 insertions, 5 deletions
diff --git a/document/src/tests/fieldsettest.cpp b/document/src/tests/fieldsettest.cpp index b82cca86ce7..2642bbe23ce 100644 --- a/document/src/tests/fieldsettest.cpp +++ b/document/src/tests/fieldsettest.cpp @@ -2,9 +2,6 @@ #include <vespa/document/base/testdocman.h> #include <vespa/document/fieldset/fieldsetrepo.h> -#include <vespa/vespalib/io/fileutil.h> -#include <vespa/document/datatype/annotationreferencedatatype.h> -#include <vespa/document/repo/configbuilder.h> #include <vespa/document/repo/documenttyperepo.h> #include <vespa/vespalib/objects/nbostream.h> #include <algorithm> @@ -12,8 +9,6 @@ using vespalib::nbostream; -using namespace document::config_builder; - namespace document { class FieldSetTest : public ::testing::Test { @@ -290,4 +285,27 @@ TEST_F(FieldSetTest, testStripFields) doStripFields(*src, repo, "testdoctype1:hstringval,content")); } +TEST(FieldCollectionTest, testHash ) { + TestDocMan testDocMan; + const DocumentTypeRepo& repo = testDocMan.getTypeRepo(); + const DocumentType & type = *repo.getDocumentType("testdoctype1"); + FieldCollection fc(type); + EXPECT_EQ(0ul, fc.hash()); + fc.insert(type.getField("headerval")); + EXPECT_EQ(0x548599858c77ef83ul, fc.hash()); + fc.insert(type.getField("hstringval")); + EXPECT_EQ(0x4a7ff2406d36a9b0ul, fc.hash()); + fc.insert(type.getField("headerval")); + EXPECT_EQ(0x4a7ff2406d36a9b0ul, fc.hash()); + + FieldCollection fc2(type); + EXPECT_EQ(0ul, fc2.hash()); + fc2.insert(type.getField("hstringval")); + EXPECT_EQ(0x1e0918531b19734ul, fc2.hash()); + fc2.insert(type.getField("headerval")); + EXPECT_EQ(fc.hash(), fc2.hash()); + fc2.insert(type.getField("headerval")); + EXPECT_EQ(fc.hash(), fc2.hash()); +} + } // document |