Skip to content

Commit 1234e46

Browse files
committed
refactor tests
1 parent 24bcf72 commit 1234e46

File tree

3 files changed

+17
-36
lines changed

3 files changed

+17
-36
lines changed

CMakeLists.txt

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,19 @@ else()
99
set(CMAKE_CXX_STANDARD 17)
1010
endif()
1111

12+
# Add Google Test
13+
# Include FetchContent to download and manage external dependencies
14+
include(FetchContent)
15+
FetchContent_Declare(
16+
googletest
17+
URL https://github.com/google/googletest/archive/refs/tags/release-1.11.0.zip
18+
)
19+
FetchContent_MakeAvailable(googletest)
1220

13-
add_executable(RingBufferTest main.cpp)
21+
enable_testing()
22+
add_executable(RingBufferTest test_main.cpp)
23+
target_link_libraries(RingBufferTest gtest gtest_main)
24+
25+
26+
include(GoogleTest)
27+
gtest_discover_tests(RingBufferTest)

RingBuffer.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ namespace buffers {
3838
using iterator_category = std::forward_iterator_tag;
3939

4040
ring_buffer_iterator() noexcept = default;
41+
4142
ring_buffer_iterator(buffer_t source, size_type index, size_type count) noexcept
4243
: source_{source},
4344
index_{index},
@@ -181,6 +182,7 @@ using std::bool_constant;
181182
[[nodiscard]] const_iterator cend() const noexcept { return const_iterator{this, head_, size_};}
182183
[[nodiscard]] bool empty() const noexcept { return size_ == 0; }
183184
[[nodiscard]] bool full() const noexcept { return size_ == N; }
185+
[[nodiscard]] size_type size() const noexcept { return size_; }
184186
[[nodiscard]] size_type capacity() const noexcept { return N; }
185187
void clear() noexcept{
186188
destroy_all(bool_constant<is_trivially_destructible_v<value_type>>{});

main.cpp

Lines changed: 0 additions & 35 deletions
This file was deleted.

0 commit comments

Comments
 (0)