This repository was archived by the owner on Dec 29, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 194
Expand file tree
/
Copy pathevent_test.cc
More file actions
91 lines (74 loc) · 2.37 KB
/
event_test.cc
File metadata and controls
91 lines (74 loc) · 2.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#include "wtf/event.h"
#include <fstream>
#include "gtest/gtest.h"
namespace wtf {
namespace {
class EventTest : public ::testing::Test {
protected:
void TearDown() override {}
EventDefinition CreateEventDefinition(const char *name_spec) {
return EventDefinition::Create<int, const char*>(
/*wire_id=*/0, EventClass::kScoped, /*flags=*/0, name_spec);
}
EventDefinition CreateEventDefinition0(const char *name_spec) {
return EventDefinition::Create(
/*wire_id=*/0, EventClass::kScoped, /*flags=*/0, name_spec);
}
};
TEST_F(EventTest, CheckNameSpecParsing) {
std::string output;
auto event = CreateEventDefinition("MyFunc");
event.AppendName(&output);
EXPECT_EQ(output, "MyFunc");
output.clear();
event.AppendArguments(&output);
EXPECT_EQ(output, "int32 a0, ascii a1");
output.clear();
event = CreateEventDefinition("MyNamespace::MyClass::MyFunc");
event.AppendName(&output);
EXPECT_EQ(output, "MyNamespace::MyClass::MyFunc");
output.clear();
event.AppendArguments(&output);
EXPECT_EQ(output, "int32 a0, ascii a1");
output.clear();
event = CreateEventDefinition("MyClass::MyFunc2: arg1 , arg2");
event.AppendName(&output);
EXPECT_EQ(output, "MyClass::MyFunc2");
output.clear();
event.AppendArguments(&output);
EXPECT_EQ(output, "int32 arg1, ascii arg2");
output.clear();
event = CreateEventDefinition("MyFunc2: arg1 , arg2");
event.AppendName(&output);
EXPECT_EQ(output, "MyFunc2");
output.clear();
event.AppendArguments(&output);
EXPECT_EQ(output, "int32 arg1, ascii arg2");
output.clear();
event = CreateEventDefinition("MyFunc3: arg1");
event.AppendName(&output);
EXPECT_EQ(output, "MyFunc3");
output.clear();
event.AppendArguments(&output);
EXPECT_EQ(output, "int32 arg1, ascii a1");
output.clear();
event = CreateEventDefinition0("MyMethodNoArgs");
event.AppendName(&output);
EXPECT_EQ(output, "MyMethodNoArgs");
output.clear();
event.AppendArguments(&output);
EXPECT_EQ(output, "");
output.clear();
event = CreateEventDefinition0("-[MyMethod looksLikeObjC:hasColons:]");
event.AppendName(&output);
EXPECT_EQ(output, "-[MyMethod looksLikeObjC:hasColons:]");
output.clear();
event.AppendArguments(&output);
EXPECT_EQ(output, "");
}
} // namespace
} // namespace wtf
int main(int argc, char** argv) {
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}