Skip to content

Commit 74097fe

Browse files
author
Gonzalo Diaz
committed
[Hacker Rank] Warmup: Time Conversion solved ✅. Triying to fix sonarlint detected issues.
1 parent 661f6ec commit 74097fe

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

src/lib/exercises/src/hackerrank/warmup/time_conversion.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@
99
#include <string.h>
1010

1111
char *HACKERRANK_WARMUP_firstN(const char *s, unsigned long n) {
12+
if (s == NULL) {
13+
return NULL;
14+
}
15+
1216
unsigned long len = strlen(s);
1317
if (n > len) {
1418
return NULL;

src/tests/unit/lib/hackerrank/warmup/time_conversion.test.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ TEST_CASE("time_conversion JSON Test Cases",
3434

3535
TEST_CASE("time_conversion helper functions edge cases",
3636
"[hackerrank] [helper] [warmup]") {
37+
CHECK(HACKERRANK_WARMUP_firstN(nullptr, 0) == nullptr);
38+
3739
CHECK(HACKERRANK_WARMUP_firstN("", 10) == nullptr);
3840
CHECK(HACKERRANK_WARMUP_lastN("", 10) == nullptr);
3941

0 commit comments

Comments
 (0)