本文整理汇总了C++中testing类的典型用法代码示例。如果您正苦于以下问题:C++ testing类的具体用法?C++ testing怎么用?C++ testing使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了testing类的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: MatchesRegex
TEST_F(HTTPDigestAuthenticateTest, RequestStoreDigest_Stale)
{
std::vector<std::string> test;
test.push_back("digest_1");
test.push_back("realm");
test[1] = "realm";
_hc->set_result("/impi/1231231231%40home.domain/av?impu=sip%3A1231231231%40home.domain", test);
// set the _impu/_impi
_auth_mod->set_members("sip:[email protected]", "GET", "[email protected]", 0);
// Request the digest. The header will contain the stale parameter
std::string www_auth_header;
long rc = _auth_mod->request_digest_and_store(www_auth_header, true, _response);
EXPECT_THAT(www_auth_header,
MatchesRegex("Digest realm=\"home\\.domain\",qop=\"auth\",nonce=\".*\",opaque=\".*\",stale=TRUE"));
ASSERT_EQ(rc, 401);
}
开发者ID:AiprNick,项目名称:memento,代码行数:19,代码来源:httpdigestauthenticate_test.cpp
示例2: MatchesRegex
TEST_F(SessionExpiresHelperTest, ClientSupportsTimerSEModified)
{
Message msg1;
msg1._uac_supports_timer = true;
msg1._se = "Session-Expires: 800";
do_request_flow(&msg1);
EXPECT_EQ(get_headers(current_txdata()->msg, "Session-Expires"),
"Session-Expires: 600");
do_response_flow();
EXPECT_EQ(get_headers(current_txdata()->msg, "Session-Expires"),
"Session-Expires: 600;refresher=uac");
EXPECT_THAT(get_headers(current_txdata()->msg, "Require"),
MatchesRegex("Require:.*[ ,]timer($|[ ,])"));
free_txdata();
}
开发者ID:ClearwaterCore,项目名称:sprout,代码行数:19,代码来源:session_expires_helper_test.cpp
示例3: XPathToken
TEST_F(XPathParserTest, multiple_predicates)
{
tokens.add({
XPathToken("*"),
XPathToken(XPathTokenType::LeftBracket),
XPathToken(2.0),
XPathToken(XPathTokenType::RightBracket),
XPathToken(XPathTokenType::LeftBracket),
XPathToken(1.0),
XPathToken(XPathTokenType::RightBracket)
});
auto expr = parser->parse();
add_child(top_node, "first");
auto second = add_child(top_node, "second");
ASSERT_THAT(evaluate_on(expr, top_node).nodeset(), ElementsAre(second));
}
开发者ID:shepmaster,项目名称:sxd-cpp,代码行数:19,代码来源:xpath-parser-test.cpp
示例4: Eq
TEST(ReaderTest, TestReadingMovesPosition)
{
Reader reader;
uint8_t array[] = {0x55, 0xaa, 0x77, 0xee, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99};
reader.Initialize(array);
ASSERT_THAT(reader.ReadByte(), Eq(0x55));
ASSERT_THAT(reader.ReadWordLE(), Eq(0x77AA));
ASSERT_THAT(reader.ReadDoubleWordLE(), Eq(0x332211EEU));
ASSERT_THAT(reader.ReadArray(3), Eq(gsl::span<const std::uint8_t>(array + 7, 3)));
ASSERT_THAT(reader.ReadByte(), Eq(0x77));
ASSERT_THAT(reader.ReadWordBE(), Eq(0x8899));
ASSERT_TRUE(reader.Status());
}
开发者ID:PW-Sat2,项目名称:PWSat2OBC,代码行数:14,代码来源:ReaderTest.cpp
示例5: driver
// This test ensures that a framework connecting with a
// failed over master gets a registered callback.
// Note that this behavior might change in the future and
// the scheduler might receive a re-registered callback.
TEST_F(FaultToleranceTest, MasterFailover)
{
Try<PID<Master> > master = StartMaster();
ASSERT_SOME(master);
MockScheduler sched;
MesosSchedulerDriver driver(&sched, DEFAULT_FRAMEWORK_INFO, master.get());
Future<process::Message> frameworkRegisteredMessage =
FUTURE_MESSAGE(Eq(FrameworkRegisteredMessage().GetTypeName()), _, _);
EXPECT_CALL(sched, registered(&driver, _, _));
driver.start();
AWAIT_READY(frameworkRegisteredMessage);
// Simulate failed over master by restarting the master.
Stop(master.get());
master = StartMaster();
ASSERT_SOME(master);
EXPECT_CALL(sched, disconnected(&driver));
Future<Nothing> registered;
EXPECT_CALL(sched, registered(&driver, _, _))
.WillOnce(FutureSatisfy(®istered));
// Simulate a new master detected message to the scheduler.
NewMasterDetectedMessage newMasterDetectedMsg;
newMasterDetectedMsg.set_pid(master.get());
process::post(frameworkRegisteredMessage.get().to, newMasterDetectedMsg);
// Framework should get a registered callback.
AWAIT_READY(registered);
driver.stop();
driver.join();
Shutdown();
}
开发者ID:nadirabid,项目名称:mesos,代码行数:46,代码来源:fault_tolerance_tests.cpp
示例6: strdup
TEST_F(LibNiceConnectionTest, getCandidate_Passes_Candidate_to_Listener) {
GSList* candidate_list = NULL;
NiceCandidate* arbitrary_candidate = nice_candidate_new(NICE_CANDIDATE_TYPE_HOST);
arbitrary_candidate->username = strdup("an_arbitrary_username");
arbitrary_candidate->password = strdup("an_arbitrary_password");
arbitrary_candidate->stream_id = (guint) 1;
arbitrary_candidate->component_id = 1;
arbitrary_candidate->priority = 1;
arbitrary_candidate->transport = NICE_CANDIDATE_TRANSPORT_UDP;
nice_address_set_from_string(&arbitrary_candidate->addr, "192.168.1.1");
nice_address_set_from_string(&arbitrary_candidate->base_addr, "192.168.1.2");
nice_address_set_port(&arbitrary_candidate->addr, 10);
nice_address_set_port(&arbitrary_candidate->base_addr, 20);
candidate_list = g_slist_prepend(candidate_list, arbitrary_candidate);
EXPECT_CALL(*libnice, NiceAgentGetLocalCandidates(_, _, _)).Times(1).WillOnce(Return(candidate_list));
EXPECT_CALL(*nice_listener, onCandidate(_, _)).Times(1);
nice_connection->getCandidate(1, 1, "test");
}
开发者ID:mccob,项目名称:licode,代码行数:20,代码来源:LibNiceConnectionTest.cpp
示例7: msg
TEST_F(IRCSockTest, OnNickMessage) {
CMessage msg(":nobody NICK nick");
m_pTestSock->ReadLine(msg.ToString());
EXPECT_THAT(m_pTestModule->vsHooks, ElementsAre("OnNickMessage"));
EXPECT_THAT(m_pTestModule->vsMessages, ElementsAre(msg.ToString()));
EXPECT_THAT(m_pTestModule->vNetworks, ElementsAre(m_pTestNetwork));
EXPECT_THAT(m_pTestModule->vChannels, ElementsAre(nullptr));
EXPECT_THAT(m_pTestClient->vsLines, IsEmpty());
msg.Parse(":nick NICK somebody");
m_pTestSock->ReadLine(msg.ToString());
EXPECT_THAT(m_pTestClient->vsLines, ElementsAre(msg.ToString()));
}
开发者ID:DarthGandalf,项目名称:znc,代码行数:15,代码来源:IRCSockTest.cpp
示例8: handler
TEST(Process, remote)
{
ASSERT_TRUE(GTEST_IS_THREADSAFE);
RemoteProcess process;
volatile bool handlerCalled = false;
EXPECT_CALL(process, handler(_, _))
.WillOnce(Assign(&handlerCalled, true));
spawn(process);
int s = socket(AF_INET, SOCK_STREAM, IPPROTO_IP);
ASSERT_LE(0, s);
sockaddr_in addr;
memset(&addr, 0, sizeof(addr));
addr.sin_family = PF_INET;
addr.sin_port = htons(process.self().port);
addr.sin_addr.s_addr = process.self().ip;
ASSERT_EQ(0, connect(s, (sockaddr*) &addr, sizeof(addr)));
Message message;
message.name = "handler";
message.from = UPID();
message.to = process.self();
const std::string& data = MessageEncoder::encode(&message);
ASSERT_EQ(data.size(), write(s, data.data(), data.size()));
ASSERT_EQ(0, close(s));
while (!handlerCalled);
terminate(process);
wait(process);
}
开发者ID:mailmahee,项目名称:libprocess,代码行数:41,代码来源:tests.cpp
示例9: ElementsAreArray
TEST(EventLogListBuilder, SingleInt) {
EventLogListBuilder builder;
const uint8_t EXPECTED_LOG[] = {
EVENT_TYPE_LIST,
1, // Number of items in the list.
EVENT_TYPE_INT,
42, 0, 0, 0, // 4 byte integer value.
};
builder.Append(42);
std::unique_ptr<uint8_t[]> log;
size_t size;
builder.Release(&log, &size);
EXPECT_EQ(7U, size);
uint8_t* log_data = log.get();
EXPECT_THAT(std::vector<uint8_t>(log_data, log_data + size),
ElementsAreArray(EXPECTED_LOG));
}
开发者ID:mnemonyc,项目名称:platform_system_core,代码行数:21,代码来源:event_log_list_builder_test.cpp
示例10: transaction
TEST_F(HumanPersistenceFacadeTest, subtractHuman_HumanIsPresent_SubtractAll)
{
ITransactionShrPtr transaction(new TransactionDummy);
// Mocks setup: HumanAccessorMock.
HumanAccessorMock * mock = new HumanAccessorMock;
EXPECT_CALL(*mock, deleteRecord(_, m_id_holder, KEY_WORKER_MINER_NOVICE));
EXPECT_CALL(*mock, getRecord(_, m_id_holder, KEY_WORKER_MINER_NOVICE))
.WillOnce(Return(make_shared<HumanWithVolumeRecord>(m_id_holder, KEY_WORKER_MINER_NOVICE, 5)));
// Mocks setup: Wrapping around.
IHumanAccessorAutPtr accessor(mock);
// Preconditions.
HumanPersistenceFacade persistence_facade(m_context, accessor);
// Test commands and assertions.
ASSERT_TRUE(persistence_facade.subtractHuman(transaction, m_id_holder, KEY_WORKER_MINER_NOVICE, 5));
}
开发者ID:BrianRickardMason,项目名称:TheUltimateStrategy,代码行数:21,代码来源:HumanPersistenceFacadeTest.cpp
示例11: loci_encoding
TEST(PvalLoci, NonPvalueLociSkippedDuringInitialization) {
istringstream loci_encoding (
"chr1 3000573 3000574 c:0.582447:0.143575 0.2273\n"
"chr1 3000725 3000726 c:0.246345:0.06131 -1\n"
"chr2 3000900 3000901 c:0.502302:0.11534 0.422782\n" );
vector<PvalLocus> pval_loci;
initialize_pval_loci(loci_encoding, pval_loci);
ASSERT_THAT(pval_loci.size(), Eq(2));
ASSERT_THAT(pval_loci[0].chrom_ind, Eq(0));
ASSERT_THAT(pval_loci[0].pos, Eq(3000573));
ASSERT_THAT(pval_loci[0].raw_pval, Eq(0.2273));
ASSERT_THAT(pval_loci[1].chrom_ind, Eq(1));
ASSERT_THAT(pval_loci[1].pos, Eq(3000900));
ASSERT_THAT(pval_loci[1].raw_pval, Eq(0.422782));
}
开发者ID:smithlabcode,项目名称:radmeth,代码行数:19,代码来源:test_pvallocus.cpp
示例12: timeout
TEST(Process, order)
{
ASSERT_TRUE(GTEST_IS_THREADSAFE);
Clock::pause();
TimeoutProcess process1;
volatile bool timeoutCalled = false;
EXPECT_CALL(process1, timeout())
.WillOnce(Assign(&timeoutCalled, true));
spawn(process1);
double now = Clock::now(&process1);
double seconds = 1.0;
Clock::advance(1.0);
EXPECT_EQ(now, Clock::now(&process1));
OrderProcess process2;
spawn(process2);
dispatch(process2, &OrderProcess::order, process1.self());
while (!timeoutCalled);
EXPECT_EQ(now + seconds, Clock::now(&process1));
terminate(process1);
wait(process1);
terminate(process2);
wait(process2);
Clock::resume();
}
开发者ID:mailmahee,项目名称:libprocess,代码行数:40,代码来源:tests.cpp
示例13: timeoutCalled
TEST(ProcessTest, Order)
{
ASSERT_TRUE(GTEST_IS_THREADSAFE);
Clock::pause();
TimeoutProcess process1;
std::atomic_bool timeoutCalled(false);
EXPECT_CALL(process1, timeout())
.WillOnce(Assign(&timeoutCalled, true));
spawn(process1);
Time now = Clock::now(&process1);
Seconds seconds(1);
Clock::advance(Seconds(1));
EXPECT_EQ(now, Clock::now(&process1));
OrderProcess process2;
spawn(process2);
dispatch(process2, &OrderProcess::order, process1.self());
while (timeoutCalled.load() == false);
EXPECT_EQ(now + seconds, Clock::now(&process1));
terminate(process1);
wait(process1);
terminate(process2);
wait(process2);
Clock::resume();
}
开发者ID:LinxiaHu,项目名称:mesos,代码行数:40,代码来源:process_tests.cpp
示例14: pipe
TEST(HTTPTest, StreamingGetFailure)
{
Http http;
http::Pipe pipe;
http::OK ok;
ok.type = http::Response::PIPE;
ok.reader = pipe.reader();
EXPECT_CALL(*http.process, pipe(_))
.WillOnce(Return(ok));
Future<http::Response> response =
http::streaming::get(http.process->self(), "pipe");
// The response should be ready since the headers were sent.
AWAIT_READY(response);
EXPECT_SOME_EQ("chunked", response.get().headers.get("Transfer-Encoding"));
ASSERT_EQ(http::Response::PIPE, response.get().type);
ASSERT_SOME(response.get().reader);
http::Pipe::Reader reader = response.get().reader.get();
// There is no data to read yet.
Future<string> read = reader.read();
EXPECT_TRUE(read.isPending());
// Stream data into the body and read it from the response.
http::Pipe::Writer writer = pipe.writer();
EXPECT_TRUE(writer.write("hello"));
AWAIT_EQ("hello", read);
EXPECT_TRUE(writer.write("goodbye"));
AWAIT_EQ("goodbye", reader.read());
// Fail the response.
EXPECT_TRUE(writer.fail("oops"));
AWAIT_FAILED(reader.read());
}
开发者ID:haosdent,项目名称:mesos,代码行数:40,代码来源:http_tests.cpp
示例15: connect
TEST_F(DocumentWebSocketChannelTest, sendBinaryInArrayBufferNonLatin1UTF8Continuation)
{
connect();
Checkpoint checkpoint;
{
InSequence s;
EXPECT_CALL(*handle(), send(false, WebSocketHandle::MessageTypeBinary, MemEq("\xe7\x8b\x90\xe7\x8b\x90\xe7\x8b\x90\xe7\x8b\x90\xe7\x8b\x90\xe7", 16), 16));
EXPECT_CALL(checkpoint, Call(1));
EXPECT_CALL(*handle(), send(true, WebSocketHandle::MessageTypeContinuation, MemEq("\x8b\x90", 2), 2));
}
handleClient()->didReceiveFlowControl(handle(), 16);
EXPECT_CALL(*channelClient(), didConsumeBufferedAmount(_)).Times(AnyNumber());
RefPtr<DOMArrayBuffer> b = DOMArrayBuffer::create("\xe7\x8b\x90\xe7\x8b\x90\xe7\x8b\x90\xe7\x8b\x90\xe7\x8b\x90\xe7\x8b\x90", 18);
channel()->send(*b, 0, 18);
checkpoint.Call(1);
handleClient()->didReceiveFlowControl(handle(), 16);
EXPECT_EQ(18ul, m_sumOfConsumedBufferedAmount);
}
开发者ID:azureplus,项目名称:chromium,代码行数:22,代码来源:DocumentWebSocketChannelTest.cpp
示例16: process
TEST(Process, exited)
{
ASSERT_TRUE(GTEST_IS_THREADSAFE);
UPID pid = spawn(new ProcessBase(), true);
ExitedProcess process(pid);
volatile bool exitedCalled = false;
EXPECT_CALL(process, exited(pid))
.WillOnce(Assign(&exitedCalled, true));
spawn(process);
terminate(pid);
while (!exitedCalled);
terminate(process);
wait(process);
}
开发者ID:mailmahee,项目名称:libprocess,代码行数:22,代码来源:tests.cpp
示例17: process
TEST(ProcessTest, InjectExited)
{
ASSERT_TRUE(GTEST_IS_THREADSAFE);
UPID pid = spawn(new ProcessBase(), true);
ExitedProcess process(pid);
std::atomic_bool exitedCalled(false);
EXPECT_CALL(process, exited(pid))
.WillOnce(Assign(&exitedCalled, true));
spawn(process);
inject::exited(pid, process.self());
while (exitedCalled.load() == false);
terminate(process);
wait(process);
}
开发者ID:LinxiaHu,项目名称:mesos,代码行数:22,代码来源:process_tests.cpp
示例18: driver
TEST_F(ResourceOffersTest, ResourceOfferWithMultipleSlaves)
{
Try<PID<Master> > master = StartMaster();
ASSERT_SOME(master);
// Start 10 slaves.
for (int i = 0; i < 10; i++) {
slave::Flags flags = CreateSlaveFlags();
flags.resources = Option<std::string>("cpus:2;mem:1024");
Try<PID<Slave> > slave = StartSlave(flags);
ASSERT_SOME(slave);
}
MockScheduler sched;
MesosSchedulerDriver driver(&sched, DEFAULT_FRAMEWORK_INFO, master.get());
EXPECT_CALL(sched, registered(&driver, _, _))
.Times(1);
Future<vector<Offer> > offers;
EXPECT_CALL(sched, resourceOffers(&driver, _))
.WillOnce(FutureArg<1>(&offers))
.WillRepeatedly(Return()); // All 10 slaves might not be in first offer.
driver.start();
AWAIT_READY(offers);
EXPECT_NE(0u, offers.get().size());
EXPECT_GE(10u, offers.get().size());
Resources resources(offers.get()[0].resources());
EXPECT_EQ(2, resources.get("cpus", Value::Scalar()).value());
EXPECT_EQ(1024, resources.get("mem", Value::Scalar()).value());
driver.stop();
driver.join();
Shutdown();
}
开发者ID:WuErPing,项目名称:mesos,代码行数:39,代码来源:resource_offers_tests.cpp
示例19: ScrollAnimator
// Test that a smooth scroll offset animation is aborted when followed by a
// non-smooth scroll offset animation.
TEST(ScrollAnimatorTest, AnimatedScrollAborted)
{
OwnPtrWillBeRawPtr<MockScrollableArea> scrollableArea =
MockScrollableArea::create(true);
OwnPtrWillBeRawPtr<ScrollAnimator> scrollAnimator = adoptPtrWillBeNoop(
new ScrollAnimator(scrollableArea.get(), getMockedTime));
EXPECT_CALL(*scrollableArea, minimumScrollPosition()).Times(AtLeast(1))
.WillRepeatedly(Return(IntPoint()));
EXPECT_CALL(*scrollableArea, maximumScrollPosition()).Times(AtLeast(1))
.WillRepeatedly(Return(IntPoint(1000, 1000)));
EXPECT_CALL(*scrollableArea, setScrollOffset(_, _)).Times(3);
EXPECT_CALL(*scrollableArea, registerForAnimation()).Times(2);
EXPECT_CALL(*scrollableArea, scheduleAnimation()).Times(AtLeast(1))
.WillRepeatedly(Return(true));
EXPECT_FALSE(scrollAnimator->hasAnimationThatRequiresService());
// Smooth scroll.
ScrollResultOneDimensional result = scrollAnimator->userScroll(
HorizontalScrollbar, ScrollByLine, 100, 1);
EXPECT_TRUE(scrollAnimator->hasAnimationThatRequiresService());
EXPECT_TRUE(result.didScroll);
EXPECT_FLOAT_EQ(0.0, result.unusedScrollDelta);
EXPECT_TRUE(scrollAnimator->hasRunningAnimation());
gMockedTime += 0.05;
scrollAnimator->updateCompositorAnimations();
scrollAnimator->tickAnimation(getMockedTime());
EXPECT_NE(100, scrollAnimator->currentPosition().x());
EXPECT_NE(0, scrollAnimator->currentPosition().x());
EXPECT_EQ(0, scrollAnimator->currentPosition().y());
float x = scrollAnimator->currentPosition().x();
// Instant scroll.
result = scrollAnimator->userScroll(
HorizontalScrollbar, ScrollByPrecisePixel, 100, 1);
EXPECT_TRUE(result.didScroll);
EXPECT_FALSE(scrollAnimator->hasRunningAnimation());
EXPECT_EQ(x + 100, scrollAnimator->currentPosition().x());
EXPECT_EQ(0, scrollAnimator->currentPosition().y());
reset(*scrollAnimator);
}
开发者ID:joone,项目名称:chromium-crosswalk,代码行数:48,代码来源:ScrollAnimatorTest.cpp
注:本文中的testing类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论