tatami_test
Utilities for testing tatami libraries
Loading...
Searching...
No Matches
throws_error.hpp
Go to the documentation of this file.
1#ifndef TATAMI_TEST_THROWS_ERROR_HPP
2#define TATAMI_TEST_THROWS_ERROR_HPP
3
4#include <string>
5#include <gtest/gtest.h>
6
12namespace tatami_test {
13
22template<class Function_>
23void throws_error(Function_ fun, const std::string& msg) {
24 try {
25 fun();
26 FAIL() << "expected error message '" << msg << "', got no error";
27 } catch (std::exception& e) {
28 std::string observed(e.what());
29 if (observed.find(msg) == std::string::npos) {
30 FAIL() << "expected error message '" << msg << "', got '" << observed << "'";
31 }
32 }
33}
34
35}
36
37#endif
Utilities for testing tatami libraries.
Definition create_indexed_subset.hpp:15
void throws_error(Function_ fun, const std::string &msg)
Definition throws_error.hpp:23