Coder Social home page Coder Social logo

cgotestgenerator's Introduction

cGoTestGenerator

A GoLang tool to generate unit tests of C code embedded in Go

We roughly follow the standard xUnit setup.

The most basic cGoTest primitives are the cGoTest assertions. All assertions test their respective assertion and if it fails report an error. Failing XXX_MayFail assertions will stop the test case at that point. All other XXX assertions will allow the test case to proceed.

These assertions are placed in cGoTestCases. cGoTestCases are meant to test one "action" (and any associated structures). A cGoTestCase is an ANSI-C function which returns char* and takes a single void* argument and whose name ends in CGoTest. The most recent \inFixture <fixtureName> (or @inFixture <fixtureName>) marker is used to associated a given cGoTestCase to a cGoTestFixture.

cGoTestCases are run as part of a cGoTestFixture. cGoTestFixtures provide the context for one or more cGoTestCases. A cGoTestFixture is defined by the \testFixture <fixtureName> (or @testFixture <fixtureName>) marker.

Typically a cGoTestFixture will define a cGoTestSetup and/or cGoTestTeardown function used to respectively setup and teardown all required structures for each cGoTestCase in the cGoTestFixture. A cGoTestSetup is an ANSI-C function which returns a void* and takes no arguments. A cGoTestTeardown is an ANSI-C function which takes a single void* argument. The most recent \inFixture <fixtureName> (or @inFixture <fixtureName>) marker is used to assocaite the setup or teardown method with a cGoTestFixture.

One or more cGoTestFixtures are run as part of a cGoTestSuite.

NOTE: Since we are using line based regular expressions to find the cGoTestCases, cGoTestSetup, cGoTestTeardown functions as well as cGoTestFixture and cGoTestSuite definitions, the respective function prototypes and/or markers MUST be on one line. Function prototypes and/or markers which occurs over more than one line will not be recognized.

Typical use:

     //go:generate cGoTestGenerator <packageName> <packageDesc>

Will run the cGoTestGenerator on any files ending in "CGotTest.c" in the current directory and any of its subdirectories. (See go:generate)

Requirements

We use Matt Jibson's 'mjibson/esc to embed all "static" ANSI-C code files required by the cGoTests into the single cGoTestGenerator binary.

To install esc type:

go get -u github.com/mjibson/esc

Gitignore

The automatically generated files satisfy the following .gitignore patterns:

*GoTests.go
*GoTests_test.go
*GoTests.h
*GoTestsUtils.h

Doxygen

The \testSuite, \inSuite, \testFixture, and \inFixture markers are all meant to work with Doxygen as embedded commands. To do this you need to add the following to your Doxyfile:

ALIASES += testSuite="\par Suite:\n"
ALIASES += inSuite="\par Suite:\n"
ALIASES += testFixture="\par Fixture:\n"
ALIASES += inFixture="\par Fixture:\n"

(See Doxygen Custon Commands).

cgotestgenerator's People

Contributors

stephengaito avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.