| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef NET_CERT_INTERNAL_TEST_HELPERS_H_ | 5 #ifndef NET_CERT_INTERNAL_TEST_HELPERS_H_ |
| 6 #define NET_CERT_INTERNAL_TEST_HELPERS_H_ | 6 #define NET_CERT_INTERNAL_TEST_HELPERS_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include <ostream> | 10 #include <ostream> |
| 11 #include <string> | 11 #include <string> |
| 12 #include <vector> | 12 #include <vector> |
| 13 | 13 |
| 14 #include "net/der/input.h" | 14 #include "net/der/input.h" |
| 15 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
| 16 | 16 |
| 17 namespace net { | 17 namespace net { |
| 18 | 18 |
| 19 namespace der { | 19 namespace der { |
| 20 | 20 |
| 21 // These functions are used by GTest to support EXPECT_EQ() for | 21 // These functions are used by GTest to support EXPECT_EQ() for |
| 22 // der::Input. | 22 // der::Input. |
| 23 void PrintTo(const Input& data, ::std::ostream* os); | 23 void PrintTo(const Input& data, ::std::ostream* os); |
| 24 bool operator==(const Input& a, const Input& b); | 24 bool operator==(const Input& a, const Input& b); |
| 25 | 25 |
| 26 } // namespace der | 26 } // namespace der |
| 27 | 27 |
| 28 // Creates a der::Input from an std::string. The lifetimes are a bit subtle | |
| 29 // when using this function: | |
| 30 // | |
| 31 // The returned der::Input() is only valid so long as the input string is alive | |
| 32 // and is not mutated. | |
| 33 // | |
| 34 // Note that the input parameter has been made a pointer to prevent callers | |
| 35 // from accidentally passing an r-value. | |
| 36 der::Input InputFromString(const std::string* s); | |
| 37 | |
| 38 // Parses |s| as a DER SEQUENCE TLV and returns a der::Input corresponding to | 28 // Parses |s| as a DER SEQUENCE TLV and returns a der::Input corresponding to |
| 39 // the value portion. On error returns an empty der::Input and adds a gtest | 29 // the value portion. On error returns an empty der::Input and adds a gtest |
| 40 // failure. | 30 // failure. |
| 41 // | 31 // |
| 42 // The returned der::Input() is only valid so long as the input string is alive | 32 // The returned der::Input() is only valid so long as the input string is alive |
| 43 // and is not mutated. | 33 // and is not mutated. |
| 44 der::Input SequenceValueFromString(const std::string* s); | 34 der::Input SequenceValueFromString(const std::string* s); |
| 45 | 35 |
| 46 // Helper structure that maps a PEM block header (for instance "CERTIFICATE") to | 36 // Helper structure that maps a PEM block header (for instance "CERTIFICATE") to |
| 47 // the destination where the value for that block should be written. | 37 // the destination where the value for that block should be written. |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 template <size_t N> | 72 template <size_t N> |
| 83 ::testing::AssertionResult ReadTestDataFromPemFile( | 73 ::testing::AssertionResult ReadTestDataFromPemFile( |
| 84 const std::string& file_path_ascii, | 74 const std::string& file_path_ascii, |
| 85 const PemBlockMapping(&mappings)[N]) { | 75 const PemBlockMapping(&mappings)[N]) { |
| 86 return ReadTestDataFromPemFile(file_path_ascii, mappings, N); | 76 return ReadTestDataFromPemFile(file_path_ascii, mappings, N); |
| 87 } | 77 } |
| 88 | 78 |
| 89 } // namespace net | 79 } // namespace net |
| 90 | 80 |
| 91 #endif // NET_CERT_INTERNAL_TEST_HELPERS_H_ | 81 #endif // NET_CERT_INTERNAL_TEST_HELPERS_H_ |
| OLD | NEW |