123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- package sentio
- import "testing"
- func TestSideFromString(t *testing.T) {
- tests := []struct {
- arg string
- want Side
- wantErr bool
- }{
- {
- arg: "short",
- want: SHORT,
- wantErr: false,
- },
- {
- arg: "Short",
- want: SHORT,
- wantErr: false,
- },
- {
- arg: " short ",
- want: SHORT,
- wantErr: false,
- },
- {
- arg: "ShOrT",
- want: SHORT,
- wantErr: false,
- },
- {
- arg: "šhort",
- want: -1,
- wantErr: true,
- },
- {
- arg: "base",
- want: BASE,
- wantErr: false,
- },
- }
- for _, tt := range tests {
- t.Run("TestSideFromString", func(t *testing.T) {
- got, err := ParseSide(tt.arg)
- if (err != nil) != tt.wantErr {
- t.Errorf("SideFromString() error = %v, wantErr %v", err, tt.wantErr)
- return
- }
- if got != tt.want {
- t.Errorf("SideFromString() got = %v, want %v", got, tt.want)
- }
- })
- }
- }
|