Skip to content

Commit

Permalink
compare array
Browse files Browse the repository at this point in the history
  • Loading branch information
sjuergen committed Feb 13, 2024
1 parent 3bc9753 commit 26fc4c8
Showing 1 changed file with 4 additions and 22 deletions.
26 changes: 4 additions & 22 deletions test/TestCompareArray.st
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ USING AxUnit.Assert;
USING System.Strings;

NAMESPACE Simatic.Ax.Json

{TestFixture}
CLASS TestCompareArrayOfChar
VAR
Expand All @@ -12,15 +13,14 @@ NAMESPACE Simatic.Ax.Json
a2_6_12345 : ARRAY[2..6] OF CHAR := ['1', '2', '3', '4', '5'];
a0_2_abc : ARRAY[0..2] OF CHAR := ['a', 'b', 'c'];
END_VAR

{Test}
METHOD PUBLIC Copare_same_ArrayWithLengt5_Expect_TRUE
VAR_TEMP
res : BOOL;
END_VAR
res := CompareArray(a0_4_abcde, a0_4_abcde, 5);
Equal(expected := TRUE, actual := res);

res := CompareArray(a2_6_abcde, a2_6_abcde, 5);
Equal(expected := TRUE, actual := res);
END_METHOD
Expand All @@ -32,25 +32,19 @@ NAMESPACE Simatic.Ax.Json
END_VAR
res := CompareArray(a0_4_abcde, a2_6_12345, 5);
Equal(expected := FALSE, actual := res);

res := CompareArray(a2_6_abcde, a0_4_12345, 5);
Equal(expected := FALSE, actual := res);

res := CompareArray(a0_4_abcde, a0_4_abcdf, 5);
Equal(expected := FALSE, actual := res);

END_METHOD


{Test}
METHOD PUBLIC Copare_different_ArrayWithLengt4_Expect_TRUE
VAR_TEMP
res : BOOL;
END_VAR

res := CompareArray(a0_4_abcde, a0_4_abcdf, 4);
Equal(expected := TRUE, actual := res);

END_METHOD

{Test}
Expand All @@ -60,7 +54,6 @@ NAMESPACE Simatic.Ax.Json
END_VAR
res := CompareArray(a0_4_abcde, a0_4_abcde, 4);
Equal(expected := TRUE, actual := res);

res := CompareArray(a2_6_abcde, a2_6_abcde, 4);
Equal(expected := TRUE, actual := res);
END_METHOD
Expand All @@ -81,7 +74,6 @@ NAMESPACE Simatic.Ax.Json
END_VAR
res := CompareArray(a0_4_abcde, a2_6_12345, 4);
Equal(expected := FALSE, actual := res);

res := CompareArray(a2_6_abcde, a0_4_12345, 4);
Equal(expected := FALSE, actual := res);
END_METHOD
Expand All @@ -93,35 +85,25 @@ NAMESPACE Simatic.Ax.Json
END_VAR
res := CompareArray(a0_4_abcde, a0_2_abc, 2);
Equal(expected := TRUE, actual := res);

res := CompareArray(a0_2_abc, a0_4_abcde, 2);
Equal(expected := TRUE, actual := res);

res := CompareArray(a0_4_abcde, a0_2_abc, 3);
Equal(expected := TRUE, actual := res);

res := CompareArray(a0_2_abc, a0_4_abcde, 3);
Equal(expected := TRUE, actual := res);

res := CompareArray(a0_4_abcde, a0_2_abc, 4);
Equal(expected := FALSE, actual := res);

res := CompareArray(a0_2_abc, a0_4_abcde, 4);
Equal(expected := FALSE, actual := res);

res := CompareArray(a0_4_abcde, a0_2_abc, 5);
Equal(expected := FALSE, actual := res);

res := CompareArray(a0_2_abc, a0_4_abcde, 5);
Equal(expected := FALSE, actual := res);

res := CompareArray(a0_4_abcde, a0_2_abc, 6);
Equal(expected := FALSE, actual := res);

res := CompareArray(a0_2_abc, a0_4_abcde, 6);
Equal(expected := FALSE, actual := res);

END_METHOD

END_CLASS
END_NAMESPACE

END_NAMESPACE

0 comments on commit 26fc4c8

Please sign in to comment.