@@ -183,6 +183,17 @@ technique is discussed in more detail in
...
@@ -183,6 +183,17 @@ technique is discussed in more detail in
which also contains a link to a fully generalized implementation
which also contains a link to a fully generalized implementation
of the technique.
of the technique.
##### Visual Studio Dynamic vs Static Runtimes #####
By default, new Visual Studio projects link the C runtimes dynamically
but Google Test links them statically.
This will generate an error that looks something like the following:
gtest.lib(gtest-all.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MTd_StaticDebug' doesn't match value 'MDd_DynamicDebug' in main.obj
Google Test already has a CMake option for this: `gtest_force_shared_crt`
Enabling this option will make gtest link the runtimes dynamically too,
@@ -102,9 +102,9 @@ Then every user of your machine can write tests without
...
@@ -102,9 +102,9 @@ Then every user of your machine can write tests without
recompiling Google Test.
recompiling Google Test.
This seemed like a good idea, but it has a
This seemed like a good idea, but it has a
got-cha: every user needs to compile his tests using the _same_ compiler
got-cha: every user needs to compile their tests using the _same_ compiler
flags used to compile the installed Google Test libraries; otherwise
flags used to compile the installed Google Test libraries; otherwise
he may run into undefined behaviors (i.e. the tests can behave
they may run into undefined behaviors (i.e. the tests can behave
strangely and may even crash for no obvious reasons).
strangely and may even crash for no obvious reasons).
Why? Because C++ has this thing called the One-Definition Rule: if
Why? Because C++ has this thing called the One-Definition Rule: if
...
@@ -1034,7 +1034,7 @@ namespace bar {
...
@@ -1034,7 +1034,7 @@ namespace bar {
TEST(CoolTest, DoSomething) {
TEST(CoolTest, DoSomething) {
SUCCEED();
SUCCEED();
}
}
} // namespace foo
} // namespace bar
```
```
However, the following code is **not allowed** and will produce a runtime error from Google Test because the test methods are using different test fixture classes with the same test case name.
However, the following code is **not allowed** and will produce a runtime error from Google Test because the test methods are using different test fixture classes with the same test case name.
...
@@ -1052,7 +1052,7 @@ class CoolTest : public ::testing::Test {}; // Fixture: bar::CoolTest
...
@@ -1052,7 +1052,7 @@ class CoolTest : public ::testing::Test {}; // Fixture: bar::CoolTest
TEST_F(CoolTest, DoSomething) {
TEST_F(CoolTest, DoSomething) {
SUCCEED();
SUCCEED();
}
}
} // namespace foo
} // namespace bar
```
```
## How do I build Google Testing Framework with Xcode 4? ##
## How do I build Google Testing Framework with Xcode 4? ##
* The implementation is in a single Python script and thus ultra portable: no build or installation is needed and it works cross platforms.
* The implementation is in a single Python script and thus ultra portable: no build or installation is needed and it works cross platforms.
* Pump tries to be smart with respect to [Google's style guide](http://code.google.com/p/google-styleguide/): it breaks long lines (easy to have when they are generated) at acceptable places to fit within 80 columns and indent the continuation lines correctly.
* Pump tries to be smart with respect to [Google's style guide](https://github.com/google/styleguide): it breaks long lines (easy to have when they are generated) at acceptable places to fit within 80 columns and indent the continuation lines correctly.
* The format is human-readable and more concise than XML.
* The format is human-readable and more concise than XML.
* The format works relatively well with Emacs' C++ mode.
* The format works relatively well with Emacs' C++ mode.