mirror of
https://bitbucket.org/Mattrixwv/my-classes.git
synced 2025-12-06 18:23:57 -05:00
Added test for new function
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
//myClasses/testStopwatch.cpp
|
//myClasses/testStopwatch.cpp
|
||||||
//Matthew Ellison
|
//Matthew Ellison
|
||||||
// Created: 02-12-19
|
// Created: 02-12-19
|
||||||
//Modified: 02-12-19
|
//Modified: 07-09-20
|
||||||
//This file is a simple test for the Stopwatch class
|
//This file is a simple test for the Stopwatch class
|
||||||
|
|
||||||
|
|
||||||
@@ -73,6 +73,42 @@ int main(){
|
|||||||
std::cout << "Test failed" << std::endl;
|
std::cout << "Test failed" << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Test string function
|
||||||
|
bool failedTimeResolutionTests = false;
|
||||||
|
std::string results = mee::Stopwatch::getStr(1.0);
|
||||||
|
if(results != "1.000 nanoseconds"){
|
||||||
|
failedTimeResolutionTests = true;
|
||||||
|
std::cout << "Failed the nanosecond test" << std::endl;
|
||||||
|
}
|
||||||
|
results = mee::Stopwatch::getStr(1.0e3);
|
||||||
|
if(results != "1.000 microseconds"){
|
||||||
|
failedTimeResolutionTests = true;
|
||||||
|
std::cout << "Failed the microsecond test" << std::endl;
|
||||||
|
}
|
||||||
|
results = mee::Stopwatch::getStr(1.0e6);
|
||||||
|
if(results != "1.000 milliseconds"){
|
||||||
|
failedTimeResolutionTests = true;
|
||||||
|
std::cout << "Failed the millisecond test" << std::endl;
|
||||||
|
}
|
||||||
|
results = mee::Stopwatch::getStr(1.0e9);
|
||||||
|
if(results != "1.000 seconds"){
|
||||||
|
failedTimeResolutionTests = true;
|
||||||
|
std::cout << "Failed the second test" << std::endl;
|
||||||
|
}
|
||||||
|
results = mee::Stopwatch::getStr(1.0e12);
|
||||||
|
if(results != "16.667 minutes"){
|
||||||
|
failedTimeResolutionTests = true;
|
||||||
|
std::cout << "Failed the minute test" << std::endl;
|
||||||
|
}
|
||||||
|
results = mee::Stopwatch::getStr(1.0e13);
|
||||||
|
if(results != "2.778 hours"){
|
||||||
|
failedTimeResolutionTests = true;
|
||||||
|
std::cout << "Failed the hour test" << std::endl;
|
||||||
|
}
|
||||||
|
if(!failedTimeResolutionTests){
|
||||||
|
std::cout << "Passed all string resolution tests" << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user