[sword-svn] r128 - in trunk/source/test: iotest letest
chrislit at www.crosswire.org
chrislit at www.crosswire.org
Thu Dec 21 04:10:34 MST 2006
Author: chrislit
Date: 2006-12-21 04:10:34 -0700 (Thu, 21 Dec 2006)
New Revision: 128
Modified:
trunk/source/test/iotest/Makefile.in
trunk/source/test/iotest/filetst.c
trunk/source/test/iotest/iotest.cpp
trunk/source/test/iotest/iotest.h
trunk/source/test/iotest/stream.cpp
trunk/source/test/iotest/strtst.c
trunk/source/test/iotest/trnstst.c
trunk/source/test/letest/FontObject.cpp
trunk/source/test/letest/FontObject.h
trunk/source/test/letest/FontTableCache.cpp
trunk/source/test/letest/FontTableCache.h
trunk/source/test/letest/Makefile.in
trunk/source/test/letest/PortableFontInstance.cpp
trunk/source/test/letest/PortableFontInstance.h
trunk/source/test/letest/SimpleFontInstance.cpp
trunk/source/test/letest/SimpleFontInstance.h
trunk/source/test/letest/cmaps.cpp
trunk/source/test/letest/cmaps.h
trunk/source/test/letest/gendata.cpp
trunk/source/test/letest/gendata.xml
trunk/source/test/letest/letest.cpp
trunk/source/test/letest/letest.h
trunk/source/test/letest/letsutil.cpp
trunk/source/test/letest/letsutil.h
trunk/source/test/letest/readme.html
trunk/source/test/letest/sfnt.h
trunk/source/test/letest/testdata.cpp
Log:
corrected eol properties for *nix builds
Modified: trunk/source/test/iotest/Makefile.in
===================================================================
--- trunk/source/test/iotest/Makefile.in 2006-12-21 11:09:23 UTC (rev 127)
+++ trunk/source/test/iotest/Makefile.in 2006-12-21 11:10:34 UTC (rev 128)
@@ -1,95 +1,95 @@
-#******************************************************************************
-#
-# Copyright (C) 1999-2005, International Business Machines
-# Corporation and others. All Rights Reserved.
-#
-#******************************************************************************
-## Makefile.in for ICU - test/iotest
-
-## Source directory information
-srcdir = @srcdir@
-top_srcdir = @top_srcdir@
-
-top_builddir = ../..
-
-## All the flags and other definitions are included here.
-include $(top_builddir)/icudefs.mk
-
-## Build directory information
-subdir = test/iotest
-
-## Extra files to remove for 'make clean'
-CLEANFILES = *~ $(DEPS)
-
-## Target information
-TARGET = iotest$(EXEEXT)
-
-BUILDDIR := $(CURR_SRCCODE_FULL_DIR)/../../
-# Simplify the path for Unix
-BUILDDIR := $(BUILDDIR:test/iotest/../../=)
-# Simplify the path for Windows
-BUILDDIR := $(BUILDDIR:test\\iotest/../../=)
-# Simplify the path for Windows 98
-BUILDDIR := $(BUILDDIR:TEST\\IOTEST/../../=)
-
-ifneq ($(top_builddir),$(top_srcdir))
-CPPFLAGS += -I$(top_builddir)/common
-endif
-CPPFLAGS += -I$(top_srcdir)/common -I$(top_srcdir)/i18n -I$(top_srcdir)/tools/ctestfw -I$(top_srcdir)/io
-DEFS += -D'U_TOPSRCDIR="$(top_srcdir)/"' -D'U_TOPBUILDDIR="$(BUILDDIR)"'
-LIBS = $(LIBCTESTFW) $(LIBICUTOOLUTIL) $(LIBICUIO) $(LIBICUI18N) $(LIBICUUC) $(DEFAULT_LIBS) $(LIB_M)
-
-OBJECTS = iotest.o stream.o strtst.o filetst.o trnstst.o
-
-DEPS = $(OBJECTS:.o=.d)
-
--include Makefile.local
-
-## List of phony targets
-.PHONY : all all-local install install-local clean clean-local \
-distclean distclean-local dist dist-local check check-local
-
-## Clear suffix list
-.SUFFIXES :
-
-## List of standard targets
-all: all-local
-install: install-local
-clean: clean-local
-distclean : distclean-local
-dist: dist-local
-check: all check-local
-
-all-local: $(TARGET)
-
-install-local:
-
-dist-local:
-
-clean-local:
- test -z "$(CLEANFILES)" || $(RMV) $(CLEANFILES)
- $(RMV) $(OBJECTS) $(TARGET)
-
-distclean-local: clean-local
- $(RMV) Makefile
-
-check-local: all-local
- $(INVOKE) ./$(TARGET) $(IOTEST_OPTS) || true
-
-Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
- cd $(top_builddir) \
- && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
-
-$(TARGET) : $(OBJECTS)
- $(LINK.cc) $(OUTOPT)$@ $^ $(LIBS)
-
-ifeq (,$(MAKECMDGOALS))
--include $(DEPS)
-else
-ifneq ($(patsubst %clean,,$(MAKECMDGOALS)),)
-ifneq ($(patsubst %install,,$(MAKECMDGOALS)),)
--include $(DEPS)
-endif
-endif
-endif
-
+#******************************************************************************
+#
+# Copyright (C) 1999-2005, International Business Machines
+# Corporation and others. All Rights Reserved.
+#
+#******************************************************************************
+## Makefile.in for ICU - test/iotest
+
+## Source directory information
+srcdir = @srcdir@
+top_srcdir = @top_srcdir@
+
+top_builddir = ../..
+
+## All the flags and other definitions are included here.
+include $(top_builddir)/icudefs.mk
+
+## Build directory information
+subdir = test/iotest
+
+## Extra files to remove for 'make clean'
+CLEANFILES = *~ $(DEPS)
+
+## Target information
+TARGET = iotest$(EXEEXT)
+
+BUILDDIR := $(CURR_SRCCODE_FULL_DIR)/../../
+# Simplify the path for Unix
+BUILDDIR := $(BUILDDIR:test/iotest/../../=)
+# Simplify the path for Windows
+BUILDDIR := $(BUILDDIR:test\\iotest/../../=)
+# Simplify the path for Windows 98
+BUILDDIR := $(BUILDDIR:TEST\\IOTEST/../../=)
+
+ifneq ($(top_builddir),$(top_srcdir))
+CPPFLAGS += -I$(top_builddir)/common
+endif
+CPPFLAGS += -I$(top_srcdir)/common -I$(top_srcdir)/i18n -I$(top_srcdir)/tools/ctestfw -I$(top_srcdir)/io
+DEFS += -D'U_TOPSRCDIR="$(top_srcdir)/"' -D'U_TOPBUILDDIR="$(BUILDDIR)"'
+LIBS = $(LIBCTESTFW) $(LIBICUTOOLUTIL) $(LIBICUIO) $(LIBICUI18N) $(LIBICUUC) $(DEFAULT_LIBS) $(LIB_M)
+
+OBJECTS = iotest.o stream.o strtst.o filetst.o trnstst.o
+
+DEPS = $(OBJECTS:.o=.d)
+
+-include Makefile.local
+
+## List of phony targets
+.PHONY : all all-local install install-local clean clean-local \
+distclean distclean-local dist dist-local check check-local
+
+## Clear suffix list
+.SUFFIXES :
+
+## List of standard targets
+all: all-local
+install: install-local
+clean: clean-local
+distclean : distclean-local
+dist: dist-local
+check: all check-local
+
+all-local: $(TARGET)
+
+install-local:
+
+dist-local:
+
+clean-local:
+ test -z "$(CLEANFILES)" || $(RMV) $(CLEANFILES)
+ $(RMV) $(OBJECTS) $(TARGET)
+
+distclean-local: clean-local
+ $(RMV) Makefile
+
+check-local: all-local
+ $(INVOKE) ./$(TARGET) $(IOTEST_OPTS) || true
+
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ cd $(top_builddir) \
+ && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
+
+$(TARGET) : $(OBJECTS)
+ $(LINK.cc) $(OUTOPT)$@ $^ $(LIBS)
+
+ifeq (,$(MAKECMDGOALS))
+-include $(DEPS)
+else
+ifneq ($(patsubst %clean,,$(MAKECMDGOALS)),)
+ifneq ($(patsubst %install,,$(MAKECMDGOALS)),)
+-include $(DEPS)
+endif
+endif
+endif
+
Property changes on: trunk/source/test/iotest/Makefile.in
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/source/test/iotest/filetst.c
===================================================================
--- trunk/source/test/iotest/filetst.c 2006-12-21 11:09:23 UTC (rev 127)
+++ trunk/source/test/iotest/filetst.c 2006-12-21 11:10:34 UTC (rev 128)
@@ -1,1454 +1,1454 @@
-/*
-**********************************************************************
-* Copyright (C) 2004-2006, International Business Machines
-* Corporation and others. All Rights Reserved.
-**********************************************************************
-* file name: filetst.c
-* encoding: US-ASCII
-* tab size: 8 (not used)
-* indentation:4
-*
-* created on: 2004apr06
-* created by: George Rhoten
-*/
-
-#include "iotest.h"
-#include "unicode/ustdio.h"
-#include "unicode/ustring.h"
-#include "unicode/uloc.h"
-
-#include <string.h>
-
-const char STANDARD_TEST_FILE[] = "iotest-c.txt";
-
-
-#if !UCONFIG_NO_FORMATTING
-static void TestFileFromICU(UFILE *myFile) {
- int32_t n[1];
- float myFloat = -1234.0;
- int32_t newValuePtr[1];
- double newDoubleValuePtr[1];
- UChar myUString[256];
- UChar uStringBuf[256];
- char myString[256] = "";
- char testBuf[256] = "";
- void *origPtr, *ptr;
- U_STRING_DECL(myStringOrig, "My-String", 9);
-
- U_STRING_INIT(myStringOrig, "My-String", 9);
- u_memset(myUString, 0x2a, sizeof(myUString)/sizeof(*myUString));
- u_memset(uStringBuf, 0x2a, sizeof(uStringBuf)/sizeof(*uStringBuf));
- memset(myString, '*', sizeof(myString)/sizeof(*myString));
- memset(testBuf, '*', sizeof(testBuf)/sizeof(*testBuf));
-
- if (myFile == NULL) {
- log_err("Can't write test file.\n");
- return;
- }
-
- *n = -1234;
- if (sizeof(void *) == 4) {
- origPtr = (void *)0xdeadbeef;
- } else if (sizeof(void *) == 8) {
- origPtr = (void *) INT64_C(0x1000200030004000);
- } else if (sizeof(void *) == 16) {
- /* iSeries */
- union {
- int32_t arr[4];
- void *ptr;
- } massiveBigEndianPtr = {{ 0x10002000, 0x30004000, 0x50006000, 0x70008000 }};
- origPtr = massiveBigEndianPtr.ptr;
- } else {
- log_err("sizeof(void*)=%d hasn't been tested before", (int)sizeof(void*));
- }
-
- /* Test fprintf */
- u_fprintf(myFile, "Signed decimal integer %%d: %d\n", *n);
- u_fprintf(myFile, "Signed decimal integer %%i: %i\n", *n);
- u_fprintf(myFile, "Unsigned octal integer %%o: %o\n", *n);
- u_fprintf(myFile, "Unsigned decimal integer %%u: %u\n", *n);
- u_fprintf(myFile, "Lowercase unsigned hexadecimal integer %%x: %x\n", *n);
- u_fprintf(myFile, "Uppercase unsigned hexadecimal integer %%X: %X\n", *n);
- u_fprintf(myFile, "Float %%f: %f\n", myFloat);
- u_fprintf(myFile, "Lowercase float %%e: %e\n", myFloat);
- u_fprintf(myFile, "Uppercase float %%E: %E\n", myFloat);
- u_fprintf(myFile, "Lowercase float %%g: %g\n", myFloat);
- u_fprintf(myFile, "Uppercase float %%G: %G\n", myFloat);
- u_fprintf(myFile, "Pointer %%p: %p\n", origPtr);
- u_fprintf(myFile, "Char %%c: %c\n", 'A');
- u_fprintf(myFile, "UChar %%C: %C\n", (UChar)0x0041); /*'A'*/
- u_fprintf(myFile, "String %%s: %s\n", "My-String");
- u_fprintf(myFile, "NULL String %%s: %s\n", NULL);
- u_fprintf(myFile, "Unicode String %%S: %S\n", myStringOrig);
- u_fprintf(myFile, "NULL Unicode String %%S: %S\n", NULL);
- u_fprintf(myFile, "Percent %%P (non-ANSI): %P\n", myFloat);
- u_fprintf(myFile, "Spell Out %%V (non-ANSI): %V\n", myFloat);
-
- if (u_feof(myFile)) {
- log_err("Got feof while writing the file.\n");
- }
-
- *n = 1;
- u_fprintf(myFile, "\t\nPointer to integer (Count) %%n: n=%d %n n=%d\n", *n, n, *n);
- u_fprintf(myFile, "Pointer to integer Value: %d\n", *n);
- u_fprintf(myFile, "This is a long test123456789012345678901234567890123456789012345678901234567890\n");
- *n = 1;
- u_fprintf(myFile, "\tNormal fprintf count: n=%d %n n=%d\n", (int)*n, (int*)n, (int)*n);
- fprintf(u_fgetfile(myFile), "\tNormal fprintf count value: n=%d\n", (int)*n); /* Should be 27 as stated later on. */
-
- u_fclose(myFile);
- myFile = u_fopen(STANDARD_TEST_FILE, "r", NULL, NULL);
-
- if (myFile == NULL) {
- log_err("Can't read test file.");
- return;
- }
-
- if (u_feof(myFile)) {
- log_err("Got feof while reading the file and not at the end of the file.\n");
- }
-
- myUString[0] = u_fgetc(myFile);
- if (myUString[0] != 0x53 /* S */) {
- log_err("u_fgetc 1 returned %X. Expected 'S'.", myString[0]);
- }
- u_fungetc(myUString[0], myFile);
- myUString[0] = u_fgetc(myFile);
- if (myUString[0] != 0x53 /* S */) {
- log_err("u_fgetc 2 returned %X. Expected 'S'.", myString[0]);
- }
- u_fungetc(myUString[0], myFile);
- myUString[0] = u_fgetc(myFile);
- if (myUString[0] != 0x53 /* S */) {
- log_err("u_fgetc 3 returned %X. Expected 'S'.", myString[0]);
- }
- u_fungetc(myUString[0], myFile);
- myUString[0] = u_fgetc(myFile);
- myUString[1] = (UChar)u_fgetcx(myFile); /* Mix getc and getcx and see what happens. */
- myUString[2] = u_fgetc(myFile);
- if (myUString[0] != 0x53 /* S */ && myUString[1] != 0x69 /* i */ && myUString[2] != 0x6E /* n */) {
- log_err("u_fgetcx returned \\u%04X\\u%04X\\u%04X. Expected 'Sin'.", myString[0], myString[1], myString[2]);
- }
- u_fungetc(myUString[2], myFile);
- u_fungetc(myUString[1], myFile);
- u_fungetc(myUString[0], myFile);
-
- *n = -1234;
-
- *newValuePtr = 1;
- u_fscanf(myFile, "Signed decimal integer %%d: %d\n", newValuePtr);
- if (*n != *newValuePtr) {
- log_err("%%d Got: %d, Expected: %d\n", *newValuePtr, *n);
- }
- *newValuePtr = 1;
- u_fscanf(myFile, "Signed decimal integer %%i: %i\n", newValuePtr);
- if (*n != *newValuePtr) {
- log_err("%%i Got: %i, Expected: %i\n", *newValuePtr, *n);
- }
- *newValuePtr = 1;
- u_fscanf(myFile, "Unsigned octal integer %%o: %o\n", newValuePtr);
- if (*n != *newValuePtr) {
- log_err("%%o Got: %o, Expected: %o\n", *newValuePtr, *n);
- }
- *newValuePtr = 1;
- u_fscanf(myFile, "Unsigned decimal integer %%u: %u\n", newValuePtr);
- if (*n != *newValuePtr) {
- log_err("%%u Got: %u, Expected: %u\n", *newValuePtr, *n);
- }
- *newValuePtr = 1;
- u_fscanf(myFile, "Lowercase unsigned hexadecimal integer %%x: %x\n", newValuePtr);
- if (*n != *newValuePtr) {
- log_err("%%x Got: %x, Expected: %x\n", *newValuePtr, *n);
- }
- *newValuePtr = 1;
- u_fscanf(myFile, "Uppercase unsigned hexadecimal integer %%X: %X\n", newValuePtr);
- if (*n != *newValuePtr) {
- log_err("%%X Got: %X, Expected: %X\n", *newValuePtr, *n);
- }
- *newDoubleValuePtr = -1.0;
- u_fscanf(myFile, "Float %%f: %lf\n", newDoubleValuePtr);
- if (myFloat != *newDoubleValuePtr) {
- log_err("%%f Got: %f, Expected: %f\n", *newDoubleValuePtr, myFloat);
- }
- *newDoubleValuePtr = -1.0;
- u_fscanf(myFile, "Lowercase float %%e: %le\n", newDoubleValuePtr);
- if (myFloat != *newDoubleValuePtr) {
- log_err("%%e Got: %e, Expected: %e\n", *newDoubleValuePtr, myFloat);
- }
- *newDoubleValuePtr = -1.0;
- u_fscanf(myFile, "Uppercase float %%E: %lE\n", newDoubleValuePtr);
- if (myFloat != *newDoubleValuePtr) {
- log_err("%%E Got: %E, Expected: %E\n", *newDoubleValuePtr, myFloat);
- }
- *newDoubleValuePtr = -1.0;
- u_fscanf(myFile, "Lowercase float %%g: %lg\n", newDoubleValuePtr);
- if (myFloat != *newDoubleValuePtr) {
- log_err("%%g Got: %g, Expected: %g\n", *newDoubleValuePtr, myFloat);
- }
- *newDoubleValuePtr = -1.0;
- u_fscanf(myFile, "Uppercase float %%G: %lG\n", newDoubleValuePtr);
- if (myFloat != *newDoubleValuePtr) {
- log_err("%%G Got: %G, Expected: %G\n", *newDoubleValuePtr, myFloat);
- }
- ptr = NULL;
- u_fscanf(myFile, "Pointer %%p: %p\n", &ptr);
- if (ptr != origPtr) {
- log_err("%%p Got: %p, Expected: %p\n", ptr, origPtr);
- }
- u_fscanf(myFile, "Char %%c: %c\n", myString);
- if (*myString != 'A') {
- log_err("%%c Got: %c, Expected: A\n", *myString);
- }
- u_fscanf(myFile, "UChar %%C: %C\n", myUString);
- if (*myUString != (UChar)0x0041) { /*'A'*/
- log_err("%%C Got: %C, Expected: A\n", *myUString);
- }
- u_fscanf(myFile, "String %%s: %s\n", myString);
- if (strcmp(myString, "My-String")) {
- log_err("%%s Got: %s, Expected: My String\n", myString);
- }
- u_fscanf(myFile, "NULL String %%s: %s\n", myString);
- if (strcmp(myString, "(null)")) {
- log_err("%%s Got: %s, Expected: My String\n", myString);
- }
- u_fscanf(myFile, "Unicode String %%S: %S\n", myUString);
- u_austrncpy(myString, myUString, sizeof(myUString)/sizeof(*myUString));
- if (strcmp(myString, "My-String")) {
- log_err("%%S Got: %S, Expected: My String\n", myUString);
- }
- u_fscanf(myFile, "NULL Unicode String %%S: %S\n", myUString);
- u_austrncpy(myString, myUString, sizeof(myUString)/sizeof(*myUString));
- if (strcmp(myString, "(null)")) {
- log_err("%%S Got: %S, Expected: My String\n", myUString);
- }
- *newDoubleValuePtr = -1.0;
- u_fscanf(myFile, "Percent %%P (non-ANSI): %P\n", newDoubleValuePtr);
- if (myFloat != *newDoubleValuePtr) {
- log_err("%%P Got: %f, Expected: %f\n", *newDoubleValuePtr, myFloat);
- }
- *newDoubleValuePtr = -1.0;
- u_fscanf(myFile, "Spell Out %%V (non-ANSI): %V\n", newDoubleValuePtr);
- if (myFloat != *newDoubleValuePtr) {
- log_err("%%V Got: %f, Expected: %f\n", *newDoubleValuePtr, myFloat);
- }
-
- u_fgets(myUString, 4, myFile);
- u_austrncpy(myString, myUString, sizeof(myUString)/sizeof(*myUString));
- if (myString == NULL || strcmp(myString, "\t\n") != 0) {
- log_err("u_fgets got \"%s\"\n", myString);
- }
-
- if (u_fgets(myUString, sizeof(myUString)/sizeof(*myUString), myFile) != myUString) {
- log_err("u_fgets did not return myUString\n");
- }
- u_austrncpy(myString, myUString, sizeof(myUString)/sizeof(*myUString));
- if (myString == NULL || strcmp(myString, "Pointer to integer (Count) %n: n=1 n=1\n") != 0) {
- log_err("u_fgets got \"%s\"\n", myString);
- }
-
- if (u_fgets(myUString, sizeof(myUString)/sizeof(*myUString), myFile) != myUString) {
- log_err("u_fgets did not return myUString\n");
- }
- u_austrncpy(myString, myUString, sizeof(myUString)/sizeof(*myUString));
- if (myString == NULL || strcmp(myString, "Pointer to integer Value: 37\n") != 0) {
- log_err("u_fgets got \"%s\"\n", myString);
- }
-
- if (u_fgets(myUString, sizeof(myUString)/sizeof(*myUString), myFile) != myUString) {
- log_err("u_fgets did not return myUString\n");
- }
- u_austrncpy(myString, myUString, sizeof(myUString)/sizeof(*myUString));
- if (myString == NULL || strcmp(myString, "This is a long test123456789012345678901234567890123456789012345678901234567890\n") != 0) {
- log_err("u_fgets got \"%s\"\n", myString);
- }
-
- if (u_fgets(myUString, 0, myFile) != NULL) {
- log_err("u_fgets got \"%s\" and it should have returned NULL\n", myString);
- }
-
- if (u_fgets(myUString, 1, myFile) != myUString) {
- log_err("u_fgets did not return myUString\n");
- }
- u_austrncpy(myString, myUString, sizeof(myUString)/sizeof(*myUString));
- if (myString == NULL || strcmp(myString, "") != 0) {
- log_err("u_fgets got \"%s\"\n", myString);
- }
-
- if (u_fgets(myUString, 2, myFile) != myUString) {
- log_err("u_fgets did not return myUString\n");
- }
- u_austrncpy(myString, myUString, sizeof(myUString)/sizeof(*myUString));
- if (myString == NULL || strcmp(myString, "\t") != 0) {
- log_err("u_fgets got \"%s\"\n", myString);
- }
-
- u_austrncpy(myString, u_fgets(myUString, sizeof(myUString)/sizeof(*myUString), myFile),
- sizeof(myUString)/sizeof(*myUString));
- if (strcmp(myString, "Normal fprintf count: n=1 n=1\n") != 0) {
- log_err("u_fgets got \"%s\"\n", myString);
- }
-
- if (u_feof(myFile)) {
- log_err("Got feof while reading the file and not at the end of the file.\n");
- }
- u_austrncpy(myString, u_fgets(myUString, sizeof(myUString)/sizeof(*myUString), myFile),
- sizeof(myUString)/sizeof(*myUString));
- if (strcmp(myString, "\tNormal fprintf count value: n=27\n") != 0) {
- log_err("u_fgets got \"%s\"\n", myString);
- }
- if (!u_feof(myFile)) {
- log_err("Did not get feof while reading the end of the file.\n");
- }
- if (u_fscanf(myFile, "%S\n", myUString) != 0) {
- log_err("u_fscanf read data while reading the end of the file.\n");
- }
-
- u_fclose(myFile);
-}
-
-static void TestFile(void) {
-/* FILE *standardFile;*/
-
- log_verbose("Testing u_fopen\n");
- TestFileFromICU(u_fopen(STANDARD_TEST_FILE, "w", NULL, NULL));
-
-/* Don't know how to make this work without stdout or stderr */
-/*
- log_verbose("Testing u_finit\n");
- standardFile = fopen(STANDARD_TEST_FILE, "wb");
- TestFileFromICU(u_finit(standardFile, NULL, NULL));
- fclose(standardFile);
-*/
-}
-#endif
-
-static void StdinBuffering(void) {
-#if 0
- UChar buff[255];
- int32_t num = 0;
- UFILE *uStdIn = NULL;
- UFILE *uStdOut = NULL;
- uStdIn = u_finit(stdin, NULL, NULL);
- uStdOut = u_finit(stdout, NULL, NULL);
- if (uStdIn == NULL)
- return;
-
- buff[0] = 0x40;
- buff[1] = 0;
- u_fgets(buff, sizeof(buff)/sizeof(buff[0]), uStdIn);
- u_fprintf(uStdOut, "%S\n", buff);
- u_fscanf(uStdIn, "%d", &num);
- u_fprintf(uStdOut, "%d\n", num);
- u_fscanf(uStdIn, "%d", &num);
- u_fprintf(uStdOut, "%d\n", num);
-#else
- log_verbose("Test disabled because it requires user interaction");
-#endif
-}
-
-static void TestCodepageAndLocale(void) {
- UFILE *myFile = u_fopen(STANDARD_TEST_FILE, "w", NULL, NULL);
- if (myFile == NULL) {
- log_err("Can't write test file.\n");
- return;
- }
- if (u_fgetcodepage(myFile) == NULL
- || strcmp(u_fgetcodepage(myFile), ucnv_getDefaultName()) != 0)
- {
- log_err("Didn't get the proper default codepage. Got %s expected: %s\n",
- u_fgetcodepage(myFile), ucnv_getDefaultName());
- }
-#if !UCONFIG_NO_FORMATTING
- if (u_fgetlocale(myFile) == NULL
- || strcmp(u_fgetlocale(myFile), uloc_getDefault()) != 0)
- {
- log_err("Didn't get the proper default locale. Got %s expected: %s\n",
- u_fgetlocale(myFile), uloc_getDefault());
- }
-#endif
- u_fclose(myFile);
-
- myFile = u_fopen(STANDARD_TEST_FILE, "w", "es", NULL);
- if (u_fgetcodepage(myFile) == NULL
- || strcmp(u_fgetcodepage(myFile), ucnv_getDefaultName()) != 0)
- {
- log_err("Didn't get the proper default codepage for \"es\". Got %s expected: iso-8859-1\n",
- u_fgetcodepage(myFile));
- }
-#if !UCONFIG_NO_FORMATTING
- if (u_fgetlocale(myFile) == NULL
- || strcmp(u_fgetlocale(myFile), "es") != 0)
- {
- log_err("Didn't get the proper default locale. Got %s expected: %s\n",
- u_fgetlocale(myFile), "es");
- }
-#endif
- u_fclose(myFile);
-
- myFile = u_fopen(STANDARD_TEST_FILE, "w", NULL, "UTF-16");
- if (u_fgetcodepage(myFile) == NULL
- || strcmp(u_fgetcodepage(myFile), "UTF-16") != 0)
- {
- log_err("Didn't get the proper default codepage for \"en\". Got %s expected: iso-8859-1\n",
- u_fgetcodepage(myFile));
- }
-#if !UCONFIG_NO_FORMATTING
- if (u_fgetlocale(myFile) == NULL
- || strcmp(u_fgetlocale(myFile), uloc_getDefault()) != 0)
- {
- log_err("Didn't get the proper default locale. Got %s expected: %s\n",
- u_fgetlocale(myFile), uloc_getDefault());
- }
-#endif
- u_fclose(myFile);
-
- myFile = u_fopen(STANDARD_TEST_FILE, "w", "zh", "UTF-16");
- if (u_fgetcodepage(myFile) == NULL
- || strcmp(u_fgetcodepage(myFile), "UTF-16") != 0)
- {
- log_err("Didn't get the proper default codepage for \"en\". Got %s expected: iso-8859-1\n",
- u_fgetcodepage(myFile));
- }
-#if !UCONFIG_NO_FORMATTING
- if (u_fgetlocale(myFile) == NULL
- || strcmp(u_fgetlocale(myFile), "zh") != 0)
- {
- log_err("Didn't get the proper default locale. Got %s expected: %s\n",
- u_fgetlocale(myFile), "zh");
- }
-#endif
- u_fclose(myFile);
-}
-
-
-static void TestfgetsBuffers(void) {
- UChar buffer[2048];
- UChar expectedBuffer[2048];
- static const char testStr[] = "This is a test string that tests u_fgets. It makes sure that we don't try to read too much!";
- UFILE *myFile = u_fopen(STANDARD_TEST_FILE, "w", NULL, "UTF-16");
- int32_t expectedSize = (int32_t)strlen(testStr);
- int32_t readSize;
- int32_t repetitions;
-
- if (myFile == NULL) {
- log_err("Can't write test file.\n");
- return;
- }
-
- u_fputc(0x3BC, myFile);
- if (u_fputc(0x110000, myFile) != U_EOF) {
- log_err("u_fputc should return U_EOF for 0x110000.\n");
- }
- if (u_fputc((UChar32)0xFFFFFFFFu, myFile) != U_EOF) {
- log_err("u_fputc should return U_EOF for 0xFFFFFFFF.\n");
- }
- u_fputc(0xFF41, myFile);
- u_memset(buffer, 0xBEEF, sizeof(buffer)/sizeof(buffer[0]));
- u_memset(expectedBuffer, 0, sizeof(expectedBuffer)/sizeof(expectedBuffer[0]));
- u_uastrncpy(buffer, testStr, expectedSize+1);
- for (repetitions = 0; repetitions < 16; repetitions++) {
- u_file_write(buffer, expectedSize, myFile);
- u_strcat(expectedBuffer, buffer);
- }
- u_fclose(myFile);
-
- u_memset(buffer, 0xBEEF, sizeof(buffer)/sizeof(buffer[0]));
- myFile = u_fopen(STANDARD_TEST_FILE, "r", NULL, "UTF-16");
- if (u_fgetc(myFile) != 0x3BC) {
- log_err("The first character is wrong\n");
- }
- if (u_fgetc(myFile) != 0xFF41) {
- log_err("The second character is wrong\n");
- }
- if (u_fgets(buffer, sizeof(buffer)/sizeof(buffer[0]), myFile) != buffer) {
- log_err("Didn't get the buffer back\n");
- return;
- }
- readSize = u_strlen(buffer);
- if (readSize != expectedSize*repetitions) {
- log_err("Buffer is the wrong size. Got %d Expected %d\n", u_strlen(buffer), expectedSize*repetitions);
- }
- if (buffer[(expectedSize*repetitions) + 1] != 0xBEEF) {
- log_err("u_fgets wrote too much data\n");
- }
- if (u_strcmp(buffer, expectedBuffer) != 0) {
- log_err("Did get expected string back\n");
- }
- if (strcmp(u_fgetcodepage(myFile), "UTF-16") != 0) {
- log_err("Got %s instead of UTF-16\n", u_fgetcodepage(myFile));
- }
- u_fclose(myFile);
-
- log_verbose("Now trying a multi-byte encoding (UTF-8).\n");
-
- myFile = u_fopen(STANDARD_TEST_FILE, "w", NULL, "UTF-8");
-
- u_fputc(0x3BC, myFile);
- u_fputc(0xFF41, myFile);
- u_memset(buffer, 0xBEEF, sizeof(buffer)/sizeof(buffer[0]));
- u_memset(expectedBuffer, 0, sizeof(expectedBuffer)/sizeof(expectedBuffer[0]));
- u_uastrncpy(buffer, testStr, expectedSize+1);
- for (repetitions = 0; repetitions < 16; repetitions++) {
- u_file_write(buffer, expectedSize, myFile);
- u_strcat(expectedBuffer, buffer);
- }
- u_fclose(myFile);
-
- u_memset(buffer, 0xBEEF, sizeof(buffer)/sizeof(buffer[0]));
- myFile = u_fopen(STANDARD_TEST_FILE, "r", NULL, "UTF-8");
- if (strcmp(u_fgetcodepage(myFile), "UTF-8") != 0) {
- log_err("Got %s instead of UTF-8\n", u_fgetcodepage(myFile));
- }
- if (u_fgetc(myFile) != 0x3BC) {
- log_err("The first character is wrong\n");
- }
- if (u_fgetc(myFile) != 0xFF41) {
- log_err("The second character is wrong\n");
- }
- if (u_fgets(buffer, sizeof(buffer)/sizeof(buffer[0]), myFile) != buffer) {
- log_err("Didn't get the buffer back\n");
- return;
- }
- readSize = u_strlen(buffer);
- if (readSize != expectedSize*repetitions) {
- log_err("Buffer is the wrong size. Got %d Expected %d\n", u_strlen(buffer), expectedSize*repetitions);
- }
- if (buffer[(expectedSize*repetitions) + 1] != 0xBEEF) {
- log_err("u_fgets wrote too much data\n");
- }
- if (u_strcmp(buffer, expectedBuffer) != 0) {
- log_err("Did get expected string back\n");
- }
- u_fclose(myFile);
-
-
- log_verbose("Now trying a multi-byte encoding (UTF-8) with a really small buffer.\n");
-
- myFile = u_fopen(STANDARD_TEST_FILE, "w", NULL, "UTF-8");
-
- u_fputc(0xFF41, myFile);
- u_memset(buffer, 0xBEEF, sizeof(buffer)/sizeof(buffer[0]));
- u_memset(expectedBuffer, 0, sizeof(expectedBuffer)/sizeof(expectedBuffer[0]));
- u_uastrncpy(buffer, testStr, expectedSize+1);
- for (repetitions = 0; repetitions < 1; repetitions++) {
- u_file_write(buffer, expectedSize, myFile);
- u_strcat(expectedBuffer, buffer);
- }
- u_fclose(myFile);
-
- u_memset(buffer, 0xBEEF, sizeof(buffer)/sizeof(buffer[0]));
- myFile = u_fopen(STANDARD_TEST_FILE, "r", NULL, "UTF-8");
- if (u_fgets(buffer, 2, myFile) != buffer) {
- log_err("Didn't get the buffer back\n");
- return;
- }
- readSize = u_strlen(buffer);
- if (readSize != 1) {
- log_err("Buffer is the wrong size. Got %d Expected %d\n", u_strlen(buffer), 1);
- }
- if (buffer[0] != 0xFF41 || buffer[1] != 0) {
- log_err("Did get expected string back\n");
- }
- if (buffer[2] != 0xBEEF) {
- log_err("u_fgets wrote too much data\n");
- }
- u_fclose(myFile);
-
-}
-
-static void TestFileReadBuffering(void) {
- UChar buffer[1024];
- UFILE *myFile = u_fopen(STANDARD_TEST_FILE, "w", NULL, "UTF-16");
- int32_t how_many;
- int32_t repetitions;
-
- u_memset(buffer, 0xBEEF, sizeof(buffer)/sizeof(buffer[0]));
- for (repetitions = 0; repetitions < 2; repetitions++) {
- u_file_write(buffer, sizeof(buffer)/sizeof(buffer[0]), myFile);
- }
-
- u_fclose(myFile);
- u_memset(buffer, 0xDEAD, sizeof(buffer)/sizeof(buffer[0]));
- myFile = u_fopen(STANDARD_TEST_FILE, "r", NULL, "UTF-16");
- how_many = u_file_read(buffer, 1024, myFile);
- if (how_many != 1024 || buffer[1023] != 0xBEEF) {
- log_err("u_file_read read too much or not enough data\n");
- }
- u_fclose(myFile);
-}
-
-static void TestfgetsLineCount(void) {
- UChar buffer[2048];
- UChar expectedBuffer[2048];
- char charBuffer[2048];
- static const char testStr[] = "This is a test string that tests u_fgets. It makes sure that we don't try to read too much!";
- UFILE *myFile = NULL;
- FILE *stdFile = fopen(STANDARD_TEST_FILE, "w");
- int32_t expectedSize = (int32_t)strlen(testStr);
- int32_t repetitions;
- int32_t nlRepetitions;
-
- if (stdFile == NULL) {
- log_err("Can't write test file.\n");
- return;
- }
- u_memset(expectedBuffer, 0, sizeof(expectedBuffer)/sizeof(expectedBuffer[0]));
-
- for (repetitions = 0; repetitions < 16; repetitions++) {
- fwrite(testStr, sizeof(testStr[0]), expectedSize, stdFile);
- for (nlRepetitions = 0; nlRepetitions < repetitions; nlRepetitions++) {
- fwrite("\n", sizeof(testStr[0]), 1, stdFile);
- }
- }
- fclose(stdFile);
-
- myFile = u_fopen(STANDARD_TEST_FILE, "r", NULL, NULL);
- stdFile = fopen(STANDARD_TEST_FILE, "r");
-
- for (;;) {
- char *returnedCharBuffer;
- UChar *returnedUCharBuffer;
-
- u_memset(buffer, 0xBEEF, sizeof(buffer)/sizeof(buffer[0]));
- returnedCharBuffer = fgets(charBuffer, sizeof(charBuffer)/sizeof(charBuffer[0]), stdFile);
- returnedUCharBuffer = u_fgets(buffer, sizeof(buffer)/sizeof(buffer[0]), myFile);
-
- if (!returnedCharBuffer && !returnedUCharBuffer) {
- /* Both returned NULL. stop. */
- break;
- }
- if (returnedCharBuffer != charBuffer) {
- log_err("Didn't get the charBuffer back\n");
- continue;
- }
- u_uastrncpy(expectedBuffer, charBuffer, (int32_t)strlen(charBuffer)+1);
- if (returnedUCharBuffer != buffer) {
- log_err("Didn't get the buffer back\n");
- continue;
- }
- if (u_strcmp(buffer, expectedBuffer) != 0) {
- log_err("buffers are different\n");
- }
- if (buffer[u_strlen(buffer)+1] != 0xBEEF) {
- log_err("u_fgets wrote too much\n");
- }
- }
- fclose(stdFile);
- u_fclose(myFile);
-}
-
-static void TestfgetsNewLineHandling(void) {
- UChar buffer[256];
- static const UChar testUStr[][16] = {
- {0x000D, 0},
- {0x000D, 0x000A, 0},
- {0x000D, 0},
- {0x000D, 0},
- {0x0085, 0},
- {0x000A, 0},
- {0x000D, 0},
- {0x000B, 0},
- {0x000C, 0},
- {0x000C, 0},
- {0x2028, 0},
- {0x0085, 0},
- {0x2029, 0},
- {0x0085, 0},
-
- {0x008B, 0x000D, 0},
- {0x00A0, 0x000D, 0x000A, 0},
- {0x3000, 0x000D, 0},
- {0xd800, 0xdfff, 0x000D, 0},
- {0x00AB, 0x0085, 0},
- {0x00AC, 0x000A, 0},
- {0x00AD, 0x000D, 0},
- {0x00BA, 0x000B, 0},
- {0x00AB, 0x000C, 0},
- {0x00B1, 0x000C, 0},
- {0x30BB, 0x2028, 0},
- {0x00A5, 0x0085, 0},
- {0x0080, 0x2029, 0},
- {0x00AF, 0x0085, 0}
-
- };
- UFILE *myFile = NULL;
- int32_t lineIdx;
-
- myFile = u_fopen(STANDARD_TEST_FILE, "wb", NULL, "UTF-8");
- if (myFile == NULL) {
- log_err("Can't write test file.\n");
- return;
- }
- for (lineIdx = 0; lineIdx < (int32_t)(sizeof(testUStr)/sizeof(testUStr[0])); lineIdx++) {
- u_file_write(testUStr[lineIdx], u_strlen(testUStr[lineIdx]), myFile);
- }
- u_fclose(myFile);
-
- myFile = u_fopen(STANDARD_TEST_FILE, "rb", NULL, "UTF-8");
-
- for (lineIdx = 0; lineIdx < (int32_t)(sizeof(testUStr)/sizeof(testUStr[0])); lineIdx++) {
- UChar *returnedUCharBuffer;
-
- u_memset(buffer, 0xBEEF, sizeof(buffer)/sizeof(buffer[0]));
- returnedUCharBuffer = u_fgets(buffer, sizeof(buffer)/sizeof(buffer[0]), myFile);
-
- if (!returnedUCharBuffer) {
- /* Returned NULL. stop. */
- break;
- }
- if (u_strcmp(buffer, testUStr[lineIdx]) != 0) {
- log_err("buffers are different at index = %d\n", lineIdx);
- }
- if (buffer[u_strlen(buffer)+1] != 0xBEEF) {
- log_err("u_fgets wrote too much\n");
- }
- }
- if (lineIdx != (int32_t)(sizeof(testUStr)/sizeof(testUStr[0]))) {
- log_err("u_fgets read too much\n");
- }
- if (u_fgets(buffer, sizeof(buffer)/sizeof(buffer[0]), myFile) != NULL) {
- log_err("u_file_write wrote too much\n");
- }
- u_fclose(myFile);
-}
-
-static void TestLineCount(const char *prefixLine, const char *line, int32_t numRepititions) {
- UChar buffer[64];
- UChar expectedBuffer[64];
- int32_t lineLen = strlen(line);
- UChar *returnedUCharBuffer;
- int32_t repetitions;
- UFILE *myFile = NULL;
- FILE *stdFile = fopen(STANDARD_TEST_FILE, "wb");
-
- if (stdFile == NULL) {
- log_err("Can't write test file.\n");
- return;
- }
- /* Write a prefix line and then write a bunch of lines */
- fwrite(prefixLine, strlen(prefixLine), 1, stdFile);
- for (repetitions = 0; repetitions < numRepititions; repetitions++) {
- fwrite(line, lineLen, 1, stdFile);
- }
- fclose(stdFile);
-
- myFile = u_fopen(STANDARD_TEST_FILE, "rb", NULL, NULL);
- if (myFile == NULL) {
- log_err("Can't read test file.\n");
- return;
- }
-
- /* Read the prefix line. This can make sure that a Windows newline is either on a boundary or before it. */
- u_uastrncpy(expectedBuffer, prefixLine, (int32_t)strlen(prefixLine)+1);
- returnedUCharBuffer = u_fgets(buffer, sizeof(buffer)/sizeof(buffer[0]), myFile);
- if (u_strcmp(returnedUCharBuffer, expectedBuffer) != 0) {
- log_err("prefix buffer is different. prefix=\"%s\"\n", prefixLine);
- return;
- }
-
- u_uastrncpy(expectedBuffer, line, (int32_t)strlen(line)+1);
- for (repetitions = 0; ; repetitions++) {
- u_memset(buffer, 0xBEEF, sizeof(buffer)/sizeof(buffer[0]));
- returnedUCharBuffer = u_fgets(buffer, sizeof(buffer)/sizeof(buffer[0]), myFile);
-
- if (!returnedUCharBuffer) {
- /* returned NULL. stop. */
- break;
- }
- if (u_strcmp(buffer, expectedBuffer) != 0) {
- log_err("buffers are different at count %d\n", repetitions);
- }
- if (buffer[u_strlen(buffer)+1] != 0xBEEF) {
- log_err("u_fgets wrote too much\n");
- }
- }
- if (repetitions != numRepititions) {
- log_err("got wrong number of lines. got=%d expected=%d\n", repetitions, numRepititions);
- }
- u_fclose(myFile);
-}
-
-static void TestfgetsNewLineCount(void) {
- /* This makes sure that lines are correctly handled between buffer boundaries. */
- TestLineCount("\n", "\n", 1024); /* Unix newlines */
- TestLineCount("\r\n", "\r\n", 1024);/* Windows newlines */
- TestLineCount("a\r\n", "\r\n", 1024);/* Windows newlines offset by 1 byte */
- TestLineCount("\r\n", "a\r\n", 1024);/* Windows newlines offset with data */
- TestLineCount("\n", "a\n", 1024); /* Unix newlines offset with data */
- TestLineCount("\n", "\r\n", 1024); /* a mixed number of lines. */
-}
-
-static void TestFgetsLineBuffering(void) {
- UChar buffer[2003]; /* Use a non-power of 2 or 10 */
- UChar *returnedUCharBuffer;
- int32_t repetitions;
- UFILE *myFile = NULL;
- FILE *stdFile = fopen(STANDARD_TEST_FILE, "wb");
-
- if (stdFile == NULL) {
- log_err("Can't write test file.\n");
- return;
- }
- u_memset(buffer, 0xBEEF, sizeof(buffer)/sizeof(buffer[0]));
-
- /* Write one very long line */
- for (repetitions = 0; repetitions < ((sizeof(buffer)/sizeof(buffer[0]))*2); repetitions++) {
- fwrite(repetitions ? "1" : "2", 1, 1, stdFile);
- }
- fclose(stdFile);
-
- myFile = u_fopen(STANDARD_TEST_FILE, "rb", NULL, NULL);
- if (myFile == NULL) {
- log_err("Can't read test file.\n");
- return;
- }
-
- /* Read part of one very long line */
- returnedUCharBuffer = u_fgets(buffer, (sizeof(buffer)/sizeof(buffer[0]))-1, myFile);
- if (u_strlen(returnedUCharBuffer) != ((sizeof(buffer)/sizeof(buffer[0]))-2)) {
- log_err("Line is wrong length. Got %d. Expected %d.\n",
- u_strlen(returnedUCharBuffer), ((sizeof(buffer)/sizeof(buffer[0]))-2));
- }
- /* We better not read too much */
- if (buffer[(sizeof(buffer)/sizeof(buffer[0]))-1] != 0xBEEF) {
- log_err("Too much data was written\n");
- }
-
- u_fclose(myFile);
-}
-
-
-static void TestCodepage(void) {
- UFILE *myFile = NULL;
- static const UChar strABAccentA[] = { 0x0041, 0x0042, 0x00C1, 0x0043, 0};
- static const UChar strBadConversion[] = { 0x0041, 0x0042, 0xfffd, 0x0043, 0};
- UChar testBuf[sizeof(strABAccentA)/sizeof(strABAccentA[0])*2]; /* *2 to see if too much was */
- char convName[UCNV_MAX_CONVERTER_NAME_LENGTH];
- int32_t retVal;
- UErrorCode status = U_ZERO_ERROR;
-
- myFile = u_fopen(STANDARD_TEST_FILE, "w", NULL, "absurd converter that can't be opened");
-
- if (myFile) {
- log_err("Recieved a UFILE * with an invalid codepage parameter\n");
- u_fclose(myFile);
- }
-
- myFile = u_fopen(STANDARD_TEST_FILE, "w", NULL, "ISO-8859-1");
- if (myFile == NULL) {
- log_err("Can't write test file for iso-8859-1.\n");
- return;
- }
- if (strcmp("ISO-8859-1", u_fgetcodepage(myFile)) != 0) {
- log_err("Couldn't get ISO-8859-1 back as opened codepage\n");
- }
- u_file_write(strABAccentA, u_strlen(strABAccentA), myFile);
- u_fclose(myFile);
-
- /* Now see what we got wrote */
- myFile = u_fopen(STANDARD_TEST_FILE, "r", NULL, NULL);
- if (u_fsetcodepage("ISO-8859-1", myFile) != 0) {
- log_err("u_fsetcodepage didn't set the codepage\n");
- }
- retVal = u_file_read(testBuf, u_strlen(strABAccentA), myFile);
- if (u_strncmp(strABAccentA, testBuf, u_strlen(strABAccentA)) != 0) {
- log_err("The test data was read and written differently!\n");
- }
- if (retVal != u_strlen(strABAccentA)) {
- log_err("The test data returned different lengths. Got: %d, Expected %d\n", retVal, u_strlen(strABAccentA));
- }
- u_fclose(myFile);
-
- /* What happens on invalid input? */
- myFile = u_fopen(STANDARD_TEST_FILE, "r", NULL, "ISO-8859-1");
- if (strcmp(ucnv_getName(u_fgetConverter(myFile), &status), "ISO-8859-1") != 0) {
- log_err("u_fgetConverter returned %s\n", ucnv_getName(u_fgetConverter(myFile), &status));
- }
- if (u_fsetcodepage("UTF-8", myFile) != 0) {
- log_err("u_fsetcodepage didn't set the codepage to UTF-8\n");
- }
- if (strcmp(ucnv_getName(u_fgetConverter(myFile), &status), "UTF-8") != 0) {
- log_err("u_fgetConverter returned %s\n", ucnv_getName(u_fgetConverter(myFile), &status));
- }
- retVal = u_file_read(testBuf, u_strlen(strBadConversion), myFile);
- if (u_strncmp(strBadConversion, testBuf, u_strlen(strBadConversion)) != 0) {
- log_err("The test data wasn't subsituted as expected\n");
- }
- u_fclose(myFile);
-
- /* Can't currently swap codepages midstream */
- myFile = u_fopen(STANDARD_TEST_FILE, "r", NULL, "ISO-8859-1");
- strcpy(convName, u_fgetcodepage(myFile));
- u_file_read(testBuf, 1, myFile);
- if (u_fsetcodepage("UTF-8", myFile) == 0) {
- log_err("u_fsetcodepage set the codepage after reading a byte\n");
- }
- retVal = u_file_read(testBuf + 1, u_strlen(strABAccentA) - 1, myFile);
- if (u_strncmp(strABAccentA, testBuf, u_strlen(strABAccentA)) != 0) {
- log_err("u_fsetcodepage changed the codepages after writing data\n");
- }
- if ((retVal + 1) != u_strlen(strABAccentA)) {
- log_err("The test data returned different lengths. Got: %d, Expected %d\n", retVal, u_strlen(strABAccentA));
- }
- u_frewind(myFile);
- retVal = u_file_read(testBuf, u_strlen(strABAccentA), myFile);
- if (u_strncmp(strABAccentA, testBuf, u_strlen(strABAccentA)) != 0) {
- log_err("The test data was read and written differently!\n");
- }
- if (retVal != u_strlen(strABAccentA)) {
- log_err("The test data returned different lengths. Got: %d, Expected %d\n", retVal, u_strlen(strABAccentA));
- }
- u_fclose(myFile);
-
-}
-
-#if !UCONFIG_NO_FORMATTING
-static void TestFilePrintCompatibility(void) {
- UFILE *myFile = u_fopen(STANDARD_TEST_FILE, "wb", "en_US_POSIX", NULL);
- FILE *myCFile;
- int32_t num;
- char cVal;
- static const UChar emptyStr[] = {0};
- char readBuf[512] = "";
- char testBuf[512] = "";
-
- if (myFile == NULL) {
- log_err("Can't write test file.\n");
- return;
- }
-#if !UCONFIG_NO_FORMATTING
- if (strcmp(u_fgetlocale(myFile), "en_US_POSIX") != 0) {
- log_err("Got %s instead of en_US_POSIX for locale\n", u_fgetlocale(myFile));
- }
-#endif
-
- /* Compare against C API compatibility */
- for (num = -STANDARD_TEST_NUM_RANGE; num < STANDARD_TEST_NUM_RANGE; num++) {
- u_fprintf(myFile, "%x ", num);
- u_fprintf(myFile, "%X ", num);
- u_fprintf(myFile, "%o ", num);
- u_fprintf(myFile, "%d ", num);
- u_fprintf(myFile, "%i ", num);
- u_fprintf(myFile, "%f ", (double)num);
-/* u_fprintf(myFile, "%e ", (double)num);
- u_fprintf(myFile, "%E ", (double)num);*/
- u_fprintf(myFile, "%g ", (double)num);
- u_fprintf(myFile, "%G", (double)num);
- u_fputs(emptyStr, myFile);
- }
-
- u_fprintf_u(myFile, NEW_LINE);
-
- for (num = 0; num < 0x80; num++) {
- u_fprintf(myFile, "%c", num);
- }
-
- u_fclose(myFile);
- myCFile = fopen(STANDARD_TEST_FILE, "rb");
- if (myCFile == NULL) {
- log_err("Can't read test file.");
- return;
- }
-
- for (num = -STANDARD_TEST_NUM_RANGE; num < STANDARD_TEST_NUM_RANGE; num++) {
- fscanf(myCFile, "%s", readBuf);
- sprintf(testBuf, "%x", (int)num);
- if (strcmp(readBuf, testBuf) != 0) {
- log_err("%%x Got: \"%s\", Expected: \"%s\"\n", readBuf, testBuf);
- }
-
- fscanf(myCFile, "%s", readBuf);
- sprintf(testBuf, "%X", (int)num);
- if (strcmp(readBuf, testBuf) != 0) {
- log_err("%%X Got: \"%s\", Expected: \"%s\"\n", readBuf, testBuf);
- }
-
- fscanf(myCFile, "%s", readBuf);
- sprintf(testBuf, "%o", (int)num);
- if (strcmp(readBuf, testBuf) != 0) {
- log_err("%%o Got: \"%s\", Expected: \"%s\"\n", readBuf, testBuf);
- }
-
- /* fprintf is not compatible on all platforms e.g. the iSeries */
- fscanf(myCFile, "%s", readBuf);
- sprintf(testBuf, "%d", (int)num);
- if (strcmp(readBuf, testBuf) != 0) {
- log_err("%%d Got: \"%s\", Expected: \"%s\"\n", readBuf, testBuf);
- }
-
- fscanf(myCFile, "%s", readBuf);
- sprintf(testBuf, "%i", (int)num);
- if (strcmp(readBuf, testBuf) != 0) {
- log_err("%%i Got: \"%s\", Expected: \"%s\"\n", readBuf, testBuf);
- }
-
- fscanf(myCFile, "%s", readBuf);
- sprintf(testBuf, "%f", (double)num);
- if (strcmp(readBuf, testBuf) != 0) {
- log_err("%%f Got: \"%s\", Expected: \"%s\"\n", readBuf, testBuf);
- }
-
-/* fscanf(myCFile, "%s", readBuf);
- sprintf(testBuf, "%e", (double)num);
- if (strcmp(readBuf, testBuf) != 0) {
- log_err("%%e Got: \"%s\", Expected: \"%s\"\n", readBuf, testBuf);
- }
-
- fscanf(myCFile, "%s", readBuf);
- sprintf(testBuf, "%E", (double)num);
- if (strcmp(readBuf, testBuf) != 0) {
- log_err("%%E Got: \"%s\", Expected: \"%s\"\n", readBuf, testBuf);
- }*/
-
- fscanf(myCFile, "%s", readBuf);
- sprintf(testBuf, "%g", (double)num);
- if (strcmp(readBuf, testBuf) != 0) {
- log_err("%%g Got: \"%s\", Expected: \"%s\"\n", readBuf, testBuf);
- }
-
- fscanf(myCFile, "%s", readBuf);
- sprintf(testBuf, "%G", (double)num);
- if (strcmp(readBuf, testBuf) != 0) {
- log_err("%%G Got: \"%s\", Expected: \"%s\"\n", readBuf, testBuf);
- }
- }
-
- /* Properly eat the newlines */
- for (num = 0; num < (int32_t)strlen(C_NEW_LINE); num++) {
- fscanf(myCFile, "%c", &cVal);
- if (cVal != C_NEW_LINE[num]) {
- log_err("OS newline error\n");
- }
- }
- for (num = 0; num < (int32_t)strlen(C_NEW_LINE); num++) {
- fscanf(myCFile, "%c", &cVal);
- if (cVal != C_NEW_LINE[num]) {
- log_err("ustdio newline error\n");
- }
- }
-
- for (num = 0; num < 0x80; num++) {
- cVal = -1;
- fscanf(myCFile, "%c", &cVal);
- if (num != cVal) {
- log_err("%%c Got: 0x%x, Expected: 0x%x\n", cVal, num);
- }
- }
- fclose(myCFile);
-}
-#endif
-
-#define TestFPrintFormat(uFormat, uValue, cFormat, cValue) \
- myFile = u_fopen(STANDARD_TEST_FILE, "w", "en_US_POSIX", NULL);\
- if (myFile == NULL) {\
- log_err("Can't write test file for %s.\n", uFormat);\
- return;\
- }\
- /* Reinitialize the buffer to verify null termination works. */\
- u_memset(uBuffer, 0x2a, sizeof(uBuffer)/sizeof(*uBuffer));\
- memset(buffer, '*', sizeof(buffer)/sizeof(*buffer));\
- \
- uNumPrinted = u_fprintf(myFile, uFormat, uValue);\
- u_fclose(myFile);\
- myFile = u_fopen(STANDARD_TEST_FILE, "r", "en_US_POSIX", NULL);\
- u_fgets(uBuffer, sizeof(uBuffer)/sizeof(*uBuffer), myFile);\
- u_fclose(myFile);\
- u_austrncpy(compBuffer, uBuffer, sizeof(uBuffer)/sizeof(*uBuffer));\
- cNumPrinted = sprintf(buffer, cFormat, cValue);\
- if (strcmp(buffer, compBuffer) != 0) {\
- log_err("%" uFormat " Got: \"%s\", Expected: \"%s\"\n", compBuffer, buffer);\
- }\
- if (cNumPrinted != uNumPrinted) {\
- log_err("%" uFormat " number printed Got: %d, Expected: %d\n", uNumPrinted, cNumPrinted);\
- }\
- if (buffer[uNumPrinted+1] != '*') {\
- log_err("%" uFormat " too much stored\n");\
- }\
-
-#if !UCONFIG_NO_FORMATTING
-static void TestFprintfFormat(void) {
- static const UChar abcUChars[] = {0x61,0x62,0x63,0};
- static const char abcChars[] = "abc";
- UChar uBuffer[256];
- char buffer[256];
- char compBuffer[256];
- int32_t uNumPrinted;
- int32_t cNumPrinted;
- UFILE *myFile;
-
- TestFPrintFormat("%8S", abcUChars, "%8s", abcChars);
- TestFPrintFormat("%-8S", abcUChars, "%-8s", abcChars);
- TestFPrintFormat("%.2S", abcUChars, "%.2s", abcChars); /* strlen is 3 */
-
- TestFPrintFormat("%8s", abcChars, "%8s", abcChars);
- TestFPrintFormat("%-8s", abcChars, "%-8s", abcChars);
- TestFPrintFormat("%.2s", abcChars, "%.2s", abcChars); /* strlen is 3 */
-
- TestFPrintFormat("%8c", (char)'e', "%8c", (char)'e');
- TestFPrintFormat("%-8c", (char)'e', "%-8c", (char)'e');
-
- TestFPrintFormat("%8C", (UChar)0x65, "%8c", (char)'e');
- TestFPrintFormat("%-8C", (UChar)0x65, "%-8c", (char)'e');
-
- TestFPrintFormat("%f", 1.23456789, "%f", 1.23456789);
- TestFPrintFormat("%f", 12345.6789, "%f", 12345.6789);
- TestFPrintFormat("%f", 123456.789, "%f", 123456.789);
- TestFPrintFormat("%f", 1234567.89, "%f", 1234567.89);
- TestFPrintFormat("%10f", 1.23456789, "%10f", 1.23456789);
- TestFPrintFormat("%-10f", 1.23456789, "%-10f", 1.23456789);
- TestFPrintFormat("%10f", 123.456789, "%10f", 123.456789);
- TestFPrintFormat("%10.4f", 123.456789, "%10.4f", 123.456789);
- TestFPrintFormat("%-10f", 123.456789, "%-10f", 123.456789);
-
-/* TestFPrintFormat("%g", 12345.6789, "%g", 12345.6789);
- TestFPrintFormat("%g", 123456.789, "%g", 123456.789);
- TestFPrintFormat("%g", 1234567.89, "%g", 1234567.89);
- TestFPrintFormat("%G", 123456.789, "%G", 123456.789);
- TestFPrintFormat("%G", 1234567.89, "%G", 1234567.89);*/
- TestFPrintFormat("%10g", 1.23456789, "%10g", 1.23456789);
- TestFPrintFormat("%10.4g", 1.23456789, "%10.4g", 1.23456789);
- TestFPrintFormat("%-10g", 1.23456789, "%-10g", 1.23456789);
- TestFPrintFormat("%10g", 123.456789, "%10g", 123.456789);
- TestFPrintFormat("%-10g", 123.456789, "%-10g", 123.456789);
-
- TestFPrintFormat("%8x", 123456, "%8x", 123456);
- TestFPrintFormat("%-8x", 123456, "%-8x", 123456);
- TestFPrintFormat("%08x", 123456, "%08x", 123456);
-
- TestFPrintFormat("%8X", 123456, "%8X", 123456);
- TestFPrintFormat("%-8X", 123456, "%-8X", 123456);
- TestFPrintFormat("%08X", 123456, "%08X", 123456);
- TestFPrintFormat("%#x", 123456, "%#x", 123456);
- TestFPrintFormat("%#x", -123456, "%#x", -123456);
-
- TestFPrintFormat("%8o", 123456, "%8o", 123456);
- TestFPrintFormat("%-8o", 123456, "%-8o", 123456);
- TestFPrintFormat("%08o", 123456, "%08o", 123456);
- TestFPrintFormat("%#o", 123, "%#o", 123);
- TestFPrintFormat("%#o", -123, "%#o", -123);
-
- TestFPrintFormat("%8u", 123456, "%8u", 123456);
- TestFPrintFormat("%-8u", 123456, "%-8u", 123456);
- TestFPrintFormat("%08u", 123456, "%08u", 123456);
- TestFPrintFormat("%8u", -123456, "%8u", -123456);
- TestFPrintFormat("%-8u", -123456, "%-8u", -123456);
- TestFPrintFormat("%.5u", 123456, "%.5u", 123456);
- TestFPrintFormat("%.6u", 123456, "%.6u", 123456);
- TestFPrintFormat("%.7u", 123456, "%.7u", 123456);
-
- TestFPrintFormat("%8d", 123456, "%8d", 123456);
- TestFPrintFormat("%-8d", 123456, "%-8d", 123456);
- TestFPrintFormat("%08d", 123456, "%08d", 123456);
- TestFPrintFormat("% d", 123456, "% d", 123456);
- TestFPrintFormat("% d", -123456, "% d", -123456);
-
- TestFPrintFormat("%8i", 123456, "%8i", 123456);
- TestFPrintFormat("%-8i", 123456, "%-8i", 123456);
- TestFPrintFormat("%08i", 123456, "%08i", 123456);
-
- log_verbose("Get really crazy with the formatting.\n");
-
- TestFPrintFormat("%-#12x", 123, "%-#12x", 123);
- TestFPrintFormat("%-#12x", -123, "%-#12x", -123);
- TestFPrintFormat("%#12x", 123, "%#12x", 123);
- TestFPrintFormat("%#12x", -123, "%#12x", -123);
-
- TestFPrintFormat("%-+12d", 123, "%-+12d", 123);
- TestFPrintFormat("%-+12d", -123, "%-+12d", -123);
- TestFPrintFormat("%- 12d", 123, "%- 12d", 123);
- TestFPrintFormat("%- 12d", -123, "%- 12d", -123);
- TestFPrintFormat("%+12d", 123, "%+12d", 123);
- TestFPrintFormat("%+12d", -123, "%+12d", -123);
- TestFPrintFormat("% 12d", 123, "% 12d", 123);
- TestFPrintFormat("% 12d", -123, "% 12d", -123);
- TestFPrintFormat("%12d", 123, "%12d", 123);
- TestFPrintFormat("%12d", -123, "%12d", -123);
- TestFPrintFormat("%.12d", 123, "%.12d", 123);
- TestFPrintFormat("%.12d", -123, "%.12d", -123);
-
- TestFPrintFormat("%-+12.1f", 1.234, "%-+12.1f", 1.234);
- TestFPrintFormat("%-+12.1f", -1.234, "%-+12.1f", -1.234);
- TestFPrintFormat("%- 12.10f", 1.234, "%- 12.10f", 1.234);
- TestFPrintFormat("%- 12.1f", -1.234, "%- 12.1f", -1.234);
- TestFPrintFormat("%+12.1f", 1.234, "%+12.1f", 1.234);
- TestFPrintFormat("%+12.1f", -1.234, "%+12.1f", -1.234);
- TestFPrintFormat("% 12.1f", 1.234, "% 12.1f", 1.234);
- TestFPrintFormat("% 12.1f", -1.234, "% 12.1f", -1.234);
- TestFPrintFormat("%12.1f", 1.234, "%12.1f", 1.234);
- TestFPrintFormat("%12.1f", -1.234, "%12.1f", -1.234);
- TestFPrintFormat("%.2f", 1.234, "%.2f", 1.234);
- TestFPrintFormat("%.2f", -1.234, "%.2f", -1.234);
- TestFPrintFormat("%3f", 1.234, "%3f", 1.234);
- TestFPrintFormat("%3f", -1.234, "%3f", -1.234);
-
- myFile = u_fopen(STANDARD_TEST_FILE, "w", "en_US_POSIX", NULL);
- /* Reinitialize the buffer to verify null termination works. */
- u_memset(uBuffer, 0x2a, sizeof(uBuffer)/sizeof(*uBuffer));
- memset(buffer, '*', sizeof(buffer)/sizeof(*buffer));
-
- uNumPrinted = u_fprintf(myFile, "%d % d %d", -1234, 1234, 1234);
- u_fclose(myFile);
- myFile = u_fopen(STANDARD_TEST_FILE, "r", "en_US_POSIX", NULL);
- u_fgets(uBuffer, sizeof(uBuffer)/sizeof(*uBuffer), myFile);
- u_fclose(myFile);
- u_austrncpy(compBuffer, uBuffer, sizeof(uBuffer)/sizeof(*uBuffer));
- cNumPrinted = sprintf(buffer, "%d % d %d", -1234, 1234, 1234);
- if (strcmp(buffer, compBuffer) != 0) {
- log_err("%%d %% d %%d Got: \"%s\", Expected: \"%s\"\n", compBuffer, buffer);
- }
- if (cNumPrinted != uNumPrinted) {
- log_err("%%d %% d %%d number printed Got: %d, Expected: %d\n", uNumPrinted, cNumPrinted);
- }
- if (buffer[uNumPrinted+1] != '*') {
- log_err("%%d %% d %%d too much stored\n");
- }
-}
-#endif
-
-#undef TestFPrintFormat
-
-#if !UCONFIG_NO_FORMATTING
-static void TestFScanSetFormat(const char *format, const UChar *uValue, const char *cValue, UBool expectedToPass) {
- UFILE *myFile;
- UChar uBuffer[256];
- char buffer[256];
- char compBuffer[256];
- int32_t uNumScanned;
- int32_t cNumScanned;
-
- myFile = u_fopen(STANDARD_TEST_FILE, "w", NULL, NULL);
- if (myFile == NULL) {
- log_err("Can't write test file for %s.\n", format);
- return;
- }
- /* Reinitialize the buffer to verify null termination works. */
- u_memset(uBuffer, 0x2a, sizeof(uBuffer)/sizeof(*uBuffer));
- uBuffer[sizeof(uBuffer)/sizeof(*uBuffer)-1] = 0;
- memset(buffer, '*', sizeof(buffer)/sizeof(*buffer));
- buffer[sizeof(buffer)/sizeof(*buffer)-1] = 0;
-
- u_fprintf(myFile, "%S", uValue);
- u_fclose(myFile);
- myFile = u_fopen(STANDARD_TEST_FILE, "r", "en_US_POSIX", NULL);
- uNumScanned = u_fscanf(myFile, format, uBuffer);
- u_fclose(myFile);
- if (expectedToPass) {
- u_austrncpy(compBuffer, uBuffer, sizeof(uBuffer)/sizeof(*uBuffer));
- cNumScanned = sscanf(cValue, format, buffer);
- if (strncmp(buffer, compBuffer, sizeof(buffer)/sizeof(*buffer)) != 0) {
- log_err("%s Got: \"%s\", Expected: \"%s\"\n", format, compBuffer, buffer);
- }
- if (cNumScanned != uNumScanned) {
- log_err("%s number printed Got: %d, Expected: %d\n", format, uNumScanned, cNumScanned);
- }
- if (uNumScanned > 0 && uBuffer[u_strlen(uBuffer)+1] != 0x2a) {
- log_err("%s too much stored\n", format);
- }
- }
- else {
- if (uNumScanned != 0 || uBuffer[0] != 0x2a || uBuffer[1] != 0x2a) {
- log_err("%s too much stored on a failure\n", format);
- }
- }
-}
-#endif
-
-#if !UCONFIG_NO_FORMATTING
-static void TestFScanset(void) {
- static const UChar abcUChars[] = {0x61,0x62,0x63,0x63,0x64,0x65,0x66,0x67,0};
- static const char abcChars[] = "abccdefg";
-
- TestFScanSetFormat("%[bc]S", abcUChars, abcChars, TRUE);
- TestFScanSetFormat("%[cb]S", abcUChars, abcChars, TRUE);
-
- TestFScanSetFormat("%[ab]S", abcUChars, abcChars, TRUE);
- TestFScanSetFormat("%[ba]S", abcUChars, abcChars, TRUE);
-
- TestFScanSetFormat("%[ab]", abcUChars, abcChars, TRUE);
- TestFScanSetFormat("%[ba]", abcUChars, abcChars, TRUE);
-
- TestFScanSetFormat("%[abcdefgh]", abcUChars, abcChars, TRUE);
- TestFScanSetFormat("%[;hgfedcba]", abcUChars, abcChars, TRUE);
-
- TestFScanSetFormat("%[^a]", abcUChars, abcChars, TRUE);
- TestFScanSetFormat("%[^e]", abcUChars, abcChars, TRUE);
- TestFScanSetFormat("%[^ed]", abcUChars, abcChars, TRUE);
- TestFScanSetFormat("%[^dc]", abcUChars, abcChars, TRUE);
- TestFScanSetFormat("%[^e] ", abcUChars, abcChars, TRUE);
-
- TestFScanSetFormat("%1[ab] ", abcUChars, abcChars, TRUE);
- TestFScanSetFormat("%2[^f]", abcUChars, abcChars, TRUE);
-
- TestFScanSetFormat("%[qrst]", abcUChars, abcChars, TRUE);
-
- /* Extra long string for testing */
- TestFScanSetFormat(" %[qrst]",
- abcUChars, abcChars, TRUE);
-
- TestFScanSetFormat("%[a-]", abcUChars, abcChars, TRUE);
-
- /* Bad format */
- TestFScanSetFormat("%[f-a]", abcUChars, abcChars, FALSE);
- TestFScanSetFormat("%[c-a]", abcUChars, abcChars, FALSE);
- TestFScanSetFormat("%[a", abcUChars, abcChars, FALSE);
- /* The following is not deterministic on Windows */
-/* TestFScanSetFormat("%[a-", abcUChars, abcChars);*/
-
- /* TODO: Need to specify precision with a "*" */
-}
-#endif
-#if !UCONFIG_NO_FORMATTING
-static void TestBadFScanfFormat(const char *format, const UChar *uValue, const char *cValue) {
- UFILE *myFile;
- UChar uBuffer[256];
- int32_t uNumScanned;
-
- myFile = u_fopen(STANDARD_TEST_FILE, "w", NULL, NULL);
- if (myFile == NULL) {
- log_err("Can't write test file for %s.\n", format);
- return;
- }
- /* Reinitialize the buffer to verify null termination works. */
- u_memset(uBuffer, 0x2a, sizeof(uBuffer)/sizeof(*uBuffer));
- uBuffer[sizeof(uBuffer)/sizeof(*uBuffer)-1] = 0;
-
- u_fprintf(myFile, "%S", uValue);
- u_fclose(myFile);
- myFile = u_fopen(STANDARD_TEST_FILE, "r", "en_US_POSIX", NULL);
- uNumScanned = u_fscanf(myFile, format, uBuffer);
- u_fclose(myFile);
- if (uNumScanned != 0 || uBuffer[0] != 0x2a || uBuffer[1] != 0x2a) {
- log_err("%s too much stored on a failure\n", format);
- }
-}
-#endif
-#if !UCONFIG_NO_FORMATTING
-static void TestBadScanfFormat(void) {
- static const UChar abcUChars[] = {0x61,0x62,0x63,0x63,0x64,0x65,0x66,0x67,0};
- static const char abcChars[] = "abccdefg";
-
- TestBadFScanfFormat("%[] ", abcUChars, abcChars);
-}
-#endif
-#if !UCONFIG_NO_FORMATTING
-static void Test_u_vfprintf(const char *expectedResult, const char *format, ...) {
- UChar uBuffer[256];
- UChar uBuffer2[256];
- va_list ap;
- int32_t count;
- UFILE *myFile;
-
- myFile = u_fopen(STANDARD_TEST_FILE, "w", "en_US_POSIX", "UTF-8");
- if (!myFile) {
- log_err("Test file can't be opened\n");
- return;
- }
-
- va_start(ap, format);
- count = u_vfprintf(myFile, format, ap);
- va_end(ap);
-
- u_fclose(myFile);
-
-
- myFile = u_fopen(STANDARD_TEST_FILE, "r", "en_US_POSIX", "UTF-8");
- if (!myFile) {
- log_err("Test file can't be opened\n");
- return;
- }
- u_fgets(uBuffer, sizeof(uBuffer)/sizeof(*uBuffer), myFile);
- u_uastrcpy(uBuffer2, expectedResult);
- if (u_strcmp(uBuffer, uBuffer2) != 0) {
- log_err("Got two different results for \"%s\" expected \"%s\"\n", format, expectedResult);
- }
- u_fclose(myFile);
-
-
- myFile = u_fopen(STANDARD_TEST_FILE, "w", "en_US_POSIX", NULL);
- if (!myFile) {
- log_err("Test file can't be opened\n");
- return;
- }
- u_uastrcpy(uBuffer, format);
-
- va_start(ap, format);
- count = u_vfprintf_u(myFile, uBuffer, ap);
- va_end(ap);
-
- u_fclose(myFile);
-
-
- myFile = u_fopen(STANDARD_TEST_FILE, "r", "en_US_POSIX", NULL);
- if (!myFile) {
- log_err("Test file can't be opened\n");
- return;
- }
- u_fgets(uBuffer, sizeof(uBuffer)/sizeof(*uBuffer), myFile);
- u_uastrcpy(uBuffer2, expectedResult);
- if (u_strcmp(uBuffer, uBuffer2) != 0) {
- log_err("Got two different results for \"%s\" expected \"%s\"\n", format, expectedResult);
- }
- u_fclose(myFile);
-}
-
-static void TestVargs(void) {
- Test_u_vfprintf("8 9 a B 8.9", "%d %u %x %X %.1f", 8, 9, 10, 11, 8.9);
-}
-#endif
-
-static void TestUnicodeFormat(void)
-{
-#if !UCONFIG_NO_FORMATTING
- /* Make sure that invariant conversion doesn't happen on the _u formats. */
- UChar myUString[256];
- UFILE *myFile;
- static const UChar TEST_STR[] = { 0x03BC, 0x0025, 0x0024, 0};
- static const UChar PERCENT_S[] = { 0x03BC, 0x0025, 0x0053, 0};
-
- u_memset(myUString, 0x2a, sizeof(myUString)/sizeof(*myUString));
-
- myFile = u_fopen(STANDARD_TEST_FILE, "w", NULL, "UTF-8");
- if (!myFile) {
- log_err("Test file can't be opened\n");
- return;
- }
- u_fprintf_u(myFile, PERCENT_S, TEST_STR);
- u_fclose(myFile);
-
- myFile = u_fopen(STANDARD_TEST_FILE, "r", NULL, "UTF-8");
- if (!myFile) {
- log_err("Test file can't be opened\n");
- return;
- }
- u_fscanf_u(myFile, PERCENT_S, myUString);
- u_fclose(myFile);
- if (u_strcmp(TEST_STR, myUString) != 0) {
- log_err("u_fscanf_u doesn't work.\n");
- }
-#endif
-}
-
-
-U_CFUNC void
-addFileTest(TestNode** root) {
-#if !UCONFIG_NO_FORMATTING
- addTest(root, &TestFile, "file/TestFile");
-#endif
- addTest(root, &StdinBuffering, "file/StdinBuffering");
- addTest(root, &TestfgetsBuffers, "file/TestfgetsBuffers");
- addTest(root, &TestFileReadBuffering, "file/TestFileReadBuffering");
- addTest(root, &TestfgetsLineCount, "file/TestfgetsLineCount");
- addTest(root, &TestfgetsNewLineHandling, "file/TestfgetsNewLineHandling");
- addTest(root, &TestfgetsNewLineCount, "file/TestfgetsNewLineCount");
- addTest(root, &TestFgetsLineBuffering, "file/TestFgetsLineBuffering");
- addTest(root, &TestCodepage, "file/TestCodepage");
-#if !UCONFIG_NO_FORMATTING
- addTest(root, &TestCodepageAndLocale, "file/TestCodepageAndLocale");
- addTest(root, &TestFprintfFormat, "file/TestFprintfFormat");
- addTest(root, &TestFScanset, "file/TestFScanset");
- addTest(root, &TestFilePrintCompatibility, "file/TestFilePrintCompatibility");
- addTest(root, &TestBadScanfFormat, "file/TestBadScanfFormat");
- addTest(root, &TestVargs, "file/TestVargs");
- addTest(root, &TestUnicodeFormat, "file/TestUnicodeFormat");
-#endif
-}
+/*
+**********************************************************************
+* Copyright (C) 2004-2006, International Business Machines
+* Corporation and others. All Rights Reserved.
+**********************************************************************
+* file name: filetst.c
+* encoding: US-ASCII
+* tab size: 8 (not used)
+* indentation:4
+*
+* created on: 2004apr06
+* created by: George Rhoten
+*/
+
+#include "iotest.h"
+#include "unicode/ustdio.h"
+#include "unicode/ustring.h"
+#include "unicode/uloc.h"
+
+#include <string.h>
+
+const char STANDARD_TEST_FILE[] = "iotest-c.txt";
+
+
+#if !UCONFIG_NO_FORMATTING
+static void TestFileFromICU(UFILE *myFile) {
+ int32_t n[1];
+ float myFloat = -1234.0;
+ int32_t newValuePtr[1];
+ double newDoubleValuePtr[1];
+ UChar myUString[256];
+ UChar uStringBuf[256];
+ char myString[256] = "";
+ char testBuf[256] = "";
+ void *origPtr, *ptr;
+ U_STRING_DECL(myStringOrig, "My-String", 9);
+
+ U_STRING_INIT(myStringOrig, "My-String", 9);
+ u_memset(myUString, 0x2a, sizeof(myUString)/sizeof(*myUString));
+ u_memset(uStringBuf, 0x2a, sizeof(uStringBuf)/sizeof(*uStringBuf));
+ memset(myString, '*', sizeof(myString)/sizeof(*myString));
+ memset(testBuf, '*', sizeof(testBuf)/sizeof(*testBuf));
+
+ if (myFile == NULL) {
+ log_err("Can't write test file.\n");
+ return;
+ }
+
+ *n = -1234;
+ if (sizeof(void *) == 4) {
+ origPtr = (void *)0xdeadbeef;
+ } else if (sizeof(void *) == 8) {
+ origPtr = (void *) INT64_C(0x1000200030004000);
+ } else if (sizeof(void *) == 16) {
+ /* iSeries */
+ union {
+ int32_t arr[4];
+ void *ptr;
+ } massiveBigEndianPtr = {{ 0x10002000, 0x30004000, 0x50006000, 0x70008000 }};
+ origPtr = massiveBigEndianPtr.ptr;
+ } else {
+ log_err("sizeof(void*)=%d hasn't been tested before", (int)sizeof(void*));
+ }
+
+ /* Test fprintf */
+ u_fprintf(myFile, "Signed decimal integer %%d: %d\n", *n);
+ u_fprintf(myFile, "Signed decimal integer %%i: %i\n", *n);
+ u_fprintf(myFile, "Unsigned octal integer %%o: %o\n", *n);
+ u_fprintf(myFile, "Unsigned decimal integer %%u: %u\n", *n);
+ u_fprintf(myFile, "Lowercase unsigned hexadecimal integer %%x: %x\n", *n);
+ u_fprintf(myFile, "Uppercase unsigned hexadecimal integer %%X: %X\n", *n);
+ u_fprintf(myFile, "Float %%f: %f\n", myFloat);
+ u_fprintf(myFile, "Lowercase float %%e: %e\n", myFloat);
+ u_fprintf(myFile, "Uppercase float %%E: %E\n", myFloat);
+ u_fprintf(myFile, "Lowercase float %%g: %g\n", myFloat);
+ u_fprintf(myFile, "Uppercase float %%G: %G\n", myFloat);
+ u_fprintf(myFile, "Pointer %%p: %p\n", origPtr);
+ u_fprintf(myFile, "Char %%c: %c\n", 'A');
+ u_fprintf(myFile, "UChar %%C: %C\n", (UChar)0x0041); /*'A'*/
+ u_fprintf(myFile, "String %%s: %s\n", "My-String");
+ u_fprintf(myFile, "NULL String %%s: %s\n", NULL);
+ u_fprintf(myFile, "Unicode String %%S: %S\n", myStringOrig);
+ u_fprintf(myFile, "NULL Unicode String %%S: %S\n", NULL);
+ u_fprintf(myFile, "Percent %%P (non-ANSI): %P\n", myFloat);
+ u_fprintf(myFile, "Spell Out %%V (non-ANSI): %V\n", myFloat);
+
+ if (u_feof(myFile)) {
+ log_err("Got feof while writing the file.\n");
+ }
+
+ *n = 1;
+ u_fprintf(myFile, "\t\nPointer to integer (Count) %%n: n=%d %n n=%d\n", *n, n, *n);
+ u_fprintf(myFile, "Pointer to integer Value: %d\n", *n);
+ u_fprintf(myFile, "This is a long test123456789012345678901234567890123456789012345678901234567890\n");
+ *n = 1;
+ u_fprintf(myFile, "\tNormal fprintf count: n=%d %n n=%d\n", (int)*n, (int*)n, (int)*n);
+ fprintf(u_fgetfile(myFile), "\tNormal fprintf count value: n=%d\n", (int)*n); /* Should be 27 as stated later on. */
+
+ u_fclose(myFile);
+ myFile = u_fopen(STANDARD_TEST_FILE, "r", NULL, NULL);
+
+ if (myFile == NULL) {
+ log_err("Can't read test file.");
+ return;
+ }
+
+ if (u_feof(myFile)) {
+ log_err("Got feof while reading the file and not at the end of the file.\n");
+ }
+
+ myUString[0] = u_fgetc(myFile);
+ if (myUString[0] != 0x53 /* S */) {
+ log_err("u_fgetc 1 returned %X. Expected 'S'.", myString[0]);
+ }
+ u_fungetc(myUString[0], myFile);
+ myUString[0] = u_fgetc(myFile);
+ if (myUString[0] != 0x53 /* S */) {
+ log_err("u_fgetc 2 returned %X. Expected 'S'.", myString[0]);
+ }
+ u_fungetc(myUString[0], myFile);
+ myUString[0] = u_fgetc(myFile);
+ if (myUString[0] != 0x53 /* S */) {
+ log_err("u_fgetc 3 returned %X. Expected 'S'.", myString[0]);
+ }
+ u_fungetc(myUString[0], myFile);
+ myUString[0] = u_fgetc(myFile);
+ myUString[1] = (UChar)u_fgetcx(myFile); /* Mix getc and getcx and see what happens. */
+ myUString[2] = u_fgetc(myFile);
+ if (myUString[0] != 0x53 /* S */ && myUString[1] != 0x69 /* i */ && myUString[2] != 0x6E /* n */) {
+ log_err("u_fgetcx returned \\u%04X\\u%04X\\u%04X. Expected 'Sin'.", myString[0], myString[1], myString[2]);
+ }
+ u_fungetc(myUString[2], myFile);
+ u_fungetc(myUString[1], myFile);
+ u_fungetc(myUString[0], myFile);
+
+ *n = -1234;
+
+ *newValuePtr = 1;
+ u_fscanf(myFile, "Signed decimal integer %%d: %d\n", newValuePtr);
+ if (*n != *newValuePtr) {
+ log_err("%%d Got: %d, Expected: %d\n", *newValuePtr, *n);
+ }
+ *newValuePtr = 1;
+ u_fscanf(myFile, "Signed decimal integer %%i: %i\n", newValuePtr);
+ if (*n != *newValuePtr) {
+ log_err("%%i Got: %i, Expected: %i\n", *newValuePtr, *n);
+ }
+ *newValuePtr = 1;
+ u_fscanf(myFile, "Unsigned octal integer %%o: %o\n", newValuePtr);
+ if (*n != *newValuePtr) {
+ log_err("%%o Got: %o, Expected: %o\n", *newValuePtr, *n);
+ }
+ *newValuePtr = 1;
+ u_fscanf(myFile, "Unsigned decimal integer %%u: %u\n", newValuePtr);
+ if (*n != *newValuePtr) {
+ log_err("%%u Got: %u, Expected: %u\n", *newValuePtr, *n);
+ }
+ *newValuePtr = 1;
+ u_fscanf(myFile, "Lowercase unsigned hexadecimal integer %%x: %x\n", newValuePtr);
+ if (*n != *newValuePtr) {
+ log_err("%%x Got: %x, Expected: %x\n", *newValuePtr, *n);
+ }
+ *newValuePtr = 1;
+ u_fscanf(myFile, "Uppercase unsigned hexadecimal integer %%X: %X\n", newValuePtr);
+ if (*n != *newValuePtr) {
+ log_err("%%X Got: %X, Expected: %X\n", *newValuePtr, *n);
+ }
+ *newDoubleValuePtr = -1.0;
+ u_fscanf(myFile, "Float %%f: %lf\n", newDoubleValuePtr);
+ if (myFloat != *newDoubleValuePtr) {
+ log_err("%%f Got: %f, Expected: %f\n", *newDoubleValuePtr, myFloat);
+ }
+ *newDoubleValuePtr = -1.0;
+ u_fscanf(myFile, "Lowercase float %%e: %le\n", newDoubleValuePtr);
+ if (myFloat != *newDoubleValuePtr) {
+ log_err("%%e Got: %e, Expected: %e\n", *newDoubleValuePtr, myFloat);
+ }
+ *newDoubleValuePtr = -1.0;
+ u_fscanf(myFile, "Uppercase float %%E: %lE\n", newDoubleValuePtr);
+ if (myFloat != *newDoubleValuePtr) {
+ log_err("%%E Got: %E, Expected: %E\n", *newDoubleValuePtr, myFloat);
+ }
+ *newDoubleValuePtr = -1.0;
+ u_fscanf(myFile, "Lowercase float %%g: %lg\n", newDoubleValuePtr);
+ if (myFloat != *newDoubleValuePtr) {
+ log_err("%%g Got: %g, Expected: %g\n", *newDoubleValuePtr, myFloat);
+ }
+ *newDoubleValuePtr = -1.0;
+ u_fscanf(myFile, "Uppercase float %%G: %lG\n", newDoubleValuePtr);
+ if (myFloat != *newDoubleValuePtr) {
+ log_err("%%G Got: %G, Expected: %G\n", *newDoubleValuePtr, myFloat);
+ }
+ ptr = NULL;
+ u_fscanf(myFile, "Pointer %%p: %p\n", &ptr);
+ if (ptr != origPtr) {
+ log_err("%%p Got: %p, Expected: %p\n", ptr, origPtr);
+ }
+ u_fscanf(myFile, "Char %%c: %c\n", myString);
+ if (*myString != 'A') {
+ log_err("%%c Got: %c, Expected: A\n", *myString);
+ }
+ u_fscanf(myFile, "UChar %%C: %C\n", myUString);
+ if (*myUString != (UChar)0x0041) { /*'A'*/
+ log_err("%%C Got: %C, Expected: A\n", *myUString);
+ }
+ u_fscanf(myFile, "String %%s: %s\n", myString);
+ if (strcmp(myString, "My-String")) {
+ log_err("%%s Got: %s, Expected: My String\n", myString);
+ }
+ u_fscanf(myFile, "NULL String %%s: %s\n", myString);
+ if (strcmp(myString, "(null)")) {
+ log_err("%%s Got: %s, Expected: My String\n", myString);
+ }
+ u_fscanf(myFile, "Unicode String %%S: %S\n", myUString);
+ u_austrncpy(myString, myUString, sizeof(myUString)/sizeof(*myUString));
+ if (strcmp(myString, "My-String")) {
+ log_err("%%S Got: %S, Expected: My String\n", myUString);
+ }
+ u_fscanf(myFile, "NULL Unicode String %%S: %S\n", myUString);
+ u_austrncpy(myString, myUString, sizeof(myUString)/sizeof(*myUString));
+ if (strcmp(myString, "(null)")) {
+ log_err("%%S Got: %S, Expected: My String\n", myUString);
+ }
+ *newDoubleValuePtr = -1.0;
+ u_fscanf(myFile, "Percent %%P (non-ANSI): %P\n", newDoubleValuePtr);
+ if (myFloat != *newDoubleValuePtr) {
+ log_err("%%P Got: %f, Expected: %f\n", *newDoubleValuePtr, myFloat);
+ }
+ *newDoubleValuePtr = -1.0;
+ u_fscanf(myFile, "Spell Out %%V (non-ANSI): %V\n", newDoubleValuePtr);
+ if (myFloat != *newDoubleValuePtr) {
+ log_err("%%V Got: %f, Expected: %f\n", *newDoubleValuePtr, myFloat);
+ }
+
+ u_fgets(myUString, 4, myFile);
+ u_austrncpy(myString, myUString, sizeof(myUString)/sizeof(*myUString));
+ if (myString == NULL || strcmp(myString, "\t\n") != 0) {
+ log_err("u_fgets got \"%s\"\n", myString);
+ }
+
+ if (u_fgets(myUString, sizeof(myUString)/sizeof(*myUString), myFile) != myUString) {
+ log_err("u_fgets did not return myUString\n");
+ }
+ u_austrncpy(myString, myUString, sizeof(myUString)/sizeof(*myUString));
+ if (myString == NULL || strcmp(myString, "Pointer to integer (Count) %n: n=1 n=1\n") != 0) {
+ log_err("u_fgets got \"%s\"\n", myString);
+ }
+
+ if (u_fgets(myUString, sizeof(myUString)/sizeof(*myUString), myFile) != myUString) {
+ log_err("u_fgets did not return myUString\n");
+ }
+ u_austrncpy(myString, myUString, sizeof(myUString)/sizeof(*myUString));
+ if (myString == NULL || strcmp(myString, "Pointer to integer Value: 37\n") != 0) {
+ log_err("u_fgets got \"%s\"\n", myString);
+ }
+
+ if (u_fgets(myUString, sizeof(myUString)/sizeof(*myUString), myFile) != myUString) {
+ log_err("u_fgets did not return myUString\n");
+ }
+ u_austrncpy(myString, myUString, sizeof(myUString)/sizeof(*myUString));
+ if (myString == NULL || strcmp(myString, "This is a long test123456789012345678901234567890123456789012345678901234567890\n") != 0) {
+ log_err("u_fgets got \"%s\"\n", myString);
+ }
+
+ if (u_fgets(myUString, 0, myFile) != NULL) {
+ log_err("u_fgets got \"%s\" and it should have returned NULL\n", myString);
+ }
+
+ if (u_fgets(myUString, 1, myFile) != myUString) {
+ log_err("u_fgets did not return myUString\n");
+ }
+ u_austrncpy(myString, myUString, sizeof(myUString)/sizeof(*myUString));
+ if (myString == NULL || strcmp(myString, "") != 0) {
+ log_err("u_fgets got \"%s\"\n", myString);
+ }
+
+ if (u_fgets(myUString, 2, myFile) != myUString) {
+ log_err("u_fgets did not return myUString\n");
+ }
+ u_austrncpy(myString, myUString, sizeof(myUString)/sizeof(*myUString));
+ if (myString == NULL || strcmp(myString, "\t") != 0) {
+ log_err("u_fgets got \"%s\"\n", myString);
+ }
+
+ u_austrncpy(myString, u_fgets(myUString, sizeof(myUString)/sizeof(*myUString), myFile),
+ sizeof(myUString)/sizeof(*myUString));
+ if (strcmp(myString, "Normal fprintf count: n=1 n=1\n") != 0) {
+ log_err("u_fgets got \"%s\"\n", myString);
+ }
+
+ if (u_feof(myFile)) {
+ log_err("Got feof while reading the file and not at the end of the file.\n");
+ }
+ u_austrncpy(myString, u_fgets(myUString, sizeof(myUString)/sizeof(*myUString), myFile),
+ sizeof(myUString)/sizeof(*myUString));
+ if (strcmp(myString, "\tNormal fprintf count value: n=27\n") != 0) {
+ log_err("u_fgets got \"%s\"\n", myString);
+ }
+ if (!u_feof(myFile)) {
+ log_err("Did not get feof while reading the end of the file.\n");
+ }
+ if (u_fscanf(myFile, "%S\n", myUString) != 0) {
+ log_err("u_fscanf read data while reading the end of the file.\n");
+ }
+
+ u_fclose(myFile);
+}
+
+static void TestFile(void) {
+/* FILE *standardFile;*/
+
+ log_verbose("Testing u_fopen\n");
+ TestFileFromICU(u_fopen(STANDARD_TEST_FILE, "w", NULL, NULL));
+
+/* Don't know how to make this work without stdout or stderr */
+/*
+ log_verbose("Testing u_finit\n");
+ standardFile = fopen(STANDARD_TEST_FILE, "wb");
+ TestFileFromICU(u_finit(standardFile, NULL, NULL));
+ fclose(standardFile);
+*/
+}
+#endif
+
+static void StdinBuffering(void) {
+#if 0
+ UChar buff[255];
+ int32_t num = 0;
+ UFILE *uStdIn = NULL;
+ UFILE *uStdOut = NULL;
+ uStdIn = u_finit(stdin, NULL, NULL);
+ uStdOut = u_finit(stdout, NULL, NULL);
+ if (uStdIn == NULL)
+ return;
+
+ buff[0] = 0x40;
+ buff[1] = 0;
+ u_fgets(buff, sizeof(buff)/sizeof(buff[0]), uStdIn);
+ u_fprintf(uStdOut, "%S\n", buff);
+ u_fscanf(uStdIn, "%d", &num);
+ u_fprintf(uStdOut, "%d\n", num);
+ u_fscanf(uStdIn, "%d", &num);
+ u_fprintf(uStdOut, "%d\n", num);
+#else
+ log_verbose("Test disabled because it requires user interaction");
+#endif
+}
+
+static void TestCodepageAndLocale(void) {
+ UFILE *myFile = u_fopen(STANDARD_TEST_FILE, "w", NULL, NULL);
+ if (myFile == NULL) {
+ log_err("Can't write test file.\n");
+ return;
+ }
+ if (u_fgetcodepage(myFile) == NULL
+ || strcmp(u_fgetcodepage(myFile), ucnv_getDefaultName()) != 0)
+ {
+ log_err("Didn't get the proper default codepage. Got %s expected: %s\n",
+ u_fgetcodepage(myFile), ucnv_getDefaultName());
+ }
+#if !UCONFIG_NO_FORMATTING
+ if (u_fgetlocale(myFile) == NULL
+ || strcmp(u_fgetlocale(myFile), uloc_getDefault()) != 0)
+ {
+ log_err("Didn't get the proper default locale. Got %s expected: %s\n",
+ u_fgetlocale(myFile), uloc_getDefault());
+ }
+#endif
+ u_fclose(myFile);
+
+ myFile = u_fopen(STANDARD_TEST_FILE, "w", "es", NULL);
+ if (u_fgetcodepage(myFile) == NULL
+ || strcmp(u_fgetcodepage(myFile), ucnv_getDefaultName()) != 0)
+ {
+ log_err("Didn't get the proper default codepage for \"es\". Got %s expected: iso-8859-1\n",
+ u_fgetcodepage(myFile));
+ }
+#if !UCONFIG_NO_FORMATTING
+ if (u_fgetlocale(myFile) == NULL
+ || strcmp(u_fgetlocale(myFile), "es") != 0)
+ {
+ log_err("Didn't get the proper default locale. Got %s expected: %s\n",
+ u_fgetlocale(myFile), "es");
+ }
+#endif
+ u_fclose(myFile);
+
+ myFile = u_fopen(STANDARD_TEST_FILE, "w", NULL, "UTF-16");
+ if (u_fgetcodepage(myFile) == NULL
+ || strcmp(u_fgetcodepage(myFile), "UTF-16") != 0)
+ {
+ log_err("Didn't get the proper default codepage for \"en\". Got %s expected: iso-8859-1\n",
+ u_fgetcodepage(myFile));
+ }
+#if !UCONFIG_NO_FORMATTING
+ if (u_fgetlocale(myFile) == NULL
+ || strcmp(u_fgetlocale(myFile), uloc_getDefault()) != 0)
+ {
+ log_err("Didn't get the proper default locale. Got %s expected: %s\n",
+ u_fgetlocale(myFile), uloc_getDefault());
+ }
+#endif
+ u_fclose(myFile);
+
+ myFile = u_fopen(STANDARD_TEST_FILE, "w", "zh", "UTF-16");
+ if (u_fgetcodepage(myFile) == NULL
+ || strcmp(u_fgetcodepage(myFile), "UTF-16") != 0)
+ {
+ log_err("Didn't get the proper default codepage for \"en\". Got %s expected: iso-8859-1\n",
+ u_fgetcodepage(myFile));
+ }
+#if !UCONFIG_NO_FORMATTING
+ if (u_fgetlocale(myFile) == NULL
+ || strcmp(u_fgetlocale(myFile), "zh") != 0)
+ {
+ log_err("Didn't get the proper default locale. Got %s expected: %s\n",
+ u_fgetlocale(myFile), "zh");
+ }
+#endif
+ u_fclose(myFile);
+}
+
+
+static void TestfgetsBuffers(void) {
+ UChar buffer[2048];
+ UChar expectedBuffer[2048];
+ static const char testStr[] = "This is a test string that tests u_fgets. It makes sure that we don't try to read too much!";
+ UFILE *myFile = u_fopen(STANDARD_TEST_FILE, "w", NULL, "UTF-16");
+ int32_t expectedSize = (int32_t)strlen(testStr);
+ int32_t readSize;
+ int32_t repetitions;
+
+ if (myFile == NULL) {
+ log_err("Can't write test file.\n");
+ return;
+ }
+
+ u_fputc(0x3BC, myFile);
+ if (u_fputc(0x110000, myFile) != U_EOF) {
+ log_err("u_fputc should return U_EOF for 0x110000.\n");
+ }
+ if (u_fputc((UChar32)0xFFFFFFFFu, myFile) != U_EOF) {
+ log_err("u_fputc should return U_EOF for 0xFFFFFFFF.\n");
+ }
+ u_fputc(0xFF41, myFile);
+ u_memset(buffer, 0xBEEF, sizeof(buffer)/sizeof(buffer[0]));
+ u_memset(expectedBuffer, 0, sizeof(expectedBuffer)/sizeof(expectedBuffer[0]));
+ u_uastrncpy(buffer, testStr, expectedSize+1);
+ for (repetitions = 0; repetitions < 16; repetitions++) {
+ u_file_write(buffer, expectedSize, myFile);
+ u_strcat(expectedBuffer, buffer);
+ }
+ u_fclose(myFile);
+
+ u_memset(buffer, 0xBEEF, sizeof(buffer)/sizeof(buffer[0]));
+ myFile = u_fopen(STANDARD_TEST_FILE, "r", NULL, "UTF-16");
+ if (u_fgetc(myFile) != 0x3BC) {
+ log_err("The first character is wrong\n");
+ }
+ if (u_fgetc(myFile) != 0xFF41) {
+ log_err("The second character is wrong\n");
+ }
+ if (u_fgets(buffer, sizeof(buffer)/sizeof(buffer[0]), myFile) != buffer) {
+ log_err("Didn't get the buffer back\n");
+ return;
+ }
+ readSize = u_strlen(buffer);
+ if (readSize != expectedSize*repetitions) {
+ log_err("Buffer is the wrong size. Got %d Expected %d\n", u_strlen(buffer), expectedSize*repetitions);
+ }
+ if (buffer[(expectedSize*repetitions) + 1] != 0xBEEF) {
+ log_err("u_fgets wrote too much data\n");
+ }
+ if (u_strcmp(buffer, expectedBuffer) != 0) {
+ log_err("Did get expected string back\n");
+ }
+ if (strcmp(u_fgetcodepage(myFile), "UTF-16") != 0) {
+ log_err("Got %s instead of UTF-16\n", u_fgetcodepage(myFile));
+ }
+ u_fclose(myFile);
+
+ log_verbose("Now trying a multi-byte encoding (UTF-8).\n");
+
+ myFile = u_fopen(STANDARD_TEST_FILE, "w", NULL, "UTF-8");
+
+ u_fputc(0x3BC, myFile);
+ u_fputc(0xFF41, myFile);
+ u_memset(buffer, 0xBEEF, sizeof(buffer)/sizeof(buffer[0]));
+ u_memset(expectedBuffer, 0, sizeof(expectedBuffer)/sizeof(expectedBuffer[0]));
+ u_uastrncpy(buffer, testStr, expectedSize+1);
+ for (repetitions = 0; repetitions < 16; repetitions++) {
+ u_file_write(buffer, expectedSize, myFile);
+ u_strcat(expectedBuffer, buffer);
+ }
+ u_fclose(myFile);
+
+ u_memset(buffer, 0xBEEF, sizeof(buffer)/sizeof(buffer[0]));
+ myFile = u_fopen(STANDARD_TEST_FILE, "r", NULL, "UTF-8");
+ if (strcmp(u_fgetcodepage(myFile), "UTF-8") != 0) {
+ log_err("Got %s instead of UTF-8\n", u_fgetcodepage(myFile));
+ }
+ if (u_fgetc(myFile) != 0x3BC) {
+ log_err("The first character is wrong\n");
+ }
+ if (u_fgetc(myFile) != 0xFF41) {
+ log_err("The second character is wrong\n");
+ }
+ if (u_fgets(buffer, sizeof(buffer)/sizeof(buffer[0]), myFile) != buffer) {
+ log_err("Didn't get the buffer back\n");
+ return;
+ }
+ readSize = u_strlen(buffer);
+ if (readSize != expectedSize*repetitions) {
+ log_err("Buffer is the wrong size. Got %d Expected %d\n", u_strlen(buffer), expectedSize*repetitions);
+ }
+ if (buffer[(expectedSize*repetitions) + 1] != 0xBEEF) {
+ log_err("u_fgets wrote too much data\n");
+ }
+ if (u_strcmp(buffer, expectedBuffer) != 0) {
+ log_err("Did get expected string back\n");
+ }
+ u_fclose(myFile);
+
+
+ log_verbose("Now trying a multi-byte encoding (UTF-8) with a really small buffer.\n");
+
+ myFile = u_fopen(STANDARD_TEST_FILE, "w", NULL, "UTF-8");
+
+ u_fputc(0xFF41, myFile);
+ u_memset(buffer, 0xBEEF, sizeof(buffer)/sizeof(buffer[0]));
+ u_memset(expectedBuffer, 0, sizeof(expectedBuffer)/sizeof(expectedBuffer[0]));
+ u_uastrncpy(buffer, testStr, expectedSize+1);
+ for (repetitions = 0; repetitions < 1; repetitions++) {
+ u_file_write(buffer, expectedSize, myFile);
+ u_strcat(expectedBuffer, buffer);
+ }
+ u_fclose(myFile);
+
+ u_memset(buffer, 0xBEEF, sizeof(buffer)/sizeof(buffer[0]));
+ myFile = u_fopen(STANDARD_TEST_FILE, "r", NULL, "UTF-8");
+ if (u_fgets(buffer, 2, myFile) != buffer) {
+ log_err("Didn't get the buffer back\n");
+ return;
+ }
+ readSize = u_strlen(buffer);
+ if (readSize != 1) {
+ log_err("Buffer is the wrong size. Got %d Expected %d\n", u_strlen(buffer), 1);
+ }
+ if (buffer[0] != 0xFF41 || buffer[1] != 0) {
+ log_err("Did get expected string back\n");
+ }
+ if (buffer[2] != 0xBEEF) {
+ log_err("u_fgets wrote too much data\n");
+ }
+ u_fclose(myFile);
+
+}
+
+static void TestFileReadBuffering(void) {
+ UChar buffer[1024];
+ UFILE *myFile = u_fopen(STANDARD_TEST_FILE, "w", NULL, "UTF-16");
+ int32_t how_many;
+ int32_t repetitions;
+
+ u_memset(buffer, 0xBEEF, sizeof(buffer)/sizeof(buffer[0]));
+ for (repetitions = 0; repetitions < 2; repetitions++) {
+ u_file_write(buffer, sizeof(buffer)/sizeof(buffer[0]), myFile);
+ }
+
+ u_fclose(myFile);
+ u_memset(buffer, 0xDEAD, sizeof(buffer)/sizeof(buffer[0]));
+ myFile = u_fopen(STANDARD_TEST_FILE, "r", NULL, "UTF-16");
+ how_many = u_file_read(buffer, 1024, myFile);
+ if (how_many != 1024 || buffer[1023] != 0xBEEF) {
+ log_err("u_file_read read too much or not enough data\n");
+ }
+ u_fclose(myFile);
+}
+
+static void TestfgetsLineCount(void) {
+ UChar buffer[2048];
+ UChar expectedBuffer[2048];
+ char charBuffer[2048];
+ static const char testStr[] = "This is a test string that tests u_fgets. It makes sure that we don't try to read too much!";
+ UFILE *myFile = NULL;
+ FILE *stdFile = fopen(STANDARD_TEST_FILE, "w");
+ int32_t expectedSize = (int32_t)strlen(testStr);
+ int32_t repetitions;
+ int32_t nlRepetitions;
+
+ if (stdFile == NULL) {
+ log_err("Can't write test file.\n");
+ return;
+ }
+ u_memset(expectedBuffer, 0, sizeof(expectedBuffer)/sizeof(expectedBuffer[0]));
+
+ for (repetitions = 0; repetitions < 16; repetitions++) {
+ fwrite(testStr, sizeof(testStr[0]), expectedSize, stdFile);
+ for (nlRepetitions = 0; nlRepetitions < repetitions; nlRepetitions++) {
+ fwrite("\n", sizeof(testStr[0]), 1, stdFile);
+ }
+ }
+ fclose(stdFile);
+
+ myFile = u_fopen(STANDARD_TEST_FILE, "r", NULL, NULL);
+ stdFile = fopen(STANDARD_TEST_FILE, "r");
+
+ for (;;) {
+ char *returnedCharBuffer;
+ UChar *returnedUCharBuffer;
+
+ u_memset(buffer, 0xBEEF, sizeof(buffer)/sizeof(buffer[0]));
+ returnedCharBuffer = fgets(charBuffer, sizeof(charBuffer)/sizeof(charBuffer[0]), stdFile);
+ returnedUCharBuffer = u_fgets(buffer, sizeof(buffer)/sizeof(buffer[0]), myFile);
+
+ if (!returnedCharBuffer && !returnedUCharBuffer) {
+ /* Both returned NULL. stop. */
+ break;
+ }
+ if (returnedCharBuffer != charBuffer) {
+ log_err("Didn't get the charBuffer back\n");
+ continue;
+ }
+ u_uastrncpy(expectedBuffer, charBuffer, (int32_t)strlen(charBuffer)+1);
+ if (returnedUCharBuffer != buffer) {
+ log_err("Didn't get the buffer back\n");
+ continue;
+ }
+ if (u_strcmp(buffer, expectedBuffer) != 0) {
+ log_err("buffers are different\n");
+ }
+ if (buffer[u_strlen(buffer)+1] != 0xBEEF) {
+ log_err("u_fgets wrote too much\n");
+ }
+ }
+ fclose(stdFile);
+ u_fclose(myFile);
+}
+
+static void TestfgetsNewLineHandling(void) {
+ UChar buffer[256];
+ static const UChar testUStr[][16] = {
+ {0x000D, 0},
+ {0x000D, 0x000A, 0},
+ {0x000D, 0},
+ {0x000D, 0},
+ {0x0085, 0},
+ {0x000A, 0},
+ {0x000D, 0},
+ {0x000B, 0},
+ {0x000C, 0},
+ {0x000C, 0},
+ {0x2028, 0},
+ {0x0085, 0},
+ {0x2029, 0},
+ {0x0085, 0},
+
+ {0x008B, 0x000D, 0},
+ {0x00A0, 0x000D, 0x000A, 0},
+ {0x3000, 0x000D, 0},
+ {0xd800, 0xdfff, 0x000D, 0},
+ {0x00AB, 0x0085, 0},
+ {0x00AC, 0x000A, 0},
+ {0x00AD, 0x000D, 0},
+ {0x00BA, 0x000B, 0},
+ {0x00AB, 0x000C, 0},
+ {0x00B1, 0x000C, 0},
+ {0x30BB, 0x2028, 0},
+ {0x00A5, 0x0085, 0},
+ {0x0080, 0x2029, 0},
+ {0x00AF, 0x0085, 0}
+
+ };
+ UFILE *myFile = NULL;
+ int32_t lineIdx;
+
+ myFile = u_fopen(STANDARD_TEST_FILE, "wb", NULL, "UTF-8");
+ if (myFile == NULL) {
+ log_err("Can't write test file.\n");
+ return;
+ }
+ for (lineIdx = 0; lineIdx < (int32_t)(sizeof(testUStr)/sizeof(testUStr[0])); lineIdx++) {
+ u_file_write(testUStr[lineIdx], u_strlen(testUStr[lineIdx]), myFile);
+ }
+ u_fclose(myFile);
+
+ myFile = u_fopen(STANDARD_TEST_FILE, "rb", NULL, "UTF-8");
+
+ for (lineIdx = 0; lineIdx < (int32_t)(sizeof(testUStr)/sizeof(testUStr[0])); lineIdx++) {
+ UChar *returnedUCharBuffer;
+
+ u_memset(buffer, 0xBEEF, sizeof(buffer)/sizeof(buffer[0]));
+ returnedUCharBuffer = u_fgets(buffer, sizeof(buffer)/sizeof(buffer[0]), myFile);
+
+ if (!returnedUCharBuffer) {
+ /* Returned NULL. stop. */
+ break;
+ }
+ if (u_strcmp(buffer, testUStr[lineIdx]) != 0) {
+ log_err("buffers are different at index = %d\n", lineIdx);
+ }
+ if (buffer[u_strlen(buffer)+1] != 0xBEEF) {
+ log_err("u_fgets wrote too much\n");
+ }
+ }
+ if (lineIdx != (int32_t)(sizeof(testUStr)/sizeof(testUStr[0]))) {
+ log_err("u_fgets read too much\n");
+ }
+ if (u_fgets(buffer, sizeof(buffer)/sizeof(buffer[0]), myFile) != NULL) {
+ log_err("u_file_write wrote too much\n");
+ }
+ u_fclose(myFile);
+}
+
+static void TestLineCount(const char *prefixLine, const char *line, int32_t numRepititions) {
+ UChar buffer[64];
+ UChar expectedBuffer[64];
+ int32_t lineLen = strlen(line);
+ UChar *returnedUCharBuffer;
+ int32_t repetitions;
+ UFILE *myFile = NULL;
+ FILE *stdFile = fopen(STANDARD_TEST_FILE, "wb");
+
+ if (stdFile == NULL) {
+ log_err("Can't write test file.\n");
+ return;
+ }
+ /* Write a prefix line and then write a bunch of lines */
+ fwrite(prefixLine, strlen(prefixLine), 1, stdFile);
+ for (repetitions = 0; repetitions < numRepititions; repetitions++) {
+ fwrite(line, lineLen, 1, stdFile);
+ }
+ fclose(stdFile);
+
+ myFile = u_fopen(STANDARD_TEST_FILE, "rb", NULL, NULL);
+ if (myFile == NULL) {
+ log_err("Can't read test file.\n");
+ return;
+ }
+
+ /* Read the prefix line. This can make sure that a Windows newline is either on a boundary or before it. */
+ u_uastrncpy(expectedBuffer, prefixLine, (int32_t)strlen(prefixLine)+1);
+ returnedUCharBuffer = u_fgets(buffer, sizeof(buffer)/sizeof(buffer[0]), myFile);
+ if (u_strcmp(returnedUCharBuffer, expectedBuffer) != 0) {
+ log_err("prefix buffer is different. prefix=\"%s\"\n", prefixLine);
+ return;
+ }
+
+ u_uastrncpy(expectedBuffer, line, (int32_t)strlen(line)+1);
+ for (repetitions = 0; ; repetitions++) {
+ u_memset(buffer, 0xBEEF, sizeof(buffer)/sizeof(buffer[0]));
+ returnedUCharBuffer = u_fgets(buffer, sizeof(buffer)/sizeof(buffer[0]), myFile);
+
+ if (!returnedUCharBuffer) {
+ /* returned NULL. stop. */
+ break;
+ }
+ if (u_strcmp(buffer, expectedBuffer) != 0) {
+ log_err("buffers are different at count %d\n", repetitions);
+ }
+ if (buffer[u_strlen(buffer)+1] != 0xBEEF) {
+ log_err("u_fgets wrote too much\n");
+ }
+ }
+ if (repetitions != numRepititions) {
+ log_err("got wrong number of lines. got=%d expected=%d\n", repetitions, numRepititions);
+ }
+ u_fclose(myFile);
+}
+
+static void TestfgetsNewLineCount(void) {
+ /* This makes sure that lines are correctly handled between buffer boundaries. */
+ TestLineCount("\n", "\n", 1024); /* Unix newlines */
+ TestLineCount("\r\n", "\r\n", 1024);/* Windows newlines */
+ TestLineCount("a\r\n", "\r\n", 1024);/* Windows newlines offset by 1 byte */
+ TestLineCount("\r\n", "a\r\n", 1024);/* Windows newlines offset with data */
+ TestLineCount("\n", "a\n", 1024); /* Unix newlines offset with data */
+ TestLineCount("\n", "\r\n", 1024); /* a mixed number of lines. */
+}
+
+static void TestFgetsLineBuffering(void) {
+ UChar buffer[2003]; /* Use a non-power of 2 or 10 */
+ UChar *returnedUCharBuffer;
+ int32_t repetitions;
+ UFILE *myFile = NULL;
+ FILE *stdFile = fopen(STANDARD_TEST_FILE, "wb");
+
+ if (stdFile == NULL) {
+ log_err("Can't write test file.\n");
+ return;
+ }
+ u_memset(buffer, 0xBEEF, sizeof(buffer)/sizeof(buffer[0]));
+
+ /* Write one very long line */
+ for (repetitions = 0; repetitions < ((sizeof(buffer)/sizeof(buffer[0]))*2); repetitions++) {
+ fwrite(repetitions ? "1" : "2", 1, 1, stdFile);
+ }
+ fclose(stdFile);
+
+ myFile = u_fopen(STANDARD_TEST_FILE, "rb", NULL, NULL);
+ if (myFile == NULL) {
+ log_err("Can't read test file.\n");
+ return;
+ }
+
+ /* Read part of one very long line */
+ returnedUCharBuffer = u_fgets(buffer, (sizeof(buffer)/sizeof(buffer[0]))-1, myFile);
+ if (u_strlen(returnedUCharBuffer) != ((sizeof(buffer)/sizeof(buffer[0]))-2)) {
+ log_err("Line is wrong length. Got %d. Expected %d.\n",
+ u_strlen(returnedUCharBuffer), ((sizeof(buffer)/sizeof(buffer[0]))-2));
+ }
+ /* We better not read too much */
+ if (buffer[(sizeof(buffer)/sizeof(buffer[0]))-1] != 0xBEEF) {
+ log_err("Too much data was written\n");
+ }
+
+ u_fclose(myFile);
+}
+
+
+static void TestCodepage(void) {
+ UFILE *myFile = NULL;
+ static const UChar strABAccentA[] = { 0x0041, 0x0042, 0x00C1, 0x0043, 0};
+ static const UChar strBadConversion[] = { 0x0041, 0x0042, 0xfffd, 0x0043, 0};
+ UChar testBuf[sizeof(strABAccentA)/sizeof(strABAccentA[0])*2]; /* *2 to see if too much was */
+ char convName[UCNV_MAX_CONVERTER_NAME_LENGTH];
+ int32_t retVal;
+ UErrorCode status = U_ZERO_ERROR;
+
+ myFile = u_fopen(STANDARD_TEST_FILE, "w", NULL, "absurd converter that can't be opened");
+
+ if (myFile) {
+ log_err("Recieved a UFILE * with an invalid codepage parameter\n");
+ u_fclose(myFile);
+ }
+
+ myFile = u_fopen(STANDARD_TEST_FILE, "w", NULL, "ISO-8859-1");
+ if (myFile == NULL) {
+ log_err("Can't write test file for iso-8859-1.\n");
+ return;
+ }
+ if (strcmp("ISO-8859-1", u_fgetcodepage(myFile)) != 0) {
+ log_err("Couldn't get ISO-8859-1 back as opened codepage\n");
+ }
+ u_file_write(strABAccentA, u_strlen(strABAccentA), myFile);
+ u_fclose(myFile);
+
+ /* Now see what we got wrote */
+ myFile = u_fopen(STANDARD_TEST_FILE, "r", NULL, NULL);
+ if (u_fsetcodepage("ISO-8859-1", myFile) != 0) {
+ log_err("u_fsetcodepage didn't set the codepage\n");
+ }
+ retVal = u_file_read(testBuf, u_strlen(strABAccentA), myFile);
+ if (u_strncmp(strABAccentA, testBuf, u_strlen(strABAccentA)) != 0) {
+ log_err("The test data was read and written differently!\n");
+ }
+ if (retVal != u_strlen(strABAccentA)) {
+ log_err("The test data returned different lengths. Got: %d, Expected %d\n", retVal, u_strlen(strABAccentA));
+ }
+ u_fclose(myFile);
+
+ /* What happens on invalid input? */
+ myFile = u_fopen(STANDARD_TEST_FILE, "r", NULL, "ISO-8859-1");
+ if (strcmp(ucnv_getName(u_fgetConverter(myFile), &status), "ISO-8859-1") != 0) {
+ log_err("u_fgetConverter returned %s\n", ucnv_getName(u_fgetConverter(myFile), &status));
+ }
+ if (u_fsetcodepage("UTF-8", myFile) != 0) {
+ log_err("u_fsetcodepage didn't set the codepage to UTF-8\n");
+ }
+ if (strcmp(ucnv_getName(u_fgetConverter(myFile), &status), "UTF-8") != 0) {
+ log_err("u_fgetConverter returned %s\n", ucnv_getName(u_fgetConverter(myFile), &status));
+ }
+ retVal = u_file_read(testBuf, u_strlen(strBadConversion), myFile);
+ if (u_strncmp(strBadConversion, testBuf, u_strlen(strBadConversion)) != 0) {
+ log_err("The test data wasn't subsituted as expected\n");
+ }
+ u_fclose(myFile);
+
+ /* Can't currently swap codepages midstream */
+ myFile = u_fopen(STANDARD_TEST_FILE, "r", NULL, "ISO-8859-1");
+ strcpy(convName, u_fgetcodepage(myFile));
+ u_file_read(testBuf, 1, myFile);
+ if (u_fsetcodepage("UTF-8", myFile) == 0) {
+ log_err("u_fsetcodepage set the codepage after reading a byte\n");
+ }
+ retVal = u_file_read(testBuf + 1, u_strlen(strABAccentA) - 1, myFile);
+ if (u_strncmp(strABAccentA, testBuf, u_strlen(strABAccentA)) != 0) {
+ log_err("u_fsetcodepage changed the codepages after writing data\n");
+ }
+ if ((retVal + 1) != u_strlen(strABAccentA)) {
+ log_err("The test data returned different lengths. Got: %d, Expected %d\n", retVal, u_strlen(strABAccentA));
+ }
+ u_frewind(myFile);
+ retVal = u_file_read(testBuf, u_strlen(strABAccentA), myFile);
+ if (u_strncmp(strABAccentA, testBuf, u_strlen(strABAccentA)) != 0) {
+ log_err("The test data was read and written differently!\n");
+ }
+ if (retVal != u_strlen(strABAccentA)) {
+ log_err("The test data returned different lengths. Got: %d, Expected %d\n", retVal, u_strlen(strABAccentA));
+ }
+ u_fclose(myFile);
+
+}
+
+#if !UCONFIG_NO_FORMATTING
+static void TestFilePrintCompatibility(void) {
+ UFILE *myFile = u_fopen(STANDARD_TEST_FILE, "wb", "en_US_POSIX", NULL);
+ FILE *myCFile;
+ int32_t num;
+ char cVal;
+ static const UChar emptyStr[] = {0};
+ char readBuf[512] = "";
+ char testBuf[512] = "";
+
+ if (myFile == NULL) {
+ log_err("Can't write test file.\n");
+ return;
+ }
+#if !UCONFIG_NO_FORMATTING
+ if (strcmp(u_fgetlocale(myFile), "en_US_POSIX") != 0) {
+ log_err("Got %s instead of en_US_POSIX for locale\n", u_fgetlocale(myFile));
+ }
+#endif
+
+ /* Compare against C API compatibility */
+ for (num = -STANDARD_TEST_NUM_RANGE; num < STANDARD_TEST_NUM_RANGE; num++) {
+ u_fprintf(myFile, "%x ", num);
+ u_fprintf(myFile, "%X ", num);
+ u_fprintf(myFile, "%o ", num);
+ u_fprintf(myFile, "%d ", num);
+ u_fprintf(myFile, "%i ", num);
+ u_fprintf(myFile, "%f ", (double)num);
+/* u_fprintf(myFile, "%e ", (double)num);
+ u_fprintf(myFile, "%E ", (double)num);*/
+ u_fprintf(myFile, "%g ", (double)num);
+ u_fprintf(myFile, "%G", (double)num);
+ u_fputs(emptyStr, myFile);
+ }
+
+ u_fprintf_u(myFile, NEW_LINE);
+
+ for (num = 0; num < 0x80; num++) {
+ u_fprintf(myFile, "%c", num);
+ }
+
+ u_fclose(myFile);
+ myCFile = fopen(STANDARD_TEST_FILE, "rb");
+ if (myCFile == NULL) {
+ log_err("Can't read test file.");
+ return;
+ }
+
+ for (num = -STANDARD_TEST_NUM_RANGE; num < STANDARD_TEST_NUM_RANGE; num++) {
+ fscanf(myCFile, "%s", readBuf);
+ sprintf(testBuf, "%x", (int)num);
+ if (strcmp(readBuf, testBuf) != 0) {
+ log_err("%%x Got: \"%s\", Expected: \"%s\"\n", readBuf, testBuf);
+ }
+
+ fscanf(myCFile, "%s", readBuf);
+ sprintf(testBuf, "%X", (int)num);
+ if (strcmp(readBuf, testBuf) != 0) {
+ log_err("%%X Got: \"%s\", Expected: \"%s\"\n", readBuf, testBuf);
+ }
+
+ fscanf(myCFile, "%s", readBuf);
+ sprintf(testBuf, "%o", (int)num);
+ if (strcmp(readBuf, testBuf) != 0) {
+ log_err("%%o Got: \"%s\", Expected: \"%s\"\n", readBuf, testBuf);
+ }
+
+ /* fprintf is not compatible on all platforms e.g. the iSeries */
+ fscanf(myCFile, "%s", readBuf);
+ sprintf(testBuf, "%d", (int)num);
+ if (strcmp(readBuf, testBuf) != 0) {
+ log_err("%%d Got: \"%s\", Expected: \"%s\"\n", readBuf, testBuf);
+ }
+
+ fscanf(myCFile, "%s", readBuf);
+ sprintf(testBuf, "%i", (int)num);
+ if (strcmp(readBuf, testBuf) != 0) {
+ log_err("%%i Got: \"%s\", Expected: \"%s\"\n", readBuf, testBuf);
+ }
+
+ fscanf(myCFile, "%s", readBuf);
+ sprintf(testBuf, "%f", (double)num);
+ if (strcmp(readBuf, testBuf) != 0) {
+ log_err("%%f Got: \"%s\", Expected: \"%s\"\n", readBuf, testBuf);
+ }
+
+/* fscanf(myCFile, "%s", readBuf);
+ sprintf(testBuf, "%e", (double)num);
+ if (strcmp(readBuf, testBuf) != 0) {
+ log_err("%%e Got: \"%s\", Expected: \"%s\"\n", readBuf, testBuf);
+ }
+
+ fscanf(myCFile, "%s", readBuf);
+ sprintf(testBuf, "%E", (double)num);
+ if (strcmp(readBuf, testBuf) != 0) {
+ log_err("%%E Got: \"%s\", Expected: \"%s\"\n", readBuf, testBuf);
+ }*/
+
+ fscanf(myCFile, "%s", readBuf);
+ sprintf(testBuf, "%g", (double)num);
+ if (strcmp(readBuf, testBuf) != 0) {
+ log_err("%%g Got: \"%s\", Expected: \"%s\"\n", readBuf, testBuf);
+ }
+
+ fscanf(myCFile, "%s", readBuf);
+ sprintf(testBuf, "%G", (double)num);
+ if (strcmp(readBuf, testBuf) != 0) {
+ log_err("%%G Got: \"%s\", Expected: \"%s\"\n", readBuf, testBuf);
+ }
+ }
+
+ /* Properly eat the newlines */
+ for (num = 0; num < (int32_t)strlen(C_NEW_LINE); num++) {
+ fscanf(myCFile, "%c", &cVal);
+ if (cVal != C_NEW_LINE[num]) {
+ log_err("OS newline error\n");
+ }
+ }
+ for (num = 0; num < (int32_t)strlen(C_NEW_LINE); num++) {
+ fscanf(myCFile, "%c", &cVal);
+ if (cVal != C_NEW_LINE[num]) {
+ log_err("ustdio newline error\n");
+ }
+ }
+
+ for (num = 0; num < 0x80; num++) {
+ cVal = -1;
+ fscanf(myCFile, "%c", &cVal);
+ if (num != cVal) {
+ log_err("%%c Got: 0x%x, Expected: 0x%x\n", cVal, num);
+ }
+ }
+ fclose(myCFile);
+}
+#endif
+
+#define TestFPrintFormat(uFormat, uValue, cFormat, cValue) \
+ myFile = u_fopen(STANDARD_TEST_FILE, "w", "en_US_POSIX", NULL);\
+ if (myFile == NULL) {\
+ log_err("Can't write test file for %s.\n", uFormat);\
+ return;\
+ }\
+ /* Reinitialize the buffer to verify null termination works. */\
+ u_memset(uBuffer, 0x2a, sizeof(uBuffer)/sizeof(*uBuffer));\
+ memset(buffer, '*', sizeof(buffer)/sizeof(*buffer));\
+ \
+ uNumPrinted = u_fprintf(myFile, uFormat, uValue);\
+ u_fclose(myFile);\
+ myFile = u_fopen(STANDARD_TEST_FILE, "r", "en_US_POSIX", NULL);\
+ u_fgets(uBuffer, sizeof(uBuffer)/sizeof(*uBuffer), myFile);\
+ u_fclose(myFile);\
+ u_austrncpy(compBuffer, uBuffer, sizeof(uBuffer)/sizeof(*uBuffer));\
+ cNumPrinted = sprintf(buffer, cFormat, cValue);\
+ if (strcmp(buffer, compBuffer) != 0) {\
+ log_err("%" uFormat " Got: \"%s\", Expected: \"%s\"\n", compBuffer, buffer);\
+ }\
+ if (cNumPrinted != uNumPrinted) {\
+ log_err("%" uFormat " number printed Got: %d, Expected: %d\n", uNumPrinted, cNumPrinted);\
+ }\
+ if (buffer[uNumPrinted+1] != '*') {\
+ log_err("%" uFormat " too much stored\n");\
+ }\
+
+#if !UCONFIG_NO_FORMATTING
+static void TestFprintfFormat(void) {
+ static const UChar abcUChars[] = {0x61,0x62,0x63,0};
+ static const char abcChars[] = "abc";
+ UChar uBuffer[256];
+ char buffer[256];
+ char compBuffer[256];
+ int32_t uNumPrinted;
+ int32_t cNumPrinted;
+ UFILE *myFile;
+
+ TestFPrintFormat("%8S", abcUChars, "%8s", abcChars);
+ TestFPrintFormat("%-8S", abcUChars, "%-8s", abcChars);
+ TestFPrintFormat("%.2S", abcUChars, "%.2s", abcChars); /* strlen is 3 */
+
+ TestFPrintFormat("%8s", abcChars, "%8s", abcChars);
+ TestFPrintFormat("%-8s", abcChars, "%-8s", abcChars);
+ TestFPrintFormat("%.2s", abcChars, "%.2s", abcChars); /* strlen is 3 */
+
+ TestFPrintFormat("%8c", (char)'e', "%8c", (char)'e');
+ TestFPrintFormat("%-8c", (char)'e', "%-8c", (char)'e');
+
+ TestFPrintFormat("%8C", (UChar)0x65, "%8c", (char)'e');
+ TestFPrintFormat("%-8C", (UChar)0x65, "%-8c", (char)'e');
+
+ TestFPrintFormat("%f", 1.23456789, "%f", 1.23456789);
+ TestFPrintFormat("%f", 12345.6789, "%f", 12345.6789);
+ TestFPrintFormat("%f", 123456.789, "%f", 123456.789);
+ TestFPrintFormat("%f", 1234567.89, "%f", 1234567.89);
+ TestFPrintFormat("%10f", 1.23456789, "%10f", 1.23456789);
+ TestFPrintFormat("%-10f", 1.23456789, "%-10f", 1.23456789);
+ TestFPrintFormat("%10f", 123.456789, "%10f", 123.456789);
+ TestFPrintFormat("%10.4f", 123.456789, "%10.4f", 123.456789);
+ TestFPrintFormat("%-10f", 123.456789, "%-10f", 123.456789);
+
+/* TestFPrintFormat("%g", 12345.6789, "%g", 12345.6789);
+ TestFPrintFormat("%g", 123456.789, "%g", 123456.789);
+ TestFPrintFormat("%g", 1234567.89, "%g", 1234567.89);
+ TestFPrintFormat("%G", 123456.789, "%G", 123456.789);
+ TestFPrintFormat("%G", 1234567.89, "%G", 1234567.89);*/
+ TestFPrintFormat("%10g", 1.23456789, "%10g", 1.23456789);
+ TestFPrintFormat("%10.4g", 1.23456789, "%10.4g", 1.23456789);
+ TestFPrintFormat("%-10g", 1.23456789, "%-10g", 1.23456789);
+ TestFPrintFormat("%10g", 123.456789, "%10g", 123.456789);
+ TestFPrintFormat("%-10g", 123.456789, "%-10g", 123.456789);
+
+ TestFPrintFormat("%8x", 123456, "%8x", 123456);
+ TestFPrintFormat("%-8x", 123456, "%-8x", 123456);
+ TestFPrintFormat("%08x", 123456, "%08x", 123456);
+
+ TestFPrintFormat("%8X", 123456, "%8X", 123456);
+ TestFPrintFormat("%-8X", 123456, "%-8X", 123456);
+ TestFPrintFormat("%08X", 123456, "%08X", 123456);
+ TestFPrintFormat("%#x", 123456, "%#x", 123456);
+ TestFPrintFormat("%#x", -123456, "%#x", -123456);
+
+ TestFPrintFormat("%8o", 123456, "%8o", 123456);
+ TestFPrintFormat("%-8o", 123456, "%-8o", 123456);
+ TestFPrintFormat("%08o", 123456, "%08o", 123456);
+ TestFPrintFormat("%#o", 123, "%#o", 123);
+ TestFPrintFormat("%#o", -123, "%#o", -123);
+
+ TestFPrintFormat("%8u", 123456, "%8u", 123456);
+ TestFPrintFormat("%-8u", 123456, "%-8u", 123456);
+ TestFPrintFormat("%08u", 123456, "%08u", 123456);
+ TestFPrintFormat("%8u", -123456, "%8u", -123456);
+ TestFPrintFormat("%-8u", -123456, "%-8u", -123456);
+ TestFPrintFormat("%.5u", 123456, "%.5u", 123456);
+ TestFPrintFormat("%.6u", 123456, "%.6u", 123456);
+ TestFPrintFormat("%.7u", 123456, "%.7u", 123456);
+
+ TestFPrintFormat("%8d", 123456, "%8d", 123456);
+ TestFPrintFormat("%-8d", 123456, "%-8d", 123456);
+ TestFPrintFormat("%08d", 123456, "%08d", 123456);
+ TestFPrintFormat("% d", 123456, "% d", 123456);
+ TestFPrintFormat("% d", -123456, "% d", -123456);
+
+ TestFPrintFormat("%8i", 123456, "%8i", 123456);
+ TestFPrintFormat("%-8i", 123456, "%-8i", 123456);
+ TestFPrintFormat("%08i", 123456, "%08i", 123456);
+
+ log_verbose("Get really crazy with the formatting.\n");
+
+ TestFPrintFormat("%-#12x", 123, "%-#12x", 123);
+ TestFPrintFormat("%-#12x", -123, "%-#12x", -123);
+ TestFPrintFormat("%#12x", 123, "%#12x", 123);
+ TestFPrintFormat("%#12x", -123, "%#12x", -123);
+
+ TestFPrintFormat("%-+12d", 123, "%-+12d", 123);
+ TestFPrintFormat("%-+12d", -123, "%-+12d", -123);
+ TestFPrintFormat("%- 12d", 123, "%- 12d", 123);
+ TestFPrintFormat("%- 12d", -123, "%- 12d", -123);
+ TestFPrintFormat("%+12d", 123, "%+12d", 123);
+ TestFPrintFormat("%+12d", -123, "%+12d", -123);
+ TestFPrintFormat("% 12d", 123, "% 12d", 123);
+ TestFPrintFormat("% 12d", -123, "% 12d", -123);
+ TestFPrintFormat("%12d", 123, "%12d", 123);
+ TestFPrintFormat("%12d", -123, "%12d", -123);
+ TestFPrintFormat("%.12d", 123, "%.12d", 123);
+ TestFPrintFormat("%.12d", -123, "%.12d", -123);
+
+ TestFPrintFormat("%-+12.1f", 1.234, "%-+12.1f", 1.234);
+ TestFPrintFormat("%-+12.1f", -1.234, "%-+12.1f", -1.234);
+ TestFPrintFormat("%- 12.10f", 1.234, "%- 12.10f", 1.234);
+ TestFPrintFormat("%- 12.1f", -1.234, "%- 12.1f", -1.234);
+ TestFPrintFormat("%+12.1f", 1.234, "%+12.1f", 1.234);
+ TestFPrintFormat("%+12.1f", -1.234, "%+12.1f", -1.234);
+ TestFPrintFormat("% 12.1f", 1.234, "% 12.1f", 1.234);
+ TestFPrintFormat("% 12.1f", -1.234, "% 12.1f", -1.234);
+ TestFPrintFormat("%12.1f", 1.234, "%12.1f", 1.234);
+ TestFPrintFormat("%12.1f", -1.234, "%12.1f", -1.234);
+ TestFPrintFormat("%.2f", 1.234, "%.2f", 1.234);
+ TestFPrintFormat("%.2f", -1.234, "%.2f", -1.234);
+ TestFPrintFormat("%3f", 1.234, "%3f", 1.234);
+ TestFPrintFormat("%3f", -1.234, "%3f", -1.234);
+
+ myFile = u_fopen(STANDARD_TEST_FILE, "w", "en_US_POSIX", NULL);
+ /* Reinitialize the buffer to verify null termination works. */
+ u_memset(uBuffer, 0x2a, sizeof(uBuffer)/sizeof(*uBuffer));
+ memset(buffer, '*', sizeof(buffer)/sizeof(*buffer));
+
+ uNumPrinted = u_fprintf(myFile, "%d % d %d", -1234, 1234, 1234);
+ u_fclose(myFile);
+ myFile = u_fopen(STANDARD_TEST_FILE, "r", "en_US_POSIX", NULL);
+ u_fgets(uBuffer, sizeof(uBuffer)/sizeof(*uBuffer), myFile);
+ u_fclose(myFile);
+ u_austrncpy(compBuffer, uBuffer, sizeof(uBuffer)/sizeof(*uBuffer));
+ cNumPrinted = sprintf(buffer, "%d % d %d", -1234, 1234, 1234);
+ if (strcmp(buffer, compBuffer) != 0) {
+ log_err("%%d %% d %%d Got: \"%s\", Expected: \"%s\"\n", compBuffer, buffer);
+ }
+ if (cNumPrinted != uNumPrinted) {
+ log_err("%%d %% d %%d number printed Got: %d, Expected: %d\n", uNumPrinted, cNumPrinted);
+ }
+ if (buffer[uNumPrinted+1] != '*') {
+ log_err("%%d %% d %%d too much stored\n");
+ }
+}
+#endif
+
+#undef TestFPrintFormat
+
+#if !UCONFIG_NO_FORMATTING
+static void TestFScanSetFormat(const char *format, const UChar *uValue, const char *cValue, UBool expectedToPass) {
+ UFILE *myFile;
+ UChar uBuffer[256];
+ char buffer[256];
+ char compBuffer[256];
+ int32_t uNumScanned;
+ int32_t cNumScanned;
+
+ myFile = u_fopen(STANDARD_TEST_FILE, "w", NULL, NULL);
+ if (myFile == NULL) {
+ log_err("Can't write test file for %s.\n", format);
+ return;
+ }
+ /* Reinitialize the buffer to verify null termination works. */
+ u_memset(uBuffer, 0x2a, sizeof(uBuffer)/sizeof(*uBuffer));
+ uBuffer[sizeof(uBuffer)/sizeof(*uBuffer)-1] = 0;
+ memset(buffer, '*', sizeof(buffer)/sizeof(*buffer));
+ buffer[sizeof(buffer)/sizeof(*buffer)-1] = 0;
+
+ u_fprintf(myFile, "%S", uValue);
+ u_fclose(myFile);
+ myFile = u_fopen(STANDARD_TEST_FILE, "r", "en_US_POSIX", NULL);
+ uNumScanned = u_fscanf(myFile, format, uBuffer);
+ u_fclose(myFile);
+ if (expectedToPass) {
+ u_austrncpy(compBuffer, uBuffer, sizeof(uBuffer)/sizeof(*uBuffer));
+ cNumScanned = sscanf(cValue, format, buffer);
+ if (strncmp(buffer, compBuffer, sizeof(buffer)/sizeof(*buffer)) != 0) {
+ log_err("%s Got: \"%s\", Expected: \"%s\"\n", format, compBuffer, buffer);
+ }
+ if (cNumScanned != uNumScanned) {
+ log_err("%s number printed Got: %d, Expected: %d\n", format, uNumScanned, cNumScanned);
+ }
+ if (uNumScanned > 0 && uBuffer[u_strlen(uBuffer)+1] != 0x2a) {
+ log_err("%s too much stored\n", format);
+ }
+ }
+ else {
+ if (uNumScanned != 0 || uBuffer[0] != 0x2a || uBuffer[1] != 0x2a) {
+ log_err("%s too much stored on a failure\n", format);
+ }
+ }
+}
+#endif
+
+#if !UCONFIG_NO_FORMATTING
+static void TestFScanset(void) {
+ static const UChar abcUChars[] = {0x61,0x62,0x63,0x63,0x64,0x65,0x66,0x67,0};
+ static const char abcChars[] = "abccdefg";
+
+ TestFScanSetFormat("%[bc]S", abcUChars, abcChars, TRUE);
+ TestFScanSetFormat("%[cb]S", abcUChars, abcChars, TRUE);
+
+ TestFScanSetFormat("%[ab]S", abcUChars, abcChars, TRUE);
+ TestFScanSetFormat("%[ba]S", abcUChars, abcChars, TRUE);
+
+ TestFScanSetFormat("%[ab]", abcUChars, abcChars, TRUE);
+ TestFScanSetFormat("%[ba]", abcUChars, abcChars, TRUE);
+
+ TestFScanSetFormat("%[abcdefgh]", abcUChars, abcChars, TRUE);
+ TestFScanSetFormat("%[;hgfedcba]", abcUChars, abcChars, TRUE);
+
+ TestFScanSetFormat("%[^a]", abcUChars, abcChars, TRUE);
+ TestFScanSetFormat("%[^e]", abcUChars, abcChars, TRUE);
+ TestFScanSetFormat("%[^ed]", abcUChars, abcChars, TRUE);
+ TestFScanSetFormat("%[^dc]", abcUChars, abcChars, TRUE);
+ TestFScanSetFormat("%[^e] ", abcUChars, abcChars, TRUE);
+
+ TestFScanSetFormat("%1[ab] ", abcUChars, abcChars, TRUE);
+ TestFScanSetFormat("%2[^f]", abcUChars, abcChars, TRUE);
+
+ TestFScanSetFormat("%[qrst]", abcUChars, abcChars, TRUE);
+
+ /* Extra long string for testing */
+ TestFScanSetFormat(" %[qrst]",
+ abcUChars, abcChars, TRUE);
+
+ TestFScanSetFormat("%[a-]", abcUChars, abcChars, TRUE);
+
+ /* Bad format */
+ TestFScanSetFormat("%[f-a]", abcUChars, abcChars, FALSE);
+ TestFScanSetFormat("%[c-a]", abcUChars, abcChars, FALSE);
+ TestFScanSetFormat("%[a", abcUChars, abcChars, FALSE);
+ /* The following is not deterministic on Windows */
+/* TestFScanSetFormat("%[a-", abcUChars, abcChars);*/
+
+ /* TODO: Need to specify precision with a "*" */
+}
+#endif
+#if !UCONFIG_NO_FORMATTING
+static void TestBadFScanfFormat(const char *format, const UChar *uValue, const char *cValue) {
+ UFILE *myFile;
+ UChar uBuffer[256];
+ int32_t uNumScanned;
+
+ myFile = u_fopen(STANDARD_TEST_FILE, "w", NULL, NULL);
+ if (myFile == NULL) {
+ log_err("Can't write test file for %s.\n", format);
+ return;
+ }
+ /* Reinitialize the buffer to verify null termination works. */
+ u_memset(uBuffer, 0x2a, sizeof(uBuffer)/sizeof(*uBuffer));
+ uBuffer[sizeof(uBuffer)/sizeof(*uBuffer)-1] = 0;
+
+ u_fprintf(myFile, "%S", uValue);
+ u_fclose(myFile);
+ myFile = u_fopen(STANDARD_TEST_FILE, "r", "en_US_POSIX", NULL);
+ uNumScanned = u_fscanf(myFile, format, uBuffer);
+ u_fclose(myFile);
+ if (uNumScanned != 0 || uBuffer[0] != 0x2a || uBuffer[1] != 0x2a) {
+ log_err("%s too much stored on a failure\n", format);
+ }
+}
+#endif
+#if !UCONFIG_NO_FORMATTING
+static void TestBadScanfFormat(void) {
+ static const UChar abcUChars[] = {0x61,0x62,0x63,0x63,0x64,0x65,0x66,0x67,0};
+ static const char abcChars[] = "abccdefg";
+
+ TestBadFScanfFormat("%[] ", abcUChars, abcChars);
+}
+#endif
+#if !UCONFIG_NO_FORMATTING
+static void Test_u_vfprintf(const char *expectedResult, const char *format, ...) {
+ UChar uBuffer[256];
+ UChar uBuffer2[256];
+ va_list ap;
+ int32_t count;
+ UFILE *myFile;
+
+ myFile = u_fopen(STANDARD_TEST_FILE, "w", "en_US_POSIX", "UTF-8");
+ if (!myFile) {
+ log_err("Test file can't be opened\n");
+ return;
+ }
+
+ va_start(ap, format);
+ count = u_vfprintf(myFile, format, ap);
+ va_end(ap);
+
+ u_fclose(myFile);
+
+
+ myFile = u_fopen(STANDARD_TEST_FILE, "r", "en_US_POSIX", "UTF-8");
+ if (!myFile) {
+ log_err("Test file can't be opened\n");
+ return;
+ }
+ u_fgets(uBuffer, sizeof(uBuffer)/sizeof(*uBuffer), myFile);
+ u_uastrcpy(uBuffer2, expectedResult);
+ if (u_strcmp(uBuffer, uBuffer2) != 0) {
+ log_err("Got two different results for \"%s\" expected \"%s\"\n", format, expectedResult);
+ }
+ u_fclose(myFile);
+
+
+ myFile = u_fopen(STANDARD_TEST_FILE, "w", "en_US_POSIX", NULL);
+ if (!myFile) {
+ log_err("Test file can't be opened\n");
+ return;
+ }
+ u_uastrcpy(uBuffer, format);
+
+ va_start(ap, format);
+ count = u_vfprintf_u(myFile, uBuffer, ap);
+ va_end(ap);
+
+ u_fclose(myFile);
+
+
+ myFile = u_fopen(STANDARD_TEST_FILE, "r", "en_US_POSIX", NULL);
+ if (!myFile) {
+ log_err("Test file can't be opened\n");
+ return;
+ }
+ u_fgets(uBuffer, sizeof(uBuffer)/sizeof(*uBuffer), myFile);
+ u_uastrcpy(uBuffer2, expectedResult);
+ if (u_strcmp(uBuffer, uBuffer2) != 0) {
+ log_err("Got two different results for \"%s\" expected \"%s\"\n", format, expectedResult);
+ }
+ u_fclose(myFile);
+}
+
+static void TestVargs(void) {
+ Test_u_vfprintf("8 9 a B 8.9", "%d %u %x %X %.1f", 8, 9, 10, 11, 8.9);
+}
+#endif
+
+static void TestUnicodeFormat(void)
+{
+#if !UCONFIG_NO_FORMATTING
+ /* Make sure that invariant conversion doesn't happen on the _u formats. */
+ UChar myUString[256];
+ UFILE *myFile;
+ static const UChar TEST_STR[] = { 0x03BC, 0x0025, 0x0024, 0};
+ static const UChar PERCENT_S[] = { 0x03BC, 0x0025, 0x0053, 0};
+
+ u_memset(myUString, 0x2a, sizeof(myUString)/sizeof(*myUString));
+
+ myFile = u_fopen(STANDARD_TEST_FILE, "w", NULL, "UTF-8");
+ if (!myFile) {
+ log_err("Test file can't be opened\n");
+ return;
+ }
+ u_fprintf_u(myFile, PERCENT_S, TEST_STR);
+ u_fclose(myFile);
+
+ myFile = u_fopen(STANDARD_TEST_FILE, "r", NULL, "UTF-8");
+ if (!myFile) {
+ log_err("Test file can't be opened\n");
+ return;
+ }
+ u_fscanf_u(myFile, PERCENT_S, myUString);
+ u_fclose(myFile);
+ if (u_strcmp(TEST_STR, myUString) != 0) {
+ log_err("u_fscanf_u doesn't work.\n");
+ }
+#endif
+}
+
+
+U_CFUNC void
+addFileTest(TestNode** root) {
+#if !UCONFIG_NO_FORMATTING
+ addTest(root, &TestFile, "file/TestFile");
+#endif
+ addTest(root, &StdinBuffering, "file/StdinBuffering");
+ addTest(root, &TestfgetsBuffers, "file/TestfgetsBuffers");
+ addTest(root, &TestFileReadBuffering, "file/TestFileReadBuffering");
+ addTest(root, &TestfgetsLineCount, "file/TestfgetsLineCount");
+ addTest(root, &TestfgetsNewLineHandling, "file/TestfgetsNewLineHandling");
+ addTest(root, &TestfgetsNewLineCount, "file/TestfgetsNewLineCount");
+ addTest(root, &TestFgetsLineBuffering, "file/TestFgetsLineBuffering");
+ addTest(root, &TestCodepage, "file/TestCodepage");
+#if !UCONFIG_NO_FORMATTING
+ addTest(root, &TestCodepageAndLocale, "file/TestCodepageAndLocale");
+ addTest(root, &TestFprintfFormat, "file/TestFprintfFormat");
+ addTest(root, &TestFScanset, "file/TestFScanset");
+ addTest(root, &TestFilePrintCompatibility, "file/TestFilePrintCompatibility");
+ addTest(root, &TestBadScanfFormat, "file/TestBadScanfFormat");
+ addTest(root, &TestVargs, "file/TestVargs");
+ addTest(root, &TestUnicodeFormat, "file/TestUnicodeFormat");
+#endif
+}
Property changes on: trunk/source/test/iotest/filetst.c
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/source/test/iotest/iotest.cpp
===================================================================
--- trunk/source/test/iotest/iotest.cpp 2006-12-21 11:09:23 UTC (rev 127)
+++ trunk/source/test/iotest/iotest.cpp 2006-12-21 11:10:34 UTC (rev 128)
@@ -1,836 +1,836 @@
-/*
-**********************************************************************
-* Copyright (C) 2002-2006, International Business Machines
-* Corporation and others. All Rights Reserved.
-**********************************************************************
-* file name: iotest.cpp
-* encoding: US-ASCII
-* tab size: 8 (not used)
-* indentation:4
-*
-* created on: 2002feb21
-* created by: George Rhoten
-*/
-
-
-#include "unicode/ustdio.h"
-#include "unicode/uclean.h"
-
-#include "unicode/ucnv.h"
-#include "unicode/uchar.h"
-#include "unicode/unistr.h"
-#include "unicode/ustring.h"
-#include "ustr_cnv.h"
-#include "iotest.h"
-#include "unicode/tstdtmod.h"
-#include "putilimp.h"
-
-#include <string.h>
-#include <stdlib.h>
-
-class DataDrivenLogger : public TestLog {
- static const char* fgDataDir;
- static char *fgTestDataPath;
-
-public:
- static void cleanUp() {
- if (fgTestDataPath) {
- free(fgTestDataPath);
- fgTestDataPath = NULL;
- }
- }
- virtual void errln( const UnicodeString &message ) {
- char buffer[4000];
- message.extract(0, message.length(), buffer, sizeof(buffer));
- buffer[3999] = 0; /* NULL terminate */
- log_err(buffer);
- }
-
- static const char * pathToDataDirectory(void)
- {
-
- if(fgDataDir != NULL) {
- return fgDataDir;
- }
-
- /* U_TOPSRCDIR is set by the makefiles on UNIXes when building cintltst and intltst
- // to point to the top of the build hierarchy, which may or
- // may not be the same as the source directory, depending on
- // the configure options used. At any rate,
- // set the data path to the built data from this directory.
- // The value is complete with quotes, so it can be used
- // as-is as a string constant.
- */
- #if defined (U_TOPSRCDIR)
- {
- fgDataDir = U_TOPSRCDIR U_FILE_SEP_STRING "data" U_FILE_SEP_STRING;
- }
- #else
-
- /* On Windows, the file name obtained from __FILE__ includes a full path.
- * This file is "wherever\icu\source\test\cintltst\cintltst.c"
- * Change to "wherever\icu\source\data"
- */
- {
- static char p[sizeof(__FILE__) + 10];
- char *pBackSlash;
- int i;
-
- strcpy(p, __FILE__);
- /* We want to back over three '\' chars. */
- /* Only Windows should end up here, so looking for '\' is safe. */
- for (i=1; i<=3; i++) {
- pBackSlash = strrchr(p, U_FILE_SEP_CHAR);
- if (pBackSlash != NULL) {
- *pBackSlash = 0; /* Truncate the string at the '\' */
- }
- }
-
- if (pBackSlash != NULL) {
- /* We found and truncated three names from the path.
- * Now append "source\data" and set the environment
- */
- strcpy(pBackSlash, U_FILE_SEP_STRING "data" U_FILE_SEP_STRING );
- fgDataDir = p;
- }
- else {
- /* __FILE__ on MSVC7 does not contain the directory */
- FILE *file = fopen(".."U_FILE_SEP_STRING".."U_FILE_SEP_STRING "data" U_FILE_SEP_STRING "Makefile.in", "r");
- if (file) {
- fclose(file);
- fgDataDir = ".."U_FILE_SEP_STRING".."U_FILE_SEP_STRING "data" U_FILE_SEP_STRING;
- }
- else {
- fgDataDir = ".."U_FILE_SEP_STRING".."U_FILE_SEP_STRING".."U_FILE_SEP_STRING "data" U_FILE_SEP_STRING;
- }
- }
- }
- #endif
-
- return fgDataDir;
-
- }
-
- static const char* loadTestData(UErrorCode& err){
- if( fgTestDataPath == NULL){
- const char* directory=NULL;
- UResourceBundle* test =NULL;
- char* tdpath=NULL;
- const char* tdrelativepath;
-
-#if defined (U_TOPBUILDDIR)
- tdrelativepath = "test"U_FILE_SEP_STRING"testdata"U_FILE_SEP_STRING"out"U_FILE_SEP_STRING;
- directory = U_TOPBUILDDIR;
-#else
- tdrelativepath = ".."U_FILE_SEP_STRING"test"U_FILE_SEP_STRING"testdata"U_FILE_SEP_STRING"out"U_FILE_SEP_STRING;
- directory = pathToDataDirectory();
-#endif
-
- tdpath = (char*) malloc(sizeof(char) *(( strlen(directory) * strlen(tdrelativepath)) + 100));
-
-
- /* u_getDataDirectory shoul return \source\data ... set the
- * directory to ..\source\data\..\test\testdata\out\testdata
- */
- strcpy(tdpath, directory);
- strcat(tdpath, tdrelativepath);
- strcat(tdpath,"testdata");
-
- test=ures_open(tdpath, "testtypes", &err);
-
- if(U_FAILURE(err)){
- err = U_FILE_ACCESS_ERROR;
- log_err("Could not load testtypes.res in testdata bundle with path %s - %s\n", tdpath, u_errorName(err));
- return "";
- }
- ures_close(test);
- fgTestDataPath = tdpath;
- }
- return fgTestDataPath;
- }
-
- virtual const char* getTestDataPath(UErrorCode& err) {
- return loadTestData(err);
- }
-};
-
-const char* DataDrivenLogger::fgDataDir = NULL;
-char* DataDrivenLogger::fgTestDataPath = NULL;
-
-static int64_t
-uto64(const UChar *buffer)
-{
- int64_t result = 0;
- /* iterate through buffer */
- while(*buffer) {
- /* read the next digit */
- result *= 16;
- if (!u_isxdigit(*buffer)) {
- log_err("\\u%04X is not a valid hex digit for this test\n", (UChar)*buffer);
- }
- result += *buffer - 0x0030 - (*buffer >= 0x0041 ? (*buffer >= 0x0061 ? 39 : 7) : 0);
- buffer++;
- }
- return result;
-}
-
-
-U_CDECL_BEGIN
-static void U_CALLCONV DataDrivenPrintf(void)
-{
-#if !UCONFIG_NO_FORMATTING
- UErrorCode errorCode;
- TestDataModule *dataModule;
- TestData *testData;
- const DataMap *testCase;
- DataDrivenLogger logger;
- UChar uBuffer[512];
- char cBuffer[512];
- char cFormat[sizeof(cBuffer)];
- char cExpected[sizeof(cBuffer)];
- UnicodeString tempStr;
- UChar format[512];
- UChar expectedResult[512];
- UChar argument[512];
- int32_t i;
- int8_t i8;
- int16_t i16;
- int32_t i32;
- int64_t i64;
- double dbl;
- int32_t uBufferLenReturned;
-
- const char *fileLocale = "en_US_POSIX";
- int32_t uFileBufferLenReturned;
- UFILE *testFile;
-
- errorCode=U_ZERO_ERROR;
- dataModule=TestDataModule::getTestDataModule("icuio", logger, errorCode);
- if(U_SUCCESS(errorCode)) {
- testData=dataModule->createTestData("printf", errorCode);
- if(U_SUCCESS(errorCode)) {
- for(i=0; testData->nextCase(testCase, errorCode); ++i) {
- if(U_FAILURE(errorCode)) {
- log_err("error retrieving icuio/printf test case %d - %s\n",
- i, u_errorName(errorCode));
- errorCode=U_ZERO_ERROR;
- continue;
- }
- testFile = u_fopen(STANDARD_TEST_FILE, "w", fileLocale, "UTF-8");
- if (!testFile) {
- log_err("Can't open test file - %s\n",
- STANDARD_TEST_FILE);
- continue;
- }
- u_memset(uBuffer, 0x2A, sizeof(uBuffer)/sizeof(uBuffer[0]));
- uBuffer[sizeof(uBuffer)/sizeof(uBuffer[0])-1] = 0;
- tempStr=testCase->getString("format", errorCode);
- tempStr.extract(format, sizeof(format)/sizeof(format[0]), errorCode);
- tempStr=testCase->getString("result", errorCode);
- tempStr.extract(expectedResult, sizeof(expectedResult)/sizeof(expectedResult[0]), errorCode);
- tempStr=testCase->getString("argument", errorCode);
- tempStr.extract(argument, sizeof(argument)/sizeof(argument[0]), errorCode);
- u_austrncpy(cBuffer, format, sizeof(cBuffer));
- if(U_FAILURE(errorCode)) {
- log_err("error retrieving icuio/printf test case %d - %s\n",
- i, u_errorName(errorCode));
- errorCode=U_ZERO_ERROR;
- continue;
- }
- log_verbose("Test %d: format=\"%s\"\n", i, cBuffer);
- switch (testCase->getString("argumentType", errorCode)[0]) {
- case 0x64: // 'd' double
- dbl = atof(u_austrcpy(cBuffer, argument));
- uBufferLenReturned = u_sprintf_u(uBuffer, format, dbl);
- uFileBufferLenReturned = u_fprintf_u(testFile, format, dbl);
- break;
- case 0x31: // '1' int8_t
- i8 = (int8_t)uto64(argument);
- uBufferLenReturned = u_sprintf_u(uBuffer, format, i8);
- uFileBufferLenReturned = u_fprintf_u(testFile, format, i8);
- break;
- case 0x32: // '2' int16_t
- i16 = (int16_t)uto64(argument);
- uBufferLenReturned = u_sprintf_u(uBuffer, format, i16);
- uFileBufferLenReturned = u_fprintf_u(testFile, format, i16);
- break;
- case 0x34: // '4' int32_t
- i32 = (int32_t)uto64(argument);
- uBufferLenReturned = u_sprintf_u(uBuffer, format, i32);
- uFileBufferLenReturned = u_fprintf_u(testFile, format, i32);
- break;
- case 0x38: // '8' int64_t
- i64 = uto64(argument);
- uBufferLenReturned = u_sprintf_u(uBuffer, format, i64);
- uFileBufferLenReturned = u_fprintf_u(testFile, format, i64);
- break;
- case 0x73: // 's' char *
- u_austrncpy(cBuffer, argument, sizeof(cBuffer));
- uBufferLenReturned = u_sprintf_u(uBuffer, format, cBuffer);
- uFileBufferLenReturned = u_fprintf_u(testFile, format, cBuffer);
- break;
- case 0x53: // 'S' UChar *
- uBufferLenReturned = u_sprintf_u(uBuffer, format, argument);
- uFileBufferLenReturned = u_fprintf_u(testFile, format, argument);
- break;
- default:
- uBufferLenReturned = 0;
- uFileBufferLenReturned = 0;
- log_err("Unknown type %c for test %d\n", testCase->getString("argumentType", errorCode)[0], i);
- }
- if (u_strcmp(uBuffer, expectedResult) != 0) {
- u_austrncpy(cBuffer, uBuffer, sizeof(cBuffer));
- u_austrncpy(cFormat, format, sizeof(cFormat));
- u_austrncpy(cExpected, expectedResult, sizeof(cExpected));
- cBuffer[sizeof(cBuffer)-1] = 0;
- log_err("FAILURE string test case %d \"%s\" - Got: \"%s\" Expected: \"%s\"\n",
- i, cFormat, cBuffer, cExpected);
- }
- if (uBuffer[uBufferLenReturned-1] == 0
- || uBuffer[uBufferLenReturned] != 0
- || uBuffer[uBufferLenReturned+1] != 0x2A
- || uBuffer[uBufferLenReturned+2] != 0x2A)
- {
- u_austrncpy(cBuffer, uBuffer, sizeof(cBuffer));
- cBuffer[sizeof(cBuffer)-1] = 0;
- log_err("FAILURE test case %d - \"%s\" wrong amount of characters was written. Got %d.\n",
- i, cBuffer, uBufferLenReturned);
- }
- u_fclose(testFile);
- testFile = u_fopen(STANDARD_TEST_FILE, "r", fileLocale, "UTF-8");
- if (!testFile) {
- log_err("Can't open test file - %s\n",
- STANDARD_TEST_FILE);
- }
- uBuffer[0]=0;
- u_fgets(uBuffer, sizeof(uBuffer)/sizeof(uBuffer[0]), testFile);
- if (u_strcmp(uBuffer, expectedResult) != 0) {
- u_austrncpy(cBuffer, uBuffer, sizeof(cBuffer));
- u_austrncpy(cFormat, format, sizeof(cFormat));
- u_austrncpy(cExpected, expectedResult, sizeof(cExpected));
- cBuffer[sizeof(cBuffer)-1] = 0;
- log_err("FAILURE file test case %d \"%s\" - Got: \"%s\" Expected: \"%s\"\n",
- i, cFormat, cBuffer, cExpected);
- }
- if (uFileBufferLenReturned != uBufferLenReturned)
- {
- u_austrncpy(cBuffer, uBuffer, sizeof(cBuffer));
- cBuffer[sizeof(cBuffer)-1] = 0;
- log_err("FAILURE uFileBufferLenReturned(%d) != uBufferLenReturned(%d)\n",
- uFileBufferLenReturned, uBufferLenReturned);
- }
-
- if(U_FAILURE(errorCode)) {
- log_err("error running icuio/printf test case %d - %s\n",
- i, u_errorName(errorCode));
- errorCode=U_ZERO_ERROR;
- continue;
- }
- u_fclose(testFile);
- }
- delete testData;
- }
- delete dataModule;
- }
- else {
- log_err("Failed: could not load test icuio data\n");
- }
-#endif
-}
-U_CDECL_END
-
-U_CDECL_BEGIN
-static void U_CALLCONV DataDrivenScanf(void)
-{
-#if !UCONFIG_NO_FORMATTING
- UErrorCode errorCode;
- TestDataModule *dataModule;
- TestData *testData;
- const DataMap *testCase;
- DataDrivenLogger logger;
- UChar uBuffer[512];
- char cBuffer[512];
- char cExpected[sizeof(cBuffer)];
- UnicodeString tempStr;
- UChar format[512];
- UChar expectedResult[512];
- UChar argument[512];
- int32_t i;
- int8_t i8, expected8;
- int16_t i16, expected16;
- int32_t i32, expected32;
- int64_t i64, expected64;
- double dbl, expectedDbl;
- volatile float flt, expectedFlt; // Use volatile in order to get around an Intel compiler issue.
- int32_t uBufferLenReturned;
-
- //const char *fileLocale = "en_US_POSIX";
- //int32_t uFileBufferLenReturned;
- //UFILE *testFile;
-
- errorCode=U_ZERO_ERROR;
- dataModule=TestDataModule::getTestDataModule("icuio", logger, errorCode);
- if(U_SUCCESS(errorCode)) {
- testData=dataModule->createTestData("scanf", errorCode);
- if(U_SUCCESS(errorCode)) {
- for(i=0; testData->nextCase(testCase, errorCode); ++i) {
- if(U_FAILURE(errorCode)) {
- log_err("error retrieving icuio/printf test case %d - %s\n",
- i, u_errorName(errorCode));
- errorCode=U_ZERO_ERROR;
- continue;
- }
-/* testFile = u_fopen(STANDARD_TEST_FILE, "w", fileLocale, "UTF-8");
- if (!testFile) {
- log_err("Can't open test file - %s\n",
- STANDARD_TEST_FILE);
- }*/
- u_memset(uBuffer, 0x2A, sizeof(uBuffer)/sizeof(uBuffer[0]));
- uBuffer[sizeof(uBuffer)/sizeof(uBuffer[0])-1] = 0;
- tempStr=testCase->getString("format", errorCode);
- tempStr.extract(format, sizeof(format)/sizeof(format[0]), errorCode);
- tempStr=testCase->getString("result", errorCode);
- tempStr.extract(expectedResult, sizeof(expectedResult)/sizeof(expectedResult[0]), errorCode);
- tempStr=testCase->getString("argument", errorCode);
- tempStr.extract(argument, sizeof(argument)/sizeof(argument[0]), errorCode);
- u_austrncpy(cBuffer, format, sizeof(cBuffer));
- if(U_FAILURE(errorCode)) {
- log_err("error retrieving icuio/printf test case %d - %s\n",
- i, u_errorName(errorCode));
- errorCode=U_ZERO_ERROR;
- continue;
- }
- log_verbose("Test %d: format=\"%s\"\n", i, cBuffer);
- switch (testCase->getString("argumentType", errorCode)[0]) {
- case 0x64: // 'd' double
- expectedDbl = atof(u_austrcpy(cBuffer, expectedResult));
- uBufferLenReturned = u_sscanf_u(argument, format, &dbl);
- //uFileBufferLenReturned = u_fscanf_u(testFile, format, dbl);
- if (dbl != expectedDbl) {
- log_err("error in scanf test case[%d] Got: %f Exp: %f\n",
- i, dbl, expectedDbl);
- }
- break;
- case 0x66: // 'f' float
- expectedFlt = (float)atof(u_austrcpy(cBuffer, expectedResult));
- uBufferLenReturned = u_sscanf_u(argument, format, &flt);
- //uFileBufferLenReturned = u_fscanf_u(testFile, format, flt);
- if (flt != expectedFlt) {
- log_err("error in scanf test case[%d] Got: %f Exp: %f\n",
- i, flt, expectedFlt);
- }
- break;
- case 0x31: // '1' int8_t
- expected8 = (int8_t)uto64(expectedResult);
- uBufferLenReturned = u_sscanf_u(argument, format, &i8);
- //uFileBufferLenReturned = u_fscanf_u(testFile, format, i8);
- if (i8 != expected8) {
- log_err("error in scanf test case[%d] Got: %02X Exp: %02X\n",
- i, i8, expected8);
- }
- break;
- case 0x32: // '2' int16_t
- expected16 = (int16_t)uto64(expectedResult);
- uBufferLenReturned = u_sscanf_u(argument, format, &i16);
- //uFileBufferLenReturned = u_fscanf_u(testFile, format, i16);
- if (i16 != expected16) {
- log_err("error in scanf test case[%d] Got: %04X Exp: %04X\n",
- i, i16, expected16);
- }
- break;
- case 0x34: // '4' int32_t
- expected32 = (int32_t)uto64(expectedResult);
- uBufferLenReturned = u_sscanf_u(argument, format, &i32);
- //uFileBufferLenReturned = u_fscanf_u(testFile, format, i32);
- if (i32 != expected32) {
- log_err("error in scanf test case[%d] Got: %08X Exp: %08X\n",
- i, i32, expected32);
- }
- break;
- case 0x38: // '8' int64_t
- expected64 = uto64(expectedResult);
- uBufferLenReturned = u_sscanf_u(argument, format, &i64);
- //uFileBufferLenReturned = u_fscanf_u(testFile, format, i64);
- if (i64 != expected64) {
- log_err("error in scanf 64-bit. Test case = %d\n", i);
- }
- break;
- case 0x73: // 's' char *
- u_austrcpy(cExpected, expectedResult);
- uBufferLenReturned = u_sscanf_u(argument, format, cBuffer);
- //uFileBufferLenReturned = u_fscanf_u(testFile, format, cBuffer);
- if (strcmp(cBuffer, cExpected) != 0) {
- log_err("error in scanf char * string. Got \"%s\" Expected \"%s\". Test case = %d\n", cBuffer, cExpected, i);
- }
- break;
- case 0x53: // 'S' UChar *
- uBufferLenReturned = u_sscanf_u(argument, format, uBuffer);
- //uFileBufferLenReturned = u_fscanf_u(testFile, format, argument);
- if (u_strcmp(uBuffer, expectedResult) != 0) {
- u_austrcpy(cExpected, format);
- u_austrcpy(cBuffer, uBuffer);
- log_err("error in scanf UChar * string %s Got: \"%s\". Test case = %d\n", cExpected, cBuffer, i);
- }
- break;
- default:
- uBufferLenReturned = 0;
- //uFileBufferLenReturned = 0;
- log_err("Unknown type %c for test %d\n", testCase->getString("argumentType", errorCode)[0], i);
- }
- if (uBufferLenReturned != 1) {
- log_err("error scanf converted %d arguments. Test case = %d\n", uBufferLenReturned, i);
- }
-/* if (u_strcmp(uBuffer, expectedResult) != 0) {
- u_austrncpy(cBuffer, uBuffer, sizeof(cBuffer));
- u_austrncpy(cFormat, format, sizeof(cFormat));
- u_austrncpy(cExpected, expectedResult, sizeof(cExpected));
- cBuffer[sizeof(cBuffer)-1] = 0;
- log_err("FAILURE string test case %d \"%s\" - Got: \"%s\" Expected: \"%s\"\n",
- i, cFormat, cBuffer, cExpected);
- }
- if (uBuffer[uBufferLenReturned-1] == 0
- || uBuffer[uBufferLenReturned] != 0
- || uBuffer[uBufferLenReturned+1] != 0x2A
- || uBuffer[uBufferLenReturned+2] != 0x2A)
- {
- u_austrncpy(cBuffer, uBuffer, sizeof(cBuffer));
- cBuffer[sizeof(cBuffer)-1] = 0;
- log_err("FAILURE test case %d - \"%s\" wrong amount of characters was written. Got %d.\n",
- i, cBuffer, uBufferLenReturned);
- }*/
-/* u_fclose(testFile);
- testFile = u_fopen(STANDARD_TEST_FILE, "r", fileLocale, "UTF-8");
- if (!testFile) {
- log_err("Can't open test file - %s\n",
- STANDARD_TEST_FILE);
- }
- uBuffer[0];
- u_fgets(uBuffer, sizeof(uBuffer)/sizeof(uBuffer[0]), testFile);
- if (u_strcmp(uBuffer, expectedResult) != 0) {
- u_austrncpy(cBuffer, uBuffer, sizeof(cBuffer));
- u_austrncpy(cFormat, format, sizeof(cFormat));
- u_austrncpy(cExpected, expectedResult, sizeof(cExpected));
- cBuffer[sizeof(cBuffer)-1] = 0;
- log_err("FAILURE file test case %d \"%s\" - Got: \"%s\" Expected: \"%s\"\n",
- i, cFormat, cBuffer, cExpected);
- }
- if (uFileBufferLenReturned != uBufferLenReturned)
- {
- u_austrncpy(cBuffer, uBuffer, sizeof(cBuffer));
- cBuffer[sizeof(cBuffer)-1] = 0;
- log_err("FAILURE uFileBufferLenReturned(%d) != uBufferLenReturned(%d)\n",
- uFileBufferLenReturned, uBufferLenReturned);
- }
-*/
- if(U_FAILURE(errorCode)) {
- log_err("error running icuio/printf test case %d - %s\n",
- i, u_errorName(errorCode));
- errorCode=U_ZERO_ERROR;
- continue;
- }
-// u_fclose(testFile);
- }
- delete testData;
- }
- delete dataModule;
- }
- else {
- log_err("Failed: could not load test icuio data\n");
- }
-#endif
-}
-U_CDECL_END
-
-U_CDECL_BEGIN
-static void U_CALLCONV DataDrivenPrintfPrecision(void)
-{
-#if !UCONFIG_NO_FORMATTING
- UErrorCode errorCode;
- TestDataModule *dataModule;
- TestData *testData;
- const DataMap *testCase;
- DataDrivenLogger logger;
- UChar uBuffer[512];
- char cBuffer[512];
- char cFormat[sizeof(cBuffer)];
- char cExpected[sizeof(cBuffer)];
- UnicodeString tempStr;
- UChar format[512];
- UChar expectedResult[512];
- UChar argument[512];
- int32_t precision;
- int32_t i;
- int8_t i8;
- int16_t i16;
- int32_t i32;
- int64_t i64;
- double dbl;
- int32_t uBufferLenReturned;
-
- errorCode=U_ZERO_ERROR;
- dataModule=TestDataModule::getTestDataModule("icuio", logger, errorCode);
- if(U_SUCCESS(errorCode)) {
- testData=dataModule->createTestData("printfPrecision", errorCode);
- if(U_SUCCESS(errorCode)) {
- for(i=0; testData->nextCase(testCase, errorCode); ++i) {
- if(U_FAILURE(errorCode)) {
- log_err("error retrieving icuio/printf test case %d - %s\n",
- i, u_errorName(errorCode));
- errorCode=U_ZERO_ERROR;
- continue;
- }
- u_memset(uBuffer, 0x2A, sizeof(uBuffer)/sizeof(uBuffer[0]));
- uBuffer[sizeof(uBuffer)/sizeof(uBuffer[0])-1] = 0;
- tempStr=testCase->getString("format", errorCode);
- tempStr.extract(format, sizeof(format)/sizeof(format[0]), errorCode);
- tempStr=testCase->getString("result", errorCode);
- tempStr.extract(expectedResult, sizeof(expectedResult)/sizeof(expectedResult[0]), errorCode);
- tempStr=testCase->getString("argument", errorCode);
- tempStr.extract(argument, sizeof(argument)/sizeof(argument[0]), errorCode);
- precision=testCase->getInt28("precision", errorCode);
- u_austrncpy(cBuffer, format, sizeof(cBuffer));
- if(U_FAILURE(errorCode)) {
- log_err("error retrieving icuio/printf test case %d - %s\n",
- i, u_errorName(errorCode));
- errorCode=U_ZERO_ERROR;
- continue;
- }
- log_verbose("Test %d: format=\"%s\"\n", i, cBuffer);
- switch (testCase->getString("argumentType", errorCode)[0]) {
- case 0x64: // 'd' double
- dbl = atof(u_austrcpy(cBuffer, argument));
- uBufferLenReturned = u_sprintf_u(uBuffer, format, precision, dbl);
- break;
- case 0x31: // '1' int8_t
- i8 = (int8_t)uto64(argument);
- uBufferLenReturned = u_sprintf_u(uBuffer, format, precision, i8);
- break;
- case 0x32: // '2' int16_t
- i16 = (int16_t)uto64(argument);
- uBufferLenReturned = u_sprintf_u(uBuffer, format, precision, i16);
- break;
- case 0x34: // '4' int32_t
- i32 = (int32_t)uto64(argument);
- uBufferLenReturned = u_sprintf_u(uBuffer, format, precision, i32);
- break;
- case 0x38: // '8' int64_t
- i64 = uto64(argument);
- uBufferLenReturned = u_sprintf_u(uBuffer, format, precision, i64);
- break;
- case 0x73: // 's' char *
- u_austrncpy(cBuffer, uBuffer, sizeof(cBuffer));
- uBufferLenReturned = u_sprintf_u(uBuffer, format, precision, cBuffer);
- break;
- case 0x53: // 'S' UChar *
- uBufferLenReturned = u_sprintf_u(uBuffer, format, precision, argument);
- break;
- default:
- uBufferLenReturned = 0;
- log_err("Unknown type %c for test %d\n", testCase->getString("argumentType", errorCode)[0], i);
- }
- if (u_strcmp(uBuffer, expectedResult) != 0) {
- u_austrncpy(cBuffer, uBuffer, sizeof(cBuffer));
- u_austrncpy(cFormat, format, sizeof(cFormat));
- u_austrncpy(cExpected, expectedResult, sizeof(cExpected));
- cBuffer[sizeof(cBuffer)-1] = 0;
- log_err("FAILURE test case %d \"%s\" - Got: \"%s\" Expected: \"%s\"\n",
- i, cFormat, cBuffer, cExpected);
- }
- if (uBuffer[uBufferLenReturned-1] == 0
- || uBuffer[uBufferLenReturned] != 0
- || uBuffer[uBufferLenReturned+1] != 0x2A
- || uBuffer[uBufferLenReturned+2] != 0x2A)
- {
- u_austrncpy(cBuffer, uBuffer, sizeof(cBuffer));
- cBuffer[sizeof(cBuffer)-1] = 0;
- log_err("FAILURE test case %d - \"%s\" wrong amount of characters was written. Got %d.\n",
- i, cBuffer, uBufferLenReturned);
- }
- if(U_FAILURE(errorCode)) {
- log_err("error running icuio/printf test case %d - %s\n",
- i, u_errorName(errorCode));
- errorCode=U_ZERO_ERROR;
- continue;
- }
- }
- delete testData;
- }
- delete dataModule;
- }
- else {
- log_err("Failed: could not load test icuio data\n");
- }
-#endif
-}
-U_CDECL_END
-
-static void addAllTests(TestNode** root) {
- addFileTest(root);
- addStringTest(root);
- addTranslitTest(root);
-
-#if !UCONFIG_NO_FORMATTING
- addTest(root, &DataDrivenPrintf, "datadriv/DataDrivenPrintf");
- addTest(root, &DataDrivenPrintfPrecision, "datadriv/DataDrivenPrintfPrecision");
- addTest(root, &DataDrivenScanf, "datadriv/DataDrivenScanf");
-#endif
- addStreamTests(root);
-}
-
-/* returns the path to icu/source/data/out */
-static const char *ctest_dataOutDir()
-{
- static const char *dataOutDir = NULL;
-
- if(dataOutDir) {
- return dataOutDir;
- }
-
- /* U_TOPBUILDDIR is set by the makefiles on UNIXes when building cintltst and intltst
- // to point to the top of the build hierarchy, which may or
- // may not be the same as the source directory, depending on
- // the configure options used. At any rate,
- // set the data path to the built data from this directory.
- // The value is complete with quotes, so it can be used
- // as-is as a string constant.
- */
-#if defined (U_TOPBUILDDIR)
- {
- dataOutDir = U_TOPBUILDDIR "data"U_FILE_SEP_STRING"out"U_FILE_SEP_STRING;
- }
-#else
-
- /* On Windows, the file name obtained from __FILE__ includes a full path.
- * This file is "wherever\icu\source\test\cintltst\cintltst.c"
- * Change to "wherever\icu\source\data"
- */
- {
- static char p[sizeof(__FILE__) + 20];
- char *pBackSlash;
- int i;
-
- strcpy(p, __FILE__);
- /* We want to back over three '\' chars. */
- /* Only Windows should end up here, so looking for '\' is safe. */
- for (i=1; i<=3; i++) {
- pBackSlash = strrchr(p, U_FILE_SEP_CHAR);
- if (pBackSlash != NULL) {
- *pBackSlash = 0; /* Truncate the string at the '\' */
- }
- }
-
- if (pBackSlash != NULL) {
- /* We found and truncated three names from the path.
- * Now append "source\data" and set the environment
- */
- strcpy(pBackSlash, U_FILE_SEP_STRING "data" U_FILE_SEP_STRING "out" U_FILE_SEP_STRING);
- dataOutDir = p;
- }
- else {
- /* __FILE__ on MSVC7 does not contain the directory */
- FILE *file = fopen(".."U_FILE_SEP_STRING".."U_FILE_SEP_STRING "data" U_FILE_SEP_STRING "Makefile.in", "r");
- if (file) {
- fclose(file);
- dataOutDir = ".."U_FILE_SEP_STRING".."U_FILE_SEP_STRING "data" U_FILE_SEP_STRING "out" U_FILE_SEP_STRING;
- }
- else {
- dataOutDir = ".."U_FILE_SEP_STRING".."U_FILE_SEP_STRING".."U_FILE_SEP_STRING "data" U_FILE_SEP_STRING "out" U_FILE_SEP_STRING;
- }
- }
- }
-#endif
-
- return dataOutDir;
-}
-
-/* ctest_setICU_DATA - if the ICU_DATA environment variable is not already
- * set, try to deduce the directory in which ICU was built,
- * and set ICU_DATA to "icu/source/data" in that location.
- * The intent is to allow the tests to have a good chance
- * of running without requiring that the user manually set
- * ICU_DATA. Common data isn't a problem, since it is
- * picked up via a static (build time) reference, but the
- * tests dynamically load some data.
- */
-static void ctest_setICU_DATA() {
-
- /* No location for the data dir was identifiable.
- * Add other fallbacks for the test data location here if the need arises
- */
- if (getenv("ICU_DATA") == NULL) {
- /* If ICU_DATA isn't set, set it to the usual location */
- u_setDataDirectory(ctest_dataOutDir());
- }
-}
-
-int main(int argc, char* argv[])
-{
- int32_t nerrors = 0;
- TestNode *root = NULL;
- UErrorCode errorCode = U_ZERO_ERROR;
- UDate startTime, endTime;
- int32_t diffTime;
-
- startTime = uprv_getUTCtime();
-
- /* Check whether ICU will initialize without forcing the build data directory into
- * the ICU_DATA path. Success here means either the data dll contains data, or that
- * this test program was run with ICU_DATA set externally. Failure of this check
- * is normal when ICU data is not packaged into a shared library.
- *
- * Whether or not this test succeeds, we want to cleanup and reinitialize
- * with a data path so that data loading from individual files can be tested.
- */
- u_init(&errorCode);
- if (U_FAILURE(errorCode)) {
- fprintf(stderr,
- "#### Note: ICU Init without build-specific setDataDirectory() failed.\n");
- }
- u_cleanup();
- errorCode = U_ZERO_ERROR;
-
- /* Initialize ICU */
- ctest_setICU_DATA(); /* u_setDataDirectory() must happen Before u_init() */
- u_init(&errorCode);
- if (U_FAILURE(errorCode)) {
- fprintf(stderr,
- "#### ERROR! %s: u_init() failed with status = \"%s\".\n"
- "*** Check the ICU_DATA environment variable and \n"
- "*** check that the data files are present.\n", argv[0], u_errorName(errorCode));
- return 1;
- }
-
- fprintf(stdout, "Default charset for this run is %s\n", ucnv_getDefaultName());
-
- addAllTests(&root);
- nerrors = processArgs(root, argc, argv);
-
-#if 1
- {
- FILE* fileToRemove = fopen(STANDARD_TEST_FILE, "r");
- /* This should delete any temporary files. */
- if (fileToRemove) {
- fclose(fileToRemove);
- if (remove(STANDARD_TEST_FILE) != 0) {
- /* Maybe someone didn't close the file correctly. */
- fprintf(stderr, "FAIL: Could not delete %s\n", STANDARD_TEST_FILE);
- nerrors += 1;
- }
- }
- }
-#endif
-
- cleanUpTestTree(root);
- DataDrivenLogger::cleanUp();
- u_cleanup();
-
- endTime = uprv_getUTCtime();
- diffTime = (int32_t)(endTime - startTime);
- printf("Elapsed Time: %02d:%02d:%02d.%03d\n",
- (int)((diffTime%U_MILLIS_PER_DAY)/U_MILLIS_PER_HOUR),
- (int)((diffTime%U_MILLIS_PER_HOUR)/U_MILLIS_PER_MINUTE),
- (int)((diffTime%U_MILLIS_PER_MINUTE)/U_MILLIS_PER_SECOND),
- (int)(diffTime%U_MILLIS_PER_SECOND));
-
- return nerrors;
-}
+/*
+**********************************************************************
+* Copyright (C) 2002-2006, International Business Machines
+* Corporation and others. All Rights Reserved.
+**********************************************************************
+* file name: iotest.cpp
+* encoding: US-ASCII
+* tab size: 8 (not used)
+* indentation:4
+*
+* created on: 2002feb21
+* created by: George Rhoten
+*/
+
+
+#include "unicode/ustdio.h"
+#include "unicode/uclean.h"
+
+#include "unicode/ucnv.h"
+#include "unicode/uchar.h"
+#include "unicode/unistr.h"
+#include "unicode/ustring.h"
+#include "ustr_cnv.h"
+#include "iotest.h"
+#include "unicode/tstdtmod.h"
+#include "putilimp.h"
+
+#include <string.h>
+#include <stdlib.h>
+
+class DataDrivenLogger : public TestLog {
+ static const char* fgDataDir;
+ static char *fgTestDataPath;
+
+public:
+ static void cleanUp() {
+ if (fgTestDataPath) {
+ free(fgTestDataPath);
+ fgTestDataPath = NULL;
+ }
+ }
+ virtual void errln( const UnicodeString &message ) {
+ char buffer[4000];
+ message.extract(0, message.length(), buffer, sizeof(buffer));
+ buffer[3999] = 0; /* NULL terminate */
+ log_err(buffer);
+ }
+
+ static const char * pathToDataDirectory(void)
+ {
+
+ if(fgDataDir != NULL) {
+ return fgDataDir;
+ }
+
+ /* U_TOPSRCDIR is set by the makefiles on UNIXes when building cintltst and intltst
+ // to point to the top of the build hierarchy, which may or
+ // may not be the same as the source directory, depending on
+ // the configure options used. At any rate,
+ // set the data path to the built data from this directory.
+ // The value is complete with quotes, so it can be used
+ // as-is as a string constant.
+ */
+ #if defined (U_TOPSRCDIR)
+ {
+ fgDataDir = U_TOPSRCDIR U_FILE_SEP_STRING "data" U_FILE_SEP_STRING;
+ }
+ #else
+
+ /* On Windows, the file name obtained from __FILE__ includes a full path.
+ * This file is "wherever\icu\source\test\cintltst\cintltst.c"
+ * Change to "wherever\icu\source\data"
+ */
+ {
+ static char p[sizeof(__FILE__) + 10];
+ char *pBackSlash;
+ int i;
+
+ strcpy(p, __FILE__);
+ /* We want to back over three '\' chars. */
+ /* Only Windows should end up here, so looking for '\' is safe. */
+ for (i=1; i<=3; i++) {
+ pBackSlash = strrchr(p, U_FILE_SEP_CHAR);
+ if (pBackSlash != NULL) {
+ *pBackSlash = 0; /* Truncate the string at the '\' */
+ }
+ }
+
+ if (pBackSlash != NULL) {
+ /* We found and truncated three names from the path.
+ * Now append "source\data" and set the environment
+ */
+ strcpy(pBackSlash, U_FILE_SEP_STRING "data" U_FILE_SEP_STRING );
+ fgDataDir = p;
+ }
+ else {
+ /* __FILE__ on MSVC7 does not contain the directory */
+ FILE *file = fopen(".."U_FILE_SEP_STRING".."U_FILE_SEP_STRING "data" U_FILE_SEP_STRING "Makefile.in", "r");
+ if (file) {
+ fclose(file);
+ fgDataDir = ".."U_FILE_SEP_STRING".."U_FILE_SEP_STRING "data" U_FILE_SEP_STRING;
+ }
+ else {
+ fgDataDir = ".."U_FILE_SEP_STRING".."U_FILE_SEP_STRING".."U_FILE_SEP_STRING "data" U_FILE_SEP_STRING;
+ }
+ }
+ }
+ #endif
+
+ return fgDataDir;
+
+ }
+
+ static const char* loadTestData(UErrorCode& err){
+ if( fgTestDataPath == NULL){
+ const char* directory=NULL;
+ UResourceBundle* test =NULL;
+ char* tdpath=NULL;
+ const char* tdrelativepath;
+
+#if defined (U_TOPBUILDDIR)
+ tdrelativepath = "test"U_FILE_SEP_STRING"testdata"U_FILE_SEP_STRING"out"U_FILE_SEP_STRING;
+ directory = U_TOPBUILDDIR;
+#else
+ tdrelativepath = ".."U_FILE_SEP_STRING"test"U_FILE_SEP_STRING"testdata"U_FILE_SEP_STRING"out"U_FILE_SEP_STRING;
+ directory = pathToDataDirectory();
+#endif
+
+ tdpath = (char*) malloc(sizeof(char) *(( strlen(directory) * strlen(tdrelativepath)) + 100));
+
+
+ /* u_getDataDirectory shoul return \source\data ... set the
+ * directory to ..\source\data\..\test\testdata\out\testdata
+ */
+ strcpy(tdpath, directory);
+ strcat(tdpath, tdrelativepath);
+ strcat(tdpath,"testdata");
+
+ test=ures_open(tdpath, "testtypes", &err);
+
+ if(U_FAILURE(err)){
+ err = U_FILE_ACCESS_ERROR;
+ log_err("Could not load testtypes.res in testdata bundle with path %s - %s\n", tdpath, u_errorName(err));
+ return "";
+ }
+ ures_close(test);
+ fgTestDataPath = tdpath;
+ }
+ return fgTestDataPath;
+ }
+
+ virtual const char* getTestDataPath(UErrorCode& err) {
+ return loadTestData(err);
+ }
+};
+
+const char* DataDrivenLogger::fgDataDir = NULL;
+char* DataDrivenLogger::fgTestDataPath = NULL;
+
+static int64_t
+uto64(const UChar *buffer)
+{
+ int64_t result = 0;
+ /* iterate through buffer */
+ while(*buffer) {
+ /* read the next digit */
+ result *= 16;
+ if (!u_isxdigit(*buffer)) {
+ log_err("\\u%04X is not a valid hex digit for this test\n", (UChar)*buffer);
+ }
+ result += *buffer - 0x0030 - (*buffer >= 0x0041 ? (*buffer >= 0x0061 ? 39 : 7) : 0);
+ buffer++;
+ }
+ return result;
+}
+
+
+U_CDECL_BEGIN
+static void U_CALLCONV DataDrivenPrintf(void)
+{
+#if !UCONFIG_NO_FORMATTING
+ UErrorCode errorCode;
+ TestDataModule *dataModule;
+ TestData *testData;
+ const DataMap *testCase;
+ DataDrivenLogger logger;
+ UChar uBuffer[512];
+ char cBuffer[512];
+ char cFormat[sizeof(cBuffer)];
+ char cExpected[sizeof(cBuffer)];
+ UnicodeString tempStr;
+ UChar format[512];
+ UChar expectedResult[512];
+ UChar argument[512];
+ int32_t i;
+ int8_t i8;
+ int16_t i16;
+ int32_t i32;
+ int64_t i64;
+ double dbl;
+ int32_t uBufferLenReturned;
+
+ const char *fileLocale = "en_US_POSIX";
+ int32_t uFileBufferLenReturned;
+ UFILE *testFile;
+
+ errorCode=U_ZERO_ERROR;
+ dataModule=TestDataModule::getTestDataModule("icuio", logger, errorCode);
+ if(U_SUCCESS(errorCode)) {
+ testData=dataModule->createTestData("printf", errorCode);
+ if(U_SUCCESS(errorCode)) {
+ for(i=0; testData->nextCase(testCase, errorCode); ++i) {
+ if(U_FAILURE(errorCode)) {
+ log_err("error retrieving icuio/printf test case %d - %s\n",
+ i, u_errorName(errorCode));
+ errorCode=U_ZERO_ERROR;
+ continue;
+ }
+ testFile = u_fopen(STANDARD_TEST_FILE, "w", fileLocale, "UTF-8");
+ if (!testFile) {
+ log_err("Can't open test file - %s\n",
+ STANDARD_TEST_FILE);
+ continue;
+ }
+ u_memset(uBuffer, 0x2A, sizeof(uBuffer)/sizeof(uBuffer[0]));
+ uBuffer[sizeof(uBuffer)/sizeof(uBuffer[0])-1] = 0;
+ tempStr=testCase->getString("format", errorCode);
+ tempStr.extract(format, sizeof(format)/sizeof(format[0]), errorCode);
+ tempStr=testCase->getString("result", errorCode);
+ tempStr.extract(expectedResult, sizeof(expectedResult)/sizeof(expectedResult[0]), errorCode);
+ tempStr=testCase->getString("argument", errorCode);
+ tempStr.extract(argument, sizeof(argument)/sizeof(argument[0]), errorCode);
+ u_austrncpy(cBuffer, format, sizeof(cBuffer));
+ if(U_FAILURE(errorCode)) {
+ log_err("error retrieving icuio/printf test case %d - %s\n",
+ i, u_errorName(errorCode));
+ errorCode=U_ZERO_ERROR;
+ continue;
+ }
+ log_verbose("Test %d: format=\"%s\"\n", i, cBuffer);
+ switch (testCase->getString("argumentType", errorCode)[0]) {
+ case 0x64: // 'd' double
+ dbl = atof(u_austrcpy(cBuffer, argument));
+ uBufferLenReturned = u_sprintf_u(uBuffer, format, dbl);
+ uFileBufferLenReturned = u_fprintf_u(testFile, format, dbl);
+ break;
+ case 0x31: // '1' int8_t
+ i8 = (int8_t)uto64(argument);
+ uBufferLenReturned = u_sprintf_u(uBuffer, format, i8);
+ uFileBufferLenReturned = u_fprintf_u(testFile, format, i8);
+ break;
+ case 0x32: // '2' int16_t
+ i16 = (int16_t)uto64(argument);
+ uBufferLenReturned = u_sprintf_u(uBuffer, format, i16);
+ uFileBufferLenReturned = u_fprintf_u(testFile, format, i16);
+ break;
+ case 0x34: // '4' int32_t
+ i32 = (int32_t)uto64(argument);
+ uBufferLenReturned = u_sprintf_u(uBuffer, format, i32);
+ uFileBufferLenReturned = u_fprintf_u(testFile, format, i32);
+ break;
+ case 0x38: // '8' int64_t
+ i64 = uto64(argument);
+ uBufferLenReturned = u_sprintf_u(uBuffer, format, i64);
+ uFileBufferLenReturned = u_fprintf_u(testFile, format, i64);
+ break;
+ case 0x73: // 's' char *
+ u_austrncpy(cBuffer, argument, sizeof(cBuffer));
+ uBufferLenReturned = u_sprintf_u(uBuffer, format, cBuffer);
+ uFileBufferLenReturned = u_fprintf_u(testFile, format, cBuffer);
+ break;
+ case 0x53: // 'S' UChar *
+ uBufferLenReturned = u_sprintf_u(uBuffer, format, argument);
+ uFileBufferLenReturned = u_fprintf_u(testFile, format, argument);
+ break;
+ default:
+ uBufferLenReturned = 0;
+ uFileBufferLenReturned = 0;
+ log_err("Unknown type %c for test %d\n", testCase->getString("argumentType", errorCode)[0], i);
+ }
+ if (u_strcmp(uBuffer, expectedResult) != 0) {
+ u_austrncpy(cBuffer, uBuffer, sizeof(cBuffer));
+ u_austrncpy(cFormat, format, sizeof(cFormat));
+ u_austrncpy(cExpected, expectedResult, sizeof(cExpected));
+ cBuffer[sizeof(cBuffer)-1] = 0;
+ log_err("FAILURE string test case %d \"%s\" - Got: \"%s\" Expected: \"%s\"\n",
+ i, cFormat, cBuffer, cExpected);
+ }
+ if (uBuffer[uBufferLenReturned-1] == 0
+ || uBuffer[uBufferLenReturned] != 0
+ || uBuffer[uBufferLenReturned+1] != 0x2A
+ || uBuffer[uBufferLenReturned+2] != 0x2A)
+ {
+ u_austrncpy(cBuffer, uBuffer, sizeof(cBuffer));
+ cBuffer[sizeof(cBuffer)-1] = 0;
+ log_err("FAILURE test case %d - \"%s\" wrong amount of characters was written. Got %d.\n",
+ i, cBuffer, uBufferLenReturned);
+ }
+ u_fclose(testFile);
+ testFile = u_fopen(STANDARD_TEST_FILE, "r", fileLocale, "UTF-8");
+ if (!testFile) {
+ log_err("Can't open test file - %s\n",
+ STANDARD_TEST_FILE);
+ }
+ uBuffer[0]=0;
+ u_fgets(uBuffer, sizeof(uBuffer)/sizeof(uBuffer[0]), testFile);
+ if (u_strcmp(uBuffer, expectedResult) != 0) {
+ u_austrncpy(cBuffer, uBuffer, sizeof(cBuffer));
+ u_austrncpy(cFormat, format, sizeof(cFormat));
+ u_austrncpy(cExpected, expectedResult, sizeof(cExpected));
+ cBuffer[sizeof(cBuffer)-1] = 0;
+ log_err("FAILURE file test case %d \"%s\" - Got: \"%s\" Expected: \"%s\"\n",
+ i, cFormat, cBuffer, cExpected);
+ }
+ if (uFileBufferLenReturned != uBufferLenReturned)
+ {
+ u_austrncpy(cBuffer, uBuffer, sizeof(cBuffer));
+ cBuffer[sizeof(cBuffer)-1] = 0;
+ log_err("FAILURE uFileBufferLenReturned(%d) != uBufferLenReturned(%d)\n",
+ uFileBufferLenReturned, uBufferLenReturned);
+ }
+
+ if(U_FAILURE(errorCode)) {
+ log_err("error running icuio/printf test case %d - %s\n",
+ i, u_errorName(errorCode));
+ errorCode=U_ZERO_ERROR;
+ continue;
+ }
+ u_fclose(testFile);
+ }
+ delete testData;
+ }
+ delete dataModule;
+ }
+ else {
+ log_err("Failed: could not load test icuio data\n");
+ }
+#endif
+}
+U_CDECL_END
+
+U_CDECL_BEGIN
+static void U_CALLCONV DataDrivenScanf(void)
+{
+#if !UCONFIG_NO_FORMATTING
+ UErrorCode errorCode;
+ TestDataModule *dataModule;
+ TestData *testData;
+ const DataMap *testCase;
+ DataDrivenLogger logger;
+ UChar uBuffer[512];
+ char cBuffer[512];
+ char cExpected[sizeof(cBuffer)];
+ UnicodeString tempStr;
+ UChar format[512];
+ UChar expectedResult[512];
+ UChar argument[512];
+ int32_t i;
+ int8_t i8, expected8;
+ int16_t i16, expected16;
+ int32_t i32, expected32;
+ int64_t i64, expected64;
+ double dbl, expectedDbl;
+ volatile float flt, expectedFlt; // Use volatile in order to get around an Intel compiler issue.
+ int32_t uBufferLenReturned;
+
+ //const char *fileLocale = "en_US_POSIX";
+ //int32_t uFileBufferLenReturned;
+ //UFILE *testFile;
+
+ errorCode=U_ZERO_ERROR;
+ dataModule=TestDataModule::getTestDataModule("icuio", logger, errorCode);
+ if(U_SUCCESS(errorCode)) {
+ testData=dataModule->createTestData("scanf", errorCode);
+ if(U_SUCCESS(errorCode)) {
+ for(i=0; testData->nextCase(testCase, errorCode); ++i) {
+ if(U_FAILURE(errorCode)) {
+ log_err("error retrieving icuio/printf test case %d - %s\n",
+ i, u_errorName(errorCode));
+ errorCode=U_ZERO_ERROR;
+ continue;
+ }
+/* testFile = u_fopen(STANDARD_TEST_FILE, "w", fileLocale, "UTF-8");
+ if (!testFile) {
+ log_err("Can't open test file - %s\n",
+ STANDARD_TEST_FILE);
+ }*/
+ u_memset(uBuffer, 0x2A, sizeof(uBuffer)/sizeof(uBuffer[0]));
+ uBuffer[sizeof(uBuffer)/sizeof(uBuffer[0])-1] = 0;
+ tempStr=testCase->getString("format", errorCode);
+ tempStr.extract(format, sizeof(format)/sizeof(format[0]), errorCode);
+ tempStr=testCase->getString("result", errorCode);
+ tempStr.extract(expectedResult, sizeof(expectedResult)/sizeof(expectedResult[0]), errorCode);
+ tempStr=testCase->getString("argument", errorCode);
+ tempStr.extract(argument, sizeof(argument)/sizeof(argument[0]), errorCode);
+ u_austrncpy(cBuffer, format, sizeof(cBuffer));
+ if(U_FAILURE(errorCode)) {
+ log_err("error retrieving icuio/printf test case %d - %s\n",
+ i, u_errorName(errorCode));
+ errorCode=U_ZERO_ERROR;
+ continue;
+ }
+ log_verbose("Test %d: format=\"%s\"\n", i, cBuffer);
+ switch (testCase->getString("argumentType", errorCode)[0]) {
+ case 0x64: // 'd' double
+ expectedDbl = atof(u_austrcpy(cBuffer, expectedResult));
+ uBufferLenReturned = u_sscanf_u(argument, format, &dbl);
+ //uFileBufferLenReturned = u_fscanf_u(testFile, format, dbl);
+ if (dbl != expectedDbl) {
+ log_err("error in scanf test case[%d] Got: %f Exp: %f\n",
+ i, dbl, expectedDbl);
+ }
+ break;
+ case 0x66: // 'f' float
+ expectedFlt = (float)atof(u_austrcpy(cBuffer, expectedResult));
+ uBufferLenReturned = u_sscanf_u(argument, format, &flt);
+ //uFileBufferLenReturned = u_fscanf_u(testFile, format, flt);
+ if (flt != expectedFlt) {
+ log_err("error in scanf test case[%d] Got: %f Exp: %f\n",
+ i, flt, expectedFlt);
+ }
+ break;
+ case 0x31: // '1' int8_t
+ expected8 = (int8_t)uto64(expectedResult);
+ uBufferLenReturned = u_sscanf_u(argument, format, &i8);
+ //uFileBufferLenReturned = u_fscanf_u(testFile, format, i8);
+ if (i8 != expected8) {
+ log_err("error in scanf test case[%d] Got: %02X Exp: %02X\n",
+ i, i8, expected8);
+ }
+ break;
+ case 0x32: // '2' int16_t
+ expected16 = (int16_t)uto64(expectedResult);
+ uBufferLenReturned = u_sscanf_u(argument, format, &i16);
+ //uFileBufferLenReturned = u_fscanf_u(testFile, format, i16);
+ if (i16 != expected16) {
+ log_err("error in scanf test case[%d] Got: %04X Exp: %04X\n",
+ i, i16, expected16);
+ }
+ break;
+ case 0x34: // '4' int32_t
+ expected32 = (int32_t)uto64(expectedResult);
+ uBufferLenReturned = u_sscanf_u(argument, format, &i32);
+ //uFileBufferLenReturned = u_fscanf_u(testFile, format, i32);
+ if (i32 != expected32) {
+ log_err("error in scanf test case[%d] Got: %08X Exp: %08X\n",
+ i, i32, expected32);
+ }
+ break;
+ case 0x38: // '8' int64_t
+ expected64 = uto64(expectedResult);
+ uBufferLenReturned = u_sscanf_u(argument, format, &i64);
+ //uFileBufferLenReturned = u_fscanf_u(testFile, format, i64);
+ if (i64 != expected64) {
+ log_err("error in scanf 64-bit. Test case = %d\n", i);
+ }
+ break;
+ case 0x73: // 's' char *
+ u_austrcpy(cExpected, expectedResult);
+ uBufferLenReturned = u_sscanf_u(argument, format, cBuffer);
+ //uFileBufferLenReturned = u_fscanf_u(testFile, format, cBuffer);
+ if (strcmp(cBuffer, cExpected) != 0) {
+ log_err("error in scanf char * string. Got \"%s\" Expected \"%s\". Test case = %d\n", cBuffer, cExpected, i);
+ }
+ break;
+ case 0x53: // 'S' UChar *
+ uBufferLenReturned = u_sscanf_u(argument, format, uBuffer);
+ //uFileBufferLenReturned = u_fscanf_u(testFile, format, argument);
+ if (u_strcmp(uBuffer, expectedResult) != 0) {
+ u_austrcpy(cExpected, format);
+ u_austrcpy(cBuffer, uBuffer);
+ log_err("error in scanf UChar * string %s Got: \"%s\". Test case = %d\n", cExpected, cBuffer, i);
+ }
+ break;
+ default:
+ uBufferLenReturned = 0;
+ //uFileBufferLenReturned = 0;
+ log_err("Unknown type %c for test %d\n", testCase->getString("argumentType", errorCode)[0], i);
+ }
+ if (uBufferLenReturned != 1) {
+ log_err("error scanf converted %d arguments. Test case = %d\n", uBufferLenReturned, i);
+ }
+/* if (u_strcmp(uBuffer, expectedResult) != 0) {
+ u_austrncpy(cBuffer, uBuffer, sizeof(cBuffer));
+ u_austrncpy(cFormat, format, sizeof(cFormat));
+ u_austrncpy(cExpected, expectedResult, sizeof(cExpected));
+ cBuffer[sizeof(cBuffer)-1] = 0;
+ log_err("FAILURE string test case %d \"%s\" - Got: \"%s\" Expected: \"%s\"\n",
+ i, cFormat, cBuffer, cExpected);
+ }
+ if (uBuffer[uBufferLenReturned-1] == 0
+ || uBuffer[uBufferLenReturned] != 0
+ || uBuffer[uBufferLenReturned+1] != 0x2A
+ || uBuffer[uBufferLenReturned+2] != 0x2A)
+ {
+ u_austrncpy(cBuffer, uBuffer, sizeof(cBuffer));
+ cBuffer[sizeof(cBuffer)-1] = 0;
+ log_err("FAILURE test case %d - \"%s\" wrong amount of characters was written. Got %d.\n",
+ i, cBuffer, uBufferLenReturned);
+ }*/
+/* u_fclose(testFile);
+ testFile = u_fopen(STANDARD_TEST_FILE, "r", fileLocale, "UTF-8");
+ if (!testFile) {
+ log_err("Can't open test file - %s\n",
+ STANDARD_TEST_FILE);
+ }
+ uBuffer[0];
+ u_fgets(uBuffer, sizeof(uBuffer)/sizeof(uBuffer[0]), testFile);
+ if (u_strcmp(uBuffer, expectedResult) != 0) {
+ u_austrncpy(cBuffer, uBuffer, sizeof(cBuffer));
+ u_austrncpy(cFormat, format, sizeof(cFormat));
+ u_austrncpy(cExpected, expectedResult, sizeof(cExpected));
+ cBuffer[sizeof(cBuffer)-1] = 0;
+ log_err("FAILURE file test case %d \"%s\" - Got: \"%s\" Expected: \"%s\"\n",
+ i, cFormat, cBuffer, cExpected);
+ }
+ if (uFileBufferLenReturned != uBufferLenReturned)
+ {
+ u_austrncpy(cBuffer, uBuffer, sizeof(cBuffer));
+ cBuffer[sizeof(cBuffer)-1] = 0;
+ log_err("FAILURE uFileBufferLenReturned(%d) != uBufferLenReturned(%d)\n",
+ uFileBufferLenReturned, uBufferLenReturned);
+ }
+*/
+ if(U_FAILURE(errorCode)) {
+ log_err("error running icuio/printf test case %d - %s\n",
+ i, u_errorName(errorCode));
+ errorCode=U_ZERO_ERROR;
+ continue;
+ }
+// u_fclose(testFile);
+ }
+ delete testData;
+ }
+ delete dataModule;
+ }
+ else {
+ log_err("Failed: could not load test icuio data\n");
+ }
+#endif
+}
+U_CDECL_END
+
+U_CDECL_BEGIN
+static void U_CALLCONV DataDrivenPrintfPrecision(void)
+{
+#if !UCONFIG_NO_FORMATTING
+ UErrorCode errorCode;
+ TestDataModule *dataModule;
+ TestData *testData;
+ const DataMap *testCase;
+ DataDrivenLogger logger;
+ UChar uBuffer[512];
+ char cBuffer[512];
+ char cFormat[sizeof(cBuffer)];
+ char cExpected[sizeof(cBuffer)];
+ UnicodeString tempStr;
+ UChar format[512];
+ UChar expectedResult[512];
+ UChar argument[512];
+ int32_t precision;
+ int32_t i;
+ int8_t i8;
+ int16_t i16;
+ int32_t i32;
+ int64_t i64;
+ double dbl;
+ int32_t uBufferLenReturned;
+
+ errorCode=U_ZERO_ERROR;
+ dataModule=TestDataModule::getTestDataModule("icuio", logger, errorCode);
+ if(U_SUCCESS(errorCode)) {
+ testData=dataModule->createTestData("printfPrecision", errorCode);
+ if(U_SUCCESS(errorCode)) {
+ for(i=0; testData->nextCase(testCase, errorCode); ++i) {
+ if(U_FAILURE(errorCode)) {
+ log_err("error retrieving icuio/printf test case %d - %s\n",
+ i, u_errorName(errorCode));
+ errorCode=U_ZERO_ERROR;
+ continue;
+ }
+ u_memset(uBuffer, 0x2A, sizeof(uBuffer)/sizeof(uBuffer[0]));
+ uBuffer[sizeof(uBuffer)/sizeof(uBuffer[0])-1] = 0;
+ tempStr=testCase->getString("format", errorCode);
+ tempStr.extract(format, sizeof(format)/sizeof(format[0]), errorCode);
+ tempStr=testCase->getString("result", errorCode);
+ tempStr.extract(expectedResult, sizeof(expectedResult)/sizeof(expectedResult[0]), errorCode);
+ tempStr=testCase->getString("argument", errorCode);
+ tempStr.extract(argument, sizeof(argument)/sizeof(argument[0]), errorCode);
+ precision=testCase->getInt28("precision", errorCode);
+ u_austrncpy(cBuffer, format, sizeof(cBuffer));
+ if(U_FAILURE(errorCode)) {
+ log_err("error retrieving icuio/printf test case %d - %s\n",
+ i, u_errorName(errorCode));
+ errorCode=U_ZERO_ERROR;
+ continue;
+ }
+ log_verbose("Test %d: format=\"%s\"\n", i, cBuffer);
+ switch (testCase->getString("argumentType", errorCode)[0]) {
+ case 0x64: // 'd' double
+ dbl = atof(u_austrcpy(cBuffer, argument));
+ uBufferLenReturned = u_sprintf_u(uBuffer, format, precision, dbl);
+ break;
+ case 0x31: // '1' int8_t
+ i8 = (int8_t)uto64(argument);
+ uBufferLenReturned = u_sprintf_u(uBuffer, format, precision, i8);
+ break;
+ case 0x32: // '2' int16_t
+ i16 = (int16_t)uto64(argument);
+ uBufferLenReturned = u_sprintf_u(uBuffer, format, precision, i16);
+ break;
+ case 0x34: // '4' int32_t
+ i32 = (int32_t)uto64(argument);
+ uBufferLenReturned = u_sprintf_u(uBuffer, format, precision, i32);
+ break;
+ case 0x38: // '8' int64_t
+ i64 = uto64(argument);
+ uBufferLenReturned = u_sprintf_u(uBuffer, format, precision, i64);
+ break;
+ case 0x73: // 's' char *
+ u_austrncpy(cBuffer, uBuffer, sizeof(cBuffer));
+ uBufferLenReturned = u_sprintf_u(uBuffer, format, precision, cBuffer);
+ break;
+ case 0x53: // 'S' UChar *
+ uBufferLenReturned = u_sprintf_u(uBuffer, format, precision, argument);
+ break;
+ default:
+ uBufferLenReturned = 0;
+ log_err("Unknown type %c for test %d\n", testCase->getString("argumentType", errorCode)[0], i);
+ }
+ if (u_strcmp(uBuffer, expectedResult) != 0) {
+ u_austrncpy(cBuffer, uBuffer, sizeof(cBuffer));
+ u_austrncpy(cFormat, format, sizeof(cFormat));
+ u_austrncpy(cExpected, expectedResult, sizeof(cExpected));
+ cBuffer[sizeof(cBuffer)-1] = 0;
+ log_err("FAILURE test case %d \"%s\" - Got: \"%s\" Expected: \"%s\"\n",
+ i, cFormat, cBuffer, cExpected);
+ }
+ if (uBuffer[uBufferLenReturned-1] == 0
+ || uBuffer[uBufferLenReturned] != 0
+ || uBuffer[uBufferLenReturned+1] != 0x2A
+ || uBuffer[uBufferLenReturned+2] != 0x2A)
+ {
+ u_austrncpy(cBuffer, uBuffer, sizeof(cBuffer));
+ cBuffer[sizeof(cBuffer)-1] = 0;
+ log_err("FAILURE test case %d - \"%s\" wrong amount of characters was written. Got %d.\n",
+ i, cBuffer, uBufferLenReturned);
+ }
+ if(U_FAILURE(errorCode)) {
+ log_err("error running icuio/printf test case %d - %s\n",
+ i, u_errorName(errorCode));
+ errorCode=U_ZERO_ERROR;
+ continue;
+ }
+ }
+ delete testData;
+ }
+ delete dataModule;
+ }
+ else {
+ log_err("Failed: could not load test icuio data\n");
+ }
+#endif
+}
+U_CDECL_END
+
+static void addAllTests(TestNode** root) {
+ addFileTest(root);
+ addStringTest(root);
+ addTranslitTest(root);
+
+#if !UCONFIG_NO_FORMATTING
+ addTest(root, &DataDrivenPrintf, "datadriv/DataDrivenPrintf");
+ addTest(root, &DataDrivenPrintfPrecision, "datadriv/DataDrivenPrintfPrecision");
+ addTest(root, &DataDrivenScanf, "datadriv/DataDrivenScanf");
+#endif
+ addStreamTests(root);
+}
+
+/* returns the path to icu/source/data/out */
+static const char *ctest_dataOutDir()
+{
+ static const char *dataOutDir = NULL;
+
+ if(dataOutDir) {
+ return dataOutDir;
+ }
+
+ /* U_TOPBUILDDIR is set by the makefiles on UNIXes when building cintltst and intltst
+ // to point to the top of the build hierarchy, which may or
+ // may not be the same as the source directory, depending on
+ // the configure options used. At any rate,
+ // set the data path to the built data from this directory.
+ // The value is complete with quotes, so it can be used
+ // as-is as a string constant.
+ */
+#if defined (U_TOPBUILDDIR)
+ {
+ dataOutDir = U_TOPBUILDDIR "data"U_FILE_SEP_STRING"out"U_FILE_SEP_STRING;
+ }
+#else
+
+ /* On Windows, the file name obtained from __FILE__ includes a full path.
+ * This file is "wherever\icu\source\test\cintltst\cintltst.c"
+ * Change to "wherever\icu\source\data"
+ */
+ {
+ static char p[sizeof(__FILE__) + 20];
+ char *pBackSlash;
+ int i;
+
+ strcpy(p, __FILE__);
+ /* We want to back over three '\' chars. */
+ /* Only Windows should end up here, so looking for '\' is safe. */
+ for (i=1; i<=3; i++) {
+ pBackSlash = strrchr(p, U_FILE_SEP_CHAR);
+ if (pBackSlash != NULL) {
+ *pBackSlash = 0; /* Truncate the string at the '\' */
+ }
+ }
+
+ if (pBackSlash != NULL) {
+ /* We found and truncated three names from the path.
+ * Now append "source\data" and set the environment
+ */
+ strcpy(pBackSlash, U_FILE_SEP_STRING "data" U_FILE_SEP_STRING "out" U_FILE_SEP_STRING);
+ dataOutDir = p;
+ }
+ else {
+ /* __FILE__ on MSVC7 does not contain the directory */
+ FILE *file = fopen(".."U_FILE_SEP_STRING".."U_FILE_SEP_STRING "data" U_FILE_SEP_STRING "Makefile.in", "r");
+ if (file) {
+ fclose(file);
+ dataOutDir = ".."U_FILE_SEP_STRING".."U_FILE_SEP_STRING "data" U_FILE_SEP_STRING "out" U_FILE_SEP_STRING;
+ }
+ else {
+ dataOutDir = ".."U_FILE_SEP_STRING".."U_FILE_SEP_STRING".."U_FILE_SEP_STRING "data" U_FILE_SEP_STRING "out" U_FILE_SEP_STRING;
+ }
+ }
+ }
+#endif
+
+ return dataOutDir;
+}
+
+/* ctest_setICU_DATA - if the ICU_DATA environment variable is not already
+ * set, try to deduce the directory in which ICU was built,
+ * and set ICU_DATA to "icu/source/data" in that location.
+ * The intent is to allow the tests to have a good chance
+ * of running without requiring that the user manually set
+ * ICU_DATA. Common data isn't a problem, since it is
+ * picked up via a static (build time) reference, but the
+ * tests dynamically load some data.
+ */
+static void ctest_setICU_DATA() {
+
+ /* No location for the data dir was identifiable.
+ * Add other fallbacks for the test data location here if the need arises
+ */
+ if (getenv("ICU_DATA") == NULL) {
+ /* If ICU_DATA isn't set, set it to the usual location */
+ u_setDataDirectory(ctest_dataOutDir());
+ }
+}
+
+int main(int argc, char* argv[])
+{
+ int32_t nerrors = 0;
+ TestNode *root = NULL;
+ UErrorCode errorCode = U_ZERO_ERROR;
+ UDate startTime, endTime;
+ int32_t diffTime;
+
+ startTime = uprv_getUTCtime();
+
+ /* Check whether ICU will initialize without forcing the build data directory into
+ * the ICU_DATA path. Success here means either the data dll contains data, or that
+ * this test program was run with ICU_DATA set externally. Failure of this check
+ * is normal when ICU data is not packaged into a shared library.
+ *
+ * Whether or not this test succeeds, we want to cleanup and reinitialize
+ * with a data path so that data loading from individual files can be tested.
+ */
+ u_init(&errorCode);
+ if (U_FAILURE(errorCode)) {
+ fprintf(stderr,
+ "#### Note: ICU Init without build-specific setDataDirectory() failed.\n");
+ }
+ u_cleanup();
+ errorCode = U_ZERO_ERROR;
+
+ /* Initialize ICU */
+ ctest_setICU_DATA(); /* u_setDataDirectory() must happen Before u_init() */
+ u_init(&errorCode);
+ if (U_FAILURE(errorCode)) {
+ fprintf(stderr,
+ "#### ERROR! %s: u_init() failed with status = \"%s\".\n"
+ "*** Check the ICU_DATA environment variable and \n"
+ "*** check that the data files are present.\n", argv[0], u_errorName(errorCode));
+ return 1;
+ }
+
+ fprintf(stdout, "Default charset for this run is %s\n", ucnv_getDefaultName());
+
+ addAllTests(&root);
+ nerrors = processArgs(root, argc, argv);
+
+#if 1
+ {
+ FILE* fileToRemove = fopen(STANDARD_TEST_FILE, "r");
+ /* This should delete any temporary files. */
+ if (fileToRemove) {
+ fclose(fileToRemove);
+ if (remove(STANDARD_TEST_FILE) != 0) {
+ /* Maybe someone didn't close the file correctly. */
+ fprintf(stderr, "FAIL: Could not delete %s\n", STANDARD_TEST_FILE);
+ nerrors += 1;
+ }
+ }
+ }
+#endif
+
+ cleanUpTestTree(root);
+ DataDrivenLogger::cleanUp();
+ u_cleanup();
+
+ endTime = uprv_getUTCtime();
+ diffTime = (int32_t)(endTime - startTime);
+ printf("Elapsed Time: %02d:%02d:%02d.%03d\n",
+ (int)((diffTime%U_MILLIS_PER_DAY)/U_MILLIS_PER_HOUR),
+ (int)((diffTime%U_MILLIS_PER_HOUR)/U_MILLIS_PER_MINUTE),
+ (int)((diffTime%U_MILLIS_PER_MINUTE)/U_MILLIS_PER_SECOND),
+ (int)(diffTime%U_MILLIS_PER_SECOND));
+
+ return nerrors;
+}
Property changes on: trunk/source/test/iotest/iotest.cpp
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/source/test/iotest/iotest.h
===================================================================
--- trunk/source/test/iotest/iotest.h 2006-12-21 11:09:23 UTC (rev 127)
+++ trunk/source/test/iotest/iotest.h 2006-12-21 11:10:34 UTC (rev 128)
@@ -1,42 +1,42 @@
-/*
-**********************************************************************
-* Copyright (C) 2004-2005, International Business Machines
-* Corporation and others. All Rights Reserved.
-**********************************************************************
-* file name: iotest.h
-* encoding: US-ASCII
-* tab size: 8 (not used)
-* indentation:4
-*
-* created on: 2004apr06
-* created by: George Rhoten
-*/
-
-#ifndef IOTEST_H
-#define IOTEST_H 1
-
-#include "unicode/utypes.h"
-#include "unicode/ctest.h"
-
-U_CFUNC void
-addStringTest(TestNode** root);
-
-U_CFUNC void
-addFileTest(TestNode** root);
-
-U_CFUNC void
-addTranslitTest(TestNode** root);
-
-U_CFUNC void
-addStreamTests(TestNode** root);
-
-U_CDECL_BEGIN
-extern const UChar NEW_LINE[];
-extern const char C_NEW_LINE[];
-extern const char STANDARD_TEST_FILE[];
-U_CDECL_END
-
-#define STANDARD_TEST_NUM_RANGE 1000
-
-
-#endif
+/*
+**********************************************************************
+* Copyright (C) 2004-2005, International Business Machines
+* Corporation and others. All Rights Reserved.
+**********************************************************************
+* file name: iotest.h
+* encoding: US-ASCII
+* tab size: 8 (not used)
+* indentation:4
+*
+* created on: 2004apr06
+* created by: George Rhoten
+*/
+
+#ifndef IOTEST_H
+#define IOTEST_H 1
+
+#include "unicode/utypes.h"
+#include "unicode/ctest.h"
+
+U_CFUNC void
+addStringTest(TestNode** root);
+
+U_CFUNC void
+addFileTest(TestNode** root);
+
+U_CFUNC void
+addTranslitTest(TestNode** root);
+
+U_CFUNC void
+addStreamTests(TestNode** root);
+
+U_CDECL_BEGIN
+extern const UChar NEW_LINE[];
+extern const char C_NEW_LINE[];
+extern const char STANDARD_TEST_FILE[];
+U_CDECL_END
+
+#define STANDARD_TEST_NUM_RANGE 1000
+
+
+#endif
Property changes on: trunk/source/test/iotest/iotest.h
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/source/test/iotest/stream.cpp
===================================================================
--- trunk/source/test/iotest/stream.cpp 2006-12-21 11:09:23 UTC (rev 127)
+++ trunk/source/test/iotest/stream.cpp 2006-12-21 11:10:34 UTC (rev 128)
@@ -1,135 +1,135 @@
-/*
-**********************************************************************
-* Copyright (C) 2002-2006, International Business Machines
-* Corporation and others. All Rights Reserved.
-**********************************************************************
-* file name: iotest.cpp
-* encoding: US-ASCII
-* tab size: 8 (not used)
-* indentation:4
-*
-* created on: 2002feb21
-* created by: George Rhoten
-*/
-
-
-#include "unicode/ustream.h"
-
-#include "unicode/ucnv.h"
-#include "unicode/ustring.h"
-#include "ustr_cnv.h"
-#include "iotest.h"
-
-#if U_IOSTREAM_SOURCE >= 199711
-#if defined(__GNUC__) && __GNUC__ >= 4
-#define USE_SSTREAM 1
-#include <sstream>
-#else
-// <strstream> is deprecated on some platforms, and the compiler complains very loudly if you use it.
-#include <strstream>
-#endif
-using namespace std;
-#elif U_IOSTREAM_SOURCE >= 198506
-#include <strstream.h>
-#endif
-
-#include <string.h>
-
-U_CDECL_BEGIN
-#ifdef U_WINDOWS
-const UChar NEW_LINE[] = {0x0d,0x0a,0};
-const char C_NEW_LINE[] = {0x0d,0x0a,0};
-#define UTF8_NEW_LINE "\x0d\x0a"
-#else
-const UChar NEW_LINE[] = {0x0a,0};
-const char C_NEW_LINE[] = {'\n',0};
-#define UTF8_NEW_LINE "\x0a"
-#endif
-U_CDECL_END
-
-U_CDECL_BEGIN
-static void U_CALLCONV TestStream(void)
-{
-#if U_IOSTREAM_SOURCE >= 198506
- const UChar thisMu[] = { 0x74, 0x48, 0x69, 0x73, 0x3BC, 0};
- const UChar mu[] = { 0x6D, 0x75, 0};
- UnicodeString str1 = UNICODE_STRING_SIMPLE("str1");
- UnicodeString str2 = UNICODE_STRING_SIMPLE(" <<");
- UnicodeString str3 = UNICODE_STRING_SIMPLE("2");
- UnicodeString str4 = UNICODE_STRING_SIMPLE(" UTF-8 ");
- UnicodeString inStr = UNICODE_STRING_SIMPLE(" UTF-8 ");
- UnicodeString inStr2;
- char defConvName[UCNV_MAX_CONVERTER_NAME_LENGTH*2];
- char inStrC[128];
- UErrorCode status = U_ZERO_ERROR;
- UConverter *defConv;
- static const char testStr[] = "\x42\x65\x67\x69\x6E\x6E\x69\x6E\x67\x20\x6F\x66\x20\x74\x65\x73\x74\x20\x73\x74\x72\x31\x20\x20\x20\x3C\x3C\x32\x31\x20" UTF8_NEW_LINE "\x20\x55\x54\x46\x2D\x38\x20\xCE\xBC\xF0\x90\x80\x81\xF0\x90\x80\x82";
-
- str4.append((UChar32)0x03BC); /* mu */
- str4.append((UChar32)0x10001);
- str4.append((UChar32)0x10002);
-
- /* release the default converter and use utf-8 for a bit */
- defConv = u_getDefaultConverter(&status);
- if (U_FAILURE(status)) {
- log_err("Can't get default converter\n");
- return;
- }
- ucnv_close(defConv);
- strncpy(defConvName, ucnv_getDefaultName(), sizeof(defConvName)/sizeof(defConvName[0]));
- ucnv_setDefaultName("UTF-8");
-
- static const char * const TESTSTRING = "\x20\x74\x48\x69\x73\xCE\xBC\xE2\x80\x82\x20\x6D\x75\x20\x77\x6F\x72\x6C\x64";
-#ifdef USE_SSTREAM
- ostringstream outTestStream;
- istringstream inTestStream(TESTSTRING);
-#else
- char testStreamBuf[512];
- ostrstream outTestStream(testStreamBuf, sizeof(testStreamBuf));
- istrstream inTestStream(TESTSTRING, 0);
-
- /* initialize testStreamBuf */
- memset(testStreamBuf, '*', sizeof(testStreamBuf));
- testStreamBuf[sizeof(testStreamBuf)-1] = 0;
-#endif
-
- outTestStream << "\x42\x65\x67\x69\x6E\x6E\x69\x6E\x67\x20\x6F\x66\x20\x74\x65\x73\x74\x20";
- outTestStream << str1 << "\x20\x20" << str2 << str3 << "\x31\x20" << UTF8_NEW_LINE << str4 << ends;
-#ifdef USE_SSTREAM
- string tempStr = outTestStream.str();
- const char *testStreamBuf = tempStr.c_str();
-#endif
- if (strcmp(testStreamBuf, testStr) != 0) {
- log_err("Got: \"%s\", Expected: \"%s\"\n", testStreamBuf, testStr);
- }
-
- inTestStream >> inStr >> inStr2;
- if (inStr.compare(thisMu) != 0) {
- u_austrncpy(inStrC, inStr.getBuffer(), inStr.length());
- inStrC[inStr.length()] = 0;
- log_err("Got: \"%s\", Expected: \"tHis\\u03BC\"\n", inStrC);
- }
- if (inStr2.compare(mu) != 0) {
- u_austrncpy(inStrC, inStr.getBuffer(), inStr.length());
- inStrC[inStr.length()] = 0;
- log_err("Got: \"%s\", Expected: \"mu\"\n", inStrC);
- }
-
- /* return the default converter to the original state. */
- ucnv_setDefaultName(defConvName);
- defConv = u_getDefaultConverter(&status);
- if (U_FAILURE(status)) {
- log_err("Can't get default converter");
- return;
- }
- ucnv_close(defConv);
-#else
- log_info("U_IOSTREAM_SOURCE is disabled\n");
-#endif
-}
-U_CDECL_END
-
-U_CFUNC void addStreamTests(TestNode** root) {
- addTest(root, &TestStream, "stream/TestStream");
-}
-
+/*
+**********************************************************************
+* Copyright (C) 2002-2006, International Business Machines
+* Corporation and others. All Rights Reserved.
+**********************************************************************
+* file name: iotest.cpp
+* encoding: US-ASCII
+* tab size: 8 (not used)
+* indentation:4
+*
+* created on: 2002feb21
+* created by: George Rhoten
+*/
+
+
+#include "unicode/ustream.h"
+
+#include "unicode/ucnv.h"
+#include "unicode/ustring.h"
+#include "ustr_cnv.h"
+#include "iotest.h"
+
+#if U_IOSTREAM_SOURCE >= 199711
+#if defined(__GNUC__) && __GNUC__ >= 4
+#define USE_SSTREAM 1
+#include <sstream>
+#else
+// <strstream> is deprecated on some platforms, and the compiler complains very loudly if you use it.
+#include <strstream>
+#endif
+using namespace std;
+#elif U_IOSTREAM_SOURCE >= 198506
+#include <strstream.h>
+#endif
+
+#include <string.h>
+
+U_CDECL_BEGIN
+#ifdef U_WINDOWS
+const UChar NEW_LINE[] = {0x0d,0x0a,0};
+const char C_NEW_LINE[] = {0x0d,0x0a,0};
+#define UTF8_NEW_LINE "\x0d\x0a"
+#else
+const UChar NEW_LINE[] = {0x0a,0};
+const char C_NEW_LINE[] = {'\n',0};
+#define UTF8_NEW_LINE "\x0a"
+#endif
+U_CDECL_END
+
+U_CDECL_BEGIN
+static void U_CALLCONV TestStream(void)
+{
+#if U_IOSTREAM_SOURCE >= 198506
+ const UChar thisMu[] = { 0x74, 0x48, 0x69, 0x73, 0x3BC, 0};
+ const UChar mu[] = { 0x6D, 0x75, 0};
+ UnicodeString str1 = UNICODE_STRING_SIMPLE("str1");
+ UnicodeString str2 = UNICODE_STRING_SIMPLE(" <<");
+ UnicodeString str3 = UNICODE_STRING_SIMPLE("2");
+ UnicodeString str4 = UNICODE_STRING_SIMPLE(" UTF-8 ");
+ UnicodeString inStr = UNICODE_STRING_SIMPLE(" UTF-8 ");
+ UnicodeString inStr2;
+ char defConvName[UCNV_MAX_CONVERTER_NAME_LENGTH*2];
+ char inStrC[128];
+ UErrorCode status = U_ZERO_ERROR;
+ UConverter *defConv;
+ static const char testStr[] = "\x42\x65\x67\x69\x6E\x6E\x69\x6E\x67\x20\x6F\x66\x20\x74\x65\x73\x74\x20\x73\x74\x72\x31\x20\x20\x20\x3C\x3C\x32\x31\x20" UTF8_NEW_LINE "\x20\x55\x54\x46\x2D\x38\x20\xCE\xBC\xF0\x90\x80\x81\xF0\x90\x80\x82";
+
+ str4.append((UChar32)0x03BC); /* mu */
+ str4.append((UChar32)0x10001);
+ str4.append((UChar32)0x10002);
+
+ /* release the default converter and use utf-8 for a bit */
+ defConv = u_getDefaultConverter(&status);
+ if (U_FAILURE(status)) {
+ log_err("Can't get default converter\n");
+ return;
+ }
+ ucnv_close(defConv);
+ strncpy(defConvName, ucnv_getDefaultName(), sizeof(defConvName)/sizeof(defConvName[0]));
+ ucnv_setDefaultName("UTF-8");
+
+ static const char * const TESTSTRING = "\x20\x74\x48\x69\x73\xCE\xBC\xE2\x80\x82\x20\x6D\x75\x20\x77\x6F\x72\x6C\x64";
+#ifdef USE_SSTREAM
+ ostringstream outTestStream;
+ istringstream inTestStream(TESTSTRING);
+#else
+ char testStreamBuf[512];
+ ostrstream outTestStream(testStreamBuf, sizeof(testStreamBuf));
+ istrstream inTestStream(TESTSTRING, 0);
+
+ /* initialize testStreamBuf */
+ memset(testStreamBuf, '*', sizeof(testStreamBuf));
+ testStreamBuf[sizeof(testStreamBuf)-1] = 0;
+#endif
+
+ outTestStream << "\x42\x65\x67\x69\x6E\x6E\x69\x6E\x67\x20\x6F\x66\x20\x74\x65\x73\x74\x20";
+ outTestStream << str1 << "\x20\x20" << str2 << str3 << "\x31\x20" << UTF8_NEW_LINE << str4 << ends;
+#ifdef USE_SSTREAM
+ string tempStr = outTestStream.str();
+ const char *testStreamBuf = tempStr.c_str();
+#endif
+ if (strcmp(testStreamBuf, testStr) != 0) {
+ log_err("Got: \"%s\", Expected: \"%s\"\n", testStreamBuf, testStr);
+ }
+
+ inTestStream >> inStr >> inStr2;
+ if (inStr.compare(thisMu) != 0) {
+ u_austrncpy(inStrC, inStr.getBuffer(), inStr.length());
+ inStrC[inStr.length()] = 0;
+ log_err("Got: \"%s\", Expected: \"tHis\\u03BC\"\n", inStrC);
+ }
+ if (inStr2.compare(mu) != 0) {
+ u_austrncpy(inStrC, inStr.getBuffer(), inStr.length());
+ inStrC[inStr.length()] = 0;
+ log_err("Got: \"%s\", Expected: \"mu\"\n", inStrC);
+ }
+
+ /* return the default converter to the original state. */
+ ucnv_setDefaultName(defConvName);
+ defConv = u_getDefaultConverter(&status);
+ if (U_FAILURE(status)) {
+ log_err("Can't get default converter");
+ return;
+ }
+ ucnv_close(defConv);
+#else
+ log_info("U_IOSTREAM_SOURCE is disabled\n");
+#endif
+}
+U_CDECL_END
+
+U_CFUNC void addStreamTests(TestNode** root) {
+ addTest(root, &TestStream, "stream/TestStream");
+}
+
Property changes on: trunk/source/test/iotest/stream.cpp
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/source/test/iotest/strtst.c
===================================================================
--- trunk/source/test/iotest/strtst.c 2006-12-21 11:09:23 UTC (rev 127)
+++ trunk/source/test/iotest/strtst.c 2006-12-21 11:10:34 UTC (rev 128)
@@ -1,790 +1,790 @@
-/*
-**********************************************************************
-* Copyright (C) 2004-2006, International Business Machines
-* Corporation and others. All Rights Reserved.
-**********************************************************************
-* file name: strtst.c
-* encoding: US-ASCII
-* tab size: 8 (not used)
-* indentation:4
-*
-* created on: 2004apr06
-* created by: George Rhoten
-*/
-
-#include "unicode/ustdio.h"
-#include "unicode/ustring.h"
-#include "iotest.h"
-
-#include <string.h>
-
-static void TestString(void) {
-#if !UCONFIG_NO_FORMATTING
- int32_t n[1];
- float myFloat = -1234.0;
- int32_t newValuePtr[1];
- double newDoubleValuePtr[1];
- UChar myUString[512];
- UChar uStringBuf[512];
- char myString[512] = "";
- int32_t retVal;
- void *origPtr, *ptr;
- U_STRING_DECL(myStringOrig, "My-String", 9);
-
- U_STRING_INIT(myStringOrig, "My-String", 9);
- u_memset(myUString, 0x0a, sizeof(myUString)/ sizeof(*myUString));
- u_memset(uStringBuf, 0x0a, sizeof(uStringBuf) / sizeof(*uStringBuf));
-
- *n = -1234;
- if (sizeof(void *) == 4) {
- origPtr = (void *)0xdeadbeef;
- } else if (sizeof(void *) == 8) {
- origPtr = (void *) INT64_C(0x1000200030004000);
- } else if (sizeof(void *) == 16) {
- /* iSeries */
- union {
- int32_t arr[4];
- void *ptr;
- } massiveBigEndianPtr = {{ 0x10002000, 0x30004000, 0x50006000, 0x70008000 }};
- origPtr = massiveBigEndianPtr.ptr;
- } else {
- log_err("sizeof(void*)=%d hasn't been tested before", (int)sizeof(void*));
- }
-
- /* Test sprintf */
- u_sprintf(uStringBuf, "Signed decimal integer d: %d", *n);
- *newValuePtr = 1;
- u_sscanf(uStringBuf, "Signed decimal integer d: %d", newValuePtr);
- if (*n != *newValuePtr) {
- log_err("%%d Got: %d, Expected: %d\n", *newValuePtr, *n);
- }
-
- u_sprintf(uStringBuf, "Signed decimal integer i: %i", *n);
- *newValuePtr = 1;
- u_sscanf(uStringBuf, "Signed decimal integer i: %i", newValuePtr);
- if (*n != *newValuePtr) {
- log_err("%%i Got: %i, Expected: %i\n", *newValuePtr, *n);
- }
-
- u_sprintf(uStringBuf, "Unsigned octal integer o: %o", *n);
- *newValuePtr = 1;
- u_sscanf(uStringBuf, "Unsigned octal integer o: %o", newValuePtr);
- if (*n != *newValuePtr) {
- log_err("%%o Got: %o, Expected: %o\n", *newValuePtr, *n);
- }
-
- u_sprintf(uStringBuf, "Unsigned decimal integer %%u: %u", *n);
- *newValuePtr = 1;
- u_sscanf(uStringBuf, "Unsigned decimal integer %%u: %u", newValuePtr);
- if (*n != *newValuePtr) {
- log_err("%%u Got: %u, Expected: %u\n", *newValuePtr, *n);
- }
-
- u_sprintf(uStringBuf, "Lowercase unsigned hexadecimal integer x: %x", *n);
- *newValuePtr = 1;
- u_sscanf(uStringBuf, "Lowercase unsigned hexadecimal integer x: %x", newValuePtr);
- if (*n != *newValuePtr) {
- log_err("%%x Got: %x, Expected: %x\n", *newValuePtr, *n);
- }
-
- u_sprintf(uStringBuf, "Uppercase unsigned hexadecimal integer X: %X", *n);
- *newValuePtr = 1;
- u_sscanf(uStringBuf, "Uppercase unsigned hexadecimal integer X: %X", newValuePtr);
- if (*n != *newValuePtr) {
- log_err("%%X Got: %X, Expected: %X\n", *newValuePtr, *n);
- }
-
- u_sprintf(uStringBuf, "Float f: %f", myFloat);
- *newDoubleValuePtr = -1.0;
- u_sscanf(uStringBuf, "Float f: %lf", newDoubleValuePtr);
- if (myFloat != *newDoubleValuePtr) {
- log_err("%%f Got: %f, Expected: %f\n", *newDoubleValuePtr, myFloat);
- }
-
- u_sprintf(uStringBuf, "Lowercase float e: %e", myFloat);
- *newDoubleValuePtr = -1.0;
- u_sscanf(uStringBuf, "Lowercase float e: %le", newDoubleValuePtr);
- if (myFloat != *newDoubleValuePtr) {
- log_err("%%e Got: %e, Expected: %e\n", *newDoubleValuePtr, myFloat);
- }
-
- u_sprintf(uStringBuf, "Uppercase float E: %E", myFloat);
- *newDoubleValuePtr = -1.0;
- u_sscanf(uStringBuf, "Uppercase float E: %lE", newDoubleValuePtr);
- if (myFloat != *newDoubleValuePtr) {
- log_err("%%E Got: %E, Expected: %E\n", *newDoubleValuePtr, myFloat);
- }
-
- u_sprintf(uStringBuf, "Lowercase float g: %g", myFloat);
- *newDoubleValuePtr = -1.0;
- u_sscanf(uStringBuf, "Lowercase float g: %lg", newDoubleValuePtr);
- if (myFloat != *newDoubleValuePtr) {
- log_err("%%g Got: %g, Expected: %g\n", *newDoubleValuePtr, myFloat);
- }
-
- u_sprintf(uStringBuf, "Uppercase float G: %G", myFloat);
- *newDoubleValuePtr = -1.0;
- u_sscanf(uStringBuf, "Uppercase float G: %lG", newDoubleValuePtr);
- if (myFloat != *newDoubleValuePtr) {
- log_err("%%G Got: %G, Expected: %G\n", *newDoubleValuePtr, myFloat);
- }
-
- ptr = NULL;
- u_sprintf(uStringBuf, "Pointer %%p: %p\n", origPtr);
- u_sscanf(uStringBuf, "Pointer %%p: %p\n", &ptr);
- if (ptr != origPtr || u_strlen(uStringBuf) != 13+(sizeof(void*)*2)) {
- log_err("%%p Got: %p, Expected: %p\n", ptr, origPtr);
- }
-
- u_sprintf(uStringBuf, "Char c: %c", 'A');
- u_sscanf(uStringBuf, "Char c: %c", myString);
- if (*myString != 'A') {
- log_err("%%c Got: %c, Expected: A\n", *myString);
- }
-
- u_sprintf(uStringBuf, "UChar %%C: %C", (UChar)0x0041); /*'A'*/
- u_sscanf(uStringBuf, "UChar %%C: %C", myUString);
- if (*myUString != (UChar)0x0041) { /*'A'*/
- log_err("%%C Got: %C, Expected: A\n", *myUString);
- }
-
- u_sprintf(uStringBuf, "String %%s: %s", "My-String");
- u_sscanf(uStringBuf, "String %%s: %s", myString);
- if (strcmp(myString, "My-String")) {
- log_err("%%s Got: %s, Expected: My-String\n", myString);
- }
- if (uStringBuf[20] != 0) {
- log_err("String not terminated. Got %c\n", uStringBuf[20] );
- }
- u_sprintf(uStringBuf, "NULL String %%s: %s", NULL);
- u_sscanf(uStringBuf, "NULL String %%s: %s", myString);
- if (strcmp(myString, "(null)")) {
- log_err("%%s Got: %s, Expected: My-String\n", myString);
- }
-
- u_sprintf(uStringBuf, "Unicode String %%S: %S", myStringOrig);
- u_sscanf(uStringBuf, "Unicode String %%S: %S", myUString);
- u_austrncpy(myString, myUString, sizeof(myString)/sizeof(*myString));
- if (strcmp(myString, "My-String")) {
- log_err("%%S Got: %s, Expected: My String\n", myString);
- }
-
- u_sprintf(uStringBuf, "NULL Unicode String %%S: %S", NULL);
- u_sscanf(uStringBuf, "NULL Unicode String %%S: %S", myUString);
- u_austrncpy(myString, myUString, sizeof(myString)/sizeof(*myString));
- if (strcmp(myString, "(null)")) {
- log_err("%%S Got: %s, Expected: (null)\n", myString);
- }
-
- u_sprintf(uStringBuf, "Percent %%P (non-ANSI): %P", myFloat);
- *newDoubleValuePtr = -1.0;
- u_sscanf(uStringBuf, "Percent %%P (non-ANSI): %P", newDoubleValuePtr);
- if (myFloat != *newDoubleValuePtr) {
- log_err("%%P Got: %P, Expected: %P\n", *newDoubleValuePtr, myFloat);
- }
-
- u_sprintf(uStringBuf, "Spell Out %%V (non-ANSI): %V", myFloat);
- *newDoubleValuePtr = -1.0;
- u_sscanf(uStringBuf, "Spell Out %%V (non-ANSI): %V", newDoubleValuePtr);
- if (myFloat != *newDoubleValuePtr) {
- log_err("%%V Got: %f, Expected: %f\n", *newDoubleValuePtr, myFloat);
- }
-
- *newValuePtr = 1;
- u_sprintf(uStringBuf, "\t\nPointer to integer (Count) %%n: n=%d %n n=%d\n", *newValuePtr, newValuePtr, *newValuePtr);
- if (*newValuePtr != 37) {
- log_err("%%V Got: %f, Expected: %f\n", *newDoubleValuePtr, myFloat);
- }
-
-/* u_sscanf(uStringBuf, "Pointer %%p: %p\n", myFile);*/
-
- {
- static const char longStr[] = "This is a long test12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890";
-
- retVal = u_sprintf(uStringBuf, longStr);
- u_austrncpy(myString, uStringBuf, sizeof(uStringBuf)/sizeof(*uStringBuf));
- if (strcmp(myString, longStr)) {
- log_err("%%S Got: %s, Expected: %s\n", myString, longStr);
- }
- if (retVal != (int32_t)strlen(longStr)) {
- log_err("%%S returned different sizes. Got: %d Expected: %d\n", retVal, strlen(longStr));
- }
-
- retVal = u_sprintf(uStringBuf, "%s", longStr);
- u_austrncpy(myString, uStringBuf, sizeof(uStringBuf)/sizeof(*uStringBuf));
- if (strcmp(myString, longStr)) {
- log_err("%%S Got: %s, Expected: %s\n", myString, longStr);
- }
- if (retVal != (int32_t)strlen(longStr)) {
- log_err("%%S returned different sizes. Got: %d Expected: %d\n", retVal, strlen(longStr));
- }
-
- u_uastrncpy(myUString, longStr, sizeof(longStr)/sizeof(*longStr));
- u_sprintf_u(uStringBuf, myUString);
- if (u_strcmp(myUString, uStringBuf)) {
- log_err("%%S Long strings differ. Expected: %s\n", longStr);
- }
-
- u_uastrncpy(myUString, longStr, sizeof(longStr)/sizeof(*longStr));
- retVal = u_sprintf_u(uStringBuf, myUString+10);
- if (u_strcmp(myUString+10, uStringBuf)) {
- log_err("%%S Long strings differ. Expected: %s\n", longStr + 10);
- }
- if (retVal != (int32_t)strlen(longStr + 10)) {
- log_err("%%S returned different sizes. Got: %d Expected: %d\n", retVal, strlen(longStr));
- }
-
- u_memset(uStringBuf, 1, sizeof(longStr)/sizeof(*longStr));
- u_uastrncpy(myUString, longStr, sizeof(longStr)/sizeof(*longStr));
- retVal = u_snprintf_u(uStringBuf, 10, myUString);
- if (u_strncmp(myUString, uStringBuf, 10) || uStringBuf[10] != 1 || retVal != 10) {
- log_err("%%S Long strings differ. Expected the first 10 characters of %s\n", longStr);
- }
- }
-#endif
-}
-
-static void TestLocalizedString(void) {
-#if !UCONFIG_NO_FORMATTING
- UChar testStr[256];
- UChar uBuffer[256];
- char cBuffer[256];
- int32_t numResult = -1;
- const char *locale;
- UFILE *strFile = u_fstropen(testStr, sizeof(testStr)/sizeof(testStr[0]), "en_US");
-
- if (!strFile) {
- log_err("u_fstropen failed to work\n");
- return;
- }
- u_fprintf(strFile, "%d", 1234);
- u_frewind(strFile);
- u_fscanf(strFile, "%d", &numResult);
- u_uastrcpy(uBuffer,"1,234");
- u_austrcpy(cBuffer,testStr);
- if (u_strcmp(testStr, uBuffer) != 0) {
- log_err("u_fprintf failed to work on an en string Got: %s\n", cBuffer);
- }
- if (numResult != 1234) {
- log_err("u_fscanf failed to work on an en string Got: %d\n", numResult);
- }
-
- u_frewind(strFile);
- locale = u_fgetlocale(strFile);
- if (locale == NULL || strcmp(locale, "en_US") != 0) {
- log_err("u_fgetlocale didn't return \"en\" Got: %d\n", u_fgetlocale(strFile));
- }
- u_fsetlocale(strFile, "de_DE");
- locale = u_fgetlocale(strFile);
- if (locale == NULL || strcmp(locale, "de_DE") != 0) {
- log_err("u_fgetlocale didn't return \"de\" Got: %d\n", u_fgetlocale(strFile));
- }
-
- u_fprintf(strFile, "%d", 1234);
- u_frewind(strFile);
- numResult = -1;
- u_fscanf(strFile, "%d", &numResult);
- u_fclose(strFile);
- u_uastrcpy(uBuffer,"1.234");
- u_austrcpy(cBuffer,testStr);
- if (u_strcmp(testStr, uBuffer) != 0) {
- log_err("u_fprintf failed to work on a de string Got: %s\n", cBuffer);
- }
- if (numResult != 1234) {
- log_err("u_fscanf failed to work on a de string Got: %d\n", numResult);
- }
-
- strFile = u_fstropen(testStr, sizeof(testStr)/sizeof(testStr[0]), NULL);
- u_fprintf(strFile, "%d", 1234);
- u_frewind(strFile);
- numResult = -1;
- u_fscanf(strFile, "%d", &numResult);
- u_fclose(strFile);
- if (numResult != 1234) {
- log_err("u_fscanf failed to work on a default locale string Got: %d, Expected: 1234\n", numResult);
- }
- if (u_fstropen(testStr, -1, NULL) != NULL) {
- log_err("u_fstropen returned a UFILE* on a negative buffer size\n", numResult);
- }
-#endif
-}
-
-#if !UCONFIG_NO_FORMATTING
-#define Test_u_snprintf(limit, format, value, expectedSize, expectedStr) \
- u_uastrncpy(testStr, "xxxxxxxxxxxxxx", sizeof(testStr)/sizeof(testStr[0]));\
- size = u_snprintf(testStr, limit, format, value);\
- u_austrncpy(cTestResult, testStr, sizeof(cTestResult)/sizeof(cTestResult[0]));\
- if (size != expectedSize || strcmp(cTestResult, expectedStr) != 0) {\
- log_err("Unexpected formatting. size=%d expectedSize=%d cTestResult=%s expectedStr=%s\n",\
- size, expectedSize, cTestResult, expectedStr);\
- }\
- else {\
- log_verbose("Got: %s\n", cTestResult);\
- }\
-
-#endif
-
-static void TestSnprintf(void) {
-#if !UCONFIG_NO_FORMATTING
- UChar testStr[256];
- char cTestResult[256];
- int32_t size;
-
- Test_u_snprintf(0, "%d", 123, 0, "xxxxxxxxxxxxxx");
- Test_u_snprintf(2, "%d", 123, 2, "12xxxxxxxxxxxx");
- Test_u_snprintf(3, "%d", 123, 3, "123xxxxxxxxxxx");
- Test_u_snprintf(4, "%d", 123, 3, "123");
-
- Test_u_snprintf(0, "%s", "abcd", 0, "xxxxxxxxxxxxxx");
- Test_u_snprintf(3, "%s", "abcd", 3, "abcxxxxxxxxxxx");
- Test_u_snprintf(4, "%s", "abcd", 4, "abcdxxxxxxxxxx");
- Test_u_snprintf(5, "%s", "abcd", 4, "abcd");
-
- Test_u_snprintf(0, "%e", 12.34, 0, "xxxxxxxxxxxxxx");
- Test_u_snprintf(1, "%e", 12.34, 1, "1xxxxxxxxxxxxx");
- Test_u_snprintf(2, "%e", 12.34, 2, "1.xxxxxxxxxxxx");
- Test_u_snprintf(3, "%e", 12.34, 3, "1.2xxxxxxxxxxx");
- Test_u_snprintf(5, "%e", 12.34, 5, "1.234xxxxxxxxx");
- Test_u_snprintf(6, "%e", 12.34, 6, "1.2340xxxxxxxx");
- Test_u_snprintf(8, "%e", 12.34, 8, "1.234000xxxxxx");
- Test_u_snprintf(9, "%e", 12.34, 9, "1.234000exxxxx");
- Test_u_snprintf(10, "%e", 12.34, 10, "1.234000e+xxxx");
- Test_u_snprintf(11, "%e", 12.34, 11, "1.234000e+0xxx");
- Test_u_snprintf(13, "%e", 12.34, 13, "1.234000e+001x");
- Test_u_snprintf(14, "%e", 12.34, 13, "1.234000e+001");
-#endif
-}
-
-#define TestSPrintFormat(uFormat, uValue, cFormat, cValue) \
- /* Reinitialize the buffer to verify null termination works. */\
- u_memset(uBuffer, 0x2a, sizeof(uBuffer)/sizeof(*uBuffer));\
- memset(buffer, '*', sizeof(buffer)/sizeof(*buffer));\
- \
- uNumPrinted = u_sprintf(uBuffer, uFormat, uValue);\
- u_austrncpy(compBuffer, uBuffer, sizeof(uBuffer)/sizeof(uBuffer[0]));\
- cNumPrinted = sprintf(buffer, cFormat, cValue);\
- if (strcmp(buffer, compBuffer) != 0) {\
- log_err("%" uFormat " Got: \"%s\", Expected: \"%s\"\n", compBuffer, buffer);\
- }\
- if (cNumPrinted != uNumPrinted) {\
- log_err("%" uFormat " number printed Got: %d, Expected: %d\n", uNumPrinted, cNumPrinted);\
- }\
- if (buffer[uNumPrinted+1] != '*') {\
- log_err("%" uFormat " too much stored\n");\
- }\
-
-static void TestSprintfFormat(void) {
-#if !UCONFIG_NO_FORMATTING
- static const UChar abcUChars[] = {0x61,0x62,0x63,0};
- static const char abcChars[] = "abc";
- UChar uBuffer[256];
- char buffer[256];
- char compBuffer[256];
- int32_t uNumPrinted;
- int32_t cNumPrinted;
-
-
- TestSPrintFormat("%8S", abcUChars, "%8s", abcChars);
- TestSPrintFormat("%-8S", abcUChars, "%-8s", abcChars);
- TestSPrintFormat("%.2S", abcUChars, "%.2s", abcChars); /* strlen is 3 */
-
- TestSPrintFormat("%8s", abcChars, "%8s", abcChars);
- TestSPrintFormat("%-8s", abcChars, "%-8s", abcChars);
- TestSPrintFormat("%.2s", abcChars, "%.2s", abcChars); /* strlen is 3 */
-
- TestSPrintFormat("%8c", (char)'e', "%8c", (char)'e');
- TestSPrintFormat("%-8c", (char)'e', "%-8c", (char)'e');
-
- TestSPrintFormat("%8C", (UChar)0x65, "%8c", (char)'e');
- TestSPrintFormat("%-8C", (UChar)0x65, "%-8c", (char)'e');
-
- TestSPrintFormat("%f", 1.23456789, "%f", 1.23456789);
- TestSPrintFormat("%f", 12345.6789, "%f", 12345.6789);
- TestSPrintFormat("%f", 123456.789, "%f", 123456.789);
- TestSPrintFormat("%f", 1234567.89, "%f", 1234567.89);
- TestSPrintFormat("%10f", 1.23456789, "%10f", 1.23456789);
- TestSPrintFormat("%-10f", 1.23456789, "%-10f", 1.23456789);
- TestSPrintFormat("%10f", 123.456789, "%10f", 123.456789);
- TestSPrintFormat("%10.4f", 123.456789, "%10.4f", 123.456789);
- TestSPrintFormat("%-10f", 123.456789, "%-10f", 123.456789);
-
-/* TestSPrintFormat("%g", 12345.6789, "%g", 12345.6789);
- TestSPrintFormat("%g", 123456.789, "%g", 123456.789);
- TestSPrintFormat("%g", 1234567.89, "%g", 1234567.89);
- TestSPrintFormat("%G", 123456.789, "%G", 123456.789);
- TestSPrintFormat("%G", 1234567.89, "%G", 1234567.89);*/
- TestSPrintFormat("%10g", 1.23456789, "%10g", 1.23456789);
- TestSPrintFormat("%10.4g", 1.23456789, "%10.4g", 1.23456789);
- TestSPrintFormat("%-10g", 1.23456789, "%-10g", 1.23456789);
- TestSPrintFormat("%10g", 123.456789, "%10g", 123.456789);
- TestSPrintFormat("%-10g", 123.456789, "%-10g", 123.456789);
-
- TestSPrintFormat("%8x", 123456, "%8x", 123456);
- TestSPrintFormat("%-8x", 123456, "%-8x", 123456);
- TestSPrintFormat("%08x", 123456, "%08x", 123456);
-
- TestSPrintFormat("%8X", 123456, "%8X", 123456);
- TestSPrintFormat("%-8X", 123456, "%-8X", 123456);
- TestSPrintFormat("%08X", 123456, "%08X", 123456);
- TestSPrintFormat("%#x", 123456, "%#x", 123456);
- TestSPrintFormat("%#x", -123456, "%#x", -123456);
-
- TestSPrintFormat("%8o", 123456, "%8o", 123456);
- TestSPrintFormat("%-8o", 123456, "%-8o", 123456);
- TestSPrintFormat("%08o", 123456, "%08o", 123456);
- TestSPrintFormat("%#o", 123, "%#o", 123);
- TestSPrintFormat("%#o", -123, "%#o", -123);
-
- TestSPrintFormat("%8u", 123456, "%8u", 123456);
- TestSPrintFormat("%-8u", 123456, "%-8u", 123456);
- TestSPrintFormat("%08u", 123456, "%08u", 123456);
- TestSPrintFormat("%8u", -123456, "%8u", -123456);
- TestSPrintFormat("%-8u", -123456, "%-8u", -123456);
- TestSPrintFormat("%.5u", 123456, "%.5u", 123456);
- TestSPrintFormat("%.6u", 123456, "%.6u", 123456);
- TestSPrintFormat("%.7u", 123456, "%.7u", 123456);
-
- TestSPrintFormat("%8d", 123456, "%8d", 123456);
- TestSPrintFormat("%-8d", 123456, "%-8d", 123456);
- TestSPrintFormat("%08d", 123456, "%08d", 123456);
- TestSPrintFormat("% d", 123456, "% d", 123456);
- TestSPrintFormat("% d", -123456, "% d", -123456);
-
- TestSPrintFormat("%8i", 123456, "%8i", 123456);
- TestSPrintFormat("%-8i", 123456, "%-8i", 123456);
- TestSPrintFormat("%08i", 123456, "%08i", 123456);
-
- log_verbose("Get really crazy with the formatting.\n");
-
- TestSPrintFormat("%-#12x", 123, "%-#12x", 123);
- TestSPrintFormat("%-#12x", -123, "%-#12x", -123);
- TestSPrintFormat("%#12x", 123, "%#12x", 123);
- TestSPrintFormat("%#12x", -123, "%#12x", -123);
-
- TestSPrintFormat("%-+12d", 123, "%-+12d", 123);
- TestSPrintFormat("%-+12d", -123, "%-+12d", -123);
- TestSPrintFormat("%- 12d", 123, "%- 12d", 123);
- TestSPrintFormat("%- 12d", -123, "%- 12d", -123);
- TestSPrintFormat("%+12d", 123, "%+12d", 123);
- TestSPrintFormat("%+12d", -123, "%+12d", -123);
- TestSPrintFormat("% 12d", 123, "% 12d", 123);
- TestSPrintFormat("% 12d", -123, "% 12d", -123);
- TestSPrintFormat("%12d", 123, "%12d", 123);
- TestSPrintFormat("%12d", -123, "%12d", -123);
- TestSPrintFormat("%.12d", 123, "%.12d", 123);
- TestSPrintFormat("%.12d", -123, "%.12d", -123);
-
- TestSPrintFormat("%-+12.1f", 1.234, "%-+12.1f", 1.234);
- TestSPrintFormat("%-+12.1f", -1.234, "%-+12.1f", -1.234);
- TestSPrintFormat("%- 12.10f", 1.234, "%- 12.10f", 1.234);
- TestSPrintFormat("%- 12.1f", -1.234, "%- 12.1f", -1.234);
- TestSPrintFormat("%+12.1f", 1.234, "%+12.1f", 1.234);
- TestSPrintFormat("%+12.1f", -1.234, "%+12.1f", -1.234);
- TestSPrintFormat("% 12.1f", 1.234, "% 12.1f", 1.234);
- TestSPrintFormat("% 12.1f", -1.234, "% 12.1f", -1.234);
- TestSPrintFormat("%12.1f", 1.234, "%12.1f", 1.234);
- TestSPrintFormat("%12.1f", -1.234, "%12.1f", -1.234);
- TestSPrintFormat("%.2f", 1.234, "%.2f", 1.234);
- TestSPrintFormat("%.2f", -1.234, "%.2f", -1.234);
- TestSPrintFormat("%3f", 1.234, "%3f", 1.234);
- TestSPrintFormat("%3f", -1.234, "%3f", -1.234);
-#endif
-}
-
-#undef TestSPrintFormat
-
-static void TestStringCompatibility(void) {
-#if !UCONFIG_NO_FORMATTING
- UChar myUString[256];
- UChar uStringBuf[256];
- char myString[256] = "";
- char testBuf[256] = "";
- int32_t num;
-
- u_memset(myUString, 0x0a, sizeof(myUString)/ sizeof(*myUString));
- u_memset(uStringBuf, 0x0a, sizeof(uStringBuf) / sizeof(*uStringBuf));
-
- /* Compare against C API compatibility */
- for (num = -STANDARD_TEST_NUM_RANGE; num < STANDARD_TEST_NUM_RANGE; num++) {
- sprintf(testBuf, "%x", (int)num);
- u_sprintf(uStringBuf, "%x", num);
- u_austrncpy(myString, uStringBuf, sizeof(myString)/sizeof(myString[0]));
- if (strcmp(myString, testBuf) != 0) {
- log_err("%%x Got: \"%s\", Expected: \"%s\"\n", myString, testBuf);
- }
-
- sprintf(testBuf, "%X", (int)num);
- u_sprintf(uStringBuf, "%X", num);
- u_austrncpy(myString, uStringBuf, sizeof(myString)/sizeof(myString[0]));
- if (strcmp(myString, testBuf) != 0) {
- log_err("%%X Got: \"%s\", Expected: \"%s\"\n", myString, testBuf);
- }
-
- sprintf(testBuf, "%o", (int)num);
- u_sprintf(uStringBuf, "%o", num);
- u_austrncpy(myString, uStringBuf, sizeof(myString)/sizeof(myString[0]));
- if (strcmp(myString, testBuf) != 0) {
- log_err("%%o Got: \"%s\", Expected: \"%s\"\n", myString, testBuf);
- }
-
- /* sprintf is not compatible on all platforms e.g. the iSeries*/
- sprintf(testBuf, "%d", (int)num);
- u_sprintf(uStringBuf, "%d", num);
- u_austrncpy(myString, uStringBuf, sizeof(myString)/sizeof(myString[0]));
- if (strcmp(myString, testBuf) != 0) {
- log_err("%%d Got: \"%s\", Expected: \"%s\"\n", myString, testBuf);
- }
-
- sprintf(testBuf, "%i", (int)num);
- u_sprintf(uStringBuf, "%i", num);
- u_austrncpy(myString, uStringBuf, sizeof(myString)/sizeof(myString[0]));
- if (strcmp(myString, testBuf) != 0) {
- log_err("%%i Got: \"%s\", Expected: \"%s\"\n", myString, testBuf);
- }
-
- sprintf(testBuf, "%f", (double)num);
- u_sprintf(uStringBuf, "%f", (double)num);
- u_austrncpy(myString, uStringBuf, sizeof(myString)/sizeof(myString[0]));
- if (strcmp(myString, testBuf) != 0) {
- log_err("%%f Got: \"%s\", Expected: \"%s\"\n", myString, testBuf);
- }
-
-/* sprintf(testBuf, "%e", (double)num);
- u_sprintf(uStringBuf, "%e", (double)num);
- u_austrncpy(myString, uStringBuf, sizeof(myString)/sizeof(myString[0]));
- if (strcmp(myString, testBuf) != 0) {
- log_err("%%e Got: \"%s\", Expected: \"%s\"\n", myString, testBuf);
- }
-
- sprintf(testBuf, "%E", (double)num);
- u_sprintf(uStringBuf, "%E", (double)num);
- u_austrncpy(myString, uStringBuf, sizeof(myString)/sizeof(myString[0]));
- if (strcmp(myString, testBuf) != 0) {
- log_err("%%E Got: \"%s\", Expected: \"%s\"\n", myString, testBuf);
- }*/
-
- sprintf(testBuf, "%g", (double)num);
- u_sprintf(uStringBuf, "%g", (double)num);
- u_austrncpy(myString, uStringBuf, sizeof(myString)/sizeof(myString[0]));
- if (strcmp(myString, testBuf) != 0) {
- log_err("%%g Got: \"%s\", Expected: \"%s\"\n", myString, testBuf);
- }
-
- sprintf(testBuf, "%G", (double)num);
- u_sprintf(uStringBuf, "%G", (double)num);
- u_austrncpy(myString, uStringBuf, sizeof(myString)/sizeof(myString[0]));
- if (strcmp(myString, testBuf) != 0) {
- log_err("%%G Got: \"%s\", Expected: \"%s\"\n", myString, testBuf);
- }
- }
-
- for (num = 0; num < 0x80; num++) {
- testBuf[0] = (char)0xFF;
- uStringBuf[0] = (UChar)0xfffe;
- sprintf(testBuf, "%c", (char)num);
- u_sprintf(uStringBuf, "%c", num);
- u_austrncpy(myString, uStringBuf, sizeof(myString)/sizeof(myString[0]));
- if (testBuf[0] != myString[0] || myString[0] != num) {
- log_err("%%c Got: 0x%x, Expected: 0x%x\n", myString[0], testBuf[0]);
- }
- }
-#endif
-}
-
-static void TestSScanSetFormat(const char *format, const UChar *uValue, const char *cValue, UBool expectedToPass) {
-#if !UCONFIG_NO_FORMATTING
- UChar uBuffer[256];
- char buffer[256];
- char compBuffer[256];
- int32_t uNumScanned;
- int32_t cNumScanned;
-
- /* Reinitialize the buffer to verify null termination works. */
- u_memset(uBuffer, 0x2a, sizeof(uBuffer)/sizeof(*uBuffer));
- uBuffer[sizeof(uBuffer)/sizeof(*uBuffer)-1] = 0;
- memset(buffer, '*', sizeof(buffer)/sizeof(*buffer));
- buffer[sizeof(buffer)/sizeof(*buffer)-1] = 0;
-
- uNumScanned = u_sscanf(uValue, format, uBuffer);
- if (expectedToPass) {
- u_austrncpy(compBuffer, uBuffer, sizeof(uBuffer)/sizeof(uBuffer[0]));
- cNumScanned = sscanf(cValue, format, buffer);
- if (strncmp(buffer, compBuffer, sizeof(uBuffer)/sizeof(uBuffer[0])) != 0) {
- log_err("%s Got: \"%s\", Expected: \"%s\"\n", format, compBuffer, buffer);
- }
- if (cNumScanned != uNumScanned) {
- log_err("%s number scanned Got: %d, Expected: %d\n", format, uNumScanned, cNumScanned);
- }
- if (uNumScanned > 0 && uBuffer[u_strlen(uBuffer)+1] != 0x2a) {
- log_err("%s too much stored\n", format);
- }
- }
- else {
- if (uNumScanned != 0 || uBuffer[0] != 0x2a || uBuffer[1] != 0x2a) {
- log_err("%s too much stored on a failure\n", format);
- }
- }
-#endif
-}
-
-static void TestSScanset(void) {
-#if !UCONFIG_NO_FORMATTING
- static const UChar abcUChars[] = {0x61,0x62,0x63,0x63,0x64,0x65,0x66,0x67,0};
- static const char abcChars[] = "abccdefg";
-
- TestSScanSetFormat("%[bc]S", abcUChars, abcChars, TRUE);
- TestSScanSetFormat("%[cb]S", abcUChars, abcChars, TRUE);
-
- TestSScanSetFormat("%[ab]S", abcUChars, abcChars, TRUE);
- TestSScanSetFormat("%[ba]S", abcUChars, abcChars, TRUE);
-
- TestSScanSetFormat("%[ab]", abcUChars, abcChars, TRUE);
- TestSScanSetFormat("%[ba]", abcUChars, abcChars, TRUE);
-
- TestSScanSetFormat("%[abcdefgh]", abcUChars, abcChars, TRUE);
- TestSScanSetFormat("%[;hgfedcba]", abcUChars, abcChars, TRUE);
-
- TestSScanSetFormat("%[^a]", abcUChars, abcChars, TRUE);
- TestSScanSetFormat("%[^e]", abcUChars, abcChars, TRUE);
- TestSScanSetFormat("%[^ed]", abcUChars, abcChars, TRUE);
- TestSScanSetFormat("%[^dc]", abcUChars, abcChars, TRUE);
- TestSScanSetFormat("%[^e] ", abcUChars, abcChars, TRUE);
-
- TestSScanSetFormat("%1[ab] ", abcUChars, abcChars, TRUE);
- TestSScanSetFormat("%2[^f]", abcUChars, abcChars, TRUE);
-
- TestSScanSetFormat("%[qrst]", abcUChars, abcChars, TRUE);
-
- /* Extra long string for testing */
- TestSScanSetFormat(" %[qrst]",
- abcUChars, abcChars, TRUE);
-
- TestSScanSetFormat("%[a-]", abcUChars, abcChars, TRUE);
-
- /* Bad format */
- TestSScanSetFormat("%[a", abcUChars, abcChars, FALSE);
- TestSScanSetFormat("%[f-a]", abcUChars, abcChars, FALSE);
- TestSScanSetFormat("%[c-a]", abcUChars, abcChars, FALSE);
- /* The following is not deterministic on Windows */
-/* TestSScanSetFormat("%[a-", abcUChars, abcChars);*/
-
- /* TODO: Need to specify precision with a "*" */
-#endif
-}
-
-static void TestBadSScanfFormat(const char *format, const UChar *uValue, const char *cValue) {
-#if !UCONFIG_NO_FORMATTING
- UChar uBuffer[256];
- int32_t uNumScanned;
-
- /* Reinitialize the buffer to verify null termination works. */
- u_memset(uBuffer, 0x2a, sizeof(uBuffer)/sizeof(*uBuffer));
- uBuffer[sizeof(uBuffer)/sizeof(*uBuffer)-1] = 0;
-
- uNumScanned = u_sscanf(uValue, format, uBuffer);
- if (uNumScanned != 0 || uBuffer[0] != 0x2a || uBuffer[1] != 0x2a) {
- log_err("%s too much stored on a failure\n", format);
- }
-#endif
-}
-
-static void TestBadScanfFormat(void) {
-#if !UCONFIG_NO_FORMATTING
- static const UChar abcUChars[] = {0x61,0x62,0x63,0x63,0x64,0x65,0x66,0x67,0};
- static const char abcChars[] = "abccdefg";
-
- TestBadSScanfFormat("%[] ", abcUChars, abcChars);
-#endif
-}
-
-static void Test_u_vfprintf(const char *expectedResult, const char *format, ...) {
-#if !UCONFIG_NO_FORMATTING
- UChar uBuffer[256];
- UChar uBuffer2[256];
- va_list ap;
- int32_t count;
-
- va_start(ap, format);
- count = u_vsprintf(uBuffer, format, ap);
- va_end(ap);
- u_uastrcpy(uBuffer2, expectedResult);
- if (u_strcmp(uBuffer, uBuffer2) != 0) {
- log_err("Got two different results for \"%s\" expected \"%s\"\n", format, expectedResult);
- }
-
- u_uastrcpy(uBuffer2, format);
- va_start(ap, format);
- count = u_vsprintf_u(uBuffer, uBuffer2, ap);
- va_end(ap);
- u_uastrcpy(uBuffer2, expectedResult);
- if (u_strcmp(uBuffer, uBuffer2) != 0) {
- log_err("Got two different results for \"%s\" expected \"%s\"\n", format, expectedResult);
- }
-#endif
-}
-
-static void TestVargs(void) {
-#if !UCONFIG_NO_FORMATTING
- Test_u_vfprintf("8 9 a B 8.9", "%d %u %x %X %.1f", 8, 9, 10, 11, 8.9);
-#endif
-}
-
-static void TestCount(void) {
-#if !UCONFIG_NO_FORMATTING
- static const UChar x15[] = { 0x78, 0x31, 0x35, 0 };
- UChar testStr[16];
- UChar character;
- int16_t i16 = -1;
- int32_t i32 = -1, actual_count, actual_result;
- int64_t i64 = -1;
- u_uastrcpy(testStr, "1233456789");
- if (u_sscanf(testStr, "%*3[123]%n%*[1-9]", &i32) != 0) {
- log_err("test 1: scanf did not return 0\n");
- }
- if (i32 != 3) {
- log_err("test 1: scanf returned %hd instead of 3\n", i32);
- }
- if (u_sscanf(testStr, "%*4[123]%hn%*[1-9]", &i16) != 0) {
- log_err("test 2: scanf did not return 0\n");
- }
- if (i16 != 4) {
- log_err("test 2: scanf returned %d instead of 4\n", i16);
- }
- if (u_sscanf(testStr, "%*[123]%*[1-9]%lln", &i64) != 0) {
- log_err("test 3: scanf did not return 0\n");
- }
- if (i64 != 10) {
- log_err("test 3: scanf did not return 10\n", i64);
- }
- actual_result = u_sscanf(x15, "%C%d%n", &character, &i32, &actual_count);
- if (actual_result != 2) {
- log_err("scanf should return 2, but returned %d\n", actual_result);
- }
- if (character != 0x78) {
- log_err("scanf should return 0x78 for the character, but returned %X\n", character);
- }
- if (i32 != 15) {
- log_err("scanf should return 15 for the number, but returned %d\n", i32);
- }
- if (actual_count != 3) {
- log_err("scanf should return 3 for actual_count, but returned %d\n", actual_count);
- }
-#endif
-}
-
-U_CFUNC void
-addStringTest(TestNode** root) {
-#if !UCONFIG_NO_FORMATTING
- addTest(root, &TestString, "string/TestString");
- addTest(root, &TestLocalizedString, "string/TestLocalizedString");
- addTest(root, &TestSprintfFormat, "string/TestSprintfFormat");
- addTest(root, &TestSnprintf, "string/TestSnprintf");
- addTest(root, &TestSScanset, "string/TestSScanset");
- addTest(root, &TestStringCompatibility, "string/TestStringCompatibility");
- addTest(root, &TestBadScanfFormat, "string/TestBadScanfFormat");
- addTest(root, &TestVargs, "string/TestVargs");
- addTest(root, &TestCount, "string/TestCount");
-#endif
-}
-
-
+/*
+**********************************************************************
+* Copyright (C) 2004-2006, International Business Machines
+* Corporation and others. All Rights Reserved.
+**********************************************************************
+* file name: strtst.c
+* encoding: US-ASCII
+* tab size: 8 (not used)
+* indentation:4
+*
+* created on: 2004apr06
+* created by: George Rhoten
+*/
+
+#include "unicode/ustdio.h"
+#include "unicode/ustring.h"
+#include "iotest.h"
+
+#include <string.h>
+
+static void TestString(void) {
+#if !UCONFIG_NO_FORMATTING
+ int32_t n[1];
+ float myFloat = -1234.0;
+ int32_t newValuePtr[1];
+ double newDoubleValuePtr[1];
+ UChar myUString[512];
+ UChar uStringBuf[512];
+ char myString[512] = "";
+ int32_t retVal;
+ void *origPtr, *ptr;
+ U_STRING_DECL(myStringOrig, "My-String", 9);
+
+ U_STRING_INIT(myStringOrig, "My-String", 9);
+ u_memset(myUString, 0x0a, sizeof(myUString)/ sizeof(*myUString));
+ u_memset(uStringBuf, 0x0a, sizeof(uStringBuf) / sizeof(*uStringBuf));
+
+ *n = -1234;
+ if (sizeof(void *) == 4) {
+ origPtr = (void *)0xdeadbeef;
+ } else if (sizeof(void *) == 8) {
+ origPtr = (void *) INT64_C(0x1000200030004000);
+ } else if (sizeof(void *) == 16) {
+ /* iSeries */
+ union {
+ int32_t arr[4];
+ void *ptr;
+ } massiveBigEndianPtr = {{ 0x10002000, 0x30004000, 0x50006000, 0x70008000 }};
+ origPtr = massiveBigEndianPtr.ptr;
+ } else {
+ log_err("sizeof(void*)=%d hasn't been tested before", (int)sizeof(void*));
+ }
+
+ /* Test sprintf */
+ u_sprintf(uStringBuf, "Signed decimal integer d: %d", *n);
+ *newValuePtr = 1;
+ u_sscanf(uStringBuf, "Signed decimal integer d: %d", newValuePtr);
+ if (*n != *newValuePtr) {
+ log_err("%%d Got: %d, Expected: %d\n", *newValuePtr, *n);
+ }
+
+ u_sprintf(uStringBuf, "Signed decimal integer i: %i", *n);
+ *newValuePtr = 1;
+ u_sscanf(uStringBuf, "Signed decimal integer i: %i", newValuePtr);
+ if (*n != *newValuePtr) {
+ log_err("%%i Got: %i, Expected: %i\n", *newValuePtr, *n);
+ }
+
+ u_sprintf(uStringBuf, "Unsigned octal integer o: %o", *n);
+ *newValuePtr = 1;
+ u_sscanf(uStringBuf, "Unsigned octal integer o: %o", newValuePtr);
+ if (*n != *newValuePtr) {
+ log_err("%%o Got: %o, Expected: %o\n", *newValuePtr, *n);
+ }
+
+ u_sprintf(uStringBuf, "Unsigned decimal integer %%u: %u", *n);
+ *newValuePtr = 1;
+ u_sscanf(uStringBuf, "Unsigned decimal integer %%u: %u", newValuePtr);
+ if (*n != *newValuePtr) {
+ log_err("%%u Got: %u, Expected: %u\n", *newValuePtr, *n);
+ }
+
+ u_sprintf(uStringBuf, "Lowercase unsigned hexadecimal integer x: %x", *n);
+ *newValuePtr = 1;
+ u_sscanf(uStringBuf, "Lowercase unsigned hexadecimal integer x: %x", newValuePtr);
+ if (*n != *newValuePtr) {
+ log_err("%%x Got: %x, Expected: %x\n", *newValuePtr, *n);
+ }
+
+ u_sprintf(uStringBuf, "Uppercase unsigned hexadecimal integer X: %X", *n);
+ *newValuePtr = 1;
+ u_sscanf(uStringBuf, "Uppercase unsigned hexadecimal integer X: %X", newValuePtr);
+ if (*n != *newValuePtr) {
+ log_err("%%X Got: %X, Expected: %X\n", *newValuePtr, *n);
+ }
+
+ u_sprintf(uStringBuf, "Float f: %f", myFloat);
+ *newDoubleValuePtr = -1.0;
+ u_sscanf(uStringBuf, "Float f: %lf", newDoubleValuePtr);
+ if (myFloat != *newDoubleValuePtr) {
+ log_err("%%f Got: %f, Expected: %f\n", *newDoubleValuePtr, myFloat);
+ }
+
+ u_sprintf(uStringBuf, "Lowercase float e: %e", myFloat);
+ *newDoubleValuePtr = -1.0;
+ u_sscanf(uStringBuf, "Lowercase float e: %le", newDoubleValuePtr);
+ if (myFloat != *newDoubleValuePtr) {
+ log_err("%%e Got: %e, Expected: %e\n", *newDoubleValuePtr, myFloat);
+ }
+
+ u_sprintf(uStringBuf, "Uppercase float E: %E", myFloat);
+ *newDoubleValuePtr = -1.0;
+ u_sscanf(uStringBuf, "Uppercase float E: %lE", newDoubleValuePtr);
+ if (myFloat != *newDoubleValuePtr) {
+ log_err("%%E Got: %E, Expected: %E\n", *newDoubleValuePtr, myFloat);
+ }
+
+ u_sprintf(uStringBuf, "Lowercase float g: %g", myFloat);
+ *newDoubleValuePtr = -1.0;
+ u_sscanf(uStringBuf, "Lowercase float g: %lg", newDoubleValuePtr);
+ if (myFloat != *newDoubleValuePtr) {
+ log_err("%%g Got: %g, Expected: %g\n", *newDoubleValuePtr, myFloat);
+ }
+
+ u_sprintf(uStringBuf, "Uppercase float G: %G", myFloat);
+ *newDoubleValuePtr = -1.0;
+ u_sscanf(uStringBuf, "Uppercase float G: %lG", newDoubleValuePtr);
+ if (myFloat != *newDoubleValuePtr) {
+ log_err("%%G Got: %G, Expected: %G\n", *newDoubleValuePtr, myFloat);
+ }
+
+ ptr = NULL;
+ u_sprintf(uStringBuf, "Pointer %%p: %p\n", origPtr);
+ u_sscanf(uStringBuf, "Pointer %%p: %p\n", &ptr);
+ if (ptr != origPtr || u_strlen(uStringBuf) != 13+(sizeof(void*)*2)) {
+ log_err("%%p Got: %p, Expected: %p\n", ptr, origPtr);
+ }
+
+ u_sprintf(uStringBuf, "Char c: %c", 'A');
+ u_sscanf(uStringBuf, "Char c: %c", myString);
+ if (*myString != 'A') {
+ log_err("%%c Got: %c, Expected: A\n", *myString);
+ }
+
+ u_sprintf(uStringBuf, "UChar %%C: %C", (UChar)0x0041); /*'A'*/
+ u_sscanf(uStringBuf, "UChar %%C: %C", myUString);
+ if (*myUString != (UChar)0x0041) { /*'A'*/
+ log_err("%%C Got: %C, Expected: A\n", *myUString);
+ }
+
+ u_sprintf(uStringBuf, "String %%s: %s", "My-String");
+ u_sscanf(uStringBuf, "String %%s: %s", myString);
+ if (strcmp(myString, "My-String")) {
+ log_err("%%s Got: %s, Expected: My-String\n", myString);
+ }
+ if (uStringBuf[20] != 0) {
+ log_err("String not terminated. Got %c\n", uStringBuf[20] );
+ }
+ u_sprintf(uStringBuf, "NULL String %%s: %s", NULL);
+ u_sscanf(uStringBuf, "NULL String %%s: %s", myString);
+ if (strcmp(myString, "(null)")) {
+ log_err("%%s Got: %s, Expected: My-String\n", myString);
+ }
+
+ u_sprintf(uStringBuf, "Unicode String %%S: %S", myStringOrig);
+ u_sscanf(uStringBuf, "Unicode String %%S: %S", myUString);
+ u_austrncpy(myString, myUString, sizeof(myString)/sizeof(*myString));
+ if (strcmp(myString, "My-String")) {
+ log_err("%%S Got: %s, Expected: My String\n", myString);
+ }
+
+ u_sprintf(uStringBuf, "NULL Unicode String %%S: %S", NULL);
+ u_sscanf(uStringBuf, "NULL Unicode String %%S: %S", myUString);
+ u_austrncpy(myString, myUString, sizeof(myString)/sizeof(*myString));
+ if (strcmp(myString, "(null)")) {
+ log_err("%%S Got: %s, Expected: (null)\n", myString);
+ }
+
+ u_sprintf(uStringBuf, "Percent %%P (non-ANSI): %P", myFloat);
+ *newDoubleValuePtr = -1.0;
+ u_sscanf(uStringBuf, "Percent %%P (non-ANSI): %P", newDoubleValuePtr);
+ if (myFloat != *newDoubleValuePtr) {
+ log_err("%%P Got: %P, Expected: %P\n", *newDoubleValuePtr, myFloat);
+ }
+
+ u_sprintf(uStringBuf, "Spell Out %%V (non-ANSI): %V", myFloat);
+ *newDoubleValuePtr = -1.0;
+ u_sscanf(uStringBuf, "Spell Out %%V (non-ANSI): %V", newDoubleValuePtr);
+ if (myFloat != *newDoubleValuePtr) {
+ log_err("%%V Got: %f, Expected: %f\n", *newDoubleValuePtr, myFloat);
+ }
+
+ *newValuePtr = 1;
+ u_sprintf(uStringBuf, "\t\nPointer to integer (Count) %%n: n=%d %n n=%d\n", *newValuePtr, newValuePtr, *newValuePtr);
+ if (*newValuePtr != 37) {
+ log_err("%%V Got: %f, Expected: %f\n", *newDoubleValuePtr, myFloat);
+ }
+
+/* u_sscanf(uStringBuf, "Pointer %%p: %p\n", myFile);*/
+
+ {
+ static const char longStr[] = "This is a long test12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890";
+
+ retVal = u_sprintf(uStringBuf, longStr);
+ u_austrncpy(myString, uStringBuf, sizeof(uStringBuf)/sizeof(*uStringBuf));
+ if (strcmp(myString, longStr)) {
+ log_err("%%S Got: %s, Expected: %s\n", myString, longStr);
+ }
+ if (retVal != (int32_t)strlen(longStr)) {
+ log_err("%%S returned different sizes. Got: %d Expected: %d\n", retVal, strlen(longStr));
+ }
+
+ retVal = u_sprintf(uStringBuf, "%s", longStr);
+ u_austrncpy(myString, uStringBuf, sizeof(uStringBuf)/sizeof(*uStringBuf));
+ if (strcmp(myString, longStr)) {
+ log_err("%%S Got: %s, Expected: %s\n", myString, longStr);
+ }
+ if (retVal != (int32_t)strlen(longStr)) {
+ log_err("%%S returned different sizes. Got: %d Expected: %d\n", retVal, strlen(longStr));
+ }
+
+ u_uastrncpy(myUString, longStr, sizeof(longStr)/sizeof(*longStr));
+ u_sprintf_u(uStringBuf, myUString);
+ if (u_strcmp(myUString, uStringBuf)) {
+ log_err("%%S Long strings differ. Expected: %s\n", longStr);
+ }
+
+ u_uastrncpy(myUString, longStr, sizeof(longStr)/sizeof(*longStr));
+ retVal = u_sprintf_u(uStringBuf, myUString+10);
+ if (u_strcmp(myUString+10, uStringBuf)) {
+ log_err("%%S Long strings differ. Expected: %s\n", longStr + 10);
+ }
+ if (retVal != (int32_t)strlen(longStr + 10)) {
+ log_err("%%S returned different sizes. Got: %d Expected: %d\n", retVal, strlen(longStr));
+ }
+
+ u_memset(uStringBuf, 1, sizeof(longStr)/sizeof(*longStr));
+ u_uastrncpy(myUString, longStr, sizeof(longStr)/sizeof(*longStr));
+ retVal = u_snprintf_u(uStringBuf, 10, myUString);
+ if (u_strncmp(myUString, uStringBuf, 10) || uStringBuf[10] != 1 || retVal != 10) {
+ log_err("%%S Long strings differ. Expected the first 10 characters of %s\n", longStr);
+ }
+ }
+#endif
+}
+
+static void TestLocalizedString(void) {
+#if !UCONFIG_NO_FORMATTING
+ UChar testStr[256];
+ UChar uBuffer[256];
+ char cBuffer[256];
+ int32_t numResult = -1;
+ const char *locale;
+ UFILE *strFile = u_fstropen(testStr, sizeof(testStr)/sizeof(testStr[0]), "en_US");
+
+ if (!strFile) {
+ log_err("u_fstropen failed to work\n");
+ return;
+ }
+ u_fprintf(strFile, "%d", 1234);
+ u_frewind(strFile);
+ u_fscanf(strFile, "%d", &numResult);
+ u_uastrcpy(uBuffer,"1,234");
+ u_austrcpy(cBuffer,testStr);
+ if (u_strcmp(testStr, uBuffer) != 0) {
+ log_err("u_fprintf failed to work on an en string Got: %s\n", cBuffer);
+ }
+ if (numResult != 1234) {
+ log_err("u_fscanf failed to work on an en string Got: %d\n", numResult);
+ }
+
+ u_frewind(strFile);
+ locale = u_fgetlocale(strFile);
+ if (locale == NULL || strcmp(locale, "en_US") != 0) {
+ log_err("u_fgetlocale didn't return \"en\" Got: %d\n", u_fgetlocale(strFile));
+ }
+ u_fsetlocale(strFile, "de_DE");
+ locale = u_fgetlocale(strFile);
+ if (locale == NULL || strcmp(locale, "de_DE") != 0) {
+ log_err("u_fgetlocale didn't return \"de\" Got: %d\n", u_fgetlocale(strFile));
+ }
+
+ u_fprintf(strFile, "%d", 1234);
+ u_frewind(strFile);
+ numResult = -1;
+ u_fscanf(strFile, "%d", &numResult);
+ u_fclose(strFile);
+ u_uastrcpy(uBuffer,"1.234");
+ u_austrcpy(cBuffer,testStr);
+ if (u_strcmp(testStr, uBuffer) != 0) {
+ log_err("u_fprintf failed to work on a de string Got: %s\n", cBuffer);
+ }
+ if (numResult != 1234) {
+ log_err("u_fscanf failed to work on a de string Got: %d\n", numResult);
+ }
+
+ strFile = u_fstropen(testStr, sizeof(testStr)/sizeof(testStr[0]), NULL);
+ u_fprintf(strFile, "%d", 1234);
+ u_frewind(strFile);
+ numResult = -1;
+ u_fscanf(strFile, "%d", &numResult);
+ u_fclose(strFile);
+ if (numResult != 1234) {
+ log_err("u_fscanf failed to work on a default locale string Got: %d, Expected: 1234\n", numResult);
+ }
+ if (u_fstropen(testStr, -1, NULL) != NULL) {
+ log_err("u_fstropen returned a UFILE* on a negative buffer size\n", numResult);
+ }
+#endif
+}
+
+#if !UCONFIG_NO_FORMATTING
+#define Test_u_snprintf(limit, format, value, expectedSize, expectedStr) \
+ u_uastrncpy(testStr, "xxxxxxxxxxxxxx", sizeof(testStr)/sizeof(testStr[0]));\
+ size = u_snprintf(testStr, limit, format, value);\
+ u_austrncpy(cTestResult, testStr, sizeof(cTestResult)/sizeof(cTestResult[0]));\
+ if (size != expectedSize || strcmp(cTestResult, expectedStr) != 0) {\
+ log_err("Unexpected formatting. size=%d expectedSize=%d cTestResult=%s expectedStr=%s\n",\
+ size, expectedSize, cTestResult, expectedStr);\
+ }\
+ else {\
+ log_verbose("Got: %s\n", cTestResult);\
+ }\
+
+#endif
+
+static void TestSnprintf(void) {
+#if !UCONFIG_NO_FORMATTING
+ UChar testStr[256];
+ char cTestResult[256];
+ int32_t size;
+
+ Test_u_snprintf(0, "%d", 123, 0, "xxxxxxxxxxxxxx");
+ Test_u_snprintf(2, "%d", 123, 2, "12xxxxxxxxxxxx");
+ Test_u_snprintf(3, "%d", 123, 3, "123xxxxxxxxxxx");
+ Test_u_snprintf(4, "%d", 123, 3, "123");
+
+ Test_u_snprintf(0, "%s", "abcd", 0, "xxxxxxxxxxxxxx");
+ Test_u_snprintf(3, "%s", "abcd", 3, "abcxxxxxxxxxxx");
+ Test_u_snprintf(4, "%s", "abcd", 4, "abcdxxxxxxxxxx");
+ Test_u_snprintf(5, "%s", "abcd", 4, "abcd");
+
+ Test_u_snprintf(0, "%e", 12.34, 0, "xxxxxxxxxxxxxx");
+ Test_u_snprintf(1, "%e", 12.34, 1, "1xxxxxxxxxxxxx");
+ Test_u_snprintf(2, "%e", 12.34, 2, "1.xxxxxxxxxxxx");
+ Test_u_snprintf(3, "%e", 12.34, 3, "1.2xxxxxxxxxxx");
+ Test_u_snprintf(5, "%e", 12.34, 5, "1.234xxxxxxxxx");
+ Test_u_snprintf(6, "%e", 12.34, 6, "1.2340xxxxxxxx");
+ Test_u_snprintf(8, "%e", 12.34, 8, "1.234000xxxxxx");
+ Test_u_snprintf(9, "%e", 12.34, 9, "1.234000exxxxx");
+ Test_u_snprintf(10, "%e", 12.34, 10, "1.234000e+xxxx");
+ Test_u_snprintf(11, "%e", 12.34, 11, "1.234000e+0xxx");
+ Test_u_snprintf(13, "%e", 12.34, 13, "1.234000e+001x");
+ Test_u_snprintf(14, "%e", 12.34, 13, "1.234000e+001");
+#endif
+}
+
+#define TestSPrintFormat(uFormat, uValue, cFormat, cValue) \
+ /* Reinitialize the buffer to verify null termination works. */\
+ u_memset(uBuffer, 0x2a, sizeof(uBuffer)/sizeof(*uBuffer));\
+ memset(buffer, '*', sizeof(buffer)/sizeof(*buffer));\
+ \
+ uNumPrinted = u_sprintf(uBuffer, uFormat, uValue);\
+ u_austrncpy(compBuffer, uBuffer, sizeof(uBuffer)/sizeof(uBuffer[0]));\
+ cNumPrinted = sprintf(buffer, cFormat, cValue);\
+ if (strcmp(buffer, compBuffer) != 0) {\
+ log_err("%" uFormat " Got: \"%s\", Expected: \"%s\"\n", compBuffer, buffer);\
+ }\
+ if (cNumPrinted != uNumPrinted) {\
+ log_err("%" uFormat " number printed Got: %d, Expected: %d\n", uNumPrinted, cNumPrinted);\
+ }\
+ if (buffer[uNumPrinted+1] != '*') {\
+ log_err("%" uFormat " too much stored\n");\
+ }\
+
+static void TestSprintfFormat(void) {
+#if !UCONFIG_NO_FORMATTING
+ static const UChar abcUChars[] = {0x61,0x62,0x63,0};
+ static const char abcChars[] = "abc";
+ UChar uBuffer[256];
+ char buffer[256];
+ char compBuffer[256];
+ int32_t uNumPrinted;
+ int32_t cNumPrinted;
+
+
+ TestSPrintFormat("%8S", abcUChars, "%8s", abcChars);
+ TestSPrintFormat("%-8S", abcUChars, "%-8s", abcChars);
+ TestSPrintFormat("%.2S", abcUChars, "%.2s", abcChars); /* strlen is 3 */
+
+ TestSPrintFormat("%8s", abcChars, "%8s", abcChars);
+ TestSPrintFormat("%-8s", abcChars, "%-8s", abcChars);
+ TestSPrintFormat("%.2s", abcChars, "%.2s", abcChars); /* strlen is 3 */
+
+ TestSPrintFormat("%8c", (char)'e', "%8c", (char)'e');
+ TestSPrintFormat("%-8c", (char)'e', "%-8c", (char)'e');
+
+ TestSPrintFormat("%8C", (UChar)0x65, "%8c", (char)'e');
+ TestSPrintFormat("%-8C", (UChar)0x65, "%-8c", (char)'e');
+
+ TestSPrintFormat("%f", 1.23456789, "%f", 1.23456789);
+ TestSPrintFormat("%f", 12345.6789, "%f", 12345.6789);
+ TestSPrintFormat("%f", 123456.789, "%f", 123456.789);
+ TestSPrintFormat("%f", 1234567.89, "%f", 1234567.89);
+ TestSPrintFormat("%10f", 1.23456789, "%10f", 1.23456789);
+ TestSPrintFormat("%-10f", 1.23456789, "%-10f", 1.23456789);
+ TestSPrintFormat("%10f", 123.456789, "%10f", 123.456789);
+ TestSPrintFormat("%10.4f", 123.456789, "%10.4f", 123.456789);
+ TestSPrintFormat("%-10f", 123.456789, "%-10f", 123.456789);
+
+/* TestSPrintFormat("%g", 12345.6789, "%g", 12345.6789);
+ TestSPrintFormat("%g", 123456.789, "%g", 123456.789);
+ TestSPrintFormat("%g", 1234567.89, "%g", 1234567.89);
+ TestSPrintFormat("%G", 123456.789, "%G", 123456.789);
+ TestSPrintFormat("%G", 1234567.89, "%G", 1234567.89);*/
+ TestSPrintFormat("%10g", 1.23456789, "%10g", 1.23456789);
+ TestSPrintFormat("%10.4g", 1.23456789, "%10.4g", 1.23456789);
+ TestSPrintFormat("%-10g", 1.23456789, "%-10g", 1.23456789);
+ TestSPrintFormat("%10g", 123.456789, "%10g", 123.456789);
+ TestSPrintFormat("%-10g", 123.456789, "%-10g", 123.456789);
+
+ TestSPrintFormat("%8x", 123456, "%8x", 123456);
+ TestSPrintFormat("%-8x", 123456, "%-8x", 123456);
+ TestSPrintFormat("%08x", 123456, "%08x", 123456);
+
+ TestSPrintFormat("%8X", 123456, "%8X", 123456);
+ TestSPrintFormat("%-8X", 123456, "%-8X", 123456);
+ TestSPrintFormat("%08X", 123456, "%08X", 123456);
+ TestSPrintFormat("%#x", 123456, "%#x", 123456);
+ TestSPrintFormat("%#x", -123456, "%#x", -123456);
+
+ TestSPrintFormat("%8o", 123456, "%8o", 123456);
+ TestSPrintFormat("%-8o", 123456, "%-8o", 123456);
+ TestSPrintFormat("%08o", 123456, "%08o", 123456);
+ TestSPrintFormat("%#o", 123, "%#o", 123);
+ TestSPrintFormat("%#o", -123, "%#o", -123);
+
+ TestSPrintFormat("%8u", 123456, "%8u", 123456);
+ TestSPrintFormat("%-8u", 123456, "%-8u", 123456);
+ TestSPrintFormat("%08u", 123456, "%08u", 123456);
+ TestSPrintFormat("%8u", -123456, "%8u", -123456);
+ TestSPrintFormat("%-8u", -123456, "%-8u", -123456);
+ TestSPrintFormat("%.5u", 123456, "%.5u", 123456);
+ TestSPrintFormat("%.6u", 123456, "%.6u", 123456);
+ TestSPrintFormat("%.7u", 123456, "%.7u", 123456);
+
+ TestSPrintFormat("%8d", 123456, "%8d", 123456);
+ TestSPrintFormat("%-8d", 123456, "%-8d", 123456);
+ TestSPrintFormat("%08d", 123456, "%08d", 123456);
+ TestSPrintFormat("% d", 123456, "% d", 123456);
+ TestSPrintFormat("% d", -123456, "% d", -123456);
+
+ TestSPrintFormat("%8i", 123456, "%8i", 123456);
+ TestSPrintFormat("%-8i", 123456, "%-8i", 123456);
+ TestSPrintFormat("%08i", 123456, "%08i", 123456);
+
+ log_verbose("Get really crazy with the formatting.\n");
+
+ TestSPrintFormat("%-#12x", 123, "%-#12x", 123);
+ TestSPrintFormat("%-#12x", -123, "%-#12x", -123);
+ TestSPrintFormat("%#12x", 123, "%#12x", 123);
+ TestSPrintFormat("%#12x", -123, "%#12x", -123);
+
+ TestSPrintFormat("%-+12d", 123, "%-+12d", 123);
+ TestSPrintFormat("%-+12d", -123, "%-+12d", -123);
+ TestSPrintFormat("%- 12d", 123, "%- 12d", 123);
+ TestSPrintFormat("%- 12d", -123, "%- 12d", -123);
+ TestSPrintFormat("%+12d", 123, "%+12d", 123);
+ TestSPrintFormat("%+12d", -123, "%+12d", -123);
+ TestSPrintFormat("% 12d", 123, "% 12d", 123);
+ TestSPrintFormat("% 12d", -123, "% 12d", -123);
+ TestSPrintFormat("%12d", 123, "%12d", 123);
+ TestSPrintFormat("%12d", -123, "%12d", -123);
+ TestSPrintFormat("%.12d", 123, "%.12d", 123);
+ TestSPrintFormat("%.12d", -123, "%.12d", -123);
+
+ TestSPrintFormat("%-+12.1f", 1.234, "%-+12.1f", 1.234);
+ TestSPrintFormat("%-+12.1f", -1.234, "%-+12.1f", -1.234);
+ TestSPrintFormat("%- 12.10f", 1.234, "%- 12.10f", 1.234);
+ TestSPrintFormat("%- 12.1f", -1.234, "%- 12.1f", -1.234);
+ TestSPrintFormat("%+12.1f", 1.234, "%+12.1f", 1.234);
+ TestSPrintFormat("%+12.1f", -1.234, "%+12.1f", -1.234);
+ TestSPrintFormat("% 12.1f", 1.234, "% 12.1f", 1.234);
+ TestSPrintFormat("% 12.1f", -1.234, "% 12.1f", -1.234);
+ TestSPrintFormat("%12.1f", 1.234, "%12.1f", 1.234);
+ TestSPrintFormat("%12.1f", -1.234, "%12.1f", -1.234);
+ TestSPrintFormat("%.2f", 1.234, "%.2f", 1.234);
+ TestSPrintFormat("%.2f", -1.234, "%.2f", -1.234);
+ TestSPrintFormat("%3f", 1.234, "%3f", 1.234);
+ TestSPrintFormat("%3f", -1.234, "%3f", -1.234);
+#endif
+}
+
+#undef TestSPrintFormat
+
+static void TestStringCompatibility(void) {
+#if !UCONFIG_NO_FORMATTING
+ UChar myUString[256];
+ UChar uStringBuf[256];
+ char myString[256] = "";
+ char testBuf[256] = "";
+ int32_t num;
+
+ u_memset(myUString, 0x0a, sizeof(myUString)/ sizeof(*myUString));
+ u_memset(uStringBuf, 0x0a, sizeof(uStringBuf) / sizeof(*uStringBuf));
+
+ /* Compare against C API compatibility */
+ for (num = -STANDARD_TEST_NUM_RANGE; num < STANDARD_TEST_NUM_RANGE; num++) {
+ sprintf(testBuf, "%x", (int)num);
+ u_sprintf(uStringBuf, "%x", num);
+ u_austrncpy(myString, uStringBuf, sizeof(myString)/sizeof(myString[0]));
+ if (strcmp(myString, testBuf) != 0) {
+ log_err("%%x Got: \"%s\", Expected: \"%s\"\n", myString, testBuf);
+ }
+
+ sprintf(testBuf, "%X", (int)num);
+ u_sprintf(uStringBuf, "%X", num);
+ u_austrncpy(myString, uStringBuf, sizeof(myString)/sizeof(myString[0]));
+ if (strcmp(myString, testBuf) != 0) {
+ log_err("%%X Got: \"%s\", Expected: \"%s\"\n", myString, testBuf);
+ }
+
+ sprintf(testBuf, "%o", (int)num);
+ u_sprintf(uStringBuf, "%o", num);
+ u_austrncpy(myString, uStringBuf, sizeof(myString)/sizeof(myString[0]));
+ if (strcmp(myString, testBuf) != 0) {
+ log_err("%%o Got: \"%s\", Expected: \"%s\"\n", myString, testBuf);
+ }
+
+ /* sprintf is not compatible on all platforms e.g. the iSeries*/
+ sprintf(testBuf, "%d", (int)num);
+ u_sprintf(uStringBuf, "%d", num);
+ u_austrncpy(myString, uStringBuf, sizeof(myString)/sizeof(myString[0]));
+ if (strcmp(myString, testBuf) != 0) {
+ log_err("%%d Got: \"%s\", Expected: \"%s\"\n", myString, testBuf);
+ }
+
+ sprintf(testBuf, "%i", (int)num);
+ u_sprintf(uStringBuf, "%i", num);
+ u_austrncpy(myString, uStringBuf, sizeof(myString)/sizeof(myString[0]));
+ if (strcmp(myString, testBuf) != 0) {
+ log_err("%%i Got: \"%s\", Expected: \"%s\"\n", myString, testBuf);
+ }
+
+ sprintf(testBuf, "%f", (double)num);
+ u_sprintf(uStringBuf, "%f", (double)num);
+ u_austrncpy(myString, uStringBuf, sizeof(myString)/sizeof(myString[0]));
+ if (strcmp(myString, testBuf) != 0) {
+ log_err("%%f Got: \"%s\", Expected: \"%s\"\n", myString, testBuf);
+ }
+
+/* sprintf(testBuf, "%e", (double)num);
+ u_sprintf(uStringBuf, "%e", (double)num);
+ u_austrncpy(myString, uStringBuf, sizeof(myString)/sizeof(myString[0]));
+ if (strcmp(myString, testBuf) != 0) {
+ log_err("%%e Got: \"%s\", Expected: \"%s\"\n", myString, testBuf);
+ }
+
+ sprintf(testBuf, "%E", (double)num);
+ u_sprintf(uStringBuf, "%E", (double)num);
+ u_austrncpy(myString, uStringBuf, sizeof(myString)/sizeof(myString[0]));
+ if (strcmp(myString, testBuf) != 0) {
+ log_err("%%E Got: \"%s\", Expected: \"%s\"\n", myString, testBuf);
+ }*/
+
+ sprintf(testBuf, "%g", (double)num);
+ u_sprintf(uStringBuf, "%g", (double)num);
+ u_austrncpy(myString, uStringBuf, sizeof(myString)/sizeof(myString[0]));
+ if (strcmp(myString, testBuf) != 0) {
+ log_err("%%g Got: \"%s\", Expected: \"%s\"\n", myString, testBuf);
+ }
+
+ sprintf(testBuf, "%G", (double)num);
+ u_sprintf(uStringBuf, "%G", (double)num);
+ u_austrncpy(myString, uStringBuf, sizeof(myString)/sizeof(myString[0]));
+ if (strcmp(myString, testBuf) != 0) {
+ log_err("%%G Got: \"%s\", Expected: \"%s\"\n", myString, testBuf);
+ }
+ }
+
+ for (num = 0; num < 0x80; num++) {
+ testBuf[0] = (char)0xFF;
+ uStringBuf[0] = (UChar)0xfffe;
+ sprintf(testBuf, "%c", (char)num);
+ u_sprintf(uStringBuf, "%c", num);
+ u_austrncpy(myString, uStringBuf, sizeof(myString)/sizeof(myString[0]));
+ if (testBuf[0] != myString[0] || myString[0] != num) {
+ log_err("%%c Got: 0x%x, Expected: 0x%x\n", myString[0], testBuf[0]);
+ }
+ }
+#endif
+}
+
+static void TestSScanSetFormat(const char *format, const UChar *uValue, const char *cValue, UBool expectedToPass) {
+#if !UCONFIG_NO_FORMATTING
+ UChar uBuffer[256];
+ char buffer[256];
+ char compBuffer[256];
+ int32_t uNumScanned;
+ int32_t cNumScanned;
+
+ /* Reinitialize the buffer to verify null termination works. */
+ u_memset(uBuffer, 0x2a, sizeof(uBuffer)/sizeof(*uBuffer));
+ uBuffer[sizeof(uBuffer)/sizeof(*uBuffer)-1] = 0;
+ memset(buffer, '*', sizeof(buffer)/sizeof(*buffer));
+ buffer[sizeof(buffer)/sizeof(*buffer)-1] = 0;
+
+ uNumScanned = u_sscanf(uValue, format, uBuffer);
+ if (expectedToPass) {
+ u_austrncpy(compBuffer, uBuffer, sizeof(uBuffer)/sizeof(uBuffer[0]));
+ cNumScanned = sscanf(cValue, format, buffer);
+ if (strncmp(buffer, compBuffer, sizeof(uBuffer)/sizeof(uBuffer[0])) != 0) {
+ log_err("%s Got: \"%s\", Expected: \"%s\"\n", format, compBuffer, buffer);
+ }
+ if (cNumScanned != uNumScanned) {
+ log_err("%s number scanned Got: %d, Expected: %d\n", format, uNumScanned, cNumScanned);
+ }
+ if (uNumScanned > 0 && uBuffer[u_strlen(uBuffer)+1] != 0x2a) {
+ log_err("%s too much stored\n", format);
+ }
+ }
+ else {
+ if (uNumScanned != 0 || uBuffer[0] != 0x2a || uBuffer[1] != 0x2a) {
+ log_err("%s too much stored on a failure\n", format);
+ }
+ }
+#endif
+}
+
+static void TestSScanset(void) {
+#if !UCONFIG_NO_FORMATTING
+ static const UChar abcUChars[] = {0x61,0x62,0x63,0x63,0x64,0x65,0x66,0x67,0};
+ static const char abcChars[] = "abccdefg";
+
+ TestSScanSetFormat("%[bc]S", abcUChars, abcChars, TRUE);
+ TestSScanSetFormat("%[cb]S", abcUChars, abcChars, TRUE);
+
+ TestSScanSetFormat("%[ab]S", abcUChars, abcChars, TRUE);
+ TestSScanSetFormat("%[ba]S", abcUChars, abcChars, TRUE);
+
+ TestSScanSetFormat("%[ab]", abcUChars, abcChars, TRUE);
+ TestSScanSetFormat("%[ba]", abcUChars, abcChars, TRUE);
+
+ TestSScanSetFormat("%[abcdefgh]", abcUChars, abcChars, TRUE);
+ TestSScanSetFormat("%[;hgfedcba]", abcUChars, abcChars, TRUE);
+
+ TestSScanSetFormat("%[^a]", abcUChars, abcChars, TRUE);
+ TestSScanSetFormat("%[^e]", abcUChars, abcChars, TRUE);
+ TestSScanSetFormat("%[^ed]", abcUChars, abcChars, TRUE);
+ TestSScanSetFormat("%[^dc]", abcUChars, abcChars, TRUE);
+ TestSScanSetFormat("%[^e] ", abcUChars, abcChars, TRUE);
+
+ TestSScanSetFormat("%1[ab] ", abcUChars, abcChars, TRUE);
+ TestSScanSetFormat("%2[^f]", abcUChars, abcChars, TRUE);
+
+ TestSScanSetFormat("%[qrst]", abcUChars, abcChars, TRUE);
+
+ /* Extra long string for testing */
+ TestSScanSetFormat(" %[qrst]",
+ abcUChars, abcChars, TRUE);
+
+ TestSScanSetFormat("%[a-]", abcUChars, abcChars, TRUE);
+
+ /* Bad format */
+ TestSScanSetFormat("%[a", abcUChars, abcChars, FALSE);
+ TestSScanSetFormat("%[f-a]", abcUChars, abcChars, FALSE);
+ TestSScanSetFormat("%[c-a]", abcUChars, abcChars, FALSE);
+ /* The following is not deterministic on Windows */
+/* TestSScanSetFormat("%[a-", abcUChars, abcChars);*/
+
+ /* TODO: Need to specify precision with a "*" */
+#endif
+}
+
+static void TestBadSScanfFormat(const char *format, const UChar *uValue, const char *cValue) {
+#if !UCONFIG_NO_FORMATTING
+ UChar uBuffer[256];
+ int32_t uNumScanned;
+
+ /* Reinitialize the buffer to verify null termination works. */
+ u_memset(uBuffer, 0x2a, sizeof(uBuffer)/sizeof(*uBuffer));
+ uBuffer[sizeof(uBuffer)/sizeof(*uBuffer)-1] = 0;
+
+ uNumScanned = u_sscanf(uValue, format, uBuffer);
+ if (uNumScanned != 0 || uBuffer[0] != 0x2a || uBuffer[1] != 0x2a) {
+ log_err("%s too much stored on a failure\n", format);
+ }
+#endif
+}
+
+static void TestBadScanfFormat(void) {
+#if !UCONFIG_NO_FORMATTING
+ static const UChar abcUChars[] = {0x61,0x62,0x63,0x63,0x64,0x65,0x66,0x67,0};
+ static const char abcChars[] = "abccdefg";
+
+ TestBadSScanfFormat("%[] ", abcUChars, abcChars);
+#endif
+}
+
+static void Test_u_vfprintf(const char *expectedResult, const char *format, ...) {
+#if !UCONFIG_NO_FORMATTING
+ UChar uBuffer[256];
+ UChar uBuffer2[256];
+ va_list ap;
+ int32_t count;
+
+ va_start(ap, format);
+ count = u_vsprintf(uBuffer, format, ap);
+ va_end(ap);
+ u_uastrcpy(uBuffer2, expectedResult);
+ if (u_strcmp(uBuffer, uBuffer2) != 0) {
+ log_err("Got two different results for \"%s\" expected \"%s\"\n", format, expectedResult);
+ }
+
+ u_uastrcpy(uBuffer2, format);
+ va_start(ap, format);
+ count = u_vsprintf_u(uBuffer, uBuffer2, ap);
+ va_end(ap);
+ u_uastrcpy(uBuffer2, expectedResult);
+ if (u_strcmp(uBuffer, uBuffer2) != 0) {
+ log_err("Got two different results for \"%s\" expected \"%s\"\n", format, expectedResult);
+ }
+#endif
+}
+
+static void TestVargs(void) {
+#if !UCONFIG_NO_FORMATTING
+ Test_u_vfprintf("8 9 a B 8.9", "%d %u %x %X %.1f", 8, 9, 10, 11, 8.9);
+#endif
+}
+
+static void TestCount(void) {
+#if !UCONFIG_NO_FORMATTING
+ static const UChar x15[] = { 0x78, 0x31, 0x35, 0 };
+ UChar testStr[16];
+ UChar character;
+ int16_t i16 = -1;
+ int32_t i32 = -1, actual_count, actual_result;
+ int64_t i64 = -1;
+ u_uastrcpy(testStr, "1233456789");
+ if (u_sscanf(testStr, "%*3[123]%n%*[1-9]", &i32) != 0) {
+ log_err("test 1: scanf did not return 0\n");
+ }
+ if (i32 != 3) {
+ log_err("test 1: scanf returned %hd instead of 3\n", i32);
+ }
+ if (u_sscanf(testStr, "%*4[123]%hn%*[1-9]", &i16) != 0) {
+ log_err("test 2: scanf did not return 0\n");
+ }
+ if (i16 != 4) {
+ log_err("test 2: scanf returned %d instead of 4\n", i16);
+ }
+ if (u_sscanf(testStr, "%*[123]%*[1-9]%lln", &i64) != 0) {
+ log_err("test 3: scanf did not return 0\n");
+ }
+ if (i64 != 10) {
+ log_err("test 3: scanf did not return 10\n", i64);
+ }
+ actual_result = u_sscanf(x15, "%C%d%n", &character, &i32, &actual_count);
+ if (actual_result != 2) {
+ log_err("scanf should return 2, but returned %d\n", actual_result);
+ }
+ if (character != 0x78) {
+ log_err("scanf should return 0x78 for the character, but returned %X\n", character);
+ }
+ if (i32 != 15) {
+ log_err("scanf should return 15 for the number, but returned %d\n", i32);
+ }
+ if (actual_count != 3) {
+ log_err("scanf should return 3 for actual_count, but returned %d\n", actual_count);
+ }
+#endif
+}
+
+U_CFUNC void
+addStringTest(TestNode** root) {
+#if !UCONFIG_NO_FORMATTING
+ addTest(root, &TestString, "string/TestString");
+ addTest(root, &TestLocalizedString, "string/TestLocalizedString");
+ addTest(root, &TestSprintfFormat, "string/TestSprintfFormat");
+ addTest(root, &TestSnprintf, "string/TestSnprintf");
+ addTest(root, &TestSScanset, "string/TestSScanset");
+ addTest(root, &TestStringCompatibility, "string/TestStringCompatibility");
+ addTest(root, &TestBadScanfFormat, "string/TestBadScanfFormat");
+ addTest(root, &TestVargs, "string/TestVargs");
+ addTest(root, &TestCount, "string/TestCount");
+#endif
+}
+
+
Property changes on: trunk/source/test/iotest/strtst.c
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/source/test/iotest/trnstst.c
===================================================================
--- trunk/source/test/iotest/trnstst.c 2006-12-21 11:09:23 UTC (rev 127)
+++ trunk/source/test/iotest/trnstst.c 2006-12-21 11:10:34 UTC (rev 128)
@@ -1,316 +1,316 @@
-/*
-**********************************************************************
-* Copyright (C) 2005-2005, International Business Machines
-* Corporation and others. All Rights Reserved.
-**********************************************************************
-* file name: strtst.c
-* created by: George Rhoten
-*/
-
-#include "iotest.h"
-#include "unicode/ustdio.h"
-#include "unicode/utrans.h"
-#include "unicode/ustring.h"
-
-static void TestTranslitOps(void)
-{
-#if !UCONFIG_NO_TRANSLITERATION
- UFILE *f;
- UErrorCode err = U_ZERO_ERROR;
- UTransliterator *a = NULL, *b = NULL, *c = NULL;
-
- log_verbose("opening a transliterator and UFILE for testing\n");
-
- f = u_fopen(STANDARD_TEST_FILE, "w", "en_US_POSIX", NULL);
- if(f == NULL)
- {
- log_err("Couldn't open test file for writing\n");
- return;
- }
-
- a = utrans_open("Latin-Greek", UTRANS_FORWARD, NULL, -1, NULL, &err);
- if(U_FAILURE(err))
- {
- log_err("Error opening transliterator %s\n", u_errorName(err));
- u_fclose(f);
- return;
- }
-
-
- log_verbose("setting a transliterator\n");
- b = u_fsettransliterator(f, U_WRITE, a, &err);
- if(U_FAILURE(err))
- {
- log_err("Error setting transliterator %s\n", u_errorName(err));
- u_fclose(f);
- return;
- }
-
- if(b != NULL)
- {
- log_err("Error, a transliterator was already set!\n");
- }
-
- b = u_fsettransliterator(NULL, U_WRITE, a, &err);
- if(err != U_ILLEGAL_ARGUMENT_ERROR)
- {
- log_err("Error setting transliterator on NULL file err=%s\n", u_errorName(err));
- }
-
- if(b != a)
- {
- log_err("Error getting the same transliterator was not returned on NULL file\n");
- }
-
- err = U_FILE_ACCESS_ERROR;
- b = u_fsettransliterator(f, U_WRITE, a, &err);
- if(err != U_FILE_ACCESS_ERROR)
- {
- log_err("Error setting transliterator on error status err=%s\n", u_errorName(err));
- }
-
- if(b != a)
- {
- log_err("Error getting the same transliterator on error status\n");
- }
- err = U_ZERO_ERROR;
-
-
- log_verbose("un-setting transliterator (setting to null)\n");
- c = u_fsettransliterator(f, U_WRITE, NULL, &err);
- if(U_FAILURE(err))
- {
- log_err("Err setting transliterator %s\n", u_errorName(err));
- u_fclose(f);
- return;
- }
-
- if(c != a)
- {
- log_err("Err, transliterator that came back was not the original one.\n");
- }
-
- log_verbose("Trying to set read transliterator (should fail)\n");
- b = u_fsettransliterator(f, U_READ, NULL, &err);
- if(err != U_UNSUPPORTED_ERROR)
- {
- log_err("Should have U_UNSUPPORTED_ERROR setting Read transliterator but got %s - REVISIT AND UPDATE TEST\n", u_errorName(err));
- u_fclose(f);
- return;
- }
- else
- {
- log_verbose("Got %s error (expected) setting READ transliterator.\n", u_errorName(err));
- err = U_ZERO_ERROR;
- }
-
-
- utrans_close(c);
- u_fclose(f);
-#endif
-}
-
-static void TestTranslitFileOut(void)
-{
-#if !UCONFIG_NO_FORMATTING
-#if !UCONFIG_NO_TRANSLITERATION
- UFILE *f;
- UErrorCode err = U_ZERO_ERROR;
- UTransliterator *a = NULL, *b = NULL, *c = NULL;
- FILE *infile;
- UChar compare[] = { 0xfeff, 0x03a3, 0x03c4, 0x03b5, 0x03c6, 0x1f00, 0x03bd, 0x03bf, 0x03c2, 0x043C, 0x0000 };
- UChar ubuf[256];
- int len;
-
- log_verbose("opening a transliterator and UFILE for testing\n");
-
- f = u_fopen(STANDARD_TEST_FILE, "w", "en_US_POSIX", "utf-16");
- if(f == NULL)
- {
- log_err("Couldn't open test file for writing\n");
- return;
- }
-
- a = utrans_open("Latin-Greek", UTRANS_FORWARD, NULL, -1, NULL, &err);
- if(U_FAILURE(err))
- {
- log_err("Err opening transliterator %s\n", u_errorName(err));
- u_fclose(f);
- return;
- }
-
- log_verbose("setting a transliterator\n");
- b = u_fsettransliterator(f, U_WRITE, a, &err);
- if(U_FAILURE(err))
- {
- log_err("Err setting transliterator %s\n", u_errorName(err));
- u_fclose(f);
- return;
- }
-
- if(b != NULL)
- {
- log_err("Err, a transliterator was already set!\n");
- }
-
- u_fprintf(f, "Stephanos");
-
- c = utrans_open("Latin-Cyrillic", UTRANS_FORWARD, NULL, -1, NULL, &err);
- if(U_FAILURE(err))
- {
- log_err("Err opening transliterator %s\n", u_errorName(err));
- u_fclose(f);
- return;
- }
-
- log_verbose("setting a transliterator\n");
- b = u_fsettransliterator(f, U_WRITE, c, &err);
- if(U_FAILURE(err))
- {
- log_err("Err setting transliterator %s\n", u_errorName(err));
- u_fclose(f);
- return;
- }
-
- if(b != a)
- {
- log_err("Error: a different transliterator was returned!\n");
- }
- utrans_close(b);
-
- u_fprintf(f, "m");
-
- u_fclose(f);
-
- log_verbose("Re reading test file to verify transliteration\n");
- infile = fopen(STANDARD_TEST_FILE, "rb");
- if(infile == NULL)
- {
- log_err("Couldn't reopen test file\n");
- return;
- }
-
- len=fread(ubuf, sizeof(UChar), u_strlen(compare), infile);
- log_verbose("Read %d UChars\n", len);
- if(len != u_strlen(compare))
- {
- log_err("Wanted %d UChars from file, got %d\n", u_strlen(compare), len);
- }
- ubuf[len]=0;
-
- if(u_strlen(compare) != u_strlen(ubuf))
- {
- log_err("Wanted %d UChars from file, but u_strlen() returns %d\n", u_strlen(compare), len);
- }
-
- if(u_strcmp(compare, ubuf))
- {
- log_err("Read string doesn't match expected.\n");
- }
- else
- {
- log_verbose("Read string matches expected.\n");
- }
-
- fclose(infile);
-#endif
-#endif
-}
-
-static void TestTranslitStringOut(void)
-{
-#if !UCONFIG_NO_FORMATTING
-#if !UCONFIG_NO_TRANSLITERATION
- UFILE *f;
- UErrorCode err = U_ZERO_ERROR;
- UTransliterator *a = NULL, *b = NULL, *c = NULL;
- UChar compare[] = { 0x03a3, 0x03c4, 0x03b5, 0x03c6, 0x1f00, 0x03bd, 0x03bf, 0x03c2, 0x043C, 0x0000 };
- UChar ubuf[256];
-
- log_verbose("opening a transliterator and UFILE for testing\n");
-
- f = u_fstropen(ubuf, sizeof(ubuf)/sizeof(ubuf[0]), "en_US_POSIX");
- if(f == NULL)
- {
- log_err("Couldn't open test file for writing\n");
- return;
- }
-
- a = utrans_open("Latin-Greek", UTRANS_FORWARD, NULL, -1, NULL, &err);
- if(U_FAILURE(err))
- {
- log_err("Err opening transliterator %s\n", u_errorName(err));
- u_fclose(f);
- return;
- }
-
- log_verbose("setting a transliterator\n");
- b = u_fsettransliterator(f, U_WRITE, a, &err);
- if(U_FAILURE(err))
- {
- log_err("Err setting transliterator %s\n", u_errorName(err));
- u_fclose(f);
- return;
- }
-
- if(b != NULL)
- {
- log_err("Err, a transliterator was already set!\n");
- }
-
- u_fprintf(f, "Stephanos");
-
- c = utrans_open("Latin-Cyrillic", UTRANS_FORWARD, NULL, -1, NULL, &err);
- if(U_FAILURE(err))
- {
- log_err("Err opening transliterator %s\n", u_errorName(err));
- u_fclose(f);
- return;
- }
-
- log_verbose("setting a transliterator\n");
- b = u_fsettransliterator(f, U_WRITE, c, &err);
- if(U_FAILURE(err))
- {
- log_err("Err setting transliterator %s\n", u_errorName(err));
- u_fclose(f);
- return;
- }
-
- if(b != a)
- {
- log_err("Error: a different transliterator was returned!\n");
- }
- utrans_close(b);
-
- u_fprintf(f, "m");
-
- u_fclose(f);
-
- if(u_strlen(compare) != u_strlen(ubuf))
- {
- log_err("Wanted %d UChars from file, but u_strlen() returns %d\n", u_strlen(compare), u_strlen(ubuf));
- }
-
- if(u_strcmp(compare, ubuf))
- {
- log_err("Read string doesn't match expected.\n");
- }
- else
- {
- log_verbose("Read string matches expected.\n");
- }
-#endif
-#endif
-}
-
-U_CFUNC void
-addTranslitTest(TestNode** root) {
-#if !UCONFIG_NO_TRANSLITERATION
- addTest(root, &TestTranslitOps, "translit/ops");
-#if !UCONFIG_NO_FORMATTING
- addTest(root, &TestTranslitFileOut, "translit/fileOut");
- addTest(root, &TestTranslitStringOut, "translit/stringOut");
-#endif
-#endif
-}
+/*
+**********************************************************************
+* Copyright (C) 2005-2005, International Business Machines
+* Corporation and others. All Rights Reserved.
+**********************************************************************
+* file name: strtst.c
+* created by: George Rhoten
+*/
+
+#include "iotest.h"
+#include "unicode/ustdio.h"
+#include "unicode/utrans.h"
+#include "unicode/ustring.h"
+
+static void TestTranslitOps(void)
+{
+#if !UCONFIG_NO_TRANSLITERATION
+ UFILE *f;
+ UErrorCode err = U_ZERO_ERROR;
+ UTransliterator *a = NULL, *b = NULL, *c = NULL;
+
+ log_verbose("opening a transliterator and UFILE for testing\n");
+
+ f = u_fopen(STANDARD_TEST_FILE, "w", "en_US_POSIX", NULL);
+ if(f == NULL)
+ {
+ log_err("Couldn't open test file for writing\n");
+ return;
+ }
+
+ a = utrans_open("Latin-Greek", UTRANS_FORWARD, NULL, -1, NULL, &err);
+ if(U_FAILURE(err))
+ {
+ log_err("Error opening transliterator %s\n", u_errorName(err));
+ u_fclose(f);
+ return;
+ }
+
+
+ log_verbose("setting a transliterator\n");
+ b = u_fsettransliterator(f, U_WRITE, a, &err);
+ if(U_FAILURE(err))
+ {
+ log_err("Error setting transliterator %s\n", u_errorName(err));
+ u_fclose(f);
+ return;
+ }
+
+ if(b != NULL)
+ {
+ log_err("Error, a transliterator was already set!\n");
+ }
+
+ b = u_fsettransliterator(NULL, U_WRITE, a, &err);
+ if(err != U_ILLEGAL_ARGUMENT_ERROR)
+ {
+ log_err("Error setting transliterator on NULL file err=%s\n", u_errorName(err));
+ }
+
+ if(b != a)
+ {
+ log_err("Error getting the same transliterator was not returned on NULL file\n");
+ }
+
+ err = U_FILE_ACCESS_ERROR;
+ b = u_fsettransliterator(f, U_WRITE, a, &err);
+ if(err != U_FILE_ACCESS_ERROR)
+ {
+ log_err("Error setting transliterator on error status err=%s\n", u_errorName(err));
+ }
+
+ if(b != a)
+ {
+ log_err("Error getting the same transliterator on error status\n");
+ }
+ err = U_ZERO_ERROR;
+
+
+ log_verbose("un-setting transliterator (setting to null)\n");
+ c = u_fsettransliterator(f, U_WRITE, NULL, &err);
+ if(U_FAILURE(err))
+ {
+ log_err("Err setting transliterator %s\n", u_errorName(err));
+ u_fclose(f);
+ return;
+ }
+
+ if(c != a)
+ {
+ log_err("Err, transliterator that came back was not the original one.\n");
+ }
+
+ log_verbose("Trying to set read transliterator (should fail)\n");
+ b = u_fsettransliterator(f, U_READ, NULL, &err);
+ if(err != U_UNSUPPORTED_ERROR)
+ {
+ log_err("Should have U_UNSUPPORTED_ERROR setting Read transliterator but got %s - REVISIT AND UPDATE TEST\n", u_errorName(err));
+ u_fclose(f);
+ return;
+ }
+ else
+ {
+ log_verbose("Got %s error (expected) setting READ transliterator.\n", u_errorName(err));
+ err = U_ZERO_ERROR;
+ }
+
+
+ utrans_close(c);
+ u_fclose(f);
+#endif
+}
+
+static void TestTranslitFileOut(void)
+{
+#if !UCONFIG_NO_FORMATTING
+#if !UCONFIG_NO_TRANSLITERATION
+ UFILE *f;
+ UErrorCode err = U_ZERO_ERROR;
+ UTransliterator *a = NULL, *b = NULL, *c = NULL;
+ FILE *infile;
+ UChar compare[] = { 0xfeff, 0x03a3, 0x03c4, 0x03b5, 0x03c6, 0x1f00, 0x03bd, 0x03bf, 0x03c2, 0x043C, 0x0000 };
+ UChar ubuf[256];
+ int len;
+
+ log_verbose("opening a transliterator and UFILE for testing\n");
+
+ f = u_fopen(STANDARD_TEST_FILE, "w", "en_US_POSIX", "utf-16");
+ if(f == NULL)
+ {
+ log_err("Couldn't open test file for writing\n");
+ return;
+ }
+
+ a = utrans_open("Latin-Greek", UTRANS_FORWARD, NULL, -1, NULL, &err);
+ if(U_FAILURE(err))
+ {
+ log_err("Err opening transliterator %s\n", u_errorName(err));
+ u_fclose(f);
+ return;
+ }
+
+ log_verbose("setting a transliterator\n");
+ b = u_fsettransliterator(f, U_WRITE, a, &err);
+ if(U_FAILURE(err))
+ {
+ log_err("Err setting transliterator %s\n", u_errorName(err));
+ u_fclose(f);
+ return;
+ }
+
+ if(b != NULL)
+ {
+ log_err("Err, a transliterator was already set!\n");
+ }
+
+ u_fprintf(f, "Stephanos");
+
+ c = utrans_open("Latin-Cyrillic", UTRANS_FORWARD, NULL, -1, NULL, &err);
+ if(U_FAILURE(err))
+ {
+ log_err("Err opening transliterator %s\n", u_errorName(err));
+ u_fclose(f);
+ return;
+ }
+
+ log_verbose("setting a transliterator\n");
+ b = u_fsettransliterator(f, U_WRITE, c, &err);
+ if(U_FAILURE(err))
+ {
+ log_err("Err setting transliterator %s\n", u_errorName(err));
+ u_fclose(f);
+ return;
+ }
+
+ if(b != a)
+ {
+ log_err("Error: a different transliterator was returned!\n");
+ }
+ utrans_close(b);
+
+ u_fprintf(f, "m");
+
+ u_fclose(f);
+
+ log_verbose("Re reading test file to verify transliteration\n");
+ infile = fopen(STANDARD_TEST_FILE, "rb");
+ if(infile == NULL)
+ {
+ log_err("Couldn't reopen test file\n");
+ return;
+ }
+
+ len=fread(ubuf, sizeof(UChar), u_strlen(compare), infile);
+ log_verbose("Read %d UChars\n", len);
+ if(len != u_strlen(compare))
+ {
+ log_err("Wanted %d UChars from file, got %d\n", u_strlen(compare), len);
+ }
+ ubuf[len]=0;
+
+ if(u_strlen(compare) != u_strlen(ubuf))
+ {
+ log_err("Wanted %d UChars from file, but u_strlen() returns %d\n", u_strlen(compare), len);
+ }
+
+ if(u_strcmp(compare, ubuf))
+ {
+ log_err("Read string doesn't match expected.\n");
+ }
+ else
+ {
+ log_verbose("Read string matches expected.\n");
+ }
+
+ fclose(infile);
+#endif
+#endif
+}
+
+static void TestTranslitStringOut(void)
+{
+#if !UCONFIG_NO_FORMATTING
+#if !UCONFIG_NO_TRANSLITERATION
+ UFILE *f;
+ UErrorCode err = U_ZERO_ERROR;
+ UTransliterator *a = NULL, *b = NULL, *c = NULL;
+ UChar compare[] = { 0x03a3, 0x03c4, 0x03b5, 0x03c6, 0x1f00, 0x03bd, 0x03bf, 0x03c2, 0x043C, 0x0000 };
+ UChar ubuf[256];
+
+ log_verbose("opening a transliterator and UFILE for testing\n");
+
+ f = u_fstropen(ubuf, sizeof(ubuf)/sizeof(ubuf[0]), "en_US_POSIX");
+ if(f == NULL)
+ {
+ log_err("Couldn't open test file for writing\n");
+ return;
+ }
+
+ a = utrans_open("Latin-Greek", UTRANS_FORWARD, NULL, -1, NULL, &err);
+ if(U_FAILURE(err))
+ {
+ log_err("Err opening transliterator %s\n", u_errorName(err));
+ u_fclose(f);
+ return;
+ }
+
+ log_verbose("setting a transliterator\n");
+ b = u_fsettransliterator(f, U_WRITE, a, &err);
+ if(U_FAILURE(err))
+ {
+ log_err("Err setting transliterator %s\n", u_errorName(err));
+ u_fclose(f);
+ return;
+ }
+
+ if(b != NULL)
+ {
+ log_err("Err, a transliterator was already set!\n");
+ }
+
+ u_fprintf(f, "Stephanos");
+
+ c = utrans_open("Latin-Cyrillic", UTRANS_FORWARD, NULL, -1, NULL, &err);
+ if(U_FAILURE(err))
+ {
+ log_err("Err opening transliterator %s\n", u_errorName(err));
+ u_fclose(f);
+ return;
+ }
+
+ log_verbose("setting a transliterator\n");
+ b = u_fsettransliterator(f, U_WRITE, c, &err);
+ if(U_FAILURE(err))
+ {
+ log_err("Err setting transliterator %s\n", u_errorName(err));
+ u_fclose(f);
+ return;
+ }
+
+ if(b != a)
+ {
+ log_err("Error: a different transliterator was returned!\n");
+ }
+ utrans_close(b);
+
+ u_fprintf(f, "m");
+
+ u_fclose(f);
+
+ if(u_strlen(compare) != u_strlen(ubuf))
+ {
+ log_err("Wanted %d UChars from file, but u_strlen() returns %d\n", u_strlen(compare), u_strlen(ubuf));
+ }
+
+ if(u_strcmp(compare, ubuf))
+ {
+ log_err("Read string doesn't match expected.\n");
+ }
+ else
+ {
+ log_verbose("Read string matches expected.\n");
+ }
+#endif
+#endif
+}
+
+U_CFUNC void
+addTranslitTest(TestNode** root) {
+#if !UCONFIG_NO_TRANSLITERATION
+ addTest(root, &TestTranslitOps, "translit/ops");
+#if !UCONFIG_NO_FORMATTING
+ addTest(root, &TestTranslitFileOut, "translit/fileOut");
+ addTest(root, &TestTranslitStringOut, "translit/stringOut");
+#endif
+#endif
+}
Property changes on: trunk/source/test/iotest/trnstst.c
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/source/test/letest/FontObject.cpp
===================================================================
--- trunk/source/test/letest/FontObject.cpp 2006-12-21 11:09:23 UTC (rev 127)
+++ trunk/source/test/letest/FontObject.cpp 2006-12-21 11:10:34 UTC (rev 128)
@@ -1,240 +1,240 @@
-/***************************************************************************
-*
-* Copyright (C) 1998-2002, International Business Machines
-* Corporation and others. All Rights Reserved.
-*
-************************************************************************/
-
-#include <stdio.h>
-
-#include "LETypes.h"
-#include "FontObject.h"
-#include "LESwaps.h"
-
-FontObject::FontObject(char *fileName)
- : directory(NULL), numTables(0), searchRange(0),entrySelector(0),
- cmapTable(NULL), cmSegCount(0), cmSearchRange(0), cmEntrySelector(0),
- cmEndCodes(NULL), cmStartCodes(NULL), cmIdDelta(0), cmIdRangeOffset(0),
- headTable(NULL), hmtxTable(NULL), numGlyphs(0), numOfLongHorMetrics(0), file(NULL)
-{
- file = fopen(fileName, "rb");
-
- if (file == NULL) {
- printf("?? Couldn't open %s", fileName);
- return;
- }
-
- SFNTDirectory tempDir;
-
- fread(&tempDir, sizeof tempDir, 1, file);
-
- numTables = SWAPW(tempDir.numTables);
- searchRange = SWAPW(tempDir.searchRange) >> 4;
- entrySelector = SWAPW(tempDir.entrySelector);
- rangeShift = SWAPW(tempDir.rangeShift) >> 4;
-
- int dirSize = sizeof tempDir + ((numTables - ANY_NUMBER) * sizeof(DirectoryEntry));
-
- directory = (SFNTDirectory *) new char[dirSize];
-
- fseek(file, 0L, SEEK_SET);
- fread(directory, sizeof(char), dirSize, file);
-
- initUnicodeCMAP();
-}
-
-FontObject::~FontObject()
-{
- fclose(file);
- delete[] directory;
- delete[] cmapTable;
- delete[] headTable;
- delete[] hmtxTable;
-}
-
-void FontObject::deleteTable(void *table)
-{
- delete[] (char *) table;
-}
-
-DirectoryEntry *FontObject::findTable(LETag tag)
-{
- le_uint16 table = 0;
- le_uint16 probe = 1 << entrySelector;
-
- if (SWAPL(directory->tableDirectory[rangeShift].tag) <= tag) {
- table = rangeShift;
- }
-
- while (probe > (1 << 0)) {
- probe >>= 1;
-
- if (SWAPL(directory->tableDirectory[table + probe].tag) <= tag) {
- table += probe;
- }
- }
-
- if (SWAPL(directory->tableDirectory[table].tag) == tag) {
- return &directory->tableDirectory[table];
- }
-
- return NULL;
-}
-
-void *FontObject::readTable(LETag tag, le_uint32 *length)
-{
- DirectoryEntry *entry = findTable(tag);
-
- if (entry == NULL) {
- *length = 0;
- return NULL;
- }
-
- *length = SWAPL(entry->length);
-
- void *table = new char[*length];
-
- fseek(file, SWAPL(entry->offset), SEEK_SET);
- fread(table, sizeof(char), *length, file);
-
- return table;
-}
-
-CMAPEncodingSubtable *FontObject::findCMAP(le_uint16 platformID, le_uint16 platformSpecificID)
-{
- LETag cmapTag = 0x636D6170; // 'cmap'
-
- if (cmapTable == NULL) {
- le_uint32 length;
-
- cmapTable = (CMAPTable *) readTable(cmapTag, &length);
- }
-
- if (cmapTable != NULL) {
- le_uint16 i;
- le_uint16 nSubtables = SWAPW(cmapTable->numberSubtables);
-
-
- for (i = 0; i < nSubtables; i += 1) {
- CMAPEncodingSubtableHeader *esh = &cmapTable->encodingSubtableHeaders[i];
-
- if (SWAPW(esh->platformID) == platformID &&
- SWAPW(esh->platformSpecificID) == platformSpecificID) {
- return (CMAPEncodingSubtable *) ((char *) cmapTable + SWAPL(esh->encodingOffset));
- }
- }
- }
-
- return NULL;
-}
-
-void FontObject::initUnicodeCMAP()
-{
- CMAPEncodingSubtable *encodingSubtable = findCMAP(3, 1);
-
- if (encodingSubtable == 0 ||
- SWAPW(encodingSubtable->format) != 4) {
- printf("Can't find unicode 'cmap'");
- return;
- }
-
- CMAPFormat4Encoding *header = (CMAPFormat4Encoding *) encodingSubtable;
-
- cmSegCount = SWAPW(header->segCountX2) / 2;
- cmSearchRange = SWAPW(header->searchRange);
- cmEntrySelector = SWAPW(header->entrySelector);
- cmRangeShift = SWAPW(header->rangeShift) / 2;
- cmEndCodes = &header->endCodes[0];
- cmStartCodes = &header->endCodes[cmSegCount + 1]; // + 1 for reservedPad...
- cmIdDelta = &cmStartCodes[cmSegCount];
- cmIdRangeOffset = &cmIdDelta[cmSegCount];
-}
-
-LEGlyphID FontObject::unicodeToGlyph(LEUnicode32 unicode32)
-{
- if (unicode32 >= 0x10000) {
- return 0;
- }
-
- LEUnicode16 unicode = (LEUnicode16) unicode32;
- le_uint16 index = 0;
- le_uint16 probe = 1 << cmEntrySelector;
- LEGlyphID result = 0;
-
- if (SWAPW(cmStartCodes[cmRangeShift]) <= unicode) {
- index = cmRangeShift;
- }
-
- while (probe > (1 << 0)) {
- probe >>= 1;
-
- if (SWAPW(cmStartCodes[index + probe]) <= unicode) {
- index += probe;
- }
- }
-
- if (unicode >= SWAPW(cmStartCodes[index]) && unicode <= SWAPW(cmEndCodes[index])) {
- if (cmIdRangeOffset[index] == 0) {
- result = (LEGlyphID) unicode;
- } else {
- le_uint16 offset = unicode - SWAPW(cmStartCodes[index]);
- le_uint16 rangeOffset = SWAPW(cmIdRangeOffset[index]);
- le_uint16 *glyphIndexTable = (le_uint16 *) ((char *) &cmIdRangeOffset[index] + rangeOffset);
-
- result = SWAPW(glyphIndexTable[offset]);
- }
-
- result += SWAPW(cmIdDelta[index]);
- } else {
- result = 0;
- }
-
- return result;
-}
-
-le_uint16 FontObject::getUnitsPerEM()
-{
- if (headTable == NULL) {
- LETag headTag = 0x68656164; // 'head'
- le_uint32 length;
-
- headTable = (HEADTable *) readTable(headTag, &length);
- }
-
- return SWAPW(headTable->unitsPerEm);
-}
-
-le_uint16 FontObject::getGlyphAdvance(LEGlyphID glyph)
-{
- if (hmtxTable == NULL) {
- LETag maxpTag = 0x6D617870; // 'maxp'
- LETag hheaTag = 0x68686561; // 'hhea'
- LETag hmtxTag = 0x686D7478; // 'hmtx'
- le_uint32 length;
- HHEATable *hheaTable;
- MAXPTable *maxpTable = (MAXPTable *) readTable(maxpTag, &length);
-
- numGlyphs = SWAPW(maxpTable->numGlyphs);
- deleteTable(maxpTable);
-
- hheaTable = (HHEATable *) readTable(hheaTag, &length);
- numOfLongHorMetrics = SWAPW(hheaTable->numOfLongHorMetrics);
- deleteTable(hheaTable);
-
- hmtxTable = (HMTXTable *) readTable(hmtxTag, &length);
- }
-
- le_uint16 index = glyph;
-
- if (glyph >= numGlyphs) {
- return 0;
- }
-
- if (glyph >= numOfLongHorMetrics) {
- index = numOfLongHorMetrics - 1;
- }
-
- return SWAPW(hmtxTable->hMetrics[index].advanceWidth);
-}
-
-
+/***************************************************************************
+*
+* Copyright (C) 1998-2002, International Business Machines
+* Corporation and others. All Rights Reserved.
+*
+************************************************************************/
+
+#include <stdio.h>
+
+#include "LETypes.h"
+#include "FontObject.h"
+#include "LESwaps.h"
+
+FontObject::FontObject(char *fileName)
+ : directory(NULL), numTables(0), searchRange(0),entrySelector(0),
+ cmapTable(NULL), cmSegCount(0), cmSearchRange(0), cmEntrySelector(0),
+ cmEndCodes(NULL), cmStartCodes(NULL), cmIdDelta(0), cmIdRangeOffset(0),
+ headTable(NULL), hmtxTable(NULL), numGlyphs(0), numOfLongHorMetrics(0), file(NULL)
+{
+ file = fopen(fileName, "rb");
+
+ if (file == NULL) {
+ printf("?? Couldn't open %s", fileName);
+ return;
+ }
+
+ SFNTDirectory tempDir;
+
+ fread(&tempDir, sizeof tempDir, 1, file);
+
+ numTables = SWAPW(tempDir.numTables);
+ searchRange = SWAPW(tempDir.searchRange) >> 4;
+ entrySelector = SWAPW(tempDir.entrySelector);
+ rangeShift = SWAPW(tempDir.rangeShift) >> 4;
+
+ int dirSize = sizeof tempDir + ((numTables - ANY_NUMBER) * sizeof(DirectoryEntry));
+
+ directory = (SFNTDirectory *) new char[dirSize];
+
+ fseek(file, 0L, SEEK_SET);
+ fread(directory, sizeof(char), dirSize, file);
+
+ initUnicodeCMAP();
+}
+
+FontObject::~FontObject()
+{
+ fclose(file);
+ delete[] directory;
+ delete[] cmapTable;
+ delete[] headTable;
+ delete[] hmtxTable;
+}
+
+void FontObject::deleteTable(void *table)
+{
+ delete[] (char *) table;
+}
+
+DirectoryEntry *FontObject::findTable(LETag tag)
+{
+ le_uint16 table = 0;
+ le_uint16 probe = 1 << entrySelector;
+
+ if (SWAPL(directory->tableDirectory[rangeShift].tag) <= tag) {
+ table = rangeShift;
+ }
+
+ while (probe > (1 << 0)) {
+ probe >>= 1;
+
+ if (SWAPL(directory->tableDirectory[table + probe].tag) <= tag) {
+ table += probe;
+ }
+ }
+
+ if (SWAPL(directory->tableDirectory[table].tag) == tag) {
+ return &directory->tableDirectory[table];
+ }
+
+ return NULL;
+}
+
+void *FontObject::readTable(LETag tag, le_uint32 *length)
+{
+ DirectoryEntry *entry = findTable(tag);
+
+ if (entry == NULL) {
+ *length = 0;
+ return NULL;
+ }
+
+ *length = SWAPL(entry->length);
+
+ void *table = new char[*length];
+
+ fseek(file, SWAPL(entry->offset), SEEK_SET);
+ fread(table, sizeof(char), *length, file);
+
+ return table;
+}
+
+CMAPEncodingSubtable *FontObject::findCMAP(le_uint16 platformID, le_uint16 platformSpecificID)
+{
+ LETag cmapTag = 0x636D6170; // 'cmap'
+
+ if (cmapTable == NULL) {
+ le_uint32 length;
+
+ cmapTable = (CMAPTable *) readTable(cmapTag, &length);
+ }
+
+ if (cmapTable != NULL) {
+ le_uint16 i;
+ le_uint16 nSubtables = SWAPW(cmapTable->numberSubtables);
+
+
+ for (i = 0; i < nSubtables; i += 1) {
+ CMAPEncodingSubtableHeader *esh = &cmapTable->encodingSubtableHeaders[i];
+
+ if (SWAPW(esh->platformID) == platformID &&
+ SWAPW(esh->platformSpecificID) == platformSpecificID) {
+ return (CMAPEncodingSubtable *) ((char *) cmapTable + SWAPL(esh->encodingOffset));
+ }
+ }
+ }
+
+ return NULL;
+}
+
+void FontObject::initUnicodeCMAP()
+{
+ CMAPEncodingSubtable *encodingSubtable = findCMAP(3, 1);
+
+ if (encodingSubtable == 0 ||
+ SWAPW(encodingSubtable->format) != 4) {
+ printf("Can't find unicode 'cmap'");
+ return;
+ }
+
+ CMAPFormat4Encoding *header = (CMAPFormat4Encoding *) encodingSubtable;
+
+ cmSegCount = SWAPW(header->segCountX2) / 2;
+ cmSearchRange = SWAPW(header->searchRange);
+ cmEntrySelector = SWAPW(header->entrySelector);
+ cmRangeShift = SWAPW(header->rangeShift) / 2;
+ cmEndCodes = &header->endCodes[0];
+ cmStartCodes = &header->endCodes[cmSegCount + 1]; // + 1 for reservedPad...
+ cmIdDelta = &cmStartCodes[cmSegCount];
+ cmIdRangeOffset = &cmIdDelta[cmSegCount];
+}
+
+LEGlyphID FontObject::unicodeToGlyph(LEUnicode32 unicode32)
+{
+ if (unicode32 >= 0x10000) {
+ return 0;
+ }
+
+ LEUnicode16 unicode = (LEUnicode16) unicode32;
+ le_uint16 index = 0;
+ le_uint16 probe = 1 << cmEntrySelector;
+ LEGlyphID result = 0;
+
+ if (SWAPW(cmStartCodes[cmRangeShift]) <= unicode) {
+ index = cmRangeShift;
+ }
+
+ while (probe > (1 << 0)) {
+ probe >>= 1;
+
+ if (SWAPW(cmStartCodes[index + probe]) <= unicode) {
+ index += probe;
+ }
+ }
+
+ if (unicode >= SWAPW(cmStartCodes[index]) && unicode <= SWAPW(cmEndCodes[index])) {
+ if (cmIdRangeOffset[index] == 0) {
+ result = (LEGlyphID) unicode;
+ } else {
+ le_uint16 offset = unicode - SWAPW(cmStartCodes[index]);
+ le_uint16 rangeOffset = SWAPW(cmIdRangeOffset[index]);
+ le_uint16 *glyphIndexTable = (le_uint16 *) ((char *) &cmIdRangeOffset[index] + rangeOffset);
+
+ result = SWAPW(glyphIndexTable[offset]);
+ }
+
+ result += SWAPW(cmIdDelta[index]);
+ } else {
+ result = 0;
+ }
+
+ return result;
+}
+
+le_uint16 FontObject::getUnitsPerEM()
+{
+ if (headTable == NULL) {
+ LETag headTag = 0x68656164; // 'head'
+ le_uint32 length;
+
+ headTable = (HEADTable *) readTable(headTag, &length);
+ }
+
+ return SWAPW(headTable->unitsPerEm);
+}
+
+le_uint16 FontObject::getGlyphAdvance(LEGlyphID glyph)
+{
+ if (hmtxTable == NULL) {
+ LETag maxpTag = 0x6D617870; // 'maxp'
+ LETag hheaTag = 0x68686561; // 'hhea'
+ LETag hmtxTag = 0x686D7478; // 'hmtx'
+ le_uint32 length;
+ HHEATable *hheaTable;
+ MAXPTable *maxpTable = (MAXPTable *) readTable(maxpTag, &length);
+
+ numGlyphs = SWAPW(maxpTable->numGlyphs);
+ deleteTable(maxpTable);
+
+ hheaTable = (HHEATable *) readTable(hheaTag, &length);
+ numOfLongHorMetrics = SWAPW(hheaTable->numOfLongHorMetrics);
+ deleteTable(hheaTable);
+
+ hmtxTable = (HMTXTable *) readTable(hmtxTag, &length);
+ }
+
+ le_uint16 index = glyph;
+
+ if (glyph >= numGlyphs) {
+ return 0;
+ }
+
+ if (glyph >= numOfLongHorMetrics) {
+ index = numOfLongHorMetrics - 1;
+ }
+
+ return SWAPW(hmtxTable->hMetrics[index].advanceWidth);
+}
+
+
Property changes on: trunk/source/test/letest/FontObject.cpp
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/source/test/letest/FontObject.h
===================================================================
--- trunk/source/test/letest/FontObject.h 2006-12-21 11:09:23 UTC (rev 127)
+++ trunk/source/test/letest/FontObject.h 2006-12-21 11:10:34 UTC (rev 128)
@@ -1,235 +1,235 @@
-/***************************************************************************
-*
-* Copyright (C) 1998-2002, International Business Machines
-* Corporation and others. All Rights Reserved.
-*
-************************************************************************/
-
-
-#ifndef __FONTOBJECT_H
-#define __FONTOBJECT_H
-
-#include <stdio.h>
-
-#include "LETypes.h"
-
-
-#ifndef ANY_NUMBER
-#define ANY_NUMBER 1
-#endif
-
-struct DirectoryEntry
-{
- le_uint32 tag;
- le_uint32 checksum;
- le_uint32 offset;
- le_uint32 length;
-};
-
-struct SFNTDirectory
-{
- le_uint32 scalerType;
- le_uint16 numTables;
- le_uint16 searchRange;
- le_uint16 entrySelector;
- le_uint16 rangeShift;
- DirectoryEntry tableDirectory[ANY_NUMBER];
-};
-
-
-struct CMAPEncodingSubtableHeader
-{
- le_uint16 platformID;
- le_uint16 platformSpecificID;
- le_uint32 encodingOffset;
-};
-
-struct CMAPTable
-{
- le_uint16 version;
- le_uint16 numberSubtables;
- CMAPEncodingSubtableHeader encodingSubtableHeaders[ANY_NUMBER];
-};
-
-struct CMAPEncodingSubtable
-{
- le_uint16 format;
- le_uint16 length;
- le_uint16 language;
-};
-
-struct CMAPFormat0Encoding : CMAPEncodingSubtable
-{
- le_uint8 glyphIndexArray[256];
-};
-
-struct CMAPFormat2Subheader
-{
- le_uint16 firstCode;
- le_uint16 entryCount;
- le_int16 idDelta;
- le_uint16 idRangeOffset;
-};
-
-struct CMAPFormat2Encoding : CMAPEncodingSubtable
-{
- le_uint16 subHeadKeys[256];
- CMAPFormat2Subheader subheaders[ANY_NUMBER];
-};
-
-struct CMAPFormat4Encoding : CMAPEncodingSubtable
-{
- le_uint16 segCountX2;
- le_uint16 searchRange;
- le_uint16 entrySelector;
- le_uint16 rangeShift;
- le_uint16 endCodes[ANY_NUMBER];
-// le_uint16 reservedPad;
-// le_uint16 startCodes[ANY_NUMBER];
-// le_uint16 idDelta[ANY_NUMBER];
-// le_uint16 idRangeOffset[ANY_NUMBER];
-// le_uint16 glyphIndexArray[ANY_NUMBER];
-};
-
-struct CMAPFormat6Encoding : CMAPEncodingSubtable
-{
- le_uint16 firstCode;
- le_uint16 entryCount;
- le_uint16 glyphIndexArray[ANY_NUMBER];
-};
-
-typedef le_int32 fixed;
-
-struct BigDate
-{
- le_uint32 bc;
- le_uint32 ad;
-};
-
-struct HEADTable
-{
- fixed version;
- fixed fontRevision;
- le_uint32 checksumAdjustment;
- le_uint32 magicNumber;
- le_uint16 flags;
- le_uint16 unitsPerEm;
- BigDate created;
- BigDate modified;
- le_int16 xMin;
- le_int16 yMin;
- le_int16 xMax;
- le_int16 yMax;
- le_int16 lowestRecPPEM;
- le_int16 fontDirectionHint;
- le_int16 indexToLocFormat;
- le_int16 glyphDataFormat;
-};
-
-struct MAXPTable
-{
- fixed version;
- le_uint16 numGlyphs;
- le_uint16 maxPoints;
- le_uint16 maxContours;
- le_uint16 maxComponentPoints;
- le_uint16 maxComponentContours;
- le_uint16 maxZones;
- le_uint16 maxTwilightPoints;
- le_uint16 maxStorage;
- le_uint16 maxFunctionDefs;
- le_uint16 maxInstructionDefs;
- le_uint16 maxStackElements;
- le_uint16 maxSizeOfInstructions;
- le_uint16 maxComponentElements;
- le_uint16 maxComponentDepth;
-};
-
-struct HHEATable
-{
- fixed version;
- le_int16 ascent;
- le_int16 descent;
- le_int16 lineGap;
- le_uint16 advanceWidthMax;
- le_int16 minLeftSideBearing;
- le_int16 minRightSideBearing;
- le_int16 xMaxExtent;
- le_int16 caretSlopeRise;
- le_int16 caretSlopeRun;
- le_int16 caretOffset;
- le_int16 reserved1;
- le_int16 reserved2;
- le_int16 reserved3;
- le_int16 reserved4;
- le_int16 metricDataFormat;
- le_uint16 numOfLongHorMetrics;
-};
-
-struct LongHorMetric
-{
- le_uint16 advanceWidth;
- le_int16 leftSideBearing;
-};
-
-struct HMTXTable
-{
- LongHorMetric hMetrics[ANY_NUMBER]; // ANY_NUMBER = numOfLongHorMetrics from hhea table
-// le_int16 leftSideBearing[ANY_NUMBER]; // ANY_NUMBER = numGlyphs - numOfLongHorMetrics
-};
-
-class FontObject
-{
-public:
- FontObject(char *fontName);
- ~FontObject();
-
- void *readTable(LETag tag, le_uint32 *length);
- void deleteTable(void *table);
-
- LEGlyphID unicodeToGlyph(LEUnicode32 unicode);
-
-#if 0
- le_uint32 unicodesToGlyphs(LEUnicode *chars, le_uint32 nChars, LEGlyphID *glyphs,
- le_uint32 *charIndices, le_bool rightToLeft);
-#endif
-
- le_uint16 getUnitsPerEM();
-
- le_uint16 getGlyphAdvance(LEGlyphID glyph);
-
-private:
- FontObject();
-
- DirectoryEntry *findTable(LETag tag);
- CMAPEncodingSubtable *findCMAP(le_uint16 platformID, le_uint16 platformSpecificID);
- void initUnicodeCMAP();
-
- SFNTDirectory *directory;
- le_uint16 numTables;
- le_uint16 searchRange;
- le_uint16 entrySelector;
- le_uint16 rangeShift;
-
- CMAPTable *cmapTable;
- le_uint16 cmSegCount;
- le_uint16 cmSearchRange;
- le_uint16 cmEntrySelector;
- le_uint16 cmRangeShift;
- le_uint16 *cmEndCodes;
- le_uint16 *cmStartCodes;
- le_uint16 *cmIdDelta;
- le_uint16 *cmIdRangeOffset;
-
- HEADTable *headTable;
-
- HMTXTable *hmtxTable;
- le_uint16 numGlyphs;
- le_uint16 numOfLongHorMetrics;
-
- FILE *file;
-
-};
-
-#endif
-
+/***************************************************************************
+*
+* Copyright (C) 1998-2002, International Business Machines
+* Corporation and others. All Rights Reserved.
+*
+************************************************************************/
+
+
+#ifndef __FONTOBJECT_H
+#define __FONTOBJECT_H
+
+#include <stdio.h>
+
+#include "LETypes.h"
+
+
+#ifndef ANY_NUMBER
+#define ANY_NUMBER 1
+#endif
+
+struct DirectoryEntry
+{
+ le_uint32 tag;
+ le_uint32 checksum;
+ le_uint32 offset;
+ le_uint32 length;
+};
+
+struct SFNTDirectory
+{
+ le_uint32 scalerType;
+ le_uint16 numTables;
+ le_uint16 searchRange;
+ le_uint16 entrySelector;
+ le_uint16 rangeShift;
+ DirectoryEntry tableDirectory[ANY_NUMBER];
+};
+
+
+struct CMAPEncodingSubtableHeader
+{
+ le_uint16 platformID;
+ le_uint16 platformSpecificID;
+ le_uint32 encodingOffset;
+};
+
+struct CMAPTable
+{
+ le_uint16 version;
+ le_uint16 numberSubtables;
+ CMAPEncodingSubtableHeader encodingSubtableHeaders[ANY_NUMBER];
+};
+
+struct CMAPEncodingSubtable
+{
+ le_uint16 format;
+ le_uint16 length;
+ le_uint16 language;
+};
+
+struct CMAPFormat0Encoding : CMAPEncodingSubtable
+{
+ le_uint8 glyphIndexArray[256];
+};
+
+struct CMAPFormat2Subheader
+{
+ le_uint16 firstCode;
+ le_uint16 entryCount;
+ le_int16 idDelta;
+ le_uint16 idRangeOffset;
+};
+
+struct CMAPFormat2Encoding : CMAPEncodingSubtable
+{
+ le_uint16 subHeadKeys[256];
+ CMAPFormat2Subheader subheaders[ANY_NUMBER];
+};
+
+struct CMAPFormat4Encoding : CMAPEncodingSubtable
+{
+ le_uint16 segCountX2;
+ le_uint16 searchRange;
+ le_uint16 entrySelector;
+ le_uint16 rangeShift;
+ le_uint16 endCodes[ANY_NUMBER];
+// le_uint16 reservedPad;
+// le_uint16 startCodes[ANY_NUMBER];
+// le_uint16 idDelta[ANY_NUMBER];
+// le_uint16 idRangeOffset[ANY_NUMBER];
+// le_uint16 glyphIndexArray[ANY_NUMBER];
+};
+
+struct CMAPFormat6Encoding : CMAPEncodingSubtable
+{
+ le_uint16 firstCode;
+ le_uint16 entryCount;
+ le_uint16 glyphIndexArray[ANY_NUMBER];
+};
+
+typedef le_int32 fixed;
+
+struct BigDate
+{
+ le_uint32 bc;
+ le_uint32 ad;
+};
+
+struct HEADTable
+{
+ fixed version;
+ fixed fontRevision;
+ le_uint32 checksumAdjustment;
+ le_uint32 magicNumber;
+ le_uint16 flags;
+ le_uint16 unitsPerEm;
+ BigDate created;
+ BigDate modified;
+ le_int16 xMin;
+ le_int16 yMin;
+ le_int16 xMax;
+ le_int16 yMax;
+ le_int16 lowestRecPPEM;
+ le_int16 fontDirectionHint;
+ le_int16 indexToLocFormat;
+ le_int16 glyphDataFormat;
+};
+
+struct MAXPTable
+{
+ fixed version;
+ le_uint16 numGlyphs;
+ le_uint16 maxPoints;
+ le_uint16 maxContours;
+ le_uint16 maxComponentPoints;
+ le_uint16 maxComponentContours;
+ le_uint16 maxZones;
+ le_uint16 maxTwilightPoints;
+ le_uint16 maxStorage;
+ le_uint16 maxFunctionDefs;
+ le_uint16 maxInstructionDefs;
+ le_uint16 maxStackElements;
+ le_uint16 maxSizeOfInstructions;
+ le_uint16 maxComponentElements;
+ le_uint16 maxComponentDepth;
+};
+
+struct HHEATable
+{
+ fixed version;
+ le_int16 ascent;
+ le_int16 descent;
+ le_int16 lineGap;
+ le_uint16 advanceWidthMax;
+ le_int16 minLeftSideBearing;
+ le_int16 minRightSideBearing;
+ le_int16 xMaxExtent;
+ le_int16 caretSlopeRise;
+ le_int16 caretSlopeRun;
+ le_int16 caretOffset;
+ le_int16 reserved1;
+ le_int16 reserved2;
+ le_int16 reserved3;
+ le_int16 reserved4;
+ le_int16 metricDataFormat;
+ le_uint16 numOfLongHorMetrics;
+};
+
+struct LongHorMetric
+{
+ le_uint16 advanceWidth;
+ le_int16 leftSideBearing;
+};
+
+struct HMTXTable
+{
+ LongHorMetric hMetrics[ANY_NUMBER]; // ANY_NUMBER = numOfLongHorMetrics from hhea table
+// le_int16 leftSideBearing[ANY_NUMBER]; // ANY_NUMBER = numGlyphs - numOfLongHorMetrics
+};
+
+class FontObject
+{
+public:
+ FontObject(char *fontName);
+ ~FontObject();
+
+ void *readTable(LETag tag, le_uint32 *length);
+ void deleteTable(void *table);
+
+ LEGlyphID unicodeToGlyph(LEUnicode32 unicode);
+
+#if 0
+ le_uint32 unicodesToGlyphs(LEUnicode *chars, le_uint32 nChars, LEGlyphID *glyphs,
+ le_uint32 *charIndices, le_bool rightToLeft);
+#endif
+
+ le_uint16 getUnitsPerEM();
+
+ le_uint16 getGlyphAdvance(LEGlyphID glyph);
+
+private:
+ FontObject();
+
+ DirectoryEntry *findTable(LETag tag);
+ CMAPEncodingSubtable *findCMAP(le_uint16 platformID, le_uint16 platformSpecificID);
+ void initUnicodeCMAP();
+
+ SFNTDirectory *directory;
+ le_uint16 numTables;
+ le_uint16 searchRange;
+ le_uint16 entrySelector;
+ le_uint16 rangeShift;
+
+ CMAPTable *cmapTable;
+ le_uint16 cmSegCount;
+ le_uint16 cmSearchRange;
+ le_uint16 cmEntrySelector;
+ le_uint16 cmRangeShift;
+ le_uint16 *cmEndCodes;
+ le_uint16 *cmStartCodes;
+ le_uint16 *cmIdDelta;
+ le_uint16 *cmIdRangeOffset;
+
+ HEADTable *headTable;
+
+ HMTXTable *hmtxTable;
+ le_uint16 numGlyphs;
+ le_uint16 numOfLongHorMetrics;
+
+ FILE *file;
+
+};
+
+#endif
+
Property changes on: trunk/source/test/letest/FontObject.h
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/source/test/letest/FontTableCache.cpp
===================================================================
--- trunk/source/test/letest/FontTableCache.cpp 2006-12-21 11:09:23 UTC (rev 127)
+++ trunk/source/test/letest/FontTableCache.cpp 2006-12-21 11:10:34 UTC (rev 128)
@@ -1,86 +1,86 @@
-/*
- **********************************************************************
- * Copyright (C) 2003-2006, International Business Machines
- * Corporation and others. All Rights Reserved.
- **********************************************************************
- */
-
-#include "layout/LETypes.h"
-
-#include "letest.h"
-#include "FontTableCache.h"
-
-#define TABLE_CACHE_INIT 5
-#define TABLE_CACHE_GROW 5
-
-struct FontTableCacheEntry
-{
- LETag tag;
- const void *table;
-};
-
-FontTableCache::FontTableCache()
- : fTableCacheCurr(0), fTableCacheSize(TABLE_CACHE_INIT)
-{
- fTableCache = NEW_ARRAY(FontTableCacheEntry, fTableCacheSize);
-
- if (fTableCache == NULL) {
- fTableCacheSize = 0;
- return;
- }
-
- for (int i = 0; i < fTableCacheSize; i += 1) {
- fTableCache[i].tag = 0;
- fTableCache[i].table = NULL;
- }
-}
-
-FontTableCache::~FontTableCache()
-{
- for (int i = fTableCacheCurr - 1; i >= 0; i -= 1) {
- DELETE_ARRAY(fTableCache[i].table);
-
- fTableCache[i].tag = 0;
- fTableCache[i].table = NULL;
- }
-
- fTableCacheCurr = 0;
-
- DELETE_ARRAY(fTableCache);
-}
-
-const void *FontTableCache::find(LETag tableTag) const
-{
- for (int i = 0; i < fTableCacheCurr; i += 1) {
- if (fTableCache[i].tag == tableTag) {
- return fTableCache[i].table;
- }
- }
-
- const void *table = readFontTable(tableTag);
-
- ((FontTableCache *) this)->add(tableTag, table);
-
- return table;
-}
-
-void FontTableCache::add(LETag tableTag, const void *table)
-{
- if (fTableCacheCurr >= fTableCacheSize) {
- le_int32 newSize = fTableCacheSize + TABLE_CACHE_GROW;
-
- fTableCache = (FontTableCacheEntry *) GROW_ARRAY(fTableCache, newSize);
-
- for (le_int32 i = fTableCacheSize; i < newSize; i += 1) {
- fTableCache[i].tag = 0;
- fTableCache[i].table = NULL;
- }
-
- fTableCacheSize = newSize;
- }
-
- fTableCache[fTableCacheCurr].tag = tableTag;
- fTableCache[fTableCacheCurr].table = table;
-
- fTableCacheCurr += 1;
-}
+/*
+ **********************************************************************
+ * Copyright (C) 2003-2006, International Business Machines
+ * Corporation and others. All Rights Reserved.
+ **********************************************************************
+ */
+
+#include "layout/LETypes.h"
+
+#include "letest.h"
+#include "FontTableCache.h"
+
+#define TABLE_CACHE_INIT 5
+#define TABLE_CACHE_GROW 5
+
+struct FontTableCacheEntry
+{
+ LETag tag;
+ const void *table;
+};
+
+FontTableCache::FontTableCache()
+ : fTableCacheCurr(0), fTableCacheSize(TABLE_CACHE_INIT)
+{
+ fTableCache = NEW_ARRAY(FontTableCacheEntry, fTableCacheSize);
+
+ if (fTableCache == NULL) {
+ fTableCacheSize = 0;
+ return;
+ }
+
+ for (int i = 0; i < fTableCacheSize; i += 1) {
+ fTableCache[i].tag = 0;
+ fTableCache[i].table = NULL;
+ }
+}
+
+FontTableCache::~FontTableCache()
+{
+ for (int i = fTableCacheCurr - 1; i >= 0; i -= 1) {
+ DELETE_ARRAY(fTableCache[i].table);
+
+ fTableCache[i].tag = 0;
+ fTableCache[i].table = NULL;
+ }
+
+ fTableCacheCurr = 0;
+
+ DELETE_ARRAY(fTableCache);
+}
+
+const void *FontTableCache::find(LETag tableTag) const
+{
+ for (int i = 0; i < fTableCacheCurr; i += 1) {
+ if (fTableCache[i].tag == tableTag) {
+ return fTableCache[i].table;
+ }
+ }
+
+ const void *table = readFontTable(tableTag);
+
+ ((FontTableCache *) this)->add(tableTag, table);
+
+ return table;
+}
+
+void FontTableCache::add(LETag tableTag, const void *table)
+{
+ if (fTableCacheCurr >= fTableCacheSize) {
+ le_int32 newSize = fTableCacheSize + TABLE_CACHE_GROW;
+
+ fTableCache = (FontTableCacheEntry *) GROW_ARRAY(fTableCache, newSize);
+
+ for (le_int32 i = fTableCacheSize; i < newSize; i += 1) {
+ fTableCache[i].tag = 0;
+ fTableCache[i].table = NULL;
+ }
+
+ fTableCacheSize = newSize;
+ }
+
+ fTableCache[fTableCacheCurr].tag = tableTag;
+ fTableCache[fTableCacheCurr].table = table;
+
+ fTableCacheCurr += 1;
+}
Property changes on: trunk/source/test/letest/FontTableCache.cpp
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/source/test/letest/FontTableCache.h
===================================================================
--- trunk/source/test/letest/FontTableCache.h 2006-12-21 11:09:23 UTC (rev 127)
+++ trunk/source/test/letest/FontTableCache.h 2006-12-21 11:10:34 UTC (rev 128)
@@ -1,38 +1,38 @@
-/*
- **********************************************************************
- * Copyright (C) 2003, International Business Machines
- * Corporation and others. All Rights Reserved.
- **********************************************************************
- */
-
-#ifndef __FONTTABLECACHE_H
-
-#define __FONTTABLECACHE_H
-
-#include "layout/LETypes.h"
-
-struct FontTableCacheEntry;
-
-class FontTableCache
-{
-public:
- FontTableCache();
-
- virtual ~FontTableCache();
-
- const void *find(LETag tableTag) const;
-
-protected:
- virtual const void *readFontTable(LETag tableTag) const = 0;
-
-private:
-
- void add(LETag tableTag, const void *table);
-
- FontTableCacheEntry *fTableCache;
- le_int32 fTableCacheCurr;
- le_int32 fTableCacheSize;
-};
-
-#endif
-
+/*
+ **********************************************************************
+ * Copyright (C) 2003, International Business Machines
+ * Corporation and others. All Rights Reserved.
+ **********************************************************************
+ */
+
+#ifndef __FONTTABLECACHE_H
+
+#define __FONTTABLECACHE_H
+
+#include "layout/LETypes.h"
+
+struct FontTableCacheEntry;
+
+class FontTableCache
+{
+public:
+ FontTableCache();
+
+ virtual ~FontTableCache();
+
+ const void *find(LETag tableTag) const;
+
+protected:
+ virtual const void *readFontTable(LETag tableTag) const = 0;
+
+private:
+
+ void add(LETag tableTag, const void *table);
+
+ FontTableCacheEntry *fTableCache;
+ le_int32 fTableCacheCurr;
+ le_int32 fTableCacheSize;
+};
+
+#endif
+
Property changes on: trunk/source/test/letest/FontTableCache.h
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/source/test/letest/Makefile.in
===================================================================
--- trunk/source/test/letest/Makefile.in 2006-12-21 11:09:23 UTC (rev 127)
+++ trunk/source/test/letest/Makefile.in 2006-12-21 11:10:34 UTC (rev 128)
@@ -1,102 +1,102 @@
-## Makefile.in for ICU - test/letest
-## Copyright (c) 2001-2006, International Business Machines Corporation and
-## others. All Rights Reserved.
-
-## Source directory information
-srcdir = @srcdir@
-top_srcdir = @top_srcdir@
-
-top_builddir = ../..
-
-include $(top_builddir)/icudefs.mk
-
-## Platform-specific setup
-include @platform_make_fragment@
-
-## Build directory information
-subdir = test/letest
-
-## Extra files to remove for 'make clean'
-CLEANFILES = *~ $(DEPS)
-
-## Target information
-TESTTARGET = letest
-GENTARGET = gendata
-
-BUILDDIR := $(CURR_SRCCODE_FULL_DIR)/../../
-# Simplify the path for Unix
-BUILDDIR := $(BUILDDIR:test/cintltst/../../=)
-# Simplify the path for Windows
-BUILDDIR := $(BUILDDIR:test\\cintltst/../../=)
-# Simplify the path for Windows 98
-BUILDDIR := $(BUILDDIR:TEST\\CINTLTST/../../=)
-
-ifneq ($(top_builddir),$(top_srcdir))
-CPPFLAGS += -I$(top_builddir)/common
-endif
-
-CPPFLAGS += -I$(top_builddir)/common -I$(top_srcdir)/common -I$(top_srcdir)/i18n -I$(top_srcdir)/tools/ctestfw -I$(top_srcdir)/tools/toolutil -I$(top_srcdir)/layout -I$(top_srcdir)
-DEFS += -D'U_TOPSRCDIR="$(top_srcdir)/"' -D'U_TOPBUILDDIR="$(BUILDDIR)"'
-LIBS = $(LIBICULE) $(LIBICUUC) $(LIBICUI18N) $(LIBCTESTFW) $(LIBICUTOOLUTIL) @LIBS@ @LIB_M@
-
-COMMONOBJECTS = letsutil.o cmaps.o FontTableCache.o SimpleFontInstance.o PortableFontInstance.o
-TESTOBJECTS = letest.o
-GENOBJECTS = gendata.o
-
-OBJECTS = $(COMMONOBJECTS) $(TESTOBJECTS) $(GENOBJECTS)
-
-DEPS = $(OBJECTS:.o=.d)
-
-## List of phony targets
-.PHONY : all all-local install install-local clean clean-local \
-distclean distclean-local dist dist-local check check-local
-
-## Clear suffix list
-.SUFFIXES :
-
-## List of standard targets
-all: all-local
-install: install-local
-clean: clean-local
-distclean : distclean-local
-dist: dist-local
-check: all check-local
-
-all-local: $(TESTTARGET)
-
-install-local:
-
-dist-local:
-
-clean-local:
- test -z "$(CLEANFILES)" || $(RMV) $(CLEANFILES)
- $(RMV) $(OBJECTS) $(TARGET)
-
-distclean-local: clean-local
- $(RMV) Makefile
-
-check-local: all-local
- $(INVOKE) ./$(TESTTARGET)
-
-Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
- cd $(top_builddir) \
- && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
-
-$(TESTTARGET) : $(COMMONOBJECTS) $(TESTOBJECTS)
- $(LINK.cc) -o $@ $^ $(LIBS)
-
-$(GENTARGET) : $(COMMONOBJECTS) $(GENOBJECTS)
- $(LINK.cc) -o $@ $^ $(LIBS)
-
-invoke:
- ICU_DATA=$${ICU_DATA:-$(top_builddir)/data/} TZ=PST8PDT $(INVOKE) $(INVOCATION)
-
-ifeq (,$(MAKECMDGOALS))
--include $(DEPS)
-else
-ifneq ($(patsubst %clean,,$(MAKECMDGOALS)),)
-ifneq ($(patsubst %install,,$(MAKECMDGOALS)),)
--include $(DEPS)
-endif
-endif
-endif
+## Makefile.in for ICU - test/letest
+## Copyright (c) 2001-2006, International Business Machines Corporation and
+## others. All Rights Reserved.
+
+## Source directory information
+srcdir = @srcdir@
+top_srcdir = @top_srcdir@
+
+top_builddir = ../..
+
+include $(top_builddir)/icudefs.mk
+
+## Platform-specific setup
+include @platform_make_fragment@
+
+## Build directory information
+subdir = test/letest
+
+## Extra files to remove for 'make clean'
+CLEANFILES = *~ $(DEPS)
+
+## Target information
+TESTTARGET = letest
+GENTARGET = gendata
+
+BUILDDIR := $(CURR_SRCCODE_FULL_DIR)/../../
+# Simplify the path for Unix
+BUILDDIR := $(BUILDDIR:test/cintltst/../../=)
+# Simplify the path for Windows
+BUILDDIR := $(BUILDDIR:test\\cintltst/../../=)
+# Simplify the path for Windows 98
+BUILDDIR := $(BUILDDIR:TEST\\CINTLTST/../../=)
+
+ifneq ($(top_builddir),$(top_srcdir))
+CPPFLAGS += -I$(top_builddir)/common
+endif
+
+CPPFLAGS += -I$(top_builddir)/common -I$(top_srcdir)/common -I$(top_srcdir)/i18n -I$(top_srcdir)/tools/ctestfw -I$(top_srcdir)/tools/toolutil -I$(top_srcdir)/layout -I$(top_srcdir)
+DEFS += -D'U_TOPSRCDIR="$(top_srcdir)/"' -D'U_TOPBUILDDIR="$(BUILDDIR)"'
+LIBS = $(LIBICULE) $(LIBICUUC) $(LIBICUI18N) $(LIBCTESTFW) $(LIBICUTOOLUTIL) @LIBS@ @LIB_M@
+
+COMMONOBJECTS = letsutil.o cmaps.o FontTableCache.o SimpleFontInstance.o PortableFontInstance.o
+TESTOBJECTS = letest.o
+GENOBJECTS = gendata.o
+
+OBJECTS = $(COMMONOBJECTS) $(TESTOBJECTS) $(GENOBJECTS)
+
+DEPS = $(OBJECTS:.o=.d)
+
+## List of phony targets
+.PHONY : all all-local install install-local clean clean-local \
+distclean distclean-local dist dist-local check check-local
+
+## Clear suffix list
+.SUFFIXES :
+
+## List of standard targets
+all: all-local
+install: install-local
+clean: clean-local
+distclean : distclean-local
+dist: dist-local
+check: all check-local
+
+all-local: $(TESTTARGET)
+
+install-local:
+
+dist-local:
+
+clean-local:
+ test -z "$(CLEANFILES)" || $(RMV) $(CLEANFILES)
+ $(RMV) $(OBJECTS) $(TARGET)
+
+distclean-local: clean-local
+ $(RMV) Makefile
+
+check-local: all-local
+ $(INVOKE) ./$(TESTTARGET)
+
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ cd $(top_builddir) \
+ && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
+
+$(TESTTARGET) : $(COMMONOBJECTS) $(TESTOBJECTS)
+ $(LINK.cc) -o $@ $^ $(LIBS)
+
+$(GENTARGET) : $(COMMONOBJECTS) $(GENOBJECTS)
+ $(LINK.cc) -o $@ $^ $(LIBS)
+
+invoke:
+ ICU_DATA=$${ICU_DATA:-$(top_builddir)/data/} TZ=PST8PDT $(INVOKE) $(INVOCATION)
+
+ifeq (,$(MAKECMDGOALS))
+-include $(DEPS)
+else
+ifneq ($(patsubst %clean,,$(MAKECMDGOALS)),)
+ifneq ($(patsubst %install,,$(MAKECMDGOALS)),)
+-include $(DEPS)
+endif
+endif
+endif
Property changes on: trunk/source/test/letest/Makefile.in
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/source/test/letest/PortableFontInstance.cpp
===================================================================
--- trunk/source/test/letest/PortableFontInstance.cpp 2006-12-21 11:09:23 UTC (rev 127)
+++ trunk/source/test/letest/PortableFontInstance.cpp 2006-12-21 11:10:34 UTC (rev 128)
@@ -1,400 +1,400 @@
-/*
- *******************************************************************************
- *
- * Copyright (C) 1999-2006, International Business Machines
- * Corporation and others. All Rights Reserved.
- *
- *******************************************************************************
- * file name: PortableFontInstance.cpp
- *
- * created on: 11/22/1999
- * created by: Eric R. Mader
- */
-
-#include <stdio.h>
-
-#include "layout/LETypes.h"
-#include "layout/LEFontInstance.h"
-#include "layout/LESwaps.h"
-
-#include "PortableFontInstance.h"
-
-#include "letest.h"
-#include "sfnt.h"
-
-#include <string.h>
-
-//
-// Finds the high bit by binary searching
-// through the bits in n.
-//
-le_int8 PortableFontInstance::highBit(le_int32 value)
-{
- if (value <= 0) {
- return -32;
- }
-
- le_uint8 bit = 0;
-
- if (value >= 1 << 16) {
- value >>= 16;
- bit += 16;
- }
-
- if (value >= 1 << 8) {
- value >>= 8;
- bit += 8;
- }
-
- if (value >= 1 << 4) {
- value >>= 4;
- bit += 4;
- }
-
- if (value >= 1 << 2) {
- value >>= 2;
- bit += 2;
- }
-
- if (value >= 1 << 1) {
- value >>= 1;
- bit += 1;
- }
-
- return bit;
-}
-
-PortableFontInstance::PortableFontInstance(const char *fileName, float pointSize, LEErrorCode &status)
- : fFile(NULL), fPointSize(pointSize), fUnitsPerEM(0), fFontChecksum(0), fAscent(0), fDescent(0), fLeading(0),
- fDirectory(NULL), fNAMETable(NULL), fNameCount(0), fNameStringOffset(0), fCMAPMapper(NULL), fHMTXTable(NULL), fNumGlyphs(0), fNumLongHorMetrics(0)
-{
- if (LE_FAILURE(status)) {
- return;
- }
-
- // open the font file
- fFile = fopen(fileName, "rb");
-
- if (fFile == NULL) {
- status = LE_FONT_FILE_NOT_FOUND_ERROR;
- return;
- }
-
- // read in the directory
- SFNTDirectory tempDir;
-
- fread(&tempDir, sizeof tempDir, 1, fFile);
-
- le_int32 dirSize = sizeof tempDir + ((SWAPW(tempDir.numTables) - ANY_NUMBER) * sizeof(DirectoryEntry));
- const LETag headTag = LE_HEAD_TABLE_TAG;
- const LETag hheaTag = LE_HHEA_TABLE_TAG;
- const HEADTable *headTable = NULL;
- const HHEATable *hheaTable = NULL;
-// const NAMETable *nameTable = NULL;
- le_uint16 numTables = 0;
-
- fDirectory = (const SFNTDirectory *) NEW_ARRAY(char, dirSize);
-
- if (fDirectory == NULL) {
- status = LE_MEMORY_ALLOCATION_ERROR;
- goto error_exit;
- }
-
- fseek(fFile, 0L, SEEK_SET);
- fread((void *) fDirectory, sizeof(char), dirSize, fFile);
-
- //
- // We calculate these numbers 'cause some fonts
- // have bogus values for them in the directory header.
- //
- numTables = SWAPW(fDirectory->numTables);
- fDirPower = 1 << highBit(numTables);
- fDirExtra = numTables - fDirPower;
-
- // read unitsPerEm from 'head' table
- headTable = (const HEADTable *) readFontTable(headTag);
-
- if (headTable == NULL) {
- status = LE_MISSING_FONT_TABLE_ERROR;
- goto error_exit;
- }
-
- fUnitsPerEM = SWAPW(headTable->unitsPerEm);
- fFontChecksum = SWAPL(headTable->checksumAdjustment);
- deleteTable(headTable);
-
- //nameTable = (NAMETable *) readFontTable(nameTag);
-
- //if (nameTable == NULL) {
- // status = LE_MISSING_FONT_TABLE_ERROR;
- // goto error_exit;
- //}
-
- //fFontVersionString = findName(nameTable, NAME_VERSION_STRING, PLATFORM_MACINTOSH, MACINTOSH_ROMAN, MACINTOSH_ENGLISH);
-
- //if (fFontVersionString == NULL) {
- // status = LE_MISSING_FONT_TABLE_ERROR;
- // goto error_exit;
- //}
-
- //deleteTable(nameTable);
-
- hheaTable = (HHEATable *) readFontTable(hheaTag);
-
- if (hheaTable == NULL) {
- status = LE_MISSING_FONT_TABLE_ERROR;
- goto error_exit;
- }
-
- fAscent = (le_int32) yUnitsToPoints((float) SWAPW(hheaTable->ascent));
- fDescent = (le_int32) yUnitsToPoints((float) SWAPW(hheaTable->descent));
- fLeading = (le_int32) yUnitsToPoints((float) SWAPW(hheaTable->lineGap));
-
- fNumLongHorMetrics = SWAPW(hheaTable->numOfLongHorMetrics);
-
- deleteTable((void *) hheaTable);
-
- fCMAPMapper = findUnicodeMapper();
-
- if (fCMAPMapper == NULL) {
- status = LE_MISSING_FONT_TABLE_ERROR;
- goto error_exit;
- }
-
- return;
-
-error_exit:
- fclose(fFile);
- fFile = NULL;
- return;
-}
-
-PortableFontInstance::~PortableFontInstance()
-{
- if (fFile != NULL) {
- fclose(fFile);
-
- deleteTable(fHMTXTable);
- deleteTable(fNAMETable);
-
- delete fCMAPMapper;
-
- DELETE_ARRAY(fDirectory);
- }
-}
-
-void PortableFontInstance::deleteTable(const void *table) const
-{
- DELETE_ARRAY(table);
-}
-
-const DirectoryEntry *PortableFontInstance::findTable(LETag tag) const
-{
- if (fDirectory != NULL) {
- le_uint16 table = 0;
- le_uint16 probe = fDirPower;
-
- if (SWAPL(fDirectory->tableDirectory[fDirExtra].tag) <= tag) {
- table = fDirExtra;
- }
-
- while (probe > (1 << 0)) {
- probe >>= 1;
-
- if (SWAPL(fDirectory->tableDirectory[table + probe].tag) <= tag) {
- table += probe;
- }
- }
-
- if (SWAPL(fDirectory->tableDirectory[table].tag) == tag) {
- return &fDirectory->tableDirectory[table];
- }
- }
-
- return NULL;
-}
-
-const void *PortableFontInstance::readTable(LETag tag, le_uint32 *length) const
-{
- const DirectoryEntry *entry = findTable(tag);
-
- if (entry == NULL) {
- *length = 0;
- return NULL;
- }
-
- *length = SWAPL(entry->length);
-
- void *table = NEW_ARRAY(char, *length);
-
- if (table != NULL) {
- fseek(fFile, SWAPL(entry->offset), SEEK_SET);
- fread(table, sizeof(char), *length, fFile);
- }
-
- return table;
-}
-
-const void *PortableFontInstance::getFontTable(LETag tableTag) const
-{
- return FontTableCache::find(tableTag);
-}
-
-const void *PortableFontInstance::readFontTable(LETag tableTag) const
-{
- le_uint32 len;
-
- return readTable(tableTag, &len);
-}
-
-CMAPMapper *PortableFontInstance::findUnicodeMapper()
-{
- LETag cmapTag = LE_CMAP_TABLE_TAG;
- const CMAPTable *cmap = (CMAPTable *) readFontTable(cmapTag);
-
- if (cmap == NULL) {
- return NULL;
- }
-
- return CMAPMapper::createUnicodeMapper(cmap);
-}
-
-const char *PortableFontInstance::getNameString(le_uint16 nameID, le_uint16 platformID, le_uint16 encodingID, le_uint16 languageID) const
-{
- if (fNAMETable == NULL) {
- LETag nameTag = LE_NAME_TABLE_TAG;
- PortableFontInstance *realThis = (PortableFontInstance *) this;
-
- realThis->fNAMETable = (const NAMETable *) readFontTable(nameTag);
-
- if (realThis->fNAMETable != NULL) {
- realThis->fNameCount = SWAPW(realThis->fNAMETable->count);
- realThis->fNameStringOffset = SWAPW(realThis->fNAMETable->stringOffset);
- }
- }
-
- for(le_int32 i = 0; i < fNameCount; i += 1) {
- const NameRecord *nameRecord = &fNAMETable->nameRecords[i];
-
- if (SWAPW(nameRecord->platformID) == platformID && SWAPW(nameRecord->encodingID == encodingID) &&
- SWAPW(nameRecord->languageID) == languageID && SWAPW(nameRecord->nameID) == nameID) {
- char *name = ((char *) fNAMETable) + fNameStringOffset + SWAPW(nameRecord->offset);
- le_uint16 length = SWAPW(nameRecord->length);
- char *result = NEW_ARRAY(char, length + 2);
-
- ARRAY_COPY(result, name, length);
- result[length] = result[length + 1] = 0;
-
- return result;
- }
- }
-
- return NULL;
-}
-
-void PortableFontInstance::deleteNameString(const char *name) const
-{
- DELETE_ARRAY(name);
-}
-
-void PortableFontInstance::getGlyphAdvance(LEGlyphID glyph, LEPoint &advance) const
-{
- TTGlyphID ttGlyph = (TTGlyphID) LE_GET_GLYPH(glyph);
-
- if (fHMTXTable == NULL) {
- LETag maxpTag = LE_MAXP_TABLE_TAG;
- LETag hmtxTag = LE_HMTX_TABLE_TAG;
- const MAXPTable *maxpTable = (MAXPTable *) readFontTable(maxpTag);
- PortableFontInstance *realThis = (PortableFontInstance *) this;
-
- if (maxpTable != NULL) {
- realThis->fNumGlyphs = SWAPW(maxpTable->numGlyphs);
- deleteTable(maxpTable);
- }
-
- realThis->fHMTXTable = (const HMTXTable *) readFontTable(hmtxTag);
- }
-
- le_uint16 index = ttGlyph;
-
- if (ttGlyph >= fNumGlyphs || fHMTXTable == NULL) {
- advance.fX = advance.fY = 0;
- return;
- }
-
- if (ttGlyph >= fNumLongHorMetrics) {
- index = fNumLongHorMetrics - 1;
- }
-
- advance.fX = xUnitsToPoints(SWAPW(fHMTXTable->hMetrics[index].advanceWidth));
- advance.fY = 0;
-}
-
-le_bool PortableFontInstance::getGlyphPoint(LEGlyphID /*glyph*/, le_int32 /*pointNumber*/, LEPoint &/*point*/) const
-{
- return FALSE;
-}
-
-le_int32 PortableFontInstance::getUnitsPerEM() const
-{
- return fUnitsPerEM;
-}
-
-le_uint32 PortableFontInstance::getFontChecksum() const
-{
- return fFontChecksum;
-}
-
-le_int32 PortableFontInstance::getAscent() const
-{
- return fAscent;
-}
-
-le_int32 PortableFontInstance::getDescent() const
-{
- return fDescent;
-}
-
-le_int32 PortableFontInstance::getLeading() const
-{
- return fLeading;
-}
-
-// We really want to inherit this method from the superclass, but some compilers
-// issue a warning if we don't implement it...
-LEGlyphID PortableFontInstance::mapCharToGlyph(LEUnicode32 ch, const LECharMapper *mapper, le_bool filterZeroWidth) const
-{
- return LEFontInstance::mapCharToGlyph(ch, mapper, filterZeroWidth);
-}
-
-// We really want to inherit this method from the superclass, but some compilers
-// issue a warning if we don't implement it...
-LEGlyphID PortableFontInstance::mapCharToGlyph(LEUnicode32 ch, const LECharMapper *mapper) const
-{
- return LEFontInstance::mapCharToGlyph(ch, mapper);
-}
-
-LEGlyphID PortableFontInstance::mapCharToGlyph(LEUnicode32 ch) const
-{
- return fCMAPMapper->unicodeToGlyph(ch);
-}
-
-float PortableFontInstance::getXPixelsPerEm() const
-{
- return fPointSize;
-}
-
-float PortableFontInstance::getYPixelsPerEm() const
-{
- return fPointSize;
-}
-
-float PortableFontInstance::getScaleFactorX() const
-{
- return 1.0;
-}
-
-float PortableFontInstance::getScaleFactorY() const
-{
- return 1.0;
-}
+/*
+ *******************************************************************************
+ *
+ * Copyright (C) 1999-2006, International Business Machines
+ * Corporation and others. All Rights Reserved.
+ *
+ *******************************************************************************
+ * file name: PortableFontInstance.cpp
+ *
+ * created on: 11/22/1999
+ * created by: Eric R. Mader
+ */
+
+#include <stdio.h>
+
+#include "layout/LETypes.h"
+#include "layout/LEFontInstance.h"
+#include "layout/LESwaps.h"
+
+#include "PortableFontInstance.h"
+
+#include "letest.h"
+#include "sfnt.h"
+
+#include <string.h>
+
+//
+// Finds the high bit by binary searching
+// through the bits in n.
+//
+le_int8 PortableFontInstance::highBit(le_int32 value)
+{
+ if (value <= 0) {
+ return -32;
+ }
+
+ le_uint8 bit = 0;
+
+ if (value >= 1 << 16) {
+ value >>= 16;
+ bit += 16;
+ }
+
+ if (value >= 1 << 8) {
+ value >>= 8;
+ bit += 8;
+ }
+
+ if (value >= 1 << 4) {
+ value >>= 4;
+ bit += 4;
+ }
+
+ if (value >= 1 << 2) {
+ value >>= 2;
+ bit += 2;
+ }
+
+ if (value >= 1 << 1) {
+ value >>= 1;
+ bit += 1;
+ }
+
+ return bit;
+}
+
+PortableFontInstance::PortableFontInstance(const char *fileName, float pointSize, LEErrorCode &status)
+ : fFile(NULL), fPointSize(pointSize), fUnitsPerEM(0), fFontChecksum(0), fAscent(0), fDescent(0), fLeading(0),
+ fDirectory(NULL), fNAMETable(NULL), fNameCount(0), fNameStringOffset(0), fCMAPMapper(NULL), fHMTXTable(NULL), fNumGlyphs(0), fNumLongHorMetrics(0)
+{
+ if (LE_FAILURE(status)) {
+ return;
+ }
+
+ // open the font file
+ fFile = fopen(fileName, "rb");
+
+ if (fFile == NULL) {
+ status = LE_FONT_FILE_NOT_FOUND_ERROR;
+ return;
+ }
+
+ // read in the directory
+ SFNTDirectory tempDir;
+
+ fread(&tempDir, sizeof tempDir, 1, fFile);
+
+ le_int32 dirSize = sizeof tempDir + ((SWAPW(tempDir.numTables) - ANY_NUMBER) * sizeof(DirectoryEntry));
+ const LETag headTag = LE_HEAD_TABLE_TAG;
+ const LETag hheaTag = LE_HHEA_TABLE_TAG;
+ const HEADTable *headTable = NULL;
+ const HHEATable *hheaTable = NULL;
+// const NAMETable *nameTable = NULL;
+ le_uint16 numTables = 0;
+
+ fDirectory = (const SFNTDirectory *) NEW_ARRAY(char, dirSize);
+
+ if (fDirectory == NULL) {
+ status = LE_MEMORY_ALLOCATION_ERROR;
+ goto error_exit;
+ }
+
+ fseek(fFile, 0L, SEEK_SET);
+ fread((void *) fDirectory, sizeof(char), dirSize, fFile);
+
+ //
+ // We calculate these numbers 'cause some fonts
+ // have bogus values for them in the directory header.
+ //
+ numTables = SWAPW(fDirectory->numTables);
+ fDirPower = 1 << highBit(numTables);
+ fDirExtra = numTables - fDirPower;
+
+ // read unitsPerEm from 'head' table
+ headTable = (const HEADTable *) readFontTable(headTag);
+
+ if (headTable == NULL) {
+ status = LE_MISSING_FONT_TABLE_ERROR;
+ goto error_exit;
+ }
+
+ fUnitsPerEM = SWAPW(headTable->unitsPerEm);
+ fFontChecksum = SWAPL(headTable->checksumAdjustment);
+ deleteTable(headTable);
+
+ //nameTable = (NAMETable *) readFontTable(nameTag);
+
+ //if (nameTable == NULL) {
+ // status = LE_MISSING_FONT_TABLE_ERROR;
+ // goto error_exit;
+ //}
+
+ //fFontVersionString = findName(nameTable, NAME_VERSION_STRING, PLATFORM_MACINTOSH, MACINTOSH_ROMAN, MACINTOSH_ENGLISH);
+
+ //if (fFontVersionString == NULL) {
+ // status = LE_MISSING_FONT_TABLE_ERROR;
+ // goto error_exit;
+ //}
+
+ //deleteTable(nameTable);
+
+ hheaTable = (HHEATable *) readFontTable(hheaTag);
+
+ if (hheaTable == NULL) {
+ status = LE_MISSING_FONT_TABLE_ERROR;
+ goto error_exit;
+ }
+
+ fAscent = (le_int32) yUnitsToPoints((float) SWAPW(hheaTable->ascent));
+ fDescent = (le_int32) yUnitsToPoints((float) SWAPW(hheaTable->descent));
+ fLeading = (le_int32) yUnitsToPoints((float) SWAPW(hheaTable->lineGap));
+
+ fNumLongHorMetrics = SWAPW(hheaTable->numOfLongHorMetrics);
+
+ deleteTable((void *) hheaTable);
+
+ fCMAPMapper = findUnicodeMapper();
+
+ if (fCMAPMapper == NULL) {
+ status = LE_MISSING_FONT_TABLE_ERROR;
+ goto error_exit;
+ }
+
+ return;
+
+error_exit:
+ fclose(fFile);
+ fFile = NULL;
+ return;
+}
+
+PortableFontInstance::~PortableFontInstance()
+{
+ if (fFile != NULL) {
+ fclose(fFile);
+
+ deleteTable(fHMTXTable);
+ deleteTable(fNAMETable);
+
+ delete fCMAPMapper;
+
+ DELETE_ARRAY(fDirectory);
+ }
+}
+
+void PortableFontInstance::deleteTable(const void *table) const
+{
+ DELETE_ARRAY(table);
+}
+
+const DirectoryEntry *PortableFontInstance::findTable(LETag tag) const
+{
+ if (fDirectory != NULL) {
+ le_uint16 table = 0;
+ le_uint16 probe = fDirPower;
+
+ if (SWAPL(fDirectory->tableDirectory[fDirExtra].tag) <= tag) {
+ table = fDirExtra;
+ }
+
+ while (probe > (1 << 0)) {
+ probe >>= 1;
+
+ if (SWAPL(fDirectory->tableDirectory[table + probe].tag) <= tag) {
+ table += probe;
+ }
+ }
+
+ if (SWAPL(fDirectory->tableDirectory[table].tag) == tag) {
+ return &fDirectory->tableDirectory[table];
+ }
+ }
+
+ return NULL;
+}
+
+const void *PortableFontInstance::readTable(LETag tag, le_uint32 *length) const
+{
+ const DirectoryEntry *entry = findTable(tag);
+
+ if (entry == NULL) {
+ *length = 0;
+ return NULL;
+ }
+
+ *length = SWAPL(entry->length);
+
+ void *table = NEW_ARRAY(char, *length);
+
+ if (table != NULL) {
+ fseek(fFile, SWAPL(entry->offset), SEEK_SET);
+ fread(table, sizeof(char), *length, fFile);
+ }
+
+ return table;
+}
+
+const void *PortableFontInstance::getFontTable(LETag tableTag) const
+{
+ return FontTableCache::find(tableTag);
+}
+
+const void *PortableFontInstance::readFontTable(LETag tableTag) const
+{
+ le_uint32 len;
+
+ return readTable(tableTag, &len);
+}
+
+CMAPMapper *PortableFontInstance::findUnicodeMapper()
+{
+ LETag cmapTag = LE_CMAP_TABLE_TAG;
+ const CMAPTable *cmap = (CMAPTable *) readFontTable(cmapTag);
+
+ if (cmap == NULL) {
+ return NULL;
+ }
+
+ return CMAPMapper::createUnicodeMapper(cmap);
+}
+
+const char *PortableFontInstance::getNameString(le_uint16 nameID, le_uint16 platformID, le_uint16 encodingID, le_uint16 languageID) const
+{
+ if (fNAMETable == NULL) {
+ LETag nameTag = LE_NAME_TABLE_TAG;
+ PortableFontInstance *realThis = (PortableFontInstance *) this;
+
+ realThis->fNAMETable = (const NAMETable *) readFontTable(nameTag);
+
+ if (realThis->fNAMETable != NULL) {
+ realThis->fNameCount = SWAPW(realThis->fNAMETable->count);
+ realThis->fNameStringOffset = SWAPW(realThis->fNAMETable->stringOffset);
+ }
+ }
+
+ for(le_int32 i = 0; i < fNameCount; i += 1) {
+ const NameRecord *nameRecord = &fNAMETable->nameRecords[i];
+
+ if (SWAPW(nameRecord->platformID) == platformID && SWAPW(nameRecord->encodingID == encodingID) &&
+ SWAPW(nameRecord->languageID) == languageID && SWAPW(nameRecord->nameID) == nameID) {
+ char *name = ((char *) fNAMETable) + fNameStringOffset + SWAPW(nameRecord->offset);
+ le_uint16 length = SWAPW(nameRecord->length);
+ char *result = NEW_ARRAY(char, length + 2);
+
+ ARRAY_COPY(result, name, length);
+ result[length] = result[length + 1] = 0;
+
+ return result;
+ }
+ }
+
+ return NULL;
+}
+
+void PortableFontInstance::deleteNameString(const char *name) const
+{
+ DELETE_ARRAY(name);
+}
+
+void PortableFontInstance::getGlyphAdvance(LEGlyphID glyph, LEPoint &advance) const
+{
+ TTGlyphID ttGlyph = (TTGlyphID) LE_GET_GLYPH(glyph);
+
+ if (fHMTXTable == NULL) {
+ LETag maxpTag = LE_MAXP_TABLE_TAG;
+ LETag hmtxTag = LE_HMTX_TABLE_TAG;
+ const MAXPTable *maxpTable = (MAXPTable *) readFontTable(maxpTag);
+ PortableFontInstance *realThis = (PortableFontInstance *) this;
+
+ if (maxpTable != NULL) {
+ realThis->fNumGlyphs = SWAPW(maxpTable->numGlyphs);
+ deleteTable(maxpTable);
+ }
+
+ realThis->fHMTXTable = (const HMTXTable *) readFontTable(hmtxTag);
+ }
+
+ le_uint16 index = ttGlyph;
+
+ if (ttGlyph >= fNumGlyphs || fHMTXTable == NULL) {
+ advance.fX = advance.fY = 0;
+ return;
+ }
+
+ if (ttGlyph >= fNumLongHorMetrics) {
+ index = fNumLongHorMetrics - 1;
+ }
+
+ advance.fX = xUnitsToPoints(SWAPW(fHMTXTable->hMetrics[index].advanceWidth));
+ advance.fY = 0;
+}
+
+le_bool PortableFontInstance::getGlyphPoint(LEGlyphID /*glyph*/, le_int32 /*pointNumber*/, LEPoint &/*point*/) const
+{
+ return FALSE;
+}
+
+le_int32 PortableFontInstance::getUnitsPerEM() const
+{
+ return fUnitsPerEM;
+}
+
+le_uint32 PortableFontInstance::getFontChecksum() const
+{
+ return fFontChecksum;
+}
+
+le_int32 PortableFontInstance::getAscent() const
+{
+ return fAscent;
+}
+
+le_int32 PortableFontInstance::getDescent() const
+{
+ return fDescent;
+}
+
+le_int32 PortableFontInstance::getLeading() const
+{
+ return fLeading;
+}
+
+// We really want to inherit this method from the superclass, but some compilers
+// issue a warning if we don't implement it...
+LEGlyphID PortableFontInstance::mapCharToGlyph(LEUnicode32 ch, const LECharMapper *mapper, le_bool filterZeroWidth) const
+{
+ return LEFontInstance::mapCharToGlyph(ch, mapper, filterZeroWidth);
+}
+
+// We really want to inherit this method from the superclass, but some compilers
+// issue a warning if we don't implement it...
+LEGlyphID PortableFontInstance::mapCharToGlyph(LEUnicode32 ch, const LECharMapper *mapper) const
+{
+ return LEFontInstance::mapCharToGlyph(ch, mapper);
+}
+
+LEGlyphID PortableFontInstance::mapCharToGlyph(LEUnicode32 ch) const
+{
+ return fCMAPMapper->unicodeToGlyph(ch);
+}
+
+float PortableFontInstance::getXPixelsPerEm() const
+{
+ return fPointSize;
+}
+
+float PortableFontInstance::getYPixelsPerEm() const
+{
+ return fPointSize;
+}
+
+float PortableFontInstance::getScaleFactorX() const
+{
+ return 1.0;
+}
+
+float PortableFontInstance::getScaleFactorY() const
+{
+ return 1.0;
+}
Property changes on: trunk/source/test/letest/PortableFontInstance.cpp
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/source/test/letest/PortableFontInstance.h
===================================================================
--- trunk/source/test/letest/PortableFontInstance.h 2006-12-21 11:09:23 UTC (rev 127)
+++ trunk/source/test/letest/PortableFontInstance.h 2006-12-21 11:10:34 UTC (rev 128)
@@ -1,114 +1,114 @@
-
-/*
- *******************************************************************************
- *
- * Copyright (C) 1999-2006, International Business Machines
- * Corporation and others. All Rights Reserved.
- *
- *******************************************************************************
- * file name: PortableFontInstance.h
- *
- * created on: 11/12/1999
- * created by: Eric R. Mader
- */
-
-#ifndef __PORTABLEFONTINSTANCE_H
-#define __PORTABLEFONTINSTANCE_H
-
-#include <stdio.h>
-
-#include "layout/LETypes.h"
-#include "layout/LEFontInstance.h"
-
-#include "FontTableCache.h"
-
-#include "sfnt.h"
-#include "cmaps.h"
-
-class PortableFontInstance : public LEFontInstance, protected FontTableCache
-{
-private:
- FILE *fFile;
-
- float fPointSize;
- le_int32 fUnitsPerEM;
- le_uint32 fFontChecksum;
- le_int32 fAscent;
- le_int32 fDescent;
- le_int32 fLeading;
-
- const SFNTDirectory *fDirectory;
- le_uint16 fDirPower;
- le_uint16 fDirExtra;
-
- float fDeviceScaleX;
- float fDeviceScaleY;
-
- const NAMETable *fNAMETable;
- le_uint16 fNameCount;
- le_uint16 fNameStringOffset;
-
- CMAPMapper *fCMAPMapper;
-
- const HMTXTable *fHMTXTable;
- le_uint16 fNumGlyphs;
- le_uint16 fNumLongHorMetrics;
-
- static le_int8 highBit(le_int32 value);
-
- const DirectoryEntry *findTable(LETag tag) const;
- const void *readTable(LETag tag, le_uint32 *length) const;
- void deleteTable(const void *table) const;
- void getMetrics();
-
- CMAPMapper *findUnicodeMapper();
-
-protected:
- const void *readFontTable(LETag tableTag) const;
-
-public:
- PortableFontInstance(const char *fileName, float pointSize, LEErrorCode &status);
-
- virtual ~PortableFontInstance();
-
- virtual const void *getFontTable(LETag tableTag) const;
-
- virtual const char *getNameString(le_uint16 nameID, le_uint16 platform, le_uint16 encoding, le_uint16 language) const;
-
- virtual void deleteNameString(const char *name) const;
-
- virtual le_int32 getUnitsPerEM() const;
-
- virtual le_uint32 getFontChecksum() const;
-
- virtual le_int32 getAscent() const;
-
- virtual le_int32 getDescent() const;
-
- virtual le_int32 getLeading() const;
-
- // We really want to inherit this method from the superclass, but some compilers
- // issue a warning if we don't implement it...
- virtual LEGlyphID mapCharToGlyph(LEUnicode32 ch, const LECharMapper *mapper, le_bool filterZeroWidth) const;
-
- // We really want to inherit this method from the superclass, but some compilers
- // issue a warning if we don't implement it...
- virtual LEGlyphID mapCharToGlyph(LEUnicode32 ch, const LECharMapper *mapper) const;
-
- virtual LEGlyphID mapCharToGlyph(LEUnicode32 ch) const;
-
- virtual void getGlyphAdvance(LEGlyphID glyph, LEPoint &advance) const;
-
- virtual le_bool getGlyphPoint(LEGlyphID glyph, le_int32 pointNumber, LEPoint &point) const;
-
- float getXPixelsPerEm() const;
-
- float getYPixelsPerEm() const;
-
- float getScaleFactorX() const;
-
- float getScaleFactorY() const;
-
-};
-
-#endif
+
+/*
+ *******************************************************************************
+ *
+ * Copyright (C) 1999-2006, International Business Machines
+ * Corporation and others. All Rights Reserved.
+ *
+ *******************************************************************************
+ * file name: PortableFontInstance.h
+ *
+ * created on: 11/12/1999
+ * created by: Eric R. Mader
+ */
+
+#ifndef __PORTABLEFONTINSTANCE_H
+#define __PORTABLEFONTINSTANCE_H
+
+#include <stdio.h>
+
+#include "layout/LETypes.h"
+#include "layout/LEFontInstance.h"
+
+#include "FontTableCache.h"
+
+#include "sfnt.h"
+#include "cmaps.h"
+
+class PortableFontInstance : public LEFontInstance, protected FontTableCache
+{
+private:
+ FILE *fFile;
+
+ float fPointSize;
+ le_int32 fUnitsPerEM;
+ le_uint32 fFontChecksum;
+ le_int32 fAscent;
+ le_int32 fDescent;
+ le_int32 fLeading;
+
+ const SFNTDirectory *fDirectory;
+ le_uint16 fDirPower;
+ le_uint16 fDirExtra;
+
+ float fDeviceScaleX;
+ float fDeviceScaleY;
+
+ const NAMETable *fNAMETable;
+ le_uint16 fNameCount;
+ le_uint16 fNameStringOffset;
+
+ CMAPMapper *fCMAPMapper;
+
+ const HMTXTable *fHMTXTable;
+ le_uint16 fNumGlyphs;
+ le_uint16 fNumLongHorMetrics;
+
+ static le_int8 highBit(le_int32 value);
+
+ const DirectoryEntry *findTable(LETag tag) const;
+ const void *readTable(LETag tag, le_uint32 *length) const;
+ void deleteTable(const void *table) const;
+ void getMetrics();
+
+ CMAPMapper *findUnicodeMapper();
+
+protected:
+ const void *readFontTable(LETag tableTag) const;
+
+public:
+ PortableFontInstance(const char *fileName, float pointSize, LEErrorCode &status);
+
+ virtual ~PortableFontInstance();
+
+ virtual const void *getFontTable(LETag tableTag) const;
+
+ virtual const char *getNameString(le_uint16 nameID, le_uint16 platform, le_uint16 encoding, le_uint16 language) const;
+
+ virtual void deleteNameString(const char *name) const;
+
+ virtual le_int32 getUnitsPerEM() const;
+
+ virtual le_uint32 getFontChecksum() const;
+
+ virtual le_int32 getAscent() const;
+
+ virtual le_int32 getDescent() const;
+
+ virtual le_int32 getLeading() const;
+
+ // We really want to inherit this method from the superclass, but some compilers
+ // issue a warning if we don't implement it...
+ virtual LEGlyphID mapCharToGlyph(LEUnicode32 ch, const LECharMapper *mapper, le_bool filterZeroWidth) const;
+
+ // We really want to inherit this method from the superclass, but some compilers
+ // issue a warning if we don't implement it...
+ virtual LEGlyphID mapCharToGlyph(LEUnicode32 ch, const LECharMapper *mapper) const;
+
+ virtual LEGlyphID mapCharToGlyph(LEUnicode32 ch) const;
+
+ virtual void getGlyphAdvance(LEGlyphID glyph, LEPoint &advance) const;
+
+ virtual le_bool getGlyphPoint(LEGlyphID glyph, le_int32 pointNumber, LEPoint &point) const;
+
+ float getXPixelsPerEm() const;
+
+ float getYPixelsPerEm() const;
+
+ float getScaleFactorX() const;
+
+ float getScaleFactorY() const;
+
+};
+
+#endif
Property changes on: trunk/source/test/letest/PortableFontInstance.h
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/source/test/letest/SimpleFontInstance.cpp
===================================================================
--- trunk/source/test/letest/SimpleFontInstance.cpp 2006-12-21 11:09:23 UTC (rev 127)
+++ trunk/source/test/letest/SimpleFontInstance.cpp 2006-12-21 11:10:34 UTC (rev 128)
@@ -1,132 +1,132 @@
-/*
- *******************************************************************************
- *
- * Copyright (C) 1999-2006, International Business Machines
- * Corporation and others. All Rights Reserved.
- *
- *******************************************************************************
- * file name: SimpleFontInstance.cpp
- *
- * created on: 03/30/2006
- * created by: Eric R. Mader
- */
-
-#include "unicode/utypes.h"
-#include "unicode/uchar.h"
-
-#include "layout/LETypes.h"
-#include "layout/LEFontInstance.h"
-
-#include "CanonShaping.h"
-#include "SimpleFontInstance.h"
-
-SimpleFontInstance::SimpleFontInstance(float pointSize, LEErrorCode &status)
- : fPointSize(pointSize), fAscent(0), fDescent(0)
-{
- if (LE_FAILURE(status)) {
- return;
- }
-
- fAscent = (le_int32) yUnitsToPoints(2000.0);
- fDescent = (le_int32) yUnitsToPoints(600.0);
-
- return;
-}
-
-SimpleFontInstance::~SimpleFontInstance()
-{
- // nothing to do...
-}
-
-const void *SimpleFontInstance::getFontTable(LETag tableTag) const
-{
- if (tableTag == LE_GSUB_TABLE_TAG) {
- return CanonShaping::glyphSubstitutionTable;
- }
-
- if (tableTag == LE_GDEF_TABLE_TAG) {
- return CanonShaping::glyphDefinitionTable;
- }
-
- return NULL;
-}
-
-void SimpleFontInstance::getGlyphAdvance(LEGlyphID glyph, LEPoint &advance) const
-{
-#if 0
- if (u_getCombiningClass((UChar32) glyph) == 0) {
- advance.fX = xUnitsToPoints(2048);
- } else {
- advance.fX = 0;
- }
-#else
- advance.fX = xUnitsToPoints(2048);
-#endif
-
- advance.fY = 0;
-}
-
-le_int32 SimpleFontInstance::getUnitsPerEM() const
-{
- return 2048;
-}
-
-le_int32 SimpleFontInstance::getAscent() const
-{
- return fAscent;
-}
-
-le_int32 SimpleFontInstance::getDescent() const
-{
- return fDescent;
-}
-
-le_int32 SimpleFontInstance::getLeading() const
-{
- return 0;
-}
-
-// We really want to inherit this method from the superclass, but some compilers
-// issue a warning if we don't implement it...
-LEGlyphID SimpleFontInstance::mapCharToGlyph(LEUnicode32 ch, const LECharMapper *mapper, le_bool filterZeroWidth) const
-{
- return LEFontInstance::mapCharToGlyph(ch, mapper, filterZeroWidth);
-}
-
-// We really want to inherit this method from the superclass, but some compilers
-// issue a warning if we don't implement it...
-LEGlyphID SimpleFontInstance::mapCharToGlyph(LEUnicode32 ch, const LECharMapper *mapper) const
-{
- return LEFontInstance::mapCharToGlyph(ch, mapper);
-}
-
-LEGlyphID SimpleFontInstance::mapCharToGlyph(LEUnicode32 ch) const
-{
- return (LEGlyphID) ch;
-}
-
-float SimpleFontInstance::getXPixelsPerEm() const
-{
- return fPointSize;
-}
-
-float SimpleFontInstance::getYPixelsPerEm() const
-{
- return fPointSize;
-}
-
-float SimpleFontInstance::getScaleFactorX() const
-{
- return 1.0;
-}
-
-float SimpleFontInstance::getScaleFactorY() const
-{
- return 1.0;
-}
-
-le_bool SimpleFontInstance::getGlyphPoint(LEGlyphID /*glyph*/, le_int32 /*pointNumber*/, LEPoint &/*point*/) const
-{
- return FALSE;
-}
-
+/*
+ *******************************************************************************
+ *
+ * Copyright (C) 1999-2006, International Business Machines
+ * Corporation and others. All Rights Reserved.
+ *
+ *******************************************************************************
+ * file name: SimpleFontInstance.cpp
+ *
+ * created on: 03/30/2006
+ * created by: Eric R. Mader
+ */
+
+#include "unicode/utypes.h"
+#include "unicode/uchar.h"
+
+#include "layout/LETypes.h"
+#include "layout/LEFontInstance.h"
+
+#include "CanonShaping.h"
+#include "SimpleFontInstance.h"
+
+SimpleFontInstance::SimpleFontInstance(float pointSize, LEErrorCode &status)
+ : fPointSize(pointSize), fAscent(0), fDescent(0)
+{
+ if (LE_FAILURE(status)) {
+ return;
+ }
+
+ fAscent = (le_int32) yUnitsToPoints(2000.0);
+ fDescent = (le_int32) yUnitsToPoints(600.0);
+
+ return;
+}
+
+SimpleFontInstance::~SimpleFontInstance()
+{
+ // nothing to do...
+}
+
+const void *SimpleFontInstance::getFontTable(LETag tableTag) const
+{
+ if (tableTag == LE_GSUB_TABLE_TAG) {
+ return CanonShaping::glyphSubstitutionTable;
+ }
+
+ if (tableTag == LE_GDEF_TABLE_TAG) {
+ return CanonShaping::glyphDefinitionTable;
+ }
+
+ return NULL;
+}
+
+void SimpleFontInstance::getGlyphAdvance(LEGlyphID glyph, LEPoint &advance) const
+{
+#if 0
+ if (u_getCombiningClass((UChar32) glyph) == 0) {
+ advance.fX = xUnitsToPoints(2048);
+ } else {
+ advance.fX = 0;
+ }
+#else
+ advance.fX = xUnitsToPoints(2048);
+#endif
+
+ advance.fY = 0;
+}
+
+le_int32 SimpleFontInstance::getUnitsPerEM() const
+{
+ return 2048;
+}
+
+le_int32 SimpleFontInstance::getAscent() const
+{
+ return fAscent;
+}
+
+le_int32 SimpleFontInstance::getDescent() const
+{
+ return fDescent;
+}
+
+le_int32 SimpleFontInstance::getLeading() const
+{
+ return 0;
+}
+
+// We really want to inherit this method from the superclass, but some compilers
+// issue a warning if we don't implement it...
+LEGlyphID SimpleFontInstance::mapCharToGlyph(LEUnicode32 ch, const LECharMapper *mapper, le_bool filterZeroWidth) const
+{
+ return LEFontInstance::mapCharToGlyph(ch, mapper, filterZeroWidth);
+}
+
+// We really want to inherit this method from the superclass, but some compilers
+// issue a warning if we don't implement it...
+LEGlyphID SimpleFontInstance::mapCharToGlyph(LEUnicode32 ch, const LECharMapper *mapper) const
+{
+ return LEFontInstance::mapCharToGlyph(ch, mapper);
+}
+
+LEGlyphID SimpleFontInstance::mapCharToGlyph(LEUnicode32 ch) const
+{
+ return (LEGlyphID) ch;
+}
+
+float SimpleFontInstance::getXPixelsPerEm() const
+{
+ return fPointSize;
+}
+
+float SimpleFontInstance::getYPixelsPerEm() const
+{
+ return fPointSize;
+}
+
+float SimpleFontInstance::getScaleFactorX() const
+{
+ return 1.0;
+}
+
+float SimpleFontInstance::getScaleFactorY() const
+{
+ return 1.0;
+}
+
+le_bool SimpleFontInstance::getGlyphPoint(LEGlyphID /*glyph*/, le_int32 /*pointNumber*/, LEPoint &/*point*/) const
+{
+ return FALSE;
+}
+
Property changes on: trunk/source/test/letest/SimpleFontInstance.cpp
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/source/test/letest/SimpleFontInstance.h
===================================================================
--- trunk/source/test/letest/SimpleFontInstance.h 2006-12-21 11:09:23 UTC (rev 127)
+++ trunk/source/test/letest/SimpleFontInstance.h 2006-12-21 11:10:34 UTC (rev 128)
@@ -1,72 +1,72 @@
-
-/*
- *******************************************************************************
- *
- * Copyright (C) 1999-2006, International Business Machines
- * Corporation and others. All Rights Reserved.
- *
- *******************************************************************************
- * file name: SimpleFontInstance.h
- *
- * created on: 03/30/2006
- * created by: Eric R. Mader
- */
-
-#ifndef __SIMPLEFONTINSTANCE_H
-#define __SIMPLEFONTINSTANCE_H
-
-#include <stdio.h>
-
-#include "layout/LETypes.h"
-#include "layout/LEFontInstance.h"
-
-class SimpleFontInstance : public LEFontInstance
-{
-private:
- float fPointSize;
- le_int32 fAscent;
- le_int32 fDescent;
-
-protected:
- const void *readFontTable(LETag tableTag) const;
-
-public:
- SimpleFontInstance(float pointSize, LEErrorCode &status);
-
- virtual ~SimpleFontInstance();
-
- virtual const void *getFontTable(LETag tableTag) const;
-
- virtual le_int32 getUnitsPerEM() const;
-
- virtual le_int32 getAscent() const;
-
- virtual le_int32 getDescent() const;
-
- virtual le_int32 getLeading() const;
-
- // We really want to inherit this method from the superclass, but some compilers
- // issue a warning if we don't implement it...
- virtual LEGlyphID mapCharToGlyph(LEUnicode32 ch, const LECharMapper *mapper, le_bool filterZeroWidth) const;
-
- // We really want to inherit this method from the superclass, but some compilers
- // issue a warning if we don't implement it...
- virtual LEGlyphID mapCharToGlyph(LEUnicode32 ch, const LECharMapper *mapper) const;
-
- virtual LEGlyphID mapCharToGlyph(LEUnicode32 ch) const;
-
- virtual void getGlyphAdvance(LEGlyphID glyph, LEPoint &advance) const;
-
- virtual le_bool getGlyphPoint(LEGlyphID glyph, le_int32 pointNumber, LEPoint &point) const;
-
- float getXPixelsPerEm() const;
-
- float getYPixelsPerEm() const;
-
- float getScaleFactorX() const;
-
- float getScaleFactorY() const;
-
-};
-
-#endif
+
+/*
+ *******************************************************************************
+ *
+ * Copyright (C) 1999-2006, International Business Machines
+ * Corporation and others. All Rights Reserved.
+ *
+ *******************************************************************************
+ * file name: SimpleFontInstance.h
+ *
+ * created on: 03/30/2006
+ * created by: Eric R. Mader
+ */
+
+#ifndef __SIMPLEFONTINSTANCE_H
+#define __SIMPLEFONTINSTANCE_H
+
+#include <stdio.h>
+
+#include "layout/LETypes.h"
+#include "layout/LEFontInstance.h"
+
+class SimpleFontInstance : public LEFontInstance
+{
+private:
+ float fPointSize;
+ le_int32 fAscent;
+ le_int32 fDescent;
+
+protected:
+ const void *readFontTable(LETag tableTag) const;
+
+public:
+ SimpleFontInstance(float pointSize, LEErrorCode &status);
+
+ virtual ~SimpleFontInstance();
+
+ virtual const void *getFontTable(LETag tableTag) const;
+
+ virtual le_int32 getUnitsPerEM() const;
+
+ virtual le_int32 getAscent() const;
+
+ virtual le_int32 getDescent() const;
+
+ virtual le_int32 getLeading() const;
+
+ // We really want to inherit this method from the superclass, but some compilers
+ // issue a warning if we don't implement it...
+ virtual LEGlyphID mapCharToGlyph(LEUnicode32 ch, const LECharMapper *mapper, le_bool filterZeroWidth) const;
+
+ // We really want to inherit this method from the superclass, but some compilers
+ // issue a warning if we don't implement it...
+ virtual LEGlyphID mapCharToGlyph(LEUnicode32 ch, const LECharMapper *mapper) const;
+
+ virtual LEGlyphID mapCharToGlyph(LEUnicode32 ch) const;
+
+ virtual void getGlyphAdvance(LEGlyphID glyph, LEPoint &advance) const;
+
+ virtual le_bool getGlyphPoint(LEGlyphID glyph, le_int32 pointNumber, LEPoint &point) const;
+
+ float getXPixelsPerEm() const;
+
+ float getYPixelsPerEm() const;
+
+ float getScaleFactorX() const;
+
+ float getScaleFactorY() const;
+
+};
+
+#endif
Property changes on: trunk/source/test/letest/SimpleFontInstance.h
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/source/test/letest/cmaps.cpp
===================================================================
--- trunk/source/test/letest/cmaps.cpp 2006-12-21 11:09:23 UTC (rev 127)
+++ trunk/source/test/letest/cmaps.cpp 2006-12-21 11:10:34 UTC (rev 128)
@@ -1,200 +1,200 @@
-/***************************************************************************
-*
-* Copyright (C) 1998-2003, International Business Machines
-* Corporation and others. All Rights Reserved.
-*
-************************************************************************/
-
-#include "LETypes.h"
-#include "LESwaps.h"
-
-#include "sfnt.h"
-#include "cmaps.h"
-
-#define SWAPU16(code) ((LEUnicode16) SWAPW(code))
-#define SWAPU32(code) ((LEUnicode32) SWAPL(code))
-
-//
-// Finds the high bit by binary searching
-// through the bits in value.
-//
-le_int8 highBit(le_uint32 value)
-{
- le_uint8 bit = 0;
-
- if (value >= 1 << 16) {
- value >>= 16;
- bit += 16;
- }
-
- if (value >= 1 << 8) {
- value >>= 8;
- bit += 8;
- }
-
- if (value >= 1 << 4) {
- value >>= 4;
- bit += 4;
- }
-
- if (value >= 1 << 2) {
- value >>= 2;
- bit += 2;
- }
-
- if (value >= 1 << 1) {
- value >>= 1;
- bit += 1;
- }
-
- return bit;
-}
-
-CMAPMapper *CMAPMapper::createUnicodeMapper(const CMAPTable *cmap)
-{
- le_uint16 i;
- le_uint16 nSubtables = SWAPW(cmap->numberSubtables);
- const CMAPEncodingSubtable *subtable = NULL;
- le_uint32 offset1 = 0, offset10 = 0;
-
- for (i = 0; i < nSubtables; i += 1) {
- const CMAPEncodingSubtableHeader *esh = &cmap->encodingSubtableHeaders[i];
-
- if (SWAPW(esh->platformID) == 3) {
- switch (SWAPW(esh->platformSpecificID)) {
- case 1:
- offset1 = SWAPL(esh->encodingOffset);
- break;
-
- case 10:
- offset10 = SWAPL(esh->encodingOffset);
- break;
- }
- }
- }
-
-
- if (offset10 != 0)
- {
- subtable = (const CMAPEncodingSubtable *) ((const char *) cmap + offset10);
- } else if (offset1 != 0) {
- subtable = (const CMAPEncodingSubtable *) ((const char *) cmap + offset1);
- } else {
- return NULL;
- }
-
- switch (SWAPW(subtable->format)) {
- case 4:
- return new CMAPFormat4Mapper(cmap, (const CMAPFormat4Encoding *) subtable);
-
- case 12:
- {
- const CMAPFormat12Encoding *encoding = (const CMAPFormat12Encoding *) subtable;
-
- return new CMAPGroupMapper(cmap, encoding->groups, SWAPL(encoding->nGroups));
- }
-
- default:
- break;
- }
-
- return NULL;
-}
-
-CMAPFormat4Mapper::CMAPFormat4Mapper(const CMAPTable *cmap, const CMAPFormat4Encoding *header)
- : CMAPMapper(cmap)
-{
- le_uint16 segCount = SWAPW(header->segCountX2) / 2;
-
- fEntrySelector = SWAPW(header->entrySelector);
- fRangeShift = SWAPW(header->rangeShift) / 2;
- fEndCodes = &header->endCodes[0];
- fStartCodes = &header->endCodes[segCount + 1]; // + 1 for reservedPad...
- fIdDelta = &fStartCodes[segCount];
- fIdRangeOffset = &fIdDelta[segCount];
-}
-
-LEGlyphID CMAPFormat4Mapper::unicodeToGlyph(LEUnicode32 unicode32) const
-{
- if (unicode32 >= 0x10000) {
- return 0;
- }
-
- LEUnicode16 unicode = (LEUnicode16) unicode32;
- le_uint16 index = 0;
- le_uint16 probe = 1 << fEntrySelector;
- TTGlyphID result = 0;
-
- if (SWAPU16(fStartCodes[fRangeShift]) <= unicode) {
- index = fRangeShift;
- }
-
- while (probe > (1 << 0)) {
- probe >>= 1;
-
- if (SWAPU16(fStartCodes[index + probe]) <= unicode) {
- index += probe;
- }
- }
-
- if (unicode >= SWAPU16(fStartCodes[index]) && unicode <= SWAPU16(fEndCodes[index])) {
- if (fIdRangeOffset[index] == 0) {
- result = (TTGlyphID) unicode;
- } else {
- le_uint16 offset = unicode - SWAPU16(fStartCodes[index]);
- le_uint16 rangeOffset = SWAPW(fIdRangeOffset[index]);
- le_uint16 *glyphIndexTable = (le_uint16 *) ((char *) &fIdRangeOffset[index] + rangeOffset);
-
- result = SWAPW(glyphIndexTable[offset]);
- }
-
- result += SWAPW(fIdDelta[index]);
- } else {
- result = 0;
- }
-
- return LE_SET_GLYPH(0, result);
-}
-
-CMAPFormat4Mapper::~CMAPFormat4Mapper()
-{
- // parent destructor does it all
-}
-
-CMAPGroupMapper::CMAPGroupMapper(const CMAPTable *cmap, const CMAPGroup *groups, le_uint32 nGroups)
- : CMAPMapper(cmap), fGroups(groups)
-{
- le_uint8 bit = highBit(nGroups);
- fPower = 1 << bit;
- fRangeOffset = nGroups - fPower;
-}
-
-LEGlyphID CMAPGroupMapper::unicodeToGlyph(LEUnicode32 unicode32) const
-{
- le_int32 probe = fPower;
- le_int32 range = 0;
-
- if (SWAPU32(fGroups[fRangeOffset].startCharCode) <= unicode32) {
- range = fRangeOffset;
- }
-
- while (probe > (1 << 0)) {
- probe >>= 1;
-
- if (SWAPU32(fGroups[range + probe].startCharCode) <= unicode32) {
- range += probe;
- }
- }
-
- if (SWAPU32(fGroups[range].startCharCode) <= unicode32 && SWAPU32(fGroups[range].endCharCode) >= unicode32) {
- return (LEGlyphID) (SWAPU32(fGroups[range].startGlyphCode) + unicode32 - SWAPU32(fGroups[range].startCharCode));
- }
-
- return 0;
-}
-
-CMAPGroupMapper::~CMAPGroupMapper()
-{
- // parent destructor does it all
-}
-
+/***************************************************************************
+*
+* Copyright (C) 1998-2003, International Business Machines
+* Corporation and others. All Rights Reserved.
+*
+************************************************************************/
+
+#include "LETypes.h"
+#include "LESwaps.h"
+
+#include "sfnt.h"
+#include "cmaps.h"
+
+#define SWAPU16(code) ((LEUnicode16) SWAPW(code))
+#define SWAPU32(code) ((LEUnicode32) SWAPL(code))
+
+//
+// Finds the high bit by binary searching
+// through the bits in value.
+//
+le_int8 highBit(le_uint32 value)
+{
+ le_uint8 bit = 0;
+
+ if (value >= 1 << 16) {
+ value >>= 16;
+ bit += 16;
+ }
+
+ if (value >= 1 << 8) {
+ value >>= 8;
+ bit += 8;
+ }
+
+ if (value >= 1 << 4) {
+ value >>= 4;
+ bit += 4;
+ }
+
+ if (value >= 1 << 2) {
+ value >>= 2;
+ bit += 2;
+ }
+
+ if (value >= 1 << 1) {
+ value >>= 1;
+ bit += 1;
+ }
+
+ return bit;
+}
+
+CMAPMapper *CMAPMapper::createUnicodeMapper(const CMAPTable *cmap)
+{
+ le_uint16 i;
+ le_uint16 nSubtables = SWAPW(cmap->numberSubtables);
+ const CMAPEncodingSubtable *subtable = NULL;
+ le_uint32 offset1 = 0, offset10 = 0;
+
+ for (i = 0; i < nSubtables; i += 1) {
+ const CMAPEncodingSubtableHeader *esh = &cmap->encodingSubtableHeaders[i];
+
+ if (SWAPW(esh->platformID) == 3) {
+ switch (SWAPW(esh->platformSpecificID)) {
+ case 1:
+ offset1 = SWAPL(esh->encodingOffset);
+ break;
+
+ case 10:
+ offset10 = SWAPL(esh->encodingOffset);
+ break;
+ }
+ }
+ }
+
+
+ if (offset10 != 0)
+ {
+ subtable = (const CMAPEncodingSubtable *) ((const char *) cmap + offset10);
+ } else if (offset1 != 0) {
+ subtable = (const CMAPEncodingSubtable *) ((const char *) cmap + offset1);
+ } else {
+ return NULL;
+ }
+
+ switch (SWAPW(subtable->format)) {
+ case 4:
+ return new CMAPFormat4Mapper(cmap, (const CMAPFormat4Encoding *) subtable);
+
+ case 12:
+ {
+ const CMAPFormat12Encoding *encoding = (const CMAPFormat12Encoding *) subtable;
+
+ return new CMAPGroupMapper(cmap, encoding->groups, SWAPL(encoding->nGroups));
+ }
+
+ default:
+ break;
+ }
+
+ return NULL;
+}
+
+CMAPFormat4Mapper::CMAPFormat4Mapper(const CMAPTable *cmap, const CMAPFormat4Encoding *header)
+ : CMAPMapper(cmap)
+{
+ le_uint16 segCount = SWAPW(header->segCountX2) / 2;
+
+ fEntrySelector = SWAPW(header->entrySelector);
+ fRangeShift = SWAPW(header->rangeShift) / 2;
+ fEndCodes = &header->endCodes[0];
+ fStartCodes = &header->endCodes[segCount + 1]; // + 1 for reservedPad...
+ fIdDelta = &fStartCodes[segCount];
+ fIdRangeOffset = &fIdDelta[segCount];
+}
+
+LEGlyphID CMAPFormat4Mapper::unicodeToGlyph(LEUnicode32 unicode32) const
+{
+ if (unicode32 >= 0x10000) {
+ return 0;
+ }
+
+ LEUnicode16 unicode = (LEUnicode16) unicode32;
+ le_uint16 index = 0;
+ le_uint16 probe = 1 << fEntrySelector;
+ TTGlyphID result = 0;
+
+ if (SWAPU16(fStartCodes[fRangeShift]) <= unicode) {
+ index = fRangeShift;
+ }
+
+ while (probe > (1 << 0)) {
+ probe >>= 1;
+
+ if (SWAPU16(fStartCodes[index + probe]) <= unicode) {
+ index += probe;
+ }
+ }
+
+ if (unicode >= SWAPU16(fStartCodes[index]) && unicode <= SWAPU16(fEndCodes[index])) {
+ if (fIdRangeOffset[index] == 0) {
+ result = (TTGlyphID) unicode;
+ } else {
+ le_uint16 offset = unicode - SWAPU16(fStartCodes[index]);
+ le_uint16 rangeOffset = SWAPW(fIdRangeOffset[index]);
+ le_uint16 *glyphIndexTable = (le_uint16 *) ((char *) &fIdRangeOffset[index] + rangeOffset);
+
+ result = SWAPW(glyphIndexTable[offset]);
+ }
+
+ result += SWAPW(fIdDelta[index]);
+ } else {
+ result = 0;
+ }
+
+ return LE_SET_GLYPH(0, result);
+}
+
+CMAPFormat4Mapper::~CMAPFormat4Mapper()
+{
+ // parent destructor does it all
+}
+
+CMAPGroupMapper::CMAPGroupMapper(const CMAPTable *cmap, const CMAPGroup *groups, le_uint32 nGroups)
+ : CMAPMapper(cmap), fGroups(groups)
+{
+ le_uint8 bit = highBit(nGroups);
+ fPower = 1 << bit;
+ fRangeOffset = nGroups - fPower;
+}
+
+LEGlyphID CMAPGroupMapper::unicodeToGlyph(LEUnicode32 unicode32) const
+{
+ le_int32 probe = fPower;
+ le_int32 range = 0;
+
+ if (SWAPU32(fGroups[fRangeOffset].startCharCode) <= unicode32) {
+ range = fRangeOffset;
+ }
+
+ while (probe > (1 << 0)) {
+ probe >>= 1;
+
+ if (SWAPU32(fGroups[range + probe].startCharCode) <= unicode32) {
+ range += probe;
+ }
+ }
+
+ if (SWAPU32(fGroups[range].startCharCode) <= unicode32 && SWAPU32(fGroups[range].endCharCode) >= unicode32) {
+ return (LEGlyphID) (SWAPU32(fGroups[range].startGlyphCode) + unicode32 - SWAPU32(fGroups[range].startCharCode));
+ }
+
+ return 0;
+}
+
+CMAPGroupMapper::~CMAPGroupMapper()
+{
+ // parent destructor does it all
+}
+
Property changes on: trunk/source/test/letest/cmaps.cpp
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/source/test/letest/cmaps.h
===================================================================
--- trunk/source/test/letest/cmaps.h 2006-12-21 11:09:23 UTC (rev 127)
+++ trunk/source/test/letest/cmaps.h 2006-12-21 11:10:34 UTC (rev 128)
@@ -1,85 +1,85 @@
-/***************************************************************************
-*
-* Copyright (C) 1998-2006, International Business Machines
-* Corporation and others. All Rights Reserved.
-*
-************************************************************************/
-
-
-#ifndef __CMAPS_H
-#define __CMAPS_H
-
-#include "layout/LETypes.h"
-#include "letest.h"
-#include "sfnt.h"
-
-class CMAPMapper
-{
-public:
- virtual LEGlyphID unicodeToGlyph(LEUnicode32 unicode32) const = 0;
-
- virtual ~CMAPMapper();
-
- static CMAPMapper *createUnicodeMapper(const CMAPTable *cmap);
-
-protected:
- CMAPMapper(const CMAPTable *cmap);
-
- CMAPMapper() {};
-
-private:
- const CMAPTable *fcmap;
-};
-
-class CMAPFormat4Mapper : public CMAPMapper
-{
-public:
- CMAPFormat4Mapper(const CMAPTable *cmap, const CMAPFormat4Encoding *header);
-
- virtual ~CMAPFormat4Mapper();
-
- virtual LEGlyphID unicodeToGlyph(LEUnicode32 unicode32) const;
-
-protected:
- CMAPFormat4Mapper() {};
-
-private:
- le_uint16 fEntrySelector;
- le_uint16 fRangeShift;
- const le_uint16 *fEndCodes;
- const le_uint16 *fStartCodes;
- const le_uint16 *fIdDelta;
- const le_uint16 *fIdRangeOffset;
-};
-
-class CMAPGroupMapper : public CMAPMapper
-{
-public:
- CMAPGroupMapper(const CMAPTable *cmap, const CMAPGroup *groups, le_uint32 nGroups);
-
- virtual ~CMAPGroupMapper();
-
- virtual LEGlyphID unicodeToGlyph(LEUnicode32 unicode32) const;
-
-protected:
- CMAPGroupMapper() {};
-
-private:
- le_int32 fPower;
- le_int32 fRangeOffset;
- const CMAPGroup *fGroups;
-};
-
-inline CMAPMapper::CMAPMapper(const CMAPTable *cmap)
- : fcmap(cmap)
-{
- // nothing else to do
-}
-
-inline CMAPMapper::~CMAPMapper()
-{
- DELETE_ARRAY(fcmap);
-}
-
-#endif
-
+/***************************************************************************
+*
+* Copyright (C) 1998-2006, International Business Machines
+* Corporation and others. All Rights Reserved.
+*
+************************************************************************/
+
+
+#ifndef __CMAPS_H
+#define __CMAPS_H
+
+#include "layout/LETypes.h"
+#include "letest.h"
+#include "sfnt.h"
+
+class CMAPMapper
+{
+public:
+ virtual LEGlyphID unicodeToGlyph(LEUnicode32 unicode32) const = 0;
+
+ virtual ~CMAPMapper();
+
+ static CMAPMapper *createUnicodeMapper(const CMAPTable *cmap);
+
+protected:
+ CMAPMapper(const CMAPTable *cmap);
+
+ CMAPMapper() {};
+
+private:
+ const CMAPTable *fcmap;
+};
+
+class CMAPFormat4Mapper : public CMAPMapper
+{
+public:
+ CMAPFormat4Mapper(const CMAPTable *cmap, const CMAPFormat4Encoding *header);
+
+ virtual ~CMAPFormat4Mapper();
+
+ virtual LEGlyphID unicodeToGlyph(LEUnicode32 unicode32) const;
+
+protected:
+ CMAPFormat4Mapper() {};
+
+private:
+ le_uint16 fEntrySelector;
+ le_uint16 fRangeShift;
+ const le_uint16 *fEndCodes;
+ const le_uint16 *fStartCodes;
+ const le_uint16 *fIdDelta;
+ const le_uint16 *fIdRangeOffset;
+};
+
+class CMAPGroupMapper : public CMAPMapper
+{
+public:
+ CMAPGroupMapper(const CMAPTable *cmap, const CMAPGroup *groups, le_uint32 nGroups);
+
+ virtual ~CMAPGroupMapper();
+
+ virtual LEGlyphID unicodeToGlyph(LEUnicode32 unicode32) const;
+
+protected:
+ CMAPGroupMapper() {};
+
+private:
+ le_int32 fPower;
+ le_int32 fRangeOffset;
+ const CMAPGroup *fGroups;
+};
+
+inline CMAPMapper::CMAPMapper(const CMAPTable *cmap)
+ : fcmap(cmap)
+{
+ // nothing else to do
+}
+
+inline CMAPMapper::~CMAPMapper()
+{
+ DELETE_ARRAY(fcmap);
+}
+
+#endif
+
Property changes on: trunk/source/test/letest/cmaps.h
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/source/test/letest/gendata.cpp
===================================================================
--- trunk/source/test/letest/gendata.cpp 2006-12-21 11:09:23 UTC (rev 127)
+++ trunk/source/test/letest/gendata.cpp 2006-12-21 11:10:34 UTC (rev 128)
@@ -1,282 +1,282 @@
-/*
- *******************************************************************************
- *
- * Copyright (C) 1999-2006, International Business Machines
- * Corporation and others. All Rights Reserved.
- *
- *******************************************************************************
- * file name: gendata.cpp
- *
- * created on: 11/03/2000
- * created by: Eric R. Mader
- */
-
-#include <stdio.h>
-#include <string.h>
-#include <time.h>
-
-#include "unicode/utypes.h"
-#include "unicode/unistr.h"
-#include "unicode/uscript.h"
-#include "unicode/ubidi.h"
-
-#include "layout/LETypes.h"
-#include "layout/LEScripts.h"
-#include "layout/LayoutEngine.h"
-
-#include "PortableFontInstance.h"
-#include "SimpleFontInstance.h"
-
-#include "xmlparser.h"
-
-#include "letsutil.h"
-#include "letest.h"
-
-U_NAMESPACE_USE
-
-struct TestInput
-{
- const char *fontName;
- LEUnicode *text;
- le_int32 textLength;
- le_int32 scriptCode;
- le_bool rightToLeft;
-};
-
-/*
- * FIXME: should use the output file name and the current date.
- */
-const char *header =
- "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
- "\n"
- "<!--\n"
- " Copyright (c) 1999-%4.4d International Business Machines\n"
- " Corporation and others. All rights reserved.\n"
- "\n"
- " WARNING: THIS FILE IS MACHINE GENERATED. DO NOT HAND EDIT IT\n"
- " UNLESS YOU REALLY KNOW WHAT YOU'RE DOING.\n"
- "\n"
- " file name: letest.xml\n"
- " generated on: %s\n"
- " generated by: gendata.cpp\n"
- "-->\n"
- "\n"
- "<layout-tests>\n";
-
-void dumpLongs(FILE *file, const char *tag, le_int32 *longs, le_int32 count) {
- char lineBuffer[8 * 12 + 2];
- le_int32 bufp = 0;
-
- fprintf(file, " <%s>\n", tag);
-
- for (int i = 0; i < count; i += 1) {
- if (i % 8 == 0 && bufp != 0) {
- fprintf(file, " %s\n", lineBuffer);
- bufp = 0;
- }
-
- bufp += sprintf(&lineBuffer[bufp], "0x%8.8X, ", longs[i]);
- }
-
- if (bufp != 0) {
- lineBuffer[bufp - 2] = '\0';
- fprintf(file, " %s\n", lineBuffer);
- }
-
- fprintf(file, " </%s>\n\n", tag);
-}
-
-void dumpFloats(FILE *file, const char *tag, float *floats, le_int32 count) {
- char lineBuffer[8 * 16 + 2];
- le_int32 bufp = 0;
-
- fprintf(file, " <%s>\n", tag);
-
- for (int i = 0; i < count; i += 1) {
- if (i % 8 == 0 && bufp != 0) {
- fprintf(file, " %s\n", lineBuffer);
- bufp = 0;
- }
-
- bufp += sprintf(&lineBuffer[bufp], "%f, ", floats[i]);
- }
-
- if (bufp != 0) {
- lineBuffer[bufp - 2] = '\0';
- fprintf(file, " %s\n", lineBuffer);
- }
-
- fprintf(file, " </%s>\n", tag);
-}
-
-int main(int /*argc*/, char *argv[])
-{
- UErrorCode status = U_ZERO_ERROR;
- FILE *outputFile = fopen(argv[1], "w");
- time_t now = time(NULL);
- struct tm *local = localtime(&now);
- const char *tmFormat = "%m/%d/%Y %I:%M:%S %p %Z";
- char tmString[64];
-
- strftime(tmString, 64, tmFormat, local);
- fprintf(outputFile, header, local->tm_year + 1900, tmString);
-
- UXMLParser *parser = UXMLParser::createParser(status);
- UXMLElement *root = parser->parseFile("gendata.xml", status);
-
- if (root == NULL) {
- printf("Error: Could not open gendata.xml\n");
- delete parser;
- return -1;
- }
-
- UnicodeString test_case = UNICODE_STRING_SIMPLE("test-case");
- UnicodeString test_text = UNICODE_STRING_SIMPLE("test-text");
- UnicodeString test_font = UNICODE_STRING_SIMPLE("test-font");
-
- // test-case attributes
- UnicodeString id_attr = UNICODE_STRING_SIMPLE("id");
- UnicodeString script_attr = UNICODE_STRING_SIMPLE("script");
- UnicodeString lang_attr = UNICODE_STRING_SIMPLE("lang");
-
- // test-font attributes
- UnicodeString name_attr = UNICODE_STRING_SIMPLE("name");
-
- const UXMLElement *testCase;
- int32_t tc = 0;
-
- while((testCase = root->nextChildElement(tc)) != NULL) {
- if (testCase->getTagName().compare(test_case) == 0) {
- char *id = getCString(testCase->getAttribute(id_attr));
- char *script = getCString(testCase->getAttribute(script_attr));
- char *lang = getCString(testCase->getAttribute(lang_attr));
- LEFontInstance *font = NULL;
- const UXMLElement *element;
- int32_t ec = 0;
- int32_t charCount = 0;
- int32_t typoFlags = 3; // kerning + ligatures...
- UScriptCode scriptCode;
- le_int32 languageCode = -1;
- UnicodeString text;
- int32_t glyphCount = 0;
- LEErrorCode leStatus = LE_NO_ERROR;
- LayoutEngine *engine = NULL;
- LEGlyphID *glyphs = NULL;
- le_int32 *indices = NULL;
- float *positions = NULL;
-
- uscript_getCode(script, &scriptCode, 1, &status);
- if (LE_FAILURE(status)) {
- printf("Error: invalid script name: %s.\n", script);
- goto free_c_strings;
- }
-
- if (lang != NULL) {
- languageCode = getLanguageCode(lang);
-
- if (languageCode < 0) {
- printf("Error: invalid language name: %s.\n", lang);
- goto free_c_strings;
- }
-
- fprintf(outputFile, " <test-case id=\"%s\" script=\"%s\" lang=\"%s\">\n", id, script, lang);
- } else {
- fprintf(outputFile, " <test-case id=\"%s\" script=\"%s\">\n", id, script);
- }
-
- while((element = testCase->nextChildElement(ec)) != NULL) {
- UnicodeString tag = element->getTagName();
-
- // TODO: make sure that each element is only used once.
- if (tag.compare(test_font) == 0) {
- char *fontName = getCString(element->getAttribute(name_attr));
- const char *version = NULL;
- PortableFontInstance *pfi = new PortableFontInstance(fontName, 12, leStatus);
-
- if (LE_FAILURE(leStatus)) {
- printf("Error: could not open font: %s\n", fontName);
- freeCString(fontName);
- goto free_c_strings;
- }
-
- version = pfi->getNameString(NAME_VERSION_STRING, PLATFORM_MACINTOSH, MACINTOSH_ROMAN, MACINTOSH_ENGLISH);
-
- fprintf(outputFile, " <test-font name=\"%s\" version=\"%s\" checksum=\"0x%8.8X\"/>\n\n",
- fontName, version, pfi->getFontChecksum());
-
- pfi->deleteNameString(version);
- freeCString(fontName);
- font = pfi;
- } else if (tag.compare(test_text) == 0) {
- char *utf8 = NULL;
-
- text = element->getText(TRUE);
- charCount = text.length();
-
- utf8 = getUTF8String(&text);
- fprintf(outputFile, " <test-text>%s</test-text>\n\n", utf8);
- freeCString(utf8);
- } else {
- // an unknown tag...
- char *cTag = getCString(&tag);
-
- printf("Test %s: unknown element with tag \"%s\"\n", id, cTag);
- freeCString(cTag);
- }
- }
-
- if (font == NULL) {
- LEErrorCode fontStatus = LE_NO_ERROR;
-
- font = new SimpleFontInstance(12, fontStatus);
- typoFlags |= 0x80000000L; // use CharSubstitutionFilter...
- }
-
- engine = LayoutEngine::layoutEngineFactory(font, scriptCode, languageCode, typoFlags, leStatus);
-
- if (LE_FAILURE(leStatus)) {
- printf("Error for test %s: could not create a LayoutEngine.\n", id);
- goto delete_font;
- }
-
- glyphCount = engine->layoutChars(text.getBuffer(), 0, charCount, charCount, getRTL(text), 0, 0, leStatus);
-
- glyphs = NEW_ARRAY(LEGlyphID, glyphCount);
- indices = NEW_ARRAY(le_int32, glyphCount);
- positions = NEW_ARRAY(float, glyphCount * 2 + 2);
-
- engine->getGlyphs(glyphs, leStatus);
- engine->getCharIndices(indices, leStatus);
- engine->getGlyphPositions(positions, leStatus);
-
- dumpLongs(outputFile, "result-glyphs", (le_int32 *) glyphs, glyphCount);
-
- dumpLongs(outputFile, "result-indices", indices, glyphCount);
-
- dumpFloats(outputFile, "result-positions", positions, glyphCount * 2 + 2);
-
- fprintf(outputFile, " </test-case>\n\n");
-
- DELETE_ARRAY(positions);
- DELETE_ARRAY(indices);
- DELETE_ARRAY(glyphs);
-
- delete engine;
-
-delete_font:
- delete font;
-
-free_c_strings:
- freeCString(lang);
- freeCString(script);
- freeCString(id);
- }
- }
-
- delete root;
- delete parser;
-
- fprintf(outputFile, "</layout-tests>\n");
-
- fclose(outputFile);
-}
+/*
+ *******************************************************************************
+ *
+ * Copyright (C) 1999-2006, International Business Machines
+ * Corporation and others. All Rights Reserved.
+ *
+ *******************************************************************************
+ * file name: gendata.cpp
+ *
+ * created on: 11/03/2000
+ * created by: Eric R. Mader
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <time.h>
+
+#include "unicode/utypes.h"
+#include "unicode/unistr.h"
+#include "unicode/uscript.h"
+#include "unicode/ubidi.h"
+
+#include "layout/LETypes.h"
+#include "layout/LEScripts.h"
+#include "layout/LayoutEngine.h"
+
+#include "PortableFontInstance.h"
+#include "SimpleFontInstance.h"
+
+#include "xmlparser.h"
+
+#include "letsutil.h"
+#include "letest.h"
+
+U_NAMESPACE_USE
+
+struct TestInput
+{
+ const char *fontName;
+ LEUnicode *text;
+ le_int32 textLength;
+ le_int32 scriptCode;
+ le_bool rightToLeft;
+};
+
+/*
+ * FIXME: should use the output file name and the current date.
+ */
+const char *header =
+ "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
+ "\n"
+ "<!--\n"
+ " Copyright (c) 1999-%4.4d International Business Machines\n"
+ " Corporation and others. All rights reserved.\n"
+ "\n"
+ " WARNING: THIS FILE IS MACHINE GENERATED. DO NOT HAND EDIT IT\n"
+ " UNLESS YOU REALLY KNOW WHAT YOU'RE DOING.\n"
+ "\n"
+ " file name: letest.xml\n"
+ " generated on: %s\n"
+ " generated by: gendata.cpp\n"
+ "-->\n"
+ "\n"
+ "<layout-tests>\n";
+
+void dumpLongs(FILE *file, const char *tag, le_int32 *longs, le_int32 count) {
+ char lineBuffer[8 * 12 + 2];
+ le_int32 bufp = 0;
+
+ fprintf(file, " <%s>\n", tag);
+
+ for (int i = 0; i < count; i += 1) {
+ if (i % 8 == 0 && bufp != 0) {
+ fprintf(file, " %s\n", lineBuffer);
+ bufp = 0;
+ }
+
+ bufp += sprintf(&lineBuffer[bufp], "0x%8.8X, ", longs[i]);
+ }
+
+ if (bufp != 0) {
+ lineBuffer[bufp - 2] = '\0';
+ fprintf(file, " %s\n", lineBuffer);
+ }
+
+ fprintf(file, " </%s>\n\n", tag);
+}
+
+void dumpFloats(FILE *file, const char *tag, float *floats, le_int32 count) {
+ char lineBuffer[8 * 16 + 2];
+ le_int32 bufp = 0;
+
+ fprintf(file, " <%s>\n", tag);
+
+ for (int i = 0; i < count; i += 1) {
+ if (i % 8 == 0 && bufp != 0) {
+ fprintf(file, " %s\n", lineBuffer);
+ bufp = 0;
+ }
+
+ bufp += sprintf(&lineBuffer[bufp], "%f, ", floats[i]);
+ }
+
+ if (bufp != 0) {
+ lineBuffer[bufp - 2] = '\0';
+ fprintf(file, " %s\n", lineBuffer);
+ }
+
+ fprintf(file, " </%s>\n", tag);
+}
+
+int main(int /*argc*/, char *argv[])
+{
+ UErrorCode status = U_ZERO_ERROR;
+ FILE *outputFile = fopen(argv[1], "w");
+ time_t now = time(NULL);
+ struct tm *local = localtime(&now);
+ const char *tmFormat = "%m/%d/%Y %I:%M:%S %p %Z";
+ char tmString[64];
+
+ strftime(tmString, 64, tmFormat, local);
+ fprintf(outputFile, header, local->tm_year + 1900, tmString);
+
+ UXMLParser *parser = UXMLParser::createParser(status);
+ UXMLElement *root = parser->parseFile("gendata.xml", status);
+
+ if (root == NULL) {
+ printf("Error: Could not open gendata.xml\n");
+ delete parser;
+ return -1;
+ }
+
+ UnicodeString test_case = UNICODE_STRING_SIMPLE("test-case");
+ UnicodeString test_text = UNICODE_STRING_SIMPLE("test-text");
+ UnicodeString test_font = UNICODE_STRING_SIMPLE("test-font");
+
+ // test-case attributes
+ UnicodeString id_attr = UNICODE_STRING_SIMPLE("id");
+ UnicodeString script_attr = UNICODE_STRING_SIMPLE("script");
+ UnicodeString lang_attr = UNICODE_STRING_SIMPLE("lang");
+
+ // test-font attributes
+ UnicodeString name_attr = UNICODE_STRING_SIMPLE("name");
+
+ const UXMLElement *testCase;
+ int32_t tc = 0;
+
+ while((testCase = root->nextChildElement(tc)) != NULL) {
+ if (testCase->getTagName().compare(test_case) == 0) {
+ char *id = getCString(testCase->getAttribute(id_attr));
+ char *script = getCString(testCase->getAttribute(script_attr));
+ char *lang = getCString(testCase->getAttribute(lang_attr));
+ LEFontInstance *font = NULL;
+ const UXMLElement *element;
+ int32_t ec = 0;
+ int32_t charCount = 0;
+ int32_t typoFlags = 3; // kerning + ligatures...
+ UScriptCode scriptCode;
+ le_int32 languageCode = -1;
+ UnicodeString text;
+ int32_t glyphCount = 0;
+ LEErrorCode leStatus = LE_NO_ERROR;
+ LayoutEngine *engine = NULL;
+ LEGlyphID *glyphs = NULL;
+ le_int32 *indices = NULL;
+ float *positions = NULL;
+
+ uscript_getCode(script, &scriptCode, 1, &status);
+ if (LE_FAILURE(status)) {
+ printf("Error: invalid script name: %s.\n", script);
+ goto free_c_strings;
+ }
+
+ if (lang != NULL) {
+ languageCode = getLanguageCode(lang);
+
+ if (languageCode < 0) {
+ printf("Error: invalid language name: %s.\n", lang);
+ goto free_c_strings;
+ }
+
+ fprintf(outputFile, " <test-case id=\"%s\" script=\"%s\" lang=\"%s\">\n", id, script, lang);
+ } else {
+ fprintf(outputFile, " <test-case id=\"%s\" script=\"%s\">\n", id, script);
+ }
+
+ while((element = testCase->nextChildElement(ec)) != NULL) {
+ UnicodeString tag = element->getTagName();
+
+ // TODO: make sure that each element is only used once.
+ if (tag.compare(test_font) == 0) {
+ char *fontName = getCString(element->getAttribute(name_attr));
+ const char *version = NULL;
+ PortableFontInstance *pfi = new PortableFontInstance(fontName, 12, leStatus);
+
+ if (LE_FAILURE(leStatus)) {
+ printf("Error: could not open font: %s\n", fontName);
+ freeCString(fontName);
+ goto free_c_strings;
+ }
+
+ version = pfi->getNameString(NAME_VERSION_STRING, PLATFORM_MACINTOSH, MACINTOSH_ROMAN, MACINTOSH_ENGLISH);
+
+ fprintf(outputFile, " <test-font name=\"%s\" version=\"%s\" checksum=\"0x%8.8X\"/>\n\n",
+ fontName, version, pfi->getFontChecksum());
+
+ pfi->deleteNameString(version);
+ freeCString(fontName);
+ font = pfi;
+ } else if (tag.compare(test_text) == 0) {
+ char *utf8 = NULL;
+
+ text = element->getText(TRUE);
+ charCount = text.length();
+
+ utf8 = getUTF8String(&text);
+ fprintf(outputFile, " <test-text>%s</test-text>\n\n", utf8);
+ freeCString(utf8);
+ } else {
+ // an unknown tag...
+ char *cTag = getCString(&tag);
+
+ printf("Test %s: unknown element with tag \"%s\"\n", id, cTag);
+ freeCString(cTag);
+ }
+ }
+
+ if (font == NULL) {
+ LEErrorCode fontStatus = LE_NO_ERROR;
+
+ font = new SimpleFontInstance(12, fontStatus);
+ typoFlags |= 0x80000000L; // use CharSubstitutionFilter...
+ }
+
+ engine = LayoutEngine::layoutEngineFactory(font, scriptCode, languageCode, typoFlags, leStatus);
+
+ if (LE_FAILURE(leStatus)) {
+ printf("Error for test %s: could not create a LayoutEngine.\n", id);
+ goto delete_font;
+ }
+
+ glyphCount = engine->layoutChars(text.getBuffer(), 0, charCount, charCount, getRTL(text), 0, 0, leStatus);
+
+ glyphs = NEW_ARRAY(LEGlyphID, glyphCount);
+ indices = NEW_ARRAY(le_int32, glyphCount);
+ positions = NEW_ARRAY(float, glyphCount * 2 + 2);
+
+ engine->getGlyphs(glyphs, leStatus);
+ engine->getCharIndices(indices, leStatus);
+ engine->getGlyphPositions(positions, leStatus);
+
+ dumpLongs(outputFile, "result-glyphs", (le_int32 *) glyphs, glyphCount);
+
+ dumpLongs(outputFile, "result-indices", indices, glyphCount);
+
+ dumpFloats(outputFile, "result-positions", positions, glyphCount * 2 + 2);
+
+ fprintf(outputFile, " </test-case>\n\n");
+
+ DELETE_ARRAY(positions);
+ DELETE_ARRAY(indices);
+ DELETE_ARRAY(glyphs);
+
+ delete engine;
+
+delete_font:
+ delete font;
+
+free_c_strings:
+ freeCString(lang);
+ freeCString(script);
+ freeCString(id);
+ }
+ }
+
+ delete root;
+ delete parser;
+
+ fprintf(outputFile, "</layout-tests>\n");
+
+ fclose(outputFile);
+}
Property changes on: trunk/source/test/letest/gendata.cpp
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/source/test/letest/gendata.xml
===================================================================
--- trunk/source/test/letest/gendata.xml 2006-12-21 11:09:23 UTC (rev 127)
+++ trunk/source/test/letest/gendata.xml 2006-12-21 11:10:34 UTC (rev 128)
@@ -1,77 +1,77 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
- Copyright (c) 1999-2006 International Business Machines
- Corporation and others. All rights reserved.
--->
-
-<layout-tests>
- <test-case id="Ghita" script="deva">
- <test-font name="raghu.ttf"/>
- <test-text>श्रीमद् भगवद्गीता अध्याय अर्जुन विषाद योग धृतराष्ट्र उवाचृ धर्मक्षेत्रे कुरुक्षेत्रे समवेता युयुत्सवः मामकाः पाण्डवाश्चैव किमकुर्वत संजव</test-text>
- </test-case>
-
- <test-case id="Arabic" script="arab">
- <test-font name="CODE2000.TTF"/>
- <test-text>أساسًا، تتعامل الحواسيب فقط مع الأرقام، وتقوم بتخزين الأحرف والمحارف الأخرى بعد أن تُعطي رقما معينا لكل واحد منها. وقبل اختراع "يونِكود"، كان هناك مئات الأنظمة للتشفير وتخصيص هذه الأرقام للمحارف، ولم يوجد نظام تشفير واحد يحتوي على جميع المحارف الضرورية</test-text>
- </test-case>
-
- <test-case id="Unicode Arabic" script="arab">
- <test-font name="LucidaSansRegular.ttf"/>
- <test-text>أساسًا، تتعامل الحواسيب فقط مع الأرقام، وتقوم بتخزين الأحرف والمحارف الأخرى بعد أن تُعطي رقما معينا لكل واحد منها. وقبل اختراع "يونِكود"، كان هناك مئات الأنظمة للتشفير وتخصيص هذه الأرقام للمحارف، ولم يوجد نظام تشفير واحد يحتوي على جميع المحارف الضرورية</test-text>
- </test-case>
-
- <test-case id="Thai" script="thai">
- <test-font name="angsd___.ttf"/>
- <test-text>บทที่๑พายุไซโคลนโดโรธีอาศัยอยู่ท่ามกลางทุ่งใหญ่ในแคนซัสกับลุงเฮนรีชาวไร่และป้าเอ็มภรรยาชาวไร่บ้านของพวกเขาหลังเล็กเพราะไม้สร้างบ้านต้องขนมาด้วยเกวียนเป็นระยะทางหลายไมล์</test-text>
- </test-case>
-
- <test-case id="Arabic Simple" script="arab">
- <test-text>أساسًا، تتعامل الحواسيب فقط مع الأرقام، وتقوم بتخزين الأحرف والمحارف الأخرى بعد أن تُعطي رقما معينا لكل واحد منها. وقبل اختراع "يونِكود"، كان هناك مئات الأنظمة للتشفير وتخصيص هذه الأرقام للمحارف، ولم يوجد نظام تشفير واحد يحتوي على جميع المحارف الضرورية</test-text>
- </test-case>
-
- <test-case id="Matra Test" script="deva">
- <test-font name="Devamt.ttf"/>
- <test-text>ुं ं॑</test-text>
- </test-case>
-
- <test-case id="Deva Stress Test" script="deva">
- <test-font name="Devamt.ttf"/>
- <test-text>कँ कं कः क॑ क॒ कँ॑ कं॒ कँंः क॒॑</test-text>
- </test-case>
-
- <test-case id="Deva Test" script="deva">
- <test-font name="Devamt.ttf"/>
- <test-text>रू क़् क्ष क्कि क्रि ट्रि हिन्दी र्क्रिं क्षत्रज्ञत्रक्ष श्र थ्र श्र कके र्कें केूकूेकेृ र्कू क़ क क् क्ष क्ष् क्ष्क ज़ ज ज् ज्ञ ज्ञ् ज्ञ्क र्क र्क्क ड्र क्क क़्क क़्क क़् क्ष्क क्ष् त्र्क द्द कि हि रू रु र्के र्कं क् कु के द्द्द क़्ष क्ष र्क्षे द्दत्र्क ज्ञ क्त्व ज्ञ्क र्कँ र्किँ र्केँ र्क्रिँ हिंदी ह्मिह्यिखि ङ्क ङ्म ङ्क्त ङ्ख ङ्ग ङ्घ ङ्क्ष ङ्क्ष्व ङ्क्ष्य र्क्त्वि र्र्र्र कै के कु कू कृ कॅ कॆ हु हू हॆ है हे</test-text>
- </test-case>
-
- <test-case id="Japanese Han" script="hani" lang="JAN">
- <test-font name="ARIALUNI.TTF"/>
- <test-text>中华人民共和国 台湾 中華人民共和國 臺灣</test-text>
- </test-case>
-
- <test-case id="Korean Han" script="hani" lang="KOR">
- <test-font name="ARIALUNI.TTF"/>
- <test-text>中华人民共和国 台湾 中華人民共和國 臺灣</test-text>
- </test-case>
-
- <test-case id="Traditional Han" script="hani" lang="ZHT">
- <test-font name="ARIALUNI.TTF"/>
- <test-text>中华人民共和国 台湾 中華人民共和國 臺灣</test-text>
- </test-case>
-
- <test-case id="Simplified Han" script="hani" lang="ZHS">
- <test-font name="ARIALUNI.TTF"/>
- <test-text>中华人民共和国 台湾 中華人民共和國 臺灣</test-text>
- </test-case>
-
- <test-case id="Deva locl Hindi" script="deva" lang="HIN">
- <test-font name="TestFont1.otf"/>
- <test-text>शङ़ु</test-text>
- </test-case>
-
- <test-case id="Deva locl Marathi" script="deva" lang="MAR">
- <test-font name="TestFont1.otf"/>
- <test-text>शङ़ु</test-text>
- </test-case>
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ Copyright (c) 1999-2006 International Business Machines
+ Corporation and others. All rights reserved.
+-->
+
+<layout-tests>
+ <test-case id="Ghita" script="deva">
+ <test-font name="raghu.ttf"/>
+ <test-text>श्रीमद् भगवद्गीता अध्याय अर्जुन विषाद योग धृतराष्ट्र उवाचृ धर्मक्षेत्रे कुरुक्षेत्रे समवेता युयुत्सवः मामकाः पाण्डवाश्चैव किमकुर्वत संजव</test-text>
+ </test-case>
+
+ <test-case id="Arabic" script="arab">
+ <test-font name="CODE2000.TTF"/>
+ <test-text>أساسًا، تتعامل الحواسيب فقط مع الأرقام، وتقوم بتخزين الأحرف والمحارف الأخرى بعد أن تُعطي رقما معينا لكل واحد منها. وقبل اختراع "يونِكود"، كان هناك مئات الأنظمة للتشفير وتخصيص هذه الأرقام للمحارف، ولم يوجد نظام تشفير واحد يحتوي على جميع المحارف الضرورية</test-text>
+ </test-case>
+
+ <test-case id="Unicode Arabic" script="arab">
+ <test-font name="LucidaSansRegular.ttf"/>
+ <test-text>أساسًا، تتعامل الحواسيب فقط مع الأرقام، وتقوم بتخزين الأحرف والمحارف الأخرى بعد أن تُعطي رقما معينا لكل واحد منها. وقبل اختراع "يونِكود"، كان هناك مئات الأنظمة للتشفير وتخصيص هذه الأرقام للمحارف، ولم يوجد نظام تشفير واحد يحتوي على جميع المحارف الضرورية</test-text>
+ </test-case>
+
+ <test-case id="Thai" script="thai">
+ <test-font name="angsd___.ttf"/>
+ <test-text>บทที่๑พายุไซโคลนโดโรธีอาศัยอยู่ท่ามกลางทุ่งใหญ่ในแคนซัสกับลุงเฮนรีชาวไร่และป้าเอ็มภรรยาชาวไร่บ้านของพวกเขาหลังเล็กเพราะไม้สร้างบ้านต้องขนมาด้วยเกวียนเป็นระยะทางหลายไมล์</test-text>
+ </test-case>
+
+ <test-case id="Arabic Simple" script="arab">
+ <test-text>أساسًا، تتعامل الحواسيب فقط مع الأرقام، وتقوم بتخزين الأحرف والمحارف الأخرى بعد أن تُعطي رقما معينا لكل واحد منها. وقبل اختراع "يونِكود"، كان هناك مئات الأنظمة للتشفير وتخصيص هذه الأرقام للمحارف، ولم يوجد نظام تشفير واحد يحتوي على جميع المحارف الضرورية</test-text>
+ </test-case>
+
+ <test-case id="Matra Test" script="deva">
+ <test-font name="Devamt.ttf"/>
+ <test-text>ुं ं॑</test-text>
+ </test-case>
+
+ <test-case id="Deva Stress Test" script="deva">
+ <test-font name="Devamt.ttf"/>
+ <test-text>कँ कं कः क॑ क॒ कँ॑ कं॒ कँंः क॒॑</test-text>
+ </test-case>
+
+ <test-case id="Deva Test" script="deva">
+ <test-font name="Devamt.ttf"/>
+ <test-text>रू क़् क्ष क्कि क्रि ट्रि हिन्दी र्क्रिं क्षत्रज्ञत्रक्ष श्र थ्र श्र कके र्कें केूकूेकेृ र्कू क़ क क् क्ष क्ष् क्ष्क ज़ ज ज् ज्ञ ज्ञ् ज्ञ्क र्क र्क्क ड्र क्क क़्क क़्क क़् क्ष्क क्ष् त्र्क द्द कि हि रू रु र्के र्कं क् कु के द्द्द क़्ष क्ष र्क्षे द्दत्र्क ज्ञ क्त्व ज्ञ्क र्कँ र्किँ र्केँ र्क्रिँ हिंदी ह्मिह्यिखि ङ्क ङ्म ङ्क्त ङ्ख ङ्ग ङ्घ ङ्क्ष ङ्क्ष्व ङ्क्ष्य र्क्त्वि र्र्र्र कै के कु कू कृ कॅ कॆ हु हू हॆ है हे</test-text>
+ </test-case>
+
+ <test-case id="Japanese Han" script="hani" lang="JAN">
+ <test-font name="ARIALUNI.TTF"/>
+ <test-text>中华人民共和国 台湾 中華人民共和國 臺灣</test-text>
+ </test-case>
+
+ <test-case id="Korean Han" script="hani" lang="KOR">
+ <test-font name="ARIALUNI.TTF"/>
+ <test-text>中华人民共和国 台湾 中華人民共和國 臺灣</test-text>
+ </test-case>
+
+ <test-case id="Traditional Han" script="hani" lang="ZHT">
+ <test-font name="ARIALUNI.TTF"/>
+ <test-text>中华人民共和国 台湾 中華人民共和國 臺灣</test-text>
+ </test-case>
+
+ <test-case id="Simplified Han" script="hani" lang="ZHS">
+ <test-font name="ARIALUNI.TTF"/>
+ <test-text>中华人民共和国 台湾 中華人民共和國 臺灣</test-text>
+ </test-case>
+
+ <test-case id="Deva locl Hindi" script="deva" lang="HIN">
+ <test-font name="TestFont1.otf"/>
+ <test-text>शङ़ु</test-text>
+ </test-case>
+
+ <test-case id="Deva locl Marathi" script="deva" lang="MAR">
+ <test-font name="TestFont1.otf"/>
+ <test-text>शङ़ु</test-text>
+ </test-case>
</layout-tests>
\ No newline at end of file
Property changes on: trunk/source/test/letest/gendata.xml
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/source/test/letest/letest.cpp
===================================================================
--- trunk/source/test/letest/letest.cpp 2006-12-21 11:09:23 UTC (rev 127)
+++ trunk/source/test/letest/letest.cpp 2006-12-21 11:10:34 UTC (rev 128)
@@ -1,860 +1,860 @@
-/*
- *******************************************************************************
- *
- * Copyright (C) 1999-2006, International Business Machines
- * Corporation and others. All Rights Reserved.
- *
- *******************************************************************************
- * file name: letest.cpp
- *
- * created on: 11/06/2000
- * created by: Eric R. Mader
- */
-
-#include "unicode/utypes.h"
-#include "unicode/uclean.h"
-#include "unicode/uchar.h"
-#include "unicode/unistr.h"
-#include "unicode/uscript.h"
-#include "unicode/putil.h"
-#include "unicode/ctest.h"
-
-#include "layout/LETypes.h"
-#include "layout/LEScripts.h"
-#include "layout/LayoutEngine.h"
-
-#include "PortableFontInstance.h"
-#include "SimpleFontInstance.h"
-
-#include "letsutil.h"
-#include "letest.h"
-
-#include "xmlparser.h"
-#include "putilimp.h" // for uprv_getUTCtime()
-
-#include <stdlib.h>
-#include <string.h>
-
-U_NAMESPACE_USE
-
-#define CH_COMMA 0x002C
-
-U_CDECL_BEGIN
-static void U_CALLCONV ParamTest(void)
-{
- LEErrorCode status = LE_NO_ERROR;
- SimpleFontInstance *font = new SimpleFontInstance(12, status);
- LayoutEngine *engine = LayoutEngine::layoutEngineFactory(font, arabScriptCode, -1, status);
- LEGlyphID *glyphs = NULL;
- le_int32 *indices = NULL;
- float *positions = NULL;
- le_int32 glyphCount = 0;
-
- glyphCount = engine->getGlyphCount();
- if (glyphCount != 0) {
- log_err("Calling getGlyphCount() on an empty layout returned %d.\n", glyphCount);
- }
-
- glyphs = NEW_ARRAY(LEGlyphID, glyphCount + 10);
- indices = NEW_ARRAY(le_int32, glyphCount + 10);
- positions = NEW_ARRAY(float, glyphCount + 10);
-
- engine->getGlyphs(NULL, status);
-
- if (status != LE_ILLEGAL_ARGUMENT_ERROR) {
- log_err("Calling getGlyphs(NULL, status) did not return LE_ILLEGAL_ARGUMENT_ERROR.\n");
- }
-
- status = LE_NO_ERROR;
- engine->getGlyphs(glyphs, status);
-
- if (status != LE_NO_LAYOUT_ERROR) {
- log_err("Calling getGlyphs(glyphs, status) on an empty layout did not return LE_NO_LAYOUT_ERROR.\n");
- }
-
- status = LE_NO_ERROR;
- engine->getGlyphs(NULL, 0xFF000000L, status);
-
- if (status != LE_ILLEGAL_ARGUMENT_ERROR) {
- log_err("Calling getGlyphs(NULL, 0xFF000000L, status) did not return LE_ILLEGAL_ARGUMENT_ERROR.\n");
- }
-
- status = LE_NO_ERROR;
- engine->getGlyphs(glyphs, 0xFF000000L, status);
-
- if (status != LE_NO_LAYOUT_ERROR) {
- log_err("Calling getGlyphs(glyphs, 0xFF000000L, status) on an empty layout did not return LE_NO_LAYOUT_ERROR.\n");
- }
-
- status = LE_NO_ERROR;
- engine->getCharIndices(NULL, status);
-
- if (status != LE_ILLEGAL_ARGUMENT_ERROR) {
- log_err("Calling getCharIndices(NULL, status) did not return LE_ILLEGAL_ARGUMENT_ERROR.\n");
- }
-
- status = LE_NO_ERROR;
- engine->getCharIndices(indices, status);
-
- if (status != LE_NO_LAYOUT_ERROR) {
- log_err("Calling getCharIndices(indices, status) on an empty layout did not return LE_NO_LAYOUT_ERROR.\n");
- }
-
- status = LE_NO_ERROR;
- engine->getCharIndices(NULL, 1024, status);
-
- if (status != LE_ILLEGAL_ARGUMENT_ERROR) {
- log_err("Calling getCharIndices(NULL, 1024, status) did not return LE_ILLEGAL_ARGUMENT_ERROR.\n");
- }
-
- status = LE_NO_ERROR;
- engine->getCharIndices(indices, 1024, status);
-
- if (status != LE_NO_LAYOUT_ERROR) {
- log_err("Calling getCharIndices(indices, 1024, status) on an empty layout did not return LE_NO_LAYOUT_ERROR.\n");
- }
-
- status = LE_NO_ERROR;
- engine->getGlyphPositions(NULL, status);
-
- if (status != LE_ILLEGAL_ARGUMENT_ERROR) {
- log_err("Calling getGlyphPositions(NULL, status) did not return LE_ILLEGAL_ARGUMENT_ERROR.\n");
- }
-
- status = LE_NO_ERROR;
- engine->getGlyphPositions(positions, status);
-
- if (status != LE_NO_LAYOUT_ERROR) {
- log_err("Calling getGlyphPositions(positions, status) on an empty layout did not return LE_NO_LAYOUT_ERROR.\n");
- }
-
- DELETE_ARRAY(positions);
- DELETE_ARRAY(indices);
- DELETE_ARRAY(glyphs);
-
- status = LE_NO_ERROR;
- glyphCount = engine->layoutChars(NULL, 0, 0, 0, FALSE, 0.0, 0.0, status);
-
- if (status != LE_ILLEGAL_ARGUMENT_ERROR) {
- log_err("Calling layoutChars(NULL, 0, 0, 0, FALSE, 0.0, 0.0, status) did not fail w/ LE_ILLEGAL_ARGUMENT_ERROR.\n");
- }
-
- LEUnicode chars[] = {
- 0x0045, 0x006E, 0x0067, 0x006C, 0x0069, 0x0073, 0x0068, 0x0020, // "English "
- 0x0645, 0x0627, 0x0646, 0x062A, 0x0648, 0x0634, // MEM ALIF KAF NOON TEH WAW SHEEN
- 0x0020, 0x0074, 0x0065, 0x0078, 0x0074, 0x02E // " text."
- };
-
- status = LE_NO_ERROR;
- glyphCount = engine->layoutChars(chars, -1, 6, 20, TRUE, 0.0, 0.0, status);
-
- if (status != LE_ILLEGAL_ARGUMENT_ERROR) {
- log_err("Calling layoutChars(chars, -1, 6, 20, TRUE, 0.0, 0.0, status) did not fail w/ LE_ILLEGAL_ARGUMENT_ERROR.\n");
- }
-
- status = LE_NO_ERROR;
- glyphCount = engine->layoutChars(chars, 8, -1, 20, TRUE, 0.0, 0.0, status);
-
- if (status != LE_ILLEGAL_ARGUMENT_ERROR) {
- log_err("Calling layoutChars(chars, 8, -1, 20, TRUE, 0.0, 0.0, status) did not fail w/ LE_ILLEGAL_ARGUMENT_ERROR.\n");
- }
-
- status = LE_NO_ERROR;
- glyphCount = engine->layoutChars(chars, 8, 6, -1, TRUE, 0.0, 0.0, status);
-
- if (status != LE_ILLEGAL_ARGUMENT_ERROR) {
- log_err("Calling layoutChars((chars, 8, 6, -1, TRUE, 0.0, 0.0, status) did not fail w/ LE_ILLEGAL_ARGUMENT_ERROR.\n");
- }
-
- status = LE_NO_ERROR;
- glyphCount = engine->layoutChars(chars, 8, 6, 10, TRUE, 0.0, 0.0, status);
-
- if (status != LE_ILLEGAL_ARGUMENT_ERROR) {
- log_err("Calling layoutChars(chars, 8, 6, 10, TRUE, 0.0, 0.0, status) did not fail w/ LE_ILLEGAL_ARGUMENT_ERROR.\n");
- }
-
- float x = 0.0, y = 0.0;
-
- status = LE_NO_ERROR;
- glyphCount = engine->layoutChars(chars, 8, 6, 20, TRUE, 0.0, 0.0, status);
-
- if (LE_FAILURE(status)) {
- log_err("Calling layoutChars(chars, 8, 6, 20, TRUE, 0.0, 0.0, status) failed.\n");
- goto bail;
- }
-
- engine->getGlyphPosition(-1, x, y, status);
-
- if (status != LE_INDEX_OUT_OF_BOUNDS_ERROR) {
- log_err("Calling getGlyphPosition(-1, x, y, status) did not fail w/ LE_INDEX_OUT_OF_BOUNDS_ERROR.\n");
- }
-
- status = LE_NO_ERROR;
- engine->getGlyphPosition(glyphCount + 1, x, y, status);
-
- if (status != LE_INDEX_OUT_OF_BOUNDS_ERROR) {
- log_err("Calling getGlyphPosition(glyphCount + 1, x, y, status) did not fail w/ LE_INDEX_OUT_OF_BOUNDS_ERROR.\n");
- }
-
-bail:
- delete engine;
- delete font;
-}
-U_CDECL_END
-
-U_CDECL_BEGIN
-static void U_CALLCONV FactoryTest(void)
-{
- LEErrorCode status = LE_NO_ERROR;
- SimpleFontInstance *font = new SimpleFontInstance(12, status);
- LayoutEngine *engine = NULL;
-
- for(le_int32 scriptCode = 0; scriptCode < scriptCodeCount; scriptCode += 1) {
- status = LE_NO_ERROR;
- engine = LayoutEngine::layoutEngineFactory(font, scriptCode, -1, status);
-
- if (LE_FAILURE(status)) {
- log_err("Could not create a LayoutEngine for script \'%s\'.\n", uscript_getShortName((UScriptCode)scriptCode));
- }
-
- delete engine;
- }
-
- delete font;
-}
-U_CDECL_END
-
-U_CDECL_BEGIN
-static void U_CALLCONV AccessTest(void)
-{
- LEErrorCode status = LE_NO_ERROR;
- SimpleFontInstance *font = new SimpleFontInstance(12, status);
- LayoutEngine *engine = LayoutEngine::layoutEngineFactory(font, arabScriptCode, -1, status);
- le_int32 glyphCount;
- LEGlyphID glyphs[6], extraBitGlyphs[6];;
- le_int32 biasedIndices[6], indices[6], glyph;
- float positions[6 * 2 + 2];
- LEUnicode chars[] = {
- 0x0045, 0x006E, 0x0067, 0x006C, 0x0069, 0x0073, 0x0068, 0x0020, // "English "
- 0x0645, 0x0627, 0x0646, 0x062A, 0x0648, 0x0634, // MEM ALIF KAF NOON TEH WAW SHEEN
- 0x0020, 0x0074, 0x0065, 0x0078, 0x0074, 0x02E // " text."
- };
-
- if (LE_FAILURE(status)) {
- log_err("Could not create LayoutEngine.\n");
- goto bail;
- }
-
- glyphCount = engine->layoutChars(chars, 8, 6, 20, TRUE, 0.0, 0.0, status);
-
- if (LE_FAILURE(status) || glyphCount != 6) {
- log_err("layoutChars(chars, 8, 6, 20, TRUE, 0.0, 0.0, status) failed.\n");
- goto bail;
- }
-
- engine->getGlyphs(glyphs, status);
- engine->getCharIndices(indices, status);
- engine->getGlyphPositions(positions, status);
-
- if (LE_FAILURE(status)) {
- log_err("Could not get glyph, indices and position arrays.\n");
- goto bail;
- }
-
- engine->getGlyphs(extraBitGlyphs, 0xFF000000L, status);
-
- if (LE_FAILURE(status)) {
- log_err("getGlyphs(extraBitGlyphs, 0xFF000000L, status); failed.\n");
- } else {
- for(glyph = 0; glyph < glyphCount; glyph += 1) {
- if (extraBitGlyphs[glyph] != (glyphs[glyph] | 0xFF000000L)) {
- log_err("extraBigGlyphs[%d] != glyphs[%d] | 0xFF000000L: %8X, %8X\n",
- glyph, glyph, extraBitGlyphs[glyph], glyphs[glyph]);
- break;
- }
- }
- }
-
- status = LE_NO_ERROR;
- engine->getCharIndices(biasedIndices, 1024, status);
-
- if (LE_FAILURE(status)) {
- log_err("getCharIndices(biasedIndices, 1024, status) failed.\n");
- } else {
- for (glyph = 0; glyph < glyphCount; glyph += 1) {
- if (biasedIndices[glyph] != (indices[glyph] + 1024)) {
- log_err("biasedIndices[%d] != indices[%d] + 1024: %8X, %8X\n",
- glyph, glyph, biasedIndices[glyph], indices[glyph]);
- break;
- }
- }
- }
-
- status = LE_NO_ERROR;
- for (glyph = 0; glyph <= glyphCount; glyph += 1) {
- float x = 0.0, y = 0.0;
-
- engine->getGlyphPosition(glyph, x, y, status);
-
- if (LE_FAILURE(status)) {
- log_err("getGlyphPosition(%d, x, y, status) failed.\n", glyph);
- break;
- }
-
- if (x != positions[glyph*2] || y != positions[glyph*2 + 1]) {
- log_err("getGlyphPosition(%d, x, y, status) returned bad position: (%f, %f) != (%f, %f)\n",
- glyph, x, y, positions[glyph*2], positions[glyph*2 + 1]);
- break;
- }
- }
-
-bail:
- delete engine;
- delete font;
-}
-U_CDECL_END
-
-le_bool compareResults(const char *testID, TestResult *expected, TestResult *actual)
-{
- /* NOTE: we'll stop on the first failure 'cause once there's one error, it may cascade... */
- if (actual->glyphCount != expected->glyphCount) {
- log_err("Test %s: incorrect glyph count: exptected %d, got %d\n",
- testID, expected->glyphCount, actual->glyphCount);
- return FALSE;
- }
-
- le_int32 i;
-
- for (i = 0; i < actual->glyphCount; i += 1) {
- if (actual->glyphs[i] != expected->glyphs[i]) {
- log_err("Test %s: incorrect id for glyph %d: expected %4X, got %4X\n",
- testID, i, expected->glyphs[i], actual->glyphs[i]);
- return FALSE;
- }
- }
-
- for (i = 0; i < actual->glyphCount; i += 1) {
- if (actual->indices[i] != expected->indices[i]) {
- log_err("Test %s: incorrect index for glyph %d: expected %8X, got %8X\n",
- testID, i, expected->indices[i], actual->indices[i]);
- return FALSE;
- }
- }
-
- for (i = 0; i <= actual->glyphCount; i += 1) {
- double xError = uprv_fabs(actual->positions[i * 2] - expected->positions[i * 2]);
-
- if (xError > 0.0001) {
- log_err("Test %s: incorrect x position for glyph %d: expected %f, got %f\n",
- testID, i, expected->positions[i * 2], actual->positions[i * 2]);
- return FALSE;
- }
-
- double yError = uprv_fabs(actual->positions[i * 2 + 1] - expected->positions[i * 2 + 1]);
-
- if (yError < 0) {
- yError = -yError;
- }
-
- if (yError > 0.0001) {
- log_err("Test %s: incorrect y position for glyph %d: expected %f, got %f\n",
- testID, i, expected->positions[i * 2 + 1], actual->positions[i * 2 + 1]);
- return FALSE;
- }
- }
-
- return TRUE;
-}
-
-static void checkFontVersion(PortableFontInstance *fontInstance, const char *testVersionString,
- le_uint32 testChecksum, const char *testID)
-{
- le_uint32 fontChecksum = fontInstance->getFontChecksum();
-
- if (fontChecksum != testChecksum) {
- const char *fontVersionString = fontInstance->getNameString(NAME_VERSION_STRING,
- PLATFORM_MACINTOSH, MACINTOSH_ROMAN, MACINTOSH_ENGLISH);
-
- log_info("Test %s: this may not be the same font used to generate the test data.\n", testID);
- log_info("Your font's version string is \"%s\"\n", fontVersionString);
- log_info("The expected version string is \"%s\"\n", testVersionString);
- log_info("If you see errors, they may be due to the version of the font you're using.\n");
-
- fontInstance->deleteNameString(fontVersionString);
- }
-}
-
-/* Returns the path to icu/source/test/testdata/ */
-const char *getSourceTestData() {
- const char *srcDataDir = NULL;
-#ifdef U_TOPSRCDIR
- srcDataDir = U_TOPSRCDIR U_FILE_SEP_STRING"test"U_FILE_SEP_STRING"testdata"U_FILE_SEP_STRING;
-#else
- srcDataDir = ".."U_FILE_SEP_STRING".."U_FILE_SEP_STRING"test"U_FILE_SEP_STRING"testdata"U_FILE_SEP_STRING;
- FILE *f = fopen(".."U_FILE_SEP_STRING".."U_FILE_SEP_STRING"test"U_FILE_SEP_STRING"testdata"U_FILE_SEP_STRING"rbbitst.txt", "r");
-
- if (f != NULL) {
- /* We're in icu/source/test/letest/ */
- fclose(f);
- } else {
- /* We're in icu/source/test/letest/(Debug|Release) */
- srcDataDir = ".."U_FILE_SEP_STRING".."U_FILE_SEP_STRING".."U_FILE_SEP_STRING"test"U_FILE_SEP_STRING"testdata"U_FILE_SEP_STRING;
- }
-#endif
-
- return srcDataDir;
-}
-
-const char *getPath(char buffer[2048], const char *filename) {
- const char *testDataDirectory = getSourceTestData();
-
- strcpy(buffer, testDataDirectory);
- strcat(buffer, filename);
-
- return buffer;
-}
-
-le_uint32 *getHexArray(const UnicodeString &numbers, int32_t &arraySize)
-{
- int32_t offset = -1;
-
- arraySize = 1;
- while((offset = numbers.indexOf(CH_COMMA, offset + 1)) >= 0) {
- arraySize += 1;
- }
-
- le_uint32 *array = NEW_ARRAY(le_uint32, arraySize);
- char number[16];
- le_int32 count = 0;
- le_int32 start = 0, end = 0;
- le_int32 len = 0;
-
- // trim leading whitespace
- while(u_isUWhiteSpace(numbers[start])) {
- start += 1;
- }
-
- while((end = numbers.indexOf(CH_COMMA, start)) >= 0) {
- len = numbers.extract(start, end - start, number, ARRAY_SIZE(number), US_INV);
- number[len] = '\0';
- start = end + 1;
-
- sscanf(number, "%x", &array[count++]);
-
- // trim whitespace following the comma
- while(u_isUWhiteSpace(numbers[start])) {
- start += 1;
- }
- }
-
- // trim trailing whitespace
- end = numbers.length();
- while(u_isUWhiteSpace(numbers[end - 1])) {
- end -= 1;
- }
-
- len = numbers.extract(start, end - start, number, ARRAY_SIZE(number), US_INV);
- number[len] = '\0';
- sscanf(number, "%x", &array[count]);
-
- return array;
-}
-
-float *getFloatArray(const UnicodeString &numbers, int32_t &arraySize)
-{
- int32_t offset = -1;
-
- arraySize = 1;
- while((offset = numbers.indexOf(CH_COMMA, offset + 1)) >= 0) {
- arraySize += 1;
- }
-
- float *array = NEW_ARRAY(float, arraySize);
- char number[32];
- le_int32 count = 0;
- le_int32 start = 0, end = 0;
- le_int32 len = 0;
-
- // trim leading whitespace
- while(u_isUWhiteSpace(numbers[start])) {
- start += 1;
- }
-
- while((end = numbers.indexOf(CH_COMMA, start)) >= 0) {
- len = numbers.extract(start, end - start, number, ARRAY_SIZE(number), US_INV);
- number[len] = '\0';
- start = end + 1;
-
- sscanf(number, "%f", &array[count++]);
-
- // trim whiteapce following the comma
- while(u_isUWhiteSpace(numbers[start])) {
- start += 1;
- }
- }
-
- while(u_isUWhiteSpace(numbers[start])) {
- start += 1;
- }
-
- // trim trailing whitespace
- end = numbers.length();
- while(u_isUWhiteSpace(numbers[end - 1])) {
- end -= 1;
- }
-
- len = numbers.extract(start, end - start, number, ARRAY_SIZE(number), US_INV);
- number[len] = '\0';
- sscanf(number, "%f", &array[count]);
-
- return array;
-}
-
-LEFontInstance *openFont(const char *fontName, const char *checksum, const char *version, const char *testID)
-{
- char path[2048];
- PortableFontInstance *font;
- LEErrorCode fontStatus = LE_NO_ERROR;
-
-
- font = new PortableFontInstance(getPath(path, fontName), 12, fontStatus);
-
- if (LE_FAILURE(fontStatus)) {
- log_info("Test %s: can't open font %s - test skipped.\n", testID, fontName);
- delete font;
- return NULL;
- } else {
- le_uint32 cksum = 0;
-
- sscanf(checksum, "%x", &cksum);
-
- checkFontVersion(font, version, cksum, testID);
- }
-
- return font;
-}
-
-U_CDECL_BEGIN
-static void U_CALLCONV DataDrivenTest(void)
-{
-#if !UCONFIG_NO_REGULAR_EXPRESSIONS
- UErrorCode status = U_ZERO_ERROR;
- char path[2048];
- const char *testFilePath = getPath(path, "letest.xml");
-
- UXMLParser *parser = UXMLParser::createParser(status);
- UXMLElement *root = parser->parseFile(testFilePath, status);
-
- if (root == NULL) {
- log_err("Could not open the test data file: %s\n", testFilePath);
- delete parser;
- return;
- }
-
- UnicodeString test_case = UNICODE_STRING_SIMPLE("test-case");
- UnicodeString test_text = UNICODE_STRING_SIMPLE("test-text");
- UnicodeString test_font = UNICODE_STRING_SIMPLE("test-font");
- UnicodeString result_glyphs = UNICODE_STRING_SIMPLE("result-glyphs");
- UnicodeString result_indices = UNICODE_STRING_SIMPLE("result-indices");
- UnicodeString result_positions = UNICODE_STRING_SIMPLE("result-positions");
-
- // test-case attributes
- UnicodeString id_attr = UNICODE_STRING_SIMPLE("id");
- UnicodeString script_attr = UNICODE_STRING_SIMPLE("script");
- UnicodeString lang_attr = UNICODE_STRING_SIMPLE("lang");
-
- // test-font attributes
- UnicodeString name_attr = UNICODE_STRING_SIMPLE("name");
- UnicodeString ver_attr = UNICODE_STRING_SIMPLE("version");
- UnicodeString cksum_attr = UNICODE_STRING_SIMPLE("checksum");
-
- const UXMLElement *testCase;
- int32_t tc = 0;
-
- while((testCase = root->nextChildElement(tc)) != NULL) {
- if (testCase->getTagName().compare(test_case) == 0) {
- char *id = getCString(testCase->getAttribute(id_attr));
- char *script = getCString(testCase->getAttribute(script_attr));
- char *lang = getCString(testCase->getAttribute(lang_attr));
- LEFontInstance *font = NULL;
- const UXMLElement *element;
- int32_t ec = 0;
- int32_t charCount = 0;
- int32_t typoFlags = 3; // kerning + ligatures...
- UScriptCode scriptCode;
- le_int32 languageCode = -1;
- UnicodeString text, glyphs, indices, positions;
- int32_t glyphCount = 0, indexCount = 0, positionCount = 0;
- TestResult expected = {0, NULL, NULL, NULL};
- TestResult actual = {0, NULL, NULL, NULL};
- LEErrorCode success = LE_NO_ERROR;
- LayoutEngine *engine = NULL;
-
- uscript_getCode(script, &scriptCode, 1, &status);
- if (LE_FAILURE(status)) {
- log_err("invalid script name: %s.\n", script);
- goto free_c_strings;
- }
-
- if (lang != NULL) {
- languageCode = getLanguageCode(lang);
-
- if (languageCode < 0) {
- log_err("invalid language name: %s.\n", lang);
- goto free_c_strings;
- }
- }
-
- while((element = testCase->nextChildElement(ec)) != NULL) {
- UnicodeString tag = element->getTagName();
-
- // TODO: make sure that each element is only used once.
- if (tag.compare(test_font) == 0) {
- char *fontName = getCString(element->getAttribute(name_attr));
- char *fontVer = getCString(element->getAttribute(ver_attr));
- char *fontCksum = getCString(element->getAttribute(cksum_attr));
-
- font = openFont(fontName, fontCksum, fontVer, id);
- freeCString(fontCksum);
- freeCString(fontVer);
- freeCString(fontName);
-
- if (font == NULL) {
- // warning message already displayed...
- goto free_c_strings;
- }
- } else if (tag.compare(test_text) == 0) {
- text = element->getText(TRUE);
- charCount = text.length();
- } else if (tag.compare(result_glyphs) == 0) {
- glyphs = element->getText(TRUE);
- } else if (tag.compare(result_indices) == 0) {
- indices = element->getText(TRUE);
- } else if (tag.compare(result_positions) == 0) {
- positions = element->getText(TRUE);
- } else {
- // an unknown tag...
- char *cTag = getCString(&tag);
-
- log_info("Test %s: unknown element with tag \"%s\"\n", id, cTag);
- freeCString(cTag);
- }
- }
-
- // TODO: make sure that the font, test-text, result-glyphs, result-indices and result-positions
- // have all been provided
- if (font == NULL) {
- LEErrorCode fontStatus = LE_NO_ERROR;
-
- font = new SimpleFontInstance(12, fontStatus);
- typoFlags |= 0x80000000L; // use CharSubstitutionFilter...
- }
-
- expected.glyphs = (LEGlyphID *) getHexArray(glyphs, glyphCount);
- expected.indices = (le_int32 *) getHexArray(indices, indexCount);
- expected.positions = getFloatArray(positions, positionCount);
-
- expected.glyphCount = glyphCount;
-
- if (glyphCount < charCount || indexCount != glyphCount || positionCount < glyphCount * 2 + 2) {
- log_err("Test %s: inconsistent input data: charCount = %d, glyphCount = %d, glyphCount = %d, indexCount = %d, positionCount = %d\n",
- id, charCount, glyphCount, indexCount, positionCount);
- goto free_expected;
- };
-
- engine = LayoutEngine::layoutEngineFactory(font, scriptCode, languageCode, typoFlags, success);
-
- if (LE_FAILURE(success)) {
- log_err("Test %s: could not create a LayoutEngine.\n", id);
- goto free_expected;
- }
-
- actual.glyphCount = engine->layoutChars(text.getBuffer(), 0, charCount, charCount, getRTL(text), 0, 0, success);
-
- actual.glyphs = NEW_ARRAY(LEGlyphID, actual.glyphCount);
- actual.indices = NEW_ARRAY(le_int32, actual.glyphCount);
- actual.positions = NEW_ARRAY(float, actual.glyphCount * 2 + 2);
-
- engine->getGlyphs(actual.glyphs, success);
- engine->getCharIndices(actual.indices, success);
- engine->getGlyphPositions(actual.positions, success);
-
- compareResults(id, &expected, &actual);
-
- DELETE_ARRAY(actual.positions);
- DELETE_ARRAY(actual.indices);
- DELETE_ARRAY(actual.glyphs);
-
- delete engine;
-
-free_expected:
- DELETE_ARRAY(expected.positions);
- DELETE_ARRAY(expected.indices);
- DELETE_ARRAY(expected.glyphs);
-
- delete font;
-
-free_c_strings:
- freeCString(lang);
- freeCString(script);
- freeCString(id);
- }
- }
-
- delete root;
- delete parser;
-#endif
-}
-U_CDECL_END
-
-static void addAllTests(TestNode** root)
-{
- addTest(root, &ParamTest, "api/ParameterTest");
- addTest(root, &FactoryTest, "api/FactoryTest");
- addTest(root, &AccessTest, "layout/AccessTest");
- addTest(root, &DataDrivenTest, "layout/DataDrivenTest");
-}
-
-/* returns the path to icu/source/data/out */
-static const char *ctest_dataOutDir()
-{
- static const char *dataOutDir = NULL;
-
- if(dataOutDir) {
- return dataOutDir;
- }
-
- /* U_TOPBUILDDIR is set by the makefiles on UNIXes when building cintltst and intltst
- // to point to the top of the build hierarchy, which may or
- // may not be the same as the source directory, depending on
- // the configure options used. At any rate,
- // set the data path to the built data from this directory.
- // The value is complete with quotes, so it can be used
- // as-is as a string constant.
- */
-#if defined (U_TOPBUILDDIR)
- {
- dataOutDir = U_TOPBUILDDIR "data"U_FILE_SEP_STRING"out"U_FILE_SEP_STRING;
- }
-#else
-
- /* On Windows, the file name obtained from __FILE__ includes a full path.
- * This file is "wherever\icu\source\test\cintltst\cintltst.c"
- * Change to "wherever\icu\source\data"
- */
- {
- static char p[sizeof(__FILE__) + 20];
- char *pBackSlash;
- int i;
-
- strcpy(p, __FILE__);
- /* We want to back over three '\' chars. */
- /* Only Windows should end up here, so looking for '\' is safe. */
- for (i=1; i<=3; i++) {
- pBackSlash = strrchr(p, U_FILE_SEP_CHAR);
- if (pBackSlash != NULL) {
- *pBackSlash = 0; /* Truncate the string at the '\' */
- }
- }
-
- if (pBackSlash != NULL) {
- /* We found and truncated three names from the path.
- * Now append "source\data" and set the environment
- */
- strcpy(pBackSlash, U_FILE_SEP_STRING "data" U_FILE_SEP_STRING "out" U_FILE_SEP_STRING);
- dataOutDir = p;
- }
- else {
- /* __FILE__ on MSVC7 does not contain the directory */
- FILE *file = fopen(".."U_FILE_SEP_STRING".."U_FILE_SEP_STRING "data" U_FILE_SEP_STRING "Makefile.in", "r");
- if (file) {
- fclose(file);
- dataOutDir = ".."U_FILE_SEP_STRING".."U_FILE_SEP_STRING "data" U_FILE_SEP_STRING "out" U_FILE_SEP_STRING;
- }
- else {
- dataOutDir = ".."U_FILE_SEP_STRING".."U_FILE_SEP_STRING".."U_FILE_SEP_STRING "data" U_FILE_SEP_STRING "out" U_FILE_SEP_STRING;
- }
- }
- }
-#endif
-
- return dataOutDir;
-}
-
-/* ctest_setICU_DATA - if the ICU_DATA environment variable is not already
- * set, try to deduce the directory in which ICU was built,
- * and set ICU_DATA to "icu/source/data" in that location.
- * The intent is to allow the tests to have a good chance
- * of running without requiring that the user manually set
- * ICU_DATA. Common data isn't a problem, since it is
- * picked up via a static (build time) reference, but the
- * tests dynamically load some data.
- */
-static void ctest_setICU_DATA() {
-
- /* No location for the data dir was identifiable.
- * Add other fallbacks for the test data location here if the need arises
- */
- if (getenv("ICU_DATA") == NULL) {
- /* If ICU_DATA isn't set, set it to the usual location */
- u_setDataDirectory(ctest_dataOutDir());
- }
-}
-
-int main(int argc, char* argv[])
-{
- int32_t nerrors = 0;
- TestNode *root = NULL;
- UErrorCode errorCode = U_ZERO_ERROR;
- UDate startTime, endTime;
- int32_t diffTime;
-
- startTime = uprv_getUTCtime();
-
- /* Check whether ICU will initialize without forcing the build data directory into
- * the ICU_DATA path. Success here means either the data dll contains data, or that
- * this test program was run with ICU_DATA set externally. Failure of this check
- * is normal when ICU data is not packaged into a shared library.
- *
- * Whether or not this test succeeds, we want to cleanup and reinitialize
- * with a data path so that data loading from individual files can be tested.
- */
- u_init(&errorCode);
-
- if (U_FAILURE(errorCode)) {
- fprintf(stderr,
- "#### Note: ICU Init without build-specific setDataDirectory() failed.\n");
- }
-
- u_cleanup();
- errorCode = U_ZERO_ERROR;
-
- /* Initialize ICU */
- ctest_setICU_DATA(); /* u_setDataDirectory() must happen Before u_init() */
- u_init(&errorCode);
-
- if (U_FAILURE(errorCode)) {
- fprintf(stderr,
- "#### ERROR! %s: u_init() failed with status = \"%s\".\n"
- "*** Check the ICU_DATA environment variable and \n"
- "*** check that the data files are present.\n", argv[0], u_errorName(errorCode));
- return 1;
- }
-
- addAllTests(&root);
- nerrors = processArgs(root, argc, argv);
-
- cleanUpTestTree(root);
- u_cleanup();
-
- endTime = uprv_getUTCtime();
- diffTime = (int32_t)(endTime - startTime);
- printf("Elapsed Time: %02d:%02d:%02d.%03d\n",
- (int)((diffTime%U_MILLIS_PER_DAY)/U_MILLIS_PER_HOUR),
- (int)((diffTime%U_MILLIS_PER_HOUR)/U_MILLIS_PER_MINUTE),
- (int)((diffTime%U_MILLIS_PER_MINUTE)/U_MILLIS_PER_SECOND),
- (int)(diffTime%U_MILLIS_PER_SECOND));
-
- return nerrors;
-}
-
+/*
+ *******************************************************************************
+ *
+ * Copyright (C) 1999-2006, International Business Machines
+ * Corporation and others. All Rights Reserved.
+ *
+ *******************************************************************************
+ * file name: letest.cpp
+ *
+ * created on: 11/06/2000
+ * created by: Eric R. Mader
+ */
+
+#include "unicode/utypes.h"
+#include "unicode/uclean.h"
+#include "unicode/uchar.h"
+#include "unicode/unistr.h"
+#include "unicode/uscript.h"
+#include "unicode/putil.h"
+#include "unicode/ctest.h"
+
+#include "layout/LETypes.h"
+#include "layout/LEScripts.h"
+#include "layout/LayoutEngine.h"
+
+#include "PortableFontInstance.h"
+#include "SimpleFontInstance.h"
+
+#include "letsutil.h"
+#include "letest.h"
+
+#include "xmlparser.h"
+#include "putilimp.h" // for uprv_getUTCtime()
+
+#include <stdlib.h>
+#include <string.h>
+
+U_NAMESPACE_USE
+
+#define CH_COMMA 0x002C
+
+U_CDECL_BEGIN
+static void U_CALLCONV ParamTest(void)
+{
+ LEErrorCode status = LE_NO_ERROR;
+ SimpleFontInstance *font = new SimpleFontInstance(12, status);
+ LayoutEngine *engine = LayoutEngine::layoutEngineFactory(font, arabScriptCode, -1, status);
+ LEGlyphID *glyphs = NULL;
+ le_int32 *indices = NULL;
+ float *positions = NULL;
+ le_int32 glyphCount = 0;
+
+ glyphCount = engine->getGlyphCount();
+ if (glyphCount != 0) {
+ log_err("Calling getGlyphCount() on an empty layout returned %d.\n", glyphCount);
+ }
+
+ glyphs = NEW_ARRAY(LEGlyphID, glyphCount + 10);
+ indices = NEW_ARRAY(le_int32, glyphCount + 10);
+ positions = NEW_ARRAY(float, glyphCount + 10);
+
+ engine->getGlyphs(NULL, status);
+
+ if (status != LE_ILLEGAL_ARGUMENT_ERROR) {
+ log_err("Calling getGlyphs(NULL, status) did not return LE_ILLEGAL_ARGUMENT_ERROR.\n");
+ }
+
+ status = LE_NO_ERROR;
+ engine->getGlyphs(glyphs, status);
+
+ if (status != LE_NO_LAYOUT_ERROR) {
+ log_err("Calling getGlyphs(glyphs, status) on an empty layout did not return LE_NO_LAYOUT_ERROR.\n");
+ }
+
+ status = LE_NO_ERROR;
+ engine->getGlyphs(NULL, 0xFF000000L, status);
+
+ if (status != LE_ILLEGAL_ARGUMENT_ERROR) {
+ log_err("Calling getGlyphs(NULL, 0xFF000000L, status) did not return LE_ILLEGAL_ARGUMENT_ERROR.\n");
+ }
+
+ status = LE_NO_ERROR;
+ engine->getGlyphs(glyphs, 0xFF000000L, status);
+
+ if (status != LE_NO_LAYOUT_ERROR) {
+ log_err("Calling getGlyphs(glyphs, 0xFF000000L, status) on an empty layout did not return LE_NO_LAYOUT_ERROR.\n");
+ }
+
+ status = LE_NO_ERROR;
+ engine->getCharIndices(NULL, status);
+
+ if (status != LE_ILLEGAL_ARGUMENT_ERROR) {
+ log_err("Calling getCharIndices(NULL, status) did not return LE_ILLEGAL_ARGUMENT_ERROR.\n");
+ }
+
+ status = LE_NO_ERROR;
+ engine->getCharIndices(indices, status);
+
+ if (status != LE_NO_LAYOUT_ERROR) {
+ log_err("Calling getCharIndices(indices, status) on an empty layout did not return LE_NO_LAYOUT_ERROR.\n");
+ }
+
+ status = LE_NO_ERROR;
+ engine->getCharIndices(NULL, 1024, status);
+
+ if (status != LE_ILLEGAL_ARGUMENT_ERROR) {
+ log_err("Calling getCharIndices(NULL, 1024, status) did not return LE_ILLEGAL_ARGUMENT_ERROR.\n");
+ }
+
+ status = LE_NO_ERROR;
+ engine->getCharIndices(indices, 1024, status);
+
+ if (status != LE_NO_LAYOUT_ERROR) {
+ log_err("Calling getCharIndices(indices, 1024, status) on an empty layout did not return LE_NO_LAYOUT_ERROR.\n");
+ }
+
+ status = LE_NO_ERROR;
+ engine->getGlyphPositions(NULL, status);
+
+ if (status != LE_ILLEGAL_ARGUMENT_ERROR) {
+ log_err("Calling getGlyphPositions(NULL, status) did not return LE_ILLEGAL_ARGUMENT_ERROR.\n");
+ }
+
+ status = LE_NO_ERROR;
+ engine->getGlyphPositions(positions, status);
+
+ if (status != LE_NO_LAYOUT_ERROR) {
+ log_err("Calling getGlyphPositions(positions, status) on an empty layout did not return LE_NO_LAYOUT_ERROR.\n");
+ }
+
+ DELETE_ARRAY(positions);
+ DELETE_ARRAY(indices);
+ DELETE_ARRAY(glyphs);
+
+ status = LE_NO_ERROR;
+ glyphCount = engine->layoutChars(NULL, 0, 0, 0, FALSE, 0.0, 0.0, status);
+
+ if (status != LE_ILLEGAL_ARGUMENT_ERROR) {
+ log_err("Calling layoutChars(NULL, 0, 0, 0, FALSE, 0.0, 0.0, status) did not fail w/ LE_ILLEGAL_ARGUMENT_ERROR.\n");
+ }
+
+ LEUnicode chars[] = {
+ 0x0045, 0x006E, 0x0067, 0x006C, 0x0069, 0x0073, 0x0068, 0x0020, // "English "
+ 0x0645, 0x0627, 0x0646, 0x062A, 0x0648, 0x0634, // MEM ALIF KAF NOON TEH WAW SHEEN
+ 0x0020, 0x0074, 0x0065, 0x0078, 0x0074, 0x02E // " text."
+ };
+
+ status = LE_NO_ERROR;
+ glyphCount = engine->layoutChars(chars, -1, 6, 20, TRUE, 0.0, 0.0, status);
+
+ if (status != LE_ILLEGAL_ARGUMENT_ERROR) {
+ log_err("Calling layoutChars(chars, -1, 6, 20, TRUE, 0.0, 0.0, status) did not fail w/ LE_ILLEGAL_ARGUMENT_ERROR.\n");
+ }
+
+ status = LE_NO_ERROR;
+ glyphCount = engine->layoutChars(chars, 8, -1, 20, TRUE, 0.0, 0.0, status);
+
+ if (status != LE_ILLEGAL_ARGUMENT_ERROR) {
+ log_err("Calling layoutChars(chars, 8, -1, 20, TRUE, 0.0, 0.0, status) did not fail w/ LE_ILLEGAL_ARGUMENT_ERROR.\n");
+ }
+
+ status = LE_NO_ERROR;
+ glyphCount = engine->layoutChars(chars, 8, 6, -1, TRUE, 0.0, 0.0, status);
+
+ if (status != LE_ILLEGAL_ARGUMENT_ERROR) {
+ log_err("Calling layoutChars((chars, 8, 6, -1, TRUE, 0.0, 0.0, status) did not fail w/ LE_ILLEGAL_ARGUMENT_ERROR.\n");
+ }
+
+ status = LE_NO_ERROR;
+ glyphCount = engine->layoutChars(chars, 8, 6, 10, TRUE, 0.0, 0.0, status);
+
+ if (status != LE_ILLEGAL_ARGUMENT_ERROR) {
+ log_err("Calling layoutChars(chars, 8, 6, 10, TRUE, 0.0, 0.0, status) did not fail w/ LE_ILLEGAL_ARGUMENT_ERROR.\n");
+ }
+
+ float x = 0.0, y = 0.0;
+
+ status = LE_NO_ERROR;
+ glyphCount = engine->layoutChars(chars, 8, 6, 20, TRUE, 0.0, 0.0, status);
+
+ if (LE_FAILURE(status)) {
+ log_err("Calling layoutChars(chars, 8, 6, 20, TRUE, 0.0, 0.0, status) failed.\n");
+ goto bail;
+ }
+
+ engine->getGlyphPosition(-1, x, y, status);
+
+ if (status != LE_INDEX_OUT_OF_BOUNDS_ERROR) {
+ log_err("Calling getGlyphPosition(-1, x, y, status) did not fail w/ LE_INDEX_OUT_OF_BOUNDS_ERROR.\n");
+ }
+
+ status = LE_NO_ERROR;
+ engine->getGlyphPosition(glyphCount + 1, x, y, status);
+
+ if (status != LE_INDEX_OUT_OF_BOUNDS_ERROR) {
+ log_err("Calling getGlyphPosition(glyphCount + 1, x, y, status) did not fail w/ LE_INDEX_OUT_OF_BOUNDS_ERROR.\n");
+ }
+
+bail:
+ delete engine;
+ delete font;
+}
+U_CDECL_END
+
+U_CDECL_BEGIN
+static void U_CALLCONV FactoryTest(void)
+{
+ LEErrorCode status = LE_NO_ERROR;
+ SimpleFontInstance *font = new SimpleFontInstance(12, status);
+ LayoutEngine *engine = NULL;
+
+ for(le_int32 scriptCode = 0; scriptCode < scriptCodeCount; scriptCode += 1) {
+ status = LE_NO_ERROR;
+ engine = LayoutEngine::layoutEngineFactory(font, scriptCode, -1, status);
+
+ if (LE_FAILURE(status)) {
+ log_err("Could not create a LayoutEngine for script \'%s\'.\n", uscript_getShortName((UScriptCode)scriptCode));
+ }
+
+ delete engine;
+ }
+
+ delete font;
+}
+U_CDECL_END
+
+U_CDECL_BEGIN
+static void U_CALLCONV AccessTest(void)
+{
+ LEErrorCode status = LE_NO_ERROR;
+ SimpleFontInstance *font = new SimpleFontInstance(12, status);
+ LayoutEngine *engine = LayoutEngine::layoutEngineFactory(font, arabScriptCode, -1, status);
+ le_int32 glyphCount;
+ LEGlyphID glyphs[6], extraBitGlyphs[6];;
+ le_int32 biasedIndices[6], indices[6], glyph;
+ float positions[6 * 2 + 2];
+ LEUnicode chars[] = {
+ 0x0045, 0x006E, 0x0067, 0x006C, 0x0069, 0x0073, 0x0068, 0x0020, // "English "
+ 0x0645, 0x0627, 0x0646, 0x062A, 0x0648, 0x0634, // MEM ALIF KAF NOON TEH WAW SHEEN
+ 0x0020, 0x0074, 0x0065, 0x0078, 0x0074, 0x02E // " text."
+ };
+
+ if (LE_FAILURE(status)) {
+ log_err("Could not create LayoutEngine.\n");
+ goto bail;
+ }
+
+ glyphCount = engine->layoutChars(chars, 8, 6, 20, TRUE, 0.0, 0.0, status);
+
+ if (LE_FAILURE(status) || glyphCount != 6) {
+ log_err("layoutChars(chars, 8, 6, 20, TRUE, 0.0, 0.0, status) failed.\n");
+ goto bail;
+ }
+
+ engine->getGlyphs(glyphs, status);
+ engine->getCharIndices(indices, status);
+ engine->getGlyphPositions(positions, status);
+
+ if (LE_FAILURE(status)) {
+ log_err("Could not get glyph, indices and position arrays.\n");
+ goto bail;
+ }
+
+ engine->getGlyphs(extraBitGlyphs, 0xFF000000L, status);
+
+ if (LE_FAILURE(status)) {
+ log_err("getGlyphs(extraBitGlyphs, 0xFF000000L, status); failed.\n");
+ } else {
+ for(glyph = 0; glyph < glyphCount; glyph += 1) {
+ if (extraBitGlyphs[glyph] != (glyphs[glyph] | 0xFF000000L)) {
+ log_err("extraBigGlyphs[%d] != glyphs[%d] | 0xFF000000L: %8X, %8X\n",
+ glyph, glyph, extraBitGlyphs[glyph], glyphs[glyph]);
+ break;
+ }
+ }
+ }
+
+ status = LE_NO_ERROR;
+ engine->getCharIndices(biasedIndices, 1024, status);
+
+ if (LE_FAILURE(status)) {
+ log_err("getCharIndices(biasedIndices, 1024, status) failed.\n");
+ } else {
+ for (glyph = 0; glyph < glyphCount; glyph += 1) {
+ if (biasedIndices[glyph] != (indices[glyph] + 1024)) {
+ log_err("biasedIndices[%d] != indices[%d] + 1024: %8X, %8X\n",
+ glyph, glyph, biasedIndices[glyph], indices[glyph]);
+ break;
+ }
+ }
+ }
+
+ status = LE_NO_ERROR;
+ for (glyph = 0; glyph <= glyphCount; glyph += 1) {
+ float x = 0.0, y = 0.0;
+
+ engine->getGlyphPosition(glyph, x, y, status);
+
+ if (LE_FAILURE(status)) {
+ log_err("getGlyphPosition(%d, x, y, status) failed.\n", glyph);
+ break;
+ }
+
+ if (x != positions[glyph*2] || y != positions[glyph*2 + 1]) {
+ log_err("getGlyphPosition(%d, x, y, status) returned bad position: (%f, %f) != (%f, %f)\n",
+ glyph, x, y, positions[glyph*2], positions[glyph*2 + 1]);
+ break;
+ }
+ }
+
+bail:
+ delete engine;
+ delete font;
+}
+U_CDECL_END
+
+le_bool compareResults(const char *testID, TestResult *expected, TestResult *actual)
+{
+ /* NOTE: we'll stop on the first failure 'cause once there's one error, it may cascade... */
+ if (actual->glyphCount != expected->glyphCount) {
+ log_err("Test %s: incorrect glyph count: exptected %d, got %d\n",
+ testID, expected->glyphCount, actual->glyphCount);
+ return FALSE;
+ }
+
+ le_int32 i;
+
+ for (i = 0; i < actual->glyphCount; i += 1) {
+ if (actual->glyphs[i] != expected->glyphs[i]) {
+ log_err("Test %s: incorrect id for glyph %d: expected %4X, got %4X\n",
+ testID, i, expected->glyphs[i], actual->glyphs[i]);
+ return FALSE;
+ }
+ }
+
+ for (i = 0; i < actual->glyphCount; i += 1) {
+ if (actual->indices[i] != expected->indices[i]) {
+ log_err("Test %s: incorrect index for glyph %d: expected %8X, got %8X\n",
+ testID, i, expected->indices[i], actual->indices[i]);
+ return FALSE;
+ }
+ }
+
+ for (i = 0; i <= actual->glyphCount; i += 1) {
+ double xError = uprv_fabs(actual->positions[i * 2] - expected->positions[i * 2]);
+
+ if (xError > 0.0001) {
+ log_err("Test %s: incorrect x position for glyph %d: expected %f, got %f\n",
+ testID, i, expected->positions[i * 2], actual->positions[i * 2]);
+ return FALSE;
+ }
+
+ double yError = uprv_fabs(actual->positions[i * 2 + 1] - expected->positions[i * 2 + 1]);
+
+ if (yError < 0) {
+ yError = -yError;
+ }
+
+ if (yError > 0.0001) {
+ log_err("Test %s: incorrect y position for glyph %d: expected %f, got %f\n",
+ testID, i, expected->positions[i * 2 + 1], actual->positions[i * 2 + 1]);
+ return FALSE;
+ }
+ }
+
+ return TRUE;
+}
+
+static void checkFontVersion(PortableFontInstance *fontInstance, const char *testVersionString,
+ le_uint32 testChecksum, const char *testID)
+{
+ le_uint32 fontChecksum = fontInstance->getFontChecksum();
+
+ if (fontChecksum != testChecksum) {
+ const char *fontVersionString = fontInstance->getNameString(NAME_VERSION_STRING,
+ PLATFORM_MACINTOSH, MACINTOSH_ROMAN, MACINTOSH_ENGLISH);
+
+ log_info("Test %s: this may not be the same font used to generate the test data.\n", testID);
+ log_info("Your font's version string is \"%s\"\n", fontVersionString);
+ log_info("The expected version string is \"%s\"\n", testVersionString);
+ log_info("If you see errors, they may be due to the version of the font you're using.\n");
+
+ fontInstance->deleteNameString(fontVersionString);
+ }
+}
+
+/* Returns the path to icu/source/test/testdata/ */
+const char *getSourceTestData() {
+ const char *srcDataDir = NULL;
+#ifdef U_TOPSRCDIR
+ srcDataDir = U_TOPSRCDIR U_FILE_SEP_STRING"test"U_FILE_SEP_STRING"testdata"U_FILE_SEP_STRING;
+#else
+ srcDataDir = ".."U_FILE_SEP_STRING".."U_FILE_SEP_STRING"test"U_FILE_SEP_STRING"testdata"U_FILE_SEP_STRING;
+ FILE *f = fopen(".."U_FILE_SEP_STRING".."U_FILE_SEP_STRING"test"U_FILE_SEP_STRING"testdata"U_FILE_SEP_STRING"rbbitst.txt", "r");
+
+ if (f != NULL) {
+ /* We're in icu/source/test/letest/ */
+ fclose(f);
+ } else {
+ /* We're in icu/source/test/letest/(Debug|Release) */
+ srcDataDir = ".."U_FILE_SEP_STRING".."U_FILE_SEP_STRING".."U_FILE_SEP_STRING"test"U_FILE_SEP_STRING"testdata"U_FILE_SEP_STRING;
+ }
+#endif
+
+ return srcDataDir;
+}
+
+const char *getPath(char buffer[2048], const char *filename) {
+ const char *testDataDirectory = getSourceTestData();
+
+ strcpy(buffer, testDataDirectory);
+ strcat(buffer, filename);
+
+ return buffer;
+}
+
+le_uint32 *getHexArray(const UnicodeString &numbers, int32_t &arraySize)
+{
+ int32_t offset = -1;
+
+ arraySize = 1;
+ while((offset = numbers.indexOf(CH_COMMA, offset + 1)) >= 0) {
+ arraySize += 1;
+ }
+
+ le_uint32 *array = NEW_ARRAY(le_uint32, arraySize);
+ char number[16];
+ le_int32 count = 0;
+ le_int32 start = 0, end = 0;
+ le_int32 len = 0;
+
+ // trim leading whitespace
+ while(u_isUWhiteSpace(numbers[start])) {
+ start += 1;
+ }
+
+ while((end = numbers.indexOf(CH_COMMA, start)) >= 0) {
+ len = numbers.extract(start, end - start, number, ARRAY_SIZE(number), US_INV);
+ number[len] = '\0';
+ start = end + 1;
+
+ sscanf(number, "%x", &array[count++]);
+
+ // trim whitespace following the comma
+ while(u_isUWhiteSpace(numbers[start])) {
+ start += 1;
+ }
+ }
+
+ // trim trailing whitespace
+ end = numbers.length();
+ while(u_isUWhiteSpace(numbers[end - 1])) {
+ end -= 1;
+ }
+
+ len = numbers.extract(start, end - start, number, ARRAY_SIZE(number), US_INV);
+ number[len] = '\0';
+ sscanf(number, "%x", &array[count]);
+
+ return array;
+}
+
+float *getFloatArray(const UnicodeString &numbers, int32_t &arraySize)
+{
+ int32_t offset = -1;
+
+ arraySize = 1;
+ while((offset = numbers.indexOf(CH_COMMA, offset + 1)) >= 0) {
+ arraySize += 1;
+ }
+
+ float *array = NEW_ARRAY(float, arraySize);
+ char number[32];
+ le_int32 count = 0;
+ le_int32 start = 0, end = 0;
+ le_int32 len = 0;
+
+ // trim leading whitespace
+ while(u_isUWhiteSpace(numbers[start])) {
+ start += 1;
+ }
+
+ while((end = numbers.indexOf(CH_COMMA, start)) >= 0) {
+ len = numbers.extract(start, end - start, number, ARRAY_SIZE(number), US_INV);
+ number[len] = '\0';
+ start = end + 1;
+
+ sscanf(number, "%f", &array[count++]);
+
+ // trim whiteapce following the comma
+ while(u_isUWhiteSpace(numbers[start])) {
+ start += 1;
+ }
+ }
+
+ while(u_isUWhiteSpace(numbers[start])) {
+ start += 1;
+ }
+
+ // trim trailing whitespace
+ end = numbers.length();
+ while(u_isUWhiteSpace(numbers[end - 1])) {
+ end -= 1;
+ }
+
+ len = numbers.extract(start, end - start, number, ARRAY_SIZE(number), US_INV);
+ number[len] = '\0';
+ sscanf(number, "%f", &array[count]);
+
+ return array;
+}
+
+LEFontInstance *openFont(const char *fontName, const char *checksum, const char *version, const char *testID)
+{
+ char path[2048];
+ PortableFontInstance *font;
+ LEErrorCode fontStatus = LE_NO_ERROR;
+
+
+ font = new PortableFontInstance(getPath(path, fontName), 12, fontStatus);
+
+ if (LE_FAILURE(fontStatus)) {
+ log_info("Test %s: can't open font %s - test skipped.\n", testID, fontName);
+ delete font;
+ return NULL;
+ } else {
+ le_uint32 cksum = 0;
+
+ sscanf(checksum, "%x", &cksum);
+
+ checkFontVersion(font, version, cksum, testID);
+ }
+
+ return font;
+}
+
+U_CDECL_BEGIN
+static void U_CALLCONV DataDrivenTest(void)
+{
+#if !UCONFIG_NO_REGULAR_EXPRESSIONS
+ UErrorCode status = U_ZERO_ERROR;
+ char path[2048];
+ const char *testFilePath = getPath(path, "letest.xml");
+
+ UXMLParser *parser = UXMLParser::createParser(status);
+ UXMLElement *root = parser->parseFile(testFilePath, status);
+
+ if (root == NULL) {
+ log_err("Could not open the test data file: %s\n", testFilePath);
+ delete parser;
+ return;
+ }
+
+ UnicodeString test_case = UNICODE_STRING_SIMPLE("test-case");
+ UnicodeString test_text = UNICODE_STRING_SIMPLE("test-text");
+ UnicodeString test_font = UNICODE_STRING_SIMPLE("test-font");
+ UnicodeString result_glyphs = UNICODE_STRING_SIMPLE("result-glyphs");
+ UnicodeString result_indices = UNICODE_STRING_SIMPLE("result-indices");
+ UnicodeString result_positions = UNICODE_STRING_SIMPLE("result-positions");
+
+ // test-case attributes
+ UnicodeString id_attr = UNICODE_STRING_SIMPLE("id");
+ UnicodeString script_attr = UNICODE_STRING_SIMPLE("script");
+ UnicodeString lang_attr = UNICODE_STRING_SIMPLE("lang");
+
+ // test-font attributes
+ UnicodeString name_attr = UNICODE_STRING_SIMPLE("name");
+ UnicodeString ver_attr = UNICODE_STRING_SIMPLE("version");
+ UnicodeString cksum_attr = UNICODE_STRING_SIMPLE("checksum");
+
+ const UXMLElement *testCase;
+ int32_t tc = 0;
+
+ while((testCase = root->nextChildElement(tc)) != NULL) {
+ if (testCase->getTagName().compare(test_case) == 0) {
+ char *id = getCString(testCase->getAttribute(id_attr));
+ char *script = getCString(testCase->getAttribute(script_attr));
+ char *lang = getCString(testCase->getAttribute(lang_attr));
+ LEFontInstance *font = NULL;
+ const UXMLElement *element;
+ int32_t ec = 0;
+ int32_t charCount = 0;
+ int32_t typoFlags = 3; // kerning + ligatures...
+ UScriptCode scriptCode;
+ le_int32 languageCode = -1;
+ UnicodeString text, glyphs, indices, positions;
+ int32_t glyphCount = 0, indexCount = 0, positionCount = 0;
+ TestResult expected = {0, NULL, NULL, NULL};
+ TestResult actual = {0, NULL, NULL, NULL};
+ LEErrorCode success = LE_NO_ERROR;
+ LayoutEngine *engine = NULL;
+
+ uscript_getCode(script, &scriptCode, 1, &status);
+ if (LE_FAILURE(status)) {
+ log_err("invalid script name: %s.\n", script);
+ goto free_c_strings;
+ }
+
+ if (lang != NULL) {
+ languageCode = getLanguageCode(lang);
+
+ if (languageCode < 0) {
+ log_err("invalid language name: %s.\n", lang);
+ goto free_c_strings;
+ }
+ }
+
+ while((element = testCase->nextChildElement(ec)) != NULL) {
+ UnicodeString tag = element->getTagName();
+
+ // TODO: make sure that each element is only used once.
+ if (tag.compare(test_font) == 0) {
+ char *fontName = getCString(element->getAttribute(name_attr));
+ char *fontVer = getCString(element->getAttribute(ver_attr));
+ char *fontCksum = getCString(element->getAttribute(cksum_attr));
+
+ font = openFont(fontName, fontCksum, fontVer, id);
+ freeCString(fontCksum);
+ freeCString(fontVer);
+ freeCString(fontName);
+
+ if (font == NULL) {
+ // warning message already displayed...
+ goto free_c_strings;
+ }
+ } else if (tag.compare(test_text) == 0) {
+ text = element->getText(TRUE);
+ charCount = text.length();
+ } else if (tag.compare(result_glyphs) == 0) {
+ glyphs = element->getText(TRUE);
+ } else if (tag.compare(result_indices) == 0) {
+ indices = element->getText(TRUE);
+ } else if (tag.compare(result_positions) == 0) {
+ positions = element->getText(TRUE);
+ } else {
+ // an unknown tag...
+ char *cTag = getCString(&tag);
+
+ log_info("Test %s: unknown element with tag \"%s\"\n", id, cTag);
+ freeCString(cTag);
+ }
+ }
+
+ // TODO: make sure that the font, test-text, result-glyphs, result-indices and result-positions
+ // have all been provided
+ if (font == NULL) {
+ LEErrorCode fontStatus = LE_NO_ERROR;
+
+ font = new SimpleFontInstance(12, fontStatus);
+ typoFlags |= 0x80000000L; // use CharSubstitutionFilter...
+ }
+
+ expected.glyphs = (LEGlyphID *) getHexArray(glyphs, glyphCount);
+ expected.indices = (le_int32 *) getHexArray(indices, indexCount);
+ expected.positions = getFloatArray(positions, positionCount);
+
+ expected.glyphCount = glyphCount;
+
+ if (glyphCount < charCount || indexCount != glyphCount || positionCount < glyphCount * 2 + 2) {
+ log_err("Test %s: inconsistent input data: charCount = %d, glyphCount = %d, glyphCount = %d, indexCount = %d, positionCount = %d\n",
+ id, charCount, glyphCount, indexCount, positionCount);
+ goto free_expected;
+ };
+
+ engine = LayoutEngine::layoutEngineFactory(font, scriptCode, languageCode, typoFlags, success);
+
+ if (LE_FAILURE(success)) {
+ log_err("Test %s: could not create a LayoutEngine.\n", id);
+ goto free_expected;
+ }
+
+ actual.glyphCount = engine->layoutChars(text.getBuffer(), 0, charCount, charCount, getRTL(text), 0, 0, success);
+
+ actual.glyphs = NEW_ARRAY(LEGlyphID, actual.glyphCount);
+ actual.indices = NEW_ARRAY(le_int32, actual.glyphCount);
+ actual.positions = NEW_ARRAY(float, actual.glyphCount * 2 + 2);
+
+ engine->getGlyphs(actual.glyphs, success);
+ engine->getCharIndices(actual.indices, success);
+ engine->getGlyphPositions(actual.positions, success);
+
+ compareResults(id, &expected, &actual);
+
+ DELETE_ARRAY(actual.positions);
+ DELETE_ARRAY(actual.indices);
+ DELETE_ARRAY(actual.glyphs);
+
+ delete engine;
+
+free_expected:
+ DELETE_ARRAY(expected.positions);
+ DELETE_ARRAY(expected.indices);
+ DELETE_ARRAY(expected.glyphs);
+
+ delete font;
+
+free_c_strings:
+ freeCString(lang);
+ freeCString(script);
+ freeCString(id);
+ }
+ }
+
+ delete root;
+ delete parser;
+#endif
+}
+U_CDECL_END
+
+static void addAllTests(TestNode** root)
+{
+ addTest(root, &ParamTest, "api/ParameterTest");
+ addTest(root, &FactoryTest, "api/FactoryTest");
+ addTest(root, &AccessTest, "layout/AccessTest");
+ addTest(root, &DataDrivenTest, "layout/DataDrivenTest");
+}
+
+/* returns the path to icu/source/data/out */
+static const char *ctest_dataOutDir()
+{
+ static const char *dataOutDir = NULL;
+
+ if(dataOutDir) {
+ return dataOutDir;
+ }
+
+ /* U_TOPBUILDDIR is set by the makefiles on UNIXes when building cintltst and intltst
+ // to point to the top of the build hierarchy, which may or
+ // may not be the same as the source directory, depending on
+ // the configure options used. At any rate,
+ // set the data path to the built data from this directory.
+ // The value is complete with quotes, so it can be used
+ // as-is as a string constant.
+ */
+#if defined (U_TOPBUILDDIR)
+ {
+ dataOutDir = U_TOPBUILDDIR "data"U_FILE_SEP_STRING"out"U_FILE_SEP_STRING;
+ }
+#else
+
+ /* On Windows, the file name obtained from __FILE__ includes a full path.
+ * This file is "wherever\icu\source\test\cintltst\cintltst.c"
+ * Change to "wherever\icu\source\data"
+ */
+ {
+ static char p[sizeof(__FILE__) + 20];
+ char *pBackSlash;
+ int i;
+
+ strcpy(p, __FILE__);
+ /* We want to back over three '\' chars. */
+ /* Only Windows should end up here, so looking for '\' is safe. */
+ for (i=1; i<=3; i++) {
+ pBackSlash = strrchr(p, U_FILE_SEP_CHAR);
+ if (pBackSlash != NULL) {
+ *pBackSlash = 0; /* Truncate the string at the '\' */
+ }
+ }
+
+ if (pBackSlash != NULL) {
+ /* We found and truncated three names from the path.
+ * Now append "source\data" and set the environment
+ */
+ strcpy(pBackSlash, U_FILE_SEP_STRING "data" U_FILE_SEP_STRING "out" U_FILE_SEP_STRING);
+ dataOutDir = p;
+ }
+ else {
+ /* __FILE__ on MSVC7 does not contain the directory */
+ FILE *file = fopen(".."U_FILE_SEP_STRING".."U_FILE_SEP_STRING "data" U_FILE_SEP_STRING "Makefile.in", "r");
+ if (file) {
+ fclose(file);
+ dataOutDir = ".."U_FILE_SEP_STRING".."U_FILE_SEP_STRING "data" U_FILE_SEP_STRING "out" U_FILE_SEP_STRING;
+ }
+ else {
+ dataOutDir = ".."U_FILE_SEP_STRING".."U_FILE_SEP_STRING".."U_FILE_SEP_STRING "data" U_FILE_SEP_STRING "out" U_FILE_SEP_STRING;
+ }
+ }
+ }
+#endif
+
+ return dataOutDir;
+}
+
+/* ctest_setICU_DATA - if the ICU_DATA environment variable is not already
+ * set, try to deduce the directory in which ICU was built,
+ * and set ICU_DATA to "icu/source/data" in that location.
+ * The intent is to allow the tests to have a good chance
+ * of running without requiring that the user manually set
+ * ICU_DATA. Common data isn't a problem, since it is
+ * picked up via a static (build time) reference, but the
+ * tests dynamically load some data.
+ */
+static void ctest_setICU_DATA() {
+
+ /* No location for the data dir was identifiable.
+ * Add other fallbacks for the test data location here if the need arises
+ */
+ if (getenv("ICU_DATA") == NULL) {
+ /* If ICU_DATA isn't set, set it to the usual location */
+ u_setDataDirectory(ctest_dataOutDir());
+ }
+}
+
+int main(int argc, char* argv[])
+{
+ int32_t nerrors = 0;
+ TestNode *root = NULL;
+ UErrorCode errorCode = U_ZERO_ERROR;
+ UDate startTime, endTime;
+ int32_t diffTime;
+
+ startTime = uprv_getUTCtime();
+
+ /* Check whether ICU will initialize without forcing the build data directory into
+ * the ICU_DATA path. Success here means either the data dll contains data, or that
+ * this test program was run with ICU_DATA set externally. Failure of this check
+ * is normal when ICU data is not packaged into a shared library.
+ *
+ * Whether or not this test succeeds, we want to cleanup and reinitialize
+ * with a data path so that data loading from individual files can be tested.
+ */
+ u_init(&errorCode);
+
+ if (U_FAILURE(errorCode)) {
+ fprintf(stderr,
+ "#### Note: ICU Init without build-specific setDataDirectory() failed.\n");
+ }
+
+ u_cleanup();
+ errorCode = U_ZERO_ERROR;
+
+ /* Initialize ICU */
+ ctest_setICU_DATA(); /* u_setDataDirectory() must happen Before u_init() */
+ u_init(&errorCode);
+
+ if (U_FAILURE(errorCode)) {
+ fprintf(stderr,
+ "#### ERROR! %s: u_init() failed with status = \"%s\".\n"
+ "*** Check the ICU_DATA environment variable and \n"
+ "*** check that the data files are present.\n", argv[0], u_errorName(errorCode));
+ return 1;
+ }
+
+ addAllTests(&root);
+ nerrors = processArgs(root, argc, argv);
+
+ cleanUpTestTree(root);
+ u_cleanup();
+
+ endTime = uprv_getUTCtime();
+ diffTime = (int32_t)(endTime - startTime);
+ printf("Elapsed Time: %02d:%02d:%02d.%03d\n",
+ (int)((diffTime%U_MILLIS_PER_DAY)/U_MILLIS_PER_HOUR),
+ (int)((diffTime%U_MILLIS_PER_HOUR)/U_MILLIS_PER_MINUTE),
+ (int)((diffTime%U_MILLIS_PER_MINUTE)/U_MILLIS_PER_SECOND),
+ (int)(diffTime%U_MILLIS_PER_SECOND));
+
+ return nerrors;
+}
+
Property changes on: trunk/source/test/letest/letest.cpp
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/source/test/letest/letest.h
===================================================================
--- trunk/source/test/letest/letest.h 2006-12-21 11:09:23 UTC (rev 127)
+++ trunk/source/test/letest/letest.h 2006-12-21 11:10:34 UTC (rev 128)
@@ -1,39 +1,39 @@
-/*
- *******************************************************************************
- *
- * Copyright (C) 1999-2006, International Business Machines
- * Corporation and others. All Rights Reserved.
- *
- *******************************************************************************
- * file name: letest.h
- *
- * created on: 11/06/2000
- * created by: Eric R. Mader
- */
-
-#ifndef __LETEST_H
-#define __LETEST_H
-
-#include "LETypes.h"
-
-#include <stdlib.h>
-#include <string.h>
-
-#define ARRAY_SIZE(array) (sizeof array / sizeof array[0])
-
-#define ARRAY_COPY(dst, src, count) memcpy((void *) (dst), (void *) (src), (count) * sizeof (src)[0])
-
-#define NEW_ARRAY(type,count) (type *) malloc((count) * sizeof(type))
-
-#define DELETE_ARRAY(array) free((void *) (array))
-
-#define GROW_ARRAY(array,newSize) realloc((void *) (array), (newSize) * sizeof (array)[0])
-
-struct TestResult
-{
- le_int32 glyphCount;
- LEGlyphID *glyphs;
- le_int32 *indices;
- float *positions;
-};
-#endif
+/*
+ *******************************************************************************
+ *
+ * Copyright (C) 1999-2006, International Business Machines
+ * Corporation and others. All Rights Reserved.
+ *
+ *******************************************************************************
+ * file name: letest.h
+ *
+ * created on: 11/06/2000
+ * created by: Eric R. Mader
+ */
+
+#ifndef __LETEST_H
+#define __LETEST_H
+
+#include "LETypes.h"
+
+#include <stdlib.h>
+#include <string.h>
+
+#define ARRAY_SIZE(array) (sizeof array / sizeof array[0])
+
+#define ARRAY_COPY(dst, src, count) memcpy((void *) (dst), (void *) (src), (count) * sizeof (src)[0])
+
+#define NEW_ARRAY(type,count) (type *) malloc((count) * sizeof(type))
+
+#define DELETE_ARRAY(array) free((void *) (array))
+
+#define GROW_ARRAY(array,newSize) realloc((void *) (array), (newSize) * sizeof (array)[0])
+
+struct TestResult
+{
+ le_int32 glyphCount;
+ LEGlyphID *glyphs;
+ le_int32 *indices;
+ float *positions;
+};
+#endif
Property changes on: trunk/source/test/letest/letest.h
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/source/test/letest/letsutil.cpp
===================================================================
--- trunk/source/test/letest/letsutil.cpp 2006-12-21 11:09:23 UTC (rev 127)
+++ trunk/source/test/letest/letsutil.cpp 2006-12-21 11:10:34 UTC (rev 128)
@@ -1,98 +1,98 @@
-/*
- *******************************************************************************
- *
- * Copyright (C) 1999-2006, International Business Machines
- * Corporation and others. All Rights Reserved.
- *
- *******************************************************************************
- * file name: letsutil.cpp
- *
- * created on: 04/25/2006
- * created by: Eric R. Mader
- */
-
-#include "unicode/utypes.h"
-#include "unicode/unistr.h"
-#include "unicode/ubidi.h"
-
-#include "layout/LETypes.h"
-#include "layout/LEScripts.h"
-#include "layout/LayoutEngine.h"
-#include "layout/LELanguages.h"
-
-#include "OpenTypeLayoutEngine.h"
-
-#include "letest.h"
-#include "letsutil.h"
-
-U_NAMESPACE_USE
-
-char *getCString(const UnicodeString *uString)
-{
- if (uString == NULL) {
- return NULL;
- }
-
- le_int32 uLength = uString->length();
- le_int32 cLength = uString->extract(0, uLength, NULL, 0, US_INV);
- char *cString = NEW_ARRAY(char, cLength + 1);
-
- uString->extract(0, uLength, cString, cLength, US_INV);
- cString[cLength] = '\0';
-
- return cString;
-}
-
-char *getUTF8String(const UnicodeString *uString)
-{
- if (uString == NULL) {
- return NULL;
- }
-
- le_int32 uLength = uString->length();
- le_int32 cLength = uString->extract(0, uLength, NULL, 0, "UTF-8");
- char *cString = NEW_ARRAY(char, cLength + 1);
-
- uString->extract(0, uLength, cString, cLength, "UTF-8");
-
- cString[cLength] = '\0';
-
- return cString;
-}
-
-void freeCString(char *cString)
-{
- DELETE_ARRAY(cString);
-}
-
-le_bool getRTL(const UnicodeString &text)
-{
- UBiDiLevel paraLevel;
- UErrorCode status = U_ZERO_ERROR;
- le_int32 charCount = text.length();
- UBiDi *ubidi = ubidi_openSized(charCount, 0, &status);
-
- ubidi_setPara(ubidi, text.getBuffer(), charCount, UBIDI_DEFAULT_LTR, NULL, &status);
- paraLevel = ubidi_getParaLevel(ubidi);
- ubidi_close(ubidi);
-
- return paraLevel & 1;
-}
-
-le_int32 getLanguageCode(const char *lang)
-{
- if (strlen(lang) != 3) {
- return -1;
- }
-
- LETag langTag = (LETag) ((lang[0] << 24) + (lang[1] << 16) + (lang[2] << 8) + 0x20);
-
- for (le_int32 i = 0; i < languageCodeCount; i += 1) {
- if (langTag == OpenTypeLayoutEngine::languageTags[i]) {
- return i;
- }
- }
-
- return -1;
-}
-
+/*
+ *******************************************************************************
+ *
+ * Copyright (C) 1999-2006, International Business Machines
+ * Corporation and others. All Rights Reserved.
+ *
+ *******************************************************************************
+ * file name: letsutil.cpp
+ *
+ * created on: 04/25/2006
+ * created by: Eric R. Mader
+ */
+
+#include "unicode/utypes.h"
+#include "unicode/unistr.h"
+#include "unicode/ubidi.h"
+
+#include "layout/LETypes.h"
+#include "layout/LEScripts.h"
+#include "layout/LayoutEngine.h"
+#include "layout/LELanguages.h"
+
+#include "OpenTypeLayoutEngine.h"
+
+#include "letest.h"
+#include "letsutil.h"
+
+U_NAMESPACE_USE
+
+char *getCString(const UnicodeString *uString)
+{
+ if (uString == NULL) {
+ return NULL;
+ }
+
+ le_int32 uLength = uString->length();
+ le_int32 cLength = uString->extract(0, uLength, NULL, 0, US_INV);
+ char *cString = NEW_ARRAY(char, cLength + 1);
+
+ uString->extract(0, uLength, cString, cLength, US_INV);
+ cString[cLength] = '\0';
+
+ return cString;
+}
+
+char *getUTF8String(const UnicodeString *uString)
+{
+ if (uString == NULL) {
+ return NULL;
+ }
+
+ le_int32 uLength = uString->length();
+ le_int32 cLength = uString->extract(0, uLength, NULL, 0, "UTF-8");
+ char *cString = NEW_ARRAY(char, cLength + 1);
+
+ uString->extract(0, uLength, cString, cLength, "UTF-8");
+
+ cString[cLength] = '\0';
+
+ return cString;
+}
+
+void freeCString(char *cString)
+{
+ DELETE_ARRAY(cString);
+}
+
+le_bool getRTL(const UnicodeString &text)
+{
+ UBiDiLevel paraLevel;
+ UErrorCode status = U_ZERO_ERROR;
+ le_int32 charCount = text.length();
+ UBiDi *ubidi = ubidi_openSized(charCount, 0, &status);
+
+ ubidi_setPara(ubidi, text.getBuffer(), charCount, UBIDI_DEFAULT_LTR, NULL, &status);
+ paraLevel = ubidi_getParaLevel(ubidi);
+ ubidi_close(ubidi);
+
+ return paraLevel & 1;
+}
+
+le_int32 getLanguageCode(const char *lang)
+{
+ if (strlen(lang) != 3) {
+ return -1;
+ }
+
+ LETag langTag = (LETag) ((lang[0] << 24) + (lang[1] << 16) + (lang[2] << 8) + 0x20);
+
+ for (le_int32 i = 0; i < languageCodeCount; i += 1) {
+ if (langTag == OpenTypeLayoutEngine::languageTags[i]) {
+ return i;
+ }
+ }
+
+ return -1;
+}
+
Property changes on: trunk/source/test/letest/letsutil.cpp
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/source/test/letest/letsutil.h
===================================================================
--- trunk/source/test/letest/letsutil.h 2006-12-21 11:09:23 UTC (rev 127)
+++ trunk/source/test/letest/letsutil.h 2006-12-21 11:10:34 UTC (rev 128)
@@ -1,36 +1,36 @@
-/*
- *******************************************************************************
- *
- * Copyright (C) 1999-2006, International Business Machines
- * Corporation and others. All Rights Reserved.
- *
- *******************************************************************************
- * file name: letsutil.h
- *
- * created on: 04/25/2006
- * created by: Eric R. Mader
- */
-
-#ifndef __LETSUTIL_H
-#define __LETSUTIL_H
-
-#include "unicode/utypes.h"
-#include "unicode/unistr.h"
-#include "unicode/ubidi.h"
-
-#include "layout/LETypes.h"
-#include "layout/LEScripts.h"
-#include "layout/LayoutEngine.h"
-#include "layout/LELanguages.h"
-
-#include "OpenTypeLayoutEngine.h"
-
-#include "letest.h"
-
-char *getCString(const UnicodeString *uString);
-char *getUTF8String(const UnicodeString *uString);
-void freeCString(char *cString);
-le_bool getRTL(const UnicodeString &text);
-le_int32 getLanguageCode(const char *lang);
-
-#endif
+/*
+ *******************************************************************************
+ *
+ * Copyright (C) 1999-2006, International Business Machines
+ * Corporation and others. All Rights Reserved.
+ *
+ *******************************************************************************
+ * file name: letsutil.h
+ *
+ * created on: 04/25/2006
+ * created by: Eric R. Mader
+ */
+
+#ifndef __LETSUTIL_H
+#define __LETSUTIL_H
+
+#include "unicode/utypes.h"
+#include "unicode/unistr.h"
+#include "unicode/ubidi.h"
+
+#include "layout/LETypes.h"
+#include "layout/LEScripts.h"
+#include "layout/LayoutEngine.h"
+#include "layout/LELanguages.h"
+
+#include "OpenTypeLayoutEngine.h"
+
+#include "letest.h"
+
+char *getCString(const UnicodeString *uString);
+char *getUTF8String(const UnicodeString *uString);
+void freeCString(char *cString);
+le_bool getRTL(const UnicodeString &text);
+le_int32 getLanguageCode(const char *lang);
+
+#endif
Property changes on: trunk/source/test/letest/letsutil.h
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/source/test/letest/readme.html
===================================================================
--- trunk/source/test/letest/readme.html 2006-12-21 11:09:23 UTC (rev 127)
+++ trunk/source/test/letest/readme.html 2006-12-21 11:10:34 UTC (rev 128)
@@ -1,100 +1,100 @@
-<!DOCTYPE html PUBLIC "-//w3c//dtd html 4.0 transitional//en">
-<html>
-<head>
- <meta http-equiv="Content-Type"
- content="text/html; charset=iso-8859-1">
- <meta name="Copyright"
- content="Copyright (c) 2001-2005, International Business Machines Corporation and others. All Rights Reserved.">
- <meta name="Author" content="Eric Mader">
- <meta name="GENERATOR"
- content="Mozilla/4.72 [en] (Windows NT 5.0; U) [Netscape]">
- <title>Readme file for letest and gendata</title>
-</head>
-<body>
-<h2> What are letest and gendata?</h2>
-letest is a program you can use to verify that you have built and
-installed the ICU LayoutEngine correctly. The test is not
-comprehensive,
-it just verifies that the results of laying out some Devanagari, Arabic
-and Thai text are as expected. Once this test has passed, you can use
-the ICU LayoutEngine in your application knowing that it has been
-correctly installed and that the basic functionality is in place.
-<p>gendata is a program that is used by the ICU team to build the
-source file testdata.cpp, which contains the expected results of
-running
-letest. Unless you have changed your copy of the LayoutEngine and want
-to validate the changes on other platforms, there's no reason for you
-to run this program. </p>
-<p>(The ICU team first runs a Windows application which uses the ICU
-LayoutEngine to display the text that letest uses. Once it has been
-verified that the text is displayed correctly, gendata is run to
-produce
-testdata.cpp, and then letest is run on Windows to verify that letest
-still works with the new data.) <br>
- </p>
-<h2> How do I build letest?</h2>
-First, you need to build ICU, including the LayoutEngine.
-<p>On Windows, the layout project should be listed as a dependency of
-all, so layout will build when you build all. If it doesn't for some
-reason, just select the layout project in the project toolbar and build
-it. </p>
-<p>On UNIX systems, you need to add the "--enable-layout=yes" option
-when you invoke the runConfigureICU script. When you've done that,
-layout should build when you do "make all install" </p>
-<p>To build letest on Windows, just open the letest project in
-<icu>\source\test\letest and build it. On UNIX systems, connect
-to
-<top-build-dir>/test/letest and do "make all" <br>
- </p>
-<h2> How do I run letest?</h2>
-Before you can run letest, you'll need to get the fonts it uses. For
-legal reasons, we can't include them with ICU, but you can download
-them
-from the web. To do this, you'll need access to a computer running
-Windows. Here's how to get the fonts:
-<p>Download a recent version of the Java 2 Platform, Standard Edition
-(J2SE) from <a href="http://java.sun.com/j2se.index.jsp">java.sun.com</a>.
-From this page, follow the link for the version you want to download,
-and then select the "Downloads" link on the left side of the page.
-Select either the SDK or the JRE. (The JRE is sufficient for letest.)
-Read the license agreement and click on "Accept" if you agree. This
-will take you to the actual download page. Download the package and
-install it. You'll need one font. On Windows, it will be in, for
-example, "C:\j2sdk1.4.2_06/jre/lib/fonts. The file you want is
-"LucidaSansRegular.ttf". Copy this file into the directory from which
-you'll run letest.<br>
-</p>
-<p>Next is the Hindi font. Go to the NCST site and download <a
- href="http://rohini.ncst.ernet.in/indix/download/font/raghu.ttf">
-raghu.ttf</a>. Be sure to look at the <a
- href="http://rohini.ncst.ernet.in/indix/download/font/README">README</a>
-file before you download the font. You can download raghu.ttf into the
-directory from which you'll run letest.<br>
-</p>
-<p>Then download the Thai font. Go to <a
- href="http://www.into-asia.com/thai_language/thaifont/">into-asia.com</a>
-and click on the link for the Angsana font. This will download a .ZIP
-file. Extract the font file, angsd___.ttf, into the directory from
-which you will run letest.<br>
-</p>
-<p>There's still one more font to get, the Code2000 Unicode font.Go to
-James Kass' <a href="http://home.att.net/%7Ejameskass/">Unicode
-Support In Your Browser</a> page and click on the link that says "Click
-Here to download Code2000 shareware demo Unicode font." This will
-download a .ZIP file which contains CODE2000.TTF and CODE2000.HTM.
-Expand this .ZIP file and put the CODE2000.TTF file in the directory
-from which you'll run letest.<br>
-</p>
-<p><span style="font-weight: bold;">Note:</span> The Code2000 font is
-shareware. If you want to use it for longer than a trial period, you
-should send a shareware fee to James. Directions for how to do this are
-in CODE2000.HTM.</p>
-<p>That's it! Now all you have to do is run letest (CTRL+F5 in Visual
-C++, or "./letest" in UNIX) If everything's OK you should see
-something like this: </p>
-<blockquote><tt>Test 0, font = raghu.ttf... passed.</tt> <br>
- <tt>Test 1, font = CODE2000.TTF... passed.</tt> <br>
- <tt>Test 2, font = LucidaSansRegular.ttf... passed.</tt> <br>
- <tt>Test 3, font = angsd___.ttf... passed.</tt></blockquote>
-</body>
-</html>
+<!DOCTYPE html PUBLIC "-//w3c//dtd html 4.0 transitional//en">
+<html>
+<head>
+ <meta http-equiv="Content-Type"
+ content="text/html; charset=iso-8859-1">
+ <meta name="Copyright"
+ content="Copyright (c) 2001-2005, International Business Machines Corporation and others. All Rights Reserved.">
+ <meta name="Author" content="Eric Mader">
+ <meta name="GENERATOR"
+ content="Mozilla/4.72 [en] (Windows NT 5.0; U) [Netscape]">
+ <title>Readme file for letest and gendata</title>
+</head>
+<body>
+<h2> What are letest and gendata?</h2>
+letest is a program you can use to verify that you have built and
+installed the ICU LayoutEngine correctly. The test is not
+comprehensive,
+it just verifies that the results of laying out some Devanagari, Arabic
+and Thai text are as expected. Once this test has passed, you can use
+the ICU LayoutEngine in your application knowing that it has been
+correctly installed and that the basic functionality is in place.
+<p>gendata is a program that is used by the ICU team to build the
+source file testdata.cpp, which contains the expected results of
+running
+letest. Unless you have changed your copy of the LayoutEngine and want
+to validate the changes on other platforms, there's no reason for you
+to run this program. </p>
+<p>(The ICU team first runs a Windows application which uses the ICU
+LayoutEngine to display the text that letest uses. Once it has been
+verified that the text is displayed correctly, gendata is run to
+produce
+testdata.cpp, and then letest is run on Windows to verify that letest
+still works with the new data.) <br>
+ </p>
+<h2> How do I build letest?</h2>
+First, you need to build ICU, including the LayoutEngine.
+<p>On Windows, the layout project should be listed as a dependency of
+all, so layout will build when you build all. If it doesn't for some
+reason, just select the layout project in the project toolbar and build
+it. </p>
+<p>On UNIX systems, you need to add the "--enable-layout=yes" option
+when you invoke the runConfigureICU script. When you've done that,
+layout should build when you do "make all install" </p>
+<p>To build letest on Windows, just open the letest project in
+<icu>\source\test\letest and build it. On UNIX systems, connect
+to
+<top-build-dir>/test/letest and do "make all" <br>
+ </p>
+<h2> How do I run letest?</h2>
+Before you can run letest, you'll need to get the fonts it uses. For
+legal reasons, we can't include them with ICU, but you can download
+them
+from the web. To do this, you'll need access to a computer running
+Windows. Here's how to get the fonts:
+<p>Download a recent version of the Java 2 Platform, Standard Edition
+(J2SE) from <a href="http://java.sun.com/j2se.index.jsp">java.sun.com</a>.
+From this page, follow the link for the version you want to download,
+and then select the "Downloads" link on the left side of the page.
+Select either the SDK or the JRE. (The JRE is sufficient for letest.)
+Read the license agreement and click on "Accept" if you agree. This
+will take you to the actual download page. Download the package and
+install it. You'll need one font. On Windows, it will be in, for
+example, "C:\j2sdk1.4.2_06/jre/lib/fonts. The file you want is
+"LucidaSansRegular.ttf". Copy this file into the directory from which
+you'll run letest.<br>
+</p>
+<p>Next is the Hindi font. Go to the NCST site and download <a
+ href="http://rohini.ncst.ernet.in/indix/download/font/raghu.ttf">
+raghu.ttf</a>. Be sure to look at the <a
+ href="http://rohini.ncst.ernet.in/indix/download/font/README">README</a>
+file before you download the font. You can download raghu.ttf into the
+directory from which you'll run letest.<br>
+</p>
+<p>Then download the Thai font. Go to <a
+ href="http://www.into-asia.com/thai_language/thaifont/">into-asia.com</a>
+and click on the link for the Angsana font. This will download a .ZIP
+file. Extract the font file, angsd___.ttf, into the directory from
+which you will run letest.<br>
+</p>
+<p>There's still one more font to get, the Code2000 Unicode font.Go to
+James Kass' <a href="http://home.att.net/%7Ejameskass/">Unicode
+Support In Your Browser</a> page and click on the link that says "Click
+Here to download Code2000 shareware demo Unicode font." This will
+download a .ZIP file which contains CODE2000.TTF and CODE2000.HTM.
+Expand this .ZIP file and put the CODE2000.TTF file in the directory
+from which you'll run letest.<br>
+</p>
+<p><span style="font-weight: bold;">Note:</span> The Code2000 font is
+shareware. If you want to use it for longer than a trial period, you
+should send a shareware fee to James. Directions for how to do this are
+in CODE2000.HTM.</p>
+<p>That's it! Now all you have to do is run letest (CTRL+F5 in Visual
+C++, or "./letest" in UNIX) If everything's OK you should see
+something like this: </p>
+<blockquote><tt>Test 0, font = raghu.ttf... passed.</tt> <br>
+ <tt>Test 1, font = CODE2000.TTF... passed.</tt> <br>
+ <tt>Test 2, font = LucidaSansRegular.ttf... passed.</tt> <br>
+ <tt>Test 3, font = angsd___.ttf... passed.</tt></blockquote>
+</body>
+</html>
Property changes on: trunk/source/test/letest/readme.html
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/source/test/letest/sfnt.h
===================================================================
--- trunk/source/test/letest/sfnt.h 2006-12-21 11:09:23 UTC (rev 127)
+++ trunk/source/test/letest/sfnt.h 2006-12-21 11:10:34 UTC (rev 128)
@@ -1,275 +1,275 @@
-/***************************************************************************
-*
-* Copyright (C) 1998-2005, International Business Machines
-* Corporation and others. All Rights Reserved.
-*
-************************************************************************/
-
-#ifndef __SFNT_H
-#define __SFNT_H
-
-#include "LETypes.h"
-
-
-#ifndef ANY_NUMBER
-#define ANY_NUMBER 1
-#endif
-
-struct DirectoryEntry
-{
- le_uint32 tag;
- le_uint32 checksum;
- le_uint32 offset;
- le_uint32 length;
-};
-
-struct SFNTDirectory
-{
- le_uint32 scalerType;
- le_uint16 numTables;
- le_uint16 searchRange;
- le_uint16 entrySelector;
- le_uint16 rangeShift;
- DirectoryEntry tableDirectory[ANY_NUMBER];
-};
-
-
-struct CMAPEncodingSubtableHeader
-{
- le_uint16 platformID;
- le_uint16 platformSpecificID;
- le_uint32 encodingOffset;
-};
-
-struct CMAPTable
-{
- le_uint16 version;
- le_uint16 numberSubtables;
- CMAPEncodingSubtableHeader encodingSubtableHeaders[ANY_NUMBER];
-};
-
-struct CMAPEncodingSubtable
-{
- le_uint16 format;
- le_uint16 length;
- le_uint16 language;
-};
-
-struct CMAPFormat0Encoding : CMAPEncodingSubtable
-{
- le_uint8 glyphIndexArray[256];
-};
-
-struct CMAPFormat2Subheader
-{
- le_uint16 firstCode;
- le_uint16 entryCount;
- le_int16 idDelta;
- le_uint16 idRangeOffset;
-};
-
-struct CMAPFormat2Encoding : CMAPEncodingSubtable
-{
- le_uint16 subHeadKeys[256];
- CMAPFormat2Subheader subheaders[ANY_NUMBER];
-};
-
-struct CMAPFormat4Encoding : CMAPEncodingSubtable
-{
- le_uint16 segCountX2;
- le_uint16 searchRange;
- le_uint16 entrySelector;
- le_uint16 rangeShift;
- le_uint16 endCodes[ANY_NUMBER];
-// le_uint16 reservedPad;
-// le_uint16 startCodes[ANY_NUMBER];
-// le_uint16 idDelta[ANY_NUMBER];
-// le_uint16 idRangeOffset[ANY_NUMBER];
-// le_uint16 glyphIndexArray[ANY_NUMBER];
-};
-
-struct CMAPFormat6Encoding : CMAPEncodingSubtable
-{
- le_uint16 firstCode;
- le_uint16 entryCount;
- le_uint16 glyphIndexArray[ANY_NUMBER];
-};
-
-struct CMAPEncodingSubtable32
-{
- le_uint32 format;
- le_uint32 length;
- le_uint32 language;
-};
-
-struct CMAPGroup
-{
- le_uint32 startCharCode;
- le_uint32 endCharCode;
- le_uint32 startGlyphCode;
-};
-
-struct CMAPFormat8Encoding : CMAPEncodingSubtable32
-{
- le_uint32 is32[65536/32];
- le_uint32 nGroups;
- CMAPGroup groups[ANY_NUMBER];
-};
-
-struct CMAPFormat10Encoding : CMAPEncodingSubtable32
-{
- le_uint32 startCharCode;
- le_uint32 numCharCodes;
- le_uint16 glyphs[ANY_NUMBER];
-};
-
-struct CMAPFormat12Encoding : CMAPEncodingSubtable32
-{
- le_uint32 nGroups;
- CMAPGroup groups[ANY_NUMBER];
-};
-
-typedef le_int32 fixed;
-
-struct BigDate
-{
- le_uint32 bc;
- le_uint32 ad;
-};
-
-struct HEADTable
-{
- fixed version;
- fixed fontRevision;
- le_uint32 checksumAdjustment;
- le_uint32 magicNumber;
- le_uint16 flags;
- le_uint16 unitsPerEm;
- BigDate created;
- BigDate modified;
- le_int16 xMin;
- le_int16 yMin;
- le_int16 xMax;
- le_int16 yMax;
- le_int16 lowestRecPPEM;
- le_int16 fontDirectionHint;
- le_int16 indexToLocFormat;
- le_int16 glyphDataFormat;
-};
-
-struct MAXPTable
-{
- fixed version;
- le_uint16 numGlyphs;
- le_uint16 maxPoints;
- le_uint16 maxContours;
- le_uint16 maxComponentPoints;
- le_uint16 maxComponentContours;
- le_uint16 maxZones;
- le_uint16 maxTwilightPoints;
- le_uint16 maxStorage;
- le_uint16 maxFunctionDefs;
- le_uint16 maxInstructionDefs;
- le_uint16 maxStackElements;
- le_uint16 maxSizeOfInstructions;
- le_uint16 maxComponentElements;
- le_uint16 maxComponentDepth;
-};
-
-struct HHEATable
-{
- fixed version;
- le_int16 ascent;
- le_int16 descent;
- le_int16 lineGap;
- le_uint16 advanceWidthMax;
- le_int16 minLeftSideBearing;
- le_int16 minRightSideBearing;
- le_int16 xMaxExtent;
- le_int16 caretSlopeRise;
- le_int16 caretSlopeRun;
- le_int16 caretOffset;
- le_int16 reserved1;
- le_int16 reserved2;
- le_int16 reserved3;
- le_int16 reserved4;
- le_int16 metricDataFormat;
- le_uint16 numOfLongHorMetrics;
-};
-
-struct LongHorMetric
-{
- le_uint16 advanceWidth;
- le_int16 leftSideBearing;
-};
-
-struct HMTXTable
-{
- LongHorMetric hMetrics[ANY_NUMBER]; // ANY_NUMBER = numOfLongHorMetrics from hhea table
-// le_int16 leftSideBearing[ANY_NUMBER]; // ANY_NUMBER = numGlyphs - numOfLongHorMetrics
-};
-
-enum PlatformID
-{
- PLATFORM_UNICODE = 0,
- PLATFORM_MACINTOSH = 1,
- PLATFORM_ISO = 2,
- PLATFORM_MICROSOFT = 3,
- PLATFORM_CUSTOM = 4
-};
-
-enum MacintoshEncodingID
-{
- MACINTOSH_ROMAN = 0
-};
-
-enum MacintoshLanguageID
-{
- MACINTOSH_ENGLISH = 0
-};
-
-enum NameID
-{
- NAME_COPYRIGHT_NOTICE = 0,
- NAME_FONT_FAMILY = 1,
- NAME_FONT_SUB_FAMILY = 2,
- NAME_UNIQUE_FONT_ID = 3,
- NAME_FULL_FONT_NAME = 4,
- NAME_VERSION_STRING = 5,
- NAME_POSTSCRIPT_NAME = 6,
- NAME_TRADEMARK = 7,
- NAME_MANUFACTURER = 8,
- NAME_DESIGNER = 9,
- NAME_DESCRIPTION = 10,
- NAME_VENDOR_URL = 11,
- NAME_DESIGNER_URL = 12,
- NAME_LICENSE_DESCRIPTION = 13,
- NAME_LICENSE_URL = 14,
- NAME_RESERVED = 15,
- NAME_PREFERRED_FAMILY = 16,
- NAME_PREFERRED_SUB_FAMILY = 17,
- NAME_COMPATIBLE_FULL = 18,
- NAME_SAMPLE_TEXT = 19,
- NAME_POSTSCRIPT_CID = 20
-};
-
-struct NameRecord
-{
- le_uint16 platformID;
- le_uint16 encodingID;
- le_uint16 languageID;
- le_uint16 nameID;
- le_uint16 length;
- le_uint16 offset;
-};
-
-struct NAMETable
-{
- le_uint16 version;
- le_uint16 count;
- le_uint16 stringOffset;
- NameRecord nameRecords[ANY_NUMBER];
-};
-
-#endif
-
+/***************************************************************************
+*
+* Copyright (C) 1998-2005, International Business Machines
+* Corporation and others. All Rights Reserved.
+*
+************************************************************************/
+
+#ifndef __SFNT_H
+#define __SFNT_H
+
+#include "LETypes.h"
+
+
+#ifndef ANY_NUMBER
+#define ANY_NUMBER 1
+#endif
+
+struct DirectoryEntry
+{
+ le_uint32 tag;
+ le_uint32 checksum;
+ le_uint32 offset;
+ le_uint32 length;
+};
+
+struct SFNTDirectory
+{
+ le_uint32 scalerType;
+ le_uint16 numTables;
+ le_uint16 searchRange;
+ le_uint16 entrySelector;
+ le_uint16 rangeShift;
+ DirectoryEntry tableDirectory[ANY_NUMBER];
+};
+
+
+struct CMAPEncodingSubtableHeader
+{
+ le_uint16 platformID;
+ le_uint16 platformSpecificID;
+ le_uint32 encodingOffset;
+};
+
+struct CMAPTable
+{
+ le_uint16 version;
+ le_uint16 numberSubtables;
+ CMAPEncodingSubtableHeader encodingSubtableHeaders[ANY_NUMBER];
+};
+
+struct CMAPEncodingSubtable
+{
+ le_uint16 format;
+ le_uint16 length;
+ le_uint16 language;
+};
+
+struct CMAPFormat0Encoding : CMAPEncodingSubtable
+{
+ le_uint8 glyphIndexArray[256];
+};
+
+struct CMAPFormat2Subheader
+{
+ le_uint16 firstCode;
+ le_uint16 entryCount;
+ le_int16 idDelta;
+ le_uint16 idRangeOffset;
+};
+
+struct CMAPFormat2Encoding : CMAPEncodingSubtable
+{
+ le_uint16 subHeadKeys[256];
+ CMAPFormat2Subheader subheaders[ANY_NUMBER];
+};
+
+struct CMAPFormat4Encoding : CMAPEncodingSubtable
+{
+ le_uint16 segCountX2;
+ le_uint16 searchRange;
+ le_uint16 entrySelector;
+ le_uint16 rangeShift;
+ le_uint16 endCodes[ANY_NUMBER];
+// le_uint16 reservedPad;
+// le_uint16 startCodes[ANY_NUMBER];
+// le_uint16 idDelta[ANY_NUMBER];
+// le_uint16 idRangeOffset[ANY_NUMBER];
+// le_uint16 glyphIndexArray[ANY_NUMBER];
+};
+
+struct CMAPFormat6Encoding : CMAPEncodingSubtable
+{
+ le_uint16 firstCode;
+ le_uint16 entryCount;
+ le_uint16 glyphIndexArray[ANY_NUMBER];
+};
+
+struct CMAPEncodingSubtable32
+{
+ le_uint32 format;
+ le_uint32 length;
+ le_uint32 language;
+};
+
+struct CMAPGroup
+{
+ le_uint32 startCharCode;
+ le_uint32 endCharCode;
+ le_uint32 startGlyphCode;
+};
+
+struct CMAPFormat8Encoding : CMAPEncodingSubtable32
+{
+ le_uint32 is32[65536/32];
+ le_uint32 nGroups;
+ CMAPGroup groups[ANY_NUMBER];
+};
+
+struct CMAPFormat10Encoding : CMAPEncodingSubtable32
+{
+ le_uint32 startCharCode;
+ le_uint32 numCharCodes;
+ le_uint16 glyphs[ANY_NUMBER];
+};
+
+struct CMAPFormat12Encoding : CMAPEncodingSubtable32
+{
+ le_uint32 nGroups;
+ CMAPGroup groups[ANY_NUMBER];
+};
+
+typedef le_int32 fixed;
+
+struct BigDate
+{
+ le_uint32 bc;
+ le_uint32 ad;
+};
+
+struct HEADTable
+{
+ fixed version;
+ fixed fontRevision;
+ le_uint32 checksumAdjustment;
+ le_uint32 magicNumber;
+ le_uint16 flags;
+ le_uint16 unitsPerEm;
+ BigDate created;
+ BigDate modified;
+ le_int16 xMin;
+ le_int16 yMin;
+ le_int16 xMax;
+ le_int16 yMax;
+ le_int16 lowestRecPPEM;
+ le_int16 fontDirectionHint;
+ le_int16 indexToLocFormat;
+ le_int16 glyphDataFormat;
+};
+
+struct MAXPTable
+{
+ fixed version;
+ le_uint16 numGlyphs;
+ le_uint16 maxPoints;
+ le_uint16 maxContours;
+ le_uint16 maxComponentPoints;
+ le_uint16 maxComponentContours;
+ le_uint16 maxZones;
+ le_uint16 maxTwilightPoints;
+ le_uint16 maxStorage;
+ le_uint16 maxFunctionDefs;
+ le_uint16 maxInstructionDefs;
+ le_uint16 maxStackElements;
+ le_uint16 maxSizeOfInstructions;
+ le_uint16 maxComponentElements;
+ le_uint16 maxComponentDepth;
+};
+
+struct HHEATable
+{
+ fixed version;
+ le_int16 ascent;
+ le_int16 descent;
+ le_int16 lineGap;
+ le_uint16 advanceWidthMax;
+ le_int16 minLeftSideBearing;
+ le_int16 minRightSideBearing;
+ le_int16 xMaxExtent;
+ le_int16 caretSlopeRise;
+ le_int16 caretSlopeRun;
+ le_int16 caretOffset;
+ le_int16 reserved1;
+ le_int16 reserved2;
+ le_int16 reserved3;
+ le_int16 reserved4;
+ le_int16 metricDataFormat;
+ le_uint16 numOfLongHorMetrics;
+};
+
+struct LongHorMetric
+{
+ le_uint16 advanceWidth;
+ le_int16 leftSideBearing;
+};
+
+struct HMTXTable
+{
+ LongHorMetric hMetrics[ANY_NUMBER]; // ANY_NUMBER = numOfLongHorMetrics from hhea table
+// le_int16 leftSideBearing[ANY_NUMBER]; // ANY_NUMBER = numGlyphs - numOfLongHorMetrics
+};
+
+enum PlatformID
+{
+ PLATFORM_UNICODE = 0,
+ PLATFORM_MACINTOSH = 1,
+ PLATFORM_ISO = 2,
+ PLATFORM_MICROSOFT = 3,
+ PLATFORM_CUSTOM = 4
+};
+
+enum MacintoshEncodingID
+{
+ MACINTOSH_ROMAN = 0
+};
+
+enum MacintoshLanguageID
+{
+ MACINTOSH_ENGLISH = 0
+};
+
+enum NameID
+{
+ NAME_COPYRIGHT_NOTICE = 0,
+ NAME_FONT_FAMILY = 1,
+ NAME_FONT_SUB_FAMILY = 2,
+ NAME_UNIQUE_FONT_ID = 3,
+ NAME_FULL_FONT_NAME = 4,
+ NAME_VERSION_STRING = 5,
+ NAME_POSTSCRIPT_NAME = 6,
+ NAME_TRADEMARK = 7,
+ NAME_MANUFACTURER = 8,
+ NAME_DESIGNER = 9,
+ NAME_DESCRIPTION = 10,
+ NAME_VENDOR_URL = 11,
+ NAME_DESIGNER_URL = 12,
+ NAME_LICENSE_DESCRIPTION = 13,
+ NAME_LICENSE_URL = 14,
+ NAME_RESERVED = 15,
+ NAME_PREFERRED_FAMILY = 16,
+ NAME_PREFERRED_SUB_FAMILY = 17,
+ NAME_COMPATIBLE_FULL = 18,
+ NAME_SAMPLE_TEXT = 19,
+ NAME_POSTSCRIPT_CID = 20
+};
+
+struct NameRecord
+{
+ le_uint16 platformID;
+ le_uint16 encodingID;
+ le_uint16 languageID;
+ le_uint16 nameID;
+ le_uint16 length;
+ le_uint16 offset;
+};
+
+struct NAMETable
+{
+ le_uint16 version;
+ le_uint16 count;
+ le_uint16 stringOffset;
+ NameRecord nameRecords[ANY_NUMBER];
+};
+
+#endif
+
Property changes on: trunk/source/test/letest/sfnt.h
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/source/test/letest/testdata.cpp
===================================================================
--- trunk/source/test/letest/testdata.cpp 2006-12-21 11:09:23 UTC (rev 127)
+++ trunk/source/test/letest/testdata.cpp 2006-12-21 11:10:34 UTC (rev 128)
@@ -1,638 +1,638 @@
-/*
- *******************************************************************************
- *
- * Copyright (C) 1999-2005, International Business Machines
- * Corporation and others. All Rights Reserved.
- *
- * WARNING: THIS FILE IS MACHINE GENERATED. DO NOT HAND EDIT IT
- * UNLESS YOU REALLY KNOW WHAT YOU'RE DOING.
- *
- *******************************************************************************
- *
- * file name: testdata.cpp
- * generated on: 02/28/2005 03:20:06 PM Pacific Standard Time
- * generated by: gendata.cpp
- */
-
-#include "LETypes.h"
-#include "LEScripts.h"
-#include "letest.h"
-
-const char *fontVersionString0 = "Version 0.99";
-le_uint32 fontChecksum0 = 0x541C94C7;
-
-LEUnicode inputText0[] =
-{
- 0x0936, 0x094D, 0x0930, 0x0940, 0x092E, 0x0926, 0x094D, 0x0020,
- 0x092D, 0x0917, 0x0935, 0x0926, 0x094D, 0x0917, 0x0940, 0x0924,
- 0x093E, 0x0020, 0x0905, 0x0927, 0x094D, 0x092F, 0x093E, 0x092F,
- 0x0020, 0x0905, 0x0930, 0x094D, 0x091C, 0x0941, 0x0928, 0x0020,
- 0x0935, 0x093F, 0x0937, 0x093E, 0x0926, 0x0020, 0x092F, 0x094B,
- 0x0917, 0x0020, 0x0927, 0x0943, 0x0924, 0x0930, 0x093E, 0x0937,
- 0x094D, 0x091F, 0x094D, 0x0930, 0x0020, 0x0909, 0x0935, 0x093E,
- 0x091A, 0x0943, 0x0020, 0x0927, 0x0930, 0x094D, 0x092E, 0x0915,
- 0x094D, 0x0937, 0x0947, 0x0924, 0x094D, 0x0930, 0x0947, 0x0020,
- 0x0915, 0x0941, 0x0930, 0x0941, 0x0915, 0x094D, 0x0937, 0x0947,
- 0x0924, 0x094D, 0x0930, 0x0947, 0x0020, 0x0938, 0x092E, 0x0935,
- 0x0947, 0x0924, 0x093E, 0x0020, 0x092F, 0x0941, 0x092F, 0x0941,
- 0x0924, 0x094D, 0x0938, 0x0935, 0x0903, 0x0020, 0x092E, 0x093E,
- 0x092E, 0x0915, 0x093E, 0x0903, 0x0020, 0x092A, 0x093E, 0x0923,
- 0x094D, 0x0921, 0x0935, 0x093E, 0x0936, 0x094D, 0x091A, 0x0948,
- 0x0935, 0x0020, 0x0915, 0x093F, 0x092E, 0x0915, 0x0941, 0x0930,
- 0x094D, 0x0935, 0x0924, 0x0020, 0x0938, 0x0902, 0x091C, 0x0935
-};
-
-LEGlyphID resultGlyphs0[] =
-{
- 0x0000012E, 0x0000FFFF, 0x0000FFFF, 0x00000222, 0x00000098, 0x0000026E, 0x0000FFFF, 0x00000003,
- 0x00000097, 0x00000082, 0x0000009D, 0x000001A5, 0x0000FFFF, 0x0000FFFF, 0x00000222, 0x0000008F,
- 0x00000221, 0x00000003, 0x0000005C, 0x000000DA, 0x0000FFFF, 0x00000099, 0x00000221, 0x00000099,
- 0x00000003, 0x0000005C, 0x00000087, 0x000001D5, 0x0000005B, 0x0000FFFF, 0x00000093, 0x00000003,
- 0x000001D2, 0x0000009D, 0x0000009F, 0x00000221, 0x00000091, 0x00000003, 0x00000099, 0x0000022A,
- 0x00000082, 0x00000003, 0x00000092, 0x000001D9, 0x0000008F, 0x0000009A, 0x00000221, 0x000001B6,
- 0x0000FFFF, 0x0000FFFF, 0x0000FFFF, 0x0000FFFF, 0x00000003, 0x00000060, 0x0000009D, 0x00000221,
- 0x00000085, 0x000001D9, 0x00000003, 0x00000092, 0x00000098, 0x0000005B, 0x0000FFFF, 0x000000A2,
- 0x0000FFFF, 0x0000FFFF, 0x0000022F, 0x0000011F, 0x0000FFFF, 0x0000FFFF, 0x0000022F, 0x00000003,
- 0x00000080, 0x000001D5, 0x0000009A, 0x000001FD, 0x000000A2, 0x0000FFFF, 0x0000FFFF, 0x0000022F,
- 0x0000011F, 0x0000FFFF, 0x0000FFFF, 0x0000022F, 0x00000003, 0x000000A0, 0x00000098, 0x0000009D,
- 0x0000022F, 0x0000008F, 0x00000221, 0x00000003, 0x00000099, 0x000001D5, 0x00000099, 0x000001D5,
- 0x000000D7, 0x0000FFFF, 0x000000A0, 0x0000009D, 0x0000022C, 0x00000003, 0x00000098, 0x00000221,
- 0x00000098, 0x00000080, 0x00000221, 0x0000022C, 0x00000003, 0x00000094, 0x00000221, 0x000000D6,
- 0x0000FFFF, 0x0000008C, 0x0000009D, 0x00000221, 0x000001B1, 0x0000FFFF, 0x0000FFFF, 0x00000230,
- 0x0000009D, 0x00000003, 0x000001D1, 0x00000080, 0x00000098, 0x00000080, 0x000001D5, 0x0000009D,
- 0x0000005B, 0x0000FFFF, 0x0000008F, 0x00000003, 0x000000A0, 0x00000232, 0x00000087, 0x0000009D
-};
-
-le_int32 resultGlyphCount0 = 136;
-
-le_int32 resultIndices0[] =
-{
- 0x00000000, 0x00000002, 0x00000001, 0x00000003, 0x00000004, 0x00000005, 0x00000006, 0x00000007,
- 0x00000008, 0x00000009, 0x0000000A, 0x0000000B, 0x0000000C, 0x0000000D, 0x0000000E, 0x0000000F,
- 0x00000010, 0x00000011, 0x00000012, 0x00000013, 0x00000014, 0x00000015, 0x00000016, 0x00000017,
- 0x00000018, 0x00000019, 0x0000001C, 0x0000001D, 0x0000001A, 0x0000001B, 0x0000001E, 0x0000001F,
- 0x00000021, 0x00000020, 0x00000022, 0x00000023, 0x00000024, 0x00000025, 0x00000026, 0x00000027,
- 0x00000028, 0x00000029, 0x0000002A, 0x0000002B, 0x0000002C, 0x0000002D, 0x0000002E, 0x0000002F,
- 0x00000030, 0x00000031, 0x00000033, 0x00000032, 0x00000034, 0x00000035, 0x00000036, 0x00000037,
- 0x00000038, 0x00000039, 0x0000003A, 0x0000003B, 0x0000003E, 0x0000003C, 0x0000003D, 0x0000003F,
- 0x00000040, 0x00000041, 0x00000042, 0x00000043, 0x00000045, 0x00000044, 0x00000046, 0x00000047,
- 0x00000048, 0x00000049, 0x0000004A, 0x0000004B, 0x0000004C, 0x0000004D, 0x0000004E, 0x0000004F,
- 0x00000050, 0x00000052, 0x00000051, 0x00000053, 0x00000054, 0x00000055, 0x00000056, 0x00000057,
- 0x00000058, 0x00000059, 0x0000005A, 0x0000005B, 0x0000005C, 0x0000005D, 0x0000005E, 0x0000005F,
- 0x00000060, 0x00000061, 0x00000062, 0x00000063, 0x00000064, 0x00000065, 0x00000066, 0x00000067,
- 0x00000068, 0x00000069, 0x0000006A, 0x0000006B, 0x0000006C, 0x0000006D, 0x0000006E, 0x0000006F,
- 0x00000070, 0x00000071, 0x00000072, 0x00000073, 0x00000074, 0x00000075, 0x00000076, 0x00000077,
- 0x00000078, 0x00000079, 0x0000007B, 0x0000007A, 0x0000007C, 0x0000007D, 0x0000007E, 0x00000081,
- 0x0000007F, 0x00000080, 0x00000082, 0x00000083, 0x00000084, 0x00000085, 0x00000086, 0x00000087
-};
-
-float resultPositions0[] =
-{
- 0.000000F, 0.000000F, 9.468750F, 0.000000F, 9.468750F, 0.000000F, 9.468750F, 0.000000F,
- 13.125000F, 0.000000F, 22.593750F, 0.000000F, 30.562500F, 0.000000F, 30.562500F, 0.000000F,
- 36.562500F, 0.000000F, 46.031250F, 0.000000F, 55.500000F, 0.000000F, 63.468750F, 0.000000F,
- 71.437500F, 0.000000F, 71.437500F, 0.000000F, 71.437500F, 0.000000F, 75.093750F, 0.000000F,
- 83.062500F, 0.000000F, 86.718750F, 0.000000F, 92.718750F, 0.000000F, 102.656250F, 0.000000F,
- 109.921875F, 0.000000F, 109.921875F, 0.000000F, 119.390625F, 0.000000F, 123.046875F, 0.000000F,
- 132.515625F, 0.000000F, 138.515625F, 0.000000F, 148.453125F, 0.000000F, 158.203125F, -0.011719F,
- 158.203125F, 0.263672F, 157.921875F, 0.000000F, 157.921875F, 0.000000F, 167.390625F, 0.000000F,
- 173.390625F, 0.000000F, 177.750000F, 0.000000F, 185.718750F, 0.000000F, 193.687500F, 0.000000F,
- 197.343750F, 0.000000F, 205.312500F, 0.000000F, 211.312500F, 0.000000F, 220.781250F, 0.000000F,
- 224.859375F, 0.000000F, 234.328125F, 0.000000F, 240.328125F, 0.000000F, 250.224609F, -0.011719F,
- 249.796875F, 0.000000F, 257.765625F, 0.000000F, 264.281250F, 0.000000F, 267.937500F, 0.000000F,
- 276.281250F, 0.000000F, 276.281250F, 0.000000F, 276.281250F, 0.000000F, 276.281250F, 0.000000F,
- 276.281250F, 0.000000F, 282.281250F, 0.000000F, 290.250000F, 0.000000F, 298.218750F, 0.000000F,
- 301.875000F, 0.000000F, 311.859375F, -0.011719F, 311.343750F, 0.000000F, 317.343750F, 0.000000F,
- 326.812500F, 0.000000F, 336.644531F, 0.263672F, 336.281250F, 0.000000F, 336.281250F, 0.000000F,
- 347.156250F, 0.000000F, 347.156250F, 0.000000F, 346.353516F, 0.275391F, 347.156250F, 0.000000F,
- 355.125000F, 0.000000F, 355.125000F, 0.000000F, 355.263672F, 0.263672F, 355.125000F, 0.000000F,
- 361.125000F, 0.000000F, 368.824219F, -0.011719F, 372.000000F, 0.000000F, 378.515625F, 0.000000F,
- 379.875000F, 0.000000F, 390.750000F, 0.000000F, 390.750000F, 0.000000F, 389.947266F, 0.275391F,
- 390.750000F, 0.000000F, 398.718750F, 0.000000F, 398.718750F, 0.000000F, 398.857422F, 0.263672F,
- 398.718750F, 0.000000F, 404.718750F, 0.000000F, 414.187500F, 0.000000F, 423.656250F, 0.000000F,
- 430.769531F, 0.263672F, 431.625000F, 0.000000F, 439.593750F, 0.000000F, 443.250000F, 0.000000F,
- 449.250000F, 0.000000F, 458.859375F, -0.011719F, 458.718750F, 0.000000F, 468.328125F, -0.011719F,
- 468.187500F, 0.000000F, 474.117188F, 0.000000F, 474.117188F, 0.000000F, 483.585938F, 0.000000F,
- 491.554688F, 0.000000F, 495.914063F, 0.000000F, 501.914063F, 0.000000F, 511.382813F, 0.000000F,
- 515.039063F, 0.000000F, 524.507813F, 0.000000F, 535.382813F, 0.000000F, 539.039063F, 0.000000F,
- 543.398438F, 0.000000F, 549.398438F, 0.000000F, 557.367188F, 0.000000F, 561.023438F, 0.000000F,
- 568.289063F, 0.000000F, 568.289063F, 0.000000F, 576.257813F, 0.000000F, 584.226563F, 0.000000F,
- 587.882813F, 0.000000F, 598.757813F, 0.000000F, 598.757813F, 0.000000F, 598.628906F, 0.263672F,
- 598.757813F, 0.000000F, 606.726563F, 0.000000F, 612.726563F, 0.000000F, 617.085938F, 0.000000F,
- 627.960938F, 0.000000F, 637.429688F, 0.000000F, 645.128906F, -0.011719F, 648.304688F, 0.000000F,
- 656.566406F, 0.263672F, 656.273438F, 0.000000F, 656.273438F, 0.000000F, 664.242188F, 0.000000F,
- 670.242188F, 0.000000F, 679.429688F, 0.966797F, 679.710938F, 0.000000F, 689.179688F, 0.000000F,
- 697.148438F, 0.000000F
-};
-
-
-const char *fontVersionString1 = "Version 1.14";
-le_uint32 fontChecksum1 = 0x2B6E171D;
-
-LEUnicode inputText1[] =
-{
- 0x0623, 0x0633, 0x0627, 0x0633, 0x064B, 0x0627, 0x060C, 0x0020,
- 0x062A, 0x062A, 0x0639, 0x0627, 0x0645, 0x0644, 0x0020, 0x0627,
- 0x0644, 0x062D, 0x0648, 0x0627, 0x0633, 0x064A, 0x0628, 0x0020,
- 0x0641, 0x0642, 0x0637, 0x0020, 0x0645, 0x0639, 0x0020, 0x0627,
- 0x0644, 0x0623, 0x0631, 0x0642, 0x0627, 0x0645, 0x060C, 0x0020,
- 0x0648, 0x062A, 0x0642, 0x0648, 0x0645, 0x0020, 0x0628, 0x062A,
- 0x062E, 0x0632, 0x064A, 0x0646, 0x0020, 0x0627, 0x0644, 0x0623,
- 0x062D, 0x0631, 0x0641, 0x0020, 0x0648, 0x0627, 0x0644, 0x0645,
- 0x062D, 0x0627, 0x0631, 0x0641, 0x0020, 0x0627, 0x0644, 0x0623,
- 0x062E, 0x0631, 0x0649, 0x0020, 0x0628, 0x0639, 0x062F, 0x0020,
- 0x0623, 0x0646, 0x0020, 0x062A, 0x064F, 0x0639, 0x0637, 0x064A,
- 0x0020, 0x0631, 0x0642, 0x0645, 0x0627, 0x0020, 0x0645, 0x0639,
- 0x064A, 0x0646, 0x0627, 0x0020, 0x0644, 0x0643, 0x0644, 0x0020,
- 0x0648, 0x0627, 0x062D, 0x062F, 0x0020, 0x0645, 0x0646, 0x0647,
- 0x0627, 0x002E, 0x0020, 0x0648, 0x0642, 0x0628, 0x0644, 0x0020,
- 0x0627, 0x062E, 0x062A, 0x0631, 0x0627, 0x0639, 0x0020, 0x0022,
- 0x064A, 0x0648, 0x0646, 0x0650, 0x0643, 0x0648, 0x062F, 0x0022,
- 0x060C, 0x0020, 0x0643, 0x0627, 0x0646, 0x0020, 0x0647, 0x0646,
- 0x0627, 0x0643, 0x0020, 0x0645, 0x0626, 0x0627, 0x062A, 0x0020,
- 0x0627, 0x0644, 0x0623, 0x0646, 0x0638, 0x0645, 0x0629, 0x0020,
- 0x0644, 0x0644, 0x062A, 0x0634, 0x0641, 0x064A, 0x0631, 0x0020,
- 0x0648, 0x062A, 0x062E, 0x0635, 0x064A, 0x0635, 0x0020, 0x0647,
- 0x0630, 0x0647, 0x0020, 0x0627, 0x0644, 0x0623, 0x0631, 0x0642,
- 0x0627, 0x0645, 0x0020, 0x0644, 0x0644, 0x0645, 0x062D, 0x0627,
- 0x0631, 0x0641, 0x060C, 0x0020, 0x0648, 0x0644, 0x0645, 0x0020,
- 0x064A, 0x0648, 0x062C, 0x062F, 0x0020, 0x0646, 0x0638, 0x0627,
- 0x0645, 0x0020, 0x062A, 0x0634, 0x0641, 0x064A, 0x0631, 0x0020,
- 0x0648, 0x0627, 0x062D, 0x062F, 0x0020, 0x064A, 0x062D, 0x062A,
- 0x0648, 0x064A, 0x0020, 0x0639, 0x0644, 0x0649, 0x0020, 0x062C,
- 0x0645, 0x064A, 0x0639, 0x0020, 0x0627, 0x0644, 0x0645, 0x062D,
- 0x0627, 0x0631, 0x0641, 0x0020, 0x0627, 0x0644, 0x0636, 0x0631,
- 0x0648, 0x0631, 0x064A, 0x0629
-};
-
-LEGlyphID resultGlyphs1[] =
-{
- 0x0000C530, 0x0000C58F, 0x0000C549, 0x0000C589, 0x0000C54A, 0x0000C55C, 0x0000C57B, 0x0000C529,
- 0x00000003, 0x0000C56D, 0x0000C549, 0x0000C52A, 0x0000C540, 0x0000C580, 0x0000C57B, 0x0000C529,
- 0x00000003, 0x0000C566, 0x0000C590, 0x0000C580, 0x0000C53B, 0x00000003, 0x0000C58C, 0x0000C57C,
- 0x0000C567, 0x00000003, 0x0000C58D, 0x0000C58A, 0x0000C534, 0x0000C540, 0x0000C58F, 0x00000003,
- 0x0000C546, 0x0000C53F, 0x0000C529, 0x0000C589, 0x00000003, 0x0000C54A, 0x0000C590, 0x0000C570,
- 0x0000C554, 0x0000C533, 0x00000003, 0x0000C57D, 0x0000C52A, 0x0000C564, 0x0000C583, 0x00000003,
- 0x0000C546, 0x0000C53B, 0x0000C58A, 0x0000C58F, 0x00000003, 0x0000C57E, 0x0000C57B, 0x0000C589,
- 0x00000003, 0x00000528, 0x0000C56D, 0x0000C549, 0x0000C52A, 0x0000C540, 0x0000C580, 0x0000C57C,
- 0x0000C57B, 0x00000003, 0x0000C57D, 0x0000C52A, 0x0000C573, 0x0000C549, 0x0000FFFE, 0x0000C593,
- 0x0000C529, 0x00000003, 0x0000C585, 0x0000C548, 0x0000C587, 0x00000003, 0x0000C556, 0x0000C590,
- 0x0000C558, 0x0000C544, 0x0000C533, 0x0000C589, 0x00000003, 0x0000C54A, 0x0000C590, 0x0000C570,
- 0x0000C554, 0x0000C534, 0x0000C57C, 0x0000C57B, 0x00000003, 0x0000C530, 0x0000C580, 0x0000C564,
- 0x0000C583, 0x0000FFFE, 0x0000C593, 0x0000C529, 0x00000003, 0x0000C531, 0x0000C52A, 0x00000530,
- 0x0000C57F, 0x00000003, 0x0000C575, 0x0000C52A, 0x0000C584, 0x0000C587, 0x00000003, 0x0000C581,
- 0x0000C52A, 0x0000C577, 0x00000003, 0x00000528, 0x00000005, 0x0000C545, 0x0000C58A, 0x0000C578,
- 0x00000555, 0x0000C583, 0x0000C58A, 0x0000C58F, 0x00000005, 0x00000003, 0x0000C565, 0x0000C529,
- 0x0000C54A, 0x0000C534, 0x0000C543, 0x0000C529, 0x00000003, 0x0000C57A, 0x0000C52E, 0x0000C573,
- 0x0000C589, 0x00000003, 0x00000011, 0x0000C52A, 0x0000C588, 0x0000C584, 0x0000C57F, 0x00000003,
- 0x0000C546, 0x0000C53F, 0x0000C529, 0x0000C589, 0x00000003, 0x0000C57A, 0x0000C578, 0x0000C57B,
- 0x00000003, 0x0000C52A, 0x0000C584, 0x0000C590, 0x0000C568, 0x0000C57F, 0x00000003, 0x0000C52A,
- 0x0000C580, 0x0000C573, 0x0000C549, 0x00000003, 0x0000C58E, 0x0000C560, 0x0000C568, 0x00000554,
- 0x0000C533, 0x00000003, 0x0000C581, 0x0000C51F, 0x00000003, 0x0000C546, 0x0000C568, 0x0000C52D,
- 0x00000003, 0x0000C58B, 0x0000C54A, 0x0000C543, 0x0000FFFE, 0x0000C593, 0x0000C529, 0x00000003,
- 0x0000C56D, 0x0000C549, 0x0000C52A, 0x0000C540, 0x0000C580, 0x0000C57B, 0x0000C529, 0x0000C589,
- 0x00000003, 0x0000C56D, 0x0000C54A, 0x0000C53F, 0x0000FFFE, 0x0000C593, 0x0000C529, 0x00000003,
- 0x0000C582, 0x0000C58F, 0x0000C54C, 0x0000C544, 0x0000C534, 0x0000C52D, 0x00000003, 0x0000C57D,
- 0x0000C58A, 0x0000C574, 0x0000C533, 0x0000C589, 0x00000003, 0x00000528, 0x0000C57D, 0x0000C52A,
- 0x0000C573, 0x0000C549, 0x0000FFFE, 0x0000C593, 0x0000C529, 0x00000003, 0x0000C566, 0x0000C57F,
- 0x00000003, 0x0000C55E, 0x0000C574, 0x0000C56F, 0x00000003, 0x0000C52C, 0x0000C590, 0x0000C54F,
- 0x0000C529, 0x0000C58A, 0x0000C540, 0x0000C57B, 0x0000C529, 0x00000003, 0x0000C57A, 0x0000C57F,
- 0x0000C52A, 0x0000C568, 0x0000C534, 0x0000C533, 0x00000003, 0x00000528, 0x0000C52A, 0x00000550,
- 0x0000C54F, 0x0000C52A, 0x0000C54F, 0x0000C51F
-};
-
-le_int32 resultGlyphCount1 = 252;
-
-le_int32 resultIndices1[] =
-{
- 0x000000FB, 0x000000FA, 0x000000F9, 0x000000F8, 0x000000F7, 0x000000F6, 0x000000F5, 0x000000F4,
- 0x000000F3, 0x000000F2, 0x000000F1, 0x000000F0, 0x000000EF, 0x000000EE, 0x000000ED, 0x000000EC,
- 0x000000EB, 0x000000EA, 0x000000E9, 0x000000E8, 0x000000E7, 0x000000E6, 0x000000E5, 0x000000E4,
- 0x000000E3, 0x000000E2, 0x000000E1, 0x000000E0, 0x000000DF, 0x000000DE, 0x000000DD, 0x000000DC,
- 0x000000DB, 0x000000DA, 0x000000D9, 0x000000D8, 0x000000D7, 0x000000D6, 0x000000D5, 0x000000D4,
- 0x000000D3, 0x000000D2, 0x000000D1, 0x000000D0, 0x000000CF, 0x000000CE, 0x000000CD, 0x000000CC,
- 0x000000CB, 0x000000CA, 0x000000C9, 0x000000C8, 0x000000C7, 0x000000C6, 0x000000C5, 0x000000C4,
- 0x000000C3, 0x000000C2, 0x000000C1, 0x000000C0, 0x000000BF, 0x000000BE, 0x000000BD, 0x000000BC,
- 0x000000BB, 0x000000BA, 0x000000B9, 0x000000B8, 0x000000B7, 0x000000B6, 0x000000B5, 0x000000B4,
- 0x000000B3, 0x000000B2, 0x000000B1, 0x000000B0, 0x000000AF, 0x000000AE, 0x000000AD, 0x000000AC,
- 0x000000AB, 0x000000AA, 0x000000A9, 0x000000A8, 0x000000A7, 0x000000A6, 0x000000A5, 0x000000A4,
- 0x000000A3, 0x000000A2, 0x000000A1, 0x000000A0, 0x0000009F, 0x0000009E, 0x0000009D, 0x0000009C,
- 0x0000009B, 0x0000009A, 0x00000099, 0x00000098, 0x00000097, 0x00000096, 0x00000095, 0x00000094,
- 0x00000093, 0x00000092, 0x00000091, 0x00000090, 0x0000008F, 0x0000008E, 0x0000008D, 0x0000008C,
- 0x0000008B, 0x0000008A, 0x00000089, 0x00000088, 0x00000087, 0x00000086, 0x00000085, 0x00000084,
- 0x00000083, 0x00000082, 0x00000081, 0x00000080, 0x0000007F, 0x0000007E, 0x0000007D, 0x0000007C,
- 0x0000007B, 0x0000007A, 0x00000079, 0x00000078, 0x00000077, 0x00000076, 0x00000075, 0x00000074,
- 0x00000073, 0x00000072, 0x00000071, 0x00000070, 0x0000006F, 0x0000006E, 0x0000006D, 0x0000006C,
- 0x0000006B, 0x0000006A, 0x00000069, 0x00000068, 0x00000067, 0x00000066, 0x00000065, 0x00000064,
- 0x00000063, 0x00000062, 0x00000061, 0x00000060, 0x0000005F, 0x0000005E, 0x0000005D, 0x0000005C,
- 0x0000005B, 0x0000005A, 0x00000059, 0x00000058, 0x00000057, 0x00000056, 0x00000055, 0x00000054,
- 0x00000053, 0x00000052, 0x00000051, 0x00000050, 0x0000004F, 0x0000004E, 0x0000004D, 0x0000004C,
- 0x0000004B, 0x0000004A, 0x00000049, 0x00000048, 0x00000047, 0x00000046, 0x00000045, 0x00000044,
- 0x00000043, 0x00000042, 0x00000041, 0x00000040, 0x0000003F, 0x0000003E, 0x0000003D, 0x0000003C,
- 0x0000003B, 0x0000003A, 0x00000039, 0x00000038, 0x00000037, 0x00000036, 0x00000035, 0x00000034,
- 0x00000033, 0x00000032, 0x00000031, 0x00000030, 0x0000002F, 0x0000002E, 0x0000002D, 0x0000002C,
- 0x0000002B, 0x0000002A, 0x00000029, 0x00000028, 0x00000027, 0x00000026, 0x00000025, 0x00000024,
- 0x00000023, 0x00000022, 0x00000021, 0x00000020, 0x0000001F, 0x0000001E, 0x0000001D, 0x0000001C,
- 0x0000001B, 0x0000001A, 0x00000019, 0x00000018, 0x00000017, 0x00000016, 0x00000015, 0x00000014,
- 0x00000013, 0x00000012, 0x00000011, 0x00000010, 0x0000000F, 0x0000000E, 0x0000000D, 0x0000000C,
- 0x0000000B, 0x0000000A, 0x00000009, 0x00000008, 0x00000007, 0x00000006, 0x00000005, 0x00000004,
- 0x00000003, 0x00000002, 0x00000001, 0x00000000
-};
-
-float resultPositions1[] =
-{
- 0.000000F, 0.000000F, 4.007813F, 0.000000F, 8.226563F, 0.000000F, 12.679688F, 0.000000F,
- 18.679688F, 0.000000F, 23.132813F, 0.000000F, 31.289063F, 0.000000F, 34.312500F, 0.000000F,
- 36.375000F, 0.000000F, 41.062500F, 0.000000F, 50.296875F, 0.000000F, 54.750000F, 0.000000F,
- 56.859375F, 0.000000F, 62.367188F, 0.000000F, 66.632813F, 0.000000F, 69.656250F, 0.000000F,
- 71.718750F, 0.000000F, 76.406250F, 0.000000F, 81.421875F, 0.000000F, 85.664063F, 0.000000F,
- 89.929688F, 0.000000F, 95.742188F, 0.000000F, 100.429688F, 0.000000F, 108.796875F, 0.000000F,
- 112.171875F, 0.000000F, 115.734375F, 0.000000F, 120.421875F, 0.000000F, 128.765625F, 0.000000F,
- 134.765625F, 0.000000F, 139.007813F, 0.000000F, 144.515625F, 0.000000F, 148.734375F, 0.000000F,
- 153.421875F, 0.000000F, 157.359375F, 0.000000F, 163.171875F, 0.000000F, 165.234375F, 0.000000F,
- 171.234375F, 0.000000F, 175.921875F, 0.000000F, 180.375000F, 0.000000F, 184.617188F, 0.000000F,
- 188.085938F, 0.000000F, 195.117188F, 0.000000F, 199.312500F, 0.000000F, 204.000000F, 0.000000F,
- 208.007813F, 0.000000F, 210.117188F, 0.000000F, 217.054688F, 0.000000F, 220.429688F, 0.000000F,
- 225.117188F, 0.000000F, 229.054688F, 0.000000F, 234.867188F, 0.000000F, 240.867188F, 0.000000F,
- 245.085938F, 0.000000F, 249.773438F, 0.000000F, 253.781250F, 0.000000F, 256.804688F, 0.000000F,
- 262.804688F, 0.000000F, 267.492188F, 0.000000F, 271.007813F, 0.000000F, 280.242188F, 0.000000F,
- 284.695313F, 0.000000F, 286.804688F, 0.000000F, 292.312500F, 0.000000F, 296.578125F, 0.000000F,
- 299.953125F, 0.000000F, 302.976563F, 0.000000F, 307.664063F, 0.000000F, 311.671875F, 0.000000F,
- 313.781250F, 0.000000F, 317.882813F, 0.000000F, 322.335938F, 0.000000F, 322.335938F, 0.000000F,
- 328.500000F, 0.000000F, 330.562500F, 0.000000F, 335.250000F, 0.000000F, 339.140625F, 0.000000F,
- 343.078125F, 0.000000F, 348.984375F, 0.000000F, 353.671875F, 0.000000F, 366.445313F, 0.000000F,
- 370.687500F, 0.000000F, 378.843750F, 0.000000F, 384.351563F, 0.000000F, 388.546875F, 0.000000F,
- 394.546875F, 0.000000F, 399.234375F, 0.000000F, 403.687500F, 0.000000F, 407.929688F, 0.000000F,
- 411.398438F, 0.000000F, 418.429688F, 0.000000F, 422.671875F, 0.000000F, 426.046875F, 0.000000F,
- 429.070313F, 0.000000F, 433.757813F, 0.000000F, 437.765625F, 0.000000F, 442.031250F, 0.000000F,
- 448.968750F, 0.000000F, 452.343750F, 0.000000F, 452.343750F, 0.000000F, 458.507813F, 0.000000F,
- 460.570313F, 0.000000F, 465.257813F, 0.000000F, 474.492188F, 0.000000F, 476.601563F, 0.000000F,
- 484.968750F, 0.000000F, 489.234375F, 0.000000F, 493.921875F, 0.000000F, 501.562500F, 0.000000F,
- 503.671875F, 0.000000F, 507.890625F, 0.000000F, 513.796875F, 0.000000F, 518.484375F, 0.000000F,
- 525.796875F, 0.000000F, 527.906250F, 0.000000F, 533.578125F, 0.000000F, 538.265625F, 0.000000F,
- 541.781250F, 0.000000F, 547.171875F, 0.000000F, 550.710938F, 0.000000F, 556.710938F, 0.000000F,
- 564.492188F, 0.000000F, 564.492188F, 0.000000F, 567.867188F, 0.000000F, 573.867188F, 0.000000F,
- 578.085938F, 0.000000F, 583.476563F, 0.000000F, 588.164063F, 0.000000F, 593.976563F, 0.000000F,
- 596.039063F, 0.000000F, 600.492188F, 0.000000F, 604.734375F, 0.000000F, 610.546875F, 0.000000F,
- 612.609375F, 0.000000F, 617.296875F, 0.000000F, 623.695313F, 0.000000F, 627.937500F, 0.000000F,
- 632.039063F, 0.000000F, 638.039063F, 0.000000F, 642.726563F, 0.000000F, 646.054688F, 0.000000F,
- 648.164063F, 0.000000F, 651.914063F, 0.000000F, 656.132813F, 0.000000F, 660.398438F, 0.000000F,
- 665.085938F, 0.000000F, 669.023438F, 0.000000F, 674.835938F, 0.000000F, 676.898438F, 0.000000F,
- 682.898438F, 0.000000F, 687.585938F, 0.000000F, 693.984375F, 0.000000F, 701.765625F, 0.000000F,
- 704.789063F, 0.000000F, 709.476563F, 0.000000F, 711.585938F, 0.000000F, 715.804688F, 0.000000F,
- 720.046875F, 0.000000F, 723.515625F, 0.000000F, 727.781250F, 0.000000F, 732.468750F, 0.000000F,
- 734.578125F, 0.000000F, 738.843750F, 0.000000F, 742.945313F, 0.000000F, 747.398438F, 0.000000F,
- 752.085938F, 0.000000F, 760.453125F, 0.000000F, 767.390625F, 0.000000F, 770.859375F, 0.000000F,
- 770.859375F, 0.000000F, 775.054688F, 0.000000F, 779.742188F, 0.000000F, 787.054688F, 0.000000F,
- 789.398438F, 0.000000F, 794.085938F, 0.000000F, 798.023438F, 0.000000F, 801.492188F, 0.000000F,
- 804.937500F, 0.000000F, 809.625000F, 0.000000F, 817.968750F, 0.000000F, 822.421875F, 0.000000F,
- 828.234375F, 0.000000F, 828.234375F, 0.000000F, 834.398438F, 0.000000F, 836.460938F, 0.000000F,
- 841.148438F, 0.000000F, 850.382813F, 0.000000F, 854.835938F, 0.000000F, 856.945313F, 0.000000F,
- 862.453125F, 0.000000F, 866.718750F, 0.000000F, 869.742188F, 0.000000F, 871.804688F, 0.000000F,
- 877.804688F, 0.000000F, 882.492188F, 0.000000F, 891.726563F, 0.000000F, 896.179688F, 0.000000F,
- 901.992188F, 0.000000F, 901.992188F, 0.000000F, 908.156250F, 0.000000F, 910.218750F, 0.000000F,
- 914.906250F, 0.000000F, 922.382813F, 0.000000F, 926.601563F, 0.000000F, 931.054688F, 0.000000F,
- 936.562500F, 0.000000F, 940.804688F, 0.000000F, 944.250000F, 0.000000F, 948.937500F, 0.000000F,
- 952.945313F, 0.000000F, 958.945313F, 0.000000F, 962.414063F, 0.000000F, 966.609375F, 0.000000F,
- 972.609375F, 0.000000F, 977.296875F, 0.000000F, 980.812500F, 0.000000F, 984.820313F, 0.000000F,
- 986.929688F, 0.000000F, 991.031250F, 0.000000F, 995.484375F, 0.000000F, 995.484375F, 0.000000F,
- 1001.648438F, 0.000000F, 1003.710938F, 0.000000F, 1008.398438F, 0.000000F, 1013.414063F, 0.000000F,
- 1017.679688F, 0.000000F, 1022.367188F, 0.000000F, 1030.312500F, 0.000000F, 1033.781250F, 0.000000F,
- 1037.882813F, 0.000000F, 1042.570313F, 0.000000F, 1051.921875F, 0.000000F, 1056.164063F, 0.000000F,
- 1062.984375F, 0.000000F, 1065.046875F, 0.000000F, 1071.046875F, 0.000000F, 1076.554688F, 0.000000F,
- 1079.578125F, 0.000000F, 1081.640625F, 0.000000F, 1086.328125F, 0.000000F, 1092.726563F, 0.000000F,
- 1096.992188F, 0.000000F, 1099.101563F, 0.000000F, 1102.570313F, 0.000000F, 1106.812500F, 0.000000F,
- 1111.007813F, 0.000000F, 1115.695313F, 0.000000F, 1119.210938F, 0.000000F, 1121.320313F, 0.000000F,
- 1121.320313F, 0.000000F, 1128.140625F, 0.000000F, 1130.250000F, 0.000000F, 1137.070313F, 0.000000F,
- 1139.414063F, 0.000000F
-};
-
-
-const char *fontVersionString2 = "Version 1.20 - October 2000";
-le_uint32 fontChecksum2 = 0xF5D9BA6D;
-
-LEUnicode inputText2[] =
-{
- 0x0623, 0x0633, 0x0627, 0x0633, 0x064B, 0x0627, 0x060C, 0x0020,
- 0x062A, 0x062A, 0x0639, 0x0627, 0x0645, 0x0644, 0x0020, 0x0627,
- 0x0644, 0x062D, 0x0648, 0x0627, 0x0633, 0x064A, 0x0628, 0x0020,
- 0x0641, 0x0642, 0x0637, 0x0020, 0x0645, 0x0639, 0x0020, 0x0627,
- 0x0644, 0x0623, 0x0631, 0x0642, 0x0627, 0x0645, 0x060C, 0x0020,
- 0x0648, 0x062A, 0x0642, 0x0648, 0x0645, 0x0020, 0x0628, 0x062A,
- 0x062E, 0x0632, 0x064A, 0x0646, 0x0020, 0x0627, 0x0644, 0x0623,
- 0x062D, 0x0631, 0x0641, 0x0020, 0x0648, 0x0627, 0x0644, 0x0645,
- 0x062D, 0x0627, 0x0631, 0x0641, 0x0020, 0x0627, 0x0644, 0x0623,
- 0x062E, 0x0631, 0x0649, 0x0020, 0x0628, 0x0639, 0x062F, 0x0020,
- 0x0623, 0x0646, 0x0020, 0x062A, 0x064F, 0x0639, 0x0637, 0x064A,
- 0x0020, 0x0631, 0x0642, 0x0645, 0x0627, 0x0020, 0x0645, 0x0639,
- 0x064A, 0x0646, 0x0627, 0x0020, 0x0644, 0x0643, 0x0644, 0x0020,
- 0x0648, 0x0627, 0x062D, 0x062F, 0x0020, 0x0645, 0x0646, 0x0647,
- 0x0627, 0x002E, 0x0020, 0x0648, 0x0642, 0x0628, 0x0644, 0x0020,
- 0x0627, 0x062E, 0x062A, 0x0631, 0x0627, 0x0639, 0x0020, 0x0022,
- 0x064A, 0x0648, 0x0646, 0x0650, 0x0643, 0x0648, 0x062F, 0x0022,
- 0x060C, 0x0020, 0x0643, 0x0627, 0x0646, 0x0020, 0x0647, 0x0646,
- 0x0627, 0x0643, 0x0020, 0x0645, 0x0626, 0x0627, 0x062A, 0x0020,
- 0x0627, 0x0644, 0x0623, 0x0646, 0x0638, 0x0645, 0x0629, 0x0020,
- 0x0644, 0x0644, 0x062A, 0x0634, 0x0641, 0x064A, 0x0631, 0x0020,
- 0x0648, 0x062A, 0x062E, 0x0635, 0x064A, 0x0635, 0x0020, 0x0647,
- 0x0630, 0x0647, 0x0020, 0x0627, 0x0644, 0x0623, 0x0631, 0x0642,
- 0x0627, 0x0645, 0x0020, 0x0644, 0x0644, 0x0645, 0x062D, 0x0627,
- 0x0631, 0x0641, 0x060C, 0x0020, 0x0648, 0x0644, 0x0645, 0x0020,
- 0x064A, 0x0648, 0x062C, 0x062F, 0x0020, 0x0646, 0x0638, 0x0627,
- 0x0645, 0x0020, 0x062A, 0x0634, 0x0641, 0x064A, 0x0631, 0x0020,
- 0x0648, 0x0627, 0x062D, 0x062F, 0x0020, 0x064A, 0x062D, 0x062A,
- 0x0648, 0x064A, 0x0020, 0x0639, 0x0644, 0x0649, 0x0020, 0x062C,
- 0x0645, 0x064A, 0x0639, 0x0020, 0x0627, 0x0644, 0x0645, 0x062D,
- 0x0627, 0x0631, 0x0641, 0x0020, 0x0627, 0x0644, 0x0636, 0x0631,
- 0x0648, 0x0631, 0x064A, 0x0629
-};
-
-LEGlyphID resultGlyphs2[] =
-{
- 0x00000872, 0x000008D1, 0x000003F9, 0x0000040B, 0x0000088C, 0x0000089E, 0x000008BD, 0x000003EF,
- 0x00000003, 0x00000404, 0x000003F9, 0x0000086C, 0x00000882, 0x000008C2, 0x000008BD, 0x000003EF,
- 0x00000003, 0x000008A8, 0x000008D2, 0x000008C2, 0x0000087D, 0x00000003, 0x000008CE, 0x000008BE,
- 0x000008A9, 0x00000003, 0x0000040D, 0x000008CC, 0x00000876, 0x00000882, 0x000008D1, 0x00000003,
- 0x00000888, 0x00000881, 0x000003EF, 0x0000040B, 0x00000003, 0x0000088C, 0x000008D2, 0x000008B2,
- 0x00000896, 0x00000875, 0x00000003, 0x00000408, 0x0000086C, 0x000008A6, 0x000008C5, 0x00000003,
- 0x00000888, 0x0000087D, 0x000008CC, 0x000008D1, 0x00000003, 0x000008C0, 0x000008BD, 0x0000040B,
- 0x00000003, 0x000003E6, 0x00000404, 0x000003F9, 0x0000086C, 0x00000882, 0x000008C2, 0x000008BE,
- 0x000008BD, 0x00000003, 0x00000408, 0x0000086C, 0x000008B5, 0x000003F9, 0x0000FFFF, 0x000008D5,
- 0x000003EF, 0x00000003, 0x0000040A, 0x0000088A, 0x000008C9, 0x00000003, 0x00000898, 0x000008D2,
- 0x0000089A, 0x00000886, 0x00000875, 0x0000040B, 0x00000003, 0x0000088C, 0x000008D2, 0x000008B2,
- 0x00000896, 0x00000876, 0x000008BE, 0x000008BD, 0x00000003, 0x00000872, 0x000008C2, 0x000008A6,
- 0x000008C5, 0x0000FFFF, 0x000008D5, 0x000003EF, 0x00000003, 0x000003F2, 0x0000086C, 0x0000086A,
- 0x000008C1, 0x00000003, 0x00000406, 0x0000086C, 0x000008C6, 0x000008C9, 0x00000003, 0x00000409,
- 0x0000086C, 0x000008B9, 0x00000003, 0x000003E6, 0x00000005, 0x000003F7, 0x000008CC, 0x000008BA,
- 0x00000413, 0x000008C5, 0x000008CC, 0x000008D1, 0x00000005, 0x00000003, 0x00000401, 0x000003EF,
- 0x0000088C, 0x00000876, 0x00000885, 0x000003EF, 0x00000003, 0x000008BC, 0x00000870, 0x000008B5,
- 0x0000040B, 0x00000003, 0x00000011, 0x0000086C, 0x000008CA, 0x000008C6, 0x000008C1, 0x00000003,
- 0x00000888, 0x00000881, 0x000003EF, 0x0000040B, 0x00000003, 0x000008BC, 0x000008BA, 0x000008BD,
- 0x00000003, 0x0000086C, 0x000008C6, 0x000008D2, 0x000008AA, 0x000008C1, 0x00000003, 0x0000086C,
- 0x000008C2, 0x000008B5, 0x000003F9, 0x00000003, 0x000008D0, 0x000008A2, 0x000008AA, 0x00000412,
- 0x00000875, 0x00000003, 0x00000409, 0x000003EB, 0x00000003, 0x00000888, 0x000008AA, 0x0000086F,
- 0x00000003, 0x0000040C, 0x0000088C, 0x00000885, 0x0000FFFF, 0x000008D5, 0x000003EF, 0x00000003,
- 0x00000404, 0x000003F9, 0x0000086C, 0x00000882, 0x000008C2, 0x000008BD, 0x000003EF, 0x0000040B,
- 0x00000003, 0x00000404, 0x0000088C, 0x00000881, 0x0000FFFF, 0x000008D5, 0x000003EF, 0x00000003,
- 0x000008C4, 0x000008D1, 0x0000088E, 0x00000886, 0x00000876, 0x0000086F, 0x00000003, 0x00000408,
- 0x000008CC, 0x000008B6, 0x00000875, 0x0000040B, 0x00000003, 0x000003E6, 0x00000408, 0x0000086C,
- 0x000008B5, 0x000003F9, 0x0000FFFF, 0x000008D5, 0x000003EF, 0x00000003, 0x000008A8, 0x000008C1,
- 0x00000003, 0x000008A0, 0x000008B6, 0x000008B1, 0x00000003, 0x0000086E, 0x000008D2, 0x00000891,
- 0x000003EF, 0x000008CC, 0x00000882, 0x000008BD, 0x000003EF, 0x00000003, 0x000008BC, 0x000008C1,
- 0x0000086C, 0x000008AA, 0x00000876, 0x00000875, 0x00000003, 0x000003E6, 0x0000086C, 0x0000040E,
- 0x00000891, 0x0000086C, 0x00000891, 0x000003EB
-};
-
-le_int32 resultGlyphCount2 = 252;
-
-le_int32 resultIndices2[] =
-{
- 0x000000FB, 0x000000FA, 0x000000F9, 0x000000F8, 0x000000F7, 0x000000F6, 0x000000F5, 0x000000F4,
- 0x000000F3, 0x000000F2, 0x000000F1, 0x000000F0, 0x000000EF, 0x000000EE, 0x000000ED, 0x000000EC,
- 0x000000EB, 0x000000EA, 0x000000E9, 0x000000E8, 0x000000E7, 0x000000E6, 0x000000E5, 0x000000E4,
- 0x000000E3, 0x000000E2, 0x000000E1, 0x000000E0, 0x000000DF, 0x000000DE, 0x000000DD, 0x000000DC,
- 0x000000DB, 0x000000DA, 0x000000D9, 0x000000D8, 0x000000D7, 0x000000D6, 0x000000D5, 0x000000D4,
- 0x000000D3, 0x000000D2, 0x000000D1, 0x000000D0, 0x000000CF, 0x000000CE, 0x000000CD, 0x000000CC,
- 0x000000CB, 0x000000CA, 0x000000C9, 0x000000C8, 0x000000C7, 0x000000C6, 0x000000C5, 0x000000C4,
- 0x000000C3, 0x000000C2, 0x000000C1, 0x000000C0, 0x000000BF, 0x000000BE, 0x000000BD, 0x000000BC,
- 0x000000BB, 0x000000BA, 0x000000B9, 0x000000B8, 0x000000B7, 0x000000B6, 0x000000B5, 0x000000B4,
- 0x000000B3, 0x000000B2, 0x000000B1, 0x000000B0, 0x000000AF, 0x000000AE, 0x000000AD, 0x000000AC,
- 0x000000AB, 0x000000AA, 0x000000A9, 0x000000A8, 0x000000A7, 0x000000A6, 0x000000A5, 0x000000A4,
- 0x000000A3, 0x000000A2, 0x000000A1, 0x000000A0, 0x0000009F, 0x0000009E, 0x0000009D, 0x0000009C,
- 0x0000009B, 0x0000009A, 0x00000099, 0x00000098, 0x00000097, 0x00000096, 0x00000095, 0x00000094,
- 0x00000093, 0x00000092, 0x00000091, 0x00000090, 0x0000008F, 0x0000008E, 0x0000008D, 0x0000008C,
- 0x0000008B, 0x0000008A, 0x00000089, 0x00000088, 0x00000087, 0x00000086, 0x00000085, 0x00000084,
- 0x00000083, 0x00000082, 0x00000081, 0x00000080, 0x0000007F, 0x0000007E, 0x0000007D, 0x0000007C,
- 0x0000007B, 0x0000007A, 0x00000079, 0x00000078, 0x00000077, 0x00000076, 0x00000075, 0x00000074,
- 0x00000073, 0x00000072, 0x00000071, 0x00000070, 0x0000006F, 0x0000006E, 0x0000006D, 0x0000006C,
- 0x0000006B, 0x0000006A, 0x00000069, 0x00000068, 0x00000067, 0x00000066, 0x00000065, 0x00000064,
- 0x00000063, 0x00000062, 0x00000061, 0x00000060, 0x0000005F, 0x0000005E, 0x0000005D, 0x0000005C,
- 0x0000005B, 0x0000005A, 0x00000059, 0x00000058, 0x00000057, 0x00000056, 0x00000055, 0x00000054,
- 0x00000053, 0x00000052, 0x00000051, 0x00000050, 0x0000004F, 0x0000004E, 0x0000004D, 0x0000004C,
- 0x0000004B, 0x0000004A, 0x00000049, 0x00000048, 0x00000047, 0x00000046, 0x00000045, 0x00000044,
- 0x00000043, 0x00000042, 0x00000041, 0x00000040, 0x0000003F, 0x0000003E, 0x0000003D, 0x0000003C,
- 0x0000003B, 0x0000003A, 0x00000039, 0x00000038, 0x00000037, 0x00000036, 0x00000035, 0x00000034,
- 0x00000033, 0x00000032, 0x00000031, 0x00000030, 0x0000002F, 0x0000002E, 0x0000002D, 0x0000002C,
- 0x0000002B, 0x0000002A, 0x00000029, 0x00000028, 0x00000027, 0x00000026, 0x00000025, 0x00000024,
- 0x00000023, 0x00000022, 0x00000021, 0x00000020, 0x0000001F, 0x0000001E, 0x0000001D, 0x0000001C,
- 0x0000001B, 0x0000001A, 0x00000019, 0x00000018, 0x00000017, 0x00000016, 0x00000015, 0x00000014,
- 0x00000013, 0x00000012, 0x00000011, 0x00000010, 0x0000000F, 0x0000000E, 0x0000000D, 0x0000000C,
- 0x0000000B, 0x0000000A, 0x00000009, 0x00000008, 0x00000007, 0x00000006, 0x00000005, 0x00000004,
- 0x00000003, 0x00000002, 0x00000001, 0x00000000
-};
-
-float resultPositions2[] =
-{
- 0.000000F, 0.000000F, 6.316406F, 0.000000F, 10.382813F, 0.000000F, 15.492188F, 0.000000F,
- 21.035156F, 0.000000F, 27.058594F, 0.000000F, 39.527344F, 0.000000F, 43.792969F, 0.000000F,
- 47.408203F, 0.000000F, 51.205078F, 0.000000F, 66.216797F, 0.000000F, 71.326172F, 0.000000F,
- 74.695313F, 0.000000F, 83.367188F, 0.000000F, 90.826172F, 0.000000F, 95.091797F, 0.000000F,
- 98.707031F, 0.000000F, 102.503906F, 0.000000F, 109.962891F, 0.000000F, 114.949219F, 0.000000F,
- 122.408203F, 0.000000F, 130.687500F, 0.000000F, 134.484375F, 0.000000F, 145.787109F, 0.000000F,
- 150.773438F, 0.000000F, 156.884766F, 0.000000F, 160.681641F, 0.000000F, 172.277344F, 0.000000F,
- 177.919922F, 0.000000F, 182.906250F, 0.000000F, 191.578125F, 0.000000F, 195.644531F, 0.000000F,
- 199.441406F, 0.000000F, 206.507813F, 0.000000F, 214.787109F, 0.000000F, 218.402344F, 0.000000F,
- 223.945313F, 0.000000F, 227.742188F, 0.000000F, 233.765625F, 0.000000F, 238.751953F, 0.000000F,
- 245.185547F, 0.000000F, 257.982422F, 0.000000F, 262.048828F, 0.000000F, 265.845703F, 0.000000F,
- 272.654297F, 0.000000F, 276.023438F, 0.000000F, 285.240234F, 0.000000F, 289.306641F, 0.000000F,
- 293.103516F, 0.000000F, 300.169922F, 0.000000F, 308.449219F, 0.000000F, 314.091797F, 0.000000F,
- 318.158203F, 0.000000F, 321.955078F, 0.000000F, 329.572266F, 0.000000F, 333.837891F, 0.000000F,
- 339.380859F, 0.000000F, 343.177734F, 0.000000F, 346.974609F, 0.000000F, 361.986328F, 0.000000F,
- 367.095703F, 0.000000F, 370.464844F, 0.000000F, 379.136719F, 0.000000F, 386.595703F, 0.000000F,
- 391.582031F, 0.000000F, 395.847656F, 0.000000F, 399.644531F, 0.000000F, 406.453125F, 0.000000F,
- 409.822266F, 0.000000F, 415.523438F, 0.000000F, 420.632813F, 0.000000F, 420.632813F, 0.000000F,
- 427.441406F, 0.000000F, 431.056641F, 0.000000F, 434.853516F, 0.000000F, 441.357422F, 0.000000F,
- 448.423828F, 0.000000F, 455.912109F, 0.000000F, 459.708984F, 0.000000F, 479.255859F, 0.000000F,
- 484.242188F, 0.000000F, 496.710938F, 0.000000F, 505.382813F, 0.000000F, 509.449219F, 0.000000F,
- 514.992188F, 0.000000F, 518.789063F, 0.000000F, 524.812500F, 0.000000F, 529.798828F, 0.000000F,
- 536.232422F, 0.000000F, 549.029297F, 0.000000F, 554.015625F, 0.000000F, 559.001953F, 0.000000F,
- 563.267578F, 0.000000F, 567.064453F, 0.000000F, 573.380859F, 0.000000F, 580.839844F, 0.000000F,
- 590.056641F, 0.000000F, 594.123047F, 0.000000F, 594.123047F, 0.000000F, 600.931641F, 0.000000F,
- 604.546875F, 0.000000F, 608.343750F, 0.000000F, 620.636719F, 0.000000F, 624.005859F, 0.000000F,
- 628.992188F, 0.000000F, 635.830078F, 0.000000F, 639.626953F, 0.000000F, 653.361328F, 0.000000F,
- 656.730469F, 0.000000F, 661.716797F, 0.000000F, 669.205078F, 0.000000F, 673.001953F, 0.000000F,
- 683.777344F, 0.000000F, 687.146484F, 0.000000F, 692.660156F, 0.000000F, 696.457031F, 0.000000F,
- 700.253906F, 0.000000F, 704.736328F, 0.000000F, 711.105469F, 0.000000F, 716.748047F, 0.000000F,
- 722.994141F, 0.000000F, 722.994141F, 0.000000F, 727.060547F, 0.000000F, 732.703125F, 0.000000F,
- 736.769531F, 0.000000F, 741.251953F, 0.000000F, 745.048828F, 0.000000F, 752.507813F, 0.000000F,
- 756.123047F, 0.000000F, 762.146484F, 0.000000F, 767.132813F, 0.000000F, 775.412109F, 0.000000F,
- 779.027344F, 0.000000F, 782.824219F, 0.000000F, 794.203125F, 0.000000F, 799.189453F, 0.000000F,
- 804.890625F, 0.000000F, 810.433594F, 0.000000F, 814.230469F, 0.000000F, 818.027344F, 0.000000F,
- 821.396484F, 0.000000F, 828.128906F, 0.000000F, 833.115234F, 0.000000F, 839.953125F, 0.000000F,
- 843.750000F, 0.000000F, 850.816406F, 0.000000F, 859.095703F, 0.000000F, 862.710938F, 0.000000F,
- 868.253906F, 0.000000F, 872.050781F, 0.000000F, 883.429688F, 0.000000F, 889.675781F, 0.000000F,
- 893.941406F, 0.000000F, 897.738281F, 0.000000F, 901.107422F, 0.000000F, 906.093750F, 0.000000F,
- 911.080078F, 0.000000F, 917.800781F, 0.000000F, 924.638672F, 0.000000F, 928.435547F, 0.000000F,
- 931.804688F, 0.000000F, 939.263672F, 0.000000F, 944.964844F, 0.000000F, 950.074219F, 0.000000F,
- 953.871094F, 0.000000F, 965.173828F, 0.000000F, 974.390625F, 0.000000F, 981.111328F, 0.000000F,
- 981.111328F, 0.000000F, 985.177734F, 0.000000F, 988.974609F, 0.000000F, 999.750000F, 0.000000F,
- 1003.365234F, 0.000000F, 1007.162109F, 0.000000F, 1014.228516F, 0.000000F, 1020.949219F, 0.000000F,
- 1025.015625F, 0.000000F, 1028.812500F, 0.000000F, 1040.408203F, 0.000000F, 1046.431641F, 0.000000F,
- 1054.710938F, 0.000000F, 1054.710938F, 0.000000F, 1061.519531F, 0.000000F, 1065.134766F, 0.000000F,
- 1068.931641F, 0.000000F, 1083.943359F, 0.000000F, 1089.052734F, 0.000000F, 1092.421875F, 0.000000F,
- 1101.093750F, 0.000000F, 1108.552734F, 0.000000F, 1112.818359F, 0.000000F, 1116.433594F, 0.000000F,
- 1121.976563F, 0.000000F, 1125.773438F, 0.000000F, 1140.785156F, 0.000000F, 1146.808594F, 0.000000F,
- 1155.087891F, 0.000000F, 1155.087891F, 0.000000F, 1161.896484F, 0.000000F, 1165.511719F, 0.000000F,
- 1169.308594F, 0.000000F, 1180.541016F, 0.000000F, 1184.607422F, 0.000000F, 1190.630859F, 0.000000F,
- 1199.302734F, 0.000000F, 1204.289063F, 0.000000F, 1208.355469F, 0.000000F, 1212.152344F, 0.000000F,
- 1218.960938F, 0.000000F, 1224.603516F, 0.000000F, 1231.037109F, 0.000000F, 1235.103516F, 0.000000F,
- 1240.646484F, 0.000000F, 1244.443359F, 0.000000F, 1248.240234F, 0.000000F, 1255.048828F, 0.000000F,
- 1258.417969F, 0.000000F, 1264.119141F, 0.000000F, 1269.228516F, 0.000000F, 1269.228516F, 0.000000F,
- 1276.037109F, 0.000000F, 1279.652344F, 0.000000F, 1283.449219F, 0.000000F, 1290.908203F, 0.000000F,
- 1297.746094F, 0.000000F, 1301.542969F, 0.000000F, 1311.427734F, 0.000000F, 1317.861328F, 0.000000F,
- 1323.562500F, 0.000000F, 1327.359375F, 0.000000F, 1341.492188F, 0.000000F, 1346.478516F, 0.000000F,
- 1357.904297F, 0.000000F, 1361.519531F, 0.000000F, 1367.162109F, 0.000000F, 1375.833984F, 0.000000F,
- 1380.099609F, 0.000000F, 1383.714844F, 0.000000F, 1387.511719F, 0.000000F, 1398.890625F, 0.000000F,
- 1405.728516F, 0.000000F, 1409.097656F, 0.000000F, 1415.818359F, 0.000000F, 1420.804688F, 0.000000F,
- 1424.871094F, 0.000000F, 1428.667969F, 0.000000F, 1432.464844F, 0.000000F, 1435.833984F, 0.000000F,
- 1435.833984F, 0.000000F, 1447.259766F, 0.000000F, 1450.628906F, 0.000000F, 1462.054688F, 0.000000F,
- 1465.669922F, 0.000000F
-};
-
-
-const char *fontVersionString3 = "Version 2.1 - July 1995";
-le_uint32 fontChecksum3 = 0x49B67200;
-
-LEUnicode inputText3[] =
-{
- 0x0E1A, 0x0E17, 0x0E17, 0x0E35, 0x0E48, 0x0E51, 0x0E1E, 0x0E32,
- 0x0E22, 0x0E38, 0x0E44, 0x0E0B, 0x0E42, 0x0E04, 0x0E25, 0x0E19,
- 0x0E42, 0x0E14, 0x0E42, 0x0E23, 0x0E18, 0x0E35, 0x0E2D, 0x0E32,
- 0x0E28, 0x0E31, 0x0E22, 0x0E2D, 0x0E22, 0x0E39, 0x0E48, 0x0E17,
- 0x0E48, 0x0E32, 0x0E21, 0x0E01, 0x0E25, 0x0E32, 0x0E07, 0x0E17,
- 0x0E38, 0x0E48, 0x0E07, 0x0E43, 0x0E2B, 0x0E0D, 0x0E48, 0x0E43,
- 0x0E19, 0x0E41, 0x0E04, 0x0E19, 0x0E0B, 0x0E31, 0x0E2A, 0x0E01,
- 0x0E31, 0x0E1A, 0x0E25, 0x0E38, 0x0E07, 0x0E40, 0x0E2E, 0x0E19,
- 0x0E23, 0x0E35, 0x0E0A, 0x0E32, 0x0E27, 0x0E44, 0x0E23, 0x0E48,
- 0x0E41, 0x0E25, 0x0E30, 0x0E1B, 0x0E49, 0x0E32, 0x0E40, 0x0E2D,
- 0x0E47, 0x0E21, 0x0E20, 0x0E23, 0x0E23, 0x0E22, 0x0E32, 0x0E0A,
- 0x0E32, 0x0E27, 0x0E44, 0x0E23, 0x0E48, 0x0E1A, 0x0E49, 0x0E32,
- 0x0E19, 0x0E02, 0x0E2D, 0x0E07, 0x0E1E, 0x0E27, 0x0E01, 0x0E40,
- 0x0E02, 0x0E32, 0x0E2B, 0x0E25, 0x0E31, 0x0E07, 0x0E40, 0x0E25,
- 0x0E47, 0x0E01, 0x0E40, 0x0E1E, 0x0E23, 0x0E32, 0x0E30, 0x0E44,
- 0x0E21, 0x0E49, 0x0E2A, 0x0E23, 0x0E49, 0x0E32, 0x0E07, 0x0E1A,
- 0x0E49, 0x0E32, 0x0E19, 0x0E15, 0x0E49, 0x0E2D, 0x0E07, 0x0E02,
- 0x0E19, 0x0E21, 0x0E32, 0x0E14, 0x0E49, 0x0E27, 0x0E22, 0x0E40,
- 0x0E01, 0x0E27, 0x0E35, 0x0E22, 0x0E19, 0x0E40, 0x0E1B, 0x0E47,
- 0x0E19, 0x0E23, 0x0E30, 0x0E22, 0x0E30, 0x0E17, 0x0E32, 0x0E07,
- 0x0E2B, 0x0E25, 0x0E32, 0x0E22, 0x0E44, 0x0E21, 0x0E25, 0x0E4C
-};
-
-LEGlyphID resultGlyphs3[] =
-{
- 0x000000F3, 0x000000F0, 0x000000F0, 0x0000010E, 0x0000011D, 0x00000126, 0x000000F7, 0x0000010B,
- 0x000000FB, 0x00000111, 0x00000119, 0x000000E4, 0x00000117, 0x000000DD, 0x000000FE, 0x000000F2,
- 0x00000117, 0x000000ED, 0x00000117, 0x000000FC, 0x000000F1, 0x0000010E, 0x00000106, 0x0000010B,
- 0x00000101, 0x0000010A, 0x000000FB, 0x00000106, 0x000000FB, 0x00000112, 0x0000013B, 0x000000F0,
- 0x0000013B, 0x0000010B, 0x000000FA, 0x000000DA, 0x000000FE, 0x0000010B, 0x000000E0, 0x000000F0,
- 0x00000111, 0x0000013B, 0x000000E0, 0x00000118, 0x00000104, 0x000000E6, 0x0000013B, 0x00000118,
- 0x000000F2, 0x00000116, 0x000000DD, 0x000000F2, 0x000000E4, 0x0000010A, 0x00000103, 0x000000DA,
- 0x0000010A, 0x000000F3, 0x000000FE, 0x00000111, 0x000000E0, 0x00000115, 0x00000107, 0x000000F2,
- 0x000000FC, 0x0000010E, 0x000000E3, 0x0000010B, 0x00000100, 0x00000119, 0x000000FC, 0x0000013B,
- 0x00000116, 0x000000FE, 0x00000109, 0x000000F4, 0x00000137, 0x0000010B, 0x00000115, 0x00000106,
- 0x0000011C, 0x000000FA, 0x000000F9, 0x000000FC, 0x000000FC, 0x000000FB, 0x0000010B, 0x000000E3,
- 0x0000010B, 0x00000100, 0x00000119, 0x000000FC, 0x0000013B, 0x000000F3, 0x0000013C, 0x0000010B,
- 0x000000F2, 0x000000DB, 0x00000106, 0x000000E0, 0x000000F7, 0x00000100, 0x000000DA, 0x00000115,
- 0x000000DB, 0x0000010B, 0x00000104, 0x000000FE, 0x0000010A, 0x000000E0, 0x00000115, 0x000000FE,
- 0x0000011C, 0x000000DA, 0x00000115, 0x000000F7, 0x000000FC, 0x0000010B, 0x00000109, 0x00000119,
- 0x000000FA, 0x0000013C, 0x00000103, 0x000000FC, 0x0000013C, 0x0000010B, 0x000000E0, 0x000000F3,
- 0x0000013C, 0x0000010B, 0x000000F2, 0x000000EE, 0x0000013C, 0x00000106, 0x000000E0, 0x000000DB,
- 0x000000F2, 0x000000FA, 0x0000010B, 0x000000ED, 0x0000013C, 0x00000100, 0x000000FB, 0x00000115,
- 0x000000DA, 0x00000100, 0x0000010E, 0x000000FB, 0x000000F2, 0x00000115, 0x000000F4, 0x00000143,
- 0x000000F2, 0x000000FC, 0x00000109, 0x000000FB, 0x00000109, 0x000000F0, 0x0000010B, 0x000000E0,
- 0x00000104, 0x000000FE, 0x0000010B, 0x000000FB, 0x00000119, 0x000000FA, 0x000000FE, 0x0000013F
-};
-
-le_int32 resultGlyphCount3 = 168;
-
-le_int32 resultIndices3[] =
-{
- 0x00000000, 0x00000001, 0x00000002, 0x00000003, 0x00000004, 0x00000005, 0x00000006, 0x00000007,
- 0x00000008, 0x00000009, 0x0000000A, 0x0000000B, 0x0000000C, 0x0000000D, 0x0000000E, 0x0000000F,
- 0x00000010, 0x00000011, 0x00000012, 0x00000013, 0x00000014, 0x00000015, 0x00000016, 0x00000017,
- 0x00000018, 0x00000019, 0x0000001A, 0x0000001B, 0x0000001C, 0x0000001D, 0x0000001E, 0x0000001F,
- 0x00000020, 0x00000021, 0x00000022, 0x00000023, 0x00000024, 0x00000025, 0x00000026, 0x00000027,
- 0x00000028, 0x00000029, 0x0000002A, 0x0000002B, 0x0000002C, 0x0000002D, 0x0000002E, 0x0000002F,
- 0x00000030, 0x00000031, 0x00000032, 0x00000033, 0x00000034, 0x00000035, 0x00000036, 0x00000037,
- 0x00000038, 0x00000039, 0x0000003A, 0x0000003B, 0x0000003C, 0x0000003D, 0x0000003E, 0x0000003F,
- 0x00000040, 0x00000041, 0x00000042, 0x00000043, 0x00000044, 0x00000045, 0x00000046, 0x00000047,
- 0x00000048, 0x00000049, 0x0000004A, 0x0000004B, 0x0000004C, 0x0000004D, 0x0000004E, 0x0000004F,
- 0x00000050, 0x00000051, 0x00000052, 0x00000053, 0x00000054, 0x00000055, 0x00000056, 0x00000057,
- 0x00000058, 0x00000059, 0x0000005A, 0x0000005B, 0x0000005C, 0x0000005D, 0x0000005E, 0x0000005F,
- 0x00000060, 0x00000061, 0x00000062, 0x00000063, 0x00000064, 0x00000065, 0x00000066, 0x00000067,
- 0x00000068, 0x00000069, 0x0000006A, 0x0000006B, 0x0000006C, 0x0000006D, 0x0000006E, 0x0000006F,
- 0x00000070, 0x00000071, 0x00000072, 0x00000073, 0x00000074, 0x00000075, 0x00000076, 0x00000077,
- 0x00000078, 0x00000079, 0x0000007A, 0x0000007B, 0x0000007C, 0x0000007D, 0x0000007E, 0x0000007F,
- 0x00000080, 0x00000081, 0x00000082, 0x00000083, 0x00000084, 0x00000085, 0x00000086, 0x00000087,
- 0x00000088, 0x00000089, 0x0000008A, 0x0000008B, 0x0000008C, 0x0000008D, 0x0000008E, 0x0000008F,
- 0x00000090, 0x00000091, 0x00000092, 0x00000093, 0x00000094, 0x00000095, 0x00000096, 0x00000097,
- 0x00000098, 0x00000099, 0x0000009A, 0x0000009B, 0x0000009C, 0x0000009D, 0x0000009E, 0x0000009F,
- 0x000000A0, 0x000000A1, 0x000000A2, 0x000000A3, 0x000000A4, 0x000000A5, 0x000000A6, 0x000000A7
-};
-
-float resultPositions3[] =
-{
- 0.000000F, 0.000000F, 5.399414F, 0.000000F, 10.798828F, 0.000000F, 16.198242F, 0.000000F,
- 16.198242F, 0.000000F, 16.198242F, 0.000000F, 21.046875F, 0.000000F, 26.616211F, 0.000000F,
- 30.035156F, 0.000000F, 34.151367F, 0.000000F, 34.151367F, 0.000000F, 38.279297F, 0.000000F,
- 43.558594F, 0.000000F, 47.663086F, 0.000000F, 52.438477F, 0.000000F, 57.178711F, 0.000000F,
- 62.698242F, 0.000000F, 66.802734F, 0.000000F, 71.601563F, 0.000000F, 75.706055F, 0.000000F,
- 79.810547F, 0.000000F, 84.369141F, 0.000000F, 84.369141F, 0.000000F, 89.097656F, 0.000000F,
- 92.516602F, 0.000000F, 97.195313F, 0.000000F, 97.195313F, 0.000000F, 101.311523F, 0.000000F,
- 106.040039F, 0.000000F, 110.156250F, 0.000000F, 110.156250F, 0.000000F, 110.156250F, 0.000000F,
- 115.555664F, 0.000000F, 115.555664F, 0.000000F, 118.974609F, 0.000000F, 124.013672F, 0.000000F,
- 128.765625F, 0.000000F, 133.505859F, 0.000000F, 136.924805F, 0.000000F, 140.704102F, 0.000000F,
- 146.103516F, 0.000000F, 146.103516F, 0.000000F, 146.103516F, 0.000000F, 149.882813F, 0.000000F,
- 153.553711F, 0.000000F, 159.158203F, 0.000000F, 165.421875F, 0.000000F, 165.421875F, 0.000000F,
- 169.092773F, 0.000000F, 174.612305F, 0.000000F, 179.135742F, 0.000000F, 183.911133F, 0.000000F,
- 189.430664F, 0.000000F, 194.709961F, 0.000000F, 194.709961F, 0.000000F, 199.989258F, 0.000000F,
- 204.741211F, 0.000000F, 204.741211F, 0.000000F, 210.140625F, 0.000000F, 214.880859F, 0.000000F,
- 214.880859F, 0.000000F, 218.660156F, 0.000000F, 220.675781F, 0.000000F, 225.128906F, 0.000000F,
- 230.648438F, 0.000000F, 234.752930F, 0.000000F, 234.752930F, 0.000000F, 239.613281F, 0.000000F,
- 243.032227F, 0.000000F, 247.280273F, 0.000000F, 251.408203F, 0.000000F, 255.512695F, 0.000000F,
- 255.512695F, 0.000000F, 260.036133F, 0.000000F, 264.776367F, 0.000000F, 269.071289F, 0.000000F,
- 274.470703F, 0.000000F, 274.470703F, 0.000000F, 277.889648F, 0.000000F, 279.905273F, 0.000000F,
- 284.633789F, 0.000000F, 284.633789F, 0.000000F, 289.672852F, 0.000000F, 294.641602F, 0.000000F,
- 298.746094F, 0.000000F, 302.850586F, 0.000000F, 306.966797F, 0.000000F, 310.385742F, 0.000000F,
- 315.246094F, 0.000000F, 318.665039F, 0.000000F, 322.913086F, 0.000000F, 327.041016F, 0.000000F,
- 331.145508F, 0.000000F, 331.145508F, 0.000000F, 336.544922F, 0.000000F, 336.544922F, 0.000000F,
- 339.963867F, 0.000000F, 345.483398F, 0.000000F, 350.258789F, 0.000000F, 354.987305F, 0.000000F,
- 358.766602F, 0.000000F, 364.335938F, 0.000000F, 368.583984F, 0.000000F, 373.335938F, 0.000000F,
- 375.351563F, 0.000000F, 380.126953F, 0.000000F, 383.545898F, 0.000000F, 389.150391F, 0.000000F,
- 393.890625F, 0.000000F, 393.890625F, 0.000000F, 397.669922F, 0.000000F, 399.685547F, 0.000000F,
- 404.425781F, 0.000000F, 404.425781F, 0.000000F, 409.177734F, 0.000000F, 411.193359F, 0.000000F,
- 416.762695F, 0.000000F, 420.867188F, 0.000000F, 424.286133F, 0.000000F, 428.581055F, 0.000000F,
- 432.708984F, 0.000000F, 437.748047F, 0.000000F, 437.748047F, 0.000000F, 443.027344F, 0.000000F,
- 447.131836F, 0.000000F, 447.131836F, 0.000000F, 450.550781F, 0.000000F, 454.330078F, 0.000000F,
- 459.729492F, 0.000000F, 459.729492F, 0.000000F, 463.148438F, 0.000000F, 468.667969F, 0.000000F,
- 473.478516F, 0.000000F, 473.478516F, 0.000000F, 478.207031F, 0.000000F, 481.986328F, 0.000000F,
- 486.761719F, 0.000000F, 492.281250F, 0.000000F, 497.320313F, 0.000000F, 500.739258F, 0.000000F,
- 505.538086F, 0.000000F, 505.538086F, 0.000000F, 509.786133F, 0.000000F, 513.902344F, 0.000000F,
- 515.917969F, 0.000000F, 520.669922F, 0.000000F, 524.917969F, 0.000000F, 524.917969F, 0.000000F,
- 529.034180F, 0.000000F, 534.553711F, 0.000000F, 536.569336F, 0.000000F, 541.968750F, 0.000000F,
- 541.968750F, 0.000000F, 547.488281F, 0.000000F, 551.592773F, 0.000000F, 555.887695F, 0.000000F,
- 560.003906F, 0.000000F, 564.298828F, 0.000000F, 569.698242F, 0.000000F, 573.117188F, 0.000000F,
- 576.896484F, 0.000000F, 582.500977F, 0.000000F, 587.241211F, 0.000000F, 590.660156F, 0.000000F,
- 594.776367F, 0.000000F, 598.904297F, 0.000000F, 603.943359F, 0.000000F, 608.683594F, 0.000000F,
- 608.683594F, 0.000000F
-};
-
-
-TestInput testInputs[] =
-{
- {"raghu.ttf", fontVersionString0, fontChecksum0, inputText0, 136, devaScriptCode, FALSE},
- {"CODE2000.TTF", fontVersionString1, fontChecksum1, inputText1, 252, arabScriptCode, TRUE},
- {"LucidaSansRegular.ttf", fontVersionString2, fontChecksum2, inputText2, 252, arabScriptCode, TRUE},
- {"angsd___.ttf", fontVersionString3, fontChecksum3, inputText3, 168, thaiScriptCode, FALSE},
-};
-
-le_int32 testCount = ARRAY_LENGTH(testInputs);
-
-TestResult testResults[] =
-{
- {resultGlyphCount0, resultGlyphs0, resultIndices0, resultPositions0},
- {resultGlyphCount1, resultGlyphs1, resultIndices1, resultPositions1},
- {resultGlyphCount2, resultGlyphs2, resultIndices2, resultPositions2},
- {resultGlyphCount3, resultGlyphs3, resultIndices3, resultPositions3},
-};
-
+/*
+ *******************************************************************************
+ *
+ * Copyright (C) 1999-2005, International Business Machines
+ * Corporation and others. All Rights Reserved.
+ *
+ * WARNING: THIS FILE IS MACHINE GENERATED. DO NOT HAND EDIT IT
+ * UNLESS YOU REALLY KNOW WHAT YOU'RE DOING.
+ *
+ *******************************************************************************
+ *
+ * file name: testdata.cpp
+ * generated on: 02/28/2005 03:20:06 PM Pacific Standard Time
+ * generated by: gendata.cpp
+ */
+
+#include "LETypes.h"
+#include "LEScripts.h"
+#include "letest.h"
+
+const char *fontVersionString0 = "Version 0.99";
+le_uint32 fontChecksum0 = 0x541C94C7;
+
+LEUnicode inputText0[] =
+{
+ 0x0936, 0x094D, 0x0930, 0x0940, 0x092E, 0x0926, 0x094D, 0x0020,
+ 0x092D, 0x0917, 0x0935, 0x0926, 0x094D, 0x0917, 0x0940, 0x0924,
+ 0x093E, 0x0020, 0x0905, 0x0927, 0x094D, 0x092F, 0x093E, 0x092F,
+ 0x0020, 0x0905, 0x0930, 0x094D, 0x091C, 0x0941, 0x0928, 0x0020,
+ 0x0935, 0x093F, 0x0937, 0x093E, 0x0926, 0x0020, 0x092F, 0x094B,
+ 0x0917, 0x0020, 0x0927, 0x0943, 0x0924, 0x0930, 0x093E, 0x0937,
+ 0x094D, 0x091F, 0x094D, 0x0930, 0x0020, 0x0909, 0x0935, 0x093E,
+ 0x091A, 0x0943, 0x0020, 0x0927, 0x0930, 0x094D, 0x092E, 0x0915,
+ 0x094D, 0x0937, 0x0947, 0x0924, 0x094D, 0x0930, 0x0947, 0x0020,
+ 0x0915, 0x0941, 0x0930, 0x0941, 0x0915, 0x094D, 0x0937, 0x0947,
+ 0x0924, 0x094D, 0x0930, 0x0947, 0x0020, 0x0938, 0x092E, 0x0935,
+ 0x0947, 0x0924, 0x093E, 0x0020, 0x092F, 0x0941, 0x092F, 0x0941,
+ 0x0924, 0x094D, 0x0938, 0x0935, 0x0903, 0x0020, 0x092E, 0x093E,
+ 0x092E, 0x0915, 0x093E, 0x0903, 0x0020, 0x092A, 0x093E, 0x0923,
+ 0x094D, 0x0921, 0x0935, 0x093E, 0x0936, 0x094D, 0x091A, 0x0948,
+ 0x0935, 0x0020, 0x0915, 0x093F, 0x092E, 0x0915, 0x0941, 0x0930,
+ 0x094D, 0x0935, 0x0924, 0x0020, 0x0938, 0x0902, 0x091C, 0x0935
+};
+
+LEGlyphID resultGlyphs0[] =
+{
+ 0x0000012E, 0x0000FFFF, 0x0000FFFF, 0x00000222, 0x00000098, 0x0000026E, 0x0000FFFF, 0x00000003,
+ 0x00000097, 0x00000082, 0x0000009D, 0x000001A5, 0x0000FFFF, 0x0000FFFF, 0x00000222, 0x0000008F,
+ 0x00000221, 0x00000003, 0x0000005C, 0x000000DA, 0x0000FFFF, 0x00000099, 0x00000221, 0x00000099,
+ 0x00000003, 0x0000005C, 0x00000087, 0x000001D5, 0x0000005B, 0x0000FFFF, 0x00000093, 0x00000003,
+ 0x000001D2, 0x0000009D, 0x0000009F, 0x00000221, 0x00000091, 0x00000003, 0x00000099, 0x0000022A,
+ 0x00000082, 0x00000003, 0x00000092, 0x000001D9, 0x0000008F, 0x0000009A, 0x00000221, 0x000001B6,
+ 0x0000FFFF, 0x0000FFFF, 0x0000FFFF, 0x0000FFFF, 0x00000003, 0x00000060, 0x0000009D, 0x00000221,
+ 0x00000085, 0x000001D9, 0x00000003, 0x00000092, 0x00000098, 0x0000005B, 0x0000FFFF, 0x000000A2,
+ 0x0000FFFF, 0x0000FFFF, 0x0000022F, 0x0000011F, 0x0000FFFF, 0x0000FFFF, 0x0000022F, 0x00000003,
+ 0x00000080, 0x000001D5, 0x0000009A, 0x000001FD, 0x000000A2, 0x0000FFFF, 0x0000FFFF, 0x0000022F,
+ 0x0000011F, 0x0000FFFF, 0x0000FFFF, 0x0000022F, 0x00000003, 0x000000A0, 0x00000098, 0x0000009D,
+ 0x0000022F, 0x0000008F, 0x00000221, 0x00000003, 0x00000099, 0x000001D5, 0x00000099, 0x000001D5,
+ 0x000000D7, 0x0000FFFF, 0x000000A0, 0x0000009D, 0x0000022C, 0x00000003, 0x00000098, 0x00000221,
+ 0x00000098, 0x00000080, 0x00000221, 0x0000022C, 0x00000003, 0x00000094, 0x00000221, 0x000000D6,
+ 0x0000FFFF, 0x0000008C, 0x0000009D, 0x00000221, 0x000001B1, 0x0000FFFF, 0x0000FFFF, 0x00000230,
+ 0x0000009D, 0x00000003, 0x000001D1, 0x00000080, 0x00000098, 0x00000080, 0x000001D5, 0x0000009D,
+ 0x0000005B, 0x0000FFFF, 0x0000008F, 0x00000003, 0x000000A0, 0x00000232, 0x00000087, 0x0000009D
+};
+
+le_int32 resultGlyphCount0 = 136;
+
+le_int32 resultIndices0[] =
+{
+ 0x00000000, 0x00000002, 0x00000001, 0x00000003, 0x00000004, 0x00000005, 0x00000006, 0x00000007,
+ 0x00000008, 0x00000009, 0x0000000A, 0x0000000B, 0x0000000C, 0x0000000D, 0x0000000E, 0x0000000F,
+ 0x00000010, 0x00000011, 0x00000012, 0x00000013, 0x00000014, 0x00000015, 0x00000016, 0x00000017,
+ 0x00000018, 0x00000019, 0x0000001C, 0x0000001D, 0x0000001A, 0x0000001B, 0x0000001E, 0x0000001F,
+ 0x00000021, 0x00000020, 0x00000022, 0x00000023, 0x00000024, 0x00000025, 0x00000026, 0x00000027,
+ 0x00000028, 0x00000029, 0x0000002A, 0x0000002B, 0x0000002C, 0x0000002D, 0x0000002E, 0x0000002F,
+ 0x00000030, 0x00000031, 0x00000033, 0x00000032, 0x00000034, 0x00000035, 0x00000036, 0x00000037,
+ 0x00000038, 0x00000039, 0x0000003A, 0x0000003B, 0x0000003E, 0x0000003C, 0x0000003D, 0x0000003F,
+ 0x00000040, 0x00000041, 0x00000042, 0x00000043, 0x00000045, 0x00000044, 0x00000046, 0x00000047,
+ 0x00000048, 0x00000049, 0x0000004A, 0x0000004B, 0x0000004C, 0x0000004D, 0x0000004E, 0x0000004F,
+ 0x00000050, 0x00000052, 0x00000051, 0x00000053, 0x00000054, 0x00000055, 0x00000056, 0x00000057,
+ 0x00000058, 0x00000059, 0x0000005A, 0x0000005B, 0x0000005C, 0x0000005D, 0x0000005E, 0x0000005F,
+ 0x00000060, 0x00000061, 0x00000062, 0x00000063, 0x00000064, 0x00000065, 0x00000066, 0x00000067,
+ 0x00000068, 0x00000069, 0x0000006A, 0x0000006B, 0x0000006C, 0x0000006D, 0x0000006E, 0x0000006F,
+ 0x00000070, 0x00000071, 0x00000072, 0x00000073, 0x00000074, 0x00000075, 0x00000076, 0x00000077,
+ 0x00000078, 0x00000079, 0x0000007B, 0x0000007A, 0x0000007C, 0x0000007D, 0x0000007E, 0x00000081,
+ 0x0000007F, 0x00000080, 0x00000082, 0x00000083, 0x00000084, 0x00000085, 0x00000086, 0x00000087
+};
+
+float resultPositions0[] =
+{
+ 0.000000F, 0.000000F, 9.468750F, 0.000000F, 9.468750F, 0.000000F, 9.468750F, 0.000000F,
+ 13.125000F, 0.000000F, 22.593750F, 0.000000F, 30.562500F, 0.000000F, 30.562500F, 0.000000F,
+ 36.562500F, 0.000000F, 46.031250F, 0.000000F, 55.500000F, 0.000000F, 63.468750F, 0.000000F,
+ 71.437500F, 0.000000F, 71.437500F, 0.000000F, 71.437500F, 0.000000F, 75.093750F, 0.000000F,
+ 83.062500F, 0.000000F, 86.718750F, 0.000000F, 92.718750F, 0.000000F, 102.656250F, 0.000000F,
+ 109.921875F, 0.000000F, 109.921875F, 0.000000F, 119.390625F, 0.000000F, 123.046875F, 0.000000F,
+ 132.515625F, 0.000000F, 138.515625F, 0.000000F, 148.453125F, 0.000000F, 158.203125F, -0.011719F,
+ 158.203125F, 0.263672F, 157.921875F, 0.000000F, 157.921875F, 0.000000F, 167.390625F, 0.000000F,
+ 173.390625F, 0.000000F, 177.750000F, 0.000000F, 185.718750F, 0.000000F, 193.687500F, 0.000000F,
+ 197.343750F, 0.000000F, 205.312500F, 0.000000F, 211.312500F, 0.000000F, 220.781250F, 0.000000F,
+ 224.859375F, 0.000000F, 234.328125F, 0.000000F, 240.328125F, 0.000000F, 250.224609F, -0.011719F,
+ 249.796875F, 0.000000F, 257.765625F, 0.000000F, 264.281250F, 0.000000F, 267.937500F, 0.000000F,
+ 276.281250F, 0.000000F, 276.281250F, 0.000000F, 276.281250F, 0.000000F, 276.281250F, 0.000000F,
+ 276.281250F, 0.000000F, 282.281250F, 0.000000F, 290.250000F, 0.000000F, 298.218750F, 0.000000F,
+ 301.875000F, 0.000000F, 311.859375F, -0.011719F, 311.343750F, 0.000000F, 317.343750F, 0.000000F,
+ 326.812500F, 0.000000F, 336.644531F, 0.263672F, 336.281250F, 0.000000F, 336.281250F, 0.000000F,
+ 347.156250F, 0.000000F, 347.156250F, 0.000000F, 346.353516F, 0.275391F, 347.156250F, 0.000000F,
+ 355.125000F, 0.000000F, 355.125000F, 0.000000F, 355.263672F, 0.263672F, 355.125000F, 0.000000F,
+ 361.125000F, 0.000000F, 368.824219F, -0.011719F, 372.000000F, 0.000000F, 378.515625F, 0.000000F,
+ 379.875000F, 0.000000F, 390.750000F, 0.000000F, 390.750000F, 0.000000F, 389.947266F, 0.275391F,
+ 390.750000F, 0.000000F, 398.718750F, 0.000000F, 398.718750F, 0.000000F, 398.857422F, 0.263672F,
+ 398.718750F, 0.000000F, 404.718750F, 0.000000F, 414.187500F, 0.000000F, 423.656250F, 0.000000F,
+ 430.769531F, 0.263672F, 431.625000F, 0.000000F, 439.593750F, 0.000000F, 443.250000F, 0.000000F,
+ 449.250000F, 0.000000F, 458.859375F, -0.011719F, 458.718750F, 0.000000F, 468.328125F, -0.011719F,
+ 468.187500F, 0.000000F, 474.117188F, 0.000000F, 474.117188F, 0.000000F, 483.585938F, 0.000000F,
+ 491.554688F, 0.000000F, 495.914063F, 0.000000F, 501.914063F, 0.000000F, 511.382813F, 0.000000F,
+ 515.039063F, 0.000000F, 524.507813F, 0.000000F, 535.382813F, 0.000000F, 539.039063F, 0.000000F,
+ 543.398438F, 0.000000F, 549.398438F, 0.000000F, 557.367188F, 0.000000F, 561.023438F, 0.000000F,
+ 568.289063F, 0.000000F, 568.289063F, 0.000000F, 576.257813F, 0.000000F, 584.226563F, 0.000000F,
+ 587.882813F, 0.000000F, 598.757813F, 0.000000F, 598.757813F, 0.000000F, 598.628906F, 0.263672F,
+ 598.757813F, 0.000000F, 606.726563F, 0.000000F, 612.726563F, 0.000000F, 617.085938F, 0.000000F,
+ 627.960938F, 0.000000F, 637.429688F, 0.000000F, 645.128906F, -0.011719F, 648.304688F, 0.000000F,
+ 656.566406F, 0.263672F, 656.273438F, 0.000000F, 656.273438F, 0.000000F, 664.242188F, 0.000000F,
+ 670.242188F, 0.000000F, 679.429688F, 0.966797F, 679.710938F, 0.000000F, 689.179688F, 0.000000F,
+ 697.148438F, 0.000000F
+};
+
+
+const char *fontVersionString1 = "Version 1.14";
+le_uint32 fontChecksum1 = 0x2B6E171D;
+
+LEUnicode inputText1[] =
+{
+ 0x0623, 0x0633, 0x0627, 0x0633, 0x064B, 0x0627, 0x060C, 0x0020,
+ 0x062A, 0x062A, 0x0639, 0x0627, 0x0645, 0x0644, 0x0020, 0x0627,
+ 0x0644, 0x062D, 0x0648, 0x0627, 0x0633, 0x064A, 0x0628, 0x0020,
+ 0x0641, 0x0642, 0x0637, 0x0020, 0x0645, 0x0639, 0x0020, 0x0627,
+ 0x0644, 0x0623, 0x0631, 0x0642, 0x0627, 0x0645, 0x060C, 0x0020,
+ 0x0648, 0x062A, 0x0642, 0x0648, 0x0645, 0x0020, 0x0628, 0x062A,
+ 0x062E, 0x0632, 0x064A, 0x0646, 0x0020, 0x0627, 0x0644, 0x0623,
+ 0x062D, 0x0631, 0x0641, 0x0020, 0x0648, 0x0627, 0x0644, 0x0645,
+ 0x062D, 0x0627, 0x0631, 0x0641, 0x0020, 0x0627, 0x0644, 0x0623,
+ 0x062E, 0x0631, 0x0649, 0x0020, 0x0628, 0x0639, 0x062F, 0x0020,
+ 0x0623, 0x0646, 0x0020, 0x062A, 0x064F, 0x0639, 0x0637, 0x064A,
+ 0x0020, 0x0631, 0x0642, 0x0645, 0x0627, 0x0020, 0x0645, 0x0639,
+ 0x064A, 0x0646, 0x0627, 0x0020, 0x0644, 0x0643, 0x0644, 0x0020,
+ 0x0648, 0x0627, 0x062D, 0x062F, 0x0020, 0x0645, 0x0646, 0x0647,
+ 0x0627, 0x002E, 0x0020, 0x0648, 0x0642, 0x0628, 0x0644, 0x0020,
+ 0x0627, 0x062E, 0x062A, 0x0631, 0x0627, 0x0639, 0x0020, 0x0022,
+ 0x064A, 0x0648, 0x0646, 0x0650, 0x0643, 0x0648, 0x062F, 0x0022,
+ 0x060C, 0x0020, 0x0643, 0x0627, 0x0646, 0x0020, 0x0647, 0x0646,
+ 0x0627, 0x0643, 0x0020, 0x0645, 0x0626, 0x0627, 0x062A, 0x0020,
+ 0x0627, 0x0644, 0x0623, 0x0646, 0x0638, 0x0645, 0x0629, 0x0020,
+ 0x0644, 0x0644, 0x062A, 0x0634, 0x0641, 0x064A, 0x0631, 0x0020,
+ 0x0648, 0x062A, 0x062E, 0x0635, 0x064A, 0x0635, 0x0020, 0x0647,
+ 0x0630, 0x0647, 0x0020, 0x0627, 0x0644, 0x0623, 0x0631, 0x0642,
+ 0x0627, 0x0645, 0x0020, 0x0644, 0x0644, 0x0645, 0x062D, 0x0627,
+ 0x0631, 0x0641, 0x060C, 0x0020, 0x0648, 0x0644, 0x0645, 0x0020,
+ 0x064A, 0x0648, 0x062C, 0x062F, 0x0020, 0x0646, 0x0638, 0x0627,
+ 0x0645, 0x0020, 0x062A, 0x0634, 0x0641, 0x064A, 0x0631, 0x0020,
+ 0x0648, 0x0627, 0x062D, 0x062F, 0x0020, 0x064A, 0x062D, 0x062A,
+ 0x0648, 0x064A, 0x0020, 0x0639, 0x0644, 0x0649, 0x0020, 0x062C,
+ 0x0645, 0x064A, 0x0639, 0x0020, 0x0627, 0x0644, 0x0645, 0x062D,
+ 0x0627, 0x0631, 0x0641, 0x0020, 0x0627, 0x0644, 0x0636, 0x0631,
+ 0x0648, 0x0631, 0x064A, 0x0629
+};
+
+LEGlyphID resultGlyphs1[] =
+{
+ 0x0000C530, 0x0000C58F, 0x0000C549, 0x0000C589, 0x0000C54A, 0x0000C55C, 0x0000C57B, 0x0000C529,
+ 0x00000003, 0x0000C56D, 0x0000C549, 0x0000C52A, 0x0000C540, 0x0000C580, 0x0000C57B, 0x0000C529,
+ 0x00000003, 0x0000C566, 0x0000C590, 0x0000C580, 0x0000C53B, 0x00000003, 0x0000C58C, 0x0000C57C,
+ 0x0000C567, 0x00000003, 0x0000C58D, 0x0000C58A, 0x0000C534, 0x0000C540, 0x0000C58F, 0x00000003,
+ 0x0000C546, 0x0000C53F, 0x0000C529, 0x0000C589, 0x00000003, 0x0000C54A, 0x0000C590, 0x0000C570,
+ 0x0000C554, 0x0000C533, 0x00000003, 0x0000C57D, 0x0000C52A, 0x0000C564, 0x0000C583, 0x00000003,
+ 0x0000C546, 0x0000C53B, 0x0000C58A, 0x0000C58F, 0x00000003, 0x0000C57E, 0x0000C57B, 0x0000C589,
+ 0x00000003, 0x00000528, 0x0000C56D, 0x0000C549, 0x0000C52A, 0x0000C540, 0x0000C580, 0x0000C57C,
+ 0x0000C57B, 0x00000003, 0x0000C57D, 0x0000C52A, 0x0000C573, 0x0000C549, 0x0000FFFE, 0x0000C593,
+ 0x0000C529, 0x00000003, 0x0000C585, 0x0000C548, 0x0000C587, 0x00000003, 0x0000C556, 0x0000C590,
+ 0x0000C558, 0x0000C544, 0x0000C533, 0x0000C589, 0x00000003, 0x0000C54A, 0x0000C590, 0x0000C570,
+ 0x0000C554, 0x0000C534, 0x0000C57C, 0x0000C57B, 0x00000003, 0x0000C530, 0x0000C580, 0x0000C564,
+ 0x0000C583, 0x0000FFFE, 0x0000C593, 0x0000C529, 0x00000003, 0x0000C531, 0x0000C52A, 0x00000530,
+ 0x0000C57F, 0x00000003, 0x0000C575, 0x0000C52A, 0x0000C584, 0x0000C587, 0x00000003, 0x0000C581,
+ 0x0000C52A, 0x0000C577, 0x00000003, 0x00000528, 0x00000005, 0x0000C545, 0x0000C58A, 0x0000C578,
+ 0x00000555, 0x0000C583, 0x0000C58A, 0x0000C58F, 0x00000005, 0x00000003, 0x0000C565, 0x0000C529,
+ 0x0000C54A, 0x0000C534, 0x0000C543, 0x0000C529, 0x00000003, 0x0000C57A, 0x0000C52E, 0x0000C573,
+ 0x0000C589, 0x00000003, 0x00000011, 0x0000C52A, 0x0000C588, 0x0000C584, 0x0000C57F, 0x00000003,
+ 0x0000C546, 0x0000C53F, 0x0000C529, 0x0000C589, 0x00000003, 0x0000C57A, 0x0000C578, 0x0000C57B,
+ 0x00000003, 0x0000C52A, 0x0000C584, 0x0000C590, 0x0000C568, 0x0000C57F, 0x00000003, 0x0000C52A,
+ 0x0000C580, 0x0000C573, 0x0000C549, 0x00000003, 0x0000C58E, 0x0000C560, 0x0000C568, 0x00000554,
+ 0x0000C533, 0x00000003, 0x0000C581, 0x0000C51F, 0x00000003, 0x0000C546, 0x0000C568, 0x0000C52D,
+ 0x00000003, 0x0000C58B, 0x0000C54A, 0x0000C543, 0x0000FFFE, 0x0000C593, 0x0000C529, 0x00000003,
+ 0x0000C56D, 0x0000C549, 0x0000C52A, 0x0000C540, 0x0000C580, 0x0000C57B, 0x0000C529, 0x0000C589,
+ 0x00000003, 0x0000C56D, 0x0000C54A, 0x0000C53F, 0x0000FFFE, 0x0000C593, 0x0000C529, 0x00000003,
+ 0x0000C582, 0x0000C58F, 0x0000C54C, 0x0000C544, 0x0000C534, 0x0000C52D, 0x00000003, 0x0000C57D,
+ 0x0000C58A, 0x0000C574, 0x0000C533, 0x0000C589, 0x00000003, 0x00000528, 0x0000C57D, 0x0000C52A,
+ 0x0000C573, 0x0000C549, 0x0000FFFE, 0x0000C593, 0x0000C529, 0x00000003, 0x0000C566, 0x0000C57F,
+ 0x00000003, 0x0000C55E, 0x0000C574, 0x0000C56F, 0x00000003, 0x0000C52C, 0x0000C590, 0x0000C54F,
+ 0x0000C529, 0x0000C58A, 0x0000C540, 0x0000C57B, 0x0000C529, 0x00000003, 0x0000C57A, 0x0000C57F,
+ 0x0000C52A, 0x0000C568, 0x0000C534, 0x0000C533, 0x00000003, 0x00000528, 0x0000C52A, 0x00000550,
+ 0x0000C54F, 0x0000C52A, 0x0000C54F, 0x0000C51F
+};
+
+le_int32 resultGlyphCount1 = 252;
+
+le_int32 resultIndices1[] =
+{
+ 0x000000FB, 0x000000FA, 0x000000F9, 0x000000F8, 0x000000F7, 0x000000F6, 0x000000F5, 0x000000F4,
+ 0x000000F3, 0x000000F2, 0x000000F1, 0x000000F0, 0x000000EF, 0x000000EE, 0x000000ED, 0x000000EC,
+ 0x000000EB, 0x000000EA, 0x000000E9, 0x000000E8, 0x000000E7, 0x000000E6, 0x000000E5, 0x000000E4,
+ 0x000000E3, 0x000000E2, 0x000000E1, 0x000000E0, 0x000000DF, 0x000000DE, 0x000000DD, 0x000000DC,
+ 0x000000DB, 0x000000DA, 0x000000D9, 0x000000D8, 0x000000D7, 0x000000D6, 0x000000D5, 0x000000D4,
+ 0x000000D3, 0x000000D2, 0x000000D1, 0x000000D0, 0x000000CF, 0x000000CE, 0x000000CD, 0x000000CC,
+ 0x000000CB, 0x000000CA, 0x000000C9, 0x000000C8, 0x000000C7, 0x000000C6, 0x000000C5, 0x000000C4,
+ 0x000000C3, 0x000000C2, 0x000000C1, 0x000000C0, 0x000000BF, 0x000000BE, 0x000000BD, 0x000000BC,
+ 0x000000BB, 0x000000BA, 0x000000B9, 0x000000B8, 0x000000B7, 0x000000B6, 0x000000B5, 0x000000B4,
+ 0x000000B3, 0x000000B2, 0x000000B1, 0x000000B0, 0x000000AF, 0x000000AE, 0x000000AD, 0x000000AC,
+ 0x000000AB, 0x000000AA, 0x000000A9, 0x000000A8, 0x000000A7, 0x000000A6, 0x000000A5, 0x000000A4,
+ 0x000000A3, 0x000000A2, 0x000000A1, 0x000000A0, 0x0000009F, 0x0000009E, 0x0000009D, 0x0000009C,
+ 0x0000009B, 0x0000009A, 0x00000099, 0x00000098, 0x00000097, 0x00000096, 0x00000095, 0x00000094,
+ 0x00000093, 0x00000092, 0x00000091, 0x00000090, 0x0000008F, 0x0000008E, 0x0000008D, 0x0000008C,
+ 0x0000008B, 0x0000008A, 0x00000089, 0x00000088, 0x00000087, 0x00000086, 0x00000085, 0x00000084,
+ 0x00000083, 0x00000082, 0x00000081, 0x00000080, 0x0000007F, 0x0000007E, 0x0000007D, 0x0000007C,
+ 0x0000007B, 0x0000007A, 0x00000079, 0x00000078, 0x00000077, 0x00000076, 0x00000075, 0x00000074,
+ 0x00000073, 0x00000072, 0x00000071, 0x00000070, 0x0000006F, 0x0000006E, 0x0000006D, 0x0000006C,
+ 0x0000006B, 0x0000006A, 0x00000069, 0x00000068, 0x00000067, 0x00000066, 0x00000065, 0x00000064,
+ 0x00000063, 0x00000062, 0x00000061, 0x00000060, 0x0000005F, 0x0000005E, 0x0000005D, 0x0000005C,
+ 0x0000005B, 0x0000005A, 0x00000059, 0x00000058, 0x00000057, 0x00000056, 0x00000055, 0x00000054,
+ 0x00000053, 0x00000052, 0x00000051, 0x00000050, 0x0000004F, 0x0000004E, 0x0000004D, 0x0000004C,
+ 0x0000004B, 0x0000004A, 0x00000049, 0x00000048, 0x00000047, 0x00000046, 0x00000045, 0x00000044,
+ 0x00000043, 0x00000042, 0x00000041, 0x00000040, 0x0000003F, 0x0000003E, 0x0000003D, 0x0000003C,
+ 0x0000003B, 0x0000003A, 0x00000039, 0x00000038, 0x00000037, 0x00000036, 0x00000035, 0x00000034,
+ 0x00000033, 0x00000032, 0x00000031, 0x00000030, 0x0000002F, 0x0000002E, 0x0000002D, 0x0000002C,
+ 0x0000002B, 0x0000002A, 0x00000029, 0x00000028, 0x00000027, 0x00000026, 0x00000025, 0x00000024,
+ 0x00000023, 0x00000022, 0x00000021, 0x00000020, 0x0000001F, 0x0000001E, 0x0000001D, 0x0000001C,
+ 0x0000001B, 0x0000001A, 0x00000019, 0x00000018, 0x00000017, 0x00000016, 0x00000015, 0x00000014,
+ 0x00000013, 0x00000012, 0x00000011, 0x00000010, 0x0000000F, 0x0000000E, 0x0000000D, 0x0000000C,
+ 0x0000000B, 0x0000000A, 0x00000009, 0x00000008, 0x00000007, 0x00000006, 0x00000005, 0x00000004,
+ 0x00000003, 0x00000002, 0x00000001, 0x00000000
+};
+
+float resultPositions1[] =
+{
+ 0.000000F, 0.000000F, 4.007813F, 0.000000F, 8.226563F, 0.000000F, 12.679688F, 0.000000F,
+ 18.679688F, 0.000000F, 23.132813F, 0.000000F, 31.289063F, 0.000000F, 34.312500F, 0.000000F,
+ 36.375000F, 0.000000F, 41.062500F, 0.000000F, 50.296875F, 0.000000F, 54.750000F, 0.000000F,
+ 56.859375F, 0.000000F, 62.367188F, 0.000000F, 66.632813F, 0.000000F, 69.656250F, 0.000000F,
+ 71.718750F, 0.000000F, 76.406250F, 0.000000F, 81.421875F, 0.000000F, 85.664063F, 0.000000F,
+ 89.929688F, 0.000000F, 95.742188F, 0.000000F, 100.429688F, 0.000000F, 108.796875F, 0.000000F,
+ 112.171875F, 0.000000F, 115.734375F, 0.000000F, 120.421875F, 0.000000F, 128.765625F, 0.000000F,
+ 134.765625F, 0.000000F, 139.007813F, 0.000000F, 144.515625F, 0.000000F, 148.734375F, 0.000000F,
+ 153.421875F, 0.000000F, 157.359375F, 0.000000F, 163.171875F, 0.000000F, 165.234375F, 0.000000F,
+ 171.234375F, 0.000000F, 175.921875F, 0.000000F, 180.375000F, 0.000000F, 184.617188F, 0.000000F,
+ 188.085938F, 0.000000F, 195.117188F, 0.000000F, 199.312500F, 0.000000F, 204.000000F, 0.000000F,
+ 208.007813F, 0.000000F, 210.117188F, 0.000000F, 217.054688F, 0.000000F, 220.429688F, 0.000000F,
+ 225.117188F, 0.000000F, 229.054688F, 0.000000F, 234.867188F, 0.000000F, 240.867188F, 0.000000F,
+ 245.085938F, 0.000000F, 249.773438F, 0.000000F, 253.781250F, 0.000000F, 256.804688F, 0.000000F,
+ 262.804688F, 0.000000F, 267.492188F, 0.000000F, 271.007813F, 0.000000F, 280.242188F, 0.000000F,
+ 284.695313F, 0.000000F, 286.804688F, 0.000000F, 292.312500F, 0.000000F, 296.578125F, 0.000000F,
+ 299.953125F, 0.000000F, 302.976563F, 0.000000F, 307.664063F, 0.000000F, 311.671875F, 0.000000F,
+ 313.781250F, 0.000000F, 317.882813F, 0.000000F, 322.335938F, 0.000000F, 322.335938F, 0.000000F,
+ 328.500000F, 0.000000F, 330.562500F, 0.000000F, 335.250000F, 0.000000F, 339.140625F, 0.000000F,
+ 343.078125F, 0.000000F, 348.984375F, 0.000000F, 353.671875F, 0.000000F, 366.445313F, 0.000000F,
+ 370.687500F, 0.000000F, 378.843750F, 0.000000F, 384.351563F, 0.000000F, 388.546875F, 0.000000F,
+ 394.546875F, 0.000000F, 399.234375F, 0.000000F, 403.687500F, 0.000000F, 407.929688F, 0.000000F,
+ 411.398438F, 0.000000F, 418.429688F, 0.000000F, 422.671875F, 0.000000F, 426.046875F, 0.000000F,
+ 429.070313F, 0.000000F, 433.757813F, 0.000000F, 437.765625F, 0.000000F, 442.031250F, 0.000000F,
+ 448.968750F, 0.000000F, 452.343750F, 0.000000F, 452.343750F, 0.000000F, 458.507813F, 0.000000F,
+ 460.570313F, 0.000000F, 465.257813F, 0.000000F, 474.492188F, 0.000000F, 476.601563F, 0.000000F,
+ 484.968750F, 0.000000F, 489.234375F, 0.000000F, 493.921875F, 0.000000F, 501.562500F, 0.000000F,
+ 503.671875F, 0.000000F, 507.890625F, 0.000000F, 513.796875F, 0.000000F, 518.484375F, 0.000000F,
+ 525.796875F, 0.000000F, 527.906250F, 0.000000F, 533.578125F, 0.000000F, 538.265625F, 0.000000F,
+ 541.781250F, 0.000000F, 547.171875F, 0.000000F, 550.710938F, 0.000000F, 556.710938F, 0.000000F,
+ 564.492188F, 0.000000F, 564.492188F, 0.000000F, 567.867188F, 0.000000F, 573.867188F, 0.000000F,
+ 578.085938F, 0.000000F, 583.476563F, 0.000000F, 588.164063F, 0.000000F, 593.976563F, 0.000000F,
+ 596.039063F, 0.000000F, 600.492188F, 0.000000F, 604.734375F, 0.000000F, 610.546875F, 0.000000F,
+ 612.609375F, 0.000000F, 617.296875F, 0.000000F, 623.695313F, 0.000000F, 627.937500F, 0.000000F,
+ 632.039063F, 0.000000F, 638.039063F, 0.000000F, 642.726563F, 0.000000F, 646.054688F, 0.000000F,
+ 648.164063F, 0.000000F, 651.914063F, 0.000000F, 656.132813F, 0.000000F, 660.398438F, 0.000000F,
+ 665.085938F, 0.000000F, 669.023438F, 0.000000F, 674.835938F, 0.000000F, 676.898438F, 0.000000F,
+ 682.898438F, 0.000000F, 687.585938F, 0.000000F, 693.984375F, 0.000000F, 701.765625F, 0.000000F,
+ 704.789063F, 0.000000F, 709.476563F, 0.000000F, 711.585938F, 0.000000F, 715.804688F, 0.000000F,
+ 720.046875F, 0.000000F, 723.515625F, 0.000000F, 727.781250F, 0.000000F, 732.468750F, 0.000000F,
+ 734.578125F, 0.000000F, 738.843750F, 0.000000F, 742.945313F, 0.000000F, 747.398438F, 0.000000F,
+ 752.085938F, 0.000000F, 760.453125F, 0.000000F, 767.390625F, 0.000000F, 770.859375F, 0.000000F,
+ 770.859375F, 0.000000F, 775.054688F, 0.000000F, 779.742188F, 0.000000F, 787.054688F, 0.000000F,
+ 789.398438F, 0.000000F, 794.085938F, 0.000000F, 798.023438F, 0.000000F, 801.492188F, 0.000000F,
+ 804.937500F, 0.000000F, 809.625000F, 0.000000F, 817.968750F, 0.000000F, 822.421875F, 0.000000F,
+ 828.234375F, 0.000000F, 828.234375F, 0.000000F, 834.398438F, 0.000000F, 836.460938F, 0.000000F,
+ 841.148438F, 0.000000F, 850.382813F, 0.000000F, 854.835938F, 0.000000F, 856.945313F, 0.000000F,
+ 862.453125F, 0.000000F, 866.718750F, 0.000000F, 869.742188F, 0.000000F, 871.804688F, 0.000000F,
+ 877.804688F, 0.000000F, 882.492188F, 0.000000F, 891.726563F, 0.000000F, 896.179688F, 0.000000F,
+ 901.992188F, 0.000000F, 901.992188F, 0.000000F, 908.156250F, 0.000000F, 910.218750F, 0.000000F,
+ 914.906250F, 0.000000F, 922.382813F, 0.000000F, 926.601563F, 0.000000F, 931.054688F, 0.000000F,
+ 936.562500F, 0.000000F, 940.804688F, 0.000000F, 944.250000F, 0.000000F, 948.937500F, 0.000000F,
+ 952.945313F, 0.000000F, 958.945313F, 0.000000F, 962.414063F, 0.000000F, 966.609375F, 0.000000F,
+ 972.609375F, 0.000000F, 977.296875F, 0.000000F, 980.812500F, 0.000000F, 984.820313F, 0.000000F,
+ 986.929688F, 0.000000F, 991.031250F, 0.000000F, 995.484375F, 0.000000F, 995.484375F, 0.000000F,
+ 1001.648438F, 0.000000F, 1003.710938F, 0.000000F, 1008.398438F, 0.000000F, 1013.414063F, 0.000000F,
+ 1017.679688F, 0.000000F, 1022.367188F, 0.000000F, 1030.312500F, 0.000000F, 1033.781250F, 0.000000F,
+ 1037.882813F, 0.000000F, 1042.570313F, 0.000000F, 1051.921875F, 0.000000F, 1056.164063F, 0.000000F,
+ 1062.984375F, 0.000000F, 1065.046875F, 0.000000F, 1071.046875F, 0.000000F, 1076.554688F, 0.000000F,
+ 1079.578125F, 0.000000F, 1081.640625F, 0.000000F, 1086.328125F, 0.000000F, 1092.726563F, 0.000000F,
+ 1096.992188F, 0.000000F, 1099.101563F, 0.000000F, 1102.570313F, 0.000000F, 1106.812500F, 0.000000F,
+ 1111.007813F, 0.000000F, 1115.695313F, 0.000000F, 1119.210938F, 0.000000F, 1121.320313F, 0.000000F,
+ 1121.320313F, 0.000000F, 1128.140625F, 0.000000F, 1130.250000F, 0.000000F, 1137.070313F, 0.000000F,
+ 1139.414063F, 0.000000F
+};
+
+
+const char *fontVersionString2 = "Version 1.20 - October 2000";
+le_uint32 fontChecksum2 = 0xF5D9BA6D;
+
+LEUnicode inputText2[] =
+{
+ 0x0623, 0x0633, 0x0627, 0x0633, 0x064B, 0x0627, 0x060C, 0x0020,
+ 0x062A, 0x062A, 0x0639, 0x0627, 0x0645, 0x0644, 0x0020, 0x0627,
+ 0x0644, 0x062D, 0x0648, 0x0627, 0x0633, 0x064A, 0x0628, 0x0020,
+ 0x0641, 0x0642, 0x0637, 0x0020, 0x0645, 0x0639, 0x0020, 0x0627,
+ 0x0644, 0x0623, 0x0631, 0x0642, 0x0627, 0x0645, 0x060C, 0x0020,
+ 0x0648, 0x062A, 0x0642, 0x0648, 0x0645, 0x0020, 0x0628, 0x062A,
+ 0x062E, 0x0632, 0x064A, 0x0646, 0x0020, 0x0627, 0x0644, 0x0623,
+ 0x062D, 0x0631, 0x0641, 0x0020, 0x0648, 0x0627, 0x0644, 0x0645,
+ 0x062D, 0x0627, 0x0631, 0x0641, 0x0020, 0x0627, 0x0644, 0x0623,
+ 0x062E, 0x0631, 0x0649, 0x0020, 0x0628, 0x0639, 0x062F, 0x0020,
+ 0x0623, 0x0646, 0x0020, 0x062A, 0x064F, 0x0639, 0x0637, 0x064A,
+ 0x0020, 0x0631, 0x0642, 0x0645, 0x0627, 0x0020, 0x0645, 0x0639,
+ 0x064A, 0x0646, 0x0627, 0x0020, 0x0644, 0x0643, 0x0644, 0x0020,
+ 0x0648, 0x0627, 0x062D, 0x062F, 0x0020, 0x0645, 0x0646, 0x0647,
+ 0x0627, 0x002E, 0x0020, 0x0648, 0x0642, 0x0628, 0x0644, 0x0020,
+ 0x0627, 0x062E, 0x062A, 0x0631, 0x0627, 0x0639, 0x0020, 0x0022,
+ 0x064A, 0x0648, 0x0646, 0x0650, 0x0643, 0x0648, 0x062F, 0x0022,
+ 0x060C, 0x0020, 0x0643, 0x0627, 0x0646, 0x0020, 0x0647, 0x0646,
+ 0x0627, 0x0643, 0x0020, 0x0645, 0x0626, 0x0627, 0x062A, 0x0020,
+ 0x0627, 0x0644, 0x0623, 0x0646, 0x0638, 0x0645, 0x0629, 0x0020,
+ 0x0644, 0x0644, 0x062A, 0x0634, 0x0641, 0x064A, 0x0631, 0x0020,
+ 0x0648, 0x062A, 0x062E, 0x0635, 0x064A, 0x0635, 0x0020, 0x0647,
+ 0x0630, 0x0647, 0x0020, 0x0627, 0x0644, 0x0623, 0x0631, 0x0642,
+ 0x0627, 0x0645, 0x0020, 0x0644, 0x0644, 0x0645, 0x062D, 0x0627,
+ 0x0631, 0x0641, 0x060C, 0x0020, 0x0648, 0x0644, 0x0645, 0x0020,
+ 0x064A, 0x0648, 0x062C, 0x062F, 0x0020, 0x0646, 0x0638, 0x0627,
+ 0x0645, 0x0020, 0x062A, 0x0634, 0x0641, 0x064A, 0x0631, 0x0020,
+ 0x0648, 0x0627, 0x062D, 0x062F, 0x0020, 0x064A, 0x062D, 0x062A,
+ 0x0648, 0x064A, 0x0020, 0x0639, 0x0644, 0x0649, 0x0020, 0x062C,
+ 0x0645, 0x064A, 0x0639, 0x0020, 0x0627, 0x0644, 0x0645, 0x062D,
+ 0x0627, 0x0631, 0x0641, 0x0020, 0x0627, 0x0644, 0x0636, 0x0631,
+ 0x0648, 0x0631, 0x064A, 0x0629
+};
+
+LEGlyphID resultGlyphs2[] =
+{
+ 0x00000872, 0x000008D1, 0x000003F9, 0x0000040B, 0x0000088C, 0x0000089E, 0x000008BD, 0x000003EF,
+ 0x00000003, 0x00000404, 0x000003F9, 0x0000086C, 0x00000882, 0x000008C2, 0x000008BD, 0x000003EF,
+ 0x00000003, 0x000008A8, 0x000008D2, 0x000008C2, 0x0000087D, 0x00000003, 0x000008CE, 0x000008BE,
+ 0x000008A9, 0x00000003, 0x0000040D, 0x000008CC, 0x00000876, 0x00000882, 0x000008D1, 0x00000003,
+ 0x00000888, 0x00000881, 0x000003EF, 0x0000040B, 0x00000003, 0x0000088C, 0x000008D2, 0x000008B2,
+ 0x00000896, 0x00000875, 0x00000003, 0x00000408, 0x0000086C, 0x000008A6, 0x000008C5, 0x00000003,
+ 0x00000888, 0x0000087D, 0x000008CC, 0x000008D1, 0x00000003, 0x000008C0, 0x000008BD, 0x0000040B,
+ 0x00000003, 0x000003E6, 0x00000404, 0x000003F9, 0x0000086C, 0x00000882, 0x000008C2, 0x000008BE,
+ 0x000008BD, 0x00000003, 0x00000408, 0x0000086C, 0x000008B5, 0x000003F9, 0x0000FFFF, 0x000008D5,
+ 0x000003EF, 0x00000003, 0x0000040A, 0x0000088A, 0x000008C9, 0x00000003, 0x00000898, 0x000008D2,
+ 0x0000089A, 0x00000886, 0x00000875, 0x0000040B, 0x00000003, 0x0000088C, 0x000008D2, 0x000008B2,
+ 0x00000896, 0x00000876, 0x000008BE, 0x000008BD, 0x00000003, 0x00000872, 0x000008C2, 0x000008A6,
+ 0x000008C5, 0x0000FFFF, 0x000008D5, 0x000003EF, 0x00000003, 0x000003F2, 0x0000086C, 0x0000086A,
+ 0x000008C1, 0x00000003, 0x00000406, 0x0000086C, 0x000008C6, 0x000008C9, 0x00000003, 0x00000409,
+ 0x0000086C, 0x000008B9, 0x00000003, 0x000003E6, 0x00000005, 0x000003F7, 0x000008CC, 0x000008BA,
+ 0x00000413, 0x000008C5, 0x000008CC, 0x000008D1, 0x00000005, 0x00000003, 0x00000401, 0x000003EF,
+ 0x0000088C, 0x00000876, 0x00000885, 0x000003EF, 0x00000003, 0x000008BC, 0x00000870, 0x000008B5,
+ 0x0000040B, 0x00000003, 0x00000011, 0x0000086C, 0x000008CA, 0x000008C6, 0x000008C1, 0x00000003,
+ 0x00000888, 0x00000881, 0x000003EF, 0x0000040B, 0x00000003, 0x000008BC, 0x000008BA, 0x000008BD,
+ 0x00000003, 0x0000086C, 0x000008C6, 0x000008D2, 0x000008AA, 0x000008C1, 0x00000003, 0x0000086C,
+ 0x000008C2, 0x000008B5, 0x000003F9, 0x00000003, 0x000008D0, 0x000008A2, 0x000008AA, 0x00000412,
+ 0x00000875, 0x00000003, 0x00000409, 0x000003EB, 0x00000003, 0x00000888, 0x000008AA, 0x0000086F,
+ 0x00000003, 0x0000040C, 0x0000088C, 0x00000885, 0x0000FFFF, 0x000008D5, 0x000003EF, 0x00000003,
+ 0x00000404, 0x000003F9, 0x0000086C, 0x00000882, 0x000008C2, 0x000008BD, 0x000003EF, 0x0000040B,
+ 0x00000003, 0x00000404, 0x0000088C, 0x00000881, 0x0000FFFF, 0x000008D5, 0x000003EF, 0x00000003,
+ 0x000008C4, 0x000008D1, 0x0000088E, 0x00000886, 0x00000876, 0x0000086F, 0x00000003, 0x00000408,
+ 0x000008CC, 0x000008B6, 0x00000875, 0x0000040B, 0x00000003, 0x000003E6, 0x00000408, 0x0000086C,
+ 0x000008B5, 0x000003F9, 0x0000FFFF, 0x000008D5, 0x000003EF, 0x00000003, 0x000008A8, 0x000008C1,
+ 0x00000003, 0x000008A0, 0x000008B6, 0x000008B1, 0x00000003, 0x0000086E, 0x000008D2, 0x00000891,
+ 0x000003EF, 0x000008CC, 0x00000882, 0x000008BD, 0x000003EF, 0x00000003, 0x000008BC, 0x000008C1,
+ 0x0000086C, 0x000008AA, 0x00000876, 0x00000875, 0x00000003, 0x000003E6, 0x0000086C, 0x0000040E,
+ 0x00000891, 0x0000086C, 0x00000891, 0x000003EB
+};
+
+le_int32 resultGlyphCount2 = 252;
+
+le_int32 resultIndices2[] =
+{
+ 0x000000FB, 0x000000FA, 0x000000F9, 0x000000F8, 0x000000F7, 0x000000F6, 0x000000F5, 0x000000F4,
+ 0x000000F3, 0x000000F2, 0x000000F1, 0x000000F0, 0x000000EF, 0x000000EE, 0x000000ED, 0x000000EC,
+ 0x000000EB, 0x000000EA, 0x000000E9, 0x000000E8, 0x000000E7, 0x000000E6, 0x000000E5, 0x000000E4,
+ 0x000000E3, 0x000000E2, 0x000000E1, 0x000000E0, 0x000000DF, 0x000000DE, 0x000000DD, 0x000000DC,
+ 0x000000DB, 0x000000DA, 0x000000D9, 0x000000D8, 0x000000D7, 0x000000D6, 0x000000D5, 0x000000D4,
+ 0x000000D3, 0x000000D2, 0x000000D1, 0x000000D0, 0x000000CF, 0x000000CE, 0x000000CD, 0x000000CC,
+ 0x000000CB, 0x000000CA, 0x000000C9, 0x000000C8, 0x000000C7, 0x000000C6, 0x000000C5, 0x000000C4,
+ 0x000000C3, 0x000000C2, 0x000000C1, 0x000000C0, 0x000000BF, 0x000000BE, 0x000000BD, 0x000000BC,
+ 0x000000BB, 0x000000BA, 0x000000B9, 0x000000B8, 0x000000B7, 0x000000B6, 0x000000B5, 0x000000B4,
+ 0x000000B3, 0x000000B2, 0x000000B1, 0x000000B0, 0x000000AF, 0x000000AE, 0x000000AD, 0x000000AC,
+ 0x000000AB, 0x000000AA, 0x000000A9, 0x000000A8, 0x000000A7, 0x000000A6, 0x000000A5, 0x000000A4,
+ 0x000000A3, 0x000000A2, 0x000000A1, 0x000000A0, 0x0000009F, 0x0000009E, 0x0000009D, 0x0000009C,
+ 0x0000009B, 0x0000009A, 0x00000099, 0x00000098, 0x00000097, 0x00000096, 0x00000095, 0x00000094,
+ 0x00000093, 0x00000092, 0x00000091, 0x00000090, 0x0000008F, 0x0000008E, 0x0000008D, 0x0000008C,
+ 0x0000008B, 0x0000008A, 0x00000089, 0x00000088, 0x00000087, 0x00000086, 0x00000085, 0x00000084,
+ 0x00000083, 0x00000082, 0x00000081, 0x00000080, 0x0000007F, 0x0000007E, 0x0000007D, 0x0000007C,
+ 0x0000007B, 0x0000007A, 0x00000079, 0x00000078, 0x00000077, 0x00000076, 0x00000075, 0x00000074,
+ 0x00000073, 0x00000072, 0x00000071, 0x00000070, 0x0000006F, 0x0000006E, 0x0000006D, 0x0000006C,
+ 0x0000006B, 0x0000006A, 0x00000069, 0x00000068, 0x00000067, 0x00000066, 0x00000065, 0x00000064,
+ 0x00000063, 0x00000062, 0x00000061, 0x00000060, 0x0000005F, 0x0000005E, 0x0000005D, 0x0000005C,
+ 0x0000005B, 0x0000005A, 0x00000059, 0x00000058, 0x00000057, 0x00000056, 0x00000055, 0x00000054,
+ 0x00000053, 0x00000052, 0x00000051, 0x00000050, 0x0000004F, 0x0000004E, 0x0000004D, 0x0000004C,
+ 0x0000004B, 0x0000004A, 0x00000049, 0x00000048, 0x00000047, 0x00000046, 0x00000045, 0x00000044,
+ 0x00000043, 0x00000042, 0x00000041, 0x00000040, 0x0000003F, 0x0000003E, 0x0000003D, 0x0000003C,
+ 0x0000003B, 0x0000003A, 0x00000039, 0x00000038, 0x00000037, 0x00000036, 0x00000035, 0x00000034,
+ 0x00000033, 0x00000032, 0x00000031, 0x00000030, 0x0000002F, 0x0000002E, 0x0000002D, 0x0000002C,
+ 0x0000002B, 0x0000002A, 0x00000029, 0x00000028, 0x00000027, 0x00000026, 0x00000025, 0x00000024,
+ 0x00000023, 0x00000022, 0x00000021, 0x00000020, 0x0000001F, 0x0000001E, 0x0000001D, 0x0000001C,
+ 0x0000001B, 0x0000001A, 0x00000019, 0x00000018, 0x00000017, 0x00000016, 0x00000015, 0x00000014,
+ 0x00000013, 0x00000012, 0x00000011, 0x00000010, 0x0000000F, 0x0000000E, 0x0000000D, 0x0000000C,
+ 0x0000000B, 0x0000000A, 0x00000009, 0x00000008, 0x00000007, 0x00000006, 0x00000005, 0x00000004,
+ 0x00000003, 0x00000002, 0x00000001, 0x00000000
+};
+
+float resultPositions2[] =
+{
+ 0.000000F, 0.000000F, 6.316406F, 0.000000F, 10.382813F, 0.000000F, 15.492188F, 0.000000F,
+ 21.035156F, 0.000000F, 27.058594F, 0.000000F, 39.527344F, 0.000000F, 43.792969F, 0.000000F,
+ 47.408203F, 0.000000F, 51.205078F, 0.000000F, 66.216797F, 0.000000F, 71.326172F, 0.000000F,
+ 74.695313F, 0.000000F, 83.367188F, 0.000000F, 90.826172F, 0.000000F, 95.091797F, 0.000000F,
+ 98.707031F, 0.000000F, 102.503906F, 0.000000F, 109.962891F, 0.000000F, 114.949219F, 0.000000F,
+ 122.408203F, 0.000000F, 130.687500F, 0.000000F, 134.484375F, 0.000000F, 145.787109F, 0.000000F,
+ 150.773438F, 0.000000F, 156.884766F, 0.000000F, 160.681641F, 0.000000F, 172.277344F, 0.000000F,
+ 177.919922F, 0.000000F, 182.906250F, 0.000000F, 191.578125F, 0.000000F, 195.644531F, 0.000000F,
+ 199.441406F, 0.000000F, 206.507813F, 0.000000F, 214.787109F, 0.000000F, 218.402344F, 0.000000F,
+ 223.945313F, 0.000000F, 227.742188F, 0.000000F, 233.765625F, 0.000000F, 238.751953F, 0.000000F,
+ 245.185547F, 0.000000F, 257.982422F, 0.000000F, 262.048828F, 0.000000F, 265.845703F, 0.000000F,
+ 272.654297F, 0.000000F, 276.023438F, 0.000000F, 285.240234F, 0.000000F, 289.306641F, 0.000000F,
+ 293.103516F, 0.000000F, 300.169922F, 0.000000F, 308.449219F, 0.000000F, 314.091797F, 0.000000F,
+ 318.158203F, 0.000000F, 321.955078F, 0.000000F, 329.572266F, 0.000000F, 333.837891F, 0.000000F,
+ 339.380859F, 0.000000F, 343.177734F, 0.000000F, 346.974609F, 0.000000F, 361.986328F, 0.000000F,
+ 367.095703F, 0.000000F, 370.464844F, 0.000000F, 379.136719F, 0.000000F, 386.595703F, 0.000000F,
+ 391.582031F, 0.000000F, 395.847656F, 0.000000F, 399.644531F, 0.000000F, 406.453125F, 0.000000F,
+ 409.822266F, 0.000000F, 415.523438F, 0.000000F, 420.632813F, 0.000000F, 420.632813F, 0.000000F,
+ 427.441406F, 0.000000F, 431.056641F, 0.000000F, 434.853516F, 0.000000F, 441.357422F, 0.000000F,
+ 448.423828F, 0.000000F, 455.912109F, 0.000000F, 459.708984F, 0.000000F, 479.255859F, 0.000000F,
+ 484.242188F, 0.000000F, 496.710938F, 0.000000F, 505.382813F, 0.000000F, 509.449219F, 0.000000F,
+ 514.992188F, 0.000000F, 518.789063F, 0.000000F, 524.812500F, 0.000000F, 529.798828F, 0.000000F,
+ 536.232422F, 0.000000F, 549.029297F, 0.000000F, 554.015625F, 0.000000F, 559.001953F, 0.000000F,
+ 563.267578F, 0.000000F, 567.064453F, 0.000000F, 573.380859F, 0.000000F, 580.839844F, 0.000000F,
+ 590.056641F, 0.000000F, 594.123047F, 0.000000F, 594.123047F, 0.000000F, 600.931641F, 0.000000F,
+ 604.546875F, 0.000000F, 608.343750F, 0.000000F, 620.636719F, 0.000000F, 624.005859F, 0.000000F,
+ 628.992188F, 0.000000F, 635.830078F, 0.000000F, 639.626953F, 0.000000F, 653.361328F, 0.000000F,
+ 656.730469F, 0.000000F, 661.716797F, 0.000000F, 669.205078F, 0.000000F, 673.001953F, 0.000000F,
+ 683.777344F, 0.000000F, 687.146484F, 0.000000F, 692.660156F, 0.000000F, 696.457031F, 0.000000F,
+ 700.253906F, 0.000000F, 704.736328F, 0.000000F, 711.105469F, 0.000000F, 716.748047F, 0.000000F,
+ 722.994141F, 0.000000F, 722.994141F, 0.000000F, 727.060547F, 0.000000F, 732.703125F, 0.000000F,
+ 736.769531F, 0.000000F, 741.251953F, 0.000000F, 745.048828F, 0.000000F, 752.507813F, 0.000000F,
+ 756.123047F, 0.000000F, 762.146484F, 0.000000F, 767.132813F, 0.000000F, 775.412109F, 0.000000F,
+ 779.027344F, 0.000000F, 782.824219F, 0.000000F, 794.203125F, 0.000000F, 799.189453F, 0.000000F,
+ 804.890625F, 0.000000F, 810.433594F, 0.000000F, 814.230469F, 0.000000F, 818.027344F, 0.000000F,
+ 821.396484F, 0.000000F, 828.128906F, 0.000000F, 833.115234F, 0.000000F, 839.953125F, 0.000000F,
+ 843.750000F, 0.000000F, 850.816406F, 0.000000F, 859.095703F, 0.000000F, 862.710938F, 0.000000F,
+ 868.253906F, 0.000000F, 872.050781F, 0.000000F, 883.429688F, 0.000000F, 889.675781F, 0.000000F,
+ 893.941406F, 0.000000F, 897.738281F, 0.000000F, 901.107422F, 0.000000F, 906.093750F, 0.000000F,
+ 911.080078F, 0.000000F, 917.800781F, 0.000000F, 924.638672F, 0.000000F, 928.435547F, 0.000000F,
+ 931.804688F, 0.000000F, 939.263672F, 0.000000F, 944.964844F, 0.000000F, 950.074219F, 0.000000F,
+ 953.871094F, 0.000000F, 965.173828F, 0.000000F, 974.390625F, 0.000000F, 981.111328F, 0.000000F,
+ 981.111328F, 0.000000F, 985.177734F, 0.000000F, 988.974609F, 0.000000F, 999.750000F, 0.000000F,
+ 1003.365234F, 0.000000F, 1007.162109F, 0.000000F, 1014.228516F, 0.000000F, 1020.949219F, 0.000000F,
+ 1025.015625F, 0.000000F, 1028.812500F, 0.000000F, 1040.408203F, 0.000000F, 1046.431641F, 0.000000F,
+ 1054.710938F, 0.000000F, 1054.710938F, 0.000000F, 1061.519531F, 0.000000F, 1065.134766F, 0.000000F,
+ 1068.931641F, 0.000000F, 1083.943359F, 0.000000F, 1089.052734F, 0.000000F, 1092.421875F, 0.000000F,
+ 1101.093750F, 0.000000F, 1108.552734F, 0.000000F, 1112.818359F, 0.000000F, 1116.433594F, 0.000000F,
+ 1121.976563F, 0.000000F, 1125.773438F, 0.000000F, 1140.785156F, 0.000000F, 1146.808594F, 0.000000F,
+ 1155.087891F, 0.000000F, 1155.087891F, 0.000000F, 1161.896484F, 0.000000F, 1165.511719F, 0.000000F,
+ 1169.308594F, 0.000000F, 1180.541016F, 0.000000F, 1184.607422F, 0.000000F, 1190.630859F, 0.000000F,
+ 1199.302734F, 0.000000F, 1204.289063F, 0.000000F, 1208.355469F, 0.000000F, 1212.152344F, 0.000000F,
+ 1218.960938F, 0.000000F, 1224.603516F, 0.000000F, 1231.037109F, 0.000000F, 1235.103516F, 0.000000F,
+ 1240.646484F, 0.000000F, 1244.443359F, 0.000000F, 1248.240234F, 0.000000F, 1255.048828F, 0.000000F,
+ 1258.417969F, 0.000000F, 1264.119141F, 0.000000F, 1269.228516F, 0.000000F, 1269.228516F, 0.000000F,
+ 1276.037109F, 0.000000F, 1279.652344F, 0.000000F, 1283.449219F, 0.000000F, 1290.908203F, 0.000000F,
+ 1297.746094F, 0.000000F, 1301.542969F, 0.000000F, 1311.427734F, 0.000000F, 1317.861328F, 0.000000F,
+ 1323.562500F, 0.000000F, 1327.359375F, 0.000000F, 1341.492188F, 0.000000F, 1346.478516F, 0.000000F,
+ 1357.904297F, 0.000000F, 1361.519531F, 0.000000F, 1367.162109F, 0.000000F, 1375.833984F, 0.000000F,
+ 1380.099609F, 0.000000F, 1383.714844F, 0.000000F, 1387.511719F, 0.000000F, 1398.890625F, 0.000000F,
+ 1405.728516F, 0.000000F, 1409.097656F, 0.000000F, 1415.818359F, 0.000000F, 1420.804688F, 0.000000F,
+ 1424.871094F, 0.000000F, 1428.667969F, 0.000000F, 1432.464844F, 0.000000F, 1435.833984F, 0.000000F,
+ 1435.833984F, 0.000000F, 1447.259766F, 0.000000F, 1450.628906F, 0.000000F, 1462.054688F, 0.000000F,
+ 1465.669922F, 0.000000F
+};
+
+
+const char *fontVersionString3 = "Version 2.1 - July 1995";
+le_uint32 fontChecksum3 = 0x49B67200;
+
+LEUnicode inputText3[] =
+{
+ 0x0E1A, 0x0E17, 0x0E17, 0x0E35, 0x0E48, 0x0E51, 0x0E1E, 0x0E32,
+ 0x0E22, 0x0E38, 0x0E44, 0x0E0B, 0x0E42, 0x0E04, 0x0E25, 0x0E19,
+ 0x0E42, 0x0E14, 0x0E42, 0x0E23, 0x0E18, 0x0E35, 0x0E2D, 0x0E32,
+ 0x0E28, 0x0E31, 0x0E22, 0x0E2D, 0x0E22, 0x0E39, 0x0E48, 0x0E17,
+ 0x0E48, 0x0E32, 0x0E21, 0x0E01, 0x0E25, 0x0E32, 0x0E07, 0x0E17,
+ 0x0E38, 0x0E48, 0x0E07, 0x0E43, 0x0E2B, 0x0E0D, 0x0E48, 0x0E43,
+ 0x0E19, 0x0E41, 0x0E04, 0x0E19, 0x0E0B, 0x0E31, 0x0E2A, 0x0E01,
+ 0x0E31, 0x0E1A, 0x0E25, 0x0E38, 0x0E07, 0x0E40, 0x0E2E, 0x0E19,
+ 0x0E23, 0x0E35, 0x0E0A, 0x0E32, 0x0E27, 0x0E44, 0x0E23, 0x0E48,
+ 0x0E41, 0x0E25, 0x0E30, 0x0E1B, 0x0E49, 0x0E32, 0x0E40, 0x0E2D,
+ 0x0E47, 0x0E21, 0x0E20, 0x0E23, 0x0E23, 0x0E22, 0x0E32, 0x0E0A,
+ 0x0E32, 0x0E27, 0x0E44, 0x0E23, 0x0E48, 0x0E1A, 0x0E49, 0x0E32,
+ 0x0E19, 0x0E02, 0x0E2D, 0x0E07, 0x0E1E, 0x0E27, 0x0E01, 0x0E40,
+ 0x0E02, 0x0E32, 0x0E2B, 0x0E25, 0x0E31, 0x0E07, 0x0E40, 0x0E25,
+ 0x0E47, 0x0E01, 0x0E40, 0x0E1E, 0x0E23, 0x0E32, 0x0E30, 0x0E44,
+ 0x0E21, 0x0E49, 0x0E2A, 0x0E23, 0x0E49, 0x0E32, 0x0E07, 0x0E1A,
+ 0x0E49, 0x0E32, 0x0E19, 0x0E15, 0x0E49, 0x0E2D, 0x0E07, 0x0E02,
+ 0x0E19, 0x0E21, 0x0E32, 0x0E14, 0x0E49, 0x0E27, 0x0E22, 0x0E40,
+ 0x0E01, 0x0E27, 0x0E35, 0x0E22, 0x0E19, 0x0E40, 0x0E1B, 0x0E47,
+ 0x0E19, 0x0E23, 0x0E30, 0x0E22, 0x0E30, 0x0E17, 0x0E32, 0x0E07,
+ 0x0E2B, 0x0E25, 0x0E32, 0x0E22, 0x0E44, 0x0E21, 0x0E25, 0x0E4C
+};
+
+LEGlyphID resultGlyphs3[] =
+{
+ 0x000000F3, 0x000000F0, 0x000000F0, 0x0000010E, 0x0000011D, 0x00000126, 0x000000F7, 0x0000010B,
+ 0x000000FB, 0x00000111, 0x00000119, 0x000000E4, 0x00000117, 0x000000DD, 0x000000FE, 0x000000F2,
+ 0x00000117, 0x000000ED, 0x00000117, 0x000000FC, 0x000000F1, 0x0000010E, 0x00000106, 0x0000010B,
+ 0x00000101, 0x0000010A, 0x000000FB, 0x00000106, 0x000000FB, 0x00000112, 0x0000013B, 0x000000F0,
+ 0x0000013B, 0x0000010B, 0x000000FA, 0x000000DA, 0x000000FE, 0x0000010B, 0x000000E0, 0x000000F0,
+ 0x00000111, 0x0000013B, 0x000000E0, 0x00000118, 0x00000104, 0x000000E6, 0x0000013B, 0x00000118,
+ 0x000000F2, 0x00000116, 0x000000DD, 0x000000F2, 0x000000E4, 0x0000010A, 0x00000103, 0x000000DA,
+ 0x0000010A, 0x000000F3, 0x000000FE, 0x00000111, 0x000000E0, 0x00000115, 0x00000107, 0x000000F2,
+ 0x000000FC, 0x0000010E, 0x000000E3, 0x0000010B, 0x00000100, 0x00000119, 0x000000FC, 0x0000013B,
+ 0x00000116, 0x000000FE, 0x00000109, 0x000000F4, 0x00000137, 0x0000010B, 0x00000115, 0x00000106,
+ 0x0000011C, 0x000000FA, 0x000000F9, 0x000000FC, 0x000000FC, 0x000000FB, 0x0000010B, 0x000000E3,
+ 0x0000010B, 0x00000100, 0x00000119, 0x000000FC, 0x0000013B, 0x000000F3, 0x0000013C, 0x0000010B,
+ 0x000000F2, 0x000000DB, 0x00000106, 0x000000E0, 0x000000F7, 0x00000100, 0x000000DA, 0x00000115,
+ 0x000000DB, 0x0000010B, 0x00000104, 0x000000FE, 0x0000010A, 0x000000E0, 0x00000115, 0x000000FE,
+ 0x0000011C, 0x000000DA, 0x00000115, 0x000000F7, 0x000000FC, 0x0000010B, 0x00000109, 0x00000119,
+ 0x000000FA, 0x0000013C, 0x00000103, 0x000000FC, 0x0000013C, 0x0000010B, 0x000000E0, 0x000000F3,
+ 0x0000013C, 0x0000010B, 0x000000F2, 0x000000EE, 0x0000013C, 0x00000106, 0x000000E0, 0x000000DB,
+ 0x000000F2, 0x000000FA, 0x0000010B, 0x000000ED, 0x0000013C, 0x00000100, 0x000000FB, 0x00000115,
+ 0x000000DA, 0x00000100, 0x0000010E, 0x000000FB, 0x000000F2, 0x00000115, 0x000000F4, 0x00000143,
+ 0x000000F2, 0x000000FC, 0x00000109, 0x000000FB, 0x00000109, 0x000000F0, 0x0000010B, 0x000000E0,
+ 0x00000104, 0x000000FE, 0x0000010B, 0x000000FB, 0x00000119, 0x000000FA, 0x000000FE, 0x0000013F
+};
+
+le_int32 resultGlyphCount3 = 168;
+
+le_int32 resultIndices3[] =
+{
+ 0x00000000, 0x00000001, 0x00000002, 0x00000003, 0x00000004, 0x00000005, 0x00000006, 0x00000007,
+ 0x00000008, 0x00000009, 0x0000000A, 0x0000000B, 0x0000000C, 0x0000000D, 0x0000000E, 0x0000000F,
+ 0x00000010, 0x00000011, 0x00000012, 0x00000013, 0x00000014, 0x00000015, 0x00000016, 0x00000017,
+ 0x00000018, 0x00000019, 0x0000001A, 0x0000001B, 0x0000001C, 0x0000001D, 0x0000001E, 0x0000001F,
+ 0x00000020, 0x00000021, 0x00000022, 0x00000023, 0x00000024, 0x00000025, 0x00000026, 0x00000027,
+ 0x00000028, 0x00000029, 0x0000002A, 0x0000002B, 0x0000002C, 0x0000002D, 0x0000002E, 0x0000002F,
+ 0x00000030, 0x00000031, 0x00000032, 0x00000033, 0x00000034, 0x00000035, 0x00000036, 0x00000037,
+ 0x00000038, 0x00000039, 0x0000003A, 0x0000003B, 0x0000003C, 0x0000003D, 0x0000003E, 0x0000003F,
+ 0x00000040, 0x00000041, 0x00000042, 0x00000043, 0x00000044, 0x00000045, 0x00000046, 0x00000047,
+ 0x00000048, 0x00000049, 0x0000004A, 0x0000004B, 0x0000004C, 0x0000004D, 0x0000004E, 0x0000004F,
+ 0x00000050, 0x00000051, 0x00000052, 0x00000053, 0x00000054, 0x00000055, 0x00000056, 0x00000057,
+ 0x00000058, 0x00000059, 0x0000005A, 0x0000005B, 0x0000005C, 0x0000005D, 0x0000005E, 0x0000005F,
+ 0x00000060, 0x00000061, 0x00000062, 0x00000063, 0x00000064, 0x00000065, 0x00000066, 0x00000067,
+ 0x00000068, 0x00000069, 0x0000006A, 0x0000006B, 0x0000006C, 0x0000006D, 0x0000006E, 0x0000006F,
+ 0x00000070, 0x00000071, 0x00000072, 0x00000073, 0x00000074, 0x00000075, 0x00000076, 0x00000077,
+ 0x00000078, 0x00000079, 0x0000007A, 0x0000007B, 0x0000007C, 0x0000007D, 0x0000007E, 0x0000007F,
+ 0x00000080, 0x00000081, 0x00000082, 0x00000083, 0x00000084, 0x00000085, 0x00000086, 0x00000087,
+ 0x00000088, 0x00000089, 0x0000008A, 0x0000008B, 0x0000008C, 0x0000008D, 0x0000008E, 0x0000008F,
+ 0x00000090, 0x00000091, 0x00000092, 0x00000093, 0x00000094, 0x00000095, 0x00000096, 0x00000097,
+ 0x00000098, 0x00000099, 0x0000009A, 0x0000009B, 0x0000009C, 0x0000009D, 0x0000009E, 0x0000009F,
+ 0x000000A0, 0x000000A1, 0x000000A2, 0x000000A3, 0x000000A4, 0x000000A5, 0x000000A6, 0x000000A7
+};
+
+float resultPositions3[] =
+{
+ 0.000000F, 0.000000F, 5.399414F, 0.000000F, 10.798828F, 0.000000F, 16.198242F, 0.000000F,
+ 16.198242F, 0.000000F, 16.198242F, 0.000000F, 21.046875F, 0.000000F, 26.616211F, 0.000000F,
+ 30.035156F, 0.000000F, 34.151367F, 0.000000F, 34.151367F, 0.000000F, 38.279297F, 0.000000F,
+ 43.558594F, 0.000000F, 47.663086F, 0.000000F, 52.438477F, 0.000000F, 57.178711F, 0.000000F,
+ 62.698242F, 0.000000F, 66.802734F, 0.000000F, 71.601563F, 0.000000F, 75.706055F, 0.000000F,
+ 79.810547F, 0.000000F, 84.369141F, 0.000000F, 84.369141F, 0.000000F, 89.097656F, 0.000000F,
+ 92.516602F, 0.000000F, 97.195313F, 0.000000F, 97.195313F, 0.000000F, 101.311523F, 0.000000F,
+ 106.040039F, 0.000000F, 110.156250F, 0.000000F, 110.156250F, 0.000000F, 110.156250F, 0.000000F,
+ 115.555664F, 0.000000F, 115.555664F, 0.000000F, 118.974609F, 0.000000F, 124.013672F, 0.000000F,
+ 128.765625F, 0.000000F, 133.505859F, 0.000000F, 136.924805F, 0.000000F, 140.704102F, 0.000000F,
+ 146.103516F, 0.000000F, 146.103516F, 0.000000F, 146.103516F, 0.000000F, 149.882813F, 0.000000F,
+ 153.553711F, 0.000000F, 159.158203F, 0.000000F, 165.421875F, 0.000000F, 165.421875F, 0.000000F,
+ 169.092773F, 0.000000F, 174.612305F, 0.000000F, 179.135742F, 0.000000F, 183.911133F, 0.000000F,
+ 189.430664F, 0.000000F, 194.709961F, 0.000000F, 194.709961F, 0.000000F, 199.989258F, 0.000000F,
+ 204.741211F, 0.000000F, 204.741211F, 0.000000F, 210.140625F, 0.000000F, 214.880859F, 0.000000F,
+ 214.880859F, 0.000000F, 218.660156F, 0.000000F, 220.675781F, 0.000000F, 225.128906F, 0.000000F,
+ 230.648438F, 0.000000F, 234.752930F, 0.000000F, 234.752930F, 0.000000F, 239.613281F, 0.000000F,
+ 243.032227F, 0.000000F, 247.280273F, 0.000000F, 251.408203F, 0.000000F, 255.512695F, 0.000000F,
+ 255.512695F, 0.000000F, 260.036133F, 0.000000F, 264.776367F, 0.000000F, 269.071289F, 0.000000F,
+ 274.470703F, 0.000000F, 274.470703F, 0.000000F, 277.889648F, 0.000000F, 279.905273F, 0.000000F,
+ 284.633789F, 0.000000F, 284.633789F, 0.000000F, 289.672852F, 0.000000F, 294.641602F, 0.000000F,
+ 298.746094F, 0.000000F, 302.850586F, 0.000000F, 306.966797F, 0.000000F, 310.385742F, 0.000000F,
+ 315.246094F, 0.000000F, 318.665039F, 0.000000F, 322.913086F, 0.000000F, 327.041016F, 0.000000F,
+ 331.145508F, 0.000000F, 331.145508F, 0.000000F, 336.544922F, 0.000000F, 336.544922F, 0.000000F,
+ 339.963867F, 0.000000F, 345.483398F, 0.000000F, 350.258789F, 0.000000F, 354.987305F, 0.000000F,
+ 358.766602F, 0.000000F, 364.335938F, 0.000000F, 368.583984F, 0.000000F, 373.335938F, 0.000000F,
+ 375.351563F, 0.000000F, 380.126953F, 0.000000F, 383.545898F, 0.000000F, 389.150391F, 0.000000F,
+ 393.890625F, 0.000000F, 393.890625F, 0.000000F, 397.669922F, 0.000000F, 399.685547F, 0.000000F,
+ 404.425781F, 0.000000F, 404.425781F, 0.000000F, 409.177734F, 0.000000F, 411.193359F, 0.000000F,
+ 416.762695F, 0.000000F, 420.867188F, 0.000000F, 424.286133F, 0.000000F, 428.581055F, 0.000000F,
+ 432.708984F, 0.000000F, 437.748047F, 0.000000F, 437.748047F, 0.000000F, 443.027344F, 0.000000F,
+ 447.131836F, 0.000000F, 447.131836F, 0.000000F, 450.550781F, 0.000000F, 454.330078F, 0.000000F,
+ 459.729492F, 0.000000F, 459.729492F, 0.000000F, 463.148438F, 0.000000F, 468.667969F, 0.000000F,
+ 473.478516F, 0.000000F, 473.478516F, 0.000000F, 478.207031F, 0.000000F, 481.986328F, 0.000000F,
+ 486.761719F, 0.000000F, 492.281250F, 0.000000F, 497.320313F, 0.000000F, 500.739258F, 0.000000F,
+ 505.538086F, 0.000000F, 505.538086F, 0.000000F, 509.786133F, 0.000000F, 513.902344F, 0.000000F,
+ 515.917969F, 0.000000F, 520.669922F, 0.000000F, 524.917969F, 0.000000F, 524.917969F, 0.000000F,
+ 529.034180F, 0.000000F, 534.553711F, 0.000000F, 536.569336F, 0.000000F, 541.968750F, 0.000000F,
+ 541.968750F, 0.000000F, 547.488281F, 0.000000F, 551.592773F, 0.000000F, 555.887695F, 0.000000F,
+ 560.003906F, 0.000000F, 564.298828F, 0.000000F, 569.698242F, 0.000000F, 573.117188F, 0.000000F,
+ 576.896484F, 0.000000F, 582.500977F, 0.000000F, 587.241211F, 0.000000F, 590.660156F, 0.000000F,
+ 594.776367F, 0.000000F, 598.904297F, 0.000000F, 603.943359F, 0.000000F, 608.683594F, 0.000000F,
+ 608.683594F, 0.000000F
+};
+
+
+TestInput testInputs[] =
+{
+ {"raghu.ttf", fontVersionString0, fontChecksum0, inputText0, 136, devaScriptCode, FALSE},
+ {"CODE2000.TTF", fontVersionString1, fontChecksum1, inputText1, 252, arabScriptCode, TRUE},
+ {"LucidaSansRegular.ttf", fontVersionString2, fontChecksum2, inputText2, 252, arabScriptCode, TRUE},
+ {"angsd___.ttf", fontVersionString3, fontChecksum3, inputText3, 168, thaiScriptCode, FALSE},
+};
+
+le_int32 testCount = ARRAY_LENGTH(testInputs);
+
+TestResult testResults[] =
+{
+ {resultGlyphCount0, resultGlyphs0, resultIndices0, resultPositions0},
+ {resultGlyphCount1, resultGlyphs1, resultIndices1, resultPositions1},
+ {resultGlyphCount2, resultGlyphs2, resultIndices2, resultPositions2},
+ {resultGlyphCount3, resultGlyphs3, resultIndices3, resultPositions3},
+};
+
Property changes on: trunk/source/test/letest/testdata.cpp
___________________________________________________________________
Name: svn:eol-style
+ native
More information about the sword-cvs
mailing list