/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test @summary Ensure that Murmur3 hash performs according to specification.
* @compile -XDignore.symbol.file Hashing.java
*/
public class Hashing {
static final byte ONE_BYTE[] = {
(byte) 0x80};
static final byte TWO_BYTE[] = {
(byte) 0x80, (byte) 0x81};
static final char ONE_CHAR[] = {
(char) 0x8180};
static final byte THREE_BYTE[] = {
(byte) 0x80, (byte) 0x81, (byte) 0x82};
static final byte FOUR_BYTE[] = {
(byte) 0x80, (byte) 0x81, (byte) 0x82, (byte) 0x83};
static final char TWO_CHAR[] = {
(char) 0x8180, (char) 0x8382};
static final int ONE_INT[] = {
0x83828180};
static final byte SIX_BYTE[] = {
(byte) 0x80, (byte) 0x81, (byte) 0x82,
(byte) 0x83, (byte) 0x84, (byte) 0x85};
static final char THREE_CHAR[] = {
(char) 0x8180, (char) 0x8382, (char) 0x8584};
static final byte EIGHT_BYTE[] = {
(byte) 0x80, (byte) 0x81, (byte) 0x82,
(byte) 0x83, (byte) 0x84, (byte) 0x85,
(byte) 0x86, (byte) 0x87};
static final char FOUR_CHAR[] = {
(char) 0x8180, (char) 0x8382,
(char) 0x8584, (char) 0x8786};
static final int TWO_INT[] = {
0x83828180, 0x87868584};
// per http://code.google.com/p/smhasher/source/browse/trunk/main.cpp, line:72
public static void testMurmur3_32_ByteArray() {
byte[] vector = new byte[256];
for (int i = 0; i < 256; i++) {
vector[i] = (byte) i;
}
// Hash subranges {}, {0}, {0,1}, {0,1,2}, ..., {0,...,255}
for (int i = 0; i < 256; i++) {
}
// hash to get final result.
if (MURMUR3_32_X86_CHECK_VALUE != final_hash) {
throw new RuntimeException(
final_hash));
}
}
public static void testEquivalentHashes() {
}
throw new RuntimeException(String.format("Hashes did not match. b:%08x != c:%08x != i:%08x", bytes, chars, ints));
}
}
throw new RuntimeException(String.format("Hashes did not match. b:%08x != c:%08x != i:%08x", bytes, chars, ints));
}
}
}
}