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"
16 #define TOGETHER (DDE_ATOMS/5)
19 /* run random sequences */
22 ATOM atom_list[TOGETHER];
23 char str[TOGETHER][80];
25 int atom_len[TOGETHER];
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--)
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);
47 if (atom_list[atom_n]!=GlobalAddAtom(str[atom_n])) {
49 "wrong second GlobalAddAtom(\"%s\")\n", str[atom_n]);
53 for (atom_n=0 ; atom_n<TOGETHER ; atom_n++) {
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);
61 "wrong length of GlobalGetAtomName(\"%s\")\n",
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);
73 "wrong third GlobalAddAtom(\"%s\")\n", str[atom_n]);
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])) {
82 "i=%d, atom_n=%d wrong fifth GlobalAddAtom(\"%s\")\n",
87 GlobalDeleteAtom(atom_list[atom_n]);
88 if (atom_list[atom_n]!=GlobalFindAtom(str[atom_n])) {
90 "i=%d, atom_n=%d wrong GlobalFindAtom(\"%s\")\n",
95 GlobalDeleteAtom(atom_list[atom_n]);