This repository has been archived by the owner on Aug 2, 2023. It is now read-only.
forked from Peternator7/strum
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests for nostd environment (Peternator7#196)
Co-authored-by: Peter Glotfelty <[email protected]>
- Loading branch information
1 parent
2ba6b0a
commit 0c80602
Showing
4 changed files
with
54 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
[package] | ||
name = "strum_nostd_tests" | ||
version = "0.23.1" | ||
edition = "2018" | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] | ||
strum = { path = "../strum", features = ["derive"] } | ||
strum_macros = { path = "../strum_macros", features = [] } | ||
|
||
[dev-dependencies] | ||
rustversion = "1.0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#![no_std] | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
use core::str::FromStr; | ||
use strum::EnumString; | ||
|
||
#[derive(Debug, Eq, PartialEq, EnumString)] | ||
enum Color { | ||
Red, | ||
Blue { | ||
hue: usize, | ||
}, | ||
#[strum(serialize = "y", serialize = "yellow")] | ||
Yellow, | ||
#[strum(to_string = "purp")] | ||
Purple, | ||
#[strum(serialize = "blk", serialize = "Black", ascii_case_insensitive)] | ||
Black, | ||
} | ||
|
||
#[test] | ||
fn from_str_no_std() { | ||
assert_eq!(Color::Yellow, Color::from_str("yellow").unwrap()); | ||
} | ||
|
||
#[test] | ||
#[rustversion::since(1.34)] | ||
fn try_from_str_no_std() { | ||
use core::convert::TryFrom; | ||
assert_eq!(Color::Yellow, Color::try_from("yellow").unwrap()); | ||
} | ||
|
||
#[test] | ||
#[rustversion::before(1.34)] | ||
fn try_from_str_no_std() {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters