-
Notifications
You must be signed in to change notification settings - Fork 108
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bugfix and added test for shared_ptr
- Loading branch information
1 parent
1f0dcf5
commit 4fa84ff
Showing
4 changed files
with
44 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#include <iostream> | ||
#include <memory> | ||
#include <rfl.hpp> | ||
#include <rfl/json.hpp> | ||
#include <source_location> | ||
#include <string> | ||
#include <vector> | ||
|
||
#include "test_unique_ptr.hpp" | ||
#include "write_and_read.hpp" | ||
|
||
namespace test_shared_ptr { | ||
|
||
struct Person { | ||
rfl::Rename<"firstName", std::string> first_name; | ||
rfl::Rename<"lastName", std::string> last_name = "Simpson"; | ||
std::shared_ptr<std::vector<Person>> children; | ||
}; | ||
|
||
void test() { | ||
std::cout << std::source_location::current().function_name() << std::endl; | ||
|
||
auto children = std::make_shared<std::vector<Person>>(); | ||
children->emplace_back(Person{.first_name = "Bart"}); | ||
children->emplace_back(Person{.first_name = "Lisa"}); | ||
children->emplace_back(Person{.first_name = "Maggie"}); | ||
|
||
const auto homer = | ||
Person{.first_name = "Homer", .children = std::move(children)}; | ||
|
||
write_and_read( | ||
homer, | ||
R"({"firstName":"Homer","lastName":"Simpson","children":[{"firstName":"Bart","lastName":"Simpson"},{"firstName":"Lisa","lastName":"Simpson"},{"firstName":"Maggie","lastName":"Simpson"}]})"); | ||
} | ||
} // namespace test_shared_ptr |
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,4 @@ | ||
namespace test_shared_ptr { | ||
void test(); | ||
} | ||
|
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