<commit_before><?php

require_once $config->get('sysRoot').'alpha/util/helpers/Validator.inc';

/**
 *
 * Test case for the Validator helper class
 * 
 * @package alpha::tests
 * @author <NAME> <<EMAIL>>
 * @copyright 2009 <NAME>
 * @version $Id$
 * 
 */
class Validator_Test extends PHPUnit_Framework_TestCase {
    /**
     * Validate that the provided value is a valid integer
     */
    public function testIsInteger() {
        $this->assertTrue(Validator::isInteger(100));
		$this->assertTrue(Validator::isInteger(-100));
		$this->assertTrue(Validator::isInteger(0));
		$this->assertTrue(Validator::isInteger(00000000008));
		$this->assertTrue(Validator::isInteger('00000000008'));
		$this->assertTrue(Validator::isInteger('100'));
		$this->assertFalse(Validator::isInteger('1.1'));
		$this->assertFalse(Validator::isInteger(1.1));
		$this->assertFalse(Validator::isInteger('twenty'));
    }

    /**
     * Validate that the provided value is a valid double
     */
    public function testIsDouble() {
        $this->assertTrue(Validator::isDouble(10.0));
		$this->assertTrue(Validator::isDouble(-10.0));
		$this->assertTrue(Validator::isDouble(0.10));
		$this->assertFalse(Validator::isDouble('twenty'));
		$this->assertFalse(Validator::isDouble(100));
		$this->assertFalse(Validator::isDouble('100'));
    }

    /**
     * Validate that the provided value is a valid alphabetic string (strictly a-zA-Z)
     */
    public function testIsAlpha() {
        $this->assertTrue(Validator::isAlpha('test'));
		$this->assertTrue(Validator::isAlpha('Test'));
		$this->assertTrue(Validator::isAlpha('TEST'));
		$this->assertFalse(Validator::isAlpha('number5'));
		$this->assertFalse(Validator::isAlpha('!-++#'));
		$this->assertFalse(Validator::isAlpha('100'));
    }

    /**
     * Validate that the provided value is a valid alpha-numeric string (strictly a-zA-Z0-9)
     */
    public function testIsAlphaNum() {
        $this->assertTrue(Validator::isAlphaNum('test1'));
		$this->assertTrue(Validator::isAlphaNum('1Test'));
		$this->assertTrue(Validator::isAlphaNum('1TEST1'));
		$this->assertFalse(Validator::isAlphaNum('test value'));
		$this->assertFalse(Validator::isAlphaNum('!-++#'));
		$this->assertFalse(Validator::isAlphaNum('1.00'));
    }

    /**
     * Validate that the provided value is a valid URL
     */
    public function testIsURL() {
        $this->assertTrue(Validator::isURL('http://www.alphaframework.org'));
		$this->assertTrue(Validator::isURL('http://www.alphaframework.org/controller/View.php?some=value'));
		$this->assertTrue(Validator::isURL('http://alphaframework.org/'));
		$this->assertFalse(Validator::isURL('http://alpha framework.org/'));
		$this->assertFalse(Validator::isURL('http//www.alphaframework.org'));
		$this->assertFalse(Validator::isURL('http:/www.alphaframework.org'));
    }

    /**
     * Validate that the provided value is a valid IP address
     */
    public function testIsIP() {
        $this->assertTrue(Validator::isIP('127.0.0.1'));
		$this->assertTrue(Validator::isIP('255.255.255.255'));
		$this->assertTrue(Validator::isIP('192.168.127.12'));
		$this->assertFalse(Validator::isIP('127.0.0.1000'));
		$this->assertFalse(Validator::isIP('127.0.0'));
		$this->assertFalse(Validator::isIP('127.0.0.1.1'));
    }

    /**
     * Validate that the provided value is a valid email address
     */
    public function testIsEmail() {
        $this->assertTrue(Validator::isEmail('<EMAIL>'));
		$this->assertTrue(Validator::isEmail('<EMAIL>'));
		$this->assertTrue(Validator::isEmail('<EMAIL>'));
		$this->assertFalse(Validator::isEmail('nobodyalphaframework.org'));
		$this->assertFalse(Validator::isEmail('no <EMAIL>'));
		$this->assertFalse(Validator::isEmail('<EMAIL>'));
    }
}

?><commit_msg>Added some test cases for the isSequence method<commit_after><?php

require_once $config->get('sysRoot').'alpha/util/helpers/Validator.inc';

/**
 *
 * Test case for the Validator helper class
 * 
 * @package alpha::tests
 * @author <NAME> <<EMAIL>>
 * @copyright 2009 <NAME>
 * @version $Id$
 * 
 */
