Merge fixes from branch 'xorn'
[geda-gaf.git] / xorn / tests / storage / stat.c
blob645b8a3ffe962d7689403f7a352235e73184b439
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. */
17 #include "Setup.h"
18 #include <stdlib.h>
21 int main(void)
23 xorn_revision_t rev0, rev1, rev2, rev3;
24 xorn_object_t ob0, ob1a, ob1b;
26 xorn_object_t *objects;
27 size_t count;
29 setup(&rev0, &rev1, &rev2, &rev3, &ob0, &ob1a, &ob1b);
31 assert(xorn_get_added_objects(rev0, rev1, &objects, &count) == 0);
32 assert(objects != NULL);
33 assert(count == 1);
34 assert(objects[0] == ob0);
35 free(objects);
36 assert(xorn_get_removed_objects(rev0, rev1, &objects, &count) == 0);
37 assert(count == 0);
38 free(objects);
39 assert(xorn_get_modified_objects(rev0, rev1, &objects, &count) == 0);
40 assert(count == 0);
41 free(objects);
43 assert(xorn_get_added_objects(rev1, rev2, &objects, &count) == 0);
44 assert(objects != NULL);
45 assert(count == 2);
46 assert((objects[0] == ob1a && objects[1] == ob1b) ||
47 (objects[0] == ob1b && objects[1] == ob1a));
48 free(objects);
49 assert(xorn_get_removed_objects(rev1, rev2, &objects, &count) == 0);
50 assert(count == 0);
51 free(objects);
52 assert(xorn_get_modified_objects(rev1, rev2, &objects, &count) == 0);
53 assert(count == 0);
54 free(objects);
56 assert(xorn_get_added_objects(rev2, rev3, &objects, &count) == 0);
57 assert(count == 0);
58 free(objects);
59 assert(xorn_get_removed_objects(rev2, rev3, &objects, &count) == 0);
60 assert(objects != NULL);
61 assert(count == 1);
62 assert(objects[0] == ob1a);
63 free(objects);
64 assert(xorn_get_modified_objects(rev2, rev3, &objects, &count) == 0);
65 assert(objects != NULL);
66 assert(count == 1);
67 assert(objects[0] == ob0);
68 free(objects);
70 xorn_free_revision(rev3);
71 xorn_free_revision(rev2);
72 xorn_free_revision(rev1);
73 xorn_free_revision(rev0);
74 return 0;