From: Maxim Kokryashkin via Tarantool-patches <tarantool-patches@dev.tarantool.org> To: "Sergey Kaplun" <skaplun@tarantool.org> Cc: tarantool-patches@dev.tarantool.org Subject: Re: [Tarantool-patches] [PATCH v2 luajit 2/6] test: introduce module for C tests Date: Fri, 19 May 2023 14:46:16 +0300 [thread overview] Message-ID: <1684496776.620499904@f752.i.mail.ru> (raw) In-Reply-To: <4564f805b390388473afa982db5cf3235f1cbaad.1684442182.git.skaplun@tarantool.org> [-- Attachment #1: Type: text/plain, Size: 2993 bytes --] Hi, Sergey! Thanks for the patch! LGTM. > >diff --git a/test/tarantool-c-tests/test.h b/test/tarantool-c-tests/test.h >new file mode 100644 >index 00000000..28df9daf >--- /dev/null >+++ b/test/tarantool-c-tests/test.h >@@ -0,0 +1,217 @@ Looks so much better now! >+#define LOCATION_FMT "location:\t%s:%d\n" >+#define ASSERT_NAME_FMT(name) "failed_assertion:\t" #name "\n" >+#define ASSERT_EQUAL_FMT(name_type, type_fmt) \ >+ LOCATION_FMT \ >+ ASSERT_NAME_FMT(assert_ ## name_type ## _equal) \ >+ "got: " type_fmt "\n" \ >+ "expected: " type_fmt "\n" >+ >+#define ASSERT_NOT_EQUAL_FMT(type_fmt) \ >+ LOCATION_FMT \ >+ ASSERT_NAME_FMT(assert_ ## name_type ## _not_equal) \ >+ "got: " type_fmt "\n" \ >+ "unexpected: " type_fmt "\n" >+ >+#define assert_true(cond) do { \ >+ if (!(cond)) { \ >+ test_save_diag_data(LOCATION_FMT \ >+ "condition_failed:\t'" #cond "'\n", \ >+ __FILE__, __LINE__); \ >+ _test_exit(TEST_LJMP_EXIT_FAILURE); \ >+ } \ >+} while (0) >+ >+#define assert_false(cond) assert_true(!(cond)) >+ >+#define assert_general(cond, fmt, ...) do { \ >+ if (!(cond)) { \ >+ test_save_diag_data(fmt, __VA_ARGS__); \ >+ _test_exit(TEST_LJMP_EXIT_FAILURE); \ >+ } \ >+} while (0) >+ >+#define assert_ptr_equal(got, expected) do { \ >+ assert_general((got) == (expected), \ >+ ASSERT_EQUAL_FMT(ptr, "%p"), \ >+ __FILE__, __LINE__, (got), (expected) \ >+ ); \ >+} while (0) >+ >+#define assert_ptr_not_equal(got, unexpected) do { \ >+ assert_general((got) != (unexpected), \ >+ ASSERT_NOT_EQUAL_FMT(ptr, "%p"), \ >+ __FILE__, __LINE__, (got), (unexpected) \ >+ ); \ >+} while (0) >+ >+ >+#define assert_int_equal(got, expected) do { \ >+ assert_general((got) == (expected), \ >+ ASSERT_EQUAL_FMT(int, "%d"), \ >+ __FILE__, __LINE__, (got), (expected) \ >+ ); \ >+} while (0) >+ >+#define assert_int_not_equal(got, unexpected) do { \ >+ assert_general((got) != (unexpected), \ >+ ASSERT_NOT_EQUAL_FMT(int, "%d"), \ >+ __FILE__, __LINE__, (got), (unexpected) \ >+ ); \ >+} while (0) >+ >+#define assert_sizet_equal(got, expected) do { \ >+ assert_general((got) == (expected), \ >+ ASSERT_EQUAL_FMT(sizet, "%lu"), \ >+ __FILE__, __LINE__, (got), (expected) \ >+ ); \ >+} while (0) >+ >+#define assert_sizet_not_equal(got, unexpected) do { \ >+ assert_general((got) != (unexpected), \ >+ ASSERT_NOT_EQUAL_FMT(sizet, "%lu"), \ >+ __FILE__, __LINE__, (got), (unexpected) \ >+ ); \ >+} while (0) >+ >+/* Check that doubles are __exactly__ the same. */ >+#define assert_double_equal(got, expected) do { \ >+ assert_general((got) == (expected), \ >+ ASSERT_EQUAL_FMT(double, "%lf"), \ >+ __FILE__, __LINE__, (got), (expected) \ >+ ); \ >+} while (0) >+ >+/* Check that doubles are not __exactly__ the same. */ >+#define assert_double_not_equal(got, unexpected) do { \ >+ assert_general((got) != (unexpected), \ >+ ASSERT_NOT_EQUAL_FMT(double, "%lf"), \ >+ __FILE__, __LINE__, (got), (unexpected) \ >+ ); \ >+} while (0) >+ >+#endif /* TEST_H */ >-- >2.34.1 -- Best regards, Maxim Kokryashkin [-- Attachment #2: Type: text/html, Size: 3521 bytes --]
next prev parent reply other threads:[~2023-05-19 11:46 UTC|newest] Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-05-18 20:44 [Tarantool-patches] [PATCH v2 luajit 0/6] Revorking " Sergey Kaplun via Tarantool-patches 2023-05-18 20:44 ` [Tarantool-patches] [PATCH v2 luajit 1/6] test: fix setting of {DY}LD_LIBRARY_PATH variables Sergey Kaplun via Tarantool-patches 2023-05-19 11:23 ` Maxim Kokryashkin via Tarantool-patches 2023-05-22 11:03 ` Sergey Bronnikov via Tarantool-patches 2023-05-23 6:47 ` Sergey Kaplun via Tarantool-patches 2023-05-29 14:37 ` Sergey Bronnikov via Tarantool-patches 2023-05-18 20:44 ` [Tarantool-patches] [PATCH v2 luajit 2/6] test: introduce module for C tests Sergey Kaplun via Tarantool-patches 2023-05-19 11:46 ` Maxim Kokryashkin via Tarantool-patches [this message] 2023-05-22 12:33 ` Sergey Bronnikov via Tarantool-patches 2023-05-24 6:41 ` Sergey Kaplun via Tarantool-patches 2023-05-25 17:33 ` Sergey Bronnikov via Tarantool-patches 2023-05-29 10:03 ` Sergey Kaplun via Tarantool-patches 2023-05-29 14:38 ` Sergey Bronnikov via Tarantool-patches 2023-05-31 13:32 ` Sergey Kaplun via Tarantool-patches 2023-05-18 20:44 ` [Tarantool-patches] [PATCH v2 luajit 3/6] test: introduce utils.h helper " Sergey Kaplun via Tarantool-patches 2023-05-19 11:58 ` Maxim Kokryashkin via Tarantool-patches 2023-05-20 7:52 ` Sergey Kaplun via Tarantool-patches 2023-05-29 15:26 ` Sergey Bronnikov via Tarantool-patches 2023-05-18 20:44 ` [Tarantool-patches] [PATCH v2 luajit 4/6] test: rewrite misclib-getmetrics-capi test in C Sergey Kaplun via Tarantool-patches 2023-05-19 12:17 ` Maxim Kokryashkin via Tarantool-patches 2023-05-20 8:08 ` Sergey Kaplun via Tarantool-patches 2023-05-29 16:15 ` Sergey Bronnikov via Tarantool-patches 2023-05-18 20:44 ` [Tarantool-patches] [PATCH v2 luajit 5/6] test: rewrite misclib-sysprof-capi " Sergey Kaplun via Tarantool-patches 2023-05-19 13:00 ` Maxim Kokryashkin via Tarantool-patches 2023-05-20 7:28 ` Sergey Kaplun via Tarantool-patches 2023-05-18 20:44 ` [Tarantool-patches] [PATCH v2 luajit 6/6] test: rewrite lj-49-bad-lightuserdata " Sergey Kaplun via Tarantool-patches 2023-05-19 12:40 ` Maxim Kokryashkin via Tarantool-patches 2023-05-19 14:29 ` [Tarantool-patches] [PATCH v2 luajit 0/6] Revorking C tests Maxim Kokryashkin via Tarantool-patches 2023-05-20 8:38 ` Sergey Kaplun via Tarantool-patches
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=1684496776.620499904@f752.i.mail.ru \ --to=tarantool-patches@dev.tarantool.org \ --cc=m.kokryashkin@tarantool.org \ --cc=skaplun@tarantool.org \ --subject='Re: [Tarantool-patches] [PATCH v2 luajit 2/6] test: introduce module for C tests' \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox