#!/usr/bin/perl -w # test.pl - Don Yang (uguu.org) # # 09/07/08 use strict; my $CIRNO = "perl ./cirno.pl"; my $AKYUU = "perl ./akyuu.pl"; sub RunTest($) { my ($data) = @_; my ($file); open $file, "> test_input.bin" or die $!; print $file $data; close $file; system "$CIRNO < test_input.bin | $AKYUU > test_output.bin"; open $file, "< test_output.bin" or die $!; my $output = join '', <$file>; close $file; unlink "test_input.bin", "test_output.bin"; if( $data ne $output ) { die "FAIL\n$data\n"; } } RunTest(""); for(my $i = 0; $i < 256; $i += 16) { RunTest(chr($i)); RunTest(chr($i) . chr($i)); RunTest(chr($i) . "\0" . chr($i)); RunTest(chr($i) . "\0\0" . chr($i)); RunTest(chr($i) . "\0\0\0" . chr($i)); RunTest(chr($i + 15) x 7); } for(my $i = 0; $i < 128; $i++) { my $data = ""; for(my $j = 0; $j < 1024 + $i; $j++) { $data .= chr(rand 256); } RunTest($data); } for(my $i = 0; $i < 8; $i++) { my $data = ""; for(my $j = 0; $j < 1024 * 1024 + $i; $j++) { $data .= chr(rand 256); } RunTest($data); }