From 7f235e1d24ce525a2bd032cefa82d96ccfdc8a19 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Thu, 26 Dec 2019 23:05:57 +0300 Subject: Add implementation --- libicui18n/tests/.gitignore | 3 ++ libicui18n/tests/basic/buildfile | 8 ++++ libicui18n/tests/basic/driver.cpp | 85 ++++++++++++++++++++++++++++++++++ libicui18n/tests/basic/testscript | 7 +++ libicui18n/tests/build/.gitignore | 3 ++ libicui18n/tests/build/bootstrap.build | 9 ++++ libicui18n/tests/build/root.build | 24 ++++++++++ libicui18n/tests/buildfile | 5 ++ 8 files changed, 144 insertions(+) create mode 100644 libicui18n/tests/.gitignore create mode 100644 libicui18n/tests/basic/buildfile create mode 100644 libicui18n/tests/basic/driver.cpp create mode 100644 libicui18n/tests/basic/testscript create mode 100644 libicui18n/tests/build/.gitignore create mode 100644 libicui18n/tests/build/bootstrap.build create mode 100644 libicui18n/tests/build/root.build create mode 100644 libicui18n/tests/buildfile (limited to 'libicui18n/tests') diff --git a/libicui18n/tests/.gitignore b/libicui18n/tests/.gitignore new file mode 100644 index 0000000..2e508a9 --- /dev/null +++ b/libicui18n/tests/.gitignore @@ -0,0 +1,3 @@ +driver +test/ +test-*/ diff --git a/libicui18n/tests/basic/buildfile b/libicui18n/tests/basic/buildfile new file mode 100644 index 0000000..d4e9ead --- /dev/null +++ b/libicui18n/tests/basic/buildfile @@ -0,0 +1,8 @@ +# file : tests/basic/buildfile +# copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC +# license : Unicode License; see accompanying LICENSE file + +import libs = libicui18n%lib{icui18n} +import libs += libicuuc%lib{icuuc} + +exe{driver}: {hxx cxx}{*} $libs testscript diff --git a/libicui18n/tests/basic/driver.cpp b/libicui18n/tests/basic/driver.cpp new file mode 100644 index 0000000..f9bf704 --- /dev/null +++ b/libicui18n/tests/basic/driver.cpp @@ -0,0 +1,85 @@ +// file : tests/basic/driver.cpp +// copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC +// license : Unicode License; see accompanying LICENSE file + +#include +#include // unique_ptr +#include +#include +#include // runtime_error + +#include +#include + +#include +#include +#include +#include + +// Usage: argv[0] +// +// Print the full 01/01/2020 00:00 time in Berlin's timezone using the +// specified locale. +// +int +main (int argc, char* argv[]) +{ + using namespace std; + using namespace icu; + + assert (argc == 2); + const char* locale (argv[1]); + + UErrorCode e (U_ZERO_ERROR); + + auto validate = [&e] (const char* what) + { + if (U_FAILURE (e)) + throw runtime_error (string (what) + " failed: " + u_errorName (e)); + }; + + int r (0); + + try + { + unique_ptr cal (Calendar::createInstance (e)); + validate ("Calendar::createInstance()"); + + cal->adoptTimeZone (TimeZone::createTimeZone ("Europe/Berlin")); + cal->clear (); + cal->set (2020, Calendar::JANUARY, 1); + + UDate date (cal->getTime (e)); + validate ("Calendar::getTime()"); + + unique_ptr fmt ( + DateFormat::createDateTimeInstance (DateFormat::kFull, + DateFormat::kFull, + locale)); + + fmt->setCalendar (*cal); + + UnicodeString us; + fmt->format(date, us, e); + validate ("DateFormat::format()"); + + string s; + StringByteSink bs (&s); + us.toUTF8 (bs); + + cout << s << endl; + } + catch (const runtime_error& e) + { + cerr << e.what () << endl; + + r = 1; + } + + // Free any heap storage that has been potentially allocated and held by the + // ICU library. + // + u_cleanup (); + + return r; +} diff --git a/libicui18n/tests/basic/testscript b/libicui18n/tests/basic/testscript new file mode 100644 index 0000000..dc6fad8 --- /dev/null +++ b/libicui18n/tests/basic/testscript @@ -0,0 +1,7 @@ +# file : tests/basic/testscript +# copyright : Copyright (c) 2016-2019 Code Synthesis Ltd +# license : Unicode License; see accompanying LICENSE file + +$* "de" >>EOO +Mittwoch, 1. Januar 2020 um 00:00:00 Mitteleuropäische Normalzeit +EOO diff --git a/libicui18n/tests/build/.gitignore b/libicui18n/tests/build/.gitignore new file mode 100644 index 0000000..4a730a3 --- /dev/null +++ b/libicui18n/tests/build/.gitignore @@ -0,0 +1,3 @@ +config.build +root/ +bootstrap/ diff --git a/libicui18n/tests/build/bootstrap.build b/libicui18n/tests/build/bootstrap.build new file mode 100644 index 0000000..17797c1 --- /dev/null +++ b/libicui18n/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/libicui18n/tests/build/root.build b/libicui18n/tests/build/root.build new file mode 100644 index 0000000..e8283ae --- /dev/null +++ b/libicui18n/tests/build/root.build @@ -0,0 +1,24 @@ +# file : tests/build/root.build +# copyright : Copyright (c) 2016-2019 Code Synthesis Ltd +# license : Unicode License; see accompanying LICENSE file + +cxx.std = 14 + +using cxx + +hxx{*}: extension = h +cxx{*}: extension = cpp + +if ($cxx.target.system == 'win32-msvc') + cxx.poptions += -D_CRT_SECURE_NO_WARNINGS -D_SCL_SECURE_NO_WARNINGS + +if ($cxx.class == 'msvc') + cxx.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 = $cxx.target diff --git a/libicui18n/tests/buildfile b/libicui18n/tests/buildfile new file mode 100644 index 0000000..d976635 --- /dev/null +++ b/libicui18n/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