diff options
author | David Robillard <d@drobilla.net> | 2024-09-28 14:02:00 -0400 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2024-10-11 18:51:19 -0400 |
commit | 837179db6484241cebfb64ec7cf929cc58b7a42a (patch) | |
tree | e5f8e9d351c2217149718260d9c644d29e752fac /test | |
parent | 8befe96f974b1a4f447f73d19a2b1f7f9c3eb154 (diff) | |
download | raul-837179db6484241cebfb64ec7cf929cc58b7a42a.tar.gz raul-837179db6484241cebfb64ec7cf929cc58b7a42a.tar.bz2 raul-837179db6484241cebfb64ec7cf929cc58b7a42a.zip |
Check variables in unit tests
Avoid seemingly unused variables by checking something about them, even though
the main point of the test is to check something else.
Check accepted connections in socket test
Diffstat (limited to 'test')
-rw-r--r-- | test/maid_test.cpp | 3 | ||||
-rw-r--r-- | test/socket_test.cpp | 5 |
2 files changed, 7 insertions, 1 deletions
diff --git a/test/maid_test.cpp b/test/maid_test.cpp index 0456913..fbd278a 100644 --- a/test/maid_test.cpp +++ b/test/maid_test.cpp @@ -65,8 +65,10 @@ test() { assert(n_junk == 0); const Maid::managed_ptr<Junk> a = maid.make_managed<Junk>(1U); + assert(a->value() == 1U); assert(n_junk == 1); const Maid::managed_ptr<Junk> b = maid.make_managed<Junk>(2U); + assert(b->value() == 2U); assert(n_junk == 2); } @@ -119,6 +121,7 @@ test() // Allocate a new object, then let it and the Maid go out of scope const Maid::managed_ptr<Junk> c = maid.make_managed<Junk>(5U); + assert(c->value() == 5U); assert(n_junk == 1); } diff --git a/test/socket_test.cpp b/test/socket_test.cpp index b29788c..1f2d736 100644 --- a/test/socket_test.cpp +++ b/test/socket_test.cpp @@ -60,11 +60,15 @@ main() if (pfds[0].revents & POLLIN) { const std::shared_ptr<Socket> conn = unix_server_sock.accept(); + assert(conn); + assert(conn->fd()); ++n_received; } if (pfds[1].revents & POLLIN) { const std::shared_ptr<Socket> conn = tcp_server_sock.accept(); + assert(conn); + assert(conn->fd()); ++n_received; } } @@ -72,7 +76,6 @@ main() unix_server_sock.shutdown(); tcp_server_sock.shutdown(); unlink("/tmp/raul_test_sock"); - fprintf(stderr, "n received: %u\n", n_received); return n_received != 2; } |