summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--generic/tclTest.c12
-rw-r--r--tests/utf.test28
2 files changed, 30 insertions, 10 deletions
diff --git a/generic/tclTest.c b/generic/tclTest.c
index 4c13850..1f6882f 100644
--- a/generic/tclTest.c
+++ b/generic/tclTest.c
@@ -6834,13 +6834,15 @@ TestUtfNextCmd(
}
bytes = Tcl_GetStringFromObj(objv[1], &numBytes);
- if (numBytes > (int)sizeof(buffer)-3) {
- Tcl_AppendResult(interp, "\"testutfnext\" can only handle 29 bytes", NULL);
+ if (numBytes > (int)sizeof(buffer) - 4) {
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "\"testutfnext\" can only handle %d bytes",
+ (int)sizeof(buffer) - 4));
return TCL_ERROR;
}
memcpy(buffer + 1, bytes, numBytes);
- buffer[0] = buffer[numBytes + 1] = buffer[numBytes + 2] = '\x00';
+ buffer[0] = buffer[numBytes + 1] = buffer[numBytes + 2] = buffer[numBytes + 3] = '\xA0';
first = result = TclUtfNext(buffer + 1);
while ((buffer[0] = *p++) != '\0') {
@@ -6856,8 +6858,8 @@ TestUtfNextCmd(
/* Run Tcl_UtfNext with many more possible bytes at src[end], all should give the same result */
result = TclUtfNext(buffer + 1);
if (first != result) {
- Tcl_AppendResult(interp, "Tcl_UtfNext is not supposed to read src[end]", NULL);
- return TCL_ERROR;
+ first = buffer;
+ break;
}
}
diff --git a/tests/utf.test b/tests/utf.test
index c2c8039..86779f0 100644
--- a/tests/utf.test
+++ b/tests/utf.test
@@ -187,7 +187,7 @@ test utf-6.1 {Tcl_UtfNext} testutfnext {
# This takes the pointer one past the terminating NUL.
# This is really an invalid call.
testutfnext {}
-} 1
+} -1
test utf-6.2 {Tcl_UtfNext} testutfnext {
testutfnext A
} 1
@@ -209,7 +209,13 @@ test utf-6.7 {Tcl_UtfNext} {testutfnext testbytestring} {
test utf-6.8 {Tcl_UtfNext} {testutfnext testbytestring} {
testutfnext A[testbytestring \xF8]
} 1
-test utf-6.9 {Tcl_UtfNext} {testutfnext testbytestring} {
+test utf-6.9.0 {Tcl_UtfNext} {testutfnext testbytestring ucs2} {
+ testutfnext [testbytestring \xA0]
+} 1
+test utf-6.9.1 {Tcl_UtfNext} {testutfnext testbytestring utf16} {
+ testutfnext [testbytestring \xA0]
+} -1
+test utf-6.9.2 {Tcl_UtfNext} {testutfnext testbytestring ucs4} {
testutfnext [testbytestring \xA0\x00]
} 1
test utf-6.10 {Tcl_UtfNext} {testutfnext testbytestring} {
@@ -253,7 +259,7 @@ test utf-6.22 {Tcl_UtfNext} {testutfnext testbytestring} {
} 1
test utf-6.23 {Tcl_UtfNext} {testutfnext testbytestring} {
testutfnext [testbytestring \xE8]
-} 1
+} -1
test utf-6.24 {Tcl_UtfNext} {testutfnext testbytestring} {
testutfnext [testbytestring \xE8]G
} 1
@@ -272,15 +278,27 @@ test utf-6.28 {Tcl_UtfNext} {testutfnext testbytestring} {
test utf-6.29 {Tcl_UtfNext} {testutfnext testbytestring} {
testutfnext [testbytestring \xE8\xF8]
} 1
-test utf-6.30 {Tcl_UtfNext} {testutfnext testbytestring} {
+test utf-6.30.0 {Tcl_UtfNext} {testutfnext testbytestring ucs2} {
testutfnext [testbytestring \xF2]
} 1
+test utf-6.30.1 {Tcl_UtfNext} {testutfnext testbytestring utf16} {
+ testutfnext [testbytestring \xF2]
+} -1
+test utf-6.30.2 {Tcl_UtfNext} {testutfnext testbytestring ucs4} {
+ testutfnext [testbytestring \xF2]
+} -1
test utf-6.31 {Tcl_UtfNext} {testutfnext testbytestring} {
testutfnext [testbytestring \xF2]G
} 1
-test utf-6.32 {Tcl_UtfNext} {testutfnext testbytestring} {
+test utf-6.32.0 {Tcl_UtfNext} {testutfnext testbytestring ucs2} {
testutfnext [testbytestring \xF2\xA0]
} 1
+test utf-6.32.1 {Tcl_UtfNext} {testutfnext testbytestring utf16} {
+ testutfnext [testbytestring \xF2\xA0]
+} -1
+test utf-6.32.2 {Tcl_UtfNext} {testutfnext testbytestring ucs4} {
+ testutfnext [testbytestring \xF2\xA0]
+} -1
test utf-6.33 {Tcl_UtfNext} {testutfnext testbytestring} {
testutfnext [testbytestring \xF2\xD0]
} 1