home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / libs / tsipp / tsipp.lha / tsipp3.0a / tests / poly.test < prev    next >
Encoding:
Text File  |  1992-11-02  |  3.4 KB  |  138 lines

  1. #==============================================================================
  2. #                                 poly.test
  3. #------------------------------------------------------------------------------
  4. # Test of the Tcl SIPP polygon commands.
  5. #------------------------------------------------------------------------------
  6. # Copyright 1992 Mark Diekhans
  7. # Permission to use, copy, modify, and distribute this software and its
  8. # documentation for any purpose and without fee is hereby granted, provided
  9. # that the above copyright notice appear in all copies.  Mark Diekhans makes
  10. # no representations about the suitability of this software for any purpose.
  11. # It is provided "as is" without express or implied warranty.
  12. #------------------------------------------------------------------------------
  13. # $Id: poly.test,v 2.0 1992/11/02 03:55:57 markd Rel $
  14. #==============================================================================
  15.  
  16. if {[info procs test] == ""} {source testprocs.tcl}
  17.  
  18. proc MakePolys {testid} {
  19.     test $testid {
  20.         SippVertexPush {{0 0 0}}
  21.         set vertexList {{ 0  0  0} {-1  0  0} {-1 -1  0} {-1 -1  0}}
  22.         SippPolygonPush
  23.  
  24.         set vertexList {{ 0  0  0} {-1  0  0} {-1 -1  0} {-1 -1  0}}
  25.         SippPolygonPush $vertexList
  26.     } 0 {}
  27. }
  28.  
  29. #
  30. # Test setup.
  31. #
  32.  
  33. test {polygon-1.1} {
  34.     set shader1 [SippShaderBasic .6 .1 .4 {.8 .5 .2}]
  35.     crange $shader1 0 5
  36. } 0 {shader}
  37.  
  38. #
  39. # Test SippVertexPush command.
  40. #
  41.  
  42. test {polygon-2.1} {
  43.     SippVertexPush
  44. } 1 {wrong # args: SippVertexPush [-tex] vertexList}
  45.  
  46. test {polygon-2.2} {
  47.     SippVertexPush {a b}
  48. } 1 {vertex or vector must be a list of three elements}
  49.  
  50. test {polygon-2.3} {
  51.     SippVertexPush {{1 2}}
  52. } 1 {vertex or vector must be a list of three elements}
  53.  
  54. test {polygon-2.4} {
  55.     SippVertexPush {{1 2 3} {1 2}}
  56. } 1 {vertex or vector must be a list of three elements}
  57.  
  58. #
  59. # Test SippPolygonPush command.
  60. #
  61.  
  62. test {polygon-3.1} {
  63.     SippPolygonPush {2 3} {1 2 2}
  64. } 1 {expected option of `-tex', got `2 3'}
  65.  
  66. test {polygon-3.2} {
  67.     SippPolygonPush {{1 2 3} {1 2 a}}
  68. } 1 {expected floating-point number but got "a"}
  69.  
  70. test {polygon-3.3} {
  71.     SippPolygonPush -tex {{1 2 3} {1 2 a}}
  72. } 1 {vertex-texture list must be a list of two coordinates}
  73.  
  74. #
  75. # Test SippSurfaceCreate command.
  76. #
  77.  
  78. test {polygon-4.1} {
  79.     set surface [SippSurfaceCreate foo]
  80. } 1 {invalid shader handle: foo}
  81.  
  82. test {polygon-4.2} {
  83.     set surface1 [SippSurfaceCreate $shader1]
  84. } 1 {the polygon stack is empty}
  85.  
  86. test {polygon-4.3} {
  87.     MakePolys polygon-4.3
  88.     set surface1 [SippSurfaceCreate $shader1]
  89.     SippSurfaceDelete $surface1
  90.     crange $surface1 0 6
  91. } 0 {surface}
  92.  
  93. #
  94. # Test SippSurfaceDelete command.
  95. #
  96.  
  97. test {polygon-5.1} {
  98.     SippSurfaceDelete foo
  99. } 1 {invalid surface handle: foo}
  100.  
  101. test {polygon-5.2} {
  102.     MakePolys polygon-5.2
  103.     set surface1 [SippSurfaceCreate $shader1]
  104.     SippSurfaceDelete $surface1
  105. } 0 {}
  106.  
  107. test {polygon-5.3} {
  108.     SippSurfaceDelete $surface1
  109. } 1 {surface is not open}
  110.  
  111. #
  112. # Test SippSurfaceSetShader command.
  113. #
  114.  
  115. test {polygon-6.1} {
  116.     SippSurfaceSetShader foo baz
  117. } 1 {invalid surface handle: foo}
  118.  
  119. test {polygon-6.2} {
  120.     MakePolys polygon-6.2
  121.     set surface1 [SippSurfaceCreate $shader1]
  122.     SippSurfaceSetShader $surface1 baz
  123. } 1 {invalid shader handle: baz}
  124.  
  125. test {polygon-6.3} {
  126.     SippSurfaceSetShader $surface1 $shader1
  127. } 0 {}
  128.  
  129. #
  130. # Cleanup.
  131. #
  132.  
  133. test {polygon-7.1} {
  134.     SippSurfaceDelete $surface1
  135.     SippShaderDelete $shader1
  136. } 0 {}
  137.  
  138.