/* ========================================== Unity Project - A Test Framework for C Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams [Released under MIT License. Please refer to license.txt for details] ========================================== */ #include "unity.h" #define TEST_INSTANCES #include "self_assessment_utils.h" static int SetToOneToFailInTearDown; static int SetToOneMeanWeAlreadyCheckedThisGuy; void setUp(void) { SetToOneToFailInTearDown = 0; SetToOneMeanWeAlreadyCheckedThisGuy = 0; } void tearDown(void) { endPutcharSpy(); /* Stop suppressing test output */ if (SetToOneToFailInTearDown == 1) { /* These will be skipped internally if already failed/ignored */ TEST_FAIL_MESSAGE("<= Failed in tearDown"); TEST_IGNORE_MESSAGE("<= Ignored in tearDown"); } if ((SetToOneMeanWeAlreadyCheckedThisGuy == 0) && (Unity.CurrentTestFailed > 0)) { UnityPrint(": [[[[ Test Should Have Passed But Did Not ]]]]"); UNITY_OUTPUT_CHAR('\n'); } } void testDoublesWithinDelta(void) { #ifdef UNITY_EXCLUDE_DOUBLE TEST_IGNORE(); #else TEST_ASSERT_DOUBLE_WITHIN(0.00003, 187245.03485, 187245.03488); TEST_ASSERT_DOUBLE_WITHIN(1.0, 187245.0, 187246.0); TEST_ASSERT_DOUBLE_WITHIN(0.05, 9273.2549, 9273.2049); TEST_ASSERT_DOUBLE_WITHIN(0.007, -726.93725, -726.94424); EXPECT_ABORT_BEGIN TEST_ASSERT_DOUBLE_NOT_WITHIN(0.05, 9273.2549, 9273.2049); VERIFY_FAILS_END #endif } void testDoublesNotWithinDelta(void) { #ifdef UNITY_EXCLUDE_DOUBLE TEST_IGNORE(); #else TEST_ASSERT_DOUBLE_NOT_WITHIN(0.05, 9273.2649, 9273.2049); EXPECT_ABORT_BEGIN TEST_ASSERT_DOUBLE_WITHIN(0.05, 9273.2649, 9273.2049); VERIFY_FAILS_END #endif } void testDoublesEqual(void) { #ifdef UNITY_EXCLUDE_DOUBLE TEST_IGNORE(); #else TEST_ASSERT_EQUAL_DOUBLE(187245123456.0, 187245123456.0); TEST_ASSERT_EQUAL_DOUBLE(187241234567.5, 187241234567.6); TEST_ASSERT_EQUAL_DOUBLE(9273.2512345649, 9273.25123455699); TEST_ASSERT_EQUAL_DOUBLE(-726.12345693724, -726.1234569374); EXPECT_ABORT_BEGIN TEST_ASSERT_NOT_EQUAL_DOUBLE(-726.12345693724, -726.1234569374); VERIFY_FAILS_END #endif } void testDoublesNotEqual(void) { #ifdef UNITY_EXCLUDE_DOUBLE TEST_IGNORE(); #else TEST_ASSERT_NOT_EQUAL_DOUBLE(9273.9649, 9273.0049); EXPECT_ABORT_BEGIN TEST_ASSERT_EQUAL_DOUBLE(9273.9649, 9273.0049); VERIFY_FAILS_END #endif } void testDoublesNotEqualNegative1(void) { #ifdef UNITY_EXCLUDE_DOUBLE TEST_IGNORE(); #else TEST_ASSERT_NOT_EQUAL_DOUBLE(-9273.9649, -9273.0049); EXPECT_ABORT_BEGIN TEST_ASSERT_EQUAL_DOUBLE(-9273.9649, -9273.0049); VERIFY_FAILS_END #endif } void testDoublesNotEqualNegative2(void) { #ifdef UNITY_EXCLUDE_DOUBLE TEST_IGNORE(); #else TEST_ASSERT_NOT_EQUAL_DOUBLE(-9273.0049, -9273.9649); EXPECT_ABORT_BEGIN TEST_ASSERT_EQUAL_DOUBLE(-9273.0049, -9273.9649); VERIFY_FAILS_END #endif } void testDoublesNotEqualActualNaN(void) { #ifdef UNITY_EXCLUDE_DOUBLE TEST_IGNORE(); #else TEST_ASSERT_NOT_EQUAL_DOUBLE(85.963, 0.0 / d_zero); EXPECT_ABORT_BEGIN TEST_ASSERT_EQUAL_DOUBLE(85.963, 0.0 / d_zero); VERIFY_FAILS_END #endif } void testDoublesNotEqualExpectedNaN(void) { #ifdef UNITY_EXCLUDE_DOUBLE TEST_IGNORE(); #else TEST_ASSERT_NOT_EQUAL_DOUBLE(0.0 / d_zero, 85.963); EXPECT_ABORT_BEGIN TEST_ASSERT_EQUAL_DOUBLE(0.0 / d_zero, 85.963); VERIFY_FAILS_END #endif } void testDoublesEqualBothNaN(void) { #ifdef UNITY_EXCLUDE_DOUBLE TEST_IGNORE(); #else TEST_ASSERT_EQUAL_DOUBLE(0.0 / d_zero, 0.0 / d_zero); EXPECT_ABORT_BEGIN TEST_ASSERT_NOT_EQUAL_DOUBLE(0.0 / d_zero, 0.0 / d_zero); VERIFY_FAILS_END #endif } void testDoublesNotEqualInfNaN(void) { #ifdef UNITY_EXCLUDE_DOUBLE TEST_IGNORE(); #else TEST_ASSERT_NOT_EQUAL_DOUBLE(1.0 / d_zero, 0.0 / d_zero); EXPECT_ABORT_BEGIN TEST_ASSERT_EQUAL_DOUBLE(1.0 / d_zero, 0.0 / d_zero); VERIFY_FAILS_END #endif } void testDoublesNotEqualNaNInf(void) { #ifdef UNITY_EXCLUDE_DOUBLE TEST_IGNORE(); #else TEST_ASSERT_NOT_EQUAL_DOUBLE(0.0 / d_zero, 1.0 / d_zero); EXPECT_ABORT_BEGIN TEST_ASSERT_EQUAL_DOUBLE(0.0 / d_zero, 1.0 / d_zero); VERIFY_FAILS_END #endif } void testDoublesNotEqualActualInf(void) { #ifdef UNITY_EXCLUDE_DOUBLE TEST_IGNORE(); #else TEST_ASSERT_NOT_EQUAL_DOUBLE(321.642, 1.0 / d_zero); EXPECT_ABORT_BEGIN TEST_ASSERT_EQUAL_DOUBLE(321.642, 1.0 / d_zero); VERIFY_FAILS_END #endif } void testDoublesNotEqualExpectedInf(void) { #ifdef UNITY_EXCLUDE_DOUBLE TEST_IGNORE(); #else TEST_ASSERT_NOT_EQUAL_DOUBLE(1.0 / d_zero, 321.642); EXPECT_ABORT_BEGIN TEST_ASSERT_EQUAL_DOUBLE(1.0 / d_zero, 321.642); VERIFY_FAILS_END #endif } void testDoublesEqualBothInf(void) { #ifdef UNITY_EXCLUDE_DOUBLE TEST_IGNORE(); #else TEST_ASSERT_EQUAL_DOUBLE(1.0 / d_zero, 1.0 / d_zero); EXPECT_ABORT_BEGIN TEST_ASSERT_NOT_EQUAL_DOUBLE(1.0 / d_zero, 1.0 / d_zero); VERIFY_FAILS_END #endif } void testDoublesNotEqualPlusMinusInf(void) { #ifdef UNITY_EXCLUDE_DOUBLE TEST_IGNORE(); #else TEST_ASSERT_NOT_EQUAL_DOUBLE(1.0 / d_zero, -1.0 / d_zero); EXPECT_ABORT_BEGIN TEST_ASSERT_EQUAL_DOUBLE(1.0 / d_zero, -1.0 / d_zero); VERIFY_FAILS_END #endif } void testDoublesGreaterThan(void) { #ifdef UNITY_EXCLUDE_DOUBLE TEST_IGNORE(); #else TEST_ASSERT_GREATER_THAN_DOUBLE(1.0, 2.0); TEST_ASSERT_GREATER_THAN_DOUBLE(-1.0, 1.0); TEST_ASSERT_GREATER_THAN_DOUBLE(-2.0, -1.0); #endif } void testDoublesGreaterThanInf(void) { #ifdef UNITY_EXCLUDE_DOUBLE TEST_IGNORE(); #else TEST_ASSERT_GREATER_THAN_DOUBLE(1.0, 1.0 / d_zero); TEST_ASSERT_GREATER_THAN_DOUBLE(-1.0 / d_zero, 1.0 / d_zero); TEST_ASSERT_GREATER_THAN_DOUBLE(-1.0 / d_zero, 1.0); #endif } void testDoublesNotGreaterThan(void) { #ifdef UNITY_EXCLUDE_DOUBLE TEST_IGNORE(); #else EXPECT_ABORT_BEGIN TEST_ASSERT_GREATER_THAN_DOUBLE(2.0, 1.0); VERIFY_FAILS_END #endif } void testDoublesNotGreaterThanNanActual(void) { #ifdef UNITY_EXCLUDE_DOUBLE TEST_IGNORE(); #else EXPECT_ABORT_BEGIN TEST_ASSERT_GREATER_THAN_DOUBLE(1.0, 0.0 / d_zero); VERIFY_FAILS_END #endif } void testDoublesNotGreaterThanNanThreshold(void) { #ifdef UNITY_EXCLUDE_DOUBLE TEST_IGNORE(); #else EXPECT_ABORT_BEGIN TEST_ASSERT_GREATER_THAN_DOUBLE(0.0 / d_zero, 1.0); VERIFY_FAILS_END #endif } void testDoublesNotGreaterThanNanBoth(void) { #ifdef UNITY_EXCLUDE_DOUBLE TEST_IGNORE(); #else EXPECT_ABORT_BEGIN TEST_ASSERT_GREATER_THAN_DOUBLE(0.0 / d_zero, 0.0 / d_zero); VERIFY_FAILS_END #endif } void testDoublesNotGreaterThanInfActual(void) { #ifdef UNITY_EXCLUDE_DOUBLE TEST_IGNORE(); #else EXPECT_ABORT_BEGIN TEST_ASSERT_GREATER_THAN_DOUBLE(1.0 / d_zero, 1.0); VERIFY_FAILS_END #endif } void testDoublesNotGreaterThanNegInf(void) { #ifdef UNITY_EXCLUDE_DOUBLE TEST_IGNORE(); #else EXPECT_ABORT_BEGIN TEST_ASSERT_GREATER_THAN_DOUBLE(1.0, -1.0 / d_zero); VERIFY_FAILS_END #endif } void testDoublesNotGreaterThanBothInf(void) { #ifdef UNITY_EXCLUDE_DOUBLE TEST_IGNORE(); #else EXPECT_ABORT_BEGIN TEST_ASSERT_GREATER_THAN_DOUBLE(1.0 / d_zero, 1.0 / d_zero); VERIFY_FAILS_END #endif } void testDoublesNotGreaterThanBothNegInf(void) { #ifdef UNITY_EXCLUDE_DOUBLE TEST_IGNORE(); #else EXPECT_ABORT_BEGIN TEST_ASSERT_GREATER_THAN_DOUBLE(-1.0 / d_zero, -1.0 / d_zero); VERIFY_FAILS_END #endif } void testDoublesGreaterOrEqual(void) { #ifdef UNITY_EXCLUDE_DOUBLE TEST_IGNORE(); #else TEST_ASSERT_GREATER_OR_EQUAL_DOUBLE(1.0, 2.0); TEST_ASSERT_GREATER_OR_EQUAL_DOUBLE(2.0, 2.0); TEST_ASSERT_GREATER_OR_EQUAL_DOUBLE(-1.0, 1.0); TEST_ASSERT_GREATER_OR_EQUAL_DOUBLE(-2.0, -1.0); TEST_ASSERT_GREATER_OR_EQUAL_DOUBLE(-2.0, -2.0); #endif } void testDoublesGreaterOrEqualInf(void) { #ifdef UNITY_EXCLUDE_DOUBLE TEST_IGNORE(); #else TEST_ASSERT_GREATER_OR_EQUAL_DOUBLE(1.0, 1.0 / d_zero); TEST_ASSERT_GREATER_OR_EQUAL_DOUBLE(-1.0 / d_zero, 1.0 / d_zero); TEST_ASSERT_GREATER_OR_EQUAL_DOUBLE(-1.0 / d_zero, 1.0); #endif } void testDoublesNotGreaterOrEqual(void) { #ifdef UNITY_EXCLUDE_DOUBLE TEST_IGNORE(); #else EXPECT_ABORT_BEGIN TEST_ASSERT_GREATER_OR_EQUAL_DOUBLE(2.0, 1.0); VERIFY_FAILS_END #endif } void testDoublesNotGreaterOrEqualNanActual(void) { #ifdef UNITY_EXCLUDE_DOUBLE TEST_IGNORE(); #else EXPECT_ABORT_BEGIN TEST_ASSERT_GREATER_OR_EQUAL_DOUBLE(1.0, 0.0 / d_zero); VERIFY_FAILS_END #endif } void testDoublesNotGreaterOrEqualNanThreshold(void) { #ifdef UNITY_EXCLUDE_DOUBLE TEST_IGNORE(); #else EXPECT_ABORT_BEGIN TEST_ASSERT_GREATER_OR_EQUAL_DOUBLE(0.0 / d_zero, 1.0); VERIFY_FAILS_END #endif } void testDoublesGreaterOrEqualNanBoth(void) { #ifdef UNITY_EXCLUDE_DOUBLE TEST_IGNORE(); #else TEST_ASSERT_GREATER_OR_EQUAL_DOUBLE(0.0 / d_zero, 0.0 / d_zero); #endif } void testDoublesNotGreaterOrEqualInfActual(void) { #ifdef UNITY_EXCLUDE_DOUBLE TEST_IGNORE(); #else EXPECT_ABORT_BEGIN TEST_ASSERT_GREATER_OR_EQUAL_DOUBLE(1.0 / d_zero, 1.0); VERIFY_FAILS_END #endif } void testDoublesNotGreaterOrEqualNegInf(void) { #ifdef UNITY_EXCLUDE_DOUBLE TEST_IGNORE(); #else EXPECT_ABORT_BEGIN TEST_ASSERT_GREATER_OR_EQUAL_DOUBLE(1.0, -1.0 / d_zero); VERIFY_FAILS_END #endif } void testDoublesGreaterOrEqualBothInf(void) { #ifdef UNITY_EXCLUDE_DOUBLE TEST_IGNORE(); #else TEST_ASSERT_GREATER_OR_EQUAL_DOUBLE(1.0 / d_zero, 1.0 / d_zero); #endif } void testDoublesGreaterOrEqualBothNegInf(void) { #ifdef UNITY_EXCLUDE_DOUBLE TEST_IGNORE(); #else TEST_ASSERT_GREATER_OR_EQUAL_DOUBLE(-1.0 / d_zero, -1.0 / d_zero); #endif } void testDoublesLessThan(void) { #ifdef UNITY_EXCLUDE_DOUBLE TEST_IGNORE(); #else TEST_ASSERT_LESS_THAN_DOUBLE(2.0, 1.0); TEST_ASSERT_LESS_THAN_DOUBLE(1.0, -1.0); TEST_ASSERT_LESS_THAN_DOUBLE(-1.0, -2.0); #endif } void testDoublesLessThanInf(void) { #ifdef UNITY_EXCLUDE_DOUBLE TEST_IGNORE(); #else TEST_ASSERT_LESS_THAN_DOUBLE(1.0 / d_zero, 1.0); TEST_ASSERT_LESS_THAN_DOUBLE(1.0 / d_zero, -1.0 / d_zero); TEST_ASSERT_LESS_THAN_DOUBLE(1.0, -1.0 / d_zero); #endif } void testDoublesNotLessThan(void) { #ifdef UNITY_EXCLUDE_DOUBLE TEST_IGNORE(); #else EXPECT_ABORT_BEGIN TEST_ASSERT_LESS_THAN_DOUBLE(1.0, 2.0); VERIFY_FAILS_END #endif } void testDoublesNotLessThanNanActual(void) { #ifdef UNITY_EXCLUDE_DOUBLE TEST_IGNORE(); #else EXPECT_ABORT_BEGIN TEST_ASSERT_LESS_THAN_DOUBLE(1.0, 0.0 / d_zero); VERIFY_FAILS_END #endif } void testDoublesNotLessThanNanThreshold(void) { #ifdef UNITY_EXCLUDE_DOUBLE TEST_IGNORE(); #else EXPECT_ABORT_BEGIN TEST_ASSERT_LESS_THAN_DOUBLE(0.0 / d_zero, 1.0); VERIFY_FAILS_END #endif } void testDoublesNotLessThanNanBoth(void) { #ifdef UNITY_EXCLUDE_DOUBLE TEST_IGNORE(); #else EXPECT_ABORT_BEGIN TEST_ASSERT_LESS_THAN_DOUBLE(0.0 / d_zero, 0.0 / d_zero); VERIFY_FAILS_END #endif } void testDoublesNotLessThanInf(void) { #ifdef UNITY_EXCLUDE_DOUBLE TEST_IGNORE(); #else EXPECT_ABORT_BEGIN TEST_ASSERT_LESS_THAN_DOUBLE(1.0, 1.0 / d_zero); VERIFY_FAILS_END #endif } void testDoublesNotLessThanNegInf(void) { #ifdef UNITY_EXCLUDE_DOUBLE TEST_IGNORE(); #else EXPECT_ABORT_BEGIN TEST_ASSERT_LESS_THAN_DOUBLE(-1.0 / d_zero, 1.0); VERIFY_FAILS_END #endif } void testDoublesNotLessThanBothInf(void) { #ifdef UNITY_EXCLUDE_DOUBLE TEST_IGNORE(); #else EXPECT_ABORT_BEGIN TEST_ASSERT_LESS_THAN_DOUBLE(1.0 / d_zero, 1.0 / d_zero); VERIFY_FAILS_END #endif } void testDoublesNotLessThanBothNegInf(void) { #ifdef UNITY_EXCLUDE_DOUBLE TEST_IGNORE(); #else EXPECT_ABORT_BEGIN TEST_ASSERT_LESS_THAN_DOUBLE(-1.0 / d_zero, -1.0 / d_zero); VERIFY_FAILS_END #endif } void testDoublesLessOrEqual(void) { #ifdef UNITY_EXCLUDE_DOUBLE TEST_IGNORE(); #else TEST_ASSERT_LESS_OR_EQUAL_DOUBLE(2.0, 1.0); TEST_ASSERT_LESS_OR_EQUAL_DOUBLE(2.0, 2.0); TEST_ASSERT_LESS_OR_EQUAL_DOUBLE(1.0, -1.0); TEST_ASSERT_LESS_OR_EQUAL_DOUBLE(-1.0, -2.0); TEST_ASSERT_LESS_OR_EQUAL_DOUBLE(-2.0, -2.0); #endif } void testDoublesLessOrEqualInf(void) { #ifdef UNITY_EXCLUDE_DOUBLE TEST_IGNORE(); #else TEST_ASSERT_LESS_OR_EQUAL_DOUBLE(1.0 / d_zero, 1.0); TEST_ASSERT_LESS_OR_EQUAL_DOUBLE(1.0 / d_zero, -1.0 / d_zero); TEST_ASSERT_LESS_OR_EQUAL_DOUBLE(1.0, -1.0 / d_zero); #endif } void testDoublesNotLessOrEqual(void) { #ifdef UNITY_EXCLUDE_DOUBLE TEST_IGNORE(); #else EXPECT_ABORT_BEGIN TEST_ASSERT_LESS_OR_EQUAL_DOUBLE(1.0, 2.0); VERIFY_FAILS_END #endif } void testDoublesNotLessOrEqualNanActual(void) { #ifdef UNITY_EXCLUDE_DOUBLE TEST_IGNORE(); #else EXPECT_ABORT_BEGIN TEST_ASSERT_LESS_OR_EQUAL_DOUBLE(1.0, 0.0 / d_zero); VERIFY_FAILS_END #endif } void testDoublesNotLessOrEqualNanThreshold(void) { #ifdef UNITY_EXCLUDE_DOUBLE TEST_IGNORE(); #else EXPECT_ABORT_BEGIN TEST_ASSERT_LESS_OR_EQUAL_DOUBLE(0.0 / d_zero, 1.0); VERIFY_FAILS_END #endif } void testDoublesLessOrEqualNanBoth(void) { #ifdef UNITY_EXCLUDE_DOUBLE TEST_IGNORE(); #else TEST_ASSERT_LESS_OR_EQUAL_DOUBLE(0.0 / d_zero, 0.0 / d_zero); #endif } void testDoublesNotLessOrEqualInf(void) { #ifdef UNITY_EXCLUDE_DOUBLE TEST_IGNORE(); #else EXPECT_ABORT_BEGIN TEST_ASSERT_LESS_OR_EQUAL_DOUBLE(1.0, 1.0 / d_zero); VERIFY_FAILS_END #endif } void testDoublesNotLessOrEqualNegInf(void) { #ifdef UNITY_EXCLUDE_DOUBLE TEST_IGNORE(); #else EXPECT_ABORT_BEGIN TEST_ASSERT_LESS_OR_EQUAL_DOUBLE(-1.0 / d_zero, 1.0); VERIFY_FAILS_END #endif } void testDoublesLessOrEqualBothInf(void) { #ifdef UNITY_EXCLUDE_DOUBLE TEST_IGNORE(); #else TEST_ASSERT_LESS_OR_EQUAL_DOUBLE(1.0 / d_zero, 1.0 / d_zero); #endif } void testDoublesLessOrEqualBothNegInf(void) { #ifdef UNITY_EXCLUDE_DOUBLE TEST_IGNORE(); #else TEST_ASSERT_LESS_OR_EQUAL_DOUBLE(-1.0 / d_zero, -1.0 / d_zero); #endif } void testDoubleIsPosInf1(void) { #ifdef UNITY_EXCLUDE_DOUBLE TEST_IGNORE(); #else TEST_ASSERT_DOUBLE_IS_INF(2.0 / d_zero); #endif } void testDoubleIsPosInf2(void) { #ifdef UNITY_EXCLUDE_DOUBLE TEST_IGNORE(); #else EXPECT_ABORT_BEGIN TEST_ASSERT_DOUBLE_IS_NOT_INF(2.0 / d_zero); VERIFY_FAILS_END #endif } void testDoubleIsNegInf1(void) { #ifdef UNITY_EXCLUDE_DOUBLE TEST_IGNORE(); #else TEST_ASSERT_DOUBLE_IS_NEG_INF(-3.0 / d_zero); #endif } void testDoubleIsNegInf2(void) { #ifdef UNITY_EXCLUDE_DOUBLE TEST_IGNORE(); #else EXPECT_ABORT_BEGIN TEST_ASSERT_DOUBLE_IS_NOT_NEG_INF(-3.0 / d_zero); VERIFY_FAILS_END #endif } void testDoubleIsNotPosInf1(void) { #ifdef UNITY_EXCLUDE_DOUBLE TEST_IGNORE(); #else EXPECT_ABORT_BEGIN TEST_ASSERT_DOUBLE_IS_INF(2.0); VERIFY_FAILS_END #endif } void testDoubleIsNotPosInf2(void) { #ifdef UNITY_EXCLUDE_DOUBLE TEST_IGNORE(); #else TEST_ASSERT_DOUBLE_IS_NOT_INF(2.0); #endif } void testDoubleIsNotNegInf(void) { #ifdef UNITY_EXCLUDE_DOUBLE TEST_IGNORE(); #else EXPECT_ABORT_BEGIN TEST_ASSERT_DOUBLE_IS_NEG_INF(-999.876); VERIFY_FAILS_END #endif } void testDoubleIsNan1(void) { #ifdef UNITY_EXCLUDE_DOUBLE TEST_IGNORE(); #else TEST_ASSERT_DOUBLE_IS_NAN(0.0 / d_zero); #endif } void testDoubleIsNan2(void) { #ifdef UNITY_EXCLUDE_DOUBLE TEST_IGNORE(); #else EXPECT_ABORT_BEGIN TEST_ASSERT_DOUBLE_IS_NOT_NAN(0.0 / d_zero); VERIFY_FAILS_END #endif } void testDoubleIsNotNan1(void) { #ifdef UNITY_EXCLUDE_DOUBLE TEST_IGNORE(); #else EXPECT_ABORT_BEGIN TEST_ASSERT_DOUBLE_IS_NAN(234.9); VERIFY_FAILS_END #endif } void testDoubleIsNotNan2(void) { #ifdef UNITY_EXCLUDE_DOUBLE TEST_IGNORE(); #else TEST_ASSERT_DOUBLE_IS_NOT_NAN(234.9); #endif } void testDoubleInfIsNotNan(void) { #ifdef UNITY_EXCLUDE_DOUBLE TEST_IGNORE(); #else EXPECT_ABORT_BEGIN TEST_ASSERT_DOUBLE_IS_NAN(1.0 / d_zero); VERIFY_FAILS_END #endif } void testDoubleNanIsNotInf(void) { #ifdef UNITY_EXCLUDE_DOUBLE TEST_IGNORE(); #else EXPECT_ABORT_BEGIN TEST_ASSERT_DOUBLE_IS_INF(0.0 / d_zero); VERIFY_FAILS_END #endif } void testDoubleIsDeterminate1(void) { #ifdef UNITY_EXCLUDE_DOUBLE TEST_IGNORE(); #else TEST_ASSERT_DOUBLE_IS_DETERMINATE(0.0); TEST_ASSERT_DOUBLE_IS_DETERMINATE(123.3); TEST_ASSERT_DOUBLE_IS_DETERMINATE(-88.3); #endif } void testDoubleIsDeterminate2(void) { #ifdef UNITY_EXCLUDE_DOUBLE TEST_IGNORE(); #else EXPECT_ABORT_BEGIN TEST_ASSERT_DOUBLE_IS_NOT_DETERMINATE(-88.3); VERIFY_FAILS_END #endif } void testDoubleIsNotDeterminate1(void) { #ifdef UNITY_EXCLUDE_DOUBLE TEST_IGNORE(); #else TEST_ASSERT_DOUBLE_IS_NOT_DETERMINATE(1.0 / d_zero); TEST_ASSERT_DOUBLE_IS_NOT_DETERMINATE(-1.0 / d_zero); TEST_ASSERT_DOUBLE_IS_NOT_DETERMINATE(0.0 / d_zero); #endif } void testDoubleIsNotDeterminate2(void) { #ifdef UNITY_EXCLUDE_DOUBLE TEST_IGNORE(); #else EXPECT_ABORT_BEGIN TEST_ASSERT_DOUBLE_IS_DETERMINATE(-1.0 / d_zero); VERIFY_FAILS_END #endif } void testDoubleTraitFailsOnInvalidTrait(void) { #ifdef UNITY_EXCLUDE_DOUBLE TEST_IGNORE(); #else EXPECT_ABORT_BEGIN UnityAssertDoubleSpecial(1.0, NULL, __LINE__, UNITY_FLOAT_INVALID_TRAIT); VERIFY_FAILS_END #endif } void testEqualDoubleArrays(void) { #ifdef UNITY_EXCLUDE_DOUBLE TEST_IGNORE(); #else double p0[] = {1.0, -8.0, 25.4, -0.123}; double p1[] = {1.0, -8.0, 25.4, -0.123}; double p2[] = {1.0, -8.0, 25.4, -0.2}; double p3[] = {1.0, -23.0, 25.0, -0.26}; TEST_ASSERT_EQUAL_DOUBLE_ARRAY(p0, p0, 1); TEST_ASSERT_EQUAL_DOUBLE_ARRAY(p0, p0, 4); TEST_ASSERT_EQUAL_DOUBLE_ARRAY(p0, p1, 4); TEST_ASSERT_EQUAL_DOUBLE_ARRAY(p0, p2, 3); TEST_ASSERT_EQUAL_DOUBLE_ARRAY(p0, p3, 1); TEST_ASSERT_EQUAL_DOUBLE_ARRAY(NULL, NULL, 1); #endif } void testNotEqualDoubleArraysExpectedNull(void) { #ifdef UNITY_EXCLUDE_DOUBLE TEST_IGNORE(); #else double* p0 = NULL; double p1[] = {1.0, 8.0, 25.4, 0.252}; EXPECT_ABORT_BEGIN TEST_ASSERT_EQUAL_DOUBLE_ARRAY(p0, p1, 4); VERIFY_FAILS_END #endif } void testNotEqualDoubleArraysActualNull(void) { #ifdef UNITY_EXCLUDE_DOUBLE TEST_IGNORE(); #else double p0[] = {1.0, 8.0, 25.4, 0.253}; double* p1 = NULL; EXPECT_ABORT_BEGIN TEST_ASSERT_EQUAL_DOUBLE_ARRAY(p0, p1, 4); VERIFY_FAILS_END #endif } void testNotEqualDoubleArrays1(void) { #ifdef UNITY_EXCLUDE_DOUBLE TEST_IGNORE(); #else double p0[] = {1.0, 8.0, 25.4, 0.25666666667}; double p1[] = {1.0, 8.0, 25.4, 0.25666666666}; EXPECT_ABORT_BEGIN TEST_ASSERT_EQUAL_DOUBLE_ARRAY(p0, p1, 4); VERIFY_FAILS_END #endif } void testNotEqualDoubleArrays2(void) { #ifdef UNITY_EXCLUDE_DOUBLE TEST_IGNORE(); #else double p0[] = {1.0, 8.0, 25.4, 0.253}; double p1[] = {2.0, 8.0, 25.4, 0.253}; EXPECT_ABORT_BEGIN TEST_ASSERT_EQUAL_DOUBLE_ARRAY(p0, p1, 4); VERIFY_FAILS_END #endif } void testNotEqualDoubleArrays3(void) { #ifdef UNITY_EXCLUDE_DOUBLE TEST_IGNORE(); #else double p0[] = {1.0, 8.0, 25.4, 0.253}; double p1[] = {1.0, 8.0, 25.5, 0.253}; EXPECT_ABORT_BEGIN TEST_ASSERT_EQUAL_DOUBLE_ARRAY(p0, p1, 4); VERIFY_FAILS_END #endif } void testNotEqualDoubleArraysNegative1(void) { #ifdef UNITY_EXCLUDE_DOUBLE TEST_IGNORE(); #else double p0[] = {-1.0, -8.0, -25.4, -0.2566666667}; double p1[] = {-1.0, -8.0, -25.4, -0.2566666666}; EXPECT_ABORT_BEGIN TEST_ASSERT_EQUAL_DOUBLE_ARRAY(p0, p1, 4); VERIFY_FAILS_END #endif } void testNotEqualDoubleArraysNegative2(void) { #ifdef UNITY_EXCLUDE_DOUBLE TEST_IGNORE(); #else double p0[] = {-1.0, -8.0, -25.4, -0.253}; double p1[] = {-2.0, -8.0, -25.4, -0.253}; EXPECT_ABORT_BEGIN TEST_ASSERT_EQUAL_DOUBLE_ARRAY(p0, p1, 4); VERIFY_FAILS_END #endif } void testNotEqualDoubleArraysNegative3(void) { #ifdef UNITY_EXCLUDE_DOUBLE TEST_IGNORE(); #else double p0[] = {-1.0, -8.0, -25.4, -0.253}; double p1[] = {-1.0, -8.0, -25.5, -0.253}; EXPECT_ABORT_BEGIN TEST_ASSERT_EQUAL_DOUBLE_ARRAY(p0, p1, 4); VERIFY_FAILS_END #endif } void testEqualDoubleArraysNaN(void) { #ifdef UNITY_EXCLUDE_DOUBLE TEST_IGNORE(); #else double p0[] = {1.0, 0.0 / d_zero, 25.4, 0.253}; double p1[] = {1.0, 0.0 / d_zero, 25.4, 0.253}; TEST_ASSERT_EQUAL_DOUBLE_ARRAY(p0, p1, 4); #endif } void testEqualDoubleArraysInf(void) { #ifdef UNITY_EXCLUDE_DOUBLE TEST_IGNORE(); #else double p0[] = {1.0, 1.0 / d_zero, 25.4, 0.253}; double p1[] = {1.0, 1.0 / d_zero, 25.4, 0.253}; TEST_ASSERT_EQUAL_DOUBLE_ARRAY(p0, p1, 4); #endif } void testNotEqualDoubleArraysLengthZero(void) { #ifdef UNITY_EXCLUDE_DOUBLE TEST_IGNORE(); #else double p0[1] = {0.0}; double p1[1] = {0.0}; EXPECT_ABORT_BEGIN TEST_ASSERT_EQUAL_DOUBLE_ARRAY(p0, p1, 0); VERIFY_FAILS_END #endif } void testDoubleArraysWithin(void) { #ifdef UNITY_EXCLUDE_DOUBLE TEST_IGNORE(); #else double p0[] = {1.0, -8.0, 25.4, -0.123}; double p1[] = {1.0, -8.0, 25.4, -0.123}; double p2[] = {1.0, -8.0, 25.4, -0.2}; double p3[] = {1.0, -23.0, 25.0, -0.26}; double p4[] = {2.0, -9.0, 26.2, 0.26}; double p5[] = {-1.0, -7.0, 29.0, 2.6}; TEST_ASSERT_DOUBLE_ARRAY_WITHIN(1.0, p0, p0, 1); TEST_ASSERT_DOUBLE_ARRAY_WITHIN(1.0, p0, p0, 4); TEST_ASSERT_DOUBLE_ARRAY_WITHIN(1.0, p0, p1, 4); TEST_ASSERT_DOUBLE_ARRAY_WITHIN(1.0, p0, p2, 3); TEST_ASSERT_DOUBLE_ARRAY_WITHIN(1.0, p0, p3, 1); TEST_ASSERT_DOUBLE_ARRAY_WITHIN(1.0, p0, p4, 1); TEST_ASSERT_DOUBLE_ARRAY_WITHIN(1.0, p0, p4, 4); TEST_ASSERT_DOUBLE_ARRAY_WITHIN(2.0, p0, p5, 1); TEST_ASSERT_DOUBLE_ARRAY_WITHIN(2.0, p0, p5, 2); TEST_ASSERT_DOUBLE_ARRAY_WITHIN(1.0, NULL, NULL, 1); #endif } void testDoubleArraysWithinUnusualDelta(void) { #ifdef UNITY_EXCLUDE_DOUBLE TEST_IGNORE(); #else double p0[] = {-INFINITY, -8.0, 25.4, -0.123}; double p1[] = {INFINITY, 10.1}; TEST_ASSERT_DOUBLE_ARRAY_WITHIN(INFINITY, p0, p1, 2); EXPECT_ABORT_BEGIN TEST_ASSERT_DOUBLE_ARRAY_WITHIN(NAN, p0, p0, 4); VERIFY_FAILS_END #endif } void testEqualDoubleEachEqual(void) { #ifdef UNITY_EXCLUDE_DOUBLE TEST_IGNORE(); #else double p0[] = {1.0, 1.0, 1.0, 1.0}; double p1[] = {-0.123, -0.123, -0.123, -0.123}; double p2[] = {25.4, 25.4, 25.4, -0.2}; double p3[] = {1.0, -23.0, 25.0, -0.26}; TEST_ASSERT_EACH_EQUAL_DOUBLE(1.0, p0, 1); TEST_ASSERT_EACH_EQUAL_DOUBLE(1.0, p0, 4); TEST_ASSERT_EACH_EQUAL_DOUBLE(-0.123, p1, 4); TEST_ASSERT_EACH_EQUAL_DOUBLE(25.4, p2, 3); TEST_ASSERT_EACH_EQUAL_DOUBLE(1.0, p3, 1); #endif } void testNotEqualDoubleEachEqualActualNull(void) { #ifdef UNITY_EXCLUDE_DOUBLE TEST_IGNORE(); #else double* p0 = NULL; EXPECT_ABORT_BEGIN TEST_ASSERT_EACH_EQUAL_DOUBLE(5, p0, 4); VERIFY_FAILS_END #endif } void testNotEqualDoubleEachEqual1(void) { #ifdef UNITY_EXCLUDE_DOUBLE TEST_IGNORE(); #else double p0[] = {0.253, 8.0, 0.253, 0.253}; EXPECT_ABORT_BEGIN TEST_ASSERT_EACH_EQUAL_DOUBLE(0.253, p0, 4); VERIFY_FAILS_END #endif } void testNotEqualDoubleEachEqual2(void) { #ifdef UNITY_EXCLUDE_DOUBLE TEST_IGNORE(); #else double p0[] = {8.0, 8.0, 8.0, 0.253}; EXPECT_ABORT_BEGIN TEST_ASSERT_EACH_EQUAL_DOUBLE(8.0, p0, 4); VERIFY_FAILS_END #endif } void testNotEqualDoubleEachEqual3(void) { #ifdef UNITY_EXCLUDE_DOUBLE TEST_IGNORE(); #else double p0[] = {1.0, 1.0, 1.0, 0.253}; EXPECT_ABORT_BEGIN TEST_ASSERT_EACH_EQUAL_DOUBLE(1.0, p0, 4); VERIFY_FAILS_END #endif } void testNotEqualDoubleEachEqualNegative1(void) { #ifdef UNITY_EXCLUDE_DOUBLE TEST_IGNORE(); #else double p0[] = {-1.0, -0.253, -0.253, -0.253}; EXPECT_ABORT_BEGIN TEST_ASSERT_EACH_EQUAL_DOUBLE(-0.253, p0, 4); VERIFY_FAILS_END #endif } void testNotEqualDoubleEachEqualNegative2(void) { #ifdef UNITY_EXCLUDE_DOUBLE TEST_IGNORE(); #else double p0[] = {-25.4, -8.0, -25.4, -25.4}; EXPECT_ABORT_BEGIN TEST_ASSERT_EACH_EQUAL_DOUBLE(-25.4, p0, 4); VERIFY_FAILS_END #endif } void testNotEqualDoubleEachEqualNegative3(void) { #ifdef UNITY_EXCLUDE_DOUBLE TEST_IGNORE(); #else double p0[] = {-8.0, -8.0, -8.0, -0.253}; EXPECT_ABORT_BEGIN TEST_ASSERT_EACH_EQUAL_DOUBLE(-8.0, p0, 4); VERIFY_FAILS_END #endif } void testEqualDoubleEachEqualNaN(void) { #ifdef UNITY_EXCLUDE_DOUBLE TEST_IGNORE(); #else double p0[] = {0.0 / d_zero, 0.0 / d_zero, 0.0 / d_zero, 0.0 / d_zero}; TEST_ASSERT_EACH_EQUAL_DOUBLE(0.0 / d_zero, p0, 4); #endif } void testEqualDoubleEachEqualInf(void) { #ifdef UNITY_EXCLUDE_DOUBLE TEST_IGNORE(); #else double p0[] = {1.0 / d_zero, 1.0 / d_zero, 25.4, 0.253}; TEST_ASSERT_EACH_EQUAL_DOUBLE(1.0 / d_zero, p0, 2); #endif } void testNotEqualDoubleEachEqualLengthZero(void) { #ifdef UNITY_EXCLUDE_DOUBLE TEST_IGNORE(); #else double p0[1] = {0.0}; EXPECT_ABORT_BEGIN TEST_ASSERT_EACH_EQUAL_DOUBLE(0.0, p0, 0); VERIFY_FAILS_END #endif } void testDoublePrinting(void) { #if defined(UNITY_EXCLUDE_FLOAT_PRINT) || defined(UNITY_EXCLUDE_DOUBLE) || !defined(USING_OUTPUT_SPY) TEST_IGNORE(); #else TEST_ASSERT_EQUAL_PRINT_FLOATING("0", 0.0); TEST_ASSERT_EQUAL_PRINT_FLOATING("4.99e-07", 0.000000499); TEST_ASSERT_EQUAL_PRINT_FLOATING("5.0000005e-07", 0.00000050000005); TEST_ASSERT_EQUAL_PRINT_FLOATING("0.100469499", 0.100469499); TEST_ASSERT_EQUAL_PRINT_FLOATING("1", 0.9999999995); /*Rounding to int place*/ TEST_ASSERT_EQUAL_PRINT_FLOATING("1", 1.0); TEST_ASSERT_EQUAL_PRINT_FLOATING("1.25", 1.25); TEST_ASSERT_EQUAL_PRINT_FLOATING("7.99999999", 7.99999999); /*Not rounding*/ TEST_ASSERT_EQUAL_PRINT_FLOATING("16.0000002", 16.0000002); TEST_ASSERT_EQUAL_PRINT_FLOATING("16.0000004", 16.0000004); TEST_ASSERT_EQUAL_PRINT_FLOATING("16.0000006", 16.0000006); TEST_ASSERT_EQUAL_PRINT_FLOATING("999999999", 999999999.0); /*Last full print integer*/ TEST_ASSERT_EQUAL_PRINT_FLOATING("0", -0.0); /* -0 no supported on all targets */ TEST_ASSERT_EQUAL_PRINT_FLOATING("-4.99e-07", -0.000000499); TEST_ASSERT_EQUAL_PRINT_FLOATING("-5.0000005e-07", -0.00000050000005); TEST_ASSERT_EQUAL_PRINT_FLOATING("-0.100469499", -0.100469499); TEST_ASSERT_EQUAL_PRINT_FLOATING("-1", -0.9999999995); /*Rounding to int place*/ TEST_ASSERT_EQUAL_PRINT_FLOATING("-1", -1.0); TEST_ASSERT_EQUAL_PRINT_FLOATING("-1.25", -1.25); TEST_ASSERT_EQUAL_PRINT_FLOATING("-7.99999999", -7.99999999); /*Not rounding*/ TEST_ASSERT_EQUAL_PRINT_FLOATING("-16.0000002", -16.0000002); TEST_ASSERT_EQUAL_PRINT_FLOATING("-16.0000004", -16.0000004); TEST_ASSERT_EQUAL_PRINT_FLOATING("-16.0000006", -16.0000006); TEST_ASSERT_EQUAL_PRINT_FLOATING("-999999999", -999999999.0); /*Last full print integer*/ TEST_ASSERT_EQUAL_PRINT_FLOATING("0.1004695", 0.10046949999999999); TEST_ASSERT_EQUAL_PRINT_FLOATING("4.2949673e+09", 4294967295.9); TEST_ASSERT_EQUAL_PRINT_FLOATING("4.2949673e+09", 4294967296.0); TEST_ASSERT_EQUAL_PRINT_FLOATING("1e+10", 9999999995.0); TEST_ASSERT_EQUAL_PRINT_FLOATING("9.00719925e+15", 9007199254740990.0); TEST_ASSERT_EQUAL_PRINT_FLOATING("7e+100", 7.0e+100); TEST_ASSERT_EQUAL_PRINT_FLOATING("3e+200", 3.0e+200); TEST_ASSERT_EQUAL_PRINT_FLOATING("9.23456789e+300", 9.23456789e+300); TEST_ASSERT_EQUAL_PRINT_FLOATING("-0.1004695", -0.10046949999999999); TEST_ASSERT_EQUAL_PRINT_FLOATING("-4.2949673e+09", -4294967295.9); TEST_ASSERT_EQUAL_PRINT_FLOATING("-4.2949673e+09", -4294967296.0); TEST_ASSERT_EQUAL_PRINT_FLOATING("-7e+100", -7.0e+100); #endif } void testDoublePrintingRoundTiesToEven(void) { #if defined(UNITY_EXCLUDE_FLOAT_PRINT) || defined(UNITY_EXCLUDE_DOUBLE) || !defined(USING_OUTPUT_SPY) TEST_IGNORE(); #else #ifdef UNITY_ROUND_TIES_AWAY_FROM_ZERO TEST_ASSERT_EQUAL_PRINT_FLOATING("1.00000001e+10", 10000000050.0); TEST_ASSERT_EQUAL_PRINT_FLOATING("9.00719925e+15", 9007199245000000.0); #else /* Default to Round ties to even */ TEST_ASSERT_EQUAL_PRINT_FLOATING("1e+10", 10000000050.0); TEST_ASSERT_EQUAL_PRINT_FLOATING("9.00719924e+15", 9007199245000000.0); #endif #endif } void testDoublePrintingInfinityAndNaN(void) { #if defined(UNITY_EXCLUDE_FLOAT_PRINT) || defined(UNITY_EXCLUDE_DOUBLE) || !defined(USING_OUTPUT_SPY) TEST_IGNORE(); #else TEST_ASSERT_EQUAL_PRINT_FLOATING("inf", 1.0 / d_zero); TEST_ASSERT_EQUAL_PRINT_FLOATING("-inf", -1.0 / d_zero); TEST_ASSERT_EQUAL_PRINT_FLOATING("nan", 0.0 / d_zero); #endif }