pub fn escape_ident(name: &str) -> String {
    format!("\"{}\"", name.replace('"', "\"\""))
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn escape_ident_simple_name() {
        assert_eq!(escape_ident("users"), "\"users\"");
    }

    #[test]
    fn escape_ident_with_double_quotes() {
        assert_eq!(escape_ident(r#"my"table"#), r#""my""table""#);
    }

    #[test]
    fn escape_ident_empty_string() {
        assert_eq!(escape_ident(""), r#""""#);
    }

    #[test]
    fn escape_ident_with_spaces() {
        assert_eq!(escape_ident("my table"), "\"my table\"");
    }

    #[test]
    fn escape_ident_with_semicolon() {
        assert_eq!(escape_ident("users; DROP TABLE"), "\"users; DROP TABLE\"");
    }

    #[test]
    fn escape_ident_with_single_quotes() {
        assert_eq!(escape_ident("it's"), "\"it's\"");
    }

    #[test]
    fn escape_ident_with_backslash() {
        assert_eq!(escape_ident(r"back\slash"), r#""back\slash""#);
    }

    #[test]
    fn escape_ident_unicode() {
        assert_eq!(escape_ident("таблица"), "\"таблица\"");
    }

    #[test]
    fn escape_ident_multiple_double_quotes() {
        assert_eq!(escape_ident(r#"a""b"#), r#""a""""b""#);
    }

    #[test]
    fn escape_ident_reserved_word() {
        assert_eq!(escape_ident("select"), "\"select\"");
    }

    #[test]
    fn escape_ident_null_byte() {
        assert_eq!(escape_ident("a\0b"), "\"a\0b\"");
    }

    #[test]
    fn escape_ident_newline() {
        assert_eq!(escape_ident("a\nb"), "\"a\nb\"");
    }
}
