Skip to content

Commit

Permalink
Merge branch 'master' of github.com:dangmoody/Temper
Browse files Browse the repository at this point in the history
  • Loading branch information
dangmoody committed Nov 15, 2023
2 parents 40df340 + 32b4f8f commit 4cdd220
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 33 deletions.
3 changes: 3 additions & 0 deletions temper.h
Original file line number Diff line number Diff line change
Expand Up @@ -1192,6 +1192,7 @@ void TemperTestTrueInternal( const bool condition, const char* conditionStr, con
va_start( args, fmt );
g_temperTestContext.callbacks.VFPrintf( stderr, fmt, args );
va_end( args );
printf("\n"); // So users don't need to add \n to the end of all their error logs and everything can just be on a new line
}
TemperSetTextColorInternal( TEMPERDEV_COLOR_DEFAULT );
}
Expand Down Expand Up @@ -1250,6 +1251,8 @@ static void TemperOnAllTestsFinishedInternal( void ) {
g_temperTestContext.testsQuit, TemperGetPercentInternal( g_temperTestContext.testsQuit, totalFound ),
g_temperTestContext.testsSkipped, TemperGetPercentInternal( g_temperTestContext.testsSkipped, totalFound )
);

TemperSetTextColorInternal( TEMPERDEV_COLOR_DEFAULT );
}

