1/* 2 * Copyright (C) 2021 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' 16import dataRdb from '@ohos.data.rdb'; 17 18const TAG = "[RDB_JSKITS _TEST]" 19const CREATE_TABLE_ALL_DATA_TYPE_SQL = "CREATE TABLE IF NOT EXISTS AllDataType " 20+ "(id INTEGER PRIMARY KEY AUTOINCREMENT, " 21+ "integerValue INTEGER , longValue INTEGER , shortValue INTEGER , booleanValue INTEGER , " 22+ "doubleValue REAL , floatValue REAL , stringValue TEXT , blobValue BLOB , clobValue TEXT , " 23+ "byteValue INTEGER , dateValue INTEGER , timeValue INTEGER , timestampValue INTEGER , " 24+ "calendarValue INTEGER , characterValue TEXT , primIntValue INTEGER , primLongValue INTEGER , " 25+ "primShortValue INTEGER , primFloatValue REAL , primDoubleValue REAL , " 26+ "primBooleanValue INTEGER , primByteValue INTEGER , primCharValue TEXT, `order` INTEGER);"; 27 28const STORE_CONFIG = { 29 name: "Predicates.db", 30} 31var rdbStore = undefined; 32var DOUBLE_MAX = 9223372036854775807; 33describe('rdbPredicatesTest', function () { 34 beforeAll(async function () { 35 console.info(TAG + 'beforeAll') 36 rdbStore = await dataRdb.getRdbStore(STORE_CONFIG, 1); 37 await rdbStore.executeSql(CREATE_TABLE_ALL_DATA_TYPE_SQL, null); 38 await buildAllDataType1(); 39 await buildAllDataType2(); 40 await buildAllDataType3(); 41 }) 42 43 beforeEach(function () { 44 console.info(TAG + 'beforeEach') 45 }) 46 47 afterEach(function () { 48 console.info(TAG + 'afterEach') 49 }) 50 51 afterAll(async function () { 52 console.info(TAG + 'afterAll') 53 rdbStore = null 54 await dataRdb.deleteRdbStore("Predicates.db"); 55 }) 56 57 function resultSize(resultSet) { 58 if (!resultSet.goToFirstRow()) { 59 return 0; 60 } 61 let count = 1; 62 while (resultSet.goToNextRow()) { 63 count++; 64 } 65 return count; 66 } 67 68 async function buildAllDataType1() { 69 console.log(TAG + "buildAllDataType1 start"); 70 { 71 var u8 = new Uint8Array([1, 2, 3]) 72 const valueBucket = { 73 "integerValue": 2147483647, 74 "doubleValue": DOUBLE_MAX, 75 "booleanValue": true, 76 "floatValue": -0.123, 77 "longValue": 9223372036854775807, 78 "shortValue": 32767, 79 "characterValue": ' ', 80 "stringValue": "ABCDEFGHIJKLMN", 81 "blobValue": u8, 82 "byteValue": 127, 83 } 84 await rdbStore.insert("AllDataType", valueBucket) 85 } 86 } 87 88 async function buildAllDataType2() { 89 console.log(TAG + "buildAllDataType2 start"); 90 { 91 var u8 = new Uint8Array([1, 2, 3]) 92 const valueBucket = { 93 "integerValue": 1, 94 "doubleValue": 1.0, 95 "booleanValue": false, 96 "floatValue": 1.0, 97 "longValue": 1, 98 "shortValue": 1, 99 "characterValue": '中', 100 "stringValue": "ABCDEFGHIJKLMN", 101 "blobValue": u8, 102 "byteValue": 1, 103 } 104 await rdbStore.insert("AllDataType", valueBucket) 105 } 106 } 107 108 async function buildAllDataType3() { 109 console.log(TAG + "buildAllDataType3 start"); 110 { 111 var u8 = new Uint8Array([1, 2, 3]) 112 const valueBucket = { 113 "integerValue": -2147483648, 114 "doubleValue": Number.MIN_VALUE, 115 "booleanValue": false, 116 "floatValue": 0.1234567, 117 "longValue": -9223372036854775808, 118 "shortValue": -32768, 119 "characterValue": '#', 120 "stringValue": "ABCDEFGHIJKLMN", 121 "blobValue": u8, 122 "byteValue": -128, 123 } 124 await rdbStore.insert("AllDataType", valueBucket) 125 } 126 } 127 128 console.log(TAG + "*************Unit Test Begin*************"); 129 130 /** 131 * @tc.name predicates equalTo normal test 132 * @tc.number SUB_DDM_AppDataFWK_JSRDB_Predicates_0010 133 * @tc.desc predicates equalTo normal test 134 */ 135 it('testEqualTo0001', 0, async function (done) { 136 console.log(TAG + "************* testEqualTo0001 start *************"); 137 let predicates = await new dataRdb.RdbPredicates("AllDataType"); 138 { 139 predicates.equalTo("booleanValue", true); 140 let result = await rdbStore.query(predicates); 141 expect(1).assertEqual(result.rowCount); 142 result = null 143 } 144 done(); 145 console.log(TAG + "************* testEqualTo0001 end *************"); 146 }) 147 148 /** 149 * @tc.name predicates equalTo normal test 150 * @tc.number SUB_DDM_AppDataFWK_JSRDB_Predicates_0011 151 * @tc.desc predicates equalTo normal test 152 */ 153 it('testEqualTo0002', 0, async function (done) { 154 console.log(TAG + "************* testEqualTo0002 start *************"); 155 { 156 let predicates = await new dataRdb.RdbPredicates("AllDataType"); 157 predicates.equalTo("byteValue", -128).or().equalTo("byteValue", 1); 158 let result = await rdbStore.query(predicates); 159 expect(2).assertEqual(result.rowCount); 160 result = null 161 } 162 done(); 163 console.log(TAG + "************* testEqualTo0002 end *************"); 164 }) 165 166 /** 167 * @tc.name predicates equalTo normal test 168 * @tc.number SUB_DDM_AppDataFWK_JSRDB_Predicates_0012 169 * @tc.desc predicates equalTo normal test 170 */ 171 it('testEqualTo0003', 0, async function (done) { 172 console.log(TAG + "************* testEqualTo0003 start *************"); 173 { 174 let predicates = await new dataRdb.RdbPredicates("AllDataType"); 175 predicates.equalTo("stringValue", "ABCDEFGHIJKLMN"); 176 let result = await rdbStore.query(predicates); 177 expect(3).assertEqual(result.rowCount); 178 result = null 179 } 180 done(); 181 console.log(TAG + "************* testEqualTo0003 end *************"); 182 }) 183 184 /** 185 * @tc.name predicates equalTo normal test 186 * @tc.number SUB_DDM_AppDataFWK_JSRDB_Predicates_0013 187 * @tc.desc predicates equalTo normal test 188 */ 189 it('testEqualTo0004', 0, async function (done) { 190 console.log(TAG + "************* testEqualTo0004 start *************"); 191 { 192 let predicates = await new dataRdb.RdbPredicates("AllDataType"); 193 predicates.equalTo("doubleValue", DOUBLE_MAX); 194 let result = await rdbStore.query(predicates); 195 expect(1).assertEqual(result.rowCount); 196 result = null 197 } 198 done(); 199 console.log(TAG + "************* testEqualTo0004 end *************"); 200 }) 201 202 /** 203 * @tc.name predicates equalTo normal test 204 * @tc.number SUB_DDM_AppDataFWK_JSRDB_Predicates_0014 205 * @tc.desc predicates equalTo normal test 206 */ 207 it('testEqualTo0005', 0, async function (done) { 208 console.log(TAG + "************* testEqualTo0005 start *************"); 209 { 210 let predicates = await new dataRdb.RdbPredicates("AllDataType"); 211 predicates.equalTo("shortValue", -32768.0); 212 let result = await rdbStore.query(predicates); 213 expect(1).assertEqual(result.rowCount); 214 result = null 215 } 216 done(); 217 console.log(TAG + "************* testEqualTo0005 end *************"); 218 }) 219 220 /** 221 * @tc.name predicates equalTo normal test 222 * @tc.number SUB_DDM_AppDataFWK_JSRDB_Predicates_0015 223 * @tc.desc predicates equalTo normal test 224 */ 225 it('testEqualTo0006', 0, async function (done) { 226 console.log(TAG + "************* testEqualTo0006 start *************"); 227 { 228 let predicates = await new dataRdb.RdbPredicates("AllDataType"); 229 predicates.equalTo("integerValue", 1); 230 let result = await rdbStore.query(predicates); 231 expect(true).assertEqual(result.goToFirstRow()); 232 expect(2).assertEqual(result.getLong(0)); 233 } 234 done(); 235 console.log(TAG + "************* testEqualTo0006 end *************"); 236 }) 237 238 /** 239 * @tc.name predicates equalTo normal test 240 * @tc.number SUB_DDM_AppDataFWK_JSRDB_Predicates_0016 241 * @tc.desc predicates equalTo normal test 242 */ 243 it('testEqualTo0007', 0, async function (done) { 244 console.log(TAG + "************* testEqualTo0007 start *************"); 245 { 246 let predicates = await new dataRdb.RdbPredicates("AllDataType"); 247 predicates.equalTo("longValue", 1); 248 let result = await rdbStore.query(predicates); 249 expect(true).assertEqual(result.goToFirstRow()); 250 expect(2).assertEqual(result.getLong(0)) 251 } 252 done(); 253 console.log(TAG + "************* testEqualTo0007 end *************"); 254 }) 255 256 /** 257 * @tc.name predicates equalTo normal test 258 * @tc.number SUB_DDM_AppDataFWK_JSRDB_Predicates_0017 259 * @tc.desc predicates equalTo normal test 260 */ 261 it('testEqualTo0008', 0, async function (done) { 262 console.log(TAG + "************* testEqualTo0008 start *************"); 263 { 264 let predicates = await new dataRdb.RdbPredicates("AllDataType"); 265 predicates.equalTo("floatValue", -0.123); 266 let result = await rdbStore.query(predicates); 267 expect(true).assertEqual(result.goToFirstRow()); 268 expect(1).assertEqual(result.getLong(0)) 269 result = null 270 } 271 done(); 272 console.log(TAG + "************* testEqualTo0008 end *************"); 273 }) 274 275 /** 276 * @tc.name predicates notEqualTo normal test 277 * @tc.number SUB_DDM_AppDataFWK_JSRDB_Predicates_0020 278 * @tc.desc predicates notEqualTo normal test 279 */ 280 it('testNotEqualTo0001', 0, async function (done) { 281 console.log(TAG + "************* testNotEqualTo0001 start *************"); 282 { 283 let predicates = await new dataRdb.RdbPredicates("AllDataType"); 284 predicates.notEqualTo("booleanValue", true); 285 let result = await rdbStore.query(predicates); 286 expect(2).assertEqual(result.rowCount); 287 result = null 288 } 289 done(); 290 console.log(TAG + "************* testNotEqualTo0001 end *************"); 291 }) 292 293 /** 294 * @tc.name predicates notEqualTo normal test 295 * @tc.number SUB_DDM_AppDataFWK_JSRDB_Predicates_0021 296 * @tc.desc predicates notEqualTo normal test 297 */ 298 it('testNotEqualTo0002', 0, async function (done) { 299 console.log(TAG + "************* testNotEqualTo0002 start *************"); 300 { 301 let predicates = await new dataRdb.RdbPredicates("AllDataType"); 302 predicates.notEqualTo("byteValue", -128); 303 predicates.notEqualTo("byteValue", 1); 304 let result = await rdbStore.query(predicates); 305 expect(1).assertEqual(result.rowCount); 306 result = null 307 } 308 done(); 309 console.log(TAG + "************* testNotEqualTo0002 end *************"); 310 }) 311 312 /** 313 * @tc.name predicates notEqualTo normal test 314 * @tc.number SUB_DDM_AppDataFWK_JSRDB_Predicates_0022 315 * @tc.desc predicates notEqualTo normal test 316 */ 317 it('testNotEqualTo0003', 0, async function (done) { 318 console.log(TAG + "************* testNotEqualTo0003 start *************"); 319 { 320 let predicates = await new dataRdb.RdbPredicates("AllDataType"); 321 predicates.notEqualTo("stringValue", "ABCDEFGHIJKLMN"); 322 let result = await rdbStore.query(predicates); 323 expect(0).assertEqual(result.rowCount); 324 result = null 325 } 326 done(); 327 console.log(TAG + "************* testNotEqualTo0003 end *************"); 328 }) 329 330 /** 331 * @tc.name predicates notEqualTo normal test 332 * @tc.number SUB_DDM_AppDataFWK_JSRDB_Predicates_0023 333 * @tc.desc predicates notEqualTo normal test 334 */ 335 it('testNotEqualTo0004', 0, async function (done) { 336 console.log(TAG + "************* testNotEqualTo0004 start *************"); 337 { 338 let predicates = await new dataRdb.RdbPredicates("AllDataType"); 339 predicates.notEqualTo("doubleValue", DOUBLE_MAX); 340 let result = await rdbStore.query(predicates); 341 expect(2).assertEqual(result.rowCount); 342 result = null 343 } 344 done(); 345 console.log(TAG + "************* testNotEqualTo0004 end *************"); 346 }) 347 348 /** 349 * @tc.name predicates notEqualTo normal test 350 * @tc.number SUB_DDM_AppDataFWK_JSRDB_Predicates_0024 351 * @tc.desc predicates notEqualTo normal test 352 */ 353 it('testNotEqualTo0005', 0, async function (done) { 354 console.log(TAG + "************* testNotEqualTo0005 start *************"); 355 { 356 let predicates = await new dataRdb.RdbPredicates("AllDataType"); 357 predicates.notEqualTo("shortValue", -32768); 358 let result = await rdbStore.query(predicates); 359 expect(2).assertEqual(result.rowCount); 360 result = null 361 } 362 done(); 363 console.log(TAG + "************* testNotEqualTo0005 end *************"); 364 }) 365 366 /** 367 * @tc.name predicates notEqualTo normal test 368 * @tc.number SUB_DDM_AppDataFWK_JSRDB_Predicates_0025 369 * @tc.desc predicates notEqualTo normal test 370 */ 371 it('testNotEqualTo0006', 0, async function (done) { 372 console.log(TAG + "************* testNotEqualTo0006 start *************"); 373 { 374 let predicates = await new dataRdb.RdbPredicates("AllDataType"); 375 predicates.notEqualTo("integerValue", 1); 376 let result = await rdbStore.query(predicates); 377 expect(2).assertEqual(result.rowCount); 378 result = null 379 } 380 done(); 381 console.log(TAG + "************* testNotEqualTo0006 end *************"); 382 }) 383 384 /** 385 * @tc.name predicates notEqualTo normal test 386 * @tc.number SUB_DDM_AppDataFWK_JSRDB_Predicates_0026 387 * @tc.desc predicates notEqualTo normal test 388 */ 389 it('testNotEqualTo0007', 0, async function (done) { 390 console.log(TAG + "************* testNotEqualTo0007 start *************"); 391 { 392 let predicates = await new dataRdb.RdbPredicates("AllDataType"); 393 predicates.notEqualTo("longValue", 1); 394 let result = await rdbStore.query(predicates); 395 expect(2).assertEqual(result.rowCount); 396 result = null 397 } 398 done(); 399 console.log(TAG + "************* testNotEqualTo0007 end *************"); 400 }) 401 402 /** 403 * @tc.name predicates notEqualTo normal test 404 * @tc.number SUB_DDM_AppDataFWK_JSRDB_Predicates_0027 405 * @tc.desc predicates notEqualTo normal test 406 */ 407 it('testNotEqualTo0008', 0, async function (done) { 408 console.log(TAG + "************* testNotEqualTo0008 start *************"); 409 { 410 let predicates = await new dataRdb.RdbPredicates("AllDataType"); 411 predicates.notEqualTo("floatValue", -0.123); 412 let result = await rdbStore.query(predicates); 413 expect(2).assertEqual(result.rowCount); 414 result = null 415 } 416 done(); 417 console.log(TAG + "************* testNotEqualTo0008 end *************"); 418 }) 419 420 /** 421 * @tc.name predicates isNull normal test 422 * @tc.number SUB_DDM_AppDataFWK_JSRDB_Predicates_0030 423 * @tc.desc predicates isNull normal test 424 */ 425 it('testIsNull0001', 0, async function (done) { 426 console.log(TAG + "************* testIsNull001 start *************"); 427 let predicates = await new dataRdb.RdbPredicates("AllDataType"); 428 predicates.isNull("primLongValue"); 429 let result = await rdbStore.query(predicates); 430 expect(3).assertEqual(result.rowCount); 431 result = null 432 done(); 433 console.log(TAG + "************* testIsNull0001 end *************"); 434 }) 435 436 /** 437 * @tc.name predicates isNull normal test 438 * @tc.number SUB_DDM_AppDataFWK_JSRDB_Predicates_0031 439 * @tc.desc predicates isNull normal test 440 */ 441 it('testIsNull0002', 0, async function (done) { 442 console.log(TAG + "************* testIsNull0002 start *************"); 443 let predicates = await new dataRdb.RdbPredicates("AllDataType"); 444 predicates.isNull("longValue"); 445 let result = await rdbStore.query(predicates); 446 expect(0).assertEqual(result.rowCount); 447 result = null 448 done(); 449 console.log(TAG + "************* testIsNull0002 end *************"); 450 }) 451 452 /** 453 * @tc.name predicates isNull normal test 454 * @tc.number SUB_DDM_AppDataFWK_JSRDB_Predicates_0032 455 * @tc.desc predicates isNull normal test 456 */ 457 it('testIsNull0003', 0, async function (done) { 458 console.log(TAG + "************* testIsNull0003 start *************"); 459 let predicates = await new dataRdb.RdbPredicates("AllDataType"); 460 predicates.isNull("stringValue"); 461 let result = await rdbStore.query(predicates); 462 expect(0).assertEqual(result.rowCount); 463 result = null 464 done(); 465 console.log(TAG + "************* testIsNull0003 end *************"); 466 }) 467 468 /** 469 * @tc.name predicates isNull normal test 470 * @tc.number SUB_DDM_AppDataFWK_JSRDB_Predicates_0033 471 * @tc.desc predicates isNull normal test 472 */ 473 it('testIsNull0004', 0, async function (done) { 474 console.log(TAG + "************* testIsNull0004 start *************"); 475 let predicates = await new dataRdb.RdbPredicates("AllDataType"); 476 predicates.isNull("stringValueX"); 477 let result = await rdbStore.query(predicates); 478 expect(-1).assertEqual(result.rowCount); 479 result = null 480 done(); 481 console.log(TAG + "************* testIsNull0004 end *************"); 482 }) 483 484 /** 485 * @tc.name predicates isNotNull normal test 486 * @tc.number SUB_DDM_AppDataFWK_JSRDB_Predicates_0040 487 * @tc.desc predicates isNotNull normal test 488 */ 489 it('testIsNotNull0001', 0, async function (done) { 490 console.log(TAG + "************* testIsNotNull0001 start *************"); 491 let predicates = await new dataRdb.RdbPredicates("AllDataType"); 492 predicates.isNotNull("primLongValue"); 493 let result = await rdbStore.query(predicates); 494 expect(0).assertEqual(result.rowCount); 495 result = null 496 done(); 497 console.log(TAG + "************* testIsNotNull0001 end *************"); 498 }) 499 500 /** 501 * @tc.name predicates isNotNull normal test 502 * @tc.number SUB_DDM_AppDataFWK_JSRDB_Predicates_0041 503 * @tc.desc predicates isNotNull normal test 504 */ 505 it('testIsNotNull0002', 0, async function (done) { 506 console.log(TAG + "************* testIsNotNull0002 start *************"); 507 let predicates = await new dataRdb.RdbPredicates("AllDataType"); 508 predicates.isNotNull("longValue"); 509 let result = await rdbStore.query(predicates); 510 expect(3).assertEqual(result.rowCount); 511 result = null 512 done(); 513 console.log(TAG + "************* testIsNotNull0002 end *************"); 514 }) 515 516 /** 517 * @tc.name predicates isNotNull normal test 518 * @tc.number SUB_DDM_AppDataFWK_JSRDB_Predicates_0042 519 * @tc.desc predicates isNotNull normal test 520 */ 521 it('testIsNotNull0003', 0, async function (done) { 522 console.log(TAG + "************* testIsNotNull0003 start *************"); 523 let predicates = await new dataRdb.RdbPredicates("AllDataType"); 524 predicates.isNotNull("stringValue"); 525 let result = await rdbStore.query(predicates); 526 expect(3).assertEqual(result.rowCount); 527 result = null 528 done(); 529 console.log(TAG + "************* testIsNotNull0003 end *************"); 530 }) 531 532 /** 533 * @tc.name predicates isNotNull normal test 534 * @tc.number SUB_DDM_AppDataFWK_JSRDB_Predicates_0043 535 * @tc.desc predicates isNotNull normal test 536 */ 537 it('testIsNotNull0004', 0, async function (done) { 538 console.log(TAG + "************* testIsNotNull0004 start *************"); 539 let predicates = await new dataRdb.RdbPredicates("AllDataType"); 540 predicates.isNotNull("stringValueX"); 541 let result = await rdbStore.query(predicates); 542 expect(-1).assertEqual(result.rowCount); 543 result = null 544 done(); 545 console.log(TAG + "************* testIsNotNull0004 end *************"); 546 }) 547 548 /** 549 * @tc.name predicates greaterThan normal test 550 * @tc.number SUB_DDM_AppDataFWK_JSRDB_Predicates_0050 551 * @tc.desc predicates greaterThan normal test 552 */ 553 it('testGreaterThan0001', 0, async function (done) { 554 console.log(TAG + "************* testGreaterThan0001 start *************"); 555 { 556 let predicates = await new dataRdb.RdbPredicates("AllDataType"); 557 predicates.greaterThan("stringValue", "ABC"); 558 let result = await rdbStore.query(predicates); 559 expect(3).assertEqual(result.rowCount); 560 result = null 561 } 562 done(); 563 console.log(TAG + "************* testGreaterThan0001 end *************"); 564 }) 565 566 /** 567 * @tc.name predicates greaterThan normal test 568 * @tc.number SUB_DDM_AppDataFWK_JSRDB_Predicates_0051 569 * @tc.desc predicates greaterThan normal test 570 */ 571 it('testGreaterThan0002', 0, async function (done) { 572 console.log(TAG + "************* testGreaterThan0002 start *************"); 573 { 574 let predicates = await new dataRdb.RdbPredicates("AllDataType"); 575 predicates.greaterThan("doubleValue", 0.0); 576 let result = await rdbStore.query(predicates); 577 expect(3).assertEqual(result.rowCount); 578 result = null 579 } 580 done(); 581 console.log(TAG + "************* testGreaterThan0002 end *************"); 582 }) 583 584 /** 585 * @tc.name predicates greaterThan normal test 586 * @tc.number SUB_DDM_AppDataFWK_JSRDB_Predicates_0052 587 * @tc.desc predicates greaterThan normal test 588 */ 589 it('testGreaterThan0003', 0, async function (done) { 590 console.log(TAG + "************* testGreaterThan0003 start *************"); 591 { 592 let predicates = await new dataRdb.RdbPredicates("AllDataType"); 593 predicates.greaterThan("integerValue", 1); 594 let result = await rdbStore.query(predicates); 595 expect(1).assertEqual(result.rowCount); 596 result = null 597 } 598 done(); 599 console.log(TAG + "************* testGreaterThan0003 end *************"); 600 }) 601 602 /** 603 * @tc.name predicates greaterThan normal test 604 * @tc.number SUB_DDM_AppDataFWK_JSRDB_Predicates_0053 605 * @tc.desc predicates greaterThan normal test 606 */ 607 it('testGreaterThan0004', 0, async function (done) { 608 console.log(TAG + "************* testGreaterThan0004 start *************"); 609 { 610 let predicates = await new dataRdb.RdbPredicates("AllDataType"); 611 predicates.greaterThan("longValue", 1); 612 let result = await rdbStore.query(predicates); 613 expect(1).assertEqual(result.rowCount); 614 result = null 615 } 616 done(); 617 console.log(TAG + "************* testGreaterThan0004 end *************"); 618 }) 619 620 /** 621 * @tc.name predicates greaterThan normal test 622 * @tc.number SUB_DDM_AppDataFWK_JSRDB_Predicates_0054 623 * @tc.desc predicates greaterThan normal test 624 */ 625 it('testGreaterThan0005', 0, async function (done) { 626 console.log(TAG + "************* testGreaterThan0005 start *************"); 627 { 628 let predicates = await new dataRdb.RdbPredicates("AllDataType"); 629 predicates.greaterThan("stringValue", "ZZZ"); 630 let result = await rdbStore.query(predicates); 631 expect(0).assertEqual(result.rowCount); 632 result = null 633 } 634 done(); 635 console.log(TAG + "************* testGreaterThan0005 end *************"); 636 }) 637 638 /** 639 * @tc.name predicates greaterThan normal test 640 * @tc.number SUB_DDM_AppDataFWK_JSRDB_Predicates_0055 641 * @tc.desc predicates greaterThan normal test 642 */ 643 it('testGreaterThan0006', 0, async function (done) { 644 console.log(TAG + "************* testGreaterThan0006 start *************"); 645 { 646 let predicates = await new dataRdb.RdbPredicates("AllDataType"); 647 predicates.greaterThan("doubleValue", 999.0); 648 let result = await rdbStore.query(predicates); 649 expect(1).assertEqual(result.rowCount); 650 result = null 651 } 652 done(); 653 console.log(TAG + "************* testGreaterThan0006 end *************"); 654 }) 655 656 /** 657 * @tc.name predicates greaterThan normal test 658 * @tc.number SUB_DDM_AppDataFWK_JSRDB_Predicates_0056 659 * @tc.desc predicates greaterThan normal test 660 */ 661 it('testGreaterThan0007', 0, async function (done) { 662 console.log(TAG + "************* testGreaterThan0007 start *************"); 663 { 664 let predicates = await new dataRdb.RdbPredicates("AllDataType"); 665 predicates.greaterThan("integerValue", -999); 666 let result = await rdbStore.query(predicates); 667 expect(2).assertEqual(result.rowCount); 668 result = null 669 } 670 done(); 671 console.log(TAG + "************* testGreaterThan0007 end *************"); 672 }) 673 674 /** 675 * @tc.name predicates greaterThan normal test 676 * @tc.number SUB_DDM_AppDataFWK_JSRDB_Predicates_0057 677 * @tc.desc predicates greaterThan normal test 678 */ 679 it('testGreaterThan0008', 0, async function (done) { 680 console.log(TAG + "************* testGreaterThan0008 start *************"); 681 { 682 let predicates = await new dataRdb.RdbPredicates("AllDataType"); 683 predicates.greaterThan("longValue", -999); 684 let result = await rdbStore.query(predicates); 685 expect(2).assertEqual(result.rowCount); 686 result = null 687 } 688 done(); 689 console.log(TAG + "************* testGreaterThan0008 end *************"); 690 }) 691 692 /** 693 * @tc.name predicates greaterThanOrEqualTo normal test 694 * @tc.number SUB_DDM_AppDataFWK_JSRDB_Predicates_0060 695 * @tc.desc predicates greaterThanOrEqualTo normal test 696 */ 697 it('testGreaterThanOrEqualTo0001', 0, async function (done) { 698 console.log(TAG + "************* testGreaterThanOrEqualTo0001 start *************"); 699 { 700 let predicates = await new dataRdb.RdbPredicates("AllDataType"); 701 predicates.greaterThanOrEqualTo("stringValue", "ABC"); 702 let result = await rdbStore.query(predicates); 703 expect(3).assertEqual(result.rowCount); 704 result = null 705 } 706 done(); 707 console.log(TAG + "************* testGreaterThanOrEqualTo0001 end *************"); 708 }) 709 710 /** 711 * @tc.name predicates greaterThanOrEqualTo normal test 712 * @tc.number SUB_DDM_AppDataFWK_JSRDB_Predicates_0061 713 * @tc.desc predicates greaterThanOrEqualTo normal test 714 */ 715 it('testGreaterThanOrEqualTo0002', 0, async function (done) { 716 console.log(TAG + "************* testGreaterThanOrEqualTo0002 start *************"); 717 { 718 let predicates = await new dataRdb.RdbPredicates("AllDataType"); 719 predicates.greaterThanOrEqualTo("doubleValue", 0.0); 720 let result = await rdbStore.query(predicates); 721 expect(3).assertEqual(result.rowCount); 722 result = null 723 } 724 done(); 725 console.log(TAG + "************* testGreaterThanOrEqualTo0002 end *************"); 726 }) 727 728 /** 729 * @tc.name predicates greaterThanOrEqualTo normal test 730 * @tc.number SUB_DDM_AppDataFWK_JSRDB_Predicates_0062 731 * @tc.desc predicates greaterThanOrEqualTo normal test 732 */ 733 it('testGreaterThanOrEqualTo0003', 0, async function (done) { 734 console.log(TAG + "************* testGreaterThanOrEqualTo0003 start *************"); 735 { 736 let predicates = await new dataRdb.RdbPredicates("AllDataType"); 737 predicates.greaterThanOrEqualTo("integerValue", 1); 738 let result = await rdbStore.query(predicates); 739 expect(2).assertEqual(result.rowCount); 740 result = null 741 } 742 done(); 743 console.log(TAG + "************* testGreaterThanOrEqualTo0003 end *************"); 744 }) 745 746 /** 747 * @tc.name predicates greaterThanOrEqualTo normal test 748 * @tc.number SUB_DDM_AppDataFWK_JSRDB_Predicates_0063 749 * @tc.desc predicates greaterThanOrEqualTo normal test 750 */ 751 it('testGreaterThanOrEqualTo0004', 0, async function (done) { 752 console.log(TAG + "************* testGreaterThanOrEqualTo0004 start *************"); 753 { 754 let predicates = await new dataRdb.RdbPredicates("AllDataType"); 755 predicates.greaterThanOrEqualTo("longValue", 1); 756 let result = await rdbStore.query(predicates); 757 expect(2).assertEqual(result.rowCount); 758 result = null 759 } 760 done(); 761 console.log(TAG + "************* testGreaterThanOrEqualTo0004 end *************"); 762 }) 763 764 /** 765 * @tc.name predicates lessThan normal test 766 * @tc.number SUB_DDM_AppDataFWK_JSRDB_Predicates_0070 767 * @tc.desc predicates lessThan normal test 768 */ 769 it('testLessThan0001', 0, async function (done) { 770 console.log(TAG + "************* testLessThan0001 start *************"); 771 { 772 let predicates = await new dataRdb.RdbPredicates("AllDataType"); 773 predicates.lessThan("stringValue", "ABD"); 774 let result = await rdbStore.query(predicates); 775 expect(3).assertEqual(result.rowCount); 776 result = null 777 } 778 done(); 779 console.log(TAG + "************* testLessThan0001 end *************"); 780 }) 781 782 /** 783 * @tc.name predicates lessThan normal test 784 * @tc.number SUB_DDM_AppDataFWK_JSRDB_Predicates_0071 785 * @tc.desc predicates lessThan normal test 786 */ 787 it('testLessThan0002', 0, async function (done) { 788 console.log(TAG + "************* testLessThan0002 start *************"); 789 { 790 let predicates = await new dataRdb.RdbPredicates("AllDataType"); 791 predicates.lessThan("doubleValue", 0.0); 792 let result = await rdbStore.query(predicates); 793 expect(0).assertEqual(result.rowCount); 794 result = null 795 } 796 done(); 797 console.log(TAG + "************* testLessThan0002 end *************"); 798 }) 799 800 /** 801 * @tc.name predicates lessThan normal test 802 * @tc.number SUB_DDM_AppDataFWK_JSRDB_Predicates_0072 803 * @tc.desc predicates lessThan normal test 804 */ 805 it('testLessThan0003', 0, async function (done) { 806 console.log(TAG + "************* testLessThan0003 start *************"); 807 { 808 let predicates = await new dataRdb.RdbPredicates("AllDataType"); 809 predicates.lessThan("integerValue", 1); 810 let result = await rdbStore.query(predicates); 811 expect(1).assertEqual(result.rowCount); 812 result = null 813 } 814 done(); 815 console.log(TAG + "************* testLessThan0003 end *************"); 816 }) 817 818 /** 819 * @tc.name predicates lessThan normal test 820 * @tc.number SUB_DDM_AppDataFWK_JSRDB_Predicates_0073 821 * @tc.desc predicates lessThan normal test 822 */ 823 it('testLessThan0004', 0, async function (done) { 824 console.log(TAG + "************* testLessThan0004 start *************"); 825 { 826 let predicates = await new dataRdb.RdbPredicates("AllDataType"); 827 predicates.lessThan("longValue", 1); 828 let result = await rdbStore.query(predicates); 829 expect(1).assertEqual(result.rowCount); 830 result = null 831 } 832 done(); 833 console.log(TAG + "************* testLessThan0004 end *************"); 834 }) 835 836 /** 837 * @tc.name predicates lessThan normal test 838 * @tc.number SUB_DDM_AppDataFWK_JSRDB_Predicates_0074 839 * @tc.desc predicates lessThan normal test 840 */ 841 it('testLessThan0005', 0, async function (done) { 842 console.log(TAG + "************* testLessThan0005 start *************"); 843 { 844 let predicates = await new dataRdb.RdbPredicates("AllDataType"); 845 predicates.lessThan("stringValue", "ABD"); 846 let result = await rdbStore.query(predicates); 847 expect(3).assertEqual(result.rowCount); 848 result = null 849 } 850 done(); 851 console.log(TAG + "************* testLessThan0005 end *************"); 852 }) 853 854 /** 855 * @tc.name predicates lessThan normal test 856 * @tc.number SUB_DDM_AppDataFWK_JSRDB_Predicates_0075 857 * @tc.desc predicates lessThan normal test 858 */ 859 it('testLessThan0006', 0, async function (done) { 860 console.log(TAG + "************* testLessThan0006 start *************"); 861 { 862 let predicates = await new dataRdb.RdbPredicates("AllDataType"); 863 predicates.lessThan("doubleValue", 1.0); 864 let result = await rdbStore.query(predicates); 865 expect(1).assertEqual(result.rowCount); 866 result = null 867 } 868 done(); 869 console.log(TAG + "************* testLessThan0006 end *************"); 870 }) 871 872 /** 873 * @tc.name predicates lessThan normal test 874 * @tc.number SUB_DDM_AppDataFWK_JSRDB_Predicates_0076 875 * @tc.desc predicates lessThan normal test 876 */ 877 it('testLessThan0007', 0, async function (done) { 878 console.log(TAG + "************* testLessThan0007 start *************"); 879 { 880 let predicates = await new dataRdb.RdbPredicates("AllDataType"); 881 predicates.lessThan("integerValue", -2147483648); 882 let result = await rdbStore.query(predicates); 883 expect(0).assertEqual(result.rowCount); 884 result = null 885 } 886 done(); 887 console.log(TAG + "************* testLessThan0007 end *************"); 888 }) 889 890 /** 891 * @tc.name predicates lessThan normal test 892 * @tc.number SUB_DDM_AppDataFWK_JSRDB_Predicates_0077 893 * @tc.desc predicates lessThan normal test 894 */ 895 it('testLessThan0008', 0, async function (done) { 896 console.log(TAG + "************* testLessThan0008 start *************"); 897 { 898 let predicates = await new dataRdb.RdbPredicates("AllDataType"); 899 predicates.lessThan("longValue", -9223372036854775808); 900 let result = await rdbStore.query(predicates); 901 expect(0).assertEqual(result.rowCount); 902 result = null 903 } 904 done(); 905 console.log(TAG + "************* testLessThan0008 end *************"); 906 }) 907 908 /** 909 * @tc.name predicates lessThanOrEqualTo normal test 910 * @tc.number SUB_DDM_AppDataFWK_JSRDB_Predicates_0080 911 * @tc.desc predicates lessThanOrEqualTo normal test 912 */ 913 it('testLessThanOrEqualTo0001', 0, async function (done) { 914 console.log(TAG + "************* testLessThanOrEqualTo0001 start *************"); 915 { 916 let predicates = await new dataRdb.RdbPredicates("AllDataType"); 917 predicates.lessThanOrEqualTo("stringValue", "ABD"); 918 let result = await rdbStore.query(predicates); 919 expect(3).assertEqual(result.rowCount); 920 result = null 921 } 922 done(); 923 console.log(TAG + "************* testLessThanOrEqualTo0001 end *************"); 924 }) 925 926 /** 927 * @tc.name predicates lessThanOrEqualTo normal test 928 * @tc.number SUB_DDM_AppDataFWK_JSRDB_Predicates_0081 929 * @tc.desc predicates lessThanOrEqualTo normal test 930 */ 931 it('testLessThanOrEqualTo0002', 0, async function (done) { 932 console.log(TAG + "************* testLessThanOrEqualTo0002 start *************"); 933 { 934 let predicates = await new dataRdb.RdbPredicates("AllDataType"); 935 predicates.lessThanOrEqualTo("doubleValue", 0.0); 936 let result = await rdbStore.query(predicates); 937 expect(0).assertEqual(result.rowCount); 938 result = null 939 } 940 done(); 941 console.log(TAG + "************* testLessThanOrEqualTo0002 end *************"); 942 }) 943 944 /** 945 * @tc.name predicates lessThanOrEqualTo normal test 946 * @tc.number SUB_DDM_AppDataFWK_JSRDB_Predicates_0082 947 * @tc.desc predicates lessThanOrEqualTo normal test 948 */ 949 it('testLessThanOrEqualTo0003', 0, async function (done) { 950 console.log(TAG + "************* testLessThanOrEqualTo0003 start *************"); 951 { 952 let predicates = await new dataRdb.RdbPredicates("AllDataType"); 953 predicates.lessThanOrEqualTo("integerValue", 1); 954 let result = await rdbStore.query(predicates); 955 expect(2).assertEqual(result.rowCount); 956 result = null 957 } 958 done(); 959 console.log(TAG + "************* testLessThanOrEqualTo0003 end *************"); 960 }) 961 962 /** 963 * @tc.name predicates lessThanOrEqualTo normal test 964 * @tc.number SUB_DDM_AppDataFWK_JSRDB_Predicates_0083 965 * @tc.desc predicates lessThanOrEqualTo normal test 966 */ 967 it('testLessThanOrEqualTo0004', 0, async function (done) { 968 console.log(TAG + "************* testLessThanOrEqualTo0004 start *************"); 969 { 970 let predicates = await new dataRdb.RdbPredicates("AllDataType"); 971 predicates.lessThanOrEqualTo("longValue", 1); 972 let result = await rdbStore.query(predicates); 973 expect(2).assertEqual(result.rowCount); 974 result = null 975 } 976 done(); 977 console.log(TAG + "************* testLessThanOrEqualTo0004 end *************"); 978 }) 979 980 /** 981 * @tc.name predicates between normal test 982 * @tc.number SUB_DDM_AppDataFWK_JSRDB_Predicates_0090 983 * @tc.desc predicates between normal test 984 */ 985 it('testBetween0001', 0, async function (done) { 986 console.log(TAG + "************* testBetween0001 start *************"); 987 { 988 let predicates = await new dataRdb.RdbPredicates("AllDataType"); 989 predicates.between("stringValue", "ABB", "ABD"); 990 let result = await rdbStore.query(predicates); 991 expect(3).assertEqual(result.rowCount); 992 result = null 993 } 994 done(); 995 console.log(TAG + "************* testBetween0001 end *************"); 996 }) 997 998 /** 999 * @tc.name predicates between normal test 1000 * @tc.number SUB_DDM_AppDataFWK_JSRDB_Predicates_0091 1001 * @tc.desc predicates between normal test 1002 */ 1003 it('testBetween0002', 0, async function (done) { 1004 console.log(TAG + "************* testBetween0002 start *************"); 1005 { 1006 let predicates = await new dataRdb.RdbPredicates("AllDataType"); 1007 predicates.between("doubleValue", 0.0, DOUBLE_MAX); 1008 let result = await rdbStore.query(predicates); 1009 expect(3).assertEqual(result.rowCount); 1010 result = null 1011 } 1012 done(); 1013 console.log(TAG + "************* testBetween0002 end *************"); 1014 }) 1015 1016 /** 1017 * @tc.name predicates between normal test 1018 * @tc.number SUB_DDM_AppDataFWK_JSRDB_Predicates_0092 1019 * @tc.desc predicates between normal test 1020 */ 1021 it('testBetween0003', 0, async function (done) { 1022 console.log(TAG + "************* testBetween0003 start *************"); 1023 { 1024 let predicates = await new dataRdb.RdbPredicates("AllDataType"); 1025 predicates.between("integerValue", 0, 1); 1026 let result = await rdbStore.query(predicates); 1027 expect(1).assertEqual(result.rowCount); 1028 result = null 1029 } 1030 done(); 1031 console.log(TAG + "************* testBetween0003 end *************"); 1032 }) 1033 1034 /** 1035 * @tc.name predicates between normal test 1036 * @tc.number SUB_DDM_AppDataFWK_JSRDB_Predicates_0093 1037 * @tc.desc predicates between normal test 1038 */ 1039 it('testBetween0004', 0, async function (done) { 1040 console.log(TAG + "************* testBetween0004 start *************"); 1041 { 1042 let predicates = await new dataRdb.RdbPredicates("AllDataType"); 1043 predicates.between("longValue", 0, 2); 1044 let result = await rdbStore.query(predicates); 1045 expect(1).assertEqual(result.rowCount); 1046 result = null 1047 } 1048 done(); 1049 console.log(TAG + "************* testBetween0004 end *************"); 1050 }) 1051 1052 /** 1053 * @tc.name predicates between normal test 1054 * @tc.number SUB_DDM_AppDataFWK_JSRDB_Predicates_0094 1055 * @tc.desc predicates between normal test 1056 */ 1057 it('testBetween0005', 0, async function (done) { 1058 console.log(TAG + "************* testBetween0005 start *************"); 1059 { 1060 let predicates = await new dataRdb.RdbPredicates("AllDataType"); 1061 predicates.between("stringValue", "ABB", "ABB"); 1062 let result = await rdbStore.query(predicates); 1063 expect(0).assertEqual(result.rowCount); 1064 result = null 1065 } 1066 done(); 1067 console.log(TAG + "************* testBetween0005 end *************"); 1068 }) 1069 1070 /** 1071 * @tc.name predicates between normal test 1072 * @tc.number SUB_DDM_AppDataFWK_JSRDB_Predicates_0095 1073 * @tc.desc predicates between normal test 1074 */ 1075 it('testBetween0006', 0, async function (done) { 1076 console.log(TAG + "************* testBetween0006 start *************"); 1077 { 1078 let predicates = await new dataRdb.RdbPredicates("AllDataType"); 1079 predicates.between("doubleValue", DOUBLE_MAX, DOUBLE_MAX); 1080 let result = await rdbStore.query(predicates); 1081 expect(1).assertEqual(result.rowCount); 1082 result = null 1083 } 1084 done(); 1085 console.log(TAG + "************* testBetween0006 end *************"); 1086 }) 1087 1088 /** 1089 * @tc.name predicates between normal test 1090 * @tc.number SUB_DDM_AppDataFWK_JSRDB_Predicates_0096 1091 * @tc.desc predicates between normal test 1092 */ 1093 it('testBetween0007', 0, async function (done) { 1094 console.log(TAG + "************* testBetween0007 start *************"); 1095 { 1096 let predicates = await new dataRdb.RdbPredicates("AllDataType"); 1097 predicates.between("integerValue", 1, 0); 1098 let result = await rdbStore.query(predicates); 1099 expect(0).assertEqual(result.rowCount); 1100 result = null 1101 } 1102 done(); 1103 console.log(TAG + "************* testBetween0007 end *************"); 1104 }) 1105 1106 /** 1107 * @tc.name predicates between normal test 1108 * @tc.number SUB_DDM_AppDataFWK_JSRDB_Predicates_0097 1109 * @tc.desc predicates between normal test 1110 */ 1111 it('testBetween0008', 0, async function (done) { 1112 console.log(TAG + "************* testBetween0008 start *************"); 1113 { 1114 let predicates = await new dataRdb.RdbPredicates("AllDataType"); 1115 predicates.between("longValue", 2, -1); 1116 let result = await rdbStore.query(predicates); 1117 expect(0).assertEqual(result.rowCount); 1118 result = null 1119 } 1120 done(); 1121 console.log(TAG + "************* testBetween0008 end *************"); 1122 }) 1123 1124 /** 1125 * @tc.name testNotBetween0001 1126 * @tc.number I4JWCV 1127 * @tc.desc test string value with notBetween. 1128 */ 1129 it('testNotBetween0001', 0, async function (done) { 1130 console.log(TAG + "************* testNotBetween0001 start *************"); 1131 { 1132 let predicates = await new dataRdb.RdbPredicates("AllDataType"); 1133 predicates.notBetween("stringValue", "ABB", "ABD"); 1134 let result = await rdbStore.query(predicates); 1135 expect(0).assertEqual(result.rowCount); 1136 result.close(); 1137 result = null 1138 } 1139 done(); 1140 console.log(TAG + "************* testNotBetween0001 end *************"); 1141 }) 1142 1143 /** 1144 * @tc.name testNotBetween0002 1145 * @tc.number I4JWCV 1146 * @tc.desc test double value with notBetween. 1147 */ 1148 it('testNotBetween0002', 0, async function (done) { 1149 console.log(TAG + "************* testNotBetween0002 start *************"); 1150 { 1151 let predicates = await new dataRdb.RdbPredicates("AllDataType"); 1152 predicates.notBetween("doubleValue", 0.0, DOUBLE_MAX); 1153 let result = await rdbStore.query(predicates); 1154 expect(0).assertEqual(result.rowCount); 1155 result.close(); 1156 result = null 1157 } 1158 done(); 1159 console.log(TAG + "************* testNotBetween0002 end *************"); 1160 }) 1161 1162 /** 1163 * @tc.name testNotBetween0003 1164 * @tc.number I4JWCV 1165 * @tc.desc test integer value with notBetween. 1166 */ 1167 it('testNotBetween0003', 0, async function (done) { 1168 console.log(TAG + "************* testNotBetween0003 start *************"); 1169 { 1170 let predicates = await new dataRdb.RdbPredicates("AllDataType"); 1171 predicates.notBetween("integerValue", 0, 1); 1172 let result = await rdbStore.query(predicates); 1173 expect(2).assertEqual(result.rowCount); 1174 result.close(); 1175 result = null 1176 } 1177 done(); 1178 console.log(TAG + "************* testNotBetween0003 end *************"); 1179 }) 1180 1181 /** 1182 * @tc.name testNotBetween0004 1183 * @tc.number I4JWCV 1184 * @tc.desc test long value with notBetween. 1185 */ 1186 it('testNotBetween0004', 0, async function (done) { 1187 console.log(TAG + "************* testNotBetween0004 start *************"); 1188 { 1189 let predicates = await new dataRdb.RdbPredicates("AllDataType"); 1190 predicates.notBetween("longValue", 0, 2); 1191 let result = await rdbStore.query(predicates); 1192 expect(2).assertEqual(result.rowCount); 1193 result.close(); 1194 result = null 1195 } 1196 done(); 1197 console.log(TAG + "************* testNotBetween0004 end *************"); 1198 }) 1199 1200 /** 1201 * @tc.name testGlob0001 1202 * @tc.number I4JWCV 1203 * @tc.desc end with ? by glob. 1204 */ 1205 it('testGlob0001', 0, async function (done) { 1206 console.log(TAG + "************* testGlob0001 start *************"); 1207 { 1208 let predicates = await new dataRdb.RdbPredicates("AllDataType"); 1209 predicates.glob("stringValue", "ABC*"); 1210 let result = await rdbStore.query(predicates); 1211 expect(3).assertEqual(result.rowCount); 1212 result.close(); 1213 result = null 1214 } 1215 done(); 1216 console.log(TAG + "************* testGlob0001 end *************"); 1217 }) 1218 1219 /** 1220 * @tc.name testGlob0002 1221 * @tc.number I4JWCV 1222 * @tc.desc begin with * by glob. 1223 */ 1224 it('testGlob0002', 0, async function (done) { 1225 console.log(TAG + "************* testGlob0002 start *************"); 1226 { 1227 let predicates = await new dataRdb.RdbPredicates("AllDataType"); 1228 predicates.glob("stringValue", "*LMN"); 1229 let result = await rdbStore.query(predicates); 1230 expect(3).assertEqual(result.rowCount); 1231 result.close(); 1232 result = null 1233 } 1234 done(); 1235 console.log(TAG + "************* testGlob0002 end *************"); 1236 }) 1237 1238 /** 1239 * @tc.name testGlob0003 1240 * @tc.number I4JWCV 1241 * @tc.desc end with ? by glob. 1242 */ 1243 it('testGlob0003', 0, async function (done) { 1244 console.log(TAG + "************* testGlob0003 start *************"); 1245 { 1246 let predicates = await new dataRdb.RdbPredicates("AllDataType"); 1247 predicates.glob("stringValue", "ABCDEFGHIJKLM?"); 1248 let result = await rdbStore.query(predicates); 1249 expect(3).assertEqual(result.rowCount); 1250 result.close(); 1251 result = null 1252 } 1253 done(); 1254 console.log(TAG + "************* testGlob0003 end *************"); 1255 }) 1256 1257 /** 1258 * @tc.name testGlob0004 1259 * @tc.number I4JWCV 1260 * @tc.desc begin with ? by glob. 1261 */ 1262 it('testGlob0004', 0, async function (done) { 1263 console.log(TAG + "************* testGlob0004 start *************"); 1264 { 1265 let predicates = await new dataRdb.RdbPredicates("AllDataType"); 1266 predicates.glob("stringValue", "?BCDEFGHIJKLMN"); 1267 let result = await rdbStore.query(predicates); 1268 expect(3).assertEqual(result.rowCount); 1269 result.close(); 1270 result = null 1271 } 1272 done(); 1273 console.log(TAG + "************* testGlob0004 end *************"); 1274 }) 1275 1276 /** 1277 * @tc.name testGlob0005 1278 * @tc.number I4JWCV 1279 * @tc.desc begin and end with * by glob. 1280 */ 1281 it('testGlob0005', 0, async function (done) { 1282 console.log(TAG + "************* testGlob0005 start *************"); 1283 { 1284 let predicates = await new dataRdb.RdbPredicates("AllDataType"); 1285 predicates.glob("stringValue", "*FGHI*"); 1286 let result = await rdbStore.query(predicates); 1287 expect(3).assertEqual(result.rowCount); 1288 result.close(); 1289 result = null 1290 } 1291 done(); 1292 console.log(TAG + "************* testGlob0005 end *************"); 1293 }) 1294 1295 /** 1296 * @tc.name testGlob0006 1297 * @tc.number I4JWCV 1298 * @tc.desc begin and end with ? by glob. 1299 */ 1300 it('testGlob0006', 0, async function (done) { 1301 console.log(TAG + "************* testGlob0006 start *************"); 1302 { 1303 let predicates = await new dataRdb.RdbPredicates("AllDataType"); 1304 predicates.glob("stringValue", "?BCDEFGHIJKLM?"); 1305 let result = await rdbStore.query(predicates); 1306 expect(3).assertEqual(result.rowCount); 1307 result.close(); 1308 result = null 1309 } 1310 done(); 1311 console.log(TAG + "************* testGlob0006 end *************"); 1312 }) 1313 1314 /** 1315 * @tc.name predicates contains normal test 1316 * @tc.number SUB_DDM_AppDataFWK_JSRDB_Predicates_0100 1317 * @tc.desc predicates contains normal test 1318 */ 1319 it('testContains0001', 0, async function (done) { 1320 console.log(TAG + "************* testContains0001 start *************"); 1321 let predicates = await new dataRdb.RdbPredicates("AllDataType"); 1322 predicates.contains("stringValue", "DEF"); 1323 let result = await rdbStore.query(predicates); 1324 expect(3).assertEqual(result.rowCount); 1325 result = null 1326 done(); 1327 console.log(TAG + "************* testContains0001 end *************"); 1328 }) 1329 1330 /** 1331 * @tc.name predicates contains normal test 1332 * @tc.number SUB_DDM_AppDataFWK_JSRDB_Predicates_0101 1333 * @tc.desc predicates contains normal test 1334 */ 1335 it('testContains0002', 0, async function (done) { 1336 console.log(TAG + "************* testContains0002 start *************"); 1337 let predicates = await new dataRdb.RdbPredicates("AllDataType"); 1338 predicates.contains("stringValue", "DEFX"); 1339 let result = await rdbStore.query(predicates); 1340 expect(0).assertEqual(result.rowCount); 1341 result = null 1342 done(); 1343 console.log(TAG + "************* testContains0002 end *************"); 1344 }) 1345 1346 /** 1347 * @tc.name predicates contains normal test 1348 * @tc.number SUB_DDM_AppDataFWK_JSRDB_Predicates_0102 1349 * @tc.desc predicates contains normal test 1350 */ 1351 it('testContains0003', 0, async function (done) { 1352 console.log(TAG + "************* testContains0003 start *************"); 1353 let predicates = await new dataRdb.RdbPredicates("AllDataType"); 1354 predicates.contains("characterValue", "中"); 1355 let result = await rdbStore.query(predicates); 1356 expect(1).assertEqual(result.rowCount); 1357 result = null 1358 done(); 1359 console.log(TAG + "************* testContains0003 end *************"); 1360 }) 1361 1362 /** 1363 * @tc.name predicates contains normal test 1364 * @tc.number SUB_DDM_AppDataFWK_JSRDB_Predicates_0103 1365 * @tc.desc predicates contains normal test 1366 */ 1367 it('testContains0004', 0, async function (done) { 1368 console.log(TAG + "************* testContains0004 start *************"); 1369 let predicates = await new dataRdb.RdbPredicates("AllDataType"); 1370 predicates.contains("characterValue", "#"); 1371 let result = await rdbStore.query(predicates); 1372 expect(1).assertEqual(result.rowCount); 1373 result = null 1374 done(); 1375 console.log(TAG + "************* testContains0004 end *************"); 1376 }) 1377 1378 /** 1379 * @tc.name predicates beginsWith normal test 1380 * @tc.number SUB_DDM_AppDataFWK_JSRDB_Predicates_0110 1381 * @tc.desc predicates beginsWith normal test 1382 */ 1383 it('testBeginsWith0001', 0, async function (done) { 1384 console.log(TAG + "************* testBeginsWith0001 start *************"); 1385 let predicates = await new dataRdb.RdbPredicates("AllDataType"); 1386 predicates.beginsWith("stringValue", "ABC"); 1387 let result = await rdbStore.query(predicates); 1388 expect(3).assertEqual(result.rowCount); 1389 result = null 1390 done(); 1391 console.log(TAG + "************* testBeginsWith0001 end *************"); 1392 }) 1393 1394 /** 1395 * @tc.name predicates beginsWith normal test 1396 * @tc.number SUB_DDM_AppDataFWK_JSRDB_Predicates_0111 1397 * @tc.desc predicates beginsWith normal test 1398 */ 1399 it('testBeginsWith0002', 0, async function (done) { 1400 console.log(TAG + "************* testBeginsWith0002 start *************"); 1401 let predicates = await new dataRdb.RdbPredicates("AllDataType"); 1402 predicates.beginsWith("stringValue", "ABCX"); 1403 let result = await rdbStore.query(predicates); 1404 expect(0).assertEqual(result.rowCount); 1405 result = null 1406 done(); 1407 console.log(TAG + "************* testBeginsWith0002 end *************"); 1408 }) 1409 1410 /** 1411 * @tc.name predicates beginsWith normal test 1412 * @tc.number SUB_DDM_AppDataFWK_JSRDB_Predicates_0112 1413 * @tc.desc predicates beginsWith normal test 1414 */ 1415 it('testBeginsWith0003', 0, async function (done) { 1416 console.log(TAG + "************* testBeginsWith0003 start *************"); 1417 let predicates = await new dataRdb.RdbPredicates("AllDataType"); 1418 predicates.beginsWith("characterValue", "中"); 1419 let result = await rdbStore.query(predicates); 1420 expect(1).assertEqual(result.rowCount); 1421 result = null 1422 done(); 1423 console.log(TAG + "************* testBeginsWith0003 end *************"); 1424 }) 1425 1426 /** 1427 * @tc.name predicates beginsWith normal test 1428 * @tc.number SUB_DDM_AppDataFWK_JSRDB_Predicates_0113 1429 * @tc.desc predicates beginsWith normal test 1430 */ 1431 it('testBeginsWith0004', 0, async function (done) { 1432 console.log(TAG + "************* testBeginsWith0004 start *************"); 1433 let predicates = await new dataRdb.RdbPredicates("AllDataType"); 1434 predicates.beginsWith("characterValue", "#"); 1435 let result = await rdbStore.query(predicates); 1436 expect(1).assertEqual(result.rowCount); 1437 result = null 1438 done(); 1439 console.log(TAG + "************* testBeginsWith0004 end *************"); 1440 }) 1441 1442 /** 1443 * @tc.name predicates endsWith normal test 1444 * @tc.number SUB_DDM_AppDataFWK_JSRDB_Predicates_0120 1445 * @tc.desc predicates endsWith normal test 1446 */ 1447 it('testEndsWith0001', 0, async function (done) { 1448 console.log(TAG + "************* testEndsWith0001 start *************"); 1449 let predicates = await new dataRdb.RdbPredicates("AllDataType"); 1450 predicates.endsWith("stringValue", "LMN"); 1451 let result = await rdbStore.query(predicates); 1452 expect(3).assertEqual(result.rowCount); 1453 result = null 1454 done(); 1455 console.log(TAG + "************* testEndsWith0001 end *************"); 1456 }) 1457 1458 /** 1459 * @tc.name predicates endsWith normal test 1460 * @tc.number SUB_DDM_AppDataFWK_JSRDB_Predicates_0121 1461 * @tc.desc predicates endsWith normal test 1462 */ 1463 it('testEndsWith0002', 0, async function (done) { 1464 console.log(TAG + "************* testEndsWith0002 start *************"); 1465 let predicates = await new dataRdb.RdbPredicates("AllDataType"); 1466 predicates.endsWith("stringValue", "LMNX"); 1467 let result = await rdbStore.query(predicates); 1468 expect(0).assertEqual(result.rowCount); 1469 result = null 1470 done(); 1471 console.log(TAG + "************* testEndsWith0002 end *************"); 1472 }) 1473 1474 /** 1475 * @tc.name predicates endsWith normal test 1476 * @tc.number SUB_DDM_AppDataFWK_JSRDB_Predicates_0122 1477 * @tc.desc predicates endsWith normal test 1478 */ 1479 it('testEndsWith0003', 0, async function (done) { 1480 console.log(TAG + "************* testEndsWith0003 start *************"); 1481 let predicates = await new dataRdb.RdbPredicates("AllDataType"); 1482 predicates.endsWith("characterValue", "中"); 1483 let result = await rdbStore.query(predicates); 1484 expect(1).assertEqual(result.rowCount); 1485 result = null 1486 done(); 1487 console.log(TAG + "************* testEndsWith0003 end *************"); 1488 }) 1489 1490 /** 1491 * @tc.name predicates endsWith normal test 1492 * @tc.number SUB_DDM_AppDataFWK_JSRDB_Predicates_0123 1493 * @tc.desc predicates endsWith normal test 1494 */ 1495 it('testEndsWith0004', 0, async function (done) { 1496 console.log(TAG + "************* testEndsWith0004 start *************"); 1497 let predicates = await new dataRdb.RdbPredicates("AllDataType"); 1498 predicates.endsWith("characterValue", "#"); 1499 let result = await rdbStore.query(predicates); 1500 expect(1).assertEqual(result.rowCount); 1501 result = null 1502 done(); 1503 console.log(TAG + "************* testEndsWith0004 end *************"); 1504 }) 1505 1506 /** 1507 * @tc.name predicates like normal test 1508 * @tc.number SUB_DDM_AppDataFWK_JSRDB_Predicates_0130 1509 * @tc.desc predicates like normal test 1510 */ 1511 it('testLike0001', 0, async function (done) { 1512 console.log(TAG + "************* testLike0001 start *************"); 1513 let predicates = await new dataRdb.RdbPredicates("AllDataType"); 1514 predicates.like("stringValue", "%LMN%"); 1515 let result = await rdbStore.query(predicates); 1516 expect(3).assertEqual(result.rowCount); 1517 result = null 1518 done(); 1519 console.log(TAG + "************* testLike0001 end *************"); 1520 }) 1521 1522 /** 1523 * @tc.name predicates like normal test 1524 * @tc.number SUB_DDM_AppDataFWK_JSRDB_Predicates_0130 1525 * @tc.desc predicates like normal test 1526 */ 1527 it('testLike0002', 0, async function (done) { 1528 console.log(TAG + "************* testLike0002 start *************"); 1529 let predicates = await new dataRdb.RdbPredicates("AllDataType"); 1530 predicates.like("stringValue", "%LMNX%"); 1531 let result = await rdbStore.query(predicates); 1532 expect(0).assertEqual(result.rowCount); 1533 result = null 1534 done(); 1535 console.log(TAG + "************* testLike0002 end *************"); 1536 }) 1537 1538 /** 1539 * @tc.name predicates like normal test 1540 * @tc.number SUB_DDM_AppDataFWK_JSRDB_Predicates_0132 1541 * @tc.desc predicates like normal test 1542 */ 1543 it('testLike0003', 0, async function (done) { 1544 console.log(TAG + "************* testLike0003 start *************"); 1545 let predicates = await new dataRdb.RdbPredicates("AllDataType"); 1546 predicates.like("characterValue", "%中%"); 1547 let result = await rdbStore.query(predicates); 1548 expect(1).assertEqual(result.rowCount); 1549 result = null 1550 done(); 1551 console.log(TAG + "************* testLike0003 end *************"); 1552 }) 1553 1554 /** 1555 * @tc.name predicates like normal test 1556 * @tc.number SUB_DDM_AppDataFWK_JSRDB_Predicates_0133 1557 * @tc.desc predicates like normal test 1558 */ 1559 it('testLike0004', 0, async function (done) { 1560 console.log(TAG + "************* testLike0004 start *************"); 1561 let predicates = await new dataRdb.RdbPredicates("AllDataType"); 1562 predicates.like("characterValue", "%#%"); 1563 let result = await rdbStore.query(predicates); 1564 expect(1).assertEqual(result.rowCount); 1565 result = null 1566 done(); 1567 console.log(TAG + "************* testLike0004 end *************"); 1568 }) 1569 1570 /** 1571 * @tc.name predicates beginWrap normal test 1572 * @tc.number SUB_DDM_AppDataFWK_JSRDB_Predicates_0140 1573 * @tc.desc predicates beginWrap normal test 1574 */ 1575 it('testBeginWrap0001', 0, async function (done) { 1576 console.log(TAG + "************* testBeginWrap0001 start *************"); 1577 { 1578 let predicates = await new dataRdb.RdbPredicates("AllDataType"); 1579 predicates.equalTo("stringValue", "ABCDEFGHIJKLMN") 1580 .beginWrap() 1581 .equalTo("integerValue", 1) 1582 .or() 1583 .equalTo("integerValue", 2147483647) 1584 .endWrap(); 1585 let result = await rdbStore.query(predicates); 1586 expect(2).assertEqual(result.rowCount); 1587 result = null 1588 } 1589 done(); 1590 console.log(TAG + "************* testBeginWrap0001 end *************"); 1591 }) 1592 1593 /** 1594 * @tc.name predicates beginWrap normal test 1595 * @tc.number SUB_DDM_AppDataFWK_JSRDB_Predicates_0141 1596 * @tc.desc predicates beginWrap normal test 1597 */ 1598 it('testBeginWrap0002', 0, async function (done) { 1599 console.log(TAG + "************* testBeginWrap0002 start *************"); 1600 { 1601 let predicates = await new dataRdb.RdbPredicates("AllDataType"); 1602 predicates.equalTo("stringValue", "ABCDEFGHIJKLMN") 1603 .beginWrap() 1604 .equalTo("characterValue", ' ') 1605 .endWrap(); 1606 let result = await rdbStore.query(predicates); 1607 expect(1).assertEqual(result.rowCount); 1608 result = null 1609 } 1610 done(); 1611 console.log(TAG + "************* testBeginWrap0002 end *************"); 1612 }) 1613 1614 /** 1615 * @tc.name predicates beginWrap normal test 1616 * @tc.number SUB_DDM_AppDataFWK_JSRDB_Predicates_0142 1617 * @tc.desc predicates beginWrap normal test 1618 */ 1619 it('testBeginWrap0003', 0, async function (done) { 1620 console.log(TAG + "************* testBeginWrap0003 start *************"); 1621 { 1622 let predicates = await new dataRdb.RdbPredicates("AllDataType"); 1623 predicates.equalTo("stringValue", "ABCDEFGHIJKLMN") 1624 .beginWrap() 1625 .equalTo("characterValue", '中') 1626 .endWrap(); 1627 let result = await rdbStore.query(predicates); 1628 expect(1).assertEqual(result.rowCount); 1629 result = null 1630 } 1631 done(); 1632 console.log(TAG + "************* testBeginWrap0003 end *************"); 1633 }) 1634 1635 /** 1636 * @tc.name predicates beginWrap normal test 1637 * @tc.number SUB_DDM_AppDataFWK_JSRDB_Predicates_0143 1638 * @tc.desc predicates beginWrap normal test 1639 */ 1640 it('testBeginWrap0004', 0, async function (done) { 1641 console.log(TAG + "************* testBeginWrap0004 start *************"); 1642 { 1643 let predicates = await new dataRdb.RdbPredicates("AllDataType"); 1644 predicates.equalTo("stringValue", "ABCDEFGHIJKLMN") 1645 .equalTo("characterValue", '中') 1646 .endWrap(); 1647 let result = await rdbStore.query(predicates); 1648 expect(-1).assertEqual(result.rowCount); 1649 result = null 1650 } 1651 done(); 1652 console.log(TAG + "************* testBeginWrap0004 end *************"); 1653 }) 1654 1655 /** 1656 * @tc.name predicates beginWrap normal test 1657 * @tc.number SUB_DDM_AppDataFWK_JSRDB_Predicates_0144 1658 * @tc.desc predicates beginWrap normal test 1659 */ 1660 it('testBeginWrap0005', 0, async function (done) { 1661 console.log(TAG + "************* testBeginWrap0005 start *************"); 1662 { 1663 let predicates = await new dataRdb.RdbPredicates("AllDataType"); 1664 predicates.equalTo("stringValue", "ABCDEFGHIJKLMN") 1665 .beginWrap() 1666 .equalTo("characterValue", '中'); 1667 let result = await rdbStore.query(predicates); 1668 expect(-1).assertEqual(result.rowCount); 1669 result = null 1670 } 1671 done(); 1672 console.log(TAG + "************* testBeginWrap0005 end *************"); 1673 }) 1674 1675 /** 1676 * @tc.name predicates and normal test 1677 * @tc.number SUB_DDM_AppDataFWK_JSRDB_Predicates_0150 1678 * @tc.desc predicates and normal test 1679 */ 1680 it('testAnd0001', 0, async function (done) { 1681 console.log(TAG + "************* testAnd0001 start *************"); 1682 { 1683 let predicates = await new dataRdb.RdbPredicates("AllDataType"); 1684 predicates.equalTo("stringValue", "ABCDEFGHIJKLMN") 1685 .and() 1686 .equalTo("integerValue", 1); 1687 let result = await rdbStore.query(predicates); 1688 expect(1).assertEqual(result.rowCount); 1689 result = null 1690 } 1691 done(); 1692 console.log(TAG + "************* testAnd0001 end *************"); 1693 }) 1694 1695 /** 1696 * @tc.name predicates or normal test 1697 * @tc.number SUB_DDM_AppDataFWK_JSRDB_Predicates_0151 1698 * @tc.desc predicates or normal test 1699 */ 1700 it('testAnd0002', 0, async function (done) { 1701 console.log(TAG + "************* testAnd0002 start *************"); 1702 { 1703 let predicates = await new dataRdb.RdbPredicates("AllDataType"); 1704 predicates.equalTo("stringValue", "ABCDEFGHIJKLMN") 1705 .beginWrap() 1706 .equalTo("integerValue", 1) 1707 .or() 1708 .equalTo("integerValue", 2147483647) 1709 .endWrap(); 1710 let result = await rdbStore.query(predicates); 1711 expect(2).assertEqual(result.rowCount); 1712 result = null 1713 } 1714 done(); 1715 console.log(TAG + "************* testAnd0002 end *************"); 1716 }) 1717 1718 /** 1719 * @tc.name predicates and normal test 1720 * @tc.number SUB_DDM_AppDataFWK_JSRDB_Predicates_0152 1721 * @tc.desc predicates and normal test 1722 */ 1723 it('testAnd0003', 0, async function (done) { 1724 console.log(TAG + "************* testAnd0003 start *************"); 1725 { 1726 let predicates = await new dataRdb.RdbPredicates("AllDataType"); 1727 predicates.equalTo("stringValue", "ABCDEFGHIJKLMN").or().and().equalTo("integerValue", 1); 1728 console.log(TAG + "you should not start a request" + " with \"and\" or use or() before this function"); 1729 } 1730 done(); 1731 console.log(TAG + "************* testAnd0003 end *************"); 1732 }) 1733 1734 /** 1735 * @tc.name predicates and normal test 1736 * @tc.number SUB_DDM_AppDataFWK_JSRDB_Predicates_0153 1737 * @tc.desc predicates and normal test 1738 */ 1739 it('testAnd0004', 0, async function (done) { 1740 console.log(TAG + "************* testAnd0004 start *************"); 1741 { 1742 let predicates = await new dataRdb.RdbPredicates("AllDataType"); 1743 predicates.equalTo("stringValue", "ABCDEFGHIJKLMN").or().or().equalTo("integerValue", 1); 1744 console.log(TAG + "you are starting a sql request with predicate or or," 1745 + "using function or() immediately after another or(). that is ridiculous."); 1746 } 1747 done(); 1748 console.log(TAG + "************* testAnd0004 end *************"); 1749 }) 1750 1751 /** 1752 * @tc.name predicates order normal test 1753 * @tc.number SUB_DDM_AppDataFWK_JSRDB_Predicates_0160 1754 * @tc.desc predicates order normal test 1755 */ 1756 it('testOrder0001', 0, async function (done) { 1757 console.log(TAG + "************* testOrder0001 start *************"); 1758 { 1759 let predicates = await new dataRdb.RdbPredicates("AllDataType"); 1760 predicates.equalTo("stringValue", "ABCDEFGHIJKLMN").orderByAsc("integerValue").distinct(); 1761 let result = await rdbStore.query(predicates); 1762 expect(3).assertEqual(result.rowCount); 1763 expect(true).assertEqual(result.goToFirstRow()) 1764 expect(3).assertEqual(result.getLong(0)); 1765 expect(true).assertEqual(result.goToNextRow()) 1766 expect(2).assertEqual(result.getLong(0)); 1767 expect(true).assertEqual(result.goToNextRow()) 1768 expect(1).assertEqual(result.getLong(0)); 1769 result = null 1770 } 1771 done(); 1772 console.log(TAG + "************* testOrder0001 end *************"); 1773 }) 1774 1775 /** 1776 * @tc.name predicates order normal test 1777 * @tc.number SUB_DDM_AppDataFWK_JSRDB_Predicates_0161 1778 * @tc.desc predicates order normal test 1779 */ 1780 it('testOrder0002', 0, async function (done) { 1781 console.log(TAG + "************* testOrder0002 start *************"); 1782 { 1783 let predicates = await new dataRdb.RdbPredicates("AllDataType"); 1784 predicates.equalTo("stringValue", "ABCDEFGHIJKLMN").orderByDesc("integerValue").distinct(); 1785 let result = await rdbStore.query(predicates); 1786 expect(3).assertEqual(result.rowCount); 1787 expect(true).assertEqual(result.goToFirstRow()) 1788 expect(1).assertEqual(result.getLong(0)); 1789 expect(true).assertEqual(result.goToNextRow()) 1790 expect(2).assertEqual(result.getLong(0)); 1791 expect(true).assertEqual(result.goToNextRow()) 1792 expect(3).assertEqual(result.getLong(0)); 1793 result = null 1794 } 1795 done(); 1796 console.log(TAG + "************* testOrder0002 end *************"); 1797 }) 1798 1799 /** 1800 * @tc.name predicates order normal test 1801 * @tc.number SUB_DDM_AppDataFWK_JSRDB_Predicates_0162 1802 * @tc.desc predicates order normal test 1803 */ 1804 it('testOrder0003', 0, async function (done) { 1805 console.log(TAG + "************* testOrder0003 start *************"); 1806 { 1807 let predicates = await new dataRdb.RdbPredicates("AllDataType"); 1808 predicates.equalTo("stringValue", "ABCDEFGHIJKLMN").orderByDesc("integerValueX").distinct(); 1809 let result = await rdbStore.query(predicates); 1810 expect(-1).assertEqual(result.rowCount); 1811 result = null 1812 } 1813 done(); 1814 console.log(TAG + "************* testOrder0003 end *************"); 1815 }) 1816 1817 /** 1818 * @tc.name predicates order normal test 1819 * @tc.number SUB_DDM_AppDataFWK_JSRDB_Predicates_0163 1820 * @tc.desc predicates order normal test 1821 */ 1822 it('testOrder0004', 0, async function (done) { 1823 console.log(TAG + "************* testOrder0004 start *************"); 1824 { 1825 let predicates = await new dataRdb.RdbPredicates("AllDataType"); 1826 predicates.equalTo("stringValue", "ABCDEFGHIJKLMN").orderByAsc("integerValueX").distinct(); 1827 let result = await rdbStore.query(predicates); 1828 expect(-1).assertEqual(result.rowCount); 1829 result = null 1830 } 1831 done(); 1832 console.log(TAG + "************* testOrder0004 end *************"); 1833 }) 1834 1835 /** 1836 * @tc.name predicates limit normal test 1837 * @tc.number SUB_DDM_AppDataFWK_JSRDB_Predicates_0170 1838 * @tc.desc predicates limit normal test 1839 */ 1840 it('testLimit0001', 0, async function (done) { 1841 console.log(TAG + "************* testLimit0001 start *************"); 1842 let predicates = await new dataRdb.RdbPredicates("AllDataType"); 1843 predicates.like("stringValue", "ABCDEFGHIJKLMN").limitAs(1); 1844 let result = await rdbStore.query(predicates); 1845 expect(1).assertEqual(result.rowCount); 1846 result = null 1847 done(); 1848 console.log(TAG + "************* testLimit0001 end *************"); 1849 }) 1850 1851 /** 1852 * @tc.name predicates limit normal test 1853 * @tc.number SUB_DDM_AppDataFWK_JSRDB_Predicates_0171 1854 * @tc.desc predicates limit normal test 1855 */ 1856 it('testLimit0002', 0, async function (done) { 1857 console.log(TAG + "************* testLimit0002 start *************"); 1858 let predicates = await new dataRdb.RdbPredicates("AllDataType"); 1859 predicates.like("stringValue", "ABCDEFGHIJKLMN").limitAs(3); 1860 let result = await rdbStore.query(predicates); 1861 expect(3).assertEqual(result.rowCount); 1862 result = null 1863 done(); 1864 console.log(TAG + "************* testLimit0002 end *************"); 1865 }) 1866 1867 /** 1868 * @tc.name predicates limit normal test 1869 * @tc.number SUB_DDM_AppDataFWK_JSRDB_Predicates_0172 1870 * @tc.desc predicates limit normal test 1871 */ 1872 it('testLimit0003', 0, async function (done) { 1873 console.log(TAG + "************* testLimit0003 start *************"); 1874 let predicates = await new dataRdb.RdbPredicates("AllDataType"); 1875 predicates.like("stringValue", "ABCDEFGHIJKLMN").limitAs(100); 1876 let result = await rdbStore.query(predicates); 1877 expect(3).assertEqual(result.rowCount); 1878 result = null 1879 done(); 1880 console.log(TAG + "************* testLimit0003 end *************"); 1881 }) 1882 1883 /** 1884 * @tc.name predicates limit normal test 1885 * @tc.number SUB_DDM_AppDataFWK_JSRDB_Predicates_0173 1886 * @tc.desc predicates limit normal test 1887 */ 1888 it('testLimit0004', 0, async function (done) { 1889 console.log(TAG + "************* testLimit0004 start *************"); 1890 let predicates = await new dataRdb.RdbPredicates("AllDataType"); 1891 predicates.like("stringValue", "中").limitAs(1); 1892 let result = await rdbStore.query(predicates); 1893 expect(0).assertEqual(result.rowCount); 1894 result = null 1895 done(); 1896 console.log(TAG + "************* testLimit0004 end *************"); 1897 }) 1898 1899 /** 1900 * @tc.name predicates limit normal test 1901 * @tc.number SUB_DDM_AppDataFWK_JSRDB_Predicates_0174 1902 * @tc.desc predicates limit normal test 1903 */ 1904 it('testLimit0005', 0, async function (done) { 1905 console.log(TAG + "************* testLimit0005 start *************"); 1906 let predicates = await new dataRdb.RdbPredicates("AllDataType"); 1907 predicates.like("stringValue", "ABCDEFGHIJKLMN").limitAs(0); 1908 let result = await rdbStore.query(predicates); 1909 expect(3).assertEqual(result.rowCount); 1910 result = null 1911 done(); 1912 console.log(TAG + "************* testLimit0005 end *************"); 1913 }) 1914 1915 /** 1916 * @tc.name predicates limit normal test 1917 * @tc.number SUB_DDM_AppDataFWK_JSRDB_Predicates_0175 1918 * @tc.desc predicates limit normal test 1919 */ 1920 it('testLimit0006', 0, async function (done) { 1921 console.log(TAG + "************* testLimit0006 start *************"); 1922 let predicates = await new dataRdb.RdbPredicates("AllDataType"); 1923 predicates.like("stringValue", "ABCDEFGHIJKLMN").limitAs(-1); 1924 let result = await rdbStore.query(predicates); 1925 expect(3).assertEqual(result.rowCount); 1926 result = null 1927 done(); 1928 console.log(TAG + "************* testLimit0006 end *************"); 1929 }) 1930 1931 /** 1932 * @tc.name predicates offset normal test 1933 * @tc.number SUB_DDM_AppDataFWK_JSRDB_Predicates_0180 1934 * @tc.desc predicates offset normal test 1935 */ 1936 it('testOffset0001', 0, async function (done) { 1937 console.log(TAG + "************* testOffset0001 start *************"); 1938 let predicates = await new dataRdb.RdbPredicates("AllDataType"); 1939 predicates.like("stringValue", "ABCDEFGHIJKLMN").limitAs(3).offsetAs(1); 1940 let result = await rdbStore.query(predicates); 1941 expect(2).assertEqual(result.rowCount); 1942 result = null 1943 done(); 1944 console.log(TAG + "************* testOffset0001 end *************"); 1945 }) 1946 1947 /** 1948 * @tc.name predicates offset normal test 1949 * @tc.number SUB_DDM_AppDataFWK_JSRDB_Predicates_0181 1950 * @tc.desc predicates offset normal test 1951 */ 1952 it('testOffset0002', 0, async function (done) { 1953 console.log(TAG + "************* testOffset0002 start *************"); 1954 let predicates = await new dataRdb.RdbPredicates("AllDataType"); 1955 predicates.like("stringValue", "ABCDEFGHIJKLMN").limitAs(3).offsetAs(0); 1956 let result = await rdbStore.query(predicates); 1957 expect(3).assertEqual(result.rowCount); 1958 result = null 1959 done(); 1960 console.log(TAG + "************* testOffset0002 end *************"); 1961 }) 1962 1963 /** 1964 * @tc.name predicates offset normal test 1965 * @tc.number SUB_DDM_AppDataFWK_JSRDB_Predicates_0182 1966 * @tc.desc predicates offset normal test 1967 */ 1968 it('testOffset0003', 0, async function (done) { 1969 console.log(TAG + "************* testOffset0003 start *************"); 1970 let predicates = await new dataRdb.RdbPredicates("AllDataType"); 1971 predicates.like("stringValue", "ABCDEFGHIJKLMN").limitAs(3).offsetAs(5); 1972 let result = await rdbStore.query(predicates); 1973 expect(0).assertEqual(result.rowCount); 1974 result = null 1975 done(); 1976 console.log(TAG + "************* testOffset0003 end *************"); 1977 }) 1978 1979 /** 1980 * @tc.name predicates offset normal test 1981 * @tc.number SUB_DDM_AppDataFWK_JSRDB_Predicates_0183 1982 * @tc.desc predicates offset normal test 1983 */ 1984 it('testOffset0004', 0, async function (done) { 1985 console.log(TAG + "************* testOffset0004 start *************"); 1986 let predicates = await new dataRdb.RdbPredicates("AllDataType"); 1987 predicates.like("stringValue", "ABCDEFGHIJKLMN").limitAs(3).offsetAs(-1); 1988 let result = await rdbStore.query(predicates); 1989 expect(3).assertEqual(result.rowCount); 1990 result = null 1991 done(); 1992 console.log(TAG + "************* testOffset0004 end *************"); 1993 }) 1994 1995 /** 1996 * @tc.name predicates in normal test 1997 * @tc.number SUB_DDM_AppDataFWK_JSRDB_Predicates_0190 1998 * @tc.desc predicates in normal test 1999 */ 2000 it('testIn0001', 0, async function (done) { 2001 console.log(TAG + "************* testIn0001 start *************"); 2002 var values = [Number.MIN_VALUE.toString()]; 2003 let predicates = await new dataRdb.RdbPredicates("AllDataType"); 2004 predicates.in("doubleValue", values); 2005 let result = await rdbStore.query(predicates); 2006 expect(1).assertEqual(result.rowCount); 2007 done(); 2008 console.log(TAG + "************* testIn0001 end *************"); 2009 }) 2010 2011 /** 2012 * @tc.name predicates in normal test 2013 * @tc.number SUB_DDM_AppDataFWK_JSRDB_Predicates_0191 2014 * @tc.desc predicates in normal test 2015 */ 2016 it('testIn0002', 0, async function (done) { 2017 console.log(TAG + "************* testIn0002 start *************"); 2018 var values = ["1.0"]; 2019 let predicates = await new dataRdb.RdbPredicates("AllDataType"); 2020 predicates.in("doubleValue", values); 2021 let result = await rdbStore.query(predicates); 2022 expect(1).assertEqual(result.rowCount); 2023 done(); 2024 console.log(TAG + "************* testIn0002 end *************"); 2025 }) 2026 2027 /** 2028 * @tc.name predicates in normal test 2029 * @tc.number SUB_DDM_AppDataFWK_JSRDB_Predicates_0192 2030 * @tc.desc predicates in normal test 2031 */ 2032 it('testIn0003', 0, async function (done) { 2033 console.log(TAG + "************* testIn0003 start *************"); 2034 var values = [DOUBLE_MAX.toString()]; 2035 let predicates = await new dataRdb.RdbPredicates("AllDataType"); 2036 predicates.in("doubleValue", values); 2037 let result = await rdbStore.query(predicates); 2038 expect(1).assertEqual(result.rowCount); 2039 done(); 2040 console.log(TAG + "************* testIn0003 end *************"); 2041 }) 2042 2043 /** 2044 * @tc.name predicates in normal test 2045 * @tc.number SUB_DDM_AppDataFWK_JSRDB_Predicates_0193 2046 * @tc.desc predicates in normal test 2047 */ 2048 it('testIn0004', 0, async function (done) { 2049 console.log(TAG + "************* testIn0004 start *************"); 2050 var values = [Number.MIN_VALUE.toString(), "1.0", DOUBLE_MAX.toString()]; 2051 let predicates = await new dataRdb.RdbPredicates("AllDataType"); 2052 predicates.in("doubleValue", values); 2053 let result = await rdbStore.query(predicates); 2054 expect(3).assertEqual(result.rowCount); 2055 done(); 2056 console.log(TAG + "************* testIn0004 end *************"); 2057 }) 2058 2059 /** 2060 * @tc.name testNotIn0001 2061 * @tc.number I4JWCV 2062 * @tc.desc the common and min value test with notin. 2063 */ 2064 it('testNotIn0001', 0, async function (done) { 2065 console.log(TAG + "************* testNotIn0001 start *************"); 2066 var values = [1, -2147483648]; 2067 let predicates = await new dataRdb.RdbPredicates("AllDataType"); 2068 predicates.notIn("integerValue", values); 2069 let result = await rdbStore.query(predicates); 2070 expect(1).assertEqual(result.rowCount); 2071 result.close(); 2072 done(); 2073 console.log(TAG + "************* testNotIn0001 end *************"); 2074 }) 2075 2076 /** 2077 * @tc.name testNotIn0002 2078 * @tc.number I4JWCV 2079 * @tc.desc the common and max value test with notin. 2080 */ 2081 it('testNotIn0002', 0, async function (done) { 2082 console.log(TAG + "************* testNotIn0002 start *************"); 2083 let values = [1, 2147483647]; 2084 let predicates = await new dataRdb.RdbPredicates("AllDataType"); 2085 predicates.notIn("integerValue", values); 2086 let result = await rdbStore.query(predicates); 2087 expect(1).assertEqual(result.rowCount); 2088 result.close(); 2089 done(); 2090 console.log(TAG + "************* testNotIn0002 end *************"); 2091 }) 2092 2093 /** 2094 * @tc.name testNotIn0003 2095 * @tc.number I4JWCV 2096 * @tc.desc the min and max value test with notin. 2097 */ 2098 it('testNotIn0003', 0, async function (done) { 2099 console.log(TAG + "************* testNotIn0003 start *************"); 2100 var values = [-2147483648, 2147483647]; 2101 let predicates = await new dataRdb.RdbPredicates("AllDataType"); 2102 predicates.notIn("integerValue", values); 2103 let result = await rdbStore.query(predicates); 2104 expect(1).assertEqual(result.rowCount); 2105 result.close(); 2106 done(); 2107 console.log(TAG + "************* testNotIn0003 end *************"); 2108 }) 2109 2110 /** 2111 * @tc.name predicates constructor test 2112 * @tc.number SUB_DDM_AppDataFWK_JSRDB_Predicates_0200 2113 * @tc.desc predicates constructor test 2114 */ 2115 it('testCreate0001', 0, async function (done) { 2116 console.log(TAG + "************* testCreate0001 start *************"); 2117 let predicates = await new dataRdb.RdbPredicates("AllDataType"); 2118 let result = await rdbStore.query(predicates); 2119 expect(3).assertEqual(result.rowCount); 2120 done(); 2121 console.log(TAG + "************* testCreate0001 end *************"); 2122 }) 2123 2124 /** 2125 * @tc.name predicates constructor test 2126 * @tc.number SUB_DDM_AppDataFWK_JSRDB_Predicates_0201 2127 * @tc.desc predicates constructor test 2128 */ 2129 it('testCreate0002', 0, async function (done) { 2130 console.log(TAG + "************* testCreate0002 start *************"); 2131 let predicates = await new dataRdb.RdbPredicates("test"); 2132 let result = await rdbStore.query(predicates); 2133 expect(-1).assertEqual(result.rowCount); 2134 done(); 2135 console.log(TAG + "************* testCreate0002 end *************"); 2136 }) 2137 2138 /** 2139 * @tc.name predicates groupBy test 2140 * @tc.number SUB_DDM_AppDataFWK_JSRDB_Predicates_0210 2141 * @tc.desc predicates groupBy test 2142 */ 2143 it('testGroupBy0001', 0, async function (done) { 2144 console.log(TAG + "************* testGroupBy0001 start *************"); 2145 let predicates = await new dataRdb.RdbPredicates("AllDataType"); 2146 predicates.like("stringValue", "ABCDEFGHIJKLMN").groupBy(["characterValue"]); 2147 let result = await rdbStore.query(predicates); 2148 expect(3).assertEqual(result.rowCount); 2149 result = null 2150 done(); 2151 console.log(TAG + "************* testGroupBy0001 end *************"); 2152 }) 2153 2154 /** 2155 * @tc.name predicates groupBy test 2156 * @tc.number SUB_DDM_AppDataFWK_JSRDB_Predicates_0211 2157 * @tc.desc predicates groupBy test 2158 */ 2159 it('testGroupBy0002', 0, async function (done) { 2160 console.log(TAG + "************* testGroupBy0002 start *************"); 2161 let predicates = await new dataRdb.RdbPredicates("AllDataType"); 2162 predicates.like("stringValue", "ABCDEFGHIJKLMN").groupBy(["characterValueX"]); 2163 let result = await rdbStore.query(predicates); 2164 expect(-1).assertEqual(result.rowCount); 2165 result = null 2166 done(); 2167 console.log(TAG + "************* testGroupBy0002 end *************"); 2168 }) 2169 2170 /** 2171 * @tc.name predicates indexedBy test 2172 * @tc.number SUB_DDM_AppDataFWK_JSRDB_Predicates_0220 2173 * @tc.desc predicates indexedBy test 2174 */ 2175 it('testIndexedBy0001', 0, async function (done) { 2176 console.log(TAG + "************* testIndexedBy0001 start *************"); 2177 let predicates = await new dataRdb.RdbPredicates("AllDataType"); 2178 predicates.like("stringValue", "ABCDEFGHIJKLMN").indexedBy("characterValue"); 2179 let result = await rdbStore.query(predicates); 2180 //test table have no indexe column, so return -1 2181 expect(-1).assertEqual(result.rowCount); 2182 result = null 2183 done(); 2184 console.log(TAG + "************* testIndexedBy0001 end *************"); 2185 }) 2186 2187 /** 2188 * @tc.name predicates indexedBy test 2189 * @tc.number SUB_DDM_AppDataFWK_JSRDB_Predicates_0221 2190 * @tc.desc predicates indexedBy test 2191 */ 2192 it('testIndexedBy0002', 0, async function (done) { 2193 console.log(TAG + "************* testIndexedBy0002 start *************"); 2194 let predicates = await new dataRdb.RdbPredicates("AllDataType"); 2195 try { 2196 predicates.like("stringValue", "ABCDEFGHIJKLMN").indexedBy(["characterValueX"]); 2197 let result = await rdbStore.query(predicates); 2198 expect(3).assertEqual(result.rowCount); 2199 result = null 2200 } catch (err) { 2201 console.log("catch err: failed, err: code=" + err.code + " message=" + err.message) 2202 } 2203 done(); 2204 console.log(TAG + "************* testIndexedBy0002 end *************"); 2205 }) 2206 2207 console.log(TAG + "*************Unit Test End*************"); 2208})