本文整理汇总了C++中CXXTOOLS_UNIT_ASSERT_EQUALS函数的典型用法代码示例。如果您正苦于以下问题:C++ CXXTOOLS_UNIT_ASSERT_EQUALS函数的具体用法?C++ CXXTOOLS_UNIT_ASSERT_EQUALS怎么用?C++ CXXTOOLS_UNIT_ASSERT_EQUALS使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了CXXTOOLS_UNIT_ASSERT_EQUALS函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: testQueryParams
void testQueryParams()
{
cxxtools::QueryParams q;
q.add("p1", "value1");
q.add("p2", "value2");
q.add("value3");
CXXTOOLS_UNIT_ASSERT(q.has("p1"));
CXXTOOLS_UNIT_ASSERT(q.has("p2"));
CXXTOOLS_UNIT_ASSERT(!q.has("p3"));
CXXTOOLS_UNIT_ASSERT_EQUALS(q["p1"], "value1");
CXXTOOLS_UNIT_ASSERT_EQUALS(q["p2"], "value2");
CXXTOOLS_UNIT_ASSERT_EQUALS(q[0], "value3");
}
示例2: muldiv
void muldiv()
{
cxxtools::Seconds t1(2500);
cxxtools::Timespan d = t1 * 2.0;
CXXTOOLS_UNIT_ASSERT_EQUALS(d, cxxtools::Seconds(5000));
d = 3.0 * t1;
CXXTOOLS_UNIT_ASSERT_EQUALS(d, cxxtools::Seconds(7500));
d = t1 / 2.0;
CXXTOOLS_UNIT_ASSERT_EQUALS(d, cxxtools::Seconds(1250));
}
示例3: testCopy
void testCopy()
{
cxxtools::QueryParams q;
q.add("p1", "value1");
q.add("p2", "value2");
q.add("value3");
cxxtools::QueryParams q2 = q;
CXXTOOLS_UNIT_ASSERT(q2.has("p1"));
CXXTOOLS_UNIT_ASSERT(q2.has("p2"));
CXXTOOLS_UNIT_ASSERT(!q2.has("p3"));
CXXTOOLS_UNIT_ASSERT_EQUALS(q2["p1"], "value1");
CXXTOOLS_UNIT_ASSERT_EQUALS(q2["p2"], "value2");
CXXTOOLS_UNIT_ASSERT_EQUALS(q2[0], "value3");
}
示例4: s
void StringTest::testReserve()
{
const cxxtools::Char c1[] = { 'a', 'b', 'c', 'd', '\0' };
cxxtools::String s(L"abcd");
cxxtools::String s2 = s;
s2.reserve(10);
CXXTOOLS_UNIT_ASSERT( s2.capacity() >= 10 );
CXXTOOLS_UNIT_ASSERT( s2.size() == 4 );
CXXTOOLS_UNIT_ASSERT_EQUALS( std::char_traits<cxxtools::Char>::compare(s2.c_str(), c1, 4) , 0 );
CXXTOOLS_UNIT_ASSERT( s.capacity() >= 4 );
CXXTOOLS_UNIT_ASSERT_EQUALS( s.size(), 4 );
CXXTOOLS_UNIT_ASSERT_EQUALS( std::char_traits<cxxtools::Char>::compare(s.c_str(), c1, 4) , 0 );
}
示例5: testArgChar
void testArgChar()
{
int argc = 5;
char* argv[] = { arg("prog"), arg("-D"), arg("A"), arg("-F"), arg("\t"), 0 };
cxxtools::Arg<char> optionA(argc, argv, 'A');
cxxtools::Arg<char> optionD(argc, argv, 'D');
cxxtools::Arg<char> optionF(argc, argv, 'F');
CXXTOOLS_UNIT_ASSERT(!optionA.isSet());
CXXTOOLS_UNIT_ASSERT(optionD.isSet());
CXXTOOLS_UNIT_ASSERT(optionF.isSet());
CXXTOOLS_UNIT_ASSERT_EQUALS(*optionD, 'A');
CXXTOOLS_UNIT_ASSERT_EQUALS(*optionF, '\t');
CXXTOOLS_UNIT_ASSERT_EQUALS(argc, 1);
}
示例6: multipartMessage
void multipartMessage()
{
cxxtools::MimeMultipart mp;
mp.addObject();
mp.addObject();
CXXTOOLS_UNIT_ASSERT_EQUALS(mp.size(), 2);
}
示例7: bunzip2OstreamTest
void bunzip2OstreamTest()
{
// test
std::stringstream bzip2target;
{
zim::Bzip2Stream compressor(bzip2target);
compressor << testtext << std::flush;
compressor.end();
}
{
std::ostringstream msg;
msg << "teststring with " << testtext.size() << " bytes compressed into " << bzip2target.str().size() << " bytes";
reportMessage(msg.str());
}
std::ostringstream bunzip2target;
{
zim::Bunzip2Stream bunzip2(bunzip2target); // bunzip2 is a ostream here
bunzip2 << bzip2target.str() << std::flush;
}
{
std::ostringstream msg;
msg << "teststring uncompressed to " << bunzip2target.str().size() << " bytes";
reportMessage(msg.str());
}
CXXTOOLS_UNIT_ASSERT_EQUALS(testtext, bunzip2target.str());
}
示例8: inflatorOstreamTest
void inflatorOstreamTest()
{
// test
std::stringstream deflatetarget;
zim::DeflateStream deflator(deflatetarget);
deflator << testtext << std::flush;
{
std::ostringstream msg;
msg << "teststring with " << testtext.size() << " bytes compressed into " << deflatetarget.str().size() << " bytes";
reportMessage(msg.str());
}
std::ostringstream inflatetarget;
zim::InflateStream inflator(inflatetarget); // inflator is a ostream here
inflator << deflatetarget.str() << std::flush;
{
std::ostringstream msg;
msg << "teststring uncompressed to " << inflatetarget.str().size() << " bytes";
reportMessage(msg.str());
}
CXXTOOLS_UNIT_ASSERT_EQUALS(testtext, inflatetarget.str());
}
示例9: Multiple
////////////////////////////////////////////////////////////
// Multiple calls
//
void Multiple()
{
_server->registerMethod("multiply", *this, &BinRpcTest::multiplyDouble);
typedef cxxtools::RemoteProcedure<double, double, double> Multiply;
std::vector<cxxtools::bin::RpcClient> clients;
std::vector<Multiply> procs;
clients.reserve(16);
procs.reserve(16);
for (unsigned i = 0; i < 16; ++i)
{
clients.push_back(cxxtools::bin::RpcClient(_loop, "", _port));
procs.push_back(Multiply(clients.back(), "multiply"));
procs.back().begin(i, i);
}
for (unsigned i = 0; i < 16; ++i)
{
CXXTOOLS_UNIT_ASSERT_EQUALS(procs[i].end(2000), i*i);
}
}
示例10: testPlainInt
void testPlainInt()
{
std::ostringstream out;
cxxtools::JsonSerializer serializer(out);
serializer.serialize(-4711).finish();
CXXTOOLS_UNIT_ASSERT_EQUALS(out.str(), "-4711");
}
示例11: testPlainEmpty
void testPlainEmpty()
{
std::ostringstream out;
cxxtools::JsonSerializer serializer(out);
serializer.finish();
CXXTOOLS_UNIT_ASSERT_EQUALS(out.str(), "");
}
示例12: testInt
void testInt()
{
std::ostringstream out;
cxxtools::JsonSerializer serializer(out);
serializer.serialize(-4711, "value").finish();
CXXTOOLS_UNIT_ASSERT_EQUALS(out.str(), "{\"value\":-4711}");
}
示例13: Array
////////////////////////////////////////////////////////////
// Array
//
void Array()
{
_server->registerMethod("multiply", *this, &BinRpcTest::multiplyVector);
cxxtools::bin::RpcClient client(_loop, "", _port);
cxxtools::RemoteProcedure< std::vector<int>, std::vector<int>, std::vector<int> > multiply(client, "multiply");
std::vector<int> vec;
vec.push_back(10);
vec.push_back(20);
multiply.begin(vec, vec);
std::vector<int> r = multiply.end(2000);
CXXTOOLS_UNIT_ASSERT_EQUALS(r.size(), 2);
CXXTOOLS_UNIT_ASSERT_EQUALS(r.at(0), 100);
CXXTOOLS_UNIT_ASSERT_EQUALS(r.at(1), 400);
}
示例14: Connect
////////////////////////////////////////////////////////////
// Connect
//
void Connect()
{
_server->registerMethod("boolean", *this, &BinRpcTest::boolean);
// test connect using cxxtools::net::AddrInfo
{
cxxtools::bin::RpcClient client(_loop);
cxxtools::RemoteProcedure<bool, bool, bool> boolean(client, "boolean");
client.connect(cxxtools::net::AddrInfo("", _port));
boolean.begin(true, true);
CXXTOOLS_UNIT_ASSERT_EQUALS(boolean.end(2000), true);
}
// test connect using host and port
{
cxxtools::bin::RpcClient client(_loop);
cxxtools::RemoteProcedure<bool, bool, bool> boolean(client, "boolean");
client.connect("", _port);
boolean.begin(true, true);
CXXTOOLS_UNIT_ASSERT_EQUALS(boolean.end(2000), true);
}
// test connect using uri
{
cxxtools::bin::RpcClient client(_loop);
cxxtools::RemoteProcedure<bool, bool, bool> boolean(client, "boolean");
std::ostringstream uri;
uri << "http://localhost:" << _port << '/';
client.connect(cxxtools::net::Uri(uri.str()));
boolean.begin(true, true);
CXXTOOLS_UNIT_ASSERT_EQUALS(boolean.end(2000), true);
}
// test failing connect
{
cxxtools::bin::RpcClient client(_loop);
cxxtools::RemoteProcedure<bool, bool, bool> boolean(client, "boolean");
CXXTOOLS_UNIT_ASSERT_THROW(client.connect("", _port + 1), cxxtools::IOError);
}
}
示例15: testArgBool
void testArgBool()
{
int argc = 7;
char* argv[] = { arg("prog"), arg("-i"), arg("-j"), arg("-k"),
arg("-cf"), arg("--foo"), arg("foo"), 0 };
cxxtools::Arg<bool> optionJ(argc, argv, 'j');
cxxtools::Arg<bool> optionL(argc, argv, 'l');
cxxtools::Arg<bool> optionC(argc, argv, 'c');
cxxtools::Arg<bool> optionFoo(argc, argv, "--foo");
cxxtools::Arg<bool> optionBar(argc, argv, "--bar");
CXXTOOLS_UNIT_ASSERT(optionJ);
CXXTOOLS_UNIT_ASSERT(!optionL);
CXXTOOLS_UNIT_ASSERT(optionC);
CXXTOOLS_UNIT_ASSERT(optionFoo);
CXXTOOLS_UNIT_ASSERT(!optionBar);
CXXTOOLS_UNIT_ASSERT_EQUALS(argc, 5);
CXXTOOLS_UNIT_ASSERT_EQUALS(strcmp(argv[0], "prog"), 0);
CXXTOOLS_UNIT_ASSERT_EQUALS(strcmp(argv[1], "-i"), 0);
CXXTOOLS_UNIT_ASSERT_EQUALS(strcmp(argv[2], "-k"), 0);
CXXTOOLS_UNIT_ASSERT_EQUALS(strcmp(argv[3], "-f"), 0);
CXXTOOLS_UNIT_ASSERT_EQUALS(strcmp(argv[4], "foo"), 0);
CXXTOOLS_UNIT_ASSERT_EQUALS(argv[5], static_cast<const char*>(0));
}