class Validator_Test extends PHPUnit_Framework_TestCase {
    /**
     * Validate that the provided value is a valid integer
     */
    public function testIsInteger() {
        $this->assertTrue(Validator::isInteger(100));
		$this->assertTrue(Validator::isInteger(-100));
		$this->assertTrue(Validator::isInteger(0));
		$this->assertTrue(Validator::isInteger(00000000008));
		$this->assertTrue(Validator::isInteger('00000000008'));
		$this->assertTrue(Validator::isInteger('100'));
		$this->assertFalse(Validator::isInteger('1.1'));
		$this->assertFalse(Validator::isInteger(1.1));
		$this->assertFalse(Validator::isInteger('twenty'));
    }

    /**
     * Validate that the provided value is a valid double
     */
    public function testIsDouble() {
        $this->assertTrue(Validator::isDouble(10.0));
		$this->assertTrue(Validator::isDouble(-10.0));
		$this->assertTrue(Validator::isDouble(0.10));
		$this->assertFalse(Validator::isDouble('twenty'));
		$this->assertFalse(Validator::isDouble(100));
		$this->assertFalse(Validator::isDouble('100'));
    }

    /**
     * Validate that the provided value is a valid alphabetic string (strictly a-zA-Z)
     */
    public function testIsAlpha() {
        $this->assertTrue(Validator::isAlpha('test'));
		$this->assertTrue(Validator::isAlpha('Test'));
		$this->assertTrue(Validator::isAlpha('TEST'));
		$this->assertFalse(Validator::isAlpha('number5'));
		$this->assertFalse(Validator::isAlpha('!-++#'));
		$this->assertFalse(Validator::isAlpha('100'));
    }

    /**
     * Validate that the provided value is a valid alpha-numeric string (strictly a-zA-Z0-9)
     */
    public function testIsAlphaNum() {
        $this->assertTrue(Validator::isAlphaNum('test1'));
		$this->assertTrue(Validator::isAlphaNum('1Test'));
		$this->assertTrue(Validator::isAlphaNum('1TEST1'));
		$this->assertFalse(Validator::isAlphaNum('test value'));
		$this->assertFalse(Validator::isAlphaNum('!-++#'));
		$this->assertFalse(Validator::isAlphaNum('1.00'));
    }

    /**
     * Validate that the provided value is a valid URL
     */
    public function testIsURL() {
        $this->assertTrue(Validator::isURL('http://www.alphaframework.org'));
		$this->assertTrue(Validator::isURL('http://www.alphaframework.org/controller/View.php?some=value'));
		$this->assertTrue(Validator::isURL('http://alphaframework.org/'));
		$this->assertFalse(Validator::isURL('http://alpha framework.org/'));
		$this->assertFalse(Validator::isURL('http//www.alphaframework.org'));
		$this->assertFalse(Validator::isURL('http:/www.alphaframework.org'));
    }

    /**
     * Validate that the provided value is a valid IP address
     */
    public function testIsIP() {
        $this->assertTrue(Validator::isIP('127.0.0.1'));
		$this->assertTrue(Validator::isIP('255.255.255.255'));
		$this->assertTrue(Validator::isIP('192.168.127.12'));
		$this->assertFalse(Validator::isIP('127.0.0.1000'));
		$this->assertFalse(Validator::isIP('127.0.0'));
		$this->assertFalse(Validator::isIP('127.0.0.1.1'));
    }

    /**
     * Validate that the provided value is a valid email address
     */
    public function testIsEmail() {
        $this->assertTrue(Validator::isEmail('<EMAIL>'));
		$this->assertTrue(Validator::isEmail('<EMAIL>'));
		$this->assertTrue(Validator::isEmail('<EMAIL>'));
		$this->assertFalse(Validator::isEmail('<EMAIL>'));
		$this->assertFalse(Validator::isEmail('no <EMAIL>'));
		$this->assertFalse(Validator::isEmail('<EMAIL>'));
    }
    
    /**
     * Validate that the provided value is a valid Sequence value
     */
    public function testIsSequence() {
    	$this->assertTrue(Validator::isSequence('BARS-150'));
    	$this->assertTrue(Validator::isSequence('ALPH-15'));
    	$this->assertTrue(Validator::isSequence('DESI-1'));
    	$this->assertFalse(Validator::isSequence('1'));
    	$this->assertFalse(Validator::isSequence('1.0'));
    	$this->assertFalse(Validator::isSequence('DESI8'));
    }
}

?>
{'fraction_non_alphanumeric': 0.1942365269461078, 'fraction_numerical': 0.030688622754491017, 'mean_word_length': 4.767625899280575, 'pattern_counts': {'":': 0, '<': 24, '<?xml version=': 0, '>': 122, 'https://': 0, 'lorem ipsum': 0, 'www.': 8, 'xml': 0}, 'pii_count': 10, 'substrings_counts': 4, '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': '2940062', 'n_tokens_mistral': 2646, 'n_tokens_neox': 2482, 'n_words': 354}