diff options
author | Matthew Woehlke <matthew.woehlke@kitware.com> | 2016-09-02 20:53:34 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2016-09-12 14:29:20 (GMT) |
commit | 612d6f29f8743ec100f135aed55d0920b3ea9fda (patch) | |
tree | 1fe4fccd5a9db03c4c178920958001cf99145462 /Tests/RunCMake/GenerateExportHeader/libshared | |
parent | ce76abb4c49a85d491a99318637c6e9e37729f6e (diff) | |
download | CMake-612d6f29f8743ec100f135aed55d0920b3ea9fda.zip CMake-612d6f29f8743ec100f135aed55d0920b3ea9fda.tar.gz CMake-612d6f29f8743ec100f135aed55d0920b3ea9fda.tar.bz2 |
Tests: Refactor GenerateExportHeader test code
Refactor the library code used in the GenerateExportHeader test to use
an improved naming convention that more directly identifies what it
being tested, making use of namespaces to avoid possible symbol
collisions. This also eliminates duplicate cases such as `libshared()`
and `libshared_not_exported()` which had the same decoration, and adds
consistent pairings of <name>_EXPORT and <name>_DEPRECATED_EXPORT which
were missing previously. The data tests from the previous commit are
also added to `libstatic` and `libshared_and_static` for consistency.
Note that there are no exported members of exported classes, as these
are not allowed on Windows.
Diffstat (limited to 'Tests/RunCMake/GenerateExportHeader/libshared')
-rw-r--r-- | Tests/RunCMake/GenerateExportHeader/libshared/libshared.cpp | 71 | ||||
-rw-r--r-- | Tests/RunCMake/GenerateExportHeader/libshared/libshared.h | 67 |
2 files changed, 62 insertions, 76 deletions
diff --git a/Tests/RunCMake/GenerateExportHeader/libshared/libshared.cpp b/Tests/RunCMake/GenerateExportHeader/libshared/libshared.cpp index 7e46ab5..328ef6f 100644 --- a/Tests/RunCMake/GenerateExportHeader/libshared/libshared.cpp +++ b/Tests/RunCMake/GenerateExportHeader/libshared/libshared.cpp @@ -1,129 +1,116 @@ - #include "libshared.h" -int Libshared::libshared() const +int libshared::Class::method() const { return 0; } -int Libshared::libshared_exported() const +int libshared::Class::method_exported() const { return 0; } -int Libshared::libshared_deprecated() const +int libshared::Class::method_deprecated() const { return 0; } -int Libshared::libshared_not_exported() const +int libshared::Class::method_deprecated_exported() const { return 0; } -int Libshared::libshared_excluded() const +int libshared::Class::method_excluded() const { return 0; } -int const Libshared::data_exported = 1; - -int const Libshared::data_not_exported = 1; - -int const Libshared::data_excluded = 1; +int const libshared::Class::data = 1; -int LibsharedNotExported::libshared() const -{ - return 0; -} +int const libshared::Class::data_exported = 1; -int LibsharedNotExported::libshared_exported() const -{ - return 0; -} +int const libshared::Class::data_excluded = 1; -int LibsharedNotExported::libshared_deprecated() const +int libshared::ExportedClass::method() const { return 0; } -int LibsharedNotExported::libshared_not_exported() const +int libshared::ExportedClass::method_deprecated() const { return 0; } -int LibsharedNotExported::libshared_excluded() const +int libshared::ExportedClass::method_excluded() const { return 0; } -int const LibsharedNotExported::data_exported = 1; - -int const LibsharedNotExported::data_not_exported = 1; +int const libshared::ExportedClass::data = 1; -int const LibsharedNotExported::data_excluded = 1; +int const libshared::ExportedClass::data_excluded = 1; -int LibsharedExcluded::libshared() const +int libshared::ExcludedClass::method() const { return 0; } -int LibsharedExcluded::libshared_exported() const +int libshared::ExcludedClass::method_exported() const { return 0; } -int LibsharedExcluded::libshared_deprecated() const +int libshared::ExcludedClass::method_deprecated() const { return 0; } -int LibsharedExcluded::libshared_not_exported() const +int libshared::ExcludedClass::method_deprecated_exported() const { return 0; } -int LibsharedExcluded::libshared_excluded() const +int libshared::ExcludedClass::method_excluded() const { return 0; } -int const LibsharedExcluded::data_exported = 1; +int const libshared::ExcludedClass::data = 1; -int const LibsharedExcluded::data_not_exported = 1; +int const libshared::ExcludedClass::data_exported = 1; -int const LibsharedExcluded::data_excluded = 1; +int const libshared::ExcludedClass::data_excluded = 1; -int libshared() +int libshared::function() { return 0; } -int libshared_exported() +int libshared::function_exported() { return 0; } -int libshared_deprecated() +int libshared::function_deprecated() { return 0; } -int libshared_not_exported() +int libshared::function_deprecated_exported() { return 0; } -int libshared_excluded() +int libshared::function_excluded() { return 0; } -int const data_exported = 1; +int const libshared::data = 1; -int const data_not_exported = 1; +int const libshared::data_exported = 1; -int const data_excluded = 1; +int const libshared::data_excluded = 1; void use_int(int) { diff --git a/Tests/RunCMake/GenerateExportHeader/libshared/libshared.h b/Tests/RunCMake/GenerateExportHeader/libshared/libshared.h index 62879c2..6574bd5 100644 --- a/Tests/RunCMake/GenerateExportHeader/libshared/libshared.h +++ b/Tests/RunCMake/GenerateExportHeader/libshared/libshared.h @@ -1,83 +1,82 @@ - #ifndef LIBSHARED_H #define LIBSHARED_H #include "libshared_export.h" -class LIBSHARED_EXPORT Libshared +namespace libshared { + +class Class { public: - int libshared() const; + int method() const; - int libshared_exported() const; + int LIBSHARED_EXPORT method_exported() const; - int LIBSHARED_DEPRECATED libshared_deprecated() const; + int LIBSHARED_DEPRECATED method_deprecated() const; - int libshared_not_exported() const; + int LIBSHARED_DEPRECATED_EXPORT method_deprecated_exported() const; - int LIBSHARED_NO_EXPORT libshared_excluded() const; + int LIBSHARED_NO_EXPORT method_excluded() const; - static int const LIBSHARED_EXPORT data_exported; + static int const data; - static int const data_not_exported; + static int const LIBSHARED_EXPORT data_exported; static int const LIBSHARED_NO_EXPORT data_excluded; }; -class LibsharedNotExported +class LIBSHARED_EXPORT ExportedClass { public: - int libshared() const; - - int LIBSHARED_EXPORT libshared_exported() const; - - int LIBSHARED_DEPRECATED_EXPORT libshared_deprecated() const; - - int libshared_not_exported() const; + int method() const; - int LIBSHARED_NO_EXPORT libshared_excluded() const; + int LIBSHARED_DEPRECATED method_deprecated() const; - static int const LIBSHARED_EXPORT data_exported; + int LIBSHARED_NO_EXPORT method_excluded() const; - static int const data_not_exported; + static int const data; static int const LIBSHARED_NO_EXPORT data_excluded; }; -class LIBSHARED_NO_EXPORT LibsharedExcluded +class LIBSHARED_NO_EXPORT ExcludedClass { public: - int libshared() const; + int method() const; - int LIBSHARED_EXPORT libshared_exported() const; + int LIBSHARED_EXPORT method_exported() const; - int LIBSHARED_DEPRECATED_EXPORT libshared_deprecated() const; + int LIBSHARED_DEPRECATED method_deprecated() const; - int libshared_not_exported() const; + int LIBSHARED_DEPRECATED_EXPORT method_deprecated_exported() const; - int LIBSHARED_NO_EXPORT libshared_excluded() const; + int LIBSHARED_NO_EXPORT method_excluded() const; - static int const LIBSHARED_EXPORT data_exported; + static int const data; - static int const data_not_exported; + static int const LIBSHARED_EXPORT data_exported; static int const LIBSHARED_NO_EXPORT data_excluded; }; -LIBSHARED_EXPORT int libshared_exported(); +int function(); -LIBSHARED_DEPRECATED_EXPORT int libshared_deprecated(); +int LIBSHARED_EXPORT function_exported(); -int libshared_not_exported(); +int LIBSHARED_DEPRECATED function_deprecated(); -int LIBSHARED_NO_EXPORT libshared_excluded(); +int LIBSHARED_DEPRECATED_EXPORT function_deprecated_exported(); -extern int const LIBSHARED_EXPORT data_exported; +int LIBSHARED_NO_EXPORT function_excluded(); -extern int const data_not_exported; +extern int const data; + +extern int const LIBSHARED_EXPORT data_exported; extern int const LIBSHARED_NO_EXPORT data_excluded; +} // namespace libshared + LIBSHARED_EXPORT void use_int(int); #endif |