#include <stdio.h>
#include <stdlib.h> /* for free */
#include <string.h> /* for strcmp */
#include <strings.h>

#include <platform/cbassert.h>

static void test_asprintf(void) {
    char *result = 0;
    cb_assert(asprintf(&result, "test 1") > 0);
    cb_assert(strcmp(result, "test 1") == 0);
    free(result);

    cb_assert(asprintf(&result, "test %d", 2) > 0);
    cb_assert(strcmp(result, "test 2") == 0);
    free(result);

    cb_assert(asprintf(&result, "%c%c%c%c %d", 't', 'e', 's', 't', 3) > 0);
    cb_assert(strcmp(result, "test 3") == 0);
    free(result);
}

int main(void) {
    test_asprintf();
    return 0;
}

#include <stdio.h>
#include <stdlib.h> /* for free */
#include <string.h> /* for strcmp */
#include <strings.h>

#include <platform/cbassert.h>

static void test_asprintf(void) {
    char *result = 0;
    (void)asprintf(&result, "test 1");
    cb_assert(strcmp(result, "test 1") == 0);
    free(result);

    (void)asprintf(&result, "test %d", 2);
    cb_assert(strcmp(result, "test 2") == 0);
    free(result);

    (void)asprintf(&result, "%c%c%c%c %d", 't', 'e', 's', 't', 3);
    cb_assert(strcmp(result, "test 3") == 0);
    free(result);
}

int main(void) {
    test_asprintf();
    return 0;
}

--- 
+++ 
@@ -7,15 +7,15 @@
 
 static void test_asprintf(void) {
     char *result = 0;
-    (void)asprintf(&result, "test 1");
+    cb_assert(asprintf(&result, "test 1") > 0);
     cb_assert(strcmp(result, "test 1") == 0);
     free(result);
 
-    (void)asprintf(&result, "test %d", 2);
+    cb_assert(asprintf(&result, "test %d", 2) > 0);
     cb_assert(strcmp(result, "test 2") == 0);
     free(result);
 
-    (void)asprintf(&result, "%c%c%c%c %d", 't', 'e', 's', 't', 3);
+    cb_assert(asprintf(&result, "%c%c%c%c %d", 't', 'e', 's', 't', 3) > 0);
     cb_assert(strcmp(result, "test 3") == 0);
     free(result);
 }
Check for return value for asprintf

Change-Id: Ib163468aac1a5e52cef28c59b55be2287dc4ba43
Reviewed-on: http://review.couchbase.org/43023
Reviewed-by: Trond Norbye <60edd2ef23891a753f231b0c6f161dc634079a93@gmail.com>
Tested-by: Trond Norbye <60edd2ef23891a753f231b0c6f161dc634079a93@gmail.com>
