From 636882316b5191931e144212d93665c10859ac95 Mon Sep 17 00:00:00 2001 From: Steven Le Rouzic Date: Fri, 7 Mar 2025 00:00:43 +0100 Subject: Some work on clang-tidy-ing things up --- asl/hashing/hash.hpp | 2 +- asl/hashing/hash_tests.cpp | 57 +++++++++++++++++++++++----------------------- 2 files changed, 30 insertions(+), 29 deletions(-) (limited to 'asl/hashing') diff --git a/asl/hashing/hash.hpp b/asl/hashing/hash.hpp index 443a774..f8987df 100644 --- a/asl/hashing/hash.hpp +++ b/asl/hashing/hash.hpp @@ -80,7 +80,7 @@ struct HashState { auto bytes = as_bytes(s); auto hashed = city_hash::CityHash128WithSeed( - reinterpret_cast(bytes.data()), + reinterpret_cast(bytes.data()), // NOLINT(*-reinterpret-cast) static_cast(bytes.size()), h.state); return HashState{hashed}; diff --git a/asl/hashing/hash_tests.cpp b/asl/hashing/hash_tests.cpp index e4e69bf..4cb2f6e 100644 --- a/asl/hashing/hash_tests.cpp +++ b/asl/hashing/hash_tests.cpp @@ -29,10 +29,10 @@ static_assert(asl::hashable); ASL_TEST(integers) { - uint64_t a = asl::hash_value(45); - uint64_t b = asl::hash_value(45); - uint64_t c = asl::hash_value(46); - uint64_t d = asl::hash_value(45); + const uint64_t a = asl::hash_value(45); + const uint64_t b = asl::hash_value(45); + const uint64_t c = asl::hash_value(46); + const uint64_t d = asl::hash_value(45); ASL_TEST_EXPECT(a == b); ASL_TEST_EXPECT(a != c); @@ -187,19 +187,19 @@ static_assert(asl::uniquely_represented>); ASL_TEST(option) { - asl::option int1 = 0; - asl::option int2 = 0; - asl::option int3 = 1; - asl::option int4 = asl::nullopt; + const asl::option int1 = 0; + const asl::option int2 = 0; + const asl::option int3 = 1; + const asl::option int4 = asl::nullopt; ASL_TEST_EXPECT(asl::hash_value(int1) == asl::hash_value(int2)); ASL_TEST_EXPECT(asl::hash_value(int1) != asl::hash_value(int3)); ASL_TEST_EXPECT(asl::hash_value(int1) != asl::hash_value(int4)); - asl::option noz1{8}; - asl::option noz2{8}; - asl::option noz3{9}; - asl::option noz4 = asl::nullopt; + const asl::option noz1{8}; + const asl::option noz2{8}; + const asl::option noz3{9}; + const asl::option noz4 = asl::nullopt; ASL_TEST_EXPECT(asl::hash_value(noz1) == asl::hash_value(noz2)); ASL_TEST_EXPECT(asl::hash_value(noz1) != asl::hash_value(noz3)); @@ -208,17 +208,18 @@ ASL_TEST(option) static_assert(asl::hashable); +// NOLINTNEXTLINE(*-cognitive-complexity) ASL_TEST(status) { - asl::status s1 = asl::ok(); - asl::status s2 = asl::ok(); - asl::status s3 = asl::internal_error(); - asl::status s4 = asl::internal_error(); - asl::status s5 = asl::runtime_error(); - asl::status s6 = asl::internal_error("Oh, no!"); - asl::status s7 = asl::internal_error("Oh, no!"); - asl::status s8 = asl::internal_error("Oh, no"); - asl::status s9 = asl::runtime_error("Oh, no!"); + const asl::status s1 = asl::ok(); + const asl::status s2 = asl::ok(); + const asl::status s3 = asl::internal_error(); + const asl::status s4 = asl::internal_error(); + const asl::status s5 = asl::runtime_error(); + const asl::status s6 = asl::internal_error("Oh, no!"); + const asl::status s7 = asl::internal_error("Oh, no!"); + const asl::status s8 = asl::internal_error("Oh, no"); + const asl::status s9 = asl::runtime_error("Oh, no!"); ASL_TEST_EXPECT(asl::hash_value(s1) == asl::hash_value(s2)); ASL_TEST_EXPECT(asl::hash_value(s3) == asl::hash_value(s4)); @@ -244,13 +245,13 @@ static_assert(!asl::hashable>); ASL_TEST(status_or) { - asl::status_or s1 = 42; - asl::status_or s2 = 42; - asl::status_or s3 = 43; - asl::status_or s4 = asl::runtime_error(); - asl::status_or s5 = asl::runtime_error(); - asl::status_or s6 = asl::runtime_error("Hello"); - asl::status_or s7 = asl::runtime_error("Hello"); + const asl::status_or s1 = 42; + const asl::status_or s2 = 42; + const asl::status_or s3 = 43; + const asl::status_or s4 = asl::runtime_error(); + const asl::status_or s5 = asl::runtime_error(); + const asl::status_or s6 = asl::runtime_error("Hello"); + const asl::status_or s7 = asl::runtime_error("Hello"); ASL_TEST_EXPECT(asl::hash_value(s1) == asl::hash_value(s2)); ASL_TEST_EXPECT(asl::hash_value(s4) == asl::hash_value(s5)); -- cgit