mirror of
https://github.com/DaveGamble/cJSON.git
synced 2023-08-10 21:13:26 +03:00
Merge commit '6b9b57be226a505a9c9cdd9ed029f22495ce04ec' as 'tests/unity'
This commit is contained in:
1252
tests/unity/test/tests/test_generate_test_runner.rb
Normal file
1252
tests/unity/test/tests/test_generate_test_runner.rb
Normal file
File diff suppressed because it is too large
Load Diff
110
tests/unity/test/tests/testparameterized.c
Normal file
110
tests/unity/test/tests/testparameterized.c
Normal file
@ -0,0 +1,110 @@
|
||||
/* ==========================================
|
||||
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 <setjmp.h>
|
||||
#include <stdio.h>
|
||||
#include "unity.h"
|
||||
|
||||
void putcharSpy(int c) { (void)putchar(c);} // include passthrough for linking tests
|
||||
|
||||
#define TEST_CASE(...)
|
||||
|
||||
#define EXPECT_ABORT_BEGIN \
|
||||
if (TEST_PROTECT()) \
|
||||
{
|
||||
|
||||
#define VERIFY_FAILS_END \
|
||||
} \
|
||||
Unity.CurrentTestFailed = (Unity.CurrentTestFailed != 0) ? 0 : 1; \
|
||||
if (Unity.CurrentTestFailed == 1) { \
|
||||
SetToOneMeanWeAlreadyCheckedThisGuy = 1; \
|
||||
UnityPrintNumberUnsigned(Unity.CurrentTestLineNumber); \
|
||||
UNITY_OUTPUT_CHAR(':'); \
|
||||
UnityPrint(Unity.CurrentTestName); \
|
||||
UnityPrint(":FAIL: [[[[ Test Should Have Failed But Did Not ]]]]"); \
|
||||
UNITY_OUTPUT_CHAR('\n'); \
|
||||
}
|
||||
|
||||
#define VERIFY_IGNORES_END \
|
||||
} \
|
||||
Unity.CurrentTestFailed = (Unity.CurrentTestIgnored != 0) ? 0 : 1; \
|
||||
Unity.CurrentTestIgnored = 0; \
|
||||
if (Unity.CurrentTestFailed == 1) { \
|
||||
SetToOneMeanWeAlreadyCheckedThisGuy = 1; \
|
||||
UnityPrintNumberUnsigned(Unity.CurrentTestLineNumber); \
|
||||
UNITY_OUTPUT_CHAR(':'); \
|
||||
UnityPrint(Unity.CurrentTestName); \
|
||||
UnityPrint(":FAIL: [[[[ Test Should Have Ignored But Did Not ]]]]"); \
|
||||
UNITY_OUTPUT_CHAR('\n'); \
|
||||
}
|
||||
|
||||
int SetToOneToFailInTearDown;
|
||||
int SetToOneMeanWeAlreadyCheckedThisGuy;
|
||||
|
||||
void setUp(void)
|
||||
{
|
||||
SetToOneToFailInTearDown = 0;
|
||||
SetToOneMeanWeAlreadyCheckedThisGuy = 0;
|
||||
}
|
||||
|
||||
void tearDown(void)
|
||||
{
|
||||
if (SetToOneToFailInTearDown == 1)
|
||||
TEST_FAIL_MESSAGE("<= Failed in tearDown");
|
||||
if ((SetToOneMeanWeAlreadyCheckedThisGuy == 0) && (Unity.CurrentTestFailed > 0))
|
||||
{
|
||||
UnityPrint(": [[[[ Test Should Have Passed But Did Not ]]]]");
|
||||
UNITY_OUTPUT_CHAR('\n');
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE(0)
|
||||
TEST_CASE(44)
|
||||
TEST_CASE((90)+9)
|
||||
void test_TheseShouldAllPass(int Num)
|
||||
{
|
||||
TEST_ASSERT_TRUE(Num < 100);
|
||||
}
|
||||
|
||||
TEST_CASE(3)
|
||||
TEST_CASE(77)
|
||||
TEST_CASE( (99) + 1 - (1))
|
||||
void test_TheseShouldAllFail(int Num)
|
||||
{
|
||||
EXPECT_ABORT_BEGIN
|
||||
TEST_ASSERT_TRUE(Num > 100);
|
||||
VERIFY_FAILS_END
|
||||
}
|
||||
|
||||
TEST_CASE(1)
|
||||
TEST_CASE(44)
|
||||
TEST_CASE(99)
|
||||
TEST_CASE(98)
|
||||
void test_TheseAreEveryOther(int Num)
|
||||
{
|
||||
if (Num & 1)
|
||||
{
|
||||
EXPECT_ABORT_BEGIN
|
||||
TEST_ASSERT_TRUE(Num > 100);
|
||||
VERIFY_FAILS_END
|
||||
}
|
||||
else
|
||||
{
|
||||
TEST_ASSERT_TRUE(Num < 100);
|
||||
}
|
||||
}
|
||||
|
||||
void test_NormalPassesStillWork(void)
|
||||
{
|
||||
TEST_ASSERT_TRUE(1);
|
||||
}
|
||||
|
||||
void test_NormalFailsStillWork(void)
|
||||
{
|
||||
EXPECT_ABORT_BEGIN
|
||||
TEST_ASSERT_TRUE(0);
|
||||
VERIFY_FAILS_END
|
||||
}
|
4058
tests/unity/test/tests/testunity.c
Normal file
4058
tests/unity/test/tests/testunity.c
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user