More smoke test types: exercise maybeptr=true.
Sanity check level: gen result compiles.
Next: time to target tests at all this jazz that actually exercise
and run the generated code.
@@ -22,6 +22,7 @@ func TestSmoke(t *testing.T) {
adjCfg := &AdjunctCfg{
maybeUsesPtr: map[schema.TypeName]bool{
"String": false,
+ "Strang": true,
},
}
@@ -30,6 +31,8 @@ func TestSmoke(t *testing.T) {
tString := schema.SpawnString("String")
+ tStrang := schema.SpawnString("Strang") // MaybeUsesPtr==true
+
tStroct := schema.SpawnStruct("Stroct",
[]schema.StructField{
// Every field in this struct (including their order) is exercising an interesting case...
@@ -42,6 +45,18 @@ func TestSmoke(t *testing.T) {
schema.StructRepresentation_Map{},
)
+ tStract := schema.SpawnStruct("Stract",
+ []schema.StructField{
+ // Exactly like Stroct, except all the fields are Strang, and so all the maybes use ptrs.
+ schema.SpawnStructField("f1", tStrang, false, false), // plain field.
+ schema.SpawnStructField("f2", tStrang, true, false), // optional; later we have more than one optional field, nonsequentially.
+ schema.SpawnStructField("f3", tStrang, false, true), // nullable; but required.
+ schema.SpawnStructField("f4", tStrang, true, true), // optional and nullable; trailing optional.
+ schema.SpawnStructField("f5", tStrang, true, false), // optional; and the second one in a row, trailing.
+ },
+ schema.StructRepresentation_Map{},
+ )
+
f = openOrPanic("_test/tString.go")
EmitFileHeader(pkgName, f)
EmitEntireType(NewStringReprStringGenerator(pkgName, tString, adjCfg), f)
@@ -49,4 +64,12 @@ func TestSmoke(t *testing.T) {
f = openOrPanic("_test/tStroct.go")
EmitFileHeader(pkgName, f)
EmitEntireType(NewStructReprMapGenerator(pkgName, tStroct, adjCfg), f)
+
+ f = openOrPanic("_test/tStrang.go")
+ EmitFileHeader(pkgName, f)
+ EmitEntireType(NewStringReprStringGenerator(pkgName, tStrang, adjCfg), f)
+
+ f = openOrPanic("_test/tStract.go")
+ EmitFileHeader(pkgName, f)
+ EmitEntireType(NewStructReprMapGenerator(pkgName, tStract, adjCfg), f)
}
