From 0d447b8c8e9ab9235fa8e748073939eeb3d77837 Mon Sep 17 00:00:00 2001 From: Vlad Denisov Date: Wed, 15 Sep 2021 13:10:55 +0300 Subject: [PATCH] fix segmentLength #3 --- src/lesson2/task1/IfElse.kt | 2 +- test/lesson2/task1/Tests.kt | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/lesson2/task1/IfElse.kt b/src/lesson2/task1/IfElse.kt index f5c891253..e049b3e8c 100644 --- a/src/lesson2/task1/IfElse.kt +++ b/src/lesson2/task1/IfElse.kt @@ -171,7 +171,7 @@ fun segmentLength(a: Int, b: Int, c: Int, d: Int): Int { if (d >= b) { return b - a } - if (d < b && d > a) { + if (d < b && d >= a) { return d - a } } diff --git a/test/lesson2/task1/Tests.kt b/test/lesson2/task1/Tests.kt index 09b4d6f5f..27d752fb5 100644 --- a/test/lesson2/task1/Tests.kt +++ b/test/lesson2/task1/Tests.kt @@ -89,5 +89,6 @@ class Tests { assertEquals(1, segmentLength(3, 6, 1, 4)) assertEquals(4, segmentLength(1, 15, 10, 14)) assertEquals(0, segmentLength(0, 1, 1, 1)) + assertEquals(0, segmentLength(0, 1, 0, 0)) } } \ No newline at end of file