. # This file contains tests for functions in code/wfpl/misc.php # # See code/wfpl/unit_tests.php for details on how to run or create tests require_once('code/wfpl/misc.php'); # returns number of errors function test_ordinalize() { $errors = 0; $tests = array( '', '', 0, "0th", 1, "1st", 2, "2nd", 3, "3rd", 111, "111th", "62", "62nd"); for($i = 0; $i < count($tests); $i += 2) { $arg = $tests[$i]; $correct = $tests[$i + 1]; $ret = ordinalize($arg); if($ret !== $correct) { message("ordinalize($arg) returned \"$ret\" instead of \"$correct\""); $errors += 1; } } return $errors; } # returns number of errors function misc_unit_tests_main() { $errors = 0; $errors += test_ordinalize(); return $errors; }