File: assert_test.go

package info (click to toggle)
golang-github-bruth-assert 0.0+git20130823.de420fa-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 72 kB
  • sloc: makefile: 2
file content (90 lines) | stat: -rw-r--r-- 1,735 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
package assert

import (
    "testing"
)

type MyStruct struct {
    Sub *MyStruct
}

func TestEqual(t *testing.T) {
    Equal(t, "foo", "foo")
    Equal(t, true, true)

    myStructA := MyStruct{}
    myStructB := MyStruct{}
    Equal(t, myStructA, myStructB)

    // Equal(t, "foo", "bar", "this should blow up")
}

func TestNotEqual(t *testing.T) {
    NotEqual(t, "foo", "bar", "msg!")
    NotEqual(t, nil, false)

    myStructA := MyStruct{}
    myStructB := MyStruct{&myStructA}
    NotEqual(t, myStructA, myStructB)
    NotEqual(t, &myStructA, myStructA)

    // NotEqual(t, "foo", "foo", "this should blow up")
}

func TestTrue(t *testing.T) {
    True(t, true)
}

func TestFalse(t *testing.T) {
    False(t, false)
}

func TestNil(t *testing.T) {
    Nil(t, nil)

    var nilChan chan int
    Nil(t, nilChan)

    var nilFunc func(int) int
    Nil(t, nilFunc)

    var nilInterface interface{}
    Nil(t, nilInterface)

    var nilMap map[string]string
    Nil(t, nilMap)

    var myStruct MyStruct
    Nil(t, myStruct.Sub) // nil pointer

    var nilSlice []string
    Nil(t, nilSlice)

    // Nil(t, "foo", "this should blow up")
}

func TestNotNil(t *testing.T) {
    NotNil(t, "foo")

    myStruct := MyStruct{}
    NotNil(t, myStruct)
    NotNil(t, &myStruct)

    // NotNil(t, nil, "this should blow up")
    // var myNilStruct MyStruct
    // NotNil(t, myNilStruct, "this should blow up")
}

func TestContains(t *testing.T) {
    Contains(t, "foo", "bizmarfooba")
    Contains(t, "", "bizmarfooba")

    // Contains(t, "cool", "", "This should blow up")
}

func TestNotContains(t *testing.T) {
    NotContains(t, "a", "")
    NotContains(t, "Lorem", "lorem")

    // NotContains(t, "c", "abc", "This should blow up")
}