Mercurial > sdl-ios-xcode
annotate test/automated/SDL_at.h @ 3741:808fad5fb593 gsoc2009_unit_tests
Added command line options.
Added verbosity levels.
author | Edgar Simo <bobbens@gmail.com> |
---|---|
date | Sun, 02 Aug 2009 18:58:03 +0000 |
parents | 6eca2af6a86b |
children | 9428ae743878 |
rev | line source |
---|---|
3711
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1 /* |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
2 * Common code for automated test suite. |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
3 * |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
4 * Written by Edgar Simo "bobbens" |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
5 * |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
6 * Released under Public Domain. |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
7 */ |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
8 |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
9 |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
10 /** |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
11 * @file SDL_at.h |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
12 * |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
13 * @brief Handles automatic testing functionality. |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
14 * |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
15 * You create a testsuite and then run multiple testcases within that suite. |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
16 * Syntax is similar to OpenGL. An example would be: |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
17 * |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
18 * @code |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
19 * int f; |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
20 * SDL_ATinit( "My testsuite" ); |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
21 * |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
22 * SDL_ATbegin( "My first testcase" ); |
3725
6eca2af6a86b
Added SDL_ATvassert for printf style printing.
Edgar Simo <bobbens@gmail.com>
parents:
3715
diff
changeset
|
23 * if (!SDL_ATassert( (1+1)==2, "Trying '1+1=2'.")) |
3715
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
3711
diff
changeset
|
24 * return; |
3711
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
25 * |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
26 * SDL_ATbegin( "My second testcase" ); |
3725
6eca2af6a86b
Added SDL_ATvassert for printf style printing.
Edgar Simo <bobbens@gmail.com>
parents:
3715
diff
changeset
|
27 * if (!SDL_ATassert( (4/2)==2, "Trying '4/2=2'.")) |
3715
3c9d9c052c8f
Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
3711
diff
changeset
|
28 * return; |
3711
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
29 * |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
30 * f = SDL_ATend(); |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
31 * @endcode |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
32 * |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
33 * @author Edgar Simo "bobbens" |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
34 */ |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
35 |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
36 |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
37 #ifndef _SDL_AT_H |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
38 # define _SDL_AT_H |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
39 |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
40 |
3741
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3725
diff
changeset
|
41 |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3725
diff
changeset
|
42 enum { |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3725
diff
changeset
|
43 SDL_AT_VERBOSE, |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3725
diff
changeset
|
44 SDL_AT_QUIET |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3725
diff
changeset
|
45 }; |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3725
diff
changeset
|
46 |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3725
diff
changeset
|
47 |
3711
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
48 /* |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
49 * Suite level actions. |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
50 */ |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
51 /** |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
52 * @brief Starts the testsuite. |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
53 * |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
54 * @param suite Name of the suite to start testing. |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
55 */ |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
56 void SDL_ATinit( const char *suite ); |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
57 /** |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
58 * @brief Finishes the testsuite printing out global results if verbose. |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
59 * |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
60 * @param verbose Displays global results. |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
61 */ |
3741
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3725
diff
changeset
|
62 int SDL_ATfinish (void); |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3725
diff
changeset
|
63 /** |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3725
diff
changeset
|
64 * @brief Sets a global property value. |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3725
diff
changeset
|
65 * |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3725
diff
changeset
|
66 * @param property Property to set. |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3725
diff
changeset
|
67 * @param value Value to set property to. |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3725
diff
changeset
|
68 */ |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3725
diff
changeset
|
69 void SDL_ATseti( int property, int value ); |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3725
diff
changeset
|
70 /** |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3725
diff
changeset
|
71 * @brief Gets a global property value. |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3725
diff
changeset
|
72 * |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3725
diff
changeset
|
73 * @param property Property to get. |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3725
diff
changeset
|
74 * @param[out] value Value of the property. |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3725
diff
changeset
|
75 */ |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3725
diff
changeset
|
76 void SDL_ATgeti( int property, int *value ); |
3711
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
77 |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
78 |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
79 /* |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
80 * Testcase level actions. |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
81 */ |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
82 /** |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
83 * @brief Begins a testcase. |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
84 * |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
85 * @param testcase Name of the testcase to begin. |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
86 */ |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
87 void SDL_ATbegin( const char *testcase ); |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
88 /** |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
89 * @brief Checks a condition in the testcase. |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
90 * |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
91 * Will automatically call SDL_ATend if the condition isn't met. |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
92 * |
3725
6eca2af6a86b
Added SDL_ATvassert for printf style printing.
Edgar Simo <bobbens@gmail.com>
parents:
3715
diff
changeset
|
93 * @param condition Condition to make sure is true. |
3711
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
94 * @param msg Message to display for failure. |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
95 * @return Returns 1 if the condition isn't met. |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
96 */ |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
97 int SDL_ATassert( const char *msg, int condition ); |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
98 /** |
3725
6eca2af6a86b
Added SDL_ATvassert for printf style printing.
Edgar Simo <bobbens@gmail.com>
parents:
3715
diff
changeset
|
99 * @brief Checks a condition in the testcase. |
6eca2af6a86b
Added SDL_ATvassert for printf style printing.
Edgar Simo <bobbens@gmail.com>
parents:
3715
diff
changeset
|
100 * |
6eca2af6a86b
Added SDL_ATvassert for printf style printing.
Edgar Simo <bobbens@gmail.com>
parents:
3715
diff
changeset
|
101 * Will automatically call SDL_ATend if the condition isn't met. |
6eca2af6a86b
Added SDL_ATvassert for printf style printing.
Edgar Simo <bobbens@gmail.com>
parents:
3715
diff
changeset
|
102 * |
6eca2af6a86b
Added SDL_ATvassert for printf style printing.
Edgar Simo <bobbens@gmail.com>
parents:
3715
diff
changeset
|
103 * @param condition Condition to make sure is true. |
6eca2af6a86b
Added SDL_ATvassert for printf style printing.
Edgar Simo <bobbens@gmail.com>
parents:
3715
diff
changeset
|
104 * @param msg Message to display for failure with printf style formatting. |
6eca2af6a86b
Added SDL_ATvassert for printf style printing.
Edgar Simo <bobbens@gmail.com>
parents:
3715
diff
changeset
|
105 * @return Returns 1 if the condition isn't met. |
6eca2af6a86b
Added SDL_ATvassert for printf style printing.
Edgar Simo <bobbens@gmail.com>
parents:
3715
diff
changeset
|
106 */ |
6eca2af6a86b
Added SDL_ATvassert for printf style printing.
Edgar Simo <bobbens@gmail.com>
parents:
3715
diff
changeset
|
107 int SDL_ATvassert( int condition, const char *msg, ... ); |
6eca2af6a86b
Added SDL_ATvassert for printf style printing.
Edgar Simo <bobbens@gmail.com>
parents:
3715
diff
changeset
|
108 /** |
3711
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
109 * @brief Ends a testcase. |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
110 */ |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
111 void SDL_ATend (void); |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
112 |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
113 |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
114 /* |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
115 * Misc functions. |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
116 */ |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
117 /** |
3741
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3725
diff
changeset
|
118 * @brief Prints an error. |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3725
diff
changeset
|
119 * |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3725
diff
changeset
|
120 * @param msg printf formatted string to display. |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3725
diff
changeset
|
121 * @return Number of character printed. |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3725
diff
changeset
|
122 */ |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3725
diff
changeset
|
123 int SDL_ATprintErr( const char *msg, ... ); |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3725
diff
changeset
|
124 /** |
3711
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
125 * @brief Prints some text. |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
126 * |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
127 * @param msg printf formatted string to display. |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
128 * @return Number of character printed. |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
129 */ |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
130 int SDL_ATprint( const char *msg, ... ); |
3741
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3725
diff
changeset
|
131 /** |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3725
diff
changeset
|
132 * @brief Prints some verbose text. |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3725
diff
changeset
|
133 * |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3725
diff
changeset
|
134 * @param level Level of verbosity to print at. |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3725
diff
changeset
|
135 * @param msg printf formatted string to display. |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3725
diff
changeset
|
136 * @return Number of character printed. |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3725
diff
changeset
|
137 */ |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3725
diff
changeset
|
138 int SDL_ATprintVerbose( int level, const char *msg, ... ); |
3711
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
139 |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
140 |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
141 #endif /* _SDL_AT_H */ |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
142 |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
143 |