libdballe  7.7
tests-lua.h
1 
20 #ifndef WREPORT_TEST_UTILS_LUA_H
21 #define WREPORT_TEST_UTILS_LUA_H
22 
23 extern "C" {
24 #include <lauxlib.h>
25 #include <lualib.h>
26 }
27 
28 #include <string>
29 #include <iosfwd>
30 
31 namespace dballe {
32 namespace tests {
33 
34 struct Lua
35 {
36  lua_State *L;
37  std::string m_filename;
38 
39  Lua(const std::string& src = std::string());
40  ~Lua();
41 
43  void loadFile(const std::string& fname);
44 
46  void loadString(const std::string& buf);
47 
50  void create_lua_object();
51 
53  void captureOutput(std::ostream& buf);
54 
56  std::string run();
57 };
58 
59 }
60 }
61 
62 #endif
void loadString(const std::string &buf)
Load the test code from the given string containing Lua source code.
void create_lua_object()
Runs the parsed code to let it define the &#39;test&#39; function we are going to use.
void loadFile(const std::string &fname)
Load the test code from the given file.
Copyright (C) 2008–2010 ARPA-SIM urpsim@smr.arpa.emr.it
Definition: cmdline.h:17
Definition: tests-lua.h:34
void captureOutput(std::ostream &buf)
Send Lua&#39;s print output to an ostream.
std::string run()
Run the &#39;test&#39; function and return its result, as a string.