Files
Liu 3801fdc10f refactor(yutil): rename public APIs and migrate timer to ptk
- charset module renamed to encoding (decode/encode kept)
- time: get_time_ms → y_gettime, sleep_ms → y_sleep
- time: delete get_time_us, get_time_delta, sleep_s
- string: strdup2 → y_strdup, wcsdup2 → y_wcsdup
- string: strtolower → y_strlower, strtrim → y_strtrim
- string: wcstrim → y_wcstrim, strhash → y_strhash
- string: strreplace → y_strreplace, strsplit → y_strsplit
- string: delete wcsreplace, cmdsplit
- math: delete y_iround, y_pow2
- timer module migrated from yutil to ptk as internal timer_scheduler
- WinMain simplified to use __argc/__argv instead of cmdsplit

BREAKING CHANGE: all renamed yutil public APIs require downstream
  to update function names. Deleted APIs require code changes:
  - get_time_us: use y_gettime() for ms timestamps
  - get_time_delta: use y_gettime() - start instead
  - sleep_s: use y_sleep(ms) with millisecond argument
  - wcsreplace: no replacement, had zero callers
  - cmdsplit: WinMain now uses __argc/__argv from CRT
  - timer_list_*: migrated to ptk timer_scheduler_*;
    ptk_reset_timer still available for external use
2026-08-05 22:42:26 +08:00

46 lines
1.8 KiB
C

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "test.h"
#include "libtest.h"
#include "yutil/keywords.h"
#include "yutil/string.h"
#include "yutil/strlist.h"
void test_strs(void)
{
char **strs = NULL;
strlist_add(&strs, "first-child");
strlist_add(&strs, "last-child");
strlist_add(&strs, "one two");
it_b("check first-child is in the list",
strlist_has(strs, "first-child"), true);
it_b("check last-child is in the list", strlist_has(strs, "last-child"),
true);
it_b("check one is in the list", strlist_has(strs, "one"), true);
it_b("check two is in the list", strlist_has(strs, "two"), true);
it_b("check remove(last_child)", strlist_remove(&strs, "last-child"),
true);
it_b("check remove(first-child", strlist_remove(&strs, "first-child"),
true);
it_b("check remove(one)", strlist_remove(&strs, "one"), true);
it_b("check first-child is removed", strlist_has(strs, "first-child"),
false);
it_b("check one is removed", strlist_has(strs, "one"), false);
it_b("check two is still in the list", strlist_has(strs, "two"), true);
it_i("check y_strhash(123, \"123\") is consistent",
y_strhash(123, "123"), y_strhash(123, "123"));
it_b("check y_strhash(123, \"123\") != y_strhash(123, \"312\")",
y_strhash(123, "123") == y_strhash(123, "312"), false);
it_b("check y_strhash(100, \"123\") != y_strhash(123, \"123\")",
y_strhash(100, "123") == y_strhash(123, "123"), false);
it_b("check adding first-child", strlist_add(&strs, "first-child"),
true);
strlist_free(strs);
}
void test_string(void)
{
describe("test strs", test_strs);
}