tCon *AddContract(tCustomer *p, int pos)
{
	int nContracts;
	tCon *paux;

	paux = p[pos].custContract.pContract;
	nContracts = p[pos].custContract.nCurrentContract;
	paux = (tCon *)realloc(paux, (nContracts + 1)*sizeof(tCon));
	if (paux != NULL)
	{
		ReadContract(&paux[nContracts]);
		p[pos].custContract.nCurrentContract++;
	}
	return paux;
}
Esempio n. 2
0
         <kind> LOAD </kind>\
         <units> 5 </units>\
         <timeFrom> 2013-05-29T09:30:10</timeFrom>\
         <timeUntil> 2013-05-29T10:30:00 </timeUntil>\
       </station>\
       <station>\
         <latitude> 53.12345 </latitude>\
         <longitude> 3.12345 </longitude>\
         <kind> UNLOAD </kind>\
         <units> 5 </units>\
         <timeFrom> 2013-05-30T09:30:10.5 </timeFrom>\
         <timeUntil> 2013-05-30T10:30:00</timeUntil>\
       </station>\
     </contract>";

    std::auto_ptr<CContract> pContract = ReadContract(xml1);
    CHECK_EQUAL(2, pContract->_sequence.size());
    CHECK(!pContract->_sealed);

    CHECK_EQUAL(52123450, pContract->_sequence[0]->_coord._lat);
    CHECK_EQUAL(2123450, pContract->_sequence[0]->_coord._long);
    CHECK_EQUAL(CShipmentStation::KLoad, pContract->_sequence[0]->_kind);
    CHECK_EQUAL(1, pContract->_sequence[0]->_cargo.size());
    CHECK_EQUAL(5, pContract->_sequence[0]->_cargo[0]._units);

    CHECK_EQUAL(53123450, pContract->_sequence[1]->_coord._lat);
    CHECK_EQUAL(3123450, pContract->_sequence[1]->_coord._long);
    CHECK_EQUAL(CShipmentStation::KUnload, pContract->_sequence[1]->_kind);
    CHECK_EQUAL(1, pContract->_sequence[1]->_cargo.size());
    CHECK_EQUAL(5, pContract->_sequence[1]->_cargo[0]._units);