Update SDL_InvalidParamError to take param name; add additional fuzzer function; add new tests to keyboard test suite; improve surface test suite
authorAndreas Schiffler <aschiffler@ferzkopp.net>
Sat, 12 Jan 2013 22:58:12 -0800
changeset 6811 60d95fcfaf3c
parent 6810 b5609445aa4c
child 6812 1f92a4ad24e7
Update SDL_InvalidParamError to take param name; add additional fuzzer function; add new tests to keyboard test suite; improve surface test suite
include/SDL_error.h
include/SDL_test_fuzzer.h
src/SDL_error.c
src/events/SDL_keyboard.c
src/test/SDL_test_fuzzer.c
src/video/android/SDL_androidkeyboard.c
src/video/cocoa/SDL_cocoakeyboard.m
src/video/windows/SDL_windowskeyboard.c
test/testautomation_keyboard.c
test/testautomation_surface.c
--- a/include/SDL_error.h	Sat Jan 12 14:06:58 2013 -0500
+++ b/include/SDL_error.h	Sat Jan 12 22:58:12 2013 -0800
@@ -52,7 +52,7 @@
 /*@{*/
 #define SDL_OutOfMemory()	SDL_Error(SDL_ENOMEM)
 #define SDL_Unsupported()	SDL_Error(SDL_UNSUPPORTED)
-#define SDL_InvalidParamError()	SDL_Error(SDL_INVALIDPARAM)
+#define SDL_InvalidParamError(param)	SDL_SetError("Parameter '%s' is invalid", (param))
 typedef enum
 {
     SDL_ENOMEM,
@@ -60,7 +60,6 @@
     SDL_EFWRITE,
     SDL_EFSEEK,
     SDL_UNSUPPORTED,
-    SDL_INVALIDPARAM,
     SDL_LASTERROR
 } SDL_errorcode;
 extern DECLSPEC void SDLCALL SDL_Error(SDL_errorcode code);
--- a/include/SDL_test_fuzzer.h	Sat Jan 12 14:06:58 2013 -0500
+++ b/include/SDL_test_fuzzer.h	Sat Jan 12 22:58:12 2013 -0800
@@ -329,30 +329,44 @@
 
 
 /**
- * Generates random null-terminated string. The maximum length for
- * the string is 255 characters and it can contain ASCII characters
- * from 1 to 127.
+ * Generates random null-terminated string. The minimum length for
+ * the string is 1 character, maximum length for the string is 255 
+ * characters and it can contain ASCII characters from 32 to 126.
  *
  * Note: Returned string needs to be deallocated.
  *
- * \returns newly allocated random string
+ * \returns Newly allocated random string; or NULL if length was invalid or string could not be allocated.
  */
 char * SDLTest_RandomAsciiString();
 
 
 /**
  * Generates random null-terminated string. The maximum length for
- * the string is defined by maxLenght parameter.
- * String can contain ASCII characters from 1 to 127.
+ * the string is defined by the maxLength parameter.
+ * String can contain ASCII characters from 32 to 126.
  *
  * Note: Returned string needs to be deallocated.
  *
- * \param maxLength Maximum length of the generated string
+ * \param maxLength The maximum length of the generated string.
  *
- * \returns newly allocated random string
+ * \returns Newly allocated random string; or NULL if maxLength was invalid or string could not be allocated. 
  */
 char * SDLTest_RandomAsciiStringWithMaximumLength(int maxLength);
 
+
+/**
+ * Generates random null-terminated string. The length for
+ * the string is defined by the size parameter.
+ * String can contain ASCII characters from 32 to 126.
+ *
+ * Note: Returned string needs to be deallocated.
+ *
+ * \param size The length of the generated string
+ *
+ * \returns Newly allocated random string; or NULL if size was invalid or string could not be allocated.
+ */
+char * SDLTest_RandomAsciiStringOfSize(int size);
+
 /**
  * Returns the invocation count for the fuzzer since last ...FuzzerInit.
  */
--- a/src/SDL_error.c	Sat Jan 12 14:06:58 2013 -0500
+++ b/src/SDL_error.c	Sat Jan 12 22:58:12 2013 -0800
@@ -235,9 +235,6 @@
     case SDL_UNSUPPORTED:
         SDL_SetError("That operation is not supported");
         break;
-    case SDL_INVALIDPARAM:
-        SDL_SetError("Parameter is invalid");
-        break;
     default:
         SDL_SetError("Unknown SDL error");
         break;
