2 * Copyright 2001-2005 Internet2
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #include "shib-target.h"
21 using namespace shibtarget;
23 static void test (ShibINI &ini, const char* header)
25 cout << "Testing Header: \"";
27 cout << "\"\tExists: ";
28 cout << (ini.exists (header) ? "Yes\n" : "No\n");
31 static void test (ShibINI &ini, const char* header, const char* tag)
37 cout << "\"\tExists: ";
38 if (ini.exists (header, tag)) {
39 cout << "Yes\tValue: \"";
40 cout << ini.get (header, tag);
46 static void test_header_iter (ShibINI &ini)
48 cout << "Test Header Iterator: ";
49 ShibINI::Iterator* iter = ini.header_iterator();
50 for (const string* str = iter->begin(); str; str = iter->next())
51 cout << "\"" << *str << "\" ";
57 static void test_tag_iter (ShibINI &ini, const char* header)
60 cout << "Test Tag Iterator \"" << header << "\" : ";
61 ShibINI::Iterator* iter = ini.tag_iterator(h);
62 for (const string* str = iter->begin(); str; str = iter->next())
63 cout << "\"" << *str << "\" ";
69 static void run_test (ShibINI &ini)
71 char* headers[] = { "test1", "", "header1", "Header1", "header2", "header2 " };
72 char* tags[] = { "test1", "test2", "test3", "test4", "test5", "TeSt5", "test 6" };
76 test_header_iter (ini);
78 for (int i = 0; i < sizeof(headers)/sizeof(*headers); i++) {
79 test (ini, headers[i]);
81 for (int j = 0; j < sizeof(tags)/sizeof(*tags); j++)
82 test (ini, headers[i], tags[j]);
84 test_tag_iter (ini, headers[i]);
91 ShibINI ini("testini.ini");
94 ShibINI ini2("testini.ini", false);