From: Joel Rosdahl Date: Sun, 19 Dec 2021 20:11:49 +0000 (+0100) Subject: style: Add some comments and tweaks X-Git-Tag: v4.6~59 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1045a6f043b09317014c2ec35f8d0734ac524378;p=thirdparty%2Fccache.git style: Add some comments and tweaks --- diff --git a/test/suites/secondary_file.bash b/test/suites/secondary_file.bash index 3ab48f973..0878a0ffd 100644 --- a/test/suites/secondary_file.bash +++ b/test/suites/secondary_file.bash @@ -12,6 +12,7 @@ SUITE_secondary_file() { # ------------------------------------------------------------------------- TEST "Base case" + # Compile and send result to primary and secondary storage. $CCACHE_COMPILE -c test.c expect_stat direct_cache_hit 0 expect_stat cache_miss 1 @@ -27,6 +28,7 @@ SUITE_secondary_file() { fi expect_file_count 3 '*' secondary # CACHEDIR.TAG + result + manifest + # Get result from primary storage. $CCACHE_COMPILE -c test.c expect_stat direct_cache_hit 1 expect_stat cache_miss 1 @@ -37,10 +39,12 @@ SUITE_secondary_file() { expect_stat files_in_cache 2 expect_file_count 3 '*' secondary # CACHEDIR.TAG + result + manifest + # Clear primary storage. $CCACHE -C >/dev/null expect_stat files_in_cache 0 expect_file_count 3 '*' secondary # CACHEDIR.TAG + result + manifest + # Get result from secondary storage, copying it to primary storage. $CCACHE_COMPILE -c test.c expect_stat direct_cache_hit 2 expect_stat cache_miss 1 @@ -51,6 +55,7 @@ SUITE_secondary_file() { expect_stat files_in_cache 2 # fetched from secondary expect_file_count 3 '*' secondary # CACHEDIR.TAG + result + manifest + # Get result from primary storage again. $CCACHE_COMPILE -c test.c expect_stat direct_cache_hit 3 expect_stat cache_miss 1 @@ -60,6 +65,7 @@ SUITE_secondary_file() { expect_stat secondary_storage_miss 2 # result + manifest expect_stat files_in_cache 2 # fetched from secondary expect_file_count 3 '*' secondary # CACHEDIR.TAG + result + manifest + # ------------------------------------------------------------------------- TEST "Flat layout" diff --git a/unittest/test_Util.cpp b/unittest/test_Util.cpp index 218927278..f2398c4fb 100644 --- a/unittest/test_Util.cpp +++ b/unittest/test_Util.cpp @@ -651,23 +651,20 @@ TEST_CASE("Util::read_file and Util::write_file") "No such file or directory"); } -TEST_CASE( - "Util::read_file, Util::write_file and Util::copy_file with binary files") +TEST_CASE("Util::{read,write,copy}_file with binary files") { TestContext test_context; - std::string origin_data; - for (int i = 0; i < 512; i++) { - origin_data.push_back(static_cast((32 + i) % 256)); + std::string data; + for (size_t i = 0; i < 512; ++i) { + data.push_back(static_cast((32 + i) % 256)); } - Util::write_file("test", origin_data, std::ios_base::binary); - std::string data = Util::read_file("test"); - CHECK(data == origin_data); + Util::write_file("test", data); + CHECK(Util::read_file("test") == data); Util::copy_file("test", "copy"); - data = Util::read_file("copy"); - CHECK(data == origin_data); + CHECK(Util::read_file("copy") == data); } TEST_CASE("Util::remove_extension")