aboutsummaryrefslogtreecommitdiffstats
path: root/searchcommon
diff options
context:
space:
mode:
authorGeir Storli <geirst@verizonmedia.com>2019-05-02 13:02:09 +0000
committerGeir Storli <geirst@verizonmedia.com>2019-05-02 13:02:09 +0000
commitc1ea7086047619f75528b972c1c57eb463446ecd (patch)
tree290026676dd264adf3943fa9c135e6773d99612b /searchcommon
parent040450c5f83b98d221f4463fa36b70ee9e55f649 (diff)
Rewrite schema test to use gtest.
Diffstat (limited to 'searchcommon')
-rw-r--r--searchcommon/src/tests/schema/CMakeLists.txt1
-rw-r--r--searchcommon/src/tests/schema/schema_test.cpp267
2 files changed, 144 insertions, 124 deletions
diff --git a/searchcommon/src/tests/schema/CMakeLists.txt b/searchcommon/src/tests/schema/CMakeLists.txt
index a8e6ec311a3..aafe015d9a1 100644
--- a/searchcommon/src/tests/schema/CMakeLists.txt
+++ b/searchcommon/src/tests/schema/CMakeLists.txt
@@ -4,5 +4,6 @@ vespa_add_executable(searchcommon_schema_test_app TEST
schema_test.cpp
DEPENDS
searchcommon
+ gtest
)
vespa_add_test(NAME searchcommon_schema_test_app NO_VALGRIND COMMAND searchcommon_schema_test_app)
diff --git a/searchcommon/src/tests/schema/schema_test.cpp b/searchcommon/src/tests/schema/schema_test.cpp
index 790e5703109..4ebbd574fc3 100644
--- a/searchcommon/src/tests/schema/schema_test.cpp
+++ b/searchcommon/src/tests/schema/schema_test.cpp
@@ -1,10 +1,11 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-#include <vespa/vespalib/stllike/string.h>
-#include <fstream>
-#include <vespa/vespalib/testkit/test_kit.h>
#include <vespa/config/common/configparser.h>
-#include <vespa/searchcommon/common/schemaconfigurer.h>
#include <vespa/searchcommon/common/schema.h>
+#include <vespa/searchcommon/common/schemaconfigurer.h>
+#include <vespa/vespalib/gtest/gtest.h>
+#include <vespa/vespalib/stllike/string.h>
+#include <fstream>
+
#include <vespa/log/log.h>
LOG_SETUP("schema_test");
@@ -16,60 +17,67 @@ using schema::DataType;
using schema::CollectionType;
using SIAF = Schema::ImportedAttributeField;
-void assertField(const Schema::Field & exp, const Schema::Field & act) {
- EXPECT_EQUAL(exp.getName(), act.getName());
- EXPECT_EQUAL(exp.getDataType(), act.getDataType());
- EXPECT_EQUAL(exp.getCollectionType(), act.getCollectionType());
+void
+assertField(const Schema::Field& exp, const Schema::Field& act)
+{
+ EXPECT_EQ(exp.getName(), act.getName());
+ EXPECT_EQ(exp.getDataType(), act.getDataType());
+ EXPECT_EQ(exp.getCollectionType(), act.getCollectionType());
}
-void assertIndexField(const Schema::IndexField & exp,
- const Schema::IndexField & act)
+void
+assertIndexField(const Schema::IndexField& exp,
+ const Schema::IndexField& act)
{
assertField(exp, act);
- EXPECT_EQUAL(exp.getAvgElemLen(), act.getAvgElemLen());
+ EXPECT_EQ(exp.getAvgElemLen(), act.getAvgElemLen());
}
-void assertSet(const Schema::FieldSet &exp,
- const Schema::FieldSet &act)
+void
+assertSet(const Schema::FieldSet& exp,
+ const Schema::FieldSet& act)
{
- EXPECT_EQUAL(exp.getName(), act.getName());
- ASSERT_EQUAL(exp.getFields().size(), act.getFields().size());
+ EXPECT_EQ(exp.getName(), act.getName());
+ ASSERT_EQ(exp.getFields().size(), act.getFields().size());
for (size_t i = 0; i < exp.getFields().size(); ++i) {
- EXPECT_EQUAL(exp.getFields()[i], act.getFields()[i]);
+ EXPECT_EQ(exp.getFields()[i], act.getFields()[i]);
}
}
-void assertSchema(const Schema & exp, const Schema & act) {
- ASSERT_EQUAL(exp.getNumIndexFields(), act.getNumIndexFields());
+void
+assertSchema(const Schema& exp, const Schema& act)
+{
+ ASSERT_EQ(exp.getNumIndexFields(), act.getNumIndexFields());
for (size_t i = 0; i < exp.getNumIndexFields(); ++i) {
assertIndexField(exp.getIndexField(i), act.getIndexField(i));
}
- ASSERT_EQUAL(exp.getNumAttributeFields(), act.getNumAttributeFields());
+ ASSERT_EQ(exp.getNumAttributeFields(), act.getNumAttributeFields());
for (size_t i = 0; i < exp.getNumAttributeFields(); ++i) {
assertField(exp.getAttributeField(i), act.getAttributeField(i));
}
- ASSERT_EQUAL(exp.getNumSummaryFields(), act.getNumSummaryFields());
+ ASSERT_EQ(exp.getNumSummaryFields(), act.getNumSummaryFields());
for (size_t i = 0; i < exp.getNumSummaryFields(); ++i) {
assertField(exp.getSummaryField(i), act.getSummaryField(i));
}
- ASSERT_EQUAL(exp.getNumFieldSets(), act.getNumFieldSets());
+ ASSERT_EQ(exp.getNumFieldSets(), act.getNumFieldSets());
for (size_t i = 0; i < exp.getNumFieldSets(); ++i) {
assertSet(exp.getFieldSet(i), act.getFieldSet(i));
}
const auto &expImported = exp.getImportedAttributeFields();
const auto &actImported = act.getImportedAttributeFields();
- ASSERT_EQUAL(expImported.size(), actImported.size());
+ ASSERT_EQ(expImported.size(), actImported.size());
for (size_t i = 0; i < expImported.size(); ++i) {
assertField(expImported[i], actImported[i]);
}
}
-TEST("testBasic") {
+TEST(SchemaTest, test_basic)
+{
Schema s;
- EXPECT_EQUAL(0u, s.getNumIndexFields());
- EXPECT_EQUAL(0u, s.getNumAttributeFields());
- EXPECT_EQUAL(0u, s.getNumSummaryFields());
- EXPECT_EQUAL(0u, s.getNumImportedAttributeFields());
+ EXPECT_EQ(0u, s.getNumIndexFields());
+ EXPECT_EQ(0u, s.getNumAttributeFields());
+ EXPECT_EQ(0u, s.getNumSummaryFields());
+ EXPECT_EQ(0u, s.getNumImportedAttributeFields());
s.addIndexField(Schema::IndexField("foo", DataType::STRING));
s.addIndexField(Schema::IndexField("bar", DataType::INT32));
@@ -87,95 +95,96 @@ TEST("testBasic") {
s.addImportedAttributeField(SIAF("imported", DataType::INT32));
- EXPECT_EQUAL(2u, s.getNumIndexFields());
+ ASSERT_EQ(2u, s.getNumIndexFields());
{
- EXPECT_EQUAL("foo", s.getIndexField(0).getName());
- EXPECT_EQUAL(DataType::STRING, s.getIndexField(0).getDataType());
- EXPECT_EQUAL(CollectionType::SINGLE, s.getIndexField(0).getCollectionType());
+ EXPECT_EQ("foo", s.getIndexField(0).getName());
+ EXPECT_EQ(DataType::STRING, s.getIndexField(0).getDataType());
+ EXPECT_EQ(CollectionType::SINGLE, s.getIndexField(0).getCollectionType());
- EXPECT_EQUAL("bar", s.getIndexField(1).getName());
- EXPECT_EQUAL(DataType::INT32, s.getIndexField(1).getDataType());
- EXPECT_EQUAL(CollectionType::SINGLE, s.getIndexField(1).getCollectionType());
+ EXPECT_EQ("bar", s.getIndexField(1).getName());
+ EXPECT_EQ(DataType::INT32, s.getIndexField(1).getDataType());
+ EXPECT_EQ(CollectionType::SINGLE, s.getIndexField(1).getCollectionType());
- EXPECT_EQUAL(0u, s.getIndexFieldId("foo"));
- EXPECT_EQUAL(1u, s.getIndexFieldId("bar"));
- EXPECT_EQUAL(Schema::UNKNOWN_FIELD_ID, s.getIndexFieldId("cox"));
+ EXPECT_EQ(0u, s.getIndexFieldId("foo"));
+ EXPECT_EQ(1u, s.getIndexFieldId("bar"));
+ EXPECT_EQ(Schema::UNKNOWN_FIELD_ID, s.getIndexFieldId("cox"));
}
- EXPECT_EQUAL(3u, s.getNumAttributeFields());
+ ASSERT_EQ(3u, s.getNumAttributeFields());
{
- EXPECT_EQUAL("foo", s.getAttributeField(0).getName());
- EXPECT_EQUAL(DataType::STRING, s.getAttributeField(0).getDataType());
- EXPECT_EQUAL(CollectionType::ARRAY, s.getAttributeField(0).getCollectionType());
-
- EXPECT_EQUAL("bar", s.getAttributeField(1).getName());
- EXPECT_EQUAL(DataType::INT32, s.getAttributeField(1).getDataType());
- EXPECT_EQUAL(CollectionType::WEIGHTEDSET, s.getAttributeField(1).getCollectionType());
-
- EXPECT_EQUAL("cox", s.getAttributeField(2).getName());
- EXPECT_EQUAL(DataType::STRING, s.getAttributeField(2).getDataType());
- EXPECT_EQUAL(CollectionType::SINGLE, s.getAttributeField(2).getCollectionType());
-
- EXPECT_EQUAL(0u, s.getAttributeFieldId("foo"));
- EXPECT_EQUAL(1u, s.getAttributeFieldId("bar"));
- EXPECT_EQUAL(2u, s.getAttributeFieldId("cox"));
- EXPECT_EQUAL(Schema::UNKNOWN_FIELD_ID, s.getIndexFieldId("fox"));
+ EXPECT_EQ("foo", s.getAttributeField(0).getName());
+ EXPECT_EQ(DataType::STRING, s.getAttributeField(0).getDataType());
+ EXPECT_EQ(CollectionType::ARRAY, s.getAttributeField(0).getCollectionType());
+
+ EXPECT_EQ("bar", s.getAttributeField(1).getName());
+ EXPECT_EQ(DataType::INT32, s.getAttributeField(1).getDataType());
+ EXPECT_EQ(CollectionType::WEIGHTEDSET, s.getAttributeField(1).getCollectionType());
+
+ EXPECT_EQ("cox", s.getAttributeField(2).getName());
+ EXPECT_EQ(DataType::STRING, s.getAttributeField(2).getDataType());
+ EXPECT_EQ(CollectionType::SINGLE, s.getAttributeField(2).getCollectionType());
+
+ EXPECT_EQ(0u, s.getAttributeFieldId("foo"));
+ EXPECT_EQ(1u, s.getAttributeFieldId("bar"));
+ EXPECT_EQ(2u, s.getAttributeFieldId("cox"));
+ EXPECT_EQ(Schema::UNKNOWN_FIELD_ID, s.getIndexFieldId("fox"));
}
- EXPECT_EQUAL(4u, s.getNumSummaryFields());
+ ASSERT_EQ(4u, s.getNumSummaryFields());
{
- EXPECT_EQUAL("foo", s.getSummaryField(0).getName());
- EXPECT_EQUAL(DataType::STRING, s.getSummaryField(0).getDataType());
- EXPECT_EQUAL(CollectionType::ARRAY, s.getSummaryField(0).getCollectionType());
-
- EXPECT_EQUAL("bar", s.getSummaryField(1).getName());
- EXPECT_EQUAL(DataType::INT32, s.getSummaryField(1).getDataType());
- EXPECT_EQUAL(CollectionType::WEIGHTEDSET, s.getSummaryField(1).getCollectionType());
-
- EXPECT_EQUAL("cox", s.getSummaryField(2).getName());
- EXPECT_EQUAL(DataType::STRING, s.getSummaryField(2).getDataType());
- EXPECT_EQUAL(CollectionType::SINGLE, s.getSummaryField(2).getCollectionType());
-
- EXPECT_EQUAL("fox", s.getSummaryField(3).getName());
- EXPECT_EQUAL(DataType::RAW, s.getSummaryField(3).getDataType());
- EXPECT_EQUAL(CollectionType::SINGLE, s.getSummaryField(3).getCollectionType());
-
- EXPECT_EQUAL(0u, s.getSummaryFieldId("foo"));
- EXPECT_EQUAL(1u, s.getSummaryFieldId("bar"));
- EXPECT_EQUAL(2u, s.getSummaryFieldId("cox"));
- EXPECT_EQUAL(3u, s.getSummaryFieldId("fox"));
- EXPECT_EQUAL(Schema::UNKNOWN_FIELD_ID, s.getSummaryFieldId("not"));
+ EXPECT_EQ("foo", s.getSummaryField(0).getName());
+ EXPECT_EQ(DataType::STRING, s.getSummaryField(0).getDataType());
+ EXPECT_EQ(CollectionType::ARRAY, s.getSummaryField(0).getCollectionType());
+
+ EXPECT_EQ("bar", s.getSummaryField(1).getName());
+ EXPECT_EQ(DataType::INT32, s.getSummaryField(1).getDataType());
+ EXPECT_EQ(CollectionType::WEIGHTEDSET, s.getSummaryField(1).getCollectionType());
+
+ EXPECT_EQ("cox", s.getSummaryField(2).getName());
+ EXPECT_EQ(DataType::STRING, s.getSummaryField(2).getDataType());
+ EXPECT_EQ(CollectionType::SINGLE, s.getSummaryField(2).getCollectionType());
+
+ EXPECT_EQ("fox", s.getSummaryField(3).getName());
+ EXPECT_EQ(DataType::RAW, s.getSummaryField(3).getDataType());
+ EXPECT_EQ(CollectionType::SINGLE, s.getSummaryField(3).getCollectionType());
+
+ EXPECT_EQ(0u, s.getSummaryFieldId("foo"));
+ EXPECT_EQ(1u, s.getSummaryFieldId("bar"));
+ EXPECT_EQ(2u, s.getSummaryFieldId("cox"));
+ EXPECT_EQ(3u, s.getSummaryFieldId("fox"));
+ EXPECT_EQ(Schema::UNKNOWN_FIELD_ID, s.getSummaryFieldId("not"));
}
- EXPECT_EQUAL(1u, s.getNumFieldSets());
+ ASSERT_EQ(1u, s.getNumFieldSets());
{
- EXPECT_EQUAL("default", s.getFieldSet(0).getName());
- EXPECT_EQUAL(2u, s.getFieldSet(0).getFields().size());
- EXPECT_EQUAL("foo", s.getFieldSet(0).getFields()[0]);
- EXPECT_EQUAL("bar", s.getFieldSet(0).getFields()[1]);
+ EXPECT_EQ("default", s.getFieldSet(0).getName());
+ EXPECT_EQ(2u, s.getFieldSet(0).getFields().size());
+ EXPECT_EQ("foo", s.getFieldSet(0).getFields()[0]);
+ EXPECT_EQ("bar", s.getFieldSet(0).getFields()[1]);
}
- EXPECT_EQUAL(1u, s.getNumImportedAttributeFields());
+ EXPECT_EQ(1u, s.getNumImportedAttributeFields());
{
const auto &imported = s.getImportedAttributeFields();
- EXPECT_EQUAL(1u, imported.size());
- TEST_DO(assertField(SIAF("imported", DataType::INT32, CollectionType::SINGLE), imported[0]));
+ EXPECT_EQ(1u, imported.size());
+ assertField(SIAF("imported", DataType::INT32, CollectionType::SINGLE), imported[0]);
}
}
-TEST("testLoadAndSave") {
+TEST(SchemaTest, test_load_and_save)
+{
using SIF = Schema::IndexField;
using SAF = Schema::AttributeField;
using SSF = Schema::SummaryField;
using SDT = schema::DataType;
using SCT = schema::CollectionType;
- typedef Schema::FieldSet SFS;
+ using SFS = Schema::FieldSet;
{ // load from config -> save to file -> load from file
Schema s;
- SchemaConfigurer configurer(s, "dir:" + TEST_PATH("load-save-cfg"));
- EXPECT_EQUAL(3u, s.getNumIndexFields());
+ SchemaConfigurer configurer(s, "dir:load-save-cfg");
+ EXPECT_EQ(3u, s.getNumIndexFields());
assertIndexField(SIF("a", SDT::STRING), s.getIndexField(0));
assertIndexField(SIF("b", SDT::INT64), s.getIndexField(1));
assertIndexField(SIF("c", SDT::STRING), s.getIndexField(2));
- EXPECT_EQUAL(9u, s.getNumAttributeFields());
+ EXPECT_EQ(9u, s.getNumAttributeFields());
assertField(SAF("a", SDT::STRING, SCT::SINGLE),
s.getAttributeField(0));
assertField(SAF("b", SDT::INT8, SCT::ARRAY), s.getAttributeField(1));
@@ -188,7 +197,7 @@ TEST("testLoadAndSave") {
assertField(SAF("h", SDT::BOOLEANTREE), s.getAttributeField(7));
assertField(SAF("i", SDT::TENSOR), s.getAttributeField(8));
- EXPECT_EQUAL(12u, s.getNumSummaryFields());
+ EXPECT_EQ(12u, s.getNumSummaryFields());
assertField(SSF("a", SDT::INT8), s.getSummaryField(0));
assertField(SSF("b", SDT::INT16), s.getSummaryField(1));
assertField(SSF("c", SDT::INT32), s.getSummaryField(2));
@@ -202,7 +211,7 @@ TEST("testLoadAndSave") {
assertField(SSF("k", SDT::RAW), s.getSummaryField(10));
assertField(SSF("l", SDT::RAW), s.getSummaryField(11));
- EXPECT_EQUAL(1u, s.getNumFieldSets());
+ EXPECT_EQ(1u, s.getNumFieldSets());
assertSet(SFS("default").addField("a").addField("c"),
s.getFieldSet(0));
@@ -233,7 +242,8 @@ TEST("testLoadAndSave") {
}
}
-TEST("require that schema can save and load timestamps for fields") {
+TEST(SchemaTest, require_that_schema_can_save_and_load_timestamps_for_fields)
+{
const fastos::TimeStamp timestamp(42);
const std::string file_name = "schema-with-timestamps.txt";
Schema s;
@@ -243,11 +253,12 @@ TEST("require that schema can save and load timestamps for fields") {
ASSERT_TRUE(s.saveToFile(file_name));
Schema s2;
ASSERT_TRUE(s2.loadFromFile(file_name));
- ASSERT_EQUAL(1u, s2.getNumIndexFields());
- ASSERT_EQUAL(timestamp, s2.getIndexField(0).getTimestamp());
+ ASSERT_EQ(1u, s2.getNumIndexFields());
+ EXPECT_EQ(timestamp, s2.getIndexField(0).getTimestamp());
}
-TEST("require that timestamps are omitted when 0.") {
+TEST(SchemaTest, require_that_timestamps_are_omitted_when_0)
+{
const std::string file_name = "schema-without-timestamps.txt";
Schema s;
s.addIndexField(Schema::IndexField("foo", DataType::STRING));
@@ -258,16 +269,18 @@ TEST("require that timestamps are omitted when 0.") {
while (file) {
std::string line;
getline(file, line);
- EXPECT_NOT_EQUAL("indexfield[0].timestamp 0", line);
+ EXPECT_NE("indexfield[0].timestamp 0", line);
}
Schema s2;
ASSERT_TRUE(s2.loadFromFile(file_name));
- ASSERT_EQUAL(1u, s2.getNumIndexFields());
+ ASSERT_EQ(1u, s2.getNumIndexFields());
}
-void addAllFieldTypes(const string &name, Schema &schema,
- fastos::TimeStamp timestamp) {
+void
+addAllFieldTypes(const string& name, Schema& schema,
+ fastos::TimeStamp timestamp)
+{
Schema::IndexField index_field(name, DataType::STRING);
index_field.setTimestamp(timestamp);
schema.addIndexField(index_field);
@@ -283,7 +296,8 @@ void addAllFieldTypes(const string &name, Schema &schema,
schema.addFieldSet(Schema::FieldSet(name));
}
-TEST("require that schemas can be added") {
+TEST(SchemaTest, require_that_schemas_can_be_added)
+{
const string name1 = "foo";
const string name2 = "bar";
const fastos::TimeStamp timestamp1(42);
@@ -294,29 +308,30 @@ TEST("require that schemas can be added") {
addAllFieldTypes(name2, s2, timestamp2);
Schema::UP sum = Schema::make_union(s1, s2);
- ASSERT_EQUAL(2u, sum->getNumIndexFields());
+ ASSERT_EQ(2u, sum->getNumIndexFields());
EXPECT_TRUE(s1.getIndexField(0) ==
sum->getIndexField(sum->getIndexFieldId(name1)));
EXPECT_TRUE(s2.getIndexField(0) ==
sum->getIndexField(sum->getIndexFieldId(name2)));
- ASSERT_EQUAL(2u, sum->getNumAttributeFields());
+ ASSERT_EQ(2u, sum->getNumAttributeFields());
EXPECT_TRUE(s1.getAttributeField(0) ==
sum->getAttributeField(sum->getAttributeFieldId(name1)));
EXPECT_TRUE(s2.getAttributeField(0) ==
sum->getAttributeField(sum->getAttributeFieldId(name2)));
- ASSERT_EQUAL(2u, sum->getNumSummaryFields());
+ ASSERT_EQ(2u, sum->getNumSummaryFields());
EXPECT_TRUE(s1.getSummaryField(0) ==
sum->getSummaryField(sum->getSummaryFieldId(name1)));
EXPECT_TRUE(s2.getSummaryField(0) ==
sum->getSummaryField(sum->getSummaryFieldId(name2)));
- ASSERT_EQUAL(2u, sum->getNumFieldSets());
+ ASSERT_EQ(2u, sum->getNumFieldSets());
EXPECT_TRUE(s1.getFieldSet(0) ==
sum->getFieldSet(sum->getFieldSetId(name1)));
EXPECT_TRUE(s2.getFieldSet(0) ==
sum->getFieldSet(sum->getFieldSetId(name2)));
}
-TEST("require that S union S = S for schema S") {
+TEST(SchemaTest, require_that_S_union_S_equals_S_for_schema_S)
+{
Schema schema;
addAllFieldTypes("foo", schema, 42);
@@ -324,7 +339,8 @@ TEST("require that S union S = S for schema S") {
EXPECT_TRUE(schema == *sum);
}
-TEST("require that schema can calculate set_difference") {
+TEST(SchemaTest, require_that_schema_can_calculate_set_difference)
+{
const string name1 = "foo";
const string name2 = "bar";
const fastos::TimeStamp timestamp1(42);
@@ -342,7 +358,8 @@ TEST("require that schema can calculate set_difference") {
EXPECT_TRUE(expected == *schema);
}
-TEST("require that getOldFields returns a subset of a schema") {
+TEST(SchemaTest, require_that_get_old_fields_returns_a_subset_of_a_schema)
+{
Schema schema;
const int64_t limit_timestamp = 1000;
@@ -352,13 +369,14 @@ TEST("require that getOldFields returns a subset of a schema") {
Schema::UP old_fields =
schema.getOldFields(fastos::TimeStamp(limit_timestamp));
- EXPECT_EQUAL(1u, old_fields->getNumIndexFields());
- EXPECT_EQUAL("bar", old_fields->getIndexField(0).getName());
- EXPECT_EQUAL(1u, old_fields->getNumAttributeFields());
- EXPECT_EQUAL(1u, old_fields->getNumSummaryFields());
+ EXPECT_EQ(1u, old_fields->getNumIndexFields());
+ EXPECT_EQ("bar", old_fields->getIndexField(0).getName());
+ EXPECT_EQ(1u, old_fields->getNumAttributeFields());
+ EXPECT_EQ(1u, old_fields->getNumSummaryFields());
}
-TEST("require that schema can calculate intersection") {
+TEST(SchemaTest, require_that_schema_can_calculate_intersection)
+{
const string name1 = "foo";
const string name2 = "bar";
const string name3 = "baz";
@@ -378,18 +396,19 @@ TEST("require that schema can calculate intersection") {
EXPECT_TRUE(expected == *schema);
}
-TEST("require that incompatible fields are removed from intersection") {
+TEST(SchemaTest, require_that_incompatible_fields_are_removed_from_intersection)
+{
const string name = "foo";
Schema s1;
s1.addIndexField(Schema::IndexField(name, DataType::STRING));
Schema s2;
s2.addIndexField(Schema::IndexField(name, DataType::INT32));
Schema::UP schema = Schema::intersect(s1, s2);
- EXPECT_EQUAL(0u, schema->getNumIndexFields());
+ EXPECT_EQ(0u, schema->getNumIndexFields());
EXPECT_FALSE(schema->isIndexField(name));
}
-TEST("require that imported attribute fields are not saved to disk")
+TEST(SchemaTest, require_that_imported_attribute_fields_are_not_saved_to_disk)
{
const vespalib::string fileName = "schema-no-imported-fields.txt";
{
@@ -400,25 +419,25 @@ TEST("require that imported attribute fields are not saved to disk")
{
Schema s;
s.loadFromFile(fileName);
- EXPECT_EQUAL(0u, s.getNumImportedAttributeFields());
+ EXPECT_EQ(0u, s.getNumImportedAttributeFields());
}
}
-TEST("require that schema can be built with imported attribute fields")
+TEST(SchemaTest, require_that_schema_can_be_built_with_imported_attribute_fields)
{
Schema s;
- SchemaConfigurer configurer(s, "dir:" + TEST_PATH("imported-fields-cfg"));
+ SchemaConfigurer configurer(s, "dir:imported-fields-cfg");
const auto &imported = s.getImportedAttributeFields();
- EXPECT_EQUAL(2u, imported.size());
- TEST_DO(assertField(SIAF("imported_a", DataType::INT32, CollectionType::SINGLE), imported[0]));
- TEST_DO(assertField(SIAF("imported_b", DataType::STRING, CollectionType::ARRAY), imported[1]));
+ ASSERT_EQ(2u, imported.size());
+ assertField(SIAF("imported_a", DataType::INT32, CollectionType::SINGLE), imported[0]);
+ assertField(SIAF("imported_b", DataType::STRING, CollectionType::ARRAY), imported[1]);
const auto &regular = s.getAttributeFields();
- EXPECT_EQUAL(1u, regular.size());
- TEST_DO(assertField(SIAF("regular", DataType::INT32, CollectionType::SINGLE), regular[0]));
+ ASSERT_EQ(1u, regular.size());
+ assertField(SIAF("regular", DataType::INT32, CollectionType::SINGLE), regular[0]);
}
}
-TEST_MAIN() { TEST_RUN_ALL(); }
+GTEST_MAIN_RUN_ALL_TESTS()