Skip to content

Commit 7a9a5fb

Browse files
committed
update tests
1 parent 63d10af commit 7a9a5fb

File tree

5 files changed

+35
-9
lines changed

5 files changed

+35
-9
lines changed

index.hxx

+3-5
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
#include <map>
1010

1111
class EventEmitter {
12-
1312
std::map<std::string, void*> events;
1413
std::map<std::string, bool> events_once;
1514

@@ -33,15 +32,14 @@ class EventEmitter {
3332
int _listeners = 0;
3433

3534
public:
36-
3735
int maxListeners = 10;
3836

3937
int listeners() {
4038
return this->_listeners;
4139
}
4240

4341
template <typename Callback>
44-
void on(std::string name, Callback cb) {
42+
void on(const std::string& name, Callback cb) {
4543

4644
auto it = events.find(name);
4745
if (it != events.end()) {
@@ -62,7 +60,7 @@ class EventEmitter {
6260
}
6361

6462
template <typename Callback>
65-
void once(std::string name, Callback cb) {
63+
void once(const std::string& name, Callback cb) {
6664
this->on(name, cb);
6765
events_once[name] = true;
6866
}
@@ -73,7 +71,7 @@ class EventEmitter {
7371
this->_listeners = 0;
7472
}
7573

76-
void off(std::string name) {
74+
void off(const std::string& name) {
7775

7876
auto it = events.find(name);
7977

package.json

+10-2
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,17 @@
66
"url": "git://github.com/datcxx/cxx-eventemitter.git"
77
},
88
"homepage": "https://github.com/datcxx/cxx-eventemitter",
9-
"dependencies": {},
9+
"dependencies": {
10+
},
1011
"scripts": {
11-
"test": "c++ -std=c++2a test/index.cxx -o test/index && ./test/index"
12+
"test": [
13+
"clang++ -std=c++2a",
14+
"-O1 -g -fsanitize=address -fno-omit-frame-pointer",
15+
"test/index.cxx -o test/index &&",
16+
"ASAN_OPTIONS=detect_leaks=1",
17+
"ASAN_OPTIONS=fast_unwind_on_malloc=0",
18+
"./test/index"
19+
]
1220
},
1321
"files": [
1422
"index.hxx"

test/index.cxx

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
} \
1313
} while(0);
1414

15-
int main (int argc, char* argv[]) {
15+
int main () {
1616
int testcount = 0;
1717
int testplan = 9;
1818

@@ -25,7 +25,7 @@ int main (int argc, char* argv[]) {
2525

2626
ASSERT("maxListeners should be 10", ee.maxListeners == 10);
2727

28-
ee.on("event1", [&](int a, std::string b) {
28+
ee.on("event1", [&](int a, std::string& b) {
2929
ASSERT("first arg should be equal to 10", a == 10);
3030
ASSERT("second arg should be foo", b == "foo");
3131
});

test/index.dSYM/Contents/Info.plist

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>CFBundleDevelopmentRegion</key>
6+
<string>English</string>
7+
<key>CFBundleIdentifier</key>
8+
<string>com.apple.xcode.dsym.index</string>
9+
<key>CFBundleInfoDictionaryVersion</key>
10+
<string>6.0</string>
11+
<key>CFBundlePackageType</key>
12+
<string>dSYM</string>
13+
<key>CFBundleSignature</key>
14+
<string>????</string>
15+
<key>CFBundleShortVersionString</key>
16+
<string>1.0</string>
17+
<key>CFBundleVersion</key>
18+
<string>1</string>
19+
</dict>
20+
</plist>
1.15 MB
Binary file not shown.

0 commit comments

Comments
 (0)