Added new tests for different resolutions of time

This commit is contained in:
2019-01-24 15:39:17 -05:00
parent d31fd9ea27
commit c40ca4399a

View File

@@ -6,24 +6,42 @@
from Stopwatch import Stopwatch
#Start of the tests
timer = Stopwatch()
print("BEGIN TEST\n")
#Tests that should cause faults
print("Trying to print the time before it has been started:")
print(str(timer.getTime()))
timer.stop()
print("Trying to print the time after stop was called, but before start was")
print("Trying to print the time after stop was called, but before start was:")
print(str(timer.getTime()))
timer.start()
print("Trying to print the time after it was started but before it was stopped:")
print(str(timer.getTime()))
cnt = 0
print("Entering loop:")
while(cnt < 1000):
print(cnt)
#A loop just to eat up time
print("\n\nEntering loop")
while(cnt < 10000):
#print(cnt)
cnt = cnt + 1
print("Exiting loop")
print("Exiting loop\n")
timer.stop()
print("Trying to print time after it was finished")
#Get the correct ending to the test
print("Trying to print time after it was finished:")
print(str(timer.getTime()))
print("\n")
#Test the different time resolutions
print("Print times in specific resolutions:")
print('{:08.6f}'.format(timer.getSeconds()) + " seconds")
print(str(timer.getMilliseconds()) + " milliseconds")
print(str(timer.getMicroseconds()) + " microseconds")
print(str(timer.getNanoseconds()) + " nanoseconds")
#Test end
print("\nEND OF TEST")
"""Results: