netlist: Add `tedax' backend
[geda-gaf.git] / tests / storage / invalid_obtype.c
blob9bbc9a1c59ead924df5012566b9e4eec8e8ca1cf
1 /* Copyright (C) 2013-2017 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 <xornstorage.h>
18 #include <assert.h>
19 #include <string.h>
21 #define NO_ERROR ((xorn_error_t) -1)
24 int main(void)
26 xorn_revision_t rev0, rev1, rev2;
27 struct xornsch_line line_data;
28 xorn_object_t ob;
29 xorn_error_t err;
31 rev0 = xorn_new_revision(NULL);
32 assert(rev0 != NULL);
33 xorn_finalize_revision(rev0);
35 rev1 = xorn_new_revision(rev0);
36 assert(rev1 != NULL);
38 memset(&line_data, 0, sizeof line_data);
39 line_data.pos.x = 0;
40 line_data.pos.y = 1;
41 line_data.size.x = 3;
42 line_data.size.y = 2;
43 line_data.color = 3;
44 line_data.line.width = 1;
46 err = NO_ERROR;
47 ob = xorn_add_object(rev1, xorn_obtype_none, &line_data, &err);
48 assert(ob == NULL);
49 assert(err == xorn_error_invalid_argument);
51 err = NO_ERROR;
52 ob = xorn_add_object(rev1, xornsch_obtype_line, &line_data, &err);
53 assert(ob != NULL);
54 assert(err == NO_ERROR);
56 xorn_finalize_revision(rev1);
58 rev2 = xorn_new_revision(rev1);
59 assert(rev2 != NULL);
61 err = NO_ERROR;
62 assert(xorn_set_object_data(
63 rev2, ob, xorn_obtype_none, &line_data, &err) == -1);
64 assert(err == xorn_error_invalid_argument);
66 err = NO_ERROR;
67 assert(xorn_set_object_data(
68 rev2, ob, xornsch_obtype_line, &line_data, &err) == 0);
69 assert(err == NO_ERROR);
71 xorn_finalize_revision(rev2);
73 xorn_free_revision(rev2);
74 xorn_free_revision(rev1);
75 xorn_free_revision(rev0);
76 return 0;