summaryrefslogtreecommitdiff
path: root/xc/test/xsuite/xtest/tset/CH10/strbyts/strbyts.m
blob: 055a860c2505b1120f65609111af44e3c73dfc19 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/*
 * Copyright 1990, 1991 by the Massachusetts Institute of Technology and
 * UniSoft Group Limited.
 * 
 * Permission to use, copy, modify, distribute, and sell this software and
 * its documentation for any purpose is hereby granted without fee,
 * provided that the above copyright notice appear in all copies and that
 * both that copyright notice and this permission notice appear in
 * supporting documentation, and that the names of MIT and UniSoft not be
 * used in advertising or publicity pertaining to distribution of the
 * software without specific, written prior permission.  MIT and UniSoft
 * make no representations about the suitability of this software for any
 * purpose.  It is provided "as is" without express or implied warranty.
 *
 * $XConsortium$
 */
>>TITLE XStoreBytes CH10

XStoreBytes(display, bytes, nbytes)
Display	*display = Dsp;
char	*bytes = buff;
int	nbytes = NELEM(buff);
>>EXTERN
static char	buff[1217];
>>ASSERTION Good A
A call to xname stores
.A nbytes
bytes from the
.A bytes
argument into cut buffer zero.
>>STRATEGY
Store bytes in cut buffer 0 using xname.
Obtain the contents of cut buffer 0 using XFetchBuffer.
Verify that the buffer contents is correct.
>>CODE
char	*bp;
char	*bpr = (char *) NULL;
int	i;
int	br;

	for(i=NELEM(buff), bp = buff; i>0; *bp++ = (char) (i & 255), i--);

	XCALL;

	bp = XFetchBuffer(display, &br, 0);

	if(bp == (char *) NULL) {
		report("%s() did not set buffer 0 to contain any data.", TestName);
		FAIL;
	} else {
		CHECK;

		if(br != NELEM(buff)) {
			report("%s() set buffer 0 to contain %d bytes instead of %d.", TestName, br, NELEM(buff));
			FAIL;
		} else {
			CHECK;

			if(memcmp(bp, buff, NELEM(buff)) != 0) {
				report("%s() set buffer 0 to contain the wrong data.", TestName);
				FAIL;
			} else
				CHECK;
		}

		XFree(bp);
	}

	CHECKPASS(3);

>>ASSERTION Bad B 1
.ER BadAlloc