int main() { xorn_revision_t rev0, rev1; xorn_object_t ob; memset(&text_data, 0, sizeof text_data); text_data.text.s = caption; text_data.text.len = strlen(caption) + 1; rev0 = xorn_new_revision(NULL); assert(rev0 != NULL); xorn_finalize_revision(rev0); rev1 = xorn_new_revision(rev0); assert(rev1 != NULL); ob = xornsch_add_text(rev1, &text_data); assert(ob != NULL); xorn_finalize_revision(rev1); const struct xornsch_text *text_return = xornsch_get_text_data(rev1, ob); assert(text_return != NULL); assert(text_return->text.s != NULL); assert(text_return->text.s != caption); assert(text_return->text.len == strlen(caption) + 1); assert(memcmp(text_return->text.s, caption, text_return->text.len) == 0); xorn_free_revision(rev1); xorn_free_revision(rev0); return 0; }
int main(void) { xorn_revision_t rev0, rev1, rev2; xorn_object_t ob; memset(&line_data, 0, sizeof line_data); line_data.pos.x = 0; line_data.pos.y = 1; line_data.size.x = 3; line_data.size.y = 2; line_data.color = 3; line_data.line.width = 1; memset(&box_data, 0, sizeof box_data); box_data.pos.x = 1; box_data.pos.y = 1; box_data.size.x = 2; box_data.size.y = 2; box_data.color = 3; box_data.line.width = 1; rev0 = xorn_new_revision(NULL); assert(rev0 != NULL); assert(xorn_revision_is_transient(rev0) == true); xorn_finalize_revision(rev0); assert(xorn_revision_is_transient(rev0) == false); rev1 = xorn_new_revision(rev0); assert(rev1 != NULL); assert(xorn_revision_is_transient(rev1) == true); ob = xornsch_add_line(rev1, &line_data, NULL); assert(ob != NULL); xorn_finalize_revision(rev1); assert(xorn_revision_is_transient(rev1) == false); try_modify(rev1, ob, false); rev2 = xorn_new_revision(rev1); assert(rev2 != NULL); assert(xorn_revision_is_transient(rev2) == true); try_modify(rev2, ob, true); xorn_finalize_revision(rev2); assert(xorn_revision_is_transient(rev2) == false); xorn_free_revision(rev2); xorn_free_revision(rev1); xorn_free_revision(rev0); return 0; }
static int Revision_init(Revision *self, PyObject *args, PyObject *kwds) { PyObject *parent = NULL; static char *kwlist[] = { "rev", NULL }; if (!PyArg_ParseTupleAndKeywords( args, kwds, "|O:Revision", kwlist, &parent)) return -1; if (!parent || parent == Py_None) return 0; if (!PyObject_TypeCheck(parent, &RevisionType)) { char buf[BUFSIZ]; snprintf(buf, BUFSIZ, "Revision() argument 1 must be %.50s, " "not %.50s", RevisionType.tp_name, parent->ob_type->tp_name); PyErr_SetString(PyExc_TypeError, buf); return -1; } xorn_revision_t rev = xorn_new_revision(((Revision *)parent)->rev); if (rev == NULL) { PyErr_NoMemory(); return -1; } xorn_free_revision(self->rev); self->rev = rev; return 0; }
int main(void) { xorn_revision_t rev; struct xornsch_text data; xorn_object_t ob; char *s; rev = xorn_new_revision(NULL); memset(&data, 0, sizeof data); data.text.s = "Hello"; data.text.len = 5; ob = xornsch_add_text(rev, &data); data.text.s = "World"; data.text.len = 5; xornsch_set_text_data(rev, ob, &data); s = strdup("!"); data.text.s = s; data.text.len = 1; xornsch_set_text_data(rev, ob, &data); free(s); xorn_free_revision(rev); return 0; }
int main(void) { xorn_revision_t rev0, rev1, rev2, rev3; xorn_object_t ob0, ob1a, ob1b; xorn_selection_t sel0, sel1; xorn_revision_t rev4; xorn_object_t *objects; size_t count; setup(&rev0, &rev1, &rev2, &rev3, &ob0, &ob1a, &ob1b); rev4 = xorn_new_revision(rev2); assert(rev4 != NULL); sel0 = xorn_select_all(rev3); assert(sel0 != NULL); sel1 = xorn_copy_objects(rev4, rev2, sel0, NULL); assert(sel1 != NULL); xorn_finalize_revision(rev4); assert(xorn_object_is_selected(rev4, sel0, ob0)); assert(!xorn_object_is_selected(rev4, sel0, ob1a)); assert(xorn_object_is_selected(rev4, sel0, ob1b)); assert(!xorn_object_is_selected(rev4, sel1, ob0)); assert(!xorn_object_is_selected(rev4, sel1, ob1a)); assert(!xorn_object_is_selected(rev4, sel1, ob1b)); assert(xorn_get_objects(rev4, &objects, &count) == 0); assert(objects != NULL); assert(count == 5); assert(objects[0] == ob0); assert(objects[1] == ob1a); assert(objects[2] == ob1b); assert(!xorn_object_is_selected(rev4, sel0, objects[3])); assert(!xorn_object_is_selected(rev4, sel0, objects[4])); assert(xorn_object_is_selected(rev4, sel1, objects[3])); assert(xorn_object_is_selected(rev4, sel1, objects[4])); free(objects); xorn_free_selection(sel1); xorn_free_selection(sel0); xorn_free_revision(rev4); xorn_free_revision(rev3); xorn_free_revision(rev2); xorn_free_revision(rev1); xorn_free_revision(rev0); return 0; }
int main() { xorn_revision_t rev0, rev1, rev2; struct xornsch_line line_data; xorn_object_t ob; rev0 = xorn_new_revision(NULL); assert(rev0 != NULL); xorn_finalize_revision(rev0); rev1 = xorn_new_revision(rev0); assert(rev1 != NULL); memset(&line_data, 0, sizeof line_data); line_data.pos.x = 0; line_data.pos.y = 1; line_data.size.x = 3; line_data.size.y = 2; line_data.color = 3; line_data.line.width = 1; ob = xorn_add_object(rev1, xorn_obtype_none, &line_data); assert(ob == NULL); ob = xorn_add_object(rev1, xornsch_obtype_line, &line_data); assert(ob != NULL); xorn_finalize_revision(rev1); rev2 = xorn_new_revision(rev1); assert(rev2 != NULL); assert(xorn_set_object_data(rev2, ob, xorn_obtype_none, &line_data) == -1); assert(xorn_set_object_data(rev2, ob, xornsch_obtype_line, &line_data) == 0); xorn_finalize_revision(rev2); xorn_free_revision(rev2); xorn_free_revision(rev1); xorn_free_revision(rev0); return 0; }
static void check_order(void) { xorn_revision_t rev0, rev1, rev2, rev3, rev4; xorn_object_t ob0, ob1a, ob1b, ob2; struct xornsch_arc arc_data; setup(&rev0, &rev1, &rev2, &rev3, &ob0, &ob1a, &ob1b); assert_object_location_fails(rev0, ob0); assert_object_location_fails(rev0, ob1a); assert_object_location_fails(rev0, ob1b); assert_object_location(rev1, ob0, NULL, 0); assert_object_location_fails(rev1, ob1a); assert_object_location_fails(rev1, ob1b); assert_object_location(rev2, ob0, NULL, 0); assert_object_location(rev2, ob1a, NULL, 1); assert_object_location(rev2, ob1b, NULL, 2); assert_object_location(rev3, ob0, NULL, 0); assert_object_location_fails(rev3, ob1a); assert_object_location(rev3, ob1b, NULL, 1); rev4 = xorn_new_revision(rev3); memset(&arc_data, 0, sizeof arc_data); assert(xornsch_set_arc_data(rev4, ob1a, &arc_data) == 0); assert_object_location(rev4, ob0, NULL, 0); assert_object_location(rev4, ob1a, NULL, 2); assert_object_location(rev4, ob1b, NULL, 1); ob2 = xorn_copy_object(rev4, rev1, ob0); assert(ob2 != NULL); assert_object_location(rev4, ob0, NULL, 0); assert_object_location(rev4, ob1a, NULL, 2); assert_object_location(rev4, ob1b, NULL, 1); assert_object_location(rev4, ob2, NULL, 3); xorn_delete_object(rev4, ob0); assert_object_location_fails(rev4, ob0); assert_object_location(rev4, ob1a, NULL, 1); assert_object_location(rev4, ob1b, NULL, 0); assert_object_location(rev4, ob2, NULL, 2); xorn_free_revision(rev4); xorn_free_revision(rev3); xorn_free_revision(rev2); xorn_free_revision(rev1); xorn_free_revision(rev0); }
static PyObject *Revision_new(PyTypeObject *type, PyObject *args, PyObject *kwds) { Revision *self = (Revision *)type->tp_alloc(type, 0); if (self == NULL) return NULL; self->rev = xorn_new_revision(NULL); if (self->rev == NULL) { Py_DECREF(self); return PyErr_NoMemory(); } return (PyObject *)self; }
int main() { xorn_revision_t rev; xorn_object_t ob0, ob1; struct xornsch_component component_data; struct xornsch_picture picture_data; xorn_selection_t sel0, sel1; assert(rev = xorn_new_revision(NULL)); memset(&component_data, 0, sizeof component_data); component_data.symbol.ptr = &refcnt0; component_data.symbol.incref = (void (*)(void *))inc; component_data.symbol.decref = (void (*)(void *))dec; assert(ob0 = xornsch_add_component(rev, &component_data)); assert(refcnt0 == 1); memset(&picture_data, 0, sizeof picture_data); picture_data.pixmap.ptr = &refcnt1; picture_data.pixmap.incref = (void (*)(void *))inc; picture_data.pixmap.decref = (void (*)(void *))dec; assert(ob1 = xornsch_add_picture(rev, &picture_data)); assert(refcnt0 == 1); assert(refcnt1 == 1); assert(sel0 = xorn_select_all(rev)); assert(sel1 = xorn_copy_objects(rev, rev, sel0)); assert(refcnt0 != 0); assert(refcnt1 != 0); memset(&picture_data, 0, sizeof picture_data); assert(xornsch_set_picture_data(rev, ob1, &picture_data) == 0); assert(refcnt0 != 0); assert(refcnt1 != 0); xorn_delete_selected_objects(rev, sel1); assert(refcnt0 == 1); assert(refcnt1 == 0); xorn_free_selection(sel1); xorn_free_selection(sel0); xorn_free_revision(rev); assert(refcnt0 == 0); assert(refcnt1 == 0); return 0; }
static void check_delete_0(xorn_revision_t rev, xorn_object_t del) { xorn_revision_t r; xorn_object_t *objects; size_t count; assert(r = xorn_new_revision(rev)); xorn_delete_object(r, del); assert(xorn_get_objects(r, &objects, &count) == 0); assert(count == 0); free(objects); xorn_free_revision(r); }
static void check_attach(void) { xorn_revision_t rev; xorn_object_t N, a, b; struct xornsch_net net_data; struct xornsch_text text_data; assert(rev = xorn_new_revision(NULL)); memset(&net_data, 0, sizeof net_data); assert(N = xornsch_add_net(rev, &net_data)); memset(&text_data, 0, sizeof text_data); assert(a = xornsch_add_text(rev, &text_data)); assert(b = xornsch_add_text(rev, &text_data)); assert_object_location(rev, N, _, 0); assert_object_location(rev, a, _, 1); assert_object_location(rev, b, _, 2); assert(xorn_relocate_object(rev, a, N, _) == 0); assert_object_location(rev, N, _, 0); assert_object_location(rev, a, N, 0); assert_object_location(rev, b, _, 1); assert(xorn_relocate_object(rev, b, N, _) == 0); assert_object_location(rev, N, _, 0); assert_object_location(rev, a, N, 0); assert_object_location(rev, b, N, 1); assert(xorn_relocate_object(rev, b, N, a) == 0); assert_object_location(rev, N, _, 0); assert_object_location(rev, a, N, 1); assert_object_location(rev, b, N, 0); assert(xorn_relocate_object(rev, a, _, N) == 0); assert_object_location(rev, N, _, 1); assert_object_location(rev, a, _, 0); assert_object_location(rev, b, N, 0); xorn_free_revision(rev); }
static void check_delete_2(xorn_revision_t rev, xorn_object_t del, xorn_object_t ob0, xorn_object_t ob1) { xorn_revision_t r; xorn_object_t *objects; size_t count; assert(r = xorn_new_revision(rev)); xorn_delete_object(r, del); assert(xorn_get_objects(r, &objects, &count) == 0); assert(objects != NULL); assert(count == 2); assert(objects[0] == ob0); assert(objects[1] == ob1); free(objects); xorn_free_revision(r); }
int main(void) { xorn_revision_t rev; rev = xorn_new_revision(NULL); /** [discrete] */ xorn_object_t *objects; size_t count; unsigned int i; xorn_get_objects(rev, &objects, &count); for (i = 0; i < count; i++) { xorn_obtype_t type = xorn_get_object_type(rev, objects[i]); if (type == xornsch_obtype_circle && xornsch_get_circle_data(rev, objects[i])->radius == 0.) xorn_delete_object(rev, objects[i], NULL); if (type == xornsch_obtype_arc && xornsch_get_arc_data(rev, objects[i])->radius == 0.) xorn_delete_object(rev, objects[i], NULL); } free(objects); /** [discrete] */ /** [integrated] */ xorn_selection_t sel = xornsch_select_by_radius(rev, 0.); xorn_delete_selected_objects(rev, sel, NULL); xorn_free_selection(sel); /** [integrated] */ xorn_free_revision(rev); return 0; }
int main(void) { xorn_revision_t rev0, rev1, rev2, rev3; xorn_object_t ob0, ob1a, ob1b; xorn_revision_t rev4; setup(&rev0, &rev1, &rev2, &rev3, &ob0, &ob1a, &ob1b); rev4 = xorn_new_revision(rev3); assert(rev4 != NULL); assert(xornsch_add_line(rev4, NULL) == NULL); assert(xornsch_set_line_data(rev4, ob0, NULL) == -1); xorn_finalize_revision(rev4); xorn_free_revision(rev4); xorn_free_revision(rev3); xorn_free_revision(rev2); xorn_free_revision(rev1); xorn_free_revision(rev0); return 0; }
int main(void) { xorn_revision_t rev; struct xornsch_net net_data; struct xornsch_text text_data; xorn_object_t N, a, b; xorn_revision_t rev1; struct xornsch_line line_data; struct xornsch_component component_data; assert(rev = xorn_new_revision(NULL)); memset(&net_data, 0, sizeof net_data); assert(N = xornsch_add_net(rev, &net_data)); memset(&text_data, 0, sizeof text_data); assert(a = xornsch_add_text(rev, &text_data)); assert(b = xornsch_add_text(rev, &text_data)); common_checks(rev, N, a, b, N, a, b); /* can move objects */ do_it(rev, N, _, _, 0, a, b, N, &check2, N, a, b); do_it(rev, N, _, a, 0, N, a, b, &check0, N, a, b); do_it(rev, N, _, b, 0, a, N, b, &check1, N, a, b); do_it(rev, a, _, _, 0, N, b, a, &check0, N, b, a); do_it(rev, a, _, N, 0, a, N, b, &check1, N, a, b); do_it(rev, a, _, b, 0, N, a, b, &check0, N, a, b); do_it(rev, b, _, N, 0, b, N, a, &check1, N, b, a); do_it(rev, b, _, a, 0, N, b, a, &check0, N, b, a); do_it(rev, b, _, _, 0, N, a, b, &check0, N, a, b); /* can embed a to N, but not before b */ do_it(rev, a, N, _, 0, N, a, b, &check3, N, a, b); do_it(rev, a, N, b, -1, N, a, b, &check3, N, a, b); do_it(rev, b, _, N, 0, b, N, a, &check4, N, b, a); do_it(rev, b, _, a, -1, b, N, a, &check4, N, b, a); do_it(rev, b, _, _, 0, N, a, b, &check3, N, a, b); do_it(rev, a, _, b, 0, N, a, b, &check0, N, a, b); /* can embed b to N, but not before a */ do_it(rev, b, N, _, 0, N, b, a, &check3, N, b, a); do_it(rev, b, N, a, -1, N, b, a, &check3, N, b, a); do_it(rev, a, _, N, 0, a, N, b, &check4, N, a, b); do_it(rev, a, _, b, -1, a, N, b, &check4, N, a, b); do_it(rev, a, _, _, 0, N, b, a, &check3, N, b, a); do_it(rev, b, _, _, 0, N, a, b, &check0, N, a, b); /* can embed both */ do_it(rev, a, N, _, 0, N, a, b, &check3, N, a, b); do_it(rev, b, N, _, 0, N, a, b, &check5, N, a, b); do_it(rev, a, N, _, 0, N, b, a, &check5, N, b, a); do_it(rev, a, N, b, 0, N, a, b, &check5, N, a, b); do_it(rev, b, N, a, 0, N, b, a, &check5, N, b, a); do_it(rev, b, N, _, 0, N, a, b, &check5, N, a, b); do_it(rev, a, _, _, 0, N, b, a, &check3, N, b, a); do_it(rev, b, _, _, 0, N, a, b, &check0, N, a, b); xorn_finalize_revision(rev); common_checks(rev, N, a, b, N, a, b); check(rev, N, _, _, -1, N, a, b); check(rev, N, _, a, -1, N, a, b); check(rev, N, _, b, -1, N, a, b); check(rev, a, _, _, -1, N, a, b); check(rev, a, _, N, -1, N, a, b); check(rev, a, _, b, -1, N, a, b); check(rev, a, N, _, -1, N, a, b); check(rev, b, _, _, -1, N, a, b); check(rev, b, _, N, -1, N, a, b); check(rev, b, _, a, -1, N, a, b); check(rev, b, N, _, -1, N, a, b); assert(rev1 = xorn_new_revision(rev)); /* can't attach text to line */ memset(&line_data, 0, sizeof line_data); assert(xornsch_set_line_data(rev1, N, &line_data) == 0); do_it(rev1, a, N, _, -1, N, a, b, &check0, N, a, b); /* can attach text to component */ memset(&component_data, 0, sizeof component_data); assert(xornsch_set_component_data(rev1, N, &component_data) == 0); do_it(rev1, a, N, _, 0, N, a, b, &check3, N, a, b); xorn_free_revision(rev1); xorn_free_revision(rev); return 0; }
int main(void) { xorn_revision_t rev; rev = xorn_new_revision(NULL); { /** [add object] */ struct xornsch_line line_data; memset(&line_data, 0, sizeof line_data); line_data.pos.x = 0; line_data.pos.y = 0; line_data.size.x = 100; line_data.size.y = 100; line_data.line.width = 1; xorn_object_t ob; ob = xorn_add_object(rev, xornsch_obtype_line, &line_data); if (ob == NULL) /* handle error */; /** [add object] */ /** [get object data] */ const struct xornsch_line *data; data = xorn_get_object_data(rev, ob, xornsch_obtype_line); if (data == NULL) /* ob doesn't exist or isn't a line */; /** [get object data] */ } { struct xornsch_net net_data; xorn_object_t ob; memset(&net_data, 0, sizeof net_data); ob = xornsch_add_net(rev, &net_data); /** [set object data] */ struct xornsch_line line_data; memset(&line_data, 0, sizeof line_data); line_data.pos.x = 0; line_data.pos.y = 0; line_data.size.x = 100; line_data.size.y = 100; line_data.line.width = 1; if (xorn_set_object_data(rev, ob, xornsch_obtype_line, &line_data) == -1) /* handle error */; /** [set object data] */ } { /** [get objects] */ xorn_object_t *objects; size_t count; unsigned int i; if (xorn_get_objects(rev, &objects, &count) == -1) /* handle error */; for (i = 0; i < count; i++) /* do something with objects[i] */; free(objects); /** [get objects] */ } { struct xornsch_component component_data; xorn_object_t component; memset(&component_data, 0, sizeof component_data); component = xornsch_add_component(rev, &component_data); /** [add attribute] */ struct xornsch_text text_data; memset(&text_data, 0, sizeof text_data); text_data.text.s = "refdes=R1"; text_data.text.len = strlen(text_data.text.s); xorn_object_t ob; ob = xornsch_add_text(rev, &text_data); if (ob == NULL) /* handle error */; if (xorn_relocate_object(rev, ob, component, NULL) == -1) /* handle error */; /** [add attribute] */ } xorn_free_revision(rev); return 0; }
int main(void) { xorn_revision_t src, dest; struct xornsch_net net_data; struct xornsch_text text_data; xorn_object_t net0, net1, text0, text1, copy; xorn_selection_t sel, copies; assert(src = xorn_new_revision(NULL)); memset(&net_data, 0, sizeof net_data); net_data.color = 1; assert(net0 = xornsch_add_net(src, &net_data, NULL)); net_data.color = 2; assert(net1 = xornsch_add_net(src, &net_data, NULL)); memset(&text_data, 0, sizeof text_data); text_data.color = 3; assert(text0 = xornsch_add_text(src, &text_data, NULL)); text_data.color = 4; assert(text1 = xornsch_add_text(src, &text_data, NULL)); assert(xorn_relocate_object(src, text1, net1, NULL, NULL) == 0); xorn_finalize_revision(src); /* text1 is attached to net1, text0 is not attached */ assert(dest = xorn_new_revision(NULL)); assert(copy = xorn_copy_object(dest, src, net0, NULL)); assert_this_net(dest, copy, 1); xorn_free_revision(dest); assert(dest = xorn_new_revision(NULL)); assert(copy = xorn_copy_object(dest, src, net1, NULL)); assert_this_net_with_text(dest, copy, 2, 4); xorn_free_revision(dest); assert(dest = xorn_new_revision(NULL)); assert(sel = xorn_select_object(net0)); assert(copies = xorn_copy_objects(dest, src, sel, NULL)); assert_this_net(dest, get_only_selected_object(dest, copies), 1); xorn_free_selection(copies); xorn_free_selection(sel); xorn_free_revision(dest); assert(dest = xorn_new_revision(NULL)); assert(sel = xorn_select_object(net1)); assert(copies = xorn_copy_objects(dest, src, sel, NULL)); assert_this_net_with_text( dest, get_only_selected_object(dest, copies), 2, 4); xorn_free_selection(copies); xorn_free_selection(sel); xorn_free_revision(dest); assert(dest = xorn_new_revision(NULL)); assert(sel = xorn_select_attached_to(src, NULL)); assert(copies = xorn_copy_objects(dest, src, sel, NULL)); assert_four(dest, copies, 1, 2, 3, 4); xorn_free_selection(copies); xorn_free_selection(sel); xorn_free_revision(dest); xorn_free_revision(src); return 0; }
int main(void) { xorn_revision_t rev0, rev1, rev2, rev3; xorn_object_t ob0, ob1a, ob1b; xorn_selection_t sel; struct xorn_double2d pos; xorn_revision_t rev4; struct xornsch_text text_data; xorn_object_t text_ob; struct xornsch_line_attr line; struct xornsch_fill_attr fill; setup(&rev0, &rev1, &rev2, &rev3, &ob0, &ob1a, &ob1b); sel = xornsch_select_by_color(rev2, 3); assert(xorn_object_is_selected(rev2, sel, ob0) == true); assert(xorn_object_is_selected(rev2, sel, ob1a) == true); assert(xorn_object_is_selected(rev2, sel, ob1b) == true); xorn_free_selection(sel); sel = xornsch_select_by_color(rev2, 4); assert(xorn_object_is_selected(rev2, sel, ob0) == false); assert(xorn_object_is_selected(rev2, sel, ob1a) == false); assert(xorn_object_is_selected(rev2, sel, ob1b) == false); xorn_free_selection(sel); sel = xornsch_select_by_color(rev3, 3); assert(xorn_object_is_selected(rev3, sel, ob0) == false); assert(xorn_object_is_selected(rev3, sel, ob1a) == false); assert(xorn_object_is_selected(rev3, sel, ob1b) == true); xorn_free_selection(sel); sel = xornsch_select_by_color(rev3, 4); assert(xorn_object_is_selected(rev3, sel, ob0) == true); assert(xorn_object_is_selected(rev3, sel, ob1a) == false); assert(xorn_object_is_selected(rev3, sel, ob1b) == false); xorn_free_selection(sel); sel = xornsch_select_by_line_width(rev2, 0.); assert(xorn_object_is_selected(rev2, sel, ob0) == false); assert(xorn_object_is_selected(rev2, sel, ob1a) == false); assert(xorn_object_is_selected(rev2, sel, ob1b) == false); xorn_free_selection(sel); sel = xornsch_select_by_line_width(rev2, 1.); assert(xorn_object_is_selected(rev2, sel, ob0) == true); assert(xorn_object_is_selected(rev2, sel, ob1a) == true); assert(xorn_object_is_selected(rev2, sel, ob1b) == true); xorn_free_selection(sel); sel = xornsch_select_by_line_width(rev3, 0.); assert(xorn_object_is_selected(rev3, sel, ob0) == false); assert(xorn_object_is_selected(rev3, sel, ob1a) == false); assert(xorn_object_is_selected(rev3, sel, ob1b) == false); xorn_free_selection(sel); sel = xornsch_select_by_line_width(rev3, 1.); assert(xorn_object_is_selected(rev3, sel, ob0) == false); assert(xorn_object_is_selected(rev3, sel, ob1a) == false); assert(xorn_object_is_selected(rev3, sel, ob1b) == true); xorn_free_selection(sel); pos.x = 0.; pos.y = 1.; sel = xornsch_select_by_pos(rev3, &pos); assert(xorn_object_is_selected(rev3, sel, ob0) == true); assert(xorn_object_is_selected(rev3, sel, ob1a) == false); assert(xorn_object_is_selected(rev3, sel, ob1b) == false); xorn_free_selection(sel); pos.x = -1.; pos.y = -1.; sel = xornsch_select_by_pos(rev3, &pos); assert(xorn_object_is_selected(rev3, sel, ob0) == false); assert(xorn_object_is_selected(rev3, sel, ob1a) == false); assert(xorn_object_is_selected(rev3, sel, ob1b) == true); xorn_free_selection(sel); sel = xornsch_select_by_pos_x(rev3, 0.); assert(xorn_object_is_selected(rev3, sel, ob0) == true); assert(xorn_object_is_selected(rev3, sel, ob1a) == false); assert(xorn_object_is_selected(rev3, sel, ob1b) == false); xorn_free_selection(sel); sel = xornsch_select_by_pos_x(rev3, 1.); assert(xorn_object_is_selected(rev3, sel, ob0) == false); assert(xorn_object_is_selected(rev3, sel, ob1a) == false); assert(xorn_object_is_selected(rev3, sel, ob1b) == false); xorn_free_selection(sel); sel = xornsch_select_by_pos_y(rev3, 0.); assert(xorn_object_is_selected(rev3, sel, ob0) == false); assert(xorn_object_is_selected(rev3, sel, ob1a) == false); assert(xorn_object_is_selected(rev3, sel, ob1b) == false); xorn_free_selection(sel); sel = xornsch_select_by_pos_y(rev3, 1.); assert(xorn_object_is_selected(rev3, sel, ob0) == true); assert(xorn_object_is_selected(rev3, sel, ob1a) == false); assert(xorn_object_is_selected(rev3, sel, ob1b) == false); xorn_free_selection(sel); rev4 = xorn_new_revision(rev3); assert(rev4 != NULL); memset(&text_data, 0, sizeof text_data); text_data.text.s = "Hello world"; text_data.text.len = 11; text_ob = xornsch_add_text(rev4, &text_data); assert(text_ob != NULL); xorn_finalize_revision(rev4); text_data.text.s = ""; text_data.text.len = 0; sel = xornsch_select_by_text(rev4, &text_data.text); assert(xorn_object_is_selected(rev4, sel, ob0) == false); assert(xorn_object_is_selected(rev4, sel, ob1a) == false); assert(xorn_object_is_selected(rev4, sel, ob1b) == false); assert(xorn_object_is_selected(rev4, sel, text_ob) == false); xorn_free_selection(sel); text_data.text.s = "Hello world"; text_data.text.len = 11; sel = xornsch_select_by_text(rev4, &text_data.text); assert(xorn_object_is_selected(rev4, sel, ob0) == false); assert(xorn_object_is_selected(rev4, sel, ob1a) == false); assert(xorn_object_is_selected(rev4, sel, ob1b) == false); assert(xorn_object_is_selected(rev4, sel, text_ob) == true); xorn_free_selection(sel); memset(&line, 0, sizeof line); sel = xornsch_select_by_line(rev2, &line); assert(xorn_object_is_selected(rev2, sel, ob0) == false); assert(xorn_object_is_selected(rev2, sel, ob1a) == false); assert(xorn_object_is_selected(rev2, sel, ob1b) == false); xorn_free_selection(sel); sel = xornsch_select_by_line(rev3, &line); assert(xorn_object_is_selected(rev3, sel, ob0) == false); assert(xorn_object_is_selected(rev3, sel, ob1a) == false); assert(xorn_object_is_selected(rev3, sel, ob1b) == false); xorn_free_selection(sel); line.width = 1.; sel = xornsch_select_by_line(rev2, &line); assert(xorn_object_is_selected(rev2, sel, ob0) == true); assert(xorn_object_is_selected(rev2, sel, ob1a) == true); assert(xorn_object_is_selected(rev2, sel, ob1b) == true); xorn_free_selection(sel); sel = xornsch_select_by_line(rev3, &line); assert(xorn_object_is_selected(rev3, sel, ob0) == false); assert(xorn_object_is_selected(rev3, sel, ob1a) == false); assert(xorn_object_is_selected(rev3, sel, ob1b) == true); xorn_free_selection(sel); memset(&fill, 0, sizeof fill); sel = xornsch_select_by_fill(rev2, &fill); assert(xorn_object_is_selected(rev2, sel, ob0) == false); assert(xorn_object_is_selected(rev2, sel, ob1a) == true); assert(xorn_object_is_selected(rev2, sel, ob1b) == false); xorn_free_selection(sel); sel = xornsch_select_by_fill(rev3, &fill); assert(xorn_object_is_selected(rev3, sel, ob0) == false); assert(xorn_object_is_selected(rev3, sel, ob1a) == false); assert(xorn_object_is_selected(rev3, sel, ob1b) == false); xorn_free_selection(sel); fill.type = 1; sel = xornsch_select_by_fill(rev2, &fill); assert(xorn_object_is_selected(rev2, sel, ob0) == false); assert(xorn_object_is_selected(rev2, sel, ob1a) == false); assert(xorn_object_is_selected(rev2, sel, ob1b) == true); xorn_free_selection(sel); sel = xornsch_select_by_fill(rev3, &fill); assert(xorn_object_is_selected(rev3, sel, ob0) == false); assert(xorn_object_is_selected(rev3, sel, ob1a) == false); assert(xorn_object_is_selected(rev3, sel, ob1b) == true); xorn_free_selection(sel); xorn_free_revision(rev4); xorn_free_revision(rev3); xorn_free_revision(rev2); xorn_free_revision(rev1); xorn_free_revision(rev0); return 0; }
int main(void) { xorn_revision_t rev0, rev1, rev2, rev3; xorn_object_t line, box, circle; struct xornsch_line line_data; struct xornsch_box box_data; struct xornsch_circle circle_data; struct xornsch_net net_data; /* Create an empty revision and make it read-only. */ rev0 = xorn_new_revision(NULL); if (rev0 == NULL) goto error0; xorn_finalize_revision(rev0); /* Copy the revision */ /* You could omit the previous step and just create an empty revision if you don't need to refer to the empty state later. */ rev1 = xorn_new_revision(rev0); if (rev1 == NULL) goto error1; /* Prepare a xornsch_line structure */ memset(&line_data, 0, sizeof line_data); line_data.pos.x = 0; line_data.pos.y = 1; line_data.size.x = 3; line_data.size.y = 2; line_data.color = 3; line_data.line.width = 1; /* Add a line object with this data to the revision */ line = xornsch_add_line(rev1, &line_data); if (line == NULL) goto error2; /* Finalize the revision */ xorn_finalize_revision(rev1); /* Create a copy of the last revision, add a box and a circle to it, and finalize it */ rev2 = xorn_new_revision(rev1); if (rev2 == NULL) goto error2; memset(&box_data, 0, sizeof box_data); box_data.pos.x = 1; box_data.pos.y = 1; box_data.size.x = 2; box_data.size.y = 2; box_data.color = 3; box_data.line.width = 1; box = xornsch_add_box(rev2, &box_data); if (box == NULL) goto error3; memset(&circle_data, 0, sizeof circle_data); circle_data.pos.x = -1; circle_data.pos.y = -1; circle_data.radius = 2; circle_data.color = 3; circle_data.line.width = 1; circle_data.fill.type = 1; circle = xornsch_add_circle(rev2, &circle_data); if (circle == NULL) goto error3; xorn_finalize_revision(rev2); /* Create a copy of the last revision, set the line's object type to net and change its color, delete the box, and finalize the revision */ rev3 = xorn_new_revision(rev2); if (rev3 == NULL) goto error3; memset(&net_data, 0, sizeof net_data); net_data.pos.x = 0; net_data.pos.y = 1; net_data.size.x = 3; net_data.size.y = 2; net_data.color = 4; if (xornsch_set_net_data(rev3, line, &net_data) == -1) goto error4; xorn_delete_object(rev3, box); xorn_finalize_revision(rev3); /* ... you could do something with these revisions now ... */ /* Free the revisions (the order doesn't matter) */ xorn_free_revision(rev3); xorn_free_revision(rev2); xorn_free_revision(rev1); xorn_free_revision(rev0); /* No need to free objects */ return 0; error4: xorn_free_revision(rev3); error3: xorn_free_revision(rev2); error2: xorn_free_revision(rev1); error1: xorn_free_revision(rev0); error0: fprintf(stderr, "Out of memory\n"); return 1; }
int main() { xorn_revision_t rev; xorn_object_t ob0, ob1; struct xornsch_line line_data; struct xornsch_net net_data; struct xornsch_component component_data; struct xornsch_text text_data; memset(&line_data, 0, sizeof line_data); memset(&net_data, 0, sizeof net_data); memset(&component_data, 0, sizeof component_data); memset(&text_data, 0, sizeof text_data); assert(rev = xorn_new_revision(NULL)); assert(ob0 = xornsch_add_line(rev, &line_data)); assert(ob1 = xornsch_add_line(rev, &line_data)); assert(xornsch_set_net_data(rev, ob0, &net_data) == 0); assert(xornsch_set_text_data(rev, ob1, &text_data) == 0); check_not_attached(rev, ob0, ob1); /* data can be set without the object being reordered */ assert(xornsch_set_line_data(rev, ob0, &line_data) == 0); check_not_attached(rev, ob0, ob1); assert(xornsch_set_net_data(rev, ob0, &net_data) == 0); check_not_attached(rev, ob0, ob1); assert(xornsch_set_line_data(rev, ob1, &line_data) == 0); check_not_attached(rev, ob0, ob1); assert(xornsch_set_net_data(rev, ob1, &net_data) == 0); check_not_attached(rev, ob0, ob1); /* objects are re-added at the end */ xorn_delete_object(rev, ob0); assert(xornsch_set_line_data(rev, ob0, &line_data) == 0); check_not_attached(rev, ob1, ob0); xorn_delete_object(rev, ob0); assert(xornsch_set_line_data(rev, ob0, &line_data) == 0); check_not_attached(rev, ob1, ob0); xorn_delete_object(rev, ob1); assert(xornsch_set_line_data(rev, ob1, &line_data) == 0); check_not_attached(rev, ob0, ob1); xorn_delete_object(rev, ob1); assert(xornsch_set_line_data(rev, ob1, &line_data) == 0); check_not_attached(rev, ob0, ob1); xorn_delete_object(rev, ob0); assert(xornsch_set_net_data(rev, ob0, &net_data) == 0); check_not_attached(rev, ob1, ob0); xorn_delete_object(rev, ob0); assert(xornsch_set_net_data(rev, ob0, &net_data) == 0); check_not_attached(rev, ob1, ob0); xorn_delete_object(rev, ob1); assert(xornsch_set_net_data(rev, ob1, &net_data) == 0); check_not_attached(rev, ob0, ob1); xorn_delete_object(rev, ob1); assert(xornsch_set_net_data(rev, ob1, &net_data) == 0); check_not_attached(rev, ob0, ob1); /* can change ob0 to any type while no object is attached */ assert(xornsch_set_line_data(rev, ob0, &line_data) == 0); check_not_attached(rev, ob0, ob1); assert(xornsch_set_component_data(rev, ob0, &component_data) == 0); check_not_attached(rev, ob0, ob1); assert(xornsch_set_text_data(rev, ob0, &text_data) == 0); check_not_attached(rev, ob0, ob1); assert(xornsch_set_net_data(rev, ob0, &net_data) == 0); check_not_attached(rev, ob0, ob1); /* can change type of ob1 while not attached */ assert(xornsch_set_line_data(rev, ob1, &line_data) == 0); check_not_attached(rev, ob0, ob1); assert(xornsch_set_net_data(rev, ob1, &net_data) == 0); check_not_attached(rev, ob0, ob1); assert(xornsch_set_component_data(rev, ob1, &component_data) == 0); check_not_attached(rev, ob0, ob1); assert(xornsch_set_text_data(rev, ob1, &text_data) == 0); check_not_attached(rev, ob0, ob1); assert(xorn_relocate_object(rev, ob1, ob0, NULL) == 0); check_attached(rev, ob0, ob1); /* can't change ob0 to line or text while an object is attached */ assert(xornsch_set_line_data(rev, ob0, &line_data) == -1); check_attached(rev, ob0, ob1); assert(xornsch_set_net_data(rev, ob0, &net_data) == 0); check_attached(rev, ob0, ob1); assert(xornsch_set_component_data(rev, ob0, &component_data) == 0); check_attached(rev, ob0, ob1); assert(xornsch_set_text_data(rev, ob0, &text_data) == -1); check_attached(rev, ob0, ob1); /* can't change type of ob1 while attached */ assert(xornsch_set_line_data(rev, ob1, &line_data) == -1); check_attached(rev, ob0, ob1); assert(xornsch_set_net_data(rev, ob1, &net_data) == -1); check_attached(rev, ob0, ob1); assert(xornsch_set_component_data(rev, ob1, &component_data) == -1); check_attached(rev, ob0, ob1); assert(xornsch_set_text_data(rev, ob1, &text_data) == 0); check_attached(rev, ob0, ob1); xorn_free_revision(rev); return 0; }
int main() { xorn_revision_t rev; struct xornsch_net net_data; struct xornsch_text text_data; xorn_object_t N, a, b; assert(rev = xorn_new_revision(NULL)); memset(&net_data, 0, sizeof net_data); assert(N = xornsch_add_net(rev, &net_data)); memset(&text_data, 0, sizeof text_data); assert(a = xornsch_add_text(rev, &text_data)); assert(b = xornsch_add_text(rev, &text_data)); assert_attached_objects_3(rev, _, N, a, b); assert_attached_objects_0(rev, N); assert_attached_objects_0(rev, a); assert_attached_objects_0(rev, b); assert(xorn_relocate_object(rev, N, _, _) == 0); assert_attached_objects_3(rev, _, a, b, N); assert_attached_objects_0(rev, N); assert_attached_objects_0(rev, a); assert_attached_objects_0(rev, b); assert(xorn_relocate_object(rev, N, _, b) == 0); assert_attached_objects_3(rev, _, a, N, b); assert_attached_objects_0(rev, N); assert_attached_objects_0(rev, a); assert_attached_objects_0(rev, b); assert(xorn_relocate_object(rev, a, N, _) == 0); assert_attached_objects_2(rev, _, N, b); assert_attached_objects_1(rev, N, a); assert_attached_objects_0(rev, a); assert_attached_objects_0(rev, b); assert(xorn_relocate_object(rev, b, N, _) == 0); assert_attached_objects_1(rev, _, N); assert_attached_objects_2(rev, N, a, b); assert_attached_objects_0(rev, a); assert_attached_objects_0(rev, b); assert(xorn_relocate_object(rev, a, N, _) == 0); assert_attached_objects_1(rev, _, N); assert_attached_objects_2(rev, N, b, a); assert_attached_objects_0(rev, a); assert_attached_objects_0(rev, b); assert(xorn_relocate_object(rev, a, N, b) == 0); assert_attached_objects_1(rev, _, N); assert_attached_objects_2(rev, N, a, b); assert_attached_objects_0(rev, a); assert_attached_objects_0(rev, b); xorn_delete_object(rev, b); assert_attached_objects_1(rev, _, N); assert_attached_objects_1(rev, N, a); assert_attached_objects_0(rev, a); assert_attached_objects_f(rev, b); xorn_delete_object(rev, N); assert_attached_objects_0(rev, _); assert_attached_objects_f(rev, N); assert_attached_objects_f(rev, a); assert_attached_objects_f(rev, b); xorn_free_revision(rev); return 0; }
int main(void) { xorn_revision_t rev0, rev1, rev2, rev3; xorn_object_t ob0, ob1a, ob1b; xorn_object_t *objects; size_t count; xorn_revision_t rev4; setup(&rev0, &rev1, &rev2, &rev3, &ob0, &ob1a, &ob1b); rev4 = xorn_new_revision(rev2); assert(xorn_get_objects(rev4, &objects, &count) == 0); assert(objects != NULL); assert(count == 3); assert(objects[0] == ob0); assert(objects[1] == ob1a); assert(objects[2] == ob1b); free(objects); relocate_and_assert_3(rev4, ob0, ob0, E_OK, ob0, ob1a, ob1b); relocate_and_assert_3(rev4, ob0, ob1a, E_OK, ob0, ob1a, ob1b); relocate_and_assert_3(rev4, ob0, ob1b, E_OK, ob1a, ob0, ob1b); relocate_and_assert_3(rev4, ob0, NULL, E_OK, ob1a, ob1b, ob0); relocate_and_assert_3(rev4, ob1a, ob0, E_OK, ob1b, ob1a, ob0); relocate_and_assert_3(rev4, ob1a, ob1a, E_OK, ob1b, ob1a, ob0); relocate_and_assert_3(rev4, ob1a, ob1b, E_OK, ob1a, ob1b, ob0); relocate_and_assert_3(rev4, ob1a, NULL, E_OK, ob1b, ob0, ob1a); relocate_and_assert_3(rev4, ob1b, ob0, E_OK, ob1b, ob0, ob1a); relocate_and_assert_3(rev4, ob1b, ob1a, E_OK, ob0, ob1b, ob1a); relocate_and_assert_3(rev4, ob1b, ob1b, E_OK, ob0, ob1b, ob1a); relocate_and_assert_3(rev4, ob1b, NULL, E_OK, ob0, ob1a, ob1b); relocate_and_assert_3(rev4, NULL, ob0, E_NOEXIST, ob0, ob1a, ob1b); relocate_and_assert_3(rev4, NULL, ob1a, E_NOEXIST, ob0, ob1a, ob1b); relocate_and_assert_3(rev4, NULL, ob1b, E_NOEXIST, ob0, ob1a, ob1b); relocate_and_assert_3(rev4, NULL, NULL, E_NOEXIST, ob0, ob1a, ob1b); relocate_and_assert_3(rev4, ob0, ob0, E_OK, ob0, ob1a, ob1b); relocate_and_assert_3(rev4, ob1a, ob1a, E_OK, ob0, ob1a, ob1b); relocate_and_assert_3(rev4, ob1b, ob1b, E_OK, ob0, ob1a, ob1b); assert(xorn_delete_object(rev4, ob0, NULL) == 0); assert(xorn_get_objects(rev4, &objects, &count) == 0); assert(objects != NULL); assert(count == 2); assert(objects[0] == ob1a); assert(objects[1] == ob1b); free(objects); relocate_and_assert_2(rev4, ob0, ob0, E_NOEXIST, ob1a, ob1b); relocate_and_assert_2(rev4, ob0, ob1a, E_NOEXIST, ob1a, ob1b); relocate_and_assert_2(rev4, ob0, ob1b, E_NOEXIST, ob1a, ob1b); relocate_and_assert_2(rev4, ob0, NULL, E_NOEXIST, ob1a, ob1b); relocate_and_assert_2(rev4, ob1a, ob0, E_NOSUCC, ob1a, ob1b); relocate_and_assert_2(rev4, ob1a, ob1a, E_OK, ob1a, ob1b); relocate_and_assert_2(rev4, ob1a, ob1b, E_OK, ob1a, ob1b); relocate_and_assert_2(rev4, ob1a, NULL, E_OK, ob1b, ob1a); relocate_and_assert_2(rev4, ob1b, ob0, E_NOSUCC, ob1b, ob1a); relocate_and_assert_2(rev4, ob1b, ob1a, E_OK, ob1b, ob1a); relocate_and_assert_2(rev4, ob1b, ob1b, E_OK, ob1b, ob1a); relocate_and_assert_2(rev4, ob1b, NULL, E_OK, ob1a, ob1b); relocate_and_assert_2(rev4, NULL, ob0, E_NOEXIST, ob1a, ob1b); relocate_and_assert_2(rev4, NULL, ob1a, E_NOEXIST, ob1a, ob1b); relocate_and_assert_2(rev4, NULL, ob1b, E_NOEXIST, ob1a, ob1b); relocate_and_assert_2(rev4, NULL, NULL, E_NOEXIST, ob1a, ob1b); xorn_finalize_revision(rev4); relocate_and_assert_2(rev4, ob1a, ob1a, E_NOTRANS, ob1a, ob1b); relocate_and_assert_2(rev4, ob1a, ob1b, E_NOTRANS, ob1a, ob1b); relocate_and_assert_2(rev4, ob1a, NULL, E_NOTRANS, ob1a, ob1b); relocate_and_assert_2(rev4, ob1b, ob1a, E_NOTRANS, ob1a, ob1b); relocate_and_assert_2(rev4, ob1b, ob1b, E_NOTRANS, ob1a, ob1b); relocate_and_assert_2(rev4, ob1b, NULL, E_NOTRANS, ob1a, ob1b); xorn_free_revision(rev4); xorn_free_revision(rev3); xorn_free_revision(rev2); xorn_free_revision(rev1); xorn_free_revision(rev0); return 0; }
int main(void) { xorn_revision_t rev0, rev1, rev2, rev3; xorn_object_t ob0, ob1a, ob1b; xorn_selection_t sel0, sel1, sel2, sel3; xorn_revision_t rev4; struct xorn_double2d pos; struct xornsch_text text_data; xorn_object_t text_ob; xorn_selection_t text_sel; xorn_revision_t rev5; struct xornsch_line_attr line; struct xornsch_fill_attr fill; setup(&rev0, &rev1, &rev2, &rev3, &ob0, &ob1a, &ob1b); sel0 = xorn_select_all(rev0); assert(sel0 != NULL); sel1 = xorn_select_all(rev1); assert(sel1 != NULL); sel2 = xorn_select_all(rev2); assert(sel2 != NULL); sel3 = xorn_select_all(rev3); assert(sel3 != NULL); rev4 = xorn_new_revision(rev3); assert(rev4 != NULL); assert(xornsch_set_color(rev4, sel0, 70) == 0); assert_color(rev4, ob0, true, 4); assert_color(rev4, ob1a, false, 0); assert_color(rev4, ob1b, true, 3); assert(xornsch_set_color(rev4, sel1, 71) == 0); assert_color(rev4, ob0, true, 71); assert_color(rev4, ob1a, false, 0); assert_color(rev4, ob1b, true, 3); assert(xornsch_set_color(rev4, sel2, 72) == 0); assert_color(rev4, ob0, true, 72); assert_color(rev4, ob1a, false, 0); assert_color(rev4, ob1b, true, 72); assert(xornsch_set_color(rev4, sel3, 73) == 0); assert_color(rev4, ob0, true, 73); assert_color(rev4, ob1a, false, 0); assert_color(rev4, ob1b, true, 73); assert(xornsch_set_line_width(rev4, sel0, 8.0) == 0); assert_line_width(rev4, ob0, false, 0.); assert_line_width(rev4, ob1a, false, 0.); assert_line_width(rev4, ob1b, true, 1.); assert(xornsch_set_line_width(rev4, sel1, 8.1) == 0); assert_line_width(rev4, ob0, false, 0.); assert_line_width(rev4, ob1a, false, 0.); assert_line_width(rev4, ob1b, true, 1.); assert(xornsch_set_line_width(rev4, sel2, 8.2) == 0); assert_line_width(rev4, ob0, false, 0.); assert_line_width(rev4, ob1a, false, 0.); assert_line_width(rev4, ob1b, true, 8.2); assert(xornsch_set_line_width(rev4, sel3, 8.3) == 0); assert_line_width(rev4, ob0, false, 0.); assert_line_width(rev4, ob1a, false, 0.); assert_line_width(rev4, ob1b, true, 8.3); pos.x = 9.00; pos.y = 9.05; assert(xornsch_set_pos(rev4, sel0, &pos) == 0); assert_position(rev4, ob0, true, 0., 1.); assert_position(rev4, ob1a, false, 0., 0.); assert_position(rev4, ob1b, true, -1., -1.); pos.x = 9.10; pos.y = 9.15; assert(xornsch_set_pos(rev4, sel1, &pos) == 0); assert_position(rev4, ob0, true, 9.10, 9.15); assert_position(rev4, ob1a, false, 0., 0.); assert_position(rev4, ob1b, true, -1., -1.); pos.x = 9.20; pos.y = 9.25; assert(xornsch_set_pos(rev4, sel2, &pos) == 0); assert_position(rev4, ob0, true, 9.20, 9.25); assert_position(rev4, ob1a, false, 0., 0.); assert_position(rev4, ob1b, true, 9.20, 9.25); pos.x = 9.30; pos.y = 9.35; assert(xornsch_set_pos(rev4, sel3, &pos) == 0); assert_position(rev4, ob0, true, 9.30, 9.35); assert_position(rev4, ob1a, false, 0., 0.); assert_position(rev4, ob1b, true, 9.30, 9.35); assert(xornsch_set_pos_x(rev4, sel3, 9.40) == 0); assert_position(rev4, ob0, true, 9.40, 9.35); assert_position(rev4, ob1a, false, 0., 0.); assert_position(rev4, ob1b, true, 9.40, 9.35); assert(xornsch_set_pos_y(rev4, sel3, 9.45) == 0); assert_position(rev4, ob0, true, 9.40, 9.45); assert_position(rev4, ob1a, false, 0., 0.); assert_position(rev4, ob1b, true, 9.40, 9.45); memset(&text_data, 0, sizeof text_data); text_data.text.s = "Hello world"; text_data.text.len = 11; text_ob = xornsch_add_text(rev4, &text_data); assert(text_ob != NULL); text_sel = xorn_select_object(text_ob); assert(text_sel != NULL); assert_text(rev4, ob0, false, ""); assert_text(rev4, ob1a, false, ""); assert_text(rev4, ob1b, false, ""); assert_text(rev4, text_ob, true, "Hello world"); text_data.text.s = "dlrow olleH"; assert(xornsch_set_text(rev4, text_sel, &text_data.text) == 0); assert_text(rev4, ob0, false, ""); assert_text(rev4, ob1a, false, ""); assert_text(rev4, ob1b, false, ""); assert_text(rev4, text_ob, true, "dlrow olleH"); xorn_finalize_revision(rev4); rev5 = xorn_new_revision(rev2); assert(rev5 != NULL); memset(&line, 0, sizeof line); line.width = 10.; line.cap_style = 11; line.dash_style = 12; line.dash_length = 13.; line.dash_space = 14.; assert(xornsch_set_line(rev5, sel0, &line) == 0); assert_line(rev5, ob0, true, 1., 0, 0, 0., 0.); assert_line(rev5, ob1a, true, 1., 0, 0, 0., 0.); assert_line(rev5, ob1b, true, 1., 0, 0, 0., 0.); assert(xornsch_set_line(rev5, sel1, &line) == 0); assert_line(rev5, ob0, true, 10., 11, 12, 13., 14.); assert_line(rev5, ob1a, true, 1., 0, 0, 0., 0.); assert_line(rev5, ob1b, true, 1., 0, 0, 0., 0.); assert(xornsch_set_line(rev5, sel2, &line) == 0); assert_line(rev5, ob0, true, 10., 11, 12, 13., 14.); assert_line(rev5, ob1a, true, 10., 11, 12, 13., 14.); assert_line(rev5, ob1b, true, 10., 11, 12, 13., 14.); line.dash_space = 14.1; assert(xornsch_set_line(rev5, sel3, &line) == 0); assert_line(rev5, ob0, true, 10., 11, 12, 13., 14.1); assert_line(rev5, ob1a, true, 10., 11, 12, 13., 14.); assert_line(rev5, ob1b, true, 10., 11, 12, 13., 14.1); memset(&fill, 0, sizeof fill); fill.type = 20; fill.width = 21.; fill.angle0 = 22; fill.pitch0 = 23.; fill.angle1 = 24; fill.pitch1 = 25.; assert(xornsch_set_fill(rev5, sel0, &fill) == 0); assert_fill(rev5, ob0, false, 0, 0., 0, 0., 0, 0.); assert_fill(rev5, ob1a, true, 0, 0., 0, 0., 0, 0.); assert_fill(rev5, ob1b, true, 1, 0., 0, 0., 0, 0.); assert(xornsch_set_fill(rev5, sel1, &fill) == 0); assert_fill(rev5, ob0, false, 0, 0., 0, 0., 0, 0.); assert_fill(rev5, ob1a, true, 0, 0., 0, 0., 0, 0.); assert_fill(rev5, ob1b, true, 1, 0., 0, 0., 0, 0.); assert(xornsch_set_fill(rev5, sel2, &fill) == 0); assert_fill(rev5, ob0, false, 0, 0., 0, 0., 0, 0.); assert_fill(rev5, ob1a, true, 20, 21., 22, 23., 24, 25.); assert_fill(rev5, ob1b, true, 20, 21., 22, 23., 24, 25.); fill.pitch1 = 25.1; assert(xornsch_set_fill(rev5, sel3, &fill) == 0); assert_fill(rev5, ob0, false, 0, 0., 0, 0., 0, 0.); assert_fill(rev5, ob1a, true, 20, 21., 22, 23., 24, 25.); assert_fill(rev5, ob1b, true, 20, 21., 22, 23., 24, 25.1); xorn_finalize_revision(rev5); xorn_free_selection(text_sel); xorn_free_selection(sel3); xorn_free_selection(sel2); xorn_free_selection(sel1); xorn_free_selection(sel0); xorn_free_revision(rev5); xorn_free_revision(rev4); xorn_free_revision(rev3); xorn_free_revision(rev2); xorn_free_revision(rev1); xorn_free_revision(rev0); return 0; }