a335f2aeed
This replaces all typedefs that define types and not functions by the equivalent "using" declaration. This was done mostly automatically using this command: ag -l '\btypedef\b' src test | xargs -L1 \ perl -i -p0e 's/typedef ([^*;{}]+) (\w+);/using \2 = \1;/sg' Patchset 2 then adds some manual changes for typedefs for pointer types, where the regular expression did not match. R=mstarzinger@chromium.org TBR=yangguo@chromium.org, jarin@chromium.org Bug: v8:9183 Change-Id: I6f6ee28d1793b7ac34a58f980b94babc21874b78 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1631409 Commit-Queue: Clemens Hammacher <clemensh@chromium.org> Reviewed-by: Michael Starzinger <mstarzinger@chromium.org> Cr-Commit-Position: refs/heads/master@{#61849}
87 lines
1.9 KiB
C++
87 lines
1.9 KiB
C++
// Copyright 2015 the V8 project authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
#include "src/utils/locked-queue-inl.h"
|
|
#include "testing/gtest/include/gtest/gtest.h"
|
|
|
|
namespace {
|
|
|
|
using Record = int;
|
|
|
|
} // namespace
|
|
|
|
namespace v8 {
|
|
namespace internal {
|
|
|
|
TEST(LockedQueue, ConstructorEmpty) {
|
|
LockedQueue<Record> queue;
|
|
EXPECT_TRUE(queue.IsEmpty());
|
|
}
|
|
|
|
TEST(LockedQueue, SingleRecordEnqueueDequeue) {
|
|
LockedQueue<Record> queue;
|
|
EXPECT_TRUE(queue.IsEmpty());
|
|
queue.Enqueue(1);
|
|
EXPECT_FALSE(queue.IsEmpty());
|
|
Record a = -1;
|
|
bool success = queue.Dequeue(&a);
|
|
EXPECT_TRUE(success);
|
|
EXPECT_EQ(a, 1);
|
|
EXPECT_TRUE(queue.IsEmpty());
|
|
}
|
|
|
|
TEST(LockedQueue, Peek) {
|
|
LockedQueue<Record> queue;
|
|
EXPECT_TRUE(queue.IsEmpty());
|
|
queue.Enqueue(1);
|
|
EXPECT_FALSE(queue.IsEmpty());
|
|
Record a = -1;
|
|
bool success = queue.Peek(&a);
|
|
EXPECT_TRUE(success);
|
|
EXPECT_EQ(a, 1);
|
|
EXPECT_FALSE(queue.IsEmpty());
|
|
success = queue.Dequeue(&a);
|
|
EXPECT_TRUE(success);
|
|
EXPECT_EQ(a, 1);
|
|
EXPECT_TRUE(queue.IsEmpty());
|
|
}
|
|
|
|
TEST(LockedQueue, PeekOnEmpty) {
|
|
LockedQueue<Record> queue;
|
|
EXPECT_TRUE(queue.IsEmpty());
|
|
Record a = -1;
|
|
bool success = queue.Peek(&a);
|
|
EXPECT_FALSE(success);
|
|
}
|
|
|
|
TEST(LockedQueue, MultipleRecords) {
|
|
LockedQueue<Record> queue;
|
|
EXPECT_TRUE(queue.IsEmpty());
|
|
queue.Enqueue(1);
|
|
EXPECT_FALSE(queue.IsEmpty());
|
|
for (int i = 2; i <= 5; ++i) {
|
|
queue.Enqueue(i);
|
|
EXPECT_FALSE(queue.IsEmpty());
|
|
}
|
|
Record rec = 0;
|
|
for (int i = 1; i <= 4; ++i) {
|
|
EXPECT_FALSE(queue.IsEmpty());
|
|
queue.Dequeue(&rec);
|
|
EXPECT_EQ(i, rec);
|
|
}
|
|
for (int i = 6; i <= 12; ++i) {
|
|
queue.Enqueue(i);
|
|
EXPECT_FALSE(queue.IsEmpty());
|
|
}
|
|
for (int i = 5; i <= 12; ++i) {
|
|
EXPECT_FALSE(queue.IsEmpty());
|
|
queue.Dequeue(&rec);
|
|
EXPECT_EQ(i, rec);
|
|
}
|
|
EXPECT_TRUE(queue.IsEmpty());
|
|
}
|
|
|
|
} // namespace internal
|
|
} // namespace v8
|