summaryrefslogtreecommitdiffstats
path: root/src/piklab-test/misc/misc_check.cpp
blob: 7f8c710ef76b44e8f80be746b72e8d089de9504c (plain)
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
/***************************************************************************
 *   Copyright (C) 2007 Nicolas Hadacek <[email protected]>                  *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 ***************************************************************************/
#include "misc_check.h"

#include "common/global/purl.h"

//----------------------------------------------------------------------------
bool MiscCheck::execute()
{
  {
    PURL::Url url = PURL::Url::fromPathOrUrl(TQString());
    if ( !url.isEmpty() ) TEST_FAILED("isEmpty");
    TEST_PASSED;
  }
  {
    PURL::Url url = PURL::Url::fromPathOrUrl("");
    if ( !url.isEmpty() ) TEST_FAILED("isEmpty");
    TEST_PASSED;
  }
  {
    PURL::Url url = PURL::Url::fromPathOrUrl("/");
    if ( url.isEmpty() ) TEST_FAILED("isEmpty");
    if ( url.isRelative() ) TEST_FAILED("isRelative");
    if ( !url.isLocal() ) TEST_FAILED("isLocal");
    if ( url.path()!="/" ) TEST_FAILED("");
    if ( url.filepath()!="/" ) TEST_FAILED(url.filepath());
    if ( url.unterminatedPath()!="/" ) TEST_FAILED("");
    if ( !url.filename().isEmpty() ) TEST_FAILED(url.filename());
    TEST_PASSED;
  }
  {
    PURL::Url url = PURL::Url::fromPathOrUrl("test");
    if ( url.isEmpty() ) TEST_FAILED("isEmpty");
    if ( !url.isRelative() ) TEST_FAILED("isRelative");
    if ( !url.isLocal() ) TEST_FAILED("isLocal");
    if ( url.filename()!="test" ) TEST_FAILED(url.filename());
    TEST_PASSED;
  }
  {
    PURL::Url url = PURL::Url::fromPathOrUrl("/test");
    if ( url.isEmpty() ) TEST_FAILED("isEmpty");
    if ( url.isRelative() ) TEST_FAILED("isRelative");
    if ( !url.isLocal() ) TEST_FAILED("isLocal");
    if ( url.path()!="/" ) TEST_FAILED("");
    if ( url.unterminatedPath()!="/" ) TEST_FAILED("");
    if ( url.filepath()!="/test" ) TEST_FAILED(url.filepath());
    if ( url.filename()!="test" ) TEST_FAILED(url.filename());
    TEST_PASSED;
  }
  {
    PURL::Url url = PURL::Url::fromPathOrUrl("/test/");
    if ( url.isEmpty() ) TEST_FAILED("isEmpty");
    if ( url.isRelative() ) TEST_FAILED("isRelative");
    if ( !url.isLocal() ) TEST_FAILED("isLocal");
    if ( url.path()!="/test/" ) TEST_FAILED("");
    if ( url.unterminatedPath()!="/test" ) TEST_FAILED("");
    if ( url.filepath()!="/test/" ) TEST_FAILED(url.filepath());
    if ( !url.filename().isEmpty() ) TEST_FAILED(url.filename());
    TEST_PASSED;
  }
  {
    PURL::Url url = PURL::Url::fromPathOrUrl("c:/test");
    if ( url.isEmpty() ) TEST_FAILED("isEmpty");
    if ( url.isRelative() ) TEST_FAILED("isRelative");
    if ( !url.isLocal() ) TEST_FAILED("isLocal");
    PURL::Url url2 = PURL::Url::fromPathOrUrl("c:/");
    if ( url.path()!=url2.path() ) TEST_FAILED(url.path());
    if ( url==url2 ) TEST_FAILED(url.path());
    if ( url.filename()!="test" ) TEST_FAILED(url.filename());
    TEST_PASSED;
  }
  {
    PURL::Url url = PURL::Url::fromPathOrUrl("d:/test/");
    if ( url.isEmpty() ) TEST_FAILED("isEmpty");
    if ( url.isRelative() ) TEST_FAILED("isRelative");
    if ( !url.isLocal() ) TEST_FAILED("isLocal");
    if ( !url.filename().isEmpty() ) TEST_FAILED(url.filename());
    TEST_PASSED;
  }
  {
    PURL::Url url(KURL::fromPathOrURL("http://test.net/test"));
    if ( url.isEmpty() ) TEST_FAILED("isEmpty");
    if ( url.isRelative() ) TEST_FAILED("isRelative");
    if ( url.isLocal() ) TEST_FAILED("isLocal");
    if ( url.filename()!="test" ) TEST_FAILED(url.filename());
    TEST_PASSED;
  }

  return true;
}

//----------------------------------------------------------------------------
TEST_MAIN(MiscCheck)