summaryrefslogtreecommitdiffstats
path: root/kopete/protocols/oscar/liboscar/tests/ipaddrtest.cpp
blob: 0f37f614d320aba553735fff645a9f53e3ed5dbd (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 <tqstring.h>

using namespace std;
IPAddrTest::IPAddrTest(int argc, char ** argv)
: TQApplication( 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()
{
    TQString address = "65.93.151.168";
    return ( Oscar::getNumericalIP( address ) == 1096652712 );
}

bool IPAddrTest::testAllZeroNumerical()
{
    TQString 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() );
}