/*
* Unit Test Bootstrap
* Autor: Tomasz Jaworski, 2018-2019
*
* Test dla zadania Histogram
* Autor testowanej odpowiedzi: Szymon Ptak
* Test wygenerowano automatycznie o 2019-08-23 16:28:14.725404
*
* 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[] = {2, 1, 1, 2, 0, 0, 0, 2, 1, 1, 0};
int output[] = {2, -1, -1, 1, -2, -2, 1, -2, 0, -2, -2};
printf("#####START#####");
int res = create_histogram((float[]){3.248319, 7.396763, 0.484101, 8.145117, 0.999271, 9.671348, 7.294095, 2.887272, 1.471467, 3.921252}, 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ć: [2, 1, 1, 2, 0, 0, 0, 2, 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[] = {4, 5, 6, 3, 5, 3, 4, 4, 5, 4, 2};
int output[] = {-2, -2, 0, -2, -1, -1, -1, -1, 0, 1, 1};
printf("#####START#####");
int res = create_histogram((float[]){2.506893, 10.600220, 2.874830, 7.276582, 6.211875, 8.900280, 5.234348, 6.640665, 8.388414, 0.723749, 4.139178, 2.944749, 2.955684, 7.590780, 9.776809, 8.850551, 9.418888, 2.797830, 7.485756, 1.134341, 8.999192, 10.686421, 5.536435, 3.440346, 4.567648, 6.105404, 8.600699, 4.384694, 9.085812, 0.931319, 5.584527, 0.122351, 1.977676, 7.716860, 1.170350, 1.486151, 2.523526, 1.543613, 3.391746, 3.139242, 4.573253, 4.304672, 6.860072, 9.774976, 0.485692}, 45, 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, 5, 6, 3, 5, 3, 4, 4, 5, 4, 2]\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[] = {15, 17, 10, 15, 13, 16, 13, 9, 14, 17, 19};
int output[] = {2, -1, -1, 1, 0, -2, 2, -2, 2, -2, -2};
printf("#####START#####");
int res = create_histogram((float[]){9.673802, 3.860609, 5.517692, 7.020696, 9.106704, 1.368450, 3.455505, 3.705738, 4.587456, 0.282430, 6.347256, 2.111459, 9.805199, 10.117107, 7.941927, 4.457710, 8.824139, 3.664744, 10.018337, 5.973466, 3.604400, 0.568126, 1.066383, 0.310945, 8.578564, 6.527401, 5.426462, 8.965765, 2.269743, 10.492968, 9.508829, 6.983509, 10.290864, 7.619236, 1.170822, 10.017355, 9.421462, 10.498926, 1.283612, 8.201296, 10.908957, 2.768613, 2.294778, 5.855034, 6.841599, 4.882691, 4.268664, 4.079006, 3.798285, 7.731695, 4.713937, 8.746236, 0.405341, 5.320160, 2.584245, 0.541835, 7.394806, 8.069373, 1.467791, 5.355080, 8.057265, 3.967686, 3.651755, 1.823464, 6.142653, 6.344485, 9.982632, 0.048669, 1.166609, 10.654029, 9.541239, 10.054325, 10.170580, 2.554615, 3.652439, 9.076974, 5.238136, 2.721848, 2.787277, 7.017092, 1.633257, 6.529180, 5.234693, 4.849085, 6.100453, 5.443684, 4.870867, 9.059685, 7.002723, 10.674166, 6.231111, 0.196267, 4.136639, 3.031012, 10.298400, 1.018410, 0.309354, 5.229622, 1.522441, 5.669904, 1.885405, 10.205986, 5.645762, 6.990774, 10.425162, 9.096038, 10.476932, 10.543562, 6.440093, 9.392756, 9.251765, 5.341699, 10.663821, 3.281752, 4.301767, 6.140219, 1.528175, 4.978232, 4.377141, 10.423710, 8.926406, 0.729342, 5.257781, 8.614398, 1.036109, 0.568862, 8.936892, 4.746469, 8.126790, 8.792143, 6.466192, 5.511017, 9.416346, 2.373131, 9.105631, 2.923354, 8.333043, 3.621037, 3.804462, 1.518055, 10.937633, 7.178322, 5.710372, 0.275052, 9.057438, 0.748582, 0.029085, 9.908521, 3.570885, 1.211996, 7.681556, 0.856167, 9.218388, 3.374432, 8.195527, 1.623129, 1.531579, 0.408452}, 158, 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ć: [15, 17, 10, 15, 13, 16, 13, 9, 14, 17, 19]\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, 0, 0, 1, 0, 0, 0, 0};
int output[] = {1, -2, 1, 2, 1, 2, 2, 1, -2, 1, 0};
printf("#####START#####");
int res = create_histogram((float[]){-8.532529, 6.264068, -4.927327, -0.653754}, 4, 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, 1, 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 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[] = {3, 2, 1, 4, 4, 2, 4, 3, 4, 4, 0};
int output[] = {1, 2, -2, 2, 0, 2, -1, 0, 2, 2, 1};
printf("#####START#####");
int res = create_histogram((float[]){-2.510552, -5.822062, 3.075616, 8.747776, 0.509301, 3.030128, -6.827838, 7.159118, -4.364599, 9.041301, 4.077863, 6.113622, -1.923342, 2.231130, -0.148298, -8.166464, -1.688635, -7.832407, -5.047468, 9.407823, 8.647244, 7.001114, -2.911520, 4.551018, 8.400524, -0.472282, -7.164604, 0.146832, -1.505375, 4.882978, -9.416068, 1.087996, 6.073270, 4.888553, 5.998466, 3.631289, 9.858502, -8.570023, -5.323128, 6.644374, -5.008684, 6.931097, 5.104658, 8.026429, 3.709977, -9.904067, -2.717376, 0.050892, 7.823395, -3.213109, 9.544319, 1.145762, -2.703442, -8.912937}, 54, 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, 1, 4, 4, 2, 4, 3, 4, 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[] = {4, 4, 3, 4, 5, 4, 1, 2, 4, 2, 0, 3, 5, 5, 3, 2, 0, 4, 5, 4, 0};
int output[] = {0, 1, 1, 0, -1, 2, -2, 1, 1, 2, 1, -1, -1, 2, 0, 2, 2, -2, -1, -1, -1};
printf("#####START#####");
int res = create_histogram((float[]){3.425484, 8.786451, 5.852549, 3.226241, 1.226412, 19.275560, 19.172476, 2.586031, 7.898519, 4.770144, 13.548555, 6.382701, 18.405174, 12.852468, 2.550443, 11.464733, 3.377651, 4.487293, 18.340282, 12.776345, 4.972965, 0.644451, 5.936437, 12.536089, 1.764626, 12.007898, 8.689781, 8.376639, 14.043230, 1.662292, 0.666101, 15.590894, 1.389049, 17.573570, 15.827828, 19.083403, 13.315087, 0.071082, 5.838731, 12.165684, 17.858250, 9.527735, 2.311268, 4.604838, 14.802573, 17.795874, 18.437494, 14.701774, 11.963664, 17.301503, 4.416855, 9.775729, 11.282348, 13.962161, 3.107659, 0.906671, 18.550406, 13.509106, 8.837046, 19.548599, 5.114456, 7.650541, 18.905924, 13.281770}, 64, 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ć: [4, 4, 3, 4, 5, 4, 1, 2, 4, 2, 0, 3, 5, 5, 3, 2, 0, 4, 5, 4, 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[] = {5, 6, 4, 13, 11, 10, 14, 13, 5, 9, 12, 11, 12, 8, 4, 8, 12, 7, 8, 4, 8, 6, 10, 8, 13, 9, 7, 12, 9, 11, 9, 7, 12, 11, 10, 9, 8, 13, 7, 5, 15, 17, 8, 7, 14, 9, 10, 6, 9, 6, 7, 7, 15, 6, 12, 13, 11, 8, 8, 10, 5, 7, 11, 11, 10, 11, 8, 13, 8, 7, 11, 11, 16, 8, 10, 8, 7, 9, 7, 12, 9, 6, 13, 24, 8, 0};
int output[] = {0, 2, 1, 0, 2, 1, 1, -1, -1, 2, 0, -2, -2, -2, -2, 0, 1, -1, 0, 2, 1, -1, 2, 1, 0, 1, 1, 2, 1, -1, 1, 0, 0, 0, 0, 0, 1, 2, 0, 0, -2, 1, 0, 1, -1, -1, 1, 1, -1, 1, -2, -2, -1, 2, 1, 2, 0, -1, -2, 2, -2, -2, 1, -2, -2, 1, 1, -1, -2, 1, 2, 1, -1, 0, 1, 0, -2, 1, -1, 1, -2, 1, 0, -1, 1, 0};
printf("#####START#####");
int res = create_histogram((float[]){77.527600, 22.358352, 82.721942, 76.454647, 45.861196, 18.594133, 62.314849, 58.363659, 59.433354, 63.604337, 38.606520, 67.826489, 7.684506, 63.291912, 59.829914, 42.980049, 27.142895, 48.432337, 46.590345, 48.894723, 41.853129, 3.918574, 22.084770, 3.924539, 82.814640, 9.052974, 4.890310, 65.348926, 56.481625, 13.415677, 64.819237, 70.163488, 48.201400, 28.236483, 0.912660, 81.022340, 5.982490, 72.344529, 32.527796, 72.020065, 60.091773, 68.626678, 66.398581, 35.721495, 18.549322, 57.540812, 34.888325, 33.586427, 82.280776, 35.228021, 71.335462, 39.943646, 76.358762, 25.312128, 5.965909, 77.967945, 59.172073, 31.514538, 54.931889, 76.432459, 3.567724, 4.136571, 67.605886, 72.740342, 15.623810, 4.568190, 62.324780, 43.350744, 80.315998, 63.895302, 48.402825, 44.019526, 30.782572, 14.121966, 28.659831, 12.181686, 67.818645, 80.906990, 83.795733, 65.274834, 56.854558, 40.346818, 48.436642, 43.739244, 19.451139, 46.600979, 53.664558, 39.220505, 41.951190, 32.270920, 45.086081, 44.530865, 39.854149, 27.374771, 42.918927, 34.596348, 56.451932, 12.998056, 10.283501, 20.654395, 63.314009, 83.321845, 7.366690, 27.225619, 44.393249, 10.163981, 49.125402, 15.214081, 83.075611, 52.344461, 40.406210, 6.317646, 20.297183, 51.726937, 10.269099, 71.931777, 46.629084, 61.647929, 64.391995, 45.820824, 28.315344, 72.091489, 71.924891, 45.176046, 57.564769, 8.376738, 36.449205, 1.764407, 63.047514, 22.355768, 16.231964, 3.282592, 67.968679, 43.570106, 26.607135, 46.343004, 8.917653, 9.531962, 22.793770, 43.189157, 69.278084, 83.951554, 17.726876, 29.818024, 62.440794, 80.965440, 24.421586, 37.935952, 42.631878, 22.740280, 65.319552, 3.872462, 74.203904, 81.285019, 52.741792, 64.131232, 83.129188, 60.451877, 26.741289, 47.903555, 3.696514, 46.471019, 82.484113, 59.265245, 70.209904, 57.306065, 57.552231, 26.664821, 36.589488, 40.004759, 11.450508, 78.953742, 23.320708, 9.200929, 84.342390, 34.358021, 63.642290, 48.686937, 34.272476, 29.944406, 65.105249, 51.016987, 29.019301, 33.159189, 8.304664, 32.892140, 63.588689, 41.348940, 81.306491, 78.971391, 3.584565, 12.872626, 11.674560, 36.370093, 26.344768, 79.960578, 7.016151, 78.278729, 67.206349, 17.061966, 40.258333, 50.311987, 27.464553, 12.990817, 27.950899, 2.589120, 81.920110, 80.659910, 62.035013, 72.761907, 2.426198, 79.006356, 75.918928, 52.277221, 66.454652, 70.407022, 47.597604, 70.564456, 73.916746, 3.056501, 51.434969, 79.450467, 62.134132, 81.719782, 75.783952, 16.416705, 56.465217, 35.876214, 64.153768, 25.976643, 31.402702, 52.111328, 38.878744, 40.891685, 74.922292, 67.631475, 30.570380, 33.659373, 30.258758, 35.289304, 30.002594, 55.161222, 44.382396, 50.297806, 48.494658, 82.640582, 69.843303, 32.670409, 4.300006, 71.763848, 45.511172, 27.469707, 18.489547, 50.457043, 40.469339, 6.286383, 0.974336, 1.652925, 13.682814, 67.324681, 44.178283, 15.655430, 4.522494, 16.122415, 83.480930, 24.340140, 68.737747, 84.614849, 79.150124, 7.657684, 6.394557, 46.696238, 67.573444, 41.028481, 37.134894, 39.759605, 65.223722, 38.101088, 67.068221, 21.914144, 33.266915, 10.473646, 6.272867, 24.215088, 58.937804, 25.801216, 64.246311, 63.278876, 54.046270, 52.180246, 72.672632, 43.273225, 83.710940, 29.902635, 50.047947, 79.331587, 37.381866, 6.412970, 65.947907, 37.988989, 51.006175, 73.856000, 17.122766, 83.231268, 6.175744, 84.817972, 18.166097, 12.972437, 65.096772, 66.736804, 11.072230, 32.789005, 37.417679, 74.114683, 6.588855, 79.482393, 11.144865, 70.900766, 54.536542, 71.943611, 14.736917, 52.048061, 59.614801, 37.587066, 11.263822, 55.169940, 5.274743, 54.998385, 33.508381, 16.183648, 15.715551, 83.504581, 40.622617, 77.962920, 83.843396, 75.900013, 16.306330, 59.754842, 83.905904, 47.058550, 19.983823, 25.436618, 52.860394, 24.506206, 65.540195, 67.189531, 19.654040, 40.380944, 80.604689, 25.173621, 36.230661, 55.605222, 18.718728, 21.013557, 79.955775, 41.809889, 62.146243, 75.160404, 55.248279, 31.817126, 84.840955, 3.363256, 9.303951, 10.489783, 30.880029, 27.193963, 40.294701, 78.793099, 35.427758, 61.341772, 83.939695, 3.424470, 16.205403, 44.519114, 72.866607, 6.289826, 72.611963, 29.762563, 71.438753, 41.595104, 83.917656, 75.474430, 73.378168, 58.946189, 57.337567, 29.642240, 29.878809, 1.886119, 6.679723, 69.994033, 25.749330, 69.970126, 12.227837, 77.040907, 41.885777, 29.778460, 52.123409, 55.592782, 32.864481, 40.956327, 83.545615, 37.911024, 15.128270, 62.578132, 56.373511, 82.551089, 53.729747, 53.923855, 64.165566, 21.228749, 13.148640, 42.131671, 11.561653, 4.685280, 60.917214, 24.889187, 59.659915, 61.756350, 5.747454, 55.032688, 52.153569, 74.407956, 54.789970, 48.943050, 47.988140, 21.810502, 57.290930, 41.098693, 22.513113, 54.656511, 38.405212, 37.079668, 4.943716, 44.620422, 41.454321, 50.701590, 11.606680, 5.226876, 30.321632, 32.113316, 24.930143, 75.028449, 57.976205, 35.187805, 26.185295, 82.607492, 42.138925, 84.615277, 62.085871, 53.043648, 20.486560, 46.207055, 31.367658, 17.685044, 62.703941, 9.231036, 38.336908, 84.838413, 43.425584, 38.197237, 7.898696, 19.206855, 74.261800, 70.429789, 79.050487, 58.236040, 20.678369, 56.207554, 0.019347, 31.855237, 23.821297, 16.459032, 53.881731, 5.164422, 18.167930, 66.995750, 55.193257, 51.950831, 45.882602, 38.429189, 9.663183, 20.668273, 32.859989, 12.429392, 79.782888, 4.324367, 79.470542, 75.421491, 67.604061, 49.131995, 41.458390, 6.387935, 52.544066, 80.620278, 39.634726, 54.092772, 16.161082, 24.941499, 24.025911, 74.748528, 54.884119, 16.316827, 16.533593, 6.911258, 13.789017, 24.922250, 69.710483, 58.635213, 44.951313, 1.355386, 73.067328, 49.028702, 16.756084, 5.659834, 10.066875, 82.768150, 71.135964, 80.539145, 50.087676, 16.919133, 21.319288, 64.663468, 17.058124, 82.960681, 28.172583, 74.012357, 34.634449, 68.280725, 70.573557, 30.577151, 52.720745, 28.846623, 76.139983, 41.468023, 69.375737, 64.627107, 1.931989, 71.131253, 34.527356, 55.468044, 4.480182, 28.281676, 44.448856, 23.425285, 28.100782, 0.249373, 23.740510, 0.706815, 83.017726, 66.213774, 32.190081, 18.329976, 65.924360, 30.914312, 72.253944, 37.198861, 46.822804, 61.235854, 27.091036, 23.475469, 30.097150, 76.201192, 35.003050, 33.299103, 40.663928, 40.276939, 68.459777, 20.648398, 52.668675, 33.038405, 44.748974, 8.720476, 7.968213, 72.284442, 61.567790, 66.749001, 83.898302, 74.700663, 49.519438, 41.355694, 29.225568, 64.951155, 3.375410, 44.637970, 23.412788, 83.761908, 66.263875, 41.809746, 70.998404, 22.610789, 82.490596, 78.813240, 56.010968, 9.521543, 33.680399, 33.411429, 53.971917, 27.333447, 55.638604, 83.151663, 34.755365, 43.238785, 68.761147, 70.255755, 37.783400, 41.095684, 72.022390, 7.818467, 83.841957, 58.325199, 24.767349, 59.894988, 52.952448, 64.883558, 79.803485, 51.792527, 67.117949, 55.549126, 32.314533, 5.213959, 54.625753, 77.690067, 63.390064, 13.756395, 5.209311, 55.622299, 10.696016, 36.255481, 44.108548, 4.650816, 82.933132, 80.200623, 32.404868, 77.690236, 62.573607, 80.660612, 73.400398, 62.823352, 24.460526, 41.511024, 45.318613, 75.744142, 26.860302, 42.819044, 68.470832, 34.776042, 41.390110, 35.003028, 83.852516, 10.972007, 73.613687, 7.295474, 74.843421, 83.268482, 32.437806, 54.997930, 51.149227, 54.162707, 77.101558, 7.336239, 46.224127, 12.611428, 65.053526, 77.182825, 82.588507, 48.538669, 23.206885, 41.730295, 6.852046, 52.049281, 59.222761, 17.996343, 2.766760, 31.046225, 29.307523, 27.255367, 73.185507, 12.957760, 10.958058, 25.859316, 76.831584, 37.925548, 35.930234, 82.639392, 29.811818, 6.900862, 13.771680, 63.683304, 44.169587, 7.566410, 58.959354, 72.756671, 67.991150, 44.101985, 45.379164, 33.869857, 46.206717, 15.791002, 3.972520, 56.386966, 49.859696, 22.006788, 6.954533, 56.103231, 68.234047, 83.154848, 20.881052, 42.575636, 40.415194, 56.841277, 11.813972, 25.503581, 24.067010, 42.885553, 68.302369, 72.009761, 27.913966, 79.546752, 12.304608, 12.787380, 40.471754, 66.907671, 73.432136, 5.513215, 70.129964, 10.367430, 78.793080, 70.701217, 69.898581, 59.102714, 37.818025, 9.452469, 28.161716, 15.353885, 76.309277, 33.434685, 47.237172, 54.230549, 34.463318, 7.136113, 21.783789, 23.836630, 55.099012, 78.650122, 71.006960, 31.797779, 11.037478, 10.368823, 36.255991, 14.006141, 28.227948, 13.610889, 34.991300, 71.523439, 37.502533, 1.168342, 45.718138, 56.793563, 47.225504, 8.470782, 57.699719, 20.386146, 61.293621, 11.734308, 74.030931, 25.474744, 71.487989, 55.565964, 13.711926, 7.166509, 24.116030, 49.236295, 50.014678, 72.156606, 40.795790, 27.208785, 15.405532, 84.018800, 2.323696, 72.469189, 4.109215, 18.782732, 22.218565, 52.053031, 83.440946, 36.729405, 11.711661, 84.590932, 72.313688, 83.944450, 26.048743, 10.944874, 60.198315, 22.300541, 14.247502, 9.274989, 63.497453, 60.498177, 17.654432, 65.467013, 36.547434, 3.644284, 12.859042, 77.508169, 58.502242, 61.490364, 81.600971, 7.288648}, 808, output, 86);
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 < 86; ++i)
ok += output[i] != expected_array[i];
if (ok)
{
printf("Powinno być: [5, 6, 4, 13, 11, 10, 14, 13, 5, 9, 12, 11, 12, 8, 4, 8, 12, 7, 8, 4, 8, 6, 10, 8, 13, 9, 7, 12, 9, 11, 9, 7, 12, 11, 10, 9, 8, 13, 7, 5, 15, 17, 8, 7, 14, 9, 10, 6, 9, 6, 7, 7, 15, 6, 12, 13, 11, 8, 8, 10, 5, 7, 11, 11, 10, 11, 8, 13, 8, 7, 11, 11, 16, 8, 10, 8, 7, 9, 7, 12, 9, 6, 13, 24, 8, 0]\n");
printf("\nTablica po wywołaniu funkcji create_histogram: ");
for (int i = 0; i < 86; ++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[] = {0, 2, 1, 1, 5, 2, 2, 1};
int output[] = {1, 1, 1, -1, 1, 1, -2, 2};
printf("#####START#####");
int res = create_histogram((float[]){8.503796, 1.345291, 4.970274, 4.220617, 4.180377, 4.132490, 6.863538, 1.057318, 4.012440, 2.924203, 5.599069, 6.174275, 10.889307, 3.206574, 5.276046, 10.473260, 9.916955, 7.116471, 10.980748, 8.554507, 9.869172}, 21, output, 8);
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 < 8; ++i)
ok += output[i] != expected_array[i];
if (ok)
{
printf("Powinno być: [0, 2, 1, 1, 5, 2, 2, 1]\n");
printf("\nTablica po wywołaniu funkcji create_histogram: ");
for (int i = 0; i < 8; ++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, 1, 0, 0, 0, 0};
int output[] = {-2, 2, 0, 1, -1, 1, 0, 0, -2, -1, -1};
printf("#####START#####");
int res = create_histogram((float[]){6.794850}, 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, 1, 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[]){7.750098, 6.791576, 0.558523, 6.480599, 9.404241, 2.955722, 9.111588, 5.279370, 9.763350, 9.638057, 7.035505, 5.535509, 7.084771, 7.999160, 6.683873, 9.415635, 8.752609, 6.180805, 1.011846, 0.443718, 0.977110, 8.195757, 2.506769, 8.634808}, 24, 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[]){3.248319, 7.396763, 0.484101, 8.145117, 0.999271, 9.671348, 7.294095, 2.887272, 1.471467, 3.921252}, 16, NULL, 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 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, -1, 1, -2, 0, 0, 2, -1, 1, 1};
printf("#####START#####");
int res = create_histogram(NULL, 13, 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[] = {-2, -2, -1, 1, -2, 0, 0, 2, -1, 1, 1};
printf("#####START#####");
int res = create_histogram((float[]){3.248319, 7.396763, 0.484101, 8.145117, 0.999271, 9.671348, 7.294095, 2.887272, 1.471467, 3.921252}, 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[] = {-2, -2, -1, 1, -2, 0, 0, 2, -1, 1, 1};
printf("#####START#####");
int res = create_histogram((float[]){3.248319, 7.396763, 0.484101, 8.145117, 0.999271, 9.671348, 7.294095, 2.887272, 1.471467, 3.921252}, 13, 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, -1, 1, -2, 0, 0, 2, -1, 1, 1};
printf("#####START#####");
int res = create_histogram((float[]){3.248319, 7.396763, 0.484101, 8.145117, 0.999271, 9.671348, 7.294095, 2.887272, 1.471467, 3.921252}, -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 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, -1, 1, -2, 0, 0, 2, -1, 1, 1};
printf("#####START#####");
int res = create_histogram((float[]){3.248319, 7.396763, 0.484101, 8.145117, 0.999271, 9.671348, 7.294095, 2.887272, 1.471467, 3.921252}, 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 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, 0, -7, -4, 1, 1, -3};
//-------------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, -7);
printf("***END***\n");
//-------------3-----------------------
printf("\n***TEST 3***\n\n");
printf("***START***\n");
display_vector(tab, 7);
printf("***END***\n");
//-------------4-----------------------
printf("\n***TEST 4***\n\n");
printf("***START***\n");
display_vector(tab, 7 - 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 = 7;
const float expected_array[] = {-8.000000, 10.000000, 10.000000, -7.000000, 9.000000, 8.000000, -5.000000, 0.000000};
float dest[8];
int result = read_vector_float(dest, 8, 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ć: [-8.000000, 10.000000, 10.000000, -7.000000, 9.000000, 8.000000, -5.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 = 7;
const float expected_array[] = {-2.000000, 8.000000, -10.000000, -1.000000, 6.000000, -3.000000, 0.000000, -4.000000};
float dest[8];
int result = read_vector_float(dest, 8, -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ć: [-2.000000, 8.000000, -10.000000, -1.000000, 6.000000, -3.000000, 0.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[] = {1.000000, 7.000000, 4.000000, 5.000000};
float dest[4];
int result = read_vector_float(dest, 4, -5);
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ć: [1.000000, 7.000000, 4.000000, 5.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[8];
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[10];
printf("#####START#####");
int result = read_vector_float(dest, -1, 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();
}
//
// 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, 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();
}
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();
}