Skip to content

Commit

Permalink
move compression test to dbtests
Browse files Browse the repository at this point in the history
  • Loading branch information
erh committed Aug 5, 2011
1 parent 8f31837 commit a3f80b9
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 14 deletions.
18 changes: 18 additions & 0 deletions dbtests/basictests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include "../util/queue.h"
#include "../util/paths.h"
#include "../util/stringutils.h"
#include "../util/compress.h"
#include "../db/db.h"

namespace BasicTests {
Expand Down Expand Up @@ -630,6 +631,21 @@ namespace BasicTests {
}
};

struct CompressionTest1 {
void run() {
const char * c = "this is a test";
std::string s;
size_t len = compress(c, strlen(c)+1, &s);
assert( len > 0 );

std::string out;
bool ok = uncompress(s.c_str(), s.size(), &out);
assert(ok);
assert( strcmp(out.c_str(), c) == 0 );
}
} ctest1;


class All : public Suite {
public:
All() : Suite( "basic" ) {
Expand Down Expand Up @@ -667,6 +683,8 @@ namespace BasicTests {
add< HostAndPortTests >();
add< RelativePathTest >();
add< CmdLineParseConfigTest >();

add< CompressionTest1 >();
}
} myall;

Expand Down
14 changes: 0 additions & 14 deletions util/compress.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,4 @@ namespace mongo {
return snappy::Uncompress(compressed, compressed_length, uncompressed);
}

struct CTest {
CTest() {
const char * c = "this is a test";
std::string s;
size_t len = compress(c, strlen(c)+1, &s);
assert( len > 0 );

std::string out;
bool ok = uncompress(s.c_str(), s.size(), &out);
assert(ok);
assert( strcmp(out.c_str(), c) == 0 );
}
} ctest;

}

0 comments on commit a3f80b9

Please sign in to comment.