Skip to content

Commit df464a6

Browse files
authored
Add toString override and improve test coverage (#953)
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.
1 parent 7695fb2 commit df464a6

File tree

2 files changed

+5
-0
lines changed
  • core/src

2 files changed

+5
-0
lines changed

core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/ColumnAccessorImpl.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,6 @@ internal class ColumnAccessorImpl<T>(val path: ColumnPath) : ColumnAccessor<T> {
4343
override fun getValue(row: AnyRow) = path.getValue(row) as T
4444

4545
override fun getValueOrNull(row: AnyRow) = path.getValueOrNull(row) as T
46+
47+
override fun toString(): String = path().toString()
4648
}

core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/api/get.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ class GetTests {
4949
shouldThrow<IllegalArgumentException> { row.getValue(c) }
5050
shouldThrow<IllegalArgumentException> { row.getValue(A::c) }
5151

52+
val throwable = shouldThrow<IllegalArgumentException> { df[column<Int>("c")] }
53+
throwable.message shouldContain "Column not found: '[c]'"
54+
5255
val added = df.add(A::c) { "3" }[0]
5356

5457
shouldThrow<ClassCastException> { added.getValue(c) + 1 }

0 commit comments

Comments
 (0)