File: TemporaryFile.cc

package info (click to toggle)
spatialindex 2.1.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 4,312 kB
  • sloc: cpp: 51,468; python: 3,886; ansic: 848; sh: 375; makefile: 155
file content (33 lines) | stat: -rw-r--r-- 1,018 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include <spatialindex/SpatialIndex.h>
#include <spatialindex/tools/Tools.h>

using namespace SpatialIndex;
using namespace std;

/* 
 * Test the TemporaryFile
 */
int main(int /*argc*/, char** /*argv*/) {
    Tools::TemporaryFile temporaryFile;

    const std::string path = temporaryFile.getFileName();

#if defined ( _MSC_VER )
    const std::string shouldContain = "Temp";
    if (path.find(shouldContain) == std::string::npos) {
        cerr << "Test failed:  TemporaryFile path " << path << " does not contain " << shouldContain << endl;
        return -1;
    }
#else
    const std::string lnxShouldContain = "/tmp/spatialindex-";
    const std::string macShouldContain = "/var/folders/";
    if ( (path.find(lnxShouldContain) == std::string::npos) &&
       (path.find(macShouldContain) == std::string::npos) )
    {
        cerr << "Test failed:  TemporaryFile path " << path << " does not contain " << lnxShouldContain << " nor " << macShouldContain << endl;
        return -1;
    }
#endif

    return 0;
}