Giter VIP home page Giter VIP logo

rktest_example's Introduction

RK Test Example Repository

This repository contains examples for how to integrate the RK Test unit test library into a C project.

CMake and Git Submodule

One straight forward way to include RK Test into your project is to include it in your source directory as a git submodule, and then include it as a subdirectory in your CMakeLists.txt.

This uses a project structure like the following, where factorial.c contains the code we want to test:

├── CMakeLists.txt
├── src
│   ├── main.c
│   ├── factorial.c
│   └── factorial.h
├── tests
|   └── factorial_tests.c
└── external
    └── rktest
        ├── CMakeLists.txt
        ├── include
        │   └── rktest
        │       └── rktest.h
        └── src
            └── rktest.c

Assuming we're in the project root, we can add RK Test as a git submodule with:

mkdir external
git submodule add https://github.com/Warwolt/rktest.git external/rktest

Afterwards, we can add the rktest directory to the projects CMakeLists.txt file, and add a test runner executable that links to rktest_main.

cmake_minimum_required(VERSION 3.16.0)
project(rktest_cmake_example)
enable_language(C)

# Inlucde RK Test
add_subdirectory(external/rktest)

# Main program
add_executable(${PROJECT_NAME}
    src/main.c
    src/factorial.c
)

# Unit tests
add_executable(tests
    src/factorial.c
    tests/factorial_tests.c
)
target_include_directories(tests PRIVATE src)
target_link_libraries(tests PRIVATE rktest_main)

rktest_example's People

Contributors

warwolt avatar

Stargazers

 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.