void stats_register_control_commands(void) { control_register_command("STATS", control_connection_send_stats, NULL); control_register_command("RESET_STATS", control_connection_reset_stats, NULL); control_register_command("QUERY", process_query_command, NULL); }
Test(control_cmds, test_replace_existing_command) { control_register_command("REPLACE", _original_replace, (gpointer)0xbaadf00d); ControlCommand *cmd = control_find_command("REPLACE"); ControlCommand expected_original = { .func = _original_replace, .command_name = "REPLACE", .user_data = (gpointer)0xbaadf00d }; _assert_control_command_eq(cmd, &expected_original); control_replace_command("REPLACE", _new_replace, (gpointer)0xd006f00d); ControlCommand *new_cmd = control_find_command("REPLACE"); ControlCommand expected_new = { .func = _new_replace, .command_name = "REPLACE", .user_data = (gpointer) 0xd006f00d }; _assert_control_command_eq(new_cmd, &expected_new); } Test(control_cmds, test_replace_non_existing_command) { control_replace_command("REPLACE", _new_replace, (gpointer)0xd006f00d); ControlCommand *new_cmd = control_find_command("REPLACE"); ControlCommand expected_new = { .func = _new_replace, .command_name = "REPLACE", .user_data = (gpointer) 0xd006f00d }; _assert_control_command_eq(new_cmd, &expected_new); }