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

Side by Side Diff: testing/fx_string_testhelpers.cpp

Issue 1840483003: Reduce signed/unsigned comparison warnings (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 4 years, 9 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium 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 #include "testing/fx_string_testhelpers.h" 5 #include "testing/fx_string_testhelpers.h"
6 6
7 #include <iomanip> 7 #include <iomanip>
8 #include <ios> 8 #include <ios>
9 9
10 namespace { 10 namespace {
11 11
12 template <typename T> 12 template <typename T>
13 std::ostream& output_string(std::ostream& out, const T& str) { 13 std::ostream& output_string(std::ostream& out, const T& str) {
14 out << std::hex << std::setfill('0') << '"'; 14 out << std::hex << std::setfill('0') << '"';
15 for (size_t i = 0; i < str.GetLength(); ++i) { 15 // This function is used for FX strings whose length is defined as int.
16 for (int i = 0; i < str.GetLength(); ++i) {
16 unsigned int c = str.GetAt(i); 17 unsigned int c = str.GetAt(i);
17 if (c >= 0x20 && c < 0x7F) { 18 if (c >= 0x20 && c < 0x7F) {
18 out << static_cast<char>(c); 19 out << static_cast<char>(c);
19 } else if (sizeof(typename T::value_type) == 1) { 20 } else if (sizeof(typename T::value_type) == 1) {
20 out << "\\x" << std::setw(2) << c << std::setw(0); 21 out << "\\x" << std::setw(2) << c << std::setw(0);
21 } else if (c < 0x10000) { 22 } else if (c < 0x10000) {
22 out << "\\u" << std::setw(4) << c << std::setw(0); 23 out << "\\u" << std::setw(4) << c << std::setw(0);
23 } else { 24 } else {
24 out << "<invalid>"; 25 out << "<invalid>";
25 } 26 }
(...skipping 12 matching lines...) Expand all
38 return output_string(out, str); 39 return output_string(out, str);
39 } 40 }
40 41
41 std::ostream& operator<<(std::ostream& out, const CFX_WideStringC& str) { 42 std::ostream& operator<<(std::ostream& out, const CFX_WideStringC& str) {
42 return output_string(out, str); 43 return output_string(out, str);
43 } 44 }
44 45
45 std::ostream& operator<<(std::ostream& out, const CFX_WideString& str) { 46 std::ostream& operator<<(std::ostream& out, const CFX_WideString& str) {
46 return output_string(out, str); 47 return output_string(out, str);
47 } 48 }
OLDNEW
« fpdfsdk/pdfwindow/PWL_FontMap.cpp ('K') | « fpdfsdk/pdfwindow/PWL_FontMap.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698