-
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.
- Loading branch information
Showing
6 changed files
with
108 additions
and
73 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
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
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,87 +1,87 @@ | ||
USING AxUnit.Assert; | ||
USING System.Strings; | ||
USING Simatic.Ax.Conversion; | ||
// USING AxUnit.Assert; | ||
// USING System.Strings; | ||
// USING Simatic.Ax.Conversion; | ||
|
||
NAMESPACE Simatic.Ax.Json | ||
{TestFixture} | ||
CLASS TestJsonObject | ||
// NAMESPACE Simatic.Ax.Json | ||
// {TestFixture} | ||
// CLASS TestJsonObject | ||
|
||
VAR PROTECTED | ||
e : JsonDInt := (Value := 999, Key := 'test'); | ||
e2 : JsonDInt := (Value := -999, Key := 'second_key'); | ||
e3 : JsonDInt := (Value := 1, Key := '3rd'); | ||
o : JsonObject := (Key := 'Name'); | ||
doc : JsonDocument; | ||
cmpBuff : ARRAY[0..399] OF CHAR; | ||
len : DINT; | ||
buffer : ARRAY[0..200] OF CHAR; | ||
END_VAR | ||
// VAR PROTECTED | ||
// e : JsonDInt := (Value := 999, Key := 'test'); | ||
// e2 : JsonDInt := (Value := -999, Key := 'second_key'); | ||
// e3 : JsonDInt := (Value := 1, Key := '3rd'); | ||
// o : JsonObject := (Key := 'Name'); | ||
// doc : JsonDocument; | ||
// cmpBuff : ARRAY[0..399] OF CHAR; | ||
// len : DINT; | ||
// buffer : ARRAY[0..200] OF CHAR; | ||
// END_VAR | ||
|
||
{Test} | ||
METHOD PUBLIC Test_Empty_object_ToString_Expect_empty_object | ||
VAR_TEMP | ||
_expStr : STRING; | ||
_actStr : STRING; | ||
END_VAR | ||
// {Test} | ||
// METHOD PUBLIC Test_Empty_object_ToString_Expect_empty_object | ||
// VAR_TEMP | ||
// _expStr : STRING; | ||
// _actStr : STRING; | ||
// END_VAR | ||
|
||
// {} | ||
_expStr := '{}'; | ||
_actStr := o.ToString(); | ||
Equal(expected := _actStr, actual := _expStr); | ||
END_METHOD | ||
// // {} | ||
// _expStr := '{}'; | ||
// _actStr := o.ToString(); | ||
// Equal(expected := _actStr, actual := _expStr); | ||
// END_METHOD | ||
|
||
{Test} | ||
METHOD PUBLIC Test_Object_with_one_element | ||
VAR_TEMP | ||
_expStr : STRING; | ||
_actStr : STRING; | ||
END_VAR | ||
o.AddElement(e); | ||
_expStr := '"Name": {"test": 999}'; | ||
_actStr := o.ToString(); | ||
Equal(expected := _actStr, actual := _expStr); | ||
END_METHOD | ||
// {Test} | ||
// METHOD PUBLIC Test_Object_with_one_element | ||
// VAR_TEMP | ||
// _expStr : STRING; | ||
// _actStr : STRING; | ||
// END_VAR | ||
// o.AddElement(e); | ||
// _expStr := '"Name": {"test": 999}'; | ||
// _actStr := o.ToString(); | ||
// Equal(expected := _actStr, actual := _expStr); | ||
// END_METHOD | ||
|
||
{Test} | ||
METHOD PUBLIC Test_Object_with_three_elements | ||
VAR_TEMP | ||
_expStr : STRING; | ||
_actStr : STRING; | ||
_i, _j : INT; | ||
END_VAR | ||
o.AddElement(e); | ||
o.AddElement(e2); | ||
o.AddElement(e3); | ||
_expStr := '"Name": {"test": 999, "second_key": -999, "3rd": 1}'; | ||
_expStr := StartOf(_expStr, 5); | ||
// {Test} | ||
// METHOD PUBLIC Test_Object_with_three_elements | ||
// VAR_TEMP | ||
// _expStr : STRING; | ||
// _actStr : STRING; | ||
// _i, _j : INT; | ||
// END_VAR | ||
// o.AddElement(e); | ||
// o.AddElement(e2); | ||
// o.AddElement(e3); | ||
// _expStr := '"Name": {"test": 999, "second_key": -999, "3rd": 1}'; | ||
// _expStr := StartOf(_expStr, 5); | ||
|
||
_i := LengthOf(_expStr); | ||
// _i := LengthOf(_expStr); | ||
|
||
|
||
|
||
_actStr := StartOf(o.ToString(), LengthOf(_expStr)); | ||
_j := LengthOf(_actStr); | ||
Equal(expected := _actStr, actual := _expStr); | ||
END_METHOD | ||
// _actStr := StartOf(o.ToString(), LengthOf(_expStr)); | ||
// _j := LengthOf(_actStr); | ||
// Equal(expected := _actStr, actual := _expStr); | ||
// END_METHOD | ||
|
||
{Test} | ||
METHOD PUBLIC Test_Serialize_Object_with_three_elements | ||
VAR_TEMP | ||
_expStr : STRING; | ||
_actStr : STRING; | ||
_i, _j : INT; | ||
_res : BOOL; | ||
END_VAR | ||
THIS.Test_Object_with_three_elements(); | ||
_expStr := '"Name": {"test": 999, "second_key": -999, "3rd": 1}'; | ||
// {Test} | ||
// METHOD PUBLIC Test_Serialize_Object_with_three_elements | ||
// VAR_TEMP | ||
// _expStr : STRING; | ||
// _actStr : STRING; | ||
// _i, _j : INT; | ||
// _res : BOOL; | ||
// END_VAR | ||
// THIS.Test_Object_with_three_elements(); | ||
// _expStr := '"Name": {"test": 999, "second_key": -999, "3rd": 1}'; | ||
|
||
doc.buffer := REF(buffer); | ||
o.Serialize(REF(doc)); | ||
// doc.buffer := REF(buffer); | ||
// o.Serialize(REF(doc)); | ||
|
||
len := Strings.ToArray.OfCharCount(str := _expStr, arr := cmpBuff); | ||
_res := CompareArray(first := buffer, scnd := cmpBuff, count := TO_INT(len)); | ||
Equal(expected := TRUE, actual := _res); | ||
END_METHOD | ||
// len := Strings.ToArray.OfCharCount(str := _expStr, arr := cmpBuff); | ||
// _res := CompareArray(first := buffer, scnd := cmpBuff, count := TO_INT(len)); | ||
// Equal(expected := TRUE, actual := _res); | ||
// END_METHOD | ||
|
||
END_CLASS | ||
END_NAMESPACE | ||
// END_CLASS | ||
// END_NAMESPACE |