aboutsummaryrefslogtreecommitdiffstats
path: root/document/src/tests/fieldvalue/document_test.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'document/src/tests/fieldvalue/document_test.cpp')
-rw-r--r--document/src/tests/fieldvalue/document_test.cpp31
1 files changed, 31 insertions, 0 deletions
diff --git a/document/src/tests/fieldvalue/document_test.cpp b/document/src/tests/fieldvalue/document_test.cpp
new file mode 100644
index 00000000000..51216c6d77a
--- /dev/null
+++ b/document/src/tests/fieldvalue/document_test.cpp
@@ -0,0 +1,31 @@
+// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+// Unit tests for document.
+
+#include <vespa/log/log.h>
+LOG_SETUP("document_test");
+#include <vespa/fastos/fastos.h>
+
+#include <vespa/document/base/documentid.h>
+#include <vespa/document/base/testdocrepo.h>
+#include <vespa/document/fieldvalue/document.h>
+#include <vespa/vespalib/testkit/testapp.h>
+
+using namespace document;
+
+namespace {
+
+TEST("require that document with id schema 'id' checks type") {
+ TestDocRepo repo;
+ const DataType *type = repo.getDocumentType("testdoctype1");
+ ASSERT_TRUE(type);
+
+ Document(*type, DocumentId("id:ns:testdoctype1::")); // Should not throw
+
+ EXPECT_EXCEPTION(Document(*type, DocumentId("id:ns:type::")),
+ vespalib::IllegalArgumentException,
+ "testdoctype1 that don't match the id (type type)");
+}
+
+} // namespace
+
+TEST_MAIN() { TEST_RUN_ALL(); }