Tests: bcmod version 34

Function:
Description: Get the modulus of the left_operand using modulus.
Version:
Status: obsolete
Date: 2012-03-16 20:10
Summary: Adding tests for zero modulus and modulus rounding.
Programmer: jj5
Tests
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
function bcmod_tests() {

  // API reference: http://docs.jquery.com/QUnit
  module( "bcmod" );

  test( "bcmod", function() {

    // some basic modulus cases:
    equal( bcmod( '4', '2' ), '0' );
    equal( bcmod( '2', '4' ), '2' );
    equal( bcmod( '123456', '1000' ), '456' );

    // fractional modulus is not supported:
    notEqual( bcmod( '10', '1.3' ), '0.9' );

    // testing negative left_operand:
    equal( bcmod( '-11', '2' ), '-1' );

    // testing zero modulus and modulus rounding:
    equal( bcmod( '3', '0' ), null );
    equal( bcmod( '3', '0.0' ), null );
    equal( bcmod( '3', '0.1' ), null );
    equal( bcmod( '3', '0.5' ), '0' );
    equal( bcmod( '3', '0.9' ), '0' );
    equal( bcmod( '3', '1' ), '0' );
    equal( bcmod( '3', '1.0' ), '0' );
    equal( bcmod( '3', '1.1' ), '0' );
    equal( bcmod( '3', '1.5' ), '1' );
    equal( bcmod( '3', '1.9' ), '1' );
    equal( bcmod( '3', '2' ), '1' );
    equal( bcmod( '3', '2.0' ), '1' );
    equal( bcmod( '3', '2.1' ), '1' );
    equal( bcmod( '3', '2.5' ), '0' );
    equal( bcmod( '3', '2.9' ), '0' );
    equal( bcmod( '3', '3' ), '0' );

    ok( true, "all pass" );

  } );

}
[top]

Comments

There are no comments yet, be the first!

Please Login or Register to post comments.