hare

[hare] The Hare programming language
git clone https://git.torresjrjr.com/hare.git
Log | Files | Refs | README | LICENSE

commit 5b0f6d2d07b674f65c30a8eeccfc5fd33bc9545c
parent a3749ad1ff35cfcd356b9aae2682001121853390
Author: Haelwenn (lanodan) Monnier <contact+sr.ht@hacktivis.me>
Date:   Wed,  7 Dec 2022 17:17:59 +0100

net/uri/+test: Use wanted/got wrapping for all str assertions

Signed-off-by: Haelwenn (lanodan) Monnier <contact+sr.ht@hacktivis.me>
Signed-off-by: Drew DeVault <sir@cmpwn.com>

Diffstat:
Mnet/uri/+test.ha | 22+++++++++++++---------
1 file changed, 13 insertions(+), 9 deletions(-)

diff --git a/net/uri/+test.ha b/net/uri/+test.ha @@ -145,25 +145,29 @@ fn test_uri(in: str, expected_uri: uri, expected_str: str) (void | invalid) = { const u = parse(in)?; defer finish(&u); - assert(u.scheme == expected_uri.scheme); + assert_str(u.scheme, expected_uri.scheme); match (u.host) { case let s: str => - assert(s == expected_uri.host as str); + assert_str(s, expected_uri.host as str); case let i: ip::addr => assert(ip::equal(i, expected_uri.host as ip::addr)); }; assert(u.port == expected_uri.port); - assert(u.userinfo == expected_uri.userinfo); - assert(u.path == expected_uri.path); - assert(u.query == expected_uri.query); - assert(u.fragment == expected_uri.fragment); + assert_str(u.userinfo, expected_uri.userinfo); + assert_str(u.path, expected_uri.path); + assert_str(u.query, expected_uri.query); + assert_str(u.fragment, expected_uri.fragment); const s = string(&u); defer free(s); - if (s != expected_str) { - fmt::errorfln("=== wanted\n{}", expected_str)!; - fmt::errorfln("=== got\n{}", s)!; + assert_str(s, expected_str); +}; + +fn assert_str(got: str, expected: str) void = { + if (got != expected) { + fmt::errorfln("=== wanted\n{}", expected)!; + fmt::errorfln("=== got\n{}", got)!; abort(); }; };