Skip to content

Added tests #222

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Mar 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions pydatastructs/trees/tests/test_m_ary_trees.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from pydatastructs import MAryTree

def test_MAryTree():
m = MAryTree(1, 1)
assert str(m) == '[(1, 1)]'
3 changes: 3 additions & 0 deletions pydatastructs/utils/misc_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,9 @@ def add_children(self, *children):
for child in children:
self.children.append(child)

def __str__(self):
return str((self.key, self.data))


class LinkedListNode(Node):
"""
Expand Down
15 changes: 14 additions & 1 deletion pydatastructs/utils/tests/test_misc_util.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from pydatastructs.utils import AdjacencyListGraphNode, AdjacencyMatrixGraphNode, GraphEdge
from pydatastructs.utils import (AdjacencyListGraphNode, AdjacencyMatrixGraphNode,
GraphEdge, BinomialTreeNode, MAryTreeNode)
from pydatastructs.utils.raises_util import raises

def test_AdjacencyListGraphNode():
Expand All @@ -25,3 +26,15 @@ def test_GraphEdge():
g_2 = AdjacencyListGraphNode('g_2', 2)
e = GraphEdge(g_1, g_2, value=2)
assert str(e) == "('g_1', 'g_2')"

def test_BinomialTreeNode():
b = BinomialTreeNode(1,1)
b.add_children(*[BinomialTreeNode(i,i) for i in range(2,10)])
assert str(b) == '(1, 1)'
assert str(b.children) == "['(2, 2)', '(3, 3)', '(4, 4)', '(5, 5)', '(6, 6)', '(7, 7)', '(8, 8)', '(9, 9)']"

def test_MAryTreeNode():
m = MAryTreeNode(1, 1)
m.add_children(*[i for i in range(2,10)])
assert str(m) == "(1, 1)"
assert str(m.children) == "['2', '3', '4', '5', '6', '7', '8', '9']"