Skip to content

Commit 83e2756

Browse files
committed
Add unit test of existing type_name2type_identifier behaviour
In order to quickly test that no regressions have occured as part of adding extra functionality.
1 parent 7a20ab6 commit 83e2756

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

unit/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ SRC += analyses/ai/ai.cpp \
1515
analyses/does_remove_const/does_type_preserve_const_correctness.cpp \
1616
analyses/does_remove_const/is_type_at_least_as_const_as.cpp \
1717
ansi-c/max_malloc_size.cpp \
18+
ansi-c/type2name.cpp \
1819
big-int/big-int.cpp \
1920
compound_block_locations.cpp \
2021
get_goto_model_from_c_test.cpp \

unit/ansi-c/type2name.cpp

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*******************************************************************\
2+
3+
Module: Unit tests for type_name2type_identifier
4+
5+
Author: Thomas Spriggs
6+
7+
\*******************************************************************/
8+
9+
#include <testing-utils/use_catch.h>
10+
11+
extern std::string type_name2type_identifier(const std::string &name);
12+
13+
TEST_CASE(
14+
"type_name2type_identifier sanity check",
15+
"[core][ansi-c][type_name2type_identifier]")
16+
{
17+
CHECK(type_name2type_identifier("char") == "char");
18+
}
19+
20+
TEST_CASE(
21+
"type_name2type_identifier special characters",
22+
"[core][ansi-c][type_name2type_identifier]")
23+
{
24+
CHECK(type_name2type_identifier("char*") == "char_ptr_");
25+
CHECK(type_name2type_identifier("foo{bar}") == "foo_start_sub_bar_end_sub_");
26+
}

0 commit comments

Comments
 (0)