| 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 |
) |
| 11 |
|
| 12 |
func main() { |
| 13 |
const want = 2 |
| 14 |
if got := a.Min[int](2, 3); got != want { |
| 15 |
panic(fmt.Sprintf("got %d, want %d", got, want)) |
| 16 |
} |
| 17 |
|
| 18 |
if got := a.Min(2, 3); got != want { |
| 19 |
panic(fmt.Sprintf("want %d, got %d", want, got)) |
| 20 |
} |
| 21 |
|
| 22 |
if got := a.Min[float64](3.5, 2.0); got != want { |
| 23 |
panic(fmt.Sprintf("got %d, want %d", got, want)) |
| 24 |
} |
| 25 |
|
| 26 |
if got := a.Min(3.5, 2.0); got != want { |
| 27 |
panic(fmt.Sprintf("got %d, want %d", got, want)) |
| 28 |
} |
| 29 |
|
| 30 |
const want2 = "ay" |
| 31 |
if got := a.Min[string]("bb", "ay"); got != want2 { // ERROR "string does not satisfy" |
| 32 |
panic(fmt.Sprintf("got %d, want %d", got, want2)) |
| 33 |
} |
| 34 |
|
| 35 |
if got := a.Min("bb", "ay"); got != want2 { // ERROR "string does not satisfy" |
| 36 |
panic(fmt.Sprintf("got %d, want %d", got, want2)) |
| 37 |
} |
| 38 |
} |