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


C++ Tester::test方法代码示例

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


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

示例1: test_class_SSArray_ctor_dctor_count

// test_class_SSArray_ctor_dctor_count
// Test suite for class template SSArray, number of class to item type
//  ctor, dctor.
// Pre: None.
// Post:
//     Pass/fail status of tests have been registered with t.
//     Appropriate messages have been printed to cout.
// Does not throw (No-Throw Guarantee)
void test_class_SSArray_ctor_dctor_count(Tester & t)
{
    std::cout << "Test Suite: class template SSArray - ctor, dctor count"
              << std::endl;

    // Check number of value type ctor/dctor calls
    //  on array creation & destruction
    Counter::reset();
    { // Block, so we get dctor calls before function ends
        const SSArray<Counter> tacc(10);

        t.test(Counter::getCtorCount() == 10,
          "Counting default ctor calls due to array creation");

        Counter::reset();
    }
    t.test(Counter::getDctorCount() == 10,
      "Counting dctor calls due to destruction");

/*
    // Check correct number of value type ctor & dctor calls
    //  on self-assignment
    SSArray<Counter> tacc2(10);
    Counter::reset();
    tacc2 = tacc2;
    int i1 = Counter::getCtorCount() + Counter::getDctorCount();
    t.test(i1 == 0 || i1 == 20, "Self-assignment ctor/dctor calls");
*/
}
开发者ID:jasonwarta,项目名称:CS311_Assignments,代码行数:37,代码来源:ssarray_test.cpp

示例2: test_class_KSArray_types

// test_class_KSArray_types
// Test suite for class KSArray, types
// Pre: None.
// Post:
//     Pass/fail status of tests have been registered with t.
//     Appropriate messages have been printed to cout.
// Does not throw (No-Throw Guarantee)
void test_class_KSArray_types(Tester & t)
{
    std::cout << "Test Suite: class KSArray - types" << std::endl;

    bool correctType;  // result of type checking

    // value_type test #1: int
    KSArray<int>::value_type i1 = 0;
    correctType = TypeCheck<int>::check(i1);
    t.test(correctType, "value_type test #1");

    // value_type test #2: double
    KSArray<double>::value_type d1 = 0.;
    correctType = TypeCheck<double>::check(d1);
    t.test(correctType, "value_type test #2");

    // value_type check modifiability (only needs to compile)
    KSArray<double>::value_type d2;
    d2 = 0.;
    t.test(true, "value_type check modifiability");

    // size_type test
    KSArray<Counter>::size_type s1 = 0;
    correctType = TypeCheck<std::size_t>::check(s1)
                  || TypeCheck<std::ptrdiff_t>::check(s1);
    t.test(correctType, "size_type test");

    // size_type check modifiability (only needs to compile)
    KSArray<Counter>::size_type s2;
    s2 = 0;
    t.test(true, "size_type check modifiability");
}
开发者ID:stachick,项目名称:CS-311-DataStructuresAndAlgorithms,代码行数:39,代码来源:ksarray_test.cpp

示例3: test_class_SSArray_bracket_op

// test_class_SSArray_bracket_op
// Test suite for class Product, bracket operator
// Pre: None.
// Post:
//     Pass/fail status of tests have been registered with t.
//     Appropriate have been messages printed to cout.
void test_class_SSArray_bracket_op(Tester & t)
{
    std::cout << "Test Suite: class Product, bracket operator" << std::endl;

    const int theSize = 10;
    bool noErrors;  // True if no errors encountered
    int i;          // Counter

    SSArray<int> ssai(theSize);
    for (i = 0; i < theSize; ++i)
        ssai[i] = 15 - i * i;

    noErrors = true;
    for (i = 0; i < theSize; ++i)
    {
        if (ssai[i] != 15 - i * i)
            noErrors = false;
    }
    t.test(noErrors, "Bracket operator (non-const)");

    // Make const version, no copy
    const SSArray<int> & ssaiRef = ssai;

    noErrors = true;
    for (i = 0; i < theSize; ++i)
    {
        if (ssaiRef[i] != 15 - i * i)
            noErrors = false;
    }
    t.test(noErrors, "Bracket operator (const)");
}
开发者ID:amiel,项目名称:random-useless-scripts,代码行数:37,代码来源:ssarray-test.cpp

