1 package org.robolectric.shadows; 2 3 import static com.google.common.truth.Truth.assertThat; 4 5 import android.util.LruCache; 6 import androidx.test.ext.junit.runners.AndroidJUnit4; 7 import org.junit.Test; 8 import org.junit.runner.RunWith; 9 10 @RunWith(AndroidJUnit4.class) 11 public class ShadowLruTest { 12 13 @Test shouldLru()14 public void shouldLru() throws Exception { 15 LruCache<Integer, String> lruCache = new LruCache<>(2); 16 lruCache.put(1, "one"); 17 lruCache.put(2, "two"); 18 lruCache.put(3, "three"); 19 20 assertThat(lruCache.size()).isEqualTo(2); 21 assertThat(lruCache.get(1)).isNull(); 22 assertThat(lruCache.get(2)).isEqualTo("two"); 23 assertThat(lruCache.get(3)).isEqualTo("three"); 24 } 25 } 26