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

Side by Side Diff: sql/test/test_helpers.cc

Issue 145873006: ui/base/resource: Roll our own version of ReadBigEndian() function. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/websockets/websocket_frame_parser.cc ('k') | ui/base/resource/resource_bundle.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 #include "sql/test/test_helpers.h" 5 #include "sql/test/test_helpers.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "sql/connection.h" 10 #include "sql/connection.h"
(...skipping 24 matching lines...) Expand all
35 const char kPageSql[] = "SELECT rootpage FROM sqlite_master WHERE name = ?"; 35 const char kPageSql[] = "SELECT rootpage FROM sqlite_master WHERE name = ?";
36 sql::Statement s(db->GetUniqueStatement(kPageSql)); 36 sql::Statement s(db->GetUniqueStatement(kPageSql));
37 s.BindString(0, name); 37 s.BindString(0, name);
38 if (!s.Step()) 38 if (!s.Step())
39 return false; 39 return false;
40 *page_number = s.ColumnInt(0); 40 *page_number = s.ColumnInt(0);
41 return true; 41 return true;
42 } 42 }
43 43
44 // Helper for reading a number from the SQLite header. 44 // Helper for reading a number from the SQLite header.
45 // See net/base/big_endian.h. 45 // See base/big_endian.h.
46 unsigned ReadBigEndian(unsigned char* buf, size_t bytes) { 46 unsigned ReadBigEndian(unsigned char* buf, size_t bytes) {
47 unsigned r = buf[0]; 47 unsigned r = buf[0];
48 for (size_t i = 1; i < bytes; i++) { 48 for (size_t i = 1; i < bytes; i++) {
49 r <<= 8; 49 r <<= 8;
50 r |= buf[i]; 50 r |= buf[i];
51 } 51 }
52 return r; 52 return r;
53 } 53 }
54 54
55 // Helper for writing a number to the SQLite header. 55 // Helper for writing a number to the SQLite header.
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 sql::Statement statement(db->GetUniqueStatement("PRAGMA integrity_check")); 241 sql::Statement statement(db->GetUniqueStatement("PRAGMA integrity_check"));
242 242
243 // SQLite should always return a row of data. 243 // SQLite should always return a row of data.
244 EXPECT_TRUE(statement.Step()); 244 EXPECT_TRUE(statement.Step());
245 245
246 return statement.ColumnString(0); 246 return statement.ColumnString(0);
247 } 247 }
248 248
249 } // namespace test 249 } // namespace test
250 } // namespace sql 250 } // namespace sql
OLDNEW
« no previous file with comments | « net/websockets/websocket_frame_parser.cc ('k') | ui/base/resource/resource_bundle.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698