Skip to content

Commit

Permalink
Merge pull request #13 from unravelin/true-false-consts
Browse files Browse the repository at this point in the history
Valid True and False consts
  • Loading branch information
talon266 authored Apr 25, 2023
2 parents 59f0b32 + d01bc09 commit f0b03ed
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
8 changes: 8 additions & 0 deletions bool.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@ type Bool struct {
sql.NullBool
}

func True() Bool {
return B(true)
}

func False() Bool {
return B(false)
}

// NewBool creates a new Bool
func NewBool(b bool, valid bool) Bool {
return Bool{
Expand Down
7 changes: 7 additions & 0 deletions bool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -295,3 +295,10 @@ func assertBoolEqualIsFalse(t *testing.T, a, b Bool) {
t.Errorf("Equal() of Bool{%t, Valid:%t} and Bool{%t, Valid:%t} should return false", a.Bool, a.Valid, b.Bool, b.Valid)
}
}

func TestTrueFalse(t *testing.T) {
assert.True(t, True().Valid)
assert.True(t, True().Bool)
assert.True(t, False().Valid)
assert.False(t, False().Bool)
}

0 comments on commit f0b03ed

Please sign in to comment.