summaryrefslogtreecommitdiff
path: root/neozip/test/test_adler32.cc
diff options
context:
space:
mode:
authorMehmet Samet Duman <yongdohyun@projecttick.org>2026-04-02 19:56:09 +0300
committerMehmet Samet Duman <yongdohyun@projecttick.org>2026-04-02 19:56:09 +0300
commit7fb132859fda54aa96bc9dd46d302b343eeb5a02 (patch)
treeb43ae77d7451fb470a260c03349a1caf2846c5e5 /neozip/test/test_adler32.cc
parentb1e34e861b5d732afe828d58aad2c638135061fd (diff)
parentc2712b8a345191f6ed79558c089777df94590087 (diff)
downloadProject-Tick-7fb132859fda54aa96bc9dd46d302b343eeb5a02.tar.gz
Project-Tick-7fb132859fda54aa96bc9dd46d302b343eeb5a02.zip
Add 'neozip/' from commit 'c2712b8a345191f6ed79558c089777df94590087'
git-subtree-dir: neozip git-subtree-mainline: b1e34e861b5d732afe828d58aad2c638135061fd git-subtree-split: c2712b8a345191f6ed79558c089777df94590087
Diffstat (limited to 'neozip/test/test_adler32.cc')
-rw-r--r--neozip/test/test_adler32.cc75
1 files changed, 75 insertions, 0 deletions
diff --git a/neozip/test/test_adler32.cc b/neozip/test/test_adler32.cc
new file mode 100644
index 0000000000..c461f93939
--- /dev/null
+++ b/neozip/test/test_adler32.cc
@@ -0,0 +1,75 @@
+/* test_adler32.c -- unit test for adler32 in the zlib compression library
+ * Copyright (C) 2020 IBM Corporation
+ * Author: Rogerio Alves <rcardoso@linux.ibm.com>
+ * For conditions of distribution and use, see copyright notice in zlib.h
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+
+extern "C" {
+# include "zbuild.h"
+# include "arch_functions.h"
+# include "test_cpu_features.h"
+# include "hash_test_strings_p.h"
+}
+
+#include <gtest/gtest.h>
+
+class adler32_variant : public ::testing::TestWithParam<hash_test> {
+public:
+ void hash(hash_test param, adler32_func adler32) {
+ uint32_t adler = adler32((uint32_t)param.initial_adler, param.buf, param.len);
+ EXPECT_EQ(adler, param.expect_adler);
+ }
+};
+
+INSTANTIATE_TEST_SUITE_P(adler32, adler32_variant, testing::ValuesIn(hash_tests));
+
+#define TEST_ADLER32(name, func, support_flag) \
+ TEST_P(adler32_variant, name) { \
+ if (!(support_flag)) { \
+ GTEST_SKIP(); \
+ return; \
+ } \
+ hash(GetParam(), func); \
+ }
+
+TEST_ADLER32(c, adler32_c, 1)
+
+#ifdef DISABLE_RUNTIME_CPU_DETECTION
+TEST_ADLER32(native, native_adler32, 1)
+#else
+
+#ifdef ARM_NEON
+TEST_ADLER32(neon, adler32_neon, test_cpu_features.arm.has_neon)
+#elif defined(POWER8_VSX)
+TEST_ADLER32(power8, adler32_power8, test_cpu_features.power.has_arch_2_07)
+#elif defined(PPC_VMX)
+TEST_ADLER32(vmx, adler32_vmx, test_cpu_features.power.has_altivec)
+#elif defined(RISCV_RVV)
+TEST_ADLER32(rvv, adler32_rvv, test_cpu_features.riscv.has_rvv)
+#endif
+
+#ifdef X86_SSSE3
+TEST_ADLER32(ssse3, adler32_ssse3, test_cpu_features.x86.has_ssse3)
+#endif
+#ifdef X86_AVX2
+TEST_ADLER32(avx2, adler32_avx2, test_cpu_features.x86.has_avx2)
+#endif
+#ifdef X86_AVX512
+TEST_ADLER32(avx512, adler32_avx512, test_cpu_features.x86.has_avx512_common)
+#endif
+#ifdef X86_AVX512VNNI
+TEST_ADLER32(avx512_vnni, adler32_avx512_vnni, test_cpu_features.x86.has_avx512vnni)
+#endif
+
+#ifdef LOONGARCH_LSX
+TEST_ADLER32(lsx, adler32_lsx, test_cpu_features.loongarch.has_lsx)
+#endif
+#ifdef LOONGARCH_LASX
+TEST_ADLER32(lasx, adler32_lasx, test_cpu_features.loongarch.has_lasx)
+#endif
+
+#endif