[Half-Life AMXX] / testsuite / admins_test.sma Repository:
ViewVC logotype

Annotation of /testsuite/admins_test.sma

Parent Directory Parent Directory | Revision Log Revision Log


Revision 17 - (view) (download)

1 : ian 17 #include <amxmodx>
2 :    
3 :     new __testnumber;
4 :     new errcount;
5 :    
6 :     enum TestType
7 :     {
8 :     TT_Equal = 0,
9 :     TT_LessThan,
10 :     TT_GreaterThan,
11 :     TT_LessThanEqual,
12 :     TT_GreaterThanEqual,
13 :     TT_NotEqual
14 :     };
15 :    
16 :     new TestWords[6][] = {
17 :     "==",
18 :     "<",
19 :     ">",
20 :     "<=",
21 :     ">=",
22 :     "!="
23 :     };
24 :    
25 :    
26 :    
27 :     stock test(A,B=0,TestType:Type=TT_Equal)
28 :     {
29 :     ++__testnumber;
30 :    
31 :     new passed=0;
32 :    
33 :     switch (Type)
34 :     {
35 :     case TT_Equal: if (A==B) passed=1;
36 :     case TT_LessThan: if (A<B) passed=1;
37 :     case TT_GreaterThan: if (A>B) passed=1;
38 :     case TT_LessThanEqual: if (A<=B) passed=1;
39 :     case TT_GreaterThanEqual: if (A>=B) passed=1;
40 :     case TT_NotEqual: if (A!=B) passed=1;
41 :     }
42 :    
43 :     if (!passed)
44 :     {
45 :     log_amx("Failed test #%d (%d %s %d)",__testnumber,A,TestWords[_:Type],B);
46 :     errcount++;
47 :     }
48 :     }
49 :    
50 :    
51 :     public plugin_init()
52 :     {
53 :     register_srvcmd("testadmins","testadmins");
54 :     }
55 :     public testadmins()
56 :     {
57 :    
58 :     new AuthData[44];
59 :     new Password[32];
60 :     new Access;
61 :     new Flags;
62 :     new id;
63 :    
64 :     __testnumber=0;
65 :     errcount=0;
66 :    
67 :    
68 :     test(admins_num(),0);
69 :    
70 :     admins_push("STEAM_0:1:23456","",read_flags("abcdefghijklmnopqrstu"),read_flags("ce"));
71 :    
72 :     test(admins_num(),1);
73 :    
74 :     admins_push("ABCDEFGHIJKLMNOP","abcdefghijklmnop",read_flags("z"),read_flags("a"));
75 :    
76 :     test(admins_num(),2);
77 :    
78 :     admins_push("ZYXWVUTSRQPONMLKJIHGFEDCBA","plop",read_flags("a"),read_flags("b"));
79 :    
80 :     test(admins_num(),3);
81 :    
82 :     id=0;
83 :    
84 :     admins_lookup(id,AdminProp_Auth,AuthData,sizeof(AuthData)-1);
85 :     admins_lookup(id,AdminProp_Password,Password,sizeof(Password)-1);
86 :     Access=admins_lookup(id,AdminProp_Access);
87 :     Flags=admins_lookup(id,AdminProp_Flags);
88 :    
89 :     test(strcmp(AuthData,"STEAM_0:1:23456"),0);
90 :     test(strcmp(Password,""),0);
91 :     test(Access,read_flags("abcdefghijklmnopqrstu"));
92 :     test(Flags,read_flags("ce"));
93 :    
94 :     id++;
95 :    
96 :     admins_lookup(id,AdminProp_Auth,AuthData,sizeof(AuthData)-1);
97 :     admins_lookup(id,AdminProp_Password,Password,sizeof(Password)-1);
98 :     Access=admins_lookup(id,AdminProp_Access);
99 :     Flags=admins_lookup(id,AdminProp_Flags);
100 :    
101 :     test(strcmp(AuthData,"ABCDEFGHIJKLMNOP"),0);
102 :     test(strcmp(Password,"abcdefghijklmnop"),0);
103 :     test(Access,read_flags("z"));
104 :     test(Flags,read_flags("a"));
105 :    
106 :     id++;
107 :    
108 :     admins_lookup(id,AdminProp_Auth,AuthData,sizeof(AuthData)-1);
109 :     admins_lookup(id,AdminProp_Password,Password,sizeof(Password)-1);
110 :     Access=admins_lookup(id,AdminProp_Access);
111 :     Flags=admins_lookup(id,AdminProp_Flags);
112 :    
113 :     test(strcmp(AuthData,"ZYXWVUTSRQPONMLKJIHGFEDCBA"),0);
114 :     test(strcmp(Password,"plop"),0);
115 :     test(Access,read_flags("a"));
116 :     test(Flags,read_flags("b"));
117 :    
118 :     admins_flush();
119 :    
120 :     test(admins_num(),0);
121 :    
122 :     server_print("test complete, %d errors",errcount);
123 :     }

Contact
ViewVC Help
Powered by ViewVC 1.0.4