tests: 64-bit fixes, fix typo in image tests

This commit is contained in:
Sean Barrett 2019-02-07 04:42:32 -08:00
parent 27460c23a6
commit a28a6b126b
3 changed files with 16 additions and 10 deletions

View File

@ -84,7 +84,7 @@ int main(int argc, char **argv)
int w2,h2,n2; int w2,h2,n2;
unsigned char *data; unsigned char *data;
printf("%s\n", argv[i]); printf("%s\n", argv[i]);
res = stbi_info(argv[1], &w2, &h2, &n2); res = stbi_info(argv[i], &w2, &h2, &n2);
data = stbi_load(argv[i], &w, &h, &n, 4); if (data) free(data); else printf("Failed &n\n"); data = stbi_load(argv[i], &w, &h, &n, 4); if (data) free(data); else printf("Failed &n\n");
data = stbi_load(argv[i], &w, &h, 0, 1); if (data) free(data); else printf("Failed 1\n"); data = stbi_load(argv[i], &w, &h, 0, 1); if (data) free(data); else printf("Failed 1\n");
data = stbi_load(argv[i], &w, &h, 0, 2); if (data) free(data); else printf("Failed 2\n"); data = stbi_load(argv[i], &w, &h, 0, 2); if (data) free(data); else printf("Failed 2\n");

View File

@ -13,12 +13,13 @@
#include <crtdbg.h> #include <crtdbg.h>
#endif #endif
#define STB_STUA
//#define STB_FASTMALLOC //#define STB_FASTMALLOC
#ifdef _DEBUG #ifdef _DEBUG
#define STB_MALLOC_WRAPPER_DEBUG #define STB_MALLOC_WRAPPER_DEBUG
#endif #endif
#ifndef _M_AMD64
#define STB_NPTR #define STB_NPTR
#endif
#define STB_DEFINE #define STB_DEFINE
#include "stb.h" #include "stb.h"
@ -119,7 +120,7 @@ void test_classes(void)
return; return;
} }
#ifdef STB_STUA
void test_script(void) void test_script(void)
{ {
stua_run_script( stua_run_script(
@ -193,6 +194,7 @@ void test_script(void)
" // final comment with no newline" " // final comment with no newline"
); );
} }
#endif
#ifdef STB_THREADS #ifdef STB_THREADS
extern void __stdcall Sleep(unsigned long); extern void __stdcall Sleep(unsigned long);
@ -2254,11 +2256,13 @@ void test_packed_floats(void)
void do_compressor(int argc,char**argv) void do_compressor(int argc,char**argv)
{ {
char *p; char *p;
size_t slen;
int len; int len;
int window; int window;
if (argc == 2) { if (argc == 2) {
p = stb_file(argv[1], &len); p = stb_file(argv[1], &slen);
len = (int) slen;
if (p) { if (p) {
int dlen, clen = stb_compress_tofile("data/dummy.bin", p, len); int dlen, clen = stb_compress_tofile("data/dummy.bin", p, len);
char *q = stb_decompress_fromfile("data/dummy.bin", &dlen); char *q = stb_decompress_fromfile("data/dummy.bin", &dlen);
@ -2278,7 +2282,8 @@ void do_compressor(int argc,char**argv)
window = atoi(argv[1]); window = atoi(argv[1]);
if (window && argc == 4) { if (window && argc == 4) {
p = stb_file(argv[3], &len); p = stb_file(argv[3], &slen);
len = (int) slen;
if (p) { if (p) {
stb_compress_hashsize(window); stb_compress_hashsize(window);
stb_compress_tofile(argv[2], p, len); stb_compress_tofile(argv[2], p, len);
@ -2506,10 +2511,10 @@ void first_for_prod_plus_sym(stb_bitset **first, stb_bitset *out, short *prod, i
stb_bitset_unioneq_changed(out, first[symbol], symset); stb_bitset_unioneq_changed(out, first[symbol], symset);
} }
#define Item(p,c,t) ((void *) (((t) << 18) + ((c) << 12) + ((p) << 2))) #define Item(p,c,t) ((void *) (size_t) (((t) << 18) + ((c) << 12) + ((p) << 2)))
#define ItemProd(i) ((((uint32) (i)) >> 2) & 1023) #define ItemProd(i) ((((uint32) (size_t) (i)) >> 2) & 1023)
#define ItemCursor(i) ((((uint32) (i)) >> 12) & 63) #define ItemCursor(i) ((((uint32) (size_t) (i)) >> 12) & 63)
#define ItemLookahead(i) (((uint32) (i)) >> 18) #define ItemLookahead(i) (((uint32) (size_t) (i)) >> 18)
static void pc(stb_ps *p) static void pc(stb_ps *p)
{ {

View File

@ -2,9 +2,10 @@
#define WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN
//#include <windows.h> //#include <windows.h>
#include <conio.h> #include <conio.h>
#define STB_STUA
#define STB_DEFINE #define STB_DEFINE
#ifndef _M_AMD64
#define STB_NPTR #define STB_NPTR
#endif
#define STB_ONLY #define STB_ONLY
#include "stb.h" #include "stb.h"
//#include "stb_file.h" //#include "stb_file.h"