### Question:
SimpleCache implements Cache { @Override public synchronized long getCachedLength(String key, long position, long length) { Assertions.checkState(!released); CachedContent cachedContent = contentIndex.get(key); return cachedContent != null ? cachedContent.getCachedBytesLength(position, length) : -length; } @Deprecated  SimpleCache(File cacheDir, CacheEvictor evictor); @Deprecated  SimpleCache(File cacheDir, CacheEvictor evictor, @Nullable byte[] secretKey); @Deprecated  SimpleCache(
      File cacheDir, CacheEvictor evictor, @Nullable byte[] secretKey, boolean encrypt);  SimpleCache(File cacheDir, CacheEvictor evictor, DatabaseProvider databaseProvider);  SimpleCache(
      File cacheDir,
      CacheEvictor evictor,
      @Nullable DatabaseProvider databaseProvider,
      @Nullable byte[] legacyIndexSecretKey,
      boolean legacyIndexEncrypt,
      boolean preferLegacyIndex);   SimpleCache(
      File cacheDir,
      CacheEvictor evictor,
      CachedContentIndex contentIndex,
      @Nullable CacheFileMetadataIndex fileIndex); static synchronized boolean isCacheFolderLocked(File cacheFolder); @Deprecated static synchronized void disableCacheFolderLocking(); @Deprecated static void disableCacheInitializationExceptions(); static void delete(File cacheDir, @Nullable DatabaseProvider databaseProvider); synchronized void checkInitialization(); @Override synchronized long getUid(); @Override synchronized void release(); @Override synchronized NavigableSet<CacheSpan> addListener(String key, Listener listener); @Override synchronized void removeListener(String key, Listener listener); @NonNull @Override synchronized NavigableSet<CacheSpan> getCachedSpans(String key); @Override synchronized Set<String> getKeys(); @Override synchronized long getCacheSpace(); @Override synchronized SimpleCacheSpan startReadWrite(String key, long position); @Override @Nullable synchronized SimpleCacheSpan startReadWriteNonBlocking(String key, long position); @Override synchronized File startFile(String key, long position, long length); @Override synchronized void commitFile(File file, long length); @Override synchronized void releaseHoleSpan(CacheSpan holeSpan); @Override synchronized void removeSpan(CacheSpan span); @Override synchronized boolean isCached(String key, long position, long length); @Override synchronized long getCachedLength(String key, long position, long length); @Override synchronized void applyContentMetadataMutations(
      String key, ContentMetadataMutations mutations); @Override synchronized ContentMetadata getContentMetadata(String key);  }### Answer:
@Test public void testGetCachedLength() throws Exception { SimpleCache simpleCache = getSimpleCache(); CacheSpan cacheSpan = simpleCache.startReadWrite(KEY_1, 0); assertThat(simpleCache.getCachedLength(KEY_1, 0, 100)).isEqualTo(-100); assertThat(simpleCache.getCachedLength(KEY_1, 20, 100)).isEqualTo(-100); addCache(simpleCache, KEY_1, 0, 15); assertThat(simpleCache.getCachedLength(KEY_1, 0, 100)).isEqualTo(15); assertThat(simpleCache.getCachedLength(KEY_1, 0, 10)).isEqualTo(10); addCache(simpleCache, KEY_1, 15, 35); assertThat(simpleCache.getCachedLength(KEY_1, 0, 100)).isEqualTo(50); addCache(simpleCache, KEY_1, 60, 10); assertThat(simpleCache.getCachedLength(KEY_1, 0, 100)).isEqualTo(50); assertThat(simpleCache.getCachedLength(KEY_1, 55, 100)).isEqualTo(-5); simpleCache.releaseHoleSpan(cacheSpan); }