Main Content

matlab.unittest.constraints.EveryCellOf 클래스

네임스페이스: matlab.unittest.constraints

셀형 배열의 모든 요소가 제약 조건을 충족하는지 테스트

설명

matlab.unittest.constraints.EveryCellOf 클래스는 실제 값의 프록시를 제공하므로 셀형 배열의 모든 요소가 주어진 제약 조건을 충족하는지 테스트할 수 있습니다. 테스트에 프록시를 포함시키면 테스트 프레임워크가 요소별로 제약 조건을 검사합니다.

이 클래스의 인스턴스를 가설 검정 메서드인 assertThat, assumeThat, fatalAssertThat 또는 verifyThat을 사용하여 수행되는 테스트에서 사용할 수 있습니다. 이 클래스는 제공된 실제 값을 수정하지 않습니다. 단지, 제약 조건 분석을 수행하는 래퍼 역할만 합니다.

생성

설명

예제

p = matlab.unittest.constraints.EveryCellOf(actualValue)는 지정된 셀형 배열의 모든 요소가 제약 조건을 충족하는지 테스트하는 프록시를 생성하고 ActualValue 속성을 설정합니다. 이 프록시를 사용하여 제약 조건과 비교 테스트할 때 actualValue의 모든 요소가 제약 조건을 충족하면 테스트가 통과합니다.

속성

모두 확장

제약 조건과 비교 테스트할 실제 값으로, 임의의 데이터형 값으로 반환됩니다. 프록시를 생성할 때 이 속성의 값을 지정합니다. 임의의 데이터형 값으로 지정할 수 있지만, 실제 값이 비어 있지 않은 셀형 배열이 아니면 테스트가 실패합니다.

특성:

GetAccess
public
SetAccess
private

예제

모두 축소

EveryCellOf 클래스를 사용하여 셀형 배열의 모든 요소가 제약 조건을 충족하는지 테스트합니다.

먼저 이 예제에서 사용되는 클래스를 가져옵니다.

import matlab.unittest.TestCase
import matlab.unittest.constraints.EveryCellOf
import matlab.unittest.constraints.HasElementCount
import matlab.unittest.constraints.ContainsSubstring
import matlab.unittest.constraints.IsEmpty
import matlab.unittest.constraints.IsReal

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

testCase = TestCase.forInteractiveUse;

{{'hello','world'},{11,38}}의 모든 셀에 두 개의 요소가 포함되어 있는지 확인합니다.

testCase.verifyThat(EveryCellOf({{'hello','world'},{11,38}}), ...
    HasElementCount(2))
Verification passed.

셀형 배열 {'Rain','Main','Plain'}의 모든 요소에 부분문자열 "ain"이 포함되어 있는지 확인합니다.

testCase.verifyThat(EveryCellOf({'Rain','Main','Plain'}), ...
    ContainsSubstring("ain"))
Verification passed.

셀형 배열 {struct([]),''}의 모든 요소가 비어 있는지 테스트합니다. 테스트가 통과합니다.

testCase.verifyThat(EveryCellOf({struct([]),''}),IsEmpty)
Verification passed.

셀형 배열 {0,4i}의 모든 요소가 복소수인지 테스트합니다. 요소 중 하나가 실수 값이므로 테스트가 실패합니다.

testCase.verifyThat(EveryCellOf({0,4i}),~IsReal)
Verification failed.
    ---------------------
    Framework Diagnostic:
    ---------------------
    At least one cell failed.
    
    Failing indices:
        1
    The first failing cell failed because:
    --> Negated IsReal failed.
        --> The value must not be real.
        
        Actual Value:
             0
    
    Actual Value Cell Array:
      1×2 cell array
    
        {[0]}    {[0.000000000000000 + 4.000000000000000i]}

버전 내역

R2013a에 개발됨