Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / compiler-rt / test / sanitizer_common / TestCases / NetBSD / strtoi.cpp
blob4d0d8b3aebf00c9ab4c81de41b5bee419a0f2831
1 // RUN: %clangxx -O0 -g %s -o %t && %run %t 2>&1 | FileCheck %s
3 #include <inttypes.h>
4 #include <stdio.h>
6 void test_strtoi(const char *nptr, int base, intmax_t lo, intmax_t hi) {
7 char *p;
8 int status;
9 intmax_t i = strtoi(nptr, &p, base, lo, hi, &status);
10 printf("strtoi: conversion of '%s' to a number %s, using %jd, p=%#" PRIx8
11 "\n",
12 nptr, status ? "failed" : "successful", i, *p);
15 void test_strtou(const char *nptr, int base, intmax_t lo, intmax_t hi) {
16 char *p;
17 int status;
18 uintmax_t i = strtou(nptr, &p, base, lo, hi, &status);
19 printf("strtou: conversion of '%s' to a number %s, using %ju, p=%#" PRIx8
20 "\n",
21 nptr, status ? "failed" : "successful", i, *p);
24 int main(void) {
25 printf("strtoi\n");
27 test_strtoi("100", 0, 1, 100);
28 test_strtoi("100", 0, 1, 10);
29 test_strtoi("100xyz", 0, 1, 100);
30 test_strtou("100", 0, 1, 100);
31 test_strtou("100", 0, 1, 10);
32 test_strtou("100xyz", 0, 1, 100);
34 // CHECK: strtoi
35 // CHECK: strtoi: conversion of '100' to a number successful, using 100, p=0
36 // CHECK: strtoi: conversion of '100' to a number failed, using 10, p=0
37 // CHECK: strtoi: conversion of '100xyz' to a number failed, using 100, p=0x78
38 // CHECK: strtou: conversion of '100' to a number successful, using 100, p=0
39 // CHECK: strtou: conversion of '100' to a number failed, using 10, p=0
40 // CHECK: strtou: conversion of '100xyz' to a number failed, using 100, p=0x78
42 return 0;