const std = @import("std"); const testing = std.testing; pub const value = @import("../zisp/value.zig"); test "istr" { const istr = value.istr; const fx = value.fixnum; const s1 = "foo bar baz"; const v1 = istr.intern(s1, false); const v1_len: usize = @intCast(fx.unpack(istr.len(v1))); try testing.expectEqualStrings(s1, istr.getHeader(v1).bytes()); try testing.expectEqual(s1.len, v1_len); const file = try std.fs.cwd().openFile("src/test/data/string.txt", .{}); defer file.close(); var s2_buf: [4096]u8 = undefined; const s2_len = try file.readAll(&s2_buf); var s2: []u8 = s2_buf[0..s2_len]; const v2 = istr.intern(s2, false); const v2_len: usize = @intCast(fx.unpack(istr.len(v2))); var s2_orig_buf: [4096]u8 = undefined; @memcpy(&s2_orig_buf, &s2_buf); const s2_orig = s2_orig_buf[0..s2_len]; s2[0] = s2[0] +% 1; try testing.expectEqualStrings(s2_orig, istr.getHeader(v2).bytes()); try testing.expectEqual(s2_len, v2_len); }