Skip to content

Commit

Permalink
Fix a test, and add an extra one just in case.
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Cole committed Jul 9, 2023
1 parent 0db5dd7 commit a45ea99
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 1 deletion.
44 changes: 44 additions & 0 deletions YSI_Coding/y_hooks/y_hooks_tests.inc
Original file line number Diff line number Diff line change
Expand Up @@ -1162,6 +1162,50 @@ hook stock y_hooks_HookedStock(str[], v, &c)
ASSERT_EQ(YSI_g_sMinC, 6);
}

#if defined _ALS_strlen
#error Found exsting strlen hook in y_hooks tests.
#endif

stock y_hooks_strlen_1(const string[])
{
YSI_g_sMinA += 10;
return strlen(string);
}

#define strlen( y_hooks_strlen_1(

hook native strlen(const string[])
{
YSI_g_sMinA *= 2;
return continue(string);
}

#tryinclude "..\YSI_Coding\y_unique"
#tryinclude "..\..\YSI_Coding\y_unique"

hook native strlen(const string[])
{
YSI_g_sMinA = 50;
return continue(string);
}

//stock y_hooks_strlen_2(const string[])
//{
// YSI_g_sMinA = 50;
// return strlen(string);
//}
//
//#define strlen( y_hooks_strlen_2(

@test(.group = "y_hooks") y_hooks_strlen()
{
ASSERT_EQ(strlen("Hello world."), 12);
ASSERT_EQ(YSI_g_sMinA, 50 * 2 + 10);
}

// Don't affect other code.
#undef strlen

//@hook(.callback = "OnNewHooks") OnNewHooks1(playerid)
//{
// #pragma unused playerid
Expand Down
2 changes: 1 addition & 1 deletion YSI_Coding/y_va/y_va_tests.inc
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ static stock y_va_printf_3(num, other, const str[], va_args<>)
YSI_g_sVariable = 8;
y_va_CallLocalFunction(0, 45);
ASSERT_EQ(YSI_g_sVariable, 9);
ASSERT_EQ(123, y_va_CallLocalFunction(1, 45));
ASSERT_EQ(y_va_CallLocalFunction(1, 45), 123);
ASSERT_EQ(YSI_g_sVariable, 45);
}

Expand Down

0 comments on commit a45ea99

Please sign in to comment.