BytePattern a linear time byte pattern finder and set of XCTest assertions

I present BytePattern - a linear time byte pattern finder. It is a small library to help identifying that two byte sequence "probably" are equal to each other, but where programmer (me me me) have got some small detail wrong.

This is convenient when working with data where the underlying data might represent integers but the programmer got endianness or order of ints wrong etc.

The idea os that it can be used as part of your test suite and/or dev process, to help you identity that you almost got some nebulous byte handling right.

Please come with feedback on API, Documentation and implementation :)

Thank you!

3 Likes

Just made a new release 0.0.2, with two new XCTest assertion functions using the BytePatternFinder, linked to in README:

func test_nonIdentical_but_passing() {
    XCTAssertBytesFromHexEqual(
        "ab12 cd34",
        "12ab 34cd",
        passOnPatternNonIdentical: true
    )
}

Hello, I was reading your code and I have a question about the usage of this subscript ([...]). Is that being used to copy the value of the hexString variable or does it have a different purpose? Thanks.

It turns the string into a substring, so that I can use assignment from dropFirst below.

1 Like