test/testiconv.c
branchSDL-1.2
changeset 3997 6a4f3a32c2e6
parent 1528 ff3322d66771
equal deleted inserted replaced
3996:5f463dddee36 3997:6a4f3a32c2e6
    51 		ucs4 = SDL_iconv_string("UCS-4", "UTF-8", buffer, SDL_strlen(buffer)+1);
    51 		ucs4 = SDL_iconv_string("UCS-4", "UTF-8", buffer, SDL_strlen(buffer)+1);
    52 		len = (widelen(ucs4)+1)*4;
    52 		len = (widelen(ucs4)+1)*4;
    53 		for ( i = 0; i < SDL_arraysize(formats); ++i ) {
    53 		for ( i = 0; i < SDL_arraysize(formats); ++i ) {
    54 			test[0] = SDL_iconv_string(formats[i], "UCS-4", ucs4, len);
    54 			test[0] = SDL_iconv_string(formats[i], "UCS-4", ucs4, len);
    55 			test[1] = SDL_iconv_string("UCS-4", formats[i], test[0], len);
    55 			test[1] = SDL_iconv_string("UCS-4", formats[i], test[0], len);
    56 			if ( SDL_memcmp(test[1], ucs4, len) != 0 ) {
    56 			if ( !test[1] || SDL_memcmp(test[1], ucs4, len) != 0 ) {
    57 				fprintf(stderr, "FAIL: %s\n", formats[i]);
    57 				fprintf(stderr, "FAIL: %s\n", formats[i]);
    58 				++errors;
    58 				++errors;
    59 			}
    59 			}
    60 			SDL_free(test[0]);
    60 			if ( test[0] ) {
    61 			SDL_free(test[1]);
    61 				SDL_free(test[0]);
       
    62 			}
       
    63 			if ( test[1] ) {
       
    64 				SDL_free(test[1]);
       
    65 			}
    62 		}
    66 		}
    63 		test[0] = SDL_iconv_string("UTF-8", "UCS-4", ucs4, len);
    67 		test[0] = SDL_iconv_string("UTF-8", "UCS-4", ucs4, len);
    64 		SDL_free(ucs4);
    68 		SDL_free(ucs4);
    65 		fputs(test[0], stdout);
    69 		fputs(test[0], stdout);
    66 		SDL_free(test[0]);
    70 		SDL_free(test[0]);