Skip to content

Commit

Permalink
Add more tests for attribute and spacing bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
benkasminbullock committed Apr 19, 2017
1 parent 81c371f commit 6f72e33
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
1 change: 1 addition & 0 deletions tests/attribute.c
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
static void print_usage_message () __attribute__ ((noreturn));
6 changes: 6 additions & 0 deletions tests/spacing.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
kanji_codes_status_t
jis2euc (two_bytes jis, two_bytes * euc)
{
* euc = jis | 0x8080;
OK;
}
29 changes: 29 additions & 0 deletions tests/test.pl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 6f72e33

Please sign in to comment.