|
| 1 | +// Copyright (c) 2023 VMware, Inc. or its affiliates. All rights reserved. |
| 2 | +// |
| 3 | +// This software, the RabbitMQ Stream Java client library, is dual-licensed under the |
| 4 | +// Mozilla Public License 2.0 ("MPL"), and the Apache License version 2 ("ASL"). |
| 5 | +// For the MPL, please see LICENSE-MPL-RabbitMQ. For the ASL, |
| 6 | +// please see LICENSE-APACHE2. |
| 7 | +// |
| 8 | +// This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, |
| 9 | +// either express or implied. See the LICENSE file for specific language governing |
| 10 | +// rights and limitations of this software. |
| 11 | +// |
| 12 | +// If you have any questions regarding licensing, please contact us at |
| 13 | + |
| 14 | +package com.rabbitmq.stream.impl; |
| 15 | + |
| 16 | +import static org.assertj.core.api.Assertions.assertThat; |
| 17 | + |
| 18 | +import org.junit.jupiter.params.ParameterizedTest; |
| 19 | +import org.junit.jupiter.params.provider.CsvSource; |
| 20 | + |
| 21 | +public class HashUtilsTest { |
| 22 | + |
| 23 | + @ParameterizedTest |
| 24 | + @CsvSource({"hello,1321743225", "brave,3825276426", "new,2970740106", "world,2453398188"}) |
| 25 | + void murmur3WithDefaultSeed(String input, String unsignedHash) { |
| 26 | + int expectedHash = Integer.parseUnsignedInt(unsignedHash); |
| 27 | + assertThat(HashUtils.MURMUR3.applyAsInt(input)).isEqualTo(expectedHash); |
| 28 | + } |
| 29 | + |
| 30 | + @ParameterizedTest |
| 31 | + @CsvSource({"hello,3806057185", "brave,619588758", "new,1483300585", "world,1145629360"}) |
| 32 | + void murmur3WithSeed(String input, String unsignedHash) { |
| 33 | + int expectedHash = Integer.parseUnsignedInt(unsignedHash); |
| 34 | + HashUtils.Murmur3 hash = new HashUtils.Murmur3(42); |
| 35 | + assertThat(hash.applyAsInt(input)).isEqualTo(expectedHash); |
| 36 | + } |
| 37 | +} |
0 commit comments