Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
trs
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Taddeüs Kroes
trs
Commits
0e7541cf
Commit
0e7541cf
authored
Jan 14, 2012
by
Taddeus Kroes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added unit tests for utils.py.
parent
f0701c3a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
0 deletions
+33
-0
tests/test_rules_utils.py
tests/test_rules_utils.py
+33
-0
No files found.
tests/test_rules_utils.py
0 → 100644
View file @
0e7541cf
from
src.node
import
ExpressionNode
as
N
from
src.rules.utils
import
nary_node
,
is_prime
,
least_common_multiple
from
tests.test_rules_poly
import
tree
from
tests.rulestestcase
import
RulesTestCase
class
TestRulesUtils
(
RulesTestCase
):
def
test_nary_node
(
self
):
a
,
b
,
c
,
d
=
tree
(
'a,b,c,d'
)
self
.
assertEqualNodes
(
nary_node
(
'+'
,
[
a
]),
a
)
self
.
assertEqualNodes
(
nary_node
(
'+'
,
[
a
,
b
]),
N
(
'+'
,
a
,
b
))
self
.
assertEqualNodes
(
nary_node
(
'+'
,
[
a
,
b
,
c
]),
N
(
'+'
,
N
(
'+'
,
a
,
b
),
c
))
self
.
assertEqualNodes
(
nary_node
(
'+'
,
[
a
,
b
,
c
,
d
]),
N
(
'+'
,
N
(
'+'
,
N
(
'+'
,
a
,
b
),
c
),
d
))
def
test_is_prime
(
self
):
self
.
assertTrue
(
is_prime
(
2
))
self
.
assertTrue
(
is_prime
(
3
))
self
.
assertTrue
(
is_prime
(
647
))
self
.
assertFalse
(
is_prime
(
0
))
self
.
assertFalse
(
is_prime
(
1
))
self
.
assertFalse
(
is_prime
(
4
))
self
.
assertFalse
(
is_prime
(
9
))
self
.
assertFalse
(
is_prime
(
100
))
def
test_least_common_multiple
(
self
):
self
.
assertEqual
(
least_common_multiple
(
5
,
6
),
30
)
self
.
assertEqual
(
least_common_multiple
(
5
,
6
,
15
),
30
)
self
.
assertEqual
(
least_common_multiple
(
2
,
4
),
4
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment