This commit is contained in:
@@ -74,8 +74,58 @@ void device_create_set_state_free(const char *capability, const char *test_name_
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
void device_create_three_devices_remove_second(const char *capability)
|
||||
void device_create_three_devices_remove_second(const char *capability, const char *test_array)
|
||||
{
|
||||
struct json_object *root_node;
|
||||
devices_manager_t *dm;
|
||||
int ret;
|
||||
char *device_serialized;
|
||||
|
||||
dm = devices_manager_new();
|
||||
ASSERT_NOT_NULL(dm);
|
||||
|
||||
// Create a New Entry 1.
|
||||
root_node = json_object_new_object();
|
||||
json_object_object_add(root_node, k_entry_name, json_object_new_string("test1"));
|
||||
|
||||
ret = devices_manager_create(dm, capability, root_node);
|
||||
/* Clean the json object. */
|
||||
json_object_put(root_node);
|
||||
ASSERT_EQUAL_INT(ret, 0);
|
||||
|
||||
// Create a New Entry 2.
|
||||
root_node = json_object_new_object();
|
||||
json_object_object_add(root_node, k_entry_name, json_object_new_string("test2"));
|
||||
|
||||
ret = devices_manager_create(dm, capability, root_node);
|
||||
/* Clean the json object. */
|
||||
json_object_put(root_node);
|
||||
ASSERT_EQUAL_INT(ret, 0);
|
||||
|
||||
// Create a New Entry 3.
|
||||
root_node = json_object_new_object();
|
||||
json_object_object_add(root_node, k_entry_name, json_object_new_string("test3"));
|
||||
|
||||
ret = devices_manager_create(dm, capability, root_node);
|
||||
/* Clean the json object. */
|
||||
json_object_put(root_node);
|
||||
ASSERT_EQUAL_INT(ret, 0);
|
||||
|
||||
// Remove ID 1.
|
||||
root_node = json_object_new_object();
|
||||
json_object_object_add(root_node, k_entry_id, json_object_new_int(2));
|
||||
ret = devices_manager_delete(dm, capability, root_node);
|
||||
json_object_put(root_node);
|
||||
ASSERT_EQUAL_INT(ret, 0);
|
||||
|
||||
device_serialized = devices_manager_get(dm, capability);
|
||||
// printf ("device: %s\n", device_serialized);
|
||||
ASSERT_EQUAL_STR(device_serialized, test_array);
|
||||
free(device_serialized);
|
||||
|
||||
// Free the Object.
|
||||
devices_manager_free(dm);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
|
||||
#define kSprinklerTestNameTrue "{ \"id\": 1, \"name\": \"test_name\", \"state\": true }"
|
||||
#define kSprinklerTestNameFalse "{ \"id\": 1, \"name\": \"test_name\", \"state\": false }"
|
||||
#define kSprinklerTestRemove "[ { \"id\": 1, \"name\": \"test1\", \"state\": false }, { \"id\": 3, \"name\": \"test3\", \"state\": false } ]"
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
@@ -39,9 +40,9 @@ TEST("Sprinkler - create set_state free\t")
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
TEST("Sprinkler - create 3 devices and remove second\t")
|
||||
TEST("Sprinkler - create 3 device remove 2\t")
|
||||
{
|
||||
device_create_three_devices_remove_second(kSprinklerEntry);
|
||||
device_create_three_devices_remove_second(kSprinklerEntry, kSprinklerTestRemove);
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
Reference in New Issue
Block a user