]> git.ipfire.org Git - thirdparty/squid.git/blame - src/tests/testACLMaxUserIP.cc
Author: D Kazarov <d.y.kazarov@mail.ru>
[thirdparty/squid.git] / src / tests / testACLMaxUserIP.cc
CommitLineData
ec94e362
AJ
1#define SQUID_UNIT_TEST 1
2
d295d770 3#include "squid.h"
d295d770 4#include "testACLMaxUserIP.h"
3ad63615 5#include "auth/AclMaxUserIp.h"
d295d770 6
27e059d4
AJ
7#if HAVE_STDEXCEPT
8#include <stdexcept>
9#endif
10
d295d770 11CPPUNIT_TEST_SUITE_REGISTRATION( testACLMaxUserIP );
12
13
14void
15testACLMaxUserIP::testDefaults()
16{
17 ACLMaxUserIP anACL("max_user_ip");
18 /* 0 is not a valid maximum, so we start at 0 */
19 CPPUNIT_ASSERT(anACL.getMaximum() == 0);
20 /* and we have no option to turn strict OFF, so start ON. */
21 CPPUNIT_ASSERT(anACL.getStrict() == false);
22 /* an unparsed acl must not be valid - there is no sane default */
23 CPPUNIT_ASSERT(!anACL.valid());
24}
25
26
27void
28testACLMaxUserIP::testParseLine()
29{
30 /* a config line to pass with a lead-in token to seed the parser. */
31 char * line = xstrdup("token -s 1");
32 /* seed the parser */
33 strtok(line, w_space);
34 ACLMaxUserIP anACL("max_user_ip");
35 anACL.parse();
36 /* we want a maximum of one, and strict to be true */
37 CPPUNIT_ASSERT(anACL.getMaximum() == 1);
38 CPPUNIT_ASSERT(anACL.getStrict() == true);
39 /* the acl must be vaid */
40 CPPUNIT_ASSERT(anACL.valid());
41 xfree(line);
42}