> 85 public static Test suite() {
> 86 return new TestSuite(SerialDateTests.class);
> 87 }
> 88
> 89 /**
> 90 * Подготовка задачи.
> 91 */
> 92 protected void setUp() {
> 93 this.nov9Y2001 = SerialDate.createInstance(9, MonthConstants.NOVEMBER, 2001);
> 94 }
> 95
> 96 /**
> 97 * 9 ноября 2001 + 2 месяца = должно быть 9 января 2002.
> 98 */
> 99 public void testAddMonthsTo9Nov2001() {
>100 final SerialDate jan9Y2002 = SerialDate.addMonths(2, this.nov9Y2001);
>101 final SerialDate answer = SerialDate.createInstance(9, 1, 2002);
>102 assertEquals(answer, jan9Y2002);
>103 }
>104
>105 /**
>106 * Тестовый сценарий для известной ошибки (исправлено).
>107 */
>108 public void testAddMonthsTo5Oct2003() {
>109 final SerialDate d1 = SerialDate.createInstance(5, MonthConstants.OCTOBER,
> 2003);
>110 final SerialDate d2 = SerialDate.addMonths(2, d1);
>111 assertEquals(d2, SerialDate.createInstance(5, MonthConstants.DECEMBER,
> 2003));
>112 }
>113
>114 /**
>115 * Тестовый сценарий для известной ошибки (исправлено).
>116 */
>117 public void testAddMonthsTo1Jan2003() {
>118 final SerialDate d1 = SerialDate.createInstance(1, MonthConstants.JANUARY,
> 2003);
>119 final SerialDate d2 = SerialDate.addMonths(0, d1);
>120 assertEquals(d2, d1);
>121 }
>122
>123 /**
>124 * Понедельник, предшествующий 9 ноября 2001, - должно быть 5 ноября.
>125 */
>126 public void testMondayPrecedingFriday9Nov2001() {
>127 SerialDate mondayBefore = SerialDate.getPreviousDayOfWeek(
>128 SerialDate.MONDAY, this.nov9Y2001
>129 );
>130 assertEquals(5, mondayBefore.getDayOfMonth());
>131 }
>132
>133 /**
>134 * Понедельник, следующий за 9 ноября 2001, - должно быть 12 ноября.
>135 */
>136 public void testMondayFollowingFriday9Nov2001() {
>137 SerialDate mondayAfter = SerialDate.getFollowingDayOfWeek(
>138 SerialDate.MONDAY, this.nov9Y2001
>139 );
>140 assertEquals(12, mondayAfter.getDayOfMonth());
>141 }
>142
>143 /**
>144 * Понедельник, ближайший к 9 ноября 2001, - должно быть 12 ноября.
>145 */
>146 public void testMondayNearestFriday9Nov2001() {
>147 SerialDate mondayNearest = SerialDate.getNearestDayOfWeek(
>148 SerialDate.MONDAY, this.nov9Y2001
>149 );
>150 assertEquals(12, mondayNearest.getDayOfMonth());
Листинг Б.2 (продолжение)x
>151 }