I'm creating functional tests to my program, but for some reason when I wrote system1->getValue() - 36.6033
I got a crazy number like -6.58727e-005
. I've done some debbuging and system1->getValue()
is returning 36.6032
, but the subtraction isn't resulting in 0.0001
.
Here is the code:
void exponentialFunctionalTest(){
Model* model = new Model("Exponential test");
System* system1 = new System("System 1", 100);
System* system2 = new System("System 2", 0);
Exponential* exponential = new Exponential("Exponential", system1, system2);
model->add(system1);
model->add(system2);
model->add(exponential);
model->run(0, 100, 1);
assert(abs(system1->getValue() - 36.6032) < 0.0001);
assert(abs(system2->getValue() - 63.3968) < 0.0001);
delete model;
}
In this program I have two systems, one has a variable value that starts with 100
and the other 0
. Also, I have an exponential flow that will affect both system's values 100 times. The first system is returning 36.6032
at the end, as it should be, but when I try to use the assert()
function like my teacher taught me, it isn't working, it keeps passing the test that is suppose to fail.