-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added functionality to check limits of AssertResults.
Linted markdown/documentation files. See: #190 - "AddAssertResult not checking limits of AssertResults array" #193 - "Fix overflow of assert array limits"
- Loading branch information
1 parent
89738d5
commit 4a48bdd
Showing
16 changed files
with
285 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
TcUnit-Verifier/TcUnit-Verifier_DotNet/TcUnit-Verifier/FB_AssertCountExceedsMaxNumber.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
|
||
namespace TcUnit.Verifier | ||
{ | ||
class FB_AssertCountExceedsMaxNumber : TestFunctionBlockAssert | ||
{ | ||
public FB_AssertCountExceedsMaxNumber(IEnumerable<ErrorList.Error> errors, string testFunctionBlockInstance = null) : base(errors, testFunctionBlockInstance) | ||
{ | ||
string testName; | ||
string testMessage; | ||
|
||
testName = "Assert_SameEntryInOneCycle"; | ||
testMessage = "AssertResults.TotalAsserts invalid"; | ||
AssertDoesNotContainMessage(testName, testMessage, EnvDTE80.vsBuildErrorLevel.vsBuildErrorLevelHigh); | ||
|
||
testName = "Assert_SameArrayEntryInOneCycle"; | ||
testMessage = "AssertArrayResults.TotalArrayAsserts invalid"; | ||
AssertDoesNotContainMessage(testName, testMessage, EnvDTE80.vsBuildErrorLevel.vsBuildErrorLevelHigh); | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...t-Verifier/TcUnit-Verifier_TwinCAT/TcUnit-Verifier_TwinCAT/TcUnit-Verifier_TwinCAT.tsproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
..._TwinCAT/TcUnit-Verifier_TwinCAT/TcUnitVerifier/Test/FB_AssertCountExceedsMaxNumber.TcPOU
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<TcPlcObject Version="1.1.0.1"> | ||
<POU Name="FB_AssertCountExceedsMaxNumber" Id="{5ccd4520-25c7-4bc8-a1a7-a6751f509f85}" SpecialFunc="None"> | ||
<Declaration><![CDATA[(* | ||
This test-suite runs several asserts with the same parameters (same expected, actual, message), calling the asserts | ||
in different cycles and using the same test. | ||
On top of this, we will call new asserts (though with same parameters) in later cycles. | ||
The reason we want the framework to support this is that theoretically the user could want to do an assert with the | ||
same message, using the same test with the same data values for both expected and actual, and splitting the asserts | ||
on different cycles. | ||
*) | ||
FUNCTION_BLOCK FB_AssertCountExceedsMaxNumber EXTENDS TcUnit.FB_TestSuite | ||
VAR | ||
END_VAR]]></Declaration> | ||
<Implementation> | ||
<ST><![CDATA[Assert_SameEntryInOneCycle(); | ||
Assert_SameArrayEntryInOneCycle();]]></ST> | ||
</Implementation> | ||
<Method Name="Assert_SameArrayEntryInOneCycle" Id="{6f972df2-c1ab-4b10-9350-030d31b8135f}"> | ||
<Declaration><![CDATA[METHOD PRIVATE Assert_SameArrayEntryInOneCycle | ||
VAR | ||
a : ARRAY[1..ARRAY_LENGTH] OF DWORD := [16#12345678, 16#23456789]; | ||
b : ARRAY[1..ARRAY_LENGTH] OF DWORD := [16#90ABCDEF, 16#0ABCDEF1]; | ||
i : UINT; | ||
END_VAR | ||
VAR CONSTANT | ||
ARRAY_LENGTH : UINT := 2; | ||
MAX_INDEX : UINT := (TcUnit.GVL_Param_TcUnit.MaxNumberOfAssertsForEachTestSuite + 100); | ||
END_VAR]]></Declaration> | ||
<Implementation> | ||
<ST><![CDATA[TEST('Assert_SameArrayEntryInOneCycle'); | ||
// Only checks if PLC crashes | ||
FOR i := 1 TO MAX_INDEX DO | ||
AssertArrayEquals_DWORD(Expecteds := a, | ||
Actuals := a, | ||
Message := 'Values differ'); | ||
END_FOR; | ||
AssertEquals_UINT(Expected := GVL_Param_TcUnit.MaxNumberOfAssertsForEachTestSuite, | ||
Actual := AssertArrayResults.TotalArrayAsserts, | ||
Message := 'AssertArrayResults.TotalArrayAsserts invalid'); | ||
TEST_FINISHED();]]></ST> | ||
</Implementation> | ||
</Method> | ||
<Method Name="Assert_SameEntryInOneCycle" Id="{79d00f1b-a496-49a2-8093-dbe58274f7f4}"> | ||
<Declaration><![CDATA[METHOD PRIVATE Assert_SameEntryInOneCycle | ||
VAR | ||
a : DWORD := 16#12345678; | ||
b : DWORD := 16#90ABCDEF; | ||
i : UINT; | ||
END_VAR | ||
VAR CONSTANT | ||
MAX_INDEX : UINT := (TcUnit.GVL_Param_TcUnit.MaxNumberOfAssertsForEachTestSuite + 100); | ||
END_VAR]]></Declaration> | ||
<Implementation> | ||
<ST><![CDATA[TEST('Assert_SameEntryInOneCycle'); | ||
// Only checks if PLC crashes | ||
FOR i := 1 TO MAX_INDEX DO | ||
AssertEquals_DWORD(Expected := a, | ||
Actual := a, | ||
Message := 'Values differ'); | ||
END_FOR; | ||
AssertEquals_UINT(Expected := GVL_Param_TcUnit.MaxNumberOfAssertsForEachTestSuite, | ||
Actual := AssertResults.TotalAsserts, | ||
Message := 'AssertResults.TotalAsserts invalid'); | ||
TEST_FINISHED();]]></ST> | ||
</Implementation> | ||
</Method> | ||
</POU> | ||
</TcPlcObject> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.