1 /* Copyright (C) 2013-2020 Roland Lutz
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; either version 2 of the License, or
6 (at your option) any later version.
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
13 You should have received a copy of the GNU General Public License
14 along with this program; if not, write to the Free Software Foundation,
15 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
20 #define NO_ERROR ((xorn_error_t) -1)
25 xorn_revision_t rev0
, rev1
, rev2
, rev3
;
26 xorn_object_t ob0
, ob1a
, ob1b
;
29 xorn_object_t ob0copy
;
32 xorn_object_t
*objects
;
35 setup(&rev0
, &rev1
, &rev2
, &rev3
, &ob0
, &ob1a
, &ob1b
);
38 /* can't copy object which doesn't exist in source revision */
40 rev4
= xorn_new_revision(rev3
);
44 ob0copy
= xorn_copy_object(rev4
, rev0
, ob0
, &err
);
45 assert(ob0copy
== NULL
);
46 assert(err
== xorn_error_object_doesnt_exist
);
48 xorn_finalize_revision(rev4
);
50 assert(xorn_get_objects(rev4
, &objects
, &count
) == 0);
51 assert(objects
!= NULL
);
53 assert(objects
[0] == ob0
);
54 assert(objects
[1] == ob1b
);
57 xorn_free_revision(rev4
);
60 /* can copy object otherwise */
62 rev4
= xorn_new_revision(rev3
);
66 ob0copy
= xorn_copy_object(rev4
, rev1
, ob0
, &err
);
67 assert(ob0copy
!= NULL
);
68 assert(err
== NO_ERROR
);
70 xorn_finalize_revision(rev4
);
72 assert(xorn_get_object_type(rev4
, ob0copy
) !=
73 xorn_get_object_type(rev4
, ob0
));
74 assert(xorn_get_object_type(rev4
, ob0copy
) ==
75 xorn_get_object_type(rev1
, ob0
));
77 assert(xorn_get_objects(rev4
, &objects
, &count
) == 0);
78 assert(objects
!= NULL
);
80 assert(objects
[0] == ob0
);
81 assert(objects
[1] == ob1b
);
82 assert(objects
[2] == ob0copy
);
85 xorn_free_revision(rev4
);
88 xorn_free_revision(rev3
);
89 xorn_free_revision(rev2
);
90 xorn_free_revision(rev1
);
91 xorn_free_revision(rev0
);