moving from gitlab
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
#include "math.h"
|
||||
#include <criterion/alloc.h>
|
||||
#include <criterion/criterion.h>
|
||||
#include <criterion/internal/new_asserts.h>
|
||||
#include <criterion/new/assert.h>
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
||||
Test(basic, test1) { cr_assert(1 == 1); }
|
||||
|
||||
Test(basic, test2) { cr_expect(2 == 2); }
|
||||
|
||||
void setup() { printf("setup!\n"); }
|
||||
|
||||
void teardown() { printf("teardown\n"); }
|
||||
|
||||
Test(basic, setup_teardown, .init = setup, .fini = teardown) {
|
||||
cr_assert(true);
|
||||
}
|
||||
|
||||
Test(basic, signal, .signal = SIGSEGV) {
|
||||
|
||||
int arr[2] = {1, 2};
|
||||
arr[2] = 3;
|
||||
}
|
||||
|
||||
Test(basic, noSignal) {
|
||||
|
||||
int arr[2] = {1, 2};
|
||||
arr[2] = 3;
|
||||
}
|
||||
|
||||
Test(basic, fail) { cr_fail("this test will always fail until.."); }
|
||||
|
||||
Test(basic, pass) { cr_skip("feature is not implemented"); }
|
||||
|
||||
struct thing {
|
||||
int *param;
|
||||
};
|
||||
|
||||
Test(basic, memory) {
|
||||
struct thing thing1 = {.param = cr_malloc(sizeof(int))};
|
||||
|
||||
// run tests...
|
||||
cr_free(thing1.param);
|
||||
}
|
||||
|
||||
Test(math, add) { cr_assert(add(1, 1) == 2); }
|
||||
Test(math, sub) { cr_assert(subtract(5, 10) == -5); }
|
||||
Test(math, mulitpy) { cr_assert(mulitply(2, 3) == 6); }
|
||||
Test(math, sqrt25) { cr_assert(squareRoot(25) == 5.0); }
|
||||
Test(math, sqrt2) {
|
||||
double res = squareRoot(2);
|
||||
printf("sqrt2 == %.5f\n", res);
|
||||
cr_assert(epsilon_eq(flt, res, 1.4142135, 0.00001));
|
||||
}
|
||||
Reference in New Issue
Block a user