Skip to content

Commit

Permalink
corrige bug #37
Browse files Browse the repository at this point in the history
  • Loading branch information
dhersz committed Dec 19, 2024
1 parent 69dd8ff commit e816ba6
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Correção de bugs

- Corrigido bug na `padronizar_numeros()` em que zeros após o separador de milhares
eram suprimidos. Por exemplo, "1.028" virava "1.28". Relacionado ao [issue
#37](https://github.com/ipeaGIT/enderecobr/issues/37).

## Novas funcionalidades

## Notas
Expand Down
2 changes: 1 addition & 1 deletion R/padronizar_numeros.R
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ padronizar_numeros <- function(numeros) {
numeros_padrao <- stringr::str_replace_all(
numeros_padrao,
c(
r"{\b0+(\d+)\b}" = "\\1", # 015 -> 15, 00001 -> 1, 0180 0181 -> 180 181
r"{(?<!\.)\b0+(\d+)\b}" = "\\1", # 015 -> 15, 00001 -> 1, 0180 0181 -> 180 181, mas não 1.028 -> 1.28

r"{(\d+)\.(\d{3})}" = "\\1\\2", # separador de milhar

Expand Down
2 changes: 2 additions & 0 deletions tests/testthat/test-padronizar_numeros.R
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ test_that("padroniza corretamente - caracter", {
"20.100", "20100",
"20.100 20.101", "20100 20101",

"1.028", "1028", # mistura dos dois casos acima - issue #37 (https://github.com/ipeaGIT/enderecobr/issues/37)

"SN", "S/N",
"SNº", "S/N",
"S N", "S/N",
Expand Down

0 comments on commit e816ba6

Please sign in to comment.