GithubHelp home page GithubHelp logo

stest's Introduction

stest

stest is small compact simple to understand and navigate C library for running unit tests. Library is C99 standard compliant and requires no dependencies.

Getting started

Clone the repository, and run make to build from source. If you want to install the lib, use make install. Default installation path:

  • .so -> /usr/local/lib
  • .h -> /usr/local/include

If you wish to change directory for header file and/or .so, then modify the LIB_DIR_INSTALL and HEADER_DIR_INSTALL directories in Makefile.

Make sure the instalation path for the shared library (.so) is in the linker runtime path. Now for good measure do: sudo ldconfig

Example

#include <stest.h>
#include <string.h>

// expands to 'void int_test(void);'
TEST(int_test);
TEST(int_test_2);
TEST(string_test);
TEST(string_test_2);
TEST(string_test_3);

int
main(void)
{
    ssuite* suite_str = ssuite_new("string_tests");
    ssuite* suite_int = ssuite_new("int_tests");

    ssuite_add_test(suite_str, string_test);
    ssuite_add_test(suite_str, string_test_2);
    ssuite_add_test(suite_str, string_test_3);

    ssuite_add_test(suite_int, int_test);
    ssuite_add_test(suite_int, int_test_2);

    srunner* runner = srunner_new();
    srunner_add_suite(runner, suite_str);
    srunner_add_suite(runner, suite_int);

    srunner_run(runner);
    srunner_free(runner);
}

TEST(int_test)
{
    int x = 5;
    int y = 6;

    ASSERT_EQ(sizeof(x), sizeof(y));

    ASSERT(x == y);
}

TEST(int_test_2)
{
    int x = 5;
    int y = 6;

    ASSERT_NEQ(x, y);
    ASSERT(6 == y);
}

TEST(string_test)
{
    const char* first  = "We are equal";
    const char* second = "We are equal";

    ASSERT_STR_EQ(first, second);
}

TEST(string_test_2)
{
    const char* first  = "We are equal";
    const char* second = "We are notequal";

    ASSERT_STR_NEQ(first, second);
    ASSERT_STR_EQ(first, "We are equal");
}

TEST(string_test_3)
{
    const char* first  = "We are equal";
    const char* second = "We are notequal";

    ASSERT_STR_EQ(first, second);
}

stest's People

Contributors

b-jure avatar

Watchers

 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.