Test(stomp_proto, test_generate_gstring_from_frame) { stomp_frame frame; GString *actual; stomp_frame_init(&frame, "SEND", sizeof("SEND")); stomp_frame_add_header(&frame, "header_name", "header_value"); stomp_frame_set_body(&frame, "body", sizeof("body")); actual = create_gstring_from_frame(&frame); cr_assert_str_eq(actual->str, "SEND\nheader_name:header_value\n\nbody", "Generated stomp frame does not match"); stomp_frame_deinit(&frame); };
int stomp_write(stomp_connection *connection, stomp_frame *frame) { GString *data; if (!stomp_check_for_frame(connection)) return FALSE; data = create_gstring_from_frame(frame); if (!write_gstring_to_socket(connection->socket, data)) { msg_error("Write error, partial write", NULL); stomp_frame_deinit(frame); g_string_free(data, TRUE); return FALSE; } g_string_free(data, TRUE); stomp_frame_deinit(frame); return TRUE; }