blob: 2be0271cdb8cb84ff9f80139e83af6204f6efbe4 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.io;
import org.junit.Test;
import com.yahoo.text.Utf8;
import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
import java.io.UnsupportedEncodingException;
import java.nio.ByteBuffer;
import java.nio.charset.Charset;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
/**
* @author <a href="mailto:simon@yahoo-inc.com">Simon Thoresen Hult</a>
* @author <a href="mailto:steinar@yahoo-inc.com">Steinar Knutsen</a>
*/
public class HexDumpTestCase {
private static final Charset UTF8 = Charset.forName("UTF-8");
private static final Charset UTF16 = Charset.forName("UTF-16");
@Test
public void requireThatToHexStringAcceptsNull() {
assertNull(HexDump.toHexString(null));
}
@Test
public void requireThatToHexStringIsUnformatted() {
assertEquals("6162636465666768696A6B6C6D6E6F707172737475767778797A",
HexDump.toHexString("abcdefghijklmnopqrstuvwxyz".getBytes(UTF8)));
assertEquals("FEFF006100620063006400650066006700680069006A006B006C00" +
"6D006E006F0070007100720073007400750076007700780079007A",
HexDump.toHexString("abcdefghijklmnopqrstuvwxyz".getBytes(UTF16)));
}
}
|