Bin search
This commit is contained in:
23
tests/s0704_binary_search.cpp
Normal file
23
tests/s0704_binary_search.cpp
Normal file
@@ -0,0 +1,23 @@
|
||||
#include "s0704_binary_search.hpp"
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
TEST(Problem704, Case1) {
|
||||
vector<int> nums{-1, 0, 3, 5, 9, 12};
|
||||
int target{9};
|
||||
int o{4};
|
||||
Solution1 solution1;
|
||||
Solution2 solution2;
|
||||
EXPECT_EQ(solution1.binSearch(nums, target), o);
|
||||
EXPECT_EQ(solution2.binSearch(nums, target), o);
|
||||
}
|
||||
|
||||
TEST(Problem704, Case2) {
|
||||
vector<int> nums{-1, 0, 3, 5, 9, 12};
|
||||
int target{2};
|
||||
int o{-1};
|
||||
Solution1 solution1;
|
||||
Solution2 solution2;
|
||||
EXPECT_EQ(solution1.binSearch(nums, target), o);
|
||||
EXPECT_EQ(solution2.binSearch(nums, target), o);
|
||||
}
|
||||
Reference in New Issue
Block a user