summaryrefslogtreecommitdiff
path: root/src/main.cpp
diff options
context:
space:
mode:
authorMike Buland <mike@xagasoft.com>2013-04-16 10:50:07 -0600
committerMike Buland <mike@xagasoft.com>2013-04-16 10:50:07 -0600
commit25989c6d3911b1d29a5866e668bff52537893afb (patch)
treedd07375016a8a3836605cf4e2d9eca829193693f /src/main.cpp
parent44542adf023315d60a8ffc4863f2b161b3c1eb90 (diff)
downloadclic-25989c6d3911b1d29a5866e668bff52537893afb.tar.gz
clic-25989c6d3911b1d29a5866e668bff52537893afb.tar.bz2
clic-25989c6d3911b1d29a5866e668bff52537893afb.tar.xz
clic-25989c6d3911b1d29a5866e668bff52537893afb.zip
Added operators: -, ==, !=, <, >, <=, >=
Still working on division, needed some other operators to make it work.
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp79
1 files changed, 77 insertions, 2 deletions
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()
149 arg( a.toString() ). 149 arg( a.toString() ).
150 arg( b.toString() ). 150 arg( b.toString() ).
151 arg( (a * b).toString() ); 151 arg( (a * b).toString() );
152
153 a = "123";
154 b = "45";
155
156 println("%1 / %2 = %3").
157 arg( a.toString() ).
158 arg( b.toString() ).
159 arg( (a / b).toString() );
160}
161
162#define compcheck( anum, op, bnum ) \
163 a = #anum; b = #bnum; \
164 println("%4: %1 " #op " %2 = %3").arg( a.toString() ).arg( b.toString() ). \
165 arg( a op b ).arg( ((a op b) == (anum op bnum)) ? "pass" : "fail" )
166
167void numbertestcomp()
168{
169 Number a, b;
170
171 println("-==- Greater Than -==-");
172 compcheck( 5, >, 10 );
173 compcheck( 10, >, 5 );
174 compcheck( 5, >, 5 );
175 compcheck( 7, >, 5 );
176 compcheck( 5, >, 7 );
177 compcheck( 123, >, 122 );
178 compcheck( 123, >, 123 );
179 compcheck( 123, >, 124 );
180 compcheck( -123, >, 122 );
181 compcheck( -123, >, -122 );
182 compcheck( -122, >, -123 );
183 compcheck( 123, >, -122 );
184
185 println("-==- Less Than -==-");
186 compcheck( 5, <, 10 );
187 compcheck( 10, <, 5 );
188 compcheck( 5, <, 5 );
189 compcheck( 7, <, 5 );
190 compcheck( 5, <, 7 );
191 compcheck( 123, <, 122 );
192 compcheck( 123, <, 123 );
193 compcheck( 123, <, 124 );
194 compcheck( -123, <, 122 );
195 compcheck( -123, <, -122 );
196 compcheck( -122, <, -123 );
197 compcheck( 123, <, -122 );
198
199 println("-==- Greater Than or Equal To -==-");
200 compcheck( 5, >=, 10 );
201 compcheck( 10, >=, 5 );
202 compcheck( 5, >=, 5 );
203 compcheck( 7, >=, 5 );
204 compcheck( 5, >=, 7 );
205 compcheck( 123, >=, 122 );
206 compcheck( 123, >=, 123 );
207 compcheck( 123, >=, 124 );
208 compcheck( -123, >=, 122 );
209 compcheck( -123, >=, -122 );
210 compcheck( -122, >=, -123 );
211 compcheck( 123, >=, -122 );
212
213 println("-==- Less Than or Equal To -==-");
214 compcheck( 5, <=, 10 );
215 compcheck( 10, <=, 5 );
216 compcheck( 5, <=, 5 );
217 compcheck( 7, <=, 5 );
218 compcheck( 5, <=, 7 );
219 compcheck( 123, <=, 122 );
220 compcheck( 123, <=, 123 );
221 compcheck( 123, <=, 124 );
222 compcheck( -123, <=, 122 );
223 compcheck( -123, <=, -122 );
224 compcheck( -122, <=, -123 );
225 compcheck( 123, <=, -122 );
152} 226}
153 227
154int main( int argc, char *argv[] ) 228int main( int , char *[] )
155{ 229{
156 println("CliC"); 230 println("CliC");
157 231
158// packedtest1(); 232// packedtest1();
159 numbertest1(); 233// numbertest1();
234 numbertestcomp();
160 235
161 return 0; 236 return 0;
162} 237}