aboutsummaryrefslogtreecommitdiffstats
path: root/searchcore/src/tests/proton/common/document_type_inspector/document_type_inspector_test.cpp
blob: 8f4d6f1f2fee93e6b0766d1f862e168103d58289 (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
// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include <vespa/fastos/fastos.h>
#include <vespa/searchcore/proton/common/document_type_inspector.h>
#include <vespa/searchlib/index/docbuilder.h>
#include <vespa/vespalib/testkit/testapp.h>

using namespace document;
using namespace proton;
using namespace search::index;

Schema
getSchema()
{
    Schema schema;
    schema.addSummaryField(Schema::SummaryField("f1", schema::STRING));
    schema.addSummaryField(Schema::SummaryField("f2", schema::STRING));
    return schema;
}

struct Fixture
{
    Schema _schema;
    DocBuilder _builder;
    DocumentTypeInspector _inspector;
    Fixture()
        : _schema(getSchema()),
          _builder(_schema),
          _inspector(_builder.getDocumentType())
    {
    }
};

TEST_F("require that existing fields are known", Fixture)
{
    EXPECT_TRUE(f._inspector.hasField("f1"));
    EXPECT_TRUE(f._inspector.hasField("f2"));
}

TEST_F("require that non-existing fields are NOT known", Fixture)
{
    EXPECT_FALSE(f._inspector.hasField("not"));
}

TEST_MAIN()
{
    TEST_RUN_ALL();
}