1
0
mirror of https://github.com/duke-git/lancet.git synced 2026-02-08 06:32:28 +08:00

feat: add Of and Unwrap

This commit is contained in:
dudaodong
2023-06-02 11:48:17 +08:00
parent b1c6614549
commit 2f6ee84443
3 changed files with 83 additions and 2 deletions

View File

@@ -1,12 +1,32 @@
package pointer
import (
"github.com/duke-git/lancet/v2/internal"
"testing"
"github.com/duke-git/lancet/v2/internal"
)
func TestExtractPointer(t *testing.T) {
func TestOf(t *testing.T) {
assert := internal.NewAssert(t, "TestOf")
result1 := Of(123)
result2 := Of("abc")
assert.Equal(123, *result1)
assert.Equal("abc", *result2)
}
func TestUnwrap(t *testing.T) {
assert := internal.NewAssert(t, "TestUnwrap")
a := 123
b := "abc"
assert.Equal(a, Unwrap(&a))
assert.Equal(b, Unwrap(&b))
}
func TestExtractPointer(t *testing.T) {
assert := internal.NewAssert(t, "TestExtractPointer")
a := 1