Skip to content
Myr

vc6 project files for testing stb.h

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Sean Barrett · committed by Sean Barrett · parent d4f114a · Browse files · 5 files+317 added−99 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

5 files+317 added−99 removed

  • tests:+317 added−99 removed

5 files+317 added−99 removed

added:tests/stb_cpp.cpp+83 added
1#define WIN32_MEAN_AND_LEAN2#define WIN32_LEAN_AND_MEAN3//#include <windows.h>4#include <conio.h>5#define STB_STUA6#define STB_DEFINE7#define STB_NPTR8#define STB_ONLY9#include "stb.h"10//#include "stb_file.h"1112int count;13void c(int truth, char *error)14{15 if (!truth) {16 fprintf(stderr, "Test failed: %s\n", error);17 ++count;18 }19}2021char *expects(stb_matcher *m, char *s, int result, int len, char *str)22{23 int res2,len2=0;24 res2 = stb_lex(m, s, &len2);25 c(result == res2 && len == len2, str);26 return s + len;27}2829void test_lex(void)30{31 stb_matcher *m = stb_lex_matcher();32 // tok_en5 .3 20.1 20. .20 .133 char *s = "tok_en5.3 20.1 20. .20.1";3435 stb_lex_item(m, "[a-zA-Z_][a-zA-Z0-9_]*", 1 );36 stb_lex_item(m, "[0-9]*\\.?[0-9]*" , 2 );37 stb_lex_item(m, "[\r\n\t ]+" , 3 );38 stb_lex_item(m, "." , -99 );39 s=expects(m,s,1,7, "stb_lex 1");40 s=expects(m,s,2,2, "stb_lex 2");41 s=expects(m,s,3,1, "stb_lex 3");42 s=expects(m,s,2,4, "stb_lex 4");43 s=expects(m,s,3,1, "stb_lex 5");44 s=expects(m,s,2,3, "stb_lex 6");45 s=expects(m,s,3,1, "stb_lex 7");46 s=expects(m,s,2,3, "stb_lex 8");47 s=expects(m,s,2,2, "stb_lex 9");48 s=expects(m,s,0,0, "stb_lex 10");49 stb_matcher_free(m);50}5152int main(int argc, char **argv)53{54 char *p;55 p = "abcdefghijklmnopqrstuvwxyz";56 c(stb_ischar('c', p), "stb_ischar 1");57 c(stb_ischar('x', p), "stb_ischar 2");58 c(!stb_ischar('#', p), "stb_ischar 3");59 c(!stb_ischar('X', p), "stb_ischar 4");60 p = "0123456789";61 c(!stb_ischar('c', p), "stb_ischar 5");62 c(!stb_ischar('x', p), "stb_ischar 6");63 c(!stb_ischar('#', p), "stb_ischar 7");64 c(!stb_ischar('X', p), "stb_ischar 8");65 p = "#####";66 c(!stb_ischar('c', p), "stb_ischar a");67 c(!stb_ischar('x', p), "stb_ischar b");68 c(stb_ischar('#', p), "stb_ischar c");69 c(!stb_ischar('X', p), "stb_ischar d");70 p = "xXyY";71 c(!stb_ischar('c', p), "stb_ischar e");72 c(stb_ischar('x', p), "stb_ischar f");73 c(!stb_ischar('#', p), "stb_ischar g");74 c(stb_ischar('X', p), "stb_ischar h");7576 test_lex();7778 if (count) {79 _getch();80 }81 return 0;82}83
added:tests/stb_cpp.dsp+88 added
1# Microsoft Developer Studio Project File - Name="stb_cpp" - Package Owner=<4>2# Microsoft Developer Studio Generated Build File, Format Version 6.003# ** DO NOT EDIT **45# TARGTYPE "Win32 (x86) Console Application" 0x010367CFG=stb_cpp - Win32 Debug8!MESSAGE This is not a valid makefile. To build this project using NMAKE,9!MESSAGE use the Export Makefile command and run10!MESSAGE 11!MESSAGE NMAKE /f "stb_cpp.mak".12!MESSAGE 13!MESSAGE You can specify a configuration when running NMAKE14!MESSAGE by defining the macro CFG on the command line. For example:15!MESSAGE 16!MESSAGE NMAKE /f "stb_cpp.mak" CFG="stb_cpp - Win32 Debug"17!MESSAGE 18!MESSAGE Possible choices for configuration are:19!MESSAGE 20!MESSAGE "stb_cpp - Win32 Release" (based on "Win32 (x86) Console Application")21!MESSAGE "stb_cpp - Win32 Debug" (based on "Win32 (x86) Console Application")22!MESSAGE 2324# Begin Project25# PROP AllowPerConfigDependencies 026# PROP Scc_ProjName ""27# PROP Scc_LocalPath ""28CPP=cl.exe29RSC=rc.exe3031!IF "$(CFG)" == "stb_cpp - Win32 Release"3233# PROP BASE Use_MFC 034# PROP BASE Use_Debug_Libraries 035# PROP BASE Output_Dir "Release"36# PROP BASE Intermediate_Dir "Release"37# PROP BASE Target_Dir ""38# PROP Use_MFC 039# PROP Use_Debug_Libraries 040# PROP Output_Dir "Release"41# PROP Intermediate_Dir "Release"42# PROP Target_Dir ""43# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c44# ADD CPP /nologo /W3 /GX /O2 /I ".." /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c45# ADD BASE RSC /l 0x409 /d "NDEBUG"46# ADD RSC /l 0x409 /d "NDEBUG"47BSC32=bscmake.exe48# ADD BASE BSC32 /nologo49# ADD BSC32 /nologo50LINK32=link.exe51# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I38652# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I3865354!ELSEIF "$(CFG)" == "stb_cpp - Win32 Debug"5556# PROP BASE Use_MFC 057# PROP BASE Use_Debug_Libraries 158# PROP BASE Output_Dir "Debug"59# PROP BASE Intermediate_Dir "Debug"60# PROP BASE Target_Dir ""61# PROP Use_MFC 062# PROP Use_Debug_Libraries 163# PROP Output_Dir "Debug"64# PROP Intermediate_Dir "Debug"65# PROP Target_Dir ""66# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c67# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I ".." /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c68# ADD BASE RSC /l 0x409 /d "_DEBUG"69# ADD RSC /l 0x409 /d "_DEBUG"70BSC32=bscmake.exe71# ADD BASE BSC32 /nologo72# ADD BSC32 /nologo73LINK32=link.exe74# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept75# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept7677!ENDIF 7879# Begin Target8081# Name "stb_cpp - Win32 Release"82# Name "stb_cpp - Win32 Debug"83# Begin Source File8485SOURCE=.\stb_cpp.cpp86# End Source File87# End Target88# End Project
modified:tests/stb.c+10 added-99 removed
17 unmodified lines
18#ifdef _DEBUG19#define STB_MALLOC_WRAPPER_DEBUG20#endif21#define STB_NPTR22#define STB_DEFINE23#include "stb.h"23#include "stb_file.h"24#include "stb_pixel32.h"24//#include "stb_file.h"25//#include "stb_pixel32.h"2627//#define DEBUG_BLOCK28#ifdef DEBUG_BLOCK29#include <conio.h>
520 unmodified lines
550 }551 }552}553553#define BN 800554unsigned int bloc[BN];555char *data[BN];556int dlen[BN];557558int bcheck(stb_blockfile *b, int n)559{560 char temp[2048];561 if (!stb_blockfile_read(b, temp, bloc[n], dlen[n])) {562 c(0, "blockfile_test read error");563 bloc[n] = 0;564 return 0;565 }566 if (memcmp(temp, data[n], dlen[n])) {567 c(0, "blockfile_test read");568 bloc[n] = 0;569 return 0;570 }571 return 1;572}573574void blockfile_test(void)575{576 int inuse=0, max_inuse=0;577 int i,j,freespace=0;578 int z;579 stb_blockfile *b;580 int o[BN];581582 b = stb_blockfile_open("btest.bin", 1);583584 for (i=0; i < BN; ++i) {585 bloc[i] = 0;586 dlen[i] = stb_rand() % 500 + 50;587 data[i] = malloc(1024);588 for (j=0; j < dlen[i]; ++j)589 data[i][j] = (char) stb_rand();590 }591592 for(z=0; z < 50; ++z) {593 if (z % 4 == 3) {594 //if (!b->dirty_flag) stb__dirty(b);595 stb_blockfile_close(b);596 b = stb_blockfile_open("btest.bin", 0);597 //if (!b->dirty_flag) stb__dirty(b);598 }599 for (i=0; i < BN; ++i) o[i] = i;600 stb_shuffle(o, BN, sizeof(o[0]), stb_rand());601 for (i=0; i < BN; ++i) {602 int n = o[i];603 if (bloc[n] > 0) {604 // first check it605 if (!bcheck(b,n)) continue;606 if (stb_rand() % 100 > 75) {607 stb_blockfile_free(b, bloc[n], dlen[n]);608 bloc[n] = 0;609 inuse -= dlen[n];610 } else if (stb_rand() % 100 > 75) {611 int olen = dlen[n];612 dlen[n] = stb_rand() % 500 + 50;613 for (j=0; j < dlen[n]; ++j)614 data[n][j] = (char) stb_rand();615 bloc[n] = stb_blockfile_rewrite(b, data[n], dlen[n], bloc[n], olen);616 inuse = inuse + dlen[n] - olen;617 }618 } else {619 if (stb_rand() % 100 > 40) {620 bloc[n] = stb_blockfile_write(b, data[n], dlen[n]);621 assert(bloc[n]);622 inuse += dlen[n];623 }624 }625 if (inuse > max_inuse) max_inuse = inuse;626 }627 #ifdef DEBUG_BLOCK628 printf("Pass %d\n", z+1);629 stb_block_compact_freelist(b->manager);630 qsort(b->manager->freelist, b->manager->len, 8, stb__freelist_compare);631 for (i=0; i < b->manager->len; ++i)632 printf("%9d %9d\n", b->manager->freelist[i].start, b->manager->freelist[i].len);633 _getch();634 #endif635 }636637 freespace = 0;638 for (i=0; i < b->manager->len; ++i)639 freespace += b->manager->freelist[i].len;640641 printf("Max data: %d; Inuse: %d; freespace: %d (%d)\n", max_inuse, inuse, freespace, b->manager->len);642 stb_blockfile_close(b);643644 for (i=0; i < BN; ++i)645 free(data[i]);646}647554extern void stu_uninit(void);555556stb_define_sort(sort_int, int, *a < *b)557
24 unmodified lines
582 char *wildcards[] = { "*foo*", "*bar", "baz", "*1*2*3*", "*/CVS/repository", "*oof*" };583 char **s;584 char buf[256], *p;585 int n,len2,*q,i;680 stb_mml *m;586 stb_matcher *mt=NULL;587588 if (argc > 1) {589 do_compressor(argc,argv);
78 unmodified lines
668 bst_test();669670 c(stb_alloc_count_alloc == stb_alloc_count_free, "stb_alloc 0");671672#if 0673 // stb_block674 {675 int inuse=0, freespace=0;676 int *x = malloc(10000*sizeof(*x));
63 unmodified lines
740 free(l);741 free(x);742 }743838// blockfile_test();744 blockfile_test();745#endif746747 mt = stb_lex_matcher();748 for (i=0; i < 5; ++i)749 stb_lex_item_wild(mt, wildcards[i], i+1);
267 unmodified lines
1017 s = stb_getopt_param(&n, args, "s");1018 c(s == NULL && n == 0 , "stb_getopt 5");1019 stb_getopt_free(s);10201021#if 01022 c(*stb_csample_int(sample_test[0], 1, 5, 5, 3, -1, -1) == 1, "stb_csample_int 1");1023 c(*stb_csample_int(sample_test[0], 1, 5, 5, 3, 1, -3) == 2, "stb_csample_int 2");1024 c(*stb_csample_int(sample_test[0], 1, 5, 5, 3, 12, -2) == 5, "stb_csample_int 3");1025 c(*stb_csample_int(sample_test[0], 1, 5, 5, 3, 15, 1) == 10, "stb_csample_int 4");
1 unmodified line
1027 c(*stb_csample_int(sample_test[0], 1, 5, 5, 3, 3, 3) == 14, "stb_csample_int 6");1028 c(*stb_csample_int(sample_test[0], 1, 5, 5, 3, -2, 5) == 11, "stb_csample_int 7");1029 c(*stb_csample_int(sample_test[0], 1, 5, 5, 3, -7, 0) == 1, "stb_csample_int 8");1030 c(*stb_csample_int(sample_test[0], 1, 5, 5, 3, 2, 1) == 8, "stb_csample_int 9");1031#endif10321033 c(!strcmp(stb_splitpath(buf, p1, STB_PATH ), "foo/bar\\baz/"), "stb_splitpath 1");1034 c(!strcmp(stb_splitpath(buf, p1, STB_FILE ), "test"), "stb_splitpath 2");1035 c(!strcmp(stb_splitpath(buf, p1, STB_EXT ), ".xyz"), "stb_splitpath 3");
21 unmodified lines
1057 c(!strcmp(p=stb_dupreplace("testfootffooo foo fox", "foo", "" ), "testtfo fox" ), "stb_dupreplace 2"); free(p);1058 c(!strcmp(p=stb_dupreplace("abacab", "a", "aba"), "abababacabab" ), "stb_dupreplace 3"); free(p);105910601061#if 01062 m = stb_mml_parse("<a><b><c>x</c><d>y</d></b><e>&lt;&amp;f&gt;</e></a>");1063 c(m != NULL, "stb_mml_parse 1");1064 if (m) {1065 c(!strcmp(m->child[0]->child[0]->child[1]->tag, "d"), "stb_mml_parse 2");
4 unmodified lines
1070 c(stb_alloc_count_alloc == stb_alloc_count_free, "stb_alloc 1");1071 if (stb_alloc_count_alloc != stb_alloc_count_free) {1072 printf("%d allocs, %d frees\n", stb_alloc_count_alloc, stb_alloc_count_free);1073 }1074#endif10751076 c(stb_linear_remap(3.0f,0,8,1,2) == 1.375, "stb_linear_remap()");10771078 c(stb_bitreverse(0x1248fec8) == 0x137f1248, "stb_bitreverse() 1");
2236 unmodified lines
added:tests/stb.dsp+92 added
1# Microsoft Developer Studio Project File - Name="stb" - Package Owner=<4>2# Microsoft Developer Studio Generated Build File, Format Version 6.003# ** DO NOT EDIT **45# TARGTYPE "Win32 (x86) Console Application" 0x010367CFG=stb - Win32 Debug8!MESSAGE This is not a valid makefile. To build this project using NMAKE,9!MESSAGE use the Export Makefile command and run10!MESSAGE 11!MESSAGE NMAKE /f "stb.mak".12!MESSAGE 13!MESSAGE You can specify a configuration when running NMAKE14!MESSAGE by defining the macro CFG on the command line. For example:15!MESSAGE 16!MESSAGE NMAKE /f "stb.mak" CFG="stb - Win32 Debug"17!MESSAGE 18!MESSAGE Possible choices for configuration are:19!MESSAGE 20!MESSAGE "stb - Win32 Release" (based on "Win32 (x86) Console Application")21!MESSAGE "stb - Win32 Debug" (based on "Win32 (x86) Console Application")22!MESSAGE 2324# Begin Project25# PROP AllowPerConfigDependencies 026# PROP Scc_ProjName ""27# PROP Scc_LocalPath ""28CPP=cl.exe29RSC=rc.exe3031!IF "$(CFG)" == "stb - Win32 Release"3233# PROP BASE Use_MFC 034# PROP BASE Use_Debug_Libraries 035# PROP BASE Output_Dir "Release"36# PROP BASE Intermediate_Dir "Release"37# PROP BASE Target_Dir ""38# PROP Use_MFC 039# PROP Use_Debug_Libraries 040# PROP Output_Dir "Release"41# PROP Intermediate_Dir "Release"42# PROP Ignore_Export_Lib 043# PROP Target_Dir ""44# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c45# ADD CPP /nologo /G6 /MT /W3 /GX /Z7 /O2 /Ob2 /I ".." /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /FD /c46# ADD BASE RSC /l 0x409 /d "NDEBUG"47# ADD RSC /l 0x409 /d "NDEBUG"48BSC32=bscmake.exe49# ADD BASE BSC32 /nologo50# ADD BSC32 /nologo51LINK32=link.exe52# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I38653# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I3865455!ELSEIF "$(CFG)" == "stb - Win32 Debug"5657# PROP BASE Use_MFC 058# PROP BASE Use_Debug_Libraries 159# PROP BASE Output_Dir "Debug"60# PROP BASE Intermediate_Dir "Debug"61# PROP BASE Target_Dir ""62# PROP Use_MFC 063# PROP Use_Debug_Libraries 164# PROP Output_Dir "Debug"65# PROP Intermediate_Dir "Debug"66# PROP Ignore_Export_Lib 067# PROP Target_Dir ""68# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c69# ADD CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /I ".." /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FR /FD /GZ /c70# SUBTRACT CPP /YX71# ADD BASE RSC /l 0x409 /d "_DEBUG"72# ADD RSC /l 0x409 /d "_DEBUG"73BSC32=bscmake.exe74# ADD BASE BSC32 /nologo75# ADD BSC32 /nologo76LINK32=link.exe77# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept78# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /incremental:no /debug /machine:I386 /pdbtype:sept79# SUBTRACT LINK32 /force8081!ENDIF 8283# Begin Target8485# Name "stb - Win32 Release"86# Name "stb - Win32 Debug"87# Begin Source File8889SOURCE=.\stb.c90# End Source File91# End Target92# End Project
added:tests/stb.dsw+44 added
1Microsoft Developer Studio Workspace File, Format Version 6.002# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!34###############################################################################56Project: "stb"=.\stb.dsp - Package Owner=<4>78Package=<5>9{{{10}}}1112Package=<4>13{{{14 Begin Project Dependency15 Project_Dep_Name stb_cpp16 End Project Dependency17}}}1819###############################################################################2021Project: "stb_cpp"=.\stb_cpp.dsp - Package Owner=<4>2223Package=<5>24{{{25}}}2627Package=<4>28{{{29}}}3031###############################################################################3233Global:3435Package=<5>36{{{37}}}3839Package=<3>40{{{41}}}4243###############################################################################44