test: Migrated custom test to proper test.

This commit is contained in:
2026-07-08 16:49:00 -04:00
parent fb6581345e
commit 27b3c68df7
2 changed files with 32 additions and 28 deletions
+32
View File
@@ -16,6 +16,7 @@ test_version :: proc(t: ^testing.T) {
@(test)
test_connect_does_not_allocate_with_string_literals :: proc(t: ^testing.T) {
context.allocator = runtime.panic_allocator()
context.temp_allocator = runtime.panic_allocator()
ctx := ctx_new()
@@ -115,3 +116,34 @@ test_simple_const_echo :: proc(t: ^testing.T) {
}
}
@(test)
test_duplicate_bind_fails :: proc(t: ^testing.T) {
ctx := ctx_new()
defer ctx_term(ctx)
rep1, serr := socket(ctx, .REP)
testing.expect_value(t, serr, nil)
if serr != nil {
testing.fail_now(t, "create first socket")
}
defer close(rep1)
if berr := bind(rep1, "inproc://duplicate"); berr != nil {
testing.expect_value(t, berr, nil)
testing.fail_now(t, "first bind should succeed")
}
rep2, cerr := socket(ctx, .REP)
testing.expect_value(t, cerr, nil)
if cerr != nil {
testing.fail_now(t, "create second socket")
}
defer close(rep2)
if berr := bind(rep2, "inproc://duplicate"); berr == nil {
testing.fail_now(t, "second bind to same endpoint should fail with EADDRINUSE")
} else {
testing.expect_value(t, berr, ZMQ_Error.EADDRINUSE)
}
}