mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-08-02 14:57:31 +03:00
tcp: initial tests
This commit is contained in:
@ -325,6 +325,7 @@ test {
|
||||
_ = @import("termio.zig");
|
||||
_ = @import("input.zig");
|
||||
_ = @import("cli.zig");
|
||||
_ = @import("tcp.zig");
|
||||
_ = @import("surface_mouse.zig");
|
||||
|
||||
// Libraries
|
||||
|
@ -1,8 +1,8 @@
|
||||
//! TCP implementation. The TCP implementation is responsible for
|
||||
//! responding to TCP requests and dispatching them to the app's Mailbox.
|
||||
pub const Thread = @import("tcp/Thread.zig");
|
||||
pub const Server = @import("tcp/Server.zig");
|
||||
|
||||
test {
|
||||
@import("std").testing.refAllDecls(@This());
|
||||
_ = @import("tcp/Command.zig");
|
||||
_ = @import("tcp/Server.zig");
|
||||
}
|
||||
|
@ -44,4 +44,15 @@ pub const Command = enum {
|
||||
}
|
||||
};
|
||||
|
||||
// TODO: These need proper testing.
|
||||
test "Command.parse ping" {
|
||||
const input = "ping";
|
||||
const expected = Command.ping;
|
||||
const result = try Command.parse(input);
|
||||
try std.testing.expect(result == expected);
|
||||
}
|
||||
|
||||
test "Command.parse invalid input" {
|
||||
const input = "";
|
||||
const result = Command.parse(input);
|
||||
try std.testing.expectError(Command.Error.InvalidInput, result);
|
||||
}
|
||||
|
@ -125,3 +125,19 @@ pub fn parseAddress(raw_addr: ?[:0]const u8) BindError!std.net.Address {
|
||||
|
||||
return BindError.InvalidAddress;
|
||||
}
|
||||
|
||||
test "parseAddress unix socket" {
|
||||
const addr = "unix:///tmp/test.sock";
|
||||
const expected = try std.net.Address.initUnix("/tmp/test.sock");
|
||||
const actual = try parseAddress(addr);
|
||||
const result = std.net.Address.eql(actual, expected);
|
||||
try std.testing.expect(result == true);
|
||||
}
|
||||
|
||||
test "parseAddress IP address" {
|
||||
const addr = "tcp://127.0.0.1:9090";
|
||||
const expected = try std.net.Address.parseIp4("127.0.0.1", 9090);
|
||||
const actual = try parseAddress(addr);
|
||||
const result = std.net.Address.eql(actual, expected);
|
||||
try std.testing.expect(result == true);
|
||||
}
|
||||
|
Reference in New Issue
Block a user