-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add - prt|brk|doc - Initial movement of Figletize to Textify.Figlet
--- 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
Showing
18 changed files
with
2,133 additions
and
1,975 deletions.
There are no files selected for viewing
905 changes: 461 additions & 444 deletions
905
Textify.Figlet.Generator.Tests/FigletSourceGeneratorTests.cs
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
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,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"); | ||
} | ||
} |
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,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)); | ||
} | ||
} | ||
} |
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,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) | ||
{ } | ||
} | ||
} |
Oops, something went wrong.