MCPcopy Create free account
hub / github.com/bitflags/bitflags / valid

Function valid

src/tests/parser.rs:71–100  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

69
70 #[test]
71 fn valid() {
72 assert_eq!(0, from_str::<TestFlags>("").unwrap().bits());
73
74 assert_eq!(1, from_str::<TestFlags>("A").unwrap().bits());
75 assert_eq!(1, from_str::<TestFlags>(" A ").unwrap().bits());
76 assert_eq!(
77 1 | 1 << 1 | 1 << 2,
78 from_str::<TestFlags>("A | B | C").unwrap().bits()
79 );
80 assert_eq!(
81 1 | 1 << 1 | 1 << 2,
82 from_str::<TestFlags>("A\n|\tB\r\n| C ").unwrap().bits()
83 );
84 assert_eq!(
85 1 | 1 << 1 | 1 << 2,
86 from_str::<TestFlags>("A|B|C").unwrap().bits()
87 );
88
89 assert_eq!(1 << 3, from_str::<TestFlags>("0x8").unwrap().bits());
90 assert_eq!(1 | 1 << 3, from_str::<TestFlags>("A | 0x8").unwrap().bits());
91 assert_eq!(
92 1 | 1 << 1 | 1 << 3,
93 from_str::<TestFlags>("0x1 | 0x8 | B").unwrap().bits()
94 );
95
96 assert_eq!(
97 1 | 1 << 1,
98 from_str::<TestUnicode>("一 | 二").unwrap().bits()
99 );
100 }
101
102 #[test]
103 fn invalid() {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected