Skip to content

Commit dfd230b

Browse files
committed
Incorporate review feedback
1 parent 51d2293 commit dfd230b

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

examples/cpp/CMakeLists.txt

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,15 @@ FetchContent_Declare(
1919

2020
FetchContent_MakeAvailable(Catch2 cpprealm)
2121

22-
# add_executable(examples testHelpers.hpp testHelpersTests.cpp authentication.cpp define-object-model.cpp examples.cpp flexible-sync.cpp supported-types.cpp)
23-
add_executable(examples authentication.cpp define-object-model.cpp examples.cpp filter-data.cpp flexible-sync.cpp quick-start.cpp supported-types.cpp)
22+
add_executable(examples
23+
authentication.cpp
24+
define-object-model.cpp
25+
examples.cpp
26+
filter-data.cpp
27+
flexible-sync.cpp
28+
quick-start.cpp
29+
supported-types.cpp
30+
)
2431

2532
target_link_libraries(examples PRIVATE Catch2::Catch2WithMain)
2633
target_link_libraries(examples PRIVATE cpprealm)

examples/cpp/quick-start.cpp

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
#include <catch2/catch_test_macros.hpp>
2-
//#include <string>
32
#include <thread>
43
#include <future>
54
#include <string>
6-
#include <unistd.h>
75
// :snippet-start: includes
86
#include <cpprealm/sdk.hpp>
97
// :snippet-end:
@@ -12,7 +10,7 @@
1210
// "terms": {
1311
// "Local_": "",
1412
// "Sync_": "",
15-
// "charUserId": "userId"
13+
// "userId.c_str()": "userId"
1614
// }
1715
// }
1816

@@ -122,7 +120,7 @@ TEST_CASE("sync quick start", "[realm][write][sync]") {
122120
auto realm = synced_realm_ref.resolve();
123121
// :remove-start:
124122
// Remove any existing subscriptions before adding the one for this example
125-
auto clearInitialSubscriptions = realm.subscriptions().update([](realm::mutable_sync_subscription_set &subs) {
123+
auto clearInitialSubscriptions = realm.subscriptions().update([](auto &subs) {
126124
subs.clear();
127125
}).get_future().get();
128126
CHECK(clearInitialSubscriptions == true);
@@ -144,13 +142,11 @@ TEST_CASE("sync quick start", "[realm][write][sync]") {
144142
// The C++ SDK is currently missing a constructor to store a std::string
145143
// So convert the userId std::string to a character array for persisting.
146144
// TODO: Remove this and use the userId directly when the constructor is added.
147-
char* charUserId = strcpy(new char[userId.length() + 1], userId.c_str());
148-
149145
// :snippet-start: write-to-synced-realm
150146
auto todo = Sync_Todo {
151147
.name = "Create a Sync todo item",
152148
.status = "In Progress",
153-
.ownerId = charUserId
149+
.ownerId = userId.c_str()
154150
};
155151

156152
realm.write([&realm, &todo] {

0 commit comments

Comments
 (0)