Namespaces | Macros | Functions | Variables
util.hpp File Reference
#include <string>

Go to the source code of this file.

Namespaces

 stan
 
 stan::test
 

Macros

#define EXPECT_THROW_MSG(expr, T_e, msg)
 

Functions

int count_matches (const std::string &target, const std::string &s)
 
void stan::test::capture_std_streams ()
 
void stan::test::reset_std_streams ()
 

Variables

std::streambuf * stan::test::cout_buf = 0
 
std::streambuf * stan::test::cerr_buf = 0
 
std::stringstream stan::test::cout_ss
 
std::stringstream stan::test::cerr_ss
 

Macro Definition Documentation

#define EXPECT_THROW_MSG (   expr,
  T_e,
  msg 
)
Value:
try { \
expr; \
} catch(const T_e& e) { \
EXPECT_EQ(1, count_matches(msg, e.what())) \
<< "expected message: " << msg << std::endl \
<< "found message: " << e.what(); \
} catch(...) { \
FAIL() \
<< "Wrong exception type thrown" << std::endl; \
}
int count_matches(const std::string &target, const std::string &s)
Definition: util.hpp:19
Float_t e
Definition: plot.C:35

Definition at line 6 of file util.hpp.

Referenced by TEST(), and TEST_F().

Function Documentation

int count_matches ( const std::string target,
const std::string s 
)

Definition at line 19 of file util.hpp.

References confusionMatrixTree::count, and elec2geo::pos.

Referenced by expect_match(), expect_matches(), TEST(), TEST_F(), and test_num_warnings().

20  {
21  if (target.size() == 0) return -1; // error
22  int count = 0;
23  for (size_t pos = 0; (pos = s.find(target,pos)) != std::string::npos; pos += target.size())
24  ++count;
25  return count;
26 }
const XML_Char * target
Definition: expat.h:268
const XML_Char * s
Definition: expat.h:262