From c43bac44ba261cb730da05df54b059aea6afc981 Mon Sep 17 00:00:00 2001 From: Andrew Nguyen Date: Sun, 18 Jul 2010 19:33:27 -0500 Subject: [PATCH] shlwapi/tests: Add tests for StrStrA. --- dlls/shlwapi/tests/string.c | 48 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/dlls/shlwapi/tests/string.c b/dlls/shlwapi/tests/string.c index b8cf7e05450..a4e8d459818 100644 --- a/dlls/shlwapi/tests/string.c +++ b/dlls/shlwapi/tests/string.c @@ -960,6 +960,53 @@ if (0) win_skip("wnsprintfW() is not available\n"); } +static void test_StrStrA(void) +{ + static const char *deadbeef = "DeAdBeEf"; + + const struct + { + const char *search; + const char *expect; + } StrStrA_cases[] = + { + {"", NULL}, + {"DeAd", deadbeef}, + {"dead", NULL}, + {"AdBe", deadbeef + 2}, + {"adbe", NULL}, + {"BeEf", deadbeef + 4}, + {"beef", NULL}, + }; + + LPSTR ret; + int i; + + /* Tests crash on Win9x/Win2k. */ + if (0) + { + ret = StrStrA(NULL, NULL); + ok(!ret, "Expected StrStrA to return NULL, got %p\n", ret); + + ret = StrStrA(NULL, ""); + ok(!ret, "Expected StrStrA to return NULL, got %p\n", ret); + + ret = StrStrA("", NULL); + ok(!ret, "Expected StrStrA to return NULL, got %p\n", ret); + } + + ret = StrStrA("", ""); + ok(!ret, "Expected StrStrA to return NULL, got %p\n", ret); + + for (i = 0; i < sizeof(StrStrA_cases)/sizeof(StrStrA_cases[0]); i++) + { + ret = StrStrA(deadbeef, StrStrA_cases[i].search); + ok(ret == StrStrA_cases[i].expect, + "[%d] Expected StrStrA to return %p, got %p\n", + i, StrStrA_cases[i].expect, ret); + } +} + START_TEST(string) { HMODULE hShlwapi; @@ -1029,6 +1076,7 @@ START_TEST(string) test_SHAnsiToAnsi(); test_SHUnicodeToUnicode(); test_StrXXX_overflows(); + test_StrStrA(); CoUninitialize(); } -- 2.11.4.GIT