Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Attribute bytes start at 0x2 #915

Open
joshka opened this issue Aug 17, 2024 · 0 comments
Open

Attribute bytes start at 0x2 #915

joshka opened this issue Aug 17, 2024 · 0 comments

Comments

@joshka
Copy link
Collaborator

joshka commented Aug 17, 2024

Describe the bug
Just checking out how attributes were implemented and I noticed that Attribute::Reset.bytes() starts at 0x2 instead of 1. This seems like a possible off by 1 error (but I'm not 100% sure.

To Reproduce
Steps to reproduce the behavior:

    #[rstest]
    #[case(Attribute::Reset, 0x2)]
    #[case(Attribute::Bold, 0x4)]
    #[case(Attribute::Dim, 0x8)]
    #[case(Attribute::Italic, 0x10)]
    #[case(Attribute::Underlined, 0x20)]
    #[case(Attribute::DoubleUnderlined, 0x40)]
    #[case(Attribute::Undercurled, 0x80)]
    #[case(Attribute::Underdotted, 0x100)]
    #[case(Attribute::Underdashed, 0x200)]
    #[case(Attribute::SlowBlink, 0x400)]
    #[case(Attribute::RapidBlink, 0x800)]
    #[case(Attribute::Reverse, 0x1000)]
    #[case(Attribute::Hidden, 0x2000)]
    #[case(Attribute::CrossedOut, 0x4000)]
    #[case(Attribute::Fraktur, 0x8000)]
    #[case(Attribute::NoBold, 0x10000)]
    #[case(Attribute::NormalIntensity, 0x20000)]
    #[case(Attribute::NoItalic, 0x40000)]
    #[case(Attribute::NoUnderline, 0x80000)]
    #[case(Attribute::NoBlink, 0x100000)]
    #[case(Attribute::NoReverse, 0x200000)]
    #[case(Attribute::NoHidden, 0x400000)]
    #[case(Attribute::NotCrossedOut, 0x800000)]
    #[case(Attribute::Framed, 0x1000000)]
    #[case(Attribute::Encircled, 0x2000000)]
    #[case(Attribute::OverLined, 0x4000000)]
    #[case(Attribute::NotFramedOrEncircled, 0x8000000)]
    #[case(Attribute::NotOverLined, 0x10000000)]
    fn bytes(#[case] attribute: Attribute, #[case] expected: u32) {
        assert_eq!(attribute.bytes(), expected);
    }

Expected behavior
first bitfield should probably be 1

OS

  • e.g. MacOs, Windows, Linux, (version) etc...

Terminal/Console

  • e.g. ConHost/xterm/iterm2/Windows Terminal etc.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant