Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #445. Testing the behavior of the strncasecmp_custom function. #454

Merged
merged 3 commits into from
Oct 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/strhelper.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,11 @@ strncasecmp_custom( const char *s1, const char *s2, size_t n ) {
if (n != 0) {
do {
if (tolower(*s1) != tolower(*s2++))
return tolower(*s1) - tolower(*--s2);
return tolower(*--s2) - tolower(*s1);
if (*s1++ == '\0')
break;
} while (--n != 0);
if(*s2 != '\0') return tolower(*s2) - tolower(*s1);
}
return 0;
}
}
24 changes: 24 additions & 0 deletions test/function/severity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,4 +113,28 @@ namespace {
EXPECT_EQ( result, -1 );
}

TEST( GetSeverityEnumFromBuffer, IncompleteSeverity ) {
enum stumpless_severity result = stumpless_get_severity_enum( "war" );
EXPECT_EQ( result, -1 );

result = stumpless_get_severity_enum( "not" );
EXPECT_EQ( result, -1 );
}


TEST( GetSeverityEnumFromBuffer, OverextendedSeverity ) {
enum stumpless_severity result = stumpless_get_severity_enum( "warnings are neat" );
EXPECT_EQ( result, -1 );

result = stumpless_get_severity_enum( "notices are bad" );
EXPECT_EQ( result, -1 );

result = stumpless_get_severity_enum( "panic you should not" );
EXPECT_EQ( result, -1 );

}




}
Loading