--- a/xpcom/tests/TestUTF.cpp
+++ b/xpcom/tests/TestUTF.cpp
@@ -117,30 +117,33 @@ test_invalid8()
}
return PR_TRUE;
}
PRBool
test_malformed8()
{
+// Don't run this test in debug builds as that intentionally asserts.
+#ifndef DEBUG
for (unsigned int i = 0; i < NS_ARRAY_LENGTH(Malformed8Strings); ++i) {
nsDependentCString str8(Malformed8Strings[i]);
if (!NS_ConvertUTF8toUTF16(str8).IsEmpty())
return PR_FALSE;
nsString tmp16(NS_LITERAL_STRING("string"));
AppendUTF8toUTF16(str8, tmp16);
if (!tmp16.Equals(NS_LITERAL_STRING("string")))
return PR_FALSE;
if (CompareUTF8toUTF16(str8, EmptyString()) == 0)
return PR_FALSE;
}
+#endif
return PR_TRUE;
}
PRBool
test_hashas16()
{
for (unsigned int i = 0; i < NS_ARRAY_LENGTH(ValidStrings); ++i) {
@@ -156,43 +159,43 @@ test_hashas16()
nsDependentCString str8(Invalid8Strings[i].m8);
PRBool err;
if (nsCRT::HashCode(Invalid8Strings[i].m16) !=
nsCRT::HashCodeAsUTF16(str8.get(), str8.Length(), &err) ||
err)
return PR_FALSE;
}
+// Don't run this test in debug builds as that intentionally asserts.
+#ifndef DEBUG
for (unsigned int i = 0; i < NS_ARRAY_LENGTH(Malformed8Strings); ++i) {
nsDependentCString str8(Malformed8Strings[i]);
PRBool err;
if (nsCRT::HashCodeAsUTF16(str8.get(), str8.Length(), &err) != 0 ||
!err)
return PR_FALSE;
}
+#endif
return PR_TRUE;
}
typedef PRBool (*TestFunc)();
static const struct Test
{
const char* name;
TestFunc func;
}
tests[] =
{
{ "test_valid", test_valid },
{ "test_invalid16", test_invalid16 },
{ "test_invalid8", test_invalid8 },
-#ifndef DEBUG
- // Don't run this test in debug builds as that intentionally asserts
{ "test_malformed8", test_malformed8 },
-#endif
{ "test_hashas16", test_hashas16 },
{ nsnull, nsnull }
};
}
using namespace TestUTF;
--- a/xpcom/tests/UTFStrings.h
+++ b/xpcom/tests/UTFStrings.h
@@ -108,16 +108,18 @@ static const UTFStringsStringPair Invali
{ { 0xFFFD, 'x', 0xFFFD },
{ 0xF8, 0x80, 0x80, 0x80, 0x80, 'x', 0xF8, 0x88, 0x80, 0x80, 0x80 } },
{ { 0xFFFD, 0xFFFD },
{ 0xFB, 0xBF, 0xBF, 0xBF, 0xBF, 0xFC, 0xA0, 0x80, 0x80, 0x80, 0x80 } },
{ { 0xFFFD, 0xFFFD },
{ 0xFC, 0x80, 0x80, 0x80, 0x80, 0x80, 0xFD, 0xBF, 0xBF, 0xBF, 0xBF, 0xBF } },
};
+// Don't use this array in debug builds as that intentionally asserts.
+#ifndef DEBUG
static const char Malformed8Strings[][16] =
{
{ 0x80 },
{ 'a', 0xC8, 'c' },
{ 'a', 0xC0 },
{ 'a', 0xE8, 'c' },
{ 'a', 0xE8, 0x80, 'c' },
{ 'a', 0xE8, 0x80 },
@@ -130,10 +132,11 @@ static const char Malformed8Strings[][16
{ 'a', 0xFA, 'c' },
{ 'a', 0xFA, 0x80, 0x80, 0x7F, 0x80, 'c' },
{ 'a', 0xFA, 0x80, 0x80, 0x80, 0x80, 0x80, 'c' },
{ 'a', 0xFD },
{ 'a', 0xFD, 0x80, 0x80, 0x80, 0x80, 'c' },
{ 'a', 0xFD, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 },
{ 'a', 0xFC, 0x80, 0x80, 0x40, 0x80, 0x80, 'c' },
};
+#endif
#endif