Release 970305
[wine] / ipc / dde_mem_test.c
1 /***************************************************************************
2  * Copyright 1995, Technion, Israel Institute of Technology
3  * Electrical Eng, Software Lab.
4  * Author:    Michael Veksler.
5  ***************************************************************************
6  * File:      dde_mem_test.c
7  * Purpose :  test shared DDE memory functionality for DDE
8  * Usage:     Look for assertion failures
9  ***************************************************************************
10  */
11 #include <stdio.h>
12 #include <assert.h>
13 #include <win.h>
14 #include "dde_mem.h"
15 /* stub */
16
17 void ATOM_GlobalInit()
18 {
19   printf("ATOM_GlobalInit\n");
20 }
21
22
23 int main()
24 {
25   HWND h1,h2,h3;
26   int ret;
27   void *p1,*p2,*p3,*p;
28   SHMDATA shmdata;
29   
30   /* alloc h1, h2, h3 */
31
32   setbuf(stdout,NULL);
33   p1=DDE_malloc(GMEM_DDESHARE, 0x6000, &shmdata);
34   h1= shmdata.handle;
35   assert(p1 != NULL);
36   assert(h1 != 0);
37   p2=DDE_malloc(GMEM_DDESHARE, 0xff00, &shmdata);
38   h2= shmdata.handle;
39   assert(p2 != NULL);
40   assert(h2 != 0);
41   p3=DDE_malloc(GMEM_DDESHARE, 0x6000, &shmdata);
42   h3= shmdata.handle;
43   assert(p3 != 0);
44   assert(h3 != 0);
45
46   /* lock h1, h2, h3 */
47   p=DDE_AttachHandle(h1,NULL);
48   assert(p1==p);
49   p=DDE_AttachHandle(h2,NULL);
50   assert(p2==p);
51   p=DDE_AttachHandle(h3,NULL);
52   assert(p3==p);
53
54
55   
56   ret=DDE_GlobalFree(h1);
57   assert(ret==0);
58   /* do some implementation dependant tests */
59   p=DDE_malloc(GMEM_DDESHARE, 0x6000, &shmdata);
60   assert(p!=NULL);
61   assert(shmdata.handle==h1);
62   p=DDE_AttachHandle(h1,NULL);
63   assert(p1==p);
64
65   /* check freeing */
66   ret=DDE_GlobalFree(h1);
67   assert(ret==0);
68   ret=DDE_GlobalFree(h2);
69   assert(ret==0);
70   ret=DDE_GlobalFree(h3);
71   assert(ret==0);
72   return 0;
73 }