1 //===-- StreamCallbackTest.cpp --------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #include "lldb/Utility/StreamCallback.h"
10 #include "gtest/gtest.h"
11 
12 using namespace lldb;
13 using namespace lldb_private;
14 
15 static char test_baton;
16 static size_t callback_count = 0;
TestCallback(const char * data,void * baton)17 static void TestCallback(const char *data, void *baton) {
18   EXPECT_STREQ("Foobar", data);
19   EXPECT_EQ(&test_baton, baton);
20   ++callback_count;
21 }
22 
TEST(StreamCallbackTest,Callback)23 TEST(StreamCallbackTest, Callback) {
24   StreamCallback stream(TestCallback, &test_baton);
25   stream << "Foobar";
26   EXPECT_EQ(1u, callback_count);
27 }
28