[Issue #60] Added regression tests for theories

This commit is contained in:
Snaipe 2015-09-28 13:30:02 +02:00
parent 218cd9ecfa
commit 9549db4fac
7 changed files with 140 additions and 0 deletions

View file

@ -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}")

View file

@ -0,0 +1,15 @@
[----] theories_regression.c:52: Assertion failed: The conditions for this assertion were not met.
[----] Theory theory::gen failed with the following parameters: (1)
[----] theories_regression.c:52: Assertion failed: The conditions for this assertion were not met.
[----] Theory theory::gen failed with the following parameters: (2)
[----] theories_regression.c:52: Assertion failed: The conditions for this assertion were not met.
[----] Theory theory::gen failed with the following parameters: (3)
[----] theories_regression.c:52: Assertion failed: The conditions for this assertion were not met.
[----] Theory theory::gen failed with the following parameters: (4)
[----] theories_regression.c:52: Assertion failed: The conditions for this assertion were not met.
[----] Theory theory::gen failed with the following parameters: (5)
[FAIL] theory::gen: (0.00s)
[----] theories_regression.c:35: Assertion failed: The conditions for this assertion were not met.
[----] Theory theory::misc failed with the following parameters: ('a', true, 1, 1, 1l, 1l, 3.14f, 3.14, "test", "other test")
[FAIL] theory::misc: (0.00s)
[====] Synthesis: Tested: 2 | Passing: 0 | Failing: 2 | Crashing: 0 

View file

@ -0,0 +1,15 @@
[----] theories_regression.cc:54: Assertion failed: The conditions for this assertion were not met.
[----] Theory theory::gen failed with the following parameters: (1)
[----] theories_regression.cc:54: Assertion failed: The conditions for this assertion were not met.
[----] Theory theory::gen failed with the following parameters: (2)
[----] theories_regression.cc:54: Assertion failed: The conditions for this assertion were not met.
[----] Theory theory::gen failed with the following parameters: (3)
[----] theories_regression.cc:54: Assertion failed: The conditions for this assertion were not met.
[----] Theory theory::gen failed with the following parameters: (4)
[----] theories_regression.cc:54: Assertion failed: The conditions for this assertion were not met.
[----] Theory theory::gen failed with the following parameters: (5)
[FAIL] theory::gen: (0.00s)
[----] theories_regression.cc:37: Assertion failed: The conditions for this assertion were not met.
[----] Theory theory::misc failed with the following parameters: ('a', true, 1, 1, 1l, 1l, 3.14f, 3.14, "test", "other test")
[FAIL] theory::misc: (0.00s)
[====] Synthesis: Tested: 2 | Passing: 0 | Failing: 2 | Crashing: 0 

View 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
}

View 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
}