Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
Assignement_02
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Alma Berisha
Assignement_02
Commits
c192119b
Commit
c192119b
authored
3 weeks ago
by
Alma Berisha
Browse files
Options
Downloads
Patches
Plain Diff
Testfälle für student5 hinzugefügt
parent
2520ac35
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
test_me_on_student5.py
+30
-0
30 additions, 0 deletions
test_me_on_student5.py
test_student5_on_me.py
+57
-0
57 additions, 0 deletions
test_student5_on_me.py
with
87 additions
and
0 deletions
test_me_on_student5.py
0 → 100644
+
30
−
0
View file @
c192119b
import
unittest
from
other.student5.Calculator_combined
import
StringCalculator
#orlando
class
TestMeOnStudent5
(
unittest
.
TestCase
):
def
setUp
(
self
):
self
.
calc
=
StringCalculator
()
def
test_ignores_empty_entries
(
self
):
self
.
assertEqual
(
self
.
calc
.
add
(
"
1,,2
"
),
3
)
self
.
assertEqual
(
self
.
calc
.
add
(
"
,,1,,2,,
"
),
3
)
def
test_add_multi_char_delimiter
(
self
):
self
.
assertEqual
(
self
.
calc
.
add
(
"
//[abc]
\n
4abc5abc6
"
),
15
)
def
test_newlines_mixed_with_commas
(
self
):
self
.
assertEqual
(
self
.
calc
.
add
(
"
1,2
\n
3
"
),
6
)
def
test_single_number
(
self
):
self
.
assertEqual
(
self
.
calc
.
add
(
"
5
"
),
5
)
def
test_custom_delimiters_varied
(
self
):
self
.
assertEqual
(
self
.
calc
.
add
(
"
//_
\n
7_8_9
"
),
24
)
def
test_multiple_negatives
(
self
):
with
self
.
assertRaises
(
ValueError
)
as
context
:
self
.
calc
.
add
(
"
-1,-2
"
)
self
.
assertIn
(
"
negatives not allowed
"
,
str
(
context
.
exception
))
if
__name__
==
"
__main__
"
:
unittest
.
main
()
This diff is collapsed.
Click to expand it.
test_student5_on_me.py
0 → 100644
+
57
−
0
View file @
c192119b
import
unittest
from
my_string_calculator
import
StringCalculator
class
TestStudent5OnMyCode
(
unittest
.
TestCase
):
def
setUp
(
self
):
self
.
calc
=
StringCalculator
()
def
test_add_empty_string
(
self
):
self
.
assertEqual
(
self
.
calc
.
add
(
""
),
0
)
def
test_add_single_number
(
self
):
self
.
assertEqual
(
self
.
calc
.
add
(
"
1
"
),
1
)
def
test_add_two_numbers
(
self
):
self
.
assertEqual
(
self
.
calc
.
add
(
"
1,2
"
),
3
)
def
test_add_multiple_numbers
(
self
):
self
.
assertEqual
(
self
.
calc
.
add
(
"
1,2,3
"
),
6
)
self
.
assertEqual
(
self
.
calc
.
add
(
"
1,2,3,4,5
"
),
15
)
def
test_add_ignores_empty_entries
(
self
):
self
.
assertEqual
(
self
.
calc
.
add
(
"
1,,2
"
),
3
)
self
.
assertEqual
(
self
.
calc
.
add
(
"
1, ,2
"
),
3
)
self
.
assertEqual
(
self
.
calc
.
add
(
"
,,1,,2,,,
"
),
3
)
def
test_add_with_newlines_between_numbers
(
self
):
self
.
assertEqual
(
self
.
calc
.
add
(
"
1
\n
2,3
"
),
6
)
self
.
assertEqual
(
self
.
calc
.
add
(
"
1,2
\n
3
"
),
6
)
self
.
assertEqual
(
self
.
calc
.
add
(
"
1
\n
2
\n
3
"
),
6
)
def
test_add_raises_exception_on_negative_number
(
self
):
with
self
.
assertRaises
(
ValueError
)
as
context
:
self
.
calc
.
add
(
"
1,-2
"
)
self
.
assertIn
(
"
Negatives not allowed
"
,
str
(
context
.
exception
))
def
test_add_raises_exception_on_multiple_negatives
(
self
):
with
self
.
assertRaises
(
ValueError
)
as
context
:
self
.
calc
.
add
(
"
-1,-2,3
"
)
self
.
assertIn
(
"
Negatives not allowed
"
,
str
(
context
.
exception
))
def
test_add_with_custom_delimiter
(
self
):
self
.
assertEqual
(
self
.
calc
.
add
(
"
//;
\n
1;2
"
),
3
)
self
.
assertEqual
(
self
.
calc
.
add
(
"
//|
\n
4|5|6
"
),
15
)
self
.
assertEqual
(
self
.
calc
.
add
(
"
//_
\n
7_8_9
"
),
24
)
def
test_add_ignores_numbers_greater_than_1000
(
self
):
self
.
assertEqual
(
self
.
calc
.
add
(
"
2,1001
"
),
2
)
self
.
assertEqual
(
self
.
calc
.
add
(
"
1000,1
"
),
1001
)
self
.
assertEqual
(
self
.
calc
.
add
(
"
1234,1001,3
"
),
3
)
def
test_add_with_multi_char_delimiter
(
self
):
self
.
assertEqual
(
self
.
calc
.
add
(
"
//[***]
\n
1***2***3
"
),
6
)
self
.
assertEqual
(
self
.
calc
.
add
(
"
//[abc]
\n
4abc5abc6
"
),
15
)
self
.
assertEqual
(
self
.
calc
.
add
(
"
//[+]
\n
1+2+3
"
),
6
)
if
__name__
==
"
__main__
"
:
unittest
.
main
()
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment