このページの内容は最新ではありません。最新版の英語を参照するには、ここをクリックします。
matlab.unittest.constraints.HasUniqueElements クラス
名前空間: matlab.unittest.constraints
スーパークラス: matlab.unittest.constraints.BooleanConstraint
セットに一意の要素が含まれているかどうかのテスト
構築
HasUniqueElements
は、一意の要素を含むセットを指定する制約を作成します。この制約は、実際の値のセットに一意の要素が含まれない場合に検定エラーを生成します。numel(unique(actualSet))
が numel(actualSet)
に等しい場合、制約は実際の値セットが一意の要素をもつと見なします。
コピーのセマンティクス
値。値クラスがコピー操作に与える影響については、オブジェクトのコピーを参照してください。
例
一意の要素のテスト
対話型テスト用にテスト ケースを作成します。
import matlab.unittest.TestCase; import matlab.unittest.constraints.HasUniqueElements; testCase = TestCase.forInteractiveUse;
'abc'
と 'Mississippi'
が一意の要素をもつかどうかをテストします。
testCase.verifyThat('abc', HasUniqueElements);
Interactive verification passed.
testCase.verifyThat('Mississippi', HasUniqueElements);
Interactive verification failed. --------------------- Framework Diagnostic: --------------------- HasUniqueElements failed. --> The value contains 3 nonunique element(s): --> Nonunique element found at indices [2 5 8 11]: i --> Nonunique element found at indices [9 10]: p --> Nonunique element found at indices [3 4 6 7]: s Actual char: Mississippi
double のセットが一意の要素をもつことをアサートします。
testCase.assertThat(magic(6), HasUniqueElements);
Interactive assertion passed.
testCase.assertThat(abs(-3:3), HasUniqueElements);
Interactive assertion failed. --------------------- Framework Diagnostic: --------------------- HasUniqueElements failed. --> The value contains 3 nonunique element(s): --> Nonunique element found at indices [3 5]: 1 --> Nonunique element found at indices [2 6]: 2 --> Nonunique element found at indices [1 7]: 3 Actual double: 3 2 1 0 1 2 3 Assertion failed.
cell 配列が一意の要素をもつことを検証します。
testCase.verifyThat({'abc','123';'abc','345'},HasUniqueElements);
Interactive verification failed. --------------------- Framework Diagnostic: --------------------- HasUniqueElements failed. --> The value contains 1 nonunique element(s): --> Nonunique element found at indices [1 2]: 'abc' Actual cell: 'abc' '123' 'abc' '345'
テーブルが一意の行をもつことをアサートします。
t = table([3;3;5],{'A';'C';'E'},logical([1;0;0])); testCase.assertThat(t,HasUniqueElements);
Interactive assertion passed.
バージョン履歴
R2016a で導入
MATLAB コマンド
次の MATLAB コマンドに対応するリンクがクリックされました。
コマンドを MATLAB コマンド ウィンドウに入力して実行してください。Web ブラウザーは MATLAB コマンドをサポートしていません。
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)