);
}
-#[test]
-fn borders() {
+fn d4(title: &str, borders: EnumMap<Border, BorderStyle>) -> PivotTable {
let a = Dimension::builder(
Axis3::X,
Group::builder("a")
.with(Group::builder("dg1").with("d1").with("d2"))
.with("d3"),
);
- let borders = EnumMap::from_fn(|border| match border {
- Border::Dimension(RowColBorder(HeadingRegion::Rows, Axis2::X))
- | Border::Dimension(RowColBorder(HeadingRegion::Columns, Axis2::Y)) => BorderStyle {
- stroke: Stroke::Solid,
- color: Color::BLUE,
- },
- _ => BorderStyle::none(),
- });
- let mut pivot_table = PivotTable::builder("Dimension Borders 1", &[a, b, c, d])
+ let mut pivot_table = PivotTable::builder(title, &[a, b, c, d])
.with_look(Arc::new(test_look().with_borders(borders)));
let mut i = 0;
for d in 0..3 {
}
}
}
- let pivot_table = pivot_table.build();
+ pivot_table.build()
+}
+
+#[test]
+fn dimension_borders_1() {
+ let pivot_table = d4(
+ "Dimension Borders 1",
+ EnumMap::from_fn(|border| match border {
+ Border::Dimension(RowColBorder(HeadingRegion::Rows, Axis2::X))
+ | Border::Dimension(RowColBorder(HeadingRegion::Columns, Axis2::Y)) => BorderStyle {
+ stroke: Stroke::Solid,
+ color: Color::BLUE,
+ },
+ _ => BorderStyle::none(),
+ }),
+ );
assert_rendering(
&pivot_table,
"\
c3 72│73 74│75│76 77│78│79 80
",
);
+}
- let mut pivot_table = pivot_table.with_title("Category Borders 1");
- pivot_table.look_mut().borders = EnumMap::from_fn(|border| match border {
- Border::Category(RowColBorder(HeadingRegion::Rows, Axis2::X))
- | Border::Category(RowColBorder(HeadingRegion::Columns, Axis2::Y)) => BorderStyle {
- stroke: Stroke::Dashed,
- color: Color::RED,
- },
- _ => BorderStyle::none(),
- });
+#[test]
+fn dimension_borders_2() {
+ let pivot_table = d4(
+ "Dimension Borders 2",
+ EnumMap::from_fn(|border| match border {
+ Border::Dimension(RowColBorder(HeadingRegion::Rows, Axis2::Y))
+ | Border::Dimension(RowColBorder(HeadingRegion::Columns, Axis2::X)) => BorderStyle {
+ stroke: Stroke::Solid,
+ color: Color::BLUE,
+ },
+ _ => BorderStyle::none(),
+ }),
+ );
+ assert_rendering(
+ &pivot_table,
+ "\
+Dimension Borders 2
+ b
+ bg1
+ b1 b2 b3
+ ╶──────────────────────────
+ a a a
+ ag1 ag1 ag1
+d c a1 a2 a3 a1 a2 a3 a1 a2 a3
+dg1 d1│ c1 0 1 2 3 4 5 6 7 8
+ │cg1 c2 9 10 11 12 13 14 15 16 17
+ │ c3 18 19 20 21 22 23 24 25 26
+ d2│ c1 27 28 29 30 31 32 33 34 35
+ │cg1 c2 36 37 38 39 40 41 42 43 44
+ │ c3 45 46 47 48 49 50 51 52 53
+ d3│ c1 54 55 56 57 58 59 60 61 62
+ │cg1 c2 63 64 65 66 67 68 69 70 71
+ │ c3 72 73 74 75 76 77 78 79 80
+",
+ );
+}
+
+#[test]
+fn category_borders_1() {
+ let pivot_table = d4(
+ "Category Borders 1",
+ EnumMap::from_fn(|border| match border {
+ Border::Category(RowColBorder(HeadingRegion::Rows, Axis2::X))
+ | Border::Category(RowColBorder(HeadingRegion::Columns, Axis2::Y)) => BorderStyle {
+ stroke: Stroke::Dashed,
+ color: Color::RED,
+ },
+ _ => BorderStyle::none(),
+ }),
+ );
assert_rendering(
&pivot_table,
"\
┊ ag1 ┊ ┊ ag1 ┊ ┊ ag1
d c a1┊a2┊a3┊a1┊a2┊a3┊a1┊a2┊a3
dg1 d1 c1 0┊ 1┊ 2┊ 3┊ 4┊ 5┊ 6┊ 7┊ 8
- â\95¶╌╌╌╌╌╌╌╌╌+╌╌+╌╌+╌╌+╌╌+╌╌+╌╌+╌╌+╌╌
+ â\95\8c╌╌╌╌╌╌╌╌╌+╌╌+╌╌+╌╌+╌╌+╌╌+╌╌+╌╌+╌╌
cg1 c2 9┊10┊11┊12┊13┊14┊15┊16┊17
- â\95¶╌╌╌╌╌+╌╌+╌╌+╌╌+╌╌+╌╌+╌╌+╌╌+╌╌
+ â\95\8c╌╌╌╌╌+╌╌+╌╌+╌╌+╌╌+╌╌+╌╌+╌╌+╌╌
c3 18┊19┊20┊21┊22┊23┊24┊25┊26
- â\95¶╌╌╌╌╌╌╌╌╌╌╌╌+╌╌+╌╌+╌╌+╌╌+╌╌+╌╌+╌╌+╌╌
+ â\95\8c╌╌╌╌╌╌╌╌╌╌╌╌+╌╌+╌╌+╌╌+╌╌+╌╌+╌╌+╌╌+╌╌
d2 c1 27┊28┊29┊30┊31┊32┊33┊34┊35
- â\95¶╌╌╌╌╌╌╌╌╌+╌╌+╌╌+╌╌+╌╌+╌╌+╌╌+╌╌+╌╌
+ â\95\8c╌╌╌╌╌╌╌╌╌+╌╌+╌╌+╌╌+╌╌+╌╌+╌╌+╌╌+╌╌
cg1 c2 36┊37┊38┊39┊40┊41┊42┊43┊44
- â\95¶╌╌╌╌╌+╌╌+╌╌+╌╌+╌╌+╌╌+╌╌+╌╌+╌╌
+ â\95\8c╌╌╌╌╌+╌╌+╌╌+╌╌+╌╌+╌╌+╌╌+╌╌+╌╌
c3 45┊46┊47┊48┊49┊50┊51┊52┊53
╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌+╌╌+╌╌+╌╌+╌╌+╌╌+╌╌+╌╌+╌╌
d3 c1 54┊55┊56┊57┊58┊59┊60┊61┊62
- â\95¶╌╌╌╌╌╌╌╌╌+╌╌+╌╌+╌╌+╌╌+╌╌+╌╌+╌╌+╌╌
+ â\95\8c╌╌╌╌╌╌╌╌╌+╌╌+╌╌+╌╌+╌╌+╌╌+╌╌+╌╌+╌╌
cg1 c2 63┊64┊65┊66┊67┊68┊69┊70┊71
- â\95¶╌╌╌╌╌+╌╌+╌╌+╌╌+╌╌+╌╌+╌╌+╌╌+╌╌
+ â\95\8c╌╌╌╌╌+╌╌+╌╌+╌╌+╌╌+╌╌+╌╌+╌╌+╌╌
c3 72┊73┊74┊75┊76┊77┊78┊79┊80
",
);
+}
- let mut pivot_table = pivot_table.with_title("Category and Dimension Borders 1");
- pivot_table.look_mut().borders = EnumMap::from_fn(|border| match border {
- Border::Dimension(RowColBorder(HeadingRegion::Rows, Axis2::X))
- | Border::Dimension(RowColBorder(HeadingRegion::Columns, Axis2::Y)) => BorderStyle {
- stroke: Stroke::Solid,
- color: Color::BLUE,
- },
- Border::Category(RowColBorder(HeadingRegion::Rows, Axis2::X))
- | Border::Category(RowColBorder(HeadingRegion::Columns, Axis2::Y)) => BorderStyle {
- stroke: Stroke::Dashed,
- color: Color::RED,
- },
- _ => BorderStyle::none(),
- });
+#[test]
+fn category_borders_2() {
+ let pivot_table = d4(
+ "Category Borders 2",
+ EnumMap::from_fn(|border| match border {
+ Border::Category(RowColBorder(HeadingRegion::Rows, Axis2::Y))
+ | Border::Category(RowColBorder(HeadingRegion::Columns, Axis2::X)) => BorderStyle {
+ stroke: Stroke::Dashed,
+ color: Color::RED,
+ },
+ _ => BorderStyle::none(),
+ }),
+ );
+ assert_rendering(
+ &pivot_table,
+ "\
+Category Borders 2
+ b
+ ╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌
+ bg1
+ ╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌
+ b1 b2 b3
+ ╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌
+ a a a
+ ╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌
+ ag1 ag1 ag1
+ ╌╌╌╌╌╌╌ ╌╌╌╌╌╌╌ ╌╌╌╌╌╌
+d c a1 a2 a3 a1 a2 a3 a1 a2 a3
+dg1┊d1┊ c1 0 1 2 3 4 5 6 7 8
+ ┊ ┊cg1┊c2 9 10 11 12 13 14 15 16 17
+ ┊ ┊ ┊c3 18 19 20 21 22 23 24 25 26
+ ┊d2┊ c1 27 28 29 30 31 32 33 34 35
+ ┊ ┊cg1┊c2 36 37 38 39 40 41 42 43 44
+ ┊ ┊ ┊c3 45 46 47 48 49 50 51 52 53
+ d3┊ c1 54 55 56 57 58 59 60 61 62
+ ┊cg1┊c2 63 64 65 66 67 68 69 70 71
+ ┊ ┊c3 72 73 74 75 76 77 78 79 80
+",
+ );
+}
+
+#[test]
+fn category_and_dimension_borders_1() {
+ let pivot_table = d4(
+ "Category and Dimension Borders 1",
+ EnumMap::from_fn(|border| match border {
+ Border::Dimension(RowColBorder(HeadingRegion::Rows, Axis2::X))
+ | Border::Dimension(RowColBorder(HeadingRegion::Columns, Axis2::Y)) => BorderStyle {
+ stroke: Stroke::Solid,
+ color: Color::BLUE,
+ },
+ Border::Category(RowColBorder(HeadingRegion::Rows, Axis2::X))
+ | Border::Category(RowColBorder(HeadingRegion::Columns, Axis2::Y)) => BorderStyle {
+ stroke: Stroke::Dashed,
+ color: Color::RED,
+ },
+ _ => BorderStyle::none(),
+ }),
+ );
assert_rendering(
&pivot_table,
"\
dg1 d1 c1 0│ 1┊ 2│ 3│ 4┊ 5│ 6│ 7┊ 8
╶─────────┼──┼──┼──┼──┼──┼──┼──┼──
cg1 c2 9│10┊11│12│13┊14│15│16┊17
- â\95¶╌╌╌╌╌┼╌╌+╌╌┼╌╌┼╌╌+╌╌┼╌╌┼╌╌+╌╌
+ â\95\8c╌╌╌╌╌┼╌╌+╌╌┼╌╌┼╌╌+╌╌┼╌╌┼╌╌+╌╌
c3 18│19┊20│21│22┊23│24│25┊26
╶────────────┼──┼──┼──┼──┼──┼──┼──┼──
d2 c1 27│28┊29│30│31┊32│33│34┊35
╶─────────┼──┼──┼──┼──┼──┼──┼──┼──
cg1 c2 36│37┊38│39│40┊41│42│43┊44
- â\95¶╌╌╌╌╌┼╌╌+╌╌┼╌╌┼╌╌+╌╌┼╌╌┼╌╌+╌╌
+ â\95\8c╌╌╌╌╌┼╌╌+╌╌┼╌╌┼╌╌+╌╌┼╌╌┼╌╌+╌╌
c3 45│46┊47│48│49┊50│51│52┊53
────────────────┼──┼──┼──┼──┼──┼──┼──┼──
d3 c1 54│55┊56│57│58┊59│60│61┊62
╶─────────┼──┼──┼──┼──┼──┼──┼──┼──
cg1 c2 63│64┊65│66│67┊68│69│70┊71
- â\95¶╌╌╌╌╌┼╌╌+╌╌┼╌╌┼╌╌+╌╌┼╌╌┼╌╌+╌╌
+ â\95\8c╌╌╌╌╌┼╌╌+╌╌┼╌╌┼╌╌+╌╌┼╌╌┼╌╌+╌╌
c3 72│73┊74│75│76┊77│78│79┊80
",
);
}
+
+#[test]
+fn category_and_dimension_borders_2() {
+ let pivot_table = d4(
+ "Category and Dimension Borders 2",
+ EnumMap::from_fn(|border| match border {
+ Border::Dimension(RowColBorder(HeadingRegion::Rows, Axis2::Y))
+ | Border::Dimension(RowColBorder(HeadingRegion::Columns, Axis2::X)) => BorderStyle {
+ stroke: Stroke::Solid,
+ color: Color::BLUE,
+ },
+ Border::Category(RowColBorder(HeadingRegion::Rows, Axis2::Y))
+ | Border::Category(RowColBorder(HeadingRegion::Columns, Axis2::X)) => BorderStyle {
+ stroke: Stroke::Dashed,
+ color: Color::RED,
+ },
+ _ => BorderStyle::none(),
+ }),
+ );
+ assert_rendering(
+ &pivot_table,
+ "\
+Category and Dimension Borders 2
+ b
+ ╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌
+ bg1
+ ╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌
+ b1 b2 b3
+ ╶──────────────────────────
+ a a a
+ ╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌
+ ag1 ag1 ag1
+ ╌╌╌╌╌╌╌ ╌╌╌╌╌╌╌ ╌╌╌╌╌╌
+d c a1 a2 a3 a1 a2 a3 a1 a2 a3
+dg1┊d1│ c1 0 1 2 3 4 5 6 7 8
+ ┊ │cg1┊c2 9 10 11 12 13 14 15 16 17
+ ┊ │ ┊c3 18 19 20 21 22 23 24 25 26
+ ┊d2│ c1 27 28 29 30 31 32 33 34 35
+ ┊ │cg1┊c2 36 37 38 39 40 41 42 43 44
+ ┊ │ ┊c3 45 46 47 48 49 50 51 52 53
+ d3│ c1 54 55 56 57 58 59 60 61 62
+ │cg1┊c2 63 64 65 66 67 68 69 70 71
+ │ ┊c3 72 73 74 75 76 77 78 79 80
+",
+ );
+}
let d = Line::Dashed;
use Line::{Double as D, Single as S};
unicode_box.put(n, n, n, [' ', '╵', '╵', '║']);
- unicode_box.put(n, n, d, ['â\95´', '╯', '╯', '╜']);
+ unicode_box.put(n, n, d, ['â\95\8c', '╯', '╯', '╜']);
unicode_box.put(n, n, S, ['╴', '╯', '╯', '╜']);
unicode_box.put(n, n, D, ['═', '╛', '╛', '╝']);
unicode_box.put(n, S, n, ['╷', '│', '│', '║']);
unicode_box.put(n, D, d, ['╖', '╢', '╢', '╢']);
unicode_box.put(n, D, S, ['╖', '╢', '╢', '╢']);
unicode_box.put(n, D, D, ['╗', '╣', '╣', '╣']);
- unicode_box.put(d, n, n, ['â\95¶', '╰', '╰', '╙']);
+ unicode_box.put(d, n, n, ['â\95\8c', '╰', '╰', '╙']);
unicode_box.put(d, n, d, ['╌', '┴', '┴', '╨']);
unicode_box.put(d, n, S, ['─', '┴', '┴', '╨']);
unicode_box.put(d, n, D, ['═', '╧', '╧', '╩']);