Skip to content

Commit

Permalink
Merge pull request #2 from niclashoyer/1.0.0-alpha.6
Browse files Browse the repository at this point in the history
Increase test coverage
  • Loading branch information
niclashoyer committed Dec 22, 2021
2 parents 2458e1b + ad46f92 commit d686018
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [0.4.1] - 2021-12-23
### Changed
- Extended tests to increase test coverage

## [0.4.0] - 2021-12-23
### Changed
- Updated `embedded-hal` to `1.0.0-alpha.6`
Expand Down
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "embedded-hal-sync-pins"
version = "0.4.0"
version = "0.4.1"
authors = ["Niclas Hoyer <info@niclashoyer.de>"]
edition = "2018"
description = "embedded-hal pin implementations that can be shared between threads"
Expand Down
15 changes: 15 additions & 0 deletions src/pins.rs
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,11 @@ mod tests {
fn atomic_pin_state() {
use PinState::*;
let state = AtomicPinState::new();
let state_def = AtomicPinState::default();
assert_eq!(
state_def.load(Ordering::SeqCst),
state.load(Ordering::SeqCst)
);
assert_eq!(Floating, state.load(Ordering::SeqCst));
// loading second time should still contain value
assert_eq!(Floating, state.load(Ordering::SeqCst));
Expand Down Expand Up @@ -392,6 +397,7 @@ mod tests {
use hal::InputPin as HalInputPin;
use hal::OutputPin as HalOutputPin;
use hal::StatefulOutputPin as HalStatefulOutputPin;
use hal::ToggleableOutputPin;
use PinState::*;
let state = Arc::new(AtomicPinState::new());
let mut pin = PushPullPin::new(state.clone());
Expand All @@ -408,13 +414,18 @@ mod tests {
assert_eq!(Low, state.load(Ordering::SeqCst));
assert_eq!(Ok(false), pin.is_high());
assert_eq!(Ok(true), pin.is_low());
assert_eq!(Ok(()), pin.toggle());
assert_eq!(High, state.load(Ordering::SeqCst));
assert_eq!(Ok(()), pin.toggle());
assert_eq!(Low, state.load(Ordering::SeqCst));
}

#[test]
fn hal_open_drain_pin() {
use hal::InputPin as HalInputPin;
use hal::OutputPin as HalOutputPin;
use hal::StatefulOutputPin as HalStatefulOutputPin;
use hal::ToggleableOutputPin;
use PinState::*;
let state = Arc::new(AtomicPinState::new());
let mut pin = OpenDrainPin::new(state.clone());
Expand All @@ -431,5 +442,9 @@ mod tests {
assert_eq!(Ok(false), pin.is_low());
assert_eq!(Ok(true), pin.is_set_low());
assert_eq!(Ok(false), pin.is_set_high());
assert_eq!(Ok(()), pin.toggle());
assert_eq!(Low, state.load(Ordering::SeqCst));
assert_eq!(Ok(()), pin.toggle());
assert_eq!(Floating, state.load(Ordering::SeqCst));
}
}

0 comments on commit d686018

Please sign in to comment.