|
@@ -1,149 +0,0 @@
|
1
|
|
-From e10b53b87bb7ce87d1a31473e03a02ccafa78787 Mon Sep 17 00:00:00 2001
|
2
|
|
-From: J-P Nurmi <jpnurmi@gmail.com>
|
3
|
|
-Date: Tue, 3 Feb 2015 10:11:47 +0100
|
4
|
|
-Subject: [PATCH] Fix CIRCNetwork::FindChans() and FindQueries() to be
|
5
|
|
- case-insensitive
|
6
|
|
-
|
7
|
|
-The playback module failed to clear a buffer, because it tried to
|
8
|
|
-clear "NickServ" whereas ZNC had internally stored it has "nickserv".
|
9
|
|
----
|
10
|
|
- Makefile.in | 2 +-
|
11
|
|
- src/IRCNetwork.cpp | 6 ++--
|
12
|
|
- test/NetworkTest.cpp | 96 ++++++++++++++++++++++++++++++++++++++++++++++++++++
|
13
|
|
- 3 files changed, 101 insertions(+), 3 deletions(-)
|
14
|
|
- create mode 100644 test/NetworkTest.cpp
|
15
|
|
-
|
16
|
|
---- a/Makefile.in
|
17
|
|
-+++ b/Makefile.in
|
18
|
|
-@@ -48,7 +48,7 @@ LIB_SRCS := $(addprefix src/,$(LIB_SRCS
|
19
|
|
- BIN_SRCS := src/main.cpp
|
20
|
|
- LIB_OBJS := $(patsubst %cpp,%o,$(LIB_SRCS))
|
21
|
|
- BIN_OBJS := $(patsubst %cpp,%o,$(BIN_SRCS))
|
22
|
|
--TESTS := StringTest ConfigTest UtilsTest ThreadTest NickTest ClientTest
|
23
|
|
-+TESTS := StringTest ConfigTest UtilsTest ThreadTest NickTest ClientTest NetworkTest
|
24
|
|
- TESTS := $(addprefix test/,$(addsuffix .o,$(TESTS)))
|
25
|
|
- CLEAN := znc src/*.o test/*.o core core.* .version_extra .depend modules/.depend unittest
|
26
|
|
- DISTCLEAN := Makefile config.log config.status znc-buildmod \
|
27
|
|
---- a/src/IRCNetwork.cpp
|
28
|
|
-+++ b/src/IRCNetwork.cpp
|
29
|
|
-@@ -787,8 +787,9 @@ CChan* CIRCNetwork::FindChan(CString sNa
|
30
|
|
- std::vector<CChan*> CIRCNetwork::FindChans(const CString& sWild) const {
|
31
|
|
- std::vector<CChan*> vChans;
|
32
|
|
- vChans.reserve(m_vChans.size());
|
33
|
|
-+ const CString sLower = sWild.AsLower();
|
34
|
|
- for (std::vector<CChan*>::const_iterator it = m_vChans.begin(); it != m_vChans.end(); ++it) {
|
35
|
|
-- if ((*it)->GetName().WildCmp(sWild))
|
36
|
|
-+ if ((*it)->GetName().AsLower().WildCmp(sLower))
|
37
|
|
- vChans.push_back(*it);
|
38
|
|
- }
|
39
|
|
- return vChans;
|
40
|
|
-@@ -946,8 +947,9 @@ CQuery* CIRCNetwork::FindQuery(const CSt
|
41
|
|
- std::vector<CQuery*> CIRCNetwork::FindQueries(const CString& sWild) const {
|
42
|
|
- std::vector<CQuery*> vQueries;
|
43
|
|
- vQueries.reserve(m_vQueries.size());
|
44
|
|
-+ const CString sLower = sWild.AsLower();
|
45
|
|
- for (std::vector<CQuery*>::const_iterator it = m_vQueries.begin(); it != m_vQueries.end(); ++it) {
|
46
|
|
-- if ((*it)->GetName().WildCmp(sWild))
|
47
|
|
-+ if ((*it)->GetName().AsLower().WildCmp(sLower))
|
48
|
|
- vQueries.push_back(*it);
|
49
|
|
- }
|
50
|
|
- return vQueries;
|
51
|
|
---- /dev/null
|
52
|
|
-+++ b/test/NetworkTest.cpp
|
53
|
|
-@@ -0,0 +1,96 @@
|
54
|
|
-+/*
|
55
|
|
-+ * Copyright (C) 2004-2015 ZNC, see the NOTICE file for details.
|
56
|
|
-+ *
|
57
|
|
-+ * Licensed under the Apache License, Version 2.0 (the "License");
|
58
|
|
-+ * you may not use this file except in compliance with the License.
|
59
|
|
-+ * You may obtain a copy of the License at
|
60
|
|
-+ *
|
61
|
|
-+ * http://www.apache.org/licenses/LICENSE-2.0
|
62
|
|
-+ *
|
63
|
|
-+ * Unless required by applicable law or agreed to in writing, software
|
64
|
|
-+ * distributed under the License is distributed on an "AS IS" BASIS,
|
65
|
|
-+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
66
|
|
-+ * See the License for the specific language governing permissions and
|
67
|
|
-+ * limitations under the License.
|
68
|
|
-+ */
|
69
|
|
-+
|
70
|
|
-+#include <gtest/gtest.h>
|
71
|
|
-+#include <znc/IRCNetwork.h>
|
72
|
|
-+#include <znc/User.h>
|
73
|
|
-+#include <znc/znc.h>
|
74
|
|
-+
|
75
|
|
-+class NetworkTest : public ::testing::Test {
|
76
|
|
-+protected:
|
77
|
|
-+ void SetUp() { CZNC::CreateInstance(); }
|
78
|
|
-+ void TearDown() { CZNC::DestroyInstance(); }
|
79
|
|
-+};
|
80
|
|
-+
|
81
|
|
-+TEST_F(NetworkTest, FindChan) {
|
82
|
|
-+ CUser user("user");
|
83
|
|
-+ CIRCNetwork network(&user, "network");
|
84
|
|
-+
|
85
|
|
-+ EXPECT_TRUE(network.AddChan("#foo", false));
|
86
|
|
-+ EXPECT_TRUE(network.AddChan("#Bar", false));
|
87
|
|
-+ EXPECT_TRUE(network.AddChan("#BAZ", false));
|
88
|
|
-+
|
89
|
|
-+ EXPECT_TRUE(network.FindChan("#foo"));
|
90
|
|
-+ EXPECT_TRUE(network.FindChan("#Bar"));
|
91
|
|
-+ EXPECT_TRUE(network.FindChan("#BAZ"));
|
92
|
|
-+
|
93
|
|
-+ EXPECT_TRUE(network.FindChan("#Foo"));
|
94
|
|
-+ EXPECT_TRUE(network.FindChan("#BAR"));
|
95
|
|
-+ EXPECT_TRUE(network.FindChan("#baz"));
|
96
|
|
-+
|
97
|
|
-+ EXPECT_FALSE(network.FindChan("#f"));
|
98
|
|
-+ EXPECT_FALSE(network.FindChan("&foo"));
|
99
|
|
-+ EXPECT_FALSE(network.FindChan("##foo"));
|
100
|
|
-+}
|
101
|
|
-+
|
102
|
|
-+TEST_F(NetworkTest, FindChans) {
|
103
|
|
-+ CUser user("user");
|
104
|
|
-+ CIRCNetwork network(&user, "network");
|
105
|
|
-+
|
106
|
|
-+ EXPECT_TRUE(network.AddChan("#foo", false));
|
107
|
|
-+ EXPECT_TRUE(network.AddChan("#Bar", false));
|
108
|
|
-+ EXPECT_TRUE(network.AddChan("#BAZ", false));
|
109
|
|
-+
|
110
|
|
-+ EXPECT_EQ(network.FindChans("#f*").size(), 1);
|
111
|
|
-+ EXPECT_EQ(network.FindChans("#b*").size(), 2);
|
112
|
|
-+ EXPECT_EQ(network.FindChans("#?A*").size(), 2);
|
113
|
|
-+ EXPECT_EQ(network.FindChans("*z").size(), 1);
|
114
|
|
-+}
|
115
|
|
-+
|
116
|
|
-+TEST_F(NetworkTest, FindQuery) {
|
117
|
|
-+ CUser user("user");
|
118
|
|
-+ CIRCNetwork network(&user, "network");
|
119
|
|
-+
|
120
|
|
-+ EXPECT_TRUE(network.AddQuery("foo"));
|
121
|
|
-+ EXPECT_TRUE(network.AddQuery("Bar"));
|
122
|
|
-+ EXPECT_TRUE(network.AddQuery("BAZ"));
|
123
|
|
-+
|
124
|
|
-+ EXPECT_TRUE(network.FindQuery("foo"));
|
125
|
|
-+ EXPECT_TRUE(network.FindQuery("Bar"));
|
126
|
|
-+ EXPECT_TRUE(network.FindQuery("BAZ"));
|
127
|
|
-+
|
128
|
|
-+ EXPECT_TRUE(network.FindQuery("Foo"));
|
129
|
|
-+ EXPECT_TRUE(network.FindQuery("BAR"));
|
130
|
|
-+ EXPECT_TRUE(network.FindQuery("baz"));
|
131
|
|
-+
|
132
|
|
-+ EXPECT_FALSE(network.FindQuery("f"));
|
133
|
|
-+ EXPECT_FALSE(network.FindQuery("fo"));
|
134
|
|
-+ EXPECT_FALSE(network.FindQuery("FF"));
|
135
|
|
-+}
|
136
|
|
-+
|
137
|
|
-+TEST_F(NetworkTest, FindQueries) {
|
138
|
|
-+ CUser user("user");
|
139
|
|
-+ CIRCNetwork network(&user, "network");
|
140
|
|
-+
|
141
|
|
-+ EXPECT_TRUE(network.AddQuery("foo"));
|
142
|
|
-+ EXPECT_TRUE(network.AddQuery("Bar"));
|
143
|
|
-+ EXPECT_TRUE(network.AddQuery("BAZ"));
|
144
|
|
-+
|
145
|
|
-+ EXPECT_EQ(network.FindQueries("f*").size(), 1);
|
146
|
|
-+ EXPECT_EQ(network.FindQueries("b*").size(), 2);
|
147
|
|
-+ EXPECT_EQ(network.FindQueries("?A*").size(), 2);
|
148
|
|
-+ EXPECT_EQ(network.FindQueries("*z").size(), 1);
|
149
|
|
-+}
|