22 gettimeofday(&date,
NULp);
25 struct timespec local;
26 TIMEVAL_TO_TIMESPEC(&date, &local);
27 p = localtime(&local.tv_sec);
29 p = localtime(&date.tv_sec);
36 const char *date_string =
NULp;
37 #if defined(UNIT_TESTS)
39 date_string =
"Thu Nov 29 22:33:09 1973";
46 char *cr = strchr(readable,
'\n');
56 const unsigned SUFFIXLEN = 8+1+6;
57 static char buffer[SUFFIXLEN+1];
60 #if defined(ASSERTION_USED)
63 strftime(buffer, SUFFIXLEN+1,
"%Y%m%d_%H%M%S", p);
65 buffer[SUFFIXLEN] = 0;
77 stringKeeper.
keep(str);
99 #define TEST_EXPECT_HEAPCOPY_EQUAL(copy,expected) do { \
100 char *theCopy = (copy); \
101 TEST_EXPECT_EQUAL(theCopy, expected); \
105 void TEST_arbtest_strf() {
112 void TEST_arbtest_readable() {
131 TEST_EXPECT_HEAPCOPY_EQUAL(
val2readable(
make_copy(
"some\ntext\twhich\"special\\chars")),
"\"some\\ntext\\twhich\\\"special\\\\chars\"");
132 TEST_EXPECT_HEAPCOPY_EQUAL(
val2readable(
make_copy(
"a\x01\x02\x07\x08\x09\x0b\x0c\x0d\x1a\x22\x27\x5c\x7e\x7f\x80\xfe\xff")),
133 "\"a\\1\\2\\a\\b\\t\\v\\f\\r\\x1a\\\"'\\\\~\\x7f\\x80\\xfe\\xff\"");
143 void TEST_arbtest_copyable() {
147 const char *
s =
"servas";
153 #define TEST_DESCRIPTIONS(d, tt, tf, ft, ff) do { \
154 TEST_EXPECT_EQUAL((d).make(true, true), (tt)); \
155 TEST_EXPECT_EQUAL((d).make(true, false), (tf)); \
156 TEST_EXPECT_EQUAL((d).make(false, true), (ft)); \
157 TEST_EXPECT_EQUAL((d).make(false, false), (ff)); \
160 #define TEST_SIMPLE_DESCRIPTIONS(d, ae, nae) TEST_DESCRIPTIONS(d, ae, nae, ae, nae)
162 void TEST_arbtest_predicate_description() {
167 "equals",
"doesnt equal",
168 "doesnt differ",
"differs");
171 "is less_than",
"isnt less_than",
172 "isnt more_than",
"is more_than");
175 void TEST_arbtest_expectations() {
179 string apple =
"Apfel";
180 string pear =
"Birne";
181 string boskop = apple;
182 string pomegranate =
"Granatapfel";
238 void TEST_expectation_groups() {
253 TEST_EXPECT(
all().ofgroup(unfulfilled_expectation).unfulfilled());
255 TEST_EXPECT(
all().ofgroup(some_fulfilled_expectations).unfulfilled());
256 TEST_EXPECT(
none().ofgroup(some_fulfilled_expectations).unfulfilled());
259 void TEST_replace_old_TEST_EXPECTS_by_expectations() {
262 const char *car_ccp =
"Alfa";
264 string car_str(
"Alfa");
295 short unsigned su = 7;
301 long unsigned lu = (
long unsigned)INT_MAX+3;
329 user_type(
int X,
int Y) : x(X), y(Y) {}
331 int get_x()
const {
return x; }
332 int get_y()
const {
return y; }
334 user_type flipped()
const {
return user_type(y,x); }
336 int quadrant()
const {
337 if (x == 0 || y == 0)
return 0;
338 if (y>0)
return x<0 ? 2 : 1;
345 inline bool operator == (
const user_type& u1,
const user_type& u2) {
return u1.get_x() == u2.get_x() && u1.get_y() == u2.get_y(); }
347 inline bool in_same_quadrant(
const user_type& u1,
const user_type& u2) {
return u1.quadrant() == u2.quadrant(); }
349 void TEST_user_type_with_expectations() {
351 user_type ut12(4, 4);
352 user_type ut2(-4, 4);
353 user_type ut3(-4, -8);
354 user_type ut4(4, -8);
367 void TEST_similarity() {
370 double d2 = d1-epsilon*0.6;
371 double d3 = d1+epsilon*0.6;
381 void TEST_less_equal() {
406 readModified(
int v) : val(v) {}
407 void set(
int n) { val = n; }
408 int getAndMod(
int n) {
415 #if !defined(__clang__)
417 void TEST_single_eval() {
440 void TEST_MyEnum_loop() {
441 int loops_performed = 0;
442 const char *db_name[]= {
NULp,
"TEST_trees.arb",
"TEST_realign.arb",
"TEST_realign.arb",
NULp };
443 for (
int iat = MY_RNA; iat<=MY_AA; ++iat) {
444 MyEnum at = MyEnum(iat);
446 fprintf(stderr,
"at=%i db_name[%i]='%s'\n", at, at, db_name[at]);
454 void TEST_ARB_strchrnul() {
455 const char *check =
"check";
473 static const char *keepOne(
char *s) {
474 static char *s2 =
NULp;
479 #define TEST_EXPECT_STRPARTDUP_TO(start,end,expected) TEST_EXPECT_EQUAL(keepOne(ARB_strpartdup(start,end)),expected)
480 #define TEST_EXPECT_STRNDUP_TO(start,len,expected) TEST_EXPECT_EQUAL(keepOne(ARB_strndup(start,len)),expected)
482 void TEST_string_duppers() {
483 const char *text =
"text";
484 const char *empty =
"";
486 TEST_EXPECT_STRPARTDUP_TO(text, text+4, text);
487 TEST_EXPECT_STRPARTDUP_TO(text, text+3, text);
488 TEST_EXPECT_STRPARTDUP_TO(text, text,
"t");
489 TEST_EXPECT_STRPARTDUP_TO(text, text-1, empty);
492 TEST_EXPECT_STRPARTDUP_TO(text,
NULp, text);
493 TEST_EXPECT_STRPARTDUP_TO(empty,
NULp, empty);
495 TEST_EXPECT_STRNDUP_TO(text, 5, text);
496 TEST_EXPECT_STRNDUP_TO(text, 4, text);
497 TEST_EXPECT_STRNDUP_TO(text, 1,
"t");
498 TEST_EXPECT_STRNDUP_TO(text, 0, empty);
509 TEST_EXPECT_STRPARTDUP_TO(
NULp, empty,
NULp);
510 TEST_EXPECT_STRPARTDUP_TO(
NULp, text,
NULp);
#define is_more_than(val)
#define is_less_than(val)
#define TEST_EXPECT_SIMILAR(expr, want, epsilon)
const char * ARB_keep_string(char *str)
char * ARB_strdup(const char *str)
copy< T > make_copy(const T &t)
const char * ARB_date_string()
char * strf(const char *format,...) __ATTR__FORMAT(1)
#define TEST_EXPECT_LESS_EQUAL(val, ref)
char * ARB_strpartdup(const char *start, const char *end)
char buffer[MESSAGE_BUFFERSIZE]
#define TEST_EXPECT_IN_RANGE__BROKEN(val, lower, higher)
const char * ARB_dateTime_suffix()
#define TEST_PUBLISH(testfunction)
#define TEST_EXPECT_CONTAINS(str, part)
#define TEST_EXPECT(cond)
match_expectation wrong(const expectation &e)
#define does_differ_from(val)
#define TEST_EXPECT_EQUAL__BROKEN(expr, want, got)
#define is_less_or_equal(val)
#define TEST_REJECT_NULL(n)
#define TEST_EXPECT_LESS(val, ref)
#define TEST_EXPECT_ZERO(cond)
#define TEST_EXPECTATION(EXPCTN)
group_matcher exactly(int amount)
group_matcher atleast(int min)
#define TEST_EXPECT_NULL(n)
char * val2readable(bool b)
str readable(const copy< T > &v)
char * ARB_strndup(const char *start, int len)
#define fulfills(pred, arg)
#define TEST_EXPECT_IN_RANGE(val, lower, higher)
bool operator==(const PosGene &a, const PosGene &b)
const char * ARB_strchrnul(const char *str, int chr)
#define contradicts(pred, arg)
static char * strf(const char *format,...) __attribute__((format(__printf__
#define is_more_or_equal(val)
group_matcher atmost(int max)
#define TEST_EXPECT_EQUAL(expr, want)
GB_write_int const char s