diff options
| author | Jon A. Cruz <jon@joncruz.org> | 2015-05-06 08:54:02 +0000 |
|---|---|---|
| committer | Jon A. Cruz <jon@joncruz.org> | 2015-05-06 08:54:02 +0000 |
| commit | f2a97ac662d344badaec74c0e70844b5dedf167c (patch) | |
| tree | 81c16c317502ae59c5167cb35d9798bb18198f75 /test | |
| parent | Changed return type to be consistent with other calls and to make header stan... (diff) | |
| download | inkscape-f2a97ac662d344badaec74c0e70844b5dedf167c.tar.gz inkscape-f2a97ac662d344badaec74c0e70844b5dedf167c.zip | |
Converted unit test fr dir-util for Google Test.
(bzr r14113)
Diffstat (limited to 'test')
| -rw-r--r-- | test/CMakeLists.txt | 1 | ||||
| -rw-r--r-- | test/src/dir-util-test.cpp | 63 |
2 files changed, 64 insertions, 0 deletions
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 750b658ee..0b9584631 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -436,6 +436,7 @@ add_executable(unittest doc-per-case-test.cpp src/attributes-test.cpp src/color-profile-test.cpp + src/dir-util-test.cpp ${inkscape_SRC} ${sp_SRC} ${inkscape_global_SRC} diff --git a/test/src/dir-util-test.cpp b/test/src/dir-util-test.cpp new file mode 100644 index 000000000..32b3fce74 --- /dev/null +++ b/test/src/dir-util-test.cpp @@ -0,0 +1,63 @@ +/* + * Unit tests for dir utils. + * + * Author: + * Jon A. Cruz <jon@joncruz.org> + * + * Copyright (C) 2015 Authors + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#include "gtest/gtest.h" + +#include <glib.h> + +#include "dir-util.h" + +namespace { + + +TEST(DirUtilTest, Base) +{ + char const* cases[][3] = { +#if defined(WIN32) || defined(__WIN32__) + {"\\foo\\bar", "\\foo", "bar"}, + {"\\foo\\barney", "\\foo\\bar", "\\foo\\barney"}, + {"\\foo\\bar\\baz", "\\foo\\", "bar\\baz"}, + {"\\foo\\bar\\baz", "\\", "foo\\bar\\baz"}, + {"\\foo\\bar\\baz", "\\foo\\qux", "\\foo\\bar\\baz"}, +#else + {"/foo/bar", "/foo", "bar"}, + {"/foo/barney", "/foo/bar", "/foo/barney"}, + {"/foo/bar/baz", "/foo/", "bar/baz"}, + {"/foo/bar/baz", "/", "foo/bar/baz"}, + {"/foo/bar/baz", "/foo/qux", "/foo/bar/baz"}, +#endif + }; + + for ( size_t i = 0; i < G_N_ELEMENTS(cases); i++ ) + { + if ( cases[i][0] && cases[i][1] ) { // std::string can't use null. + std::string result = sp_relative_path_from_path( cases[i][0], cases[i][1] ); + ASSERT_FALSE( result.empty() ); + if ( !result.empty() ) + { + ASSERT_EQ( std::string(cases[i][2]), result ); + } + } + } +} + +} // namespace + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : |
