--- /dev/null
+<?php
+
+# Copyright (C) 2009 Jason Woofenden
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+
+# 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;
+}