74 lines
2 KiB
C++
74 lines
2 KiB
C++
////////////////////////////////////////////////////////////////////////////////
|
|
// (c) Copyright, Ubisoft Entertainment Inc. || Created by Harbour //
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
#include "tests/config.h"
|
|
#include "tests/fixture/memoryCheckFixture.h"
|
|
#include <ubiservices/core/JSON/jsonWriter.h>
|
|
#include <ubiservices/services/parameters/parametersGroupInfo.h>
|
|
|
|
namespace US_NS {;
|
|
US_DEFINE_TEST(TestParamatersGroup);
|
|
|
|
typedef LeakChecker UNIT_PARAMETERS;
|
|
|
|
#if !defined(US_DLL)
|
|
namespace ParametersGroupInfoPrivate
|
|
{
|
|
bool extractData(const Json& source, ParametersGroupInfo& target);
|
|
}
|
|
#endif
|
|
|
|
#if !defined(US_DLL)
|
|
TEST_F(UNIT_PARAMETERS, LOCAL_JsonParseParametersGroupInfo)
|
|
{
|
|
JsonWriter writer;
|
|
{
|
|
#if defined(US_SDK_S2S)
|
|
writer["revision"] = 0;
|
|
#else
|
|
JsonWriter relatedPopulation;
|
|
relatedPopulation["name"] = "dummyName1";
|
|
relatedPopulation["subject"] = "dummySubject1";
|
|
writer["relatedPopulation"] = relatedPopulation.getJson();
|
|
#endif
|
|
}
|
|
|
|
{
|
|
ParametersGroupInfo parametersGroup;
|
|
EXPECT_FALSE(ParametersGroupInfoPrivate::extractData(Json(writer.renderContent()), parametersGroup));
|
|
}
|
|
|
|
// Adds missing mandatory fields
|
|
{
|
|
JsonWriter fields;
|
|
fields["platform"] = "PC";
|
|
fields["uplayGameCode"] = "AVA";
|
|
fields["environment"] = "dev";
|
|
#if defined(US_SDK_S2S)
|
|
writer["noPopulation"] = fields.getJson();
|
|
#else
|
|
writer["fields"] = fields.getJson();
|
|
#endif
|
|
}
|
|
|
|
{
|
|
ParametersGroupInfo parametersGroup;
|
|
EXPECT_TRUE(ParametersGroupInfoPrivate::extractData(Json(writer.renderContent()), parametersGroup));
|
|
}
|
|
|
|
// Adds Extra field
|
|
{
|
|
JsonWriter extra;
|
|
extra["dummyExtraField"] = "dummValue";
|
|
writer["extraField"] = extra.getJson();
|
|
}
|
|
|
|
{
|
|
ParametersGroupInfo parametersGroup;
|
|
EXPECT_TRUE(ParametersGroupInfoPrivate::extractData(Json(writer.renderContent()), parametersGroup));
|
|
}
|
|
|
|
}
|
|
|
|
#endif // !defined(US_DLL)
|
|
};
|