From ed86958cf65226a246cf4b8532e5f5e904a4b05d Mon Sep 17 00:00:00 2001 From: Henning Baldersheim Date: Tue, 25 Jul 2017 19:47:35 +0200 Subject: We are not java so we do not need these sanity checks. valgrind will do them just fine. Remove the tests --- document/src/tests/arrayfieldvaluetest.cpp | 11 ----------- document/src/tests/structfieldvaluetest.cpp | 9 --------- document/src/vespa/document/datatype/collectiondatatype.h | 2 +- document/src/vespa/document/fieldvalue/arrayfieldvalue.cpp | 14 +++++--------- document/src/vespa/document/fieldvalue/fieldvalue.cpp | 2 ++ document/src/vespa/document/fieldvalue/mapfieldvalue.cpp | 3 +-- .../src/vespa/document/fieldvalue/structfieldvalue.cpp | 5 ----- 7 files changed, 9 insertions(+), 37 deletions(-) (limited to 'document') diff --git a/document/src/tests/arrayfieldvaluetest.cpp b/document/src/tests/arrayfieldvaluetest.cpp index c9a35bacf1c..8e1cbfafb43 100644 --- a/document/src/tests/arrayfieldvaluetest.cpp +++ b/document/src/tests/arrayfieldvaluetest.cpp @@ -161,17 +161,6 @@ void ArrayFieldValueTest::testArray() // Failure situations. - // Refuse to accept non-array types - try{ - ArrayFieldValue value6(*DataType::TAG); - CPPUNIT_FAIL("Didn't complain about non-array type"); - } catch (std::exception& e) { - fprintf(stderr, "Exception = %s\n", e.what()); - CPPUNIT_ASSERT_CONTAIN( - "Cannot generate an array value with non-array type", - e.what()); - } - // Verify that datatypes are verified // Created almost equal types to try to get it to fail ArrayDataType type1(*DataType::INT); diff --git a/document/src/tests/structfieldvaluetest.cpp b/document/src/tests/structfieldvaluetest.cpp index 38e915ec82d..9fffe1d630f 100644 --- a/document/src/tests/structfieldvaluetest.cpp +++ b/document/src/tests/structfieldvaluetest.cpp @@ -193,15 +193,6 @@ void StructFieldValueTest::testStruct() // Failure situations. - // Refuse to accept non-struct types - try{ - StructFieldValue value6(*DataType::DOCUMENT); - CPPUNIT_FAIL("Didn't complain about non-struct type"); - } catch (std::exception& e) { - CPPUNIT_ASSERT_CONTAIN("Cannot generate a struct value with " - "non-struct type", e.what()); - } - // Refuse to set wrong types try{ value2.setValue(intF, StringFieldValue("bar")); diff --git a/document/src/vespa/document/datatype/collectiondatatype.h b/document/src/vespa/document/datatype/collectiondatatype.h index 04fcb0f5be4..0e258e3e0cf 100644 --- a/document/src/vespa/document/datatype/collectiondatatype.h +++ b/document/src/vespa/document/datatype/collectiondatatype.h @@ -9,7 +9,7 @@ */ #pragma once -#include +#include "datatype.h" namespace document { diff --git a/document/src/vespa/document/fieldvalue/arrayfieldvalue.cpp b/document/src/vespa/document/fieldvalue/arrayfieldvalue.cpp index 1173ed6df8d..85fd031ac10 100644 --- a/document/src/vespa/document/fieldvalue/arrayfieldvalue.cpp +++ b/document/src/vespa/document/fieldvalue/arrayfieldvalue.cpp @@ -12,6 +12,7 @@ LOG_SETUP(".document.fieldvalue.array"); using namespace vespalib::xml; +using vespalib::make_string; namespace document { @@ -27,11 +28,6 @@ ArrayFieldValue::ArrayFieldValue(const DataType &type) : CollectionFieldValue(type), _array() { - if (!type.inherits(ArrayDataType::classId)) { - throw IllegalArgumentException( - "Cannot generate an array value with non-array type " - + type.toString() + ".", VESPA_STRLOC); - } _array.reset(static_cast(createArray(getNestedType()).release())); } @@ -60,7 +56,7 @@ void ArrayFieldValue::remove(uint32_t index) { if (_array->size() <= index) { - throw IllegalArgumentException(vespalib::make_string( + throw IllegalArgumentException(make_string( "Cannot remove index %u from an array of size %lu.", index, (unsigned long)_array->size()), VESPA_STRLOC); } @@ -73,7 +69,7 @@ ArrayFieldValue::addValue(const FieldValue& value) if (getNestedType().isValueType(value)) { _array->push_back(value); } else { - throw IllegalArgumentException(vespalib::make_string( + throw IllegalArgumentException(make_string( "Cannot add value of type %s to array containing type %s.", value.getDataType()->toString().c_str(), getNestedType().toString().c_str()), VESPA_STRLOC); @@ -92,7 +88,7 @@ ArrayFieldValue::containsValue(const FieldValue& value) const } return false; } else { - throw IllegalArgumentException(vespalib::make_string( + throw IllegalArgumentException(make_string( "Value of type %s can't possibly be in array of type %s.", value.getDataType()->toString().c_str(), getDataType()->toString().c_str()), VESPA_STRLOC); @@ -114,7 +110,7 @@ ArrayFieldValue::removeValue(const FieldValue& value) } return (oldSize != _array->size()); } else { - throw IllegalArgumentException(vespalib::make_string( + throw IllegalArgumentException(make_string( "Value of type %s can't possibly be in array of type %s.", value.getDataType()->toString().c_str(), getDataType()->toString().c_str()), VESPA_STRLOC); diff --git a/document/src/vespa/document/fieldvalue/fieldvalue.cpp b/document/src/vespa/document/fieldvalue/fieldvalue.cpp index 903922c0992..979a6316e45 100644 --- a/document/src/vespa/document/fieldvalue/fieldvalue.cpp +++ b/document/src/vespa/document/fieldvalue/fieldvalue.cpp @@ -217,6 +217,7 @@ using vespalib::ComplexArrayT; using vespalib::PrimitiveArrayT; namespace { + class FieldValueFactory : public ComplexArrayT::Factory { public: @@ -226,6 +227,7 @@ public: private: DataType::CP _dataType; }; + } std::unique_ptr diff --git a/document/src/vespa/document/fieldvalue/mapfieldvalue.cpp b/document/src/vespa/document/fieldvalue/mapfieldvalue.cpp index 750bb8d3bab..2b0463d39e6 100644 --- a/document/src/vespa/document/fieldvalue/mapfieldvalue.cpp +++ b/document/src/vespa/document/fieldvalue/mapfieldvalue.cpp @@ -27,8 +27,7 @@ namespace { const MapDataType *verifyMapType(const DataType& type) { const MapDataType *ptr(Identifiable::cast(&type)); if (!ptr) { - throw vespalib::IllegalArgumentException( - "Datatype given is not a map type", VESPA_STRLOC); + throw vespalib::IllegalArgumentException("Datatype given is not a map type", VESPA_STRLOC); } return ptr; } diff --git a/document/src/vespa/document/fieldvalue/structfieldvalue.cpp b/document/src/vespa/document/fieldvalue/structfieldvalue.cpp index f4afd843896..adb6fb9fa4e 100644 --- a/document/src/vespa/document/fieldvalue/structfieldvalue.cpp +++ b/document/src/vespa/document/fieldvalue/structfieldvalue.cpp @@ -33,11 +33,6 @@ StructFieldValue::StructFieldValue(const DataType &type) _version(Document::getNewestSerializationVersion()), _hasChanged(true) { - if (!type.getClass().inherits(StructDataType::classId)) { - throw vespalib::IllegalArgumentException( - "Cannot generate a struct value with non-struct type " - + type.toString() + ".", VESPA_STRLOC); - } } StructFieldValue::~StructFieldValue() { } -- cgit v1.2.3