1
0
forked from 131/lab3_test
Files
lab3_test/aux_test.c
etrushko05 59d2d3e1cd 523
2025-11-22 03:22:24 -05:00

68 lines
2.3 KiB
C
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include <stdio.h>
#include "munit/munit.h"
#include "aux_lib.h"
#include <stdbool.h>
static MunitResult test_fibonacci_base(const MunitParameter params[], void* fixture) {
munit_assert_int(fibonacci(0), ==, 0);
munit_assert_int(fibonacci(1), ==, 1);
munit_assert_int(fibonacci(2), ==, 1);
munit_assert_int(fibonacci(3), ==, 2);
return MUNIT_OK;
}
static MunitResult test_bit_count(const MunitParameter params[], void* fixture) {
munit_assert_int(bit_count(0), ==, 0);
munit_assert_int(bit_count(1), ==, 1);
munit_assert_int(bit_count(3), ==, 2);
munit_assert_int(bit_count(8), ==, 1);
munit_assert_int(bit_count(255), ==, 8);
munit_assert_int(bit_count(0xFFFFFFFF), ==, 32);
return MUNIT_OK;
}
static MunitResult test_fibonacci_advanced(const MunitParameter params[], void* fixture) {
munit_assert_int(fibonacci(10), ==, 55);
munit_assert_int(fibonacci(20), ==, 6765);
return MUNIT_OK;
}
static MunitResult test_sum_odd(const MunitParameter params[], void* fixture) {
int arr[] = {1, 2, 3, 4, 5};
munit_assert_true(sum_is_odd(arr, 5));
return MUNIT_OK;
}
static MunitResult test_sum_even(const MunitParameter params[], void* fixture) {
int arr[] = {1, 2, 3, 4, 5, 1};
munit_assert_false(sum_is_odd(arr, 6));
return MUNIT_OK;
}
static MunitTest test_suite_tests[] = {
{ (char*) "fibonacci base cases", test_fibonacci_base, NULL, NULL, MUNIT_TEST_OPTION_NONE, NULL },
{ (char*) "fibonacci advanced cases", test_fibonacci_advanced, NULL, NULL, MUNIT_TEST_OPTION_NONE, NULL },
{ (char*) "sum odd array", test_sum_odd, NULL, NULL, MUNIT_TEST_OPTION_NONE, NULL },
{ (char*) "sum even array", test_sum_even, NULL, NULL, MUNIT_TEST_OPTION_NONE, NULL },
{ (char*) "bit count", test_bit_count, NULL, NULL, MUNIT_TEST_OPTION_NONE, NULL },
{ NULL, NULL, NULL, NULL, MUNIT_TEST_OPTION_NONE, NULL }
};
static const MunitSuite test_suite = {
(char*) "",
test_suite_tests,
NULL, // Вложенные наборы ÑеÑ<C2B5>tov
1, // КоличеÑ<C2B5>Ñво прогонов
MUNIT_SUITE_OPTION_NONE
};
int
main(int argc, const char *argv[])
{
munit_suite_main(&test_suite, (void *) "auxiliary library test", argc, (char * const*) argv);
return 0;
}