• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // (c) Copyright Juergen Hunold 2009
2 // Use, modification and distribution is subject to the Boost Software
3 // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
4 // http://www.boost.org/LICENSE_1_0.txt)
5 
6 #define BOOST_TEST_MODULE QtScriptTools
7 
8 #include <QScriptEngine>
9 
10 #include <QScriptEngineDebugger>
11 
12 #include <QApplication>
13 
14 #include <boost/test/unit_test.hpp>
15 
16 #include <iostream>
17 
18 namespace utf = boost::unit_test::framework;
19 
20 std::ostream&
operator <<(std::ostream & stream,QString const & string)21 operator << (std::ostream& stream, QString const& string)
22 {
23     stream << qPrintable(string);
24     return stream;
25 }
26 
BOOST_AUTO_TEST_CASE(defines)27 BOOST_AUTO_TEST_CASE( defines)
28 {
29     BOOST_CHECK_EQUAL(BOOST_IS_DEFINED(QT_SCRIPTTOOLS_LIB), true);
30 }
31 
BOOST_AUTO_TEST_CASE(script)32 BOOST_AUTO_TEST_CASE( script )
33 {
34    QApplication app(utf::master_test_suite().argc,
35                     utf::master_test_suite().argv);
36 
37    QScriptEngine myEngine;
38    QScriptValue three = myEngine.evaluate("1 + 2");
39 
40    QScriptEngineDebugger debugger;
41    debugger.attachTo(&myEngine);
42 
43    BOOST_CHECK_EQUAL(three.toNumber(), 3);
44    BOOST_CHECK_EQUAL(three.toString(), QLatin1String("3"));
45 
46    debugger.detach();
47 }
48