00001
00007 #include "ctl/ctldef.h"
00008 #ifndef CTL_UNIT
00009
00010
00011
00012 #else
00013
00014 #include "unit/unit.h"
00015
00016 #define PIXEL uint8
00017 #include "opc/opc.h"
00018 #include "opc/opctool.h"
00019 #include "opc/opc.temp.h"
00020 #include "opc/opctool.temp.h"
00021 #include "opc/iterator.h"
00022 #include "opc/bmp.h"
00023
00024
00025
00029 void Test_OPC(void)
00030 {
00031 PIXEL buff[32][32];
00032 OPC opc;
00033 size_t size = OPC_Needs(32,32);
00034 Rect tmp = {0,0,32,32};
00035 Test_Error( sizeof(buff) == size );
00036
00037 OPC_Init( &opc, 0,0, &tmp, buff );
00038
00039
00040 memset(buff,0x20,sizeof(buff));
00041 OPC_VLine( &opc, 31, 0, 32, '\0' );
00042
00043 OPC_HLine( &opc, 0, 15, 31, '+' );
00044 OPC_HLine( &opc, -3, 16, 36, '-' );
00045 OPC_VLine( &opc, 15, 0, 32, '+' );
00046 OPC_VLine( &opc, 16, -3, 36, '|' );
00047 OPC_VLine( &opc, 31, 0, 32, '\0' );
00048
00049 {
00050 OPC opcshape;
00051 Rect tmp = {0,0,31,31};
00052 size_t size;
00053 OPC_Clip( &opcshape, &opc, &tmp );
00054 size = OPC_Shape_Calc( &opcshape, 0x20, false );
00055 {
00056
00057 void* pBuff = malloc(size);
00058 OPCShape* shape = OPC_Shape_Create( &opcshape, 0x20, pBuff, false );
00059
00060
00061 Test_Error( size >= OPC_Shape_TotalSize( shape ) );
00062
00063
00064 memset(buff,'.',sizeof(buff));
00065 OPC_VLine( &opc, 31, 0, 32, '\0' );
00066
00067
00068 OPC_Shape( &opc, shape, 0,0 );
00069 OPC_Shape_Mask( &opc, shape, 0,0, '*' );
00070
00071
00072 memset(buff,'.',sizeof(buff));
00073 OPC_VLine( &opc, 31, 0, 32, '\0' );
00074
00075
00076 OPC_Shape( &opc, shape, -10,-10 );
00077 OPC_Shape_Mask( &opc, shape, -10,-10, '*' );
00078
00079
00080 memset(buff,'.',sizeof(buff));
00081 OPC_VLine( &opc, 31, 0, 32, '\0' );
00082
00083
00084 OPC_Shape( &opc, shape, 10,10 );
00085 OPC_VLine( &opc, 31, 0, 32, '\0' );
00086 OPC_Shape_Mask( &opc, shape, 10,10, '*' );
00087 OPC_VLine( &opc, 31, 0, 32, '\0' );
00088 }
00089 }
00090 {
00091 IncLine(test);
00092 IncLine_Init_Step(test, 0,0, 15,15 );
00093 while( IncLine_Remains(test) )
00094 {
00095 int x, y;
00096 IncLine_XY(test,x,y)
00097 Test_Error( x == y );
00098 IncLine_Step(test);
00099 }
00100 }
00101 {
00102 IncLine(test);
00103 IncLine_Init_Step(test, 0,0, 15,15 );
00104 {
00105 IncLine_foreach(test, x, y )
00106 Test_Error( x == y );
00107 }
00108 }
00109 {
00110 IncLine(test);
00111 IncLine_Init_Span(test, 0,0, 15,31 );
00112 Test_Error( IncLine_Spans_Y(test) );
00113 while( IncLine_Remains(test) )
00114 {
00115 int x, y;
00116 IncLine_XY(test,x,y)
00117 Test_Error( x*2 == y );
00118 IncLine_Step(test);
00119 }
00120 }
00121 {
00122 IncLine(test);
00123 IncLine_Init_Span(test, 0,0, 15,31 );
00124 Test_Error( IncLine_Spans_Y(test) );
00125 {
00126 IncLine_foreach_spans(test, xs, ys, xe, ye )
00127 {
00128 Test_Error( xs*2 == ys );
00129 Test_Error( xe*2 == ye );
00130 }
00131 }
00132 }
00133 }
00134
00135 #endif