0
Fork 0
mirror of https://codeberg.org/ziglang/zig synced 2026-11-18 07:05:05 +00:00
zig/lib/std/testing.zig

1304 lines
49 KiB

2021-05-04 19:36:59 +03:00
2021-05-04 19:36:59 +03:00
2021-05-04 19:36:59 +03:00
2021-05-04 19:36:59 +03:00
2021-05-04 19:36:59 +03:00
2021-05-04 19:36:59 +03:00
2021-05-04 19:36:59 +03:00
2021-05-04 19:36:59 +03:00
2021-05-04 19:36:59 +03:00
2021-05-04 19:36:59 +03:00
2021-05-04 19:36:59 +03:00
2021-05-04 19:36:59 +03:00
2021-05-04 19:36:59 +03:00
2021-05-04 19:36:59 +03:00
2021-05-04 19:36:59 +03:00
2021-05-04 19:36:59 +03:00
2021-05-04 19:36:59 +03:00
2020-06-23 18:05:32 +02:00
2020-06-23 18:05:32 +02:00
2021-05-04 19:36:59 +03:00
2020-06-23 18:05:32 +02:00
2021-05-04 19:36:59 +03:00
2020-06-23 18:08:15 +02:00
2020-06-23 18:08:15 +02:00
2021-05-04 19:36:59 +03:00
2020-06-23 18:08:15 +02:00
2020-12-08 21:54:46 -07:00
2021-05-04 19:36:59 +03:00
2021-05-04 19:36:59 +03:00
2019-12-22 06:37:25 +05:00
std/base64: cleanups & support url-safe and other non-padded variants This makes a few changes to the base64 codecs. * The padding character is optional. The common "URL-safe" variant, in particular, is generally not used with padding. This is also the case for password hashes, so having this will avoid code duplication with bcrypt, scrypt and other functions. * The URL-safe variant is added. Instead of having individual constants for each parameter of each variant, we are now grouping these in a struct. So, `standard_pad_char` just becomes `standard.pad_char`. * Types are not `snake_case`'d any more. So, `standard_encoder` becomes `standard.Encoder`, as it is a type. * Creating a decoder with ignored characters required the alphabet and padding. Now, `standard.decoderWithIgnore(<ignored chars>)` returns a decoder with the standard parameters and the set of ignored chars. * Whatever applies to `standard.*` obviously also works with `url_safe.*` * the `calcSize()` interface was inconsistent, taking a length in the encoder, and a slice in the encoder. Rename the variant that takes a slice to `calcSizeForSlice()`. * In the decoder with ignored characters, add `calcSizeUpperBound()`, which is more useful than the one that takes a slice in order to size a fixed buffer before we have the data. * Return `error.InvalidCharacter` when the input actually contains characters that are neither padding nor part of the alphabet. If we hit a padding issue (which includes extra bits at the end), consistently return `error.InvalidPadding`. * Don't keep the `char_in_alphabet` array permanently in a decoder; it is only required for sanity checks during initialization. * Tests are unchanged, but now cover both the standard (padded) and the url-safe (non-padded) variants. * Add an error set, rename `OutputTooSmallError` to `NoSpaceLeft` to match the `hex2bin` equivalent.
2021-03-19 19:26:30 +01:00
2021-05-04 19:36:59 +03:00
std: introduce GeneralPurposeAllocator `std.GeneralPurposeAllocator` is now available. It is a function that takes a configuration struct (with default field values) and returns an allocator. There is a detailed description of this allocator in the doc comments at the top of the new file. The main feature of this allocator is that it is *safe*. It prevents double-free, use-after-free, and detects leaks. Some deprecation compile errors are removed. The Allocator interface gains `old_align` as a new parameter to `resizeFn`. This is useful to quickly look up allocations. `std.heap.page_allocator` is improved to use mmap address hints to avoid obtaining the same virtual address pages when unmapping and mapping pages. The new general purpose allocator uses the page allocator as its backing allocator by default. `std.testing.allocator` is replaced with usage of this new allocator, which does leak checking, and so the LeakCheckAllocator is retired. stage1 is improved so that the `@typeInfo` of a pointer has a lazy value for the alignment of the child type, to avoid false dependency loops when dealing with pointers to async function frames. The `std.mem.Allocator` interface is refactored to be in its own file. `std.Mutex` now exposes the dummy mutex with `std.Mutex.Dummy`. This allocator is great for debug mode, however it needs some work to have better performance in release modes. The next step will be setting up a series of tests in ziglang/gotta-go-fast and then making improvements to the implementation.
2020-08-07 22:35:15 -07:00
std: introduce GeneralPurposeAllocator `std.GeneralPurposeAllocator` is now available. It is a function that takes a configuration struct (with default field values) and returns an allocator. There is a detailed description of this allocator in the doc comments at the top of the new file. The main feature of this allocator is that it is *safe*. It prevents double-free, use-after-free, and detects leaks. Some deprecation compile errors are removed. The Allocator interface gains `old_align` as a new parameter to `resizeFn`. This is useful to quickly look up allocations. `std.heap.page_allocator` is improved to use mmap address hints to avoid obtaining the same virtual address pages when unmapping and mapping pages. The new general purpose allocator uses the page allocator as its backing allocator by default. `std.testing.allocator` is replaced with usage of this new allocator, which does leak checking, and so the LeakCheckAllocator is retired. stage1 is improved so that the `@typeInfo` of a pointer has a lazy value for the alignment of the child type, to avoid false dependency loops when dealing with pointers to async function frames. The `std.mem.Allocator` interface is refactored to be in its own file. `std.Mutex` now exposes the dummy mutex with `std.Mutex.Dummy`. This allocator is great for debug mode, however it needs some work to have better performance in release modes. The next step will be setting up a series of tests in ziglang/gotta-go-fast and then making improvements to the implementation.
2020-08-07 22:35:15 -07:00
std: introduce GeneralPurposeAllocator `std.GeneralPurposeAllocator` is now available. It is a function that takes a configuration struct (with default field values) and returns an allocator. There is a detailed description of this allocator in the doc comments at the top of the new file. The main feature of this allocator is that it is *safe*. It prevents double-free, use-after-free, and detects leaks. Some deprecation compile errors are removed. The Allocator interface gains `old_align` as a new parameter to `resizeFn`. This is useful to quickly look up allocations. `std.heap.page_allocator` is improved to use mmap address hints to avoid obtaining the same virtual address pages when unmapping and mapping pages. The new general purpose allocator uses the page allocator as its backing allocator by default. `std.testing.allocator` is replaced with usage of this new allocator, which does leak checking, and so the LeakCheckAllocator is retired. stage1 is improved so that the `@typeInfo` of a pointer has a lazy value for the alignment of the child type, to avoid false dependency loops when dealing with pointers to async function frames. The `std.mem.Allocator` interface is refactored to be in its own file. `std.Mutex` now exposes the dummy mutex with `std.Mutex.Dummy`. This allocator is great for debug mode, however it needs some work to have better performance in release modes. The next step will be setting up a series of tests in ziglang/gotta-go-fast and then making improvements to the implementation.
2020-08-07 22:35:15 -07:00
std: introduce GeneralPurposeAllocator `std.GeneralPurposeAllocator` is now available. It is a function that takes a configuration struct (with default field values) and returns an allocator. There is a detailed description of this allocator in the doc comments at the top of the new file. The main feature of this allocator is that it is *safe*. It prevents double-free, use-after-free, and detects leaks. Some deprecation compile errors are removed. The Allocator interface gains `old_align` as a new parameter to `resizeFn`. This is useful to quickly look up allocations. `std.heap.page_allocator` is improved to use mmap address hints to avoid obtaining the same virtual address pages when unmapping and mapping pages. The new general purpose allocator uses the page allocator as its backing allocator by default. `std.testing.allocator` is replaced with usage of this new allocator, which does leak checking, and so the LeakCheckAllocator is retired. stage1 is improved so that the `@typeInfo` of a pointer has a lazy value for the alignment of the child type, to avoid false dependency loops when dealing with pointers to async function frames. The `std.mem.Allocator` interface is refactored to be in its own file. `std.Mutex` now exposes the dummy mutex with `std.Mutex.Dummy`. This allocator is great for debug mode, however it needs some work to have better performance in release modes. The next step will be setting up a series of tests in ziglang/gotta-go-fast and then making improvements to the implementation.
2020-08-07 22:35:15 -07:00
std: introduce GeneralPurposeAllocator `std.GeneralPurposeAllocator` is now available. It is a function that takes a configuration struct (with default field values) and returns an allocator. There is a detailed description of this allocator in the doc comments at the top of the new file. The main feature of this allocator is that it is *safe*. It prevents double-free, use-after-free, and detects leaks. Some deprecation compile errors are removed. The Allocator interface gains `old_align` as a new parameter to `resizeFn`. This is useful to quickly look up allocations. `std.heap.page_allocator` is improved to use mmap address hints to avoid obtaining the same virtual address pages when unmapping and mapping pages. The new general purpose allocator uses the page allocator as its backing allocator by default. `std.testing.allocator` is replaced with usage of this new allocator, which does leak checking, and so the LeakCheckAllocator is retired. stage1 is improved so that the `@typeInfo` of a pointer has a lazy value for the alignment of the child type, to avoid false dependency loops when dealing with pointers to async function frames. The `std.mem.Allocator` interface is refactored to be in its own file. `std.Mutex` now exposes the dummy mutex with `std.Mutex.Dummy`. This allocator is great for debug mode, however it needs some work to have better performance in release modes. The next step will be setting up a series of tests in ziglang/gotta-go-fast and then making improvements to the implementation.
2020-08-07 22:35:15 -07:00
2021-05-04 19:36:59 +03:00
2022-09-28 23:02:49 -04:00
2021-05-04 19:36:59 +03:00
2020-12-08 21:54:46 -07:00
2020-12-08 21:54:46 -07:00
2021-05-04 19:36:59 +03:00
2020-12-08 21:54:46 -07:00
2023-01-30 06:00:14 +08:00
2023-01-30 06:00:14 +08:00
2023-01-30 06:00:14 +08:00
2023-01-30 06:00:14 +08:00
2023-01-30 06:00:14 +08:00
2023-01-30 06:00:14 +08:00
2023-01-30 06:00:14 +08:00
2023-01-30 06:00:14 +08:00
2023-01-30 06:00:14 +08:00
2023-01-30 06:00:14 +08:00
2023-01-30 06:00:14 +08:00
2023-01-30 06:00:14 +08:00
2023-01-30 06:00:14 +08:00
2023-01-30 06:00:14 +08:00
2023-01-30 06:00:14 +08:00
2023-01-30 06:00:14 +08:00
2023-01-30 06:00:14 +08:00
2023-01-30 06:00:14 +08:00
2023-01-30 06:00:14 +08:00
2023-01-30 06:00:14 +08:00
2023-01-30 06:00:14 +08:00
2023-01-30 06:00:14 +08:00
2023-01-30 06:00:14 +08:00
2023-01-30 06:00:14 +08:00
2023-01-30 06:00:14 +08:00
2023-01-30 06:00:14 +08:00
2023-01-30 06:00:14 +08:00
2023-01-30 06:00:14 +08:00
2023-01-30 06:00:14 +08:00
2023-01-30 06:00:14 +08:00
2023-01-30 06:00:14 +08:00
2023-01-30 06:00:14 +08:00
2023-01-30 06:00:14 +08:00
2023-01-30 06:00:14 +08:00
2023-01-30 06:00:14 +08:00
2023-01-30 06:00:14 +08:00
2023-01-30 06:00:14 +08:00
2023-01-30 06:00:14 +08:00
2021-05-04 19:36:59 +03:00
2022-12-12 15:32:37 +02:00
2022-12-12 15:32:37 +02:00