1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2024-11-17 10:35:10 +00:00

Remove REQUIRE from cpu Test

cpu_barval now has the same behavior as cpu_percentage when trying to 
get info from a non-existent cpu.
This commit is contained in:
Travis Yaeger 2019-05-28 09:59:36 -07:00 committed by Brenden Matthews
parent 08847314bd
commit 0ad2119bb4
2 changed files with 5 additions and 2 deletions

View File

@ -375,6 +375,10 @@ uint8_t cpu_percentage(struct text_object *obj) {
} }
double cpu_barval(struct text_object *obj) { double cpu_barval(struct text_object *obj) {
if (static_cast<unsigned int>(obj->data.i) > info.cpu_count) {
NORM_ERR("obj->data.i %i info.cpu_count %i", obj->data.i, info.cpu_count);
CRIT_ERR(nullptr, nullptr, "attempting to use more CPUs than you have!");
}
if (info.cpu_usage != nullptr) { return info.cpu_usage[obj->data.i]; } if (info.cpu_usage != nullptr) { return info.cpu_usage[obj->data.i]; }
return 0.; return 0.;
} }

View File

@ -160,11 +160,10 @@ TEST_CASE("cpu_percentage and cpu_barval return correct values") {
info.cpu_usage[0] = 0.253; info.cpu_usage[0] = 0.253;
info.cpu_usage[1] = 0.507; info.cpu_usage[1] = 0.507;
REQUIRE(cpu_barval(&obj2) == 0);
// This does not exist in Catch2, but would be nice to have since that's // This does not exist in Catch2, but would be nice to have since that's
// what happens in this case. // what happens in this case.
// REQUIRE_EXIT(cpu_percentage(&obj2)); // REQUIRE_EXIT(cpu_percentage(&obj2));
// REQUIRE_EXIT(cpu_barval(&obj2));
delete[] info.cpu_usage; delete[] info.cpu_usage;
} }