Main Content

matlab.unittest.constraints.IsEmpty クラス

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

値が空であるかどうかをテスト

説明

matlab.unittest.constraints.IsEmpty クラスは、値が空であるかどうかをテストするための制約を提供します。

作成

説明

c = matlab.unittest.constraints.IsEmpty は、値が空であるかどうかをテストするための制約を作成します。この制約は、少なくとも 1 つの次元の長さがゼロと等しい配列で満たされます。

すべて折りたたむ

IsEmpty 制約を使用して、値をテストします。

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

import matlab.unittest.TestCase
import matlab.unittest.TestSuite
import matlab.unittest.constraints.IsEmpty

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

testCase = TestCase.forInteractiveUse;

空の文字ベクトルが IsEmpty 制約を満たすことを検証します。

testCase.verifyThat('',IsEmpty)
Verification passed.

長さがゼロの次元がある配列が空であることを検証します。テストはパスします。

testCase.verifyThat(rand(2,5,0,3),IsEmpty)
Verification passed.

ベクトル [1 1 2 3 5 8 13] が空でないことを検証します。テストはパスします。

testCase.verifyThat([1 1 2 3 5 8 13],~IsEmpty)
Verification passed.

空の数値配列からなる cell 配列をテストします。cell 配列が空でないため、テストは失敗します。

testCase.verifyThat({[],[],[]},IsEmpty)
Verification failed.
    ---------------------
    Framework Diagnostic:
    ---------------------
    IsEmpty failed.
    --> The value must be empty.
    --> The value has a size of [1  3].
    
    Actual Value:
      1×3 cell array
    
        {0×0 double}    {0×0 double}    {0×0 double}

空のテスト スイートをテストします。テストはパスします。

testCase.verifyThat(TestSuite.empty,IsEmpty)
Verification passed.

バージョン履歴

R2013a で導入