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 ***************************************************************************
14 #include "shm_main_blk.h"
17 #define TOGETHER (DDE_ATOMS/5)
20 /* run random sequences */
23 ATOM atom_list[TOGETHER];
24 char str[TOGETHER][80];
26 int atom_len[TOGETHER];
32 for (i=0 ; i<=10000/TOGETHER ; i++) {
33 for (atom_n=0 ; atom_n<TOGETHER ; atom_n++) {
34 atom_len[atom_n]=rand()%64+1;
35 for (j=atom_len[atom_n]-1; j>=0; j--)
37 str[atom_n][j]=(char)(rand()%255+1);
38 } while (j==0 && str[atom_n][j]=='#');
40 str[atom_n][ atom_len[atom_n] ]='\0';
42 atom_list[atom_n]=GlobalAddAtom(str[atom_n]);
44 if (atom_list[atom_n]==0) {
45 fprintf(stderr,"failed i=%d, atom_n=%d\n",i,atom_n);
48 if (atom_list[atom_n]!=GlobalAddAtom(str[atom_n])) {
50 "wrong second GlobalAddAtom(\"%s\")\n", str[atom_n]);
54 for (atom_n=0 ; atom_n<TOGETHER ; atom_n++) {
58 len=GlobalGetAtomName( atom_list[atom_n], buf, 79);
59 if (atom_len[atom_n] != len) {
60 fprintf(stderr, "i=%d, atom_n=%d; ", i, atom_n);
62 "wrong length of GlobalGetAtomName(\"%s\")\n",
69 for (atom_n=0 ; atom_n<TOGETHER ; atom_n++) {
70 GlobalDeleteAtom(atom_list[atom_n]);
71 if (atom_list[atom_n]!=GlobalAddAtom(str[atom_n])) {
72 fprintf(stderr, "i=%d, atom_n=%d; ", i, atom_n);
74 "wrong third GlobalAddAtom(\"%s\")\n", str[atom_n]);
77 GlobalDeleteAtom(atom_list[atom_n]);
78 GlobalDeleteAtom(atom_list[atom_n]);
80 atom_list[atom_n]=GlobalAddAtom(str[atom_n]);
81 if (atom_list[atom_n]!=GlobalAddAtom(str[atom_n])) {
83 "i=%d, atom_n=%d wrong fifth GlobalAddAtom(\"%s\")\n",
88 GlobalDeleteAtom(atom_list[atom_n]);
89 if (atom_list[atom_n]!=GlobalFindAtom(str[atom_n])) {
91 "i=%d, atom_n=%d wrong GlobalFindAtom(\"%s\")\n",
96 GlobalDeleteAtom(atom_list[atom_n]);