• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // (c) Copyright Juergen Hunold 2008
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 QtScript
7 
8 #include <QScriptEngine>
9 
10 #include <QCoreApplication>
11 
12 #include <boost/test/unit_test.hpp>
13 
14 #include <iostream>
15 
16 std::ostream&
operator <<(std::ostream & stream,QString const & string)17 operator << (std::ostream& stream, QString const& string)
18 {
19     stream << qPrintable(string);
20     return stream;
21 }
22 
BOOST_AUTO_TEST_CASE(defines)23 BOOST_AUTO_TEST_CASE( defines)
24 {
25     BOOST_CHECK_EQUAL(BOOST_IS_DEFINED(QT_SCRIPT_LIB), true);
26 }
27 
BOOST_AUTO_TEST_CASE(script)28 BOOST_AUTO_TEST_CASE( script )
29 {
30     QCoreApplication app(boost::unit_test::framework::master_test_suite().argc,
31                          boost::unit_test::framework::master_test_suite().argv);
32     QScriptEngine myEngine;
33     QScriptValue three = myEngine.evaluate("1 + 2");
34 
35     BOOST_CHECK_EQUAL(three.toNumber(), 3);
36     BOOST_CHECK_EQUAL(three.toString(), QLatin1String("3"));
37 }
38