2 -- Copyright (C) 2008 Matthew Wild
3 -- Copyright (C) 2008 Waqas Hussain
5 -- This program is free software; you can redistribute it and/or
6 -- modify it under the terms of the GNU General Public License
7 -- as published by the Free Software Foundation; either version 2
8 -- of the License, or (at your option) any later version.
10 -- This program is distributed in the hope that it will be useful,
11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 -- GNU General Public License for more details.
15 -- You should have received a copy of the GNU General Public License
16 -- along with this program; if not, write to the Free Software
17 -- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 function compare_srv_priorities(csp)
22 local r1 = { priority = 10, weight = 0 }
23 local r2 = { priority = 100, weight = 0 }
24 local r3 = { priority = 1000, weight = 2 }
25 local r4 = { priority = 1000, weight = 2 }
26 local r5 = { priority = 1000, weight = 5 }
28 assert_equal(csp(r1, r1), false);
29 assert_equal(csp(r1, r2), true);
30 assert_equal(csp(r1, r3), true);
31 assert_equal(csp(r1, r4), true);
32 assert_equal(csp(r1, r5), true);
34 assert_equal(csp(r2, r1), false);
35 assert_equal(csp(r2, r2), false);
36 assert_equal(csp(r2, r3), true);
37 assert_equal(csp(r2, r4), true);
38 assert_equal(csp(r2, r5), true);
40 assert_equal(csp(r3, r1), false);
41 assert_equal(csp(r3, r2), false);
42 assert_equal(csp(r3, r3), false);
43 assert_equal(csp(r3, r4), false);
44 assert_equal(csp(r3, r5), true);
46 assert_equal(csp(r4, r1), false);
47 assert_equal(csp(r4, r2), false);
48 assert_equal(csp(r4, r3), false);
49 assert_equal(csp(r4, r4), false);
50 assert_equal(csp(r4, r5), true);
52 assert_equal(csp(r5, r1), false);
53 assert_equal(csp(r5, r2), false);
54 assert_equal(csp(r5, r3), false);
55 assert_equal(csp(r5, r4), false);
56 assert_equal(csp(r5, r5), false);