REMOVE IBAN EXAMPLE SUMMARY AND ADD JSON FIXTURES

This commit removes the implementation summary for IBAN test coverage and adds a new module to generate test fixtures in
JSON format from the IBAN examples.
This commit is contained in:
2025-12-02 10:59:09 -05:00
parent befe29334f
commit 71aa8cfde6
6 changed files with 2389 additions and 147 deletions

View File

@@ -170,11 +170,11 @@ test "all countries have account numbers (100% coverage)" do
end
describe "Character type distribution" do
test "validates numeric-only BBANs (68 countries, 64.8%)" do
test "validates numeric-only BBANs (54+ countries, ~51%)" do
numeric_ibans = TestData.ibans_with(numeric_only: true)
assert length(numeric_ibans) >= 65,
"Expected ~68 numeric-only countries, got #{length(numeric_ibans)}"
assert length(numeric_ibans) >= 50,
"Expected ~54 numeric-only countries, got #{length(numeric_ibans)}"
# Verify they are actually numeric
Enum.each(numeric_ibans, fn iban ->
@@ -186,11 +186,11 @@ test "validates numeric-only BBANs (68 countries, 64.8%)" do
end)
end
test "validates alphanumeric BBANs (31+ countries, 29.5%)" do
test "validates alphanumeric BBANs (51+ countries, ~49%)" do
alphanumeric_ibans = TestData.ibans_with(numeric_only: false)
assert length(alphanumeric_ibans) >= 30,
"Expected ~31 alphanumeric countries, got #{length(alphanumeric_ibans)}"
assert length(alphanumeric_ibans) >= 45,
"Expected ~51 alphanumeric countries, got #{length(alphanumeric_ibans)}"
# Verify they contain letters
Enum.each(alphanumeric_ibans, fn iban ->
@@ -271,7 +271,7 @@ test "validates SEPA territory mappings" do
if length(ibans) > 0 do
iban = List.first(ibans)
{:ok, parsed} = Parser.parse(iban)
{:ok, _parsed} = Parser.parse(iban)
# Should have same length as France (27 chars)
assert String.length(iban) == 27,
@@ -287,7 +287,7 @@ test "validates SEPA territory mappings" do
if length(ibans) > 0 do
iban = List.first(ibans)
{:ok, parsed} = Parser.parse(iban)
{:ok, _parsed} = Parser.parse(iban)
# Should have same length as GB (22 chars)
assert String.length(iban) == 22,
@@ -389,8 +389,8 @@ test "Norway - shortest with minimal structure (4!n6!n1!n)" do
{:ok, no} = Parser.parse("NO9386011117947")
assert String.length(no.bank_code) == 4
# 6 + 1 check digit
assert String.length(no.account_number) == 7
assert String.length(no.account_number) == 6
assert String.length(no.national_check) == 1
assert no.branch_code == nil
end

View File

@@ -97,7 +97,7 @@ test "parsing valid IBANs from available countries returns {:ok, %IbanEx.Iban{}}
test "parsing invalid IBANs from unavailable countries returns {:error, :unsupported_country_code}" do
invalid_ibans =
[
# Fake country codes (removed SD, GF, AX, BY, DJ, HN, IQ, LC, ST, TN - now supported)
# Fake country codes - countries that don't exist or don't use IBAN
"SU56263300012039086",
"ZZ9121000418450200051332",
"FU4550000000058398257466",
@@ -130,18 +130,22 @@ test "parsing invalid IBANs from unavailable countries returns {:error, :unsuppo
"NE31120000001987426375413750",
"SN31120000001987426375413750",
"TD3112000000198742637541375",
"TF3112000000198742637541375",
"TG31120000001987426375413750",
"WF3112000000198742637541375",
"YT3112000000198742637541375"
"TG31120000001987426375413750"
]
Enum.all?(
invalid_ibans,
&assert(
match?({:error, :unsupported_country_code}, Parser.parse(&1)),
"expected #{&1} to match {:error, :unsupported_country_code}"
result =
Enum.all?(
invalid_ibans,
fn iban ->
case Parser.parse(iban) do
{:error, :unsupported_country_code} -> true
other ->
IO.puts("Unexpected result for #{iban}: #{inspect(other)}")
false
end
end
)
)
assert result, "Some IBANs did not return {:error, :unsupported_country_code}"
end
end

File diff suppressed because it is too large Load Diff

View File

@@ -212,7 +212,11 @@ defp filter_by_numeric_only(specs, nil), do: specs
defp filter_by_numeric_only(specs, numeric_only) do
Enum.filter(specs, fn {_code, spec} ->
is_numeric_only?(spec["bban_spec"]) == numeric_only
# Use numeric_only field if available, otherwise fall back to bban_spec check
case spec["numeric_only"] do
nil -> is_numeric_only?(spec["bban_spec"]) == numeric_only
value -> value == numeric_only
end
end)
end
@@ -222,7 +226,8 @@ defp has_branch_code?(spec) do
end
defp has_national_check?(spec) do
Map.has_key?(spec["positions"], "national_check")
positions = spec["positions"]["national_check"]
positions != nil and positions["start"] != positions["end"]
end
defp is_numeric_only?(bban_spec) do