[Issue #60] Added regression tests for theories
This commit is contained in:
parent
218cd9ecfa
commit
9549db4fac
7 changed files with 140 additions and 0 deletions
|
@ -3,11 +3,13 @@ set(SAMPLES
|
|||
exit.c
|
||||
long-messages.c
|
||||
other-crashes.c
|
||||
theories_regression.c
|
||||
|
||||
failmessages.cc
|
||||
exit.cc
|
||||
long-messages.cc
|
||||
other-crashes.cc
|
||||
theories_regression.cc
|
||||
)
|
||||
|
||||
add_samples("${CMAKE_CURRENT_LIST_DIR}" "${SAMPLES}")
|
||||
|
|
15
samples/tests/outputs/theories_regression.c.bin.err.expected
Normal file
15
samples/tests/outputs/theories_regression.c.bin.err.expected
Normal file
|
@ -0,0 +1,15 @@
|
|||
[[0;34m----[0m] [0;1mtheories_regression.c[0m:[0;31m52[0m: Assertion failed: The conditions for this assertion were not met.
|
||||
[[0;34m----[0m] Theory theory::gen failed with the following parameters: (1)
|
||||
[[0;34m----[0m] [0;1mtheories_regression.c[0m:[0;31m52[0m: Assertion failed: The conditions for this assertion were not met.
|
||||
[[0;34m----[0m] Theory theory::gen failed with the following parameters: (2)
|
||||
[[0;34m----[0m] [0;1mtheories_regression.c[0m:[0;31m52[0m: Assertion failed: The conditions for this assertion were not met.
|
||||
[[0;34m----[0m] Theory theory::gen failed with the following parameters: (3)
|
||||
[[0;34m----[0m] [0;1mtheories_regression.c[0m:[0;31m52[0m: Assertion failed: The conditions for this assertion were not met.
|
||||
[[0;34m----[0m] Theory theory::gen failed with the following parameters: (4)
|
||||
[[0;34m----[0m] [0;1mtheories_regression.c[0m:[0;31m52[0m: Assertion failed: The conditions for this assertion were not met.
|
||||
[[0;34m----[0m] Theory theory::gen failed with the following parameters: (5)
|
||||
[[0;31mFAIL[0m] theory::gen: (0.00s)
|
||||
[[0;34m----[0m] [0;1mtheories_regression.c[0m:[0;31m35[0m: Assertion failed: The conditions for this assertion were not met.
|
||||
[[0;34m----[0m] Theory theory::misc failed with the following parameters: ('a', true, 1, 1, 1l, 1l, 3.14f, 3.14, "test", "other test")
|
||||
[[0;31mFAIL[0m] theory::misc: (0.00s)
|
||||
[[0;34m====[0m] [0;1mSynthesis: Tested: [0;34m2[0;1m | Passing: [0;32m0[0;1m | Failing: [0;31m2[0;1m | Crashing: [0;31m0[0;1m [0m
|
|
@ -0,0 +1,15 @@
|
|||
[[0;34m----[0m] [0;1mtheories_regression.cc[0m:[0;31m54[0m: Assertion failed: The conditions for this assertion were not met.
|
||||
[[0;34m----[0m] Theory theory::gen failed with the following parameters: (1)
|
||||
[[0;34m----[0m] [0;1mtheories_regression.cc[0m:[0;31m54[0m: Assertion failed: The conditions for this assertion were not met.
|
||||
[[0;34m----[0m] Theory theory::gen failed with the following parameters: (2)
|
||||
[[0;34m----[0m] [0;1mtheories_regression.cc[0m:[0;31m54[0m: Assertion failed: The conditions for this assertion were not met.
|
||||
[[0;34m----[0m] Theory theory::gen failed with the following parameters: (3)
|
||||
[[0;34m----[0m] [0;1mtheories_regression.cc[0m:[0;31m54[0m: Assertion failed: The conditions for this assertion were not met.
|
||||
[[0;34m----[0m] Theory theory::gen failed with the following parameters: (4)
|
||||
[[0;34m----[0m] [0;1mtheories_regression.cc[0m:[0;31m54[0m: Assertion failed: The conditions for this assertion were not met.
|
||||
[[0;34m----[0m] Theory theory::gen failed with the following parameters: (5)
|
||||
[[0;31mFAIL[0m] theory::gen: (0.00s)
|
||||
[[0;34m----[0m] [0;1mtheories_regression.cc[0m:[0;31m37[0m: Assertion failed: The conditions for this assertion were not met.
|
||||
[[0;34m----[0m] Theory theory::misc failed with the following parameters: ('a', true, 1, 1, 1l, 1l, 3.14f, 3.14, "test", "other test")
|
||||
[[0;31mFAIL[0m] theory::misc: (0.00s)
|
||||
[[0;34m====[0m] [0;1mSynthesis: Tested: [0;34m2[0;1m | Passing: [0;32m0[0;1m | Failing: [0;31m2[0;1m | Crashing: [0;31m0[0;1m [0m
|
53
samples/tests/theories_regression.c
Normal file
53
samples/tests/theories_regression.c
Normal file
|
@ -0,0 +1,53 @@
|
|||
#ifdef _MSC_VER
|
||||
#pragma warning(disable : 4090)
|
||||
#endif
|
||||
|
||||
#include <criterion/theories.h>
|
||||
|
||||
// Testing for various parameters
|
||||
|
||||
TheoryDataPoints(theory, misc) = {
|
||||
DataPoints(char, 'a'),
|
||||
DataPoints(bool, true),
|
||||
DataPoints(short, 1),
|
||||
DataPoints(int, 1),
|
||||
DataPoints(long, 1),
|
||||
DataPoints(long long, 1),
|
||||
DataPoints(float, 3.14f),
|
||||
DataPoints(double, 3.14),
|
||||
DataPoints(char *, "test"),
|
||||
DataPoints(const char *, "other test"),
|
||||
};
|
||||
|
||||
Theory((char c, bool b, short s, int i, long l, long long ll, float f, double d, char *str, const char *cstr), theory, misc) {
|
||||
cr_assert(b);
|
||||
cr_assert_eq(c, 'a');
|
||||
cr_assert_eq(s, 1);
|
||||
cr_assert_eq(i, 1);
|
||||
cr_assert_eq(l, 1);
|
||||
cr_assert_eq(ll, 1);
|
||||
cr_assert_eq(f, 3.14f);
|
||||
cr_assert_eq(d, 3.14);
|
||||
cr_assert_str_eq(str, "test");
|
||||
cr_assert_str_eq(cstr, "other test");
|
||||
|
||||
// abort to see the formatted string of all parameters
|
||||
cr_assert_fail();
|
||||
}
|
||||
|
||||
// Manually generate datapoints
|
||||
|
||||
TheoryDataPoints(theory, gen) = {
|
||||
DataPoints(int, 0), // placeholder
|
||||
};
|
||||
|
||||
static void generate_datapoints(void) {
|
||||
static int arr[] = {1, 2, 3, 4, 5};
|
||||
TheoryDataPoint(theory, gen)[0].len = 5;
|
||||
TheoryDataPoint(theory, gen)[0].arr = &arr;
|
||||
}
|
||||
|
||||
Theory((int i), theory, gen, .init = generate_datapoints) {
|
||||
(void) i;
|
||||
cr_assert_fail(); // we fail to display the parameter
|
||||
}
|
55
samples/tests/theories_regression.cc
Normal file
55
samples/tests/theories_regression.cc
Normal file
|
@ -0,0 +1,55 @@
|
|||
#ifdef _MSC_VER
|
||||
#pragma warning(disable : 4090)
|
||||
#endif
|
||||
|
||||
#include <criterion/theories.h>
|
||||
|
||||
// Testing for various parameters
|
||||
|
||||
char test_str[] = {'t', 'e', 's', 't', '\0'};
|
||||
|
||||
TheoryDataPoints(theory, misc) = {
|
||||
DataPoints(char, 'a'),
|
||||
DataPoints(bool, true),
|
||||
DataPoints(short, 1),
|
||||
DataPoints(int, 1),
|
||||
DataPoints(long, 1),
|
||||
DataPoints(long long, 1),
|
||||
DataPoints(float, 3.14f),
|
||||
DataPoints(double, 3.14),
|
||||
DataPoints(char *, test_str),
|
||||
DataPoints(const char *, "other test"),
|
||||
};
|
||||
|
||||
Theory((char c, bool b, short s, int i, long l, long long ll, float f, double d, char *str, const char *cstr), theory, misc) {
|
||||
cr_assert(b);
|
||||
cr_assert_eq(c, 'a');
|
||||
cr_assert_eq(s, 1);
|
||||
cr_assert_eq(i, 1);
|
||||
cr_assert_eq(l, 1);
|
||||
cr_assert_eq(ll, 1);
|
||||
cr_assert_eq(f, 3.14f);
|
||||
cr_assert_eq(d, 3.14);
|
||||
cr_assert_str_eq(str, "test");
|
||||
cr_assert_str_eq(cstr, "other test");
|
||||
|
||||
// abort to see the formatted string of all parameters
|
||||
cr_assert_fail();
|
||||
}
|
||||
|
||||
// Manually generate datapoints
|
||||
|
||||
TheoryDataPoints(theory, gen) = {
|
||||
DataPoints(int, 0), // placeholder
|
||||
};
|
||||
|
||||
static void generate_datapoints(void) {
|
||||
static int arr[] = {1, 2, 3, 4, 5};
|
||||
TheoryDataPoint(theory, gen)[0].len = 5;
|
||||
TheoryDataPoint(theory, gen)[0].arr = &arr;
|
||||
}
|
||||
|
||||
Theory((int i), theory, gen, .init = generate_datapoints) {
|
||||
(void) i;
|
||||
cr_assert_fail(); // we fail to display the parameter
|
||||
}
|
Loading…
Add table
Reference in a new issue