File: integration_test.go

package info (click to toggle)
golang-check.v1 0.0%2Bgit20200902.038fdea-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bookworm-proposed-updates, bullseye
  • size: 308 kB
  • sloc: makefile: 2
file content (94 lines) | stat: -rw-r--r-- 2,377 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
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
91
92
93
94
// Integration tests

package check_test

import (
	. "gopkg.in/check.v1"
)

// -----------------------------------------------------------------------
// Integration test suite.

type integrationS struct{}

var _ = Suite(&integrationS{})

type integrationTestHelper struct{}

func (s *integrationTestHelper) TestMultiLineStringEqualFails(c *C) {
	c.Check("foo\nbar\nbaz\nboom\n", Equals, "foo\nbaar\nbaz\nboom\n")
}

func (s *integrationTestHelper) TestStringEqualFails(c *C) {
	c.Check("foo", Equals, "bar")
}

func (s *integrationTestHelper) TestIntEqualFails(c *C) {
	c.Check(42, Equals, 43)
}

type complexStruct struct {
	r, i int
}

func (s *integrationTestHelper) TestStructEqualFails(c *C) {
	c.Check(complexStruct{1, 2}, Equals, complexStruct{3, 4})
}

func (s *integrationS) TestOutput(c *C) {
	helper := integrationTestHelper{}
	output := String{}
	Run(&helper, &RunConf{Output: &output})
	c.Assert(output.value, Equals, `
----------------------------------------------------------------------
FAIL: integration_test.go:26: integrationTestHelper.TestIntEqualFails

integration_test.go:27:
    c.Check(42, Equals, 43)
... obtained int = 42
... expected int = 43


----------------------------------------------------------------------
FAIL: integration_test.go:18: integrationTestHelper.TestMultiLineStringEqualFails

integration_test.go:19:
    c.Check("foo\nbar\nbaz\nboom\n", Equals, "foo\nbaar\nbaz\nboom\n")
... obtained string = "" +
...     "foo\n" +
...     "bar\n" +
...     "baz\n" +
...     "boom\n"
... expected string = "" +
...     "foo\n" +
...     "baar\n" +
...     "baz\n" +
...     "boom\n"
... String difference:
...     [1]: "bar" != "baar"



----------------------------------------------------------------------
FAIL: integration_test.go:22: integrationTestHelper.TestStringEqualFails

integration_test.go:23:
    c.Check("foo", Equals, "bar")
... obtained string = "foo"
... expected string = "bar"


----------------------------------------------------------------------
FAIL: integration_test.go:34: integrationTestHelper.TestStructEqualFails

integration_test.go:35:
    c.Check(complexStruct{1, 2}, Equals, complexStruct{3, 4})
... obtained check_test.complexStruct = check_test.complexStruct{r:1, i:2}
... expected check_test.complexStruct = check_test.complexStruct{r:3, i:4}
... Difference:
...     r: 1 != 3
...     i: 2 != 4


`)
}