-
Notifications
You must be signed in to change notification settings - Fork 0
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
9 changed files
with
107 additions
and
32 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
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 |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#include "unit_test_dto_person.h" | ||
#include <vector> | ||
#include <wsjcpp_core.h> | ||
#include <wsjcpp_dto.h> | ||
|
||
REGISTRY_WSJCPP_UNIT_TEST(UnitTestDtoPerson) | ||
|
||
UnitTestDtoPerson::UnitTestDtoPerson() | ||
: WsjcppUnitTestBase("UnitTestDtoPerson") { | ||
} | ||
|
||
// --------------------------------------------------------------------- | ||
|
||
void UnitTestDtoPerson::init() { | ||
// nothing | ||
} | ||
|
||
// --------------------------------------------------------------------- | ||
|
||
class WsjcppDtoPerson : public WsjcppDto { | ||
public: | ||
WsjcppDtoPerson() : WsjcppDto("person", "Person") { | ||
requireField<WsjcppDtoString>("name", "Name of person"); | ||
optionalField<WsjcppDtoInteger>("age", "Age of person"); | ||
}; | ||
}; | ||
|
||
// --------------------------------------------------------------------- | ||
|
||
bool UnitTestDtoPerson::run() { | ||
bool bTestSuccess = true; | ||
WsjcppDtoPerson p; | ||
p.setFieldStringValue("name", "John Smith"); | ||
p.setFieldIntegerValue("age", 21); | ||
std::string sJsonGot = p.toJson().dump(); | ||
std::string sJsonExpected = "{\"age\":21,\"name\":\"John Smith\"}"; | ||
compareS(bTestSuccess, "WsjcppDtoPerson", sJsonGot, sJsonExpected); | ||
return bTestSuccess; | ||
} | ||
|
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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#ifndef UNIT_TEST_DTO_PERSON_H | ||
#define UNIT_TEST_DTO_PERSON_H | ||
|
||
#include <wsjcpp_unit_tests.h> | ||
|
||
// Description: TODO | ||
class UnitTestDtoPerson : public WsjcppUnitTestBase { | ||
public: | ||
UnitTestDtoPerson(); | ||
virtual void init(); | ||
virtual bool run(); | ||
}; | ||
|
||
#endif // UNIT_TEST_DTO_PERSON_H | ||
|
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