File: dictionary-list.vala

package info (click to toggle)
libkkc 0.3.5-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 2,728 kB
  • ctags: 136
  • sloc: ansic: 7,099; makefile: 920; cpp: 435; python: 233; sh: 124
file content (58 lines) | stat: -rw-r--r-- 1,776 bytes parent folder | download | duplicates (5)
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 DictionaryListTests : Kkc.TestCase {
    public DictionaryListTests () {
        base ("DictionaryList");

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

    void test_properties () {
        var dictionaries = new Kkc.DictionaryList ();
        int size;
        dictionaries.get ("size", out size);

        var enum_class = (EnumClass) typeof (Kkc.DictionaryCallbackReturn).class_ref ();
        for (int i = enum_class.minimum; i <= enum_class.maximum; i++) {
            var enum_value = enum_class.get_value (i);
            assert (enum_value != null);
        }
    }

    void test_collection () {
        var dictionaries = new Kkc.DictionaryList ();

        Kkc.Dictionary? system_segment_dictionary = null;
        try {
            var srcdir = Environment.get_variable ("srcdir");
            assert (srcdir != null);
            system_segment_dictionary = new Kkc.SystemSegmentDictionary (
                Path.build_filename (srcdir, "system-segment-dictionary"));
        } catch (Error e) {
            stderr.printf ("%s\n", e.message);
        }
        dictionaries.add (system_segment_dictionary);
        assert (dictionaries.size == 1);

        var empty_dictionary = new Kkc.EmptySegmentDictionary ();
        dictionaries.add (empty_dictionary);
        assert (dictionaries.size == 2);

        dictionaries.remove (empty_dictionary);
        assert (dictionaries.size == 1);

        dictionaries.clear ();
        assert (dictionaries.size == 0);
    }
}

int main (string[] args) {
    Test.init (ref args);
    Kkc.init ();

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

    Test.run ();

    return 0;
}