LoginSignup
0
0

More than 3 years have passed since last update.

Java単体テストライブラリ-Artery-現在日判定

Posted at

目次 ⇒ Java単体テストライブラリ-Artery-サンプル

package jp.avaj.lib.test;

import java.util.Calendar;

import jp.avaj.lib.algo.ArDateUtil;

/**
 Java単体テストライブラリ-Artery-現在日判定

 ArDate,Date,Calendar,longが現在日であるかを判定する.

 本サンプルではCalendarの場合を示す.
 */
public class Q05_00 {
  public static void main(String[] args) {
    // テストケースを開始する、結果の集計が不要ならば不必要
    ArTest.startTestCase("Q05_00");

    // 現在日時を取得する
    Calendar cal = ArDateUtil.getCalendar();
    // 現在日であるか判定する
    ArTest.currentDate("現在日時","cal",cal);

    // 二時間進める⇒22時以前であれば現在日
    cal = ArDateUtil.forward(cal,0,2,0,0);
    ArTest.currentDate("現在日時+2時間","cal",cal);

    // 一日進める⇒現在日ではない
    cal = ArDateUtil.forward(cal,1,0,0,0);
    ArTest.currentDate("現在日時+一日+2時間 ⇒ NG","cal",cal);

    // テストケースを終了する、結果の集計が不要ならば不必要
    ArTest.endTestCase();
  }
}

結果は次の通り。

result.txt
**** Q05_00 start ****
OK 現在日時:cal=2019/09/30 07:39:27
OK 現在日時+2時間:cal=2019/09/30 09:39:27
NG 現在日時+一日+2時間 ⇒ NG:cal=2019/10/01 09:39:27
jp.avaj.lib.test.Q05_00.main(Q05_00.java:30)
**** Q05_00 summary ****
test count = 3
success    = 2

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0