Skip to content

Commit

Permalink
more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
samber committed May 9, 2024
1 parent 89e9eb8 commit 668e292
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ Not supported (yet?):
- structs in anonymous types
- structs in function input or output
- structs in generic type
- `any("foobar")` reported as `string` instead of `any` (see #2)

## Examples

Expand Down Expand Up @@ -104,7 +105,7 @@ func main() {

## 🤝 Contributing

- Ping me on twitter [@samuelberthe](https://twitter.com/samuelberthe) (DMs, mentions, whatever :))
- Ping me on Twitter [@samuelberthe](https://twitter.com/samuelberthe) (DMs, mentions, whatever :))
- Fork the [project](https://github.com/samber/go-type-to-string)
- Fix [open issues](https://github.com/samber/go-type-to-string/issues) or request new features

Expand Down
11 changes: 10 additions & 1 deletion converter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,8 @@ func TestGetType(t *testing.T) {
is.Equal("interface {}", name)
name = GetType[*any]()
is.Equal("*interface {}", name)
name = GetType[**any]()
is.Equal("**interface {}", name)

// all mixed
name = GetType[[]chan *[]*map[*testStruct][]map[chan int]*map[testInterface]func(int, string) bool]()
Expand All @@ -163,11 +165,18 @@ func TestGetValueType(t *testing.T) {

a = ""
name = GetValueType(a)
is.Equal("interface {}", name) // not string
is.Equal("interface {}", name) // not string ?

a = ""
name = GetValueType(&a)
is.Equal("*interface {}", name)

a = 42
name = GetValueType(a)
is.Equal("interface {}", name) // not int ?

name = GetValueType(any("42"))
is.Equal("interface {}", name) // not string ?
}

func TestGetReflectValueType(t *testing.T) {
Expand Down

0 comments on commit 668e292

Please sign in to comment.