more tests

master
Charles Iliya Krempeaux 2023-09-24 05:30:44 +09:00
parent b434dd95d3
commit 3f808e9749
2 changed files with 38 additions and 0 deletions

View File

@ -44,3 +44,22 @@ func TestOptional_MarshalJSON_bool(t *testing.T) {
} }
} }
} }
func TestOptional_MarshalJSON_bool_fail(t *testing.T) {
var nothing opt.Optional[bool]
actualBytes, err := nothing.MarshalJSON()
if nil == err {
t.Error("Expected an error but did not actually get one.")
t.Logf("ACTUAL: %q", actualBytes)
t.Logf("ERROR: (%T) %s", err, err)
return
}
if nil != actualBytes {
t.Error("Expected not bytes but actually get some.")
t.Logf("ACTUAL: %q", actualBytes)
t.Logf("ERROR: (%T) %s", err, err)
return
}
}

View File

@ -103,3 +103,22 @@ func TestOptional_MarshalJSON_string(t *testing.T) {
} }
} }
} }
func TestOptional_MarshalJSON_string_fail(t *testing.T) {
var nothing opt.Optional[string]
actualBytes, err := nothing.MarshalJSON()
if nil == err {
t.Error("Expected an error but did not actually get one.")
t.Logf("ACTUAL: %q", actualBytes)
t.Logf("ERROR: (%T) %s", err, err)
return
}
if nil != actualBytes {
t.Error("Expected not bytes but actually get some.")
t.Logf("ACTUAL: %q", actualBytes)
t.Logf("ERROR: (%T) %s", err, err)
return
}
}