added two new functions Nor and Nand
bool Or(bool a, bool b) { return a+b; } bool And(bool a, bool b) { return a*b; } bool Xor(bool a, bool b) { return a!=b; } bool Nor(bool a, bool b) { return !(a+b); } bool Nand(bool a, bool b) { return !(a*b); }
- bool Or(bool a, bool b) {
- return a+b;
- }
- bool And(bool a, bool b) {
- return a*b;
- }
- bool Xor(bool a, bool b) {
- return a!=b;
- }
- bool Nor(bool a, bool b) {
- return !(a+b);
- }
- bool Nand(bool a, bool b) {
- return !(a*b);
- }
// TODO: Replace examples and use TDD development by writing your own tests Describe(AND_OR_XOR) { It(AND) { Assert::That(And(true, false), Equals(false)); Assert::That(And(false, true), Equals(false)); Assert::That(And(true, true), Equals(true)); Assert::That(And(false, false), Equals(false)); } It(OR) { Assert::That(Or(true, false), Equals(true)); Assert::That(Or(false, true), Equals(true)); Assert::That(Or(true, true), Equals(true)); Assert::That(Or(false, false), Equals(false)); } It(XOR) { Assert::That(Xor(true, false), Equals(true)); Assert::That(Xor(false, true), Equals(true)); Assert::That(Xor(true, true), Equals(false)); Assert::That(Xor(false, false), Equals(false)); } It(NOR) { Assert::That(Nor(true, false), Equals(false)); Assert::That(Nor(false, true), Equals(false)); Assert::That(Nor(true, true), Equals(false)); Assert::That(Nor(false, false), Equals(true)); } It(NAND) { Assert::That(Nand(true, false), Equals(true)); Assert::That(Nand(false, true), Equals(true)); Assert::That(Nand(true, true), Equals(false)); Assert::That(Nand(false, false), Equals(true)); } };
- // TODO: Replace examples and use TDD development by writing your own tests
- Describe(AND_OR_XOR)
- {
- It(AND)
- {
- Assert::That(And(true, false), Equals(false));
- Assert::That(And(false, true), Equals(false));
- Assert::That(And(true, true), Equals(true));
- Assert::That(And(false, false), Equals(false));
- }
- It(OR)
- {
- Assert::That(Or(true, false), Equals(true));
- Assert::That(Or(false, true), Equals(true));
- Assert::That(Or(true, true), Equals(true));
- Assert::That(Or(false, false), Equals(false));
- }
- It(XOR)
- {
- Assert::That(Xor(true, false), Equals(true));
- Assert::That(Xor(false, true), Equals(true));
- Assert::That(Xor(true, true), Equals(false));
- Assert::That(Xor(false, false), Equals(false));
- }
- It(NOR)
- {
- Assert::That(Nor(true, false), Equals(false));
- Assert::That(Nor(false, true), Equals(false));
- Assert::That(Nor(true, true), Equals(false));
- Assert::That(Nor(false, false), Equals(true));
- }
- It(NAND)
- {
- Assert::That(Nand(true, false), Equals(true));
- Assert::That(Nand(false, true), Equals(true));
- Assert::That(Nand(true, true), Equals(false));
- Assert::That(Nand(false, false), Equals(true));
- }
- };