TBOX的所有测试代码都在./src/demo下面,基本上包含所有模块的测试。

demo使用

编译完TBOX后会在./src/demo下面生成一个demo.b的测试程序,用msvc编译出来的为demo.exe

直接运行:./src/demo/demo.b 则会列出所有测试模块:

  1. [demo]: ======================================================================
  2. [demo]: help: echo "name" > ./.demo
  3. [demo]: help: ./demo.b args ...
  4. [demo]: help: or
  5. [demo]: help: ./demo.b name args ...
  6. [demo]: help:
  7. [demo]: help: example: echo "stream" > ./.demo
  8. [demo]: help: example: ./demo.b --help
  9. [demo]: help: example: ./demo.b http://www.xxxxx.com /tmp/a
  10. [demo]: help: example: or
  11. [demo]: help: example: ./demo.b stream http://www.xxxxx.com /tmp/a
  12. [demo]: help:
  13. [demo]: help: name: libc_time
  14. [demo]: help: name: libc_wchar
  15. [demo]: help: name: libc_string
  16. [demo]: help: name: libc_stdlib
  17. [demo]: help: name: libm_float
  18. [demo]: help: name: libm_double
  19. [demo]: help: name: libm_integer
  20. [demo]: help: name: database_sql
  21. [demo]: help: name: xml_reader
  22. [demo]: help: name: xml_writer
  23. [demo]: help: name: xml_document
  24. [demo]: help: name: asio_dns
  25. [demo]: help: name: asio_http
  26. [demo]: help: name: asio_httpd
  27. [demo]: help: name: asio_aiopc
  28. [demo]: help: name: asio_aiopd
  29. [demo]: help: name: asio_aicpc
  30. [demo]: help: name: asio_aicpd
  31. [demo]: help: name: math_fixed
  32. [demo]: help: name: math_random
  33. [demo]: help: name: utils_url
  34. [demo]: help: name: utils_crc
  35. [demo]: help: name: utils_md5
  36. [demo]: help: name: utils_sha
  37. [demo]: help: name: utils_bits
  38. [demo]: help: name: utils_dump
  39. [demo]: help: name: utils_option
  40. [demo]: help: name: utils_base32
  41. [demo]: help: name: utils_base64
  42. [demo]: help: name: other_flv
  43. [demo]: help: name: other_test
  44. [demo]: help: name: other_charset
  45. [demo]: help: name: object_json
  46. [demo]: help: name: object_bin
  47. [demo]: help: name: object_xml
  48. [demo]: help: name: object_bplist
  49. [demo]: help: name: object_xplist
  50. [demo]: help: name: object_dump
  51. [demo]: help: name: stream
  52. [demo]: help: name: stream_null
  53. [demo]: help: name: stream_cache
  54. [demo]: help: name: stream_charset
  55. [demo]: help: name: stream_zip
  56. [demo]: help: name: stream_transfer_pool
  57. [demo]: help: name: stream_async_transfer
  58. [demo]: help: name: stream_async_stream_null
  59. [demo]: help: name: stream_async_stream_cache
  60. [demo]: help: name: stream_async_stream
  61. [demo]: help: name: stream_async_stream_charset
  62. [demo]: help: name: stream_async_stream_zip
  63. [demo]: help: name: string_string
  64. [demo]: help: name: string_static_string
  65. [demo]: help: name: memory_check
  66. [demo]: help: name: memory_pool
  67. [demo]: help: name: memory_fixed_pool
  68. [demo]: help: name: memory_large_pool
  69. [demo]: help: name: memory_small_pool
  70. [demo]: help: name: memory_string_pool
  71. [demo]: help: name: memory_memops
  72. [demo]: help: name: memory_buffer
  73. [demo]: help: name: memory_queue_buffer
  74. [demo]: help: name: memory_static_buffer
  75. [demo]: help: name: memory_impl_static_fixed_pool
  76. [demo]: help: name: network_dns
  77. [demo]: help: name: network_url
  78. [demo]: help: name: network_ipv4
  79. [demo]: help: name: network_http
  80. [demo]: help: name: network_whois
  81. [demo]: help: name: network_spider
  82. [demo]: help: name: network_cookies
  83. [demo]: help: name: network_impl_date
  84. [demo]: help: name: platform_file
  85. [demo]: help: name: platform_lock
  86. [demo]: help: name: platform_path
  87. [demo]: help: name: platform_event
  88. [demo]: help: name: platform_utils
  89. [demo]: help: name: platform_timer
  90. [demo]: help: name: platform_ltimer
  91. [demo]: help: name: platform_atomic
  92. [demo]: help: name: platform_process
  93. [demo]: help: name: platform_barrier
  94. [demo]: help: name: platform_atomic64
  95. [demo]: help: name: platform_processor
  96. [demo]: help: name: platform_backtrace
  97. [demo]: help: name: platform_directory
  98. [demo]: help: name: platform_exception
  99. [demo]: help: name: platform_semaphore
  100. [demo]: help: name: platform_cache_time
  101. [demo]: help: name: platform_thread_pool
  102. [demo]: help: name: platform_thread_store
  103. [demo]: help: name: container_heap
  104. [demo]: help: name: container_hash
  105. [demo]: help: name: container_list
  106. [demo]: help: name: container_queue
  107. [demo]: help: name: container_stack
  108. [demo]: help: name: container_vector
  109. [demo]: help: name: container_list_entry
  110. [demo]: help: name: container_single_list
  111. [demo]: help: name: container_single_list_entry
  112. [demo]: help: name: container_bloom_filter
  113. [demo]: help: name: algorithm_find
  114. [demo]: help: name: algorithm_sort

比较使用的一些测试demo

  1. 测试http服务器demo

    1. ./src/demo/demo.b asio_httpd /tmp/web/root
  2. 测试http爬虫demo

    1. ./src/demo/demo.b network_spider http://www.xxxx.com
  3. 测试stream下载demo

    1. ./src/demo/demo.b stream http://www.xxxx.com /tmp/a
  4. 测试async_stream下载demo

    1. ./src/demo/demo.b async_stream http://www.xxxx.com /tmp/a
  5. 测试dns解析demo

    1. ./src/demo/demo.b network_dns www.xxxx.com
  6. 测试asio dns解析demo

    1. ./src/demo/demo.b asio_dns www.xxxx.com

还有好多好多,具体可以直接进入./src/demo目录浏览下,看下代码,大体都能猜到怎么使用