mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-18 21:30:38 +01:00
Added some basic tests for the AST members.
Change-Id: I9a1f297fb72a57e9b58e3951c22066134c8da9ea
This commit is contained in:
@@ -19,8 +19,11 @@ objs += $(addprefix poincare/src/layout/,\
|
||||
exponent_layout.o\
|
||||
string_layout.o)
|
||||
tests += $(addprefix poincare/test/,\
|
||||
addition.cpp\
|
||||
fraction.cpp\
|
||||
integer.cpp\
|
||||
product.cpp)
|
||||
product.cpp\
|
||||
subtraction.cpp)
|
||||
|
||||
# Even though flex and bison will generate both implementation and headers at
|
||||
# once, we don't declare it in the Makefile. If we did, "make -jN" with N>1 may
|
||||
|
||||
12
poincare/test/addition.cpp
Normal file
12
poincare/test/addition.cpp
Normal file
@@ -0,0 +1,12 @@
|
||||
#include <quiz.h>
|
||||
#include <poincare.h>
|
||||
#include <assert.h>
|
||||
|
||||
QUIZ_CASE(poincare_addition_approximate) {
|
||||
Context context;
|
||||
// Note: these have to be heap allocated.
|
||||
Integer *a = new Integer(1);
|
||||
Integer *b = new Integer(2);
|
||||
assert(Addition(a, b).approximate(context) == 3.0f);
|
||||
}
|
||||
|
||||
12
poincare/test/fraction.cpp
Normal file
12
poincare/test/fraction.cpp
Normal file
@@ -0,0 +1,12 @@
|
||||
#include <quiz.h>
|
||||
#include <poincare.h>
|
||||
#include <assert.h>
|
||||
|
||||
QUIZ_CASE(poincare_fraction_approximate) {
|
||||
Context context;
|
||||
// Note: these have to be heap allocated.
|
||||
Integer *a = new Integer(1);
|
||||
Integer *b = new Integer(2);
|
||||
assert(Fraction(a, b).approximate(context) == 0.5f);
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ QUIZ_CASE(poincare_integer_subtract) {
|
||||
|
||||
QUIZ_CASE(poincare_integer_multiply) {
|
||||
assert(Integer(12) * Integer(34) == Integer(408));
|
||||
//assert(Integer(56) * Integer(0) == Integer(0));
|
||||
assert(Integer(56) * Integer(0) == Integer(0));
|
||||
assert(Integer(-12) * Integer(34) == Integer(-408));
|
||||
assert(Integer(-12) * Integer(-34) == Integer(408));
|
||||
assert(Integer(999999) * Integer(999999) == Integer("999998000001"));
|
||||
|
||||
@@ -2,8 +2,10 @@
|
||||
#include <poincare.h>
|
||||
#include <assert.h>
|
||||
|
||||
QUIZ_CASE(poincare_multiply_approximate) {
|
||||
//Context context;
|
||||
//Integer a(1), b(2);
|
||||
//assert(Product(&a, &b).approximate(context) == 2);
|
||||
QUIZ_CASE(poincare_procuct_approximate) {
|
||||
Context context;
|
||||
// Note: these have to be heap allocated.
|
||||
Integer *a = new Integer(1);
|
||||
Integer *b = new Integer(2);
|
||||
assert(Product(a, b).approximate(context) == 2.0f);
|
||||
}
|
||||
|
||||
11
poincare/test/subtraction.cpp
Normal file
11
poincare/test/subtraction.cpp
Normal file
@@ -0,0 +1,11 @@
|
||||
#include <quiz.h>
|
||||
#include <poincare.h>
|
||||
#include <assert.h>
|
||||
|
||||
QUIZ_CASE(poincare_subtraction_approximate) {
|
||||
Context context;
|
||||
// Note: these have to be heap allocated.
|
||||
Integer *a = new Integer(1);
|
||||
Integer *b = new Integer(2);
|
||||
assert(Subtraction(a, b).approximate(context) == -1.0f);
|
||||
}
|
||||
Reference in New Issue
Block a user