gitee.com/mirrors_u-root/u-root@v7.0.0+incompatible/pkg/uflag/flagfile_test.go (about)

     1  // Copyright 2020 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 uflag
     6  
     7  import (
     8  	"reflect"
     9  	"testing"
    10  )
    11  
    12  func TestArgvs(t *testing.T) {
    13  	for _, tt := range []struct {
    14  		argv []string
    15  	}{
    16  		{
    17  			argv: []string{"--append=\"foobar\nfoobaz\"", "--haha"},
    18  		},
    19  		{
    20  			argv: []string{"oh damn", "--append=\"foobar foobaz\"", "--haha"},
    21  		},
    22  		{
    23  			argv: []string{},
    24  		},
    25  	} {
    26  		got := FileToArgv(ArgvToFile(tt.argv))
    27  		// Accept nil for []string{} by checking len == 0.
    28  		if !(len(tt.argv) == 0 && len(got) == 0) && !reflect.DeepEqual(got, tt.argv) {
    29  			t.Errorf("FileToArgv(ArgvToFile(%#v)) = %#v, wanted original value back", tt.argv, got)
    30  		}
    31  	}
    32  }