#include <gtest/gtest.h>
#include <binary.hxx>
Go to the source code of this file.
|
| TEST (TestSearch, BinarySearchBasics) |
|
| TEST (TestSearch, BinarySearchDoubles) |
|
TEST |
( |
TestSearch |
, |
|
|
BinarySearchBasics |
|
|
) |
| |
Definition at line 55 of file TestBinary.cxx.
57 Container sortedArray(SortedArrayInt, SortedArrayInt +
sizeof(SortedArrayInt) /
sizeof(
int));
61 Container emptyArray = Container();
62 const auto index = BinarySearch<IT, EQUAL<int>>(emptyArray.begin(), emptyArray.end(), 0);
68 const auto index = BinarySearch<IT, EQUAL<int>>(sortedArray.begin(), sortedArray.end(), -3);
74 const auto index = BinarySearch<IT, EQUAL<int>>(sortedArray.begin(), sortedArray.end(), 8);
80 const auto index = BinarySearch<IT, EQUAL<int>>(sortedArray.begin(), sortedArray.end(), 1);
86 const auto index = BinarySearch<std::string::const_iterator, EQUAL<char>>
87 (OrderedStr.begin(), OrderedStr.end(),
'm');
TEST |
( |
TestSearch |
, |
|
|
BinarySearchDoubles |
|
|
) |
| |
Definition at line 93 of file TestBinary.cxx.
95 std::vector<double> sortedDoubleArray
96 (SortedDoubleArray, SortedDoubleArray +
sizeof(SortedDoubleArray) /
sizeof(
double));
100 const auto index = BinarySearch<IT_DL, EQUIVALENT<double>>
101 (sortedDoubleArray.begin(), sortedDoubleArray.end(),
static_cast<const double>(-.3));
107 const auto index = BinarySearch<IT_DL, EQUIVALENT<double>>
108 (sortedDoubleArray.begin(), sortedDoubleArray.end(),
static_cast<const double>(0.12));
114 const auto index = BinarySearch<IT_DL, EQUIVALENT<double>>
115 (sortedDoubleArray.begin(), sortedDoubleArray.end(),
static_cast<const double>(8.1));
116 EXPECT_EQ(-1, index);
121 std::vector<double> identicalArray = std::vector<double>(10, 3.);
122 const auto index = BinarySearch<IT_DL, EQUIVALENT<double>>
123 (identicalArray.begin(), identicalArray.end(),
static_cast<const double>(3.));