Giter Club home page Giter Club logo

test-lib's Introduction

Test Lib

A Simple and Light C++23 modules based C++ testing library.

Example Usage

import moderna.test_lib;
auto tester = moderna::test_lib::Tester<>{ "Many entry test" }
  .add_test("Some Name over here", [](){})
  .add_test("Another Name", [](){});

// Run and print
test_lib::run_all_and_print(tester);

API Documentation

Creating a Test

import moderna.test_lib;
auto tester = moderna::test_lib::Tester<>{ 
  "Many entry test", // Name of the test Suite,
  true, // Should runs be done in parallel, 
  false // Should run progress be printed;
}

auto tester_with_progress_hook = moderna::test_lib::Tester<>{
  "Many entry test", // Entry test
  [](size_t progress){}, // Get the progress in a callback functino
  true, // Should runs be done in parallel
  false // Should run progress be printed
}

Getting the Run Results

import moderna.test_lib;
auto tester = moderna::test_lib::Tester<>{ "Many entry test" }
  .add_test("Some Name over here", [](){})
  .add_test("Another Name", [](){});

/*
  Runs all the tests. 
*/
const moderna::test_lib::ResultList<tester.test_count()>& results = tester.run_all();
size_t ok_count = results.ok_count();
size_t err_count = results.err_count();
std::array<TestResult, tester.test_count()> result_array& = tester.array;
/*
  Prints all the test result and exit with the correct exit code if not all the tests exits 
  successfully
*/
tester.print_and_exit();

Performing Assertions

#include <vector>
import moderna.test_lib;
moderna::test_lib::assert_equal(1, 1);
moderna::test_lib::assert_lt(0, 1); // Asserts less than

// This can be done on vectors too
moderna::test_lib::assert_equal(
  std::vector<uint32_t>({1, 2, 3}), 
  std::vector<uint32_t>({1, 2, 3})
);

test-lib's People

Contributors

jowillianto avatar

Stargazers

 avatar

Watchers

 avatar

test-lib's Issues

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.