Update of /cvsroot/jaxme/JaxMe2/src/net/sf/jaxme/util
In directory sc8-pr-cvs1:/tmp/cvs-serv3549/src/net/sf/jaxme/util
Modified Files:
Base64Binary.java HexBinary.java
Log Message:
Made the test suite working again. Bugfix by Marty Kube.
Index: Base64Binary.java
===================================================================
RCS file: /cvsroot/jaxme/JaxMe2/src/net/sf/jaxme/util/Base64Binary.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- Base64Binary.java 10 Feb 2003 21:07:48 -0000 1.1
+++ Base64Binary.java 12 Feb 2003 18:55:46 -0000 1.2
@@ -23,4 +23,21 @@
public static String encode(byte[] pValue) {
return (new BASE64Encoder()).encode(pValue);
}
+
+ public static void main(String[] args) throws Exception {
+ byte[] bytes = new byte[]{1, 17, 35, 78, 115, -99, -69, -1};
+ String base64 = encode(bytes);
+ System.out.println(base64);
+ byte[] result = decode(base64);
+ if (result.length != bytes.length) {
+ System.err.println("length: " + result.length + " != " + bytes.length);
+ } else {
+ for (int i = 0; i < bytes.length; i++) {
+ if (bytes[i] != result[i]) {
+ System.err.println("byte " + i + ": " + bytes[i] + " != " + result[i]);
+ }
+ }
+ }
+ System.out.println("Ok");
+ }
}
Index: HexBinary.java
===================================================================
RCS file: /cvsroot/jaxme/JaxMe2/src/net/sf/jaxme/util/HexBinary.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- HexBinary.java 10 Feb 2003 21:07:47 -0000 1.1
+++ HexBinary.java 12 Feb 2003 18:55:46 -0000 1.2
@@ -16,25 +16,25 @@
}
byte[] result = new byte[pValue.length() / 2];
int j = 0;
- for (int i = 0; i < pValue.length(); i += 2) {
+ for (int i = 0; i < pValue.length(); ) {
byte b;
char c = pValue.charAt(i++);
- char d = pValue.charAt(j++);
+ char d = pValue.charAt(i++);
if (c >= '0' && c <= '9') {
b = (byte) ((c - '0') << 4);
} else if (c >= 'A' && c <= 'F') {
- b = (byte) ((c - 'A') << 4);
+ b = (byte) ((c - 'A' + 10) << 4);
} else if (c >= 'a' && c <= 'f') {
- b = (byte) ((c - 'a') << 4);
+ b = (byte) ((c - 'a' + 10) << 4);
} else {
throw new IllegalArgumentException("Invalid hex digit: " + c);
}
if (d >= '0' && d <= '9') {
b += (byte) (d - '0');
} else if (d >= 'A' && d <= 'F') {
- b = (byte) (d - 'A');
+ b += (byte) (d - 'A' + 10);
} else if (d >= 'a' && d <= 'f') {
- b = (byte) (d - 'a');
+ b += (byte) (d - 'a' + 10);
} else {
throw new IllegalArgumentException("Invalid hex digit: " + d);
}
-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
Jaxme-jaxb-dev mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jaxme-jaxb-dev