Avoid using String::null where an empty string is required.

String::null is not necessarily be empty or remains the same instance.
Using it in a public header may lead to a linkage error.
This commit is contained in:
Tsuda Kageyu
2015-11-20 22:21:47 +09:00
parent c4fe65787c
commit 8c6fe45453
29 changed files with 106 additions and 105 deletions

View File

@ -108,7 +108,7 @@ public:
ByteVector data("Test Data");
item.setBinaryData(data);
CPPUNIT_ASSERT(item.values().isEmpty());
CPPUNIT_ASSERT_EQUAL(String::null, item.toString());
CPPUNIT_ASSERT_EQUAL(String(), item.toString());
CPPUNIT_ASSERT_EQUAL(data, item.binaryData());
item.setValue("Test Text 2");

View File

@ -36,7 +36,7 @@ class PublicFrame : public ID3v2::Frame
String readStringField(const ByteVector &data, String::Type encoding,
int *positon = 0)
{ return ID3v2::Frame::readStringField(data, encoding, positon); }
virtual String toString() const { return String::null; }
virtual String toString() const { return String(); }
virtual void parseFields(const ByteVector &) {}
virtual ByteVector renderFields() const { return ByteVector(); }
};

View File

@ -123,10 +123,10 @@ private:
CPPUNIT_ASSERT_EQUAL((TagLib::uchar)128, p->panningSeparation());
CPPUNIT_ASSERT_EQUAL((TagLib::uchar) 0, p->pitchWheelDepth());
CPPUNIT_ASSERT_EQUAL(title, t->title());
CPPUNIT_ASSERT_EQUAL(String::null, t->artist());
CPPUNIT_ASSERT_EQUAL(String::null, t->album());
CPPUNIT_ASSERT_EQUAL(String(), t->artist());
CPPUNIT_ASSERT_EQUAL(String(), t->album());
CPPUNIT_ASSERT_EQUAL(comment, t->comment());
CPPUNIT_ASSERT_EQUAL(String::null, t->genre());
CPPUNIT_ASSERT_EQUAL(String(), t->genre());
CPPUNIT_ASSERT_EQUAL(0U, t->year());
CPPUNIT_ASSERT_EQUAL(0U, t->track());
CPPUNIT_ASSERT_EQUAL(String("Impulse Tracker"), t->trackerName());

View File

@ -113,10 +113,10 @@ private:
CPPUNIT_ASSERT_EQUAL(31U, p->instrumentCount());
CPPUNIT_ASSERT_EQUAL((uchar)1, p->lengthInPatterns());
CPPUNIT_ASSERT_EQUAL(title, t->title());
CPPUNIT_ASSERT_EQUAL(String::null, t->artist());
CPPUNIT_ASSERT_EQUAL(String::null, t->album());
CPPUNIT_ASSERT_EQUAL(String(), t->artist());
CPPUNIT_ASSERT_EQUAL(String(), t->album());
CPPUNIT_ASSERT_EQUAL(comment, t->comment());
CPPUNIT_ASSERT_EQUAL(String::null, t->genre());
CPPUNIT_ASSERT_EQUAL(String(), t->genre());
CPPUNIT_ASSERT_EQUAL(0U, t->year());
CPPUNIT_ASSERT_EQUAL(0U, t->track());
CPPUNIT_ASSERT_EQUAL(String("StarTrekker"), t->trackerName());

View File

@ -110,10 +110,10 @@ private:
CPPUNIT_ASSERT_EQUAL((TagLib::uchar)125, p->tempo());
CPPUNIT_ASSERT_EQUAL((TagLib::uchar) 6, p->bpmSpeed());
CPPUNIT_ASSERT_EQUAL(title, t->title());
CPPUNIT_ASSERT_EQUAL(String::null, t->artist());
CPPUNIT_ASSERT_EQUAL(String::null, t->album());
CPPUNIT_ASSERT_EQUAL(String(), t->artist());
CPPUNIT_ASSERT_EQUAL(String(), t->album());
CPPUNIT_ASSERT_EQUAL(comment, t->comment());
CPPUNIT_ASSERT_EQUAL(String::null, t->genre());
CPPUNIT_ASSERT_EQUAL(String(), t->genre());
CPPUNIT_ASSERT_EQUAL(0U, t->year());
CPPUNIT_ASSERT_EQUAL(0U, t->track());
CPPUNIT_ASSERT_EQUAL(String("ScreamTracker III"), t->trackerName());

View File

@ -69,7 +69,7 @@ public:
s.clear();
CPPUNIT_ASSERT(s.isEmpty());
CPPUNIT_ASSERT(!s.isNull());
CPPUNIT_ASSERT(!s.isNull()); // deprecated, but still worth it to check.
String unicode("José Carlos", String::UTF8);
CPPUNIT_ASSERT(strcmp(unicode.toCString(), "Jos\xe9 Carlos") == 0);

View File

@ -139,13 +139,13 @@ public:
CPPUNIT_ASSERT_EQUAL((TagLib::ushort) 6, p->tempo());
CPPUNIT_ASSERT_EQUAL((TagLib::ushort)125, p->bpmSpeed());
CPPUNIT_ASSERT_EQUAL(titleBefore, t->title());
CPPUNIT_ASSERT_EQUAL(String::null, t->artist());
CPPUNIT_ASSERT_EQUAL(String::null, t->album());
CPPUNIT_ASSERT_EQUAL(String::null, t->comment());
CPPUNIT_ASSERT_EQUAL(String::null, t->genre());
CPPUNIT_ASSERT_EQUAL(String(), t->artist());
CPPUNIT_ASSERT_EQUAL(String(), t->album());
CPPUNIT_ASSERT_EQUAL(String(), t->comment());
CPPUNIT_ASSERT_EQUAL(String(), t->genre());
CPPUNIT_ASSERT_EQUAL(0U, t->year());
CPPUNIT_ASSERT_EQUAL(0U, t->track());
CPPUNIT_ASSERT_EQUAL(String::null, t->trackerName());
CPPUNIT_ASSERT_EQUAL(String(), t->trackerName());
}
void testWriteTagsShort()
@ -185,10 +185,10 @@ private:
CPPUNIT_ASSERT_EQUAL((TagLib::ushort) 6, p->tempo());
CPPUNIT_ASSERT_EQUAL((TagLib::ushort)125, p->bpmSpeed());
CPPUNIT_ASSERT_EQUAL(title, t->title());
CPPUNIT_ASSERT_EQUAL(String::null, t->artist());
CPPUNIT_ASSERT_EQUAL(String::null, t->album());
CPPUNIT_ASSERT_EQUAL(String(), t->artist());
CPPUNIT_ASSERT_EQUAL(String(), t->album());
CPPUNIT_ASSERT_EQUAL(comment, t->comment());
CPPUNIT_ASSERT_EQUAL(String::null, t->genre());
CPPUNIT_ASSERT_EQUAL(String(), t->genre());
CPPUNIT_ASSERT_EQUAL(0U, t->year());
CPPUNIT_ASSERT_EQUAL(0U, t->track());
CPPUNIT_ASSERT_EQUAL(trackerName, t->trackerName());