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

Unified Diff: runtime/vm/log_test.cc

Issue 913503004: Per isolate Log with block support (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/log.cc ('k') | runtime/vm/service.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/log_test.cc
diff --git a/runtime/vm/log_test.cc b/runtime/vm/log_test.cc
new file mode 100644
index 0000000000000000000000000000000000000000..b75ccee88c9d8c72e86771dcc2baaa35df744579
--- /dev/null
+++ b/runtime/vm/log_test.cc
@@ -0,0 +1,78 @@
+// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+#include "platform/globals.h"
+
+#include "include/dart_debugger_api.h"
+#include "vm/dart_api_impl.h"
+#include "vm/dart_entry.h"
+#include "vm/debugger.h"
+#include "vm/globals.h"
+#include "vm/isolate.h"
+#include "vm/log.h"
+#include "vm/message_handler.h"
+#include "vm/unit_test.h"
+
+namespace dart {
+
+static const char* test_output_;
+static void TestPrinter(const char* print, ...) {
+ test_output_ = print;
+}
+
+class LogTestHelper : public AllStatic {
+ public:
+ static void SetPrinter(Log* log, LogPrinter printer) {
+ ASSERT(log != NULL);
+ ASSERT(printer != NULL);
+ log->printer_ = printer;
+ }
+};
+
+
+TEST_CASE(Log_Macro) {
+ test_output_ = NULL;
+ Isolate* isolate = Isolate::Current();
+ Log* log = isolate->Log();
+ LogTestHelper::SetPrinter(log, TestPrinter);
+
+ ISL_Print("Hello %s", "World");
+ EXPECT_STREQ("Hello World", test_output_);
+ ISL_Print("SingleArgument");
+ EXPECT_STREQ("SingleArgument", test_output_);
+}
+
+
+TEST_CASE(Log_Basic) {
+ test_output_ = NULL;
+ Log* log = new Log(TestPrinter);
+
+ EXPECT_EQ(reinterpret_cast<const char*>(NULL), test_output_);
+ log->Print("Hello %s", "World");
+ EXPECT_STREQ("Hello World", test_output_);
+}
+
+
+TEST_CASE(Log_Block) {
+ test_output_ = NULL;
+ Log* log = new Log(TestPrinter);
+
+ Isolate* isolate = Isolate::Current();
+
+ EXPECT_EQ(reinterpret_cast<const char*>(NULL), test_output_);
+ {
+ LogBlock ba(isolate, log);
+ log->Print("APPLE");
+ EXPECT_EQ(reinterpret_cast<const char*>(NULL), test_output_);
+ {
+ LogBlock ba(isolate, log);
+ log->Print("BANANA");
+ EXPECT_EQ(reinterpret_cast<const char*>(NULL), test_output_);
+ }
+ EXPECT_STREQ("BANANA", test_output_);
+ }
+ EXPECT_STREQ("APPLE", test_output_);
+}
+
+} // namespace dart
« no previous file with comments | « runtime/vm/log.cc ('k') | runtime/vm/service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698