forked from cleolibrary/CLEO4
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Added cleanup steps to file operations unit tests * Added IniFiles tests.
- Loading branch information
Showing
13 changed files
with
467 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
Oops, something went wrong.