/*
    1600 - 2399 年の春分を正しく計算できるかテスト
    正確な日付は以下のアドレスから得た
    https://ja.wikipedia.org/wiki/%E6%98%A5%E5%88%86
*/

var data = [
// from   to    +0      +1      +2      +3    (at the boundary)
[1600,	1631,	20,	20,	21,	21],
[1632,	1663,	20,	20,	20,	21],
[1664,	1699,	20,	20,	20,	20,	1696,	19],
[1700,	1731,	20,	21,	21,	21,	1729,	20],
[1732,	1763,	20,	20,	21,	21],
[1764,	1795,	20,	20,	20,	21,	1795,	20],
[1796,	1799,	20,	20,	20,	20],
[1800,	1827,	21,	21,	21,	21],
[1828,	1859,	20,	21,	21,	21,	1828,	20],
[1860,	1891,	20,	20,	21,	21],
[1892,	1899,	20,	20,	20,	21,	1894,	20],
[1900,	1923,	21,	21,	21,	22],
[1924,	1959,	21,	21,	21,	21,	1927,	21],
[1960,	1991,	20,	21,	21,	21],
[1992,	2023,	20,	20,	21,	21],
[2024,	2055,	20,	20,	20,	21],
[2056,	2091,	20,	20,	20,	20],
[2092,	2099,	19,	20,	20,	20],
[2100,	2123,	20,	21,	21,	21],
[2124,	2155,	20,	20,	21,	21],
[2156,	2187,	20,	20,	20,	21,	2187,	20],
[2188,	2199,	20,	20,	20,	20],
[2200,	2223,	21,	21,	21,	21,	2220,	20],
[2224,	2255,	20,	21,	21,	21,	2253,	20],
[2256,	2287,	20,	20,	21,	21,	2286,	20],
[2288,	2299,	20,	20,	20,	21],
[2300,	2319,	21,	21,	21,	22,	2319,	21],
[2320,	2351,	21,	21,	21,	21],
[2352,	2383,	20,	21,	21,	21,	2352,	20],
[2384,	2399,	20,	20,	21,	21]
];

const assert = require('assert');
const Holidays = require('../lib/uchina-holidays.js');

const shunbun = Holidays.__forTest.shunbunWithTime;

data.forEach(function(entry){
  //           from           to
  for (var y = entry[0]; y <= entry[1]; y += 4){
    for (var i = 0; i < 4; i++){
      var s = shunbun(y+i);

      if (Holidays.getJDate(s) !== entry[2+i])
        console.log(y+i, entry[2+i], Holidays.getJDate(s), 
                    Holidays.getJHours(s), Holidays.getJMinutes(s));

      assert( Holidays.getJDate(s) === entry[2+i],
        "Shunbun on " + (y+i) + " should be " + entry[2+i] + 
                                " but was " + Holidays.getJDate(s));
    }
  }
});
