matlab.unittest.constraints.IsFile 클래스
패키지: matlab.unittest.constraints
슈퍼클래스: matlab.unittest.constraints.BooleanConstraint
파일을 가리키는 값을 지정하는 제약 조건
생성
IsFile
은 기존 파일을 가리키는 string형 스칼라 또는 문자형 벡터인 값을 지정하는 제약 조건을 만듭니다. 값이 기존 파일의 절대 경로 또는 상대 경로인 경우 제약 조건을 충족합니다.
복사 의미 체계
값입니다. 값 클래스가 복사 작업에 미치는 영향에 대한 내용은 객체 복사 항목을 참조하십시오.
예제
파일이 있는지 테스트하기
대화형 방식 테스트를 위한 테스트 케이스를 생성합니다.
import matlab.unittest.TestCase; import matlab.unittest.constraints.IsFile; testCase = TestCase.forInteractiveUse;
myFile.mat
가 현재 작업 폴더에 있는 기존 파일인지 테스트합니다. 이 예제는 파일이 존재하지 않으며 테스트에 실패하는 것으로 가정합니다.
act = 'myFile.mat';
testCase.verifyThat(act,IsFile)
Interactive verification failed. --------------------- Framework Diagnostic: --------------------- IsFile failed. --> Value does not point to an existing file. --> Current folder during evaluation: 'C:\work' Actual char: myFile.mat
현재 작업 폴더에서 파일 myTxtFile.txt
가 포함된 폴더 myFolder
를 만듭니다.
mkdir myFolder dlmwrite(['myFolder' filesep 'myTxtFile.txt'],rand(5))
myTxtFile.txt
가 myFolder
에 있는 기존 파일인지 확인합니다.
act = ['myFolder' filesep 'myTxtFile.txt']; testCase.verifyThat(act,IsFile)
Interactive verification passed.
파일이 존재하지 않는지 테스트하기
대화형 방식 테스트를 위한 테스트 케이스를 생성합니다.
import matlab.unittest.TestCase; import matlab.unittest.constraints.IsFile; testCase = TestCase.forInteractiveUse;
nonexistentFile.mat
가 현재 작업 폴더에 있는 기존 파일이 아닌지 확인합니다. 이 예제는 파일이 존재하지 않으며 테스트에 통과하는 것으로 가정합니다.
act = 'nonexistentFile.mat';
testCase.verifyThat(act,~IsFile)
Interactive verification passed.
버전 내역
MATLAB 명령
다음 MATLAB 명령에 해당하는 링크를 클릭했습니다.
명령을 실행하려면 MATLAB 명령 창에 입력하십시오. 웹 브라우저는 MATLAB 명령을 지원하지 않습니다.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)