File: template.vala

package info (click to toggle)
libkkc 0.3.5-13
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,904 kB
  • sloc: ansic: 7,099; makefile: 917; cpp: 435; python: 231; sh: 124
file content (58 lines) | stat: -rw-r--r-- 1,613 bytes parent folder | download | duplicates (3)
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
class TemplateTests : Kkc.TestCase {
    public TemplateTests () {
        base ("Template");

        add_test ("properties", this.test_properties);
    }

    void test_properties () {
        Kkc.Template template;
        string? source = null;
        bool okuri;

        template = new Kkc.SimpleTemplate ("source");
        template.get ("source", out source,
                      "okuri", out okuri);
        assert (source == "source");
        assert (!okuri);

        template = new Kkc.OkuriganaTemplate ("かう", 1);
        source = null;
        template.get ("source", out source,
                      "okuri", out okuri);

        assert (source == "かu");
        assert (okuri);

        template = new Kkc.NumericTemplate ("だい11かい");
        source = null;
        template.get ("source", out source,
                      "okuri", out okuri);

        assert (source == "だい#かい");
        assert (!okuri);

        assert (template.expand ("第#0回") == "第11回");
        assert (template.expand ("第#1回") == "第11回");
        assert (template.expand ("第#2回") == "第一一回");
        assert (template.expand ("第#3回") == "第十一回");

        // Unsupported.
        assert (template.expand ("第#4回") == "第11回");
        assert (template.expand ("第#9回") == "第11回");
    }
}

int main (string[] args) {
    Intl.setlocale (LocaleCategory.ALL, "");

    Test.init (ref args);
    Kkc.init ();

    TestSuite root = TestSuite.get_root ();
    root.add_suite (new TemplateTests ().get_suite ());

    Test.run ();

    return 0;
}