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

Side by Side Diff: debugger/rsp/rsp_blob_utils_test.cc

Issue 7466014: Add rsp::GetOffsets command + reply (Closed) Base URL: http://nativeclient-sdk.googlecode.com/svn/trunk/src/
Patch Set: Created 9 years, 5 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
OLDNEW
1 // Copyright (c) 2011 The Native Client Authors. All rights reserved. 1 // Copyright (c) 2011 The Native Client 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 #include "debugger/rsp/rsp_blob_utils.h" 4 #include "debugger/rsp/rsp_blob_utils.h"
5 #include "gtest/gtest.h" 5 #include "gtest/gtest.h"
6 6
7 namespace { 7 namespace {
8 // BlobUtilsTest test fixture. 8 // BlobUtilsTest test fixture.
9 class BlobUtilsTest : public ::testing::Test { 9 class BlobUtilsTest : public ::testing::Test {
10 public: 10 public:
11 BlobUtilsTest() {} 11 BlobUtilsTest() {}
12 void LoadBlob(const char* str) { blob_.FromString(str); } 12 void LoadBlob(const char* str) { blob_.FromString(str); }
13 13
14 debug::Blob blob_; 14 debug::Blob blob_;
15 }; 15 };
16 16
17 #define EXPECT_BLOBEQ(x, y) EXPECT_STREQ(x, y.ToString().c_str()); y.Clear()
18
17 // Unit tests start here. 19 // Unit tests start here.
18 TEST_F(BlobUtilsTest, PopInt8FromFront) { 20 TEST_F(BlobUtilsTest, PopInt8FromFront) {
19 LoadBlob("10abcd"); 21 LoadBlob("10abcd");
20 uint8_t v = 0; 22 uint8_t v = 0;
21 EXPECT_TRUE(rsp::PopIntFromFront(&blob_, &v)); 23 EXPECT_TRUE(rsp::PopIntFromFront(&blob_, &v));
22 EXPECT_EQ(0x10, v); 24 EXPECT_EQ(0x10, v);
23 EXPECT_STREQ("abcd", blob_.ToString().c_str()); 25 EXPECT_STREQ("abcd", blob_.ToString().c_str());
24 26
25 LoadBlob("f"); 27 LoadBlob("f");
26 v = 0; 28 v = 0;
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 } 114 }
113 115
114 TEST_F(BlobUtilsTest, Format) { 116 TEST_F(BlobUtilsTest, Format) {
115 rsp::Format(&blob_, "[%s]", "abcd"); 117 rsp::Format(&blob_, "[%s]", "abcd");
116 EXPECT_STREQ("[abcd]", blob_.ToString().c_str()); 118 EXPECT_STREQ("[abcd]", blob_.ToString().c_str());
117 119
118 rsp::Format(&blob_, "[%d]", 12345); 120 rsp::Format(&blob_, "[%d]", 12345);
119 EXPECT_STREQ("[12345]", blob_.ToString().c_str()); 121 EXPECT_STREQ("[12345]", blob_.ToString().c_str());
120 122
121 rsp::Format(&blob_, "[%d-%x]", 12345, 0x1234); 123 rsp::Format(&blob_, "[%d-%x]", 12345, 0x1234);
122 EXPECT_STREQ("[12345-1234]", blob_.ToString().c_str()); 124 EXPECT_BLOBEQ("[12345-1234]", blob_);
125 }
126
127 TEST_F(BlobUtilsTest, PushIntToBack) {
128 uint32_t x = 0;
129 debug::Blob blob;
130 EXPECT_BLOBEQ("0", rsp::PushIntToBack(x, &blob));
131
132 x = 0x21;
133 EXPECT_BLOBEQ("21", rsp::PushIntToBack(x, &blob));
134
135 x = 0x1234;
136 EXPECT_BLOBEQ("1234", rsp::PushIntToBack(x, &blob));
137
138 x = 0x0234;
139 EXPECT_BLOBEQ("234", rsp::PushIntToBack(x, &blob));
140
141 uint64_t y = 0;
142 EXPECT_BLOBEQ("0", rsp::PushIntToBack(y, &blob));
143
144 y = 0x21;
145 EXPECT_BLOBEQ("21", rsp::PushIntToBack(y, &blob));
146
147 y = 0x1234;
148 EXPECT_BLOBEQ("1234", rsp::PushIntToBack(y, &blob));
149
150 y = 0x0234;
151 EXPECT_BLOBEQ("234", rsp::PushIntToBack(y, &blob));
152
153 y = 0x1234567890abcdef;
154 EXPECT_BLOBEQ("1234567890abcdef", rsp::PushIntToBack(y, &blob));
155
156 y = 0x234567890abcdef;
157 EXPECT_BLOBEQ("234567890abcdef", rsp::PushIntToBack(y, &blob));
158
159 y = 0x34567890abcdef;
160 EXPECT_BLOBEQ("34567890abcdef", rsp::PushIntToBack(y, &blob));
123 } 161 }
124 162
125 } // namespace 163 } // namespace
126 164
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698