From 96309fc6e2439ede2604fc18ad04e82ffc54b606 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Fri, 17 Dec 2010 12:28:33 -0500 Subject: Make TestsWorkingDirectory test a C file --- Tests/TestsWorkingDirectory/CMakeLists.txt | 2 +- Tests/TestsWorkingDirectory/main.c | 66 ++++++++++++++++++++++++++++++ Tests/TestsWorkingDirectory/main.cxx | 66 ------------------------------ 3 files changed, 67 insertions(+), 67 deletions(-) create mode 100644 Tests/TestsWorkingDirectory/main.c delete mode 100644 Tests/TestsWorkingDirectory/main.cxx diff --git a/Tests/TestsWorkingDirectory/CMakeLists.txt b/Tests/TestsWorkingDirectory/CMakeLists.txt index 24dc5e6..01e6650 100644 --- a/Tests/TestsWorkingDirectory/CMakeLists.txt +++ b/Tests/TestsWorkingDirectory/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required(VERSION 2.6) project(TestsWorkingDirectoryProj) -add_executable(WorkingDirectory main.cxx) +add_executable(WorkingDirectory main.c) enable_testing() diff --git a/Tests/TestsWorkingDirectory/main.c b/Tests/TestsWorkingDirectory/main.c new file mode 100644 index 0000000..ad5eb30 --- /dev/null +++ b/Tests/TestsWorkingDirectory/main.c @@ -0,0 +1,66 @@ +#include +#include +#include +#include + +#if defined(_WIN32) && (defined(_MSC_VER) || defined(__WATCOMC__) || defined(__BORLANDC__) || defined(__MINGW32__)) + +#include +#include + +#if defined(__WATCOMC__) +#include +#define _getcwd getcwd +#endif + +static const char* Getcwd(char* buf, unsigned int len) +{ + const char* ret = _getcwd(buf, len); + char* p = NULL; + if(!ret) + { + fprintf(stderr, "No current working directory.\n"); + abort(); + } + // make sure the drive letter is capital + if(strlen(buf) > 1 && buf[1] == ':') + { + buf[0] = toupper(buf[0]); + } + for(p = buf; *p; ++p) + { + if(*p == '\\') + { + *p = '/'; + } + } + return ret; +} + +#else +#include +#include +#include + +static const char* Getcwd(char* buf, unsigned int len) +{ + const char* ret = getcwd(buf, len); + if(!ret) + { + fprintf(stderr, "No current working directory\n"); + abort(); + } + return ret; +} + +#endif + +int main(int argc, char *argv[]) +{ + char buf[2048]; + const char *cwd = Getcwd(buf, sizeof(buf)); + + fprintf(stdout, "Working directory: -->%s<--", cwd); + + return 0; +} diff --git a/Tests/TestsWorkingDirectory/main.cxx b/Tests/TestsWorkingDirectory/main.cxx deleted file mode 100644 index 42c3d34..0000000 --- a/Tests/TestsWorkingDirectory/main.cxx +++ /dev/null @@ -1,66 +0,0 @@ -#include -#include -#include - -#include - -#if defined(_WIN32) && (defined(_MSC_VER) || defined(__WATCOMC__) || defined(__BORLANDC__) || defined(__MINGW32__)) - -#include -#include - -#if defined(__WATCOMC__) -#include -#define _getcwd getcwd -#endif - -inline const char* Getcwd(char* buf, unsigned int len) -{ - const char* ret = _getcwd(buf, len); - if(!ret) - { - std::cerr << "No current working directory." << std::endl; - abort(); - } - // make sure the drive letter is capital - if(strlen(buf) > 1 && buf[1] == ':') - { - buf[0] = toupper(buf[0]); - } - for(char* p = buf; *p; ++p) - { - if(*p == '\\') - { - *p = '/'; - } - } - return ret; -} - -#else -#include -#include -#include - -inline const char* Getcwd(char* buf, unsigned int len) -{ - const char* ret = getcwd(buf, len); - if(!ret) - { - std::cerr << "No current working directory" << std::endl; - abort(); - } - return ret; -} - -#endif - -int main(int argc, char *argv[]) -{ - char buf[2048]; - const char *cwd = Getcwd(buf, sizeof(buf)); - - std::cout << "Working directory: -->" << cwd << "<--"; - - return 0; -} -- cgit v0.12