File: testArithmetic.cpp

package info (click to toggle)
openexr 1.2.2-4.3
  • links: PTS
  • area: main
  • in suites: etch-m68k
  • size: 15,508 kB
  • ctags: 3,410
  • sloc: cpp: 40,009; sh: 8,399; makefile: 345
file content (55 lines) | stat: -rw-r--r-- 891 bytes parent folder | download | duplicates (3)
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
#include <testArithmetic.h>
#include <half.h>
#include <iostream>
#include <assert.h>

using namespace std;


void
testArithmetic ()
{
    cout << "basic arithmetic operations:\n";

    float f1 (1);
    float f2 (2);
    half  h1 (3);
    half  h2 (4);

    cout << "f1 = " << f1 << ", "
	    "f2 = " << f2 << ", "
	    "h1 = " << h1 << ", "
	    "h2 = " << h2 << endl;

    h1 = f1 + f2;
    assert (h1 == 3);

    cout << "h1 = f1 + f2: " << h1 << endl;

    h2 += f1;
    assert (h2 == 5);

    cout << "h2 += f1: " << h2 << endl;

    h2 = h1 + h2;
    assert (h2 == 8);

    cout << "h2 = h1 + h2: " << h2 << endl;

    h2 += h1;
    assert (h2 == 11);

    cout << "h2 += h1: " << h2 << endl;

    h1 = h2;
    assert (h1 == 11);

    cout << "h1 = h2: " << h1 << endl;

    h2 = -h1;
    assert (h2 == -11);

    cout << "h2 = -h1: " << h2 << endl;

    cout << "ok\n\n" << flush;
}