Skip to content

Commit

Permalink
Add divide test to main test file
Browse files Browse the repository at this point in the history
A new test was added to tests/main.c to verify the functionality of the division operation in the Oasis library. This includes creating a division expression, simplifying it, and comparing the result to an expected value as well as ensuring memory cleanup for the divideResult.
  • Loading branch information
matthew-mccall committed Jul 12, 2024
1 parent 8c18818 commit ce32e7f
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions tests/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "Oasis/Add.h"
#include "Oasis/Subtract.h"
#include "Oasis/Multiply.h"
#include "Oasis/Divide.h"
#include "Oasis/Real.h"

int main()
Expand All @@ -29,9 +30,15 @@ int main()

munit_assert_float(Oa_GetValueFromReal(multiplyResult), ==, 6);

struct Oa_Expression* divide = Oa_CreateDivideNF(real1, real2);
struct Oa_Expression* divideResult = Oa_Simplify(divide);

munit_assert_double_equal(Oa_GetValueFromReal(divideResult), 0.667, 3);

Oa_Free(real1);
Oa_Free(real2);
Oa_Free(addResult);
Oa_Free(subtractResult);
Oa_Free(multiplyResult);
Oa_Free(divideResult);
}

0 comments on commit ce32e7f

Please sign in to comment.