Scilab Home page | Wiki | Bug tracker | Forge | Mailing list archives | ATOMS | File exchange
Please login or create an account
Change language to: English - Français - Português - Русский
Scilabヘルプ >> Development tools > Assert > assert_checkequal

assert_checkequal

計算値と予測値が等しいことを確認する.

呼び出し手順

assert_checkequal ( computed , expected )
flag = assert_checkequal ( computed , expected )
[flag,errmsg] = assert_checkequal ( computed , expected )

パラメータ

computed:

計算結果

expected :

予測された結果

flag :

1行1列の論理値行列で, 計算値が予測値と等しい場合に%t,そうでない場合に%f

errmsg :

1行1列の文字列行列で,エラーメッセージ. flag==%t の場合, errormsg==""となります. flag==%f の場合, errmsgにはエラーメッセージが出力されます.

説明

computedとexpectedが等しい場合,そのまま実行されます.

For complex numbers: まず実部を確認し,それが等しい場合に虚部を確認します.

Matching Nan values are always considered equal.

1/%z and 2/(2*%z) are not equal: For the time being, Scilab does not normalize equivalent rationals.

In containers, matching void elements are considered equal.

比較がcomputedがexpectedに等しくないことを示す場合,

  • errmsg出力変数が使用されない場合,エラーが生成され,

  • errmsg出力変数が使用される場合,エラーは生成されません.

成功するテスト:

assert_checkequal ( %T , %T );
[flag , errmsg] = assert_checkequal ( [%T %F], [%T %F] );
assert_checkequal ( %nan , %nan );
c = complex(1, %nan)
assert_checkequal (c, c);
assert_checkequal ( sparse(%nan) , sparse(%nan) );
assert_checkequal ( 2:$-1, 2:$-1 );

assert_checkequal ( ["abc" "" ascii([9 10 13])],  ["abc" "" ascii([9 10 13])] );
assert_checkequal ( [gdf(), gda()], [gdf(), gda()]);

assert_checkequal ( list() , list() );
assert_checkequal ( list(1,,3), list(1,,3) );
assert_checkequal ( list(1,,list(,4)), list(1,,list(,4)) );
assert_checkequal ( list(%nan,,7) , list(%nan,,7) );

sine = sin;
assert_checkequal ( sin, sine );
cosinus = cosd;
assert_checkequal ( cosinus, cosd );
assert_checkequal( iolib, iolib );

失敗するテスト:

assert_checkequal ( %F , %T );
flag = assert_checkequal ( %F , %T );
// エラーは発生しません :
[flag , errmsg] = assert_checkequal ( %F , %T )

assert_checkequal ( [1 2], [3 4] )
assert_checkequal ( 1 , [2 3] )
assert_checkequal ( 1 , "b" )
assert_checkequal ( "b", "B" )
assert_checkequal ( 1+%s, 1+%z )
assert_checkequal ( 1/%s, 2/(2*%s) )

assert_checkequal (list(2,,7), list(2,%F,8));
assert_checkequal ( [gdf(), gda()], [gdf(), gdf()] );
assert_checkequal ( sind, cosd );
assert_checkequal ( iolib, corelib );
...
--> assert_checkequal (list(2,,7), list(2,%F,8));
at line    22 of function assert_generror   ( SCI\modules\..\assert_generror.sci line 33 )
at line   178 of function assert_checkequal ( SCI\modules\..\assert_checkequal.sci line 190 )

assert_checkequal: Assertion failed: expected(2)= F  while computed(2)= (void)

--> assert_checkequal ( [gdf(), gda()], [gdf(), gdf()] );
at line    22 of function assert_generror   ( SCI\modules\..\assert_generror.sci line 33 )
at line   178 of function assert_checkequal ( SCI\modules\..\assert_checkequal.sci line 190 )

assert_checkequal: Assertion failed: expected(2)= Figure(uid:55)  while computed(2)= Axes(uid:85)

--> assert_checkequal ( sind, cosd );
at line    22 of function assert_generror   ( SCI\modules\..\assert_generror.sci line 33 )
at line    82 of function assert_checkequal ( SCI\modules\..\assert_checkequal.sci line 94 )

assert_checkequal: Assertion failed: expected= cosd()  while computed= sind()

--> assert_checkequal ( iolib, corelib );
at line    22 of function assert_generror   ( SCI\modules\..\assert_generror.sci line 33 )
at line    95 of function assert_checkequal ( SCI\modules\..\assert_checkequal.sci line 107 )

assert_checkequal: Assertion failed: expected= lib@SCI\modules\core\macros\  while ..
                                     computed= lib@SCI\modules\io\macros\

参考文献

"Automated Software Testing for Matlab", Steven Eddins, 2009

履歴

バージョン記述
5.4.0 関数が導入されました
6.1.0
  • The comparison of two implicit lists, Scilab functions, Scilab libraries, built-in functions or graphic handles is now always possible and properly done.
  • In two lists, void and Nan elements are now supported, and matching ones are considered as equal.
  • Nan are now supported in input sparse matrices and are considered as equal.
  • When the test fails while inputs are arrays, the message now indicates the index of the first mismatching element.
6.1.1 Matching NaN or void elements in simple or nested containers are now considered equal.
Scilab Enterprises
Copyright (c) 2011-2017 (Scilab Enterprises)
Copyright (c) 1989-2012 (INRIA)
Copyright (c) 1989-2007 (ENPC)
with contributors
Last updated:
Tue Jul 20 11:20:47 CEST 2021