14514f5e3Sopenharmony_ci/* 24514f5e3Sopenharmony_ci * Copyright (c) 2023 Huawei Device Co., Ltd. 34514f5e3Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 44514f5e3Sopenharmony_ci * you may not use this file except in compliance with the License. 54514f5e3Sopenharmony_ci * You may obtain a copy of the License at 64514f5e3Sopenharmony_ci * 74514f5e3Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 84514f5e3Sopenharmony_ci * 94514f5e3Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 104514f5e3Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 114514f5e3Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 124514f5e3Sopenharmony_ci * See the License for the specific language governing permissions and 134514f5e3Sopenharmony_ci * limitations under the License. 144514f5e3Sopenharmony_ci */ 154514f5e3Sopenharmony_ci 164514f5e3Sopenharmony_ci/* 174514f5e3Sopenharmony_ci * @tc.name:dataview 184514f5e3Sopenharmony_ci * @tc.desc:test dataview 194514f5e3Sopenharmony_ci * @tc.type: FUNC 204514f5e3Sopenharmony_ci * @tc.require: issue#I7NUZM 214514f5e3Sopenharmony_ci */ 224514f5e3Sopenharmony_ciconst buffer = new ArrayBuffer(16); 234514f5e3Sopenharmony_ciconst view = new DataView(buffer); 244514f5e3Sopenharmony_ciview.setInt32({}, 0x1337, {}); 254514f5e3Sopenharmony_ciprint(view.getInt32({}, {})); 264514f5e3Sopenharmony_ci 274514f5e3Sopenharmony_citry { 284514f5e3Sopenharmony_ci var buffer1 = new ArrayBuffer(64); 294514f5e3Sopenharmony_ci var dataview = new DataView(buffer1, 8, 24); 304514f5e3Sopenharmony_ci dataview.setInt32(0, 1n); 314514f5e3Sopenharmony_ci} catch(e) { 324514f5e3Sopenharmony_ci print(e) 334514f5e3Sopenharmony_ci} 344514f5e3Sopenharmony_ci 354514f5e3Sopenharmony_ciconst buf = new ArrayBuffer(16); 364514f5e3Sopenharmony_ciconst first = new DataView(buf, 0, 8); 374514f5e3Sopenharmony_ciconst second = new DataView(buf, 8); 384514f5e3Sopenharmony_ci// test setInt32 394514f5e3Sopenharmony_cisecond.setInt32(0, NaN); 404514f5e3Sopenharmony_ciprint(second.getInt32(0)); 414514f5e3Sopenharmony_cisecond.setInt32(0, 13.54); 424514f5e3Sopenharmony_ciprint(second.getInt32(0)); 434514f5e3Sopenharmony_cisecond.setInt32(0, -413.54); 444514f5e3Sopenharmony_ciprint(second.getInt32(0)); 454514f5e3Sopenharmony_cisecond.setInt32(1, 2147483648); 464514f5e3Sopenharmony_ciprint(second.getInt32(1)); 474514f5e3Sopenharmony_cisecond.setInt32(1, 13.54); 484514f5e3Sopenharmony_ciprint(second.getInt32(0)); 494514f5e3Sopenharmony_cisecond.setInt32(0, Infinity); 504514f5e3Sopenharmony_ciprint(second.getInt32(0)); 514514f5e3Sopenharmony_cisecond.setInt32(0, 27, true); 524514f5e3Sopenharmony_ciprint(second.getInt32(0)); 534514f5e3Sopenharmony_ci 544514f5e3Sopenharmony_ci// test setFloat32 554514f5e3Sopenharmony_cisecond.setFloat32(0, NaN); 564514f5e3Sopenharmony_ciprint(second.getInt32(0)); 574514f5e3Sopenharmony_cisecond.setFloat32(0, 13.54); 584514f5e3Sopenharmony_ciprint(second.getInt32(0)); 594514f5e3Sopenharmony_cisecond.setFloat32(0, -413.54); 604514f5e3Sopenharmony_ciprint(second.getInt32(0)); 614514f5e3Sopenharmony_cisecond.setFloat32(1, 2147483648); 624514f5e3Sopenharmony_ciprint(second.getInt32(1)); 634514f5e3Sopenharmony_cisecond.setFloat32(1, 13.54); 644514f5e3Sopenharmony_ciprint(second.getInt32(0)); 654514f5e3Sopenharmony_cisecond.setFloat32(0, Infinity); 664514f5e3Sopenharmony_ciprint(second.getInt32(0)); 674514f5e3Sopenharmony_cisecond.setFloat32(0, 27, true); 684514f5e3Sopenharmony_ciprint(second.getInt32(0)); 694514f5e3Sopenharmony_ci 704514f5e3Sopenharmony_ci// test setFloat64 714514f5e3Sopenharmony_cisecond.setFloat64(0, NaN); 724514f5e3Sopenharmony_ciprint(second.getInt32(0)); 734514f5e3Sopenharmony_cisecond.setFloat64(0, 13.54); 744514f5e3Sopenharmony_ciprint(second.getInt32(0)); 754514f5e3Sopenharmony_cisecond.setFloat64(0, -413.54); 764514f5e3Sopenharmony_ciprint(second.getInt32(0)); 774514f5e3Sopenharmony_cisecond.setFloat64(0, 2147483648); 784514f5e3Sopenharmony_ciprint(second.getInt32(1)); 794514f5e3Sopenharmony_cisecond.setFloat64(0, 13.54); 804514f5e3Sopenharmony_ciprint(second.getInt32(0)); 814514f5e3Sopenharmony_cisecond.setFloat64(0, Infinity); 824514f5e3Sopenharmony_ciprint(second.getInt32(0)); 834514f5e3Sopenharmony_cisecond.setFloat64(0, 27, true); 844514f5e3Sopenharmony_ciprint(second.getInt32(0));