Commit Graph

128 Commits

Author SHA1 Message Date
Bas van den Berg
4c49efda86 style: removed trailing space 2023-01-17 11:03:10 +01:00
Tyge Løvset
6abd959b2d Added cast to double, and split the line. 2023-01-17 11:03:08 +01:00
Tyge Løvset
adba050f20 Removed warnings when assigning clock() to t1/t2. Change to clock_t, but it's an unspecified type, so convert to double on usage.
Removed a warning on write(). MinGW-64 gcc takes unsigned int as length (although docs seems to say size_t?), and warns when passing result of strlen().
Removed not needed #include <process.h> for _WIN32, as getpid() is not called. <io.h> still needed for write() and isatty().
2023-01-17 11:03:05 +01:00
Tyge Løvset
2c5ec07d30 Updated discussed fixes. 2023-01-17 11:03:00 +01:00
Tyge Løvset
ba5bf18a38 Portability Pull Request:
This commit removes dependency of two POSIX functions which are not supported on many non-unix/linux platforms (one exception is CYGWIN).
gettimeofday() is replaced with the standard clock() function. On windows, the kill() call is skipped, as segmentation fault will terminate the process in any case (without core-dump).
These changes enables ctest to compile and work with both MinGW gcc, clang and TINYC on Windows with SEGFAULT enabled. (TINYC on Linux misbehaves, but this is likely an issue with TINYC).
2023-01-17 11:02:57 +01:00
Tyge Løvset
0700b738c2 Added static to added local functions, and moved it to where it is used. 2023-01-17 11:02:53 +01:00
Tyge Løvset
6f2f65adf1 1. Improved default accuracy handling for real numbers: relative accuracy error. (tol < 0). _TOL still uses absolute error spec.
2. Added ASSERT_NOT_STR(), ASSERT_STRSTR() and ASSERT_NOT_STRSTR() + wide string versions - search for containing string.
3. Added ASSERT_LT(), ASSERT_LE(), ASSERT_GT(), ASSERT_GE() - new integer comparisons functions with useful error reporting.
4. Added ASSERT_FLT_NEAR(), ASSERT_FLT_FAR() - uses float relative accuracy error.
5. Added ASSERT_DBL_LT(), ASSERT_DBL_GT() -  - new double comparisons functions with useful error reporting.

Added some tests. This is a compact and minimum code change to add this functionality.
2023-01-17 11:02:43 +01:00
Bas van den Berg
6b37e2d794 legal: update copyright notice 2023-01-02 08:24:41 +01:00
Bas van den Berg
e35302569f Copyright: update for 2022 2022-02-22 10:35:46 +01:00
Bas van den Berg
cd46041baf copyright: update to 2021 2021-01-13 06:21:52 +01:00
Andrew Eckel
cf30ad66e9 Remove unused uname variable 2020-09-16 22:09:10 -04:00
Andrew Eckel
78a37432bd Compile the example tests with both a C and C++ compiler 2020-09-16 22:09:10 -04:00
Andrew Eckel
f8a83d694b Add basic C++ support
This commit adds C++ support with the following modifications:
- Remove the use of C-only features including designated initializers
  and non-strict prototypes.
- Add spaces between literals and string macros to silence the C++-only
  -Wliteral-suffix warning.
- Conditionally use template specialization instead of tentative
  definitions to implement optional setup/teardown functions.

