Mercurial > hg > orthanc
annotate UnitTests/RestApi.cpp @ 293:7417915ce0f3
preparing for release
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 14 Dec 2012 15:34:59 +0100 |
parents | e5402c368b21 |
children | 78a8eaa5f30b |
rev | line source |
---|---|
209 | 1 #include "gtest/gtest.h" |
2 | |
3 #include <ctype.h> | |
4 #include <glog/logging.h> | |
5 | |
6 #include "../Core/RestApi/RestApi.h" | |
221
e7432706b354
accessors to storage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
210
diff
changeset
|
7 #include "../Core/Uuid.h" |
e7432706b354
accessors to storage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
210
diff
changeset
|
8 #include "../Core/OrthancException.h" |
e7432706b354
accessors to storage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
210
diff
changeset
|
9 #include "../Core/Compression/ZlibCompressor.h" |
209 | 10 |
11 using namespace Orthanc; | |
12 | |
13 TEST(RestApi, RestApiPath) | |
14 { | |
15 RestApiPath::Components args; | |
16 UriComponents trail; | |
17 | |
18 { | |
19 RestApiPath uri("/coucou/{abc}/d/*"); | |
20 ASSERT_TRUE(uri.Match(args, trail, "/coucou/moi/d/e/f/g")); | |
21 ASSERT_EQ(1u, args.size()); | |
22 ASSERT_EQ(3u, trail.size()); | |
23 ASSERT_EQ("moi", args["abc"]); | |
24 ASSERT_EQ("e", trail[0]); | |
25 ASSERT_EQ("f", trail[1]); | |
26 ASSERT_EQ("g", trail[2]); | |
27 | |
28 ASSERT_FALSE(uri.Match(args, trail, "/coucou/moi/f")); | |
29 ASSERT_TRUE(uri.Match(args, trail, "/coucou/moi/d/")); | |
30 ASSERT_FALSE(uri.Match(args, trail, "/a/moi/d")); | |
31 ASSERT_FALSE(uri.Match(args, trail, "/coucou/moi")); | |
32 } | |
33 | |
34 { | |
35 RestApiPath uri("/coucou/{abc}/d"); | |
36 ASSERT_FALSE(uri.Match(args, trail, "/coucou/moi/d/e/f/g")); | |
37 ASSERT_TRUE(uri.Match(args, trail, "/coucou/moi/d")); | |
38 ASSERT_EQ(1u, args.size()); | |
39 ASSERT_EQ(0u, trail.size()); | |
40 ASSERT_EQ("moi", args["abc"]); | |
41 } | |
42 | |
43 { | |
44 RestApiPath uri("/*"); | |
45 ASSERT_TRUE(uri.Match(args, trail, "/a/b/c")); | |
46 ASSERT_EQ(0u, args.size()); | |
47 ASSERT_EQ(3u, trail.size()); | |
48 ASSERT_EQ("a", trail[0]); | |
49 ASSERT_EQ("b", trail[1]); | |
50 ASSERT_EQ("c", trail[2]); | |
51 } | |
52 } |