Main Content

matlab.unittest.constraints.IsEmpty 클래스

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

값이 비어 있는지 테스트

설명

matlab.unittest.constraints.IsEmpty 클래스는 값이 비어 있는지 테스트하는 제약 조건을 제공합니다.

생성

설명

예제

c = matlab.unittest.constraints.IsEmpty는 값이 비어 있는지 테스트하는 제약 조건을 만듭니다. 이 제약 조건은 배열이 길이가 0인 차원을 적어도 하나 가지는 경우 충족됩니다.

예제

모두 축소

IsEmpty 제약 조건을 사용하여 값을 테스트합니다.

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

import matlab.unittest.TestCase
import matlab.unittest.TestSuite
import matlab.unittest.constraints.IsEmpty

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

testCase = TestCase.forInteractiveUse;

빈 문자형 벡터가 IsEmpty 제약 조건을 충족하는지 확인합니다.

testCase.verifyThat('',IsEmpty)
Verification passed.

길이가 0인 차원을 갖는 배열이 비어 있는지 확인합니다. 테스트가 통과합니다.

testCase.verifyThat(rand(2,5,0,3),IsEmpty)
Verification passed.

벡터 [1 1 2 3 5 8 13]이 비어 있지 않은지 확인합니다. 테스트가 통과합니다.

testCase.verifyThat([1 1 2 3 5 8 13],~IsEmpty)
Verification passed.

빈 숫자형 배열로 구성된 셀형 배열을 테스트합니다. 셀형 배열이 비어 있지 않기 때문에 테스트가 실패합니다.

testCase.verifyThat({[],[],[]},IsEmpty)
Verification failed.
    ---------------------
    Framework Diagnostic:
    ---------------------
    IsEmpty failed.
    --> The value must be empty.
    --> The value has a size of [1  3].
    
    Actual Value:
      1×3 cell array
    
        {0×0 double}    {0×0 double}    {0×0 double}

빈 테스트 스위트를 테스트합니다. 테스트가 통과합니다.

testCase.verifyThat(TestSuite.empty,IsEmpty)
Verification passed.

버전 내역

R2013a에 개발됨