From 16397241f6d85956f460f1b1049cf9ce0312bca4 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Wed, 30 Oct 2019 00:50:30 -0400 Subject: [PATCH] fix std.net tests and std.net.TcpServer docs --- lib/std/net.zig | 2 -- lib/std/net/test.zig | 10 +++++----- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/lib/std/net.zig b/lib/std/net.zig index e2f1f80b9..1794f36c8 100644 --- a/lib/std/net.zig +++ b/lib/std/net.zig @@ -1252,8 +1252,6 @@ fn dnsParseCallback(ctx: dpc_ctx, rr: u8, data: []const u8, packet: []const u8) } } -/// This API only works when `std.io.mode` is `std.io.Mode.evented`. -/// This struct is immovable after calling `listen`. pub const TcpServer = struct { /// Copied from `Options` on `init`. kernel_backlog: u32, diff --git a/lib/std/net/test.zig b/lib/std/net/test.zig index f62bcbd90..47d85ce18 100644 --- a/lib/std/net/test.zig +++ b/lib/std/net/test.zig @@ -4,7 +4,7 @@ const mem = std.mem; const testing = std.testing; test "std.net.parseIp4" { - assert((try parseIp4("127.0.0.1")) == mem.bigToNative(u32, 0x7f000001)); + testing.expect((try net.parseIp4("127.0.0.1")) == mem.bigToNative(u32, 0x7f000001)); testParseIp4Fail("256.0.0.1", error.Overflow); testParseIp4Fail("x.0.0.1", error.InvalidCharacter); @@ -14,16 +14,16 @@ test "std.net.parseIp4" { } fn testParseIp4Fail(buf: []const u8, expected_err: anyerror) void { - if (parseIp4(buf)) |_| { + if (net.parseIp4(buf)) |_| { @panic("expected error"); } else |e| { - assert(e == expected_err); + testing.expect(e == expected_err); } } test "std.net.parseIp6" { - const ip6 = try parseIp6("FF01:0:0:0:0:0:0:FB"); - const addr = Address.initIp6(ip6, 80); + const ip6 = try net.parseIp6("FF01:0:0:0:0:0:0:FB"); + const addr = net.Address.initIp6(ip6, 80); var buf: [100]u8 = undefined; const printed = try std.fmt.bufPrint(&buf, "{}", addr); std.testing.expect(mem.eql(u8, "[ff01::fb]:80", printed));