1 /*
2  * Copyright (c) 2024 Mustafa Abdullah Kus, Sparse Technology
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
7 #include <zephyr/ztest.h>
8 
9 #include <zephyr/net/prometheus/gauge.h>
10 
11 PROMETHEUS_GAUGE_DEFINE(test_gauge_m, "Test gauge",
12 			({ .key = "test", .value = "gauge" }), NULL);
13 
14 /**
15  * @brief Test prometheus_gauge_set
16  *
17  * @details The test shall set the gauge value to 1 and check if the
18  * value is set correctly.
19  *
20  * @details The test shall set the gauge value to 2 and check if the
21  * value is set correctly.
22  */
ZTEST(test_gauge,test_gauge_set)23 ZTEST(test_gauge, test_gauge_set)
24 {
25 	int ret;
26 
27 	zassert_equal(test_gauge_m.value, 0, "Gauge value is not 0");
28 
29 	ret = prometheus_gauge_set(&test_gauge_m, 1);
30 	zassert_ok(ret, "Error setting gauge");
31 
32 	zassert_equal(test_gauge_m.value, 1, "Gauge value is not 1");
33 
34 	ret = prometheus_gauge_set(&test_gauge_m, 2);
35 	zassert_ok(ret, "Error setting gauge");
36 
37 	zassert_equal(test_gauge_m.value, 2, "Gauge value is not 2");
38 }
39 
40 ZTEST_SUITE(test_gauge, NULL, NULL, NULL, NULL, NULL);
41