summaryrefslogtreecommitdiff
path: root/tests/test_asprintf.c
blob: a02d11030bf24970a31ed7092f8c35135ae0b9a7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#define _GNU_SOURCE
#include "common.h"

#include <assert.h>
#include <stdio.h>
#include <stdlib.h>

int main(int argc, char** argv) {
    char* buf;
    asprintf(&buf, "total: %d+%d=%d", 1, 2, 3);
    puts(buf);
    free(buf);

#ifndef __clang__
    asprintf(&buf, "total: %", 1);
    assert(buf == NULL);
#endif

    return 0;
}