sourcemod/plugins/testsuite/stacktest.sp
2014-11-15 12:46:17 -08:00

52 lines
1.1 KiB
SourcePawn

#include <sourcemod>
public Plugin:myinfo =
{
name = "Stack Tests",
author = "AlliedModders LLC",
description = "Tests stack functions",
version = "1.0.0.0",
url = "http://www.sourcemod.net/"
};
public OnPluginStart()
{
RegServerCmd("test_stack", Test_Stack);
}
public Action:Test_Stack(args)
{
int test[20];
char buffer[42];
test[0] = 5
test[1] = 7
ArrayStack stack = ArrayStack(30);
stack.Push(50);
stack.PushArray(test, 2);
stack.PushArray(test, 2);
stack.PushString("space craaab");
stack.Push(12);
PrintToServer("empty? %d", stack.Empty);
stack.Pop();
stack.PopString(buffer, sizeof(buffer));
PrintToServer("popped: \"%s\"", buffer);
test[0] = 0
test[1] = 0
PrintToServer("values: %d, %d", test[0], test[1]);
stack.PopArray(test, 2);
PrintToServer("popped: %d, %d", test[0], test[1]);
test[0] = stack.Pop(1);
PrintToServer("popped: x, %d", test[0]);
test[0] = stack.Pop();
PrintToServer("popped: %d", test[0]);
PrintToServer("empty? %d", stack.Empty);
delete stack;
return Plugin_Handled;
}