brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.1 KiB · a4f0130 Raw
55 lines · cpp
1// RUN: %clangxx -O0 -g %s -o %t && %run %t 2>&1 | FileCheck %s2//3// UNSUPPORTED: darwin, target={{.*(linux|solaris).*}}4 5#define _OPENBSD_SOURCE6 7#include <assert.h>8#include <stdio.h>9#include <stdlib.h>10 11int main(void) {12  const char *errstr;13 14  printf("strtonum\n");15 16  long long l = strtonum("100", 1, 100, &errstr);17  assert(!errstr);18  printf("%lld\n", l);19 20  l = strtonum("200", 1, 100, &errstr);21  assert(errstr);22  printf("%s\n", errstr);23 24  l = strtonum("300", 1000, 1001, &errstr);25  assert(errstr);26  printf("%s\n", errstr);27 28  l = strtonum("abc", 1000, 1001, &errstr);29  assert(errstr);30  printf("%s\n", errstr);31 32  l = strtonum("1000", 1001, 1000, &errstr);33  assert(errstr);34  printf("%s\n", errstr);35 36  l = strtonum("1000abc", 1000, 1001, &errstr);37  assert(errstr);38  printf("%s\n", errstr);39 40  l = strtonum("1000.0", 1000, 1001, &errstr);41  assert(errstr);42  printf("%s\n", errstr);43 44  // CHECK: strtonum45  // CHECK: 10046  // CHECK: too large47  // CHECK: too small48  // CHECK: invalid49  // CHECK: invalid50  // CHECK: invalid51  // CHECK: invalid52 53  return 0;54}55