提交 f0363a57 编写于 作者: T ThomasPerkins1123 提交者: Oleg Nenashev

Add unit tests for hudson.cli.HexDump (#4058)

* Add unit tests for hudson.cli.HexDump

These tests were written using Diffblue Cover.

* Changed byte arrays to work for windows
上级 4404c6e6
package hudson.cli;
import org.junit.Assert;
import org.junit.Test;
public class HexDumpTest {
@Test
public void testToHex1() {
Assert.assertEquals("'fooBar'",
HexDump.toHex(new byte[] {'f', 'o', 'o', 'B', 'a', 'r'}));
Assert.assertEquals("0xc3",
HexDump.toHex(new byte[] {(byte)'Ã'}));
Assert.assertEquals("0xac '100'",
HexDump.toHex(new byte[] {(byte)'€', '1', '0', '0'}));
Assert.assertEquals("'1' 0xf7 '2'",
HexDump.toHex(new byte[] {'1', (byte)'÷', '2'}));
Assert.assertEquals("'foo' 0x0a\n'Bar'",
HexDump.toHex(new byte[] {'f', 'o', 'o', '\n', 'B', 'a', 'r'}));
}
@Test
public void testToHex2() {
Assert.assertEquals("'ooBa'",
HexDump.toHex(new byte[] {'f', 'o', 'o', 'B', 'a', 'r'}, 1, 4));
Assert.assertEquals("0xc3",
HexDump.toHex(new byte[] {(byte)'Ã'}, 0, 1));
Assert.assertEquals("0xac '10'",
HexDump.toHex(new byte[] {(byte)'€', '1', '0', '0'}, 0, 3));
Assert.assertEquals("0xf7 '2'",
HexDump.toHex(new byte[] {'1', (byte)'÷', '2'}, 1, 2));
Assert.assertEquals("'Bar'",
HexDump.toHex(new byte[] {'f', 'o', 'o', '\n', 'B', 'a', 'r'}, 4, 3));
Assert.assertEquals("",
HexDump.toHex(new byte[] {'f', 'o', 'o', 'B', 'a', 'r'}, 0, 0));
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册