Code Monkey home page Code Monkey logo

multiverse-cpp's Introduction

Welcome to

MULTIVERSE OF LANGUAGES


Introduction

In this task you will be working on a C++ File and coding it according to given task. The main motive of this task is to make you familiar with:

  • Git and GitHub
  • C++
  • Standard Template Library (STL)

Setting up the project

Follow the following steps to setup this project.

Fork this repository

First of all, click on the top-right corner of this repository to fork it.

Create a local clone of your fork

Then, clone your forked repository using this command:

git clone https://github.com/YOUR-USERNAME/Multiverse-CPP.git

Change your current directory to the repo's root.

cd Multiverse-CPP

Thats it!

Go through the tasks in src folder and

Enjoy coding

Then you can finally test your submission by running this command from root folder.

make

Submission

  • Follow the instructions to setup this project.
  • Complete the task by making the required changes in the files.
  • When done, commit your work locally and push it to your origin (forked repository).
  • Make a pull request to our repository, stating the tasks which you have completed.
  • Let us review your pull request.


Want to know about doctest? See this example

Suppose we have a factorial() function that we want to test:

int factorial(int number) { return number <= 1 ? number : factorial(number - 1) * number; }

A complete compiling example with a self-registering test looks like this:

#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN
#include "test/doctest.h"

int factorial(int number) { return number <= 1 ? number : factorial(number - 1) * number; }

TEST_CASE("testing the factorial function") {
    CHECK(factorial(1) == 1);
    CHECK(factorial(2) == 2);
    CHECK(factorial(3) == 6);
    CHECK(factorial(10) == 3628800);
}

This will compile to a complete executable which responds to command line arguments. If you just run it with no arguments it will execute all test cases (in this case - just one), report any failures, report a summary of how many tests passed and failed and returns 0 on success and 1 if anything failed (useful if you just want a yes/no answer to: "did it work").

If you run this as written it will pass. Everything is good. Right? Well there is still a bug here. We missed to check if factorial(0) == 1 so lets add that check as well:

TEST_CASE("testing the factorial function") {
    CHECK(factorial(0) == 1);
    CHECK(factorial(1) == 1);
    CHECK(factorial(2) == 2);
    CHECK(factorial(3) == 6);
    CHECK(factorial(10) == 3628800);
}

Now we get a failure - something like:

test.cpp(7) FAILED!
  CHECK( factorial(0) == 1 )
with expansion:
  CHECK( 0 == 1 )

multiverse-cpp's People

Contributors

ankur-agrawal-ece20 avatar it-is-skywalkerl avatar satyamaditya9119 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.