Skip to content

Commit af3d1e4

Browse files
committed
Add sanity test for serializing an empty SC, then deserializing it back to one.
1 parent 938a5f3 commit af3d1e4

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

t/serialization/01-basic.t

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#! nqp
2+
3+
plan(4);
4+
5+
# Serializing an empty SC.
6+
{
7+
my $sc := pir::nqp_create_sc__Ps('TEST_SC_1_IN');
8+
my $sh := pir::new__Ps('ResizableStringArray');
9+
10+
my $serialized := pir::nqp_serialize_sc__SPP($sc, $sh);
11+
ok(nqp::chars($serialized) > 0, 'serialized empty SC to non-empty string');
12+
ok(nqp::chars($serialized) >= 36, 'output is at least as long as the header');
13+
ok(nqp::elems($sh) == 0, 'string heap empty with empty SC');
14+
15+
my $dsc := pir::nqp_create_sc__Ps('TEST_SC_1_OUT');
16+
pir::nqp_deserialize_sc__vSPP($serialized, $dsc, $sh);
17+
18+
ok(nqp::elems($dsc) == 0, 'deserialized SC is also empty');
19+
}

0 commit comments

Comments
 (0)