diff --git a/tests/cleo_tests/FilesystemOperations/0AE5.txt b/tests/cleo_tests/FilesystemOperations/0AE5.txt index ee35ebb0..37e74600 100644 --- a/tests/cleo_tests/FilesystemOperations/0AE5.txt +++ b/tests/cleo_tests/FilesystemOperations/0AE5.txt @@ -9,10 +9,16 @@ terminate_this_custom_script const Test_Path = "cleo\\cleo_test_directory" function tests + before_each(@cleanup) + after_each(@cleanup) it("should create directory", test1) return + :cleanup + delete_directory {path} Test_Path {recursive} true + return + function test1 does_directory_exist {path} Test_Path assert_result_false() @@ -22,9 +28,6 @@ function tests does_directory_exist {path} Test_Path assert_result_true() - - // cleanup - delete_directory {path} Test_Path {recursive} false end end diff --git a/tests/cleo_tests/FilesystemOperations/0B00.txt b/tests/cleo_tests/FilesystemOperations/0B00.txt index 2e9ba50d..29413007 100644 --- a/tests/cleo_tests/FilesystemOperations/0B00.txt +++ b/tests/cleo_tests/FilesystemOperations/0B00.txt @@ -9,11 +9,17 @@ terminate_this_custom_script const Test_Path = "cleo\\cleo_test_file.ini" function tests - + before_each(@cleanup) + after_each(@cleanup) + it("should fail on a non-existing file", test1) it("should delete existing file", test2) return + :cleanup + delete_file {path} Test_Path + return + function test1 delete_file {path} "cleo\\not_a_file.ini" // tested opcode assert_result_false() diff --git a/tests/cleo_tests/FilesystemOperations/0B01.txt b/tests/cleo_tests/FilesystemOperations/0B01.txt index 56eea860..587f8372 100644 --- a/tests/cleo_tests/FilesystemOperations/0B01.txt +++ b/tests/cleo_tests/FilesystemOperations/0B01.txt @@ -9,12 +9,19 @@ terminate_this_custom_script const Test_Path = "cleo\\cleo_test_directory" function tests + before_each(@cleanup) + after_each(@cleanup) it("should fail on a non-existing directory", test1) it("should delete empty directory", test2) it("should delete directory with contents", test3) return + :cleanup + set_current_directory {path} 0 + delete_directory {dirPath} Test_Path {recursive} true + return + function test1 delete_directory {dirPath} Test_Path {recursive} false // tested opcode assert_result_false() diff --git a/tests/cleo_tests/FilesystemOperations/0B02.txt b/tests/cleo_tests/FilesystemOperations/0B02.txt index 94b5c6cd..6457790f 100644 --- a/tests/cleo_tests/FilesystemOperations/0B02.txt +++ b/tests/cleo_tests/FilesystemOperations/0B02.txt @@ -10,11 +10,18 @@ const Test_Path_Src = "cleo\\cleo_test_file.ini" const Test_Path_Dst = "_test_file_B.ini" function tests + before_each(@cleanup) + after_each(@cleanup) it("should fail on a non-existing file", test1) it("should move file", test2) return + :cleanup + delete_file {path} Test_Path_Src + delete_file {path} Test_Path_Dst + return + function test1 does_file_exist {dirPath} Test_Path_Src assert_result_false() @@ -42,9 +49,6 @@ function tests int value = read_int_from_ini_file {path} Test_Path_Dst {section} "test" {key} "test" assert_eq(value, 42) - - // cleanup - delete_file {fileName} Test_Path_Dst end end diff --git a/tests/cleo_tests/FilesystemOperations/0B03.txt b/tests/cleo_tests/FilesystemOperations/0B03.txt index be094d3b..990649b1 100644 --- a/tests/cleo_tests/FilesystemOperations/0B03.txt +++ b/tests/cleo_tests/FilesystemOperations/0B03.txt @@ -10,11 +10,19 @@ const Test_Path_Src = "cleo\\cleo_test_dir" const Test_Path_Dst = "test_directory" function tests + before_each(@cleanup) + after_each(@cleanup) it("should fail on a non-existing directory", test1) it("should move directory", test2) return + :cleanup + set_current_directory {path} 0 + delete_directory {path} Test_Path_Src + delete_directory {path} Test_Path_Dst + return + function test1 does_directory_exist {dirPath} Test_Path_Src assert_result_false() @@ -57,10 +65,6 @@ function tests assert_result_true() value = read_int_from_ini_file {path} "Test_File.ini" {section} "test" {key} "test" assert_eq(value, 42) - set_current_directory {path} 0 - - // cleanup - delete_directory {dirPath} Test_Path_Dst {recursive} true end end diff --git a/tests/cleo_tests/FilesystemOperations/0B04.txt b/tests/cleo_tests/FilesystemOperations/0B04.txt index 19679aee..0407eeff 100644 --- a/tests/cleo_tests/FilesystemOperations/0B04.txt +++ b/tests/cleo_tests/FilesystemOperations/0B04.txt @@ -10,13 +10,20 @@ const Test_Path_Src = "cleo\\cleo_test_file.ini" const Test_Path_Dst = "_test_file_B.ini" function tests + before_each(@cleanup) + after_each(@cleanup) it("should fail on a non-existing file", test1) it("should copy file", test2) return + :cleanup + delete_file {path} Test_Path_Src + delete_file {path} Test_Path_Dst + return + function test1 - does_file_exist {dirPath} Test_Path_Src + does_file_exist {path} Test_Path_Src assert_result_false() copy_file {path} Test_Path_Src {newPath} Test_Path_Dst // tested opcode @@ -27,9 +34,9 @@ function tests // setup write_int_to_ini_file {value} 42 {path} Test_Path_Src {section} "test" {key} "test" assert_result_true() - does_file_exist {dirPath} Test_Path_Src + does_file_exist {path} Test_Path_Src assert_result_true() - does_file_exist {dirPath} Test_Path_Dst + does_file_exist {path} Test_Path_Dst assert_result_false() // act @@ -41,10 +48,6 @@ function tests value = read_int_from_ini_file {path} Test_Path_Dst {section} "test" {key} "test" assert_eq(value, 42) - - // cleanup - delete_file {fileName} Test_Path_Src - delete_file {fileName} Test_Path_Dst end end diff --git a/tests/cleo_tests/FilesystemOperations/0B05.txt b/tests/cleo_tests/FilesystemOperations/0B05.txt index d157602f..b94cf244 100644 --- a/tests/cleo_tests/FilesystemOperations/0B05.txt +++ b/tests/cleo_tests/FilesystemOperations/0B05.txt @@ -10,11 +10,19 @@ const Test_Path_Src = "cleo\\cleo_test_dir" const Test_Path_Dst = "test_directory" function tests + before_each(@cleanup) + after_each(@cleanup) it("should fail on a non-existing directory", test1) it("should move directory", test2) return + :cleanup + set_current_directory {path} 0 + delete_directory {path} Test_Path_Src {recursive} true + delete_directory {path} Test_Path_Dst {recursive} true + return + function test1 does_directory_exist {dirPath} Test_Path_Src assert_result_false() @@ -64,11 +72,6 @@ function tests assert_result_true() value = read_int_from_ini_file {path} "Test_File.ini" {section} "test" {key} "test" assert_eq(value, 42) - set_current_directory {path} 0 - - // cleanup - delete_directory {dirPath} Test_Path_Src {recursive} true - delete_directory {dirPath} Test_Path_Dst {recursive} true end end diff --git a/tests/cleo_tests/IniFiles/0AF0.txt b/tests/cleo_tests/IniFiles/0AF0.txt new file mode 100644 index 00000000..72725e8e --- /dev/null +++ b/tests/cleo_tests/IniFiles/0AF0.txt @@ -0,0 +1,59 @@ +{$CLEO .s} +{$INCLUDE_ONCE ../cleo_tester.inc} + +script_name "0AF0" +test("0AF0 (read_int_from_ini_file)", tests) +terminate_this_custom_script + + +const Test_Path = "cleo\\cleo_test_file.ini" + +function tests + before_each(@setup) + after_each(@cleanup) + + it("should fail on not-existing file", test1) + it("should fail on invalid file", test2) + it("should fail on not existing value", test3) + it("should fail on invalid type", test4) + it("should read value", test5) + + return + + :setup + delete_file {path} Test_Path + write_int_to_ini_file {value} 42 {path} Test_Path {section} "test" {key} "test_int" + write_float_to_ini_file {value} 50.0 {path} Test_Path {section} "test" {key} "test_float" + write_string_to_ini_file {value} "value_one" {path} Test_Path {section} "test" {key} "test_string" + return + + :cleanup + delete_file {path} Test_Path + return + + function test1 + int value = read_int_from_ini_file {path} "not_a_file.ini" {section} "test" {key} "test_int" + assert_result_false() + end + + function test2 + int value = read_int_from_ini_file {path} "cleo.asi" {section} "test" {key} "test_int" + assert_result_false() + end + + function test3 + int value = read_int_from_ini_file {path} Test_Path {section} "test" {key} "invalid_key" + assert_result_false() + end + + function test4 + int value = read_int_from_ini_file {path} Test_Path {section} "test" {key} "test_string" + assert_result_false() + end + + function test5 + int value = read_int_from_ini_file {path} Test_Path {section} "test" {key} "test_int" + assert_result_true() + assert_eq(value, 42) + end +end diff --git a/tests/cleo_tests/IniFiles/0AF1.txt b/tests/cleo_tests/IniFiles/0AF1.txt new file mode 100644 index 00000000..ee8a6578 --- /dev/null +++ b/tests/cleo_tests/IniFiles/0AF1.txt @@ -0,0 +1,81 @@ +{$CLEO .s} +{$INCLUDE_ONCE ../cleo_tester.inc} + +script_name "0AF1" +test("0AF1 (write_int_to_ini_file)", tests) +terminate_this_custom_script + + +const Test_Path = "cleo\\cleo_test_file.ini" + +function tests + before_each(@cleanup) + after_each(@cleanup) + + it("should fail to overwrite file", test1) + it("should fail to overwrite directory", test2) + it("should create new file", test3) + it("should append to existing file", test4) + it("should overwrite value", test5) + return + + :cleanup + delete_file {path} Test_Path + return + + function test1 + write_int_to_ini_file {value} 42 {path} "gta_sa.exe" {section} "test" {key} "test" + assert_result_false() + end + + function test2 + write_int_to_ini_file {value} 42 {path} "cleo" {section} "test" {key} "test" + assert_result_false() + end + + function test3 + does_file_exist {path} Test_Path + assert_result_false() + + write_int_to_ini_file {value} 42 {path} Test_Path {section} "test" {key} "test" + assert_result_true() + + does_file_exist {path} Test_Path + assert_result_true() + + int value = read_int_from_ini_file {path} Test_Path {section} "test" {key} "test" + assert_eq(value, 42) + end + + function test4 + does_file_exist {path} Test_Path + assert_result_false() + + write_int_to_ini_file {value} 42 {path} Test_Path {section} "test" {key} "testA" + assert_result_true() + + write_int_to_ini_file {value} 50 {path} Test_Path {section} "test" {key} "testB" + assert_result_true() + + int value = read_int_from_ini_file {path} Test_Path {section} "test" {key} "testA" + assert_eq(value, 42) + + value = read_int_from_ini_file {path} Test_Path {section} "test" {key} "testB" + assert_eq(value, 50) + end + + function test5 + does_file_exist {path} Test_Path + assert_result_false() + + write_int_to_ini_file {value} 42 {path} Test_Path {section} "test" {key} "test" + assert_result_true() + + write_int_to_ini_file {value} 50 {path} Test_Path {section} "test" {key} "test" + assert_result_true() + + int value = read_int_from_ini_file {path} Test_Path {section} "test" {key} "test" + assert_eq(value, 50) + end + +end diff --git a/tests/cleo_tests/IniFiles/0AF2.txt b/tests/cleo_tests/IniFiles/0AF2.txt new file mode 100644 index 00000000..7121be4f --- /dev/null +++ b/tests/cleo_tests/IniFiles/0AF2.txt @@ -0,0 +1,59 @@ +{$CLEO .s} +{$INCLUDE_ONCE ../cleo_tester.inc} + +script_name "0AF2" +test("0AF2 (read_float_from_ini_file)", tests) +terminate_this_custom_script + + +const Test_Path = "cleo\\cleo_test_file.ini" + +function tests + before_each(@setup) + after_each(@cleanup) + + it("should fail on not-existing file", test1) + it("should fail on invalid file", test2) + it("should fail on not existing value", test3) + it("should fail on invalid type", test4) + it("should read value", test5) + + return + + :setup + delete_file {path} Test_Path + write_int_to_ini_file {value} 42 {path} Test_Path {section} "test" {key} "test_int" + write_float_to_ini_file {value} 50.0 {path} Test_Path {section} "test" {key} "test_float" + write_string_to_ini_file {value} "value_one" {path} Test_Path {section} "test" {key} "test_string" + return + + :cleanup + delete_file {path} Test_Path + return + + function test1 + float value = read_float_from_ini_file {path} "not_a_file.ini" {section} "test" {key} "test_float" + assert_result_false() + end + + function test2 + float value = read_float_from_ini_file {path} "cleo.asi" {section} "test" {key} "test_float" + assert_result_false() + end + + function test3 + float value = read_float_from_ini_file {path} Test_Path {section} "test" {key} "invalid_key" + assert_result_false() + end + + function test4 + float value = read_float_from_ini_file {path} Test_Path {section} "test" {key} "test_string" + assert_result_false() + end + + function test5 + float value = read_float_from_ini_file {path} Test_Path {section} "test" {key} "test_float" + assert_result_true() + assert_eqf(value, 50.0) + end +end diff --git a/tests/cleo_tests/IniFiles/0AF3.txt b/tests/cleo_tests/IniFiles/0AF3.txt new file mode 100644 index 00000000..56ed769b --- /dev/null +++ b/tests/cleo_tests/IniFiles/0AF3.txt @@ -0,0 +1,81 @@ +{$CLEO .s} +{$INCLUDE_ONCE ../cleo_tester.inc} + +script_name "0AF3" +test("0AF3 (write_float_to_ini_file)", tests) +terminate_this_custom_script + + +const Test_Path = "cleo\\cleo_test_file.ini" + +function tests + before_each(@cleanup) + after_each(@cleanup) + + it("should fail to overwrite file", test1) + it("should fail to overwrite directory", test2) + it("should create new file", test3) + it("should append to existing file", test4) + it("should overwrite value", test5) + return + + :cleanup + delete_file {path} Test_Path + return + + function test1 + write_float_to_ini_file {value} 42.0 {path} "gta_sa.exe" {section} "test" {key} "test" + assert_result_false() + end + + function test2 + write_float_to_ini_file {value} 42.0 {path} "cleo" {section} "test" {key} "test" + assert_result_false() + end + + function test3 + does_file_exist {path} Test_Path + assert_result_false() + + write_float_to_ini_file {value} 42.0 {path} Test_Path {section} "test" {key} "test" + assert_result_true() + + does_file_exist {path} Test_Path + assert_result_true() + + int value = read_float_from_ini_file {path} Test_Path {section} "test" {key} "test" + assert_eqf(value, 42.0) + end + + function test4 + does_file_exist {path} Test_Path + assert_result_false() + + write_float_to_ini_file {value} 42.0 {path} Test_Path {section} "test" {key} "testA" + assert_result_true() + + write_float_to_ini_file {value} 50.0 {path} Test_Path {section} "test" {key} "testB" + assert_result_true() + + int value = read_float_from_ini_file {path} Test_Path {section} "test" {key} "testA" + assert_eqf(value, 42.0) + + value = read_float_from_ini_file {path} Test_Path {section} "test" {key} "testB" + assert_eqf(value, 50.0) + end + + function test5 + does_file_exist {path} Test_Path + assert_result_false() + + write_float_to_ini_file {value} 42.0 {path} Test_Path {section} "test" {key} "test" + assert_result_true() + + write_float_to_ini_file {value} 50.0 {path} Test_Path {section} "test" {key} "test" + assert_result_true() + + int value = read_float_from_ini_file {path} Test_Path {section} "test" {key} "test" + assert_eqf(value, 50.0) + end + +end diff --git a/tests/cleo_tests/IniFiles/0AF4.txt b/tests/cleo_tests/IniFiles/0AF4.txt new file mode 100644 index 00000000..5bf2ca55 --- /dev/null +++ b/tests/cleo_tests/IniFiles/0AF4.txt @@ -0,0 +1,53 @@ +{$CLEO .s} +{$INCLUDE_ONCE ../cleo_tester.inc} + +script_name "0AF4" +test("0AF4 (read_string_from_ini_file)", tests) +terminate_this_custom_script + + +const Test_Path = "cleo\\cleo_test_file.ini" + +function tests + before_each(@setup) + after_each(@cleanup) + + it("should fail on not-existing file", test1) + it("should fail on invalid file", test2) + it("should fail on not existing value", test3) + it("should read value", test4) + + return + + :setup + delete_file {path} Test_Path + write_int_to_ini_file {value} 42 {path} Test_Path {section} "test" {key} "test_int" + write_float_to_ini_file {value} 50.0 {path} Test_Path {section} "test" {key} "test_float" + write_string_to_ini_file {value} "value_one" {path} Test_Path {section} "test" {key} "test_string" + return + + :cleanup + delete_file {path} Test_Path + return + + function test1 + longstring value = read_string_from_ini_file {path} "not_a_file.ini" {section} "test" {key} "test_string" + assert_result_false() + end + + function test2 + longstring value = read_string_from_ini_file {path} "cleo.asi" {section} "test" {key} "test_string" + assert_result_false() + end + + function test3 + longstring value = read_string_from_ini_file {path} Test_Path {section} "test" {key} "invalid_key" + assert_result_false() + end + + function test4 + longstring value = read_string_from_ini_file {path} Test_Path {section} "test" {key} "test_string" + assert_result_true() + assert_eqs(value, "value_one") + end +end diff --git a/tests/cleo_tests/IniFiles/0AF5.txt b/tests/cleo_tests/IniFiles/0AF5.txt new file mode 100644 index 00000000..69d27128 --- /dev/null +++ b/tests/cleo_tests/IniFiles/0AF5.txt @@ -0,0 +1,81 @@ +{$CLEO .s} +{$INCLUDE_ONCE ../cleo_tester.inc} + +script_name "0AF5" +test("0AF5 (write_string_to_ini_file)", tests) +terminate_this_custom_script + + +const Test_Path = "cleo\\cleo_test_file.ini" + +function tests + before_each(@cleanup) + after_each(@cleanup) + + it("should fail to overwrite file", test1) + it("should fail to overwrite directory", test2) + it("should create new file", test3) + it("should append to existing file", test4) + it("should overwrite value", test5) + return + + :cleanup + delete_file {path} Test_Path + return + + function test1 + write_string_to_ini_file {value} "value_one" {path} "gta_sa.exe" {section} "test" {key} "test" + assert_result_false() + end + + function test2 + write_string_to_ini_file {value} "value_one" {path} "cleo" {section} "test" {key} "test" + assert_result_false() + end + + function test3 + does_file_exist {path} Test_Path + assert_result_false() + + write_string_to_ini_file {value} "value_one" {path} Test_Path {section} "test" {key} "test" + assert_result_true() + + does_file_exist {path} Test_Path + assert_result_true() + + longstring value = read_string_from_ini_file {path} Test_Path {section} "test" {key} "test" + assert_eqs(value, "value_one") + end + + function test4 + does_file_exist {path} Test_Path + assert_result_false() + + write_string_to_ini_file {value} "value_one" {path} Test_Path {section} "test" {key} "testA" + assert_result_true() + + write_string_to_ini_file {value} "value_two" {path} Test_Path {section} "test" {key} "testB" + assert_result_true() + + longstring value = read_string_from_ini_file {path} Test_Path {section} "test" {key} "testA" + assert_eqs(value, "value_one") + + value = read_string_from_ini_file {path} Test_Path {section} "test" {key} "testB" + assert_eqs(value, "value_two") + end + + function test5 + does_file_exist {path} Test_Path + assert_result_false() + + write_string_to_ini_file {value} "value_one" {path} Test_Path {section} "test" {key} "test" + assert_result_true() + + write_string_to_ini_file {value} "value_two" {path} Test_Path {section} "test" {key} "test" + assert_result_true() + + longstring value = read_string_from_ini_file {path} Test_Path {section} "test" {key} "test" + assert_eqs(value, "value_two") + end + +end