1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
use azalea_brigadier::suggestion::Suggestions;
use azalea_buf::AzBuf;
use azalea_protocol_macros::ClientboundGamePacket;
#[derive(AzBuf, ClientboundGamePacket, Clone, Debug, PartialEq)]
pub struct ClientboundCommandSuggestions {
#[var]
pub id: u32,
pub suggestions: Suggestions,
}
#[cfg(test)]
mod tests {
use std::io::Cursor;
use azalea_brigadier::{context::StringRange, suggestion::Suggestion};
use azalea_buf::AzBuf;
use super::*;
#[test]
fn test_suggestions() {
let suggestions = Suggestions::new(
StringRange::new(0, 5),
vec![Suggestion::new_with_tooltip(
StringRange::new(1, 4),
"foo",
"bar".to_owned(),
)],
);
let mut buf = Vec::new();
suggestions.azalea_write(&mut buf).unwrap();
let mut cursor = Cursor::new(&buf[..]);
let suggestions = Suggestions::azalea_read(&mut cursor).unwrap();
assert_eq!(suggestions, suggestions);
}
}
|