Christoph Mallon: Replace strlen(x) == 0 (O(n)) by x[0] == '\0' (O(1)).
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427
diff --git a/src/test/SDL_test_harness.c b/src/test/SDL_test_harness.c
index c58eae4..1bfe9c2 100644
--- a/src/test/SDL_test_harness.c
+++ b/src/test/SDL_test_harness.c
@@ -109,17 +109,17 @@ SDLTest_GenerateExecKey(char *runSeed, char *suiteName, char *testName, int iter
Uint32 entireStringLength;
char *buffer;
- if (runSeed == NULL || SDL_strlen(runSeed)==0) {
+ if (runSeed == NULL || runSeed[0] == '\0') {
SDLTest_LogError("Invalid runSeed string.");
return -1;
}
- if (suiteName == NULL || SDL_strlen(suiteName)==0) {
+ if (suiteName == NULL || suiteName[0] == '\0') {
SDLTest_LogError("Invalid suiteName string.");
return -1;
}
- if (testName == NULL || SDL_strlen(testName)==0) {
+ if (testName == NULL || testName[0] == '\0') {
SDLTest_LogError("Invalid testName string.");
return -1;
}
@@ -399,7 +399,7 @@ int SDLTest_RunSuites(SDLTest_TestSuiteReference *testSuites[], const char *user
}
/* Generate run see if we don't have one already */
- if (userRunSeed == NULL || SDL_strlen(userRunSeed) == 0) {
+ if (userRunSeed == NULL || userRunSeed[0] == '\0') {
runSeed = SDLTest_GenerateRunSeed(16);
if (runSeed == NULL) {
SDLTest_LogError("Generating a random seed failed");
@@ -422,7 +422,7 @@ int SDLTest_RunSuites(SDLTest_TestSuiteReference *testSuites[], const char *user
SDLTest_Log("::::: Test Run /w seed '%s' started\n", runSeed);
/* Initialize filtering */
- if (filter != NULL && SDL_strlen(filter) > 0) {
+ if (filter != NULL && filter[0] != '\0') {
/* Loop over all suites to check if we have a filter match */
suiteCounter = 0;
while (testSuites[suiteCounter] && suiteFilter == 0) {
@@ -521,7 +521,7 @@ int SDLTest_RunSuites(SDLTest_TestSuiteReference *testSuites[], const char *user
suiteCounter,
testCounter,
currentTestName);
- if (testCase->description != NULL && SDL_strlen(testCase->description)>0) {
+ if (testCase->description != NULL && testCase->description[0] != '\0') {
SDLTest_Log("Test Description: '%s'",
(testCase->description) ? testCase->description : SDLTest_InvalidNameFormat);
}
diff --git a/src/video/SDL_clipboard.c b/src/video/SDL_clipboard.c
index cd1d341..8c0626e 100644
--- a/src/video/SDL_clipboard.c
+++ b/src/video/SDL_clipboard.c
@@ -65,7 +65,7 @@ SDL_HasClipboardText(void)
if (_this->HasClipboardText) {
return _this->HasClipboardText(_this);
} else {
- if ((_this->clipboard_text) && (SDL_strlen(_this->clipboard_text)>0)) {
+ if (_this->clipboard_text && _this->clipboard_text[0] != '\0') {
return SDL_TRUE;
} else {
return SDL_FALSE;
diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c
index 53de057..53e6e02 100644
--- a/src/video/SDL_video.c
+++ b/src/video/SDL_video.c
@@ -1453,7 +1453,7 @@ SDL_SetWindowData(SDL_Window * window, const char *name, void *userdata)
CHECK_WINDOW_MAGIC(window, NULL);
/* Input validation */
- if (name == NULL || SDL_strlen(name) == 0) {
+ if (name == NULL || name[0] == '\0') {
SDL_InvalidParamError("name");
return NULL;
}
@@ -1500,7 +1500,7 @@ SDL_GetWindowData(SDL_Window * window, const char *name)
CHECK_WINDOW_MAGIC(window, NULL);
/* Input validation */
- if (name == NULL || SDL_strlen(name) == 0) {
+ if (name == NULL || name[0] == '\0') {
SDL_InvalidParamError("name");
return NULL;
}
diff --git a/src/video/bwindow/SDL_bclipboard.cc b/src/video/bwindow/SDL_bclipboard.cc
index 492b2fa..2ec80c6 100644
--- a/src/video/bwindow/SDL_bclipboard.cc
+++ b/src/video/bwindow/SDL_bclipboard.cc
@@ -82,7 +82,7 @@ SDL_bool BE_HasClipboardText(_THIS) {
SDL_bool result = SDL_FALSE;
char *text = BE_GetClipboardText(_this);
if (text) {
- result = (SDL_strlen(text)>0) ? SDL_TRUE : SDL_FALSE;
+ result = text[0] != '\0' ? SDL_TRUE : SDL_FALSE;
SDL_free(text);
}
return result;
diff --git a/src/video/cocoa/SDL_cocoaclipboard.m b/src/video/cocoa/SDL_cocoaclipboard.m
index ab31031..62c34b5 100644
--- a/src/video/cocoa/SDL_cocoaclipboard.m
+++ b/src/video/cocoa/SDL_cocoaclipboard.m
@@ -95,7 +95,7 @@ Cocoa_HasClipboardText(_THIS)
SDL_bool result = SDL_FALSE;
char *text = Cocoa_GetClipboardText(_this);
if (text) {
- result = (SDL_strlen(text)>0) ? SDL_TRUE : SDL_FALSE;
+ result = text[0] != '\0' ? SDL_TRUE : SDL_FALSE;
SDL_free(text);
}
return result;
diff --git a/src/video/windows/SDL_windowsclipboard.c b/src/video/windows/SDL_windowsclipboard.c
index 3d1db4a..15eea1a 100644
--- a/src/video/windows/SDL_windowsclipboard.c
+++ b/src/video/windows/SDL_windowsclipboard.c
@@ -137,7 +137,7 @@ WIN_HasClipboardText(_THIS)
SDL_bool result = SDL_FALSE;
char *text = WIN_GetClipboardText(_this);
if (text) {
- result = (SDL_strlen(text)>0) ? SDL_TRUE : SDL_FALSE;
+ result = text[0] != '\0' ? SDL_TRUE : SDL_FALSE;
SDL_free(text);
}
return result;
diff --git a/src/video/x11/SDL_x11clipboard.c b/src/video/x11/SDL_x11clipboard.c
index 54b5eb6..970aeaf 100644
--- a/src/video/x11/SDL_x11clipboard.c
+++ b/src/video/x11/SDL_x11clipboard.c
@@ -165,7 +165,7 @@ X11_HasClipboardText(_THIS)
SDL_bool result = SDL_FALSE;
char *text = X11_GetClipboardText(_this);
if (text) {
- result = (SDL_strlen(text)>0) ? SDL_TRUE : SDL_FALSE;
+ result = text[0] != '\0' ? SDL_TRUE : SDL_FALSE;
SDL_free(text);
}
return result;
diff --git a/test/testautomation_audio.c b/test/testautomation_audio.c
index 780c9e9..c5c3f04 100644
--- a/test/testautomation_audio.c
+++ b/test/testautomation_audio.c
@@ -77,7 +77,7 @@ int audio_initQuitAudio()
audioDriver = SDL_GetAudioDriver(i);
SDLTest_AssertPass("Call to SDL_GetAudioDriver(%d)", i);
SDLTest_AssertCheck(audioDriver != NULL, "Audio driver name is not NULL");
- SDLTest_AssertCheck(SDL_strlen(audioDriver) > 0, "Audio driver name is not empty; got: %s", audioDriver);
+ SDLTest_AssertCheck(audioDriver[0] != '\0', "Audio driver name is not empty; got: %s", audioDriver);
/* Call Init */
result = SDL_AudioInit(audioDriver);
@@ -134,7 +134,7 @@ int audio_initOpenCloseQuitAudio()
audioDriver = SDL_GetAudioDriver(i);
SDLTest_AssertPass("Call to SDL_GetAudioDriver(%d)", i);
SDLTest_AssertCheck(audioDriver != NULL, "Audio driver name is not NULL");
- SDLTest_AssertCheck(SDL_strlen(audioDriver) > 0, "Audio driver name is not empty; got: %s", audioDriver);
+ SDLTest_AssertCheck(audioDriver[0] != '\0', "Audio driver name is not empty; got: %s", audioDriver);
/* Change specs */
for (j = 0; j < 2; j++) {
@@ -226,14 +226,14 @@ int audio_enumerateAndNameAudioDevices()
SDLTest_AssertPass("Call to SDL_GetAudioDeviceName(%i, %i)", i, t);
SDLTest_AssertCheck(name != NULL, "Verify result from SDL_GetAudioDeviceName(%i, %i) is not NULL", i, t);
if (name != NULL) {
- SDLTest_AssertCheck(SDL_strlen(name)>0, "verify result from SDL_GetAudioDeviceName(%i, %i) is not empty, got: '%s'", i, t, name);
+ SDLTest_AssertCheck(name[0] != '\0', "verify result from SDL_GetAudioDeviceName(%i, %i) is not empty, got: '%s'", i, t, name);
if (t==1) {
/* Also try non-zero type */
tt = t + SDLTest_RandomIntegerInRange(1,10);
nameAgain = SDL_GetAudioDeviceName(i, tt);
SDLTest_AssertCheck(nameAgain != NULL, "Verify result from SDL_GetAudioDeviceName(%i, %i) is not NULL", i, tt);
if (nameAgain != NULL) {
- SDLTest_AssertCheck(SDL_strlen(nameAgain)>0, "Verify result from SDL_GetAudioDeviceName(%i, %i) is not empty, got: '%s'", i, tt, nameAgain);
+ SDLTest_AssertCheck(nameAgain[0] != '\0', "Verify result from SDL_GetAudioDeviceName(%i, %i) is not empty, got: '%s'", i, tt, nameAgain);
SDLTest_AssertCheck(SDL_strcmp(name, nameAgain)==0,
"Verify SDL_GetAudioDeviceName(%i, %i) and SDL_GetAudioDeviceName(%i %i) return the same string",
i, t, i, tt);
@@ -318,7 +318,7 @@ int audio_printAudioDrivers()
SDLTest_AssertPass("Call to SDL_GetAudioDriver(%i)", i);
SDLTest_AssertCheck(name != NULL, "Verify returned name is not NULL");
if (name != NULL) {
- SDLTest_AssertCheck(SDL_strlen(name)>0, "Verify returned name is not empty, got: '%s'", name);
+ SDLTest_AssertCheck(name[0] != '\0', "Verify returned name is not empty, got: '%s'", name);
}
}
}
@@ -339,7 +339,7 @@ int audio_printCurrentAudioDriver()
SDLTest_AssertPass("Call to SDL_GetCurrentAudioDriver()");
SDLTest_AssertCheck(name != NULL, "Verify returned name is not NULL");
if (name != NULL) {
- SDLTest_AssertCheck(SDL_strlen(name)>0, "Verify returned name is not empty, got: '%s'", name);
+ SDLTest_AssertCheck(name[0] != '\0', "Verify returned name is not empty, got: '%s'", name);
}
return TEST_COMPLETED;
@@ -509,7 +509,7 @@ int audio_buildAudioCVTNegative()
SDLTest_AssertCheck(result == -1, "Verify result value; expected: -1, got: %i", result);
error = SDL_GetError();
SDLTest_AssertPass("Call to SDL_GetError()");
- SDLTest_AssertCheck(error != NULL && SDL_strlen(error)>0, "Validate that error message was not NULL or empty");
+ SDLTest_AssertCheck(error != NULL && error[0] != '\0', "Validate that error message was not NULL or empty");
}
SDL_ClearError();
diff --git a/test/testautomation_clipboard.c b/test/testautomation_clipboard.c
index 1c438ee..9ce4f51 100644
--- a/test/testautomation_clipboard.c
+++ b/test/testautomation_clipboard.c
@@ -118,7 +118,7 @@ clipboard_testClipboardTextFunctions(void *arg)
charResult != NULL,
"Verify SDL_GetClipboardText did not return NULL");
SDLTest_AssertCheck(
- SDL_strlen(charResult) == 0,
+ charResult[0] == '\0',
"Verify SDL_GetClipboardText returned string with length 0, got length %i",
SDL_strlen(charResult));
intResult = SDL_SetClipboardText((const char *)text);
diff --git a/test/testautomation_pixels.c b/test/testautomation_pixels.c
index 3c0f63b..5112333 100644
--- a/test/testautomation_pixels.c
+++ b/test/testautomation_pixels.c
@@ -242,7 +242,7 @@ pixels_getPixelFormatName(void *arg)
SDLTest_AssertPass("Call to SDL_GetPixelFormatName()");
SDLTest_AssertCheck(result != NULL, "Verify result is not NULL");
if (result != NULL) {
- SDLTest_AssertCheck(SDL_strlen(result) > 0, "Verify result is non-empty");
+ SDLTest_AssertCheck(result[0] != '\0', "Verify result is non-empty");
SDLTest_AssertCheck(SDL_strcmp(result, unknownFormat) == 0,
"Verify result text; expected: %s, got %s", unknownFormat, result);
}
@@ -257,7 +257,7 @@ pixels_getPixelFormatName(void *arg)
SDLTest_AssertPass("Call to SDL_GetPixelFormatName()");
SDLTest_AssertCheck(result != NULL, "Verify result is not NULL");
if (result != NULL) {
- SDLTest_AssertCheck(SDL_strlen(result) > 0, "Verify result is non-empty");
+ SDLTest_AssertCheck(result[0] != '\0', "Verify result is non-empty");
SDLTest_AssertCheck(SDL_strcmp(result, _RGBPixelFormatsVerbose[i]) == 0,
"Verify result text; expected: %s, got %s", _RGBPixelFormatsVerbose[i], result);
}
@@ -273,7 +273,7 @@ pixels_getPixelFormatName(void *arg)
SDLTest_AssertPass("Call to SDL_GetPixelFormatName()");
SDLTest_AssertCheck(result != NULL, "Verify result is not NULL");
if (result != NULL) {
- SDLTest_AssertCheck(SDL_strlen(result) > 0, "Verify result is non-empty");
+ SDLTest_AssertCheck(result[0] != '\0', "Verify result is non-empty");
SDLTest_AssertCheck(SDL_strcmp(result, _nonRGBPixelFormatsVerbose[i]) == 0,
"Verify result text; expected: %s, got %s", _nonRGBPixelFormatsVerbose[i], result);
}
@@ -290,14 +290,14 @@ pixels_getPixelFormatName(void *arg)
SDLTest_AssertPass("Call to SDL_GetPixelFormatName(%u)", format);
SDLTest_AssertCheck(result != NULL, "Verify result is not NULL");
if (result != NULL) {
- SDLTest_AssertCheck(SDL_strlen(result) > 0,
+ SDLTest_AssertCheck(result[0] != '\0',
"Verify result is non-empty; got: %s", result);
SDLTest_AssertCheck(SDL_strcmp(result, _invalidPixelFormatsVerbose[i]) == 0,
"Validate name is UNKNOWN, expected: '%s', got: '%s'", _invalidPixelFormatsVerbose[i], result);
}
error = SDL_GetError();
SDLTest_AssertPass("Call to SDL_GetError()");
- SDLTest_AssertCheck(error != NULL && SDL_strlen(error) == 0, "Validate that error message is empty");
+ SDLTest_AssertCheck(error != NULL && error[0] != '\0', "Validate that error message is empty");
}
return TEST_COMPLETED;
diff --git a/test/testautomation_sdltest.c b/test/testautomation_sdltest.c
index e0d921b..d9ce7d2 100644
--- a/test/testautomation_sdltest.c
+++ b/test/testautomation_sdltest.c
@@ -192,7 +192,7 @@ sdltest_randomBoundaryNumberUint8(void *arg)
"Validate result value for parameters (1,255,SDL_FALSE); expected: 0, got: %lld", uresult);
lastError = (char *)SDL_GetError();
SDLTest_AssertPass("SDL_GetError()");
- SDLTest_AssertCheck(lastError == NULL || SDL_strlen(lastError) == 0, "Validate no error message was set");
+ SDLTest_AssertCheck(lastError == NULL || lastError[0] == '\0', "Validate no error message was set");
/* RandomUintXBoundaryValue(0, 0xfe, SDL_FALSE) returns 0xff (no error) */
uresult = (Uint64)SDLTest_RandomUint8BoundaryValue(0, 254, SDL_FALSE);
@@ -202,7 +202,7 @@ sdltest_randomBoundaryNumberUint8(void *arg)
"Validate result value for parameters (0,254,SDL_FALSE); expected: 0xff, got: %lld", uresult);
lastError = (char *)SDL_GetError();
SDLTest_AssertPass("SDL_GetError()");
- SDLTest_AssertCheck(lastError == NULL || SDL_strlen(lastError) == 0, "Validate no error message was set");
+ SDLTest_AssertCheck(lastError == NULL || lastError[0] == '\0', "Validate no error message was set");
/* RandomUintXBoundaryValue(0, 0xff, SDL_FALSE) returns 0 (sets error) */
uresult = (Uint64)SDLTest_RandomUint8BoundaryValue(0, 255, SDL_FALSE);
@@ -302,7 +302,7 @@ sdltest_randomBoundaryNumberUint16(void *arg)
"Validate result value for parameters (1,0xffff,SDL_FALSE); expected: 0, got: %lld", uresult);
lastError = (char *)SDL_GetError();
SDLTest_AssertPass("SDL_GetError()");
- SDLTest_AssertCheck(lastError == NULL || SDL_strlen(lastError) == 0, "Validate no error message was set");
+ SDLTest_AssertCheck(lastError == NULL || lastError[0] == '\0', "Validate no error message was set");
/* RandomUintXBoundaryValue(0, 0xfffe, SDL_FALSE) returns 0xffff (no error) */
uresult = (Uint64)SDLTest_RandomUint16BoundaryValue(0, 0xfffe, SDL_FALSE);
@@ -312,7 +312,7 @@ sdltest_randomBoundaryNumberUint16(void *arg)
"Validate result value for parameters (0,0xfffe,SDL_FALSE); expected: 0xffff, got: %lld", uresult);
lastError = (char *)SDL_GetError();
SDLTest_AssertPass("SDL_GetError()");
- SDLTest_AssertCheck(lastError == NULL || SDL_strlen(lastError) == 0, "Validate no error message was set");
+ SDLTest_AssertCheck(lastError == NULL || lastError[0] == '\0', "Validate no error message was set");
/* RandomUintXBoundaryValue(0, 0xffff, SDL_FALSE) returns 0 (sets error) */
uresult = (Uint64)SDLTest_RandomUint16BoundaryValue(0, 0xffff, SDL_FALSE);
@@ -412,7 +412,7 @@ sdltest_randomBoundaryNumberUint32(void *arg)
"Validate result value for parameters (1,0xffffffff,SDL_FALSE); expected: 0, got: %lld", uresult);
lastError = (char *)SDL_GetError();
SDLTest_AssertPass("SDL_GetError()");
- SDLTest_AssertCheck(lastError == NULL || SDL_strlen(lastError) == 0, "Validate no error message was set");
+ SDLTest_AssertCheck(lastError == NULL || lastError[0] == '\0', "Validate no error message was set");
/* RandomUintXBoundaryValue(0, 0xfffffffe, SDL_FALSE) returns 0xffffffff (no error) */
uresult = (Uint64)SDLTest_RandomUint32BoundaryValue(0, 0xfffffffe, SDL_FALSE);
@@ -422,7 +422,7 @@ sdltest_randomBoundaryNumberUint32(void *arg)
"Validate result value for parameters (0,0xfffffffe,SDL_FALSE); expected: 0xffffffff, got: %lld", uresult);
lastError = (char *)SDL_GetError();
SDLTest_AssertPass("SDL_GetError()");
- SDLTest_AssertCheck(lastError == NULL || SDL_strlen(lastError) == 0, "Validate no error message was set");
+ SDLTest_AssertCheck(lastError == NULL || lastError[0] == '\0', "Validate no error message was set");
/* RandomUintXBoundaryValue(0, 0xffffffff, SDL_FALSE) returns 0 (sets error) */
uresult = (Uint64)SDLTest_RandomUint32BoundaryValue(0, 0xffffffff, SDL_FALSE);
@@ -522,7 +522,7 @@ sdltest_randomBoundaryNumberUint64(void *arg)
"Validate result value for parameters (1,0xffffffffffffffff,SDL_FALSE); expected: 0, got: %lld", uresult);
lastError = (char *)SDL_GetError();
SDLTest_AssertPass("SDL_GetError()");
- SDLTest_AssertCheck(lastError == NULL || SDL_strlen(lastError) == 0, "Validate no error message was set");
+ SDLTest_AssertCheck(lastError == NULL || lastError[0] == '\0', "Validate no error message was set");
/* RandomUintXBoundaryValue(0, 0xfffffffffffffffe, SDL_FALSE) returns 0xffffffffffffffff (no error) */
uresult = (Uint64)SDLTest_RandomUint64BoundaryValue(0, (Uint64)0xfffffffffffffffeULL, SDL_FALSE);
@@ -532,7 +532,7 @@ sdltest_randomBoundaryNumberUint64(void *arg)
"Validate result value for parameters (0,0xfffffffffffffffe,SDL_FALSE); expected: 0xffffffffffffffff, got: %lld", uresult);
lastError = (char *)SDL_GetError();
SDLTest_AssertPass("SDL_GetError()");
- SDLTest_AssertCheck(lastError == NULL || SDL_strlen(lastError) == 0, "Validate no error message was set");
+ SDLTest_AssertCheck(lastError == NULL || lastError[0] == '\0', "Validate no error message was set");
/* RandomUintXBoundaryValue(0, 0xffffffffffffffff, SDL_FALSE) returns 0 (sets error) */
uresult = (Uint64)SDLTest_RandomUint64BoundaryValue(0, (Uint64)0xffffffffffffffffULL, SDL_FALSE);
@@ -632,7 +632,7 @@ sdltest_randomBoundaryNumberSint8(void *arg)
"Validate result value for parameters (SCHAR_MIN + 1,SCHAR_MAX,SDL_FALSE); expected: %d, got: %lld", SCHAR_MIN, sresult);
lastError = (char *)SDL_GetError();
SDLTest_AssertPass("SDL_GetError()");
- SDLTest_AssertCheck(lastError == NULL || SDL_strlen(lastError) == 0, "Validate no error message was set");
+ SDLTest_AssertCheck(lastError == NULL || lastError[0] == '\0', "Validate no error message was set");
/* RandomSintXBoundaryValue(SCHAR_MIN, SCHAR_MAX - 1, SDL_FALSE) returns SCHAR_MAX (no error) */
sresult = (Sint64)SDLTest_RandomSint8BoundaryValue(SCHAR_MIN, SCHAR_MAX -1, SDL_FALSE);
@@ -642,7 +642,7 @@ sdltest_randomBoundaryNumberSint8(void *arg)
"Validate result value for parameters (SCHAR_MIN,SCHAR_MAX - 1,SDL_FALSE); expected: %d, got: %lld", SCHAR_MAX, sresult);
lastError = (char *)SDL_GetError();
SDLTest_AssertPass("SDL_GetError()");
- SDLTest_AssertCheck(lastError == NULL || SDL_strlen(lastError) == 0, "Validate no error message was set");
+ SDLTest_AssertCheck(lastError == NULL || lastError[0] == '\0', "Validate no error message was set");
/* RandomSintXBoundaryValue(SCHAR_MIN, SCHAR_MAX, SDL_FALSE) returns SCHAR_MIN (sets error) */
sresult = (Sint64)SDLTest_RandomSint8BoundaryValue(SCHAR_MIN, SCHAR_MAX, SDL_FALSE);
@@ -742,7 +742,7 @@ sdltest_randomBoundaryNumberSint16(void *arg)
"Validate result value for parameters (SHRT_MIN+1,SHRT_MAX,SDL_FALSE); expected: %d, got: %lld", SHRT_MIN, sresult);
lastError = (char *)SDL_GetError();
SDLTest_AssertPass("SDL_GetError()");
- SDLTest_AssertCheck(lastError == NULL || SDL_strlen(lastError) == 0, "Validate no error message was set");
+ SDLTest_AssertCheck(lastError == NULL || lastError[0] == '\0', "Validate no error message was set");
/* RandomSintXBoundaryValue(SHRT_MIN, SHRT_MAX - 1, SDL_FALSE) returns SHRT_MAX (no error) */
sresult = (Sint64)SDLTest_RandomSint16BoundaryValue(SHRT_MIN, SHRT_MAX - 1, SDL_FALSE);
@@ -752,7 +752,7 @@ sdltest_randomBoundaryNumberSint16(void *arg)
"Validate result value for parameters (SHRT_MIN,SHRT_MAX - 1,SDL_FALSE); expected: %d, got: %lld", SHRT_MAX, sresult);
lastError = (char *)SDL_GetError();
SDLTest_AssertPass("SDL_GetError()");
- SDLTest_AssertCheck(lastError == NULL || SDL_strlen(lastError) == 0, "Validate no error message was set");
+ SDLTest_AssertCheck(lastError == NULL || lastError[0] == '\0', "Validate no error message was set");
/* RandomSintXBoundaryValue(SHRT_MIN, SHRT_MAX, SDL_FALSE) returns 0 (sets error) */
sresult = (Sint64)SDLTest_RandomSint16BoundaryValue(SHRT_MIN, SHRT_MAX, SDL_FALSE);
@@ -859,7 +859,7 @@ sdltest_randomBoundaryNumberSint32(void *arg)
"Validate result value for parameters (LONG_MIN+1,LONG_MAX,SDL_FALSE); expected: %d, got: %lld", long_min, sresult);
lastError = (char *)SDL_GetError();
SDLTest_AssertPass("SDL_GetError()");
- SDLTest_AssertCheck(lastError == NULL || SDL_strlen(lastError) == 0, "Validate no error message was set");
+ SDLTest_AssertCheck(lastError == NULL || lastError[0] == '\0', "Validate no error message was set");
/* RandomSintXBoundaryValue(LONG_MIN, LONG_MAX - 1, SDL_FALSE) returns LONG_MAX (no error) */
sresult = (Sint64)SDLTest_RandomSint32BoundaryValue(long_min, long_max - 1, SDL_FALSE);
@@ -869,7 +869,7 @@ sdltest_randomBoundaryNumberSint32(void *arg)
"Validate result value for parameters (LONG_MIN,LONG_MAX - 1,SDL_FALSE); expected: %d, got: %lld", long_max, sresult);
lastError = (char *)SDL_GetError();
SDLTest_AssertPass("SDL_GetError()");
- SDLTest_AssertCheck(lastError == NULL || SDL_strlen(lastError) == 0, "Validate no error message was set");
+ SDLTest_AssertCheck(lastError == NULL || lastError[0] == '\0', "Validate no error message was set");
/* RandomSintXBoundaryValue(LONG_MIN, LONG_MAX, SDL_FALSE) returns 0 (sets error) */
sresult = (Sint64)SDLTest_RandomSint32BoundaryValue(long_min, long_max, SDL_FALSE);
@@ -969,7 +969,7 @@ sdltest_randomBoundaryNumberSint64(void *arg)
"Validate result value for parameters (LLONG_MIN+1,LLONG_MAX,SDL_FALSE); expected: %lld, got: %lld", LLONG_MIN, sresult);
lastError = (char *)SDL_GetError();
SDLTest_AssertPass("SDL_GetError()");
- SDLTest_AssertCheck(lastError == NULL || SDL_strlen(lastError) == 0, "Validate no error message was set");
+ SDLTest_AssertCheck(lastError == NULL || lastError[0] == '\0', "Validate no error message was set");
/* RandomSintXBoundaryValue(LLONG_MIN, LLONG_MAX - 1, SDL_FALSE) returns LLONG_MAX (no error) */
sresult = (Sint64)SDLTest_RandomSint64BoundaryValue(LLONG_MIN, LLONG_MAX - 1, SDL_FALSE);
@@ -979,7 +979,7 @@ sdltest_randomBoundaryNumberSint64(void *arg)
"Validate result value for parameters (LLONG_MIN,LLONG_MAX - 1,SDL_FALSE); expected: %lld, got: %lld", LLONG_MAX, sresult);
lastError = (char *)SDL_GetError();
SDLTest_AssertPass("SDL_GetError()");
- SDLTest_AssertCheck(lastError == NULL || SDL_strlen(lastError) == 0, "Validate no error message was set");
+ SDLTest_AssertCheck(lastError == NULL || lastError[0] == '\0', "Validate no error message was set");
/* RandomSintXBoundaryValue(LLONG_MIN, LLONG_MAX, SDL_FALSE) returns 0 (sets error) */
sresult = (Sint64)SDLTest_RandomSint64BoundaryValue(LLONG_MIN, LLONG_MAX, SDL_FALSE);
diff --git a/test/testime.c b/test/testime.c
index 0baf437..93b33e0 100644
--- a/test/testime.c
+++ b/test/testime.c
@@ -331,7 +331,7 @@ int main(int argc, char *argv[]) {
break;
case SDL_TEXTINPUT:
- if (SDL_strlen(event.text.text) == 0 || event.text.text[0] == '\n' ||
+ if (event.text.text[0] == '\0' || event.text.text[0] == '\n' ||
markedRect.w < 0)
break;