Skip to content

Commit

Permalink
Enhance string tests
Browse files Browse the repository at this point in the history
- Add missing optional members
  • Loading branch information
tzussman committed May 6, 2023
1 parent 605e36d commit 6915c8e
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions valparse/tests/test_vgerror.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,13 @@ def test_Status():
def test_SFrame():
"""Create an instance of a SFrame and check its fields."""
sframe = valparse.SFrame(
obj="0x4",
obj="test",
fun="main",
)

assert sframe.obj == "0x4"
assert sframe.obj == "test"
assert sframe.fun == "main"
assert str(sframe) == " Object: 0x4\n Function: main\n"
assert str(sframe) == " Object: test\n Function: main\n"


def test_FatalSignal():
Expand All @@ -141,6 +141,7 @@ def test_FatalSignal():
line=50,
),
],
threadname="test_thread",
)

assert sig.tid == 5
Expand All @@ -149,6 +150,7 @@ def test_FatalSignal():
assert sig.sicode == 1
assert sig.siaddr == "0x0"
assert len(sig.stack) == 1
assert sig.threadname == "test_thread"

assert sig.get_signal() == signal.SIGSEGV
sig_str = '''Thread ID: 5
Expand All @@ -163,6 +165,7 @@ def test_FatalSignal():
Directory: /home/valparse/examples/
File: invalid_read.c
Line: 50
Thread name: test_thread
'''

assert str(sig) == sig_str
Expand Down Expand Up @@ -218,16 +221,20 @@ def test_Suppression():
supp = valparse.Suppression(
name="test_supp",
kind="Memcheck:Value8",
stack=[valparse.SFrame(fun="main")],
stack=[valparse.SFrame(fun="main", obj="test")],
auxkind="Test suppression",
)

assert supp.name == "test_supp"
assert supp.kind == "Memcheck:Value8"
assert len(supp.stack) == 1
assert supp.auxkind == "Test suppression"

supp_str = '''Suppression kind: Memcheck:Value8
Stack frame:
Object: test
Function: main
Aux kind: Test suppression
'''

assert str(supp) == supp_str

0 comments on commit 6915c8e

Please sign in to comment.