From 96966ca83f96ed1babcd2bd23aa68feb63fbb7a7 Mon Sep 17 00:00:00 2001 From: Einar Egilsson Date: Tue, 15 Sep 2009 21:41:06 +0000 Subject: Total restructuring of files. Unescape matches fully working Export of redirects working. git-svn-id: http://einaregilsson.googlecode.com/svn/mozilla/redirector/trunk@249 119bf307-c92d-0410-89bd-8f53e6181181 --- chrome/content/unittest/run.html | 87 ++++++++++++++++++++++++++++++++++++ chrome/content/unittest/testcases.js | 39 ++++++++++++++++ 2 files changed, 126 insertions(+) create mode 100644 chrome/content/unittest/run.html create mode 100644 chrome/content/unittest/testcases.js (limited to 'chrome/content/unittest') diff --git a/chrome/content/unittest/run.html b/chrome/content/unittest/run.html new file mode 100644 index 0000000..2c4f968 --- /dev/null +++ b/chrome/content/unittest/run.html @@ -0,0 +1,87 @@ + + + + Redirector Unit Tests + + + + +

Redirector Unit Tests

+ + + + \ No newline at end of file diff --git a/chrome/content/unittest/testcases.js b/chrome/content/unittest/testcases.js new file mode 100644 index 0000000..ea6e26b --- /dev/null +++ b/chrome/content/unittest/testcases.js @@ -0,0 +1,39 @@ +//// $Id$ +var tests = { + "Wildcard matches" : { + run : function(data) { + var pattern = data[0], + url = data[1], + expected = data[2]; + var parts = expected.split(','); + var redirectUrl = ''; + if (!(parts.length == 1 && parts[0] == '')) { + for (var i in parts) { + redirectUrl += '$' + (parseFloat(i)+1) + ','; + } + redirectUrl = redirectUrl.substr(0, redirectUrl.length-1); + } + var result = redirector.wildcardMatch(pattern, url, redirectUrl, false); + return result == expected; + }, + + describe : function(data) { return data[0] + ' == ' + data[1] + ', matches=' + data[2]; }, + tests : [ + ['http://foo*', 'http://foobar.is', 'bar.is'], + ['http://foo*', 'http://foo', ''], + ['*://foo.is', 'http://foo.is', 'http'], + ['*http://foo.is', 'http://foo.is', ''], + ['http*foo*', 'http://foobar.is', '://,bar.is'], + ['http*foo*', 'http://foo', '://,'], + ['*://f*.is', 'http://foo.is', 'http,oo'], + ['*http://f*.is', 'http://foo.is', ',oo'], + ['*foo*', 'http://foo', 'http://,'], + ['*foo*', 'foobar.is', ',bar.is'], + ['*foo*', 'http://foobar.is', 'http://,bar.is'], + ['http://foo.is', 'http://foo.is', ''], + ['*', 'http://foo.is', 'http://foo.is'], + ['*://*oo*bar*', 'http://foo.is/bar/baz', 'http,f,.is/,/baz'], + ['*://**oo*bar*', 'http://foo.is/bar/baz', 'http,,f,.is/,/baz'], + ] + } +}; -- cgit v1.2.3-70-g09d2