- Notifications
You must be signed in to change notification settings - Fork44
Migrate normalization tests to test/ to simplify pruning tests during shipping.#48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Merged
Uh oh!
There was an error while loading.Please reload this page.
Merged
Changes fromall commits
Commits
Show all changes
4 commits Select commitHold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
3 changes: 3 additions & 0 deletions.travis.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletionCargo.toml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletionssrc/__test_api.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| // This crate comprises hacks and glue required to test private functions from tests/ | ||
| // | ||
| // Keep this as slim as possible. | ||
| // | ||
| // If you're caught using this outside this crates tests/, you get to clean up the mess. | ||
| use crate::stream_safe::StreamSafe; | ||
| pub fn stream_safe(s: &str) -> String { | ||
| StreamSafe::new(s.chars()).collect() | ||
| } | ||
| pub mod quick_check { | ||
| pub use crate::quick_check::*; | ||
| } |
4 changes: 2 additions & 2 deletionssrc/lib.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
10 changes: 0 additions & 10 deletionssrc/stream_safe.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
88 changes: 0 additions & 88 deletionssrc/test.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
File renamed without changes.
105 changes: 105 additions & 0 deletionstests/tests.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,105 @@ | ||
| extern crate unicode_normalization; | ||
| use unicode_normalization::UnicodeNormalization; | ||
| use unicode_normalization::__test_api::{ | ||
| stream_safe, | ||
| }; | ||
| mod data { | ||
| pub mod normalization_tests; | ||
| } | ||
| use data::normalization_tests::NORMALIZATION_TESTS; | ||
| #[test] | ||
| fn test_normalization_tests_unaffected() { | ||
| for test in NORMALIZATION_TESTS { | ||
| for &s in &[test.source, test.nfc, test.nfd, test.nfkc, test.nfkd] { | ||
| assert_eq!(stream_safe(s), s); | ||
| } | ||
| } | ||
| } | ||
| #[test] | ||
| fn test_official() { | ||
| macro_rules! normString { | ||
| ($method: ident, $input: expr) => { $input.$method().collect::<String>() } | ||
| } | ||
| for test in NORMALIZATION_TESTS { | ||
| // these invariants come from the CONFORMANCE section of | ||
| // http://www.unicode.org/Public/UNIDATA/NormalizationTest.txt | ||
| { | ||
| let r1 = normString!(nfc, test.source); | ||
| let r2 = normString!(nfc, test.nfc); | ||
| let r3 = normString!(nfc, test.nfd); | ||
| let r4 = normString!(nfc, test.nfkc); | ||
| let r5 = normString!(nfc, test.nfkd); | ||
| assert_eq!(test.nfc, &r1[..]); | ||
| assert_eq!(test.nfc, &r2[..]); | ||
| assert_eq!(test.nfc, &r3[..]); | ||
| assert_eq!(test.nfkc, &r4[..]); | ||
| assert_eq!(test.nfkc, &r5[..]); | ||
| } | ||
| { | ||
| let r1 = normString!(nfd, test.source); | ||
| let r2 = normString!(nfd, test.nfc); | ||
| let r3 = normString!(nfd, test.nfd); | ||
| let r4 = normString!(nfd, test.nfkc); | ||
| let r5 = normString!(nfd, test.nfkd); | ||
| assert_eq!(test.nfd, &r1[..]); | ||
| assert_eq!(test.nfd, &r2[..]); | ||
| assert_eq!(test.nfd, &r3[..]); | ||
| assert_eq!(test.nfkd, &r4[..]); | ||
| assert_eq!(test.nfkd, &r5[..]); | ||
| } | ||
| { | ||
| let r1 = normString!(nfkc, test.source); | ||
| let r2 = normString!(nfkc, test.nfc); | ||
| let r3 = normString!(nfkc, test.nfd); | ||
| let r4 = normString!(nfkc, test.nfkc); | ||
| let r5 = normString!(nfkc, test.nfkd); | ||
| assert_eq!(test.nfkc, &r1[..]); | ||
| assert_eq!(test.nfkc, &r2[..]); | ||
| assert_eq!(test.nfkc, &r3[..]); | ||
| assert_eq!(test.nfkc, &r4[..]); | ||
| assert_eq!(test.nfkc, &r5[..]); | ||
| } | ||
| { | ||
| let r1 = normString!(nfkd, test.source); | ||
| let r2 = normString!(nfkd, test.nfc); | ||
| let r3 = normString!(nfkd, test.nfd); | ||
| let r4 = normString!(nfkd, test.nfkc); | ||
| let r5 = normString!(nfkd, test.nfkd); | ||
| assert_eq!(test.nfkd, &r1[..]); | ||
| assert_eq!(test.nfkd, &r2[..]); | ||
| assert_eq!(test.nfkd, &r3[..]); | ||
| assert_eq!(test.nfkd, &r4[..]); | ||
| assert_eq!(test.nfkd, &r5[..]); | ||
| } | ||
| } | ||
| } | ||
| #[test] | ||
| fn test_quick_check() { | ||
| use unicode_normalization::__test_api::quick_check; | ||
| for test in NORMALIZATION_TESTS { | ||
| assert!(quick_check::is_nfc(test.nfc)); | ||
| assert!(quick_check::is_nfd(test.nfd)); | ||
| assert!(quick_check::is_nfkc(test.nfkc)); | ||
| assert!(quick_check::is_nfkd(test.nfkd)); | ||
| if test.nfc != test.nfd { | ||
| assert!(!quick_check::is_nfc(test.nfd)); | ||
| assert!(!quick_check::is_nfd(test.nfc)); | ||
| } | ||
| if test.nfkc != test.nfc { | ||
| assert!(!quick_check::is_nfkc(test.nfc)); | ||
| assert!(quick_check::is_nfc(test.nfkc)); | ||
| } | ||
| if test.nfkd != test.nfd { | ||
| assert!(!quick_check::is_nfkd(test.nfd)); | ||
| assert!(quick_check::is_nfd(test.nfkd)); | ||
| } | ||
| } | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.