]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | // (c) Copyright Juergen Hunold 2008 |
2 | // Use, modification and distribution is subject to the Boost Software | |
1e59de90 TL |
3 | // License, Version 1.0. (See accompanying file LICENSE.txt or copy at |
4 | // https://www.bfgroup.xyz/b2/LICENSE.txt) | |
7c673cae FG |
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& | |
17 | operator << (std::ostream& stream, QString const& string) | |
18 | { | |
19 | stream << qPrintable(string); | |
20 | return stream; | |
21 | } | |
22 | ||
23 | BOOST_AUTO_TEST_CASE( defines) | |
24 | { | |
25 | BOOST_CHECK_EQUAL(BOOST_IS_DEFINED(QT_SCRIPT_LIB), true); | |
26 | } | |
27 | ||
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 | } |