github.com/mitranim/gg@v0.1.17/zop_test.go (about) 1 package gg_test 2 3 import ( 4 "testing" 5 6 "github.com/mitranim/gg" 7 "github.com/mitranim/gg/gtest" 8 ) 9 10 func TestZop_MarshalJSON(t *testing.T) { 11 defer gtest.Catch(t) 12 13 type Type = gg.Zop[int] 14 15 gtest.Eq(gg.JsonString(gg.Zero[Type]()), `null`) 16 gtest.Eq(gg.JsonString(Type{123}), `123`) 17 gtest.Eq(gg.JsonString(gg.ZopVal(123)), `123`) 18 } 19 20 func TestZop_UnmarshalJSON(t *testing.T) { 21 defer gtest.Catch(t) 22 23 type Type = gg.Zop[int] 24 25 gtest.Zero(gg.JsonParseTo[Type](`null`)) 26 27 gtest.Equal( 28 gg.JsonParseTo[Type](`123`), 29 gg.ZopVal(123), 30 ) 31 }