init commit

This commit is contained in:
Faynot
2026-07-07 20:35:07 +03:00
commit 38cc34a6e9
33 changed files with 659 additions and 0 deletions

33
tests/test_basic.c Normal file
View File

@@ -0,0 +1,33 @@
#include <assert.h>
#include <stddef.h>
#include <stdio.h>
#include <string.h>
int main(void) {
/* memcpy */
char src[] = "hello world";
char dst[64];
memcpy(dst, src, 12);
dst[12] = 0;
assert(strcmp(dst, "hello world") == 0);
/* strlen */
assert(strlen("") == 0);
assert(strlen("abc") == 3);
/* memset */
char buf[10];
memset(buf, 0xAB, 10);
for (int i = 0; i < 10; i++) assert((unsigned char)buf[i] == 0xAB);
/* memcmp */
assert(memcmp("abc", "abc", 3) == 0);
assert(memcmp("abc", "abd", 3) < 0);
/* strcmp */
assert(strcmp("hello", "hello") == 0);
assert(strcmp("abc", "def") < 0);
printf("ALL STRING TESTS PASSED\n");
return 0;
}