Add additional nil checks in niljson_test.go

Enhanced the test coverage by adding nil checks for ByteSlice and Float32 types after reset. This ensures that more types are adequately handled and validated for nil values in the tests. Additionally, included a check for the string using the Get method.
This commit is contained in:
Winni Neessen 2024-09-01 16:51:10 +02:00
parent fcc4f5d0d0
commit 80f2ea15a5
Signed by: wneessen
GPG key ID: 385AC9889632126E

View file

@ -75,10 +75,22 @@ func TestVariable_UnmarshalJSON(t *testing.T) {
t.Errorf("expected string to be 'test', got %s", jt.String.Value())
}
if jt.String.Get() != "test" {
t.Errorf("expected string to be 'test', got %s", jt.String.Get())
}
jt.Bool.Reset()
if jt.Bool.NotNil() {
t.Errorf("expected bool to be nil after reset")
}
jt.ByteSlice.Reset()
if jt.ByteSlice.NotNil() {
t.Errorf("expected byte slice to be nil after reset")
}
jt.Float32.Reset()
if jt.Float32.NotNil() {
t.Errorf("expected float32 to be nil after reset")
}
jt.Float64.Reset()
if jt.Float64.NotNil() {
t.Errorf("expected float64 to be nil after reset")