1/*******************************************************************************
2 * Copyright (c) 2009, 2015 Mountainminds GmbH & Co. KG and Contributors
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html
7 *
8 * Contributors:
9 *    Marc R. Hoffmann - initial API and implementation
10 *
11 *******************************************************************************/
12package org.jacoco.core.internal.data;
13
14import static org.junit.Assert.assertEquals;
15
16import java.io.UnsupportedEncodingException;
17
18import org.junit.Test;
19
20/**
21 * Unit tests for {@link CRC64}.
22 */
23public class CRC64Test {
24
25	@Test
26	public void test0() {
27		final long sum = CRC64.checksum(new byte[0]);
28		assertEquals(0L, sum);
29	}
30
31	/**
32	 * Example taken from http://swissknife.sourceforge.net/docs/CRC64.html
33	 *
34	 * @throws UnsupportedEncodingException
35	 */
36	@Test
37	public void test1() throws UnsupportedEncodingException {
38		final long sum = CRC64.checksum("IHATEMATH".getBytes("ASCII"));
39		assertEquals(0xE3DCADD69B01ADD1L, sum);
40	}
41
42	/**
43	 * Example generated with http://fsumfe.sourceforge.net/
44	 *
45	 * @throws UnsupportedEncodingException
46	 */
47	@Test
48	public void test2() {
49		final long sum = CRC64.checksum(new byte[] { (byte) 0xff, (byte) 0xff,
50				(byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
51				(byte) 0xff, (byte) 0xff });
52		assertEquals(0x5300000000000000L, sum);
53	}
54
55	/**
56	 * Example generated with http://fsumfe.sourceforge.net/
57	 *
58	 * @throws UnsupportedEncodingException
59	 */
60	@Test
61	public void test3() throws UnsupportedEncodingException {
62		final long sum = CRC64.checksum("JACOCO_JACOCO_JACOCO_JACOCO"
63				.getBytes("ASCII"));
64		assertEquals(0xD8016B38AAD48308L, sum);
65	}
66
67}
68