File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1111
1212import org .junit .jupiter .api .*;
1313
14+ import com .google .gson .JsonElement ;
1415import com .google .gson .JsonObject ;
1516import com .google .gson .JsonParser ;
1617import com .google .gson .stream .JsonWriter ;
4445import java .io .StringWriter ;
4546
4647import java .util .ArrayList ;
48+ import java .util .Iterator ;
4749import java .util .List ;
4850
4951// The FunctionSerializer is a utility class of the PatchestryListFunctions script.
@@ -146,5 +148,18 @@ public void testSerialize() throws Exception {
146148 JsonObject jsonOutput = JsonParser
147149 .parseString (stringWriter .toString ())
148150 .getAsJsonObject ();
151+
152+ assertEquals (jsonOutput .get ("program" ).getAsString (), program .getName ());
153+ Iterator <JsonElement > functions = jsonOutput .get ("functions" ).getAsJsonArray ().iterator ();
154+ assertNotNull (functions );
155+ assertTrue (functions .hasNext ());
156+
157+ while (functions .hasNext ()) {
158+ JsonObject element = functions .next ().getAsJsonObject ();
159+ assertTrue (element .has ("name" ));
160+ assertTrue (element .has ("address" ));
161+ assertTrue (element .has ("is_thunk" ));
162+ }
163+ assertFalse (functions .hasNext ());
149164 }
150165}
You can’t perform that action at this time.
0 commit comments