Commit 41bb7841 authored by Pierre Aubert's avatar Pierre Aubert
Browse files

Add test

parent ef2c811b
Pipeline #96654 passed with stages
in 1 minute and 8 seconds
......@@ -2,4 +2,5 @@ project(Phoenix)
cmake_minimum_required(VERSION 2.8)
add_subdirectory(TEST_PHISTOGRAM)
add_subdirectory(TEST_MIN_MAX)
project(Phoenix)
add_executable(test_pmin_max main.cpp)
add_test(NAME TestPMinMax
COMMAND ${CMAKE_CURRENT_BINARY_DIR}/test_pmin_max)
/***************************************
Auteur : Pierre Aubert
Mail : aubertp7@gmail.com
Licence : CeCILL-C
****************************************/
#include "pMinMax.h"
///Test the graph conversion to dot
/** @return true on success, false otherwise
*/
bool testPMinMax(){
bool b(true);
int tabSingle[] = {1};
b &= pminTab(tabSingle, 1lu) == 1;
b &= pminTabPos(tabSingle, 1lu) == 0lu;
b &= pmaxTab(tabSingle, 1lu) == 1;
b &= pmaxTabPos(tabSingle, 1lu) == 0lu;
size_t nbValue(15lu);
int tabValue[] = {1,4,6,3,6,6,7,0,4,3,7,5,3,5,6};
b &= pminTab(tabValue, nbValue) == 0;
b &= pminTabPos(tabValue, nbValue) == 7lu;
b &= pmaxTab(tabValue, nbValue) == 7;
b &= pmaxTabPos(tabValue, nbValue) == 6lu;
return b;
}
int main(int argc, char** argv){
bool b(testPMinMax());
return b - 1;
}
......@@ -15,8 +15,8 @@ bool testPHistogram(){
PHistogram<float> hist(-1.0f, 1.0f, 10lu);
hist.reset();
for(size_t i(0lu); i < 100lu; ++i){
hist.addValue((((float)(i*27lu%19)) - 9.0)/5.0f);
for(size_t i(0lu); i < 1000lu; ++i){
hist.addValue((((float)(i*27lu%19)) - 9.0)/2.0f);
}
std::cout << "testPHistogram : min = " << hist.getMin() << ", max = " << hist.getMax() << ", range = " << hist.getRange() << ", nbValueUnderMin = " << hist.getUnderXMin() << ", nbValueUpperMax = " << hist.getOverXMax() << std::endl;
std::cout << hist << std::endl;
......@@ -56,7 +56,7 @@ bool testPHistogram2(){
std::cout << hist << std::endl;
PHistogram<float> hist4;
PHistogram<float> hist4(10lu);
hist4.setRange(-1.0f, 1.0f);
hist4.resize(20lu);
for(size_t i(0lu); i < 200lu; ++i){
......
......@@ -219,7 +219,7 @@ void pminmaxTab(T & xmin, T & xmax, const T* tab, size_t size){
for(i = 1; i < size; ++i){
tmp = tab[i];
if(tmp > xmax) xmax = tmp;
else if(tmp < xmin) xmin = tmp;
else{xmin = tmp;}
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment