aboutsummaryrefslogtreecommitdiff
path: root/tests/core/test_vsnprintf.in
blob: 85f91e940a1aedac91780c6df4e27ff6f84f55e6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include <stdio.h>
#include <stdarg.h>
#include <stdint.h>

void printy(const char *f, ...) {
  char buffer[256];
  va_list args;
  va_start(args, f);
  vsnprintf(buffer, 256, f, args);
  puts(buffer);
  va_end(args);
}

int main(int argc, char **argv) {
  int64_t x = argc - 1;
  int64_t y = argc - 1 + 0x400000;
  if (x % 3 == 2) y *= 2;

  printy("0x%llx_0x%llx", x, y);
  printy("0x%llx_0x%llx", x, x);
  printy("0x%llx_0x%llx", y, x);
  printy("0x%llx_0x%llx", y, y);

  {
    uint64_t A = 0x800000;
    uint64_t B = 0x800000000000ULL;
    printy("0x%llx_0x%llx", A, B);
  }
  {
    uint64_t A = 0x800;
    uint64_t B = 0x12340000000000ULL;
    printy("0x%llx_0x%llx", A, B);
  }
  {
    uint64_t A = 0x000009182746756;
    uint64_t B = 0x192837465631ACBDULL;
    printy("0x%llx_0x%llx", A, B);
  }

  return 0;
}