github.hscsec.cn/u-root/u-root@v7.0.0+incompatible/pkg/complete/prefix_test.go (about)

     1  // Copyright 2012-2018 the u-root 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 complete
     6  
     7  import (
     8  	"testing"
     9  )
    10  
    11  func TestPrefix(t *testing.T) {
    12  	var tests = []string{
    13  		"/etc/hosts.allow",
    14  		"/etc/hosts.deny",
    15  		"/etc/hosts",
    16  		"/etc/host.conf",
    17  		"/etc/hostname",
    18  		"/etc",
    19  		"/a",
    20  		"",
    21  	}
    22  
    23  	var testsout = []string{
    24  		"/etc/hosts.allow",
    25  		"/etc/hosts.",
    26  		"/etc/hosts",
    27  		"/etc/host",
    28  		"/etc/host",
    29  		"/etc",
    30  		"/",
    31  		"",
    32  	}
    33  	for i := range tests {
    34  		test := tests[:i+1]
    35  		p := Prefix(test)
    36  		if p != testsout[i] {
    37  			t.Errorf("Test %d: %v: got %v, want %v", i, test, p, testsout[i])
    38  		}
    39  	}
    40  }