Simple unit testing framework for C language

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

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.

相关文章
  • 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

  • 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

  • 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

  • Introduction to JUnit and Unit Testing Introduction 2010-04-18

    1 white-box testing of several related concepts - the test object as an open box, the program's internal logic structure and other information on the test personnel are public. Regression testing - Software or the environment after the repair or corr

  • Introduction to JUnit and unit testing 2010-12-23

    1, several related concepts White-box testing - the test object as an open box, the program logic of the internal structure and other information is open for testers. Regression testing - Software or the environment, repair or correction after the "r

  • In. NET environment using unit testing tool NUnit 2010-06-12

    How are you to http://www.iwms.net/n2140c13.aspx Thank you on Introduction The preparation of unit test is a validation act, but also a design act. Similarly, it is a kind of written document behavior. Write unit tests to avoid a considerable number

  • Summary of Unit Testing Practice 2010-08-26

    Species used in the system unit test development process, will bring many benefits, the most obvious are: When you become convinced of the value of comprehensive unit testing, you'll find that it begins to influence how you write code, and the framew

  • Unit Testing Practice Summary 2010-08-26

    Species in the system development process using unit testing, will bring many benefits, the most obvious are: When you become convinced of the value of comprehensive unit testing, you'll find that it begins to influence how you write code, and the fr

  • Unit testing JUNIT DBUNIT UNITILS 2011-01-06

    Java unit testing in the field, JUNIT have developers and testers you the best choice, which not only provides many standard API, while many IDE also provides a runtime environment to support it. Especially JUNIT4 after the introduction of the Java a

  • The use of JUnit in struts + spring + hibernate framework for unit testing environment 2009-05-26

    Way past the use of the IDE from the original break point of the DEBUG error checking to the current instrument is still the most efficient use of language output (log or system.out). Debug mode is not to say that these poor, but in some cases less t

  • Unit testing and JUNIT 2011-04-26

    Preface Study on unit testing and JUnit present article is to introduce the unit test either theory, either through a simple HelloWorld example describes the use of tools. This is very easy for the reader in the practical application can not start. B

  • About the unit testing of JSF program 2008-05-04

    Do not know if you have no experience of Web pages to test? Or is you want to test out web pages? Why no one reply to the article below it? JSF is because few people used, or because I think few people are more advanced on the JSF page automatic test

  • MOCK objects using examples of unit testing on the 2009-09-15

    1. What's the problem? The goal of unit testing is a one way authentication only, small step forward, fine-grained tests, but if a certain method depends on a number of other difficult to control the East, for example, network connectivity, database

  • The definition of unit testing 2010-04-01

    Readme: the article discusses the unit has many, many tests, but unit testing is the software development process has truly become an integral part of an important activity? I do not know how other companies, I know that is not at least in our compan

  • JUnit unit testing techniques and related 2010-08-13

    Work in practice, many projects did not write unit test cases. Programmers to write unit test cases are often very tired of a project activity, many people feel no need to waste time. All of these tests because they did not realize the importance of:

  • MySQL introduced automated testing framework 2010-11-07

    1 Overview Playing in our patch to MySQL, not only need to test new features, while the more important issue is the need for the return of the original features - the new patch if the other functions have led to the original bug, to outweigh the bene