Skip to content

Commit

Permalink
dq3.dumptool: change docstring and add a test (#33)
Browse files Browse the repository at this point in the history
  • Loading branch information
showa-yojyo committed Nov 6, 2024
1 parent 1ce4851 commit eb8c501
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 6 deletions.
20 changes: 14 additions & 6 deletions src/dqutils/snescpu/dumptool.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
"""
Example:
$ dumptool.py dqutils.dq3.dumptool 0xC8F323 0x36 10
#$0000\t#$00001F
#$0000\t#$0003E0
...
#$0035\t#$000001
[EOF]
$ dumptool.py 0xC30900 8 5 --delimiter : <<< '#$00:#$007F
#$00:#$0080
#$01:#$00FF
#$02:#$00FF
#$03:#$00FF
#$04:#$00FF
#$05:#$00FF
#$06:#$00FF
#$07:#$00FF'
0000:06:1:08:1A:19:10:18:21:03
0001:02:1:77:B8:B9:BA:BB:00:00
0002:00:0:36:03:0D:3E:3F:55:79
0003:02:1:B8:B9:BA:BB:BF:00:00
0004:00:0:07:06:22:41:66:5C:00
"""

from __future__ import annotations
Expand Down
24 changes: 24 additions & 0 deletions tests/dq3/test_dumptool.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,27 @@ def test_run(self):
"""
)
self.assertMultiLineEqual(output.getvalue(), expected)

def test_shop_data(self):
data = StringIO(
"#$00:#$007F\n"
"#$00:#$0080\n"
"#$01:#$00FF\n"
"#$02:#$00FF\n"
"#$03:#$00FF\n"
"#$04:#$00FF\n"
"#$05:#$00FF\n"
"#$06:#$00FF\n"
"#$07:#$00FF\n"
)
expected = (
"0000:06:1:08:1A:19:10:18:21:03\n"
"0001:02:1:77:B8:B9:BA:BB:00:00\n"
"0002:00:0:36:03:0D:3E:3F:55:79\n"
"0003:02:1:B8:B9:BA:BB:BF:00:00\n"
"0004:00:0:07:06:22:41:66:5C:00\n"
)
with patch("sys.stdin", data), patch("sys.stdout", StringIO()) as output:
main(["0xC30900", "8", "5", "--delimiter", ":"])
# self.maxDiff = None
self.assertMultiLineEqual(output.getvalue(), expected)

0 comments on commit eb8c501

Please sign in to comment.