From 683c6da83f078d09fc020d2b48a4abe471853b2b Mon Sep 17 00:00:00 2001 From: Mattijs Korpershoek Date: Wed, 5 Apr 2023 10:14:31 +0200 Subject: test: controls: control_info_map: Test default constructor ControlInfoMap can be default-constructed. In that case, some of its members (like idmap_) can be a nullptr, and ControlInfoMap.find() will segfault. Add a test with a default constructed ControlInfoMap to cover this. Signed-off-by: Mattijs Korpershoek Reviewed-by: Jacopo Mondi Reviewed-by: Umang Jain Signed-off-by: Kieran Bingham --- test/controls/control_info_map.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'test') diff --git a/test/controls/control_info_map.cpp b/test/controls/control_info_map.cpp index db95945a..29b33515 100644 --- a/test/controls/control_info_map.cpp +++ b/test/controls/control_info_map.cpp @@ -75,6 +75,13 @@ protected: return TestFail; } + /* Test looking up a control on a default-constructed infoMap */ + const ControlInfoMap emptyInfoMap; + if (emptyInfoMap.find(12345) != emptyInfoMap.end()) { + cerr << "find() on empty ControlInfoMap failed" << endl; + return TestFail; + } + return TestPass; } }; -- cgit v1.2.1