Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
Firmware
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
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
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
Alberto Ruiz Garcia
Firmware
Commits
75129b9c
Commit
75129b9c
authored
9 years ago
by
Lorenz Meier
Browse files
Options
Downloads
Patches
Plain Diff
Fix code style for unit tests
parent
fba569f1
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/modules/unit_test/unit_test.h
+12
-11
12 additions, 11 deletions
src/modules/unit_test/unit_test.h
with
12 additions
and
11 deletions
src/modules/unit_test/unit_test.h
+
12
−
11
View file @
75129b9c
...
...
@@ -44,14 +44,14 @@ public:
UnitTest
();
virtual
~
UnitTest
();
/// @brief Override to run your unit tests. Unit tests should be called using ut_run_test macro.
/// @return true: all unit tests succeeded, false: one or more unit tests failed
virtual
bool
run_tests
(
void
)
=
0
;
/// @brief Prints results from running of unit tests.
void
print_results
(
void
);
/// @brief Macro to create a function which will run a unit test class and print results.
#define ut_declare_test(test_function, test_class) \
bool test_function(void) \
...
...
@@ -61,9 +61,9 @@ public:
test->print_results(); \
return success; \
}
protected:
/// @brief Runs a single unit test. Unit tests must have the function signature of bool test(void). The unit
/// test should return true if it succeeded, false for fail.
#define ut_run_test(test) \
...
...
@@ -80,7 +80,7 @@ protected:
} \
_cleanup(); \
} while (0)
/// @brief Used to assert a value within a unit test.
#define ut_assert(message, test) \
do { \
...
...
@@ -91,7 +91,7 @@ protected:
_assertions++; \
} \
} while (0)
/// @brief Used to compare two integer values within a unit test. If possible use ut_compare instead of ut_assert
/// since it will give you better error reporting of the actual values being compared.
#define ut_compare(message, v1, v2) \
...
...
@@ -105,12 +105,13 @@ protected:
_assertions++; \
} \
} while (0)
virtual
void
_init
(
void
)
{
};
///< Run before each unit test. Override to provide custom behavior.
virtual
void
_cleanup
(
void
)
{
};
///< Run after each unit test. Override to provide custom behavior.
void
_print_assert
(
const
char
*
msg
,
const
char
*
test
,
const
char
*
file
,
int
line
);
void
_print_compare
(
const
char
*
msg
,
const
char
*
v1_text
,
int
v1
,
const
char
*
v2_text
,
int
v2
,
const
char
*
file
,
int
line
);
void
_print_assert
(
const
char
*
msg
,
const
char
*
test
,
const
char
*
file
,
int
line
);
void
_print_compare
(
const
char
*
msg
,
const
char
*
v1_text
,
int
v1
,
const
char
*
v2_text
,
int
v2
,
const
char
*
file
,
int
line
);
int
_tests_run
;
///< The number of individual unit tests run
int
_tests_failed
;
///< The number of unit tests which failed
...
...
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