Skip to content

Commit 501a4e8

Browse files
committed
ros2: tighter testing
- unit test for correctness of result
1 parent 9d05655 commit 501a4e8

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

open-codegen/test/test_ros2.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import logging
22
import os
3+
import re
34
import shlex
45
import signal
56
import shutil
@@ -402,6 +403,25 @@ def test_generated_ros2_package_works(self):
402403
self._terminate_process(echo_process)
403404

404405
self.assertIn("solution", echo_stdout)
406+
# A bit of integration testing: check whether the solver was able to
407+
# solve the problem successfully
408+
self.assertRegex(
409+
echo_stdout,
410+
r"solution:\s*\n(?:- .+\n)+",
411+
msg=f"Expected a non-empty solution vector in result output:\n{echo_stdout}")
412+
self.assertIn("status: 0", echo_stdout)
413+
self.assertRegex(
414+
echo_stdout,
415+
r"inner_iterations:\s*[1-9]\d*",
416+
msg=f"Expected a positive inner iteration count in result output:\n{echo_stdout}")
417+
self.assertRegex(
418+
echo_stdout,
419+
r"outer_iterations:\s*[1-9]\d*",
420+
msg=f"Expected a positive outer iteration count in result output:\n{echo_stdout}")
421+
self.assertRegex(
422+
echo_stdout,
423+
r"cost:\s*-?\d+(?:\.\d+)?(?:e[+-]?\d+)?",
424+
msg=f"Expected a numeric cost in result output:\n{echo_stdout}")
405425
self.assertIn("solve_time_ms", echo_stdout)
406426
finally:
407427
if node_process.poll() is None:

0 commit comments

Comments
 (0)