Skip to content

Commit

Permalink
add - prt|brk|doc - Initial movement of Figletize to Textify.Figlet
Browse files Browse the repository at this point in the history
---

We've cleaned up some parts of the figlet part. The only thing left is to tweak as much as we can.

---

Type: add
Breaking: True
Doc Required: True
Part: 2/2
  • Loading branch information
AptiviCEO committed May 11, 2024
1 parent 9b8ddb6 commit 9437128
Show file tree
Hide file tree
Showing 18 changed files with 2,133 additions and 1,975 deletions.
905 changes: 461 additions & 444 deletions Textify.Figlet.Generator.Tests/FigletSourceGeneratorTests.cs

Large diffs are not rendered by default.

449 changes: 233 additions & 216 deletions Textify.Figlet.Generator/FigletSourceGenerator.cs

Large diffs are not rendered by default.

214 changes: 60 additions & 154 deletions Textify.Figlet.Tests/FigletFontTest.cs

Large diffs are not rendered by default.

142 changes: 76 additions & 66 deletions Textify.Figlet.Tests/ParseUtilTest.cs
Original file line number Diff line number Diff line change
@@ -1,81 +1,91 @@
// Copyright Drew Noakes. Licensed under the Apache-2.0 license. See the LICENSE file for more details.
// Copyright 2023-2024 - Aptivi. Licensed under the Apache-2.0 license. See the LICENSE file for more details.
//
// Textify Copyright (C) 2023-2024 Aptivi
//
// This file is part of Textify
//
// Textify is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Textify is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY, without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
//

using Microsoft.VisualStudio.TestTools.UnitTesting;
using Shouldly;
using Textify.Figlet.Utilities;

namespace Textify.Figlet.Tests;

public class ParseUtilTest
namespace Textify.Figlet.Tests
{
[TestMethod]
public void Parse()
public class ParseUtilTest
{
void Test(string s, int expected)
[TestMethod]
[DataRow("1234", 1234)]
[DataRow("1234 ", 1234)]
[DataRow("1234 ", 1234)]
[DataRow("0X4D2", 1234)]
[DataRow("0h4D2", 1234)]
[DataRow("0x4d2", 1234)]
[DataRow("0x4D2 ", 1234)]
[DataRow("02322", 1234)]
[DataRow("02322 ", 1234)]
[DataRow("002322 ", 1234)]
[DataRow("0002322 ", 1234)]
[DataRow("-1234", -1234)]
[DataRow("-1234 ", -1234)]
[DataRow("-1234 ", -1234)]
[DataRow("-0X4D2", -1234)]
[DataRow("-0h4D2", -1234)]
[DataRow("-0x4d2", -1234)]
[DataRow("-0x4D2 ", -1234)]
[DataRow("-02322", -1234)]
[DataRow("-02322 ", -1234)]
[DataRow("-002322 ", -1234)]
[DataRow("-0002322 ", -1234)]
[DataRow(" 1234", 1234)]
[DataRow(" 1234 ", 1234)]
[DataRow(" 1234 ", 1234)]
[DataRow(" 0X4D2", 1234)]
[DataRow(" 0h4D2", 1234)]
[DataRow(" 0x4d2", 1234)]
[DataRow(" 0x4D2 ", 1234)]
[DataRow(" 02322", 1234)]
[DataRow(" 02322 ", 1234)]
[DataRow(" 002322 ", 1234)]
[DataRow(" 0002322 ", 1234)]
[DataRow("0", 0)]
[DataRow("00", 0)]
[DataRow("000", 0)]
[DataRow("0x0", 0)]
[DataRow(" 0 ", 0)]
[DataRow(" 00 ", 0)]
[DataRow(" 000 ", 0)]
[DataRow(" 0x0 ", 0)]
public void TestParseValid(string s, int expected)
{
ParseUtil.TryParse(s, out var actual).ShouldBeTrue();
actual.ShouldBe(expected);
}

void TestFails(string s) =>
[TestMethod]
[DataRow("Hello")]
[DataRow("0Hello")]
[DataRow("0xx1234")]
[DataRow("04D2")]
[DataRow("4D2")]
[DataRow("098LKJ")]
[DataRow("0x")]
[DataRow("0x ")]
[DataRow(" 0x ")]
[DataRow("- 123")]
[DataRow("--123")]
public void TestParseInalid(string s) =>
ParseUtil.TryParse(s, out var _).ShouldBeFalse();

Test("1234", 1234);
Test("1234 ", 1234);
Test("1234 ", 1234);
Test("0X4D2", 1234);
Test("0h4D2", 1234);
Test("0x4d2", 1234);
Test("0x4D2 ", 1234);
Test("02322", 1234);
Test("02322 ", 1234);
Test("002322 ", 1234);
Test("0002322 ", 1234);

Test("-1234", -1234);
Test("-1234 ", -1234);
Test("-1234 ", -1234);
Test("-0X4D2", -1234);
Test("-0h4D2", -1234);
Test("-0x4d2", -1234);
Test("-0x4D2 ", -1234);
Test("-02322", -1234);
Test("-02322 ", -1234);
Test("-002322 ", -1234);
Test("-0002322 ", -1234);

Test(" 1234", 1234);
Test(" 1234 ", 1234);
Test(" 1234 ", 1234);
Test(" 0X4D2", 1234);
Test(" 0h4D2", 1234);
Test(" 0x4d2", 1234);
Test(" 0x4D2 ", 1234);
Test(" 02322", 1234);
Test(" 02322 ", 1234);
Test(" 002322 ", 1234);
Test(" 0002322 ", 1234);

Test("0", 0);
Test("00", 0);
Test("000", 0);
Test("0x0", 0);
Test(" 0 ", 0);
Test(" 00 ", 0);
Test(" 000 ", 0);
Test(" 0x0 ", 0);

TestFails("Hello");
TestFails("0Hello");
TestFails("0xx1234");
TestFails("04D2");
TestFails("4D2");
TestFails("098LKJ");
TestFails("0x");
TestFails("0x ");
TestFails(" 0x ");
TestFails("- 123");
TestFails("--123");
}
}
49 changes: 33 additions & 16 deletions Textify.Figlet.Tests/StringPoolTest.cs
Original file line number Diff line number Diff line change
@@ -1,28 +1,45 @@
// Copyright Drew Noakes. Licensed under the Apache-2.0 license. See the LICENSE file for more details.
// Copyright 2023-2024 - Aptivi. Licensed under the Apache-2.0 license. See the LICENSE file for more details.
//
// Textify Copyright (C) 2023-2024 Aptivi
//
// This file is part of Textify
//
// Textify is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Textify is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY, without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
//

