4static void test_escape_returns_null_on_null_input_or_zero_chars(
void **state) {
6 assert_null(escape_for_batch(
nullptr, 10));
7 assert_null(escape_for_batch(L
"input", 0));
10static void test_escape_handles_special_characters(
void **state) {
12 wchar_t *out = escape_for_batch(L
"%VAR%", 5);
13 assert_memory_equal(L
"%%VAR%%", out, 7);
16 out = escape_for_batch(L
"\"VAR\"", 5);
17 assert_memory_equal(L
"\"\"VAR\"\"", out, 7);
21static void test_escape_handles_reg_multi_sz(
void **state) {
23 wchar_t input[] = {L
'a', L
'\0', L
'b', L
'\0', L
'c'};
24 wchar_t *out = escape_for_batch(input, 5);
25 assert_memory_equal(L
"a\\0b\\0c", out, 9);
29static void test_escape_returns_same_when_escaping_unnecessary(
void **state) {
31 wchar_t *out = escape_for_batch(L
"abcdef", 6);
32 assert_memory_equal(L
"abcdef", out, 6);
36const struct CMUnitTest shell_tests[] = {
37 cmocka_unit_test(test_escape_handles_reg_multi_sz),
38 cmocka_unit_test(test_escape_handles_special_characters),
39 cmocka_unit_test(test_escape_returns_null_on_null_input_or_zero_chars),
40 cmocka_unit_test(test_escape_returns_same_when_escaping_unnecessary),
43int main(
int argc,
char *argv[]) {
46 return cmocka_run_group_tests(shell_tests,
nullptr,
nullptr);