@@ -407,11 +407,13 @@ func TestOptionalString(t *testing.T) {
407407 t .Fatal ("should be the default" )
408408 }
409409 if val := defaultOptionalString .WithDefault ("" ); val != "" {
410- t .Errorf ("optional integer should have been empty, got %s" , val )
410+ t .Errorf ("optional string should have been empty, got %s" , val )
411+ }
412+ if val := defaultOptionalString .String (); val != "default" {
413+ t .Fatalf ("default optional string should be the 'default' string, got %s" , val )
411414 }
412-
413415 if val := defaultOptionalString .WithDefault ("foo" ); val != "foo" {
414- t .Errorf ("optional integer should have been foo, got %s" , val )
416+ t .Errorf ("optional string should have been foo, got %s" , val )
415417 }
416418
417419 var filledStr OptionalString
@@ -420,17 +422,20 @@ func TestOptionalString(t *testing.T) {
420422 t .Fatal ("should not be the default" )
421423 }
422424 if val := filledStr .WithDefault ("bar" ); val != "foo" {
423- t .Errorf ("optional integer should have been foo, got %s" , val )
425+ t .Errorf ("optional string should have been foo, got %s" , val )
426+ }
427+ if val := filledStr .String (); val != "foo" {
428+ t .Fatalf ("optional string should have been foo, got %s" , val )
424429 }
425-
426430 filledStr = OptionalString {value : makeStringPointer ("" )}
427431 if val := filledStr .WithDefault ("foo" ); val != "" {
428- t .Errorf ("optional integer should have been 0, got %s" , val )
432+ t .Errorf ("optional string should have been 0, got %s" , val )
429433 }
430434
431435 for jsonStr , goValue := range map [string ]OptionalString {
432436 "null" : {},
433437 "\" 0\" " : {value : makeStringPointer ("0" )},
438+ "\" \" " : {value : makeStringPointer ("" )},
434439 `"1"` : {value : makeStringPointer ("1" )},
435440 `"-1"` : {value : makeStringPointer ("-1" )},
436441 `"qwerty"` : {value : makeStringPointer ("qwerty" )},
0 commit comments