diff --git a/.gitignore b/.gitignore index a962af0..9ae047a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,42 +1,140 @@ +# binaries +buffer_allocator_test +buffer_allocator_container_test + +# misc +*.log +*.trs +Makefile +.deps + +# Created by https://www.gitignore.io/api/vim,c++,gcov,valgrind,autotools +# Edit at https://www.gitignore.io/?templates=vim,c++,gcov,valgrind,autotools + +### Autotools ### +# http://www.gnu.org/software/automake + +Makefile.in +/ar-lib +/mdate-sh +/py-compile +/test-driver +/ylwrap + +# http://www.gnu.org/software/autoconf + +autom4te.cache +/autoscan.log +/autoscan-*.log +/aclocal.m4 +/compile +/config.guess +/config.h.in +/config.log +/config.status +/config.sub +/configure +/configure.scan +/depcomp +/install-sh +/missing +/stamp-h1 + +# https://www.gnu.org/software/libtool/ + +/ltmain.sh + +# http://www.gnu.org/software/texinfo + +/texinfo.tex + +# http://www.gnu.org/software/m4/ + +m4/libtool.m4 +m4/ltoptions.m4 +m4/ltsugar.m4 +m4/ltversion.m4 +m4/lt~obsolete.m4 + +### Autotools Patch ### + +### C++ ### +# Prerequisites +*.d + # Compiled Object files *.slo *.lo *.o +*.obj + +# Precompiled Headers +*.gch +*.pch # Compiled Dynamic libraries *.so *.dylib +*.dll + +# Fortran module files +*.mod +*.smod # Compiled Static libraries *.lai *.la *.a +*.lib -# Autotools files -*.in -config.h -config.h.* -autom4te.cache -aclocal.m4 -Makefile -.deps -configure -config.log -config.status -stamp-h1 -AUTHORS -ChangeLog -INSTALL -README -missing -install-sh -NEWS -depcomp -ltmain.sh - -# VIM -*.swp +# Executables +*.exe +*.out +*.app -# binaries -buffer_allocator_test -buffer_allocator_container_test +### Gcov ### +# gcc coverage testing tool files + +*.gcno +*.gcda +*.gcov + +### Valgrind ### +# Callgrind output files +callgrind.out +callgrind.out.* + +# Cachegrind output files +cachegrind.out +cachegrind.out.* + +# Massif output files +massif.out +massif.out.* + +# BBV output files +bb.out +bb.out.* + + + +### Vim ### +# Swap +[._]*.s[a-v][a-z] +[._]*.sw[a-p] +[._]s[a-rt-v][a-z] +[._]ss[a-gi-z] +[._]sw[a-p] + +# Session +Session.vim + +# Temporary +.netrwhist +*~ +# Auto-generated tag files +tags +# Persistent undo +[._]*.un~ + +# End of https://www.gitignore.io/api/vim,c++,gcov,valgrind,autotools diff --git a/.travis.yml b/.travis.yml index e1743e4..cef4592 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,7 +3,7 @@ language: cpp matrix: include: - os: linux - dist: trusty + dist: xenial compiler: gcc addons: apt: @@ -13,15 +13,15 @@ matrix: - automake - autoconf - cppcheck - - g++-4.9 + - g++-5 - libboost-test-dev - make - valgrind env: - - MATRIX_EVAL="CC=gcc-4.9 && CXX=g++-4.9" + - MATRIX_EVAL="CC=gcc-5 && CXX=g++-5" - os: linux - dist: trusty + dist: xenial compiler: gcc addons: apt: @@ -31,15 +31,15 @@ matrix: - automake - autoconf - cppcheck - - g++-5 + - g++-6 - libboost-test-dev - make - valgrind env: - - MATRIX_EVAL="CC=gcc-5 && CXX=g++-5" + - MATRIX_EVAL="CC=gcc-6 && CXX=g++-6" - os: linux - dist: trusty + dist: xenial compiler: gcc addons: apt: @@ -49,15 +49,15 @@ matrix: - automake - autoconf - cppcheck - - g++-6 + - g++-7 - libboost-test-dev - make - valgrind env: - - MATRIX_EVAL="CC=gcc-6 && CXX=g++-6" + - MATRIX_EVAL="CC=gcc-7 && CXX=g++-7" - os: linux - dist: trusty + dist: xenial compiler: gcc addons: apt: @@ -67,145 +67,145 @@ matrix: - automake - autoconf - cppcheck - - g++-7 + - g++-8 - libboost-test-dev - make - valgrind env: - - MATRIX_EVAL="CC=gcc-7 && CXX=g++-7" + - MATRIX_EVAL="CC=gcc-8 && CXX=g++-8" - os: linux - dist: trusty + dist: xenial compiler: clang addons: apt: sources: - ubuntu-toolchain-r-test - - llvm-toolchain-trusty-3.5 + - llvm-toolchain-xenial-3.8 packages: - automake - autoconf - - clang-3.5 + - clang-3.8 - cppcheck - libboost-test-dev - make - valgrind env: - - MATRIX_EVAL="CC=clang-3.5 && CXX=clang++-3.5" + - MATRIX_EVAL="CC=clang-3.8 && CXX=clang++-3.8" - os: linux - dist: trusty + dist: xenial compiler: clang addons: apt: sources: - ubuntu-toolchain-r-test - - llvm-toolchain-trusty-3.6 + - llvm-toolchain-xenial-3.9 packages: - automake - autoconf - - clang-3.6 + - clang-3.9 - cppcheck - libboost-test-dev - make - valgrind env: - - MATRIX_EVAL="CC=clang-3.6 && CXX=clang++-3.6" + - MATRIX_EVAL="CC=clang && CXX=clang++" - os: linux - dist: trusty + dist: xenial compiler: clang addons: apt: sources: - ubuntu-toolchain-r-test - - llvm-toolchain-precise-3.7 + - llvm-toolchain-xenial-4.0 packages: - automake - autoconf - - clang-3.7 + - clang-4.0 - cppcheck - libboost-test-dev - make - valgrind env: - - MATRIX_EVAL="CC=clang-3.7 && CXX=clang++-3.7" + - MATRIX_EVAL="CC=clang-4.0 && CXX=clang++-4.0" - os: linux - dist: trusty + dist: xenial compiler: clang addons: apt: sources: - ubuntu-toolchain-r-test - - llvm-toolchain-trusty-3.8 + - llvm-toolchain-xenial-5.0 packages: - automake - autoconf - - clang-3.8 + - clang-5.0 - cppcheck - libboost-test-dev - make - valgrind env: - - MATRIX_EVAL="CC=clang-3.8 && CXX=clang++-3.8" + - MATRIX_EVAL="CC=clang-5.0 && CXX=clang++-5.0" - os: linux - dist: trusty + dist: xenial compiler: clang addons: apt: sources: - ubuntu-toolchain-r-test - - llvm-toolchain-trusty-3.9 + - llvm-toolchain-xenial-6.0 packages: - automake - autoconf - - clang-3.9 + - clang-6.0 - cppcheck - libboost-test-dev - make - valgrind env: - - MATRIX_EVAL="CC=clang && CXX=clang++" + - MATRIX_EVAL="CC=clang-6.0 && CXX=clang++-6.0" - os: linux - dist: trusty + dist: xenial compiler: clang addons: apt: sources: - ubuntu-toolchain-r-test - - llvm-toolchain-trusty-4.0 + - llvm-toolchain-xenial-7 packages: - automake - autoconf - - clang-4.0 + - clang-7 - cppcheck - libboost-test-dev - make - valgrind env: - - MATRIX_EVAL="CC=clang-4.0 && CXX=clang++-4.0" + - MATRIX_EVAL="CC=clang-7 && CXX=clang++-7" - os: linux - dist: trusty + dist: xenial compiler: clang addons: apt: sources: - ubuntu-toolchain-r-test - - llvm-toolchain-trusty-5.0 + - llvm-toolchain-xenial-8 packages: - automake - autoconf - - clang-5.0 + - clang-8 - cppcheck - libboost-test-dev - make - valgrind env: - - MATRIX_EVAL="CC=clang-5.0 && CXX=clang++-5.0" + - MATRIX_EVAL="CC=clang-8 && CXX=clang++-8" before_install: - eval "${MATRIX_EVAL}" @@ -219,6 +219,7 @@ script: - ./configure - make - make check +- ${CXX} --version after_success: - if [[ "${CXX}" == "g++" ]]; then diff --git a/src/buffer_allocator_container_test.cpp b/src/buffer_allocator_container_test.cpp index 122bb4e..f2e6963 100644 --- a/src/buffer_allocator_container_test.cpp +++ b/src/buffer_allocator_container_test.cpp @@ -127,14 +127,15 @@ BOOST_AUTO_TEST_CASE( stl_string_copy ) BOOST_REQUIRE_EQUAL(str1, str2); BOOST_REQUIRE_EQUAL(str1, "Hello, world!"); BOOST_REQUIRE_EQUAL(str2, "Hello, world!"); - // basic_strings are reference-counted, so even after str1 is cleared, str2 - // will still hold the value but pointing to str1's buffer1. If we messed - // with str1's underlying buffer1, str2 will see the value and gets screwed. + + // basic_string used to be reference-counted and copies on + // write, but it seem like the behavior changed. str1.clear(); memset(buffer1, 0, sizeof(buffer1)); BOOST_REQUIRE(str1.empty()); - BOOST_REQUIRE_EQUAL(str2.length(), 0); - BOOST_REQUIRE_NE(str2, "Hello, world!"); + BOOST_REQUIRE_EQUAL(str1.length(), 0); + BOOST_REQUIRE_EQUAL(str2.length(), strlen("Hello, world!")); + BOOST_REQUIRE_EQUAL(str2, "Hello, world!"); // basic_string copies on write, if we changed str2, it would stop using // str1's buffer1 and uses its own buffer2.