Simon Sapin 7 лет назад
Родитель
Сommit
50c3efe92f
2 измененных файлов с 11 добавлено и 19 удалено
  1. 5 10
      idna/tests/unit.rs
  2. 6 9
      idna/tests/uts46.rs

+ 5 - 10
idna/tests/unit.rs

@@ -1,18 +1,13 @@
 extern crate idna;
 extern crate unicode_normalization;
 
-use idna::uts46;
 use unicode_normalization::char::is_combining_mark;
 
-fn _to_ascii(domain: &str) -> Result<String, uts46::Errors> {
-    uts46::to_ascii(
-        domain,
-        uts46::Flags {
-            transitional_processing: false,
-            use_std3_ascii_rules: true,
-            verify_dns_length: true,
-        },
-    )
+fn _to_ascii(domain: &str) -> Result<String, idna::Errors> {
+    idna::Config::default()
+        .verify_dns_length(true)
+        .use_std3_ascii_rules(true)
+        .to_ascii(domain)
 }
 
 #[test]

+ 6 - 9
idna/tests/uts46.rs

@@ -6,7 +6,6 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-use idna::uts46;
 use std::char;
 use test::TestFn;
 
@@ -49,14 +48,12 @@ pub fn collect_tests<F: FnMut(String, TestFn)>(add_test: &mut F) {
         add_test(
             test_name,
             TestFn::dyn_test_fn(move || {
-                let result = uts46::to_ascii(
-                    &source,
-                    uts46::Flags {
-                        use_std3_ascii_rules: true,
-                        transitional_processing: test_type == "T",
-                        verify_dns_length: true,
-                    },
-                );
+                let result = idna::Config::default()
+                    .use_std3_ascii_rules(true)
+                    .verify_dns_length(true)
+                    .check_hyphens(true)
+                    .transitional_processing(test_type == "T")
+                    .to_ascii(&source);
 
                 if to_ascii.starts_with("[") {
                     if to_ascii.starts_with("[C") {