llurlentry_test.cpp
上传用户:king477883
上传日期:2021-03-01
资源大小:9553k
文件大小:20k
源码类别:

游戏引擎

开发平台:

C++ Builder

  1. /**
  2.  * @file llurlentry_test.cpp
  3.  * @author Martin Reddy
  4.  * @brief Unit tests for LLUrlEntry objects
  5.  *
  6.  * $LicenseInfo:firstyear=2009&license=viewergpl$
  7.  * 
  8.  * Copyright (c) 2009-2010, Linden Research, Inc.
  9.  * 
  10.  * Second Life Viewer Source Code
  11.  * The source code in this file ("Source Code") is provided by Linden Lab
  12.  * to you under the terms of the GNU General Public License, version 2.0
  13.  * ("GPL"), unless you have obtained a separate licensing agreement
  14.  * ("Other License"), formally executed by you and Linden Lab.  Terms of
  15.  * the GPL can be found in doc/GPL-license.txt in this distribution, or
  16.  * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
  17.  * 
  18.  * There are special exceptions to the terms and conditions of the GPL as
  19.  * it is applied to this Source Code. View the full text of the exception
  20.  * in the file doc/FLOSS-exception.txt in this software distribution, or
  21.  * online at
  22.  * http://secondlifegrid.net/programs/open_source/licensing/flossexception
  23.  * 
  24.  * By copying, modifying or distributing this software, you acknowledge
  25.  * that you have read and understood your obligations described above,
  26.  * and agree to abide by those obligations.
  27.  * 
  28.  * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
  29.  * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
  30.  * COMPLETENESS OR PERFORMANCE.
  31.  * $/LicenseInfo$
  32.  */
  33. #include "linden_common.h"
  34. #include "../llurlentry.h"
  35. #include "llurlentry_stub.cpp"
  36. #include "lltut.h"
  37. #include "../lluicolortable.h"
  38. #include <boost/regex.hpp>
  39. LLUIColor LLUIColorTable::getColor(const std::string& name, const LLColor4& default_color) const
  40. {
  41. return LLUIColor();
  42. }
  43. LLUIColor::LLUIColor() : mColorPtr(NULL) {}
  44. namespace tut
  45. {
  46. struct LLUrlEntryData
  47. {
  48. };
  49. typedef test_group<LLUrlEntryData> factory;
  50. typedef factory::object object;
  51. }
  52. namespace
  53. {
  54. tut::factory tf("LLUrlEntry");
  55. }
  56. namespace tut
  57. {
  58. void testRegex(const std::string &testname, LLUrlEntryBase &entry,
  59.    const char *text, const std::string &expected)
  60. {
  61. boost::regex regex = entry.getPattern();
  62. std::string url = "";
  63. boost::cmatch result;
  64. bool found = boost::regex_search(text, result, regex);
  65. if (found)
  66. {
  67. S32 start = static_cast<U32>(result[0].first - text);
  68. S32 end = static_cast<U32>(result[0].second - text);
  69. url = entry.getUrl(std::string(text+start, end-start));
  70. }
  71. ensure_equals(testname, url, expected);
  72. }
  73. template<> template<>
  74. void object::test<1>()
  75. {
  76. //
  77. // test LLUrlEntryHTTP - standard http Urls
  78. //
  79. LLUrlEntryHTTP url;
  80. testRegex("no valid url", url,
  81.   "htp://slurl.com/",
  82.   "");
  83. testRegex("simple http (1)", url,
  84.   "http://slurl.com/",
  85.   "http://slurl.com/");
  86. testRegex("simple http (2)", url,
  87.   "http://slurl.com",
  88.   "http://slurl.com");
  89. testRegex("simple http (3)", url,
  90.   "http://slurl.com/about.php",
  91.   "http://slurl.com/about.php");
  92. testRegex("simple https", url,
  93.   "https://slurl.com/about.php",
  94.   "https://slurl.com/about.php");
  95. testRegex("http in text (1)", url,
  96.   "XX http://slurl.com/ XX",
  97.   "http://slurl.com/");
  98. testRegex("http in text (2)", url,
  99.   "XX http://slurl.com/about.php XX",
  100.   "http://slurl.com/about.php");
  101. testRegex("https in text", url,
  102.   "XX https://slurl.com/about.php XX",
  103.   "https://slurl.com/about.php");
  104. testRegex("two http urls", url,
  105.   "XX http://slurl.com/about.php http://secondlife.com/ XX",
  106.   "http://slurl.com/about.php");
  107. testRegex("http url with port and username", url,
  108.   "XX http://nobody@slurl.com:80/about.php http://secondlife.com/ XX",
  109.   "http://nobody@slurl.com:80/about.php");
  110. testRegex("http url with port, username, and query string", url,
  111.   "XX http://nobody@slurl.com:80/about.php?title=hi%20there http://secondlife.com/ XX",
  112.   "http://nobody@slurl.com:80/about.php?title=hi%20there");
  113. // note: terminating commas will be removed by LLUrlRegistry:findUrl()
  114. testRegex("http url with commas in middle and terminating", url,
  115.   "XX http://slurl.com/?title=Hi,There, XX",
  116.   "http://slurl.com/?title=Hi,There,");
  117. // note: terminating periods will be removed by LLUrlRegistry:findUrl()
  118. testRegex("http url with periods in middle and terminating", url,
  119.   "XX http://slurl.com/index.php. XX",
  120.   "http://slurl.com/index.php.");
  121. // DEV-19842: Closing parenthesis ")" breaks urls
  122. testRegex("http url with brackets (1)", url,
  123.   "XX http://en.wikipedia.org/wiki/JIRA_(software) XX",
  124.   "http://en.wikipedia.org/wiki/JIRA_(software)");
  125. // DEV-19842: Closing parenthesis ")" breaks urls
  126. testRegex("http url with brackets (2)", url, 
  127.   "XX http://jira.secondlife.com/secure/attachment/17990/eggy+avs+in+1.21.0+(93713)+public+nightly.jpg XX",
  128.   "http://jira.secondlife.com/secure/attachment/17990/eggy+avs+in+1.21.0+(93713)+public+nightly.jpg");
  129. // DEV-10353: URLs in chat log terminated incorrectly when newline in chat
  130. testRegex("http url with newlines", url,
  131.   "XXnhttp://www.secondlife.com/nXX",
  132.   "http://www.secondlife.com/");
  133. }
  134. template<> template<>
  135. void object::test<2>()
  136. {
  137. //
  138. // test LLUrlEntryHTTPLabel - wiki-style http Urls with labels
  139. //
  140. LLUrlEntryHTTPLabel url;
  141. testRegex("invalid wiki url [1]", url,
  142.   "[http://www.example.org]",
  143.   "");
  144. testRegex("invalid wiki url [2]", url,
  145.   "[http://www.example.org",
  146.   "");
  147. testRegex("invalid wiki url [3]", url,
  148.   "[http://www.example.org Label",
  149.   "");
  150. testRegex("example.org with label (spaces)", url,
  151.   "[http://www.example.org  Text]",
  152.   "http://www.example.org");
  153. testRegex("example.org with label (tabs)", url,
  154.   "[http://www.example.orgt Text]",
  155.   "http://www.example.org");
  156. testRegex("SL http URL with label", url,
  157.   "[http://www.secondlife.com/ Second Life]",
  158.   "http://www.secondlife.com/");
  159. testRegex("SL https URL with label", url,
  160.   "XXX [https://www.secondlife.com/ Second Life] YYY",
  161.   "https://www.secondlife.com/");
  162. testRegex("SL http URL with label", url,
  163.   "[http://www.secondlife.com/?test=Hi%20There Second Life]",
  164.   "http://www.secondlife.com/?test=Hi%20There");
  165. }
  166. template<> template<>
  167. void object::test<3>()
  168. {
  169. //
  170. // test LLUrlEntrySLURL - second life URLs
  171. //
  172. LLUrlEntrySLURL url;
  173. testRegex("no valid slurl [1]", url,
  174.   "htp://slurl.com/secondlife/Ahern/50/50/50/",
  175.   "");
  176. testRegex("no valid slurl [2]", url,
  177.   "http://slurl.com/secondlife/",
  178.   "");
  179. testRegex("no valid slurl [3]", url,
  180.   "hhtp://slurl.com/secondlife/Ahern/50/FOO/50/",
  181.   "");
  182. testRegex("Ahern (50,50,50) [1]", url,
  183.   "http://slurl.com/secondlife/Ahern/50/50/50/",
  184.   "http://slurl.com/secondlife/Ahern/50/50/50/");
  185. testRegex("Ahern (50,50,50) [2]", url,
  186.   "XXX http://slurl.com/secondlife/Ahern/50/50/50/ XXX",
  187.   "http://slurl.com/secondlife/Ahern/50/50/50/");
  188. testRegex("Ahern (50,50,50) [3]", url,
  189.   "XXX http://slurl.com/secondlife/Ahern/50/50/50 XXX",
  190.   "http://slurl.com/secondlife/Ahern/50/50/50");
  191. testRegex("Ahern (50,50,50) multicase", url,
  192.   "XXX http://SLUrl.com/SecondLife/Ahern/50/50/50/ XXX",
  193.   "http://SLUrl.com/SecondLife/Ahern/50/50/50/");
  194. testRegex("Ahern (50,50) [1]", url,
  195.   "XXX http://slurl.com/secondlife/Ahern/50/50/ XXX",
  196.   "http://slurl.com/secondlife/Ahern/50/50/");
  197. testRegex("Ahern (50,50) [2]", url,
  198.   "XXX http://slurl.com/secondlife/Ahern/50/50 XXX",
  199.   "http://slurl.com/secondlife/Ahern/50/50");
  200. testRegex("Ahern (50)", url,
  201.   "XXX http://slurl.com/secondlife/Ahern/50 XXX",
  202.   "http://slurl.com/secondlife/Ahern/50");
  203. testRegex("Ahern", url,
  204.   "XXX http://slurl.com/secondlife/Ahern/ XXX",
  205.   "http://slurl.com/secondlife/Ahern/");
  206. testRegex("Ahern SLURL with title", url,
  207.   "XXX http://slurl.com/secondlife/Ahern/50/50/50/?title=YOUR%20TITLE%20HERE! XXX",
  208.   "http://slurl.com/secondlife/Ahern/50/50/50/?title=YOUR%20TITLE%20HERE!");
  209. testRegex("Ahern SLURL with msg", url,
  210.   "XXX http://slurl.com/secondlife/Ahern/50/50/50/?msg=Your%20text%20here. XXX",
  211.   "http://slurl.com/secondlife/Ahern/50/50/50/?msg=Your%20text%20here.");
  212. // DEV-21577: In-world SLURLs containing "(" or ")" are not treated as a hyperlink in chat
  213. testRegex("SLURL with brackets", url,
  214.   "XXX http://slurl.com/secondlife/Burning%20Life%20(Hyper)/27/210/30 XXX",
  215.   "http://slurl.com/secondlife/Burning%20Life%20(Hyper)/27/210/30");
  216. // DEV-35459: SLURLs and teleport Links not parsed properly
  217. testRegex("SLURL with quote", url,
  218.   "XXX http://slurl.com/secondlife/A'ksha%20Oasis/41/166/701 XXX",
  219.   "http://slurl.com/secondlife/A%27ksha%20Oasis/41/166/701");
  220. }
  221. template<> template<>
  222. void object::test<4>()
  223. {
  224. //
  225. // test LLUrlEntryAgent - secondlife://app/agent Urls
  226. //
  227. LLUrlEntryAgent url;
  228. testRegex("Invalid Agent Url", url,
  229.   "secondlife:///app/agent/0e346d8b-4433-4d66-XXXX-fd37083abc4c/about",
  230.   "");
  231. testRegex("Agent Url ", url,
  232.   "secondlife:///app/agent/0e346d8b-4433-4d66-a6b0-fd37083abc4c/about",
  233.   "secondlife:///app/agent/0e346d8b-4433-4d66-a6b0-fd37083abc4c/about");
  234. testRegex("Agent Url in text", url,
  235.   "XXX secondlife:///app/agent/0e346d8b-4433-4d66-a6b0-fd37083abc4c/about XXX",
  236.   "secondlife:///app/agent/0e346d8b-4433-4d66-a6b0-fd37083abc4c/about");
  237. testRegex("Agent Url multicase", url,
  238.   "XXX secondlife:///App/AGENT/0E346D8B-4433-4d66-a6b0-fd37083abc4c/About XXX",
  239.   "secondlife:///App/AGENT/0E346D8B-4433-4d66-a6b0-fd37083abc4c/About");
  240. testRegex("Agent Url alternate command", url,
  241.   "XXX secondlife:///App/AGENT/0E346D8B-4433-4d66-a6b0-fd37083abc4c/foobar",
  242.   "secondlife:///App/AGENT/0E346D8B-4433-4d66-a6b0-fd37083abc4c/foobar");
  243. }
  244. template<> template<>
  245. void object::test<5>()
  246. {
  247. //
  248. // test LLUrlEntryGroup - secondlife://app/group Urls
  249. //
  250. LLUrlEntryGroup url;
  251. testRegex("Invalid Group Url", url,
  252.   "secondlife:///app/group/00005ff3-4044-c79f-XXXX-fb28ae0df991/about",
  253.   "");
  254. testRegex("Group Url ", url,
  255.   "secondlife:///app/group/00005ff3-4044-c79f-9de8-fb28ae0df991/about",
  256.   "secondlife:///app/group/00005ff3-4044-c79f-9de8-fb28ae0df991/about");
  257. testRegex("Group Url ", url,
  258.   "secondlife:///app/group/00005ff3-4044-c79f-9de8-fb28ae0df991/inspect",
  259.   "secondlife:///app/group/00005ff3-4044-c79f-9de8-fb28ae0df991/inspect");
  260. testRegex("Group Url in text", url,
  261.   "XXX secondlife:///app/group/00005ff3-4044-c79f-9de8-fb28ae0df991/about XXX",
  262.   "secondlife:///app/group/00005ff3-4044-c79f-9de8-fb28ae0df991/about");
  263. testRegex("Group Url multicase", url,
  264.   "XXX secondlife:///APP/Group/00005FF3-4044-c79f-9de8-fb28ae0df991/About XXX",
  265.   "secondlife:///APP/Group/00005FF3-4044-c79f-9de8-fb28ae0df991/About");
  266. }
  267. template<> template<>
  268. void object::test<6>()
  269. {
  270. //
  271. // test LLUrlEntryPlace - secondlife://<location> URLs
  272. //
  273. LLUrlEntryPlace url;
  274. testRegex("no valid slurl [1]", url,
  275.   "secondlife://Ahern/FOO/50/",
  276.   "");
  277. testRegex("Ahern (50,50,50) [1]", url,
  278.   "secondlife://Ahern/50/50/50/",
  279.   "secondlife://Ahern/50/50/50/");
  280. testRegex("Ahern (50,50,50) [2]", url,
  281.   "XXX secondlife://Ahern/50/50/50/ XXX",
  282.   "secondlife://Ahern/50/50/50/");
  283. testRegex("Ahern (50,50,50) [3]", url,
  284.   "XXX secondlife://Ahern/50/50/50 XXX",
  285.   "secondlife://Ahern/50/50/50");
  286. testRegex("Ahern (50,50,50) multicase", url,
  287.   "XXX SecondLife://Ahern/50/50/50/ XXX",
  288.   "SecondLife://Ahern/50/50/50/");
  289. testRegex("Ahern (50,50) [1]", url,
  290.   "XXX secondlife://Ahern/50/50/ XXX",
  291.   "secondlife://Ahern/50/50/");
  292. testRegex("Ahern (50,50) [2]", url,
  293.   "XXX secondlife://Ahern/50/50 XXX",
  294.   "secondlife://Ahern/50/50");
  295. // DEV-21577: In-world SLURLs containing "(" or ")" are not treated as a hyperlink in chat
  296. testRegex("SLURL with brackets", url,
  297.   "XXX secondlife://Burning%20Life%20(Hyper)/27/210/30 XXX",
  298.   "secondlife://Burning%20Life%20(Hyper)/27/210/30");
  299. // DEV-35459: SLURLs and teleport Links not parsed properly
  300. testRegex("SLURL with quote", url,
  301.   "XXX secondlife://A'ksha%20Oasis/41/166/701 XXX",
  302.   "secondlife://A%27ksha%20Oasis/41/166/701");
  303. }
  304. template<> template<>
  305. void object::test<7>()
  306. {
  307. //
  308. // test LLUrlEntryParcel - secondlife://app/parcel Urls
  309. //
  310. LLUrlEntryParcel url;
  311. testRegex("Invalid Classified Url", url,
  312.   "secondlife:///app/parcel/0000060e-4b39-e00b-XXXX-d98b1934e3a8/about",
  313.   "");
  314. testRegex("Classified Url ", url,
  315.   "secondlife:///app/parcel/0000060e-4b39-e00b-d0c3-d98b1934e3a8/about",
  316.   "secondlife:///app/parcel/0000060e-4b39-e00b-d0c3-d98b1934e3a8/about");
  317. testRegex("Classified Url in text", url,
  318.   "XXX secondlife:///app/parcel/0000060e-4b39-e00b-d0c3-d98b1934e3a8/about XXX",
  319.   "secondlife:///app/parcel/0000060e-4b39-e00b-d0c3-d98b1934e3a8/about");
  320. testRegex("Classified Url multicase", url,
  321.   "XXX secondlife:///APP/Parcel/0000060e-4b39-e00b-d0c3-d98b1934e3a8/About XXX",
  322.   "secondlife:///APP/Parcel/0000060e-4b39-e00b-d0c3-d98b1934e3a8/About");
  323. }
  324. template<> template<>
  325. void object::test<8>()
  326. {
  327. //
  328. // test LLUrlEntryTeleport - secondlife://app/teleport URLs
  329. //
  330. LLUrlEntryTeleport url;
  331. testRegex("no valid teleport [1]", url,
  332.   "http://slurl.com/secondlife/Ahern/50/50/50/",
  333.   "");
  334. testRegex("no valid teleport [2]", url,
  335.   "secondlife:///app/teleport/",
  336.   "");
  337. testRegex("no valid teleport [3]", url,
  338.   "second-life:///app/teleport/Ahern/50/50/50/",
  339.   "");
  340. testRegex("no valid teleport [3]", url,
  341.   "hhtp://slurl.com/secondlife/Ahern/50/FOO/50/",
  342.   "");
  343. testRegex("Ahern (50,50,50) [1]", url,
  344.   "secondlife:///app/teleport/Ahern/50/50/50/",
  345.   "secondlife:///app/teleport/Ahern/50/50/50/");
  346. testRegex("Ahern (50,50,50) [2]", url,
  347.   "XXX secondlife:///app/teleport/Ahern/50/50/50/ XXX",
  348.   "secondlife:///app/teleport/Ahern/50/50/50/");
  349. testRegex("Ahern (50,50,50) [3]", url,
  350.   "XXX secondlife:///app/teleport/Ahern/50/50/50 XXX",
  351.   "secondlife:///app/teleport/Ahern/50/50/50");
  352. testRegex("Ahern (50,50,50) multicase", url,
  353.   "XXX secondlife:///app/teleport/Ahern/50/50/50/ XXX",
  354.   "secondlife:///app/teleport/Ahern/50/50/50/");
  355. testRegex("Ahern (50,50) [1]", url,
  356.   "XXX secondlife:///app/teleport/Ahern/50/50/ XXX",
  357.   "secondlife:///app/teleport/Ahern/50/50/");
  358. testRegex("Ahern (50,50) [2]", url,
  359.   "XXX secondlife:///app/teleport/Ahern/50/50 XXX",
  360.   "secondlife:///app/teleport/Ahern/50/50");
  361. testRegex("Ahern (50)", url,
  362.   "XXX secondlife:///app/teleport/Ahern/50 XXX",
  363.   "secondlife:///app/teleport/Ahern/50");
  364. testRegex("Ahern", url,
  365.   "XXX secondlife:///app/teleport/Ahern/ XXX",
  366.   "secondlife:///app/teleport/Ahern/");
  367. testRegex("Ahern teleport with title", url,
  368.   "XXX secondlife:///app/teleport/Ahern/50/50/50/?title=YOUR%20TITLE%20HERE! XXX",
  369.   "secondlife:///app/teleport/Ahern/50/50/50/?title=YOUR%20TITLE%20HERE!");
  370. testRegex("Ahern teleport with msg", url,
  371.   "XXX secondlife:///app/teleport/Ahern/50/50/50/?msg=Your%20text%20here. XXX",
  372.   "secondlife:///app/teleport/Ahern/50/50/50/?msg=Your%20text%20here.");
  373. // DEV-21577: In-world SLURLs containing "(" or ")" are not treated as a hyperlink in chat
  374. testRegex("Teleport with brackets", url,
  375.   "XXX secondlife:///app/teleport/Burning%20Life%20(Hyper)/27/210/30 XXX",
  376.   "secondlife:///app/teleport/Burning%20Life%20(Hyper)/27/210/30");
  377. // DEV-35459: SLURLs and teleport Links not parsed properly
  378. testRegex("Teleport url with quote", url,
  379.   "XXX secondlife:///app/teleport/A'ksha%20Oasis/41/166/701 XXX",
  380.   "secondlife:///app/teleport/A%27ksha%20Oasis/41/166/701");
  381. }
  382. template<> template<>
  383. void object::test<9>()
  384. {
  385. //
  386. // test LLUrlEntrySL - general secondlife:// URLs
  387. //
  388. LLUrlEntrySL url;
  389. testRegex("no valid slapp [1]", url,
  390.   "http:///app/",
  391.   "");
  392. testRegex("valid slapp [1]", url,
  393.   "secondlife:///app/",
  394.   "secondlife:///app/");
  395. testRegex("valid slapp [2]", url,
  396.   "secondlife:///app/teleport/Ahern/50/50/50/",
  397.   "secondlife:///app/teleport/Ahern/50/50/50/");
  398. testRegex("valid slapp [3]", url,
  399.   "secondlife:///app/foo",
  400.   "secondlife:///app/foo");
  401. testRegex("valid slapp [4]", url,
  402.   "secondlife:///APP/foo?title=Hi%20There",
  403.   "secondlife:///APP/foo?title=Hi%20There");
  404. testRegex("valid slapp [5]", url,
  405.   "secondlife://host/app/",
  406.   "secondlife://host/app/");
  407. testRegex("valid slapp [6]", url,
  408.   "secondlife://host:8080/foo/bar",
  409.   "secondlife://host:8080/foo/bar");
  410. }
  411. template<> template<>
  412. void object::test<10>()
  413. {
  414. //
  415. // test LLUrlEntrySLLabel - general secondlife:// URLs with labels
  416. //
  417. LLUrlEntrySLLabel url;
  418. testRegex("invalid wiki url [1]", url,
  419.   "[secondlife:///app/]",
  420.   "");
  421. testRegex("invalid wiki url [2]", url,
  422.   "[secondlife:///app/",
  423.   "");
  424. testRegex("invalid wiki url [3]", url,
  425.   "[secondlife:///app/ Label",
  426.   "");
  427. testRegex("agent slurl with label (spaces)", url,
  428.   "[secondlife:///app/agent/0e346d8b-4433-4d66-a6b0-fd37083abc4c/about  Text]",
  429.   "secondlife:///app/agent/0e346d8b-4433-4d66-a6b0-fd37083abc4c/about");
  430. testRegex("agent slurl with label (tabs)", url,
  431.   "[secondlife:///app/agent/0e346d8b-4433-4d66-a6b0-fd37083abc4c/aboutt Text]",
  432.   "secondlife:///app/agent/0e346d8b-4433-4d66-a6b0-fd37083abc4c/about");
  433. testRegex("agent slurl with label", url,
  434.   "[secondlife:///app/agent/0e346d8b-4433-4d66-a6b0-fd37083abc4c/about FirstName LastName]",
  435.   "secondlife:///app/agent/0e346d8b-4433-4d66-a6b0-fd37083abc4c/about");
  436. testRegex("teleport slurl with label", url,
  437.   "XXX [secondlife:///app/teleport/Ahern/50/50/50/ Teleport to Ahern] YYY",
  438.   "secondlife:///app/teleport/Ahern/50/50/50/");
  439. }
  440. template<> template<>
  441. void object::test<11>()
  442. {
  443. //
  444. // test LLUrlEntryHTTPNoProtocol - general URLs without a protocol
  445. //
  446. LLUrlEntryHTTPNoProtocol url;
  447. testRegex("naked .com URL", url,
  448.   "see google.com",
  449.   "http://google.com");
  450. testRegex("naked .org URL", url,
  451.   "see en.wikipedia.org for details",
  452.   "http://en.wikipedia.org");
  453. testRegex("naked .net URL", url,
  454.   "example.net",
  455.   "http://example.net");
  456. testRegex("naked .edu URL (2 instances)", url,
  457.   "MIT web site is at web.mit.edu and also www.mit.edu",
  458.   "http://web.mit.edu");
  459. testRegex("don't match e-mail addresses", url,
  460.   "test@lindenlab.com",
  461.   "");
  462. testRegex(".com URL with path", url,
  463.   "see secondlife.com/status for grid status",
  464.   "http://secondlife.com/status");
  465. testRegex(".com URL with port", url,
  466.   "secondlife.com:80",
  467.   "http://secondlife.com:80");
  468. testRegex(".com URL with port and path", url,
  469.   "see secondlife.com:80/status",
  470.   "http://secondlife.com:80/status");
  471. testRegex("www.*.com URL with port and path", url,
  472.   "see www.secondlife.com:80/status",
  473.   "http://www.secondlife.com:80/status");
  474. testRegex("invalid .com URL [1]", url,
  475.   "..com",
  476.   "");
  477. testRegex("invalid .com URL [2]", url,
  478.   "you.come",
  479.   "");
  480. testRegex("invalid .com URL [3]", url,
  481.   "recommended",
  482.   "");
  483. testRegex("invalid .edu URL", url,
  484.   "hi there scheduled maitenance has begun",
  485.   "");
  486. testRegex("invalid .net URL", url,
  487.   "foo.netty",
  488.   "");
  489. testRegex("XML tags around URL [1]", url,
  490.   "<foo>secondlife.com</foo>",
  491.   "http://secondlife.com");
  492. testRegex("XML tags around URL [2]", url,
  493.   "<foo>secondlife.com/status?bar=1</foo>",
  494.   "http://secondlife.com/status?bar=1");
  495. }
  496. template<> template<>
  497. void object::test<12>()
  498. {
  499. //
  500. // test LLUrlEntryNoLink - turn off hyperlinking
  501. //
  502. LLUrlEntryNoLink url;
  503. testRegex("<nolink> [1]", url,
  504.   "<nolink>google.com</nolink>",
  505.   "google.com");
  506. testRegex("<nolink> [2]", url,
  507.   "<nolink>google.com",
  508.   "");
  509. testRegex("<nolink> [3]", url,
  510.   "google.com</nolink>",
  511.   "");
  512. testRegex("<nolink> [4]", url,
  513.   "<nolink>Hello World</nolink>",
  514.   "Hello World");
  515. testRegex("<nolink> [5]", url,
  516.   "<nolink>My Object</nolink>",
  517.   "My Object");
  518. }
  519. }