From: Pasi Kallinen Date: Mon, 14 Mar 2022 17:06:07 +0000 (+0200) Subject: Add test for selection subtraction X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b271826147424602fb751c9836ee994cc651d30f;p=nethack Add test for selection subtraction --- diff --git a/test/test_sel.lua b/test/test_sel.lua index 6ad7d04a4..a6a3295b5 100644 --- a/test/test_sel.lua +++ b/test/test_sel.lua @@ -222,6 +222,29 @@ function test_sel_logical_xor() sel_has_n_points(selr, 2, __func__); end -- test_sel_logical_xor +function test_sel_subtraction() + local __func__ = "test_sel_subtraction"; + local sela = selection.new(); + local selb = selection.new(); + + sela:set(5,5); + sela:set(6,5); + sela:set(5,6); + sela:set(6,6); + + selb:set(5,5); + selb:set(6,6); + + local selr = sela - selb; + + sel_pt_ne(selr, 5,5, 0, __func__); + sel_pt_ne(selr, 6,5, 1, __func__); + sel_pt_ne(selr, 5,6, 1, __func__); + sel_pt_ne(selr, 6,6, 0, __func__); + + sel_has_n_points(selr, 2, __func__); +end -- test_sel_subtraction + function test_sel_filter_percent() local __func__ = "test_sel_filter_percent"; local sela = selection.negate(); @@ -448,6 +471,8 @@ test_sel_negate(); test_sel_logical_and(); test_sel_logical_or(); test_sel_logical_xor(); +-- addition operator is the same as logical or +test_sel_subtraction(); test_sel_filter_percent(); test_sel_line(); test_sel_rect();