zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

test_void_in_hashmap.zig (387B) - Raw


      1 const std = @import("std");
      2 const expect = std.testing.expect;
      3 
      4 test "turn HashMap into a set with void" {
      5     var map = std.AutoHashMap(i32, void).init(std.testing.allocator);
      6     defer map.deinit();
      7 
      8     try map.put(1, {});
      9     try map.put(2, {});
     10 
     11     try expect(map.contains(2));
     12     try expect(!map.contains(3));
     13 
     14     _ = map.remove(2);
     15     try expect(!map.contains(2));
     16 }
     17 
     18 // test