2022-06-21 15:13:10 +02:00
|
|
|
#define __USE_GNU
|
|
|
|
#include <assert.h>
|
|
|
|
#include <stdbool.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
2023-06-01 17:22:38 +02:00
|
|
|
#include "./Include/fileGestion.h"
|
|
|
|
#include "./Include/getArray.h"
|
|
|
|
#include "./Include/growthRate.h"
|
|
|
|
#include "./Include/power.h"
|
|
|
|
#include "./Include/simulateFlux.h"
|
|
|
|
#include "./Include/queue.h"
|
|
|
|
#include "./Include/average.h"
|
|
|
|
// #include "b2hd.h"
|
2022-06-21 15:13:10 +02:00
|
|
|
|
|
|
|
bool rawDataWriteFlag;
|
|
|
|
int nRowRawData = 500;
|
|
|
|
int nRowGR = 150;
|
|
|
|
int nCol = 1;
|
|
|
|
double freqEch = 250;
|
|
|
|
|
|
|
|
int nbRowBinFile = 900011;
|
|
|
|
int nbRowIgnore = 19;
|
|
|
|
|
|
|
|
Pqueue firstRawDataQueue;
|
2023-05-09 13:37:36 +02:00
|
|
|
// Captor 1 2 3 4 5 6 7 8
|
2022-06-21 15:13:10 +02:00
|
|
|
bool selectionCaptors[] = {true, false, true, false, false, false, true, false};
|
|
|
|
|
|
|
|
int cptData = 0;
|
|
|
|
int cptFile = 1;
|
|
|
|
int cptValue = 0;
|
|
|
|
|
|
|
|
double period = 0;
|
|
|
|
double invTimeBandWidth = 0;
|
|
|
|
|
|
|
|
bool test_queueCreateEmpty()
|
|
|
|
{
|
|
|
|
Pqueue new = queueCreateEmpty();
|
|
|
|
|
|
|
|
assert(queueGetCharLen(new) == 0);
|
|
|
|
assert(queueGetTabChar(new) == NULL);
|
|
|
|
assert(queueGetNextE(new) == NULL);
|
|
|
|
|
|
|
|
// queueDelAll(new);
|
|
|
|
queueRmFrstE(new);
|
|
|
|
|
|
|
|
return EXIT_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2022-06-23 16:24:47 +02:00
|
|
|
bool test_queueCreateE()
|
|
|
|
{
|
|
|
|
const char tabChar[12] = "PetitNavire\0";
|
|
|
|
Pqueue new = queueCreateE(12, tabChar);
|
|
|
|
|
|
|
|
const char *test = queueGetTabChar(new);
|
|
|
|
|
|
|
|
assert(queueGetCharLen(new) == 12);
|
|
|
|
assert(test != NULL);
|
|
|
|
assert(strcmp(test, tabChar) == 0);
|
|
|
|
assert(queueGetNextE(new) == NULL);
|
|
|
|
|
|
|
|
queueRmFrstE(new);
|
|
|
|
return EXIT_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2022-06-21 15:13:10 +02:00
|
|
|
bool test_queueSetCharLen()
|
|
|
|
{
|
|
|
|
Pqueue new = queueCreateEmpty();
|
|
|
|
|
|
|
|
queueSetCharLen(new, 13);
|
|
|
|
|
|
|
|
assert(queueGetCharLen(new) == 13);
|
|
|
|
assert(queueGetTabChar(new) == NULL);
|
|
|
|
assert(queueGetNextE(new) == NULL);
|
|
|
|
|
|
|
|
// queueDelAll(new);
|
|
|
|
queueRmFrstE(new);
|
|
|
|
return EXIT_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2022-06-23 16:24:47 +02:00
|
|
|
bool test_queueSetTabChar()
|
|
|
|
{
|
|
|
|
// Set and Get tabChar are similar because use for same test
|
2022-06-21 15:13:10 +02:00
|
|
|
Pqueue new = queueCreateEmpty();
|
|
|
|
|
2022-06-23 16:24:47 +02:00
|
|
|
const char tabChar[12] = "PetitNavire\0";
|
|
|
|
queueSetTabChar(new, 12, tabChar);
|
|
|
|
const char *test = queueGetTabChar(new);
|
2022-06-21 15:13:10 +02:00
|
|
|
|
2022-06-23 16:24:47 +02:00
|
|
|
assert(queueGetCharLen(new) == 12);
|
|
|
|
assert(test != NULL);
|
|
|
|
assert(strcmp(test, tabChar) == 0);
|
2022-06-21 15:13:10 +02:00
|
|
|
assert(queueGetNextE(new) == NULL);
|
|
|
|
|
|
|
|
queueRmFrstE(new);
|
2022-06-23 16:24:47 +02:00
|
|
|
return EXIT_SUCCESS;
|
|
|
|
}
|
2022-06-21 15:13:10 +02:00
|
|
|
|
2022-06-23 16:24:47 +02:00
|
|
|
bool test_queueGetTabChar()
|
|
|
|
{
|
|
|
|
Pqueue new = queueCreateEmpty();
|
|
|
|
|
|
|
|
const char tabChar[12] = "PetitNavire\0";
|
|
|
|
queueSetTabChar(new, 12, tabChar);
|
|
|
|
const char *test = queueGetTabChar(new);
|
|
|
|
|
|
|
|
assert(queueGetCharLen(new) == 12);
|
|
|
|
assert(test != NULL);
|
|
|
|
assert(strcmp(test, tabChar) == 0);
|
|
|
|
assert(queueGetNextE(new) == NULL);
|
|
|
|
|
|
|
|
queueRmFrstE(new);
|
2022-06-21 15:13:10 +02:00
|
|
|
return EXIT_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool test_queueSetNextE()
|
|
|
|
{
|
|
|
|
Pqueue new = queueCreateEmpty(), next = queueCreateEmpty();
|
|
|
|
|
|
|
|
queueSetNextE(new, next);
|
|
|
|
|
|
|
|
assert(queueGetNextE(new) == next);
|
|
|
|
assert(queueGetNextE(next) == NULL);
|
|
|
|
|
|
|
|
queueDelAll(new);
|
|
|
|
return EXIT_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool test_queueGetNextE()
|
|
|
|
{
|
|
|
|
Pqueue new = queueCreateEmpty(), next = queueCreateEmpty();
|
|
|
|
|
|
|
|
queueSetNextE(new, next);
|
|
|
|
|
|
|
|
assert(queueGetNextE(new) == next);
|
|
|
|
assert(queueGetNextE(next) == NULL);
|
|
|
|
|
|
|
|
queueDelAll(new);
|
|
|
|
return EXIT_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool test_queueGetCharLen()
|
|
|
|
{
|
|
|
|
Pqueue new = queueCreateEmpty();
|
|
|
|
|
|
|
|
assert(queueGetCharLen(new) == 0);
|
|
|
|
|
|
|
|
queueSetCharLen(new, 13);
|
|
|
|
|
|
|
|
assert(queueGetCharLen(new) == 13);
|
|
|
|
|
|
|
|
queueDelAll(new);
|
|
|
|
return EXIT_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2022-06-23 16:24:47 +02:00
|
|
|
bool test_queueAddLastQ()
|
|
|
|
{
|
|
|
|
Pqueue new = queueCreateEmpty(), next = NULL;
|
|
|
|
const char tabChar[12] = "PetitNavire\0";
|
|
|
|
queueAddLastQ(new, tabChar, 12);
|
|
|
|
next = queueGetNextE(new);
|
|
|
|
|
|
|
|
assert(next != NULL);
|
|
|
|
assert(queueGetCharLen(next) == 12);
|
|
|
|
assert(strcmp(queueGetTabChar(next), tabChar) == 0);
|
|
|
|
assert(queueGetNextE(next) == NULL);
|
|
|
|
|
|
|
|
queueDelAll(new);
|
|
|
|
return EXIT_SUCCESS;
|
|
|
|
}
|
|
|
|
bool test_queueRmLastE()
|
|
|
|
{
|
|
|
|
Pqueue new = queueCreateEmpty();
|
|
|
|
const char tabChar[12] = "PetitNavire\0";
|
|
|
|
queueAddLastQ(new, tabChar, 12);
|
|
|
|
queueAddLastQ(new, tabChar, 12);
|
|
|
|
|
|
|
|
assert(queueGetNextE(new) != NULL && queueGetNextE(queueGetNextE(new)) != NULL && queueGetNextE(queueGetNextE(queueGetNextE(new))) == NULL);
|
|
|
|
queueRmLastE(new);
|
|
|
|
assert(queueGetNextE(new) != NULL && queueGetNextE(queueGetNextE(new)) == NULL);
|
|
|
|
|
|
|
|
queueDelAll(new);
|
|
|
|
return EXIT_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool test_queueRmFrstE()
|
|
|
|
{
|
|
|
|
Pqueue new = queueCreateEmpty(), second;
|
|
|
|
const char tabChar[12] = "PetitNavire\0";
|
|
|
|
queueAddLastQ(new, tabChar, 12);
|
|
|
|
queueAddLastQ(new, tabChar, 12);
|
|
|
|
second = queueGetNextE(new);
|
|
|
|
|
|
|
|
assert(queueGetNextE(new) != NULL && queueGetNextE(queueGetNextE(new)) != NULL && queueGetNextE(queueGetNextE(queueGetNextE(new))) == NULL);
|
|
|
|
new = queueRmFrstE(new);
|
|
|
|
assert((new == second) && (queueGetNextE(new) != NULL) && (queueGetNextE(queueGetNextE(new)) == NULL));
|
|
|
|
|
|
|
|
queueDelAll(new);
|
|
|
|
return EXIT_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool test_queueNextDelFrst()
|
|
|
|
{
|
|
|
|
Pqueue new = queueCreateEmpty(), second;
|
|
|
|
const char tabChar[12] = "PetitNavire\0";
|
|
|
|
queueAddLastQ(new, tabChar, 12);
|
|
|
|
queueAddLastQ(new, tabChar, 12);
|
|
|
|
second = queueGetNextE(new);
|
|
|
|
|
|
|
|
assert(queueGetNextE(new) != NULL && queueGetNextE(queueGetNextE(new)) != NULL && queueGetNextE(queueGetNextE(queueGetNextE(new))) == NULL);
|
|
|
|
new = queueNextDelFrst(new);
|
|
|
|
assert((new == second) && (queueGetNextE(new) != NULL) && (queueGetNextE(queueGetNextE(new)) == NULL));
|
|
|
|
|
|
|
|
queueDelAll(new);
|
|
|
|
return EXIT_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***************** Main test start *****************/
|
|
|
|
|
2022-06-21 15:13:10 +02:00
|
|
|
void usage(int argc, char *argv[])
|
|
|
|
{
|
|
|
|
fprintf(stderr, "Usage: %s <testname> [<...>]\n", argv[0]);
|
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
|
|
|
|
int main(int argc, char *argv[])
|
|
|
|
{
|
|
|
|
if (argc == 1)
|
|
|
|
usage(argc, argv);
|
|
|
|
|
|
|
|
// start test
|
|
|
|
fprintf(stderr, "=> Start test \"%s\"\n", argv[1]);
|
|
|
|
int ok = 1;
|
|
|
|
if (strcmp("queueCreateEmpty", argv[1]) == 0)
|
2022-06-23 16:24:47 +02:00
|
|
|
{
|
2022-06-21 15:13:10 +02:00
|
|
|
ok = test_queueCreateEmpty();
|
2022-06-23 16:24:47 +02:00
|
|
|
}
|
|
|
|
else if (strcmp("queueCreateE", argv[1]) == 0)
|
|
|
|
{
|
|
|
|
ok = test_queueCreateE();
|
|
|
|
}
|
2022-06-21 15:13:10 +02:00
|
|
|
else if (strcmp("queueSetCharLen", argv[1]) == 0)
|
|
|
|
{
|
|
|
|
ok = test_queueSetCharLen();
|
|
|
|
}
|
|
|
|
else if (strcmp("queueGetTabChar", argv[1]) == 0)
|
|
|
|
{
|
|
|
|
ok = test_queueGetTabChar();
|
|
|
|
}
|
|
|
|
else if (strcmp("queueSetNextE", argv[1]) == 0)
|
|
|
|
{
|
|
|
|
ok = test_queueSetNextE();
|
|
|
|
}
|
|
|
|
else if (strcmp("queueGetNextE", argv[1]) == 0)
|
|
|
|
{
|
|
|
|
ok = test_queueGetNextE();
|
|
|
|
}
|
|
|
|
else if (strcmp("queueGetCharLen", argv[1]) == 0)
|
|
|
|
{
|
|
|
|
ok = test_queueGetCharLen();
|
|
|
|
}
|
|
|
|
else if (strcmp("queueGetTabChar", argv[1]) == 0)
|
|
|
|
{
|
|
|
|
ok = test_queueGetTabChar();
|
2022-06-23 16:24:47 +02:00
|
|
|
}
|
|
|
|
else if (strcmp("queueSetTabChar", argv[1]) == 0)
|
|
|
|
{
|
|
|
|
ok = test_queueSetTabChar();
|
|
|
|
}
|
|
|
|
else if (strcmp("queueAddLastQ", argv[1]) == 0)
|
|
|
|
{
|
|
|
|
ok = test_queueAddLastQ();
|
|
|
|
}
|
|
|
|
else if (strcmp("queueRmLastE", argv[1]) == 0)
|
|
|
|
{
|
|
|
|
ok = test_queueRmLastE();
|
|
|
|
}
|
|
|
|
else if (strcmp("queueRmFrstE", argv[1]) == 0)
|
|
|
|
{
|
|
|
|
ok = test_queueRmFrstE();
|
|
|
|
}
|
|
|
|
else if (strcmp("queueNextDelFrst", argv[1]) == 0)
|
|
|
|
{
|
|
|
|
ok = test_queueNextDelFrst();
|
|
|
|
// }else if(strcmp("default_solution",argv[1]) == 0){
|
|
|
|
// ok = test_game_default_solution();
|
2022-06-21 15:13:10 +02:00
|
|
|
// }else if(strcmp("default_solution",argv[1]) == 0){
|
|
|
|
// ok = test_game_default_solution();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
fprintf(stderr, "Error: test \"%s\" not found!\n", argv[1]);
|
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
|
|
|
|
// print test result
|
|
|
|
if (ok == 0)
|
|
|
|
{
|
|
|
|
fprintf(stderr, "Test \"%s\" finished: SUCCESS\n", argv[1]);
|
|
|
|
return EXIT_SUCCESS;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
fprintf(stderr, "Test \"%s\" finished: FAILURE\n", argv[1]);
|
|
|
|
return EXIT_FAILURE;
|
|
|
|
}
|
|
|
|
}
|