/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=2 et sw=2 tw=80: */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
os << serializable; return os.str();
} bool ParsingResultComparer::Compare(const Results& aResA, const Results& aResB, const std::string& aOriginalSdp, const SdpPref::AlternateParseModes& aMode) {
MOZ_ASSERT(aResA, "aResA must not be a nullptr");
MOZ_ASSERT(aResB, "aResB must not be a nullptr");
MOZ_ASSERT(aResA->ParserName() != aResB->ParserName(), "aResA and aResB must be from different parsers");
bool result = rsdparsaSdpStr == sipccSdpStr;
LOG_EXPECT(result, expect, ("The original sdp: \n%s", mOriginalSdp.c_str())); if (result) {
LOG_EXPECT(result, expect, ("Serialization is equal")); return result;
} // Do a deep comparison
result = true;
LOG_EXPECT(result, expect,
("Serialization is not equal\n" " --- Sipcc SDP ---\n" "%s\n" "--- Rsdparsa SDP ---\n" "%s\n",
sipccSdpStr.c_str(), rsdparsaSdpStr.c_str()));
if (sipccMediaSecCount != rsdparsaMediaSecCount) {
result = false;
LOG_EXPECT(result, expect,
("Media section count is NOT equal, rsdparsa: %d, sipcc: %d \n",
rsdparsaMediaSecCount, sipccMediaSecCount));
}
for (size_t i = 0; i < std::min(sipccMediaSecCount, rsdparsaMediaSecCount);
i++) {
result &= CompareMediaSections(rsdparsaSdp.GetMediaSection(i),
sipccSdp.GetMediaSection(i));
}
return result;
}
bool ParsingResultComparer::CompareMediaSections( const SdpMediaSection& rustMediaSection, const SdpMediaSection& sipccMediaSection, const SdpComparisonResult expect) const { bool result = true; auto trackMediaLineMismatch = [&result, &expect]( auto rustValue, auto sipccValue, const nsString& valueDescription) {
result = false;
LOG_EXPECT(result, expect,
("The media line values %s are not equal\n" "rsdparsa value: %s\n" "sipcc value: %s\n",
NS_LossyConvertUTF16toASCII(valueDescription).get(),
ToString(rustValue).c_str(), ToString(sipccValue).c_str()));
};
auto compareMediaLineValue = [trackMediaLineMismatch]( auto rustValue, auto sipccValue, const nsString& valueDescription) { if (rustValue != sipccValue) {
trackMediaLineMismatch(rustValue, sipccValue, valueDescription);
}
};
auto compareSimpleMediaLineValue =
[&rustMediaSection, &sipccMediaSection, compareMediaLineValue]( auto valGetFuncPtr, const nsString& valueDescription) {
compareMediaLineValue((rustMediaSection.*valGetFuncPtr)(),
(sipccMediaSection.*valGetFuncPtr)(),
valueDescription);
};
result &= CompareAttrLists(rustMediaSection.GetAttributeList(),
sipccMediaSection.GetAttributeList(), static_cast<int>(rustMediaSection.GetLevel())); return result;
}
bool ParsingResultComparer::CompareAttrLists( const SdpAttributeList& rustAttrlist, const SdpAttributeList& sipccAttrlist, int level, const SdpComparisonResult expect) const { bool result = true;
for (size_t i = AttributeType::kFirstAttribute;
i <= static_cast<size_t>(AttributeType::kLastAttribute); i++) { const AttributeType type = static_cast<AttributeType>(i);
std::string attrStr; if (type != AttributeType::kDirectionAttribute) {
attrStr = "a=" + SdpAttribute::GetAttributeTypeString(type);
} else {
attrStr = "a=_direction_attribute_";
}
if (sipccAttrlist.HasAttribute(type, false)) { auto sipccAttrStr = ToString(*sipccAttrlist.GetAttribute(type, false));
if (!rustAttrlist.HasAttribute(type, false)) {
result = false;
LOG_EXPECT(result, expect,
("Rust is missing the attribute: %s\n", attrStr.c_str()));
LOG_EXPECT(result, expect,
("Rust is missing: %s\n", sipccAttrStr.c_str()));
continue;
}
auto rustAttrStr = ToString(*rustAttrlist.GetAttribute(type, false));
if (rustAttrStr != sipccAttrStr) { if (type == AttributeType::kFmtpAttribute) { if (rustAttrlist.GetFmtp() == sipccAttrlist.GetFmtp()) { continue;
}
}
std::string originalAttrStr = GetAttributeLines(attrStr, level); if (rustAttrStr != originalAttrStr) {
result = false;
LOG_EXPECT(result, expect,
("%s is neither equal to sipcc nor to the orginal sdp\n" "--------------rsdparsa attribute---------------\n" "%s" "--------------sipcc attribute---------------\n" "%s" "--------------original attribute---------------\n" "%s\n",
attrStr.c_str(), rustAttrStr.c_str(),
sipccAttrStr.c_str(), originalAttrStr.c_str()));
} else {
LOG_EXPECT(
result, expect,
("But the rust serialization is equal to the orignal sdp\n"));
}
}
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.