Closes #32
This commit is contained in:
1 parent
e44529007a
commit
f60faea2e7
35 files changed
+2361
-2145
No files matched your search
@@ -116,6 +116,8 @@ private Q_SLOTS:
|
||||
void integration();
|
||||
void invalidSignals();
|
||||
void validSignals();
|
||||
void longSignalDefinitions_data();
|
||||
void longSignalDefinitions();
|
||||
void physicalNumbersCppLocale();
|
||||
void physicalNumbersCLocale();
|
||||
void dispatch();
|
||||
@@ -1146,6 +1148,56 @@ void DbcParserTest::validSignals() {
|
||||
} catch (const std::exception &error) { CHECK(false, error.what()); }
|
||||
}
|
||||
|
||||
void DbcParserTest::longSignalDefinitions_data() {
|
||||
QTest::addColumn<std::string>("line");
|
||||
QTest::addColumn<bool>("valid");
|
||||
QTest::addColumn<std::string>("unit");
|
||||
const std::string longText(50000U, 'x');
|
||||
const std::string prefix = "SG_ Value : 0|8@1+ (1,0) [0|255] ";
|
||||
QTest::newRow("long-unit") << prefix + "\"" + longText + "\" ECU" << true << longText;
|
||||
QTest::newRow("unterminated-unit") << prefix + "\"" + longText << false << std::string();
|
||||
QTest::newRow("missing-receiver-separator") << prefix + "\"" + longText + "\"ECU" << false << std::string();
|
||||
QTest::newRow("long-name") << SignalLine("0", "8", "1+", "1", "0", "0", "255", longText) << true << std::string();
|
||||
QTest::newRow("long-receiver") << prefix + "\"\" " + longText << true << std::string();
|
||||
std::string receivers = "ECU";
|
||||
for (unsigned index = 0U; index < 10000U; ++index)
|
||||
receivers += ",ECU";
|
||||
QTest::newRow("many-receivers") << prefix + "\"\" " + receivers << true << std::string();
|
||||
QTest::newRow("trailing-receiver-comma") << prefix + "\"\" " + receivers + "," << false << std::string();
|
||||
QTest::newRow("long-factor") << SignalLine("0", "8", "1+", std::string(50000U, '0') + "1", "0", "0", "255") << true << std::string();
|
||||
QTest::newRow("invalid-long-factor") << SignalLine("0", "8", "1+", std::string(50000U, '0') + "1x", "0", "0", "255") << false << std::string();
|
||||
QTest::newRow("overflowing-start-bit") << SignalLine(std::string(50000U, '9'), "8", "1+", "1", "0", "0", "255") << false << std::string();
|
||||
QTest::newRow("missing-colon") << "SG_ " + longText << false << std::string();
|
||||
}
|
||||
|
||||
void DbcParserTest::longSignalDefinitions() {
|
||||
QFETCH(std::string, line);
|
||||
QFETCH(bool, valid);
|
||||
QFETCH(std::string, unit);
|
||||
Fixture fixture;
|
||||
fixture.Write("BO_ 1 Frame: 1 ECU\n" + line + "\n");
|
||||
const DbcParser parser;
|
||||
const DbcParseResult result = parser.ParseFileWithDiagnostics(fixture.path.string());
|
||||
QCOMPARE(result.HasErrors(), !valid);
|
||||
if (valid) {
|
||||
QVERIFY(result.diagnostics.empty());
|
||||
const DbcDatabase database = parser.ParseFile(fixture.path.string());
|
||||
QCOMPARE(database.frames.size(), std::size_t(1));
|
||||
QCOMPARE(database.frames[0].signals.size(), std::size_t(1));
|
||||
QCOMPARE(database.frames[0].signals[0].unit, unit);
|
||||
QCOMPARE(result.database.frames[0].signals[0].unit, unit);
|
||||
QCOMPARE(database.frames[0].signals[0].factor, 1.0);
|
||||
QVERIFY(!database.frames[0].signals[0].receivers.empty());
|
||||
} else {
|
||||
QVERIFY(result.database.frames.empty());
|
||||
QCOMPARE(result.diagnostics.size(), std::size_t(1));
|
||||
QCOMPARE(result.diagnostics[0].code, DbcDiagnosticCode::InvalidStatement);
|
||||
QCOMPARE(result.diagnostics[0].lineNumber, std::size_t(2));
|
||||
QCOMPARE(result.diagnostics[0].filePath, fixture.path.string());
|
||||
RejectSignal(fixture, line, 1U);
|
||||
}
|
||||
}
|
||||
|
||||
void DbcParserTest::CheckPhysicalNumbers() {
|
||||
Fixture fixture;
|
||||
struct PhysicalCase {
|
||||
|
||||
Reference in new issue
Block a user