这篇教程C++ ASSERT_OK函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中ASSERT_OK函数的典型用法代码示例。如果您正苦于以下问题:C++ ASSERT_OK函数的具体用法?C++ ASSERT_OK怎么用?C++ ASSERT_OK使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了ASSERT_OK函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: TESTTEST(CollectionOptions, MaxTimeMSWhitelistedOptionIgnored) { CollectionOptions options; auto status = options.parse(fromjson("{maxTimeMS: 1}")); ASSERT_OK(status);}
开发者ID:acmorrow,项目名称:mongo,代码行数:5,
示例2: TESTTEST(QueryRequestTest, PositiveBatchSize) { QueryRequest qr(testns); qr.setBatchSize(1); ASSERT_OK(qr.validate());}
开发者ID:ShaneHarvey,项目名称:mongo,代码行数:5,
示例3: addIndex void addIndex(const BSONObj& obj) { ASSERT_OK(dbtests::createIndex(&_txn, ns(), obj)); }
开发者ID:Andiry,项目名称:mongo,代码行数:3,
示例4: test_trailing_spaces_okstatic voidtest_trailing_spaces_ok(void){ ASSERT_OK("$ENV ", "NV");}
开发者ID:ackeack,项目名称:workenv,代码行数:5,
示例5: TEST_FTEST_F(PropertiesTest, SetString) { // Null key -> unsuccessful set { // Null key -> fails EXPECT_GT(0, property_set(/*key*/NULL, PROPERTY_TEST_VALUE_DEFAULT)); } // Null value -> returns default value { // Null value -> OK , and it clears the value EXPECT_OK(property_set(PROPERTY_TEST_KEY, /*value*/NULL)); ResetValue(); // Since the value is null, default value will be returned size_t len = property_get(PROPERTY_TEST_KEY, mValue, PROPERTY_TEST_VALUE_DEFAULT); EXPECT_EQ(strlen(PROPERTY_TEST_VALUE_DEFAULT), len); EXPECT_STREQ(PROPERTY_TEST_VALUE_DEFAULT, mValue); } // Trivial case => get returns what was set { size_t len = SetAndGetProperty("hello_world"); EXPECT_EQ(strlen("hello_world"), len) << "hello_world key"; EXPECT_STREQ("hello_world", mValue); ResetValue(); } // Set to empty string => get returns default always { const char* EMPTY_STRING_DEFAULT = "EMPTY_STRING"; size_t len = SetAndGetProperty("", EMPTY_STRING_DEFAULT); EXPECT_EQ(strlen(EMPTY_STRING_DEFAULT), len) << "empty key"; EXPECT_STREQ(EMPTY_STRING_DEFAULT, mValue); ResetValue(); } // Set to max length => get returns what was set { std::string maxLengthString = std::string(PROPERTY_VALUE_MAX-1, 'a'); int len = SetAndGetProperty(maxLengthString.c_str()); EXPECT_EQ(PROPERTY_VALUE_MAX-1, len) << "max length key"; EXPECT_STREQ(maxLengthString.c_str(), mValue); ResetValue(); } // Set to max length + 1 => set fails { const char* VALID_TEST_VALUE = "VALID_VALUE"; ASSERT_OK(property_set(PROPERTY_TEST_KEY, VALID_TEST_VALUE)); std::string oneLongerString = std::string(PROPERTY_VALUE_MAX, 'a'); // Expect that the value set fails since it's too long EXPECT_GT(0, property_set(PROPERTY_TEST_KEY, oneLongerString.c_str())); size_t len = property_get(PROPERTY_TEST_KEY, mValue, PROPERTY_TEST_VALUE_DEFAULT); EXPECT_EQ(strlen(VALID_TEST_VALUE), len) << "set should've failed"; EXPECT_STREQ(VALID_TEST_VALUE, mValue); ResetValue(); }}
开发者ID:BenzoRoms,项目名称:system_core,代码行数:63,
示例6: ConnectProducer // Connect to a producer in a 'correct' fashion. // Precondition: Consumer is connected. void ConnectProducer() { ASSERT_OK(TryConnectProducer()); }
开发者ID:debian-pkg-android-tools,项目名称:android-platform-frameworks-native,代码行数:5,
示例7: TEST_FTEST_F(IGraphicBufferProducerTest, Disconnect_Succeeds) { ASSERT_NO_FATAL_FAILURE(ConnectProducer()); ASSERT_OK(mProducer->disconnect(TEST_API));}
开发者ID:debian-pkg-android-tools,项目名称:android-platform-frameworks-native,代码行数:5,
示例8: TESTTEST(CollectionOptions, CollationFieldLeftEmptyWhenOmitted) { CollectionOptions options; ASSERT_OK(options.parse(fromjson("{validator: {a: 1}}"))); ASSERT_TRUE(options.collation.isEmpty());}
开发者ID:AlexOreshkevich,项目名称:mongo,代码行数:5,
示例9: TEST // Insert a record and try to perform an in-place update on it. TEST( RecordStoreTestHarness, UpdateWithDamages ) { scoped_ptr<HarnessHelper> harnessHelper( newHarnessHelper() ); scoped_ptr<RecordStore> rs( harnessHelper->newNonCappedRecordStore() ); if (!rs->updateWithDamagesSupported()) return; { scoped_ptr<OperationContext> opCtx( harnessHelper->newOperationContext() ); ASSERT_EQUALS( 0, rs->numRecords( opCtx.get() ) ); } string data = "00010111"; RecordId loc; const RecordData rec(data.c_str(), data.size() + 1); { scoped_ptr<OperationContext> opCtx( harnessHelper->newOperationContext() ); { WriteUnitOfWork uow( opCtx.get() ); StatusWith<RecordId> res = rs->insertRecord( opCtx.get(), rec.data(), rec.size(), false ); ASSERT_OK( res.getStatus() ); loc = res.getValue(); uow.commit(); } } { scoped_ptr<OperationContext> opCtx( harnessHelper->newOperationContext() ); ASSERT_EQUALS( 1, rs->numRecords( opCtx.get() ) ); } { scoped_ptr<OperationContext> opCtx( harnessHelper->newOperationContext() ); { mutablebson::DamageVector dv( 3 ); dv[0].sourceOffset = 5; dv[0].targetOffset = 0; dv[0].size = 2; dv[1].sourceOffset = 3; dv[1].targetOffset = 2; dv[1].size = 3; dv[2].sourceOffset = 0; dv[2].targetOffset = 5; dv[2].size = 3; WriteUnitOfWork uow( opCtx.get() ); ASSERT_OK( rs->updateWithDamages( opCtx.get(), loc, rec, data.c_str(), dv ) ); uow.commit(); } } data = "11101000"; { scoped_ptr<OperationContext> opCtx( harnessHelper->newOperationContext() ); { RecordData record = rs->dataFor( opCtx.get(), loc ); ASSERT_EQUALS( data, record.data() ); } } }
开发者ID:7segments,项目名称:mongo-1,代码行数:64,
示例10: test_simple_okstatic voidtest_simple_ok(void){ ASSERT_OK("$ENV", "NV");}
开发者ID:ackeack,项目名称:workenv,代码行数:5,
示例11: TESTTEST(SSLManager, MongoDBRolesParser) { /* openssl asn1parse -genconf mongodbroles.cnf -out foo.der -------- mongodbroles.cnf -------- asn1 = SET:MongoDBAuthorizationGrant [MongoDBAuthorizationGrant] grant1 = SEQUENCE:MongoDBRole [MongoDBRole] role = UTF8:role_name database = UTF8:Third field */ // Positive: Simple parsing test { unsigned char derData[] = {0x31, 0x1a, 0x30, 0x18, 0x0c, 0x09, 0x72, 0x6f, 0x6c, 0x65, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x0c, 0x0b, 0x54, 0x68, 0x69, 0x72, 0x64, 0x20, 0x66, 0x69, 0x65, 0x6c, 0x64}; auto swPeer = parsePeerRoles(ConstDataRange(reinterpret_cast<char*>(derData), std::extent<decltype(derData)>::value)); ASSERT_OK(swPeer.getStatus()); auto item = *(swPeer.getValue().begin()); ASSERT_EQ(item.getRole(), "role_name"); ASSERT_EQ(item.getDB(), "Third field"); } // Positive: Very long role_name, and long form lengths { unsigned char derData[] = { 0x31, 0x82, 0x01, 0x3e, 0x30, 0x82, 0x01, 0x3a, 0x0c, 0x82, 0x01, 0x29, 0x72, 0x6f, 0x6c, 0x65, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x72, 0x6f, 0x6c, 0x65, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x72, 0x6f, 0x6c, 0x65, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x72, 0x6f, 0x6c, 0x65, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x72, 0x6f, 0x6c, 0x65, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x72, 0x6f, 0x6c, 0x65, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x72, 0x6f, 0x6c, 0x65, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x72, 0x6f, 0x6c, 0x65, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x72, 0x6f, 0x6c, 0x65, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x72, 0x6f, 0x6c, 0x65, 0x5f, 0x6e, 0x61, 0x6d, 0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, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x72, 0x6f, 0x6c, 0x65, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x72, 0x6f, 0x6c, 0x65, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x0c, 0x0b, 0x54, 0x68, 0x69, 0x72, 0x64, 0x20, 0x66, 0x69, 0x65, 0x6c, 0x64}; auto swPeer = parsePeerRoles(ConstDataRange(reinterpret_cast<char*>(derData), std::extent<decltype(derData)>::value)); ASSERT_OK(swPeer.getStatus()); auto item = *(swPeer.getValue().begin()); ASSERT_EQ(item.getRole(), "role_namerole_namerole_namerole_namerole_namerole_namerole_namerole_namerole_" "namerole_namerole_namerole_namerole_namerole_namerole_namerole_namerole_" "namerole_namerole_namerole_namerole_namerole_namerole_namerole_namerole_" "namerole_namerole_namerole_namerole_namerole_namerole_namerole_namerole_name"); ASSERT_EQ(item.getDB(), "Third field"); } // Negative: Encode MAX_INT64 into a length { unsigned char derData[] = {0x31, 0x88, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x3e, 0x18, 0x0c, 0x09, 0x72, 0x6f, 0x6c, 0x65, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x0c, 0x0b, 0x54, 0x68, 0x69, 0x72, 0x64, 0x20, 0x66, 0x69, 0x65, 0x6c, 0x64}; auto swPeer = parsePeerRoles(ConstDataRange(reinterpret_cast<char*>(derData), std::extent<decltype(derData)>::value)); ASSERT_NOT_OK(swPeer.getStatus()); } // Negative: Runt, only a tag { unsigned char derData[] = {0x31}; auto swPeer = parsePeerRoles(ConstDataRange(reinterpret_cast<char*>(derData), std::extent<decltype(derData)>::value)); ASSERT_NOT_OK(swPeer.getStatus()); } // Negative: Runt, only a tag and short length { unsigned char derData[] = {0x31, 0x0b}; auto swPeer = parsePeerRoles(ConstDataRange(reinterpret_cast<char*>(derData), std::extent<decltype(derData)>::value)); ASSERT_NOT_OK(swPeer.getStatus()); } // Negative: Runt, only a tag and long length with wrong missing length { unsigned char derData[] = { 0x31, 0x88, 0xff, 0xff, }; auto swPeer = parsePeerRoles(ConstDataRange(reinterpret_cast<char*>(derData),//.........这里部分代码省略.........
开发者ID:ShaneHarvey,项目名称:mongo,代码行数:101,
示例12: TESTTEST(KVEngineTestHarness, AllCommittedTimestamp) { unique_ptr<KVHarnessHelper> helper(KVHarnessHelper::create()); KVEngine* engine = helper->getEngine(); if (!engine->supportsDocLocking()) return; unique_ptr<RecordStore> rs; { MyOperationContext opCtx(engine); WriteUnitOfWork uow(&opCtx); CollectionOptions options; options.capped = true; options.cappedSize = 10240; options.cappedMaxDocs = -1; NamespaceString oplogNss("local.oplog.rs"); ASSERT_OK(engine->createRecordStore(&opCtx, oplogNss.ns(), "ident", options)); rs = engine->getRecordStore(&opCtx, oplogNss.ns(), "ident", options); ASSERT(rs); } { Timestamp t11(1, 1); Timestamp t12(1, 2); Timestamp t21(2, 1); auto t11Doc = BSON("ts" << t11); auto t12Doc = BSON("ts" << t12); auto t21Doc = BSON("ts" << t21); Timestamp allCommitted = engine->getAllCommittedTimestamp(); MyOperationContext opCtx1(engine); WriteUnitOfWork uow1(&opCtx1); ASSERT_EQ(invariant(rs->insertRecord( &opCtx1, t11Doc.objdata(), t11Doc.objsize(), Timestamp::min())), RecordId(1, 1)); Timestamp lastAllCommitted = allCommitted; allCommitted = engine->getAllCommittedTimestamp(); ASSERT_GTE(allCommitted, lastAllCommitted); ASSERT_LT(allCommitted, t11); MyOperationContext opCtx2(engine); WriteUnitOfWork uow2(&opCtx2); ASSERT_EQ(invariant(rs->insertRecord( &opCtx2, t21Doc.objdata(), t21Doc.objsize(), Timestamp::min())), RecordId(2, 1)); uow2.commit(); lastAllCommitted = allCommitted; allCommitted = engine->getAllCommittedTimestamp(); ASSERT_GTE(allCommitted, lastAllCommitted); ASSERT_LT(allCommitted, t11); ASSERT_EQ(invariant(rs->insertRecord( &opCtx1, t12Doc.objdata(), t12Doc.objsize(), Timestamp::min())), RecordId(1, 2)); lastAllCommitted = allCommitted; allCommitted = engine->getAllCommittedTimestamp(); ASSERT_GTE(allCommitted, lastAllCommitted); ASSERT_LT(allCommitted, t11); uow1.commit(); lastAllCommitted = allCommitted; allCommitted = engine->getAllCommittedTimestamp(); ASSERT_GTE(allCommitted, lastAllCommitted); ASSERT_LTE(allCommitted, t21); }}
开发者ID:hanumantmk,项目名称:mongo,代码行数:70,
示例13: insert void insert(const BSONObj& doc) { WriteUnitOfWork wunit(&_txn); ASSERT_OK(_coll->insertDocument(&_txn, doc, false)); wunit.commit(); }
开发者ID:CeperaCPP,项目名称:mongo,代码行数:5,
示例14: addSample void addSample(const BSONObj& sample) { ASSERT_OK(_writer.writeSample(sample, Date_t())); _docs.emplace_back(sample); }
开发者ID:stevelyall,项目名称:mongol-db,代码行数:4,
示例15: START_TEST} END_TESTSTART_TEST(calculate_age_from_current_and_birthday) { ASSERT_OK(subtract(roman, "MMXVI", "MCMLVIII")); ck_assert_str_eq(roman, "LVIII");} END_TEST
开发者ID:rconaway,项目名称:roman-kata-c,代码行数:6,
注:本文中的ASSERT_OK函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ ASSERT_ON_ERROR函数代码示例 C++ ASSERT_NULL函数代码示例 |