#include "testdata_source.h"
#include <libaddressinput/callback.h>
#include <libaddressinput/source.h>
#include <cstddef>
#include <memory>
#include <string>
#include <gtest/gtest.h>
#include "region_data_constants.h"
namespace {
BuildCallback;
kDataFileName;
RegionDataConstants;
Source;
TestdataSource;
class TestdataSourceTest : public testing::TestWithParam<std::string> { … };
testing::AssertionResult DataIsValid(const std::string& data,
const std::string& key) { … }
TEST_P(TestdataSourceTest, TestdataSourceHasValidDataForRegion) {
std::string key = "data/" + GetParam();
source_.Get(key, *data_ready_);
EXPECT_TRUE(success_);
EXPECT_EQ(key, key_);
EXPECT_TRUE(DataIsValid(data_, key));
};
TEST_P(TestdataSourceTest, TestdataSourceWithPathHasValidDataForRegion) {
std::string key = "data/" + GetParam();
source_with_path_.Get(key, *data_ready_);
EXPECT_TRUE(success_);
EXPECT_EQ(key, key_);
EXPECT_TRUE(DataIsValid(data_, key));
};
testing::AssertionResult AggregateDataIsValid(const std::string& data,
const std::string& key) { … }
TEST_P(TestdataSourceTest, TestdataSourceHasValidAggregatedDataForRegion) {
std::string key = "data/" + GetParam();
aggregate_source_.Get(key, *data_ready_);
EXPECT_TRUE(success_);
EXPECT_EQ(key, key_);
EXPECT_TRUE(AggregateDataIsValid(data_, key));
};
TEST_P(TestdataSourceTest,
TestdataSourceWithPathHasValidAggregatedDataForRegion) {
std::string key = "data/" + GetParam();
aggregate_source_with_path_.Get(key, *data_ready_);
EXPECT_TRUE(success_);
EXPECT_EQ(key, key_);
EXPECT_TRUE(AggregateDataIsValid(data_, key));
};
INSTANTIATE_TEST_SUITE_P(…);
TEST_F(TestdataSourceTest, GetExistingData) { … }
TEST_F(TestdataSourceTest, GetMissingKeyReturnsEmptyDictionary) { … }
TEST_F(TestdataSourceTest, AggregateGetMissingKeyReturnsEmptyDictionary) { … }
TEST_F(TestdataSourceTest, GetEmptyKeyReturnsEmptyDictionary) { … }
}