blob: 7714644cad222619338930a39af3503d409a5646 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
/* $Id$*/
#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
|