TestPartitionLog.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 <partition_log.hxx>
22 
23 // Testing namespace
24 using namespace SHA_Logger;
25 
26 // STD includes
27 #include <fstream>
28 #include <functional>
29 #include <vector>
30 #include <string>
31 
32 #ifndef DOXYGEN_SKIP
33 namespace {
34  // Simple random array of integers with negative values
35 // const int RandomArrayInt[] = {40, 80, -10, 50, 1, 65, -80, 26, -20, -35, 35, 35, -70, 100, -50};
36  const int RandomArrayInt[] = {-1, 6, -4, 5, 8, 4, -5, -6, 7, 0, 2, -2, -3, 3, 3, -7, -8, 1};
37 
38  typedef std::vector<int> Container;
39  typedef Container::iterator IT;
40 }
41 #endif /* DOXYGEN_SKIP */
42 
43 // Test TestAlgo Construction
44 TEST(TestPartitionLog, build)
45 {
46  Container randomdArray(RandomArrayInt, RandomArrayInt + sizeof(RandomArrayInt) / sizeof(int));
47  IT pivot = randomdArray.begin() + std::distance(randomdArray.begin(), randomdArray.end()) / 2;
48 
49  OFStream fileStream("partition_output.json");
50 
51  // Run partition - Should result in: max[begin, pivot[ <= pivot <= min]pivot, end]
52  PartitionLog<IT>::Build(fileStream, OpGetAll, randomdArray.begin(), pivot, randomdArray.end());
53 }
std::ofstream OFStream
Definition: typedef.hxx:38
TEST(TestPartitionLog, build)
static IT Build(Ostream &os, Options opts, const IT &begin, const IT &pivot, const IT &end, const int offSet=0)