|
| 1 | +{$CLEO .s} |
| 2 | +{$INCLUDE_ONCE ../cleo_tester.inc} |
| 3 | + |
| 4 | +script_name "0B03" |
| 5 | +test("0B03 (move_directory)", tests) |
| 6 | +terminate_this_custom_script |
| 7 | + |
| 8 | + |
| 9 | +const Test_Path_Src = "cleo\\cleo_test_dir" |
| 10 | +const Test_Path_Dst = "test_directory" |
| 11 | + |
| 12 | +function tests |
| 13 | + |
| 14 | + it("should fail on a non-existing directory", test1) |
| 15 | + it("should move directory", test2) |
| 16 | + return |
| 17 | + |
| 18 | + function test1 |
| 19 | + does_directory_exist {dirPath} Test_Path_Src |
| 20 | + assert_result_false() |
| 21 | + |
| 22 | + move_directory {path} Test_Path_Src {newPath} Test_Path_Dst // tested opcode |
| 23 | + assert_result_false() |
| 24 | + end |
| 25 | + |
| 26 | + function test2 |
| 27 | + // setup |
| 28 | + create_directory {path} Test_Path_Src |
| 29 | + set_current_directory {path} Test_Path_Src |
| 30 | + create_directory {path} "Test_Sub_Dir" |
| 31 | + write_int_to_ini_file {value} 42 {path} "Test_File.ini" {section} "test" {key} "test" |
| 32 | + set_current_directory {path} 0 |
| 33 | + assert_result_true() |
| 34 | + does_directory_exist {dirPath} Test_Path_Src |
| 35 | + assert_result_true() |
| 36 | + does_directory_exist {dirPath} Test_Path_Dst |
| 37 | + assert_result_false() |
| 38 | + |
| 39 | + // check if file was actually created in desired location |
| 40 | + int str = allocate_memory {size} 260 |
| 41 | + string_format str = "%s\\Test_File.ini" Test_Path_Src |
| 42 | + int value = read_int_from_ini_file {path} str {section} "test" {key} "test" |
| 43 | + assert_eq(value, 42) |
| 44 | + free_memory str |
| 45 | + |
| 46 | + // act |
| 47 | + move_directory {path} Test_Path_Src {newPath} Test_Path_Dst // tested opcode |
| 48 | + assert_result_true() |
| 49 | + does_directory_exist {dirPath} Test_Path_Src |
| 50 | + assert_result_false() |
| 51 | + does_directory_exist {dirPath} Test_Path_Dst |
| 52 | + assert_result_true() |
| 53 | + |
| 54 | + // check contents |
| 55 | + set_current_directory {path} Test_Path_Dst |
| 56 | + does_directory_exist {path} "Test_Sub_Dir" |
| 57 | + assert_result_true() |
| 58 | + value = read_int_from_ini_file {path} "Test_File.ini" {section} "test" {key} "test" |
| 59 | + assert_eq(value, 42) |
| 60 | + set_current_directory {path} 0 |
| 61 | + |
| 62 | + // cleanup |
| 63 | + delete_directory {dirPath} Test_Path_Dst {recursive} true |
| 64 | + end |
| 65 | + |
| 66 | +end |
0 commit comments