DBC_REQUIRE 示例代码

2022-03-03

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

示例1:
test.cpp开发语言: C++项目名称: KeyRemap4MacBook代码行数: 552
20TEST_CASE("sizeof_", "[Generic]") {
21  REQUIRE(sizeof(EventType) == sizeof(unsigned int));
22  REQUIRE(sizeof(KeyboardType) == sizeof(unsigned int));
23  REQUIRE(sizeof(ModifierFlag) == sizeof(unsigned int));
24  REQUIRE(sizeof(Flags) == sizeof(unsigned int));
25  REQUIRE(sizeof(KeyCode) == sizeof(unsigned int));
26  REQUIRE(sizeof(ConsumerKeyCode) == sizeof(unsigned int));
27  REQUIRE(sizeof(PointingButton) == sizeof(unsigned int));
28  REQUIRE(sizeof(Buttons) == sizeof(unsigned int));
29  REQUIRE(sizeof(ScrollWheel) == sizeof(unsigned int));
30  REQUIRE(sizeof(PointingRelative) == sizeof(unsigned int));
示例2:
test.cpp开发语言: C++项目名称: KeyRemap4MacBook代码行数: 695
21  FlagStatus flagStatus;
22  REQUIRE(flagStatus.makeFlags() == Flags());
23
24  flagStatus.set();
25  REQUIRE(flagStatus.makeFlags() == Flags());
26
27  flagStatus.set(KeyCode::A, Flags(0));
28  REQUIRE(flagStatus.makeFlags() == Flags());
29
31  flagStatus.set(KeyCode::SHIFT_L, Flags(ModifierFlag::SHIFT_L));
32  REQUIRE(flagStatus.makeFlags() == Flags(ModifierFlag::SHIFT_L));
33
35  flagStatus.set(KeyCode::A, Flags(ModifierFlag::NONE));
36  REQUIRE(flagStatus.makeFlags() == Flags(ModifierFlag::SHIFT_L));
37
示例3:
test_random_access.cpp开发语言: C++项目名称: skip_list代码行数: 492
15{
16    //REQUIRE(false);
17}
346    list.erase_at(1);
347    REQUIRE(list[0] == 0);    REQUIRE(list[1] == 2);    REQUIRE(list[2] == 3);
348    REQUIRE(list[3] == 4);    REQUIRE(list[4] == 5);    REQUIRE(list[7] == 8);
357    REQUIRE(list[0] == 0);    REQUIRE(list[1] == 1);    REQUIRE(list[2] == 3);
358    REQUIRE(list[3] == 4);    REQUIRE(list[4] == 5);    REQUIRE(list[7] == 8);
359}
367    REQUIRE(list[0] == 0);    REQUIRE(list[1] == 1);    REQUIRE(list[2] == 2);
368    REQUIRE(list[3] == 4);    REQUIRE(list[4] == 5);    REQUIRE(list[7] == 8);
369}
377    REQUIRE(list[0] == 0);    REQUIRE(list[1] == 1);    REQUIRE(list[2] == 2);
378    REQUIRE(list[3] == 3);    REQUIRE(list[4] == 5);    REQUIRE(list[7] == 8);
379}
示例4:
test_multi_skip_list.cpp开发语言: C++项目名称: skip_list代码行数: 430
282
283    REQUIRE(LowerBoundTest(5,  set, 0)); REQUIRE(LowerBoundTest(5,  list, 0));
284    REQUIRE(LowerBoundTest(7,  set, 1)); REQUIRE(LowerBoundTest(7,  list, 1));
409    REQUIRE(EqualRangeTest(11, set)); REQUIRE(EqualRangeTest(11, list));
410    REQUIRE(EqualRangeTest(21, set)); REQUIRE(EqualRangeTest(21, list));
411    
412    REQUIRE(EqualRangeTest(0,  set)); REQUIRE(EqualRangeTest(0,  list));
413    REQUIRE(EqualRangeTest(4,  set)); REQUIRE(EqualRangeTest(4,  list));
414    REQUIRE(EqualRangeTest(6,  set)); REQUIRE(EqualRangeTest(6,  list));
415    REQUIRE(EqualRangeTest(8,  set)); REQUIRE(EqualRangeTest(8,  list));
416    REQUIRE(EqualRangeTest(20, set)); REQUIRE(EqualRangeTest(20, list));
417    REQUIRE(EqualRangeTest(22, set)); REQUIRE(EqualRangeTest(22, list));
418    
示例5:
test_skip_list.cpp开发语言: C++项目名称: skip_list代码行数: 1404
543    std::vector<int>::iterator i = list.begin();
544    REQUIRE(*i++ == 1); REQUIRE(*i++ == 3); REQUIRE(*i++ == 4); REQUIRE(i == list.end());
545    
546    std::vector<int>::reverse_iterator ri = list.rbegin();
547    REQUIRE(*ri++ == 4); REQUIRE(*ri++ == 3); REQUIRE(*ri++ == 1); REQUIRE(ri == list.rend());
548}
557    skip_list<int>::iterator i = list.begin();
558    REQUIRE(*i++ == 1); REQUIRE(*i++ == 3); REQUIRE(*i++ == 4); REQUIRE(i == list.end());
559    
560    skip_list<int>::reverse_iterator ri = list.rbegin();
561    REQUIRE(*ri++ == 4); REQUIRE(*ri++ == 3); REQUIRE(*ri++ == 1); REQUIRE(ri == list.rend());
562}
901    skip_list<int>::iterator i2 = assignee.begin();
902    REQUIRE(*i1 == 12); REQUIRE(*i2 == 12); ++i1; ++i2; REQUIRE(i1 != source.end());
903    REQUIRE(*i1 == 34); REQUIRE(*i2 == 34); ++i1; ++i2; REQUIRE(i1 != source.end());
示例6:
test.cpp开发语言: C++项目名称: KeyRemap4MacBook代码行数: 1603
12  xml_compiler.reload();
13  REQUIRE(xml_compiler.get_error_information().get_count() == 0);
14  REQUIRE(xml_compiler.get_error_information().get_message() == "");
19
20    REQUIRE(xml_compiler.get_symbol_map().get_optional("ConfigIndex::system_vk_modifier_definition") == boost::optional<uint32_t>(v++));
21    REQUIRE(xml_compiler.get_symbol_map().get_optional("ConfigIndex::system_vk_change_inputsource_definition") == boost::optional<uint32_t>(v++));
22    REQUIRE(xml_compiler.get_symbol_map().get_optional("ConfigIndex::system_vk_open_url_definition") == boost::optional<uint32_t>(v++));
23    REQUIRE(xml_compiler.get_symbol_map().get_optional("ConfigIndex::notsave_private_sample") == boost::optional<uint32_t>(v++));
24    REQUIRE(xml_compiler.get_symbol_map().get_optional("ConfigIndex::notsave_passthrough") == boost::optional<uint32_t>(v++));
25    REQUIRE(xml_compiler.get_symbol_map().get_optional("ConfigIndex::notsave_remap_sample") == boost::optional<uint32_t>(v++));
26    REQUIRE(xml_compiler.get_symbol_map().get_optional("ConfigIndex::private_include_test") == boost::optional<uint32_t>(v++));
27    REQUIRE(xml_compiler.get_symbol_map().get_optional("ConfigIndex::private_style_test_important") == boost::optional<uint32_t>(v++));
示例7:
ConditionTests.cpp开发语言: C++项目名称: Catch代码行数: 336
54
55    REQUIRE( data.int_seven == 7 );
56    REQUIRE( data.float_nine_point_one == Approx( 9.1f ) );
57    REQUIRE( data.double_pi == Approx( 3.1415926535 ) );
58    REQUIRE( data.str_hello == "hello" );
59    REQUIRE( "hello" == data.str_hello );
60    REQUIRE( data.str_hello.size() == 5 );
62    double x = 1.1 + 0.1 + 0.1;
63    REQUIRE( x == Approx( 1.3 ) );
64}
90
91    REQUIRE( data.int_seven != 6 );
92    REQUIRE( data.int_seven != 8 );
示例8:
MiscTests.cpp开发语言: C++项目名称: Catch代码行数: 486
26    {
27        REQUIRE( a != b );
28        REQUIRE( b != a );
32    {
33        REQUIRE( a != b);
34    }
43    {
44        REQUIRE( a != b );
45        REQUIRE( b != a );
48        {
49            REQUIRE( a != b);
50        }
62        {
63            REQUIRE( a == b );
64        }
示例9:
test.cpp开发语言: C++项目名称: KeyRemap4MacBook代码行数: 171
42TEST_CASE("push_back", "[Vector]") {
43  REQUIRE(TestItem::counter == 0);
44
47
48  REQUIRE(v.empty() == true);
49  REQUIRE(v.capacity() == static_cast<size_t>(0));
52    // push twice
53    REQUIRE(v.size() == i * 2);
54    REQUIRE(v.capacity() == i * 2);
55    v.push_back(TestItem(i)).push_back(TestItem(i));
56    REQUIRE(v.size() == i * 2 + 2);
57    REQUIRE(v.capacity() == i * 2 + 2);
60  for (size_t i = 0; i < MAXITEM; ++i) {
61    REQUIRE(v[i * 2 + 0].v() == i);
62    REQUIRE(v[i * 2 + 1].v() == i);
示例10:
test.cpp开发语言: C++项目名称: KeyRemap4MacBook代码行数: 257
31  list.push_back(nullptr);
32  REQUIRE(list.size() == static_cast<size_t>(0));
33
34  // ------------------------------------------------------------
35  REQUIRE(list.size() == static_cast<size_t>(0));
36  for (int i = 0; i < MAXITEM; ++i) {
37    list.push_back(new TestItem(i));
38    REQUIRE(list.size() == static_cast<size_t>(i + 1));
39  }
42    p = dynamic_cast<TestItem*>(list.safe_front());
43    REQUIRE(p != nullptr);
44    REQUIRE(p->v() == i);
46    list.pop_front();
47    REQUIRE(list.size() == static_cast<size_t>(MAXITEM - (i + 1)));
48  }

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