Skip to content

Commit d8a681a

Browse files
committed
Add more tests for non-core modules
1 parent f312da5 commit d8a681a

File tree

4 files changed

+107
-0
lines changed

4 files changed

+107
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*
2+
* Copyright 2017 ZXing authors
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.google.zxing.client.j2se;
18+
19+
import org.junit.Assert;
20+
import org.junit.Test;
21+
22+
import java.nio.charset.StandardCharsets;
23+
24+
public final class Base64DecoderTestCase extends Assert {
25+
26+
@Test
27+
public void testEncode() {
28+
Base64Decoder decoder = Base64Decoder.getInstance();
29+
assertArrayEquals("foo".getBytes(StandardCharsets.UTF_8), decoder.decode("Zm9v"));
30+
}
31+
32+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/*
2+
* Copyright 2017 ZXing authors
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.google.zxing.client.j2se;
18+
19+
import org.junit.Assert;
20+
import org.junit.Test;
21+
22+
import java.awt.image.BufferedImage;
23+
import java.net.URI;
24+
25+
public final class ImageReaderTestCase extends Assert {
26+
27+
@Test
28+
public void testFoo() throws Exception {
29+
String uri =
30+
"data:image/gif;base64,R0lGODlhEAAQAMQAAORHHOVSKudfOulrSOp3WOyDZu6QdvCchPGolfO0o/XBs/fNwfjZ0frl3/zy7////w" +
31+
"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAkAABAALAAAAAAQABAAAAVVICSOZGlCQAosJ6" +
32+
"mu7fiyZeKqNKToQGDsM8hBADgUXoGAiqhSvp5QAnQKGIgUhwFUYLCVDFCrKUE1lBavAViFIDlTImbKC5Gm2hB0SlBCBMQiB0UjIQA7";
33+
BufferedImage image = ImageReader.readImage(new URI(uri));
34+
assertEquals(16, image.getWidth());
35+
assertEquals(16, image.getHeight());
36+
}
37+
38+
}

zxingorg/pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@
4040
<groupId>com.google.guava</groupId>
4141
<artifactId>guava</artifactId>
4242
</dependency>
43+
<dependency>
44+
<groupId>junit</groupId>
45+
<artifactId>junit</artifactId>
46+
<scope>test</scope>
47+
</dependency>
4348
</dependencies>
4449

4550
<parent>
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*
2+
* Copyright 2017 ZXing authors
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.google.zxing.web;
18+
19+
import org.junit.Assert;
20+
import org.junit.Test;
21+
22+
public final class OutputUtilsTestCase extends Assert {
23+
24+
@Test
25+
public void testOutput() {
26+
byte[] array = new byte[] { 0, 1, -1, 127, -128, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 };
27+
assertEquals(
28+
"00 01 ff 7f 80 02 03 04 05 06 07 08 09 0a 0b 0c\n",
29+
OutputUtils.arrayToString(array));
30+
}
31+
32+
}

0 commit comments

Comments
 (0)