GithubHelp home page GithubHelp logo

Comments (3)

GoogleCodeExporter avatar GoogleCodeExporter commented on May 28, 2024
I missed a backslash:

====
//depot/agent/main/ThirdPartySource/gtest/1.1.0/include/gtest/internal/gtest-int
ernal.h#1
-
C:\depot\agent\main\ThirdPartySource\gtest\1.1.0\include\gtest\internal\gtest-in
ternal.h
====
@@ -728,6 +728,10 @@
     catch (expected_exception const&) { \
       gtest_caught_expected = true; \
     } \
+    catch (expected_exception const* expected_exception_const_pointer) { \
+      delete expected_exception_const_pointer; \
+      gtest_caught_expected = true; \
+    } \
     catch (...) { \
       gtest_msg = "Expected: " #statement " throws an exception of type " \
                   #expected_exception ".\n  Actual: it throws a different " \

This is now correct and compiles.

Original comment by [email protected] on 7 Oct 2008 at 5:53

from googletest.

GoogleCodeExporter avatar GoogleCodeExporter commented on May 28, 2024
Thanks for the report and the patch.

However I'm not sure if the new behavior is more desirable.  It assumes the 
pointer
was created using new, which may not be true.  More importantly, it can be
misleading: when I see EXPECT_THROW(s, E) and the test passes, I may think that 
the
code is throwing an E, when it actually throws an E*.  I would want to be 
notified if
someone accidentally changes 'throw E()' to 'throw new E()' - I would not want 
the
test to continue to pass.

The philosophy behind EXPECT_THROW() and friends is that they provide a 
convenient
solution for the common case, not necessarily the general case.  You can always 
write
explicit try-catch if the macros aren't adequate for you.


Original comment by [email protected] on 8 Oct 2008 at 9:25

  • Changed state: WontFix
  • Added labels: Type-Enhancement
  • Removed labels: Type-Defect

from googletest.

GoogleCodeExporter avatar GoogleCodeExporter commented on May 28, 2024
The problem is that with the test as it stands, I can't do EXPECT_THROW(s, E*). 
I tried.

I'm not convinced, given the prevalence of "throw new E()" in our code (and 
much of
it is pre-2004 when I started), that the "common case" is "throw E()". There's 
enough
cases of "throw new E()" that try-catch becomes an imposition, not a solution.

I still think that there's a problem here when attempting to add tests to 
legacy code
that does this, when going through and changing everything from "throw new E()" 
to
"throw E()" isn't the appropriate answer.

Google Code Search suggests that there's ~13k instances of "throw new".
http://www.google.com/codesearch?q=%22throw+new%22+lang%3A%22C%2B%2B%22

Original comment by [email protected] on 8 Oct 2008 at 9:54

from googletest.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.