Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/include/ConfigDB/Union.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ class Union : public Object
*/
void setTag(Tag tag)
{
if(!writeCheck()) {
return;
}
assert(tag < typeinfo().objectCount);
disposeArrays();
memset(getDataPtr(), 0, typeinfo().structSize);
Expand All @@ -63,6 +66,9 @@ class Union : public Object
*/
void clear()
{
if(!writeCheck()) {
return;
}
disposeArrays();
memset(getDataPtr(), 0, typeinfo().structSize);
getPropertyData(0)->uint8 = 0;
Expand Down
3 changes: 2 additions & 1 deletion test/modules/Streaming.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,8 @@ class StreamingTest : public TestGroup
{
// An un-named root object should produce same output (i.e. options are ignored)
String expectedContent =
F("{\"int_array\":[13,28,39,40],\"string_array\":[\"a\",\"b\",\"c\"],\"object_array\":[],\"color\":"
F("{\"simple-union\":{\"obj2\":{\"value\":12}},\"int_array\":[13,28,39,40],\"string_array\":[\"a\","
"\"b\",\"c\"],\"object_array\":[],\"color\":"
"\"red\",\"simple-bool\":true,\"simple-string\":\"donkey\",\"simple-int\":100,\"simple-float\":3."
"1415927}");
TestConfig::Root root(database);
Expand Down
5 changes: 5 additions & 0 deletions test/resource/array_test_default.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
{
"simple-union": {
"obj1": {
"value": 0
}
},
"int_array": [
1,
2,
Expand Down
2 changes: 1 addition & 1 deletion test/resource/async-update-result.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"int_array":[100,1],"string_array":["go","away"],"object_array":[{"intval":1,"stringval":"biscuit"},{"intval":2,"stringval":"cake"}],"color":"green","simple-bool":true,"simple-string":"gorilla","simple-int":100,"simple-float":1.2e8}
{"simple-union":{"obj1":{"value":0}},"int_array":[100,1],"string_array":["go","away"],"object_array":[{"intval":1,"stringval":"biscuit"},{"intval":2,"stringval":"cake"}],"color":"green","simple-bool":true,"simple-string":"gorilla","simple-int":100,"simple-float":1.2e8}
2 changes: 1 addition & 1 deletion test/resource/database1.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"int_array":[13,28,39,40],"string_array":["a","b","c"],"object_array":[],"color":"red","simple-bool":true,"simple-string":"donkey","simple-int":100,"simple-float":3.1415927,"array-store":[],"object-array-store":[]}
{"simple-union":{"obj2":{"value":12}},"int_array":[13,28,39,40],"string_array":["a","b","c"],"object_array":[],"color":"red","simple-bool":true,"simple-string":"donkey","simple-int":100,"simple-float":3.1415927,"array-store":[],"object-array-store":[]}
2 changes: 1 addition & 1 deletion test/resource/root1.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"int_array":[13,28,39,40],"string_array":["a","b","c"],"object_array":[],"color":"red","simple-bool":true,"simple-string":"donkey","simple-int":100,"simple-float":3.1415927}
{"simple-union":{"obj2":{"value":12}},"int_array":[13,28,39,40],"string_array":["a","b","c"],"object_array":[],"color":"red","simple-bool":true,"simple-string":"donkey","simple-int":100,"simple-float":3.1415927}
7 changes: 6 additions & 1 deletion test/resource/update1.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
{
"simple-bool": true,
"simple-int": 11111110101010
"simple-int": 11111110101010,
"simple-union": {
"obj2": {
"value": 12
}
}
}
31 changes: 31 additions & 0 deletions test/test-config.cfgdb
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,37 @@
"default": 3.141592654,
"maximum": 1.2e8
},
"simple-union": {
"oneOf": [
{
"type": "object",
"title": "obj1",
"properties": {
"value": {
"type": "integer"
}
}
},
{
"type": "object",
"title": "obj2",
"properties": {
"value": {
"type": "number"
}
}
},
{
"type": "object",
"title": "obj3",
"properties": {
"value": {
"type": "string"
}
}
}
]
},
"int_array": {
"type": "array",
"items": {
Expand Down
Loading