Mark Dominus on 27 Sep 2005 17:34:03 -0000 |
Meng Weng Wong: > Could you post a couple of tests so I can tell if my code is > doing the right thing? Here's the test suite I wrote for my own code: if ($ARGV[0] eq "TEST") { require Test::More; Test::More->import("no_plan"); my $pi = "141592653589793238"; my $haystack = pack "H*", $pi; is (search_bcd($haystack, "653"), 6); is (search_bcd($haystack, "535"), 7); is (search_bcd($haystack, "6535"), 6); is (search_bcd($haystack, "5358"), 7); for my $i (0 .. length($pi)-2) { for my $j (1 .. length($pi)-$i-1) { my $needle = substr($pi, $i, $j); is(search_bcd($haystack, $needle), index($pi, $needle), "Looking for <$needle> at position $i"); } } for my $failure (qw(0 12 43 142 999 373 142857)) { is(search_bcd($haystack, $failure), -1, "search for absent '$failure'"); } } - **Majordomo list services provided by PANIX <URL:http://www.panix.com>** **To Unsubscribe, send "unsubscribe phl" to majordomo@lists.pm.org**
|
|