--- a/src/events/SDL_keyboard.c	Sat Jan 12 14:06:58 2013 -0500
+++ b/src/events/SDL_keyboard.c	Sat Jan 12 22:58:12 2013 -0800
@@ -895,17 +895,20 @@
 	int i;
 
 	if (!name || !*name) {
+	        SDL_InvalidParamError("name");
 		return SDL_SCANCODE_UNKNOWN;
 	}
 
 	for (i = 0; i < SDL_arraysize(SDL_scancode_names); ++i) {
 		if (!SDL_scancode_names[i]) {
 			continue;
-		}
+		}		
 		if (SDL_strcasecmp(name, SDL_scancode_names[i]) == 0) {
 			return (SDL_Scancode)i;
 		}
 	}
+
+	SDL_InvalidParamError("name");
 	return SDL_SCANCODE_UNKNOWN;
 }
 
--- a/src/test/SDL_test_fuzzer.c	Sat Jan 12 14:06:58 2013 -0500
+++ b/src/test/SDL_test_fuzzer.c	Sat Jan 12 22:58:12 2013 -0800
@@ -614,25 +614,37 @@
 char *
 SDLTest_RandomAsciiString()
 {
-	// note: fuzzerInvocationCounter is increment in the RandomAsciiStringWithMaximumLenght
 	return SDLTest_RandomAsciiStringWithMaximumLength(255);
 }
 
 char *
