authorgravatar for lgustaf1@binghamton.eduLayne Gustafson <lgustaf1@binghamton.edu> 2020-03-28 20:40:26-04:00
committergravatar for lgustaf1@binghamton.eduLayne Gustafson <lgustaf1@binghamton.edu> 2020-03-28 20:40:26-04:00
loga55897106e34c55b02aeb5a5256e7da34f253de5
tree2672a4f3c90eb5deb9c4be88a6a2eb70d60c2b50
parent2a05ca1c9449fb26beaa948402e2742dee680137

Add macro string concat tests


1 files changed, 39 insertions(+), 0 deletions(-)

test/translate_c.zig+39
......@@ -2808,4 +2808,43 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
28082808 \\ return if (x > y) x else y;
28092809 \\}
28102810 });
2811
2812 cases.add("string concatenation in macros",
2813 \\#define FOO "hello"
2814 \\#define BAR FOO " world"
2815 \\#define BAZ "oh, " FOO
2816 , &[_][]const u8{
2817 \\pub const FOO = "hello";
2818 ,
2819 \\pub const BAR = FOO ++ " world";
2820 ,
2821 \\pub const BAZ = "oh, " ++ FOO;
2822 });
2823
2824 cases.add("string concatenation in macros: two defines",
2825 \\#define FOO "hello"
2826 \\#define BAZ " world"
2827 \\#define BAR FOO BAZ
2828 , &[_][]const u8{
2829 \\pub const FOO = "hello";
2830 ,
2831 \\pub const BAZ = " world";
2832 ,
2833 \\pub const BAR = FOO ++ BAZ;
2834 });
2835
2836 cases.add("string concatenation in macros: two strings",
2837 \\#define FOO "a" "b"
2838 \\#define BAR FOO "c"
2839 , &[_][]const u8{
2840 \\pub const FOO = "a" ++ "b";
2841 ,
2842 \\pub const BAR = FOO ++ "c";
2843 });
2844
2845 cases.add("string concatenation in macros: three strings",
2846 \\#define FOO "a" "b" "c"
2847 , &[_][]const u8{
2848 \\pub const FOO = "a" ++ ("b" ++ "c");
2849 });
28112850}