zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit a55897106e34c55b02aeb5a5256e7da34f253de5 (tree)
parent 2a05ca1c9449fb26beaa948402e2742dee680137
Author: Layne Gustafson <lgustaf1@binghamton.edu>
Date:   Sat, 28 Mar 2020 20:40:26 -0400

Add macro string concat tests

Diffstat:
Mtest/translate_c.zig | 39+++++++++++++++++++++++++++++++++++++++
1 file changed, 39 insertions(+), 0 deletions(-)

diff --git a/test/translate_c.zig b/test/translate_c.zig @@ -2808,4 +2808,43 @@ pub fn addCases(cases: *tests.TranslateCContext) void { \\ return if (x > y) x else y; \\} }); + + cases.add("string concatenation in macros", + \\#define FOO "hello" + \\#define BAR FOO " world" + \\#define BAZ "oh, " FOO + , &[_][]const u8{ + \\pub const FOO = "hello"; + , + \\pub const BAR = FOO ++ " world"; + , + \\pub const BAZ = "oh, " ++ FOO; + }); + + cases.add("string concatenation in macros: two defines", + \\#define FOO "hello" + \\#define BAZ " world" + \\#define BAR FOO BAZ + , &[_][]const u8{ + \\pub const FOO = "hello"; + , + \\pub const BAZ = " world"; + , + \\pub const BAR = FOO ++ BAZ; + }); + + cases.add("string concatenation in macros: two strings", + \\#define FOO "a" "b" + \\#define BAR FOO "c" + , &[_][]const u8{ + \\pub const FOO = "a" ++ "b"; + , + \\pub const BAR = FOO ++ "c"; + }); + + cases.add("string concatenation in macros: three strings", + \\#define FOO "a" "b" "c" + , &[_][]const u8{ + \\pub const FOO = "a" ++ ("b" ++ "c"); + }); }