commit eca294cd23b3b1cdb4a94fb37dfe52eeb0a7c51d (tree)
parent cd39f6df957886f4b40a30b3bd02148abcac16b0
Author: LemonBoy <thatlemon@gmail.com>
Date: Mon, 6 Jan 2020 00:18:26 +0100
Add run-translated-c test
Diffstat:
1 file changed, 17 insertions(+), 0 deletions(-)
diff --git a/test/run_translated_c.zig b/test/run_translated_c.zig
@@ -3,6 +3,23 @@ const tests = @import("tests.zig");
const nl = std.cstr.line_sep;
pub fn addCases(cases: *tests.RunTranslatedCContext) void {
+ cases.add("boolean values and expressions",
+ \\#include <stdlib.h>
+ \\static const _Bool false_val = 0;
+ \\static const _Bool true_val = 1;
+ \\void foo(int x, int y) {
+ \\ _Bool r = x < y;
+ \\ if (!r) abort();
+ \\ _Bool self = foo;
+ \\ if (self == false_val) abort();
+ \\}
+ \\int main(int argc, char **argv) {
+ \\ foo(2, 5);
+ \\ if (false_val == true_val) abort();
+ \\ return 0;
+ \\}
+ , "");
+
cases.add("hello world",
\\#define _NO_CRT_STDIO_INLINE 1
\\#include <stdio.h>