aboutsummaryrefslogtreecommitdiffstats
path: root/document/src/tests/testdocmantest.cpp
diff options
context:
space:
mode:
authorJon Bratseth <bratseth@yahoo-inc.com>2016-06-15 23:09:44 +0200
committerJon Bratseth <bratseth@yahoo-inc.com>2016-06-15 23:09:44 +0200
commit72231250ed81e10d66bfe70701e64fa5fe50f712 (patch)
tree2728bba1131a6f6e5bdf95afec7d7ff9358dac50 /document/src/tests/testdocmantest.cpp
Publish
Diffstat (limited to 'document/src/tests/testdocmantest.cpp')
-rw-r--r--document/src/tests/testdocmantest.cpp62
1 files changed, 62 insertions, 0 deletions
diff --git a/document/src/tests/testdocmantest.cpp b/document/src/tests/testdocmantest.cpp
new file mode 100644
index 00000000000..14140b4b508
--- /dev/null
+++ b/document/src/tests/testdocmantest.cpp
@@ -0,0 +1,62 @@
+// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+
+/* $Id$*/
+
+#include <vespa/fastos/fastos.h>
+#include <iostream>
+#include <set>
+#include <sstream>
+#include <vespa/document/base/testdocman.h>
+#include <vespa/vdstestlib/cppunit/macros.h>
+
+namespace document {
+
+class TestDocManTest : public CppUnit::TestFixture {
+ CPPUNIT_TEST_SUITE(TestDocManTest);
+ CPPUNIT_TEST(testSimpleUsage);
+ CPPUNIT_TEST_SUITE_END();
+
+protected:
+ void testSimpleUsage();
+};
+
+CPPUNIT_TEST_SUITE_REGISTRATION(TestDocManTest);
+
+void TestDocManTest::testSimpleUsage()
+{
+ TestDocMan testdm;
+ Document::UP doc1(testdm.createRandomDocument());
+ Document::UP doc2(testdm.createRandomDocument());
+ Document::UP doc3(testdm.createRandomDocument(1));
+ {
+ FieldValue::UP v(doc1->getValue(doc1->getField("content")));
+ StringFieldValue& sval(dynamic_cast<StringFieldValue&>(*v));
+ CPPUNIT_ASSERT_EQUAL(std::string("To be, or "),
+ std::string(sval.getValue().c_str()));
+
+ FieldValue::UP v2(doc2->getValue(doc2->getField("content")));
+ StringFieldValue& sval2(dynamic_cast<StringFieldValue&>(*v));
+ CPPUNIT_ASSERT_EQUAL(std::string(sval.getValue().c_str()),
+ std::string(sval2.getValue().c_str()));
+ }
+ {
+ FieldValue::UP v(doc3->getValue(doc3->getField("content")));
+ StringFieldValue& sval(dynamic_cast<StringFieldValue&>(*v));
+ CPPUNIT_ASSERT_EQUAL(
+ std::string("To be, or not to be: that is the question:\n"
+ "Whether 'tis nobler in the mind to suffer\n"
+ "The slings and a"),
+ std::string(sval.getValue().c_str()));
+ }
+ CPPUNIT_ASSERT_EQUAL(
+ vespalib::string("id:mail:testdoctype1:n=51019:192.html"),
+ doc1->getId().toString());
+ CPPUNIT_ASSERT_EQUAL(
+ vespalib::string("id:mail:testdoctype1:n=51019:192.html"),
+ doc2->getId().toString());
+ CPPUNIT_ASSERT_EQUAL(
+ vespalib::string("id:mail:testdoctype1:n=10744:245.html"),
+ doc3->getId().toString());
+}
+
+} // document