Skip to content
Closed
Changes from 1 commit
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
Prev Previous commit
Next Next commit
squash: add test for overload operators
  • Loading branch information
danbev committed Mar 9, 2018
commit 651bfb207a5c82615c8fd773f368f9cc7dc6484b
14 changes: 14 additions & 0 deletions test/cctest/test_aliased_buffer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -207,3 +207,17 @@ TEST_F(AliasBufferTest, SharedArrayBuffer4) {
int8_t, v8::Int8Array,
int32_t, v8::Int32Array>(isolate_, 1, 3, 1);
}

TEST_F(AliasBufferTest, OperatorOverloads) {
v8::Isolate::Scope isolate_scope(isolate_);
v8::HandleScope handle_scope(isolate_);
v8::Local<v8::Context> context = v8::Context::New(isolate_);
v8::Context::Scope context_scope(context);
const size_t size = 10;
AliasedBuffer<uint32_t, v8::Uint32Array> ab{isolate_, size};

EXPECT_EQ(static_cast<uint32_t>(1), ab[0] = 1);
EXPECT_EQ(static_cast<uint32_t>(4), ab[0] += 3);
EXPECT_EQ(static_cast<uint32_t>(2), ab[0] -= 2);
EXPECT_EQ(static_cast<uint32_t>(-2), -ab[0]);
}