Debian Codegraph @

debian/rust-vendor/chrono/tests/win_bindings.rs

raw
1 use std::fs;
2 use windows_bindgen::bindgen;
3
4 #[test]
5 fn gen_bindings() {
6 let existing = fs::read_to_string(BINDINGS).unwrap();
7
8 bindgen([
9 "--out",
10 BINDINGS,
11 "--flat",
12 "--no-comment",
13 "--no-deps",
14 "--sys",
15 "--filter",
16 "GetTimeZoneInformationForYear",
17 "SystemTimeToFileTime",
18 "SystemTimeToTzSpecificLocalTime",
19 "TzSpecificLocalTimeToSystemTime",
20 ])
21 .unwrap();
22
23 // Check the output is the same as before.
24 // Depending on the git configuration the file may have been checked out with `\r\n` newlines or
25 // with `\n`. Compare line-by-line to ignore this difference.
26 let mut new = fs::read_to_string(BINDINGS).unwrap();
27 if existing.contains("\r\n") && !new.contains("\r\n") {
28 new = new.replace("\n", "\r\n");
29 } else if !existing.contains("\r\n") && new.contains("\r\n") {
30 new = new.replace("\r\n", "\n");
31 }
32
33 similar_asserts::assert_eq!(existing, new);
34 if !new.lines().eq(existing.lines()) {
35 panic!("generated file `{BINDINGS}` is changed.");
36 }
37 }
38
39 const BINDINGS: &str = "src/offset/local/win_bindings.rs";