mirror of
https://github.com/starovoid/rxing.git
synced 2026-07-26 04:12:34 +00:00
generic test runner
This commit is contained in:
@@ -25,7 +25,7 @@ mod common;
|
|||||||
fn aztec_black_box1_test_case() {
|
fn aztec_black_box1_test_case() {
|
||||||
let mut tester = common::AbstractBlackBoxTestCase::new(
|
let mut tester = common::AbstractBlackBoxTestCase::new(
|
||||||
"test_resources/blackbox/aztec-1",
|
"test_resources/blackbox/aztec-1",
|
||||||
Box::new(AztecReader {}),
|
AztecReader {},
|
||||||
BarcodeFormat::AZTEC,
|
BarcodeFormat::AZTEC,
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -47,7 +47,7 @@ fn aztec_black_box1_test_case() {
|
|||||||
fn aztec_black_box2_test_case() {
|
fn aztec_black_box2_test_case() {
|
||||||
let mut tester = common::AbstractBlackBoxTestCase::new(
|
let mut tester = common::AbstractBlackBoxTestCase::new(
|
||||||
"test_resources/blackbox/aztec-2",
|
"test_resources/blackbox/aztec-2",
|
||||||
Box::new(AztecReader {}),
|
AztecReader {},
|
||||||
BarcodeFormat::AZTEC,
|
BarcodeFormat::AZTEC,
|
||||||
);
|
);
|
||||||
// super(, new AztecReader(), BarcodeFormat.AZTEC);
|
// super(, new AztecReader(), BarcodeFormat.AZTEC);
|
||||||
|
|||||||
@@ -33,15 +33,16 @@ use super::TestRXingResult;
|
|||||||
* @author Sean Owen
|
* @author Sean Owen
|
||||||
* @author dswitkin@google.com (Daniel Switkin)
|
* @author dswitkin@google.com (Daniel Switkin)
|
||||||
*/
|
*/
|
||||||
pub struct AbstractBlackBoxTestCase {
|
pub struct AbstractBlackBoxTestCase<T:Reader> {
|
||||||
test_base: Box<Path>,
|
test_base: Box<Path>,
|
||||||
barcode_reader: Box<dyn Reader>,
|
barcode_reader: T,
|
||||||
expected_format: BarcodeFormat,
|
expected_format: BarcodeFormat,
|
||||||
test_rxing_results: Vec<TestRXingResult>,
|
test_rxing_results: Vec<TestRXingResult>,
|
||||||
hints: HashMap<DecodeHintType, DecodeHintValue>,
|
hints: HashMap<DecodeHintType, DecodeHintValue>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AbstractBlackBoxTestCase {
|
impl<T:Reader> AbstractBlackBoxTestCase<T> {
|
||||||
|
|
||||||
pub fn buildTestBase(testBasePathSuffix: &str) -> Box<Path> {
|
pub fn buildTestBase(testBasePathSuffix: &str) -> Box<Path> {
|
||||||
// A little workaround to prevent aggravation in my IDE
|
// A little workaround to prevent aggravation in my IDE
|
||||||
let test_base = Path::new(testBasePathSuffix);
|
let test_base = Path::new(testBasePathSuffix);
|
||||||
@@ -54,7 +55,7 @@ impl AbstractBlackBoxTestCase {
|
|||||||
|
|
||||||
pub fn new(
|
pub fn new(
|
||||||
test_base_path_suffix: &str,
|
test_base_path_suffix: &str,
|
||||||
barcode_reader: Box<dyn Reader>,
|
barcode_reader: T,
|
||||||
expected_format: BarcodeFormat,
|
expected_format: BarcodeFormat,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
Self {
|
Self {
|
||||||
@@ -129,7 +130,7 @@ impl AbstractBlackBoxTestCase {
|
|||||||
paths
|
paths
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn getReader(&self) -> &Box<dyn Reader> {
|
pub fn getReader(&self) -> &T {
|
||||||
&self.barcode_reader
|
&self.barcode_reader
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ mod common;
|
|||||||
fn maxicode1_test_case() {
|
fn maxicode1_test_case() {
|
||||||
let mut tester = common::AbstractBlackBoxTestCase::new(
|
let mut tester = common::AbstractBlackBoxTestCase::new(
|
||||||
"test_resources/blackbox/maxicode-1",
|
"test_resources/blackbox/maxicode-1",
|
||||||
Box::new(MaxiCodeReader {}),
|
MaxiCodeReader {},
|
||||||
BarcodeFormat::MAXICODE,
|
BarcodeFormat::MAXICODE,
|
||||||
);
|
);
|
||||||
// super("src/test/resources/blackbox/maxicode-1", new MultiFormatReader(), BarcodeFormat.MAXICODE);
|
// super("src/test/resources/blackbox/maxicode-1", new MultiFormatReader(), BarcodeFormat.MAXICODE);
|
||||||
@@ -44,7 +44,7 @@ fn maxicode1_test_case() {
|
|||||||
fn maxi_code_black_box1_test_case() {
|
fn maxi_code_black_box1_test_case() {
|
||||||
let mut tester = common::AbstractBlackBoxTestCase::new(
|
let mut tester = common::AbstractBlackBoxTestCase::new(
|
||||||
"test_resources/blackbox/maxicode-1",
|
"test_resources/blackbox/maxicode-1",
|
||||||
Box::new(MaxiCodeReader {}),
|
MaxiCodeReader {},
|
||||||
BarcodeFormat::MAXICODE,
|
BarcodeFormat::MAXICODE,
|
||||||
);
|
);
|
||||||
// super("src/test/resources/blackbox/maxicode-1", new MultiFormatReader(), BarcodeFormat.MAXICODE);
|
// super("src/test/resources/blackbox/maxicode-1", new MultiFormatReader(), BarcodeFormat.MAXICODE);
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ mod common;
|
|||||||
fn qrcode_black_box1_test_case() {
|
fn qrcode_black_box1_test_case() {
|
||||||
let mut tester = common::AbstractBlackBoxTestCase::new(
|
let mut tester = common::AbstractBlackBoxTestCase::new(
|
||||||
"test_resources/blackbox/qrcode-1",
|
"test_resources/blackbox/qrcode-1",
|
||||||
Box::new(QRCodeReader {}),
|
QRCodeReader {},
|
||||||
rxing::BarcodeFormat::QR_CODE,
|
rxing::BarcodeFormat::QR_CODE,
|
||||||
);
|
);
|
||||||
// super("src/test/resources/blackbox/qrcode-1", new MultiFormatReader(), BarcodeFormat.QR_CODE);
|
// super("src/test/resources/blackbox/qrcode-1", new MultiFormatReader(), BarcodeFormat.QR_CODE);
|
||||||
@@ -46,7 +46,7 @@ fn qrcode_black_box1_test_case() {
|
|||||||
fn qrcode_black_box2_test_case() {
|
fn qrcode_black_box2_test_case() {
|
||||||
let mut tester = common::AbstractBlackBoxTestCase::new(
|
let mut tester = common::AbstractBlackBoxTestCase::new(
|
||||||
"test_resources/blackbox/qrcode-2",
|
"test_resources/blackbox/qrcode-2",
|
||||||
Box::new(QRCodeReader {}),
|
QRCodeReader {},
|
||||||
BarcodeFormat::QR_CODE,
|
BarcodeFormat::QR_CODE,
|
||||||
);
|
);
|
||||||
tester.addTest(31, 31, 0.0);
|
tester.addTest(31, 31, 0.0);
|
||||||
@@ -65,7 +65,7 @@ fn qrcode_black_box2_test_case() {
|
|||||||
fn qrcode_black_box3_test_case() {
|
fn qrcode_black_box3_test_case() {
|
||||||
let mut tester = common::AbstractBlackBoxTestCase::new(
|
let mut tester = common::AbstractBlackBoxTestCase::new(
|
||||||
"test_resources/blackbox/qrcode-3",
|
"test_resources/blackbox/qrcode-3",
|
||||||
Box::new(QRCodeReader {}),
|
QRCodeReader {},
|
||||||
BarcodeFormat::QR_CODE,
|
BarcodeFormat::QR_CODE,
|
||||||
);
|
);
|
||||||
tester.addTest(38, 38, 0.0);
|
tester.addTest(38, 38, 0.0);
|
||||||
@@ -86,7 +86,7 @@ fn qrcode_black_box3_test_case() {
|
|||||||
fn qrcode_black_box4_test_case() {
|
fn qrcode_black_box4_test_case() {
|
||||||
let mut tester = common::AbstractBlackBoxTestCase::new(
|
let mut tester = common::AbstractBlackBoxTestCase::new(
|
||||||
"test_resources/blackbox/qrcode-4",
|
"test_resources/blackbox/qrcode-4",
|
||||||
Box::new(QRCodeReader {}),
|
QRCodeReader {},
|
||||||
BarcodeFormat::QR_CODE,
|
BarcodeFormat::QR_CODE,
|
||||||
);
|
);
|
||||||
tester.addTest(36, 36, 0.0);
|
tester.addTest(36, 36, 0.0);
|
||||||
@@ -109,7 +109,7 @@ fn qrcode_black_box4_test_case() {
|
|||||||
fn qrcode_black_box5_test_case() {
|
fn qrcode_black_box5_test_case() {
|
||||||
let mut tester = common::AbstractBlackBoxTestCase::new(
|
let mut tester = common::AbstractBlackBoxTestCase::new(
|
||||||
"test_resources/blackbox/qrcode-5",
|
"test_resources/blackbox/qrcode-5",
|
||||||
Box::new(QRCodeReader {}),
|
QRCodeReader {},
|
||||||
BarcodeFormat::QR_CODE,
|
BarcodeFormat::QR_CODE,
|
||||||
);
|
);
|
||||||
tester.addTest(19, 19, 0.0);
|
tester.addTest(19, 19, 0.0);
|
||||||
@@ -129,7 +129,7 @@ fn qrcode_black_box5_test_case() {
|
|||||||
fn qrcode_black_box6_test_case() {
|
fn qrcode_black_box6_test_case() {
|
||||||
let mut tester = common::AbstractBlackBoxTestCase::new(
|
let mut tester = common::AbstractBlackBoxTestCase::new(
|
||||||
"test_resources/blackbox/qrcode-6",
|
"test_resources/blackbox/qrcode-6",
|
||||||
Box::new(QRCodeReader {}),
|
QRCodeReader {},
|
||||||
BarcodeFormat::QR_CODE,
|
BarcodeFormat::QR_CODE,
|
||||||
);
|
);
|
||||||
tester.addTest(15, 15, 0.0);
|
tester.addTest(15, 15, 0.0);
|
||||||
|
|||||||
Reference in New Issue
Block a user