TestBinaryLog.cxx
Go to the documentation of this file.
1 /*===========================================================================================================
2  *
3  * SHA-L - Simple Hybesis Algorithm Logger
4  *
5  * Copyright (c) Michael Jeulin-Lagarrigue
6  *
7  * Licensed under the MIT License, you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * https://github.com/michael-jeulinl/Simple-Hybesis-Algorithms-Logger/blob/master/LICENSE
11  *
12  * Unless required by applicable law or agreed to in writing, software distributed under the License is
13  * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and limitations under the License.
15  *
16  * The above copyright notice and this permission notice shall be included in all copies or
17  * substantial portions of the Software.
18  *
19  *=========================================================================================================*/
20 #include <gtest/gtest.h>
21 #include <binary_log.hxx>
22 
23 // Testing namespace
24 using namespace SHA_Logger;
25 
26 #ifndef DOXYGEN_SKIP
27 namespace {
28  // Simple sorted array of integers with negative values
29  const int SortedArrayInt[] = {-3, -2, 0, 2, 8, 15, 36, 212, 366};
30 
31  template <typename T>
32  struct EQUAL
33  {
34  bool operator()(const T& a, const T& b) const { return a == b; }
35  };
36 
37  typedef std::vector<int> Container;
38  typedef Container::const_iterator IT;
39  typedef BinaryLog<IT, int, EQUAL<int>> BinaryLogT;
40 }
41 #endif /* DOXYGEN_SKIP */
42 
43 // Test TestAlgo Construction
44 TEST(TestBinaryLog, build)
45 {
46  const Container sortedArray(SortedArrayInt, SortedArrayInt + sizeof(SortedArrayInt) / sizeof(int));
47 
48  // Empty array
49  {
50  Container emptyArray = Container();
51  BinaryLogT::Build(std::cout, OpGetAll, emptyArray.begin(), emptyArray.end(), 0);
52  }
53 
54  BinaryLogT::Build(std::cout, OpGetMin, sortedArray.begin(), sortedArray.end(), -3);// First element
55  BinaryLogT::Build(std::cout, OpGetMin, sortedArray.begin(), sortedArray.end(), 8); // Existing random value
56 }
TEST(TestBinaryLog, build)