diff --git a/tst/tst-args_cli.c b/tst/tst-args_cli.c index 7fce55b..d56e837 100644 --- a/tst/tst-args_cli.c +++ b/tst/tst-args_cli.c @@ -41,7 +41,7 @@ void args_parse_cli__valid(void **state) { "--ratio-master", "0.2", "--count-wide-left", "8", "--ratio-wide", "0.8", - "--smart-gaps", "off", + "--smart-gaps", "on", "--inner-gaps", "6", "--outer-gaps", "6", "--border-width", "5", @@ -61,7 +61,7 @@ void args_parse_cli__valid(void **state) { assert_float_equal(cfg->ratio_master, 0.2, 0.001); assert_int_equal(cfg->count_wide_left, 8); assert_float_equal(cfg->ratio_wide, 0.8, 0.001); - assert_false(cfg->smart_gaps); + assert_true(cfg->smart_gaps); assert_int_equal(cfg->inner_gaps, 6); assert_int_equal(cfg->outer_gaps, 6); assert_int_equal(cfg->border_width, 5); @@ -78,7 +78,7 @@ void args_parse_cli__valid(void **state) { "--ratio-master 0.2\n" "--count-wide-left 8\n" "--ratio-wide 0.8\n" - "--smart-gaps off\n" + "--smart-gaps on\n" "--inner-gaps 6\n" "--outer-gaps 6\n" "--border-width 5\n" @@ -181,6 +181,45 @@ void args_parse_cli__bad_ratio_wide(void **state) { assert_log(ERROR, "invalid --ratio-wide '-1'\n\n"); } +void args_parse_cli__bad_smart_gaps(void **state) { + int argc = 3; + char *argv[] = { "dummy", + "--smart-gaps", "enabled", + }; + + expect_value(__wrap_usage, status, EXIT_FAILURE); + + args_cli(argc, argv); + + assert_log(ERROR, "invalid --smart-gaps 'enabled'\n\n"); +} + +void args_parse_cli__bad_inner_gaps(void **state) { + int argc = 3; + char *argv[] = { "dummy", + "--inner-gaps", "-1", + }; + + expect_value(__wrap_usage, status, EXIT_FAILURE); + + args_cli(argc, argv); + + assert_log(ERROR, "invalid --inner-gaps '-1'\n\n"); +} + +void args_parse_cli__bad_outer_gaps(void **state) { + int argc = 3; + char *argv[] = { "dummy", + "--outer-gaps", "-1", + }; + + expect_value(__wrap_usage, status, EXIT_FAILURE); + + args_cli(argc, argv); + + assert_log(ERROR, "invalid --outer-gaps '-1'\n\n"); +} + void args_parse_cli__bad_border_width(void **state) { int argc = 3; char *argv[] = { "dummy", @@ -269,6 +308,9 @@ int main(void) { TEST(args_parse_cli__bad_ratio_master), TEST(args_parse_cli__bad_count_wide_left), TEST(args_parse_cli__bad_ratio_wide), + TEST(args_parse_cli__bad_smart_gaps), + TEST(args_parse_cli__bad_inner_gaps), + TEST(args_parse_cli__bad_outer_gaps), TEST(args_parse_cli__bad_border_width), TEST(args_parse_cli__bad_border_width_monocle), TEST(args_parse_cli__bad_border_color_focused), diff --git a/tst/tst-arrange_master_stack.c b/tst/tst-arrange_master_stack.c index d635db0..bbaaca1 100644 --- a/tst/tst-arrange_master_stack.c +++ b/tst/tst-arrange_master_stack.c @@ -2,6 +2,7 @@ #include "asserts.h" #include +#include #include "enum.h" #include "layout.h" @@ -64,6 +65,42 @@ void arrange_master_stack__zero_stack(void **state) { assert_box_equal(&stack, 0, 0, 0, 0); } +void arrange_master_stack__zero_master_with_gaps(void **state) { + struct Box master, stack; + + struct Demand demand = { .view_count = 1, .usable_width = 9, .usable_height = 5, }; + struct Tag tag = { .layout_cur = LEFT, .ratio_master = 0.5, + .smart_gaps = false, .inner_gaps = 1, .outer_gaps = 1, }; + struct Tag smart_tag = { .layout_cur = LEFT, .ratio_master = 0.5, + .smart_gaps = true, .inner_gaps = 1, .outer_gaps = 1, }; + + arrange_master_stack(&demand, &tag, 0, 1, &master, &stack); + assert_box_equal(&master, 0, 0, 0, 0); + assert_box_equal(&stack, 1, 1, 7, 3); + + arrange_master_stack(&demand, &smart_tag, 0, 1, &master, &stack); + assert_box_equal(&master, 0, 0, 0, 0); + assert_box_equal(&stack, 0, 0, 9, 5); +} + +void arrange_master_stack__zero_stack_with_gaps(void **state) { + struct Box master, stack; + + struct Demand demand = { .view_count = 1, .usable_width = 9, .usable_height = 5, }; + struct Tag tag = { .layout_cur = LEFT, .ratio_master = 0.5, + .smart_gaps = false, .inner_gaps = 1, .outer_gaps = 1, }; + struct Tag smart_tag = { .layout_cur = LEFT, .ratio_master = 0.5, + .smart_gaps = true, .inner_gaps = 1, .outer_gaps = 1, }; + + arrange_master_stack(&demand, &tag, 1, 0, &master, &stack); + assert_box_equal(&master, 1, 1, 7, 3); + assert_box_equal(&stack, 0, 0, 0, 0); + + arrange_master_stack(&demand, &smart_tag, 1, 0, &master, &stack); + assert_box_equal(&master, 0, 0, 9, 5); + assert_box_equal(&stack, 0, 0, 0, 0); +} + void arrange_master_stack__left(void **state) { struct Box master, stack; @@ -77,6 +114,18 @@ void arrange_master_stack__left(void **state) { assert_box_equal(&stack, 4, 0, 5, 5); } +void arrange_master_stack__left_with_gaps(void **state) { + struct Box master, stack; + + struct Demand demand = { .usable_width = 9, .usable_height = 5, }; + struct Tag tag = { .layout_cur = LEFT, .ratio_master = 0.4, + .inner_gaps = 1, .outer_gaps = 1, }; + + arrange_master_stack(&demand, &tag, 1, 1, &master, &stack); + assert_box_equal(&master, 1, 1, 2, 3); + assert_box_equal(&stack, 4, 1, 4, 3); +} + void arrange_master_stack__right(void **state) { struct Box master, stack; @@ -90,6 +139,18 @@ void arrange_master_stack__right(void **state) { assert_box_equal(&stack, 0, 0, 5, 5); } +void arrange_master_stack__right_with_gaps(void **state) { + struct Box master, stack; + + struct Demand demand = { .usable_width = 9, .usable_height = 5, }; + struct Tag tag = { .layout_cur = RIGHT, .ratio_master = 0.4, + .inner_gaps = 1, .outer_gaps = 1, }; + + arrange_master_stack(&demand, &tag, 1, 1, &master, &stack); + assert_box_equal(&master, 6, 1, 2, 3); + assert_box_equal(&stack, 1, 1, 4, 3); +} + void arrange_master_stack__top(void **state) { struct Box master, stack; @@ -103,6 +164,18 @@ void arrange_master_stack__top(void **state) { assert_box_equal(&stack, 0, 2, 9, 3); } +void arrange_master_stack__top_with_gaps(void **state) { + struct Box master, stack; + + struct Demand demand = { .usable_width = 9, .usable_height = 5, }; + struct Tag tag = { .layout_cur = TOP, .ratio_master = 0.3, + .inner_gaps = 1, .outer_gaps = 1, }; + + arrange_master_stack(&demand, &tag, 1, 1, &master, &stack); + assert_box_equal(&master, 1, 1, 7, 1); + assert_box_equal(&stack, 1, 3, 7, 1); +} + void arrange_master_stack__bottom(void **state) { struct Box master, stack; @@ -116,6 +189,18 @@ void arrange_master_stack__bottom(void **state) { assert_box_equal(&stack, 0, 0, 9, 3); } +void arrange_master_stack__bottom_with_gaps(void **state) { + struct Box master, stack; + + struct Demand demand = { .usable_width = 9, .usable_height = 5, }; + struct Tag tag = { .layout_cur = BOTTOM, .ratio_master = 0.3, + .inner_gaps = 1, .outer_gaps = 1, }; + + arrange_master_stack(&demand, &tag, 1, 1, &master, &stack); + assert_box_equal(&master, 1, 3, 7, 1); + assert_box_equal(&stack, 1, 1, 7, 1); +} + int main(void) { const struct CMUnitTest tests[] = { TEST(arrange_master_stack__zero), @@ -126,6 +211,14 @@ int main(void) { TEST(arrange_master_stack__right), TEST(arrange_master_stack__top), TEST(arrange_master_stack__bottom), + + TEST(arrange_master_stack__zero_master_with_gaps), + TEST(arrange_master_stack__zero_stack_with_gaps), + + TEST(arrange_master_stack__left_with_gaps), + TEST(arrange_master_stack__right_with_gaps), + TEST(arrange_master_stack__top_with_gaps), + TEST(arrange_master_stack__bottom_with_gaps), }; return RUN(tests); diff --git a/tst/tst-arrange_mid.c b/tst/tst-arrange_mid.c index 6f63204..b4b70a1 100644 --- a/tst/tst-arrange_mid.c +++ b/tst/tst-arrange_mid.c @@ -2,6 +2,7 @@ #include "asserts.h" #include +#include #include "layout.h" #include "tag.h" @@ -50,6 +51,26 @@ void arrange_wide__010(void **state) { assert_box_equal(&after, 0, 0, 0, 0); } +void arrange_wide__010_with_gaps(void **state) { + struct Box master, before, after; + + struct Demand demand = { .view_count = 1, .usable_width = 13, .usable_height = 5, }; + struct Tag tag = { .ratio_wide = 999, .smart_gaps = false, + .inner_gaps = 1, .outer_gaps = 1, }; + struct Tag smart_tag = { .ratio_wide = 999, .smart_gaps = true, + .inner_gaps = 1, .outer_gaps = 1, }; + + arrange_wide(&demand, &tag, 0, 1, 0, &before, &master, &after); + assert_box_equal(&before, 0, 0, 0, 0); + assert_box_equal(&master, 1, 1, 11, 3); + assert_box_equal(&after, 0, 0, 0, 0); + + arrange_wide(&demand, &smart_tag, 0, 1, 0, &before, &master, &after); + assert_box_equal(&before, 0, 0, 0, 0); + assert_box_equal(&master, 0, 0, 13, 5); + assert_box_equal(&after, 0, 0, 0, 0); +} + void arrange_wide__001(void **state) { struct Box master, before, after; @@ -63,6 +84,26 @@ void arrange_wide__001(void **state) { assert_box_equal(&after, 0, 0, 13, 5); } +void arrange_wide__001_with_gaps(void **state) { + struct Box master, before, after; + + struct Demand demand = { .view_count = 1, .usable_width = 13, .usable_height = 5, }; + struct Tag tag = { .ratio_wide = 999, .smart_gaps = false, + .inner_gaps = 1, .outer_gaps = 1, }; + struct Tag smart_tag = { .ratio_wide = 999, .smart_gaps = true, + .inner_gaps = 1, .outer_gaps = 1, }; + + arrange_wide(&demand, &tag, 0, 0, 1, &before, &master, &after); + assert_box_equal(&before, 0, 0, 0, 0); + assert_box_equal(&master, 0, 0, 0, 0); + assert_box_equal(&after, 1, 1, 11, 3); + + arrange_wide(&demand, &smart_tag, 0, 0, 1, &before, &master, &after); + assert_box_equal(&before, 0, 0, 0, 0); + assert_box_equal(&master, 0, 0, 0, 0); + assert_box_equal(&after, 0, 0, 13, 5); +} + void arrange_wide__100(void **state) { struct Box master, before, after; @@ -76,6 +117,26 @@ void arrange_wide__100(void **state) { assert_box_equal(&after, 0, 0, 0, 0); } +void arrange_wide__100_with_gaps(void **state) { + struct Box master, before, after; + + struct Demand demand = { .view_count = 1, .usable_width = 13, .usable_height = 5, }; + struct Tag tag = { .ratio_wide = 999, .smart_gaps = false, + .inner_gaps = 1, .outer_gaps = 1, }; + struct Tag smart_tag = { .ratio_wide = 999, .smart_gaps = true, + .inner_gaps = 1, .outer_gaps = 1, }; + + arrange_wide(&demand, &tag, 1, 0, 0, &before, &master, &after); + assert_box_equal(&before, 1, 1, 11, 3); + assert_box_equal(&master, 0, 0, 0, 0); + assert_box_equal(&after, 0, 0, 0, 0); + + arrange_wide(&demand, &smart_tag, 1, 0, 0, &before, &master, &after); + assert_box_equal(&before, 0, 0, 13, 5); + assert_box_equal(&master, 0, 0, 0, 0); + assert_box_equal(&after, 0, 0, 0, 0); +} + void arrange_wide__101(void **state) { struct Box master, before, after; @@ -89,6 +150,18 @@ void arrange_wide__101(void **state) { assert_box_equal(&after, 7, 0, 6, 5); } +void arrange_wide__101_with_gaps(void **state) { + struct Box master, before, after; + + struct Demand demand = { .usable_width = 13, .usable_height = 5, }; + struct Tag tag = { .ratio_wide = 999, .inner_gaps = 1, .outer_gaps = 1, }; + + arrange_wide(&demand, &tag, 1, 0, 1, &before, &master, &after); + assert_box_equal(&before, 1, 1, 5, 3); + assert_box_equal(&master, 0, 0, 0, 0); + assert_box_equal(&after, 7, 1, 5, 3); +} + void arrange_wide__011(void **state) { struct Box master, before, after; @@ -102,6 +175,18 @@ void arrange_wide__011(void **state) { assert_box_equal(&after, 8, 0, 5, 5); } +void arrange_wide__011_with_gaps(void **state) { + struct Box master, before, after; + + struct Demand demand = { .usable_width = 13, .usable_height = 5, }; + struct Tag tag = { .ratio_wide = 0.2, .inner_gaps = 1, .outer_gaps = 1, }; + + arrange_wide(&demand, &tag, 0, 1, 1, &before, &master, &after); + assert_box_equal(&before, 0, 0, 0, 0); + assert_box_equal(&master, 1, 1, 6, 3); + assert_box_equal(&after, 8, 1, 4, 3); +} + void arrange_wide__110(void **state) { struct Box master, before, after; @@ -115,6 +200,18 @@ void arrange_wide__110(void **state) { assert_box_equal(&after, 0, 0, 0, 0); } +void arrange_wide__110_with_gaps(void **state) { + struct Box master, before, after; + + struct Demand demand = { .usable_width = 13, .usable_height = 5, }; + struct Tag tag = { .ratio_wide = 0.7, .inner_gaps = 1, .outer_gaps = 1, }; + + arrange_wide(&demand, &tag, 1, 1, 0, &before, &master, &after); + assert_box_equal(&before, 1, 1, 1, 3); + assert_box_equal(&master, 3, 1, 9, 3); + assert_box_equal(&after, 0, 0, 0, 0); +} + void arrange_wide__111(void **state) { struct Box master, before, after; @@ -128,6 +225,18 @@ void arrange_wide__111(void **state) { assert_box_equal(&after, 10, 0, 3, 5); } +void arrange_wide__111_with_gaps(void **state) { + struct Box master, before, after; + + struct Demand demand = { .usable_width = 13, .usable_height = 5, }; + struct Tag tag = { .ratio_wide = 0.5, .inner_gaps = 1, .outer_gaps = 1, }; + + arrange_wide(&demand, &tag, 1, 1, 1, &before, &master, &after); + assert_box_equal(&before, 1, 1, 2, 3); + assert_box_equal(&master, 4, 1, 5, 3); + assert_box_equal(&after, 10, 1, 2, 3); +} + int main(void) { const struct CMUnitTest tests[] = { TEST(arrange_wide__000), @@ -142,6 +251,14 @@ int main(void) { TEST(arrange_wide__110), TEST(arrange_wide__111), + + TEST(arrange_wide__010_with_gaps), + TEST(arrange_wide__001_with_gaps), + TEST(arrange_wide__100_with_gaps), + TEST(arrange_wide__101_with_gaps), + TEST(arrange_wide__011_with_gaps), + TEST(arrange_wide__110_with_gaps), + TEST(arrange_wide__111_with_gaps), }; return RUN(tests); diff --git a/tst/tst-arrange_views.c b/tst/tst-arrange_views.c index d43731f..4730140 100644 --- a/tst/tst-arrange_views.c +++ b/tst/tst-arrange_views.c @@ -55,6 +55,24 @@ void arrange_views__n(void **state) { slist_free_vals(&stack, NULL); } +void arrange_views__n_with_gaps(void **state) { + struct SList *stack = NULL; + struct Demand demand = { 0 }; + struct Box usable = { 1, 2, 5, 11, }; + + arrange_views(&demand, EVEN, N, N, 2, 2, /*inner_gap=*/1, usable, usable, &stack); + assert_int_equal(slist_length(stack), 2); + assert_box_equal(slist_at(stack, 0), 1, 8, 5, 5); + assert_box_equal(slist_at(stack, 1), 1, 2, 5, 5); + slist_free_vals(&stack, NULL); + + arrange_views(&demand, EVEN, N, N, 2, 2, /*inner_gap=*/2, usable, usable, &stack); + assert_int_equal(slist_length(stack), 2); + assert_box_equal(slist_at(stack, 0), 1, 8, 5, 5); + assert_box_equal(slist_at(stack, 1), 1, 2, 5, 4); + slist_free_vals(&stack, NULL); +} + void arrange_views__s(void **state) { struct SList *stack = NULL; struct Demand demand = { 0 }; @@ -70,6 +88,24 @@ void arrange_views__s(void **state) { slist_free_vals(&stack, NULL); } +void arrange_views__s_with_gaps(void **state) { + struct SList *stack = NULL; + struct Demand demand = { 0 }; + struct Box usable = { 1, 2, 5, 11, }; + + arrange_views(&demand, EVEN, S, S, 2, 2, /*inner_gap=*/1, usable, usable, &stack); + assert_int_equal(slist_length(stack), 2); + assert_box_equal(slist_at(stack, 0), 1, 2, 5, 5); + assert_box_equal(slist_at(stack, 1), 1, 8, 5, 5); + slist_free_vals(&stack, NULL); + + arrange_views(&demand, EVEN, S, S, 2, 2, /*inner_gap=*/2, usable, usable, &stack); + assert_int_equal(slist_length(stack), 2); + assert_box_equal(slist_at(stack, 0), 1, 2, 5, 5); + assert_box_equal(slist_at(stack, 1), 1, 9, 5, 4); + slist_free_vals(&stack, NULL); +} + void arrange_views__e(void **state) { struct SList *stack = NULL; struct Demand demand = { 0 }; @@ -85,6 +121,24 @@ void arrange_views__e(void **state) { slist_free_vals(&stack, NULL); } +void arrange_views__e_with_gaps(void **state) { + struct SList *stack = NULL; + struct Demand demand = { 0 }; + struct Box usable = { 1, 2, 5, 11, }; + + arrange_views(&demand, EVEN, E, E, 2, 2, /*inner_gap=*/1, usable, usable, &stack); + assert_int_equal(slist_length(stack), 2); + assert_box_equal(slist_at(stack, 0), 1, 2, 2, 11); + assert_box_equal(slist_at(stack, 1), 4, 2, 2, 11); + slist_free_vals(&stack, NULL); + + arrange_views(&demand, EVEN, E, E, 2, 2, /*inner_gap=*/2, usable, usable, &stack); + assert_int_equal(slist_length(stack), 2); + assert_box_equal(slist_at(stack, 0), 1, 2, 2, 11); + assert_box_equal(slist_at(stack, 1), 5, 2, 1, 11); + slist_free_vals(&stack, NULL); +} + void arrange_views__w(void **state) { struct SList *stack = NULL; struct Demand demand = { 0 }; @@ -100,6 +154,24 @@ void arrange_views__w(void **state) { slist_free_vals(&stack, NULL); } +void arrange_views__w_with_gaps(void **state) { + struct SList *stack = NULL; + struct Demand demand = { 0 }; + struct Box usable = { 1, 2, 5, 11, }; + + arrange_views(&demand, EVEN, W, W, 2, 2, /*inner_gap=*/1, usable, usable, &stack); + assert_int_equal(slist_length(stack), 2); + assert_box_equal(slist_at(stack, 0), 4, 2, 2, 11); + assert_box_equal(slist_at(stack, 1), 1, 2, 2, 11); + slist_free_vals(&stack, NULL); + + arrange_views(&demand, EVEN, W, W, 2, 2, /*inner_gap=*/2, usable, usable, &stack); + assert_int_equal(slist_length(stack), 2); + assert_box_equal(slist_at(stack, 0), 4, 2, 2, 11); + assert_box_equal(slist_at(stack, 1), 1, 2, 1, 11); + slist_free_vals(&stack, NULL); +} + void arrange_views__even(void **state) { struct SList *stack = NULL; struct Demand demand = { 0 }; @@ -116,6 +188,26 @@ void arrange_views__even(void **state) { slist_free_vals(&stack, NULL); } +void arrange_views__even_with_gaps(void **state) { + struct SList *stack = NULL; + struct Demand demand = { 0 }; + struct Box usable = { 1, 2, 5, 11, }; + + arrange_views(&demand, EVEN, S, S, 3, 3, /*inner_gap=*/1, usable, usable, &stack); + assert_int_equal(slist_length(stack), 3); + assert_box_equal(slist_at(stack, 0), 1, 2, 5, 3); + assert_box_equal(slist_at(stack, 1), 1, 6, 5, 3); + assert_box_equal(slist_at(stack, 2), 1, 10, 5, 3); + slist_free_vals(&stack, NULL); + + arrange_views(&demand, EVEN, S, S, 3, 3, /*inner_gap=*/2, usable, usable, &stack); + assert_int_equal(slist_length(stack), 3); + assert_box_equal(slist_at(stack, 0), 1, 2, 5, 2); + assert_box_equal(slist_at(stack, 1), 1, 6, 5, 3); + assert_box_equal(slist_at(stack, 2), 1, 11, 5, 2); + slist_free_vals(&stack, NULL); +} + void arrange_views__diminish(void **state) { struct SList *stack = NULL; struct Demand demand = { 0 }; @@ -136,6 +228,34 @@ void arrange_views__diminish(void **state) { slist_free_vals(&stack, NULL); } +void arrange_views__diminish_with_gaps(void **state) { + struct SList *stack = NULL; + struct Demand demand = { 0 }; + struct Box usable = { 0, 0, 97, 1, }; + + arrange_views(&demand, DIMINISH, E, E, 7, 7, /*inner_gap=*/1, usable, usable, &stack); + assert_int_equal(slist_length(stack), 7); + assert_box_equal(slist_at(stack, 0), 0, 0, 23, 1); // 91 * 7/28 up + assert_box_equal(slist_at(stack, 1), 24, 0, 20, 1); // 91 * 6/28 up + assert_box_equal(slist_at(stack, 2), 45, 0, 16, 1); // 91 * 5/28 + assert_box_equal(slist_at(stack, 3), 62, 0, 13, 1); // 91 * 4/28 + assert_box_equal(slist_at(stack, 4), 76, 0, 10, 1); // 91 * 3/28 up + assert_box_equal(slist_at(stack, 5), 87, 0, 7, 1); // 91 * 2/28 up + assert_box_equal(slist_at(stack, 6), 95, 0, 2, 1); // 91 * 1/28 + slist_free_vals(&stack, NULL); + + arrange_views(&demand, DIMINISH, E, E, 7, 7, /*inner_gap=*/2, usable, usable, &stack); + assert_int_equal(slist_length(stack), 7); + assert_box_equal(slist_at(stack, 0), 0, 0, 21, 1); // 85 * 7/28 + assert_box_equal(slist_at(stack, 1), 23, 0, 18, 1); // 85 * 6/28 + assert_box_equal(slist_at(stack, 2), 43, 0, 15, 1); // 85 * 5/28 + assert_box_equal(slist_at(stack, 3), 60, 0, 12, 1); // 85 * 4/28 + assert_box_equal(slist_at(stack, 4), 74, 0, 9, 1); // 85 * 3/28 + assert_box_equal(slist_at(stack, 5), 85, 0, 6, 1); // 85 * 2/28 + assert_box_equal(slist_at(stack, 6), 93, 0, 4, 1); // 85 * 1/28 + slist_free_vals(&stack, NULL); +} + void arrange_views__dwindle(void **state) { struct SList *stack = NULL; struct Demand demand = { 0 }; @@ -157,6 +277,24 @@ void arrange_views__dwindle(void **state) { slist_free_vals(&stack, NULL); } +void arrange_views__dwindle_with_gaps(void **state) { + struct SList *stack = NULL; + struct Demand demand = { 0 }; + struct Box usable = { 100, 100, 37, 71, }; + + arrange_views(&demand, DWINDLE, S, E, 8, 8, /*inner_gap=*/1, usable, usable, &stack); + assert_int_equal(slist_length(stack), 8); + assert_box_equal(slist_at(stack, 0), 100, 100, 37, 35); + assert_box_equal(slist_at(stack, 1), 100, 136, 18, 35); + assert_box_equal(slist_at(stack, 2), 119, 136, 18, 17); + assert_box_equal(slist_at(stack, 3), 119, 154, 9, 17); + assert_box_equal(slist_at(stack, 4), 129, 154, 8, 8); + assert_box_equal(slist_at(stack, 5), 129, 163, 4, 8); + assert_box_equal(slist_at(stack, 6), 134, 163, 3, 4); + assert_box_equal(slist_at(stack, 7), 134, 168, 3, 3); + slist_free_vals(&stack, NULL); +} + int main(void) { const struct CMUnitTest tests[] = { TEST(arrange_views__one), @@ -165,12 +303,17 @@ int main(void) { TEST(arrange_views__s), TEST(arrange_views__e), TEST(arrange_views__w), - TEST(arrange_views__even), - TEST(arrange_views__diminish), - TEST(arrange_views__dwindle), + + TEST(arrange_views__n_with_gaps), + TEST(arrange_views__s_with_gaps), + TEST(arrange_views__e_with_gaps), + TEST(arrange_views__w_with_gaps), + TEST(arrange_views__even_with_gaps), + TEST(arrange_views__diminish_with_gaps), + TEST(arrange_views__dwindle_with_gaps), }; return RUN(tests);