unit_test_v2.c

/*
 * Unit Test Bootstrap
 * Autor: Tomasz Jaworski, 2018-2019
 *
 * Test dla zadania Histogram
 * Autor testowanej odpowiedzi: Szymon Ptak
 * Test wygenerowano automatycznie o 2019-08-22 17:07:13.557569
 *
 * 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, 1, 0, 0, 1, 1, 3, 2, 0, 0, 0};
                int output[] = {-2, 1, -1, -1, 0, -2, 0, 1, -1, -2, -1};
        
                printf("#####START#####");
                int res = create_histogram((float[]){7.969321, 7.836848, 5.232981, 1.782231, 4.455962, 6.470932, 6.481610, 6.096210}, 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ć: [0, 1, 0, 0, 1, 1, 3, 2, 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 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[] = {2, 4, 2, 1, 3, 4, 1, 2, 2, 3, 3};
                int output[] = {2, -1, 1, 1, 1, -2, 1, 0, 1, 1, 2};
        
                printf("#####START#####");
                int res = create_histogram((float[]){10.985397, 4.503601, 1.512195, 5.543511, 8.786003, 1.599027, 0.419482, 2.312369, 5.553299, 7.052401, 5.739536, 4.265490, 0.736611, 2.049116, 10.333840, 3.573445, 9.076917, 4.583299, 10.139140, 1.410495, 1.278876, 5.733157, 9.706714, 6.228879, 9.779346, 7.680008, 8.348204}, 27, 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, 4, 2, 1, 3, 4, 1, 2, 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[] = {18, 14, 11, 11, 14, 19, 13, 16, 11, 8, 15};
                int output[] = {0, 1, -1, -2, 2, 2, 1, 0, 1, 0, 0};
        
                printf("#####START#####");
                int res = create_histogram((float[]){7.557263, 2.534817, 5.238125, 7.397401, 7.970965, 1.802141, 10.805632, 1.111282, 9.864605, 4.481003, 2.878691, 10.836939, 5.605945, 1.666343, 7.997425, 8.212496, 0.641546, 4.434909, 5.234452, 9.341317, 2.886766, 0.503394, 10.714482, 5.931684, 6.212996, 7.243263, 10.317065, 6.213554, 6.759651, 8.867572, 5.590101, 9.706802, 9.565845, 10.064800, 4.456430, 6.707466, 4.301431, 0.687404, 1.036214, 8.243885, 3.768310, 1.418107, 7.306296, 4.654788, 3.148422, 0.946947, 3.915713, 0.777653, 6.901772, 0.742371, 0.976788, 10.805985, 2.719833, 4.791839, 10.166328, 7.934296, 1.431011, 8.296743, 2.336619, 0.599891, 5.676055, 4.933160, 2.123233, 3.274528, 8.500920, 5.518916, 9.431317, 1.885570, 7.722541, 7.820753, 2.756820, 6.786112, 7.079832, 5.571431, 1.604471, 3.729937, 7.576174, 3.151076, 6.727975, 2.060577, 0.291124, 7.307039, 10.279260, 5.305620, 7.780396, 0.799073, 3.197064, 2.659832, 2.160279, 7.857040, 6.206337, 8.884544, 7.852282, 10.948423, 0.586095, 5.837743, 5.079120, 5.261610, 10.985722, 9.076759, 2.269099, 8.531265, 3.445782, 8.095239, 4.719481, 8.511650, 10.343399, 1.011754, 1.675052, 6.224478, 4.638422, 0.887304, 6.717776, 4.557879, 4.878395, 1.065995, 8.341001, 5.750163, 10.281176, 6.738683, 1.047102, 5.810954, 5.613485, 8.066217, 0.257725, 5.505482, 3.604010, 0.281221, 10.868875, 10.069836, 0.797912, 0.044366, 0.216323, 3.395644, 0.332788, 10.293943, 7.364815, 4.779427, 1.345372, 1.750216, 3.248175, 5.628760, 9.299264, 4.549116, 5.730197, 6.825022, 5.740128, 4.550660, 9.539718, 6.002967}, 150, 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ć: [18, 14, 11, 11, 14, 19, 13, 16, 11, 8, 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[] = {2, 0, 1, 0, 1, 1, 0, 1, 0, 0, 0};
                int output[] = {-1, -2, -1, 1, 0, 2, -2, -1, 2, 2, 0};
        
                printf("#####START#####");
                int res = create_histogram((float[]){4.300666, 0.174390, -5.285246, -3.042337, 7.363246, 2.863393, -5.409358, 0.339529, 5.288154, -4.681248}, 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, 0, 1, 0, 1, 1, 0, 1, 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[] = {1, 2, 9, 3, 2, 3, 2, 3, 2, 5, 0};
                int output[] = {-1, 0, -1, -1, -2, 2, 0, -1, -2, 1, -2};
        
                printf("#####START#####");
                int res = create_histogram((float[]){-5.917347, -2.076829, -0.195143, 9.392112, -7.948956, -5.533097, -3.850839, 3.267600, -2.188817, -8.813200, -1.760809, -3.906830, 8.787657, -3.947104, -8.792607, -9.253014, -6.729804, 5.419901, 8.791588, 5.847411, 6.271576, 2.353657, -7.513529, 2.279534, -4.501936, -5.132328, -6.351767, -6.143846, -9.618091, -4.454988, 6.851918, 2.737840, 7.348332, 2.278902, 3.471330, -5.936842, 3.171508, -2.723537, 9.826909, 9.957848, -7.205968, 9.170119, -9.822605, 2.761365, 4.089740, -4.908106, -6.812589, -1.286019, 2.325026, 1.417193, -3.599207, -2.655543, 0.845244, 2.945607, -1.923890, -7.058706, 2.654750, 4.871111, -1.996544, -1.822955, -7.270934, 7.938056, -8.262213, 2.883670, -7.986989, -2.105588, 1.227817, -2.522352, 7.826892, 5.760883, -7.144776, 9.532768, -5.189060, -8.414269}, 74, 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, 9, 3, 2, 3, 2, 3, 2, 5, 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, 7, 7, 5, 5, 6, 6, 7, 8, 2, 6, 1, 6, 4, 7, 5, 7, 3, 2, 3, 0};
                int output[] = {2, -1, 2, -1, -2, 0, 0, -2, 2, 2, -2, 2, -2, 2, 0, -1, -1, 0, 0, -1, -1};
        
                printf("#####START#####");
                int res = create_histogram((float[]){14.993440, 14.238313, 7.302066, 6.347671, 5.801227, 13.504593, 10.501718, 6.238999, 16.298451, 3.381458, 15.015717, 10.372876, 19.414552, 4.556380, 8.117185, 8.322255, 1.465327, 0.194656, 16.381894, 15.842313, 12.654739, 12.009220, 1.959485, 6.868774, 3.531819, 13.249105, 14.412965, 15.412682, 4.482354, 7.940371, 16.853037, 10.480272, 19.160640, 8.662163, 14.280462, 18.608773, 8.435557, 2.637007, 15.614091, 3.872129, 2.693946, 1.475119, 8.717380, 13.500313, 6.040314, 12.606534, 10.493603, 7.344699, 2.573437, 7.242982, 14.039689, 10.887375, 12.532497, 7.612679, 8.584134, 10.389131, 7.736201, 1.902912, 14.908864, 12.708446, 5.602661, 8.885066, 7.561004, 15.008118, 16.569341, 16.118114, 5.470016, 16.853929, 5.705541, 4.708995, 18.595223, 5.997675, 17.256318, 16.657472, 6.066487, 13.391159, 14.947558, 12.925081, 4.159513, 11.933741, 1.603913, 17.573740, 3.316872, 1.585547, 9.327267, 6.033274, 2.101011, 2.845602, 3.524455, 2.495130, 17.977557, 19.733094, 5.785719, 1.841450, 8.087164, 9.126287, 4.426767, 2.915559}, 98, 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, 7, 7, 5, 5, 6, 6, 7, 8, 2, 6, 1, 6, 4, 7, 5, 7, 3, 2, 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[] = {7, 13, 5, 15, 12, 11, 9, 9, 8, 7, 13, 13, 8, 12, 12, 8, 13, 11, 8, 10, 13, 9, 9, 8, 7, 12, 6, 9, 9, 11, 13, 11, 12, 12, 19, 12, 11, 9, 12, 12, 9, 13, 8, 10, 11, 12, 11, 13, 11, 9, 10, 13, 10, 13, 10, 14, 15, 9, 13, 9, 6, 13, 12, 14, 15, 7, 9, 6, 11, 4, 8, 12, 13, 13, 11, 18, 15, 10, 7, 10, 7, 8, 5, 6, 7, 0};
                int output[] = {1, 1, -1, 1, -1, 1, -1, -2, -1, -1, -2, 0, 2, 1, 0, -1, 2, -2, -2, 0, -2, 1, 0, 0, -2, 0, -2, 1, 0, 2, -1, 1, 1, -2, 2, 1, 2, -1, 2, 0, 0, 0, -1, 0, -2, 0, -1, 2, -2, -1, 1, 0, -1, -2, 0, 1, 2, 2, 0, -2, -1, 0, -2, -1, 1, 2, -2, -2, -2, 2, 0, -1, 2, 2, -1, -1, -2, 2, 0, -2, 0, 1, 1, 1, -1, 1};
        
                printf("#####START#####");
                int res = create_histogram((float[]){32.158875, 72.163938, 34.634305, 51.123052, 75.220205, 49.740933, 45.059132, 54.624838, 48.901023, 17.697255, 26.184718, 3.039295, 76.801322, 41.429165, 43.540801, 41.539419, 34.204458, 7.162254, 64.557776, 29.991348, 68.307714, 25.182251, 3.133569, 54.505224, 53.290000, 19.183951, 55.873869, 3.453523, 39.930420, 56.431352, 29.374027, 10.998497, 24.475180, 59.319804, 30.181399, 46.629620, 28.084991, 41.760625, 70.107414, 14.795424, 58.890849, 7.631499, 46.360454, 0.678811, 46.552263, 18.852336, 77.620679, 59.784754, 35.087460, 48.478688, 72.217143, 14.486626, 7.062668, 60.884805, 47.068487, 7.039896, 26.426134, 35.063459, 49.943035, 49.859492, 72.389265, 39.522178, 84.168092, 42.754022, 30.292802, 0.404791, 71.048910, 4.368383, 84.710171, 20.367424, 11.354572, 9.657351, 57.003939, 47.790996, 79.227797, 68.110406, 34.799475, 66.688400, 66.270835, 62.319803, 82.905498, 3.202728, 36.454307, 18.737642, 76.742797, 3.628194, 64.935183, 80.740517, 6.845970, 1.841243, 9.306951, 34.743294, 11.950611, 57.565949, 41.124958, 48.463799, 26.633642, 76.098941, 39.057617, 47.397418, 63.552387, 36.288757, 44.493597, 40.408486, 10.816129, 77.552020, 21.570105, 47.867253, 39.028311, 36.231641, 74.358761, 24.706222, 21.712358, 61.532691, 54.774819, 15.206709, 14.485306, 72.852310, 33.176426, 56.437234, 3.085272, 10.331095, 56.981723, 67.310840, 8.395402, 36.448606, 38.225723, 34.909714, 3.429992, 70.262826, 13.164058, 73.132240, 41.461392, 67.100451, 48.686636, 73.881482, 29.276732, 56.599444, 71.795986, 72.092682, 63.568220, 31.381045, 73.899599, 50.949874, 15.151340, 33.380971, 60.538098, 71.800711, 51.235561, 32.268952, 33.708980, 22.128569, 51.556681, 78.455378, 5.835626, 82.006723, 20.233446, 61.490066, 83.563562, 65.344458, 50.348385, 13.410196, 17.387857, 70.092640, 8.519141, 36.530804, 69.705532, 66.023419, 38.296351, 83.931172, 1.442874, 75.895862, 64.585497, 33.460471, 39.882186, 65.986105, 50.120212, 78.626331, 10.924283, 20.711111, 30.042805, 72.386148, 29.539619, 75.919569, 77.224505, 33.049629, 14.598972, 5.829386, 41.779483, 3.012580, 14.593000, 12.433591, 0.849371, 83.749882, 48.097470, 74.759026, 33.460651, 33.993968, 22.876882, 3.093797, 26.040234, 42.645644, 18.621280, 67.107024, 6.572720, 35.388243, 72.837679, 40.059573, 10.860428, 51.036412, 13.780082, 79.142876, 72.242548, 34.812807, 68.638350, 18.482286, 13.449636, 50.599110, 31.333286, 34.807896, 68.272471, 50.377987, 58.659108, 37.439305, 18.018827, 35.786857, 58.023499, 63.733300, 73.426540, 29.142097, 41.395679, 1.766551, 22.017314, 1.767490, 67.982657, 81.784189, 64.691169, 33.241525, 37.248718, 9.514661, 62.768236, 42.474552, 16.949990, 26.486665, 47.246151, 68.929686, 18.066342, 48.606919, 41.813955, 30.020201, 48.863447, 11.992655, 52.556406, 23.180217, 51.197701, 38.946866, 82.981552, 83.385803, 58.249130, 8.597749, 68.276455, 29.301114, 72.697271, 31.640611, 10.295149, 47.960049, 59.383467, 83.872139, 56.664708, 5.487226, 5.321045, 39.750984, 11.231651, 71.198841, 63.909089, 28.093541, 66.941931, 10.802282, 31.879337, 26.199616, 20.219296, 59.289423, 4.505988, 78.770347, 63.995255, 27.663662, 49.609197, 14.742237, 8.489771, 42.459350, 67.806817, 35.962142, 42.335304, 35.083607, 27.842429, 33.069983, 75.682999, 36.034727, 52.020827, 58.495348, 64.513583, 76.370142, 64.388408, 23.640723, 22.579887, 46.762922, 14.593957, 38.515013, 31.756850, 22.474936, 74.081908, 56.257000, 27.596704, 21.483130, 75.088874, 71.144411, 34.426890, 58.690406, 27.337127, 20.954634, 16.995471, 0.976527, 13.709631, 44.451121, 20.083770, 74.444378, 4.031198, 61.835280, 64.137989, 62.681849, 58.917670, 20.634797, 50.261259, 59.061993, 54.785484, 55.583760, 40.986654, 38.424982, 55.789528, 68.205526, 72.510575, 16.842454, 74.586457, 40.071071, 42.473569, 45.349379, 51.456131, 47.392426, 56.055154, 7.738767, 4.953751, 79.093070, 17.232453, 70.758330, 76.382509, 77.731389, 35.543452, 9.102695, 5.231048, 62.525146, 0.951386, 5.333229, 56.298842, 0.838519, 11.833566, 59.652421, 81.562925, 46.236709, 55.114700, 30.755594, 23.210879, 29.443245, 32.997936, 17.834812, 44.829753, 58.249218, 64.161880, 58.246857, 80.801130, 13.310264, 25.925564, 32.418428, 56.446793, 75.198523, 30.165986, 75.237428, 53.252716, 2.876078, 52.916429, 40.496181, 44.936086, 3.747435, 72.915164, 73.955356, 73.794361, 25.713283, 78.707371, 73.646384, 47.198494, 11.574781, 53.447810, 77.911799, 58.527188, 58.023982, 36.975008, 3.429959, 45.758988, 37.861162, 61.858243, 45.467237, 30.542343, 63.234387, 16.244135, 12.009074, 76.075122, 78.641282, 62.603085, 55.005695, 9.960512, 6.733432, 76.974398, 73.467992, 1.248536, 63.427619, 30.173203, 38.383611, 60.023522, 13.049001, 63.067224, 28.971594, 34.788089, 46.983441, 39.927183, 28.826221, 63.010801, 21.092278, 53.745003, 20.544620, 47.081550, 34.753237, 27.352809, 46.538109, 37.540223, 60.014138, 70.366299, 43.982621, 61.918714, 6.658272, 50.647885, 19.267951, 33.887533, 21.595299, 38.881515, 54.716563, 75.012014, 45.498679, 53.072253, 23.124297, 72.959975, 53.359692, 10.187459, 81.186781, 24.387291, 34.633543, 37.617435, 76.368681, 55.994674, 53.369468, 57.234596, 43.141870, 75.277332, 61.734704, 29.080741, 4.491177, 25.687016, 62.602466, 75.281872, 83.585182, 16.793259, 39.889896, 37.658692, 30.481447, 61.244932, 55.050076, 17.123823, 8.184581, 44.313290, 40.044005, 65.293903, 34.807894, 34.061494, 57.150861, 64.294224, 81.578833, 0.283092, 15.846935, 22.062878, 84.848300, 67.850894, 75.259250, 44.154349, 45.222588, 58.599048, 53.185315, 39.733293, 52.516464, 32.908465, 27.715520, 48.582772, 17.576681, 75.044670, 54.654813, 32.207784, 79.660669, 37.547906, 78.604416, 75.616874, 54.278930, 32.902984, 21.551570, 16.619862, 80.773806, 39.043175, 46.800996, 72.744619, 36.352573, 13.725977, 46.927587, 16.864203, 41.058369, 79.710432, 50.707151, 46.353689, 12.070915, 29.443425, 4.525348, 35.733071, 63.299069, 37.208247, 33.296171, 75.310010, 18.106937, 11.546343, 20.320815, 57.026629, 3.244130, 75.095950, 50.661928, 53.065752, 13.363180, 47.368974, 44.968085, 19.863468, 35.179788, 74.418290, 73.607179, 81.611681, 65.803989, 58.061753, 16.627444, 71.534729, 10.299926, 84.361090, 49.388385, 11.590276, 52.097166, 71.829678, 79.681215, 41.549103, 15.122308, 66.015394, 56.170605, 40.843342, 35.646800, 3.166819, 64.583647, 74.259980, 34.369947, 3.041895, 56.520906, 13.646071, 76.716848, 84.961499, 39.074230, 53.827473, 75.712735, 47.514046, 50.805087, 60.983203, 71.771441, 35.978065, 25.970699, 5.690219, 28.912435, 19.615837, 10.898258, 23.138806, 30.832984, 34.352827, 55.925507, 49.851365, 43.363980, 27.563934, 48.343131, 55.106342, 64.511959, 45.786389, 77.608690, 5.418662, 68.035940, 73.462580, 38.425608, 54.042644, 18.311710, 15.642220, 48.636398, 21.933401, 45.831728, 4.598181, 4.290149, 76.061527, 30.666036, 17.649037, 24.352549, 6.081973, 15.424730, 79.107657, 25.552972, 25.406798, 46.508577, 43.675021, 24.196032, 55.349108, 47.471440, 1.787855, 25.481761, 55.758897, 71.191150, 14.375663, 15.373623, 16.288182, 19.015278, 51.791353, 8.391293, 27.488335, 51.823580, 32.863787, 34.116998, 62.203245, 24.754437, 43.686588, 57.822600, 36.890431, 1.008899, 61.312892, 75.911551, 71.939721, 61.592062, 64.978209, 1.285971, 66.293206, 70.457329, 49.782081, 79.590411, 7.919849, 44.194808, 3.403510, 12.123156, 57.922487, 41.845664, 64.386028, 45.249127, 53.733845, 64.711076, 52.756562, 30.432051, 2.590595, 20.034374, 52.655332, 76.813168, 65.408323, 38.233436, 23.110443, 31.486681, 31.386083, 11.646268, 22.682109, 13.923460, 62.944146, 61.876052, 17.785846, 12.479477, 40.592404, 44.256029, 10.910974, 10.761966, 73.750818, 31.076562, 8.024379, 63.204725, 65.935711, 21.114519, 9.904308, 84.414580, 55.249340, 12.038695, 10.198181, 17.872541, 76.481597, 1.998479, 51.941671, 73.297546, 63.985579, 81.502870, 63.060124, 32.935559, 32.163001, 43.331848, 12.452244, 51.700443, 54.085044, 79.779285, 1.091472, 2.411899, 15.182618, 77.841045, 19.148833, 6.314024, 75.768667, 28.332043, 16.577216, 4.287921, 11.338656, 74.571731, 34.991509, 82.341658, 60.714985, 22.202644, 19.000777, 71.972291, 42.094453, 11.885017, 7.136983, 1.439932, 38.718325, 19.252797, 44.792355, 66.649796, 20.435411, 80.195108, 14.239546, 28.309102, 25.348900, 48.464102, 52.288859, 16.583256, 69.588758, 29.470628, 74.321929, 43.044813, 11.430614, 56.913726, 52.888271, 53.817686, 9.464421, 5.529978, 74.554886, 14.257842, 8.720202, 68.862260, 20.193338, 80.464309, 82.706055, 68.400152, 12.007288, 74.165129, 71.897490, 43.434908, 51.732326, 34.351849, 49.498709, 25.857974, 54.472930, 17.322558, 57.816808, 84.185215, 66.450425, 19.068384, 56.851976, 77.113336, 29.509612, 36.749917, 45.045300, 6.449905, 31.998481, 38.289383, 5.371115, 69.050555, 16.928227, 73.976293, 44.513340, 80.453569, 21.690139, 76.026540, 5.980454, 36.374663, 32.164368, 78.499308, 61.307399, 42.751930, 4.971395, 51.113517, 7.280215, 17.920674, 47.639070, 23.335998, 63.069601, 45.228615, 31.979385, 28.254222, 77.219761, 62.582969, 61.979658, 62.096527, 41.739732, 56.057346, 77.964739, 1.967746, 34.805094, 62.497194, 2.732371, 40.298327, 23.581329, 39.564585, 45.199681, 49.054129, 76.450674, 27.804720, 61.368062, 79.654025, 7.473483, 52.290377, 25.566140, 24.854178, 56.707319, 68.072347, 76.410803, 59.606919, 53.163177, 11.812699, 51.053534, 66.226446, 35.438873, 43.962416, 4.644201, 81.413681, 30.337963, 4.809389, 59.632850, 19.682929, 41.884392, 2.701643, 32.169110, 20.472655, 64.896710, 62.121950, 14.372426, 80.078883, 33.852467, 16.341953, 69.309011, 14.320156, 55.635526, 22.482539, 55.720587, 70.240608, 81.132115, 6.552038, 25.773338, 59.953034, 1.602806, 38.900403, 31.663562, 70.786499, 37.590070, 65.266395, 57.122364, 28.641692, 13.115170, 6.541355}, 890, 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ć: [7, 13, 5, 15, 12, 11, 9, 9, 8, 7, 13, 13, 8, 12, 12, 8, 13, 11, 8, 10, 13, 9, 9, 8, 7, 12, 6, 9, 9, 11, 13, 11, 12, 12, 19, 12, 11, 9, 12, 12, 9, 13, 8, 10, 11, 12, 11, 13, 11, 9, 10, 13, 10, 13, 10, 14, 15, 9, 13, 9, 6, 13, 12, 14, 15, 7, 9, 6, 11, 4, 8, 12, 13, 13, 11, 18, 15, 10, 7, 10, 7, 8, 5, 6, 7, 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[] = {3, 5, 2, 3};
                int output[] = {-1, -1, 2, -2};
        
                printf("#####START#####");
                int res = create_histogram((float[]){1.168217, 7.803291, 10.574004, 0.740388, 9.043714, 4.491352, 5.613773, 6.273281, 4.129251, 4.695813, 5.337615, 4.485827, 10.180119, 8.416504, 3.504443, 6.153408, 6.735734, 1.130892, 1.230816, 1.929331, 5.133123, 2.511752, 8.734218, 8.817884, 2.839807, 3.016491, 6.519936, 7.511917, 5.125783, 10.174273, 7.955836, 6.586053, 7.810331, 4.901399, 4.583173, 5.166767, 6.900294, 10.436036, 3.597766, 0.640244, 7.363401, 8.507898, 0.456287, 6.520880, 1.513777}, 45, 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ć: [3, 5, 2, 3]\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, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0};
                int output[] = {0, 1, -1, -1, 0, -1, -2, 0, -2, -1, -1};
        
                printf("#####START#####");
                int res = create_histogram((float[]){1.462185}, 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, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n");

                    printf("\nTablica po wywołaniu funkcji create_histogram: ");

                    for (int i = 0; i < 11; ++i)
                        printf("%d ", output[i]);            

                    printf("\n");

                    test_error(ok == 0, "Funkcja create_histogram() niepoprawnie wypełniła tablicę");
                }


            
    //
    // -----------
    //

    // przywrócenie podstawowych parametów przydzielania zasobów (jeśli to tylko możliwe)
    rldebug_reset_limits();
    test_file_write_limit_restore();
    
    test_ok();
}

//
//  Test 10: Sprawdzanie poprawności działania funkcji create_histogram
//
void UTEST10(void)
{
    // informacje o teście
    test_start(10, "Sprawdzanie poprawności działania funkcji create_histogram", __LINE__);

    // uwarunkowanie zasobów - pamięci, itd...
    test_file_write_limit_setup(33554432);
    rldebug_reset_limits();
    
    //
    // -----------
    //
    
        
                const int expected_array[] = {0};
                int output[] = {-2};
        
                printf("#####START#####");
                int res = create_histogram((float[]){9.520784, 6.237036, 9.865236, 9.815388, 9.880059, 1.228849, 7.225123, 7.265869, 7.374612, 1.029733, 9.052763, 10.473173, 2.056990, 2.419550, 4.800155, 4.503286, 4.696011, 3.972387, 4.339621, 2.858205, 7.382452, 5.864139, 5.320704}, 23, 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ć: [0]\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[]){7.969321, 7.836848, 5.232981, 1.782231, 4.455962, 6.470932, 6.481610, 6.096210}, 17, NULL, 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 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[] = {0, 1, -1, 1, 1, -2, -2, 2, -2, 1, 2};

            printf("#####START#####");
            int res = create_histogram(NULL, 10, output, 17);
            printf("#####END#####");
            test_error(res == 1, "Funkcja create_histogram() powinna zwrócić 1, a zwróciłą %d", res);
        
    //
    // -----------
    //

    // przywrócenie podstawowych parametów przydzielania zasobów (jeśli to tylko możliwe)
    rldebug_reset_limits();
    test_file_write_limit_restore();
    
    test_ok();
}

//
//  Test 13: Sprawdzanie poprawności działania funkcji create_histogram
//
void UTEST13(void)
{
    // informacje o teście
    test_start(13, "Sprawdzanie poprawności działania funkcji create_histogram", __LINE__);

    // uwarunkowanie zasobów - pamięci, itd...
    test_file_write_limit_setup(33554432);
    rldebug_reset_limits();
    
    //
    // -----------
    //
    

            int output[] = {0, 1, -1, 1, 1, -2, -2, 2, -2, 1, 2};

            printf("#####START#####");
            int res = create_histogram((float[]){7.969321, 7.836848, 5.232981, 1.782231, 4.455962, 6.470932, 6.481610, 6.096210}, 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[] = {0, 1, -1, 1, 1, -2, -2, 2, -2, 1, 2};

            printf("#####START#####");
            int res = create_histogram((float[]){7.969321, 7.836848, 5.232981, 1.782231, 4.455962, 6.470932, 6.481610, 6.096210}, 12, 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[] = {0, 1, -1, 1, 1, -2, -2, 2, -2, 1, 2};

            printf("#####START#####");
            int res = create_histogram((float[]){7.969321, 7.836848, 5.232981, 1.782231, 4.455962, 6.470932, 6.481610, 6.096210}, -17, output, 13);
            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[] = {0, 1, -1, 1, 1, -2, -2, 2, -2, 1, 2};

            printf("#####START#####");
            int res = create_histogram((float[]){7.969321, 7.836848, 5.232981, 1.782231, 4.455962, 6.470932, 6.481610, 6.096210}, 10, output, -20);
            printf("#####END#####");
            test_error(res == 1, "Funkcja create_histogram() powinna zwrócić 1, a zwróciłą %d", res);
        
    //
    // -----------
    //

    // przywrócenie podstawowych parametów przydzielania zasobów (jeśli to tylko możliwe)
    rldebug_reset_limits();
    test_file_write_limit_restore();
    
    test_ok();
}

//
//  Test 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[] = {-7, 1, 5, -9, 2, 4, -7, 4, -4, 8, 0, 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 = 8;
                const float expected_array[] = {-5.000000, 8.000000, -5.000000, 10.000000, -2.000000, 2.000000, -1.000000, -10.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ć: [-5.000000, 8.000000, -5.000000, 10.000000, -2.000000, 2.000000, -1.000000, -10.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[] = {0.000000, -7.000000, -5.000000, -4.000000, -7.000000, -10.000000, -10.000000, -1.000000, 5.000000, 10.000000, -3.000000, -8.000000};
                float dest[12]; 
                int result = read_vector_float(dest, 12, -8);           

                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, -7.000000, -5.000000, -4.000000, -7.000000, -10.000000, -10.000000, -1.000000, 5.000000, 10.000000, -3.000000, -8.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 = 5;
                const float expected_array[] = {-6.000000, -9.000000, 9.000000, -8.000000, -2.000000};
                float dest[5]; 
                int result = read_vector_float(dest, 5, -7);           

                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ć: [-6.000000, -9.000000, 9.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 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, -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 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[5]; 
            printf("#####START#####");
            int result = read_vector_float(dest, -8, -4);           
            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, -5, 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();
}




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();
}