File tree Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -212,6 +212,30 @@ test "cursor api" {
212212 }
213213}
214214
215+ test "messagepack extensions" {
216+ var buf : [1024 ]u8 = undefined ;
217+ var writer = Writer .init (& buf );
218+
219+ try writer .startMap (1 );
220+ try writer .writeString ("key" );
221+ try writer .writeExtension (10 , "hello world" );
222+ try writer .finishMap ();
223+ try writer .deinit ();
224+
225+ var reader = Reader .init (& buf );
226+ defer (reader .deinit () catch unreachable );
227+
228+ var cursor = reader .cursor ();
229+ _ = try cursor .next ();
230+ _ = try cursor .next ();
231+ const ext = try cursor .next ();
232+ _ = try cursor .next ();
233+
234+ try std .testing .expect (ext .? == .extension );
235+ try std .testing .expectEqual (10 , ext .? .extension .type );
236+ try std .testing .expectEqualStrings ("hello world" , ext .? .extension .data );
237+ }
238+
215239test "convenience api" {
216240 var tree = try Tree .init (allocator , & buffer , null );
217241 defer (tree .deinit () catch {});
You can’t perform that action at this time.
0 commit comments