-
Notifications
You must be signed in to change notification settings - Fork 688
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b541737
commit 0ae4314
Showing
10 changed files
with
51 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
/.project | ||
/.classpath | ||
/.settings | ||
/build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 11 additions & 6 deletions
17
...a/com/d_project/qrcode/BitBufferTest.java → ...t/com/d_project/qrcode/BitBufferTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,43 @@ | ||
package com.d_project.qrcode; | ||
|
||
import junit.framework.TestCase; | ||
import org.junit.Assert; | ||
import org.junit.Test; | ||
|
||
public class BitBufferTest extends TestCase { | ||
public class BitBufferTest { | ||
|
||
@Test | ||
public void test1() { | ||
BitBuffer bb = new BitBuffer(); | ||
QRData qd = new QR8BitByte("534TEST!!!あ"); | ||
qd.write(bb); | ||
|
||
assertEquals(96, bb.getLengthInBits() ); | ||
Assert.assertEquals(96, bb.getLengthInBits() ); | ||
} | ||
|
||
@Test | ||
public void test2() { | ||
BitBuffer bb = new BitBuffer(); | ||
QRData qd = new QRAlphaNum("534TEST $%*+-./:"); | ||
qd.write(bb); | ||
|
||
assertEquals(88, bb.getLengthInBits() ); | ||
Assert.assertEquals(88, bb.getLengthInBits() ); | ||
} | ||
|
||
@Test | ||
public void test3() { | ||
BitBuffer bb = new BitBuffer(); | ||
QRData qd = new QRKanji("あいうえお"); | ||
qd.write(bb); | ||
|
||
assertEquals(65, bb.getLengthInBits() ); | ||
Assert.assertEquals(65, bb.getLengthInBits() ); | ||
} | ||
|
||
@Test | ||
public void test4() { | ||
BitBuffer bb = new BitBuffer(); | ||
QRData qd = new QRNumber("0123456789"); | ||
qd.write(bb); | ||
|
||
assertEquals(34, bb.getLengthInBits() ); | ||
Assert.assertEquals(34, bb.getLengthInBits() ); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 10 additions & 5 deletions
15
...java/com/d_project/qrcode/QRCodeTest.java → ...test/com/d_project/qrcode/QRCodeTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,46 @@ | ||
package com.d_project.qrcode; | ||
|
||
import junit.framework.TestCase; | ||
import org.junit.Assert; | ||
import org.junit.Test; | ||
|
||
public class QRCodeTest extends TestCase { | ||
public class QRCodeTest { | ||
|
||
@Test | ||
public void test1() { | ||
QRNumber data = new QRNumber("0123"); | ||
byte[] act = QRCode.createData(1, ErrorCorrectLevel.H, new QRData[]{data} ); | ||
byte[] exp = new byte[]{16,16,12,48,-20,17,-20,17,-20,-50,-20,-24,66,-27,44,-31,-124,-111,13,-69,-37,15,-16,36,-69,104}; | ||
assertEquals(exp, act); | ||
} | ||
|
||
@Test | ||
public void test2() { | ||
QRAlphaNum data = new QRAlphaNum("AB01"); | ||
byte[] act = QRCode.createData(1, ErrorCorrectLevel.H, new QRData[]{data} ); | ||
byte[] exp = new byte[]{32,33,-51,0,32,-20,17,-20,17,105,-125,-85,106,65,-91,54,-123,-112,-11,-73,21,-13,-106,-89,114,-25}; | ||
assertEquals(exp, act); | ||
} | ||
|
||
@Test | ||
public void test3() { | ||
QRKanji data = new QRKanji("漢字"); | ||
byte[] act = QRCode.createData(1, ErrorCorrectLevel.H, new QRData[]{data} ); | ||
byte[] exp = new byte[]{-128,35,-97,-88,104,0,-20,17,-20,-11,-82,108,-126,119,-6,118,-128,99,-41,-105,117,-68,-107,-120,47,-5}; | ||
assertEquals(exp, act); | ||
} | ||
|
||
@Test | ||
public void test4() { | ||
QR8BitByte data = new QR8BitByte("ab01"); | ||
byte[] act = QRCode.createData(1, ErrorCorrectLevel.H, new QRData[]{data} ); | ||
byte[] exp = new byte[]{64,70,22,35,3,16,-20,17,-20,91,-25,80,48,-87,54,40,-83,84,-117,33,87,54,-57,50,-84,49}; | ||
assertEquals(exp, act); | ||
} | ||
|
||
public void assertEquals(byte[] expected, byte[] actual) { | ||
assertEquals(expected.length, actual.length); | ||
protected void assertEquals(byte[] expected, byte[] actual) { | ||
Assert.assertEquals(expected.length, actual.length); | ||
for (int i = 0; i < expected.length; i++) { | ||
assertEquals(expected[i], actual[i]); | ||
Assert.assertEquals(expected[i], actual[i]); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters