Skip to content

Commit 46edcf0

Browse files
committed
Add test for rust-lang#13259
1 parent e0bd16c commit 46edcf0

File tree

1 file changed

+55
-0
lines changed

1 file changed

+55
-0
lines changed
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
extern crate native;
2+
extern crate libc;
3+
use libc::{c_void, LPVOID, DWORD};
4+
use libc::types::os::arch::extra::LPWSTR;
5+
6+
extern "system" {
7+
fn FormatMessageW(flags: DWORD,
8+
lpSrc: LPVOID,
9+
msgId: DWORD,
10+
langId: DWORD,
11+
buf: LPWSTR,
12+
nsize: DWORD,
13+
args: *const c_void)
14+
-> DWORD;
15+
16+
fn GetLastError() -> u32;
17+
}
18+
19+
fn test() {
20+
let mut buf: [u16, ..50] = [0, ..50];
21+
let ret = unsafe {
22+
FormatMessageW(0x1000, 0 as *mut c_void, 1, 0x400,
23+
buf.as_mut_ptr(), buf.len() as u32, 0 as *const c_void)
24+
};
25+
assert!(ret != 0);
26+
if ret == 0 {
27+
let err = unsafe { GetLastError() };
28+
println!("err: {}", err);
29+
}
30+
let s = std::str::from_utf16(buf);
31+
println!("{}", s);
32+
fail!();
33+
}
34+
fn main() {
35+
if cfg!(spawn) {
36+
spawn(proc() {
37+
test();
38+
});
39+
} else {
40+
test();
41+
}
42+
}
43+
44+
#[start]
45+
pub fn start(argc: int, argv: *const *const u8) -> int {
46+
if cfg!(green) {
47+
//green::start(argc, argv, rustuv::event_loop, main)
48+
0
49+
} else if cfg!(raw) {
50+
main();
51+
0
52+
} else {
53+
native::start(argc, argv, main)
54+
}
55+
}

0 commit comments

Comments
 (0)