Guest User

Untitled

a guest
Nov 19th, 2020
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. const std = @import("std");
  2. const Allocator = std.mem.Allocator;
  3. const ArrayList = std.ArrayList;
  4.  
  5. pub const IObject = struct {
  6. const Self = @This();
  7. next: ?*IObject = null,
  8.  
  9. pub fn parseMessage(self: *Self) bool {}
  10. };
  11.  
  12.  
  13. pub const IParser = struct struct {
  14. allocator: *Allocator,
  15. fn parse(self: *Self) type {
  16. var chain: type = ArrayList(IObject).init(self.allocator);
  17. defer chain.deinit();
  18. return chain;
  19. }
  20. pub fn test1(self: *Self) void {
  21. var args: type = self.parse();
  22. }
  23. }
  24.  
  25. // Tests
  26. const expect = std.testing.expect;
  27.  
  28. test "IParser" {
  29. var fixed_buffer_mem: [100 * 1024]u8 = undefined;
  30. var fixed_allocator = std.heap.FixedBufferAllocator.init(fixed_buffer_mem[0..]);
  31. var failing_allocator = std.testing.FailingAllocator.init(&fixed_allocator.allocator, 0);
  32. var parser = IParser{
  33. .allocator = &failing_allocator.allocator,
  34. };
  35.  
  36. var ret = parser.test1();
  37. if (ret == null) {
  38. std.log.err("ret is null \n", .{});
  39. }
  40.  
  41. expect(true);
  42. }
  43.  
Advertisement
Add Comment
Please, Sign In to add comment