Main Content

このページの内容は最新ではありません。最新版の英語を参照するには、ここをクリックします。

matlab.unittest.constraints.IsSupersetOf クラス

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

実際のセットが期待されるセットの上位集合であるかどうかのテスト

構築

IsSupersetOf(expSet) は、実際の値セットが期待される値セットのスーパーセットであることを指定する制約を作成します。この制約は、実際の値セットが期待される値セットのスーパーセットではない場合に検定エラーを生成します。ismember(expSet,actSet) の値がすべて true であり、かつ実際の値と期待される値が次のいずれかの条件を満たす場合、実際の値セットは期待される値セットのスーパーセットであると見なされます。

  • 実際の値と期待される値が同じクラスである。

  • 実際の値がオブジェクトである。

  • 期待される値がオブジェクトである。

入力引数

すべて展開する

実際の値セットと比較する、期待される値セット。入力のタイプは、テスト値によって決まります。

プロパティ

すべて展開する

実際の値セットのサブセット。プロパティのデータ型はテスト値によって異なります。制約を満たすには、実際の値セットが Subset のスーパーセットでなければなりません。このプロパティは、入力引数 expSet を介してコンストラクターで設定します。

コピーのセマンティクス

値。値クラスがコピー操作に与える影響については、オブジェクトのコピーを参照してください。

すべて折りたたむ

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

import matlab.unittest.TestCase;
import matlab.unittest.constraints.IsSupersetOf;

testCase = TestCase.forInteractiveUse;

実際の cell 配列が期待されるセットのサブセットであることを検証します。

testCase.verifyThat({'a','b','c'}, IsSupersetOf({'c';'b'}));
Interactive verification passed.
testCase.verifyThat({'a','b','c'}, IsSupersetOf({'a','d'}));
Interactive verification failed.

---------------------
Framework Diagnostic:
---------------------
IsSupersetOf failed.
--> The expected subset contains 1 element(s) not found in the actual value:
    --> Element at index 2 not found in the actual value:
                'd'

Actual Value (cell):
        'a'    'b'    'c'
Expected Subset (cell):
        'a'    'd'

double のセットが期待されるセットのサブセットであることをアサートします。

testCase.assertThat(magic(21), IsSupersetOf([25;209]));
Interactive assertion passed.
testCase.assertThat(25:33, IsSupersetOf(30:40));
Interactive assertion failed.

---------------------
Framework Diagnostic:
---------------------
IsSupersetOf failed.
--> The expected subset contains elements not found in the actual value (First 5 of 7):
    --> Element at index 5 not found in the actual value:
                34
    --> Element at index 6 not found in the actual value:
                35
    --> Element at index 7 not found in the actual value:
                36
    --> Element at index 8 not found in the actual value:
                37
    --> Element at index 9 not found in the actual value:
                38

Actual Value (double):
        25    26    27    28    29    30    31    32    33
Expected Subset (double):
        30    31    32    33    34    35    36    37    38    39    40
Assertion failed.

テーブルの行が期待されるテーブルのサブセットであることを検証します。

actT = table([1:2:5]',{'A';'C';'E'},logical([1;0;0]));
expT = table([3,1]',{'C';'A'},logical([0;1]));
testCase.verifyThat(actT, IsSupersetOf(expT));
Interactive verification passed.

実際のセットと期待されるセットの型が異なる場合は制約 IsSubsetOf が満たされないことをテストします。

testCase.assumeThat(single(0:5), IsSupersetOf(1:3));
Interactive assumption failed.

---------------------
Framework Diagnostic:
---------------------
IsSupersetOf failed.
--> Classes do not match.
    
    Actual Class:
        single
    Expected Class:
        double

Actual Value (single):
         0     1     2     3     4     5
Expected Subset (double):
         1     2     3
Assumption failed.

バージョン履歴

R2016a で導入