Skip to content

Commit

Permalink
deref.Or test
Browse files Browse the repository at this point in the history
  • Loading branch information
mikhalytch committed May 29, 2024
1 parent f0c7a3f commit 6255fab
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions deref/or_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package deref_test

import (
"testing"

"github.com/mikhalytch/eggs/deref"
"github.com/mikhalytch/eggs/ptr"

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

func Test_Or(t *testing.T) {
type s string

var sVal *s

require.Equal(t, s(""), deref.Or(sVal, ""))
require.Equal(t, s("123"), deref.Or(sVal, "123"))

sVal = ptr.Of(s("abc"))
require.Equal(t, s("abc"), deref.Or(sVal, "123"))
}

0 comments on commit 6255fab

Please sign in to comment.