Skip to content

Commit

Permalink
Solved issue #224 - Adding empty string as actual-string to assert_st…
Browse files Browse the repository at this point in the history
…ring doesn't show the actual string.
  • Loading branch information
sagatowski committed Nov 23, 2023
1 parent ddef47c commit 80d8b14
Show file tree
Hide file tree
Showing 6 changed files with 106 additions and 65 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ public FB_PrimitiveTypes(IEnumerable<ErrorList.Error> errors, string testFunctio
Test_SINT_Differ();
Test_STRING_Equals();
Test_STRING_Differ();
Test_STRING_Differ2();
Test_STRING_Differ3();
Test_TIME_Equals();
Test_TIME_Differ();
Test_TIME_OF_DAY_Equals();
Expand Down Expand Up @@ -235,6 +237,18 @@ private void Test_STRING_Differ()
AssertContainsMessage(testMessage, EnvDTE80.vsBuildErrorLevel.vsBuildErrorLevelHigh);
}

private void Test_STRING_Differ2()
{
string testMessage = CreateFailedTestMessage("Test_STRING_Differ2", "", "This string is not empty", "Values differ");
AssertContainsMessage(testMessage, EnvDTE80.vsBuildErrorLevel.vsBuildErrorLevelHigh);
}

private void Test_STRING_Differ3()
{
string testMessage = CreateFailedTestMessage("Test_STRING_Differ3", "This string is not empty", "", "Values differ");
AssertContainsMessage(testMessage, EnvDTE80.vsBuildErrorLevel.vsBuildErrorLevelHigh);
}

