aboutsummaryrefslogtreecommitdiff
path: root/pw_unit_test/framework.cc
diff options
context:
space:
mode:
Diffstat (limited to 'pw_unit_test/framework.cc')
-rw-r--r--pw_unit_test/framework.cc30
1 files changed, 30 insertions, 0 deletions
diff --git a/pw_unit_test/framework.cc b/pw_unit_test/framework.cc
index 945e2f4fb..e58cee0bf 100644
--- a/pw_unit_test/framework.cc
+++ b/pw_unit_test/framework.cc
@@ -78,6 +78,36 @@ int Framework::RunAllTests() {
return exit_status_;
}
+void Framework::SetUpTestSuiteIfNeeded(SetUpTestSuiteFunc set_up_ts) const {
+ if (set_up_ts == Test::SetUpTestSuite) {
+ return;
+ }
+
+ for (TestInfo* info = tests_; info != current_test_; info = info->next()) {
+ if (info->test_case().suite_name == current_test_->test_case().suite_name) {
+ return;
+ }
+ }
+
+ set_up_ts();
+}
+
+void Framework::TearDownTestSuiteIfNeeded(
+ TearDownTestSuiteFunc tear_down_ts) const {
+ if (tear_down_ts == Test::TearDownTestSuite) {
+ return;
+ }
+
+ for (TestInfo* info = current_test_->next(); info != nullptr;
+ info = info->next()) {
+ if (info->test_case().suite_name == current_test_->test_case().suite_name) {
+ return;
+ }
+ }
+
+ tear_down_ts();
+}
+
void Framework::StartTest(const TestInfo& test) {
current_test_ = &test;
current_result_ = TestResult::kSuccess;