From 6f72e3393f776fdc6e68e487bf367acd3bc78b66 Mon Sep 17 00:00:00 2001 From: Ben Bullock Date: Wed, 19 Apr 2017 16:26:47 +0900 Subject: [PATCH] Add more tests for attribute and spacing bugs --- tests/attribute.c | 1 + tests/spacing.c | 6 ++++++ tests/test.pl | 29 +++++++++++++++++++++++++++++ 3 files changed, 36 insertions(+) create mode 100644 tests/attribute.c create mode 100644 tests/spacing.c diff --git a/tests/attribute.c b/tests/attribute.c new file mode 100644 index 0000000..28e5f50 --- /dev/null +++ b/tests/attribute.c @@ -0,0 +1 @@ +static void print_usage_message () __attribute__ ((noreturn)); diff --git a/tests/spacing.c b/tests/spacing.c new file mode 100644 index 0000000..bd3546f --- /dev/null +++ b/tests/spacing.c @@ -0,0 +1,6 @@ +kanji_codes_status_t +jis2euc (two_bytes jis, two_bytes * euc) +{ + * euc = jis | 0x8080; + OK; +} diff --git a/tests/test.pl b/tests/test.pl index 2a4f105..e610e1b 100755 --- a/tests/test.pl +++ b/tests/test.pl @@ -76,6 +76,10 @@ sub main rm_h_files (); test_line_numbers (); rm_h_files (); + test_spacing (); + rm_h_files (); + test_attribute (); + rm_h_files (); } # Remove the backups @@ -342,6 +346,31 @@ sub test_line_numbers }; } +# https://github.com/benkasminbullock/cfunctions/issues/3 + +sub test_spacing +{ + my $file = "$Bin/spacing.c"; + my ($hfile, $htext) = run_ok ($file); + like ($htext, qr/kanji_codes_status_t\s+jis2euc/, "preserved space in function declaration"); + TODO: { + local $TODO = 'Do not add spaces before commas or end bracket of function.'; + unlike ($htext, qr/\s[,\)]/, "did not add extra space to function arguments"); + }; +} + +sub test_attribute +{ + my $file = "$Bin/attribute.c"; + run3 ("$cfunctions $file", undef, \my $output, \my $errors); + my $hfile = c_to_h_name ($file); + ok (-f $hfile, "made hfile"); + TODO: { + local $TODO = 'fix errors due to __attribute__'; + ok (! $errors, "no errors with __attribute__(()) stuff"); + }; +}; + # Run on a file expecting no output or errors sub run_ok