Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

About calling a runtime_error what() function {UTFreamwork} #10

Open
alshakh opened this issue Feb 1, 2013 · 2 comments
Open

About calling a runtime_error what() function {UTFreamwork} #10

alshakh opened this issue Feb 1, 2013 · 2 comments

Comments

@alshakh
Copy link

alshakh commented Feb 1, 2013

This issue is to continue the descussion about UTFreamwork changes.

The changes were :

cppFine Line(155)

void UTFramework::FaultException(std::exception exeption )
will be :
void UTFramework::FaultException(const std::exception& exeption )

hFile Line(97)

static void FaultException (std::exception exeption );
will be :
static void FaultException (const std::exception& exeption );

I tried a code like this.

#include <cstdlib>
#include <iostream>
#include <stdexcept>
#include "UTFramework.h"
using namespace std;
using namespace Thilenius;

SUITE_BEGIN("Suite!")

TEST_BEGIN("Test") {
    throw runtime_error("Message");
}

TEST_END

SUITE_END


int main() {
    UTFrameworkInit;
}

Without the changes, the result was std::exception. When I tried the changes, the result was Message.

Ahmed

Quote(Alec Thilenius )

To answer your comment, that is because a runtime error is not an std::exception. I 'think' that they are both children of the exception object, but I am not sure about that one. For my own curiosity could you please send me the code that generated a runtime error? I may add it to the framework as a supported type.

Quote(Ahmed Alshakh)

I don't know why I can't see your comment here, but I can see it on the updates. I don't really know how to use git. Sorry..
I made the change because when I tried to throw a "runtime_error" UTFreamework showed "std::exception" not my message. I played with it for long time until it worked. I am not sure this is the right change but It worked for me.

Quote(Alec Thilenius )

Could you please elaborate on why you made this change? Passing by value is fine, and had been tested.

Quote(Ahmed Alshakh )

The function FaultException() should get the exception by reference not by value in order to show e.what() instead of std::exception

@AThilenius
Copy link
Collaborator

Ahhh yes. I see what you are talking about now. It is specific to GCC. The same thing does not show up in VC++. I'm guessing what ever implementation GCC is using for std::exception does not have the copy constructor defined property. I'll take a look at this when I finish the next version of the unit testing framework.

@alshakh
Copy link
Author

alshakh commented Feb 1, 2013

I did not know that there are differences like that between GCC and VC++! I should have said I am using GCC.
Could you please notify me when the new version of UTFreamwork comes out. I like it very much. I couldn't find another UniteTest I can understand.

Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants