github.com/go-asm/go@v1.21.1-0.20240213172139-40c5ead50c48/cmd/go/modload/mvs_test.go (about) 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 6 7 import ( 8 "testing" 9 ) 10 11 func TestReqsMax(t *testing.T) { 12 type testCase struct { 13 a, b, want string 14 } 15 reqs := new(mvsReqs) 16 for _, tc := range []testCase{ 17 {a: "v0.1.0", b: "v0.2.0", want: "v0.2.0"}, 18 {a: "v0.2.0", b: "v0.1.0", want: "v0.2.0"}, 19 {a: "", b: "v0.1.0", want: ""}, // "" is Target.Version 20 {a: "v0.1.0", b: "", want: ""}, 21 {a: "none", b: "v0.1.0", want: "v0.1.0"}, 22 {a: "v0.1.0", b: "none", want: "v0.1.0"}, 23 {a: "none", b: "", want: ""}, 24 {a: "", b: "none", want: ""}, 25 } { 26 max := reqs.Max("", tc.a, tc.b) 27 if max != tc.want { 28 t.Errorf("(%T).Max(%q, %q) = %q; want %q", reqs, tc.a, tc.b, max, tc.want) 29 } 30 } 31 }