|
15 | 15 |
|
16 | 16 | --> |
17 | 17 |
|
18 | | -<h1 align="center">AtomicGo | template</h1> |
| 18 | +<h1 align="center">AtomicGo | assert</h1> |
19 | 19 |
|
20 | 20 | <p align="center"> |
21 | | -<img src="https://img.shields.io/endpoint?url=https%3A%2F%2Fatomicgo.dev%2Fapi%2Fshields%2Ftemplate&style=flat-square" alt="Downloads"> |
| 21 | +<img src="https://img.shields.io/endpoint?url=https%3A%2F%2Fatomicgo.dev%2Fapi%2Fshields%2Fassert&style=flat-square" alt="Downloads"> |
22 | 22 |
|
23 | | -<a href="https://github.com/atomicgo/template/releases"> |
24 | | -<img src="https://img.shields.io/github/v/release/atomicgo/template?style=flat-square" alt="Latest Release"> |
| 23 | +<a href="https://github.com/atomicgo/assert/releases"> |
| 24 | +<img src="https://img.shields.io/github/v/release/atomicgo/assert?style=flat-square" alt="Latest Release"> |
25 | 25 | </a> |
26 | 26 |
|
27 | | -<a href="https://codecov.io/gh/atomicgo/template" target="_blank"> |
28 | | -<img src="https://img.shields.io/github/actions/workflow/status/atomicgo/template/go.yml?style=flat-square" alt="Tests"> |
| 27 | +<a href="https://codecov.io/gh/atomicgo/assert" target="_blank"> |
| 28 | +<img src="https://img.shields.io/github/actions/workflow/status/atomicgo/assert/go.yml?style=flat-square" alt="Tests"> |
29 | 29 | </a> |
30 | 30 |
|
31 | | -<a href="https://codecov.io/gh/atomicgo/template" target="_blank"> |
32 | | -<img src="https://img.shields.io/codecov/c/gh/atomicgo/template?color=magenta&logo=codecov&style=flat-square" alt="Coverage"> |
| 31 | +<a href="https://codecov.io/gh/atomicgo/assert" target="_blank"> |
| 32 | +<img src="https://img.shields.io/codecov/c/gh/atomicgo/assert?color=magenta&logo=codecov&style=flat-square" alt="Coverage"> |
33 | 33 | </a> |
34 | 34 |
|
35 | | -<a href="https://codecov.io/gh/atomicgo/template"> |
36 | | -<!-- unittestcount:start --><img src="https://img.shields.io/badge/Unit_Tests-3-magenta?style=flat-square" alt="Unit test count"><!-- unittestcount:end --> |
| 35 | +<a href="https://codecov.io/gh/atomicgo/assert"> |
| 36 | +<!-- unittestcount:start --><img src="https://img.shields.io/badge/Unit_Tests-162-magenta?style=flat-square" alt="Unit test count"><!-- unittestcount:end --> |
37 | 37 | </a> |
38 | 38 |
|
39 | 39 | <a href="https://opensource.org/licenses/MIT" target="_blank"> |
40 | 40 | <img src="https://img.shields.io/badge/License-MIT-yellow.svg?style=flat-square" alt="License: MIT"> |
41 | 41 | </a> |
42 | 42 |
|
43 | | -<a href="https://goreportcard.com/report/github.com/atomicgo/template" target="_blank"> |
44 | | -<img src="https://goreportcard.com/badge/github.com/atomicgo/template?style=flat-square" alt="Go report"> |
| 43 | +<a href="https://goreportcard.com/report/github.com/atomicgo/assert" target="_blank"> |
| 44 | +<img src="https://goreportcard.com/badge/github.com/atomicgo/assert?style=flat-square" alt="Go report"> |
45 | 45 | </a> |
46 | 46 |
|
47 | 47 | </p> |
48 | 48 |
|
49 | 49 | --- |
50 | 50 |
|
51 | 51 | <p align="center"> |
52 | | -<strong><a href="https://pkg.go.dev/atomicgo.dev/template#section-documentation" target="_blank">Documentation</a></strong> |
| 52 | +<strong><a href="https://pkg.go.dev/atomicgo.dev/assert#section-documentation" target="_blank">Documentation</a></strong> |
53 | 53 | | |
54 | 54 | <strong><a href="https://github.com/atomicgo/atomicgo/blob/main/CONTRIBUTING.md" target="_blank">Contributing</a></strong> |
55 | 55 | | |
|
68 | 68 | </tbody> |
69 | 69 | </table> |
70 | 70 | </p> |
71 | | -<h3 align="center"><pre>go get atomicgo.dev/template</pre></h3> |
| 71 | +<h3 align="center"><pre>go get atomicgo.dev/assert</pre></h3> |
72 | 72 | <p align="center"> |
73 | 73 | <table> |
74 | 74 | <tbody> |
|
80 | 80 |
|
81 | 81 | <!-- Code generated by gomarkdoc. DO NOT EDIT --> |
82 | 82 |
|
83 | | -# template |
| 83 | +# assert |
84 | 84 |
|
85 | 85 | ```go |
86 | | -import "atomicgo.dev/template" |
| 86 | +import "atomicgo.dev/assert" |
87 | 87 | ``` |
88 | 88 |
|
89 | | -Package template is used to generate new AtomicGo repositories. |
| 89 | +Package assert provides a set of assertion functions. Every assertion function returns a boolean. This package does not integrateinto the testing package automatically. If you want to use this package inside unit tests, you have to check the returning boolean value and call \`t.Fatal\(\)\` if the assertion fails. |
90 | 90 |
|
91 | | -Write the description of the module here. You can use \*\*markdown\*\*\! This description should clearly explain what the package does. |
| 91 | +This library does not provide any error messages. That way the assertions can also be used in production code. |
92 | 92 |
|
93 | | -Example description: https://golang.org/src/encoding/gob/doc.go |
| 93 | +If you want a full\-featured testing framework, we recommend https://github.com/MarvinJWendt/testza \(which uses this library for assertions\) |
94 | 94 |
|
| 95 | +## Index |
| 96 | + |
| 97 | +- [func Contains\(a any, b any\) bool](<#Contains>) |
| 98 | +- [func ContainsAll\[T any\]\(a T, v \[\]T\) bool](<#ContainsAll>) |
| 99 | +- [func ContainsAny\[T any\]\(a T, v \[\]T\) bool](<#ContainsAny>) |
| 100 | +- [func ContainsNone\[T any\]\(a T, v \[\]T\) bool](<#ContainsNone>) |
| 101 | +- [func Equal\[T any\]\(a, b T\) bool](<#Equal>) |
| 102 | +- [func Implements\(a, iface any\) bool](<#Implements>) |
| 103 | +- [func Kind\(a any, kind reflect.Kind\) bool](<#Kind>) |
| 104 | +- [func Len\(a any, length int\) \(b bool\)](<#Len>) |
| 105 | +- [func Lowercase\(s string\) bool](<#Lowercase>) |
| 106 | +- [func Nil\(a any\) bool](<#Nil>) |
| 107 | +- [func Number\(a any\) bool](<#Number>) |
| 108 | +- [func Panic\(f func\(\)\) \(panicked bool\)](<#Panic>) |
| 109 | +- [func Range\[T constraints.Number\]\(a, minimum, maximum T\) bool](<#Range>) |
| 110 | +- [func Regex\(regex, s string\) bool](<#Regex>) |
| 111 | +- [func Unique\[T any\]\(s \[\]T\) bool](<#Unique>) |
| 112 | +- [func Uppercase\(s string\) bool](<#Uppercase>) |
| 113 | +- [func Zero\(a any\) bool](<#Zero>) |
| 114 | + |
| 115 | + |
| 116 | +<a name="Contains"></a> |
| 117 | +## func [Contains](<https://github.com/atomicgo/assert/blob/main/assert.go#L108>) |
| 118 | + |
| 119 | +```go |
| 120 | +func Contains(a any, b any) bool |
| 121 | +``` |
| 122 | + |
| 123 | +Contains returns true if obj contains expectedLen. |
| 124 | + |
| 125 | +<a name="ContainsAll"></a> |
| 126 | +## func [ContainsAll](<https://github.com/atomicgo/assert/blob/main/assert.go#L128>) |
| 127 | + |
| 128 | +```go |
| 129 | +func ContainsAll[T any](a T, v []T) bool |
| 130 | +``` |
| 131 | + |
| 132 | +ContainsAll returns true if all values are contained in obj. |
| 133 | + |
| 134 | +<a name="ContainsAny"></a> |
| 135 | +## func [ContainsAny](<https://github.com/atomicgo/assert/blob/main/assert.go#L139>) |
95 | 136 |
|
| 137 | +```go |
| 138 | +func ContainsAny[T any](a T, v []T) bool |
| 139 | +``` |
96 | 140 |
|
| 141 | +ContainsAny returns true if any of the values are contained in obj. |
97 | 142 |
|
| 143 | +<a name="ContainsNone"></a> |
| 144 | +## func [ContainsNone](<https://github.com/atomicgo/assert/blob/main/assert.go#L150>) |
98 | 145 |
|
99 | 146 | ```go |
100 | | -package main |
| 147 | +func ContainsNone[T any](a T, v []T) bool |
| 148 | +``` |
101 | 149 |
|
102 | | -import ( |
103 | | - "fmt" |
| 150 | +ContainsNone returns true if none of the values are contained in obj. |
104 | 151 |
|
105 | | - "atomicgo.dev/template" |
106 | | -) |
| 152 | +<a name="Equal"></a> |
| 153 | +## func [Equal](<https://github.com/atomicgo/assert/blob/main/assert.go#L12>) |
107 | 154 |
|
108 | | -func main() { |
109 | | - fmt.Println(template.HelloWorld()) |
110 | | -} |
| 155 | +```go |
| 156 | +func Equal[T any](a, b T) bool |
111 | 157 | ``` |
112 | 158 |
|
113 | | -#### Output |
| 159 | +Equal compares two values and returns true if they are equal. |
| 160 | + |
| 161 | +<a name="Implements"></a> |
| 162 | +## func [Implements](<https://github.com/atomicgo/assert/blob/main/assert.go#L64>) |
114 | 163 |
|
| 164 | +```go |
| 165 | +func Implements(a, iface any) bool |
115 | 166 | ``` |
116 | | -Hello, World! |
| 167 | + |
| 168 | +Implements returns true if the value implements the interface. |
| 169 | + |
| 170 | +<a name="Kind"></a> |
| 171 | +## func [Kind](<https://github.com/atomicgo/assert/blob/main/assert.go#L17>) |
| 172 | + |
| 173 | +```go |
| 174 | +func Kind(a any, kind reflect.Kind) bool |
117 | 175 | ``` |
118 | 176 |
|
| 177 | +Kind returns true if the value is of the given kind. |
119 | 178 |
|
| 179 | +<a name="Len"></a> |
| 180 | +## func [Len](<https://github.com/atomicgo/assert/blob/main/assert.go#L176>) |
120 | 181 |
|
121 | | -## Index |
| 182 | +```go |
| 183 | +func Len(a any, length int) (b bool) |
| 184 | +``` |
| 185 | + |
| 186 | +Len returns true if the length of the value is equal to the given length. |
| 187 | + |
| 188 | +<a name="Lowercase"></a> |
| 189 | +## func [Lowercase](<https://github.com/atomicgo/assert/blob/main/assert.go#L166>) |
| 190 | + |
| 191 | +```go |
| 192 | +func Lowercase(s string) bool |
| 193 | +``` |
122 | 194 |
|
123 | | -- [func HelloWorld\(\) string](<#HelloWorld>) |
| 195 | +Lowercase returns true if the string is lowercase. |
124 | 196 |
|
| 197 | +<a name="Nil"></a> |
| 198 | +## func [Nil](<https://github.com/atomicgo/assert/blob/main/assert.go#L22>) |
125 | 199 |
|
126 | | -<a name="HelloWorld"></a> |
127 | | -## func [HelloWorld](<https://github.com/atomicgo/template/blob/main/template.go#L4>) |
| 200 | +```go |
| 201 | +func Nil(a any) bool |
| 202 | +``` |
| 203 | + |
| 204 | +Nil returns true if the value is nil. |
| 205 | + |
| 206 | +<a name="Number"></a> |
| 207 | +## func [Number](<https://github.com/atomicgo/assert/blob/main/assert.go#L37>) |
128 | 208 |
|
129 | 209 | ```go |
130 | | -func HelloWorld() string |
| 210 | +func Number(a any) bool |
131 | 211 | ``` |
132 | 212 |
|
133 | | -HelloWorld returns \`Hello, World\!\`. |
| 213 | +Number returns true if the value is obj number. |
134 | 214 |
|
| 215 | +<a name="Panic"></a> |
| 216 | +## func [Panic](<https://github.com/atomicgo/assert/blob/main/assert.go#L79>) |
135 | 217 |
|
| 218 | +```go |
| 219 | +func Panic(f func()) (panicked bool) |
| 220 | +``` |
136 | 221 |
|
| 222 | +Panic returns true if the function panics. |
137 | 223 |
|
| 224 | +<a name="Range"></a> |
| 225 | +## func [Range](<https://github.com/atomicgo/assert/blob/main/assert.go#L54>) |
138 | 226 |
|
139 | 227 | ```go |
140 | | -package main |
| 228 | +func Range[T constraints.Number](a, minimum, maximum T) bool |
| 229 | +``` |
141 | 230 |
|
142 | | -import ( |
143 | | - "fmt" |
| 231 | +Range returns true if the value is within the range. |
144 | 232 |
|
145 | | - "atomicgo.dev/template" |
146 | | -) |
| 233 | +<a name="Regex"></a> |
| 234 | +## func [Regex](<https://github.com/atomicgo/assert/blob/main/assert.go#L171>) |
147 | 235 |
|
148 | | -func main() { |
149 | | - fmt.Println(template.HelloWorld()) |
150 | | -} |
| 236 | +```go |
| 237 | +func Regex(regex, s string) bool |
151 | 238 | ``` |
152 | 239 |
|
153 | | -#### Output |
| 240 | +Regex returns true if the string matches the regex. |
| 241 | + |
| 242 | +<a name="Unique"></a> |
| 243 | +## func [Unique](<https://github.com/atomicgo/assert/blob/main/assert.go#L93>) |
154 | 244 |
|
| 245 | +```go |
| 246 | +func Unique[T any](s []T) bool |
155 | 247 | ``` |
156 | | -Hello, World! |
| 248 | + |
| 249 | +Unique returns true if the slice contains unique values. Items are considered unique if they are not deep equal. |
| 250 | + |
| 251 | +<a name="Uppercase"></a> |
| 252 | +## func [Uppercase](<https://github.com/atomicgo/assert/blob/main/assert.go#L161>) |
| 253 | + |
| 254 | +```go |
| 255 | +func Uppercase(s string) bool |
157 | 256 | ``` |
158 | 257 |
|
| 258 | +Uppercase returns true if the string is uppercase. |
| 259 | + |
| 260 | +<a name="Zero"></a> |
| 261 | +## func [Zero](<https://github.com/atomicgo/assert/blob/main/assert.go#L59>) |
| 262 | + |
| 263 | +```go |
| 264 | +func Zero(a any) bool |
| 265 | +``` |
159 | 266 |
|
| 267 | +Zero returns true if the value is the zero value. |
160 | 268 |
|
161 | 269 | Generated by [gomarkdoc](<https://github.com/princjef/gomarkdoc>) |
162 | 270 |
|
|
0 commit comments