/vqdr/trunk

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/vqdr/trunk

« back to all changes in this revision

Viewing changes to tests/fast_number.vala

  • Committer: Gustav Hartvigsson
  • Date: 2021-05-24 15:49:06 UTC
  • Revision ID: gustav.hartvigsson@gmail.com-20210524154906-z65s7fxnt3zfb8qn
* FastNumber:
  * added ability to get the decimal.
  * added ability to set the decimal.
  * Explicitly define the raw number.
  * Made operatiors public

* OperatorToken:
  * uncommented the operators in init_token ()

* [...]OperatorToken:
  * constructers: protected -> public

* Tests:
  * Added test for FastNumber (need more cases)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
using GLib;
 
2
 
 
3
using VQDR.Common.Utils;
 
4
using VQDR.Common;
 
5
using VQDR.Expression;
 
6
 
 
7
void fast_number_test () {
 
8
  Test.add_func ("/Common/Utils/FastNumber/add", () => {
 
9
    var f1 = new FastNumber (1337);
 
10
    var f2 = new FastNumber (1333);
 
11
    var f3 = f1.add (f2);
 
12
    if (f3.number != 2670) {
 
13
      Test.fail ();
 
14
      Test.message ("The added numbers do not match the expected value");
 
15
    }
 
16
  });
 
17
  Test.add_func ("/Common/Utils/FastNumber/subtract", () => {
 
18
    var f1 = new FastNumber (1337);
 
19
    var f2 = new FastNumber (1333);
 
20
    var f3 = f1.subtract (f2);
 
21
    if (f3.number != 4) {
 
22
      Test.fail ();
 
23
      Test.message ("The subtracted numbers do not match the expected value");
 
24
    }
 
25
  });
 
26
  Test.add_func ("/Common/Utils/FastNumber/divide", () => {
 
27
    var f1 = new FastNumber (1338);
 
28
    var f2 = new FastNumber (4);
 
29
    FastNumber f3 = null;
 
30
    try {
 
31
      f3 = f1.divide (f2);
 
32
    } catch {}
 
33
    Utils.print_ln ("f3.number: %i", f3.number);
 
34
    /*if (f3.number != 669) {
 
35
      Test.fail ();
 
36
      Test.message ("The added numbers do not match the expected value");
 
37
    }*/
 
38
  });
 
39
  Test.add_func ("/Common/Utils/FastNumber/multiply", () => {
 
40
    
 
41
  });
 
42
}