/*****************************************************************/
/**                                                             **/
/**             (C) Copyright 1992 the Regents of the           **/
/**        University of California.  All Rights Reserved.      **/
/**                                                             **/
/**        This work was produced under the sponsorship of      **/
/**         the U.S. Department of Energy.  The Government      **/
/**                retains certain rights therein.              **/
/**                                                             **/
/**                         Written by                          **/
/**         Distributed Programming Environments Project        **/
/**           Computer Software and Networking Division,        **/
/**                   Livermore Computer Center,                **/
/**            Lawrence Livermore National Laboratory           **/
/**                                                             **/
/*****************************************************************/

Interface sample;

Union
{
   Integer(4)     int4u1;
   Enumerated(4)  en4u2;
} u2inten;

End;

main(argc,argv)
   int argc;
   char *argv[];
{
   u2inten v1_s,v1_r;
   Data (sample) inst;

   if (argc != 2)
      exit(1);
   v1_s.tag = 1;
   v1_s.un.en4u2 = 56;

/***************** send it out ************************/

   Bind_STUB(inst,argv[1],"w",Asn_1_ber);
   Encode inst
   {
      v1_s => u2inten;
   }
   Unbind(inst);

/***************** receive it back ********************/

   Bind_STUB(inst,argv[1],"r",Asn_1_ber);
   Decode inst
   {
      On u2inten => (v1_r);
   }
   Unbind(inst);

/***************** report results *********************/

   if (cmpun(v1_s,v1_r)) {
      printf("   v1 value was bad\n");
   }

   printf("test completed\n");
   return 0;
}


int cmpun(u1, u2)
u2inten u1,u2;
{
   int l1,l2;

   switch (u2.tag) {
      case 0:
	 if (u1.un.int4u1 != u2.un.int4u1)
	    return 1;
	 break;
      case 1:
	 if (u1.un.en4u2 != u2.un.en4u2)
	    return 1;
	 break;
      default:
	 return 1;
   }
   return 0;
}
