Skip to content

Commit

Permalink
[dev.typealias] reflect: add test for type aliases
Browse files Browse the repository at this point in the history
For #18130.

Change-Id: Idd77cb391178c185227cfd779c70fec16351f825
Reviewed-on: https://go-review.googlesource.com/35733
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
  • Loading branch information
rsc committed Jan 25, 2017
1 parent 9bbb07d commit 49b7af8
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/reflect/all_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5985,6 +5985,11 @@ func TestUnaddressableField(t *testing.T) {
})
}


type Tint int

type Tint2 = Tint

type Talias1 struct {
byte
uint8
Expand All @@ -5993,11 +5998,24 @@ type Talias1 struct {
rune
}

type Talias2 struct {
Tint
Tint2
}

func TestAliasNames(t *testing.T) {
t1 := Talias1{byte: 1, uint8: 2, int: 3, int32: 4, rune: 5}
out := fmt.Sprintf("%#v", t1)
want := "reflect_test.Talias1{byte:0x1, uint8:0x2, int:3, int32:4, rune:5}"
if out != want {
t.Errorf("Talias1 print:\nhave: %s\nwant: %s", out, want)
}

t2 := Talias2{Tint: 1, Tint2: 2}
out = fmt.Sprintf("%#v", t2)
want = "reflect_test.Talias2{Tint:1, Tint2:2}"
if out != want {
t.Errorf("Talias2 print:\nhave: %s\nwant: %s", out, want)
}
}

0 comments on commit 49b7af8

Please sign in to comment.