plugins/testsuite/stacktest.sp
branchrefac-jit
changeset 2168 c24a6fa957db
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/plugins/testsuite/stacktest.sp	Sun Jul 06 04:49:55 2008 +0000
     1.3 @@ -0,0 +1,53 @@
     1.4 +#include <sourcemod>
     1.5 +
     1.6 +public Plugin:myinfo = 
     1.7 +{
     1.8 +	name = "Stack Tests",
     1.9 +	author = "AlliedModders LLC",
    1.10 +	description = "Tests stack functions",
    1.11 +	version = "1.0.0.0",
    1.12 +	url = "http://www.sourcemod.net/"
    1.13 +};
    1.14 +
    1.15 +public OnPluginStart()
    1.16 +{
    1.17 +	RegServerCmd("test_stack", Test_Stack);
    1.18 +}
    1.19 +
    1.20 +public Action:Test_Stack(args)
    1.21 +{
    1.22 +	new Handle:stack;
    1.23 +	new test[20]
    1.24 +	decl String:buffer[42];
    1.25 +	
    1.26 +	test[0] = 5
    1.27 +	test[1] = 7
    1.28 +	
    1.29 +	stack = CreateStack(30);
    1.30 +	PushStackCell(stack, 50);
    1.31 +	PushStackArray(stack, test, 2);
    1.32 +	PushStackArray(stack, test, 2);
    1.33 +	PushStackString(stack, "space craaab");
    1.34 +	PushStackCell(stack, 12);
    1.35 +	
    1.36 +	PrintToServer("empty? %d", IsStackEmpty(stack));
    1.37 +	
    1.38 +	PopStack(stack);
    1.39 +	PopStackString(stack, buffer, sizeof(buffer));
    1.40 +	PrintToServer("popped: \"%s\"", buffer);
    1.41 +	test[0] = 0
    1.42 +	test[1] = 0
    1.43 +	PrintToServer("values: %d, %d", test[0], test[1]);
    1.44 +	PopStackArray(stack, test, 2);
    1.45 +	PrintToServer("popped: %d, %d", test[0], test[1]);
    1.46 +	PopStackCell(stack, test[0], 1);
    1.47 +	PrintToServer("popped: x, %d", test[0]);
    1.48 +	PopStackCell(stack, test[0]);
    1.49 +	PrintToServer("popped: %d", test[0]);
    1.50 +	
    1.51 +	PrintToServer("empty? %d", IsStackEmpty(stack));
    1.52 +	
    1.53 +	CloseHandle(stack);
    1.54 +	
    1.55 +	return Plugin_Handled;
    1.56 +}