737c974400
- Split tests/ (libc feature tests) and examples/ (real apps); shared
app.mk in repo root, was examples/example.mk
- libc/io/* split into libc/{conio,env,errno,file,mouse,string,sys,
time,video}/ — clearer module boundaries
- New examples/mdview/: markdown viewer (Phases 1-5 + light nested
lists). Headers (H1-H4), HR, ulist/olist/quote with nesting via
leading spaces, fenced code blocks, inline emphasis (bold/italic/
underscore/code), wrap/unwrap mode with soft wrap (F2), horizontal
pan (← →) with '>' truncation indicator
- libc additions: scroll() in conio (ESTEX SCROLL), strlwr/strupr,
gets() test
- Makefile updates across tests/ for the new shared app.mk path
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
54 lines
1.4 KiB
C
54 lines
1.4 KiB
C
#include <stdio.h>
|
|
#include <string.h>
|
|
|
|
static void check(const char *label, int ok)
|
|
{
|
|
puts(label);
|
|
puts(ok ? " OK" : " FAIL");
|
|
}
|
|
|
|
int main(void)
|
|
{
|
|
char buf[32];
|
|
|
|
/* strlen */
|
|
check("strlen(\"\") == 0", strlen("") == 0);
|
|
check("strlen(\"hello\") == 5", strlen("hello") == 5);
|
|
|
|
/* strcpy + strlen */
|
|
strcpy(buf, "Sprinter");
|
|
check("strcpy + strlen == 8", strlen(buf) == 8);
|
|
|
|
/* strcmp */
|
|
check("strcmp(\"a\",\"a\") == 0", strcmp("a", "a") == 0);
|
|
check("strcmp(\"a\",\"b\") < 0", strcmp("a", "b") < 0);
|
|
check("strcmp(\"b\",\"a\") > 0", strcmp("b", "a") > 0);
|
|
check("strcmp(buf,\"Sprinter\")", strcmp(buf, "Sprinter") == 0);
|
|
|
|
/* strcat */
|
|
strcpy(buf, "Hello ");
|
|
strcat(buf, "Sprinter!");
|
|
check("strcat -> \"Hello Sprinter!\"", strcmp(buf, "Hello Sprinter!") == 0);
|
|
|
|
/* memcpy */
|
|
memset(buf, 'X', 16);
|
|
memcpy(buf + 4, "ABCD", 4);
|
|
buf[16] = 0;
|
|
check("memset+memcpy -> \"XXXXABCDXXXXXXXX\"",
|
|
strcmp(buf, "XXXXABCDXXXXXXXX") == 0);
|
|
|
|
/* memset */
|
|
memset(buf, 'q', 5);
|
|
buf[5] = 0;
|
|
check("memset(buf,'q',5) -> \"qqqqq\"", strcmp(buf, "qqqqq") == 0);
|
|
|
|
/* memcmp */
|
|
check("memcmp equal", memcmp("abcd", "abcd", 4) == 0);
|
|
check("memcmp diff", memcmp("abcd", "abxd", 4) != 0);
|
|
|
|
puts("");
|
|
puts("All checks done. Press any key to exit.");
|
|
(void)getchar();
|
|
return 0;
|
|
}
|