generic test runner

This commit is contained in:
Henry Schimke
2022-10-16 13:18:13 -05:00
parent accf587bea
commit 5a1ae8cd90
4 changed files with 16 additions and 15 deletions

View File

@@ -25,7 +25,7 @@ mod common;
fn aztec_black_box1_test_case() {
let mut tester = common::AbstractBlackBoxTestCase::new(
"test_resources/blackbox/aztec-1",
Box::new(AztecReader {}),
AztecReader {},
BarcodeFormat::AZTEC,
);
@@ -47,7 +47,7 @@ fn aztec_black_box1_test_case() {
fn aztec_black_box2_test_case() {
let mut tester = common::AbstractBlackBoxTestCase::new(
"test_resources/blackbox/aztec-2",
Box::new(AztecReader {}),
AztecReader {},
BarcodeFormat::AZTEC,
);
// super(, new AztecReader(), BarcodeFormat.AZTEC);

View File

@@ -33,15 +33,16 @@ use super::TestRXingResult;
* @author Sean Owen
* @author dswitkin@google.com (Daniel Switkin)
*/
pub struct AbstractBlackBoxTestCase {
pub struct AbstractBlackBoxTestCase<T:Reader> {
test_base: Box<Path>,
barcode_reader: Box<dyn Reader>,
barcode_reader: T,
expected_format: BarcodeFormat,
test_rxing_results: Vec<TestRXingResult>,
hints: HashMap<DecodeHintType, DecodeHintValue>,
}
impl AbstractBlackBoxTestCase {
impl<T:Reader> AbstractBlackBoxTestCase<T> {
pub fn buildTestBase(testBasePathSuffix: &str) -> Box<Path> {
// A little workaround to prevent aggravation in my IDE
let test_base = Path::new(testBasePathSuffix);
@@ -54,7 +55,7 @@ impl AbstractBlackBoxTestCase {
pub fn new(
test_base_path_suffix: &str,
barcode_reader: Box<dyn Reader>,
barcode_reader: T,
expected_format: BarcodeFormat,
) -> Self {
Self {
@@ -129,7 +130,7 @@ impl AbstractBlackBoxTestCase {
paths
}
pub fn getReader(&self) -> &Box<dyn Reader> {
pub fn getReader(&self) -> &T {
&self.barcode_reader
}

View File

@@ -25,7 +25,7 @@ mod common;
fn maxicode1_test_case() {
let mut tester = common::AbstractBlackBoxTestCase::new(
"test_resources/blackbox/maxicode-1",
Box::new(MaxiCodeReader {}),
MaxiCodeReader {},
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() {
let mut tester = common::AbstractBlackBoxTestCase::new(
"test_resources/blackbox/maxicode-1",
Box::new(MaxiCodeReader {}),
MaxiCodeReader {},
BarcodeFormat::MAXICODE,
);
// super("src/test/resources/blackbox/maxicode-1", new MultiFormatReader(), BarcodeFormat.MAXICODE);

View File

@@ -26,7 +26,7 @@ mod common;
fn qrcode_black_box1_test_case() {
let mut tester = common::AbstractBlackBoxTestCase::new(
"test_resources/blackbox/qrcode-1",
Box::new(QRCodeReader {}),
QRCodeReader {},
rxing::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() {
let mut tester = common::AbstractBlackBoxTestCase::new(
"test_resources/blackbox/qrcode-2",
Box::new(QRCodeReader {}),
QRCodeReader {},
BarcodeFormat::QR_CODE,
);
tester.addTest(31, 31, 0.0);
@@ -65,7 +65,7 @@ fn qrcode_black_box2_test_case() {
fn qrcode_black_box3_test_case() {
let mut tester = common::AbstractBlackBoxTestCase::new(
"test_resources/blackbox/qrcode-3",
Box::new(QRCodeReader {}),
QRCodeReader {},
BarcodeFormat::QR_CODE,
);
tester.addTest(38, 38, 0.0);
@@ -86,7 +86,7 @@ fn qrcode_black_box3_test_case() {
fn qrcode_black_box4_test_case() {
let mut tester = common::AbstractBlackBoxTestCase::new(
"test_resources/blackbox/qrcode-4",
Box::new(QRCodeReader {}),
QRCodeReader {},
BarcodeFormat::QR_CODE,
);
tester.addTest(36, 36, 0.0);
@@ -109,7 +109,7 @@ fn qrcode_black_box4_test_case() {
fn qrcode_black_box5_test_case() {
let mut tester = common::AbstractBlackBoxTestCase::new(
"test_resources/blackbox/qrcode-5",
Box::new(QRCodeReader {}),
QRCodeReader {},
BarcodeFormat::QR_CODE,
);
tester.addTest(19, 19, 0.0);
@@ -129,7 +129,7 @@ fn qrcode_black_box5_test_case() {
fn qrcode_black_box6_test_case() {
let mut tester = common::AbstractBlackBoxTestCase::new(
"test_resources/blackbox/qrcode-6",
Box::new(QRCodeReader {}),
QRCodeReader {},
BarcodeFormat::QR_CODE,
);
tester.addTest(15, 15, 0.0);