Skip to content

Commit 7db585e

Browse files
committed
Fix review findings
1 parent af8eff6 commit 7db585e

File tree

6 files changed

+27
-30
lines changed

6 files changed

+27
-30
lines changed

CMakeLists.txt

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
CMAKE_MINIMUM_REQUIRED( VERSION 3.10 )
22
PROJECT( cppcore )
3-
SET ( CPPCORE_VERSION_MAJOR 0 )
4-
SET ( CPPCORE_VERSION_MINOR 1 )
5-
SET ( CPPCORE_VERSION_PATCH 0 )
6-
SET ( CPPCORE_VERSION ${CPPCORE_VERSION_MAJOR}.${CPPCORE_VERSION_MINOR}.${CPPCORE_VERSION_PATCH} )
7-
SET ( PROJECT_VERSION "${CPPCORE_VERSION}" )
3+
SET( CPPCORE_VERSION_MAJOR 0 )
4+
SET( CPPCORE_VERSION_MINOR 1 )
5+
SET( CPPCORE_VERSION_PATCH 0 )
6+
SET( CPPCORE_VERSION ${CPPCORE_VERSION_MAJOR}.${CPPCORE_VERSION_MINOR}.${CPPCORE_VERSION_PATCH} )
7+
SET( PROJECT_VERSION "${CPPCORE_VERSION}" )
88

99
find_package(GTest)
1010

@@ -17,11 +17,11 @@ option( CPPCORE_BUILD_UNITTESTS
1717
"Build unit tests."
1818
ON
1919
)
20-
option( CPPCORE_ASAN
20+
option(CPPCORE_ASAN
2121
"Enable AddressSanitizer."
2222
OFF
2323
)
24-
option( CPPCORE_UBSAN
24+
option(CPPCORE_UBSAN
2525
"Enable Undefined Behavior sanitizer."
2626
OFF
2727
)
@@ -38,9 +38,9 @@ link_directories(
3838
${CMAKE_HOME_DIRECTORY}/
3939
)
4040

41-
SET( CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_HOME_DIRECTORY}/lib )
42-
SET( CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_HOME_DIRECTORY}/lib )
43-
SET( CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_HOME_DIRECTORY}/bin )
41+
SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_HOME_DIRECTORY}/lib )
42+
SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_HOME_DIRECTORY}/lib )
43+
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_HOME_DIRECTORY}/bin )
4444

4545
if( WIN32 AND NOT CYGWIN )
4646
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc" ) # Force to always compile with W4
@@ -56,24 +56,24 @@ elseif ( "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" )
5656
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wno-long-long -g -pedantic -std=c++11")
5757
endif()
5858

59-
IF (ASSIMP_ASAN)
59+
IF(CPPCORE_ASAN)
6060
MESSAGE(STATUS "AddressSanitizer enabled")
6161
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address")
6262
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address")
6363
ENDIF()
6464

65-
IF (ASSIMP_UBSAN)
65+
IF(CPPCORE_UBSAN)
6666
MESSAGE(STATUS "Undefined Behavior sanitizer enabled")
67-
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=undefined -fno-sanitize-recover=all")
68-
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=undefined -fno-sanitize-recover=all")
67+
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=undefined -fno-sanitize-recover=all")
68+
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=undefined -fno-sanitize-recover=all")
6969
ENDIF()
7070

71-
SET ( cppcore_src
71+
SET(cppcore_src
7272
code/cppcore.cpp
7373
include/cppcore/CPPCoreCommon.h
7474
)
7575

76-
SET ( cppcore_common_src
76+
SET(cppcore_common_src
7777
include/cppcore/Common/Hash.h
7878
include/cppcore/Common/TStringBase.h
7979
include/cppcore/Common/TStringView.h
@@ -83,12 +83,12 @@ SET ( cppcore_common_src
8383
include/cppcore/Common/TOptional.h
8484
)
8585

86-
SET( cppcore_random_src
86+
SET(cppcore_random_src
8787
include/cppcore/Random/RandomGenerator.h
8888
code/Random/RandomGenerator.cpp
8989
)
9090

91-
SET ( cppcore_container_src
91+
SET(cppcore_container_src
9292
include/cppcore/Container/THashMap.h
9393
include/cppcore/Container/TArray.h
9494
include/cppcore/Container/TStaticArray.h
@@ -97,7 +97,7 @@ SET ( cppcore_container_src
9797
include/cppcore/Container/TStaticArray.h
9898
)
9999

100-
SET ( cppcore_memory_src
100+
SET(cppcore_memory_src
101101
include/cppcore/Memory/MemUtils.h
102102
include/cppcore/Memory/TDefaultAllocator.h
103103
include/cppcore/Memory/TStackAllocator.h

include/cppcore/Common/TStringBase.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ inline TStringBase<T>::~TStringBase() {
8484

8585
template <class T>
8686
inline void TStringBase<T>::set(const T *ptr, size_t size) {
87-
void reset();
87+
reset();
8888
if (nullptr != ptr) {
8989
copyFrom(*this, ptr, size);
9090
}

include/cppcore/Common/TStringView.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class TStringView {
4040
TStringView(const T *ptr, size_t len);
4141
~TStringView() = default;
4242
size_t size() const;
43-
T *data() const;
43+
const T *data() const;
4444
bool isEmpty() const;
4545
const_iterator begin() const;
4646
const_iterator end() const;
@@ -63,7 +63,7 @@ inline size_t TStringView<T>::size() const {
6363
}
6464

6565
template <class T>
66-
inline T *TStringView<T>::data() const {
66+
inline const T *TStringView<T>::data() const {
6767
return mPtr;
6868
}
6969

test/common/HashTest.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,6 @@ using namespace cppcore;
3131
class HashTest : public testing::Test {
3232
public:
3333
using UiHash = THash<unsigned int>;
34-
35-
protected:
36-
// empty
3734
};
3835

3936
TEST_F( HashTest, CreateTest ) {

test/common/TOptionalTest.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,15 @@ using namespace ::cppcore;
2828
class TOptionalTest : public ::testing::Test {};
2929

3030
TEST_F(TOptionalTest, createInstance_success) {
31-
constexpr int ValInt = 1;
31+
constexpr int ValInt{1};
3232
TOptional<int> test_int(ValInt);
3333

3434
EXPECT_FALSE(test_int.isInited());
3535
test_int.set(1);
3636
EXPECT_TRUE(test_int.isInited());
3737
EXPECT_EQ(test_int.value(), ValInt);
3838

39-
constexpr float ValFloat = 1.0f;
39+
constexpr float ValFloat{1.0f};
4040
TOptional<float> test_float(ValFloat);
4141

4242
EXPECT_FALSE(test_float.isInited());

test/common/TStringViewTest.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ TEST_F(TStringViewTest, createTest) {
3434
using StringView = TStringView<char>;
3535

3636
StringView sv("this is a test", 14l);
37-
StringView::const_iterator start = sv.begin();
38-
StringView::const_iterator end = sv.end();
37+
auto start = sv.begin();
38+
auto end = sv.end();
3939

4040
size_t d = distance(start, end);
4141
EXPECT_EQ(d, 14);
@@ -46,7 +46,7 @@ TEST_F(TStringViewTest, iterateTest) {
4646
constexpr char tag[] = "this is a test";
4747
StringView sv(tag, 14l);
4848
size_t i{0};
49-
for (StringView::const_iterator it = sv.begin(); it != sv.end(); ++it) {
49+
for (auto it = sv.begin(); it != sv.end(); ++it) {
5050
EXPECT_EQ(tag[i++], *it);
5151
}
5252
}

0 commit comments

Comments
 (0)