-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #89 from simatic-ax/Update_to_SDK2311
Update to sdk2311
- Loading branch information
Showing
21 changed files
with
1,863 additions
and
1,601 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
78 changes: 36 additions & 42 deletions
78
test/Deserializer/GetValues/Test_GetValues_BasicDataTypes.st
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 |
---|---|---|
@@ -1,50 +1,44 @@ | ||
USING Simatic.Ax.Conversion; | ||
USING AxUnit.Assert; | ||
USING System.Strings; | ||
using Simatic.Ax.Json; | ||
|
||
USING Simatic.Ax.Json; | ||
|
||
NAMESPACE Deserializer | ||
NAMESPACE GetValues | ||
|
||
{TestFixture} | ||
CLASS Test_Deserializer_GetValues_BasicDataTypes | ||
VAR protected | ||
deserializer : Deserializer; | ||
|
||
buffer : ARRAY[0..999] OF CHAR; | ||
key: STRING; | ||
value: STRING; | ||
END_VAR | ||
|
||
{Test} | ||
Method Public Test_FindValue_in_JSON_SimpleEntries | ||
VAR | ||
JSON_Entry: STRING := '{"key": "Element1", "key 2": "something", "key 3": 456, "Key 4": 1234 }'; | ||
|
||
len:DINT; | ||
keyFound: BOOL; | ||
END_VAR | ||
|
||
len:= Strings.ToArray.OfCharCount(str := JSON_Entry, arr := buffer); | ||
deserializer.buffer := REF(buffer); | ||
|
||
key := 'key'; | ||
keyFound := deserializer.TryParse( key, value); | ||
Equal(8, LengthOf(value)); | ||
Equal('Element1', value); | ||
|
||
key := 'Key 4'; | ||
keyFound := deserializer.TryParse( key, value); | ||
Equal(4, LengthOf(value)); | ||
Equal('1234', value); | ||
|
||
key := 'not a key'; | ||
keyFound := deserializer.TryParse( key, value); | ||
Equal('', value); | ||
END_Method | ||
|
||
END_CLASS | ||
NAMESPACE GetValues | ||
|
||
{TestFixture} | ||
CLASS Test_Deserializer_GetValues_BasicDataTypes | ||
VAR PROTECTED | ||
deserializer : Deserializer; | ||
buffer : ARRAY[0..999] OF CHAR; | ||
key : STRING; | ||
value : STRING; | ||
END_VAR | ||
|
||
{Test} | ||
METHOD PUBLIC Test_FindValue_in_JSON_SimpleEntries | ||
VAR | ||
JSON_Entry : STRING := '{"key": "Element1", "key 2": "something", "key 3": 456, "Key 4": 1234 }'; | ||
len : DINT; | ||
keyFound : BOOL; | ||
END_VAR | ||
len := Strings.ToArray.OfCharCount(str := JSON_Entry, arr := buffer); | ||
deserializer.buffer := REF(buffer); | ||
key := 'key'; | ||
keyFound := deserializer.TryParse(key, value); | ||
Equal(8, LengthOf(value)); | ||
Equal('Element1', value); | ||
key := 'Key 4'; | ||
keyFound := deserializer.TryParse(key, value); | ||
Equal(4, LengthOf(value)); | ||
Equal('1234', value); | ||
key := 'not a key'; | ||
keyFound := deserializer.TryParse(key, value); | ||
Equal('', value); | ||
END_METHOD | ||
END_CLASS | ||
|
||
END_NAMESPACE | ||
|
||
END_NAMESPACE | ||
END_NAMESPACE |
Oops, something went wrong.