Check if InitGoogleLogging is not called twice.
git-svn-id: https://google-glog.googlecode.com/svn/trunk@47 eb4d4688-79bd-11dd-afb4-1d65580434c0
This commit is contained in:
parent
e334c48314
commit
a86eb1ac62
@ -309,6 +309,8 @@ void SetCrashReason(const CrashReason* r) {
|
|||||||
} // namespace glog_internal_namespace_
|
} // namespace glog_internal_namespace_
|
||||||
|
|
||||||
void InitGoogleLogging(const char* argv0) {
|
void InitGoogleLogging(const char* argv0) {
|
||||||
|
CHECK(!IsGoogleLoggingInitialized())
|
||||||
|
<< "You called InitGoogleLogging() twice!";
|
||||||
const char* slash = strrchr(argv0, '/');
|
const char* slash = strrchr(argv0, '/');
|
||||||
#ifdef OS_WINDOWS
|
#ifdef OS_WINDOWS
|
||||||
if (!slash) slash = strrchr(argv0, '\\');
|
if (!slash) slash = strrchr(argv0, '\\');
|
||||||
|
|||||||
@ -35,13 +35,17 @@
|
|||||||
|
|
||||||
using namespace GOOGLE_NAMESPACE;
|
using namespace GOOGLE_NAMESPACE;
|
||||||
|
|
||||||
TEST(sync_val_compare_and_swap, utilities) {
|
TEST(utilities, sync_val_compare_and_swap) {
|
||||||
bool now_entering = false;
|
bool now_entering = false;
|
||||||
EXPECT_FALSE(sync_val_compare_and_swap(&now_entering, false, true));
|
EXPECT_FALSE(sync_val_compare_and_swap(&now_entering, false, true));
|
||||||
EXPECT_TRUE(sync_val_compare_and_swap(&now_entering, false, true));
|
EXPECT_TRUE(sync_val_compare_and_swap(&now_entering, false, true));
|
||||||
EXPECT_TRUE(sync_val_compare_and_swap(&now_entering, false, true));
|
EXPECT_TRUE(sync_val_compare_and_swap(&now_entering, false, true));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(utilities, InitGoogleLoggingDeathTest) {
|
||||||
|
ASSERT_DEATH(InitGoogleLogging("foobar"), "");
|
||||||
|
}
|
||||||
|
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
InitGoogleLogging(argv[0]);
|
InitGoogleLogging(argv[0]);
|
||||||
InitGoogleTest(&argc, argv);
|
InitGoogleTest(&argc, argv);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user