示例4: test_class_SSArray_ctor_from_size_and_val

// test_class_SSArray_ctor_from_size_and_val
// Test suite for class template SSArray, ctor from size & value
// Pre: None.
// Post:
//     Pass/fail status of tests have been registered with t.
//     Appropriate have been messages printed to cout.
// Does not throw (No-Throw Guarantee)
void test_class_SSArray_ctor_from_size_and_val(Tester & t)
{
    std::cout << "Test Suite: class template SSArray - "
              << "ctor from size & value"
              << std::endl;

    const int theSize = 1000;
    bool noErrors;  // True if no errors encountered
    const double val = -3.2;

    SSArray<double> tad(theSize, val);

    // check size
    t.test(tad.size() == theSize, "Ctor from size & value - check size");

    // check values
    typedef SSArray<double>::size_type ST;
    noErrors = true;
    for (auto i = static_cast<ST>(0);
         i < tad.size();
         ++i)
    {
        if (tad[i] != val)
            noErrors = false;
    }
    t.test(noErrors, "Ctor from size & value - check values");
}
开发者ID:jasonwarta,项目名称:CS311_Assignments,代码行数:34,代码来源:ssarray_test.cpp

示例5: test_class_SSArray_copy_assn

// test_class_SSArray_copy_assn
// Test suite for class SSArray, copy assignment
// Pre: None.
// Post:
//     Pass/fail status of tests have been registered with t.
//     Appropriate have been messages printed to cout.
void test_class_SSArray_copy_assn(Tester & t)
{
    std::cout << "Test Suite: class SSArray - copy assignment" << std::endl;

    const int theSize = 10;
    bool noErrors;  // True if no errors encountered
    int i;          // Counter

    SSArray<int> ssai(theSize);
    for (i = 0; i < theSize; ++i)
        ssai[i] = 15 - i * i;

    // Make const version, no copy
    const SSArray<int> & ssaiRef = ssai;
    // Make copy (copy assignment)
    SSArray<int> ssaiCopy(1);
    ssaiCopy = ssaiRef;

    t.test(ssaiCopy.size() == theSize, "Copy assignment - check size");

    noErrors = true;
    for (i = 0; i < theSize; ++i)
    {
        if (ssaiCopy[i] != 15 - i * i)
            noErrors = false;
    }
    t.test(noErrors, "Copy assignment - check values");
}
开发者ID:amiel,项目名称:random-useless-scripts,代码行数:34,代码来源:ssarray-test.cpp

示例6: test_class_SSArray_equality_comparisons

// test_class_SSArray_equality_comparisons
// Test suite for class template SSArray, comparisons ==, !=
// Pre: None.
// Post:
//     Pass/fail status of tests have been registered with t.
//     Appropriate messages have been printed to cout.
// Does not throw (No-Throw Guarantee)
void test_class_SSArray_equality_comparisons(Tester & t)
{
    std::cout << "Test Suite: class template SSArray - "
              << "equality comparisons"
              << std::endl;

    bool correctType;  // result of type checking

    const int theSize = 10;
    int i;          // Counter

    SSArray<int> tai1(theSize);
    for (i = 0; i < theSize; ++i)
        tai1[i] = 15 - i * i;
    const SSArray<int> & tai1Ref = tai1;
    SSArray<int> tai1Copy(tai1Ref);
    SSArray<int> tai2(theSize-1);
    for (i = 0; i < theSize-1; ++i)
        tai2[i] = 15 - i * i;
    const SSArray<int> & tai2Ref = tai2;
    
    // operator== return type
    correctType = TypeCheck<bool>::check(tai1 == tai1Copy);
    t.test(correctType, "operator==, return type");

    // operator!= return type
    correctType = TypeCheck<bool>::check(tai1 != tai1Copy);
    t.test(correctType, "operator!=, return type");

    // Check equality of copies
    t.test(tai1 == tai1Copy, "Equality of copies");

    // Check inequality of copies
    t.test(!(tai1 != tai1Copy), "Inequality of copies");

    // Check equality of different sizes #1
    //  (compilation checks constness of op==)
    t.test(!(tai1Ref == tai2Ref), "Equality of different sizes #1");

    // Check inequality of different sizes #1
    //  (compilation checks constness of op!=)
    t.test(tai1Ref != tai2Ref, "Inequality of different sizes #1");

    // Check equality of different sizes #2
    t.test(!(tai2Ref == tai1Ref), "Equality of different sizes #2");

    // Check inequality of different sizes #2
    t.test(tai2Ref != tai1Ref, "Inequality of different sizes #2");

    // Modify copy
    ++tai1Copy[theSize-1];

    // Check equality of modification of copy
    t.test(!(tai1 == tai1Copy), "Equality of modification of copy");

    // Check inequality of modification of copy
    t.test(tai1 != tai1Copy, "Inequality of modification of copy");
}
开发者ID:jasonwarta,项目名称:CS311_Assignments,代码行数:65,代码来源:ssarray_test.cpp

