当前位置: 首页>>代码示例>>C++>>正文


C++ Obj::makeValue方法代码示例

本文整理汇总了C++中Obj::makeValue方法的典型用法代码示例。如果您正苦于以下问题:C++ Obj::makeValue方法的具体用法?C++ Obj::makeValue怎么用?C++ Obj::makeValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Obj的用法示例。


在下文中一共展示了Obj::makeValue方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: ASSERT

void MyTestDriver<TYPE>::testCase2()
{
    // --------------------------------------------------------------------
    // DEFAULT CTOR, PRIMARY MANIPULATORS, AND DTOR
    //   Ensure that we can use the default constructor to create an
    //   object (having the default-constructed value), use the primary
    //   manipulators to put that object into any state relevant for
    //   thorough testing, and use the destructor to destroy it safely.
    //
    // Concerns:
    //: 1 An object created using the default constructor (with or without
    //:   a supplied allocator) has the contractually specified value.
    //:
    //: 2 The 'makeValue' method sets the value of a object to any specified
    //:   value.
    //:
    //: 3 The 'makeNull' method set the value of a object to null.
    //:
    //: 4 Objects of different values can coexist.
    //:
    //: 5 The destructor does not modify other objects.
    //
    // Plan:
    //: 1 Default-construct an object and use the (as yet unproven) salient
    //:   attribute accessors to verify that the value of the object is the
    //:   null value.  (C-1)
    //:
    //: 2 Default-construct another object, and use the 'makeValue' method,
    //:   passing in an object created with the 'TemplateTestFacility::create'
    //:   class method template, to set the value of the object to a non-null
    //:   value.  Use the (as yet unproven) salient attribute accessors and the
    //:   'TemplateTestFacility::getIdentifier' class method template to verify
    //:   that the new object the expected value and the object created in P-1
    //:   still has the same value.  (C-2, 4)
    //:
    //: 3 Using the loop-based approach, for each identifier in a range of
    //:   integer identifiers:
    //:
    //:   1 Default-construct a modifiable object, 'mL', and use the (as yet
    //:     unproven) salient attribute accessors to verify the value of the
    //:     default constructed object is the null value.  (C-1)
    //:
    //:   2 Create an object of the parameterized 'TYPE', 'LV', using the
    //:     'TemplateTestFacility::create' class method template, specifying
    //:     the integer loop identifier.
    //:
    //:   3 Use the 'makeValue' method to set the value of 'mL' to 'LV'.  Use
    //:     the (as yet unproven) salient attribute accessors and the
    //:     'TemplateTestFacility::getIdentifier' class method template to verify
    //:     'mL' has the expected value.  (C-2)
    //:
    //:   4 Invoke the 'makeNull' method of 'mL'.  Use the attribute
    //:     accessors to verify the value of the object is now null.  (C-3)
    //:
    //: 4 Create an object in a nested block.  Below the block, verify the
    //:   objects created in P-1 and P-2 still have the same value.  (C-5)
    //
    // Testing:
    //   MyNullableValue();
    //   ~MyNullableValue();
    //   void makeNull();
    //   void MakeValue(const TYPE& value);
    // --------------------------------------------------------------------

    if (verbose) printf("\nDEFAULT CTOR, PRIMARY MANIPULATORS, AND DTOR"
                        "\n============================================\n");


    if (verbose) printf("\nTesting default constructor.\n");

    Obj mW; const Obj& W = mW;
    ASSERT(true == W.isNull());

    Obj mX; const Obj& X = mX;
    const TYPE XV = TemplateTestFacility::create<TYPE>(1);
    mX.makeValue(XV);
    ASSERT(1 == TemplateTestFacility::getIdentifier<TYPE>(X.value()));

    if (verbose) printf("\nTesting primary manipulators.\n");

    for (size_t ti = 0; ti < 10; ++ti) {

        if (veryVerbose) { T_ P(ti) }

        Obj mL; const Obj& L = mL;
        ASSERT(true == L.isNull());

        const TYPE LV = TemplateTestFacility::create<TYPE>(ti);

        mL.makeValue(LV);
        ASSERT(false == L.isNull());
        ASSERT(LV == L.value());

        mL.makeNull();
        ASSERT(true == L.isNull());
    }

    if (verbose) printf("\nTesting destructor.\n");
    {
        Obj Z;
//.........这里部分代码省略.........
开发者ID:RMGiroux,项目名称:bde,代码行数:101,代码来源:bsltf_templatetestfacility.t.cpp


注:本文中的Obj::makeValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。