Design: 02.02.03/P02

This is an abstract, language-independent design. Grim details may be found in the corresponding source code. You may return to the documentation for the module containing this program design, or to the entire hierarchical table of topics covered by the PVT.


PROGRAM 2: Set edit mode to REPLACE and manipulate element pointer

CHARACTERISTICS: nnnn

OPERATOR SCRIPT: passive test.

DESIGN:

Use <inquire edit mode> throughout to determine:
    edmod = edit mode

Use <inquire element pointer> throughout to determine:
    ielpos = element position

strid  = 35
label1 = 11
label2 = 12
label3 = 13
label4 = 14
label5 = 15

<open structure> with strid

fill structure with elements:
<label> with label1
<label> with label2
<label> with label3
<label> with label4
<label> with label5

<set edit mode> to REPLACE
TEST: #SR 1 11
      "<Inquire edit mode> should return the current edit mode as REPLACE."
<inquire edit mode> to set edmod
pass/fail depending on (edmod = REPLACE)

elepos = 2
<set element pointer> to elepos
<label> with label4
TEST: #SR 3
      "When <set edit mode> is REPLACE, new elements should replace the
       element pointed to by the element pointer."
pass/fail depending on
  (current structure contents = labels 11, 14, 13, 14, 15)

TEST: #SR 4
      "When the edit mode is REPLACE, the element pointer should be
       updated to point to the new element after replacement."
pass/fail depending on (current element position = 2)

elepos = 10
<set element pointer> to elepos
TEST: #SR 7 10
      "If <set element pointer> is used to position the element pointer
       to a position greater than the last element in the open structure,
       the element pointer should point to the last element."
pass/fail depending on (current element position = 5)

elpsof = 7
<offset element pointer> with elpsof
TEST: #SR 8 10
      "If <offset element pointer> is used to position the element pointer
       to a position greater than the last element in the open structure,
       the element pointer should point to the last element."
pass/fail depending on (current element position = 5)

elepos = -3
<set element pointer> to elepos
TEST: #SR 7 10
      "If <set element pointer> is used to position the element pointer
       to a position less than zero, the element pointer should point
       to zero."
pass/fail depending on (current element position = 0)

elpsof = -6
<offset element pointer> with elpsof
TEST: #SR 8 10
      "If <offset element pointer> is used to position the element pointer
       to a position less than zero, the element pointer should point
       to zero."
pass/fail depending on (current element position = 0)

<label> with label5
TEST: #SR 6
      "If the element pointer is 0, then the new element should be inserted
       immediately before element 1 even when edit mode is REPLACE."
pass/fail depending on
  (current structure contents = labels 15, 11, 14, 13, 14, 15)

TEST: #SR 6
      "After an insertion of an element at the beginning of a structure,
       the element pointer should become 1 and point at the new element."
pass/fail depending on (current element position = 1)

<set element pointer at label> with label5
TEST: #SR 9
      "If the element pointer is already positioned at a label element,
       <set element pointer at label> should position the element pointer
       at the next occurence of a specified label element within the open
       structure."
pass/fail depending on (current element position = 6)

<close phigs>
<open phigs>
TEST: #SR 5 11
      "Closing and re-opening PHIGS should re-set the edit mode to INSERT."
<inquire edit mode> to set edmod
pass/fail depending on (edmod = INSERT)

END PROGRAM 2