Main Content

matlab.unittest.constraints.IsGreaterThan クラス

名前空間: matlab.unittest.constraints
スーパークラス: matlab.unittest.constraints.Constraint

値が指定値より大きいかどうかをテスト

説明

matlab.unittest.constraints.IsGreaterThan クラスは、数値が別の値より大きいかどうかをテストするための制約を提供します。

作成

説明

c = matlab.unittest.constraints.IsGreaterThan(floorValue) は、値が floorValue より大きいかどうかをテストするための制約を作成し、FloorValue プロパティを設定します。比較する値は同じサイズであるか、互換性のあるサイズでなければなりません。互換性のある配列の詳細については、基本的な演算で互換性のある配列サイズを参照してください。

プロパティ

すべて展開する

比較する値。数値配列として返されます。このプロパティの値は、制約の作成時に指定します。

属性:

GetAccess
public
SetAccess
private

すべて折りたたむ

IsGreaterThan 制約を使用して、数値を比較します。

最初に、この例で使用するクラスをインポートします。

import matlab.unittest.TestCase
import matlab.unittest.constraints.IsGreaterThan

対話型テスト用にテスト ケースを作成します。

testCase = TestCase.forInteractiveUse;

32 より大きいことを検証します。

testCase.verifyThat(3,IsGreaterThan(2))
Verification passed.

行列 [1 2 3; 4 5 6] の各要素が負方向の丸め値 4 より大きいかテストします。テストは失敗します。

testCase.verifyThat([1 2 3; 4 5 6],IsGreaterThan(4))
Verification failed.
    ---------------------
    Framework Diagnostic:
    ---------------------
    IsGreaterThan failed.
    --> Each element must be greater than the minimum value.
        
        Failing Indices:
             1     2     3     5
    
    Actual Value:
         1     2     3
         4     5     6
    Minimum Value (Exclusive):
         4

5 が負方向の丸めベクトル [1 2 3] の各要素より大きいことを検証します。

testCase.verifyThat(5,IsGreaterThan([1 2 3]))
Verification passed.

ベクトル [5 -3 2] の各要素が負方向の丸めベクトル [4 -9 0] の対応する各要素より大きいかどうかをテストします。テストはパスします。

testCase.verifyThat([5 -3 2],IsGreaterThan([4 -9 0]))
Verification passed.

2 つの等価な配列を比較します。テストは失敗します。

testCase.verifyThat(eye(2),IsGreaterThan(eye(2)))
Verification failed.
    ---------------------
    Framework Diagnostic:
    ---------------------
    IsGreaterThan failed.
    --> Each element must be greater than each corresponding element of the minimum value array.
        
        Failing Indices:
             1     2     3     4
    
    Actual Value:
         1     0
         0     1
    Minimum Value (Exclusive):
         1     0
         0     1

バージョン履歴

R2013a で導入