Skip to content
This repository has been archived by the owner on Oct 7, 2024. It is now read-only.

Wrong converting to class case #76

Open
WaffleLapkin opened this issue Dec 7, 2019 · 2 comments
Open

Wrong converting to class case #76

WaffleLapkin opened this issue Dec 7, 2019 · 2 comments

Comments

@WaffleLapkin
Copy link

This code:

assert_eq!(
    inflector::cases::classcase::to_class_case("editMessageMedia"), 
    "EditMessageMedia"
);

Fails with this error:

thread 'main' panicked at 'assertion failed: `(left == right)`
  left: `"EditMessageMedum"`,
 right: `"EditMessageMedia"`', src/main.rs:228:5
@hgomersall
Copy link

This happens on i or t in the second last position or s in the last position (when the second last is not s:

use inflector::Inflector;

fn main() {

    for b_last_letter in b'a'..=b'z' {
        let last_letter = b_last_letter as char;

        for b_mid_letter in b'a'..=b'z' {
            let mid_letter = b_mid_letter as char;
            let class_case_string =
                format!("a{}{}", mid_letter, last_letter).to_class_case();

            if class_case_string != format!("A{}{}", mid_letter, last_letter) {
                println!("a{}{} => {}", 
                    mid_letter, last_letter, class_case_string);
            }
        }
    }
}

outputs:

aia => Aum
ata => Aum
aas => Aa
abs => Ab
acs => Ac
ads => Ad
aes => Ae
afs => Af
ags => Ag
ahs => Ah
ais => Ai
ajs => Aj
aks => Ak
als => Al
ams => Am
ans => An
aos => Ao
aps => Ap
aqs => Aq
ars => Ar
ats => At
aus => Au
avs => Av
aws => Aw
axs => Ax
ays => Ay
azs => Az

@hgomersall
Copy link

The problem is the final to_singular().

This seems like the wrong behaviour to me...

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants