summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
author <shinichiro.hamaji@gmail.com>2009-04-10 16:15:53 +0000
committer <shinichiro.hamaji@gmail.com>2009-04-10 16:15:53 +0000
commita86eb1ac62341f313b2cb20c8450bfc1d9f3ae16 (patch)
tree54bd70c76ee554fbd111260a11211c663af25111 /src
parente334c48314062ac1a1843c741ac4f925ac7e2db2 (diff)
downloadglog-a86eb1ac62341f313b2cb20c8450bfc1d9f3ae16.tar.gz
glog-a86eb1ac62341f313b2cb20c8450bfc1d9f3ae16.tar.bz2
glog-a86eb1ac62341f313b2cb20c8450bfc1d9f3ae16.zip
Check if InitGoogleLogging is not called twice.
git-svn-id: https://google-glog.googlecode.com/svn/trunk@47 eb4d4688-79bd-11dd-afb4-1d65580434c0
Diffstat (limited to 'src')
-rw-r--r--src/utilities.cc2
-rw-r--r--src/utilities_unittest.cc6
2 files changed, 7 insertions, 1 deletions
diff --git a/src/utilities.cc b/src/utilities.cc
index 3efe779..7769634 100644
--- a/src/utilities.cc
+++ b/src/utilities.cc
@@ -309,6 +309,8 @@ void SetCrashReason(const CrashReason* r) {
} // namespace glog_internal_namespace_
void InitGoogleLogging(const char* argv0) {
+ CHECK(!IsGoogleLoggingInitialized())
+ << "You called InitGoogleLogging() twice!";
const char* slash = strrchr(argv0, '/');
#ifdef OS_WINDOWS
if (!slash) slash = strrchr(argv0, '\\');
diff --git a/src/utilities_unittest.cc b/src/utilities_unittest.cc
index a2fb31b..7b79619 100644
--- a/src/utilities_unittest.cc
+++ b/src/utilities_unittest.cc
@@ -35,13 +35,17 @@
using namespace GOOGLE_NAMESPACE;
-TEST(sync_val_compare_and_swap, utilities) {
+TEST(utilities, sync_val_compare_and_swap) {
bool now_entering = false;
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));
}
+TEST(utilities, InitGoogleLoggingDeathTest) {
+ ASSERT_DEATH(InitGoogleLogging("foobar"), "");
+}
+
int main(int argc, char **argv) {
InitGoogleLogging(argv[0]);
InitGoogleTest(&argc, argv);