FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
Java/src/test/java/com/caching/LRUCacheTest.java at Development · iDev-git/Java · GitHub
iDev-git
Java
Repository navigation
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
Java
/
src
/
test
/
java
/
com
/
caching
/
LRUCacheTest.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
25 lines (20 loc) · 871 Bytes
Breadcrumbs
Java
/
src
/
test
/
java
/
com
/
caching
/
LRUCacheTest.java
Copy path
File metadata and controls
25 lines (20 loc) · 871 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
package
com
.
caching
;
import
org
.
junit
.
jupiter
.
api
.
Assertions
;
import
org
.
junit
.
jupiter
.
api
.
Test
;
import
java
.
util
.
NoSuchElementException
;
public
class
LRUCacheTest
{
@
Test
public
void
testLFUCache
() {
LRUCache
<
Integer
>
cache
=
new
LRUCache
<
Integer
>(
2
);
cache
.
put
(
1
,
5
);
cache
.
put
(
2
,
4
);
Assertions
.
assertEquals
(
5
,
cache
.
get
(
1
));
// returns 5
cache
.
put
(
3
,
6
);
// evicts key 2
Assertions
.
assertThrows
(
NoSuchElementException
.
class
, () ->
cache
.
get
(
7
));
// throws exception
Assertions
.
assertEquals
(
6
,
cache
.
get
(
3
));
// returns 6.
cache
.
put
(
4
,
8
);
// evicts key 1.
Assertions
.
assertThrows
(
NoSuchElementException
.
class
, () ->
cache
.
get
(
1
));
// throws exception
Assertions
.
assertEquals
(
6
,
cache
.
get
(
3
));
// returns 6
Assertions
.
assertEquals
(
8
,
cache
.
get
(
4
));
// returns 8
}
}
Back
|
FazBrowse Home
|
New Git URL