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

Add containsKey assertion for Map #561

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Goooler
Copy link
Contributor

@Goooler Goooler commented Jan 12, 2025

No description provided.

@Goooler Goooler force-pushed the add-contains-key-for-map branch from e4b62ee to d925b4c Compare January 15, 2025 08:42
@jzbrooks
Copy link

The key assertion does this. What's the value add?

@Goooler
Copy link
Contributor Author

Goooler commented Jan 25, 2025

Inverted for

/**
* Asserts the map does not contain the expected key.
*/
fun <K, V> Assert<Map<K, V>>.doesNotContainKey(key: K) = given {
if (!it.containsKey(key)) return
expected("to not contain key:${show(key)} but had value: ${show(it[key])}")
}

@jzbrooks
Copy link

The key assertion asserts that the map contains a key and transforms the assert into an assertion on the value. You don't have to use the latter part of that functionality if you don't want to. The former does the same thing the proposed assertion does.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants