matlab.unittest.constraints.IsSupersetOf 类
命名空间: matlab.unittest.constraints
超类: matlab.unittest.constraints.BooleanConstraint
测试实际集合是否为预期集合的超集
构造
IsSupersetOf(
创建一个约束,限定实际值集合是预期值集合的超集。若任何实际值集合不是预期值集合的超集,此约束将生成验证失败。如果 expSet
)ismember(expSet,actSet)
包含所有 true 值,并且实际值和预期值满足下列条件之一,即认为实际值集合是预期值集合的超集:
实际值和预期值属于同一类。
实际值是一个对象。
预期值是一个对象。
输入参数
expSet
— 预期值集合与实际值集合比较
取决于测试值
预期值集合与实际值集合比较。输入的类型取决于测试值。
属性
Subset
— 实际值集合的子集
取决于测试值
实际值集合的子集。属性的数据类型取决于测试值。要满足该约束,实际值集合必须是 Subset
的超集。此属性由构造函数通过 expSet
输入参数设置。
复制语义
值。要了解值类如何影响复制操作,请参阅复制对象。
示例
测试实际集合是否为预期集合的超集
创建一个供交互测试的测试用例。
import matlab.unittest.TestCase; import matlab.unittest.constraints.IsSupersetOf; testCase = TestCase.forInteractiveUse;
验证实际元胞数组是否为预期集合的子集。
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'
断言双精度值集合是预期集合的子集。
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 中推出
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)