#!/usr/bin/perl # ichijou_unittest.pl - Don Yang (uguu.org) # # 06/18/06 use strict; my ($gold_bin, $test_bin, $test_infile, @test_cases); $gold_bin = "./nato.sh"; $test_bin = "./ichijou"; $test_infile = "unittest_input.txt"; @test_cases = ( 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'abcdefghijklmnopqrstuvwxyz', 'a1b2c3d4 e5f6g7h8', 'aabbccddee', 'a b c d e' ); local (*OUTFILE); open OUTFILE, "> $test_infile" or die $!; print OUTFILE "$_\n" foreach @test_cases; close OUTFILE; my (@gold_output, @test_output); @gold_output = `$gold_bin < $test_infile`; @test_output = `$test_bin < $test_infile`; unlink $test_infile; for(my $i = 0; $i <= $#gold_output; $i++) { my ($a, $b) = ($gold_output[$i], $test_output[$i]); $a =~ s/\s*$//; $b =~ s/\s*$//; if( $a ne $b ) { die "expected: '$a', got '$b'\n"; } } print "PASS\n"; exit 0;