Skip to main content

create_platon_plugin/
lib.rs

1pub fn convert_to_kebab_case(input: &str) -> String {
2    inflections::case::to_kebab_case(input)
3}
4
5pub fn convert_to_camel_case(input: &str) -> String {
6    inflections::case::to_camel_case(input)
7}
8
9#[cfg(test)]
10mod tests {
11    use crate::{convert_to_camel_case, convert_to_kebab_case};
12
13    #[test]
14    fn check_camel_case_to_kebab_case() {
15        let result = convert_to_kebab_case("myPlugin");
16        assert_eq!(result, "my-plugin".to_owned());
17    }
18
19    #[test]
20    fn check_pascal_case_to_kebab_case() {
21        let result = convert_to_kebab_case("MyPlugin");
22        assert_eq!(result, "my-plugin".to_owned());
23    }
24
25    #[test]
26    fn check_constant_case_to_kebab_case() {
27        let result = convert_to_kebab_case("myplugin");
28        assert_eq!(result, "myplugin".to_owned());
29    }
30
31    #[test]
32    fn check_kebab_case_to_camel_case() {
33        let result = convert_to_camel_case("my-plugin");
34        assert_eq!(result, "myPlugin".to_owned());
35    }
36
37    #[test]
38    fn check_pascal_case_to_camel_case() {
39        let result = convert_to_camel_case("MyPlugin");
40        assert_eq!(result, "myPlugin".to_owned());
41    }
42
43    #[test]
44    fn check_constant_case_to_camel_case() {
45        let result = convert_to_camel_case("plugin");
46        assert_eq!(result, "plugin".to_owned());
47    }
48}