Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "s21_math.h"
- #include <check.h>
- #include <math.h>
- #include <stdio.h>
- // логарифм, синус, косинус - идеально
- // экспонента - посмотреть на большие числа
- // тангенс - пипополам
- // аркиснус и арккосинус выдают -nan вместо nan
- START_TEST(s21_abs_test) {}
- END_TEST
- START_TEST(s21_acos_test) {}
- END_TEST
- START_TEST(s21_asin_test) {}
- END_TEST
- START_TEST(s21_atan_test) {}
- END_TEST
- START_TEST(s21_ceil_test) {}
- END_TEST
- START_TEST(s21_cos_test) {
- int boolean = 0;
- long double E = 0.0000001;
- long double a = cos(0);
- long double b = s21_cos(0);
- if (fabs(a - b) < E)
- boolean = 1;
- else
- boolean = 0;
- ck_assert_msg(boolean, "PI_POPOLAM");
- a = cos(s21_PI_2);
- b = s21_cos(s21_PI_2);
- if (fabs(a - b) < E)
- boolean = 1;
- else
- boolean = 0;
- ck_assert_msg(boolean, "PI_POPOLAM");
- a = cos(1000000000);
- b = s21_cos(1000000000);
- if (fabs(a - b) < E)
- boolean = 1;
- else
- boolean = 0;
- ck_assert_msg(boolean, "PI_POPOLAM");
- // boolean = s21_memcmp(s21_memchr(testStr, 'B', 5), memchr(testStr, 'B', 5), 4) == 0;
- // ck_assert_double_eq(4.5, 4.5);
- // ck_assert_double_eq_tol(4.500032, 4.50055, 0.1);
- a = cos(s21_PI);
- b = s21_cos(s21_PI);
- if (fabs(a - b) < E)
- boolean = 1;
- else
- boolean = 0;
- ck_assert_msg(boolean, "PI_POPOLAM");
- a = cos(-999999999);
- b = s21_cos(-999999999);
- if (fabs(a - b) < E)
- boolean = 1;
- else
- boolean = 0;
- ck_assert_msg(boolean, "PI_POPOLAM");
- a = cos(1.234567);
- b = s21_cos(1.234567);
- if (fabs(a - b) < E)
- boolean = 1;
- else
- boolean = 0;
- ck_assert_msg(boolean, "PI_POPOLAM");
- }
- END_TEST
- START_TEST(s21_exp_test) {
- int boolean = 0;
- long double E = 0.0000001;
- long double a = exp(0.1);
- long double b = s21_exp(0.1);
- if (fabs(a - b) < E)
- boolean = 1;
- else
- boolean = 0;
- ck_assert_msg(boolean, "PI_POPOLAM");
- a = exp(0);
- b = s21_exp(0);
- if (fabs(a - b) < E)
- boolean = 1;
- else
- boolean = 0;
- ck_assert_msg(boolean, "PI_POPOLAM");
- a = exp(10);
- b = s21_exp(10);
- if (fabs(a - b) < E)
- boolean = 1;
- else
- boolean = 0;
- ck_assert_msg(boolean, "PI_POPOLAM");
- a = exp(-10);
- b = s21_exp(-10);
- if (fabs(a - b) < E)
- boolean = 1;
- else
- boolean = 0;
- ck_assert_msg(boolean, "PI_POPOLAM");
- a = exp(-1.23456);
- b = s21_exp(-1.23456);
- if (fabs(a - b) < E)
- boolean = 1;
- else
- boolean = 0;
- ck_assert_msg(boolean, "PI_POPOLAM");
- a = exp(-1000000000);
- b = s21_exp(-1000000000);
- if (fabs(a - b) < E)
- boolean = 1;
- else
- boolean = 0;
- ck_assert_msg(boolean, "PI_POPOLAM");
- }
- END_TEST
- START_TEST(s21_fabs_test) {}
- END_TEST
- START_TEST(s21_floor_test) {}
- END_TEST
- START_TEST(s21_fmod_test) {}
- END_TEST
- START_TEST(s21_log_test) {
- int boolean = 0;
- long double E = 0.0000001;
- long double a = log(0.1);
- long double b = s21_log(0.1);
- if (fabs(a - b) < E)
- boolean = 1;
- else
- boolean = 0;
- ck_assert_msg(boolean, "PI_POPOLAM");
- a = log(1);
- b = s21_log(1);
- if (fabs(a - b) < E)
- boolean = 1;
- else
- boolean = 0;
- ck_assert_msg(boolean, "PI_POPOLAM");
- a = log(1000000000000);
- b = s21_log(1000000000000);
- if (fabs(a - b) < E)
- boolean = 1;
- else
- boolean = 0;
- ck_assert_msg(boolean, "PI_POPOLAM");
- a = log(0.000001);
- b = s21_log(0.000001);
- if (fabs(a - b) < E)
- boolean = 1;
- else
- boolean = 0;
- ck_assert_msg(boolean, "PI_POPOLAM");
- }
- END_TEST
- START_TEST(s21_pow_test) {}
- END_TEST
- START_TEST(s21_sin_test) {
- int boolean = 0;
- long double E = 0.0000001;
- long double a = sin(0);
- long double b = s21_sin(0);
- if (fabs(a - b) < E)
- boolean = 1;
- else
- boolean = 0;
- ck_assert_msg(boolean, "PI_POPOLAM");
- a = sin(s21_PI_2);
- b = s21_sin(s21_PI_2);
- if (fabs(a - b) < E)
- boolean = 1;
- else
- boolean = 0;
- ck_assert_msg(boolean, "PI_POPOLAM");
- a = sin(1000000000);
- b = s21_sin(1000000000);
- if (fabs(a - b) < E)
- boolean = 1;
- else
- boolean = 0;
- ck_assert_msg(boolean, "PI_POPOLAM");
- // boolean = s21_memcmp(s21_memchr(testStr, 'B', 5), memchr(testStr, 'B', 5), 4) == 0;
- // ck_assert_double_eq(4.5, 4.5);
- // ck_assert_double_eq_tol(4.500032, 4.50055, 0.1);
- a = sin(s21_PI);
- b = s21_sin(s21_PI);
- if (fabs(a - b) < E)
- boolean = 1;
- else
- boolean = 0;
- ck_assert_msg(boolean, "PI_POPOLAM");
- a = sin(-999999999);
- b = s21_sin(-999999999);
- if (fabs(a - b) < E)
- boolean = 1;
- else
- boolean = 0;
- ck_assert_msg(boolean, "PI_POPOLAM");
- a = sin(1.234567);
- b = s21_sin(1.234567);
- if (fabs(a - b) < E)
- boolean = 1;
- else
- boolean = 0;
- ck_assert_msg(boolean, "PI_POPOLAM");
- }
- END_TEST
- START_TEST(s21_sqrt_test) {}
- END_TEST
- START_TEST(s21_tan_test) {}
- END_TEST
- Suite *s21_string_suite(void) {
- Suite *suite;
- TCase *getCase;
- suite = suite_create("String");
- getCase = tcase_create("core");
- tcase_add_test(getCase, s21_abs_test);
- tcase_add_test(getCase, s21_acos_test);
- tcase_add_test(getCase, s21_asin_test);
- tcase_add_test(getCase, s21_atan_test);
- tcase_add_test(getCase, s21_ceil_test);
- tcase_add_test(getCase, s21_cos_test);
- tcase_add_test(getCase, s21_exp_test);
- tcase_add_test(getCase, s21_fabs_test);
- tcase_add_test(getCase, s21_floor_test);
- tcase_add_test(getCase, s21_fmod_test);
- tcase_add_test(getCase, s21_log_test);
- tcase_add_test(getCase, s21_pow_test);
- tcase_add_test(getCase, s21_sin_test);
- tcase_add_test(getCase, s21_sqrt_test);
- tcase_add_test(getCase, s21_tan_test);
- suite_add_tcase(suite, getCase);
- return suite;
- }
- int main(void) {
- int amountOfFailed = 0;
- Suite *suite;
- SRunner *runner;
- suite = s21_string_suite();
- runner = srunner_create(suite);
- srunner_run_all(runner, CK_NORMAL);
- amountOfFailed = srunner_ntests_failed(runner);
- srunner_free(runner);
- return (amountOfFailed == 0) ? 0 : 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement