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 14:14:53.352693
 *
 * 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, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0};
                int output[] = {-1, 2, 2, -1, -1, -2, 1, 2, 0, -2, 2};
        
                printf("#####START#####");
                int res = create_histogram((float[]){6.407812, 3.557603, 9.863350}, 3, 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, 1, 0, 0, 1, 0, 0, 1, 0]\n");

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

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

                    printf("\n");

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


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

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

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

    // uwarunkowanie zasobów - pamięci, itd...
    test_file_write_limit_setup(33554432);
    rldebug_reset_limits();
    
    //
    // -----------
    //
    
        
                const int expected_array[] = {5, 3, 3, 5, 1, 4, 0, 1, 0, 2, 2};
                int output[] = {2, 0, 1, 1, -2, 1, 1, 1, 0, -1, -1};
        
                printf("#####START#####");
                int res = create_histogram((float[]){0.273665, 3.857588, 5.237781, 2.159398, 5.028495, 5.150045, 3.930555, 5.865012, 1.787693, 3.462190, 3.671181, 1.900065, 4.843636, 0.197723, 2.747757, 9.849533, 10.275765, 2.374611, 7.996246, 3.100597, 10.396882, 0.118141, 9.828860, 1.966249, 0.091648, 0.809554}, 26, output, 11);
                printf("#####END#####");
                test_error(res == 0, "Funkcja create_histogram() powinna zwrócić 0, a zwróciłą %d", res);


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

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

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

                    printf("\n");

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


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

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

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

    // uwarunkowanie zasobów - pamięci, itd...
    test_file_write_limit_setup(33554432);
    rldebug_reset_limits();
    
    //
    // -----------
    //
    
        
                const int expected_array[] = {18, 7, 9, 16, 12, 9, 4, 9, 15, 13, 12};
                int output[] = {1, 2, 2, -1, 2, 2, 0, 1, -1, -1, -2};
        
                printf("#####START#####");
                int res = create_histogram((float[]){9.190540, 9.568535, 7.133672, 3.564402, 5.489269, 2.948351, 1.532615, 8.764288, 9.842306, 3.146964, 7.774524, 1.338075, 4.917439, 10.317621, 3.195369, 8.481395, 7.365748, 10.998611, 8.384750, 10.190977, 0.404293, 4.095131, 2.959606, 3.014411, 2.130415, 6.769239, 10.861476, 5.688384, 2.544285, 3.771646, 0.752151, 0.270949, 0.967920, 1.758845, 2.807318, 0.719359, 0.636792, 2.542419, 8.281297, 10.065761, 9.300010, 4.998282, 3.112954, 0.166138, 0.584683, 6.545681, 9.440957, 4.872542, 8.360990, 8.195529, 8.625283, 8.392457, 3.367427, 5.311382, 1.921808, 8.526277, 8.131548, 0.920459, 4.935241, 10.762581, 5.392221, 3.914778, 7.210274, 9.285200, 4.873203, 10.493491, 3.095429, 3.427678, 0.680851, 9.197388, 9.226641, 10.875168, 10.179279, 4.754041, 4.297972, 2.035838, 3.501279, 7.815992, 10.424642, 1.556967, 3.355617, 9.631377, 3.969193, 0.334701, 8.233705, 2.467586, 0.273667, 5.820437, 5.029274, 6.380090, 4.127879, 1.130965, 6.260289, 2.628248, 5.628069, 0.448698, 5.558360, 10.027203, 8.621015, 1.514170, 9.927662, 8.423447, 8.985216, 3.467676, 7.951348, 0.827843, 10.374223, 7.355344, 4.945042, 7.476913, 9.946496, 3.079870, 7.568018, 9.809877, 0.585660, 4.381666, 5.735981, 3.700776, 0.681355, 0.925463, 0.924793, 4.817081, 9.585894, 8.154352}, 124, output, 11);
                printf("#####END#####");
                test_error(res == 0, "Funkcja create_histogram() powinna zwrócić 0, a zwróciłą %d", res);


                int ok = 0;        
                for (int i = 0; i < 11; ++i)
                    ok += output[i] != expected_array[i];
                    
                if (ok)
                {         
                    printf("Powinno być: [18, 7, 9, 16, 12, 9, 4, 9, 15, 13, 12]\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, -1, -1, -1, -1, 0, 0, 1, -2, -1, 1};
        
                printf("#####START#####");
                int res = create_histogram((float[]){-7.835732, -1.917765}, 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, 3, 3, 5, 6, 7, 4, 7, 4, 3, 0};
                int output[] = {2, -2, 1, 2, -1, 1, 0, 2, 1, 1, 2};
        
                printf("#####START#####");
                int res = create_histogram((float[]){4.314152, 5.568249, 7.397722, 2.297939, -8.112551, -9.084786, 0.541915, -7.522820, -5.312819, 5.252867, -1.285063, -4.268243, -4.453903, -4.760725, -9.002825, 7.278770, 2.697100, 3.359540, 8.560971, 4.459591, -5.845106, 3.302011, 1.660570, -6.782771, 0.939365, 7.700162, 1.013715, -6.532710, 6.199872, 7.760056, -3.674195, 4.899480, -1.503481, -4.688896, 9.819084, 5.033186, 0.443231, -5.269397, 5.247450, -8.185076, 8.363341, 3.888512, 5.109387, 4.074608, -4.242587, -6.532854, -9.213004, 6.707292, 4.849612, 5.907439, -1.239421, 3.794935, 6.080145, 9.556577, 0.015146, -5.834119, -8.955908, -8.056165, 0.693468, 6.336688, -3.149919, 9.809649, -0.886322, 0.443082, 0.100355, -8.066445, -3.840300, 5.155453, 1.100376, -7.580105, 3.238369, -5.303391, -6.524596, -8.601295, 0.113775, 8.434237, 7.255597, 4.896756, -0.345766, 8.863439, -3.940298, -2.767750, 7.247442, -7.961113, 2.236441, 7.538874, -4.948049}, 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ć: [8, 3, 3, 5, 6, 7, 4, 7, 4, 3, 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, 3, 3, 7, 5, 3, 7, 5, 3, 2, 3, 3, 5, 2, 2, 8, 6, 4, 6, 3, 0};
                int output[] = {2, 0, -1, 2, -1, 2, -2, 1, -2, -2, -1, 2, -1, 0, 1, 0, -1, -2, 2, 1, 0};
        
                printf("#####START#####");
                int res = create_histogram((float[]){7.769890, 3.479103, 18.294037, 18.458522, 2.533783, 3.966172, 12.651537, 0.077833, 3.661162, 2.024005, 16.696500, 5.081769, 15.656036, 5.649570, 9.168414, 15.225598, 15.361246, 4.248941, 18.684270, 10.617889, 17.169800, 18.900837, 7.046322, 0.934698, 11.791308, 3.258675, 19.963426, 16.010120, 4.355095, 16.339266, 6.344374, 11.130695, 19.564637, 6.009171, 4.361805, 13.967774, 12.165360, 19.493112, 17.030244, 6.845739, 14.544452, 4.635371, 15.887883, 16.384798, 12.080769, 8.927451, 15.473185, 6.263699, 18.764795, 0.564775, 15.077845, 13.144982, 8.860881, 4.998471, 2.649339, 12.654451, 3.886132, 6.810353, 7.827420, 1.897698, 0.423594, 6.893877, 5.082600, 1.423927, 3.568438, 10.524601, 7.485895, 15.052165, 3.512967, 17.386746, 14.826867, 1.916452, 18.290471, 7.162318, 10.537477, 16.412617, 16.249566, 8.905109, 12.043612, 17.247905, 9.485399, 6.130743, 15.419824, 11.744469}, 84, 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, 3, 3, 7, 5, 3, 7, 5, 3, 2, 3, 3, 5, 2, 2, 8, 6, 4, 6, 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[] = {12, 8, 13, 23, 21, 16, 11, 14, 17, 10, 14, 19, 14, 19, 15, 21, 14, 15, 20, 17, 14, 19, 20, 15, 15, 14, 18, 12, 16, 12, 17, 19, 15, 21, 20, 18, 18, 10, 16, 18, 11, 20, 15, 27, 17, 19, 12, 18, 19, 16, 11, 15, 19, 14, 18, 16, 0};
                int output[] = {-2, 0, 1, 0, -1, -2, 0, -2, 2, 2, -2, -1, 0, -2, 1, -1, -1, -1, -1, 2, -2, 2, 1, 1, 2, -1, 1, 2, -2, 0, -2, -1, -2, -2, 0, 2, -2, 2, 0, -2, 1, 2, -1, 2, 2, -2, 2, 2, -1, -2, -2, 1, -1, 1, -1, -1, -1};
        
                printf("#####START#####");
                int res = create_histogram((float[]){18.434973, 44.748985, 23.285768, 44.827402, 8.367054, 45.615637, 19.916359, 4.214665, 51.748470, 55.053255, 13.012138, 25.137672, 52.297958, 45.034477, 53.231840, 39.435065, 24.511525, 46.476425, 24.904097, 2.454587, 41.051626, 33.833727, 15.575795, 31.425719, 46.772122, 39.679606, 19.841202, 10.612886, 48.967286, 21.887472, 29.192749, 25.734626, 45.050550, 49.923743, 21.887734, 55.540499, 15.233784, 7.525428, 31.530388, 25.096486, 5.506575, 15.671629, 36.344411, 38.640112, 54.852638, 54.161277, 41.147144, 33.268414, 21.202080, 32.936185, 35.920154, 33.982952, 11.947434, 41.522903, 4.230886, 46.790780, 35.158025, 35.811159, 15.377594, 52.788411, 32.369802, 12.713045, 48.668503, 37.806782, 33.518779, 39.104638, 19.656383, 49.555584, 2.032142, 14.415728, 34.511457, 4.054053, 13.654927, 10.309986, 29.522284, 41.895491, 27.128076, 12.569083, 19.574017, 38.533254, 7.230613, 7.902906, 49.928920, 16.064620, 21.716025, 25.124378, 25.196533, 19.824391, 22.939015, 17.617842, 35.427485, 35.177986, 37.986211, 40.722960, 53.099167, 9.618111, 36.970694, 43.706149, 51.230016, 11.888930, 34.309714, 45.580082, 52.769092, 48.999898, 54.281997, 47.066520, 22.061721, 10.904036, 54.986407, 2.989828, 44.104744, 36.022779, 20.200642, 29.694209, 23.013234, 43.271443, 32.781957, 41.752735, 21.179387, 53.236028, 39.002643, 44.800907, 12.434179, 33.136183, 5.895432, 15.807016, 27.445749, 27.268619, 22.593557, 3.320243, 38.082907, 48.506981, 44.064784, 21.622095, 2.055319, 55.581139, 42.023439, 20.195375, 16.155016, 17.421374, 48.644900, 13.813881, 1.900419, 37.026067, 14.717514, 43.344627, 51.427047, 32.029924, 3.114125, 47.507768, 18.993477, 27.648445, 20.477332, 33.980701, 47.906872, 53.995349, 17.355658, 8.751798, 8.826754, 50.218484, 42.301266, 29.390041, 33.238299, 46.379445, 12.009501, 39.752114, 24.066045, 14.603227, 43.526129, 11.187276, 3.394432, 39.964383, 19.311698, 19.464014, 19.075359, 40.258904, 45.171956, 15.553037, 7.756874, 26.688961, 13.024750, 34.244935, 33.110333, 12.407431, 6.218589, 3.944819, 9.620091, 17.315382, 46.593912, 18.976192, 1.375007, 25.034958, 22.463684, 11.922037, 7.974992, 29.250299, 43.461055, 43.096354, 35.702248, 55.666221, 0.510369, 22.044736, 53.163461, 7.298442, 11.764890, 28.358448, 3.087108, 17.931047, 53.802732, 18.996973, 28.116070, 23.015854, 20.031890, 49.291788, 24.146964, 52.599813, 20.276520, 15.089131, 9.424310, 33.519845, 47.974079, 33.742819, 36.824666, 41.401435, 43.154490, 16.395823, 41.410253, 8.281368, 48.487850, 43.867739, 42.572075, 11.794919, 43.172986, 5.245779, 29.132580, 8.303625, 3.283088, 6.854585, 16.825579, 18.611768, 30.162836, 1.680397, 43.930437, 46.457798, 55.915674, 0.898382, 2.788154, 0.226479, 47.829245, 41.967785, 49.099562, 45.319827, 4.809021, 51.469720, 21.358756, 31.701228, 1.547744, 31.334033, 48.399410, 15.373334, 39.505684, 54.271273, 25.027024, 5.629472, 38.569570, 41.047757, 29.329374, 21.313874, 16.137382, 33.320168, 10.841806, 55.809751, 45.141183, 8.680812, 50.697484, 48.039955, 42.216224, 24.417751, 48.450444, 7.626102, 15.876947, 22.020469, 17.167520, 37.791420, 43.500553, 54.822516, 37.655194, 3.169925, 15.521354, 26.941560, 55.308955, 21.387994, 35.292240, 0.399953, 11.518721, 6.865102, 39.948746, 8.889421, 5.398009, 23.128144, 30.470480, 17.946274, 9.332546, 1.567308, 10.384947, 44.949036, 15.676651, 26.482711, 4.280793, 24.739064, 10.966483, 16.155085, 22.479479, 5.394912, 46.280926, 18.203517, 14.710093, 36.385619, 19.339936, 43.447022, 22.027048, 0.860156, 18.148790, 30.627894, 18.167835, 43.626062, 40.038667, 50.803988, 32.707028, 53.085124, 12.260557, 26.273654, 52.136510, 3.504027, 8.346152, 31.859760, 34.970837, 31.621324, 40.167736, 34.294525, 51.615573, 11.337368, 50.915972, 17.621823, 37.848216, 44.665284, 42.747447, 12.617810, 25.596039, 51.329328, 23.879616, 40.979966, 44.625486, 13.643867, 8.586191, 49.988213, 21.594927, 13.645603, 13.416315, 23.829025, 36.765347, 26.395857, 26.879768, 4.970681, 0.356881, 40.215141, 16.685979, 4.550721, 2.656328, 44.855382, 19.501384, 26.061577, 0.382967, 28.773590, 48.797958, 39.491979, 44.876567, 31.894968, 47.018952, 5.839739, 14.626158, 17.195049, 48.208474, 16.778077, 49.215138, 30.020228, 13.065388, 3.786436, 33.797897, 6.882666, 38.799558, 18.510743, 48.405295, 31.831128, 16.343978, 45.311182, 27.044700, 3.458187, 11.756223, 47.482903, 21.114768, 50.262048, 16.908665, 45.015545, 30.312612, 54.746577, 3.088914, 21.528076, 28.017277, 18.263439, 20.721175, 28.159256, 18.667628, 37.114202, 47.290043, 3.303296, 37.875446, 4.168687, 49.979769, 2.961355, 43.841133, 22.318995, 25.213885, 15.316077, 4.277353, 4.062551, 14.920267, 3.026812, 20.135799, 25.557500, 24.481456, 4.484683, 46.018027, 42.551190, 23.247321, 39.240006, 51.902409, 41.787427, 38.574914, 36.178752, 1.303469, 20.676377, 3.100582, 7.961753, 10.549871, 45.495336, 1.393677, 23.391487, 35.120270, 31.940301, 29.281386, 26.201273, 38.108138, 26.530433, 33.637586, 15.342916, 34.191420, 34.562995, 44.815912, 35.479687, 43.252074, 15.908545, 55.737486, 33.564924, 32.895349, 53.286242, 21.302518, 20.356617, 54.936869, 4.619466, 41.859039, 36.711359, 40.276361, 42.703063, 24.028980, 33.430424, 22.713001, 13.316967, 47.424400, 48.320607, 44.470631, 34.332289, 42.864654, 22.340326, 15.708207, 10.866770, 41.879857, 18.747756, 8.809524, 35.127731, 24.814274, 7.686857, 8.779005, 54.765405, 27.199054, 28.468642, 7.624893, 27.689169, 50.310576, 6.411569, 19.960358, 11.201831, 30.519617, 51.885285, 31.960337, 3.578876, 13.474735, 28.971366, 20.939033, 52.190261, 24.015422, 43.124629, 2.692717, 10.779443, 30.368224, 4.194001, 28.472988, 38.173101, 18.609987, 45.387999, 32.719137, 51.673387, 11.037272, 40.399874, 5.109422, 41.186571, 40.703090, 23.886479, 13.246435, 2.719629, 9.911059, 28.731876, 22.710397, 1.653504, 36.904490, 14.401064, 41.601680, 8.970810, 52.283748, 22.087873, 52.558578, 3.539710, 4.439100, 36.232853, 46.615158, 32.631829, 52.286564, 7.727978, 23.918784, 16.986345, 33.192586, 0.426277, 23.125604, 50.729320, 15.061278, 6.919039, 22.964530, 37.794618, 44.882229, 31.442116, 12.038607, 9.479311, 35.618458, 54.642514, 41.330555, 28.884628, 47.918929, 52.386942, 6.872439, 36.093914, 26.517019, 34.278227, 0.222490, 42.828365, 55.534817, 18.961885, 47.248044, 14.527606, 6.626371, 6.127922, 35.557940, 36.797572, 52.398024, 39.199188, 54.534424, 3.424104, 26.218768, 16.912572, 14.559647, 15.936551, 54.872155, 23.518952, 53.216403, 2.487884, 18.435992, 2.706606, 10.550594, 20.071933, 28.305476, 50.624753, 49.858889, 39.533158, 21.717224, 53.016576, 53.441717, 21.118508, 45.054549, 42.913915, 36.967717, 47.386031, 33.865485, 0.265858, 8.877300, 50.565404, 15.714716, 15.448258, 21.029074, 34.255291, 18.181988, 14.511435, 45.116161, 51.447305, 48.786463, 23.546434, 52.259441, 19.124550, 22.965157, 36.466364, 15.708157, 38.422829, 43.272211, 36.080291, 26.733437, 13.406166, 52.473140, 46.930472, 50.742761, 42.894119, 26.757750, 12.788227, 43.782943, 29.508763, 54.569796, 12.674594, 34.116990, 22.305358, 5.855548, 22.814922, 4.781115, 23.372961, 20.184362, 36.706393, 17.918049, 28.152930, 35.563679, 21.545349, 40.091647, 21.888151, 38.879526, 35.788790, 16.062191, 22.687577, 34.618489, 24.624773, 11.474557, 34.990127, 49.025443, 3.500413, 14.608855, 55.474760, 13.330886, 33.148218, 55.833961, 31.104430, 10.176607, 48.163591, 43.833739, 15.548263, 11.053287, 4.615473, 32.867905, 47.882342, 21.672221, 53.942871, 54.957457, 30.503425, 28.034947, 17.550856, 30.381344, 25.069795, 11.013052, 22.243154, 47.771310, 31.997254, 13.620606, 32.849497, 27.336903, 52.133963, 10.946105, 48.022435, 24.187662, 27.723168, 25.828931, 28.988002, 18.763440, 51.946984, 48.952729, 5.522379, 29.892426, 55.038609, 10.747429, 19.776664, 32.049337, 3.260765, 4.131203, 12.116765, 42.337418, 11.013136, 18.418278, 31.272285, 26.227752, 8.191885, 49.315031, 19.645217, 38.432269, 33.043932, 11.208957, 0.350418, 25.074014, 5.227477, 32.582207, 14.222808, 48.546307, 9.322819, 34.987593, 47.928232, 49.137686, 13.750253, 38.562456, 4.338876, 8.749971, 45.602580, 42.349919, 38.070938, 6.760258, 6.367847, 27.171767, 3.457073, 43.073926, 30.885757, 39.028070, 22.534888, 4.470796, 26.345209, 31.882977, 46.419388, 51.642562, 53.101546, 51.811671, 44.436847, 25.360285, 10.537653, 45.402050, 5.255043, 43.189062, 19.083804, 43.183625, 30.532248, 13.808240, 38.980004, 42.608211, 11.940362, 5.437221, 54.584347, 31.354918, 7.719998, 54.306262, 43.743315, 44.294974, 32.058530, 47.718744, 7.530872, 49.908163, 39.462612, 49.650025, 51.419543, 2.702298, 52.608097, 30.005454, 8.729625, 36.148371, 37.895484, 3.396158, 24.446541, 39.992851, 48.674872, 54.510110, 45.268606, 9.521764, 43.184613, 7.582424, 26.528365, 4.179664, 8.795833, 55.498290, 53.564872, 23.536924, 20.889669, 35.606497, 35.639974, 9.550816, 34.191953, 2.215572, 18.398413, 45.820636, 35.483753, 33.690481, 27.567134, 29.304677, 43.043228, 30.590302, 52.760518, 41.567561, 5.834871, 36.533326, 24.743562, 16.253385, 33.476134, 41.656360, 38.387290, 9.497638, 3.150311, 18.766825, 31.241336, 5.855998, 47.226519, 11.290067, 52.008877, 4.085340, 29.342699, 44.761532, 3.414303, 31.200450, 34.503949, 14.886667, 17.612458, 41.096395, 43.927799, 13.798400, 0.201074, 5.089976, 46.585881, 19.357956, 40.844902, 30.204379, 17.803065, 31.209418, 14.289000, 55.439753, 39.102789, 30.521196, 26.885136, 24.441403, 32.479545, 45.962462, 39.539755, 34.751046, 12.619311, 42.171467, 52.355512, 54.906040, 12.378595, 14.065944, 41.530607, 28.894901, 30.165363, 50.253932, 51.651825, 35.423124, 41.936177, 30.524886, 13.541808, 34.817650, 38.599868, 43.498321, 52.466068, 26.416602, 34.358632, 49.138846, 55.070708, 55.116999, 19.215026, 45.433306, 17.022446, 49.123076, 17.140772, 27.739300, 20.383720, 44.922505, 28.276423, 34.372332, 13.876065, 32.387687, 47.306914, 11.632560, 39.134270, 12.488227}, 907, output, 57);
                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 < 57; ++i)
                    ok += output[i] != expected_array[i];
                    
                if (ok)
                {         
                    printf("Powinno być: [12, 8, 13, 23, 21, 16, 11, 14, 17, 10, 14, 19, 14, 19, 15, 21, 14, 15, 20, 17, 14, 19, 20, 15, 15, 14, 18, 12, 16, 12, 17, 19, 15, 21, 20, 18, 18, 10, 16, 18, 11, 20, 15, 27, 17, 19, 12, 18, 19, 16, 11, 15, 19, 14, 18, 16, 0]\n");

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

                    for (int i = 0; i < 57; ++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, 11, 7, 10, 8};
                int output[] = {0, 2, 2, 0, -2};
        
                printf("#####START#####");
                int res = create_histogram((float[]){9.794504, 1.965850, 7.921490, 3.626457, 6.849742, 4.364229, 1.868772, 3.556968, 6.740499, 4.807068, 8.316713, 8.776154, 3.774956, 5.584292, 7.029158, 10.476162, 3.849103, 3.727583, 6.208129, 0.953428, 5.964710, 2.029934, 9.509325, 1.970911, 3.867953, 9.175660, 7.931541, 6.204905, 6.626600, 3.356338, 8.465162, 10.549677, 10.626933, 2.114205, 9.665608, 3.985247, 9.662304, 8.971835, 0.826989, 2.322445, 5.891876, 8.864178, 4.673323, 5.583452, 9.253724, 2.636119, 2.375512, 1.595411, 5.469396, 0.967748, 8.644925, 1.263287, 1.764050, 9.741301, 10.981714, 3.659332, 10.030574, 10.132368, 4.566403, 1.683439, 3.251569, 8.076359, 6.685148, 8.731141, 9.189849, 4.393078, 4.769627, 1.193299, 10.407331, 4.476190, 1.541310, 4.891941, 2.127399, 1.908930, 0.012289, 2.833206, 10.221392, 5.432997, 1.975762, 7.273048, 10.529278, 0.980324, 5.078019, 6.077533, 10.653857, 5.284806}, 86, output, 5);
                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 < 5; ++i)
                    ok += output[i] != expected_array[i];
                    
                if (ok)
                {         
                    printf("Powinno być: [5, 11, 7, 10, 8]\n");

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

                    for (int i = 0; i < 5; ++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, 2, 1, -2, 2, 2, 0, -1, -1, 2, 0};
        
                printf("#####START#####");
                int res = create_histogram((float[]){8.686943}, 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[] = {6};
                int output[] = {-2};
        
                printf("#####START#####");
                int res = create_histogram((float[]){2.056034, 10.780870, 9.180255, 0.482890, 2.731081, 8.073808, 10.707920, 5.930591, 10.483317, 1.870027, 10.288083, 4.462088, 10.380186, 10.760187, 7.111499, 1.908667, 0.628505, 7.728381, 10.848377, 2.194006, 3.432502, 2.744639, 10.746922, 0.545826, 10.218983, 1.629904, 0.917431, 8.339515, 1.987808, 8.583135, 2.374049, 3.041361, 7.537249, 7.344750, 9.728625, 10.545833, 8.395078, 2.567873, 4.014848, 0.574270, 6.100544, 3.498531, 4.375418, 3.335248, 6.395029, 5.088868, 0.012581, 2.302174}, 48, 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ć: [6]\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[]){6.407812, 3.557603, 9.863350}, 12, 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, 0, -1, 0, 1, 2, 2, -2, -2, 0, -1};

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

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

//
//  Test 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, 0, -1, 0, 1, 2, 2, -2, -2, 0, -1};

            printf("#####START#####");
            int res = create_histogram((float[]){6.407812, 3.557603, 9.863350}, 0, output, 16);
            printf("#####END#####");
            test_error(res == 1, "Funkcja create_histogram() powinna zwrócić 1, a zwróciłą %d", res);
        
    //
    // -----------
    //

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

//
//  Test 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, 0, -1, 0, 1, 2, 2, -2, -2, 0, -1};

            printf("#####START#####");
            int res = create_histogram((float[]){6.407812, 3.557603, 9.863350}, 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[] = {-2, 0, -1, 0, 1, 2, 2, -2, -2, 0, -1};

            printf("#####START#####");
            int res = create_histogram((float[]){6.407812, 3.557603, 9.863350}, -11, output, 15);
            printf("#####END#####");
            test_error(res == 1, "Funkcja create_histogram() powinna zwrócić 1, a zwróciłą %d", res);
        
    //
    // -----------
    //

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

//
//  Test 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, 0, -1, 0, 1, 2, 2, -2, -2, 0, -1};

            printf("#####START#####");
            int res = create_histogram((float[]){6.407812, 3.557603, 9.863350}, 19, output, -11);
            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[] = {-10, -5, 1, 0, -8, -9, -1, -9, 6};

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


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

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

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

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

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

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

            onerror_terminate(); // przerwanie wszystkich testów jednostkowych (np. coś jest mocno nie tak z kodem)

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

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

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

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


                const int expected_result = 8;
                const float expected_array[] = {8.000000, 10.000000, 3.000000, -3.000000, -6.000000, 9.000000, -8.000000, 7.000000, 0.000000};
                float dest[9]; 
                int result = read_vector_float(dest, 9, 0);           

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

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

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

                }

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

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

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

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


                const int expected_result = 8;
                const float expected_array[] = {-2.000000, 0.000000, -6.000000, 6.000000, -1.000000, -7.000000, 0.000000, -3.000000, -9.000000};
                float dest[9]; 
                int result = read_vector_float(dest, 9, -9);           

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

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

                test_error(ok == 0, "Funkcja read_vector_float() niepoprawnie pobrałá dane od użytkownika");
                if (ok)
                {
                    printf("Powinno być: [-5.000000, 3.000000, 6.000000, -3.000000, 7.000000, 10.000000, 8.000000, -6.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, 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();
}

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

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

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

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

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

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

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

            int expected_result = -1; 
            printf("#####START#####");
            int result = read_vector_float(NULL, -2, 2);           
            printf("#####END#####");

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

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




enum run_mode_t { rm_normal_with_rld = 0, rm_unit_test = 1, rm_main_test = 2 };

int __wrap_main(volatile int _argc, char** _argv, char** _envp)
{
    int volatile vargc = _argc;
    char ** volatile vargv = _argv, ** volatile venvp = _envp;
    volatile enum run_mode_t run_mode = rm_unit_test; // -1
    volatile int selected_test = -1;

    if (vargc > 1)
    {
        char* smode = strtok(vargv[1], ",");
        char* stest = strtok(NULL, "");
        char *errptr = NULL;
        run_mode = (enum run_mode_t)strtol(smode, &errptr, 10);
        if (*errptr == '\x0')
        {
            memmove(vargv + 1, vargv + 2, sizeof(char*) * (vargc - 1));
            vargc--;

            if (stest != NULL)
            {
                int val = (int)strtol(stest, &errptr, 10);
                if (*errptr == '\x0')
                    selected_test = val;
            }
        }
    }

    // printf("runmode=%d; selected_test=%d\n", run_mode, selected_test);

    // inicjuj testy jednostkowe
    unit_test_init(run_mode, "unit_test_v2.c");
    test_limit_init();
    rldebug_set_reported_severity_level(MSL_FAILURE);

    if (run_mode == rm_normal_with_rld)
    {
        // konfiguracja ograniczników
        rldebug_reset_limits();
        

        // uruchom funkcję main Studenta a potem wyświetl podsumowanie sterty i zasobów
        volatile int ret_code = rdebug_call_main(tested_main, vargc, vargv, venvp);

        rldebug_reset_limits();
        

        int leaks_detected = rldebug_show_leaked_resources(0);
        if (leaks_detected)
            raise(SIGHEAP);

        return ret_code;
    }

    
    if (run_mode == rm_unit_test)
    {
        test_title("Testy jednostkowe");

        void (*pfcn[])(void) =
        { 
            UTEST1, // Sprawdzanie poprawności działania funkcji create_histogram
            UTEST2, // Sprawdzanie poprawności działania funkcji create_histogram
            UTEST3, // Sprawdzanie poprawności działania funkcji create_histogram
            UTEST4, // Sprawdzanie poprawności działania funkcji create_histogram
            UTEST5, // Sprawdzanie poprawności działania funkcji create_histogram
            UTEST6, // Sprawdzanie poprawności działania funkcji create_histogram
            UTEST7, // Sprawdzanie poprawności działania funkcji create_histogram
            UTEST8, // Sprawdzanie poprawności działania funkcji create_histogram
            UTEST9, // Sprawdzanie poprawności działania funkcji create_histogram
            UTEST10, // Sprawdzanie poprawności działania funkcji create_histogram
            UTEST11, // Sprawdzanie poprawności działania funkcji create_histogram
            UTEST12, // Sprawdzanie poprawności działania funkcji create_histogram
            UTEST13, // Sprawdzanie poprawności działania funkcji create_histogram
            UTEST14, // Sprawdzanie poprawności działania funkcji create_histogram
            UTEST15, // Sprawdzanie poprawności działania funkcji create_histogram
            UTEST16, // Sprawdzanie poprawności działania funkcji create_histogram
            UTEST17, // Sprawdzanie poprawności działania funkcji display
            UTEST18, // Sprawdzanie poprawności działania funkcji read_vector_float
            UTEST19, // Sprawdzanie poprawności działania funkcji read_vector_float
            UTEST20, // Sprawdzanie poprawności działania funkcji read_vector_float
            UTEST21, // Sprawdzanie poprawności działania funkcji read_vector_float
            UTEST22, // Sprawdzanie poprawności działania funkcji read_vector_float
            UTEST23, // Sprawdzanie poprawności działania funkcji read_vector_float
            UTEST24, // Sprawdzanie poprawności działania funkcji read_vector_float
            NULL
        };

        for (int idx = 0; pfcn[idx] != NULL && !test_get_session_termination_flag(); idx++)
        {
            if (selected_test == -1 || selected_test == idx + 1)
                pfcn[idx]();

            // limit niezaliczonych testów, po jakim testy jednostkowe zostaną przerwane
            if (test_session_get_fail_count() >= 1000)
                test_terminate_session();
        }


        test_title("RLDebug :: Analiza wycieku zasobów");
        // sprawdź wycieki pamięci
        int leaks_detected = rldebug_show_leaked_resources(1);
        test_set_session_leaks(leaks_detected);

        // poinformuj serwer Mrówka o wyniku testu - podsumowanie
        test_title("Podsumowanie");
        if (selected_test == -1)
            test_summary(24); // wszystkie testy muszą zakończyć się sukcesem
        else
            test_summary(1); // tylko jeden (selected_test) test musi zakończyć się sukcesem
        return EXIT_SUCCESS;
    }
    

    if (run_mode == rm_main_test)
    {
        test_title("Testy funkcji main()");

        void (*pfcn[])(int, char**, char**) =
        { 
            NULL
        };

        for (volatile int idx = 0; pfcn[idx] != NULL && !test_get_session_termination_flag(); idx++)
        {
            if (selected_test == -1 || selected_test == idx + 1)
                pfcn[idx](vargc, vargv, venvp);

            // limit niezaliczonych testów, po jakim testy jednostkowe zostaną przerwane
            if (test_session_get_fail_count() >= 1000)
                test_terminate_session();
        }


        test_title("RLDebug :: Analiza wycieku zasobów");
        // sprawdź wycieki pamięci
        int leaks_detected = rldebug_show_leaked_resources(1);
        test_set_session_leaks(leaks_detected);

        // poinformuj serwer Mrówka o wyniku testu - podsumowanie
        test_title("Podsumowanie");
        if (selected_test == -1)
            test_summary(0); // wszystkie testy muszą zakończyć się sukcesem
        else
            test_summary(1); // tylko jeden (selected_test) test musi zakończyć się sukcesem

        return EXIT_SUCCESS;
    }

    printf("*** Nieznana wartość RunMode: %d", (int)run_mode);
    abort();
}