scran_test_utils
Test utilities for libscran projects
Loading...
Searching...
No Matches
expect_error.hpp
Go to the documentation of this file.
1#ifndef SCRAN_TESTS_EXPECT_ERROR_HPP
2#define SCRAN_TESTS_EXPECT_ERROR_HPP
3
4#include <gtest/gtest.h>
5#include <string>
6
12namespace scran_tests {
13
23template<typename Function_>
24void expect_error(Function_ fun, std::string match) {
25 bool failed = false;
26 std::string msg;
27
28 try {
29 fun();
30 } catch(std::exception& e) {
31 failed = true;
32 msg = e.what();
33 }
34
35 ASSERT_TRUE(failed) << "function did not throw an exception with message '" << match << "'";
36 ASSERT_TRUE(msg.find(match) != std::string::npos) << "function did not throw an exception with message '" << match << "'";
37}
38
39}
40
41#endif
Test utilites for libscran.
Definition compare_almost_equal.hpp:11
void expect_error(Function_ fun, std::string match)
Definition expect_error.hpp:24