Source file src/cmd/go/internal/modload/mvs_test.go

     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  }
    32  

View as plain text