|
| 1 | +// Copyright 2020 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 modload_test |
| 6 | + |
| 7 | +import ( |
| 8 | + "testing" |
| 9 | + |
| 10 | + "cmd/go/internal/modload" |
| 11 | +) |
| 12 | + |
| 13 | +func TestReqsMax(t *testing.T) { |
| 14 | + type testCase struct { |
| 15 | + a, b, want string |
| 16 | + } |
| 17 | + reqs := modload.Reqs() |
| 18 | + for _, tc := range []testCase{ |
| 19 | + {a: "v0.1.0", b: "v0.2.0", want: "v0.2.0"}, |
| 20 | + {a: "v0.2.0", b: "v0.1.0", want: "v0.2.0"}, |
| 21 | + {a: "", b: "v0.1.0", want: ""}, // "" is Target.Version |
| 22 | + {a: "v0.1.0", b: "", want: ""}, |
| 23 | + {a: "none", b: "v0.1.0", want: "v0.1.0"}, |
| 24 | + {a: "v0.1.0", b: "none", want: "v0.1.0"}, |
| 25 | + {a: "none", b: "", want: ""}, |
| 26 | + {a: "", b: "none", want: ""}, |
| 27 | + } { |
| 28 | + max := reqs.Max(tc.a, tc.b) |
| 29 | + if max != tc.want { |
| 30 | + t.Errorf("Reqs().Max(%q, %q) = %q; want %q", tc.a, tc.b, max, tc.want) |
| 31 | + } |
| 32 | + } |
| 33 | +} |
0 commit comments