Skip to content

Commit

Permalink
add missing asserts to openjdk tests that check only in their custom …
Browse files Browse the repository at this point in the history
…harness
  • Loading branch information
ben-manes committed Jan 5, 2025
1 parent a9846ae commit ae21802
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
*/
package com.github.benmanes.caffeine.openjdk.concurrent.concurrentmap;

import static com.google.common.truth.Truth.assertThat;
import static java.util.Locale.US;

/*
Expand Down Expand Up @@ -114,16 +115,20 @@ public static void main(String[] args) {

@Test
public void bounded() {
Cache<Integer,Integer> cache = Caffeine.newBuilder()
testCaffeine(Caffeine.newBuilder()
.expireAfterWrite(Duration.ofNanos(Long.MAX_VALUE))
.maximumSize(Long.MAX_VALUE)
.build();
test(cache.asMap());
.build());
}

@Test
public void unbounded() {
Cache<Integer,Integer> cache = Caffeine.newBuilder().build();
testCaffeine(Caffeine.newBuilder().build());
}

private static void testCaffeine(Cache<Integer,Integer> cache) {
test(cache.asMap());
assertThat(failed).isEqualTo(0);
assertThat(passed).isGreaterThan(0);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
*/
package com.github.benmanes.caffeine.openjdk.map;

import static com.google.common.truth.Truth.assertThat;
import static java.util.Locale.US;

import java.time.Duration;
Expand Down Expand Up @@ -57,17 +58,21 @@ public class Get {

@Test
public void bounded() {
Cache<Character, Boolean> cache = Caffeine.newBuilder()
testCaffeine(Caffeine.newBuilder()
.expireAfterWrite(Duration.ofNanos(Long.MAX_VALUE))
.maximumSize(Long.MAX_VALUE)
.build();
testMap(cache.asMap());
.build());
}

@Test
public void unbounded() {
Cache<Character, Boolean> cache = Caffeine.newBuilder().build();
testCaffeine(Caffeine.newBuilder().build());
}

private static void testCaffeine(Cache<Character, Boolean> cache) {
testMap(cache.asMap());
assertThat(failed).isEqualTo(0);
assertThat(passed).isGreaterThan(0);
}

private static void realMain(String[] args) throws Throwable {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
*/
package com.github.benmanes.caffeine.openjdk.map;

import static com.google.common.truth.Truth.assertThat;
import static java.util.Locale.US;

import java.time.Duration;
Expand Down Expand Up @@ -141,11 +142,15 @@ public void bounded() {
.expireAfterWrite(Duration.ofNanos(Long.MAX_VALUE))
.maximumSize(Long.MAX_VALUE)
.build().asMap());
assertThat(failed).isEqualTo(0);
assertThat(passed).isGreaterThan(0);
}

@Test
public void unbounded() {
test(() -> Caffeine.newBuilder().build().asMap());
assertThat(failed).isEqualTo(0);
assertThat(passed).isGreaterThan(0);
}

//--------------------- Infrastructure ---------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
*/
package com.github.benmanes.caffeine.openjdk.map;

import static com.google.common.truth.Truth.assertThat;
import static java.util.Locale.US;

import java.time.Duration;
Expand Down Expand Up @@ -62,17 +63,21 @@ public class ToArray {

@Test
public void bounded() throws Exception {
Cache<Integer, Long> cache = Caffeine.newBuilder()
testCaffeine(Caffeine.newBuilder()
.expireAfterWrite(Duration.ofNanos(Long.MAX_VALUE))
.maximumSize(Long.MAX_VALUE)
.build();
testMap(cache.asMap());
.build());
}

@Test
public void unbounded() throws Exception {
Cache<Integer, Long> cache = Caffeine.newBuilder().build();
testCaffeine(Caffeine.newBuilder().build());
}

private static void testCaffeine(Cache<Integer, Long> cache) {
testMap(cache.asMap());
assertThat(failed).isEqualTo(0);
assertThat(passed).isGreaterThan(0);
}

private static void realMain(String[] args) throws Throwable {
Expand Down

0 comments on commit ae21802

Please sign in to comment.