This is Unofficial EPICS BASE Doxygen Site
pvUnitTest.cpp
Go to the documentation of this file.
1 /*
2  * Copyright information and license terms for this software can be
3  * found in the file LICENSE that is included with the distribution
4  */
5 
6 #include <string>
7 #include <vector>
8 
9 #include <epicsUnitTest.h>
10 
11 #define epicsExportSharedSymbols
12 #include <pv/pvUnitTest.h>
13 
14 namespace detail {
15 
17  if(!alive) return;
18  std::string msg(strm.str());
19  size_t nl = msg.find_first_of('\n');
20  if(nl==msg.npos) {
21  // single-line output
22  if(dotest)
23  testOk(pass, "%s", msg.c_str());
24  else
25  testDiag("%s", msg.c_str());
26 
27  } else {
28  // multi-line output
29  std::istringstream lines(msg);
30  std::string line;
31  bool first = true;
32  while(std::getline(lines ,line)) {
33  if(dotest && first) {
34  first = false;
35  testOk(pass, "%s", line.c_str());
36  } else {
37  testDiag("%s", line.c_str());
38  }
39  }
40  }
41 }
42 
44  :strm(o.strm.str())
45  ,dotest(o.dotest)
46  ,pass(o.pass)
47  ,alive(o.alive)
48 {
49  strm.seekp(0, std::ios_base::end);
50  o.alive = false;
51 }
52 
53 } // namespace detail
int testDiag(const char *fmt,...)
#define str(v)
char * line
Definition: reader.c:25
Unit test routines.
int testOk(int pass, const char *fmt,...)