summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorKevin Smith <git@kismith.co.uk>2012-10-17 12:18:33 (GMT)
committerKevin Smith <git@kismith.co.uk>2012-10-17 12:19:54 (GMT)
commitaf68084020b0ebeba75541775a12cb0f07d10b18 (patch)
treefd26c1f7899fc45a03daf1967ef068efe958b2d4 /test
parentf952ee8db573fae8b2c91dbd04fe3d9f11258c9f (diff)
downloadstroke-af68084020b0ebeba75541775a12cb0f07d10b18.zip
stroke-af68084020b0ebeba75541775a12cb0f07d10b18.tar.bz2
Fix ZLib unit tests by fixing underlying hexify implementation
Change-Id: Iba3aeab8b0140c32f732ce01b1e2da243e7ec141
Diffstat (limited to 'test')
-rw-r--r--test/com/isode/stroke/stringcodecs/HexifyTest.java43
1 files changed, 43 insertions, 0 deletions
diff --git a/test/com/isode/stroke/stringcodecs/HexifyTest.java b/test/com/isode/stroke/stringcodecs/HexifyTest.java
new file mode 100644
index 0000000..4d6dc0d
--- /dev/null
+++ b/test/com/isode/stroke/stringcodecs/HexifyTest.java
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2012, Isode Limited, London, England.
+ * All rights reserved.
+ */
+/*
+ * Copyright (c) 2010, Remko Tronçon.
+ * All rights reserved.
+ */
+package com.isode.stroke.stringcodecs;
+
+import com.isode.stroke.base.ByteArray;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+public class HexifyTest {
+
+ private ByteArray fix(int[] vals) {
+ byte[] fixed = new byte[vals.length];
+ for (int i = 0; i < fixed.length; i++) {
+ fixed[i] = (byte) vals[i];
+ }
+ return new ByteArray(fixed);
+ }
+
+ @Test
+ public void testHexify() {
+ assertEquals("4206b23ca6b0a643d20d89b04ff58cf78b8096ed", Hexify.hexify(fix(new int[]{0x42, 0x06, 0xb2, 0x3c, 0xa6, 0xb0, 0xa6, 0x43, 0xd2, 0x0d, 0x89, 0xb0, 0x4f, 0xf5, 0x8c, 0xf7, 0x8b, 0x80, 0x96, 0xed})));
+ }
+
+ @Test
+ public void testHexify_Byte() {
+ assertEquals("b2", Hexify.hexify((byte) 0xb2));
+ }
+
+ @Test
+ public void testUnhexify() {
+ assertEquals("ffaf02", Hexify.hexify(Hexify.unhexify("ffaf02")));
+ assertEquals(new ByteArray(fix(new int[]{0x01, 0x23, 0xf2})), Hexify.unhexify("0123f2"));
+ }
+};
+