2011-07-13 04:13:33 +04:00
|
|
|
|
|
|
|
#include "libshared.h"
|
|
|
|
|
|
|
|
#include "libstatic.h"
|
|
|
|
|
|
|
|
// #define BUILD_FAIL
|
|
|
|
|
|
|
|
#ifndef BUILD_FAIL
|
|
|
|
#define DOES_NOT_BUILD(function)
|
|
|
|
#else
|
|
|
|
#define DOES_NOT_BUILD(function) function
|
|
|
|
#endif
|
|
|
|
|
2013-12-11 04:01:50 +04:00
|
|
|
#include <fstream>
|
|
|
|
#include <iostream>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
void compare(const char* refName, const char* testName)
|
|
|
|
{
|
|
|
|
std::ifstream ref;
|
|
|
|
ref.open(refName);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!ref.is_open()) {
|
2013-12-11 04:01:50 +04:00
|
|
|
std::cout << "Could not open \"" << refName << "\"." << std::endl;
|
|
|
|
exit(1);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2013-12-11 04:01:50 +04:00
|
|
|
std::ifstream test;
|
|
|
|
test.open(testName);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!test.is_open()) {
|
2013-12-11 04:01:50 +04:00
|
|
|
std::cout << "Could not open \"" << testName << "\"." << std::endl;
|
|
|
|
exit(1);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2013-12-11 04:01:50 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
while (!ref.eof() && !test.eof()) {
|
2013-12-11 04:01:50 +04:00
|
|
|
std::string refLine;
|
|
|
|
std::string testLine;
|
|
|
|
std::getline(ref, refLine);
|
|
|
|
std::getline(test, testLine);
|
2015-12-31 20:45:34 +03:00
|
|
|
// Some very old Borland runtimes (C++ Builder 5 WITHOUT Update 1) add a
|
|
|
|
// trailing null to the string that we need to strip before testing for a
|
|
|
|
// trailing space.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (refLine.size() && refLine[refLine.size() - 1] == 0) {
|
2015-12-31 20:45:34 +03:00
|
|
|
refLine = refLine.substr(0, refLine.size() - 1);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (testLine.size() && testLine[testLine.size() - 1] == 0) {
|
2015-12-31 20:45:34 +03:00
|
|
|
testLine = testLine.substr(0, testLine.size() - 1);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-12-31 20:45:34 +03:00
|
|
|
// The reference files never have trailing spaces:
|
2016-05-16 17:34:04 +03:00
|
|
|
if (testLine.size() && testLine[testLine.size() - 1] == ' ') {
|
2013-12-11 04:01:50 +04:00
|
|
|
testLine = testLine.substr(0, testLine.size() - 1);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (refLine != testLine) {
|
|
|
|
std::cout << "Ref and test are not the same:\n Ref: \"" << refLine
|
|
|
|
<< "\"\n Test: \"" << testLine << "\"\n";
|
2013-12-11 04:01:50 +04:00
|
|
|
exit(1);
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (!ref.eof() || !test.eof()) {
|
2013-12-11 04:01:50 +04:00
|
|
|
std::cout << "Ref and test have differing numbers of lines.";
|
|
|
|
exit(1);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2013-12-11 04:01:50 +04:00
|
|
|
}
|
|
|
|
|
2011-07-13 04:13:33 +04:00
|
|
|
int main()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Libshared l;
|
|
|
|
l.libshared();
|
|
|
|
l.libshared_exported();
|
|
|
|
l.libshared_deprecated();
|
|
|
|
l.libshared_not_exported();
|
|
|
|
|
|
|
|
DOES_NOT_BUILD(l.libshared_excluded();)
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
LibsharedNotExported l;
|
|
|
|
DOES_NOT_BUILD(l.libshared();)
|
|
|
|
l.libshared_exported();
|
|
|
|
l.libshared_deprecated();
|
|
|
|
DOES_NOT_BUILD(l.libshared_not_exported();)
|
|
|
|
DOES_NOT_BUILD(l.libshared_excluded();)
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
LibsharedExcluded l;
|
|
|
|
DOES_NOT_BUILD(l.libshared();)
|
|
|
|
l.libshared_exported();
|
|
|
|
l.libshared_deprecated();
|
|
|
|
DOES_NOT_BUILD(l.libshared_not_exported();)
|
|
|
|
DOES_NOT_BUILD(l.libshared_excluded();)
|
|
|
|
}
|
|
|
|
|
|
|
|
libshared_exported();
|
|
|
|
libshared_deprecated();
|
|
|
|
DOES_NOT_BUILD(libshared_not_exported();)
|
|
|
|
DOES_NOT_BUILD(libshared_excluded();)
|
|
|
|
|
|
|
|
{
|
|
|
|
Libstatic l;
|
|
|
|
l.libstatic();
|
|
|
|
l.libstatic_exported();
|
|
|
|
l.libstatic_deprecated();
|
|
|
|
l.libstatic_not_exported();
|
|
|
|
l.libstatic_excluded();
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
LibstaticNotExported l;
|
|
|
|
l.libstatic();
|
|
|
|
l.libstatic_exported();
|
|
|
|
l.libstatic_deprecated();
|
|
|
|
l.libstatic_not_exported();
|
|
|
|
l.libstatic_excluded();
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
LibstaticExcluded l;
|
|
|
|
l.libstatic();
|
|
|
|
l.libstatic_exported();
|
|
|
|
l.libstatic_deprecated();
|
|
|
|
l.libstatic_not_exported();
|
|
|
|
l.libstatic_excluded();
|
|
|
|
}
|
|
|
|
|
|
|
|
libstatic_exported();
|
|
|
|
libstatic_deprecated();
|
|
|
|
libstatic_not_exported();
|
|
|
|
libstatic_excluded();
|
|
|
|
|
2016-02-12 21:14:59 +03:00
|
|
|
compare(SRC_DIR "/libshared_export.h",
|
|
|
|
BIN_DIR "/libshared/libshared_export.h");
|
|
|
|
compare(SRC_DIR "/libstatic_export.h",
|
|
|
|
BIN_DIR "/libstatic/libstatic_export.h");
|
2013-12-11 04:01:50 +04:00
|
|
|
|
2011-07-13 04:13:33 +04:00
|
|
|
return 0;
|
2011-08-23 21:49:52 +04:00
|
|
|
}
|