From feb19cafddcc40bfab74e4f50c4b72ec73313cca Mon Sep 17 00:00:00 2001 From: Johannes Schlatow Date: Mon, 31 Jan 2011 22:09:42 +0100 Subject: [PATCH] Unit tests * Bug #668 --- test/bug.668.t | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++ test/uri.t.cpp | 21 +++++++++++++++- 2 files changed, 85 insertions(+), 1 deletion(-) create mode 100755 test/bug.668.t diff --git a/test/bug.668.t b/test/bug.668.t new file mode 100755 index 000000000..be7c7578a --- /dev/null +++ b/test/bug.668.t @@ -0,0 +1,65 @@ +#! /usr/bin/perl +################################################################################ +## taskwarrior - a command line task list manager. +## +## Copyright 2006 - 2011, Paul Beckingham, Federico Hernandez. +## All rights reserved. +## +## This program is free software; you can redistribute it and/or modify it under +## the terms of the GNU General Public License as published by the Free Software +## Foundation; either version 2 of the License, or (at your option) any later +## version. +## +## This program is distributed in the hope that it will be useful, but WITHOUT +## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +## FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +## details. +## +## You should have received a copy of the GNU General Public License along with +## this program; if not, write to the +## +## Free Software Foundation, Inc., +## 51 Franklin Street, Fifth Floor, +## Boston, MA +## 02110-1301 +## USA +## +################################################################################ + +use strict; +use warnings; +use Test::More tests => 9; + +# Create the rc file. +if (open my $fh, '>', 'bug.rc') +{ + print $fh "data.location=.\n"; + close $fh; + ok (-r 'bug.rc', 'Created bug.rc'); +} + +# Bug 668: URL should allow users with dot character + +my $output = qx{../src/task rc:bug.rc merge user.name\@taskwarrior.org:undo.data}; +unlike ($output, qr/not a valid modifier/, 'scp syntax with dots'); +unlike ($output, qr/not in the expected format/, 'scp syntax with dots'); + +$output = qx{../src/task rc:bug.rc merge ssh://user.name\@taskwarrior.org/udno.data}; +unlike ($output, qr/not a valid modifier/, 'standard syntax with dots'); +unlike ($output, qr/not in the expected format/, 'standard syntax with dots'); + +# Cleanup. +unlink 'pending.data'; +ok (!-r 'pending.data', 'Removed pending.data'); + +unlink 'completed.data'; +ok (!-r 'completed.data', 'Removed completed.data'); + +unlink 'undo.data'; +ok (!-r 'undo.data', 'Removed undo.data'); + +unlink 'bug.rc'; +ok (!-r 'bug.rc', 'Removed bug.rc'); + +exit 0; + diff --git a/test/uri.t.cpp b/test/uri.t.cpp index 85bdf9cda..1fb4a0db9 100644 --- a/test/uri.t.cpp +++ b/test/uri.t.cpp @@ -35,7 +35,7 @@ Context context; //////////////////////////////////////////////////////////////////////////////// int main (int argc, char** argv) { - UnitTest t (44); + UnitTest t (54); Uri uri1 ("asfd://user@host/folder/"); uri1.parse (); @@ -111,7 +111,26 @@ int main (int argc, char** argv) t.is (uri9.port, "", "Uri::parse() : 'user@name'@host:path/to/x"); t.is (uri9.path, "path/to/x", "Uri::parse() : 'user@name'@host:path/to/x"); + // bug #668 + Uri uri10 ("user.name@host.com:undo.data"); + uri10.parse (); + t.is (uri10.user, "user.name", "Uri::parse() : user.name@host.com:undo.data"); + t.is (uri10.host, "host.com", "Uri::parse() : user.name@host.com:undo.data"); + t.is (uri10.port, "", "Uri::parse() : user.name@host.com:undo.data"); + t.is (uri10.path, "undo.data", "Uri::parse() : user.name@host.com:undo.data"); + t.is (uri10.protocol, "ssh", "Uri::parse() : user.name@host.com:undo.data"); + + Uri uri11 ("ssh://user.name@host.com/undo.data"); + uri11.parse (); + t.is (uri11.user, "user.name", "Uri::parse() : ssh://user.name@host.com/undo.data"); + t.is (uri11.host, "host.com", "Uri::parse() : ssh://user.name@host.com/undo.data"); + t.is (uri11.port, "", "Uri::parse() : ssh://user.name@host.com/undo.data"); + t.is (uri11.path, "undo.data", "Uri::parse() : ssh://user.name@host.com/undo.data"); + t.is (uri11.protocol, "ssh", "Uri::parse() : ssh://user.name@host.com/undo.data"); + + return 0; } //////////////////////////////////////////////////////////////////////////////// +// vim: et ts=2 sw=2