return 0;
}
+DEF_TEST(distribution_marshal_text) {
+ struct {
+ value_t value;
+ char const *want;
+ } cases[] = {
+ {
+ .value.distribution = distribution_new_linear(2, 20),
+ .want = "\"buckets:\" {\n"
+ "\"20.00\":\"0\",\n"
+ "\"inf\":\"0\"\n"
+ "},\n\"count\":\"0\",\n"
+ "\"sum\":\"0.00\n",
+ },
+ {
+ .value.distribution = distribution_new_exponential(10, 2, 3),
+ .want = "\"buckets:\" {\n"
+ "\"3.00\":\"0\",\n"
+ "\"6.00\":\"0\",\n"
+ "\"12.00\":\"0\",\n"
+ "\"24.00\":\"0\",\n"
+ "\"48.00\":\"0\",\n"
+ "\"96.00\":\"0\",\n"
+ "\"192.00\":\"0\",\n"
+ "\"384.00\":\"0\",\n"
+ "\"768.00\":\"0\",\n"
+ "\"inf\":\"0\"\n"
+ "},\n\"count\":\"0\",\n"
+ "\"sum\":\"0.00\n",
+ },
+ {
+ .value.distribution =
+ distribution_new_custom(4, (double[]){3, 10, 50, 100}),
+ .want = "\"buckets:\" {\n"
+ "\"3.00\":\"0\",\n"
+ "\"10.00\":\"0\",\n"
+ "\"50.00\":\"0\",\n"
+ "\"100.00\":\"0\",\n"
+ "\"inf\":\"0\"\n"
+ "},\n\"count\":\"0\",\n"
+ "\"sum\":\"0.00\n",
+ },
+ };
+
+ for (size_t i = 0; i < (sizeof(cases) / sizeof(cases[0])); i++) {
+ printf("## Case %zu: \n", i);
+
+ distribution_t *dist = cases[i].value.distribution;
+ strbuf_t buf = STRBUF_CREATE;
+
+ CHECK_ZERO(distribution_marshal_text(&buf, dist));
+ EXPECT_EQ_STR(cases[i].want, buf.ptr);
+ distribution_destroy(dist);
+ STRBUF_DESTROY(buf);
+ }
+ return 0;
+}
+
int main(void) {
RUN_TEST(metric_label_set);
RUN_TEST(metric_identity);
RUN_TEST(metric_family_append);
RUN_TEST(metric_reset);
+ RUN_TEST(distribution_marshal_text);
END_TEST;
}