Skip to content

Commit b1b2a08

Browse files
abdelkadersellamierikbosch
authored andcommitted
Add tests to cover the binary exporter use-case for allowed values
Signed-off-by: Abdelkader Sellami <abdelkader.sellami.2@volvo.com>
1 parent 91a3314 commit b1b2a08

File tree

4 files changed

+48
-0
lines changed

4 files changed

+48
-0
lines changed

binary/c_parser/testparser.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,11 @@ int main(int argc, char** argv) {
147147
printf("Node type=%s\n", getTypeName(VSSgetType((long)(&(searchData[i]))->foundNodeHandles)));
148148
printf("Node path=%s\n", (char*)(&(searchData[i]))->responsePaths);
149149
printf("Node validation=%d\n", VSSgetValidation((long)(&(searchData[i]))->foundNodeHandles));
150+
int numberOfAllowedElements = VSSgetNumOfAllowedElements((long)(&(searchData[i]))->foundNodeHandles);
151+
printf("Node num of allowed values=%d\n", numberOfAllowedElements);
152+
for (int j = 0; j < numberOfAllowedElements; j++) {
153+
printf("Node allowed value=%s at index=%d\n", VSSgetAllowedElement((long)(&(searchData[i]))->foundNodeHandles, j), j);
154+
}
150155
}
151156
}
152157
break;

binary/go_parser/testparser.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ func main() {
122122
}
123123
case 'm': //subtree metadata
124124
{
125+
var numberOfAllowedElements int
125126
var subTreePath string
126127
fmt.Printf("\nPath to subtree node: ")
127128
fmt.Scanf("%s", &subTreePath)
@@ -141,6 +142,11 @@ func main() {
141142
fmt.Printf("Node type=%s\n", getTypeName(parser.VSSgetType(searchData[i].NodeHandle)))
142143
fmt.Printf("Node path=%s\n", searchData[i].NodePath)
143144
fmt.Printf("Node validation=%d\n", parser.VSSgetValidation(searchData[i].NodeHandle))
145+
numberOfAllowedElements = parser.VSSgetNumOfAllowedElements(searchData[i].NodeHandle)
146+
fmt.Printf("Node num of allowed values=%d\n", numberOfAllowedElements);
147+
for j := 0 ; j < numberOfAllowedElements ; j++ {
148+
fmt.Printf("Node allowed value=%s at index=%d\n", parser.VSSgetAllowedElement(searchData[i].NodeHandle, j), j);
149+
}
144150
}
145151
}
146152
case 'h': //help

tests/binary/test.vspec

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,29 @@ A.Int:
1212
datatype: uint16
1313
type: actuator
1414
description: An int
15+
16+
A.AllowedFloat:
17+
datatype: float
18+
allowed:
19+
- 1.1
20+
- 2.54
21+
- 3
22+
description: A list of allowed floats
23+
type: actuator
24+
25+
A.AllowedInt:
26+
datatype: uint16
27+
allowed:
28+
- 0
29+
- 10
30+
- 20
31+
type: actuator
32+
description: A list of allowed ints
33+
34+
A.AllowedString:
35+
datatype: string
36+
allowed:
37+
- A
38+
- B
39+
type: actuator
40+
description: A list of allowed strings

tests/binary/test_binary.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,14 @@ def test_binary(tmp_path):
4444
for parser in parsers:
4545
check_expected_for_tool(parser, "A.String", "Node type=SENSOR", test_binary)
4646
check_expected_for_tool(parser, "A.Int", "Node type=ACTUATOR", test_binary)
47+
check_expected_for_tool(parser, "A.AllowedInt", "Node num of allowed values=3", test_binary)
48+
check_expected_for_tool(parser, "A.AllowedInt", "Node allowed value=0 at index=0", test_binary)
49+
check_expected_for_tool(parser, "A.AllowedInt", "Node allowed value=10 at index=1", test_binary)
50+
check_expected_for_tool(parser, "A.AllowedInt", "Node allowed value=20 at index=2", test_binary)
51+
check_expected_for_tool(parser, "A.AllowedString", "Node num of allowed values=2", test_binary)
52+
check_expected_for_tool(parser, "A.AllowedString", "Node allowed value=A at index=0", test_binary)
53+
check_expected_for_tool(parser, "A.AllowedString", "Node allowed value=B at index=1", test_binary)
54+
check_expected_for_tool(parser, "A.AllowedFloat", "Node num of allowed values=3", test_binary)
55+
check_expected_for_tool(parser, "A.AllowedFloat", "Node allowed value=1.1 at index=0", test_binary)
56+
check_expected_for_tool(parser, "A.AllowedFloat", "Node allowed value=2.54 at index=1", test_binary)
57+
check_expected_for_tool(parser, "A.AllowedFloat", "Node allowed value=3 at index=2", test_binary)

0 commit comments

Comments
 (0)