1/*
2 * Copyright (c) 2022 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 */
15
16import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
17import factory from '@ohos.data.distributedKVStore';
18
19describe('SingleKvStoreEnumTest', function () {
20
21    /**
22     * @tc.name SingleKvStoreEnumConstantsMaxKeyLengthSucTest
23     * @tc.desc  Test Js Enum Value Constants.MAX_KEY_LENGTH successfully
24     * @tc.type: FUNC
25     * @tc.require: issueNumber
26     */
27    it('SingleKvStoreEnumConstantsMaxKeyLengthSucSucTest', 0, function () {
28        try {
29            var maxKeyLength = factory.Constants.MAX_KEY_LENGTH;
30            console.info('maxKeyLength = ' + maxKeyLength);
31            expect(maxKeyLength == 1024).assertTrue()
32        } catch (e) {
33            expect(null).assertFailed();
34        }
35    })
36
37    /**
38     * @tc.name SingleKvStoreEnumConstantsMaxValueLengthSucTest
39     * @tc.desc  Test Js Enum Value Constants.MAX_VALUE_LENGTH successfully
40     * @tc.type: FUNC
41     * @tc.require: issueNumber
42     */
43    it('SingleKvStoreEnumConstantsMaxValueLengthSucSucTest', 0, function () {
44        try {
45            var maxValueLength = factory.Constants.MAX_VALUE_LENGTH;
46            console.info('maxValueLength = ' + maxValueLength);
47            expect(maxValueLength == 4194303).assertTrue();
48            expect(factory.Constants.MAX_VALUE_LENGTH).assertEqual(4194303);
49        } catch (e) {
50            expect(null).assertFailed();
51        }
52    })
53
54    /**
55     * @tc.name SingleKvStoreEnumConstantsMaxValueLengthSucTest
56     * @tc.desc  Test Js Enum Value Constants.MAX_VALUE_LENGTH successfully
57     * @tc.type: FUNC
58     * @tc.require: issueNumber
59     */
60    it('SingleKvStoreEnumConstantsMaxValueLengthSucTest', 0, function () {
61        try {
62            factory.Constants.MAX_VALUE_LENGTH = 123;
63        } catch (e) {
64            console.info('can NOT set value to MAX_VALUE_LENGTH : ' + e);
65            expect(factory.Constants.MAX_VALUE_LENGTH).assertEqual(4194303);
66        }
67    })
68
69    /**
70     * @tc.name SingleKvStoreEnumConstantsMaxKeyLengthDeviceSucTest
71     * @tc.desc  Test Js Enum Value Constants.MAX_KEY_LENGTH_DEVICE successfully
72     * @tc.type: FUNC
73     * @tc.require: issueNumber
74     */
75    it('SingleKvStoreEnumConstantsMaxKeyLengthDeviceSucTest', 0, function () {
76
77        try {
78            var maxKeyLengthDevice = factory.Constants.MAX_KEY_LENGTH_DEVICE;
79            console.info('maxKeyLengthDevice = ' + maxKeyLengthDevice);
80            expect(maxKeyLengthDevice == 896).assertTrue()
81        } catch (e) {
82            expect(null).assertFailed();
83        }
84    })
85
86    /**
87     * @tc.name SingleKvStoreEnumConstantsMaxStoreIdLengthSucTest
88     * @tc.desc  Test Js Enum Value Constants.MAX_STORE_ID_LENGTH successfully
89     * @tc.type: FUNC
90     * @tc.require: issueNumber
91     */
92    it('SingleKvStoreEnumConstantsMaxStoreIdLengthSucTest', 0, function () {
93
94        try {
95            var maxStoreIdLength = factory.Constants.MAX_STORE_ID_LENGTH;
96            console.info('maxStoreIdLength = ' + maxStoreIdLength);
97            expect(maxStoreIdLength == 128).assertTrue()
98        } catch (e) {
99            expect(null).assertFailed();
100        }
101    })
102
103    /**
104     * @tc.name SingleKvStoreEnumConstantsMaxQueryLengthSucTest
105     * @tc.desc  Test Js Enum Value Constants.MAX_QUERY_LENGTH successfully
106     * @tc.type: FUNC
107     * @tc.require: issueNumber
108     */
109    it('SingleKvStoreEnumConstantsMaxQueryLengthSucTest', 0, function () {
110
111        try {
112            var maxQueryLength = factory.Constants.MAX_QUERY_LENGTH;
113            console.info('maxQueryLength = ' + maxQueryLength);
114            expect(maxQueryLength == 512000).assertTrue()
115        } catch (e) {
116            expect(null).assertFailed();
117        }
118    })
119
120    /**
121     * @tc.name SingleKvStoreEnumConstantsMaxBatchSizeSucTest
122     * @tc.desc  Test Js Enum Value Constants.MAX_BATCH_SIZE successfully
123     * @tc.type: FUNC
124     * @tc.require: issueNumber
125     */
126    it('SingleKvStoreEnumConstantsMaxBatchSizeSucTest', 0, function () {
127
128        try {
129            var maxBatchSize = factory.Constants.MAX_BATCH_SIZE;
130            console.info('maxBatchSize = ' + maxBatchSize);
131            expect(maxBatchSize == 128).assertTrue()
132        } catch (e) {
133            expect(null).assertFailed();
134        }
135    })
136
137    /**
138     * @tc.name SingleKvStoreEnumSecuritylevelS1SucTest
139     * @tc.desc  Test Js Enum Value Securitylevel.S1 successfully
140     * @tc.type: FUNC
141     * @tc.require: issueNumber
142     */
143    it('SingleKvStoreEnumSecuritylevelS1SucTest', 0, function () {
144        try {
145            var s1 = factory.SecurityLevel.S1;
146            console.info('s1 = ' + s1);
147            expect(s1 == 2).assertTrue();
148        } catch (e) {
149            expect(null).assertFailed();
150        }
151    })
152
153    /**
154     * @tc.name SingleKvStoreEnumSecuritylevelS2SucTest
155     * @tc.desc  Test Js Enum Value Securitylevel.S2 successfully
156     * @tc.type: FUNC
157     * @tc.require: issueNumber
158     */
159    it('SingleKvStoreEnumSecuritylevelS2SucTest', 0, function () {
160        try {
161            var s2 = factory.SecurityLevel.S2;
162            console.info('s2 = ' + s2);
163            expect(s2 == 3).assertTrue()
164        } catch (e) {
165            expect(null).assertFailed();
166        }
167    })
168
169    /**
170     * @tc.name SingleKvStoreEnumSecuritylevelS3SucTest
171     * @tc.desc  Test Js Enum Value Securitylevel.S3 successfully
172     * @tc.type: FUNC
173     * @tc.require: issueNumber
174     */
175    it('SingleKvStoreEnumSecuritylevelS3SucTest', 0, function () {
176        try {
177            var s3 = factory.SecurityLevel.S3;
178            console.info('s3 = ' + s3);
179            expect(s3 == 5).assertTrue()
180        } catch (e) {
181            expect(null).assertFailed();
182        }
183    })
184
185    /**
186     * @tc.name SingleKvStoreEnumSecuritylevelS4SucTest
187     * @tc.desc  Test Js Enum Value Securitylevel.S4 successfully
188     * @tc.type: FUNC
189     * @tc.require: issueNumber
190     */
191    it('SingleKvStoreEnumSecuritylevelS4SucTest', 0, function () {
192        try {
193            var s4 = factory.SecurityLevel.S4;
194            console.info('s4 = ' + s4);
195            expect(s4 == 6).assertTrue()
196        } catch (e) {
197            expect(null).assertFailed();
198        }
199    })
200})
201