src/net/tools/huffman_trie/huffman/huffman_builder_unittest.cc
TEST(HuffmanBuilderTest, NoMissingInputs) {
  HuffmanBuilder builder;
  HuffmanRepresentationTable encoding;
  for (uint8_t i = 0; i <= 127; i++) {
    if (i % 2) {
      for (uint8_t j = 0; j <= i % 5; j++) {
        builder.RecordUsage(i);
      }
    }
  }

  encoding = builder.ToTable();
  for (uint8_t i = 0; i <= 127; i++) {
    if (i % 2) {
      EXPECT_NE(encoding.find(i), encoding.cend());
    } else {
      EXPECT_EQ(encoding.find(i), encoding.cend());
    }
  }
}
// Test that all recorded characters get a representation and that no other
// representations are created.
// Note: There is an exception for encodings with less than 2 unique inputs.
Test that all recorded characters get a representation and that no other
representations are created.
Note: There is an exception for encodings with less than 2 unique inputs.
Test that all recorded characters get a representation and that no other representations are created . Note : There is an exception for encodings with less than 2 unique inputs .
TEST(HuffmanBuilderTest, NoMissingInputs) {
  HuffmanBuilder builder;
  HuffmanRepresentationTable encoding;
  for (uint8_t i = 0; i <= 127; i++) {
    if (i % 2) {
      for (uint8_t j = 0; j <= i % 5; j++) {
        builder.RecordUsage(i);
      }
    }
  }
  encoding = builder.ToTable();
  for (uint8_t i = 0; i <= 127; i++) {
    if (i % 2) {
      EXPECT_NE(encoding.find(i), encoding.cend());
    } else {
      EXPECT_EQ(encoding.find(i), encoding.cend());
    }
  }
}
TEST ( HuffmanBuilderTest , NoMissingInputs ) { HuffmanBuilder builder ; HuffmanRepresentationTable encoding ; for ( uint8_t i = 0 ; i <= 127 ; i ++ ) { if ( i % 2 ) { for ( uint8_t j = 0 ; j <= i % 5 ; j ++ ) { builder . RecordUsage ( i ) ; } } } encoding = builder . ToTable ( ) ; for ( uint8_t i = 0 ; i <= 127 ; i ++ ) { if ( i % 2 ) { EXPECT_NE ( encoding . find ( i ) , encoding . cend ( ) ) ; } else { EXPECT_EQ ( encoding . find ( i ) , encoding . cend ( ) ) ; } } }
Test that all recorded characters get a representation and that no other
representations are created.
Test that all recorded characters get a representation and that no other representations are created .