CodeMod: Prefer ADD_FAILURE() over EXPECT_TRUE(false), et cetera
Summary: CodeMod: Prefer `ADD_FAILURE()` over `EXPECT_TRUE(false)`, et cetera. The tautologically-conditioned and tautologically-contradicted boolean expectations/assertions have better alternatives: unconditional passes and failures. Reviewed By: Orvid Differential Revision: D5432398 Tags: codemod, codemod-opensource fbshipit-source-id: d16b447e8696a6feaa94b41199f5052226ef6914
This commit is contained in:
parent
4a2e4891fe
commit
f1a056e005
@ -152,7 +152,7 @@ class CorruptionTest : public testing::Test {
|
||||
struct stat sbuf;
|
||||
if (stat(fname.c_str(), &sbuf) != 0) {
|
||||
const char* msg = strerror(errno);
|
||||
ASSERT_TRUE(false) << fname << ": " << msg;
|
||||
FAIL() << fname << ": " << msg;
|
||||
}
|
||||
|
||||
if (offset < 0) {
|
||||
@ -213,7 +213,7 @@ class CorruptionTest : public testing::Test {
|
||||
return;
|
||||
}
|
||||
}
|
||||
ASSERT_TRUE(false) << "no file found at level";
|
||||
FAIL() << "no file found at level";
|
||||
}
|
||||
|
||||
|
||||
|
@ -497,7 +497,7 @@ TEST_F(DBBlockCacheTest, CompressedCache) {
|
||||
options.compression = kNoCompression;
|
||||
break;
|
||||
default:
|
||||
ASSERT_TRUE(false);
|
||||
FAIL();
|
||||
}
|
||||
CreateAndReopenWithCF({"pikachu"}, options);
|
||||
// default column family doesn't have block cache
|
||||
@ -560,7 +560,7 @@ TEST_F(DBBlockCacheTest, CompressedCache) {
|
||||
ASSERT_EQ(TestGetTickerCount(options, BLOCK_CACHE_COMPRESSED_HIT), 0);
|
||||
break;
|
||||
default:
|
||||
ASSERT_TRUE(false);
|
||||
FAIL();
|
||||
}
|
||||
|
||||
options.create_if_missing = true;
|
||||
|
@ -451,20 +451,20 @@ TEST_F(WriteBatchTest, DISABLED_ManyUpdates) {
|
||||
}
|
||||
virtual Status DeleteCF(uint32_t column_family_id,
|
||||
const Slice& key) override {
|
||||
EXPECT_TRUE(false);
|
||||
ADD_FAILURE();
|
||||
return Status::OK();
|
||||
}
|
||||
virtual Status SingleDeleteCF(uint32_t column_family_id,
|
||||
const Slice& key) override {
|
||||
EXPECT_TRUE(false);
|
||||
ADD_FAILURE();
|
||||
return Status::OK();
|
||||
}
|
||||
virtual Status MergeCF(uint32_t column_family_id, const Slice& key,
|
||||
const Slice& value) override {
|
||||
EXPECT_TRUE(false);
|
||||
ADD_FAILURE();
|
||||
return Status::OK();
|
||||
}
|
||||
virtual void LogData(const Slice& blob) override { EXPECT_TRUE(false); }
|
||||
virtual void LogData(const Slice& blob) override { ADD_FAILURE(); }
|
||||
virtual bool Continue() override { return num_seen < kNumUpdates; }
|
||||
} handler;
|
||||
|
||||
@ -502,20 +502,20 @@ TEST_F(WriteBatchTest, DISABLED_LargeKeyValue) {
|
||||
}
|
||||
virtual Status DeleteCF(uint32_t column_family_id,
|
||||
const Slice& key) override {
|
||||
EXPECT_TRUE(false);
|
||||
ADD_FAILURE();
|
||||
return Status::OK();
|
||||
}
|
||||
virtual Status SingleDeleteCF(uint32_t column_family_id,
|
||||
const Slice& key) override {
|
||||
EXPECT_TRUE(false);
|
||||
ADD_FAILURE();
|
||||
return Status::OK();
|
||||
}
|
||||
virtual Status MergeCF(uint32_t column_family_id, const Slice& key,
|
||||
const Slice& value) override {
|
||||
EXPECT_TRUE(false);
|
||||
ADD_FAILURE();
|
||||
return Status::OK();
|
||||
}
|
||||
virtual void LogData(const Slice& blob) override { EXPECT_TRUE(false); }
|
||||
virtual void LogData(const Slice& blob) override { ADD_FAILURE(); }
|
||||
virtual bool Continue() override { return num_seen < 2; }
|
||||
} handler;
|
||||
|
||||
|
@ -137,7 +137,7 @@ void MockTableFactory::AssertLatestFile(
|
||||
ParseInternalKey(Slice(key), &ikey);
|
||||
std::cout << ikey.DebugString(false) << " -> " << value << std::endl;
|
||||
}
|
||||
ASSERT_TRUE(false);
|
||||
FAIL();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -569,7 +569,7 @@ TEST_F(ThreadLocalTest, DISABLED_MainThreadDiesFirst) {
|
||||
#ifndef ROCKSDB_LITE
|
||||
} catch (const std::system_error& ex) {
|
||||
std::cerr << "Start thread: " << ex.code() << std::endl;
|
||||
ASSERT_TRUE(false);
|
||||
FAIL();
|
||||
}
|
||||
#endif // ROCKSDB_LITE
|
||||
}
|
||||
|
@ -101,7 +101,7 @@ class DummyDB : public StackableDB {
|
||||
|
||||
virtual uint64_t LogNumber() const override {
|
||||
// what business do you have calling this method?
|
||||
EXPECT_TRUE(false);
|
||||
ADD_FAILURE();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -372,7 +372,7 @@ TEST_F(CheckpointTest, CheckpointCFNoFlush) {
|
||||
rocksdb::SyncPoint::GetInstance()->SetCallBack(
|
||||
"DBImpl::BackgroundCallFlush:start", [&](void* arg) {
|
||||
// Flush should never trigger.
|
||||
ASSERT_TRUE(false);
|
||||
FAIL();
|
||||
});
|
||||
rocksdb::SyncPoint::GetInstance()->EnableProcessing();
|
||||
Checkpoint* checkpoint;
|
||||
|
@ -26,7 +26,7 @@ class StopOnErrorLogger : public Logger {
|
||||
virtual void Logv(const char* format, va_list ap) override {
|
||||
vfprintf(stderr, format, ap);
|
||||
fprintf(stderr, "\n");
|
||||
ASSERT_TRUE(false);
|
||||
FAIL();
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -372,7 +372,7 @@ void PersistentCacheDBTest::RunTest(
|
||||
options.table_factory.reset(NewBlockBasedTableFactory(table_options));
|
||||
break;
|
||||
default:
|
||||
ASSERT_TRUE(false);
|
||||
FAIL();
|
||||
}
|
||||
|
||||
std::vector<std::string> values;
|
||||
@ -425,7 +425,7 @@ void PersistentCacheDBTest::RunTest(
|
||||
ASSERT_EQ(compressed_block_miss, 0);
|
||||
break;
|
||||
default:
|
||||
ASSERT_TRUE(false);
|
||||
FAIL();
|
||||
}
|
||||
|
||||
options.create_if_missing = true;
|
||||
|
@ -242,7 +242,7 @@ TEST_P(TransactionTest, WaitingTxn) {
|
||||
|
||||
// Column family is 1 or 0 (cfa).
|
||||
if (cf_iterator->first != 1 && cf_iterator->first != 0) {
|
||||
ASSERT_FALSE(true);
|
||||
FAIL();
|
||||
}
|
||||
// The locked key is "foo" and is locked by txn1
|
||||
ASSERT_EQ(cf_iterator->second.key, "foo");
|
||||
@ -253,7 +253,7 @@ TEST_P(TransactionTest, WaitingTxn) {
|
||||
|
||||
// Column family is 0 (default) or 1.
|
||||
if (cf_iterator->first != 1 && cf_iterator->first != 0) {
|
||||
ASSERT_FALSE(true);
|
||||
FAIL();
|
||||
}
|
||||
// The locked key is "foo" and is locked by txn1
|
||||
ASSERT_EQ(cf_iterator->second.key, "foo");
|
||||
@ -1080,7 +1080,7 @@ TEST_P(TransactionTest, DISABLED_TwoPhaseMultiThreadTest) {
|
||||
env->SleepForMicroseconds(10);
|
||||
}
|
||||
} else {
|
||||
ASSERT_TRUE(false);
|
||||
FAIL();
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -131,7 +131,7 @@ class TtlTest : public testing::Test {
|
||||
batch.Delete(kv_it_->first);
|
||||
break;
|
||||
default:
|
||||
ASSERT_TRUE(false);
|
||||
FAIL();
|
||||
}
|
||||
}
|
||||
db_ttl_->Write(wopts, &batch);
|
||||
@ -184,12 +184,12 @@ class TtlTest : public testing::Test {
|
||||
if (ret == false || value_found == false) {
|
||||
fprintf(stderr, "KeyMayExist could not find key=%s in the database but"
|
||||
" should have\n", kv.first.c_str());
|
||||
ASSERT_TRUE(false);
|
||||
FAIL();
|
||||
} else if (val.compare(kv.second) != 0) {
|
||||
fprintf(stderr, " value for key=%s present in database is %s but"
|
||||
" should be %s\n", kv.first.c_str(), val.c_str(),
|
||||
kv.second.c_str());
|
||||
ASSERT_TRUE(false);
|
||||
FAIL();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -239,18 +239,18 @@ class TtlTest : public testing::Test {
|
||||
} else {
|
||||
fprintf(stderr, "is present in db but was expected to be absent\n");
|
||||
}
|
||||
ASSERT_TRUE(false);
|
||||
FAIL();
|
||||
} else if (s.ok()) {
|
||||
if (test_compaction_change && v.compare(kNewValue_) != 0) {
|
||||
fprintf(stderr, " value for key=%s present in database is %s but "
|
||||
" should be %s\n", kv_it_->first.c_str(), v.c_str(),
|
||||
kNewValue_.c_str());
|
||||
ASSERT_TRUE(false);
|
||||
FAIL();
|
||||
} else if (!test_compaction_change && v.compare(kv_it_->second) !=0) {
|
||||
fprintf(stderr, " value for key=%s present in database is %s but "
|
||||
" should be %s\n", kv_it_->first.c_str(), v.c_str(),
|
||||
kv_it_->second.c_str());
|
||||
ASSERT_TRUE(false);
|
||||
FAIL();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user