Add unit tests for `associate` and `associateBy`
- Dominant language
- Kotlin
- Stars
- 1.1k
- Forks
- 83
- Avg merge
- 4d 12h
- Merged PRs (30d)
- 30
Description
`core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/associate.kt` has public APIs `associate` and `associateBy`, but there is no dedicated unit test file for them.
Add focused unit tests for both APIs.
### Test scenarios as an option
#### `associate`
- Basic case: build a map from row values, e.g. `df.associate { name to age }`.
- Computed key/value: use expressions based on several columns, e.g. `fullName to age + 1`.
- Duplicate keys: if several rows produce the same key, the last value wins, consistently with Kotlin stdlib `associate`.
- Empty dataframe: returns an empty map.
- Nullable key/value: supports `null` as key or value if produced by the row expression.
#### `associateBy`
- Basic case: build a map from key to `DataRow`, e.g. `df.associateBy { id }`.
- Computed key: use an expression based on several columns.
- Duplicate keys: if several rows produce the same key, the last row wins, consistently with Kotlin stdlib `associateBy`.
- Empty dataframe: returns an empty map.
- Nullable key: supports `null` as a key if produced by the row expression.
#### Error scenarios
- Accessing a missing column inside the row expression throws the same exception as normal row access.
- Accessing a column with an incompatible type inside the row expression throws the same exception as normal typed access.
### Acceptance criteria
- Dedicated tests exist in `core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/api/associate.kt`.
- `associate` and `associateBy` are both covered.
- Duplicate-key behavior is explicitly tested.
- At least one negative scenario verifies that row-expression errors are propagated.
Contributor guide
Assessment
This issue has not been assessed yet.