fix tests fail depending on features
All checks were successful
Rust / build (pull_request) Successful in 1m54s

This commit is contained in:
Vinzenz Schroeter 2025-05-24 13:27:08 +02:00
parent c80449777d
commit 020c75c487
5 changed files with 32 additions and 12 deletions

View file

@ -6,6 +6,7 @@ use servicepoint::{
};
use std::{fmt::Debug, net::UdpSocket};
/// Command that sets the brightness to zero globally.
#[derive(Debug, Eq, PartialEq, Clone)]
pub struct ZeroBrightnessCommand;
@ -15,6 +16,7 @@ impl Into<Packet> for ZeroBrightnessCommand {
}
}
/// Command that turns into a random packet.
#[derive(Debug, Eq, PartialEq, Clone)]
pub struct FuzzyCommand;

View file

@ -263,13 +263,16 @@ mod tests {
#[test]
fn into_packet_invalid_alignment() {
let mut cmd = BitmapCommand::from(Bitmap::max_sized());
cmd.origin.x = 5;
let cmd = BitmapCommand {
bitmap: Bitmap::max_sized(),
compression: CompressionCode::Uncompressed,
origin: Origin::new(5, 0),
};
let packet = Packet::try_from(cmd).unwrap();
assert_eq!(
packet.header,
Header {
command_code: 25,
command_code: 19,
a: 0,
b: 0,
c: 56,
@ -277,13 +280,16 @@ mod tests {
}
);
let mut cmd = BitmapCommand::from(Bitmap::max_sized());
cmd.origin.x = 11;
let cmd = BitmapCommand{
bitmap: Bitmap::max_sized(),
compression: CompressionCode::Uncompressed,
origin: Origin::new(11, 0),
};
let packet = Packet::try_from(cmd).unwrap();
assert_eq!(
packet.header,
Header {
command_code: 25,
command_code: 19,
a: 1,
b: 0,
c: 56,

View file

@ -383,6 +383,7 @@ mod tests {
fn into_packet_invalid_alignment() {
let mut cmd = BitVecCommand::from(DisplayBitVec::repeat(false, 32));
cmd.offset = 5;
cmd.compression = CompressionCode::Uncompressed;
let packet = Packet::try_from(cmd).unwrap();
assert_eq!(
packet.header,
@ -390,13 +391,17 @@ mod tests {
command_code: 18,
a: 5,
b: 4,
c: 27770,
c: 0,
d: 0
}
);
let mut cmd = BitVecCommand::from(DisplayBitVec::repeat(false, 32));
cmd.offset = 11;
let cmd = BitVecCommand {
bitvec: DisplayBitVec::repeat(false, 32),
offset: 11,
operation: BinaryOperation::Overwrite,
compression: CompressionCode::Uncompressed,
};
let packet = Packet::try_from(cmd).unwrap();
assert_eq!(
packet.header,
@ -404,7 +409,7 @@ mod tests {
command_code: 18,
a: 11,
b: 4,
c: 27770,
c: 0,
d: 0
}
);

View file

@ -16,8 +16,10 @@ use crate::{
/// # use servicepoint::*;
/// # let connection = FakeConnection;
/// let grid = CharGrid::from("Hello,\nWorld!");
/// # #[cfg(feature = "cp437")] {
/// let grid = Cp437Grid::from(&grid);
/// connection.send_command(Cp437GridCommand{ origin: Origin::ZERO, grid }).expect("send failed");
/// # }
/// ```
///
/// ```rust

View file

@ -2,23 +2,28 @@
///
/// # Examples
///
/// create command without payload compression
/// ```rust
/// # use servicepoint::*;
/// // create command without payload compression
/// # let pixels = Bitmap::max_sized();
/// _ = BitmapCommand {
/// origin: Origin::ZERO,
/// bitmap: pixels,
/// compression: CompressionCode::Uncompressed
/// };
/// ```
///
/// // create command with payload compressed with lzma and appropriate header flags
/// create command with payload compressed with lzma and appropriate header flags
/// ```rust
/// # use servicepoint::*;
/// # let pixels = Bitmap::max_sized();
/// # #[cfg(feature = "compression_lzma")] {
/// _ = BitmapCommand {
/// origin: Origin::ZERO,
/// bitmap: pixels,
/// compression: CompressionCode::Lzma
/// };
/// # }
/// ```
#[repr(u16)]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]