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

assertEquals fails #10

Closed
Neurone opened this issue Jan 13, 2011 · 3 comments
Closed

assertEquals fails #10

Neurone opened this issue Jan 13, 2011 · 3 comments

Comments

@Neurone
Copy link

Neurone commented Jan 13, 2011

At line 172 of Test.java file there's an "assertEquals" failing.

This is the expected:

{"cook_time":"3 hours","name":"bread","tagName":"recipe","childNodes":[{"tagName":"title","childNodes":["Basic bread"]},{"amount":8,"unit":"dL","tagName":"ingredient","childNodes":["Flour"]},{"amount":10,"unit":"grams","tagName":"ingredient","childNodes":["Yeast"]},{"amount":4,"unit":"dL","tagName":"ingredient","state":"warm","childNodes":["Water"]},{"amount":1,"unit":"teaspoon","tagName":"ingredient","childNodes":["Salt"]},{"tagName":"instructions","childNodes":[{"tagName":"step","childNodes":["Mix all ingredients together."]},{"tagName":"step","childNodes":["Knead thoroughly."]},{"tagName":"step","childNodes":["Cover with a cloth, and leave for one hour in warm room."]},{"tagName":"step","childNodes":["Knead again."]},{"tagName":"step","childNodes":["Place in a bread baking tin."]},{"tagName":"step","childNodes":["Cover with a cloth, and leave for one hour in warm room."]},{"tagName":"step","childNodes":["Bake in the oven at 180(degrees)C for 30 minutes."]}]}],"prep_time":"5 mins"}

and this is the actual one:

{"cook_time":"3 hours","childNodes":[{"childNodes":["Basic bread"],"tagName":"title"},{"unit":"dL","childNodes":["Flour"],"tagName":"ingredient","amount":8},{"unit":"grams","childNodes":["Yeast"],"tagName":"ingredient","amount":10},{"state":"warm","unit":"dL","childNodes":["Water"],"tagName":"ingredient","amount":4},{"unit":"teaspoon","childNodes":["Salt"],"tagName":"ingredient","amount":1},{"childNodes":[{"childNodes":["Mix all ingredients together."],"tagName":"step"},{"childNodes":["Knead thoroughly."],"tagName":"step"},{"childNodes":["Cover with a cloth, and leave for one hour in warm room."],"tagName":"step"},{"childNodes":["Knead again."],"tagName":"step"},{"childNodes":["Place in a bread baking tin."],"tagName":"step"},{"childNodes":["Cover with a cloth, and leave for one hour in warm room."],"tagName":"step"},{"childNodes":["Bake in the oven at 180(degrees)C for 30 minutes."],"tagName":"step"}],"tagName":"instructions"}],"tagName":"recipe","name":"bread","prep_time":"5 mins"}
@douglascrockford
Copy link
Contributor

You might have noticed this statement at the top of Test.java:

  • Issue: JSONObject does not specify the ordering of keys, so simple-minded
  • comparisons of .toString to a string literal are likely to fail.

So the basic junit stuff is simply inadequate. But it is very popular, so it must be a good thing.

@Neurone
Copy link
Author

Neurone commented Jan 13, 2011

Oh, I suspected it was a keys ordering related issue but I didn't noticed your comments at the top of the file. Anyway, if a case can't be tested, I think removing it at all will be a better solution. Or at least it could be isolated just to show a possible toString() method misunderstanding, because that single fault currently prevents following tests inside testJSON() method to be executed.

I noticed sarcasm in your words about JUnit also ^^ Why do you think it's not a good choice? You don't like TDD or JUnit in particular?

@douglascrockford
Copy link
Contributor

If it were any good, you would not have filed the original report.
Simplistic solutions are great when they work.

BGehrels pushed a commit to BGehrels/JSON-java that referenced this issue Apr 29, 2020
This issue was closed.
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

No branches or pull requests

2 participants