spiegel-keyman/core/tests/unit/ldml
Marc Durdin 57f0dc4597 fix(developer): validate id and modifiers attributes in Layr compiler
Per the spec, the `id` attribute is required for touch layers, and
`modifiers` attribute is required for hardware layers. There is
ambiguity in the spec at present as to whether they should be allowed
for the alternative type.

* Validate that the attributes are present where required.
* Tighten validation of `modifiers` attribute - it cannot be empty or
  missing for hardware; "" != "none".
* Hint if the attribute is present when it probably shouldn't be (to be
  potentially raised to warning or error after spec clarified).
* Fixup all keyboard3 xml files to conform to spec and eliminate hints.
* Add unit tests.
* Removed threshold warning for coverage as kmc-ldml is already > 90%.

Fixes: #12423
2026-08-28 13:21:12 +02:00
..
invalid-keyboards fix(developer): validate id and modifiers attributes in Layr compiler 2026-08-28 13:21:12 +02:00
keyboards fix(developer): validate id and modifiers attributes in Layr compiler 2026-08-28 13:21:12 +02:00
context_normalization.tests.cpp chore(core): Merge branch 'master' into fix/core/12619-disable-assertions-vcwin-release-build 2024-12-01 16:17:21 +07:00
core_ldml_min.tests.cpp chore(core): remove km_core_keyboard_load API 2024-12-04 13:38:07 +07:00
kmx_plus.tests.cpp feat(core): improve kmxplus validation tests 2025-03-18 11:08:44 -05:00
ldml.cpp fix(core): changed ldml tests to use context list instead of vector 2026-02-18 16:08:59 +01:00
ldml_test_source.cpp fix(core): handle backspace decomposition 2026-01-25 07:24:15 +11:00
ldml_test_source.hpp Merge remote-tracking branch 'origin/master' into fix/core/12298-get-key-list 2024-12-04 13:58:24 -06:00
ldml_test_utils.cpp chore(linux): Rename namespace kbp to core 2023-10-19 10:39:55 +02:00
ldml_test_utils.hpp refactor(core): split context API from Core primary API 2024-01-17 14:44:25 +11:00
meson.build feat(core): move kmx_plus.tests.cpp to GTest 2025-03-13 15:05:55 -05:00
README.md feat(core): ldml unit tests and stub actions 2022-08-07 08:02:50 -05:00
transforms.tests.cpp chore(core): Merge branch 'master' into fix/core/12619-disable-assertions-vcwin-release-build 2024-11-28 09:53:45 +07:00
unicode.tests.cpp fix(core): normalization segment should end on NFC boundary, not NFD 2026-01-28 14:32:25 +11:00
write_node_versions.js fix(core): add a test to verify ICU and Unicode version 2024-05-23 09:31:15 -05:00

LDML unit tests

This directory contains unit tests that test the LDML keyboard processing.

The driver (ldml.cpp) loads and executes the tests. Each test consist of a Keyman keyboard source file (*.xml) and the compiled KMXPlus keyboard. The source file contains rules and defines the setup, input and expected results.

Defining tests in the .xml file

Somewhere near the top of the file, an XML comment contains lines that define the setup, input and expected results.

Setup

  • description: this is just for commenting what we test here
@@description: Tests Caps Lock env set
  • capsLock: allows to set the caps lock state. The example below turns caps-lock on at the start of the test. [K_CAPS] in the keys comment allows toggling of caps lock.
@@capsLock: 1
  • context: allows to setup a string which serves as context
@@context:

Input

  • keys: defines one or more virtual keys that will be processed one after the other
@@keys: [K_1][K_CAPS][K_2][SHIFT K_3][K_4][K_CAPS][K_5][K_CAPS][K_6]

Expected Result

  • expected: the resulting string of processing the input keys. In the example below each key press is expected to output the string 'pass.'.
@@expected: pass.pass.pass.pass.pass.pass.

Running the tests

All tests can be run at once with ./build.sh --debug tests.

Alternatively it's possible to run a single test with:

cd core
build/arch/debug/tests/unit/ldml/ldml 'tests/unit/ldml/000_test_zero.xml' 'tests/unit/ldml/000_test_zero.kmx'