pico-tracker/firmware/test/tc/times_two.py

39 wiersze
1.0 KiB
Python

2014-07-30 19:32:00 +00:00
#!/usr/bin/env python
# ------------------------------------------------------------------------------
# Imports
# ------------------------------------------------------------------------------
import sys
sys.path.append("./test")
import main
2014-07-30 19:32:00 +00:00
from random import randint
2014-07-30 19:32:00 +00:00
# ------------------------------------------------------------------------------
# Test Script
# ------------------------------------------------------------------------------
class times_two_tc:
def __init__(self):
2014-07-30 19:32:00 +00:00
self.name = self.__class__.__name__
self.iterations = 20
2014-07-30 19:32:00 +00:00
def get_test(self):
"""Returns some suitable test parameters"""
params = main.struct_times_two_tc_params()
params.input = randint(0, 10000)
return params
def is_correct(self, params, result, print_info):
"""Returns if a result is correct for the given parameters"""
2014-07-30 19:32:00 +00:00
print_info("%d * 2 = %d"%(params.input, result['result']))
2014-07-30 19:32:00 +00:00
if (params.input * 2 == result['result']):
return True
else:
return False