Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 4 additions & 18 deletions 22 test/cctest/node_test_fixture.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,6 @@
#include "v8.h"
#include "libplatform/libplatform.h"

class ArrayBufferAllocator : public v8::ArrayBuffer::Allocator {
public:
virtual void* Allocate(size_t length) {
return AllocateUninitialized(length);
}

virtual void* AllocateUninitialized(size_t length) {
return calloc(length, 1);
}

virtual void Free(void* data, size_t) {
free(data);
}
};

struct Argv {
public:
Argv() : Argv({"node", "-p", "process.version"}) {}
Expand Down Expand Up @@ -76,8 +61,6 @@ class NodeTestFixture : public ::testing::Test {
node::MultiIsolatePlatform* Platform() const { return platform_; }

protected:
v8::Isolate::CreateParams params_;
ArrayBufferAllocator allocator_;
v8::Isolate* isolate_;

~NodeTestFixture() {
Expand All @@ -89,7 +72,8 @@ class NodeTestFixture : public ::testing::Test {
platform_ = new node::NodePlatform(8, nullptr);
v8::V8::InitializePlatform(platform_);
v8::V8::Initialize();
params_.array_buffer_allocator = &allocator_;
v8::Isolate::CreateParams params_;
params_.array_buffer_allocator = allocator_.get();
isolate_ = v8::Isolate::New(params_);
}

Expand All @@ -107,6 +91,8 @@ class NodeTestFixture : public ::testing::Test {

private:
node::NodePlatform* platform_ = nullptr;
std::unique_ptr<v8::ArrayBuffer::Allocator> allocator_{
v8::ArrayBuffer::Allocator::NewDefaultAllocator()};
};

#endif // TEST_CCTEST_NODE_TEST_FIXTURE_H_
Morty Proxy This is a proxified and sanitized view of the page, visit original site.