The simplest unit test framework for C language

2010-04-30  来源:本站原创  分类:Mobile  人气:204 

Information from the Internet. Simple C language unit testing framework, and only a 3-line header. As follows:

$ Cat test / mini_test.h

# Define mini_assert (message, test) do (if (! (Test)) return message;) while (0)

# Define mini_test (test) do (char * message = test (); tests_run + +; if (message) return message;) while (0)

extern int tests_run;

Usage:

$ Cat test / test_all.c

# Include <stdio.h> / * For printf * /

# Include "mini_test.h"

int tests_run = 0;

static char * test1 () (

mini_assert ("must be true", 1 == 1);

return 0;

)

static char * all_tests () (

mini_test (test1);

return 0;

)

int main (int argc, char ** argv) (

char * result = all_tests ();

if (result! = 0) (

printf ("% s \ n", result);

) Else (

printf ("ALL TESTS PASSED \ n");

)

printf ("Tests run:% d \ n", tests_run);

return result! = 0;

)

As the testing framework is very simple, so it is easy for embedded system development, such as MTK's C-language development.

相关文章
  • The simplest unit test framework for C language 2010-04-30

    Information from the Internet. Simple C language unit testing framework, and only a 3-line header. As follows: $ Cat test / mini_test.h # Define mini_assert (message, test) do (if (! (Test)) return message;) while (0) # Define mini_test (test) do (ch

  • Simple unit testing framework for C language 2010-04-30

    Information from the Internet. Simple C language unit testing framework, and only a 3-line header. As follows: $ Cat test / mini_test.h # Define mini_assert (message, test) do (if (! (Test)) return message;) while (0) # Define mini_test (test) do (ch

  • Simple color-color writing PHP unit testing framework Kenxu_Uint v0.1 2010-09-10

    Simple color-color writing PHP unit testing framework Kenxu_Uint v0.1 released, Ha ha ha, finally do not have PHP UNIT a very strong but a lot of trouble though, when installed on the support ... its still pear wrote a Look at the code: To test the m

  • Unit testing framework JMock compared with the use of Mockito 2010-08-27

    We all have this experience, testing the software coding process we occupy most of the time, and sometimes have decided that a good service code to write, but writing test code Quenan, and unit testing is to test the students entrusted to your own co

  • When unit testing framework for face 2007-10-05

    Now I follow our layered architecture for hierarchical test that we see here have discussed DAO test, hierarchical test discussion, but a lot of posts have not replied. Why write this article Would like to summarize our TDD approach. Looking at "JUni

  • Unit testing framework JMock usage compared with Mockito 2010-08-27

    We have this experience, the process of testing our software coding to occupy most of the time, sometimes feel good to write software business code, but but difficult to write test code, unit testing is to test the students entrusted to their own cod

  • Java stored procedures implemented unit testing framework Store Procedure Unit Test 2011-09-02

    Stored procedure Store Procedure Unit Test unit testing more testing and report the resulting

  • Open-source cross-platform C + + class library set (change) 2010-04-01

    Under the library support in the following, the development of the system can easily ported to most of current platforms to run without modification Shang, simply corresponds to the platform in your favorite compiler, recompilation The classic C + +

  • Android 2.1 Source Structure Analysis 2010-05-10

    Android 2.1 Source Structure Analysis Rockie Cheng Android 2.1 | - Makefile | - Bionic (bionic C Library) | - Bootable (boot-related code) | - Build (compile rules and generic storage systems and other infrastructure development package configuration

  • Android 2.1 source directory structure of (turn) 2010-08-03

    Android 2.1 source directory structure of (turn) Author Rockie Cheng Android 2.1 | - Makefile | - Bionic (bionic C Library) | - Bootable (boot-related code) | - Build (compile rules and generic storage systems and other infrastructure development pac

  • The most comprehensive source directory structure Xiangjie Android 2010-08-25

    Android 2.1 | - Makefile | - bionic (bionic C Library) | - bootable (boot-related code) | - build (compile rules and generic storage systems and other infrastructure development package configuration) | - cts (Android compatibility test suite standar

  • Source directory structure Xiangjie 2010-09-11

    Android 2.1 | - Makefile | - Bionic (bionic C Library) | - Bootable (boot-related code) | - Build (compile rules and generic storage systems and other infrastructure development package configuration) | - Cts (Android compatibility test kit standard)

  • Android2.1 source structure analysis 2010-09-29

    The following is reproduced: Android 2.1 Source Structure Analysis Rockie Cheng Android 2.1 | - Makefile | - Bionic (bionic C Library) | - Bootable (boot-related code) | - Build (compile rules and generic storage systems and other infrastructure deve

  • Android - Android2.1 Source Structure Analysis 2010-12-07

    Android 2.1 Source Structure Analysis Android 2.1 | - Makefile | - Bionic (bionic C Library) | - Bootable (boot-related code) | - Build (compile rules and generic storage systems and other infrastructure development kit configuration) | - Cts (Androi

  • Detailed source directory structure 2011-01-10

    Android 2.1 | - Makefile | - Bionic (bionic C Library) | - Bootable (boot-related code) | - Build (compile rules and generic storage systems and other infrastructure development kit configuration) | - Cts (Android compatibility test suite standard) |

  • Android 2.1 Source Structure 2011-01-14

    Android 2.1 | - Makefile | - Bionic (bionic C Library) | - Bootable (boot-related code) | - Build (compile rules and generic storage systems and other infrastructure development kit configuration) | - Cts (Android compatibility test suite standard) |

  • [To] Android directory structure 2011-05-23

    Android directory structure Android 2.1 | - Makefile | - bionic (bionic C Library) | - bootable (boot-related code) | - build (compile rules and generic storage systems and other infrastructure development kit configuration) | - cts (Android compatib

  • Novice iSoftStone software testing pen questions 2011-09-02

    This face questions from the network to find, I only study reference, no other intention. 1. Software testing is an important part of software development, software testing is performed () A) that software errors do not exist B) to prove the existenc

  • Open Language Framework 2010-08-16

    Ant seen from the functional point of custom convenience, according to inspiration and the latest thinking ant, think of the prototype of an open language framework. Java custom language used to achieve the final package to provide jar, jar package n

  • Transfer: OGNL and practice of language description 2010-09-02

    OGNL is the Object-Graph Navigation Language acronym, from the language point of view: it is a powerful expression language, used to get and set Java ™ object. OGNL has applications in many areas. This paper will be introduced and how to use OGNL OGN