File: testgreg_month.cpp

package info (click to toggle)
boost1.74 1.74.0-9
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 464,084 kB
  • sloc: cpp: 3,338,324; xml: 131,293; python: 33,088; ansic: 14,336; asm: 4,034; sh: 3,351; makefile: 1,193; perl: 1,036; yacc: 478; php: 212; ruby: 102; lisp: 24; sql: 13; csh: 6
file content (67 lines) | stat: -rw-r--r-- 3,116 bytes parent folder | download | duplicates (17)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/* Copyright (c) 2002,2003 CrystalClear Software, Inc.
 * Use, modification and distribution is subject to the 
 * Boost Software License, Version 1.0. (See accompanying
 * file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
 * Author: Jeff Garland 
 */

#include "boost/date_time/gregorian/greg_month.hpp"
#include "../testfrmwk.hpp"
#include <iostream>


void 
test_month() 
{
  using namespace boost::gregorian;
  greg_month m1(Jan), m2(Feb), m3(Mar), m4(Apr), m5(May), m6(Jun);
  greg_month m7(Jul), m8(Aug), m9(Sep), m10(Oct), m11(Nov),m12(Dec);
  check("January  as_number", m1.as_number() == 1);
  check("December as_number", m12.as_number() == 12);
  check("Jan as Short String",  m1.as_short_string()  == std::string("Jan"));
  check("Feb as Short String",  m2.as_short_string()  == std::string("Feb"));
  check("Mar as Short String",  m3.as_short_string()  == std::string("Mar"));
  check("Apr as Short String",  m4.as_short_string()  == std::string("Apr"));
  check("May as Short String",  m5.as_short_string()  == std::string("May"));
  check("Jun as Short String",  m6.as_short_string()  == std::string("Jun"));
  check("Jul as Short String",  m7.as_short_string()  == std::string("Jul"));
  check("Aug as Short String",  m8.as_short_string()  == std::string("Aug"));
  check("Sep as Short String",  m9.as_short_string()  == std::string("Sep"));
  check("Oct as Short String",  m10.as_short_string() == std::string("Oct"));
  check("Nov as Short String",  m11.as_short_string() == std::string("Nov"));
  check("Dec as Short String",  m12.as_short_string() == std::string("Dec"));
  check("Jan as Long String",  m1.as_long_string()  == std::string("January"));
  check("Feb as Long String",  m2.as_long_string()  == std::string("February"));
  check("Mar as Long String",  m3.as_long_string()  == std::string("March"));
  check("Apr as Long String",  m4.as_long_string()  == std::string("April"));
  check("May as Long String",  m5.as_long_string()  == std::string("May"));
  check("Jun as Long String",  m6.as_long_string()  == std::string("June"));
  check("Jul as Long String",  m7.as_long_string()  == std::string("July"));
  check("Aug as Long String",  m8.as_long_string()  == std::string("August"));
  check("Sep as Long String",  m9.as_long_string()  == std::string("September"));
  check("Oct as Long String",  m10.as_long_string() == std::string("October"));
  check("Nov as Long String",  m11.as_long_string() == std::string("November"));
  check("Dec as Long String",  m12.as_long_string() == std::string("December"));
  //month m(5);

  //TODO can this support NAM? or check exception
  //  greg_month sm0(0);
  greg_month sm1(1);
  greg_month sm12(12);
  //check("check not a month value", sm0.as_short_string() == "NAM");
  check("short construction -- 1", 
        sm1.as_short_string() == std::string("Jan"));
  check("short construction -- 12", 
        sm12.as_short_string() == std::string("Dec"));
  check("month traits min", (greg_month::min)() == 1);
  check("month traits max", (greg_month::max)() == 12);

}

int
main() 
{
  test_month();
  return printTestStats();
}