//----------------------------------------------------------
Expand Down
66 changes: 33 additions & 33 deletions tests/automation_c/automation_c.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ static void AbsolveTest( const bool condition ) {
g_temperTestContext.currentTestErrorCount = 0;

TemperSetTextColorInternal( TEMPERDEV_COLOR_GREEN );
g_temperTestContext.callbacks.Log( stdout, "Current test absolved.\n" );
g_temperTestContext.callbacks.Log( stdout, "Current test absolved." );
TemperSetTextColorInternal( TEMPERDEV_COLOR_DEFAULT );
}
}
Expand All @@ -111,19 +111,19 @@ static void AbsolvePreviousTest( const automationAccountFor_t claim ) {
TEMPERDEV_ASSERT( g_temperTestContext.testsFailed > 0 );
g_temperTestContext.testsPassed += 1;
g_temperTestContext.testsFailed -= 1;
g_temperTestContext.callbacks.Log( stdout, "Absolved previous fail.\n" );
g_temperTestContext.callbacks.Log( stdout, "Absolved previous fail." );
} else if ( claim == ACCOUNT_FOR_ONE_ABORT ) {
TEMPERDEV_ASSERT( g_temperTestContext.testsFailed > 0 );
TEMPERDEV_ASSERT( g_temperTestContext.testsAborted > 0 );
g_temperTestContext.testsPassed += 1;
g_temperTestContext.testsFailed -= 1;
g_temperTestContext.testsAborted -= 1;
g_temperTestContext.callbacks.Log( stdout, "Absolved previous abort.\n" );
g_temperTestContext.callbacks.Log( stdout, "Absolved previous abort." );
} else if ( claim == ACCOUNT_FOR_ONE_SKIP ) {
TEMPERDEV_ASSERT( g_temperTestContext.testsSkipped > 0 );
g_temperTestContext.testsPassed += 1;
g_temperTestContext.testsSkipped -= 1;
g_temperTestContext.callbacks.Log( stdout, "Absolved previous skip.\n" );
g_temperTestContext.callbacks.Log( stdout, "Absolved previous skip." );
}else if ( claim == ACCOUNT_FOR_QUIT_ATTEMPT ) {
TEMPERDEV_ASSERT( g_temperTestContext.testsFailed > 0 );
TEMPERDEV_ASSERT( g_temperTestContext.testsAborted > 0 );
Expand All @@ -132,7 +132,7 @@ static void AbsolvePreviousTest( const automationAccountFor_t claim ) {
g_temperTestContext.testsFailed -= 1;
g_temperTestContext.testsAborted -= 1;
g_temperTestContext.testsQuit -= 1;
g_temperTestContext.callbacks.Log( stdout, "Absolved quit.\n" );
g_temperTestContext.callbacks.Log( stdout, "Absolved quit." );
}

TemperSetTextColorInternal( TEMPERDEV_COLOR_DEFAULT );
Expand Down Expand Up @@ -256,8 +256,8 @@ typedef struct person_t {

TEMPER_TEST_PARAMETRIC( ParametricTest_WhenDeclaredWithStructParm_StructParmIsValid, TEMPER_FLAG_SHOULD_RUN, person_t* person, const char* expectedName, const uint32_t expectedAge ) {
// general data validation
TEMPER_CHECK_TRUE_AM( person != NULL, "person ptr is NULL.\n" );
TEMPER_CHECK_TRUE_AM( person->name != NULL, "person->name ptr inside \"%s\" is NULL.\n" );
TEMPER_CHECK_TRUE_AM( person != NULL, "person ptr is NULL." );
TEMPER_CHECK_TRUE_AM( person->name != NULL, "person->name ptr inside \"%s\" is NULL." );

// actual comparing what was passed in vs what was expected
TEMPER_CHECK_TRUE_AM( strcmp( person->name, expectedName ) == 0, "person->name was expected to be \"%s\" but was actually \"%s\".\n", expectedName, person->name );
Expand All @@ -275,12 +275,12 @@ TEMPER_INVOKE_PARAMETRIC_TEST( ParametricTest_WhenDeclaredWithStructParm_StructP

TEMPER_TEST( CheckTrue_WhenFails_ErrorCountIncrements, TEMPER_FLAG_SHOULD_RUN ) {
bool countIsCorrect = true;
TEMPER_CHECK_TRUE_M( false, "We expect this test to fail.\n" );
TEMPER_CHECK_TRUE_M( false, "We expect this test to fail." );
countIsCorrect = g_temperTestContext.currentTestErrorCount == 1 ? countIsCorrect : false;

TEMPER_CHECK_TRUE_M( 5 == 7 && 8 + 2 == 11, "We expect this test to fail.\n" );
TEMPER_CHECK_TRUE_M( 5 == 5 && 8 + 2 == 11, "We expect this test to fail.\n" );
TEMPER_CHECK_TRUE_M( 5 == 5 && 8 + 2 == 10, "We expect this test to fail.\n" );
TEMPER_CHECK_TRUE_M( 5 == 7 && 8 + 2 == 11, "We expect this test to fail." );
TEMPER_CHECK_TRUE_M( 5 == 5 && 8 + 2 == 11, "We expect this test to fail." );
TEMPER_CHECK_TRUE_M( 5 == 5 && 8 + 2 == 10, "We expect this test to fail." );
countIsCorrect = g_temperTestContext.currentTestErrorCount == 3 ? countIsCorrect : false;

AbsolveTest( countIsCorrect );
Expand All @@ -291,7 +291,7 @@ TEMPER_TEST( CheckTrue_WhenFails_ErrorCountIncrements, TEMPER_FLAG_SHOULD_RUN )
//----------------------------------------------------------

RESULT_DEPENDANT_TEST( TemperCheck_WhenErrorTriggered_FailsTest, TEMPER_FLAG_SHOULD_RUN ) {
TEMPER_CHECK_TRUE_M( false, "We expect this test to fail.\n" );
TEMPER_CHECK_TRUE_M( false, "We expect this test to fail." );
}

TEMPER_TEST( CheckAndCleanResults_6, TEMPER_FLAG_SHOULD_RUN ) {
Expand All @@ -305,7 +305,7 @@ TEMPER_TEST( CheckAndCleanResults_6, TEMPER_FLAG_SHOULD_RUN ) {
//----------------------------------------------------------

RESULT_DEPENDANT_TEST( CheckTrue_WhenAbortTriggered_AbortsTest, TEMPER_FLAG_SHOULD_RUN ) {
TEMPER_CHECK_TRUE_AM( false, "We expect this test to abort.\n" );
TEMPER_CHECK_TRUE_AM( false, "We expect this test to abort." );
testAbortTestNumberWeNeverExpectSet = THE_ABORT_TEST_FAILURE_NUMBER;
}

Expand All @@ -319,7 +319,7 @@ TEMPER_TEST( CheckAndCleanResults_7, TEMPER_FLAG_SHOULD_RUN ) {
}

RESULT_DEPDENDANT_TEST_PARAMETRIC( CheckTrue_WhenAbortTriggered_AbortsParametricTest, const bool check ) {
TEMPER_CHECK_TRUE_AM( check, "We expect this test to abort.\n" );
TEMPER_CHECK_TRUE_AM( check, "We expect this test to abort." );
testAbortTestNumberWeNeverExpectSet = THE_ABORT_TEST_FAILURE_NUMBER;
}

Expand Down Expand Up @@ -377,28 +377,28 @@ CONDITION_TEST( CheckTrue_FalseParsed_ErrorCountIncrements ) {
bool errorCountCorrect = g_temperTestContext.currentTestErrorCount == 0 ? true : false;
TEMPER_CHECK_TRUE( false );
errorCountCorrect = g_temperTestContext.currentTestErrorCount == 1 ? errorCountCorrect : false;
PassOrFailTest( errorCountCorrect, "Should have incremented the error count to 1.\n" );
PassOrFailTest( errorCountCorrect, "Should have incremented the error count to 1." );
}

CONDITION_TEST( CheckTrue_TrueParsed_ErrorCountStays ) {
bool errorCountCorrect = g_temperTestContext.currentTestErrorCount == 0 ? true : false;
TEMPER_CHECK_TRUE( true );
errorCountCorrect = g_temperTestContext.currentTestErrorCount == 0 ? errorCountCorrect : false;
PassOrFailTest( errorCountCorrect, "Shouldn't have incremented the error count.\n" );
PassOrFailTest( errorCountCorrect, "Shouldn't have incremented the error count." );
}

CONDITION_TEST( CheckTrue_LongFalseStatementParsed_ErrorCountIncrements ) {
bool errorCountCorrect = g_temperTestContext.currentTestErrorCount == 0 ? true : false;
TEMPER_CHECK_TRUE( ( ( 2 * 8 ) / 4 ) == 4 && 7 - 7 );
errorCountCorrect = g_temperTestContext.currentTestErrorCount == 1 ? errorCountCorrect : false;
PassOrFailTest( errorCountCorrect, "Should have incremented the error count to 1.\n" );
PassOrFailTest( errorCountCorrect, "Should have incremented the error count to 1." );
}

CONDITION_TEST( CheckTrue_LongTrueStatementParsed_ErrorCountStays ) {
bool errorCountCorrect = g_temperTestContext.currentTestErrorCount == 0 ? true : false;
TEMPER_CHECK_TRUE( ( ( 2 * 8 ) / 4 ) == 4 && 7 - 6 );
errorCountCorrect = g_temperTestContext.currentTestErrorCount == 0 ? errorCountCorrect : false;
PassOrFailTest( errorCountCorrect, "Shouldn't have incremented the error count.\n" );
PassOrFailTest( errorCountCorrect, "Shouldn't have incremented the error count." );
}

//----------------------------------------------------------
Expand All @@ -409,28 +409,28 @@ CONDITION_TEST( CheckFalse_FalseParsed_ErrorCountStays ) {
bool errorCountCorrect = g_temperTestContext.currentTestErrorCount == 0 ? true : false;
TEMPER_CHECK_FALSE( false );
errorCountCorrect = g_temperTestContext.currentTestErrorCount == 0 ? errorCountCorrect : false;
PassOrFailTest( errorCountCorrect, "Shouldn't have incremented the error count.\n" );
PassOrFailTest( errorCountCorrect, "Shouldn't have incremented the error count." );
}

CONDITION_TEST( CheckFalse_TrueParsed_ErrorCountIncrements ) {
bool errorCountCorrect = g_temperTestContext.currentTestErrorCount == 0 ? true : false;
TEMPER_CHECK_FALSE( true );
errorCountCorrect = g_temperTestContext.currentTestErrorCount == 1 ? errorCountCorrect : false;
PassOrFailTest( errorCountCorrect, "Should have incremented the error count to 1.\n" );
PassOrFailTest( errorCountCorrect, "Should have incremented the error count to 1." );
}

CONDITION_TEST( CheckFalse_LongFalseStatementParsed_ErrorCountStays ) {
bool errorCountCorrect = g_temperTestContext.currentTestErrorCount == 0 ? true : false;
TEMPER_CHECK_FALSE( ( ( 2 * 8 ) / 4 ) == 4 && 7 - 7 );
errorCountCorrect = g_temperTestContext.currentTestErrorCount == 0 ? errorCountCorrect : false;
PassOrFailTest( errorCountCorrect, "Shouldn't have incremented the error count.\n" );
PassOrFailTest( errorCountCorrect, "Shouldn't have incremented the error count." );
}

CONDITION_TEST( CheckFalse_LongTrueStatementParsed_ErrorCountIncrements ) {
bool errorCountCorrect = g_temperTestContext.currentTestErrorCount == 0 ? true : false;
TEMPER_CHECK_FALSE( ( ( 2 * 8 ) / 4 ) == 4 && 7 - 6 );
errorCountCorrect = g_temperTestContext.currentTestErrorCount == 1 ? errorCountCorrect : false;
PassOrFailTest( errorCountCorrect, "Should have incremented the error count to 1.\n" );
PassOrFailTest( errorCountCorrect, "Should have incremented the error count to 1." );
}

//----------------------------------------------------------
Expand All @@ -441,14 +441,14 @@ CONDITION_TEST( CheckEqual_WhenTwoValuesAreEqual_ErrorCountStays ) {
bool errorCountCorrect = g_temperTestContext.currentTestErrorCount == 0 ? true : false;
TEMPER_CHECK_EQUAL( 8, 8 );
errorCountCorrect = g_temperTestContext.currentTestErrorCount == 0 ? errorCountCorrect : false;
PassOrFailTest( errorCountCorrect, "Shouldn't have incremented the error count.\n" );
PassOrFailTest( errorCountCorrect, "Shouldn't have incremented the error count." );
}

CONDITION_TEST( CheckFalse_WhenTwoValuesAreNotEqual_ErrorCountIncrements ) {
bool errorCountCorrect = g_temperTestContext.currentTestErrorCount == 0 ? true : false;
TEMPER_CHECK_EQUAL( 4, 8 );
errorCountCorrect = g_temperTestContext.currentTestErrorCount == 1 ? errorCountCorrect : false;
PassOrFailTest( errorCountCorrect, "Should have incremented the error count to 1.\n" );
PassOrFailTest( errorCountCorrect, "Should have incremented the error count to 1." );
}

//----------------------------------------------------------
Expand All @@ -468,7 +468,7 @@ CONDITION_TEST( CheckFloatEqual_ValuesAroundUpperLowerBoundaries_ErrorCountIncre
errorCountCorrect = g_temperTestContext.currentTestErrorCount == 1 ? errorCountCorrect : false;
TEMPER_CHECK_FLOAT_EQUAL( lhs, 4.999992f ); // Below lower threshold
errorCountCorrect = g_temperTestContext.currentTestErrorCount == 2 ? errorCountCorrect : false;
PassOrFailTest( errorCountCorrect, "Should have incremented the error count to 2.\n" );
PassOrFailTest( errorCountCorrect, "Should have incremented the error count to 2." );
}

//----------------------------------------------------------
Expand All @@ -488,7 +488,7 @@ CONDITION_TEST( CheckNotFloatEqual_ValuesAroundUpperLowerBoundaries_ErrorCountIn
errorCountCorrect = g_temperTestContext.currentTestErrorCount == 3 ? errorCountCorrect : false;
TEMPER_CHECK_NOT_FLOAT_EQUAL( lhs, 4.999992f ); // Below lower threshold
errorCountCorrect = g_temperTestContext.currentTestErrorCount == 3 ? errorCountCorrect : false;
PassOrFailTest( errorCountCorrect, "Should have incremented the error count to 2.\n" );
PassOrFailTest( errorCountCorrect, "Should have incremented the error count to 2." );
}

//----------------------------------------------------------
Expand All @@ -509,7 +509,7 @@ CONDITION_TEST( CheckFloatSEqual_ValuesAroundUpperLowerBoundaries_ErrorCountIncr
errorCountCorrect = g_temperTestContext.currentTestErrorCount == 1 ? errorCountCorrect : false;
TEMPER_CHECK_FLOAT_WITHIN_RANGE( lhs, -2.6f, epsilon ); // Below lower threshold
errorCountCorrect = g_temperTestContext.currentTestErrorCount == 2 ? errorCountCorrect : false;
PassOrFailTest( errorCountCorrect, "Should have incremented the error count to 2.\n" );
PassOrFailTest( errorCountCorrect, "Should have incremented the error count to 2." );
}

//----------------------------------------------------------
Expand All @@ -530,7 +530,7 @@ CONDITION_TEST( CheckNotFloatSEqual_ValuesAroundUpperLowerBoundaries_ErrorCountI
errorCountCorrect = g_temperTestContext.currentTestErrorCount == 3 ? errorCountCorrect : false;
TEMPER_CHECK_FLOAT_NOT_WITHIN_RANGE( lhs, -2.6f, epsilon ); // Below lower threshold
errorCountCorrect = g_temperTestContext.currentTestErrorCount == 3 ? errorCountCorrect : false;
PassOrFailTest( errorCountCorrect, "Should have incremented the error count to 3.\n" );
PassOrFailTest( errorCountCorrect, "Should have incremented the error count to 3." );
}

//----------------------------------------------------------
Expand All @@ -550,7 +550,7 @@ CONDITION_TEST( CheckDoubleEqual_ValuesAroundUpperLowerBoundaries_ErrorCountIncr
errorCountCorrect = g_temperTestContext.currentTestErrorCount == 1 ? errorCountCorrect : false;
TEMPER_CHECK_DOUBLE_EQUAL( lhs, 4.99999999999992 ); // Below lower threshold
errorCountCorrect = g_temperTestContext.currentTestErrorCount == 2 ? errorCountCorrect : false;
PassOrFailTest( errorCountCorrect, "Should have incremented the error count to 2.\n" );
PassOrFailTest( errorCountCorrect, "Should have incremented the error count to 2." );
}

//----------------------------------------------------------
Expand All @@ -570,7 +570,7 @@ CONDITION_TEST( CheckNotDoubleEqual_ValuesAroundUpperLowerBoundaries_ErrorCountI
errorCountCorrect = g_temperTestContext.currentTestErrorCount == 3 ? errorCountCorrect : false;
TEMPER_CHECK_NOT_DOUBLE_EQUAL( lhs, 4.99999999999992 ); // Below lower threshold
errorCountCorrect = g_temperTestContext.currentTestErrorCount == 3 ? errorCountCorrect : false;
PassOrFailTest( errorCountCorrect, "Should have incremented the error count to 2.\n" );
PassOrFailTest( errorCountCorrect, "Should have incremented the error count to 2." );
}

//----------------------------------------------------------
Expand All @@ -591,7 +591,7 @@ CONDITION_TEST( CheckDoubleSEqual_ValuesAroundUpperLowerBoundaries_ErrorCountInc
errorCountCorrect = g_temperTestContext.currentTestErrorCount == 1 ? errorCountCorrect : false;
TEMPER_CHECK_DOUBLE_WITHIN_RANGE( lhs, -2.6, epsilon ); // Below lower threshold
errorCountCorrect = g_temperTestContext.currentTestErrorCount == 2 ? errorCountCorrect : false;
PassOrFailTest( errorCountCorrect, "Should have incremented the error count to 2.\n" );
PassOrFailTest( errorCountCorrect, "Should have incremented the error count to 2." );
}

//----------------------------------------------------------
Expand All @@ -612,7 +612,7 @@ CONDITION_TEST( CheckNotDoubleSEqual_ValuesAroundUpperLowerBoundaries_ErrorCount
errorCountCorrect = g_temperTestContext.currentTestErrorCount == 3 ? errorCountCorrect : false;
TEMPER_CHECK_DOUBLE_NOT_WITHIN_RANGE( lhs, -2.6, epsilon ); // Below lower threshold
errorCountCorrect = g_temperTestContext.currentTestErrorCount == 3 ? errorCountCorrect : false;
PassOrFailTest( errorCountCorrect, "Should have incremented the error count to 3.\n" );
PassOrFailTest( errorCountCorrect, "Should have incremented the error count to 3." );
}

//----------------------------------------------------------
Expand All @@ -637,7 +637,7 @@ TEMPER_TEST( CheckAndCleanResults_9, TEMPER_FLAG_SHOULD_RUN ) {

RESULT_DEPDENDANT_TEST_PARAMETRIC( CheckTrue_WhenQuitTriggered_QuitInvokedAndAbortsParametricTest, const bool check ) {
g_temperTestContext.negateQuitAttempts = true;
TEMPER_CHECK_TRUE_QM( check, "We expect this test to quit.\n" );
TEMPER_CHECK_TRUE_QM( check, "We expect this test to quit." );
testAbortTestNumberWeNeverExpectSet = THE_ABORT_TEST_FAILURE_NUMBER;
}

Expand Down

0 comments on commit 4cdd220

Please sign in to comment.