diff --git a/javase/src/test/java/com/google/zxing/client/j2se/Base64DecoderTestCase.java b/javase/src/test/java/com/google/zxing/client/j2se/Base64DecoderTestCase.java new file mode 100644 index 000000000..8b286fbb9 --- /dev/null +++ b/javase/src/test/java/com/google/zxing/client/j2se/Base64DecoderTestCase.java @@ -0,0 +1,32 @@ +/* + * Copyright 2017 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.zxing.client.j2se; + +import org.junit.Assert; +import org.junit.Test; + +import java.nio.charset.StandardCharsets; + +public final class Base64DecoderTestCase extends Assert { + + @Test + public void testEncode() { + Base64Decoder decoder = Base64Decoder.getInstance(); + assertArrayEquals("foo".getBytes(StandardCharsets.UTF_8), decoder.decode("Zm9v")); + } + +} diff --git a/javase/src/test/java/com/google/zxing/client/j2se/ImageReaderTestCase.java b/javase/src/test/java/com/google/zxing/client/j2se/ImageReaderTestCase.java new file mode 100644 index 000000000..029e170db --- /dev/null +++ b/javase/src/test/java/com/google/zxing/client/j2se/ImageReaderTestCase.java @@ -0,0 +1,38 @@ +/* + * Copyright 2017 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.zxing.client.j2se; + +import org.junit.Assert; +import org.junit.Test; + +import java.awt.image.BufferedImage; +import java.net.URI; + +public final class ImageReaderTestCase extends Assert { + + @Test + public void testFoo() throws Exception { + String uri = + "data:image/gif;base64,R0lGODlhEAAQAMQAAORHHOVSKudfOulrSOp3WOyDZu6QdvCchPGolfO0o/XBs/fNwfjZ0frl3/zy7////w" + + "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAkAABAALAAAAAAQABAAAAVVICSOZGlCQAosJ6" + + "mu7fiyZeKqNKToQGDsM8hBADgUXoGAiqhSvp5QAnQKGIgUhwFUYLCVDFCrKUE1lBavAViFIDlTImbKC5Gm2hB0SlBCBMQiB0UjIQA7"; + BufferedImage image = ImageReader.readImage(new URI(uri)); + assertEquals(16, image.getWidth()); + assertEquals(16, image.getHeight()); + } + +} diff --git a/zxingorg/pom.xml b/zxingorg/pom.xml index 05c91d097..66bb42762 100644 --- a/zxingorg/pom.xml +++ b/zxingorg/pom.xml @@ -40,6 +40,11 @@ com.google.guava guava + + junit + junit + test + diff --git a/zxingorg/src/test/java/com/google/zxing/web/OutputUtilsTestCase.java b/zxingorg/src/test/java/com/google/zxing/web/OutputUtilsTestCase.java new file mode 100644 index 000000000..ade772d74 --- /dev/null +++ b/zxingorg/src/test/java/com/google/zxing/web/OutputUtilsTestCase.java @@ -0,0 +1,32 @@ +/* + * Copyright 2017 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.zxing.web; + +import org.junit.Assert; +import org.junit.Test; + +public final class OutputUtilsTestCase extends Assert { + + @Test + public void testOutput() { + byte[] array = new byte[] { 0, 1, -1, 127, -128, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 }; + assertEquals( + "00 01 ff 7f 80 02 03 04 05 06 07 08 09 0a 0b 0c\n", + OutputUtils.arrayToString(array)); + } + +}