示例#1
0
文件: String.cpp 项目: oroisec/ios
String::String(const Identifier& str)
{
    if (str.isNull())
        return;
    
    if (str.isEmpty())
        m_impl = StringImpl::empty();
    else 
        m_impl = new StringImpl(reinterpret_cast<const UChar*>(str.data()), str.size());
}
示例#2
0
void TestIdentifier::testIdentifier()
{
  QFETCH(QString, stringId);
  const IndexedString indexedStringId(stringId);

  Identifier id(stringId);
  QCOMPARE(id.isEmpty(), stringId.isEmpty());
  QCOMPARE(id, Identifier(stringId));
  QVERIFY(!(id != Identifier(stringId)));
  QCOMPARE(id, Identifier(stringId));
  QCOMPARE(id, Identifier(indexedStringId));
  QCOMPARE(id.identifier(), indexedStringId);
  QCOMPARE(id.toString(), stringId);
  QVERIFY(id.nameEquals(Identifier(stringId)));
  QVERIFY(!id.isUnique());

  if (stringId.isEmpty()) {
    QVERIFY(id.inRepository());
    QVERIFY(Identifier(id).inRepository());
    QVERIFY(Identifier(indexedStringId).inRepository());
  }

  Identifier copy = id;
  QCOMPARE(copy, id);
  copy = copy;
  QCOMPARE(copy, id);
  copy = Identifier();
  QVERIFY(copy.isEmpty());
  copy = id;
  QCOMPARE(copy, id);

  IndexedIdentifier indexedId(id);
  QVERIFY(indexedId == id);
  QCOMPARE(indexedId, IndexedIdentifier(id));
  QCOMPARE(indexedId.isEmpty(), stringId.isEmpty());
  QCOMPARE(indexedId.identifier(), id);
  IndexedIdentifier indexedCopy = indexedId;
  QCOMPARE(indexedCopy, indexedId);
  indexedCopy = indexedCopy;
  QCOMPARE(indexedCopy, indexedId);
  indexedCopy = IndexedIdentifier();
  QVERIFY(indexedCopy.isEmpty());
  indexedCopy = indexedId;
  QCOMPARE(indexedCopy, indexedId);

  Identifier moved = std::move(id);
  QVERIFY(id.isEmpty());
  QVERIFY(id.inRepository());
  QCOMPARE(moved, copy);

  IndexedIdentifier movedIndexed = std::move(indexedId);
  QVERIFY(indexedId.isEmpty());
  QCOMPARE(movedIndexed, indexedCopy);
}
示例#3
0
bool LabelStack::contains(const Identifier &id) const
{
    if (id.isEmpty())
        return true;

    for (StackElem* curr = m_topOfStack; curr; curr = curr->prev) {
        if (curr->id == id)
            return true;
    }

    return false;
}