~ubuntu-branches/debian/squeeze/mysql-5.1/squeeze

« back to all changes in this revision

Viewing changes to unittest/my_decimal/my_decimal-t.cc

  • Committer: Package Import Robot
  • Author(s): Moritz Muehlenhoff
  • Date: 2014-01-14 10:40:30 UTC
  • mfrom: (1.1.5)
  • Revision ID: package-import@ubuntu.com-20140114104030-44alii0hx3x3g41y
Tags: 5.1.73-1
* New upstream release
  http://dev.mysql.com/doc/relnotes/mysql/5.1/en/news-5-1-73.html
* Update patches
* Disable flaky test rpl.rpl_innodb_bug28430 breaking the build. It's  marked
  as experimental by upstream and the internet is full of reports about it's
  unrelialibity

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
 
2
 
 
3
   This program is free software; you can redistribute it and/or modify
 
4
   it under the terms of the GNU General Public License as published by
 
5
   the Free Software Foundation; version 2 of the License.
 
6
 
 
7
   This program is distributed in the hope that it will be useful,
 
8
   but WITHOUT ANY WARRANTY; without even the implied warranty of
 
9
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
10
   GNU General Public License for more details.
 
11
 
 
12
   You should have received a copy of the GNU General Public License
 
13
   along with this program; if not, write to the Free Software
 
14
   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */
 
15
 
 
16
#include "my_config.h"
 
17
#include "config.h"
 
18
#include <tap.h>
 
19
#include <my_global.h>
 
20
#include <my_sys.h>
 
21
#include <m_string.h>
 
22
#include <sql_string.h>
 
23
#include <my_decimal.h>
 
24
 
 
25
 
 
26
 
 
27
/*
 
28
  Test my_decimal constuctor and assignement operators
 
29
*/
 
30
static int
 
31
test_copy_and_compare()
 
32
{
 
33
  my_decimal d1,d2;
 
34
 
 
35
  ulonglong val= 42;
 
36
 
 
37
  ok(ulonglong2decimal(val,&d1) == 0, "Pass");
 
38
  d2= d1;
 
39
  my_decimal d3(d1);
 
40
 
 
41
  ok(my_decimal_cmp(&d1, &d2) == 0, "Pass");
 
42
  ok(my_decimal_cmp(&d2, &d3) == 0, "Pass");
 
43
  ok(my_decimal_cmp(&d3, &d1) == 0,"Pass");
 
44
 
 
45
  ulonglong val1, val2, val3;
 
46
  ok(decimal2ulonglong(&d1, &val1) == 0, "Pass");
 
47
  ok(decimal2ulonglong(&d2, &val2) == 0,"Pass");
 
48
  ok(decimal2ulonglong(&d3, &val3) == 0,"Pass");
 
49
 
 
50
  ok(val == val1,"Pass");
 
51
  ok(val == val2,"Pass");
 
52
  ok(val == val3,"Pass");
 
53
 
 
54
  // The CTOR/operator=() generated by the compiler would fail here:
 
55
  val= 45;
 
56
  ok(ulonglong2decimal(val, &d1) == 0,"Pass");
 
57
  ok(my_decimal_cmp(&d1, &d2) == 1,"Pass");
 
58
  ok(my_decimal_cmp(&d1, &d3) == 1,"Pass");
 
59
 
 
60
  return 0;
 
61
 
 
62
}
 
63
 
 
64
int main()
 
65
{
 
66
  plan(13);
 
67
  diag("Testing my_decimal constructor and assignment operators");
 
68
 
 
69
  test_copy_and_compare();
 
70
  
 
71
  return exit_status();
 
72
}