/********************************************************************
* COPYRIGHT:
- * Copyright (c) 2005-2009, International Business Machines Corporation and
+ * Copyright (c) 2005-2012, International Business Machines Corporation and
* others. All Rights Reserved.
********************************************************************/
/************************************************************************
*
************************************************************************/
-#include "unicode/utypes.h"
-
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
-#include <unicode/utext.h>
-#include <unicode/utf8.h>
-#include <unicode/ustring.h>
-#include <unicode/uchriter.h>
+#include "unicode/utypes.h"
+#include "unicode/utext.h"
+#include "unicode/utf8.h"
+#include "unicode/ustring.h"
+#include "unicode/uchriter.h"
#include "utxttest.h"
static UBool gFailed = FALSE;
- delete []cpMap;
- delete []u8Map;
- delete []u8String;
+ delete []cpMap;
+ delete []u8Map;
+ delete []u8String;
}
// TestCMR test Copy, Move and Replace operations.
// or whether the lead surrogate of the pair is extracted.
// It's a buffer overflow error in either case.
TEST_ASSERT(buf[0] == us.charAt(0) ||
- buf[0] == 0x5555 && U_IS_SUPPLEMENTARY(us.char32At(0)));
+ (buf[0] == 0x5555 && U_IS_SUPPLEMENTARY(us.char32At(0))));
TEST_ASSERT(buf[1] == 0x5555);
if (us.length() == 1) {
TEST_ASSERT(status == U_STRING_NOT_TERMINATED_WARNING);
delete []buf;
}
-
-
//
// ErrorTest() Check various error and edge cases.
//
TEST_ASSERT(utp == &ut);
}
+ // Invalid parameters on open
+ //
+ {
+ UErrorCode status = U_ZERO_ERROR;
+ UText ut = UTEXT_INITIALIZER;
+
+ utext_openUChars(&ut, NULL, 5, &status);
+ TEST_ASSERT(status == U_ILLEGAL_ARGUMENT_ERROR);
+
+ status = U_ZERO_ERROR;
+ utext_openUChars(&ut, NULL, -1, &status);
+ TEST_ASSERT(status == U_ILLEGAL_ARGUMENT_ERROR);
+
+ status = U_ZERO_ERROR;
+ utext_openUTF8(&ut, NULL, 4, &status);
+ TEST_ASSERT(status == U_ILLEGAL_ARGUMENT_ERROR);
+
+ status = U_ZERO_ERROR;
+ utext_openUTF8(&ut, NULL, -1, &status);
+ TEST_ASSERT(status == U_ILLEGAL_ARGUMENT_ERROR);
+ }
+
//
// UTF-8 with malformed sequences.
// These should come through as the Unicode replacement char, \ufffd
utext_setNativeIndex(ut, 0);
int32_t count = 0;
UChar32 c = 0;
- int32_t nativeIndex = UTEXT_GETNATIVEINDEX(ut);
+ int64_t nativeIndex = UTEXT_GETNATIVEINDEX(ut);
TEST_ASSERT(nativeIndex == 0);
while ((c = utext_next32(ut)) != U_SENTINEL) {
TEST_ASSERT(c == 0x41);