create ordered sequence of the given ranges' start and end values

This commit is contained in:
2026-01-10 17:19:28 -06:00
parent 2f654bc1e2
commit 725906c2e8
2 changed files with 45 additions and 1 deletions

View File

@@ -17,6 +17,8 @@
start)
(end [_this]
end)
(range-type [_this]
:int-range-inclusive)
Object
(toString [_this]
@@ -51,3 +53,21 @@
(is (= 1 (range/start (int-range-inclusive 1 8)))))
(testing "end"
(is (= 8 (range/end (int-range-inclusive 1 8))))))
(deftest ordered-range-values
(testing "ordered range values are sorted by value and then the range's start boundary before any end boundary"
(is (= [{:value 4 :boundary-type :start :type :int-range-inclusive}
{:value 5 :boundary-type :start :type :int-range-inclusive}
{:value 5 :boundary-type :start :type :int-range-inclusive}
{:value 5 :boundary-type :end :type :int-range-inclusive}
{:value 5 :boundary-type :end :type :int-range-inclusive}
{:value 8 :boundary-type :end :type :int-range-inclusive}]
(#'range/ordered-range-values [(int-range-inclusive 4 5)
(int-range-inclusive 5 8)
(int-range-inclusive 5 5)])))
(is (= [{:value 5 :boundary-type :start :type :int-range-inclusive}
{:value 5 :boundary-type :start :type :int-range-inclusive}
{:value 5 :boundary-type :end :type :int-range-inclusive}
{:value 5 :boundary-type :end :type :int-range-inclusive}]
(#'range/ordered-range-values [(int-range-inclusive 5 5)
(int-range-inclusive 5 5)])))))