From 5a1ae8cd903ccf83de08beb112559b449f97049d Mon Sep 17 00:00:00 2001 From: Henry Schimke Date: Sun, 16 Oct 2022 13:18:13 -0500 Subject: [PATCH] generic test runner --- tests/aztec_blackbox_tests.rs | 4 ++-- tests/common/abstract_black_box_test_case.rs | 11 ++++++----- tests/maxicode_blackbox_tests.rs | 4 ++-- tests/qr_code_blackbox_tests.rs | 12 ++++++------ 4 files changed, 16 insertions(+), 15 deletions(-) diff --git a/tests/aztec_blackbox_tests.rs b/tests/aztec_blackbox_tests.rs index 0feeb20..4efdb3b 100644 --- a/tests/aztec_blackbox_tests.rs +++ b/tests/aztec_blackbox_tests.rs @@ -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); diff --git a/tests/common/abstract_black_box_test_case.rs b/tests/common/abstract_black_box_test_case.rs index 54916b0..03f9790 100644 --- a/tests/common/abstract_black_box_test_case.rs +++ b/tests/common/abstract_black_box_test_case.rs @@ -33,15 +33,16 @@ use super::TestRXingResult; * @author Sean Owen * @author dswitkin@google.com (Daniel Switkin) */ -pub struct AbstractBlackBoxTestCase { +pub struct AbstractBlackBoxTestCase { test_base: Box, - barcode_reader: Box, + barcode_reader: T, expected_format: BarcodeFormat, test_rxing_results: Vec, hints: HashMap, } -impl AbstractBlackBoxTestCase { +impl AbstractBlackBoxTestCase { + pub fn buildTestBase(testBasePathSuffix: &str) -> Box { // 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, + barcode_reader: T, expected_format: BarcodeFormat, ) -> Self { Self { @@ -129,7 +130,7 @@ impl AbstractBlackBoxTestCase { paths } - pub fn getReader(&self) -> &Box { + pub fn getReader(&self) -> &T { &self.barcode_reader } diff --git a/tests/maxicode_blackbox_tests.rs b/tests/maxicode_blackbox_tests.rs index ee76e09..15b2e95 100644 --- a/tests/maxicode_blackbox_tests.rs +++ b/tests/maxicode_blackbox_tests.rs @@ -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); diff --git a/tests/qr_code_blackbox_tests.rs b/tests/qr_code_blackbox_tests.rs index e4b9e09..66fb294 100644 --- a/tests/qr_code_blackbox_tests.rs +++ b/tests/qr_code_blackbox_tests.rs @@ -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);