| 1 | #set square 0 |
| 2 | if { [isdraw result] } { |
| 3 | #check if result is valid |
| 4 | |
| 5 | puts [checkshape result] |
| 6 | set prop "square" |
| 7 | set mass $square |
| 8 | regexp {Mass +: +([-0-9.+eE]+)} [sprops result] full m |
| 9 | |
| 10 | if { [string compare "$mass" "empty"] != 0 } { |
| 11 | if { $m == 0 } { |
| 12 | puts "Error : The $command is not valid. The $prop is 0." |
| 13 | } |
| 14 | if { $mass > 0 } { |
| 15 | puts "The expected $prop is $mass" |
| 16 | } |
| 17 | #check of change of square is < 1% |
| 18 | if { ($mass != 0 && [expr 1.*abs($mass - $m)/$mass] > 0.01) || ($mass == 0 && $m != 0) } { |
| 19 | puts "Error : The $prop of the resulting shape is $m" |
| 20 | } |
| 21 | } else { |
| 22 | if { $m != 0 } { |
| 23 | puts "Error : The $command is not valid. The $prop is $m" |
| 24 | } |
| 25 | } |
| 26 | |
| 27 | set glob_inf [info global nb_*_good] |
| 28 | if { [regexp "nb_.*_good" $glob_inf] == 1 } { |
| 29 | if { [info exists nbsh_t] } { |
| 30 | set nb_info [nbshapes result -t] |
| 31 | } else { |
| 32 | set nb_info [nbshapes result] |
| 33 | } |
| 34 | } |
| 35 | |
| 36 | if { [info exists nb_v_good] } { |
| 37 | regexp {VERTEX +: +([-0-9.+eE]+)} $nb_info full nb_v |
| 38 | if { ${nb_v} != ${nb_v_good} } { |
| 39 | puts "Error : The resulting shape is WRONG because it must contains ${nb_v_good} vertexes instead of ${nb_v}" |
| 40 | } else { |
| 41 | puts "The resulting shape contains ${nb_v} vertexes" |
| 42 | } |
| 43 | } |
| 44 | |
| 45 | if { [info exists nb_e_good] } { |
| 46 | regexp {EDGE +: +([-0-9.+eE]+)} $nb_info full nb_e |
| 47 | if { ${nb_e} != ${nb_e_good} } { |
| 48 | puts "Error : The resulting shape is WRONG because it must contains ${nb_e_good} edges instead of ${nb_e}" |
| 49 | } else { |
| 50 | puts "The resulting shape contains ${nb_e} edges" |
| 51 | } |
| 52 | } |
| 53 | |
| 54 | if { [info exists nb_w_good] } { |
| 55 | regexp {WIRE +: +([-0-9.+eE]+)} $nb_info full nb_w |
| 56 | if { ${nb_w} != ${nb_w_good} } { |
| 57 | puts "Error : The resulting shape is WRONG because it must contains ${nb_w_good} wires instead of ${nb_w}" |
| 58 | } else { |
| 59 | puts "The resulting shape contains ${nb_w} wires" |
| 60 | } |
| 61 | } |
| 62 | |
| 63 | if { [info exists nb_f_good] } { |
| 64 | regexp {FACE +: +([-0-9.+eE]+)} $nb_info full nb_f |
| 65 | if { ${nb_f} != ${nb_f_good} } { |
| 66 | puts "Error : The resulting shape is WRONG because it must contains ${nb_f_good} faces instead of ${nb_f}" |
| 67 | } else { |
| 68 | puts "The resulting shape contains ${nb_f} faces" |
| 69 | } |
| 70 | } |
| 71 | |
| 72 | if { [info exists nb_sh_good] } { |
| 73 | regexp {SHELL +: +([-0-9.+eE]+)} $nb_info full nb_sh |
| 74 | if { ${nb_sh} != ${nb_sh_good} } { |
| 75 | puts "Error : The resulting shape is WRONG because it must contains ${nb_sh_good} shells instead of ${nb_sh}" |
| 76 | } else { |
| 77 | puts "The resulting shape contains ${nb_sh} shells" |
| 78 | } |
| 79 | } |
| 80 | |
| 81 | if { [info exists nb_sol_good] } { |
| 82 | regexp {SOLID +: +([-0-9.+eE]+)} $nb_info full nb_sol |
| 83 | if { ${nb_sol} != ${nb_sol_good} } { |
| 84 | puts "Error : The resulting shape is WRONG because it must contains ${nb_sol_good} solids instead of ${nb_sol}" |
| 85 | } else { |
| 86 | puts "The resulting shape contains ${nb_sol} solids" |
| 87 | } |
| 88 | } |
| 89 | |
| 90 | if { [info exists nb_compsol_good] } { |
| 91 | regexp {COMPSOLID +: +([-0-9.+eE]+)} $nb_info full nb_compsol |
| 92 | if { ${nb_compsol} != ${nb_compsol_good} } { |
| 93 | puts "Error : The resulting shape is WRONG because it must contains ${nb_compsol_good} compsolids instead of ${nb_compsol}" |
| 94 | } else { |
| 95 | puts "The resulting shape contains ${nb_compsol} compsolids" |
| 96 | } |
| 97 | } |
| 98 | |
| 99 | if { [info exists nb_compound_good] } { |
| 100 | regexp {COMPOUND +: +([-0-9.+eE]+)} $nb_info full nb_compound |
| 101 | if { ${nb_compound} != ${nb_compound_good} } { |
| 102 | puts "Error : The resulting shape is WRONG because it must contains ${nb_compound_good} compounds instead of ${nb_compound}" |
| 103 | } else { |
| 104 | puts "The resulting shape contains ${nb_compound} compounds" |
| 105 | } |
| 106 | } |
| 107 | |
| 108 | if { [info exists nb_shape_good] } { |
| 109 | regexp {SHAPE +: +([-0-9.+eE]+)} $nb_info full nb_shape |
| 110 | if { ${nb_shape} != ${nb_shape_good} } { |
| 111 | puts "Error : The resulting shape is WRONG because it must contains ${nb_shape_good} shapes instead of ${nb_shape}" |
| 112 | } else { |
| 113 | puts "The resulting shape contains ${nb_shape} shapes" |
| 114 | } |
| 115 | } |
| 116 | |
| 117 | |
| 118 | if { $m > 0 } { |
| 119 | smallview |
| 120 | clear |
| 121 | donly result |
| 122 | fit |
| 123 | xwd $imagedir/${test_image}.png |
| 124 | } else { |
| 125 | smallview |
| 126 | clear |
| 127 | fit |
| 128 | xwd $imagedir/${test_image}.png |
| 129 | } |
| 130 | } else { |
| 131 | puts "Error : The $command cannot be built." |
| 132 | } |
| 133 | |
| 134 | # to end a test script |
| 135 | puts "TEST COMPLETED" |