chickenhouse/tests/unittests/test_data_buffer.py
Thomas Klaehn 4646c7d7a6 project: reorder
Signed-off-by: Thomas Klaehn <thomas.klaehn@u-blox.com>
2018-08-27 11:26:31 +02:00

30 lines
781 B
Python

'''
Created on Dec 19, 2016
@author: klaehn
'''
import unittest
import random
import gate_guard.data_buffer
class Test(unittest.TestCase):
def test_zero_space(self):
dut = gate_guard.data_buffer.DataBuffer(0)
result = dut.push(10)
self.assertFalse(result, "test_zero_space - exp: False res: True")
def test_max_data(self):
buffer_size = 10
dut = gate_guard.data_buffer.DataBuffer(buffer_size)
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()