| 1 | use comfy_tablerust-analyzer cargo comfy-table 7.2.2 crate/::{presetsrust-analyzer cargo comfy-table 7.2.2 style/presets/::UTF8_FULLrust-analyzer cargo comfy-table 7.2.2 style/presets/UTF8_FULL., *}; |
| 2 | use pretty_assertionsrust-analyzer cargo pretty_assertions 1.4.1 crate/::assert_eqrust-analyzer cargo pretty_assertions 1.4.1 assert_eq!; |
| 3 | |
| 4 | fn get_preset_tablerust-analyzer cargo comfy-table 7.2.2 all/styling_test/get_preset_table().() -> Tablerust-analyzer cargo comfy-table 7.2.2 table/Table# { |
| 5 | let mut table = Tablerust-analyzer cargo comfy-table 7.2.2 table/Table#::newrust-analyzer cargo comfy-table 7.2.2 table/impl#[Table]new().(); |
| 6 | table |
| 7 | .load_presetrust-analyzer cargo comfy-table 7.2.2 table/impl#[Table]load_preset().(UTF8_FULLrust-analyzer cargo comfy-table 7.2.2 style/presets/UTF8_FULL.) |
| 8 | .set_headerrust-analyzer cargo comfy-table 7.2.2 table/impl#[Table]set_header().(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![ |
| 9 | Cellrust-analyzer cargo comfy-table 7.2.2 cell/Cell#::newrust-analyzer cargo comfy-table 7.2.2 cell/impl#[Cell]new().("Header1").add_attributerust-analyzer cargo comfy-table 7.2.2 cell/impl#[Cell]add_attribute().(Attributerust-analyzer cargo crossterm 0.29.0 style/types/attribute/Attribute#::Boldrust-analyzer cargo crossterm 0.29.0 style/types/attribute/Attribute#Bold#), |
| 10 | Cellrust-analyzer cargo comfy-table 7.2.2 cell/Cell#::newrust-analyzer cargo comfy-table 7.2.2 cell/impl#[Cell]new().("Header2").fgrust-analyzer cargo comfy-table 7.2.2 cell/impl#[Cell]fg().(Colorrust-analyzer cargo crossterm 0.29.0 style/types/color/Color#::Greenrust-analyzer cargo crossterm 0.29.0 style/types/color/Color#Green#), |
| 11 | Cellrust-analyzer cargo comfy-table 7.2.2 cell/Cell#::newrust-analyzer cargo comfy-table 7.2.2 cell/impl#[Cell]new().("Header3").bgrust-analyzer cargo comfy-table 7.2.2 cell/impl#[Cell]bg().(Colorrust-analyzer cargo crossterm 0.29.0 style/types/color/Color#::Blackrust-analyzer cargo crossterm 0.29.0 style/types/color/Color#Black#), |
| 12 | ]) |
| 13 | .add_rowrust-analyzer cargo comfy-table 7.2.2 table/impl#[Table]add_row().(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![ |
| 14 | Cellrust-analyzer cargo comfy-table 7.2.2 cell/Cell#::newrust-analyzer cargo comfy-table 7.2.2 cell/impl#[Cell]new().("This is a bold text").add_attributerust-analyzer cargo comfy-table 7.2.2 cell/impl#[Cell]add_attribute().(Attributerust-analyzer cargo crossterm 0.29.0 style/types/attribute/Attribute#::Boldrust-analyzer cargo crossterm 0.29.0 style/types/attribute/Attribute#Bold#), |
| 15 | Cellrust-analyzer cargo comfy-table 7.2.2 cell/Cell#::newrust-analyzer cargo comfy-table 7.2.2 cell/impl#[Cell]new().("This is a green text").fgrust-analyzer cargo comfy-table 7.2.2 cell/impl#[Cell]fg().(Colorrust-analyzer cargo crossterm 0.29.0 style/types/color/Color#::Greenrust-analyzer cargo crossterm 0.29.0 style/types/color/Color#Green#), |
| 16 | Cellrust-analyzer cargo comfy-table 7.2.2 cell/Cell#::newrust-analyzer cargo comfy-table 7.2.2 cell/impl#[Cell]new().("This one has black background").bgrust-analyzer cargo comfy-table 7.2.2 cell/impl#[Cell]bg().(Colorrust-analyzer cargo crossterm 0.29.0 style/types/color/Color#::Blackrust-analyzer cargo crossterm 0.29.0 style/types/color/Color#Black#), |
| 17 | ]) |
| 18 | .add_rowrust-analyzer cargo comfy-table 7.2.2 table/impl#[Table]add_row().(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![ |
| 19 | Cellrust-analyzer cargo comfy-table 7.2.2 cell/Cell#::newrust-analyzer cargo comfy-table 7.2.2 cell/impl#[Cell]new().("Blinking boiii").add_attributerust-analyzer cargo comfy-table 7.2.2 cell/impl#[Cell]add_attribute().(Attributerust-analyzer cargo crossterm 0.29.0 style/types/attribute/Attribute#::SlowBlinkrust-analyzer cargo crossterm 0.29.0 style/types/attribute/Attribute#SlowBlink#), |
| 20 | Cellrust-analyzer cargo comfy-table 7.2.2 cell/Cell#::newrust-analyzer cargo comfy-table 7.2.2 cell/impl#[Cell]new().("Now\nadd some\nmulti line stuff") |
| 21 | .fgrust-analyzer cargo comfy-table 7.2.2 cell/impl#[Cell]fg().(Colorrust-analyzer cargo crossterm 0.29.0 style/types/color/Color#::Cyanrust-analyzer cargo crossterm 0.29.0 style/types/color/Color#Cyan#) |
| 22 | .add_attributerust-analyzer cargo comfy-table 7.2.2 cell/impl#[Cell]add_attribute().(Attributerust-analyzer cargo crossterm 0.29.0 style/types/attribute/Attribute#::Underlinedrust-analyzer cargo crossterm 0.29.0 style/types/attribute/Attribute#Underlined#), |
| 23 | Cellrust-analyzer cargo comfy-table 7.2.2 cell/Cell#::newrust-analyzer cargo comfy-table 7.2.2 cell/impl#[Cell]new().("COMBINE ALL THE THINGS") |
| 24 | .fgrust-analyzer cargo comfy-table 7.2.2 cell/impl#[Cell]fg().(Colorrust-analyzer cargo crossterm 0.29.0 style/types/color/Color#::Greenrust-analyzer cargo crossterm 0.29.0 style/types/color/Color#Green#) |
| 25 | .bgrust-analyzer cargo comfy-table 7.2.2 cell/impl#[Cell]bg().(Colorrust-analyzer cargo crossterm 0.29.0 style/types/color/Color#::Blackrust-analyzer cargo crossterm 0.29.0 style/types/color/Color#Black#) |
| 26 | .add_attributerust-analyzer cargo comfy-table 7.2.2 cell/impl#[Cell]add_attribute().(Attributerust-analyzer cargo crossterm 0.29.0 style/types/attribute/Attribute#::Boldrust-analyzer cargo crossterm 0.29.0 style/types/attribute/Attribute#Bold#) |
| 27 | .add_attributerust-analyzer cargo comfy-table 7.2.2 cell/impl#[Cell]add_attribute().(Attributerust-analyzer cargo crossterm 0.29.0 style/types/attribute/Attribute#::SlowBlinkrust-analyzer cargo crossterm 0.29.0 style/types/attribute/Attribute#SlowBlink#), |
| 28 | ]); |
| 29 | |
| 30 | table |
| 31 | } |
| 32 | |
| 33 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 34 | fn styled_tablerust-analyzer cargo comfy-table 7.2.2 all/styling_test/styled_table().() { |
| 35 | let mut table = get_preset_tablerust-analyzer cargo comfy-table 7.2.2 all/styling_test/get_preset_table().(); |
| 36 | table.force_no_ttyrust-analyzer cargo comfy-table 7.2.2 table/impl#[Table]force_no_tty().().enforce_stylingrust-analyzer cargo comfy-table 7.2.2 table/impl#[Table]enforce_styling().(); |
| 37 | printlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/println!!("{table}"); |
| 38 | let expected = " |
| 39 | ┌─────────────────────┬──────────────────────┬───────────────────────────────┐ |
| 40 | │\u{1b}[1m Header1 \u{1b}[0m┆\u{1b}[38;5;10m Header2 \u{1b}[39m┆\u{1b}[48;5;0m Header3 \u{1b}[49m│ |
| 41 | ╞═════════════════════╪══════════════════════╪═══════════════════════════════╡ |
| 42 | │\u{1b}[1m This is a bold text \u{1b}[0m┆\u{1b}[38;5;10m This is a green text \u{1b}[39m┆\u{1b}[48;5;0m This one has black background \u{1b}[49m│ |
| 43 | ├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤ |
| 44 | │\u{1b}[5m Blinking boiii \u{1b}[0m┆\u{1b}[38;5;14m\u{1b}[4m Now \u{1b}[0m┆\u{1b}[48;5;0m\u{1b}[38;5;10m\u{1b}[1m\u{1b}[5m COMBINE ALL THE THINGS \u{1b}[0m│ |
| 45 | │ ┆\u{1b}[38;5;14m\u{1b}[4m add some \u{1b}[0m┆ │ |
| 46 | │ ┆\u{1b}[38;5;14m\u{1b}[4m multi line stuff \u{1b}[0m┆ │ |
| 47 | └─────────────────────┴──────────────────────┴───────────────────────────────┘"; |
| 48 | assert_eqrust-analyzer cargo pretty_assertions 1.4.1 assert_eq!!(expected, "\n".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().() +rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add(). &table.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()); |
| 49 | } |
| 50 | |
| 51 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 52 | fn no_style_styled_tablerust-analyzer cargo comfy-table 7.2.2 all/styling_test/no_style_styled_table().() { |
| 53 | let mut table = get_preset_tablerust-analyzer cargo comfy-table 7.2.2 all/styling_test/get_preset_table().(); |
| 54 | table.force_no_ttyrust-analyzer cargo comfy-table 7.2.2 table/impl#[Table]force_no_tty().(); |
| 55 | |
| 56 | printlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/println!!("{table}"); |
| 57 | let expected = " |
| 58 | ┌─────────────────────┬──────────────────────┬───────────────────────────────┐ |
| 59 | │ Header1 ┆ Header2 ┆ Header3 │ |
| 60 | ╞═════════════════════╪══════════════════════╪═══════════════════════════════╡ |
| 61 | │ This is a bold text ┆ This is a green text ┆ This one has black background │ |
| 62 | ├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤ |
| 63 | │ Blinking boiii ┆ Now ┆ COMBINE ALL THE THINGS │ |
| 64 | │ ┆ add some ┆ │ |
| 65 | │ ┆ multi line stuff ┆ │ |
| 66 | └─────────────────────┴──────────────────────┴───────────────────────────────┘"; |
| 67 | assert_eqrust-analyzer cargo pretty_assertions 1.4.1 assert_eq!!(expected, "\n".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().() +rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add(). &table.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()); |
| 68 | } |
| 69 | |
| 70 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 71 | fn styled_text_only_tablerust-analyzer cargo comfy-table 7.2.2 all/styling_test/styled_text_only_table().() { |
| 72 | let mut table = get_preset_tablerust-analyzer cargo comfy-table 7.2.2 all/styling_test/get_preset_table().(); |
| 73 | table.force_no_ttyrust-analyzer cargo comfy-table 7.2.2 table/impl#[Table]force_no_tty().().enforce_stylingrust-analyzer cargo comfy-table 7.2.2 table/impl#[Table]enforce_styling().().style_text_onlyrust-analyzer cargo comfy-table 7.2.2 table/impl#[Table]style_text_only().(); |
| 74 | printlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/println!!("{table}"); |
| 75 | let expected = " |
| 76 | ┌─────────────────────┬──────────────────────┬───────────────────────────────┐ |
| 77 | │ \u{1b}[1mHeader1\u{1b}[0m ┆ \u{1b}[38;5;10mHeader2\u{1b}[39m ┆ \u{1b}[48;5;0mHeader3\u{1b}[49m │ |
| 78 | ╞═════════════════════╪══════════════════════╪═══════════════════════════════╡ |
| 79 | │ \u{1b}[1mThis is a bold text\u{1b}[0m ┆ \u{1b}[38;5;10mThis is a green text\u{1b}[39m ┆ \u{1b}[48;5;0mThis one has black background\u{1b}[49m │ |
| 80 | ├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤ |
| 81 | │ \u{1b}[5mBlinking boiii\u{1b}[0m ┆ \u{1b}[38;5;14m\u{1b}[4mNow\u{1b}[0m ┆ \u{1b}[48;5;0m\u{1b}[38;5;10m\u{1b}[1m\u{1b}[5mCOMBINE ALL THE THINGS\u{1b}[0m │ |
| 82 | │ ┆ \u{1b}[38;5;14m\u{1b}[4madd some\u{1b}[0m ┆ │ |
| 83 | │ ┆ \u{1b}[38;5;14m\u{1b}[4mmulti line stuff\u{1b}[0m ┆ │ |
| 84 | └─────────────────────┴──────────────────────┴───────────────────────────────┘"; |
| 85 | |
| 86 | assert_eqrust-analyzer cargo pretty_assertions 1.4.1 assert_eq!!(expected, "\n".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().() +rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add(). &table.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()); |
| 87 | } |