. # This file contains tests for functions in wfpl/encode.php # # See wfpl/test.php for details on how to run or create tests require_once(__DIR__.'/../'.'encode.php'); function _test_encode_pulled($field, $value, $correct) { unit_test_func('enc_pulled', $value, $field, $correct); } function test_encode_pulled() { pulldown('array', array('one', 'two', "symbols&'\"")); _test_encode_pulled('array', 'one', 'one'); _test_encode_pulled('array', 'One', 'One'); # not found is unchanged _test_encode_pulled('array', 'two', 'two'); _test_encode_pulled('array', 'symbols&\'"', 'symbols&\'"'); pulldown('mixed', array(array('one', 'Eno'), 'two', array('symbols&\'"', 'Slobmys'))); _test_encode_pulled('mixed', 'one', 'Eno'); _test_encode_pulled('mixed', 'One', 'One'); # not found is unchanged _test_encode_pulled('mixed', 'two', 'two'); _test_encode_pulled('mixed', 'symbols&\'"', 'symbols&\'"'); # not found is unchanged _test_encode_pulled('mixed', 'symbols&\'"', 'Slobmys'); pulldown('array_2d', array(array('one', 'Eno'), array('two', 'Owt'), array('symbols&\'"', 'Slobmys'))); _test_encode_pulled('array_2d', 'one', 'Eno'); _test_encode_pulled('array_2d', 'One', 'One'); # not found in unchanged _test_encode_pulled('array_2d', 'two', 'Owt'); _test_encode_pulled('array_2d', 'symbols&\'"', 'symbols&\'"'); # not found in unchanged } function test_encode_misc() { unit_test_func('enc_tab', '', ''); unit_test_func('enc_tab', "\n", "\t\n\t"); unit_test_func('enc_tab', "a", "\ta"); unit_test_func('enc_tab', "a\n", "\ta\n\t"); unit_test_func('enc_tab', "\t", "\t\t"); unit_test_func('enc_tab', "\n\na", "\t\n\t\n\ta"); unit_test_func('enc_tab', "\t\n\t\n\ta", "\t\t\n\t\t\n\t\ta"); } function encode_unit_tests_main() { test_encode_pulled(); test_encode_misc(); }