示例7: test_class_SSArray_bracket_op

// test_class_SSArray_bracket_op
// Test suite for class template SSArray, bracket operator
// Pre: None.
// Post:
//     Pass/fail status of tests have been registered with t.
//     Appropriate messages have been printed to cout.
// Does not throw (No-Throw Guarantee)
void test_class_SSArray_bracket_op(Tester & t)
{
    std::cout << "Test Suite: class template SSArray, bracket operator"
              << std::endl;

    bool correctType;  // result of type checking

    const int theSize = 10;
    bool noErrors;  // True if no errors encountered
    int i;          // Counter

    SSArray<double> tad1;
    correctType = TypeCheck<SSArray<double>::value_type>::check(tad1[1]);
    t.test(correctType, "Bracket operator (non-const), return type");

    SSArray<int> tai(theSize);
    for (i = 0; i < theSize; ++i)
        tai[i] = 15 - i * i;

    noErrors = true;
    for (i = 0; i < theSize; ++i)
    {
        if (tai[i] != 15 - i * i)
            noErrors = false;
    }
    t.test(noErrors, "Bracket operator (non-const) #1");

    tai[2] = 1000;
    noErrors = true;
    for (i = 0; i < theSize; ++i)
    {
        if (tai[i] != ((i == 2) ? 1000 : 15 - i * i))
            noErrors = false;
    }
    t.test(noErrors, "Bracket operator (non-const) #2");

    // Make const version, no copy
    const SSArray<int> & taiRef = tai;

    const SSArray<double> tad2;
    correctType = TypeCheck<SSArray<double>::value_type>::check(tad2[1]);
    t.test(correctType, "Bracket operator (const), return type");

    noErrors = true;
    for (i = 0; i < theSize; ++i)
    {
        if (taiRef[i] != ((i == 2) ? 1000 : 15 - i * i))
            noErrors = false;
    }
    t.test(noErrors, "Bracket operator (const)");

}
开发者ID:jasonwarta,项目名称:CS311_Assignments,代码行数:59,代码来源:ssarray_test.cpp

示例8: test_class_SSArray_size_and_ctor_from_size

// test_class_SSArray_size_and_ctor_from_size
// Test suite for class SSArray, function size and ctor from size
// Pre: None.
// Post:
//     Pass/fail status of tests have been registered with t.
//     Appropriate have been messages printed to cout.
void test_class_SSArray_size_and_ctor_from_size(Tester & t)
{
    std::cout << "Test Suite: class SSArray - function size, ctor from size" << std::endl;

    const SSArray<int> ssai(10);
    t.test(ssai.size() == 10, "size, ctor from size (const) #1");

    const SSArray<double> ssad(100);
    t.test(ssad.size() == 100, "size, ctor from size (const) #2)");

    SSArray<int> ssai2(20);
    t.test(ssai2.size() == 20, "size, ctor from size (non-const)");
}
开发者ID:amiel,项目名称:random-useless-scripts,代码行数:19,代码来源:ssarray-test.cpp

示例9: test_class_KSArray_begin_end

