aboutsummaryrefslogtreecommitdiffstats
path: root/document/src/tests/positiontypetest.cpp
blob: 3c308563029dc5b2ac06290f2d526497df93015b (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
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include <vespa/document/datatype/positiondatatype.h>
#include <gtest/gtest.h>

namespace document {

TEST(PositionTypeTest, requireThatNameIsCorrect)
{
    const StructDataType &type = PositionDataType::getInstance();
    EXPECT_EQ(vespalib::string("position"), type.getName());
}

TEST(PositionTypeTest, requireThatExpectedFieldsAreThere)
{
    const StructDataType &type = PositionDataType::getInstance();
    Field field = type.getField("x");
    EXPECT_EQ(*DataType::INT, field.getDataType());

    field = type.getField("y");
    EXPECT_EQ(*DataType::INT, field.getDataType());
}

TEST(PositionTypeTest, requireThatZCurveFieldMatchesJava)
{
    EXPECT_EQ(vespalib::string("foo_zcurve"), PositionDataType::getZCurveFieldName("foo"));
    EXPECT_TRUE( ! PositionDataType::isZCurveFieldName("foo"));
    EXPECT_TRUE( ! PositionDataType::isZCurveFieldName("_zcurve"));
    EXPECT_TRUE( PositionDataType::isZCurveFieldName("x_zcurve"));
    EXPECT_TRUE( ! PositionDataType::isZCurveFieldName("x_zcurvex"));
    EXPECT_EQ(vespalib::stringref("x"), PositionDataType::cutZCurveFieldName("x_zcurve"));
}

} // document