PuzzleSDK
Bug1174Layer类 参考

#include <Bug-1174.h>

+ 类 Bug1174Layer 继承关系图:
+ Bug1174Layer 的协作图:

Public 成员函数

 CREATE_FUNC (Bug1174Layer)
 
virtual bool init () override
 
virtual std::string title () const override
 
- Public 成员函数 继承自 TestCase
 TestCase ()
 
 ~TestCase ()
 
virtual std::string subtitle () const
 
virtual Type getTestType () const
 
virtual float getDuration () const
 
virtual std::string getExpectedOutput () const
 
virtual std::string getActualOutput () const
 
virtual void restartTestCallback (cocos2d::Ref *sender)
 
virtual void nextTestCallback (cocos2d::Ref *sender)
 
virtual void priorTestCallback (cocos2d::Ref *sender)
 
virtual void onBackCallback (cocos2d::Ref *sender)
 
void setTestSuite (TestSuite *testSuite)
 
TestSuitegetTestSuite () const
 
float getRunTime () const
 
void setTestCaseName (const std::string &name)
 
std::string getTestCaseName () const
 
const cocos2d::Label * getSubtitleLable () const
 
const cocos2d::MenuItemImage * getRestartTestItem () const
 
virtual void onEnter () override
 

额外继承的成员函数

- Public 类型 继承自 TestCase
enum class  Type { ROBUSTNESS , UNIT , GRAPHICAL_STATIC , MANUAL }
 
- Public 属性 继承自 TestCase
CC_CONSTRUCTOR_ACCESS __pad0__: virtual bool init() override
 
- Protected 属性 继承自 TestCase
cocos2d::MenuItemImage * _priorTestItem
 
cocos2d::MenuItemImage * _restartTestItem
 
cocos2d::MenuItemImage * _nextTestItem
 
cocos2d::Label * _titleLabel
 
cocos2d::Label * _subtitleLabel
 

详细描述

在文件 Bug-1174.h30 行定义.

成员函数说明

◆ CREATE_FUNC()

Bug1174Layer::CREATE_FUNC ( Bug1174Layer  )

◆ init()

bool Bug1174Layer::init ( )
overridevirtual

在文件 Bug-1174.cpp59 行定义.

60{
61 if (BugsTestBase::init())
62 {
63// // seed
64// std::srand(0);
65
66 Vec2 A,B,C,D,p1,p2,p3,p4;
67 float s,t;
68
69 int err=0;
70 int ok=0;
71
72 //
73 // Test 1.
74 //
75 log("Test1 - Start");
76 for( int i=0; i < 10000; i++)
77 {
78 // A | b
79 // -----
80 // c | d
81 float ax = CCRANDOM_0_1() * -5000;
82 float ay = CCRANDOM_0_1() * 5000;
83
84 // a | b
85 // -----
86 // c | D
87 float dx = CCRANDOM_0_1() * 5000;
88 float dy = CCRANDOM_0_1() * -5000;
89
90 // a | B
91 // -----
92 // c | d
93 float bx = CCRANDOM_0_1() * 5000;
94 float by = CCRANDOM_0_1() * 5000;
95
96 // a | b
97 // -----
98 // C | d
99 float cx = CCRANDOM_0_1() * -5000;
100 float cy = CCRANDOM_0_1() * -5000;
101
102 A = Vec2(ax,ay);
103 B = Vec2(bx,by);
104 C = Vec2(cx,cy);
105 D = Vec2(dx,dy);
106 if( Vec2::isLineIntersect( A, D, B, C, &s, &t) ) {
107 if( check_for_error(A, D, B, C, s, t) )
108 err++;
109 else
110 ok++;
111 }
112 }
113 log("Test1 - End. OK=%i, Err=%i", ok, err);
114
115 //
116 // Test 2.
117 //
118 log("Test2 - Start");
119
120 p1 = Vec2(220,480);
121 p2 = Vec2(304,325);
122 p3 = Vec2(264,416);
123 p4 = Vec2(186,416);
124 s = 0.0f;
125 t = 0.0f;
126 if( Vec2::isLineIntersect(p1, p2, p3, p4, &s, &t) )
127 check_for_error(p1, p2, p3, p4, s,t );
128
129 log("Test2 - End");
130
131
132 //
133 // Test 3
134 //
135 log("Test3 - Start");
136
137 ok=0;
138 err=0;
139 for( int i=0;i<10000;i++)
140 {
141 // A | b
142 // -----
143 // c | d
144 float ax = CCRANDOM_0_1() * -500;
145 float ay = CCRANDOM_0_1() * 500;
146 p1 = Vec2(ax,ay);
147
148 // a | b
149 // -----
150 // c | D
151 float dx = CCRANDOM_0_1() * 500;
152 float dy = CCRANDOM_0_1() * -500;
153 p2 = Vec2(dx,dy);
154
155
157
158 float y = ay - ((ay - dy) /2.0f);
159
160 // a | b
161 // -----
162 // C | d
163 float cx = CCRANDOM_0_1() * -500;
164 p3 = Vec2(cx,y);
165
166 // a | B
167 // -----
168 // c | d
169 float bx = CCRANDOM_0_1() * 500;
170 p4 = Vec2(bx,y);
171
172 s = 0.0f;
173 t = 0.0f;
174 if( Vec2::isLineIntersect(p1, p2, p3, p4, &s, &t) ) {
175 if( check_for_error(p1, p2, p3, p4, s,t ) )
176 err++;
177 else
178 ok++;
179 }
180 }
181
182 log("Test3 - End. OK=%i, err=%i", ok, err);
183 return true;
184 }
185
186 return false;
187}
int check_for_error(Vec2 p1, Vec2 p2, Vec2 p3, Vec2 p4, float s, float t)
Definition: Bug-1174.cpp:36

引用了 check_for_error().

+ 函数调用图:

◆ title()

virtual std::string Bug1174Layer::title ( ) const
inlineoverridevirtual

重载 BugsTestBase .

在文件 Bug-1174.h36 行定义.

36{ return "Bug1174";}

该类的文档由以下文件生成: