Skip to content

Commit 43e6616

Browse files
committed
Modify the code style of some files
1 parent 5961465 commit 43e6616

File tree

8 files changed

+62
-56
lines changed

8 files changed

+62
-56
lines changed

trantor/net/inner/AresResolver.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ class AresResolver : public Resolver,
8484
void onQueryResult(int status,
8585
struct hostent* result,
8686
const std::string& hostname,
87-
const Callback& cb);
87+
const Callback& callback);
8888
void onSockCreate(int sockfd, int type);
8989
void onSockStateChange(int sockfd, bool read, bool write);
9090

trantor/net/inner/NormalResolver.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,8 @@ void NormalResolver::resolve(const std::string &hostname,
9494
{
9595
std::lock_guard<std::mutex> guard(thisPtr->globalMutex());
9696
thisPtr->globalCache()[hostname].first = addr.sin_addr;
97-
thisPtr->globalCache()[hostname].second = trantor::Date::date();
97+
thisPtr->globalCache()[hostname].second =
98+
trantor::Date::date();
9899
}
99100
return;
100101
}

trantor/net/inner/NormalResolver.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class NormalResolver : public Resolver,
2121
public:
2222
virtual void resolve(const std::string& hostname,
2323
const Callback& callback) override;
24-
NormalResolver(size_t timeout)
24+
explicit NormalResolver(size_t timeout)
2525
: _taskQueue("Dns Queue"), _timeout(timeout), _resolveBuffer(16 * 1024)
2626
{
2727
}

