PH Logo
Logo intepreter modeled after UCB Logo.
/Users/paul/Documents/phlogo/core/lunittest.cpp
00001 #define BOOST_TEST_MAIN
00002 #include <boost/test/unit_test.hpp>
00003 
00004 #include <iostream>
00005 #include <string>
00006 #include <sstream>
00007 #include <algorithm>
00008 #include <iterator>
00009 
00010 #include "Console.h"
00011 #include "World.h"
00012 #include "Interpreter.h"
00013 #include "Thing.h"
00014 
00015 using namespace std;
00016 using namespace phlogo;
00017 using namespace boost;
00018 
00019 BOOST_AUTO_TEST_CASE( passed )
00020 {
00021         StringConsole c;
00022         World w(&c);
00023         Interpreter itp(&w);
00024     w.setThing("code", shared_ptr<Thing>(new Thing("print [hello]")));
00025     itp.run(&w, "test :code \"hello");
00026     BOOST_CHECK_EQUAL(w.getResult()->getWord(), "passed");
00027 }
00028 
00029 BOOST_AUTO_TEST_CASE( failed )
00030 {
00031         StringConsole c;
00032         World w(&c);
00033         Interpreter itp(&w);
00034     w.setThing("code", shared_ptr<Thing>(new Thing("print [hello]")));
00035     itp.run(&w, "test :code \"hellos");
00036     BOOST_CHECK_EQUAL(w.getResult()->getWord(), "failed [hellos != hello]");
00037 }
00038 
00039 BOOST_AUTO_TEST_CASE( suitepassed )
00040 {
00041         StringConsole c;
00042         World w(&c);
00043         Interpreter itp(&w);
00044     itp.run(&w, "testsuite \"first");
00045     BOOST_CHECK_EQUAL(w.getResult()->getWord(), "passed [1]");
00046 }
00047 
00048 BOOST_AUTO_TEST_CASE( suitefailed )
00049 {
00050         StringConsole c;
00051         World w(&c);
00052         Interpreter itp(&w);
00053     itp.run(&w, "testsuite \"firstfail");
00054     BOOST_CHECK_EQUAL(w.getResult()->getWord(), "failed [1]");
00055 }
00056 
 All Classes Functions