Created
March 20, 2011 05:00
-
-
Save deepthawtz/878090 to your computer and use it in GitHub Desktop.
some school stuff
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // ************************************************************************** | |
| // * Author: Dylan Clendenin * | |
| // ************************************************************************** | |
| #include <iostream> | |
| #include <cassert> | |
| using namespace std; | |
| #include "Rational.h" | |
| int main() | |
| { | |
| Rational c(1,3), d(7,8), x; | |
| // addition() | |
| x = c.addition(d); | |
| Rational addition_result(29,24); | |
| assert(x == addition_result); | |
| // since assert will call abort() if it fails, this next line prints only if the above assertion passes | |
| // the funky chars in that string will output as green in the console (don't know bout Windows though) | |
| cout << "\e[1;32m...addition() passed\e[0m" << endl; | |
| // subtraction() | |
| x = c.subtraction(d); | |
| Rational subtraction_result(-13,24); | |
| assert(x == subtraction_result); | |
| cout << "\e[1;32m...subtraction() passed\e[0m" << endl; | |
| // multiplication() | |
| x = c.multiplication(d); | |
| Rational multiplication_result(7,24); | |
| assert(x == multiplication_result); | |
| cout << "\e[1;32m...multiplication() passed\e[0m" << endl; | |
| // division() | |
| x = c.division(d); | |
| Rational division_result(8,21); | |
| assert(x == division_result); | |
| cout << "\e[1;32m...division() passed\e[0m" << endl; | |
| return 0; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment