mirror of
https://github.com/openharmony/third_party_jsoncpp.git
synced 2026-07-19 12:42:12 -04:00
@@ -73,11 +73,10 @@ namespace JsonTest {
|
||||
// class TestResult
|
||||
// //////////////////////////////////////////////////////////////////
|
||||
|
||||
TestResult::TestResult()
|
||||
: predicateId_(1), lastUsedPredicateId_(0), messageTarget_(JSONCPP_NULL) {
|
||||
TestResult::TestResult() {
|
||||
// The root predicate has id 0
|
||||
rootPredicateNode_.id_ = 0;
|
||||
rootPredicateNode_.next_ = JSONCPP_NULL;
|
||||
rootPredicateNode_.next_ = nullptr;
|
||||
predicateStackTail_ = &rootPredicateNode_;
|
||||
}
|
||||
|
||||
@@ -89,7 +88,7 @@ TestResult& TestResult::addFailure(const char* file, unsigned int line,
|
||||
/// added.
|
||||
unsigned int nestingLevel = 0;
|
||||
PredicateContext* lastNode = rootPredicateNode_.next_;
|
||||
for (; lastNode != JSONCPP_NULL; lastNode = lastNode->next_) {
|
||||
for (; lastNode != nullptr; lastNode = lastNode->next_) {
|
||||
if (lastNode->id_ > lastUsedPredicateId_) // new PredicateContext
|
||||
{
|
||||
lastUsedPredicateId_ = lastNode->id_;
|
||||
@@ -122,18 +121,17 @@ void TestResult::addFailureInfo(const char* file, unsigned int line,
|
||||
|
||||
TestResult& TestResult::popPredicateContext() {
|
||||
PredicateContext* lastNode = &rootPredicateNode_;
|
||||
while (lastNode->next_ != JSONCPP_NULL &&
|
||||
lastNode->next_->next_ != JSONCPP_NULL) {
|
||||
while (lastNode->next_ != nullptr && lastNode->next_->next_ != nullptr) {
|
||||
lastNode = lastNode->next_;
|
||||
}
|
||||
// Set message target to popped failure
|
||||
PredicateContext* tail = lastNode->next_;
|
||||
if (tail != JSONCPP_NULL && tail->failure_ != JSONCPP_NULL) {
|
||||
if (tail != nullptr && tail->failure_ != nullptr) {
|
||||
messageTarget_ = tail->failure_;
|
||||
}
|
||||
// Remove tail from list
|
||||
predicateStackTail_ = lastNode;
|
||||
lastNode->next_ = JSONCPP_NULL;
|
||||
lastNode->next_ = nullptr;
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -149,9 +147,7 @@ void TestResult::printFailure(bool printTestName) const {
|
||||
}
|
||||
|
||||
// Print in reverse to display the callstack in the right order
|
||||
for (Failures::const_iterator it = failures_.begin(); it != failures_.end();
|
||||
++it) {
|
||||
const Failure& failure = *it;
|
||||
for (const auto& failure : failures_) {
|
||||
Json::String indent(failure.nestingLevel_ * 2, ' ');
|
||||
if (failure.file_) {
|
||||
printf("%s%s(%u): ", indent.c_str(), failure.file_, failure.line_);
|
||||
@@ -185,7 +181,7 @@ Json::String TestResult::indentText(const Json::String& text,
|
||||
}
|
||||
|
||||
TestResult& TestResult::addToLastFailure(const Json::String& message) {
|
||||
if (messageTarget_ != JSONCPP_NULL) {
|
||||
if (messageTarget_ != nullptr) {
|
||||
messageTarget_->message_ += message;
|
||||
}
|
||||
return *this;
|
||||
@@ -206,9 +202,9 @@ TestResult& TestResult::operator<<(bool value) {
|
||||
// class TestCase
|
||||
// //////////////////////////////////////////////////////////////////
|
||||
|
||||
TestCase::TestCase() : result_(JSONCPP_NULL) {}
|
||||
TestCase::TestCase() = default;
|
||||
|
||||
TestCase::~TestCase() {}
|
||||
TestCase::~TestCase() = default;
|
||||
|
||||
void TestCase::run(TestResult& result) {
|
||||
result_ = &result;
|
||||
@@ -218,7 +214,7 @@ void TestCase::run(TestResult& result) {
|
||||
// class Runner
|
||||
// //////////////////////////////////////////////////////////////////
|
||||
|
||||
Runner::Runner() {}
|
||||
Runner::Runner() = default;
|
||||
|
||||
Runner& Runner::add(TestCaseFactory factory) {
|
||||
tests_.push_back(factory);
|
||||
@@ -272,8 +268,7 @@ bool Runner::runAllTest(bool printSummary) const {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
for (size_t index = 0; index < failures.size(); ++index) {
|
||||
TestResult& result = failures[index];
|
||||
for (auto& result : failures) {
|
||||
result.printFailure(count > 1);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user