Movatterモバイル変換


[0]ホーム

URL:


Google Git
Sign in
chromium /chromium /src /refs/heads/main /. /gin /array_buffer_unittest.cc
blob: 188cd2f86596edb8bba6f9482e9e39c9d988a9f0 [file] [log] [blame]
Avi Drissman468e51b62022-09-13 20:47:01[diff] [blame]1// Copyright 2017 The Chromium Authors
Eric Holkb2fa95d2017-07-17 18:51:36[diff] [blame]2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#include"gin/array_buffer.h"
Lei Zhang8815c182022-11-03 14:40:27[diff] [blame]6
7#include"base/check_op.h"
Eric Holkb2fa95d2017-07-17 18:51:36[diff] [blame]8#include"build/build_config.h"
9#include"gin/per_isolate_data.h"
10#include"gin/public/isolate_holder.h"
11#include"gin/test/v8_test.h"
12
Eric Holkb2fa95d2017-07-17 18:51:36[diff] [blame]13namespace gin{
14
15usingArrayBufferTest= V8Test;
16
17namespace{
18constsize_t kBufferLength=65536;
19}
20
Bill Budge2ca35142018-02-21 23:22:22[diff] [blame]21// Make sure we can allocate, access and free memory.
Eric Holkb2fa95d2017-07-17 18:51:36[diff] [blame]22TEST_F(ArrayBufferTest,AllocateAndFreeBuffer){
23 v8::Isolate*const isolate= instance_->isolate();
24 v8::ArrayBuffer::Allocator*const allocator=
25PerIsolateData::From(isolate)->allocator();
26
27void* buffer= allocator->Allocate(kBufferLength);
Bill Budge2ca35142018-02-21 23:22:22[diff] [blame]28char* buffer0=reinterpret_cast<char*>(buffer);
29*buffer0='0';// ASCII zero
30 CHECK_EQ('0',*buffer0);
Eric Holkb2fa95d2017-07-17 18:51:36[diff] [blame]31 allocator->Free(buffer, kBufferLength);
32}
33
Eric Holkb2fa95d2017-07-17 18:51:36[diff] [blame]34}// namespace gin

[8]ページ先頭

©2009-2025 Movatter.jp