A dead-simple, yet extensible, C test framework.

Philosophy

Most test frameworks for C require a lot of boilerplate code to set up tests and test suites -- you need to create a main, then register new test suites, then register the tests within these suits, and finally call the right functions.

This gives the user great control, at the unfortunate cost of simplicity.

Criterion follows the KISS principle, while keeping the control the user would have with other frameworks:

  • Tests are automatically registered when declared.
  • A default entry point is provided, no need to declare a main unless you want to do special handling.
  • Test are isolated in their own process, crashes and signals can be reported and tested.
  • Progress and statistics can be followed in real time with report hooks.

Installation

$ git clone https://github.com/Snaipe/Criterion.git
$ cd Criterion
$ ./autogen.sh && ./configure && make && sudo make install

Given a test file named test.c, compile it with -lcriterion :

$ gcc -o test test.c -lcriterion

Samples

Sample tests can be found in thesample directory.

Q. What's wrong with other test frameworks?

A. I worked with CUnit and Check, and I must say that they do their job very well -- the only thing that bugs me is that setting up a test suite from scratch is a pain, it should really be simpler. Most (if not all) high-level languages have test frameworks with automatic test registration, but all the ones for C require you to set up a main, manually register suites, then tests. Criterion tries to fix these shortcomings.

Q. Where has this been tested?

A. Currently, on Linux 2.6.32 and Linux 3.15.7, although it should work on most *nix systems. More tests will be added on the build matrix.

Q. Will this work under Windows/MSVC?

A. Windows support with MinGW is coming, but MSVC is a bit of a lost cause for the C language. The project internally uses c99 features and gnu extensions, and MSVC is stuck at supporting c89.

Criterion - 一个简单可扩展的 C 语言测试框架的更多相关文章

  1. 将一个对象相同的属性(不区分大小写)赋值给一个新对象 DataTable的一个简单的扩展

    将一个对象相同的属性(不区分大小写)赋值给一个新对象   1 public static T Mapper<S, T>(S source) 2 { 3 T t = Activator.Cr ...

  2. 《maven实战》笔记(2)----一个简单maven项目的搭建,测试和打包

    参照<maven实战>在本地创建对应的基本项目helloworld,在本地完成后项目结构如下: 可以看到maven项目的骨架:src/main/java(javaz主代码)src/test ...

  3. 一个简单的NetCore项目:1 - 搭建框架,生成数据库

    1- 启动项目 安装.NETCORE SDK,教程在网上可以搜索的到,这里就不讲述了.简单粗暴的方式就是安装最新的VS2015. 2-搭建框架 2.1 打开VS新建一个项目,在弹出的新建项目对话框中, ...

  4. Python实现一个简单三层神经网络的搭建并测试

    python实现一个简单三层神经网络的搭建(有代码) 废话不多说了,直接步入正题,一个完整的神经网络一般由三层构成:输入层,隐藏层(可以有多层)和输出层.本文所构建的神经网络隐藏层只有一层.一个神经网 ...

  5. 一个简单但能考察C语言基础的题目

    请看题: #include<stdio.h> int a=1; int main(void) { int a=a; printf("a=d%\n",a); return ...

  6. DataTable的一个简单的扩展

    我们在调试代码的时候经常遇到DataTable的数据类型错误,这个类可以帮助我们很快查看DataTable的结构信息. /// <summary> /// DataTable扩展类 /// ...

  7. 一个简单的、面向对象的javascript基础框架

    如果以后公司再能让我独立做一套新的完整系统,那么我肯定会为这个系统再写一个前端框架,那么我到底该如何写这个框架呢? 在我以前的博客里我给大家展示了一个我自己写的框架,由于当时时间很紧张,做之前几乎没有 ...

  8. 使用react-native做一个简单的应用-04界面主框架

    欢迎界面搭建完毕,我们接下来需要做的就是搭建应用程序的主体框架啦.首先我们看一下首页的截图: 从图中看到,我将首页分为了三部分:用黑色矩形表示的头部,绿色表示的内容和红色表示的底部. 下面我们需要解决 ...

  9. 手写网站服务器~用Python手动实现一个简单的服务器,不借助任何框架在浏览器中输出任意内容

    写在前面的一些P话: 在公司网站开发中,我们往往借助于Flask.Django等网站开发框架去提高网站开发效率.那么在面试后端开发工程师的时候,面试官可能就会问到网站开发的底层原理是什么? 我们不止仅 ...

随机推荐

  1. 两种Service如何一起使用

    1.先是调用startservice来开启服务,并在且在后台一起运行. 2.在调用bindservice,获取中间对象. 3.unbindservice解绑服务. 4.最后在调用stopservice ...

  2. 6-17 Shortest Path [2](25 分)

    Write a program to find the weighted shortest distances from any vertex to a given source vertex in ...

  3. Springboot使用Cookie,生成cookie,获取cookie信息(注解与非注解方式)

    先 创建一个控制类吧, 其实我没有分层啊,随便做个例子: MyGetCookieController: @RestControllerpublic class MyGetCookieControlle ...

  4. Ext.js树结构

    1.app.js Ext.onReady(function(){ Ext.QuickTips.init(); Ext.Loader.setConfig({ enabled:true }); Ext.a ...

  5. office 2013母版保存并调用

    如果觉得某个ppt的母版不错,想保存下来以后使用的话,那么执行 开始->另存为->  选择位置和格式,注意格式选择potx. 之后如果想要使用这组母版,怎么办呢? 浏览主题,打开之前保存的 ...

  6. 创建自定义graphql-binding

    graphql-binding 是一个比较方便强大的工具,方便我们进行代码生成以及开发gateway的功能 项目初始化 使用prisma cli 使用脚手架 prisma init appdemo ? ...

  7. 949. Largest Time for Given Digits

    Given an array of 4 digits, return the largest 24 hour time that can be made. The smallest 24 hour t ...

  8. sublime text 3 配置优化

    1.在用Sublime里编写代码时,需要把TAB键转换成四个空格. 菜单栏里点击:首选项-> 设置-用户(Preferences-> Setting-User)在弹出来的文本里,添加如下两 ...

  9. XSS漏洞攻击原理与解决办法

    转自:http://www.frostsky.com/2011/10/xss-hack/ 对于的用户输入中出现XSS漏洞的问题,主要是由于开发人员对XSS了解不足,安全的意识不够造成的.现在让我们来普 ...

  10. 使用Java配置SpringMVC

    在此之前,一直使用的是XML的方式配置SpringMVC,现在为了适应Servlert3.0以及JavaConfig的Spring配置方式,在这里记录一下使用Java代码配置SpringMVC.首先, ...