| 1 |
// Copyright 2021 The Go Authors. All rights reserved. |
| 2 |
// Use of this source code is governed by a BSD-style |
| 3 |
// license that can be found in the LICENSE file. |
| 4 |
|
| 5 |
package main |
| 6 |
|
| 7 |
import ( |
| 8 |
"./a" |
| 9 |
"fmt" |
| 10 |
"reflect" |
| 11 |
"strconv" |
| 12 |
) |
| 13 |
|
| 14 |
type myint int |
| 15 |
|
| 16 |
func (i myint) String() string { |
| 17 |
return strconv.Itoa(int(i)) |
| 18 |
} |
| 19 |
|
| 20 |
func main() { |
| 21 |
x := []myint{myint(1), myint(2), myint(3)} |
| 22 |
|
| 23 |
got := a.Stringify(x) |
| 24 |
want := []string{"1", "2", "3"} |
| 25 |
if !reflect.DeepEqual(got, want) { |
| 26 |
panic(fmt.Sprintf("got %s, want %s", got, want)) |
| 27 |
} |
| 28 |
|
| 29 |
m1 := myint(1) |
| 30 |
m2 := myint(2) |
| 31 |
m3 := myint(3) |
| 32 |
y := []*myint{&m1, &m2, &m3} |
| 33 |
got2 := a.Stringify(y) |
| 34 |
want2 := []string{"1", "2", "3"} |
| 35 |
if !reflect.DeepEqual(got2, want2) { |
| 36 |
panic(fmt.Sprintf("got %s, want %s", got2, want2)) |
| 37 |
} |
| 38 |
} |