gotestyourself / gotestyourself/gotest.tools

Feature: Implement data type comparison

Open
#161 4 comments 0 reactions 0 assignees View on GitHub
documentation question
Dominant language
Go
Stars
576
Forks
54
Avg merge
6d 3h
Merged PRs (30d)
2

Description

In order to compare between data types, I am doing

```go
type (
CustomInterface interface {
Foo() string
}

CustomType1 struct { }
CustomType2 struct { }
)

func (ct1 CustomType1) Foo() {}
func (ct2 CustomType2) Foo() {}

...

func TestType(t testing.T) {
var i interface{} = &CustomType1{}

_, isType1 := i.(CustomType1)
_, isType2 := i.(CustomType1)

assert.Assert(t, isType1) // Success
assert.Assert(t, isType2) // Fail
}
```

It would be better if

```golang
customType := &CustomType1{}

assert.Assert(t, is.SameType(customType, CustomType1) // Success
assert.Assert(t, is.SameType(customType, CustomType2) // Fail
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.