1 // RUN: %clangxx -O0 -g %s -o %t && %run %t 2>&1 | FileCheck %s
6 void test_strtoi(const char *nptr
, int base
, intmax_t lo
, intmax_t hi
) {
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
12 nptr
, status
? "failed" : "successful", i
, *p
);
15 void test_strtou(const char *nptr
, int base
, intmax_t lo
, intmax_t hi
) {
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
21 nptr
, status
? "failed" : "successful", i
, *p
);
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);
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