From 58c0dd9c2c0a34db58b37bbcabb2bc5c1ce84c6c Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sat, 27 Jul 2024 20:25:56 +0000 Subject: [PATCH] style: pre-commit.ci fixes --- fuzz/cli11_app_fuzz.cpp | 4 +- fuzz/fuzzApp.cpp | 150 ++++++++++----------------- include/CLI/impl/StringTools_inl.hpp | 4 +- tests/AppTest.cpp | 5 +- tests/FuzzFailTest.cpp | 7 +- tests/HelpersTest.cpp | 1 - tests/SubcommandTest.cpp | 1 - 7 files changed, 61 insertions(+), 111 deletions(-) diff --git a/fuzz/cli11_app_fuzz.cpp b/fuzz/cli11_app_fuzz.cpp index 8064b545c..becf272ca 100644 --- a/fuzz/cli11_app_fuzz.cpp +++ b/fuzz/cli11_app_fuzz.cpp @@ -55,8 +55,8 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) { app->clear(); std::stringstream out(configOut); app2->parse_from_stream(out); - auto result=fuzzdata2.compare(fuzzdata); - if (!result) { + auto result = fuzzdata2.compare(fuzzdata); + if(!result) { throw CLI::ParseError("file input doesn't match"); } return 0; diff --git a/fuzz/fuzzApp.cpp b/fuzz/fuzzApp.cpp index ed3baedf2..3a7307496 100644 --- a/fuzz/fuzzApp.cpp +++ b/fuzz/fuzzApp.cpp @@ -149,191 +149,145 @@ std::shared_ptr FuzzApp::generateApp() { return fApp; } - -bool FuzzApp::compare(const FuzzApp& other) const -{ - if (val32 != other.val32) - { +bool FuzzApp::compare(const FuzzApp &other) const { + if(val32 != other.val32) { return false; } - if (val16 != other.val16) - { - return false; - } - if (val8 != other.val8) - { - return false; - } - if (val64 != other.val64) - { + if(val16 != other.val16) { + return false; + } + if(val8 != other.val8) { + return false; + } + if(val64 != other.val64) { return false; } - if (uval32 != other.uval32) - { + if(uval32 != other.uval32) { return false; } - if (uval16 != other.uval16) - { + if(uval16 != other.uval16) { return false; } - if (uval8 != other.uval8) - { + if(uval8 != other.uval8) { return false; } - if (uval64 != other.uval64) - { + if(uval64 != other.uval64) { return false; } - if (atomicval64 != other.atomicval64) - { + if(atomicval64 != other.atomicval64) { return false; } - if (atomicuval64 != other.atomicuval64) - { + if(atomicuval64 != other.atomicuval64) { return false; } - if (v1 != other.v1) - { + if(v1 != other.v1) { return false; } - if (v2 != other.v2) - { + if(v2 != other.v2) { return false; } - if (vv1 != other.vv1) - { + if(vv1 != other.vv1) { return false; } - if (vstr != other.vstr) - { + if(vstr != other.vstr) { return false; } - if (vecvecd != other.vecvecd) - { + if(vecvecd != other.vecvecd) { return false; } - if (vvs != other.vvs) - { + if(vvs != other.vvs) { return false; } - if (od1 != other.od1) - { + if(od1 != other.od1) { return false; } - if (ods != other.ods) - { + if(ods != other.ods) { return false; } - if (p1 != other.p1) - { + if(p1 != other.p1) { return false; } - if (p2 != other.p2) - { + if(p2 != other.p2) { return false; } - if (t1 != other.t1) - { + if(t1 != other.t1) { return false; } - if ( tcomplex != other.tcomplex) - { - return false; + if(tcomplex != other.tcomplex) { + return false; } - if (tcomplex2 != other.tcomplex2) - { - return false; + if(tcomplex2 != other.tcomplex2) { + return false; } - if (vectup != other.vectup) - { + if(vectup != other.vectup) { return false; } - if (vstrv != other.vstrv) - { + if(vstrv != other.vstrv) { return false; } - if (flag1 != other.flag1) - { + if(flag1 != other.flag1) { return false; } - if (flagCnt != other.flagCnt) - { + if(flagCnt != other.flagCnt) { return false; } - if (flagAtomic != other.flagAtomic) - { + if(flagAtomic != other.flagAtomic) { return false; } - if (iwrap.value() != other.iwrap.value()) - { + if(iwrap.value() != other.iwrap.value()) { return false; } - if (dwrap.value() != other.dwrap.value()) - { + if(dwrap.value() != other.dwrap.value()) { return false; } - if (swrap.value() != other.swrap.value()) - { + if(swrap.value() != other.swrap.value()) { return false; } - if (buffer != other.buffer) - { + if(buffer != other.buffer) { return false; } - if (intbuffer != other.intbuffer) - { + if(intbuffer != other.intbuffer) { return false; } - if (doubleAtomic != other.doubleAtomic) - { + if(doubleAtomic != other.doubleAtomic) { return false; } // for testing restrictions and reduction methods - if (vstrA != other.vstrA ) - { + if(vstrA != other.vstrA) { return false; } - if ( vstrB != other. vstrB) - { + if(vstrB != other.vstrB) { return false; } - if ( vstrC != other. vstrC) - { + if(vstrC != other.vstrC) { return false; } - if (vstrD != other.vstrD) - { + if(vstrD != other.vstrD) { // the return result if reversed so it can alternate - auto res=vstrD; - std::reverse(res.begin(),res.end()); - if (res != other.vstrD) - { + auto res = vstrD; + std::reverse(res.begin(), res.end()); + if(res != other.vstrD) { return false; } - } - if (vstrE != other.vstrE) - { + if(vstrE != other.vstrE) { return false; } - if (vstrF != other.vstrF) - { + if(vstrF != other.vstrF) { return false; } - if (mergeBuffer != other.mergeBuffer) - { + if(mergeBuffer != other.mergeBuffer) { return false; } - if (validator_strings != other.validator_strings) - { + if(validator_strings != other.validator_strings) { return false; } return true; diff --git a/include/CLI/impl/StringTools_inl.hpp b/include/CLI/impl/StringTools_inl.hpp index 1fb9006d1..e3775619b 100644 --- a/include/CLI/impl/StringTools_inl.hpp +++ b/include/CLI/impl/StringTools_inl.hpp @@ -459,8 +459,8 @@ CLI11_INLINE std::string binary_escape_string(const std::string &string_to_escap if(escaped_string != string_to_escape) { auto sqLoc = escaped_string.find('\''); while(sqLoc != std::string::npos) { - escaped_string[sqLoc]='\\'; - escaped_string.insert(sqLoc+1,"x27"); + escaped_string[sqLoc] = '\\'; + escaped_string.insert(sqLoc + 1, "x27"); sqLoc = escaped_string.find('\''); } escaped_string.insert(0, "'B\"("); diff --git a/tests/AppTest.cpp b/tests/AppTest.cpp index d224fbc77..519f05c3a 100644 --- a/tests/AppTest.cpp +++ b/tests/AppTest.cpp @@ -2073,18 +2073,17 @@ TEST_CASE_METHOD(TApp, "EnvOnly", "[app]") { } // reported bug #1013 on github -TEST_CASE_METHOD(TApp,"groupEnvRequired", "[app]") { +TEST_CASE_METHOD(TApp, "groupEnvRequired", "[app]") { std::string str; auto group1 = app.add_option_group("group1"); put_env("CLI11_TEST_GROUP_REQUIRED", "string_abc"); group1->add_option("-f", str, "f")->envname("CLI11_TEST_GROUP_REQUIRED")->required(); run(); - CHECK(str=="string_abc"); + CHECK(str == "string_abc"); unset_env("CLI11_TEST_GROUP_REQUIRED"); } - TEST_CASE_METHOD(TApp, "RangeInt", "[app]") { int x{0}; app.add_option("--one", x)->check(CLI::Range(3, 6)); diff --git a/tests/FuzzFailTest.cpp b/tests/FuzzFailTest.cpp index 8f8228f75..655e11d2d 100644 --- a/tests/FuzzFailTest.cpp +++ b/tests/FuzzFailTest.cpp @@ -137,11 +137,10 @@ TEST_CASE("app_file_roundtrip") { std::string configOut = app->config_to_str(); std::stringstream out(configOut); app2->parse_from_stream(out); - bool result=fuzzdata2.compare(fuzzdata); - if (!result) - { + bool result = fuzzdata2.compare(fuzzdata); + if(!result) { std::string configOut = app->config_to_str(); - result=fuzzdata2.compare(fuzzdata); + result = fuzzdata2.compare(fuzzdata); } CHECK(result); } diff --git a/tests/HelpersTest.cpp b/tests/HelpersTest.cpp index c84af58e4..f67037e94 100644 --- a/tests/HelpersTest.cpp +++ b/tests/HelpersTest.cpp @@ -287,7 +287,6 @@ TEST_CASE("StringTools: binaryEscapseConversion2", "[helpers]") { CHECK(CLI::detail::is_binary_escaped_string(estring)); std::string rstring = CLI::detail::extract_binary_string(estring); CHECK(rstring == testString); - } TEST_CASE("StringTools: binaryStrings", "[helpers]") { diff --git a/tests/SubcommandTest.cpp b/tests/SubcommandTest.cpp index e98fb3291..f64f04b93 100644 --- a/tests/SubcommandTest.cpp +++ b/tests/SubcommandTest.cpp @@ -2143,4 +2143,3 @@ TEST_CASE_METHOD(TApp, "subcommandEnvironmentName", "[subcom]") { CHECK_THROWS_AS(run(), CLI::RequiredError); unset_env("SOME_FILE"); } -