dgiunchi / googletest

Automatically exported from code.google.com/p/googletest
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

Unable to compile tests which use exception assertions #418

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
The issue has been posted in googletestframework without being replied, so I 
post it here as well.

https://groups.google.com/d/topic/googletestframework/D3OqJspi2TI/discussion

If you really need to create a new issue, please provide the information
asked for below.

What steps will reproduce the problem?
1. Create a test file that is using either of: ASSERT_THROW, ASSERT_ANY_THROW, 
ASSERT_NO_THROW, EXPECT_THROW, EXPECT_ANY_THROW, EXPECT_NO_THROW.
For example use this:

#include "gtest/gtest.h"

TEST(Tests, NoThrowTest) {
     EXPECT_NO_THROW({ int i = 1; });
}

2. Compile with VC7.1 (Microsoft Visual Studio .NET 2003)

What is the expected output? What do you see instead?
I expect the compilation to succeed. Instead, I get compilation error:

------ Build started: Project: Unit_tests, Configuration: Debug Win32 ------

Compiling...

tcp_ip_tests.cpp

d:\Projects\Diamond_0_1\diamond_0.1_integ\hwctrl\test\src\core\communication\tcp
_ip\tcp_ip_tests.cpp(4) : error C2143: syntax error : missing ';' before '('

d:\Projects\Diamond_0_1\diamond_0.1_integ\hwctrl\test\src\core\communication\tcp
_ip\tcp_ip_tests.cpp(4) : error C2143: syntax error : missing ';' before ':'

d:\Projects\Diamond_0_1\diamond_0.1_integ\hwctrl\test\src\core\communication\tcp
_ip\tcp_ip_tests.cpp(4) : error C3861: 'gtest_label_testnothrow_': identifier 
not found, even with argument-dependent lookup

d:\Projects\Diamond_0_1\diamond_0.1_integ\hwctrl\test\src\core\communication\tcp
_ip\tcp_ip_tests.cpp(4) : error C2143: syntax error : missing ';' before ':'

What version of Google Test are you using? 
I use google test version 1.6

On what operating system?
Windows 7

Please provide any additional information below, such as a code snippet.
The compilation problem shows only when using exception assertions. Without 
them it compiles and runs as expected.

Original issue reported on code.google.com by YalonLo...@gmail.com on 4 Sep 2012 at 11:57

GoogleCodeExporter commented 9 years ago
Please try passing the code through the pre-processor, format it, and run again 
via the compiler. Where does it report the errors? (please post the code and 
the error messages)

Original comment by vladlosev on 4 Sep 2012 at 11:10

GoogleCodeExporter commented 9 years ago
I did that and surprisingly when compiling the resulting preprocessed code, I 
got new different compilation errors. A typical error message is something like 
this:
error C2947: expecting '>' to terminate template-argument-list, found '>>'

I tried locating the source of this problem and found its root in 
gtest-tuple.h. There are several templates and macros combinations that produce 
source code like this (after preprocessing):
struct TupleElement<true, 0, tuple<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9>> { 
typedef T0 type; };

There's a problem in T9>> which should be T9> > (that is, a space should be 
added before the second '>')
I changed several templates in that file by padding the '>' and '<' with 
spaces. The enclosed file contains my corrections.

After that, I managed to compile the preprocessed file, but I'm still having 
compilation errors for the original file (the one before preprocessing).

That is a surprising phenomenon!

Any idea how to proceed from here?

Original comment by YalonLo...@gmail.com on 5 Sep 2012 at 10:53

Attachments:

GoogleCodeExporter commented 9 years ago
There is a tuple fix in the revision 622. Try again pre-processing and 
compiling it again.

Original comment by vladlosev on 6 Sep 2012 at 4:44

GoogleCodeExporter commented 9 years ago
Hello,

Thanks for the prompt responsiveness.

I downloaded the fix for gtest-tuple.h and indeed I don't see the problems with 
>> any longer. 
However, the compilation failure of my test persists, but only in my raw file 
and not in the preprocessed file. That is a surprising phenomenon!

Any idea what can lead to differences between the two? 

Yalon

Original comment by YalonLo...@gmail.com on 9 Sep 2012 at 6:16