src/net/dns/esni_content_unittest.cc
// Test merging some more complex instances of the class.
Test merging some more complex instances of the class.
Test merging some more complex instances of the class .
TEST(EsniContentTest, MergeSeveralHostsAndKeys) {
  EsniContent c1, c2, expected;
  for (int i = 0; i < 50; ++i) {
    IPAddress address = MakeIPAddress();
    std::string key = base::NumberToString(i);
    switch (i % 3) {
      case 0:
        c1.AddKey(key);
        expected.AddKey(key);
        break;
      case 1:
        c2.AddKey(key);
        expected.AddKey(key);
        break;
    }
    {
      int j = 0;
      for (auto key : c1.keys()) {
        if (j % 2) {
          c1.AddKeyForAddress(address, key);
          expected.AddKeyForAddress(address, key);
        }
        ++j;
      }
    }
    {
      int j = 0;
      for (auto key : c2.keys()) {
        if (j % 3 == 1) {
          c2.AddKeyForAddress(address, key);
          expected.AddKeyForAddress(address, key);
        }
        ++j;
      }
    }
  }
  {
    EsniContent merge_dest = c1;
    EsniContent merge_src = c2;
    merge_dest.MergeFrom(merge_src);
    EXPECT_EQ(merge_dest, expected);
  }
  {
    EsniContent merge_dest = c2;
    EsniContent merge_src = c1;
    merge_dest.MergeFrom(merge_src);
    EXPECT_EQ(merge_dest, expected);
  }
}
TEST ( EsniContentTest , MergeSeveralHostsAndKeys ) { EsniContent c1 , c2 , expected ; for ( int i = 0 ; i < 50 ; ++ i ) { IPAddress address = MakeIPAddress ( ) ; std :: string key = base :: NumberToString ( i ) ; switch ( i % 3 ) { case 0 : c1 . AddKey ( key ) ; expected . AddKey ( key ) ; break ; case 1 : c2 . AddKey ( key ) ; expected . AddKey ( key ) ; break ; } { int j = 0 ; for ( auto key : c1 . keys ( ) ) { if ( j % 2 ) { c1 . AddKeyForAddress ( address , key ) ; expected . AddKeyForAddress ( address , key ) ; } ++ j ; } } { int j = 0 ; for ( auto key : c2 . keys ( ) ) { if ( j % 3 == 1 ) { c2 . AddKeyForAddress ( address , key ) ; expected . AddKeyForAddress ( address , key ) ; } ++ j ; } } } { EsniContent merge_dest = c1 ; EsniContent merge_src = c2 ; merge_dest . MergeFrom ( merge_src ) ; EXPECT_EQ ( merge_dest , expected ) ; } { EsniContent merge_dest = c2 ; EsniContent merge_src = c1 ; merge_dest . MergeFrom ( merge_src ) ; EXPECT_EQ ( merge_dest , expected ) ; } }
Test merging some more complex instances of the class.
Test merging some more complex instances of the class .
// Associate each address with a subset of the keys seen so far