Skip to content

Commit

Permalink
continued
Browse files Browse the repository at this point in the history
  • Loading branch information
wonder-sk committed Apr 26, 2021
1 parent 7201536 commit 6d9bfc5
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 19 deletions.
1 change: 1 addition & 0 deletions geodiff/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ SET(TESTS
test_changeset_reader.cpp
test_changeset_utils.cpp
test_driver_sqlite.cpp
test_utils.cpp
)

FOREACH(TESTSRC ${TESTS})
Expand Down
20 changes: 1 addition & 19 deletions geodiff/tests/test_changeset_reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ TEST( ChangesetReaderTest, test_read_update )

EXPECT_FALSE( reader.nextEntry( entry ) );
}
#include "geodiffutils.hpp"

TEST( ChangesetReaderTest, test_read_delete )
{
std::string changeset = pathjoin( testdir(), "2_deletes", "base-deleted_A.diff" );
Expand All @@ -98,24 +98,6 @@ TEST( ChangesetReaderTest, test_read_delete )

EXPECT_FALSE( reader.nextEntry( entry ) );
EXPECT_FALSE( reader.nextEntry( entry ) );

// test whether unicode characters are working
std::string json = pathjoin( testdir(), "2_updates", "čúčo.json" );
EXPECT_EQ( GEODIFF_listChanges( changeset.c_str(), json.c_str() ), GEODIFF_SUCCESS );
EXPECT_TRUE( fileExists( json ) );
EXPECT_FALSE( isFileEmpty( json ) );
EXPECT_TRUE( fileContains( json, "geodiff" ) );

printFileToStdout( "CUCO.JSON :-)", json );

FILE *ff = openFile( json, "r" );
EXPECT_TRUE( ff != nullptr );
std::cerr << "CUCO.JSON output:" << std::endl;
char data[100];
fread( data, 99, 1, ff );
data[99] = 0;
std::cerr << data << std::endl;
fclose( ff );
}


Expand Down
36 changes: 36 additions & 0 deletions geodiff/tests/test_utils.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
GEODIFF - MIT License
Copyright (C) 2021 Martin Dobias
*/

#include "gtest/gtest.h"
#include "geodiff_testutils.hpp"
#include "geodiff.h"

#include "geodiffutils.hpp"

TEST( UtilsTest, test_unicode )
{
std::string diffSource = pathjoin( testdir(), "utf_test_ščé", "changes.diff" );
std::string json = pathjoin( tmpdir(), "čúčo.json" );

// test whether unicode characters are working
EXPECT_EQ( GEODIFF_listChanges( diffSource.c_str(), json.c_str() ), GEODIFF_SUCCESS );

// make sure our test util functions can deal with unicode
EXPECT_TRUE( fileExists( json ) );
EXPECT_FALSE( isFileEmpty( json ) );
EXPECT_TRUE( fileContains( json, "geodiff" ) );

printFileToStdout( "CUCO.JSON", json );
}


int main( int argc, char **argv )
{
testing::InitGoogleTest( &argc, argv );
init_test();
int ret = RUN_ALL_TESTS();
finalize_test();
return ret;
}

0 comments on commit 6d9bfc5

Please sign in to comment.