From 89f0f2e1c5ba33523a82325462bcb460930c9e84 Mon Sep 17 00:00:00 2001 From: serr Date: Mon, 12 May 2025 18:51:58 +0300 Subject: [PATCH] add test poly --- analyzers/polynomials/stack/test_poly_calc.c | 28 +++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/analyzers/polynomials/stack/test_poly_calc.c b/analyzers/polynomials/stack/test_poly_calc.c index e11761d..e58463c 100644 --- a/analyzers/polynomials/stack/test_poly_calc.c +++ b/analyzers/polynomials/stack/test_poly_calc.c @@ -16,6 +16,31 @@ int main() { return 0; } +void test6() { + printf("TEST 6: MUL POLY AND UINT\n"); + // (-6x^4+3x+1)*10 = -60x^4+30x^1+10 + + Polynomial p1, p2; + init_polynomial(&p1); + add_term(&p1, 1, 0); + add_term(&p1, -6, 4); + add_term(&p1, 3, 1); + // Целое число так же представляю в виде полинома + init_polynomial(&p2); + add_term(&p2, 10, 0); + Polynomial res = mul_polynomials(&p1, &p2); + sort_polynomial(&res); + + printf("EXPECTED:\n-60x^4+30x^1+10\n"); + printf("OUTPUT:\n"); + print_polynomial(&res); + + free_polynomial(&p1); + free_polynomial(&p2); + free_polynomial(&res); + +} + void test5() { printf("TEST 5: UINT DEGREE\n"); // (-6x^4+3x+1)^5 = -7776x^20+19440x^17+6480x^16-19440x^14-12960x^13-2160x^12+9720x^11+9720x^10+3240x^9-2070x^8-3240x^7-1620x^6-117x^5+375x^4+270x^3+90x^2+15x^1+1 @@ -141,5 +166,6 @@ void tests() { test2(); printf("\n\n"); test3(); printf("\n\n"); test4(); printf("\n\n"); - test5(); + test5(); printf("\n\n"); + test6(); } \ No newline at end of file