Coder Social home page Coder Social logo

xtest's Introduction


Logo

xtest

C++ testing framework inspired by googletest!
Explore the docs »

Wiki · Report Bug · Request Feature

xtest is a C++ testing framework inspired by gtest. This is just a minimal implementation of a C++ unit testing framework which gives all the required facilities for unit testing a software without going template crazy and causing compilation issues.

A better and more robust version of this library is GoogleTest which is developed and maintained by Google. It is a official Google product and is used by many notable projects.

Installation

Clone the repository.

git clone https://github.com/joshiayush/xtest.git

Install libxtest

sudo chmod +x ./tools/install_libxtest.sh
./tools/install_libxtest.sh

Build samples

To build samples,

cmake -B build/ -S . -DBUILD_SAMPLES:BOOL=ON
cd build
make install

Now run the samples,

./samples/factorial/factorial  # Runs the factorial unit test samples binary
./samples/isprime/isprime      # Runs the isprime unit test samples binary

Usage

Testing a custom function that returns the sqaure of a given number.

#include <xtest/xtest.hh>

double square(int n) {
  return n*n;
}

TEST(TestSquare, TestWithPositiveNumber) {
  EXPECT_EQ(square(10), 100);
}

int32_t main(int32_t argc, char** argv) {
  ::xtest::InitXTest(&argc, argv);
  return RUN_ALL_TESTS();
}

Now compile the file and link the libxtest.so file with it:

g++ -lxtest square_test.cc -o square_test

Contribution

If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement", "bug", or "documentation". Don't forget to give the project a star! Thanks again!

Project xtest is hosted on GitHub. If you want to contribute changes please make sure to read the CONTRIBUTING.md file. You can also contribute changes to the CONTRIBUTING.md file itself.

xtest's People

Contributors

joshiayush avatar panquesito7 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.