/*
* Unit Test Bootstrap
* Autor: Tomasz Jaworski, 2018-2019
*
* Test dla zadania Histogram
* Autor testowanej odpowiedzi: Szymon Ptak
* Test wygenerowano automatycznie o 2019-08-22 14:54:05.346368
*
* 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[] = {1, 2, 0, 0, 1, 1, 0, 0, 1, 1, 0};
int output[] = {-1, 1, 2, 0, 1, -2, 0, 0, -1, -2, -1};
printf("#####START#####");
int res = create_histogram((float[]){1.580122, 4.201131, 9.659867, 5.615203, 1.813276, 8.743232, 0.546663}, 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ć: [1, 2, 0, 0, 1, 1, 0, 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[] = {5, 1, 2, 1, 2, 1, 1, 0, 2, 3, 3};
int output[] = {2, 0, -2, -1, 2, 0, 0, 0, -2, -2, -2};
printf("#####START#####");
int res = create_histogram((float[]){8.133729, 0.639783, 8.837014, 10.205810, 0.936047, 6.044333, 0.175807, 0.386106, 2.926462, 1.523505, 9.491736, 9.480048, 9.744511, 4.372110, 2.812719, 10.252553, 3.741547, 4.711922, 5.112484, 0.702633, 10.424451}, 21, 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, 1, 2, 1, 2, 1, 1, 0, 2, 3, 3]\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[] = {17, 11, 8, 14, 20, 16, 20, 21, 15, 18, 13};
int output[] = {-2, 2, 2, -1, 1, -1, -1, -1, -2, 2, 2};
printf("#####START#####");
int res = create_histogram((float[]){6.710052, 0.843985, 3.297015, 6.847186, 6.512410, 0.244260, 7.224934, 0.978961, 0.884443, 6.581132, 8.105484, 9.193472, 4.897590, 7.705696, 10.013180, 4.553912, 1.426947, 4.136317, 6.856732, 8.490535, 5.167685, 5.785450, 8.108976, 7.472485, 9.550736, 8.075805, 4.617987, 7.216828, 3.002745, 7.594979, 0.245794, 9.845558, 7.665484, 0.232365, 5.679801, 3.378764, 9.298391, 5.244065, 4.486246, 5.088716, 1.967262, 4.163384, 10.482821, 5.886346, 9.205409, 7.930611, 7.640681, 4.000042, 7.660003, 8.879908, 9.422131, 8.834338, 5.000116, 6.737212, 6.134764, 6.708611, 2.307674, 4.758483, 6.147600, 9.990147, 7.049812, 8.519227, 4.818075, 4.123818, 0.914419, 5.195714, 5.880636, 7.335923, 4.462754, 3.182993, 10.413037, 5.145741, 9.272918, 8.799657, 0.138311, 6.992249, 7.126915, 7.192905, 9.401327, 4.637032, 3.309886, 9.478639, 2.730069, 9.614120, 4.262520, 9.778561, 10.991064, 3.712523, 10.527926, 2.684139, 2.000101, 6.172575, 3.783701, 0.283656, 10.539407, 5.727545, 10.321561, 9.953757, 9.565461, 6.586872, 3.566311, 10.720581, 1.949874, 4.301397, 0.700857, 6.281961, 0.545778, 1.977622, 0.523581, 9.810800, 8.524766, 3.015073, 7.155608, 10.903615, 6.569641, 0.259225, 6.750392, 1.410272, 4.229623, 5.483971, 0.028703, 8.771929, 9.152662, 10.730861, 8.376842, 9.207498, 7.162570, 1.453242, 4.377489, 2.540641, 5.978088, 1.792628, 8.369381, 3.613712, 4.449775, 8.481621, 3.748527, 4.232556, 6.030924, 2.258859, 7.890047, 7.967000, 7.795633, 10.221229, 0.652492, 1.043956, 3.678874, 1.735398, 7.558093, 7.734826, 3.361281, 10.522745, 3.220030, 8.916175, 10.474577, 6.518465, 5.457043, 8.204516, 4.488118, 4.048792, 9.080833, 0.563037, 1.254298, 5.556365, 6.543788, 6.908128, 2.572495, 2.043916, 6.731920, 0.849074, 7.304215, 1.779412, 5.697009}, 173, 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ć: [17, 11, 8, 14, 20, 16, 20, 21, 15, 18, 13]\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, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0};
int output[] = {-1, -1, -2, 0, 2, -2, 0, 0, 1, 2, 2};
printf("#####START#####");
int res = create_histogram((float[]){-8.774144, -9.575710, -0.278827, -2.315789, 1.512273, -5.272960, -5.230445, -2.087508, -8.453557, 9.330198}, 10, 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, 1, 0, 0, 0, 0, 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 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[] = {2, 3, 4, 2, 1, 5, 1, 3, 1, 1, 0};
int output[] = {0, -1, -1, 2, -1, 0, 1, -2, 0, 0, 2};
printf("#####START#####");
int res = create_histogram((float[]){0.788325, 2.208083, -1.491956, 8.815479, -4.162284, 7.035294, -6.833539, -9.613354, 5.404825, -3.646917, 6.658628, -6.604475, 1.313049, -1.362007, -1.733501, -9.554592, 9.846611, -9.365031, 2.826905, 7.147655, 5.377414, 2.449230, 3.692477, -9.900806, -7.988682, -8.332843, -3.564741, -4.449833, 2.003364, -1.745755, 1.367092, 4.804645, 0.191738, -2.141733, -8.983474, -2.193747, -7.384754, -9.700593, -1.112335, 5.501385, -3.070420, -4.106455, -6.894598, -9.874577, 1.973855, 5.072388, 7.988325, -6.222943, 3.601657, 5.405231, -8.557977}, 51, 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ć: [2, 3, 4, 2, 1, 5, 1, 3, 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 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[] = {1, 3, 1, 6, 2, 4, 3, 5, 1, 6, 7, 4, 1, 4, 9, 2, 5, 0, 4, 5, 0};
int output[] = {-2, -1, -1, 0, 1, -1, -1, 1, -1, -2, 1, -2, 0, -2, 1, -2, 2, 1, 2, 1, -2};
printf("#####START#####");
int res = create_histogram((float[]){10.909883, 11.074401, 3.334612, 6.534015, 7.303870, 1.743536, 12.604900, 6.693181, 9.176775, 2.222268, 6.606591, 9.204541, 19.677028, 13.429763, 18.692165, 16.231936, 16.504086, 16.632582, 10.321456, 11.601782, 5.401636, 13.452274, 19.634199, 3.102299, 13.949063, 7.967148, 19.176237, 7.508940, 9.173336, 10.858134, 18.240767, 14.766286, 18.207859, 3.780051, 16.733639, 14.132488, 1.015931, 14.103527, 10.985070, 11.390953, 11.929912, 3.419891, 14.934134, 14.733459, 9.473714, 8.188302, 18.721783, 14.850261, 19.477255, 16.614011, 13.541378, 10.313148, 7.845363, 14.976567, 14.300471, 15.421224, 5.258198, 5.256460, 19.167940, 4.208198, 3.060155, 3.419960, 7.216895, 14.923698, 10.348850, 9.850289, 15.115013, 9.715547, 10.955273, 5.206735, 4.129845, 1.399788, 0.886400}, 73, 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ć: [1, 3, 1, 6, 2, 4, 3, 5, 1, 6, 7, 4, 1, 4, 9, 2, 5, 0, 4, 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[] = {7, 8, 5, 10, 9, 9, 8, 4, 6, 10, 7, 10, 7, 12, 9, 8, 9, 11, 10, 7, 12, 10, 6, 4, 13, 6, 9, 4, 6, 11, 9, 6, 8, 8, 6, 7, 9, 14, 14, 9, 7, 3, 10, 13, 10, 5, 9, 7, 7, 15, 4, 12, 9, 9, 9, 7, 3, 9, 6, 9, 6, 11, 13, 8, 5, 12, 7, 11, 10, 7, 8, 13, 4, 4, 9, 9, 6, 11, 6, 12, 5, 13, 5, 6, 9, 5, 10, 0};
int output[] = {1, -1, -2, 0, 0, 0, 0, 2, -1, -1, -1, -2, 1, -1, -1, 0, -2, -2, 2, -2, 0, 1, 2, 0, -1, -1, 2, 2, 2, 2, -1, -1, 2, 0, -2, 1, 1, 0, 1, -2, 1, 2, 0, 1, 0, -1, 1, 1, -2, 0, 0, 0, 2, 1, -1, 1, -1, 1, -1, -1, -1, -2, 2, 1, 0, 2, 2, 2, 2, -2, 2, 2, -2, -2, 0, 1, -2, 2, 0, -2, -2, 0, -2, -2, 2, -1, 2, -1};
printf("#####START#####");
int res = create_histogram((float[]){39.960140, 84.208974, 26.170854, 68.669020, 64.133963, 39.623302, 64.364137, 82.392368, 47.345212, 58.299875, 33.659539, 44.154435, 48.354514, 49.213243, 67.511182, 44.279851, 53.974126, 57.986894, 68.251967, 49.199982, 52.137562, 16.127846, 71.796133, 81.251903, 49.863210, 67.405474, 86.601759, 16.899448, 72.156903, 26.884295, 79.612906, 43.469570, 77.621562, 84.532150, 85.830008, 31.701603, 86.778761, 54.549755, 9.711554, 48.730088, 58.233565, 46.533499, 62.496339, 8.544136, 21.976824, 60.737717, 44.684145, 12.256746, 75.700538, 47.203177, 71.835672, 0.779818, 6.152163, 18.740416, 7.383703, 50.920896, 49.311940, 54.234616, 62.877923, 86.158304, 7.804514, 33.525364, 4.054789, 11.613262, 36.818614, 14.173122, 17.159757, 47.395776, 66.393762, 62.601078, 38.823754, 25.530634, 4.310851, 64.287725, 42.806350, 63.234541, 11.788952, 18.777217, 60.091241, 25.186283, 31.392672, 65.851957, 11.745851, 56.981535, 68.082669, 86.531883, 39.166275, 14.720248, 66.020130, 54.680309, 17.620514, 54.941115, 80.821024, 46.187972, 38.809276, 3.107888, 3.170625, 71.782183, 44.553229, 29.726207, 69.432130, 56.508234, 40.084889, 53.641012, 81.342512, 13.070728, 51.052285, 42.031467, 2.636713, 63.306592, 52.293018, 21.519624, 1.055287, 71.147904, 39.229980, 14.233623, 79.326574, 20.967676, 14.017382, 81.577998, 13.000286, 25.893529, 24.254986, 50.898086, 62.445083, 7.885970, 12.337917, 38.332341, 30.391178, 76.302019, 47.443403, 12.331925, 37.637232, 80.189654, 79.466972, 6.835429, 20.685900, 17.978066, 65.706176, 34.301876, 39.053017, 37.865262, 30.742169, 55.273260, 59.148571, 61.232539, 38.167919, 4.682399, 62.122660, 65.729304, 3.719752, 3.519465, 76.787238, 29.666702, 24.586933, 64.378919, 19.494951, 57.507999, 15.174467, 40.317021, 22.958189, 14.501570, 53.665879, 79.439596, 81.399914, 2.908083, 48.720266, 65.913427, 60.686507, 54.231956, 47.039662, 37.008743, 21.022851, 49.613188, 76.088634, 47.916494, 84.930576, 51.013710, 51.629940, 9.620996, 34.681140, 20.939155, 0.484505, 41.718674, 9.305098, 26.219271, 77.117634, 74.094672, 20.773185, 70.041217, 11.820755, 43.008165, 20.405588, 30.419011, 79.503956, 68.220049, 74.568004, 41.638565, 76.856448, 32.890988, 26.819985, 38.833584, 0.807237, 75.228301, 9.822060, 16.443779, 66.376362, 59.528507, 57.607008, 29.157533, 67.848486, 0.031970, 15.769092, 12.955867, 20.902744, 10.117127, 78.288681, 49.809066, 40.256818, 19.985483, 74.611134, 28.577399, 75.991727, 46.091159, 37.733651, 11.013855, 85.861827, 25.932182, 27.956889, 29.898984, 73.446666, 5.991768, 59.838799, 29.263615, 20.905494, 17.243008, 59.119205, 58.129249, 45.057522, 33.067311, 78.088987, 30.165695, 58.125542, 31.927418, 77.435555, 29.471533, 32.563480, 45.917299, 28.792101, 67.089691, 53.255568, 45.656369, 12.213716, 1.648188, 11.263802, 17.251916, 5.331019, 11.656511, 38.712190, 24.933102, 60.746139, 43.010497, 5.076964, 54.634634, 61.839558, 40.843332, 38.088112, 66.968060, 5.031671, 16.755029, 71.913361, 29.333890, 1.162859, 65.193118, 26.528854, 67.312676, 47.810912, 51.585375, 22.182421, 86.027979, 66.445796, 85.234571, 52.698581, 32.421716, 30.897815, 3.355926, 16.871930, 10.287789, 63.042387, 75.924505, 32.618560, 77.672458, 52.849335, 30.113035, 51.144713, 42.252756, 78.255700, 74.669818, 17.995321, 43.295542, 39.990253, 81.765497, 10.482855, 2.499497, 61.530474, 79.487271, 55.567472, 46.254183, 75.077063, 57.522774, 21.912290, 84.235619, 69.579992, 75.536971, 49.204298, 81.121376, 49.678571, 52.210549, 48.287210, 33.464545, 39.172224, 5.817865, 71.188802, 34.774815, 32.945797, 63.199438, 6.551609, 69.315680, 52.565104, 26.621615, 86.748528, 24.709937, 49.470368, 37.836064, 64.442876, 13.649615, 62.892880, 62.686572, 22.200691, 9.429541, 56.542150, 26.106072, 13.914238, 18.462214, 31.692714, 54.614064, 62.249404, 55.566180, 51.252568, 71.278317, 13.602831, 42.892972, 68.671540, 62.970256, 8.304162, 66.027338, 70.774727, 84.660721, 77.804357, 18.263048, 49.110680, 36.540441, 4.648903, 3.224822, 11.357133, 17.687680, 81.556340, 11.139550, 37.944813, 67.102414, 55.679165, 37.143157, 53.880487, 52.520280, 83.081647, 43.379972, 35.584524, 6.887802, 1.045286, 82.822249, 53.277461, 30.602319, 1.934633, 81.067105, 65.799021, 27.522021, 6.731147, 83.988531, 61.173949, 13.348642, 8.739877, 44.855207, 36.097100, 38.676521, 29.251440, 6.464081, 57.420281, 10.147297, 28.175950, 69.417608, 19.050043, 20.797507, 10.986468, 77.915674, 39.717688, 29.018790, 66.180360, 65.096437, 79.125502, 15.058401, 4.828650, 83.938828, 59.443234, 68.585648, 68.813788, 17.470468, 19.473269, 40.461026, 61.496177, 4.687416, 27.378463, 29.500344, 78.280462, 34.146104, 61.877677, 49.820121, 10.981727, 15.892788, 48.790340, 65.731922, 70.391509, 14.005369, 20.952233, 30.379571, 13.582177, 80.901156, 3.076025, 53.802887, 21.918205, 1.709151, 9.714589, 71.642306, 52.114613, 36.086119, 9.416356, 71.688149, 2.487081, 14.724476, 51.175570, 42.174416, 20.335377, 43.176497, 24.741395, 38.501040, 82.795066, 33.132092, 44.232124, 43.270814, 4.356739, 79.317731, 20.220314, 45.683200, 59.552258, 24.268535, 40.330022, 36.976522, 22.090640, 59.095029, 65.790138, 83.105944, 37.191319, 61.574766, 49.131381, 76.857961, 24.287703, 77.215727, 32.977931, 77.994236, 23.923724, 49.460286, 14.258950, 42.138340, 74.584042, 50.436446, 81.326940, 13.381429, 9.484782, 81.438556, 19.674859, 67.056790, 26.468321, 10.508728, 13.522329, 17.165732, 69.674311, 65.622986, 71.903079, 70.984415, 13.511631, 55.789462, 75.149487, 4.463051, 25.143965, 49.593779, 70.799329, 34.730251, 41.109271, 35.655083, 36.477280, 23.940163, 9.544295, 23.537634, 51.560300, 63.496553, 38.463305, 38.244914, 5.843745, 31.167499, 57.149816, 13.537799, 27.788953, 74.006381, 81.708987, 51.098706, 80.079548, 50.969357, 44.578399, 71.224952, 13.910217, 33.359105, 43.116846, 19.215413, 42.188233, 17.985595, 21.656375, 24.516750, 46.298192, 51.408376, 18.599117, 24.310773, 42.171803, 75.858348, 37.197393, 18.937358, 39.478071, 55.709605, 0.475253, 37.529629, 1.632580, 70.967114, 59.653054, 28.014375, 5.428218, 84.533148, 43.396201, 18.585057, 36.643889, 72.108942, 8.619890, 43.391505, 29.087685, 20.935593, 57.729096, 84.968823, 79.085344, 79.023292, 85.334596, 77.327060, 42.343355, 35.505546, 65.202426, 62.910726, 63.669546, 24.418418, 0.672106, 57.079873, 40.702483, 57.721650, 24.800054, 44.927371, 35.273883, 54.074186, 78.753820, 69.538678, 84.668579, 73.876577, 0.180952, 44.015537, 43.351079, 63.995710, 18.976706, 15.978585, 85.488192, 9.023058, 71.875844, 37.277851, 4.064673, 65.384913, 12.472732, 30.908552, 21.300811, 19.572571, 25.827615, 11.070055, 1.792012, 24.692414, 74.555480, 46.497659, 33.391718, 67.174263, 15.161672, 42.662525, 21.187508, 6.630137, 23.856888, 67.554153, 33.812379, 53.631752, 32.159285, 17.670629, 6.627544, 8.623552, 8.484271, 38.402023, 18.214375, 59.579790, 48.055501, 72.015051, 3.669930, 68.722326, 58.174556, 82.267801, 73.590740, 83.823363, 18.501599, 5.909647, 46.316986, 37.790843, 37.821098, 78.202683, 76.711499, 86.955992, 61.479197, 36.322565, 72.029405, 51.350749, 81.091700, 34.119601, 28.053093, 7.519080, 21.064830, 3.755735, 60.653758, 58.433604, 82.667935, 86.665758, 43.957324, 46.368742, 16.926970, 15.612949, 16.297068, 53.192263, 26.349848, 35.450032, 35.549488, 43.367337, 49.467212, 22.484158, 81.597811, 77.758208, 74.326061, 3.295068, 38.299151, 73.093478, 31.975886, 68.752962, 46.366655, 36.061783, 67.239231, 37.351557, 44.486592, 24.700525, 16.259890, 71.379132, 2.360436, 21.023357, 16.881843, 35.215114, 62.143987, 63.306104, 70.202202, 12.107155, 79.436468, 55.178446, 69.087683, 60.958382, 54.790406, 80.736640, 62.786946, 51.820893, 15.563723, 28.304454, 38.264521, 77.957063, 61.136835, 70.721470, 79.883918, 45.288187, 62.130614, 14.580132, 68.661420, 48.490544, 86.198645, 83.365509, 61.097056, 74.246179, 84.514078, 32.357798, 75.788648, 5.381253, 86.305677, 52.259352, 67.873387, 61.620863, 22.729934}, 725, output, 88);
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 < 88; ++i)
ok += output[i] != expected_array[i];
if (ok)
{
printf("Powinno być: [7, 8, 5, 10, 9, 9, 8, 4, 6, 10, 7, 10, 7, 12, 9, 8, 9, 11, 10, 7, 12, 10, 6, 4, 13, 6, 9, 4, 6, 11, 9, 6, 8, 8, 6, 7, 9, 14, 14, 9, 7, 3, 10, 13, 10, 5, 9, 7, 7, 15, 4, 12, 9, 9, 9, 7, 3, 9, 6, 9, 6, 11, 13, 8, 5, 12, 7, 11, 10, 7, 8, 13, 4, 4, 9, 9, 6, 11, 6, 12, 5, 13, 5, 6, 9, 5, 10, 0]\n");
printf("\nTablica po wywołaniu funkcji create_histogram: ");
for (int i = 0; i < 88; ++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[] = {2, 2, 4, 3, 6, 5, 7, 1, 2};
int output[] = {2, 0, -1, 2, 2, 1, 0, -1, 0};
printf("#####START#####");
int res = create_histogram((float[]){6.867560, 6.008458, 4.548003, 5.583443, 6.460995, 6.344474, 2.684271, 3.713693, 3.946184, 6.828428, 1.951519, 7.268972, 9.883788, 9.198008, 5.457850, 4.770667, 8.849139, 4.725909, 3.190621, 10.759143, 0.128709, 0.933342, 4.154685, 2.940284, 2.303912, 4.995564, 9.240252, 1.223134, 5.418474, 5.314237, 5.995036, 6.979908, 4.671442, 8.240742, 10.167304, 2.193415, 6.097536}, 37, 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ć: [2, 2, 4, 3, 6, 5, 7, 1, 2]\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, 0, 0, 1, 0, 0, 0, 0, 0};
int output[] = {0, 0, 0, -2, 2, -2, 0, 0, -1, 2, 0};
printf("#####START#####");
int res = create_histogram((float[]){5.399205}, 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, 1, 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[] = {3};
int output[] = {2};
printf("#####START#####");
int res = create_histogram((float[]){0.787637, 6.932628, 5.091062, 9.259413, 6.005953, 1.544016, 2.629962, 4.371991, 1.220035, 0.495188, 1.151276, 6.678052, 10.731818, 3.412734, 9.720175, 2.362640, 8.625393, 7.211435, 9.911390, 8.877262, 8.064858, 7.639849, 3.828017, 10.925997, 3.295006, 0.609131, 2.672884, 2.362792, 7.278597, 2.311725}, 30, 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ć: [3]\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.580122, 4.201131, 9.659867, 5.615203, 1.813276, 8.743232, 0.546663}, 10, NULL, 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 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[] = {1, -2, 2, 1, -1, 1, 2, -2, 2, 2, -1};
printf("#####START#####");
int res = create_histogram(NULL, 14, 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 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[] = {1, -2, 2, 1, -1, 1, 2, -2, 2, 2, -1};
printf("#####START#####");
int res = create_histogram((float[]){1.580122, 4.201131, 9.659867, 5.615203, 1.813276, 8.743232, 0.546663}, 0, output, 15);
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[] = {1, -2, 2, 1, -1, 1, 2, -2, 2, 2, -1};
printf("#####START#####");
int res = create_histogram((float[]){1.580122, 4.201131, 9.659867, 5.615203, 1.813276, 8.743232, 0.546663}, 14, 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[] = {1, -2, 2, 1, -1, 1, 2, -2, 2, 2, -1};
printf("#####START#####");
int res = create_histogram((float[]){1.580122, 4.201131, 9.659867, 5.615203, 1.813276, 8.743232, 0.546663}, -12, 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 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[] = {1, -2, 2, 1, -1, 1, 2, -2, 2, 2, -1};
printf("#####START#####");
int res = create_histogram((float[]){1.580122, 4.201131, 9.659867, 5.615203, 1.813276, 8.743232, 0.546663}, 20, 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 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[] = {1, -2, -9, 5, 0, -10, 0, 3, -7, 8, 7, -6};
//-------------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, -12);
printf("***END***\n");
//-------------3-----------------------
printf("\n***TEST 3***\n\n");
printf("***START***\n");
display_vector(tab, 12);
printf("***END***\n");
//-------------4-----------------------
printf("\n***TEST 4***\n\n");
printf("***START***\n");
display_vector(tab, 12 - 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 = 6;
const float expected_array[] = {-10.000000, 4.000000, 3.000000, 2.000000, -8.000000, 7.000000, 0.000000};
float dest[7];
int result = read_vector_float(dest, 7, 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ć: [-10.000000, 4.000000, 3.000000, 2.000000, -8.000000, 7.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 = 10;
const float expected_array[] = {7.000000, -2.000000, 9.000000, -3.000000, 0.000000, -10.000000, 10.000000, 3.000000, -3.000000, 9.000000, -4.000000};
float dest[11];
int result = read_vector_float(dest, 11, -4);
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ć: [7.000000, -2.000000, 9.000000, -3.000000, 0.000000, -10.000000, 10.000000, 3.000000, -3.000000, 9.000000, -4.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[] = {7.000000, 6.000000, 5.000000, -4.000000};
float dest[4];
int result = read_vector_float(dest, 4, -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ć: [7.000000, 6.000000, 5.000000, -4.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, -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();
}
//
// 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, -2, -1);
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, -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();
}