本文整理汇总了C++中unittest类的典型用法代码示例。如果您正苦于以下问题:C++ unittest类的具体用法?C++ unittest怎么用?C++ unittest使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了unittest类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: spec
// Multi-language : test nested arrays
TEST(FTSElementIterator, Test4) {
BSONObj obj = fromjson(
"{ language : \"english\","
" a : ["
" { language : \"danish\","
" b :"
" [ { c : [\"foredrag\"] },"
" { c : [\"foredragsholder\"] },"
" { c : [\"lector\"] } ]"
" } ]"
"}");
BSONObj indexSpec = fromjson("{ key : { \"a.b.c\" : \"text\" }, weights : { \"a.b.c\" : 5 } }");
FTSSpec spec(assertGet(FTSSpec::fixSpec(indexSpec)));
FTSElementIterator it(spec, obj);
ASSERT(it.more());
FTSIteratorValue val = it.next();
ASSERT_EQUALS("foredrag", string(val._text));
ASSERT_EQUALS("danish", val._language->str());
ASSERT_EQUALS(5, val._weight);
ASSERT(it.more());
val = it.next();
ASSERT_EQUALS("foredragsholder", string(val._text));
ASSERT_EQUALS("danish", val._language->str());
ASSERT_EQUALS(5, val._weight);
ASSERT(it.more());
val = it.next();
ASSERT_EQUALS("lector", string(val._text));
ASSERT_EQUALS("danish", val._language->str());
ASSERT_EQUALS(5, val._weight);
}
开发者ID:EvgeniyPatlan,项目名称:percona-server-mongodb,代码行数:36,代码来源:fts_element_iterator_test.cpp
示例2: expectConfigCollectionInsert
void ShardingTestFixture::expectConfigCollectionInsert(const HostAndPort& configHost,
StringData collName,
Date_t timestamp,
const std::string& what,
const std::string& ns,
const BSONObj& detail) {
onCommand([&](const RemoteCommandRequest& request) {
ASSERT_EQUALS(configHost, request.target);
ASSERT_EQUALS("config", request.dbname);
BatchedInsertRequest actualBatchedInsert;
std::string errmsg;
ASSERT_TRUE(actualBatchedInsert.parseBSON(request.dbname, request.cmdObj, &errmsg));
ASSERT_EQ("config", actualBatchedInsert.getNS().db());
ASSERT_EQ(collName, actualBatchedInsert.getNS().coll());
auto inserts = actualBatchedInsert.getDocuments();
ASSERT_EQUALS(1U, inserts.size());
const ChangeLogType& actualChangeLog = assertGet(ChangeLogType::fromBSON(inserts.front()));
ASSERT_EQUALS(operationContext()->getClient()->clientAddress(true),
actualChangeLog.getClientAddr());
ASSERT_EQUALS(detail, actualChangeLog.getDetails());
ASSERT_EQUALS(ns, actualChangeLog.getNS());
ASSERT_EQUALS(network()->getHostName(), actualChangeLog.getServer());
ASSERT_EQUALS(timestamp, actualChangeLog.getTime());
ASSERT_EQUALS(what, actualChangeLog.getWhat());
// Handle changeId specially because there's no way to know what OID was generated
std::string changeId = actualChangeLog.getChangeId();
size_t firstDash = changeId.find("-");
size_t lastDash = changeId.rfind("-");
const std::string serverPiece = changeId.substr(0, firstDash);
const std::string timePiece = changeId.substr(firstDash + 1, lastDash - firstDash - 1);
const std::string oidPiece = changeId.substr(lastDash + 1);
ASSERT_EQUALS(grid.getNetwork()->getHostName(), serverPiece);
ASSERT_EQUALS(timestamp.toString(), timePiece);
OID generatedOID;
// Just make sure this doesn't throws and assume the OID is valid
generatedOID.init(oidPiece);
BatchedCommandResponse response;
response.setOk(true);
return response.toBSON();
});
}
开发者ID:GodotGo,项目名称:mongo,代码行数:52,代码来源:sharding_test_fixture.cpp
示例3: runQueryAsCommand
void QueryPlannerTest::runQueryAsCommand(const BSONObj& cmdObj) {
solns.clear();
invariant(nss.isValid());
const bool isExplain = false;
std::unique_ptr<LiteParsedQuery> lpq(
assertGet(LiteParsedQuery::makeFromFindCommand(nss, cmdObj, isExplain)));
auto statusWithCQ = CanonicalQuery::canonicalize(lpq.release(), ExtensionsCallbackNoop());
ASSERT_OK(statusWithCQ.getStatus());
Status s = QueryPlanner::plan(*statusWithCQ.getValue(), params, &solns.mutableVector());
ASSERT_OK(s);
}
开发者ID:amidvidy,项目名称:mongo,代码行数:15,代码来源:query_planner_test_fixture.cpp
示例4: runQueryAsCommand
void QueryPlannerTest::runQueryAsCommand(const BSONObj& cmdObj) {
solns.clear();
const NamespaceString nss(ns);
invariant(nss.isValid());
const bool isExplain = false;
std::unique_ptr<LiteParsedQuery> lpq(
assertGet(LiteParsedQuery::makeFromFindCommand(nss, cmdObj, isExplain)));
CanonicalQuery* rawCq;
WhereCallbackNoop whereCallback;
Status canonStatus = CanonicalQuery::canonicalize(lpq.release(), &rawCq, whereCallback);
ASSERT_OK(canonStatus);
cq.reset(rawCq);
Status s = QueryPlanner::plan(*cq, params, &solns.mutableVector());
ASSERT_OK(s);
}
开发者ID:daveh86,项目名称:mongo,代码行数:19,代码来源:query_planner_test_fixture.cpp
示例5: expectSetShardVersion
void ShardingTestFixture::expectSetShardVersion(const HostAndPort& expectedHost,
const ShardType& expectedShard,
const NamespaceString& expectedNs,
const ChunkVersion& expectedChunkVersion) {
onCommand([&](const RemoteCommandRequest& request) {
ASSERT_EQ(expectedHost, request.target);
ASSERT_EQUALS(rpc::makeEmptyMetadata(), request.metadata);
SetShardVersionRequest ssv =
assertGet(SetShardVersionRequest::parseFromBSON(request.cmdObj));
ASSERT(!ssv.isInit());
ASSERT(ssv.isAuthoritative());
ASSERT_EQ(grid.shardRegistry()->getConfigServerConnectionString().toString(),
ssv.getConfigServer().toString());
ASSERT_EQ(expectedShard.getHost(), ssv.getShardConnectionString().toString());
ASSERT_EQ(expectedNs.toString(), ssv.getNS().ns());
ASSERT_EQ(expectedChunkVersion.toString(), ssv.getNSVersion().toString());
return BSON("ok" << true);
});
}
开发者ID:GodotGo,项目名称:mongo,代码行数:22,代码来源:sharding_test_fixture.cpp
示例6: runInvalidQueryAsCommand
void QueryPlannerTest::runInvalidQueryAsCommand(const BSONObj& cmdObj) {
solns.clear();
cq.reset();
invariant(nss.isValid());
const bool isExplain = false;
std::unique_ptr<QueryRequest> qr(
assertGet(QueryRequest::makeFromFindCommand(nss, cmdObj, isExplain)));
const boost::intrusive_ptr<ExpressionContext> expCtx;
auto statusWithCQ =
CanonicalQuery::canonicalize(opCtx.get(),
std::move(qr),
expCtx,
ExtensionsCallbackNoop(),
MatchExpressionParser::kAllowAllSpecialFeatures);
ASSERT_OK(statusWithCQ.getStatus());
cq = std::move(statusWithCQ.getValue());
auto statusWithSolutions = QueryPlanner::plan(*cq, params);
ASSERT_NOT_OK(statusWithSolutions.getStatus());
}
开发者ID:i80and,项目名称:mongo,代码行数:23,代码来源:query_planner_test_fixture.cpp
注:本文中的unittest类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论