Re: Test cases for round()

Ben Barrowes <[email protected]>
Newsgroups gmane.comp.gnu.octave.maintainers
Message-ID <[email protected]>
   On Thursday, August 27, 2020, 12:07:42 PM EDT, Ricardo <[email protected]> wrote:  
 
 Hello.
I want to improve round function to support extra parameters.

Can someone run the appended file in Matlab and send me the output
assert_round.m file?

Thank you,
Ricardo.



Attached are the contents of the resulting "assert_round.m"
assert_round.m (text/plain, 17.8 KB)
%!assert (round ([-5090.543           -100             -3              0        1.11111       8.888888], -10, "decimals"), [0  0  0  0  0  0]);\n%!assert (round ([0-13i                       0-7i                       0+0i                       0+1i                       0+2i                      0+10i], -10, "decimals"), [0  0  0  0  0  0]);\n%!assert (round ([-5090.543-13i                        -100-7i                          -3+0i                           0+1i                     1.11111+2i                   8.888888+10i], -10, "decimals"), [0  0  0  0  0  0]);\n%!assert (round ([-5090.543           -100             -3              0        1.11111      8.8888884], -10, "decimals"), [0  0  0  0  0  0]);\n%!assert (round ([0-13i     0-7i     0+0i     0+1i     0+2i    0+10i], -10, "decimals"), [0  0  0  0  0  0]);\n%!assert (round ([-5090.543-13i                        -100-7i                          -3+0i                           0+1i                     1.11111+2i                  8.8888884+10i], -10, "decimals"), [0  0  0  0  0  0]);\n%!assert (round ([0-5090.543i                         0-100i                           0-3i                           0+0i                     0+1.11111i                    0+8.888888i], -10, "decimals"), [0  0  0  0  0  0]);\n%!assert (round ([13            7            0           -1           -2          -10], -10, "decimals"), [0  0  0  0  0  0]);\n%!assert (round ([-5090.543           -100             -3              0        1.11111       8.888888], -5, "decimals"), [0  0  0  0  0  0]);\n%!assert (round ([0-13i                       0-7i                       0+0i                       0+1i                       0+2i                      0+10i], -5, "decimals"), [0  0  0  0  0  0]);\n%!assert (round ([-5090.543-13i                        -100-7i                          -3+0i                           0+1i                     1.11111+2i                   8.888888+10i], -5, "decimals"), [0  0  0  0  0  0]);\n%!assert (round ([-5090.543           -100             -3              0        1.11111      8.8888884], -5, "decimals"), [0  0  0  0  0  0]);\n%!assert (round ([0-13i     0-7i     0+0i     0+1i     0+2i    0+10i], -5, "decimals"), [0  0  0  0  0  0]);\n%!assert (round ([-5090.543-13i                        -100-7i                          -3+0i                           0+1i                     1.11111+2i                  8.8888884+10i], -5, "decimals"), [0  0  0  0  0  0]);\n%!assert (round ([0-5090.543i                         0-100i                           0-3i                           0+0i                     0+1.11111i                    0+8.888888i], -5, "decimals"), [0  0  0  0  0  0]);\n%!assert (round ([13            7            0           -1           -2          -10], -5, "decimals"), [0  0  0  0  0  0]);\n%!assert (round ([-5090.543           -100             -3              0        1.11111       8.888888], -1, "decimals"), [-5090  -100     0     0     0    10]);\n%!assert (round ([0-13i                       0-7i                       0+0i                       0+1i                       0+2i                      0+10i], -1, "decimals"), [0-10i    0-10i     0+0i     0+0i     0+0i    0+10i]);\n%!assert (round ([-5090.543-13i                        -100-7i                          -3+0i                           0+1i                     1.11111+2i                   8.888888+10i], -1, "decimals"), [-5090-10i     -100-10i         0+0i         0+0i         0+0i       10+10i]);\n%!assert (round ([-5090.543           -100             -3              0        1.11111      8.8888884], -1, "decimals"), [-5090  -100     0     0     0    10]);\n%!assert (round ([0-13i     0-7i     0+0i     0+1i     0+2i    0+10i], -1, "decimals"), [0-10i    0-10i     0+0i     0+0i     0+0i    0+10i]);\n%!assert (round ([-5090.543-13i                        -100-7i                          -3+0i                           0+1i                     1.11111+2i                  8.8888884+10i], -1, "decimals"), [-5090-10i     -100-10i         0+0i         0+0i         0+0i       10+10i]);\n%!assert (round ([0-5090.543i                         0-100i                           0-3i                           0+0i                     0+1.11111i                    0+8.888888i], -1, "decimals"), [0-5090i       0-100i         0+0i         0+0i         0+0i        0+10i]);\n%!assert (round ([13            7            0           -1           -2          -10], -1, "decimals"), [10  10   0   0   0 -10]);\n%!assert (round ([-5090.543           -100             -3              0        1.11111       8.888888], 0, "decimals"), [-5091  -100    -3     0     1     9]);\n%!assert (round ([0-13i                       0-7i                       0+0i                       0+1i                       0+2i                      0+10i], 0, "decimals"), [0-13i     0-7i     0+0i     0+1i     0+2i    0+10i]);\n%!assert (round ([-5090.543-13i                        -100-7i                          -3+0i                           0+1i                     1.11111+2i                   8.888888+10i], 0, "decimals"), [-5091-13i      -100-7i        -3+0i         0+1i         1+2i        9+10i]);\n%!assert (round ([-5090.543           -100             -3              0        1.11111      8.8888884], 0, "decimals"), [-5091  -100    -3     0     1     9]);\n%!assert (round ([0-13i     0-7i     0+0i     0+1i     0+2i    0+10i], 0, "decimals"), [0-13i     0-7i     0+0i     0+1i     0+2i    0+10i]);\n%!assert (round ([-5090.543-13i                        -100-7i                          -3+0i                           0+1i                     1.11111+2i                  8.8888884+10i], 0, "decimals"), [-5091-13i      -100-7i        -3+0i         0+1i         1+2i        9+10i]);\n%!assert (round ([0-5090.543i                         0-100i                           0-3i                           0+0i                     0+1.11111i                    0+8.888888i], 0, "decimals"), [0-5091i       0-100i         0-3i         0+0i         0+1i         0+9i]);\n%!assert (round ([13            7            0           -1           -2          -10], 0, "decimals"), [13   7   0  -1  -2 -10]);\n%!assert (round ([-5090.543           -100             -3              0        1.11111       8.888888], 1, "decimals"), [-5090.5           -100             -3              0            1.1            8.9]);\n%!assert (round ([0-13i                       0-7i                       0+0i                       0+1i                       0+2i                      0+10i], 1, "decimals"), [0-13i     0-7i     0+0i     0+1i     0+2i    0+10i]);\n%!assert (round ([-5090.543-13i                        -100-7i                          -3+0i                           0+1i                     1.11111+2i                   8.888888+10i], 1, "decimals"), [-5090.5-13i                        -100-7i                          -3+0i                           0+1i                         1.1+2i                        8.9+10i]);\n%!assert (round ([-5090.543           -100             -3              0        1.11111      8.8888884], 1, "decimals"), [-5090.5           -100             -3              0            1.1      8.8999996]);\n%!assert (round ([0-13i     0-7i     0+0i     0+1i     0+2i    0+10i], 1, "decimals"), [0-13i     0-7i     0+0i     0+1i     0+2i    0+10i]);\n%!assert (round ([-5090.543-13i                        -100-7i                          -3+0i                           0+1i                     1.11111+2i                  8.8888884+10i], 1, "decimals"), [-5090.5-13i                        -100-7i                          -3+0i                           0+1i                         1.1+2i                  8.8999996+10i]);\n%!assert (round ([0-5090.543i                         0-100i                           0-3i                           0+0i                     0+1.11111i                    0+8.888888i], 1, "decimals"), [0-5090.5i                         0-100i                           0-3i                           0+0i                         0+1.1i                         0+8.9i]);\n%!assert (round ([13            7            0           -1           -2          -10], 1, "decimals"), [13   7   0  -1  -2 -10]);\n%!assert (round ([-5090.543           -100             -3              0        1.11111       8.888888], 2, "decimals"), [-5090.54           -100             -3              0           1.11           8.89]);\n%!assert (round ([0-13i                       0-7i                       0+0i                       0+1i                       0+2i                      0+10i], 2, "decimals"), [0-13i     0-7i     0+0i     0+1i     0+2i    0+10i]);\n%!assert (round ([-5090.543-13i                        -100-7i                          -3+0i                           0+1i                     1.11111+2i                   8.888888+10i], 2, "decimals"), [-5090.54-13i                        -100-7i                          -3+0i                           0+1i                        1.11+2i                       8.89+10i]);\n%!assert (round ([-5090.543           -100             -3              0        1.11111      8.8888884], 2, "decimals"), [-5090.54           -100             -3              0           1.11      8.8900003]);\n%!assert (round ([0-13i     0-7i     0+0i     0+1i     0+2i    0+10i], 2, "decimals"), [0-13i     0-7i     0+0i     0+1i     0+2i    0+10i]);\n%!assert (round ([-5090.543-13i                        -100-7i                          -3+0i                           0+1i                     1.11111+2i                  8.8888884+10i], 2, "decimals"), [-5090.54-13i                        -100-7i                          -3+0i                           0+1i                        1.11+2i                  8.8900003+10i]);\n%!assert (round ([0-5090.543i                         0-100i                           0-3i                           0+0i                     0+1.11111i                    0+8.888888i], 2, "decimals"), [0-5090.54i                         0-100i                           0-3i                           0+0i                        0+1.11i                        0+8.89i]);\n%!assert (round ([13            7            0           -1           -2          -10], 2, "decimals"), [13   7   0  -1  -2 -10]);\n%!assert (round ([-5090.543           -100             -3              0        1.11111       8.888888], 7, "decimals"), [-5090.543           -100             -3              0        1.11111       8.888888]);\n%!assert (round ([0-13i                       0-7i                       0+0i                       0+1i                       0+2i                      0+10i], 7, "decimals"), [0-13i     0-7i     0+0i     0+1i     0+2i    0+10i]);\n%!assert (round ([-5090.543-13i                        -100-7i                          -3+0i                           0+1i                     1.11111+2i                   8.888888+10i], 7, "decimals"), [-5090.543-13i                        -100-7i                          -3+0i                           0+1i                     1.11111+2i                   8.888888+10i]);\n%!assert (round ([-5090.543           -100             -3              0        1.11111      8.8888884], 7, "decimals"), [-5090.543           -100             -3              0        1.11111      8.8888884]);\n%!assert (round ([0-13i     0-7i     0+0i     0+1i     0+2i    0+10i], 7, "decimals"), [0-13i     0-7i     0+0i     0+1i     0+2i    0+10i]);\n%!assert (round ([-5090.543-13i                        -100-7i                          -3+0i                           0+1i                     1.11111+2i                  8.8888884+10i], 7, "decimals"), [-5090.543-13i                        -100-7i                          -3+0i                           0+1i                     1.11111+2i                  8.8888884+10i]);\n%!assert (round ([0-5090.543i                         0-100i                           0-3i                           0+0i                     0+1.11111i                    0+8.888888i], 7, "decimals"), [0-5090.543i                         0-100i                           0-3i                           0+0i                     0+1.11111i                    0+8.888888i]);\n%!assert (round ([13            7            0           -1           -2          -10], 7, "decimals"), [13   7   0  -1  -2 -10]);\n%!assert (round ([-5090.543           -100             -3              0        1.11111       8.888888], 1, "significant"), [-5000  -100    -3     0     1     9]);\n%!assert (round ([0-13i                       0-7i                       0+0i                       0+1i                       0+2i                      0+10i], 1, "significant"), [0-10i     0-7i     0+0i     0+1i     0+2i    0+10i]);\n%!assert (round ([-5090.543-13i                        -100-7i                          -3+0i                           0+1i                     1.11111+2i                   8.888888+10i], 1, "significant"), [-5000-10i      -100-7i        -3+0i         0+1i         1+2i        9+10i]);\n%!assert (round ([-5090.543           -100             -3              0        1.11111      8.8888884], 1, "significant"), [-5000  -100    -3     0     1     9]);\n%!assert (round ([0-13i     0-7i     0+0i     0+1i     0+2i    0+10i], 1, "significant"), [0-10i     0-7i     0+0i     0+1i     0+2i    0+10i]);\n%!assert (round ([-5090.543-13i                        -100-7i                          -3+0i                           0+1i                     1.11111+2i                  8.8888884+10i], 1, "significant"), [-5000-10i      -100-7i        -3+0i         0+1i         1+2i        9+10i]);\n%!assert (round ([0-5090.543i                         0-100i                           0-3i                           0+0i                     0+1.11111i                    0+8.888888i], 1, "significant"), [0-5000i       0-100i         0-3i         0+0i         0+1i         0+9i]);\n%!assert (round ([13            7            0           -1           -2          -10], 1, "significant"), [10   7   0  -1  -2 -10]);\n%!assert (round ([-5090.543           -100             -3              0        1.11111       8.888888], 2, "significant"), [-5100           -100             -3              0            1.1            8.9]);\n%!assert (round ([0-13i                       0-7i                       0+0i                       0+1i                       0+2i                      0+10i], 2, "significant"), [0-13i     0-7i     0+0i     0+1i     0+2i    0+10i]);\n%!assert (round ([-5090.543-13i                        -100-7i                          -3+0i                           0+1i                     1.11111+2i                   8.888888+10i], 2, "significant"), [-5100-13i                        -100-7i                          -3+0i                           0+1i                         1.1+2i                        8.9+10i]);\n%!assert (round ([-5090.543           -100             -3              0        1.11111      8.8888884], 2, "significant"), [-5100           -100             -3              0            1.1      8.8999996]);\n%!assert (round ([0-13i     0-7i     0+0i     0+1i     0+2i    0+10i], 2, "significant"), [0-13i     0-7i     0+0i     0+1i     0+2i    0+10i]);\n%!assert (round ([-5090.543-13i                        -100-7i                          -3+0i                           0+1i                     1.11111+2i                  8.8888884+10i], 2, "significant"), [-5100-13i                        -100-7i                          -3+0i                           0+1i                         1.1+2i                  8.8999996+10i]);\n%!assert (round ([0-5090.543i                         0-100i                           0-3i                           0+0i                     0+1.11111i                    0+8.888888i], 2, "significant"), [0-5100i                         0-100i                           0-3i                           0+0i                         0+1.1i                         0+8.9i]);\n%!assert (round ([13            7            0           -1           -2          -10], 2, "significant"), [13   7   0  -1  -2 -10]);\n%!assert (round ([-5090.543           -100             -3              0        1.11111       8.888888], 7, "significant"), [-5090.543           -100             -3              0        1.11111       8.888888]);\n%!assert (round ([0-13i                       0-7i                       0+0i                       0+1i                       0+2i                      0+10i], 7, "significant"), [0-13i     0-7i     0+0i     0+1i     0+2i    0+10i]);\n%!assert (round ([-5090.543-13i                        -100-7i                          -3+0i                           0+1i                     1.11111+2i                   8.888888+10i], 7, "significant"), [-5090.543-13i                        -100-7i                          -3+0i                           0+1i                     1.11111+2i                   8.888888+10i]);\n%!assert (round ([-5090.543           -100             -3              0        1.11111      8.8888884], 7, "significant"), [-5090.543           -100             -3              0        1.11111      8.8888884]);\n%!assert (round ([0-13i     0-7i     0+0i     0+1i     0+2i    0+10i], 7, "significant"), [0-13i     0-7i     0+0i     0+1i     0+2i    0+10i]);\n%!assert (round ([-5090.543-13i                        -100-7i                          -3+0i                           0+1i                     1.11111+2i                  8.8888884+10i], 7, "significant"), [-5090.543-13i                        -100-7i                          -3+0i                           0+1i                     1.11111+2i                  8.8888884+10i]);\n%!assert (round ([0-5090.543i                         0-100i                           0-3i                           0+0i                     0+1.11111i                    0+8.888888i], 7, "significant"), [0-5090.543i                         0-100i                           0-3i                           0+0i                     0+1.11111i                    0+8.888888i]);\n%!assert (round ([13            7            0           -1           -2          -10], 7, "significant"), [13   7   0  -1  -2 -10]);\n
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.