Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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
Manishearth merged 4 commits intounicode-rs:masterfromkentfredric:attempt-4
Nov 22, 2019
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions.travis.yml
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,6 +7,9 @@ sudo: false
script:
- cargo build --verbose
- cargo test --verbose
- cargo package
- cd target/package/unicode-normalization-*
- cargo test --verbose
notifications:
email:
on_success: never
2 changes: 1 addition & 1 deletionCargo.toml
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -18,7 +18,7 @@ Decomposition and Recomposition, as described in
Unicode Standard Annex #15.
"""

exclude = [ "target/*", "Cargo.lock", "scripts/tmp", "*.txt", "src/normalization_tests.rs", "src/test.rs" ]
exclude = [ "target/*", "Cargo.lock", "scripts/tmp", "*.txt", "tests/*" ]

[dependencies]
smallvec = "0.6"
13 changes: 13 additions & 0 deletionssrc/__test_api.rs
View file
Open in desktop
Original file line numberDiff line numberDiff 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
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -75,8 +75,8 @@ mod tables;

#[cfg(test)]
mod test;
#[cfg(test)]
modnormalization_tests;
#[doc(hidden)]
pubmod__test_api;

/// Methods for composing and decomposing characters.
pub mod char {
Expand Down
10 changes: 0 additions & 10 deletionssrc/stream_safe.rs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -111,23 +111,13 @@ mod tests {
classify_nonstarters,
};
use std::char;
use normalization_tests::NORMALIZATION_TESTS;
use normalize::decompose_compatible;
use lookups::canonical_combining_class;

fn stream_safe(s: &str) -> String {
StreamSafe::new(s.chars()).collect()
}

#[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_simple() {
let technically_okay = "Da\u{0300}\u{0301}\u{0302}\u{0303}\u{0304}\u{0305}\u{0306}\u{0307}\u{0308}\u{0309}\u{030a}\u{030b}\u{030c}\u{030d}\u{030e}\u{030f}\u{0310}\u{0311}\u{0312}\u{0313}\u{0314}\u{0315}\u{0316}\u{0317}\u{0318}\u{0319}\u{031a}\u{031b}\u{031c}\u{031d}ngerzone";
Expand Down
88 changes: 0 additions & 88 deletionssrc/test.rs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -95,94 +95,6 @@ fn test_nfkc() {
t!("a\u{300}\u{305}\u{315}\u{5ae}b", "\u{e0}\u{5ae}\u{305}\u{315}b");
}

#[test]
fn test_official() {
use normalization_tests::NORMALIZATION_TESTS;
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 normalization_tests::NORMALIZATION_TESTS;
use 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));
}
}
}

#[test]
fn test_is_combining_mark_ascii() {
for cp in 0..0x7f {
Expand Down
File renamed without changes.
105 changes: 105 additions & 0 deletionstests/tests.rs
View file
Open in desktop
Original file line numberDiff line numberDiff 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));
}
}
}

[8]ページ先頭

©2009-2025 Movatter.jp