File: object_test.rs

package info (click to toggle)
rust-tabled 0.18.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,408 kB
  • sloc: makefile: 4
file content (52 lines) | stat: -rw-r--r-- 1,680 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#![cfg(feature = "std")]

use tabled::grid::config::Entity;
use tabled::settings::{
    object::{Columns, Object, ObjectIterator, Segment},
    Alignment, Style,
};

use crate::matrix::Matrix;
use testing_table::test_table;

// todo: Columns::all()

test_table!(
    skip,
    Matrix::new(3, 3).with(Style::psql()).modify(Columns::new(..).not(Columns::first()).skip(2), Alignment::right()),
    " N | column 0 | column 1 | column 2 "
    "---+----------+----------+----------"
    " 0 |   0-0    |      0-1 |      0-2 "
    " 1 |      1-0 |      1-1 |      1-2 "
    " 2 |      2-0 |      2-1 |      2-2 "
);

test_table!(
    skip_segment_all,
    Matrix::new(3, 3).with(Style::psql()).modify(Segment::all().skip(1), Alignment::right()),
    " N | column 0 | column 1 | column 2 "
    "---+----------+----------+----------"
    " 0 |   0-0    |   0-1    |   0-2    "
    " 1 |   1-0    |   1-1    |   1-2    "
    " 2 |   2-0    |   2-1    |   2-2    "
);

test_table!(
    step_by,
    Matrix::new(3, 3).with(Style::psql()).modify(Columns::new(..).step_by(3), Alignment::right()),
    " N | column 0 | column 1 | column 2 "
    "---+----------+----------+----------"
    " 0 |   0-0    |   0-1    |      0-2 "
    " 1 |   1-0    |   1-1    |      1-2 "
    " 2 |   2-0    |   2-1    |      2-2 "
);

test_table!(
    filter,
    Matrix::new(3, 3).with(Style::psql()).modify(Columns::new(..).filter(|e| matches!(e, Entity::Column(1 | 3))), Alignment::right()),
    " N | column 0 | column 1 | column 2 "
    "---+----------+----------+----------"
    " 0 |      0-0 |   0-1    |      0-2 "
    " 1 |      1-0 |   1-1    |      1-2 "
    " 2 |      2-0 |   2-1    |      2-2 "
);