/**************************************** * 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. * ******************************************/ use to_snake_case::ToSnakeCase; #[test] fn snake_case() { let expected = "to_snake_case"; let input = String::from(expected); let output = input.to_snake_case(); assert_eq!(expected, &output); } #[test] fn snake_case_with_additional_underscores() { let expected = "to__snake_case"; let input = String::from(expected); let output = input.to_snake_case(); assert_eq!(expected, &output); } #[test] fn snake_case_with_anomaly() { let expected = "to__snake_case"; let input = String::from("to__snake_Case"); let output = input.to_snake_case(); assert_eq!(expected, &output); } #[test] fn snake_case_with_anomaly2() { let expected = "t_o__snake_case"; let input = String::from("tO__snake_Case"); let output = input.to_snake_case(); assert_eq!(expected, &output); } #[test] fn snake_case_with_anomaly3() { let expected = "t_o__snake_c_ase"; let input = String::from("tO__snake_CAse"); let output = input.to_snake_case(); assert_eq!(expected, &output); } #[test] fn snake_case_with_anomaly4() { let expected = "t_o__snake_c_ase"; let input = String::from("tO__SNAKE_CAse"); let output = input.to_snake_case(); assert_eq!(expected, &output); } #[test] fn underscore() { assert!('_'.is_ascii_punctuation()); assert!(!'_'.is_lowercase()); assert!(!'_'.is_uppercase()); }