tests: net: prometheus: counter: Add counter add tests
Add a test that will test the counter value add functionality. Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
This commit is contained in:
parent
d94bcd2566
commit
840a88a6b5
1 changed files with 21 additions and 1 deletions
|
@ -26,7 +26,7 @@ PROMETHEUS_COUNTER_DEFINE(test_counter_m, &test_counter_metric);
|
|||
* @details The test shall increment the counter value by 1 and check if the
|
||||
* value is incremented correctly.
|
||||
*/
|
||||
ZTEST(test_counter, test_prometheus_counter_inc)
|
||||
ZTEST(test_counter, test_prometheus_counter_01_inc)
|
||||
{
|
||||
int ret;
|
||||
|
||||
|
@ -43,4 +43,24 @@ ZTEST(test_counter, test_prometheus_counter_inc)
|
|||
zassert_equal(test_counter_m.value, 2, "Counter value is not 2");
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Test prometheus_counter_add
|
||||
* @details The test shall increment the counter value by arbitrary value
|
||||
* and check if the value is incremented correctly.
|
||||
*/
|
||||
ZTEST(test_counter, test_prometheus_counter_02_add)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = prometheus_counter_add(&test_counter_m, 2);
|
||||
zassert_ok(ret, "Error adding counter");
|
||||
|
||||
zassert_equal(test_counter_m.value, 4, "Counter value is not 4");
|
||||
|
||||
ret = prometheus_counter_add(&test_counter_m, 0);
|
||||
zassert_ok(ret, "Error adding counter");
|
||||
|
||||
zassert_equal(test_counter_m.value, 4, "Counter value is not 4");
|
||||
}
|
||||
|
||||
ZTEST_SUITE(test_counter, NULL, NULL, NULL, NULL, NULL);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue