plugins/testsuite/fakenative2.sp
changeset 601 fe5b368fcedc
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/plugins/testsuite/fakenative2.sp	Mon Mar 12 07:08:05 2007 +0000
     1.3 @@ -0,0 +1,87 @@
     1.4 +#include <sourcemod>
     1.5 +
     1.6 +native TestNative1(gaben, ...);
     1.7 +native TestNative2(String:buffer[]);
     1.8 +native TestNative3(value1, &value2);
     1.9 +native TestNative4(const input[], output[], size);
    1.10 +native TestNative5(bool:local, String:buffer[], maxlength, const String:fmt[], {Handle,Float,String,_}:...);
    1.11 +
    1.12 +public Plugin:myinfo = 
    1.13 +{
    1.14 +	name = "FakeNative Testing Lab #2",
    1.15 +	author = "AlliedModders LLC",
    1.16 +	description = "Test suite #2 for dynamic natives",
    1.17 +	version = "1.0.0.0",
    1.18 +	url = "http://www.sourcemod.net/"
    1.19 +};
    1.20 +
    1.21 +public OnPluginStart()
    1.22 +{
    1.23 +	RegServerCmd("test_native1", Test_Native1);
    1.24 +	RegServerCmd("test_native2", Test_Native2);
    1.25 +	RegServerCmd("test_native3", Test_Native3);
    1.26 +	RegServerCmd("test_native4", Test_Native4);
    1.27 +	RegServerCmd("test_native5", Test_Native5);
    1.28 +}
    1.29 +
    1.30 +public Action:Test_Native1(args)
    1.31 +{
    1.32 +	PrintToServer("Returned: %d", TestNative1(1));
    1.33 +	PrintToServer("Returned: %d", TestNative1(1,2));
    1.34 +	PrintToServer("Returned: %d", TestNative1(1,2,3,4));
    1.35 +	
    1.36 +	return Plugin_Handled;
    1.37 +}
    1.38 +
    1.39 +public Action:Test_Native2(args)
    1.40 +{
    1.41 +	new String:buffer[] = "IBM";
    1.42 +	
    1.43 +	PrintToServer("Before: %s", buffer);
    1.44 +	
    1.45 +	TestNative2(buffer);
    1.46 +	
    1.47 +	PrintToServer("AfteR: %s", buffer);
    1.48 +	
    1.49 +	return Plugin_Handled;
    1.50 +}
    1.51 +
    1.52 +public Action:Test_Native3(args)
    1.53 +{
    1.54 +	new value1 = 5, value2 = 6
    1.55 +	
    1.56 +	PrintToServer("Before: %d, %d", value1, value2);
    1.57 +	
    1.58 +	TestNative3(value1, value2);
    1.59 +	
    1.60 +	PrintToServer("After: %d, %d", value1, value2);
    1.61 +	
    1.62 +	return Plugin_Handled;
    1.63 +}
    1.64 +
    1.65 +public Action:Test_Native4(args)
    1.66 +{
    1.67 +	new input[5] = {0, 1, 2, 3, 4};
    1.68 +	new output[5];
    1.69 +	
    1.70 +	TestNative4(input, output, 5);
    1.71 +	
    1.72 +	PrintToServer("[0=%d] [1=%d] [2=%d] [3=%d] [4=%d]", input[0], input[1], input[2], input[3], input[4]);
    1.73 +	PrintToServer("[0=%d] [1=%d] [2=%d] [3=%d] [4=%d]", output[0], output[1], output[2], output[3], output[4]);
    1.74 +	
    1.75 +	return Plugin_Handled;
    1.76 +}
    1.77 +
    1.78 +public Action:Test_Native5(args)
    1.79 +{
    1.80 +	new String:buffer1[512];
    1.81 +	new String:buffer2[512];
    1.82 +	
    1.83 +	TestNative5(true, buffer1, sizeof(buffer1), "%d gabens in the %s", 50, "gabpark");
    1.84 +	TestNative5(true, buffer2, sizeof(buffer2), "%d gabens in the %s", 50, "gabpark");
    1.85 +	
    1.86 +	PrintToServer("Test 1: %s", buffer1);
    1.87 +	PrintToServer("Test 2: %s", buffer2);
    1.88 +	
    1.89 +	return Plugin_Handled;
    1.90 +}