Skip to content

Commit c22d1ea

Browse files
committed
format
1 parent 3393751 commit c22d1ea

File tree

2 files changed

+33
-45
lines changed

2 files changed

+33
-45
lines changed

unittest/misc_test.cc

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1385,39 +1385,36 @@ TEST_F(MiscTest, flatHashMap) {
13851385
}
13861386

13871387
TEST_F(MiscTest, testNaN) {
1388-
std::cout<<1.0/0.0<<std::endl;
1388+
std::cout << 1.0 / 0.0 << std::endl;
13891389
}
1390-
#include <variant>
13911390
#include <any>
1391+
#include <variant>
13921392
TEST_F(MiscTest, testVariant) {
1393-
std::variant<int, float,double,std::string> v;
1394-
std::variant<int,short, float,double,std::string> v1;
1395-
std::cout<<sizeof(v)<<std::endl;
1396-
std::cout<<sizeof(v1)<<std::endl;
1393+
std::variant<int, float, double, std::string> v;
1394+
std::variant<int, short, float, double, std::string> v1;
1395+
std::cout << sizeof(v) << std::endl;
1396+
std::cout << sizeof(v1) << std::endl;
13971397
std::any a;
13981398

1399-
std::cout<<sizeof(a)<<std::endl;
1399+
std::cout << sizeof(a) << std::endl;
14001400
}
14011401

14021402
#include <absl/strings/str_join.h>
14031403

1404-
template<typename Type>
1404+
template <typename Type>
14051405
struct ColumnBuilder {
1406-
void append(const Type& value) {
1407-
data.push_back(value);
1408-
}
1406+
void append(const Type& value) { data.push_back(value); }
14091407
//template<typename T, typename=std::enable_if_t<std::is_arithmetic_v<T>&&!std::is_same_v<T, Type>, T>>
14101408
//void append(const T& value) {
14111409
// append(static_cast<Type>(value));
14121410
//}
1413-
void print() {
1414-
std::cout<<absl::StrJoin(data, ",")<<std::endl;
1415-
}
1411+
void print() { std::cout << absl::StrJoin(data, ",") << std::endl; }
1412+
14161413
private:
14171414
std::vector<Type> data;
14181415
};
14191416

1420-
TEST_F(MiscTest, testAppend){
1417+
TEST_F(MiscTest, testAppend) {
14211418
ColumnBuilder<int> x;
14221419
#pragma GCC diagnostic ignored "-Wconversion"
14231420
#pragma GCC diagnostic ignored "-Wfloat-conversion"

unittest/test_memory_leak.cc

Lines changed: 21 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,51 @@
1-
#include <gtest/gtest.h>
21
#include <glog/logging.h>
2+
#include <gtest/gtest.h>
3+
#include <stacktrace.h>
4+
#include <utilities.h>
5+
36
#include <memory>
47
#include <string>
5-
#include <utilities.h>
6-
#include <stacktrace.h>
78

89
namespace test {
9-
struct MemoryLeakTest: public ::testing::Test {
10-
};
11-
TEST_F(MemoryLeakTest, testMoveUniqueToSharedPtr){
10+
struct MemoryLeakTest : public ::testing::Test {};
11+
TEST_F(MemoryLeakTest, testMoveUniqueToSharedPtr) {
1212
google::InstallFailureSignalHandler();
13-
struct CharBuffer{
13+
struct CharBuffer {
1414
std::string s;
15-
explicit CharBuffer(const std::string& s):s(s){
16-
std::cout<<"Ctor"<<std::endl;
17-
}
18-
CharBuffer(const CharBuffer& cb):s(cb.s) {
19-
std::cout<<"Copy ctor"<<std::endl;
20-
}
21-
~CharBuffer() {
22-
std::cout<<"Dtor"<<std::endl;
23-
}
24-
std::unique_ptr<CharBuffer> clone() {
25-
return std::make_unique<CharBuffer>(s);
26-
}
15+
explicit CharBuffer(const std::string& s) : s(s) { std::cout << "Ctor" << std::endl; }
16+
CharBuffer(const CharBuffer& cb) : s(cb.s) { std::cout << "Copy ctor" << std::endl; }
17+
~CharBuffer() { std::cout << "Dtor" << std::endl; }
18+
std::unique_ptr<CharBuffer> clone() { return std::make_unique<CharBuffer>(s); }
2719
};
2820

2921
auto cb0 = std::make_shared<CharBuffer>("abc");
3022
auto cb2 = cb0->clone();
3123
std::shared_ptr<CharBuffer> cb3 = std::move(cb2);
32-
std::cout<<cb0.get()<<std::endl;
33-
std::cout<<cb2.get()<<std::endl;
34-
std::cout<<cb3.get()<<std::endl;
35-
DCHECK(cb0.get()==nullptr);
24+
std::cout << cb0.get() << std::endl;
25+
std::cout << cb2.get() << std::endl;
26+
std::cout << cb3.get() << std::endl;
27+
DCHECK(cb0.get() == nullptr);
3628
std::string s;
3729
//google::glog_internal_namespace_::DumpStackTraceToString(&s);
38-
std::cout<<s<<std::endl;
30+
std::cout << s << std::endl;
3931
}
4032
TEST_F(MemoryLeakTest, testNoCtor) {
41-
struct A{
42-
std::vector<std::shared_ptr<std::string>> data;
33+
struct A {
34+
std::vector<std::shared_ptr<std::string>> data;
4335
};
4436
auto a = std::make_shared<A>();
4537
a->data.reserve(10);
46-
for (int i=0; i < 10; ++i) {
38+
for (int i = 0; i < 10; ++i) {
4739
auto s = std::make_shared<std::string>("aaaaaaaaaa");
4840
a->data.push_back(s);
4941
}
5042

5143
A* a0 = new A(*a.get());
5244
delete a0;
53-
54-
}
5545
}
46+
} // namespace test
5647

57-
int main(int argc, char**argv){
48+
int main(int argc, char** argv) {
5849
testing::InitGoogleTest(&argc, argv);
5950
return RUN_ALL_TESTS();
6051
}

0 commit comments

Comments
 (0)