-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add testing upperBound function acting on values.
- Loading branch information
Showing
2 changed files
with
43 additions
and
0 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#include "../include/crap/algorithm.d/upperboundfortype.h" | ||
|
||
#include <cstdlib> | ||
#include <functional> | ||
#include <iostream> | ||
#include <iterator> | ||
#include <numeric> | ||
|
||
#include "testutils.h" | ||
#include "../include/crap/utility.d/valuelist.h" | ||
|
||
bool test_upperBoundValueTrivialTest() | ||
{ | ||
using valueTestType = unsigned int; | ||
constexpr const static valueTestType Constrain = 42u; | ||
constexpr const static valueTestType Subject = 7u; | ||
static_assert(Subject < Constrain, "Subject should be smaller than Constrain so test may function."); | ||
|
||
//TODO: Make sequence random. | ||
using testList1 = | ||
crap :: valueList<valueTestType, 0u, 1u, 2u, 3u, 4u, 5u, 6u, 7u, Subject, Subject + 1u, Constrain>; | ||
using testedFun = crap :: upperBoundForType< | ||
valueTestType, | ||
Subject, | ||
lessConstrainedForType <valueTestType, Constrain> :: template type>; | ||
using testResult_t = typename testList1 :: copy <testedFun :: template type>; | ||
constexpr const static auto testResult = testResult_t :: value; | ||
static_assert(testResult < testList1 :: size + 1u, "Subject should be somewher!"); | ||
static_assert(testList1 :: data()[testResult - 1u] == Subject, "Subject in wrong place"); | ||
return true; | ||
} | ||
|
||
int main() | ||
{ | ||
const bool results[] = { | ||
test_upperBoundValueTrivialTest() | ||
}; | ||
return std :: accumulate(std :: begin(results), std :: end(results), true, std :: logical_and<bool>()) | ||
? EXIT_SUCCESS | ||
: EXIT_FAILURE; | ||
} | ||
|