|
@@ -60,6 +60,68 @@ static int stdlib_strlcpy(void *arg)
|
|
|
return TEST_COMPLETED;
|
|
|
}
|
|
|
|
|
|
+/**
|
|
|
+ * Call to SDL_strstr
|
|
|
+ */
|
|
|
+static int stdlib_strstr(void *arg)
|
|
|
+{
|
|
|
+ char *result;
|
|
|
+ const char *text = "abcdef";
|
|
|
+ const char *expected;
|
|
|
+
|
|
|
+ result = SDL_strstr(text, "");
|
|
|
+ expected = text;
|
|
|
+ SDLTest_AssertPass("Call to SDL_strstr(text, \"\")");
|
|
|
+ SDLTest_AssertCheck(result == expected, "Check result, expected: %s, got: %s", expected, result);
|
|
|
+
|
|
|
+ result = SDL_strstr(text, "abc");
|
|
|
+ expected = text;
|
|
|
+ SDLTest_AssertPass("Call to SDL_strstr(text, \"abc\")");
|
|
|
+ SDLTest_AssertCheck(result == expected, "Check result, expected: %s, got: %s", expected, result);
|
|
|
+
|
|
|
+ result = SDL_strstr(text, "bcd");
|
|
|
+ expected = text+1;
|
|
|
+ SDLTest_AssertPass("Call to SDL_strstr(text, \"bcd\")");
|
|
|
+ SDLTest_AssertCheck(result == expected, "Check result, expected: %s, got: %s", expected, result);
|
|
|
+
|
|
|
+ result = SDL_strstr(text, "xyz");
|
|
|
+ expected = NULL;
|
|
|
+ SDLTest_AssertPass("Call to SDL_strstr(text, \"xyz\")");
|
|
|
+ SDLTest_AssertCheck(result == expected, "Check result, expected: (null), got: %s", result);
|
|
|
+
|
|
|
+ result = SDL_strnstr(text, "", SDL_strlen(text));
|
|
|
+ expected = text;
|
|
|
+ SDLTest_AssertPass("Call to SDL_strnstr(text, \"\", SDL_strlen(text))");
|
|
|
+ SDLTest_AssertCheck(result == expected, "Check result, expected: %s, got: %s", expected, result);
|
|
|
+
|
|
|
+ result = SDL_strnstr(text, "abc", SDL_strlen(text));
|
|
|
+ expected = text;
|
|
|
+ SDLTest_AssertPass("Call to SDL_strnstr(text, \"abc\", SDL_strlen(text))");
|
|
|
+ SDLTest_AssertCheck(result == expected, "Check result, expected: %s, got: %s", expected, result);
|
|
|
+
|
|
|
+ result = SDL_strnstr(text, "bcd", SDL_strlen(text));
|
|
|
+ expected = text+1;
|
|
|
+ SDLTest_AssertPass("Call to SDL_strnstr(text, \"bcd\", SDL_strlen(text))");
|
|
|
+ SDLTest_AssertCheck(result == expected, "Check result, expected: %s, got: %s", expected, result);
|
|
|
+
|
|
|
+ result = SDL_strnstr(text, "bcd", 3);
|
|
|
+ expected = NULL;
|
|
|
+ SDLTest_AssertPass("Call to SDL_strnstr(text, \"bcd\", 3)");
|
|
|
+ SDLTest_AssertCheck(result == expected, "Check result, expected: (null), got: %s", result);
|
|
|
+
|
|
|
+ result = SDL_strnstr(text, "xyz", 3);
|
|
|
+ expected = NULL;
|
|
|
+ SDLTest_AssertPass("Call to SDL_strnstr(text, \"xyz\", 3)");
|
|
|
+ SDLTest_AssertCheck(result == expected, "Check result, expected: (null), got: %s", result);
|
|
|
+
|
|
|
+ result = SDL_strnstr(text, "xyz", SDL_strlen(text)*100000);
|
|
|
+ expected = NULL;
|
|
|
+ SDLTest_AssertPass("Call to SDL_strnstr(text, \"xyz\", SDL_strlen(text)*100000)");
|
|
|
+ SDLTest_AssertCheck(result == expected, "Check result, expected: (null), got: %s", result);
|
|
|
+
|
|
|
+ return TEST_COMPLETED;
|
|
|
+}
|
|
|
+
|
|
|
#if defined(HAVE_WFORMAT) || defined(HAVE_WFORMAT_EXTRA_ARGS)
|
|
|
#pragma GCC diagnostic push
|
|
|
#ifdef HAVE_WFORMAT
|
|
@@ -930,22 +992,26 @@ static const SDLTest_TestCaseReference stdlibTest2 = {
|
|
|
};
|
|
|
|
|
|
static const SDLTest_TestCaseReference stdlibTest3 = {
|
|
|
- stdlib_snprintf, "stdlib_snprintf", "Call to SDL_snprintf", TEST_ENABLED
|
|
|
+ stdlib_strstr, "stdlib_strstr", "Call to SDL_strstr", TEST_ENABLED
|
|
|
};
|
|
|
|
|
|
static const SDLTest_TestCaseReference stdlibTest4 = {
|
|
|
- stdlib_swprintf, "stdlib_swprintf", "Call to SDL_swprintf", TEST_ENABLED
|
|
|
+ stdlib_snprintf, "stdlib_snprintf", "Call to SDL_snprintf", TEST_ENABLED
|
|
|
};
|
|
|
|
|
|
static const SDLTest_TestCaseReference stdlibTest5 = {
|
|
|
- stdlib_getsetenv, "stdlib_getsetenv", "Call to SDL_getenv and SDL_setenv", TEST_ENABLED
|
|
|
+ stdlib_swprintf, "stdlib_swprintf", "Call to SDL_swprintf", TEST_ENABLED
|
|
|
};
|
|
|
|
|
|
static const SDLTest_TestCaseReference stdlibTest6 = {
|
|
|
- stdlib_sscanf, "stdlib_sscanf", "Call to SDL_sscanf", TEST_ENABLED
|
|
|
+ stdlib_getsetenv, "stdlib_getsetenv", "Call to SDL_getenv and SDL_setenv", TEST_ENABLED
|
|
|
};
|
|
|
|
|
|
static const SDLTest_TestCaseReference stdlibTest7 = {
|
|
|
+ stdlib_sscanf, "stdlib_sscanf", "Call to SDL_sscanf", TEST_ENABLED
|
|
|
+};
|
|
|
+
|
|
|
+static const SDLTest_TestCaseReference stdlibTest8 = {
|
|
|
stdlib_aligned_alloc, "stdlib_aligned_alloc", "Call to SDL_aligned_alloc", TEST_ENABLED
|
|
|
};
|
|
|
|
|
@@ -962,6 +1028,7 @@ static const SDLTest_TestCaseReference *stdlibTests[] = {
|
|
|
&stdlibTest5,
|
|
|
&stdlibTest6,
|
|
|
&stdlibTest7,
|
|
|
+ &stdlibTest8,
|
|
|
&stdlibTestOverflow,
|
|
|
NULL
|
|
|
};
|