1
0
mirror of https://github.com/myhdl/myhdl.git synced 2024-12-14 07:44:38 +08:00

Merge pull request #159 from atharvaw/master

Increasing test coverage for encoding in enum
This commit is contained in:
jandecaluwe 2018-02-21 21:00:19 +01:00 committed by GitHub
commit 212792f98a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 1 deletions

Binary file not shown.

View File

@ -32,7 +32,7 @@ random.seed(1) # random, but deterministic
t_State = enum("SEARCH", "CONFIRM", "SYNC")
t_Homograph = enum("SEARCH", "CONFIRM", "SYNC")
t_incomplete = enum("SEARCH", "CONFIRM")
class TestEnum:
@ -62,3 +62,26 @@ class TestEnum:
e = copy.deepcopy(t_State.SEARCH)
assert e == t_State.SEARCH
assert e != t_State.CONFIRM
## Adding test coverage for encoding in enum
def testItemNotDeepCopy(self):
e = copy.copy(t_State.SEARCH)
assert e == t_State.SEARCH
assert e != t_State.CONFIRM
def testWrongEncoding(self):
def logic1(encoding):
t_State = enum("SEARCH", "CONFIRM", "SYNC",encoding=encoding)
with pytest.raises(ValueError):
logic1(encoding)
def testNotStringtype(self):
with pytest.raises(TypeError):
t_State = enum("SEARCH", 1, "SYNC")
def testEnumLength(self):
l = len(t_State)
assert l == len(t_State)