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
2520ac35
Commit
2520ac35
authored
2 months ago
by
Alma Berisha
Browse files
Options
Downloads
Patches
Plain Diff
Testfälle für student4 hinzugefügt
parent
5b02300b
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_student4.py
+49
-0
49 additions, 0 deletions
test_me_on_student4.py
test_student4_on_me.py
+55
-0
55 additions, 0 deletions
test_student4_on_me.py
with
104 additions
and
0 deletions
test_me_on_student4.py
0 → 100644
+
49
−
0
View file @
2520ac35
import
unittest
from
other.student4.Calculator
import
StringCalculator
# Marvin
class
TestMyCasesOnStudent4
(
unittest
.
TestCase
):
def
setUp
(
self
):
self
.
calc
=
StringCalculator
()
def
test_empty_string
(
self
):
self
.
assertEqual
(
self
.
calc
.
add
(
""
),
0
)
def
test_single_number
(
self
):
self
.
assertEqual
(
self
.
calc
.
add
(
"
1
"
),
1
)
def
test_two_numbers
(
self
):
self
.
assertEqual
(
self
.
calc
.
add
(
"
1,2
"
),
3
)
def
test_multiple_numbers
(
self
):
self
.
assertEqual
(
self
.
calc
.
add
(
"
1,2,3,4,5
"
),
15
)
def
test_numbers_with_newline
(
self
):
self
.
assertEqual
(
self
.
calc
.
add
(
"
1
\n
2,3
"
),
6
)
def
test_multiple_newlines
(
self
):
self
.
assertEqual
(
self
.
calc
.
add
(
"
1
\n
2
\n
3
\n
4
\n
5
"
),
15
)
def
test_negative_number
(
self
):
with
self
.
assertRaises
(
ValueError
)
as
e
:
self
.
calc
.
add
(
"
1,-2,3
"
)
self
.
assertEqual
(
str
(
e
.
exception
),
"
Negative numbers are not allowed: -2
"
)
def
test_multiple_negative_numbers
(
self
):
with
self
.
assertRaises
(
ValueError
)
as
e
:
self
.
calc
.
add
(
"
1,-2,-3,4
"
)
self
.
assertEqual
(
str
(
e
.
exception
),
"
Negative numbers are not allowed: -2, -3
"
)
def
test_custom_delimiter
(
self
):
self
.
assertEqual
(
self
.
calc
.
add
(
"
//;
\n
1;2
"
),
3
)
def
test_custom_delimiter_with_newline
(
self
):
self
.
assertEqual
(
self
.
calc
.
add
(
"
//;
\n
1;2
\n
3
"
),
6
)
def
test_ignore_numbers_over_1000
(
self
):
self
.
assertEqual
(
self
.
calc
.
add
(
"
2,1001
"
),
2
)
def
test_custom_delimiter_any_length
(
self
):
self
.
assertEqual
(
self
.
calc
.
add
(
"
//[***]
\n
1***2***3
"
),
6
)
if
__name__
==
"
__main__
"
:
unittest
.
main
()
This diff is collapsed.
Click to expand it.
test_student4_on_me.py
0 → 100644
+
55
−
0
View file @
2520ac35
import
unittest
from
my_string_calculator
import
StringCalculator
class
TestStudent4CasesOnMe
(
unittest
.
TestCase
):
def
setUp
(
self
):
self
.
calculator
=
StringCalculator
()
def
test_empty_string_returns_zero
(
self
):
self
.
assertEqual
(
self
.
calculator
.
add
(
""
),
0
)
def
test_single_number_returns_value
(
self
):
self
.
assertEqual
(
self
.
calculator
.
add
(
"
1
"
),
1
)
def
test_two_numbers_return_sum
(
self
):
self
.
assertEqual
(
self
.
calculator
.
add
(
"
1,2
"
),
3
)
def
test_add_multiple_numbers
(
self
):
self
.
assertEqual
(
self
.
calculator
.
add
(
"
1,2,3,4,5
"
),
15
)
def
test_add_numbers_with_newlines
(
self
):
self
.
assertEqual
(
self
.
calculator
.
add
(
"
1
\n
2
\n
3
"
),
6
)
def
test_add_negative_numbers
(
self
):
with
self
.
assertRaises
(
ValueError
)
as
e
:
self
.
calculator
.
add
(
"
-1,2,-3
"
)
self
.
assertEqual
(
str
(
e
.
exception
),
"
Negatives not allowed: -1, -3
"
)
def
test_add_numbers_with_custom_delimiter
(
self
):
self
.
assertEqual
(
self
.
calculator
.
add
(
"
//;
\n
1;2;3
"
),
6
)
def
test_add_numbers_with_custom_delimiter_different_symbol
(
self
):
self
.
assertEqual
(
self
.
calculator
.
add
(
"
//#
\n
4#5#6
"
),
15
)
def
test_custom_delimiter_with_multiple_numbers
(
self
):
self
.
assertEqual
(
self
.
calculator
.
add
(
"
//:
\n
1:2:3:4:5:6
"
),
21
)
def
test_add_numbers_greater_than_1000
(
self
):
self
.
assertEqual
(
self
.
calculator
.
add
(
"
1,1001,2,3
"
),
6
)
def
test_add_numbers_with_newlines_and_ignore_above_1000
(
self
):
self
.
assertEqual
(
self
.
calculator
.
add
(
"
1
\n
2
\n
1000
\n
1001
"
),
1003
)
def
test_add_numbers_with_custom_delimiter_long_length
(
self
):
self
.
assertEqual
(
self
.
calculator
.
add
(
"
//[***]
\n
1***2***3
"
),
6
)
def
test_custom_long_delimiter_with_large_number_ignored
(
self
):
self
.
assertEqual
(
self
.
calculator
.
add
(
"
//[***]
\n
1***1001***2
"
),
3
)
def
test_custom_long_delimiter_with_negative_numbers
(
self
):
with
self
.
assertRaises
(
ValueError
)
as
e
:
self
.
calculator
.
add
(
"
//[***]
\n
1***-2***3***-4
"
)
self
.
assertEqual
(
str
(
e
.
exception
),
"
Negatives not allowed: -2, -4
"
)
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