Skip to content
Snippets Groups Projects
Commit 9eb4bec2 authored by Huste, Tobias's avatar Huste, Tobias
Browse files

Merge branch 'ci-episode-6-exercise-1-optimize-ci-pipeline' into...

Merge branch 'ci-episode-6-exercise-1-optimize-ci-pipeline' into ci-episode-7-exercise-1-using-includes
parents 13982f0b e6dbe221
No related branches found
No related tags found
No related merge requests found
Pipeline #503618 passed
...@@ -6,15 +6,15 @@ ...@@ -6,15 +6,15 @@
--- ---
running: running:
image: gcc:13 image: gcc:14
stage: run stage: run
script: script:
- cd build_gcc_13/bin/ && ./helloWorld - cd build_gcc_14/bin/ && ./helloWorld
needs: needs:
- job: "build:gcc" - job: "build:gcc"
artifacts: true artifacts: true
parallel: parallel:
matrix: matrix:
- VERSION: 13 - VERSION: 14
... ...
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
#include <iostream> #include <iostream>
#include <string>
#include "src/helloworld.h" #include "src/helloworld.h"
......
...@@ -4,41 +4,42 @@ ...@@ -4,41 +4,42 @@
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include <cstdlib> #include <cstdlib>
#include <string>
#include "src/helloworld.h" #include "src/helloworld.h"
namespace { namespace {
TEST(getUserNameViaEnv, HandleEnvUnset) { TEST(getUserNameViaEnv, HandleEnvUnset) {
// Test if function returns World if environment variable unset // Test if function returns World if environment variable unset
// Make sure environment variable is unset // Make sure environment variable is unset
char* envVarNameChar; char* envVarNameChar;
std::string envVarName = std::string{"GITLAB_USER_NAME"}; std::string envVarName = std::string{"GITLAB_USER_NAME"};
envVarNameChar = &envVarName[0]; envVarNameChar = &envVarName[0];
unsetenv(envVarNameChar); unsetenv(envVarNameChar);
// Assert that we get the expected result // Assert that we get the expected result
EXPECT_EQ(std::string{"World"}, getUserNameViaEnv()); EXPECT_EQ(std::string{"World"}, getUserNameViaEnv());
} }
TEST(getUserNameViaEnv, HandleEnvSet) { TEST(getUserNameViaEnv, HandleEnvSet) {
// Test if function returns World if environment variable unset // Test if function returns World if environment variable unset
// Set the environment variable to the desired value // Set the environment variable to the desired value
char* envVarNameChar; char* envVarNameChar;
char* envVarValChar; char* envVarValChar;
std::string envVarName = std::string{"GITLAB_USER_NAME"}; std::string envVarName = std::string{"GITLAB_USER_NAME"};
std::string envVarVal = std::string{"Jane Doe"}; std::string envVarVal = std::string{"Jane Doe"};
envVarNameChar = &envVarName[0]; envVarNameChar = &envVarName[0];
envVarValChar = &envVarVal[0]; envVarValChar = &envVarVal[0];
setenv(envVarNameChar, envVarValChar, true); setenv(envVarNameChar, envVarValChar, true);
// Assert that function output and environment variable are similar // Assert that function output and environment variable are similar
EXPECT_EQ(envVarVal, getUserNameViaEnv()); EXPECT_EQ(envVarVal, getUserNameViaEnv());
// Clean up // Clean up
unsetenv(envVarNameChar); unsetenv(envVarNameChar);
} }
} // namespace } // namespace
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment