Main Content

matlab.unittest.constraints.AnyCellOf 클래스

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

셀형 배열의 요소 중 하나라도 제약 조건을 충족하는지 테스트

설명

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

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

생성

설명

예제

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

속성

모두 확장

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

특성:

GetAccess
public
SetAccess
private

예제

모두 축소

AnyCellOf 클래스를 사용하여 셀형 배열의 요소 중 적어도 하나가 제약 조건을 충족하는지 테스트합니다.

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

import matlab.unittest.TestCase
import matlab.unittest.constraints.AnyCellOf
import matlab.unittest.constraints.HasElementCount
import matlab.unittest.constraints.IsFinite
import matlab.unittest.constraints.IsLessThan
import matlab.unittest.constraints.Matches
import matlab.unittest.constraints.IsEmpty

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

testCase = TestCase.forInteractiveUse;

{42,[11 38],1:5}의 셀 중 적어도 하나가 5개의 요소를 포함하는지 확인합니다.

testCase.verifyThat(AnyCellOf({42,[11 38],1:5}),HasElementCount(5))
Verification passed.

셀형 배열 {NaN,Inf,5}의 요소 중 적어도 하나가 유한한지 확인합니다.

testCase.verifyThat(AnyCellOf({NaN,Inf,5}),IsFinite)
Verification passed.

셀형 배열 {-1,5}의 요소 중 적어도 하나가 음수인지 확인합니다.

testCase.verifyThat(AnyCellOf({-1,5}),IsLessThan(0))
Verification passed.

셀형 배열 {'Coffee','Tea','Water'}의 요소 중 적어도 하나가 대/소문자에 관계없이 "tea"와 일치하는지 테스트합니다. 테스트가 통과합니다.

testCase.verifyThat(AnyCellOf({'Coffee','Tea','Water'}), ...
    Matches("tea","IgnoringCase",true))
Verification passed.

셀형 배열 {struct([]),''}의 요소 중 적어도 하나가 비어 있지 않은지 테스트합니다. 두 요소가 모두 비어 있으므로 테스트가 실패합니다.

testCase.verifyThat(AnyCellOf({struct([]),''}),~IsEmpty)
Verification failed.
    ---------------------
    Framework Diagnostic:
    ---------------------
    All cells failed. The first cell failed because:
    --> Negated IsEmpty failed.
        --> The value must not be empty.
        --> The value has a size of [0  0].
        
        Actual Value:
          0×0 empty struct array with no fields.
    
    Actual Value Cell Array:
      1×2 cell array
    
        {0×0 struct}    {0×0 char}

버전 내역

R2013a에 개발됨