From 83da9028e6df1d3a794677191fe55a697e0a14e6 Mon Sep 17 00:00:00 2001 From: "pavel.sergeev" Date: Tue, 29 Oct 2024 19:09:08 +0100 Subject: [PATCH] fix test --- .../commonTest/kotlin/org/jetbrains/skia/ParagraphTest.kt | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/skiko/src/commonTest/kotlin/org/jetbrains/skia/ParagraphTest.kt b/skiko/src/commonTest/kotlin/org/jetbrains/skia/ParagraphTest.kt index fb2ffeacb..ed8052f01 100644 --- a/skiko/src/commonTest/kotlin/org/jetbrains/skia/ParagraphTest.kt +++ b/skiko/src/commonTest/kotlin/org/jetbrains/skia/ParagraphTest.kt @@ -7,6 +7,8 @@ import org.jetbrains.skia.tests.assertContentCloseEnough import org.jetbrains.skia.tests.makeFromResource import org.jetbrains.skiko.tests.* import kotlin.math.ceil +import kotlin.math.floor +import kotlin.math.truncate import kotlin.test.Test import kotlin.test.assertContentEquals import kotlin.test.assertEquals @@ -195,8 +197,12 @@ class ParagraphTest { it.build() }.layout(Float.POSITIVE_INFINITY) assertEquals(1, paragraph.lineNumber) + + val maxIntrinsicWidth = paragraph.maxIntrinsicWidth + val isMaxIntrinsicWidthRound = maxIntrinsicWidth == truncate(maxIntrinsicWidth) + val expectedLines = if (unexpectedWrapsPresent && isMaxIntrinsicWidthRound) 2 else 1 + paragraph.layout(ceil(paragraph.maxIntrinsicWidth)) - val expectedLines = if (unexpectedWrapsPresent) 2 else 1 assertEquals(expectedLines, paragraph.lineNumber) paragraph.layout(paragraph.maxIntrinsicWidth) assertEquals(expectedLines, paragraph.lineNumber)