Unit tests
- Added tests for Transport class
This commit is contained in:
@@ -33,23 +33,23 @@
|
|||||||
class Transport {
|
class Transport {
|
||||||
public:
|
public:
|
||||||
Transport (const std::string&, const std::string&, const std::string&, const std::string&);
|
Transport (const std::string&, const std::string&, const std::string&, const std::string&);
|
||||||
Transport (const std::string&);
|
Transport (const std::string&);
|
||||||
~Transport ();
|
~Transport ();
|
||||||
|
|
||||||
static Transport* getTransport(const std::string&);
|
static Transport* getTransport(const std::string&);
|
||||||
|
|
||||||
void parseUri (std::string);
|
void parseUri (std::string);
|
||||||
virtual void send (const std::string&) = 0;
|
virtual void send (const std::string&) = 0;
|
||||||
virtual void recv (std::string) = 0;
|
virtual void recv (std::string) = 0;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
std::string executable;
|
std::string executable;
|
||||||
std::vector<std::string> arguments;
|
std::vector<std::string> arguments;
|
||||||
|
|
||||||
std::string host;
|
std::string host;
|
||||||
std::string path;
|
std::string path;
|
||||||
std::string port;
|
std::string port;
|
||||||
std::string user;
|
std::string user;
|
||||||
|
|
||||||
int execute();
|
int execute();
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -33,7 +33,7 @@
|
|||||||
class TransportSSH : public Transport {
|
class TransportSSH : public Transport {
|
||||||
public:
|
public:
|
||||||
TransportSSH (const std::string&);
|
TransportSSH (const std::string&);
|
||||||
TransportSSH (const std::string&, const std::string&, const std::string&, const std::string&);
|
TransportSSH (const std::string&, const std::string&, const std::string&, const std::string&);
|
||||||
|
|
||||||
virtual void send (const std::string&);
|
virtual void send (const std::string&);
|
||||||
virtual void recv (std::string);
|
virtual void recv (std::string);
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
PROJECT = t.t tdb.t date.t duration.t t.benchmark.t text.t autocomplete.t \
|
PROJECT = t.t tdb.t date.t duration.t t.benchmark.t text.t autocomplete.t \
|
||||||
config.t seq.t att.t stringtable.t record.t nibbler.t subst.t filt.t \
|
config.t seq.t att.t stringtable.t record.t nibbler.t subst.t filt.t \
|
||||||
cmd.t util.t color.t list.t path.t file.t directory.t grid.t rx.t \
|
cmd.t util.t color.t list.t path.t file.t directory.t grid.t rx.t \
|
||||||
taskmod.t sensor.t rectangle.t tree.t tree2.t lisp.t
|
taskmod.t sensor.t rectangle.t tree.t tree2.t lisp.t transport.t
|
||||||
CFLAGS = -I. -I.. -I../.. -Wall -pedantic -ggdb3 -fno-rtti
|
CFLAGS = -I. -I.. -I../.. -Wall -pedantic -ggdb3 -fno-rtti
|
||||||
LFLAGS = -L/usr/local/lib -lpthread -lncurses -llua
|
LFLAGS = -L/usr/local/lib -lpthread -lncurses -llua
|
||||||
OBJECTS = ../t-TDB.o ../t-Task.o ../t-text.o ../t-Date.o ../t-Table.o \
|
OBJECTS = ../t-TDB.o ../t-Task.o ../t-text.o ../t-Date.o ../t-Table.o \
|
||||||
@@ -105,6 +105,9 @@ rx.t: rx.t.o $(OBJECTS) test.o
|
|||||||
taskmod.t: taskmod.t.o $(OBJECTS) test.o
|
taskmod.t: taskmod.t.o $(OBJECTS) test.o
|
||||||
g++ taskmod.t.o $(OBJECTS) test.o $(LFLAGS) -o taskmod.t
|
g++ taskmod.t.o $(OBJECTS) test.o $(LFLAGS) -o taskmod.t
|
||||||
|
|
||||||
|
transport.t: transport.t.o $(OBJECTS) test.o
|
||||||
|
g++ transport.t.o $(OBJECTS) test.o $(LFLAGS) -o transport.t
|
||||||
|
|
||||||
lisp.t: lisp.t.o $(OBJECTS) test.o
|
lisp.t: lisp.t.o $(OBJECTS) test.o
|
||||||
g++ lisp.t.o $(OBJECTS) test.o $(LFLAGS) -o lisp.t
|
g++ lisp.t.o $(OBJECTS) test.o $(LFLAGS) -o lisp.t
|
||||||
|
|
||||||
|
|||||||
BIN
src/tests/transport.t
Executable file
BIN
src/tests/transport.t
Executable file
Binary file not shown.
82
src/tests/transport.t.cpp
Normal file
82
src/tests/transport.t.cpp
Normal file
@@ -0,0 +1,82 @@
|
|||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// taskwarrior - a command line task list manager.
|
||||||
|
//
|
||||||
|
// Copyright 2006 - 2010, Paul Beckingham.
|
||||||
|
// 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
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
#include <iostream>
|
||||||
|
#include <sstream>
|
||||||
|
#include <Context.h>
|
||||||
|
//#include <Att.h>
|
||||||
|
#include <Transport.h>
|
||||||
|
#include <test.h>
|
||||||
|
|
||||||
|
Context context;
|
||||||
|
|
||||||
|
class TransportTest : public Transport
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
TransportTest (const std::string& uri) : Transport (uri) {};
|
||||||
|
|
||||||
|
std::string getHost() { return host; };
|
||||||
|
std::string getPath() { return path; };
|
||||||
|
std::string getUser() { return user; };
|
||||||
|
std::string getPort() { return port; };
|
||||||
|
|
||||||
|
virtual void recv(std::string) {};
|
||||||
|
virtual void send(const std::string&) {};
|
||||||
|
};
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
int main (int argc, char** argv)
|
||||||
|
{
|
||||||
|
UnitTest t (16);
|
||||||
|
|
||||||
|
TransportTest tport1 ("asfd://user@host/folder/");
|
||||||
|
t.is (tport1.getUser (), "user", "Transport::parseUri() : asfd://user@host/folder/");
|
||||||
|
t.is (tport1.getHost (), "host", "Transport::parseUri() : asfd://user@host/folder/");
|
||||||
|
t.is (tport1.getPort (), "", "Transport::parseUri() : asfd://user@host/folder/");
|
||||||
|
t.is (tport1.getPath (), "folder/", "Transport::parseUri() : asfd://user@host/folder/");
|
||||||
|
|
||||||
|
TransportTest tport2 ("user@host:22/folder/file.test");
|
||||||
|
t.is (tport2.getUser (), "user", "Transport::parseUri() : user@host:22/folder/file.test");
|
||||||
|
t.is (tport2.getHost (), "host", "Transport::parseUri() : user@host:22/folder/file.test");
|
||||||
|
t.is (tport2.getPort (), "22", "Transport::parseUri() : user@host:22/folder/file.test");
|
||||||
|
t.is (tport2.getPath (), "folder/file.test", "Transport::parseUri() : user@host:22/folder/file.test");
|
||||||
|
|
||||||
|
TransportTest tport3 ("hostname.abc.de/file.test");
|
||||||
|
t.is (tport3.getUser (), "", "Transport::parseUri() : hostname.abc.de/file.test");
|
||||||
|
t.is (tport3.getHost (), "hostname.abc.de", "Transport::parseUri() : hostname.abc.de/file.test");
|
||||||
|
t.is (tport3.getPort (), "", "Transport::parseUri() : hostname.abc.de/file.test");
|
||||||
|
t.is (tport3.getPath (), "file.test", "Transport::parseUri() : hostname.abc.de/file.test");
|
||||||
|
|
||||||
|
TransportTest tport4 ("hostname/");
|
||||||
|
t.is (tport4.getUser (), "", "Transport::parseUri() : hostname/");
|
||||||
|
t.is (tport4.getHost (), "hostname", "Transport::parseUri() : hostname/");
|
||||||
|
t.is (tport4.getPort (), "", "Transport::parseUri() : hostname/");
|
||||||
|
t.is (tport4.getPath (), "", "Transport::parseUri() : hostname/");
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
Reference in New Issue
Block a user