blob: 1e41664ff7174fdc6a93db9f9c3c5fc06deaa27a [file] [log] [blame]
package groovy;
class SqlDateTest extends GroovyTestCase {
void testIncrement() {
def rightNowMillis = System.currentTimeMillis()
def sqlDate = new java.sql.Date(rightNowMillis)
sqlDate++
assertTrue "incrementing a java.sql.Date returned an incorrect type: ${sqlDate.class}", sqlDate instanceof java.sql.Date
def diff = sqlDate.getTime() - rightNowMillis
assertEquals "incrementing a java.sql.Date did not work properly", 1000 * 60 * 60 * 24, diff
}
void testDecrement() {
def rightNowMillis = System.currentTimeMillis()
def sqlDate = new java.sql.Date(rightNowMillis)
sqlDate--
assertTrue "decrementing a java.sql.Date returned an incorrect type: ${sqlDate.class}", sqlDate instanceof java.sql.Date
def diff = rightNowMillis - sqlDate.getTime()
assertEquals "decrementing a java.sql.Date did not work properly", 1000 * 60 * 60 * 24, diff
}
void testPlusOperator() {
def rightNowMillis = System.currentTimeMillis()
def sqlDate = new java.sql.Date(rightNowMillis)
sqlDate += 1
assertTrue "the plus operator applied to a java.sql.Date returned an incorrect type: ${sqlDate.class}", sqlDate instanceof java.sql.Date
def diff = sqlDate.getTime() - rightNowMillis
assertEquals "decrementing a java.sql.Date did not work properly", 1000 * 60 * 60 * 24, diff
}
void testMinusOperator() {
def rightNowMillis = System.currentTimeMillis()
def sqlDate = new java.sql.Date(rightNowMillis)
sqlDate -= 1
assertTrue "the minus operator applied to a java.sql.Date returned an incorrect type: ${sqlDate.class}", sqlDate instanceof java.sql.Date
def diff = rightNowMillis - sqlDate.getTime()
assertEquals "decrementing a java.sql.Date did not work properly", 1000 * 60 * 60 * 24, diff
}
}