Commit d2fc7fe6 by Geoffrey Martin-Noble Committed by Dominic Hamon

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
parent bf4f2ea0
...@@ -41,6 +41,7 @@ Eugene Zhuk <eugene.zhuk@gmail.com> ...@@ -41,6 +41,7 @@ Eugene Zhuk <eugene.zhuk@gmail.com>
Evgeny Safronov <division494@gmail.com> Evgeny Safronov <division494@gmail.com>
Federico Ficarelli <federico.ficarelli@gmail.com> Federico Ficarelli <federico.ficarelli@gmail.com>
Felix Homann <linuxaudio@showlabor.de> Felix Homann <linuxaudio@showlabor.de>
Geoffrey Martin-Noble <gcmn@google.com> <gmngeoffrey@gmail.com>
Hannes Hauswedell <h2@fsfe.org> Hannes Hauswedell <h2@fsfe.org>
Ismael Jimenez Martinez <ismael.jimenez.martinez@gmail.com> Ismael Jimenez Martinez <ismael.jimenez.martinez@gmail.com>
Jern-Kuan Leong <jernkuan@gmail.com> Jern-Kuan Leong <jernkuan@gmail.com>
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
//===---------------------------------------------------------------------===// //===---------------------------------------------------------------------===//
#include "../src/string_util.h" #include "../src/string_util.h"
#include "../src/internal_macros.h"
#include "gtest/gtest.h" #include "gtest/gtest.h"
namespace { namespace {
...@@ -60,9 +61,11 @@ TEST(StringUtilTest, stoul) { ...@@ -60,9 +61,11 @@ TEST(StringUtilTest, stoul) {
EXPECT_EQ(0xBEEFul, benchmark::stoul("BEEF", &pos, 16)); EXPECT_EQ(0xBEEFul, benchmark::stoul("BEEF", &pos, 16));
EXPECT_EQ(4ul, pos); EXPECT_EQ(4ul, pos);
} }
#ifndef BENCHMARK_HAS_NO_EXCEPTIONS
{ {
ASSERT_THROW(benchmark::stoul("this is a test"), std::invalid_argument); ASSERT_THROW(benchmark::stoul("this is a test"), std::invalid_argument);
} }
#endif
} }
TEST(StringUtilTest, stoi) { TEST(StringUtilTest, stoi) {
...@@ -106,9 +109,11 @@ TEST(StringUtilTest, stoi) { ...@@ -106,9 +109,11 @@ TEST(StringUtilTest, stoi) {
EXPECT_EQ(0xBEEF, benchmark::stoi("BEEF", &pos, 16)); EXPECT_EQ(0xBEEF, benchmark::stoi("BEEF", &pos, 16));
EXPECT_EQ(4ul, pos); EXPECT_EQ(4ul, pos);
} }
#ifndef BENCHMARK_HAS_NO_EXCEPTIONS
{ {
ASSERT_THROW(benchmark::stoi("this is a test"), std::invalid_argument); ASSERT_THROW(benchmark::stoi("this is a test"), std::invalid_argument);
} }
#endif
} }
TEST(StringUtilTest, stod) { TEST(StringUtilTest, stod) {
...@@ -138,9 +143,11 @@ TEST(StringUtilTest, stod) { ...@@ -138,9 +143,11 @@ TEST(StringUtilTest, stod) {
EXPECT_EQ(-1.25e+9, benchmark::stod("-1.25e+9", &pos)); EXPECT_EQ(-1.25e+9, benchmark::stod("-1.25e+9", &pos));
EXPECT_EQ(8ul, pos); EXPECT_EQ(8ul, pos);
} }
#ifndef BENCHMARK_HAS_NO_EXCEPTIONS
{ {
ASSERT_THROW(benchmark::stod("this is a test"), std::invalid_argument); ASSERT_THROW(benchmark::stod("this is a test"), std::invalid_argument);
} }
#endif
} }
} // end namespace } // end namespace
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment