本文整理汇总了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;
//.........这里部分代码省略.........