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 <mkorpershoek@baylibre.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
This commit is contained in:
Mattijs Korpershoek 2023-04-05 10:14:31 +02:00 committed by Kieran Bingham
parent 3dc2605bda
commit 683c6da83f

View file

@ -75,6 +75,13 @@ protected:
return TestFail; 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; return TestPass;
} }
}; };