<?php
-# Copyright (C) 2010 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/format.php
+# This program is in the public domain within the United States. Additionally,
+# we waive copyright and related rights in the work worldwide through the CC0
+# 1.0 Universal public domain dedication, which can be found at
+# http://creativecommons.org/publicdomain/zero/1.0/
+
+
+# This file contains tests for functions in wfpl/format.php
#
-# See code/wfpl/test.php for details on how to run or create tests
+# See wfpl/test.php for details on how to run or create tests
-require_once('code/wfpl/format.php');
+require_once(__DIR__.'/../'.'format.php');
function _test_format_money($arg, $dollars_correct, $money_correct) {
unit_test_func('format_dollars', $arg, $dollars_correct);
unit_test_func('format_decimal', $arg, $correct);
}
-# returns number of errors
function test_format_misc() {
unit_test_func('format_caption', 'something', 'Something');
unit_test_func('format_caption', 'two_words', 'Two Words');
format_12hr_to_hours($str)
format_phone($str)
*/
-
- return $errors;
-}
-
-# returns number of errors
-function _test_format_options($field, $value, $correct) {
- $ret = format_options($value, $field);
- if($ret !== $correct) {
- message("format_options($value, $field) returned \"$ret\" instead of \"$correct\"");
- return 1;
- }
- return 0;
-}
-
-
-function test_format_options() {
- $errors = 0;
- pulldown('array', array('one', 'two', "symbols&'\""), PULLDOWN_ARRAY);
- $errors +=_test_format_options('array', 'one', 'one');
- $errors +=_test_format_options('array', 'One', '');
- $errors +=_test_format_options('array', 'two', 'two');
- $errors +=_test_format_options('array', 'symbols&\'"', 'symbols&\'"');
- pulldown('hash', array('one' => 'Eno', 'two' => 'Owt', 'symbols&\'"' => 'Slobmys'), PULLDOWN_HASH);
- $errors +=_test_format_options('hash', 'one', 'one');
- $errors +=_test_format_options('hash', 'One', '');
- $errors +=_test_format_options('hash', 'two', 'two');
- $errors +=_test_format_options('hash', 'symbols&\'"', '');
- pulldown('array_2d', array(array('one', 'Eno'), array('two', 'Owt'), array('symbols&\'"', 'Slobmys')), PULLDOWN_2D);
- $errors +=_test_format_options('array_2d', 'one', 'one');
- $errors +=_test_format_options('array_2d', 'One', '');
- $errors +=_test_format_options('array_2d', 'two', 'two');
- $errors +=_test_format_options('array_2d', 'symbols&amp;\'"', '');
-
- return $errors;
}
-# returns number of errors
function format_unit_tests_main() {
- $errors = 0;
- $errors += test_format_money();
- $errors += test_format_misc();
- $errors += test_format_options();
- return $errors;
+ test_format_money();
+ test_format_misc();
}