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

Unified Diff: icu46/source/test/intltest/testutil.cpp

Issue 5516007: Check in the pristine copy of ICU 4.6... (Closed) Base URL: svn://chrome-svn/chrome/trunk/deps/third_party/
Patch Set: Created 10 years 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
« no previous file with comments | « icu46/source/test/intltest/testutil.h ('k') | icu46/source/test/intltest/textfile.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: icu46/source/test/intltest/testutil.cpp
===================================================================
--- icu46/source/test/intltest/testutil.cpp (revision 0)
+++ icu46/source/test/intltest/testutil.cpp (revision 0)
@@ -0,0 +1,61 @@
+/*
+**********************************************************************
+* Copyright (C) 2001-2009, International Business Machines
+* Corporation and others. All Rights Reserved.
+**********************************************************************
+* Date Name Description
+* 05/23/00 aliu Creation.
+**********************************************************************
+*/
+
+#include "unicode/unistr.h"
+#include "testutil.h"
+
+static const UChar HEX[16]={48,49,50,51,52,53,54,55,56,57,65,66,67,68,69,70};
+
+UnicodeString &TestUtility::appendHex(UnicodeString &buf, UChar32 ch) {
+ if (ch >= 0x10000) {
+ if (ch >= 0x100000) {
+ buf.append(HEX[0xF&(ch>>20)]);
+ }
+ buf.append(HEX[0xF&(ch>>16)]);
+ }
+ buf.append(HEX[0xF&(ch>>12)]);
+ buf.append(HEX[0xF&(ch>>8)]);
+ buf.append(HEX[0xF&(ch>>4)]);
+ buf.append(HEX[0xF&ch]);
+ return buf;
+}
+
+UnicodeString TestUtility::hex(UChar32 ch) {
+ UnicodeString buf;
+ appendHex(buf, ch);
+ return buf;
+}
+
+UnicodeString TestUtility::hex(const UnicodeString& s) {
+ return hex(s, 44 /*,*/);
+}
+
+UnicodeString TestUtility::hex(const UnicodeString& s, UChar sep) {
+ UnicodeString result;
+ if (s.isEmpty()) return result;
+ UChar32 c;
+ for (int32_t i = 0; i < s.length(); i += U16_LENGTH(c)) {
+ c = s.char32At(i);
+ if (i > 0) {
+ result.append(sep);
+ }
+ appendHex(result, c);
+ }
+ return result;
+}
+
+UnicodeString TestUtility::hex(const uint8_t* bytes, int32_t len) {
+ UnicodeString buf;
+ for (int32_t i = 0; i < len; ++i) {
+ buf.append(HEX[0x0F & (bytes[i] >> 4)]);
+ buf.append(HEX[0x0F & bytes[i]]);
+ }
+ return buf;
+}
Property changes on: icu46/source/test/intltest/testutil.cpp
___________________________________________________________________
Added: svn:eol-style
+ LF
« no previous file with comments | « icu46/source/test/intltest/testutil.h ('k') | icu46/source/test/intltest/textfile.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698