zoukankan      html  css  js  c++  java
  • redis源码笔记-testhelp

    testhelp.h是作者为redis量身定做的单元测试框架,对于redis这种规模的项目,就没有必要上GTEST这种大杀器了,作者18行代码搞定。

    不过很遗憾,在2.4.10这个版本的版本的redis中,只有sds用了这个测试框架,不知其他代码作者是如何做测试的。我慢慢摸索,摸索到了告诉大家。

     1 #ifndef __TESTHELP_H
     2 #define __TESTHELP_H
     3 
     4 int __failed_tests = 0;            //失败的测试用例数
     5 int __test_num = 0;                //总的测试用例数
     6 #define test_cond(descr,_c) do { \
     7     __test_num++; printf("%d - %s: ", __test_num, descr); \
     8     if(_c) printf("PASSED\n"); else {printf("FAILED\n"); __failed_tests++;} \
     9 } while(0);
    10 #define test_report() do { \
    11     printf("%d tests, %d passed, %d failed\n", __test_num, \
    12                     __test_num-__failed_tests, __failed_tests); \
    13     if (__failed_tests) { \
    14         printf("=== WARNING === We have failed tests here...\n"); \
    15     } \
    16 } while(0);
    17 
    18 #endif  //完全用宏实现的,一目了然,不多说了
  • 相关阅读:
    017-新闻表分页增删改查
    016-页面生命周期
    015-用户登录注册
    014-Session服务器状态保持
    013-Cookie状态保持
    012-ViewState状态保持
    011-Server服务器对象属性
    010-判断是否回传IsPostBack属性
    Github使用教程
    获取中文时间
  • 原文地址:https://www.cnblogs.com/liuhao/p/2497022.html
Copyright © 2011-2022 走看看