Skip to content

Commit 4eb78c5

Browse files
added tests for CPP_RN
1 parent 73eecc3 commit 4eb78c5

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

cpp4j/testCPP_RN.cpp

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,28 +8,32 @@ using namespace rnum;
88

99
void testCPP_RN(void)
1010
{
11-
printf("Performing unit tests for RationalNumberArray...");
11+
printf("Performing unit tests for CPP_RationalNumber...");
1212
fflush(stdout);
1313

1414

1515
CPP_RationalNumber a, x;
1616
CPP_RationalNumber b(0,1), c(2,3), d(9,3), e(-4,2), f(17,3);
17+
1718
a = b + c*d - e/f;
18-
x = -f + CPP_RationalNumber(3,4);
19-
a.toString();
2019
assert( a == CPP_RationalNumber( 40 , 17 ));
21-
assert( x == CPP_RationalNumber( -59 , 12 ));
2220

21+
x = -f + CPP_RationalNumber(3,4);
22+
assert( x == CPP_RationalNumber( -59 , 12 ));
2323

2424

2525
int i=5, j=4;
2626
CPP_RationalNumber g(1,2), h(7,3);
27-
CPP_RationalNumber aa = g*i, bb = h/j;
28-
CPP_RationalNumber ia (i);
29-
CPP_RationalNumber ja = j;
3027

28+
CPP_RationalNumber aa = g*i, bb = h/j;
29+
assert(aa==CPP_RationalNumber( 5 , 2 ));
30+
assert(bb==CPP_RationalNumber( 7 , 12 ));
3131

32+
CPP_RationalNumber ia (i);
33+
assert(ia==CPP_RationalNumber( 5 , 1 ));
3234

35+
CPP_RationalNumber ja = j;
36+
assert(ja==CPP_RationalNumber( 4 , 1 ));
3337

3438
printf(" successful!\n");
3539
}

0 commit comments

Comments
 (0)