/** @mainpage CS270 Spring 2015 * \htmlinclude "PA5.html" */ /** @file: main.c * @brief Driver to test functions of number_detective.c (do not modify) * * @details This is a driver program ... fill this in *

* @author ... fill this in * @date ... fill this in */ // Include files #include "logic.h" /** Entry point of the program * @param argc count of arguments, will always be at least 1 * @param argv array of parameters to program argv[0] is the name of * the program, so additional parameters will begin at index 1 * @details If one of the test cases fail then the program will assert. * @return 0 the Linux convention for success. */ int main(int argc, char *argv[]) { // check NOT gate truth table // A NOT(A) // 0 1 // 1 0 printf("===== Testing not_gate =====\n"); assert(not_gate(FALSE) == TRUE); assert(not_gate(TRUE) == FALSE); // check OR gate truth table // A B (A OR B) // 0 0 0 // 0 1 1 // 1 0 1 // 1 1 1 printf("===== Testing or_gate =====\n"); assert(or_gate(FALSE,FALSE) == FALSE); assert(or_gate(FALSE,TRUE) == TRUE); assert(or_gate(TRUE,FALSE) == TRUE); assert(or_gate(TRUE,TRUE) == TRUE); // check RS latch truth table // the order matters so that the saved_bit will be true when expected // S R saved_bit rs_latch(S,R) // FALSE FALSE FALSE will assert in rs_latch // FALSE FALSE TRUE will assert in rs_latch // TRUE FALSE FALSE FALSE // TRUE TRUE FALSE FALSE // FALSE TRUE FALSE TRUE // FALSE TRUE TRUE TRUE // TRUE TRUE TRUE TRUE // TRUE FALSE TRUE FALSE printf("===== Testing rs_latch =====\n"); assert( rs_latch( TRUE, FALSE )==FALSE ); assert( rs_latch( TRUE, TRUE )==FALSE ); assert( rs_latch( FALSE, TRUE )==TRUE ); assert( rs_latch( FALSE, TRUE )==TRUE ); assert( rs_latch( TRUE, TRUE )==TRUE ); assert( rs_latch( TRUE, FALSE )==FALSE ); return 0; }