From 25989c6d3911b1d29a5866e668bff52537893afb Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Tue, 16 Apr 2013 10:50:07 -0600 Subject: Added operators: -, ==, !=, <, >, <=, >= Still working on division, needed some other operators to make it work. --- src/main.cpp | 79 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 77 insertions(+), 2 deletions(-) (limited to 'src/main.cpp') diff --git a/src/main.cpp b/src/main.cpp index d78bfc3..3678278 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -149,14 +149,89 @@ void numbertest1() arg( a.toString() ). arg( b.toString() ). arg( (a * b).toString() ); + + a = "123"; + b = "45"; + + println("%1 / %2 = %3"). + arg( a.toString() ). + arg( b.toString() ). + arg( (a / b).toString() ); +} + +#define compcheck( anum, op, bnum ) \ + a = #anum; b = #bnum; \ + println("%4: %1 " #op " %2 = %3").arg( a.toString() ).arg( b.toString() ). \ + arg( a op b ).arg( ((a op b) == (anum op bnum)) ? "pass" : "fail" ) + +void numbertestcomp() +{ + Number a, b; + + println("-==- Greater Than -==-"); + compcheck( 5, >, 10 ); + compcheck( 10, >, 5 ); + compcheck( 5, >, 5 ); + compcheck( 7, >, 5 ); + compcheck( 5, >, 7 ); + compcheck( 123, >, 122 ); + compcheck( 123, >, 123 ); + compcheck( 123, >, 124 ); + compcheck( -123, >, 122 ); + compcheck( -123, >, -122 ); + compcheck( -122, >, -123 ); + compcheck( 123, >, -122 ); + + println("-==- Less Than -==-"); + compcheck( 5, <, 10 ); + compcheck( 10, <, 5 ); + compcheck( 5, <, 5 ); + compcheck( 7, <, 5 ); + compcheck( 5, <, 7 ); + compcheck( 123, <, 122 ); + compcheck( 123, <, 123 ); + compcheck( 123, <, 124 ); + compcheck( -123, <, 122 ); + compcheck( -123, <, -122 ); + compcheck( -122, <, -123 ); + compcheck( 123, <, -122 ); + + println("-==- Greater Than or Equal To -==-"); + compcheck( 5, >=, 10 ); + compcheck( 10, >=, 5 ); + compcheck( 5, >=, 5 ); + compcheck( 7, >=, 5 ); + compcheck( 5, >=, 7 ); + compcheck( 123, >=, 122 ); + compcheck( 123, >=, 123 ); + compcheck( 123, >=, 124 ); + compcheck( -123, >=, 122 ); + compcheck( -123, >=, -122 ); + compcheck( -122, >=, -123 ); + compcheck( 123, >=, -122 ); + + println("-==- Less Than or Equal To -==-"); + compcheck( 5, <=, 10 ); + compcheck( 10, <=, 5 ); + compcheck( 5, <=, 5 ); + compcheck( 7, <=, 5 ); + compcheck( 5, <=, 7 ); + compcheck( 123, <=, 122 ); + compcheck( 123, <=, 123 ); + compcheck( 123, <=, 124 ); + compcheck( -123, <=, 122 ); + compcheck( -123, <=, -122 ); + compcheck( -122, <=, -123 ); + compcheck( 123, <=, -122 ); } -int main( int argc, char *argv[] ) +int main( int , char *[] ) { println("CliC"); // packedtest1(); - numbertest1(); +// numbertest1(); + numbertestcomp(); return 0; } -- cgit v1.2.3