Esempio n. 1
0
/**
* Test if there is no overflow using 16 bits with absLong function.
*/
bool absLongTest(void) {
    signed long value = 40000;
    signed long absValue = absLong(value);

    return assertLongEquals(value, absValue, "");

    /*    
    appendCRLF(getDebugOutputStreamLogger());
    appendString(getDebugOutputStreamLogger(), "absLongTest\n");
    appendString(getDebugOutputStreamLogger(), "NORMAL=");
    appendDec(getDebugOutputStreamLogger(), value);
    appendCRLF(getDebugOutputStreamLogger());

    appendString(getDebugOutputStreamLogger(), "RESULT=");
    appendDec(getDebugOutputStreamLogger(), absValue);
    appendCRLF(getDebugOutputStreamLogger());
    */

}
Esempio n. 2
0
void checkCoders() {
	int i;
	for (i=0; i<MAX_CODERS; i++) {
		if (!checkCodersFlags[i]) {
			continue;
		}
	
		checkCodersFlags[i]=FALSE;

		long position;
		long initial;
		long position2;
		long initial2;
		
		do
		{
			position=lastZPositions[i];
			initial=initialPositions[i];
			position2=lastZPositions[i];
			initial2=initialPositions[i];
		} while ((position != position2) || (initial != initial2));

		position %= CODERS_RESOLUTION;
		if (position<0) {
			position += CODERS_RESOLUTION;
		}
		initial %= CODERS_RESOLUTION;
		if (initial<0) {
			initial += CODERS_RESOLUTION;
		}
		long diff=position-initial;
		if ((diff < -CODERS_ERROR) || (diff > CODERS_ERROR)) {
			codersErrorCounts[i]++;
			codersErrorValues[i] += absLong(diff);
			initialPositions[i]=0;
		}
	}
}
Esempio n. 3
0
void test_absLong(void) {
    long actual = absLong(-1);
    TEST_ASSERT_EQUAL(1, actual);

    actual = absLong(0);
    TEST_ASSERT_EQUAL(0, actual);

    actual = absLong(254);
    TEST_ASSERT_EQUAL(254, actual);

    actual = absLong(-65536);
    TEST_ASSERT_EQUAL(65536, actual);

    actual = absLong(2147483647);
    TEST_ASSERT_EQUAL(2147483647, actual);

    actual = absLong(-2147483647);
    TEST_ASSERT_EQUAL(2147483647, actual);
}