Added a few tests
This commit is contained in:
parent
a99d7a18d1
commit
c58555d6a9
1 changed files with 29 additions and 0 deletions
29
src/bindings/python/hammer_tests.py
Normal file
29
src/bindings/python/hammer_tests.py
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
import unittest
|
||||
import hammer as h
|
||||
|
||||
class TestTokenParser(unittest.TestCase):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
cls.parser = h.token("95\xa2")
|
||||
def test_success(self):
|
||||
self.assertEqual(self.parser.parse("95\xa2"), "95\xa2")
|
||||
def test_partial_fails(self):
|
||||
self.assertEqual(self.parser.parse("95"), None)
|
||||
|
||||
class TestChParser(unittest.TestCase):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
cls.parser_int = h.ch(0xa2)
|
||||
cls.parser_chr = h.ch("\xa2")
|
||||
def test_success(self):
|
||||
self.assertEqual(self.parser_int.parse("\xa2"), 0xa2)
|
||||
self.assertEqual(self.parser_chr.parse("\xa2"), "\xa2")
|
||||
def test_failure(self):
|
||||
self.assertEqual(self.parser_int.parse("\xa3"), None)
|
||||
self.assertEqual(self.parser_chr.parse("\xa3"), None)
|
||||
|
||||
class TestChRange(unittest.TestCase):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
cls.parser =
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue