Debian Codegraph @

crt/aws-c-s3/tests/s3_checksums_xxhash_tests.c

raw symbols SCIP
1 /**
2 * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3 * SPDX-License-Identifier: Apache-2.0.
4 */
5 #include "aws/s3/private/s3_checksums.h"
6 #include <aws/cal/hash.h>
7 #include <aws/common/byte_buf.h>
8 #include <aws/testing/aws_test_harness.h>
9
10 #include <s3_checksums_test_case_helper.h>
11 /*
12 * There is no standard test vectors for xxhash.
13 * Just test that piping is correct.
14 */
15
16 AWS_TEST_CASE(xxhash64_test_piping, s_xxhash64_test_piping)
17 static int s_xxhash64_test_piping(struct aws_allocator *allocator, void *ctx) {
18 (void)ctx;
19
20 struct aws_byte_cursor input = aws_byte_cursor_from_c_str("abc");
21 uint8_t expected[] = {0x44, 0xbc, 0x2c, 0xf5, 0xad, 0x77, 0x09, 0x99};
22 struct aws_byte_cursor expected_buf = aws_byte_cursor_from_array(expected, sizeof(expected));
23
24 return s_verify_checksum_test_case(allocator, &input, &expected_buf, aws_checksum_new, AWS_SCA_XXHASH64);
25 }
26
27 AWS_TEST_CASE(xxhash3_64_test_piping, s_xxhash3_64_test_piping)
28 static int s_xxhash3_64_test_piping(struct aws_allocator *allocator, void *ctx) {
29 (void)ctx;
30
31 struct aws_byte_cursor input = aws_byte_cursor_from_c_str("abc");
32 uint8_t expected[] = {0x78, 0xaf, 0x5f, 0x94, 0x89, 0x2f, 0x39, 0x50};
33 struct aws_byte_cursor expected_buf = aws_byte_cursor_from_array(expected, sizeof(expected));
34
35 return s_verify_checksum_test_case(allocator, &input, &expected_buf, aws_checksum_new, AWS_SCA_XXHASH3_64);
36 }
37
38 AWS_TEST_CASE(xxhash3_128_test_piping, s_xxhash3_128_test_piping)
39 static int s_xxhash3_128_test_piping(struct aws_allocator *allocator, void *ctx) {
40 (void)ctx;
41
42 struct aws_byte_cursor input = aws_byte_cursor_from_c_str("abc");
43 uint8_t expected[] = {
44 0x06, 0xb0, 0x5a, 0xb6, 0x73, 0x3a, 0x61, 0x85, 0x78, 0xaf, 0x5f, 0x94, 0x89, 0x2f, 0x39, 0x50};
45 struct aws_byte_cursor expected_buf = aws_byte_cursor_from_array(expected, sizeof(expected));
46
47 return s_verify_checksum_test_case(allocator, &input, &expected_buf, aws_checksum_new, AWS_SCA_XXHASH3_128);
48 }