Skip to content

[pull] master from TheAlgorithms:master #34

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 27, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,9 @@ assert(backtracking::subset_sum::number_of_subsets(0, array1) ==
3. Small C++ program that showcases and explains the use of tests.

```cpp
#include <vector> /// for std::vector
#include <cassert> /// for assert
#include <iostream> /// for IO operations
#include <vector> /// for std::vector
#include <cassert> /// for assert

/**
* @brief Verifies if the given array
Expand All @@ -100,7 +101,7 @@ bool is_number_on_array(const std::vector<T> &arr, const int &number) {
return true;
}
else {
return false;
// Number not in the current index, keep searching.
}
}

Expand All @@ -116,6 +117,10 @@ static void tests() {

assert(is_number_on_array(arr, 9) == true);
assert(is_number_on_array(arr, 4) == false);
assert(is_number_on_array(arr, 98) == true);
assert(is_number_on_array(arr, 512) == false);

std::cout << "All tests have successfully passed!\n";
}

/**
Expand Down Expand Up @@ -192,6 +197,9 @@ static void test() {
assert(func(...) == ...); // this ensures that the algorithm works as expected

// can have multiple checks

// this lets the user know that the tests have passed
std::cout << "All tests have successfully passed!\n";
}

/**
Expand Down