25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

cfg_aux_test.py 1.7KB

3 달 전
3 달 전
3 달 전
3 달 전
3 달 전
3 달 전
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. from cfg_aux import *
  2. def test_cfg_aux_staticSpriteName(
  3. ) -> str:
  4. section = f"static \"s-floor1\""
  5. name = cfg_aux_staticSpriteName(section)
  6. if (
  7. name == "s-floor1"
  8. ):
  9. return "OK: cfg_aux_staticSpriteName"
  10. return "ERR: cfg_aux_staticSpriteName"
  11. def test_cfg_aux_textureName(
  12. ) -> str:
  13. section = f"texture \"t-floor1\""
  14. tex = cfg_aux_textureName(section)
  15. if (
  16. tex == "t-floor1"
  17. ):
  18. return "OK: cfg_aux_textureName"
  19. return "ERR: cfg_aux_textureName"
  20. def test_cfg_aux_tree(
  21. ) -> str:
  22. lines = [
  23. "[abc]",
  24. "width = 100",
  25. "wrongSep=another",
  26. "[def]",
  27. "anotherWrongSep -> whatever",
  28. "title = yo",
  29. "subtitle = whoa",
  30. ]
  31. tree = cfg_aux_tree(lines)
  32. if (
  33. cld_len(tree) == 2 and
  34. cld_len(tree["abc"]) == 1 and
  35. cld_len(tree["def"]) == 2
  36. ):
  37. return "OK: cfg_aux_tree"
  38. return "ERR: cfg_aux_tree"
  39. def test_cfg_aux_treeCreateSection(
  40. ) -> str:
  41. tree: dict[str, dict[str, str]] = {}
  42. line = "[abc]"
  43. sectionName = cfg_aux_treeCreateSection(tree, line)
  44. if (
  45. sectionName == "abc" and
  46. cld_len(tree) == 1
  47. ):
  48. return "OK: cfg_aux_treeCreateSection"
  49. return "ERR: cfg_aux_treeCreateSection"
  50. def test_cfg_aux_treeSetKeyValue(
  51. ) -> str:
  52. tree: dict[str, dict[str, str]] = {}
  53. line = "[abc]"
  54. sectionName = cfg_aux_treeCreateSection(tree, line)
  55. line = "title = wazup"
  56. cfg_aux_treeSetKeyValue(tree, sectionName, line)
  57. if (
  58. cld_len(tree[sectionName]) == 1 and
  59. tree[sectionName]["title"] == "wazup"
  60. ):
  61. return "OK: cfg_aux_treeSetKeyValue"
  62. return "ERR: cfg_aux_treeSetKeyValue"