Commit Graph

307 Commits

Author SHA1 Message Date
Oliver Booth b2a27cdafb
fix(test): fix Clear unit test not creating the temp directory 2023-04-01 17:06:19 +01:00
Oliver Booth 35113fac27
test: run tests for .NET 7, 6, and Core 3.1
.NET Core 3.1 allows testing of the .NET Standard 2.1 implementation of X10D
2023-04-01 17:05:46 +01:00
Oliver Booth dd325ba5c9
test: test Equals(object) for various Drawing types
This brings coverage to 100% for the affected types.
2023-04-01 00:30:51 +01:00
Oliver Booth 8b768f824c
test: add tests for Point.IsOnLine and PointF.IsOnLine 2023-04-01 00:30:04 +01:00
Oliver Booth 6e7e162ffe
test: 100% coverage on MultiplicativePersistence 2023-03-31 23:19:21 +01:00
Oliver Booth 3d2baf595b
test: 100% coverage on Wrap for all types 2023-03-31 20:37:50 +01:00
Oliver Booth 3f47a4ec44
[ci skip] test: rename Pack8Bit to PackByte 2023-03-31 20:23:56 +01:00
Oliver Booth 62034ded75
style(test): segment methods to partials
This changes introduces the Moq package to create mocked objects implementing IDisposable, rather than defining a concrete class.
2023-03-31 20:21:17 +01:00
Oliver Booth f293f247e7
[ci skip] style: remove unused using directives 2023-03-31 20:18:01 +01:00
Oliver Booth 708207305c
test: use fixed point of reference for Age tests 2023-03-31 20:15:59 +01:00
Oliver Booth 3734965757
test: bring coverage to 94% for RuneExtensions 2023-03-31 20:11:03 +01:00
Oliver Booth e852726b66
test: 100% coverage on Enumerable and String methods in Text namespace 2023-03-31 18:53:08 +01:00
Oliver Booth 369882c1e8
[ci skip] style: remove unused using directives 2023-03-31 18:52:12 +01:00
Oliver Booth 275d98fbf8
feat: add LowestCommonMultiple for built-in integer types
This was previously incorrectly documented in CHANGELOG.md. The method now exists. Sorry about that
2023-03-31 18:07:50 +01:00
Oliver Booth 9ee99d72d3
[ci skip] style: upgrade projects to C# 11
NB: While using a higher C# version with lower framework version is possible, it's generally advised against because C# syntax may map to .NET types not available in older versions such as .NET Standard 2.1.

