#!/usr/bin/perl # ichijou_unittest2.pl - Don Yang (uguu.org) # # 06/19/06 use strict; my ($test_bin, $test_infile, @test_cases); $test_bin = ($#ARGV >= 0 ? "perl $ARGV[0]" : "perl ./ichijou0.pl"); $test_infile = "unittest_input2.txt"; @test_cases = ( ["alpha", "a"], ["bravo", "b"], ["charlie", "c"], ["delta", "d"], ["echo", "e"], ["foxtrot", "f"], ["golf", "g"], ["hotel", "h"], ["india", "i"], ["juliet", "j"], ["kilo", "k"], ["lima", "l"], ["mike", "m"], ["november", "n"], ["oscar", "o"], ["papa", "p"], ["quebec", "q"], ["romeo", "r"], ["sierra", "s"], ["tango", "t"], ["uniform", "u"], ["victor", "v"], ["whiskey", "w"], ["x-ray", "x"], ["yankee", "y"], ["zulu", "z"], ["Alpha", "A"], ["Bravo", "B"], ["Charlie", "C"], ["Delta", "D"], ["Echo", "E"], ["Foxtrot", "F"], ["Golf", "G"], ["Hotel", "H"], ["India", "I"], ["Juliet", "J"], ["Kilo", "K"], ["Lima", "L"], ["Mike", "M"], ["November", "N"], ["Oscar", "O"], ["Papa", "P"], ["Quebec", "Q"], ["Romeo", "R"], ["Sierra", "S"], ["Tango", "T"], ["Uniform", "U"], ["Victor", "V"], ["Whiskey", "W"], ["X-ray", "X"], ["Yankee", "Y"], ["Zulu", "Z"], ["alpha bravo charlie delta echo", "abcde"], ["foxtrot golf hotel india juliet", "fghij"], ["kilo lima mike november oscar papa", "klmnop"], ["quebec romeo sierra tango uniform", "qrstu"], ["victor whiskey x-ray yankee zulu", "vwxyz"], ["Zulu 1 Yankee X-ray Whiskey Victor Uniform", "Z1YXWVU"], ["Tango Sierra 2 Romeo Quebec Papa", "TS2RQP"], ["Oscar November Mike 3 Lima Kilo", "ONM3LK"], ["Juliet India Hotel Golf . Foxtrot", "JIHG.F"], ["Echo Delta Charlie Bravo Alpha", "EDCBA"], ["0echo", "0e"], ["echo0", "e0"], ["XXX", "XXX"], ["", ""], ); local (*OUTFILE); open OUTFILE, "> $test_infile" or die $!; print OUTFILE "$$_[0]\n" foreach @test_cases; close OUTFILE; my (@test_output); @test_output = `$test_bin < $test_infile`; unlink $test_infile; for(my $i = 0; $i <= $#test_cases; $i++) { my ($a, $b) = ($test_cases[$i][1], $test_output[$i]); $a =~ s/\s*$//; $b =~ s/\s*$//; if( $a ne $b ) { die "expected: '$a', got '$b'\n"; } } print "PASS\n"; exit 0;