Skip to content
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
46 changes: 23 additions & 23 deletions Dockerfile.debian
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ SHELL ["/bin/bash", "-o", "pipefail", "-c"]

RUN apt-get update \
&& apt-get -y install --no-install-recommends --no-install-suggests \
## common permanent packages
"make=4.4.1-2" \
## common permanent packages
"make=4.4.1-2" \
&& rm -rf /var/lib/apt/lists/*

COPY ./Makefile ${WORKDIR}/
Expand All @@ -20,14 +20,14 @@ ARG CMAKE_VERSION=4.4.3
RUN apt-get update \
&& apt-get -y install --no-install-recommends --no-install-suggests \
## common permanent packages
"ca-certificates=20250419" \
"ca-certificates=20250419" \
## add ephemeral packages
"curl=8.14.1-2+deb13u5" \
"curl=8.14.1-2+deb13u7" \
# CMAKE from Kitware repository
&& curl -fsSLH "Cache-Control: no-cache" --proto "=https" \
"https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/cmake-${CMAKE_VERSION}-linux-x86_64.tar.gz" \
| tar -xz --strip-components=1 -C /usr/local \
&& cmake --version \
&& curl -fsSLH "Cache-Control: no-cache" --proto "=https" \
"https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/cmake-${CMAKE_VERSION}-linux-x86_64.tar.gz" \
| tar -xz --strip-components=1 -C /usr/local \
&& cmake --version \
## remove ephemeral packages
&& apt-get -y autoremove curl \
## clean up
Expand All @@ -41,10 +41,10 @@ ENV GENERATE_ASM=${GENERATE_ASM}
# # build tools
RUN apt-get update \
&& apt-get -y install --no-install-recommends --no-install-suggests \
"build-essential=12.12" \
"g++=4:14.2.0-1" \
"gcc=4:14.2.0-1" \
"pkg-config=1.8.1-4" \
"build-essential=12.12" \
"g++=4:14.2.0-1" \
"gcc=4:14.2.0-1" \
"pkg-config=1.8.1-4" \
## clean up
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* \
Expand All @@ -62,12 +62,12 @@ ENV VCPKG_ROOT=/opt/vcpkg
# vcpkg Package Manager
RUN apt-get -y update \
&& apt-get -y install --no-install-recommends --no-install-suggests \
"curl=8.14.1-2+deb13u5" \
"git=1:2.47.3-0+deb13u1" \
"ninja-build=1.12.1-1" \
"patchelf=0.18.0-1.4" \
"unzip=6.0-29+deb13u1" \
"zip=3.0-15+deb13u1" \
"curl=8.14.1-2+deb13u7" \
"git=1:2.47.3-0+deb13u1" \
"ninja-build=1.12.1-1" \
"patchelf=0.18.0-1.4" \
"unzip=6.0-29+deb13u1" \
"zip=3.0-15+deb13u1" \
&& rm -rf /var/lib/apt/lists/* \
&& mkdir /opt/vcpkg \
&& git clone --branch "${VCPKG_VERSION}" https://github.com/microsoft/vcpkg "${VCPKG_ROOT}" \
Expand Down Expand Up @@ -105,8 +105,8 @@ FROM init AS lint
# Instala sólo lo mínimo necesario para linting (cmake, clang-format, cppcheck)
RUN apt-get update && \
apt-get -y install --no-install-recommends --no-install-suggests \
"clang-format=1:19.0-63" \
"cppcheck=2.17.1-2" && \
"clang-format=1:19.0-63" \
"cppcheck=2.17.1-2" && \
rm -rf /var/lib/apt/lists/*

LABEL lint-phase=enabled
Expand All @@ -130,7 +130,7 @@ FROM init AS testing

RUN apt-get -y update && \
apt-get -y install --no-install-recommends --no-install-suggests \
"lcov=2.3.1-1" && \
"lcov=2.3.1-1" && \
rm -rf /var/lib/apt/lists/*

COPY --from=builder ${WORKDIR} ${WORKDIR}
Expand All @@ -146,8 +146,8 @@ WORKDIR ${WORKDIR}

RUN apt-get update \
&& apt-get -y install --no-install-recommends --no-install-suggests \
## common permanent packages
"make=4.4.1-2" \
## common permanent packages
"make=4.4.1-2" \
&& rm -rf /var/lib/apt/lists/*

COPY --from=builder ${WORKDIR}/build/src/lib/exercises/*.a ${WORKDIR}/
Expand Down
44 changes: 22 additions & 22 deletions Dockerfile.ubuntu
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ ENV TZ=Etc/UTC

RUN apt-get update \
&& apt-get -y install --no-install-recommends --no-install-suggests \
## common permanent packages
"make=4.4.1-3" \
## common permanent packages
"make=4.4.1-3" \
&& rm -rf /var/lib/apt/lists/*

COPY ./Makefile ${WORKDIR}/
Expand All @@ -18,10 +18,10 @@ SHELL ["/bin/bash", "-o", "pipefail", "-c"]
RUN apt-get update \
&& apt-get -y install --no-install-recommends --no-install-suggests \
## common permanent packages
"ca-certificates=20260601~26.04.1" \
"ca-certificates=20260601~26.04.1" \
## add ephemeral packages
"curl=8.18.0-1ubuntu2.7" \
"gpg=2.4.8-4ubuntu3.1" \
"curl=8.18.0-1ubuntu2.8" \
"gpg=2.4.8-4ubuntu3.1" \
# CMAKE from Kitware repository
&& curl --proto "=https" -fsSL https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null \
| gpg --dearmor -o /usr/share/keyrings/kitware-archive-keyring.gpg \
Expand All @@ -30,8 +30,8 @@ RUN apt-get update \
# CMAKE from Kitware repository
&& apt-get update \
&& apt-get -y install --no-install-recommends --no-install-suggests \
"cmake=4.4.3-0kitware1ubuntu26.04.1" \
"cmake-data=4.4.3-0kitware1ubuntu26.04.1" \
"cmake=4.4.3-0kitware1ubuntu26.04.1" \
"cmake-data=4.4.3-0kitware1ubuntu26.04.1" \
## remove ephemeral packages
&& apt-get -y autoremove curl gpg \
## clean up
Expand All @@ -45,10 +45,10 @@ ENV GENERATE_ASM=${GENERATE_ASM}
# # build tools
RUN apt-get update \
&& apt-get -y install --no-install-recommends --no-install-suggests \
"build-essential=12.12ubuntu2.26.04.2" \
"g++=4:15.2.0-5ubuntu1" \
"gcc=4:15.2.0-5ubuntu1" \
"pkg-config=2.5.1-4" \
"build-essential=12.12ubuntu2.26.04.2" \
"g++=4:15.2.0-5ubuntu1" \
"gcc=4:15.2.0-5ubuntu1" \
"pkg-config=2.5.1-4" \
## clean up
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* \
Expand All @@ -66,12 +66,12 @@ ENV VCPKG_ROOT=/opt/vcpkg
# vcpkg Package Manager
RUN apt-get -y update \
&& apt-get -y install --no-install-recommends --no-install-suggests \
"curl=8.18.0-1ubuntu2.7" \
"git=1:2.53.0-1ubuntu1" \
"ninja-build=1.13.2-1" \
"patchelf=0.18.0-1.4build1" \
"unzip=6.0-29ubuntu1" \
"zip=3.0-15ubuntu3" \
"curl=8.18.0-1ubuntu2.8" \
"git=1:2.53.0-1ubuntu1" \
"ninja-build=1.13.2-1" \
"patchelf=0.18.0-1.4build1" \
"unzip=6.0-29ubuntu1" \
"zip=3.0-15ubuntu3" \
&& rm -rf /var/lib/apt/lists/* \
&& mkdir /opt/vcpkg \
&& git clone --branch "${VCPKG_VERSION}" https://github.com/microsoft/vcpkg "${VCPKG_ROOT}" \
Expand Down Expand Up @@ -109,8 +109,8 @@ FROM init AS lint
# Instala sólo lo mínimo necesario para linting (cmake, clang-format, cppcheck)
RUN apt-get update && \
apt-get -y install --no-install-recommends --no-install-suggests \
"clang-format=1:21.1.6-71" \
"cppcheck=2.19.0-3" && \
"clang-format=1:21.1.6-71" \
"cppcheck=2.19.0-3" && \
rm -rf /var/lib/apt/lists/*

LABEL lint-phase=enabled
Expand All @@ -134,7 +134,7 @@ FROM init AS testing

RUN apt-get -y update && \
apt-get -y install --no-install-recommends --no-install-suggests \
"lcov=2.4-3" && \
"lcov=2.4-3" && \
rm -rf /var/lib/apt/lists/*

COPY --from=builder ${WORKDIR} ${WORKDIR}
Expand All @@ -150,8 +150,8 @@ WORKDIR ${WORKDIR}

RUN apt-get update \
&& apt-get -y install --no-install-recommends --no-install-suggests \
## common permanent packages
"make=4.4.1-3" \
## common permanent packages
"make=4.4.1-3" \
&& rm -rf /var/lib/apt/lists/*

COPY --from=builder ${WORKDIR}/build/src/lib/exercises/*.a ${WORKDIR}/
Expand Down
8 changes: 1 addition & 7 deletions src/lib/exercises/src/hackerrank/warmup/time_conversion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,7 @@ std::string timeConversion(const std::string &s) {
int hour;
hour_str >> hour;

if (hour < 0 || hour > 23) {
throw std::invalid_argument("Invalid hour value: " + std::to_string(hour));
}

if (hour >= 12) {
hour = 0;
}
hour = hour % 12;

if (meridian.compare("PM") == 0) {
hour += 12;
Expand Down
8 changes: 3 additions & 5 deletions src/tests/unit/lib/hackerrank/warmup/a_very_big_sum.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,10 @@ using json = nlohmann::json;

TEST_CASE("aVeryBigSum JSON Test Cases",
"[hackerrank] [jsontestcase] [warmup]") {
std::filesystem::path cwd = std::filesystem::current_path();
std::string path =
cwd.string() +
"/unit/lib/hackerrank/warmup/a_very_big_sum.testcases.json";
std::filesystem::path path = std::filesystem::path(__FILE__).parent_path() /
"a_very_big_sum.testcases.json";

INFO("aVeryBigSum JSON test cases FILE: " << path);
INFO("aVeryBigSum JSON test cases FILE: " << path.string());

std::ifstream f(path);
json data = json::parse(f);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,10 @@ using json = nlohmann::json;

TEST_CASE("birthdayCakeCandles JSON Test Cases",
"[hackerrank] [jsontestcase] [warmup]") {
std::filesystem::path cwd = std::filesystem::current_path();
std::string path =
cwd.string() +
"/unit/lib/hackerrank/warmup/birthday_cake_candles.testcases.json";
std::filesystem::path path = std::filesystem::path(__FILE__).parent_path() /
"birthday_cake_candles.testcases.json";

INFO("birthdayCakeCandles JSON test cases FILE: " << path);
INFO("birthdayCakeCandles JSON test cases FILE: " << path.string());

std::ifstream f(path);
json data = json::parse(f);
Expand Down
10 changes: 5 additions & 5 deletions src/tests/unit/lib/hackerrank/warmup/compare_triplets.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ using json = nlohmann::json;

TEST_CASE("compareTriplets JSON Test Cases",
"[hackerrank] [jsontestcase] [warmup]") {
std::filesystem::path cwd = std::filesystem::current_path();
std::string path =
cwd.string() +
"/unit/lib/hackerrank/warmup/compare_triplets.testcases.json";
std::filesystem::path path = std::filesystem::path(__FILE__).parent_path() /
"compare_triplets.testcases.json";

INFO("compareTriplets JSON test cases FILE: " << path);
INFO("compareTriplets JSON test cases FILE: " << path.string());

std::ifstream f(path);
REQUIRE(f.is_open());

json data = json::parse(f);

for (auto testcase : data) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,10 @@ using json = nlohmann::json;

TEST_CASE("diagonalDifference JSON Test Cases",
"[hackerrank] [jsontestcase] [warmup]") {
std::filesystem::path cwd = std::filesystem::current_path();
std::string path =
cwd.string() +
"/unit/lib/hackerrank/warmup/diagonal_difference.testcases.json";
std::filesystem::path path = std::filesystem::path(__FILE__).parent_path() /
"diagonal_difference.testcases.json";

INFO("diagonalDifference JSON test cases FILE: " << path);
INFO("diagonalDifference JSON test cases FILE: " << path.string());

std::ifstream f(path);
json data = json::parse(f);
Expand Down
7 changes: 3 additions & 4 deletions src/tests/unit/lib/hackerrank/warmup/mini_max_sum.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,10 @@ using json = nlohmann::json;

TEST_CASE("miniMaxSum JSON Test Cases",
"[hackerrank] [jsontestcase] [warmup]") {
std::filesystem::path cwd = std::filesystem::current_path();
std::string path =
cwd.string() + "/unit/lib/hackerrank/warmup/mini_max_sum.testcases.json";
std::filesystem::path path = std::filesystem::path(__FILE__).parent_path() /
"mini_max_sum.testcases.json";

INFO("miniMaxSum JSON test cases FILE: " << path);
INFO("miniMaxSum JSON test cases FILE: " << path.string());

std::ifstream f(path);
json data = json::parse(f);
Expand Down
7 changes: 3 additions & 4 deletions src/tests/unit/lib/hackerrank/warmup/plus_minus.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,10 @@
using json = nlohmann::json;

TEST_CASE("plusMinus JSON Test Cases", "[hackerrank] [jsontestcase] [warmup]") {
std::filesystem::path cwd = std::filesystem::current_path();
std::string path =
cwd.string() + "/unit/lib/hackerrank/warmup/plus_minus.testcases.json";
std::filesystem::path path = std::filesystem::path(__FILE__).parent_path() /
"plus_minus.testcases.json";

INFO("plusMinus JSON test cases FILE: " << path);
INFO("plusMinus JSON test cases FILE: " << path.string());

std::ifstream f(path);
json data = json::parse(f);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,10 @@ using json = nlohmann::json;

TEST_CASE("simpleArraySum JSON Test Cases",
"[hackerrank] [jsontestcase] [warmup]") {
std::filesystem::path cwd = std::filesystem::current_path();
std::string path =
cwd.string() +
"/unit/lib/hackerrank/warmup/simple_array_sum.testcases.json";
std::filesystem::path path = std::filesystem::path(__FILE__).parent_path() /
"simple_array_sum.testcases.json";

INFO("simpleArraySum JSON test cases FILE: " << path);
INFO("simpleArraySum JSON test cases FILE: " << path.string());

std::ifstream f(path);
json data = json::parse(f);
Expand Down
8 changes: 3 additions & 5 deletions src/tests/unit/lib/hackerrank/warmup/solve_me_first.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,10 @@ using json = nlohmann::json;

TEST_CASE("solveMeFirst JSON Test Cases",
"[hackerrank] [jsontestcase] [warmup]") {
std::filesystem::path cwd = std::filesystem::current_path();
std::string path =
cwd.string() +
"/unit/lib/hackerrank/warmup/solve_me_first.testcases.json";
std::filesystem::path path = std::filesystem::path(__FILE__).parent_path() /
"solve_me_first.testcases.json";

INFO("solveMeFirst JSON test cases FILE: " << path);
INFO("solveMeFirst JSON test cases FILE: " << path.string());

std::ifstream f(path);
json data = json::parse(f);
Expand Down
7 changes: 3 additions & 4 deletions src/tests/unit/lib/hackerrank/warmup/staircase.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,10 @@
using json = nlohmann::json;

TEST_CASE("staircase", "[warmup]") {
std::filesystem::path cwd = std::filesystem::current_path();
std::string path =
cwd.string() + "/unit/lib/hackerrank/warmup/staircase.testcases.json";
std::filesystem::path path = std::filesystem::path(__FILE__).parent_path() /
"staircase.testcases.json";

INFO("staircase JSON test cases FILE: " << path);
INFO("staircase JSON test cases FILE: " << path.string());

std::ifstream f(path);
json data = json::parse(f);
Expand Down
13 changes: 3 additions & 10 deletions src/tests/unit/lib/hackerrank/warmup/test_conversion.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,10 @@ using json = nlohmann::json;

TEST_CASE("time_conversion JSON Test Cases",
"[hackerrank] [jsontestcase] [warmup]") {
std::filesystem::path cwd = std::filesystem::current_path();
std::string path =
cwd.string() +
"/unit/lib/hackerrank/warmup/time_conversion.testcases.json";
std::filesystem::path path = std::filesystem::path(__FILE__).parent_path() /
"time_conversion.testcases.json";

INFO("time_conversion JSON test cases FILE: " << path);
INFO("time_conversion JSON test cases FILE: " << path.string());

std::ifstream f(path);
json data = json::parse(f);
Expand All @@ -36,8 +34,3 @@ TEST_CASE("time_conversion helper functions edge cases",
CHECK(hackerrank::warmup::firstN("", 0) == "");
CHECK(hackerrank::warmup::lastN("", 0) == "");
}

TEST_CASE("time_conversion invalid input", "[hackerrank] [invalid] [warmup]") {
CHECK_THROWS_AS(hackerrank::warmup::timeConversion("25:01:00AM"),
std::invalid_argument);
}
Loading