annotate UnitTests/main.cpp @ 338:3a3b3ba8c1e0

fix for uploads through internet explorer 7
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 14 Jan 2013 11:35:01 +0100
parents 26218c4de7e0
children d2c69150a979
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 #include "gtest/gtest.h"
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3 #include <ctype.h>
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
4
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
5 #include "../Core/Compression/ZlibCompressor.h"
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6 #include "../Core/DicomFormat/DicomTag.h"
63
f1d0470ff334 renaming unittests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 50
diff changeset
7 #include "../OrthancCppClient/HttpClient.h"
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 #include "../Core/HttpServer/HttpHandler.h"
63
f1d0470ff334 renaming unittests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 50
diff changeset
9 #include "../Core/OrthancException.h"
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 #include "../Core/Toolbox.h"
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 #include "../Core/Uuid.h"
63
f1d0470ff334 renaming unittests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 50
diff changeset
12 #include "../OrthancServer/FromDcmtkBridge.h"
f1d0470ff334 renaming unittests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 50
diff changeset
13 #include "../OrthancServer/OrthancInitialization.h"
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14
63
f1d0470ff334 renaming unittests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 50
diff changeset
15 using namespace Orthanc;
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 TEST(Uuid, Generation)
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19 {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20 for (int i = 0; i < 10; i++)
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21 {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22 std::string s = Toolbox::GenerateUuid();
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23 ASSERT_TRUE(Toolbox::IsUuid(s));
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27 TEST(Uuid, Test)
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28 {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29 ASSERT_FALSE(Toolbox::IsUuid(""));
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30 ASSERT_FALSE(Toolbox::IsUuid("012345678901234567890123456789012345"));
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31 ASSERT_TRUE(Toolbox::IsUuid("550e8400-e29b-41d4-a716-446655440000"));
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
33
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
34 TEST(Zlib, Basic)
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35 {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36 std::string s = Toolbox::GenerateUuid();
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
37 s = s + s + s + s;
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
38
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
39 std::string compressed;
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
40 ZlibCompressor c;
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
41 c.Compress(compressed, s);
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
42
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
43 std::string uncompressed;
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
44 c.Uncompress(uncompressed, compressed);
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
45
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
46 ASSERT_EQ(s.size(), uncompressed.size());
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
47 ASSERT_EQ(0, memcmp(&s[0], &uncompressed[0], s.size()));
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
48 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
49
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
50 TEST(Zlib, Empty)
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
51 {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
52 std::string s = "";
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
53
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
54 std::string compressed;
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
55 ZlibCompressor c;
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
56 c.Compress(compressed, s);
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
57
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
58 std::string uncompressed;
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
59 c.Uncompress(uncompressed, compressed);
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
60
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
61 ASSERT_EQ(0u, uncompressed.size());
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
62 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
63
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
64 TEST(ParseGetQuery, Basic)
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
65 {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
66 HttpHandler::Arguments a;
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
67 HttpHandler::ParseGetQuery(a, "aaa=baaa&bb=a&aa=c");
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
68 ASSERT_EQ(3u, a.size());
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
69 ASSERT_EQ(a["aaa"], "baaa");
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
70 ASSERT_EQ(a["bb"], "a");
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
71 ASSERT_EQ(a["aa"], "c");
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
72 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
73
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
74 TEST(ParseGetQuery, BasicEmpty)
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
75 {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
76 HttpHandler::Arguments a;
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
77 HttpHandler::ParseGetQuery(a, "aaa&bb=aa&aa");
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
78 ASSERT_EQ(3u, a.size());
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
79 ASSERT_EQ(a["aaa"], "");
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
80 ASSERT_EQ(a["bb"], "aa");
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
81 ASSERT_EQ(a["aa"], "");
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
82 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
83
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
84 TEST(ParseGetQuery, Single)
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
85 {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
86 HttpHandler::Arguments a;
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
87 HttpHandler::ParseGetQuery(a, "aaa=baaa");
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
88 ASSERT_EQ(1u, a.size());
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
89 ASSERT_EQ(a["aaa"], "baaa");
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
90 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
91
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
92 TEST(ParseGetQuery, SingleEmpty)
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
93 {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
94 HttpHandler::Arguments a;
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
95 HttpHandler::ParseGetQuery(a, "aaa");
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
96 ASSERT_EQ(1u, a.size());
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
97 ASSERT_EQ(a["aaa"], "");
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
98 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
99
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
100 TEST(DicomFormat, Tag)
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
101 {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
102 ASSERT_EQ("PatientName", FromDcmtkBridge::GetName(DicomTag(0x0010, 0x0010)));
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
103
304
4eea080e6e7a refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 247
diff changeset
104 DicomTag t = FromDcmtkBridge::ParseTag("SeriesDescription");
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
105 ASSERT_EQ(0x0008, t.GetGroup());
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
106 ASSERT_EQ(0x103E, t.GetElement());
304
4eea080e6e7a refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 247
diff changeset
107
4eea080e6e7a refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 247
diff changeset
108 t = FromDcmtkBridge::ParseTag("0020-e040");
4eea080e6e7a refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 247
diff changeset
109 ASSERT_EQ(0x0020, t.GetGroup());
4eea080e6e7a refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 247
diff changeset
110 ASSERT_EQ(0xe040, t.GetElement());
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
111 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
112
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
113
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
114 TEST(Uri, SplitUriComponents)
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
115 {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
116 UriComponents c;
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
117 Toolbox::SplitUriComponents(c, "/cou/hello/world");
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
118 ASSERT_EQ(3u, c.size());
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
119 ASSERT_EQ("cou", c[0]);
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
120 ASSERT_EQ("hello", c[1]);
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
121 ASSERT_EQ("world", c[2]);
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
122
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
123 Toolbox::SplitUriComponents(c, "/cou/hello/world/");
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
124 ASSERT_EQ(3u, c.size());
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
125 ASSERT_EQ("cou", c[0]);
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
126 ASSERT_EQ("hello", c[1]);
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
127 ASSERT_EQ("world", c[2]);
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
128
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
129 Toolbox::SplitUriComponents(c, "/cou/hello/world/a");
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
130 ASSERT_EQ(4u, c.size());
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
131 ASSERT_EQ("cou", c[0]);
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
132 ASSERT_EQ("hello", c[1]);
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
133 ASSERT_EQ("world", c[2]);
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
134 ASSERT_EQ("a", c[3]);
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
135
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
136 Toolbox::SplitUriComponents(c, "/");
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
137 ASSERT_EQ(0u, c.size());
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
138
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
139 Toolbox::SplitUriComponents(c, "/hello");
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
140 ASSERT_EQ(1u, c.size());
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
141 ASSERT_EQ("hello", c[0]);
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
142
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
143 Toolbox::SplitUriComponents(c, "/hello/");
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
144 ASSERT_EQ(1u, c.size());
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
145 ASSERT_EQ("hello", c[0]);
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
146
63
f1d0470ff334 renaming unittests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 50
diff changeset
147 ASSERT_THROW(Toolbox::SplitUriComponents(c, ""), OrthancException);
f1d0470ff334 renaming unittests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 50
diff changeset
148 ASSERT_THROW(Toolbox::SplitUriComponents(c, "a"), OrthancException);
207
7f74209ea0f8 RestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 177
diff changeset
149 ASSERT_THROW(Toolbox::SplitUriComponents(c, "/coucou//coucou"), OrthancException);
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
150 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
151
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
152
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
153 TEST(Uri, Child)
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
154 {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
155 UriComponents c1; Toolbox::SplitUriComponents(c1, "/hello/world");
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
156 UriComponents c2; Toolbox::SplitUriComponents(c2, "/hello/hello");
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
157 UriComponents c3; Toolbox::SplitUriComponents(c3, "/hello");
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
158 UriComponents c4; Toolbox::SplitUriComponents(c4, "/world");
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
159 UriComponents c5; Toolbox::SplitUriComponents(c5, "/");
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
160
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
161 ASSERT_TRUE(Toolbox::IsChildUri(c1, c1));
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
162 ASSERT_FALSE(Toolbox::IsChildUri(c1, c2));
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
163 ASSERT_FALSE(Toolbox::IsChildUri(c1, c3));
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
164 ASSERT_FALSE(Toolbox::IsChildUri(c1, c4));
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
165 ASSERT_FALSE(Toolbox::IsChildUri(c1, c5));
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
166
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
167 ASSERT_FALSE(Toolbox::IsChildUri(c2, c1));
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
168 ASSERT_TRUE(Toolbox::IsChildUri(c2, c2));
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
169 ASSERT_FALSE(Toolbox::IsChildUri(c2, c3));
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
170 ASSERT_FALSE(Toolbox::IsChildUri(c2, c4));
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
171 ASSERT_FALSE(Toolbox::IsChildUri(c2, c5));
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
172
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
173 ASSERT_TRUE(Toolbox::IsChildUri(c3, c1));
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
174 ASSERT_TRUE(Toolbox::IsChildUri(c3, c2));
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
175 ASSERT_TRUE(Toolbox::IsChildUri(c3, c3));
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
176 ASSERT_FALSE(Toolbox::IsChildUri(c3, c4));
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
177 ASSERT_FALSE(Toolbox::IsChildUri(c3, c5));
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
178
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
179 ASSERT_FALSE(Toolbox::IsChildUri(c4, c1));
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
180 ASSERT_FALSE(Toolbox::IsChildUri(c4, c2));
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
181 ASSERT_FALSE(Toolbox::IsChildUri(c4, c3));
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
182 ASSERT_TRUE(Toolbox::IsChildUri(c4, c4));
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
183 ASSERT_FALSE(Toolbox::IsChildUri(c4, c5));
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
184
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
185 ASSERT_TRUE(Toolbox::IsChildUri(c5, c1));
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
186 ASSERT_TRUE(Toolbox::IsChildUri(c5, c2));
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
187 ASSERT_TRUE(Toolbox::IsChildUri(c5, c3));
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
188 ASSERT_TRUE(Toolbox::IsChildUri(c5, c4));
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
189 ASSERT_TRUE(Toolbox::IsChildUri(c5, c5));
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
190 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
191
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
192 TEST(Uri, AutodetectMimeType)
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
193 {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
194 ASSERT_EQ("", Toolbox::AutodetectMimeType("../NOTES"));
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
195 ASSERT_EQ("", Toolbox::AutodetectMimeType(""));
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
196 ASSERT_EQ("", Toolbox::AutodetectMimeType("/"));
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
197 ASSERT_EQ("", Toolbox::AutodetectMimeType("a/a"));
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
198
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
199 ASSERT_EQ("text/plain", Toolbox::AutodetectMimeType("../NOTES.txt"));
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
200 ASSERT_EQ("text/plain", Toolbox::AutodetectMimeType("../coucou.xml/NOTES.txt"));
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
201 ASSERT_EQ("text/xml", Toolbox::AutodetectMimeType("../.xml"));
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
202
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
203 ASSERT_EQ("application/javascript", Toolbox::AutodetectMimeType("NOTES.js"));
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
204 ASSERT_EQ("application/json", Toolbox::AutodetectMimeType("NOTES.json"));
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
205 ASSERT_EQ("application/pdf", Toolbox::AutodetectMimeType("NOTES.pdf"));
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
206 ASSERT_EQ("text/css", Toolbox::AutodetectMimeType("NOTES.css"));
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
207 ASSERT_EQ("text/html", Toolbox::AutodetectMimeType("NOTES.html"));
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
208 ASSERT_EQ("text/plain", Toolbox::AutodetectMimeType("NOTES.txt"));
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
209 ASSERT_EQ("text/xml", Toolbox::AutodetectMimeType("NOTES.xml"));
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
210 ASSERT_EQ("image/gif", Toolbox::AutodetectMimeType("NOTES.gif"));
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
211 ASSERT_EQ("image/jpeg", Toolbox::AutodetectMimeType("NOTES.jpg"));
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
212 ASSERT_EQ("image/jpeg", Toolbox::AutodetectMimeType("NOTES.jpeg"));
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
213 ASSERT_EQ("image/png", Toolbox::AutodetectMimeType("NOTES.png"));
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
214 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
215
22
1bc6327d1de3 MD5 sum
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 0
diff changeset
216 TEST(Toolbox, ComputeMD5)
1bc6327d1de3 MD5 sum
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 0
diff changeset
217 {
1bc6327d1de3 MD5 sum
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 0
diff changeset
218 std::string s;
1bc6327d1de3 MD5 sum
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 0
diff changeset
219
1bc6327d1de3 MD5 sum
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 0
diff changeset
220 // # echo -n "Hello" | md5sum
1bc6327d1de3 MD5 sum
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 0
diff changeset
221
1bc6327d1de3 MD5 sum
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 0
diff changeset
222 Toolbox::ComputeMD5(s, "Hello");
1bc6327d1de3 MD5 sum
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 0
diff changeset
223 ASSERT_EQ("8b1a9953c4611296a827abf8c47804d7", s);
1bc6327d1de3 MD5 sum
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 0
diff changeset
224 Toolbox::ComputeMD5(s, "");
1bc6327d1de3 MD5 sum
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 0
diff changeset
225 ASSERT_EQ("d41d8cd98f00b204e9800998ecf8427e", s);
1bc6327d1de3 MD5 sum
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 0
diff changeset
226 }
1bc6327d1de3 MD5 sum
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 0
diff changeset
227
177
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 159
diff changeset
228 TEST(Toolbox, ComputeSHA1)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 159
diff changeset
229 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 159
diff changeset
230 std::string s;
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 159
diff changeset
231
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 159
diff changeset
232 Toolbox::ComputeSHA1(s, "The quick brown fox jumps over the lazy dog");
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 159
diff changeset
233 ASSERT_EQ("2fd4e1c6-7a2d28fc-ed849ee1-bb76e739-1b93eb12", s);
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 159
diff changeset
234 Toolbox::ComputeSHA1(s, "");
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 159
diff changeset
235 ASSERT_EQ("da39a3ee-5e6b4b0d-3255bfef-95601890-afd80709", s);
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 159
diff changeset
236 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 159
diff changeset
237
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 159
diff changeset
238
24
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 22
diff changeset
239 TEST(Toolbox, Base64)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 22
diff changeset
240 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 22
diff changeset
241 ASSERT_EQ("", Toolbox::EncodeBase64(""));
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 22
diff changeset
242 ASSERT_EQ("YQ==", Toolbox::EncodeBase64("a"));
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 22
diff changeset
243 ASSERT_EQ("SGVsbG8gd29ybGQ=", Toolbox::EncodeBase64("Hello world"));
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 22
diff changeset
244 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 22
diff changeset
245
87
8517e2c44283 path to configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 63
diff changeset
246 TEST(Toolbox, PathToExecutable)
8517e2c44283 path to configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 63
diff changeset
247 {
8517e2c44283 path to configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 63
diff changeset
248 printf("[%s]\n", Toolbox::GetPathToExecutable().c_str());
8517e2c44283 path to configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 63
diff changeset
249 printf("[%s]\n", Toolbox::GetDirectoryOfExecutable().c_str());
8517e2c44283 path to configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 63
diff changeset
250 }
8517e2c44283 path to configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 63
diff changeset
251
247
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 235
diff changeset
252 TEST(Toolbox, StripSpaces)
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 235
diff changeset
253 {
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 235
diff changeset
254 ASSERT_EQ("", Toolbox::StripSpaces(" \t \r \n "));
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 235
diff changeset
255 ASSERT_EQ("coucou", Toolbox::StripSpaces(" coucou \t \r \n "));
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 235
diff changeset
256 ASSERT_EQ("cou cou", Toolbox::StripSpaces(" cou cou \n "));
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 235
diff changeset
257 ASSERT_EQ("c", Toolbox::StripSpaces(" \n\t c\r \n "));
c9b3ba0fd140 path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 235
diff changeset
258 }
100
27dc762e3dc8 getting rid of static dcmtk for debian
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 87
diff changeset
259
27dc762e3dc8 getting rid of static dcmtk for debian
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 87
diff changeset
260
102
7593b57dc1bf switch to google log
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 101
diff changeset
261 #include <glog/logging.h>
100
27dc762e3dc8 getting rid of static dcmtk for debian
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 87
diff changeset
262
27dc762e3dc8 getting rid of static dcmtk for debian
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 87
diff changeset
263 TEST(Logger, Basic)
27dc762e3dc8 getting rid of static dcmtk for debian
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 87
diff changeset
264 {
102
7593b57dc1bf switch to google log
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 101
diff changeset
265 LOG(INFO) << "I say hello";
100
27dc762e3dc8 getting rid of static dcmtk for debian
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 87
diff changeset
266 }
27dc762e3dc8 getting rid of static dcmtk for debian
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 87
diff changeset
267
107
3b45473c0a73 replace boost::locale with iconv for debian
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
268 TEST(Toolbox, ConvertFromLatin1)
3b45473c0a73 replace boost::locale with iconv for debian
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
269 {
3b45473c0a73 replace boost::locale with iconv for debian
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
270 // This is a Latin-1 test string
3b45473c0a73 replace boost::locale with iconv for debian
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
271 const unsigned char data[10] = { 0xe0, 0xe9, 0xea, 0xe7, 0x26, 0xc6, 0x61, 0x62, 0x63, 0x00 };
3b45473c0a73 replace boost::locale with iconv for debian
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
272
3b45473c0a73 replace boost::locale with iconv for debian
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
273 /*FILE* f = fopen("/tmp/tutu", "w");
3b45473c0a73 replace boost::locale with iconv for debian
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
274 fwrite(&data[0], 9, 1, f);
3b45473c0a73 replace boost::locale with iconv for debian
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
275 fclose(f);*/
3b45473c0a73 replace boost::locale with iconv for debian
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
276
3b45473c0a73 replace boost::locale with iconv for debian
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
277 std::string s((char*) &data[0], 10);
3b45473c0a73 replace boost::locale with iconv for debian
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
278 ASSERT_EQ("&abc", Toolbox::ConvertToAscii(s));
3b45473c0a73 replace boost::locale with iconv for debian
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
279
3b45473c0a73 replace boost::locale with iconv for debian
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
280 // Open in Emacs, then save with UTF-8 encoding, then "hexdump -C"
3b45473c0a73 replace boost::locale with iconv for debian
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
281 std::string utf8 = Toolbox::ConvertToUtf8(s, "ISO-8859-1");
235
1e0595885a81 cleaning room
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 222
diff changeset
282 ASSERT_EQ(15u, utf8.size());
107
3b45473c0a73 replace boost::locale with iconv for debian
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
283 ASSERT_EQ(0xc3, static_cast<unsigned char>(utf8[0]));
3b45473c0a73 replace boost::locale with iconv for debian
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
284 ASSERT_EQ(0xa0, static_cast<unsigned char>(utf8[1]));
3b45473c0a73 replace boost::locale with iconv for debian
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
285 ASSERT_EQ(0xc3, static_cast<unsigned char>(utf8[2]));
3b45473c0a73 replace boost::locale with iconv for debian
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
286 ASSERT_EQ(0xa9, static_cast<unsigned char>(utf8[3]));
3b45473c0a73 replace boost::locale with iconv for debian
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
287 ASSERT_EQ(0xc3, static_cast<unsigned char>(utf8[4]));
3b45473c0a73 replace boost::locale with iconv for debian
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
288 ASSERT_EQ(0xaa, static_cast<unsigned char>(utf8[5]));
3b45473c0a73 replace boost::locale with iconv for debian
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
289 ASSERT_EQ(0xc3, static_cast<unsigned char>(utf8[6]));
3b45473c0a73 replace boost::locale with iconv for debian
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
290 ASSERT_EQ(0xa7, static_cast<unsigned char>(utf8[7]));
3b45473c0a73 replace boost::locale with iconv for debian
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
291 ASSERT_EQ(0x26, static_cast<unsigned char>(utf8[8]));
3b45473c0a73 replace boost::locale with iconv for debian
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
292 ASSERT_EQ(0xc3, static_cast<unsigned char>(utf8[9]));
3b45473c0a73 replace boost::locale with iconv for debian
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
293 ASSERT_EQ(0x86, static_cast<unsigned char>(utf8[10]));
3b45473c0a73 replace boost::locale with iconv for debian
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
294 ASSERT_EQ(0x61, static_cast<unsigned char>(utf8[11]));
3b45473c0a73 replace boost::locale with iconv for debian
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
295 ASSERT_EQ(0x62, static_cast<unsigned char>(utf8[12]));
3b45473c0a73 replace boost::locale with iconv for debian
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
296 ASSERT_EQ(0x63, static_cast<unsigned char>(utf8[13]));
3b45473c0a73 replace boost::locale with iconv for debian
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
297 ASSERT_EQ(0x00, static_cast<unsigned char>(utf8[14])); // Null-terminated string
3b45473c0a73 replace boost::locale with iconv for debian
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
298 }
3b45473c0a73 replace boost::locale with iconv for debian
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
299
336
3c291753231f url decode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 304
diff changeset
300 TEST(Toolbox, UrlDecode)
3c291753231f url decode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 304
diff changeset
301 {
3c291753231f url decode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 304
diff changeset
302 std::string s;
3c291753231f url decode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 304
diff changeset
303
3c291753231f url decode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 304
diff changeset
304 s = "Hello%20World";
3c291753231f url decode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 304
diff changeset
305 Toolbox::UrlDecode(s);
3c291753231f url decode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 304
diff changeset
306 ASSERT_EQ("Hello World", s);
3c291753231f url decode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 304
diff changeset
307
337
26218c4de7e0 test added
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
308 s = "%21%23%24%26%27%28%29%2A%2B%2c%2f%3A%3b%3d%3f%40%5B%5D%90%ff";
336
3c291753231f url decode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 304
diff changeset
309 Toolbox::UrlDecode(s);
337
26218c4de7e0 test added
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
310 std::string ss = "!#$&'()*+,/:;=?@[]";
26218c4de7e0 test added
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
311 ss.push_back((char) 144);
26218c4de7e0 test added
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
312 ss.push_back((char) 255);
26218c4de7e0 test added
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
313 ASSERT_EQ(ss, s);
336
3c291753231f url decode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 304
diff changeset
314
3c291753231f url decode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 304
diff changeset
315 s = "(2000%2C00A4)+Other";
3c291753231f url decode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 304
diff changeset
316 Toolbox::UrlDecode(s);
3c291753231f url decode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 304
diff changeset
317 ASSERT_EQ("(2000,00A4) Other", s);
3c291753231f url decode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 304
diff changeset
318 }
3c291753231f url decode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 304
diff changeset
319
100
27dc762e3dc8 getting rid of static dcmtk for debian
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 87
diff changeset
320
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
321 int main(int argc, char **argv)
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
322 {
102
7593b57dc1bf switch to google log
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 101
diff changeset
323 // Initialize Google's logging library.
7593b57dc1bf switch to google log
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 101
diff changeset
324 FLAGS_logtostderr = true;
137
0e97abc7b950 fix of a bug in older versions of sqlite
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 107
diff changeset
325 FLAGS_minloglevel = 0;
159
c08fbad40ddd less verbosity in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 137
diff changeset
326
c08fbad40ddd less verbosity in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 137
diff changeset
327 // Go to trace-level verbosity
c08fbad40ddd less verbosity in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 137
diff changeset
328 //FLAGS_v = 1;
c08fbad40ddd less verbosity in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 137
diff changeset
329
102
7593b57dc1bf switch to google log
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 101
diff changeset
330 google::InitGoogleLogging("Orthanc");
100
27dc762e3dc8 getting rid of static dcmtk for debian
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 87
diff changeset
331
63
f1d0470ff334 renaming unittests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 50
diff changeset
332 OrthancInitialize();
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
333 ::testing::InitGoogleTest(&argc, argv);
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
334 int result = RUN_ALL_TESTS();
63
f1d0470ff334 renaming unittests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 50
diff changeset
335 OrthancFinalize();
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
336 return result;
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
337 }