summaryrefslogtreecommitdiff
path: root/i/chuck/src/tester/test_tester.cc
diff options
context:
space:
mode:
Diffstat (limited to 'i/chuck/src/tester/test_tester.cc')
-rw-r--r--i/chuck/src/tester/test_tester.cc78
1 files changed, 78 insertions, 0 deletions
diff --git a/i/chuck/src/tester/test_tester.cc b/i/chuck/src/tester/test_tester.cc
new file mode 100644
index 0000000..d292c7f
--- /dev/null
+++ b/i/chuck/src/tester/test_tester.cc
@@ -0,0 +1,78 @@
+// test_tester.cc
+// marvin - programme du robot 2006. {{{
+//
+// Copyright (C) 2006 Nicolas Schodet
+//
+// Robot APB Team/Efrei 2006.
+// Web: http://assos.efrei.fr/robot/
+// Email: robot AT efrei DOT fr
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//
+// }}}
+#include "tester.hh"
+
+class TestTester : public Tester
+{
+ public:
+ // Constructor
+ TestTester (int argc, char ** argv)
+ : Tester (argc, argv) { }
+ void funcA (const Interpreter::Args &a, bool dryrun)
+ {
+ if (!dryrun)
+ std::cout << " a " << a << std::endl;
+ }
+ void funcB (void)
+ {
+ std::cout << " b ( )" << std::endl;
+ }
+ void funcC (int i)
+ {
+ std::cout << " c ( " << i << " )" << std::endl;
+ }
+ void funcD (const std::string &s)
+ {
+ std::cout << " d ( " << s << " )" << std::endl;
+ }
+ void funcE (int i, const std::string &s, double d)
+ {
+ std::cout << " e ( " << i << ' ' << s << ' ' << d << " )" << std::endl;
+ }
+ void preRun (void)
+ {
+ Interpreter &interpreter = getInterpreter ();
+ // Add functions.
+ interpreter.add ("a", Interpreter::memFunc (*this, &TestTester::funcA), "Function a (any)");
+ interpreter.add ("b", Interpreter::memFunc (*this, &TestTester::funcB), "Function b ()");
+ interpreter.add ("c", Interpreter::memFunc (*this, &TestTester::funcC), "Function c (int)");
+ interpreter.add ("d", Interpreter::memFunc (*this, &TestTester::funcD), "Function d (string)");
+ interpreter.add ("e", Interpreter::memFunc (*this, &TestTester::funcE), "Function e (int, string, double)");
+ }
+};
+
+int
+main (int argc, char **argv)
+{
+ try
+ {
+ TestTester tt (argc, argv);
+ tt.run ();
+ }
+ catch (const std::exception &e)
+ {
+ std::cerr << e.what () << std::endl;
+ }
+}