RdbStoreResultSetJsunit.test.js 69.5 KB
Newer Older
S
smagicyun 已提交
1 2 3 4 5 6 7 8 9
/*
 * Copyright (C) 2021 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
Y
yanglifeng 已提交
10
 * distributed under the License is distributed on an 'AS IS' BASIS,
S
smagicyun 已提交
11 12 13 14
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
J
jiyong_sd 已提交
15
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from '@ohos/hypium'
16
import dataRdb from '@ohos.data.rdb'
S
smagicyun 已提交
17

Y
yanglifeng 已提交
18 19
const TAG = '[RDB_JSKITS_TEST]'
const CREATE_TABLE_TEST = 'CREATE TABLE IF NOT EXISTS test (' + 'id INTEGER PRIMARY KEY AUTOINCREMENT, ' + 'data1 text,' + 'data2 long, ' + 'data3 double,' + 'data4 blob)';
S
smagicyun 已提交
20 21

const STORE_CONFIG = {
Y
yanglifeng 已提交
22
    name: 'Resultset.db',
S
smagicyun 已提交
23
}
1
18834416147 已提交
24
const COLOUNM_NAMES = ["id","data1","data2","data3","data4"];
S
smagicyun 已提交
25 26
var rdbStore = undefined;

L
liangzhenyu123 已提交
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
function createUint8Array(length) {
    let i = 0
    let index = 0
    let temp = null
    let u8 = new Uint8Array(length)
    length = typeof (length) === 'undefined' ? 9 : length
    for (i = 1; i <= length; i++) {
        u8[i - 1] = i
    }
    for (i = 1; i <= length; i++) {
        index = parseInt(Math.random() * (length - i)) + i
        if (index != i) {
            temp = u8[i - 1]
            u8[i - 1] = u8[index - 1]
            u8[index - 1] = temp
        }
    }
    return u8;
}

async function createBigData(size) {
    await rdbStore.executeSql("DELETE FROM test");
    let u8 = createUint8Array(32768);
    let valueBucketArray = new Array();
    for (let i = 0; i < size; i++) {
        valueBucketArray.push({
            "data1": "test" + i,
            "data2": 18,
            "data3": 100.5,
            "data4": u8,
        });
    }
    await rdbStore.batchInsert("test", valueBucketArray);
}

J
jiyong_sd 已提交
62
export default function rdbResultSetTest() {
S
smagicyun 已提交
63 64 65
describe('rdbResultSetTest', function () {
    beforeAll(async function () {
        console.info(TAG + 'beforeAll')
66
        rdbStore = await dataRdb.getRdbStore(STORE_CONFIG, 1);
S
smagicyun 已提交
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
        await rdbStore.executeSql(CREATE_TABLE_TEST, null);
        await createTest();
    })

    beforeEach(async function () {
        console.info(TAG + 'beforeEach')
    })

    afterEach(function () {
        console.info(TAG + 'afterEach')
    })

    afterAll(async function () {
        console.info(TAG + 'afterAll')
        rdbStore = null
Y
yanglifeng 已提交
82
        await dataRdb.deleteRdbStore('Resultset.db');
S
smagicyun 已提交
83 84 85
    })
    //插入数据
    async function createTest() {
L
liangzhenyu123 已提交
86
        console.info(TAG + 'createTest data start');
S
smagicyun 已提交
87 88 89
        {
            var u8 = new Uint8Array([1, 2, 3])
            const valueBucket = {
Y
yanglifeng 已提交
90 91 92 93
                'data1': 'hello',
                'data2': 10,
                'data3': 1.0,
                'data4': u8,
S
smagicyun 已提交
94
            }
Y
yanglifeng 已提交
95
            await rdbStore.insert('test', valueBucket)
S
smagicyun 已提交
96 97 98 99
        }
        {
            var u8 = new Uint8Array([3, 4, 5])
            const valueBucket = {
Y
yanglifeng 已提交
100 101 102 103
                'data1': '2',
                'data2': -5,
                'data3': 2.5,
                'data4': u8,
S
smagicyun 已提交
104
            }
Y
yanglifeng 已提交
105
            await rdbStore.insert('test', valueBucket)
S
smagicyun 已提交
106 107 108 109
        }
        {
            var u8 = new Uint8Array(0)
            const valueBucket = {
Y
yanglifeng 已提交
110 111 112 113
                'data1': 'hello world',
                'data2': 3,
                'data3': 1.8,
                'data4': u8,
S
smagicyun 已提交
114
            }
Y
yanglifeng 已提交
115
            await rdbStore.insert('test', valueBucket)
S
smagicyun 已提交
116
        }
L
liangzhenyu123 已提交
117
        console.info(TAG + 'createTest data end');
S
smagicyun 已提交
118 119 120 121 122 123 124 125
    }

    /**
     * @tc.name resultSet getBlob normal test
     * @tc.number SUB_DDM_AppDataFWK_JSRDB_ResultSet_0010
     * @tc.desc resultSet getBlob normal test
     */
    it('testGetBlob0001', 0, async function (done) {
L
liangzhenyu123 已提交
126
        console.info(TAG + '************* testGetBlob0001 start *************');
Y
yanglifeng 已提交
127
        let predicates = await new dataRdb.RdbPredicates('test')
S
smagicyun 已提交
128 129 130 131
        let resultSet = await rdbStore.query(predicates)
        try {
            {
                expect(true).assertEqual(resultSet.goToFirstRow())
Y
yanglifeng 已提交
132 133
                const id = resultSet.getLong(resultSet.getColumnIndex('id'))
                const data4 = resultSet.getBlob(resultSet.getColumnIndex('data4'))
L
liangzhenyu123 已提交
134
                console.info(TAG + 'id=' + id + ', data4=' + data4);
S
smagicyun 已提交
135 136 137 138 139 140 141 142 143 144 145
                expect(1).assertEqual(data4[0]);
                expect(2).assertEqual(data4[1]);
                expect(3).assertEqual(data4[2]);
            }
            resultSet.close();
            expect(true).assertEqual(resultSet.isClosed)
        } catch (e) {
            expect(null).assertFail();
        }
        resultSet = null
        done();
L
liangzhenyu123 已提交
146
        console.info(TAG + '************* testGetBlob0001 end *************');
S
smagicyun 已提交
147 148 149 150 151 152 153 154
    })

    /**
     * @tc.name resultSet getBlob normal test
     * @tc.number SUB_DDM_AppDataFWK_JSRDB_ResultSet_0011
     * @tc.desc resultSet getBlob normal test
     */
    it('testGetBlob0002', 0, async function (done) {
L
liangzhenyu123 已提交
155
        console.info(TAG + '************* testGetBlob0002 start *************');
Y
yanglifeng 已提交
156
        let predicates = await new dataRdb.RdbPredicates('test')
S
smagicyun 已提交
157 158 159 160 161
        let resultSet = await rdbStore.query(predicates)
        try {
            {
                expect(true).assertEqual(resultSet.goToFirstRow())
                expect(true).assertEqual(resultSet.goToNextRow())
Y
yanglifeng 已提交
162 163
                const id = resultSet.getLong(resultSet.getColumnIndex('id'))
                const data4 = resultSet.getBlob(resultSet.getColumnIndex('data4'))
L
liangzhenyu123 已提交
164
                console.info(TAG + 'id=' + id + ', data4=' + data4);
S
smagicyun 已提交
165 166 167 168 169 170 171 172 173 174 175
                expect(3).assertEqual(data4[0]);
                expect(4).assertEqual(data4[1]);
                expect(5).assertEqual(data4[2]);
            }
            resultSet.close();
            expect(true).assertEqual(resultSet.isClosed)
        } catch (e) {
            expect(null).assertFail();
        }
        resultSet = null
        done();
L
liangzhenyu123 已提交
176
        console.info(TAG + '************* testGetBlob0002 end *************');
S
smagicyun 已提交
177 178 179 180 181 182 183 184
    })

    /**
     * @tc.name resultSet getBlob normal test
     * @tc.number SUB_DDM_AppDataFWK_JSRDB_ResultSet_0012
     * @tc.desc resultSet getBlob normal test
     */
    it('testGetBlob0003', 0, async function (done) {
L
liangzhenyu123 已提交
185
        console.info(TAG + '************* testGetBlob0003 start *************');
Y
yanglifeng 已提交
186
        let predicates = await new dataRdb.RdbPredicates('test')
S
smagicyun 已提交
187 188 189 190 191 192
        let resultSet = await rdbStore.query(predicates)
        try {
            {
                expect(true).assertEqual(resultSet.goToFirstRow())
                expect(true).assertEqual(resultSet.goToNextRow())
                expect(true).assertEqual(resultSet.goToNextRow())
Y
yanglifeng 已提交
193 194
                const id = resultSet.getLong(resultSet.getColumnIndex('id'))
                const data4 = resultSet.getBlob(resultSet.getColumnIndex('data4'))
L
liangzhenyu123 已提交
195
                console.info(TAG + 'id=' + id);
S
smagicyun 已提交
196 197 198 199 200 201 202 203
            }
            resultSet.close();
            expect(true).assertEqual(resultSet.isClosed)
        } catch (e) {
            expect(null).assertFail();
        }
        resultSet = null
        done();
L
liangzhenyu123 已提交
204
        console.info(TAG + '************* testGetBlob0003 end *************');
S
smagicyun 已提交
205 206 207 208 209 210 211 212
    })

    /**
     * @tc.name resultSet isStarted normal test
     * @tc.number SUB_DDM_AppDataFWK_JSRDB_ResultSet_0020
     * @tc.desc resultSet isStarted normal test
     */
    it('testIsStarted0001', 0, async function (done) {
L
liangzhenyu123 已提交
213
        console.info(TAG + '************* testIsStarted0001 start *************');
Y
yanglifeng 已提交
214
        let predicates = await new dataRdb.RdbPredicates('test')
S
smagicyun 已提交
215 216 217 218 219 220 221 222
        let resultSet = await rdbStore.query(predicates)
        try {
            expect(false).assertEqual(resultSet.isStarted)
        } catch (e) {
            expect(null).assertFail();
        }
        resultSet = null
        done();
L
liangzhenyu123 已提交
223
        console.info(TAG + '************* testIsStarted0001 end *************');
S
smagicyun 已提交
224 225 226 227 228 229 230 231
    })

    /**
     * @tc.name resultSet isStarted normal test
     * @tc.number SUB_DDM_AppDataFWK_JSRDB_ResultSet_0021
     * @tc.desc resultSet isStarted normal test
     */
    it('testIsStarted0002', 0, async function (done) {
L
liangzhenyu123 已提交
232
        console.info(TAG + '************* testIsStarted0002 start *************');
Y
yanglifeng 已提交
233
        let predicates = await new dataRdb.RdbPredicates('test')
S
smagicyun 已提交
234 235 236 237 238 239 240 241 242
        let resultSet = await rdbStore.query(predicates)
        try {
            resultSet.goTo(1)
            expect(true).assertEqual(resultSet.isStarted)
        } catch (e) {
            expect(null).assertFail();
        }
        resultSet = null
        done();
L
liangzhenyu123 已提交
243
        console.info(TAG + '************* testIsStarted0002 end *************');
S
smagicyun 已提交
244 245 246 247 248 249 250 251
    })

    /**
     * @tc.name resultSet isStarted normal test
     * @tc.number SUB_DDM_AppDataFWK_JSRDB_ResultSet_0022
     * @tc.desc resultSet isStarted normal test
     */
    it('testIsStarted0003', 0, async function (done) {
L
liangzhenyu123 已提交
252 253
        console.info(TAG + "************* testIsStarted0003 start *************");
        let predicates = await new dataRdb.RdbPredicates("test")
S
smagicyun 已提交
254 255
        let resultSet = await rdbStore.query(predicates)
        try {
L
liangzhenyu123 已提交
256
            expect(false).assertEqual(resultSet.isStarted)
S
smagicyun 已提交
257 258 259
            expect(true).assertEqual(resultSet.goToNextRow())
            expect(true).assertEqual(resultSet.isStarted)
            expect(false).assertEqual(resultSet.goToPreviousRow())
L
liangzhenyu123 已提交
260
            expect(true).assertEqual(resultSet.isStarted)
S
smagicyun 已提交
261 262 263 264 265
        } catch (e) {
            expect(null).assertFail();
        }
        resultSet = null
        done();
L
liangzhenyu123 已提交
266
        console.info(TAG + "************* testIsStarted0003 end *************");
S
smagicyun 已提交
267 268 269 270 271 272 273 274
    })

    /**
     * @tc.name resultSet isStarted with no result test
     * @tc.number SUB_DDM_AppDataFWK_JSRDB_ResultSet_0023
     * @tc.desc resultSet isStarted with no result test
     */
    it('testIsStarted0004', 0, async function (done) {
L
liangzhenyu123 已提交
275
        console.info(TAG + '************* testIsStarted0004 start *************');
Y
yanglifeng 已提交
276
        let predicates = await new dataRdb.RdbPredicates('test')
S
smagicyun 已提交
277 278 279 280 281 282 283 284 285 286
        let resultSet = await rdbStore.query(predicates)
        try {
            expect(true).assertEqual(resultSet.goToNextRow())
            expect(true).assertEqual(resultSet.isStarted)
            expect(true).assertEqual(resultSet.isStarted)
        } catch (e) {
            expect(null).assertFail();
        }
        resultSet = null
        done();
L
liangzhenyu123 已提交
287
        console.info(TAG + '************* testIsStarted0004 end *************');
S
smagicyun 已提交
288 289 290 291 292 293 294 295 296
    })


    /**
     * @tc.name resultSet isEnded normal test
     * @tc.number SUB_DDM_AppDataFWK_JSRDB_ResultSet_0030
     * @tc.desc resultSet isEnded normal test
     */
    it('testIsEnded0001', 0, async function (done) {
L
liangzhenyu123 已提交
297
        console.info(TAG + '************* testIsEnded0001 start *************');
Y
yanglifeng 已提交
298
        let predicates = await new dataRdb.RdbPredicates('test')
S
smagicyun 已提交
299 300 301 302 303 304 305 306 307
        let resultSet = await rdbStore.query(predicates)
        try {
            expect(true).assertEqual(resultSet.goToFirstRow())
            expect(false).assertEqual(resultSet.isEnded)
        } catch (e) {
            expect(null).assertFail();
        }
        resultSet = null
        done();
L
liangzhenyu123 已提交
308
        console.info(TAG + '************* testIsEnded0001 end *************');
S
smagicyun 已提交
309 310 311 312 313 314 315 316
    })

    /**
     * @tc.name resultSet isEnded normal test
     * @tc.number SUB_DDM_AppDataFWK_JSRDB_ResultSet_0031
     * @tc.desc resultSet isEnded normal test
     */
    it('testIsEnded0002', 0, async function (done) {
L
liangzhenyu123 已提交
317
        console.info(TAG + '************* testIsEnded0002 start *************');
Y
yanglifeng 已提交
318
        let predicates = await new dataRdb.RdbPredicates('test')
S
smagicyun 已提交
319 320 321 322 323 324 325 326 327
        let resultSet = await rdbStore.query(predicates)
        try {
            expect(true).assertEqual(resultSet.goToLastRow())
            expect(false).assertEqual(resultSet.isEnded)
        } catch (e) {
            expect(null).assertFail();
        }
        resultSet = null
        done();
L
liangzhenyu123 已提交
328
        console.info(TAG + '************* testIsEnded0002 end *************');
S
smagicyun 已提交
329 330 331 332 333 334 335 336
    })

    /**
     * @tc.name resultSet isEnded normal test
     * @tc.number SUB_DDM_AppDataFWK_JSRDB_ResultSet_0032
     * @tc.desc resultSet isEnded normal test
     */
    it('testIsEnded0003', 0, async function (done) {
L
liangzhenyu123 已提交
337
        console.info(TAG + '************* testIsEnded0003 start *************');
Y
yanglifeng 已提交
338
        let predicates = await new dataRdb.RdbPredicates('test')
S
smagicyun 已提交
339 340 341 342 343 344 345 346 347
        let resultSet = await rdbStore.query(predicates)
        try {
            resultSet.goToRow(3)
            expect(true).assertEqual(resultSet.isEnded)
        } catch (e) {
            expect(null).assertFail();
        }
        resultSet = null
        done();
L
liangzhenyu123 已提交
348
        console.info(TAG + '************* testIsEnded0003 end *************');
S
smagicyun 已提交
349 350 351 352 353 354 355 356
    })

    /**
     * @tc.name resultSet isEnded normal test
     * @tc.number SUB_DDM_AppDataFWK_JSRDB_ResultSet_0033
     * @tc.desc resultSet isEnded normal test
     */
    it('testIsEnded0004', 0, async function (done) {
L
liangzhenyu123 已提交
357
        console.info(TAG + '************* testIsEnded0004 start *************');
Y
yanglifeng 已提交
358
        let predicates = await new dataRdb.RdbPredicates('test')
S
smagicyun 已提交
359 360 361 362 363 364 365 366 367 368
        let resultSet = await rdbStore.query(predicates)
        try {
            resultSet.goToRow(3)
            expect(true).assertEqual(resultSet.isEnded)
            expect(true).assertEqual(resultSet.isEnded)
        } catch (e) {
            expect(null).assertFail();
        }
        resultSet = null
        done();
L
liangzhenyu123 已提交
369
        console.info(TAG + '************* testIsEnded0004 end *************');
S
smagicyun 已提交
370 371 372 373 374 375 376 377
    })

    /**
     * @tc.name resultSet rowCount normal test
     * @tc.number SUB_DDM_AppDataFWK_JSRDB_ResultSet_0040
     * @tc.desc resultSet rowCount normal test
     */
    it('testRowCount0001', 0, async function (done) {
L
liangzhenyu123 已提交
378
        console.info(TAG + '************* testRowCount0001 start *************');
Y
yanglifeng 已提交
379
        let predicates = await new dataRdb.RdbPredicates('test')
S
smagicyun 已提交
380 381 382 383 384 385 386 387
        let resultSet = await rdbStore.query(predicates)
        try {
            expect(3).assertEqual(resultSet.rowCount)
        } catch (e) {
            expect(null).assertFail();
        }
        resultSet = null
        done();
L
liangzhenyu123 已提交
388
        console.info(TAG + '************* testRowCount0001 end *************');
S
smagicyun 已提交
389 390 391 392 393 394 395 396
    })

    /**
     * @tc.name resultSet rowCount with no result test
     * @tc.number SUB_DDM_AppDataFWK_JSRDB_ResultSet_0041
     * @tc.desc resultSet rowCount with no result test
     */
    it('testRowCount0002', 0, async function (done) {
L
liangzhenyu123 已提交
397
        console.info(TAG + '************* testRowCount0002 start *************');
Y
yanglifeng 已提交
398 399
        let predicates = await new dataRdb.RdbPredicates('test')
        predicates.equalTo('name', 'wangwu');
S
smagicyun 已提交
400 401 402 403 404 405 406 407
        let resultSet = await rdbStore.query(predicates)
        try {
            expect(-1).assertEqual(resultSet.rowCount)
        } catch (e) {
            expect(null).assertFail();
        }
        resultSet = null
        done();
L
liangzhenyu123 已提交
408
        console.info(TAG + '************* testRowCount0002 end *************');
S
smagicyun 已提交
409 410 411 412 413 414 415 416
    })

    /**
     * @tc.name resultSet rowCount test
     * @tc.number SUB_DDM_AppDataFWK_JSRDB_ResultSet_0042
     * @tc.desc resultSet rowCount test
     */
    it('testRowCount0003', 0, async function (done) {
L
liangzhenyu123 已提交
417
        console.info(TAG + '************* testRowCount0003 start *************');
Y
yanglifeng 已提交
418 419
        let predicates = await new dataRdb.RdbPredicates('test')
        predicates.equalTo('data1', 'hello');
S
smagicyun 已提交
420 421 422 423 424 425 426 427
        let resultSet = await rdbStore.query(predicates)
        try {
            expect(1).assertEqual(resultSet.rowCount)
        } catch (e) {
            expect(null).assertFail();
        }
        resultSet = null
        done();
L
liangzhenyu123 已提交
428
        console.info(TAG + '************* testRowCount0003 end *************');
S
smagicyun 已提交
429 430 431 432 433 434 435 436
    })

    /**
     * @tc.name resultSet rowCount test
     * @tc.number SUB_DDM_AppDataFWK_JSRDB_ResultSet_0043
     * @tc.desc resultSet rowCount test
     */
    it('testRowCount0004', 0, async function (done) {
L
liangzhenyu123 已提交
437
        console.info(TAG + '************* testRowCount0004 start *************');
Y
yanglifeng 已提交
438 439 440
        let predicates = await new dataRdb.RdbPredicates('test')
        predicates.equalTo('data1', 'hello');
        predicates.equalTo('data2', 3);
S
smagicyun 已提交
441 442 443 444 445 446 447 448
        let resultSet = await rdbStore.query(predicates)
        try {
            expect(0).assertEqual(resultSet.rowCount)
        } catch (e) {
            expect(null).assertFail();
        }
        resultSet = null
        done();
L
liangzhenyu123 已提交
449
        console.info(TAG + '************* testRowCount0003 end *************');
S
smagicyun 已提交
450 451 452 453 454 455 456 457
    })

    /**
     * @tc.name resultSet getLong test
     * @tc.number SUB_DDM_AppDataFWK_JSRDB_ResultSet_0050
     * @tc.desc resultSet getLong test
     */
    it('testGetLong0001', 0, async function (done) {
L
liangzhenyu123 已提交
458
        console.info(TAG + '************* testGetLong0001 start *************');
Y
yanglifeng 已提交
459
        let predicates = await new dataRdb.RdbPredicates('test')
S
smagicyun 已提交
460 461 462 463
        let resultSet = await rdbStore.query(predicates)
        try {
            {
                expect(true).assertEqual(resultSet.goToFirstRow())
Y
yanglifeng 已提交
464 465
                const id = resultSet.getLong(resultSet.getColumnIndex('id'))
                const data2 = resultSet.getLong(resultSet.getColumnIndex('data2'))
L
liangzhenyu123 已提交
466
                console.info(TAG + 'id=' + id + ', data2=' + data2);
S
smagicyun 已提交
467 468 469 470 471 472 473 474 475
                expect(10).assertEqual(data2);
            }
            resultSet.close();
            expect(true).assertEqual(resultSet.isClosed)
        } catch (e) {
            expect(null).assertFail();
        }
        resultSet = null
        done();
L
liangzhenyu123 已提交
476
        console.info(TAG + '************* testGetLong0001 end *************');
S
smagicyun 已提交
477 478 479 480 481 482 483 484
    })

    /**
     * @tc.name resultSet getLong test
     * @tc.number SUB_DDM_AppDataFWK_JSRDB_ResultSet_0051
     * @tc.desc resultSet getLong test
     */
    it('testGetLong0002', 0, async function (done) {
L
liangzhenyu123 已提交
485
        console.info(TAG + '************* testGetLong0002 start *************');
Y
yanglifeng 已提交
486
        let predicates = await new dataRdb.RdbPredicates('test')
S
smagicyun 已提交
487 488 489 490 491
        let resultSet = await rdbStore.query(predicates)
        try {
            {
                expect(true).assertEqual(resultSet.goToFirstRow())
                expect(true).assertEqual(resultSet.goToNextRow())
Y
yanglifeng 已提交
492
                const data1 = resultSet.getLong(resultSet.getColumnIndex('data1'))
S
smagicyun 已提交
493 494 495 496 497 498 499 500 501
                expect(2).assertEqual(data1);
            }
            resultSet.close();
            expect(true).assertEqual(resultSet.isClosed)
        } catch (e) {
            expect(null).assertFail();
        }
        resultSet = null
        done();
L
liangzhenyu123 已提交
502
        console.info(TAG + '************* testGetLong0002 end *************');
S
smagicyun 已提交
503 504 505 506 507 508 509 510
    })

    /**
     * @tc.name resultSet getLong test
     * @tc.number SUB_DDM_AppDataFWK_JSRDB_ResultSet_0052
     * @tc.desc resultSet getLong test
     */
    it('testGetLong0003', 0, async function (done) {
L
liangzhenyu123 已提交
511
        console.info(TAG + '************* testGetLong0003 start *************');
Y
yanglifeng 已提交
512
        let predicates = await new dataRdb.RdbPredicates('test')
S
smagicyun 已提交
513 514 515 516 517
        let resultSet = await rdbStore.query(predicates)
        try {
            {
                expect(true).assertEqual(resultSet.goToFirstRow())
                expect(true).assertEqual(resultSet.goToNextRow())
Y
yanglifeng 已提交
518
                const data2 = resultSet.getLong(resultSet.getColumnIndex('data2'))
S
smagicyun 已提交
519 520 521 522 523 524 525 526 527
                expect(-5).assertEqual(data2);
            }
            resultSet.close();
            expect(true).assertEqual(resultSet.isClosed)
        } catch (e) {
            expect(null).assertFail();
        }
        resultSet = null
        done();
L
liangzhenyu123 已提交
528
        console.info(TAG + '************* testGetLong0003 end *************');
S
smagicyun 已提交
529 530 531 532 533 534 535 536
    })

    /**
     * @tc.name resultSet getString test
     * @tc.number SUB_DDM_AppDataFWK_JSRDB_ResultSet_0060
     * @tc.desc resultSet getString test
     */
    it('testGetString0001', 0, async function (done) {
L
liangzhenyu123 已提交
537
        console.info(TAG + '************* testGetString0001 start *************');
Y
yanglifeng 已提交
538
        let predicates = await new dataRdb.RdbPredicates('test')
S
smagicyun 已提交
539 540 541
        let resultSet = await rdbStore.query(predicates)
        {
            expect(true).assertEqual(resultSet.goToFirstRow())
Y
yanglifeng 已提交
542 543
            const data1 = resultSet.getString(resultSet.getColumnIndex('data1'))
            expect('hello').assertEqual(data1);
S
smagicyun 已提交
544 545 546
        }
        resultSet = null
        done();
L
liangzhenyu123 已提交
547
        console.info(TAG + '************* testGetString0001 end *************');
S
smagicyun 已提交
548 549 550 551 552 553 554 555
    })

    /**
     * @tc.name resultSet getString test
     * @tc.number SUB_DDM_AppDataFWK_JSRDB_ResultSet_0061
     * @tc.desc resultSet getString test
     */
    it('testGetString0002', 0, async function (done) {
L
liangzhenyu123 已提交
556
        console.info(TAG + '************* testGetString0002 start *************');
Y
yanglifeng 已提交
557
        let predicates = await new dataRdb.RdbPredicates('test')
S
smagicyun 已提交
558 559 560
        let resultSet = await rdbStore.query(predicates)
        {
            expect(true).assertEqual(resultSet.goToFirstRow())
Y
yanglifeng 已提交
561 562
            const data2 = resultSet.getString(resultSet.getColumnIndex('data2'))
            expect('10').assertEqual(data2);
S
smagicyun 已提交
563 564 565
        }
        resultSet = null
        done();
L
liangzhenyu123 已提交
566
        console.info(TAG + '************* testGetString0002 end *************');
S
smagicyun 已提交
567 568 569 570 571 572 573 574
    })

    /**
     * @tc.name resultSet getString test
     * @tc.number SUB_DDM_AppDataFWK_JSRDB_ResultSet_0062
     * @tc.desc resultSet getString test
     */
    it('testGetString0003', 0, async function (done) {
L
liangzhenyu123 已提交
575
        console.info(TAG + '************* testGetString0003 start *************');
Y
yanglifeng 已提交
576
        let predicates = await new dataRdb.RdbPredicates('test')
S
smagicyun 已提交
577 578 579 580
        let resultSet = await rdbStore.query(predicates)
        {
            expect(true).assertEqual(resultSet.goToFirstRow())
            expect(true).assertEqual(resultSet.goToNextRow())
Y
yanglifeng 已提交
581 582
            const data3 = resultSet.getString(resultSet.getColumnIndex('data3'))
            expect('2.5').assertEqual(data3);
S
smagicyun 已提交
583 584 585
        }
        resultSet = null
        done();
L
liangzhenyu123 已提交
586
        console.info(TAG + '************* testGetString0003 end *************');
S
smagicyun 已提交
587 588 589 590 591 592 593 594
    })

    /**
     * @tc.name resultSet getString test
     * @tc.number SUB_DDM_AppDataFWK_JSRDB_ResultSet_0063
     * @tc.desc resultSet getString test
     */
    it('testGetString0004', 0, async function (done) {
L
liangzhenyu123 已提交
595
        console.info(TAG + '************* testGetString0004 start *************');
Y
yanglifeng 已提交
596
        let predicates = await new dataRdb.RdbPredicates('test')
S
smagicyun 已提交
597 598 599 600 601
        let resultSet = await rdbStore.query(predicates)
        {
            expect(true).assertEqual(resultSet.goToFirstRow())
            expect(true).assertEqual(resultSet.goToNextRow())
            expect(true).assertEqual(resultSet.goToNextRow())
Y
yanglifeng 已提交
602 603 604 605 606 607
            const data1 = resultSet.getString(resultSet.getColumnIndex('data1'))
            const data2 = resultSet.getString(resultSet.getColumnIndex('data2'))
            const data3 = resultSet.getString(resultSet.getColumnIndex('data3'))
            expect('hello world').assertEqual(data1);
            expect('3').assertEqual(data2);
            expect('1.8').assertEqual(data3);
S
smagicyun 已提交
608 609 610
        }
        resultSet = null
        done();
L
liangzhenyu123 已提交
611
        console.info(TAG + '************* testGetString0004 end *************');
S
smagicyun 已提交
612 613 614 615 616 617 618 619
    })

    /**
     * @tc.name resultSet isClosed test
     * @tc.number SUB_DDM_AppDataFWK_JSRDB_ResultSet_0070
     * @tc.desc resultSet isClosed test
     */
    it('testIsClosed0001', 0, async function (done) {
L
liangzhenyu123 已提交
620
        console.info(TAG + '************* testIsClosed0001 start *************');
Y
yanglifeng 已提交
621
        let predicates = await new dataRdb.RdbPredicates('test')
S
smagicyun 已提交
622 623 624 625 626 627 628 629
        let resultSet = await rdbStore.query(predicates)

        expect(3).assertEqual(resultSet.rowCount)
        resultSet.close();
        expect(true).assertEqual(resultSet.isClosed)

        resultSet = null
        done();
L
liangzhenyu123 已提交
630
        console.info(TAG + '************* testIsClosed0001 end *************');
S
smagicyun 已提交
631 632 633 634 635 636 637 638
    })

    /**
     * @tc.name resultSet isClosed with not close test
     * @tc.number SUB_DDM_AppDataFWK_JSRDB_ResultSet_0071
     * @tc.desc resultSet isClosed with not close test
     */
    it('testIsClosed0002', 0, async function (done) {
L
liangzhenyu123 已提交
639
        console.info(TAG + '************* testIsClosed0002 start *************');
Y
yanglifeng 已提交
640
        let predicates = await new dataRdb.RdbPredicates('test')
S
smagicyun 已提交
641 642 643 644 645
        let resultSet = await rdbStore.query(predicates)
        expect(false).assertEqual(resultSet.isClosed)

        resultSet = null
        done();
L
liangzhenyu123 已提交
646
        console.info(TAG + '************* testIsClosed0002 end *************');
S
smagicyun 已提交
647 648 649 650 651 652 653 654
    })

    /**
     * @tc.name resultSet isClosed with not close test
     * @tc.number SUB_DDM_AppDataFWK_JSRDB_ResultSet_0072
     * @tc.desc resultSet isClosed with not close test
     */
    it('testIsClosed0003', 0, async function (done) {
L
liangzhenyu123 已提交
655
        console.info(TAG + '************* testIsClosed0003 start *************');
Y
yanglifeng 已提交
656 657
        let predicates = await new dataRdb.RdbPredicates('test')
        predicates.equalTo('name', 'wangwu');
S
smagicyun 已提交
658 659 660 661 662
        let resultSet = await rdbStore.query(predicates)
        expect(false).assertEqual(resultSet.isClosed)

        resultSet = null
        done();
L
liangzhenyu123 已提交
663
        console.info(TAG + '************* testIsClosed0003 end *************');
S
smagicyun 已提交
664 665 666 667 668 669 670 671
    })

    /**
     * @tc.name resultSet columnCount test
     * @tc.number SUB_DDM_AppDataFWK_JSRDB_ResultSet_0080
     * @tc.desc resultSet columnCount test
     */
    it('testColumnCount0001', 0, async function (done) {
L
liangzhenyu123 已提交
672
        console.info(TAG + '************* testColumnCount0001 start *************');
S
smagicyun 已提交
673
        {
Y
yanglifeng 已提交
674
            let predicates = await new dataRdb.RdbPredicates('test')
S
smagicyun 已提交
675 676 677 678
            let resultSet = await rdbStore.query(predicates)
            expect(5).assertEqual(resultSet.columnCount);
            resultSet = null;
            done();
L
liangzhenyu123 已提交
679
            console.info(TAG + '************* testColumnCount0001 end *************');
S
smagicyun 已提交
680 681 682 683 684 685 686 687 688
        }
    })

    /**
     * @tc.name resultSet columnCount test
     * @tc.number SUB_DDM_AppDataFWK_JSRDB_ResultSet_0081
     * @tc.desc resultSet columnCount test
     */
    it('testColumnCount0002', 0, async function (done) {
L
liangzhenyu123 已提交
689
        console.info(TAG + '************* testColumnCount0002 start *************');
S
smagicyun 已提交
690
        {
Y
yanglifeng 已提交
691 692
            let predicates = await new dataRdb.RdbPredicates('test')
            predicates.equalTo('name', 'wangwu');
S
smagicyun 已提交
693 694 695 696
            let resultSet = await rdbStore.query(predicates)
            expect(0).assertEqual(resultSet.columnCount);
            resultSet = null;
            done();
L
liangzhenyu123 已提交
697
            console.info(TAG + '************* testColumnCount0002 end *************');
S
smagicyun 已提交
698 699 700 701 702 703 704 705 706
        }
    })

    /**
     * @tc.name resultSet rowIndex test
     * @tc.number SUB_DDM_AppDataFWK_JSRDB_ResultSet_0090
     * @tc.desc resultSet rowIndex test
     */
    it('testRowIndex0001', 0, async function (done) {
L
liangzhenyu123 已提交
707
        console.info(TAG + '************* testRowIndex0001 *************');
S
smagicyun 已提交
708
        {
Y
yanglifeng 已提交
709
            let predicates = await new dataRdb.RdbPredicates('test')
S
smagicyun 已提交
710 711 712 713 714 715 716 717
            let resultSet = await rdbStore.query(predicates)
            {
                expect(true).assertEqual(resultSet.goToFirstRow())
                expect(0).assertEqual(resultSet.rowIndex)
            }

            resultSet = null;
            done();
L
liangzhenyu123 已提交
718
            console.info(TAG + '************* testRowIndex0001 end *************');
S
smagicyun 已提交
719 720 721 722 723 724 725 726 727
        }
    })

    /**
     * @tc.name resultSet rowIndex at last row test
     * @tc.number SUB_DDM_AppDataFWK_JSRDB_ResultSet_0091
     * @tc.desc resultSet rowIndex at last row test
     */
    it('testRowIndex0002', 0, async function (done) {
L
liangzhenyu123 已提交
728
        console.info(TAG + '************* testRowIndex0002 *************');
S
smagicyun 已提交
729
        {
Y
yanglifeng 已提交
730
            let predicates = await new dataRdb.RdbPredicates('test')
S
smagicyun 已提交
731 732 733 734 735 736 737 738
            let resultSet = await rdbStore.query(predicates)
            {
                expect(true).assertEqual(resultSet.goToLastRow())
                expect(2).assertEqual(resultSet.rowIndex)
            }

            resultSet = null;
            done();
L
liangzhenyu123 已提交
739
            console.info(TAG + '************* testRowIndex0002 end *************');
S
smagicyun 已提交
740 741 742 743 744 745 746 747 748
        }
    })

    /**
     * @tc.name resultSet goToFirstRow normal test
     * @tc.number SUB_DDM_AppDataFWK_JSRDB_ResultSet_0100
     * @tc.desc resultSet goToFirstRow normal test
     */
    it('testGoToFirstRow0001', 0, async function (done) {
L
liangzhenyu123 已提交
749
        console.info(TAG + '************* testGoToFirstRow0001 start *************');
S
smagicyun 已提交
750

Y
yanglifeng 已提交
751
        let predicates = await new dataRdb.RdbPredicates('test')
S
smagicyun 已提交
752 753 754 755 756 757 758 759 760
        let resultSet = await rdbStore.query(predicates)
        try {
            expect(true).assertEqual(resultSet.goToFirstRow())
            resultSet.close();
        } catch (e) {
            expect(null).assertFail();
        }
        resultSet = null
        done();
L
liangzhenyu123 已提交
761
        console.info(TAG + '************* testGoToFirstRow0001 end *************');
S
smagicyun 已提交
762 763 764 765 766 767 768 769
    })

    /**
     * @tc.name resultSet goToFirstRow with no result test
     * @tc.number SUB_DDM_AppDataFWK_JSRDB_ResultSet_0101
     * @tc.desc resultSet goToFirstRow with no result test
     */
    it('testGoToFirstRow0002', 0, async function (done) {
L
liangzhenyu123 已提交
770
        console.info(TAG + '************* testGoToFirstRow0002 start *************');
S
smagicyun 已提交
771

Y
yanglifeng 已提交
772 773
        let predicates = await new dataRdb.RdbPredicates('test')
        predicates.equalTo('name', 'wangwu');
S
smagicyun 已提交
774 775 776 777 778 779 780 781
        let resultSet = await rdbStore.query(predicates)
        try {
            expect(false).assertEqual(resultSet.goToFirstRow())
        } catch (e) {
            expect(null).assertFail();
        }
        resultSet = null
        done();
L
liangzhenyu123 已提交
782
        console.info(TAG + '************* testGoToFirstRow0002 end *************');
S
smagicyun 已提交
783 784 785 786 787 788 789 790
    })

    /**
     * @tc.name resultSet goToFirstRow test
     * @tc.number SUB_DDM_AppDataFWK_JSRDB_ResultSet_0102
     * @tc.desc resultSet goToFirstRow test
     */
    it('testGoToFirstRow0003', 0, async function (done) {
L
liangzhenyu123 已提交
791
        console.info(TAG + '************* testGoToFirstRow0003 start *************');
S
smagicyun 已提交
792

Y
yanglifeng 已提交
793
        let predicates = await new dataRdb.RdbPredicates('test')
S
smagicyun 已提交
794 795 796 797 798 799 800 801 802 803
        let resultSet = await rdbStore.query(predicates)
        try {
            expect(true).assertEqual(resultSet.goToFirstRow())
            expect(true).assertEqual(resultSet.goToNextRow())
            expect(true).assertEqual(resultSet.goToFirstRow())
        } catch (e) {
            expect(null).assertFail();
        }
        resultSet = null
        done();
L
liangzhenyu123 已提交
804
        console.info(TAG + '************* testGoToFirstRow0003 end *************');
S
smagicyun 已提交
805 806 807 808 809 810 811 812
    })

    /**
     * @tc.name resultSet goToLastRow test
     * @tc.number SUB_DDM_AppDataFWK_JSRDB_ResultSet_0110
     * @tc.desc resultSet goToFirstRow test
     */
    it('testGoToLastRow0001', 0, async function (done) {
L
liangzhenyu123 已提交
813
        console.info(TAG + '************* testGoToLastRow0001 start *************');
S
smagicyun 已提交
814
        {
Y
yanglifeng 已提交
815
            let predicates = await new dataRdb.RdbPredicates('test')
S
smagicyun 已提交
816 817 818 819 820 821
            let resultSet = await rdbStore.query(predicates)
            {
                expect(true).assertEqual(resultSet.goToLastRow())
            }
            resultSet = null;
            done();
L
liangzhenyu123 已提交
822
            console.info(TAG + '************* testGoToLastRow0001 end *************');
S
smagicyun 已提交
823 824 825 826 827 828 829 830 831
        }
    })

    /**
     * @tc.name resultSet goToLastRow with no result test
     * @tc.number SUB_DDM_AppDataFWK_JSRDB_ResultSet_0111
     * @tc.desc resultSet goToLastRow with no result test
     */
    it('testGoToLastRow0002', 0, async function (done) {
L
liangzhenyu123 已提交
832
        console.info(TAG + '************* testGoToLastRow0002 start *************');
S
smagicyun 已提交
833
        {
Y
yanglifeng 已提交
834 835
            let predicates = await new dataRdb.RdbPredicates('test')
            predicates.equalTo('name', 'wangwu');
S
smagicyun 已提交
836 837 838 839 840 841
            let resultSet = await rdbStore.query(predicates)
            {
                expect(false).assertEqual(resultSet.goToLastRow())
            }
            resultSet = null;
            done();
L
liangzhenyu123 已提交
842
            console.info(TAG + '************* testGoToLastRow0002 end *************');
S
smagicyun 已提交
843 844 845 846 847 848 849 850 851
        }
    })

    /**
     * @tc.name resultSet goToLastRow test
     * @tc.number SUB_DDM_AppDataFWK_JSRDB_ResultSet_0112
     * @tc.desc resultSet goToLastRow test
     */
    it('testGoToLastRow0003', 0, async function (done) {
L
liangzhenyu123 已提交
852
        console.info(TAG + '************* testGoToLastRow0003 start *************');
S
smagicyun 已提交
853
        {
Y
yanglifeng 已提交
854
            let predicates = await new dataRdb.RdbPredicates('test')
S
smagicyun 已提交
855 856 857 858 859 860 861 862
            let resultSet = await rdbStore.query(predicates)
            {
                expect(true).assertEqual(resultSet.goToLastRow())
                expect(true).assertEqual(resultSet.goToPreviousRow())
                expect(true).assertEqual(resultSet.goToLastRow())
            }
            resultSet = null;
            done();
L
liangzhenyu123 已提交
863
            console.info(TAG + '************* testGoToLastRow0003 end *************');
S
smagicyun 已提交
864 865 866 867 868 869 870 871 872
        }
    })

    /**
     * @tc.name resultSet goToNextRow test
     * @tc.number SUB_DDM_AppDataFWK_JSRDB_ResultSet_0120
     * @tc.desc resultSet goToNextRow test
     */
    it('testGoToNextRow0001', 0, async function (done) {
L
liangzhenyu123 已提交
873
        console.info(TAG + '************* testGoToNextRow0001 start *************');
S
smagicyun 已提交
874
        {
Y
yanglifeng 已提交
875
            let predicates = await new dataRdb.RdbPredicates('test')
S
smagicyun 已提交
876 877 878 879 880 881
            let resultSet = await rdbStore.query(predicates)
            {
                expect(true).assertEqual(resultSet.goToNextRow())
            }
            resultSet = null;
            done();
L
liangzhenyu123 已提交
882
            console.info(TAG + '************* testGoToNextRow0001 end *************');
S
smagicyun 已提交
883 884 885 886 887 888 889 890 891
        }
    })

    /**
     * @tc.name resultSet goToNextRow with no result test
     * @tc.number SUB_DDM_AppDataFWK_JSRDB_ResultSet_0121
     * @tc.desc resultSet goToNextRow with no result test
     */
    it('testGoToNextRow0002', 0, async function (done) {
L
liangzhenyu123 已提交
892
        console.info(TAG + '************* testGoToNextRow0002 start *************');
S
smagicyun 已提交
893
        {
Y
yanglifeng 已提交
894 895
            let predicates = await new dataRdb.RdbPredicates('test')
            predicates.equalTo('name', 'wangwu');
S
smagicyun 已提交
896 897 898 899 900 901
            let resultSet = await rdbStore.query(predicates)
            {
                expect(false).assertEqual(resultSet.goToNextRow())
            }
            resultSet = null;
            done();
L
liangzhenyu123 已提交
902
            console.info(TAG + '************* testGoToNextRow0002 end *************');
S
smagicyun 已提交
903 904 905 906 907 908 909 910 911
        }
    })

    /**
     * @tc.name resultSet goToNextRow test
     * @tc.number SUB_DDM_AppDataFWK_JSRDB_ResultSet_0122
     * @tc.desc resultSet goToNextRow test
     */
    it('testGoToNextRow0003', 0, async function (done) {
L
liangzhenyu123 已提交
912
        console.info(TAG + '************* testGoToNextRow0003 start *************');
S
smagicyun 已提交
913
        {
Y
yanglifeng 已提交
914
            let predicates = await new dataRdb.RdbPredicates('test')
S
smagicyun 已提交
915 916 917 918 919 920 921 922 923
            let resultSet = await rdbStore.query(predicates)
            {
                expect(true).assertEqual(resultSet.goToFirstRow())
                expect(true).assertEqual(resultSet.goToNextRow())
                expect(true).assertEqual(resultSet.goToPreviousRow())
                expect(true).assertEqual(resultSet.goToNextRow())
            }
            resultSet = null;
            done();
L
liangzhenyu123 已提交
924
            console.info(TAG + '************* testGoToNextRow0003 end *************');
S
smagicyun 已提交
925 926 927 928 929 930 931 932 933
        }
    })

    /**
     * @tc.name resultSet goToNextRow after last row test
     * @tc.number SUB_DDM_AppDataFWK_JSRDB_ResultSet_0123
     * @tc.desc resultSet goToNextRow after last row test
     */
    it('testGoToNextRow0004', 0, async function (done) {
L
liangzhenyu123 已提交
934
        console.info(TAG + '************* testGoToNextRow0004 start *************');
S
smagicyun 已提交
935
        {
Y
yanglifeng 已提交
936
            let predicates = await new dataRdb.RdbPredicates('test')
S
smagicyun 已提交
937 938 939 940 941 942 943
            let resultSet = await rdbStore.query(predicates)
            {
                expect(true).assertEqual(resultSet.goToLastRow())
                expect(false).assertEqual(resultSet.goToNextRow())
            }
            resultSet = null;
            done();
L
liangzhenyu123 已提交
944
            console.info(TAG + '************* testGoToNextRow0004 end *************');
S
smagicyun 已提交
945 946 947 948 949 950 951 952 953
        }
    })

    /**
     * @tc.name resultSet goToPreviousRow test
     * @tc.number SUB_DDM_AppDataFWK_JSRDB_ResultSet_0130
     * @tc.desc resultSet goToPreviousRow test
     */
    it('testGoToPreviousRow0001', 0, async function (done) {
L
liangzhenyu123 已提交
954
        console.info(TAG + '************* testGoToPreviousRow0001 start *************');
S
smagicyun 已提交
955
        {
Y
yanglifeng 已提交
956
            let predicates = await new dataRdb.RdbPredicates('test')
S
smagicyun 已提交
957 958 959 960 961 962
            let resultSet = await rdbStore.query(predicates)
            {
                expect(false).assertEqual(resultSet.goToPreviousRow())
            }
            resultSet = null;
            done();
L
liangzhenyu123 已提交
963
            console.info(TAG + '************* testGoToPreviousRow0001 end *************');
S
smagicyun 已提交
964 965 966 967 968 969 970 971 972
        }
    })

    /**
     * @tc.name resultSet goToPreviousRow with no result test
     * @tc.number SUB_DDM_AppDataFWK_JSRDB_ResultSet_0131
     * @tc.desc resultSet goToPreviousRow with no result test
     */
    it('testGoToPreviousRow0002', 0, async function (done) {
L
liangzhenyu123 已提交
973
        console.info(TAG + '************* testGoToPreviousRow0002 start *************');
S
smagicyun 已提交
974
        {
Y
yanglifeng 已提交
975 976
            let predicates = await new dataRdb.RdbPredicates('test')
            predicates.equalTo('name', 'wangwu');
S
smagicyun 已提交
977 978 979 980 981 982
            let resultSet = await rdbStore.query(predicates)
            {
                expect(false).assertEqual(resultSet.goToPreviousRow())
            }
            resultSet = null;
            done();
L
liangzhenyu123 已提交
983
            console.info(TAG + '************* testGoToPreviousRow0002 end *************');
S
smagicyun 已提交
984 985 986 987 988 989 990 991 992
        }
    })

    /**
     * @tc.name resultSet goToPreviousRow test
     * @tc.number SUB_DDM_AppDataFWK_JSRDB_ResultSet_0132
     * @tc.desc resultSet goToPreviousRow test
     */
    it('testGoToPreviousRow0003', 0, async function (done) {
L
liangzhenyu123 已提交
993
        console.info(TAG + '************* testGoToPreviousRow0003 start *************');
S
smagicyun 已提交
994
        {
Y
yanglifeng 已提交
995
            let predicates = await new dataRdb.RdbPredicates('test')
S
smagicyun 已提交
996 997 998 999 1000 1001 1002 1003
            let resultSet = await rdbStore.query(predicates)
            {
                expect(true).assertEqual(resultSet.goToFirstRow())
                expect(true).assertEqual(resultSet.goToNextRow())
                expect(true).assertEqual(resultSet.goToPreviousRow())
            }
            resultSet = null;
            done();
L
liangzhenyu123 已提交
1004
            console.info(TAG + '************* testGoToPreviousRow0003 end *************');
S
smagicyun 已提交
1005 1006 1007 1008 1009 1010 1011 1012 1013
        }
    })

    /**
     * @tc.name resultSet goToPreviousRow after last row test
     * @tc.number SUB_DDM_AppDataFWK_JSRDB_ResultSet_0133
     * @tc.desc resultSet goToPreviousRow after last row test
     */
    it('testGoToPreviousRow0004', 0, async function (done) {
L
liangzhenyu123 已提交
1014
        console.info(TAG + '************* testGoToPreviousRow0004 start *************');
S
smagicyun 已提交
1015
        {
Y
yanglifeng 已提交
1016
            let predicates = await new dataRdb.RdbPredicates('test')
S
smagicyun 已提交
1017 1018 1019 1020 1021 1022 1023
            let resultSet = await rdbStore.query(predicates)
            {
                expect(true).assertEqual(resultSet.goToLastRow())
                expect(true).assertEqual(resultSet.goToPreviousRow())
            }
            resultSet = null;
            done();
L
liangzhenyu123 已提交
1024
            console.info(TAG + '************* testGoToPreviousRow0004 end *************');
S
smagicyun 已提交
1025 1026 1027 1028 1029 1030 1031 1032 1033
        }
    })

    /**
     * @tc.name resultSet goTo test
     * @tc.number SUB_DDM_AppDataFWK_JSRDB_ResultSet_0140
     * @tc.desc resultSet goTo test
     */
    it('testGoTo0001', 0, async function (done) {
L
liangzhenyu123 已提交
1034
        console.info(TAG + '************* testGoTo0001 start *************');
S
smagicyun 已提交
1035
        {
Y
yanglifeng 已提交
1036
            let predicates = await new dataRdb.RdbPredicates('test')
S
smagicyun 已提交
1037 1038 1039 1040 1041 1042 1043 1044
            let resultSet = await rdbStore.query(predicates)
            {
                expect(true).assertEqual(resultSet.goToFirstRow())
                resultSet.goTo(1)
                expect(1).assertEqual(resultSet.rowIndex)
            }
            resultSet = null;
            done();
L
liangzhenyu123 已提交
1045
            console.info(TAG + '************* testGoTo0001 end *************');
S
smagicyun 已提交
1046 1047 1048 1049 1050 1051 1052 1053 1054
        }
    })

    /**
     * @tc.name resultSet goTo with no result test
     * @tc.number SUB_DDM_AppDataFWK_JSRDB_ResultSet_0141
     * @tc.desc resultSet goTo with no result test
     */
    it('testGoTo0002', 0, async function (done) {
L
liangzhenyu123 已提交
1055
        console.info(TAG + '************* testGoTo0002 start *************');
S
smagicyun 已提交
1056
        {
Y
yanglifeng 已提交
1057 1058
            let predicates = await new dataRdb.RdbPredicates('test')
            predicates.equalTo('name', 'wangwu');
S
smagicyun 已提交
1059 1060 1061 1062 1063 1064 1065
            let resultSet = await rdbStore.query(predicates)
            {
                resultSet.goTo(1)
                expect(-1).assertEqual(resultSet.rowIndex)
            }
            resultSet = null;
            done();
L
liangzhenyu123 已提交
1066
            console.info(TAG + '************* testGoTo0002 end *************');
S
smagicyun 已提交
1067 1068 1069 1070 1071 1072 1073 1074 1075
        }
    })

    /**
     * @tc.name resultSet goTo test
     * @tc.number SUB_DDM_AppDataFWK_JSRDB_ResultSet_0142
     * @tc.desc resultSet goTo test
     */
    it('testGoTo0003', 0, async function (done) {
L
liangzhenyu123 已提交
1076
        console.info(TAG + '************* testGoTo0003 start *************');
S
smagicyun 已提交
1077
        {
Y
yanglifeng 已提交
1078
            let predicates = await new dataRdb.RdbPredicates('test')
S
smagicyun 已提交
1079 1080 1081 1082 1083 1084 1085 1086 1087
            let resultSet = await rdbStore.query(predicates)
            {
                expect(true).assertEqual(resultSet.goToFirstRow())
                expect(true).assertEqual(resultSet.goToNextRow())
                resultSet.goTo(1)
                expect(2).assertEqual(resultSet.rowIndex)
            }
            resultSet = null;
            done();
L
liangzhenyu123 已提交
1088
            console.info(TAG + '************* testGoTo0003 end *************');
S
smagicyun 已提交
1089 1090 1091 1092 1093 1094 1095 1096 1097
        }
    })

    /**
     * @tc.name resultSet goTo after last row test
     * @tc.number SUB_DDM_AppDataFWK_JSRDB_ResultSet_0143
     * @tc.desc resultSet goTo after last row test
     */
    it('testGoTo0004', 0, async function (done) {
L
liangzhenyu123 已提交
1098
        console.info(TAG + '************* testGoTo0004 start *************');
S
smagicyun 已提交
1099
        {
Y
yanglifeng 已提交
1100
            let predicates = await new dataRdb.RdbPredicates('test')
S
smagicyun 已提交
1101 1102 1103 1104 1105 1106 1107 1108
            let resultSet = await rdbStore.query(predicates)
            {
                expect(true).assertEqual(resultSet.goToLastRow())
                resultSet.goTo(5)
                expect(3).assertEqual(resultSet.rowIndex)
            }
            resultSet = null;
            done();
L
liangzhenyu123 已提交
1109
            console.info(TAG + '************* testGoTo0004 end *************');
S
smagicyun 已提交
1110 1111 1112 1113 1114 1115 1116 1117 1118
        }
    })

    /**
     * @tc.name resultSet goToRow test
     * @tc.number SUB_DDM_AppDataFWK_JSRDB_ResultSet_0150
     * @tc.desc resultSet goToRow test
     */
    it('testGoToRow0001', 0, async function (done) {
L
liangzhenyu123 已提交
1119
        console.info(TAG + '************* testGoToRow0001 start *************');
S
smagicyun 已提交
1120
        {
Y
yanglifeng 已提交
1121
            let predicates = await new dataRdb.RdbPredicates('test')
S
smagicyun 已提交
1122 1123 1124 1125 1126 1127 1128 1129
            let resultSet = await rdbStore.query(predicates)
            {
                expect(true).assertEqual(resultSet.goToFirstRow())
                resultSet.goToRow(1)
                expect(1).assertEqual(resultSet.rowIndex)
            }
            resultSet = null;
            done();
L
liangzhenyu123 已提交
1130
            console.info(TAG + '************* testGoToRow0001 end *************');
S
smagicyun 已提交
1131 1132 1133 1134 1135 1136 1137 1138 1139
        }
    })

    /**
     * @tc.name resultSet goToRow with no result test
     * @tc.number SUB_DDM_AppDataFWK_JSRDB_ResultSet_0151
     * @tc.desc resultSet goToRow with no result test
     */
    it('testGoToRow0002', 0, async function (done) {
L
liangzhenyu123 已提交
1140
        console.info(TAG + '************* testGoToRow0002 start *************');
S
smagicyun 已提交
1141
        {
Y
yanglifeng 已提交
1142 1143
            let predicates = await new dataRdb.RdbPredicates('test')
            predicates.equalTo('name', 'wangwu');
S
smagicyun 已提交
1144 1145 1146 1147 1148 1149 1150
            let resultSet = await rdbStore.query(predicates)
            {
                resultSet.goToRow(1)
                expect(-1).assertEqual(resultSet.rowIndex)
            }
            resultSet = null;
            done();
L
liangzhenyu123 已提交
1151
            console.info(TAG + '************* testGoToRow0002 end *************');
S
smagicyun 已提交
1152 1153 1154 1155 1156 1157 1158 1159 1160
        }
    })

    /**
     * @tc.name resultSet goToRow test
     * @tc.number SUB_DDM_AppDataFWK_JSRDB_ResultSet_0152
     * @tc.desc resultSet goToRow test
     */
    it('testGoToRow0003', 0, async function (done) {
L
liangzhenyu123 已提交
1161
        console.info(TAG + '************* testGoToRow0003 start *************');
S
smagicyun 已提交
1162
        {
Y
yanglifeng 已提交
1163
            let predicates = await new dataRdb.RdbPredicates('test')
S
smagicyun 已提交
1164 1165 1166 1167 1168 1169 1170 1171 1172 1173
            let resultSet = await rdbStore.query(predicates)
            {
                expect(true).assertEqual(resultSet.goToFirstRow())
                expect(true).assertEqual(resultSet.goToNextRow())
                expect(true).assertEqual(resultSet.goToNextRow())
                resultSet.goToRow(1)
                expect(1).assertEqual(resultSet.rowIndex)
            }
            resultSet = null;
            done();
L
liangzhenyu123 已提交
1174
            console.info(TAG + '************* testGoToRow0003 end *************');
S
smagicyun 已提交
1175 1176 1177 1178 1179 1180 1181 1182 1183
        }
    })

    /**
     * @tc.name resultSet goToRow after last row test
     * @tc.number SUB_DDM_AppDataFWK_JSRDB_ResultSet_0153
     * @tc.desc resultSet goToRow after last row test
     */
    it('testGoToRow0004', 0, async function (done) {
L
liangzhenyu123 已提交
1184
        console.info(TAG + '************* testGoToRow0004 start *************');
S
smagicyun 已提交
1185
        {
Y
yanglifeng 已提交
1186
            let predicates = await new dataRdb.RdbPredicates('test')
S
smagicyun 已提交
1187 1188 1189 1190 1191 1192 1193 1194
            let resultSet = await rdbStore.query(predicates)
            {
                expect(true).assertEqual(resultSet.goToLastRow())
                resultSet.goToRow(5)
                expect(3).assertEqual(resultSet.rowIndex)
            }
            resultSet = null;
            done();
L
liangzhenyu123 已提交
1195
            console.info(TAG + '************* testGoToRow0004 end *************');
S
smagicyun 已提交
1196 1197 1198 1199 1200 1201 1202 1203 1204
        }
    })

    /**
     * @tc.name resultSet isAtFirstRow test
     * @tc.number SUB_DDM_AppDataFWK_JSRDB_ResultSet_0160
     * @tc.desc resultSet isAtFirstRow test
     */
    it('testIsAtFirstRow0001', 0, async function (done) {
L
liangzhenyu123 已提交
1205
        console.info(TAG + '************* testIsAtFirstRow0001 start *************');
S
smagicyun 已提交
1206
        {
Y
yanglifeng 已提交
1207
            let predicates = await new dataRdb.RdbPredicates('test')
S
smagicyun 已提交
1208 1209 1210 1211 1212 1213 1214
            let resultSet = await rdbStore.query(predicates)
            {
                expect(true).assertEqual(resultSet.goToFirstRow())
                expect(true).assertEqual(resultSet.isAtFirstRow)
            }
            resultSet = null;
            done();
L
liangzhenyu123 已提交
1215
            console.info(TAG + '************* testIsAtFirstRow0001 end *************');
S
smagicyun 已提交
1216 1217 1218 1219 1220 1221 1222 1223 1224
        }
    })

    /**
     * @tc.name resultSet isAtFirstRow with no result test
     * @tc.number SUB_DDM_AppDataFWK_JSRDB_ResultSet_0161
     * @tc.desc resultSet isAtFirstRow with no result test
     */
    it('testIsAtFirstRow0002', 0, async function (done) {
L
liangzhenyu123 已提交
1225
        console.info(TAG + '************* testIsAtFirstRow0002 start *************');
S
smagicyun 已提交
1226
        {
Y
yanglifeng 已提交
1227 1228
            let predicates = await new dataRdb.RdbPredicates('test')
            predicates.equalTo('name', 'wangwu');
S
smagicyun 已提交
1229 1230 1231 1232 1233 1234
            let resultSet = await rdbStore.query(predicates)
            {
                expect(false).assertEqual(resultSet.isAtFirstRow)
            }
            resultSet = null;
            done();
L
liangzhenyu123 已提交
1235
            console.info(TAG + '************* testIsAtFirstRow0002 end *************');
S
smagicyun 已提交
1236 1237 1238 1239 1240 1241 1242 1243 1244
        }
    })

    /**
     * @tc.name resultSet isAtFirstRow test
     * @tc.number SUB_DDM_AppDataFWK_JSRDB_ResultSet_0162
     * @tc.desc resultSet isAtFirstRow test
     */
    it('testIsAtFirstRow0003', 0, async function (done) {
L
liangzhenyu123 已提交
1245
        console.info(TAG + '************* testIsAtFirstRow0003 start *************');
S
smagicyun 已提交
1246
        {
Y
yanglifeng 已提交
1247
            let predicates = await new dataRdb.RdbPredicates('test')
S
smagicyun 已提交
1248 1249 1250 1251 1252 1253 1254 1255
            let resultSet = await rdbStore.query(predicates)
            {
                expect(true).assertEqual(resultSet.goToFirstRow())
                expect(true).assertEqual(resultSet.goToNextRow())
                expect(false).assertEqual(resultSet.isAtFirstRow)
            }
            resultSet = null;
            done();
L
liangzhenyu123 已提交
1256
            console.info(TAG + '************* testIsAtFirstRow0003 end *************');
S
smagicyun 已提交
1257 1258 1259 1260 1261 1262 1263 1264 1265
        }
    })

    /**
     * @tc.name resultSet isAtFirstRow after last row test
     * @tc.number SUB_DDM_AppDataFWK_JSRDB_ResultSet_0163
     * @tc.desc resultSet isAtFirstRow after last row test
     */
    it('testIsAtFirstRow0004', 0, async function (done) {
L
liangzhenyu123 已提交
1266
        console.info(TAG + '************* testIsAtFirstRow0004 start *************');
S
smagicyun 已提交
1267
        {
Y
yanglifeng 已提交
1268
            let predicates = await new dataRdb.RdbPredicates('test')
S
smagicyun 已提交
1269 1270 1271 1272 1273 1274 1275
            let resultSet = await rdbStore.query(predicates)
            {
                expect(true).assertEqual(resultSet.goToLastRow())
                expect(false).assertEqual(resultSet.isAtFirstRow)
            }
            resultSet = null;
            done();
L
liangzhenyu123 已提交
1276
            console.info(TAG + '************* testIsAtFirstRow0004 end *************');
S
smagicyun 已提交
1277 1278 1279 1280 1281 1282 1283 1284 1285
        }
    })

    /**
     * @tc.name resultSet isAtFirstRow test
     * @tc.number SUB_DDM_AppDataFWK_JSRDB_ResultSet_0165
     * @tc.descresultSet isAtFirstRow test
     */
    it('testIsAtFirstRow0005', 0, async function (done) {
L
liangzhenyu123 已提交
1286
        console.info(TAG + '************* testIsAtFirstRow0005 start *************');
S
smagicyun 已提交
1287
        {
Y
yanglifeng 已提交
1288
            let predicates = await new dataRdb.RdbPredicates('test')
S
smagicyun 已提交
1289 1290 1291 1292 1293 1294 1295 1296
            let resultSet = await rdbStore.query(predicates)
            {
                resultSet.goTo(1)
                resultSet.goTo(0)
                expect(true).assertEqual(resultSet.isAtFirstRow)
            }
            resultSet = null;
            done();
L
liangzhenyu123 已提交
1297
            console.info(TAG + '************* testIsAtFirstRow0005 end *************');
S
smagicyun 已提交
1298 1299 1300 1301 1302 1303 1304 1305 1306
        }
    })

    /**
     * @tc.name resultSet isAtFirstRow test
     * @tc.number SUB_DDM_AppDataFWK_JSRDB_ResultSet_0166
     * @tc.descresultSet isAtFirstRow test
     */
    it('testIsAtFirstRow0006', 0, async function (done) {
L
liangzhenyu123 已提交
1307
        console.info(TAG + '************* testIsAtFirstRow0006 start *************');
S
smagicyun 已提交
1308
        {
Y
yanglifeng 已提交
1309
            let predicates = await new dataRdb.RdbPredicates('test')
S
smagicyun 已提交
1310 1311 1312 1313 1314 1315 1316 1317
            let resultSet = await rdbStore.query(predicates)
            {
                resultSet.goTo(1)
                expect(true).assertEqual(resultSet.isAtFirstRow)
                expect(true).assertEqual(resultSet.isAtFirstRow)
            }
            resultSet = null;
            done();
L
liangzhenyu123 已提交
1318
            console.info(TAG + '************* testIsAtFirstRow0006 end *************');
S
smagicyun 已提交
1319 1320 1321 1322 1323 1324 1325 1326 1327
        }
    })

    /**
     * @tc.name resultSet isAtLastRow test
     * @tc.number SUB_DDM_AppDataFWK_JSRDB_ResultSet_0170
     * @tc.desc resultSet isAtLastRow test
     */
    it('testIsAtLastRow0001', 0, async function (done) {
L
liangzhenyu123 已提交
1328
        console.info(TAG + '************* testIsAtLastRow0001 start *************');
S
smagicyun 已提交
1329
        {
Y
yanglifeng 已提交
1330
            let predicates = await new dataRdb.RdbPredicates('test')
S
smagicyun 已提交
1331 1332 1333 1334 1335 1336 1337
            let resultSet = await rdbStore.query(predicates)
            {
                expect(true).assertEqual(resultSet.goToFirstRow())
                expect(false).assertEqual(resultSet.isAtLastRow)
            }
            resultSet = null;
            done();
L
liangzhenyu123 已提交
1338
            console.info(TAG + '************* testIsAtLastRow0001 end *************');
S
smagicyun 已提交
1339 1340 1341 1342 1343 1344 1345 1346 1347
        }
    })

    /**
     * @tc.name resultSet isAtLastRow with no result test
     * @tc.number SUB_DDM_AppDataFWK_JSRDB_ResultSet_0171
     * @tc.desc resultSet isAtLastRow with no result test
     */
    it('testIsAtLastRow0002', 0, async function (done) {
L
liangzhenyu123 已提交
1348
        console.info(TAG + '************* testIsAtLastRow0002 start *************');
S
smagicyun 已提交
1349
        {
Y
yanglifeng 已提交
1350 1351
            let predicates = await new dataRdb.RdbPredicates('test')
            predicates.equalTo('name', 'wangwu');
S
smagicyun 已提交
1352 1353 1354 1355 1356 1357
            let resultSet = await rdbStore.query(predicates)
            {
                expect(false).assertEqual(resultSet.isAtLastRow)
            }
            resultSet = null;
            done();
L
liangzhenyu123 已提交
1358
            console.info(TAG + '************* testIsAtLastRow0002 end *************');
S
smagicyun 已提交
1359 1360 1361 1362 1363 1364 1365 1366 1367
        }
    })

    /**
     * @tc.name resultSet isAtLastRow test
     * @tc.number SUB_DDM_AppDataFWK_JSRDB_ResultSet_0172
     * @tc.desc resultSet isAtLastRow test
     */
    it('testIsAtLastRow0003', 0, async function (done) {
L
liangzhenyu123 已提交
1368
        console.info(TAG + '************* testIsAtLastRow0003 start *************');
S
smagicyun 已提交
1369
        {
Y
yanglifeng 已提交
1370
            let predicates = await new dataRdb.RdbPredicates('test')
S
smagicyun 已提交
1371 1372 1373 1374 1375 1376 1377 1378
            let resultSet = await rdbStore.query(predicates)
            {
                expect(true).assertEqual(resultSet.goToFirstRow())
                expect(true).assertEqual(resultSet.goToNextRow())
                expect(false).assertEqual(resultSet.isAtLastRow)
            }
            resultSet = null;
            done();
L
liangzhenyu123 已提交
1379
            console.info(TAG + '************* testIsAtLastRow0003 end *************');
S
smagicyun 已提交
1380 1381 1382 1383 1384 1385 1386 1387 1388
        }
    })

    /**
     * @tc.name resultSet isAtLastRow after last row test
     * @tc.number SUB_DDM_AppDataFWK_JSRDB_ResultSet_0173
     * @tc.desc resultSet isAtLastRow after last row test
     */
    it('testIsAtLastRow0004', 0, async function (done) {
L
liangzhenyu123 已提交
1389
        console.info(TAG + '************* testIsAtLastRow0004 start *************');
S
smagicyun 已提交
1390
        {
Y
yanglifeng 已提交
1391
            let predicates = await new dataRdb.RdbPredicates('test')
S
smagicyun 已提交
1392 1393 1394 1395 1396 1397 1398
            let resultSet = await rdbStore.query(predicates)
            {
                expect(true).assertEqual(resultSet.goToLastRow())
                expect(true).assertEqual(resultSet.isAtLastRow)
            }
            resultSet = null;
            done();
L
liangzhenyu123 已提交
1399
            console.info(TAG + '************* testIsAtLastRow0004 end *************');
S
smagicyun 已提交
1400 1401 1402 1403 1404 1405 1406 1407 1408
        }
    })

    /**
     * @tc.name resultSet isAtLastRow test
     * @tc.number SUB_DDM_AppDataFWK_JSRDB_ResultSet_0174
     * @tc.desc resultSet isAtLastRow test
     */
    it('testIsAtLastRow0005', 0, async function (done) {
L
liangzhenyu123 已提交
1409
        console.info(TAG + '************* testIsAtLastRow0005 start *************');
S
smagicyun 已提交
1410
        {
Y
yanglifeng 已提交
1411
            let predicates = await new dataRdb.RdbPredicates('test')
S
smagicyun 已提交
1412 1413 1414 1415 1416 1417 1418 1419
            let resultSet = await rdbStore.query(predicates)
            {
                resultSet.goToRow(2)
                expect(true).assertEqual(resultSet.isAtLastRow)
                expect(true).assertEqual(resultSet.isAtLastRow)
            }
            resultSet = null;
            done();
L
liangzhenyu123 已提交
1420
            console.info(TAG + '************* testIsAtLastRow0005 end *************');
S
smagicyun 已提交
1421 1422 1423 1424 1425 1426 1427 1428 1429
        }
    })

    /**
     * @tc.name resultSet getDouble test
     * @tc.number SUB_DDM_AppDataFWK_JSRDB_ResultSet_0180
     * @tc.desc resultSet getDouble test
     */
    it('testGetDouble0001', 0, async function (done) {
L
liangzhenyu123 已提交
1430
        console.info(TAG + '************* testGetDouble0001 start *************');
S
smagicyun 已提交
1431
        {
Y
yanglifeng 已提交
1432
            let predicates = await new dataRdb.RdbPredicates('test')
S
smagicyun 已提交
1433 1434 1435
            let resultSet = await rdbStore.query(predicates)
            {
                resultSet.goTo(1)
Y
yanglifeng 已提交
1436
                const data3 = resultSet.getDouble(resultSet.getColumnIndex('data3'))
S
smagicyun 已提交
1437 1438 1439 1440
                expect(1.0).assertEqual(data3)
            }
            resultSet = null;
            done();
L
liangzhenyu123 已提交
1441
            console.info(TAG + '************* testGetDouble0001 end *************');
S
smagicyun 已提交
1442 1443 1444 1445 1446 1447 1448 1449 1450
        }
    })

    /**
     * @tc.name resultSet getDouble test
     * @tc.number SUB_DDM_AppDataFWK_JSRDB_ResultSet_0181
     * @tc.desc resultSet getDouble test
     */
    it('testGetDouble0002', 0, async function (done) {
L
liangzhenyu123 已提交
1451
        console.info(TAG + '************* testGetDouble0002 start *************');
S
smagicyun 已提交
1452
        {
Y
yanglifeng 已提交
1453
            let predicates = await new dataRdb.RdbPredicates('test')
S
smagicyun 已提交
1454 1455 1456
            let resultSet = await rdbStore.query(predicates)
            {
                resultSet.goTo(2)
Y
yanglifeng 已提交
1457
                const data3 = resultSet.getDouble(resultSet.getColumnIndex('data3'))
S
smagicyun 已提交
1458 1459 1460 1461
                expect(2.5).assertEqual(data3)
            }
            resultSet = null;
            done();
L
liangzhenyu123 已提交
1462
            console.info(TAG + '************* testGetDouble0002 end *************');
S
smagicyun 已提交
1463 1464 1465 1466 1467 1468 1469 1470 1471
        }
    })

    /**
     * @tc.name resultSet getDouble test
     * @tc.number SUB_DDM_AppDataFWK_JSRDB_ResultSet_0182
     * @tc.desc resultSet getDouble test
     */
    it('testGetDouble0003', 0, async function (done) {
L
liangzhenyu123 已提交
1472
        console.info(TAG + '************* testGetDouble0003 start *************');
S
smagicyun 已提交
1473
        {
Y
yanglifeng 已提交
1474
            let predicates = await new dataRdb.RdbPredicates('test')
S
smagicyun 已提交
1475 1476 1477
            let resultSet = await rdbStore.query(predicates)
            {
                resultSet.goTo(3)
Y
yanglifeng 已提交
1478
                const data3 = resultSet.getDouble(resultSet.getColumnIndex('data3'))
S
smagicyun 已提交
1479 1480 1481 1482
                expect(1.8).assertEqual(data3)
            }
            resultSet = null;
            done();
L
liangzhenyu123 已提交
1483
            console.info(TAG + '************* testGetDouble0003 end *************');
S
smagicyun 已提交
1484 1485 1486 1487 1488 1489 1490 1491 1492
        }
    })

    /**
     * @tc.name resultSet getDouble test
     * @tc.number SUB_DDM_AppDataFWK_JSRDB_ResultSet_0183
     * @tc.desc resultSet getDouble test
     */
    it('testGetDouble0004', 0, async function (done) {
L
liangzhenyu123 已提交
1493
        console.info(TAG + '************* testGetDouble0004 start *************');
S
smagicyun 已提交
1494
        {
Y
yanglifeng 已提交
1495
            let predicates = await new dataRdb.RdbPredicates('test')
S
smagicyun 已提交
1496 1497 1498
            let resultSet = await rdbStore.query(predicates)
            {
                resultSet.goTo(1)
Y
yanglifeng 已提交
1499
                const data2 = resultSet.getDouble(resultSet.getColumnIndex('data2'))
S
smagicyun 已提交
1500 1501 1502 1503
                expect(10).assertEqual(data2)
            }
            resultSet = null;
            done();
L
liangzhenyu123 已提交
1504
            console.info(TAG + '************* testGetDouble0004 end *************');
S
smagicyun 已提交
1505 1506 1507 1508 1509 1510 1511 1512 1513
        }
    })

    /**
     * @tc.name resultSet isColumnNull test
     * @tc.number SUB_DDM_AppDataFWK_JSRDB_ResultSet_0190
     * @tc.desc resultSet isColumnNull test
     */
    it('testIsColumnNull0001', 0, async function (done) {
L
liangzhenyu123 已提交
1514
        console.info(TAG + '************* testIsColumnNull0001 start *************');
S
smagicyun 已提交
1515
        {
Y
yanglifeng 已提交
1516
            let predicates = await new dataRdb.RdbPredicates('test')
S
smagicyun 已提交
1517 1518 1519 1520 1521
            let resultSet = await rdbStore.query(predicates)
            {
                expect(true).assertEqual(resultSet.goToFirstRow())
                expect(true).assertEqual(resultSet.goToNextRow())
                expect(true).assertEqual(resultSet.goToNextRow())
Y
yanglifeng 已提交
1522
                const isColumnNull1 = resultSet.isColumnNull(resultSet.getColumnIndex('data1'))
S
smagicyun 已提交
1523 1524 1525 1526
                expect(false).assertEqual(isColumnNull1)
            }
            resultSet = null;
            done();
L
liangzhenyu123 已提交
1527
            console.info(TAG + '************* testIsColumnNull0001 end *************');
S
smagicyun 已提交
1528 1529 1530 1531 1532 1533 1534 1535 1536
        }
    })

    /**
     * @tc.name resultSet isColumnNull test
     * @tc.number SUB_DDM_AppDataFWK_JSRDB_ResultSet_0191
     * @tc.desc resultSet isColumnNull test
     */
    it('testIsColumnNull0002', 0, async function (done) {
L
liangzhenyu123 已提交
1537
        console.info(TAG + '************* testIsColumnNull0002 start *************');
S
smagicyun 已提交
1538
        {
Y
yanglifeng 已提交
1539
            let predicates = await new dataRdb.RdbPredicates('test')
S
smagicyun 已提交
1540 1541 1542 1543 1544
            let resultSet = await rdbStore.query(predicates)
            {
                expect(true).assertEqual(resultSet.goToFirstRow())
                expect(true).assertEqual(resultSet.goToNextRow())
                expect(true).assertEqual(resultSet.goToNextRow())
Y
yanglifeng 已提交
1545
                const isColumnNull4 = resultSet.isColumnNull(resultSet.getColumnIndex('data4'))
S
smagicyun 已提交
1546 1547 1548 1549
                expect(true).assertEqual(isColumnNull4)
            }
            resultSet = null;
            done();
L
liangzhenyu123 已提交
1550
            console.info(TAG + '************* testIsColumnNull0002 end *************');
S
smagicyun 已提交
1551 1552 1553 1554 1555 1556 1557 1558 1559
        }
    })

    /**
     * @tc.name resultSet isColumnNull test
     * @tc.number SUB_DDM_AppDataFWK_JSRDB_ResultSet_0192
     * @tc.desc resultSet isColumnNull test
     */
    it('testIsColumnNull0003', 0, async function (done) {
L
liangzhenyu123 已提交
1560
        console.info(TAG + '************* testIsColumnNull0003 start *************');
S
smagicyun 已提交
1561
        {
Y
yanglifeng 已提交
1562
            let predicates = await new dataRdb.RdbPredicates('test')
S
smagicyun 已提交
1563 1564 1565
            let resultSet = await rdbStore.query(predicates)
            {
                resultSet.goToRow(5)
M
Maowen 已提交
1566
                expect(false).assertEqual(resultSet.isColumnNull(2))
S
smagicyun 已提交
1567 1568 1569
            }
            resultSet = null;
            done();
L
liangzhenyu123 已提交
1570
            console.info(TAG + '************* testIsColumnNull0003 end *************');
S
smagicyun 已提交
1571 1572 1573 1574 1575 1576 1577 1578
        }
    })
    /**
     * @tc.name resultSet isColumnNull test
     * @tc.number SUB_DDM_AppDataFWK_JSRDB_ResultSet_0193
     * @tc.desc resultSet isColumnNull test
     */
    it('testIsColumnNull0004', 0, async function (done) {
L
liangzhenyu123 已提交
1579
        console.info(TAG + '************* testIsColumnNull0004 start *************');
S
smagicyun 已提交
1580
        {
Y
yanglifeng 已提交
1581
            let predicates = await new dataRdb.RdbPredicates('test')
S
smagicyun 已提交
1582 1583 1584 1585 1586 1587 1588
            let resultSet = await rdbStore.query(predicates)
            {
                resultSet.goToRow(2)
                expect(false).assertEqual(resultSet.isColumnNull(1))
            }
            resultSet = null;
            done();
L
liangzhenyu123 已提交
1589
            console.info(TAG + '************* testIsColumnNull0004 end *************');
S
smagicyun 已提交
1590 1591 1592 1593 1594 1595 1596 1597 1598
        }
    })

    /**
     * @tc.name resultSet getColumnIndex test
     * @tc.number SUB_DDM_AppDataFWK_JSRDB_ResultSet_0200
     * @tc.desc resultSet getColumnIndex test
     */
    it('testGetColumnIndex0001', 0, async function (done) {
L
liangzhenyu123 已提交
1599
        console.info(TAG + '************* testGetColumnIndex0001 start *************');
S
smagicyun 已提交
1600
        {
Y
yanglifeng 已提交
1601
            let predicates = await new dataRdb.RdbPredicates('test')
S
smagicyun 已提交
1602 1603
            let resultSet = await rdbStore.query(predicates)
            expect(true).assertEqual(resultSet.goToFirstRow())
Y
yanglifeng 已提交
1604
            expect(1).assertEqual(resultSet.getColumnIndex('data1'))
S
smagicyun 已提交
1605 1606 1607

            resultSet = null;
            done();
L
liangzhenyu123 已提交
1608
            console.info(TAG + '************* testGetColumnIndex0001 end *************');
S
smagicyun 已提交
1609 1610 1611 1612 1613 1614 1615 1616 1617
        }
    })

    /**
     * @tc.name resultSet getColumnIndex test
     * @tc.number SUB_DDM_AppDataFWK_JSRDB_ResultSet_0201
     * @tc.desc resultSet getColumnIndex test
     */
    it('testGetColumnIndex0002', 0, async function (done) {
L
liangzhenyu123 已提交
1618
        console.info(TAG + '************* testGetColumnIndex0002 start *************');
S
smagicyun 已提交
1619
        {
Y
yanglifeng 已提交
1620 1621
            let predicates = await new dataRdb.RdbPredicates('test')
            predicates.equalTo('name', 'wangwu');
S
smagicyun 已提交
1622
            let resultSet = await rdbStore.query(predicates)
Y
yanglifeng 已提交
1623
            expect(-1).assertEqual(resultSet.getColumnIndex('data1'))
S
smagicyun 已提交
1624 1625 1626

            resultSet = null;
            done();
L
liangzhenyu123 已提交
1627
            console.info(TAG + '************* testGetColumnIndex0002 end *************');
S
smagicyun 已提交
1628 1629 1630 1631 1632 1633 1634 1635 1636
        }
    })

    /**
     * @tc.name resultSet getColumnIndex test
     * @tc.number SUB_DDM_AppDataFWK_JSRDB_ResultSet_0202
     * @tc.desc resultSet getColumnIndex test
     */
    it('testGetColumnIndex0003', 0, async function (done) {
L
liangzhenyu123 已提交
1637
        console.info(TAG + '************* testGetColumnIndex0003 start *************');
S
smagicyun 已提交
1638
        {
Y
yanglifeng 已提交
1639
            let predicates = await new dataRdb.RdbPredicates('test')
S
smagicyun 已提交
1640
            let resultSet = await rdbStore.query(predicates)
Y
yanglifeng 已提交
1641
            expect(-1).assertEqual(resultSet.getColumnIndex('dataX'))
S
smagicyun 已提交
1642 1643 1644

            resultSet = null;
            done();
L
liangzhenyu123 已提交
1645
            console.info(TAG + '************* testGetColumnIndex0003 end *************');
S
smagicyun 已提交
1646 1647 1648 1649 1650 1651 1652 1653 1654
        }
    })

    /**
     * @tc.name resultSet getColumnIndex test
     * @tc.number SUB_DDM_AppDataFWK_JSRDB_ResultSet_0203
     * @tc.desc resultSet getColumnIndex test
     */
    it('testGetColumnIndex0004', 0, async function (done) {
L
liangzhenyu123 已提交
1655
        console.info(TAG + '************* testGetColumnIndex0004 start *************');
S
smagicyun 已提交
1656
        {
Y
yanglifeng 已提交
1657
            let predicates = await new dataRdb.RdbPredicates('test')
S
smagicyun 已提交
1658
            let resultSet = await rdbStore.query(predicates)
Y
yanglifeng 已提交
1659
            expect(-1).assertEqual(resultSet.getColumnIndex(''))
S
smagicyun 已提交
1660 1661 1662

            resultSet = null;
            done();
L
liangzhenyu123 已提交
1663
            console.info(TAG + '************* testGetColumnIndex0004 end *************');
S
smagicyun 已提交
1664 1665 1666 1667 1668 1669 1670 1671 1672
        }
    })

    /**
     * @tc.name resultSet getColumnName test
     * @tc.number SUB_DDM_AppDataFWK_JSRDB_ResultSet_0210
     * @tc.desc resultSet getColumnName test
     */
    it('testGetColumnName0001', 0, async function (done) {
L
liangzhenyu123 已提交
1673
        console.info(TAG + '************* testGetColumnIndex0001 start *************');
S
smagicyun 已提交
1674
        {
Y
yanglifeng 已提交
1675
            let predicates = await new dataRdb.RdbPredicates('test')
S
smagicyun 已提交
1676 1677
            let resultSet = await rdbStore.query(predicates)

Y
yanglifeng 已提交
1678 1679
            expect('data1').assertEqual(resultSet.getColumnName(1))
            expect('data4').assertEqual(resultSet.getColumnName(4))
S
smagicyun 已提交
1680 1681 1682

            resultSet = null;
            done();
L
liangzhenyu123 已提交
1683
            console.info(TAG + '************* testGetColumnName0001 end *************');
S
smagicyun 已提交
1684 1685 1686 1687 1688 1689 1690 1691 1692
        }
    })

    /**
     * @tc.name resultSet getColumnName test
     * @tc.number SUB_DDM_AppDataFWK_JSRDB_ResultSet_0211
     * @tc.desc resultSet getColumnName test
     */
    it('testGetColumnName0002', 0, async function (done) {
L
liangzhenyu123 已提交
1693
        console.info(TAG + '************* testGetColumnName0002 start *************');
S
smagicyun 已提交
1694
        {
Y
yanglifeng 已提交
1695 1696
            let predicates = await new dataRdb.RdbPredicates('test')
            predicates.equalTo('name', 'wangwu');
S
smagicyun 已提交
1697 1698
            let resultSet = await rdbStore.query(predicates)

Y
yanglifeng 已提交
1699 1700
            expect('').assertEqual(resultSet.getColumnName(1))
            expect('').assertEqual(resultSet.getColumnName(4))
S
smagicyun 已提交
1701 1702 1703

            resultSet = null;
            done();
L
liangzhenyu123 已提交
1704
            console.info(TAG + '************* testGetColumnName0002 end *************');
S
smagicyun 已提交
1705 1706 1707 1708 1709 1710 1711 1712 1713
        }
    })

    /**
     * @tc.name resultSet getColumnName test
     * @tc.number SUB_DDM_AppDataFWK_JSRDB_ResultSet_0212
     * @tc.desc resultSet getColumnName test
     */
    it('testGetColumnName0003', 0, async function (done) {
L
liangzhenyu123 已提交
1714
        console.info(TAG + '************* testGetColumnName0003 start *************');
S
smagicyun 已提交
1715
        {
Y
yanglifeng 已提交
1716
            let predicates = await new dataRdb.RdbPredicates('test')
S
smagicyun 已提交
1717 1718
            let resultSet = await rdbStore.query(predicates)

Y
yanglifeng 已提交
1719
            expect('').assertEqual(resultSet.getColumnName(10))
S
smagicyun 已提交
1720 1721 1722

            resultSet = null;
            done();
L
liangzhenyu123 已提交
1723
            console.info(TAG + '************* testGetColumnName0003 end *************');
S
smagicyun 已提交
1724 1725 1726 1727 1728 1729 1730 1731 1732
        }
    })

    /**
     * @tc.name resultSet getColumnName test
     * @tc.number SUB_DDM_AppDataFWK_JSRDB_ResultSet_0213
     * @tc.desc resultSet getColumnName test
     */
    it('testGetColumnName0004', 0, async function (done) {
L
liangzhenyu123 已提交
1733
        console.info(TAG + '************* testGetColumnName0004 start *************');
S
smagicyun 已提交
1734
        {
Y
yanglifeng 已提交
1735 1736
            let predicates = await new dataRdb.RdbPredicates('test')
            predicates.equalTo('name', 'wangwu');
S
smagicyun 已提交
1737 1738
            let resultSet = await rdbStore.query(predicates)

Y
yanglifeng 已提交
1739
            expect('').assertEqual(resultSet.getColumnName(10))
S
smagicyun 已提交
1740 1741 1742

            resultSet = null;
            done();
L
liangzhenyu123 已提交
1743
            console.info(TAG + '************* testGetColumnName0004 end *************');
S
smagicyun 已提交
1744 1745 1746 1747 1748 1749 1750 1751 1752
        }
    })

    /**
     * @tc.name resultSet close test
     * @tc.number SUB_DDM_AppDataFWK_JSRDB_ResultSet_0220
     * @tc.desc resultSet close test
     */
    it('testClose0001', 0, async function (done) {
L
liangzhenyu123 已提交
1753
        console.info(TAG + '************* testClose0001 start *************');
S
smagicyun 已提交
1754
        {
Y
yanglifeng 已提交
1755
            let predicates = await new dataRdb.RdbPredicates('test')
S
smagicyun 已提交
1756 1757 1758 1759 1760 1761 1762
            let resultSet = await rdbStore.query(predicates)
            resultSet.goToRow(1)
            resultSet.close()
            expect(true).assertEqual(resultSet.isClosed)

            resultSet = null;
            done();
L
liangzhenyu123 已提交
1763
            console.info(TAG + '************* testClose0001 end *************');
S
smagicyun 已提交
1764 1765 1766 1767 1768 1769 1770 1771 1772
        }
    })

    /**
     * @tc.name resultSet close test
     * @tc.number SUB_DDM_AppDataFWK_JSRDB_ResultSet_0221
     * @tc.desc resultSet close test
     */
    it('testClose0002', 0, async function (done) {
L
liangzhenyu123 已提交
1773
        console.info(TAG + '************* testClose0002 start *************');
S
smagicyun 已提交
1774
        {
Y
yanglifeng 已提交
1775 1776
            let predicates = await new dataRdb.RdbPredicates('test')
            predicates.equalTo('name', 'wangwu');
S
smagicyun 已提交
1777 1778 1779 1780 1781 1782
            let resultSet = await rdbStore.query(predicates)
            resultSet.close()
            expect(true).assertEqual(resultSet.isClosed)

            resultSet = null;
            done();
L
liangzhenyu123 已提交
1783
            console.info(TAG + '************* testClose0002 end *************');
S
smagicyun 已提交
1784 1785 1786
        }
    })

