commit 10c755f0c116cd6aa54fbab901a0e75e8619da21
parent 744600e6692a3008ffb0b0fa1f0522daf8d51a19
Author: Kyle Milz <kyle@getaddrinfo.net>
Date: Thu, 17 Mar 2016 20:14:42 -0600
t/runtime_sanity: make the test program easier
Diffstat:
1 file changed, 14 insertions(+), 18 deletions(-)
diff --git a/t/runtime_sanity.t b/t/runtime_sanity.t
@@ -2,7 +2,7 @@ use strict;
use Data::Dumper;
use SCV::Project;
use SCV::Viewer;
-use Test::More tests => 50;
+use Test::More tests => 45;
use Test::Differences;
my $viewer = SCV::Viewer->new();
@@ -11,8 +11,7 @@ unified_diff;
$project->add_src(<<EOF
#include <err.h>
-#include <limits.h>
-#include <stdlib.h> /* strtonum */
+#include <stdlib.h>
long long fib(long long);
void print_output(long long);
@@ -21,14 +20,11 @@ int
main(int argc, char *argv[])
{
long long n;
- const char *errstr = NULL;
if (argc != 2)
errx(1, "argc != 2");
- n = strtonum(argv[1], LONG_MIN, LONG_MAX, &errstr);
- if (errstr)
- err(1, "%s", errstr);
+ n = atoi(argv[1]);
print_output(fib(n));
return 0;
@@ -71,24 +67,24 @@ $viewer->accept();
my $metadata = $viewer->get_metadata();
my ($source_0, $source_1, $source_2) = @{ $metadata };
-like ($source_0->{filename}, qr/tmp\/.*source_0.c/, "runtime filename check 0") ;
-is ($source_0->{lines}, 24, "runtime line count check 0");
-like ($source_1->{filename}, qr/tmp\/.*source_1.c/, "runtime filename check 1") ;
+like ($source_0->{filename}, qr/.*source_0.c/, "runtime filename check 0") ;
+is ($source_0->{lines}, 20, "runtime line count check 0");
+like ($source_1->{filename}, qr/.*source_1.c/, "runtime filename check 1") ;
is ($source_1->{lines}, 11, "runtime line count check 1");
-like ($source_2->{filename}, qr/tmp\/.*source_2.c/, "runtime filename check 2") ;
+like ($source_2->{filename}, qr/.*source_2.c/, "runtime filename check 2") ;
is ($source_2->{lines}, 9, "runtime line count check 2");
# Request and check execution data
my $data = $viewer->get_execution_data();
my @lines = @{ $data->[0] };
-is ( $lines[$_], 0, "src 0 line $_ check" ) for (0..13);
-is ( $lines[14], 1, "src 0 line 14 check" );
-is ( $lines[$_], 0, "src 0 line $_ check" ) for (15..16);
-is ( $lines[$_], 1, "src 0 line $_ check" ) for (17..18);
-is ( $lines[$_], 0, "src 0 line $_ check" ) for (19..20);
-is ( $lines[21], 2, "src 0 line 21 check" );
-is ( $lines[$_], 0, "src 0 line $_ check" ) for (22..23);
+is ( $lines[$_], 0, "src 0 line $_ check" ) for (1..11);
+is ( $lines[12], 1, "src 0 line 14 check" );
+is ( $lines[$_], 0, "src 0 line $_ check" ) for (13..14);
+is ( $lines[15], 1, "src 0 line 15 check" );
+is ( $lines[16], 0, "src 0 line 16 check" );
+is ( $lines[17], 2, "src 0 line 17 check" );
+is ( $lines[$_], 0, "src 0 line $_ check" ) for (18..19);
my @lines = @{ $data->[1] };
is ( $lines[$_], 0, "src 1 line $_ check" ) for (0..3);