Main Content

matlab.unittest.constraints.HasNaN 클래스

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

배열이 NaN 값을 갖는지 테스트

설명

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

생성

설명

예제

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

예제

모두 축소

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

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

import matlab.unittest.TestCase
import matlab.unittest.constraints.HasNaN

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

testCase = TestCase.forInteractiveUse;

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

testCase.verifyThat(NaN,HasNaN)
Verification passed.

벡터 [1 1 2 3 5 8 13]NaN 값을 갖는지 테스트합니다. 테스트가 실패합니다.

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

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

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

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

testCase.verifyThat(3+1i*NaN,HasNaN)
Verification passed.

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

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

버전 내역

R2013a에 개발됨