diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/in/com.pelagicore.ivi.tuner.qface | 2 | ||||
-rw-r--r-- | tests/in/org.example.echo.qface | 2 | ||||
-rw-r--r-- | tests/in/org.example.failing.qface | 5 | ||||
-rw-r--r-- | tests/test_comments.py | 6 | ||||
-rw-r--r-- | tests/test_parser.py | 22 | ||||
-rw-r--r-- | tests/test_qtcpp_helper.py | 14 |
6 files changed, 47 insertions, 4 deletions
diff --git a/tests/in/com.pelagicore.ivi.tuner.qface b/tests/in/com.pelagicore.ivi.tuner.qface index e8f53ae..725d4d5 100644 --- a/tests/in/com.pelagicore.ivi.tuner.qface +++ b/tests/in/com.pelagicore.ivi.tuner.qface @@ -2,7 +2,7 @@ module com.pelagicore.ivi.tuner 1.0; interface BaseTuner { - property int baseValue; + int baseValue; } diff --git a/tests/in/org.example.echo.qface b/tests/in/org.example.echo.qface index 04a93ce..087f14f 100644 --- a/tests/in/org.example.echo.qface +++ b/tests/in/org.example.echo.qface @@ -10,6 +10,8 @@ module org.example.echo 1.0 * @see org.example * @see http://qt.io * @anything hello + * + * continued description */ interface Echo { /** diff --git a/tests/in/org.example.failing.qface b/tests/in/org.example.failing.qface new file mode 100644 index 0000000..0fe3888 --- /dev/null +++ b/tests/in/org.example.failing.qface @@ -0,0 +1,5 @@ +module org.example 1.0 + +interfase xx Failed { + +}
\ No newline at end of file diff --git a/tests/test_comments.py b/tests/test_comments.py index 008dd0d..d2f18b6 100644 --- a/tests/test_comments.py +++ b/tests/test_comments.py @@ -35,8 +35,8 @@ def test_comment(): interface = system.lookup('org.example.echo.Echo') assert interface o = doc.parse_doc(interface.comment) - assert o.brief == 'the brief' - assert o.description == ['the description', 'continues {@link http://qt.io}'] + assert o.brief == ['the brief'] + assert o.description == ['the description', 'continues {@link http://qt.io}', 'continued description'] assert o.deprecated is True assert o.see == ['org.example.echo.Echo', 'org.example', 'http://qt.io'] @@ -50,4 +50,4 @@ def test_qdoc_translate(): assert interface doc.translate = qdoc_translate o = doc.parse_doc(interface.comment) - assert o.description == ['the description', 'continues \\link{http://qt.io}'] + assert o.description == ['the description', 'continues \\link{http://qt.io}', 'continued description'] diff --git a/tests/test_parser.py b/tests/test_parser.py index b2844fc..6adfe04 100644 --- a/tests/test_parser.py +++ b/tests/test_parser.py @@ -1,5 +1,6 @@ import logging import logging.config +import pytest from path import Path from qface.generator import FileSystem @@ -190,3 +191,24 @@ def test_interface_property(): assert prop.type.is_interface assert prop.type.reference is extension + +def test_symbol_kind(): + system = load_tuner() + tuner = system.lookup('com.pelagicore.ivi.tuner.Tuner') + assert tuner.kind == 'interface' + property = system.lookup('com.pelagicore.ivi.tuner.Tuner#primitiveModel') + assert property.kind == 'property' + + +def test_parser_exceptions(): + path = inputPath / 'org.example.failing.qface' + system = FileSystem.parse_document(path) + + try: + system = FileSystem.parse_document('not-exists') + except SystemExit as e: + pass + else: + pytest.fail('should not ome here') + + diff --git a/tests/test_qtcpp_helper.py b/tests/test_qtcpp_helper.py index a59e0d9..acc034f 100644 --- a/tests/test_qtcpp_helper.py +++ b/tests/test_qtcpp_helper.py @@ -23,6 +23,7 @@ interface Test { void echo(string message); Message message; Status status; + ApplicationState state; list<int> list001; list<Message> list002; model<int> model001; @@ -38,6 +39,14 @@ enum Status { ON, OFF } + +flag ApplicationState { + Suspended, + Hidden, + Inactive, + Active, +} + """ @@ -127,6 +136,11 @@ def test_default_value(): answer = qtcpp.Filters.defaultValue(prop) assert answer == 'ExampleModule::ON' + # check for flag + prop = interface._propertyMap['state'] + answer = qtcpp.Filters.defaultValue(prop) + assert answer == '0' + # check for list of primitive prop = interface._propertyMap['list001'] answer = qtcpp.Filters.defaultValue(prop) |