From 53c87558c97b3cd1ebba2d379cc6af157ad3eb30 Mon Sep 17 00:00:00 2001
From: patrick96
Date: Fri, 1 Jun 2018 15:24:09 +0200
Subject: [PATCH] tests: Convert scope test to gtest
---
tests/unit_tests/utils/scope.cpp | 24 +++++++++++-------------
1 file changed, 11 insertions(+), 13 deletions(-)
diff --git a/tests/unit_tests/utils/scope.cpp b/tests/unit_tests/utils/scope.cpp
index 5324e0d8..69ab87da 100644
--- a/tests/unit_tests/utils/scope.cpp
+++ b/tests/unit_tests/utils/scope.cpp
@@ -1,21 +1,19 @@
#include "common/test.hpp"
#include "utils/scope.hpp"
-int main() {
- using namespace polybar;
+using namespace polybar;
- "on_exit"_test = [] {
- auto flag = false;
+TEST(Scope, onExit) {
+ auto flag = false;
+ {
+ EXPECT_FALSE(flag);
+ auto handler = scope_util::make_exit_handler<>([&] { flag = true; });
+ EXPECT_FALSE(flag);
{
- expect(!flag);
auto handler = scope_util::make_exit_handler<>([&] { flag = true; });
- expect(!flag);
- {
- auto handler = scope_util::make_exit_handler<>([&] { flag = true; });
- }
- expect(flag);
- flag = false;
}
- expect(flag);
- };
+ EXPECT_TRUE(flag);
+ flag = false;
+ }
+ EXPECT_TRUE(flag);
}