Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cassert>
- struct date{
- int day;
- int month;
- int year;
- };
- //method stub for getDate
- struct date getDate(){
- //creates an empty date object
- struct date theDate;
- theDate.day = 1;
- theDate.month = 1;
- theDate.year = 2001;
- return theDate;
- }
- //method stub for validDate
- bool validDate(struct date theDate){
- return false;
- }
- //driver for getDate
- void testGetDate(){
- std::cout << "Entering tests for getDate()" << std::endl;
- //get the date
- struct date testDate = getDate();
- //boundary value tests for day
- assert(testDate.day > 0);
- assert(testDate.day < 31);
- std::cout << "All boundary value tests for day pass" << std::endl;;
- //boundary value tests for month
- assert(testDate.month > 0);
- assert(testDate.month < 12);
- std::cout << "All boundary value tests for month pass" << std::endl;
- //boundary value tests for year;
- assert(testDate.year > 1811);
- assert(testDate.year < 2012);
- std::cout << "All boundary value tests for year pass" << std::endl;
- }
- //driver for validDate
- void testValidDate(){
- std::cout << "Entering tests for validDate()" << std::endl;
- struct date invalidDay;
- invalidDay.day = 0;
- invalidDay.month = 1;
- invalidDay.year = 2013;
- assert(validDate(invalidDay) == false);
- std::cout << "Test for invalid day passed" << std::endl;;
- struct date invalidMonth;
- invalidMonth.day = 1;
- invalidMonth.month = 0;
- invalidMonth.year = 2013;
- assert(validDate(invalidMonth) == false);
- std::cout << "Test for invalid month passed" << std::endl;;
- struct date invalidYear;
- invalidYear.year = 0;
- invalidYear.day = 1;
- invalidYear.month = 1;
- assert(validDate(invalidYear) == false);
- std::cout << "Test for invalid year passed" << std::endl;;
- struct date dateValidDayMonthYear;
- dateValidDayMonthYear.day = 1;
- dateValidDayMonthYear.month = 1;
- dateValidDayMonthYear.year = 2012;
- assert(validDate(dateValidDayMonthYear) == true);
- std::cout << "Test for valid date passed" << std::endl;; //because method stub always returns false, assertion should not pass
- }
- int main() {
- std::cout << "CS490 Chapter 13 Driver" << std::endl;
- std::cout << "By Kyle Peeler" << std::endl << std::endl;
- testGetDate();
- testValidDate();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement