Skip to content

Commit c0e58fb

Browse files
Add cargo check workflow (#24)
* Add `cargo check` workflow * add all targets * fix sizing of array
1 parent 9f4f6a5 commit c0e58fb

File tree

3 files changed

+37
-6
lines changed

3 files changed

+37
-6
lines changed

.github/workflows/check.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Cargo Check
2+
3+
on:
4+
push:
5+
branches: [ master, main ]
6+
pull_request:
7+
branches: [ master, main ]
8+
9+
env:
10+
RUST_BACKTRACE: 1
11+
12+
jobs:
13+
check:
14+
name: Cargo Check
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Checkout code
18+
uses: actions/checkout@v4
19+
20+
- name: Install Rust
21+
uses: dtolnay/rust-toolchain@stable
22+
23+
- name: Run cargo check
24+
run: cargo check --all-targets --all-features

examples/jogcon.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
//! are represented and you can send them with square, triangle,
66
//! circle, left, up, and right.
77
8-
#![feature(duration_from_micros)]
9-
108
extern crate embedded_hal;
119
extern crate linux_embedded_hal as linux_hal;
1210
extern crate pscontroller_rs;
@@ -56,7 +54,7 @@ fn main() {
5654

5755
// We only care about the JogCon here so skip everything else
5856
let jogcon = match controller {
59-
Device::JogCon(x) => (x),
57+
Device::JogCon(x) => x,
6058
_ => continue,
6159
};
6260

src/lib.rs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -499,13 +499,22 @@ where
499499
}
500500
}
501501

502+
#[cfg(test)]
502503
mod tests {
504+
use super::ControllerData;
505+
use super::MESSAGE_MAX_LENGTH;
506+
503507
#[test]
504508
fn union_test() {
505509
// Again, buttons are active low, hence 'fe' and '7f'
506-
let controller = ControllerData {
507-
data: [0xfe, 0x7f, 0x00, 0x00, 0x00, 0xff],
508-
};
510+
let mut data = [0u8; MESSAGE_MAX_LENGTH];
511+
data[0] = 0xfe;
512+
data[1] = 0x7f;
513+
data[2] = 0x00;
514+
data[3] = 0x00;
515+
data[4] = 0x00;
516+
data[5] = 0xff;
517+
let controller = ControllerData { data };
509518

510519
unsafe {
511520
assert!(controller.ds.buttons.select() == true);

0 commit comments

Comments
 (0)