/********************************************************************
* COPYRIGHT:
- * Copyright (c) 2009-2011, International Business Machines Corporation and
+ * Copyright (c) 2009-2013, International Business Machines Corporation and
* others. All Rights Reserved.
********************************************************************/
/********************************************************************************
f = fopen(fileName, "rb");
TEST_ASSERT_NE(f, NULL);
confusables = malloc(3000000);
+ if (f != NULL) {
confusablesLength = fread(confusables, 1, 3000000, f);
fclose(f);
+ }
-
strcpy(fileName, dataSrcDir);
strcat(fileName, U_FILE_SEP_STRING "unidata" U_FILE_SEP_STRING "confusablesWholeScript.txt");
f = fopen(fileName, "rb");
TEST_ASSERT_NE(f, NULL);
confusablesWholeScript = malloc(1000000);
+ if (f != NULL) {
confusablesWholeScriptLength = fread(confusablesWholeScript, 1, 1000000, f);
fclose(f);
+ }
rsc = uspoof_openFromSource(confusables, confusablesLength,
confusablesWholeScript, confusablesWholeScriptLength,
TEST_ASSERT_SUCCESS(status);
uset_close(tmpSet);
- /* Latin Identifier should now fail; other non-latin test cases should still be OK */
+ /* Latin Identifier should now fail; other non-latin test cases should still be OK
+ * Note: fail of CHAR_LIMIT also causes the restriction level to be USPOOF_UNRESTRICTIVE
+ * which will give us a USPOOF_RESTRICTION_LEVEL failure.
+ */
checkResults = uspoof_check(sc, goodLatin, -1, NULL, &status);
TEST_ASSERT_SUCCESS(status);
- TEST_ASSERT_EQ(USPOOF_CHAR_LIMIT, checkResults);
+ TEST_ASSERT_EQ(USPOOF_CHAR_LIMIT | USPOOF_RESTRICTION_LEVEL, checkResults);
checkResults = uspoof_check(sc, goodGreek, -1, NULL, &status);
TEST_ASSERT_SUCCESS(status);
checkResults = uspoof_checkUTF8(sc, utf8buf, -1, &position, &status);
TEST_ASSERT_SUCCESS(status);
TEST_ASSERT_EQ(0, checkResults);
- TEST_ASSERT_EQ(666, position);
+ TEST_ASSERT_EQ(0, position);
u_strToUTF8(utf8buf, sizeof(utf8buf), NULL, goodCyrl, -1, &status);
TEST_ASSERT_SUCCESS(status);
checkResults = uspoof_checkUTF8(sc, utf8buf, -1, &position, &status);
TEST_ASSERT_SUCCESS(status);
TEST_ASSERT_EQ(USPOOF_MIXED_SCRIPT_CONFUSABLE | USPOOF_SINGLE_SCRIPT , checkResults);
- TEST_ASSERT_EQ(2, position);
+ TEST_ASSERT_EQ(0, position);
TEST_TEARDOWN;