MCPcopy Create free account
hub / github.com/rust-lang/libc / c_enum_basic

Function c_enum_basic

src/macros.rs:412–438  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

410
411 #[test]
412 fn c_enum_basic() {
413 // By default, variants get sequential values.
414 c_enum! {
415 pub enum e {
416 VAR0,
417 VAR1,
418 VAR2,
419 }
420
421 // Also check enums that don't create a type.
422 pub enum #anon {
423 ANON0,
424 ANON1,
425 ANON2,
426 }
427 }
428
429 assert_eq!(TypeId::of::<e>(), TypeId::of::<CEnumRepr>());
430 assert_eq!(VAR0, 0 as CEnumRepr);
431 assert_eq!(VAR1, 1 as CEnumRepr);
432 assert_eq!(VAR2, 2 as CEnumRepr);
433
434 assert_eq!(type_id_of_val(&ANON0), TypeId::of::<CEnumRepr>());
435 assert_eq!(ANON0, 0 as CEnumRepr);
436 assert_eq!(ANON1, 1 as CEnumRepr);
437 assert_eq!(ANON2, 2 as CEnumRepr);
438 }
439
440 #[test]
441 fn c_enum_repr() {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…