Tarantool development patches archive
 help / color / mirror / Atom feed
* [Tarantool-patches] [PATCH] test: full testing of guava golden100 array
@ 2021-03-10 10:25 Sergey Kaplun via Tarantool-patches
  2021-03-10 20:31 ` Cyrill Gorcunov via Tarantool-patches
  2021-03-15  9:37 ` Kirill Yukhin via Tarantool-patches
  0 siblings, 2 replies; 4+ messages in thread
From: Sergey Kaplun via Tarantool-patches @ 2021-03-10 10:25 UTC (permalink / raw)
  To: Kirill Yukhin, Cyrill Gorcunov; +Cc: tarantool-patches

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


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-03-15  9:37 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-10 10:25 [Tarantool-patches] [PATCH] test: full testing of guava golden100 array Sergey Kaplun via Tarantool-patches
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox