Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
hd1fernando committed Nov 14, 2024
2 parents bb16bd8 + d3df9f1 commit 5b3e0ca
Show file tree
Hide file tree
Showing 11 changed files with 39 additions and 390 deletions.
16 changes: 0 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,6 @@ Cnpj cnpj = "02.055.097/0001-65";
Console.WriteLine(cnpj.EValido);
// true
```

## Tipos já implementados
* CPF
* CNPJ
* Telefone

## Benchmark
``` bash
Expand Down Expand Up @@ -65,17 +60,6 @@ AMD Ryzen 5 3400G with Radeon Vega Graphics, 1 CPU, 8 logical and 4 physical cor
| CnpjMenorDoQue14Digitos | 265.31 ns | 5.343 ns | 7.132 ns | 5 | 0.0763 | - | - | 160 B |
| CnpjValorNaoNumerico | 436.29 ns | 6.250 ns | 5.846 ns | 6 | 0.1526 | - | - | 320 B |

| Method | Mean | Error | StdDev | Rank | Gen 0 | Gen 1 | Gen 2 | Allocated |
|------------------------------------ |----------:|---------:|----------:|-----:|------:|------:|------:|----------:|
| NaoEhUmTelefoneValido | 20.48 ns | 0.413 ns | 0.386 ns | 1 | - | - | - | - |
| ObterTelefoneServicoPublicoValido | 33.18 ns | 0.687 ns | 0.609 ns | 2 | - | - | - | - |
| ObterTelefoneServicoPublicoInvalido | 48.77 ns | 0.717 ns | 0.636 ns | 3 | - | - | - | - |
| ObterTelefoneDDDInvalido | 82.00 ns | 1.186 ns | 1.109 ns | 4 | - | - | - | - |
| ObterTelefoneSemDDI | 96.33 ns | 1.874 ns | 1.661 ns | 5 | - | - | - | - |
| ObterTelefoneSemNonoDigito | 121.86 ns | 2.479 ns | 3.710 ns | 6 | - | - | - | - |
| ObterTelefoneCompleto | 137.91 ns | 3.916 ns | 11.361 ns | 7 | - | - | - | - |


// * Legends *
Mean : Arithmetic mean of all measurements
Error : Half of 99.9% confidence interval
Expand Down
2 changes: 0 additions & 2 deletions benchmark/Jabuticaba.Benchmark/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ static void Main(string[] args)
{
new CnpjBenchmark(),
new CpfBenchmark(),
new CepBenchmark(),
new TelefoneBenchmark()
};

benchmarks.ForEach(
Expand Down
34 changes: 0 additions & 34 deletions benchmark/Jabuticaba.Benchmark/TelefoneBenchmark.cs

This file was deleted.

54 changes: 0 additions & 54 deletions benchmark/Jabuticaba.Benchmark/TelefoneBenchmarkDiagnoser.cs

This file was deleted.

16 changes: 14 additions & 2 deletions src/Jabuticaba/Cnpj.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ private void Validar()
{
Span<int> stackCnpj = stackalloc int[14];

ValidarSeNulo();
if (EValido == false) return;

ValidarSeSomentDigito();
if (EValido == false) return;

Expand All @@ -42,8 +45,17 @@ private void Validar()
ValidarSegundoDigito(stackCnpj);
if (EValido == false) return;

}

}

private void ValidarSeNulo()
{
if (_cnpj is null)
{
EValido = false;
Erro = "O CNPJ não pode ser nulo.";
}
}

private void ValidarSeSomentDigito()
{
for (int i = 0; i < _cnpj.Length; i++)
Expand Down
3 changes: 3 additions & 0 deletions src/Jabuticaba/Cpf.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ private void Validar()
{
Span<int> stackCpf = stackalloc int[11];

ValidarSeNulo();
if(EValido == false) return;

ValidarSeSomenteDigito();
if (EValido == false) return;

Expand Down
23 changes: 0 additions & 23 deletions src/Jabuticaba/Telefones/ServicosPublicosEmergencia.cs

This file was deleted.

148 changes: 0 additions & 148 deletions src/Jabuticaba/Telefones/Telefone.cs

This file was deleted.

15 changes: 12 additions & 3 deletions test/JabuticabaTests/CnpjTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,9 @@ public void DeveSerInvalidoQuandoPrimeiroDigitoEhInvalido()

Cnpj cnpj = "02.055.097/0001-05";

cnpj.EValido.Should().BeFalse();
cnpj.Erro.Should()
.BeEquivalentTo("O CNPJ 02.055.097/0001-05 é inválido.");
cnpj.EValido.Should().BeFalse();
cnpj.Erro.Should()
.BeEquivalentTo("O CNPJ 02.055.097/0001-05 é inválido.");
}

[Fact]
Expand All @@ -104,5 +104,14 @@ public void DeveSerInvalidoQuandoSegundoDigitoEhInvalido()
.BeEquivalentTo("O CNPJ 02.055.097/0001-60 é inválido.");
}


[Fact]
public void DeveSerInvalidoQuandoCnpjEhNulo()
{
Cnpj cnpj = null;
cnpj.EValido.Should().BeFalse();
cnpj.Erro.Should()
.BeEquivalentTo("O CNPJ não pode ser nulo.");
}
}
}
10 changes: 10 additions & 0 deletions test/JabuticabaTests/CpfTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,5 +97,15 @@ public void DeveSerInvalidoQuandoCpfConterValorNaoNumerico()
cpf.Erro.Should()
.BeEquivalentTo("Um CPF deve conter apenas números. O valor 'a' foi encontrado na posição '12'. Cpf informado: 149.764.610a");
}

[Fact]
public void DeveSerInvalidoQuandoCpfENull()
{
Cpf cpf = null;

cpf.EValido.Should().BeFalse();
cpf.Erro.Should()
.BeEquivalentTo("O CPF não pode ser nulo");
}
}
}
Loading

0 comments on commit 5b3e0ca

Please sign in to comment.