Add some information to the man page and README file.
[wine/multimedia.git] / ipc / dde_atom_test.c
blob43915692360d48b0616334f6edcf9239ab7a22f1
1 /***************************************************************************
2 * Copyright 1995, Technion, Israel Institute of Technology
3 * Electrical Eng, Software Lab.
4 * Author: Michael Veksler.
5 ***************************************************************************
6 * File: dde_atom_test.c
7 * Purpose : tests for dde_atom object
8 ***************************************************************************
9 */
10 #include <stdio.h>
11 #include <stdlib.h>
12 #include <win.h>
13 #include "dde_atom.h"
14 #include "shm_main_blk.h"
15 #include <debug.h>
16 #define TOGETHER (DDE_ATOMS/5)
19 /* run random sequences */
20 int main()
22 ATOM atom_list[TOGETHER];
23 char str[TOGETHER][80];
24 int i,j,atom_n;
25 int atom_len[TOGETHER];
27 TRACE_ON(shm)=1;
28 TRACE_ON(atom)=0;
29 TRACE_ON(sem)=0;
31 for (i=0 ; i<=10000/TOGETHER ; i++) {
32 for (atom_n=0 ; atom_n<TOGETHER ; atom_n++) {
33 atom_len[atom_n]=rand()%64+1;
34 for (j=atom_len[atom_n]-1; j>=0; j--)
35 do {
36 str[atom_n][j]=(char)(rand()%255+1);
37 } while (j==0 && str[atom_n][j]=='#');
39 str[atom_n][ atom_len[atom_n] ]='\0';
41 atom_list[atom_n]=GlobalAddAtom(str[atom_n]);
43 if (atom_list[atom_n]==0) {
44 fprintf(stderr,"failed i=%d, atom_n=%d\n",i,atom_n);
45 return 1;
47 if (atom_list[atom_n]!=GlobalAddAtom(str[atom_n])) {
48 fprintf(stderr,
49 "wrong second GlobalAddAtom(\"%s\")\n", str[atom_n]);
50 return 1;
52 } /* for */
53 for (atom_n=0 ; atom_n<TOGETHER ; atom_n++) {
54 char buf[80];
55 int len;
57 len=GlobalGetAtomName( atom_list[atom_n], buf, 79);
58 if (atom_len[atom_n] != len) {
59 fprintf(stderr, "i=%d, atom_n=%d; ", i, atom_n);
60 fprintf(stderr,
61 "wrong length of GlobalGetAtomName(\"%s\")\n",
62 str[atom_n]);
64 return 1;
68 for (atom_n=0 ; atom_n<TOGETHER ; atom_n++) {
69 GlobalDeleteAtom(atom_list[atom_n]);
70 if (atom_list[atom_n]!=GlobalAddAtom(str[atom_n])) {
71 fprintf(stderr, "i=%d, atom_n=%d; ", i, atom_n);
72 fprintf(stderr,
73 "wrong third GlobalAddAtom(\"%s\")\n", str[atom_n]);
74 return 1;
76 GlobalDeleteAtom(atom_list[atom_n]);
77 GlobalDeleteAtom(atom_list[atom_n]);
79 atom_list[atom_n]=GlobalAddAtom(str[atom_n]);
80 if (atom_list[atom_n]!=GlobalAddAtom(str[atom_n])) {
81 fprintf(stderr,
82 "i=%d, atom_n=%d wrong fifth GlobalAddAtom(\"%s\")\n",
83 i, atom_n,
84 str[atom_n]);
85 return 1;
87 GlobalDeleteAtom(atom_list[atom_n]);
88 if (atom_list[atom_n]!=GlobalFindAtom(str[atom_n])) {
89 fprintf(stderr,
90 "i=%d, atom_n=%d wrong GlobalFindAtom(\"%s\")\n",
91 i, atom_n,
92 str[atom_n]);
93 return 1;
95 GlobalDeleteAtom(atom_list[atom_n]);
98 return 0;