EXPECT_EQ should not be used with NSString* |
||
Issue description
Strings may or may not be interned. EXPECT_EQ should not be used to compare them as it just compare the pointers and can fail flakily. Instead EXPECT_NSEQ should be used as it use -isEqual: which will compare the data.
Using EXPECT_EQ can lead to the following funny failures:
[ RUN ] ChromeIconTest.TemplateBarButtonItem
../../ios/chrome/browser/ui/icons/chrome_icon_unittest.mm:61: Failure
Expected: @"label"
Which is: 1
To be equal to: barButtonItem.accessibilityLabel
Which is: 1
[ FAILED ] ChromeIconTest.TemplateBarButtonItem (1 ms)
,
Aug 29 2017
,
Aug 30 2017
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/289639481045995fa69c3ed3dd5cb6ac03bacd85 commit 289639481045995fa69c3ed3dd5cb6ac03bacd85 Author: Sylvain Defresne <sdefresne@chromium.org> Date: Wed Aug 30 07:39:59 2017 Fix incorrect uses of EXPECT_EQ with NSString*. EXPECT_EQ does compare using == which is incorrect for NSString* as it only compare the pointers not the object. Instead use the correct EXPECT_NSEQ that uses -isEqual:. Fixes uses of non-litteral NSString*. Bug: 760100 Change-Id: Ieddec072e29f8da944691c03bf82b670fb570735 Reviewed-on: https://chromium-review.googlesource.com/641710 Commit-Queue: Sylvain Defresne <sdefresne@chromium.org> Reviewed-by: Stepan Khapugin <stkhapugin@chromium.org> Cr-Commit-Position: refs/heads/master@{#498388} [modify] https://crrev.com/289639481045995fa69c3ed3dd5cb6ac03bacd85/ios/chrome/app/application_delegate/url_opener_unittest.mm |
||
►
Sign in to add a comment |
||
Comment 1 by bugdroid1@chromium.org
, Aug 29 2017