Skip to content

Commit b3aa70d

Browse files
authored
Add to_uppercase tests (#48)
Signed-off-by: RaulSanchez <raul@eprosima.com>
1 parent c756506 commit b3aa70d

3 files changed

Lines changed: 49 additions & 0 deletions

File tree

cpp_utils/test/unittest/macros/recursiveMacrosTest.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,23 @@ TEST(recursiveMacrosTest, apply_macro_for_each)
115115
ASSERT_EQ(hello, "hello");
116116
ASSERT_EQ(bye, "bye");
117117
}
118+
119+
#define TO_UPPERCASE(x) eprosima::utils::to_uppercase(x);
120+
121+
// string concatenation
122+
{
123+
std::string hello = "hello";
124+
std::string bye = "ByE";
125+
126+
APPLY_MACRO_FOR_EACH(
127+
TO_UPPERCASE,
128+
hello,
129+
bye
130+
);
131+
132+
ASSERT_EQ(hello, "HELLO");
133+
ASSERT_EQ(bye, "BYE");
134+
}
118135
}
119136

120137
int main(

cpp_utils/test/unittest/utils/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ set(TEST_LIST
2828
set_of_ptr_contains_string
2929
are_set_of_ptr_equal_int
3030
to_lowercase
31+
to_uppercase
3132
tsnh_call
3233
is_file_accessible
3334
combined_file_permissions

cpp_utils/test/unittest/utils/utilsTest.cpp

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,37 @@ TEST(utilsTest, to_lowercase)
328328
}
329329
}
330330

331+
/**
332+
* Test \c to_uppercase call
333+
*/
334+
TEST(utilsTest, to_uppercase)
335+
{
336+
// Uppercase
337+
{
338+
std::string str = "FOO";
339+
to_uppercase(str);
340+
ASSERT_EQ(str, "FOO");
341+
}
342+
// Invariant
343+
{
344+
std::string str = "foo";
345+
to_uppercase(str);
346+
ASSERT_EQ(str, "FOO");
347+
}
348+
// With non-letter characters
349+
{
350+
std::string str = "!_-.,FoO";
351+
to_uppercase(str);
352+
ASSERT_EQ(str, "!_-.,FOO");
353+
}
354+
// Empty
355+
{
356+
std::string str = "";
357+
to_uppercase(str);
358+
ASSERT_EQ(str, "");
359+
}
360+
}
361+
331362
/**
332363
* Test \c tsnh call
333364
*/

0 commit comments

Comments
 (0)