(via -D or uconfig.h, as above)
and include those header files explicitly that you actually need.<br />
Note: The ICU test suites cannot be compiled with this setting.</li>
+ <li><b>utf_old.h:</b>
+ All of utf_old.h is deprecated or obsolete.<br />
+ Beginning with ICU 60,
+ you should define <code>U_HIDE_OBSOLETE_UTF_OLD_H</code> to 1
+ (via -D or uconfig.h, as above).
+ Use of any of these macros should be replaced as noted
+ in the comments for the obsolete macro.<br />
+ Note: The ICU test suites <i>can</i> be compiled with this setting.</li>
<li><b>.dat file:</b> By default, the ICU data is built into
a shared library (DLL). This is convenient because it requires no
install-time or runtime configuration,
#ifndef __UTF_OLD_H__
#define __UTF_OLD_H__
-#ifndef U_HIDE_DEPRECATED_API
+/**
+ * \def U_HIDE_OBSOLETE_UTF_OLD_H
+ *
+ * Hides the obsolete definitions in unicode/utf_old.h.
+ * Recommended to be set to 1 at compile time to make sure
+ * the long-deprecated macros are no longer used.
+ *
+ * For reasons for the deprecation see the utf_old.h file comments.
+ *
+ * @internal
+ */
+#ifndef U_HIDE_OBSOLETE_UTF_OLD_H
+# define U_HIDE_OBSOLETE_UTF_OLD_H 0
+#endif
+
+#if !defined(U_HIDE_DEPRECATED_API) && !U_HIDE_OBSOLETE_UTF_OLD_H
#include "unicode/utf.h"
#include "unicode/utf8.h"
*/
#define UTF_SET_CHAR_LIMIT(s, start, i, length) U16_SET_CP_LIMIT(s, start, i, length)
-#endif /* U_HIDE_DEPRECATED_API */
+#endif // !U_HIDE_DEPRECATED_API && !U_HIDE_OBSOLETE_UTF_OLD_H
#endif
-
#include "unicode/utypes.h"
#include "unicode/utf.h"
#include "unicode/utf8.h"
-#include "unicode/utf_old.h"
#include "uassert.h"
/*
static const UChar32
utf8_errorValue[6]={
- UTF8_ERROR_VALUE_1, UTF8_ERROR_VALUE_2, UTF_ERROR_VALUE, 0x10ffff,
+ // Same values as UTF8_ERROR_VALUE_1, UTF8_ERROR_VALUE_2, UTF_ERROR_VALUE,
+ // but without relying on the obsolete unicode/utf_old.h.
+ 0x15, 0x9f, 0xffff,
+ 0x10ffff,
0x3ffffff, 0x7fffffff
};
s+=i;
offset=0;
c=utf8_errorValue[length-1];
- UTF8_APPEND_CHAR_UNSAFE(s, offset, c);
+ U8_APPEND_UNSAFE(s, offset, c);
i=i+offset;
}
}
#include "unicode/ubiditransform.h"
#include "unicode/ushape.h"
#include "unicode/ustring.h"
+#include "unicode/utf16.h"
#ifdef __cplusplus
extern "C" {
#include "unicode/putil.h"
#include "unicode/ctest.h"
-#if U_NO_DEFAULT_INCLUDE_UTF_HEADERS
-/* deprecated - make tests pass with U_NO_DEFAULT_INCLUDE_UTF_HEADERS */
-#include "unicode/utf_old.h"
-#endif
-
#include <stdlib.h>
#ifndef U_USE_DEPRECATED_API
#include "unicode/uloc.h"
#include "unicode/uchar.h"
#include "unicode/ustring.h"
+#include "unicode/utf16.h"
#include "unicode/putil.h"
#include "callcoll.h"
#include "cmemory.h"
#include "unicode/utypes.h"
#include "cintltst.h"
#include "unicode/ustring.h"
+#include "unicode/utf16.h"
#include "cmemory.h"
#include "cstring.h"
#include "filestrm.h"
#include "unicode/putil.h"
#include "unicode/ustring.h"
#include "unicode/ucnv.h"
+#include "unicode/utf8.h"
+#include "unicode/utf16.h"
#include "string.h"
#include "cmemory.h"
#include "cstring.h"
#include "unicode/ustring.h"
#include "unicode/uloc.h"
#include "unicode/unorm2.h"
-
+#include "unicode/utf16.h"
+#include "unicode/utf_old.h"
#include "cintltst.h"
#include "putilimp.h"
#include "uparse.h"
for(i=0; i<UPRV_LENGTHOF(codeunit); i++){
UChar c=codeunit[i];
+ if(i<4){
+ if(!(U16_IS_SINGLE(c)) || (U16_IS_LEAD(c)) || (U16_IS_TRAIL(c)) ||
+ U16_IS_SURROGATE(c) || U_IS_SURROGATE(c)) {
+ log_err("ERROR: U+%04x is a single", c);
+ }
+
+ }
+ if(i >= 4 && i< 8){
+ if(!(U16_IS_LEAD(c)) || U16_IS_SINGLE(c) || U16_IS_TRAIL(c) ||
+ !U16_IS_SURROGATE(c) || !U_IS_SURROGATE(c)){
+ log_err("ERROR: U+%04x is a first surrogate", c);
+ }
+ }
+ if(i >= 8 && i< 12){
+ if(!(U16_IS_TRAIL(c)) || U16_IS_SINGLE(c) || U16_IS_LEAD(c) ||
+ !U16_IS_SURROGATE(c) || !U_IS_SURROGATE(c)){
+ log_err("ERROR: U+%04x is a second surrogate", c);
+ }
+ }
+#if !U_HIDE_OBSOLETE_UTF_OLD_H
if(i<4){
if(!(UTF_IS_SINGLE(c)) || (UTF_IS_LEAD(c)) || (UTF_IS_TRAIL(c)) ||(UTF_IS_SURROGATE(c))){
log_err("ERROR: U+%04x is a single", c);
log_err("ERROR: U+%04x is a second surrogate", c);
}
}
+#endif
}
-
}
static void TestCodePoint(){
0xfffe,
};
int32_t i;
- for(i=0; i<UPRV_LENGTHOF(codePoint); i++){
+ for(i=0; i<UPRV_LENGTHOF(codePoint); i++) {
UChar32 c=codePoint[i];
+ if(i<6) {
+ if(!U_IS_SURROGATE(c) || !U16_IS_SURROGATE(c)) {
+ log_err("ERROR: isSurrogate() failed for U+%04x\n", c);
+ }
+ if(U_IS_UNICODE_CHAR(c)) {
+ log_err("ERROR: isUnicodeChar() failed for U+%04x\n", c);
+ }
+ } else if(i >=6 && i<18) {
+ if(U_IS_SURROGATE(c) || U16_IS_SURROGATE(c)) {
+ log_err("ERROR: isSurrogate() failed for U+%04x\n", c);
+ }
+ if(!U_IS_UNICODE_CHAR(c)) {
+ log_err("ERROR: isUnicodeChar() failed for U+%04x\n", c);
+ }
+ } else if(i >=18 && i<20) {
+ if(U_IS_SURROGATE(c) || U16_IS_SURROGATE(c)) {
+ log_err("ERROR: isSurrogate() failed for U+%04x\n", c);
+ }
+ if(!U_IS_UNICODE_CHAR(c)) {
+ log_err("ERROR: isUnicodeChar() failed for U+%04x\n", c);
+ }
+ } else if(i >=18 && i<UPRV_LENGTHOF(codePoint)) {
+ if(U_IS_SURROGATE(c) || U16_IS_SURROGATE(c)) {
+ log_err("ERROR: isSurrogate() failed for U+%04x\n", c);
+ }
+ if(U_IS_UNICODE_CHAR(c)) {
+ log_err("ERROR: isUnicodeChar() failed for U+%04x\n", c);
+ }
+ }
+#if !U_HIDE_OBSOLETE_UTF_OLD_H
if(i<6){
- if(!UTF_IS_SURROGATE(c) || !U_IS_SURROGATE(c) || !U16_IS_SURROGATE(c)){
+ if(!UTF_IS_SURROGATE(c)){
log_err("ERROR: isSurrogate() failed for U+%04x\n", c);
}
if(UTF_IS_VALID(c)){
log_err("ERROR: isValid() failed for U+%04x\n", c);
}
- if(UTF_IS_UNICODE_CHAR(c) || U_IS_UNICODE_CHAR(c)){
+ if(UTF_IS_UNICODE_CHAR(c)){
log_err("ERROR: isUnicodeChar() failed for U+%04x\n", c);
}
if(UTF_IS_ERROR(c)){
log_err("ERROR: isError() failed for U+%04x\n", c);
}
}else if(i >=6 && i<18){
- if(UTF_IS_SURROGATE(c) || U_IS_SURROGATE(c) || U16_IS_SURROGATE(c)){
+ if(UTF_IS_SURROGATE(c)){
log_err("ERROR: isSurrogate() failed for U+%04x\n", c);
}
if(!UTF_IS_VALID(c)){
log_err("ERROR: isValid() failed for U+%04x\n", c);
}
- if(!UTF_IS_UNICODE_CHAR(c) || !U_IS_UNICODE_CHAR(c)){
+ if(!UTF_IS_UNICODE_CHAR(c)){
log_err("ERROR: isUnicodeChar() failed for U+%04x\n", c);
}
if(UTF_IS_ERROR(c)){
log_err("ERROR: isError() failed for U+%04x\n", c);
}
}else if(i >=18 && i<20){
- if(UTF_IS_SURROGATE(c) || U_IS_SURROGATE(c) || U16_IS_SURROGATE(c)){
+ if(UTF_IS_SURROGATE(c)){
log_err("ERROR: isSurrogate() failed for U+%04x\n", c);
}
if(UTF_IS_VALID(c)){
log_err("ERROR: isValid() failed for U+%04x\n", c);
}
- if(!UTF_IS_UNICODE_CHAR(c) || !U_IS_UNICODE_CHAR(c)){
+ if(!UTF_IS_UNICODE_CHAR(c)){
log_err("ERROR: isUnicodeChar() failed for U+%04x\n", c);
}
if(!UTF_IS_ERROR(c)){
}
}
else if(i >=18 && i<UPRV_LENGTHOF(codePoint)){
- if(UTF_IS_SURROGATE(c) || U_IS_SURROGATE(c) || U16_IS_SURROGATE(c)){
+ if(UTF_IS_SURROGATE(c)){
log_err("ERROR: isSurrogate() failed for U+%04x\n", c);
}
if(UTF_IS_VALID(c)){
log_err("ERROR: isValid() failed for U+%04x\n", c);
}
- if(UTF_IS_UNICODE_CHAR(c) || U_IS_UNICODE_CHAR(c)){
+ if(UTF_IS_UNICODE_CHAR(c)){
log_err("ERROR: isUnicodeChar() failed for U+%04x\n", c);
}
if(!UTF_IS_ERROR(c)){
log_err("ERROR: isError() failed for U+%04x\n", c);
}
}
+#endif
}
if(
};
int32_t i;
+#if !U_HIDE_OBSOLETE_UTF_OLD_H
UBool multiple;
+#endif
for(i=0; i<UPRV_LENGTHOF(codepoint); i=(int16_t)(i+2)){
UChar32 c=codepoint[i+1];
- if(UTF_CHAR_LENGTH(c) != codepoint[i] || U16_LENGTH(c) != codepoint[i]){
+ if(
+#if !U_HIDE_OBSOLETE_UTF_OLD_H
+ UTF_CHAR_LENGTH(c) != codepoint[i] ||
+#endif
+ U16_LENGTH(c) != codepoint[i]) {
log_err("The no: of code units for U+%04x:- Expected: %d Got: %d\n", c, codepoint[i], U16_LENGTH(c));
}
+#if !U_HIDE_OBSOLETE_UTF_OLD_H
multiple=(UBool)(codepoint[i] == 1 ? FALSE : TRUE);
if(UTF_NEED_MULTIPLE_UCHAR(c) != multiple){
log_err("ERROR: Unicode::needMultipleUChar() failed for U+%04x\n", c);
}
+#endif
}
}
#include "unicode/utypes.h"
#include "unicode/ustring.h"
#include "unicode/uset.h"
+#include "unicode/utf8.h"
+#include "unicode/utf16.h"
#include "cintltst.h"
#include "cmemory.h"
if (currCh == SURROGATE_HIGH_START) {
currCh = SURROGATE_LOW_END + 1; /* Skip surrogate range */
}
- UTF16_APPEND_CHAR_SAFE(standardForm, offset16, MAX_LENGTH, currCh);
- UTF8_APPEND_CHAR_SAFE(utf8, offset8, MAX_LENGTH, currCh);
+ U16_APPEND_UNSAFE(standardForm, offset16, currCh);
+ U8_APPEND_UNSAFE(utf8, offset8, currCh);
currCh++;
}
if(!convertFromU(standardForm, offset16,
if (currCh == SURROGATE_HIGH_START) {
currCh = SURROGATE_LOW_END + 1; /* Skip surrogate range */
}
- UTF16_APPEND_CHAR_SAFE(standardForm, offset16, MAX_LENGTH, currCh);
- UTF32_APPEND_CHAR_SAFE(utf32, offset32, MAX_LENGTH, currCh);
+ U16_APPEND_UNSAFE(standardForm, offset16, currCh);
+ utf32[offset32++] = currCh;
currCh++;
}
if(!convertFromU(standardForm, offset16,
#include "unicode/uregex.h"
#include "unicode/ustring.h"
#include "unicode/utext.h"
+#include "unicode/utf8.h"
#include "cintltst.h"
#include "cmemory.h"
#include <stdio.h>
#include "unicode/utypes.h"
+#include "unicode/utf8.h"
#include "utrie2.h"
#include "utrie.h"
#include "cstring.h"
#include "unicode/utypes.h"
#include "unicode/ucnvsel.h"
#include "unicode/ustring.h"
+#include "unicode/utf8.h"
#include "cmemory.h"
#include "cstring.h"
#include "propsvec.h"
*/
#include "unicode/utypes.h"
-#include "unicode/utf16.h"
#include "unicode/ustring.h"
+#include "unicode/utf16.h"
+#include "unicode/utf_old.h"
#include "cmemory.h"
#include "cstring.h"
#include "cintltst.h"
#include <stdio.h>
-static void printUChars(const UChar *uchars);
+// Obsolete macro from obsolete unicode/utf_old.h, for some old test data.
+#ifndef UTF_ERROR_VALUE
+# define UTF_ERROR_VALUE 0xffff
+#endif
+
+#if !U_HIDE_OBSOLETE_UTF_OLD_H
+static void printUChars(const UChar *uchars) {
+ int16_t i=0;
+ for(i=0; i<u_strlen(uchars); i++) {
+ printf("%x ", *(uchars+i));
+ }
+}
+#endif
static void TestCodeUnitValues(void);
static void TestCharLength(void);
UChar c=codeunit[i];
log_verbose("Testing code unit value of %x\n", c);
if(i<4){
- if(!UTF16_IS_SINGLE(c) || UTF16_IS_LEAD(c) || UTF16_IS_TRAIL(c) || !U16_IS_SINGLE(c) || U16_IS_LEAD(c) || U16_IS_TRAIL(c)){
+ if(
+#if !U_HIDE_OBSOLETE_UTF_OLD_H
+ !UTF16_IS_SINGLE(c) || UTF16_IS_LEAD(c) || UTF16_IS_TRAIL(c) ||
+#endif
+ !U16_IS_SINGLE(c) || U16_IS_LEAD(c) || U16_IS_TRAIL(c)) {
log_err("ERROR: %x is a single character\n", c);
}
}
if(i >= 4 && i< 8){
- if(!UTF16_IS_LEAD(c) || UTF16_IS_SINGLE(c) || UTF16_IS_TRAIL(c) || !U16_IS_LEAD(c) || U16_IS_SINGLE(c) || U16_IS_TRAIL(c)){
+ if(
+#if !U_HIDE_OBSOLETE_UTF_OLD_H
+ !UTF16_IS_LEAD(c) || UTF16_IS_SINGLE(c) || UTF16_IS_TRAIL(c) ||
+#endif
+ !U16_IS_LEAD(c) || U16_IS_SINGLE(c) || U16_IS_TRAIL(c)){
log_err("ERROR: %x is a first surrogate\n", c);
}
}
if(i >= 8 && i< 12){
- if(!UTF16_IS_TRAIL(c) || UTF16_IS_SINGLE(c) || UTF16_IS_LEAD(c) || !U16_IS_TRAIL(c) || U16_IS_SINGLE(c) || U16_IS_LEAD(c)){
+ if(
+#if !U_HIDE_OBSOLETE_UTF_OLD_H
+ !UTF16_IS_TRAIL(c) || UTF16_IS_SINGLE(c) || UTF16_IS_LEAD(c) ||
+#endif
+ !U16_IS_TRAIL(c) || U16_IS_SINGLE(c) || U16_IS_LEAD(c)) {
log_err("ERROR: %x is a second surrogate\n", c);
}
}
};
int16_t i;
+#if !U_HIDE_OBSOLETE_UTF_OLD_H
UBool multiple;
+#endif
for(i=0; i<UPRV_LENGTHOF(codepoint); i=(int16_t)(i+2)){
UChar32 c=codepoint[i+1];
- if(UTF16_CHAR_LENGTH(c) != (uint16_t)codepoint[i] || U16_LENGTH(c) != (uint16_t)codepoint[i]){
- log_err("The no: of code units for %lx:- Expected: %d Got: %d\n", c, codepoint[i], UTF16_CHAR_LENGTH(c));
+ if(
+#if !U_HIDE_OBSOLETE_UTF_OLD_H
+ UTF16_CHAR_LENGTH(c) != (uint16_t)codepoint[i] ||
+#endif
+ U16_LENGTH(c) != (uint16_t)codepoint[i]) {
+ log_err("The no: of code units for %lx:- Expected: %d Got: %d\n", c, codepoint[i], U16_LENGTH(c));
}else{
- log_verbose("The no: of code units for %lx is %d\n",c, UTF16_CHAR_LENGTH(c) );
+ log_verbose("The no: of code units for %lx is %d\n",c, U16_LENGTH(c));
}
+#if !U_HIDE_OBSOLETE_UTF_OLD_H
multiple=(UBool)(codepoint[i] == 1 ? FALSE : TRUE);
if(UTF16_NEED_MULTIPLE_UCHAR(c) != multiple){
log_err("ERROR: UTF16_NEED_MULTIPLE_UCHAR failed for %lx\n", c);
}
+#endif
}
}
uint16_t offset=0;
for(offset=0; offset<UPRV_LENGTHOF(input); offset++) {
if(0<offset && offset<UPRV_LENGTHOF(input)-1){
+#if !U_HIDE_OBSOLETE_UTF_OLD_H
UTF16_GET_CHAR_UNSAFE(input, offset, c);
if(c != result[i]){
log_err("ERROR: UTF16_GET_CHAR_UNSAFE failed for offset=%ld. Expected:%lx Got:%lx\n", offset, result[i], c);
}
-
+#endif
U16_GET_UNSAFE(input, offset, c);
if(c != result[i]){
log_err("ERROR: U16_GET_CHAR_UNSAFE failed for offset=%ld. Expected:%lx Got:%lx\n", offset, result[i], c);
}
}
-
- UTF16_GET_CHAR_SAFE(input, 0, offset, UPRV_LENGTHOF(input), c, FALSE);
expected=result[i+1];
+#if !U_HIDE_OBSOLETE_UTF_OLD_H
+ UTF16_GET_CHAR_SAFE(input, 0, offset, UPRV_LENGTHOF(input), c, FALSE);
if(c != expected) {
log_err("ERROR: UTF16_GET_CHAR_SAFE failed for offset=%ld. Expected:%lx Got:%lx\n", offset, expected, c);
}
-
+#endif
U16_GET(input, 0, offset, UPRV_LENGTHOF(input), c);
if(c != expected) {
log_err("ERROR: U16_GET failed for offset=%ld. Expected:%lx Got:%lx\n", offset, expected, c);
if(c != expected) {
log_err("ERROR: U16_GET_OR_FFFD failed for offset=%ld. Expected:%lx Got:%lx\n", offset, expected, c);
}
-
+#if !U_HIDE_OBSOLETE_UTF_OLD_H
UTF16_GET_CHAR_SAFE(input, 0, offset, UPRV_LENGTHOF(input), c, TRUE);
if(c != result[i+2]){
log_err("ERROR: UTF16_GET_CHAR_SAFE(strict) failed for offset=%ld. Expected:%lx Got:%lx\n", offset, result[i+2], c);
}
+#endif
i=(uint16_t)(i+3);
}
-
}
static void TestNextPrevChar(){
uint16_t offset=0, setOffset=0;
for(offset=0; offset<UPRV_LENGTHOF(input); offset++){
setOffset=offset;
+#if !U_HIDE_OBSOLETE_UTF_OLD_H
UTF16_NEXT_CHAR_UNSAFE(input, setOffset, c);
if(setOffset != movedOffset[i]){
log_err("ERROR: UTF16_NEXT_CHAR_UNSAFE failed to move the offset correctly at %d\n ExpectedOffset:%d Got %d\n",
if(c != result[i]){
log_err("ERROR: UTF16_NEXT_CHAR_UNSAFE failed for offset=%ld. Expected:%lx Got:%lx\n", offset, result[i], c);
}
-
+#endif
setOffset=offset;
U16_NEXT_UNSAFE(input, setOffset, c);
if(setOffset != movedOffset[i]){
if(c != result[i]){
log_err("ERROR: U16_NEXT_CHAR_UNSAFE failed for offset=%ld. Expected:%lx Got:%lx\n", offset, result[i], c);
}
-
+ expected=result[i+1];
+#if !U_HIDE_OBSOLETE_UTF_OLD_H
setOffset=offset;
UTF16_NEXT_CHAR_SAFE(input, setOffset, UPRV_LENGTHOF(input), c, FALSE);
if(setOffset != movedOffset[i+1]){
log_err("ERROR: UTF16_NEXT_CHAR_SAFE failed to move the offset correctly at %d\n ExpectedOffset:%d Got %d\n",
offset, movedOffset[i+1], setOffset);
}
- expected=result[i+1];
if(c != expected) {
log_err("ERROR: UTF16_NEXT_CHAR_SAFE failed for input=%ld. Expected:%lx Got:%lx\n", offset, expected, c);
}
-
+#endif
setOffset=offset;
U16_NEXT(input, setOffset, UPRV_LENGTHOF(input), c);
if(setOffset != movedOffset[i+1]){
if(c != expected){
log_err("ERROR: U16_NEXT_OR_FFFD failed for input=%ld. Expected:%lx Got:%lx\n", offset, expected, c);
}
-
+#if !U_HIDE_OBSOLETE_UTF_OLD_H
setOffset=offset;
UTF16_NEXT_CHAR_SAFE(input, setOffset, UPRV_LENGTHOF(input), c, TRUE);
if(setOffset != movedOffset[i+1]){
if(c != result[i+2]){
log_err("ERROR: UTF16_NEXT_CHAR_SAFE(strict) failed for input=%ld. Expected:%lx Got:%lx\n", offset, result[i+2], c);
}
-
+#endif
i=(uint16_t)(i+6);
}
i=0;
for(offset=(uint16_t)UPRV_LENGTHOF(input); offset > 0; --offset){
setOffset=offset;
+#if !U_HIDE_OBSOLETE_UTF_OLD_H
UTF16_PREV_CHAR_UNSAFE(input, setOffset, c);
if(setOffset != movedOffset[i+3]){
log_err("ERROR: UTF16_PREV_CHAR_UNSAFE failed to move the offset correctly at %d\n ExpectedOffset:%d Got %d\n",
if(c != result[i+3]){
log_err("ERROR: UTF16_PREV_CHAR_UNSAFE failed for offset=%ld. Expected:%lx Got:%lx\n", offset, result[i+3], c);
}
-
+#endif
setOffset=offset;
U16_PREV_UNSAFE(input, setOffset, c);
if(setOffset != movedOffset[i+3]){
if(c != result[i+3]){
log_err("ERROR: U16_PREV_CHAR_UNSAFE failed for offset=%ld. Expected:%lx Got:%lx\n", offset, result[i+3], c);
}
-
+#if !U_HIDE_OBSOLETE_UTF_OLD_H
setOffset=offset;
UTF16_PREV_CHAR_SAFE(input, 0, setOffset, c, FALSE);
if(setOffset != movedOffset[i+4]){
if(c != result[i+4]){
log_err("ERROR: UTF16_PREV_CHAR_SAFE failed for input=%ld. Expected:%lx Got:%lx\n", offset, result[i+4], c);
}
-
+#endif
setOffset=offset;
U16_PREV(input, 0, setOffset, c);
if(setOffset != movedOffset[i+4]){
if(c != expected) {
log_err("ERROR: U16_PREV_OR_FFFD failed for input=%ld. Expected:%lx Got:%lx\n", offset, expected, c);
}
-
+#if !U_HIDE_OBSOLETE_UTF_OLD_H
setOffset=offset;
UTF16_PREV_CHAR_SAFE(input, 0, setOffset, c, TRUE);
if(setOffset != movedOffset[i+5]){
if(c != result[i+5]){
log_err("ERROR: UTF16_PREV_CHAR_SAFE(strict) failed for input=%ld. Expected:%lx Got:%lx\n", offset, result[i+5], c);
}
-
+#endif
i=(uint16_t)(i+6);
}
uint16_t offunsafe=0, offsafe=0;
uint16_t i=0;
+#if !U_HIDE_OBSOLETE_UTF_OLD_H
while(offunsafe < UPRV_LENGTHOF(input)){
UTF16_FWD_1_UNSAFE(input, offunsafe);
if(offunsafe != fwd_unsafe[i]){
}
i++;
}
-
+#endif
offunsafe=0, offsafe=0;
i=0;
while(offunsafe < UPRV_LENGTHOF(input)){
}
i++;
}
-
+#if !U_HIDE_OBSOLETE_UTF_OLD_H
+ offunsafe=0, offsafe=0;
i=0;
while(offsafe < UPRV_LENGTHOF(input)){
UTF16_FWD_1_SAFE(input, offsafe, UPRV_LENGTHOF(input));
}
i++;
}
-
+#endif
+ offunsafe=0, offsafe=0;
i=0;
while(offsafe < UPRV_LENGTHOF(input)){
U16_FWD_1(input, offsafe, UPRV_LENGTHOF(input));
}
i++;
}
-
+#if !U_HIDE_OBSOLETE_UTF_OLD_H
offunsafe=UPRV_LENGTHOF(input);
offsafe=UPRV_LENGTHOF(input);
i=0;
}
i++;
}
-
+#endif
offunsafe=UPRV_LENGTHOF(input);
offsafe=UPRV_LENGTHOF(input);
i=0;
}
i++;
}
-
+#if !U_HIDE_OBSOLETE_UTF_OLD_H
+ offunsafe=UPRV_LENGTHOF(input);
+ offsafe=UPRV_LENGTHOF(input);
i=0;
while(offsafe > 0){
UTF16_BACK_1_SAFE(input,0, offsafe);
}
i++;
}
-
+#endif
+ offunsafe=UPRV_LENGTHOF(input);
+ offsafe=UPRV_LENGTHOF(input);
i=0;
while(offsafe > 0){
U16_BACK_1(input,0, offsafe);
offunsafe=0;
offsafe=0;
+#if !U_HIDE_OBSOLETE_UTF_OLD_H
for(i=0; i<UPRV_LENGTHOF(Nvalue)-2; i++){ /*didn't want it to fail(we assume 0<i<length)*/
UTF16_FWD_N_UNSAFE(input, offunsafe, Nvalue[i]);
if(offunsafe != fwd_N_unsafe[i]){
log_err("ERROR: Forward_N_unsafe offset expected:%d, Got:%d\n", fwd_N_unsafe[i], offunsafe);
}
}
-
+#endif
offunsafe=0;
for(i=0; i<UPRV_LENGTHOF(Nvalue)-2; i++){ /*didn't want it to fail(we assume 0<i<length)*/
U16_FWD_N_UNSAFE(input, offunsafe, Nvalue[i]);
log_err("ERROR: U16_FWD_N_UNSAFE offset expected:%d, Got:%d\n", fwd_N_unsafe[i], offunsafe);
}
}
-
+#if !U_HIDE_OBSOLETE_UTF_OLD_H
offsafe=0;
for(i=0; i<UPRV_LENGTHOF(Nvalue); i++){
UTF16_FWD_N_SAFE(input, offsafe, UPRV_LENGTHOF(input), Nvalue[i]);
if(offsafe != fwd_N_safe[i]){
log_err("ERROR: Forward_N_safe offset expected:%d, Got:%d\n", fwd_N_safe[i], offsafe);
}
-
}
-
+#endif
offsafe=0;
for(i=0; i<UPRV_LENGTHOF(Nvalue); i++){
U16_FWD_N(input, offsafe, UPRV_LENGTHOF(input), Nvalue[i]);
if(offsafe != fwd_N_safe[i]){
log_err("ERROR: U16_FWD_N offset expected:%d, Got:%d\n", fwd_N_safe[i], offsafe);
}
-
}
-
+#if !U_HIDE_OBSOLETE_UTF_OLD_H
offunsafe=UPRV_LENGTHOF(input);
for(i=0; i<UPRV_LENGTHOF(Nvalue)-2; i++){
UTF16_BACK_N_UNSAFE(input, offunsafe, Nvalue[i]);
log_err("ERROR: backward_N_unsafe offset expected:%d, Got:%d\n", back_N_unsafe[i], offunsafe);
}
}
-
+#endif
offunsafe=UPRV_LENGTHOF(input);
for(i=0; i<UPRV_LENGTHOF(Nvalue)-2; i++){
U16_BACK_N_UNSAFE(input, offunsafe, Nvalue[i]);
log_err("ERROR: U16_BACK_N_UNSAFE offset expected:%d, Got:%d\n", back_N_unsafe[i], offunsafe);
}
}
-
+#if !U_HIDE_OBSOLETE_UTF_OLD_H
offsafe=UPRV_LENGTHOF(input);
for(i=0; i<UPRV_LENGTHOF(Nvalue); i++){
UTF16_BACK_N_SAFE(input, 0, offsafe, Nvalue[i]);
log_err("ERROR: backward_N_safe offset expected:%d, Got:%d\n", back_N_safe[i], offsafe);
}
}
-
+#endif
offsafe=UPRV_LENGTHOF(input);
for(i=0; i<UPRV_LENGTHOF(Nvalue); i++){
U16_BACK_N(input, 0, offsafe, Nvalue[i]);
uint16_t i=0;
uint16_t offset=0, setOffset=0;
for(offset=0; offset<UPRV_LENGTHOF(input); offset++){
+#if !U_HIDE_OBSOLETE_UTF_OLD_H
setOffset=offset;
UTF16_SET_CHAR_START_UNSAFE(input, setOffset);
if(setOffset != start_unsafe[i]){
log_err("ERROR: UTF16_SET_CHAR_START_UNSAFE failed for offset=%ld. Expected:%lx Got:%lx\n", offset, start_unsafe[i], setOffset);
}
-
+#endif
setOffset=offset;
U16_SET_CP_START_UNSAFE(input, setOffset);
if(setOffset != start_unsafe[i]){
log_err("ERROR: U16_SET_CHAR_START_UNSAFE failed for offset=%ld. Expected:%lx Got:%lx\n", offset, start_unsafe[i], setOffset);
}
-
+#if !U_HIDE_OBSOLETE_UTF_OLD_H
setOffset=offset;
UTF16_SET_CHAR_START_SAFE(input, 0, setOffset);
if(setOffset != start_safe[i]){
log_err("ERROR: UTF16_SET_CHAR_START_SAFE failed for offset=%ld. Expected:%lx Got:%lx\n", offset, start_safe[i], setOffset);
}
-
+#endif
setOffset=offset;
U16_SET_CP_START(input, 0, setOffset);
if(setOffset != start_safe[i]){
}
if (offset > 0) {
+#if !U_HIDE_OBSOLETE_UTF_OLD_H
setOffset=offset;
UTF16_SET_CHAR_LIMIT_UNSAFE(input, setOffset);
if(setOffset != limit_unsafe[i]){
log_err("ERROR: UTF16_SET_CHAR_LIMIT_UNSAFE failed for offset=%ld. Expected:%lx Got:%lx\n", offset, limit_unsafe[i], setOffset);
}
-
+#endif
setOffset=offset;
U16_SET_CP_LIMIT_UNSAFE(input, setOffset);
if(setOffset != limit_unsafe[i]){
}
static void TestAppendChar(){
+#if !U_HIDE_OBSOLETE_UTF_OLD_H
static UChar s[5]={0x0061, 0x0062, 0x0063, 0x0064, 0x0000};
static uint32_t test[]={
/*append-position(unsafe), CHAR to be appended */
count++;
}
free(str);
-
+#endif
}
static void TestAppend() {
static UChar32 s[] = {0x10000, 0x10ffff, 0x50000, 0x100000, 0x1abcd};
int i = 0;
while (i < 5) {
- UChar first = UTF_FIRST_SURROGATE(s[i]);
- UChar second = UTF_SECOND_SURROGATE(s[i]);
+ UChar first = U16_LEAD(s[i]);
+ UChar second = U16_TRAIL(s[i]);
/* algorithm from the Unicode consortium */
UChar firstresult = (UChar)(((s[i] - 0x10000) / 0x400) + 0xD800);
UChar secondresult = (UChar)(((s[i] - 0x10000) % 0x400) + 0xDC00);
- if (first != UTF16_LEAD(s[i]) || first != U16_LEAD(s[i]) || first != firstresult) {
+ if (
+#if !U_HIDE_OBSOLETE_UTF_OLD_H
+ first != UTF16_LEAD(s[i]) || first != UTF_FIRST_SURROGATE(s[i]) ||
+#endif
+ first != firstresult) {
log_err("Failure in first surrogate in 0x%x expected to be 0x%x\n",
s[i], firstresult);
}
- if (second != UTF16_TRAIL(s[i]) || second != U16_TRAIL(s[i]) || second != secondresult) {
+ if (
+#if !U_HIDE_OBSOLETE_UTF_OLD_H
+ second != UTF16_TRAIL(s[i]) || second != UTF_SECOND_SURROGATE(s[i]) ||
+#endif
+ second != secondresult) {
log_err("Failure in second surrogate in 0x%x expected to be 0x%x\n",
s[i], secondresult);
}
i ++;
}
}
-
-static void printUChars(const UChar *uchars){
- int16_t i=0;
- for(i=0; i<u_strlen(uchars); i++){
- printf("%x ", *(uchars+i));
- }
-}
#include "unicode/utypes.h"
#include "unicode/utf8.h"
+#include "unicode/utf_old.h"
#include "cmemory.h"
#include "cintltst.h"
/* -------------------------------------------------------------------------- */
-static void printUChars(const uint8_t *uchars, int16_t len);
+// Obsolete macros from obsolete unicode/utf_old.h, for some old test data.
+#ifndef UTF8_ERROR_VALUE_1
+# define UTF8_ERROR_VALUE_1 0x15
+#endif
+#ifndef UTF8_ERROR_VALUE_2
+# define UTF8_ERROR_VALUE_2 0x9f
+#endif
+#ifndef UTF_ERROR_VALUE
+# define UTF_ERROR_VALUE 0xffff
+#endif
+#ifndef UTF_IS_ERROR
+# define UTF_IS_ERROR(c) \
+ (((c)&0xfffe)==0xfffe || (c)==UTF8_ERROR_VALUE_1 || (c)==UTF8_ERROR_VALUE_2)
+#endif
+
+#if !U_HIDE_OBSOLETE_UTF_OLD_H
+static void printUChars(const uint8_t *uchars, int16_t len){
+ int16_t i=0;
+ for(i=0; i<len; i++){
+ log_err("0x%02x ", *(uchars+i));
+ }
+}
+#endif
static void TestCodeUnitValues(void);
static void TestCharLength(void);
uint8_t c=codeunit[i];
log_verbose("Testing code unit value of %x\n", c);
if(i<4){
- if(!UTF8_IS_SINGLE(c) || UTF8_IS_LEAD(c) || UTF8_IS_TRAIL(c) || !U8_IS_SINGLE(c) || U8_IS_LEAD(c) || U8_IS_TRAIL(c)){
+ if(
+#if !U_HIDE_OBSOLETE_UTF_OLD_H
+ !UTF8_IS_SINGLE(c) || UTF8_IS_LEAD(c) || UTF8_IS_TRAIL(c) ||
+#endif
+ !U8_IS_SINGLE(c) || U8_IS_LEAD(c) || U8_IS_TRAIL(c)) {
log_err("ERROR: 0x%02x is a single byte but results in single: %c lead: %c trail: %c\n",
- c, UTF8_IS_SINGLE(c) ? 'y' : 'n', UTF8_IS_LEAD(c) ? 'y' : 'n', UTF8_IS_TRAIL(c) ? 'y' : 'n');
+ c, U8_IS_SINGLE(c) ? 'y' : 'n', U8_IS_LEAD(c) ? 'y' : 'n', U8_IS_TRAIL(c) ? 'y' : 'n');
}
} else if(i< 8){
- if(!UTF8_IS_LEAD(c) || UTF8_IS_SINGLE(c) || UTF8_IS_TRAIL(c) || !U8_IS_LEAD(c) || U8_IS_SINGLE(c) || U8_IS_TRAIL(c)){
+ if(
+#if !U_HIDE_OBSOLETE_UTF_OLD_H
+ !UTF8_IS_LEAD(c) || UTF8_IS_SINGLE(c) || UTF8_IS_TRAIL(c) ||
+#endif
+ !U8_IS_LEAD(c) || U8_IS_SINGLE(c) || U8_IS_TRAIL(c)) {
log_err("ERROR: 0x%02x is a lead byte but results in single: %c lead: %c trail: %c\n",
- c, UTF8_IS_SINGLE(c) ? 'y' : 'n', UTF8_IS_LEAD(c) ? 'y' : 'n', UTF8_IS_TRAIL(c) ? 'y' : 'n');
+ c, U8_IS_SINGLE(c) ? 'y' : 'n', U8_IS_LEAD(c) ? 'y' : 'n', U8_IS_TRAIL(c) ? 'y' : 'n');
}
} else if(i< 12){
- if(!UTF8_IS_TRAIL(c) || UTF8_IS_SINGLE(c) || UTF8_IS_LEAD(c) || !U8_IS_TRAIL(c) || U8_IS_SINGLE(c) || U8_IS_LEAD(c)){
+ if(
+#if !U_HIDE_OBSOLETE_UTF_OLD_H
+ !UTF8_IS_TRAIL(c) || UTF8_IS_SINGLE(c) || UTF8_IS_LEAD(c) ||
+#endif
+ !U8_IS_TRAIL(c) || U8_IS_SINGLE(c) || U8_IS_LEAD(c)){
log_err("ERROR: 0x%02x is a trail byte but results in single: %c lead: %c trail: %c\n",
- c, UTF8_IS_SINGLE(c) ? 'y' : 'n', UTF8_IS_LEAD(c) ? 'y' : 'n', UTF8_IS_TRAIL(c) ? 'y' : 'n');
+ c, U8_IS_SINGLE(c) ? 'y' : 'n', U8_IS_LEAD(c) ? 'y' : 'n', U8_IS_TRAIL(c) ? 'y' : 'n');
}
}
}
};
int16_t i;
+#if !U_HIDE_OBSOLETE_UTF_OLD_H
UBool multiple;
+#endif
for(i=0; i<UPRV_LENGTHOF(codepoint); i=(int16_t)(i+2)){
UChar32 c=codepoint[i+1];
- if(UTF8_CHAR_LENGTH(c) != (uint16_t)codepoint[i] || U8_LENGTH(c) != (uint16_t)codepoint[i]){
- log_err("The no: of code units for %lx:- Expected: %d Got: %d\n", c, codepoint[i], UTF8_CHAR_LENGTH(c));
+ if(
+#if !U_HIDE_OBSOLETE_UTF_OLD_H
+ UTF8_CHAR_LENGTH(c) != (uint16_t)codepoint[i] ||
+#endif
+ U8_LENGTH(c) != (uint16_t)codepoint[i]) {
+ log_err("The no: of code units for %lx:- Expected: %d Got: %d\n", c, codepoint[i], U8_LENGTH(c));
}else{
- log_verbose("The no: of code units for %lx is %d\n",c, UTF8_CHAR_LENGTH(c));
+ log_verbose("The no: of code units for %lx is %d\n",c, U8_LENGTH(c));
}
+#if !U_HIDE_OBSOLETE_UTF_OLD_H
multiple=(UBool)(codepoint[i] == 1 ? FALSE : TRUE);
if(UTF8_NEED_MULTIPLE_UCHAR(c) != multiple){
log_err("ERROR: UTF8_NEED_MULTIPLE_UCHAR failed for %lx\n", c);
}
+#endif
}
}
for(offset=0; offset<sizeof(input); offset++) {
if (offset < sizeof(input) - 1) {
+#if !U_HIDE_OBSOLETE_UTF_OLD_H
UTF8_GET_CHAR_UNSAFE(input, offset, c);
if(c != result[i]){
log_err("ERROR: UTF8_GET_CHAR_UNSAFE failed for offset=%ld. Expected:%lx Got:%lx\n", offset, result[i], c);
}
-
+#endif
U8_GET_UNSAFE(input, offset, c);
if(c != result[i]){
log_err("ERROR: U8_GET_UNSAFE failed for offset=%ld. Expected:%lx Got:%lx\n", offset, result[i], c);
}
}
-
- UTF8_GET_CHAR_SAFE(input, 0, offset, sizeof(input), c, FALSE);
expected=result[i+1];
+#if !U_HIDE_OBSOLETE_UTF_OLD_H
+ UTF8_GET_CHAR_SAFE(input, 0, offset, sizeof(input), c, FALSE);
if(c != expected){
log_err("ERROR: UTF8_GET_CHAR_SAFE failed for offset=%ld. Expected:%lx Got:%lx\n", offset, expected, c);
}
-
+#endif
U8_GET(input, 0, offset, sizeof(input), c);
if(UTF_IS_ERROR(expected)) { expected=U_SENTINEL; }
if(c != expected){
if(c != expected){
log_err("ERROR: U8_GET_OR_FFFD failed for offset=%ld. Expected:%lx Got:%lx\n", offset, expected, c);
}
-
+#if !U_HIDE_OBSOLETE_UTF_OLD_H
UTF8_GET_CHAR_SAFE(input, 0, offset, sizeof(input), c, TRUE);
if(c != result[i+2]){
log_err("ERROR: UTF8_GET_CHAR_SAFE(strict) failed for offset=%ld. Expected:%lx Got:%lx\n", offset, result[i+2], c);
}
-
+#endif
i=(uint16_t)(i+3);
}
}
uint32_t offset=0;
int32_t setOffset=0;
for(offset=0; offset<sizeof(input); offset++){
+ expected=result[i+1];
+#if !U_HIDE_OBSOLETE_UTF_OLD_H
setOffset=offset;
UTF8_NEXT_CHAR_SAFE(input, setOffset, sizeof(input), c, FALSE);
if(setOffset != movedOffset[i+1]){
log_err("ERROR: UTF8_NEXT_CHAR_SAFE failed to move the offset correctly at %d\n ExpectedOffset:%d Got %d\n",
offset, movedOffset[i+1], setOffset);
}
- expected=result[i+1];
if(c != expected){
log_err("ERROR: UTF8_NEXT_CHAR_SAFE failed for input=%ld. Expected:%lx Got:%lx\n", offset, expected, c);
}
-
+#endif
setOffset=offset;
U8_NEXT(input, setOffset, sizeof(input), c);
if(setOffset != movedOffset[i+1]){
if(c != expected){
log_err("ERROR: U8_NEXT_OR_FFFD failed for input=%ld. Expected:%lx Got:%lx\n", offset, expected, c);
}
-
+#if !U_HIDE_OBSOLETE_UTF_OLD_H
setOffset=offset;
UTF8_NEXT_CHAR_SAFE(input, setOffset, sizeof(input), c, TRUE);
if(setOffset != movedOffset[i+1]){
if(c != result[i+2]){
log_err("ERROR: UTF8_NEXT_CHAR_SAFE(strict) failed for input=%ld. Expected:%lx Got:%lx\n", offset, result[i+2], c);
}
-
+#endif
i=i+6;
}
i=0;
for(offset=sizeof(input); offset > 0; --offset){
+ expected=result[i+4];
+#if !U_HIDE_OBSOLETE_UTF_OLD_H
setOffset=offset;
UTF8_PREV_CHAR_SAFE(input, 0, setOffset, c, FALSE);
if(setOffset != movedOffset[i+4]){
log_err("ERROR: UTF8_PREV_CHAR_SAFE failed to move the offset correctly at %d\n ExpectedOffset:%d Got %d\n",
offset, movedOffset[i+4], setOffset);
}
- expected=result[i+4];
if(c != expected){
log_err("ERROR: UTF8_PREV_CHAR_SAFE failed for input=%ld. Expected:%lx Got:%lx\n", offset, expected, c);
}
-
+#endif
setOffset=offset;
U8_PREV(input, 0, setOffset, c);
if(setOffset != movedOffset[i+4]){
if(c != expected){
log_err("ERROR: U8_PREV_OR_FFFD failed for input=%ld. Expected:%lx Got:%lx\n", offset, expected, c);
}
-
+#if !U_HIDE_OBSOLETE_UTF_OLD_H
setOffset=offset;
UTF8_PREV_CHAR_SAFE(input, 0, setOffset, c, TRUE);
if(setOffset != movedOffset[i+5]){
if(c != result[i+5]){
log_err("ERROR: UTF8_PREV_CHAR_SAFE(strict) failed for input=%ld. Expected:%lx Got:%lx\n", offset, result[i+5], c);
}
-
+#endif
i=i+6;
}
}
UChar32 c;
int32_t i;
uint32_t offset;
+#if !U_HIDE_OBSOLETE_UTF_OLD_H
for(i=0, offset=0; offset<sizeof(input); ++i) {
UTF8_NEXT_CHAR_UNSAFE(input, offset, c);
if(c != codePoints[i]){
offset, codePoints[i], c);
}
}
+#endif
for(i=0, offset=0; offset<sizeof(input); ++i) {
U8_NEXT_UNSAFE(input, offset, c);
if(c != codePoints[i]){
offset, codePoints[i], c);
}
}
-
+#if !U_HIDE_OBSOLETE_UTF_OLD_H
for(i=UPRV_LENGTHOF(codePoints)-1, offset=sizeof(input); offset > 0; --i){
UTF8_PREV_CHAR_UNSAFE(input, offset, c);
if(c != codePoints[i]){
offset, codePoints[i], c);
}
}
+#endif
for(i=UPRV_LENGTHOF(codePoints)-1, offset=sizeof(input); offset > 0; --i){
U8_PREV_UNSAFE(input, offset, c);
if(c != codePoints[i]){
uint32_t offsafe=0;
uint32_t i=0;
+#if !U_HIDE_OBSOLETE_UTF_OLD_H
while(offsafe < sizeof(input)){
UTF8_FWD_1_SAFE(input, offsafe, sizeof(input));
if(offsafe != fwd_safe[i]){
}
i++;
}
-
+#endif
+ offsafe=0;
i=0;
while(offsafe < sizeof(input)){
U8_FWD_1(input, offsafe, sizeof(input));
}
i++;
}
-
+#if !U_HIDE_OBSOLETE_UTF_OLD_H
i=0;
offsafe=sizeof(input);
while(offsafe > 0){
}
i++;
}
-
+#endif
i=0;
offsafe=sizeof(input);
while(offsafe > 0){
}
i++;
}
-
+#if !U_HIDE_OBSOLETE_UTF_OLD_H
offsafe=0;
for(i=0; i<UPRV_LENGTHOF(Nvalue); i++){
UTF8_FWD_N_SAFE(input, offsafe, sizeof(input), Nvalue[i]);
}
}
-
+#endif
offsafe=0;
for(i=0; i<UPRV_LENGTHOF(Nvalue); i++){
U8_FWD_N(input, offsafe, sizeof(input), Nvalue[i]);
}
}
-
+#if !U_HIDE_OBSOLETE_UTF_OLD_H
offsafe=sizeof(input);
for(i=0; i<UPRV_LENGTHOF(Nvalue); i++){
UTF8_BACK_N_SAFE(input, 0, offsafe, Nvalue[i]);
log_err("ERROR: backward_N_safe offset=%d expected:%d, Got:%ld\n", i, back_N_safe[i], offsafe);
}
}
-
+#endif
offsafe=sizeof(input);
for(i=0; i<UPRV_LENGTHOF(Nvalue); i++){
U8_BACK_N(input, 0, offsafe, Nvalue[i]);
int32_t offset;
int32_t i;
+#if !U_HIDE_OBSOLETE_UTF_OLD_H
for(i=1, offset=0; offset<UPRV_LENGTHOF(input); ++i) {
UTF8_FWD_1_UNSAFE(input, offset);
if(offset != boundaries[i]){
log_err("ERROR: UTF8_FWD_1_UNSAFE offset expected:%d, Got:%d\n", boundaries[i], offset);
}
}
+#endif
for(i=1, offset=0; offset<UPRV_LENGTHOF(input); ++i) {
U8_FWD_1_UNSAFE(input, offset);
if(offset != boundaries[i]){
log_err("ERROR: U8_FWD_1_UNSAFE offset expected:%d, Got:%d\n", boundaries[i], offset);
}
}
-
+#if !U_HIDE_OBSOLETE_UTF_OLD_H
for(i=UPRV_LENGTHOF(boundaries)-2, offset=UPRV_LENGTHOF(input); offset>0; --i) {
UTF8_BACK_1_UNSAFE(input, offset);
if(offset != boundaries[i]){
log_err("ERROR: UTF8_BACK_1_UNSAFE offset expected:%d, Got:%d\n", boundaries[i], offset);
}
}
+#endif
for(i=UPRV_LENGTHOF(boundaries)-2, offset=UPRV_LENGTHOF(input); offset>0; --i) {
U8_BACK_1_UNSAFE(input, offset);
if(offset != boundaries[i]){
log_err("ERROR: U8_BACK_1_UNSAFE offset expected:%d, Got:%d\n", boundaries[i], offset);
}
}
-
+#if !U_HIDE_OBSOLETE_UTF_OLD_H
for(i=0; i<UPRV_LENGTHOF(boundaries); ++i) {
offset=0;
UTF8_FWD_N_UNSAFE(input, offset, i);
log_err("ERROR: UTF8_FWD_N_UNSAFE offset expected:%d, Got:%d\n", boundaries[i], offset);
}
}
+#endif
for(i=0; i<UPRV_LENGTHOF(boundaries); ++i) {
offset=0;
U8_FWD_N_UNSAFE(input, offset, i);
log_err("ERROR: U8_FWD_N_UNSAFE offset expected:%d, Got:%d\n", boundaries[i], offset);
}
}
-
+#if !U_HIDE_OBSOLETE_UTF_OLD_H
for(i=0; i<UPRV_LENGTHOF(boundaries); ++i) {
int32_t j=UPRV_LENGTHOF(boundaries)-1-i;
offset=UPRV_LENGTHOF(input);
log_err("ERROR: UTF8_BACK_N_UNSAFE offset expected:%d, Got:%d\n", boundaries[j], offset);
}
}
+#endif
for(i=0; i<UPRV_LENGTHOF(boundaries); ++i) {
int32_t j=UPRV_LENGTHOF(boundaries)-1-i;
offset=UPRV_LENGTHOF(input);
int32_t offset=0, setOffset=0;
for(offset=0; offset<=UPRV_LENGTHOF(input); offset++){
if (offset<UPRV_LENGTHOF(input)){
+#if !U_HIDE_OBSOLETE_UTF_OLD_H
setOffset=offset;
UTF8_SET_CHAR_START_SAFE(input, 0, setOffset);
if(setOffset != start_safe[i]){
log_err("ERROR: UTF8_SET_CHAR_START_SAFE failed for offset=%ld. Expected:%ld Got:%ld\n", offset, start_safe[i], setOffset);
}
-
+#endif
setOffset=offset;
U8_SET_CP_START(input, 0, setOffset);
if(setOffset != start_safe[i]){
log_err("ERROR: U8_SET_CP_START failed for offset=%ld. Expected:%ld Got:%ld\n", offset, start_safe[i], setOffset);
}
}
-
+#if !U_HIDE_OBSOLETE_UTF_OLD_H
setOffset=offset;
UTF8_SET_CHAR_LIMIT_SAFE(input,0, setOffset, sizeof(input));
if(setOffset != limit_safe[i]){
log_err("ERROR: UTF8_SET_CHAR_LIMIT_SAFE failed for offset=%ld. Expected:%ld Got:%ld\n", offset, limit_safe[i], setOffset);
}
-
+#endif
setOffset=offset;
U8_SET_CP_LIMIT(input,0, setOffset, sizeof(input));
if(setOffset != limit_safe[i]){
int32_t offset=0, setOffset=0;
for(offset=0; offset<=UPRV_LENGTHOF(input); offset++){
if (offset<UPRV_LENGTHOF(input)){
+#if !U_HIDE_OBSOLETE_UTF_OLD_H
setOffset=offset;
UTF8_SET_CHAR_START_UNSAFE(input, setOffset);
if(setOffset != start_unsafe[i]){
log_err("ERROR: UTF8_SET_CHAR_START_UNSAFE failed for offset=%ld. Expected:%ld Got:%ld\n", offset, start_unsafe[i], setOffset);
}
-
+#endif
setOffset=offset;
U8_SET_CP_START_UNSAFE(input, setOffset);
if(setOffset != start_unsafe[i]){
}
if (offset != 0) { /* Can't have it go off the end of the array */
+#if !U_HIDE_OBSOLETE_UTF_OLD_H
setOffset=offset;
UTF8_SET_CHAR_LIMIT_UNSAFE(input, setOffset);
if(setOffset != limit_unsafe[i]){
log_err("ERROR: UTF8_SET_CHAR_LIMIT_UNSAFE failed for offset=%ld. Expected:%ld Got:%ld\n", offset, limit_unsafe[i], setOffset);
}
-
+#endif
setOffset=offset;
U8_SET_CP_LIMIT_UNSAFE(input, setOffset);
if(setOffset != limit_unsafe[i]){
}
static void TestAppendChar(){
+#if !U_HIDE_OBSOLETE_UTF_OLD_H
static const uint8_t s[11]={0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x00};
static const uint32_t test[]={
/* append-position(unsafe), CHAR to be appended */
}
count++;
}
-
-
+#endif
}
static void TestAppend() {
i=iu; /* go back by one UTF-8 sequence */
}
}
-
-static void printUChars(const uint8_t *uchars, int16_t len){
- int16_t i=0;
- for(i=0; i<len; i++){
- log_err("0x%02x ", *(uchars+i));
- }
-}
errln("setIndex32() isn't working right");
if (c != CharacterIterator::DONE) {
c = iter.next32();
- i=UTF16_NEED_MULTIPLE_UCHAR(c) ? i+2 : i+1;
+ i += U16_LENGTH(c);
}
} while (c != CharacterIterator::DONE);
if(iter.hasNext() == TRUE)
errln("getIndex() isn't working right");
if (c != CharacterIterator::DONE) {
c = iter.previous32();
- i=UTF16_NEED_MULTIPLE_UCHAR(c) ? i-2 : i-1;
+ i -= U16_LENGTH(c);
}
} while (c != CharacterIterator::DONE);
if(iter.hasPrevious() == TRUE)
if(c != text.char32At(i))
errln("Character mismatch at position %d, iterator has %X, string has %X", i, c, text.char32At(i));
- i=UTF16_NEED_MULTIPLE_UCHAR(c) ? i+2 : i+1;
+ i += U16_LENGTH(c);
if(iter.getIndex() != i)
errln("getIndex() aftr next32PostInc() isn't working right");
if(iter.current32() != text.char32At(i))
if (c != CharacterIterator::DONE) {
c = iter.next32();
- i=UTF16_NEED_MULTIPLE_UCHAR(c) ? i+2 : i+1;
+ i += U16_LENGTH(c);
}
} while (c != CharacterIterator::DONE);
c=iter.next32();
if (c != CharacterIterator::DONE) {
c = iter.previous32();
- i=UTF16_NEED_MULTIPLE_UCHAR(c) ? i-2 : i-1;
+ i -= U16_LENGTH(c);
}
} while (c != CharacterIterator::DONE);
#include "unicode/uniset.h"
#include "unicode/ustring.h"
#include "unicode/ures.h"
+#include "unicode/utf16.h"
#include "convtest.h"
#include "cmemory.h"
#include "unicode/tstdtmod.h"
#include "unicode/ucnv.h"
#include "unicode/ustring.h"
#include "unicode/uidna.h"
-
+#include "unicode/utf16.h"
#include "idnaconf.h"
static const UChar C_TAG[] = {0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0}; // =====
#include "unicode/ucnv.h"
#include "unicode/unistr.h"
#include "unicode/ures.h"
+#include "unicode/utf16.h"
#include "intltest.h"
#include "unicode/fmtable.h"
#include "unicode/testlog.h"
-
-#if U_NO_DEFAULT_INCLUDE_UTF_HEADERS
-/* deprecated - make tests pass with U_NO_DEFAULT_INCLUDE_UTF_HEADERS */
-#include "unicode/utf_old.h"
-#endif
-
U_NAMESPACE_USE
#if U_PLATFORM == U_PF_OS390
#include "unicode/usetiter.h"
#include "unicode/ustring.h"
#include "unicode/utext.h"
-
+#include "unicode/utf16.h"
#include "regextst.h"
#include "regexcmp.h"
#include "uvector.h"
void
StringTest::Test_UTF8_COUNT_TRAIL_BYTES() {
+#if !U_HIDE_OBSOLETE_UTF_OLD_H
if(UTF8_COUNT_TRAIL_BYTES(0x7F) != 0
- || UTF8_COUNT_TRAIL_BYTES(0xC0) != 1
- || UTF8_COUNT_TRAIL_BYTES(0xE0) != 2
- || UTF8_COUNT_TRAIL_BYTES(0xF0) != 3)
- {
- errln("Test_UTF8_COUNT_TRAIL_BYTES: UTF8_COUNT_TRAIL_BYTES does not work right! "
- "See utf_old.h.");
- }
- // Note: U8_COUNT_TRAIL_BYTES (current) and UTF8_COUNT_TRAIL_BYTES (deprecated)
- // have completely different implementations.
- if (U8_COUNT_TRAIL_BYTES(0x7F) != 0
- || U8_COUNT_TRAIL_BYTES(0xC0) != 1
- || U8_COUNT_TRAIL_BYTES(0xE0) != 2
- || U8_COUNT_TRAIL_BYTES(0xF0) != 3)
- {
- errln("Test_UTF8_COUNT_TRAIL_BYTES: U8_COUNT_TRAIL_BYTES does not work right! "
- "See utf8.h.");
- }
+ || UTF8_COUNT_TRAIL_BYTES(0xC0) != 1
+ || UTF8_COUNT_TRAIL_BYTES(0xE0) != 2
+ || UTF8_COUNT_TRAIL_BYTES(0xF0) != 3) {
+ errln("UTF8_COUNT_TRAIL_BYTES does not work right! See utf_old.h.");
+ }
+#endif
+ // Note: U8_COUNT_TRAIL_BYTES (current) and UTF8_COUNT_TRAIL_BYTES (deprecated)
+ // have completely different implementations.
+ if (U8_COUNT_TRAIL_BYTES(0x7F) != 0
+ || U8_COUNT_TRAIL_BYTES(0xC0) != 1
+ || U8_COUNT_TRAIL_BYTES(0xE0) != 2
+ || U8_COUNT_TRAIL_BYTES(0xF0) != 3) {
+ errln("U8_COUNT_TRAIL_BYTES does not work right! See utf8.h.");
+ }
}
void StringTest::runIndexedTest(int32_t index, UBool exec, const char *&name, char * /*par*/) {
#include "unicode/ustring.h"
#include "unicode/usprep.h"
#include "unicode/uniset.h"
+#include "unicode/utf16.h"
#include "cmemory.h"
#include "testidna.h"
#include "idnaref.h"
#include "unicode/utypes.h"
#include "unicode/edits.h"
#include "unicode/unistr.h"
+#include "unicode/utf16.h"
#include "testutil.h"
#include "intltest.h"
#include "unicode/ucharstriebuilder.h"
#include "unicode/uniset.h"
#include "unicode/unistr.h"
+#include "unicode/utf16.h"
#include "intltest.h"
#include "cmemory.h"
#include "unicode/ustring.h"
#include "unicode/parsepos.h"
#include "unicode/symtable.h"
+#include "unicode/utf8.h"
+#include "unicode/utf16.h"
#include "unicode/uversion.h"
#include "cmemory.h"
#include "hash.h"
#include "unicode/utypes.h"
#include "unicode/utext.h"
#include "unicode/utf8.h"
+#include "unicode/utf16.h"
#include "unicode/ustring.h"
#include "unicode/uchriter.h"
#include "cmemory.h"