Skip to content

Commit d3f22d5

Browse files
committed
Analyzer: properly require settings parameter
there are non-optional values in the `Settings` struct, accordingly all of the callers must pass it along. it was wrong to default it to an empty struct, that shouldn't even compile (but somehow does with MSVC... CLion correctly complains in the IDE).
1 parent 9ecab1f commit d3f22d5

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

include/banana-lib/lib.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ namespace banana {
143143
cv::Scalar const filter_upper_threshold_color{177, 255, 255};
144144
};
145145

146-
explicit Analyzer(Settings settings = {});
146+
explicit Analyzer(Settings settings);
147147

148148
/**
149149
* Analyse an image for the presence of bananas and their properties.

test/banana-lib-test.cpp

+9-3
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111
#define ASSERT_SAME_MAT(a,b) ASSERT_EQ(cv::Scalar(), cv::sum(a != b))
1212

1313
#define GET_RESULT(path, num_expected) \
14-
banana::Analyzer const analyzer; \
14+
banana::Analyzer const analyzer{{ \
15+
.pixels_per_meter = 1, \
16+
}}; \
1517
auto const image = cv::imread(path); \
1618
auto const result_ = analyzer.AnalyzeAndAnnotateImage(image); \
1719
ASSERT_TRUE(result_); \
@@ -20,14 +22,18 @@
2022
do {} while(false)
2123

2224
TEST(GeneralBananaTestSuite, FailOnNonExistingImage) {
23-
banana::Analyzer const analyzer;
25+
banana::Analyzer const analyzer{{
26+
.pixels_per_meter = 1,
27+
}};
2428
auto const image = cv::imread("non-existent-image.jpg");
2529
auto const result = analyzer.AnalyzeImage(image);
2630
ASSERT_FALSE(result);
2731
}
2832

2933
TEST(BananaContourFinderTestSuite, AnalyzeEmptyPicture) {
30-
banana::Analyzer const analyzer;
34+
banana::Analyzer const analyzer{{
35+
.pixels_per_meter = 1,
36+
}};
3137
auto const image = cv::imread("resources/test-images/empty.jpg");
3238
auto const result = analyzer.AnalyzeImage(image);
3339
ASSERT_TRUE(result);

0 commit comments

Comments
 (0)