...

Source file src/cmd/distpack/archive_test.go

Documentation: cmd/distpack

     1  // Copyright 2023 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 main
     6  
     7  import "testing"
     8  
     9  var amatchTests = []struct {
    10  	pattern string
    11  	name    string
    12  	ok      bool
    13  }{
    14  	{"a", "a", true},
    15  	{"a", "b", false},
    16  	{"a/**", "a", true},
    17  	{"a/**", "b", false},
    18  	{"a/**", "a/b", true},
    19  	{"a/**", "b/b", false},
    20  	{"a/**", "a/b/c/d/e/f", true},
    21  	{"a/**", "z/a/b/c/d/e/f", false},
    22  	{"**/a", "a", true},
    23  	{"**/a", "b", false},
    24  	{"**/a", "x/a", true},
    25  	{"**/a", "x/a/b", false},
    26  	{"**/a", "x/y/z/a", true},
    27  	{"**/a", "x/y/z/a/b", false},
    28  
    29  	{"go/pkg/tool/*/compile", "go/pkg/tool/darwin_amd64/compile", true},
    30  }
    31  
    32  func TestAmatch(t *testing.T) {
    33  	for _, tt := range amatchTests {
    34  		ok, err := amatch(tt.pattern, tt.name)
    35  		if ok != tt.ok || err != nil {
    36  			t.Errorf("amatch(%q, %q) = %v, %v, want %v, nil", tt.pattern, tt.name, ok, err, tt.ok)
    37  		}
    38  	}
    39  }
    40  

View as plain text