Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
att
GitHub Repository: att/ast
Path: blob/master/src/cmd/tests/aso/taso.c
1810 views
1
/***********************************************************************
2
* *
3
* This software is part of the ast package *
4
* Copyright (c) 1999-2011 AT&T Intellectual Property *
5
* and is licensed under the *
6
* Eclipse Public License, Version 1.0 *
7
* by AT&T Intellectual Property *
8
* *
9
* A copy of the License is available at *
10
* http://www.eclipse.org/org/documents/epl-v10.html *
11
* (with md5 checksum b35adb5213ca9657e911e9befb180842) *
12
* *
13
* Information and Software Systems Research *
14
* AT&T Research *
15
* Florham Park NJ *
16
* *
17
* Glenn Fowler <[email protected]> *
18
* *
19
***********************************************************************/
20
#include "terror.h"
21
22
tmain()
23
{
24
unsigned char vc, rc;
25
unsigned short vs, rs;
26
unsigned int vi, ri;
27
unsigned long vl, rl;
28
void *vp, *rp;
29
30
taso(0);
31
32
vc = 1;
33
if ((rc = asocaschar(&vc, 1, 2)) != 1)
34
terror("asocaschar return value failed -- expected %d, got %d", 1, rc);
35
else if (vc != 2)
36
terror("asocaschar value failed -- expected %d, got %d", 1, vc);
37
else if ((rc = asocaschar(&vc, 1, 3)) != 2)
38
terror("asocaschar return value failed -- expected %d, got %d", 2, rc);
39
else if (vc != 2)
40
terror("asocaschar value failed -- expected %d, got %d", 2, vc);
41
if ((rc = asoincchar(&vc)) != 2)
42
terror("asoincchar return failed -- expected %d, got %d", 2, rc);
43
else if (vc != 3)
44
terror("asoincchar value failed -- expected %d, got %d", 3, vc);
45
if ((rc = asodecchar(&vc)) != 3)
46
terror("asodecchar return failed -- expected %d, got %d", 3, rc);
47
else if (vc != 2)
48
terror("asodecchar value failed -- expected %d, got %d", 2, vc);
49
50
vs = 1;
51
if ((rs = asocasshort(&vs, 1, 2)) != 1)
52
terror("asocasshort return value failed -- expected %d, got %d", 1, rs);
53
else if (vs != 2)
54
terror("asocasshort value failed -- expected %d, got %d", 2, vs);
55
else if ((rs = asocasshort(&vs, 1, 3)) != 2)
56
terror("asocasshort return value failed -- expected %d, got %d", 2, rs);
57
else if (vs != 2)
58
terror("asocasshort value failed -- expected %d, got %d", 2, vs);
59
if ((rs = asoincshort(&vs)) != 2)
60
terror("asoincshort return failed -- expected %d, got %d", 2, rs);
61
else if (vs != 3)
62
terror("asoincshort value failed -- expected %d, got %d", 3, vs);
63
if ((rs = asodecshort(&vs)) != 3)
64
terror("asodecshort return failed -- expected %d, got %d", 3, rs);
65
else if (vs != 2)
66
terror("asodecshort value failed -- expected %d, got %d", 2, vs);
67
68
vi = 1;
69
if ((ri = asocasint(&vi, 1, 2)) != 1)
70
terror("asocasint return value failed -- expected %d, got %d", 1, ri);
71
else if (vi != 2)
72
terror("asocasint value failed -- expected %d, got %d", 2, vi);
73
else if ((ri = asocasint(&vi, 1, 3)) != 2)
74
terror("asocasint return value failed -- expected %d, got %d", 2, ri);
75
else if (vi != 2)
76
terror("asocasint value failed -- expected %d, got %d", 2, vi);
77
if ((ri = asoincint(&vi)) != 2)
78
terror("asoincint return failed -- expected %d, got %d", 2, ri);
79
else if (vi != 3)
80
terror("asoincint value failed -- expected %d, got %d", 3, vi);
81
if ((ri = asodecint(&vi)) != 3)
82
terror("asodecint return failed -- expected %d, got %d", 3, ri);
83
else if (vi != 2)
84
terror("asodecint value failed -- expected %d, got %d", 2, vi);
85
86
vl = 1;
87
if ((rl = asocaslong(&vl, 1, 2)) != 1)
88
terror("asocaslong return value failed -- expected %d, got %ld", 1, rl);
89
else if (vl != 2)
90
terror("asocaslong value failed -- expected %d, got %ld", 2, vl);
91
else if ((rl = asocaslong(&vl, 1, 3)) != 2)
92
terror("asocaslong return value failed -- expected %d, got %ld", 2, rl);
93
else if (vl != 2)
94
terror("asocaslong value failed -- expected %d, got %ld", 2, vl);
95
if ((rl = asoinclong(&vl)) != 2)
96
terror("asoinclong return failed -- expected %d, got %ld", 2, rl);
97
else if (vl != 3)
98
terror("asoinclong value failed -- expected %d, got %ld", 3, vl);
99
if ((rl = asodeclong(&vl)) != 3)
100
terror("asodeclong return failed -- expected %d, got %ld", 3, rl);
101
else if (vl != 2)
102
terror("asodeclong value failed -- expected %d, got %ld", 2, vl);
103
104
vp = (void*)1;
105
if ((rp = asocasptr(&vp, (void*)1, (void*)2)) != (void*)1)
106
terror("asocasptr return value failed -- expected %p, got %p", (void*)1, rp);
107
else if (vp != (void*)2)
108
terror("asocasptr value failed -- expected %p, got %p", (void*)2, vp);
109
else if ((rp = asocasptr(&vp, (void*)1, (void*)3)) != (void*)2)
110
terror("asocasptr return value failed -- expected %p, got %p", (void*)2, rp);
111
else if (vp != (void*)2)
112
terror("asocasptr value failed -- expected %p, got %p", (void*)2, vp);
113
114
texit(0);
115
}
116
117