~ubuntu-branches/ubuntu/trusty/libsdl2/trusty

« back to all changes in this revision

Viewing changes to test/testfile.c

  • Committer: Package Import Robot
  • Author(s): Manuel A. Fernandez Montecelo, Felix Geyer
  • Date: 2013-12-28 12:31:19 UTC
  • mfrom: (1.1.3)
  • Revision ID: package-import@ubuntu.com-20131228123119-e0k27gckmnzskfgb
Tags: 2.0.1+dfsg1-1
* New upstream release (Closes: #728974)
  - Remove patch applied upstream:
    bug-723797-false_positives_in_mouse_wheel_code.patch
* Bump Standards-Version to 3.9.5, no changes needed.

[ Felix Geyer ]
* Import upstream gpg key for uscan to verify the orig tarball.

Show diffs side-by-side

added added

removed removed

Lines of Context:
12
12
 
13
13
/* sanity tests on SDL_rwops.c (usefull for alternative implementations of stdio rwops) */
14
14
 
15
 
// quiet windows compiler warnings
 
15
/* quiet windows compiler warnings */
16
16
#define _CRT_NONSTDC_NO_WARNINGS
17
17
 
18
18
#include <stdlib.h>
44
44
static void
45
45
cleanup(void)
46
46
{
47
 
 
48
47
    unlink(FBASENAME1);
49
48
    unlink(FBASENAME2);
50
49
}
52
51
static void
53
52
rwops_error_quit(unsigned line, SDL_RWops * rwops)
54
53
{
55
 
 
56
 
    printf("testfile.c(%d): failed\n", line);
 
54
    SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "testfile.c(%d): failed\n", line);
57
55
    if (rwops) {
58
56
        rwops->close(rwops);    /* This calls SDL_FreeRW(rwops); */
59
57
    }
71
69
    SDL_RWops *rwops = NULL;
72
70
    char test_buf[30];
73
71
 
 
72
    /* Enable standard application logging */
 
73
        SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
 
74
 
74
75
    cleanup();
75
76
 
76
77
/* test 1 : basic argument test: all those calls to SDL_RWFromFile should fail */
90
91
    rwops = SDL_RWFromFile("something", NULL);
91
92
    if (rwops)
92
93
        RWOP_ERR_QUIT(rwops);
93
 
    printf("test1 OK\n");
 
94
    SDL_Log("test1 OK\n");
94
95
 
95
96
/* test 2 : check that inexistent file is not successfully opened/created when required */
96
97
/* modes : r, r+ imply that file MUST exist
123
124
        RWOP_ERR_QUIT(rwops);
124
125
    rwops->close(rwops);
125
126
    unlink(FBASENAME2);
126
 
    printf("test2 OK\n");
 
127
    SDL_Log("test2 OK\n");
127
128
 
128
129
/* test 3 : creation, writing , reading, seeking,
129
130
            test : w mode, r mode, w+ mode
201
202
    if (SDL_memcmp(test_buf, "12345678901234567890", 20))
202
203
        RWOP_ERR_QUIT(rwops);
203
204
    rwops->close(rwops);
204
 
    printf("test3 OK\n");
 
205
    SDL_Log("test3 OK\n");
205
206
 
206
207
/* test 4: same in r+ mode */
207
208
    rwops = SDL_RWFromFile(FBASENAME1, "rb+");  /* write + read + file must exists, no truncation */
236
237
    if (SDL_memcmp(test_buf, "12345678901234567890", 20))
237
238
        RWOP_ERR_QUIT(rwops);
238
239
    rwops->close(rwops);
239
 
    printf("test4 OK\n");
 
240
    SDL_Log("test4 OK\n");
240
241
 
241
242
/* test5 : append mode */
242
243
    rwops = SDL_RWFromFile(FBASENAME1, "ab+");  /* write + read + append */
277
278
    if (SDL_memcmp(test_buf, "123456789012345678901234567123", 30))
278
279
        RWOP_ERR_QUIT(rwops);
279
280
    rwops->close(rwops);
280
 
    printf("test5 OK\n");
 
281
    SDL_Log("test5 OK\n");
281
282
    cleanup();
282
283
    return 0;                   /* all ok */
283
284
}