Note that no C++-specific features have been added.  The goal of this
commit is to simply enable compiling in C++ mode.
2020-08-19 23:09:41 -04:00
Bas van den Berg
f12e0d811b ctest.h: update Copyright (2018 -> 2020) 2020-07-30 16:02:39 +02:00
Bas van den Berg
3bed825160 fix scope for msg 2019-12-24 10:32:03 +01:00
Marco Bonelli
107a1780bd
Make signal handler only call async-signal-safe functions 2019-08-31 08:00:58 +02:00
Bas van den Berg
4cdaf057f7 removed extra whitespace 2019-05-23 22:05:00 +02:00
Farkasvölgyi
2230e3e9b1 ignore sanitizer 2019-05-23 22:05:00 +02:00
Farkasvölgyi
ce02456a76 Add ASSERT_WSTR 2019-05-23 22:05:00 +02:00
Farkasvölgyi
f501ac200f Add ASSERT_WSTR 2019-05-23 22:05:00 +02:00
Bas van den Berg
0f3f58018c example: removed usleep since it seems to cause issues on Windows 2018-04-04 21:44:12 +02:00
Mike Gelfand
c39ed2245d Use C99 snprintf instead of sprintf
Since we're already using `vsnprintf` and other C99 features, it's only
natural to use `snprintf` as well. Moreover, `sprintf` is "deprecated" in
Microsoft's CRT in favor of more secure (Microsoft-specific) alternatives
with its use resulting in a warning, while `snprintf` isn't (although
requires recent enough CRT).
2018-04-04 21:36:58 +02:00
Mike Gelfand
b8f1802522 Eliminate use of empty struct in test code
Where GCC and Clang issue warnings such as "empty struct is a GNU extension"
(with `-Wgnu-empty-struct`) or "empty struct has size 0 in C, size 1 in C++"
(with `-Wc++-compat`), MSVC issues an error C2016 "C requires that a struct
or union has at least one member".
2018-03-31 16:18:01 +03:00
Andrew Eckel
a0d3adb693 Move tentative callback definitions into CTEST_DATA and remove -Wredundant-decls pragmas 2018-03-29 08:24:57 +02:00
Andrew Eckel
4ff744cc25 Remove gratuitous parens 2018-03-28 22:15:09 +02:00
Bas van den Berg
b0891e0640 move setup/teardown forward decls to CTEST_DATA 2018-03-28 22:05:20 +02:00
Andrew Eckel
6ae86e9ca5 Replace weak-linkage strategy for handling undefined setup/teardown callbacks with a standard C strategy using tentative definitions 2018-03-28 21:07:22 +02:00
Andrew Eckel
a900b3b3c7 Refactor pragma's for warning control 2018-03-28 21:07:22 +02:00
Bas van den Berg
0982423706 Copyright: update for 2018 2018-03-28 21:07:03 +02:00
Bas van den Berg
904dc560a3 removed empty line 2018-03-28 20:58:44 +02:00
Andrew Eckel
07db910d5e Add -Wshadow to CCFLAGS 2018-03-25 15:22:13 -04:00
Andrew Eckel
d911807f0b Suppress -Wshadow warning by renaming a local variable 'index', which may shadow the standard library function of the same name. 2018-03-11 21:46:46 -04:00
Matt Kelly
7ae25126a6 Convert tabs to spaces in header 2017-07-25 22:59:03 -04:00
Bas van den Berg
5478fff272 legal: changed copyright msg 2016 -> 2017 2017-04-18 22:36:38 +02:00
Bas van den Berg
ddef685e3e Makefile: added compiler warning flags 2017-04-18 22:18:36 +02:00
Mike Gelfand
92ae0d9cb5 Declare own data variable for each test case
This eliminates "redundant redeclaration of '..._data' [-Wredundant-decls]"
GCC warnings.
2017-03-05 21:33:55 +03:00
Mike Gelfand
616c99cb3f Move setup/teardown function declarations to CTEST_DATA macro
This eliminates "redundant redeclaration of '..._setup' [-Wredundant-decls]"
and "redundant redeclaration of '..._teardown' [-Wredundant-decls]" GCC
warnings.
2017-03-05 21:32:54 +03:00
Bas van den Berg
99c916e2d8 Makefile: use $CC instead of hardcoded gcc 2017-03-05 13:41:02 +01:00
Bas van den Berg
0ea727141b Merge branch 'mikedld-warnings-elimination' 2017-03-05 13:40:50 +01:00
Mike Gelfand
301626b2b2 Make function declarations proper prototypes
Where not possible (as with `ctest::run`), suppress the warning.

This eliminates "function declaration isn't a prototype [-Wstrict-prototypes]"
GCC warning.
2017-03-05 12:59:23 +03:00
Mike Gelfand
f5525fe227 Don't inline non-inlinable functions
This eliminates "function '...' can never be inlined because it uses variable
argument lists [-Winline]" and "inlining failed in call to '...': function
not inlinable [-Winline]" GCC warnings.
2017-03-05 12:55:12 +03:00
Mike Gelfand
5bb5e4310f Suppress noreturn attribute suggestion
Marking `CTEST_ERR` function as noreturn leads to same warning appearing
for `ctest_fail` function; marking the latter as noreturn as well leads
to warnings in user test cases which is not something we want.

This eliminates "function 'CTEST_ERR' could be declared with attribute
'noreturn' [-Wmissing-noreturn]" Clang warning.
2017-03-04 23:14:40 +03:00
Mike Gelfand
e5d42fc3c3 Reorder ctest struct fields for better packing
This resulted in gaps between `ctest` structs with GCC on amd64, so adding
aligned(1) attribute to the section fix this.

This eliminates "padding struct 'struct ctest' with 4 bytes to align 'data'
[-Wpadded]" and "padding size of 'struct ctest' with 4 bytes to alignment
boundary [-Wpadded]" Clang warnings.
2017-03-04 23:02:01 +03:00
Mike Gelfand
fb62076f4f Mark printf-like functions as such
This eliminates "format string is not a string literal [-Wformat-nonliteral]"
(and after that "format specifies type 'void *' but the argument has type
'... *' [-Wformat-pedantic]") Clang warning.
2017-03-04 22:12:30 +03:00
Mike Gelfand
7ca2060993 Explicitly mark data variable unused
Not using `__attribute__((unused))` as I think the warning could be useful:
if one is using CTEST2, they should be using `data`.

This eliminates "unused parameter '...' [-Wunused-parameter]" GCC/Clang
warning.
2017-03-04 21:55:35 +03:00
Mike Gelfand
26ab614fac Declare test case functions static
Provide prototypes for setup and teardown test case functions as making
them static is not possible due to weak linking.

Provide prototype for ctest_main function as making it static might break
existing code if someone does `#define ctest_main main`.

This eliminates "no previous prototype for function '...'
[-Wmissing-prototypes]" Clang warning.
2017-03-04 21:40:07 +03:00
Mike Gelfand
16b78ef57c Prefix the rest of symbols with CTEST_IMPL_ and ctest_ for symmetry 2017-03-04 21:18:44 +03:00
Mike Gelfand
8e2f92d666 Don't use names starting with two underscores
Instead use CTEST_IMPL_ prefix for internal macros.

This eliminates "macro name is a reserved identifier [-Wreserved-id-macro]"
Clang warning.
2017-03-04 21:02:16 +03:00
Bas van den Berg
ae3a381d28 added ASSERT_INTERVAL to test for intervals 2016-02-22 15:43:03 +01:00
Bas van den Berg
7a78010830 updated copyright for 2016 2016-02-22 15:39:34 +01:00