File: teststylefile.cpp

package info (click to toggle)
fcitx5-anthy 5.1.7-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 784 kB
  • sloc: cpp: 7,594; makefile: 4; sh: 1
file content (67 lines) | stat: -rw-r--r-- 3,245 bytes parent folder | download
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/*
 *  SPDX-FileCopyrightText: 2023 CSSlayer <wengxt@gmail.com>
 *
 *  SPDX-License-Identifier: GPL-2.0-or-later
 */
#include "style_file.h"
#include "testdir.h"
#include <cstddef>
#include <fcitx-utils/log.h>
#include <string>
#include <string_view>
#include <tuple>
#include <vector>

int main() {
    StyleFile style;
    style.load(TESTING_SOURCE_DIR "/profile/101kana.sty");
    FCITX_ASSERT(style.title() == "101英語キーボード用かな配列");
    constexpr std::string_view section = "KanaTable/FundamentalTable";
    auto keys = style.getKeyList(section);
    FCITX_ASSERT(keys);
    std::vector<std::tuple<std::string, std::vector<std::string>>>
        expectedValues = {
            {"~", {"ろ"}},     {"1", {"ぬ"}},     {"2", {"", "ふ"}},
            {"3", {"あ"}},     {"4", {"う"}},     {"5", {"え"}},
            {"6", {"お"}},     {"7", {"や"}},     {"8", {"ゆ"}},
            {"9", {"よ"}},     {"0", {"わ"}},     {"-", {"", "ほ"}},
            {"=", {"", "へ"}}, {"q", {"", "た"}}, {"w", {"", "て"}},
            {"e", {"い"}},     {"r", {"", "す"}}, {"t", {"", "か"}},
            {"y", {"ん"}},     {"u", {"な"}},     {"i", {"に"}},
            {"o", {"ら"}},     {"p", {"", "せ"}}, {"[", {"゛"}},
            {"]", {"゜"}},     {"\\", {"む"}},    {"a", {"", "ち"}},
            {"s", {"", "と"}}, {"d", {"", "し"}}, {"f", {"", "は"}},
            {"g", {"", "き"}}, {"h", {"", "く"}}, {"j", {"ま"}},
            {"k", {"の"}},     {"l", {"り"}},     {";", {"れ"}},
            {"'", {"", "け"}}, {"z", {"", "つ"}}, {"x", {"", "さ"}},
            {"c", {"", "そ"}}, {"v", {"", "ひ"}}, {"b", {"", "こ"}},
            {"n", {"み"}},     {"m", {"も"}},     {",", {"ね"}},
            {".", {"る"}},     {"/", {"め"}},     {"`", {"ろ"}},
            {"!", {"ぬ"}},     {"@", {"", "ふ"}}, {"#", {"ぁ"}},
            {"$", {"ぅ"}},     {"%", {"ぇ"}},     {"^", {"ぉ"}},
            {"&", {"ゃ"}},     {"*", {"ゅ"}},     {"(", {"ょ"}},
            {")", {"を"}},     {"_", {"ー"}},     {"+", {"ゑ"}},
            {"Q", {"", "た"}}, {"W", {"", "て"}}, {"E", {"ぃ"}},
            {"R", {"", "す"}}, {"T", {"ヵ"}},     {"Y", {"ん"}},
            {"U", {"な"}},     {"I", {"に"}},     {"O", {"ら"}},
            {"P", {"", "せ"}}, {"{", {"「"}},     {"}", {"」"}},
            {"|", {"む"}},     {"A", {"", "ち"}}, {"S", {"", "と"}},
            {"D", {"", "し"}}, {"F", {"", "ゎ"}}, {"G", {"", "き"}},
            {"H", {"", "く"}}, {"J", {"ま"}},     {"K", {"の"}},
            {"L", {"り"}},     {":", {"れ"}},     {"\"", {"ヶ"}},
            {"Z", {"っ"}},     {"X", {"", "さ"}}, {"C", {"", "そ"}},
            {"V", {"", "ゐ"}}, {"B", {"", "こ"}}, {"N", {"み"}},
            {"M", {"も"}},     {"?", {"・"}},

        };
    FCITX_ASSERT(expectedValues.size() == keys->size());
    for (size_t i = 0; i < keys->size(); i++) {
        FCITX_ASSERT((*keys)[i] == std::get<0>(expectedValues[i]))
            << (*keys)[i] << " " << expectedValues[i];
        auto values = style.getStringArray(section, (*keys)[i]);
        FCITX_ASSERT(values);
        FCITX_ASSERT(*values == std::get<1>(expectedValues[i]));
    }

    return 0;
}