Skip to content

Instantly share code, notes, and snippets.

@Masterkatze
Last active June 17, 2020 08:10
Show Gist options
  • Save Masterkatze/97900fbeabe7af80cbde9aad6f5a74a4 to your computer and use it in GitHub Desktop.
Save Masterkatze/97900fbeabe7af80cbde9aad6f5a74a4 to your computer and use it in GitHub Desktop.
template <class T, class M> M GetFieldType(M T::*);
template <typename T>
void GenerateTest(DataType::Processed container,
const std::string &container_name, T field,
const std::string &field_name) {
std::set<decltype(GetFieldType(field))> values;
for (const auto &data_type : container) {
values.emplace(data_type.second.*field);
}
for (const auto &value : values) {
std::cout << "EXPECT_EQ(Count(" << container_name
<< ", &DataType::" << field_name << ", " << value << "), "
<< Count(container, field, value) << ");" << std::endl;
}
std::cout << std::endl;
}
template <typename T>
void PrintValues(DataType::Processed container, const std::string &name,
T field) {
std::set<decltype(GetFieldType(field))> values;
for (const auto &data_type : container) {
values.emplace(data_type.second.*field);
}
for (const auto &value : values) {
std::cout << "\"" << name << "\"=\"" << value
<< "\" : " << Count(container, field, value) << std::endl;
}
std::cout << std::endl;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment