Created
June 11, 2019 15:06
-
-
Save junaidrahim/b3cb63552036048c3e45ec52aa7fd1ce to your computer and use it in GitHub Desktop.
test.cpp file for the medium post
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define CATCH_CONFIG_MAIN | |
#include "catch.hpp" | |
#include <vector> | |
#include "../include/binary_search.hpp" | |
std::vector<int> arr = {10,20,30,40,50,60,70,80,90,100}; | |
TEST_CASE("Testing Binary Search") { | |
// testing for existing terms | |
REQUIRE(binary_search(arr, 10) == 0); | |
REQUIRE(binary_search(arr, 50) == 4); | |
REQUIRE(binary_search(arr, 100) == 9); | |
// testing for non existing terms | |
REQUIRE(binary_search(arr, -11) == -1); | |
REQUIRE(binary_search(arr, 176) == -1); | |
REQUIRE(binary_search(arr, 1230) == -1); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment