Assume you need to test a function named inOrder. The function inOrder receives three int arguments and returns true if and only if the arguments are in non-decreasing order: that is, the second argument is not less than the first and the third is not less than the second. Write the definition of driver function testInOrder whose job it is to determine whether inOrder is correct. So testInOrder returns true if inOrder is correct and returns false otherwise.

LANGUAGE: C++

CHALLENGE:

Assume you need to test a function named inOrder. The function inOrder receives three int arguments and returns true if and only if the arguments are in non-decreasing order: that is, the second argument is not less than the first and the third is not less than the second. Write the definition of driver function testInOrder whose job it is to determine whether inOrder is correct. So testInOrder returns true if inOrder is correct and returns false otherwise.

SOLUTION:


bool testInOrder(){
   if (inOrder(0,1,2) == false) return false;
   if (inOrder(1,1,1) == false) return false;
   if (inOrder(1,2,1) == true) return false;
   if  (inOrder(2,1,2) == true) return false;
   if (inOrder(2,1,0) == true) return false;
   if (inOrder(1,2,2) == false) return false;
   if (inOrder(3,2,2) == true) return false;
   if (inOrder(1,1,2) == false) return false;
   if (inOrder(2,2,1) == true) return true;
   if (inOrder(1,2,2) == false) return false;
   return true;
}