/* $XConsortium: editmode4.pi,v 5.2 94/04/17 20:46:58 rws Exp $ */ /***************************************************************** Copyright (c) 1989, 1990, 1991,1990 X Consortium Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. Except as contained in this notice, the name of the X Consortium shall not be used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization from the X Consortium. Copyright (c) 1989, 1990, 1991,1990 by Sun Microsystems, Inc. All Rights Reserved Permission to use, copy, modify, and distribute this software and its documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in supporting documentation, and that the names of Sun Microsystems, and the X Consortium, not be used in advertising or publicity pertaining to distribution of the software without specific, written prior permission. SUN MICROSYSTEMS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SUN MICROSYSTEMS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ******************************************************************/ ## editmode4.pi - test functionity of INSERT edit mode. ## Insert elements into an empty structure, and at beginning, middle, ## and end of existing structure. tbegintest("editmode4","Editing structures with INSERT mode"); source macro.pi /* general testing utility macros */ source strmacro.pi /* macros for structure content area, like im_confirm_xx */ source apimacro.pi /* macros for api-specific functions */ # Set up phigs, workstation, and structure i_open_phigs(NULL,PDEF_MEM_SIZE); i_open_ws(1); popen_struct(1); ppost_struct(1,1,1.0); # test that initial element pointer is 0 im_confirm_elemptr(0, "failed: Initial element pointer %d, expected 0\n"); # Add an element to the empty structure (edge colour index) # (struct should become: (EDGE_COLOUR_INDEX)) pset_edge_colr_ind(2); im_confirm_elemptr(1, "failed: Elem ptr %d, not 1, after adding element to empty struct\n"); im_confirm_elemtype(1, 1, PELEM_EDGE_COLR_IND, "failed: First element added, %d, should be EDGE_COLOUR_INDEX\n"); # Adding another element (linetype, label), which should go after prev. # (struct should become (EDGE_COLOUR_INDEX, LINETYPE, LABEL)) pset_linetype(1); plabel(3); im_confirm_elemptr(3, "failed: elem pointer is %d, should have become 3\n"); im_confirm_elemtype(1, 1, PELEM_EDGE_COLR_IND, "failed: first element EDGE_COLOUR_INDEX replaced by %d\n"); im_confirm_elemtype(1, 2, PELEM_LINETYPE, "failed: second element %d should have become PELEM_LINETYPE"); im_confirm_elemtype(1, 3, PELEM_LABEL, "failed: third element %d should have become PELEM_LABEL"); # Set pointer to 2, insert MARKER_TYPE after LINETYPE # (struct should become (EDGE_COLOUR_INDEX, LINETYPE, MARKER_TYPE, LABEL)) pset_elem_ptr(2); pset_marker_type(3); im_confirm_elemptr(3, "failed: elem pointer, %d, should have advanced to 3\n"); im_confirm_elemtype(1, 2, PELEM_LINETYPE, "failed: element 2 was %d, expected PELEM_LINETYPE\n"); im_confirm_elemtype(1, 3, PELEM_MARKER_TYPE, "failed: element 3 was %d, expected PEL_MARKERTYPE\n"); im_confirm_elemtype(1, 4, PELEM_LABEL, "failed: fourth element %d should have become PELEM_LABEL"); # Add element EDGE_TYPE to end of structure # (struct should become: (EDGE_COLOUR_INDEX,LINETYPE,MARKER_TYPE,LABEL,EDGETYPE)) pset_elem_ptr(4); pset_edgetype(3); im_confirm_elemptr(5, "failed: elem pointer %d should have advanced to 5\n"); im_confirm_elemtype(1, 5, PELEM_EDGETYPE, "failed: last element %d should have been replaced by PELEM_EDGETYPE\n"); # Insert LINEWIDTH at beginning of structure # (struct should become: (LINEWIDTH, EDGE_COLOUR_INDEX, ...)) pset_elem_ptr(0); pset_linewidth(2.0); im_confirm_elemptr(1, "failed: Element pointer %d didn't avance to 1\n"); im_confirm_elemtype(1, 1, PELEM_LINEWIDTH, "failed: first element %d should be displaced by LINEWIDTH\n"); im_confirm_elemtype(1, 2, PELEM_EDGE_COLR_IND, "failed: second element should %d now be EDGE_COLOUR_INDEX\n"); pclose_struct(); pclose_ws(1); pclose_phigs(); tendtest();