Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
p2
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
cse332-20au
p2
Commits
85790ef2
Commit
85790ef2
authored
4 years ago
by
Nathan Lipiarski
Browse files
Options
Downloads
Patches
Plain Diff
Adding equals to item for better testing abilities
parent
acafcc06
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
src/cse332/datastructures/containers/Item.java
+16
-0
16 additions, 0 deletions
src/cse332/datastructures/containers/Item.java
src/tests/gitlab/ckpt1/NGramToNextChoicesMapTests.java
+2
-14
2 additions, 14 deletions
src/tests/gitlab/ckpt1/NGramToNextChoicesMapTests.java
with
18 additions
and
14 deletions
src/cse332/datastructures/containers/Item.java
+
16
−
0
View file @
85790ef2
package
cse332.datastructures.containers
;
import
java.util.Objects
;
/**
* Simple class to hold a piece of data and its value.
*
...
...
@@ -40,4 +42,18 @@ public class Item<K, V> {
public
String
toString
()
{
return
this
.
key
+
"="
+
this
.
value
+
""
;
}
@Override
public
boolean
equals
(
Object
o
)
{
if
(
this
==
o
)
return
true
;
if
(
o
==
null
||
getClass
()
!=
o
.
getClass
())
return
false
;
Item
<?,
?>
item
=
(
Item
<?,
?>)
o
;
return
Objects
.
equals
(
key
,
item
.
key
)
&&
Objects
.
equals
(
value
,
item
.
value
);
}
@Override
public
int
hashCode
()
{
return
Objects
.
hash
(
key
,
value
);
}
}
This diff is collapsed.
Click to expand it.
src/tests/gitlab/ckpt1/NGramToNextChoicesMapTests.java
+
2
−
14
View file @
85790ef2
...
...
@@ -16,14 +16,8 @@ import org.junit.Test;
import
static
org
.
junit
.
Assert
.*;
public
class
NGramToNextChoicesMapTests
{
private
Supplier
<
Dictionary
<
NGram
,
Dictionary
<
AlphabeticString
,
Integer
>>>
newOuter
=
()
->
new
BinarySearchTree
();
private
Supplier
<
Dictionary
<
AlphabeticString
,
Integer
>>
newInner
=
()
->
new
BinarySearchTree
();
private
NGramToNextChoicesMap
init
()
{
return
new
NGramToNextChoicesMap
(
newOuter
,
newInner
);
return
new
NGramToNextChoicesMap
(
BinarySearchTree:
:
new
,
BinarySearchTree:
:
new
);
}
@Test
(
timeout
=
3000
)
...
...
@@ -172,13 +166,7 @@ public class NGramToNextChoicesMapTests {
Arrays
.
sort
(
results
,
Comparator
.
comparing
(
r
->
r
.
key
));
Item
<
String
,
Integer
>[]
expected
=
answers
.
get
(
ngram
);
// checks for correct number of unique words after
assertEquals
(
expected
.
length
,
results
.
length
);
for
(
int
j
=
0
;
j
<
expected
.
length
;
j
++)
{
// checks if correct word after via sorted words
assertEquals
(
expected
[
j
].
key
,
results
[
j
].
key
);
// checks if correct count for given word after
assertEquals
(
expected
[
j
].
value
,
results
[
j
].
value
);
}
assertArrayEquals
(
expected
,
results
);
}
}
}
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