Skip to content

Commit

Permalink
bool predicates
Browse files Browse the repository at this point in the history
  • Loading branch information
mikhalytch committed Jan 15, 2024
1 parent 2686a2c commit 3cfc8c4
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
6 changes: 6 additions & 0 deletions funcs/predicate/bool.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package predicate

import constraints "github.com/mikhalytch/eggs/constraints/base"

func IsTrue[T constraints.Bool](t T) bool { return bool(t) }
func IsFalse[T constraints.Bool](t T) bool { return !bool(t) }
27 changes: 27 additions & 0 deletions funcs/predicate/bool_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package predicate_test

import (
"testing"

"github.com/stretchr/testify/require"

"github.com/mikhalytch/eggs/funcs/predicate"
)

func TestIsTrue(t *testing.T) {
type bb bool

tr, fa := bb(true), bb(false)

require.True(t, predicate.IsTrue(tr))
require.False(t, predicate.IsTrue(fa))
}

func TestIsFalse(t *testing.T) {
type bb bool

tr, fa := bb(true), bb(false)

require.True(t, predicate.IsFalse(fa))
require.False(t, predicate.IsFalse(tr))
}

0 comments on commit 3cfc8c4

Please sign in to comment.