Pavel Labath | 5fae71c | 2017-02-10 11:49:21 +0000 | [diff] [blame] | 1 | //===-- StreamCallbackTest.cpp ----------------------------------*- C++ -*-===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
Zachary Turner | fb1a0a0 | 2017-03-06 18:34:25 +0000 | [diff] [blame] | 10 | #include "lldb/Utility/StreamCallback.h" |
Pavel Labath | 5fae71c | 2017-02-10 11:49:21 +0000 | [diff] [blame] | 11 | #include "gtest/gtest.h" |
| 12 | |
| 13 | using namespace lldb; |
| 14 | using namespace lldb_private; |
| 15 | |
| 16 | static char test_baton; |
| 17 | static size_t callback_count = 0; |
| 18 | static void TestCallback(const char *data, void *baton) { |
| 19 | EXPECT_STREQ("Foobar", data); |
| 20 | EXPECT_EQ(&test_baton, baton); |
| 21 | ++callback_count; |
| 22 | } |
| 23 | |
| 24 | TEST(StreamCallbackTest, Callback) { |
| 25 | StreamCallback stream(TestCallback, &test_baton); |
| 26 | stream << "Foobar"; |
| 27 | EXPECT_EQ(1u, callback_count); |
| 28 | } |