Allow disabling image features

This commit is contained in:
Sam Wilson
2024-01-11 12:38:01 -05:00
parent 7cb00fafd1
commit 169f2f6073
33 changed files with 154 additions and 6 deletions

View File

@@ -1054,6 +1054,7 @@ mod detector_test {
Binarizer, BufferedImageLuminanceSource,
};
#[cfg(feature = "image-formats")]
#[test]
fn mode_1() {
finder_test(
@@ -1062,6 +1063,7 @@ mod detector_test {
)
}
#[cfg(feature = "image-formats")]
#[test]
fn mode_2() {
finder_test(
@@ -1070,6 +1072,7 @@ mod detector_test {
)
}
#[cfg(feature = "image-formats")]
#[test]
fn mode_2_rot90() {
finder_test(
@@ -1078,6 +1081,7 @@ mod detector_test {
)
}
#[cfg(feature = "image-formats")]
#[test]
fn mode3() {
finder_test(
@@ -1086,6 +1090,7 @@ mod detector_test {
)
}
#[cfg(feature = "image-formats")]
#[test]
fn mixed_sets() {
finder_test(
@@ -1094,6 +1099,7 @@ mod detector_test {
)
}
#[cfg(feature = "image-formats")]
#[test]
fn mode4() {
finder_test(
@@ -1102,6 +1108,7 @@ mod detector_test {
)
}
#[cfg(feature = "image-formats")]
#[test]
fn mode5() {
finder_test(
@@ -1110,6 +1117,7 @@ mod detector_test {
)
}
#[cfg(feature = "image-formats")]
#[test]
fn mode6() {
finder_test(

View File

@@ -27,6 +27,7 @@ use super::{GenericMultipleBarcodeReader, MultipleBarcodeReader};
* Tests {@link MultipleBarcodeReader}.
*/
#[cfg(feature = "image-formats")]
#[test]
fn testMulti() {
// Very basic test for now
@@ -54,6 +55,7 @@ fn testMulti() {
assert_eq!(&BarcodeFormat::QR_CODE, results[1].getBarcodeFormat());
}
#[cfg(feature = "image-formats")]
#[test]
fn testMultiQR() {
// Very basic test for now

View File

@@ -237,6 +237,7 @@ mod multi_qr_code_test_case {
* Tests {@link QRCodeMultiReader}.
*/
#[cfg(feature = "image-formats")]
#[test]
fn testMultiQRCodes() {
// Very basic test for now

View File

@@ -63,7 +63,7 @@ impl ExpandedPair {
&self.finderPattern
}
#[cfg(test)]
#[cfg(all(test, feature = "image"))]
pub(crate) fn getFinderPatternMut(&mut self) -> &mut Option<FinderPattern> {
&mut self.finderPattern
}

View File

@@ -35,7 +35,7 @@ impl ExpandedRow {
&self.pairs
}
#[cfg(test)]
#[cfg(all(test, feature = "image"))]
pub(crate) fn getPairsMut(&mut self) -> &mut [ExpandedPair] {
&mut self.pairs
}

View File

@@ -35,6 +35,7 @@ use crate::{
use super::bit_array_builder;
#[cfg(feature = "image-formats")]
#[test]
fn testDecodeRow2binary1() {
// (11)100224(17)110224(3102)000100
@@ -42,6 +43,7 @@ fn testDecodeRow2binary1() {
" ...X...X .X....X. .XX...X. X..X...X ...XX.X. ..X.X... ..X.X..X ...X..X. X.X....X .X....X. .....X.. X...X...");
}
#[cfg(feature = "image-formats")]
#[test]
fn testDecodeRow2binary2() {
// (01)90012345678908(3103)001750
@@ -51,12 +53,14 @@ fn testDecodeRow2binary2() {
);
}
#[cfg(feature = "image-formats")]
#[test]
fn testDecodeRow2binary3() {
// (10)12A
assertCorrectImage2binary("3.png", " .......X ..XX..X. X.X....X .......X ....");
}
#[cfg(feature = "image-formats")]
#[test]
fn testDecodeRow2binary4() {
// (01)98898765432106(3202)012345(15)991231
@@ -64,6 +68,7 @@ fn testDecodeRow2binary4() {
"4.png", " ..XXXX.X XX.XXXX. .XXX.XX. XX..X... .XXXXX.. XX.X..X. ..XX..XX XX.X.XXX X..XX..X .X.XXXXX XXXX");
}
#[cfg(feature = "image-formats")]
#[test]
fn testDecodeRow2binary5() {
// (01)90614141000015(3202)000150
@@ -73,6 +78,7 @@ fn testDecodeRow2binary5() {
);
}
#[cfg(feature = "image-formats")]
#[test]
fn testDecodeRow2binary10() {
// (01)98898765432106(15)991231(3103)001750(10)12A(422)123(21)123456(423)0123456789012
@@ -80,6 +86,7 @@ fn testDecodeRow2binary10() {
" .X.XX..X XX.XXXX. .XXX.XX. XX..X... .XXXXX.. XX.X..X. ..XX...X XX.X.... X.X.X.X. X.X..X.X .X....X. XX...X.. ...XX.X. .XXXXXX. .X..XX.. X.X.X... .X...... XXXX.... XX.XX... XXXXX.X. ...XXXXX .....X.X ...X.... X.XXX..X X.X.X... XX.XX..X .X..X..X .X.X.X.X X.XX...X .XX.XXX. XXX.X.XX ..X.");
}
#[cfg(feature = "image-formats")]
#[test]
fn testDecodeRow2binary11() {
// (01)98898765432106(15)991231(3103)001750(10)12A(422)123(21)123456
@@ -87,6 +94,7 @@ fn testDecodeRow2binary11() {
" .X.XX..X XX.XXXX. .XXX.XX. XX..X... .XXXXX.. XX.X..X. ..XX...X XX.X.... X.X.X.X. X.X..X.X .X....X. XX...X.. ...XX.X. .XXXXXX. .X..XX.. X.X.X... .X...... XXXX.... XX.XX... XXXXX.X. ...XXXXX .....X.X ...X.... X.XXX..X X.X.X... ....");
}
#[cfg(feature = "image-formats")]
#[test]
fn testDecodeRow2binary12() {
// (01)98898765432106(3103)001750
@@ -96,6 +104,7 @@ fn testDecodeRow2binary12() {
);
}
#[cfg(feature = "image-formats")]
#[test]
fn testDecodeRow2binary13() {
// (01)90012345678908(3922)795
@@ -105,6 +114,7 @@ fn testDecodeRow2binary13() {
);
}
#[cfg(feature = "image-formats")]
#[test]
fn testDecodeRow2binary14() {
// (01)90012345678908(3932)0401234
@@ -112,6 +122,7 @@ fn testDecodeRow2binary14() {
"14.png", " ..XX.X.. ........ .X..XXX. X.X.X... XX.XXXXX .XXXX.X. X.....X. X.....X. X.X.X.XX .X...... X...");
}
#[cfg(feature = "image-formats")]
#[test]
fn testDecodeRow2binary15() {
// (01)90012345678908(3102)001750(11)100312
@@ -119,6 +130,7 @@ fn testDecodeRow2binary15() {
"15.png", " ..XXX... ........ .X..XXX. X.X.X... XX.XXXXX .XXXX.X. ..XX...X .X.....X .XX..... XXXX.X.. XX..");
}
#[cfg(feature = "image-formats")]
#[test]
fn testDecodeRow2binary16() {
// (01)90012345678908(3202)001750(11)100312
@@ -126,6 +138,7 @@ fn testDecodeRow2binary16() {
"16.png", " ..XXX..X ........ .X..XXX. X.X.X... XX.XXXXX .XXXX.X. ..XX...X .X.....X .XX..... XXXX.X.. XX..");
}
#[cfg(feature = "image-formats")]
#[test]
fn testDecodeRow2binary17() {
// (01)90012345678908(3102)001750(13)100312
@@ -133,6 +146,7 @@ fn testDecodeRow2binary17() {
"17.png", " ..XXX.X. ........ .X..XXX. X.X.X... XX.XXXXX .XXXX.X. ..XX...X .X.....X .XX..... XXXX.X.. XX..");
}
#[cfg(feature = "image-formats")]
#[test]
fn testDecodeRow2binary18() {
// (01)90012345678908(3202)001750(13)100312
@@ -140,6 +154,7 @@ fn testDecodeRow2binary18() {
"18.png", " ..XXX.XX ........ .X..XXX. X.X.X... XX.XXXXX .XXXX.X. ..XX...X .X.....X .XX..... XXXX.X.. XX..");
}
#[cfg(feature = "image-formats")]
#[test]
fn testDecodeRow2binary19() {
// (01)90012345678908(3102)001750(15)100312
@@ -147,6 +162,7 @@ fn testDecodeRow2binary19() {
"19.png", " ..XXXX.. ........ .X..XXX. X.X.X... XX.XXXXX .XXXX.X. ..XX...X .X.....X .XX..... XXXX.X.. XX..");
}
#[cfg(feature = "image-formats")]
#[test]
fn testDecodeRow2binary20() {
// (01)90012345678908(3202)001750(15)100312
@@ -154,6 +170,7 @@ fn testDecodeRow2binary20() {
"20.png", " ..XXXX.X ........ .X..XXX. X.X.X... XX.XXXXX .XXXX.X. ..XX...X .X.....X .XX..... XXXX.X.. XX..");
}
#[cfg(feature = "image-formats")]
#[test]
fn testDecodeRow2binary21() {
// (01)90012345678908(3102)001750(17)100312
@@ -161,6 +178,7 @@ fn testDecodeRow2binary21() {
"21.png", " ..XXXXX. ........ .X..XXX. X.X.X... XX.XXXXX .XXXX.X. ..XX...X .X.....X .XX..... XXXX.X.. XX..");
}
#[cfg(feature = "image-formats")]
#[test]
fn testDecodeRow2binary22() {
// (01)90012345678908(3202)001750(17)100312

View File

@@ -37,36 +37,43 @@ use crate::{
* @author Eduardo Castillejo, University of Deusto (eduardo.castillejo@deusto.es)
*/
#[cfg(feature = "image-formats")]
#[test]
fn testDecodeRow2string1() {
assertCorrectImage2string("1.png", "(11)100224(17)110224(3102)000100");
}
#[cfg(feature = "image-formats")]
#[test]
fn testDecodeRow2string2() {
assertCorrectImage2string("2.png", "(01)90012345678908(3103)001750");
}
#[cfg(feature = "image-formats")]
#[test]
fn testDecodeRow2string3() {
assertCorrectImage2string("3.png", "(10)12A");
}
#[cfg(feature = "image-formats")]
#[test]
fn testDecodeRow2string4() {
assertCorrectImage2string("4.png", "(01)98898765432106(3202)012345(15)991231");
}
#[cfg(feature = "image-formats")]
#[test]
fn testDecodeRow2string5() {
assertCorrectImage2string("5.png", "(01)90614141000015(3202)000150");
}
#[cfg(feature = "image-formats")]
#[test]
fn testDecodeRow2string7() {
assertCorrectImage2string("7.png", "(10)567(11)010101");
}
#[cfg(feature = "image-formats")]
#[test]
fn testDecodeRow2string10() {
let expected =
@@ -74,6 +81,7 @@ fn testDecodeRow2string10() {
assertCorrectImage2string("10.png", expected);
}
#[cfg(feature = "image-formats")]
#[test]
fn testDecodeRow2string11() {
assertCorrectImage2string(
@@ -82,96 +90,115 @@ fn testDecodeRow2string11() {
);
}
#[cfg(feature = "image-formats")]
#[test]
fn testDecodeRow2string12() {
assertCorrectImage2string("12.png", "(01)98898765432106(3103)001750");
}
#[cfg(feature = "image-formats")]
#[test]
fn testDecodeRow2string13() {
assertCorrectImage2string("13.png", "(01)90012345678908(3922)795");
}
#[cfg(feature = "image-formats")]
#[test]
fn testDecodeRow2string14() {
assertCorrectImage2string("14.png", "(01)90012345678908(3932)0401234");
}
#[cfg(feature = "image-formats")]
#[test]
fn testDecodeRow2string15() {
assertCorrectImage2string("15.png", "(01)90012345678908(3102)001750(11)100312");
}
#[cfg(feature = "image-formats")]
#[test]
fn testDecodeRow2string16() {
assertCorrectImage2string("16.png", "(01)90012345678908(3202)001750(11)100312");
}
#[cfg(feature = "image-formats")]
#[test]
fn testDecodeRow2string17() {
assertCorrectImage2string("17.png", "(01)90012345678908(3102)001750(13)100312");
}
#[cfg(feature = "image-formats")]
#[test]
fn testDecodeRow2string18() {
assertCorrectImage2string("18.png", "(01)90012345678908(3202)001750(13)100312");
}
#[cfg(feature = "image-formats")]
#[test]
fn testDecodeRow2string19() {
assertCorrectImage2string("19.png", "(01)90012345678908(3102)001750(15)100312");
}
#[cfg(feature = "image-formats")]
#[test]
fn testDecodeRow2string20() {
assertCorrectImage2string("20.png", "(01)90012345678908(3202)001750(15)100312");
}
#[cfg(feature = "image-formats")]
#[test]
fn testDecodeRow2string21() {
assertCorrectImage2string("21.png", "(01)90012345678908(3102)001750(17)100312");
}
#[cfg(feature = "image-formats")]
#[test]
fn testDecodeRow2string22() {
assertCorrectImage2string("22.png", "(01)90012345678908(3202)001750(17)100312");
}
#[cfg(feature = "image-formats")]
#[test]
fn testDecodeRow2string25() {
assertCorrectImage2string("25.png", "(10)123");
}
#[cfg(feature = "image-formats")]
#[test]
fn testDecodeRow2string26() {
assertCorrectImage2string("26.png", "(10)5678(11)010101");
}
#[cfg(feature = "image-formats")]
#[test]
fn testDecodeRow2string27() {
assertCorrectImage2string("27.png", "(10)1098-1234");
}
#[cfg(feature = "image-formats")]
#[test]
fn testDecodeRow2string28() {
assertCorrectImage2string("28.png", "(10)1098/1234");
}
#[cfg(feature = "image-formats")]
#[test]
fn testDecodeRow2string29() {
assertCorrectImage2string("29.png", "(10)1098.1234");
}
#[cfg(feature = "image-formats")]
#[test]
fn testDecodeRow2string30() {
assertCorrectImage2string("30.png", "(10)1098*1234");
}
#[cfg(feature = "image-formats")]
#[test]
fn testDecodeRow2string31() {
assertCorrectImage2string("31.png", "(10)1098,1234");
}
#[cfg(feature = "image-formats")]
#[test]
fn testDecodeRow2string32() {
assertCorrectImage2string(

View File

@@ -37,6 +37,7 @@ use super::RSSExpandedReader;
* @author Eduardo Castillejo, University of Deusto (eduardo.castillejo@deusto.es)
*/
#[cfg(feature = "image-formats")]
#[test]
fn testFindFinderPatterns() {
let image = readImage("2.png");
@@ -83,6 +84,7 @@ fn testFindFinderPatterns() {
// }
}
#[cfg(feature = "image-formats")]
#[test]
fn testRetrieveNextPairPatterns() {
let image = readImage("3.png");
@@ -111,6 +113,7 @@ fn testRetrieveNextPairPatterns() {
assert_eq!(0, finderPattern.getValue());
}
#[cfg(feature = "image-formats")]
#[test]
fn testDecodeCheckCharacter() {
let image = readImage("3.png");
@@ -139,6 +142,7 @@ fn testDecodeCheckCharacter() {
assert_eq!(98, dataCharacter.getValue());
}
#[cfg(feature = "image-formats")]
#[test]
fn testDecodeDataCharacter() {
let image = readImage("3.png");

View File

@@ -32,6 +32,7 @@ use super::{test_case_util, RSSExpandedReader};
* Tests {@link RSSExpandedReader} handling of stacked RSS barcodes.
*/
#[cfg(feature = "image-formats")]
#[test]
fn testDecodingRowByRow() {
let mut rssExpandedReader = RSSExpandedReader::new();
@@ -87,6 +88,7 @@ fn testDecodingRowByRow() {
assert_eq!("(01)98898765432106(3202)012345(15)991231", result.getText());
}
#[cfg(feature = "image-formats")]
#[test]
fn testCompleteDecode() {
let mut rssExpandedReader = RSSExpandedReader::new();

View File

@@ -48,7 +48,7 @@ impl FinderPattern {
&self.startEnd
}
#[cfg(test)]
#[cfg(all(test, feature = "image"))]
pub(crate) fn getStartEndMut(&mut self) -> &mut [usize] {
&mut self.startEnd
}

View File

@@ -159,6 +159,7 @@ fn compareToGoldenFile(
// Golden images are generated with "qrcode_sample.cc". The images are checked with both eye balls
// and cell phones. We expect pixel-perfect results, because the error correction level is known,
// and the pixel dimensions matches exactly.
#[cfg(feature = "image-formats")]
#[test]
fn testRegressionTest() {
compareToGoldenFile(