using Microsoft.VisualStudio.TestTools.UnitTesting;
using Shouldly;
using Textify.Figlet.Utilities;

namespace Textify.Figlet.Tests;

public class StringPoolTest
namespace Textify.Figlet.Tests
{
[TestMethod]
public void PoolsReferences()
public class StringPoolTest
{
var pool = new StringPool();
[TestMethod]
public void PoolsReferences()
{
var pool = new StringPool();

var s1 = "s";
var s2 = "S".ToLower();
var s1 = "s";
var s2 = "S".ToLower();

Assert.AreNotSame(s1, s2);
s2.ShouldBe(s1);
Assert.AreNotSame(s1, s2);
s2.ShouldBe(s1);

Assert.AreSame(s1, pool.Pool(s1));
Assert.AreSame(s1, pool.Pool(s1));
Assert.AreSame(s1, pool.Pool(s2));
Assert.AreSame(s1, pool.Pool(s2));
Assert.AreSame(s1, pool.Pool(s1));
Assert.AreSame(s1, pool.Pool(s1));
Assert.AreSame(s1, pool.Pool(s2));
Assert.AreSame(s1, pool.Pool(s2));
}
}
}
46 changes: 30 additions & 16 deletions Textify.Figlet/FigletException.cs
Original file line number Diff line number Diff line change
@@ -1,23 +1,37 @@
// Copyright Drew Noakes. Licensed under the Apache-2.0 license. See the LICENSE file for more details.
// Copyright 2023-2024 - Aptivi. Licensed under the Apache-2.0 license. See the LICENSE file for more details.


// Copyright Drew Noakes. Licensed under the Apache-2.0 license. See the LICENSE file for more details.
// Copyright 2023-2024 - Aptivi. Licensed under the Apache-2.0 license. See the LICENSE file for more details.
//
// Textify Copyright (C) 2023-2024 Aptivi
//
// This file is part of Textify
//
// Textify is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Textify is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY, without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
//

using System;

namespace Textify.Figlet;

/// <summary>
/// Type for exceptions raised by Figlet.
/// </summary>
public sealed class FigletException : Exception
namespace Textify.Figlet
{
/// <summary>
/// Constructs a new Figlet exception.
/// Type for exceptions raised by Figlet.
/// </summary>
/// <param name="message">A message explaining the exception.</param>
public FigletException(string message) : base(message)
{ }
public sealed class FigletException : Exception
{
/// <summary>
/// Constructs a new Figlet exception.
/// </summary>
/// <param name="message">A message explaining the exception.</param>
public FigletException(string message) :
base(message)
{ }
}
}
Loading

0 comments on commit 9437128

Please sign in to comment.