Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
Exercise Project
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
HIFIS
HIFIS Software Services
Education and Training
Workshop Materials
Continuous Integration in GitLab
Exercise Project
Commits
cedf4d40
Commit
cedf4d40
authored
3 months ago
by
Huste, Tobias
Browse files
Options
Downloads
Patches
Plain Diff
Fix cpplint warnings
parent
30fe3ca9
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/main.cpp
+1
-0
1 addition, 0 deletions
src/main.cpp
tests/tests.cpp
+32
-31
32 additions, 31 deletions
tests/tests.cpp
with
33 additions
and
31 deletions
src/main.cpp
+
1
−
0
View file @
cedf4d40
...
@@ -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"
...
...
This diff is collapsed.
Click to expand it.
tests/tests.cpp
+
32
−
31
View file @
cedf4d40
...
@@ -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
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment