test.c 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288
  1. /*
  2. * Copyright (C) 2009 Mamadou Diop.
  3. *
  4. * Contact: Mamadou Diop <diopmamadou(at)doubango.org>
  5. *
  6. * This file is part of Open Source Doubango Framework.
  7. *
  8. * DOUBANGO is free software: you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation, either version 3 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * DOUBANGO is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with DOUBANGO.
  20. *
  21. */
  22. #include "stdafx.h"
  23. #include <string.h>
  24. #include <stdlib.h>
  25. #include <assert.h>
  26. #include "tsk.h"
  27. #if defined(WIN32) || defined(_WIN32) || defined(_WIN32_WCE)
  28. # define strdup _strdup
  29. #endif
  30. #define LOOP 1
  31. #define RUN_TEST_ALL 0
  32. #define RUN_TEST_LISTS 1
  33. #define RUN_TEST_HEAP 0
  34. #define RUN_TEST_STRINGS 0
  35. #define RUN_TEST_URL 0
  36. #define RUN_TEST_THREADS 0
  37. #define RUN_TEST_MUTEX 0
  38. #define RUN_TEST_CONDWAIT 0
  39. #define RUN_TEST_SEMAPHORE 0
  40. #define RUN_TEST_SAFEOBJECT 0
  41. #define RUN_TEST_OBJECT 0
  42. #define RUN_TEST_PARAMS 0
  43. #define RUN_TEST_OPTIONS 0
  44. #define RUN_TEST_TIMER 0
  45. #define RUN_TEST_RUNNABLE 0
  46. #define RUN_TEST_BUFFER 0
  47. #define RUN_TEST_MD5 0
  48. #define RUN_TEST_SHA1 0
  49. #define RUN_TEST_BASE64 0
  50. #define RUN_TEST_UUID 0
  51. #define RUN_TEST_FSM 0
  52. #if RUN_TEST_LISTS || RUN_TEST_ALL
  53. #include "test_lists.h"
  54. #endif
  55. #if RUN_TEST_HEAP || RUN_TEST_ALL
  56. #include "test_heap.h"
  57. #endif
  58. #if RUN_TEST_STRINGS || RUN_TEST_ALL
  59. #include "test_strings.h"
  60. #endif
  61. #if RUN_TEST_URL || RUN_TEST_ALL
  62. #include "test_url.h"
  63. #endif
  64. #if RUN_TEST_THREADS || RUN_TEST_ALL
  65. #include "test_threads.h"
  66. #endif
  67. #if RUN_TEST_MUTEX || RUN_TEST_ALL
  68. #include "test_mutex.h"
  69. #endif
  70. #if RUN_TEST_CONDWAIT || RUN_TEST_ALL
  71. #include "test_condwait.h"
  72. #endif
  73. #if RUN_TEST_SEMAPHORE || RUN_TEST_ALL
  74. #include "test_semaphore.h"
  75. #endif
  76. #if RUN_TEST_SAFEOBJECT || RUN_TEST_ALL
  77. //#include "test_safeobject.h"
  78. #endif
  79. #if RUN_TEST_OBJECT || RUN_TEST_ALL
  80. #include "test_object.h"
  81. #endif
  82. #if RUN_TEST_PARAMS || RUN_TEST_ALL
  83. #include "test_params.h"
  84. #endif
  85. #if RUN_TEST_OPTIONS || RUN_TEST_ALL
  86. #include "test_options.h"
  87. #endif
  88. #if RUN_TEST_TIMER || RUN_TEST_ALL
  89. #include "test_timer.h"
  90. #endif
  91. #if RUN_TEST_RUNNABLE || RUN_TEST_ALL
  92. #include "test_runnable.h"
  93. #endif
  94. #if RUN_TEST_BUFFER || RUN_TEST_ALL
  95. #include "test_buffer.h"
  96. #endif
  97. #if RUN_TEST_MD5 || RUN_TEST_ALL
  98. #include "test_md5.h"
  99. #endif
  100. #if RUN_TEST_SHA1 || RUN_TEST_ALL
  101. #include "test_sha1.h"
  102. #endif
  103. #if RUN_TEST_BASE64 || RUN_TEST_ALL
  104. #include "test_base64.h"
  105. #endif
  106. #if RUN_TEST_UUID || RUN_TEST_ALL
  107. #include "test_uuid.h"
  108. #endif
  109. #if RUN_TEST_FSM || RUN_TEST_ALL
  110. #include "test_fsm.h"
  111. #endif
  112. #ifdef _WIN32_WCE
  113. int _tmain(int argc, _TCHAR* argv[])
  114. #else
  115. int main()
  116. #endif
  117. {
  118. do {
  119. int y, x;
  120. for(y = 0; y < 16; ++y) {
  121. printf("{");
  122. for(x = 0; x < 16; ++x) {
  123. printf("%d, ", (2 * ( y / 8 ) + ( x / 8 )));
  124. }
  125. printf("}\n");
  126. }
  127. /* Print copyright information */
  128. printf("Doubango Project\nCopyright (C) 2009 Mamadou Diop \n\n");
  129. #if RUN_TEST_LISTS || RUN_TEST_ALL
  130. /* linked lists */
  131. test_basic_list();
  132. printf("\n\n");
  133. test_complex_list();
  134. printf("\n\n");
  135. test_filtered_list();
  136. printf("\n\n");
  137. #endif
  138. #if RUN_TEST_HEAP || RUN_TEST_ALL
  139. /* heap */
  140. test_heap();
  141. printf("\n\n");
  142. #endif
  143. #if RUN_TEST_STRINGS || RUN_TEST_ALL
  144. /* strings */
  145. test_strings();
  146. printf("\n\n");
  147. #endif
  148. #if RUN_TEST_URL || RUN_TEST_ALL
  149. /* url */
  150. test_url();
  151. printf("\n\n");
  152. #endif
  153. #if RUN_TEST_THREADS || RUN_TEST_ALL
  154. /* threads */
  155. test_threads();
  156. printf("\n\n");
  157. #endif
  158. #if RUN_TEST_MUTEX || RUN_TEST_ALL
  159. /* mutex */
  160. test_mutex();
  161. printf("\n\n");
  162. #endif
  163. #if RUN_TEST_CONDWAIT || RUN_TEST_ALL
  164. /* condwait */
  165. test_condwait();
  166. printf("\n\n");
  167. #endif
  168. #if RUN_TEST_SEMAPHORE || RUN_TEST_ALL
  169. /* semaphore */
  170. test_semaphore();
  171. printf("\n\n");
  172. #endif
  173. #if RUN_TEST_SAFEOBJECT || RUN_TEST_ALL
  174. /* safe object */
  175. //test_safeobject();
  176. printf("\n\n");
  177. #endif
  178. #if RUN_TEST_OBJECT || RUN_TEST_ALL
  179. /* object */
  180. //test_object();
  181. printf("\n\n");
  182. #endif
  183. #if RUN_TEST_PARAMS || RUN_TEST_ALL
  184. /* parameters */
  185. test_params();
  186. printf("\n\n");
  187. #endif
  188. #if RUN_TEST_OPTIONS || RUN_TEST_ALL
  189. /* options */
  190. test_options();
  191. printf("\n\n");
  192. #endif
  193. #if RUN_TEST_TIMER || RUN_TEST_ALL
  194. /* timer */
  195. test_timer();
  196. printf("\n\n");
  197. #endif
  198. #if RUN_TEST_RUNNABLE || RUN_TEST_ALL
  199. /* test runnable. */
  200. test_runnable();
  201. printf("\n\n");
  202. #endif
  203. #if RUN_TEST_BUFFER || RUN_TEST_ALL
  204. /* test buffer */
  205. test_buffer();
  206. #endif
  207. #if RUN_TEST_MD5 || RUN_TEST_ALL
  208. /* test md5 and hmac_md5 */
  209. test_md5();
  210. test_hmac_md5();
  211. #endif
  212. #if RUN_TEST_SHA1 || RUN_TEST_ALL
  213. /* test sha1 and hmac_sha-1 */
  214. test_sha1();
  215. test_hmac_sha1();
  216. #endif
  217. #if RUN_TEST_BASE64 || RUN_TEST_ALL
  218. /* test base64 encoding/decoding */
  219. test_base64();
  220. #endif
  221. #if RUN_TEST_UUID || RUN_TEST_ALL
  222. /* test fake UUID (version5) */
  223. test_uuid();
  224. #endif
  225. #if RUN_TEST_FSM || RUN_TEST_ALL
  226. /* test FSM */
  227. test_fsm();
  228. #endif
  229. }
  230. while(LOOP);
  231. getchar();
  232. return 0;
  233. }