| 76 | |
| 77 | template <typename ReprFunc> |
| 78 | void CheckTypeIdReprs(ReprFunc&& repr_func, bool expect_uppercase) { |
| 79 | std::unordered_set<std::string> unique_reprs; |
| 80 | const auto all_ids = AllTypeIds(); |
| 81 | for (const auto id : all_ids) { |
| 82 | std::string repr = repr_func(id); |
| 83 | ASSERT_TRUE(std::all_of(repr.begin(), repr.end(), |
| 84 | [=](const char c) { |
| 85 | return c == '_' || std::isdigit(c) || |
| 86 | (expect_uppercase ? std::isupper(c) |
| 87 | : std::islower(c)); |
| 88 | })) |
| 89 | << "Invalid type id repr: '" << repr << "'"; |
| 90 | unique_reprs.insert(std::move(repr)); |
| 91 | } |
| 92 | // No duplicates |
| 93 | ASSERT_EQ(unique_reprs.size(), all_ids.size()); |
| 94 | } |
| 95 | |
| 96 | TEST(TestTypeId, ToString) { |
| 97 | // Should be all uppercase strings (corresponding to the enum member names) |