本文整理汇总了C++中TestClient类的典型用法代码示例。如果您正苦于以下问题:C++ TestClient类的具体用法?C++ TestClient怎么用?C++ TestClient使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TestClient类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: TEST
TEST(Bootstrap, ClientConnectionManagerTest) {
// Create a single IO thread, and verify that
// client connections are pooled properly
TestServer server;
auto factory = std::make_shared<TestPipelineFactory>();
server.childPipeline(factory);
server.group(std::make_shared<IOThreadPoolExecutor>(1));
server.bind(0);
auto base = EventBaseManager::get()->getEventBase();
SocketAddress address;
server.getSockets()[0]->getAddress(&address);
TestClient client;
client.pipelineFactory(std::make_shared<TestClientPipelineFactory>());
client.connect(address);
TestClient client2;
client2.pipelineFactory(std::make_shared<TestClientPipelineFactory>());
client2.connect(address);
base->loop();
server.stop();
CHECK(factory->pipelines == 2);
}
开发者ID:ramgtv,项目名称:folly,代码行数:28,代码来源:BootstrapTest.cpp
示例2: TEST
TEST(Bootstrap, ServerAcceptGroup2Test) {
// Verify that server is using the accept IO group
// Check if reuse port is supported, if not, don't run this test
try {
EventBase base;
auto serverSocket = AsyncServerSocket::newSocket(&base);
serverSocket->bind(0);
serverSocket->listen(0);
serverSocket->startAccepting();
serverSocket->setReusePortEnabled(true);
serverSocket->stopAccepting();
} catch(...) {
LOG(INFO) << "Reuse port probably not supported";
return;
}
TestServer server;
auto factory = std::make_shared<TestPipelineFactory>();
server.childPipeline(factory);
server.group(std::make_shared<IOThreadPoolExecutor>(4), nullptr);
server.bind(0);
SocketAddress address;
server.getSockets()[0]->getAddress(&address);
TestClient client;
client.connect(address);
EventBaseManager::get()->getEventBase()->loop();
server.stop();
CHECK(factory->pipelines == 1);
}
开发者ID:smartnetguru,项目名称:folly,代码行数:34,代码来源:BootstrapTest.cpp
示例3: TEST_F
TEST_F(QueryTest, SendBuffer) {
CUser user("user");
CIRCNetwork network(&user, "network");
CDebug::SetDebug(false);
TestClient client;
client.SetNick("me");
client.AcceptLogin(user);
client.lines.clear();
CQuery query("query", &network);
query.AddBuffer(":sender PRIVMSG {target} :{text}", "a message");
query.AddBuffer(":me PRIVMSG someone :{text}", "a self-message");
query.AddBuffer(":sender NOTICE #znc :{text}", "a notice");
client.lines.clear();
query.SendBuffer(&client);
EXPECT_THAT(client.lines, ElementsAre(MatchesRegex(R"(:sender PRIVMSG me :\[\d\d:\d\d:\d\d\] a message)"),
MatchesRegex(R"(:sender NOTICE #znc :\[\d\d:\d\d:\d\d\] a notice)")));
client.lines.clear();
user.SetTimestampPrepend(false);
query.SendBuffer(&client);
EXPECT_THAT(client.lines, ElementsAre(":sender PRIVMSG me :a message", ":sender NOTICE #znc :a notice"));
client.lines.clear();
user.SetTimestampAppend(true);
query.SendBuffer(&client);
EXPECT_THAT(client.lines, ElementsAre(MatchesRegex(R"(:sender PRIVMSG me :a message \[\d\d:\d\d:\d\d\])"),
MatchesRegex(R"(:sender NOTICE #znc :a notice \[\d\d:\d\d:\d\d\])")));
network.ClientDisconnected(&client);
}
开发者ID:KielBNC,项目名称:znc,代码行数:33,代码来源:QueryTest.cpp
示例4: main
int main(int argc, char **argv)
{
KAboutData about("KNetworkStatusTestClient", 0, ki18n("knetworkstatustestclient"), version, ki18n(description), KAboutData::License_GPL, ki18n("(C) 2007 Will Stephenson"), KLocalizedString(), 0, "[email protected]");
about.addAuthor( ki18n("Will Stephenson"), KLocalizedString(), "[email protected]" );
KCmdLineArgs::init(argc, argv, &about);
KCmdLineOptions options;
KCmdLineArgs::addCmdLineOptions(options);
KApplication app;
KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
if (args->count() == 0)
{
TestClient *widget = new TestClient;
widget->show();
}
else
{
int i = 0;
for (; i < args->count(); i++)
{
TestClient *widget = new TestClient;
widget->show();
}
}
args->clear();
return app.exec();
}
开发者ID:,项目名称:,代码行数:29,代码来源:
示例5: TEST
TEST(SocketSuite, splitPackets)
{
const int port = TEST_PORT_BASE + 1;
char ipAddr[] = "127.0.0.1";
const int RECV_LENGTH = 64;
TestClient client;
TestServer server;
ByteArray recv;
// Construct server
ASSERT_TRUE(server.init(port));
// Construct a client
ASSERT_TRUE(client.init(&ipAddr[0], port));
pthread_t serverConnectThrd;
pthread_create(&serverConnectThrd, NULL, connectServerFunc, &server);
ASSERT_TRUE(client.makeConnect());
pthread_join(serverConnectThrd, NULL);
pthread_t senderThrd;
pthread_create(&senderThrd, NULL, spinSender, &client);
ASSERT_TRUE(server.receiveBytes(recv, RECV_LENGTH));
ASSERT_EQ(RECV_LENGTH, recv.getBufferSize());
pthread_cancel(senderThrd);
pthread_join(senderThrd, NULL);
}
开发者ID:fascii,项目名称:denso_v068,代码行数:29,代码来源:utest.cpp
示例6: spinSender
// Utility for running tcp client in sending loop
void*
spinSender(void* arg)
{
TestClient* client = (TestClient*)arg;
ByteArray send;
const int DATA = 256;
send.load(DATA);
while(true)
{
client->sendBytes(send);
sleep(0.1);
}
}
开发者ID:fascii,项目名称:denso_v068,代码行数:16,代码来源:utest.cpp
示例7:
void TestServer::ReceiveMessage3(TestClient& client, BigInteger A, const BinaryData& Mc)
{
BinaryData Ms = m_server.VerifyClient(Mc);
// Server -> Client: send Ms
client.ReceiveMessage4(Ms);
}
开发者ID:vividos,项目名称:MultiplayerOnlineGame,代码行数:7,代码来源:TestSRPxint.cpp
示例8: data
//==============================================================================
// Get Data
//==============================================================================
QVariant ClientListModel::data(const QModelIndex& aIndex, int aRole) const
{
// Check Index
if (aIndex.row() >= 0 && aIndex.row() < rowCount()) {
// Get Model Item
TestClient* item = clientList[aIndex.row()];
// Switch Role
switch (aRole) {
case ClientID: return item->getID();
case ClientConnected: return item->isConnected();
case ClientAdmin: return item->isAdminModeOn();
case ClientBusy: return item->isBusy();
default:
break;
}
}
return QString("");
}
开发者ID:maxavadallat,项目名称:maxcommander,代码行数:24,代码来源:testdialog.cpp
示例9: TEST
TEST(Bootstrap, LoadBalanceHandler) {
TestServer server;
auto factory = std::make_shared<TestPipelineFactory>();
server.childPipeline(factory);
auto pipelinefactory =
std::make_shared<TestHandlerPipelineFactory<TestHandlerPipeline>>();
server.pipeline(pipelinefactory);
server.bind(0);
auto base = EventBaseManager::get()->getEventBase();
SocketAddress address;
server.getSockets()[0]->getAddress(&address);
TestClient client;
client.pipelineFactory(std::make_shared<TestClientPipelineFactory>());
client.connect(address);
base->loop();
server.stop();
CHECK(factory->pipelines == 1);
CHECK(connections == 1);
}
开发者ID:chjp2046,项目名称:wangle,代码行数:23,代码来源:BootstrapTest.cpp
示例10: s
void TestServer::ReceiveMessage1(TestClient& client, const std::string& strUsername, BigInteger A)
{
BigInteger s(c_pszaSalt, 16);
if (m_strUsername != strUsername)
throw std::runtime_error("invalid user");
BigInteger PassVerifier;
if (!m_bCacheClientKey || (m_CachedPassVerifier == BigInteger()))
{
GroupParameter gp = Helper::GetPresetGroupParameter(c_uiPresetIndex);
PassVerifier = Helper::GeneratePassword(strUsername, m_strPassword, gp, s);
if (m_bCacheClientKey)
m_CachedPassVerifier = PassVerifier;
}
else
PassVerifier = m_CachedPassVerifier;
BigInteger b;
if (m_bRandom)
{
boost::xint::strong_random_generator srg;
b = boost::xint::integer::random_by_size(srg,
256,
false, // high_bit_on
false, // low_bit_on
false);// can_be_negative
}
else
b = BigInteger(c_pszaSmallB, 16);
BigInteger B = m_server.GetB(PassVerifier, b);
m_server.CalcSessionKey(A, s, strUsername, PassVerifier);
// Server -> Client: send s, B
client.ReceiveMessage2(*this, s, B);
}
开发者ID:vividos,项目名称:MultiplayerOnlineGame,代码行数:40,代码来源:TestSRPxint.cpp
示例11: configureButtons
//==============================================================================
// Configure Buttons
//==============================================================================
void TestDialog::configureButtons()
{
// Check Model
if (clientListModel) {
// Enable/Disable Buttons
ui->createClientButton->setEnabled(true);
// Get Test Client
TestClient* client = clientListModel->getClient(currentIndex);
// Enable/Disable Buttons
ui->connectButton->setEnabled(client && !client->isConnected() && !client->isAdminModeOn());
ui->connectAsRootButton->setEnabled(client && (!client->isConnected() || (client->isConnected() && !client->isAdminModeOn())));
ui->disconnectButton->setEnabled(client && client->isConnected());
ui->startButton->setEnabled(client && client->isConnected() && !client->isBusy());
ui->yesButton->setEnabled(client && client->isConnected() && client->isBusy());
ui->noButton->setEnabled(client && client->isConnected() && client->isBusy());
ui->stopButton->setEnabled(client && client->isConnected() && client->isBusy());
//ui->pauseButton->setEnabled(client && client->isConnected() && client->isBusy() && !client->isSuspended());
//ui->resumeButton->setEnabled(client && client->isConnected() && client->isBusy() && client->isSuspended());
ui->clearButton->setEnabled(clientListModel->rowCount() > 0);
} else {
// Enable/Disable Buttons
ui->createClientButton->setEnabled(false);
ui->connectButton->setEnabled(false);
ui->connectAsRootButton->setEnabled(false);
ui->startButton->setEnabled(false);
ui->yesButton->setEnabled(false);
ui->noButton->setEnabled(false);
ui->stopButton->setEnabled(false);
ui->pauseButton->setEnabled(false);
ui->resumeButton->setEnabled(false);
ui->disconnectButton->setEnabled(false);
ui->clearButton->setEnabled(false);
}
}
开发者ID:maxavadallat,项目名称:maxcommander,代码行数:43,代码来源:testdialog.cpp
示例12: TEST_CASE
#include "TestClient.h"
#include "TestServer.h"
#include "testing.h"
TEST_CASE("No erroneous transform messages on login", "") {
TestServer s = TestServer::WithData("basic_rock");
s.addObject("rock", {20, 20});
TestClient c = TestClient::WithData("basic_rock");
s.waitForUsers(1);
bool transformTimeReceived = c.waitForMessage(SV_TRANSFORM_TIME, 200);
CHECK_FALSE(transformTimeReceived);
}
开发者ID:,项目名称:,代码行数:13,代码来源:
示例13: Basics
static void __stdcall Basics()
{
// we need this line here in order to create windows from the cfix
// console application that runs our tests
if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0))
return;
// setup our objects
TLServer_WM s;
s.Start();
TestClient c;
TestClient c2;
char* sym = "TST";
int size = 200;
double price = 100;
TLMarketBasket mb;
mb.Add(sym);
c.Subscribe(mb);
// initial tests
CFIX_ASSERT(c.ticks+c.fills+c.orders==0);
// Tick test
TLTick k;
symcp(k.sym,sym);
//k.sym = sym;
k.trade = price;
k.size = size;
s.SrvGotTick(k); // send tick
CFIX_ASSERT(c.ticks==1);
// test output
// cout<<strcat(c.lasttick.sym,k.sym)<<endl;
CFIX_ASSERT(isstrsame(c.lasttick.sym,k.sym));
CFIX_ASSERT(c.lasttick.trade==k.trade);
// make sure ticks were not copied to other clients
CFIX_ASSERT(c.ticks!=c2.ticks);
// Fill test
TLTrade f;
f.symbol = sym;
f.xprice = price;
f.xsize = size;
f.xdate = 20081220;
f.xtime = 1556;
f.side = true;
s.SrvGotFill(f);
CFIX_ASSERT(c.fills==1);
CFIX_ASSERT(c.lastfill.symbol==f.symbol);
CFIX_ASSERT(c.lastfill.xprice==f.xprice);
// make sure fills were copiedto other clients
CFIX_ASSERT(c.fills==c2.fills);
// Order test
TLOrder o;
o.symbol = sym;
o.price = price;
o.size = size;
s.SrvGotOrder(o);
CFIX_ASSERT(c.orders==1);
CFIX_ASSERT(c.lastorder.symbol==o.symbol);
CFIX_ASSERT(c.lastorder.price==o.price);
// make sure orders were copied to other clients
CFIX_ASSERT(c.orders==c2.orders);
// performance test ticks
// reset ticks
c.ticks = 0;
// get random ticks
const int MAXTICKS = 1000;
vector<TLTick> ticks;
for (int i = 0; i<MAXTICKS; i++)
{
TLTick k;
symcp(k.sym,sym);
k.size = size;
k.trade = rand();
ticks.push_back(k);
}
// start timer
unsigned long start = GetTickCount();
// send ticks to clients
for (unsigned int i =0; i<ticks.size(); i++)
s.SrvGotTick(ticks[i]);
// stop timer
unsigned long stop = GetTickCount();
// elapased time
int elap = (stop - start);
// ticks per second
int rate = (MAXTICKS / elap)*1000;
CFIX_LOG(L"Performance elap (ms): %i",elap);
CFIX_LOG(L"Performance (ticks/sec): %i",rate);
// make sure it took reasonable time
CFIX_ASSERT(elap<200);
}
开发者ID:firememory,项目名称:TradeLinkProj,代码行数:98,代码来源:TestTLWM.cpp
注:本文中的TestClient类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论