Commit 919eb8d7 authored by Pierre Aubert's avatar Pierre Aubert
Browse files

Try to add branch test

parent d4990542
Pipeline #96656 passed with stages
in 42 seconds
......@@ -6,34 +6,46 @@
#include "pMinMax.h"
///Test the graph conversion to dot
///Test the min max function
/** @param tabValue : table of values
* @param nbValue : number of values
* @param minVal : expected min value
* @param minPos : expected min position of the table of value
* @param maxVal : expected max value
* @param maxPos : expected max position of the table of value
* @return true on success, false otherwise
*/
bool checkMinMaxTab(const int * tabValue, size_t nbValue, int minVal, size_t minPos, int maxVal, size_t maxPos){
bool b(true);
b &= pminTab<int>(tabValue, nbValue) == minVal;
b &= pminTabPos<int>(tabValue, nbValue) == minPos;
b &= pmaxTab<int>(tabValue, nbValue) == maxVal;
b &= pmaxTabPos<int>(tabValue, nbValue) == maxPos;
return b;
}
///Test the min max function
/** @return true on success, false otherwise
*/
bool testPMinMax(){
bool b(true);
b &= pminTab<int>(NULL, 0lu) == 0;
b &= pminTabPos<int>(NULL, 0lu) == 0lu;
b &= pmaxTab<int>(NULL, 0lu) == 0;
b &= pmaxTabPos<int>(NULL, 0lu) == 0lu;
b &= checkMinMaxTab(NULL, 0lu, 0, 0lu, 0, 0lu);
b &= checkMinMaxTab(NULL, 1lu, 0, 0lu, 0, 0lu);
int tabSingle[] = {1};
b &= pminTab(tabSingle, 1lu) == 1;
b &= pminTabPos(tabSingle, 1lu) == 0lu;
b &= pmaxTab(tabSingle, 1lu) == 1;
b &= pmaxTabPos(tabSingle, 1lu) == 0lu;
b &= checkMinMaxTab(tabSingle, 0lu, 0, 0lu, 0, 0lu);
b &= checkMinMaxTab(tabSingle, 1lu, 1, 0lu, 1, 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 &= checkMinMaxTab(tabValue, nbValue, 0, 7lu, 7, 6lu);
b &= pmaxTab(tabValue, nbValue) == 7;
b &= pmaxTabPos(tabValue, nbValue) == 6lu;
return b;
}
......
......@@ -11,10 +11,10 @@
#include <math.h>
#include <iostream>
template<class T>
template<typename T>
T pmin(const T & a, const T & b);
template<class T>
template<typename T>
T pmax(const T & a, const T & b);
template <class T>
......@@ -23,49 +23,49 @@ T pmin4(const T & x, const T & y, const T & z, const T & t);
template <class T>
T pmax4(const T & x, const T & y, const T & z, const T & t);
template<class T>
template<typename T>
T pminTab(const T* tab, size_t size);
template<class T>
template<typename T>
size_t pminTabPos(const T* tab, size_t size);
template<class T>
template<typename T>
size_t pminTabPos(T & minVal, const T* tab, size_t size);
template<class T>
template<typename T>
T pmaxTab(const T* tab, size_t size);
template<class T>
template<typename T>
size_t pmaxTabPos(const T* tab, size_t size);
template<class T>
template<typename T>
size_t pmaxTabPos(T & maxVal, const T* tab, size_t size);
template<class T>
template<typename T>
void pminmaxTab(T & xmin, T & xmax, const T* tab, size_t size);
template<class T>
template<typename T>
void pminVec(T * vecMin, const T* tab1, const T * tab2, size_t size);
template<class T>
template<typename T>
void pmaxVec(T * vecMax, const T* tab1, const T * tab2, size_t size);
template<class T>
template<typename T>
void pminmaxMatrix(T * tabMin, T * tabMax, size_t nbCol, const T* matrix, size_t nbRow);
template<class T>
template<typename T>
void pminmaxMatrixPitch(T & xmin, T & xmax, const T* mat, size_t nbRow, size_t nbCol, size_t pitch);
template<class T>
template<typename T>
void pminmaxTabXY(T & xmin, T & xmax, T & ymin, T & ymax, const T * tab, size_t sizeNbPair);
template<class T>
template<typename T>
void tabXYtoTabXmY(T* tabX, const T* tabXY, size_t sizeTabX);
template<class T>
template<typename T>
void tabXYtoTabXmYonX(T* tabX, const T* tabXY, size_t sizeTabX);
template<class T>
template<typename T>
size_t getNumberOfDiffrentValues(const T * tab, size_t size, float threshold);
......
......@@ -15,7 +15,7 @@
* @param b : valeur
* @return petite valeurs entre a et b
*/
template<class T>
template<typename T>
T pmin(const T & a, const T & b){
return (a < b)? a:b;
}
......@@ -25,7 +25,7 @@ T pmin(const T & a, const T & b){
* @param b : valeur
* @return grande valeurs entre a et b
*/
template<class T>
template<typename T>
T pmax(const T & a, const T & b){
return (a > b)? a:b;
}
......@@ -91,7 +91,7 @@ T pmax4(const T & x, const T & y, const T & z, const T & t){
* @param size : taille du tableau
* @return minimum du tableau
*/
template<class T>
template<typename T>
T pminTab(const T* tab, size_t size){
if(tab == NULL || size == 0lu) return 0.0;
T res = tab[0];
......@@ -108,7 +108,7 @@ T pminTab(const T* tab, size_t size){
* @param size : taille du tableau
* @return position du minimum du tableau
*/
template<class T>
template<typename T>
size_t pminTabPos(const T* tab, size_t size){
if(tab == NULL || size == 0lu) return 0lu;
T res = tab[0];
......@@ -129,7 +129,7 @@ size_t pminTabPos(const T* tab, size_t size){
* @param size : taille du tableau
* @return position du minimum du tableau
*/
template<class T>
template<typename T>
size_t pminTabPos(T & minVal, const T* tab, size_t size){
if(tab == NULL || size == 0lu) return 0lu;
minVal = tab[0];
......@@ -149,7 +149,7 @@ size_t pminTabPos(T & minVal, const T* tab, size_t size){
* @param size : taille du tableau
* @return maximum du tableau
*/
template<class T>
template<typename T>
T pmaxTab(const T* tab, size_t size){
if(tab == NULL || size == 0lu) return 0.0;
T res = tab[0];
......@@ -166,7 +166,7 @@ T pmaxTab(const T* tab, size_t size){
* @param size : taille du tableau
* @return position du maximum du tableau
*/
template<class T>
template<typename T>
size_t pmaxTabPos(const T* tab, size_t size){
if(tab == NULL || size == 0lu) return 0lu;
T res = tab[0];
......@@ -187,7 +187,7 @@ size_t pmaxTabPos(const T* tab, size_t size){
* @param size : taille du tableau
* @return position du maximum du tableau
*/
template<class T>
template<typename T>
size_t pmaxTabPos(T & maxVal, const T* tab, size_t size){
if(tab == NULL || size == 0lu) return 0lu;
maxVal = tab[0];
......@@ -208,7 +208,7 @@ size_t pmaxTabPos(T & maxVal, const T* tab, size_t size){
* @param tab : table we want min and max
* @param size : number of elements in the table
*/
template<class T>
template<typename T>
void pminmaxTab(T & xmin, T & xmax, const T* tab, size_t size){
if(tab == NULL || size == 0lu) return;
xmin = tab[0];
......@@ -229,7 +229,7 @@ void pminmaxTab(T & xmin, T & xmax, const T* tab, size_t size){
* @param tab2 : table
* @param size : number of element in each table
*/
template<class T>
template<typename T>
void pminVec(T * vecMin, const T* tab1, const T * tab2, size_t size){
for(size_t i(0lu); i < size; ++i){
vecMin[i] = pmin(tab1[i], tab2[i]);
......@@ -242,7 +242,7 @@ void pminVec(T * vecMin, const T* tab1, const T * tab2, size_t size){
* @param tab2 : table
* @param size : number of element in each table
*/
template<class T>
template<typename T>
void pmaxVec(T * vecMax, const T* tab1, const T * tab2, size_t size){
for(size_t i(0lu); i < size; ++i){
vecMax[i] = pmax(tab1[i], tab2[i]);
......@@ -256,7 +256,7 @@ void pmaxVec(T * vecMax, const T* tab1, const T * tab2, size_t size){
* @param matrix : table we want min and max
* @param nbRow : number of rows in the matrix
*/
template<class T>
template<typename T>
void pminmaxMatrix(T * tabMin, T * tabMax, size_t nbCol, const T* matrix, size_t nbRow){
if(tabMax == NULL || tabMin == NULL || nbCol == 0lu || matrix == NULL || nbRow == 0lu) return;
memcpy(tabMin, matrix, sizeof(T)*nbCol);
......@@ -280,7 +280,7 @@ void pminmaxMatrix(T * tabMin, T * tabMax, size_t nbCol, const T* matrix, size_t
* @param nbCol : number of columns in the matrix pitch
* @param pitch : number of extra columns used to aligned the first element of each line of the matrix (so it is a matrix pitch)
*/
template<class T>
template<typename T>
void pminmaxMatrixPitch(T & xmin, T & xmax, const T* mat, size_t nbRow, size_t nbCol, size_t pitch){
if(mat == NULL || nbRow == 0lu || nbCol == 0lu) return;
xmin = mat[0];
......@@ -303,7 +303,7 @@ void pminmaxMatrixPitch(T & xmin, T & xmax, const T* mat, size_t nbRow, size_t n
* @param tab : tableau de valeurs de XY
* @param sizeNbPair : nombre de paires (moitié de la taille du tableau de XY totale)
*/
template<class T>
template<typename T>
void pminmaxTabXY(T & xmin, T & xmax, T & ymin, T & ymax, const T * tab, size_t sizeNbPair){
if(tab == NULL || sizeNbPair == 0lu) return;
xmin = tab[0lu];
......@@ -325,7 +325,7 @@ void pminmaxTabXY(T & xmin, T & xmax, T & ymin, T & ymax, const T * tab, size_t
* @param tabXY : table of couple (x,y)
* @param sizeTabX : size of the tabX table and half-size of the tabXY one
*/
template<class T>
template<typename T>
void tabXYtoTabXmY(T* tabX, const T* tabXY, size_t sizeTabX){
if(tabX == NULL || tabXY == NULL || sizeTabX == 0lu) return;
for(size_t i(0lu); i < sizeTabX; ++i){
......@@ -338,7 +338,7 @@ void tabXYtoTabXmY(T* tabX, const T* tabXY, size_t sizeTabX){
* @param tabXY : table of couple (x,y)
* @param sizeTabX : size of the tabX table and half-size of the tabXY one
*/
template<class T>
template<typename T>
void tabXYtoTabXmYonX(T* tabX, const T* tabXY, size_t sizeTabX){
if(tabX == NULL || tabXY == NULL || sizeTabX == 0lu) return;
for(size_t i(0lu); i < sizeTabX; ++i){
......@@ -353,7 +353,7 @@ void tabXYtoTabXmYonX(T* tabX, const T* tabXY, size_t sizeTabX){
* @param threshold : considers the minimal distance between to values
* @return number of diffrents value in a table
*/
template<class T>
template<typename T>
size_t getNumberOfDiffrentValues(const T * tab, size_t size, float threshold){
if(tab == NULL || size == 0lu) return 0lu;
size_t nb(1lu);
......
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