diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2019-02-09 18:57:39 -0500 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2019-02-09 18:57:39 -0500 |
| commit | 1864acd32608ae917f8afc11b11f08a4bb362cef (patch) | |
| tree | d96b50a927fc67583d88c71822513594609621fb /std/atomic/queue.zig | |
| parent | 48c1e235cb620dacc30254d0898390b4d97f3e73 (diff) | |
| parent | ca8580ece1ab07215b72394cc4ab3030bf9df139 (diff) | |
| download | zig-1864acd32608ae917f8afc11b11f08a4bb362cef.tar.gz zig-1864acd32608ae917f8afc11b11f08a4bb362cef.zip | |
Merge remote-tracking branch 'origin/master' into llvm8
Diffstat (limited to 'std/atomic/queue.zig')
| -rw-r--r-- | std/atomic/queue.zig | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/std/atomic/queue.zig b/std/atomic/queue.zig index 183c434dc5..bdc86c0981 100644 --- a/std/atomic/queue.zig +++ b/std/atomic/queue.zig @@ -3,6 +3,7 @@ const builtin = @import("builtin"); const AtomicOrder = builtin.AtomicOrder; const AtomicRmwOp = builtin.AtomicRmwOp; const assert = std.debug.assert; +const expect = std.testing.expect; /// Many producer, many consumer, non-allocating, thread-safe. /// Uses a mutex to protect access. @@ -174,14 +175,14 @@ test "std.atomic.Queue" { { var i: usize = 0; while (i < put_thread_count) : (i += 1) { - std.debug.assertOrPanic(startPuts(&context) == 0); + expect(startPuts(&context) == 0); } } context.puts_done = 1; { var i: usize = 0; while (i < put_thread_count) : (i += 1) { - std.debug.assertOrPanic(startGets(&context) == 0); + expect(startGets(&context) == 0); } } } else { @@ -264,7 +265,7 @@ test "std.atomic.Queue single-threaded" { }; queue.put(&node_1); - assert(queue.get().?.data == 0); + expect(queue.get().?.data == 0); var node_2 = Queue(i32).Node{ .data = 2, @@ -280,9 +281,9 @@ test "std.atomic.Queue single-threaded" { }; queue.put(&node_3); - assert(queue.get().?.data == 1); + expect(queue.get().?.data == 1); - assert(queue.get().?.data == 2); + expect(queue.get().?.data == 2); var node_4 = Queue(i32).Node{ .data = 4, @@ -291,12 +292,12 @@ test "std.atomic.Queue single-threaded" { }; queue.put(&node_4); - assert(queue.get().?.data == 3); + expect(queue.get().?.data == 3); node_3.next = null; - assert(queue.get().?.data == 4); + expect(queue.get().?.data == 4); - assert(queue.get() == null); + expect(queue.get() == null); } test "std.atomic.Queue dump" { @@ -311,7 +312,7 @@ test "std.atomic.Queue dump" { // Test empty stream sos.reset(); try queue.dumpToStream(SliceOutStream.Error, &sos.stream); - assert(mem.eql(u8, buffer[0..sos.pos], + expect(mem.eql(u8, buffer[0..sos.pos], \\head: (null) \\tail: (null) \\ @@ -335,7 +336,7 @@ test "std.atomic.Queue dump" { \\ (null) \\ , @ptrToInt(queue.head), @ptrToInt(queue.tail)); - assert(mem.eql(u8, buffer[0..sos.pos], expected)); + expect(mem.eql(u8, buffer[0..sos.pos], expected)); // Test a stream with two elements var node_1 = Queue(i32).Node{ @@ -356,5 +357,5 @@ test "std.atomic.Queue dump" { \\ (null) \\ , @ptrToInt(queue.head), @ptrToInt(queue.head.?.next), @ptrToInt(queue.tail)); - assert(mem.eql(u8, buffer[0..sos.pos], expected)); + expect(mem.eql(u8, buffer[0..sos.pos], expected)); } |
