Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
StringCalculator
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
Lasse Pikkemaat
StringCalculator
Commits
5ac8e6c8
Commit
5ac8e6c8
authored
1 month ago
by
Lasse Pikkemaat
Browse files
Options
Downloads
Plain Diff
Merge branch 'feature5' into 'develop'
Feature5 See merge request
!5
parents
700de9f9
0273a324
No related branches found
Branches containing commit
No related tags found
2 merge requests
!7
Develop into main
,
!5
Feature5
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/stringcalculator.py
+2
-0
2 additions, 0 deletions
src/stringcalculator.py
tests/test_stringclaculator.py
+8
-0
8 additions, 0 deletions
tests/test_stringclaculator.py
with
10 additions
and
0 deletions
src/stringcalculator.py
+
2
−
0
View file @
5ac8e6c8
...
@@ -27,4 +27,6 @@ class StringCalculator(IStringCalculator):
...
@@ -27,4 +27,6 @@ class StringCalculator(IStringCalculator):
if
negative_numbers
:
if
negative_numbers
:
raise
ValueError
(
f
"
Negative nicht erlaubt:
{
negative_numbers
}
"
)
raise
ValueError
(
f
"
Negative nicht erlaubt:
{
negative_numbers
}
"
)
numbers_list
=
[
num
for
num
in
numbers_list
if
num
<=
1000
]
return
sum
(
numbers_list
)
return
sum
(
numbers_list
)
\ No newline at end of file
This diff is collapsed.
Click to expand it.
tests/test_stringclaculator.py
+
8
−
0
View file @
5ac8e6c8
...
@@ -16,6 +16,10 @@
...
@@ -16,6 +16,10 @@
# Bei Eingabe eines neuen Trennzeichen ";" //;\n1;2 soll 3 ausgegeben werden
# Bei Eingabe eines neuen Trennzeichen ";" //;\n1;2 soll 3 ausgegeben werden
# Bei Eingabe eines neuen Trennzeichen "x" //-\n7x8\n9 soll 24 ausgegeben werden
# Bei Eingabe eines neuen Trennzeichen "x" //-\n7x8\n9 soll 24 ausgegeben werden
# Bei Eingabe eines neuen Trennzeichens ";" ohne vollständigen Ausdrück //;1;2 soll Ungültiges Format: Nicht vollständig
# Bei Eingabe eines neuen Trennzeichens ";" ohne vollständigen Ausdrück //;1;2 soll Ungültiges Format: Nicht vollständig
#Feature5 Zahlen größer 1000 nicht erkennen
# Bei Eingabe von 2,1001 soll 2 ausgegeben werden
# Bei Eingabe von 1002, 50200 soll 0 asugegeben werden
import
unittest
import
unittest
from
src.interfaces
import
IStringCalculator
from
src.interfaces
import
IStringCalculator
...
@@ -63,6 +67,10 @@ class TestStringCalculator(unittest.TestCase):
...
@@ -63,6 +67,10 @@ class TestStringCalculator(unittest.TestCase):
self
.
calculator
.
add
(
"
//;1;2
"
)
self
.
calculator
.
add
(
"
//;1;2
"
)
print
(
str
(
context
.
exception
))
print
(
str
(
context
.
exception
))
def
test_ignore_numbers_greater_than_1000
(
self
):
self
.
assertEqual
(
self
.
calculator
.
add
(
"
2,1001
"
),
2
)
self
.
assertEqual
(
self
.
calculator
.
add
(
"
1002,50200
"
),
0
)
if
__name__
==
"
__main__
"
:
if
__name__
==
"
__main__
"
:
unittest
.
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