-
-
Notifications
You must be signed in to change notification settings - Fork 218
Path.hasSameTextualContentAs #375
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
Comments
should we rather call this |
AssertJ has hasSameTextualContentAs (they actually deprecated hasSameContentAs in favour of it) but IMO it is kind of the default case that one would want to compare textual content and thus would prefer a shorter version. But I am also not against using hasSameTextualContentAs if you think this is really necessary |
What should be considered the default depends on what those assertions do. I expected Alternatively, we could also just implement |
You lost me there, I never encountered a problem reading a binary file even if the resulting text is gibberish. I also think that doing only binary comparison would not work if the source and target file is stored in a different encoding. We could implement a heuristic à la |
Not all sequences of bits are valid code points in all encodings. For example, in UTF-8, code points always start with
Oh, wow, okay, you also want to support comparison between different encodings? I missed that (but now I see it clearly from your proposal)
I only suggested using a heuristic in reporting, not in the actual assertion logic. But maybe that is still too complicated. I personally prefer precision over conciseness, but my opinion is not very strong on this. I would prefer |
So, let's go with |
where has to be added this method? |
atrium/apis/fluent-en_GB/extensions/jdk8/atrium-api-fluent-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/jdk8/pathAssertions.kt |
so i have to write method with 3 arguments, where last two are optionals with value UTF-8. is that right? |
and one simple hasSameBinaryContentAs method |
You got it right, let me know in case you need pointers. |
should i write @SInCE [version] in doc? or not? |
Yes please, we started to add the tag since v. 0.9.0 to everything which is new and public API |
should i add this method for infix part, too? |
I have not yet thought about how the API should look like, we cannot have default arguments in the infix API. Therefore I would say no unless you have an idea at hand. |
maybe automatically determining encoding, but don't think that there is any library that can guess the encoding 100% correctly. |
Workaround it similar to this one apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/CharSequenceAssertionsSpec.kt -> getContainsDefaultTranslationOfPair use a text something like: |
alternatively you can implement the following API for infix:
where withEncoding creates a PathWithEncoding similar to PathWithCreator |
Could we do something like expect(path) hasSameTextualContentAs otherPath withEncoding (UTF_8 to UTF_16) That would feel more intuitive to me and I think it should be possible with infix? |
how would the version look like where one omits the encodings?
would not work any more. IMO not providing encodings is the default case and should be simple, simpler than the above is probably not possible.
in this sense I would continue with helper functions dealing with use cases where there are more than 1 parameter. |
I cannot speak to consistency of the API since I don’t know the API well. I generally don’t see the point of an infix API if we don’t try to make it “as infix-ish as possible”. To how I would realise this: I didn’t think my proposal through, I just liked it. I did not think of the problem that the Another, possible, solution, would be something like expect(path) withEncoding UTF_8 hasSameTextualContentAs (otherPath withEncoding UTF_16) But I am not sure that that is better. |
…ion.PathAssertionsSpec tests is what you intentded, and please also check ch.tutteli.atrium.api.infix.en_GB.jdk8.PathAssertionsSpec.
Platform (jvm, js, android): jvm
Extension (none, kotlin 1.3, jdk8): jdk8
Code related feature
per default UTF-8 should be used when reading both files.
However, one shall be able to overwrite the default, something like:
Bonus add also
hasSameBinaryContentAs
The text was updated successfully, but these errors were encountered: