Comments (2)
So, some things aren't worth the API weight, I think. And in this case, I think a few of them are easier to just write:
ASSERT.that(map.size()).is(10);
ASSERT.that(map.keys()).has().allOf(a, b);
but some valid assertions directly on the map seem to be:
ASSERT.that(map).hasKey("foo").withValue("bar");
This is similar to the hasField("foo").withValue("bar"); pattern used in Subject itself, and it makes sense here.
AS to the others, it's sort of cute, but I'm just not sure it's worth it. Now the same thing can be said about all subject methods, and you can represent any of these propositions with assertTrue(somePredicate) in theory, so maybe I'm being too conservative here. I just feel like it doesn't add anything, where hasKey().withValue() seems to.
Thoughts? I'll certainly start there.
from truth.
Initial MapSubject created and merged. Closing this. Feel free to open it or another if more features are desired on MapSubject than
hasKey()
hasKey().withValue()
lacksKey()
lacksValue()
isEmpty()
isNotEmpty()
from truth.
Related Issues (20)
- Consider reducing ImmutableList array copying HOT 1
- Wanted: Truth8Junit to support Java 8 types with assume() HOT 3
- Compatibility with gradle 7.6 HOT 2
- UsingCorrespondence should fail on use of equals(), like Subject does
- 1.1.4, Guava update leads to java.lang.UnsupportedOperationException at WindowsSecurityDescriptor.java:358 HOT 2
- Add StringSubject isNotBlank or hasText HOT 2
- Idk
- com.google.guava:guava library version update HOT 2
- Matching on exact class type, not a subtype HOT 2
- Can Truth assert a method throw exception? HOT 1
- Protobuf: allow unpopulated required fields when `comparingExpectedFieldsOnly` HOT 5
- Truth 1.1+ depends on Java 8 bytecode HOT 3
- FAQ entry: Why we don't support multiple chained calls to assertion methods on the same Subject HOT 3
- Port a core set of unit tests to kotlin HOT 2
- JUnit5 support for the existing soft-assertions support (Expect.create JUnit4 Rule) HOT 5
- Document when arrays are compared by their contents vs. their object identity HOT 3
- New extension for Gradle's TestKit HOT 1
- Asymmetric matchers like Jest's expect.stringContaining("") ? HOT 3
- Add MapSubject#containsAnyOf HOT 2
- Allow logical operations on assertions HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from truth.