Skip to content
Myr

stb_cpp.cpp

This file

Path

tests/stb_cpp.cpp

83 lines · 2.2 KiB · C++

Last changed by

Merge branch 'master' into workingSean Barrettbefore adoptiond940053

History of this file

Take it

The walk stopped after 200 commits: lines older than 94374c9 point at it.

Merge branch 'master' of https://github.com/nothings/stbSean Barrettbefore adoption94374c9

lines 1–5why, one step back
1#define WIN32_MEAN_AND_LEAN
2#define WIN32_LEAN_AND_MEAN3//#include <windows.h>4#include <conio.h>5#define STB_DEFINE

tests: 64-bit fixes, fix typo in image testsSean Barrettbefore adoptiona28a6b1

line 6why, one step back
6#ifndef _M_AMD64

Merge branch 'master' of https://github.com/nothings/stbSean Barrettbefore adoption94374c9

line 7why, one step back
7#define STB_NPTR

tests: 64-bit fixes, fix typo in image testsSean Barrettbefore adoptiona28a6b1

line 8why, one step back
8#endif

Merge branch 'master' of https://github.com/nothings/stbSean Barrettbefore adoption94374c9

lines 9–13why, one step back
9#define STB_ONLY
10#include "stb.h"11//#include "stb_file.h"1213int count;

Merge branch 'master' into workingSean Barrettbefore adoptiond940053

line 14why, one step back
14void c(int truth, const char *error)

Merge branch 'master' of https://github.com/nothings/stbSean Barrettbefore adoption94374c9

lines 15–21why, one step back
15{
16 if (!truth) {17 fprintf(stderr, "Test failed: %s\n", error);18 ++count;19 }20}21

Merge branch 'master' into workingSean Barrettbefore adoptiond940053

line 22why, one step back
22char *expects(stb_matcher *m, char *s, int result, int len, const char *str)

Merge branch 'master' of https://github.com/nothings/stbSean Barrettbefore adoption94374c9

lines 23–33why, one step back
23{
24 int res2,len2=0;25 res2 = stb_lex(m, s, &len2);26 c(result == res2 && len == len2, str);27 return s + len;28}2930void test_lex(void)31{32 stb_matcher *m = stb_lex_matcher();33 // tok_en5 .3 20.1 20. .20 .1

Merge branch 'master' into workingSean Barrettbefore adoptiond940053

line 34why, one step back
34 char *s = (char*) "tok_en5.3 20.1 20. .20.1";

Merge branch 'master' of https://github.com/nothings/stbSean Barrettbefore adoption94374c9

lines 35–55why, one step back
35
36 stb_lex_item(m, "[a-zA-Z_][a-zA-Z0-9_]*", 1 );37 stb_lex_item(m, "[0-9]*\\.?[0-9]*" , 2 );38 stb_lex_item(m, "[\r\n\t ]+" , 3 );39 stb_lex_item(m, "." , -99 );40 s=expects(m,s,1,7, "stb_lex 1");41 s=expects(m,s,2,2, "stb_lex 2");42 s=expects(m,s,3,1, "stb_lex 3");43 s=expects(m,s,2,4, "stb_lex 4");44 s=expects(m,s,3,1, "stb_lex 5");45 s=expects(m,s,2,3, "stb_lex 6");46 s=expects(m,s,3,1, "stb_lex 7");47 s=expects(m,s,2,3, "stb_lex 8");48 s=expects(m,s,2,2, "stb_lex 9");49 s=expects(m,s,0,0, "stb_lex 10");50 stb_matcher_free(m);51}5253int main(int argc, char **argv)54{55 char *p;

Merge branch 'master' into workingSean Barrettbefore adoptiond940053

line 56why, one step back
56 p = (char*) "abcdefghijklmnopqrstuvwxyz";

Merge branch 'master' of https://github.com/nothings/stbSean Barrettbefore adoption94374c9

lines 57–60why, one step back
57 c(stb_ischar('c', p), "stb_ischar 1");
58 c(stb_ischar('x', p), "stb_ischar 2");59 c(!stb_ischar('#', p), "stb_ischar 3");60 c(!stb_ischar('X', p), "stb_ischar 4");

Merge branch 'master' into workingSean Barrettbefore adoptiond940053

line 61why, one step back
61 p = (char*) "0123456789";

Merge branch 'master' of https://github.com/nothings/stbSean Barrettbefore adoption94374c9

lines 62–65why, one step back
62 c(!stb_ischar('c', p), "stb_ischar 5");
63 c(!stb_ischar('x', p), "stb_ischar 6");64 c(!stb_ischar('#', p), "stb_ischar 7");65 c(!stb_ischar('X', p), "stb_ischar 8");

Merge branch 'master' into workingSean Barrettbefore adoptiond940053

line 66why, one step back
66 p = (char*) "#####";

Merge branch 'master' of https://github.com/nothings/stbSean Barrettbefore adoption94374c9

lines 67–70why, one step back
67 c(!stb_ischar('c', p), "stb_ischar a");
68 c(!stb_ischar('x', p), "stb_ischar b");69 c(stb_ischar('#', p), "stb_ischar c");70 c(!stb_ischar('X', p), "stb_ischar d");

Merge branch 'master' into workingSean Barrettbefore adoptiond940053

line 71why, one step back
71 p = (char*) "xXyY";

Merge branch 'master' of https://github.com/nothings/stbSean Barrettbefore adoption94374c9

lines 72–83why, one step back
72 c(!stb_ischar('c', p), "stb_ischar e");
73 c(stb_ischar('x', p), "stb_ischar f");74 c(!stb_ischar('#', p), "stb_ischar g");75 c(stb_ischar('X', p), "stb_ischar h");7677 test_lex();7879 if (count) {80 _getch();81 }82 return 0;83}