DBC_ENSURE 示例代码

2022-03-03

以下示例是关于cpp中包含ENSURE用法的示例代码,想了解ENSURE的具体用法?ENSURE怎么用?ENSURE使用的例子?那么可以参考以下10个相关示例代码来学习它的具体使用方法。

示例1:
llsdmessagebuilder_tut.cpp开发语言: C++项目名称: angstrom2_ansky代码行数: 837
135	  reader.getBOOL("block", "var", outValue);
136	  ensure_equals("Ensure BOOL", inValue, outValue);
137	}
147	  reader.getU8("block", "var", outValue);
148	  ensure_equals("Ensure U8", inValue, outValue);
149	}
159	  reader.getS16("block", "var", outValue);
160	  ensure_equals("Ensure S16", inValue, outValue);
161	}
171	  reader.getU16("block", "var", outValue);
172	  ensure_equals("Ensure U16", inValue, outValue);
173	}
183	  reader.getS32("block", "var", outValue);
184	  ensure_equals("Ensure S32", inValue, outValue);
185	}
示例2:
llviewerassetstats_test.cpp开发语言: C++项目名称: angstrom2_ansky代码行数: 1016
232		// Check that helpers aren't bothered by missing global stats
233		ensure("Global gViewerAssetStatsMain should be NULL", (NULL == gViewerAssetStatsMain));
234
245	{
246		ensure("Global gViewerAssetStatsMain should be NULL", (NULL == gViewerAssetStatsMain));
247
249
250		ensure("Global gViewerAssetStatsMain should still be NULL", (NULL == gViewerAssetStatsMain));
251
255		// get an empty map back from output
256		ensure("Stat-less LLSD initially", is_no_stats_map(sd_full));
257
260		sd_full = it->asLLSD(false);
261		ensure("Correct single-key LLSD map root", is_triple_key_map(sd_full, "duration", "regions", "avatar"));
262		ensure("Correct single-slot LLSD array regions", is_single_slot_array(sd_full["regions"], region1_handle));
示例3:
llsimplestat_test.cpp开发语言: C++项目名称: angstrom2_ansky代码行数: 580
62		LLSimpleStatCounter c1;
63		ensure("Initialized counter is zero", (0 == c1.getCount()));
64
65		ensure("Counter increment return is 1", (1 == ++c1));
66		ensure("Counter increment return is 2", (2 == ++c1));
67
68		ensure("Current counter is 2", (2 == c1.getCount()));
69
70		c1.reset();
71		ensure("Counter is 0 after reset", (0 == c1.getCount()));
72		
73		ensure("Counter increment return is 1", (1 == ++c1));
74	}
示例4:
llsechandler_basic_test.cpp开发语言: C++项目名称: angstrom2_ansky代码行数: 1068
52
53#define ensure_throws(str, exc_type, cert, func, ...) \
54try \
60{ \
61ensure("Exception cert is incorrect for " str, except.getCert() == cert); \
62}
329		
330		ensure_equals("Resultant pem is correct",
331			   mPemTestCert, test_cert->getPem());
335		
336		ensure_equals("Der Format is correct", memcmp(buffer, mDerFormat.c_str(), mDerFormat.length()), 0);
337		
342		std::string llsd_cert_str = llsd_value.str();
343		ensure_equals("Issuer Name/commonName", 
344			   (std::string)llsd_cert["issuer_name"]["commonName"], "Autoridade Certificadora Raiz Brasileira");
示例5:
llmediadataclient_test.cpp开发语言: C++项目名称: angstrom2_ansky代码行数: 969
211
212// This special timer delay should ensure that the timer will fire on the very
213// next pump, no matter what (though this does make an assumption about the
240    
241    void ensure(const std::string &msg, int value, int expected)
242    {
245        m += ", expected: " + STR(expected);
246        ensure(m, value == expected);
247    }
248    
249    void ensure(const std::string &msg, const std::string & value, const std::string & expected)
250    {
253        m += ", expected: " + expected;
254        ensure(m, value == expected);
255    }
示例6:
llagentaccess_test.cpp开发语言: C++项目名称: angstrom2_ansky代码行数: 291
87#ifndef HACKED_GODLIKE_VIEWER
88		ensure("1 prefersPG",     aa.prefersPG());
89		ensure("1 prefersMature", !aa.prefersMature());
90		ensure("1 prefersAdult",  !aa.prefersAdult());
91#endif // HACKED_GODLIKE_VIEWER
94#ifndef HACKED_GODLIKE_VIEWER
95		ensure("2 prefersPG",     !aa.prefersPG());
96		ensure("2 prefersMature", aa.prefersMature());
97		ensure("2 prefersAdult",  !aa.prefersAdult());
98#endif // HACKED_GODLIKE_VIEWER
101#ifndef HACKED_GODLIKE_VIEWER
102		ensure("3 prefersPG",     !aa.prefersPG());
103		ensure("3 prefersMature", aa.prefersMature());
示例7:
v3math_test.cpp开发语言: C++项目名称: angstrom2_ansky代码行数: 585
53		LLVector3 vec3;
54		ensure("1:LLVector3:Fail to initialize ", ((0.f == vec3.mV[VX]) && (0.f == vec3.mV[VY]) && (0.f == vec3.mV[VZ])));
55		F32 x = 2.32f, y = 1.212f, z = -.12f;
56		LLVector3 vec3a(x,y,z);
57		ensure("2:LLVector3:Fail to initialize ", ((2.32f == vec3a.mV[VX]) && (1.212f == vec3a.mV[VY]) && (-.12f == vec3a.mV[VZ])));
58		const F32 vec[3] = {1.2f ,3.2f, -4.2f};
59		LLVector3 vec3b(vec);
60		ensure("3:LLVector3:Fail to initialize ", ((1.2f == vec3b.mV[VX]) && (3.2f == vec3b.mV[VY]) && (-4.2f == vec3b.mV[VZ])));
61	}
69		LLVector3 vec3a(vector3d);
70		ensure("1:LLVector3:Fail to initialize ", vec3 == vec3a);
71		LLVector4 vector4(vec3);
72		LLVector3 vec3b(vector4);
73		ensure("2:LLVector3:Fail to initialize ", vec3 == vec3b);
74	}
示例8:
llquaternion_test.cpp开发语言: C++项目名称: angstrom2_ansky代码行数: 660
52		LLQuaternion llquat;
53		ensure("LLQuaternion::LLQuaternion() failed", 0.f == llquat.mQ[0] &&
54		 									0.f == llquat.mQ[1] &&
69		llmat.initRows(vector1, vector2, vector3, vector4);
70		ensure("explicit LLQuaternion(const LLMatrix4 &mat) failed", 2.0f == llmat.mMatrix[0][0] &&
71										 	1.0f == llmat.mMatrix[0][1] &&
97
98		ensure("LLMatrix3::setRows fn failed.", 3.4028234660000000f == llmat.mMatrix[0][0] &&
99										234.56f == llmat.mMatrix[0][1] &&
121				
122		ensure("LLQuaternion::normQuat() fn failed", 
123							is_approx_equal(0.42426407f, res_quat.mQ[0]) &&
135
136		ensure("LLQuaternion::normQuat() fn. failed.", 
137							is_approx_equal(0.0f, res_quat.mQ[0]) &&
示例9:
ComponentCompiler.cpp开发语言: C++项目名称: jolog代码行数: 1249
27         if (checkTag(i, file_tag, end)) {
28            ensure(agent == 0, i, "only one agent definition is allowed per file");
29            agent = compileFile(i->children.begin(), i->children.end());
30         } else if (checkTag(i, agent_tag, end)) {
31            ensure(agent == 0, i, "only one agent definition is allowed per file");
32            agent = compileAgent(i->children.begin(), i->children.end());
37         } else {
38            ensure(false, i, "unknown '"+iteratorToName(i)+"' token at file scope");
39         }
55   iter_t i = begin;
56   ensure(i != end, i, "premature end of agent definition");
57   while (checkTag(i, prefix_tag, end)) {
71   assertTag(i, file_tag, end); //ugh
72   ensure(getValue(i) == "agent", i, "agent is not a \""+getValue(i)+"\"");
73   string sourceFile = i->value.begin().get_position().file; //we ensure that i exists first, so get_position() should always work
示例10:
llsdmessagebuilder_tut.cpp开发语言: C++项目名称: alpha代码行数: 844
141	  reader.getBOOL("block", "var", outValue);
142	  ensure_equals("Ensure BOOL", inValue, outValue);
143	}
153	  reader.getU8("block", "var", outValue);
154	  ensure_equals("Ensure U8", inValue, outValue);
155	}
165	  reader.getS16("block", "var", outValue);
166	  ensure_equals("Ensure S16", inValue, outValue);
167	}
177	  reader.getU16("block", "var", outValue);
178	  ensure_equals("Ensure U16", inValue, outValue);
179	}
189	  reader.getS32("block", "var", outValue);
190	  ensure_equals("Ensure S32", inValue, outValue);
191	}

本文地址:https://www.itbaoku.cn/snippets/415942.html