fix tests fail depending on features
All checks were successful
Rust / build (pull_request) Successful in 1m54s
All checks were successful
Rust / build (pull_request) Successful in 1m54s
This commit is contained in:
parent
c80449777d
commit
020c75c487
|
@ -6,6 +6,7 @@ use servicepoint::{
|
||||||
};
|
};
|
||||||
use std::{fmt::Debug, net::UdpSocket};
|
use std::{fmt::Debug, net::UdpSocket};
|
||||||
|
|
||||||
|
/// Command that sets the brightness to zero globally.
|
||||||
#[derive(Debug, Eq, PartialEq, Clone)]
|
#[derive(Debug, Eq, PartialEq, Clone)]
|
||||||
pub struct ZeroBrightnessCommand;
|
pub struct ZeroBrightnessCommand;
|
||||||
|
|
||||||
|
@ -15,6 +16,7 @@ impl Into<Packet> for ZeroBrightnessCommand {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Command that turns into a random packet.
|
||||||
#[derive(Debug, Eq, PartialEq, Clone)]
|
#[derive(Debug, Eq, PartialEq, Clone)]
|
||||||
pub struct FuzzyCommand;
|
pub struct FuzzyCommand;
|
||||||
|
|
||||||
|
|
|
@ -263,13 +263,16 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn into_packet_invalid_alignment() {
|
fn into_packet_invalid_alignment() {
|
||||||
let mut cmd = BitmapCommand::from(Bitmap::max_sized());
|
let cmd = BitmapCommand {
|
||||||
cmd.origin.x = 5;
|
bitmap: Bitmap::max_sized(),
|
||||||
|
compression: CompressionCode::Uncompressed,
|
||||||
|
origin: Origin::new(5, 0),
|
||||||
|
};
|
||||||
let packet = Packet::try_from(cmd).unwrap();
|
let packet = Packet::try_from(cmd).unwrap();
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
packet.header,
|
packet.header,
|
||||||
Header {
|
Header {
|
||||||
command_code: 25,
|
command_code: 19,
|
||||||
a: 0,
|
a: 0,
|
||||||
b: 0,
|
b: 0,
|
||||||
c: 56,
|
c: 56,
|
||||||
|
@ -277,13 +280,16 @@ mod tests {
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
let mut cmd = BitmapCommand::from(Bitmap::max_sized());
|
let cmd = BitmapCommand{
|
||||||
cmd.origin.x = 11;
|
bitmap: Bitmap::max_sized(),
|
||||||
|
compression: CompressionCode::Uncompressed,
|
||||||
|
origin: Origin::new(11, 0),
|
||||||
|
};
|
||||||
let packet = Packet::try_from(cmd).unwrap();
|
let packet = Packet::try_from(cmd).unwrap();
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
packet.header,
|
packet.header,
|
||||||
Header {
|
Header {
|
||||||
command_code: 25,
|
command_code: 19,
|
||||||
a: 1,
|
a: 1,
|
||||||
b: 0,
|
b: 0,
|
||||||
c: 56,
|
c: 56,
|
||||||
|
|
|
@ -383,6 +383,7 @@ mod tests {
|
||||||
fn into_packet_invalid_alignment() {
|
fn into_packet_invalid_alignment() {
|
||||||
let mut cmd = BitVecCommand::from(DisplayBitVec::repeat(false, 32));
|
let mut cmd = BitVecCommand::from(DisplayBitVec::repeat(false, 32));
|
||||||
cmd.offset = 5;
|
cmd.offset = 5;
|
||||||
|
cmd.compression = CompressionCode::Uncompressed;
|
||||||
let packet = Packet::try_from(cmd).unwrap();
|
let packet = Packet::try_from(cmd).unwrap();
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
packet.header,
|
packet.header,
|
||||||
|
@ -390,13 +391,17 @@ mod tests {
|
||||||
command_code: 18,
|
command_code: 18,
|
||||||
a: 5,
|
a: 5,
|
||||||
b: 4,
|
b: 4,
|
||||||
c: 27770,
|
c: 0,
|
||||||
d: 0
|
d: 0
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
let mut cmd = BitVecCommand::from(DisplayBitVec::repeat(false, 32));
|
let cmd = BitVecCommand {
|
||||||
cmd.offset = 11;
|
bitvec: DisplayBitVec::repeat(false, 32),
|
||||||
|
offset: 11,
|
||||||
|
operation: BinaryOperation::Overwrite,
|
||||||
|
compression: CompressionCode::Uncompressed,
|
||||||
|
};
|
||||||
let packet = Packet::try_from(cmd).unwrap();
|
let packet = Packet::try_from(cmd).unwrap();
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
packet.header,
|
packet.header,
|
||||||
|
@ -404,7 +409,7 @@ mod tests {
|
||||||
command_code: 18,
|
command_code: 18,
|
||||||
a: 11,
|
a: 11,
|
||||||
b: 4,
|
b: 4,
|
||||||
c: 27770,
|
c: 0,
|
||||||
d: 0
|
d: 0
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
|
@ -16,8 +16,10 @@ use crate::{
|
||||||
/// # use servicepoint::*;
|
/// # use servicepoint::*;
|
||||||
/// # let connection = FakeConnection;
|
/// # let connection = FakeConnection;
|
||||||
/// let grid = CharGrid::from("Hello,\nWorld!");
|
/// let grid = CharGrid::from("Hello,\nWorld!");
|
||||||
|
/// # #[cfg(feature = "cp437")] {
|
||||||
/// let grid = Cp437Grid::from(&grid);
|
/// let grid = Cp437Grid::from(&grid);
|
||||||
/// connection.send_command(Cp437GridCommand{ origin: Origin::ZERO, grid }).expect("send failed");
|
/// connection.send_command(Cp437GridCommand{ origin: Origin::ZERO, grid }).expect("send failed");
|
||||||
|
/// # }
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
|
|
|
@ -2,23 +2,28 @@
|
||||||
///
|
///
|
||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
|
/// create command without payload compression
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # use servicepoint::*;
|
/// # use servicepoint::*;
|
||||||
/// // create command without payload compression
|
|
||||||
/// # let pixels = Bitmap::max_sized();
|
/// # let pixels = Bitmap::max_sized();
|
||||||
/// _ = BitmapCommand {
|
/// _ = BitmapCommand {
|
||||||
/// origin: Origin::ZERO,
|
/// origin: Origin::ZERO,
|
||||||
/// bitmap: pixels,
|
/// bitmap: pixels,
|
||||||
/// compression: CompressionCode::Uncompressed
|
/// 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();
|
/// # let pixels = Bitmap::max_sized();
|
||||||
|
/// # #[cfg(feature = "compression_lzma")] {
|
||||||
/// _ = BitmapCommand {
|
/// _ = BitmapCommand {
|
||||||
/// origin: Origin::ZERO,
|
/// origin: Origin::ZERO,
|
||||||
/// bitmap: pixels,
|
/// bitmap: pixels,
|
||||||
/// compression: CompressionCode::Lzma
|
/// compression: CompressionCode::Lzma
|
||||||
/// };
|
/// };
|
||||||
|
/// # }
|
||||||
/// ```
|
/// ```
|
||||||
#[repr(u16)]
|
#[repr(u16)]
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||||
|
|
Loading…
Reference in a new issue