// test_class_KSArray_begin_end
// Test suite for class KSArray, functions begin & end
// Pre: None.
// Post:
//     Pass/fail status of tests have been registered with t.
//     Appropriate messages have been printed to cout.
// Does not throw (No-Throw Guarantee)
void test_class_KSArray_begin_end(Tester & t)
{
    std::cout << "Test Suite: class KSArray - functions begin & end" << std::endl;

    bool correctType;  // result of type checking

    const int theSize = 10;
    bool noErrors;      // True if no errors encountered
    int i;              // Counter
    int * iter;         // iterator
    const int * citer;  // const_iterator

    KSArray<int> tai(theSize);
    for (iter = tai.begin(), i = 0; iter != tai.end(); ++iter, ++i)
        *iter = 15 - i * i;

    // Non-const test
    KSArray<double> tad1;

    correctType = TypeCheck<KSArray<double>::value_type *>::check(tad1.begin());
    t.test(correctType, "begin (non-const), return type");

    correctType = TypeCheck<KSArray<double>::value_type *>::check(tad1.end());
    t.test(correctType, "end (non-const), return type");

    t.test(tai.begin() != tai.end(), "begin/end - inequality (non-const)");
    t.test (tai.end() - tai.begin() == theSize, "begin/end - check difference (non-const)");
    noErrors = true;
    for (iter = tai.begin(), i = 0; iter != tai.end(); ++iter, ++i)
    {
        if (*iter != 15 - i * i)
            noErrors = false;
    }
    t.test(noErrors, "begin/end - check values (non-const)");

    // Make const version, no copy
    const KSArray<int> & taiRef = tai;

    // Const test
    const KSArray<double> tad2;

    correctType = TypeCheck<const KSArray<double>::value_type *>::check(tad2.begin());
    t.test(correctType, "begin (const), return type");

    correctType = TypeCheck<const KSArray<double>::value_type *>::check(tad2.end());
    t.test(correctType, "end (const), return type");

    t.test(taiRef.end() - taiRef.begin() == theSize, "begin/end - check difference (const)");
    noErrors = true;
    for (citer = taiRef.begin(), i = 0; citer != taiRef.end(); ++citer, ++i)
    {
        if (*citer != 15 - i * i)
            noErrors = false;
    }
    t.test(noErrors, "begin/end - check values (const)");
}
开发者ID:stachick,项目名称:CS-311-DataStructuresAndAlgorithms,代码行数:63,代码来源:ksarray_test.cpp

示例10: test_class_KSArray_default_ctor

// test_class_KSArray_default_ctor
// Test suite for class KSArray, default ctor
// Pre: None.
// Post:
//     Pass/fail status of tests have been registered with t.
//     Appropriate have been messages printed to cout.
// Does not throw (No-Throw Guarantee)
void test_class_KSArray_default_ctor(Tester & t)
{
    std::cout << "Test Suite: class KSArray - default ctor" << std::endl;

    const KSArray<int> tai1;
    t.test(tai1.size() == 10, "default ctor, size");
}
开发者ID:stachick,项目名称:CS-311-DataStructuresAndAlgorithms,代码行数:14,代码来源:ksarray_test.cpp

示例11: main

int main( int argc, char **argv )
{
  QApplication app( argc, argv );
  
  Tester t;
  t.test();
  
  return 0;
}
开发者ID:KleineKarsten,项目名称:FoundationsOfQtDev,代码行数:9,代码来源:main.cpp

示例12: gcd_single_test

// gcd_single_test
// Helper function for testing function gcd
// Pre:
//     a, b are nonnegative, not both zero.
//     c is the GCD of a, b.
// Post:
//     gcd(a, b) == c has been tested.
//     Pass/fail status has been registered with t.
//     Appropriate messages have been printed to cout.
// Does not throw (No-Throw Guarantee
void gcd_single_test(Tester & t,
                     int a,
                     int b,
                     int c)
{
    std::ostringstream oss;
    int result = gcd(a, b);
    oss << "gcd(" << a << ", " << b << ") = " << c;
    if (c != result)
        oss << " [actual return value: " << result << "]";
    t.test(result == c, oss.str());
}
开发者ID:jasonwarta,项目名称:CS311_Assignments,代码行数:22,代码来源:da3_test.cpp

示例13: test_class_SSArray_ctor_dctor_count

