1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// autocorrect: false

#[cfg(test)]
mod tests {
    use crate::code::*;
    use indoc::indoc;
    use pretty_assertions::assert_eq;

    #[test]
    fn it_format_zig() {
        let example = indoc! {r###"
        //! 这是top-level文档注释
        const std = @import("std");

        /// 这是main函数
        pub fn main() !void {
            // 这是comment
            const text = "hello你好";
        }
        "###};

        let expect = indoc! {r###"
        //! 这是 top-level 文档注释
        const std = @import("std");

        /// 这是 main 函数
        pub fn main() !void {
            // 这是 comment
            const text = "hello 你好";
        }
        "###};

        assert_eq!(expect, format_for(example, "zig").to_string())
    }
}