aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/ext_depends/D-YAML/source/dyaml/test/errors.d
blob: 43b019c8cb24963540b1caabb419166fbe88d29e (plain)
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
//          Copyright Ferdinand Majerech 2011-2014
// Distributed under the Boost Software License, Version 1.0.
//    (See accompanying file LICENSE_1_0.txt or copy at
//          http://www.boost.org/LICENSE_1_0.txt)

module dyaml.test.errors;

@safe unittest
{
    import std.array : array;
    import std.exception : assertThrown;

    import dyaml : Loader;
    import dyaml.test.common : run;

    /**
    Loader error unittest from file stream.

    Params:  errorFilename = File name to read from.
    */
    static void testLoaderError(string errorFilename) @safe
    {
        assertThrown(Loader.fromFile(errorFilename).array,
            __FUNCTION__ ~ "(" ~ errorFilename ~ ") Expected an exception");
    }

    /**
    Loader error unittest from string.

    Params:  errorFilename = File name to read from.
    */
    static void testLoaderErrorString(string errorFilename) @safe
    {
        assertThrown(Loader.fromFile(errorFilename).array,
            __FUNCTION__ ~ "(" ~ errorFilename ~ ") Expected an exception");
    }

    /**
    Loader error unittest from filename.

    Params:  errorFilename = File name to read from.
    */
    static void testLoaderErrorFilename(string errorFilename) @safe
    {
        assertThrown(Loader.fromFile(errorFilename).array,
            __FUNCTION__ ~ "(" ~ errorFilename ~ ") Expected an exception");
    }

    /**
    Loader error unittest loading a single document from a file.

    Params:  errorFilename = File name to read from.
    */
    static void testLoaderErrorSingle(string errorFilename) @safe
    {
        assertThrown(Loader.fromFile(errorFilename).load(),
            __FUNCTION__ ~ "(" ~ errorFilename ~ ") Expected an exception");
    }
    run(&testLoaderError, ["loader-error"]);
    run(&testLoaderErrorString, ["loader-error"]);
    run(&testLoaderErrorFilename, ["loader-error"]);
    run(&testLoaderErrorSingle, ["single-loader-error"]);
}