~drizzle-trunk/drizzle/jenkins-Drizzle-Builder-187

1491.6.2 by Monty Taylor
Hook in to autoconf and automake.
1
/* -*- mode: c; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
 *
4
 *  Copyright (C) 2010 Pawel Blokus
5
 *
6
 *  This program is free software; you can redistribute it and/or modify
7
 *  it under the terms of the GNU General Public License as published by
8
 *  the Free Software Foundation; either version 2 of the License, or
9
 *  (at your option) any later version.
10
 *
11
 *  This program is distributed in the hope that it will be useful,
12
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 *  GNU General Public License for more details.
15
 *
16
 *  You should have received a copy of the GNU General Public License
17
 *  along with this program; if not, write to the Free Software
18
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
19
 */
20
2173.2.1 by Monty Taylor
Fixes incorrect usage of include
21
#include <config.h>
2097.2.4 by Andrew Hutchings
Convert all unit tests to boost::test
22
#define BOOST_TEST_DYN_LINK
23
#include <boost/test/unit_test.hpp>
1377.8.1 by pawel
primitive integration of the testing framework with the building process
24
25
#include <drizzled/calendar.h>
26
27
using namespace drizzled;
2097.2.3 by Andrew Hutchings
Start of migration to boost::test
28
BOOST_AUTO_TEST_SUITE(CalculationTest)
29
BOOST_AUTO_TEST_CASE(calendar_julian_day_number_from_gregorian_date_test)
1377.8.1 by pawel
primitive integration of the testing framework with the building process
30
{
31
  uint32_t year, month, day;
1377.8.2 by Paweł Blokus
created files for temporal tests
32
1377.8.1 by pawel
primitive integration of the testing framework with the building process
33
  year= 2010; month= 4; day= 2;
2097.2.3 by Andrew Hutchings
Start of migration to boost::test
34
  BOOST_REQUIRE_EQUAL(2455289, julian_day_number_from_gregorian_date(year, month, day));
1377.8.1 by pawel
primitive integration of the testing framework with the building process
35
  
36
  year= 1976; month= 12; day= 21;
2097.2.3 by Andrew Hutchings
Start of migration to boost::test
37
  BOOST_REQUIRE_EQUAL(2443134, julian_day_number_from_gregorian_date(year, month, day));
1377.8.1 by pawel
primitive integration of the testing framework with the building process
38
  
39
  year= 2050; month= 6; day= 15;
2097.2.3 by Andrew Hutchings
Start of migration to boost::test
40
  BOOST_REQUIRE_EQUAL(2469973, julian_day_number_from_gregorian_date(year, month, day));
1377.8.1 by pawel
primitive integration of the testing framework with the building process
41
  
42
  year= 1999; month= 12; day= 31;
2097.2.3 by Andrew Hutchings
Start of migration to boost::test
43
  BOOST_REQUIRE_EQUAL(2451544, julian_day_number_from_gregorian_date(year, month, day));
1377.8.1 by pawel
primitive integration of the testing framework with the building process
44
  
45
  year= 2008; month= 2; day= 29;
2097.2.3 by Andrew Hutchings
Start of migration to boost::test
46
  BOOST_REQUIRE_EQUAL(2454526, julian_day_number_from_gregorian_date(year, month, day));
1377.8.1 by pawel
primitive integration of the testing framework with the building process
47
}
48
2097.2.3 by Andrew Hutchings
Start of migration to boost::test
49
BOOST_AUTO_TEST_CASE(calendar_gregorian_date_from_julian_day_number_test)
1377.8.1 by pawel
primitive integration of the testing framework with the building process
50
{
51
  int64_t julian_day;
52
  uint32_t year_out, month_out, day_out;
53
  
54
  julian_day= 2455289;
55
  gregorian_date_from_julian_day_number(julian_day, &year_out, &month_out, &day_out);
2097.2.3 by Andrew Hutchings
Start of migration to boost::test
56
  BOOST_REQUIRE((year_out == 2010) && (month_out == 4) && (day_out == 2));
1377.8.1 by pawel
primitive integration of the testing framework with the building process
57
  
58
  julian_day= 2443134;
59
  gregorian_date_from_julian_day_number(julian_day, &year_out, &month_out, &day_out);
2097.2.3 by Andrew Hutchings
Start of migration to boost::test
60
  BOOST_REQUIRE((year_out == 1976) && (month_out == 12) && (day_out == 21));
1377.8.1 by pawel
primitive integration of the testing framework with the building process
61
  
62
  julian_day= 2469973;
63
  gregorian_date_from_julian_day_number(julian_day, &year_out, &month_out, &day_out);
2097.2.3 by Andrew Hutchings
Start of migration to boost::test
64
  BOOST_REQUIRE((year_out == 2050) && (month_out == 6) && (day_out == 15));
1377.8.1 by pawel
primitive integration of the testing framework with the building process
65
  
66
  julian_day= 2451544;
67
  gregorian_date_from_julian_day_number(julian_day, &year_out, &month_out, &day_out);
2097.2.3 by Andrew Hutchings
Start of migration to boost::test
68
  BOOST_REQUIRE((year_out == 1999) && (month_out == 12) && (day_out == 31));
1377.8.1 by pawel
primitive integration of the testing framework with the building process
69
  
70
  julian_day= 2454526;
71
  gregorian_date_from_julian_day_number(julian_day, &year_out, &month_out, &day_out);
2097.2.3 by Andrew Hutchings
Start of migration to boost::test
72
  BOOST_REQUIRE((year_out == 2008) && (month_out == 2) && (day_out == 29));
73
}
74
BOOST_AUTO_TEST_SUITE_END()
75
76
BOOST_AUTO_TEST_SUITE(DayOfWeek)
77
BOOST_AUTO_TEST_CASE(MondayFirst)
78
{
79
  /* Friday 2010 IV 2 */
80
  BOOST_REQUIRE_EQUAL(4, day_of_week(2455289, false));
81
}
82
83
BOOST_AUTO_TEST_CASE(SundayFirst)
84
{
85
  /* Friday 2010 IV 2 */
86
  BOOST_REQUIRE_EQUAL(5, day_of_week(2455289, true));
87
}
88
BOOST_AUTO_TEST_SUITE_END()
89
90
91
BOOST_AUTO_TEST_SUITE(CalendarInUnixEpochRange)
92
BOOST_AUTO_TEST_CASE(MinOfRange)
1377.8.1 by pawel
primitive integration of the testing framework with the building process
93
{
94
  uint32_t year= 1970, month= 1, day= 1, hour= 0, minute= 0, second= 0;
95
2097.2.3 by Andrew Hutchings
Start of migration to boost::test
96
  BOOST_REQUIRE(in_unix_epoch_range(year, month, day, hour, minute, second));
1377.8.1 by pawel
primitive integration of the testing framework with the building process
97
}
98
2097.2.3 by Andrew Hutchings
Start of migration to boost::test
99
BOOST_AUTO_TEST_CASE(MaxOfRange)
1377.8.1 by pawel
primitive integration of the testing framework with the building process
100
{
101
  uint32_t year= 2038, month= 1, day= 19, hour= 3, minute= 14, second= 7;
102
2097.2.3 by Andrew Hutchings
Start of migration to boost::test
103
  BOOST_REQUIRE(in_unix_epoch_range(year, month, day, hour, minute, second));
1377.8.1 by pawel
primitive integration of the testing framework with the building process
104
}
105
2097.2.3 by Andrew Hutchings
Start of migration to boost::test
106
BOOST_AUTO_TEST_CASE(OneSecondBeforeMinOfRange)
1377.8.1 by pawel
primitive integration of the testing framework with the building process
107
{
108
  uint32_t year= 1969, month= 12, day= 31, hour= 23, minute= 59, second= 59;
109
2097.2.3 by Andrew Hutchings
Start of migration to boost::test
110
  BOOST_REQUIRE(not in_unix_epoch_range(year, month, day, hour, minute, second));
1377.8.1 by pawel
primitive integration of the testing framework with the building process
111
}
112
2097.2.3 by Andrew Hutchings
Start of migration to boost::test
113
BOOST_AUTO_TEST_CASE(OneSecondAfterMaxOfRange)
1377.8.1 by pawel
primitive integration of the testing framework with the building process
114
{
115
  uint32_t year= 2038, month= 1, day= 19, hour= 3, minute= 14, second= 8;
116
2097.2.3 by Andrew Hutchings
Start of migration to boost::test
117
  BOOST_REQUIRE(not in_unix_epoch_range(year, month, day, hour, minute, second));
1377.8.1 by pawel
primitive integration of the testing framework with the building process
118
}
119
2097.2.3 by Andrew Hutchings
Start of migration to boost::test
120
BOOST_AUTO_TEST_CASE(InsideRange)
1377.8.1 by pawel
primitive integration of the testing framework with the building process
121
{
122
  uint32_t year= 1980, month= 11, day= 1, hour= 5, minute= 8, second= 5;
2097.2.3 by Andrew Hutchings
Start of migration to boost::test
123
  BOOST_REQUIRE(in_unix_epoch_range(year, month, day, hour, minute, second));
1377.8.1 by pawel
primitive integration of the testing framework with the building process
124
125
  year= 2010; month= 4; day= 2; hour= 21; minute= 44; second= 0;
2097.2.3 by Andrew Hutchings
Start of migration to boost::test
126
  BOOST_REQUIRE(in_unix_epoch_range(year, month, day, hour, minute, second));
1377.8.1 by pawel
primitive integration of the testing framework with the building process
127
128
  year= 2020; month= 7; day= 13; hour= 16; minute= 56; second= 59;
2097.2.3 by Andrew Hutchings
Start of migration to boost::test
129
  BOOST_REQUIRE(in_unix_epoch_range(year, month, day, hour, minute, second));
1377.8.1 by pawel
primitive integration of the testing framework with the building process
130
}
2097.2.3 by Andrew Hutchings
Start of migration to boost::test
131
BOOST_AUTO_TEST_SUITE_END()