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

Unified Diff: test/cctest/test-debug.cc

Issue 552043: Fix EVEN number of bugs in already passing test (Closed)
Patch Set: make sure line is zero-terminated Created 10 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/test-debug.cc
diff --git a/test/cctest/test-debug.cc b/test/cctest/test-debug.cc
index c79ab6a5eb0bdb0ccc28fd4ee841bdbcff687793..5c4575c7339e48fcaf577c9bb0e9b075f2276180 100644
--- a/test/cctest/test-debug.cc
+++ b/test/cctest/test-debug.cc
@@ -2197,13 +2197,25 @@ int Utf16ToAscii(const uint16_t* input_buffer, int length,
// We match parts of the message to get evaluate result int value.
bool GetEvaluateStringResult(char *message, char* buffer, int buffer_size) {
- const char* value = "\"value\":";
- char* pos = strstr(message, value);
- if (pos == NULL) {
+ if (strstr(message, "\"command\":\"evaluate\"") == NULL) {
+ return false;
+ }
+ const char* prefix = "\"text\":\"";
+ char* pos1 = strstr(message, prefix);
+ if (pos1 == NULL) {
+ return false;
+ }
+ pos1 += strlen(prefix);
+ char* pos2 = strchr(pos1, '"');
+ if (pos2 == NULL) {
return false;
}
Vector<char> buf(buffer, buffer_size);
- OS::StrNCpy(buf, pos, buffer_size - 1);
+ int len = pos2 - pos1;
+ if (len > buffer_size - 1) {
+ len = buffer_size - 1;
+ }
+ OS::StrNCpy(buf, pos1, len);
buffer[buffer_size - 1] = '\0';
return true;
}
@@ -2303,9 +2315,9 @@ TEST(DebugEvaluateWithoutStack) {
CHECK_EQ(3, process_debug_messages_data.counter);
- CHECK(strcmp("Pinguin", process_debug_messages_data.results[0].buffer));
- CHECK(strcmp("Captbara", process_debug_messages_data.results[1].buffer));
- CHECK(strcmp("805", process_debug_messages_data.results[2].buffer));
+ CHECK(strcmp("Pinguin", process_debug_messages_data.results[0].buffer) == 0);
+ CHECK(strcmp("Capybara", process_debug_messages_data.results[1].buffer) == 0);
+ CHECK(strcmp("805", process_debug_messages_data.results[2].buffer) == 0);
v8::Debug::SetMessageHandler(NULL);
v8::Debug::SetDebugEventListener(NULL);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698