From 7f235e1d24ce525a2bd032cefa82d96ccfdc8a19 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Thu, 26 Dec 2019 23:05:57 +0300 Subject: Add implementation --- libicuuc/tests/.gitignore | 3 ++ libicuuc/tests/basic/buildfile | 7 +++ libicuuc/tests/basic/driver.c | 86 ++++++++++++++++++++++++++++++++++++ libicuuc/tests/basic/testscript | 9 ++++ libicuuc/tests/build/.gitignore | 3 ++ libicuuc/tests/build/bootstrap.build | 9 ++++ libicuuc/tests/build/root.build | 22 +++++++++ libicuuc/tests/buildfile | 5 +++ 8 files changed, 144 insertions(+) create mode 100644 libicuuc/tests/.gitignore create mode 100644 libicuuc/tests/basic/buildfile create mode 100644 libicuuc/tests/basic/driver.c create mode 100644 libicuuc/tests/basic/testscript create mode 100644 libicuuc/tests/build/.gitignore create mode 100644 libicuuc/tests/build/bootstrap.build create mode 100644 libicuuc/tests/build/root.build create mode 100644 libicuuc/tests/buildfile (limited to 'libicuuc/tests') diff --git a/libicuuc/tests/.gitignore b/libicuuc/tests/.gitignore new file mode 100644 index 0000000..2e508a9 --- /dev/null +++ b/libicuuc/tests/.gitignore @@ -0,0 +1,3 @@ +driver +test/ +test-*/ diff --git a/libicuuc/tests/basic/buildfile b/libicuuc/tests/basic/buildfile new file mode 100644 index 0000000..6934b21 --- /dev/null +++ b/libicuuc/tests/basic/buildfile @@ -0,0 +1,7 @@ +# file : tests/basic/buildfile +# copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC +# license : Unicode License; see accompanying LICENSE file + +import libs = libicuuc%lib{icuuc} + +exe{driver}: {h c}{*} $libs testscript diff --git a/libicuuc/tests/basic/driver.c b/libicuuc/tests/basic/driver.c new file mode 100644 index 0000000..92c2b7c --- /dev/null +++ b/libicuuc/tests/basic/driver.c @@ -0,0 +1,86 @@ +/* file : tests/basic/driver.c + * copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC + * license : Unicode License; see accompanying LICENSE file + */ +#include +#include + +#include +#include +#include +#include +#include + +/* Usage: argv[0] + * + * Test some basic libicuuc functionality: + * + * - query and print the library version + * - set, query and print the default locale + * - load a portion of the bundled data and print its format id/version + */ +int +main () +{ + /* Print version. + */ + UVersionInfo v; + u_getVersion (v); + + char s[U_MAX_VERSION_STRING_LENGTH]; + u_versionToString (v, s); + + printf ("version: %s\n", s); + + /* Change and print the current locale. + */ + UErrorCode e = U_ZERO_ERROR; + + uloc_setDefault ("en_GB", &e); + + if (U_FAILURE (e)) + { + fprintf (stderr, "uloc_setDefault failed: %s\n", u_errorName (e)); + u_cleanup (); + return 1; + } + + printf ("locale: %s\n", uloc_getDefault ()); + + /* Check that data is properly loaded from the libicudata's data bundle and + * print its format id/version. + */ + UDataMemory* d = udata_open (NULL, "res", "en_US", &e); + + if (U_FAILURE (e)) + { + fprintf (stderr, "udata_open failed: %s\n", u_errorName (e)); + u_cleanup (); + return 1; + } + + UDataInfo i; + i.size = sizeof (UDataInfo); + + udata_getInfo (d, &i); + + assert (i.isBigEndian == U_IS_BIG_ENDIAN); + assert (i.charsetFamily == U_CHARSET_FAMILY); + + printf ("data: %.4s/%u.%u.%u.%u %u.%u.%u.%u\n", + i.dataFormat, + i.formatVersion[0], + i.formatVersion[1], + i.formatVersion[2], + i.formatVersion[3], + i.dataVersion[0], + i.dataVersion[1], + i.dataVersion[2], + i.dataVersion[3]); + + udata_close (d); + + u_cleanup (); + + return 0; +} diff --git a/libicuuc/tests/basic/testscript b/libicuuc/tests/basic/testscript new file mode 100644 index 0000000..72fbe00 --- /dev/null +++ b/libicuuc/tests/basic/testscript @@ -0,0 +1,9 @@ +# file : tests/basic/testscript +# copyright : Copyright (c) 2016-2019 Code Synthesis Ltd +# license : Unicode License; see accompanying LICENSE file + +$* >>~%EOO% +%version: \d{2,}\.\d+(\.\d+)?% +%locale: en_GB% +%data: ResB/\d.\d.\d.\d \d.\d.\d.\d% +EOO diff --git a/libicuuc/tests/build/.gitignore b/libicuuc/tests/build/.gitignore new file mode 100644 index 0000000..4a730a3 --- /dev/null +++ b/libicuuc/tests/build/.gitignore @@ -0,0 +1,3 @@ +config.build +root/ +bootstrap/ diff --git a/libicuuc/tests/build/bootstrap.build b/libicuuc/tests/build/bootstrap.build new file mode 100644 index 0000000..17797c1 --- /dev/null +++ b/libicuuc/tests/build/bootstrap.build @@ -0,0 +1,9 @@ +# file : tests/build/bootstrap.build +# copyright : Copyright (c) 2016-2019 Code Synthesis Ltd +# license : Unicode License; see accompanying LICENSE file + +project = # Unnamed subproject. + +using config +using dist +using test diff --git a/libicuuc/tests/build/root.build b/libicuuc/tests/build/root.build new file mode 100644 index 0000000..be01522 --- /dev/null +++ b/libicuuc/tests/build/root.build @@ -0,0 +1,22 @@ +# file : tests/build/root.build +# copyright : Copyright (c) 2016-2019 Code Synthesis Ltd +# license : Unicode License; see accompanying LICENSE file + +using c + +h{*}: extension = h +c{*}: extension = c + +if ($c.target.system == 'win32-msvc') + c.poptions += -D_CRT_SECURE_NO_WARNINGS -D_SCL_SECURE_NO_WARNINGS + +if ($c.class == 'msvc') + c.coptions += /wd4251 /wd4275 /wd4800 + +# Every exe{} in this subproject is by default a test. +# +exe{*}: test = true + +# Specify the test target for cross-testing. +# +test.target = $c.target diff --git a/libicuuc/tests/buildfile b/libicuuc/tests/buildfile new file mode 100644 index 0000000..d976635 --- /dev/null +++ b/libicuuc/tests/buildfile @@ -0,0 +1,5 @@ +# file : tests/buildfile +# copyright : Copyright (c) 2016-2019 Code Synthesis Ltd +# license : Unicode License; see accompanying LICENSE file + +./: {*/ -build/} -- cgit v1.1