Skip to content

Commit

Permalink
style: pre-commit.ci fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
pre-commit-ci[bot] committed Jul 27, 2024
1 parent 7795d8a commit 58c0dd9
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 111 deletions.
4 changes: 2 additions & 2 deletions fuzz/cli11_app_fuzz.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
150 changes: 52 additions & 98 deletions fuzz/fuzzApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,191 +149,145 @@ std::shared_ptr<CLI::App> 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;
Expand Down
4 changes: 2 additions & 2 deletions include/CLI/impl/StringTools_inl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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\"(");
Expand Down
5 changes: 2 additions & 3 deletions tests/AppTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
7 changes: 3 additions & 4 deletions tests/FuzzFailTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
1 change: 0 additions & 1 deletion tests/HelpersTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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]") {
Expand Down
1 change: 0 additions & 1 deletion tests/SubcommandTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2143,4 +2143,3 @@ TEST_CASE_METHOD(TApp, "subcommandEnvironmentName", "[subcom]") {
CHECK_THROWS_AS(run(), CLI::RequiredError);
unset_env("SOME_FILE");
}

0 comments on commit 58c0dd9

Please sign in to comment.