Main Content

matlab.unittest.constraints.HasInf 클래스

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

배열이 무한대 값을 갖는지 테스트

설명

matlab.unittest.constraints.HasInf 클래스는 배열이 무한대 값을 갖는지 테스트하는 제약 조건을 제공합니다.

생성

설명

예제

c = matlab.unittest.constraints.HasInf는 배열이 무한대 값을 갖는지 테스트하는 제약 조건을 만듭니다. 이 제약 조건은 숫자형 배열이 하나 이상의 무한대 값을 가지는 경우 충족됩니다.

예제

모두 축소

HasInf 제약 조건을 사용하여 숫자형 배열을 테스트합니다.

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

import matlab.unittest.TestCase
import matlab.unittest.constraints.HasInf

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

testCase = TestCase.forInteractiveUse;

InfHasInf 제약 조건을 충족하는지 확인합니다.

testCase.verifyThat(Inf,HasInf)
Verification passed.

벡터 [1 1 2 3 5 8 13]이 무한대 값을 갖는지 테스트합니다. 모든 벡터 요소가 유한하므로 테스트가 실패합니다.

testCase.verifyThat([1 1 2 3 5 8 13],HasInf)
Verification failed.
    ---------------------
    Framework Diagnostic:
    ---------------------
    HasInf failed.
    --> At least one element must be Inf or -Inf.
    
    Actual Value:
         1     1     2     3     5     8    13

[-Inf 5 NaN]을 테스트합니다. 이 벡터는 무한대 값을 포함하므로 테스트가 통과합니다.

testCase.verifyThat([-Inf 5 NaN],HasInf)
Verification passed.

허수부가 무한대인 복소수가 제약 조건을 충족하는지 테스트합니다. 테스트가 통과합니다.

testCase.verifyThat(3+1i/0,HasInf)
Verification passed.

행렬 [1 NaN; -Inf 3]이 무한대 값을 갖지 않는지 테스트합니다. 테스트가 실패합니다.

testCase.verifyThat([1 NaN; -Inf 3],~HasInf)
Verification failed.
    ---------------------
    Framework Diagnostic:
    ---------------------
    Negated HasInf failed.
    --> All elements must be finite or NaN.
        Failing indices:
            2
    
    Actual Value:
         1   NaN
      -Inf     3

버전 내역

R2013a에 개발됨