From: Sergey Kaplun via Tarantool-patches <tarantool-patches@dev.tarantool.org> To: Kirill Yukhin <kyukhin@tarantool.org>, Cyrill Gorcunov <gorcunov@gmail.com> Cc: tarantool-patches@dev.tarantool.org Subject: [Tarantool-patches] [PATCH] test: full testing of guava golden100 array Date: Wed, 10 Mar 2021 13:25:19 +0300 [thread overview] Message-ID: <20210310102519.18720-1-skaplun@tarantool.org> (raw) golden100 is an array of int32_t elements. So sizeof(uint64_t) is exactly double array element size. In other words, only half of golden100 array is checked. This patch makes calculation of array size type-independed. --- Branch: https://github.com/tarantool/tarantool/tree/skaplun/gh-noticket-golden100-test-fix Example to demonstrate the old behaviour: | $ gcc -x c <(echo -e "#include <stdint.h> | int main(void) { | int32_t g[] = {0, 55}; | uint64_t nr_elems = sizeof(g) / sizeof(uint64_t); | return nr_elems; | } | ") -o /tmp/test.exe && /tmp/test.exe || echo $? | 1 The new behaviour: | $ gcc -x c <(echo -e "#include <stdint.h> | int main(void) { | int32_t g[] = {0, 55}; | uint64_t nr_elems = sizeof(g) / sizeof(g[0]); | return nr_elems; | } | ") -o /tmp/test.exe && /tmp/test.exe || echo $? | 2 test/unit/guava.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/unit/guava.c b/test/unit/guava.c index fd496af9e..234d3627f 100644 --- a/test/unit/guava.c +++ b/test/unit/guava.c @@ -46,7 +46,7 @@ lcg_compat_check() 0, 55, 62, 8, 45, 59, 86, 97, 82, 59, 73, 37, 17, 56, 86, 21, 90, 37, 38, 83 }; - uint64_t nr_elems = (uint64_t)sizeof(golden100) / sizeof(uint64_t); + size_t nr_elems = sizeof(golden100) / sizeof(golden100[0]); for (size_t i = 0; i < nr_elems; ++i) check_guava_correctness(golden100[i]); -- 2.28.0
next reply other threads:[~2021-03-10 10:26 UTC|newest] Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-03-10 10:25 Sergey Kaplun via Tarantool-patches [this message] 2021-03-10 20:31 ` Cyrill Gorcunov via Tarantool-patches 2021-03-11 6:11 ` Sergey Kaplun via Tarantool-patches 2021-03-15 9:37 ` Kirill Yukhin 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=20210310102519.18720-1-skaplun@tarantool.org \ --to=tarantool-patches@dev.tarantool.org \ --cc=gorcunov@gmail.com \ --cc=kyukhin@tarantool.org \ --cc=skaplun@tarantool.org \ --subject='Re: [Tarantool-patches] [PATCH] test: full testing of guava golden100 array' \ /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