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:22:21.987630
 *
 * 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, 0, 0, 0, 2, 1, 0, 0};
                int output[] = {-1, -2, 2, -2, 1, 1, -1, 2, 1, 2, -1};
        
                printf("#####START#####");
                int res = create_histogram((float[]){1.310897, 7.278303, 8.361791, 7.407244}, 4, output, 11);
                printf("#####END#####");
                test_error(res == 0, "Funkcja create_histogram() powinna zwrócić 0, a zwróciłą %d", res);


                int ok = 0;        
                for (int i = 0; i < 11; ++i)
                    ok += output[i] != expected_array[i];
                    
                if (ok)
                {         
                    printf("Powinno być: [0, 1, 0, 0, 0, 0, 0, 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[] = {6, 8, 7, 9, 10, 4, 11, 10, 9, 10, 3};
                int output[] = {-1, -2, -2, -2, -1, -1, 0, 1, -2, -2, -2};
        
                printf("#####START#####");
                int res = create_histogram((float[]){4.504958, 3.085039, 3.475060, 2.416914, 3.953041, 4.299887, 9.186515, 10.608350, 4.584417, 2.757497, 6.955544, 5.744387, 6.265268, 8.461723, 9.743319, 4.671359, 3.748014, 0.152884, 0.723432, 4.763250, 7.187048, 1.715287, 2.177554, 9.846742, 7.431088, 6.296844, 1.121979, 0.823699, 1.090077, 7.383903, 8.480740, 4.045504, 1.341784, 2.463330, 7.373535, 6.927252, 0.035946, 3.783397, 10.861655, 1.466011, 0.387512, 1.706007, 7.919331, 2.186265, 10.971467, 7.703209, 8.843126, 7.252394, 8.620852, 6.400708, 8.116810, 8.999724, 8.117500, 9.765495, 9.981885, 7.981701, 6.703507, 4.914623, 9.798532, 2.750498, 6.611672, 6.924914, 9.061743, 5.604909, 3.268588, 5.533971, 4.085215, 3.045391, 6.510420, 5.017636, 6.133690, 3.946504, 6.556877, 8.029351, 1.811900, 8.921673, 2.684383, 1.817458, 0.873927, 7.224977, 9.301634, 4.205940, 3.084115, 9.185580, 9.476076, 4.028791, 7.998902}, 87, 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ć: [6, 8, 7, 9, 10, 4, 11, 10, 9, 10, 3]\n");

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

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

                    printf("\n");

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


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

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

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

    // uwarunkowanie zasobów - pamięci, itd...
    test_file_write_limit_setup(33554432);
    rldebug_reset_limits();
    
    //
    // -----------
    //
    
        
                const int expected_array[] = {17, 18, 10, 17, 18, 18, 19, 20, 20, 15, 10};
                int output[] = {1, 1, 2, -1, 0, 0, 2, -2, -1, -1, -2};
        
                printf("#####START#####");
                int res = create_histogram((float[]){8.652278, 8.458164, 9.701721, 8.493000, 1.138618, 7.658325, 6.453129, 7.569889, 4.517868, 8.791885, 4.288681, 8.519048, 9.420719, 8.930622, 0.652198, 7.049905, 4.335366, 9.841403, 10.381889, 5.680418, 3.177801, 2.029312, 5.176233, 4.323379, 5.220892, 8.544809, 7.024153, 9.462136, 4.282822, 0.951123, 6.279047, 2.460125, 8.645913, 5.805792, 10.633277, 0.929073, 10.419415, 10.181597, 3.644510, 4.725082, 8.280539, 3.290526, 7.489572, 1.366898, 3.394552, 9.270737, 0.340466, 0.726058, 0.527024, 5.595216, 0.839719, 3.653160, 1.913744, 2.884579, 10.185001, 8.641233, 1.274676, 6.525559, 4.456577, 7.649274, 3.595042, 10.756641, 2.287353, 4.311183, 5.631287, 7.376641, 9.491884, 1.303337, 2.661186, 0.282520, 2.577927, 8.916671, 5.353598, 6.793732, 1.528500, 8.877754, 5.442842, 1.367945, 10.226538, 1.783457, 1.224968, 6.372684, 6.823523, 10.721089, 4.111305, 7.491918, 3.606346, 0.484147, 3.944862, 8.112890, 0.967082, 0.209527, 3.000254, 0.808296, 9.210288, 0.116003, 2.104693, 1.590292, 1.777541, 7.748216, 6.301874, 4.912835, 3.130417, 9.782806, 7.227262, 5.595649, 8.914115, 5.956302, 1.959840, 4.853962, 2.371122, 4.184030, 9.929419, 2.013722, 1.128673, 8.672622, 4.895989, 5.424683, 7.188422, 7.902796, 0.121058, 6.723209, 3.902067, 6.690513, 6.572497, 7.628261, 6.241939, 6.580926, 3.718316, 9.720147, 1.686891, 1.843051, 7.173835, 5.379647, 6.299044, 1.665978, 5.720353, 4.325167, 3.168583, 9.030799, 5.729828, 7.433672, 5.993719, 7.443721, 3.499186, 5.023961, 9.249388, 10.441504, 8.542817, 6.429002, 8.483265, 9.951029, 4.236096, 7.158239, 4.373707, 1.318702, 1.072287, 7.203226, 8.340193, 3.572034, 6.882000, 4.081108, 6.172386, 10.058324, 7.529179, 0.267333, 0.493854, 0.476827, 4.342697, 8.905591, 8.371149, 6.960747, 9.813660, 7.234264, 5.850726, 3.315199, 3.583018, 6.626296, 5.013090, 9.722104, 2.686818, 6.979380}, 182, output, 11);
                printf("#####END#####");
                test_error(res == 0, "Funkcja create_histogram() powinna zwrócić 0, a zwróciłą %d", res);


                int ok = 0;        
                for (int i = 0; i < 11; ++i)
                    ok += output[i] != expected_array[i];
                    
                if (ok)
                {         
                    printf("Powinno być: [17, 18, 10, 17, 18, 18, 19, 20, 20, 15, 10]\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, 1, 0, 0, 0, 1, 0, 0, 0, 0};
                int output[] = {1, 1, -1, 1, 1, -1, 0, 2, -1, -1, -2};
        
                printf("#####START#####");
                int res = create_histogram((float[]){-9.401365, -3.208179, 2.247711, 6.614209}, 4, output, 11);
                printf("#####END#####");
                test_error(res == 0, "Funkcja create_histogram() powinna zwrócić 0, a zwróciłą %d", res);


                int ok = 0;        
                for (int i = 0; i < 11; ++i)
                    ok += output[i] != expected_array[i];
                    
                if (ok)
                {         
                    printf("Powinno być: [0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0]\n");

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

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

                    printf("\n");

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


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

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

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

    // uwarunkowanie zasobów - pamięci, itd...
    test_file_write_limit_setup(33554432);
    rldebug_reset_limits();
    
    //
    // -----------
    //
    
        
                const int expected_array[] = {2, 2, 6, 2, 5, 3, 5, 5, 5, 1, 0};
                int output[] = {-1, -1, -1, 2, 1, 1, -1, 1, -2, 2, 2};
        
                printf("#####START#####");
                int res = create_histogram((float[]){4.176881, -5.591552, 4.289445, 8.983876, 2.324116, 8.020189, -2.462729, 8.779099, -4.616455, -4.783954, -6.225285, -7.766865, 4.220213, 0.248328, -3.038319, -7.914568, 6.515852, -5.672831, 4.964375, 4.837875, -1.042757, -7.298080, 2.387075, 8.664048, -1.052094, 6.705536, 6.515364, -2.179957, 1.535358, 0.792988, 5.302873, -7.520799, 5.106872, 7.428301, -3.717154, 2.470953, 1.715774, -6.462613, -7.065735, -4.773729, -7.682210, 7.011310, 6.705451, -8.221282, -8.971484, -1.128724, 6.613022, 5.612555, 2.517641, -6.054937, -9.248024, 9.063385, 2.796687, -7.545139, 3.791795, -4.120111, 2.725416, 7.852110, 7.088311, 3.537018, -5.086188, -8.959825, -9.691825, 7.370845, -3.233565, 8.209774}, 66, 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, 2, 6, 2, 5, 3, 5, 5, 5, 1, 0]\n");

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

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

                    printf("\n");

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


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

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

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

    // uwarunkowanie zasobów - pamięci, itd...
    test_file_write_limit_setup(33554432);
    rldebug_reset_limits();
    
    //
    // -----------
    //
    
        
                const int expected_array[] = {4, 7, 5, 4, 5, 5, 3, 6, 11, 2, 5, 5, 1, 1, 4, 2, 4, 8, 3, 3, 0};
                int output[] = {0, 1, -1, -2, -1, 0, -2, 0, -1, 2, 1, 0, -2, -2, 2, -1, 2, 0, 1, 0, -2};
        
                printf("#####START#####");
                int res = create_histogram((float[]){14.247316, 19.248497, 3.741550, 8.188363, 16.624283, 17.677937, 11.012536, 7.882552, 2.114787, 4.611906, 17.370317, 5.805962, 1.098666, 3.700616, 17.968822, 0.034136, 17.038144, 7.339942, 11.251185, 14.673991, 8.997704, 10.238598, 8.400454, 5.408241, 4.443238, 7.685490, 6.687856, 19.773260, 6.681653, 1.574092, 10.837807, 17.035855, 16.448508, 16.978185, 1.846146, 8.637718, 8.286301, 16.454257, 18.416948, 8.970554, 4.722830, 4.769666, 15.057206, 14.691016, 12.714699, 11.132797, 6.575189, 5.282318, 7.790202, 18.306749, 0.256456, 10.884219, 8.976032, 1.000595, 2.787778, 18.492293, 7.524165, 17.882100, 19.978366, 8.238203, 2.222421, 1.983773, 9.745471, 1.227472, 14.844156, 3.424332, 10.558044, 2.027754, 5.919150, 0.695843, 10.855036, 11.725656, 17.474978, 3.908951, 9.808664, 13.246788, 8.492655, 4.334320, 0.186859, 7.833807, 2.472503, 8.417977, 11.654813, 8.223027, 1.412974, 15.341107, 5.887629, 17.141604}, 88, output, 21);
                printf("#####END#####");
                test_error(res == 0, "Funkcja create_histogram() powinna zwrócić 0, a zwróciłą %d", res);


                int ok = 0;        
                for (int i = 0; i < 21; ++i)
                    ok += output[i] != expected_array[i];
                    
                if (ok)
                {         
                    printf("Powinno być: [4, 7, 5, 4, 5, 5, 3, 6, 11, 2, 5, 5, 1, 1, 4, 2, 4, 8, 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[] = {14, 15, 9, 13, 13, 13, 8, 13, 14, 13, 5, 6, 17, 11, 11, 12, 9, 6, 7, 11, 14, 9, 9, 13, 9, 6, 13, 12, 4, 9, 10, 10, 12, 13, 6, 12, 11, 14, 9, 8, 12, 15, 11, 13, 13, 14, 11, 10, 12, 8, 18, 6, 10, 13, 9, 17, 14, 10, 9, 13, 9, 11, 14, 8, 13, 11, 10, 8, 12, 7, 13, 13, 10, 9, 9, 9, 12, 24, 9, 14, 12, 13, 10, 4, 12, 10, 17, 0};
                int output[] = {1, 1, -2, 1, 2, 2, 2, -2, -1, 0, 2, -2, -1, 0, -2, 2, -1, -1, 0, 1, 0, 0, -2, 0, -1, 2, -2, -2, -2, 2, -1, -2, 1, 2, -1, 2, 0, -1, 1, 2, 0, -1, -2, 1, -1, 1, 1, 1, 2, -1, 2, 0, -2, 1, 1, -2, -1, -1, 1, 1, -1, -1, 0, -2, -1, -2, 0, 2, 1, 1, -1, -2, -1, 0, 1, -2, -2, 0, 1, -2, 0, 2, 1, -2, -1, 2, 1, 0};
        
                printf("#####START#####");
                int res = create_histogram((float[]){4.945379, 20.332810, 42.639807, 29.343553, 84.658388, 55.352338, 10.544006, 72.687086, 86.383939, 5.480800, 39.397587, 35.592400, 35.099529, 81.947324, 77.580036, 71.999809, 4.539926, 50.442913, 29.849340, 44.395404, 8.152531, 69.190921, 13.651860, 8.271476, 35.008848, 38.146632, 5.315220, 62.395781, 45.035074, 50.115835, 67.875973, 8.279096, 37.857778, 45.522444, 39.373117, 15.875179, 8.923896, 77.990393, 38.619737, 77.651688, 28.669771, 17.519981, 2.657728, 0.096923, 56.907741, 41.371074, 23.014134, 2.057532, 6.243059, 47.590928, 34.793629, 39.643464, 46.090102, 82.002763, 55.525439, 0.391093, 20.096782, 77.275071, 48.232068, 45.424200, 25.947309, 30.662444, 37.026176, 6.919410, 0.201996, 55.878092, 36.455586, 67.960783, 6.755000, 65.608828, 63.399102, 19.476095, 26.804442, 51.496515, 7.769094, 49.080488, 24.850826, 68.603277, 33.527151, 3.074464, 75.081373, 55.295798, 71.174482, 36.938692, 23.379832, 11.367877, 33.019137, 77.711206, 80.810371, 14.340060, 60.701130, 53.625375, 71.516681, 53.812614, 9.123163, 69.868419, 76.743128, 18.702496, 56.588173, 0.515129, 3.361142, 26.211658, 9.809688, 52.165139, 59.996125, 60.261896, 79.389010, 4.018345, 41.455341, 17.236152, 41.199241, 67.780449, 80.219287, 50.665405, 9.345525, 68.379899, 81.328132, 68.837249, 19.380416, 47.400111, 84.904186, 15.707595, 29.768301, 79.708993, 33.513402, 12.763412, 44.209778, 70.031892, 44.922368, 43.598793, 64.144540, 31.618166, 57.502786, 82.328140, 3.302454, 50.254086, 75.825517, 61.297368, 24.843416, 51.513718, 21.280132, 72.442875, 47.233756, 9.633027, 3.911121, 14.103034, 55.312930, 80.899435, 2.101245, 15.408059, 15.576740, 64.303516, 74.054468, 37.444683, 50.651935, 52.886368, 15.731737, 45.393268, 50.831771, 77.452000, 50.845553, 4.182048, 60.933852, 74.951655, 8.397009, 76.522649, 48.131940, 21.697637, 80.605815, 62.517779, 4.133545, 3.191569, 77.016685, 1.214702, 0.875771, 86.396950, 36.367966, 70.503423, 36.267156, 81.446187, 75.840432, 57.226911, 62.072185, 86.784608, 10.843496, 79.681708, 65.099560, 45.162236, 42.206099, 86.531219, 56.968023, 85.620490, 79.735614, 29.729560, 76.525321, 13.437696, 65.227368, 36.927089, 70.490943, 51.217217, 0.387017, 57.870915, 4.900751, 26.436503, 56.144661, 31.441980, 20.170906, 52.100583, 9.220454, 18.152497, 84.368265, 80.529472, 61.372006, 35.245213, 1.733784, 86.666310, 76.749990, 7.941753, 46.801756, 22.027489, 25.274404, 73.875846, 72.304665, 21.310878, 11.647636, 58.381603, 72.193685, 1.757396, 19.910682, 38.362174, 5.699130, 54.924390, 69.230995, 74.073697, 43.872257, 31.546541, 5.270910, 16.632044, 71.113087, 62.256658, 16.616240, 55.368133, 26.320273, 27.666607, 42.160672, 8.318416, 66.462012, 14.950821, 55.658253, 17.390868, 11.962149, 43.982784, 71.054615, 26.028489, 72.118750, 52.589572, 68.917571, 14.165886, 50.768528, 41.213911, 76.973777, 44.237995, 14.099312, 77.991929, 73.149117, 40.176261, 31.981830, 83.672718, 8.627302, 9.073594, 56.264153, 26.801657, 47.270056, 67.426059, 59.253132, 26.552709, 41.728270, 75.401840, 54.416280, 81.012816, 27.241015, 48.210335, 17.429022, 55.926197, 48.208494, 1.121581, 82.634635, 6.653663, 2.531196, 3.281192, 76.414217, 85.946711, 52.837851, 70.370741, 34.348090, 55.407766, 26.881083, 11.747939, 30.500207, 77.765431, 66.343732, 54.530739, 1.737179, 70.046352, 64.243464, 44.179180, 60.534100, 41.118884, 36.444787, 20.101051, 77.222220, 23.855819, 27.154338, 53.696393, 9.254073, 80.320237, 41.621506, 11.671966, 71.848225, 6.331166, 84.584878, 32.683329, 49.062519, 48.551055, 19.381037, 20.307772, 5.017360, 64.707766, 53.467869, 42.079507, 86.154044, 23.662429, 63.516419, 18.068398, 28.228810, 61.633774, 20.339926, 53.501973, 42.359902, 58.593581, 46.583371, 78.940241, 0.159672, 37.804784, 12.285741, 64.422113, 58.876551, 86.213656, 37.318973, 1.929452, 40.630409, 61.595016, 50.073098, 74.291180, 32.939491, 84.062406, 32.298554, 86.763653, 46.052859, 86.578415, 57.365142, 58.598357, 27.454061, 20.536985, 84.394466, 56.381031, 41.199424, 85.405808, 55.684367, 67.721587, 3.891210, 25.737403, 47.508752, 12.953388, 62.198457, 67.148966, 5.653765, 70.401160, 73.865599, 63.720147, 55.749177, 24.620910, 48.252320, 33.090029, 21.259489, 22.925662, 7.305420, 32.313564, 2.809678, 3.106912, 53.693982, 65.331343, 41.367544, 76.329159, 23.992081, 85.342451, 77.266917, 65.552542, 42.683830, 73.254532, 12.376339, 0.083145, 30.520779, 29.553546, 74.737258, 78.005236, 30.388103, 57.751629, 12.464564, 20.621460, 25.409516, 12.631650, 77.618541, 64.933479, 42.699923, 23.429761, 39.915895, 72.304615, 77.837123, 36.775606, 45.240474, 8.074290, 4.429778, 5.818505, 78.162015, 86.940692, 65.848433, 79.804081, 33.955131, 13.134266, 24.460144, 13.682244, 19.763527, 3.591758, 4.019523, 62.382662, 48.411064, 32.733166, 14.497797, 48.455102, 72.193911, 14.316018, 51.464712, 84.899637, 49.508710, 80.121726, 45.365776, 30.024549, 44.701213, 40.375229, 1.097923, 59.798134, 32.147251, 7.014825, 77.985793, 16.747055, 12.857219, 23.511376, 38.799088, 85.929778, 73.021305, 37.559297, 86.211126, 31.500739, 12.386946, 27.042376, 24.743877, 26.015616, 58.161344, 45.350437, 70.849833, 59.267894, 2.023609, 28.311701, 85.177949, 64.139978, 59.719974, 19.564316, 73.237430, 32.668176, 70.695749, 35.028263, 50.867548, 82.403429, 62.910038, 24.240413, 12.665277, 21.926734, 68.702001, 78.560086, 80.395957, 5.501139, 38.856281, 52.150182, 81.568682, 1.261262, 40.904473, 19.282141, 34.114734, 73.815636, 63.070130, 68.122887, 66.900831, 19.930807, 9.182725, 0.562599, 79.099133, 40.114829, 50.782563, 79.254558, 55.602343, 30.069115, 32.903568, 65.152468, 22.325867, 85.924318, 72.402680, 54.225805, 55.873641, 49.304578, 81.710401, 35.416494, 50.400286, 77.134763, 45.930048, 0.564642, 27.539643, 33.575500, 34.996210, 8.369512, 37.593046, 71.654422, 59.709603, 60.389469, 74.025734, 52.080236, 80.125058, 17.637254, 68.631031, 44.833559, 66.329743, 45.622378, 12.294726, 61.058753, 1.814905, 22.385150, 23.190979, 78.711192, 65.259284, 30.692131, 32.950373, 65.005084, 74.680315, 40.328168, 7.335781, 37.401119, 48.136547, 31.658568, 37.919700, 56.385275, 64.092803, 13.362365, 86.717917, 23.262202, 8.081171, 78.991430, 15.394624, 59.747319, 72.830162, 66.341735, 47.028909, 35.774127, 7.127319, 82.835604, 41.297996, 20.638809, 22.540387, 85.693669, 78.204499, 40.635729, 64.374149, 85.806935, 55.162048, 62.474663, 4.406776, 68.725612, 83.707636, 40.554572, 7.565728, 29.270736, 71.624856, 18.662980, 49.062852, 4.014128, 55.010024, 67.248156, 77.254236, 82.123133, 60.123593, 84.421840, 49.654612, 61.612956, 64.673619, 46.342934, 51.049434, 0.978680, 42.561644, 49.140455, 13.615507, 54.366347, 5.726992, 21.200113, 32.394149, 1.540462, 16.946236, 50.734692, 66.162954, 41.416974, 55.453759, 77.766699, 42.841224, 4.770944, 46.257210, 75.676924, 38.473439, 3.069091, 75.016156, 21.453237, 46.754567, 12.314414, 34.058469, 26.794748, 59.200025, 43.803209, 0.307564, 60.910407, 5.864780, 33.012142, 15.750240, 48.244522, 40.861553, 32.373196, 13.721666, 54.181920, 62.782155, 65.910559, 16.397653, 1.110866, 6.661557, 44.333215, 63.411210, 12.091402, 70.948964, 26.365053, 27.190686, 71.271457, 33.621226, 20.415261, 76.815198, 45.576813, 84.467446, 71.941688, 2.480112, 29.703072, 60.836011, 61.110692, 5.527720, 64.548613, 37.928199, 53.727417, 59.032579, 4.109723, 9.613749, 54.200593, 33.292989, 44.537454, 76.369190, 63.243900, 70.915309, 45.399019, 11.879885, 80.076686, 78.969823, 31.963947, 27.287566, 86.801450, 1.845827, 71.358345, 3.001497, 28.086673, 53.216529, 55.221440, 46.600855, 46.721863, 56.669085, 80.478135, 35.025336, 69.634198, 16.016502, 53.751748, 54.679672, 79.556657, 50.696358, 37.549185, 77.902986, 20.329351, 79.489250, 79.479066, 79.599635, 77.049725, 76.294953, 72.213874, 85.637438, 77.803613, 56.376607, 66.946154, 30.909487, 27.401533, 41.824085, 69.453552, 43.431512, 35.387015, 80.466930, 36.140873, 74.720334, 56.385369, 22.693277, 45.154610, 56.311830, 61.778771, 41.426562, 77.276165, 50.530913, 23.292880, 29.664844, 71.990516, 18.659817, 58.132189, 61.229855, 81.215013, 12.159991, 73.028811, 62.944815, 7.938499, 23.590867, 66.586019, 68.729338, 31.101761, 27.064974, 41.457554, 29.419506, 50.512403, 75.133941, 35.387967, 62.561677, 33.026830, 43.457249, 5.664690, 63.145553, 15.026292, 39.215263, 34.719927, 54.561314, 18.697531, 19.441951, 44.790760, 77.626777, 38.282372, 23.887968, 59.845855, 66.309633, 0.720862, 10.514076, 53.605894, 47.953991, 43.356701, 51.892827, 59.849854, 60.362712, 30.089109, 9.764083, 84.299751, 10.896104, 70.836681, 81.679083, 35.039179, 4.289460, 79.294506, 12.674836, 47.028955, 64.094205, 48.225362, 3.048579, 32.088521, 15.762717, 12.987084, 68.105789, 37.442636, 25.232193, 22.779498, 14.241224, 67.079107, 81.103293, 56.071552, 39.310098, 15.021944, 1.451724, 18.515556, 70.316954, 86.094851, 56.351068, 65.452336, 84.265055, 56.317481, 75.481719, 44.328601, 79.382168, 78.939946, 58.896368, 2.871639, 77.402178, 14.491564, 59.166903, 73.416006, 76.831401, 57.630681, 14.888561, 13.626368, 9.003553, 43.448556, 14.553706, 64.825624, 81.603040, 76.588603, 1.530617, 16.904300, 19.845273, 21.667175, 33.226647, 38.995387, 39.046426, 2.367599, 16.370867, 9.240366, 79.814361, 68.390984, 7.817178, 61.995149, 46.336286, 77.837221, 7.882782, 36.403576, 19.945055, 81.172068, 0.642976, 43.503186, 86.720009, 38.258699, 1.210431, 61.301664, 39.123098, 52.884776, 7.054586, 46.558651, 82.751443, 43.201741, 53.564574, 48.703533, 17.650768, 58.752171, 44.140939, 8.468299, 43.357145, 35.747137, 57.327494, 53.707359, 13.067982, 30.271278, 50.761705, 42.720638, 9.066301, 82.716903, 42.549002, 53.878986, 45.253070, 8.501302, 84.522452, 82.351074, 13.175568, 12.629142, 41.298080, 83.653116, 5.198248, 24.524450, 27.021270, 22.812617, 57.719623, 26.429363, 81.621022, 43.723849, 25.340878, 26.792120, 20.232756, 40.675118, 6.387640, 86.620689, 20.385615, 36.417064, 59.229254, 47.838816, 7.595797, 58.151046, 23.941042, 52.258917, 69.529198, 47.310004, 63.078427, 24.870064, 37.080203, 33.054636, 62.959182, 52.615479, 21.804674, 31.923111, 66.077762, 69.375253, 15.096114, 62.019035, 10.231491, 7.378570, 57.665120, 37.255297, 49.740346, 83.956463, 40.496462, 82.977292, 24.483022, 43.560911, 16.164685, 15.046516, 50.869559, 27.238845, 12.817281, 57.228806, 33.974107, 74.957975, 3.210233, 68.423884, 8.647733, 22.467444, 62.349240, 81.134493, 86.617678, 13.895354, 44.505016, 40.859659, 20.774464, 8.921712, 6.912215, 36.870867, 75.595322, 70.451007, 71.760989, 31.593981}, 964, output, 88);
                printf("#####END#####");
                test_error(res == 0, "Funkcja create_histogram() powinna zwrócić 0, a zwróciłą %d", res);


                int ok = 0;        
                for (int i = 0; i < 88; ++i)
                    ok += output[i] != expected_array[i];
                    
                if (ok)
                {         
                    printf("Powinno być: [14, 15, 9, 13, 13, 13, 8, 13, 14, 13, 5, 6, 17, 11, 11, 12, 9, 6, 7, 11, 14, 9, 9, 13, 9, 6, 13, 12, 4, 9, 10, 10, 12, 13, 6, 12, 11, 14, 9, 8, 12, 15, 11, 13, 13, 14, 11, 10, 12, 8, 18, 6, 10, 13, 9, 17, 14, 10, 9, 13, 9, 11, 14, 8, 13, 11, 10, 8, 12, 7, 13, 13, 10, 9, 9, 9, 12, 24, 9, 14, 12, 13, 10, 4, 12, 10, 17, 0]\n");

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

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

                    printf("\n");

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


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

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

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

    // uwarunkowanie zasobów - pamięci, itd...
    test_file_write_limit_setup(33554432);
    rldebug_reset_limits();
    
    //
    // -----------
    //
    
        
                const int expected_array[] = {3, 5, 2, 9, 2, 6, 3, 6, 5};
                int output[] = {1, 0, -1, 1, 0, 2, 1, 2, 2};
        
                printf("#####START#####");
                int res = create_histogram((float[]){8.373328, 5.480076, 3.741057, 1.983879, 8.099016, 8.820953, 2.614774, 3.782732, 9.831721, 10.958013, 4.990224, 0.604987, 7.207804, 5.937870, 5.103777, 10.939894, 1.950316, 5.026423, 3.191602, 0.090460, 1.421636, 7.553514, 3.034428, 1.030534, 6.555291, 7.030569, 6.893702, 3.459864, 7.920179, 3.979934, 10.069716, 0.615372, 10.157774, 8.833985, 7.383689, 3.129379, 10.525932, 5.478811, 3.261628, 3.926420, 6.740397, 9.828888, 4.663434, 5.869240, 8.522325, 7.733792, 2.655086, 1.575333}, 48, output, 9);
                printf("#####END#####");
                test_error(res == 0, "Funkcja create_histogram() powinna zwrócić 0, a zwróciłą %d", res);


                int ok = 0;        
                for (int i = 0; i < 9; ++i)
                    ok += output[i] != expected_array[i];
                    
                if (ok)
                {         
                    printf("Powinno być: [3, 5, 2, 9, 2, 6, 3, 6, 5]\n");

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

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

                    printf("\n");

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


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

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

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

    // uwarunkowanie zasobów - pamięci, itd...
    test_file_write_limit_setup(33554432);
    rldebug_reset_limits();
    
    //
    // -----------
    //
    
        
                const int expected_array[] = {0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0};
                int output[] = {1, -1, 2, 0, 1, 0, -2, -1, 1, 2, 0};
        
                printf("#####START#####");
                int res = create_histogram((float[]){8.048728}, 1, output, 11);
                printf("#####END#####");
                test_error(res == 0, "Funkcja create_histogram() powinna zwrócić 0, a zwróciłą %d", res);


                int ok = 0;        
                for (int i = 0; i < 11; ++i)
                    ok += output[i] != expected_array[i];
                    
                if (ok)
                {         
                    printf("Powinno być: [0, 0, 0, 0, 0, 0, 0, 0, 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 10: Sprawdzanie poprawności działania funkcji create_histogram
//
void UTEST10(void)
{
    // informacje o teście
    test_start(10, "Sprawdzanie poprawności działania funkcji create_histogram", __LINE__);

    // uwarunkowanie zasobów - pamięci, itd...
    test_file_write_limit_setup(33554432);
    rldebug_reset_limits();
    
    //
    // -----------
    //
    
        
                const int expected_array[] = {3};
                int output[] = {1};
        
                printf("#####START#####");
                int res = create_histogram((float[]){4.569264, 9.260646, 1.380654, 5.618005, 8.686643, 5.927289, 7.543158, 9.436564, 5.271719, 6.717117, 2.331520, 9.962407, 7.051506, 5.990906, 4.411999, 1.322472, 1.192446, 4.307981, 9.595816, 7.932565, 2.703193, 6.539367, 4.034710, 9.988266, 0.479501, 3.970521, 8.865539, 8.088506, 9.583332, 2.723673, 3.728151, 5.559044, 1.640464, 9.557953, 5.108992, 4.153877, 8.564939, 4.978732, 7.647354, 7.218057, 6.101337, 6.898084, 1.635150, 4.780897, 9.851875, 10.061364, 4.626230, 10.307360, 7.836831, 1.686532, 2.068336, 9.052537, 4.769243, 6.930401, 2.341958, 6.668233, 6.230265, 10.193697, 6.726905, 10.096836, 3.015406, 5.482130, 8.701674, 2.435755, 4.546752, 1.930426, 10.595625, 3.879859, 0.499003, 4.945540, 6.999430, 3.273808, 5.917820, 5.347242, 4.334383, 9.783286, 0.055456, 7.622524, 2.095658, 3.927463, 8.016147, 10.552153, 3.040872, 7.328159, 6.168839, 7.113626, 3.096534, 5.584771, 8.974488, 8.978600}, 90, output, 1);
                printf("#####END#####");
                test_error(res == 0, "Funkcja create_histogram() powinna zwrócić 0, a zwróciłą %d", res);


                int ok = 0;        
                for (int i = 0; i < 1; ++i)
                    ok += output[i] != expected_array[i];
                    
                if (ok)
                {         
                    printf("Powinno być: [3]\n");

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

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

                    printf("\n");

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


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

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

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

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

            printf("#####START#####");
            int res = create_histogram((float[]){1.310897, 7.278303, 8.361791, 7.407244}, 14, NULL, 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 12: Sprawdzanie poprawności działania funkcji create_histogram
//
void UTEST12(void)
{
    // informacje o teście
    test_start(12, "Sprawdzanie poprawności działania funkcji create_histogram", __LINE__);

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

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

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

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

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

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

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

            printf("#####START#####");
            int res = create_histogram((float[]){1.310897, 7.278303, 8.361791, 7.407244}, 0, 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 14: Sprawdzanie poprawności działania funkcji create_histogram
//
void UTEST14(void)
{
    // informacje o teście
    test_start(14, "Sprawdzanie poprawności działania funkcji create_histogram", __LINE__);

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

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

            printf("#####START#####");
            int res = create_histogram((float[]){1.310897, 7.278303, 8.361791, 7.407244}, 19, output, 0);
            printf("#####END#####");
            test_error(res == 1, "Funkcja create_histogram() powinna zwrócić 1, a zwróciłą %d", res);
        
    //
    // -----------
    //

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

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

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

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

            printf("#####START#####");
            int res = create_histogram((float[]){1.310897, 7.278303, 8.361791, 7.407244}, -19, 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[] = {1, -1, -2, 1, 0, -1, 2, -2, 2, 2, 0};

            printf("#####START#####");
            int res = create_histogram((float[]){1.310897, 7.278303, 8.361791, 7.407244}, 19, 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 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[] = {0, -10, 1, -9, 7, -6, -6, 4, 1, -1, -3};

        //-------------1-----------------------
                printf("\n***TEST 1***\n\n");
                printf("***START***\n");
                display_vector(tab, 0);
                printf("***END***\n");


        //-------------2-----------------------

                printf("\n***TEST 2***\n\n");
                printf("***START***\n");
                display_vector(tab, -11);
                printf("***END***\n");

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

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

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

                printf("\n***TEST 4***\n\n");
                printf("***START***\n");
                display_vector(tab, 11 - 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[] = {2.000000, -4.000000, -7.000000, -6.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ć: [2.000000, -4.000000, -7.000000, -6.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 = 10;
                const float expected_array[] = {10.000000, -2.000000, -1.000000, -4.000000, -5.000000, 3.000000, 9.000000, -9.000000, 0.000000, 0.000000, -7.000000};
                float dest[11]; 
                int result = read_vector_float(dest, 11, -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ć: [10.000000, -2.000000, -1.000000, -4.000000, -5.000000, 3.000000, 9.000000, -9.000000, 0.000000, 0.000000, -7.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 = 2;
                const float expected_array[] = {-1.000000, -10.000000};
                float dest[2]; 
                int result = read_vector_float(dest, 2, -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ć: [-1.000000, -10.000000]\n");
                    printf("Jest: [");
                    for (int i = 0; i < expected_result - 1; ++i)
                        printf("%f, ", dest[i]);

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

                }

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

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

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

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

            int expected_result = -1;
            float dest[5]; 
            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[7]; 
            printf("#####START#####");
            int result = read_vector_float(dest, -10, 8);           
            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, -6, -6);           
            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();
}