trantor/net/ssl/SSLConnection.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ class SSLContext
6666
class SSLConn
6767
{
6868
public:
69-
SSLConn(SSL_CTX *ctx)
69+
explicit SSLConn(SSL_CTX *ctx)
7070
{
7171
_SSL = SSL_new(ctx);
7272
}

trantor/tests/DnsTest.cc

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,12 @@ void dns(const std::shared_ptr<trantor::Resolver> &resolver)
3131
std::cout << "bad address:" << addr.toIp() << " "
3232
<< interval / 1000 << "ms" << std::endl;
3333
});
34-
resolver->resolve("localhost",
35-
[now](const trantor::InetAddress &addr) {
36-
auto interval =
37-
trantor::Date::now().microSecondsSinceEpoch() -
38-
now.microSecondsSinceEpoch();
39-
std::cout << "localhost:" << addr.toIp() << " "
40-
<< interval / 1000 << "ms" << std::endl;
41-
});
34+
resolver->resolve("localhost", [now](const trantor::InetAddress &addr) {
35+
auto interval = trantor::Date::now().microSecondsSinceEpoch() -
36+
now.microSecondsSinceEpoch();
37+
std::cout << "localhost:" << addr.toIp() << " " << interval / 1000
38+
<< "ms" << std::endl;
39+
});
4240
}
4341
int main()
4442
{

trantor/unittests/DateUnittest.cc

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,22 @@ using namespace trantor;
66
TEST(Date, constructorTest)
77
{
88
EXPECT_STREQ("1985-01-01 00:00:00",
9-
trantor::Date(1985, 1, 1).toCustomedFormattedStringLocal("%Y-%m-%d %H:%M:%S").c_str());
9+
trantor::Date(1985, 1, 1)
10+
.toCustomedFormattedStringLocal("%Y-%m-%d %H:%M:%S")
11+
.c_str());
1012
EXPECT_STREQ("2004-02-29 00:00:00.000000",
11-
trantor::Date(2004, 2, 29).toCustomedFormattedStringLocal("%Y-%m-%d %H:%M:%S", true).c_str());
13+
trantor::Date(2004, 2, 29)
14+
.toCustomedFormattedStringLocal("%Y-%m-%d %H:%M:%S", true)
15+
.c_str());
1216
EXPECT_STRNE("2001-02-29 00:00:00.000000",
13-
trantor::Date(2001, 2, 29).toCustomedFormattedStringLocal("%Y-%m-%d %H:%M:%S", true).c_str());
17+
trantor::Date(2001, 2, 29)
18+
.toCustomedFormattedStringLocal("%Y-%m-%d %H:%M:%S", true)
19+
.c_str());
1420
EXPECT_STREQ("2018-01-01 00:00:00.000000",
15-
trantor::Date(2018, 1, 1, 12, 12, 12, 2321).roundDay().toCustomedFormattedStringLocal("%Y-%m-%d %H:%M:%S", true).c_str());
21+
trantor::Date(2018, 1, 1, 12, 12, 12, 2321)
22+
.roundDay()
23+
.toCustomedFormattedStringLocal("%Y-%m-%d %H:%M:%S", true)
24+
.c_str());
1625
}
1726
int main(int argc, char **argv)
1827
{

trantor/unittests/InetAddressUnittest.cc

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@
55
using namespace trantor;
66
TEST(InetAddress, innerIpTest)
77
{
8-
EXPECT_EQ(true,InetAddress("192.168.0.1",0).isIntranetIp());
9-
EXPECT_EQ(true,InetAddress("192.168.12.1",0).isIntranetIp());
10-
EXPECT_EQ(true,InetAddress("10.168.0.1",0).isIntranetIp());
11-
EXPECT_EQ(true,InetAddress("10.0.0.1",0).isIntranetIp());
12-
EXPECT_EQ(true,InetAddress("172.31.10.1",0).isIntranetIp());
13-
EXPECT_EQ(true,InetAddress("127.0.0.1",0).isIntranetIp());
8+
EXPECT_EQ(true, InetAddress("192.168.0.1", 0).isIntranetIp());
9+
EXPECT_EQ(true, InetAddress("192.168.12.1", 0).isIntranetIp());
10+
EXPECT_EQ(true, InetAddress("10.168.0.1", 0).isIntranetIp());
11+
EXPECT_EQ(true, InetAddress("10.0.0.1", 0).isIntranetIp());
12+
EXPECT_EQ(true, InetAddress("172.31.10.1", 0).isIntranetIp());
13+
EXPECT_EQ(true, InetAddress("127.0.0.1", 0).isIntranetIp());
1414
}
15-
int main( int argc, char **argv)
15+
int main(int argc, char **argv)
1616
{
1717
testing::InitGoogleTest(&argc, argv);
1818
return RUN_ALL_TESTS();

trantor/unittests/MsgBufferUnittest.cc

Lines changed: 31 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -7,73 +7,71 @@ TEST(MsgBufferTest, readableTest)
77
{
88
MsgBuffer buffer;
99

10-
EXPECT_EQ(0,buffer.readableBytes());
11-
buffer.append(std::string(128,'a'));
12-
EXPECT_EQ(128,buffer.readableBytes());
10+
EXPECT_EQ(0, buffer.readableBytes());
11+
buffer.append(std::string(128, 'a'));
12+
EXPECT_EQ(128, buffer.readableBytes());
1313
buffer.retrieve(100);
14-
EXPECT_EQ(28,buffer.readableBytes());
15-
EXPECT_EQ('a',buffer.peekInt8());
14+
EXPECT_EQ(28, buffer.readableBytes());
15+
EXPECT_EQ('a', buffer.peekInt8());
1616
buffer.retrieveAll();
17-
EXPECT_EQ(0,buffer.readableBytes());
17+
EXPECT_EQ(0, buffer.readableBytes());
1818
}
1919
TEST(MsgBufferTest, writableTest)
2020
{
2121
MsgBuffer buffer(100);
2222

23-
EXPECT_EQ(100,buffer.writableBytes());
23+
EXPECT_EQ(100, buffer.writableBytes());
2424
buffer.append("abcde");
25-
EXPECT_EQ(95,buffer.writableBytes());
26-
buffer.append(std::string(100,'x'));
27-
EXPECT_EQ(111,buffer.writableBytes());
25+
EXPECT_EQ(95, buffer.writableBytes());
26+
buffer.append(std::string(100, 'x'));
27+
EXPECT_EQ(111, buffer.writableBytes());
2828
buffer.retrieve(100);
29-
EXPECT_EQ(111,buffer.writableBytes());
30-
buffer.append(std::string(112,'c'));
31-
EXPECT_EQ(99,buffer.writableBytes());
29+
EXPECT_EQ(111, buffer.writableBytes());
30+
buffer.append(std::string(112, 'c'));
31+
EXPECT_EQ(99, buffer.writableBytes());
3232
buffer.retrieveAll();
33-
EXPECT_EQ(216,buffer.writableBytes());
33+
EXPECT_EQ(216, buffer.writableBytes());
3434
}
3535

3636
TEST(MsgBufferTest, addInFrontTest)
3737
{
3838
MsgBuffer buffer(100);
3939

40-
EXPECT_EQ(100,buffer.writableBytes());
40+
EXPECT_EQ(100, buffer.writableBytes());
4141
buffer.addInFrontInt8('a');
42-
EXPECT_EQ(100,buffer.writableBytes());
42+
EXPECT_EQ(100, buffer.writableBytes());
4343
buffer.addInFrontInt64(123);
44-
EXPECT_EQ(92,buffer.writableBytes());
44+
EXPECT_EQ(92, buffer.writableBytes());
4545
buffer.addInFrontInt64(100);
46-
EXPECT_EQ(84,buffer.writableBytes());
46+
EXPECT_EQ(84, buffer.writableBytes());
4747
buffer.addInFrontInt8(1);
48-
EXPECT_EQ(84,buffer.writableBytes());
48+
EXPECT_EQ(84, buffer.writableBytes());
4949
}
5050

51-
TEST(MsgBuffer,MoveContrustor)
51+
TEST(MsgBuffer, MoveContrustor)
5252
{
53-
5453
MsgBuffer buf1(100);
55-
const char *bufptr1=buf1.peek();
56-
MsgBuffer buffnew1=std::move(buf1);
57-
EXPECT_EQ(bufptr1,buffnew1.peek());
54+
const char *bufptr1 = buf1.peek();
55+
MsgBuffer buffnew1 = std::move(buf1);
56+
EXPECT_EQ(bufptr1, buffnew1.peek());
5857

5958
MsgBuffer buf2(100);
60-
const char *bufptr2=buf2.peek();
59+
const char *bufptr2 = buf2.peek();
6160
MsgBuffer buffnew2(std::move(buf2));
62-
EXPECT_EQ(bufptr2,buffnew2.peek());
63-
61+
EXPECT_EQ(bufptr2, buffnew2.peek());
6462
}
6563

6664
TEST(Msgbuffer, MoveAssignmentOperator)
6765
{
6866
MsgBuffer buf(100);
69-
const char *bufptr=buf.peek();
70-
size_t writable=buf.writableBytes();
67+
const char *bufptr = buf.peek();
68+
size_t writable = buf.writableBytes();
7169
MsgBuffer buffnew(1000);
72-
buffnew=std::move(buf);
73-
EXPECT_EQ(bufptr,buffnew.peek());
74-
EXPECT_EQ(writable,buffnew.writableBytes());
70+
buffnew = std::move(buf);
71+
EXPECT_EQ(bufptr, buffnew.peek());
72+
EXPECT_EQ(writable, buffnew.writableBytes());
7573
}
76-
int main( int argc, char **argv)
74+
int main(int argc, char **argv)
7775
{
7876
testing::InitGoogleTest(&argc, argv);
7977
return RUN_ALL_TESTS();

0 commit comments

Comments
 (0)