Skip to content
This repository was archived by the owner on Jan 30, 2020. It is now read-only.

Commit 7dcf609

Browse files
author
Nick Owens
committed
pkg: add basic StringSlice test
1 parent 363e50c commit 7dcf609

1 file changed

Lines changed: 39 additions & 0 deletions

File tree

pkg/flag_test.go

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// Copyright 2015 CoreOS, Inc.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
package pkg
16+
17+
import (
18+
"reflect"
19+
"testing"
20+
)
21+
22+
func TestStringSlice(t *testing.T) {
23+
tests := []struct {
24+
input string
25+
output []string
26+
}{
27+
{`["a"]`, []string{"a"}},
28+
{`["a","b"]`, []string{"a", "b"}},
29+
}
30+
31+
for _, tt := range tests {
32+
var ss StringSlice
33+
ss.Set(tt.input)
34+
r := ss.Value()
35+
if !reflect.DeepEqual(r, tt.output) {
36+
t.Errorf("error setting StringSlice: expected %+v, got %+v", tt.output, r)
37+
}
38+
}
39+
}

0 commit comments

Comments
 (0)