mirror of
https://github.com/zxing/zxing.git
synced 2025-02-02 05:41:08 -08:00
Fixed more unit tests.
git-svn-id: https://zxing.googlecode.com/svn/trunk@737 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
parent
a13d3ca04d
commit
e7dfffc3d0
|
@ -185,7 +185,7 @@ public final class QRCode {
|
||||||
result.append("\n num_rs_blocks: ");
|
result.append("\n num_rs_blocks: ");
|
||||||
result.append(num_rs_blocks_);
|
result.append(num_rs_blocks_);
|
||||||
if (matrix_ == null) {
|
if (matrix_ == null) {
|
||||||
result.append("\n matrix: null");
|
result.append("\n matrix: null\n");
|
||||||
} else {
|
} else {
|
||||||
result.append("\n matrix:\n");
|
result.append("\n matrix:\n");
|
||||||
result.append(matrix_.toString());
|
result.append(matrix_.toString());
|
||||||
|
|
|
@ -17,16 +17,8 @@
|
||||||
package com.google.zxing.qrcode.encoder;
|
package com.google.zxing.qrcode.encoder;
|
||||||
|
|
||||||
import com.google.zxing.common.ByteMatrix;
|
import com.google.zxing.common.ByteMatrix;
|
||||||
import com.google.zxing.qrcode.encoder.MatrixUtil;
|
|
||||||
import junit.framework.TestCase;
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
//#include "util/array/array2d-inl.h"
|
|
||||||
//#include "wireless/qrcode/bit_vector-inl.h"
|
|
||||||
//#include "Strings/Stringpiece.h"
|
|
||||||
//#include "testing/base/gunit.h"
|
|
||||||
//#include "wireless/qrcode/qrcode.h"
|
|
||||||
//#include "wireless/qrcode/qrcode_matrix_util.h"
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author satorux@google.com (Satoru Takabayashi) - creator
|
* @author satorux@google.com (Satoru Takabayashi) - creator
|
||||||
* @author mysen@google.com (Chris Mysen) - ported from C++
|
* @author mysen@google.com (Chris Mysen) - ported from C++
|
||||||
|
@ -149,10 +141,8 @@ public final class MatrixUtilTestCase extends TestCase {
|
||||||
ByteMatrix matrix = new ByteMatrix(21, 21);
|
ByteMatrix matrix = new ByteMatrix(21, 21);
|
||||||
MatrixUtil.ClearMatrix(matrix);
|
MatrixUtil.ClearMatrix(matrix);
|
||||||
boolean info_okay = MatrixUtil.EmbedTypeInfo(QRCode.EC_LEVEL_M, 5, matrix);
|
boolean info_okay = MatrixUtil.EmbedTypeInfo(QRCode.EC_LEVEL_M, 5, matrix);
|
||||||
System.out.println(info_okay + "\n" + matrix.toString());
|
|
||||||
assertTrue(info_okay);
|
assertTrue(info_okay);
|
||||||
assertEquals(expected, matrix.toString());
|
assertEquals(expected, matrix.toString());
|
||||||
assertFalse(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testEmbedVersionInfo() {
|
public void testEmbedVersionInfo() {
|
||||||
|
|
|
@ -19,10 +19,6 @@ package com.google.zxing.qrcode.encoder;
|
||||||
import com.google.zxing.common.ByteMatrix;
|
import com.google.zxing.common.ByteMatrix;
|
||||||
import junit.framework.TestCase;
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
//#include "util/array/array2d-inl.h"
|
|
||||||
//#include "testing/base/gunit.h"
|
|
||||||
//#include "wireless/qrcode/qrcode.h"
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author satorux@google.com (Satoru Takabayashi) - creator
|
* @author satorux@google.com (Satoru Takabayashi) - creator
|
||||||
* @author mysen@google.com (Chris Mysen) - ported from C++
|
* @author mysen@google.com (Chris Mysen) - ported from C++
|
||||||
|
@ -63,7 +59,7 @@ public final class QRCodeTestCase extends TestCase {
|
||||||
// Just set bogus zero/one values.
|
// Just set bogus zero/one values.
|
||||||
for (int y = 0; y < 45; ++y) {
|
for (int y = 0; y < 45; ++y) {
|
||||||
for (int x = 0; x < 45; ++x) {
|
for (int x = 0; x < 45; ++x) {
|
||||||
matrix.set(y, x, (y + x) % 2);
|
matrix.set(y, x, (y + x) % 2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,7 +73,7 @@ public final class QRCodeTestCase extends TestCase {
|
||||||
// Make sure "at()" returns the same value.
|
// Make sure "at()" returns the same value.
|
||||||
for (int y = 0; y < 45; ++y) {
|
for (int y = 0; y < 45; ++y) {
|
||||||
for (int x = 0; x < 45; ++x) {
|
for (int x = 0; x < 45; ++x) {
|
||||||
assertEquals((y + x) % 2, qr_code.at(x, y));
|
assertEquals((y + x) % 2, qr_code.at(x, y));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -96,7 +92,7 @@ public final class QRCodeTestCase extends TestCase {
|
||||||
" num_data_bytes: -1\n" +
|
" num_data_bytes: -1\n" +
|
||||||
" num_ec_bytes: -1\n" +
|
" num_ec_bytes: -1\n" +
|
||||||
" num_rs_blocks: -1\n" +
|
" num_rs_blocks: -1\n" +
|
||||||
" matrix: NULL\n" +
|
" matrix: null\n" +
|
||||||
">>\n";
|
">>\n";
|
||||||
assertEquals(expected, qr_code.toString());
|
assertEquals(expected, qr_code.toString());
|
||||||
}
|
}
|
||||||
|
@ -147,9 +143,9 @@ public final class QRCodeTestCase extends TestCase {
|
||||||
qr_code.set_num_rs_blocks(1);
|
qr_code.set_num_rs_blocks(1);
|
||||||
ByteMatrix matrix = new ByteMatrix(21, 21);
|
ByteMatrix matrix = new ByteMatrix(21, 21);
|
||||||
for (int y = 0; y < 21; ++y) {
|
for (int y = 0; y < 21; ++y) {
|
||||||
for (int x = 0; x < 21; ++x) {
|
for (int x = 0; x < 21; ++x) {
|
||||||
matrix.set(y, x, (y + x) % 2);
|
matrix.set(y, x, (y + x) % 2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
qr_code.set_matrix(matrix);
|
qr_code.set_matrix(matrix);
|
||||||
assertTrue(qr_code.IsValid());
|
assertTrue(qr_code.IsValid());
|
||||||
|
@ -198,15 +194,13 @@ public final class QRCodeTestCase extends TestCase {
|
||||||
public void testModeToString() {
|
public void testModeToString() {
|
||||||
assertEquals("UNDEFINED", QRCode.ModeToString(QRCode.MODE_UNDEFINED));
|
assertEquals("UNDEFINED", QRCode.ModeToString(QRCode.MODE_UNDEFINED));
|
||||||
assertEquals("NUMERIC", QRCode.ModeToString(QRCode.MODE_NUMERIC));
|
assertEquals("NUMERIC", QRCode.ModeToString(QRCode.MODE_NUMERIC));
|
||||||
assertEquals("ALPHANUMERIC",
|
assertEquals("ALPHANUMERIC", QRCode.ModeToString(QRCode.MODE_ALPHANUMERIC));
|
||||||
QRCode.ModeToString(QRCode.MODE_ALPHANUMERIC));
|
|
||||||
assertEquals("8BIT_BYTE", QRCode.ModeToString(QRCode.MODE_8BIT_BYTE));
|
assertEquals("8BIT_BYTE", QRCode.ModeToString(QRCode.MODE_8BIT_BYTE));
|
||||||
assertEquals("UNKNOWN", QRCode.ModeToString(QRCode.NUM_MODES));
|
assertEquals("UNKNOWN", QRCode.ModeToString(QRCode.NUM_MODES));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testECLevelToString() {
|
public void testECLevelToString() {
|
||||||
assertEquals("UNDEFINED",
|
assertEquals("UNDEFINED", QRCode.ECLevelToString(QRCode.EC_LEVEL_UNDEFINED));
|
||||||
QRCode.ECLevelToString(QRCode.EC_LEVEL_UNDEFINED));
|
|
||||||
assertEquals("L", QRCode.ECLevelToString(QRCode.EC_LEVEL_L));
|
assertEquals("L", QRCode.ECLevelToString(QRCode.EC_LEVEL_L));
|
||||||
assertEquals("M", QRCode.ECLevelToString(QRCode.EC_LEVEL_M));
|
assertEquals("M", QRCode.ECLevelToString(QRCode.EC_LEVEL_M));
|
||||||
assertEquals("Q", QRCode.ECLevelToString(QRCode.EC_LEVEL_Q));
|
assertEquals("Q", QRCode.ECLevelToString(QRCode.EC_LEVEL_Q));
|
||||||
|
|
Loading…
Reference in a new issue