aboutsummaryrefslogtreecommitdiffstats
path: root/document/src/tests
diff options
context:
space:
mode:
Diffstat (limited to 'document/src/tests')
-rw-r--r--document/src/tests/arrayfieldvaluetest.cpp18
-rw-r--r--document/src/tests/documentselectparsertest.cpp43
-rw-r--r--document/src/tests/documenttestcase.cpp46
-rw-r--r--document/src/tests/documentupdatetestcase.cpp13
-rw-r--r--document/src/tests/fieldpathupdatetestcase.cpp7
-rw-r--r--document/src/tests/fieldvalue/fieldvalue_test.cpp14
-rw-r--r--document/src/tests/primitivefieldvaluetest.cpp55
-rw-r--r--document/src/tests/serialization/vespadocumentserializer_test.cpp3
-rw-r--r--document/src/tests/weightedsetfieldvaluetest.cpp23
9 files changed, 84 insertions, 138 deletions
diff --git a/document/src/tests/arrayfieldvaluetest.cpp b/document/src/tests/arrayfieldvaluetest.cpp
index a8ca9d22916..375ce05a4e6 100644
--- a/document/src/tests/arrayfieldvaluetest.cpp
+++ b/document/src/tests/arrayfieldvaluetest.cpp
@@ -3,7 +3,6 @@
#include <vespa/document/fieldvalue/fieldvalues.h>
#include <vespa/document/serialization/vespadocumentdeserializer.h>
#include <vespa/vespalib/objects/nbostream.h>
-#include <vespa/document/util/bytebuffer.h>
#include <vespa/document/repo/documenttyperepo.h>
#include <gtest/gtest.h>
#include <gmock/gmock.h>
@@ -103,21 +102,14 @@ TEST(ArrayFieldValueTest, testArray)
ArrayFieldValue::UP valuePtr(value2.clone());
EXPECT_EQ(value, *valuePtr);
- // Iterating
+ // Iterating
const ArrayFieldValue& constVal(value);
- for(ArrayFieldValue::const_iterator it = constVal.begin();
- it != constVal.end(); ++it)
- {
- const FieldValue& fval1(*it);
- (void) fval1;
- EXPECT_EQ((uint32_t) IntFieldValue::classId,
- it->getClass().id());
+ for(const FieldValue & fval1 : constVal) {
+ EXPECT_EQ((uint32_t) IntFieldValue::classId, fval1.getClass().id());
}
value2 = value;
- for(ArrayFieldValue::iterator it = value2.begin(); it != value2.end(); ++it)
- {
- (*it).assign(IntFieldValue(7));
- it->assign(IntFieldValue(7));
+ for(size_t i(0); i < value2.size(); i++) {
+ value2[i].assign(IntFieldValue(7));
}
EXPECT_TRUE(value != value2);
EXPECT_TRUE(value2.contains(IntFieldValue(7)));
diff --git a/document/src/tests/documentselectparsertest.cpp b/document/src/tests/documentselectparsertest.cpp
index f40aec41e16..d2fa969daa9 100644
--- a/document/src/tests/documentselectparsertest.cpp
+++ b/document/src/tests/documentselectparsertest.cpp
@@ -1,5 +1,6 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+#include <vespa/document/test/fieldvalue_helpers.h>
#include <vespa/document/repo/configbuilder.h>
#include <vespa/document/repo/documenttyperepo.h>
#include <vespa/document/update/assignvalueupdate.h>
@@ -152,18 +153,18 @@ DocumentSelectParserTest::createDocs()
// Add some arrays and structs to doc 1
{
StructFieldValue sval(_doc.back()->getField("mystruct").getDataType());
- sval.set("key", 14);
- sval.set("value", "structval");
+ sval.setValue("key", IntFieldValue::make(14));
+ sval.setValue("value", StringFieldValue::make("structval"));
_doc.back()->setValue("mystruct", sval);
ArrayFieldValue
aval(_doc.back()->getField("structarray").getDataType());
{
StructFieldValue sval1(aval.getNestedType());
- sval1.set("key", 15);
- sval1.set("value", "structval1");
+ sval1.setValue("key", IntFieldValue::make(15));
+ sval1.setValue("value", StringFieldValue::make("structval1"));
StructFieldValue sval2(aval.getNestedType());
- sval2.set("key", 16);
- sval2.set("value", "structval2");
+ sval2.setValue("key", IntFieldValue::make(16));
+ sval2.setValue("value", StringFieldValue::make("structval2"));
aval.add(sval1);
aval.add(sval2);
}
@@ -181,11 +182,11 @@ DocumentSelectParserTest::createDocs()
ArrayFieldValue abval(_doc.back()->getField("structarray").getDataType());
{
StructFieldValue sval1(aval.getNestedType());
- sval1.set("key", 17);
- sval1.set("value", "structval3");
+ sval1.setValue("key", IntFieldValue::make(17));
+ sval1.setValue("value", StringFieldValue::make("structval3"));
StructFieldValue sval2(aval.getNestedType());
- sval2.set("key", 18);
- sval2.set("value", "structval4");
+ sval2.setValue("key", IntFieldValue::make(18));
+ sval2.setValue("value", StringFieldValue::make("structval4"));
abval.add(sval1);
abval.add(sval2);
}
@@ -193,17 +194,15 @@ DocumentSelectParserTest::createDocs()
amval.put(StringFieldValue("bar"), abval);
_doc.back()->setValue("structarrmap", amval);
- WeightedSetFieldValue wsval(
- _doc.back()->getField("stringweightedset").getDataType());
- wsval.add("foo");
- wsval.add("val1");
- wsval.add("val2");
- wsval.add("val3");
- wsval.add("val4");
+ WeightedSetFieldValue wsval(_doc.back()->getField("stringweightedset").getDataType());
+ WSetHelper(wsval).add("foo");
+ WSetHelper(wsval).add("val1");
+ WSetHelper(wsval).add("val2");
+ WSetHelper(wsval).add("val3");
+ WSetHelper(wsval).add("val4");
_doc.back()->setValue("stringweightedset", wsval);
- WeightedSetFieldValue wsbytes(
- _doc.back()->getField("byteweightedset").getDataType());
+ WeightedSetFieldValue wsbytes(_doc.back()->getField("byteweightedset").getDataType());
wsbytes.add(ByteFieldValue(5));
wsbytes.add(ByteFieldValue(75));
wsbytes.add(ByteFieldValue(static_cast<int8_t>(255)));
@@ -211,14 +210,12 @@ DocumentSelectParserTest::createDocs()
_doc.back()->setValue("byteweightedset", wsbytes);
}
- _doc.push_back(createDoc(
- "testdoctype1", "id:myspace:testdoctype1:n=1234:footype1", 15, 1.0, "some", "some", 0)); // DOC 2
+ _doc.push_back(createDoc("testdoctype1", "id:myspace:testdoctype1:n=1234:footype1", 15, 1.0, "some", "some", 0)); // DOC 2
// Add empty struct and array
{
StructFieldValue sval(_doc.back()->getField("mystruct").getDataType());
_doc.back()->setValue("mystruct", sval);
- ArrayFieldValue aval(
- _doc.back()->getField("structarray").getDataType());
+ ArrayFieldValue aval(_doc.back()->getField("structarray").getDataType());
_doc.back()->setValue("structarray", aval);
}
_doc.push_back(createDoc("testdoctype1", "id:myspace:testdoctype1:g=yahoo:bar", 14, 2.4, "Yet", "\xE4\xB8\xBA\xE4\xBB\x80", 0)); // DOC 3
diff --git a/document/src/tests/documenttestcase.cpp b/document/src/tests/documenttestcase.cpp
index fde702f2080..c852e219faa 100644
--- a/document/src/tests/documenttestcase.cpp
+++ b/document/src/tests/documenttestcase.cpp
@@ -1,5 +1,6 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+#include <vespa/document/test/fieldvalue_helpers.h>
#include <vespa/document/base/testdocman.h>
#include <vespa/document/datatype/documenttype.h>
#include <vespa/document/datatype/mapdatatype.h>
@@ -349,11 +350,12 @@ TEST(DocumentTest, testModifyDocument)
structmap1.put(StringFieldValue("test"), l2s1);
l1s1.setValue(structmapF, structmap1);
- WeightedSetFieldValue wset1(wset);
+ WeightedSetFieldValue wwset1(wset);
+ WSetHelper wset1(wwset1);
wset1.add("foo");
wset1.add("bar");
wset1.add("zoo");
- l1s1.setValue(wsetF, wset1);
+ l1s1.setValue(wsetF, wwset1);
WeightedSetFieldValue wset2(structwset);
wset2.add(l2s1);
@@ -705,19 +707,19 @@ TEST(DocumentTest,testReadSerializedAllVersions)
// Create a memory instance of document
{
Document doc(*docType, DocumentId("id:ns:serializetest::http://test.doc.id/"));
- doc.set("intfield", 5);
- doc.set("floatfield", -9.23);
- doc.set("stringfield", "This is a string.");
- doc.set("longfield", static_cast<int64_t>(398420092938472983LL));
- doc.set("doublefield", 98374532.398820);
- doc.set("bytefield", -2);
- doc.setValue("rawfield", RawFieldValue("RAW DATA", 8));
+ doc.setValue("intfield", IntFieldValue::make(5));
+ doc.setValue("floatfield", FloatFieldValue::make(-9.23));
+ doc.setValue("stringfield", StringFieldValue::make("This is a string."));
+ doc.setValue("longfield", LongFieldValue::make(static_cast<int64_t>(398420092938472983LL)));
+ doc.setValue("doublefield", DoubleFieldValue::make(98374532.398820));
+ doc.setValue("bytefield", ByteFieldValue::make(-2));
+ doc.setValue("rawfield", std::make_unique<RawFieldValue>("RAW DATA", 8));
Document docInDoc(*docInDocType, DocumentId("id:ns:docindoc::http://doc.in.doc/"));
- docInDoc.set("stringindocfield", "Elvis is dead");
+ docInDoc.setValue("stringindocfield", StringFieldValue::make("Elvis is dead"));
doc.setValue("docfield", docInDoc);
ArrayFieldValue floatArray(*arrayOfFloatDataType);
- floatArray.add(1.0);
- floatArray.add(2.0);
+ CollectionHelper(floatArray).add(1.0);
+ CollectionHelper(floatArray).add(2.0);
doc.setValue("arrayoffloatfield", floatArray);
WeightedSetFieldValue weightedSet(*weightedSetDataType);
weightedSet.add(StringFieldValue("Weighted 0"), 50);
@@ -828,14 +830,14 @@ TEST(DocumentTest, testGenerateSerializedFile)
DocumentTypeRepo repo(readDocumenttypesConfig(file_name));
Document doc(*repo.getDocumentType("serializetest"), DocumentId("id:ns:serializetest::http://test.doc.id/"));
- doc.set("intfield", 5);
- doc.set("floatfield", -9.23);
- doc.set("stringfield", "This is a string.");
- doc.set("longfield", (int64_t) 398420092938472983ll);
- doc.set("doublefield", 98374532.398820);
- doc.set("urifield", "http://this.is.a.test/");
- doc.set("bytefield", -2);
- doc.set("rawfield", "RAW DATA");
+ doc.setValue("intfield", IntFieldValue::make(5));
+ doc.setValue("floatfield", FloatFieldValue::make(-9.23));
+ doc.setValue("stringfield", StringFieldValue::make("This is a string."));
+ doc.setValue("longfield", LongFieldValue::make((int64_t) 398420092938472983ll));
+ doc.setValue("doublefield", DoubleFieldValue::make(98374532.398820));
+ doc.setValue("urifield", StringFieldValue::make("http://this.is.a.test/"));
+ doc.setValue("bytefield", ByteFieldValue::make(-2));
+ doc.setValue("rawfield", std::make_unique<RawFieldValue>("RAW DATA"));
const DocumentType *docindoc_type = repo.getDocumentType("docindoc");
EXPECT_TRUE(docindoc_type);
@@ -949,7 +951,7 @@ TEST(DocumentTest, testHasChanged)
Document doc2(test_repo.getTypeRepo(), buf);
EXPECT_TRUE(!doc2.hasChanged());
- doc2.set("headerval", 13);
+ doc2.setValue("headerval", IntFieldValue::make(13));
EXPECT_TRUE(doc2.hasChanged());
}
// Overwriting a value in doc tags us changed.
@@ -957,7 +959,7 @@ TEST(DocumentTest, testHasChanged)
buf.rp(0);
Document doc2(test_repo.getTypeRepo(), buf);
- doc2.set("hstringval", "bla bla bla bla bla");
+ doc2.setValue("hstringval", StringFieldValue::make("bla bla bla bla bla"));
EXPECT_TRUE(doc2.hasChanged());
}
// Clearing value tags us changed.
diff --git a/document/src/tests/documentupdatetestcase.cpp b/document/src/tests/documentupdatetestcase.cpp
index 8a9aef0bde4..26819699db4 100644
--- a/document/src/tests/documentupdatetestcase.cpp
+++ b/document/src/tests/documentupdatetestcase.cpp
@@ -1,5 +1,6 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+#include <vespa/document/test/fieldvalue_helpers.h>
#include <vespa/document/base/testdocman.h>
#include <vespa/document/base/exceptions.h>
#include <vespa/document/datatype/tensor_data_type.h>
@@ -138,8 +139,8 @@ TEST(DocumentUpdateTest, testSimpleUsage)
// Create a test document
Document doc(*docType, DocumentId("id:ns:test::1"));
- doc.set("bytef", 0);
- doc.set("intf", 5);
+ doc.setValue("bytef", ByteFieldValue::make(0));
+ doc.setValue("intf", IntFieldValue::make(5));
ArrayFieldValue array(*arrayType);
array.add(IntFieldValue(3));
array.add(IntFieldValue(7));
@@ -1287,9 +1288,9 @@ TEST(DocumentUpdateTest, array_element_update_applies_to_specified_element)
ArrayUpdateFixture f;
ArrayFieldValue array_value(f.array_field.getDataType());
- array_value.add("foo");
- array_value.add("baz");
- array_value.add("blarg");
+ CollectionHelper(array_value).add("foo");
+ CollectionHelper(array_value).add("baz");
+ CollectionHelper(array_value).add("blarg");
f.doc->setValue(f.array_field, array_value);
f.update->applyTo(*f.doc);
@@ -1306,7 +1307,7 @@ TEST(DocumentUpdateTest, array_element_update_for_invalid_index_is_ignored)
ArrayUpdateFixture f;
ArrayFieldValue array_value(f.array_field.getDataType());
- array_value.add("jerry");
+ CollectionHelper(array_value).add("jerry");
f.doc->setValue(f.array_field, array_value);
f.update->applyTo(*f.doc); // MapValueUpdate for index 1, which does not exist
diff --git a/document/src/tests/fieldpathupdatetestcase.cpp b/document/src/tests/fieldpathupdatetestcase.cpp
index 3ebf3699763..3d41a5bcacd 100644
--- a/document/src/tests/fieldpathupdatetestcase.cpp
+++ b/document/src/tests/fieldpathupdatetestcase.cpp
@@ -1,4 +1,6 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+
+#include <vespa/document/test/fieldvalue_helpers.h>
#include <vespa/document/base/testdocman.h>
#include <vespa/document/fieldvalue/iteratorhandler.h>
#include <vespa/document/fieldvalue/intfieldvalue.h>
@@ -128,11 +130,12 @@ createTestDocument(const DocumentTypeRepo &repo)
structmap1.put(StringFieldValue("test"), l2s1);
l1s1.setValue("structmap", structmap1);
- WeightedSetFieldValue wset1(*wset);
+ WeightedSetFieldValue wwset1(*wset);
+ WSetHelper wset1(wwset1);
wset1.add("foo");
wset1.add("bar");
wset1.add("zoo");
- l1s1.setValue("wset", wset1);
+ l1s1.setValue("wset", wwset1);
WeightedSetFieldValue wset2(*structwset);
wset2.add(l2s1);
diff --git a/document/src/tests/fieldvalue/fieldvalue_test.cpp b/document/src/tests/fieldvalue/fieldvalue_test.cpp
index b70fd0d18a8..d8712768000 100644
--- a/document/src/tests/fieldvalue/fieldvalue_test.cpp
+++ b/document/src/tests/fieldvalue/fieldvalue_test.cpp
@@ -1,15 +1,15 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
// Unit tests for fieldvalue.
-#include <vespa/log/log.h>
-LOG_SETUP("fieldvalue_test");
-
#include <vespa/document/fieldvalue/stringfieldvalue.h>
#include <vespa/document/fieldvalue/longfieldvalue.h>
#include <vespa/document/fieldvalue/intfieldvalue.h>
#include <vespa/vespalib/testkit/testapp.h>
+#include <vespa/log/log.h>
+LOG_SETUP("fieldvalue_test");
+
using namespace document;
namespace {
@@ -18,14 +18,6 @@ TEST("require that StringFieldValue can be assigned primitives") {
StringFieldValue val;
val = "foo";
EXPECT_EQUAL("foo", val.getValue());
- val = 1;
- EXPECT_EQUAL("1", val.getValue());
- val = static_cast<int64_t>(2);
- EXPECT_EQUAL("2", val.getValue());
- val = 3.0f;
- EXPECT_EQUAL("3", val.getValue());
- val = 4.0;
- EXPECT_EQUAL("4", val.getValue());
}
TEST("require that FieldValues does not change their storage size.") {
diff --git a/document/src/tests/primitivefieldvaluetest.cpp b/document/src/tests/primitivefieldvaluetest.cpp
index 7c734544f27..ea78baa4ee6 100644
--- a/document/src/tests/primitivefieldvaluetest.cpp
+++ b/document/src/tests/primitivefieldvaluetest.cpp
@@ -3,7 +3,6 @@
#include <vespa/document/fieldvalue/fieldvalues.h>
#include <vespa/document/serialization/vespadocumentdeserializer.h>
#include <vespa/vespalib/objects/nbostream.h>
-#include <vespa/document/util/bytebuffer.h>
#include <vespa/document/repo/documenttyperepo.h>
#include <limits>
#include <gtest/gtest.h>
@@ -32,7 +31,7 @@ void deserialize(nbostream & stream, T &value) {
const Type& medium2, const Type& largest)
{
try{
- // Less
+ // Less
EXPECT_TRUE(!(smallest < smallest));
EXPECT_TRUE(smallest < medium1);
EXPECT_TRUE(smallest < medium2);
@@ -203,31 +202,6 @@ TEST(PrimitiveFieldValueTest, testRaw)
value.getValueRef().size()) == 0);
}
-#define ASSERT_FAILED_CONV(getter, totype, floating) \
-{ \
- totype toType; \
- FieldValue::UP copy(value.clone()); \
- try{ \
- getter; \
- std::ostringstream ost; \
- ost << "Conversion unexpectedly worked from max value of " \
- << *value.getDataType() << " to " << *toType.getDataType(); \
- FAIL() << ost.str(); \
- } catch (std::exception& e) { \
- EXPECT_EQ( \
- std::string("bad numeric conversion: positive overflow"), \
- std::string(e.what())); \
- } \
- /* Verify that we can convert to smaller type if value is within \
- range. Only tests integer to integer. No floating point. */ \
- if (!floating) { \
- totype::Number maxV = std::numeric_limits<totype::Number>::max(); \
- value.setValue((Number) maxV); \
- getter; \
- } \
- value.assign(*copy); \
-}
-
namespace {
template<typename Numeric>
@@ -258,25 +232,21 @@ namespace {
// representation can keep the value.
if (floatingPoint || sizeof(Number) > sizeof(unsigned char)) {
// No longer throws. This is guarded on the perimeter by java code.
- // ASSERT_FAILED_CONV(value.getAsByte(), ByteFieldValue, floatingPoint);
} else {
EXPECT_EQ((char) maxValue, value.getAsByte());
}
if (floatingPoint || sizeof(Number) > sizeof(int32_t)) {
// No longer throws. This is guarded on the perimeter by java code.
- // ASSERT_FAILED_CONV(value.getAsInt(), IntFieldValue, floatingPoint);
} else {
EXPECT_EQ((int32_t) maxValue, value.getAsInt());
}
if (floatingPoint || sizeof(Number) > sizeof(int64_t)) {
// No longer throws. This is guarded on the perimeter by java code.
- // ASSERT_FAILED_CONV(value.getAsLong(), LongFieldValue, floatingPoint);
} else {
EXPECT_EQ((int64_t) maxValue, value.getAsLong());
}
if (floatingPoint && sizeof(Number) > sizeof(float)) {
// No longer throws. This is guarded on the perimeter by java code.
- // ASSERT_FAILED_CONV(value.getAsFloat(), FloatFieldValue, true);
} else {
EXPECT_EQ((float) maxValue, value.getAsFloat());
}
@@ -303,30 +273,15 @@ TEST(PrimitiveFieldValueTest, testBool)
v = BoolFieldValue(true);
EXPECT_TRUE(v.getValue());
- v = 0;
- EXPECT_TRUE( ! v.getValue());
- v = 1;
- EXPECT_TRUE(v.getValue());
-
- v = INT64_C(0);
- EXPECT_TRUE( ! v.getValue());
- v = INT64_C(1);
- EXPECT_TRUE(v.getValue());
-
- v = 0.0f;
- EXPECT_TRUE( ! v.getValue());
- v = 1.0f;
- EXPECT_TRUE(v.getValue());
-
- v = 0.0;
- EXPECT_TRUE( ! v.getValue());
- v = 1.0;
+ v.setValue(false);
+ EXPECT_FALSE(v.getValue());
+ v.setValue(true);
EXPECT_TRUE(v.getValue());
v = vespalib::stringref("true");
EXPECT_TRUE(v.getValue());
v = vespalib::stringref("something not true");
- EXPECT_TRUE( ! v.getValue());
+ EXPECT_FALSE(v.getValue());
}
TEST(PrimitiveFieldValueTest, testNumerics)
diff --git a/document/src/tests/serialization/vespadocumentserializer_test.cpp b/document/src/tests/serialization/vespadocumentserializer_test.cpp
index d85d5240b64..33e8c521e09 100644
--- a/document/src/tests/serialization/vespadocumentserializer_test.cpp
+++ b/document/src/tests/serialization/vespadocumentserializer_test.cpp
@@ -1,6 +1,7 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
// Unit tests for vespadocumentserializer.
+#include <vespa/document/test/fieldvalue_helpers.h>
#include <vespa/document/annotation/annotation.h>
#include <vespa/document/annotation/span.h>
#include <vespa/document/annotation/spantree.h>
@@ -345,7 +346,7 @@ void checkArrayFieldValue(SizeType value_count) {
ArrayDataType array_type(*DataType::INT);
ArrayFieldValue value(array_type);
for (uint32_t i = 0; i < value_count; ++i) {
- value.add(static_cast<int32_t>(i));
+ CollectionHelper(value).add(static_cast<int32_t>(i));
}
nbostream stream;
diff --git a/document/src/tests/weightedsetfieldvaluetest.cpp b/document/src/tests/weightedsetfieldvaluetest.cpp
index 325267e9da6..61f727120d1 100644
--- a/document/src/tests/weightedsetfieldvaluetest.cpp
+++ b/document/src/tests/weightedsetfieldvaluetest.cpp
@@ -1,5 +1,6 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+#include <vespa/document/test/fieldvalue_helpers.h>
#include <vespa/document/fieldvalue/weightedsetfieldvalue.h>
#include <vespa/document/fieldvalue/arrayfieldvalue.h>
#include <vespa/document/fieldvalue/longfieldvalue.h>
@@ -255,7 +256,8 @@ TEST(WeightedSetFieldValueTest, testWeightedSet)
WeightedSetDataType mytype2(*DataType::STRING, true, true);
EXPECT_EQ(*DataType::TAG, static_cast<DataType &>(mytype2));
- WeightedSetFieldValue val1(mytype1);
+ WeightedSetFieldValue wsval1(mytype1);
+ WSetHelper val1(wsval1);
val1.add("foo", 4);
try{
val1.increment("bar", 2);
@@ -272,25 +274,26 @@ TEST(WeightedSetFieldValueTest, testWeightedSet)
val1.decrement("foo", 3);
EXPECT_EQ(7, val1.get("foo"));
val1.decrement("foo", 7);
- EXPECT_TRUE(val1.contains("foo"));
+ EXPECT_TRUE(CollectionHelper(wsval1).contains("foo"));
- WeightedSetFieldValue val2(mytype2);
+ WeightedSetFieldValue wsval2(mytype2);
+ WSetHelper val2(wsval2);
val2.add("foo", 4);
val2.increment("bar", 2);
EXPECT_EQ(2, val2.get("bar"));
val2.decrement("bar", 4);
EXPECT_EQ(-2, val2.get("bar"));
val2.increment("bar", 2);
- EXPECT_TRUE(!val2.contains("bar"));
+ EXPECT_TRUE(!CollectionHelper(wsval2).contains("bar"));
val2.decrement("foo", 4);
- EXPECT_TRUE(!val2.contains("foo"));
+ EXPECT_TRUE(!CollectionHelper(wsval2).contains("foo"));
val2.decrement("foo", 4);
EXPECT_EQ(-4, val2.get("foo"));
val2.add("foo", 0);
- EXPECT_TRUE(!val2.contains("foo"));
+ EXPECT_TRUE(!CollectionHelper(wsval2).contains("foo"));
}
}
@@ -301,12 +304,12 @@ TEST(WeightedSetFieldValueTest, testAddIgnoreZeroWeight)
WeightedSetFieldValue ws(wsetType);
ws.addIgnoreZeroWeight(StringFieldValue("yarn"), 0);
- EXPECT_TRUE(ws.contains("yarn"));
- EXPECT_EQ(0, ws.get("yarn"));
+ EXPECT_TRUE(CollectionHelper(ws).contains("yarn"));
+ EXPECT_EQ(0, WSetHelper(ws).get("yarn"));
ws.addIgnoreZeroWeight(StringFieldValue("flarn"), 1);
- EXPECT_TRUE(ws.contains("flarn"));
- EXPECT_EQ(1, ws.get("flarn"));
+ EXPECT_TRUE(CollectionHelper(ws).contains("flarn"));
+ EXPECT_EQ(1, WSetHelper(ws).get("flarn"));
}
} // document