Commit 612d6f29 authored by Matthew Woehlke's avatar Matthew Woehlke Committed by Brad King
Browse files

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.
parent ce76abb4
Pipeline #25692 passed with stage
......@@ -56,19 +56,29 @@ void compare(const char* refName, const char* testName)
int main()
{
{
Libshared l;
l.libshared();
l.libshared_exported();
l.libshared_deprecated();
l.libshared_not_exported();
libshared::Class l;
// l.method(); LINK ERROR
l.method_exported();
// l.method_deprecated(); LINK ERROR
l.method_deprecated_exported();
// l.method_excluded(); LINK ERROR
// use_int(l.data); LINK ERROR
use_int(l.data_exported);
// use_int(l.data_excluded); LINK ERROR
}
{
libshared::ExportedClass l;
l.method();
l.method_deprecated();
#if defined(_WIN32) || defined(__CYGWIN__)
l.libshared_excluded();
l.method_excluded();
#else
// l.libshared_excluded(); LINK ERROR (NOT WIN32 AND NOT CYGWIN)
// l.method_excluded(); LINK ERROR (NOT WIN32 AND NOT CYGWIN)
#endif
use_int(l.data_exported);
use_int(l.data_not_exported);
use_int(l.data);
#if defined(_WIN32) || defined(__CYGWIN__)
use_int(l.data_excluded);
#else
......@@ -77,71 +87,76 @@ int main()
}
{
LibsharedNotExported l;
// l.libshared(); LINK ERROR
l.libshared_exported();
l.libshared_deprecated();
// l.libshared_not_exported(); LINK ERROR
// l.libshared_excluded(); LINK ERROR
use_int(l.data_exported);
// use_int(l.data_not_exported); LINK ERROR
// use_int(l.data_excluded); LINK ERROR
}
{
LibsharedExcluded l;
// l.libshared(); LINK ERROR
l.libshared_exported();
l.libshared_deprecated();
// l.libshared_not_exported(); LINK ERROR
// l.libshared_excluded(); LINK ERROR
libshared::ExcludedClass l;
// l.method(); LINK ERROR
l.method_exported();
// l.method_deprecated(); LINK ERROR
l.method_deprecated_exported();
// l.method_excluded(); LINK ERROR
// use_int(l.data); LINK ERROR
use_int(l.data_exported);
// use_int(l.data_not_exported); LINK ERROR
// use_int(l.data_excluded); LINK ERROR
}
libshared_exported();
libshared_deprecated();
// libshared_not_exported(); LINK ERROR
// libshared_excluded(); LINK ERROR
// libshared::function(); LINK ERROR
libshared::function_exported();
// libshared::function_deprecated(); LINK ERROR
libshared::function_deprecated_exported();
// libshared::function_excluded(); LINK ERROR
use_int(data_exported);
// use_int(data_not_exported); LINK ERROR
// use_int(data_excluded); LINK ERROR
// use_int(libshared::data); LINK ERROR
use_int(libshared::data_exported);
// use_int(libshared::data_excluded); LINK ERROR
{
Libstatic l;
l.libstatic();
l.libstatic_exported();
l.libstatic_deprecated();
l.libstatic_not_exported();
l.libstatic_excluded();
libstatic::Class l;
l.method();
l.method_exported();
l.method_deprecated();
l.method_deprecated_exported();
l.method_excluded();
use_int(l.data);
use_int(l.data_exported);
use_int(l.data_excluded);
}
{
LibstaticNotExported l;
l.libstatic();
l.libstatic_exported();
l.libstatic_deprecated();
l.libstatic_not_exported();
l.libstatic_excluded();
libstatic::ExportedClass l;
l.method();
l.method_exported();
l.method_deprecated();
l.method_deprecated_exported();
l.method_excluded();
use_int(l.data);
use_int(l.data_exported);
use_int(l.data_excluded);
}
{
LibstaticExcluded l;
l.libstatic();
l.libstatic_exported();
l.libstatic_deprecated();
l.libstatic_not_exported();
l.libstatic_excluded();
libstatic::ExcludedClass l;
l.method();
l.method_exported();
l.method_deprecated();
l.method_deprecated_exported();
l.method_excluded();
use_int(l.data);
use_int(l.data_exported);
use_int(l.data_excluded);
}
libstatic_exported();
libstatic_deprecated();
libstatic_not_exported();
libstatic_excluded();
libstatic::function();
libstatic::function_exported();
libstatic::function_deprecated();
libstatic::function_deprecated_exported();
libstatic::function_excluded();
use_int(libstatic::data);
use_int(libstatic::data_exported);
use_int(libstatic::data_excluded);
#if defined(SRC_DIR) && defined(BIN_DIR)
compare(SRC_DIR "/libshared_export.h",
......
#include "libshared_and_static.h"
#ifndef MY_CUSTOM_CONTENT_ADDED
#error "MY_CUSTOM_CONTENT_ADDED not defined!"
#endif
int LibsharedAndStatic::libshared_and_static() const
int libshared_and_static::Class::method() const
{
return 0;
}
int LibsharedAndStatic::libshared_and_static_exported() const
int libshared_and_static::Class::method_exported() const
{
return 0;
}
int LibsharedAndStatic::libshared_and_static_deprecated() const
int libshared_and_static::Class::method_deprecated() const
{
return 0;
}
int LibsharedAndStatic::libshared_and_static_not_exported() const
int libshared_and_static::Class::method_deprecated_exported() const
{
return 0;
}
int LibsharedAndStatic::libshared_and_static_excluded() const
int libshared_and_static::Class::method_excluded() const
{
return 0;
}
int LibsharedAndStaticNotExported::libshared_and_static() const
{
return 0;
}
int const libshared_and_static::Class::data = 1;
int LibsharedAndStaticNotExported::libshared_and_static_exported() const
int const libshared_and_static::Class::data_exported = 1;
int const libshared_and_static::Class::data_excluded = 1;
int libshared_and_static::ExportedClass::method() const
{
return 0;
}
int LibsharedAndStaticNotExported::libshared_and_static_deprecated() const
int libshared_and_static::ExportedClass::method_deprecated() const
{
return 0;
}
int LibsharedAndStaticNotExported::libshared_and_static_not_exported() const
int libshared_and_static::ExportedClass::method_excluded() const
{
return 0;
}
int LibsharedAndStaticNotExported::libshared_and_static_excluded() const
int const libshared_and_static::ExportedClass::data = 1;
int const libshared_and_static::ExportedClass::data_excluded = 1;
int libshared_and_static::ExcludedClass::method() const
{
return 0;
}
int LibsharedAndStaticExcluded::libshared_and_static() const
int libshared_and_static::ExcludedClass::method_exported() const
{
return 0;
}
int LibsharedAndStaticExcluded::libshared_and_static_exported() const
int libshared_and_static::ExcludedClass::method_deprecated() const
{
return 0;
}
int LibsharedAndStaticExcluded::libshared_and_static_deprecated() const
int libshared_and_static::ExcludedClass::method_deprecated_exported() const
{
return 0;
}
int LibsharedAndStaticExcluded::libshared_and_static_not_exported() const
int libshared_and_static::ExcludedClass::method_excluded() const
{
return 0;
}
int LibsharedAndStaticExcluded::libshared_and_static_excluded() const
int const libshared_and_static::ExcludedClass::data = 1;
int const libshared_and_static::ExcludedClass::data_exported = 1;
int const libshared_and_static::ExcludedClass::data_excluded = 1;
int libshared_and_static::function()
{
return 0;
}
int libshared_and_static()
int libshared_and_static::function_exported()
{
return 0;
}
int libshared_and_static_exported()
int libshared_and_static::function_deprecated()
{
return 0;
}
int libshared_and_static_deprecated()
int libshared_and_static::function_deprecated_exported()
{
return 0;
}
int libshared_and_static_not_exported()
int libshared_and_static::function_excluded()
{
return 0;
}
int libshared_and_static_excluded()
int const libshared_and_static::data = 1;
int const libshared_and_static::data_exported = 1;
int const libshared_and_static::data_excluded = 1;
void use_int(int)
{
return 0;
}
#ifndef SHARED_AND_STATIC_H
#define SHARED_AND_STATIC_H
#ifndef LIBSHARED_AND_STATIC_H
#define LIBSHARED_AND_STATIC_H
#include "libshared_and_static_export.h"
class MYPREFIX_LIBSHARED_AND_STATIC_EXPORT LibsharedAndStatic
namespace libshared_and_static {
class Class
{
public:
int libshared_and_static() const;
int method() const;
int MYPREFIX_LIBSHARED_AND_STATIC_EXPORT method_exported() const;
int MYPREFIX_LIBSHARED_AND_STATIC_DEPRECATED method_deprecated() const;
int libshared_and_static_exported() const;
int MYPREFIX_LIBSHARED_AND_STATIC_DEPRECATED_EXPORT
method_deprecated_exported() const;
int MYPREFIX_LIBSHARED_AND_STATIC_DEPRECATED
libshared_and_static_deprecated() const;
int MYPREFIX_LIBSHARED_AND_STATIC_NO_EXPORT method_excluded() const;
int libshared_and_static_not_exported() const;
static int const data;
int MYPREFIX_LIBSHARED_AND_STATIC_NO_EXPORT
libshared_and_static_excluded() const;
static int const MYPREFIX_LIBSHARED_AND_STATIC_EXPORT data_exported;
static int const MYPREFIX_LIBSHARED_AND_STATIC_NO_EXPORT data_excluded;
};
class LibsharedAndStaticNotExported
class MYPREFIX_LIBSHARED_AND_STATIC_EXPORT ExportedClass
{
public:
int libshared_and_static() const;
int method() const;
int MYPREFIX_LIBSHARED_AND_STATIC_EXPORT
libshared_and_static_exported() const;
int MYPREFIX_LIBSHARED_AND_STATIC_DEPRECATED method_deprecated() const;
int MYPREFIX_LIBSHARED_AND_STATIC_DEPRECATED
libshared_and_static_deprecated() const;
int MYPREFIX_LIBSHARED_AND_STATIC_NO_EXPORT method_excluded() const;
int libshared_and_static_not_exported() const;
static int const data;
int MYPREFIX_LIBSHARED_AND_STATIC_NO_EXPORT
libshared_and_static_excluded() const;
static int const MYPREFIX_LIBSHARED_AND_STATIC_NO_EXPORT data_excluded;
};
class MYPREFIX_LIBSHARED_AND_STATIC_NO_EXPORT LibsharedAndStaticExcluded
class MYPREFIX_LIBSHARED_AND_STATIC_NO_EXPORT ExcludedClass
{
public:
int libshared_and_static() const;
int method() const;
int MYPREFIX_LIBSHARED_AND_STATIC_EXPORT method_exported() const;
int MYPREFIX_LIBSHARED_AND_STATIC_DEPRECATED method_deprecated() const;
int MYPREFIX_LIBSHARED_AND_STATIC_EXPORT
libshared_and_static_exported() const;
int MYPREFIX_LIBSHARED_AND_STATIC_DEPRECATED_EXPORT
method_deprecated_exported() const;
int MYPREFIX_LIBSHARED_AND_STATIC_DEPRECATED
libshared_and_static_deprecated() const;
int MYPREFIX_LIBSHARED_AND_STATIC_NO_EXPORT method_excluded() const;
int libshared_and_static_not_exported() const;
static int const data;
int MYPREFIX_LIBSHARED_AND_STATIC_NO_EXPORT
libshared_and_static_excluded() const;
static int const MYPREFIX_LIBSHARED_AND_STATIC_EXPORT data_exported;
static int const MYPREFIX_LIBSHARED_AND_STATIC_NO_EXPORT data_excluded;
};
MYPREFIX_LIBSHARED_AND_STATIC_EXPORT int libshared_and_static_exported();
int function();
int MYPREFIX_LIBSHARED_AND_STATIC_EXPORT function_exported();
int MYPREFIX_LIBSHARED_AND_STATIC_DEPRECATED function_deprecated();
int MYPREFIX_LIBSHARED_AND_STATIC_DEPRECATED_EXPORT
function_deprecated_exported();
int MYPREFIX_LIBSHARED_AND_STATIC_NO_EXPORT function_excluded();
extern int const data;
MYPREFIX_LIBSHARED_AND_STATIC_DEPRECATED_EXPORT int
libshared_and_static_deprecated();
extern int const MYPREFIX_LIBSHARED_AND_STATIC_EXPORT data_exported;
int libshared_and_static_not_exported();
extern int const MYPREFIX_LIBSHARED_AND_STATIC_NO_EXPORT data_excluded;
int MYPREFIX_LIBSHARED_AND_STATIC_NO_EXPORT libshared_and_static_excluded();
} // namespace libshared_and_static
#endif
#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)