zig

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

test_simple_union.zig (333B) - Raw


      1 const std = @import("std");
      2 const expect = std.testing.expect;
      3 
      4 const Payload = union {
      5     int: i64,
      6     float: f64,
      7     boolean: bool,
      8 };
      9 test "simple union" {
     10     var payload = Payload{ .int = 1234 };
     11     try expect(payload.int == 1234);
     12     payload = Payload{ .float = 12.34 };
     13     try expect(payload.float == 12.34);
     14 }
     15 
     16 // test