Authors: Chris Morgan <cmorgan@wpi.edu>, James Abbatiello <abbejy@wpi.edu>
[wine/multimedia.git] / ipc / dde_atom_test.c
blob8038f40770665486a30f727d8d88f046df5b895a
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>
17 DECLARE_DEBUG_CHANNEL(atom)
18 DECLARE_DEBUG_CHANNEL(sem)
19 DECLARE_DEBUG_CHANNEL(shm)
20 #define TOGETHER (DDE_ATOMS/5)
23 /* run random sequences */
24 int main()
26 ATOM atom_list[TOGETHER];
27 char str[TOGETHER][80];
28 int i,j,atom_n;
29 int atom_len[TOGETHER];
31 TRACE_ON(shm)=1;
32 TRACE_ON(atom)=0;
33 TRACE_ON(sem)=0;
35 for (i=0 ; i<=10000/TOGETHER ; i++) {
36 for (atom_n=0 ; atom_n<TOGETHER ; atom_n++) {
37 atom_len[atom_n]=rand()%64+1;
38 for (j=atom_len[atom_n]-1; j>=0; j--)
39 do {
40 str[atom_n][j]=(char)(rand()%255+1);
41 } while (j==0 && str[atom_n][j]=='#');
43 str[atom_n][ atom_len[atom_n] ]='\0';
45 atom_list[atom_n]=GlobalAddAtom(str[atom_n]);
47 if (atom_list[atom_n]==0) {
48 fprintf(stderr,"failed i=%d, atom_n=%d\n",i,atom_n);
49 return 1;
51 if (atom_list[atom_n]!=GlobalAddAtom(str[atom_n])) {
52 fprintf(stderr,
53 "wrong second GlobalAddAtom(\"%s\")\n", str[atom_n]);
54 return 1;
56 } /* for */
57 for (atom_n=0 ; atom_n<TOGETHER ; atom_n++) {
58 char buf[80];
59 int len;
61 len=GlobalGetAtomName( atom_list[atom_n], buf, 79);
62 if (atom_len[atom_n] != len) {
63 fprintf(stderr, "i=%d, atom_n=%d; ", i, atom_n);
64 fprintf(stderr,
65 "wrong length of GlobalGetAtomName(\"%s\")\n",
66 str[atom_n]);
68 return 1;
72 for (atom_n=0 ; atom_n<TOGETHER ; atom_n++) {
73 GlobalDeleteAtom(atom_list[atom_n]);
74 if (atom_list[atom_n]!=GlobalAddAtom(str[atom_n])) {
75 fprintf(stderr, "i=%d, atom_n=%d; ", i, atom_n);
76 fprintf(stderr,
77 "wrong third GlobalAddAtom(\"%s\")\n", str[atom_n]);
78 return 1;
80 GlobalDeleteAtom(atom_list[atom_n]);
81 GlobalDeleteAtom(atom_list[atom_n]);
83 atom_list[atom_n]=GlobalAddAtom(str[atom_n]);
84 if (atom_list[atom_n]!=GlobalAddAtom(str[atom_n])) {
85 fprintf(stderr,
86 "i=%d, atom_n=%d wrong fifth GlobalAddAtom(\"%s\")\n",
87 i, atom_n,
88 str[atom_n]);
89 return 1;
91 GlobalDeleteAtom(atom_list[atom_n]);
92 if (atom_list[atom_n]!=GlobalFindAtom(str[atom_n])) {
93 fprintf(stderr,
94 "i=%d, atom_n=%d wrong GlobalFindAtom(\"%s\")\n",
95 i, atom_n,
96 str[atom_n]);
97 return 1;
99 GlobalDeleteAtom(atom_list[atom_n]);
102 return 0;