DALI_ASSERT_ALWAYS 示例代码

2022-03-03

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

示例1:
compare.cpp开发语言: C++项目名称: external_clang代码行数: 357
91         (C == (unsigned int) b) +
92         (C == (unsigned short) b) + // expected-warning {{comparison of constant 65536 with expression of type 'unsigned short' is always false}}
93         (C == (unsigned char) b) +  // expected-warning {{comparison of constant 65536 with expression of type 'unsigned char' is always false}}
103         (C < (unsigned int) b) +
104         (C < (unsigned short) b) + // expected-warning {{comparison of constant 65536 with expression of type 'unsigned short' is always false}}
105         (C < (unsigned char) b) + // expected-warning {{comparison of constant 65536 with expression of type 'unsigned char' is always false}}
121         ((int) a == C) +
122         ((short) a == C) + // expected-warning {{comparison of constant 65536 with expression of type 'short' is always false}}
123         ((signed char) a == C) + // expected-warning {{comparison of constant 65536 with expression of type 'signed char' is always false}}
133         ((int) a < C) +
134         ((short) a < C) + // expected-warning {{comparison of constant 65536 with expression of type 'short' is always true}}
135         ((signed char) a < C) + // expected-warning {{comparison of constant 65536 with expression of type 'signed char' is always true}}
143         (0x80000 == (unsigned int) b) +
144         (0x80000 == (unsigned short) b) + // expected-warning {{comparison of constant 524288 with expression of type 'unsigned short' is always false}}
145         (0x80000 == (unsigned char) b) + // expected-warning {{comparison of constant 524288 with expression of type 'unsigned char' is always false}}
示例2:
bool-compare.cpp开发语言: C++项目名称: clang代码行数: 208
7
8  if(b > true)    {} // expected-warning {{comparison of true with expression of type 'bool' is always false}}
9  if(b < true)    {} // no warning
10  if(b >= true)   {} // no warning
11  if(b <= true)   {} // expected-warning {{comparison of true with expression of type 'bool' is always true}}
12  if(b == true)   {} // no warning
15  if(b > false)   {} // no warning
16  if(b < false)   {} // expected-warning {{comparison of false with expression of type 'bool' is always false}}
17  if(b >= false)  {} // expected-warning {{comparison of false with expression of type 'bool' is always true}}
21
22  if(b > 1U){} // expected-warning {{comparison of constant 1 with expression of type 'bool' is always false}}
23
31  if (a > 0) {} // no warning
32  if (a > 1) {} // expected-warning {{comparison of constant 1 with expression of type 'bool' is always false}}
33  if (a > 2) {} // expected-warning {{comparison of constant 2 with expression of type 'bool' is always false}}
示例3:
testcondition.cpp开发语言: C++项目名称: cppcheck代码行数: 3802
78        TEST_CASE(incorrectLogicOperator14);
79        TEST_CASE(secondAlwaysTrueFalseWhenFirstTrueError);
80        TEST_CASE(incorrectLogicOp_condSwapping);
110
111        TEST_CASE(alwaysTrue);
112        TEST_CASE(alwaysTrueInfer);
113        TEST_CASE(multiConditionAlwaysTrue);
114        TEST_CASE(duplicateCondition);
116        TEST_CASE(checkInvalidTestForOverflow);
117        TEST_CASE(checkConditionIsAlwaysTrueOrFalseInsideIfWhile);
118        TEST_CASE(alwaysTrueFalseInLogicalOperators);
155              "}");
156        ASSERT_EQUALS("[test.cpp:3] -> [test.cpp:4]: (style) Mismatching assignment and comparison, comparison 'y==3' is always false.\n", errout.str());
157
示例4:
address.cpp开发语言: C++项目名称: ace代码行数: 2715
182  if (!rhs)
183    return true; // always >= 0
184  if (ACE_OS::strcmp( (const char *) lhs, rhs)>= 0)
194  if (!rhs)
195    return false; // always >= 0
196  if (ACE_OS::strcmp( (const char *) lhs, rhs)< 0)
228{
229  // always initialize what type this object is
230  smival.syntax = sNMP_SYNTAX_IPADDR;
248{
249  // always initialize what type this object is
250  smival.syntax = sNMP_SYNTAX_IPADDR;
271{
272  // always initialize what type this object is
273  smival.syntax = sNMP_SYNTAX_IPADDR;
示例5:
ms_file.cpp开发语言: C++项目名称: atem代码行数: 1161
275	//           must be >0 (error #1002)
276	//  #1,  1b, char, always '\0' (~ error #1002)
277	//  #2,  1b, unsigned char, max record number (dat file number)
278	//           must be >0 (error #1003)
279	//  #3,  1b, char, always '\0' (~ error #1003)
280	//  #4, 45b, char*, always '\0' ?
325	//  #0,  1b, unsigned char, dat file number
326	//  #1,  2b, short, file type, always 101 (error #1005)
327	//  #3,  1b, unsigned char, record length
330	//           must be 4, 5, 6, 7 or 8 (error #1007)
331	//  #5,  1b: char, always '\0' (error #1008)
332	//  #6,  1b: char, always '\0' (error #1009)
334	//           only alphanumeric characters (error #1010)
335	// #23,  2b: short, always 0 (error #1011)
336	// #25,  4b: float(ms basic), first date, valid (error #1012)
示例6:
AllTests.cpp开发语言: C++项目名称: zeroc-ice-package代码行数: 703
222        waitForServerState(admin, "server-always", IceGrid::Active);
223        TestIntfPrx obj = TestIntfPrx::checkedCast(communicator->stringToProxy("server-always"));
224        admin->stopServer("server-always");
225        waitForServerState(admin, "server-always", IceGrid::Active);
226        obj->shutdown();
227        waitForServerState(admin, "server-always", IceGrid::Active);
228        nRetry = 4;
426        test(admin->getServerState("server-always") == IceGrid::Inactive);
427        admin->enableServer("server-always", true);
428        waitForServerState(admin, "server-always", IceGrid::Active);
683        }
684        test(admin->isServerEnabled("server2-always") && admin->getServerState("server2-always") == IceGrid::Active);
685        obj->ice_ping();
示例7:
address.cpp开发语言: C++项目名称: core_tbc代码行数: 2717
187  if (!rhs)
188    return true; // always >= 0
189  if (ACE_OS::strcmp( (const char *) lhs, rhs)>= 0)
199  if (!rhs)
200    return false; // always >= 0
201  if (ACE_OS::strcmp( (const char *) lhs, rhs)< 0)
233{
234  // always initialize what type this object is
235  smival.syntax = sNMP_SYNTAX_IPADDR;
253{
254  // always initialize what type this object is
255  smival.syntax = sNMP_SYNTAX_IPADDR;
276{
277  // always initialize what type this object is
278  smival.syntax = sNMP_SYNTAX_IPADDR;
示例8:
StringKeyEx.cpp开发语言: C++项目名称: gaudi代码行数: 180
92  // 1. check the settings of key from the properties
93  always() << "The Key  : " << Gaudi::Utils::toString ( m_key  ) << endmsg ;
94  always() << "The Keys : " << Gaudi::Utils::toString ( m_keys ) << endmsg ;
133
134  always() << "Map 1:" << Gaudi::Utils::toString ( map1  ) << endmsg ;
135  always() << "Map 2:" << Gaudi::Utils::toString ( map2  ) << endmsg ;
136  always() << "Map 3:" << Gaudi::Utils::toString ( map3  ) << endmsg ;
137  always() << "Map 4:" << Gaudi::Utils::toString ( map4  ) << endmsg ;
138  
139  always() << "Map01:" << Gaudi::Utils::toString ( map01 ) << endmsg ;
140  always() << "Map02:" << Gaudi::Utils::toString ( map02 ) << endmsg ;
141  always() << "Map03:" << Gaudi::Utils::toString ( map03 ) << endmsg ;
142  always() << "Map04:" << Gaudi::Utils::toString ( map04 ) << endmsg ;
示例9:
MapAlg.cpp开发语言: C++项目名称: gaudi代码行数: 240
54  {
55    always() 
56      << endmsg 
122  
123  always() 
124    << " Inserting key " << toString(key) << " 1st: " 
130  
131  always() << "1 Map1: " << toString ( m_map1 ) << endmsg ;
132  always() << "1 Map2: " << toString ( m_map2 ) << endmsg ;
133  always() << "1 Map3: " << toString ( m_map3 ) << endmsg ;
134  always() << "1 Map4: " << toString ( m_map4 ) << endmsg ;
137  
138  always() << "2 Map1: " << toString ( m_map1 ) << endmsg ;
139  always() << "2 Map2: " << toString ( m_map2 ) << endmsg ;
示例10:
ms_file.cpp开发语言: C++项目名称: atem代码行数: 1093
248	//           must be >0 (error #1002)
249	//  #1,  1b, char, always '\0' (~ error #1002)
250	//  #2,  1b, unsigned char, max record number (dat file number)
251	//           must be >0 (error #1003)
252	//  #3,  1b, char, always '\0' (~ error #1003)
253	//  #4, 45b, char*, always '\0' ?
298	//  #0,  1b, unsigned char, dat file number
299	//  #1,  2b, short, file type, always 101 (error #1005)
300	//  #3,  1b, unsigned char, record length
303	//           must be 4, 5, 6, 7 or 8 (error #1007)
304	//  #5,  1b: char, always '\0' (error #1008)
305	//  #6,  1b: char, always '\0' (error #1009)
307	//           only alphanumeric characters (error #1010)
308	// #23,  2b: short, always 0 (error #1011)
309	// #25,  4b: float(ms basic), first date, valid (error #1012)

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