|
| 1 | +#include "DcTestProperty5.h" |
| 2 | + |
| 3 | +#include "DataConfig/Automation/DcAutomation.h" |
| 4 | +#include "DataConfig/Automation/DcAutomationUtils.h" |
| 5 | +#include "DataConfig/Extra/Misc/DcTestCommon.h" |
| 6 | +#include "DataConfig/Json/DcJsonReader.h" |
| 7 | + |
| 8 | +DC_TEST("DataConfig.Core.Property.Defaults") |
| 9 | +{ |
| 10 | + FString Str = TEXT(R"( |
| 11 | + { |
| 12 | + "StrFieldWithDefault" : "Bar", |
| 13 | + "IntFieldWithDefault" : 123, |
| 14 | +
|
| 15 | + "StrArrFieldWithDefault" : ["One", "Two", "Three", "Four"], |
| 16 | + "StrSetFieldWithDefault" : ["Foo", "Bar"], |
| 17 | + "StringIntMapFieldWithDefault" : { |
| 18 | + "Five" : 5, |
| 19 | + "Ten" : 10 |
| 20 | + } |
| 21 | + } |
| 22 | + )"); |
| 23 | + |
| 24 | + FDcJsonReader Reader(Str); |
| 25 | + FDcTestStructWithDefaults Dest; |
| 26 | + |
| 27 | + UTEST_OK("Deserialize With Defaults", DcAutomationUtils::DeserializeFrom(&Reader, FDcPropertyDatum(&Dest))); |
| 28 | + |
| 29 | + FDcTestStructWithDefaults Expect; |
| 30 | + Expect.StrFieldWithDefault = "Bar"; |
| 31 | + Expect.IntFieldWithDefault = 123; |
| 32 | + |
| 33 | + Expect.StrArrFieldWithDefault = {"One", "Two", "Three", "Four"}; |
| 34 | + Expect.StrSetFieldWithDefault = {"Foo", "Bar"}; |
| 35 | + Expect.StringIntMapFieldWithDefault = { |
| 36 | + {"Five", 5}, |
| 37 | + {"Ten", 10}, |
| 38 | + }; |
| 39 | + |
| 40 | + UTEST_OK("Deserialize With Defaults", DcAutomationUtils::TestReadDatumEqual(FDcPropertyDatum(&Dest), FDcPropertyDatum(&Expect))); |
| 41 | + |
| 42 | + return true; |
| 43 | +} |
0 commit comments