summaryrefslogtreecommitdiffstats
path: root/library/std/src/sys_common/thread_local_key/tests.rs
blob: 6a44c65d91869fc7b3034f1d1c70ab2031159dc9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use super::StaticKey;
use core::ptr;

#[test]
fn statik() {
    static K1: StaticKey = StaticKey::new(None);
    static K2: StaticKey = StaticKey::new(None);

    unsafe {
        assert!(K1.get().is_null());
        assert!(K2.get().is_null());
        K1.set(ptr::invalid_mut(1));
        K2.set(ptr::invalid_mut(2));
        assert_eq!(K1.get() as usize, 1);
        assert_eq!(K2.get() as usize, 2);
    }
}