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.
22 function get(get, config)
23 config.set("example.com", "test", "testkey", 123);
24 assert_equal(get("example.com", "test", "testkey"), 123, "Retrieving a set key");
26 config.set("*", "test", "testkey1", 321);
27 assert_equal(get("*", "test", "testkey1"), 321, "Retrieving a set global key");
28 assert_equal(get("example.com", "test", "testkey1"), 321, "Retrieving a set key of undefined host, of which only a globally set one exists");
30 config.set("example.com", "test", ""); -- Creates example.com host in config
31 assert_equal(get("example.com", "test", "testkey1"), 321, "Retrieving a set key, of which only a globally set one exists");
33 assert_equal(get(), nil, "No parameters to get()");
34 assert_equal(get("undefined host"), nil, "Getting for undefined host");
35 assert_equal(get("undefined host", "undefined section"), nil, "Getting for undefined host & section");
36 assert_equal(get("undefined host", "undefined section", "undefined key"), nil, "Getting for undefined host & section & key");
38 assert_equal(get("example.com", "undefined section", "testkey"), nil, "Defined host, undefined section");
42 assert_equal(set("*"), false, "Set with no section/key");
43 assert_equal(set("*", "set_test"), false, "Set with no key");
45 assert_equal(set("*", "set_test", "testkey"), true, "Setting a nil global value");
46 assert_equal(set("*", "set_test", "testkey", 123), true, "Setting a global value");