X-Git-Url: http://juplo.de/gitweb/?a=blobdiff_plain;f=percentcodec%2Fsrc%2Ftest%2Fjava%2Fde%2Fjuplo%2Fpercentcodec%2FPercentCodecTest.java;fp=percentcodec%2Fsrc%2Ftest%2Fjava%2Fde%2Fjuplo%2Fpercentcodec%2FPercentCodecTest.java;h=0000000000000000000000000000000000000000;hb=f95f687755d54c46975b15dbd0221e82a7458f79;hp=bec35fa3ddc84ac282a1f42f89672fc36276ef49;hpb=4f07e33a7c246caa3e4cd7c939f75064e4af03b0;p=percentcodec diff --git a/percentcodec/src/test/java/de/juplo/percentcodec/PercentCodecTest.java b/percentcodec/src/test/java/de/juplo/percentcodec/PercentCodecTest.java deleted file mode 100644 index bec35fa3..00000000 --- a/percentcodec/src/test/java/de/juplo/percentcodec/PercentCodecTest.java +++ /dev/null @@ -1,115 +0,0 @@ -package de.juplo.percentcodec; - -import de.juplo.percentcodec.PercentCodec; -import junit.framework.Assert; -import org.junit.Test; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - - -public class PercentCodecTest { - private final static Logger log = LoggerFactory.getLogger(PercentCodecTest.class); - - public final static char[] decoded = { ' ', '+', 'q', 's', '8', '0', 'x', 'ä', 'ß', 'à', '€', '¢', '@', '/', '?', '#', ';','.', '&', '%' }; - public final static String[] encoded_latin1 = { "%20", "%2b", "q", "s", "8", "0", "x", "%e4", "%df", "%e0", "%3f", "%a2", "%40", "%2f", "%3f", "%23", "%3b",".", "%26", "%25" }; - public final static String[] encoded_utf8 = { "%20", "%2b", "q", "s", "8", "0", "x", "%c3%a4", "%c3%9f", "%c3%a0", "%e2%82%ac", "%c2%a2", "%40", "%2f", "%3f", "%23", "%3b",".", "%26", "%25" }; - - - @Test - public void testEncodeLatin1() throws Exception { - PercentCodec codec = new PercentCodec("latin1"); - - for (int a = 0; a < decoded.length; a++) { - for (int b = 0; b < decoded.length; b++) { - for (int c = 0; c < decoded.length; c++) { - /** Das Zeichen '€' existiert in Latin1 nicht! */ - if (a == 10 || b == 10 || c == 10) - continue; - StringBuilder input = new StringBuilder(); - input.append(decoded[a]); - input.append(decoded[b]); - input.append(decoded[c]); - StringBuilder expected = new StringBuilder(); - expected.append(encoded_latin1[a]); - expected.append(encoded_latin1[b]); - expected.append(encoded_latin1[c]); - String output = codec.encode(input); - log.debug("{}\t-> {}", input, output); - Assert.assertEquals("\"" + input + "\" was encoded falsely", expected.toString(), output); - } - } - } - } - - @Test - public void testDecodeLatin1() throws Exception { - PercentCodec codec = new PercentCodec("latin1"); - - for (int a = 0; a < decoded.length; a++) { - for (int b = 0; b < decoded.length; b++) { - for (int c = 0; c < decoded.length; c++) { - /** Das Zeichen '€' existiert in Latin1 nicht! */ - if (a == 10 || b == 10 || c == 10) - continue; - StringBuilder input = new StringBuilder(); - input.append(encoded_latin1[a]); - input.append(encoded_latin1[b]); - input.append(encoded_latin1[c]); - StringBuilder expected = new StringBuilder(); - expected.append(decoded[a]); - expected.append(decoded[b]); - expected.append(decoded[c]); - String output = codec.decode(input); - log.debug("{}\t-> {}", input, output); - Assert.assertEquals("\"" + input + "\" was decoded falsely", expected.toString(), output); - } - } - } - } - - @Test - public void testEncodeUtf8() throws Exception { - PercentCodec codec = new PercentCodec("UTF-8"); - - for (int a = 0; a < decoded.length; a++) { - for (int b = 0; b < decoded.length; b++) { - for (int c = 0; c < decoded.length; c++) { - StringBuilder input = new StringBuilder(); - input.append(decoded[a]); - input.append(decoded[b]); - input.append(decoded[c]); - StringBuilder expected = new StringBuilder(); - expected.append(encoded_utf8[a]); - expected.append(encoded_utf8[b]); - expected.append(encoded_utf8[c]); - String output = codec.encode(input); - log.debug("{}\t-> {}", input, output); - Assert.assertEquals("\"" + input + "\" was encoded falsely", expected.toString(), output); - } - } - } - } - - @Test - public void testDecodeUtf8() throws Exception { - PercentCodec codec = new PercentCodec("UTF-8"); - - for (int a = 0; a < decoded.length; a++) { - for (int b = 0; b < decoded.length; b++) { - for (int c = 0; c < decoded.length; c++) { - StringBuilder input = new StringBuilder(); - input.append(encoded_utf8[a]); - input.append(encoded_utf8[b]); - input.append(encoded_utf8[c]); - StringBuilder expected = new StringBuilder(); - expected.append(decoded[a]); - expected.append(decoded[b]); - expected.append(decoded[c]); - String output = codec.decode(input); - log.debug("{}\t-> {}", input, output); - Assert.assertEquals("\"" + input + "\" was decoded falsely", expected.toString(), output); - } - } - } - } -}