Main Content

이 번역 페이지는 최신 내용을 담고 있지 않습니다. 최신 내용을 영문으로 보려면 여기를 클릭하십시오.

matlab.unittest.constraints.HasUniqueElements 클래스

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

집합이 고유한 요소를 포함하는지 테스트

생성

HasUniqueElements는 집합이 고유한 요소를 포함하는지를 규정하는 제약 조건을 만듭니다. 이 제약 조건은 고유한 요소를 포함하지 않는 실제 값 집합에 대해 가설 검정(Qualification) 실패를 생성합니다. numel(unique(actualSet))numel(actualSet)와 동일하면 제약 조건에서 실제 값 집합이 고유한 요소를 가진다고 간주합니다.

복사 의미 체계

값입니다. 값 클래스가 복사 작업에 미치는 영향에 대한 내용은 객체 복사 항목을 참조하십시오.

예제

모두 축소

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

import matlab.unittest.TestCase;
import matlab.unittest.constraints.HasUniqueElements;

testCase = TestCase.forInteractiveUse;

'abc''Mississippi'가 고유한 요소를 갖는지 테스트합니다.

testCase.verifyThat('abc', HasUniqueElements);
Interactive verification passed.
testCase.verifyThat('Mississippi', HasUniqueElements);
Interactive verification failed.

---------------------
Framework Diagnostic:
---------------------
HasUniqueElements failed.
--> The value contains 3 nonunique element(s):
    --> Nonunique element found at indices [2 5 8 11]:
            i
    --> Nonunique element found at indices [9 10]:
            p
    --> Nonunique element found at indices [3 4 6 7]:
            s

Actual char:
    Mississippi

double형 세트가 고유한 요소를 갖는지 어설션합니다.

testCase.assertThat(magic(6), HasUniqueElements);
Interactive assertion passed.
testCase.assertThat(abs(-3:3), HasUniqueElements);
Interactive assertion failed.

---------------------
Framework Diagnostic:
---------------------
HasUniqueElements failed.
--> The value contains 3 nonunique element(s):
    --> Nonunique element found at indices [3 5]:
                 1
    --> Nonunique element found at indices [2 6]:
                 2
    --> Nonunique element found at indices [1 7]:
                 3

Actual double:
         3     2     1     0     1     2     3
Assertion failed.

셀형 배열이 고유한 요소를 갖는지 확인합니다.

testCase.verifyThat({'abc','123';'abc','345'},HasUniqueElements);
Interactive verification failed.

---------------------
Framework Diagnostic:
---------------------
HasUniqueElements failed.
--> The value contains 1 nonunique element(s):
    --> Nonunique element found at indices [1 2]:
                'abc'

Actual cell:
        'abc'    '123'
        'abc'    '345'

테이블이 고유한 행을 갖는지 어설션합니다.

t = table([3;3;5],{'A';'C';'E'},logical([1;0;0]));
testCase.assertThat(t,HasUniqueElements);
Interactive assertion passed.

버전 내역

R2016a에 개발됨