added tests
This commit is contained in:
parent
5d2249ad3d
commit
37a19f1ebb
|
@ -4,3 +4,5 @@
|
|||
*.bz2
|
||||
xmlcopyeditor
|
||||
xmlcopyeditor.exe
|
||||
*.o
|
||||
tests-main
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
build:
|
||||
g++ -o tests-main \
|
||||
*.cpp \
|
||||
../src/replace.cpp \
|
||||
../src/readfile.cpp
|
||||
run:
|
||||
./tests-main
|
||||
all: build run
|
||||
clean:
|
||||
rm *.o tests-main
|
File diff suppressed because it is too large
Load Diff
Binary file not shown.
|
@ -0,0 +1,2 @@
|
|||
#define CATCH_CONFIG_MAIN
|
||||
#include "catch.hpp"
|
Binary file not shown.
|
@ -0,0 +1,15 @@
|
|||
#include "catch.hpp"
|
||||
#include <string>
|
||||
#include "../src/readfile.h"
|
||||
|
||||
TEST_CASE( "readfile works as specified", "[readfile]" ) {
|
||||
std::string valid_path = "catch.hpp", invalid_path = "invalid.hpp";
|
||||
std::string buf;
|
||||
|
||||
REQUIRE( ReadFile::run(valid_path, buf) == true );
|
||||
REQUIRE( buf.at(0) == '/' );
|
||||
|
||||
buf.clear();
|
||||
REQUIRE( ReadFile::run(invalid_path, buf) == false );
|
||||
REQUIRE( buf.length() == 0 );
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
#include "catch.hpp"
|
||||
#include <string>
|
||||
#include "../src/replace.h"
|
||||
|
||||
TEST_CASE( "replace works as specified", "[replace]" ) {
|
||||
std::string orig = "when shall we three meet again";
|
||||
std::string find = "THREE";
|
||||
std::string replace = "four";
|
||||
|
||||
// case insensitive
|
||||
std::string buf = orig;
|
||||
REQUIRE( Replace::run(buf, find, replace, false) == 1 );
|
||||
REQUIRE( buf == "when shall we four meet again" );
|
||||
|
||||
// case sensitive
|
||||
buf = orig;
|
||||
REQUIRE( Replace::run(buf, find, replace, true) == 0 );
|
||||
REQUIRE( buf == "when shall we three meet again" );
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
#include "catch.hpp"
|
||||
#include <string>
|
||||
#include <memory>
|
||||
#include "../src/stringset.h"
|
||||
|
||||
TEST_CASE( "stringset works as specified", "[stringset]" ) {
|
||||
std::string buf = "test";
|
||||
std::auto_ptr<StringSet<char> > dict ( new StringSet<char>() );
|
||||
|
||||
REQUIRE( dict->find(buf) == 0 );
|
||||
REQUIRE( dict->empty() == true );
|
||||
REQUIRE( dict->count() == 0 );
|
||||
|
||||
dict->insert(buf);
|
||||
|
||||
REQUIRE( dict->find(buf) != 0 );
|
||||
REQUIRE( dict->empty() == false);
|
||||
REQUIRE( dict->count() == 1);
|
||||
}
|
Binary file not shown.
Loading…
Reference in New Issue