Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added tests for GetMany and NoGetter in GetterImplTest #1

Merged
merged 2 commits into from
Jun 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions src/test/scala/monocly/impl/GetterImplTest.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package monocly.impl

import munit.FunSuite

class GetterImplTest extends munit.FunSuite {

test("GetMany getOne") {
val getter = GetManyImpl((x: List[Int]) => x)
val input = List(1,2,3)
assertEquals(
getter.get(input),
1
)
Comment on lines +7 to +13

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test case "GetMany getOne" is asserting that getter.get(input) returns 1, but it is not clear from the provided code why this should be the expected behavior. The function passed to GetManyImpl simply returns the input list, and there is no indication that the first element of the list should be returned by getter.get.

Recommendation: Ensure that the GetManyImpl class or object is correctly implemented to return the first element of the list, or adjust the test case to reflect the actual expected behavior of the getter.get method.

}

test("GetMany getOne doesn't compile") {
assertNoDiff(
compileErrors("GetManyImpl((x: List[Int]) => x).get(List(1,2,3))"),
"Error: ..."
)
}

test("NoGetter getOne doesn't compile") {
assertNoDiff(
compileErrors("NoGetter.get(1)"),
"Error: ..."
)
}

}
Loading