VCDiffAddressCache { public abstract short EncodeAddress(int address, int here_address, AtomicInteger encoded_addr); protected  VCDiffAddressCache(); protected  VCDiffAddressCache(short near_cache_size, short same_cache_size); abstract void Init(); short FirstSameMode(); short LastMode(); final int DecodeSameAddress(short mode, short encoded_address); final boolean WriteAddressAsVarintForMode(short mode); abstract void UpdateCache(int address); abstract short EncodeAddress(int address,
            int here_address,
            AtomicInteger encoded_addr); abstract int DecodeAddress(int here_address, short vcDiffMode, ByteBuffer address_stream); static final short VCD_SELF_MODE; static final short VCD_HERE_MODE; static final short VCD_FIRST_NEAR_MODE; static final short VCD_MAX_MODES; }
@Test public void EncodeAddressZeroCacheSizes() { AtomicInteger encoded_addr = new AtomicInteger(); VCDiffAddressCacheImpl zero_cache = new VCDiffAddressCacheImpl((short) 0, (short) 0); assertEquals(VCDiffAddressCache.VCD_SELF_MODE, zero_cache.EncodeAddress(0x0000FFFF, 0x10000000, encoded_addr)); assertEquals(0xFFFF, encoded_addr.get()); assertEquals(VCDiffAddressCache.VCD_HERE_MODE, zero_cache.EncodeAddress(0x10000000, 0x10000010, encoded_addr)); assertEquals(0x10, encoded_addr.get()); assertEquals(VCDiffAddressCache.VCD_HERE_MODE, zero_cache.EncodeAddress(0x10000004, 0x10000020, encoded_addr)); assertEquals(0x1C, encoded_addr.get()); assertEquals(VCDiffAddressCache.VCD_HERE_MODE, zero_cache.EncodeAddress(0x0FFFFFFE, 0x10000030, encoded_addr)); assertEquals(0x32, encoded_addr.get()); assertEquals(VCDiffAddressCache.VCD_HERE_MODE, zero_cache.EncodeAddress(0x10000004, 0x10000040, encoded_addr)); assertEquals(0x3C, encoded_addr.get()); }