def test_float_settings(self): setting = Setting("test") setting.set("float_test1", 10.5) setting.set("float_test2", -0.5) assert setting.get_double("float_test1") == 10.5, "float_test1 failed" assert setting.get_double("float_test2") == -0.5, "float_test1 failed" assert setting.get_double("float_test_default", -5.5), "float_test_default failed"
def test_bool_settings(self): setting = Setting("test") setting.set("bool_test_true", True) setting.set("bool_test_false", False) assert not setting.get_bool( "bool_test_false"), "bool_test_false failed" assert setting.get_bool("bool_test_true"), "bool_test_true failed" assert setting.get_bool("bool_test_default_True", True), "bool_test_default_True failed" assert not setting.get_bool("bool_test_default_False", False), "bool_test_default_False failed"
def test_int_settings(self): setting = Setting("test") setting.set("int_test1", 0x100) setting.set("int_test2", 0) setting.set("int_test3", -1) assert setting.get_integer("int_test1") == 0x100, "int_test1 failed" assert setting.get_integer("int_test2") == 0, "int_test2 failed" assert setting.get_integer("int_test3") == -1, "int_test3 failed" assert setting.get_integer("int_test_default_1", 1) == 1, "int_test_default_1 failed"
def test_str_settings(self): setting = Setting("test") setting.set("str_test1", "hi") setting.set("str_test2", "") setting.set("str_test3", "A" * 1000) assert setting.get_string("str_test1") == "hi", "str_test1 failed" assert setting.get_string("str_test2") == "", "str_test2 failed" assert setting.get_string( "str_test3") == "A" * 1000, "str_test3 failed" assert setting.get_string("str_test_default", "hi") == "hi", "str_test_default failed"
def test_int_list_settings(self): setting = Setting("test") setting.set("int_list_test1", [0x100]) setting.set("int_list_test2", [1, 2]) setting.set("int_list_test3", []) assert setting.get_integer_list("int_list_test1") == [ 0x100 ], "int_list_test1 failed" assert setting.get_integer_list("int_list_test2") == [ 1, 2 ], "int_list_test2 failed" assert setting.get_integer_list( "int_list_test3") == [], "int_list_test3 failed" assert setting.get_integer_list("int_list_test_default", [2, 3]), "int_list_test_default failed"
def test_str_list_settings(self): setting = Setting("test") setting.set("str_list_test1", ["hi"]) setting.set("str_list_test2", ["hello", "world"]) setting.set("str_list_test3", []) assert setting.get_string_list("str_list_test1") == [ "hi" ], "str_list_test1 failed" assert setting.get_string_list("str_list_test2") == [ "hello", "world" ], "str_list_test2 failed" assert setting.get_string_list( "str_list_test3") == [], "str_list_test3 failed" assert setting.get_string_list( "str_list_test_default", ["hi", "there"]), "str_list_test_default failed"