src/net/quic/quic_client_session_cache_unittests.cc
// Tests that simple insertion and lookup work correctly.
Tests that simple insertion and lookup work correctly.
Tests that simple insertion and lookup work correctly .
TEST_F(QuicClientSessionCacheTest, Basic) {
  QuicClientSessionCache cache;
  std::unique_ptr<quic::QuicResumptionState> state1 =
      std::make_unique<quic::QuicResumptionState>();
  state1->application_state.push_back('a');
  state1->tls_session = NewSSLSession();
  quic::QuicServerId id1("a.com", 443);
  std::unique_ptr<quic::QuicResumptionState> state2 =
      std::make_unique<quic::QuicResumptionState>();
  state2->application_state.push_back('b');
  state2->tls_session = NewSSLSession();
  quic::QuicServerId id2("b.com", 443);
  EXPECT_EQ(nullptr, cache.Lookup(id1, ssl_ctx_.get()));
  EXPECT_EQ(nullptr, cache.Lookup(id2, ssl_ctx_.get()));
  EXPECT_EQ(0u, cache.size());
  cache.Insert(id1, std::move(state1));
  EXPECT_EQ(1u, cache.size());
  EXPECT_EQ('a', cache.Lookup(id1, ssl_ctx_.get())->application_state.front());
  EXPECT_EQ(nullptr, cache.Lookup(id2, ssl_ctx_.get()));
  std::unique_ptr<quic::QuicResumptionState> state3 =
      std::make_unique<quic::QuicResumptionState>();
  state3->application_state.push_back('c');
  state3->tls_session = NewSSLSession();
  quic::QuicServerId id3("c.com", 443);
  cache.Insert(id3, std::move(state3));
  cache.Insert(id2, std::move(state2));
  EXPECT_EQ(2u, cache.size());
  EXPECT_EQ('b', cache.Lookup(id2, ssl_ctx_.get())->application_state.front());
  EXPECT_EQ('c', cache.Lookup(id3, ssl_ctx_.get())->application_state.front());
  EXPECT_EQ(nullptr, cache.Lookup(id1, ssl_ctx_.get()));
  EXPECT_EQ(nullptr, cache.Lookup(id2, ssl_ctx_.get()));
  EXPECT_EQ(nullptr, cache.Lookup(id3, ssl_ctx_.get()));
  EXPECT_EQ(0u, cache.size());
}
TEST_F ( QuicClientSessionCacheTest , Basic ) { QuicClientSessionCache cache ; std :: unique_ptr < quic :: QuicResumptionState > state1 = std :: make_unique < quic :: QuicResumptionState > ( ) ; state1 -> application_state . push_back ( ' ' ) ; state1 -> tls_session = NewSSLSession ( ) ; quic :: QuicServerId id1 ( " " , 443 ) ; std :: unique_ptr < quic :: QuicResumptionState > state2 = std :: make_unique < quic :: QuicResumptionState > ( ) ; state2 -> application_state . push_back ( ' ' ) ; state2 -> tls_session = NewSSLSession ( ) ; quic :: QuicServerId id2 ( " " , 443 ) ; EXPECT_EQ ( nullptr , cache . Lookup ( id1 , ssl_ctx_ . get ( ) ) ) ; EXPECT_EQ ( nullptr , cache . Lookup ( id2 , ssl_ctx_ . get ( ) ) ) ; EXPECT_EQ ( 0u , cache . size ( ) ) ; cache . Insert ( id1 , std :: move ( state1 ) ) ; EXPECT_EQ ( 1u , cache . size ( ) ) ; EXPECT_EQ ( ' ' , cache . Lookup ( id1 , ssl_ctx_ . get ( ) ) -> application_state . front ( ) ) ; EXPECT_EQ ( nullptr , cache . Lookup ( id2 , ssl_ctx_ . get ( ) ) ) ; std :: unique_ptr < quic :: QuicResumptionState > state3 = std :: make_unique < quic :: QuicResumptionState > ( ) ; state3 -> application_state . push_back ( ' ' ) ; state3 -> tls_session = NewSSLSession ( ) ; quic :: QuicServerId id3 ( " " , 443 ) ; cache . Insert ( id3 , std :: move ( state3 ) ) ; cache . Insert ( id2 , std :: move ( state2 ) ) ; EXPECT_EQ ( 2u , cache . size ( ) ) ; EXPECT_EQ ( ' ' , cache . Lookup ( id2 , ssl_ctx_ . get ( ) ) -> application_state . front ( ) ) ; EXPECT_EQ ( ' ' , cache . Lookup ( id3 , ssl_ctx_ . get ( ) ) -> application_state . front ( ) ) ; EXPECT_EQ ( nullptr , cache . Lookup ( id1 , ssl_ctx_ . get ( ) ) ) ; EXPECT_EQ ( nullptr , cache . Lookup ( id2 , ssl_ctx_ . get ( ) ) ) ; EXPECT_EQ ( nullptr , cache . Lookup ( id3 , ssl_ctx_ . get ( ) ) ) ; EXPECT_EQ ( 0u , cache . size ( ) ) ; }
Tests that simple insertion and lookup work correctly.
Tests that simple insertion and lookup work correctly .
// Verify that the cache is cleared after Lookups.