Skip to content

Commit 92e5b30

Browse files
authored
test(string): add Text/MarshalUnmarshal subtest to TestString (#212)
Signed-off-by: aoright <102943475+aoright@users.noreply.github.com>
1 parent db66dad commit 92e5b30

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

‎string_test.go‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,18 @@ func TestString(t *testing.T) {
7777
require.Equal(t, "bar", atom.Load(), "xml.Unmarshal didn't set the correct value.")
7878
})
7979

80+
t.Run("Text/MarshalUnmarshal", func(t *testing.T) {
81+
atom := NewString("hello")
82+
bytes, err := atom.MarshalText()
83+
require.NoError(t, err)
84+
require.Equal(t, []byte("hello"), bytes)
85+
86+
var atom2 String
87+
err = atom2.UnmarshalText([]byte("world"))
88+
require.NoError(t, err)
89+
require.Equal(t, "world", atom2.Load())
90+
})
91+
8092
t.Run("String", func(t *testing.T) {
8193
atom := NewString("foo")
8294
assert.Equal(t, "foo", atom.String(),

0 commit comments

Comments
 (0)