fix: refuse a profile that belongs to another matcher

DockProfile::validate only checks whether a profile contradicts itself. It does
not know who is holding it, and it now accepts pattern 'arc' as well as 'v'.

Without a check at the matcher, a profile saying pattern: arc was accepted in
silence by the V matcher, which then went looking for two wings on a curved
surface. That reads as "it never detects" while the log says it is looking for
a V - the kind of mismatch that costs an afternoon. ArcPatternMatcher already
refused the reverse; this makes it symmetric.
This commit is contained in:
2026-08-26 20:14:49 +07:00
parent 8eb0040efa
commit a45694f625
2 changed files with 29 additions and 0 deletions

View File

@@ -607,6 +607,27 @@ DockProfile vTapeProfile()
}
} // namespace
TEST(VPatternMatcher, RefusesAProfileForADifferentPattern)
{
// `DockProfile::validate` chỉ kiểm profile có tự mâu thuẫn không — nó không biết ai đang cầm.
// Thiếu cổng này thì `pattern: arc` được bộ khớp chữ V nhận im lặng rồi đi tìm hai cánh trên một
// mặt cong: dò mãi không ra, mà log lại báo đang tìm chữ V. Sai kiểu đó tốn cả buổi.
std::string error;
VPatternMatcher m;
DockProfile p = vProfile();
p.pattern = PatternType::kArc;
p.arc_radius = 0.40;
p.arc_radius_tolerance = 0.06;
p.arc_span = 2.0;
p.arc_min_span = 0.52;
p.arc_max_rms = 0.010;
p.min_arc_points = 8;
EXPECT_FALSE(m.configure(p, error));
EXPECT_NE(error.find("VPatternMatcher"), std::string::npos) << error;
}
TEST(VPatternMatcher, TapeConfirmsAPlateThatCarriesIt)
{
Rig rig(vTapeProfile());