Skip to content

Commit

Permalink
Merge pull request #82 from nimrof/fix_original_unittests
Browse files Browse the repository at this point in the history
Fix original unittests
  • Loading branch information
trojanobelix authored Mar 15, 2024
2 parents 0e45000 + 8c21a1a commit 00b11b6
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 13 deletions.
8 changes: 4 additions & 4 deletions Tests/ExporterTests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using Xunit;
using libEDSsharp;

Expand Down Expand Up @@ -44,7 +44,7 @@ public void Test_record_objects()
subod = new ODentry("Test String 2", 0x01, DataType.VISIBLE_STRING, new string('*', 255), EDSsharp.AccessType.ro, PDOMappingType.optional, od);
test = export_one_record_type(subod, "");

if (test != " {(void*)&CO_OD_RAM.testRecord.testString2, 0x26, 0xFF }," + Environment.NewLine)
if (test != " {(void*)&CO_OD_RAM.testRecord.testString2, 0x36, 0xFF }," + Environment.NewLine)
throw (new Exception("export_one_record_type() error test 2"));

}
Expand Down Expand Up @@ -78,7 +78,7 @@ public void TestArrays()

string test = print_h_entry(od);

if (test != "/*2000 */ VISIBLE_STRING testArray[32][4];" + Environment.NewLine)
if (test != "/*2000 */ VISIBLE_STRING testArray[4][32];" + Environment.NewLine)
throw (new Exception("TestArrays() test 1 failed"));


Expand Down Expand Up @@ -151,7 +151,7 @@ public void TestArrayNoEntries()
od.subobjects.Add(0x03, new ODentry("LINE1", 0x03, DataType.UNSIGNED32, "0x01", EDSsharp.AccessType.ro, PDOMappingType.optional));

test = write_od_line(od);
if (test != "{0x1003, 0x03, 0x06, 0, (void*)&CO_OD_RAM.testArray[0]}," + Environment.NewLine)
if (test != "{0x1003, 0x03, 0x0E, 0, (void*)&CO_OD_RAM.testArray[0]}," + Environment.NewLine)
throw (new Exception("TestArrayNoEntries() failed"));


Expand Down
17 changes: 9 additions & 8 deletions Tests/PDOHelperTests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using Xunit;
using libEDSsharp;

Expand Down Expand Up @@ -53,10 +53,10 @@ public void Test_TPDO()
throw new Exception("Mapping paramaters not generated");
}

if (comparamOD.subobjects.Count != 7)
if (comparamOD.subobjects.Count != 6)
throw new Exception("Wrong number of sub objects generated");

if(comparamOD.Nosubindexes!=7)
if(comparamOD.Nosubindexes!=6)
throw new Exception("Wrong number of sub objects generated");

if (comparamOD.subobjects[1].datatype != DataType.UNSIGNED32)
Expand All @@ -65,8 +65,6 @@ public void Test_TPDO()
throw new Exception("Wrong data type for Transmission type");
if (comparamOD.subobjects[3].datatype != DataType.UNSIGNED16)
throw new Exception("Wrong data type for Inhibit time");
if (comparamOD.subobjects[4].datatype != DataType.UNSIGNED8)
throw new Exception("Wrong data type for Compatibility Entry");
if (comparamOD.subobjects[5].datatype != DataType.UNSIGNED16)
throw new Exception("Wrong data type for Event timer");
if (comparamOD.subobjects[6].datatype != DataType.UNSIGNED8)
Expand Down Expand Up @@ -132,22 +130,25 @@ public void Test_RPDO()
throw new Exception("Mapping paramaters not generated");
}

if (comparamOD.subobjects.Count != 3)
if (comparamOD.subobjects.Count != 4)
throw new Exception("Wrong number of sub objects generated");

if (comparamOD.Nosubindexes != 3)
if (comparamOD.Nosubindexes != 4)
throw new Exception("Wrong number of sub objects generated");

if (comparamOD.subobjects[1].datatype != DataType.UNSIGNED32)
throw new Exception("Wrong data type for COB");
if (comparamOD.subobjects[2].datatype != DataType.UNSIGNED8)
throw new Exception("Wrong data type for Transmission type");
if (comparamOD.subobjects[5].datatype != DataType.UNSIGNED16)
throw new Exception("Wrong data type for Transmission type");

if (comparamOD.subobjects[1].defaultvalue != "0x401") //481 hex
throw new Exception("TPDO COB wrong");
if (comparamOD.subobjects[2].defaultvalue != "254")
throw new Exception("TPDO transmission type wrong");

if (comparamOD.subobjects[5].defaultvalue != "20")
throw new Exception("TPDO event timer wrong default value");
}


Expand Down
2 changes: 1 addition & 1 deletion libEDSsharp/CanOpenXDD.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1118,7 +1118,7 @@ public EDSsharp convert(ISO15745ProfileContainer container)

subentry.uniqueID = subobj.uniqueIDRef;

entry.subobjects.Add(subobj.subIndex[0], subentry);
entry.subobjects.Add(subobj.subIndex[subobj.subIndex.Length - 1], subentry);

}
}
Expand Down

0 comments on commit 00b11b6

Please sign in to comment.