Skip to content
This repository was archived by the owner on Dec 29, 2022. It is now read-only.

Commit 4cc3e64

Browse files
committed
kebab-case configuration: rev0.3
1 parent 47b7a31 commit 4cc3e64

File tree

1 file changed

+25
-12
lines changed

1 file changed

+25
-12
lines changed

tests/tests_old.rs

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1105,18 +1105,10 @@ fn test_omit_init_build() {
11051105
);
11061106
}
11071107

1108-
11091108
pub trait ConvertStringCase {
11101109
fn convert_string_case(s: &str) -> String;
11111110
}
11121111

1113-
struct IdentityConverter;
1114-
impl ConvertStringCase for IdentityConverter {
1115-
fn convert_string_case<'a>(s:&'a str) -> String {
1116-
s.to_string()
1117-
}
1118-
}
1119-
11201112
struct CamelCaseConverter;
11211113
impl ConvertStringCase for CamelCaseConverter {
11221114
fn convert_string_case<'a>(s:&'a str) -> String {
@@ -1125,6 +1117,22 @@ impl ConvertStringCase for CamelCaseConverter {
11251117
}
11261118
}
11271119

1120+
struct KebabCaseConverter;
1121+
impl ConvertStringCase for KebabCaseConverter {
1122+
fn convert_string_case<'a>(s:&'a str) -> String {
1123+
use heck::KebabCase;
1124+
s.to_kebab_case().to_string()
1125+
}
1126+
}
1127+
1128+
struct SnakeCaseConverter;
1129+
impl ConvertStringCase for SnakeCaseConverter {
1130+
fn convert_string_case<'a>(s:&'a str) -> String {
1131+
use heck::SnakeCase;
1132+
s.to_snake_case().to_string()
1133+
}
1134+
}
1135+
11281136
fn test_init_impl<T:ConvertStringCase>() {
11291137
use serde_json::json;
11301138

@@ -1165,13 +1173,18 @@ fn test_init_impl<T:ConvertStringCase>() {
11651173
}
11661174

11671175
#[test]
1168-
fn test_init_with_configuration() {
1169-
test_init_impl::<IdentityConverter>();
1176+
fn test_init_with_configuration_camel_case() {
1177+
test_init_impl::<CamelCaseConverter>();
1178+
}
1179+
1180+
#[test]
1181+
fn test_init_with_configuration_kebab_case() {
1182+
test_init_impl::<KebabCaseConverter>();
11701183
}
11711184

11721185
#[test]
1173-
fn test_init_with_configuration_camel_case() {
1174-
test_init_impl::<CamelCaseConverter>();
1186+
fn test_init_with_configuration_snake_case() {
1187+
test_init_impl::<SnakeCaseConverter>();
11751188
}
11761189

11771190
#[test]

0 commit comments

Comments
 (0)