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 16:58:01.914710
 *
 * 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, 1, 2, 1, 1, 2, 1, 0, 0};
                int output[] = {-1, 2, -2, -1, -1, 0, -1, 2, 1, 2, 0};
        
                printf("#####START#####");
                int res = create_histogram((float[]){7.938942, 5.713792, 1.138151, 8.536770, 7.251282, 6.141237, 3.511448, 4.888053, 4.733629}, 9, 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, 1, 2, 1, 1, 2, 1, 0, 0]\n");

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

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

                    printf("\n");

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


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

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

//
//  Test 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, 1, 4, 3, 5, 4, 6, 5, 4, 2, 4};
                int output[] = {2, 1, 0, 1, 1, 1, -2, 1, -1, -1, -1};
        
                printf("#####START#####");
                int res = create_histogram((float[]){6.487766, 5.000259, 7.812578, 6.110739, 2.095735, 8.343809, 8.491932, 2.571759, 8.723509, 3.743391, 7.589419, 5.644975, 9.613233, 10.382364, 9.355035, 4.571906, 0.003308, 1.748070, 3.584098, 4.494696, 8.135921, 0.496857, 10.104497, 4.118183, 5.084666, 7.328033, 7.599392, 6.301365, 0.598659, 10.370054, 4.271365, 6.726306, 6.837596, 2.969742, 0.245015, 7.267533, 4.807535, 2.370122, 3.015173, 10.795307, 5.448295, 6.854265}, 42, 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, 1, 4, 3, 5, 4, 6, 5, 4, 2, 4]\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[] = {12, 13, 11, 13, 16, 14, 17, 14, 14, 18, 11};
                int output[] = {-1, -2, 0, -2, -1, 1, 1, 0, 2, -2, 2};
        
                printf("#####START#####");
                int res = create_histogram((float[]){10.096922, 10.052648, 10.516417, 8.540349, 9.133268, 10.134436, 1.729003, 9.075808, 7.331829, 6.360146, 7.685922, 6.867292, 3.251034, 4.445868, 8.856111, 10.087786, 2.066575, 7.940765, 10.265017, 5.417298, 9.723204, 3.067012, 8.230946, 6.945043, 0.051090, 8.402864, 0.832737, 9.836041, 10.582614, 7.421640, 5.370797, 3.276389, 1.976237, 1.889114, 2.999796, 8.667296, 5.321107, 0.887835, 7.607149, 4.481518, 1.025542, 6.081039, 0.365137, 1.318896, 0.713756, 9.440863, 2.387585, 3.785063, 6.480798, 4.493605, 6.790874, 3.894076, 6.769838, 7.144577, 9.566577, 1.286676, 3.614320, 7.850297, 4.193646, 10.845479, 10.775040, 4.015960, 2.009723, 3.247938, 1.100783, 4.746712, 9.160727, 6.195371, 3.848730, 6.190904, 7.639511, 0.354408, 5.955636, 1.991369, 9.128492, 4.499877, 2.603378, 1.759383, 8.190702, 8.270962, 6.424425, 7.512823, 2.051856, 2.094227, 9.995542, 7.242534, 5.402377, 7.450468, 8.583585, 4.255908, 1.361399, 5.083089, 5.875920, 2.168074, 8.665416, 3.328077, 2.366626, 3.606555, 4.569618, 5.179782, 6.300181, 0.426311, 3.911288, 4.873447, 0.587809, 9.717008, 1.394787, 9.437775, 2.832498, 6.952114, 5.731308, 5.124663, 4.998791, 9.591460, 9.220926, 5.712855, 4.373404, 7.463383, 0.764782, 3.819076, 2.004510, 8.606611, 8.660466, 3.923400, 0.809085, 6.386246, 9.261875, 10.019333, 5.072116, 5.020243, 4.438131, 4.406954, 9.166580, 6.694359, 9.150977, 0.634901, 8.896593, 9.765858, 6.534001, 8.698442, 1.279170, 6.044661, 7.560236, 8.945730, 7.230648, 0.545104, 1.633115, 4.316685, 10.371893, 4.944596, 6.126894, 5.614244, 9.106972}, 153, 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ć: [12, 13, 11, 13, 16, 14, 17, 14, 14, 18, 11]\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, 0, 0, 0, 0, 0};
                int output[] = {2, -2, -1, 0, 2, 2, 1, 0, 1, 2, -2};
        
                printf("#####START#####");
                int res = create_histogram((float[]){-6.741886, -9.401240}, 2, output, 11);
                printf("#####END#####");
                test_error(res == 0, "Funkcja create_histogram() powinna zwrócić 0, a zwróciłą %d", res);


                int ok = 0;        
                for (int i = 0; i < 11; ++i)
                    ok += output[i] != expected_array[i];
                    
                if (ok)
                {         
                    printf("Powinno być: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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[] = {8, 4, 11, 5, 3, 2, 4, 8, 3, 4, 0};
                int output[] = {0, -2, -1, 0, 2, -1, 0, 1, -2, -1, -2};
        
                printf("#####START#####");
                int res = create_histogram((float[]){2.015029, 8.149120, -0.548951, 7.480322, 2.113282, 1.245753, -3.721712, -0.682773, -7.963329, 9.962218, 2.657350, 1.944444, -3.887847, 1.485859, -6.616069, 2.041178, 0.754159, 7.549575, -6.574758, 6.793397, -9.653250, 8.396692, -5.550370, 0.645532, 6.776153, -2.698630, -3.009344, -2.990231, -9.190864, -7.539394, 2.556577, 4.672688, 7.954218, 5.915646, -4.312455, 0.118566, 3.962232, -5.597021, 6.646157, -6.383589, 7.363990, 2.879060, -8.118892, 8.287970, 1.856676, 7.585387, 0.088885, 7.383964, -0.062833, 0.426964, -3.692688, -0.819056, 2.131738, 9.052470, 3.401850, 0.977459, -0.362770, -1.812326, -8.058963, -1.874792, 4.499073, -2.636939, 4.993462, 9.046521, 7.089637, -7.351338, 3.374227, 2.918204, 3.213473, -0.614683, 2.165419, -6.212059, -9.415917, 3.840017, -2.964898, 9.331398, -5.082125, -1.246356, 2.555016, 0.556906, 7.680879, -2.297820, -7.341564, 0.414788, -8.406608, -7.067042, -9.435274, -3.659087, 5.518591, -5.151442, 6.111247, -4.976686, -9.994270, 2.731392}, 94, 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ć: [8, 4, 11, 5, 3, 2, 4, 8, 3, 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[] = {7, 5, 2, 2, 1, 3, 5, 5, 4, 4, 2, 6, 6, 5, 5, 4, 2, 2, 3, 3, 0};
                int output[] = {0, 2, -2, -1, 1, -1, -1, -1, -1, -1, 1, 0, -2, 0, 1, 0, 0, 1, -1, 0, -1};
        
                printf("#####START#####");
                int res = create_histogram((float[]){0.605293, 3.779372, 12.446610, 6.185750, 11.905466, 0.375530, 12.805834, 8.099900, 11.769228, 18.645228, 16.017470, 19.606826, 7.765876, 5.214672, 17.982375, 9.762370, 15.178923, 5.692232, 7.775885, 11.439272, 0.691723, 8.248699, 9.855102, 19.645592, 13.591729, 18.286106, 11.445369, 15.289142, 1.787287, 5.754896, 13.715025, 2.249448, 1.800096, 13.041107, 6.003395, 10.056571, 8.408904, 6.594098, 10.332523, 12.288726, 18.818192, 1.810269, 15.735674, 16.763230, 0.932871, 6.766331, 14.611270, 11.916672, 8.625327, 19.071929, 14.981429, 2.459448, 14.974346, 13.983622, 7.317777, 0.517713, 17.791785, 11.121582, 3.563255, 9.959711, 12.233129, 4.192209, 0.884660, 14.795053, 9.036690, 15.423195, 14.685114, 12.972913, 1.255676, 0.514286, 7.410211, 13.067835, 12.226145, 7.132193, 6.524956, 1.264178}, 76, 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ć: [7, 5, 2, 2, 1, 3, 5, 5, 4, 4, 2, 6, 6, 5, 5, 4, 2, 2, 3, 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[] = {13, 13, 19, 9, 14, 10, 12, 12, 7, 14, 8, 13, 8, 9, 7, 14, 6, 7, 11, 14, 13, 9, 12, 6, 10, 15, 11, 10, 13, 13, 7, 21, 8, 12, 15, 14, 13, 11, 9, 6, 11, 10, 11, 12, 18, 8, 13, 12, 7, 11, 11, 6, 14, 18, 13, 9, 11, 14, 9, 8, 15, 13, 12, 13, 11, 12, 12, 17, 12, 7, 13, 5, 21, 10, 10, 19, 13, 10, 9, 10, 11, 13, 7, 0};
                int output[] = {-1, -2, -1, 2, -1, -1, -2, -1, -1, -2, 0, -1, 1, 0, 1, 1, -1, -2, 1, -2, 0, 1, 0, 0, -1, 1, -1, -2, 0, -2, -1, 1, 2, 0, 0, 0, 1, 0, 0, -2, -1, -2, -1, 1, -1, 2, -1, -1, 0, -1, -1, 1, 0, 1, 0, 2, -1, 2, -1, -2, 2, 2, 0, -1, -2, -1, 2, 2, 1, 0, -2, 0, 2, -2, 0, 0, 2, 0, -1, -2, 0, -2, 1, -2};
        
                printf("#####START#####");
                int res = create_histogram((float[]){33.073520, 14.337440, 9.305254, 38.638664, 28.569868, 69.351251, 11.812814, 69.686786, 11.749761, 57.356612, 35.470914, 37.468569, 74.596971, 26.611222, 44.491543, 10.538320, 43.070517, 0.423440, 19.877937, 64.948381, 30.303110, 44.743060, 25.794124, 17.125921, 0.922682, 9.754448, 53.523290, 53.213342, 32.145405, 62.410538, 12.259181, 34.749208, 26.723121, 7.494690, 5.081168, 67.871910, 11.161615, 71.087409, 58.588804, 35.043900, 5.749831, 70.098237, 57.465949, 56.957694, 69.926126, 36.626986, 5.907631, 49.220148, 70.280825, 15.099335, 78.891334, 52.059637, 61.460377, 11.513751, 80.391175, 75.677810, 8.361398, 13.794902, 14.940027, 0.153041, 31.469165, 51.420020, 36.733768, 38.059683, 78.421096, 20.620815, 32.761713, 15.307058, 53.904569, 54.812162, 22.591497, 81.368841, 66.300645, 15.013229, 37.748890, 33.553965, 47.034081, 33.166120, 72.617137, 72.805898, 67.006288, 65.091338, 29.652276, 60.392404, 82.336296, 33.100971, 2.383573, 40.261301, 56.499437, 25.969001, 28.585407, 56.333336, 66.618680, 25.717625, 6.791253, 6.958724, 80.614882, 6.901295, 44.400950, 75.062676, 74.526933, 65.031337, 7.104897, 77.177107, 28.625039, 72.395435, 19.805155, 28.990856, 24.412336, 76.871707, 36.431639, 40.661540, 73.023201, 30.836286, 42.333326, 54.562775, 44.129765, 6.137627, 24.882800, 55.056794, 15.054756, 73.958790, 31.790129, 76.063021, 46.409586, 1.020123, 50.841345, 35.303545, 75.234802, 21.512608, 73.413251, 22.658970, 63.092903, 40.354769, 20.684848, 26.002263, 62.844162, 10.667119, 49.738220, 67.761908, 59.480749, 67.639748, 73.507704, 10.214829, 56.414415, 35.482111, 47.282750, 27.681864, 40.472718, 18.244947, 68.884137, 79.442111, 2.687558, 49.413118, 51.135804, 78.710584, 0.695994, 54.091676, 22.503197, 29.474856, 12.413683, 57.491082, 22.132323, 26.730334, 44.158012, 43.684904, 34.195025, 73.725366, 30.669213, 53.420041, 26.650419, 17.737212, 36.426359, 13.177053, 25.712084, 53.186291, 1.628618, 68.571550, 54.054479, 58.336351, 41.127043, 52.612186, 44.687667, 19.900691, 65.942517, 20.352266, 46.753429, 60.849748, 7.036128, 65.069591, 75.606858, 80.385180, 61.326487, 62.385390, 1.294406, 15.326086, 47.956991, 66.588849, 53.886010, 75.842195, 9.751245, 14.355502, 31.328278, 55.805948, 11.436368, 60.384464, 67.710263, 55.836914, 39.746343, 5.717742, 21.521146, 35.579489, 72.484718, 31.117579, 47.019222, 19.964158, 77.851777, 37.193865, 8.457142, 55.403693, 45.133290, 71.876955, 19.918044, 65.389301, 17.712111, 9.347146, 49.049864, 51.597422, 4.704330, 57.080821, 23.134251, 0.993408, 70.321491, 55.218408, 38.255063, 13.268733, 76.676107, 28.883594, 46.308250, 77.697918, 25.723673, 18.387478, 31.192256, 48.750998, 65.140781, 31.255013, 68.879417, 60.293247, 63.579357, 59.291267, 17.997630, 3.409269, 68.112019, 16.903866, 5.763013, 58.276880, 57.618725, 73.123502, 29.732432, 81.533717, 63.946189, 15.067081, 64.473585, 42.976122, 10.365021, 34.290094, 0.037872, 32.572773, 59.994533, 26.127709, 3.079407, 29.544752, 50.832648, 6.369971, 13.759286, 42.570805, 77.168661, 2.359801, 34.586604, 9.075289, 63.575895, 47.825145, 81.315835, 32.742761, 52.723780, 69.234744, 34.797060, 9.129941, 4.915598, 45.145852, 31.688085, 2.970846, 74.988306, 25.940068, 67.701318, 21.382649, 67.221936, 63.959268, 20.370559, 7.566460, 4.367839, 72.362944, 61.344681, 53.966743, 40.790440, 11.915930, 79.275944, 75.688260, 2.506454, 6.234220, 24.710192, 61.243535, 76.796298, 65.032948, 46.078423, 43.439134, 20.929327, 52.808595, 43.880751, 72.324353, 53.547734, 10.087515, 31.711106, 57.553353, 35.182347, 66.096042, 31.061632, 47.095461, 9.599193, 17.689178, 9.763279, 20.948461, 11.800770, 37.365760, 23.710138, 43.028578, 70.543219, 25.820345, 79.584310, 22.472622, 52.708402, 2.100367, 42.026145, 46.296439, 25.067443, 46.305977, 9.272712, 53.552406, 49.034403, 37.505342, 22.830532, 56.533950, 41.071980, 38.515820, 75.860230, 33.712818, 46.745701, 18.460387, 1.517316, 58.318912, 70.060592, 31.058826, 42.740868, 63.365015, 75.078677, 34.135001, 63.183525, 18.310509, 76.855389, 28.676382, 3.401905, 30.094608, 21.380881, 49.732925, 19.037288, 54.128298, 44.612763, 59.725025, 77.842630, 44.402152, 66.544739, 28.481931, 44.845464, 31.760136, 80.899451, 58.226581, 20.525113, 22.034622, 2.051557, 36.726295, 76.068374, 31.628217, 76.594783, 78.447869, 66.173564, 45.712712, 69.355959, 4.077682, 21.384698, 82.537209, 4.739265, 3.405503, 61.420895, 48.577743, 53.964563, 40.687131, 25.973063, 12.824162, 41.793088, 15.467515, 41.075231, 24.190898, 2.298632, 75.396762, 78.062860, 75.132504, 40.889461, 60.371179, 0.909284, 79.593572, 36.529988, 6.286833, 45.268524, 10.495946, 33.875135, 61.670785, 72.646106, 2.039775, 78.606428, 15.154297, 55.558957, 68.232807, 81.279785, 46.647219, 49.547955, 27.974629, 12.583893, 27.896306, 75.312654, 12.539291, 54.767294, 16.776741, 82.085964, 71.592200, 63.691228, 28.845109, 16.852365, 67.892493, 10.154837, 52.784309, 75.305475, 27.306695, 15.207414, 3.728030, 57.260549, 35.319244, 6.622912, 38.312207, 40.303313, 76.915717, 14.372236, 11.662944, 38.257322, 31.909900, 62.327014, 43.897972, 33.340296, 50.789761, 49.406379, 35.952427, 0.932037, 39.987732, 12.672193, 23.218534, 4.564750, 74.394241, 59.556122, 12.323027, 36.538559, 24.128733, 67.047209, 40.976493, 22.950052, 2.689139, 61.880391, 81.453514, 39.719666, 27.733716, 22.052651, 60.909274, 76.379569, 80.584439, 13.748775, 47.473791, 54.334451, 39.020867, 58.884697, 29.374140, 81.447229, 77.011004, 76.794532, 48.504629, 15.518293, 29.500455, 2.343992, 73.498868, 43.848895, 14.542737, 79.116389, 80.597327, 68.705343, 72.386441, 13.216717, 36.455741, 36.384584, 80.215301, 74.233862, 70.431141, 22.297900, 0.028956, 79.007232, 19.807011, 53.034549, 45.003674, 38.760646, 79.501082, 56.526081, 28.390618, 72.562131, 3.509006, 2.827208, 72.680342, 73.630090, 67.268253, 78.909896, 11.282059, 66.669743, 52.984736, 57.701223, 82.514227, 63.483810, 70.998232, 39.842274, 22.975346, 59.670955, 63.914582, 72.933560, 30.934933, 27.769362, 70.258324, 18.797295, 44.400055, 61.745994, 27.482541, 50.431049, 33.596629, 79.812095, 60.219250, 67.888209, 45.700224, 47.571799, 75.173458, 53.219201, 70.033967, 75.825755, 35.462374, 35.181038, 52.315613, 19.034472, 0.002830, 2.572407, 18.277064, 31.866461, 35.481638, 28.496405, 17.360978, 54.565097, 29.326302, 29.904971, 72.262900, 60.300129, 53.422676, 13.617795, 9.566469, 5.381644, 60.736474, 78.876606, 67.759967, 77.909436, 50.431096, 68.712043, 14.698565, 8.327592, 52.122069, 13.853371, 36.856944, 76.016912, 18.147250, 54.937419, 62.601018, 40.211614, 46.438038, 53.374799, 26.146168, 76.013922, 72.577893, 16.174539, 77.155049, 37.008096, 77.754680, 47.153727, 1.631964, 1.713624, 38.009923, 81.806399, 50.250170, 34.425016, 0.296584, 25.712176, 18.153023, 80.161658, 6.311591, 64.329881, 20.268105, 50.094920, 35.152886, 20.786446, 81.448792, 3.004682, 72.938289, 21.065560, 47.624023, 56.186547, 25.598447, 57.541881, 68.968853, 44.375633, 81.037552, 27.787871, 32.986350, 19.015722, 38.858510, 47.492084, 82.258942, 19.324317, 11.797347, 66.445316, 53.345676, 81.943059, 1.479848, 57.517359, 58.793766, 34.956018, 72.579547, 70.639576, 41.270537, 63.885513, 31.733514, 25.904308, 9.732270, 32.979314, 46.619827, 56.751991, 29.828249, 14.488848, 42.231465, 6.225869, 45.760129, 63.107884, 29.225745, 73.846683, 59.399411, 21.720521, 53.056175, 1.090512, 28.149769, 4.552374, 74.016105, 0.781575, 4.991051, 75.210189, 77.195222, 72.221928, 60.308075, 44.767433, 54.691651, 7.766349, 34.541790, 81.782186, 23.777015, 7.173264, 2.190507, 4.883261, 2.431571, 24.759644, 49.063852, 71.067983, 25.405470, 57.410442, 45.369462, 31.654119, 28.975379, 1.391709, 15.013716, 78.832716, 6.350434, 5.877500, 58.562249, 37.215675, 68.710671, 30.420464, 66.074657, 65.278582, 44.097971, 37.437210, 68.833958, 33.653883, 66.383555, 52.026110, 25.038443, 4.970192, 37.640264, 22.081918, 42.521400, 64.701783, 68.187086, 2.286440, 26.550195, 37.926026, 42.147305, 33.684730, 66.715382, 2.369079, 44.767702, 61.290465, 79.219920, 75.192520, 33.570597, 9.017466, 25.903414, 62.067211, 62.063662, 43.830487, 67.388561, 34.869779, 4.355661, 61.595343, 82.832385, 42.597448, 50.716662, 75.905431, 44.797736, 72.279991, 32.215815, 66.714432, 82.524021, 19.266405, 26.895453, 29.692385, 39.806954, 19.137545, 67.940343, 64.924518, 70.336554, 56.409346, 72.090725, 40.377838, 52.462908, 27.501263, 7.686020, 29.182307, 29.947605, 4.882578, 65.786876, 62.291152, 19.566329, 21.943305, 5.350114, 51.273124, 5.242031, 72.036172, 8.553368, 2.501425, 34.744357, 17.127145, 51.588441, 73.812880, 62.851730, 79.538046, 7.762220, 61.309664, 53.394587, 26.792154, 64.061384, 60.738664, 37.847610, 3.371347, 70.585124, 43.805095, 36.408900, 56.749419, 48.057705, 21.543619, 52.371056, 61.288605, 57.847039, 74.098358, 58.898384, 8.603888, 43.432021, 28.421390, 27.338224, 74.450896, 36.283178, 41.281820, 32.326645, 9.162598, 6.826912, 60.924560, 31.016632, 9.236572, 55.361886, 49.020502, 64.533049, 52.013992, 13.267696, 43.252316, 3.070804, 11.532686, 74.694038, 4.954156, 44.997776, 60.866674, 49.042853, 31.847237, 68.830313, 63.192102, 59.207344, 41.148418, 15.047128, 46.513709, 64.334802, 65.336251, 34.543636, 35.534205, 42.284175, 46.754807, 56.974935, 75.600760, 1.906368, 47.578907, 15.092411, 36.728474, 81.351732, 18.438823, 1.935056, 1.866481, 18.184839, 42.821654, 80.299074, 5.169503, 72.507087, 20.383289, 7.465182, 41.465701, 74.622863, 46.666332, 71.062451, 54.866866, 80.233944, 44.309641, 7.055231, 62.842397, 34.090577, 72.203734, 55.466796, 75.239112, 31.868777, 19.276308, 64.745353, 24.333274, 43.027501, 15.696175, 76.544101, 65.467158, 62.148178, 48.456600, 24.696241, 20.882301, 54.973968, 18.303287, 48.299648, 0.569587, 1.445321, 24.734557, 12.777806, 11.991966, 20.598025, 7.944943, 60.696372, 50.523201, 53.012468, 41.419505, 10.050964, 33.602912, 51.635223, 2.398073, 24.514319, 41.639468, 61.141144, 81.183279, 64.652682, 8.265403, 31.990756, 11.386527, 70.806016, 23.903375, 16.159314, 65.566926, 54.756382, 16.110062, 52.961757, 34.863222, 48.243316, 69.712888, 23.067428, 57.918941, 57.628433, 80.227861, 26.242093, 67.807626, 20.085899, 34.902201, 50.559197, 69.536007, 55.524032, 44.777380, 31.370653, 35.723606, 7.844074, 67.740955, 50.431051, 62.033264, 67.513862, 60.856241, 30.223584, 4.066636, 8.686211, 64.061915}, 949, output, 84);
                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 < 84; ++i)
                    ok += output[i] != expected_array[i];
                    
                if (ok)
                {         
                    printf("Powinno być: [13, 13, 19, 9, 14, 10, 12, 12, 7, 14, 8, 13, 8, 9, 7, 14, 6, 7, 11, 14, 13, 9, 12, 6, 10, 15, 11, 10, 13, 13, 7, 21, 8, 12, 15, 14, 13, 11, 9, 6, 11, 10, 11, 12, 18, 8, 13, 12, 7, 11, 11, 6, 14, 18, 13, 9, 11, 14, 9, 8, 15, 13, 12, 13, 11, 12, 12, 17, 12, 7, 13, 5, 21, 10, 10, 19, 13, 10, 9, 10, 11, 13, 7, 0]\n");

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

                    for (int i = 0; i < 84; ++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[] = {5, 4, 3, 1};
                int output[] = {2, -2, -1, -1};
        
                printf("#####START#####");
                int res = create_histogram((float[]){6.691512, 8.776949, 9.976382, 2.669387, 0.474201, 10.643619, 8.356188, 9.592034, 6.334474, 5.840120, 5.027001, 8.812200, 2.719379, 4.719196, 3.685137, 1.695020, 5.970790, 8.685085, 6.166047, 0.300847, 7.625271, 10.086361, 6.106419, 1.684586, 0.534764, 5.758429, 7.595970, 7.251840, 9.482570, 1.525704, 8.905174, 6.029340, 4.006268, 0.545620, 8.427905, 6.410961, 4.226560, 10.629104, 7.022342, 6.762678, 6.169609, 7.582488, 8.173743, 4.319072, 0.734233, 10.164523, 10.530074, 1.149202, 4.283798, 8.386974, 2.203475, 10.466235}, 52, 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ć: [5, 4, 3, 1]\n");

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

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

                    printf("\n");

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


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

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

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

    // uwarunkowanie zasobów - pamięci, itd...
    test_file_write_limit_setup(33554432);
    rldebug_reset_limits();
    
    //
    // -----------
    //
    
        
                const int expected_array[] = {0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0};
                int output[] = {2, -2, 1, -2, 0, -2, 0, -2, -2, -1, -1};
        
                printf("#####START#####");
                int res = create_histogram((float[]){6.823536}, 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[] = {1};
                int output[] = {0};
        
                printf("#####START#####");
                int res = create_histogram((float[]){3.130862, 10.812756, 10.357044, 10.806153, 7.180884, 6.445729, 10.980905, 0.105436, 9.026951, 2.339348, 10.661414, 8.447149, 8.891426, 9.838556, 6.581373, 9.484549, 8.823136, 2.182491, 5.946154, 10.698690, 5.659457, 4.683278, 3.703923, 9.093431, 5.734369, 9.838062, 2.230893, 9.390027, 9.122054, 6.178924, 10.617069, 9.286249, 2.859469, 5.230054, 8.673731, 8.326881, 3.391105, 2.754372, 5.565092, 10.746590, 10.419562, 7.265516, 3.702712, 8.238838, 9.536672, 4.653223, 9.760084}, 47, 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ć: [1]\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.938942, 5.713792, 1.138151, 8.536770, 7.251282, 6.141237, 3.511448, 4.888053, 4.733629}, 10, NULL, 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 12: Sprawdzanie poprawności działania funkcji create_histogram
//
void UTEST12(void)
{
    // informacje o teście
    test_start(12, "Sprawdzanie poprawności działania funkcji create_histogram", __LINE__);

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

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

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

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

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

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

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

            printf("#####START#####");
            int res = create_histogram((float[]){7.938942, 5.713792, 1.138151, 8.536770, 7.251282, 6.141237, 3.511448, 4.888053, 4.733629}, 0, 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 14: Sprawdzanie poprawności działania funkcji create_histogram
//
void UTEST14(void)
{
    // informacje o teście
    test_start(14, "Sprawdzanie poprawności działania funkcji create_histogram", __LINE__);

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

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

            printf("#####START#####");
            int res = create_histogram((float[]){7.938942, 5.713792, 1.138151, 8.536770, 7.251282, 6.141237, 3.511448, 4.888053, 4.733629}, 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, -1, 2, 2, 2, -2, 0, -1, 2, 2, -2};

            printf("#####START#####");
            int res = create_histogram((float[]){7.938942, 5.713792, 1.138151, 8.536770, 7.251282, 6.141237, 3.511448, 4.888053, 4.733629}, -20, output, 10);
            printf("#####END#####");
            test_error(res == 1, "Funkcja create_histogram() powinna zwrócić 1, a zwróciłą %d", res);
        
    //
    // -----------
    //

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

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

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

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

            printf("#####START#####");
            int res = create_histogram((float[]){7.938942, 5.713792, 1.138151, 8.536770, 7.251282, 6.141237, 3.511448, 4.888053, 4.733629}, 15, output, -19);
            printf("#####END#####");
            test_error(res == 1, "Funkcja create_histogram() powinna zwrócić 1, a zwróciłą %d", res);
        
    //
    // -----------
    //

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

//
//  Test 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[] = {8, -10, 1, -10, 0, -2, 7, -7};

        //-------------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, -8);
                printf("***END***\n");

        //-------------3-----------------------

                printf("\n***TEST 3***\n\n");
                printf("***START***\n");
                display_vector(tab, 8);
                printf("***END***\n");

        //-------------4-----------------------

                printf("\n***TEST 4***\n\n");
                printf("***START***\n");
                display_vector(tab, 8 - 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 = 5;
                const float expected_array[] = {-8.000000, -7.000000, -1.000000, -1.000000, -2.000000, 0.000000};
                float dest[6]; 
                int result = read_vector_float(dest, 6, 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, -7.000000, -1.000000, -1.000000, -2.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, 7.000000, 0.000000, 10.000000, 1.000000, 3.000000, -9.000000, -5.000000};
                float dest[8]; 
                int result = read_vector_float(dest, 8, -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ć: [2.000000, 7.000000, 0.000000, 10.000000, 1.000000, 3.000000, -9.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 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[] = {-2.000000, 0.000000, -5.000000, -2.000000, -4.000000};
                float dest[5]; 
                int result = read_vector_float(dest, 5, -6);           

                test_error(result == expected_result, "Funkcja read_vector_float() powinna zwrócić %d, a zwróciła %d", expected_result, result);
                int ok = 0;
                for (int i = 0; i < expected_result; ++i)
                    ok += !(expected_array[i] + 0.001 >= dest[i] && expected_array[i] - 0.001 <= dest[i]);

                test_error(ok == 0, "Funkcja read_vector_float() niepoprawnie pobrałá dane od użytkownika");
                if (ok)
                {
                    printf("Powinno być: [-2.000000, 0.000000, -5.000000, -2.000000, -4.000000]\n");
                    printf("Jest: [");
                    for (int i = 0; i < expected_result - 1; ++i)
                        printf("%f, ", dest[i]);

                    printf("%f] ", dest[expected_result - 1]);

                }

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

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

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

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

            int expected_result = -1;
            float dest[9]; 
            printf("#####START#####");
            int result = read_vector_float(dest, 0, -9);           
            printf("#####END#####");

            test_error(result == expected_result, "Funkcja read_vector_float() powinna zwrócić %d, a zwróciła %d", expected_result, result);
        
    //
    // -----------
    //

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

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

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

            int expected_result = -1;
            float dest[6]; 
            printf("#####START#####");
            int result = read_vector_float(dest, -2, 9);           
            printf("#####END#####");

            test_error(result == expected_result, "Funkcja read_vector_float() powinna zwrócić %d, a zwróciła %d", expected_result, result);
        
    //
    // -----------
    //

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

//
//  Test 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, -7, -9);           
            printf("#####END#####");

            test_error(result == expected_result, "Funkcja read_vector_float() powinna zwrócić %d, a zwróciła %d", expected_result, result);
        
    //
    // -----------
    //

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




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