tests: net: prometheus: counter: Add counter set tests
Add a test that will test the counter value set functionality. Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
This commit is contained in:
parent
0ec8385bec
commit
2a5c702807
1 changed files with 20 additions and 0 deletions
|
@ -63,4 +63,24 @@ ZTEST(test_counter, test_prometheus_counter_02_add)
|
|||
zassert_equal(test_counter_m.value, 4, "Counter value is not 4");
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Test prometheus_counter_set
|
||||
* @details The test shall set the counter value by arbitrary value
|
||||
* and check if the value is incremented correctly.
|
||||
*/
|
||||
ZTEST(test_counter, test_prometheus_counter_03_set)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = prometheus_counter_set(&test_counter_m, 20);
|
||||
zassert_ok(ret, "Error setting counter");
|
||||
|
||||
zassert_equal(test_counter_m.value, 20, "Counter value is not 20");
|
||||
|
||||
ret = prometheus_counter_set(&test_counter_m, 15);
|
||||
zassert_equal(ret, -EINVAL, "Error setting counter");
|
||||
|
||||
zassert_equal(test_counter_m.value, 20, "Counter value is not 20");
|
||||
}
|
||||
|
||||
ZTEST_SUITE(test_counter, NULL, NULL, NULL, NULL, NULL);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue