-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
318 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
/* | ||
GEODIFF - MIT License | ||
Copyright (C) 2019 Peter Petrik | ||
*/ | ||
|
||
#include "gtest/gtest.h" | ||
#include "geodiff_testutils.hpp" | ||
#include "geodiff.h" | ||
|
||
TEST( ModifiedSchemeSqlite3Test, add_attribute ) | ||
{ | ||
std::cout << "geopackage add attribute to table" << std::endl; | ||
std::string testname = "added_attribute"; | ||
makedir( pathjoin( tmpdir(), testname ) ); | ||
|
||
std::string base = pathjoin( testdir(), "base.gpkg" ); | ||
std::string modified = pathjoin( testdir(), "modified_scheme", "added_attribute.gpkg" ); | ||
std::string changeset = pathjoin( tmpdir(), testname, "changeset.bin" ); | ||
|
||
ASSERT_EQ( GEODIFF_createChangeset( base.c_str(), modified.c_str(), changeset.c_str() ), GEODIFF_UNSUPPORTED_CHANGE ); | ||
} | ||
|
||
TEST( ModifiedSchemeSqlite3Test, add_table ) | ||
{ | ||
std::cout << "geopackage add table to table" << std::endl; | ||
std::string testname = "add_table"; | ||
makedir( pathjoin( tmpdir(), testname ) ); | ||
|
||
std::string base = pathjoin( testdir(), "base.gpkg" ); | ||
std::string modified = pathjoin( testdir(), "modified_scheme", "added_table.gpkg" ); | ||
std::string changeset = pathjoin( tmpdir(), testname, "changeset.bin" ); | ||
|
||
ASSERT_EQ( GEODIFF_createChangeset( base.c_str(), modified.c_str(), changeset.c_str() ), GEODIFF_UNSUPPORTED_CHANGE ); | ||
} | ||
|
||
TEST( ModifiedSchemeSqlite3Test, delete_attribute ) | ||
{ | ||
std::cout << "geopackage add attribute to table" << std::endl; | ||
std::string testname = "delete_attribute"; | ||
makedir( pathjoin( tmpdir(), testname ) ); | ||
|
||
std::string base = pathjoin( testdir(), "modified_scheme", "added_attribute.gpkg" ); | ||
std::string modified = pathjoin( testdir(), "base.gpkg" ); | ||
std::string changeset = pathjoin( tmpdir(), testname, "changeset.bin" ); | ||
|
||
ASSERT_EQ( GEODIFF_createChangeset( base.c_str(), modified.c_str(), changeset.c_str() ), GEODIFF_UNSUPPORTED_CHANGE ); | ||
} | ||
|
||
TEST( ModifiedSchemeSqlite3Test, delete_table ) | ||
{ | ||
std::cout << "geopackage delete table" << std::endl; | ||
std::string testname = "delete_table"; | ||
makedir( pathjoin( tmpdir(), testname ) ); | ||
|
||
std::string base = pathjoin( testdir(), "modified_scheme", "added_table.gpkg" ); | ||
std::string modified = pathjoin( testdir(), "base.gpkg" ); | ||
std::string changeset = pathjoin( tmpdir(), testname, "changeset.bin" ); | ||
|
||
ASSERT_EQ( GEODIFF_createChangeset( base.c_str(), modified.c_str(), changeset.c_str() ), GEODIFF_UNSUPPORTED_CHANGE ); | ||
} | ||
|
||
TEST( ModifiedSchemeSqlite3Test, rename_table ) | ||
{ | ||
std::cout << "geopackage table count is same, but tables have different name" << std::endl; | ||
std::string testname = "delete_table"; | ||
makedir( pathjoin( tmpdir(), testname ) ); | ||
|
||
std::string base = pathjoin( testdir(), "modified_scheme", "added_table.gpkg" ); | ||
std::string modified = pathjoin( testdir(), "modified_scheme", "added_table2.gpkg" ); | ||
std::string changeset = pathjoin( tmpdir(), testname, "changeset.bin" ); | ||
|
||
ASSERT_EQ( GEODIFF_createChangeset( base.c_str(), modified.c_str(), changeset.c_str() ), GEODIFF_UNSUPPORTED_CHANGE ); | ||
} | ||
|
||
TEST( ModifiedSchemeSqlite3Test, rename_attribute ) | ||
{ | ||
std::cout << "geopackage attribute count is same, but have different name" << std::endl; | ||
std::string testname = "rename_attribute"; | ||
makedir( pathjoin( tmpdir(), testname ) ); | ||
|
||
std::string base = pathjoin( testdir(), "modified_scheme", "added_attribute.gpkg" ); | ||
std::string modified = pathjoin( testdir(), "modified_scheme", "added_attribute2.gpkg" ); | ||
std::string changeset = pathjoin( tmpdir(), testname, "changeset.bin" ); | ||
|
||
ASSERT_EQ( GEODIFF_createChangeset( base.c_str(), modified.c_str(), changeset.c_str() ), GEODIFF_UNSUPPORTED_CHANGE ); | ||
} | ||
|
||
TEST( ModifiedSchemeSqlite3Test, retype_attribute ) | ||
{ | ||
std::cout << "geopackage attribute count is same, have same name, but different type" << std::endl; | ||
std::string testname = "retype_attribute"; | ||
makedir( pathjoin( tmpdir(), testname ) ); | ||
|
||
std::string base = pathjoin( testdir(), "modified_scheme", "added_attribute.gpkg" ); | ||
std::string modified = pathjoin( testdir(), "modified_scheme", "added_attribute_different_type.gpkg" ); | ||
std::string changeset = pathjoin( tmpdir(), testname, "changeset.bin" ); | ||
|
||
// this is supported since sqlite3 uses dynamic run-time typing | ||
ASSERT_EQ( GEODIFF_createChangeset( base.c_str(), modified.c_str(), changeset.c_str() ), GEODIFF_SUCCESS ); | ||
} | ||
|
||
int main( int argc, char **argv ) | ||
{ | ||
testing::InitGoogleTest( &argc, argv ); | ||
init_test(); | ||
int ret = RUN_ALL_TESTS(); | ||
finalize_test(); | ||
return ret; | ||
} |
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+96 KB
geodiff/tests/testdata/modified_scheme/added_attribute_different_type.gpkg
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters