summaryrefslogtreecommitdiff
path: root/libicuuc/tests
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2019-12-26 23:05:57 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2020-01-27 22:47:56 +0300
commit7f235e1d24ce525a2bd032cefa82d96ccfdc8a19 (patch)
treeb0df84d85c53aae6718e76af8ce3bdd557270f0c /libicuuc/tests
parentbda94b275036150b568364fe3e5f96e04ed41fc3 (diff)
Add implementation
Diffstat (limited to 'libicuuc/tests')
-rw-r--r--libicuuc/tests/.gitignore3
-rw-r--r--libicuuc/tests/basic/buildfile7
-rw-r--r--libicuuc/tests/basic/driver.c86
-rw-r--r--libicuuc/tests/basic/testscript9
-rw-r--r--libicuuc/tests/build/.gitignore3
-rw-r--r--libicuuc/tests/build/bootstrap.build9
-rw-r--r--libicuuc/tests/build/root.build22
-rw-r--r--libicuuc/tests/buildfile5
8 files changed, 144 insertions, 0 deletions
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 <stdio.h>
+#include <assert.h>
+
+#include <unicode/uloc.h>
+#include <unicode/udata.h>
+#include <unicode/uclean.h>
+#include <unicode/utypes.h>
+#include <unicode/uversion.h>
+
+/* 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/}