generated from PlexSheep/baserepo
Compare commits
4 commits
222d248fab
...
d58207cb5d
Author | SHA1 | Date | |
---|---|---|---|
d58207cb5d | |||
97b8086624 | |||
5a7f980c92 | |||
c4921ec364 |
5 changed files with 23 additions and 15 deletions
|
@ -31,13 +31,15 @@ jobs:
|
|||
echo 'index = "https://git.cscherr.de/PlexSheep/_cargo-index.git"' >> ~/.cargo/config.toml
|
||||
cat ~/.cargo/config.toml
|
||||
- name: cargo clippy check
|
||||
run: cargo clippy --all-features --all-targets
|
||||
run: cargo clippy --all-features --all-targets --workspace
|
||||
- name: cargo clippy fix
|
||||
run: cargo clippy --fix --all-features --all-targets
|
||||
run: cargo clippy --fix --all-features --all-targets --workspace
|
||||
- name: cargo fmt
|
||||
run: cargo fmt --all
|
||||
- name: install python
|
||||
run: apt update && apt install libpython3-dev -y
|
||||
- name: cargo test
|
||||
run: cargo test --all-features --all-targets
|
||||
run: cargo test --all-features --all-targets --workspace
|
||||
- name: commit back to repository
|
||||
uses: https://github.com/stefanzweifel/git-auto-commit-action@v5
|
||||
with:
|
||||
|
|
8
.github/workflows/cargo.yaml
vendored
8
.github/workflows/cargo.yaml
vendored
|
@ -32,13 +32,15 @@ jobs:
|
|||
echo 'index = "https://git.cscherr.de/PlexSheep/_cargo-index.git"' >> ~/.cargo/config.toml
|
||||
cat ~/.cargo/config.toml
|
||||
- name: cargo clippy check
|
||||
run: cargo clippy --all-features --all-targets
|
||||
run: cargo clippy --all-features --all-targets --workspace
|
||||
- name: cargo clippy fix
|
||||
run: cargo clippy --fix --all-features --all-targets
|
||||
run: cargo clippy --fix --all-features --all-targets --workspace
|
||||
- name: cargo fmt
|
||||
run: cargo fmt --all
|
||||
- name: install python
|
||||
run: apt update && apt install libpython3-dev -y
|
||||
- name: cargo test
|
||||
run: cargo test --all-features --all-targets
|
||||
run: cargo test --all-features --all-targets --workspace
|
||||
- name: commit back to repository
|
||||
uses: stefanzweifel/git-auto-commit-action@v5
|
||||
with:
|
||||
|
|
|
@ -8,11 +8,12 @@ pub use num_traits::{PrimInt, ToPrimitive};
|
|||
/// ### Arguments
|
||||
/// * `data` - The data you are trying to dump
|
||||
pub fn bytes_to_bin(data: &[u8]) -> String {
|
||||
let mut s = format!("0b{:08b}", data.first().unwrap());
|
||||
for dat in data {
|
||||
let mut s = String::new();
|
||||
for (i, dat) in data.iter().enumerate() {
|
||||
if i == 0 {
|
||||
s.push_str(&format!("0b{:08b}", dat));
|
||||
} else {
|
||||
s.push_str(&format!("_{:08b}", dat));
|
||||
if dat % 8 == 0 {
|
||||
s.push('\n')
|
||||
}
|
||||
}
|
||||
s
|
||||
|
|
|
@ -6,6 +6,10 @@ fn btobin() {
|
|||
let data = [19, 19];
|
||||
let r = bytes_to_bin(&data);
|
||||
assert_eq!(r, format!("0b00010011_00010011"));
|
||||
|
||||
let data = [0xff, 0xff];
|
||||
let r = bytes_to_bin(&data);
|
||||
assert_eq!(r, format!("0b11111111_11111111"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -15,9 +19,7 @@ fn big_btobin() {
|
|||
assert_eq!(
|
||||
r,
|
||||
format!(
|
||||
"0b00001100_00011111_01010010_\
|
||||
00100000_01111011_00100000_01011100_00010111_00001100\n\
|
||||
_00100000_00001100_00000001_00000001_00000001"
|
||||
"0b00001100_00011111_01010010_00100000_01111011_00100000_01011100_00010111_00001100_00100000_00001100_00000001_00000001_00000001"
|
||||
)
|
||||
);
|
||||
}
|
||||
|
|
|
@ -14,5 +14,6 @@ categories.workspace = true
|
|||
|
||||
[dependencies]
|
||||
anyhow = "1.0.79"
|
||||
cucumber = "0.20.2"
|
||||
libpt-log = { workspace = true }
|
||||
|
||||
[dev-dependencies]
|
||||
|
|
Reference in a new issue