summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tests/test-qdist.c10
-rw-r--r--util/qdist.c6
2 files changed, 12 insertions, 4 deletions
diff --git a/tests/test-qdist.c b/tests/test-qdist.c
index 0298986ac9..9541ce31eb 100644
--- a/tests/test-qdist.c
+++ b/tests/test-qdist.c
@@ -360,10 +360,16 @@ static void test_none(void)
g_assert(isnan(qdist_xmax(&dist)));
pr = qdist_pr_plain(&dist, 0);
- g_assert(pr == NULL);
+ g_assert_cmpstr(pr, ==, "(empty)");
+ g_free(pr);
pr = qdist_pr_plain(&dist, 2);
- g_assert(pr == NULL);
+ g_assert_cmpstr(pr, ==, "(empty)");
+ g_free(pr);
+
+ pr = qdist_pr(&dist, 0, QDIST_PR_BORDER);
+ g_assert_cmpstr(pr, ==, "(empty)");
+ g_free(pr);
qdist_destroy(&dist);
}
diff --git a/util/qdist.c b/util/qdist.c
index e95722b8a1..5f75e24c29 100644
--- a/util/qdist.c
+++ b/util/qdist.c
@@ -14,6 +14,8 @@
#define NAN (0.0 / 0.0)
#endif
+#define QDIST_EMPTY_STR "(empty)"
+
void qdist_init(struct qdist *dist)
{
dist->entries = g_new(struct qdist_entry, 1);
@@ -233,7 +235,7 @@ char *qdist_pr_plain(const struct qdist *dist, size_t n)
char *ret;
if (dist->n == 0) {
- return NULL;
+ return g_strdup(QDIST_EMPTY_STR);
}
qdist_bin__internal(&binned, dist, n);
ret = qdist_pr_internal(&binned);
@@ -308,7 +310,7 @@ char *qdist_pr(const struct qdist *dist, size_t n_bins, uint32_t opt)
GString *s;
if (dist->n == 0) {
- return NULL;
+ return g_strdup(QDIST_EMPTY_STR);
}
s = g_string_new("");