From 6da8593f16cb4abaaaada4b979952b198dfdd2d3 Mon Sep 17 00:00:00 2001 From: Yedidya Feldblum Date: Thu, 8 Jun 2017 23:45:51 -0700 Subject: [PATCH] Saner test exception in ExceptionWrapperTest.cpp Summary: [Folly] Saner test exception in `ExceptionWrapperTest.cpp`. Make construction do the work and make `what()` free. Reviewed By: andrewjcg Differential Revision: D5216707 fbshipit-source-id: bfb4c2473a61ff7da7a3a01adc85facae30d6586 --- folly/test/ExceptionWrapperTest.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/folly/test/ExceptionWrapperTest.cpp b/folly/test/ExceptionWrapperTest.cpp index 07930ee0..58a32a17 100644 --- a/folly/test/ExceptionWrapperTest.cpp +++ b/folly/test/ExceptionWrapperTest.cpp @@ -29,17 +29,16 @@ class AbstractIntException : public std::exception { class IntException : public AbstractIntException { public: - explicit IntException(int i) : i_(i) {} + explicit IntException(int i) : i_(i), what_(to("int == ", i_)) {} int getInt() const override { return i_; } const char* what() const noexcept override { - what_ = folly::to("int == ", i_); return what_.c_str(); } private: int i_; - mutable std::string what_; + std::string what_; }; const static std::string kExceptionClassName = -- 2.34.1