Update v1.0.6

This commit is contained in:
Bhanu Slathia
2016-02-16 23:22:09 +05:30
parent 62d04a0372
commit c710c20b9e
7620 changed files with 244752 additions and 1070312 deletions

View File

@@ -1,101 +0,0 @@
<?php
require_once(dirname(__FILE__)."/Test.class.php");
require_once(dirname(dirname(__FILE__))."/src/ForceUTF8/Encoding.php");
use \ForceUTF8\Encoding;
// Test the testing class itself.
Test::is("'yes' is true", 'yes', true);
Test::not("1 is not false", 1, false);
Test::identical("true is identical to true", true, true);
Test::true("1 is true", 1);
// ForceUTF8 tests.
Test::not("Source files must not use the same encoding before conversion.",
file_get_contents(dirname(__FILE__)."/data/test1.txt"),
file_get_contents(dirname(__FILE__)."/data/test1Latin.txt"));
Test::identical("Simple Encoding works.",
file_get_contents(dirname(__FILE__)."/data/test1.txt"),
Encoding::toUTF8(file_get_contents(dirname(__FILE__)."/data/test1Latin.txt")));
function test_arrays_are_different(){
$arr1 = array(
file_get_contents(dirname(__FILE__)."/data/test1Latin.txt"),
file_get_contents(dirname(__FILE__)."/data/test1.txt"),
file_get_contents(dirname(__FILE__)."/data/test1Latin.txt"));
$arr2 = array(
file_get_contents(dirname(__FILE__)."/data/test1.txt"),
file_get_contents(dirname(__FILE__)."/data/test1.txt"),
file_get_contents(dirname(__FILE__)."/data/test1.txt"));
return $arr1 != $arr2;
}
function test_encoding_of_arrays(){
$arr1 = array(
file_get_contents(dirname(__FILE__)."/data/test1Latin.txt"),
file_get_contents(dirname(__FILE__)."/data/test1.txt"),
file_get_contents(dirname(__FILE__)."/data/test1Latin.txt"));
$arr2 = array(
file_get_contents(dirname(__FILE__)."/data/test1.txt"),
file_get_contents(dirname(__FILE__)."/data/test1.txt"),
file_get_contents(dirname(__FILE__)."/data/test1.txt"));
return Encoding::toUTF8($arr1) == $arr2;
}
Test::true("Source arrays are different.", test_arrays_are_different());
Test::true("Encoding of array works.", test_encoding_of_arrays());
Test::identical("fixUTF8() maintains UTF-8 string.",
file_get_contents(dirname(__FILE__)."/data/test1.txt"),
Encoding::fixUTF8(file_get_contents(dirname(__FILE__)."/data/test1.txt")));
Test::not("An UTF-8 double encoded string differs from a correct UTF-8 string.",
file_get_contents(dirname(__FILE__)."/data/test1.txt"),
utf8_encode(file_get_contents(dirname(__FILE__)."/data/test1.txt")));
Test::identical("fixUTF8() reverts to UTF-8 a double encoded string.",
file_get_contents(dirname(__FILE__)."/data/test1.txt"),
Encoding::fixUTF8(utf8_encode(file_get_contents(dirname(__FILE__)."/data/test1.txt"))));
function test_double_encoded_arrays_are_different(){
$arr1 = array(
utf8_encode(file_get_contents(dirname(__FILE__)."/data/test1Latin.txt")),
utf8_encode(file_get_contents(dirname(__FILE__)."/data/test1.txt")),
utf8_encode(file_get_contents(dirname(__FILE__)."/data/test1Latin.txt")));
$arr2 = array(
file_get_contents(dirname(__FILE__)."/data/test1.txt"),
file_get_contents(dirname(__FILE__)."/data/test1.txt"),
file_get_contents(dirname(__FILE__)."/data/test1.txt"));
return $arr1 != $arr2;
}
function test_double_encoded_arrays_fix(){
$arr1 = array(
utf8_encode(file_get_contents(dirname(__FILE__)."/data/test1Latin.txt")),
utf8_encode(file_get_contents(dirname(__FILE__)."/data/test1.txt")),
utf8_encode(file_get_contents(dirname(__FILE__)."/data/test1Latin.txt")));
$arr2 = array(
file_get_contents(dirname(__FILE__)."/data/test1.txt"),
file_get_contents(dirname(__FILE__)."/data/test1.txt"),
file_get_contents(dirname(__FILE__)."/data/test1.txt"));
return Encoding::fixUTF8($arr1) == $arr2;
}
Test::true("Source arrays are different (fixUTF8).", test_double_encoded_arrays_are_different());
Test::true("Fixing of double encoded array works.", test_double_encoded_arrays_fix());
Test::identical("fixUTF8() Example 1 still working.",
Encoding::fixUTF8("Fédération Camerounaise de Football\n"),
"Fédération Camerounaise de Football\n");
Test::identical("fixUTF8() Example 2 still working.",
Encoding::fixUTF8("Fédération Camerounaise de Football\n"),
"Fédération Camerounaise de Football\n");
Test::identical("fixUTF8() Example 3 still working.",
Encoding::fixUTF8("Fédération Camerounaise de Football\n"),
"Fédération Camerounaise de Football\n");
Test::identical("fixUTF8() Example 4 still working.",
Encoding::fixUTF8("Fédération Camerounaise de Football\n"),
"Fédération Camerounaise de Football\n");
Test::totals();

View File

@@ -1,62 +0,0 @@
<?php
class Test {
protected static $passed = 0;
protected static $failed = 0;
protected static $last_echoed;
public static function true($test_name, $result){
return static::is($test_name, $result, TRUE);
}
public static function is($test_name, $result, $expected){
if($result == $expected) {
static::passed($test_name);
} else {
static::failed($test_name);
}
}
public static function not($test_name, $result, $expected){
if($result == $expected) {
static::failed($test_name);
} else {
static::passed($test_name);
}
}
public static function identical($test_name, $result, $expected){
if($result === $expected) {
static::passed($test_name);
} else {
static::failed($test_name);
}
}
public static function totals(){
echo "\n";
echo static::$passed." tests passed.\n";
echo static::$failed." tests failed.\n";
}
private static function failed($test_name){
echo "\n".$test_name." -> FAILED\n";
static::$failed++;
}
private static function passed($test_name){
static::character(".");
static::$passed++;
}
private static function character($char){
echo $char;
static::$last_echoed = 'char';
}
private static function line($msg){
if(static::$last_echoed == 'char') echo "\n";
echo $msg."\n";
static::$last_echoed = 'line';
}
}

View File

@@ -1 +0,0 @@
hello žš, привет

View File

@@ -1 +0,0 @@
Hírek

View File

@@ -1 +0,0 @@
H<EFBFBD>rek