mySQL 5.0.11 sources for tomato
[tomato.git] / release / src / router / mysql / unittest / my_decimal / my_decimal-t.cc
blob48d00465af9040bc47d3c5af81963a8baa5fd896
1 /* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
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.
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.
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 */
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>
28 Test my_decimal constuctor and assignement operators
30 static int
31 test_copy_and_compare()
33 my_decimal d1,d2;
35 ulonglong val= 42;
37 ok(ulonglong2decimal(val,&d1) == 0, "Pass");
38 d2= d1;
39 my_decimal d3(d1);
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");
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");
50 ok(val == val1,"Pass");
51 ok(val == val2,"Pass");
52 ok(val == val3,"Pass");
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");
60 return 0;
64 int main()
66 plan(13);
67 diag("Testing my_decimal constructor and assignment operators");
69 test_copy_and_compare();
71 return exit_status();