Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
cs2-20wi
project05
Commits
ce22e5ff
Commit
ce22e5ff
authored
4 years ago
by
Ethan Ordentlich
Browse files
Options
Download
Plain Diff
Merge branch 'tests' into 'master'
Tests See merge request
!2
parents
749c1ba2
7132f581
1 merge request
!2
Tests
Pipeline
#45397
canceled with stage
Changes
6
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
.idea/runConfigurations/ChainingHashDictionaryTests.xml
+18
-0
.idea/runConfigurations/ChainingHashDictionaryTests.xml
.idea/runConfigurations/MoveToFrontDictionaryTests.xml
+18
-0
.idea/runConfigurations/MoveToFrontDictionaryTests.xml
.idea/runConfigurations/NGramTests.xml
+18
-0
.idea/runConfigurations/NGramTests.xml
tests/edu/caltech/cs2/datastructures/ChainingHashDictionaryTests.java
+6
-8
...ltech/cs2/datastructures/ChainingHashDictionaryTests.java
tests/edu/caltech/cs2/datastructures/IDictionaryNGramTests.java
+6
-1
...edu/caltech/cs2/datastructures/IDictionaryNGramTests.java
tests/edu/caltech/cs2/datastructures/MoveToFrontDictionaryTests.java
+0
-1
...altech/cs2/datastructures/MoveToFrontDictionaryTests.java
with
66 additions
and
10 deletions
+66
-10
.idea/runConfigurations/ChainingHashDictionaryTests.xml
0 → 100644
View file @
ce22e5ff
<component
name=
"ProjectRunConfigurationManager"
>
<configuration
default=
"false"
name=
"ChainingHashDictionaryTests"
type=
"JUnit"
factoryName=
"JUnit"
nameIsGenerated=
"true"
>
<module
name=
"project05-markov"
/>
<extension
name=
"coverage"
>
<pattern>
<option
name=
"PATTERN"
value=
"edu.caltech.cs2.datastructures.*"
/>
<option
name=
"ENABLED"
value=
"true"
/>
</pattern>
</extension>
<option
name=
"PACKAGE_NAME"
value=
"edu.caltech.cs2.datastructures"
/>
<option
name=
"MAIN_CLASS_NAME"
value=
"edu.caltech.cs2.datastructures.ChainingHashDictionaryTests"
/>
<option
name=
"METHOD_NAME"
value=
""
/>
<option
name=
"TEST_OBJECT"
value=
"class"
/>
<method
v=
"2"
>
<option
name=
"Make"
enabled=
"true"
/>
</method>
</configuration>
</component>
\ No newline at end of file
This diff is collapsed.
Click to expand it.
.idea/runConfigurations/MoveToFrontDictionaryTests.xml
0 → 100644
View file @
ce22e5ff
<component
name=
"ProjectRunConfigurationManager"
>
<configuration
default=
"false"
name=
"MoveToFrontDictionaryTests"
type=
"JUnit"
factoryName=
"JUnit"
nameIsGenerated=
"true"
>
<module
name=
"project05-markov"
/>
<extension
name=
"coverage"
>
<pattern>
<option
name=
"PATTERN"
value=
"edu.caltech.cs2.datastructures.*"
/>
<option
name=
"ENABLED"
value=
"true"
/>
</pattern>
</extension>
<option
name=
"PACKAGE_NAME"
value=
"edu.caltech.cs2.datastructures"
/>
<option
name=
"MAIN_CLASS_NAME"
value=
"edu.caltech.cs2.datastructures.MoveToFrontDictionaryTests"
/>
<option
name=
"METHOD_NAME"
value=
""
/>
<option
name=
"TEST_OBJECT"
value=
"class"
/>
<method
v=
"2"
>
<option
name=
"Make"
enabled=
"true"
/>
</method>
</configuration>
</component>
\ No newline at end of file
This diff is collapsed.
Click to expand it.
.idea/runConfigurations/NGramTests.xml
0 → 100644
View file @
ce22e5ff
<component
name=
"ProjectRunConfigurationManager"
>
<configuration
default=
"false"
name=
"NGramTests"
type=
"JUnit"
factoryName=
"JUnit"
nameIsGenerated=
"true"
>
<module
name=
"project05-markov"
/>
<extension
name=
"coverage"
>
<pattern>
<option
name=
"PATTERN"
value=
"edu.caltech.cs2.datastructures.*"
/>
<option
name=
"ENABLED"
value=
"true"
/>
</pattern>
</extension>
<option
name=
"PACKAGE_NAME"
value=
"edu.caltech.cs2.datastructures"
/>
<option
name=
"MAIN_CLASS_NAME"
value=
"edu.caltech.cs2.datastructures.NGramTests"
/>
<option
name=
"METHOD_NAME"
value=
""
/>
<option
name=
"TEST_OBJECT"
value=
"class"
/>
<method
v=
"2"
>
<option
name=
"Make"
enabled=
"true"
/>
</method>
</configuration>
</component>
\ No newline at end of file
This diff is collapsed.
Click to expand it.
tests/edu/caltech/cs2/datastructures/ChainingHashDictionaryTests.java
View file @
ce22e5ff
...
...
@@ -61,7 +61,7 @@ public class ChainingHashDictionaryTests implements IDictionaryNGramTests {
@DisplayName
(
"Does not use or import disallowed classes from java.util"
)
@Test
public
void
testForInvalidImportsJavaUtil
()
{
List
<
String
>
allowed
=
List
.
of
(
"Iterator"
,
"Supplier"
,
"Stream"
);
List
<
String
>
allowed
=
List
.
of
(
"Iterator"
,
"
function\\.
Supplier"
,
"
stream\\.
Stream"
);
Inspection
.
assertNoImportsOfExcept
(
DICTIONARY_SOURCE
,
"java\\.util"
,
allowed
);
List
<
String
>
bannedUsages
=
List
.
of
(
"java\\.util\\.(?!"
+
String
.
join
(
"|"
,
allowed
)
+
")"
);
...
...
@@ -94,14 +94,12 @@ public class ChainingHashDictionaryTests implements IDictionaryNGramTests {
@Timeout
(
value
=
20
,
unit
=
SECONDS
)
@Test
public
void
testGrowthCapability
()
{
Set
<
IDictionary
<
Object
,
Object
>>
dicts
=
new
HashSet
<>();
for
(
int
i
=
0
;
i
<
50
;
i
++)
{
dicts
.
add
(
new
ChainingHashDictionary
<>(
MoveToFrontDictionary:
:
new
));
}
for
(
IDictionary
<
Object
,
Object
>
dict
:
dicts
)
{
for
(
int
i
=
0
;
i
<
400000
;
i
++)
{
dict
.
put
(
i
,
i
);
for
(
int
i
=
0
;
i
<
25
;
i
++)
{
IDictionary
<
Object
,
Object
>
dict
=
new
ChainingHashDictionary
<>(
MoveToFrontDictionary:
:
new
);
for
(
int
j
=
0
;
j
<
500000
;
j
++)
{
dict
.
put
(
j
,
j
);
}
// This _should_ get GC'd with a smaller heap size...
}
}
...
...
This diff is collapsed.
Click to expand it.
tests/edu/caltech/cs2/datastructures/IDictionaryNGramTests.java
View file @
ce22e5ff
...
...
@@ -6,6 +6,7 @@ import edu.caltech.cs2.textgenerator.NGram;
import
org.junit.jupiter.api.DisplayName
;
import
org.junit.jupiter.api.Order
;
import
org.junit.jupiter.api.Test
;
import
org.junit.jupiter.api.Timeout
;
import
org.junit.jupiter.params.provider.Arguments
;
import
java.util.HashMap
;
...
...
@@ -17,6 +18,7 @@ import java.util.stream.Stream;
import
static
edu
.
caltech
.
cs2
.
project05
.
Project05TestOrdering
.
sanityTestLevel
;
import
static
edu
.
caltech
.
cs2
.
project05
.
Project05TestOrdering
.
specialTestLevel
;
import
static
java
.
util
.
concurrent
.
TimeUnit
.
SECONDS
;
import
static
org
.
junit
.
jupiter
.
api
.
Assertions
.
assertTrue
;
// Wrapper class for all IDictionaries that will be tested using NGram keys to reduce code repetition
...
...
@@ -47,7 +49,7 @@ public interface IDictionaryNGramTests extends IDictionaryTests {
@Override
default
Map
<
Object
,
Object
>
generateRandomTestData
(
int
size
,
Random
rand
,
int
maxNodeDegree
,
int
minKeyLength
,
int
maxKeyLength
)
{
int
maxKeyLength
)
{
Map
<
Object
,
Object
>
base
=
new
HashMap
<>();
for
(
int
i
=
0
;
i
<
size
;
i
++)
{
int
keyLength
=
minKeyLength
+
rand
.
nextInt
(
maxKeyLength
-
minKeyLength
);
...
...
@@ -77,6 +79,7 @@ public interface IDictionaryNGramTests extends IDictionaryTests {
@Order
(
specialTestLevel
)
@DisplayName
(
"Test get() -- complexity"
)
@Test
@Timeout
(
value
=
20
,
unit
=
SECONDS
)
default
void
testGetComplexity
()
{
Function
<
Integer
,
IDictionary
<
Object
,
Object
>>
provide
=
(
Integer
numElements
)
->
{
IDictionary
<
Object
,
Object
>
t
=
newIDictionary
();
...
...
@@ -95,6 +98,7 @@ public interface IDictionaryNGramTests extends IDictionaryTests {
@Order
(
specialTestLevel
)
@DisplayName
(
"Test put() -- complexity"
)
@Test
@Timeout
(
value
=
20
,
unit
=
SECONDS
)
default
void
testPutComplexity
()
{
Function
<
Integer
,
IDictionary
<
Object
,
Object
>>
provide
=
(
Integer
numElements
)
->
{
IDictionary
<
Object
,
Object
>
t
=
newIDictionary
();
...
...
@@ -113,6 +117,7 @@ public interface IDictionaryNGramTests extends IDictionaryTests {
@Order
(
specialTestLevel
)
@DisplayName
(
"Test size() -- complexity"
)
@Test
@Timeout
(
value
=
20
,
unit
=
SECONDS
)
default
void
testSizeComplexity
()
{
Function
<
Integer
,
IDictionary
<
Object
,
Object
>>
provide
=
(
Integer
numElements
)
->
{
IDictionary
<
Object
,
Object
>
t
=
newIDictionary
();
...
...
This diff is collapsed.
Click to expand it.
tests/edu/caltech/cs2/datastructures/MoveToFrontDictionaryTests.java
View file @
ce22e5ff
...
...
@@ -96,7 +96,6 @@ public class MoveToFrontDictionaryTests implements IDictionaryNGramTests {
}
}
// TODO: what the fuck
@Order
(
classSpecificTestLevel
)
@DisplayName
(
"Check MoveToFrontDictionary class is properly implemented"
)
@Test
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Projects
Groups
Snippets
Help