From 44e2d525993bd432375327966eb3aba037064184 Mon Sep 17 00:00:00 2001 From: Henry Schimke Date: Mon, 3 Apr 2023 16:08:15 -0500 Subject: [PATCH] cleanup failures for existing tests --- src/common/cpp_essentials/pattern.rs | 4 ++-- src/qrcode/cpp_port/detector.rs | 7 ++++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/common/cpp_essentials/pattern.rs b/src/common/cpp_essentials/pattern.rs index e356204..53366df 100644 --- a/src/common/cpp_essentials/pattern.rs +++ b/src/common/cpp_essentials/pattern.rs @@ -117,8 +117,8 @@ impl<'a> PatternView<'_> { } pub fn end(&self) -> Option { if self.start + self.count < self.data.0.len() { - Some(self.data.0[self.start + self.count]) - }else { + Some(self.data.0[self.start + self.count]) + } else { None } } diff --git a/src/qrcode/cpp_port/detector.rs b/src/qrcode/cpp_port/detector.rs index cc0f090..f0e159a 100644 --- a/src/qrcode/cpp_port/detector.rs +++ b/src/qrcode/cpp_port/detector.rs @@ -63,7 +63,7 @@ pub fn FindFinderPatterns(image: &BitMatrix, tryHarder: bool) -> FinderPatterns while { if let Ok(next) = FindLeftGuard(&next, 0, &PATTERN, 0.5) { next.isValid() - }else { + } else { false } // let Ok(next) = FindLeftGuard(&next, 0, &PATTERN, 0.5) else { @@ -134,6 +134,11 @@ pub fn GenerateFinderPatternSets(patterns: &mut FinderPatterns) -> FinderPattern let cosLower: f64 = (135.0_f64 / 180.0 * 3.1415).cos(); let nbPatterns = (patterns).len(); + + if nbPatterns < 2 { + return FinderPatternSets::default(); + } + for i in 0..(nbPatterns - 2) { // for (int i = 0; i < nbPatterns - 2; i++) { for j in (i + 1)..(nbPatterns - 1) {