GnuCash 2.4.99
test-stuff.h
00001 /* Modified by bstanley 20010320
00002  * Added do_test macro, do_test_call and do_test_call_args,
00003  * print_test_results, set_success_print.
00004  *
00005  * Modified by bstanley 20010323
00006  * removed testing functionality which depends on the rest of gnucash -
00007  * separated into gnc-test-stuff.h
00008  *
00009  */
00010 
00011 /* Outline of a test program using the new testing functions:
00012 #include "test-stuff.h"
00013 int main( int argc, char* argv[] )
00014 {
00015         int a, b;
00016         g_log_set_always_fatal( G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_WARNING );
00017         a = b = 1;
00018         do_test( a == b, "integer equality" );
00019         do_test( a != b, "integer inequality? (should fail)" );
00020 
00021         do_test_args( a == b, "fancy info", __FILE__, __LINE__, "a = %d, b = %b", a, b );
00022 
00023         print_test_results();
00024         return get_rv();
00025 }
00026 */
00027 /* If you want to see test passes, use
00028 set_success_print(TRUE);
00029 before you execute the tests.
00030 Otherwise, only failures are printed out.
00031 */
00032 
00033 
00034 #ifndef TEST_STUFF_H
00035 #define TEST_STUFF_H
00036 
00037 #include <glib.h>
00038 #include <stdlib.h>
00039 
00046 #define do_test( result, title ) do_test_call( result, title, __FILE__, __LINE__ )
00047 #define success( title ) success_call( title, __FILE__, __LINE__ );
00048 #define failure( title ) failure_call( title, __FILE__, __LINE__ );
00049 
00057 /* Privately used to indicate a test result. You may use these if you
00058  * wish, but it's easier to use the do_test macro above.
00059  */
00060 gboolean do_test_call(
00061     gboolean result,
00062     const char* test_title,
00063     const char* filename,
00064     int line );
00065 gboolean do_test_args(
00066     gboolean result,
00067     const char* test_title,
00068     const char* filename,
00069     int line,
00070     const char* format, ... );
00071 
00072 
00076 void print_test_results(void);
00077 
00087 void set_success_print( gboolean in_should_print );
00088 
00089 /* Value to return from main. Set to 1 if there were any fails, 0 otherwise. */
00090 int get_rv(void);
00091 
00096 void success_call(
00097     const char *test_title,
00098     const char *file,
00099     int line );
00100 
00101 void success_args(
00102     const char *test_title,
00103     const char *file,
00104     int line,
00105     const char *format,
00106     ... );
00107 
00108 void failure_call(
00109     const char *test_title,
00110     const char *file,
00111     int line);
00112 
00113 void failure_args(
00114     const char *test_title,
00115     const char *file,
00116     int line,
00117     const char *format,
00118     ... );
00119 
00120 gboolean get_random_boolean(void);
00121 gint get_random_int_in_range(int start, int end);
00122 void random_character_include_funky_chars (gboolean use_funky_chars);
00123 gchar get_random_character(void);
00124 gchar* get_random_string(void);
00125 gchar * get_random_string_length_in_range(int minlen, int maxlen);
00126 gchar* get_random_string_without(const char *exclude_chars);
00127 gint64 get_random_gint64(void);
00128 double get_random_double(void);
00129 const char* get_random_string_in_array(const char* str_list[]);
00130 
00131 
00132 #endif /* TEST_STUFF_H */
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines