| Age | Commit message (Collapse) | Author |
|
Using diff Unified improve the test output readability when two large
strings are not match.
|
|
|
|
The Helper method mark the Assert function as test helper, which when
printing file and line information, the stack trace from Assert function
will be skipped.
This remove manual lines skipping that previously we have.
|
|
|
|
There are several reasons that why we move from github.com.
First, related to the name of package.
We accidentally name the package with "share" a common word in English
that does not reflect the content of repository.
By moving to other repository, we can rename it to better and unique
name, in this "pakakeh.go".
Pakakeh is Minang word for tools, and ".go" suffix indicate that the
repository related to Go programming language.
Second, supporting open source.
The new repository is hosted under sourcehut.org, the founder is known
to support open source, and all their services are licensed under AGPL,
unlike GitHub that are closed sources.
Third, regarding GitHub CoPilot.
The GitHub Terms of Service [1], allow any public content that are hosted
there granted them to parse the content.
On one side, GitHub helps and flourish the open source, but on another
side have an issues regarding scraping the copyleft license [2].
[1]: https://docs.github.com/en/site-policy/github-terms/github-terms-of-service#4-license-grant-to-us
[2]: https://githubcopilotinvestigation.com
|
|
The name TestWriter is considered stutter if its called from external
package, test.TestWriter.
While at it, implement the Error and Errorf in BufferWriter and add
comment to each exported methods.
|
|
The documentation is based on the article published at
https://kilabit.local/journal/2023/go_test_data/
after reviewing and explain how to use both of them to public.
|
|
The idea is to prevent using non-exported function in example.
Case in point, in this changes the testWriter is used in example and
not exported which make our test not runnable on public website.
To fix that we export TestWriter with this changes.
|
|
While at it, update the CHANGELOG to add that previous changes.
|
|
In the output, instead of using %q we replace it with %s, because printing
string with double quote cause escaping and hard to read
This change may cause difference in white spaces not showed in the
terminal.
In the diff changes, only print the Old and New, without printing each
chunk.
|
|
While at it, update the Assert documentation by describing output lines
after "----" and "++++".
|
|
If both exp and got types are string and its longer than 50 chars, it
will use the text/diff.Text to show the difference between them.
The diff output is as follow,
!!! string not matched:
--++
<LINE_NUM> - "<LINE_EXP>"
<LINE_NUM> + "<LINE_GOT>"
^<COL_NUM> - "<DELETED_STRING>"
^<COL_NUM> + "<INSERTED_STRING>"
The "<LINE_NUM> - " print the line number in exp followed by line itself.
The "<LINE_NUM> + " print the line number in got followed by line itself.
The "^<COL_NUM> - " show the character number in exp line followed by
deleted string (or string that not exist in got).
The "^<COL_NUM> + " show the character number in got line followed by
inserted string (or string that not exist in exp).
|
|
Since we only need to call Log and Fatalf during Assert, no need to pass
the whole instance of testing.T to Assert.
By changing it to Writer, we also can test the Assert.
This remove the AssertBench, because it have the same function
parameters and body as Assert.
|
|
|
|
Previously, the test.Assert and test.AssertBench functions has the
boolean parameter to print the stack trace of test in case its not equal.
Since this parameter is not mandatory and its usually always set to
"true", we remove them from function signature to simplify the call
to Assert and AssertBench.
|
|
The new Assert function use the reflect.DoEqual that return an error
which describe which field have unmatched value.
This changes affect other test that use "false" as the last parameter.
|
|
The IsEqual() function is like reflect.DeepEqual but its check if a
struct have method "IsEqual", if its exist it will call the method to
compare the value.
|
|
If the exp parameter implement the extended "reflect.Equaler" interface
then it will use the method IsEqual() with "got" as parameter.
|
|
Following CodeReviewComments on Go wiki about Useful Test Failures [1],
the common idiom here is that the actual value is printed first followed
by the expected value.
[1] https://github.com/golang/go/wiki/CodeReviewComments#useful-test-failures
|
|
|
|
|
|
Previous benchmark result (22dcd07 Move buffer to reader),
BenchmarkParse-2 500 19534400 ns/op 4656335 B/op 81163 allocs/op
New benchmark result,
BenchmarkParse-2 20000 71120 ns/op 35368 B/op 549 allocs/op
|
|
|
|
|