~baltix/+junk/irrlicht-test

« back to all changes in this revision

Viewing changes to tests/irrCoreEquals.cpp

  • Committer: Mantas Kriaučiūnas
  • Date: 2011-07-18 13:06:25 UTC
  • Revision ID: mantas@akl.lt-20110718130625-c5pvifp61e7kj1ol
Included whole irrlicht SVN libraries to work around launchpad recipe issue with quilt, see https://answers.launchpad.net/launchpad/+question/165193

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// Copyright (C) 2008-2011 Colin MacDonald and Christian Stehno
 
2
// No rights reserved: this software is in the public domain.
 
3
 
 
4
#include "testUtils.h"
 
5
 
 
6
bool irrCoreEquals(void)
 
7
{
 
8
        // float tests
 
9
        if(!irr::core::equals(99.f, 99.f))
 
10
        {
 
11
                logTestString("irr::core::equals(f32, f32 (, default)) failed.\n");
 
12
                return false;
 
13
        }
 
14
 
 
15
        if(!irr::core::equals(99.f, 98.f, 1.f))
 
16
        {
 
17
                logTestString("irr::core::equals(f32, f32, f32) failed.\n");
 
18
                return false;
 
19
        }
 
20
 
 
21
        // double tests
 
22
        if(!irr::core::equals(99.0, 99.0))
 
23
        {
 
24
                logTestString("irr::core::equals(f64, f64 (,default)) failed.\n");
 
25
                return false;
 
26
        }
 
27
 
 
28
        if(!irr::core::equals(99.0, 98.0, 1.0))
 
29
        {
 
30
                logTestString("irr::core::equals(f64, f64, f64) failed.\n");
 
31
                return false;
 
32
        }
 
33
 
 
34
        // int tests
 
35
        if(!irr::core::equals(99, 99))
 
36
        {
 
37
                logTestString("irr::core::equals(s32, s32 (,default)) failed.\n");
 
38
                return false;
 
39
        }
 
40
 
 
41
        if(!irr::core::equals(99, 98, 1))
 
42
        {
 
43
                logTestString("irr::core::equals(s32, s32, s32) failed.\n");
 
44
                return false;
 
45
        }
 
46
 
 
47
        if(irr::core::equals(99, 98, 0))
 
48
        {
 
49
                logTestString("irr::core::equals(s32, s32, 0) failed.\n");
 
50
                return false;
 
51
        }
 
52
 
 
53
        if(!irr::core::equals(-99, -99))
 
54
        {
 
55
                logTestString("irr::core::equals(s32, s32 (,default)) failed.\n");
 
56
                return false;
 
57
        }
 
58
 
 
59
        if(!irr::core::equals(-99, -98, 1))
 
60
        {
 
61
                logTestString("irr::core::equals(s32, s32, s32) failed.\n");
 
62
                return false;
 
63
        }
 
64
 
 
65
        if(irr::core::equals(-99, -98, 0))
 
66
        {
 
67
                logTestString("irr::core::equals(s32, s32, 0) failed.\n");
 
68
                return false;
 
69
        }
 
70
 
 
71
        // iszero is a specialized equals method
 
72
        // float tests
 
73
        if(!irr::core::iszero(.0f))
 
74
        {
 
75
                logTestString("irr::core::iszero(f32 (,default)) failed.\n");
 
76
                return false;
 
77
        }
 
78
 
 
79
        if(irr::core::iszero(-1.0f))
 
80
        {
 
81
                logTestString("irr::core::iszero(f32 (,default)) failed.\n");
 
82
                return false;
 
83
        }
 
84
 
 
85
        if(!irr::core::iszero(1.0f, 1.0f))
 
86
        {
 
87
                logTestString("irr::core::iszero(f32, f32) failed.\n");
 
88
                return false;
 
89
        }
 
90
 
 
91
        // double tests
 
92
        if(!irr::core::iszero(0.0))
 
93
        {
 
94
                logTestString("irr::core::iszero(f64 (,default)) failed.\n");
 
95
                return false;
 
96
        }
 
97
 
 
98
        if(irr::core::iszero(-1.0))
 
99
        {
 
100
                logTestString("irr::core::iszero(f64 (,default)) failed.\n");
 
101
                return false;
 
102
        }
 
103
 
 
104
        if(!irr::core::iszero(-2.0, 2.0))
 
105
        {
 
106
                logTestString("irr::core::iszero(f64, f64) failed.\n");
 
107
                return false;
 
108
        }
 
109
 
 
110
        // int tests
 
111
        if(!irr::core::iszero(0))
 
112
        {
 
113
                logTestString("irr::core::iszero(s32 (,default)) failed.\n");
 
114
                return false;
 
115
        }
 
116
 
 
117
        if(irr::core::iszero(-1))
 
118
        {
 
119
                logTestString("irr::core::iszero(s32 (,default)) failed.\n");
 
120
                return false;
 
121
        }
 
122
 
 
123
        if(!irr::core::iszero(1, 1))
 
124
        {
 
125
                logTestString("irr::core::iszero(s32, s32) failed.\n");
 
126
                return false;
 
127
        }
 
128
 
 
129
 
 
130
        return true;
 
131
}
 
132