Results 1 to 5 of 5
Thread: assertTrue not working
- 03-23-2012, 09:34 PM #1
Senior Member
- Join Date
- Oct 2011
- Posts
- 115
- Rep Power
- 0
assertTrue not working
I have the following test case, but it's not working even though the values do match up. Anyone know what's going on?
The output I get from the print statement isJava Code:try { String str = InfixToPostfixParens.convert("(6 + 6) * 2"); System.out.println(str); assertTrue(str == "6 6 + 2 * "); } catch (InfixToPostfixParens.SyntaxErrorException e) { e.printStackTrace(); }Which matches what I have in my assertTrue...Java Code:6 6 + 2 *
Last edited by kraigballa; 03-23-2012 at 09:39 PM.
- 03-23-2012, 09:40 PM #2
Senior Member
- Join Date
- Oct 2011
- Posts
- 115
- Rep Power
- 0
Re: assertTrue not working
The space after the asterisk is there in the str print
- 03-23-2012, 09:57 PM #3
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,405
- Blog Entries
- 7
- Rep Power
- 17
Re: assertTrue not working
Conratulations! You're the kazillionth person trying to compare two Strings for equality with the == operator; it doesn't work; read the API documentation for the equals( ... ) method in the String class.
kind regards,
JosWhen people rob a bank they get a penalty; when banks rob people they get a bonus.
- 03-23-2012, 10:01 PM #4
Senior Member
- Join Date
- Oct 2011
- Posts
- 115
- Rep Power
- 0
Re: assertTrue not working
ARG!!!! I'm used to PHP not Java quite yet. Both should work in all reality though...
- 03-24-2012, 08:19 AM #5
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,405
- Blog Entries
- 7
- Rep Power
- 17
Re: assertTrue not working
When people rob a bank they get a penalty; when banks rob people they get a bonus.
Similar Threads
-
Collisions are working & not working
By Jayayoh in forum Java 2DReplies: 1Last Post: 06-24-2011, 05:21 PM -
Why isn't this working?
By nickburris in forum New To JavaReplies: 14Last Post: 02-03-2011, 02:00 AM -
\n not working in GUI (working code, but \n isn't working)
By cc11rocks in forum New To JavaReplies: 2Last Post: 01-04-2011, 04:30 AM -
working with JC
By yuhobebbho in forum New To JavaReplies: 0Last Post: 02-10-2010, 11:22 PM -
Java mail problem(working in intranet,but not working in iternet)
By sundarjothi in forum Advanced JavaReplies: 8Last Post: 05-28-2008, 07:00 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks