Пример #1
0
void test_SubUsecOflow() {
	int i = -4;
	for (i = -4; i <= 4; ++i) {
		struct timeval a = timeval_init(i, 100);
		struct timeval E = timeval_init(i - 1, 200);
		struct timeval c;

		c = sub_tval_us(a, MICROSECONDS - 100);
		TEST_ASSERT_EQUAL_timeval(E, c);
	}
}
Пример #2
0
void test_AddUsecOflow1() {
	int i;
	for (i = -4; i <= 4; ++i) {
		struct timeval a = timeval_init(i, 200);
		struct timeval E = timeval_init(i + 1, 100);
		struct timeval c;

		c = add_tval_us(a, MICROSECONDS - 100);
		TEST_ASSERT_EQUAL_timeval(E, c);
	}
}
Пример #3
0
void test_SubUsecNorm() {
	int i = -4;
	for (i = -4; i <= 4; ++i) {
		struct timeval a = timeval_init(i, 600);
		struct timeval E = timeval_init(i, 200);
		struct timeval c;

		c = sub_tval_us(a, 600 - 200);
		TEST_ASSERT_EQUAL_timeval(E, c);
	}
}
Пример #4
0
void
test_AddUsecNorm(void) {
	int i;
	for (i = -4; i <= 4; ++i) {
		struct timeval a = timeval_init(i, 200);
		struct timeval E = timeval_init(i, 600);
		struct timeval c;

		c = add_tval_us(a, 600 - 200);
		TEST_ASSERT_EQUAL_timeval(E, c);
	}
}
Пример #5
0
void test_SubFullOflow() {
	int i,j;
	for (i = -4; i <= 4; ++i)
		for (j = -4; j <= 4; ++j) {
			struct timeval a = timeval_init(i, 100);
			struct timeval b = timeval_init(j, 999900);
			struct timeval E = timeval_init(i - j - 1, 200);
			struct timeval c;

			c = sub_tval(a, b);
			TEST_ASSERT_EQUAL_timeval(E, c);
		}
}
Пример #6
0
void test_SubFullNorm() {
	int i,j;
	for (i = -4; i <= 4; ++i)
		for (j = -4; j <= 4; ++j) {
			struct timeval a = timeval_init(i, 600);
			struct timeval b = timeval_init(j, 400);
			struct timeval E = timeval_init(i - j, 600 - 400);
			struct timeval c;

			c = sub_tval(a, b);
			TEST_ASSERT_EQUAL_timeval(E, c);
		}
}
Пример #7
0
void test_AddFullOflow1() {
	int i,j;
	for (i = -4; i <= 4; ++i)
		for (j = -4; j <= 4; ++j) {
			struct timeval a = timeval_init(i, 200);
			struct timeval b = timeval_init(j, 999900);
			struct timeval E = timeval_init(i + j + 1, 100);
			struct timeval c;

			c = add_tval(a, b);
			TEST_ASSERT_EQUAL_timeval(E, c);
		}
}
Пример #8
0
// usec -> frac -> usec roundtrip, using a prime start and increment
void test_LFProundtrip() {
	int32_t t = -1;
	u_int32 i = 5;
	for (t = -1; t < 2; ++t)
		for (i = 5; i < 1000000; i+=11) {
			struct timeval E = timeval_init(t, i);
			l_fp a;
			struct timeval r;

			a = tval_intv_to_lfp(E);
			r = lfp_intv_to_tval(a);
			TEST_ASSERT_EQUAL_timeval(E, r);
		}
}
Пример #9
0
void
test_AddFullNorm(void) {
	int i, j;
	for (i = -4; i <= 4; ++i)
		for (j = -4; j <= 4; ++j) {
			struct timeval a = timeval_init(i, 200);
			struct timeval b = timeval_init(j, 400);
			struct timeval E = timeval_init(i + j, 200 + 400);
			struct timeval c;

			c = add_tval(a, b);
			TEST_ASSERT_EQUAL_timeval(E, c);
		}
}