From: Yedidya Feldblum Date: Fri, 9 Jun 2017 06:45:51 +0000 (-0700) Subject: Saner test exception in ExceptionWrapperTest.cpp X-Git-Tag: v2017.06.12.00~5 X-Git-Url: http://plrg.eecs.uci.edu/git/?p=folly.git;a=commitdiff_plain;h=6da8593f16cb4abaaaada4b979952b198dfdd2d3 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 --- 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 =