1// ============================================================================= 2// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab 3// Copyright (C) 2007-2008 - INRIA - Pierre MARECHAL <pierre.marechal@inria.fr> 4// 5// This file is distributed under the same license as the Scilab package. 6// ============================================================================= 7 8// <-- CLI SHELL MODE --> 9// <-- ENGLISH IMPOSED --> 10// <-- NO CHECK REF --> 11 12// ============================================================================= 13// Unitary tests for mkdir function 14// ============================================================================= 15 16// TEST 1 : absolute path with one input argument 17 18cd; 19test_1_dir = TMPDIR+"/mkdir_test_1"; 20status_1 = mkdir(test_1_dir); 21 22if status_1 <> 1 then pause,end 23if ~isdir(test_1_dir) then pause,end 24 25// TEST 2 : absolute path with 2 input arguments 26 27cd; 28test_2_dir = TMPDIR+"/mkdir_test_2"; 29status_2 = mkdir(TMPDIR,"mkdir_test_2"); 30 31if status_2 <> 1 then pause,end 32if ~isdir(test_2_dir) then pause,end 33 34// TEST 3 : relative path 35 36cd TMPDIR; 37test_3_dir = TMPDIR+"/mkdir_test_3"; 38status_3 = mkdir("mkdir_test_3"); 39 40if status_3 <> 1 then pause,end 41if ~isdir(test_3_dir) then pause,end 42if ~isdir("mkdir_test_3") then pause,end 43 44// TEST 4 : relative path with sub-directory 45 46cd TMPDIR; 47test_4_dir = TMPDIR+"/mkdir_test_3/mkdir_test_4"; 48status_4 = mkdir("mkdir_test_3/mkdir_test_4"); 49 50if status_4 <> 1 then pause,end 51if ~isdir(test_4_dir) then pause,end 52if ~isdir("mkdir_test_3/mkdir_test_4") then pause,end 53 54// TEST 5 : Bad Case - The directory already exists 55 56cd; 57test_5_dir = test_1_dir; 58status_5 = mkdir(test_5_dir); 59if status_5 <> 2 then pause,end 60 61// TEST 6 : Bad Case - The file already exists 62 63cd; 64test_6_dir = TMPDIR+"/mkdir_test_6"; 65 66[fd_6,err_6] = mopen(test_6_dir,"wb"); 67mclose(fd_6); 68 69status_6 = mkdir(test_6_dir); 70if status_6 <> -2 then pause,end 71 72// TEST 7 : mkdir creates in the same instruction one folder and one subfolder. 73 74cd; 75test_7_dir = TMPDIR+"/mkdir_test_7/mkdir_test_7"; 76status_7 = mkdir(test_7_dir); 77if status_7 <> 1 then pause,end 78 79 80removedir(test_1_dir); 81removedir(test_2_dir); 82removedir(test_3_dir); 83assert_checkfalse(removedir(test_4_dir)); 84assert_checkfalse(removedir(test_5_dir)); 85assert_checkfalse(removedir(test_6_dir)); 86removedir(test_7_dir); 87 88// TEST : error messages 89try 90 mkdir([]) 91catch 92 [str,n]=lasterror(); 93 if n <> 10000 then pause, end 94 if str <> msprintf(_("%s: Wrong type for input argument #%d: String expected.\n"), "mkdir", 1) then pause, end 95end 96 97try 98 mkdir(["a", "b"]) 99catch 100 [str,n]=lasterror(); 101 if n <> 10000 then pause, end 102 if str <> msprintf(_("%s: Wrong size for input argument #%d: string expected.\n"), "mkdir", 1) then pause, end 103end 104