/**************************************** * NOTICE * ______________________________________ * * Copyright 2023 Tony Nguyen * * Project: * Name: to_snake_case * Links: * - https://gitlab.com/t101/to_snake_case * * Modified: 20-Feb-2023 * ______________________________________ * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ******************************************/ #[cfg(test)] mod test_camel_case { use to_snake_case::ToSnakeCase; #[test] fn test_camel_case() { let expected = "to_snake_case"; let input = String::from("toSnakeCase"); let output = input.to_snake_case(); assert_eq!(expected, &output); } #[test] fn test_camel_case_short_text_two_word() { let expected = "a_b"; let input = String::from("aB"); let output = input.to_snake_case(); assert_eq!(expected, &output); } #[test] fn test_camel_case_short_text_one_word_one_letter() { let expected = "a"; let input = String::from("a"); let output = input.to_snake_case(); assert_eq!(expected, &output); } }