Uncategorized

6 posts

Refactor fhash is done

Overview Aha, After some days, I have finished the refactor task for fhash, it’s really really big improvement for flibs, since many many components depend on it, such as: thread pool event framework pcap conversion lib log … Why need to do refactor The old fhash have some defects, such […]

A Tip of Writing Makefile — Using @

Ok, let’s talk about one of the tips for writing Makefile, the magic character ‘@’ Before continue, let’s think about one thing: when you want to build a project, write a shell script or use the Make for building your project, which one would you prefer? Ok, I’ll choose Make, […]

Compile Clang3.4

As we know, llvm is a great project, and it also include the clang compiler. And for Clang 3.4, it support dumping the format configuration file, so that people can generate the self-style format for their own project. Detail: ClangFormat  and ClangFormatStyleOptions And for now, Clang 3.4 has not been […]

How to Write a Simple UnitTest Framework

很多时候, 我们需要UnitTest帮助我们快速的发现代码修改中引发的问题, UnitTest的意义以及重要性已经无需重复, 那么在实际项目中, 我们会选取合适的UnitTest Framework帮助我们完成这项工作, 然而UnitTest Framework也有很多种, 挑选的时候大多根据项目需要, 不过大家是否有冲动自己写一个那? 来一探UnitTest Framework的究竟(本文将实现一个C语言的UnitTest Framework 代码放置在https://github.com/finaldie/final_libs的ftu中). 原理: UnitTest Framework通常帮助我们完成以下几种功能: 1. 提供常用assert API 2. 注册执行test case 3. 生成report 关于断言, 我们通常使用几种形式的断言, 比如: 1. 某个值是否于期望值相等 2. 某个值是否大于期望值 3. 某个值是否小于期望值 所以, 如果我们自己来写一个, 只需要提供基本的assert API, 注册和执行的API即可(最后的报告放在run API内部即可). WorkFlow: 实现:   原理清楚了, 实现起来就很容易了. 首先我们先来提供几个基本的assert API: extern int curr_failed_assert; extern int […]