diff options
author | Piotr Dziwinski <piotrdz@gmail.com> | 2013-02-03 20:03:36 +0100 |
---|---|---|
committer | Piotr Dziwinski <piotrdz@gmail.com> | 2013-02-03 20:03:36 +0100 |
commit | 209c6412ae149cc7c503fd7da384f344a830423c (patch) | |
tree | 5baeaeb8dee2208b46bf80a118dfe59eb65f9389 /test/cbot/CBot_console/main.cpp | |
parent | 3f41f97fc47fca22634dc858c3ecdb39d0d27e32 (diff) | |
download | colobot-209c6412ae149cc7c503fd7da384f344a830423c.tar.gz colobot-209c6412ae149cc7c503fd7da384f344a830423c.tar.bz2 colobot-209c6412ae149cc7c503fd7da384f344a830423c.zip |
Refactoring in tests infrastructure
* all tests are now in /test/ subdirectory
* unit tests concatenated to one executable (TODO: ui, common)
* preparation for test environments (OpenGL and others)
* removed old TestCBot
Diffstat (limited to 'test/cbot/CBot_console/main.cpp')
-rw-r--r-- | test/cbot/CBot_console/main.cpp | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/test/cbot/CBot_console/main.cpp b/test/cbot/CBot_console/main.cpp new file mode 100644 index 0000000..a2d3668 --- /dev/null +++ b/test/cbot/CBot_console/main.cpp @@ -0,0 +1,45 @@ +#include "CClass.h" +#include "CBotDoc.h" +#include <iostream> + + +#include <fstream> + +std::string str; + +// routine to update the instance of the class Bot common + +int main(int argc, char* argv[]) +{ + CClass newclass; + CBotDoc *botdoc; + if (argc != 2) + { + std::cout << "Usage: "<<argv[0] << " <filename>" << std::endl; + return 0; + } + + std::ifstream in(argv[1]); + std::cout << argv[1] << std::endl; + if (!in.good()) + { + std::cout << "Oh no, error!" << std::endl; + return 1; + } + + std::string contents((std::istreambuf_iterator<char>(in)), + std::istreambuf_iterator<char>()); + str = contents; + + if(!newclass.InitInstance()) + { + std::cerr << "Initialization not complete!" << std::endl; + return 1; + } + + botdoc = new CBotDoc(str); +// std::cout << "Hello CBot!" << std::endl << s; + botdoc->OnRun(); + delete botdoc; + newclass.ExitInstance(); +} |