Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
third_party
dart-lang
sdk
runtime
bin
eventhandler_test.cc
Go to the documentation of this file.
1
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2
// for details. All rights reserved. Use of this source code is governed by a
3
// BSD-style license that can be found in the LICENSE file.
4
5
#include "
bin/eventhandler.h
"
6
#include "
platform/assert.h
"
7
#include "
vm/unit_test.h
"
8
9
namespace
dart
{
10
namespace
bin {
11
12
VM_UNIT_TEST_CASE
(
CircularLinkedList
) {
13
CircularLinkedList<int>
list;
14
15
EXPECT
(!list.
HasHead
());
16
17
list.
Add
(1);
18
EXPECT
(list.
HasHead
());
19
EXPECT
(list.
head
() == 1);
20
21
// Test: Inserts don't move head.
22
for
(
int
i = 2; i <= 100; i++) {
23
list.
Add
(i);
24
EXPECT
(list.
head
() == 1);
25
}
26
27
// Test: Rotate cycle through all elements in insertion order.
28
for
(
int
i = 1; i <= 100; i++) {
29
EXPECT
(list.
HasHead
());
30
EXPECT
(list.
head
() == i);
31
list.
Rotate
();
32
}
33
34
// Test: Removing head results in next element to be head.
35
for
(
int
i = 1; i <= 100; i++) {
36
list.
RemoveHead
();
37
for
(
int
j = i + 1; j <= 100; j++) {
38
EXPECT
(list.
HasHead
());
39
EXPECT
(list.
head
() == j);
40
list.
Rotate
();
41
}
42
}
43
44
// Test: Removing all items individually make list empty.
45
EXPECT
(!list.
HasHead
());
46
47
// Test: Removing all items at once makes list empty.
48
for
(
int
i = 1; i <= 100; i++) {
49
list.
Add
(i);
50
}
51
list.
RemoveAll
();
52
EXPECT
(!list.
HasHead
());
53
54
// Test: Remove individual items just deletes them without modifying head.
55
for
(
int
i = 1; i <= 10; i++) {
56
list.
Add
(i);
57
}
58
for
(
int
i = 2; i <= 9; i++) {
59
list.
Remove
(i);
60
}
61
EXPECT
(list.
head
() == 1);
62
list.
Rotate
();
63
EXPECT
(list.
head
() == 10);
64
list.
Rotate
();
65
EXPECT
(list.
head
() == 1);
66
67
// Test: Remove nonexistent element leaves list un-changed.
68
list.
Remove
(4242);
69
EXPECT
(list.
head
() == 1);
70
71
// Test: Remove head element individually moves head to next element.
72
list.
Remove
(1);
73
EXPECT
(list.
HasHead
());
74
EXPECT
(list.
head
() == 10);
75
list.
Remove
(10);
76
EXPECT
(!list.
HasHead
());
77
78
// Test: Remove nonexistent element from empty list works.
79
list.
Remove
(4242);
80
}
81
82
}
// namespace bin
83
}
// namespace dart
EXPECT
#define EXPECT(type, expectedAlignment, expectedSize)
Definition
UniformOffsetCalculatorTest.cpp:33
assert.h
dart::bin::CircularLinkedList
Definition
eventhandler.h:113
dart::bin::CircularLinkedList::RemoveAll
void RemoveAll(ClearFun clear=nullptr)
Definition
eventhandler.h:185
dart::bin::CircularLinkedList::head
T head() const
Definition
eventhandler.h:191
dart::bin::CircularLinkedList::Remove
void Remove(T item)
Definition
eventhandler.h:155
dart::bin::CircularLinkedList::Add
bool Add(T t)
Definition
eventhandler.h:120
dart::bin::CircularLinkedList::RemoveHead
void RemoveHead(ClearFun clear=nullptr)
Definition
eventhandler.h:138
dart::bin::CircularLinkedList::HasHead
bool HasHead() const
Definition
eventhandler.h:193
dart::bin::CircularLinkedList::Rotate
void Rotate()
Definition
eventhandler.h:195
eventhandler.h
dart
Definition
dart_vm.cc:33
unit_test.h
VM_UNIT_TEST_CASE
#define VM_UNIT_TEST_CASE(name)
Definition
unit_test.h:33
Generated on Fri Apr 26 2024 06:14:41 for Flutter Engine by
1.9.8