Main Content

이 번역 페이지는 최신 내용을 담고 있지 않습니다. 최신 내용을 영문으로 보려면 여기를 클릭하십시오.

matlab.unittest.constraints.IsSubsetOf 클래스

네임스페이스: matlab.unittest.constraints
슈퍼클래스: matlab.unittest.constraints.BooleanConstraint

실제 집합이 예상 집합의 일부인지 테스트

생성

IsSubsetOf(expSet)는 실제 값 집합이 예상 값 집합의 일부인지 규정하는 제약 조건을 만듭니다. 이 제약 조건은 예상 값 집합의 일부가 아닌 실제 값 집합에 대해 가설 검정(Qualification) 실패를 생성합니다. ismember(actSet,expSet)에 포함된 값이 모두 true이고 실제 값과 예상 값이 다음 조건 중 하나를 충족하는 경우 실제 값 집합이 예상 값 집합의 일부로 간주됩니다.

  • 실제 값과 예상 값이 동일한 클래스입니다.

  • 실제 값이 객체입니다.

  • 예상 값이 객체입니다.

입력 인수

모두 확장

실제 값 집합과 비교할 예상 값 집합입니다. 입력값의 유형은 테스트 값에 따라 달라집니다.

속성

모두 확장

실제 값 집합의 상위 집합입니다. 속성의 데이터형은 테스트 값에 따라 달라집니다. 제약 조건을 충족하기 위해 실제 값의 집합은 Superset의 부분 집합이어야 합니다. expSet 입력 인수를 통해 생성자에 이 속성을 설정합니다.

복사 의미 체계

값입니다. 값 클래스가 복사 작업에 미치는 영향에 대한 내용은 객체 복사 항목을 참조하십시오.

예제

모두 축소

대화형 방식 테스트를 위한 테스트 케이스를 생성합니다.

import matlab.unittest.TestCase;
import matlab.unittest.constraints.IsSubsetOf;

testCase = TestCase.forInteractiveUse;

실제 셀형 배열이 예상 집합의 일부인지 확인합니다.

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

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

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

double형 집합이 예상 집합의 일부인지 어설션합니다.

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

---------------------
Framework Diagnostic:
---------------------
IsSubsetOf failed.
--> The actual value contains 5 element(s) not found in the expected superset:
    --> Element at index 1 not found in the expected superset:
                25
    --> Element at index 2 not found in the expected superset:
                26
    --> Element at index 3 not found in the expected superset:
                27
    --> Element at index 4 not found in the expected superset:
                28
    --> Element at index 5 not found in the expected superset:
                29

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

테이블의 행이 예상 테이블의 일부인지 확인합니다.

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

실제 집합과 예상 집합의 유형이 다른 경우 IsSubsetOf 제약 조건이 충족되지 않는지 여부를 테스트합니다.

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

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

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

버전 내역

R2016a에 개발됨