55 SPDX-License-Identifier: MIT
66========================================================================= */
77
8+ #if defined(UNITY_USE_COMMAND_LINE_ARGS ) && !defined(_WIN32 ) && !defined(_MSC_VER ) && !defined(_POSIX_C_SOURCE )
9+ #define _POSIX_C_SOURCE 200112L
10+ #endif
11+
812#include "unity.h"
913#ifdef UNITY_USE_COMMAND_LINE_ARGS
1014#include "unity_internals.h"
@@ -226,6 +230,8 @@ static void UnitySetTestContext(const char* testfile, const char* testname)
226230void testUnityParseOptionsUsesTestbridgeFilter (void )
227231{
228232 char * argv [] = { (char * )"prog" , NULL };
233+ const char * testfile = Unity .TestFile ;
234+ const char * testname = Unity .CurrentTestName ;
229235
230236 UnitySetTestbridgeFilter ("test_my_function" );
231237 UnityParseOptions (1 , argv );
@@ -236,11 +242,15 @@ void testUnityParseOptionsUsesTestbridgeFilter(void)
236242 TEST_ASSERT_FALSE (UnityTestMatches ());
237243
238244 UnitySetTestbridgeFilter (NULL );
245+ UnityParseOptions (1 , argv );
246+ UnitySetTestContext (testfile , testname );
239247}
240248
241249void testUnityParseOptionsArgsOverrideTestbridgeFilter (void )
242250{
243251 char * argv [] = { (char * )"prog" , (char * )"-n" , (char * )"other" , NULL };
252+ const char * testfile = Unity .TestFile ;
253+ const char * testname = Unity .CurrentTestName ;
244254
245255 UnitySetTestbridgeFilter ("test_my_function" );
246256 UnityParseOptions (3 , argv );
@@ -251,6 +261,8 @@ void testUnityParseOptionsArgsOverrideTestbridgeFilter(void)
251261 TEST_ASSERT_FALSE (UnityTestMatches ());
252262
253263 UnitySetTestbridgeFilter (NULL );
264+ UnityParseOptions (1 , argv );
265+ UnitySetTestContext (testfile , testname );
254266}
255267#endif
256268
0 commit comments