Testing | period-go | Spatie       

 SPATIE  

period-go
=========

spatie.be/open-source

  [Docs](https://spatie.be/docs)  [Period-go](https://spatie.be/docs/period-go/v1)  Testing

 Version   v1      

 Other versions for crawler [v1](https://spatie.be/docs/period-go/v1) 

  Testing    
- [ Introduction ](https://spatie.be/docs/period-go/v1/introduction)
- [ Installation and setup ](https://spatie.be/docs/period-go/v1/installation-and-setup)
- [ Usage ](https://spatie.be/docs/period-go/v1/usage)
- [ Testing ](https://spatie.be/docs/period-go/v1/testing)
- [ Releasing ](https://spatie.be/docs/period-go/v1/releasing)
- [ Changelog ](https://spatie.be/docs/period-go/v1/changelog)
- [ Support us ](https://spatie.be/docs/period-go/v1/support-us)

 Testing
=======

Run `go test -race ./...` to execute the tests and examples. Run `go vet ./...` for static checks and `go mod tidy -diff` to check dependency metadata. Format code with `gofmt -w .`.

The tests cover every precision and boundary style, ordered collection operations, custom iterators, fractional constructor dates, month overflow, repeated hours, mixed locations and thirteen historical missing or repeated midnights.

The nonempty set-operation fuzz test compares overlap, subtraction, symmetric difference and union to an independent bitset of UTC days:

```
go test -run '^$' -fuzz FuzzSetOperations -fuzztime=30s
```

The port was checked against [the PHP source at e101b29](https://github.com/spatie/period/commit/e101b29f6620a86723b9f8110c3a1d107a9dc298). A development comparison exercised 10,000 generated three-period cases across six precisions and seven timezones. All fifteen outputs per case matched PHP, including original and included endpoints, length, directional duration fields, duration equality and ordering, renewal, overlaps, gaps, single and multiple subtractions, symmetric difference, union and collection intersections. This comparison does not replace the permanent regression tests, and it is not a claim about every possible timezone history or date.

[The Rust port](https://github.com/spatie/period-rust) supplied additional reference cases for calendar iteration, empty subtraction fragments and mixed-location ties. PHP remains authoritative where the ports differ, including duration equality's total-day shortcut. Go-specific parsing and slice behaviour are described in [usage](usage).

 A good
match?
-------------

### What we do best

- All things Laravel
- Custom frontend components
- Building APIs
- AI-powered features
- Simplifying things
- Clean solutions
- Integrating services

### Not our cup of tea

- WordPress themes
- Cutting corners
- Free mockups to win a job
- "Just execute the briefing"

 In short: we'd like to be a **substantial part** of your project.

 [ Get in touch via email ](mailto:info@spatie.be?subject=A%20good%20match%21&body=Tell%20us%20as%20much%20as%20you%20can%20about%0A-%20your%20online%20project%0A-%20your%20planning%0A-%20your%20budget%0A-%20%E2%80%A6%0A%0AAnything%20that%20helps%20us%20to%20start%20straightforward%21)
