Skip to content
This repository has been archived by the owner on Oct 28, 2021. It is now read-only.

Commit

Permalink
push last tests
Browse files Browse the repository at this point in the history
  • Loading branch information
HelifeWasTaken committed Oct 28, 2020
1 parent 20fcaf3 commit f352d10
Showing 1 changed file with 47 additions and 22 deletions.
69 changes: 47 additions & 22 deletions tests/evalexpr/test_eval_expr.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,112 +8,137 @@

char *eval_expr(char const *str);

Test (eval_expr, one)
Test(eval_expr, one)
{
cr_expect_str_eq(eval_expr("1"), "1");
}

Test (eval_expr, minus_one)
Test(eval_expr, minus_one)
{
cr_expect_str_eq(eval_expr("-1"), "-1");
}

Test (eval_expr, one_plus_one)
Test(eval_expr, one_plus_one)
{
cr_expect_str_eq(eval_expr("1+1"), "2");
}

Test (eval_expr, zero_plus_one)
Test(eval_expr, zero_plus_one)
{
cr_expect_str_eq(eval_expr("0+1"), "1");
}

Test (eval_expr, zero_minus_one)
Test(eval_expr, zero_minus_one)
{
cr_expect_str_eq(eval_expr("0-1"), "-1");
}

Test (eval_expr, one_minus_minus_one)
Test(eval_expr, one_minus_minus_one)
{
cr_expect_str_eq(eval_expr("1--1"), "2");
}

Test (eval_expr, two_times_brackets)
Test(eval_expr, two_times_brackets)
{
cr_expect_str_eq(eval_expr("2*(1+1)"), "4");
}

Test (eval_expr, brackets_times_two)
Test(eval_expr, brackets_times_two)
{
cr_expect_str_eq(eval_expr("(1+1)*2"), "4");
}

Test (eval_expr, brackets_times_brackets)
Test(eval_expr, brackets_times_brackets)
{
cr_expect_str_eq(eval_expr("(1+1)*(1+1)"), "4");
}

Test (eval_expr, one_plus_multiplication)
Test(eval_expr, one_plus_multiplication)
{
cr_expect_str_eq(eval_expr("1+24*3"), "73");
}

Test (eval_expr, multiplication_redivided)
Test(eval_expr, multiplication_redivided)
{
cr_expect_str_eq(eval_expr("2*3/2"), "3");
}

Test (eval_expr, brackets_one)
Test(eval_expr, brackets_one)
{
cr_expect_str_eq(eval_expr("(1)"), "1");
}

Test (eval_expr, minus_brackets)
Test(eval_expr, minus_brackets)
{
cr_expect_str_eq(eval_expr("-(1)"), "-1");
}

Test (eval_expr, one_plus_brackets_times_three)
Test(eval_expr, one_plus_brackets_times_three)
{
cr_expect_str_eq(eval_expr("1+(2)*3"), "7");
}

Test (eval_expr, brackets_one_plus_one)
Test(eval_expr, brackets_one_plus_one)
{
cr_expect_str_eq(eval_expr("(1+1)"), "2");
}

Test (eval_expr, brackets_multiplication_redivided)
Test(eval_expr, brackets_multiplication_redivided)
{
cr_expect_str_eq(eval_expr("(1+24*3)"), "73");
}

Test (eval_expr, multi_brackets_one)
Test(eval_expr, multi_brackets_one)
{
cr_expect_str_eq(eval_expr("((1))"), "1");
}

Test (eval_expr, multi_brackets_one_plus_one)
Test(eval_expr, multi_brackets_one_plus_one)
{
cr_expect_str_eq(eval_expr("((1+1))"), "2");
}

Test (eval_expr, multi_brackets_multiplication_redivided)
Test(eval_expr, multi_brackets_multiplication_redivided)
{
cr_expect_str_eq(eval_expr("((1+24*3))"), "73");
}

Test (eval_expr, bracket_times_bracket_in_a_bracket)
Test(eval_expr, bracket_times_bracket_in_a_bracket)
{
cr_expect_str_eq(eval_expr("((1+1)*(2-1))"), "2");
}

Test (eval_expr, unbalanced_brackets)
Test(eval_expr, unbalanced_brackets)
{
cr_expect_str_eq(eval_expr("(1"), "0");
}

Test (eval_expr, four_divided_by_bracket_plus_two)
Test(eval_expr, four_divided_by_bracket_plus_two)
{
cr_expect_str_eq(eval_expr("4/(2)+2"), "4");
}

Test(eval_expr, help_me_please)
{
cr_expect_str_eq(eval_expr("798*12+74/2+(8*4)"), "9645");
}

Test(eval_expr, help_me_please_v2)
{
cr_expect_str_eq(eval_expr("798*12+74/2+(8*4)+89*2/47+123*(46-54)"), "8664");
}

Test(eval_expr, simpleOB_arith)
{
cr_expect_str_eq(eval_expr("789/58*2+78"), "104");
}

Test(eval_expr, division_same)
{
cr_expect_str_eq(eval_expr("44444444444/4444444444"), "10");
}

Test(eval_expr, destruction_overkill)
{
cr_expect_str_eq(eval_expr("798456*123/100+45*(12-789+78*41-13+(46*78-12))+103/2"), "1251431");
}

0 comments on commit f352d10

Please sign in to comment.