Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(79)

Unified Diff: net/tools/transport_security_state_generator/trie/trie_writer.h

Issue 2660793002: Add transport security state generator tests. (Closed)
Patch Set: export method for tests Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: net/tools/transport_security_state_generator/trie/trie_writer.h
diff --git a/net/tools/transport_security_state_generator/trie/trie_writer.h b/net/tools/transport_security_state_generator/trie/trie_writer.h
index 93fce3624f7193f8c5f281aaf643981d1b8372c3..e1147e23da1db41ac16ae455eb3e7ff85045b5bb 100644
--- a/net/tools/transport_security_state_generator/trie/trie_writer.h
+++ b/net/tools/transport_security_state_generator/trie/trie_writer.h
@@ -8,6 +8,7 @@
#include <string>
#include <vector>
+#include "base/gtest_prod_util.h"
#include "net/tools/transport_security_state_generator/bit_writer.h"
#include "net/tools/transport_security_state_generator/huffman/huffman_builder.h"
#include "net/tools/transport_security_state_generator/transport_security_state_entry.h"
@@ -40,7 +41,8 @@ class TrieWriter {
// Constructs a trie containing all |entries|. The output is written to
// |buffer_|. Returns the position of the trie root.
- uint32_t WriteEntries(const TransportSecurityStateEntries& entries);
+ bool WriteEntries(const TransportSecurityStateEntries& entries,
+ uint32_t* position);
// Returns the position |buffer_| is currently at. The returned value
// represents the number of bits.
@@ -54,11 +56,16 @@ class TrieWriter {
const std::vector<uint8_t>& bytes() const { return buffer_.bytes(); }
private:
- uint32_t WriteDispatchTables(ReversedEntries::iterator start,
- ReversedEntries::iterator end);
+ friend class TrieWriterTest;
+ FRIEND_TEST_ALL_PREFIXES(TrieWriterTest, ReverseName);
+ FRIEND_TEST_ALL_PREFIXES(TrieWriterTest, LongestCommonPrefix);
+
+ bool WriteDispatchTables(ReversedEntries::iterator start,
+ ReversedEntries::iterator end,
+ uint32_t* position);
// Serializes |*entry| and writes it to |*writer|.
- void WriteEntry(const TransportSecurityStateEntry* entry,
+ bool WriteEntry(const TransportSecurityStateEntry* entry,
TrieBitBuffer* writer);
// Removes the first |length| characters from all entries between |start| and
@@ -69,8 +76,9 @@ class TrieWriter {
// Searches for the longest common prefix for all entries between |start| and
// |end|.
- std::vector<uint8_t> LongestCommonPrefix(ReversedEntries::iterator start,
- ReversedEntries::iterator end) const;
+ std::vector<uint8_t> LongestCommonPrefix(
+ ReversedEntries::const_iterator start,
+ ReversedEntries::const_iterator end) const;
// Returns the reversed |hostname| as a vector of bytes. The reversed hostname
// will be terminated by |kTerminalValue|.

Powered by Google App Engine
This is Rietveld 408576698