Port TestExtIntl
Esse commit está contido em:
@@ -36,7 +36,6 @@
|
||||
#include "hphp/facebook/extensions/urlextraction/test_ext_urlextraction.h"
|
||||
#include "hphp/test/ext/test_ext_curl.h"
|
||||
#include "hphp/test/ext/test_ext_imagesprite.h"
|
||||
#include "hphp/test/ext/test_ext_intl.h"
|
||||
#include "hphp/test/ext/test_ext_ipc.h"
|
||||
#include "hphp/test/ext/test_ext_json.h"
|
||||
#include "hphp/test/ext/test_ext_mailparse.h"
|
||||
|
||||
@@ -1,178 +0,0 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| HipHop for PHP |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 2010-2013 Facebook, Inc. (http://www.facebook.com) |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 3.01 of the PHP license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
| available through the world-wide-web at the following url: |
|
||||
| http://www.php.net/license/3_01.txt |
|
||||
| If you did not receive a copy of the PHP license and are unable to |
|
||||
| obtain it through the world-wide-web, please send a note to |
|
||||
| license@php.net so we can mail you a copy immediately. |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
#include "hphp/test/ext/test_ext_intl.h"
|
||||
#include "hphp/runtime/ext/ext_intl.h"
|
||||
|
||||
IMPLEMENT_SEP_EXTENSION_TEST(Intl);
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
bool TestExtIntl::RunTests(const std::string &which) {
|
||||
bool ret = true;
|
||||
|
||||
RUN_TEST(test_intl_get_error_code);
|
||||
RUN_TEST(test_intl_get_error_message);
|
||||
RUN_TEST(test_intl_error_name);
|
||||
RUN_TEST(test_intl_is_failure);
|
||||
RUN_TEST(test_collator_asort);
|
||||
RUN_TEST(test_collator_compare);
|
||||
RUN_TEST(test_collator_create);
|
||||
RUN_TEST(test_collator_get_attribute);
|
||||
RUN_TEST(test_collator_get_error_code);
|
||||
RUN_TEST(test_collator_get_error_message);
|
||||
RUN_TEST(test_collator_get_locale);
|
||||
RUN_TEST(test_collator_get_strength);
|
||||
RUN_TEST(test_collator_set_attribute);
|
||||
RUN_TEST(test_collator_set_strength);
|
||||
RUN_TEST(test_collator_sort_with_sort_keys);
|
||||
RUN_TEST(test_collator_sort);
|
||||
RUN_TEST(test_idn_to_ascii);
|
||||
RUN_TEST(test_idn_to_unicode);
|
||||
RUN_TEST(test_idn_to_utf8);
|
||||
RUN_TEST(test_Collator);
|
||||
RUN_TEST(test_Locale);
|
||||
RUN_TEST(test_Normalizer);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
bool TestExtIntl::test_intl_get_error_code() {
|
||||
return Count(true);
|
||||
}
|
||||
|
||||
bool TestExtIntl::test_intl_get_error_message() {
|
||||
return Count(true);
|
||||
}
|
||||
|
||||
bool TestExtIntl::test_intl_error_name() {
|
||||
return Count(true);
|
||||
}
|
||||
|
||||
bool TestExtIntl::test_intl_is_failure() {
|
||||
return Count(true);
|
||||
}
|
||||
|
||||
bool TestExtIntl::test_collator_asort() {
|
||||
return Count(true);
|
||||
}
|
||||
|
||||
bool TestExtIntl::test_collator_compare() {
|
||||
return Count(true);
|
||||
}
|
||||
|
||||
bool TestExtIntl::test_collator_create() {
|
||||
return Count(true);
|
||||
}
|
||||
|
||||
bool TestExtIntl::test_collator_get_attribute() {
|
||||
return Count(true);
|
||||
}
|
||||
|
||||
bool TestExtIntl::test_collator_get_error_code() {
|
||||
return Count(true);
|
||||
}
|
||||
|
||||
bool TestExtIntl::test_collator_get_error_message() {
|
||||
return Count(true);
|
||||
}
|
||||
|
||||
bool TestExtIntl::test_collator_get_locale() {
|
||||
return Count(true);
|
||||
}
|
||||
|
||||
bool TestExtIntl::test_collator_get_strength() {
|
||||
return Count(true);
|
||||
}
|
||||
|
||||
bool TestExtIntl::test_collator_set_attribute() {
|
||||
return Count(true);
|
||||
}
|
||||
|
||||
bool TestExtIntl::test_collator_set_strength() {
|
||||
return Count(true);
|
||||
}
|
||||
|
||||
bool TestExtIntl::test_collator_sort_with_sort_keys() {
|
||||
return Count(true);
|
||||
}
|
||||
|
||||
bool TestExtIntl::test_collator_sort() {
|
||||
return Count(true);
|
||||
}
|
||||
|
||||
bool TestExtIntl::test_idn_to_ascii() {
|
||||
VS(f_idn_to_ascii("www.m\xc3\xa5nsjonasson.se"),
|
||||
"www.xn--mnsjonasson-x8a.se");
|
||||
VS(f_idn_to_ascii("www.facebook.com"),
|
||||
"www.facebook.com");
|
||||
VS(f_idn_to_ascii("www.xn--m\xc3\xa5nsjonasson.se"),
|
||||
false);
|
||||
VS(f_idn_to_ascii("www.12345678901234567890123456789"
|
||||
"012345678901234m\xc3\xa5nsjonasson.se"),
|
||||
"www.xn--123456789012345678901234567890123456789"
|
||||
"01234mnsjonasson-5we.se");
|
||||
VS(f_idn_to_ascii("www.12345678901234567890123456789"
|
||||
"0123456789012345m\xc3\xa5nsjonasson.se"),
|
||||
false);
|
||||
VS(f_idn_to_ascii("\u1937ai\u18ed-\u18f0.tk", 1),
|
||||
"xn--ai--youq53b.tk")
|
||||
VS(f_idn_to_ascii("\u1937ai\u18ed-\u18f0.tk", 0),
|
||||
false)
|
||||
return Count(true);
|
||||
}
|
||||
|
||||
bool TestExtIntl::test_idn_to_unicode() {
|
||||
VS(f_idn_to_unicode("www.xn--mnsjonasson-x8a.se"),
|
||||
"www.m\xc3\xa5nsjonasson.se");
|
||||
VS(f_idn_to_unicode("www.facebook.com"),
|
||||
"www.facebook.com");
|
||||
VS(f_idn_to_unicode("www.xn--12345678901234567890123456789"
|
||||
"012345678901234mnsjonasson-5we.se"),
|
||||
"www.12345678901234567890123456789"
|
||||
"012345678901234m\xc3\xa5nsjonasson.se");
|
||||
return Count(true);
|
||||
}
|
||||
|
||||
bool TestExtIntl::test_idn_to_utf8() {
|
||||
VS(f_idn_to_utf8("www.xn--mnsjonasson-x8a.se"),
|
||||
"www.m\xc3\xa5nsjonasson.se");
|
||||
VS(f_idn_to_utf8("www.facebook.com"),
|
||||
"www.facebook.com");
|
||||
VS(f_idn_to_utf8("www.xn--12345678901234567890123456789"
|
||||
"012345678901234mnsjonasson-5we.se"),
|
||||
"www.12345678901234567890123456789"
|
||||
"012345678901234m\xc3\xa5nsjonasson.se");
|
||||
return Count(true);
|
||||
}
|
||||
|
||||
bool TestExtIntl::test_Collator() {
|
||||
return Count(true);
|
||||
}
|
||||
|
||||
bool TestExtIntl::test_Locale() {
|
||||
return Count(true);
|
||||
}
|
||||
|
||||
bool TestExtIntl::test_Normalizer() {
|
||||
VERIFY(c_Normalizer::ti_isnormalized("\xC3\x85"));
|
||||
VERIFY(!c_Normalizer::ti_isnormalized("A\xCC\x8A"));
|
||||
VS(c_Normalizer::ti_normalize("A\xCC\x8A", q_Normalizer$$FORM_C),
|
||||
"\xC3\x85");
|
||||
return Count(true);
|
||||
}
|
||||
|
||||
@@ -1,56 +0,0 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| HipHop for PHP |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 2010-2013 Facebook, Inc. (http://www.facebook.com) |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 3.01 of the PHP license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
| available through the world-wide-web at the following url: |
|
||||
| http://www.php.net/license/3_01.txt |
|
||||
| If you did not receive a copy of the PHP license and are unable to |
|
||||
| obtain it through the world-wide-web, please send a note to |
|
||||
| license@php.net so we can mail you a copy immediately. |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
#ifndef incl_HPHP_TEST_EXT_INTL_H_
|
||||
#define incl_HPHP_TEST_EXT_INTL_H_
|
||||
|
||||
// >>>>>> Generated by idl.php. Do NOT modify. <<<<<<
|
||||
|
||||
#include "hphp/test/ext/test_cpp_ext.h"
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class TestExtIntl : public TestCppExt {
|
||||
public:
|
||||
virtual bool RunTests(const std::string &which);
|
||||
|
||||
bool test_intl_get_error_code();
|
||||
bool test_intl_get_error_message();
|
||||
bool test_intl_error_name();
|
||||
bool test_intl_is_failure();
|
||||
bool test_collator_asort();
|
||||
bool test_collator_compare();
|
||||
bool test_collator_create();
|
||||
bool test_collator_get_attribute();
|
||||
bool test_collator_get_error_code();
|
||||
bool test_collator_get_error_message();
|
||||
bool test_collator_get_locale();
|
||||
bool test_collator_get_strength();
|
||||
bool test_collator_set_attribute();
|
||||
bool test_collator_set_strength();
|
||||
bool test_collator_sort_with_sort_keys();
|
||||
bool test_collator_sort();
|
||||
bool test_idn_to_ascii();
|
||||
bool test_idn_to_unicode();
|
||||
bool test_idn_to_utf8();
|
||||
bool test_Collator();
|
||||
bool test_Locale();
|
||||
bool test_Normalizer();
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#endif // incl_HPHP_TEST_EXT_INTL_H_
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
// Php doesn't support \u escapes.
|
||||
function u($x) { return json_decode("\"" . $x . "\""); }
|
||||
|
||||
var_dump(idn_to_ascii("www.m\xc3\xa5nsjonasson.se") ===
|
||||
"www.xn--mnsjonasson-x8a.se");
|
||||
var_dump(idn_to_ascii("www.facebook.com"));
|
||||
var_dump(idn_to_ascii("www.xn--m\xc3\xa5nsjonasson.se") === false);
|
||||
var_dump(idn_to_ascii("www.12345678901234567890123456789".
|
||||
"012345678901234m\xc3\xa5nsjonasson.se")
|
||||
===
|
||||
"www.xn--123456789012345678901234567890123456789".
|
||||
"01234mnsjonasson-5we.se");
|
||||
var_dump(idn_to_ascii("www.12345678901234567890123456789".
|
||||
"0123456789012345m\xc3\xa5nsjonasson.se") ===
|
||||
false);
|
||||
var_dump(idn_to_ascii(u('\u1937ai\u18ed-\u18f0.tk'), 1) ===
|
||||
"xn--ai--youq53b.tk");
|
||||
var_dump(idn_to_ascii(u('\u1937ai\u18ed-\u18f0.tk'), 0) ===
|
||||
false);
|
||||
@@ -0,0 +1,7 @@
|
||||
bool(true)
|
||||
string(16) "www.facebook.com"
|
||||
bool(true)
|
||||
bool(true)
|
||||
bool(true)
|
||||
bool(true)
|
||||
bool(true)
|
||||
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
var_dump(idn_to_unicode("www.xn--mnsjonasson-x8a.se") ===
|
||||
"www.m\xc3\xa5nsjonasson.se");
|
||||
var_dump(idn_to_unicode("www.facebook.com"));
|
||||
var_dump(idn_to_unicode("www.xn--12345678901234567890123456789".
|
||||
"012345678901234mnsjonasson-5we.se")
|
||||
===
|
||||
"www.12345678901234567890123456789".
|
||||
"012345678901234m\xc3\xa5nsjonasson.se");
|
||||
@@ -0,0 +1,3 @@
|
||||
bool(true)
|
||||
string(16) "www.facebook.com"
|
||||
bool(true)
|
||||
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
var_dump(idn_to_utf8("www.xn--mnsjonasson-x8a.se") ===
|
||||
"www.m\xc3\xa5nsjonasson.se");
|
||||
var_dump(idn_to_utf8("www.facebook.com"));
|
||||
var_dump(idn_to_utf8("www.xn--12345678901234567890123456789".
|
||||
"012345678901234mnsjonasson-5we.se")
|
||||
===
|
||||
"www.12345678901234567890123456789".
|
||||
"012345678901234m\xc3\xa5nsjonasson.se");
|
||||
@@ -0,0 +1,3 @@
|
||||
bool(true)
|
||||
string(16) "www.facebook.com"
|
||||
bool(true)
|
||||
@@ -0,0 +1,6 @@
|
||||
<?php
|
||||
|
||||
var_dump(Normalizer::isnormalized("\xC3\x85"));
|
||||
var_dump(Normalizer::isnormalized("A\xCC\x8A"));
|
||||
var_dump(Normalizer::normalize("A\xCC\x8A", Normalizer::FORM_C) ===
|
||||
"\xC3\x85");
|
||||
@@ -0,0 +1,3 @@
|
||||
int(1)
|
||||
int(0)
|
||||
bool(true)
|
||||
Referência em uma Nova Issue
Bloquear um usuário