From 5e7bc26f652b21955a0935c77fadc35cfd53ae81 Mon Sep 17 00:00:00 2001 From: Mikhail Zolotukhin Date: Tue, 16 Apr 2019 15:38:08 -0700 Subject: [PATCH] Fix ASSERT_ANY_THROW. (#19321) Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/19321 ghimport-source-id: 9efffc36950152105bd0dc13f450161367101410 Differential Revision: D14962184 Pulled By: ZolotukhinM fbshipit-source-id: 22d602f50eb5e17a3e3f59cc7feb59a8d88df00d --- test/cpp/jit/test_base.h | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/test/cpp/jit/test_base.h b/test/cpp/jit/test_base.h index c0e99d9..7726308 100644 --- a/test/cpp/jit/test_base.h +++ b/test/cpp/jit/test_base.h @@ -21,14 +21,16 @@ } catch (const std::exception& e) { \ ASSERT_NE(std::string(e.what()).find(substring), std::string::npos); \ } -#define ASSERT_ANY_THROW(statement) \ - bool threw = false; \ - try { \ - (void)statement; \ - } catch (const std::exception& e) { \ - threw = true; \ - } \ - ASSERT_TRUE(threw); +#define ASSERT_ANY_THROW(statement) \ + { \ + bool threw = false; \ + try { \ + (void)statement; \ + } catch (const std::exception& e) { \ + threw = true; \ + } \ + ASSERT_TRUE(threw); \ + } #endif // defined(USE_GTEST) -- 2.7.4