File: rule.vala

package info (click to toggle)
libkkc 0.3.5-11
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 2,908 kB
  • sloc: ansic: 7,099; makefile: 917; cpp: 435; python: 231; sh: 124
file content (75 lines) | stat: -rw-r--r-- 1,837 bytes parent folder | download | duplicates (6)
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
68
69
70
71
72
73
74
75
class RuleTests : Kkc.TestCase {
    public RuleTests () {
        base ("Rule");

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

    void test_properties () {
        var rule = new Kkc.Rule (Kkc.RuleMetadata.find ("default"));
        Kkc.RuleMetadata metadata;
        rule.get ("metadata", out metadata);
    }

    void test_load () {
        const string good[] = {
            "test-empty"
        };

        const string bad[] = {
            "test-bad1",
            "test-bad2",
            "test-bad3",
            "test-bad4",
            "test-bad5",
            "test-bad6",
            "test-bad7",
            "test-bad8",
            "test-bad9",
            "test-bad10"
        };

        foreach (var name in good) {
            var metadata = Kkc.RuleMetadata.find (name);
            try {
                var rule = new Kkc.Rule (metadata);
            } catch (Error e) {
                assert_not_reached ();
            }
        }

        foreach (var name in bad) {
            var metadata = Kkc.RuleMetadata.find (name);
            try {
                var rule = new Kkc.Rule (metadata);
                assert_not_reached ();
            } catch (Error e) {
            }
        }

        var srcdir = Environment.get_variable ("srcdir");
        assert (srcdir != null);

        try {
            new Kkc.RuleMetadata (
                "bad",
                Path.build_filename (srcdir,
                                     "rule-metadata-bad.json"));
            assert_not_reached ();
        } catch (Error e) {
        }
    }
}

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

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

    Test.run ();

    return 0;
}