Skip to content

Commit

Permalink
strx: cleanup Yes tests
Browse files Browse the repository at this point in the history
  • Loading branch information
adamdecaf committed Oct 17, 2023
1 parent 98396a9 commit 3aca07f
Showing 1 changed file with 13 additions and 15 deletions.
28 changes: 13 additions & 15 deletions strx/strx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ package strx

import (
"testing"

"github.com/stretchr/testify/require"
)

func TestOr(t *testing.T) {
Expand All @@ -24,21 +26,17 @@ func TestOr(t *testing.T) {
}

func TestYes(t *testing.T) {
if !Yes("yes") {
t.Error("expected true")
}
if Yes("no") {
t.Error("expected no")
}
// accepted values
require.True(t, Yes("yes"))
require.True(t, Yes(" true "))

if !Yes(" true") {
t.Error("expected true")
}
if Yes("false") {
t.Error("expected no")
}
// common, but unsupported
require.False(t, Yes("on"))
require.False(t, Yes("y"))
require.False(t, Yes("no"))

if Yes("") {
t.Error("expected no")
}
// explicit no values
require.False(t, Yes("no"))
require.False(t, Yes("false"))
require.False(t, Yes(""))
}

0 comments on commit 3aca07f

Please sign in to comment.