test/testautomation_rwops.c
changeset 9254 6c469ea796e4
parent 9219 c65108ddbeb0
child 9260 039714172dc3
equal deleted inserted replaced
9253:4b7c962ae015 9254:6c469ea796e4
   103    SDL_zero(buf);
   103    SDL_zero(buf);
   104 
   104 
   105    /* Set to start. */
   105    /* Set to start. */
   106    i = SDL_RWseek(rw, 0, RW_SEEK_SET );
   106    i = SDL_RWseek(rw, 0, RW_SEEK_SET );
   107    SDLTest_AssertPass("Call to SDL_RWseek succeeded");
   107    SDLTest_AssertPass("Call to SDL_RWseek succeeded");
   108    SDLTest_AssertCheck(i == (Sint64)0, "Verify seek to 0 with SDL_RWseek (RW_SEEK_SET), expected 0, got %i", i);
   108    SDLTest_AssertCheck(i == (Sint64)0, "Verify seek to 0 with SDL_RWseek (RW_SEEK_SET), expected 0, got %lli", i);
   109 
   109 
   110    /* Test write. */
   110    /* Test write. */
   111    s = SDL_RWwrite(rw, RWopsHelloWorldTestString, sizeof(RWopsHelloWorldTestString)-1, 1);
   111    s = SDL_RWwrite(rw, RWopsHelloWorldTestString, sizeof(RWopsHelloWorldTestString)-1, 1);
   112    SDLTest_AssertPass("Call to SDL_RWwrite succeeded");
   112    SDLTest_AssertPass("Call to SDL_RWwrite succeeded");
   113    if (write) {
   113    if (write) {
   118    }
   118    }
   119 
   119 
   120    /* Test seek to random position */
   120    /* Test seek to random position */
   121    i = SDL_RWseek( rw, seekPos, RW_SEEK_SET );
   121    i = SDL_RWseek( rw, seekPos, RW_SEEK_SET );
   122    SDLTest_AssertPass("Call to SDL_RWseek succeeded");
   122    SDLTest_AssertPass("Call to SDL_RWseek succeeded");
   123    SDLTest_AssertCheck(i == (Sint64)seekPos, "Verify seek to %i with SDL_RWseek (RW_SEEK_SET), expected %i, got %i", seekPos, seekPos, i);
   123    SDLTest_AssertCheck(i == (Sint64)seekPos, "Verify seek to %i with SDL_RWseek (RW_SEEK_SET), expected %i, got %lli", seekPos, seekPos, i);
   124 
   124 
   125    /* Test seek back to start */
   125    /* Test seek back to start */
   126    i = SDL_RWseek(rw, 0, RW_SEEK_SET );
   126    i = SDL_RWseek(rw, 0, RW_SEEK_SET );
   127    SDLTest_AssertPass("Call to SDL_RWseek succeeded");
   127    SDLTest_AssertPass("Call to SDL_RWseek succeeded");
   128    SDLTest_AssertCheck(i == (Sint64)0, "Verify seek to 0 with SDL_RWseek (RW_SEEK_SET), expected 0, got %i", i);
   128    SDLTest_AssertCheck(i == (Sint64)0, "Verify seek to 0 with SDL_RWseek (RW_SEEK_SET), expected 0, got %lli", i);
   129 
   129 
   130    /* Test read */
   130    /* Test read */
   131    s = SDL_RWread( rw, buf, 1, sizeof(RWopsHelloWorldTestString)-1 );
   131    s = SDL_RWread( rw, buf, 1, sizeof(RWopsHelloWorldTestString)-1 );
   132    SDLTest_AssertPass("Call to SDL_RWread succeeded");
   132    SDLTest_AssertPass("Call to SDL_RWread succeeded");
   133    SDLTest_AssertCheck(
   133    SDLTest_AssertCheck(
   142    /* More seek tests. */
   142    /* More seek tests. */
   143    i = SDL_RWseek( rw, -4, RW_SEEK_CUR );
   143    i = SDL_RWseek( rw, -4, RW_SEEK_CUR );
   144    SDLTest_AssertPass("Call to SDL_RWseek(...,-4,RW_SEEK_CUR) succeeded");
   144    SDLTest_AssertPass("Call to SDL_RWseek(...,-4,RW_SEEK_CUR) succeeded");
   145    SDLTest_AssertCheck(
   145    SDLTest_AssertCheck(
   146        i == (Sint64)(sizeof(RWopsHelloWorldTestString)-5),
   146        i == (Sint64)(sizeof(RWopsHelloWorldTestString)-5),
   147        "Verify seek to -4 with SDL_RWseek (RW_SEEK_CUR), expected %i, got %i",
   147        "Verify seek to -4 with SDL_RWseek (RW_SEEK_CUR), expected %i, got %lli",
   148        sizeof(RWopsHelloWorldTestString)-5,
   148        sizeof(RWopsHelloWorldTestString)-5,
   149        i);
   149        i);
   150 
   150 
   151    i = SDL_RWseek( rw, -1, RW_SEEK_END );
   151    i = SDL_RWseek( rw, -1, RW_SEEK_END );
   152    SDLTest_AssertPass("Call to SDL_RWseek(...,-1,RW_SEEK_END) succeeded");
   152    SDLTest_AssertPass("Call to SDL_RWseek(...,-1,RW_SEEK_END) succeeded");
   153    SDLTest_AssertCheck(
   153    SDLTest_AssertCheck(
   154        i == (Sint64)(sizeof(RWopsHelloWorldTestString)-2),
   154        i == (Sint64)(sizeof(RWopsHelloWorldTestString)-2),
   155        "Verify seek to -1 with SDL_RWseek (RW_SEEK_END), expected %i, got %i",
   155        "Verify seek to -1 with SDL_RWseek (RW_SEEK_END), expected %i, got %lli",
   156        sizeof(RWopsHelloWorldTestString)-2,
   156        sizeof(RWopsHelloWorldTestString)-2,
   157        i);
   157        i);
   158 
   158 
   159    /* Invalid whence seek */
   159    /* Invalid whence seek */
   160    i = SDL_RWseek( rw, 0, 999 );
   160    i = SDL_RWseek( rw, 0, 999 );
   161    SDLTest_AssertPass("Call to SDL_RWseek(...,0,invalid_whence) succeeded");
   161    SDLTest_AssertPass("Call to SDL_RWseek(...,0,invalid_whence) succeeded");
   162    SDLTest_AssertCheck(
   162    SDLTest_AssertCheck(
   163        i == (Sint64)(-1),
   163        i == (Sint64)(-1),
   164        "Verify seek with SDL_RWseek (invalid_whence); expected: -1, got %i",
   164        "Verify seek with SDL_RWseek (invalid_whence); expected: -1, got %lli",
   165        i);
   165        i);
   166 }
   166 }
   167 
   167 
   168 /* !
   168 /* !
   169  * Negative test for SDL_RWFromFile parameters
   169  * Negative test for SDL_RWFromFile parameters
   666      SDLTest_AssertCheck(objectsWritten == 1, "Validate number of objects written, expected: 1, got: %i", objectsWritten);
   666      SDLTest_AssertCheck(objectsWritten == 1, "Validate number of objects written, expected: 1, got: %i", objectsWritten);
   667 
   667 
   668      /* Test seek to start */
   668      /* Test seek to start */
   669      result = SDL_RWseek( rw, 0, RW_SEEK_SET );
   669      result = SDL_RWseek( rw, 0, RW_SEEK_SET );
   670      SDLTest_AssertPass("Call to SDL_RWseek succeeded");
   670      SDLTest_AssertPass("Call to SDL_RWseek succeeded");
   671      SDLTest_AssertCheck(result == 0, "Verify result from position 0 with SDL_RWseek, expected 0, got %i", result);
   671      SDLTest_AssertCheck(result == 0, "Verify result from position 0 with SDL_RWseek, expected 0, got %lli", result);
   672 
   672 
   673      /* Read test data */
   673      /* Read test data */
   674      BE16test = SDL_ReadBE16(rw);
   674      BE16test = SDL_ReadBE16(rw);
   675      SDLTest_AssertPass("Call to SDL_ReadBE16()");
   675      SDLTest_AssertPass("Call to SDL_ReadBE16()");
   676      SDLTest_AssertCheck(BE16test == BE16value, "Validate return value from SDL_ReadBE16, expected: %hu, got: %hu", BE16value, BE16test);
   676      SDLTest_AssertCheck(BE16test == BE16value, "Validate return value from SDL_ReadBE16, expected: %hu, got: %hu", BE16value, BE16test);