Files
RedBear-OS/tests/stdlib/strtol.c
T
Tibor Nagy 4381bb2a22 tests: Remove redundant return statements
When the execution reaches the end of the main functions, they implicitly return a successful status.
2019-02-20 21:09:03 +01:00

30 lines
950 B
C

#include <errno.h>
#include <stdlib.h>
#include <stdio.h>
int main(void) {
printf("%ld\n", strtol(" -42", NULL, 0));
printf("%ld\n", strtol(" +555", NULL, 0));
printf("%ld\n", strtol(" 1234567890 ", NULL, 0));
printf("%ld\n", strtol(" -42", NULL, 10));
printf("%ld\n", strtol(" +555", NULL, 10));
printf("%ld\n", strtol(" 1234567890 ", NULL, 10));
printf("%lx\n", strtol(" 0x38Acfg", NULL, 0));
printf("%lx\n", strtol("0Xabcdef12", NULL, 16));
printf("%lx\n", strtol("cafebeef", NULL, 16));
printf("%lo\n", strtol(" 073189", NULL, 0));
printf("%lo\n", strtol(" 073189", NULL, 8));
printf("%lo\n", strtol(" 0b", NULL, 8));
if(errno != 0) {
printf("errno is not 0 (%d), something went wrong\n", errno);
}
printf("%lo\n", strtol(" 0b", NULL, 0));
if(errno != 0) {
printf("errno is not 0 (%d), something went wrong\n", errno);
}
}