2016-12-19 15:38:30 +00:00
|
|
|
'''
|
|
|
|
Created on Dec 19, 2016
|
|
|
|
|
|
|
|
@author: klaehn
|
|
|
|
'''
|
2017-03-30 12:09:49 +00:00
|
|
|
import sys
|
|
|
|
sys.path.append('source/')
|
2016-12-19 15:38:30 +00:00
|
|
|
import unittest
|
|
|
|
import random
|
2017-03-30 12:09:49 +00:00
|
|
|
import data_buffer
|
2016-12-19 15:38:30 +00:00
|
|
|
|
|
|
|
|
|
|
|
class Test(unittest.TestCase):
|
|
|
|
|
|
|
|
|
|
|
|
def test_zero_space(self):
|
2017-03-30 12:09:49 +00:00
|
|
|
dut = data_buffer.DataBuffer(0)
|
2016-12-19 15:38:30 +00:00
|
|
|
result = dut.push(10)
|
|
|
|
self.assertFalse(result, "test_zero_space - exp: False res: True")
|
|
|
|
|
|
|
|
def test_max_data(self):
|
|
|
|
buffer_size = 10
|
2017-03-30 12:09:49 +00:00
|
|
|
dut = data_buffer.DataBuffer(buffer_size)
|
2016-12-19 15:38:30 +00:00
|
|
|
for _ in range(11):
|
|
|
|
dut.push(random.random())
|
|
|
|
result = dut.length()
|
|
|
|
self.assertEqual(result, buffer_size, "test_max_data - exp: " + \
|
|
|
|
str(buffer_size) + " res: " + str(result))
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
#import sys;sys.argv = ['', 'Test.testName']
|
|
|
|
unittest.main()
|