From 6842cda1499e0682ed91c44cd4c944be381e0df4 Mon Sep 17 00:00:00 2001 From: Henry Schimke Date: Fri, 16 Dec 2022 17:11:55 -0600 Subject: [PATCH] rss_expanded integration partial pass --- src/oned/multi_format_one_d_reader.rs | 9 +- .../decoders/general_app_id_decoder.rs | 2 +- src/oned/rss/expanded/rss_expanded_reader.rs | 7 +- tests/RSSExpandedBlackBox1TestCase.java | 43 ------ tests/RSSExpandedBlackBox2TestCase.java | 43 ------ tests/RSSExpandedBlackBox3TestCase.java | 44 ------- .../RSSExpandedStackedBlackBox1TestCase.java | 46 ------- .../RSSExpandedStackedBlackBox2TestCase.java | 46 ------- tests/rss_expanded_blackbox.rs | 123 ++++++++++++++++++ 9 files changed, 133 insertions(+), 230 deletions(-) delete mode 100644 tests/RSSExpandedBlackBox1TestCase.java delete mode 100644 tests/RSSExpandedBlackBox2TestCase.java delete mode 100644 tests/RSSExpandedBlackBox3TestCase.java delete mode 100644 tests/RSSExpandedStackedBlackBox1TestCase.java delete mode 100644 tests/RSSExpandedStackedBlackBox2TestCase.java create mode 100644 tests/rss_expanded_blackbox.rs diff --git a/src/oned/multi_format_one_d_reader.rs b/src/oned/multi_format_one_d_reader.rs index 1d031f5..bc24358 100644 --- a/src/oned/multi_format_one_d_reader.rs +++ b/src/oned/multi_format_one_d_reader.rs @@ -14,6 +14,7 @@ * limitations under the License. */ +use super::rss::expanded::RSSExpandedReader; use super::rss::RSS14Reader; use super::CodaBarReader; use super::Code128Reader; @@ -90,9 +91,9 @@ impl MultiFormatOneDReader { if possibleFormats.contains(&BarcodeFormat::RSS_14) { readers.push(Box::new(RSS14Reader::new())); } - // if (possibleFormats.contains(&BarcodeFormat::RSS_EXPANDED)) { - // readers.add(new RSSExpandedReader()); - // } + if possibleFormats.contains(&BarcodeFormat::RSS_EXPANDED) { + readers.push(Box::new(RSSExpandedReader::new())); + } } if readers.is_empty() { readers.push(Box::new(MultiFormatUPCEANReader::new(hints))); @@ -102,7 +103,7 @@ impl MultiFormatOneDReader { readers.push(Box::new(Code128Reader {})); readers.push(Box::new(ITFReader::default())); readers.push(Box::new(RSS14Reader::new())); - // readers.push(new RSSExpandedReader()); + readers.push(Box::new(RSSExpandedReader::new())); } Self(readers) diff --git a/src/oned/rss/expanded/decoders/general_app_id_decoder.rs b/src/oned/rss/expanded/decoders/general_app_id_decoder.rs index f63c3d9..b601a93 100644 --- a/src/oned/rss/expanded/decoders/general_app_id_decoder.rs +++ b/src/oned/rss/expanded/decoders/general_app_id_decoder.rs @@ -500,7 +500,7 @@ impl<'a> GeneralAppIdDecoder<'_> { } let mut i = 0; - while i < 4 && pos < self.information.getSize() { + while i < 4 && i + pos < self.information.getSize() { // for (int i = 0; i < 4 && i + pos < this.information.getSize(); ++i) { if self.information.get(pos + i) { return false; diff --git a/src/oned/rss/expanded/rss_expanded_reader.rs b/src/oned/rss/expanded/rss_expanded_reader.rs index db55fd0..3500fbe 100644 --- a/src/oned/rss/expanded/rss_expanded_reader.rs +++ b/src/oned/rss/expanded/rss_expanded_reader.rs @@ -477,11 +477,12 @@ impl RSSExpandedReader { // Remove all the rows that contains only specified pairs fn removePartialRows(pairs: &[ExpandedPair], rows: &mut Vec) { - for i in 0..rows.len() { + let row_search = rows.clone(); + for i in 0..row_search.len() { // for r in rows { // for (Iterator iterator = rows.iterator(); iterator.hasNext();) { // ExpandedRow r = iterator.next(); - let r = rows.get(i).unwrap(); + let r = row_search.get(i).unwrap(); if r.getPairs().len() != pairs.len() { let mut allFound = true; for p in r.getPairs() { @@ -600,7 +601,7 @@ impl RSSExpandedReader { checksum %= 211; - let checkCharacterValue = 211 * (s - 4) + checksum; + let checkCharacterValue = (211 * (s as i64 - 4) + checksum as i64) as u32; checkCharacterValue == checkCharacter.unwrap().getValue() } diff --git a/tests/RSSExpandedBlackBox1TestCase.java b/tests/RSSExpandedBlackBox1TestCase.java deleted file mode 100644 index 2072004..0000000 --- a/tests/RSSExpandedBlackBox1TestCase.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (C) 2010 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * These authors would like to acknowledge the Spanish Ministry of Industry, - * Tourism and Trade, for the support in the project TSI020301-2008-2 - * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled - * Mobile Dynamic Environments", led by Treelogic - * ( http://www.treelogic.com/ ): - * - * http://www.piramidepse.com/ - */ - -package com.google.zxing.oned.rss.expanded; - -import com.google.zxing.BarcodeFormat; -import com.google.zxing.MultiFormatReader; -import com.google.zxing.common.AbstractBlackBoxTestCase; - -/** - * A test of {@link RSSExpandedReader} against a fixed test set of images. - */ -public final class RSSExpandedBlackBox1TestCase extends AbstractBlackBoxTestCase { - - public RSSExpandedBlackBox1TestCase() { - super("src/test/resources/blackbox/rssexpanded-1", new MultiFormatReader(), BarcodeFormat.RSS_EXPANDED); - addTest(32, 32, 0.0f); - addTest(32, 32, 180.0f); - } -} diff --git a/tests/RSSExpandedBlackBox2TestCase.java b/tests/RSSExpandedBlackBox2TestCase.java deleted file mode 100644 index 515179e..0000000 --- a/tests/RSSExpandedBlackBox2TestCase.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (C) 2010 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * These authors would like to acknowledge the Spanish Ministry of Industry, - * Tourism and Trade, for the support in the project TSI020301-2008-2 - * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled - * Mobile Dynamic Environments", led by Treelogic - * ( http://www.treelogic.com/ ): - * - * http://www.piramidepse.com/ - */ - -package com.google.zxing.oned.rss.expanded; - -import com.google.zxing.BarcodeFormat; -import com.google.zxing.MultiFormatReader; -import com.google.zxing.common.AbstractBlackBoxTestCase; - -/** - * A test of {@link RSSExpandedReader} against a fixed test set of images. - */ -public final class RSSExpandedBlackBox2TestCase extends AbstractBlackBoxTestCase { - - public RSSExpandedBlackBox2TestCase() { - super("src/test/resources/blackbox/rssexpanded-2", new MultiFormatReader(), BarcodeFormat.RSS_EXPANDED); - addTest(21, 23, 0.0f); - addTest(21, 23, 180.0f); - } -} diff --git a/tests/RSSExpandedBlackBox3TestCase.java b/tests/RSSExpandedBlackBox3TestCase.java deleted file mode 100644 index 6117d6e..0000000 --- a/tests/RSSExpandedBlackBox3TestCase.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (C) 2010 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * These authors would like to acknowledge the Spanish Ministry of Industry, - * Tourism and Trade, for the support in the project TSI020301-2008-2 - * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled - * Mobile Dynamic Environments", led by Treelogic - * ( http://www.treelogic.com/ ): - * - * http://www.piramidepse.com/ - */ - -package com.google.zxing.oned.rss.expanded; - -import com.google.zxing.BarcodeFormat; -import com.google.zxing.MultiFormatReader; -import com.google.zxing.common.AbstractBlackBoxTestCase; - -/** - * A test of {@link RSSExpandedReader} against a fixed test set of images. - */ -public final class RSSExpandedBlackBox3TestCase extends AbstractBlackBoxTestCase { - - public RSSExpandedBlackBox3TestCase() { - super("src/test/resources/blackbox/rssexpanded-3", new MultiFormatReader(), BarcodeFormat.RSS_EXPANDED); - addTest(117, 117, 0.0f); - addTest(117, 117, 180.0f); - } -} - diff --git a/tests/RSSExpandedStackedBlackBox1TestCase.java b/tests/RSSExpandedStackedBlackBox1TestCase.java deleted file mode 100644 index dabe8b1..0000000 --- a/tests/RSSExpandedStackedBlackBox1TestCase.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (C) 2012 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * These authors would like to acknowledge the Spanish Ministry of Industry, - * Tourism and Trade, for the support in the project TSI020301-2008-2 - * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled - * Mobile Dynamic Environments", led by Treelogic - * ( http://www.treelogic.com/ ): - * - * http://www.piramidepse.com/ - */ - -package com.google.zxing.oned.rss.expanded; - -import com.google.zxing.BarcodeFormat; -import com.google.zxing.MultiFormatReader; -import com.google.zxing.common.AbstractBlackBoxTestCase; - -/** - * A test of {@link RSSExpandedReader} against a fixed test set of images including - * stacked RSS barcodes. - */ -public final class RSSExpandedStackedBlackBox1TestCase extends AbstractBlackBoxTestCase { - - public RSSExpandedStackedBlackBox1TestCase() { - super("src/test/resources/blackbox/rssexpandedstacked-1", new MultiFormatReader(), BarcodeFormat.RSS_EXPANDED); - addTest(59, 64, 0.0f); - addTest(59, 64, 180.0f); - } - -} - diff --git a/tests/RSSExpandedStackedBlackBox2TestCase.java b/tests/RSSExpandedStackedBlackBox2TestCase.java deleted file mode 100644 index ee0e008..0000000 --- a/tests/RSSExpandedStackedBlackBox2TestCase.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (C) 2012 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * These authors would like to acknowledge the Spanish Ministry of Industry, - * Tourism and Trade, for the support in the project TSI020301-2008-2 - * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled - * Mobile Dynamic Environments", led by Treelogic - * ( http://www.treelogic.com/ ): - * - * http://www.piramidepse.com/ - */ - -package com.google.zxing.oned.rss.expanded; - -import com.google.zxing.BarcodeFormat; -import com.google.zxing.MultiFormatReader; -import com.google.zxing.common.AbstractBlackBoxTestCase; - -/** - * A test of {@link RSSExpandedReader} against a fixed test set of images including - * stacked RSS barcodes. - */ -public final class RSSExpandedStackedBlackBox2TestCase extends AbstractBlackBoxTestCase { - - public RSSExpandedStackedBlackBox2TestCase() { - super("src/test/resources/blackbox/rssexpandedstacked-2", new MultiFormatReader(), BarcodeFormat.RSS_EXPANDED); - addTest(2, 7, 0.0f); - addTest(2, 7, 180.0f); - } - -} - diff --git a/tests/rss_expanded_blackbox.rs b/tests/rss_expanded_blackbox.rs new file mode 100644 index 0000000..2b99524 --- /dev/null +++ b/tests/rss_expanded_blackbox.rs @@ -0,0 +1,123 @@ +/* + * Copyright (C) 2010 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * These authors would like to acknowledge the Spanish Ministry of Industry, + * Tourism and Trade, for the support in the project TSI020301-2008-2 + * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled + * Mobile Dynamic Environments", led by Treelogic + * ( http://www.treelogic.com/ ): + * + * http://www.piramidepse.com/ + */ + +use rxing::{BarcodeFormat, MultiFormatReader}; + +mod common; + +/** + * A test of {@link RSSExpandedReader} against a fixed test set of images. + */ +#[test] +fn rssexpanded_black_box1_test_case() { + let mut tester = common::AbstractBlackBoxTestCase::new( + "test_resources/blackbox/rssexpanded-1", + MultiFormatReader::default(), + BarcodeFormat::RSS_EXPANDED, + ); + + // super("src/test/resources/blackbox/rssexpanded-1", new MultiFormatReader(), BarcodeFormat.RSS_EXPANDED); + tester.add_test(32, 32, 0.0); + tester.add_test(32, 32, 180.0); + + tester.test_black_box() +} + +/** + * A test of {@link RSSExpandedReader} against a fixed test set of images. + */ +#[test] +fn rssexpanded_black_box2_test_case() { + let mut tester = common::AbstractBlackBoxTestCase::new( + "test_resources/blackbox/rssexpanded-2", + MultiFormatReader::default(), + BarcodeFormat::RSS_EXPANDED, + ); + + // super("src/test/resources/blackbox/rssexpanded-2", new MultiFormatReader(), BarcodeFormat.RSS_EXPANDED); + tester.add_test(21, 23, 0.0); + tester.add_test(21, 23, 180.0); + + tester.test_black_box() +} + +/** + * A test of {@link RSSExpandedReader} against a fixed test set of images. + */ +#[test] +fn rssexpanded_black_box3_test_case() { + let mut tester = common::AbstractBlackBoxTestCase::new( + "test_resources/blackbox/rssexpanded-3", + MultiFormatReader::default(), + BarcodeFormat::RSS_EXPANDED, + ); + + // super("src/test/resources/blackbox/rssexpanded-3", new MultiFormatReader(), BarcodeFormat.RSS_EXPANDED); + tester.add_test(117, 117, 0.0); + tester.add_test(117, 117, 180.0); + + tester.test_black_box() +} + +/** + * A test of {@link RSSExpandedReader} against a fixed test set of images including + * stacked RSS barcodes. + */ +#[test] +fn rssexpanded_stacked_black_box1_test_case() { + let mut tester = common::AbstractBlackBoxTestCase::new( + "test_resources/blackbox/rssexpandedstacked-1", + MultiFormatReader::default(), + BarcodeFormat::RSS_EXPANDED, + ); + + // super("src/test/resources/blackbox/rssexpandedstacked-1", new MultiFormatReader(), BarcodeFormat.RSS_EXPANDED); + tester.add_test(59, 64, 0.0); + tester.add_test(59, 64, 180.0); + + tester.test_black_box() +} + +/** + * A test of {@link RSSExpandedReader} against a fixed test set of images including + * stacked RSS barcodes. + */ +#[test] +fn rssexpanded_stacked_black_box2_test_case() { + let mut tester = common::AbstractBlackBoxTestCase::new( + "test_resources/blackbox/rssexpandedstacked-2", + MultiFormatReader::default(), + BarcodeFormat::RSS_EXPANDED, + ); + + // super("src/test/resources/blackbox/rssexpandedstacked-2", new MultiFormatReader(), BarcodeFormat.RSS_EXPANDED); + tester.add_test(2, 7, 0.0); + tester.add_test(2, 7, 180.0); + + tester.test_black_box() +} + +/* one too few images are passing on above, probably a problem edge case */ \ No newline at end of file