summaryrefslogtreecommitdiffstats
path: root/src/google/protobuf/stubs/strutil_unittest.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/google/protobuf/stubs/strutil_unittest.cc')
-rw-r--r--src/google/protobuf/stubs/strutil_unittest.cc12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/google/protobuf/stubs/strutil_unittest.cc b/src/google/protobuf/stubs/strutil_unittest.cc
index 7f27dca..b9c9253 100644
--- a/src/google/protobuf/stubs/strutil_unittest.cc
+++ b/src/google/protobuf/stubs/strutil_unittest.cc
@@ -1,6 +1,6 @@
// Protocol Buffers - Google's data interchange format
// Copyright 2008 Google Inc. All rights reserved.
-// https://developers.google.com/protocol-buffers/
+// http://code.google.com/p/protobuf/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
@@ -51,17 +51,27 @@ TEST(StringUtilityTest, ImmuneToLocales) {
// Set the locale to "C".
ASSERT_TRUE(setlocale(LC_NUMERIC, "C") != NULL);
+ EXPECT_EQ(1.5, NoLocaleStrtod("1.5", NULL));
EXPECT_EQ("1.5", SimpleDtoa(1.5));
EXPECT_EQ("1.5", SimpleFtoa(1.5));
+ // Verify that the endptr is set correctly even if not all text was parsed.
+ const char* text = "1.5f";
+ char* endptr;
+ EXPECT_EQ(1.5, NoLocaleStrtod(text, &endptr));
+ EXPECT_EQ(3, endptr - text);
+
if (setlocale(LC_NUMERIC, "es_ES") == NULL &&
setlocale(LC_NUMERIC, "es_ES.utf8") == NULL) {
// Some systems may not have the desired locale available.
GOOGLE_LOG(WARNING)
<< "Couldn't set locale to es_ES. Skipping this test.";
} else {
+ EXPECT_EQ(1.5, NoLocaleStrtod("1.5", NULL));
EXPECT_EQ("1.5", SimpleDtoa(1.5));
EXPECT_EQ("1.5", SimpleFtoa(1.5));
+ EXPECT_EQ(1.5, NoLocaleStrtod(text, &endptr));
+ EXPECT_EQ(3, endptr - text);
}
// Return to original locale.