From e6bb3d666aa76ca7c5c4812c7c1aea64993de1a8 Mon Sep 17 00:00:00 2001 From: Travis Yaeger Date: Fri, 24 May 2019 11:36:42 -0700 Subject: [PATCH] Add more mem Tests to test-common --- tests/test-common.cc | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tests/test-common.cc b/tests/test-common.cc index 11ddab59..3f227e4c 100644 --- a/tests/test-common.cc +++ b/tests/test-common.cc @@ -192,6 +192,24 @@ TEST_CASE("cpu_percentage and cpu_barval return correct values") { } } +TEST_CASE("mem_percentage and mem_barval return correct values") { + info.mem = 6; + + SECTION("for memmax == 0") { + info.memmax = 0; + + REQUIRE(mem_percentage(nullptr) == 0); + REQUIRE(mem_barval(nullptr) == 0); + } + + SECTION("for memmax > 0") { + info.memmax = 24; + + REQUIRE(mem_percentage(nullptr) == 25); + REQUIRE(mem_barval(nullptr) == Approx(0.25)); + } +} + TEST_CASE("mem_with_buffers_barval returns correct value") { info.memwithbuffers = 6;