<commit_before><?php
/*
 * File: UtilitiesTest.php
 * Holds: Testes the Utilities class
 * Created: 25.05.2015
 * Project: Youkok2
 * 
 */

namespace Youkok2\Tests\Utilities;

use Youkok2\Utilities\Utilities;

class UtilitiesTest extends \Youkok2\Tests\YoukokTestCase
{
    
    /*
     * Test prettifySQLDate
     */
    
    public function testPrettifySQLDate() {
        // Generate some dates
        $date1 = Utilities::prettifySQLDate('2014-11-11 12:00:00', false);
        $date2 = Utilities::prettifySQLDate('1999-12-30 21:00:00', false);
        $date3 = Utilities::prettifySQLDate('2000-01-01 00:00:00', false);
        $date4_with_time = Utilities::prettifySQLDate('2000-01-01 00:00:00');
        $date5_with_time = Utilities::prettifySQLDate('2000-01-01 01:01:00');
        $date6_with_time = Utilities::prettifySQLDate('2000-01-01 23:59:00');
        
        // Test them
        $this->assertEquals($date1, '11. nov 2014');
        $this->assertEquals($date2, '30. des 1999');
        $this->assertEquals($date3, '1. jan 2000');
        $this->assertEquals($date4_with_time, '1. jan 2000 @ 00:00:00');
        $this->assertEquals($date5_with_time, '1. jan 2000 @ 01:01:00');
        $this->assertEquals($date6_with_time, '1. jan 2000 @ 23:59:00');
    }
    
    /*
     * Make sure urlSafe is correct
     */
    
    public function testUrlSafe() {
        // Generate some filenames
        $special_chars = Utilities::urlSafe('`foo!"#¤%&/()=?bar');
        $quotes = Utilities::urlSafe('foo\'bar"bar');
        $with_spaces = Utilities::urlSafe('foo bar  foo');
        $url_with_spaces = Utilities::urlSafe('foo bar  foo');
        
        // Test them
        $this->assertEquals($special_chars, 'foobar');
        $this->assertEquals($quotes, 'foobarbar');
        $this->assertEquals($url_with_spaces, 'foo-bar-foo');
    }
    
    /*
     * Test password hashing
     */
    
    public function testHashPassword() {
        // Generate some hashes
        $password1 = Utilities::hashPassword('foo', '<PASSWORD>');
        $password2 = Utilities::hashPassword('foo', '<PASSWORD>', false);
        
        // Test them
        $this->assertEquals($password1, <PASSWORD>' .
            '<PASSWORD>');
        $this->assertEquals($password2, <PASSWORD>');
    }
    
    /*
     * Test password fuckup
     */
    
    public function testPasswordFuckup() {
        // Generate some hashes
        $password1 = Utilities::hashPassword('foo', '<PASSWORD>');
        $password2 = Utilities::hashPassword('foo', '<PASSWORD>', false);
        
        $password_fuckup = Utilities::passwordFuckup($password2);
        
        // Test them
        $this->assertEquals($password1, $password_fuckup);
    }
    
    /*
     * Test reverse password fuckup
     */
    
    public function testReversePasswordFuckup() {
        // Generate some hashes
        $password1 = Utilities::hashPassword('foo', '<PASSWORD>');
        $password2 = Utilities::hashPassword('foo', '<PASSWORD>', false);
        
        $reverse_fuckup = Utilities::reverseFuckup($password1);
        
        // Test them
        $this->assertEquals($password2, $reverse_fuckup);
    }
    
    /*
     * Test pretty filesizes
     */
    
    public function testPrettifyFilesize() {
        $size1 = Utilities::prettifyFilesize(10);
        $size2 = Utilities::prettifyFilesize(99999);
        $size3 = Utilities::prettifyFilesize(10000000);
        $size4 = Utilities::prettifyFilesize(999999999);
        
        // Test them
        $this->assertEquals($size1, '10 B');
        $this->assertEquals($size2, '97 kB');
        $this->assertEquals($size3, '9 MB');
        $this->assertEquals($size4, '953 MB');
    }
}<commit_msg>Testing file sizes 0 and below 0<commit_after><?php
/*
 * File: UtilitiesTest.php
 * Holds: Testes the Utilities class
 * Created: 25.05.2015
 * Project: Youkok2
 * 
 */

namespace Youkok2\Tests\Utilities;

use Youkok2\Utilities\Utilities;

class UtilitiesTest extends \Youkok2\Tests\YoukokTestCase
{
    
