Skip to content

Commit 1f3bd2c

Browse files
committed
test/integration/cmake: update project changes
1 parent 417f4a7 commit 1f3bd2c

5 files changed

Lines changed: 122 additions & 0 deletions

File tree

test/integration/cmake/cmake_test.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,9 +143,31 @@ func TestCMakeProjects(t *testing.T) {
143143
}
144144
}
145145
}
146+
// Test updating for just "cpp-flat" using content from "update-cpp-flat" folder.
147+
if project == "cpp-flat" {
148+
t.Logf("**** Update project cpp-flat (task.fbs and main.cpp) ****")
149+
cmake.CopyDir(wd, filepath.Join("update-cpp-flat", "."), filepath.Join(confDir))
150+
if multiConfigBuild {
151+
configs := []string{"Release", "Debug"}
152+
for _, config := range configs {
153+
if stdOut, stdErr, err := conf.BuildDefaultsWithConfig(config); err != nil {
154+
t.Fatalf("cmake build after update (configuration %s) failed: \n%s\n%s\n%s", config, stdOut, stdErr, err)
155+
} else {
156+
t.Logf("build after update (configuration %s) output:\n%s", config, string(stdOut))
157+
}
158+
}
159+
} else {
160+
if stdOut, stdErr, err := conf.BuildDefaults(); err != nil {
161+
t.Fatalf("cmake build after update failed: \n%s\n%s\n%s", stdOut, stdErr, err)
162+
} else {
163+
t.Logf("build after update output:\n%s", string(stdOut))
164+
}
165+
}
166+
}
146167
}
147168
}
148169
}
170+
149171
}
150172

151173
for _, singleGenerator := range singleGenerators {
@@ -155,3 +177,6 @@ func TestCMakeProjects(t *testing.T) {
155177
run(multiGenerator, true)
156178
}
157179
}
180+
181+
func TestCMakeProjectModify(t *testing.T) {
182+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
cmake_minimum_required(VERSION 3.14)
2+
3+
project(objectbox-generator-cmake-cpp-flat CXX)
4+
5+
include(../common.cmake)
6+
7+
add_executable(objectbox-test main.cpp)
8+
target_link_libraries(objectbox-test objectbox)
9+
10+
set_target_properties(objectbox-test PROPERTIES
11+
CXX_STANDARD 14
12+
CXX_STANDARD_REQUIRED YES
13+
)
14+
15+
# Variants:
16+
# - multiple add_obx_schema calls on same target
17+
# - single add_obx_schema call adding two schemas
18+
# - use OUTPUT_DIR_HEADERS (without OUTPUT_DIR)
19+
if (DO_INSOURCE)
20+
add_obx_schema(
21+
TARGET
22+
objectbox-test
23+
SCHEMA_FILES
24+
task.fbs
25+
monster.fbs
26+
person.fbs
27+
INSOURCE
28+
OUTPUT_DIR_MODEL_JSON model
29+
OUTPUT_DIR_HEADERS
30+
include2
31+
)
32+
target_include_directories(objectbox-test PRIVATE include2)
33+
else()
34+
add_obx_schema(
35+
TARGET
36+
objectbox-test
37+
SCHEMA_FILES
38+
task.fbs
39+
monster.fbs
40+
person.fbs
41+
)
42+
endif()
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
2+
#define OBX_CPP_FILE
3+
4+
5+
#include "objectbox.hpp"
6+
7+
#include "objectbox-model.h"
8+
#include "task.obx.hpp"
9+
#include "monster.obx.hpp"
10+
#include "person.obx.hpp"
11+
12+
#include <cinttypes>
13+
14+
int main(int argc, char* args[])
15+
{
16+
// create_obx_model() provided by objectbox-model.h
17+
// obx interface contents provided by objectbox.hpp
18+
obx::Store store(create_obx_model());
19+
obx::Box<Task> box(store);
20+
21+
Task my_task{};
22+
my_task.text = "Buy milk";
23+
obx_id id = box.put(my_task); // Create
24+
25+
std::unique_ptr<Task> task = box.get(id); // Read
26+
if (task) {
27+
task->text += " & some bread";
28+
box.put(*task); // Update
29+
}
30+
31+
printf("Your task has ID=%" PRIu64 ", text=%s\n, text2=%s\n",
32+
id,
33+
box.get(id)->text.c_str(),
34+
box.get(id)->text2.c_str());
35+
36+
obx::Box<Person> person_box(store);
37+
Person my_person{};
38+
obx_id person_id = person_box.put(my_person); // Create
39+
40+
printf("Your person has ID=%" PRIu64, person_id);
41+
42+
return 0;
43+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
table Person {
2+
id: ulong;
3+
name: string;
4+
age: int;
5+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
table Task {
2+
id: ulong;
3+
text: string;
4+
text2: string;
5+
date_created: ulong;
6+
date_finished: ulong;
7+
}

0 commit comments

Comments
 (0)