Skip to content

Commit

Permalink
add test_sanitize_identifier
Browse files Browse the repository at this point in the history
  • Loading branch information
MixusMinimax committed Mar 15, 2024
1 parent 9a5edea commit 8ab3322
Showing 1 changed file with 61 additions and 0 deletions.
61 changes: 61 additions & 0 deletions prost-build/src/ident.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,67 @@ mod tests {

use super::*;

#[test]
fn test_sanitize_identifier() {
assert_eq!(sanitize_identifier("as"), "r#as");
assert_eq!(sanitize_identifier("break"), "r#break");
assert_eq!(sanitize_identifier("const"), "r#const");
assert_eq!(sanitize_identifier("continue"), "r#continue");
assert_eq!(sanitize_identifier("else"), "r#else");
assert_eq!(sanitize_identifier("enum"), "r#enum");
assert_eq!(sanitize_identifier("false"), "r#false");
assert_eq!(sanitize_identifier("fn"), "r#fn");
assert_eq!(sanitize_identifier("for"), "r#for");
assert_eq!(sanitize_identifier("if"), "r#if");
assert_eq!(sanitize_identifier("impl"), "r#impl");
assert_eq!(sanitize_identifier("in"), "r#in");
assert_eq!(sanitize_identifier("let"), "r#let");
assert_eq!(sanitize_identifier("loop"), "r#loop");
assert_eq!(sanitize_identifier("match"), "r#match");
assert_eq!(sanitize_identifier("mod"), "r#mod");
assert_eq!(sanitize_identifier("move"), "r#move");
assert_eq!(sanitize_identifier("mut"), "r#mut");
assert_eq!(sanitize_identifier("pub"), "r#pub");
assert_eq!(sanitize_identifier("ref"), "r#ref");
assert_eq!(sanitize_identifier("return"), "r#return");
assert_eq!(sanitize_identifier("static"), "r#static");
assert_eq!(sanitize_identifier("struct"), "r#struct");
assert_eq!(sanitize_identifier("trait"), "r#trait");
assert_eq!(sanitize_identifier("true"), "r#true");
assert_eq!(sanitize_identifier("type"), "r#type");
assert_eq!(sanitize_identifier("unsafe"), "r#unsafe");
assert_eq!(sanitize_identifier("use"), "r#use");
assert_eq!(sanitize_identifier("where"), "r#where");
assert_eq!(sanitize_identifier("while"), "r#while");
assert_eq!(sanitize_identifier("dyn"), "r#dyn");
assert_eq!(sanitize_identifier("abstract"), "r#abstract");
assert_eq!(sanitize_identifier("become"), "r#become");
assert_eq!(sanitize_identifier("box"), "r#box");
assert_eq!(sanitize_identifier("do"), "r#do");
assert_eq!(sanitize_identifier("final"), "r#final");
assert_eq!(sanitize_identifier("macro"), "r#macro");
assert_eq!(sanitize_identifier("override"), "r#override");
assert_eq!(sanitize_identifier("priv"), "r#priv");
assert_eq!(sanitize_identifier("typeof"), "r#typeof");
assert_eq!(sanitize_identifier("unsized"), "r#unsized");
assert_eq!(sanitize_identifier("virtual"), "r#virtual");
assert_eq!(sanitize_identifier("yield"), "r#yield");
assert_eq!(sanitize_identifier("async"), "r#async");
assert_eq!(sanitize_identifier("await"), "r#await");
assert_eq!(sanitize_identifier("try"), "r#try");
assert_eq!(sanitize_identifier("self"), "self_");
assert_eq!(sanitize_identifier("super"), "super_");
assert_eq!(sanitize_identifier("extern"), "extern_");
assert_eq!(sanitize_identifier("crate"), "crate_");
assert_eq!(sanitize_identifier("foo"), "foo");
assert_eq!(sanitize_identifier("bar"), "bar");
assert_eq!(sanitize_identifier("baz"), "baz");
assert_eq!(sanitize_identifier("0foo"), "_0foo");
assert_eq!(sanitize_identifier("foo0"), "foo0");
assert_eq!(sanitize_identifier("foo_"), "foo_");
assert_eq!(sanitize_identifier("_foo"), "_foo");
}

#[test]
fn test_to_snake() {
assert_eq!("foo_bar", &to_snake("FooBar"));
Expand Down

0 comments on commit 8ab3322

Please sign in to comment.