    /*
     * Test prettifySQLDate
     */
    
    public function testPrettifySQLDate() {
        // Generate some dates
        $date1 = Utilities::prettifySQLDate('2014-11-11 12:00:00', false);
        $date2 = Utilities::prettifySQLDate('1999-12-30 21:00:00', false);
        $date3 = Utilities::prettifySQLDate('2000-01-01 00:00:00', false);
        $date4_with_time = Utilities::prettifySQLDate('2000-01-01 00:00:00');
        $date5_with_time = Utilities::prettifySQLDate('2000-01-01 01:01:00');
        $date6_with_time = Utilities::prettifySQLDate('2000-01-01 23:59:00');
        
        // Test them
        $this->assertEquals($date1, '11. nov 2014');
        $this->assertEquals($date2, '30. des 1999');
        $this->assertEquals($date3, '1. jan 2000');
        $this->assertEquals($date4_with_time, '1. jan 2000 @ 00:00:00');
        $this->assertEquals($date5_with_time, '1. jan 2000 @ 01:01:00');
        $this->assertEquals($date6_with_time, '1. jan 2000 @ 23:59:00');
    }
    
    /*
     * Make sure urlSafe is correct
     */
    
    public function testUrlSafe() {
        // Generate some filenames
        $special_chars = Utilities::urlSafe('`foo!"#¤%&/()=?bar');
        $quotes = Utilities::urlSafe('foo\'bar"bar');
        $with_spaces = Utilities::urlSafe('foo bar  foo');
        $url_with_spaces = Utilities::urlSafe('foo bar  foo');
        
        // Test them
        $this->assertEquals($special_chars, 'foobar');
        $this->assertEquals($quotes, 'foobarbar');
        $this->assertEquals($url_with_spaces, 'foo-bar-foo');
    }
    
    /*
     * Test password hashing
     */
    
    public function testHashPassword() {
        // Generate some hashes
        $password1 = Utilities::hashPassword('foo', '<PASSWORD>');
        $password2 = Utilities::hashPassword('foo', '<PASSWORD>', false);
        
        // Test them
        $this->assertEquals($password1, <PASSWORD>XB4n.v5E1cv68wsqu6071f11238e' .
            '773ac6bb269ae0a0d4f4bhsleeasdasdkjhayolo');
        $this->assertEquals($password2, <PASSWORD>');
    }
    
    /*
     * Test password fuckup
     */
    
    public function testPasswordFuckup() {
        // Generate some hashes
        $password1 = Utilities::hashPassword('foo', '<PASSWORD>');
        $password2 = Utilities::hashPassword('foo', '<PASSWORD>', false);
        
        $password_fuckup = Utilities::passwordFuckup($password2);
        
        // Test them
        $this->assertEquals($password1, $password_fuckup);
    }
    
    /*
     * Test reverse password fuckup
     */
    
    public function testReversePasswordFuckup() {
        // Generate some hashes
        $password1 = Utilities::hashPassword('foo', '<PASSWORD>');
        $password2 = Utilities::hashPassword('foo', '<PASSWORD>', false);
        
        $reverse_fuckup = Utilities::reverseFuckup($password1);
        
        // Test them
        $this->assertEquals($password2, $reverse_fuckup);
    }
    
    /*
     * Test pretty filesizes
     */
    
    public function testPrettifyFilesize() {
        $size1 = Utilities::prettifyFilesize(10);
        $size2 = Utilities::prettifyFilesize(99999);
        $size3 = Utilities::prettifyFilesize(10000000);
        $size4 = Utilities::prettifyFilesize(999999999);
        $size5 = Utilities::prettifyFilesize(0);
        $size6 = Utilities::prettifyFilesize(-10);

        // Test them
        $this->assertEquals($size1, '10 B');
        $this->assertEquals($size2, '97 kB');
        $this->assertEquals($size3, '9 MB');
        $this->assertEquals($size4, '953 MB');
        $this->assertEquals($size5, '0');
        $this->assertEquals($size6, '-10');
    }
}
{'fraction_non_alphanumeric': 0.15068137573004542, 'fraction_numerical': 0.059312134977287476, 'mean_word_length': 2.57753017641597, 'pattern_counts': {'":': 0, '<': 22, '<?xml version=': 0, '>': 56, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, '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': '4655685', 'n_tokens_mistral': 2690, 'n_tokens_neox': 2417, 'n_words': 424}