Skip to content

Commit afc38f2

Browse files
committed
test: Add more unit tests for add_to_list.
1 parent 05ce5c1 commit afc38f2

27 files changed

+630
-72
lines changed

.circleci/config.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ jobs:
6868
cmake
6969
git
7070
libconfig-dev
71+
libgmock-dev
7172
libgtest-dev
7273
libopus-dev
7374
libsodium-dev

.github/scripts/coverage-linux

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ set -eu
55
NPROC=$(nproc)
66

77
sudo apt-get install -y --no-install-recommends \
8+
libgmock-dev \
89
libgtest-dev \
910
libopus-dev \
1011
libsodium-dev \

CMakeLists.txt

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -477,14 +477,25 @@ install_module(toxcore DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/tox)
477477
#
478478
################################################################################
479479

480+
add_library(test_util STATIC
481+
toxcore/DHT_test_util.cc
482+
toxcore/DHT_test_util.hh
483+
toxcore/crypto_core_test_util.cc
484+
toxcore/crypto_core_test_util.hh
485+
toxcore/network_test_util.cc
486+
toxcore/network_test_util.hh
487+
toxcore/test_util.cc
488+
toxcore/test_util.hh)
489+
480490
function(unit_test subdir target)
481491
add_executable(unit_${target}_test ${subdir}/${target}_test.cc)
492+
target_link_libraries(unit_${target}_test PRIVATE test_util)
482493
if(TARGET toxcore_static)
483494
target_link_libraries(unit_${target}_test PRIVATE toxcore_static)
484495
else()
485496
target_link_libraries(unit_${target}_test PRIVATE toxcore_shared)
486497
endif()
487-
target_link_libraries(unit_${target}_test PRIVATE GTest::GTest GTest::Main)
498+
target_link_libraries(unit_${target}_test PRIVATE GTest::gtest GTest::gtest_main GTest::gmock)
488499
set_target_properties(unit_${target}_test PROPERTIES COMPILE_FLAGS "${TEST_CXX_FLAGS}")
489500
add_test(NAME ${target} COMMAND ${CROSSCOMPILING_EMULATOR} unit_${target}_test)
490501
set_property(TEST ${target} PROPERTY ENVIRONMENT "LLVM_PROFILE_FILE=${target}.profraw")
@@ -504,6 +515,7 @@ if(GTEST_FOUND)
504515
unit_test(toxcore mem)
505516
unit_test(toxcore mono_time)
506517
unit_test(toxcore ping_array)
518+
unit_test(toxcore test_util)
507519
unit_test(toxcore tox)
508520
unit_test(toxcore util)
509521
endif()

other/analysis/gen-file.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ CPPFLAGS+=("-Itoxav")
1515
CPPFLAGS+=("-Itoxencryptsave")
1616
CPPFLAGS+=("-Ithird_party/cmp")
1717

18-
LDFLAGS=("-lopus" "-lsodium" "-lvpx" "-lpthread" "-lconfig" "-lgtest")
18+
LDFLAGS=("-lopus" "-lsodium" "-lvpx" "-lpthread" "-lconfig" "-lgmock" "-lgtest")
1919
LDFLAGS+=("-fuse-ld=gold")
2020
LDFLAGS+=("-Wl,--detect-odr-violations")
2121
LDFLAGS+=("-Wl,--warn-common")

other/analysis/run-clang

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ run() {
1010
"${CPPFLAGS[@]}" \
1111
"${LDFLAGS[@]}" \
1212
"$@" \
13-
-std=c++11 \
13+
-std=c++17 \
1414
-Werror \
1515
-Weverything \
1616
-Wno-alloca \

other/analysis/run-clang-analyze

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ run() {
99
clang++ --analyze amalgamation.cc \
1010
"${CPPFLAGS[@]}" \
1111
"$@" \
12-
-std=c++11
12+
-std=c++20
1313
}
1414

1515
. other/analysis/variants.sh

other/analysis/run-cppcheck

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ CPPCHECK_CXX+=("--suppress=AssignmentAddressToInteger")
3434
CPPCHECK_CXX+=("--suppress=cstyleCast")
3535
# Used in Messenger.c for a static_assert(...)
3636
CPPCHECK_CXX+=("--suppress=sizeofFunctionCall")
37+
# This is outdated. Range-for is a good choice.
38+
CPPCHECK_CXX+=("--suppress=useStlAlgorithm")
3739

3840
run() {
3941
echo "Running cppcheck in variant '$*'"

other/analysis/run-gcc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ run() {
1111
"${CPPFLAGS[@]}" \
1212
"${LDFLAGS[@]}" \
1313
"$@" \
14-
-std=c++11 \
14+
-std=c++17 \
1515
-fdiagnostics-color=always \
1616
-Wall \
1717
-Wextra \
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
870f1e19aa3f3f802c7e53af3848df6a0f7af9ad4c98213aa1578fa325b30fad /usr/local/bin/tox-bootstrapd
1+
bc830120a87517f830eb85494b769c523bd1696328938d46e9eac1eefea61d38 /usr/local/bin/tox-bootstrapd

other/docker/circleci/Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ RUN apt-get update && \
77
clang \
88
cmake \
99
libconfig-dev \
10+
libgmock-dev \
1011
libgtest-dev \
1112
libopus-dev \
1213
libsodium-dev \

0 commit comments

Comments
 (0)