Пример #1
0
        public void testECBDates()
        {
            // Testing ECB dates

            List <Date> knownDates = ECB.knownDates();

            if (knownDates.empty())
            {
                QAssert.Fail("Empty EBC date vector");
            }

            int n = ECB.nextDates(Date.minDate()).Count;

            if (n != knownDates.Count)
            {
                QAssert.Fail("NextDates(minDate) returns " + n +
                             " instead of " + knownDates.Count + " dates");
            }

            Date previousEcbDate = Date.minDate(),
                 currentEcbDate, ecbDateMinusOne;

            for (int i = 0; i < knownDates.Count; ++i)
            {
                currentEcbDate = knownDates[i];

                if (!ECB.isECBdate(currentEcbDate))
                {
                    QAssert.Fail(currentEcbDate + " fails isECBdate check");
                }

                ecbDateMinusOne = currentEcbDate - 1;
                if (ECB.isECBdate(ecbDateMinusOne))
                {
                    QAssert.Fail(ecbDateMinusOne + " fails isECBdate check");
                }

                if (ECB.nextDate(ecbDateMinusOne) != currentEcbDate)
                {
                    QAssert.Fail("Next EBC date following " + ecbDateMinusOne +
                                 " must be " + currentEcbDate);
                }

                if (ECB.nextDate(previousEcbDate) != currentEcbDate)
                {
                    QAssert.Fail("Next EBC date following " + previousEcbDate +
                                 " must be " + currentEcbDate);
                }

                previousEcbDate = currentEcbDate;
            }

            Date knownDate = knownDates.First();

            ECB.removeDate(knownDate);
            if (ECB.isECBdate(knownDate))
            {
                QAssert.Fail("Unable to remove an EBC date");
            }

            ECB.addDate(knownDate);
            if (!ECB.isECBdate(knownDate))
            {
                QAssert.Fail("Unable to add an EBC date");
            }
        }