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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
|
// 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/vespalib/testkit/test_kit.h>
#include <vespa/searchcommon/attribute/config.h>
using search::attribute::Config;
using search::attribute::BasicType;
using search::attribute::CollectionType;
using vespalib::eval::ValueType;
struct Fixture
{
Config _config;
Fixture()
: _config()
{
}
Fixture(BasicType bt,
CollectionType ct = CollectionType::SINGLE,
bool fastSearch_ = false,
bool huge_ = false)
: _config(bt, ct, fastSearch_, huge_)
{
}
};
TEST_F("test default attribute config", Fixture)
{
EXPECT_EQUAL(BasicType::Type::NONE, f._config.basicType().type());
EXPECT_EQUAL(CollectionType::Type::SINGLE,
f._config.collectionType().type());
EXPECT_TRUE(!f._config.fastSearch());
EXPECT_TRUE(!f._config.huge());
EXPECT_TRUE(!f._config.getEnableBitVectors());
EXPECT_TRUE(!f._config.getEnableOnlyBitVector());
EXPECT_TRUE(!f._config.getIsFilter());
EXPECT_TRUE(!f._config.fastAccess());
EXPECT_TRUE(f._config.tensorType().is_error());
}
TEST_F("test integer weightedset attribute config",
Fixture(BasicType::Type::INT32,
CollectionType::Type::WSET))
{
EXPECT_EQUAL(BasicType::Type::INT32, f._config.basicType().type());
EXPECT_EQUAL(CollectionType::Type::WSET,
f._config.collectionType().type());
EXPECT_TRUE(!f._config.fastSearch());
EXPECT_TRUE(!f._config.huge());
EXPECT_TRUE(!f._config.getEnableBitVectors());
EXPECT_TRUE(!f._config.getEnableOnlyBitVector());
EXPECT_TRUE(!f._config.getIsFilter());
EXPECT_TRUE(!f._config.fastAccess());
EXPECT_TRUE(f._config.tensorType().is_error());
}
TEST("test operator== on attribute config")
{
Config cfg1(BasicType::Type::INT32, CollectionType::Type::WSET);
Config cfg2(BasicType::Type::INT32, CollectionType::Type::ARRAY);
Config cfg3(BasicType::Type::INT32, CollectionType::Type::WSET);
EXPECT_TRUE(cfg1 != cfg2);
EXPECT_TRUE(cfg2 != cfg3);
EXPECT_TRUE(cfg1 == cfg3);
}
TEST("test operator== on attribute config for tensor type")
{
Config cfg1(BasicType::Type::TENSOR);
Config cfg2(BasicType::Type::TENSOR);
Config cfg3(BasicType::Type::TENSOR);
ValueType dense_x = ValueType::from_spec("tensor(x[10])");
ValueType sparse_x = ValueType::from_spec("tensor(x{})");
EXPECT_TRUE(cfg1 == cfg2);
EXPECT_TRUE(cfg2 == cfg3);
EXPECT_TRUE(cfg1 == cfg3);
cfg1.setTensorType(dense_x);
cfg3.setTensorType(dense_x);
EXPECT_EQUAL(dense_x, cfg1.tensorType());
EXPECT_EQUAL(dense_x, cfg3.tensorType());
EXPECT_TRUE(!cfg1.tensorType().is_error());
EXPECT_TRUE(cfg2.tensorType().is_error());
EXPECT_TRUE(!cfg3.tensorType().is_error());
EXPECT_TRUE(cfg1 != cfg2);
EXPECT_TRUE(cfg2 != cfg3);
EXPECT_TRUE(cfg1 == cfg3);
cfg3.setTensorType(sparse_x);
EXPECT_EQUAL(sparse_x, cfg3.tensorType());
EXPECT_TRUE(!cfg3.tensorType().is_error());
EXPECT_TRUE(cfg1 != cfg3);
}
TEST_MAIN() { TEST_RUN_ALL(); }
|