summaryrefslogtreecommitdiffstats
path: root/kopete/protocols/oscar/liboscar/tests/ipaddrtest.cpp
blob: 4f4e8df2490dce4b65257ed4efcc9e41341fcb47 (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
//Licensed under the GNU General Public License

#include <iostream>
#include "ipaddrtest.h"
#include <qstring.h>

using namespace std;
IPAddrTest::IPAddrTest(int argc, char ** argv)
: QApplication( argc, argv )
{
}

IPAddrTest::~IPAddrTest()
{
}

bool IPAddrTest::testDottedDecimal()
{
    DWORD address = 1096652712;
    return ( Oscar::getDottedDecimal( address ) == "65.93.151.168" );
}

bool IPAddrTest::testAllZeroDotted()
{
    DWORD address = 0;
    return ( Oscar::getDottedDecimal( address ) == "0.0.0.0" );
}

bool IPAddrTest::testNumericalIP()
{
    QString address = "65.93.151.168";
    return ( Oscar::getNumericalIP( address ) == 1096652712 );
}

bool IPAddrTest::testAllZeroNumerical()
{
    QString address = "0.0.0.0";
    return ( Oscar::getNumericalIP( address ) == 0 );
}

void IPAddrTest::CheckTest(bool TestPassed)
{
	if ( TestPassed )
		cout << "passed" << endl;
	else
		cout << "failed" << endl;
}

int main(int argc, char ** argv)
{
	IPAddrTest a( argc, argv );

	a.CheckTest(a.testDottedDecimal());
	a.CheckTest(a.testNumericalIP());
        a.CheckTest(a.testAllZeroDotted() );
        a.CheckTest( a.testAllZeroNumerical() );
}