class TestBaseWindow(unittest.TestCase): def setUp(self): self.w = BaseWindow(4) def test_is_valid_seq_negative(self): self.assertFalse(self.w.is_valid_seq(-1)) def test_is_valid_seq_too_large(self): self.assertFalse(self.w.is_valid_seq(15)) def test_is_valid_seq(self): self.assertTrue(self.w.is_valid_seq(0))
class TestBaseWindowIsValidSeq16(unittest.TestCase): def setUp(self): self.w = BaseWindow(16) def test_negative(self): self.assertFalse(self.w.is_valid_seq(-1)) def test_first_valid(self): self.assertTrue(self.w.is_valid_seq(0)) def test_last_valid(self): self.assertTrue(self.w.is_valid_seq(65535)) def test_too_large(self): self.assertFalse(self.w.is_valid_seq(65536)) def test_too_large2(self): self.assertFalse(self.w.is_valid_seq(100000))
def test_create_1(self): w = BaseWindow(1) self.assertEqual(w.size, 1) self.assertEqual(w.expected_seq, 0) self.assertEqual(w.max_seq, 2)
def setUp(self): self.w = BaseWindow(16)
def test_create_limited_invalid2(self): with self.assertRaises(ValueError): BaseWindow(3, size=10)
def test_create_invalid2(self): with self.assertRaises(ValueError): BaseWindow(0)
def test_create_4_limited(self): w = BaseWindow(4, size=8) self.assertEqual(w.size, 8) self.assertEqual(w.expected_seq, 0) self.assertEqual(w.max_seq, 16)
def test_create(self): w = BaseWindow(4) self.assertEqual(w.size, 8) self.assertEqual(w.expected_seq, 1) self.assertEqual(w.last_seq, 0) self.assertEqual(w.max_seq, 15)