1
0
mirror of https://github.com/facebookincubator/mvfst.git synced 2025-08-09 20:42:44 +03:00
Files
mvfst/quic/common/test/MonitoredObjectTest.cpp
Dimitri Bouche 715dec85be Migrate from googletest 1.8 to googletest 1.10 (#67)
Summary:
X-link: https://github.com/facebookincubator/hsthrift/pull/67

Updating `googletest` from `1.8.0` to `1.10.0`

Reviewed By: mzlee, igorsugak, luciang, meyering, r-barnes

Differential Revision: D34351084

fbshipit-source-id: 939b3985ab63a06b6d511ec8711c2d5863bdfea8
2022-03-03 03:46:03 -08:00

37 lines
923 B
C++

/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
#include <quic/common/MonitoredObject.h>
#include <gmock/gmock.h>
#include <gtest/gtest.h>
#include <functional>
using namespace std;
using namespace quic;
using namespace ::testing;
class MockObserver {
public:
MOCK_METHOD(void, accessed, (const string&));
};
TEST(MonitoredObjectTest, TestObserverCalled) {
InSequence s;
string x = "abc";
MockObserver observer;
auto accessFn =
std::bind(&MockObserver::accessed, &observer, placeholders::_1);
MonitoredObject<string> mo(x, accessFn);
EXPECT_CALL(observer, accessed(x)).Times(1);
EXPECT_EQ(x, mo->c_str());
EXPECT_CALL(observer, accessed(x + "d")).Times(1);
mo->append("d");
EXPECT_CALL(observer, accessed(x + "de")).Times(1);
mo->append("e");
}