Skip to content

Commit b403b84

Browse files
committed
Add additional unit tests for GetNamespace to cover varied namespace extraction scenarios
1 parent ccaf524 commit b403b84

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

modules/core/util/tests/util.cpp

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,36 @@ TEST(GetNamespaceTest, ReturnsEmptyIfNoNamespace_PlainStruct) {
4646
constexpr auto kNs = ppc::util::GetNamespace<PlainType>();
4747
EXPECT_EQ(kNs, "");
4848
}
49+
50+
namespace test_ns {
51+
struct Nested {};
52+
} // namespace test_ns
53+
54+
TEST(GetNamespaceTest, ReturnsNamespaceCorrectly) {
55+
constexpr auto kNs = ppc::util::GetNamespace<test_ns::Nested>();
56+
EXPECT_EQ(kNs, "test_ns");
57+
}
58+
59+
struct NoNamespaceType {};
60+
61+
TEST(GetNamespaceTest, NoNamespaceInType) {
62+
constexpr auto kNs = ppc::util::GetNamespace<NoNamespaceType>();
63+
EXPECT_EQ(kNs, "");
64+
}
65+
66+
template <typename T>
67+
struct NotATemplate {};
68+
69+
TEST(GetNamespaceTest, NoKeyInPrettyFunction) {
70+
constexpr auto kNs = ppc::util::GetNamespace<NotATemplate<void>>();
71+
EXPECT_EQ(kNs, "");
72+
}
73+
74+
namespace crazy {
75+
struct VeryLongTypeNameWithOnlyLettersAndUnderscores {};
76+
} // namespace crazy
77+
78+
TEST(GetNamespaceTest, NoTerminatorCharactersInPrettyFunction) {
79+
constexpr auto kNs = ppc::util::GetNamespace<crazy::VeryLongTypeNameWithOnlyLettersAndUnderscores>();
80+
EXPECT_EQ(kNs, "crazy");
81+
}

0 commit comments

Comments
 (0)