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/summary.h>
10 
11 PROMETHEUS_SUMMARY_DEFINE(test_summary_m, "Test summary",
12 			  ({ .key = "test", .value = "summary" }), NULL);
13 
14 /**
15  * @brief Test prometheus_summary_observe
16  *
17  * @details The test shall observe the histogram value by 1 and check if the
18  * value is incremented correctly.
19  *
20  * @details The test shall observe the histogram value by 2 and check if the
21  * value is incremented correctly.
22  */
ZTEST(test_summary,test_summary_observe)23 ZTEST(test_summary, test_summary_observe)
24 {
25 	int ret;
26 
27 	zassert_equal(test_summary_m.sum, 0, "Histogram value is not 0");
28 
29 	ret = prometheus_summary_observe(&test_summary_m, 1);
30 	zassert_ok(ret, "Error observing histogram");
31 
32 	zassert_equal(test_summary_m.sum, 1, "Histogram value is not 1");
33 
34 	ret = prometheus_summary_observe(&test_summary_m, 2);
35 	zassert_ok(ret, "Error observing histogram");
36 
37 	zassert_equal(test_summary_m.sum, 3, "Histogram value is not 3");
38 }
39 
40 ZTEST_SUITE(test_summary, NULL, NULL, NULL, NULL, NULL);
41