5 * Moonlight List (moonlight-list@lists.ximian.com)
7 * Copyright 2009 Novell, Inc. (http://www.novell.com)
9 * See the LICENSE file included with the distribution for details.
18 TEST(Utils
, parse_rfc_1945_token_test
)
26 input
= g_strdup_printf ("asd");
27 result
= parse_rfc_1945_token (input
, &c
, &end
);
28 EXPECT_EQ (result
, input
);
30 EXPECT_EQ (end
, (void*) NULL
);
33 result
= parse_rfc_1945_token (NULL
, NULL
, NULL
);
34 EXPECT_EQ (result
, (void*) NULL
);
36 free
= input
= g_strdup_printf ("LI(H\"ñoIH\"");
37 result
= parse_rfc_1945_token (input
, &c
, &end
);
38 EXPECT_EQ (result
, input
);
39 EXPECT_STREQ (result
, "LI");
41 EXPECT_EQ (end
, result
+ 3);
43 result
= parse_rfc_1945_token (input
, &c
, &end
);
44 EXPECT_EQ (result
, input
);
45 EXPECT_STREQ (result
, "H");
47 EXPECT_EQ (end
, result
+ 2);
49 result
= parse_rfc_1945_token (input
, &c
, &end
);
50 EXPECT_EQ (result
, input
);
51 EXPECT_STREQ (result
, "ñoIH");
53 EXPECT_EQ (end
, result
+ 6);
56 free
= input
= g_strdup_printf ("packet-pair-experiment=1, no-cache, client-id=1089364828, xResetStrm=1, features=\"seekable,stridable,playlist,skipforward\", timeout=60000");
57 result
= parse_rfc_1945_token (input
, &c
, &end
);
58 EXPECT_EQ (result
, input
);
59 EXPECT_STREQ (result
, "packet-pair-experiment");
61 EXPECT_EQ (end
, result
+ 23);
63 result
= parse_rfc_1945_token (input
, &c
, &end
);
64 EXPECT_EQ (result
, input
);
65 EXPECT_STREQ (result
, "1");
67 EXPECT_EQ (end
, result
+ 2);
69 result
= parse_rfc_1945_token (input
, &c
, &end
);
70 EXPECT_EQ (result
, input
+ 1);
71 EXPECT_STREQ (result
, "no-cache");
73 EXPECT_EQ (end
, result
+ 9);
75 result
= parse_rfc_1945_token (input
, &c
, &end
);
76 EXPECT_EQ (result
, input
+ 1);
77 EXPECT_STREQ (result
, "client-id");
79 EXPECT_EQ (end
, result
+ 10);
81 result
= parse_rfc_1945_token (input
, &c
, &end
);
82 EXPECT_EQ (result
, input
);
83 EXPECT_STREQ (result
, "1089364828");
85 EXPECT_EQ (end
, result
+ 11);
87 result
= parse_rfc_1945_token (input
, &c
, &end
);
88 EXPECT_EQ (result
, input
+ 1);
89 EXPECT_STREQ (result
, "xResetStrm");
91 EXPECT_EQ (end
, result
+ 11);
93 result
= parse_rfc_1945_token (input
, &c
, &end
);
94 EXPECT_EQ (result
, input
);
95 EXPECT_STREQ (result
, "1");
97 EXPECT_EQ (end
, result
+ 2);
99 result
= parse_rfc_1945_token (input
, &c
, &end
);
100 EXPECT_EQ (result
, input
+ 1);
101 EXPECT_STREQ (result
, "features");
103 EXPECT_EQ (end
, result
+ 9);
105 result
= parse_rfc_1945_token (input
, &c
, &end
);
106 EXPECT_EQ (result
, input
+ 1);
107 EXPECT_STREQ (result
, "seekable");
109 EXPECT_EQ (end
, result
+ 9);
111 result
= parse_rfc_1945_token (input
, &c
, &end
);
112 EXPECT_EQ (result
, input
);
113 EXPECT_STREQ (result
, "stridable");
115 EXPECT_EQ (end
, result
+ 10);
117 result
= parse_rfc_1945_token (input
, &c
, &end
);
118 EXPECT_EQ (result
, input
);
119 EXPECT_STREQ (result
, "playlist");
121 EXPECT_EQ (end
, result
+ 9);
123 result
= parse_rfc_1945_token (input
, &c
, &end
);
124 EXPECT_EQ (result
, input
);
125 EXPECT_STREQ (result
, "skipforward");
127 EXPECT_EQ (end
, result
+ 12);
129 result
= parse_rfc_1945_token (input
, &c
, &end
);
130 EXPECT_EQ (result
, input
+ 2);
131 EXPECT_STREQ (result
, "timeout");
133 EXPECT_EQ (end
, result
+ 8);
135 result
= parse_rfc_1945_token (input
, &c
, &end
);
136 EXPECT_EQ (result
, input
);
137 EXPECT_STREQ (result
, "60000");
139 EXPECT_EQ (end
, (void*) NULL
);
145 TEST(Utils
, parse_rfc_1945_quoted_string_test
)
153 input
= g_strdup_printf ("\"asd");
154 result
= parse_rfc_1945_quoted_string (input
, &c
, &end
);
155 EXPECT_EQ (result
, input
+ 1);
156 EXPECT_STREQ (result
, "asd");
158 EXPECT_EQ (end
, (void*) NULL
);
161 result
= parse_rfc_1945_quoted_string (NULL
, NULL
, NULL
);
162 EXPECT_EQ (result
, (void*) NULL
);
164 free
= input
= g_strdup_printf ("LI(H\"ñoIH\"");
165 result
= parse_rfc_1945_quoted_string (input
, &c
, &end
);
166 EXPECT_EQ (result
, (void*) NULL
);
169 free
= input
= g_strdup_printf ("\"seekable,stridable,playlist,skipforward\"");
170 result
= parse_rfc_1945_quoted_string (input
, &c
, &end
);
171 EXPECT_EQ (result
, input
+ 1);
172 EXPECT_STREQ (result
, "seekable,stridable,playlist,skipforward");
174 EXPECT_EQ (end
, result
+ 40);