Skip to content

Commit

Permalink
findstr/tests: Always set text/regex search mode in tests.
Browse files Browse the repository at this point in the history
(mainly for the tests without mode, which were written with textual mode in
mind, yet run in regex mode)

Signed-off-by: Eric Pouech <[email protected]>
  • Loading branch information
Eric Pouech authored and julliard committed Feb 24, 2025
1 parent b29952f commit 2529a6b
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions programs/findstr/tests/findstr.c
Original file line number Diff line number Diff line change
Expand Up @@ -148,69 +148,69 @@ static void test_basic(void)
ok(!ret, "Got the wrong result.\n");

/* find string in stdin, LF */
run_find_stdin("abc", "abc\n", 0);
run_find_stdin("/L abc", "abc\n", 0);
ok(stdout_size > 0, "Unexpected stdout buffer size %ld.\n", stdout_size);
ok(stderr_size == 0, "Unexpected stderr buffer size %ld.\n", stderr_size);
ret = strcmp(stdout_buffer, "abc\n");
ok(!ret, "Got the wrong result.\n");

/* find string in stdin, CR/LF */
run_find_stdin("abc", "abc\r\n", 0);
run_find_stdin("/L abc", "abc\r\n", 0);
ok(stdout_size > 0, "Unexpected stdout buffer size %ld.\n", stdout_size);
ok(stderr_size == 0, "Unexpected stderr buffer size %ld.\n", stderr_size);
ret = strcmp(stdout_buffer, "abc\r\n");
ok(!ret, "Got the wrong result.\n");

/* find string in stdin fails */
run_find_stdin("abc", "cba", 1);
run_find_stdin("/L abc", "cba", 1);
ok(stdout_size == 0, "Unexpected stdout buffer size %ld.\n", stdout_size);
ok(stderr_size == 0, "Unexpected stderr buffer size %ld.\n", stderr_size);

/* find string in file */
run_find_file("abc", "abc", 0);
run_find_file("/L abc", "abc", 0);
ok(stdout_size > 0, "Unexpected stdout buffer size %ld.\n", stdout_size);
ok(stderr_size == 0, "Unexpected stderr buffer size %ld.\n", stderr_size);
ret = strcmp(stdout_buffer, "abc");
ok(!ret, "Got the wrong result.\n");

/* find string in file fails */
run_find_file("abc", "cba", 1);
run_find_file("/L abc", "cba", 1);
ok(stdout_size == 0, "Unexpected stdout buffer size %ld.\n", stdout_size);
ok(stderr_size == 0, "Unexpected stderr buffer size %ld.\n", stderr_size);

/* find string in stdin with space separator */
run_find_stdin("\"abc cba\"", "abc", 0);
run_find_stdin("/L \"abc cba\"", "abc", 0);
ok(stdout_size > 0, "Unexpected stdout buffer size %ld.\n", stdout_size);
ok(stderr_size == 0, "Unexpected stderr buffer size %ld.\n", stderr_size);
ret = strcmp(stdout_buffer, "abc\r\n");
ok(!ret, "Got the wrong result.\n");

/* find string in stdin with /C: */
run_find_stdin("/C:abc", "abc", 0);
run_find_stdin("/L /C:abc", "abc", 0);
ok(stdout_size > 0, "Unexpected stdout buffer size %ld.\n", stdout_size);
ok(stderr_size == 0, "Unexpected stderr buffer size %ld.\n", stderr_size);
ret = strcmp(stdout_buffer, "abc\r\n");
ok(!ret, "Got the wrong result.\n");

/* find string in stdin with /C:"abc" */
run_find_stdin("/C:\"abc\"", "abc", 0);
run_find_stdin("/L /C:\"abc\"", "abc", 0);
ok(stdout_size > 0, "Unexpected stdout buffer size %ld.\n", stdout_size);
ok(stderr_size == 0, "Unexpected stderr buffer size %ld.\n", stderr_size);
ret = strcmp(stdout_buffer, "abc\r\n");
ok(!ret, "Got the wrong result.\n");

/* find string in stdin with /C:"abc cba" fails */
run_find_stdin("/C:\"abc cba\"", "abc", 1);
run_find_stdin("/L /C:\"abc cba\"", "abc", 1);
ok(stdout_size == 0, "Unexpected stdout buffer size %ld.\n", stdout_size);
ok(stderr_size == 0, "Unexpected stderr buffer size %ld.\n", stderr_size);

/* find string in stdin with /C: fails */
run_find_stdin("/C:abc", "cba", 1);
run_find_stdin("/L /C:abc", "cba", 1);
ok(stdout_size == 0, "Unexpected stdout buffer size %ld.\n", stdout_size);
ok(stderr_size == 0, "Unexpected stderr buffer size %ld.\n", stderr_size);

/* find string in file, case insensitive */
run_find_file("/I aBc", "abc", 0);
run_find_file("/L /I aBc", "abc", 0);
ok(stdout_size > 0, "Unexpected stdout buffer size %ld.\n", stdout_size);
ok(stderr_size == 0, "Unexpected stderr buffer size %ld.\n", stderr_size);
ret = strcmp(stdout_buffer, "abc");
Expand Down

0 comments on commit 2529a6b

Please sign in to comment.