/
solidbase
/
C5_s21_decimal
Обзор
Документация
Войти
/
solidbase
/
C5_s21_decimal
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
develop
src/tests/test_convert.c
729 строк
24 KB
Dmitrii Isaev
earliema: refactor: rewrite convert and helpers tests
01 апр 2026, 15:15
01 апр 2026, 15:15
4d80a1c
Код
Авторство
О чём код?
#include "test_libs.h" void test_from_decimal_to_float(s21_decimal decimal, int check) { float result; int code = s21_from_decimal_to_float(decimal, &result); float_cast_test cast_result, n; cast_result.f = result; n.int32_bytes = check; ck_assert_int_eq(cast_result.int32_bytes, n.int32_bytes); ck_assert_int_eq(code, 0); } void test_from_float_to_decimal(int f, s21_decimal decimal_check) { s21_decimal result; float_cast_test cast_float; cast_float.int32_bytes = f; int code = s21_from_float_to_decimal(cast_float.f, &result); ck_assert_int_eq(code, 0); ck_assert_int_eq(s21_is_equal(result, decimal_check), 1); } void test_from_decimal_to_int(s21_decimal decimal, int check) { int result; int code = s21_from_decimal_to_int(decimal, &result); ck_assert_int_eq(result, check); ck_assert_int_eq(code, 0); } void test_from_decimal_to_int_fail(s21_decimal decimal) { int result; int code = s21_from_decimal_to_int(decimal, &result); ck_assert_int_eq(code, 1); } void test_from_int_to_decimal(int number, s21_decimal decimal_check) { s21_decimal result; int code = s21_from_int_to_decimal(number, &result); int sign_check = s21_get_sign(decimal_check); int sign_result = s21_get_sign(result); ck_assert_int_eq(code, 0); ck_assert_int_eq(s21_is_equal(result, decimal_check), 1); ck_assert_int_eq(sign_check, sign_result); } // ============================================================ // s21_from_int_to_decimal // ============================================================ START_TEST(test_from_int_to_decimal_ok1) { test_from_int_to_decimal(-2147483648, (s21_decimal){{0x80000000, 0x0, 0x0, 0x80000000}}); } END_TEST START_TEST(test_from_int_to_decimal_ok2) { test_from_int_to_decimal(-2147483647, (s21_decimal){{0x7FFFFFFF, 0x0, 0x0, 0x80000000}}); } END_TEST START_TEST(test_from_int_to_decimal_ok3) { test_from_int_to_decimal(-214748364, (s21_decimal){{0xCCCCCCC, 0x0, 0x0, 0x80000000}}); } END_TEST START_TEST(test_from_int_to_decimal_ok4) { test_from_int_to_decimal(-214748, (s21_decimal){{0x346DC, 0x0, 0x0, 0x80000000}}); } END_TEST START_TEST(test_from_int_to_decimal_ok5) { test_from_int_to_decimal(-1000, (s21_decimal){{0x3E8, 0x0, 0x0, 0x80000000}}); } END_TEST START_TEST(test_from_int_to_decimal_ok6) { test_from_int_to_decimal(-1, (s21_decimal){{0x1, 0x0, 0x0, 0x80000000}}); } END_TEST START_TEST(test_from_int_to_decimal_ok7) { test_from_int_to_decimal(0, (s21_decimal){{0x0, 0x0, 0x0, 0x0}}); } END_TEST START_TEST(test_from_int_to_decimal_ok8) { test_from_int_to_decimal(1, (s21_decimal){{0x1, 0x0, 0x0, 0x0}}); } END_TEST START_TEST(test_from_int_to_decimal_ok9) { test_from_int_to_decimal(1000, (s21_decimal){{0x3E8, 0x0, 0x0, 0x0}}); } END_TEST START_TEST(test_from_int_to_decimal_ok10) { test_from_int_to_decimal(214748, (s21_decimal){{0x346DC, 0x0, 0x0, 0x0}}); } END_TEST START_TEST(test_from_int_to_decimal_ok11) { test_from_int_to_decimal(214748364, (s21_decimal){{0xCCCCCCC, 0x0, 0x0, 0x0}}); } END_TEST START_TEST(test_from_int_to_decimal_ok12) { test_from_int_to_decimal(2147483646, (s21_decimal){{0x7FFFFFFE, 0x0, 0x0, 0x0}}); } END_TEST START_TEST(test_from_int_to_decimal_ok13) { test_from_int_to_decimal(2147483647, (s21_decimal){{0x7FFFFFFF, 0x0, 0x0, 0x0}}); } END_TEST // ============================================================ // s21_from_decimal_to_int // ============================================================ // multi-word mantissa, scale=20: 792281625.xxx -> 792281625 START_TEST(test_from_decimal_to_int_ok1) { test_from_decimal_to_int((s21_decimal){{(int)0xFFFFFFFF, (int)0xFFFFFFFF, (int)0xFFFFFFFF, 0x140000}}, 792281625); } END_TEST START_TEST(test_from_decimal_to_int_ok2) { test_from_decimal_to_int((s21_decimal){{(int)0xFFFFFFFF, (int)0xFFFFFFFF, (int)0xFFFFFFFF, 0x80140000}}, -792281625); } END_TEST // same mantissa, scale=28 (max): 7.xxx -> 7 START_TEST(test_from_decimal_to_int_ok3) { test_from_decimal_to_int((s21_decimal){{(int)0xFFFFFFFF, (int)0xFFFFFFFF, (int)0xFFFFFFFF, 0x1C0000}}, 7); } END_TEST START_TEST(test_from_decimal_to_int_ok4) { test_from_decimal_to_int((s21_decimal){{(int)0xFFFFFFFF, (int)0xFFFFFFFF, (int)0xFFFFFFFF, 0x801C0000}}, -7); } END_TEST // single word, scale=1: 286331153.0 -> 286331153 START_TEST(test_from_decimal_to_int_ok5) { test_from_decimal_to_int((s21_decimal){{(int)0xAAAAAAAA, 0x0, 0x0, 0x10000}}, 286331153); } END_TEST START_TEST(test_from_decimal_to_int_ok6) { test_from_decimal_to_int( (s21_decimal){{(int)0xAAAAAAAA, 0x0, 0x0, 0x80010000}}, -286331153); } END_TEST // single word, scale=4: 286331.1530 -> 286331 START_TEST(test_from_decimal_to_int_ok7) { test_from_decimal_to_int((s21_decimal){{(int)0xAAAAAAAA, 0x0, 0x0, 0x40000}}, 286331); } END_TEST START_TEST(test_from_decimal_to_int_ok8) { test_from_decimal_to_int( (s21_decimal){{(int)0xAAAAAAAA, 0x0, 0x0, 0x80040000}}, -286331); } END_TEST // scale=0, exact integer: 1431655765 START_TEST(test_from_decimal_to_int_ok9) { test_from_decimal_to_int((s21_decimal){{0x55555555, 0x0, 0x0, 0x0}}, 1431655765); } END_TEST START_TEST(test_from_decimal_to_int_ok10) { test_from_decimal_to_int((s21_decimal){{0x55555555, 0x0, 0x0, 0x80000000}}, -1431655765); } END_TEST // scale=9, fractional truncated: 1.431655765 -> 1 START_TEST(test_from_decimal_to_int_ok11) { test_from_decimal_to_int((s21_decimal){{0x55555555, 0x0, 0x0, 0x90000}}, 1); } END_TEST START_TEST(test_from_decimal_to_int_ok12) { test_from_decimal_to_int((s21_decimal){{0x55555555, 0x0, 0x0, 0x80090000}}, -1); } END_TEST // multi-word, scale=11: 184467440.xxx -> 184467440 START_TEST(test_from_decimal_to_int_ok13) { test_from_decimal_to_int((s21_decimal){{0x1, 0x1, 0x1, 0xB0000}}, 184467440); } END_TEST START_TEST(test_from_decimal_to_int_ok14) { test_from_decimal_to_int((s21_decimal){{0x1, 0x1, 0x1, 0x800B0000}}, -184467440); } END_TEST // ============================================================ // s21_from_decimal_to_int — fail cases // ============================================================ // 2147483648: one above INT_MAX START_TEST(test_from_decimal_to_int_fail1) { test_from_decimal_to_int_fail((s21_decimal){{0x80000000, 0x0, 0x0, 0x0}}); } END_TEST // -MAX mantissa (overflows in negative direction) START_TEST(test_from_decimal_to_int_fail2) { test_from_decimal_to_int_fail((s21_decimal){ {(int)0xFFFFFFFF, (int)0xFFFFFFFF, (int)0xFFFFFFFF, 0x80000000}}); } END_TEST // MAX mantissa scale=1: still too big after truncation START_TEST(test_from_decimal_to_int_fail3) { test_from_decimal_to_int_fail((s21_decimal){ {(int)0xFFFFFFFF, (int)0xFFFFFFFF, (int)0xFFFFFFFF, 0x10000}}); } END_TEST START_TEST(test_from_decimal_to_int_fail4) { test_from_decimal_to_int_fail((s21_decimal){ {(int)0xFFFFFFFF, (int)0xFFFFFFFF, (int)0xFFFFFFFF, 0x80010000}}); } END_TEST // 0xFFFFFFFE * 3 words, scale=0 START_TEST(test_from_decimal_to_int_fail5) { test_from_decimal_to_int_fail( (s21_decimal){{(int)0xFFFFFFFE, (int)0xFFFFFFFF, (int)0xFFFFFFFF, 0x0}}); } END_TEST // 0xAAAAAAAA * 3 words, scale=0 START_TEST(test_from_decimal_to_int_fail6) { test_from_decimal_to_int_fail( (s21_decimal){{(int)0xAAAAAAAA, (int)0xAAAAAAAA, (int)0xAAAAAAAA, 0x0}}); } END_TEST // bits[1/2] set, bits[0]=0, scale=0 START_TEST(test_from_decimal_to_int_fail7) { test_from_decimal_to_int_fail( (s21_decimal){{0x0, (int)0xAAAAAAAA, (int)0xAAAAAAAA, 0x0}}); } END_TEST // bits[0/1] set, bits[2]=0, scale=0 START_TEST(test_from_decimal_to_int_fail8) { test_from_decimal_to_int_fail( (s21_decimal){{(int)0xAAAAAAAA, (int)0xAAAAAAAA, 0x0, 0x0}}); } END_TEST // NULL pointer START_TEST(test_from_decimal_to_int_fail9) { s21_decimal d = {{1, 0, 0, 0}}; ck_assert_int_eq(s21_from_decimal_to_int(d, NULL), 1); } END_TEST // invalid bits[3]: scale=29 START_TEST(test_from_decimal_to_int_fail10) { test_from_decimal_to_int_fail((s21_decimal){{1, 0, 0, 0x1D0000}}); } END_TEST // invalid bits[3]: reserved bits non-zero START_TEST(test_from_decimal_to_int_fail11) { test_from_decimal_to_int_fail((s21_decimal){ {(int)0xFFFFFFFF, (int)0xFFFFFFFF, (int)0xFFFFFFFF, (int)0xFFFFFFFF}}); } END_TEST // ============================================================ // s21_from_float_to_decimal // ============================================================ // 2.28401628E-19 -> 0.0000000000000000002284016 START_TEST(test_from_float_to_decimal_1) { test_from_float_to_decimal(545706772, (s21_decimal){{0x22D9F0, 0x0, 0x0, 0x190000}}); } END_TEST START_TEST(test_from_float_to_decimal_2) { test_from_float_to_decimal(-1601776876, (s21_decimal){{0x22D9F0, 0x0, 0x0, 0x80190000}}); } END_TEST // 5.92141241E+23 -> 592141200000000000000000 START_TEST(test_from_float_to_decimal_3) { test_from_float_to_decimal( 1727711253, (s21_decimal){{(int)0xBF280000, 0x9ED0576, 0x7D64, 0x0}}); } END_TEST START_TEST(test_from_float_to_decimal_4) { test_from_float_to_decimal( -419772395, (s21_decimal){{(int)0xBF280000, 0x9ED0576, 0x7D64, 0x80000000}}); } END_TEST // 2.38582807E-08 -> 0.00000002385828 START_TEST(test_from_float_to_decimal_5) { test_from_float_to_decimal(852291818, (s21_decimal){{0x2467A4, 0x0, 0x0, 0xE0000}}); } END_TEST START_TEST(test_from_float_to_decimal_6) { test_from_float_to_decimal(-1295191830, (s21_decimal){{0x2467A4, 0x0, 0x0, 0x800E0000}}); } END_TEST // 7.91617864E+11 -> 791617900000 START_TEST(test_from_float_to_decimal_7) { test_from_float_to_decimal(1396199450, (s21_decimal){{(int)0x501A8DE0, 0xB8, 0x0, 0x0}}); } END_TEST START_TEST(test_from_float_to_decimal_8) { test_from_float_to_decimal( -751284198, (s21_decimal){{(int)0x501A8DE0, 0xB8, 0x0, 0x80000000}}); } END_TEST // 9.29209423E+24 -> 9292094000000000000000000 START_TEST(test_from_float_to_decimal_9) { test_from_float_to_decimal( 1760949678, (s21_decimal){{0xE380000, (int)0x6CD28004, 0x7AFAD, 0x0}}); } END_TEST START_TEST(test_from_float_to_decimal_10) { test_from_float_to_decimal( -386533970, (s21_decimal){{0xE380000, (int)0x6CD28004, 0x7AFAD, 0x80000000}}); } END_TEST // 0.000115481133 -> 0.0001154811 START_TEST(test_from_float_to_decimal_11) { test_from_float_to_decimal(955395702, (s21_decimal){{0x119EFB, 0x0, 0x0, 0xA0000}}); } END_TEST START_TEST(test_from_float_to_decimal_12) { test_from_float_to_decimal(-1192087946, (s21_decimal){{0x119EFB, 0x0, 0x0, 0x800A0000}}); } END_TEST // 4882.71582 -> 4882.716 START_TEST(test_from_float_to_decimal_13) { test_from_float_to_decimal(1167627706, (s21_decimal){{0x4A811C, 0x0, 0x0, 0x30000}}); } END_TEST START_TEST(test_from_float_to_decimal_14) { test_from_float_to_decimal(-979855942, (s21_decimal){{0x4A811C, 0x0, 0x0, 0x80030000}}); } END_TEST // ============================================================ // s21_from_decimal_to_float // ============================================================ // 79228162514264337593543950335 (MAX, scale=0) START_TEST(test_from_decimal_to_float_1) { test_from_decimal_to_float( (s21_decimal){{(int)0xFFFFFFFF, (int)0xFFFFFFFF, (int)0xFFFFFFFF, 0x0}}, 1870659584); } END_TEST START_TEST(test_from_decimal_to_float_2) { test_from_decimal_to_float((s21_decimal){{(int)0xFFFFFFFF, (int)0xFFFFFFFF, (int)0xFFFFFFFF, 0x80000000}}, -276824064); } END_TEST // 7922816251426433759354395033.5 (scale=1) START_TEST(test_from_decimal_to_float_3) { test_from_decimal_to_float((s21_decimal){{(int)0xFFFFFFFF, (int)0xFFFFFFFF, (int)0xFFFFFFFF, 0x10000}}, 1842138317); } END_TEST START_TEST(test_from_decimal_to_float_4) { test_from_decimal_to_float((s21_decimal){{(int)0xFFFFFFFF, (int)0xFFFFFFFF, (int)0xFFFFFFFF, 0x80010000}}, -305345331); } END_TEST // -123456.123456 (scale=6) START_TEST(test_from_decimal_to_float_5) { test_from_decimal_to_float( (s21_decimal){{(int)0xBE8EF240, 0x1C, 0x0, 0x80060000}}, -940498929); } END_TEST // 327158.72715840 (scale=8) START_TEST(test_from_decimal_to_float_6) { test_from_decimal_to_float( (s21_decimal){{(int)0x41F8C440, 0x1DC1, 0x0, 0x80000}}, 1218428631); } END_TEST START_TEST(test_from_decimal_to_float_7) { test_from_decimal_to_float( (s21_decimal){{(int)0x41F8C440, 0x1DC1, 0x0, 0x80080000}}, -929055017); } END_TEST // 1234567890.1234567890 (scale=10) START_TEST(test_from_decimal_to_float_8) { test_from_decimal_to_float( (s21_decimal){{(int)0xEB1F0AD2, (int)0xAB54A98C, 0x0, 0xA0000}}, 1318267910); } END_TEST START_TEST(test_from_decimal_to_float_9) { test_from_decimal_to_float( (s21_decimal){{(int)0xEB1F0AD2, (int)0xAB54A98C, 0x0, 0x800A0000}}, -829215738); } END_TEST // 1 (simplest case) START_TEST(test_from_decimal_to_float_10) { test_from_decimal_to_float((s21_decimal){{0x1, 0x0, 0x0, 0x0}}, 1065353216); } END_TEST START_TEST(test_from_decimal_to_float_11) { test_from_decimal_to_float((s21_decimal){{0x1, 0x0, 0x0, 0x80000000}}, -1082130432); } END_TEST // 2.65 START_TEST(test_from_decimal_to_float_12) { test_from_decimal_to_float((s21_decimal){{0x109, 0x0, 0x0, 0x20000}}, 1076468122); } END_TEST START_TEST(test_from_decimal_to_float_13) { test_from_decimal_to_float((s21_decimal){{0x109, 0x0, 0x0, 0x80020000}}, -1071015526); } END_TEST // 0.15625 START_TEST(test_from_decimal_to_float_14) { test_from_decimal_to_float((s21_decimal){{0x3D09, 0x0, 0x0, 0x50000}}, 1042284544); } END_TEST START_TEST(test_from_decimal_to_float_15) { test_from_decimal_to_float((s21_decimal){{0x3D09, 0x0, 0x0, 0x80050000}}, -1105199104); } END_TEST // ============================================================ // Fail cases // ============================================================ // NULL dst pointer START_TEST(test_from_decimal_to_float_fail1) { s21_decimal decimal = { {(int)0xFFFFFFFF, (int)0xFFFFFFFF, (int)0xFFFFFFFF, 0x140000}}; ck_assert_int_eq(s21_from_decimal_to_float(decimal, NULL), 1); } END_TEST // invalid bits[3]: reserved bits set START_TEST(test_from_decimal_to_float_fail2) { s21_decimal decimal = {{0, 0, 0, 1000000000}}; float result; ck_assert_int_eq(s21_from_decimal_to_float(decimal, &result), 1); } END_TEST // scale=29 (out of range) START_TEST(test_from_decimal_to_float_fail3) { s21_decimal decimal = {{-1, 0, 0, 0x1D0000}}; float result; ck_assert_int_eq(s21_from_decimal_to_float(decimal, &result), 1); } END_TEST // scale=29, mantissa=0 START_TEST(test_from_decimal_to_float_fail4) { s21_decimal decimal = {{0, 0, 0, 0x1D0000}}; float result; ck_assert_int_eq(s21_from_decimal_to_float(decimal, &result), 1); } END_TEST // scale=28 (valid) but bits 0-15 non-zero (lower byte) START_TEST(test_from_decimal_to_float_fail5) { s21_decimal decimal = {{-1, 0, 0, 0x1C0001}}; float result; ck_assert_int_eq(s21_from_decimal_to_float(decimal, &result), 1); } END_TEST // scale=28 but bits 0-15 non-zero (upper byte) START_TEST(test_from_decimal_to_float_fail6) { s21_decimal decimal = {{-1, 0, 0, 0x1C8000}}; float result; ck_assert_int_eq(s21_from_decimal_to_float(decimal, &result), 1); } END_TEST // scale=28 but bits 24-30 non-zero (lower bit) START_TEST(test_from_decimal_to_float_fail7) { s21_decimal decimal = {{-1, 0, 0, 0x11C0000}}; float result; ck_assert_int_eq(s21_from_decimal_to_float(decimal, &result), 1); } END_TEST // scale=28 but bits 24-30 non-zero (upper bit) START_TEST(test_from_decimal_to_float_fail8) { s21_decimal decimal = {{-1, 0, 0, 0x401C0000}}; float result; ck_assert_int_eq(s21_from_decimal_to_float(decimal, &result), 1); } END_TEST // all bits set START_TEST(test_from_decimal_to_float_fail9) { s21_decimal decimal = { {(int)0xFFFFFFFF, (int)0xFFFFFFFF, (int)0xFFFFFFFF, (int)0xFFFFFFFF}}; float result; ck_assert_int_eq(s21_from_decimal_to_float(decimal, &result), 1); } END_TEST // NULL dst pointer for float_to_decimal START_TEST(test_from_float_to_decimal_fail1) { ck_assert_int_eq(s21_from_float_to_decimal(1.0f, NULL), 1); } END_TEST // float too large (INF range) START_TEST(test_from_float_to_decimal_fail2) { s21_decimal result; ck_assert_int_eq(s21_from_float_to_decimal( 340282346638528859811704183484516925440.f, &result), 1); } END_TEST START_TEST(test_from_float_to_decimal_fail3) { s21_decimal result; ck_assert_int_eq(s21_from_float_to_decimal( -340282346638528859811704183484516925440.f, &result), 1); } END_TEST // float too small (underflow to zero) START_TEST(test_from_float_to_decimal_fail4) { s21_decimal result; s21_decimal check = {{0x0, 0x0, 0x0, 0x0}}; int code = s21_from_float_to_decimal(7.713304344e-45f, &result); ck_assert_int_eq(code, 1); ck_assert_int_eq(s21_is_equal(result, check), 1); } END_TEST START_TEST(test_from_float_to_decimal_fail5) { s21_decimal result; s21_decimal check = {{0x0, 0x0, 0x0, 0x0}}; int code = s21_from_float_to_decimal(-7.713304344e-45f, &result); ck_assert_int_eq(code, 1); ck_assert_int_eq(s21_is_equal(result, check), 1); } END_TEST // ============================================================ // Suite // ============================================================ Suite* suite_decimal_convert(void) { Suite* conv = suite_create("Сonvertasion"); TCase* int_to_decimal = tcase_create("Int_to_decimal"); tcase_add_test(int_to_decimal, test_from_int_to_decimal_ok1); tcase_add_test(int_to_decimal, test_from_int_to_decimal_ok2); tcase_add_test(int_to_decimal, test_from_int_to_decimal_ok3); tcase_add_test(int_to_decimal, test_from_int_to_decimal_ok4); tcase_add_test(int_to_decimal, test_from_int_to_decimal_ok5); tcase_add_test(int_to_decimal, test_from_int_to_decimal_ok6); tcase_add_test(int_to_decimal, test_from_int_to_decimal_ok7); tcase_add_test(int_to_decimal, test_from_int_to_decimal_ok8); tcase_add_test(int_to_decimal, test_from_int_to_decimal_ok9); tcase_add_test(int_to_decimal, test_from_int_to_decimal_ok10); tcase_add_test(int_to_decimal, test_from_int_to_decimal_ok11); tcase_add_test(int_to_decimal, test_from_int_to_decimal_ok12); tcase_add_test(int_to_decimal, test_from_int_to_decimal_ok13); suite_add_tcase(conv, int_to_decimal); TCase* decimal_to_int = tcase_create("Decimal_to_int"); tcase_add_test(decimal_to_int, test_from_decimal_to_int_ok1); tcase_add_test(decimal_to_int, test_from_decimal_to_int_ok2); tcase_add_test(decimal_to_int, test_from_decimal_to_int_ok3); tcase_add_test(decimal_to_int, test_from_decimal_to_int_ok4); tcase_add_test(decimal_to_int, test_from_decimal_to_int_ok5); tcase_add_test(decimal_to_int, test_from_decimal_to_int_ok6); tcase_add_test(decimal_to_int, test_from_decimal_to_int_ok7); tcase_add_test(decimal_to_int, test_from_decimal_to_int_ok8); tcase_add_test(decimal_to_int, test_from_decimal_to_int_ok9); tcase_add_test(decimal_to_int, test_from_decimal_to_int_ok10); tcase_add_test(decimal_to_int, test_from_decimal_to_int_ok11); tcase_add_test(decimal_to_int, test_from_decimal_to_int_ok12); tcase_add_test(decimal_to_int, test_from_decimal_to_int_ok13); tcase_add_test(decimal_to_int, test_from_decimal_to_int_ok14); suite_add_tcase(conv, decimal_to_int); TCase* float_to_decimal = tcase_create("Float_to_decimal"); tcase_add_test(float_to_decimal, test_from_float_to_decimal_1); tcase_add_test(float_to_decimal, test_from_float_to_decimal_2); tcase_add_test(float_to_decimal, test_from_float_to_decimal_3); tcase_add_test(float_to_decimal, test_from_float_to_decimal_4); tcase_add_test(float_to_decimal, test_from_float_to_decimal_5); tcase_add_test(float_to_decimal, test_from_float_to_decimal_6); tcase_add_test(float_to_decimal, test_from_float_to_decimal_7); tcase_add_test(float_to_decimal, test_from_float_to_decimal_8); tcase_add_test(float_to_decimal, test_from_float_to_decimal_9); tcase_add_test(float_to_decimal, test_from_float_to_decimal_10); tcase_add_test(float_to_decimal, test_from_float_to_decimal_11); tcase_add_test(float_to_decimal, test_from_float_to_decimal_12); tcase_add_test(float_to_decimal, test_from_float_to_decimal_13); tcase_add_test(float_to_decimal, test_from_float_to_decimal_14); suite_add_tcase(conv, float_to_decimal); TCase* decimal_to_float = tcase_create("Decimal_to_float"); tcase_add_test(decimal_to_float, test_from_decimal_to_float_1); tcase_add_test(decimal_to_float, test_from_decimal_to_float_2); tcase_add_test(decimal_to_float, test_from_decimal_to_float_3); tcase_add_test(decimal_to_float, test_from_decimal_to_float_4); tcase_add_test(decimal_to_float, test_from_decimal_to_float_5); tcase_add_test(decimal_to_float, test_from_decimal_to_float_6); tcase_add_test(decimal_to_float, test_from_decimal_to_float_7); tcase_add_test(decimal_to_float, test_from_decimal_to_float_8); tcase_add_test(decimal_to_float, test_from_decimal_to_float_9); tcase_add_test(decimal_to_float, test_from_decimal_to_float_10); tcase_add_test(decimal_to_float, test_from_decimal_to_float_11); tcase_add_test(decimal_to_float, test_from_decimal_to_float_12); tcase_add_test(decimal_to_float, test_from_decimal_to_float_13); tcase_add_test(decimal_to_float, test_from_decimal_to_float_14); tcase_add_test(decimal_to_float, test_from_decimal_to_float_15); suite_add_tcase(conv, decimal_to_float); TCase* fail = tcase_create("Fail data"); tcase_add_test(fail, test_from_decimal_to_float_fail1); tcase_add_test(fail, test_from_decimal_to_float_fail2); tcase_add_test(fail, test_from_decimal_to_float_fail3); tcase_add_test(fail, test_from_decimal_to_float_fail4); tcase_add_test(fail, test_from_decimal_to_float_fail5); tcase_add_test(fail, test_from_decimal_to_float_fail6); tcase_add_test(fail, test_from_decimal_to_float_fail7); tcase_add_test(fail, test_from_decimal_to_float_fail8); tcase_add_test(fail, test_from_decimal_to_float_fail9); tcase_add_test(fail, test_from_float_to_decimal_fail1); tcase_add_test(fail, test_from_float_to_decimal_fail2); tcase_add_test(fail, test_from_float_to_decimal_fail3); tcase_add_test(fail, test_from_float_to_decimal_fail4); tcase_add_test(fail, test_from_float_to_decimal_fail5); tcase_add_test(fail, test_from_decimal_to_int_fail1); tcase_add_test(fail, test_from_decimal_to_int_fail2); tcase_add_test(fail, test_from_decimal_to_int_fail3); tcase_add_test(fail, test_from_decimal_to_int_fail4); tcase_add_test(fail, test_from_decimal_to_int_fail5); tcase_add_test(fail, test_from_decimal_to_int_fail6); tcase_add_test(fail, test_from_decimal_to_int_fail7); tcase_add_test(fail, test_from_decimal_to_int_fail8); tcase_add_test(fail, test_from_decimal_to_int_fail9); tcase_add_test(fail, test_from_decimal_to_int_fail10); tcase_add_test(fail, test_from_decimal_to_int_fail11); suite_add_tcase(conv, fail); return conv; }