2020-01-07 17:36:49 +01:00
|
|
|
package txt
|
2019-07-17 13:26:20 +02:00
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
2019-12-11 14:10:20 +01:00
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
2019-07-17 13:26:20 +02:00
|
|
|
)
|
|
|
|
|
2020-04-28 17:03:37 +02:00
|
|
|
func TestBool(t *testing.T) {
|
|
|
|
t.Run("not empty", func(t *testing.T) {
|
|
|
|
assert.Equal(t, true, Bool("Browse your life in pictures"))
|
|
|
|
})
|
2021-05-26 09:51:00 +02:00
|
|
|
t.Run("oui", func(t *testing.T) {
|
|
|
|
assert.Equal(t, true, Bool("oui"))
|
|
|
|
})
|
|
|
|
t.Run("non", func(t *testing.T) {
|
|
|
|
assert.Equal(t, false, Bool("non"))
|
|
|
|
})
|
|
|
|
t.Run("ja", func(t *testing.T) {
|
|
|
|
assert.Equal(t, true, Bool("ja"))
|
|
|
|
})
|
|
|
|
t.Run("true", func(t *testing.T) {
|
|
|
|
assert.Equal(t, true, Bool("true"))
|
|
|
|
})
|
|
|
|
t.Run("yes", func(t *testing.T) {
|
|
|
|
assert.Equal(t, true, Bool("yes"))
|
|
|
|
})
|
2020-04-28 17:03:37 +02:00
|
|
|
t.Run("no", func(t *testing.T) {
|
|
|
|
assert.Equal(t, false, Bool("no"))
|
|
|
|
})
|
|
|
|
t.Run("false", func(t *testing.T) {
|
|
|
|
assert.Equal(t, false, Bool("false"))
|
|
|
|
})
|
|
|
|
t.Run("empty", func(t *testing.T) {
|
|
|
|
assert.Equal(t, false, Bool(""))
|
|
|
|
})
|
|
|
|
}
|
2021-05-26 09:51:00 +02:00
|
|
|
|
|
|
|
func TestYes(t *testing.T) {
|
|
|
|
t.Run("not empty", func(t *testing.T) {
|
|
|
|
assert.Equal(t, false, Yes("Browse your life in pictures"))
|
|
|
|
})
|
|
|
|
t.Run("oui", func(t *testing.T) {
|
|
|
|
assert.Equal(t, true, Yes("oui"))
|
|
|
|
})
|
|
|
|
t.Run("non", func(t *testing.T) {
|
|
|
|
assert.Equal(t, false, Yes("non"))
|
|
|
|
})
|
|
|
|
t.Run("ja", func(t *testing.T) {
|
|
|
|
assert.Equal(t, true, Yes("ja"))
|
|
|
|
})
|
|
|
|
t.Run("true", func(t *testing.T) {
|
|
|
|
assert.Equal(t, true, Yes("true"))
|
|
|
|
})
|
|
|
|
t.Run("yes", func(t *testing.T) {
|
|
|
|
assert.Equal(t, true, Yes("yes"))
|
|
|
|
})
|
|
|
|
t.Run("no", func(t *testing.T) {
|
|
|
|
assert.Equal(t, false, Yes("no"))
|
|
|
|
})
|
|
|
|
t.Run("false", func(t *testing.T) {
|
|
|
|
assert.Equal(t, false, Yes("false"))
|
|
|
|
})
|
2021-05-26 11:04:14 +02:00
|
|
|
t.Run("exclude", func(t *testing.T) {
|
|
|
|
assert.Equal(t, false, Yes("exclude"))
|
|
|
|
})
|
|
|
|
t.Run("include", func(t *testing.T) {
|
|
|
|
assert.Equal(t, true, Yes("include"))
|
|
|
|
})
|
2021-09-23 14:23:00 +02:00
|
|
|
t.Run("unknown", func(t *testing.T) {
|
|
|
|
assert.Equal(t, false, Yes("unknown"))
|
|
|
|
})
|
|
|
|
t.Run("please", func(t *testing.T) {
|
|
|
|
assert.Equal(t, true, Yes("please"))
|
|
|
|
})
|
|
|
|
t.Run("positive", func(t *testing.T) {
|
|
|
|
assert.Equal(t, true, Yes("positive"))
|
|
|
|
})
|
2021-05-26 09:51:00 +02:00
|
|
|
t.Run("empty", func(t *testing.T) {
|
|
|
|
assert.Equal(t, false, Yes(""))
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestNo(t *testing.T) {
|
|
|
|
t.Run("not empty", func(t *testing.T) {
|
|
|
|
assert.Equal(t, false, No("Browse your life in pictures"))
|
|
|
|
})
|
|
|
|
t.Run("oui", func(t *testing.T) {
|
|
|
|
assert.Equal(t, false, No("oui"))
|
|
|
|
})
|
|
|
|
t.Run("non", func(t *testing.T) {
|
|
|
|
assert.Equal(t, true, No("non"))
|
|
|
|
})
|
|
|
|
t.Run("ja", func(t *testing.T) {
|
|
|
|
assert.Equal(t, false, No("ja"))
|
|
|
|
})
|
|
|
|
t.Run("true", func(t *testing.T) {
|
|
|
|
assert.Equal(t, false, No("true"))
|
|
|
|
})
|
|
|
|
t.Run("yes", func(t *testing.T) {
|
|
|
|
assert.Equal(t, false, No("yes"))
|
|
|
|
})
|
|
|
|
t.Run("no", func(t *testing.T) {
|
|
|
|
assert.Equal(t, true, No("no"))
|
|
|
|
})
|
|
|
|
t.Run("false", func(t *testing.T) {
|
|
|
|
assert.Equal(t, true, No("false"))
|
|
|
|
})
|
2021-05-26 11:04:14 +02:00
|
|
|
t.Run("exclude", func(t *testing.T) {
|
|
|
|
assert.Equal(t, true, No("exclude"))
|
|
|
|
})
|
|
|
|
t.Run("include", func(t *testing.T) {
|
|
|
|
assert.Equal(t, false, No("include"))
|
|
|
|
})
|
2021-09-23 14:23:00 +02:00
|
|
|
t.Run("unknown", func(t *testing.T) {
|
|
|
|
assert.Equal(t, true, No("unknown"))
|
|
|
|
})
|
|
|
|
t.Run("please", func(t *testing.T) {
|
|
|
|
assert.Equal(t, false, No("please"))
|
|
|
|
})
|
|
|
|
t.Run("positive", func(t *testing.T) {
|
|
|
|
assert.Equal(t, false, No("positive"))
|
|
|
|
})
|
2021-05-26 09:51:00 +02:00
|
|
|
t.Run("empty", func(t *testing.T) {
|
|
|
|
assert.Equal(t, false, No(""))
|
|
|
|
})
|
|
|
|
}
|
2021-09-29 20:09:34 +02:00
|
|
|
|
|
|
|
func TestNew(t *testing.T) {
|
|
|
|
t.Run("Empty", func(t *testing.T) {
|
|
|
|
assert.Equal(t, false, New(""))
|
|
|
|
})
|
2021-10-13 16:12:56 +02:00
|
|
|
t.Run("EnNew", func(t *testing.T) {
|
|
|
|
assert.Equal(t, true, New(EnNew))
|
|
|
|
})
|
|
|
|
t.Run("Spaces", func(t *testing.T) {
|
|
|
|
assert.Equal(t, true, New(" new "))
|
|
|
|
})
|
2021-09-29 20:09:34 +02:00
|
|
|
t.Run("Uppercase", func(t *testing.T) {
|
|
|
|
assert.Equal(t, true, New("NEW"))
|
|
|
|
})
|
|
|
|
t.Run("Lowercase", func(t *testing.T) {
|
|
|
|
assert.Equal(t, true, New("new"))
|
|
|
|
})
|
|
|
|
t.Run("True", func(t *testing.T) {
|
|
|
|
assert.Equal(t, true, New("New"))
|
|
|
|
})
|
|
|
|
t.Run("False", func(t *testing.T) {
|
|
|
|
assert.Equal(t, false, New("non"))
|
|
|
|
})
|
|
|
|
}
|