Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
cython
Commits
99e2c12b
Commit
99e2c12b
authored
Jul 11, 2008
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
extended switch test case
parent
3482bd74
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
68 additions
and
0 deletions
+68
-0
tests/run/switch.pyx
tests/run/switch.pyx
+68
-0
No files found.
tests/run/switch.pyx
View file @
99e2c12b
__doc__
=
u"""
>>> switch_simple_py(1)
1
>>> switch_simple_py(2)
2
>>> switch_simple_py(3)
3
>>> switch_simple_py(4)
8
>>> switch_simple_py(5)
0
>>> switch_py(1)
1
>>> switch_py(2)
...
...
@@ -11,7 +22,24 @@ __doc__ = u"""
4
>>> switch_py(6)
0
>>> switch_py(8)
4
>>> switch_py(10)
7
>>> switch_py(12)
8
>>> switch_py(13)
0
>>> switch_simple_c(1)
1
>>> switch_simple_c(2)
2
>>> switch_simple_c(3)
3
>>> switch_simple_c(4)
8
>>> switch_simple_c(5)
0
>>> switch_c(1)
...
...
@@ -26,10 +54,29 @@ __doc__ = u"""
4
>>> switch_c(6)
0
>>> switch_c(8)
4
>>> switch_c(10)
7
>>> switch_c(12)
8
>>> switch_c(13)
0
"""
def
switch_simple_py
(
x
):
if
x
==
1
:
return
1
elif
2
==
x
:
return
2
elif
x
in
[
3
]:
return
3
elif
x
in
(
4
,):
return
8
else
:
return
0
return
-
1
def
switch_py
(
x
):
if
x
==
1
:
return
1
...
...
@@ -39,6 +86,23 @@ def switch_py(x):
return
3
elif
x
in
[
4
,
5
,
7
,
8
]:
return
4
elif
x
in
(
10
,
11
):
# doesn't work: (7,8,10,11)
return
7
elif
x
in
(
12
,):
return
8
else
:
return
0
return
-
1
def
switch_simple_c
(
int
x
):
if
x
==
1
:
return
1
elif
2
==
x
:
return
2
elif
x
in
[
3
]:
return
3
elif
x
in
(
4
,):
return
8
else
:
return
0
return
-
1
...
...
@@ -52,6 +116,10 @@ def switch_c(int x):
return
3
elif
x
in
[
4
,
5
,
7
,
8
]:
return
4
elif
x
in
(
10
,
11
):
# doesn't work: (7,8,10,11)
return
7
elif
x
in
(
12
,):
return
8
else
:
return
0
return
-
1
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