diff --git a/core/tests/unit/ldml/meson.build b/core/tests/unit/ldml/meson.build index 9e65ff343d7..79d7e938aca 100644 --- a/core/tests/unit/ldml/meson.build +++ b/core/tests/unit/ldml/meson.build @@ -91,14 +91,26 @@ if cpp_compiler.get_id() == 'emscripten' normalization_tests_flags += ['-lnodefs.js', '-sEXPORTED_RUNTIME_METHODS=[\'UTF8ToString\']'] endif -t = executable('test_context_normalization', +tc = executable('test_context_normalization', ['test_context_normalization.cpp', '../emscripten_filesystem.cpp'], cpp_args: defns + warns, include_directories: [inc, libsrc, '../../../../developer/src/ext/json'], link_args: links + normalization_tests_flags, dependencies: [icu_uc, icu_i18n], objects: lib.extract_all_objects(recursive: false)) -test('test_context_normalization', t, suite: 'ldml') +test('test_context_normalization', tc, suite: 'ldml') + +# Build and run additional test_unicode test + +u = executable('test_unicode', 'test_unicode.cpp', + 'test_unicode.cpp', + cpp_args: defns + warns, + include_directories: [inc, libsrc, '../../../../developer/src/ext/json'], + link_args: links + tests_flags, + dependencies: [icu_uc, icu_i18n], + objects: lib.extract_all_objects(recursive: false)) +test('test_unicode', u, suite: 'ldml') + # Run tests on all keyboards (`tests` defined in keyboards/meson.build) diff --git a/core/tests/unit/ldml/test_unicode.cpp b/core/tests/unit/ldml/test_unicode.cpp new file mode 100644 index 00000000000..6a3ac1cce95 --- /dev/null +++ b/core/tests/unit/ldml/test_unicode.cpp @@ -0,0 +1,72 @@ +/* + Copyright: © 2024 SIL International. + Description: Tests for normalization in the context API. + Create Date: 3 May 2024 + Authors: Steven R. Loomis + History: 3 May 2024 - SRL - Initial implementation. +*/ + +#include +#include "keyman_core.h" + +#include "path.hpp" +#include "action.hpp" + +#include +#include "../emscripten_filesystem.h" +#include +#include + +//------------------------------------------------------------------------------------- +// Unicode version tests +//------------------------------------------------------------------------------------- + +std::string arg_path; + +void test_unicode_versions() { + std::cout << "== " << __FUNCTION__ << std::endl; + + std::cout << "ICU: " << U_ICU_VERSION << std::endl; + std::cout << "Unicode: " << U_UNICODE_VERSION << std::endl; + +} + +void test_all() { + std::cout << "= " << __FUNCTION__ << std::endl; + test_unicode_versions(); +} + +//------------------------------------------------------------------------------------- +// Launcher +//------------------------------------------------------------------------------------- + +constexpr const auto help_str = "\ +test_unicode [--color]\n\ +\n\ + --color Force color output\n"; + +int error_args() { + std::cerr << "test_unicode: Invalid arguments." << std::endl; + std::cout << help_str; + return 1; +} + +int main(int argc, char *argv []) { + auto arg_color = argc > 1 && std::string(argv[1]) == "--color"; + console_color::enabled = console_color::isaterminal() || arg_color; + + // Get the path of the current executable + arg_path = argv[0]; + auto last = arg_path.find_last_of("/\\"); + if(last == std::string::npos) { + std::cerr << "could not parse argv[0]: " << argv[0] << std::endl; + return 1; + } + arg_path.resize(last+1); + +#ifdef __EMSCRIPTEN__ + arg_path = get_wasm_file_path(arg_path); +#endif + + test_all(); +}