-SDLTest_RandomAsciiStringWithMaximumLength(int maxSize)
+SDLTest_RandomAsciiStringWithMaximumLength(int maxLength)
 {
 	int size;
+
+	if(maxLength < 1) {
+                SDL_InvalidParamError("maxLength");
+		return NULL;
+	}
+
+	size = (SDLTest_RandomUint32() % (maxLength + 1));
+	
+	return SDLTest_RandomAsciiStringOfSize(size);	
+}
+
+char *
+SDLTest_RandomAsciiStringOfSize(int size)
+{
 	char *string;
 	int counter;
 
-	fuzzerInvocationCounter++;
 
-	if(maxSize < 1) {
+	if(size < 1) {
+                SDL_InvalidParamError("size");
 		return NULL;
 	}
 
-	size = (SDLTest_RandomUint32() % (maxSize + 1)) + 1;
-	string = (char *)SDL_malloc(size * sizeof(char));
+	string = (char *)SDL_malloc((size + 1) * sizeof(char));
 	if (string==NULL) {
 	  return NULL;
         }
@@ -643,5 +655,7 @@
 
 	string[counter] = '\0';
 
+	fuzzerInvocationCounter++;
+
 	return string;
 }
--- a/src/video/android/SDL_androidkeyboard.c	Sat Jan 12 14:06:58 2013 -0500
+++ b/src/video/android/SDL_androidkeyboard.c	Sat Jan 12 22:58:12 2013 -0800
@@ -318,7 +318,7 @@
     SDL_VideoData *videodata = (SDL_VideoData *)_this->driverdata;
 
     if (!rect) {
-        SDL_InvalidParamError();
+        SDL_InvalidParamError("rect");
         return;
     }
     
--- a/src/video/cocoa/SDL_cocoakeyboard.m	Sat Jan 12 14:06:58 2013 -0500
+++ b/src/video/cocoa/SDL_cocoakeyboard.m	Sat Jan 12 22:58:12 2013 -0800
@@ -669,7 +669,7 @@
     SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
 
     if (!rect) {
-	SDL_InvalidParamError();
+	SDL_InvalidParamError("rect");
 	return;
     }
 
--- a/src/video/windows/SDL_windowskeyboard.c	Sat Jan 12 14:06:58 2013 -0500
+++ b/src/video/windows/SDL_windowskeyboard.c	Sat Jan 12 22:58:12 2013 -0800
@@ -214,7 +214,7 @@
     SDL_VideoData *videodata = (SDL_VideoData *)_this->driverdata;
     
     if (!rect) {
-        SDL_InvalidParamError();
+        SDL_InvalidParamError("rect");
         return;
     }
     
--- a/test/testautomation_keyboard.c	Sat Jan 12 14:06:58 2013 -0500
+++ b/test/testautomation_keyboard.c	Sat Jan 12 22:58:12 2013 -0800
@@ -382,7 +382,7 @@
 int
 keyboard_setTextInputRectNegative(void *arg)
 {      
-   const char *expectedError = "Parameter is invalid";
+   const char *expectedError = "Parameter 'rect' is invalid";
    const char *error;
    
    SDL_ClearError();
@@ -405,6 +405,157 @@
    return TEST_COMPLETED;
 }
 
+/**
+ * @brief Check call to SDL_GetScancodeFromKey
+ * 
+ * @sa http://wiki.libsdl.org/moin.cgi/SDL_GetScancodeFromKey
+ * @sa http://wiki.libsdl.org/moin.cgi/SDL_Keycode
+ */
+int
+keyboard_getScancodeFromKey(void *arg)
+{      
+   SDL_Scancode scancode;
+   
+   /* Regular key */
+   scancode = SDL_GetScancodeFromKey(SDLK_4);
+   SDLTest_AssertPass("Call to SDL_GetScancodeFromKey(SDLK_4)");
+   SDLTest_AssertCheck(scancode == SDL_SCANCODE_4, "Validate return value from SDL_GetScancodeFromKey, expected: %i, got: %i", SDL_SCANCODE_4, scancode); 
+
+   /* Virtual key */
+   scancode = SDL_GetScancodeFromKey(SDLK_PLUS);
+   SDLTest_AssertPass("Call to SDL_GetScancodeFromKey(SDLK_PLUS)");
+   SDLTest_AssertCheck(scancode == 0, "Validate return value from SDL_GetScancodeFromKey, expected: 0, got: %i", scancode); 
+        
+   return TEST_COMPLETED;
+}
+
+/**
+ * @brief Check call to SDL_GetScancodeFromName
+ * 
+ * @sa http://wiki.libsdl.org/moin.cgi/SDL_GetScancodeFromName
+ * @sa http://wiki.libsdl.org/moin.cgi/SDL_Keycode
+ */
+int
+keyboard_getScancodeFromName(void *arg)
+{      
+   SDL_Scancode scancode;
+
+   /* Regular key, 1 character, first name in list */
+   scancode = SDL_GetScancodeFromName("A");
+   SDLTest_AssertPass("Call to SDL_GetScancodeFromName('A')");
+   SDLTest_AssertCheck(scancode == SDL_SCANCODE_A, "Validate return value from SDL_GetScancodeFromName, expected: %i, got: %i", SDL_SCANCODE_A, scancode); 
+
+   /* Regular key, 1 character */
+   scancode = SDL_GetScancodeFromName("4");
+   SDLTest_AssertPass("Call to SDL_GetScancodeFromName('4')");
+   SDLTest_AssertCheck(scancode == SDL_SCANCODE_4, "Validate return value from SDL_GetScancodeFromName, expected: %i, got: %i", SDL_SCANCODE_4, scancode); 
+
+   /* Regular key, 2 characters */
+   scancode = SDL_GetScancodeFromName("F1");
+   SDLTest_AssertPass("Call to SDL_GetScancodeFromName('F1')");
+   SDLTest_AssertCheck(scancode == SDL_SCANCODE_F1, "Validate return value from SDL_GetScancodeFromName, expected: %i, got: %i", SDL_SCANCODE_F1, scancode); 
+
+   /* Regular key, 3 characters */
+   scancode = SDL_GetScancodeFromName("End");
+   SDLTest_AssertPass("Call to SDL_GetScancodeFromName('End')");
+   SDLTest_AssertCheck(scancode == SDL_SCANCODE_END, "Validate return value from SDL_GetScancodeFromName, expected: %i, got: %i", SDL_SCANCODE_END, scancode); 
+
+   /* Regular key, 4 characters */
+   scancode = SDL_GetScancodeFromName("Find");
+   SDLTest_AssertPass("Call to SDL_GetScancodeFromName('Find')");
+   SDLTest_AssertCheck(scancode == SDL_SCANCODE_FIND, "Validate return value from SDL_GetScancodeFromName, expected: %i, got: %i", SDL_SCANCODE_FIND, scancode); 
+
+   /* Regular key, several characters */
+   scancode = SDL_GetScancodeFromName("Backspace");
+   SDLTest_AssertPass("Call to SDL_GetScancodeFromName('Backspace')");
+   SDLTest_AssertCheck(scancode == SDL_SCANCODE_BACKSPACE, "Validate return value from SDL_GetScancodeFromName, expected: %i, got: %i", SDL_SCANCODE_BACKSPACE, scancode); 
+
+   /* Regular key, several characters with space */
+   scancode = SDL_GetScancodeFromName("Keypad Enter");
+   SDLTest_AssertPass("Call to SDL_GetScancodeFromName('Keypad Enter')");
+   SDLTest_AssertCheck(scancode == SDL_SCANCODE_KP_ENTER, "Validate return value from SDL_GetScancodeFromName, expected: %i, got: %i", SDL_SCANCODE_KP_ENTER, scancode); 
+
+   /* Regular key, last name in list */
+   scancode = SDL_GetScancodeFromName("Sleep");
+   SDLTest_AssertPass("Call to SDL_GetScancodeFromName('Sleep')");
+   SDLTest_AssertCheck(scancode == SDL_SCANCODE_SLEEP, "Validate return value from SDL_GetScancodeFromName, expected: %i, got: %i", SDL_SCANCODE_SLEEP, scancode); 
+   
+   return TEST_COMPLETED;
+}
+
+/**
+ * @brief Check call to SDL_GetScancodeFromName with invalid data
+ * 
+ * @sa http://wiki.libsdl.org/moin.cgi/SDL_GetScancodeFromName
+ * @sa http://wiki.libsdl.org/moin.cgi/SDL_Keycode
+ */
+int
+keyboard_getScancodeFromNameNegative(void *arg)
+{      
+   char *name;
+   SDL_Scancode scancode;
+   const char *expectedError = "Parameter 'name' is invalid";
+   const char *error;
+
+   SDL_ClearError();
+   SDLTest_AssertPass("Call to SDL_ClearError()");
+
+   /* Random string input */
+   name = SDLTest_RandomAsciiStringOfSize(32);
+   SDLTest_Assert(name != NULL, "Check that random name is not NULL");
+   if (name == NULL) {
+      return TEST_ABORTED;
+   }   
+   scancode = SDL_GetScancodeFromName((const char *)name);
+   SDLTest_AssertPass("Call to SDL_GetScancodeFromName('%s')", name);
+   SDL_free(name);
+   SDLTest_AssertCheck(scancode == SDL_SCANCODE_UNKNOWN, "Validate return value from SDL_GetScancodeFromName, expected: %i, got: %i", SDL_SCANCODE_UNKNOWN, scancode);
+   error = SDL_GetError();
+   SDLTest_AssertPass("Call to SDL_GetError()");
+   SDLTest_AssertCheck(error != NULL, "Validate that error message was not NULL");
+   if (error != NULL) {
+      SDLTest_AssertCheck(SDL_strcmp(error, expectedError) == 0, 
+          "Validate error message, expected: '%s', got: '%s'", expectedError, error);
+   }
+
+   SDL_ClearError();
+   SDLTest_AssertPass("Call to SDL_ClearError()");
+         
+   /* Zero length string input */
+   name = "";
+   scancode = SDL_GetScancodeFromName((const char *)name);
+   SDLTest_AssertPass("Call to SDL_GetScancodeFromName(NULL)");
+   SDLTest_AssertCheck(scancode == SDL_SCANCODE_UNKNOWN, "Validate return value from SDL_GetScancodeFromName, expected: %i, got: %i", SDL_SCANCODE_UNKNOWN, scancode);
+   error = SDL_GetError();
+   SDLTest_AssertPass("Call to SDL_GetError()");
+   SDLTest_AssertCheck(error != NULL, "Validate that error message was not NULL");
+   if (error != NULL) {
+      SDLTest_AssertCheck(SDL_strcmp(error, expectedError) == 0, 
+          "Validate error message, expected: '%s', got: '%s'", expectedError, error);
+   }
+
+   SDL_ClearError();
+   SDLTest_AssertPass("Call to SDL_ClearError()");
+
+   /* NULL input */
+   name = NULL;
+   scancode = SDL_GetScancodeFromName((const char *)name);
+   SDLTest_AssertPass("Call to SDL_GetScancodeFromName(NULL)");
+   SDLTest_AssertCheck(scancode == SDL_SCANCODE_UNKNOWN, "Validate return value from SDL_GetScancodeFromName, expected: %i, got: %i", SDL_SCANCODE_UNKNOWN, scancode);
+   error = SDL_GetError();
+   SDLTest_AssertPass("Call to SDL_GetError()");
+   SDLTest_AssertCheck(error != NULL, "Validate that error message was not NULL");
+   if (error != NULL) {
+      SDLTest_AssertCheck(SDL_strcmp(error, expectedError) == 0, 
+          "Validate error message, expected: '%s', got: '%s'", expectedError, error);
+   }
+
+   SDL_ClearError();
+   SDLTest_AssertPass("Call to SDL_ClearError()");
+   
+   return TEST_COMPLETED;
+}
+
 
 
 /* ================= Test References ================== */
@@ -437,10 +588,19 @@
 static const SDLTest_TestCaseReference keyboardTest9 =
 		{ (SDLTest_TestCaseFp)keyboard_setTextInputRectNegative, "keyboard_setTextInputRectNegative", "Check call to SDL_SetTextInputRect with invalid data", TEST_ENABLED };
 
+static const SDLTest_TestCaseReference keyboardTest10 =
+		{ (SDLTest_TestCaseFp)keyboard_getScancodeFromKey, "keyboard_getScancodeFromKey", "Check call to SDL_GetScancodeFromKey", TEST_ENABLED };
+
+static const SDLTest_TestCaseReference keyboardTest11 =
+		{ (SDLTest_TestCaseFp)keyboard_getScancodeFromName, "keyboard_getScancodeFromName", "Check call to SDL_GetScancodeFromName", TEST_ENABLED };
+
+static const SDLTest_TestCaseReference keyboardTest12 =
+		{ (SDLTest_TestCaseFp)keyboard_getScancodeFromNameNegative, "keyboard_getScancodeFromNameNegative", "Check call to SDL_GetScancodeFromName with invalid data", TEST_ENABLED };
+
 /* Sequence of Keyboard test cases */
 static const SDLTest_TestCaseReference *keyboardTests[] =  {
 	&keyboardTest1, &keyboardTest2, &keyboardTest3, &keyboardTest4, &keyboardTest5, &keyboardTest6, 
-	&keyboardTest7, &keyboardTest8, &keyboardTest9, NULL
+	&keyboardTest7, &keyboardTest8, &keyboardTest9, &keyboardTest10, &keyboardTest11, &keyboardTest12, NULL
 };
 
 /* Keyboard test suite (global) */
--- a/test/testautomation_surface.c	Sat Jan 12 14:06:58 2013 -0500
+++ b/test/testautomation_surface.c	Sat Jan 12 22:58:12 2013 -0800
@@ -4,7 +4,7 @@
  */
 
 /* Supress C4996 VS compiler warnings for unlink() */
-#define _CRT_SECURE_NO_DEPRECATE
+#define _CRT_SECURE_NO_DEPRECATE
 #define _CRT_NONSTDC_NO_DEPRECATE
 
 #include <stdio.h>
@@ -27,26 +27,37 @@
 
 /* Fixture */
 
-/* Create a 32-bit writable surface for screen tests */
+/* Create a 32-bit writable surface for blitting tests */
 void
 _surfaceSetUp(void *arg)
 {
-    Uint32 rmask, gmask, bmask, amask;
-#if SDL_BYTEORDER == SDL_BIG_ENDIAN
-    rmask = 0xff000000;
-    gmask = 0x00ff0000;
-    bmask = 0x0000ff00;
-    amask = 0x000000ff;
-#else
-    rmask = 0x000000ff;
-    gmask = 0x0000ff00;
-    bmask = 0x00ff0000;
-    amask = 0xff000000;
-#endif
-
-	referenceSurface = SDLTest_ImageBlit(); /* For size info */
-	testSurface = SDL_CreateRGBSurface(SDL_SWSURFACE, referenceSurface->w, referenceSurface->h, 32, rmask, gmask, bmask, amask);
+    int result;
+    SDL_BlendMode blendMode = SDL_BLENDMODE_NONE;
+    SDL_BlendMode currentBlendMode;
+    Uint32 rmask, gmask, bmask, amask;
+#if SDL_BYTEORDER == SDL_BIG_ENDIAN
+    rmask = 0xff000000;
+    gmask = 0x00ff0000;
+    bmask = 0x0000ff00;
+    amask = 0x000000ff;
+#else
+    rmask = 0x000000ff;
+    gmask = 0x0000ff00;
+    bmask = 0x00ff0000;
+    amask = 0xff000000;
+#endif
+
+    referenceSurface = SDLTest_ImageBlit(); /* For size info */
+    testSurface = SDL_CreateRGBSurface(SDL_SWSURFACE, referenceSurface->w, referenceSurface->h, 32, rmask, gmask, bmask, amask);
     SDLTest_AssertCheck(testSurface != NULL, "Check that testSurface is not NULL");
+    if (testSurface != NULL) {
+      /* Disable blend mode for target surface */
+      result = SDL_SetSurfaceBlendMode(testSurface, blendMode);
+      SDLTest_AssertCheck(result == 0, "Validate result from SDL_SetSurfaceBlendMode, expected: 0, got: %i", result);
+      result = SDL_GetSurfaceBlendMode(testSurface, &currentBlendMode);
+      SDLTest_AssertCheck(result == 0, "Validate result from SDL_GetSurfaceBlendMode, expected: 0, got: %i", result);
+      SDLTest_AssertCheck(currentBlendMode == blendMode, "Validate blendMode, expected: %i, got: %i", blendMode, currentBlendMode);      
+    }
 }
 
 void
@@ -69,10 +80,10 @@
 {
 	int ret;
 	Uint32 color;
-	
+
 	/* Clear surface. */
-	color = SDL_MapRGB( testSurface->format, 0, 0, 0);
-	SDLTest_AssertPass("Call to SDL_MapRGB()");
+	color = SDL_MapRGBA( testSurface->format, 0, 0, 0, 0);
+	SDLTest_AssertPass("Call to SDL_MapRGBA()");
 	ret = SDL_FillRect( testSurface, NULL, color);
 	SDLTest_AssertPass("Call to SDL_FillRect()");
 	SDLTest_AssertCheck(ret == 0, "Verify result from SDL_FillRect, expected: 0, got: %i", ret);
@@ -103,6 +114,21 @@
 	SDLTest_AssertCheck(face != NULL, "Verify face surface is not NULL");
 	if (face == NULL) return;
 
+        /* Reset alpha modulation */	
+	ret = SDL_SetSurfaceAlphaMod(face, 255);
+	SDLTest_AssertPass("Call to SDL_SetSurfaceAlphaMod()");
+	SDLTest_AssertCheck(ret == 0, "Verify result from SDL_SetSurfaceAlphaMod(), expected: 0, got: %i", ret);
+
+        /* Reset color modulation */	
+	ret = SDL_SetSurfaceColorMod(face, 255, 255, 255);
+	SDLTest_AssertPass("Call to SDL_SetSurfaceColorMod()");
+	SDLTest_AssertCheck(ret == 0, "Verify result from SDL_SetSurfaceColorMod(), expected: 0, got: %i", ret);
+
+        /* Reset color key */	
+	ret = SDL_SetColorKey(face, SDL_FALSE, 0);
+	SDLTest_AssertPass("Call to SDL_SetColorKey()");
+	SDLTest_AssertCheck(ret == 0, "Verify result from SDL_SetColorKey(), expected: 0, got: %i", ret);
+
 	/* Clear the test surface */
         _clearTestSurface();
         
@@ -141,11 +167,16 @@
 		else if (mode == -4) {
 			/* Crazy blending mode magic. */
 			nmode = (i/4*j/4) % 4;
-			if (nmode==0) bmode = SDL_BLENDMODE_NONE;
-			else if (nmode==1) bmode = SDL_BLENDMODE_BLEND;
-			else if (nmode==2) bmode = SDL_BLENDMODE_ADD;
-			else if (nmode==3) bmode = SDL_BLENDMODE_MOD;
-			ret = SDL_SetSurfaceBlendMode( face, bmode );		
+			if (nmode==0) {
+				bmode = SDL_BLENDMODE_NONE;
+			} else if (nmode==1) {
+				bmode = SDL_BLENDMODE_BLEND;
+			} else if (nmode==2) {
+				bmode = SDL_BLENDMODE_ADD;				
+			} else if (nmode==3) {
+				bmode = SDL_BLENDMODE_MOD;
+			}
+			ret = SDL_SetSurfaceBlendMode( face, bmode );
 			if (ret != 0) checkFailCount4++;
 		}
 
@@ -473,7 +504,7 @@
    int ret;
    SDL_Surface *referenceSurface;
 
-   /* All blitting */ 
+   /* All blitting modes */ 
    _testBlitBlendMode(-4);
    
    /* Verify result by comparing surfaces */