-
Notifications
You must be signed in to change notification settings - Fork 526
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* [Rust] updated code generator to prevent rust warning for "ambiguous glob re-exports" * [Rust] defined new trait 'ActingVersion' * fixed code formatting issues * [Rust] fixed benchmarks * [Rust] added test for issue 984 --------- Co-authored-by: Michael Ward <[email protected]>
- Loading branch information
Showing
11 changed files
with
174 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
use issue_984::{ | ||
message_header_codec::MessageHeaderDecoder, | ||
simple_message_codec::{encoder::MyGroupEncoder, *}, | ||
*, | ||
}; | ||
|
||
fn create_encoder(buffer: &mut Vec<u8>) -> SimpleMessageEncoder { | ||
let simple_msg = SimpleMessageEncoder::default().wrap( | ||
WriteBuf::new(buffer.as_mut_slice()), | ||
message_header_codec::ENCODED_LENGTH, | ||
); | ||
let mut header = simple_msg.header(0); | ||
header.parent().unwrap() | ||
} | ||
|
||
#[test] | ||
fn round_trip() -> SbeResult<()> { | ||
// encode... | ||
let mut buffer = vec![0u8; 256]; | ||
let mut simple_msg_encoder = create_encoder(&mut buffer); | ||
simple_msg_encoder.id(1985); | ||
|
||
let mut my_grp_encoder = simple_msg_encoder.my_group_encoder(1, MyGroupEncoder::default()); | ||
my_grp_encoder.advance()?; | ||
my_grp_encoder.f1(&[1, 2, 3, 4]); | ||
my_grp_encoder.f2(&[1, 2, 3, 4, 5]); | ||
my_grp_encoder.f3(&[1, 2, 3, 4, 5, 6]); | ||
|
||
// decode... | ||
let buf = ReadBuf::new(buffer.as_slice()); | ||
let header = MessageHeaderDecoder::default().wrap(buf, 0); | ||
assert_eq!(SBE_BLOCK_LENGTH, header.block_length()); | ||
assert_eq!(SBE_SCHEMA_VERSION, header.version()); | ||
assert_eq!(SBE_TEMPLATE_ID, header.template_id()); | ||
assert_eq!(SBE_SCHEMA_ID, header.schema_id()); | ||
|
||
let simple_msg_decoder = SimpleMessageDecoder::default().header(header); | ||
assert_eq!(1985, simple_msg_decoder.id()); | ||
let mut grp_decoder = simple_msg_decoder.my_group_decoder(); | ||
assert_eq!(1, grp_decoder.count()); | ||
grp_decoder.advance()?; | ||
|
||
assert_eq!([1, 2, 3, 4], grp_decoder.f1()); | ||
assert_eq!([1, 2, 3, 4, 5], grp_decoder.f2()); | ||
assert_eq!([1, 2, 3, 4, 5, 6], grp_decoder.f3()); | ||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.