Source file src/cmd/go/internal/str/str_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 str
     6  
     7  import (
     8  	"testing"
     9  )
    10  
    11  var foldDupTests = []struct {
    12  	list   []string
    13  	f1, f2 string
    14  }{
    15  	{StringList("math/rand", "math/big"), "", ""},
    16  	{StringList("math", "strings"), "", ""},
    17  	{StringList("strings"), "", ""},
    18  	{StringList("strings", "strings"), "strings", "strings"},
    19  	{StringList("Rand", "rand", "math", "math/rand", "math/Rand"), "Rand", "rand"},
    20  }
    21  
    22  func TestFoldDup(t *testing.T) {
    23  	for _, tt := range foldDupTests {
    24  		f1, f2 := FoldDup(tt.list)
    25  		if f1 != tt.f1 || f2 != tt.f2 {
    26  			t.Errorf("foldDup(%q) = %q, %q, want %q, %q", tt.list, f1, f2, tt.f1, tt.f2)
    27  		}
    28  	}
    29  }
    30  

View as plain text