~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to unittests/temporal_test.cc

created files for temporal tests
created generator class
tests for == and != operators for Date-Date comparison

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
 
 
21
#include "config.h"
 
22
 
 
23
#include <gtest/gtest.h>
 
24
#include <drizzled/temporal.h>
 
25
 
 
26
#include "generator.h"
 
27
 
 
28
using namespace drizzled;
 
29
 
 
30
class DateTest : public ::testing::Test {
 
31
 protected:
 
32
  Date sample_date, identical_with_sample_date, before_sample_date, after_sample_date;
 
33
  
 
34
  virtual void SetUp
 
35
  {
 
36
    Generator::DateGen::make_date(&before_sample_date, 1980, 1, 1);
 
37
    
 
38
    Generator::DateGen::make_date(&sample_date, 2010, 9, 8);
 
39
    Generator::DateGen::make_date(&identical_with_sample_date, 2010, 9, 8);
 
40
 
 
41
    Generator::DateGen::make_date(&after_sample_date, 2010, 9, 8);
 
42
  }
 
43
};
 
44
 
 
45
 
 
46
TEST_F(DateTest, operatorEqual_ComparingIdencticalDates_ShouldReturn_True)
 
47
{
 
48
  bool result= (sample_date == identical_with_sample_date);
 
49
  
 
50
  ASSERT_EQ(true, result);
 
51
}
 
52
 
 
53
TEST_F(DateTest, operatorEqual_ComparingDifferentDates_ShouldReturn_False)
 
54
{
 
55
  bool result= (sample_date == before_sample_date);
 
56
  
 
57
  ASSERT_EQ(false, result);
 
58
}
 
59
 
 
60
TEST_F(DateTest, operatorNotEqual_ComparingIdencticalDates_ShouldReturn_False)
 
61
 
62
  bool result= (sample_date != identical_with_sample_date);
 
63
  
 
64
  ASSERT_EQ(false, result);
 
65
}
 
66
 
 
67
TEST_F(DateTest, operatorNotEqual_ComparingDifferentDates_ShouldReturn_True)
 
68
{
 
69
  bool result= (sample_date != before_sample_date);
 
70
  
 
71
  ASSERT_EQ(true, result);
 
72
}