Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
GoikLectures
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor 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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Goik Martin
GoikLectures
Commits
f1c98bc4
Commit
f1c98bc4
authored
1 month ago
by
Goik Martin
Browse files
Options
Downloads
Patches
Plain Diff
Amending error message for multiple arithmetic operations
parent
d4adc3ac
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Klausuren/Sd1/2023winter/Exam/src/test/java/de/hdm_stuttgart/mi/sd1/task1/B_MaxTest.java
+16
-4
16 additions, 4 deletions
...rc/test/java/de/hdm_stuttgart/mi/sd1/task1/B_MaxTest.java
with
16 additions
and
4 deletions
Klausuren/Sd1/2023winter/Exam/src/test/java/de/hdm_stuttgart/mi/sd1/task1/B_MaxTest.java
+
16
−
4
View file @
f1c98bc4
...
...
@@ -19,13 +19,13 @@ public class B_MaxTest extends ExaminationTestDefaults {
assertMaximum
(
5.1
,
0.1
,
5
,
'+'
);
assertMaximum
(
35
,
7
,
0.2
,
'/'
);
assertMaximum
(-
1.4
,-
7
,
0.2
,
'*'
);
assertMaximum
(
4
,
2
,
2
,
'+'
);
assertMaximum
(
4
,
2
,
2
,
'+'
,
'*'
);
}
private
static
void
assertMaximum
(
final
double
expected
,
final
double
first
,
final
double
second
,
char
operation
)
{
private
static
void
assertMaximum
(
final
double
expected
,
final
double
first
,
final
double
second
,
char
...
operation
)
{
final
StringBuilder
errMsg
=
new
StringBuilder
(
"Expected maximum is "
+
expected
+
" == "
+
first
+
" "
+
operation
+
" "
);
final
StringBuilder
errMsg
=
new
StringBuilder
(
"Expected maximum is "
).
append
(
expected
).
append
(
" == "
).
append
(
first
).
append
(
" "
).
append
(
join
(
operation
)).
append
(
" "
);
if
(
second
<
0
)
{
errMsg
.
append
(
"("
+
second
+
")"
);
...
...
@@ -34,4 +34,16 @@ public class B_MaxTest extends ExaminationTestDefaults {
}
Assert
.
assertEquals
(
errMsg
.
toString
(),
expected
,
B_Max
.
getBasicCalculationMax
(
first
,
second
),
PRECISION
);
}
private
static
String
join
(
char
[]
operations
)
{
if
(
1
==
operations
.
length
)
{
return
Character
.
toString
(
operations
[
0
]);
}
else
{
StringBuilder
ret
=
new
StringBuilder
(
"{"
)
.
append
(
operations
[
0
]);
for
(
int
i
=
1
;
i
<
operations
.
length
;
i
++)
{
ret
.
append
(
" or "
).
append
(
operations
[
i
]);
}
return
ret
.
append
(
'}'
).
toString
();
}
}
}
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