This change does not invite the codebase to upgrade to newer types, but rather take advantage of syntax sugar (such as file-scoped namespaces, when this project was updated to C# 10) that does not effect the compiled result.

However, this change does open up the possibilities to add extension methods for the "generic math" interfaces (made possible by static interface members), and these upcoming methods will be targeted to .NET 7 or greater **ONLY**.
2023-03-31 17:30:30 +01:00
Oliver Booth 4cd669a200
[ci skip] fix(test): force enumeration of lazy enumerable 2023-03-31 15:11:50 +01:00
Oliver Booth 14e638e6d9
feat: add IEnumerable<T>.ConcatOne 2023-03-31 14:53:02 +01:00
Oliver Booth cd4c3542f7
fix: use intrinsic convention for ToVector3 2023-03-31 01:31:19 +01:00
Oliver Booth 4c62367303
test: cover Span<char> overloads of CountSubstring 2023-03-30 21:22:45 +01:00
Oliver Booth f30c052673
test: 100% coverage for TimeSpanParser.TryParse 2023-03-30 20:44:45 +01:00
Oliver Booth 628ead1ebb
test: add tests for GetIso8601WeekOfYear 2023-03-30 20:44:32 +01:00
Oliver Booth 76810408f2
[ci skip] style(test): suppress IteratorNeverReturns warning 2023-03-30 20:18:17 +01:00
Oliver Booth 3ce8d281b7
feat: add TextReader.EnumerateLines/Async 2023-03-30 17:55:41 +01:00
Oliver Booth 4f3f791948
[ci skip] test: assert ArgumentNullException from Grep 2023-03-30 17:49:00 +01:00
Oliver Booth d0f94a6493
feat: add IEnumerable<string>.Grep() 2023-03-30 17:29:54 +01:00
Oliver Booth f49188b428
feat: add string.EnsureEndsWith and string.EnsureStartsWith 2023-03-30 02:09:04 +01:00
Oliver Booth f5b53cd3f6
[ci skip] test: remove netstandard2.1 from test csproj 2023-03-29 17:55:00 +01:00
Oliver Booth 4dd31ec1b6
[ci skip] style: reformat & cleanup solution 2023-03-29 17:46:56 +01:00
Oliver Booth 436f56d912
feat: add Saturate for floating point types (#60) 2023-03-29 16:21:16 +01:00
Oliver Booth 121c3a388a
test: 100% coverage on EnumerableExtensions 2023-03-28 16:28:38 +01:00
Oliver Booth 9bb9c9692a
tests: 100% coverage on Circle and CircleF 2023-03-28 16:09:35 +01:00
Oliver Booth 3e4d9603c0
test: cover Color.Deconstruct 2023-03-28 15:54:06 +01:00
Oliver Booth 3121b23732
fix(tests): fix incorrect timezone offset for DST 2023-03-28 14:54:11 +01:00
Oliver Booth 55cae2f454
test: update test project dependencies
- Microsoft.NET.Test.Sdk 17.5.0
- MSTest.* 3.0.2
- coverlet.collector 3.2.0
2023-03-28 14:54:11 +01:00
Oliver Booth 3b85419da3
Add MinMax and MinMaxBy (resolves #72) 2023-03-26 17:03:40 +01:00
RealityProgrammer 77b0a8ca39 Move some intrinsic methods around, reimplement RuneExtensions.Repeat(Rune, Int32) 2023-03-14 21:18:01 +07:00
Oliver Booth a685d6ec39
Merge branch 'develop' into main 2023-03-07 17:30:15 +00:00
RealityProgrammer e176f65e97 Commit git's untracked files 2023-03-07 16:50:04 +07:00
RealityProgrammer 6f343cd393 Fast Int16 packing 2023-03-07 08:58:53 +07:00
RealityProgrammer 5e4044f965 Code fixup, fast Int8 packing 2023-03-06 10:39:58 +07:00
Oliver Booth 799bc77ec8
Add IsEmpty/IsWhiteSpace and IsNullOrEmpty/WhiteSpace for string 2023-02-28 19:05:03 +00:00
Oliver Booth 041181cc5a
Add IEnumerable<T?>.WhereNotNull() 2023-02-27 21:11:37 +00:00
Oliver Booth d1959f4ba6
[ci skip] Add unit tests for IsOnLine 2023-02-27 17:05:59 +00:00
Oliver Booth 3fc2e7259e
Add Random.NextFrom([ReadOnly]Span<T>) 2023-02-27 13:15:20 +00:00
Oliver Booth d1454a1170
[ci skip] Add unit tests for ScaleRange
Add Aggressive implementations, and annotate as Pure
2023-02-26 13:33:01 +00:00
Oliver Booth 795d696eca
Add GammaToLinear and LinearToGamma (#60) 2023-02-26 13:10:59 +00:00
Oliver Booth ca1b1ccbf2
Add GreatestCommonFactor for built-in integer types 2023-02-26 12:25:50 +00:00
Oliver Booth d461c464df
Rewrite TimeSpanParserTests
The tests previously worked on the assumption that TryParse would throw an exception on null argument. This was changed with 94a841b2fc but the tests were not updated to reflect that
2023-02-26 00:46:01 +00:00
Oliver Booth d9cf9c8db5
Add Nullable<T>.TryGetValue (resolves #61) 2023-02-26 00:35:22 +00:00
Oliver Booth 35591b05e2
Add ReadOnlySpan<char> overload for TimeSpanParser
Also tidies up the code here to reduce complexity
2022-12-22 20:19:52 +00:00
Oliver Booth 9d6dbaaa23
Add Quaternion.ToAxisAngle and Quaternion.ToVector3 2022-12-06 01:08:35 +00:00
Oliver Booth b60fdc495b
Add IReadOnlyList<T>.Slice 2022-12-01 13:51:30 +00:00
Oliver Booth e02fd3b1b4
Add IReadOnlyList<T>.IndexOf 2022-12-01 12:28:33 +00:00
Oliver Booth 9c2f77b203
Remove invalid DirectoryInfo.Clear test 2022-12-01 12:28:05 +00:00
Oliver Booth 7776138909
Remove calls to no-longer-existing Clear(bool) 2022-11-29 17:27:33 +00:00
Oliver Booth 271305b056
Add .NET 7 target 2022-11-29 15:51:22 +00:00
Oliver Booth 53e8b2ff64
Repurpose Span<T>.Split to accept generic 2022-11-29 12:39:34 +00:00
Oliver Booth ed8651172b
Add [ReadOnly]Span<char>.Split
This commit also migrates CountSubstring from StringExtensions to CharSpanExtensions
2022-11-28 02:59:46 +00:00
Oliver Booth 9cce13727d
Add CountSubstring 2022-11-26 09:31:36 +00:00
Oliver Booth 3847d53120
Add more LINQ-esque methods
* IEnumerable<T>.CountWhereNot(Func<T, bool>)
* IEnumerable<T>.FirstWhereNot(Func<T, bool>)
* IEnumerable<T>.FirstWhereNotOrDefault(Func<T, bool>)
* IEnumerable<T>.LastWhereNot(Func<T, bool>)
* IEnumerable<T>.LastWhereNotOrDefault(Func<T, bool>)
* IEnumerable<T>.WhereNot(Func<T, bool>)
2022-07-30 23:53:35 +01:00
Oliver Booth 02765b8b19
Add IList<T>.Swap (#62) 2022-07-14 10:22:37 +01:00
Oliver Booth c0395feba3
Add GetClosestConsoleColor (#66) 2022-07-13 14:18:12 +01:00
Oliver Booth 46bfa17b93
Add vector and point component rounding (#65) 2022-07-13 12:09:37 +01:00
Oliver Booth b1eadf61f4
Add PopCount for built-in integer types 2022-07-08 13:09:34 +01:00
Oliver Booth 2e8626a32b
Add DirectoryInfo.Clear (#63) 2022-06-21 13:57:20 +01:00
Oliver Booth 3d896ea5d1
Add IList<T>.RemoveRange(Range) 2022-06-03 11:53:40 +01:00
Oliver Booth 3b78235957
Add tests for 3D shapes 2022-06-01 19:43:52 +01:00
Oliver Booth f02de2ad14
Refer to points as vertices in unit tests 2022-06-01 19:43:24 +01:00
Oliver Booth 0b3bf01fa0
Convert Polygon/F to class
This change also now refers to "Points" as "Vertices"
2022-06-01 18:30:48 +01:00
Oliver Booth b0cce087b3
Add additional ctor overloads for Ellipse/F 2022-06-01 17:05:25 +01:00
Oliver Booth ea56f2be48
Add Line3D 2022-06-01 16:47:03 +01:00
Oliver Booth b666b272a1
Add missing unit tests, bumps coverage to 99% 2022-06-01 15:36:45 +01:00
Oliver Booth 5e835e10f1
Add Ellipse struct 2022-06-01 15:36:18 +01:00
Oliver Booth b5227f58d3
Code cleanup for X10D.Tests 2022-06-01 15:35:00 +01:00
Oliver Booth e9b0ed08d4
Add primitive 2D structs to complement System.Drawing types 2022-06-01 13:46:22 +01:00
Oliver Booth f35f398d7f
Add conversions between Size(F)/Point(F)/Vector and Rect/Rectangle(F) 2022-05-28 14:19:46 +01:00
Oliver Booth 7ca206721b
Add MathUtility.InverseLerp (#60) 2022-05-23 10:33:52 +01:00
Oliver Booth 683e02cc2a
Add RoundUpToPowerOf2 2022-05-18 11:55:47 +01:00
Oliver Booth d312d05f7a
Add vector tuple deconstruction 2022-05-16 10:30:55 +01:00
Oliver Booth 23e07b65b8
Add [ReadOnly]Span<T>.Count(Predicate<T>) 2022-05-12 13:52:04 +01:00
Oliver Booth 4d19e2f64c
Add Vector.With* methods (resolves #56) 2022-05-09 10:33:21 +01:00
Oliver Booth d904daf431
Add Color.With* methods (resolves #55) 2022-05-09 10:01:03 +01:00
Oliver Booth 176ad9fa09
[ci skip] Define colors as fields 2022-05-09 09:59:03 +01:00
Oliver Booth aa30abea93
Add Color.Inverted (#54) 2022-05-08 19:52:49 +01:00
Oliver Booth d405faf6e2
Add IsEmoji method
Emoji validation is performed by using a regex which is generated from Twemoji. Source: https://raw.githubusercontent.com/twitter/twemoji-parser/master/src/lib/regex.js
2022-05-07 23:37:14 +01:00
Oliver Booth ed2920f8a0
Multi-target X10D.Tests 2022-05-07 23:16:06 +01:00
Oliver Booth 39ccf1f198
Denote CLS-noncompliant tests as such 2022-05-07 23:14:07 +01:00
Oliver Booth 0e726e9cd8
Cast sbyte values
Rename test file to SByteTests.cs
2022-05-07 23:12:28 +01:00
Oliver Booth adf2281f21
Add DisposeAll(Async) and ClearAndDisposeAll(Async) 2022-05-02 22:31:09 +01:00
Oliver Booth fd53b41610
Move EnumerableTests to Collections namespace 2022-05-02 22:27:21 +01:00
Oliver Booth 5d3a82a33a
Add IEnumerable<T>.For and ForEach (#50) 2022-05-01 22:25:37 +01:00
Oliver Booth 6505299c00
Move Stream extensions to IO namespace (#7)
* Finalizes unit tests, 99% coverage
* Update CHANGELOG
2022-04-30 13:52:34 +01:00
Oliver Booth a6139a5720
Migrate string extensions to appropriate namespaces (#7)
Introduces more tests
2022-04-30 13:08:39 +01:00
Oliver Booth c13cc934b6
Move ListOfByteExtensions to IO namespace
Also introduces unit tests
2022-04-30 11:59:03 +01:00
Oliver Booth 5d5bc1e384
Add tests for NextUnitVector2/3 and NextRotation(Uniform) 2022-04-30 11:34:15 +01:00
Oliver Booth 8ba5a5ad19
Remove empty lines and unnecessary namespace imports 2022-04-30 11:33:48 +01:00
Oliver Booth a7631b0efe
Add MultiplicativePersistence for integer types 2022-04-30 11:29:09 +01:00
Oliver Booth 3ae2827fd5
Fix precision errors by specifying delta 1e-6 2022-04-30 11:07:57 +01:00
Oliver Booth 7577fc1c99
"Fix" weird edge-case with Atanh returning incorrect value 1x10^-16 2022-04-30 10:41:27 +01:00
Oliver Booth 14148f751a
Add tests for ToConnectionString/ToGetParameters 2022-04-30 10:36:03 +01:00
Oliver Booth 2547d4a227
Add comprehensive math tests
Introduces extension methods for decimal
2022-04-30 10:15:36 +01:00
Oliver Booth 8d4f82e964
Remove Lerp extension methods
These extension methods lead to confusion with the parameter order, and so the advice now is to simply use MathUtility.Lerp directly
2022-04-29 23:24:59 +01:00
Oliver Booth 155a604812
Add FromUnixTime(Milli)Seconds for unsigned types 2022-04-29 23:21:00 +01:00
Oliver Booth cacdf148d5
Add RotateLeft and RotateRight for integer types 2022-04-29 23:16:37 +01:00
Oliver Booth 06413fd710
Add comprehensive IsPrime tests 2022-04-29 21:57:41 +01:00
Oliver Booth 9006bdffa2
Add IDictionary.AddOrUpdate 2022-04-29 18:10:41 +01:00
Oliver Booth d1de1625f2
Move ToHost/NetworkOrder to Net namespace (#7) 2022-04-29 17:45:43 +01:00
Oliver Booth 0f40bb2e31
[ci skip] Update MSTest 2.2.10 2022-04-29 11:24:56 +01:00
Oliver Booth e7bdb20b19
Add tests for reflection extensions 2022-04-29 11:17:02 +01:00
Oliver Booth dc3de3816e
Add T.RepeatValue(int) 2022-04-29 11:16:44 +01:00
Oliver Booth 5251408b15
Rename local IEnumerable to "enumerable" 2022-04-29 11:14:33 +01:00
Oliver Booth ba6c400a79
Rename UnpackBits to Unpack, PacknBit to Pack(CLR type) 2022-04-28 22:58:58 +01:00
Oliver Booth ef9c186684
Add IsLeapYear for DateTime(Offset) and numeric types 2022-04-28 10:27:32 +01:00
Oliver Booth e08274189a
Add Pack/Unpack bits
Allows a bool list (no more than 64 in length) to be packed to an integer, which can be unpacked again
2022-04-28 09:47:48 +01:00
Oliver Booth b743adb445
Rename n.To(n) to n.RangeTo(n) 2022-04-27 21:58:46 +01:00
Oliver Booth d672032c44
[ci skip] Remove redundant GetBytes tests in /Core 2022-04-26 11:06:17 +01:00
Oliver Booth 5a88a06551
[ci skip] Move AsArrayValue tests to CoreTests 2022-04-26 11:04:09 +01:00
Oliver Booth f7f3ea71bb
Append "Value" to AsArray/AsEnumerable, to reduce risk of LINQ collision 2022-04-26 10:45:18 +01:00
Oliver Booth 38ae5b0b7e
Move EnumExtensions to Core namespace (#7) 2022-04-26 10:22:59 +01:00
Oliver Booth 40a75e62c0
Add NextColorRgb and NextColorArgb 2022-04-26 09:55:08 +01:00
Oliver Booth 433d365a89
Move IO-related bool extensions to IO namespace (#7) 2022-04-25 22:26:22 +01:00
Oliver Booth 2ead3cbb8a
Add exhaustive Random tests
Introduces NextInt16 and NextByte
2022-04-25 22:14:11 +01:00
Oliver Booth c4abef7be6
Move IO related methods to IO namespaces (#7)
Also renames more tests to be more meaningful
2022-04-25 17:09:49 +01:00
Oliver Booth 907687a883
[ci skip] Use more meaningful test names for EndPointTests 2022-04-25 10:34:49 +01:00
Oliver Booth 9a089a9ae2
Declare sliced Fill for IList<T> not T[] 2022-04-25 10:34:17 +01:00
Oliver Booth 1f9bbe9319
Capitalize IP acronym 2022-04-25 10:21:55 +01:00
Oliver Booth 7fb9459a91
Add tests for IsEven/IsOdd/DigitalRoot 2022-04-25 00:02:08 +01:00
Oliver Booth b4f09e0a94
Move math-related extensions to Math namespace (#7) 2022-04-24 11:04:30 +01:00
Oliver Booth 2c2de1e30e
Add unsupported EndPoint tests
Satisfies 100% coverage
2022-04-24 10:48:16 +01:00
Oliver Booth 199b82b9a6
Fix nullability of AsEnumerable return type 2022-04-24 10:29:04 +01:00
Oliver Booth e2a496face
Add tests for DateTime/Offset 2022-04-24 10:28:50 +01:00
Oliver Booth 30e925cdb0
Move additional methods into child namespaces (#7) 2022-04-24 10:09:56 +01:00
Oliver Booth 154a5566a8
Add Rune.Repeat 2022-04-23 12:38:19 +01:00
Oliver Booth 346fc72d5e
Move text-based char extensions to Text namespace (#7) 2022-04-23 12:37:49 +01:00
Oliver Booth 76191cb43a
[ci skip] Add additional Stream tests 2022-04-23 11:38:20 +01:00
Oliver Booth 68d1ea6f4d
[ci skip] Reduce chance of Shuffle tests failing
A list containing 5 elements has a 1/(5!) (1/120) chance of being shuffled to the same order. This was causing unit tests to fail locally by pure fluke. Tests now generate a list from 1-52, which has a 1/(52!) chance of shuffling to the same order, so the chance is basically 0. If these tests ran once per second, it would take 1.9x10^50 * age of the universe to hit a collision.

This still can happen. Randomness does not guarantee we won't hit the same order. The odds are just so astronomically small that it's not worth considering. And if the CI run fails due to these tests failing, just re-run them anyway and call it a day
2022-04-23 11:25:09 +01:00
Oliver Booth 224e465915
Move math-related extensions to Math namespace (#7) 2022-04-23 11:14:20 +01:00
Oliver Booth 7d227ad2a8
Added Factorial method 2022-04-23 10:21:07 +01:00
Oliver Booth cfa27e0b4f
Move GetHash to child namespace (#7)
Also introduces TryWriteHash
2022-04-22 12:16:34 +01:00
Oliver Booth ae24d94da2
Add tests for AsArray/AsEnumerable 2022-04-22 09:42:58 +01:00
Oliver Booth 47f1489cbb
Add string.FromJson T.ToJson 2022-04-22 09:42:37 +01:00
Oliver Booth a5df7a9ee8
Move Extensions to Core namespace 2022-04-22 09:28:03 +01:00
Oliver Booth f961530962
[ci skip] fix product formula in overflow comment 2022-04-22 09:12:35 +01:00
Oliver Booth 6a1f64f042
Move IEnumerable.Product tests to Linq namespace (#7) 2022-04-22 09:11:18 +01:00
Oliver Booth d5a74c12a8
Move Span.Any/All to Linq namespace (#7) 2022-04-22 08:50:06 +01:00
Oliver Booth 0fb01726db
Add tests for Enumerable/List 2022-04-21 22:35:06 +01:00
Oliver Booth 118eeae46a
Remove _ from test names 2022-04-21 22:31:32 +01:00
Oliver Booth 4096265006
Move LINQ-inspired methods to child namespaces (#7) 2022-04-21 22:27:24 +01:00
Oliver Booth a95b8fe3da
[ci skip] Remove unnecessary namespace import 2022-04-21 22:09:36 +01:00
Oliver Booth e421b357fd
[ci skip] Add IpAddressTests 2022-04-21 21:44:24 +01:00