question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Asserts for CharSequence contents

See original GitHub issue

A lot of APIs in Android deal with CharSequence. And using assertEquals() with CharSequence arguments is cumbersome and unstable. One has to reproduce the exact same type which might change later. And sometimes it just does not work (e.g. StringBuilder uses default Object.equals() implementation).

Therefore I would suggest to add new methods like assertContentEquals(CharSequence expected, CharSequence actual) that would compare just the content, irregardless of the type it’s been wrapped into.

(Pull request #949 was trying to do that with generic assertEquals() which is indeed questionable)

I can create a pull request if you find this proposal reasonable.

Issue Analytics

  • State:open
  • Created 7 years ago
  • Comments:13 (6 by maintainers)

github_iconTop GitHub Comments

3reactions
kcooneycommented, Apr 9, 2017

@joseph-mccarthy GitHub apparently only lets you assign issues to someone on the project’s team. But we almost never assign issues anyway. Feel free to submit a pull request after reading https://github.com/junit-team/junit4/blob/master/CONTRIBUTING.md

0reactions
btrajkovskicommented, Oct 4, 2017

@kcooney I am assuming that @joseph-mccarthy is no longer working on this and I’ve opened a PR with implementation.

Read more comments on GitHub >

github_iconTop Results From Across the Web

AbstractCharSequenceAssert (AssertJ fluent assertions 3.12.0 ...
Base class for all implementations of assertions for CharSequence s. ... Verifies that the actual CharSequence is equal to the content of the...
Read more >
AbstractCharSequenceAssert (AssertJ fluent assertions 2.0.0 API)
Base class for all implementations of assertions for CharSequence s. ... Verifies that the actual CharSequence is equal to the content of the...
Read more >
Test CharSequences for equality in JUnit - java - Stack Overflow
You can by using CharBuffer s: assertEquals(CharBuffer.wrap(a), CharBuffer.wrap(b));. The javadoc of .equals for CharBuffer guarantees this:
Read more >
CharSequence
dropRight( -1 ) == 'groovy' assert text.dropRight( 10 ) == ''. Parameters: num - number of characters. Returns: CharSequence after removing the right...
Read more >
Source (GraalVM Truffle Java API Reference)
getName()); assert resource.toURI().equals(source.getURI()); Each URL source is represented as a canonical object, indexed by the URL. Contents are read ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found