Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const std = @import("std");
- const Allocator = std.mem.Allocator;
- const ArrayList = std.ArrayList;
- pub const IObject = struct {
- const Self = @This();
- next: ?*IObject = null,
- pub fn parseMessage(self: *Self) bool {}
- };
- pub const IParser = struct struct {
- allocator: *Allocator,
- fn parse(self: *Self) type {
- var chain: type = ArrayList(IObject).init(self.allocator);
- defer chain.deinit();
- return chain;
- }
- pub fn test1(self: *Self) void {
- var args: type = self.parse();
- }
- }
- // Tests
- const expect = std.testing.expect;
- test "IParser" {
- var fixed_buffer_mem: [100 * 1024]u8 = undefined;
- var fixed_allocator = std.heap.FixedBufferAllocator.init(fixed_buffer_mem[0..]);
- var failing_allocator = std.testing.FailingAllocator.init(&fixed_allocator.allocator, 0);
- var parser = IParser{
- .allocator = &failing_allocator.allocator,
- };
- var ret = parser.test1();
- if (ret == null) {
- std.log.err("ret is null \n", .{});
- }
- expect(true);
- }
Advertisement
Add Comment
Please, Sign In to add comment