/*
* Unit Test Bootstrap
* Autor: Tomasz Jaworski, 2018-2019
*
* Test dla zadania Histogram
* Autor testowanej odpowiedzi: Szymon Ptak
* Test wygenerowano automatycznie o 2019-08-21 14:22:40.370733
*
* Debug:
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include <signal.h>
#include <setjmp.h>
#include <assert.h>
#define _RLDEBUG_API_
#include "unit_helper_v2.h"
#include "rdebug.h"
#include "tested_declarations.h"
#include "rdebug.h"
//
// Elementy globalne dla całego testu
//
//
// Test 1: Sprawdzanie poprawności działania funkcji create_histogram
//
void UTEST1(void)
{
// informacje o teście
test_start(1, "Sprawdzanie poprawności działania funkcji create_histogram", __LINE__);
// uwarunkowanie zasobów - pamięci, itd...
test_file_write_limit_setup(33554432);
rldebug_reset_limits();
//
// -----------
//
const int expected_array[] = {0, 2, 1, 0, 1, 1, 0, 0, 0, 1, 0};
int output[] = {0, 1, -1, -2, 1, -1, 0, 1, 1, -2, -1};
printf("#####START#####");
int res = create_histogram((float[]){1.265167, 1.568573, 4.539888, 2.261551, 9.978582, 5.580424}, 6, output, 11);
printf("#####END#####");
test_error(res == 0, "Funkcja create_histogram() powinna zwrócić 0, a zwróciłą %d", res);
int ok = 0;
for (int i = 0; i < 11; ++i)
ok += output[i] != expected_array[i];
if (ok)
{
printf("Powinno być: [0, 2, 1, 0, 1, 1, 0, 0, 0, 1, 0]\n");
printf("\nTablica po wywołaniu funkcji create_histogram: ");
for (int i = 0; i < 11; ++i)
printf("%d ", output[i]);
printf("\n");
test_error(ok == 0, "Funkcja create_histogram() niepoprawnie wypełniła tablicę");
}
//
// -----------
//
// przywrócenie podstawowych parametów przydzielania zasobów (jeśli to tylko możliwe)
rldebug_reset_limits();
test_file_write_limit_restore();
test_ok();
}
//
// Test 2: Sprawdzanie poprawności działania funkcji create_histogram
//
void UTEST2(void)
{
// informacje o teście
test_start(2, "Sprawdzanie poprawności działania funkcji create_histogram", __LINE__);
// uwarunkowanie zasobów - pamięci, itd...
test_file_write_limit_setup(33554432);
rldebug_reset_limits();
//
// -----------
//
const int expected_array[] = {10, 2, 3, 6, 4, 5, 4, 5, 5, 7, 10};
int output[] = {1, -2, 0, 0, 1, -2, 1, 2, 1, 2, 0};
printf("#####START#####");
int res = create_histogram((float[]){6.581376, 4.104383, 3.084618, 7.606000, 0.170799, 0.815555, 4.504218, 4.918029, 5.156607, 5.731490, 5.852386, 0.488412, 0.862379, 10.702814, 3.135316, 5.762635, 9.381656, 7.865463, 10.139869, 8.426072, 10.992149, 1.882546, 10.242597, 9.417010, 3.434404, 0.999613, 7.219121, 0.765975, 4.879792, 6.901258, 5.691243, 10.155630, 10.421787, 10.697087, 10.454934, 9.132959, 7.660914, 0.741748, 8.324884, 8.779398, 10.088768, 8.111211, 7.183201, 2.803737, 9.578325, 3.283435, 10.119300, 9.706174, 9.470514, 0.715321, 3.392211, 1.961744, 6.542253, 3.150972, 9.049176, 8.482902, 0.670631, 6.666284, 2.446115, 0.635756, 2.401039}, 61, output, 11);
printf("#####END#####");
test_error(res == 0, "Funkcja create_histogram() powinna zwrócić 0, a zwróciłą %d", res);
int ok = 0;
for (int i = 0; i < 11; ++i)
ok += output[i] != expected_array[i];
if (ok)
{
printf("Powinno być: [10, 2, 3, 6, 4, 5, 4, 5, 5, 7, 10]\n");
printf("\nTablica po wywołaniu funkcji create_histogram: ");
for (int i = 0; i < 11; ++i)
printf("%d ", output[i]);
printf("\n");
test_error(ok == 0, "Funkcja create_histogram() niepoprawnie wypełniła tablicę");
}
//
// -----------
//
// przywrócenie podstawowych parametów przydzielania zasobów (jeśli to tylko możliwe)
rldebug_reset_limits();
test_file_write_limit_restore();
test_ok();
}
//
// Test 3: Sprawdzanie poprawności działania funkcji create_histogram
//
void UTEST3(void)
{
// informacje o teście
test_start(3, "Sprawdzanie poprawności działania funkcji create_histogram", __LINE__);
// uwarunkowanie zasobów - pamięci, itd...
test_file_write_limit_setup(33554432);
rldebug_reset_limits();
//
// -----------
//
const int expected_array[] = {5, 14, 14, 14, 24, 18, 7, 22, 16, 29, 21};
int output[] = {-2, 1, 1, -1, -1, 0, -1, -2, 2, -1, 2};
printf("#####START#####");
int res = create_histogram((float[]){5.962383, 4.826953, 9.404876, 10.328797, 7.862586, 8.645956, 1.279665, 7.951675, 8.116454, 3.347858, 9.987317, 3.027641, 6.700815, 2.259362, 2.467965, 3.645413, 5.471913, 10.414678, 1.867017, 4.793448, 3.001783, 4.054336, 9.973660, 8.867518, 8.311154, 7.454309, 1.560956, 9.168997, 2.350138, 4.135390, 4.412633, 9.219095, 9.910267, 1.683809, 4.234763, 5.013159, 2.196995, 10.422131, 7.990150, 9.168358, 9.756621, 3.623391, 5.815678, 3.493880, 2.556570, 5.528735, 3.605400, 9.586410, 5.398363, 2.842548, 5.589353, 5.584737, 3.019476, 8.200687, 7.872558, 1.725161, 2.562892, 3.220496, 7.277854, 5.003772, 4.179077, 7.819282, 4.059751, 9.769291, 8.639274, 3.811919, 1.809867, 4.797654, 4.894638, 4.103784, 10.181921, 4.497653, 9.492915, 9.257278, 9.618907, 9.337518, 9.026216, 5.339608, 10.835240, 10.820247, 2.840788, 0.678229, 9.325670, 1.035140, 5.539407, 4.779357, 1.046274, 7.440119, 2.560169, 9.114628, 9.040866, 10.487098, 4.004293, 7.136891, 1.028347, 8.050123, 7.795868, 5.059818, 2.762302, 0.067484, 7.438431, 7.665265, 10.759001, 9.567128, 0.989778, 2.928860, 8.195047, 8.274414, 4.723178, 8.215900, 6.633829, 8.531627, 10.314650, 9.595624, 7.033237, 9.475318, 9.256126, 3.486450, 2.425371, 9.819571, 7.903791, 9.704752, 6.758392, 10.741594, 2.353452, 4.295334, 7.452316, 10.186459, 9.394508, 10.674111, 6.624392, 4.089475, 5.469759, 10.388825, 7.497475, 10.542738, 0.375696, 4.697666, 7.174670, 1.564900, 10.455192, 10.623021, 10.369438, 7.713883, 8.177057, 4.209973, 5.445883, 8.239812, 2.589309, 10.508086, 1.114725, 9.297467, 4.208856, 3.564132, 1.852605, 4.894091, 8.510445, 10.909709, 5.698136, 0.451387, 9.886977, 4.655225, 7.294732, 5.231549, 7.937139, 9.394060, 3.534382, 5.640784, 8.404382, 7.565002, 5.265934, 10.225911, 8.880296, 1.361210, 4.223451, 6.681101, 7.966619, 6.875034, 10.752595, 9.362445, 1.056691, 4.036501, 6.090584, 3.443408}, 184, output, 11);
printf("#####END#####");
test_error(res == 0, "Funkcja create_histogram() powinna zwrócić 0, a zwróciłą %d", res);
int ok = 0;
for (int i = 0; i < 11; ++i)
ok += output[i] != expected_array[i];
if (ok)
{
printf("Powinno być: [5, 14, 14, 14, 24, 18, 7, 22, 16, 29, 21]\n");
printf("\nTablica po wywołaniu funkcji create_histogram: ");
for (int i = 0; i < 11; ++i)
printf("%d ", output[i]);
printf("\n");
test_error(ok == 0, "Funkcja create_histogram() niepoprawnie wypełniła tablicę");
}
//
// -----------
//
// przywrócenie podstawowych parametów przydzielania zasobów (jeśli to tylko możliwe)
rldebug_reset_limits();
test_file_write_limit_restore();
test_ok();
}
//
// Test 4: Sprawdzanie poprawności działania funkcji create_histogram
//
void UTEST4(void)
{
// informacje o teście
test_start(4, "Sprawdzanie poprawności działania funkcji create_histogram", __LINE__);
// uwarunkowanie zasobów - pamięci, itd...
test_file_write_limit_setup(33554432);
rldebug_reset_limits();
//
// -----------
//
const int expected_array[] = {0, 0, 0, 0, 2, 0, 1, 1, 1, 0, 0};
int output[] = {1, 0, 0, 0, -2, -2, -1, 2, -1, 1, 0};
printf("#####START#####");
int res = create_histogram((float[]){-8.941533, -6.350933, 4.873966, 4.304706, 7.987963, 8.374607, 6.384291}, 7, output, 11);
printf("#####END#####");
test_error(res == 0, "Funkcja create_histogram() powinna zwrócić 0, a zwróciłą %d", res);
int ok = 0;
for (int i = 0; i < 11; ++i)
ok += output[i] != expected_array[i];
if (ok)
{
printf("Powinno być: [0, 0, 0, 0, 2, 0, 1, 1, 1, 0, 0]\n");
printf("\nTablica po wywołaniu funkcji create_histogram: ");
for (int i = 0; i < 11; ++i)
printf("%d ", output[i]);
printf("\n");
test_error(ok == 0, "Funkcja create_histogram() niepoprawnie wypełniła tablicę");
}
//
// -----------
//
// przywrócenie podstawowych parametów przydzielania zasobów (jeśli to tylko możliwe)
rldebug_reset_limits();
test_file_write_limit_restore();
test_ok();
}
//
// Test 5: Sprawdzanie poprawności działania funkcji create_histogram
//
void UTEST5(void)
{
// informacje o teście
test_start(5, "Sprawdzanie poprawności działania funkcji create_histogram", __LINE__);
// uwarunkowanie zasobów - pamięci, itd...
test_file_write_limit_setup(33554432);
rldebug_reset_limits();
//
// -----------
//
const int expected_array[] = {5, 6, 2, 2, 5, 2, 2, 8, 4, 6, 0};
int output[] = {1, -2, -2, 0, -2, 0, 1, 1, -1, -2, -1};
printf("#####START#####");
int res = create_histogram((float[]){1.934522, 1.986127, 9.761328, -1.421763, -9.202488, 9.686519, -2.851427, 3.689739, 7.343693, -4.983530, 0.543861, 1.124227, -3.538589, 0.921207, -9.880055, 9.299596, 2.405778, -5.572847, -9.905415, -7.472256, -4.082525, -6.733469, 7.767758, 3.772786, -6.879740, 8.547476, 5.003666, 5.456763, 7.224866, 1.507265, 1.735151, 8.633381, 8.236445, 6.092090, 4.911106, 7.347585, 6.239940, 4.169726, -7.184862, 4.853448, -2.261783, 1.819910, -1.705225, -1.459633, -7.811671, -9.030100, -9.028185, -6.539165, 0.703710, -6.568989, 9.971513, 9.367927, -4.390679, 8.387538, 0.798439, 0.881786, 7.926429, -0.355932, 7.264294, 4.934459, 7.431019, -8.828528, -0.992250, -7.064428, -3.508642, 4.680460, -3.405893, -0.892576, -2.291474, 9.557680, 7.413581, -4.380872, 2.445907, -3.857808, -1.980923, -6.264347}, 76, output, 11);
printf("#####END#####");
test_error(res == 0, "Funkcja create_histogram() powinna zwrócić 0, a zwróciłą %d", res);
int ok = 0;
for (int i = 0; i < 11; ++i)
ok += output[i] != expected_array[i];
if (ok)
{
printf("Powinno być: [5, 6, 2, 2, 5, 2, 2, 8, 4, 6, 0]\n");
printf("\nTablica po wywołaniu funkcji create_histogram: ");
for (int i = 0; i < 11; ++i)
printf("%d ", output[i]);
printf("\n");
test_error(ok == 0, "Funkcja create_histogram() niepoprawnie wypełniła tablicę");
}
//
// -----------
//
// przywrócenie podstawowych parametów przydzielania zasobów (jeśli to tylko możliwe)
rldebug_reset_limits();
test_file_write_limit_restore();
test_ok();
}
//
// Test 6: Sprawdzanie poprawności działania funkcji create_histogram
//
void UTEST6(void)
{
// informacje o teście
test_start(6, "Sprawdzanie poprawności działania funkcji create_histogram", __LINE__);
// uwarunkowanie zasobów - pamięci, itd...
test_file_write_limit_setup(33554432);
rldebug_reset_limits();
//
// -----------
//
const int expected_array[] = {2, 2, 2, 7, 2, 1, 3, 4, 1, 4, 0, 1, 3, 3, 3, 3, 3, 1, 2, 5, 0};
int output[] = {2, -1, 2, -2, -2, -2, 1, 0, 0, 2, 1, -1, 1, 2, 0, 2, -1, 0, 1, -2, 1};
printf("#####START#####");
int res = create_histogram((float[]){3.736442, 9.982073, 3.945818, 16.647632, 15.329189, 7.359886, 16.468647, 19.128587, 1.997801, 3.980957, 13.142277, 0.281321, 3.302743, 9.108303, 11.802551, 15.471777, 14.517678, 7.276778, 19.418951, 13.317008, 14.924907, 6.234998, 0.179584, 12.700324, 1.064630, 12.286872, 7.330434, 15.354282, 9.201306, 9.119105, 4.318894, 5.483419, 6.069270, 8.840635, 12.428049, 14.615914, 2.436434, 6.048103, 4.676169, 2.801675, 19.390993, 19.626946, 17.739037, 18.773371, 3.193893, 3.582659, 3.722496, 19.241716, 7.800742, 16.323234, 13.440891, 18.756826}, 52, output, 21);
printf("#####END#####");
test_error(res == 0, "Funkcja create_histogram() powinna zwrócić 0, a zwróciłą %d", res);
int ok = 0;
for (int i = 0; i < 21; ++i)
ok += output[i] != expected_array[i];
if (ok)
{
printf("Powinno być: [2, 2, 2, 7, 2, 1, 3, 4, 1, 4, 0, 1, 3, 3, 3, 3, 3, 1, 2, 5, 0]\n");
printf("\nTablica po wywołaniu funkcji create_histogram: ");
for (int i = 0; i < 21; ++i)
printf("%d ", output[i]);
printf("\n");
test_error(ok == 0, "Funkcja create_histogram() niepoprawnie wypełniła tablicę");
}
//
// -----------
//
// przywrócenie podstawowych parametów przydzielania zasobów (jeśli to tylko możliwe)
rldebug_reset_limits();
test_file_write_limit_restore();
test_ok();
}
//
// Test 7: Sprawdzanie poprawności działania funkcji create_histogram
//
void UTEST7(void)
{
// informacje o teście
test_start(7, "Sprawdzanie poprawności działania funkcji create_histogram", __LINE__);
// uwarunkowanie zasobów - pamięci, itd...
test_file_write_limit_setup(33554432);
rldebug_reset_limits();
//
// -----------
//
const int expected_array[] = {9, 11, 6, 7, 5, 6, 7, 10, 4, 9, 4, 8, 6, 8, 7, 4, 4, 7, 9, 5, 6, 5, 7, 8, 4, 4, 8, 4, 12, 6, 5, 5, 9, 7, 6, 9, 5, 9, 8, 4, 9, 7, 6, 9, 9, 3, 8, 9, 11, 11, 6, 5, 9, 3, 9, 10, 7, 3, 9, 6, 7, 4, 4, 8, 7, 6, 6, 4, 3, 5, 8, 11, 7, 4, 5, 3, 7, 5, 11, 9, 7, 9, 5, 7, 6, 12, 4, 6, 0};
int output[] = {-2, 0, -2, 0, 0, -1, 2, 0, 2, 2, 1, 1, -2, -1, 0, 0, -2, 1, -1, 2, -2, -2, -1, 2, 1, -2, -1, 1, -2, 2, -1, 1, 1, 1, 0, 1, 1, 2, -2, -2, 1, 0, 2, 2, -2, -1, 2, -1, 0, 1, 2, -1, 0, 0, 2, 1, -2, 1, -1, 0, 2, 1, 2, 1, -2, 2, 0, 0, -1, -1, 0, 2, 1, -2, -1, -2, 2, -1, 2, 0, -1, -2, 2, -2, -2, 1, 0, -1, 2};
printf("#####START#####");
int res = create_histogram((float[]){51.186649, 48.861490, 29.193634, 11.700641, 84.263864, 11.811114, 47.361550, 37.294306, 6.432540, 58.544839, 11.424083, 55.697785, 26.706118, 68.288308, 67.913329, 9.831122, 84.607332, 50.248537, 0.990586, 71.645213, 54.010805, 26.425427, 42.346368, 29.549224, 80.187780, 83.469822, 1.014692, 41.024585, 3.386473, 25.374387, 40.915376, 13.507430, 28.845241, 8.338776, 22.456887, 46.617955, 46.638031, 70.154540, 14.564677, 13.922239, 27.385805, 44.620032, 72.491472, 12.667292, 49.982588, 13.873758, 33.186294, 87.755252, 74.536524, 30.543135, 2.561794, 33.079966, 82.681917, 24.282468, 9.548657, 10.145265, 51.950147, 81.753456, 4.754812, 54.192839, 60.835471, 79.097002, 75.122667, 7.347762, 16.580158, 58.351570, 26.009933, 18.077742, 17.136830, 37.150757, 78.390149, 48.439998, 39.547946, 38.712402, 7.287354, 74.129838, 22.265327, 53.412042, 83.764283, 47.764438, 7.380577, 14.847034, 37.192965, 64.734052, 76.903925, 24.374346, 0.171298, 12.859826, 18.669801, 66.291670, 22.658681, 50.359479, 78.374044, 43.980586, 20.692344, 40.018723, 47.317177, 43.413421, 65.277864, 29.382084, 61.849600, 28.490806, 67.012941, 40.654489, 86.582576, 36.720716, 28.090772, 0.816333, 3.828974, 14.400318, 63.770249, 59.522741, 76.328895, 52.891283, 49.004817, 71.398229, 79.925261, 19.058522, 47.133780, 21.757114, 69.658299, 28.871890, 83.269842, 40.182256, 87.510974, 23.488073, 62.814441, 74.595758, 85.121715, 24.749750, 76.348719, 23.529981, 38.922191, 31.643452, 4.854286, 32.973904, 45.629908, 54.488792, 70.099200, 18.349452, 41.387421, 71.058712, 46.928515, 46.155992, 48.715205, 68.036653, 78.680991, 63.327930, 49.573344, 2.643060, 24.422971, 87.715547, 8.348964, 27.992824, 65.584197, 29.021488, 85.066479, 79.156521, 7.176365, 60.143511, 32.581503, 38.874590, 21.692658, 81.592704, 76.853044, 26.237170, 6.750427, 0.942105, 5.276819, 34.995342, 78.704651, 76.802074, 4.217596, 59.547071, 86.892782, 1.693006, 69.135897, 66.011998, 9.349368, 54.658342, 7.939131, 32.190214, 60.741632, 5.997474, 40.999547, 60.654567, 81.256507, 5.297546, 56.649611, 13.278894, 35.779241, 74.780384, 58.862624, 49.844503, 1.516377, 71.990606, 31.852324, 40.456083, 73.638163, 55.254396, 9.736600, 87.990905, 33.537215, 18.616566, 29.438739, 79.191105, 35.277692, 52.234975, 1.729496, 78.431656, 12.202438, 8.517657, 2.116071, 43.469446, 82.410182, 78.794694, 61.572149, 63.403054, 71.365607, 37.056995, 11.168073, 46.739751, 15.442936, 83.735501, 56.685394, 63.902926, 15.783593, 71.973893, 48.082067, 25.154719, 63.159782, 62.192826, 44.473649, 70.189236, 7.815616, 65.701497, 55.802911, 55.410131, 13.040495, 23.720060, 48.694922, 15.956034, 80.914829, 72.230772, 77.427757, 23.536063, 67.556828, 27.844035, 67.802275, 77.260622, 52.653186, 54.858772, 9.530016, 11.902185, 49.534055, 58.048385, 57.211044, 23.419520, 37.563010, 20.065146, 80.977729, 32.335096, 81.160543, 58.120671, 1.200529, 38.755285, 34.089817, 51.403118, 79.063481, 7.685979, 43.279455, 70.920799, 48.400902, 4.929359, 9.748189, 2.614035, 61.977812, 32.265030, 3.083746, 42.648018, 42.413690, 2.692087, 82.101050, 54.263058, 32.801459, 79.414813, 18.300221, 19.410864, 78.467543, 63.238449, 28.701144, 63.209912, 64.812369, 33.655236, 70.267090, 7.647226, 18.880109, 55.230202, 55.924469, 22.479021, 57.697143, 78.426893, 85.364791, 53.760493, 36.805967, 5.978622, 48.371358, 29.915267, 71.790204, 65.600926, 13.882890, 63.124717, 28.540966, 25.260439, 60.156602, 33.476124, 66.012554, 10.238149, 17.308636, 3.478660, 56.857719, 53.434620, 45.230512, 18.413827, 21.499447, 87.310734, 48.030274, 52.920132, 0.597883, 41.452537, 49.254439, 80.273794, 12.745304, 43.909725, 28.325174, 85.359960, 84.700004, 49.771229, 36.087685, 49.470094, 39.480812, 19.648012, 0.182617, 76.703098, 37.510187, 70.841101, 85.349587, 55.248970, 81.922351, 75.646233, 12.031397, 64.012260, 84.080243, 72.934673, 58.643911, 55.171831, 20.183300, 42.950671, 35.465857, 37.114993, 56.855492, 64.461328, 52.943108, 37.897520, 54.591153, 79.487379, 17.986625, 44.648903, 48.225424, 26.138371, 41.429753, 77.111226, 42.018731, 1.777930, 13.819570, 20.292227, 17.512700, 86.807626, 26.923992, 16.558971, 65.043012, 13.879707, 51.277564, 59.353615, 83.145441, 19.555501, 30.047948, 26.633514, 0.277513, 56.178178, 85.182507, 73.715247, 72.077207, 47.703757, 17.858874, 43.494559, 23.192041, 41.098857, 60.347359, 65.533866, 77.035913, 22.921250, 1.787909, 87.509173, 45.512669, 54.770693, 25.984788, 62.630407, 73.180374, 14.725171, 43.189243, 40.701218, 28.246697, 30.064568, 85.208216, 47.947481, 83.282923, 19.053172, 17.893446, 71.830081, 12.924116, 80.781827, 72.765044, 37.510122, 80.764526, 47.264484, 32.506704, 6.780673, 40.832332, 40.047605, 71.629670, 61.200251, 52.375428, 17.770165, 38.445642, 5.337495, 42.609335, 71.050410, 35.673588, 14.097066, 6.910906, 9.674591, 69.607392, 44.912804, 22.623387, 33.255578, 57.587282, 34.562890, 44.566226, 20.923929, 30.058497, 58.980792, 50.722483, 70.487657, 39.346661, 9.397713, 44.803640, 11.185933, 27.821018, 32.253499, 11.482869, 64.533460, 9.312090, 22.188883, 8.505561, 34.345284, 79.117965, 56.620433, 71.798751, 36.823758, 2.303536, 3.259791, 81.211354, 14.814685, 86.172064, 1.791129, 1.874641, 6.963603, 28.991451, 72.281314, 75.716215, 31.465590, 68.680293, 35.585492, 64.183455, 85.433765, 59.171237, 33.759960, 52.063806, 7.555076, 49.668418, 46.393373, 38.285751, 18.393120, 55.820782, 3.183557, 59.454423, 21.665881, 43.711250, 6.473215, 44.369059, 58.935656, 11.240103, 15.069781, 77.775684, 54.422083, 1.641668, 85.267859, 51.878463, 66.227544, 23.622361, 52.143787, 10.708548, 43.958995, 28.296582, 78.966692, 20.825290, 66.486627, 52.654748, 36.696304, 84.528815, 81.137140, 74.869921, 1.437405, 39.056794, 78.256002, 76.222112, 21.726375, 85.125885, 44.192645, 28.552114, 80.357545, 31.464284, 0.383546, 49.283593, 59.793059, 82.415426, 47.190759, 35.252173, 0.226890, 55.161865, 81.088689, 62.501539, 73.674454, 16.985139, 46.388428, 46.007520, 35.728343, 50.721782, 64.323416, 38.355575, 81.869496, 82.754443, 70.368046, 60.317013, 41.082419, 85.113706, 56.454822, 35.210230, 66.123909, 83.701293, 58.842303, 44.374709, 69.986845, 10.132839, 48.748594, 85.769331, 35.669526, 4.250221, 16.199638, 38.722416, 49.702629, 3.096231, 50.216048, 28.013468, 14.686374, 69.996530, 78.325703, 31.947272, 5.025783, 34.110134, 18.436498, 84.967186, 23.875612, 7.017221, 47.504926, 41.472170, 34.308332, 26.715467, 48.459672, 30.566179, 72.441538, 79.695867, 32.681303, 6.204078, 50.899798}, 596, output, 89);
printf("#####END#####");
test_error(res == 0, "Funkcja create_histogram() powinna zwrócić 0, a zwróciłą %d", res);
int ok = 0;
for (int i = 0; i < 89; ++i)
ok += output[i] != expected_array[i];
if (ok)
{
printf("Powinno być: [9, 11, 6, 7, 5, 6, 7, 10, 4, 9, 4, 8, 6, 8, 7, 4, 4, 7, 9, 5, 6, 5, 7, 8, 4, 4, 8, 4, 12, 6, 5, 5, 9, 7, 6, 9, 5, 9, 8, 4, 9, 7, 6, 9, 9, 3, 8, 9, 11, 11, 6, 5, 9, 3, 9, 10, 7, 3, 9, 6, 7, 4, 4, 8, 7, 6, 6, 4, 3, 5, 8, 11, 7, 4, 5, 3, 7, 5, 11, 9, 7, 9, 5, 7, 6, 12, 4, 6, 0]\n");
printf("\nTablica po wywołaniu funkcji create_histogram: ");
for (int i = 0; i < 89; ++i)
printf("%d ", output[i]);
printf("\n");
test_error(ok == 0, "Funkcja create_histogram() niepoprawnie wypełniła tablicę");
}
//
// -----------
//
// przywrócenie podstawowych parametów przydzielania zasobów (jeśli to tylko możliwe)
rldebug_reset_limits();
test_file_write_limit_restore();
test_ok();
}
//
// Test 8: Sprawdzanie poprawności działania funkcji create_histogram
//
void UTEST8(void)
{
// informacje o teście
test_start(8, "Sprawdzanie poprawności działania funkcji create_histogram", __LINE__);
// uwarunkowanie zasobów - pamięci, itd...
test_file_write_limit_setup(33554432);
rldebug_reset_limits();
//
// -----------
//
const int expected_array[] = {4, 8, 9, 5, 12, 6, 5, 12, 10};
int output[] = {0, -2, 2, -1, 0, 2, 1, 0, 0};
printf("#####START#####");
int res = create_histogram((float[]){7.793826, 4.445328, 9.198691, 1.302548, 4.885941, 4.022086, 9.043051, 6.314850, 6.154467, 9.601178, 8.866937, 2.037743, 4.591850, 7.280025, 7.047543, 2.503924, 2.972999, 8.842742, 0.820726, 8.929438, 6.361862, 8.369505, 9.344911, 4.927456, 2.979646, 7.834380, 7.409729, 3.682716, 1.413202, 4.850712, 2.627651, 8.497060, 1.609497, 1.001037, 4.140469, 7.836265, 6.404766, 2.268278, 8.645625, 0.522682, 10.458746, 1.037396, 1.029736, 4.432234, 4.042483, 0.177355, 9.630618, 9.226502, 2.451593, 8.477822, 8.829906, 5.304470, 10.519525, 5.466019, 2.737562, 7.241702, 7.847570, 10.306315, 10.379494, 6.018525, 3.460646, 8.909993, 4.046258, 7.716267, 5.429611, 9.322796, 3.745987, 5.587941, 10.703071, 0.954020, 10.387742, 10.658378, 7.567071, 2.125658, 8.794738, 1.560054, 3.560871, 5.857077, 5.352487, 10.249527, 9.398878, 4.799729, 3.761688, 1.523774, 7.070859, 9.959450, 7.609111, 4.564030, 9.829225}, 89, output, 9);
printf("#####END#####");
test_error(res == 0, "Funkcja create_histogram() powinna zwrócić 0, a zwróciłą %d", res);
int ok = 0;
for (int i = 0; i < 9; ++i)
ok += output[i] != expected_array[i];
if (ok)
{
printf("Powinno być: [4, 8, 9, 5, 12, 6, 5, 12, 10]\n");
printf("\nTablica po wywołaniu funkcji create_histogram: ");
for (int i = 0; i < 9; ++i)
printf("%d ", output[i]);
printf("\n");
test_error(ok == 0, "Funkcja create_histogram() niepoprawnie wypełniła tablicę");
}
//
// -----------
//
// przywrócenie podstawowych parametów przydzielania zasobów (jeśli to tylko możliwe)
rldebug_reset_limits();
test_file_write_limit_restore();
test_ok();
}
//
// Test 9: Sprawdzanie poprawności działania funkcji create_histogram
//
void UTEST9(void)
{
// informacje o teście
test_start(9, "Sprawdzanie poprawności działania funkcji create_histogram", __LINE__);
// uwarunkowanie zasobów - pamięci, itd...
test_file_write_limit_setup(33554432);
rldebug_reset_limits();
//
// -----------
//
const int expected_array[] = {0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0};
int output[] = {-1, 0, -1, -1, 0, 2, 1, -1, -1, 0, -2};
printf("#####START#####");
int res = create_histogram((float[]){3.869228}, 1, output, 11);
printf("#####END#####");
test_error(res == 0, "Funkcja create_histogram() powinna zwrócić 0, a zwróciłą %d", res);
int ok = 0;
for (int i = 0; i < 11; ++i)
ok += output[i] != expected_array[i];
if (ok)
{
printf("Powinno być: [0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0]\n");
printf("\nTablica po wywołaniu funkcji create_histogram: ");
for (int i = 0; i < 11; ++i)
printf("%d ", output[i]);
printf("\n");
test_error(ok == 0, "Funkcja create_histogram() niepoprawnie wypełniła tablicę");
}
//
// -----------
//
// przywrócenie podstawowych parametów przydzielania zasobów (jeśli to tylko możliwe)
rldebug_reset_limits();
test_file_write_limit_restore();
test_ok();
}
//
// Test 10: Sprawdzanie poprawności działania funkcji create_histogram
//
void UTEST10(void)
{
// informacje o teście
test_start(10, "Sprawdzanie poprawności działania funkcji create_histogram", __LINE__);
// uwarunkowanie zasobów - pamięci, itd...
test_file_write_limit_setup(33554432);
rldebug_reset_limits();
//
// -----------
//
const int expected_array[] = {8};
int output[] = {-1};
printf("#####START#####");
int res = create_histogram((float[]){7.659470, 8.931808, 8.532040, 7.894139, 6.734611, 2.746434, 7.796990, 6.618485, 7.726058, 0.284727, 9.171661, 7.209137, 0.954293, 10.033836, 10.733789, 0.374856, 2.064079, 4.299219, 1.458146, 9.275763, 10.773123, 4.781328, 8.887294, 6.870200, 10.674659, 10.253772, 10.381384, 4.332504, 6.432183, 5.578703, 5.422393, 10.397185, 9.099999, 0.373771, 5.009777, 0.700401, 1.637029, 6.918538, 6.316991, 10.773276, 5.789246, 3.421017, 7.442086, 4.491236, 2.953445, 0.171494, 7.613584, 3.388745, 0.294679, 7.175016, 2.614865, 4.608233, 7.874888, 8.273822, 5.614525, 4.820001, 1.247555, 10.069721, 9.371553, 1.182007, 0.709548, 7.462483, 10.997649, 5.816185}, 64, output, 1);
printf("#####END#####");
test_error(res == 0, "Funkcja create_histogram() powinna zwrócić 0, a zwróciłą %d", res);
int ok = 0;
for (int i = 0; i < 1; ++i)
ok += output[i] != expected_array[i];
if (ok)
{
printf("Powinno być: [8]\n");
printf("\nTablica po wywołaniu funkcji create_histogram: ");
for (int i = 0; i < 1; ++i)
printf("%d ", output[i]);
printf("\n");
test_error(ok == 0, "Funkcja create_histogram() niepoprawnie wypełniła tablicę");
}
//
// -----------
//
// przywrócenie podstawowych parametów przydzielania zasobów (jeśli to tylko możliwe)
rldebug_reset_limits();
test_file_write_limit_restore();
test_ok();
}
//
// Test 11: Sprawdzanie poprawności działania funkcji create_histogram
//
void UTEST11(void)
{
// informacje o teście
test_start(11, "Sprawdzanie poprawności działania funkcji create_histogram", __LINE__);
// uwarunkowanie zasobów - pamięci, itd...
test_file_write_limit_setup(33554432);
rldebug_reset_limits();
//
// -----------
//
printf("#####START#####");
int res = create_histogram((float[]){1.265167, 1.568573, 4.539888, 2.261551, 9.978582, 5.580424}, 10, NULL, 17);
printf("#####END#####");
test_error(res == 1, "Funkcja create_histogram() powinna zwrócić 1, a zwróciłą %d", res);
//
// -----------
//
// przywrócenie podstawowych parametów przydzielania zasobów (jeśli to tylko możliwe)
rldebug_reset_limits();
test_file_write_limit_restore();
test_ok();
}
//
// Test 12: Sprawdzanie poprawności działania funkcji create_histogram
//
void UTEST12(void)
{
// informacje o teście
test_start(12, "Sprawdzanie poprawności działania funkcji create_histogram", __LINE__);
// uwarunkowanie zasobów - pamięci, itd...
test_file_write_limit_setup(33554432);
rldebug_reset_limits();
//
// -----------
//
int output[] = {-2, -1, 0, -1, 2, -2, -1, -2, 0, 1, -1};
printf("#####START#####");
int res = create_histogram(NULL, 16, output, 17);
printf("#####END#####");
test_error(res == 1, "Funkcja create_histogram() powinna zwrócić 1, a zwróciłą %d", res);
//
// -----------
//
// przywrócenie podstawowych parametów przydzielania zasobów (jeśli to tylko możliwe)
rldebug_reset_limits();
test_file_write_limit_restore();
test_ok();
}
//
// Test 13: Sprawdzanie poprawności działania funkcji create_histogram
//
void UTEST13(void)
{
// informacje o teście
test_start(13, "Sprawdzanie poprawności działania funkcji create_histogram", __LINE__);
// uwarunkowanie zasobów - pamięci, itd...
test_file_write_limit_setup(33554432);
rldebug_reset_limits();
//
// -----------
//
int output[] = {-2, -1, 0, -1, 2, -2, -1, -2, 0, 1, -1};
printf("#####START#####");
int res = create_histogram((float[]){1.265167, 1.568573, 4.539888, 2.261551, 9.978582, 5.580424}, 0, output, 20);
printf("#####END#####");
test_error(res == 1, "Funkcja create_histogram() powinna zwrócić 1, a zwróciłą %d", res);
//
// -----------
//
// przywrócenie podstawowych parametów przydzielania zasobów (jeśli to tylko możliwe)
rldebug_reset_limits();
test_file_write_limit_restore();
test_ok();
}
//
// Test 14: Sprawdzanie poprawności działania funkcji create_histogram
//
void UTEST14(void)
{
// informacje o teście
test_start(14, "Sprawdzanie poprawności działania funkcji create_histogram", __LINE__);
// uwarunkowanie zasobów - pamięci, itd...
test_file_write_limit_setup(33554432);
rldebug_reset_limits();
//
// -----------
//
int output[] = {-2, -1, 0, -1, 2, -2, -1, -2, 0, 1, -1};
printf("#####START#####");
int res = create_histogram((float[]){1.265167, 1.568573, 4.539888, 2.261551, 9.978582, 5.580424}, 15, output, 0);
printf("#####END#####");
test_error(res == 1, "Funkcja create_histogram() powinna zwrócić 1, a zwróciłą %d", res);
//
// -----------
//
// przywrócenie podstawowych parametów przydzielania zasobów (jeśli to tylko możliwe)
rldebug_reset_limits();
test_file_write_limit_restore();
test_ok();
}
//
// Test 15: Sprawdzanie poprawności działania funkcji create_histogram
//
void UTEST15(void)
{
// informacje o teście
test_start(15, "Sprawdzanie poprawności działania funkcji create_histogram", __LINE__);
// uwarunkowanie zasobów - pamięci, itd...
test_file_write_limit_setup(33554432);
rldebug_reset_limits();
//
// -----------
//
int output[] = {-2, -1, 0, -1, 2, -2, -1, -2, 0, 1, -1};
printf("#####START#####");
int res = create_histogram((float[]){1.265167, 1.568573, 4.539888, 2.261551, 9.978582, 5.580424}, -17, output, 16);
printf("#####END#####");
test_error(res == 1, "Funkcja create_histogram() powinna zwrócić 1, a zwróciłą %d", res);
//
// -----------
//
// przywrócenie podstawowych parametów przydzielania zasobów (jeśli to tylko możliwe)
rldebug_reset_limits();
test_file_write_limit_restore();
test_ok();
}
//
// Test 16: Sprawdzanie poprawności działania funkcji create_histogram
//
void UTEST16(void)
{
// informacje o teście
test_start(16, "Sprawdzanie poprawności działania funkcji create_histogram", __LINE__);
// uwarunkowanie zasobów - pamięci, itd...
test_file_write_limit_setup(33554432);
rldebug_reset_limits();
//
// -----------
//
int output[] = {-2, -1, 0, -1, 2, -2, -1, -2, 0, 1, -1};
printf("#####START#####");
int res = create_histogram((float[]){1.265167, 1.568573, 4.539888, 2.261551, 9.978582, 5.580424}, 13, output, -18);
printf("#####END#####");
test_error(res == 1, "Funkcja create_histogram() powinna zwrócić 1, a zwróciłą %d", res);
//
// -----------
//
// przywrócenie podstawowych parametów przydzielania zasobów (jeśli to tylko możliwe)
rldebug_reset_limits();
test_file_write_limit_restore();
test_ok();
}
//
// Test 17: Sprawdzanie poprawności działania funkcji display
//
void UTEST17(void)
{
// informacje o teście
test_start(17, "Sprawdzanie poprawności działania funkcji display", __LINE__);
// uwarunkowanie zasobów - pamięci, itd...
test_file_write_limit_setup(33554432);
rldebug_reset_limits();
//
// -----------
//
int tab[] = {0, -9, 0, 1, 3, -4};
//-------------1-----------------------
printf("\n***TEST 1***\n\n");
printf("***START***\n");
display_vector(tab, 0);
printf("***END***\n");
//-------------2-----------------------
printf("\n***TEST 2***\n\n");
printf("***START***\n");
display_vector(tab, -6);
printf("***END***\n");
//-------------3-----------------------
printf("\n***TEST 3***\n\n");
printf("***START***\n");
display_vector(tab, 6);
printf("***END***\n");
//-------------4-----------------------
printf("\n***TEST 4***\n\n");
printf("***START***\n");
display_vector(tab, 6 - 1);
printf("***END***\n");
onerror_terminate(); // przerwanie wszystkich testów jednostkowych (np. coś jest mocno nie tak z kodem)
//
// -----------
//
// przywrócenie podstawowych parametów przydzielania zasobów (jeśli to tylko możliwe)
rldebug_reset_limits();
test_file_write_limit_restore();
test_ok();
}
//
// Test 18: Sprawdzanie poprawności działania funkcji read_vector_float
//
void UTEST18(void)
{
// informacje o teście
test_start(18, "Sprawdzanie poprawności działania funkcji read_vector_float", __LINE__);
// uwarunkowanie zasobów - pamięci, itd...
test_file_write_limit_setup(33554432);
rldebug_reset_limits();
//
// -----------
//
const int expected_result = 8;
const float expected_array[] = {9.000000, -5.000000, -4.000000, -3.000000, -8.000000, 3.000000, -8.000000, -4.000000, 0.000000};
float dest[9];
int result = read_vector_float(dest, 9, 0);
test_error(result == expected_result, "Funkcja read_vector_float() powinna zwrócić %d, a zwróciła %d", expected_result, result);
int ok = 0;
for (int i = 0; i < expected_result; ++i)
ok += !(expected_array[i] + 0.001 >= dest[i] && expected_array[i] - 0.001 <= dest[i]);
test_error(ok == 0, "Funkcja read_vector_float() niepoprawnie pobrałá dane od użytkownika");
if (ok)
{
printf("Powinno być: [9.000000, -5.000000, -4.000000, -3.000000, -8.000000, 3.000000, -8.000000, -4.000000, 0.000000]\n");
printf("Jest: [");
for (int i = 0; i < expected_result - 1; ++i)
printf("%f, ", dest[i]);
printf("%f] ", dest[expected_result - 1]);
}
//
// -----------
//
// przywrócenie podstawowych parametów przydzielania zasobów (jeśli to tylko możliwe)
rldebug_reset_limits();
test_file_write_limit_restore();
test_ok();
}
//
// Test 19: Sprawdzanie poprawności działania funkcji read_vector_float
//
void UTEST19(void)
{
// informacje o teście
test_start(19, "Sprawdzanie poprawności działania funkcji read_vector_float", __LINE__);
// uwarunkowanie zasobów - pamięci, itd...
test_file_write_limit_setup(33554432);
rldebug_reset_limits();
//
// -----------
//
const int expected_result = 9;
const float expected_array[] = {-9.000000, -10.000000, -4.000000, 0.000000, -3.000000, 4.000000, -7.000000, 0.000000, 2.000000, -6.000000};
float dest[10];
int result = read_vector_float(dest, 10, -6);
test_error(result == expected_result, "Funkcja read_vector_float() powinna zwrócić %d, a zwróciła %d", expected_result, result);
int ok = 0;
for (int i = 0; i < expected_result; ++i)
ok += !(expected_array[i] + 0.001 >= dest[i] && expected_array[i] - 0.001 <= dest[i]);
test_error(ok == 0, "Funkcja read_vector_float() niepoprawnie pobrałá dane od użytkownika");
if (ok)
{
printf("Powinno być: [-9.000000, -10.000000, -4.000000, 0.000000, -3.000000, 4.000000, -7.000000, 0.000000, 2.000000, -6.000000]\n");
printf("Jest: [");
for (int i = 0; i < expected_result - 1; ++i)
printf("%f, ", dest[i]);
printf("%f] ", dest[expected_result - 1]);
}
//
// -----------
//
// przywrócenie podstawowych parametów przydzielania zasobów (jeśli to tylko możliwe)
rldebug_reset_limits();
test_file_write_limit_restore();
test_ok();
}
//
// Test 20: Sprawdzanie poprawności działania funkcji read_vector_float
//
void UTEST20(void)
{
// informacje o teście
test_start(20, "Sprawdzanie poprawności działania funkcji read_vector_float", __LINE__);
// uwarunkowanie zasobów - pamięci, itd...
test_file_write_limit_setup(33554432);
rldebug_reset_limits();
//
// -----------
//
const int expected_result = 0;
const float expected_array[] = {0.000000};
float dest[5];
int result = read_vector_float(dest, 5, 0);
test_error(result == expected_result, "Funkcja read_vector_float() powinna zwrócić %d, a zwróciła %d", expected_result, result);
int ok = 0;
for (int i = 0; i < expected_result; ++i)
ok += !(expected_array[i] + 0.001 >= dest[i] && expected_array[i] - 0.001 <= dest[i]);
test_error(ok == 0, "Funkcja read_vector_float() niepoprawnie pobrałá dane od użytkownika");
if (ok)
{
printf("Powinno być: [0.000000]\n");
printf("Jest: [");
for (int i = 0; i < expected_result - 1; ++i)
printf("%f, ", dest[i]);
printf("%f] ", dest[expected_result - 1]);
}
//
// -----------
//
// przywrócenie podstawowych parametów przydzielania zasobów (jeśli to tylko możliwe)
rldebug_reset_limits();
test_file_write_limit_restore();
test_ok();
}
//
// Test 21: Sprawdzanie poprawności działania funkcji read_vector_float
//
void UTEST21(void)
{
// informacje o teście
test_start(21, "Sprawdzanie poprawności działania funkcji read_vector_float", __LINE__);
// uwarunkowanie zasobów - pamięci, itd...
test_file_write_limit_setup(33554432);
rldebug_reset_limits();
//
// -----------
//
const int expected_result = 10;
const float expected_array[] = {-5.000000, 2.000000, 5.000000, 8.000000, -1.000000, 9.000000, 2.000000, 5.000000, 9.000000, 0.000000};
float dest[10];
int result = read_vector_float(dest, 10, -2);
test_error(result == expected_result, "Funkcja read_vector_float() powinna zwrócić %d, a zwróciła %d", expected_result, result);
int ok = 0;
for (int i = 0; i < expected_result; ++i)
ok += !(expected_array[i] + 0.001 >= dest[i] && expected_array[i] - 0.001 <= dest[i]);
test_error(ok == 0, "Funkcja read_vector_float() niepoprawnie pobrałá dane od użytkownika");
if (ok)
{
printf("Powinno być: [-5.000000, 2.000000, 5.000000, 8.000000, -1.000000, 9.000000, 2.000000, 5.000000, 9.000000, 0.000000]\n");
printf("Jest: [");
for (int i = 0; i < expected_result - 1; ++i)
printf("%f, ", dest[i]);
printf("%f] ", dest[expected_result - 1]);
}
//
// -----------
//
// przywrócenie podstawowych parametów przydzielania zasobów (jeśli to tylko możliwe)
rldebug_reset_limits();
test_file_write_limit_restore();
test_ok();
}
//
// Test 22: Sprawdzanie poprawności działania funkcji read_vector_float
//
void UTEST22(void)
{
// informacje o teście
test_start(22, "Sprawdzanie poprawności działania funkcji read_vector_float", __LINE__);
// uwarunkowanie zasobów - pamięci, itd...
test_file_write_limit_setup(33554432);
rldebug_reset_limits();
//
// -----------
//
int expected_result = -1;
float dest[7];
printf("#####START#####");
int result = read_vector_float(dest, 0, 9);
printf("#####END#####");
test_error(result == expected_result, "Funkcja read_vector_float() powinna zwrócić %d, a zwróciła %d", expected_result, result);
//
// -----------
//
// przywrócenie podstawowych parametów przydzielania zasobów (jeśli to tylko możliwe)
rldebug_reset_limits();
test_file_write_limit_restore();
test_ok();
}
//
// Test 23: Sprawdzanie poprawności działania funkcji read_vector_float
//
void UTEST23(void)
{
// informacje o teście
test_start(23, "Sprawdzanie poprawności działania funkcji read_vector_float", __LINE__);
// uwarunkowanie zasobów - pamięci, itd...
test_file_write_limit_setup(33554432);
rldebug_reset_limits();
//
// -----------
//
int expected_result = -1;
float dest[8];
printf("#####START#####");
int result = read_vector_float(dest, -4, -7);
printf("#####END#####");
test_error(result == expected_result, "Funkcja read_vector_float() powinna zwrócić %d, a zwróciła %d", expected_result, result);
//
// -----------
//
// przywrócenie podstawowych parametów przydzielania zasobów (jeśli to tylko możliwe)
rldebug_reset_limits();
test_file_write_limit_restore();
test_ok();
}
//
// Test 24: Sprawdzanie poprawności działania funkcji read_vector_float
//
void UTEST24(void)
{
// informacje o teście
test_start(24, "Sprawdzanie poprawności działania funkcji read_vector_float", __LINE__);
// uwarunkowanie zasobów - pamięci, itd...
test_file_write_limit_setup(33554432);
rldebug_reset_limits();
//
// -----------
//
int expected_result = -1;
printf("#####START#####");
int result = read_vector_float(NULL, -2, 5);
printf("#####END#####");
test_error(result == expected_result, "Funkcja read_vector_float() powinna zwrócić %d, a zwróciła %d", expected_result, result);
//
// -----------
//
// przywrócenie podstawowych parametów przydzielania zasobów (jeśli to tylko możliwe)
rldebug_reset_limits();
test_file_write_limit_restore();
test_ok();
}
enum run_mode_t { rm_normal_with_rld = 0, rm_unit_test = 1, rm_main_test = 2 };
int __wrap_main(volatile int _argc, char** _argv, char** _envp)
{
int volatile vargc = _argc;
char ** volatile vargv = _argv, ** volatile venvp = _envp;
volatile enum run_mode_t run_mode = rm_unit_test; // -1
volatile int selected_test = -1;
if (vargc > 1)
{
char* smode = strtok(vargv[1], ",");
char* stest = strtok(NULL, "");
char *errptr = NULL;
run_mode = (enum run_mode_t)strtol(smode, &errptr, 10);
if (*errptr == '\x0')
{
memmove(vargv + 1, vargv + 2, sizeof(char*) * (vargc - 1));
vargc--;
if (stest != NULL)
{
int val = (int)strtol(stest, &errptr, 10);
if (*errptr == '\x0')
selected_test = val;
}
}
}
// printf("runmode=%d; selected_test=%d\n", run_mode, selected_test);
// inicjuj testy jednostkowe
unit_test_init(run_mode, "unit_test_v2.c");
test_limit_init();
rldebug_set_reported_severity_level(MSL_FAILURE);
if (run_mode == rm_normal_with_rld)
{
// konfiguracja ograniczników
rldebug_reset_limits();
// uruchom funkcję main Studenta a potem wyświetl podsumowanie sterty i zasobów
volatile int ret_code = rdebug_call_main(tested_main, vargc, vargv, venvp);
rldebug_reset_limits();
int leaks_detected = rldebug_show_leaked_resources(0);
if (leaks_detected)
raise(SIGHEAP);
return ret_code;
}
if (run_mode == rm_unit_test)
{
test_title("Testy jednostkowe");
void (*pfcn[])(void) =
{
UTEST1, // Sprawdzanie poprawności działania funkcji create_histogram
UTEST2, // Sprawdzanie poprawności działania funkcji create_histogram
UTEST3, // Sprawdzanie poprawności działania funkcji create_histogram
UTEST4, // Sprawdzanie poprawności działania funkcji create_histogram
UTEST5, // Sprawdzanie poprawności działania funkcji create_histogram
UTEST6, // Sprawdzanie poprawności działania funkcji create_histogram
UTEST7, // Sprawdzanie poprawności działania funkcji create_histogram
UTEST8, // Sprawdzanie poprawności działania funkcji create_histogram
UTEST9, // Sprawdzanie poprawności działania funkcji create_histogram
UTEST10, // Sprawdzanie poprawności działania funkcji create_histogram
UTEST11, // Sprawdzanie poprawności działania funkcji create_histogram
UTEST12, // Sprawdzanie poprawności działania funkcji create_histogram
UTEST13, // Sprawdzanie poprawności działania funkcji create_histogram
UTEST14, // Sprawdzanie poprawności działania funkcji create_histogram
UTEST15, // Sprawdzanie poprawności działania funkcji create_histogram
UTEST16, // Sprawdzanie poprawności działania funkcji create_histogram
UTEST17, // Sprawdzanie poprawności działania funkcji display
UTEST18, // Sprawdzanie poprawności działania funkcji read_vector_float
UTEST19, // Sprawdzanie poprawności działania funkcji read_vector_float
UTEST20, // Sprawdzanie poprawności działania funkcji read_vector_float
UTEST21, // Sprawdzanie poprawności działania funkcji read_vector_float
UTEST22, // Sprawdzanie poprawności działania funkcji read_vector_float
UTEST23, // Sprawdzanie poprawności działania funkcji read_vector_float
UTEST24, // Sprawdzanie poprawności działania funkcji read_vector_float
NULL
};
for (int idx = 0; pfcn[idx] != NULL && !test_get_session_termination_flag(); idx++)
{
if (selected_test == -1 || selected_test == idx + 1)
pfcn[idx]();
// limit niezaliczonych testów, po jakim testy jednostkowe zostaną przerwane
if (test_session_get_fail_count() >= 1000)
test_terminate_session();
}
test_title("RLDebug :: Analiza wycieku zasobów");
// sprawdź wycieki pamięci
int leaks_detected = rldebug_show_leaked_resources(1);
test_set_session_leaks(leaks_detected);
// poinformuj serwer Mrówka o wyniku testu - podsumowanie
test_title("Podsumowanie");
if (selected_test == -1)
test_summary(24); // wszystkie testy muszą zakończyć się sukcesem
else
test_summary(1); // tylko jeden (selected_test) test musi zakończyć się sukcesem
return EXIT_SUCCESS;
}
if (run_mode == rm_main_test)
{
test_title("Testy funkcji main()");
void (*pfcn[])(int, char**, char**) =
{
NULL
};
for (volatile int idx = 0; pfcn[idx] != NULL && !test_get_session_termination_flag(); idx++)
{
if (selected_test == -1 || selected_test == idx + 1)
pfcn[idx](vargc, vargv, venvp);
// limit niezaliczonych testów, po jakim testy jednostkowe zostaną przerwane
if (test_session_get_fail_count() >= 1000)
test_terminate_session();
}
test_title("RLDebug :: Analiza wycieku zasobów");
// sprawdź wycieki pamięci
int leaks_detected = rldebug_show_leaked_resources(1);
test_set_session_leaks(leaks_detected);
// poinformuj serwer Mrówka o wyniku testu - podsumowanie
test_title("Podsumowanie");
if (selected_test == -1)
test_summary(0); // wszystkie testy muszą zakończyć się sukcesem
else
test_summary(1); // tylko jeden (selected_test) test musi zakończyć się sukcesem
return EXIT_SUCCESS;
}
printf("*** Nieznana wartość RunMode: %d", (int)run_mode);
abort();
}