summaryrefslogtreecommitdiffstats
path: root/searchlib/src/tests/attribute/attribute_operation/attribute_operation_test.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'searchlib/src/tests/attribute/attribute_operation/attribute_operation_test.cpp')
-rw-r--r--searchlib/src/tests/attribute/attribute_operation/attribute_operation_test.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/searchlib/src/tests/attribute/attribute_operation/attribute_operation_test.cpp b/searchlib/src/tests/attribute/attribute_operation/attribute_operation_test.cpp
index 12bac6c6b20..bdd5682acb6 100644
--- a/searchlib/src/tests/attribute/attribute_operation/attribute_operation_test.cpp
+++ b/searchlib/src/tests/attribute/attribute_operation/attribute_operation_test.cpp
@@ -45,10 +45,11 @@ TEST("test illegal operations on float attribute") {
}
AttributeVector::SP
-createAttribute(BasicType basicType, const vespalib::string &fieldName, bool fastSearch = false)
+createAttribute(BasicType basicType, const vespalib::string &fieldName, bool fastSearch = false, bool immutable = false)
{
Config cfg(basicType, CollectionType::SINGLE);
- cfg.setFastSearch(fastSearch);
+ cfg.setMutable(!immutable)
+ .setFastSearch(fastSearch);
auto av = search::AttributeFactory::createAttribute(fieldName, cfg);
while (20 >= av->getNumDocs()) {
AttributeVector::DocId checkDocId(0u);
@@ -176,4 +177,11 @@ TEST("test that fastsearch attributes will fail to update") {
}
}
+TEST("test that immutable attributes will fail to update") {
+ auto attr = createAttribute(BasicType::INT64, "ai", true, false);
+ for (auto operation : {"++", "--", "+=7", "-=9", "*=3", "/=3", "%=3"}) {
+ TEST_DO(verify<int64_t>(BasicType::INT64, operation, *attr, 7, 7));
+ }
+}
+
TEST_MAIN() { TEST_RUN_ALL(); }