-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
29 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,35 @@ | ||
|
||
from pgspot.pg_catalog.format import parse_format_string | ||
|
||
# %[position][flags][width]type | ||
|
||
|
||
def test_no_variables(): | ||
ret = parse_format_string("") | ||
assert ret == [] | ||
assert parse_format_string("") == [] | ||
assert parse_format_string("SELECT * FROM table") == [] | ||
assert parse_format_string("%%") == [] | ||
|
||
|
||
def test_single_variable(): | ||
assert parse_format_string("%s") == [("s", 1)] | ||
assert parse_format_string("%I") == [("I", 1)] | ||
assert parse_format_string("%L") == [("L", 1)] | ||
|
||
assert parse_format_string("%%%s%%") == [("s", 1)] | ||
|
||
assert parse_format_string("%1$s") == [("s", 1)] | ||
assert parse_format_string("%3$s") == [("s", 3)] | ||
|
||
assert parse_format_string("%-s") == [("s", 1)] | ||
assert parse_format_string("%-10s") == [("s", 1)] | ||
assert parse_format_string("%-*s") == [("s", 2)] | ||
assert parse_format_string("%-*1$s") == [("s", 1)] | ||
|
||
ret = parse_format_string("SELECT * FROM table") | ||
assert ret == [] | ||
assert parse_format_string("%7$-s") == [("s", 7)] | ||
assert parse_format_string("%7$-10s") == [("s", 7)] | ||
assert parse_format_string("%7$-*s") == [("s", 7)] | ||
assert parse_format_string("%7$-*1$s") == [("s", 7)] | ||
|
||
ret = parse_format_string("%%") | ||
assert ret == [] | ||
|
||
def test_multiple_variable(): | ||
assert parse_format_string("%s%I%L") == [("s", 1), ("I", 2), ("L", 3)] | ||
assert parse_format_string("%3$s%2$I%1$L") == [("s", 3), ("I", 2), ("L", 1)] |