Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion osi_sensorviewconfiguration.proto
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,9 @@ message SensorViewConfiguration
// that the simulation environment has to provide.
// Viewing range: [- \c #field_of_view_horizontal/2, \c
// #field_of_view_horizontal/2] azimuth in the sensor frame as defined in \c
// Spherical3d. Unit: rad
// Spherical3d.
//
// Unit: rad
optional double field_of_view_horizontal = 5;

// Field of View in vertical orientation of the sensor.
Expand Down
28 changes: 28 additions & 0 deletions tests/test_units.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import re
import glob
import unittest

PROTO_FILES = glob.glob("*.proto")

class TestUnits(unittest.TestCase):
""" Test class for units documentation. """

def test_no_brackets(self):
''' Test to check if units have the right syntax. '''

NOT_VALID_BRACKETS = [r'\(', r'\)', r'\[', r'\]', r'\{', r'\}']

for file in PROTO_FILES:
with open(file, "rt") as fin, self.subTest(file=file):
for i, line in enumerate(fin, start=1):
found = re.search('Unit:', line, re.IGNORECASE)

if found:
comment_list = line.split()
self.assertEqual(comment_list[0], '//', file + " in line " + str(i) + ": Unit must be on a separate line or have a space between //. (Example: '// Unit: m')")
self.assertEqual(comment_list[1], 'Unit:', file + " in line " + str(i) + f": '{comment_list[1]}' do not match 'Unit:'. (Example: '// Unit: m')")
self.assertGreaterEqual(len(comment_list), 3, file + " in line " + str(i) + ": No unit defined. (Example: '// Unit: m')")

for unit in comment_list:
for brackets in NOT_VALID_BRACKETS:
self.assertNotRegex(unit, brackets, file + " in line " + str(i) + ": Invalid brackets around units.")