aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeoffrey Martin-Noble <GMNGeoffrey@gmail.com>2019-09-20 02:25:31 -0700
committerDominic Hamon <dominichamon@users.noreply.github.com>2019-09-20 10:25:31 +0100
commitd2fc7fe6591393c2672f3ba011304b778e71c020 (patch)
tree4cbd04ef957ab0e8fc61669be89124d7637ebec8
parentbf4f2ea0bd1180b34718ac26eb79b170a4f6290e (diff)
downloadgoogle-benchmark-d2fc7fe6591393c2672f3ba011304b778e71c020.tar.gz
Guard ASSERT_THROWS checks with BENCHMARK_HAS_NO_EXCEPTIONS (#874)
* Guard ASSERT_THROWS checks with BENCHMARK_HAS_NO_EXCEPTIONS This allows the test be run with exceptions turned off * Add myself to CONTRIBUTORS I don't need to be added to AUTHORS, as I am a Google employee
-rw-r--r--CONTRIBUTORS1
-rw-r--r--test/string_util_gtest.cc7
2 files changed, 8 insertions, 0 deletions
diff --git a/CONTRIBUTORS b/CONTRIBUTORS
index 5be6dc4..e44f6f6 100644
--- a/CONTRIBUTORS
+++ b/CONTRIBUTORS
@@ -41,6 +41,7 @@ Eugene Zhuk <eugene.zhuk@gmail.com>
Evgeny Safronov <division494@gmail.com>
Federico Ficarelli <federico.ficarelli@gmail.com>
Felix Homann <linuxaudio@showlabor.de>
+Geoffrey Martin-Noble <gcmn@google.com> <gmngeoffrey@gmail.com>
Hannes Hauswedell <h2@fsfe.org>
Ismael Jimenez Martinez <ismael.jimenez.martinez@gmail.com>
Jern-Kuan Leong <jernkuan@gmail.com>
diff --git a/test/string_util_gtest.cc b/test/string_util_gtest.cc
index 2c5d073..01bf155 100644
--- a/test/string_util_gtest.cc
+++ b/test/string_util_gtest.cc
@@ -3,6 +3,7 @@
//===---------------------------------------------------------------------===//
#include "../src/string_util.h"
+#include "../src/internal_macros.h"
#include "gtest/gtest.h"
namespace {
@@ -60,9 +61,11 @@ TEST(StringUtilTest, stoul) {
EXPECT_EQ(0xBEEFul, benchmark::stoul("BEEF", &pos, 16));
EXPECT_EQ(4ul, pos);
}
+#ifndef BENCHMARK_HAS_NO_EXCEPTIONS
{
ASSERT_THROW(benchmark::stoul("this is a test"), std::invalid_argument);
}
+#endif
}
TEST(StringUtilTest, stoi) {
@@ -106,9 +109,11 @@ TEST(StringUtilTest, stoi) {
EXPECT_EQ(0xBEEF, benchmark::stoi("BEEF", &pos, 16));
EXPECT_EQ(4ul, pos);
}
+#ifndef BENCHMARK_HAS_NO_EXCEPTIONS
{
ASSERT_THROW(benchmark::stoi("this is a test"), std::invalid_argument);
}
+#endif
}
TEST(StringUtilTest, stod) {
@@ -138,9 +143,11 @@ TEST(StringUtilTest, stod) {
EXPECT_EQ(-1.25e+9, benchmark::stod("-1.25e+9", &pos));
EXPECT_EQ(8ul, pos);
}
+#ifndef BENCHMARK_HAS_NO_EXCEPTIONS
{
ASSERT_THROW(benchmark::stod("this is a test"), std::invalid_argument);
}
+#endif
}
} // end namespace