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
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use crate::*;

((*- macro compare_value(prefix, value) *))
((*- if value is string_type *))
assert_eq!(msg.(((prefix|snake_case))).to_string(), (((value|str_escape))), "incorrect value for msg.(((prefix|snake_case))), expected string '{}', is '{}'", (((value|str_escape))), msg.(((prefix|snake_case))));
assert_eq!(msg.(((prefix|snake_case))).as_bytes(), (((value|bytes_escape))), "incorrect value for msg.(((prefix|snake_case))), expected string '{:?}', is '{:?}'", (((value|bytes_escape))), msg.(((prefix|snake_case))).as_bytes());
((*- elif value is array_type *))
((*- for ff in value *))((( compare_value( (((prefix|snake_case))) + '[' + (((loop.index0|to_str))) + ']', (((ff))) ) )))((*- endfor *))
((*- elif value is dict_type *))
Expand Down
6 changes: 3 additions & 3 deletions generator/sbpg/targets/test_rust.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@
TEST_TEMPLATE_NAME = "rust/test/sbp_tests_template.rs"
TEST_MAIN_TEMPLATE_NAME = "rust/test/sbp_tests_main_template.rs"

def str_escape(value):
return "\"{}\"".format(value)
def bytes_escape(value):
return "&{}".format(list(bytes(value, "ascii")))

def mod_name(value):
return value.split('.')[1]

JENV.filters['to_str'] = to_str
JENV.filters['str_escape'] = str_escape
JENV.filters['bytes_escape'] = bytes_escape
JENV.filters['sorted'] = sorted
JENV.filters['mod_name'] = mod_name
JENV.filters['lower_acronyms'] = lower_acronyms
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,11 @@ fn test_auto_check_sbp_bootload_msg_bootloader_handshake_resp() {
msg.flags
);
assert_eq!(
msg.version.to_string(),
"v1.2
",
"incorrect value for msg.version, expected string '{}', is '{}'",
"v1.2
",
msg.version
msg.version.as_bytes(),
&[118, 49, 46, 50, 10],
"incorrect value for msg.version, expected string '{:?}', is '{:?}'",
&[118, 49, 46, 50, 10],
msg.version.as_bytes()
);
}
_ => panic!("Invalid message type! Expected a MsgBootloaderHandshakeResp"),
Expand Down Expand Up @@ -166,13 +164,11 @@ fn test_json2sbp_auto_check_sbp_bootload_msg_bootloader_handshake_resp() {
msg.flags
);
assert_eq!(
msg.version.to_string(),
"v1.2
",
"incorrect value for msg.version, expected string '{}', is '{}'",
"v1.2
",
msg.version
msg.version.as_bytes(),
&[118, 49, 46, 50, 10],
"incorrect value for msg.version, expected string '{:?}', is '{:?}'",
&[118, 49, 46, 50, 10],
msg.version.as_bytes()
);
}
_ => panic!("Invalid message type! Expected a MsgBootloaderHandshakeResp"),
Expand Down Expand Up @@ -297,13 +293,11 @@ fn test_sbp2json_auto_check_sbp_bootload_msg_bootloader_handshake_resp() {
msg.flags
);
assert_eq!(
msg.version.to_string(),
"v1.2
",
"incorrect value for msg.version, expected string '{}', is '{}'",
"v1.2
",
msg.version
msg.version.as_bytes(),
&[118, 49, 46, 50, 10],
"incorrect value for msg.version, expected string '{:?}', is '{:?}'",
&[118, 49, 46, 50, 10],
msg.version.as_bytes()
);
}
_ => panic!("Invalid message type! Expected a MsgBootloaderHandshakeResp"),
Expand Down
54 changes: 39 additions & 15 deletions rust/sbp/tests/integration/auto_check_sbp_logging_msg_log.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,19 @@ fn test_auto_check_sbp_logging_msg_log() {
msg.level
);
assert_eq!(
msg.text.to_string(),
"Filtered all obs from 2314 at tow 83.539019",
"incorrect value for msg.text, expected string '{}', is '{}'",
"Filtered all obs from 2314 at tow 83.539019",
msg.text
msg.text.as_bytes(),
&[
70, 105, 108, 116, 101, 114, 101, 100, 32, 97, 108, 108, 32, 111, 98, 115,
32, 102, 114, 111, 109, 32, 50, 51, 49, 52, 32, 97, 116, 32, 116, 111, 119,
32, 56, 51, 46, 53, 51, 57, 48, 49, 57
],
"incorrect value for msg.text, expected string '{:?}', is '{:?}'",
&[
70, 105, 108, 116, 101, 114, 101, 100, 32, 97, 108, 108, 32, 111, 98, 115,
32, 102, 114, 111, 109, 32, 50, 51, 49, 52, 32, 97, 116, 32, 116, 111, 119,
32, 56, 51, 46, 53, 51, 57, 48, 49, 57
],
msg.text.as_bytes()
);
}
_ => panic!("Invalid message type! Expected a MsgLog"),
Expand Down Expand Up @@ -117,11 +125,19 @@ fn test_json2sbp_auto_check_sbp_logging_msg_log() {
msg.level
);
assert_eq!(
msg.text.to_string(),
"Filtered all obs from 2314 at tow 83.539019",
"incorrect value for msg.text, expected string '{}', is '{}'",
"Filtered all obs from 2314 at tow 83.539019",
msg.text
msg.text.as_bytes(),
&[
70, 105, 108, 116, 101, 114, 101, 100, 32, 97, 108, 108, 32, 111, 98, 115,
32, 102, 114, 111, 109, 32, 50, 51, 49, 52, 32, 97, 116, 32, 116, 111, 119,
32, 56, 51, 46, 53, 51, 57, 48, 49, 57
],
"incorrect value for msg.text, expected string '{:?}', is '{:?}'",
&[
70, 105, 108, 116, 101, 114, 101, 100, 32, 97, 108, 108, 32, 111, 98, 115,
32, 102, 114, 111, 109, 32, 50, 51, 49, 52, 32, 97, 116, 32, 116, 111, 119,
32, 56, 51, 46, 53, 51, 57, 48, 49, 57
],
msg.text.as_bytes()
);
}
_ => panic!("Invalid message type! Expected a MsgLog"),
Expand Down Expand Up @@ -190,11 +206,19 @@ fn test_sbp2json_auto_check_sbp_logging_msg_log() {
msg.level
);
assert_eq!(
msg.text.to_string(),
"Filtered all obs from 2314 at tow 83.539019",
"incorrect value for msg.text, expected string '{}', is '{}'",
"Filtered all obs from 2314 at tow 83.539019",
msg.text
msg.text.as_bytes(),
&[
70, 105, 108, 116, 101, 114, 101, 100, 32, 97, 108, 108, 32, 111, 98, 115,
32, 102, 114, 111, 109, 32, 50, 51, 49, 52, 32, 97, 116, 32, 116, 111, 119,
32, 56, 51, 46, 53, 51, 57, 48, 49, 57
],
"incorrect value for msg.text, expected string '{:?}', is '{:?}'",
&[
70, 105, 108, 116, 101, 114, 101, 100, 32, 97, 108, 108, 32, 111, 98, 115,
32, 102, 114, 111, 109, 32, 50, 51, 49, 52, 32, 97, 116, 32, 116, 111, 119,
32, 56, 51, 46, 53, 51, 57, 48, 49, 57
],
msg.text.as_bytes()
);
}
_ => panic!("Invalid message type! Expected a MsgLog"),
Expand Down
Loading