github.com/go-xe2/third@v1.0.3/golang.org/x/text/internal/internal_test.go (about)

     1  // Copyright 2015 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 internal
     6  
     7  import (
     8  	"fmt"
     9  	"strings"
    10  	"testing"
    11  
    12  	"github.com/go-xe2/third/golang.org/x/text/language"
    13  )
    14  
    15  func TestUnique(t *testing.T) {
    16  	testCases := []struct {
    17  		in, want string
    18  	}{
    19  		{"", "[]"},
    20  		{"en", "[en]"},
    21  		{"en en", "[en]"},
    22  		{"en en en", "[en]"},
    23  		{"en-u-cu-eur en", "[en en-u-cu-eur]"},
    24  		{"nl en", "[en nl]"},
    25  		{"pt-Pt pt", "[pt pt-PT]"},
    26  	}
    27  	for _, tc := range testCases {
    28  		tags := []language.Tag{}
    29  		for _, s := range strings.Split(tc.in, " ") {
    30  			if s != "" {
    31  				tags = append(tags, language.MustParse(s))
    32  			}
    33  		}
    34  		if got := fmt.Sprint(UniqueTags(tags)); got != tc.want {
    35  			t.Errorf("Unique(%s) = %s; want %s", tc.in, got, tc.want)
    36  		}
    37  	}
    38  }