private void Test_TIME_Equals()
{
// TwinCAT 3.1.4020 & 3.1.4022
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class Program
private static string tcUnitTargetNetId = "127.0.0.1.1.1";
private static VisualStudioInstance vsInstance = null;
private static ILog log = LogManager.GetLogger("TcUnit-Verifier");
private static int expectedNumberOfFailedTests = 116; // Update this if you add intentionally failing tests
private static int expectedNumberOfFailedTests = 118; // Update this if you add intentionally failing tests

[STAThread]
static void Main(string[] args)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,8 @@
</Compile>
</ItemGroup>
<ItemGroup>
<Folder Include="DUTs" />
<Folder Include="GVLs" />
<Folder Include="Test" />
<Folder Include="Version" />
<Folder Include="VISUs" />
<Folder Include="POUs" />
</ItemGroup>
<ItemGroup>
Expand Down Expand Up @@ -163,8 +160,8 @@
<ProjectExtensions>
<PlcProjectOptions>
<XmlArchive>
<Data>
<o xml:space="preserve" t="OptionKey">
<Data>
<o xml:space="preserve" t="OptionKey">
<v n="Name">"&lt;ProjectRoot&gt;"</v>
<d n="SubKeys" t="Hashtable" ckt="String" cvt="OptionKey">
<v>{192FAD59-8248-4824-A8DE-9177C94C195A}</v>
Expand Down Expand Up @@ -204,13 +201,13 @@
</d>
<d n="Values" t="Hashtable" />
</o>
</Data>
<TypeList>
<Type n="Hashtable">System.Collections.Hashtable</Type>
<Type n="OptionKey">{54dd0eac-a6d8-46f2-8c27-2f43c7e49861}</Type>
<Type n="String">System.String</Type>
</TypeList>
</XmlArchive>
</Data>
<TypeList>
<Type n="Hashtable">System.Collections.Hashtable</Type>
<Type n="OptionKey">{54dd0eac-a6d8-46f2-8c27-2f43c7e49861}</Type>
<Type n="String">System.String</Type>
</TypeList>
</XmlArchive>
</PlcProjectOptions>
</ProjectExtensions>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ Test_SINT_Equals();
Test_SINT_Differ();
Test_STRING_Equals();
Test_STRING_Differ();
Test_STRING_Differ2();
Test_STRING_Differ3();
Test_TIME_Equals();
Test_TIME_Differ();
Test_TIME_OF_DAY_Equals();
Expand Down Expand Up @@ -544,6 +546,38 @@ AssertEquals_STRING(Expected := a,
Actual := b,
Message := 'Values differ');
TEST_FINISHED();]]></ST>
</Implementation>
</Method>
<Method Name="Test_STRING_Differ2" Id="{83fd514c-a336-4c84-b73e-0e3841ee49c4}">
<Declaration><![CDATA[METHOD PRIVATE Test_STRING_Differ2
VAR
a : STRING := '';
b : STRING := 'This string is not empty';
END_VAR]]></Declaration>
<Implementation>
<ST><![CDATA[TEST('Test_STRING_Differ2');
AssertEquals_STRING(Expected := a,
Actual := b,
Message := 'Values differ');
TEST_FINISHED();]]></ST>
</Implementation>
</Method>
<Method Name="Test_STRING_Differ3" Id="{e6ee682a-82f5-4d00-8b9f-35f174b6cd26}">
<Declaration><![CDATA[METHOD PRIVATE Test_STRING_Differ3
VAR
a : STRING := 'This string is not empty';
b : STRING := '';
END_VAR]]></Declaration>
<Implementation>
<ST><![CDATA[TEST('Test_STRING_Differ3');
AssertEquals_STRING(Expected := a,
Actual := b,
Message := 'Values differ');
TEST_FINISHED();]]></ST>
</Implementation>
</Method>
Expand Down
12 changes: 4 additions & 8 deletions TcUnit/TcUnit/POUs/FB_AdsAssertMessageFormatter.TcPOU
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,10 @@ END_VAR]]></Declaration>
TestInstancePathFinal := CONCAT(STR1 := 'FAILED TEST $'', STR2 := TestInstancePathCleaned);
TestInstancePathFinal := CONCAT(STR1 := TestInstancePathFinal, STR2 := '$'');
IF LEN(STR := Expected) > 0 THEN
TestInstancePathFinal := CONCAT(STR1 := TestInstancePathFinal, STR2 := ', EXP: ');
TestInstancePathFinal := CONCAT(STR1 := TestInstancePathFinal, STR2 := Expected);
END_IF
IF LEN(STR := Actual) > 0 THEN
TestInstancePathFinal := CONCAT(STR1 := TestInstancePathFinal, STR2 := ', ACT: ');
TestInstancePathFinal := CONCAT(STR1 := TestInstancePathFinal, STR2 := Actual);
END_IF
TestInstancePathFinal := CONCAT(STR1 := TestInstancePathFinal, STR2 := ', EXP: ');
TestInstancePathFinal := CONCAT(STR1 := TestInstancePathFinal, STR2 := Expected);
TestInstancePathFinal := CONCAT(STR1 := TestInstancePathFinal, STR2 := ', ACT: ');
TestInstancePathFinal := CONCAT(STR1 := TestInstancePathFinal, STR2 := Actual);
IF LEN(STR := Message) > 0 THEN
TestInstancePathFinal := CONCAT(STR1 := TestInstancePathFinal, STR2 := ', MSG: %s');
END_IF
Expand Down
88 changes: 44 additions & 44 deletions TcUnit/TcUnit/POUs/Functions/F_AnyToUnionValue.TcPOU
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,25 @@ END_VAR]]></Declaration>
<ST><![CDATA[CASE AnyTypeClass OF
IBaseLibrary.TypeClass.TYPE_BOOL :
MEMCPY(destaddr := ADR(F_AnyToUnionValue.boolExpectedOrActual),
srcAddr := AnyValue,
n := AnySize);
srcAddr := AnyValue,
n := AnySize);
IBaseLibrary.TypeClass.TYPE_BIT :
{warning disable C0355}
MEMCPY(destaddr := ADR(F_AnyToUnionValue.bitExpectedOrActual),
srcAddr := AnyValue,
n := AnySize);
srcAddr := AnyValue,
n := AnySize);
{warning enable C0355}
IBaseLibrary.TypeClass.TYPE_BYTE :
MEMCPY(destaddr := ADR(F_AnyToUnionValue.byteExpectedOrActual),
srcAddr := AnyValue,
n := AnySize);
srcAddr := AnyValue,
n := AnySize);
IBaseLibrary.TypeClass.TYPE_WORD :
MEMCPY(destaddr := ADR(F_AnyToUnionValue.wordExpectedOrActual),
srcAddr := AnyValue,
n := AnySize);
srcAddr := AnyValue,
n := AnySize);
IBaseLibrary.TypeClass.TYPE_DWORD :
MEMCPY(destaddr := ADR(F_AnyToUnionValue.dwordExpectedOrActual),
Expand All @@ -38,88 +38,88 @@ END_VAR]]></Declaration>
IBaseLibrary.TypeClass.TYPE_LWORD :
MEMCPY(destaddr := ADR(F_AnyToUnionValue.lwordExpectedOrActual),
srcAddr := AnyValue,
n := AnySize);
srcAddr := AnyValue,
n := AnySize);
IBaseLibrary.TypeClass.TYPE_SINT :
MEMCPY(destaddr := ADR(F_AnyToUnionValue.sintExpectedOrActual),
srcAddr := AnyValue,
n := AnySize);
srcAddr := AnyValue,
n := AnySize);
IBaseLibrary.TypeClass.TYPE_INT :
MEMCPY(destaddr := ADR(F_AnyToUnionValue.intExpectedOrActual),
srcAddr := AnyValue,
n := AnySize);
srcAddr := AnyValue,
n := AnySize);
IBaseLibrary.TypeClass.TYPE_DINT :
MEMCPY(destaddr := ADR(F_AnyToUnionValue.dintExpectedOrActual),
srcAddr := AnyValue,
n := AnySize);
srcAddr := AnyValue,
n := AnySize);
IBaseLibrary.TypeClass.TYPE_LINT :
MEMCPY(destaddr := ADR(F_AnyToUnionValue.lintExpectedOrActual),
srcAddr := AnyValue,
n := AnySize);
srcAddr := AnyValue,
n := AnySize);
IBaseLibrary.TypeClass.TYPE_USINT :
MEMCPY(destaddr := ADR(F_AnyToUnionValue.usintExpectedOrActual),
srcAddr := AnyValue,
n := AnySize);
srcAddr := AnyValue,
n := AnySize);
IBaseLibrary.TypeClass.TYPE_UINT :
MEMCPY(destaddr := ADR(F_AnyToUnionValue.uintExpectedOrActual),
srcAddr := AnyValue,
n := AnySize);
srcAddr := AnyValue,
n := AnySize);
IBaseLibrary.TypeClass.TYPE_UDINT :
MEMCPY(destaddr := ADR(F_AnyToUnionValue.udintExpectedOrActual),
srcAddr := AnyValue,
n := AnySize);
srcAddr := AnyValue,
n := AnySize);
IBaseLibrary.TypeClass.TYPE_ULINT :
MEMCPY(destaddr := ADR(F_AnyToUnionValue.ulintExpectedOrActual),
srcAddr := AnyValue,
n := AnySize);
srcAddr := AnyValue,
n := AnySize);
IBaseLibrary.TypeClass.TYPE_REAL :
MEMCPY(destaddr := ADR(F_AnyToUnionValue.realExpectedOrActual),
srcAddr := AnyValue,
n := AnySize);
srcAddr := AnyValue,
n := AnySize);
IBaseLibrary.TypeClass.TYPE_LREAL :
MEMCPY(destaddr := ADR(F_AnyToUnionValue.lrealExpectedOrActual),
srcAddr := AnyValue,
n := AnySize);
srcAddr := AnyValue,
n := AnySize);
IBaseLibrary.TypeClass.TYPE_STRING :
MEMCPY(destaddr := ADR(F_AnyToUnionValue.stringExpectedOrActual),
srcAddr := AnyValue,
n := AnySize);
srcAddr := AnyValue,
n := AnySize);
IBaseLibrary.TypeClass.TYPE_WSTRING :
MEMCPY(destaddr := ADR(F_AnyToUnionValue.wstringExpectedOrActual),
srcAddr := AnyValue,
n := AnySize);
srcAddr := AnyValue,
n := AnySize);
IBaseLibrary.TypeClass.TYPE_TIME :
MEMCPY(destaddr := ADR(F_AnyToUnionValue.timeExpectedOrActual),
srcAddr := AnyValue,
n := AnySize);
srcAddr := AnyValue,
n := AnySize);
IBaseLibrary.TypeClass.TYPE_DATE :
MEMCPY(destaddr := ADR(F_AnyToUnionValue.dateExpectedOrActual),
srcAddr := AnyValue,
n := AnySize);
srcAddr := AnyValue,
n := AnySize);
IBaseLibrary.TypeClass.TYPE_DATEANDTIME :
MEMCPY(destaddr := ADR(F_AnyToUnionValue.dateandtimeExpectedOrActual),
srcAddr := AnyValue,
n := AnySize);
srcAddr := AnyValue,
n := AnySize);
IBaseLibrary.TypeClass.TYPE_TIMEOFDAY :
MEMCPY(destaddr := ADR(F_AnyToUnionValue.timeofdayExpectedOrActual),
srcAddr := AnyValue,
n := AnySize);
srcAddr := AnyValue,
n := AnySize);
IBaseLibrary.TypeClass.TYPE_POINTER :
(* None *)
Expand Down Expand Up @@ -168,8 +168,8 @@ END_VAR]]></Declaration>
IBaseLibrary.TypeClass.TYPE_LTIME :
MEMCPY(destaddr := ADR(F_AnyToUnionValue.ltimeExpectedOrActual),
srcAddr := AnyValue,
n := AnySize);
srcAddr := AnyValue,
n := AnySize);
IBaseLibrary.TypeClass.TYPE_BITCONST :
(* None *)
Expand Down

0 comments on commit 80d8b14

Please sign in to comment.