Huggle  build:^490^dce1e5c
 All Classes Namespaces Functions Variables Enumerations Enumerator Pages
tst_testmain.cpp
1 //This program is free software: you can redistribute it and/or modify
2 //it under the terms of the GNU General Public License as published by
3 //the Free Software Foundation, either version 3 of the License, or
4 //(at your option) any later version.
5 
6 //This program is distributed in the hope that it will be useful,
7 //but WITHOUT ANY WARRANTY; without even the implied warranty of
8 //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9 //GNU General Public License for more details.
10 
11 #include <QString>
12 #include <QtTest>
13 #include "../../terminalparser.hpp"
14 #include "../../wikiuser.hpp"
15 
16 //! This is a unit test
17 class HuggleTest : public QObject
18 {
19  Q_OBJECT
20 
21  public:
22  HuggleTest();
23 
24  private Q_SLOTS:
25  //! Test if IsIP returns true for users who are IP's
27  void testCaseTerminalParser();
28 };
29 
30 HuggleTest::HuggleTest()
31 {
32 }
33 
35 {
36  QVERIFY2(Huggle::WikiUser("10.0.0.1").IsIP(), "Invalid result for new WikiUser with username of IP, the result of IsIP() was false, but should have been true");
37  QVERIFY2(Huggle::WikiUser("150.30.0.56").IsIP(), "Invalid result for new WikiUser with username of IP, the result of IsIP() was false, but should have been true");
38  QVERIFY2((Huggle::WikiUser("355.2.0.1").IsIP() == false), "Invalid result for new WikiUser with username of IP, the result of IsIP() was true, but should have been false");
39  QVERIFY2((Huggle::WikiUser("Frank").IsIP() == false), "Invalid result for new WikiUser with username of IP, the result of IsIP() was true, but should have been false");
40  QVERIFY2((Huggle::WikiUser("Joe").IsIP() == false), "Invalid result for new WikiUser with username of IP, the result of IsIP() was true, but should have been false");
41 }
42 
43 void HuggleTest::testCaseTerminalParser()
44 {
45  QStringList list;
46  list.append("huggle");
47  list.append("-v");
48  Huggle::TerminalParser *p = new Huggle::TerminalParser(list.count(), list);
49  p->Silent = true;
50  QVERIFY2(p->Parse() == false, "Invalid result for terminal parser");
51  list.append("-vvvvvvvvvvvvvvvvv");
52  delete p;
53  p = new Huggle::TerminalParser(list.count(), list);
54  p->Silent = true;
55  QVERIFY2(p->Parse() == false, "Invalid result for terminal parser");
56  list.append("-vvvvvvhvvvvvvv");
57  delete p;
58  p = new Huggle::TerminalParser(list.count(), list);
59  p->Silent = true;
60  QVERIFY2(p->Parse() == true, "Invalid result for terminal parser");
61  list.clear();
62  list.append("huggle");
63  list.append("--help");
64  delete p;
65  p = new Huggle::TerminalParser(list.count(), list);
66  p->Silent = true;
67  QVERIFY2(p->Parse() == true, "Invalid result for terminal parser");
68  list.clear();
69  list.append("huggle");
70  list.append("--safe");
71  delete p;
72  p = new Huggle::TerminalParser(list.count(), list);
73  p->Silent = true;
74  QVERIFY2(p->Parse() == false, "Invalid result for terminal parser");
75  list.clear();
76  list.append("huggle");
77  list.append("--blabla");
78  delete p;
79  p = new Huggle::TerminalParser(list.count(), list);
80  p->Silent = true;
81  QVERIFY2(p->Parse() == true, "Invalid result for terminal parser");
82  delete p;
83 }
84 
85 QTEST_APPLESS_MAIN(HuggleTest)
86 
87 #include "tst_testmain.moc"
void testCaseWikiUserCheckIP()
Test if IsIP returns true for users who are IP&#39;s.
Parses the data provided by user.
This is a unit test.