summaryrefslogtreecommitdiff
path: root/src/user/app/tests/libc/string.c
blob: 8f889dcafa2a7f54b54888fc206afb4ad60f75a8 (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
#include "../tests.h"
#include <string.h>

static void test_strtol(void) {
	char *end;
	test(1234 == strtol("1234", NULL, 10));
	test(1234 == strtol("+1234", NULL, 10));
	test(-1234 == strtol("-1234", NULL, 10));

	test(1234 == strtol("1234", &end, 10));
	test(!strcmp("", end));
	test(1234 == strtol("   1234hello", &end, 10));
	test(!strcmp("hello", end));

	test(1234 == strtol("   1234hello", &end, 0));
	test(!strcmp("hello", end));
	test(0xCAF3 == strtol("   0xCaF3hello", &end, 0));
	test(!strcmp("hello", end));
	test(01234 == strtol("   01234hello", &end, 0));
	test(!strcmp("hello", end));
}

void r_libc_string(void) {
	run_test(test_strtol);
}