mirror of
https://github.com/opentofu/opentofu.git
synced 2025-02-11 08:05:33 -06:00
Add a few tests for string_list
This commit is contained in:
parent
a1d0c61ca0
commit
563fd3872b
29
config/string_list_test.go
Normal file
29
config/string_list_test.go
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
package config
|
||||||
|
|
||||||
|
import (
|
||||||
|
"reflect"
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestStringList_slice(t *testing.T) {
|
||||||
|
expected := []string{"apple", "banana", "pear"}
|
||||||
|
l := NewStringList(expected)
|
||||||
|
actual := l.Slice()
|
||||||
|
|
||||||
|
if !reflect.DeepEqual(expected, actual) {
|
||||||
|
t.Fatalf("Expected %q, got %q", expected, actual)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestStringList_element(t *testing.T) {
|
||||||
|
list := []string{"apple", "banana", "pear"}
|
||||||
|
l := NewStringList(list)
|
||||||
|
actual := l.Element(1)
|
||||||
|
|
||||||
|
expected := "banana"
|
||||||
|
|
||||||
|
if actual != expected {
|
||||||
|
t.Fatalf("Expected 2nd element from %q to be %q, got %q",
|
||||||
|
list, expected, actual)
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user