1
18834416147 已提交
1787 1788 1789 1790 1791 1792
    /**
     * @tc.name resultSet columnNames test
     * @tc.number SUB_DDM_AppDataFWK_JSRDB_ResultSet_0240
     * @tc.desc resultSet columnNames test
     */
     it('testcolumnNames0001', 0, async function (done) {
L
liangzhenyu123 已提交
1793
        console.info(TAG + '************* testcolumnNames0001 start *************');
1
18834416147 已提交
1794 1795 1796 1797 1798 1799 1800 1801 1802 1803
        {
            let predicates = await new dataRdb.RdbPredicates('test')
            let resultSet = await rdbStore.query(predicates)
            if (COLOUNM_NAMES == resultSet.columnNames){
                expect(1).assertEqual(0);
            }else{
                expect(0).assertEqual(0);
            }
            resultSet = null;
            done();
L
liangzhenyu123 已提交
1804
            console.info(TAG + '************* testcolumnNames0001 end *************');
1
18834416147 已提交
1805 1806
        }
    })
L
liangzhenyu123 已提交
1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834

    /**
     * @tc.name big resultSet data test
     * @tc.number SUB_DDM_AppDataFWK_JSRDB_ResultSet_0250
     * @tc.desc big resultSet data test
     */
     it('testBigData0001', 0, async function (done) {
        console.log(TAG + "************* testBigData0001 start *************");
        {
            await createBigData(500);
            let resultSet = await rdbStore.querySql("SELECT * FROM test");
            let count = resultSet.rowCount;
            expect(500).assertEqual(count);

            resultSet.goToFirstRow();
            let i = 0;
            while (resultSet.isEnded == false) {
                expect("test" + i++).assertEqual(resultSet.getString(1))
                resultSet.goToNextRow();
            }

            resultSet.close()
            expect(true).assertEqual(resultSet.isClosed)
            resultSet = null;
            done();
            console.log(TAG + "************* testBigData0001 end *************");
        }
    })
1
18834416147 已提交
1835
    
L
liangzhenyu123 已提交
1836
    console.info(TAG + '*************Unit Test End*************');
1
18834416147 已提交
1837
})
J
jiyong_sd 已提交
1838
}