Skip to content

Commit 125ed51

Browse files
author
balesh2
committed
tests >= and <=
1 parent c727d59 commit 125ed51

File tree

1 file changed

+160
-7
lines changed

1 file changed

+160
-7
lines changed

math.cpp

Lines changed: 160 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -256,13 +256,6 @@ int main() {
256256
}
257257
printf("\n");
258258

259-
printf("testing sumdigits()\n");
260-
c = 123456789;
261-
b = c.sumdigits();
262-
printf("expected: %d, actual: ", 45);
263-
b.print();
264-
printf("\n");
265-
266259
printf("testing <:\n");
267260
c = 4;
268261
b = 3;
@@ -348,7 +341,167 @@ int main() {
348341
} else {
349342
printf("expected: 0, actual: 0\n");
350343
}
344+
printf("\n");
345+
346+
printf("Testing >=:\n");
347+
b = 4;
348+
if(b >= 5) {
349+
printf("expected: 0, actual: 1\n");
350+
} else {
351+
printf("expected: 0, actual: 0\n");
352+
}
353+
354+
if(b >= (long)5) {
355+
printf("expected: 0, actual: 1\n");
356+
} else {
357+
printf("expected: 0, actual: 0\n");
358+
}
359+
360+
if(b >= "5") {
361+
printf("expected: 0, actual: 1\n");
362+
} else {
363+
printf("expected: 0, actual: 0\n");
364+
}
365+
366+
c = 5;
367+
if(b >= c) {
368+
printf("expected: 0, actual: 1\n");
369+
} else {
370+
printf("expected: 0, actual: 0\n");
371+
}
372+
373+
if(b >= 4) {
374+
printf("expected: 1, actual: 1\n");
375+
} else {
376+
printf("expected: 1, actual: 0\n");
377+
}
378+
379+
if(b >= (long)4) {
380+
printf("expected: 1, actual: 1\n");
381+
} else {
382+
printf("expected: 1, actual: 0\n");
383+
}
384+
385+
if(b >= "4") {
386+
printf("expected: 1, actual: 1\n");
387+
} else {
388+
printf("expected: 1, actual: 0\n");
389+
}
351390

391+
if(b >= b) {
392+
printf("expected: 1, actual: 1\n");
393+
} else {
394+
printf("expected: 1, actual: 0\n");
395+
}
396+
397+
c = 3;
398+
if(b >= 3) {
399+
printf("expected: 1, actual: 1\n");
400+
} else {
401+
printf("expected: 1, actual: 0\n");
402+
}
403+
404+
if(b >= (long)3) {
405+
printf("expected: 1, actual: 1\n");
406+
} else {
407+
printf("expected: 1, actual: 0\n");
408+
}
409+
410+
if(b >= "3") {
411+
printf("expected: 1, actual: 1\n");
412+
} else {
413+
printf("expected: 1, actual: 0\n");
414+
}
415+
416+
if(b >= c) {
417+
printf("expected: 1, actual: 1\n");
418+
} else {
419+
printf("expected: 1, actual: 0\n");
420+
}
421+
printf("\n");
422+
423+
printf("Testing <=:\n");
424+
if(b <= 3) {
425+
printf("expected: 0, actual: 1\n");
426+
} else {
427+
printf("expected: 0, actual: 0\n");
428+
}
429+
430+
if(b <= (long)3) {
431+
printf("expected: 0, actual: 1\n");
432+
} else {
433+
printf("expected: 0, actual: 0\n");
434+
}
435+
436+
if(b <= "3") {
437+
printf("expected: 0, actual: 1\n");
438+
} else {
439+
printf("expected: 0, actual: 0\n");
440+
}
441+
442+
c = 3;
443+
if(b <= c) {
444+
printf("expected: 0, actual: 1\n");
445+
} else {
446+
printf("expected: 0, actual: 0\n");
447+
}
448+
449+
if(b <= 4) {
450+
printf("expected: 1, actual: 1\n");
451+
} else {
452+
printf("expected: 1, actual: 0\n");
453+
}
454+
455+
if(b <= (long)4) {
456+
printf("expected: 1, actual: 1\n");
457+
} else {
458+
printf("expected: 1, actual: 0\n");
459+
}
460+
461+
if(b <= "4") {
462+
printf("expected: 1, actual: 1\n");
463+
} else {
464+
printf("expected: 1, actual: 0\n");
465+
}
466+
467+
c = 4;
468+
if(b <= c) {
469+
printf("expected: 1, actual: 1\n");
470+
} else {
471+
printf("expected: 1, actual: 0\n");
472+
}
473+
474+
if(b <= 5) {
475+
printf("expected: 1, actual: 1\n");
476+
} else {
477+
printf("expected: 1, actual: 0\n");
478+
}
479+
480+
if(b <= (long)5) {
481+
printf("expected: 1, actual: 1\n");
482+
} else {
483+
printf("expected: 1, actual: 0\n");
484+
}
485+
486+
if(b <= "5") {
487+
printf("expected: 1, actual: 1\n");
488+
} else {
489+
printf("expected: 1, actual: 0\n");
490+
}
491+
492+
c = 5;
493+
if(b <= c) {
494+
printf("expected: 1, actual: 1\n");
495+
} else {
496+
printf("expected: 1, actual: 0\n");
497+
}
498+
printf("\n");
499+
500+
printf("testing sumdigits()\n");
501+
c = 123456789;
502+
b = c.sumdigits();
503+
printf("expected: %d, actual: ", 45);
504+
b.print();
352505
printf("\n");
353506

354507
printf("testing proddigits()\n");

0 commit comments

Comments
 (0)