author | qdii <qdii@reblochon.be> | 2012-11-02 13:49:03 (UTC) |
---|---|---|
committer | Michael Krelin <hacker@klever.net> | 2012-11-02 13:49:03 (UTC) |
commit | 648ae5dbd90e062f3432f809a846d50d994b86d4 (patch) (unidiff) | |
tree | d9cbb0276d9a51db9243449866f01828dba36ab7 | |
parent | 824440e52ce8ddf1c45487d20d8996d08d0f96b5 (diff) | |
download | libopkele-648ae5dbd90e062f3432f809a846d50d994b86d4.zip libopkele-648ae5dbd90e062f3432f809a846d50d994b86d4.tar.gz libopkele-648ae5dbd90e062f3432f809a846d50d994b86d4.tar.bz2 |
Function _exit was referenced in the code, but <unistd.h> was not included, causing compilation to fail.
-rw-r--r-- | test/idiscover.cc | 1 | ||||
-rw-r--r-- | test/test.cc | 1 |
2 files changed, 2 insertions, 0 deletions
diff --git a/test/idiscover.cc b/test/idiscover.cc index 4b1e90c..8a5a3fb 100644 --- a/test/idiscover.cc +++ b/test/idiscover.cc | |||
@@ -1,41 +1,42 @@ | |||
1 | #include <iostream> | 1 | #include <iostream> |
2 | #include <stdexcept> | 2 | #include <stdexcept> |
3 | #include <iterator> | 3 | #include <iterator> |
4 | #include <algorithm> | 4 | #include <algorithm> |
5 | #include <unistd.h> | ||
5 | using namespace std; | 6 | using namespace std; |
6 | #include <opkele/exception.h> | 7 | #include <opkele/exception.h> |
7 | #include <opkele/discovery.h> | 8 | #include <opkele/discovery.h> |
8 | #include <opkele/util.h> | 9 | #include <opkele/util.h> |
9 | #include <opkele/util-internal.h> | 10 | #include <opkele/util-internal.h> |
10 | 11 | ||
11 | namespace opkele { | 12 | namespace opkele { |
12 | ostream& operator<<(ostream& o,const opkele::openid_endpoint_t& oep) { | 13 | ostream& operator<<(ostream& o,const opkele::openid_endpoint_t& oep) { |
13 | o | 14 | o |
14 | << " URI: " << oep.uri << endl | 15 | << " URI: " << oep.uri << endl |
15 | << " Claimed ID: " << oep.claimed_id << endl | 16 | << " Claimed ID: " << oep.claimed_id << endl |
16 | << " Local ID: " << oep.local_id << endl; | 17 | << " Local ID: " << oep.local_id << endl; |
17 | return o; | 18 | return o; |
18 | } | 19 | } |
19 | } | 20 | } |
20 | 21 | ||
21 | int main(int argc,char **argv) { | 22 | int main(int argc,char **argv) { |
22 | try { | 23 | try { |
23 | if(argc<2) | 24 | if(argc<2) |
24 | throw opkele::exception(OPKELE_CP_ "Please, give me something to resolve"); | 25 | throw opkele::exception(OPKELE_CP_ "Please, give me something to resolve"); |
25 | for(int a=1;a<argc;++a) { | 26 | for(int a=1;a<argc;++a) { |
26 | cout << "==============================================================" << endl | 27 | cout << "==============================================================" << endl |
27 | << "User-supplied ID: " << argv[a] << endl | 28 | << "User-supplied ID: " << argv[a] << endl |
28 | << "Endpoints:" << endl | 29 | << "Endpoints:" << endl |
29 | << " --" << endl; | 30 | << " --" << endl; |
30 | string normalized = opkele::idiscover( | 31 | string normalized = opkele::idiscover( |
31 | ostream_iterator<opkele::openid_endpoint_t>(cout," --\n") | 32 | ostream_iterator<opkele::openid_endpoint_t>(cout," --\n") |
32 | ,argv[a]); | 33 | ,argv[a]); |
33 | cout << "Normalized ID: " << normalized << endl; | 34 | cout << "Normalized ID: " << normalized << endl; |
34 | } | 35 | } |
35 | }catch(exception& e) { | 36 | }catch(exception& e) { |
36 | cerr << "oops, caught " << opkele::util::abi_demangle(typeid(e).name()) << endl | 37 | cerr << "oops, caught " << opkele::util::abi_demangle(typeid(e).name()) << endl |
37 | << " .what(): " << e.what() << endl; | 38 | << " .what(): " << e.what() << endl; |
38 | _exit(1); | 39 | _exit(1); |
39 | } | 40 | } |
40 | _exit(0); | 41 | _exit(0); |
41 | } | 42 | } |
diff --git a/test/test.cc b/test/test.cc index 2143ac0..770e0c6 100644 --- a/test/test.cc +++ b/test/test.cc | |||
@@ -1,106 +1,107 @@ | |||
1 | #include <iostream> | 1 | #include <iostream> |
2 | #include <stdexcept> | 2 | #include <stdexcept> |
3 | #include <unistd.h> | ||
3 | using namespace std; | 4 | using namespace std; |
4 | #include <opkele/exception.h> | 5 | #include <opkele/exception.h> |
5 | #include <opkele/util.h> | 6 | #include <opkele/util.h> |
6 | 7 | ||
7 | #include "config.h" | 8 | #include "config.h" |
8 | 9 | ||
9 | class failed_test : public opkele::exception { | 10 | class failed_test : public opkele::exception { |
10 | public: | 11 | public: |
11 | failed_test(OPKELE_E_PARS) | 12 | failed_test(OPKELE_E_PARS) |
12 | : exception(OPKELE_E_CONS) { } | 13 | : exception(OPKELE_E_CONS) { } |
13 | }; | 14 | }; |
14 | 15 | ||
15 | void test_rfc_3986_normalize_uri(const string &ouri,bool success,const string& nuri="") { | 16 | void test_rfc_3986_normalize_uri(const string &ouri,bool success,const string& nuri="") { |
16 | try { | 17 | try { |
17 | string n = opkele::util::rfc_3986_normalize_uri(ouri); | 18 | string n = opkele::util::rfc_3986_normalize_uri(ouri); |
18 | if(!success) | 19 | if(!success) |
19 | throw failed_test(OPKELE_CP_ "Normalized URI when it shouldn't ('"+ouri+"' normalization resulted in '"+n+"')"); | 20 | throw failed_test(OPKELE_CP_ "Normalized URI when it shouldn't ('"+ouri+"' normalization resulted in '"+n+"')"); |
20 | if(n!=nuri) | 21 | if(n!=nuri) |
21 | throw failed_test(OPKELE_CP_ "rfc_3986_test_failed for '"+ouri+"' failed, expected '"+nuri+"', got '"+n+"'"); | 22 | throw failed_test(OPKELE_CP_ "rfc_3986_test_failed for '"+ouri+"' failed, expected '"+nuri+"', got '"+n+"'"); |
22 | }catch(opkele::bad_input& obi) { | 23 | }catch(opkele::bad_input& obi) { |
23 | if(success) | 24 | if(success) |
24 | throw failed_test(OPKELE_CP_ "Test '"+ouri+"' failed due to 'bad_input'["+obi.what()+"]"); | 25 | throw failed_test(OPKELE_CP_ "Test '"+ouri+"' failed due to 'bad_input'["+obi.what()+"]"); |
25 | }catch(opkele::not_implemented& oni) { | 26 | }catch(opkele::not_implemented& oni) { |
26 | if(success) | 27 | if(success) |
27 | throw failed_test(OPKELE_CP_ "Test '"+ouri+"' failed due to 'not_implemented'["+oni.what()+"]"); | 28 | throw failed_test(OPKELE_CP_ "Test '"+ouri+"' failed due to 'not_implemented'["+oni.what()+"]"); |
28 | } | 29 | } |
29 | } | 30 | } |
30 | 31 | ||
31 | void test_rfc_3986_normalize_uri() { | 32 | void test_rfc_3986_normalize_uri() { |
32 | test_rfc_3986_normalize_uri( | 33 | test_rfc_3986_normalize_uri( |
33 | "invalid", false ); | 34 | "invalid", false ); |
34 | test_rfc_3986_normalize_uri( | 35 | test_rfc_3986_normalize_uri( |
35 | "http://", false ); | 36 | "http://", false ); |
36 | test_rfc_3986_normalize_uri( | 37 | test_rfc_3986_normalize_uri( |
37 | "http:/hacker.klever.net/", false ); | 38 | "http:/hacker.klever.net/", false ); |
38 | test_rfc_3986_normalize_uri( | 39 | test_rfc_3986_normalize_uri( |
39 | "hTTp://hacker.klever.net#uh?oh", true, "http://hacker.klever.net/#uh?oh" ); | 40 | "hTTp://hacker.klever.net#uh?oh", true, "http://hacker.klever.net/#uh?oh" ); |
40 | test_rfc_3986_normalize_uri( | 41 | test_rfc_3986_normalize_uri( |
41 | "http://hacker.klever.net?uh#oh", true, "http://hacker.klever.net/?uh#oh" ); | 42 | "http://hacker.klever.net?uh#oh", true, "http://hacker.klever.net/?uh#oh" ); |
42 | test_rfc_3986_normalize_uri( | 43 | test_rfc_3986_normalize_uri( |
43 | "http://hacker.klever.net:80/", true, "http://hacker.klever.net/" ); | 44 | "http://hacker.klever.net:80/", true, "http://hacker.klever.net/" ); |
44 | test_rfc_3986_normalize_uri( | 45 | test_rfc_3986_normalize_uri( |
45 | "http://hacker.klever.net:80?uh", true, "http://hacker.klever.net/?uh" ); | 46 | "http://hacker.klever.net:80?uh", true, "http://hacker.klever.net/?uh" ); |
46 | test_rfc_3986_normalize_uri( | 47 | test_rfc_3986_normalize_uri( |
47 | "http://hacker.klever.net:80#uh", true, "http://hacker.klever.net/#uh" ); | 48 | "http://hacker.klever.net:80#uh", true, "http://hacker.klever.net/#uh" ); |
48 | test_rfc_3986_normalize_uri( | 49 | test_rfc_3986_normalize_uri( |
49 | "https://hacker.klever.net:443", true, "https://hacker.klever.net/" ); | 50 | "https://hacker.klever.net:443", true, "https://hacker.klever.net/" ); |
50 | test_rfc_3986_normalize_uri( | 51 | test_rfc_3986_normalize_uri( |
51 | "http://hacker.klever.net:?oh", true, "http://hacker.klever.net/?oh" ); | 52 | "http://hacker.klever.net:?oh", true, "http://hacker.klever.net/?oh" ); |
52 | test_rfc_3986_normalize_uri( | 53 | test_rfc_3986_normalize_uri( |
53 | "http://hacker.klever.net/ah%2E", true, "http://hacker.klever.net/ah." ); | 54 | "http://hacker.klever.net/ah%2E", true, "http://hacker.klever.net/ah." ); |
54 | test_rfc_3986_normalize_uri( | 55 | test_rfc_3986_normalize_uri( |
55 | "http://hacker.klever.net/ah/%2E/", true, "http://hacker.klever.net/ah/" ); | 56 | "http://hacker.klever.net/ah/%2E/", true, "http://hacker.klever.net/ah/" ); |
56 | test_rfc_3986_normalize_uri( | 57 | test_rfc_3986_normalize_uri( |
57 | "http://hacker.klever.net/ah/%2b/", true, "http://hacker.klever.net/ah/%2B/" ); | 58 | "http://hacker.klever.net/ah/%2b/", true, "http://hacker.klever.net/ah/%2B/" ); |
58 | test_rfc_3986_normalize_uri( | 59 | test_rfc_3986_normalize_uri( |
59 | "http://hacker.klever.net/ah/./oh?eh", true, "http://hacker.klever.net/ah/oh?eh" ); | 60 | "http://hacker.klever.net/ah/./oh?eh", true, "http://hacker.klever.net/ah/oh?eh" ); |
60 | test_rfc_3986_normalize_uri( | 61 | test_rfc_3986_normalize_uri( |
61 | "http://hacker.klever.net/ah/../oh?", true, "http://hacker.klever.net/oh?" ); | 62 | "http://hacker.klever.net/ah/../oh?", true, "http://hacker.klever.net/oh?" ); |
62 | test_rfc_3986_normalize_uri( | 63 | test_rfc_3986_normalize_uri( |
63 | "http://hacker.klever.net/ah//oh?", true, "http://hacker.klever.net/ah/oh?" ); | 64 | "http://hacker.klever.net/ah//oh?", true, "http://hacker.klever.net/ah/oh?" ); |
64 | test_rfc_3986_normalize_uri( | 65 | test_rfc_3986_normalize_uri( |
65 | "http://hacker.klever.net/ah/?", true, "http://hacker.klever.net/ah/?" ); | 66 | "http://hacker.klever.net/ah/?", true, "http://hacker.klever.net/ah/?" ); |
66 | test_rfc_3986_normalize_uri( | 67 | test_rfc_3986_normalize_uri( |
67 | "http://hacker.klever.net/ah/%", false ); | 68 | "http://hacker.klever.net/ah/%", false ); |
68 | test_rfc_3986_normalize_uri( | 69 | test_rfc_3986_normalize_uri( |
69 | "http://hacker.klever.net/ah/%a", false ); | 70 | "http://hacker.klever.net/ah/%a", false ); |
70 | test_rfc_3986_normalize_uri( | 71 | test_rfc_3986_normalize_uri( |
71 | "http://hacker.klever.net/ah/%zx", false ); | 72 | "http://hacker.klever.net/ah/%zx", false ); |
72 | test_rfc_3986_normalize_uri( | 73 | test_rfc_3986_normalize_uri( |
73 | "http://hacker.klever.net/ah/%5x", false ); | 74 | "http://hacker.klever.net/ah/%5x", false ); |
74 | test_rfc_3986_normalize_uri( | 75 | test_rfc_3986_normalize_uri( |
75 | "Http://Hacker.Klever.Net:", true, "http://hacker.klever.net/" ); | 76 | "Http://Hacker.Klever.Net:", true, "http://hacker.klever.net/" ); |
76 | test_rfc_3986_normalize_uri( | 77 | test_rfc_3986_normalize_uri( |
77 | "http://www.xxx.com/openid/1", true, "http://www.xxx.com/openid/1" ); | 78 | "http://www.xxx.com/openid/1", true, "http://www.xxx.com/openid/1" ); |
78 | } | 79 | } |
79 | 80 | ||
80 | void test_w3c_to_time(const char *w3c,time_t expected) { | 81 | void test_w3c_to_time(const char *w3c,time_t expected) { |
81 | time_t t = opkele::util::w3c_to_time(w3c); | 82 | time_t t = opkele::util::w3c_to_time(w3c); |
82 | if(t!=expected) { | 83 | if(t!=expected) { |
83 | char tmp[512]; snprintf(tmp,sizeof(tmp)-1, | 84 | char tmp[512]; snprintf(tmp,sizeof(tmp)-1, |
84 | "test failed for %s, expected %lu, got %lu (expected-got == %lu)", | 85 | "test failed for %s, expected %lu, got %lu (expected-got == %lu)", |
85 | w3c, (unsigned long)expected, (unsigned long)t, | 86 | w3c, (unsigned long)expected, (unsigned long)t, |
86 | (unsigned long)(expected-t) ); | 87 | (unsigned long)(expected-t) ); |
87 | throw failed_test(OPKELE_CP_ tmp); | 88 | throw failed_test(OPKELE_CP_ tmp); |
88 | } | 89 | } |
89 | } | 90 | } |
90 | 91 | ||
91 | void test_w3c_to_time() { | 92 | void test_w3c_to_time() { |
92 | test_w3c_to_time("2008-06-29T12:33:44",1214742824); | 93 | test_w3c_to_time("2008-06-29T12:33:44",1214742824); |
93 | } | 94 | } |
94 | 95 | ||
95 | int main() { | 96 | int main() { |
96 | try { | 97 | try { |
97 | test_w3c_to_time(); | 98 | test_w3c_to_time(); |
98 | test_rfc_3986_normalize_uri(); | 99 | test_rfc_3986_normalize_uri(); |
99 | }catch(failed_test& ft) { | 100 | }catch(failed_test& ft) { |
100 | cerr << "Test failed: " << ft.what() << endl; | 101 | cerr << "Test failed: " << ft.what() << endl; |
101 | }catch(exception& e) { | 102 | }catch(exception& e) { |
102 | cerr << "oops: " << e.what() << endl; | 103 | cerr << "oops: " << e.what() << endl; |
103 | _exit(1); | 104 | _exit(1); |
104 | } | 105 | } |
105 | _exit(0); | 106 | _exit(0); |
106 | } | 107 | } |