Created
September 15, 2017 09:26
-
-
Save rvolosatovs/ed473b0830e174f3000128d0d7b12046 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"testing" | |
"github.com/smartystreets/assertions" | |
"github.com/smartystreets/assertions/should" | |
"github.com/stretchr/testify/assert" | |
) | |
const line = "--------------------------------------------------------------------------------" | |
type T struct { | |
name string | |
} | |
func (t T) Errorf(format string, args ...interface{}) { | |
fmt.Printf("%s\nOutput of %s:\n%s\n%s\n%s\n", line, t.name, line, fmt.Sprintf(format, args...), line) | |
} | |
func (t T) Error(args ...interface{}) { | |
fmt.Printf("%s\nOutput of %s:\n%s\n%s\n%s\n", line, t.name, line, fmt.Sprint(args...), line) | |
} | |
func TestTest(_ *testing.T) { | |
type SubStruct struct { | |
A int | |
B int | |
C int | |
} | |
type Struct struct { | |
Slice []int | |
Map map[string]string | |
SubStructs []SubStruct | |
String string | |
} | |
common := SubStruct{1, 2, 3} | |
a := Struct{ | |
[]int{1, 2, 3}, | |
map[string]string{"foo": "bar", "hello": "world"}, | |
[]SubStruct{}, | |
"test", | |
} | |
b := Struct{ | |
[]int{1, 2, 3}, | |
map[string]string{"bar": "foo", "hello": "world"}, | |
[]SubStruct{}, | |
"test", | |
} | |
for i := 0; i < 20; i++ { | |
a.SubStructs = append(a.SubStructs, common) | |
b.SubStructs = append(b.SubStructs, common) | |
} | |
a.SubStructs = append(a.SubStructs, SubStruct{1, 2, 2}) | |
b.SubStructs = append(a.SubStructs, SubStruct{1, 2, 3}) | |
assertions.New(T{"github.com/smartystreets/assertions"}).So(a, should.Resemble, b) | |
assert.Equal(T{"github.com/stretchr/testify/assert"}, a, b) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment