transactd 2.4.5 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CMakeLists.txt +1 -1
- data/README-JA.md +52 -529
- data/README.md +52 -523
- data/bin/common/tdclc_32_3_0.dll +0 -0
- data/bin/common/tdclc_64_3_0.dll +0 -0
- data/build/common/system.cmake +2 -1
- data/build/common/transactd_cl_common.cmake +3 -6
- data/build/swig/ruby/ruby.swg +85 -28
- data/build/swig/ruby/tdclrb_wrap.cpp +3195 -1578
- data/build/swig/tdcl.i +161 -5
- data/build/tdclc/CMakeLists.txt +1 -0
- data/build/tdclc/tdclc.cbproj +7 -1
- data/build/tdclc/tdclc.rc +4 -4
- data/build/tdclcpp/tdclcpp.rc +4 -4
- data/build/tdclcpp/tdclcpp_bc.cbproj +2 -5
- data/build/tdclrb/tdclrb.rc +4 -4
- data/source/bzs/db/blobStructs.h +1 -1
- data/source/bzs/db/engine/mysql/database.cpp +199 -74
- data/source/bzs/db/engine/mysql/database.h +47 -18
- data/source/bzs/db/engine/mysql/dbManager.cpp +1 -0
- data/source/bzs/db/engine/mysql/mysqlInternal.h +32 -8
- data/source/bzs/db/protocol/tdap/btrDate.cpp +110 -75
- data/source/bzs/db/protocol/tdap/btrDate.h +46 -21
- data/source/bzs/db/protocol/tdap/client/activeTable.cpp +18 -18
- data/source/bzs/db/protocol/tdap/client/activeTable.h +25 -25
- data/source/bzs/db/protocol/tdap/client/activeTableImple.h +10 -4
- data/source/bzs/db/protocol/tdap/client/client.cpp +6 -5
- data/source/bzs/db/protocol/tdap/client/client.h +82 -15
- data/source/bzs/db/protocol/tdap/client/database.cpp +531 -142
- data/source/bzs/db/protocol/tdap/client/database.h +19 -6
- data/source/bzs/db/protocol/tdap/client/dbDef.cpp +461 -408
- data/source/bzs/db/protocol/tdap/client/dbDef.h +11 -17
- data/source/bzs/db/protocol/tdap/client/dllmain.cpp +61 -13
- data/source/bzs/db/protocol/tdap/client/field.cpp +1592 -1398
- data/source/bzs/db/protocol/tdap/client/field.h +110 -121
- data/source/bzs/db/protocol/tdap/client/fields.h +40 -10
- data/source/bzs/db/protocol/tdap/client/filter.h +69 -55
- data/source/bzs/db/protocol/tdap/client/groupQuery.cpp +296 -164
- data/source/bzs/db/protocol/tdap/client/groupQuery.h +77 -25
- data/source/bzs/db/protocol/tdap/client/memRecord.cpp +31 -13
- data/source/bzs/db/protocol/tdap/client/memRecord.h +31 -21
- data/source/bzs/db/protocol/tdap/client/nsDatabase.cpp +1 -1
- data/source/bzs/db/protocol/tdap/client/nsDatabase.h +4 -1
- data/source/bzs/db/protocol/tdap/client/nsTable.cpp +69 -24
- data/source/bzs/db/protocol/tdap/client/nsTable.h +3 -1
- data/source/bzs/db/protocol/tdap/client/recordset.cpp +1 -0
- data/source/bzs/db/protocol/tdap/client/recordsetImple.h +46 -27
- data/source/bzs/db/protocol/tdap/client/request.h +2 -1
- data/source/bzs/db/protocol/tdap/client/serializer.cpp +44 -9
- data/source/bzs/db/protocol/tdap/client/serializer.h +1 -1
- data/source/bzs/db/protocol/tdap/client/sqlBuilder.cpp +182 -76
- data/source/bzs/db/protocol/tdap/client/sqlBuilder.h +23 -12
- data/source/bzs/db/protocol/tdap/client/stringConverter.h +8 -10
- data/source/bzs/db/protocol/tdap/client/table.cpp +172 -93
- data/source/bzs/db/protocol/tdap/client/table.h +112 -37
- data/source/bzs/db/protocol/tdap/client/trdboostapi.h +17 -0
- data/source/bzs/db/protocol/tdap/client/trdboostapiInternal.h +0 -1
- data/source/bzs/db/protocol/tdap/client/trdclcppautolink.h +0 -2
- data/source/bzs/db/protocol/tdap/client/trdormapi.h +1 -1
- data/source/bzs/db/protocol/tdap/fieldComp.h +698 -14
- data/source/bzs/db/protocol/tdap/myDateTime.cpp +723 -307
- data/source/bzs/db/protocol/tdap/myDateTime.h +294 -0
- data/source/bzs/db/protocol/tdap/mysql/databaseSchema.cpp +164 -54
- data/source/bzs/db/protocol/tdap/mysql/databaseSchema.h +6 -3
- data/source/bzs/db/protocol/tdap/mysql/recordsetReader.h +133 -550
- data/source/bzs/db/protocol/tdap/mysql/request.h +6 -5
- data/source/bzs/db/protocol/tdap/mysql/tdapCommandExecuter.cpp +217 -82
- data/source/bzs/db/protocol/tdap/mysql/tdapCommandExecuter.h +1 -1
- data/source/bzs/db/protocol/tdap/tdapRequest.h +4 -9
- data/source/bzs/db/protocol/tdap/tdapSchema.cpp +808 -17
- data/source/bzs/db/protocol/tdap/tdapSchema.h +656 -164
- data/source/bzs/db/protocol/tdap/tdapcapi.h +130 -28
- data/source/bzs/db/protocol/tdap/uri.h +40 -32
- data/source/bzs/db/transactd/connManager.cpp +1 -1
- data/source/bzs/db/transactd/transactd.cpp +7 -0
- data/source/bzs/env/compiler.h +107 -94
- data/source/bzs/env/crosscompile.cpp +24 -12
- data/source/bzs/env/crosscompile.h +75 -6
- data/source/bzs/env/mbcswchrLinux.cpp +2 -2
- data/source/bzs/env/tcharMinGW.h +4 -0
- data/source/bzs/example/changeSchema.cpp +22 -17
- data/source/bzs/example/queryData.cpp +4 -0
- data/source/bzs/netsvc/client/iconnection.h +3 -1
- data/source/bzs/netsvc/client/tcpClient.h +10 -3
- data/source/bzs/rtl/stringBuffers.cpp +7 -0
- data/source/bzs/test/tdclatl/bench_query_atl.js +6 -0
- data/source/bzs/test/tdclatl/bench_tdclatl.js +8 -1
- data/source/bzs/test/tdclatl/test_query_atl.js +22 -2
- data/source/bzs/test/tdclatl/test_v3.js +1017 -0
- data/source/bzs/test/tdclphp/transactd_Test.php +55 -21
- data/source/bzs/test/tdclphp/transactd_datetime_Test.php +0 -5
- data/source/bzs/test/tdclphp/transactd_pool_Test.php +2 -0
- data/source/bzs/test/tdclphp/transactd_v3_Test.php +743 -0
- data/source/bzs/test/tdclrb/transactd_datetime_spec.rb +0 -5
- data/source/bzs/test/tdclrb/transactd_pool_spec.rb +2 -0
- data/source/bzs/test/tdclrb/transactd_spec.rb +39 -16
- data/source/bzs/test/tdclrb/transactd_v3_spec.rb +748 -0
- data/source/bzs/test/transactdBench/transactdBench.cpp +55 -58
- data/source/bzs/test/transactdBench/transactdBench2.cpp +1 -3
- data/source/bzs/test/trdclengn/testField.h +3305 -0
- data/source/bzs/test/trdclengn/test_tdclcpp_v3.cpp +1050 -0
- data/source/bzs/test/trdclengn/test_trdclengn.cpp +112 -190
- data/source/bzs/test/trdclengn/testbase.h +137 -0
- data/source/global/ormsrcgen/srcgen.cpp +23 -12
- data/source/global/ormsrcgen/template/ormDataClass_template.h +2 -0
- data/source/global/querystmts/querystmts.cpp +2 -3
- data/source/global/tdclatl/Bitset.cpp +38 -0
- data/source/global/tdclatl/Bitset.h +63 -0
- data/source/global/tdclatl/Database.cpp +59 -18
- data/source/global/tdclatl/Database.h +7 -4
- data/source/global/tdclatl/DbDef.cpp +6 -6
- data/source/global/tdclatl/DbDef.h +2 -1
- data/source/global/tdclatl/Field.cpp +112 -0
- data/source/global/tdclatl/Field.h +19 -5
- data/source/global/tdclatl/FieldDef.cpp +137 -16
- data/source/global/tdclatl/FieldDef.h +18 -2
- data/source/global/tdclatl/FieldDefs.cpp +54 -1
- data/source/global/tdclatl/FieldDefs.h +3 -0
- data/source/global/tdclatl/GroupQuery.cpp +8 -8
- data/source/global/tdclatl/QueryBase.cpp +65 -0
- data/source/global/tdclatl/QueryBase.h +10 -0
- data/source/global/tdclatl/Record.cpp +33 -2
- data/source/global/tdclatl/Record.h +3 -1
- data/source/global/tdclatl/RecordsetQuery.cpp +42 -0
- data/source/global/tdclatl/RecordsetQuery.h +8 -0
- data/source/global/tdclatl/Table.cpp +127 -3
- data/source/global/tdclatl/Table.h +10 -1
- data/source/global/tdclatl/TableDef.cpp +41 -8
- data/source/global/tdclatl/TableDef.h +7 -2
- data/source/global/tdclatl/activeTable.cpp +40 -71
- data/source/global/tdclatl/resource.h +0 -0
- data/source/global/tdclatl/tdclatl.idl +222 -28
- data/source/linux/tchar.h +100 -96
- data/transactd.gemspec +2 -2
- metadata +13 -11
- data/BUILD_UNIX-JA.md +0 -161
- data/BUILD_WIN-JA.md +0 -326
- data/README_ORMSRCGEN-JA.md +0 -115
- data/README_ORMSRCGEN.md +0 -118
- data/RELEASE_NOTE-JA.md +0 -356
- data/RELEASE_NOTE.md +0 -360
- data/bin/common/tdclc_32_2_4.dll +0 -0
- data/bin/common/tdclc_64_2_4.dll +0 -0
- data/source/bzs/test/trdclengn/test_blob.cpp +0 -375
@@ -0,0 +1,3305 @@
|
|
1
|
+
#ifndef BZS_TEST_TRDCLENGN_TESTFIELD_H
|
2
|
+
#define BZS_TEST_TRDCLENGN_TESTFIELD_H
|
3
|
+
/* =================================================================
|
4
|
+
Copyright (C) 2015 BizStation Corp All rights reserved.
|
5
|
+
|
6
|
+
This program is free software; you can redistribute it and/or
|
7
|
+
modify it under the terms of the GNU General Public License
|
8
|
+
as published by the Free Software Foundation; either version 2
|
9
|
+
of the License, or (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., 59 Temple Place - Suite 330, Boston, MA
|
19
|
+
02111-1307, USA.
|
20
|
+
================================================================= */
|
21
|
+
#include "testbase.h"
|
22
|
+
#include <bzs/db/protocol/tdap/btrDate.h>
|
23
|
+
#include <limits.h>
|
24
|
+
#include <stdlib.h>
|
25
|
+
|
26
|
+
#define DBNAMEV3 _T("test_v3")
|
27
|
+
|
28
|
+
const char* sql = "CREATE TABLE `setenumbit` ("
|
29
|
+
"`id` int(11) NOT NULL AUTO_INCREMENT,"
|
30
|
+
"`set5` set('A','B','C','D','E') DEFAULT '',"
|
31
|
+
"`set64` set('a0', 'a1', 'a2', 'a3', 'a4', 'a5', 'a6', 'a7', 'a8', 'a9', 'b0', 'b1', 'b2', 'b3', 'b4', 'b5', 'b6', 'b7', 'b8', 'b9', 'c0', 'c1', 'c2', 'c3', 'c4', 'c5', 'c6', 'c7', 'c8', 'c9', 'd0', 'd1', 'd2', 'd3', 'd4', 'd5', 'd6', 'd7', 'd8', 'd9', 'e0', 'e1', 'e2', 'e3', 'e4', 'e5', 'e6', 'e7', 'e8', 'e9', 'f0', 'f1', 'f2', 'f3', 'f4', 'f5', 'f6', 'f7', 'f8', 'f9', 'g0', 'g1', 'g2', 'g3') DEFAULT '',"
|
32
|
+
"`enum2` enum('Y','N') DEFAULT 'N', "
|
33
|
+
"`enum260` enum('a0', 'a1', 'a2', 'a3', 'a4', 'a5', 'a6', 'a7', 'a8', 'a9', 'b0', 'b1', 'b2', 'b3', 'b4', 'b5', 'b6', 'b7', 'b8', 'b9', 'c0', 'c1', 'c2', 'c3', 'c4', 'c5', 'c6', 'c7', 'c8', 'c9', 'd0', 'd1', 'd2', 'd3', 'd4', 'd5', 'd6', 'd7', 'd8', 'd9', 'e0', 'e1', 'e2', 'e3', 'e4', 'e5', 'e6', 'e7', 'e8', 'e9', 'f0', 'f1', 'f2', 'f3', 'f4', 'f5', 'f6', 'f7', 'f8', 'f9', 'g0', 'g1', 'g2', 'g3', 'g4', 'g5', 'g6', 'g7', 'g8', 'g9', 'h0', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'h7', 'h8', 'h9', 'i0', 'i1', 'i2', 'i3', 'i4', 'i5', 'i6', 'i7', 'i8', 'i9', 'j0', 'j1', 'j2', 'j3', 'j4', 'j5', 'j6', 'j7', 'j8', 'j9', 'k0', 'k1', 'k2', 'k3', 'k4', 'k5', 'k6', 'k7', 'k8', 'k9', 'l0', 'l1', 'l2', 'l3', 'l4', 'l5', 'l6', 'l7', 'l8', 'l9', 'm0', 'm1', 'm2', 'm3', 'm4', 'm5', 'm6', 'm7', 'm8', 'm9', 'n0', 'n1', 'n2', 'n3', 'n4', 'n5', 'n6', 'n7', 'n8', 'n9', 'o0', 'o1', 'o2', 'o3', 'o4', 'o5', 'o6', 'o7', 'o8', 'o9', 'p0', 'p1', 'p2', 'p3', 'p4', 'p5', 'p6', 'p7', 'p8', 'p9', 'q0', 'q1', 'q2', 'q3', 'q4', 'q5', 'q6', 'q7', 'q8', 'q9', 'r0', 'r1', 'r2', 'r3', 'r4', 'r5', 'r6', 'r7', 'r8', 'r9', 's0', 's1', 's2', 's3', 's4', 's5', 's6', 's7', 's8', 's9', 't0', 't1', 't2', 't3', 't4', 't5', 't6', 't7', 't8', 't9', 'u0', 'u1', 'u2', 'u3', 'u4', 'u5', 'u6', 'u7', 'u8', 'u9', 'v0', 'v1', 'v2', 'v3', 'v4', 'v5', 'v6', 'v7', 'v8', 'v9', 'w0', 'w1', 'w2', 'w3', 'w4', 'w5', 'w6', 'w7', 'w8', 'w9', 'x0', 'x1', 'x2', 'x3', 'x4', 'x5', 'x6', 'x7', 'x8', 'x9', 'y0', 'y1', 'y2', 'y3', 'y4', 'y5', 'y6', 'y7', 'y8', 'y9', 'z0', 'z1', 'z2', 'z3', 'z4', 'z5', 'z6', 'z7', 'z8', 'z9') DEFAULT 'a0',"
|
34
|
+
"`bit1` bit(1) DEFAULT b'0',"
|
35
|
+
"`bit8` bit(8) DEFAULT b'0',"
|
36
|
+
"`bit32` bit(32) DEFAULT b'0',"
|
37
|
+
"`bit64` bit(64) DEFAULT b'0',"
|
38
|
+
"PRIMARY KEY (`id`) "
|
39
|
+
") ENGINE=InnoDB DEFAULT CHARSET=utf8;";
|
40
|
+
|
41
|
+
|
42
|
+
const char* test_records = "INSERT INTO `setenumbit` (`id`, `set5`, `set64`, `enum2`, `enum260`, `bit1`, `bit8`, `bit32`, `bit64`) VALUES"
|
43
|
+
"(1, 'A', 'a0', 'N', 'a0', b'1', b'1', b'1', b'1'),"
|
44
|
+
"(2, 'A,B,C,D,E', 'a0,g3', 'Y', 'z9', b'1', b'11111111', b'11111111111111111111111111111111', b'1111111111111111111111111111111111111111111111111111111111111111'),"
|
45
|
+
"(3, '', '', '0', '0', b'0', b'00000000', b'00000000', b'00000000'),"
|
46
|
+
"(4, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);";
|
47
|
+
|
48
|
+
|
49
|
+
|
50
|
+
short createFieldStoreDataBase(database* db)
|
51
|
+
{
|
52
|
+
db->create(makeUri(PROTOCOL, HOSTNAME, DBNAMEV3, BDFNAME));
|
53
|
+
if (db->stat() == STATUS_TABLE_EXISTS_ERROR)
|
54
|
+
{
|
55
|
+
db->open(makeUri(PROTOCOL, HOSTNAME, DBNAMEV3, BDFNAME));
|
56
|
+
if (db->stat()) return db->stat();
|
57
|
+
db->drop();
|
58
|
+
db->create(makeUri(PROTOCOL, HOSTNAME, DBNAMEV3, BDFNAME));
|
59
|
+
}
|
60
|
+
if (db->stat()) return db->stat();
|
61
|
+
return 0;
|
62
|
+
}
|
63
|
+
|
64
|
+
short createTestTable1(database* db)
|
65
|
+
{
|
66
|
+
try
|
67
|
+
{
|
68
|
+
openDatabase(db, makeUri(PROTOCOL, HOSTNAME, DBNAMEV3, BDFNAME), TYPE_SCHEMA_BDF,TD_OPEN_NORMAL);
|
69
|
+
dbdef* def = db->dbDef();
|
70
|
+
short tableid = 1;
|
71
|
+
|
72
|
+
insertTable(def, tableid, _T("fieldtest"), g_td_charsetIndex);
|
73
|
+
short fieldnum = 0;
|
74
|
+
fielddef* fd;
|
75
|
+
insertField(def, tableid, fieldnum, _T("id"), ft_integer, 4);
|
76
|
+
|
77
|
+
int lens[5] = {1, 2, 3, 4, 8};
|
78
|
+
_TCHAR buf[50];
|
79
|
+
//int
|
80
|
+
for (int i=1; i < 6 ; ++i)
|
81
|
+
{
|
82
|
+
_stprintf_s(buf, 50, _T("int_%d_byte"), lens[i-1]);
|
83
|
+
fd = insertField(def, tableid, ++fieldnum, buf, ft_integer, lens[i-1]);
|
84
|
+
if (i==4)
|
85
|
+
fd->setDefaultValue((__int64)INT_MIN);
|
86
|
+
if (i==5)
|
87
|
+
fd->setDefaultValue(LLONG_MIN);
|
88
|
+
|
89
|
+
}
|
90
|
+
|
91
|
+
//unsigned int
|
92
|
+
for (int i=1; i < 6 ; ++i)
|
93
|
+
{
|
94
|
+
_stprintf_s(buf, 50, _T("uint_%d_byte"), lens[i-1]);
|
95
|
+
fd = insertField(def, tableid, ++fieldnum, buf, ft_uinteger, lens[i-1]);
|
96
|
+
if (i==4)
|
97
|
+
fd->setDefaultValue((__int64)UINT_MAX);
|
98
|
+
if (i==5)
|
99
|
+
fd->setDefaultValue((__int64)ULLONG_MAX);
|
100
|
+
}
|
101
|
+
|
102
|
+
//myyear
|
103
|
+
insertField(def, tableid, ++fieldnum, _T("year"), ft_myyear, 1);
|
104
|
+
|
105
|
+
//logical
|
106
|
+
insertField(def, tableid, ++fieldnum, _T("logical1"), ft_logical, 1);
|
107
|
+
insertField(def, tableid, ++fieldnum, _T("logical2"), ft_logical, 2);
|
108
|
+
|
109
|
+
//mydate
|
110
|
+
insertField(def, tableid, ++fieldnum, _T("date"), ft_mydate, 3);
|
111
|
+
|
112
|
+
//double
|
113
|
+
insertField(def, tableid, ++fieldnum, _T("double4.0"), ft_float, 4);
|
114
|
+
fd = insertField(def, tableid, ++fieldnum, _T("double4.4"), ft_float, 4);
|
115
|
+
fd->decimals = 4;
|
116
|
+
|
117
|
+
insertField(def, tableid, ++fieldnum, _T("double8.0"), ft_float, 8);
|
118
|
+
fd = insertField(def, tableid, ++fieldnum, _T("double8.5"), ft_float, 8);
|
119
|
+
fd->decimals = 15;
|
120
|
+
|
121
|
+
//decimal
|
122
|
+
/*for (int i=1; i < 66 ; ++i)
|
123
|
+
{
|
124
|
+
_stprintf_s(buf, 50, _T("dec_%d_digits"), i);
|
125
|
+
fd = insertField(def, tableid, ++fieldnum, buf, ft_mydecimal, 0);
|
126
|
+
fd->setLenByDecimal(i, (i-1) % 30);
|
127
|
+
}*/
|
128
|
+
fd = insertField(def, tableid, ++fieldnum, _T("dec1"), ft_mydecimal, 1);
|
129
|
+
fd->setDecimalDigits(15, 5);
|
130
|
+
|
131
|
+
fd = insertField(def, tableid, ++fieldnum, _T("dec2"), ft_mydecimal, 1);
|
132
|
+
fd->setDecimalDigits(65, 30);
|
133
|
+
|
134
|
+
fd = insertField(def, tableid, ++fieldnum, _T("dec3"), ft_mydecimal, 1);
|
135
|
+
fd->setDecimalDigits(1, 0);
|
136
|
+
|
137
|
+
fd = insertField(def, tableid, ++fieldnum, _T("dec4"), ft_mydecimal, 1);
|
138
|
+
fd->setDecimalDigits(11, 11);
|
139
|
+
|
140
|
+
fd = insertField(def, tableid, ++fieldnum, _T("dec5"), ft_mydecimal, 1);
|
141
|
+
fd->setDecimalDigits(15, 5);
|
142
|
+
|
143
|
+
fd = insertField(def, tableid, ++fieldnum, _T("dec6"), ft_mydecimal, 1);
|
144
|
+
fd->setDecimalDigits(65, 30);
|
145
|
+
|
146
|
+
fd = insertField(def, tableid, ++fieldnum, _T("dec7"), ft_mydecimal, 1);
|
147
|
+
fd->setDecimalDigits(1, 0);
|
148
|
+
|
149
|
+
fd = insertField(def, tableid, ++fieldnum, _T("dec8"), ft_mydecimal, 1);
|
150
|
+
fd->setDecimalDigits(11, 11);
|
151
|
+
|
152
|
+
keydef* kd = insertKey(def, tableid, 0);
|
153
|
+
kd->segments[0].fieldNum = 0;
|
154
|
+
kd->segments[0].flags.kf_extend = 1; // extended key type
|
155
|
+
kd->segments[0].flags.kf_changeatable = 1; // changeable
|
156
|
+
kd->segmentCount = 1;
|
157
|
+
|
158
|
+
tabledef* td = def->tableDefs(tableid);
|
159
|
+
td->primaryKeyNum = 0;
|
160
|
+
updateTableDef(def, tableid);
|
161
|
+
return 0;
|
162
|
+
|
163
|
+
}
|
164
|
+
catch (bzs::rtl::exception& e)
|
165
|
+
{
|
166
|
+
_tprintf(_T("Error! %s\n"), (*getMsg(e)).c_str());
|
167
|
+
}
|
168
|
+
return 1;
|
169
|
+
}
|
170
|
+
|
171
|
+
short createTestTableLegacyTimeTable(database* db)
|
172
|
+
{
|
173
|
+
try
|
174
|
+
{
|
175
|
+
dbdef* def = db->dbDef();
|
176
|
+
short tableid = 2;
|
177
|
+
|
178
|
+
insertTable(def, tableid, _T("timetestLegacy"), g_td_charsetIndex);
|
179
|
+
short fieldnum = 0;
|
180
|
+
insertField(def, tableid, fieldnum, _T("id"), ft_integer, 4);
|
181
|
+
|
182
|
+
//time
|
183
|
+
insertField(def, tableid, ++fieldnum, _T("time"), ft_mytime, 3);
|
184
|
+
|
185
|
+
//datetime
|
186
|
+
insertField(def, tableid, ++fieldnum, _T("datetime"), ft_mydatetime, 8);
|
187
|
+
|
188
|
+
//timestamp
|
189
|
+
insertField(def, tableid, ++fieldnum, _T("timestamp"), ft_mytimestamp, 4);
|
190
|
+
|
191
|
+
|
192
|
+
keydef* kd = insertKey(def, tableid, 0);
|
193
|
+
kd->segments[0].fieldNum = 0;
|
194
|
+
kd->segments[0].flags.kf_extend = 1; // extended key type
|
195
|
+
kd->segments[0].flags.kf_changeatable = 1; // changeable
|
196
|
+
kd->segmentCount = 1;
|
197
|
+
|
198
|
+
tabledef* td = def->tableDefs(tableid);
|
199
|
+
td->primaryKeyNum = 0;
|
200
|
+
updateTableDef(def, tableid);
|
201
|
+
return 0;
|
202
|
+
|
203
|
+
}
|
204
|
+
catch (bzs::rtl::exception& e)
|
205
|
+
{
|
206
|
+
_tprintf(_T("Error! %s\n"), (*getMsg(e)).c_str());
|
207
|
+
}
|
208
|
+
return 1;
|
209
|
+
}
|
210
|
+
|
211
|
+
/* If MySQL internal table flag has HA_OPTION_PACK_RECORD
|
212
|
+
then null_bit is offset one.
|
213
|
+
*/
|
214
|
+
short createTestTableHA_OPTION_PACK_RECORD(database* db)
|
215
|
+
{
|
216
|
+
try
|
217
|
+
{
|
218
|
+
dbdef* def = db->dbDef();
|
219
|
+
short tableid = 3;
|
220
|
+
|
221
|
+
insertTable(def, tableid, _T("packrecord_test"), g_td_charsetIndex);
|
222
|
+
short fieldnum = 0;
|
223
|
+
fielddef* fd = insertField(def, tableid, fieldnum, _T("id"), ft_integer, 4);
|
224
|
+
|
225
|
+
fd = insertField(def, tableid, ++fieldnum, _T("int"), ft_integer, 4);
|
226
|
+
fd->setNullable(true, false);
|
227
|
+
|
228
|
+
keydef* kd = insertKey(def, tableid, 0);
|
229
|
+
kd->segments[0].fieldNum = 0;
|
230
|
+
kd->segments[0].flags.kf_extend = 1; // extended key type
|
231
|
+
kd->segments[0].flags.kf_changeatable = 1; // changeable
|
232
|
+
kd->segmentCount = 1;
|
233
|
+
|
234
|
+
tabledef* td = def->tableDefs(tableid);
|
235
|
+
td->primaryKeyNum = 0;
|
236
|
+
updateTableDef(def, tableid);
|
237
|
+
return 0;
|
238
|
+
|
239
|
+
}
|
240
|
+
catch (bzs::rtl::exception& e)
|
241
|
+
{
|
242
|
+
_tprintf(_T("Error! %s\n"), (*getMsg(e)).c_str());
|
243
|
+
}
|
244
|
+
return 1;
|
245
|
+
}
|
246
|
+
|
247
|
+
short createTestTableTime(database* db, bool isMariadb, uchar_td minorVersion, bool isSupportMultiTimeStamp)
|
248
|
+
{
|
249
|
+
try
|
250
|
+
{
|
251
|
+
dbdef* def = db->dbDef();
|
252
|
+
short tableid = 2;
|
253
|
+
|
254
|
+
insertTable(def, tableid, _T("timetest"), g_td_charsetIndex);
|
255
|
+
tabledef* td = def->tableDefs(tableid);
|
256
|
+
td->primaryKeyNum = 0;
|
257
|
+
td->setValidationTarget(isMariadb, minorVersion);
|
258
|
+
|
259
|
+
short fieldnum = 0;
|
260
|
+
insertField(def, tableid, fieldnum, _T("id"), ft_integer, 4);
|
261
|
+
|
262
|
+
//time
|
263
|
+
fielddef* fd = insertField(def, tableid, ++fieldnum, _T("time5"), ft_mytime, 5);
|
264
|
+
fd->decimals = 3;
|
265
|
+
insertField(def, tableid, ++fieldnum, _T("time3"), ft_mytime, 3);
|
266
|
+
fd = insertField(def, tableid, ++fieldnum, _T("time4"), ft_mytime, 4);
|
267
|
+
fd->decimals = 2;
|
268
|
+
fd = insertField(def, tableid, ++fieldnum, _T("time6"), ft_mytime, 6);
|
269
|
+
fd->decimals = 6;
|
270
|
+
|
271
|
+
//datetime
|
272
|
+
fd = insertField(def, tableid, ++fieldnum, _T("datetime7"), ft_mydatetime, 7);
|
273
|
+
fd->decimals = 3;
|
274
|
+
insertField(def, tableid, ++fieldnum, _T("datetime5"), ft_mydatetime, 5);
|
275
|
+
fd = insertField(def, tableid, ++fieldnum, _T("datetime6"), ft_mydatetime, 6);
|
276
|
+
fd->decimals = 2;
|
277
|
+
fd = insertField(def, tableid, ++fieldnum, _T("datetime8"), ft_mydatetime, 8);
|
278
|
+
fd->decimals = 6;
|
279
|
+
|
280
|
+
//timestamp
|
281
|
+
fd = insertField(def, tableid, ++fieldnum, _T("timestamp6"), ft_mytimestamp, 6);
|
282
|
+
fd->decimals = 3;
|
283
|
+
|
284
|
+
if (isSupportMultiTimeStamp)
|
285
|
+
{
|
286
|
+
fd = insertField(def, tableid, ++fieldnum, _T("timestamp4"), ft_mytimestamp, 4);
|
287
|
+
fd->setNullable(true);
|
288
|
+
fd = insertField(def, tableid, ++fieldnum, _T("timestamp5"), ft_mytimestamp, 5);
|
289
|
+
fd->decimals = 2;
|
290
|
+
fd->setNullable(true);
|
291
|
+
fd = insertField(def, tableid, ++fieldnum, _T("timestamp7"), ft_mytimestamp, 7);
|
292
|
+
fd->decimals = 6;
|
293
|
+
fd->setNullable(true);
|
294
|
+
}
|
295
|
+
keydef* kd = insertKey(def, tableid, 0);
|
296
|
+
kd->segments[0].fieldNum = 0;
|
297
|
+
kd->segments[0].flags.kf_extend = 1; // extended key type
|
298
|
+
kd->segments[0].flags.kf_changeatable = 1; // changeable
|
299
|
+
kd->segmentCount = 1;
|
300
|
+
|
301
|
+
|
302
|
+
updateTableDef(def, tableid);
|
303
|
+
return 0;
|
304
|
+
|
305
|
+
}
|
306
|
+
catch (bzs::rtl::exception& e)
|
307
|
+
{
|
308
|
+
_tprintf(_T("Error! %s\n"), (*getMsg(e)).c_str());
|
309
|
+
}
|
310
|
+
return 1;
|
311
|
+
}
|
312
|
+
|
313
|
+
short createTestInMany(database* db)
|
314
|
+
{
|
315
|
+
try
|
316
|
+
{
|
317
|
+
dbdef* def = db->dbDef();
|
318
|
+
short tableid = 4;
|
319
|
+
|
320
|
+
insertTable(def, tableid, _T("nullkey"), g_td_charsetIndex);
|
321
|
+
tabledef* td = def->tableDefs(tableid);
|
322
|
+
td->primaryKeyNum = 0;
|
323
|
+
|
324
|
+
short fieldnum = 0;
|
325
|
+
insertField(def, tableid, fieldnum, _T("id"), ft_autoinc, 4);
|
326
|
+
|
327
|
+
//time
|
328
|
+
fielddef* fd = insertField(def, tableid, ++fieldnum, _T("id2"), ft_integer, 4);
|
329
|
+
fd->setNullable(true);
|
330
|
+
fd = insertField(def, tableid, ++fieldnum, _T("id3"), ft_integer, 4);
|
331
|
+
fd->setNullable(true);
|
332
|
+
fd = insertField(def, tableid, ++fieldnum, _T("name"), ft_myvarchar, 151);
|
333
|
+
fd->setLenByCharnum(50);
|
334
|
+
fd->setNullable(true);
|
335
|
+
|
336
|
+
|
337
|
+
keydef* kd = insertKey(def, tableid, 0);
|
338
|
+
kd->segments[0].fieldNum = 0;
|
339
|
+
kd->segments[0].flags.kf_extend = 1;
|
340
|
+
kd->segments[0].flags.kf_changeatable = 1;
|
341
|
+
kd->segmentCount = 1;
|
342
|
+
|
343
|
+
kd = insertKey(def, tableid, 1);
|
344
|
+
kd->segments[0].fieldNum = 1;
|
345
|
+
kd->segments[0].flags.kf_extend = 1;
|
346
|
+
kd->segments[0].flags.kf_changeatable = 1;
|
347
|
+
kd->segments[0].flags.kf_duplicatable = 1;
|
348
|
+
kd->segments[0].flags.kf_allseg_nullkey = 1;
|
349
|
+
kd->segmentCount = 1;
|
350
|
+
|
351
|
+
kd = insertKey(def, tableid, 2);
|
352
|
+
kd->segments[0].fieldNum = 1;
|
353
|
+
kd->segments[0].flags.kf_extend = 1;
|
354
|
+
kd->segments[0].flags.kf_changeatable = 1;
|
355
|
+
kd->segments[0].flags.kf_duplicatable = 1;
|
356
|
+
kd->segments[1].fieldNum = 2;
|
357
|
+
kd->segments[1].flags.kf_extend = 1;
|
358
|
+
kd->segments[1].flags.kf_changeatable = 1;
|
359
|
+
kd->segments[1].flags.kf_duplicatable = 1;
|
360
|
+
kd->segmentCount = 2;
|
361
|
+
updateTableDef(def, tableid);
|
362
|
+
return 0;
|
363
|
+
|
364
|
+
}
|
365
|
+
catch (bzs::rtl::exception& e)
|
366
|
+
{
|
367
|
+
_tprintf(_T("Error! %s\n"), (*getMsg(e)).c_str());
|
368
|
+
}
|
369
|
+
return 1;
|
370
|
+
}
|
371
|
+
|
372
|
+
short createTestNull(database* db)
|
373
|
+
{
|
374
|
+
try
|
375
|
+
{
|
376
|
+
dbdef* def = db->dbDef();
|
377
|
+
short tableid = 5;
|
378
|
+
|
379
|
+
insertTable(def, tableid, _T("nullvalue"), g_td_charsetIndex);
|
380
|
+
tabledef* td = def->tableDefs(tableid);
|
381
|
+
td->primaryKeyNum = 0;
|
382
|
+
|
383
|
+
short fieldnum = 0;
|
384
|
+
insertField(def, tableid, fieldnum, _T("id"), ft_autoinc, 4);
|
385
|
+
fielddef* fd = insertField(def, tableid, ++fieldnum, _T("id2"), ft_integer, 4);
|
386
|
+
fd->setNullable(true);
|
387
|
+
fd = insertField(def, tableid, ++fieldnum, _T("id3"), ft_integer, 4);
|
388
|
+
fd->setNullable(true);
|
389
|
+
fd = insertField(def, tableid, ++fieldnum, _T("name"), ft_myvarchar, 151);
|
390
|
+
fd->setLenByCharnum(50);
|
391
|
+
fd->setNullable(true);
|
392
|
+
|
393
|
+
keydef* kd = insertKey(def, tableid, 0);
|
394
|
+
kd->segments[0].fieldNum = 0;
|
395
|
+
kd->segments[0].flags.kf_extend = 1;
|
396
|
+
kd->segments[0].flags.kf_changeatable = 1;
|
397
|
+
kd->segmentCount = 1;
|
398
|
+
|
399
|
+
kd = insertKey(def, tableid, 1);
|
400
|
+
kd->segments[0].fieldNum = 1;
|
401
|
+
kd->segments[0].flags.kf_extend = 1;
|
402
|
+
kd->segments[0].flags.kf_changeatable = 1;
|
403
|
+
kd->segments[0].flags.kf_duplicatable = 1;
|
404
|
+
kd->segmentCount = 1;
|
405
|
+
|
406
|
+
kd = insertKey(def, tableid, 2);
|
407
|
+
kd->segments[0].fieldNum = 1;
|
408
|
+
kd->segments[0].flags.kf_extend = 1;
|
409
|
+
kd->segments[0].flags.kf_changeatable = 1;
|
410
|
+
kd->segments[0].flags.kf_duplicatable = 1;
|
411
|
+
kd->segments[1].fieldNum = 2;
|
412
|
+
kd->segments[1].flags.kf_extend = 1;
|
413
|
+
kd->segments[1].flags.kf_changeatable = 1;
|
414
|
+
kd->segments[1].flags.kf_duplicatable = 1;
|
415
|
+
kd->segmentCount = 2;
|
416
|
+
updateTableDef(def, tableid);
|
417
|
+
return 0;
|
418
|
+
}
|
419
|
+
catch (bzs::rtl::exception& e)
|
420
|
+
{
|
421
|
+
_tprintf(_T("Error! %s\n"), (*getMsg(e)).c_str());
|
422
|
+
}
|
423
|
+
return 1;
|
424
|
+
}
|
425
|
+
|
426
|
+
short createTestGroups(database* db)
|
427
|
+
{
|
428
|
+
try
|
429
|
+
{
|
430
|
+
dbdef* def = db->dbDef();
|
431
|
+
short tableid = 6;
|
432
|
+
|
433
|
+
insertTable(def, tableid, _T("groups"), g_td_charsetIndex);
|
434
|
+
tabledef* td = def->tableDefs(tableid);
|
435
|
+
td->primaryKeyNum = 0;
|
436
|
+
|
437
|
+
short fieldnum = 0;
|
438
|
+
insertField(def, tableid, fieldnum, _T("pri_id"), ft_autoinc, 4);
|
439
|
+
fielddef* fd = insertField(def, tableid, ++fieldnum, _T("id"), ft_integer, 4);
|
440
|
+
fd->setNullable(true);
|
441
|
+
fd = insertField(def, tableid, ++fieldnum, _T("name"), ft_myvarchar, 151);
|
442
|
+
fd->setLenByCharnum(50);
|
443
|
+
|
444
|
+
keydef* kd = insertKey(def, tableid, 0);
|
445
|
+
kd->segments[0].fieldNum = 0;
|
446
|
+
kd->segments[0].flags.kf_extend = 1;
|
447
|
+
kd->segments[0].flags.kf_changeatable = 1;
|
448
|
+
kd->segmentCount = 1;
|
449
|
+
|
450
|
+
kd = insertKey(def, tableid, 1);
|
451
|
+
kd->segments[0].fieldNum = 1;
|
452
|
+
kd->segments[0].flags.kf_extend = 1;
|
453
|
+
kd->segments[0].flags.kf_changeatable = 1;
|
454
|
+
kd->segments[0].flags.kf_duplicatable = 1;
|
455
|
+
kd->segmentCount = 1;
|
456
|
+
|
457
|
+
kd = insertKey(def, tableid, 2);
|
458
|
+
kd->segments[0].fieldNum = 0;
|
459
|
+
kd->segments[0].flags.kf_extend = 1;
|
460
|
+
kd->segments[0].flags.kf_changeatable = 1;
|
461
|
+
|
462
|
+
kd->segments[1].fieldNum = 1;
|
463
|
+
kd->segments[1].flags.kf_extend = 1;
|
464
|
+
kd->segments[1].flags.kf_changeatable = 1;
|
465
|
+
kd->segmentCount = 2;
|
466
|
+
updateTableDef(def, tableid);
|
467
|
+
return 0;
|
468
|
+
}
|
469
|
+
catch (bzs::rtl::exception& e)
|
470
|
+
{
|
471
|
+
_tprintf(_T("Error! %s\n"), (*getMsg(e)).c_str());
|
472
|
+
}
|
473
|
+
return 1;
|
474
|
+
}
|
475
|
+
|
476
|
+
short createTestUsers(database* db)
|
477
|
+
{
|
478
|
+
try
|
479
|
+
{
|
480
|
+
dbdef* def = db->dbDef();
|
481
|
+
short tableid = 7;
|
482
|
+
|
483
|
+
insertTable(def, tableid, _T("users"), g_td_charsetIndex);
|
484
|
+
tabledef* td = def->tableDefs(tableid);
|
485
|
+
td->primaryKeyNum = 0;
|
486
|
+
|
487
|
+
short fieldnum = 0;
|
488
|
+
insertField(def, tableid, fieldnum, _T("id"), ft_autoinc, 4);
|
489
|
+
fielddef* fd = insertField(def, tableid, ++fieldnum, _T("group"), ft_integer, 4);
|
490
|
+
fd->setNullable(true);
|
491
|
+
fd = insertField(def, tableid, ++fieldnum, _T("class"), ft_integer, 4);
|
492
|
+
fd->setNullable(true);
|
493
|
+
fd = insertField(def, tableid, ++fieldnum, _T("name"), ft_myvarchar, 151);
|
494
|
+
fd->setLenByCharnum(50);
|
495
|
+
|
496
|
+
keydef* kd = insertKey(def, tableid, 0);
|
497
|
+
kd->segments[0].fieldNum = 0;
|
498
|
+
kd->segments[0].flags.kf_extend = 1;
|
499
|
+
kd->segments[0].flags.kf_changeatable = 1;
|
500
|
+
kd->segmentCount = 1;
|
501
|
+
|
502
|
+
kd = insertKey(def, tableid, 1);
|
503
|
+
kd->segments[0].fieldNum = 1;
|
504
|
+
kd->segments[0].flags.kf_extend = 1;
|
505
|
+
kd->segments[0].flags.kf_changeatable = 1;
|
506
|
+
kd->segments[0].flags.kf_duplicatable = 1;
|
507
|
+
kd->segmentCount = 1;
|
508
|
+
updateTableDef(def, tableid);
|
509
|
+
return 0;
|
510
|
+
}
|
511
|
+
catch (bzs::rtl::exception& e)
|
512
|
+
{
|
513
|
+
_tprintf(_T("Error! %s\n"), (*getMsg(e)).c_str());
|
514
|
+
}
|
515
|
+
return 1;
|
516
|
+
}
|
517
|
+
|
518
|
+
short createTestScores(database* db)
|
519
|
+
{
|
520
|
+
try
|
521
|
+
{
|
522
|
+
dbdef* def = db->dbDef();
|
523
|
+
short tableid = 8;
|
524
|
+
|
525
|
+
insertTable(def, tableid, _T("scores"), g_td_charsetIndex);
|
526
|
+
tabledef* td = def->tableDefs(tableid);
|
527
|
+
td->primaryKeyNum = 0;
|
528
|
+
|
529
|
+
short fieldnum = 0;
|
530
|
+
fielddef* fd = insertField(def, tableid, fieldnum, _T("id"), ft_autoinc, 4);
|
531
|
+
fd = insertField(def, tableid, ++fieldnum, _T("subject"), ft_integer, 4);
|
532
|
+
fd = insertField(def, tableid, ++fieldnum, _T("score"), ft_integer, 4);
|
533
|
+
fd->setNullable(true);
|
534
|
+
|
535
|
+
keydef* kd = insertKey(def, tableid, 0);
|
536
|
+
kd->segments[0].fieldNum = 0;
|
537
|
+
kd->segments[0].flags.kf_extend = 1;
|
538
|
+
kd->segments[0].flags.kf_changeatable = 1;
|
539
|
+
kd->segmentCount = 1;
|
540
|
+
updateTableDef(def, tableid);
|
541
|
+
return 0;
|
542
|
+
}
|
543
|
+
catch (bzs::rtl::exception& e)
|
544
|
+
{
|
545
|
+
_tprintf(_T("Error! %s\n"), (*getMsg(e)).c_str());
|
546
|
+
}
|
547
|
+
return 1;
|
548
|
+
}
|
549
|
+
|
550
|
+
#define exec_sql createTable //exec sql for no result recordset. like a createTable.
|
551
|
+
|
552
|
+
class fixtureFieldStore
|
553
|
+
{
|
554
|
+
mutable database* m_db;
|
555
|
+
btrVersion ver;
|
556
|
+
|
557
|
+
public:
|
558
|
+
fixtureFieldStore() : m_db(NULL)
|
559
|
+
{
|
560
|
+
nsdatabase::setCheckTablePtr(true);
|
561
|
+
m_db = database::create();
|
562
|
+
if (!m_db)
|
563
|
+
printf("Error database::create()\n");
|
564
|
+
short ret = createFieldStoreDataBase(m_db);
|
565
|
+
if (ret)
|
566
|
+
{
|
567
|
+
printf("Error createDataBase\n");
|
568
|
+
return;
|
569
|
+
}else
|
570
|
+
{
|
571
|
+
ret = createTestTable1(m_db);
|
572
|
+
if (ret == 0)
|
573
|
+
{
|
574
|
+
btrVersions vs;
|
575
|
+
m_db->getBtrVersion(&vs);
|
576
|
+
if (m_db->stat())
|
577
|
+
{
|
578
|
+
printf("Error getBtrVersion\n");
|
579
|
+
return;
|
580
|
+
}
|
581
|
+
ver = vs.versions[1];
|
582
|
+
|
583
|
+
if (ret == 0)
|
584
|
+
{ if (isLegacyTimeFormat())
|
585
|
+
ret = createTestTableLegacyTimeTable(m_db);
|
586
|
+
else
|
587
|
+
ret = createTestTableTime(m_db, ver.isMariaDB(), (uchar_td)ver.minorVersion,
|
588
|
+
isSupportMultiTimeStamp());
|
589
|
+
if (ret == 0)
|
590
|
+
ret = createTestTableHA_OPTION_PACK_RECORD(m_db);
|
591
|
+
if (ret == 0)
|
592
|
+
ret = createTestInMany(m_db);
|
593
|
+
if (ret == 0)
|
594
|
+
ret = createTestNull(m_db);
|
595
|
+
if (ret == 0)
|
596
|
+
ret = createTestGroups(m_db);
|
597
|
+
if (ret == 0)
|
598
|
+
ret = createTestUsers(m_db);
|
599
|
+
if (ret == 0)
|
600
|
+
ret = createTestScores(m_db);
|
601
|
+
|
602
|
+
if (ret == 0)
|
603
|
+
m_db->open(makeUri(PROTOCOL, HOSTNAME, DBNAMEV3, BDFNAME), TYPE_SCHEMA_BDF,TD_OPEN_NORMAL);
|
604
|
+
if (m_db->stat() == 0)
|
605
|
+
{
|
606
|
+
m_db->createTable(sql); // This table is not listed in test.bdf
|
607
|
+
if (m_db->stat() == 0)
|
608
|
+
m_db->exec_sql(test_records);
|
609
|
+
}
|
610
|
+
}
|
611
|
+
}
|
612
|
+
ret = m_db->stat();
|
613
|
+
}
|
614
|
+
if (ret)
|
615
|
+
printf("Error createTable\n");
|
616
|
+
}
|
617
|
+
|
618
|
+
~fixtureFieldStore()
|
619
|
+
{
|
620
|
+
if (m_db)
|
621
|
+
m_db->release();
|
622
|
+
}
|
623
|
+
::database* db() const { return m_db; }
|
624
|
+
|
625
|
+
bool isMysql56TimeFormat() const { return ver.isMysql56TimeFormat(); }
|
626
|
+
bool isLegacyTimeFormat() const{ return ver.isFullLegacyTimeFormat(); }
|
627
|
+
bool isSupportMultiTimeStamp() const { return ver.isSupportMultiTimeStamp(); }
|
628
|
+
};
|
629
|
+
#define TEST_DATE _T("2015-11-10")
|
630
|
+
#define TEST_DATEA "2015-11-10"
|
631
|
+
|
632
|
+
void testModeMacro()
|
633
|
+
{
|
634
|
+
short mode = TD_OPEN_READONLY_EXCLUSIVE + TD_OPEN_MASK_MYSQL_NULL + TD_OPEN_MASK_GETSHCHEMA;
|
635
|
+
BOOST_CHECK_MESSAGE(IS_MODE_READONLY(mode) == true, "IS_MODE_READONLY ");
|
636
|
+
BOOST_CHECK_MESSAGE(IS_MODE_EXCLUSIVE(mode) == true, "IS_MODE_EXCLUSIVE ");
|
637
|
+
BOOST_CHECK_MESSAGE(IS_MODE_MYSQL_NULL(mode) == true, "IS_MODE_MYSQL_NULL ");
|
638
|
+
BOOST_CHECK_MESSAGE(IS_MODE_GETSCHEMA(mode) == true, "IS_MODE_GETSCHEMA ");
|
639
|
+
|
640
|
+
mode = 0;
|
641
|
+
BOOST_CHECK_MESSAGE(IS_MODE_READONLY(mode) == false, "IS_MODE_READONLY false");
|
642
|
+
BOOST_CHECK_MESSAGE(IS_MODE_EXCLUSIVE(mode) == false, "IS_MODE_EXCLUSIVE false");
|
643
|
+
BOOST_CHECK_MESSAGE(IS_MODE_MYSQL_NULL(mode) == false, "IS_MODE_MYSQL_NULL false");
|
644
|
+
BOOST_CHECK_MESSAGE(IS_MODE_GETSCHEMA(mode) == false, "IS_MODE_GETSCHEMA false");
|
645
|
+
}
|
646
|
+
#pragma warning(disable : 4996)
|
647
|
+
|
648
|
+
#define MINT_MIN -8388608
|
649
|
+
#define UMINT_MAX 16777215
|
650
|
+
#define FLOAT_V1 -1234.0f
|
651
|
+
#define FLOAT_V2 1234.1234f
|
652
|
+
|
653
|
+
#define DOUBLE_V1 (double)-12345678.0
|
654
|
+
#define DOUBLE_V2 (double)0.1234567890123
|
655
|
+
|
656
|
+
#define DEC_V1 (double)1234567890.12345
|
657
|
+
#define DEC_V1LL 1234567890LL
|
658
|
+
|
659
|
+
#define DEC_V2 (double)5.0000010000500001
|
660
|
+
#define DEC_V2LL 5LL
|
661
|
+
#define DEC_V2SA "5.000001000050000100000000000000"
|
662
|
+
#define DEC_V2S _T(DEC_V2SA)
|
663
|
+
|
664
|
+
#define DEC_V3 (double)3.0
|
665
|
+
#define DEC_V3LL 3LL
|
666
|
+
|
667
|
+
#define DEC_V4 (double)0.23456789010
|
668
|
+
#define DEC_V4LL 0LL
|
669
|
+
|
670
|
+
#define DEC_V5 (double)-1234567890.12345
|
671
|
+
#define DEC_V5LL -1234567890LL
|
672
|
+
|
673
|
+
#define DEC_V6 (double)-5.0000010000500001
|
674
|
+
#define DEC_V6LL -5LL
|
675
|
+
#define DEC_V6SA "-5.000001000050000100000000000000"
|
676
|
+
#define DEC_V6S _T(DEC_V6SA)
|
677
|
+
|
678
|
+
#define DEC_V7 (double)-3.0
|
679
|
+
#define DEC_V7LL -3LL
|
680
|
+
|
681
|
+
#define DEC_V8 (double)-0.23456789010
|
682
|
+
#define DEC_V8LL -0LL
|
683
|
+
|
684
|
+
void checkIntValue(table_ptr tb)
|
685
|
+
{
|
686
|
+
short fieldnum = 0;
|
687
|
+
// read by int64
|
688
|
+
BOOST_CHECK(tb->getFVbyt(++fieldnum) == SCHAR_MAX);
|
689
|
+
BOOST_CHECK(tb->getFVsht(++fieldnum) == SHRT_MAX);
|
690
|
+
BOOST_CHECK(tb->getFVint(++fieldnum) == MINT_MIN);
|
691
|
+
BOOST_CHECK(tb->getFVint(++fieldnum) == INT_MAX);
|
692
|
+
BOOST_CHECK(tb->getFV64(++fieldnum) == LLONG_MAX);
|
693
|
+
|
694
|
+
BOOST_CHECK(tb->getFVsht(++fieldnum) == UCHAR_MAX - 1);
|
695
|
+
BOOST_CHECK(tb->getFVint(++fieldnum) == USHRT_MAX - 1);
|
696
|
+
BOOST_CHECK(tb->getFVint(++fieldnum) == UMINT_MAX - 1);
|
697
|
+
BOOST_CHECK(tb->getFV64(++fieldnum) == UINT_MAX - 1);
|
698
|
+
BOOST_CHECK((unsigned __int64)tb->getFV64(++fieldnum) == ULLONG_MAX - 1);
|
699
|
+
|
700
|
+
BOOST_CHECK(tb->getFVsht(++fieldnum) == 2000);
|
701
|
+
BOOST_CHECK(tb->getFVbyt(++fieldnum) == 254); //logi1
|
702
|
+
BOOST_CHECK(tb->getFVint(++fieldnum) == 65000); //logi2
|
703
|
+
myDate d;
|
704
|
+
d = TEST_DATE;
|
705
|
+
BOOST_CHECK(tb->getFVint(++fieldnum) == d.i); //date
|
706
|
+
|
707
|
+
BOOST_CHECK(tb->getFVint(++fieldnum) == FLOAT_V1); //double
|
708
|
+
++fieldnum;//BOOST_CHECK(tb->getFVint(++fieldnum) == FLOAT_V2);
|
709
|
+
BOOST_CHECK(tb->getFV64(++fieldnum) == DOUBLE_V1);
|
710
|
+
++fieldnum;
|
711
|
+
BOOST_CHECK(tb->getFV64(++fieldnum) == DEC_V1LL); //decimal
|
712
|
+
BOOST_CHECK(tb->getFV64(++fieldnum) == DEC_V2LL); //decimal
|
713
|
+
BOOST_CHECK(tb->getFV64(++fieldnum) == DEC_V3LL); //decimal
|
714
|
+
BOOST_CHECK(tb->getFV64(++fieldnum) == DEC_V4LL); //decimal
|
715
|
+
BOOST_CHECK(tb->getFV64(++fieldnum) == DEC_V5LL); //decimal
|
716
|
+
BOOST_CHECK(tb->getFV64(++fieldnum) == DEC_V6LL); //decimal
|
717
|
+
BOOST_CHECK(tb->getFV64(++fieldnum) == DEC_V7LL); //decimal
|
718
|
+
BOOST_CHECK(tb->getFV64(++fieldnum) == DEC_V8LL); //decimal
|
719
|
+
|
720
|
+
|
721
|
+
// read by double
|
722
|
+
BOOST_CHECK(tb->getFVdbl(1) == SCHAR_MAX);
|
723
|
+
BOOST_CHECK(tb->getFVdbl(3) == MINT_MIN);
|
724
|
+
double v = tb->getFVdbl(5);
|
725
|
+
BOOST_CHECK(v == ((double)LLONG_MAX));
|
726
|
+
BOOST_CHECK(tb->getFVdbl(6) == UCHAR_MAX - 1);
|
727
|
+
BOOST_CHECK(tb->getFVdbl(8) == UMINT_MAX - 1);
|
728
|
+
fieldnum = 9;
|
729
|
+
v = tb->getFVdbl(++fieldnum);
|
730
|
+
BOOST_CHECK(v == ((double)ULLONG_MAX - 1));
|
731
|
+
BOOST_CHECK(tb->getFVdbl(++fieldnum) == 2000);
|
732
|
+
BOOST_CHECK(tb->getFVdbl(++fieldnum) == 254); //logi1
|
733
|
+
BOOST_CHECK(tb->getFVdbl(++fieldnum) == 65000); //logi2
|
734
|
+
BOOST_CHECK(tb->getFVdbl(++fieldnum) == (double)d.i); //date
|
735
|
+
|
736
|
+
float f = tb->getFVflt(++fieldnum);
|
737
|
+
BOOST_CHECK(f == FLOAT_V1); //double
|
738
|
+
f = tb->getFVflt(++fieldnum);
|
739
|
+
BOOST_CHECK(f == FLOAT_V2);
|
740
|
+
v = tb->getFVdbl(++fieldnum);
|
741
|
+
BOOST_CHECK(v == DOUBLE_V1);
|
742
|
+
v = tb->getFVdbl(++fieldnum);
|
743
|
+
if (DOUBLE_V2 > v)
|
744
|
+
v = DOUBLE_V2 - v;
|
745
|
+
else
|
746
|
+
v = v - DOUBLE_V2;
|
747
|
+
|
748
|
+
BOOST_CHECK(v < 0.000000001f);
|
749
|
+
|
750
|
+
//decimal
|
751
|
+
BOOST_CHECK(tb->getFVdbl(++fieldnum) == DEC_V1);
|
752
|
+
BOOST_CHECK(tb->getFVdbl(++fieldnum) == DEC_V2);
|
753
|
+
BOOST_CHECK(tb->getFVdbl(++fieldnum) == DEC_V3);
|
754
|
+
BOOST_CHECK(tb->getFVdbl(++fieldnum) == DEC_V4);
|
755
|
+
BOOST_CHECK(tb->getFVdbl(++fieldnum) == DEC_V5);
|
756
|
+
BOOST_CHECK(tb->getFVdbl(++fieldnum) == DEC_V6);
|
757
|
+
BOOST_CHECK(tb->getFVdbl(++fieldnum) == DEC_V7);
|
758
|
+
BOOST_CHECK(tb->getFVdbl(++fieldnum) == DEC_V8);
|
759
|
+
|
760
|
+
//read by string
|
761
|
+
_TCHAR buf[50];
|
762
|
+
BOOST_CHECK(_tcscmp(tb->getFVstr(1), _ltot(SCHAR_MAX, buf, 10)) == 0);
|
763
|
+
BOOST_CHECK(_tcscmp(tb->getFVstr(3), _ltot(MINT_MIN, buf, 10)) == 0);
|
764
|
+
_i64tot_s(LLONG_MAX, buf, 50, 10);
|
765
|
+
BOOST_CHECK(_tcscmp(tb->getFVstr(5), buf) == 0);
|
766
|
+
BOOST_CHECK(_tcscmp(tb->getFVstr(6), _ultot(UCHAR_MAX - 1, buf, 10)) == 0);
|
767
|
+
BOOST_CHECK(_tcscmp(tb->getFVstr(8), _ultot(UMINT_MAX - 1, buf, 10)) == 0);
|
768
|
+
fieldnum = 9;
|
769
|
+
_ui64tot_s(ULLONG_MAX - 1, buf, 50, 10);
|
770
|
+
BOOST_CHECK(_tcscmp(tb->getFVstr(++fieldnum), buf) == 0);
|
771
|
+
BOOST_CHECK(_tcscmp(tb->getFVstr(++fieldnum), _ltot(2000, buf, 10)) == 0);
|
772
|
+
BOOST_CHECK(_tcscmp(tb->getFVstr(++fieldnum), _ltot(254, buf, 10)) == 0); //logi1
|
773
|
+
BOOST_CHECK(_tcscmp(tb->getFVstr(++fieldnum), _ltot(65000, buf, 10)) == 0); //logi2
|
774
|
+
BOOST_CHECK(_tcscmp(tb->getFVstr(++fieldnum), TEST_DATE) == 0); //date
|
775
|
+
|
776
|
+
_TCHAR tmp[64];
|
777
|
+
_stprintf(tmp, _T("%0.0f"), FLOAT_V1);
|
778
|
+
BOOST_CHECK(_tcscmp(tb->getFVstr(++fieldnum), tmp) == 0); //double
|
779
|
+
_stprintf(tmp, _T("%0.4f"), FLOAT_V2);
|
780
|
+
BOOST_CHECK(_tcscmp(tb->getFVstr(++fieldnum), tmp) == 0); //double
|
781
|
+
_stprintf(tmp, _T("%0.0f"), DOUBLE_V1);
|
782
|
+
BOOST_CHECK(_tcscmp(tb->getFVstr(++fieldnum), tmp) == 0); //double
|
783
|
+
_stprintf(tmp, _T("%0.15lf"), DOUBLE_V2);
|
784
|
+
BOOST_CHECK(_tcscmp(tb->getFVstr(++fieldnum), tmp) == 0); //double
|
785
|
+
|
786
|
+
_stprintf(tmp, _T("%0.5lf"), DEC_V1);
|
787
|
+
BOOST_CHECK(_tcscmp(tb->getFVstr(++fieldnum), tmp) == 0); //decimal
|
788
|
+
_stprintf(tmp, _T("%s"), DEC_V2S);
|
789
|
+
BOOST_CHECK(_tcscmp(tb->getFVstr(++fieldnum), tmp) == 0); //decimal
|
790
|
+
_stprintf(tmp, _T("%0.0lf"), DEC_V3);
|
791
|
+
BOOST_CHECK(_tcscmp(tb->getFVstr(++fieldnum), tmp) == 0); //decimal
|
792
|
+
_stprintf(tmp, _T("%0.11lf"), DEC_V4);
|
793
|
+
BOOST_CHECK(_tcscmp(tb->getFVstr(++fieldnum), tmp) == 0); //decimal
|
794
|
+
|
795
|
+
_stprintf(tmp, _T("%0.5lf"), DEC_V5);
|
796
|
+
BOOST_CHECK(_tcscmp(tb->getFVstr(++fieldnum), tmp) == 0); //decimal
|
797
|
+
_stprintf(tmp, _T("%s"), DEC_V6S);
|
798
|
+
BOOST_CHECK(_tcscmp(tb->getFVstr(++fieldnum), tmp) == 0); //decimal
|
799
|
+
_stprintf(tmp, _T("%0.0lf"), DEC_V7);
|
800
|
+
BOOST_CHECK(_tcscmp(tb->getFVstr(++fieldnum), tmp) == 0); //decimal
|
801
|
+
_stprintf(tmp, _T("%0.11lf"), DEC_V8);
|
802
|
+
BOOST_CHECK(_tcscmp(tb->getFVstr(++fieldnum), tmp) == 0); //decimal
|
803
|
+
|
804
|
+
}
|
805
|
+
|
806
|
+
void testStoreInt(database* db)
|
807
|
+
{
|
808
|
+
short tableid = 1;
|
809
|
+
short fieldnum = 0;
|
810
|
+
table_ptr tb = openTable(db, tableid, TD_OPEN_NORMAL);
|
811
|
+
|
812
|
+
//int64 store
|
813
|
+
tb->clearBuffer();
|
814
|
+
tb->setFV(_T("id"), 1);
|
815
|
+
|
816
|
+
tb->setFV(++fieldnum, (short)SCHAR_MAX);
|
817
|
+
tb->setFV(++fieldnum, (short)SHRT_MAX);
|
818
|
+
tb->setFV(++fieldnum, (int)MINT_MIN);
|
819
|
+
|
820
|
+
BOOST_CHECK(tb->getFVint(++fieldnum) == INT_MIN);// check default value
|
821
|
+
tb->setFV(fieldnum, (int)INT_MAX);
|
822
|
+
BOOST_CHECK(tb->getFV64(++fieldnum) == LLONG_MIN);// check default value
|
823
|
+
tb->setFV(fieldnum, (__int64)LLONG_MAX);
|
824
|
+
|
825
|
+
tb->setFV(++fieldnum, (short)(UCHAR_MAX - 1));
|
826
|
+
tb->setFV(++fieldnum, (int)(USHRT_MAX - 1));
|
827
|
+
tb->setFV(++fieldnum, (int)(UMINT_MAX - 1));
|
828
|
+
BOOST_CHECK(tb->getFV64(++fieldnum) == UINT_MAX);// check default value
|
829
|
+
tb->setFV(fieldnum, (__int64)(UINT_MAX - 1));
|
830
|
+
BOOST_CHECK((unsigned __int64)tb->getFV64(++fieldnum) == ULLONG_MAX);// check default value
|
831
|
+
tb->setFV(fieldnum, (__int64)(ULLONG_MAX - 1));
|
832
|
+
tb->setFV(++fieldnum, 2000);
|
833
|
+
tb->setFV(++fieldnum, 254); //logi1
|
834
|
+
tb->setFV(++fieldnum, (int)65000); //logi2
|
835
|
+
myDate d; d = TEST_DATE;
|
836
|
+
tb->setFV(++fieldnum, d.i);
|
837
|
+
tb->setFV(++fieldnum, (int)FLOAT_V1);
|
838
|
+
tb->setFV(++fieldnum, FLOAT_V2);
|
839
|
+
tb->setFV(++fieldnum, (__int64)DOUBLE_V1);
|
840
|
+
tb->setFV(++fieldnum, DOUBLE_V2);
|
841
|
+
tb->setFV(++fieldnum, DEC_V1);
|
842
|
+
tb->setFV(++fieldnum, DEC_V2S);
|
843
|
+
tb->setFV(++fieldnum, DEC_V3);
|
844
|
+
tb->setFV(++fieldnum, DEC_V4);
|
845
|
+
tb->setFV(++fieldnum, DEC_V5);
|
846
|
+
tb->setFV(++fieldnum, DEC_V6S);
|
847
|
+
tb->setFV(++fieldnum, DEC_V7);
|
848
|
+
tb->setFV(++fieldnum, DEC_V8);
|
849
|
+
tb->insert();
|
850
|
+
|
851
|
+
tb->clearBuffer();
|
852
|
+
tb->setFV(_T("id"), 1);
|
853
|
+
tb->seek();
|
854
|
+
BOOST_CHECK(tb->stat() == 0);
|
855
|
+
checkIntValue(tb);
|
856
|
+
|
857
|
+
// char* or wchar* store
|
858
|
+
tb->clearBuffer();
|
859
|
+
tb->setFV(_T("id"), 2);
|
860
|
+
_TCHAR buf[50];
|
861
|
+
fieldnum = 0;
|
862
|
+
tb->setFV(++fieldnum, _ltot(SCHAR_MAX, buf, 10));
|
863
|
+
tb->setFV(++fieldnum, _ltot(SHRT_MAX, buf, 10));
|
864
|
+
tb->setFV(++fieldnum, _ltot(MINT_MIN, buf, 10));
|
865
|
+
tb->setFV(++fieldnum, _ltot(INT_MAX, buf, 10));
|
866
|
+
_i64tot_s(LLONG_MAX, buf, 50, 10);
|
867
|
+
tb->setFV(++fieldnum, buf);
|
868
|
+
|
869
|
+
tb->setFV(++fieldnum, _ltot(UCHAR_MAX - 1, buf, 10));
|
870
|
+
tb->setFV(++fieldnum, _ltot(USHRT_MAX - 1, buf, 10));
|
871
|
+
tb->setFV(++fieldnum, _ltot(UMINT_MAX - 1, buf, 10));
|
872
|
+
tb->setFV(++fieldnum, _ultot(UINT_MAX - 1, buf, 10));
|
873
|
+
_ui64tot_s(ULLONG_MAX - 1, buf, 50, 10);
|
874
|
+
tb->setFV(++fieldnum, buf);
|
875
|
+
tb->setFV(++fieldnum, _ltot(2000, buf, 10));
|
876
|
+
tb->setFV(++fieldnum, _ltot(254, buf, 10)); //logi1
|
877
|
+
tb->setFV(++fieldnum, _ltot(65000, buf, 10)); //logi2
|
878
|
+
tb->setFV(++fieldnum, TEST_DATE);
|
879
|
+
|
880
|
+
_stprintf(buf, _T("%.0f"), FLOAT_V1);
|
881
|
+
tb->setFV(++fieldnum, buf);
|
882
|
+
_stprintf(buf, _T("%.4f"), FLOAT_V2);
|
883
|
+
tb->setFV(++fieldnum, buf);
|
884
|
+
_stprintf(buf, _T("%.0lf"), DOUBLE_V1);
|
885
|
+
tb->setFV(++fieldnum, buf);
|
886
|
+
_stprintf(buf, _T("%.20lf"), DOUBLE_V2);
|
887
|
+
tb->setFV(++fieldnum, buf);
|
888
|
+
_stprintf(buf, _T("%.5lf"), DEC_V1);
|
889
|
+
tb->setFV(++fieldnum, buf);
|
890
|
+
#if (__BCPLUSPLUS__)
|
891
|
+
tb->setFV(++fieldnum, DEC_V2S);
|
892
|
+
#else
|
893
|
+
_stprintf(buf, _T("%.16lf"), DEC_V2);
|
894
|
+
tb->setFV(++fieldnum, buf);
|
895
|
+
#endif
|
896
|
+
_stprintf(buf, _T("%.1lf"), DEC_V3);
|
897
|
+
tb->setFV(++fieldnum, buf);
|
898
|
+
_stprintf(buf, _T("%.11lf"), DEC_V4);
|
899
|
+
tb->setFV(++fieldnum, buf);
|
900
|
+
_stprintf(buf, _T("%.5lf"), DEC_V5);
|
901
|
+
tb->setFV(++fieldnum, buf);
|
902
|
+
#if (__BCPLUSPLUS__)
|
903
|
+
tb->setFV(++fieldnum, DEC_V6S);
|
904
|
+
#else
|
905
|
+
_stprintf(buf, _T("%.16lf"), DEC_V6);
|
906
|
+
tb->setFV(++fieldnum, buf);
|
907
|
+
#endif
|
908
|
+
_stprintf(buf, _T("%.1lf"), DEC_V7);
|
909
|
+
tb->setFV(++fieldnum, buf);
|
910
|
+
_stprintf(buf, _T("%.11lf"), DEC_V8);
|
911
|
+
tb->setFV(++fieldnum, buf);
|
912
|
+
|
913
|
+
tb->insert();
|
914
|
+
|
915
|
+
tb->clearBuffer();
|
916
|
+
tb->setFV(_T("id"), 2);
|
917
|
+
tb->seek();
|
918
|
+
BOOST_CHECK(tb->stat() == 0);
|
919
|
+
checkIntValue(tb);
|
920
|
+
|
921
|
+
// double store
|
922
|
+
tb->clearBuffer();
|
923
|
+
tb->setFV(_T("id"), 3);
|
924
|
+
fieldnum = 0;
|
925
|
+
tb->setFV(++fieldnum, (double)SCHAR_MAX);
|
926
|
+
tb->setFV(++fieldnum, (double)SHRT_MAX);
|
927
|
+
tb->setFV(++fieldnum, (double)MINT_MIN);
|
928
|
+
tb->setFV(++fieldnum, (double)INT_MAX);
|
929
|
+
// LLONG_MAX double store not support, because happen truncation
|
930
|
+
//tb->setFV(++fieldnum, (double)LLONG_MAX);
|
931
|
+
tb->setFV(++fieldnum, (__int64)LLONG_MAX);
|
932
|
+
tb->setFV(++fieldnum, (double)(UCHAR_MAX - 1));
|
933
|
+
tb->setFV(++fieldnum, (double)(USHRT_MAX - 1));
|
934
|
+
tb->setFV(++fieldnum, (double)(UMINT_MAX - 1));
|
935
|
+
tb->setFV(++fieldnum, (double)(UINT_MAX - 1));
|
936
|
+
//tb->setFV(++fieldnum, (double)(ULLONG_MAX - 1));
|
937
|
+
tb->setFV(++fieldnum, (__int64)(ULLONG_MAX - 1));
|
938
|
+
tb->setFV(++fieldnum, (double)2000);
|
939
|
+
tb->setFV(++fieldnum, (double)254); //logi1
|
940
|
+
tb->setFV(++fieldnum, (double)65000); //logi2
|
941
|
+
tb->setFV(++fieldnum, (double)d.i);
|
942
|
+
tb->setFV(++fieldnum, FLOAT_V1);
|
943
|
+
tb->setFV(++fieldnum, FLOAT_V2);
|
944
|
+
tb->setFV(++fieldnum, DOUBLE_V1);
|
945
|
+
tb->setFV(++fieldnum, DOUBLE_V2);
|
946
|
+
tb->setFV(++fieldnum, DEC_V1);
|
947
|
+
tb->setFV(++fieldnum, DEC_V2S);
|
948
|
+
tb->setFV(++fieldnum, DEC_V3);
|
949
|
+
tb->setFV(++fieldnum, DEC_V4);
|
950
|
+
tb->setFV(++fieldnum, DEC_V5);
|
951
|
+
tb->setFV(++fieldnum, DEC_V6S);
|
952
|
+
tb->setFV(++fieldnum, DEC_V7);
|
953
|
+
tb->setFV(++fieldnum, DEC_V8);
|
954
|
+
tb->insert();
|
955
|
+
|
956
|
+
tb->clearBuffer();
|
957
|
+
tb->setFV(_T("id"), 3);
|
958
|
+
tb->seek();
|
959
|
+
BOOST_CHECK(tb->stat() == 0);
|
960
|
+
checkIntValue(tb);
|
961
|
+
|
962
|
+
|
963
|
+
// cleanup id 3
|
964
|
+
tb->clearBuffer();
|
965
|
+
tb->setFV(_T("id"), 3);
|
966
|
+
tb->update();
|
967
|
+
BOOST_CHECK(tb->stat() == 0);
|
968
|
+
|
969
|
+
char buf2[50];
|
970
|
+
std::string values;
|
971
|
+
values += "1\t";
|
972
|
+
values += _ltoa(SCHAR_MAX, buf2, 10);
|
973
|
+
values += "\t2\t";
|
974
|
+
values += _ltoa(SHRT_MAX, buf2, 10);
|
975
|
+
values += "\t3\t";
|
976
|
+
values += _ltoa(MINT_MIN, buf2, 10);
|
977
|
+
values += "\t4\t";
|
978
|
+
values += _ltoa(INT_MAX, buf2, 10);
|
979
|
+
values += "\t5\t";
|
980
|
+
_i64toa_s(LLONG_MAX, buf2, 50, 10);
|
981
|
+
values += buf2;
|
982
|
+
values += "\t6\t";
|
983
|
+
values += _ltoa(UCHAR_MAX - 1, buf2, 10);
|
984
|
+
values += "\t7\t";
|
985
|
+
values += _ltoa(USHRT_MAX - 1, buf2, 10);
|
986
|
+
values += "\t8\t";
|
987
|
+
values += _ltoa(UMINT_MAX - 1, buf2, 10);
|
988
|
+
values += "\t9\t";
|
989
|
+
_i64toa_s(UINT_MAX - 1, buf2, 50, 10);
|
990
|
+
values += buf2;
|
991
|
+
values += "\t10\t";
|
992
|
+
_ui64toa_s(ULLONG_MAX - 1, buf2, 50, 10);
|
993
|
+
values += buf2;
|
994
|
+
values += "\t11\t";
|
995
|
+
values += _ltoa(2000, buf2, 10);
|
996
|
+
values += "\t12\t";
|
997
|
+
values += _ltoa(254, buf2, 10);
|
998
|
+
values += "\t13\t";
|
999
|
+
values += _ltoa(65000, buf2, 10);
|
1000
|
+
values += "\t14\t";
|
1001
|
+
values += TEST_DATEA;
|
1002
|
+
values += "\t15\t";sprintf_s(buf2, 50, "%.0f", FLOAT_V1);
|
1003
|
+
values += buf2;
|
1004
|
+
values += "\t16\t";sprintf_s(buf2, 50, "%.4f", FLOAT_V2);
|
1005
|
+
values += buf2;
|
1006
|
+
values += "\t17\t";sprintf_s(buf2, 50, "%.0lf", DOUBLE_V1);
|
1007
|
+
values += buf2;
|
1008
|
+
values += "\t18\t";sprintf_s(buf2, 50, "%.20lf", DOUBLE_V2);
|
1009
|
+
values += buf2;
|
1010
|
+
values += "\t19\t";sprintf_s(buf2, 50, "%.5lf", DEC_V1);
|
1011
|
+
values += buf2;
|
1012
|
+
values += "\t20\t";
|
1013
|
+
values += DEC_V2SA;
|
1014
|
+
values += "\t21\t";sprintf_s(buf2, 50, "%.1lf", DEC_V3);
|
1015
|
+
values += buf2;
|
1016
|
+
values += "\t22\t";sprintf_s(buf2, 50, "%.11lf", DEC_V4);
|
1017
|
+
values += buf2;
|
1018
|
+
values += "\t23\t";sprintf_s(buf2, 50, "%.5lf", DEC_V5);
|
1019
|
+
values += buf2;
|
1020
|
+
values += "\t24\t";
|
1021
|
+
values += DEC_V6SA;
|
1022
|
+
values += "\t25\t";sprintf_s(buf2, 50, "%.1lf", DEC_V7);
|
1023
|
+
values += buf2;
|
1024
|
+
values += "\t26\t";sprintf_s(buf2, 50, "%.11lf", DEC_V8);
|
1025
|
+
values += buf2;
|
1026
|
+
|
1027
|
+
|
1028
|
+
tb->test_store(values.c_str());
|
1029
|
+
BOOST_CHECK(tb->stat() == 0);
|
1030
|
+
tb->clearBuffer();
|
1031
|
+
tb->setFV(_T("id"), 3);
|
1032
|
+
tb->seek();
|
1033
|
+
BOOST_CHECK(tb->stat() == 0);
|
1034
|
+
checkIntValue(tb);
|
1035
|
+
}
|
1036
|
+
|
1037
|
+
#define TEST_TIME0 _T("23:41:12")
|
1038
|
+
#define TEST_TIME0A "23:41:12"
|
1039
|
+
|
1040
|
+
#define TEST_DATETIME0 _T("2015-11-09 12:31:56")
|
1041
|
+
#define TEST_DATETIME0A "2015-11-09 12:31:56"
|
1042
|
+
|
1043
|
+
const _TCHAR* TEST_TIME[7] = {
|
1044
|
+
_T("23:41:12"),
|
1045
|
+
_T(""),
|
1046
|
+
_T("23:41:12.34"),
|
1047
|
+
_T("23:41:12.987"),
|
1048
|
+
_T(""),
|
1049
|
+
_T(""),
|
1050
|
+
_T("23:41:12.123456")
|
1051
|
+
};
|
1052
|
+
|
1053
|
+
const char* TEST_TIMEA[7] = {
|
1054
|
+
"23:41:12",
|
1055
|
+
"",
|
1056
|
+
"23:41:12.34",
|
1057
|
+
"23:41:12.987",
|
1058
|
+
"",
|
1059
|
+
"",
|
1060
|
+
"23:41:12.123456"
|
1061
|
+
};
|
1062
|
+
|
1063
|
+
const _TCHAR* TEST_DATETIME[7] = {
|
1064
|
+
_T("2015-11-09 12:31:56"),
|
1065
|
+
_T(""),
|
1066
|
+
_T("2015-11-09 12:31:56.98"),
|
1067
|
+
_T("2015-11-09 12:31:56.987"),
|
1068
|
+
_T(""),
|
1069
|
+
_T(""),
|
1070
|
+
_T("2015-11-09 12:31:56.123456")
|
1071
|
+
};
|
1072
|
+
|
1073
|
+
const char* TEST_DATETIMEA[7] = {
|
1074
|
+
"2015-11-09 12:31:56",
|
1075
|
+
"",
|
1076
|
+
"2015-11-09 12:31:56.98",
|
1077
|
+
"2015-11-09 12:31:56.987",
|
1078
|
+
"",
|
1079
|
+
"",
|
1080
|
+
"2015-11-09 12:31:56.123456"
|
1081
|
+
};
|
1082
|
+
|
1083
|
+
|
1084
|
+
void checkLegacyTimeValue(table_ptr tb)
|
1085
|
+
{
|
1086
|
+
short fieldnum = 0;
|
1087
|
+
// read by int64
|
1088
|
+
myTime t(0, false); t = TEST_TIME0;
|
1089
|
+
BOOST_CHECK(tb->getFV64(++fieldnum) == t.i64);
|
1090
|
+
|
1091
|
+
myDateTime dt(0, false); dt = TEST_DATETIME0;
|
1092
|
+
BOOST_CHECK(tb->getFV64(++fieldnum) == dt.i64);
|
1093
|
+
|
1094
|
+
myTimeStamp ts(0, false); ts = TEST_DATETIME0;
|
1095
|
+
BOOST_CHECK(tb->getFV64(++fieldnum) == ts.i64);
|
1096
|
+
|
1097
|
+
// read by double
|
1098
|
+
fieldnum = 0;
|
1099
|
+
BOOST_CHECK(tb->getFVdbl(++fieldnum) == (double)t.i64);
|
1100
|
+
BOOST_CHECK(tb->getFVdbl(++fieldnum) == (double)dt.i64);
|
1101
|
+
BOOST_CHECK(tb->getFVdbl(++fieldnum) == (double)ts.i64);
|
1102
|
+
|
1103
|
+
//read by string
|
1104
|
+
fieldnum = 0;
|
1105
|
+
BOOST_CHECK(_tcscmp(tb->getFVstr(++fieldnum), TEST_TIME0) == 0);
|
1106
|
+
BOOST_CHECK(_tcscmp(tb->getFVstr(++fieldnum), TEST_DATETIME0) == 0);
|
1107
|
+
BOOST_CHECK(_tcscmp(tb->getFVstr(++fieldnum), TEST_DATETIME0) == 0);
|
1108
|
+
|
1109
|
+
}
|
1110
|
+
|
1111
|
+
void checkAutoTimeStamp(__int64& oldValue, __int64 newValue)
|
1112
|
+
{
|
1113
|
+
BOOST_CHECK(oldValue != newValue);
|
1114
|
+
_TCHAR tmp[70];
|
1115
|
+
myTimeStamp ts_auto(0, false);
|
1116
|
+
ts_auto.i64 = newValue;
|
1117
|
+
BOOST_CHECK(_tcscmp(btrdtoa(getNowDate(),(_TCHAR*)NULL, true), ts_auto.dateStr(tmp, 70)) == 0);
|
1118
|
+
|
1119
|
+
oldValue = newValue;
|
1120
|
+
}
|
1121
|
+
|
1122
|
+
void testStoreLegacyTime(database* db)
|
1123
|
+
{
|
1124
|
+
short tableid = 2;
|
1125
|
+
short fieldnum = 0;
|
1126
|
+
|
1127
|
+
table_ptr tb = openTable(db, tableid, TD_OPEN_NORMAL);
|
1128
|
+
tb->setTimestampMode(TIMESTAMP_VALUE_CONTROL);
|
1129
|
+
BOOST_CHECK(tb->stat() == 0);
|
1130
|
+
|
1131
|
+
tb->clearBuffer();
|
1132
|
+
tb->setFV(_T("id"), 1);
|
1133
|
+
|
1134
|
+
myTime t(0, false); t = TEST_TIME0;
|
1135
|
+
tb->setFV(++fieldnum, t.i64);
|
1136
|
+
|
1137
|
+
myDateTime dt(0, false); dt = TEST_DATETIME0;
|
1138
|
+
tb->setFV(++fieldnum, dt.i64);
|
1139
|
+
|
1140
|
+
myTimeStamp ts(0, false); ts = TEST_DATETIME0;
|
1141
|
+
tb->setFV(++fieldnum, ts.i64);
|
1142
|
+
tb->insert();
|
1143
|
+
|
1144
|
+
tb->clearBuffer();
|
1145
|
+
tb->setFV(_T("id"), 1);
|
1146
|
+
tb->seek();
|
1147
|
+
BOOST_CHECK(tb->stat() == 0);
|
1148
|
+
checkLegacyTimeValue(tb);
|
1149
|
+
|
1150
|
+
|
1151
|
+
tb->clearBuffer();
|
1152
|
+
tb->setFV(_T("id"), 2);
|
1153
|
+
fieldnum = 0;
|
1154
|
+
tb->setFV(++fieldnum, TEST_TIME0);
|
1155
|
+
tb->setFV(++fieldnum, TEST_DATETIME0);
|
1156
|
+
tb->setFV(++fieldnum, TEST_DATETIME0);
|
1157
|
+
tb->insert();
|
1158
|
+
|
1159
|
+
tb->clearBuffer();
|
1160
|
+
tb->setFV(_T("id"), 2);
|
1161
|
+
tb->seek();
|
1162
|
+
BOOST_CHECK(tb->stat() == 0);
|
1163
|
+
checkLegacyTimeValue(tb);
|
1164
|
+
__int64 ts_auto_i = tb->getFV64(3);
|
1165
|
+
|
1166
|
+
tb->clearBuffer();
|
1167
|
+
tb->setFV(_T("id"), 2);
|
1168
|
+
tb->update();
|
1169
|
+
BOOST_CHECK(tb->stat() == 0);
|
1170
|
+
tb->seek();
|
1171
|
+
BOOST_CHECK(tb->stat() == 0);
|
1172
|
+
checkAutoTimeStamp(ts_auto_i, tb->getFV64(3));
|
1173
|
+
|
1174
|
+
|
1175
|
+
std::string values;
|
1176
|
+
values += "1\t";
|
1177
|
+
values += TEST_TIME0A;
|
1178
|
+
values += "\t2\t";
|
1179
|
+
values += TEST_DATETIME0A;
|
1180
|
+
values += "\t3\t";
|
1181
|
+
values += TEST_DATETIME0A;
|
1182
|
+
|
1183
|
+
tb->test_store(values.c_str());
|
1184
|
+
BOOST_CHECK(tb->stat() == 0);
|
1185
|
+
tb->clearBuffer();
|
1186
|
+
tb->setFV(_T("id"), 2);
|
1187
|
+
tb->seek();
|
1188
|
+
BOOST_CHECK(tb->stat() == 0);
|
1189
|
+
checkLegacyTimeValue(tb);
|
1190
|
+
}
|
1191
|
+
|
1192
|
+
void checkTimeValue(table_ptr tb, short fieldIndex, int decimals, bool mySql56timeFormat,
|
1193
|
+
bool isSupportMultiTimeStamp)
|
1194
|
+
{
|
1195
|
+
// read by int64
|
1196
|
+
myTime t(decimals, true);
|
1197
|
+
t = TEST_TIME[decimals];
|
1198
|
+
BOOST_CHECK_MESSAGE(tb->getFV64(fieldIndex) == t.i64, "myTime decimals = " << decimals);
|
1199
|
+
myDateTime dt(decimals, true);
|
1200
|
+
maDateTime dta(decimals, true);
|
1201
|
+
if (mySql56timeFormat)
|
1202
|
+
{
|
1203
|
+
dt = TEST_DATETIME[decimals];
|
1204
|
+
BOOST_CHECK_MESSAGE(tb->getFV64(fieldIndex + 4) == dt.i64, "myDateTime decimals = " << decimals);
|
1205
|
+
}
|
1206
|
+
else
|
1207
|
+
{
|
1208
|
+
dta = TEST_DATETIME[decimals];
|
1209
|
+
BOOST_CHECK_MESSAGE(tb->getFV64(fieldIndex + 4) == dta.i64, "maDateTime decimals = " << decimals);
|
1210
|
+
}
|
1211
|
+
if (isSupportMultiTimeStamp || decimals == 3)
|
1212
|
+
{
|
1213
|
+
myTimeStamp ts(decimals, true);
|
1214
|
+
ts = TEST_DATETIME[decimals];
|
1215
|
+
BOOST_CHECK_MESSAGE(tb->getFV64(fieldIndex + 8) == ts.i64, "myTimeStamp decimals = " << decimals);
|
1216
|
+
}
|
1217
|
+
//read by string
|
1218
|
+
BOOST_CHECK_MESSAGE(_tcscmp(tb->getFVstr(fieldIndex), TEST_TIME[decimals]) == 0, "myTime decimals = " << decimals);
|
1219
|
+
BOOST_CHECK_MESSAGE(_tcscmp(tb->getFVstr(fieldIndex + 4), TEST_DATETIME[decimals]) == 0, "dateTime decimals = " << decimals);
|
1220
|
+
if (isSupportMultiTimeStamp || decimals == 3)
|
1221
|
+
BOOST_CHECK_MESSAGE(_tcscmp(tb->getFVstr(fieldIndex + 8), TEST_DATETIME[decimals]) == 0, "myTimeStamp decimals = " << decimals);
|
1222
|
+
}
|
1223
|
+
|
1224
|
+
void checkTimeValues(table_ptr tb, bool mySql56timeFormat, bool isSupportMultiTimeStamp)
|
1225
|
+
{
|
1226
|
+
short fieldnum = 0;
|
1227
|
+
checkTimeValue(tb, ++fieldnum, 3, mySql56timeFormat, isSupportMultiTimeStamp); //3 decimals
|
1228
|
+
checkTimeValue(tb, ++fieldnum, 0, mySql56timeFormat, isSupportMultiTimeStamp); //0 decimal
|
1229
|
+
checkTimeValue(tb, ++fieldnum, 2, mySql56timeFormat, isSupportMultiTimeStamp); //2 decimals
|
1230
|
+
checkTimeValue(tb, ++fieldnum, 6, mySql56timeFormat, isSupportMultiTimeStamp); //6 decimals
|
1231
|
+
}
|
1232
|
+
|
1233
|
+
void setTimeValue64(table_ptr tb, short fieldIndex, int decimals, bool mySql56timeFormat,
|
1234
|
+
bool isSupportMultiTimeStamp)
|
1235
|
+
{
|
1236
|
+
myTime t(decimals, true);
|
1237
|
+
t = TEST_TIME[decimals]; tb->setFV(fieldIndex, t.i64);
|
1238
|
+
myDateTime dt(decimals, true);
|
1239
|
+
maDateTime dta(decimals, true);
|
1240
|
+
if (mySql56timeFormat)
|
1241
|
+
{
|
1242
|
+
dt = TEST_DATETIME[decimals]; tb->setFV(fieldIndex + 4, dt.i64);
|
1243
|
+
}
|
1244
|
+
else
|
1245
|
+
{
|
1246
|
+
dta = TEST_DATETIME[decimals]; tb->setFV(fieldIndex + 4, dta.i64);
|
1247
|
+
}
|
1248
|
+
if (!isSupportMultiTimeStamp && decimals != 3) return;
|
1249
|
+
|
1250
|
+
myTimeStamp ts(decimals, true);
|
1251
|
+
ts = TEST_DATETIME[decimals]; tb->setFV(fieldIndex + 8, ts.i64);
|
1252
|
+
}
|
1253
|
+
|
1254
|
+
void testStoreTime(database* db, bool mySql56timeFormat, bool isSupportMultiTimeStamp)
|
1255
|
+
{
|
1256
|
+
short tableid = 2;
|
1257
|
+
short fieldnum = 0;
|
1258
|
+
|
1259
|
+
|
1260
|
+
#if (defined(_DEBUG) && defined(_WIN32))
|
1261
|
+
char sqlTemp[10240];
|
1262
|
+
uint_td datalen = 10240;
|
1263
|
+
db->getSqlStringForCreateTable(_T("timetest"), sqlTemp, &datalen);
|
1264
|
+
OutputDebugStringA(sqlTemp);
|
1265
|
+
#endif
|
1266
|
+
table_ptr tb = openTable(db, tableid, TD_OPEN_NORMAL);
|
1267
|
+
tb->setTimestampMode(TIMESTAMP_VALUE_CONTROL);
|
1268
|
+
BOOST_CHECK(tb->stat() == 0);
|
1269
|
+
|
1270
|
+
tb->clearBuffer();
|
1271
|
+
tb->setFV(_T("id"), 1);
|
1272
|
+
|
1273
|
+
setTimeValue64(tb, ++fieldnum, 3, mySql56timeFormat, isSupportMultiTimeStamp);
|
1274
|
+
setTimeValue64(tb, ++fieldnum, 0, mySql56timeFormat, isSupportMultiTimeStamp);
|
1275
|
+
setTimeValue64(tb, ++fieldnum, 2, mySql56timeFormat, isSupportMultiTimeStamp);
|
1276
|
+
setTimeValue64(tb, ++fieldnum, 6, mySql56timeFormat, isSupportMultiTimeStamp);
|
1277
|
+
tb->insert();
|
1278
|
+
|
1279
|
+
tb->clearBuffer();
|
1280
|
+
tb->setFV(_T("id"), 1);
|
1281
|
+
tb->seek();
|
1282
|
+
BOOST_CHECK(tb->stat() == 0);
|
1283
|
+
checkTimeValues(tb, mySql56timeFormat, isSupportMultiTimeStamp);
|
1284
|
+
|
1285
|
+
|
1286
|
+
tb->clearBuffer();
|
1287
|
+
tb->setFV(_T("id"), 2);
|
1288
|
+
fieldnum = 0;
|
1289
|
+
setTimeValue64(tb, ++fieldnum, 3, mySql56timeFormat, isSupportMultiTimeStamp);
|
1290
|
+
setTimeValue64(tb, ++fieldnum, 0, mySql56timeFormat, isSupportMultiTimeStamp);
|
1291
|
+
setTimeValue64(tb, ++fieldnum, 2, mySql56timeFormat, isSupportMultiTimeStamp);
|
1292
|
+
setTimeValue64(tb, ++fieldnum, 6, mySql56timeFormat, isSupportMultiTimeStamp);
|
1293
|
+
tb->insert();
|
1294
|
+
|
1295
|
+
tb->clearBuffer();
|
1296
|
+
tb->setFV(_T("id"), 2);
|
1297
|
+
tb->seek();
|
1298
|
+
BOOST_CHECK(tb->stat() == 0);
|
1299
|
+
checkTimeValues(tb, mySql56timeFormat, isSupportMultiTimeStamp);
|
1300
|
+
__int64 ts_auto_i = tb->getFV64(9);
|
1301
|
+
|
1302
|
+
tb->clearBuffer();
|
1303
|
+
tb->setFV(_T("id"), 2);
|
1304
|
+
tb->update();
|
1305
|
+
BOOST_CHECK(tb->stat() == 0);
|
1306
|
+
tb->seek();
|
1307
|
+
BOOST_CHECK(tb->stat() == 0);
|
1308
|
+
checkAutoTimeStamp(ts_auto_i, tb->getFV64(9));
|
1309
|
+
|
1310
|
+
|
1311
|
+
std::string values;
|
1312
|
+
values += "1\t";
|
1313
|
+
values += TEST_TIMEA[3];
|
1314
|
+
values += "\t2\t";
|
1315
|
+
values += TEST_TIMEA[0];
|
1316
|
+
values += "\t3\t";
|
1317
|
+
values += TEST_TIMEA[2];
|
1318
|
+
values += "\t4\t";
|
1319
|
+
values += TEST_TIMEA[6];
|
1320
|
+
|
1321
|
+
values += "\t5\t";
|
1322
|
+
values += TEST_DATETIMEA[3];
|
1323
|
+
values += "\t6\t";
|
1324
|
+
values += TEST_DATETIMEA[0];
|
1325
|
+
values += "\t7\t";
|
1326
|
+
values += TEST_DATETIMEA[2];
|
1327
|
+
values += "\t8\t";
|
1328
|
+
values += TEST_DATETIMEA[6];
|
1329
|
+
|
1330
|
+
values += "\t9\t";
|
1331
|
+
values += TEST_DATETIMEA[3];
|
1332
|
+
if (isSupportMultiTimeStamp)
|
1333
|
+
{
|
1334
|
+
values += "\t10\t";
|
1335
|
+
values += TEST_DATETIMEA[0];
|
1336
|
+
values += "\t11\t";
|
1337
|
+
values += TEST_DATETIMEA[2];
|
1338
|
+
values += "\t12\t";
|
1339
|
+
values += TEST_DATETIMEA[6];
|
1340
|
+
}
|
1341
|
+
|
1342
|
+
tb->test_store(values.c_str());
|
1343
|
+
BOOST_CHECK(tb->stat() == 0);
|
1344
|
+
tb->clearBuffer();
|
1345
|
+
tb->setFV(_T("id"), 2);
|
1346
|
+
tb->seek();
|
1347
|
+
BOOST_CHECK(tb->stat() == 0);
|
1348
|
+
checkTimeValues(tb, mySql56timeFormat, isSupportMultiTimeStamp);
|
1349
|
+
}
|
1350
|
+
|
1351
|
+
void test_NOT_HA_OPTION_PACK_RECORD(database* db)
|
1352
|
+
{
|
1353
|
+
short tableid = 3;
|
1354
|
+
short fieldnum = 0;
|
1355
|
+
table_ptr tb = openTable(db, tableid, TD_OPEN_NORMAL);
|
1356
|
+
tb->clearBuffer();
|
1357
|
+
BOOST_CHECK(tb->getFVNull(1) == false);
|
1358
|
+
|
1359
|
+
tb->setFV(fieldnum++, 1);
|
1360
|
+
tb->setFV(fieldnum++, 10);
|
1361
|
+
tb->insert();
|
1362
|
+
BOOST_CHECK(tb->stat() == 0);
|
1363
|
+
|
1364
|
+
fieldnum = 0;
|
1365
|
+
tb->clearBuffer();
|
1366
|
+
tb->setFV(fieldnum++, 2);
|
1367
|
+
tb->setFVNull(fieldnum++, true);
|
1368
|
+
tb->insert();
|
1369
|
+
BOOST_CHECK(tb->stat() == 0);
|
1370
|
+
|
1371
|
+
fieldnum = 0;
|
1372
|
+
tb->clearBuffer();
|
1373
|
+
tb->setFV(fieldnum++, 2);
|
1374
|
+
tb->seek();
|
1375
|
+
BOOST_CHECK(tb->stat() == 0);
|
1376
|
+
BOOST_CHECK(tb->getFVNull(fieldnum) == true);
|
1377
|
+
|
1378
|
+
}
|
1379
|
+
|
1380
|
+
void insertInManyData(table_ptr tb)
|
1381
|
+
{
|
1382
|
+
short fieldNum = 0;
|
1383
|
+
tb->clearBuffer();
|
1384
|
+
tb->setFV(++fieldNum, 1);
|
1385
|
+
tb->setFV(++fieldNum, 1);
|
1386
|
+
tb->setFV(++fieldNum, _T("test"));
|
1387
|
+
tb->insert();
|
1388
|
+
BOOST_CHECK(tb->stat() == 0);
|
1389
|
+
|
1390
|
+
fieldNum = 0;
|
1391
|
+
tb->clearBuffer();
|
1392
|
+
tb->setFV(++fieldNum, (_TCHAR*)NULL);
|
1393
|
+
tb->setFV(++fieldNum, 2);
|
1394
|
+
tb->setFV(++fieldNum, _T("test2"));
|
1395
|
+
tb->insert();
|
1396
|
+
BOOST_CHECK(tb->stat() == 0);
|
1397
|
+
|
1398
|
+
fieldNum = 0;
|
1399
|
+
tb->clearBuffer();
|
1400
|
+
tb->setFV(++fieldNum, 3);
|
1401
|
+
tb->setFV(++fieldNum, (_TCHAR*)NULL);
|
1402
|
+
tb->setFV(++fieldNum, _T(""));
|
1403
|
+
tb->insert();
|
1404
|
+
BOOST_CHECK(tb->stat() == 0);
|
1405
|
+
|
1406
|
+
fieldNum = 0;
|
1407
|
+
tb->clearBuffer();
|
1408
|
+
tb->setFV(++fieldNum, 4);
|
1409
|
+
tb->setFV(++fieldNum, (_TCHAR*)NULL);
|
1410
|
+
tb->setFV(++fieldNum, _T("test4"));
|
1411
|
+
tb->insert();
|
1412
|
+
BOOST_CHECK(tb->stat() == 0);
|
1413
|
+
|
1414
|
+
fieldNum = 0;
|
1415
|
+
tb->clearBuffer();
|
1416
|
+
tb->setFV(++fieldNum, 4);
|
1417
|
+
tb->setFV(++fieldNum, 5);
|
1418
|
+
tb->setFV(++fieldNum, (_TCHAR*)NULL);
|
1419
|
+
tb->insert();
|
1420
|
+
BOOST_CHECK(tb->stat() == 0);
|
1421
|
+
|
1422
|
+
fieldNum = 0;
|
1423
|
+
tb->clearBuffer();
|
1424
|
+
tb->setFV(++fieldNum, (_TCHAR*)NULL);
|
1425
|
+
tb->setFV(++fieldNum, (_TCHAR*)NULL);
|
1426
|
+
tb->setFV(++fieldNum, (_TCHAR*)NULL);
|
1427
|
+
tb->insert();
|
1428
|
+
BOOST_CHECK(tb->stat() == 0);
|
1429
|
+
}
|
1430
|
+
|
1431
|
+
void insertGroupsData(table_ptr tb)
|
1432
|
+
{
|
1433
|
+
short fieldNum = 0;
|
1434
|
+
tb->clearBuffer();
|
1435
|
+
tb->setFV(++fieldNum, 1);
|
1436
|
+
tb->setFV(++fieldNum, _T("Administrators"));
|
1437
|
+
tb->insert();
|
1438
|
+
BOOST_CHECK(tb->stat() == 0);
|
1439
|
+
|
1440
|
+
fieldNum = 0;
|
1441
|
+
tb->clearBuffer();
|
1442
|
+
tb->setFV(++fieldNum, 2);
|
1443
|
+
tb->setFV(++fieldNum, _T("Users"));
|
1444
|
+
tb->insert();
|
1445
|
+
BOOST_CHECK(tb->stat() == 0);
|
1446
|
+
|
1447
|
+
fieldNum = 0;
|
1448
|
+
tb->clearBuffer();
|
1449
|
+
tb->setFV(++fieldNum, 3);
|
1450
|
+
tb->setFV(++fieldNum, _T("Guests"));
|
1451
|
+
tb->insert();
|
1452
|
+
BOOST_CHECK(tb->stat() == 0);
|
1453
|
+
|
1454
|
+
fieldNum = 0;
|
1455
|
+
tb->clearBuffer();
|
1456
|
+
tb->setFV(++fieldNum, (_TCHAR*)NULL);
|
1457
|
+
tb->setFV(++fieldNum, _T("Unknowns"));
|
1458
|
+
tb->insert();
|
1459
|
+
BOOST_CHECK(tb->stat() == 0);
|
1460
|
+
}
|
1461
|
+
|
1462
|
+
void insertUsersData(table_ptr tb)
|
1463
|
+
{
|
1464
|
+
short fieldNum = 0;
|
1465
|
+
tb->clearBuffer();
|
1466
|
+
tb->setFV(++fieldNum, 1);
|
1467
|
+
tb->setFV(++fieldNum, 3);
|
1468
|
+
tb->setFV(++fieldNum, _T("John"));
|
1469
|
+
tb->insert();
|
1470
|
+
BOOST_CHECK(tb->stat() == 0);
|
1471
|
+
|
1472
|
+
fieldNum = 0;
|
1473
|
+
tb->clearBuffer();
|
1474
|
+
tb->setFV(++fieldNum, 2);
|
1475
|
+
tb->setFV(++fieldNum, (_TCHAR*)NULL);
|
1476
|
+
tb->setFV(++fieldNum, _T("Alice"));
|
1477
|
+
tb->insert();
|
1478
|
+
BOOST_CHECK(tb->stat() == 0);
|
1479
|
+
|
1480
|
+
fieldNum = 0;
|
1481
|
+
tb->clearBuffer();
|
1482
|
+
tb->setFV(++fieldNum, (_TCHAR*)NULL);
|
1483
|
+
tb->setFV(++fieldNum, 3);
|
1484
|
+
tb->setFV(++fieldNum, _T("Pochi"));
|
1485
|
+
tb->insert();
|
1486
|
+
BOOST_CHECK(tb->stat() == 0);
|
1487
|
+
|
1488
|
+
fieldNum = 0;
|
1489
|
+
tb->clearBuffer();
|
1490
|
+
tb->setFV(++fieldNum, 2);
|
1491
|
+
tb->setFV(++fieldNum, 1);
|
1492
|
+
tb->setFV(++fieldNum, _T("Bob"));
|
1493
|
+
tb->insert();
|
1494
|
+
BOOST_CHECK(tb->stat() == 0);
|
1495
|
+
|
1496
|
+
fieldNum = 0;
|
1497
|
+
tb->clearBuffer();
|
1498
|
+
tb->setFV(++fieldNum, (_TCHAR*)NULL);
|
1499
|
+
tb->setFV(++fieldNum, 2);
|
1500
|
+
tb->setFV(++fieldNum, _T("Tama"));
|
1501
|
+
tb->insert();
|
1502
|
+
BOOST_CHECK(tb->stat() == 0);
|
1503
|
+
|
1504
|
+
fieldNum = 0;
|
1505
|
+
tb->clearBuffer();
|
1506
|
+
tb->setFV(++fieldNum, 4);
|
1507
|
+
tb->setFV(++fieldNum, 3);
|
1508
|
+
tb->setFV(++fieldNum, _T("Microsoft"));
|
1509
|
+
tb->insert();
|
1510
|
+
BOOST_CHECK(tb->stat() == 0);
|
1511
|
+
|
1512
|
+
fieldNum = 0;
|
1513
|
+
tb->clearBuffer();
|
1514
|
+
tb->setFV(++fieldNum, 2);
|
1515
|
+
tb->setFV(++fieldNum, (_TCHAR*)NULL);
|
1516
|
+
tb->setFV(++fieldNum, _T("Susie"));
|
1517
|
+
tb->insert();
|
1518
|
+
BOOST_CHECK(tb->stat() == 0);
|
1519
|
+
|
1520
|
+
fieldNum = 0;
|
1521
|
+
tb->clearBuffer();
|
1522
|
+
tb->setFV(++fieldNum, 3);
|
1523
|
+
tb->setFV(++fieldNum, 1);
|
1524
|
+
tb->setFV(++fieldNum, _T("Taro"));
|
1525
|
+
tb->insert();
|
1526
|
+
BOOST_CHECK(tb->stat() == 0);
|
1527
|
+
|
1528
|
+
fieldNum = 0;
|
1529
|
+
tb->clearBuffer();
|
1530
|
+
tb->setFV(++fieldNum, 4);
|
1531
|
+
tb->setFV(++fieldNum, 3);
|
1532
|
+
tb->setFV(++fieldNum, _T("Google"));
|
1533
|
+
tb->insert();
|
1534
|
+
BOOST_CHECK(tb->stat() == 0);
|
1535
|
+
|
1536
|
+
fieldNum = 0;
|
1537
|
+
tb->clearBuffer();
|
1538
|
+
tb->setFV(++fieldNum, 1);
|
1539
|
+
tb->setFV(++fieldNum, 1);
|
1540
|
+
tb->setFV(++fieldNum, _T("Lee"));
|
1541
|
+
tb->insert();
|
1542
|
+
BOOST_CHECK(tb->stat() == 0);
|
1543
|
+
|
1544
|
+
fieldNum = 0;
|
1545
|
+
tb->clearBuffer();
|
1546
|
+
tb->setFV(++fieldNum, 3);
|
1547
|
+
tb->setFV(++fieldNum, (_TCHAR*)NULL);
|
1548
|
+
tb->setFV(++fieldNum, _T("Hanako"));
|
1549
|
+
tb->insert();
|
1550
|
+
BOOST_CHECK(tb->stat() == 0);
|
1551
|
+
}
|
1552
|
+
|
1553
|
+
void insertScoresData(table_ptr tb)
|
1554
|
+
{
|
1555
|
+
short fieldNum = 0;
|
1556
|
+
tb->clearBuffer();
|
1557
|
+
tb->setFV(++fieldNum, 1);
|
1558
|
+
tb->setFV(++fieldNum, 80);
|
1559
|
+
tb->insert();
|
1560
|
+
BOOST_CHECK(tb->stat() == 0);
|
1561
|
+
|
1562
|
+
fieldNum = 0;
|
1563
|
+
tb->clearBuffer();
|
1564
|
+
tb->setFV(++fieldNum, 1);
|
1565
|
+
tb->setFV(++fieldNum, 70);
|
1566
|
+
tb->insert();
|
1567
|
+
BOOST_CHECK(tb->stat() == 0);
|
1568
|
+
|
1569
|
+
fieldNum = 0;
|
1570
|
+
tb->clearBuffer();
|
1571
|
+
tb->setFV(++fieldNum, 1);
|
1572
|
+
tb->setFV(++fieldNum, 50);
|
1573
|
+
tb->insert();
|
1574
|
+
BOOST_CHECK(tb->stat() == 0);
|
1575
|
+
|
1576
|
+
fieldNum = 0;
|
1577
|
+
tb->clearBuffer();
|
1578
|
+
tb->setFV(++fieldNum, 1);
|
1579
|
+
tb->setFV(++fieldNum, (_TCHAR*)NULL);
|
1580
|
+
tb->insert();
|
1581
|
+
BOOST_CHECK(tb->stat() == 0);
|
1582
|
+
|
1583
|
+
fieldNum = 0;
|
1584
|
+
tb->clearBuffer();
|
1585
|
+
tb->setFV(++fieldNum, 2);
|
1586
|
+
tb->setFV(++fieldNum, 90);
|
1587
|
+
tb->insert();
|
1588
|
+
BOOST_CHECK(tb->stat() == 0);
|
1589
|
+
|
1590
|
+
fieldNum = 0;
|
1591
|
+
tb->clearBuffer();
|
1592
|
+
tb->setFV(++fieldNum, 2);
|
1593
|
+
tb->setFV(++fieldNum, 85);
|
1594
|
+
tb->insert();
|
1595
|
+
BOOST_CHECK(tb->stat() == 0);
|
1596
|
+
|
1597
|
+
fieldNum = 0;
|
1598
|
+
tb->clearBuffer();
|
1599
|
+
tb->setFV(++fieldNum, 3);
|
1600
|
+
tb->setFV(++fieldNum, 80);
|
1601
|
+
tb->insert();
|
1602
|
+
BOOST_CHECK(tb->stat() == 0);
|
1603
|
+
|
1604
|
+
fieldNum = 0;
|
1605
|
+
tb->clearBuffer();
|
1606
|
+
tb->setFV(++fieldNum, 3);
|
1607
|
+
tb->setFV(++fieldNum, 70);
|
1608
|
+
tb->insert();
|
1609
|
+
BOOST_CHECK(tb->stat() == 0);
|
1610
|
+
|
1611
|
+
fieldNum = 0;
|
1612
|
+
tb->clearBuffer();
|
1613
|
+
tb->setFV(++fieldNum, 3);
|
1614
|
+
tb->setFV(++fieldNum, 50);
|
1615
|
+
tb->insert();
|
1616
|
+
BOOST_CHECK(tb->stat() == 0);
|
1617
|
+
|
1618
|
+
fieldNum = 0;
|
1619
|
+
tb->clearBuffer();
|
1620
|
+
tb->setFV(++fieldNum, 3);
|
1621
|
+
tb->setFV(++fieldNum, 0);
|
1622
|
+
tb->insert();
|
1623
|
+
BOOST_CHECK(tb->stat() == 0);
|
1624
|
+
|
1625
|
+
fieldNum = 0;
|
1626
|
+
tb->clearBuffer();
|
1627
|
+
tb->setFV(++fieldNum, 1);
|
1628
|
+
tb->setFV(++fieldNum, 60);
|
1629
|
+
tb->insert();
|
1630
|
+
BOOST_CHECK(tb->stat() == 0);
|
1631
|
+
|
1632
|
+
fieldNum = 0;
|
1633
|
+
tb->clearBuffer();
|
1634
|
+
tb->setFV(++fieldNum, 2);
|
1635
|
+
tb->setFV(++fieldNum, 87);
|
1636
|
+
tb->insert();
|
1637
|
+
BOOST_CHECK(tb->stat() == 0);
|
1638
|
+
|
1639
|
+
fieldNum = 0;
|
1640
|
+
tb->clearBuffer();
|
1641
|
+
tb->setFV(++fieldNum, 3);
|
1642
|
+
tb->setFV(++fieldNum, 90);
|
1643
|
+
tb->insert();
|
1644
|
+
BOOST_CHECK(tb->stat() == 0);
|
1645
|
+
}
|
1646
|
+
|
1647
|
+
void testInMany(database* db)
|
1648
|
+
{
|
1649
|
+
short tableid = 4;
|
1650
|
+
{
|
1651
|
+
table_ptr tb = openTable(db, tableid, TD_OPEN_NORMAL);
|
1652
|
+
insertInManyData(tb);
|
1653
|
+
}
|
1654
|
+
activeTable atv(db, _T("nullkey"));
|
1655
|
+
atv.index(1);
|
1656
|
+
query q;
|
1657
|
+
recordset rs;
|
1658
|
+
q.in(1, 2, 3);
|
1659
|
+
atv.read(rs, q);
|
1660
|
+
BOOST_CHECK(rs.size() == 3);
|
1661
|
+
BOOST_CHECK(rs[0][_T("id")] == 1);
|
1662
|
+
BOOST_CHECK(rs[1].isInvalidRecord() == true);
|
1663
|
+
BOOST_CHECK(rs[2][_T("id")] == 3);
|
1664
|
+
|
1665
|
+
// read by nullkey
|
1666
|
+
q.reset();
|
1667
|
+
atv.index(1).keyValue(0).read(rs, q);
|
1668
|
+
BOOST_CHECK(rs.size() == 4);
|
1669
|
+
|
1670
|
+
// read records all, that include null value
|
1671
|
+
atv.index(2).keyValue((const _TCHAR*)NULL).read(rs, q);
|
1672
|
+
BOOST_CHECK(rs.size() == 6);
|
1673
|
+
rs.orderBy(_T("id2"));
|
1674
|
+
BOOST_CHECK(rs[0][_T("id2")].isNull() == true);
|
1675
|
+
BOOST_CHECK(rs[1][_T("id2")].isNull() == true);
|
1676
|
+
BOOST_CHECK(rs[2][_T("id2")].isNull() == false);
|
1677
|
+
|
1678
|
+
sortFields sf;
|
1679
|
+
sf.add(_T("id2"), false);
|
1680
|
+
rs.orderBy(sf);
|
1681
|
+
BOOST_CHECK(rs[5][_T("id2")].isNull() == true);
|
1682
|
+
BOOST_CHECK(rs[4][_T("id2")].isNull() == true);
|
1683
|
+
BOOST_CHECK(rs[3][_T("id2")].isNull() == false);
|
1684
|
+
|
1685
|
+
recordset& rs2 = *rs.clone();
|
1686
|
+
recordsetQuery rq;
|
1687
|
+
rq.whenIsNotNull(_T("id2"));
|
1688
|
+
rs2.matchBy(rq);
|
1689
|
+
BOOST_CHECK(rs2.size() == 4);
|
1690
|
+
//rs2.release();
|
1691
|
+
|
1692
|
+
rs2 = *rs.clone();
|
1693
|
+
rq.whenIsNull(_T("id2"));
|
1694
|
+
rs2.matchBy(rq);
|
1695
|
+
BOOST_CHECK(rs2.size() == 2);
|
1696
|
+
//rs2.release();
|
1697
|
+
|
1698
|
+
rs2 = *rs.clone();
|
1699
|
+
rq.when(_T("id2"), _T("="), 4);
|
1700
|
+
rs2.matchBy(rq);
|
1701
|
+
BOOST_CHECK(rs2.size() == 2);
|
1702
|
+
|
1703
|
+
rs2 = *rs.clone();
|
1704
|
+
rq.when(_T("id2"), _T("<"), 3);
|
1705
|
+
rs2.matchBy(rq);
|
1706
|
+
BOOST_CHECK(rs2.size() == 1);
|
1707
|
+
|
1708
|
+
rs2.release();
|
1709
|
+
|
1710
|
+
// read records after null.
|
1711
|
+
atv.index(2).keyValue(0).read(rs, q);
|
1712
|
+
BOOST_CHECK(rs.size() == 4);
|
1713
|
+
|
1714
|
+
// read in has_many.
|
1715
|
+
q.reset().segmentsForInValue(1).in(4);
|
1716
|
+
atv.index(2).read(rs, q);
|
1717
|
+
BOOST_CHECK(rs.size() == 2);
|
1718
|
+
BOOST_CHECK(rs[0][_T("id")] == 4);
|
1719
|
+
BOOST_CHECK(rs[1][_T("id")] == 5);
|
1720
|
+
}
|
1721
|
+
|
1722
|
+
void testNullValue(database* db)
|
1723
|
+
{
|
1724
|
+
{
|
1725
|
+
short tableid = 5;
|
1726
|
+
table_ptr tb = openTable(db, tableid, TD_OPEN_NORMAL);
|
1727
|
+
insertInManyData(tb);
|
1728
|
+
tableid = 6;
|
1729
|
+
table_ptr tbg = openTable(db, tableid, TD_OPEN_NORMAL);
|
1730
|
+
insertGroupsData(tbg);
|
1731
|
+
tableid = 7;
|
1732
|
+
table_ptr tbu = openTable(db, tableid, TD_OPEN_NORMAL);
|
1733
|
+
insertUsersData(tbu);
|
1734
|
+
tableid = 8;
|
1735
|
+
table_ptr tbs = openTable(db, tableid, TD_OPEN_NORMAL);
|
1736
|
+
insertScoresData(tbs);
|
1737
|
+
}
|
1738
|
+
activeTable atv(db, _T("nullvalue"));
|
1739
|
+
atv.index(1);
|
1740
|
+
activeTable atg(db, _T("groups"));
|
1741
|
+
atg.alias(_T("id"), _T("group_id")).alias(_T("name"), _T("group_name"));
|
1742
|
+
atg.index(1);
|
1743
|
+
activeTable atu(db, _T("users"));
|
1744
|
+
atu.index(0);
|
1745
|
+
activeTable ats(db, _T("scores"));
|
1746
|
+
ats.index(0);
|
1747
|
+
query q;
|
1748
|
+
recordsetQuery rq;
|
1749
|
+
groupQuery gq;
|
1750
|
+
recordset rs;
|
1751
|
+
fieldNames fns;
|
1752
|
+
fns.keyField(_T("score"));
|
1753
|
+
bzs::db::protocol::tdap::client::count countFunc(_T("row_count"));
|
1754
|
+
bzs::db::protocol::tdap::client::count countField(fns, _T("valid_row"));
|
1755
|
+
bzs::db::protocol::tdap::client::sum sumField(fns, _T("sum"));
|
1756
|
+
bzs::db::protocol::tdap::client::avg avgField(fns, _T("avg"));
|
1757
|
+
bzs::db::protocol::tdap::client::min minField(fns, _T("min"));
|
1758
|
+
bzs::db::protocol::tdap::client::max maxField(fns, _T("max"));
|
1759
|
+
|
1760
|
+
// [1] WHERE id2 = 0
|
1761
|
+
// query
|
1762
|
+
rs.clear();
|
1763
|
+
q.reset().where(_T("id2"), _T("="), 0).reject(0);
|
1764
|
+
atv.keyValue((char *)NULL).read(rs, q);
|
1765
|
+
//rs.dump();
|
1766
|
+
BOOST_CHECK(rs.size() == 0);
|
1767
|
+
// query reverse
|
1768
|
+
rs.clear();
|
1769
|
+
q.reset().where(_T("id2"), _T("="), 0).reject(0).direction(table::findBackForword);
|
1770
|
+
atv.keyValue(100).read(rs, q);
|
1771
|
+
//rs.dump();
|
1772
|
+
BOOST_CHECK(rs.size() == 0);
|
1773
|
+
// recordsetQuery
|
1774
|
+
rs.clear();
|
1775
|
+
q.reset().all();
|
1776
|
+
atv.keyValue((char *)NULL).read(rs, q);
|
1777
|
+
rq.reset();
|
1778
|
+
rq.when(_T("id2"), _T("="), 0);
|
1779
|
+
rs.matchBy(rq);
|
1780
|
+
//rs.dump();
|
1781
|
+
BOOST_CHECK(rs.size() == 0);
|
1782
|
+
|
1783
|
+
// [2] WHERE id2 <> 0
|
1784
|
+
// query
|
1785
|
+
rs.clear();
|
1786
|
+
q.reset().where(_T("id2"), _T("<>"), 0).reject(0);
|
1787
|
+
atv.keyValue((char *)NULL).read(rs, q);
|
1788
|
+
//rs.dump();
|
1789
|
+
BOOST_CHECK(rs.size() == 4);
|
1790
|
+
BOOST_CHECK(rs[0][_T("id")] == 1);
|
1791
|
+
BOOST_CHECK(rs[1][_T("id")] == 3);
|
1792
|
+
BOOST_CHECK(rs[2][_T("id")] == 4);
|
1793
|
+
BOOST_CHECK(rs[3][_T("id")] == 5);
|
1794
|
+
// query reverse
|
1795
|
+
rs.clear();
|
1796
|
+
q.reset().where(_T("id2"), _T("<>"), 0).reject(0).direction(table::findBackForword);
|
1797
|
+
atv.keyValue(100).read(rs, q);
|
1798
|
+
//rs.dump();
|
1799
|
+
BOOST_CHECK(rs.size() == 4);
|
1800
|
+
BOOST_CHECK(rs[0][_T("id")] == 5);
|
1801
|
+
BOOST_CHECK(rs[1][_T("id")] == 4);
|
1802
|
+
BOOST_CHECK(rs[2][_T("id")] == 3);
|
1803
|
+
BOOST_CHECK(rs[3][_T("id")] == 1);
|
1804
|
+
// recordsetQuery
|
1805
|
+
rs.clear();
|
1806
|
+
q.reset().all();
|
1807
|
+
atv.keyValue((char *)NULL).read(rs, q);
|
1808
|
+
rq.reset();
|
1809
|
+
rq.when(_T("id2"), _T("<>"), 0);
|
1810
|
+
rs.matchBy(rq);
|
1811
|
+
//rs.dump();
|
1812
|
+
BOOST_CHECK(rs.size() == 4);
|
1813
|
+
BOOST_CHECK(rs[0][_T("id")] == 1);
|
1814
|
+
BOOST_CHECK(rs[1][_T("id")] == 3);
|
1815
|
+
BOOST_CHECK(rs[2][_T("id")] == 4);
|
1816
|
+
BOOST_CHECK(rs[3][_T("id")] == 5);
|
1817
|
+
|
1818
|
+
// [3] WHERE id2 >= 0
|
1819
|
+
// query
|
1820
|
+
rs.clear();
|
1821
|
+
q.reset().where(_T("id2"), _T(">="), 0).reject(0);
|
1822
|
+
atv.keyValue((char *)NULL).read(rs, q);
|
1823
|
+
//rs.dump();
|
1824
|
+
BOOST_CHECK(rs.size() == 4);
|
1825
|
+
BOOST_CHECK(rs[0][_T("id")] == 1);
|
1826
|
+
BOOST_CHECK(rs[1][_T("id")] == 3);
|
1827
|
+
BOOST_CHECK(rs[2][_T("id")] == 4);
|
1828
|
+
BOOST_CHECK(rs[3][_T("id")] == 5);
|
1829
|
+
// query reverse
|
1830
|
+
rs.clear();
|
1831
|
+
q.reset().where(_T("id2"), _T(">="), 0).reject(0).direction(table::findBackForword);
|
1832
|
+
atv.keyValue(100).read(rs, q);
|
1833
|
+
//rs.dump();
|
1834
|
+
BOOST_CHECK(rs.size() == 4);
|
1835
|
+
BOOST_CHECK(rs[0][_T("id")] == 5);
|
1836
|
+
BOOST_CHECK(rs[1][_T("id")] == 4);
|
1837
|
+
BOOST_CHECK(rs[2][_T("id")] == 3);
|
1838
|
+
BOOST_CHECK(rs[3][_T("id")] == 1);
|
1839
|
+
// recordsetQuery
|
1840
|
+
rs.clear();
|
1841
|
+
q.reset().all();
|
1842
|
+
atv.keyValue((char *)NULL).read(rs, q);
|
1843
|
+
rq.reset();
|
1844
|
+
rq.when(_T("id2"), _T(">="), 0);
|
1845
|
+
rs.matchBy(rq);
|
1846
|
+
//rs.dump();
|
1847
|
+
BOOST_CHECK(rs.size() == 4);
|
1848
|
+
BOOST_CHECK(rs[0][_T("id")] == 1);
|
1849
|
+
BOOST_CHECK(rs[1][_T("id")] == 3);
|
1850
|
+
BOOST_CHECK(rs[2][_T("id")] == 4);
|
1851
|
+
BOOST_CHECK(rs[3][_T("id")] == 5);
|
1852
|
+
|
1853
|
+
// [4] WHERE id2 <= 5
|
1854
|
+
// query
|
1855
|
+
rs.clear();
|
1856
|
+
q.reset().where(_T("id2"), _T("<="), 5).reject(0);
|
1857
|
+
atv.keyValue(0).read(rs, q); // set keyValue as 0, CAN NOT USE NULL IN THIS OPERATION.
|
1858
|
+
//rs.dump();
|
1859
|
+
BOOST_CHECK(rs.size() == 4);
|
1860
|
+
BOOST_CHECK(rs[0][_T("id")] == 1);
|
1861
|
+
BOOST_CHECK(rs[1][_T("id")] == 3);
|
1862
|
+
BOOST_CHECK(rs[2][_T("id")] == 4);
|
1863
|
+
BOOST_CHECK(rs[3][_T("id")] == 5);
|
1864
|
+
// query reverse
|
1865
|
+
rs.clear();
|
1866
|
+
q.reset().where(_T("id2"), _T("<="), 5).reject(0).direction(table::findBackForword);
|
1867
|
+
atv.keyValue(100).read(rs, q);
|
1868
|
+
//rs.dump();
|
1869
|
+
BOOST_CHECK(rs.size() == 4);
|
1870
|
+
BOOST_CHECK(rs[0][_T("id")] == 5);
|
1871
|
+
BOOST_CHECK(rs[1][_T("id")] == 4);
|
1872
|
+
BOOST_CHECK(rs[2][_T("id")] == 3);
|
1873
|
+
BOOST_CHECK(rs[3][_T("id")] == 1);
|
1874
|
+
// recordsetQuery
|
1875
|
+
rs.clear();
|
1876
|
+
q.reset().all();
|
1877
|
+
atv.keyValue((char *)NULL).read(rs, q);
|
1878
|
+
rq.reset();
|
1879
|
+
rq.when(_T("id2"), _T("<="), 5);
|
1880
|
+
rs.matchBy(rq);
|
1881
|
+
//rs.dump();
|
1882
|
+
BOOST_CHECK(rs.size() == 4);
|
1883
|
+
BOOST_CHECK(rs[0][_T("id")] == 1);
|
1884
|
+
BOOST_CHECK(rs[1][_T("id")] == 3);
|
1885
|
+
BOOST_CHECK(rs[2][_T("id")] == 4);
|
1886
|
+
BOOST_CHECK(rs[3][_T("id")] == 5);
|
1887
|
+
|
1888
|
+
// [5] WHERE name like 'test%'
|
1889
|
+
// query
|
1890
|
+
rs.clear();
|
1891
|
+
q.reset().where(_T("name"), _T("="), _T("test*")).reject(0);
|
1892
|
+
atv.keyValue((char *)NULL).read(rs, q);
|
1893
|
+
//rs.dump();
|
1894
|
+
BOOST_CHECK(rs.size() == 3);
|
1895
|
+
BOOST_CHECK(rs[0][_T("id")] == 2);
|
1896
|
+
BOOST_CHECK(rs[1][_T("id")] == 1);
|
1897
|
+
BOOST_CHECK(rs[2][_T("id")] == 4);
|
1898
|
+
// query reverse
|
1899
|
+
rs.clear();
|
1900
|
+
q.reset().where(_T("name"), _T("="), _T("test*")).reject(0).direction(table::findBackForword);
|
1901
|
+
atv.keyValue(100).read(rs, q);
|
1902
|
+
//rs.dump();
|
1903
|
+
BOOST_CHECK(rs.size() == 3);
|
1904
|
+
BOOST_CHECK(rs[0][_T("id")] == 4);
|
1905
|
+
BOOST_CHECK(rs[1][_T("id")] == 1);
|
1906
|
+
BOOST_CHECK(rs[2][_T("id")] == 2);
|
1907
|
+
// recordsetQuery
|
1908
|
+
rs.clear();
|
1909
|
+
q.reset().all();
|
1910
|
+
atv.keyValue((char *)NULL).read(rs, q);
|
1911
|
+
rq.reset();
|
1912
|
+
rq.when(_T("name"), _T("="), _T("test*"));
|
1913
|
+
rs.matchBy(rq);
|
1914
|
+
//rs.dump();
|
1915
|
+
BOOST_CHECK(rs.size() == 3);
|
1916
|
+
BOOST_CHECK(rs[0][_T("id")] == 2);
|
1917
|
+
BOOST_CHECK(rs[1][_T("id")] == 1);
|
1918
|
+
BOOST_CHECK(rs[2][_T("id")] == 4);
|
1919
|
+
|
1920
|
+
// [6] WHERE name not like 'test%'
|
1921
|
+
// query
|
1922
|
+
rs.clear();
|
1923
|
+
q.reset().where(_T("name"), _T("<>"), _T("test*")).reject(0);
|
1924
|
+
atv.keyValue((char *)NULL).read(rs, q);
|
1925
|
+
//rs.dump();
|
1926
|
+
BOOST_CHECK(rs.size() == 1);
|
1927
|
+
BOOST_CHECK(rs[0][_T("id")] == 3);
|
1928
|
+
// query reverse
|
1929
|
+
rs.clear();
|
1930
|
+
q.reset().where(_T("name"), _T("<>"), _T("test*")).reject(0).direction(table::findBackForword);
|
1931
|
+
atv.keyValue(100).read(rs, q);
|
1932
|
+
//rs.dump();
|
1933
|
+
BOOST_CHECK(rs.size() == 1);
|
1934
|
+
BOOST_CHECK(rs[0][_T("id")] == 3);
|
1935
|
+
// recordsetQuery
|
1936
|
+
rs.clear();
|
1937
|
+
q.reset().all();
|
1938
|
+
atv.keyValue((char *)NULL).read(rs, q);
|
1939
|
+
rq.reset();
|
1940
|
+
rq.when(_T("name"), _T("<>"), _T("test*"));
|
1941
|
+
rs.matchBy(rq);
|
1942
|
+
//rs.dump();
|
1943
|
+
BOOST_CHECK(rs.size() == 1);
|
1944
|
+
BOOST_CHECK(rs[0][_T("id")] == 3);
|
1945
|
+
|
1946
|
+
// [7] WHERE id2 IS NULL
|
1947
|
+
// query
|
1948
|
+
rs.clear();
|
1949
|
+
q.reset().whereIsNull(_T("id2")).reject(0);
|
1950
|
+
atv.keyValue((char *)NULL).read(rs, q);
|
1951
|
+
//rs.dump();
|
1952
|
+
BOOST_CHECK(rs.size() == 2);
|
1953
|
+
BOOST_CHECK(rs[0][_T("id")] == 2);
|
1954
|
+
BOOST_CHECK(rs[1][_T("id")] == 6);
|
1955
|
+
// query reverse
|
1956
|
+
rs.clear();
|
1957
|
+
q.reset().whereIsNull(_T("id2")).reject(0).direction(table::findBackForword);
|
1958
|
+
atv.keyValue(100).read(rs, q);
|
1959
|
+
//rs.dump();
|
1960
|
+
BOOST_CHECK(rs.size() == 2);
|
1961
|
+
BOOST_CHECK(rs[0][_T("id")] == 6);
|
1962
|
+
BOOST_CHECK(rs[1][_T("id")] == 2);
|
1963
|
+
// recordsetQuery
|
1964
|
+
rs.clear();
|
1965
|
+
q.reset().all();
|
1966
|
+
atv.keyValue((char *)NULL).read(rs, q);
|
1967
|
+
rq.reset();
|
1968
|
+
rq.whenIsNull(_T("id2"));
|
1969
|
+
rs.matchBy(rq);
|
1970
|
+
//rs.dump();
|
1971
|
+
BOOST_CHECK(rs.size() == 2);
|
1972
|
+
BOOST_CHECK(rs[0][_T("id")] == 2);
|
1973
|
+
BOOST_CHECK(rs[1][_T("id")] == 6);
|
1974
|
+
|
1975
|
+
// [8] WHERE id2 IS NOT NULL
|
1976
|
+
// query
|
1977
|
+
rs.clear();
|
1978
|
+
q.reset().whereIsNotNull(_T("id2")).reject(0);
|
1979
|
+
atv.keyValue((char *)NULL).read(rs, q);
|
1980
|
+
//rs.dump();
|
1981
|
+
BOOST_CHECK(rs.size() == 4);
|
1982
|
+
BOOST_CHECK(rs[0][_T("id")] == 1);
|
1983
|
+
BOOST_CHECK(rs[1][_T("id")] == 3);
|
1984
|
+
BOOST_CHECK(rs[2][_T("id")] == 4);
|
1985
|
+
BOOST_CHECK(rs[3][_T("id")] == 5);
|
1986
|
+
// query reverse
|
1987
|
+
rs.clear();
|
1988
|
+
q.reset().whereIsNotNull(_T("id2")).reject(0).direction(table::findBackForword);
|
1989
|
+
atv.keyValue(100).read(rs, q);
|
1990
|
+
//rs.dump();
|
1991
|
+
BOOST_CHECK(rs.size() == 4);
|
1992
|
+
BOOST_CHECK(rs[0][_T("id")] == 5);
|
1993
|
+
BOOST_CHECK(rs[1][_T("id")] == 4);
|
1994
|
+
BOOST_CHECK(rs[2][_T("id")] == 3);
|
1995
|
+
BOOST_CHECK(rs[3][_T("id")] == 1);
|
1996
|
+
// recordsetQuery
|
1997
|
+
rs.clear();
|
1998
|
+
q.reset().all();
|
1999
|
+
atv.keyValue((char *)NULL).read(rs, q);
|
2000
|
+
rq.reset();
|
2001
|
+
rq.whenIsNotNull(_T("id2"));
|
2002
|
+
rs.matchBy(rq);
|
2003
|
+
//rs.dump();
|
2004
|
+
BOOST_CHECK(rs.size() == 4);
|
2005
|
+
BOOST_CHECK(rs[0][_T("id")] == 1);
|
2006
|
+
BOOST_CHECK(rs[1][_T("id")] == 3);
|
2007
|
+
BOOST_CHECK(rs[2][_T("id")] == 4);
|
2008
|
+
BOOST_CHECK(rs[3][_T("id")] == 5);
|
2009
|
+
|
2010
|
+
// [9] WHERE id2 IN (1, 2, 3
|
2011
|
+
// query
|
2012
|
+
rs.clear();
|
2013
|
+
q.reset().in(1, 2, 3).reject(0);
|
2014
|
+
atv.keyValue((char *)NULL).read(rs, q);
|
2015
|
+
//rs.dump();
|
2016
|
+
BOOST_CHECK(rs.size() == 3);
|
2017
|
+
BOOST_CHECK(rs[0][_T("id")] == 1);
|
2018
|
+
BOOST_CHECK(rs[1].isInvalidRecord() == true);
|
2019
|
+
BOOST_CHECK(rs[2][_T("id")] == 3);
|
2020
|
+
// query reverse
|
2021
|
+
rs.clear();
|
2022
|
+
q.reset().in(1, 2, 3).reject(0).direction(table::findBackForword);
|
2023
|
+
atv.keyValue(100).read(rs, q);
|
2024
|
+
//rs.dump();
|
2025
|
+
BOOST_CHECK(rs.size() == 3);
|
2026
|
+
BOOST_CHECK(rs[0][_T("id")] == 1);
|
2027
|
+
BOOST_CHECK(rs[1].isInvalidRecord() == true);
|
2028
|
+
BOOST_CHECK(rs[2][_T("id")] == 3);
|
2029
|
+
|
2030
|
+
// [10] select * from `values` join `groups` on `values`.id2 = `groups`.id;
|
2031
|
+
rs.clear();
|
2032
|
+
q.reset().all();
|
2033
|
+
atv.keyValue((char *)NULL).read(rs, q);
|
2034
|
+
atg.join(rs, q, _T("id2"));
|
2035
|
+
//rs.dump();
|
2036
|
+
BOOST_CHECK(rs.size() == 2);
|
2037
|
+
BOOST_CHECK(rs[0][_T("id2")] == 1);
|
2038
|
+
BOOST_CHECK(rs[0][_T("group_name")] == _T("Administrators"));
|
2039
|
+
BOOST_CHECK(rs[1][_T("id2")] == 3);
|
2040
|
+
BOOST_CHECK(rs[1][_T("group_name")] == _T("Guests"));
|
2041
|
+
|
2042
|
+
// [11] select * from `values` join `groups` on `values`.id2 = `groups`.pri_id and `values`.id3 = `groups`.id;
|
2043
|
+
atv.index(2);
|
2044
|
+
atg.index(2);
|
2045
|
+
rs.clear();
|
2046
|
+
q.reset().all();
|
2047
|
+
atv.keyValue((char *)NULL).read(rs, q);
|
2048
|
+
atg.join(rs, q, _T("id2"), _T("id3"));
|
2049
|
+
atv.index(1);
|
2050
|
+
atg.index(1);
|
2051
|
+
//rs.dump();
|
2052
|
+
BOOST_CHECK(rs.size() == 1);
|
2053
|
+
BOOST_CHECK(rs[0][_T("id2")] == 1);
|
2054
|
+
BOOST_CHECK(rs[0][_T("group_name")] == _T("Administrators"));
|
2055
|
+
|
2056
|
+
// [12] select * from `values` left outer join `groups` on `values`.id2 = `groups`.id;
|
2057
|
+
rs.clear();
|
2058
|
+
q.reset().all();
|
2059
|
+
atv.keyValue((char *)NULL).read(rs, q);
|
2060
|
+
atg.outerJoin(rs, q, _T("id2"));
|
2061
|
+
//rs.dump();
|
2062
|
+
BOOST_CHECK(rs.size() == 6);
|
2063
|
+
BOOST_CHECK(rs[0].isInvalidRecord() == true);
|
2064
|
+
BOOST_CHECK(rs[1].isInvalidRecord() == true);
|
2065
|
+
BOOST_CHECK(rs[2][_T("id2")] == 1);
|
2066
|
+
BOOST_CHECK(rs[2][_T("group_name")] == _T("Administrators"));
|
2067
|
+
BOOST_CHECK(rs[3][_T("id2")] == 3);
|
2068
|
+
BOOST_CHECK(rs[3][_T("group_name")] == _T("Guests"));
|
2069
|
+
BOOST_CHECK(rs[4].isInvalidRecord() == true);
|
2070
|
+
BOOST_CHECK(rs[5].isInvalidRecord() == true);
|
2071
|
+
|
2072
|
+
// [13] select * from `values` left outer join `groups` on `values`.id2 = `groups`.pri_id and `values`.id3 = `groups`.id;
|
2073
|
+
atv.index(2);
|
2074
|
+
atg.index(2);
|
2075
|
+
rs.clear();
|
2076
|
+
q.reset().all();
|
2077
|
+
atv.keyValue((char *)NULL, (char *)NULL).read(rs, q);
|
2078
|
+
atg.outerJoin(rs, q, _T("id2"), _T("id3"));
|
2079
|
+
atv.index(1);
|
2080
|
+
atg.index(1);
|
2081
|
+
//rs.dump();
|
2082
|
+
BOOST_CHECK(rs.size() == 6);
|
2083
|
+
BOOST_CHECK(rs[0].isInvalidRecord() == true);
|
2084
|
+
BOOST_CHECK(rs[1].isInvalidRecord() == true);
|
2085
|
+
BOOST_CHECK(rs[2][_T("id2")] == 1);
|
2086
|
+
BOOST_CHECK(rs[2][_T("group_name")] == _T("Administrators"));
|
2087
|
+
BOOST_CHECK(rs[3].isInvalidRecord() == true);
|
2088
|
+
BOOST_CHECK(rs[4].isInvalidRecord() == true);
|
2089
|
+
BOOST_CHECK(rs[5].isInvalidRecord() == true);
|
2090
|
+
|
2091
|
+
// [14] select id2 from `values` order by id2;
|
2092
|
+
rs.clear();
|
2093
|
+
q.reset().select(_T("id2"));
|
2094
|
+
atv.keyValue((char *)NULL).read(rs, q);
|
2095
|
+
rs.orderBy(_T("id2"));
|
2096
|
+
//rs.dump();
|
2097
|
+
BOOST_CHECK(rs.size() == 6);
|
2098
|
+
BOOST_CHECK(rs[0][_T("id2")].isNull() == true);
|
2099
|
+
BOOST_CHECK(rs[1][_T("id2")].isNull() == true);
|
2100
|
+
BOOST_CHECK(rs[2][_T("id2")] == 1);
|
2101
|
+
BOOST_CHECK(rs[3][_T("id2")] == 3);
|
2102
|
+
BOOST_CHECK(rs[4][_T("id2")] == 4);
|
2103
|
+
BOOST_CHECK(rs[5][_T("id2")] == 4);
|
2104
|
+
|
2105
|
+
// [15] select id2 from `values` order by id2 DESC;
|
2106
|
+
rs.clear();
|
2107
|
+
q.reset().select(_T("id2"));
|
2108
|
+
atv.keyValue((char *)NULL).read(rs, q);
|
2109
|
+
sortFields orders;
|
2110
|
+
orders.add(_T("id2"), false); // DESC
|
2111
|
+
rs.orderBy(orders);
|
2112
|
+
//rs.dump();
|
2113
|
+
BOOST_CHECK(rs.size() == 6);
|
2114
|
+
BOOST_CHECK(rs[0][_T("id2")] == 4);
|
2115
|
+
BOOST_CHECK(rs[1][_T("id2")] == 4);
|
2116
|
+
BOOST_CHECK(rs[2][_T("id2")] == 3);
|
2117
|
+
BOOST_CHECK(rs[3][_T("id2")] == 1);
|
2118
|
+
BOOST_CHECK(rs[4][_T("id2")].isNull() == true);
|
2119
|
+
BOOST_CHECK(rs[5][_T("id2")].isNull() == true);
|
2120
|
+
|
2121
|
+
// [16] select * from users2 group by `group`;
|
2122
|
+
rs.clear();
|
2123
|
+
q.reset().all();
|
2124
|
+
atu.keyValue((char *)NULL).read(rs, q);
|
2125
|
+
gq.reset();
|
2126
|
+
gq.keyField(_T("group"));
|
2127
|
+
rs.groupBy(gq);
|
2128
|
+
//rs.dump();
|
2129
|
+
BOOST_CHECK(rs.size() == 5);
|
2130
|
+
BOOST_CHECK(rs[0][_T("group")].isNull() == true);
|
2131
|
+
BOOST_CHECK(rs[1][_T("group")] == 1);
|
2132
|
+
BOOST_CHECK(rs[2][_T("group")] == 2);
|
2133
|
+
BOOST_CHECK(rs[3][_T("group")] == 3);
|
2134
|
+
BOOST_CHECK(rs[4][_T("group")] == 4);
|
2135
|
+
|
2136
|
+
// [17] select * from users2 group by `group`, `class`;
|
2137
|
+
rs.clear();
|
2138
|
+
q.reset().all();
|
2139
|
+
atu.keyValue((char *)NULL).read(rs, q);
|
2140
|
+
gq.reset();
|
2141
|
+
gq.keyField(_T("group"), _T("class"));
|
2142
|
+
rs.groupBy(gq);
|
2143
|
+
//rs.dump();
|
2144
|
+
BOOST_CHECK(rs.size() == 9);
|
2145
|
+
BOOST_CHECK(rs[0][_T("group")].isNull() == true);
|
2146
|
+
BOOST_CHECK(rs[0][_T("class")] == 2);
|
2147
|
+
BOOST_CHECK(rs[1][_T("group")].isNull() == true);
|
2148
|
+
BOOST_CHECK(rs[1][_T("class")] == 3);
|
2149
|
+
BOOST_CHECK(rs[2][_T("group")] == 1);
|
2150
|
+
BOOST_CHECK(rs[2][_T("class")] == 1);
|
2151
|
+
BOOST_CHECK(rs[3][_T("group")] == 1);
|
2152
|
+
BOOST_CHECK(rs[3][_T("class")] == 3);
|
2153
|
+
BOOST_CHECK(rs[4][_T("group")] == 2);
|
2154
|
+
BOOST_CHECK(rs[4][_T("class")].isNull() == true);
|
2155
|
+
BOOST_CHECK(rs[5][_T("group")] == 2);
|
2156
|
+
BOOST_CHECK(rs[5][_T("class")] == 1);
|
2157
|
+
BOOST_CHECK(rs[6][_T("group")] == 3);
|
2158
|
+
BOOST_CHECK(rs[6][_T("class")].isNull() == true);
|
2159
|
+
BOOST_CHECK(rs[7][_T("group")] == 3);
|
2160
|
+
BOOST_CHECK(rs[7][_T("class")] == 1);
|
2161
|
+
BOOST_CHECK(rs[8][_T("group")] == 4);
|
2162
|
+
BOOST_CHECK(rs[8][_T("class")] == 3);
|
2163
|
+
|
2164
|
+
// [18] select `group`, count(*) from users2 group by `group`;
|
2165
|
+
rs.clear();
|
2166
|
+
q.reset().all();
|
2167
|
+
atu.keyValue((char *)NULL).read(rs, q);
|
2168
|
+
gq.reset();
|
2169
|
+
gq.keyField(_T("group"));
|
2170
|
+
gq.addFunction(&countFunc);
|
2171
|
+
rs.groupBy(gq);
|
2172
|
+
//rs.dump();
|
2173
|
+
BOOST_CHECK(rs.size() == 5);
|
2174
|
+
BOOST_CHECK(rs[0][_T("group")].isNull() == true);
|
2175
|
+
BOOST_CHECK(rs[0][_T("row_count")] == 2);
|
2176
|
+
BOOST_CHECK(rs[1][_T("group")] == 1);
|
2177
|
+
BOOST_CHECK(rs[1][_T("row_count")] == 2);
|
2178
|
+
BOOST_CHECK(rs[2][_T("group")] == 2);
|
2179
|
+
BOOST_CHECK(rs[2][_T("row_count")] == 3);
|
2180
|
+
BOOST_CHECK(rs[3][_T("group")] == 3);
|
2181
|
+
BOOST_CHECK(rs[3][_T("row_count")] == 2);
|
2182
|
+
BOOST_CHECK(rs[4][_T("group")] == 4);
|
2183
|
+
BOOST_CHECK(rs[4][_T("row_count")] == 2);
|
2184
|
+
|
2185
|
+
// [19] select `group`, `class`, count(*) from users2 group by `group`, `class`;
|
2186
|
+
rs.clear();
|
2187
|
+
q.reset().all();
|
2188
|
+
atu.keyValue((char *)NULL).read(rs, q);
|
2189
|
+
gq.reset();
|
2190
|
+
gq.keyField(_T("group"), _T("class"));
|
2191
|
+
gq.addFunction(&countFunc);
|
2192
|
+
rs.groupBy(gq);
|
2193
|
+
//rs.dump();
|
2194
|
+
BOOST_CHECK(rs.size() == 9);
|
2195
|
+
BOOST_CHECK(rs[0][_T("group")].isNull() == true);
|
2196
|
+
BOOST_CHECK(rs[0][_T("class")] == 2);
|
2197
|
+
BOOST_CHECK(rs[0][_T("row_count")] == 1);
|
2198
|
+
BOOST_CHECK(rs[1][_T("group")].isNull() == true);
|
2199
|
+
BOOST_CHECK(rs[1][_T("class")] == 3);
|
2200
|
+
BOOST_CHECK(rs[1][_T("row_count")] == 1);
|
2201
|
+
BOOST_CHECK(rs[2][_T("group")] == 1);
|
2202
|
+
BOOST_CHECK(rs[2][_T("class")] == 1);
|
2203
|
+
BOOST_CHECK(rs[2][_T("row_count")] == 1);
|
2204
|
+
BOOST_CHECK(rs[3][_T("group")] == 1);
|
2205
|
+
BOOST_CHECK(rs[3][_T("class")] == 3);
|
2206
|
+
BOOST_CHECK(rs[3][_T("row_count")] == 1);
|
2207
|
+
BOOST_CHECK(rs[4][_T("group")] == 2);
|
2208
|
+
BOOST_CHECK(rs[4][_T("class")].isNull() == true);
|
2209
|
+
BOOST_CHECK(rs[4][_T("row_count")] == 2);
|
2210
|
+
BOOST_CHECK(rs[5][_T("group")] == 2);
|
2211
|
+
BOOST_CHECK(rs[5][_T("class")] == 1);
|
2212
|
+
BOOST_CHECK(rs[5][_T("row_count")] == 1);
|
2213
|
+
BOOST_CHECK(rs[6][_T("group")] == 3);
|
2214
|
+
BOOST_CHECK(rs[6][_T("class")].isNull() == true);
|
2215
|
+
BOOST_CHECK(rs[6][_T("row_count")] == 1);
|
2216
|
+
BOOST_CHECK(rs[7][_T("group")] == 3);
|
2217
|
+
BOOST_CHECK(rs[7][_T("class")] == 1);
|
2218
|
+
BOOST_CHECK(rs[7][_T("row_count")] == 1);
|
2219
|
+
BOOST_CHECK(rs[8][_T("group")] == 4);
|
2220
|
+
BOOST_CHECK(rs[8][_T("class")] == 3);
|
2221
|
+
BOOST_CHECK(rs[8][_T("row_count")] == 2);
|
2222
|
+
|
2223
|
+
// [20] select count(*) as cnt1, count(score) as cnt2, sum(score) as sum, avg(score) as avg, min(score) as min, max(score) as max from subjectscores;
|
2224
|
+
rs.clear();
|
2225
|
+
q.reset().all();
|
2226
|
+
ats.keyValue((char *)NULL).read(rs, q);
|
2227
|
+
gq.reset();
|
2228
|
+
gq.addFunction(&countFunc);
|
2229
|
+
gq.addFunction(&countField);
|
2230
|
+
gq.addFunction(&sumField);
|
2231
|
+
gq.addFunction(&avgField);
|
2232
|
+
gq.addFunction(&minField);
|
2233
|
+
gq.addFunction(&maxField);
|
2234
|
+
rs.groupBy(gq);
|
2235
|
+
//rs.dump();
|
2236
|
+
BOOST_CHECK(rs.size() == 1);
|
2237
|
+
BOOST_CHECK(rs[0][_T("row_count")] == 13);
|
2238
|
+
BOOST_CHECK(rs[0][_T("valid_row")] == 12);
|
2239
|
+
BOOST_CHECK(rs[0][_T("sum")] == 812);
|
2240
|
+
BOOST_CHECK(rs[0][_T("avg")] == (812/12));
|
2241
|
+
BOOST_CHECK(rs[0][_T("min")] == 0);
|
2242
|
+
BOOST_CHECK(rs[0][_T("max")] == 90);
|
2243
|
+
|
2244
|
+
// [21] select count(*) as cnt1, count(score) as cnt2, sum(score) as sum, avg(score) as avg, min(score) as min, max(score) as max from subjectscores group by subject;
|
2245
|
+
rs.clear();
|
2246
|
+
q.reset().all();
|
2247
|
+
ats.keyValue((char *)NULL).read(rs, q);
|
2248
|
+
gq.reset();
|
2249
|
+
gq.addFunction(&countFunc);
|
2250
|
+
gq.addFunction(&countField);
|
2251
|
+
gq.addFunction(&sumField);
|
2252
|
+
gq.addFunction(&avgField);
|
2253
|
+
gq.addFunction(&minField);
|
2254
|
+
gq.addFunction(&maxField);
|
2255
|
+
gq.keyField(_T("subject"));
|
2256
|
+
rs.groupBy(gq);
|
2257
|
+
//rs.dump();
|
2258
|
+
BOOST_CHECK(rs.size() == 3);
|
2259
|
+
BOOST_CHECK(rs[0][_T("subject")] == 1);
|
2260
|
+
BOOST_CHECK(rs[0][_T("row_count")] == 5);
|
2261
|
+
BOOST_CHECK(rs[0][_T("valid_row")] == 4);
|
2262
|
+
BOOST_CHECK(rs[0][_T("sum")] == 260);
|
2263
|
+
BOOST_CHECK(rs[0][_T("avg")] == (260/4));
|
2264
|
+
BOOST_CHECK(rs[0][_T("min")] == 50);
|
2265
|
+
BOOST_CHECK(rs[0][_T("max")] == 80);
|
2266
|
+
BOOST_CHECK(rs[1][_T("subject")] == 2);
|
2267
|
+
BOOST_CHECK(rs[1][_T("row_count")] == 3);
|
2268
|
+
BOOST_CHECK(rs[1][_T("valid_row")] == 3);
|
2269
|
+
BOOST_CHECK(rs[1][_T("sum")] == 262);
|
2270
|
+
BOOST_CHECK(rs[1][_T("avg")] == (262/3));
|
2271
|
+
BOOST_CHECK(rs[1][_T("min")] == 85);
|
2272
|
+
BOOST_CHECK(rs[1][_T("max")] == 90);
|
2273
|
+
BOOST_CHECK(rs[2][_T("subject")] == 3);
|
2274
|
+
BOOST_CHECK(rs[2][_T("row_count")] == 5);
|
2275
|
+
BOOST_CHECK(rs[2][_T("valid_row")] == 5);
|
2276
|
+
BOOST_CHECK(rs[2][_T("sum")] == 290);
|
2277
|
+
BOOST_CHECK(rs[2][_T("avg")] == (290/5));
|
2278
|
+
BOOST_CHECK(rs[2][_T("min")] == 0);
|
2279
|
+
BOOST_CHECK(rs[2][_T("max")] == 90);
|
2280
|
+
}
|
2281
|
+
|
2282
|
+
#define SEB_DB_TABLE_NAME _T("setenumbit")
|
2283
|
+
|
2284
|
+
void testSetEnumBit()
|
2285
|
+
{
|
2286
|
+
database* db = database::create();
|
2287
|
+
db->open(makeUri(PROTOCOL, HOSTNAME, DBNAMEV3));
|
2288
|
+
|
2289
|
+
activeTable ats(db, SEB_DB_TABLE_NAME);
|
2290
|
+
ats.index(0);
|
2291
|
+
recordset rs;
|
2292
|
+
query q;
|
2293
|
+
q.reset().all();
|
2294
|
+
ats.keyValue((char *)NULL).read(rs, q);
|
2295
|
+
#ifdef _DEBUG
|
2296
|
+
//rs.dump();
|
2297
|
+
#endif
|
2298
|
+
|
2299
|
+
BOOST_CHECK(rs.size() == 4);
|
2300
|
+
|
2301
|
+
BOOST_CHECK(rs[0][_T("id")] == 1);
|
2302
|
+
BOOST_CHECK(rs[0][_T("set5")].i64() == 1);
|
2303
|
+
BOOST_CHECK(rs[0][_T("set64")].i64() == 1);
|
2304
|
+
BOOST_CHECK(rs[0][_T("enum2")].i64() == 2);
|
2305
|
+
BOOST_CHECK(rs[0][_T("enum260")].i64() == 1);
|
2306
|
+
BOOST_CHECK(rs[0][_T("bit1")].i64() == 1);
|
2307
|
+
BOOST_CHECK(rs[0][_T("bit8")].i64() == 1);
|
2308
|
+
BOOST_CHECK(rs[0][_T("bit32")].i64() == 1);
|
2309
|
+
BOOST_CHECK(rs[0][_T("bit64")].i64() == 1);
|
2310
|
+
|
2311
|
+
BOOST_CHECK(rs[1][_T("id")] == 2);
|
2312
|
+
BOOST_CHECK(rs[1][_T("set5")].i64() == 31);
|
2313
|
+
BOOST_CHECK(rs[1][_T("set64")].i64() == 0x8000000000000001);
|
2314
|
+
BOOST_CHECK(rs[1][_T("enum2")].i64() == 1);
|
2315
|
+
BOOST_CHECK(rs[1][_T("enum260")].i64() == 260);
|
2316
|
+
BOOST_CHECK(rs[1][_T("bit1")].i64() == 1);
|
2317
|
+
BOOST_CHECK(rs[1][_T("bit8")].i64() == 0xFF);
|
2318
|
+
BOOST_CHECK(rs[1][_T("bit32")].i64() == 0xFFFFFFFF);
|
2319
|
+
BOOST_CHECK(rs[1][_T("bit64")].i64() == 0xFFFFFFFFFFFFFFFF);
|
2320
|
+
|
2321
|
+
BOOST_CHECK(rs[2][_T("id")] == 3);
|
2322
|
+
BOOST_CHECK(rs[2][_T("set5")].i64() == 0);
|
2323
|
+
BOOST_CHECK(rs[2][_T("set64")].i64() == 0);
|
2324
|
+
BOOST_CHECK(rs[2][_T("enum2")].i64() == 0);
|
2325
|
+
BOOST_CHECK(rs[2][_T("enum260")].i64() == 0);
|
2326
|
+
BOOST_CHECK(rs[2][_T("bit1")].i64() == 0);
|
2327
|
+
BOOST_CHECK(rs[2][_T("bit8")].i64() == 0);
|
2328
|
+
BOOST_CHECK(rs[2][_T("bit32")].i64() == 0);
|
2329
|
+
BOOST_CHECK(rs[2][_T("bit64")].i64() == 0);
|
2330
|
+
|
2331
|
+
BOOST_CHECK(rs[3][_T("id")] == 4);
|
2332
|
+
BOOST_CHECK(rs[3][_T("set5")].isNull() == true);
|
2333
|
+
BOOST_CHECK(rs[3][_T("set64")].isNull() == true);
|
2334
|
+
BOOST_CHECK(rs[3][_T("enum2")].isNull() == true);
|
2335
|
+
BOOST_CHECK(rs[3][_T("enum260")].isNull() == true);
|
2336
|
+
BOOST_CHECK(rs[3][_T("bit1")].isNull() == true);
|
2337
|
+
BOOST_CHECK(rs[3][_T("bit8")].isNull() == true);
|
2338
|
+
BOOST_CHECK(rs[3][_T("bit32")].isNull() == true);
|
2339
|
+
BOOST_CHECK(rs[3][_T("bit64")].isNull() == true);
|
2340
|
+
db->release();
|
2341
|
+
}
|
2342
|
+
|
2343
|
+
#include <bzs/db/protocol/tdap/fieldComp.h>
|
2344
|
+
void testCompInt()
|
2345
|
+
{
|
2346
|
+
for (ushort_td len = 1; len < 6; ++len)
|
2347
|
+
{
|
2348
|
+
if (len == 5) len = 8;
|
2349
|
+
comp1Func compFunc = getCompFunc(ft_integer, len, eEqual, 0);
|
2350
|
+
__int64 l; __int64 r;
|
2351
|
+
l = 0; r = 1; BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) < 0);
|
2352
|
+
l = 0; r = 0; BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) == 0);
|
2353
|
+
l = 1; r = 0; BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) > 0);
|
2354
|
+
l = -1;r = 0; BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) < 0);
|
2355
|
+
l = -1;r = -1; BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) == 0);
|
2356
|
+
l = -1;r = -2; BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) > 0);
|
2357
|
+
}
|
2358
|
+
}
|
2359
|
+
|
2360
|
+
void testCompUint()
|
2361
|
+
{
|
2362
|
+
for (ushort_td len = 1; len < 6; ++len)
|
2363
|
+
{
|
2364
|
+
if (len == 5) len = 8;
|
2365
|
+
comp1Func compFunc = getCompFunc(ft_uinteger, len, eEqual, 0);
|
2366
|
+
unsigned __int64 l; unsigned __int64 r;
|
2367
|
+
l = 0; r = ULLONG_MAX; BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) < 0);
|
2368
|
+
l = 0; r = 0; BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) == 0);
|
2369
|
+
l = 1; r = 0; BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) > 0);
|
2370
|
+
l = ULLONG_MAX; r = 0; BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) > 0);
|
2371
|
+
l = ULLONG_MAX; r = ULLONG_MAX; BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) == 0);
|
2372
|
+
l = ULLONG_MAX-1;r = ULLONG_MAX; BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) < 0);
|
2373
|
+
}
|
2374
|
+
}
|
2375
|
+
void testCompDouble()
|
2376
|
+
{
|
2377
|
+
ushort_td len = 4;
|
2378
|
+
comp1Func compFunc = getCompFunc(ft_float, len, eEqual, 0);
|
2379
|
+
{
|
2380
|
+
float l; float r;
|
2381
|
+
l = (float)-0.2; r = 0; BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) < 0);
|
2382
|
+
l = (float)-0.2; r = (float)-0.2; BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) == 0);
|
2383
|
+
l = (float)0.2; r = 0; BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) > 0);
|
2384
|
+
}
|
2385
|
+
{
|
2386
|
+
double l; double r;
|
2387
|
+
len = 8;
|
2388
|
+
compFunc = getCompFunc(ft_float, len, eEqual, 0);
|
2389
|
+
l = -0.000000000000002; r = 0; BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) < 0);
|
2390
|
+
l = -0.000000000000002; r = -0.000000000000002; BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) == 0);
|
2391
|
+
l = 0.000000000000002; r = 0; BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) > 0);
|
2392
|
+
}
|
2393
|
+
}
|
2394
|
+
|
2395
|
+
void testCompBit()
|
2396
|
+
{
|
2397
|
+
for (ushort_td len = 1; len < 8; ++len)
|
2398
|
+
{
|
2399
|
+
// equal comp
|
2400
|
+
comp1Func compFunc = getCompFunc(ft_bit, len, eEqual, 0);
|
2401
|
+
unsigned __int64 l; unsigned __int64 r;
|
2402
|
+
|
2403
|
+
l = 0; r = 0xF0; l = changeEndian(l, len);r = changeEndian(r, len);
|
2404
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) < 0);
|
2405
|
+
|
2406
|
+
l = 0; r = 0; l = changeEndian(l, len);r = changeEndian(r, len);
|
2407
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) == 0);
|
2408
|
+
|
2409
|
+
l = 1; r = 0; l = changeEndian(l, len);r = changeEndian(r, len);
|
2410
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) > 0);
|
2411
|
+
|
2412
|
+
l = 0xF0; r = 0; l = changeEndian(l, len);r = changeEndian(r, len);
|
2413
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) > 0);
|
2414
|
+
|
2415
|
+
l = 0xF0; r = 0xF0; l = changeEndian(l, len);r = changeEndian(r, len);
|
2416
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) == 0);
|
2417
|
+
|
2418
|
+
l = 0xF0-1;r = 0xF0; l = changeEndian(l, len);r = changeEndian(r, len);
|
2419
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) < 0);
|
2420
|
+
|
2421
|
+
// bit comp
|
2422
|
+
compFunc = getCompFunc(ft_bit, len, eBitAnd, 0);
|
2423
|
+
l = 0xFF; r = 0xF0; l = changeEndian(l, len);r = changeEndian(r, len);
|
2424
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) == 0);
|
2425
|
+
l = 0xF0; r = 0xF; l = changeEndian(l, len);r = changeEndian(r, len);
|
2426
|
+
int v = compFunc((const char*)&l, (const char*)&r, len);
|
2427
|
+
BOOST_CHECK(v > 0);
|
2428
|
+
|
2429
|
+
compFunc = getCompFunc(ft_bit, len, eNotBitAnd, 0);
|
2430
|
+
l = 0xFF; r = 0xF0; l = changeEndian(l, len);r = changeEndian(r, len);
|
2431
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) == 0);
|
2432
|
+
}
|
2433
|
+
}
|
2434
|
+
|
2435
|
+
void testCompSet()
|
2436
|
+
{
|
2437
|
+
for (ushort_td len = 1; len < 5; ++len)
|
2438
|
+
{
|
2439
|
+
if (len == 5) len = 8;
|
2440
|
+
// equal comp
|
2441
|
+
comp1Func compFunc = getCompFunc(ft_set, len, eEqual, 0);
|
2442
|
+
unsigned __int64 l; unsigned __int64 r;
|
2443
|
+
l = 0; r = 0xF0;
|
2444
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) < 0);
|
2445
|
+
l = 0; r = 0;
|
2446
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) == 0);
|
2447
|
+
l = 1; r = 0;
|
2448
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) > 0);
|
2449
|
+
l = 0xF0; r = 0;
|
2450
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) > 0);
|
2451
|
+
l = 0xF0; r = 0xF0;
|
2452
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) == 0);
|
2453
|
+
l = 0xF0-1;r = 0xF0;
|
2454
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) < 0);
|
2455
|
+
|
2456
|
+
// bit comp
|
2457
|
+
compFunc = getCompFunc(ft_set, len, eBitAnd, 0);
|
2458
|
+
l = 0xFF; r = 0xF0;
|
2459
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) == 0);
|
2460
|
+
l = 0xF0; r = 0xF;
|
2461
|
+
int v = compFunc((const char*)&l, (const char*)&r, len);
|
2462
|
+
BOOST_CHECK(v > 0);
|
2463
|
+
compFunc = getCompFunc(ft_set, len, eNotBitAnd, 0);
|
2464
|
+
l = 0xFF; r = 0xF0;
|
2465
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) == 0);
|
2466
|
+
}
|
2467
|
+
}
|
2468
|
+
|
2469
|
+
void testCompEnum()
|
2470
|
+
{
|
2471
|
+
for (ushort_td len = 1; len < 3; ++len)
|
2472
|
+
{
|
2473
|
+
comp1Func compFunc = getCompFunc(ft_enum, len, eEqual, 0);
|
2474
|
+
unsigned short l; unsigned short r;
|
2475
|
+
l = 0; r = USHRT_MAX; BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) < 0);
|
2476
|
+
l = 0; r = 0; BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) == 0);
|
2477
|
+
l = 1; r = 0; BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) > 0);
|
2478
|
+
l = USHRT_MAX; r = 0; BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) > 0);
|
2479
|
+
l = USHRT_MAX; r = USHRT_MAX; BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) == 0);
|
2480
|
+
l = USHRT_MAX-1;r = USHRT_MAX; BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) < 0);
|
2481
|
+
}
|
2482
|
+
}
|
2483
|
+
|
2484
|
+
void testCompYear()
|
2485
|
+
{
|
2486
|
+
ushort_td len = 1;
|
2487
|
+
comp1Func compFunc = getCompFunc(ft_myyear, len, eEqual, 0);
|
2488
|
+
unsigned char l; unsigned char r;
|
2489
|
+
l = 0; r = 0XFF; BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) < 0);
|
2490
|
+
l = 0; r = 0; BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) == 0);
|
2491
|
+
l = 0XFF; r = 0; BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) > 0);
|
2492
|
+
}
|
2493
|
+
|
2494
|
+
void testCompDate()
|
2495
|
+
{
|
2496
|
+
ushort_td len = 3;
|
2497
|
+
comp1Func compFunc = getCompFunc(ft_mydate, len, eEqual, 0);
|
2498
|
+
myDate ld, rd;
|
2499
|
+
int l, r;
|
2500
|
+
|
2501
|
+
ld = _T("1900-01-01"); rd = _T("1900-01-02"); l = ld.getValue(); r = rd.getValue();
|
2502
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) < 0);
|
2503
|
+
ld = _T("1900-01-01"); rd = _T("1900-01-01"); l = ld.getValue(); r = rd.getValue();
|
2504
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) == 0);
|
2505
|
+
ld = _T("1900-01-02"); rd = _T("1900-01-01"); l = ld.getValue(); r = rd.getValue();
|
2506
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) > 0);
|
2507
|
+
|
2508
|
+
}
|
2509
|
+
|
2510
|
+
void testCompTime()
|
2511
|
+
{
|
2512
|
+
__int64 l, r;
|
2513
|
+
{
|
2514
|
+
ushort_td len = 3;
|
2515
|
+
{
|
2516
|
+
comp1Func compFunc = getCompFunc(ft_mytime_num_cmp, len, eEqual, 0);
|
2517
|
+
myTime ld(0, false), rd(0, false);
|
2518
|
+
ld = _T("00:00:59"); rd = _T("16:59:00"); l = ld.getValue(); r = rd.getValue();
|
2519
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) < 0);
|
2520
|
+
ld = _T("00:00:01"); rd = _T("00:00:01"); l = ld.getValue(); r = rd.getValue();
|
2521
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) == 0);
|
2522
|
+
ld = _T("16:59:00"); rd = _T("00:00:59"); l = ld.getValue(); r = rd.getValue();
|
2523
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) > 0);
|
2524
|
+
}
|
2525
|
+
{
|
2526
|
+
comp1Func compFunc = getCompFunc(ft_mytime, len, eEqual, 0);
|
2527
|
+
myTime ld(0, true), rd(0, true);
|
2528
|
+
ld = _T("00:00:59"); rd = _T("16:59:00"); l = ld.getValue(); r = rd.getValue();
|
2529
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) < 0);
|
2530
|
+
ld = _T("00:00:01"); rd = _T("00:00:01"); l = ld.getValue(); r = rd.getValue();
|
2531
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) == 0);
|
2532
|
+
ld = _T("16:59:00"); rd = _T("00:00:59"); l = ld.getValue(); r = rd.getValue();
|
2533
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) > 0);
|
2534
|
+
}
|
2535
|
+
|
2536
|
+
len = 4;
|
2537
|
+
{
|
2538
|
+
comp1Func compFunc = getCompFunc(ft_mytime, len, eEqual, 0);
|
2539
|
+
myTime ld(1, true), rd(1, true);
|
2540
|
+
ld = _T("00:00:59.1"); rd = _T("00:00:59.2"); l = ld.getValue(); r = rd.getValue();
|
2541
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) < 0);
|
2542
|
+
ld = _T("00:00:59.1"); rd = _T("00:00:59.1"); l = ld.getValue(); r = rd.getValue();
|
2543
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) == 0);
|
2544
|
+
ld = _T("00:00:59.1"); rd = _T("00:00:59.0"); l = ld.getValue(); r = rd.getValue();
|
2545
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) > 0);
|
2546
|
+
}
|
2547
|
+
|
2548
|
+
{
|
2549
|
+
comp1Func compFunc = getCompFunc(ft_mytime, len, eEqual, 0);
|
2550
|
+
myTime ld(2, true), rd(2, true);
|
2551
|
+
ld = _T("00:00:59.01"); rd = _T("00:00:59.02"); l = ld.getValue(); r = rd.getValue();
|
2552
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) < 0);
|
2553
|
+
ld = _T("00:00:59.01"); rd = _T("00:00:59.01"); l = ld.getValue(); r = rd.getValue();
|
2554
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) == 0);
|
2555
|
+
ld = _T("00:00:59.01"); rd = _T("00:00:59.00"); l = ld.getValue(); r = rd.getValue();
|
2556
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) > 0);
|
2557
|
+
}
|
2558
|
+
|
2559
|
+
len = 5;
|
2560
|
+
{
|
2561
|
+
comp1Func compFunc = getCompFunc(ft_mytime, len, eEqual, 0);
|
2562
|
+
myTime ld(3, true), rd(3, true);
|
2563
|
+
ld = _T("00:00:59.001"); rd = _T("00:00:59.002"); l = ld.getValue(); r = rd.getValue();
|
2564
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) < 0);
|
2565
|
+
ld = _T("00:00:59.001"); rd = _T("00:00:59.001"); l = ld.getValue(); r = rd.getValue();
|
2566
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) == 0);
|
2567
|
+
ld = _T("00:00:59.001"); rd = _T("00:00:59.000"); l = ld.getValue(); r = rd.getValue();
|
2568
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) > 0);
|
2569
|
+
}
|
2570
|
+
|
2571
|
+
{
|
2572
|
+
comp1Func compFunc = getCompFunc(ft_mytime, len, eEqual, 0);
|
2573
|
+
myTime ld(4, true), rd(4, true);
|
2574
|
+
ld = _T("00:00:59.0000"); rd = _T("00:00:59.0001"); l = ld.getValue(); r = rd.getValue();
|
2575
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) < 0);
|
2576
|
+
ld = _T("00:00:59.0001"); rd = _T("00:00:59.0001"); l = ld.getValue(); r = rd.getValue();
|
2577
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) == 0);
|
2578
|
+
ld = _T("00:00:59.0001"); rd = _T("00:00:59.0000"); l = ld.getValue(); r = rd.getValue();
|
2579
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) > 0);
|
2580
|
+
}
|
2581
|
+
|
2582
|
+
len = 6;
|
2583
|
+
{
|
2584
|
+
comp1Func compFunc = getCompFunc(ft_mytime, len, eEqual, 0);
|
2585
|
+
myTime ld(5, true), rd(5, true);
|
2586
|
+
ld = _T("00:00:59.00001"); rd = _T("00:00:59.00002"); l = ld.getValue(); r = rd.getValue();
|
2587
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) < 0);
|
2588
|
+
ld = _T("00:00:59.00001"); rd = _T("00:00:59.00001"); l = ld.getValue(); r = rd.getValue();
|
2589
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) == 0);
|
2590
|
+
ld = _T("00:00:59.00001"); rd = _T("00:00:59.00000"); l = ld.getValue(); r = rd.getValue();
|
2591
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) > 0);
|
2592
|
+
}
|
2593
|
+
|
2594
|
+
{
|
2595
|
+
comp1Func compFunc = getCompFunc(ft_mytime, len, eEqual, 0);
|
2596
|
+
myTime ld(6, true), rd(6, true);
|
2597
|
+
ld = _T("01:00:59.999999"); rd = _T("10:00:59.100001"); l = ld.getValue(); r = rd.getValue();
|
2598
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) < 0);
|
2599
|
+
ld = _T("00:00:59.000001"); rd = _T("00:00:59.000001"); l = ld.getValue(); r = rd.getValue();
|
2600
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) == 0);
|
2601
|
+
ld = _T("10:00:59.000000"); rd = _T("10:00:58.999999"); l = ld.getValue(); r = rd.getValue();
|
2602
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) > 0);
|
2603
|
+
}
|
2604
|
+
}
|
2605
|
+
}
|
2606
|
+
|
2607
|
+
void testCompDateTime()
|
2608
|
+
{
|
2609
|
+
__int64 l, r;
|
2610
|
+
{
|
2611
|
+
ushort_td len = 5;
|
2612
|
+
{
|
2613
|
+
comp1Func compFunc = getCompFunc(ft_mydatetime, len, eEqual, 0);
|
2614
|
+
myDateTime ld(0, true), rd(0, true);
|
2615
|
+
ld = _T("1900-01-02 00:00:59"); rd = _T("1900-01-02 16:59:00"); l = ld.getValue(); r = rd.getValue();
|
2616
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) < 0);
|
2617
|
+
ld = _T("1900-01-02 00:00:01"); rd = _T("1900-01-02 00:00:01"); l = ld.getValue(); r = rd.getValue();
|
2618
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) == 0);
|
2619
|
+
ld = _T("1900-01-02 16:59:00"); rd = _T("1900-01-02 00:00:59"); l = ld.getValue(); r = rd.getValue();
|
2620
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) > 0);
|
2621
|
+
}
|
2622
|
+
|
2623
|
+
len = 6;
|
2624
|
+
{
|
2625
|
+
comp1Func compFunc = getCompFunc(ft_mydatetime, len, eEqual, 0);
|
2626
|
+
myDateTime ld(1, true), rd(1, true);
|
2627
|
+
ld = _T("1900-01-02 00:00:59.1"); rd = _T("1900-01-02 00:00:59.2"); l = ld.getValue(); r = rd.getValue();
|
2628
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) < 0);
|
2629
|
+
ld = _T("1900-01-02 00:00:59.1"); rd = _T("1900-01-02 00:00:59.1"); l = ld.getValue(); r = rd.getValue();
|
2630
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) == 0);
|
2631
|
+
ld = _T("1900-01-02 00:00:59.1"); rd = _T("1900-01-02 00:00:59.0"); l = ld.getValue(); r = rd.getValue();
|
2632
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) > 0);
|
2633
|
+
}
|
2634
|
+
|
2635
|
+
{
|
2636
|
+
comp1Func compFunc = getCompFunc(ft_mydatetime, len, eEqual, 0);
|
2637
|
+
myDateTime ld(2, true), rd(2, true);
|
2638
|
+
ld = _T("1900-01-02 00:00:59.01"); rd = _T("1900-01-02 00:00:59.02"); l = ld.getValue(); r = rd.getValue();
|
2639
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) < 0);
|
2640
|
+
ld = _T("1900-01-02 00:00:59.01"); rd = _T("1900-01-02 00:00:59.01"); l = ld.getValue(); r = rd.getValue();
|
2641
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) == 0);
|
2642
|
+
ld = _T("1900-01-02 00:00:59.01"); rd = _T("1900-01-02 00:00:59.00"); l = ld.getValue(); r = rd.getValue();
|
2643
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) > 0);
|
2644
|
+
}
|
2645
|
+
|
2646
|
+
len = 7;
|
2647
|
+
{
|
2648
|
+
comp1Func compFunc = getCompFunc(ft_mydatetime, len, eEqual, 0);
|
2649
|
+
myDateTime ld(3, true), rd(3, true);
|
2650
|
+
ld = _T("1900-01-02 00:00:59.001"); rd = _T("1900-01-02 00:00:59.002"); l = ld.getValue(); r = rd.getValue();
|
2651
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) < 0);
|
2652
|
+
ld = _T("1900-01-02 00:00:59.001"); rd = _T("1900-01-02 00:00:59.001"); l = ld.getValue(); r = rd.getValue();
|
2653
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) == 0);
|
2654
|
+
ld = _T("1900-01-02 00:00:59.001"); rd = _T("1900-01-02 00:00:59.000"); l = ld.getValue(); r = rd.getValue();
|
2655
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) > 0);
|
2656
|
+
}
|
2657
|
+
|
2658
|
+
{
|
2659
|
+
comp1Func compFunc = getCompFunc(ft_mydatetime, len, eEqual, 0);
|
2660
|
+
myDateTime ld(4, true), rd(4, true);
|
2661
|
+
ld = _T("1900-01-02 00:00:59.0000"); rd = _T("1900-01-02 00:00:59.0001"); l = ld.getValue(); r = rd.getValue();
|
2662
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) < 0);
|
2663
|
+
ld = _T("1900-01-02 00:00:59.0001"); rd = _T("1900-01-02 00:00:59.0001"); l = ld.getValue(); r = rd.getValue();
|
2664
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) == 0);
|
2665
|
+
ld = _T("1900-01-02 00:00:59.0001"); rd = _T("1900-01-02 00:00:59.0000"); l = ld.getValue(); r = rd.getValue();
|
2666
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) > 0);
|
2667
|
+
}
|
2668
|
+
|
2669
|
+
len = 8;
|
2670
|
+
{
|
2671
|
+
comp1Func compFunc = getCompFunc(ft_mydatetime, len, eEqual, 0);
|
2672
|
+
myDateTime ld(5, true), rd(5, true);
|
2673
|
+
ld = _T("1900-01-02 00:00:59.00001"); rd = _T("1900-01-02 00:00:59.00002"); l = ld.getValue(); r = rd.getValue();
|
2674
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) < 0);
|
2675
|
+
ld = _T("1900-01-02 00:00:59.00001"); rd = _T("1900-01-02 00:00:59.00001"); l = ld.getValue(); r = rd.getValue();
|
2676
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) == 0);
|
2677
|
+
ld = _T("1900-01-02 00:00:59.00001"); rd = _T("1900-01-02 00:00:59.00000"); l = ld.getValue(); r = rd.getValue();
|
2678
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) > 0);
|
2679
|
+
}
|
2680
|
+
|
2681
|
+
{
|
2682
|
+
comp1Func compFunc = getCompFunc(ft_mydatetime, len, eEqual, 0);
|
2683
|
+
myDateTime ld(6, true), rd(6, true);
|
2684
|
+
ld = _T("1900-01-02 01:00:59.999999"); rd = _T("1900-01-02 10:00:59.100001"); l = ld.getValue(); r = rd.getValue();
|
2685
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) < 0);
|
2686
|
+
ld = _T("1900-01-02 00:00:59.000001"); rd = _T("1900-01-02 00:00:59.000001"); l = ld.getValue(); r = rd.getValue();
|
2687
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) == 0);
|
2688
|
+
ld = _T("1900-01-02 10:00:59.000000"); rd = _T("1900-01-02 10:00:58.999999"); l = ld.getValue(); r = rd.getValue();
|
2689
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) > 0);
|
2690
|
+
}
|
2691
|
+
|
2692
|
+
{
|
2693
|
+
comp1Func compFunc = getCompFunc(ft_mydatetime_num_cmp, len, eEqual, 0);
|
2694
|
+
myDateTime ld(0, false), rd(0, false);
|
2695
|
+
ld = _T("1900-01-02 00:00:59"); rd = _T("1900-01-02 16:59:00"); l = ld.getValue(); r = rd.getValue();
|
2696
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) < 0);
|
2697
|
+
ld = _T("1900-01-02 00:00:01"); rd = _T("1900-01-02 00:00:01"); l = ld.getValue(); r = rd.getValue();
|
2698
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) == 0);
|
2699
|
+
ld = _T("1900-01-02 16:59:00"); rd = _T("1900-01-02 00:00:59"); l = ld.getValue(); r = rd.getValue();
|
2700
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) > 0);
|
2701
|
+
}
|
2702
|
+
}
|
2703
|
+
}
|
2704
|
+
|
2705
|
+
void testCompTimeStamp()
|
2706
|
+
{
|
2707
|
+
__int64 l, r;
|
2708
|
+
{
|
2709
|
+
ushort_td len = 4;
|
2710
|
+
{
|
2711
|
+
comp1Func compFunc = getCompFunc(ft_mytimestamp, len, eEqual, 0);
|
2712
|
+
myTimeStamp ld(0, true), rd(0, true);
|
2713
|
+
ld = _T("1970-01-02 00:00:59"); rd = _T("1970-01-02 16:59:00"); l = ld.getValue(); r = rd.getValue();
|
2714
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) < 0);
|
2715
|
+
ld = _T("1970-01-02 00:00:01"); rd = _T("1970-01-02 00:00:01"); l = ld.getValue(); r = rd.getValue();
|
2716
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) == 0);
|
2717
|
+
ld = _T("1970-01-02 16:59:00"); rd = _T("1970-01-02 00:00:59"); l = ld.getValue(); r = rd.getValue();
|
2718
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) > 0);
|
2719
|
+
}
|
2720
|
+
|
2721
|
+
{
|
2722
|
+
comp1Func compFunc = getCompFunc(ft_mytimestamp_num_cmp, len, eEqual, 0);
|
2723
|
+
myTimeStamp ld(0, false), rd(0, false);
|
2724
|
+
ld = _T("1970-01-02 00:00:59"); rd = _T("1970-01-02 16:59:00"); l = ld.getValue(); r = rd.getValue();
|
2725
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) < 0);
|
2726
|
+
ld = _T("1970-01-02 00:00:01"); rd = _T("1970-01-02 00:00:01"); l = ld.getValue(); r = rd.getValue();
|
2727
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) == 0);
|
2728
|
+
ld = _T("1970-01-02 16:59:00"); rd = _T("1970-01-02 00:00:59"); l = ld.getValue(); r = rd.getValue();
|
2729
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) > 0);
|
2730
|
+
}
|
2731
|
+
|
2732
|
+
len = 5;
|
2733
|
+
{
|
2734
|
+
comp1Func compFunc = getCompFunc(ft_mytimestamp, len, eEqual, 0);
|
2735
|
+
myTimeStamp ld(1, true), rd(1, true);
|
2736
|
+
ld = _T("1970-01-02 00:00:59.1"); rd = _T("1970-01-02 00:00:59.2"); l = ld.getValue(); r = rd.getValue();
|
2737
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) < 0);
|
2738
|
+
ld = _T("1970-01-02 00:00:59.1"); rd = _T("1970-01-02 00:00:59.1"); l = ld.getValue(); r = rd.getValue();
|
2739
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) == 0);
|
2740
|
+
ld = _T("1970-01-02 00:00:59.1"); rd = _T("1970-01-02 00:00:59.0"); l = ld.getValue(); r = rd.getValue();
|
2741
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) > 0);
|
2742
|
+
}
|
2743
|
+
|
2744
|
+
{
|
2745
|
+
comp1Func compFunc = getCompFunc(ft_mytimestamp, len, eEqual, 0);
|
2746
|
+
myTimeStamp ld(2, true), rd(2, true);
|
2747
|
+
ld = _T("1970-01-02 00:00:59.01"); rd = _T("1970-01-02 00:00:59.02"); l = ld.getValue(); r = rd.getValue();
|
2748
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) < 0);
|
2749
|
+
ld = _T("1970-01-02 00:00:59.01"); rd = _T("1970-01-02 00:00:59.01"); l = ld.getValue(); r = rd.getValue();
|
2750
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) == 0);
|
2751
|
+
ld = _T("1970-01-02 00:00:59.01"); rd = _T("1970-01-02 00:00:59.00"); l = ld.getValue(); r = rd.getValue();
|
2752
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) > 0);
|
2753
|
+
}
|
2754
|
+
|
2755
|
+
len = 6;
|
2756
|
+
{
|
2757
|
+
comp1Func compFunc = getCompFunc(ft_mytimestamp, len, eEqual, 0);
|
2758
|
+
myTimeStamp ld(3, true), rd(3, true);
|
2759
|
+
ld = _T("1970-01-02 00:00:59.001"); rd = _T("1970-01-02 00:00:59.002"); l = ld.getValue(); r = rd.getValue();
|
2760
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) < 0);
|
2761
|
+
ld = _T("1970-01-02 00:00:59.001"); rd = _T("1970-01-02 00:00:59.001"); l = ld.getValue(); r = rd.getValue();
|
2762
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) == 0);
|
2763
|
+
ld = _T("1970-01-02 00:00:59.001"); rd = _T("1970-01-02 00:00:59.000"); l = ld.getValue(); r = rd.getValue();
|
2764
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) > 0);
|
2765
|
+
}
|
2766
|
+
|
2767
|
+
{
|
2768
|
+
comp1Func compFunc = getCompFunc(ft_mytimestamp, len, eEqual, 0);
|
2769
|
+
myTimeStamp ld(4, true), rd(4, true);
|
2770
|
+
ld = _T("1970-01-02 00:00:59.0000"); rd = _T("1970-01-02 00:00:59.0001"); l = ld.getValue(); r = rd.getValue();
|
2771
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) < 0);
|
2772
|
+
ld = _T("1970-01-02 00:00:59.0001"); rd = _T("1970-01-02 00:00:59.0001"); l = ld.getValue(); r = rd.getValue();
|
2773
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) == 0);
|
2774
|
+
ld = _T("1970-01-02 00:00:59.0001"); rd = _T("1970-01-02 00:00:59.0000"); l = ld.getValue(); r = rd.getValue();
|
2775
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) > 0);
|
2776
|
+
}
|
2777
|
+
|
2778
|
+
len = 7;
|
2779
|
+
{
|
2780
|
+
comp1Func compFunc = getCompFunc(ft_mytimestamp, len, eEqual, 0);
|
2781
|
+
myTimeStamp ld(5, true), rd(5, true);
|
2782
|
+
ld = _T("1970-01-02 00:00:59.00001"); rd = _T("1970-01-02 00:00:59.00002"); l = ld.getValue(); r = rd.getValue();
|
2783
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) < 0);
|
2784
|
+
ld = _T("1970-01-02 00:00:59.00001"); rd = _T("1970-01-02 00:00:59.00001"); l = ld.getValue(); r = rd.getValue();
|
2785
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) == 0);
|
2786
|
+
ld = _T("1970-01-02 00:00:59.00001"); rd = _T("1970-01-02 00:00:59.00000"); l = ld.getValue(); r = rd.getValue();
|
2787
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) > 0);
|
2788
|
+
}
|
2789
|
+
|
2790
|
+
{
|
2791
|
+
comp1Func compFunc = getCompFunc(ft_mytimestamp, len, eEqual, 0);
|
2792
|
+
myTimeStamp ld(6, true), rd(6, true);
|
2793
|
+
ld = _T("1970-01-02 01:00:59.999999"); rd = _T("1970-01-02 10:00:59.100001"); l = ld.getValue(); r = rd.getValue();
|
2794
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) < 0);
|
2795
|
+
ld = _T("1970-01-02 00:00:59.000001"); rd = _T("1970-01-02 00:00:59.000001"); l = ld.getValue(); r = rd.getValue();
|
2796
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) == 0);
|
2797
|
+
ld = _T("1970-01-02 10:00:59.000000"); rd = _T("1970-01-02 10:00:58.999999"); l = ld.getValue(); r = rd.getValue();
|
2798
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) > 0);
|
2799
|
+
}
|
2800
|
+
}
|
2801
|
+
}
|
2802
|
+
|
2803
|
+
void testCompTimeMa()
|
2804
|
+
{
|
2805
|
+
__int64 l, r;
|
2806
|
+
{
|
2807
|
+
ushort_td len = 3;
|
2808
|
+
{
|
2809
|
+
comp1Func compFunc = getCompFunc(ft_mytime_num_cmp, len, eEqual, 0);
|
2810
|
+
maTime ld(0, false), rd(0, false);
|
2811
|
+
ld = _T("00:00:59"); rd = _T("16:59:00"); l = ld.getValue(); r = rd.getValue();
|
2812
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) < 0);
|
2813
|
+
ld = _T("00:00:01"); rd = _T("00:00:01"); l = ld.getValue(); r = rd.getValue();
|
2814
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) == 0);
|
2815
|
+
ld = _T("16:59:00"); rd = _T("00:00:59"); l = ld.getValue(); r = rd.getValue();
|
2816
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) > 0);
|
2817
|
+
}
|
2818
|
+
{
|
2819
|
+
comp1Func compFunc = getCompFunc(ft_mytime, len, eEqual, 0);
|
2820
|
+
maTime ld(0, true), rd(0, true);
|
2821
|
+
ld = _T("00:00:59"); rd = _T("16:59:00"); l = ld.getValue(); r = rd.getValue();
|
2822
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) < 0);
|
2823
|
+
ld = _T("00:00:01"); rd = _T("00:00:01"); l = ld.getValue(); r = rd.getValue();
|
2824
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) == 0);
|
2825
|
+
ld = _T("16:59:00"); rd = _T("00:00:59"); l = ld.getValue(); r = rd.getValue();
|
2826
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) > 0);
|
2827
|
+
}
|
2828
|
+
|
2829
|
+
len = 4;
|
2830
|
+
{
|
2831
|
+
comp1Func compFunc = getCompFunc(ft_mytime, len, eEqual, 0);
|
2832
|
+
maTime ld(1, true), rd(1, true);
|
2833
|
+
ld = _T("00:00:59.1"); rd = _T("00:00:59.2"); l = ld.getValue(); r = rd.getValue();
|
2834
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) < 0);
|
2835
|
+
ld = _T("00:00:59.1"); rd = _T("00:00:59.1"); l = ld.getValue(); r = rd.getValue();
|
2836
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) == 0);
|
2837
|
+
ld = _T("00:00:59.1"); rd = _T("00:00:59.0"); l = ld.getValue(); r = rd.getValue();
|
2838
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) > 0);
|
2839
|
+
}
|
2840
|
+
|
2841
|
+
{
|
2842
|
+
comp1Func compFunc = getCompFunc(ft_mytime, len, eEqual, 0);
|
2843
|
+
maTime ld(2, true), rd(2, true);
|
2844
|
+
ld = _T("00:00:59.01"); rd = _T("00:00:59.02"); l = ld.getValue(); r = rd.getValue();
|
2845
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) < 0);
|
2846
|
+
ld = _T("00:00:59.01"); rd = _T("00:00:59.01"); l = ld.getValue(); r = rd.getValue();
|
2847
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) == 0);
|
2848
|
+
ld = _T("00:00:59.01"); rd = _T("00:00:59.00"); l = ld.getValue(); r = rd.getValue();
|
2849
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) > 0);
|
2850
|
+
}
|
2851
|
+
|
2852
|
+
len = 5;
|
2853
|
+
{
|
2854
|
+
comp1Func compFunc = getCompFunc(ft_mytime, len, eEqual, 0);
|
2855
|
+
maTime ld(3, true), rd(3, true);
|
2856
|
+
ld = _T("00:00:59.001"); rd = _T("00:00:59.002"); l = ld.getValue(); r = rd.getValue();
|
2857
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) < 0);
|
2858
|
+
ld = _T("00:00:59.001"); rd = _T("00:00:59.001"); l = ld.getValue(); r = rd.getValue();
|
2859
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) == 0);
|
2860
|
+
ld = _T("00:00:59.001"); rd = _T("00:00:59.000"); l = ld.getValue(); r = rd.getValue();
|
2861
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) > 0);
|
2862
|
+
}
|
2863
|
+
|
2864
|
+
{
|
2865
|
+
comp1Func compFunc = getCompFunc(ft_mytime, len, eEqual, 0);
|
2866
|
+
maTime ld(4, true), rd(4, true);
|
2867
|
+
ld = _T("00:00:59.0000"); rd = _T("00:00:59.0001"); l = ld.getValue(); r = rd.getValue();
|
2868
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) < 0);
|
2869
|
+
ld = _T("00:00:59.0001"); rd = _T("00:00:59.0001"); l = ld.getValue(); r = rd.getValue();
|
2870
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) == 0);
|
2871
|
+
ld = _T("00:00:59.0001"); rd = _T("00:00:59.0000"); l = ld.getValue(); r = rd.getValue();
|
2872
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) > 0);
|
2873
|
+
}
|
2874
|
+
|
2875
|
+
len = 6;
|
2876
|
+
{
|
2877
|
+
comp1Func compFunc = getCompFunc(ft_mytime, len, eEqual, 0);
|
2878
|
+
maTime ld(5, true), rd(5, true);
|
2879
|
+
ld = _T("00:00:59.00001"); rd = _T("00:00:59.00002"); l = ld.getValue(); r = rd.getValue();
|
2880
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) < 0);
|
2881
|
+
ld = _T("00:00:59.00001"); rd = _T("00:00:59.00001"); l = ld.getValue(); r = rd.getValue();
|
2882
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) == 0);
|
2883
|
+
ld = _T("00:00:59.00001"); rd = _T("00:00:59.00000"); l = ld.getValue(); r = rd.getValue();
|
2884
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) > 0);
|
2885
|
+
}
|
2886
|
+
|
2887
|
+
{
|
2888
|
+
comp1Func compFunc = getCompFunc(ft_mytime, len, eEqual, 0);
|
2889
|
+
maTime ld(6, true), rd(6, true);
|
2890
|
+
ld = _T("01:00:59.999999"); rd = _T("10:00:59.100001"); l = ld.getValue(); r = rd.getValue();
|
2891
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) < 0);
|
2892
|
+
ld = _T("00:00:59.000001"); rd = _T("00:00:59.000001"); l = ld.getValue(); r = rd.getValue();
|
2893
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) == 0);
|
2894
|
+
ld = _T("10:00:59.000000"); rd = _T("10:00:58.999999"); l = ld.getValue(); r = rd.getValue();
|
2895
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) > 0);
|
2896
|
+
}
|
2897
|
+
}
|
2898
|
+
}
|
2899
|
+
|
2900
|
+
void testCompDateTimeMa()
|
2901
|
+
{
|
2902
|
+
__int64 l, r;
|
2903
|
+
{
|
2904
|
+
ushort_td len = 5;
|
2905
|
+
{
|
2906
|
+
comp1Func compFunc = getCompFunc(ft_mydatetime, len, eEqual, 0);
|
2907
|
+
maDateTime ld(0, true), rd(0, true);
|
2908
|
+
ld = _T("1900-01-02 00:00:59"); rd = _T("1900-01-02 16:59:00"); l = ld.getValue(); r = rd.getValue();
|
2909
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) < 0);
|
2910
|
+
ld = _T("1900-01-02 00:00:01"); rd = _T("1900-01-02 00:00:01"); l = ld.getValue(); r = rd.getValue();
|
2911
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) == 0);
|
2912
|
+
ld = _T("1900-01-02 16:59:00"); rd = _T("1900-01-02 00:00:59"); l = ld.getValue(); r = rd.getValue();
|
2913
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) > 0);
|
2914
|
+
}
|
2915
|
+
|
2916
|
+
len = 6;
|
2917
|
+
{
|
2918
|
+
comp1Func compFunc = getCompFunc(ft_mydatetime, len, eEqual, 0);
|
2919
|
+
maDateTime ld(1, true), rd(1, true);
|
2920
|
+
ld = _T("1900-01-02 00:00:59.1"); rd = _T("1900-01-02 00:00:59.2"); l = ld.getValue(); r = rd.getValue();
|
2921
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) < 0);
|
2922
|
+
ld = _T("1900-01-02 00:00:59.1"); rd = _T("1900-01-02 00:00:59.1"); l = ld.getValue(); r = rd.getValue();
|
2923
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) == 0);
|
2924
|
+
ld = _T("1900-01-02 00:00:59.1"); rd = _T("1900-01-02 00:00:59.0"); l = ld.getValue(); r = rd.getValue();
|
2925
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) > 0);
|
2926
|
+
}
|
2927
|
+
|
2928
|
+
{
|
2929
|
+
comp1Func compFunc = getCompFunc(ft_mydatetime, len, eEqual, 0);
|
2930
|
+
maDateTime ld(2, true), rd(2, true);
|
2931
|
+
ld = _T("1900-01-02 00:00:59.01"); rd = _T("1900-01-02 00:00:59.02"); l = ld.getValue(); r = rd.getValue();
|
2932
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) < 0);
|
2933
|
+
ld = _T("1900-01-02 00:00:59.01"); rd = _T("1900-01-02 00:00:59.01"); l = ld.getValue(); r = rd.getValue();
|
2934
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) == 0);
|
2935
|
+
ld = _T("1900-01-02 00:00:59.01"); rd = _T("1900-01-02 00:00:59.00"); l = ld.getValue(); r = rd.getValue();
|
2936
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) > 0);
|
2937
|
+
}
|
2938
|
+
|
2939
|
+
len = 7;
|
2940
|
+
{
|
2941
|
+
comp1Func compFunc = getCompFunc(ft_mydatetime, len, eEqual, 0);
|
2942
|
+
maDateTime ld(3, true), rd(3, true);
|
2943
|
+
ld = _T("1900-01-02 00:00:59.001"); rd = _T("1900-01-02 00:00:59.002"); l = ld.getValue(); r = rd.getValue();
|
2944
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) < 0);
|
2945
|
+
ld = _T("1900-01-02 00:00:59.001"); rd = _T("1900-01-02 00:00:59.001"); l = ld.getValue(); r = rd.getValue();
|
2946
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) == 0);
|
2947
|
+
ld = _T("1900-01-02 00:00:59.001"); rd = _T("1900-01-02 00:00:59.000"); l = ld.getValue(); r = rd.getValue();
|
2948
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) > 0);
|
2949
|
+
}
|
2950
|
+
|
2951
|
+
{
|
2952
|
+
comp1Func compFunc = getCompFunc(ft_mydatetime, len, eEqual, 0);
|
2953
|
+
maDateTime ld(4, true), rd(4, true);
|
2954
|
+
ld = _T("1900-01-02 00:00:59.0000"); rd = _T("1900-01-02 00:00:59.0001"); l = ld.getValue(); r = rd.getValue();
|
2955
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) < 0);
|
2956
|
+
ld = _T("1900-01-02 00:00:59.0001"); rd = _T("1900-01-02 00:00:59.0001"); l = ld.getValue(); r = rd.getValue();
|
2957
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) == 0);
|
2958
|
+
ld = _T("1900-01-02 00:00:59.0001"); rd = _T("1900-01-02 00:00:59.0000"); l = ld.getValue(); r = rd.getValue();
|
2959
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) > 0);
|
2960
|
+
}
|
2961
|
+
|
2962
|
+
len = 8;
|
2963
|
+
{
|
2964
|
+
comp1Func compFunc = getCompFunc(ft_mydatetime, len, eEqual, 0);
|
2965
|
+
maDateTime ld(5, true), rd(5, true);
|
2966
|
+
ld = _T("1900-01-02 00:00:59.00001"); rd = _T("1900-01-02 00:00:59.00002"); l = ld.getValue(); r = rd.getValue();
|
2967
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) < 0);
|
2968
|
+
ld = _T("1900-01-02 00:00:59.00001"); rd = _T("1900-01-02 00:00:59.00001"); l = ld.getValue(); r = rd.getValue();
|
2969
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) == 0);
|
2970
|
+
ld = _T("1900-01-02 00:00:59.00001"); rd = _T("1900-01-02 00:00:59.00000"); l = ld.getValue(); r = rd.getValue();
|
2971
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) > 0);
|
2972
|
+
}
|
2973
|
+
|
2974
|
+
{
|
2975
|
+
comp1Func compFunc = getCompFunc(ft_mydatetime, len, eEqual, 0);
|
2976
|
+
maDateTime ld(6, true), rd(6, true);
|
2977
|
+
ld = _T("1900-01-02 01:00:59.999999"); rd = _T("1900-01-02 10:00:59.100001"); l = ld.getValue(); r = rd.getValue();
|
2978
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) < 0);
|
2979
|
+
ld = _T("1900-01-02 00:00:59.000001"); rd = _T("1900-01-02 00:00:59.000001"); l = ld.getValue(); r = rd.getValue();
|
2980
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) == 0);
|
2981
|
+
ld = _T("1900-01-02 10:00:59.000000"); rd = _T("1900-01-02 10:00:58.999999"); l = ld.getValue(); r = rd.getValue();
|
2982
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) > 0);
|
2983
|
+
}
|
2984
|
+
|
2985
|
+
{
|
2986
|
+
comp1Func compFunc = getCompFunc(ft_mydatetime_num_cmp, len, eEqual, 0);
|
2987
|
+
maDateTime ld(0, false), rd(0, false);
|
2988
|
+
ld = _T("1900-01-02 00:00:59"); rd = _T("1900-01-02 16:59:00"); l = ld.getValue(); r = rd.getValue();
|
2989
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) < 0);
|
2990
|
+
ld = _T("1900-01-02 00:00:01"); rd = _T("1900-01-02 00:00:01"); l = ld.getValue(); r = rd.getValue();
|
2991
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) == 0);
|
2992
|
+
ld = _T("1900-01-02 16:59:00"); rd = _T("1900-01-02 00:00:59"); l = ld.getValue(); r = rd.getValue();
|
2993
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) > 0);
|
2994
|
+
}
|
2995
|
+
}
|
2996
|
+
}
|
2997
|
+
|
2998
|
+
void testCompTimeStampMa()
|
2999
|
+
{
|
3000
|
+
__int64 l, r;
|
3001
|
+
{
|
3002
|
+
ushort_td len = 4;
|
3003
|
+
{
|
3004
|
+
comp1Func compFunc = getCompFunc(ft_mytimestamp, len, eEqual, 0);
|
3005
|
+
maTimeStamp ld(0, true), rd(0, true);
|
3006
|
+
ld = _T("1970-01-02 00:00:59"); rd = _T("1970-01-02 16:59:00"); l = ld.getValue(); r = rd.getValue();
|
3007
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) < 0);
|
3008
|
+
ld = _T("1970-01-02 00:00:01"); rd = _T("1970-01-02 00:00:01"); l = ld.getValue(); r = rd.getValue();
|
3009
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) == 0);
|
3010
|
+
ld = _T("1970-01-02 16:59:00"); rd = _T("1970-01-02 00:00:59"); l = ld.getValue(); r = rd.getValue();
|
3011
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) > 0);
|
3012
|
+
}
|
3013
|
+
|
3014
|
+
{
|
3015
|
+
comp1Func compFunc = getCompFunc(ft_mytimestamp_num_cmp, len, eEqual, 0);
|
3016
|
+
maTimeStamp ld(0, false), rd(0, false);
|
3017
|
+
ld = _T("1970-01-02 00:00:59"); rd = _T("1970-01-02 16:59:00"); l = ld.getValue(); r = rd.getValue();
|
3018
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) < 0);
|
3019
|
+
ld = _T("1970-01-02 00:00:01"); rd = _T("1970-01-02 00:00:01"); l = ld.getValue(); r = rd.getValue();
|
3020
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) == 0);
|
3021
|
+
ld = _T("1970-01-02 16:59:00"); rd = _T("1970-01-02 00:00:59"); l = ld.getValue(); r = rd.getValue();
|
3022
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) > 0);
|
3023
|
+
}
|
3024
|
+
|
3025
|
+
len = 5;
|
3026
|
+
{
|
3027
|
+
comp1Func compFunc = getCompFunc(ft_mytimestamp, len, eEqual, 0);
|
3028
|
+
maTimeStamp ld(1, true), rd(1, true);
|
3029
|
+
ld = _T("1970-01-02 00:00:59.1"); rd = _T("1970-01-02 00:00:59.2"); l = ld.getValue(); r = rd.getValue();
|
3030
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) < 0);
|
3031
|
+
ld = _T("1970-01-02 00:00:59.1"); rd = _T("1970-01-02 00:00:59.1"); l = ld.getValue(); r = rd.getValue();
|
3032
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) == 0);
|
3033
|
+
ld = _T("1970-01-02 00:00:59.1"); rd = _T("1970-01-02 00:00:59.0"); l = ld.getValue(); r = rd.getValue();
|
3034
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) > 0);
|
3035
|
+
}
|
3036
|
+
|
3037
|
+
{
|
3038
|
+
comp1Func compFunc = getCompFunc(ft_mytimestamp, len, eEqual, 0);
|
3039
|
+
maTimeStamp ld(2, true), rd(2, true);
|
3040
|
+
ld = _T("1970-01-02 00:00:59.01"); rd = _T("1970-01-02 00:00:59.02"); l = ld.getValue(); r = rd.getValue();
|
3041
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) < 0);
|
3042
|
+
ld = _T("1970-01-02 00:00:59.01"); rd = _T("1970-01-02 00:00:59.01"); l = ld.getValue(); r = rd.getValue();
|
3043
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) == 0);
|
3044
|
+
ld = _T("1970-01-02 00:00:59.01"); rd = _T("1970-01-02 00:00:59.00"); l = ld.getValue(); r = rd.getValue();
|
3045
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) > 0);
|
3046
|
+
}
|
3047
|
+
|
3048
|
+
len = 6;
|
3049
|
+
{
|
3050
|
+
comp1Func compFunc = getCompFunc(ft_mytimestamp, len, eEqual, 0);
|
3051
|
+
maTimeStamp ld(3, true), rd(3, true);
|
3052
|
+
ld = _T("1970-01-02 00:00:59.001"); rd = _T("1970-01-02 00:00:59.002"); l = ld.getValue(); r = rd.getValue();
|
3053
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) < 0);
|
3054
|
+
ld = _T("1970-01-02 00:00:59.001"); rd = _T("1970-01-02 00:00:59.001"); l = ld.getValue(); r = rd.getValue();
|
3055
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) == 0);
|
3056
|
+
ld = _T("1970-01-02 00:00:59.001"); rd = _T("1970-01-02 00:00:59.000"); l = ld.getValue(); r = rd.getValue();
|
3057
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) > 0);
|
3058
|
+
}
|
3059
|
+
|
3060
|
+
{
|
3061
|
+
comp1Func compFunc = getCompFunc(ft_mytimestamp, len, eEqual, 0);
|
3062
|
+
maTimeStamp ld(4, true), rd(4, true);
|
3063
|
+
ld = _T("1970-01-02 00:00:59.0000"); rd = _T("1970-01-02 00:00:59.0001"); l = ld.getValue(); r = rd.getValue();
|
3064
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) == -1);
|
3065
|
+
ld = _T("1970-01-02 00:00:59.0001"); rd = _T("1970-01-02 00:00:59.0001"); l = ld.getValue(); r = rd.getValue();
|
3066
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) == 0);
|
3067
|
+
ld = _T("1970-01-02 00:00:59.0001"); rd = _T("1970-01-02 00:00:59.0000"); l = ld.getValue(); r = rd.getValue();
|
3068
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) > 0);
|
3069
|
+
}
|
3070
|
+
|
3071
|
+
len = 7;
|
3072
|
+
{
|
3073
|
+
comp1Func compFunc = getCompFunc(ft_mytimestamp, len, eEqual, 0);
|
3074
|
+
maTimeStamp ld(5, true), rd(5, true);
|
3075
|
+
ld = _T("1970-01-02 00:00:59.00001"); rd = _T("1970-01-02 00:00:59.00002"); l = ld.getValue(); r = rd.getValue();
|
3076
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) == -1);
|
3077
|
+
ld = _T("1970-01-02 00:00:59.00001"); rd = _T("1970-01-02 00:00:59.00001"); l = ld.getValue(); r = rd.getValue();
|
3078
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) == 0);
|
3079
|
+
ld = _T("1970-01-02 00:00:59.00001"); rd = _T("1970-01-02 00:00:59.00000"); l = ld.getValue(); r = rd.getValue();
|
3080
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) > 0);
|
3081
|
+
}
|
3082
|
+
|
3083
|
+
{
|
3084
|
+
comp1Func compFunc = getCompFunc(ft_mytimestamp, len, eEqual, 0);
|
3085
|
+
maTimeStamp ld(6, true), rd(6, true);
|
3086
|
+
ld = _T("1970-01-02 01:00:59.999999"); rd = _T("1970-01-02 10:00:59.100001"); l = ld.getValue(); r = rd.getValue();
|
3087
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) == -1);
|
3088
|
+
ld = _T("1970-01-02 00:00:59.000001"); rd = _T("1970-01-02 00:00:59.000001"); l = ld.getValue(); r = rd.getValue();
|
3089
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) == 0);
|
3090
|
+
ld = _T("1970-01-02 10:00:59.000000"); rd = _T("1970-01-02 10:00:58.999999"); l = ld.getValue(); r = rd.getValue();
|
3091
|
+
BOOST_CHECK(compFunc((const char*)&l, (const char*)&r, len) > 0);
|
3092
|
+
}
|
3093
|
+
}
|
3094
|
+
}
|
3095
|
+
|
3096
|
+
void doTestCompStringOne(const char* lt , const char* rt, int ret, int len,
|
3097
|
+
int sizeByte, comp1Func compFunc)
|
3098
|
+
{
|
3099
|
+
char l[128] = {0x00};
|
3100
|
+
char r[128] = {0x00};
|
3101
|
+
strcpy(l + sizeByte, lt); strcpy(r + sizeByte, rt);
|
3102
|
+
if (sizeByte)
|
3103
|
+
{
|
3104
|
+
l[0] = (char)strlen(lt);
|
3105
|
+
r[0] = (char)len;
|
3106
|
+
}
|
3107
|
+
int v = compFunc((const char*)l, (const char*)r, len);
|
3108
|
+
if (ret > 0)
|
3109
|
+
BOOST_CHECK( v > 0);
|
3110
|
+
else if (ret == 0)
|
3111
|
+
BOOST_CHECK( v == 0);
|
3112
|
+
else
|
3113
|
+
BOOST_CHECK( v < 0);
|
3114
|
+
}
|
3115
|
+
|
3116
|
+
void doTestCompString(uchar_td type, int sizeByte)
|
3117
|
+
{
|
3118
|
+
uchar_td logType = eEqual;
|
3119
|
+
ushort_td len = 2;
|
3120
|
+
comp1Func compFunc = getCompFunc(type, 0, logType, sizeByte);
|
3121
|
+
doTestCompStringOne("abcc", "ac", -1, len, sizeByte, compFunc);
|
3122
|
+
doTestCompStringOne("a", "ac", -1, len, sizeByte, compFunc);
|
3123
|
+
doTestCompStringOne("ab99", "abcc", 0, len, sizeByte, compFunc);
|
3124
|
+
doTestCompStringOne("accc", "ab0", 1, len, sizeByte, compFunc);
|
3125
|
+
|
3126
|
+
logType |= CMPLOGICAL_CASEINSENSITIVE;
|
3127
|
+
compFunc = getCompFunc(type, 0, logType, sizeByte);
|
3128
|
+
|
3129
|
+
doTestCompStringOne("Abc", "ac", -1, len, sizeByte, compFunc);
|
3130
|
+
doTestCompStringOne("Abc", "aBc", 0, len, sizeByte, compFunc);
|
3131
|
+
doTestCompStringOne("acc", "Abc", 1, len, sizeByte, compFunc);
|
3132
|
+
|
3133
|
+
logType = eEqual | CMPLOGICAL_VAR_COMP_ALL;
|
3134
|
+
compFunc = getCompFunc(type, 0, logType, sizeByte);
|
3135
|
+
doTestCompStringOne("ab", "ac", -1, len, sizeByte, compFunc);
|
3136
|
+
doTestCompStringOne("ab", "ab", 0, len, sizeByte, compFunc);
|
3137
|
+
doTestCompStringOne("ac", "ab", 1, len, sizeByte, compFunc);
|
3138
|
+
|
3139
|
+
|
3140
|
+
logType |= CMPLOGICAL_CASEINSENSITIVE;
|
3141
|
+
compFunc = getCompFunc(type, 0, logType, sizeByte);
|
3142
|
+
doTestCompStringOne("Ab", "ac", -1, len, sizeByte, compFunc);
|
3143
|
+
doTestCompStringOne("Ab", "aB", 0, len, sizeByte, compFunc);
|
3144
|
+
doTestCompStringOne("ac", "Ab", 1, len, sizeByte, compFunc);
|
3145
|
+
|
3146
|
+
}
|
3147
|
+
|
3148
|
+
void testCompString()
|
3149
|
+
{
|
3150
|
+
doTestCompString(ft_mychar, 0);
|
3151
|
+
doTestCompString(ft_string, 0);
|
3152
|
+
doTestCompString(ft_zstring, 0);
|
3153
|
+
doTestCompString(ft_note, 0);
|
3154
|
+
doTestCompString(ft_myvarchar, 1);
|
3155
|
+
doTestCompString(ft_myvarchar, 2);
|
3156
|
+
doTestCompString(ft_myvarbinary, 1);
|
3157
|
+
doTestCompString(ft_myvarbinary, 2);
|
3158
|
+
doTestCompString(ft_lstring, 1);
|
3159
|
+
doTestCompString(ft_lstring, 2);
|
3160
|
+
}
|
3161
|
+
|
3162
|
+
#ifdef _WIN32
|
3163
|
+
void doTestCompWStringOne(const wchar_t* lt , const wchar_t* rt, int ret, int len,
|
3164
|
+
int sizeByte, comp1Func compFunc)
|
3165
|
+
{
|
3166
|
+
char l[128] = {0x00};
|
3167
|
+
char r[128] = {0x00};
|
3168
|
+
wcscpy((wchar_t*)(l + sizeByte), lt); wcscpy((wchar_t*)(r + sizeByte), rt);
|
3169
|
+
|
3170
|
+
if (sizeByte)
|
3171
|
+
{
|
3172
|
+
l[0] = (char)wcslen(lt) * 2;
|
3173
|
+
r[0] = (char)len;
|
3174
|
+
}
|
3175
|
+
int v = compFunc((const char*)l, (const char*)r, len);
|
3176
|
+
if (ret > 0)
|
3177
|
+
BOOST_CHECK( v > 0);
|
3178
|
+
else if (ret == 0)
|
3179
|
+
BOOST_CHECK( v == 0);
|
3180
|
+
else
|
3181
|
+
BOOST_CHECK( v < 0);
|
3182
|
+
}
|
3183
|
+
|
3184
|
+
void doTestCompWString(uchar_td type, int sizeByte)
|
3185
|
+
{
|
3186
|
+
uchar_td logType = eEqual;
|
3187
|
+
ushort_td len = 4;
|
3188
|
+
comp1Func compFunc = getCompFunc(type, 0, logType, sizeByte);
|
3189
|
+
doTestCompWStringOne(L"abcc", L"ac", -1, len, sizeByte, compFunc);
|
3190
|
+
doTestCompWStringOne(L"a", L"ac", -1, len, sizeByte, compFunc);
|
3191
|
+
doTestCompWStringOne(L"ab99", L"abcc", 0, len, sizeByte, compFunc);
|
3192
|
+
doTestCompWStringOne(L"accc", L"ab0", 1, len, sizeByte, compFunc);
|
3193
|
+
|
3194
|
+
logType |= CMPLOGICAL_CASEINSENSITIVE;
|
3195
|
+
compFunc = getCompFunc(type, 0, logType, sizeByte);
|
3196
|
+
|
3197
|
+
doTestCompWStringOne(L"Abc", L"ac", -1, len, sizeByte, compFunc);
|
3198
|
+
doTestCompWStringOne(L"Abc", L"aBc", 0, len, sizeByte, compFunc);
|
3199
|
+
doTestCompWStringOne(L"acc", L"Abc", 1, len, sizeByte, compFunc);
|
3200
|
+
|
3201
|
+
logType = eEqual | CMPLOGICAL_VAR_COMP_ALL;
|
3202
|
+
compFunc = getCompFunc(type, 0, logType, sizeByte);
|
3203
|
+
doTestCompWStringOne(L"ab", L"ac", -1, len, sizeByte, compFunc);
|
3204
|
+
doTestCompWStringOne(L"ab", L"ab", 0, len, sizeByte, compFunc);
|
3205
|
+
doTestCompWStringOne(L"ac", L"ab", 1, len, sizeByte, compFunc);
|
3206
|
+
|
3207
|
+
|
3208
|
+
logType |= CMPLOGICAL_CASEINSENSITIVE;
|
3209
|
+
compFunc = getCompFunc(type, 0, logType, sizeByte);
|
3210
|
+
doTestCompWStringOne(L"Ab", L"ac", -1, len, sizeByte, compFunc);
|
3211
|
+
doTestCompWStringOne(L"Ab", L"aB", 0, len, sizeByte, compFunc);
|
3212
|
+
doTestCompWStringOne(L"ac", L"Ab", 1, len, sizeByte, compFunc);
|
3213
|
+
|
3214
|
+
}
|
3215
|
+
|
3216
|
+
void testCompWString()
|
3217
|
+
{
|
3218
|
+
doTestCompWString(ft_mywchar, 0);
|
3219
|
+
doTestCompWString(ft_wstring, 0);
|
3220
|
+
doTestCompWString(ft_wzstring, 0);
|
3221
|
+
doTestCompWString(ft_mywvarchar, 1);
|
3222
|
+
doTestCompWString(ft_mywvarchar, 2);
|
3223
|
+
doTestCompWString(ft_mywvarbinary, 1);
|
3224
|
+
doTestCompWString(ft_mywvarbinary, 2);
|
3225
|
+
}
|
3226
|
+
|
3227
|
+
#endif
|
3228
|
+
|
3229
|
+
|
3230
|
+
|
3231
|
+
void doTestCompBlobOne(const char* lt , const char* rt, int ret, int len,
|
3232
|
+
int sizeByte, comp1Func compFunc)
|
3233
|
+
{
|
3234
|
+
char l[128] = {0x00};
|
3235
|
+
char lb[128] = {0x00};
|
3236
|
+
char r[128] = {0x00};
|
3237
|
+
strcpy(lb, lt); strcpy(r + sizeByte, rt);
|
3238
|
+
l[0] = (char)strlen(lt);
|
3239
|
+
char** p = (char**)(l + sizeByte);
|
3240
|
+
*p = lb;
|
3241
|
+
|
3242
|
+
r[0] = (char)len;
|
3243
|
+
int v = compFunc((const char*)l, (const char*)r, len);
|
3244
|
+
if (ret > 0)
|
3245
|
+
BOOST_CHECK( v > 0);
|
3246
|
+
else if (ret == 0)
|
3247
|
+
BOOST_CHECK( v == 0);
|
3248
|
+
else
|
3249
|
+
BOOST_CHECK( v < 0);
|
3250
|
+
}
|
3251
|
+
|
3252
|
+
void doTestCompBlob(uchar_td type, int sizeByte)
|
3253
|
+
{
|
3254
|
+
uchar_td logType = eEqual;
|
3255
|
+
ushort_td len = 2;
|
3256
|
+
comp1Func compFunc = getCompFunc(type, 0, logType, sizeByte);
|
3257
|
+
doTestCompBlobOne("abcc", "ac", -1, len, sizeByte, compFunc);
|
3258
|
+
doTestCompBlobOne("a", "ac", -1, len, sizeByte, compFunc);
|
3259
|
+
doTestCompBlobOne("ab99", "abcc", 0, len, sizeByte, compFunc);
|
3260
|
+
doTestCompBlobOne("accc", "ab0", 1, len, sizeByte, compFunc);
|
3261
|
+
|
3262
|
+
logType |= CMPLOGICAL_CASEINSENSITIVE;
|
3263
|
+
compFunc = getCompFunc(type, 0, logType, sizeByte);
|
3264
|
+
|
3265
|
+
doTestCompBlobOne("Abc", "ac", -1, len, sizeByte, compFunc);
|
3266
|
+
doTestCompBlobOne("Abc", "aBc", 0, len, sizeByte, compFunc);
|
3267
|
+
doTestCompBlobOne("acc", "Abc", 1, len, sizeByte, compFunc);
|
3268
|
+
|
3269
|
+
logType = eEqual | CMPLOGICAL_VAR_COMP_ALL;
|
3270
|
+
compFunc = getCompFunc(type, 0, logType, sizeByte);
|
3271
|
+
doTestCompBlobOne("ab", "ac", -1, len, sizeByte, compFunc);
|
3272
|
+
doTestCompBlobOne("ab", "ab", 0, len, sizeByte, compFunc);
|
3273
|
+
doTestCompBlobOne("ac", "ab", 1, len, sizeByte, compFunc);
|
3274
|
+
|
3275
|
+
|
3276
|
+
logType |= CMPLOGICAL_CASEINSENSITIVE;
|
3277
|
+
compFunc = getCompFunc(type, 0, logType, sizeByte);
|
3278
|
+
doTestCompBlobOne("Ab", "ac", -1, len, sizeByte, compFunc);
|
3279
|
+
doTestCompBlobOne("Ab", "aB", 0, len, sizeByte, compFunc);
|
3280
|
+
doTestCompBlobOne("ac", "Ab", 1, len, sizeByte, compFunc);
|
3281
|
+
|
3282
|
+
}
|
3283
|
+
|
3284
|
+
void testCompBlob()
|
3285
|
+
{
|
3286
|
+
doTestCompBlob(ft_mytext, 1);
|
3287
|
+
doTestCompBlob(ft_mytext, 2);
|
3288
|
+
doTestCompBlob(ft_mytext, 3);
|
3289
|
+
doTestCompBlob(ft_mytext, 4);
|
3290
|
+
doTestCompBlob(ft_myblob, 1);
|
3291
|
+
doTestCompBlob(ft_myblob, 2);
|
3292
|
+
doTestCompBlob(ft_myblob, 3);
|
3293
|
+
doTestCompBlob(ft_myblob, 4);
|
3294
|
+
}
|
3295
|
+
|
3296
|
+
void testCompDecimal()
|
3297
|
+
{
|
3298
|
+
comp1Func compFunc = getCompFunc(ft_mydecimal, 0, 0, 0);
|
3299
|
+
BOOST_CHECK(compFunc != NULL);
|
3300
|
+
|
3301
|
+
}
|
3302
|
+
|
3303
|
+
#pragma warning(default : 4996)
|
3304
|
+
|
3305
|
+
#endif // BZS_TEST_TRDCLENGN_TESTFIELD_H
|