File: core_ldml_min.tests.cpp

package info (click to toggle)
keyman 18.0.246-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 21,316 kB
  • sloc: python: 52,784; cpp: 21,289; sh: 7,633; ansic: 4,823; xml: 3,617; perl: 959; makefile: 139; javascript: 138
file content (43 lines) | stat: -rw-r--r-- 1,502 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/*
  Copyright:    © SIL International.
  Description:  Minimal, hermetic Keyman core test.
  Create Date:  6 Jan 2024
  Authors:      Steven R. Loomis

  This is a different kind of a test. It's a very minimal test of the core API.
  It does not have any file i/o other than console output and return code.

  This test is expected to fail with an assertion failure. It's to exercise the API.
*/

#include <iostream>
#include <test_assert.h>

#include "keyman_core.h"
#include "../load_kmx_file.hpp"

int main(int argc, const char *argv[]) {

    // "load" our "keyboard"
    km_core_keyboard * test_kb = nullptr;

    km_core_status status;
    km_core_path_name nowhere = {0}; // this is a narrow or wide char string
    auto blob = km::tests::load_kmx_file(nowhere);
    status = km_core_keyboard_load_from_blob(nowhere, blob.data(), blob.size(), &test_kb);

    std::cerr << "null km_core_keyboard_load_from_blob = " << status << std::endl;
    test_assert(status == KM_CORE_STATUS_INVALID_ARGUMENT);
    test_assert(test_kb == nullptr);
    km_core_keyboard_dispose(test_kb);
    km_core_state_dispose(nullptr);
    km_core_cu_dispose(nullptr);

    status = km_core_process_event(nullptr, 0, 0, 0, 0);
    /* Note: an assertion fails in km_core_process_event on debug builds,
       but we will fail on the line below on release builds (as assertions
       are disabled); actual return value is KM_CORE_STATUS_INVALID_ARGUMENT */
    test_assert(status == KM_CORE_STATUS_OK);

    return 0;
}