varunsrin / rusty_money

Money library for Rust
MIT License
85 stars 32 forks source link

to_string() returns different values according to the fact that we use from_minor or from_major #105

Open AlexandreRoba opened 7 months ago

AlexandreRoba commented 7 months ago

Hi, Thanks for this great library. Amazing job. I'm having trouble to print numbers. It'm getting different display depending on the constructor I used. Not sure it is intended...

 #[test]
    fn test_to_string_formatter() {
        let sut = rusty_money::Money::from_minor(10000, rusty_money::iso::EUR);
        let actual = format!("{}", sut);
        assert_eq!("€100,00", actual)
    } // pass

    #[test]
    fn test_to_string_formatter_from_major() {
        let sut = rusty_money::Money::from_major(100, rusty_money::iso::EUR);
        //let sut = Money::from_major(100);
        let actual = format!("{}", sut);
        assert_eq!("€100,00", actual)
    } //fails with   left: "€100.00". right: "€100"

Any idea how to prevent this?