Giter VIP home page Giter VIP logo

libzt's Introduction

C CI

libzt is an unit test library for C

libzt is a simple and robust unit test library for C.

Features

  • Robust, allowing you to focus on your code.
  • Simple and small, making it quick to learn and use.
  • Doesn't use dynamic memory allocation, reducing error handling.
  • Equipped with useful helpers for writing test cases.
  • Portable and supported on Linux, MacOS, Windows and DOS.
  • Documented and fully coverage and integration tested.

Example

#include <stdio.h>
#include <zt.h>

static const char *greeting(void) {
  return "hello there";
}

static void test_smoke(zt_t t) {
  zt_check(t, ZT_TRUE(2 + 2 == 4));
  zt_check(t, ZT_CMP_INT(2 + 2, ==, 4));
  zt_check(t, ZT_CMP_STR(greeting(), ==, "hello there"));
}

static void test_writing_to_tmpfile(zt_t t) {
  FILE *f = tmpfile();
  zt_assert(t, ZT_NOT_NULL(f)); // stops test on failure
  zt_check(t, ZT_CMP_INT(fprintf(f, "%s", greeting()), >, 0);
  zt_check(t, ZT_CMP_INT(ftell(f), ==, strlen(greeting()));
  zt_check(t, ZT_CMP_INT(fclose(f), ==, 0);
}

static void test_suite(zt_visitor v) {
  ZT_VISIT_TEST(v, test_smoke);
  ZT_VISIT_TEST(v, test_writing_to_tmpfile);
}

int main(int argc, char **argv, char **envp) {
  return zt_main(argc, argv, envp, test_suite);
}

libzt's People

Contributors

zyga avatar

Watchers

 avatar  avatar  avatar

libzt's Issues

Add support for building on GNU Hurd

This build has failed in Debian: https://buildd.debian.org/status/fetch.php?pkg=libzt&arch=hurd-i386&ver=0.2-1&stamp=1585351409&raw=0

 dpkg-source --before-build .
dpkg-buildpackage: info: host architecture hurd-i386
 /usr/bin/fakeroot debian/rules clean
dh clean
   dh_auto_clean
	make -j1 distclean
make[1]: Entering directory '/<<PKGBUILDDIR>>'
GNUmakefile:30: .makefiles/Makefile.GNU.mk: No such file or directory
make[1]: *** No rule to make target '.makefiles/Makefile.GNU.mk'.  Stop.
make[1]: Leaving directory '/<<PKGBUILDDIR>>'
dh_auto_clean: error: make -j1 distclean returned exit code 2
debian/rules:4: recipe for target 'clean' failed
make: *** [clean] Error 255
/bin/fakeauth: Error 2 for child 18140
/bin/settrans: Error 2 for child 18139

Debian GNU/kFreeBSD is unsupported

dpkg-buildpackage: info: source package libzt
dpkg-buildpackage: info: source version 0.2-1
dpkg-buildpackage: info: source distribution unstable
 dpkg-source --before-build .
dpkg-buildpackage: info: host architecture kfreebsd-amd64
 fakeroot debian/rules clean
dh clean
   dh_auto_clean
	make -j1 distclean
make[1]: Entering directory '/<<PKGBUILDDIR>>'
GNUmakefile:30: .makefiles/Makefile.GNU/kFreeBSD.mk: No such file or directory
make[1]: *** No rule to make target '.makefiles/Makefile.GNU/kFreeBSD.mk'.  Stop.
make[1]: Leaving directory '/<<PKGBUILDDIR>>'
dh_auto_clean: error: make -j1 distclean returned exit code 2
make: *** [debian/rules:4: clean] Error 25

From https://buildd.debian.org/status/package.php?p=libzt#problem-3

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.