From 2f8f02395e880285c04912f755f6ead384ba5a6b Mon Sep 17 00:00:00 2001 From: Alexey Zinoviev Date: Mon, 18 Nov 2024 12:02:15 +0100 Subject: [PATCH] Add toString override and improve test coverage Introduce a toString override in ColumnAccessorImpl to enhance debugging and readability. Added tests to verify exception behavior when a column is not found, ensuring stability and clarity in error messages. --- .../kotlinx/dataframe/impl/columns/ColumnAccessorImpl.kt | 2 ++ .../src/test/kotlin/org/jetbrains/kotlinx/dataframe/api/get.kt | 3 +++ 2 files changed, 5 insertions(+) diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/ColumnAccessorImpl.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/ColumnAccessorImpl.kt index e7748770fc..fe5d44d861 100644 --- a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/ColumnAccessorImpl.kt +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/ColumnAccessorImpl.kt @@ -43,4 +43,6 @@ internal class ColumnAccessorImpl(val path: ColumnPath) : ColumnAccessor { override fun getValue(row: AnyRow) = path.getValue(row) as T override fun getValueOrNull(row: AnyRow) = path.getValueOrNull(row) as T + + override fun toString(): String = path().toString() } diff --git a/core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/api/get.kt b/core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/api/get.kt index 5117b18687..f2a0ede4f7 100644 --- a/core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/api/get.kt +++ b/core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/api/get.kt @@ -49,6 +49,9 @@ class GetTests { shouldThrow { row.getValue(c) } shouldThrow { row.getValue(A::c) } + val throwable = shouldThrow { df[column("c")] } + throwable.message shouldContain "Column not found: '[c]'" + val added = df.add(A::c) { "3" }[0] shouldThrow { added.getValue(c) + 1 }