<commit_before><?php
// vim: foldmethod=marker
/**
 *  Ethna_Util_Test.php
 */

/**
 *  Ethna_Utilクラスのテストケース
 *
 *  @access public
 */
class Ethna_Util_Test extends Ethna_UnitTestBase
{
    // {{{  testCheckMailAddress
    function testCheckMailAddress()
    {
        $fail_words = array(
            'hogehuga.<EMAIL>',
            'untarakantara',
            '<EMAIL>',
            '<EMAIL>',
            '<EMAIL>',
        );

        foreach ($fail_words as $word) {
            $this->assertFalse(Ethna_Util::checkMailAddress($word));
        }
        
        $util = new Ethna_Util;
        $result = $util->checkMailAddress('hogefuga.net');
        $this->assertFalse($result);

        $result = $util->checkMailAddress('<EMAIL>');
        $this->assertTrue($result);
    }
    // }}}

    // {{{  testIsAbsolute
    function testIsAbsolute()
    {
        $absolute_paths = array(
            '/root',
            '/home/user/giza',
        );

        $invalid_params = array(
            '',
            false,
            true,
            '0x1',
        );

        foreach ($absolute_paths as $path) {
            $this->assertTrue(Ethna_Util::isAbsolute($path));
        }
        
        foreach ($invalid_params as $path) {
            $this->assertFalse(Ethna_Util::isAbsolute($path));
        }
    }
    // }}}

    // {{{  testGetRandom
    function testGetRandom()
    {
        //    いかなる状態であっても
        //    値が得られなければならない
        $r = Ethna_Util::getRandom();
        $this->assertNotNULL($r);
    }
    // }}}

    // {{{ testGetEra
    function testGetEra()
    {
        unset($GLOBALS['_Ethna_controller']);
        $tmp_ctl =& new Ethna_Controller();
        
        //  昭和63年
        $last_showa_t = mktime(0,0,0,12,31,1988);
        $r = Ethna_Util::getEra($last_showa_t);
        $this->assertEqual('昭和', $r[0]);
        $this->assertEqual(63, $r[1]);

        //  平成元年
        $first_heisei_t = mktime(0,0,0,1,1,1989);
        $r = Ethna_Util::getEra($first_heisei_t);
        $this->assertEqual('平成', $r[0]);
        $this->assertEqual(1, $r[1]);
    }
    // }}}
}

?>
<commit_msg>- recovered deleted test function by error, sorry.<commit_after><?php
// vim: foldmethod=marker
/**
 *  Ethna_Util_Test.php
 */

/**
 *  Ethna_Utilクラスのテストケース
 *
 *  @access public
 */
class Ethna_Util_Test extends Ethna_UnitTestBase
{
    // {{{  testCheckMailAddress
    function testCheckMailAddress()
    {
        $fail_words = array(
            'hogehuga.net',
            'untarakantara',
            '<EMAIL>',
            '<EMAIL>',
            '<EMAIL>',
        );

        foreach ($fail_words as $word) {
            $this->assertFalse(Ethna_Util::checkMailAddress($word));
        }
        
        $util = new Ethna_Util;
        $result = $util->checkMailAddress('hogefuga.net');
        $this->assertFalse($result);

        $result = $util->checkMailAddress('<EMAIL>');
        $this->assertTrue($result);
    }
    // }}}

    // {{{  testIsAbsolute
    function testIsAbsolute()
    {
        $absolute_paths = array(
            '/root',
            '/home/user/giza',
        );

        $invalid_params = array(
            '',
            false,
            true,
            '0x1',
        );

        foreach ($absolute_paths as $path) {
            $this->assertTrue(Ethna_Util::isAbsolute($path));
        }
        
        foreach ($invalid_params as $path) {
            $this->assertFalse(Ethna_Util::isAbsolute($path));
        }
    }
    // }}}

    // {{{  testIsRootDir
    function testIsRootDir()
    {
        $this->assertTrue(DIRECTORY_SEPARATOR);

        $util = new Ethna_Util;
        if (OS_WINDOWS) {
            $this->assertTrue($util->isRootDir("C:\\"));
            $this->assertFalse($util->isRootDir("C:\\Program Files\\hoge\\fuga.txt"));
            $this->assertFalse($util->isRootDir("C:\\Program Files\\hoge"));
            $this->assertFalse($util->isRootDir("C:\\hoge\\"));
            $this->assertFalse($util->isRootDir("C:\\hoge.txt"));
        } else {
            $this->assertFalse($util->isRootDir("/home/ethna/test.txt"));
            $this->assertFalse($util->isRootDir("/home/ethna/"));
            $this->assertFalse($util->isRootDir("/home/ethna"));
            $this->assertFalse($util->isRootDir("/test.txt"));
        }
    }
    // }}}

    // {{{  testGetRandom
    function testGetRandom()
    {
        //    いかなる状態であっても
        //    値が得られなければならない
        $r = Ethna_Util::getRandom();
        $this->assertNotNULL($r);
    }
    // }}}

    // {{{ testGetEra
    function testGetEra()
    {
        unset($GLOBALS['_Ethna_controller']);
        $tmp_ctl =& new Ethna_Controller();
        
        //  昭和63年
        $last_showa_t = mktime(0,0,0,12,31,1988);
        $r = Ethna_Util::getEra($last_showa_t);
        $this->assertEqual('昭和', $r[0]);
        $this->assertEqual(63, $r[1]);

        //  平成元年
        $first_heisei_t = mktime(0,0,0,1,1,1989);
        $r = Ethna_Util::getEra($first_heisei_t);
        $this->assertEqual('平成', $r[0]);
        $this->assertEqual(1, $r[1]);
    }
    // }}}
}

?>

{'fraction_non_alphanumeric': 0.17237331246331442, 'fraction_numerical': 0.012130698493445509, 'mean_word_length': 1.8289983397897067, 'pattern_counts': {'":': 0, '<': 14, '<?xml version=': 0, '>': 57, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5597031', 'n_tokens_mistral': 1767, 'n_tokens_neox': 1736, 'n_words': 208}