// test_class_SSArray_ctor_dctor_count
// Test suite for class SSArray, number of class to item type
//  ctor, dctor.
// Pre: None.
// Post:
//     Pass/fail status of tests have been registered with t.
//     Appropriate have been messages printed to cout.
void test_class_SSArray_ctor_dctor_count(Tester & t)
{
    std::cout << "Test Suite: class SSArray - ctor, dctor count" << std::endl;

    // Check number of value type ctor/dctor calls on array creation & destruction
    TestItem::resetCount();
    { // Block, so we get dctor calls before function ends
        const SSArray<TestItem> ssat(10);

        t.test(TestItem::getCount() == 10, "Counting default ctor calls due to array creation");

        TestItem::resetCount();
    }
    t.test(TestItem::getCount() == 10, "Counting dctor calls after due to destruction");

    // Check number of value type ctor/dctor calls on self-assignment
    SSArray<TestItem> ssat2(10);
    TestItem::resetCount();
    ssat2 = ssat2;
    t.test(TestItem::getCount() == 0, "Self-assignment should generate no ctor/dctor calls");
}
开发者ID:amiel,项目名称:random-useless-scripts,代码行数:28,代码来源:ssarray-test.cpp

示例14: test_class_KSArray_size_and_ctor_from_size

// test_class_KSArray_size_and_ctor_from_size
// Test suite for class KSArray, function size and ctor from size
// Pre: None.
// Post:
//     Pass/fail status of tests have been registered with t.
//     Appropriate messages have been printed to cout.
// Does not throw (No-Throw Guarantee)
void test_class_KSArray_size_and_ctor_from_size(Tester & t)
{
    std::cout << "Test Suite: class KSArray - function size, ctor from size"
              << std::endl;

    bool correctType;  // result of type checking

    const KSArray<int> tai1(1);

    correctType = TypeCheck<KSArray<int>::size_type>::check(tai1.size());
    t.test(correctType, "size, return type");

    t.test(tai1.size() == 1, "ctor from size (const) #1, check size");

    const KSArray<int> tai2(10);
    t.test(tai2.size() == 10, "ctor from size (const) #2, check size");

    const KSArray<double> tad(100);
    t.test(tad.size() == 100, "ctor from size (const) #3, check size");

    KSArray<int> tai3(20);
    t.test(tai3.size() == 20, "ctor from size (non-const), check size");

    const KSArray<int> tai4(0);
    t.test(tai4.size() == 0, "ctor from size (size 0), check size");
}
开发者ID:stachick,项目名称:CS-311-DataStructuresAndAlgorithms,代码行数:33,代码来源:ksarray_test.cpp

示例15: test_class_SSArray_comparisons

// test_class_SSArray_comparisons
// Test suite for class SSArray, comparisons
// Pre: None.
// Post:
//     Pass/fail status of tests have been registered with t.
//     Appropriate have been messages printed to cout.
void test_class_SSArray_comparisons(Tester & t)
{
    std::cout << "Test Suite: class SSArray - comparisons" << std::endl;

    const int theSize = 10;
    int i;          // Counter

    SSArray<int> ssai1(theSize);
    for (i = 0; i < theSize; ++i)
        ssai1[i] = 15 - i * i;
    const SSArray<int> & ssai1Ref = ssai1;
    const SSArray<int> ssai2(theSize + 1);
    SSArray<int> ssai1Copy(ssai1Ref);

    // Check equality of copies
    t.test(ssai1 == ssai1Copy, "Equality of copies");

    // Check inequality of copies
    t.test(!(ssai1 != ssai1Copy), "Inequality of copies");

    // Check equality of different sizes (compilation checks constness of op==)
    t.test(!(ssai1Ref == ssai2), "Equality of different sizes");

    // Check inequality of different sizes (compilation checks constness of op!=)
    t.test(ssai1Ref != ssai2, "Inequality of different sizes");

    // Modify copy
    ++ssai1Copy[4];

    // Check equality of modification of copy
    t.test(!(ssai1 == ssai1Copy), "Equality of modification of copy");

    // Check inequality of modification of copy
    t.test(ssai1 != ssai1Copy, "Inequality of modification of copy");
}
开发者ID:amiel,项目名称:random-useless-scripts,代码行数:41,代码来源:ssarray-test.cpp


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