/*
* Unit Test Bootstrap
* Autor: Tomasz Jaworski, 2018-2019
*
* Test dla zadania Histogram
* Autor testowanej odpowiedzi: Szymon Ptak
* Test wygenerowano automatycznie o 2019-08-22 16:58:29.037090
*
* 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, 0, 1, 0, 1, 1, 0};
int output[] = {1, -2, 1, 2, -2, -1, -2, -1, 1, 2, -1};
printf("#####START#####");
int res = create_histogram((float[]){2.079354, 1.298639, 9.980747, 6.611050, 4.687394, 8.521648, 1.406375}, 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, 2, 1, 0, 1, 0, 1, 0, 1, 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[] = {3, 2, 3, 1, 4, 1, 3, 1, 3, 3, 0};
int output[] = {1, 2, -1, 0, -2, -1, 2, 0, 0, 1, -2};
printf("#####START#####");
int res = create_histogram((float[]){5.374491, 7.207543, 4.975913, 6.772476, 0.820902, 8.148508, 4.318296, 4.500961, 0.577707, 2.557908, 4.527834, 2.451068, 6.027019, 3.469917, 9.007316, 1.643919, 1.782168, 8.838470, 9.041172, 6.538383, 9.013806, 2.920294, 8.932158, 0.534055}, 24, 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ć: [3, 2, 3, 1, 4, 1, 3, 1, 3, 3, 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 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[] = {21, 17, 16, 11, 14, 18, 17, 16, 13, 14, 15};
int output[] = {-2, 1, 0, -1, -1, -1, 0, 0, 1, 1, 2};
printf("#####START#####");
int res = create_histogram((float[]){2.971251, 10.532063, 10.351250, 3.503601, 0.237019, 1.944917, 8.264291, 2.424313, 5.560197, 0.941553, 8.737464, 1.409597, 6.491794, 6.247924, 7.680040, 7.320143, 5.335009, 6.151534, 0.940232, 2.198322, 1.864146, 4.735237, 8.345357, 3.039045, 3.238400, 1.643685, 2.624906, 10.327631, 10.865508, 9.545410, 1.582637, 2.661185, 6.540227, 0.866656, 4.213946, 7.133925, 0.062057, 5.981680, 4.592547, 9.403832, 3.396051, 7.917683, 0.167116, 10.167390, 9.600927, 1.116722, 6.087449, 2.151990, 5.188066, 2.463140, 2.337099, 3.671940, 10.714648, 6.363047, 9.612112, 3.801717, 2.662126, 9.104825, 2.858022, 0.121178, 6.141873, 0.641751, 10.969316, 2.931204, 4.896709, 5.281161, 10.272709, 0.567647, 6.164236, 5.014013, 3.411259, 2.132147, 9.189335, 6.428067, 7.142917, 6.438064, 0.742736, 3.501235, 8.944931, 1.877800, 4.204900, 5.523284, 1.809656, 2.440491, 9.597028, 1.532406, 8.306794, 5.576981, 4.062222, 5.763967, 9.342914, 1.558364, 7.854959, 8.415316, 1.552426, 6.262071, 7.212231, 7.051085, 10.942269, 10.359880, 9.719826, 0.181352, 1.851558, 9.054353, 4.318041, 7.150403, 0.937867, 1.886305, 5.867318, 7.550228, 0.669427, 10.190464, 7.744484, 4.387541, 2.203454, 4.318508, 5.196322, 0.852629, 10.491284, 4.992293, 5.805000, 7.056366, 0.474448, 6.289852, 3.270523, 0.719838, 5.478993, 9.256796, 1.118132, 5.068891, 1.675183, 0.372925, 7.371157, 5.294513, 8.278354, 0.332487, 4.300317, 2.849838, 8.975888, 8.014492, 3.672000, 8.493446, 0.184392, 4.315213, 5.586095, 2.162521, 9.963490, 1.719040, 6.760546, 10.326027, 8.607919, 3.080183, 8.056861, 7.924764, 5.326739, 10.131665, 0.681334, 8.338720, 7.552133, 6.954789, 0.491400, 4.493460, 9.283602, 9.699311, 6.279860, 10.402923, 6.836144, 5.572951, 4.615737, 1.252247, 7.143627, 6.918847}, 172, 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ć: [21, 17, 16, 11, 14, 18, 17, 16, 13, 14, 15]\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[] = {1, 0, 0, 0, 0, 0, 0, 1, 0, 2, 0};
int output[] = {1, 1, -2, 1, 2, -2, 1, 2, 2, 0, -2};
printf("#####START#####");
int res = create_histogram((float[]){-3.140885, 7.842987, -8.608753, 9.404327, 0.188129, -2.530612, -5.104373, 9.959954}, 8, 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ć: [1, 0, 0, 0, 0, 0, 0, 1, 0, 2, 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[] = {4, 3, 4, 3, 2, 5, 8, 6, 6, 4, 0};
int output[] = {1, 0, -1, 2, -2, 2, 0, -1, 0, 1, 2};
printf("#####START#####");
int res = create_histogram((float[]){-8.344509, -7.265411, 7.577315, -2.557557, 0.629065, 9.739570, 8.935271, 0.187308, 1.965935, -6.792230, 9.986018, -7.947483, 7.716884, 6.987607, -2.635081, 6.238815, -1.977882, 7.807921, 6.509791, 3.952074, -3.967778, 6.574709, 1.782510, -0.894494, -8.687188, 2.305738, -8.063497, 2.642590, -4.947779, 6.015915, 5.306425, 8.822263, 9.477136, -0.540486, -1.886216, 0.062138, -2.047606, 9.182528, 2.918535, 7.010967, 6.215959, -6.513272, -6.198336, 3.001894, 2.871685, -1.109946, -1.237070, 4.110574, -2.916137, 5.768061, 5.094953, 5.035360, 6.551903, 0.316099, 3.932451, 5.489147, -2.836773, 7.265221, 4.135836, 7.480828, -3.354223, 8.406453, -8.981008, -7.718090, 1.916545, -5.025684, -1.245728, 6.957267, 8.765231, 8.259541, -3.882501, -2.305001, 8.454265}, 73, 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ć: [4, 3, 4, 3, 2, 5, 8, 6, 6, 4, 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, 1, 3, 6, 1, 5, 2, 4, 6, 2, 1, 2, 1, 3, 3, 2, 3, 2, 1, 3, 0};
int output[] = {-2, 1, 1, 0, 0, -2, -1, 2, 2, 2, 1, 1, -1, 2, 0, -2, 2, 2, 0, -1, -1};
printf("#####START#####");
int res = create_histogram((float[]){2.077111, 2.486340, 5.986842, 0.137882, 16.991787, 19.303461, 9.780011, 15.428306, 7.378279, 5.174089, 3.723958, 16.476202, 8.644613, 11.626176, 2.066473, 1.250111, 5.702250, 4.092247, 17.184283, 0.939935, 18.555623, 6.629693, 3.497026, 10.783198, 8.044615, 12.412033, 13.658179, 8.433459, 7.997042, 14.394798, 3.403842, 3.410426, 6.792315, 7.473718, 17.272421, 14.066902, 19.094221, 8.948042, 3.209837, 5.050461, 9.800049, 16.419375, 13.662974, 19.210327, 14.930049, 15.555489, 7.642173, 11.949603, 8.220507, 8.314476, 13.250571, 5.474891, 3.521439}, 53, 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, 1, 3, 6, 1, 5, 2, 4, 6, 2, 1, 2, 1, 3, 3, 2, 3, 2, 1, 3, 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[] = {6, 6, 7, 8, 8, 8, 11, 6, 3, 7, 7, 9, 5, 8, 6, 5, 7, 7, 2, 3, 6, 4, 6, 1, 8, 5, 3, 4, 4, 8, 5, 6, 3, 1, 8, 8, 4, 6, 4, 8, 8, 9, 8, 3, 11, 4, 7, 3, 12, 8, 9, 6, 7, 8, 7, 8, 8, 14, 4, 13, 8, 4, 8, 1, 7, 4, 10, 6, 3, 3, 16, 13, 8, 7, 12, 8, 8, 3, 10, 7, 7, 9, 4, 10, 7, 10, 4, 9, 5, 8, 7, 4, 10, 6, 7, 6, 7, 7, 10, 6, 0};
int output[] = {2, -2, 1, -2, 0, -2, 1, 2, 0, -1, 0, 0, 1, 2, 2, 0, -1, 0, -1, 2, -1, -2, -1, 1, 2, 0, -2, 2, 2, 1, 1, -2, 0, -1, -1, -2, 1, 1, 1, -2, 0, 1, -2, 0, -2, -1, 2, 2, 2, -1, -1, -2, 1, -1, 2, 0, 0, 1, -2, -2, -2, 2, 0, 0, 2, 2, -1, 2, -2, -2, -2, -1, -1, -2, -1, 1, 0, 1, -2, -2, 2, 0, 2, -2, 0, 0, -1, 1, 1, -1, -2, 1, 2, 0, 1, 1, -1, 0, 2, 2, 1};
printf("#####START#####");
int res = create_histogram((float[]){73.339284, 16.918058, 3.955384, 89.178841, 1.791924, 60.952355, 57.603179, 81.129731, 21.665027, 80.863007, 9.031085, 11.546976, 7.066245, 67.465166, 59.787254, 73.672263, 82.143342, 90.328321, 94.931187, 76.931118, 83.346911, 74.921745, 29.738263, 66.468867, 48.514666, 11.488006, 9.068360, 13.329579, 93.063670, 71.562328, 59.043121, 57.773596, 96.721970, 40.907770, 17.766853, 6.822197, 64.630624, 72.407559, 71.185618, 94.486437, 14.684870, 98.419081, 11.856998, 13.772838, 59.050867, 94.041814, 54.805689, 53.230600, 7.378249, 5.269991, 89.748214, 98.212415, 2.763090, 85.980998, 70.527672, 57.227540, 88.567408, 78.863225, 67.926937, 92.444385, 97.634192, 51.543866, 95.996717, 91.948627, 85.629866, 53.080631, 85.061520, 45.843830, 22.752840, 8.182243, 84.116278, 47.084070, 73.671840, 7.824538, 18.819847, 93.512201, 74.816053, 52.989355, 58.998230, 87.379239, 89.547809, 62.206613, 82.453976, 57.757294, 54.700587, 53.504905, 26.500782, 55.448171, 26.040042, 43.838145, 32.487289, 91.606613, 35.699598, 14.889812, 2.012609, 60.251242, 22.317721, 67.360000, 34.211289, 74.965765, 87.989278, 70.319931, 29.648991, 3.321462, 78.219732, 52.227505, 55.536639, 6.774660, 28.985253, 57.566803, 64.301172, 6.705058, 9.016966, 61.306251, 37.870409, 4.626243, 57.046287, 91.326730, 72.653290, 70.042581, 78.845708, 1.342110, 62.643865, 44.335320, 5.164656, 39.508518, 44.759651, 5.910974, 92.075967, 50.541373, 99.799961, 44.268137, 84.121856, 90.111226, 98.375042, 48.754398, 12.400503, 45.610935, 43.656833, 70.135785, 59.945533, 60.290794, 46.780862, 74.312796, 35.126166, 31.791299, 35.698865, 37.953908, 53.099786, 41.546131, 71.527407, 87.014670, 10.292350, 46.721293, 53.158101, 69.526474, 24.737560, 93.215930, 91.047873, 70.290137, 42.956530, 12.953585, 74.538367, 34.372547, 71.188559, 3.211368, 13.920079, 81.062051, 39.456115, 70.639466, 56.721219, 96.659821, 4.328911, 79.749099, 84.353735, 67.175712, 89.245128, 83.194699, 34.890943, 83.656369, 57.238421, 4.442276, 61.778143, 95.378546, 15.787148, 41.078738, 90.132160, 6.789988, 70.074769, 75.346909, 21.350501, 34.969316, 14.164300, 12.784392, 39.486319, 42.618310, 75.116459, 49.034602, 25.192402, 81.813494, 79.642297, 66.834126, 56.616358, 0.877865, 76.349794, 55.440988, 57.242113, 78.323765, 98.246066, 89.610374, 83.427990, 80.266473, 0.823693, 53.231874, 83.391687, 36.829729, 10.356101, 2.247507, 92.367067, 20.360868, 14.502308, 55.261445, 10.152820, 40.127580, 66.643215, 87.141079, 8.728670, 42.418554, 97.484870, 88.462003, 79.138501, 56.283948, 20.137135, 69.900755, 68.412287, 71.608073, 54.477461, 73.070282, 2.653707, 3.031142, 71.435574, 84.278350, 57.896672, 31.259534, 90.419626, 74.853625, 44.043196, 24.624265, 49.184864, 17.579147, 37.847113, 75.461577, 4.359319, 16.502244, 73.788072, 6.846665, 92.718706, 83.409720, 70.968185, 38.506279, 64.309542, 34.863916, 24.611641, 48.513201, 30.818236, 87.071622, 84.231271, 68.832737, 71.698991, 73.098627, 27.539900, 50.977598, 11.696318, 0.721971, 72.749984, 16.263656, 67.687983, 96.085346, 57.892436, 93.607345, 31.543208, 4.023785, 39.917383, 14.705009, 71.349315, 96.152061, 80.264123, 27.728947, 48.906233, 89.725871, 59.280156, 39.947651, 12.893241, 81.888535, 48.089312, 10.069990, 62.632428, 79.534545, 41.210659, 78.761066, 78.787852, 84.753709, 51.649613, 74.558611, 52.081252, 34.506993, 76.730286, 50.575350, 39.707901, 85.459741, 7.956209, 3.011483, 92.946283, 98.644068, 99.322601, 96.895220, 44.027981, 40.434406, 77.852715, 45.261461, 20.863039, 6.310068, 66.694547, 49.138592, 59.316309, 72.520826, 22.477836, 29.704070, 49.854218, 92.771428, 74.228022, 87.602872, 30.549586, 40.537430, 62.899907, 95.043879, 57.902877, 51.893694, 59.787612, 75.499819, 86.834705, 44.781418, 70.026034, 82.554433, 88.638814, 98.716089, 10.677266, 95.829279, 79.364551, 40.171566, 25.775848, 44.363567, 75.748663, 15.825109, 65.250220, 44.211940, 86.300038, 74.975753, 56.828923, 25.953692, 35.070368, 80.030718, 85.135615, 4.303835, 96.910178, 70.563347, 11.947488, 81.650827, 49.992654, 46.186880, 1.524180, 96.133877, 61.613066, 65.171661, 67.718695, 37.880724, 77.738490, 9.104755, 73.874516, 24.913869, 4.790803, 85.377478, 58.119774, 87.205277, 7.006450, 19.297169, 29.897160, 92.290205, 24.299194, 38.779873, 13.749497, 35.609999, 98.603586, 60.660308, 31.960866, 97.238855, 51.123105, 30.195606, 27.943277, 78.846443, 97.463857, 34.589445, 12.346764, 76.212550, 97.984274, 5.871891, 64.319966, 11.104860, 49.638151, 95.070471, 75.661507, 64.512975, 74.012726, 34.251088, 62.495224, 64.494220, 92.710279, 70.582915, 0.589475, 97.151799, 57.138242, 66.075447, 39.770874, 99.002891, 75.070617, 90.657701, 97.540441, 6.453959, 13.799998, 46.954382, 53.762455, 49.941927, 78.264688, 13.246561, 78.510119, 28.781255, 32.639063, 17.645911, 24.880148, 52.070246, 60.798288, 21.662597, 25.795119, 60.735445, 11.453691, 90.883117, 82.820476, 70.529817, 31.412356, 70.260000, 41.722706, 36.267505, 22.771993, 9.109721, 55.543972, 99.535552, 24.593059, 29.384451, 59.341237, 46.675850, 98.177347, 66.268429, 16.822882, 2.999810, 50.227374, 71.708444, 59.966824, 79.501970, 16.713959, 26.978428, 56.455868, 81.748851, 6.401813, 72.509678, 70.475757, 51.490603, 27.407898, 41.969200, 66.805056, 80.768901, 48.582107, 48.386159, 15.757649, 94.769497, 3.633630, 48.242495, 9.640561, 46.926339, 59.779691, 48.626560, 50.997137, 55.571853, 70.330810, 72.229619, 42.442255, 85.514333, 17.042680, 62.163794, 57.707914, 71.196957, 11.222014, 59.128711, 41.084110, 40.616749, 86.452883, 0.313430, 83.631216, 85.661924, 50.880668, 51.503476, 42.525698, 18.187902, 48.224413, 90.880171, 83.057796, 66.971208, 49.588344, 81.998711, 55.605672, 16.179092, 48.930577, 92.040737, 60.846825, 37.658258, 65.655622, 30.902518, 8.929276, 72.715463, 61.491687, 44.535049, 62.923010, 63.865788, 64.850788, 71.605849, 99.913582, 35.037544, 85.009774, 76.620208, 94.275617, 5.056503, 54.706337, 32.644653, 56.964525, 77.093225, 58.016808, 33.299516, 62.849866, 57.008650, 1.572101, 83.956436, 9.998830, 72.205441, 42.711812, 2.755353, 1.929263, 22.959097, 20.669518, 41.020766, 88.298967, 41.869395, 71.261464, 39.524638, 54.963771, 50.408773, 24.368821, 75.954955, 2.881286, 20.839514, 93.951727, 52.941679, 21.941841, 10.630508, 69.296752, 76.914516, 65.136549, 16.980542, 22.310998, 68.979763, 59.465318, 54.685753, 13.068076, 13.743620, 3.211891, 87.593814, 66.953795, 78.593696, 17.688501, 52.896755, 53.386372, 30.510298, 47.973421, 56.615480, 98.545114, 31.619812, 76.984161, 17.911024, 5.512486, 7.916776, 81.392464, 93.667940, 48.317989, 81.260762, 19.919652, 17.674731, 29.988921, 44.967905, 0.550843, 28.851339, 50.000164, 70.385416, 52.027424, 86.620560, 40.873341, 45.444006, 94.290185, 54.918281, 44.199158, 5.299946, 28.404541, 84.447468, 71.006658, 59.810071, 35.665446, 60.127612, 92.961906, 11.178062, 25.341747, 83.523154, 76.832626, 4.380794, 38.025339, 99.575361, 58.345050, 98.578058, 55.532565, 66.432732, 38.419264, 6.618350, 43.283676, 94.163712, 41.916611, 20.781194, 42.436938, 42.756603, 87.442051, 80.495397, 5.632891, 19.227991, 89.730836, 74.422130, 56.733646, 29.115164, 74.764143, 6.507598, 50.698690, 36.654716, 15.125790, 14.947633, 79.767944, 6.276258, 46.718688, 29.801304, 1.567052, 3.273747, 80.460319, 37.809860, 89.728599, 47.472419, 15.297868, 95.659949, 35.054357, 85.731390, 10.081834, 88.745766, 36.437745, 40.140562, 23.407767}, 677, output, 101);
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 < 101; ++i)
ok += output[i] != expected_array[i];
if (ok)
{
printf("Powinno być: [6, 6, 7, 8, 8, 8, 11, 6, 3, 7, 7, 9, 5, 8, 6, 5, 7, 7, 2, 3, 6, 4, 6, 1, 8, 5, 3, 4, 4, 8, 5, 6, 3, 1, 8, 8, 4, 6, 4, 8, 8, 9, 8, 3, 11, 4, 7, 3, 12, 8, 9, 6, 7, 8, 7, 8, 8, 14, 4, 13, 8, 4, 8, 1, 7, 4, 10, 6, 3, 3, 16, 13, 8, 7, 12, 8, 8, 3, 10, 7, 7, 9, 4, 10, 7, 10, 4, 9, 5, 8, 7, 4, 10, 6, 7, 6, 7, 7, 10, 6, 0]\n");
printf("\nTablica po wywołaniu funkcji create_histogram: ");
for (int i = 0; i < 101; ++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[] = {8, 9, 7, 5};
int output[] = {0, 0, 0, -2};
printf("#####START#####");
int res = create_histogram((float[]){5.177215, 7.348994, 0.751622, 8.304808, 6.796502, 7.524138, 7.487365, 10.555258, 9.407491, 7.201558, 0.335296, 8.245825, 10.064216, 7.610430, 1.535671, 9.702150, 4.746629, 0.094525, 4.951010, 2.466611, 1.416486, 10.511974, 0.791827, 10.169843, 5.210476, 6.620831, 2.185010, 2.011473, 6.582379, 0.876282, 6.165871, 2.823593, 3.467540, 3.200898, 9.909044, 1.879206, 2.634151, 2.217321, 5.689799, 7.722000, 5.303051, 9.571017, 6.854544, 8.256021, 4.118358, 9.809104, 6.206637, 4.270891, 3.821861, 7.327757, 0.489009, 3.753830, 1.228866, 8.233291, 1.468900, 8.441703, 0.193576, 8.244670, 1.595141, 0.342571, 10.069165, 1.723020, 1.882103, 5.910139, 10.771786, 4.926666, 6.833868, 3.232098, 6.477371, 2.379049, 8.364261, 1.702900, 9.616050}, 73, output, 4);
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 < 4; ++i)
ok += output[i] != expected_array[i];
if (ok)
{
printf("Powinno być: [8, 9, 7, 5]\n");
printf("\nTablica po wywołaniu funkcji create_histogram: ");
for (int i = 0; i < 4; ++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, 0, 0, 0, 0, 0, 0, 0, 1};
int output[] = {2, 1, 1, 2, -2, -2, -2, -2, -2, -2, 1};
printf("#####START#####");
int res = create_histogram((float[]){10.714973}, 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, 0, 0, 0, 0, 0, 0, 0, 1]\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[] = {4};
int output[] = {-2};
printf("#####START#####");
int res = create_histogram((float[]){8.882906, 0.883685, 0.351252, 10.707384, 6.511971, 0.450464, 4.444718, 9.618140, 2.373083, 4.743774, 2.326939, 7.656494, 3.716372, 10.055117, 0.571167, 2.083818, 9.249963, 10.437779, 9.943934, 8.687591, 7.008072}, 21, 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ć: [4]\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[]){2.079354, 1.298639, 9.980747, 6.611050, 4.687394, 8.521648, 1.406375}, 16, NULL, 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 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, 2, -2, -2, 0, 0, 0, 2, 0, -2, 2};
printf("#####START#####");
int res = create_histogram(NULL, 18, output, 19);
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, 2, -2, -2, 0, 0, 0, 2, 0, -2, 2};
printf("#####START#####");
int res = create_histogram((float[]){2.079354, 1.298639, 9.980747, 6.611050, 4.687394, 8.521648, 1.406375}, 0, output, 10);
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, 2, -2, -2, 0, 0, 0, 2, 0, -2, 2};
printf("#####START#####");
int res = create_histogram((float[]){2.079354, 1.298639, 9.980747, 6.611050, 4.687394, 8.521648, 1.406375}, 10, 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, 2, -2, -2, 0, 0, 0, 2, 0, -2, 2};
printf("#####START#####");
int res = create_histogram((float[]){2.079354, 1.298639, 9.980747, 6.611050, 4.687394, 8.521648, 1.406375}, -15, output, 10);
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, 2, -2, -2, 0, 0, 0, 2, 0, -2, 2};
printf("#####START#####");
int res = create_histogram((float[]){2.079354, 1.298639, 9.980747, 6.611050, 4.687394, 8.521648, 1.406375}, 20, 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[] = {3, 6, 1, 0};
//-------------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, -4);
printf("***END***\n");
//-------------3-----------------------
printf("\n***TEST 3***\n\n");
printf("***START***\n");
display_vector(tab, 4);
printf("***END***\n");
//-------------4-----------------------
printf("\n***TEST 4***\n\n");
printf("***START***\n");
display_vector(tab, 4 - 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[] = {3.000000, 7.000000, 3.000000, 5.000000, 1.000000, -10.000000, 3.000000, 6.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ć: [3.000000, 7.000000, 3.000000, 5.000000, 1.000000, -10.000000, 3.000000, 6.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 = 11;
const float expected_array[] = {9.000000, -1.000000, -5.000000, 4.000000, -6.000000, 2.000000, 0.000000, 0.000000, -7.000000, -1.000000, 8.000000, -2.000000};
float dest[12];
int result = read_vector_float(dest, 12, -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ć: [9.000000, -1.000000, -5.000000, 4.000000, -6.000000, 2.000000, 0.000000, 0.000000, -7.000000, -1.000000, 8.000000, -2.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 = 4;
const float expected_array[] = {-10.000000, -8.000000, 5.000000, -10.000000};
float dest[4];
int result = read_vector_float(dest, 4, -1);
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ć: [-10.000000, -8.000000, 5.000000, -10.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[6];
printf("#####START#####");
int result = read_vector_float(dest, 0, 10);
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[10];
printf("#####START#####");
int result = read_vector_float(dest, -7, -10);
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, -3, 2);
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();
}