// 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)");
}
예제 #2
0
	void HeaderMapping::Apply( IVisitable* visited )
	{
		m_document = static_cast<WordDocument*>( visited );

		//start the document
        m_pXmlWriter->WriteNodeBegin( L"?xml version=\"1.0\" encoding=\"UTF-8\"?");
        m_pXmlWriter->WriteNodeBegin( L"w:hdr", TRUE );

		//write namespaces
        m_pXmlWriter->WriteAttribute( L"xmlns:w", OpenXmlNamespaces::WordprocessingML );
        m_pXmlWriter->WriteAttribute( L"xmlns:v", OpenXmlNamespaces::VectorML );
        m_pXmlWriter->WriteAttribute( L"xmlns:o", OpenXmlNamespaces::Office );
        m_pXmlWriter->WriteAttribute( L"xmlns:w10", OpenXmlNamespaces::OfficeWord );
        m_pXmlWriter->WriteAttribute( L"xmlns:r", OpenXmlNamespaces::Relationships );
        m_pXmlWriter->WriteNodeEnd( L"", TRUE, FALSE );

		//convert the header text
		_lastValidPapx	=	(*(m_document->AllPapxFkps->begin()))->grppapx[0];
		int cp			=	_hdr.GetCharacterPosition();
		int cpMax		=	_hdr.GetCharacterPosition() + this->_hdr.GetCharacterCount();

		//the CharacterCount of the headers also counts the guard paragraph mark.
		//this additional paragraph mark shall not be converted.
		cpMax--;

		while ( cp < cpMax  && cp < (int)m_document->Text->size())
		{
			int fc = m_document->FindFileCharPos(cp);
			if (fc < 0) break;

			ParagraphPropertyExceptions* papx = findValidPapx( fc );
			TableInfo tai( papx, m_document->nWordVersion );

			if ( tai.fInTable )
			{
				//this PAPX is for a table
				//cp = writeTable( cp, tai.iTap );
				Table table( this, cp, ( ( tai.iTap > 0 ) ? ( 1 ) : ( 0 ) ) );
				table.Convert( this );
				cp = table.GetCPEnd();
			}
			else
			{
				//this PAPX is for a normal paragraph
				cp = writeParagraph( cp, 0x7fffffff );
			}
		}

        m_pXmlWriter->WriteNodeEnd( L"w:hdr");

		m_context->_docx->HeaderXMLList.push_back( std::wstring( m_pXmlWriter->GetXmlString() ) );
	}
예제 #3
0
// 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)");

}
// test_class_KSArray_copy_assn
// Test suite for class KSArray, copy assignment
// 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_copy_assn(Tester & t)
{
    std::cout << "Test Suite: class KSArray - copy assignment" << std::endl;

    bool correctType;  // result of type checking

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

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

    // Make const version, no copy
    const KSArray<int> & taiRef = tai;
    // Make copy (copy ctor)
    KSArray<int> taiCopy(1);
    taiCopy = taiRef;

    // Do copy assignment & check return type
    correctType = TypeCheck<KSArray<int> >::check(taiCopy = taiRef);
    t.test(correctType, "Copy assn - return type");

    t.test(taiCopy.size() == theSize, "Copy assn - check size, copy");

    noErrors = true;
    for (i = 0; i < theSize; ++i)
    {
        if (taiCopy[i] != 15 - i * i)
            noErrors = false;
    }
    t.test(noErrors, "Copy assn - check values, copy");

    // Change original
    tai[2] = 1000;

    // Check original
    noErrors = true;
    for (i = 0; i < theSize; ++i)
    {
        if (tai[i] != ((i == 2) ? 1000 : 15 - i * i))
            noErrors = false;
    }
    t.test(noErrors, "Copy assn - change original, check values, original");

    // Check copy
    noErrors = true;
    for (i = 0; i < theSize; ++i)
    {
        if (taiCopy[i] != 15 - i * i)
            noErrors = false;
    }
    t.test(noErrors, "Copy assn - change original, check values, copy");

    // Change copy
    taiCopy[3] = 2000;

    // Check original
    noErrors = true;
    for (i = 0; i < theSize; ++i)
    {
        if (tai[i] != ((i == 2) ? 1000 : 15 - i * i))
            noErrors = false;
    }
    t.test(noErrors, "Copy assn - change copy, check values, original");

    // Check copy
    noErrors = true;
    for (i = 0; i < theSize; ++i)
    {
        if (taiCopy[i] != ((i == 3) ? 2000 : 15 - i * i))
            noErrors = false;
    }
    t.test(noErrors, "Copy assn - change copy, check values, copy");

    // Check self-assignment
    taiCopy = taiCopy;

    noErrors = true;
    for (i = 0; i < theSize; ++i)
    {
        if (taiCopy[i] != ((i == 3) ? 2000 : 15 - i * i))
            noErrors = false;
    }
    t.test(noErrors, "Copy assn - values after self-assignment");
}
// test_class_KSArray_copy_ctor
// Test suite for class KSArray, copy ctor
// 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_copy_ctor(Tester & t)
{
    std::cout << "Test Suite: class KSArray - copy ctor" << std::endl;

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

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

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

    t.test(taiCopy.size() == theSize, "Copy ctor - check size, copy");

    noErrors = true;
    for (i = 0; i < theSize; ++i)
    {
        if (taiCopy[i] != 15 - i * i)
            noErrors = false;
    }
    t.test(noErrors, "Copy ctor - check values, copy");

    // Change original
    tai[2] = 1000;

    // Check original
    noErrors = true;
    for (i = 0; i < theSize; ++i)
    {
        if (tai[i] != ((i == 2) ? 1000 : 15 - i * i))
            noErrors = false;
    }
    t.test(noErrors, "Copy ctor - change original, check values, original");

    // Check copy
    noErrors = true;
    for (i = 0; i < theSize; ++i)
    {
        if (taiCopy[i] != 15 - i * i)
            noErrors = false;
    }
    t.test(noErrors, "Copy ctor - change original, check values, copy");

    // Change copy
    taiCopy[3] = 2000;

    // Check original
    noErrors = true;
    for (i = 0; i < theSize; ++i)
    {
        if (tai[i] != ((i == 2) ? 1000 : 15 - i * i))
            noErrors = false;
    }
    t.test(noErrors, "Copy ctor - change copy, check values, original");

    // Check copy
    noErrors = true;
    for (i = 0; i < theSize; ++i)
    {
        if (taiCopy[i] != ((i == 3) ? 2000 : 15 - i * i))
            noErrors = false;
    }
    t.test(noErrors, "Copy ctor - change copy, check values, copy");
}