OLD | NEW |
1 // Copyright 2014 The Crashpad Authors. All rights reserved. | 1 // Copyright 2014 The Crashpad Authors. All rights reserved. |
2 // | 2 // |
3 // Licensed under the Apache License, Version 2.0 (the "License"); | 3 // Licensed under the Apache License, Version 2.0 (the "License"); |
4 // you may not use this file except in compliance with the License. | 4 // you may not use this file except in compliance with the License. |
5 // You may obtain a copy of the License at | 5 // You may obtain a copy of the License at |
6 // | 6 // |
7 // http://www.apache.org/licenses/LICENSE-2.0 | 7 // http://www.apache.org/licenses/LICENSE-2.0 |
8 // | 8 // |
9 // Unless required by applicable law or agreed to in writing, software | 9 // Unless required by applicable law or agreed to in writing, software |
10 // distributed under the License is distributed on an "AS IS" BASIS, | 10 // distributed under the License is distributed on an "AS IS" BASIS, |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 // least one U+FFFD replacement character was written. | 126 // least one U+FFFD replacement character was written. |
127 ASSERT_GE(file_writer.string().size(), | 127 ASSERT_GE(file_writer.string().size(), |
128 sizeof(MINIDUMP_STRING) + 2 * sizeof(MINIDUMP_STRING::Buffer[0])); | 128 sizeof(MINIDUMP_STRING) + 2 * sizeof(MINIDUMP_STRING::Buffer[0])); |
129 const MINIDUMP_STRING* minidump_string = MinidumpStringCast(file_writer); | 129 const MINIDUMP_STRING* minidump_string = MinidumpStringCast(file_writer); |
130 EXPECT_EQ(file_writer.string().size() - sizeof(MINIDUMP_STRING) - | 130 EXPECT_EQ(file_writer.string().size() - sizeof(MINIDUMP_STRING) - |
131 sizeof(MINIDUMP_STRING::Buffer[0]), | 131 sizeof(MINIDUMP_STRING::Buffer[0]), |
132 minidump_string->Length); | 132 minidump_string->Length); |
133 size_t out_units = | 133 size_t out_units = |
134 minidump_string->Length / sizeof(minidump_string->Buffer[0]); | 134 minidump_string->Length / sizeof(minidump_string->Buffer[0]); |
135 EXPECT_EQ(0, minidump_string->Buffer[out_units]); | 135 EXPECT_EQ(0, minidump_string->Buffer[out_units]); |
136 EXPECT_NE(reinterpret_cast<char16*>(NULL), | 136 EXPECT_NE(nullptr, |
137 base::c16memchr(minidump_string->Buffer, 0xfffd, out_units)); | 137 base::c16memchr(minidump_string->Buffer, 0xfffd, out_units)); |
138 } | 138 } |
139 } | 139 } |
140 | 140 |
141 const MinidumpUTF8String* MinidumpUTF8StringCast( | 141 const MinidumpUTF8String* MinidumpUTF8StringCast( |
142 const StringFileWriter& file_writer) { | 142 const StringFileWriter& file_writer) { |
143 return reinterpret_cast<const MinidumpUTF8String*>(&file_writer.string()[0]); | 143 return reinterpret_cast<const MinidumpUTF8String*>(&file_writer.string()[0]); |
144 } | 144 } |
145 | 145 |
146 TEST(MinidumpStringWriter, MinidumpUTF8StringWriter) { | 146 TEST(MinidumpStringWriter, MinidumpUTF8StringWriter) { |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 EXPECT_EQ(0, | 194 EXPECT_EQ(0, |
195 memcmp(kTestData[index].string, | 195 memcmp(kTestData[index].string, |
196 minidump_string->Buffer, | 196 minidump_string->Buffer, |
197 expected_utf8_bytes_with_nul)); | 197 expected_utf8_bytes_with_nul)); |
198 } | 198 } |
199 } | 199 } |
200 | 200 |
201 } // namespace | 201 } // namespace |
202 } // namespace test | 202 } // namespace test |
203 } // namespace crashpad | 203 } // namespace crashpad |
OLD | NEW |