~ubuntu-branches/ubuntu/saucy/libpam-krb5/saucy-proposed

« back to all changes in this revision

Viewing changes to tests/portable/asprintf-t.c

  • Committer: Package Import Robot
  • Author(s): Russ Allbery
  • Date: 2012-01-03 13:38:12 UTC
  • mfrom: (13.2.10 sid)
  • Revision ID: package-import@ubuntu.com-20120103133812-zvmfb1i5lbqocb4w
Tags: 4.5-3
Fix build rule to not override CPPFLAGS, which deactivates some of the
options passed in by dpkg-buildflags.  Instead, use --with-krb5-lib
and --with-krb5-include to locate the Kerberos headers and libraries.
Thanks, Moritz Muehlenhoff.  (Closes: #654293)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * asprintf and vasprintf test suite.
 
3
 *
 
4
 * The canonical version of this file is maintained in the rra-c-util package,
 
5
 * which can be found at <http://www.eyrie.org/~eagle/software/rra-c-util/>.
 
6
 *
 
7
 * Written by Russ Allbery <rra@stanford.edu>
 
8
 *
 
9
 * The authors hereby relinquish any claim to any copyright that they may have
 
10
 * in this work, whether granted under contract or by operation of law or
 
11
 * international treaty, and hereby commit to the public, at large, that they
 
12
 * shall not, at any time in the future, seek to enforce any copyright in this
 
13
 * work against any person or entity, or prevent any person or entity from
 
14
 * copying, publishing, distributing or creating derivative works of this
 
15
 * work.
 
16
 */
 
17
 
 
18
#include <config.h>
 
19
#include <portable/system.h>
 
20
 
 
21
#include <tests/tap/basic.h>
 
22
 
 
23
int test_asprintf(char **, const char *, ...)
 
24
    __attribute__((__format__(printf, 2, 3)));
 
25
int test_vasprintf(char **, const char *, va_list);
 
26
 
 
27
static int
 
28
vatest(char **result, const char *format, ...)
 
29
{
 
30
    va_list args;
 
31
    int status;
 
32
 
 
33
    va_start(args, format);
 
34
    status = test_vasprintf(result, format, args);
 
35
    va_end(args);
 
36
    return status;
 
37
}
 
38
 
 
39
int
 
40
main(void)
 
41
{
 
42
    char *result = NULL;
 
43
 
 
44
    plan(12);
 
45
 
 
46
    is_int(7, test_asprintf(&result, "%s", "testing"), "asprintf length");
 
47
    is_string("testing", result, "asprintf result");
 
48
    free(result);
 
49
    ok(3, "free asprintf");
 
50
    is_int(0, test_asprintf(&result, "%s", ""), "asprintf empty length");
 
51
    is_string("", result, "asprintf empty string");
 
52
    free(result);
 
53
    ok(6, "free asprintf of empty string");
 
54
 
 
55
    is_int(6, vatest(&result, "%d %s", 2, "test"), "vasprintf length");
 
56
    is_string("2 test", result, "vasprintf result");
 
57
    free(result);
 
58
    ok(9, "free vasprintf");
 
59
    is_int(0, vatest(&result, "%s", ""), "vasprintf empty length");
 
60
    is_string("", result, "vasprintf empty string");
 
61
    free(result);
 
62
    ok(12, "free vasprintf of empty string");
 
63
 
 
64
    return 0;
 
65
}