diff options
author | yazevnul <yazevnul@yandex-team.ru> | 2022-02-10 16:46:46 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:46:46 +0300 |
commit | 8cbc307de0221f84c80c42dcbe07d40727537e2c (patch) | |
tree | 625d5a673015d1df891e051033e9fcde5c7be4e5 | |
parent | 30d1ef3941e0dc835be7609de5ebee66958f215a (diff) | |
download | ydb-8cbc307de0221f84c80c42dcbe07d40727537e2c.tar.gz |
Restoring authorship annotation for <yazevnul@yandex-team.ru>. Commit 1 of 2.
1750 files changed, 22656 insertions, 22656 deletions
diff --git a/build/scripts/fetch_from_sandbox.py b/build/scripts/fetch_from_sandbox.py index a99542e1743..7c67b5b2133 100755 --- a/build/scripts/fetch_from_sandbox.py +++ b/build/scripts/fetch_from_sandbox.py @@ -1,14 +1,14 @@ -import itertools -import json -import logging +import itertools +import json +import logging import argparse -import os +import os import random -import subprocess +import subprocess import sys import time -import urllib2 -import uuid +import urllib2 +import uuid import fetch_from @@ -74,25 +74,25 @@ def download_by_skynet(resource_info, file_name): return os.path.join(temp_dir, file_name) -def _urlopen(url, data=None, headers=None): +def _urlopen(url, data=None, headers=None): n = 10 - tout = 30 - started = time.time() - reqid = uuid.uuid4() - - request = urllib2.Request(url, data=data, headers=headers or {}) - request.add_header('X-Request-Timeout', str(tout)) - request.add_header('X-Request-Id', str(reqid)) - request.add_header('User-Agent', 'fetch_from_sandbox.py') + tout = 30 + started = time.time() + reqid = uuid.uuid4() + + request = urllib2.Request(url, data=data, headers=headers or {}) + request.add_header('X-Request-Timeout', str(tout)) + request.add_header('X-Request-Id', str(reqid)) + request.add_header('User-Agent', 'fetch_from_sandbox.py') for i in xrange(n): - retry_after = i + retry_after = i try: - request.add_header('X-Request-Duration', str(int(time.time() - started))) - return urllib2.urlopen(request, timeout=tout).read() + request.add_header('X-Request-Duration', str(int(time.time() - started))) + return urllib2.urlopen(request, timeout=tout).read() except urllib2.HTTPError as e: logging.warning('failed to fetch URL %s with HTTP code %d: %s', url, e.code, e) - retry_after = int(e.headers.get('Retry-After', str(retry_after))) + retry_after = int(e.headers.get('Retry-After', str(retry_after))) if e.code not in TEMPORARY_ERROR_CODES: raise @@ -103,29 +103,29 @@ def _urlopen(url, data=None, headers=None): if i + 1 == n: raise e - time.sleep(retry_after) + time.sleep(retry_after) def _query(url): return json.loads(_urlopen(url)) -_SANDBOX_BASE_URL = 'https://sandbox.yandex-team.ru/api/v1.0' +_SANDBOX_BASE_URL = 'https://sandbox.yandex-team.ru/api/v1.0' -def get_resource_info(resource_id, touch=False, no_links=False): - url = ''.join((_SANDBOX_BASE_URL, '/resource/', str(resource_id))) - headers = {} - if touch: - headers.update({'X-Touch-Resource': '1'}) - if no_links: - headers.update({'X-No-Links': '1'}) - return _query(url) +def get_resource_info(resource_id, touch=False, no_links=False): + url = ''.join((_SANDBOX_BASE_URL, '/resource/', str(resource_id))) + headers = {} + if touch: + headers.update({'X-Touch-Resource': '1'}) + if no_links: + headers.update({'X-No-Links': '1'}) + return _query(url) def get_resource_http_links(resource_id): - url = ''.join((_SANDBOX_BASE_URL, '/resource/', str(resource_id), '/data/http')) - return [r['url'] + ORIGIN_SUFFIX for r in _query(url)] + url = ''.join((_SANDBOX_BASE_URL, '/resource/', str(resource_id), '/data/http')) + return [r['url'] + ORIGIN_SUFFIX for r in _query(url)] def fetch_via_script(script, resource_id): @@ -134,7 +134,7 @@ def fetch_via_script(script, resource_id): def fetch(resource_id, custom_fetcher): try: - resource_info = get_resource_info(resource_id, touch=True, no_links=True) + resource_info = get_resource_info(resource_id, touch=True, no_links=True) except Exception as e: sys.stderr.write( "Failed to fetch resource {}: {}\n".format(resource_id, str(e)) diff --git a/build/stdafx.hpp b/build/stdafx.hpp index 98b15adda05..7933ce4cc65 100644 --- a/build/stdafx.hpp +++ b/build/stdafx.hpp @@ -289,7 +289,7 @@ #include <util/stream/input.h> #include <util/stream/trace.h> #include <util/stream/output.h> -#include <util/stream/output.h> +#include <util/stream/output.h> #include <util/stream/format.h> #include <util/stream/tee.h> #include <util/stream/multi.h> @@ -306,7 +306,7 @@ #include <util/stream/str.h> #include <util/stream/file.h> #include <util/stream/zerocopy.h> -#include <util/stream/output.h> +#include <util/stream/output.h> #include <util/random/common_ops.h> #include <util/random/shuffle.h> #include <util/random/lcg_engine.h> diff --git a/build/ya.conf.json b/build/ya.conf.json index 5f7cc875d61..9161ba03926 100644 --- a/build/ya.conf.json +++ b/build/ya.conf.json @@ -3023,14 +3023,14 @@ } ] }, - "transfer-manager": { - "tools": { + "transfer-manager": { + "tools": { "transfer-manager": { "bottle": "transfer-manager", "executable": "transfer-manager" } - }, - "platforms": [ + }, + "platforms": [ { "host": { "os": "DARWIN" @@ -3049,16 +3049,16 @@ }, "default": true } - ] - }, - "rem-tool": { - "tools": { + ] + }, + "rem-tool": { + "tools": { "rem-tool": { "bottle": "rem-tool", "executable": "rem-tool" } - }, - "platforms": [ + }, + "platforms": [ { "host": { "os": "DARWIN" @@ -3077,8 +3077,8 @@ }, "default": true } - ] - }, + ] + }, "uc": { "tools": { "uc": { @@ -3732,13 +3732,13 @@ } ] }, - "tmux": { - "tools": { + "tmux": { + "tools": { "tmux": { "bottle": "tmux", "executable": "tmux" } - }, + }, "env": { "TERMINFO": [ "$(ROOT)/share/terminfo" @@ -3752,7 +3752,7 @@ "default": true } ] - }, + }, "rsync": { "tools": { "rsync": { @@ -6565,28 +6565,28 @@ ] } }, - "transfer-manager": { - "formula": { - "sandbox_id": 135979123, - "match": "transfer-manager" - }, - "executable": { + "transfer-manager": { + "formula": { + "sandbox_id": 135979123, + "match": "transfer-manager" + }, + "executable": { "transfer-manager": [ "transfer-manager" ] - } - }, - "rem-tool": { - "formula": { - "sandbox_id": 79265295, - "match": "rem-tool" - }, - "executable": { + } + }, + "rem-tool": { + "formula": { + "sandbox_id": 79265295, + "match": "rem-tool" + }, + "executable": { "rem-tool": [ "rem-tool" ] - } - }, + } + }, "uc": { "formula": { "sandbox_id": 505682252, @@ -6909,20 +6909,20 @@ ] } }, - "tmux": { - "formula": { + "tmux": { + "formula": { "sandbox_id": [ 1105659071 ], - "match": "tmux" - }, - "executable": { + "match": "tmux" + }, + "executable": { "tmux": [ "bin", "tmux" ] - } - }, + } + }, "optrace": { "formula": { "sandbox_id": [ diff --git a/contrib/libs/base64/LICENSE b/contrib/libs/base64/LICENSE index 4f784e06763..f55fd99c26d 100644 --- a/contrib/libs/base64/LICENSE +++ b/contrib/libs/base64/LICENSE @@ -1,25 +1,25 @@ -Copyright (c) 2013-2015, Alfred Klomp -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - -- Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - -- Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +Copyright (c) 2013-2015, Alfred Klomp +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + +- Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + +- Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS +IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A +PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED +TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/contrib/libs/base64/README.md b/contrib/libs/base64/README.md index b9ceb86cebc..57c269ea38a 100644 --- a/contrib/libs/base64/README.md +++ b/contrib/libs/base64/README.md @@ -1,447 +1,447 @@ -# Fast Base64 stream encoder/decoder - -This is an implementation of a base64 stream encoding/decoding library in C99 -with SIMD (AVX2, NEON, AArch64/NEON, SSSE3) and [OpenMP](http://www.openmp.org) -acceleration. It also contains wrapper functions to encode/decode simple -length-delimited strings. This library aims to be: - -- FAST; -- easy to use; -- elegant. - -On x86, the library does runtime feature detection. The first time it's called, -the library will determine the appropriate encoding/decoding routines for the -machine. It then remembers them for the lifetime of the program. If your -processor supports AVX2 or SSSE3 instructions, the library will pick an -optimized codec that lets it encode/decode 12 or 24 bytes at a time, which -gives a speedup of four or more times compared to the "plain" bytewise codec. - -NEON support is hardcoded to on or off at compile time, because portable -runtime feature detection is unavailable on ARM. - -Even if your processor does not support SIMD instructions, this is a very fast -library. The fallback routine can process 32 or 64 bits of input in one round, -depending on your processor's word width, which still makes it significantly -faster than naive bytewise implementations. On some 64-bit machines, the 64-bit -routines even outperform the SSSE3 ones. - -To the author's knowledge, at the time of original release, this was the only -Base64 library to offer SIMD acceleration. The author wrote -[an article](http://www.alfredklomp.com/programming/sse-base64) explaining one -possible SIMD approach to encoding/decoding Base64. The article can help figure -out what the code is doing, and why. - -Notable features: - -- Really fast on x86 and ARM systems by using SIMD vector processing; -- Can use [OpenMP](http://www.openmp.org) for even more parallel speedups; -- Really fast on other 32 or 64-bit platforms through optimized routines; -- Reads/writes blocks of streaming data; -- Does not dynamically allocate memory; -- Valid C99 that compiles with pedantic options on; -- Re-entrant and threadsafe; -- Unit tested; -- Uses Duff's Device. - -## Acknowledgements - -The original AVX2, NEON and Aarch64/NEON codecs were generously contributed by -[Inkymail](https://github.com/inkymail/base64), who, in their fork, also -implemented some additional features. Their work is slowly being backported -into this project. - -The SSSE3 and AVX2 codecs were substantially improved by using some very clever -optimizations described by Wojciech Muła in a -[series](http://0x80.pl/notesen/2016-01-12-sse-base64-encoding.html) of -[articles](http://0x80.pl/notesen/2016-01-17-sse-base64-decoding.html). -His own code is [here](https://github.com/WojciechMula/toys/tree/master/base64). - -The OpenMP implementation was added by Ferry Toth (@htot) from [Exalon Delft](http://www.exalondelft.nl). - -## Building - -The `lib` directory contains the code for the actual library. -Typing `make` in the toplevel directory will build `lib/libbase64.o` and `bin/base64`. -The first is a single, self-contained object file that you can link into your own project. -The second is a standalone test binary that works similarly to the `base64` system utility. - -The matching header file needed to use this library is in `include/libbase64.h`. - -To compile just the "plain" library without SIMD codecs, type: - -```sh -make lib/libbase64.o -``` - -Optional SIMD codecs can be included by specifying the `AVX2_CFLAGS`, `NEON32_CFLAGS`, `NEON64_CFLAGS` and/or `SSSE3_CFLAGS` environment variables. -A typical build invocation on x86 looks like this: - -```sh -AVX2_CFLAGS=-mavx2 SSSE3_CFLAGS=-mssse3 make lib/libbase64.o -``` - -### AVX2 - -To build and include the AVX2 codec, set the `AVX2_CFLAGS` environment variable to a value that will turn on AVX2 support in your compiler, typically `-mavx2`. -Example: - -```sh -AVX2_CFLAGS=-mavx2 make -``` - -The codec will only be used if runtime feature detection shows that the target machine supports AVX2. - -### SSSE3 - -To build and include the SSSE3 codec, set the `SSSE3_CFLAGS` environment variable to a value that will turn on SSSE3 support in your compiler, typically `-mssse3`. -Example: - -```sh -SSSE3_CFLAGS=-mssse3 make -``` - -The codec will only be used if runtime feature detection shows that the target machine supports SSSE3. - -### NEON - -This library includes two NEON codecs: one for regular 32-bit ARM and one for the 64-bit AArch64 with NEON, which has double the amount of SIMD registers and can do full 64-byte table lookups. -These codecs encode in 48-byte chunks and decode in massive 64-byte chunks, so they had to be augmented with an uint32/64 codec to stay fast on smaller inputs! - -Use LLVM/Clang for compiling the NEON codecs. -The code generation of at least GCC 4.6 (the version shipped with Raspbian and used for testing) contains a bug when compiling `vstq4_u8()`, and the generated assembly code is of low quality. -NEON intrinsics are a known weak area of GCC. -Clang does a better job. - -NEON support can unfortunately not be portably detected at runtime from userland (the `mrc` instruction is privileged), so the default value for using the NEON codec is determined at compile-time. -But you can do your own runtime detection. -You can include the NEON codec and make it the default, then do a runtime check if the CPU has NEON support, and if not, force a downgrade to non-NEON with `BASE64_FORCE_PLAIN`. - -These are your options: - -1. Don't include NEON support; -2. build NEON support and make it the default, but build all other code without NEON flags so that you can override the default at runtime with `BASE64_FORCE_PLAIN`; -3. build everything with NEON support and make it the default; -4. build everything with NEON support, but don't make it the default (which makes no sense). - -For option 1, simply don't specify any NEON-specific compiler flags at all, like so: - -```sh -CC=clang CFLAGS="-march=armv6" make -``` - -For option 2, keep your `CFLAGS` plain, but set the `NEON32_CFLAGS` environment variable to a value that will build NEON support. -The line below, for instance, will build all the code at ARMv6 level, except for the NEON codec, which is built at ARMv7. -It will also make the NEON codec the default. -For ARMv6 platforms, override that default at runtime with the `BASE64_FORCE_PLAIN` flag. -No ARMv7/NEON code will then be touched. - -```sh -CC=clang CFLAGS="-march=armv6" NEON32_CFLAGS="-march=armv7 -mfpu=neon" make -``` - -For option 3, put everything in your `CFLAGS` and use a stub, but non-empty, `NEON32_CFLAGS`. -This example works for the Raspberry Pi 2B V1.1, which has NEON support: - -```sh -CC=clang CFLAGS="-march=armv7 -mtune=cortex-a7" NEON32_CFLAGS="-mfpu=neon" make -``` - -To build and include the NEON64 codec, use `CFLAGS` as usual to define the platform and set `NEON64_CFLAGS` to a nonempty stub. -(The AArch64 target has mandatory NEON64 support.) -Example: - -```sh -CC=clang CFLAGS="--target=aarch64-linux-gnu -march=armv8-a" NEON64_CFLAGS=" " make -``` - -### OpenMP - -To enable OpenMP on GCC you need to build with `-fopenmp`. This can be by setting the the `OPENMP` environment variable to `1`. - -Example: - -```sh -OPENMP=1 make -``` - -This will let the compiler define `_OPENMP`, which in turn will include the OpenMP optimized `lib_openmp.c` into `lib.c`. - -By default the number of parallel threads will be equal to the number of cores of the processor. -On a quad core with hyperthreading eight cores will be detected, but hyperthreading will not increase the performance. - -To get verbose information about OpenMP start the program with `OMP_DISPLAY_ENV=VERBOSE`, for instance - -```sh -OMP_DISPLAY_ENV=VERBOSE test/benchmark -``` - -To put a limit on the number of threads, start the program with `OMP_THREAD_LIMIT=n`, for instance - -```sh -OMP_THREAD_LIMIT=2 test/benchmark -``` - -An example of running a benchmark with OpenMP, SSSE3 and AVX2 enabled: - -```sh -make clean && OPENMP=1 SSSE3_CFLAGS=-mssse3 AVX2_CFLAGS=-mavx2 make && OPENMP=1 make -C test -``` - -## API reference - -Strings are represented as a pointer and a length; they are not -zero-terminated. This was a conscious design decision. In the decoding step, -relying on zero-termination would make no sense since the output could contain -legitimate zero bytes. In the encoding step, returning the length saves the -overhead of calling `strlen()` on the output. If you insist on the trailing -zero, you can easily add it yourself at the given offset. - -### Flags - -Some API calls take a `flags` argument. -That argument can be used to force the use of a specific codec, even if that codec is a no-op in the current build. -Mainly there for testing purposes, this is also useful on ARM where the only way to do runtime NEON detection is to ask the OS if it's available. -The following constants can be used: - -- `BASE64_FORCE_AVX2` -- `BASE64_FORCE_NEON32` -- `BASE64_FORCE_NEON64` -- `BASE64_FORCE_PLAIN` -- `BASE64_FORCE_SSSE3` - -Set `flags` to `0` for the default behavior, which is runtime feature detection on x86, a compile-time fixed codec on ARM, and the plain codec on other platforms. - -### Encoding - -#### base64_encode - -```c -void base64_encode - ( const char *src - , size_t srclen - , char *out - , size_t *outlen - , int flags - ) ; -``` - -Wrapper function to encode a plain string of given length. -Output is written to `out` without trailing zero. -Output length in bytes is written to `outlen`. -The buffer in `out` has been allocated by the caller and is at least 4/3 the size of the input. - -#### base64_stream_encode_init - -```c -void base64_stream_encode_init - ( struct base64_state *state - , int flags - ) ; -``` - -Call this before calling `base64_stream_encode()` to init the state. - -#### base64_stream_encode - -```c -void base64_stream_encode - ( struct base64_state *state - , const char *src - , size_t srclen - , char *out - , size_t *outlen - ) ; -``` - -Encodes the block of data of given length at `src`, into the buffer at `out`. -Caller is responsible for allocating a large enough out-buffer; it must be at least 4/3 the size of the in-buffer, but take some margin. -Places the number of new bytes written into `outlen` (which is set to zero when the function starts). -Does not zero-terminate or finalize the output. - -#### base64_stream_encode_final - -```c -void base64_stream_encode_final - ( struct base64_state *state - , char *out - , size_t *outlen - ) ; -``` - -Finalizes the output begun by previous calls to `base64_stream_encode()`. -Adds the required end-of-stream markers if appropriate. -`outlen` is modified and will contain the number of new bytes written at `out` (which will quite often be zero). - -### Decoding - -#### base64_decode - -```c -int base64_decode - ( const char *src - , size_t srclen - , char *out - , size_t *outlen - , int flags - ) ; -``` - -Wrapper function to decode a plain string of given length. -Output is written to `out` without trailing zero. Output length in bytes is written to `outlen`. -The buffer in `out` has been allocated by the caller and is at least 3/4 the size of the input. -Returns `1` for success, and `0` when a decode error has occured due to invalid input. -Returns `-1` if the chosen codec is not included in the current build. - -#### base64_stream_decode_init - -```c -void base64_stream_decode_init - ( struct base64_state *state - , int flags - ) ; -``` - -Call this before calling `base64_stream_decode()` to init the state. - -#### base64_stream_decode - -```c -int base64_stream_decode - ( struct base64_state *state - , const char *src - , size_t srclen - , char *out - , size_t *outlen - ) ; -``` - -Decodes the block of data of given length at `src`, into the buffer at `out`. -Caller is responsible for allocating a large enough out-buffer; it must be at least 3/4 the size of the in-buffer, but take some margin. -Places the number of new bytes written into `outlen` (which is set to zero when the function starts). -Does not zero-terminate the output. -Returns 1 if all is well, and 0 if a decoding error was found, such as an invalid character. -Returns -1 if the chosen codec is not included in the current build. -Used by the test harness to check whether a codec is available for testing. - -## Examples - -A simple example of encoding a static string to base64 and printing the output -to stdout: - -```c -#include <stdio.h> /* fwrite */ -#include "libbase64.h" - -int main () -{ - char src[] = "hello world"; - char out[20]; - size_t srclen = sizeof(src) - 1; - size_t outlen; - - base64_encode(src, srclen, out, &outlen, 0); - - fwrite(out, outlen, 1, stdout); - - return 0; -} -``` - -A simple example (no error checking, etc) of stream encoding standard input to -standard output: - -```c -#include <stdio.h> -#include "libbase64.h" - -int main () -{ - size_t nread, nout; - char buf[12000], out[16000]; - struct base64_state state; - - // Initialize stream encoder: - base64_stream_encode_init(&state, 0); - - // Read contents of stdin into buffer: - while ((nread = fread(buf, 1, sizeof(buf), stdin)) > 0) { - - // Encode buffer: - base64_stream_encode(&state, buf, nread, out, &nout); - - // If there's output, print it to stdout: - if (nout) { - fwrite(out, nout, 1, stdout); - } - - // If an error occurred, exit the loop: - if (feof(stdin)) { - break; - } - } - - // Finalize encoding: - base64_stream_encode_final(&state, out, &nout); - - // If the finalizing resulted in extra output bytes, print them: - if (nout) { - fwrite(out, nout, 1, stdout); - } - - return 0; -} -``` - -Also see `bin/base64.c` for a simple re-implementation of the `base64` utility. -A file or standard input is fed through the encoder/decoder, and the output is -written to standard output. - -## Tests - -See `tests/` for a small test suite. Testing is automated with [Travis CI](https://travis-ci.org/aklomp/base64): - -[//]: # "[](https://travis-ci.org/aklomp/base64)" - -## Benchmarks - -Benchmarks can be run with the built-in benchmark program as follows: - -```sh -make -C test benchmark <buildflags> && test/benchmark -``` - -It will run an encoding and decoding benchmark for all of the compiled-in codecs. - -The table below contains some results on random machines. All numbers measured with a 10MB buffer in MB/sec, rounded to the nearest integer. - -| Processor | Plain enc | Plain dec | SSSE3 enc | SSSE3 dec | AVX2 enc | AVX2 dec | NEON32 enc | NEON32 dec | -|-------------------------------------------|----------:|----------:|----------:|----------:|---------:|---------:|-----------:|-----------:| -| i7-4771 @ 3.5 GHz | 833 | 1111 | 3333 | 4444 | 4999 | 6666 | - | - | -| i7-4770 @ 3.4 GHz DDR1600 | 1831 | 1748 | 3570 | 3695 | 6539 | 6512 | - | - | -| i7-4770 @ 3.4 GHz DDR1600 OPENMP 1 thread | 1779 | 1727 | 3419 | 3788 | 4589 | 5871 | - | - | -| i7-4770 @ 3.4 GHz DDR1600 OPENMP 2 thread | 3367 | 3374 | 4784 | 6672 | 5120 | 7721 | - | - | -| i7-4770 @ 3.4 GHz DDR1600 OPENMP 4 thread | 4834 | 6075 | 4906 | 8154 | 4839 | 6911 | - | - | -| i7-4770 @ 3.4 GHz DDR1600 OPENMP 8 thread | 4696 | 6361 | 5227 | 7737 | 4813 | 7189 | - | - | -| i5-4590S @ 3.0 GHz | 1721 | 1643 | 3255 | 3404 | 4124 | 5403 | - | - | -| Xeon X5570 @ 2.93 GHz | 1097 | 1048 | 2077 | 2215 | - | - | - | - | -| Pentium4 @ 3.4 GHz | 528 | 448 | - | - | - | - | - | - | -| Atom N270 | 112 | 125 | 331 | 368 | - | - | - | - | -| AMD E-450 | 370 | 332 | 405 | 366 | - | - | - | - | -| PowerPC E6500 @ 1.8GHz | 270 | 265 | - | - | - | - | - | - | -| Raspberry PI B+ V1.2 | 46 | 40 | - | - | - | - | - | - | -| Raspberry PI 2 B V1.1 | 104 | 88 | - | - | - | - | 158 | 116 | -| Intel Edison @ 500 MHz | 79 | 92 | 152 | 172 | - | - | - | - | -| Intel Edison @ 500 MHz OPENMP 2 thread | 158 | 184 | 300 | 343 | - | - | - | - | - -Benchmarks on i7-4770 @ 3.4 GHz DDR1600 with varrying buffer sizes: - - -Note: optimal buffer size to take advantage of the cache is in the range of 100 kB to 1 MB, leading to 12x faster AVX encoding/decoding compared to Plain, or a throughput of 24/27GB/sec. -Also note the performance degradation when the buffer size is less than 10 kB due to thread creation overhead. -To prevent this from happening `lib_openmp.c` defines `OMP_THRESHOLD 20000`, requiring at least a 20000 byte buffer to enable multithreading. - -## License - -This repository is licensed under the -[BSD 2-clause License](http://opensource.org/licenses/BSD-2-Clause). See the -LICENSE file. +# Fast Base64 stream encoder/decoder + +This is an implementation of a base64 stream encoding/decoding library in C99 +with SIMD (AVX2, NEON, AArch64/NEON, SSSE3) and [OpenMP](http://www.openmp.org) +acceleration. It also contains wrapper functions to encode/decode simple +length-delimited strings. This library aims to be: + +- FAST; +- easy to use; +- elegant. + +On x86, the library does runtime feature detection. The first time it's called, +the library will determine the appropriate encoding/decoding routines for the +machine. It then remembers them for the lifetime of the program. If your +processor supports AVX2 or SSSE3 instructions, the library will pick an +optimized codec that lets it encode/decode 12 or 24 bytes at a time, which +gives a speedup of four or more times compared to the "plain" bytewise codec. + +NEON support is hardcoded to on or off at compile time, because portable +runtime feature detection is unavailable on ARM. + +Even if your processor does not support SIMD instructions, this is a very fast +library. The fallback routine can process 32 or 64 bits of input in one round, +depending on your processor's word width, which still makes it significantly +faster than naive bytewise implementations. On some 64-bit machines, the 64-bit +routines even outperform the SSSE3 ones. + +To the author's knowledge, at the time of original release, this was the only +Base64 library to offer SIMD acceleration. The author wrote +[an article](http://www.alfredklomp.com/programming/sse-base64) explaining one +possible SIMD approach to encoding/decoding Base64. The article can help figure +out what the code is doing, and why. + +Notable features: + +- Really fast on x86 and ARM systems by using SIMD vector processing; +- Can use [OpenMP](http://www.openmp.org) for even more parallel speedups; +- Really fast on other 32 or 64-bit platforms through optimized routines; +- Reads/writes blocks of streaming data; +- Does not dynamically allocate memory; +- Valid C99 that compiles with pedantic options on; +- Re-entrant and threadsafe; +- Unit tested; +- Uses Duff's Device. + +## Acknowledgements + +The original AVX2, NEON and Aarch64/NEON codecs were generously contributed by +[Inkymail](https://github.com/inkymail/base64), who, in their fork, also +implemented some additional features. Their work is slowly being backported +into this project. + +The SSSE3 and AVX2 codecs were substantially improved by using some very clever +optimizations described by Wojciech Muła in a +[series](http://0x80.pl/notesen/2016-01-12-sse-base64-encoding.html) of +[articles](http://0x80.pl/notesen/2016-01-17-sse-base64-decoding.html). +His own code is [here](https://github.com/WojciechMula/toys/tree/master/base64). + +The OpenMP implementation was added by Ferry Toth (@htot) from [Exalon Delft](http://www.exalondelft.nl). + +## Building + +The `lib` directory contains the code for the actual library. +Typing `make` in the toplevel directory will build `lib/libbase64.o` and `bin/base64`. +The first is a single, self-contained object file that you can link into your own project. +The second is a standalone test binary that works similarly to the `base64` system utility. + +The matching header file needed to use this library is in `include/libbase64.h`. + +To compile just the "plain" library without SIMD codecs, type: + +```sh +make lib/libbase64.o +``` + +Optional SIMD codecs can be included by specifying the `AVX2_CFLAGS`, `NEON32_CFLAGS`, `NEON64_CFLAGS` and/or `SSSE3_CFLAGS` environment variables. +A typical build invocation on x86 looks like this: + +```sh +AVX2_CFLAGS=-mavx2 SSSE3_CFLAGS=-mssse3 make lib/libbase64.o +``` + +### AVX2 + +To build and include the AVX2 codec, set the `AVX2_CFLAGS` environment variable to a value that will turn on AVX2 support in your compiler, typically `-mavx2`. +Example: + +```sh +AVX2_CFLAGS=-mavx2 make +``` + +The codec will only be used if runtime feature detection shows that the target machine supports AVX2. + +### SSSE3 + +To build and include the SSSE3 codec, set the `SSSE3_CFLAGS` environment variable to a value that will turn on SSSE3 support in your compiler, typically `-mssse3`. +Example: + +```sh +SSSE3_CFLAGS=-mssse3 make +``` + +The codec will only be used if runtime feature detection shows that the target machine supports SSSE3. + +### NEON + +This library includes two NEON codecs: one for regular 32-bit ARM and one for the 64-bit AArch64 with NEON, which has double the amount of SIMD registers and can do full 64-byte table lookups. +These codecs encode in 48-byte chunks and decode in massive 64-byte chunks, so they had to be augmented with an uint32/64 codec to stay fast on smaller inputs! + +Use LLVM/Clang for compiling the NEON codecs. +The code generation of at least GCC 4.6 (the version shipped with Raspbian and used for testing) contains a bug when compiling `vstq4_u8()`, and the generated assembly code is of low quality. +NEON intrinsics are a known weak area of GCC. +Clang does a better job. + +NEON support can unfortunately not be portably detected at runtime from userland (the `mrc` instruction is privileged), so the default value for using the NEON codec is determined at compile-time. +But you can do your own runtime detection. +You can include the NEON codec and make it the default, then do a runtime check if the CPU has NEON support, and if not, force a downgrade to non-NEON with `BASE64_FORCE_PLAIN`. + +These are your options: + +1. Don't include NEON support; +2. build NEON support and make it the default, but build all other code without NEON flags so that you can override the default at runtime with `BASE64_FORCE_PLAIN`; +3. build everything with NEON support and make it the default; +4. build everything with NEON support, but don't make it the default (which makes no sense). + +For option 1, simply don't specify any NEON-specific compiler flags at all, like so: + +```sh +CC=clang CFLAGS="-march=armv6" make +``` + +For option 2, keep your `CFLAGS` plain, but set the `NEON32_CFLAGS` environment variable to a value that will build NEON support. +The line below, for instance, will build all the code at ARMv6 level, except for the NEON codec, which is built at ARMv7. +It will also make the NEON codec the default. +For ARMv6 platforms, override that default at runtime with the `BASE64_FORCE_PLAIN` flag. +No ARMv7/NEON code will then be touched. + +```sh +CC=clang CFLAGS="-march=armv6" NEON32_CFLAGS="-march=armv7 -mfpu=neon" make +``` + +For option 3, put everything in your `CFLAGS` and use a stub, but non-empty, `NEON32_CFLAGS`. +This example works for the Raspberry Pi 2B V1.1, which has NEON support: + +```sh +CC=clang CFLAGS="-march=armv7 -mtune=cortex-a7" NEON32_CFLAGS="-mfpu=neon" make +``` + +To build and include the NEON64 codec, use `CFLAGS` as usual to define the platform and set `NEON64_CFLAGS` to a nonempty stub. +(The AArch64 target has mandatory NEON64 support.) +Example: + +```sh +CC=clang CFLAGS="--target=aarch64-linux-gnu -march=armv8-a" NEON64_CFLAGS=" " make +``` + +### OpenMP + +To enable OpenMP on GCC you need to build with `-fopenmp`. This can be by setting the the `OPENMP` environment variable to `1`. + +Example: + +```sh +OPENMP=1 make +``` + +This will let the compiler define `_OPENMP`, which in turn will include the OpenMP optimized `lib_openmp.c` into `lib.c`. + +By default the number of parallel threads will be equal to the number of cores of the processor. +On a quad core with hyperthreading eight cores will be detected, but hyperthreading will not increase the performance. + +To get verbose information about OpenMP start the program with `OMP_DISPLAY_ENV=VERBOSE`, for instance + +```sh +OMP_DISPLAY_ENV=VERBOSE test/benchmark +``` + +To put a limit on the number of threads, start the program with `OMP_THREAD_LIMIT=n`, for instance + +```sh +OMP_THREAD_LIMIT=2 test/benchmark +``` + +An example of running a benchmark with OpenMP, SSSE3 and AVX2 enabled: + +```sh +make clean && OPENMP=1 SSSE3_CFLAGS=-mssse3 AVX2_CFLAGS=-mavx2 make && OPENMP=1 make -C test +``` + +## API reference + +Strings are represented as a pointer and a length; they are not +zero-terminated. This was a conscious design decision. In the decoding step, +relying on zero-termination would make no sense since the output could contain +legitimate zero bytes. In the encoding step, returning the length saves the +overhead of calling `strlen()` on the output. If you insist on the trailing +zero, you can easily add it yourself at the given offset. + +### Flags + +Some API calls take a `flags` argument. +That argument can be used to force the use of a specific codec, even if that codec is a no-op in the current build. +Mainly there for testing purposes, this is also useful on ARM where the only way to do runtime NEON detection is to ask the OS if it's available. +The following constants can be used: + +- `BASE64_FORCE_AVX2` +- `BASE64_FORCE_NEON32` +- `BASE64_FORCE_NEON64` +- `BASE64_FORCE_PLAIN` +- `BASE64_FORCE_SSSE3` + +Set `flags` to `0` for the default behavior, which is runtime feature detection on x86, a compile-time fixed codec on ARM, and the plain codec on other platforms. + +### Encoding + +#### base64_encode + +```c +void base64_encode + ( const char *src + , size_t srclen + , char *out + , size_t *outlen + , int flags + ) ; +``` + +Wrapper function to encode a plain string of given length. +Output is written to `out` without trailing zero. +Output length in bytes is written to `outlen`. +The buffer in `out` has been allocated by the caller and is at least 4/3 the size of the input. + +#### base64_stream_encode_init + +```c +void base64_stream_encode_init + ( struct base64_state *state + , int flags + ) ; +``` + +Call this before calling `base64_stream_encode()` to init the state. + +#### base64_stream_encode + +```c +void base64_stream_encode + ( struct base64_state *state + , const char *src + , size_t srclen + , char *out + , size_t *outlen + ) ; +``` + +Encodes the block of data of given length at `src`, into the buffer at `out`. +Caller is responsible for allocating a large enough out-buffer; it must be at least 4/3 the size of the in-buffer, but take some margin. +Places the number of new bytes written into `outlen` (which is set to zero when the function starts). +Does not zero-terminate or finalize the output. + +#### base64_stream_encode_final + +```c +void base64_stream_encode_final + ( struct base64_state *state + , char *out + , size_t *outlen + ) ; +``` + +Finalizes the output begun by previous calls to `base64_stream_encode()`. +Adds the required end-of-stream markers if appropriate. +`outlen` is modified and will contain the number of new bytes written at `out` (which will quite often be zero). + +### Decoding + +#### base64_decode + +```c +int base64_decode + ( const char *src + , size_t srclen + , char *out + , size_t *outlen + , int flags + ) ; +``` + +Wrapper function to decode a plain string of given length. +Output is written to `out` without trailing zero. Output length in bytes is written to `outlen`. +The buffer in `out` has been allocated by the caller and is at least 3/4 the size of the input. +Returns `1` for success, and `0` when a decode error has occured due to invalid input. +Returns `-1` if the chosen codec is not included in the current build. + +#### base64_stream_decode_init + +```c +void base64_stream_decode_init + ( struct base64_state *state + , int flags + ) ; +``` + +Call this before calling `base64_stream_decode()` to init the state. + +#### base64_stream_decode + +```c +int base64_stream_decode + ( struct base64_state *state + , const char *src + , size_t srclen + , char *out + , size_t *outlen + ) ; +``` + +Decodes the block of data of given length at `src`, into the buffer at `out`. +Caller is responsible for allocating a large enough out-buffer; it must be at least 3/4 the size of the in-buffer, but take some margin. +Places the number of new bytes written into `outlen` (which is set to zero when the function starts). +Does not zero-terminate the output. +Returns 1 if all is well, and 0 if a decoding error was found, such as an invalid character. +Returns -1 if the chosen codec is not included in the current build. +Used by the test harness to check whether a codec is available for testing. + +## Examples + +A simple example of encoding a static string to base64 and printing the output +to stdout: + +```c +#include <stdio.h> /* fwrite */ +#include "libbase64.h" + +int main () +{ + char src[] = "hello world"; + char out[20]; + size_t srclen = sizeof(src) - 1; + size_t outlen; + + base64_encode(src, srclen, out, &outlen, 0); + + fwrite(out, outlen, 1, stdout); + + return 0; +} +``` + +A simple example (no error checking, etc) of stream encoding standard input to +standard output: + +```c +#include <stdio.h> +#include "libbase64.h" + +int main () +{ + size_t nread, nout; + char buf[12000], out[16000]; + struct base64_state state; + + // Initialize stream encoder: + base64_stream_encode_init(&state, 0); + + // Read contents of stdin into buffer: + while ((nread = fread(buf, 1, sizeof(buf), stdin)) > 0) { + + // Encode buffer: + base64_stream_encode(&state, buf, nread, out, &nout); + + // If there's output, print it to stdout: + if (nout) { + fwrite(out, nout, 1, stdout); + } + + // If an error occurred, exit the loop: + if (feof(stdin)) { + break; + } + } + + // Finalize encoding: + base64_stream_encode_final(&state, out, &nout); + + // If the finalizing resulted in extra output bytes, print them: + if (nout) { + fwrite(out, nout, 1, stdout); + } + + return 0; +} +``` + +Also see `bin/base64.c` for a simple re-implementation of the `base64` utility. +A file or standard input is fed through the encoder/decoder, and the output is +written to standard output. + +## Tests + +See `tests/` for a small test suite. Testing is automated with [Travis CI](https://travis-ci.org/aklomp/base64): + +[//]: # "[](https://travis-ci.org/aklomp/base64)" + +## Benchmarks + +Benchmarks can be run with the built-in benchmark program as follows: + +```sh +make -C test benchmark <buildflags> && test/benchmark +``` + +It will run an encoding and decoding benchmark for all of the compiled-in codecs. + +The table below contains some results on random machines. All numbers measured with a 10MB buffer in MB/sec, rounded to the nearest integer. + +| Processor | Plain enc | Plain dec | SSSE3 enc | SSSE3 dec | AVX2 enc | AVX2 dec | NEON32 enc | NEON32 dec | +|-------------------------------------------|----------:|----------:|----------:|----------:|---------:|---------:|-----------:|-----------:| +| i7-4771 @ 3.5 GHz | 833 | 1111 | 3333 | 4444 | 4999 | 6666 | - | - | +| i7-4770 @ 3.4 GHz DDR1600 | 1831 | 1748 | 3570 | 3695 | 6539 | 6512 | - | - | +| i7-4770 @ 3.4 GHz DDR1600 OPENMP 1 thread | 1779 | 1727 | 3419 | 3788 | 4589 | 5871 | - | - | +| i7-4770 @ 3.4 GHz DDR1600 OPENMP 2 thread | 3367 | 3374 | 4784 | 6672 | 5120 | 7721 | - | - | +| i7-4770 @ 3.4 GHz DDR1600 OPENMP 4 thread | 4834 | 6075 | 4906 | 8154 | 4839 | 6911 | - | - | +| i7-4770 @ 3.4 GHz DDR1600 OPENMP 8 thread | 4696 | 6361 | 5227 | 7737 | 4813 | 7189 | - | - | +| i5-4590S @ 3.0 GHz | 1721 | 1643 | 3255 | 3404 | 4124 | 5403 | - | - | +| Xeon X5570 @ 2.93 GHz | 1097 | 1048 | 2077 | 2215 | - | - | - | - | +| Pentium4 @ 3.4 GHz | 528 | 448 | - | - | - | - | - | - | +| Atom N270 | 112 | 125 | 331 | 368 | - | - | - | - | +| AMD E-450 | 370 | 332 | 405 | 366 | - | - | - | - | +| PowerPC E6500 @ 1.8GHz | 270 | 265 | - | - | - | - | - | - | +| Raspberry PI B+ V1.2 | 46 | 40 | - | - | - | - | - | - | +| Raspberry PI 2 B V1.1 | 104 | 88 | - | - | - | - | 158 | 116 | +| Intel Edison @ 500 MHz | 79 | 92 | 152 | 172 | - | - | - | - | +| Intel Edison @ 500 MHz OPENMP 2 thread | 158 | 184 | 300 | 343 | - | - | - | - | + +Benchmarks on i7-4770 @ 3.4 GHz DDR1600 with varrying buffer sizes: + + +Note: optimal buffer size to take advantage of the cache is in the range of 100 kB to 1 MB, leading to 12x faster AVX encoding/decoding compared to Plain, or a throughput of 24/27GB/sec. +Also note the performance degradation when the buffer size is less than 10 kB due to thread creation overhead. +To prevent this from happening `lib_openmp.c` defines `OMP_THRESHOLD 20000`, requiring at least a 20000 byte buffer to enable multithreading. + +## License + +This repository is licensed under the +[BSD 2-clause License](http://opensource.org/licenses/BSD-2-Clause). See the +LICENSE file. diff --git a/contrib/libs/base64/REVISION b/contrib/libs/base64/REVISION index 587536c2a03..c426a596cde 100644 --- a/contrib/libs/base64/REVISION +++ b/contrib/libs/base64/REVISION @@ -1 +1 @@ -https://github.com/aklomp/base64/tree/e82ac0ff813fc1f318d215879783683fe7071cc3 +https://github.com/aklomp/base64/tree/e82ac0ff813fc1f318d215879783683fe7071cc3 diff --git a/contrib/libs/base64/avx2/codec_avx2.c b/contrib/libs/base64/avx2/codec_avx2.c index 46c351c5393..7e0dc739d64 100644 --- a/contrib/libs/base64/avx2/codec_avx2.c +++ b/contrib/libs/base64/avx2/codec_avx2.c @@ -1,191 +1,191 @@ -#include <stdint.h> -#include <stddef.h> -#include <stdlib.h> - -#include "libbase64.h" -#include "codecs.h" - -#ifdef __AVX2__ -#include <immintrin.h> - -#define CMPGT(s,n) _mm256_cmpgt_epi8((s), _mm256_set1_epi8(n)) -#define CMPEQ(s,n) _mm256_cmpeq_epi8((s), _mm256_set1_epi8(n)) -#define REPLACE(s,n) _mm256_and_si256((s), _mm256_set1_epi8(n)) -#define RANGE(s,a,b) _mm256_andnot_si256(CMPGT((s), (b)), CMPGT((s), (a) - 1)) - -static inline __m256i -_mm256_bswap_epi32 (const __m256i in) -{ - // _mm256_shuffle_epi8() works on two 128-bit lanes separately: - return _mm256_shuffle_epi8(in, _mm256_setr_epi8( - 3, 2, 1, 0, - 7, 6, 5, 4, - 11, 10, 9, 8, - 15, 14, 13, 12, - 3, 2, 1, 0, - 7, 6, 5, 4, - 11, 10, 9, 8, - 15, 14, 13, 12)); -} - -static inline __m256i -enc_reshuffle (__m256i in) -{ - // Spread out 32-bit words over both halves of the input register: - in = _mm256_permutevar8x32_epi32(in, _mm256_setr_epi32( - 0, 1, 2, -1, - 3, 4, 5, -1)); - - // Slice into 32-bit chunks and operate on all chunks in parallel. - // All processing is done within the 32-bit chunk. First, shuffle: - // before: [eeeeeeff|ccdddddd|bbbbcccc|aaaaaabb] - // after: [00000000|aaaaaabb|bbbbcccc|ccdddddd] - in = _mm256_shuffle_epi8(in, _mm256_set_epi8( - -1, 9, 10, 11, - -1, 6, 7, 8, - -1, 3, 4, 5, - -1, 0, 1, 2, - -1, 9, 10, 11, - -1, 6, 7, 8, - -1, 3, 4, 5, - -1, 0, 1, 2)); - - // cd = [00000000|00000000|0000cccc|ccdddddd] - const __m256i cd = _mm256_and_si256(in, _mm256_set1_epi32(0x00000FFF)); - - // ab = [0000aaaa|aabbbbbb|00000000|00000000] - const __m256i ab = _mm256_and_si256(_mm256_slli_epi32(in, 4), _mm256_set1_epi32(0x0FFF0000)); - - // merged = [0000aaaa|aabbbbbb|0000cccc|ccdddddd] - const __m256i merged = _mm256_or_si256(ab, cd); - - // bd = [00000000|00bbbbbb|00000000|00dddddd] - const __m256i bd = _mm256_and_si256(merged, _mm256_set1_epi32(0x003F003F)); - - // ac = [00aaaaaa|00000000|00cccccc|00000000] - const __m256i ac = _mm256_and_si256(_mm256_slli_epi32(merged, 2), _mm256_set1_epi32(0x3F003F00)); - - // indices = [00aaaaaa|00bbbbbb|00cccccc|00dddddd] - const __m256i indices = _mm256_or_si256(ac, bd); - - // return = [00dddddd|00cccccc|00bbbbbb|00aaaaaa] - return _mm256_bswap_epi32(indices); -} - -static inline __m256i -enc_translate (const __m256i in) -{ - // Translate values 0..63 to the Base64 alphabet. There are five sets: - // # From To Abs Delta Characters - // 0 [0..25] [65..90] +65 +65 ABCDEFGHIJKLMNOPQRSTUVWXYZ - // 1 [26..51] [97..122] +71 +6 abcdefghijklmnopqrstuvwxyz - // 2 [52..61] [48..57] -4 -75 0123456789 - // 3 [62] [43] -19 -15 + - // 4 [63] [47] -16 +3 / - - // Create cumulative masks for characters in sets [1,2,3,4], [2,3,4], - // [3,4], and [4]: - const __m256i mask1 = CMPGT(in, 25); - const __m256i mask2 = CMPGT(in, 51); - const __m256i mask3 = CMPGT(in, 61); - const __m256i mask4 = CMPEQ(in, 63); - - // All characters are at least in cumulative set 0, so add 'A': - __m256i out = _mm256_add_epi8(in, _mm256_set1_epi8(65)); - - // For inputs which are also in any of the other cumulative sets, - // add delta values against the previous set(s) to correct the shift: - out = _mm256_add_epi8(out, REPLACE(mask1, 6)); - out = _mm256_sub_epi8(out, REPLACE(mask2, 75)); - out = _mm256_sub_epi8(out, REPLACE(mask3, 15)); - out = _mm256_add_epi8(out, REPLACE(mask4, 3)); - - return out; -} - -static inline __m256i -dec_reshuffle (__m256i in) -{ - // Shuffle bytes to 32-bit bigendian: - in = _mm256_bswap_epi32(in); - - // Mask in a single byte per shift: - __m256i mask = _mm256_set1_epi32(0x3F000000); - - // Pack bytes together: - __m256i out = _mm256_slli_epi32(_mm256_and_si256(in, mask), 2); - mask = _mm256_srli_epi32(mask, 8); - - out = _mm256_or_si256(out, _mm256_slli_epi32(_mm256_and_si256(in, mask), 4)); - mask = _mm256_srli_epi32(mask, 8); - - out = _mm256_or_si256(out, _mm256_slli_epi32(_mm256_and_si256(in, mask), 6)); - mask = _mm256_srli_epi32(mask, 8); - - out = _mm256_or_si256(out, _mm256_slli_epi32(_mm256_and_si256(in, mask), 8)); - - // Pack bytes together within 32-bit words, discarding words 3 and 7: - out = _mm256_shuffle_epi8(out, _mm256_setr_epi8( - 3, 2, 1, - 7, 6, 5, - 11, 10, 9, - 15, 14, 13, - -1, -1, -1, -1, - 3, 2, 1, - 7, 6, 5, - 11, 10, 9, - 15, 14, 13, - -1, -1, -1, -1)); - - // Pack 32-bit words together, squashing empty words 3 and 7: - return _mm256_permutevar8x32_epi32(out, _mm256_setr_epi32( - 0, 1, 2, 4, 5, 6, -1, -1)); -} - -#endif // __AVX2__ - -void -avx2_base64_stream_encode - ( struct avx2_base64_state *state - , const char *src - , size_t srclen - , char *out - , size_t *outlen - ) -{ -#if defined(__AVX2__) - #include "enc_head.c" - #include "enc_avx2.c" - #include "enc_tail.c" -#else - (void)state; - (void)src; - (void)srclen; - (void)out; - (void)outlen; - abort(); -#endif -} - -int -avx2_base64_stream_decode - ( struct avx2_base64_state *state - , const char *src - , size_t srclen - , char *out - , size_t *outlen - ) -{ -#if defined(__AVX2__) - #include "dec_head.c" - #include "dec_avx2.c" - #include "dec_tail.c" -#else - (void)state; - (void)src; - (void)srclen; - (void)out; - (void)outlen; - abort(); -#endif -} +#include <stdint.h> +#include <stddef.h> +#include <stdlib.h> + +#include "libbase64.h" +#include "codecs.h" + +#ifdef __AVX2__ +#include <immintrin.h> + +#define CMPGT(s,n) _mm256_cmpgt_epi8((s), _mm256_set1_epi8(n)) +#define CMPEQ(s,n) _mm256_cmpeq_epi8((s), _mm256_set1_epi8(n)) +#define REPLACE(s,n) _mm256_and_si256((s), _mm256_set1_epi8(n)) +#define RANGE(s,a,b) _mm256_andnot_si256(CMPGT((s), (b)), CMPGT((s), (a) - 1)) + +static inline __m256i +_mm256_bswap_epi32 (const __m256i in) +{ + // _mm256_shuffle_epi8() works on two 128-bit lanes separately: + return _mm256_shuffle_epi8(in, _mm256_setr_epi8( + 3, 2, 1, 0, + 7, 6, 5, 4, + 11, 10, 9, 8, + 15, 14, 13, 12, + 3, 2, 1, 0, + 7, 6, 5, 4, + 11, 10, 9, 8, + 15, 14, 13, 12)); +} + +static inline __m256i +enc_reshuffle (__m256i in) +{ + // Spread out 32-bit words over both halves of the input register: + in = _mm256_permutevar8x32_epi32(in, _mm256_setr_epi32( + 0, 1, 2, -1, + 3, 4, 5, -1)); + + // Slice into 32-bit chunks and operate on all chunks in parallel. + // All processing is done within the 32-bit chunk. First, shuffle: + // before: [eeeeeeff|ccdddddd|bbbbcccc|aaaaaabb] + // after: [00000000|aaaaaabb|bbbbcccc|ccdddddd] + in = _mm256_shuffle_epi8(in, _mm256_set_epi8( + -1, 9, 10, 11, + -1, 6, 7, 8, + -1, 3, 4, 5, + -1, 0, 1, 2, + -1, 9, 10, 11, + -1, 6, 7, 8, + -1, 3, 4, 5, + -1, 0, 1, 2)); + + // cd = [00000000|00000000|0000cccc|ccdddddd] + const __m256i cd = _mm256_and_si256(in, _mm256_set1_epi32(0x00000FFF)); + + // ab = [0000aaaa|aabbbbbb|00000000|00000000] + const __m256i ab = _mm256_and_si256(_mm256_slli_epi32(in, 4), _mm256_set1_epi32(0x0FFF0000)); + + // merged = [0000aaaa|aabbbbbb|0000cccc|ccdddddd] + const __m256i merged = _mm256_or_si256(ab, cd); + + // bd = [00000000|00bbbbbb|00000000|00dddddd] + const __m256i bd = _mm256_and_si256(merged, _mm256_set1_epi32(0x003F003F)); + + // ac = [00aaaaaa|00000000|00cccccc|00000000] + const __m256i ac = _mm256_and_si256(_mm256_slli_epi32(merged, 2), _mm256_set1_epi32(0x3F003F00)); + + // indices = [00aaaaaa|00bbbbbb|00cccccc|00dddddd] + const __m256i indices = _mm256_or_si256(ac, bd); + + // return = [00dddddd|00cccccc|00bbbbbb|00aaaaaa] + return _mm256_bswap_epi32(indices); +} + +static inline __m256i +enc_translate (const __m256i in) +{ + // Translate values 0..63 to the Base64 alphabet. There are five sets: + // # From To Abs Delta Characters + // 0 [0..25] [65..90] +65 +65 ABCDEFGHIJKLMNOPQRSTUVWXYZ + // 1 [26..51] [97..122] +71 +6 abcdefghijklmnopqrstuvwxyz + // 2 [52..61] [48..57] -4 -75 0123456789 + // 3 [62] [43] -19 -15 + + // 4 [63] [47] -16 +3 / + + // Create cumulative masks for characters in sets [1,2,3,4], [2,3,4], + // [3,4], and [4]: + const __m256i mask1 = CMPGT(in, 25); + const __m256i mask2 = CMPGT(in, 51); + const __m256i mask3 = CMPGT(in, 61); + const __m256i mask4 = CMPEQ(in, 63); + + // All characters are at least in cumulative set 0, so add 'A': + __m256i out = _mm256_add_epi8(in, _mm256_set1_epi8(65)); + + // For inputs which are also in any of the other cumulative sets, + // add delta values against the previous set(s) to correct the shift: + out = _mm256_add_epi8(out, REPLACE(mask1, 6)); + out = _mm256_sub_epi8(out, REPLACE(mask2, 75)); + out = _mm256_sub_epi8(out, REPLACE(mask3, 15)); + out = _mm256_add_epi8(out, REPLACE(mask4, 3)); + + return out; +} + +static inline __m256i +dec_reshuffle (__m256i in) +{ + // Shuffle bytes to 32-bit bigendian: + in = _mm256_bswap_epi32(in); + + // Mask in a single byte per shift: + __m256i mask = _mm256_set1_epi32(0x3F000000); + + // Pack bytes together: + __m256i out = _mm256_slli_epi32(_mm256_and_si256(in, mask), 2); + mask = _mm256_srli_epi32(mask, 8); + + out = _mm256_or_si256(out, _mm256_slli_epi32(_mm256_and_si256(in, mask), 4)); + mask = _mm256_srli_epi32(mask, 8); + + out = _mm256_or_si256(out, _mm256_slli_epi32(_mm256_and_si256(in, mask), 6)); + mask = _mm256_srli_epi32(mask, 8); + + out = _mm256_or_si256(out, _mm256_slli_epi32(_mm256_and_si256(in, mask), 8)); + + // Pack bytes together within 32-bit words, discarding words 3 and 7: + out = _mm256_shuffle_epi8(out, _mm256_setr_epi8( + 3, 2, 1, + 7, 6, 5, + 11, 10, 9, + 15, 14, 13, + -1, -1, -1, -1, + 3, 2, 1, + 7, 6, 5, + 11, 10, 9, + 15, 14, 13, + -1, -1, -1, -1)); + + // Pack 32-bit words together, squashing empty words 3 and 7: + return _mm256_permutevar8x32_epi32(out, _mm256_setr_epi32( + 0, 1, 2, 4, 5, 6, -1, -1)); +} + +#endif // __AVX2__ + +void +avx2_base64_stream_encode + ( struct avx2_base64_state *state + , const char *src + , size_t srclen + , char *out + , size_t *outlen + ) +{ +#if defined(__AVX2__) + #include "enc_head.c" + #include "enc_avx2.c" + #include "enc_tail.c" +#else + (void)state; + (void)src; + (void)srclen; + (void)out; + (void)outlen; + abort(); +#endif +} + +int +avx2_base64_stream_decode + ( struct avx2_base64_state *state + , const char *src + , size_t srclen + , char *out + , size_t *outlen + ) +{ +#if defined(__AVX2__) + #include "dec_head.c" + #include "dec_avx2.c" + #include "dec_tail.c" +#else + (void)state; + (void)src; + (void)srclen; + (void)out; + (void)outlen; + abort(); +#endif +} diff --git a/contrib/libs/base64/avx2/codecs.h b/contrib/libs/base64/avx2/codecs.h index 16a285ac0bc..34857fa8e55 100644 --- a/contrib/libs/base64/avx2/codecs.h +++ b/contrib/libs/base64/avx2/codecs.h @@ -1,35 +1,35 @@ -#pragma once - -// Define machine endianness. This is for GCC: -#if (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__) - #define BASE64_AVX2_LITTLE_ENDIAN 1 -#else - #define BASE64_AVX2_LITTLE_ENDIAN 0 -#endif - -// This is for Clang: -#ifdef __LITTLE_ENDIAN__ - #define BASE64_AVX2_LITTLE_ENDIAN 1 -#endif - -#ifdef __BIG_ENDIAN__ - #define BASE64_AVX2_LITTLE_ENDIAN 0 -#endif - -// Endian conversion functions -#if BASE64_AVX2_LITTLE_ENDIAN - #define cpu_to_be32(x) __builtin_bswap32(x) - #define cpu_to_be64(x) __builtin_bswap64(x) - #define be32_to_cpu(x) __builtin_bswap32(x) - #define be64_to_cpu(x) __builtin_bswap64(x) -#else - #define cpu_to_be32(x) (x) - #define cpu_to_be64(x) (x) - #define be32_to_cpu(x) (x) - #define be64_to_cpu(x) (x) -#endif - -// These tables are used by all codecs -// for fallback plain encoding/decoding: -extern const uint8_t avx2_base64_table_enc[]; -extern const uint8_t avx2_base64_table_dec[]; +#pragma once + +// Define machine endianness. This is for GCC: +#if (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__) + #define BASE64_AVX2_LITTLE_ENDIAN 1 +#else + #define BASE64_AVX2_LITTLE_ENDIAN 0 +#endif + +// This is for Clang: +#ifdef __LITTLE_ENDIAN__ + #define BASE64_AVX2_LITTLE_ENDIAN 1 +#endif + +#ifdef __BIG_ENDIAN__ + #define BASE64_AVX2_LITTLE_ENDIAN 0 +#endif + +// Endian conversion functions +#if BASE64_AVX2_LITTLE_ENDIAN + #define cpu_to_be32(x) __builtin_bswap32(x) + #define cpu_to_be64(x) __builtin_bswap64(x) + #define be32_to_cpu(x) __builtin_bswap32(x) + #define be64_to_cpu(x) __builtin_bswap64(x) +#else + #define cpu_to_be32(x) (x) + #define cpu_to_be64(x) (x) + #define be32_to_cpu(x) (x) + #define be64_to_cpu(x) (x) +#endif + +// These tables are used by all codecs +// for fallback plain encoding/decoding: +extern const uint8_t avx2_base64_table_enc[]; +extern const uint8_t avx2_base64_table_dec[]; diff --git a/contrib/libs/base64/avx2/dec_avx2.c b/contrib/libs/base64/avx2/dec_avx2.c index cd3cafd30a0..90dde140fb6 100644 --- a/contrib/libs/base64/avx2/dec_avx2.c +++ b/contrib/libs/base64/avx2/dec_avx2.c @@ -1,43 +1,43 @@ -// If we have AVX2 support, pick off 32 bytes at a time for as long as we can, -// but make sure that we quit before seeing any == markers at the end of the -// string. Also, because we write 8 zeroes at the end of the output, ensure -// that there are at least 11 valid bytes of input data remaining to close the -// gap. 32 + 2 + 11 = 45 bytes: -while (srclen >= 45) -{ - // Load string: - __m256i str = _mm256_loadu_si256((__m256i *)c); - - // The input consists of six character sets in the Base64 alphabet, - // which we need to map back to the 6-bit values they represent. - // There are three ranges, two singles, and then there's the rest. - // - // # From To Add Characters - // 1 [43] [62] +19 + - // 2 [47] [63] +16 / - // 3 [48..57] [52..61] +4 0..9 - // 4 [65..90] [0..25] -65 A..Z - // 5 [97..122] [26..51] -71 a..z - // (6) Everything else => invalid input - - const __m256i set1 = CMPEQ(str, '+'); - const __m256i set2 = CMPEQ(str, '/'); - const __m256i set3 = RANGE(str, '0', '9'); - const __m256i set4 = RANGE(str, 'A', 'Z'); - const __m256i set5 = RANGE(str, 'a', 'z'); - const __m256i set6 = CMPEQ(str, '-'); - const __m256i set7 = CMPEQ(str, '_'); - - __m256i delta = REPLACE(set1, 19); - delta = _mm256_or_si256(delta, REPLACE(set2, 16)); - delta = _mm256_or_si256(delta, REPLACE(set3, 4)); - delta = _mm256_or_si256(delta, REPLACE(set4, -65)); - delta = _mm256_or_si256(delta, REPLACE(set5, -71)); - delta = _mm256_or_si256(delta, REPLACE(set6, 17)); - delta = _mm256_or_si256(delta, REPLACE(set7, -32)); - - // Check for invalid input: if any of the delta values are zero, - // fall back on bytewise code to do error checking and reporting: +// If we have AVX2 support, pick off 32 bytes at a time for as long as we can, +// but make sure that we quit before seeing any == markers at the end of the +// string. Also, because we write 8 zeroes at the end of the output, ensure +// that there are at least 11 valid bytes of input data remaining to close the +// gap. 32 + 2 + 11 = 45 bytes: +while (srclen >= 45) +{ + // Load string: + __m256i str = _mm256_loadu_si256((__m256i *)c); + + // The input consists of six character sets in the Base64 alphabet, + // which we need to map back to the 6-bit values they represent. + // There are three ranges, two singles, and then there's the rest. + // + // # From To Add Characters + // 1 [43] [62] +19 + + // 2 [47] [63] +16 / + // 3 [48..57] [52..61] +4 0..9 + // 4 [65..90] [0..25] -65 A..Z + // 5 [97..122] [26..51] -71 a..z + // (6) Everything else => invalid input + + const __m256i set1 = CMPEQ(str, '+'); + const __m256i set2 = CMPEQ(str, '/'); + const __m256i set3 = RANGE(str, '0', '9'); + const __m256i set4 = RANGE(str, 'A', 'Z'); + const __m256i set5 = RANGE(str, 'a', 'z'); + const __m256i set6 = CMPEQ(str, '-'); + const __m256i set7 = CMPEQ(str, '_'); + + __m256i delta = REPLACE(set1, 19); + delta = _mm256_or_si256(delta, REPLACE(set2, 16)); + delta = _mm256_or_si256(delta, REPLACE(set3, 4)); + delta = _mm256_or_si256(delta, REPLACE(set4, -65)); + delta = _mm256_or_si256(delta, REPLACE(set5, -71)); + delta = _mm256_or_si256(delta, REPLACE(set6, 17)); + delta = _mm256_or_si256(delta, REPLACE(set7, -32)); + + // Check for invalid input: if any of the delta values are zero, + // fall back on bytewise code to do error checking and reporting: #ifdef _MSC_VER // Hack for MSVC miscompilation - it inserts vzeroupper for the break // (we need to clear YMM registers before exiting the function) @@ -45,21 +45,21 @@ while (srclen >= 45) // Save delta/str in memory manually. _mm256_zeroupper(); #endif - if (_mm256_movemask_epi8(CMPEQ(delta, 0))) { - break; - } - - // Now simply add the delta values to the input: - str = _mm256_add_epi8(str, delta); - - // Reshuffle the input to packed 12-byte output format: - str = dec_reshuffle(str); - - // Store back: - _mm256_storeu_si256((__m256i *)o, str); - - c += 32; - o += 24; - outl += 24; - srclen -= 32; -} + if (_mm256_movemask_epi8(CMPEQ(delta, 0))) { + break; + } + + // Now simply add the delta values to the input: + str = _mm256_add_epi8(str, delta); + + // Reshuffle the input to packed 12-byte output format: + str = dec_reshuffle(str); + + // Store back: + _mm256_storeu_si256((__m256i *)o, str); + + c += 32; + o += 24; + outl += 24; + srclen -= 32; +} diff --git a/contrib/libs/base64/avx2/dec_head.c b/contrib/libs/base64/avx2/dec_head.c index 8bbd46ebc43..6f10a3ff7f9 100644 --- a/contrib/libs/base64/avx2/dec_head.c +++ b/contrib/libs/base64/avx2/dec_head.c @@ -1,29 +1,29 @@ -int ret = 0; -const uint8_t *c = (const uint8_t *)src; -uint8_t *o = (uint8_t *)out; -uint8_t q; - -// Use local temporaries to avoid cache thrashing: -size_t outl = 0; -struct avx2_base64_state st; -st.eof = state->eof; -st.bytes = state->bytes; -st.carry = state->carry; - -// If we previously saw an EOF or an invalid character, bail out: -if (st.eof) { - *outlen = 0; - return 0; -} - -// Turn four 6-bit numbers into three bytes: -// out[0] = 11111122 -// out[1] = 22223333 -// out[2] = 33444444 - -// Duff's device again: -switch (st.bytes) -{ - for (;;) - { - case 0: +int ret = 0; +const uint8_t *c = (const uint8_t *)src; +uint8_t *o = (uint8_t *)out; +uint8_t q; + +// Use local temporaries to avoid cache thrashing: +size_t outl = 0; +struct avx2_base64_state st; +st.eof = state->eof; +st.bytes = state->bytes; +st.carry = state->carry; + +// If we previously saw an EOF or an invalid character, bail out: +if (st.eof) { + *outlen = 0; + return 0; +} + +// Turn four 6-bit numbers into three bytes: +// out[0] = 11111122 +// out[1] = 22223333 +// out[2] = 33444444 + +// Duff's device again: +switch (st.bytes) +{ + for (;;) + { + case 0: diff --git a/contrib/libs/base64/avx2/dec_tail.c b/contrib/libs/base64/avx2/dec_tail.c index b472f91b339..0226ba651eb 100644 --- a/contrib/libs/base64/avx2/dec_tail.c +++ b/contrib/libs/base64/avx2/dec_tail.c @@ -1,65 +1,65 @@ - if (srclen-- == 0) { - ret = 1; - break; - } - if ((q = avx2_base64_table_dec[*c++]) >= 254) { - st.eof = 1; - // Treat character '=' as invalid for byte 0: - break; - } - st.carry = q << 2; - st.bytes++; - - case 1: if (srclen-- == 0) { - ret = 1; - break; - } - if ((q = avx2_base64_table_dec[*c++]) >= 254) { - st.eof = 1; - // Treat character '=' as invalid for byte 1: - break; - } - *o++ = st.carry | (q >> 4); - st.carry = q << 4; - st.bytes++; - outl++; - - case 2: if (srclen-- == 0) { - ret = 1; - break; - } - if ((q = avx2_base64_table_dec[*c++]) >= 254) { - st.eof = 1; - // When q == 254, the input char is '='. Return 1 and EOF. - // Technically, should check if next byte is also '=', but never mind. - // When q == 255, the input char is invalid. Return 0 and EOF. - ret = (q == 254) ? 1 : 0; - break; - } - *o++ = st.carry | (q >> 2); - st.carry = q << 6; - st.bytes++; - outl++; - - case 3: if (srclen-- == 0) { - ret = 1; - break; - } - if ((q = avx2_base64_table_dec[*c++]) >= 254) { - st.eof = 1; - // When q == 254, the input char is '='. Return 1 and EOF. - // When q == 255, the input char is invalid. Return 0 and EOF. - ret = (q == 254) ? 1 : 0; - break; - } - *o++ = st.carry | q; - st.carry = 0; - st.bytes = 0; - outl++; - } -} -state->eof = st.eof; -state->bytes = st.bytes; -state->carry = st.carry; -*outlen = outl; -return ret; + if (srclen-- == 0) { + ret = 1; + break; + } + if ((q = avx2_base64_table_dec[*c++]) >= 254) { + st.eof = 1; + // Treat character '=' as invalid for byte 0: + break; + } + st.carry = q << 2; + st.bytes++; + + case 1: if (srclen-- == 0) { + ret = 1; + break; + } + if ((q = avx2_base64_table_dec[*c++]) >= 254) { + st.eof = 1; + // Treat character '=' as invalid for byte 1: + break; + } + *o++ = st.carry | (q >> 4); + st.carry = q << 4; + st.bytes++; + outl++; + + case 2: if (srclen-- == 0) { + ret = 1; + break; + } + if ((q = avx2_base64_table_dec[*c++]) >= 254) { + st.eof = 1; + // When q == 254, the input char is '='. Return 1 and EOF. + // Technically, should check if next byte is also '=', but never mind. + // When q == 255, the input char is invalid. Return 0 and EOF. + ret = (q == 254) ? 1 : 0; + break; + } + *o++ = st.carry | (q >> 2); + st.carry = q << 6; + st.bytes++; + outl++; + + case 3: if (srclen-- == 0) { + ret = 1; + break; + } + if ((q = avx2_base64_table_dec[*c++]) >= 254) { + st.eof = 1; + // When q == 254, the input char is '='. Return 1 and EOF. + // When q == 255, the input char is invalid. Return 0 and EOF. + ret = (q == 254) ? 1 : 0; + break; + } + *o++ = st.carry | q; + st.carry = 0; + st.bytes = 0; + outl++; + } +} +state->eof = st.eof; +state->bytes = st.bytes; +state->carry = st.carry; +*outlen = outl; +return ret; diff --git a/contrib/libs/base64/avx2/enc_avx2.c b/contrib/libs/base64/avx2/enc_avx2.c index 25e36f40b4f..5875684de40 100644 --- a/contrib/libs/base64/avx2/enc_avx2.c +++ b/contrib/libs/base64/avx2/enc_avx2.c @@ -1,22 +1,22 @@ -// If we have AVX2 support, pick off 24 bytes at a time for as long as we can. -// But because we read 32 bytes at a time, ensure we have enough room to do a -// full 32-byte read without segfaulting: -while (srclen >= 32) -{ - // Load string: - __m256i str = _mm256_loadu_si256((__m256i *)c); - - // Reshuffle: - str = enc_reshuffle(str); - - // Translate reshuffled bytes to the Base64 alphabet: - str = enc_translate(str); - - // Store: - _mm256_storeu_si256((__m256i *)o, str); - - c += 24; // 6 * 4 bytes of input - o += 32; // 8 * 4 bytes of output - outl += 32; - srclen -= 24; -} +// If we have AVX2 support, pick off 24 bytes at a time for as long as we can. +// But because we read 32 bytes at a time, ensure we have enough room to do a +// full 32-byte read without segfaulting: +while (srclen >= 32) +{ + // Load string: + __m256i str = _mm256_loadu_si256((__m256i *)c); + + // Reshuffle: + str = enc_reshuffle(str); + + // Translate reshuffled bytes to the Base64 alphabet: + str = enc_translate(str); + + // Store: + _mm256_storeu_si256((__m256i *)o, str); + + c += 24; // 6 * 4 bytes of input + o += 32; // 8 * 4 bytes of output + outl += 32; + srclen -= 24; +} diff --git a/contrib/libs/base64/avx2/enc_head.c b/contrib/libs/base64/avx2/enc_head.c index 3d05b0bd049..5b03c7f71b3 100644 --- a/contrib/libs/base64/avx2/enc_head.c +++ b/contrib/libs/base64/avx2/enc_head.c @@ -1,23 +1,23 @@ -// Assume that *out is large enough to contain the output. -// Theoretically it should be 4/3 the length of src. -const uint8_t *c = (const uint8_t *)src; -uint8_t *o = (uint8_t *)out; - -// Use local temporaries to avoid cache thrashing: -size_t outl = 0; -struct avx2_base64_state st; -st.bytes = state->bytes; -st.carry = state->carry; - -// Turn three bytes into four 6-bit numbers: -// in[0] = 00111111 -// in[1] = 00112222 -// in[2] = 00222233 -// in[3] = 00333333 - -// Duff's device, a for() loop inside a switch() statement. Legal! -switch (st.bytes) -{ - for (;;) - { - case 0: +// Assume that *out is large enough to contain the output. +// Theoretically it should be 4/3 the length of src. +const uint8_t *c = (const uint8_t *)src; +uint8_t *o = (uint8_t *)out; + +// Use local temporaries to avoid cache thrashing: +size_t outl = 0; +struct avx2_base64_state st; +st.bytes = state->bytes; +st.carry = state->carry; + +// Turn three bytes into four 6-bit numbers: +// in[0] = 00111111 +// in[1] = 00112222 +// in[2] = 00222233 +// in[3] = 00333333 + +// Duff's device, a for() loop inside a switch() statement. Legal! +switch (st.bytes) +{ + for (;;) + { + case 0: diff --git a/contrib/libs/base64/avx2/enc_tail.c b/contrib/libs/base64/avx2/enc_tail.c index e4362db594a..8d6c2470192 100644 --- a/contrib/libs/base64/avx2/enc_tail.c +++ b/contrib/libs/base64/avx2/enc_tail.c @@ -1,28 +1,28 @@ - if (srclen-- == 0) { - break; - } - *o++ = avx2_base64_table_enc[*c >> 2]; - st.carry = (*c++ << 4) & 0x30; - st.bytes++; - outl += 1; - - case 1: if (srclen-- == 0) { - break; - } - *o++ = avx2_base64_table_enc[st.carry | (*c >> 4)]; - st.carry = (*c++ << 2) & 0x3C; - st.bytes++; - outl += 1; - - case 2: if (srclen-- == 0) { - break; - } - *o++ = avx2_base64_table_enc[st.carry | (*c >> 6)]; - *o++ = avx2_base64_table_enc[*c++ & 0x3F]; - st.bytes = 0; - outl += 2; - } -} -state->bytes = st.bytes; -state->carry = st.carry; -*outlen = outl; + if (srclen-- == 0) { + break; + } + *o++ = avx2_base64_table_enc[*c >> 2]; + st.carry = (*c++ << 4) & 0x30; + st.bytes++; + outl += 1; + + case 1: if (srclen-- == 0) { + break; + } + *o++ = avx2_base64_table_enc[st.carry | (*c >> 4)]; + st.carry = (*c++ << 2) & 0x3C; + st.bytes++; + outl += 1; + + case 2: if (srclen-- == 0) { + break; + } + *o++ = avx2_base64_table_enc[st.carry | (*c >> 6)]; + *o++ = avx2_base64_table_enc[*c++ & 0x3F]; + st.bytes = 0; + outl += 2; + } +} +state->bytes = st.bytes; +state->carry = st.carry; +*outlen = outl; diff --git a/contrib/libs/base64/avx2/lib.c b/contrib/libs/base64/avx2/lib.c index b0671c8caec..81ead08503e 100644 --- a/contrib/libs/base64/avx2/lib.c +++ b/contrib/libs/base64/avx2/lib.c @@ -1,121 +1,121 @@ -#include <stdint.h> -#include <stddef.h> - -#include "libbase64.h" -#include "codecs.h" - -const uint8_t -avx2_base64_table_enc[] = - "ABCDEFGHIJKLMNOPQRSTUVWXYZ" - "abcdefghijklmnopqrstuvwxyz" - "0123456789+/"; - -// In the lookup table below, note that the value for '=' (character 61) is -// 254, not 255. This character is used for in-band signaling of the end of -// the datastream, and we will use that later. The characters A-Z, a-z, 0-9 -// and + / are mapped to their "decoded" values. The other bytes all map to -// the value 255, which flags them as "invalid input". - -const uint8_t -avx2_base64_table_dec[] = -{ - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, // 0..15 - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, // 16..31 - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 62, 254, 62, 255, 63, // 32..47 - 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 255, 255, 255, 254, 255, 255, // 48..63 - 255, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, // 64..79 - 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 255, 255, 255, 255, 63, // 80..95 - 255, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, // 96..111 - 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 255, 255, 255, 255, 255, // 112..127 - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, // 128..143 - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, -}; - -void -avx2_base64_stream_encode_init (struct avx2_base64_state *state) -{ - state->eof = 0; - state->bytes = 0; - state->carry = 0; -} - -void -avx2_base64_stream_encode_final - ( struct avx2_base64_state *state - , char *out - , size_t *outlen - ) -{ - uint8_t *o = (uint8_t *)out; - - if (state->bytes == 1) { - *o++ = avx2_base64_table_enc[state->carry]; - *o++ = '='; - *o++ = '='; - *outlen = 3; - return; - } - if (state->bytes == 2) { - *o++ = avx2_base64_table_enc[state->carry]; - *o++ = '='; - *outlen = 2; - return; - } - *outlen = 0; -} - -void -avx2_base64_stream_decode_init (struct avx2_base64_state *state) -{ - state->eof = 0; - state->bytes = 0; - state->carry = 0; -} - -void -avx2_base64_encode - ( const char *src - , size_t srclen - , char *out - , size_t *outlen - ) -{ - size_t s; - size_t t; - struct avx2_base64_state state; - - // Init the stream reader: - avx2_base64_stream_encode_init(&state); - - // Feed the whole string to the stream reader: - avx2_base64_stream_encode(&state, src, srclen, out, &s); - - // Finalize the stream by writing trailer if any: - avx2_base64_stream_encode_final(&state, out + s, &t); - - // Final output length is stream length plus tail: - *outlen = s + t; -} - -int -avx2_base64_decode - ( const char *src - , size_t srclen - , char *out - , size_t *outlen - ) -{ - struct avx2_base64_state state; - - // Init the stream reader: - avx2_base64_stream_decode_init(&state); - - // Feed the whole string to the stream reader: - return avx2_base64_stream_decode(&state, src, srclen, out, outlen); -} +#include <stdint.h> +#include <stddef.h> + +#include "libbase64.h" +#include "codecs.h" + +const uint8_t +avx2_base64_table_enc[] = + "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + "abcdefghijklmnopqrstuvwxyz" + "0123456789+/"; + +// In the lookup table below, note that the value for '=' (character 61) is +// 254, not 255. This character is used for in-band signaling of the end of +// the datastream, and we will use that later. The characters A-Z, a-z, 0-9 +// and + / are mapped to their "decoded" values. The other bytes all map to +// the value 255, which flags them as "invalid input". + +const uint8_t +avx2_base64_table_dec[] = +{ + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, // 0..15 + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, // 16..31 + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 62, 254, 62, 255, 63, // 32..47 + 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 255, 255, 255, 254, 255, 255, // 48..63 + 255, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, // 64..79 + 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 255, 255, 255, 255, 63, // 80..95 + 255, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, // 96..111 + 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 255, 255, 255, 255, 255, // 112..127 + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, // 128..143 + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, +}; + +void +avx2_base64_stream_encode_init (struct avx2_base64_state *state) +{ + state->eof = 0; + state->bytes = 0; + state->carry = 0; +} + +void +avx2_base64_stream_encode_final + ( struct avx2_base64_state *state + , char *out + , size_t *outlen + ) +{ + uint8_t *o = (uint8_t *)out; + + if (state->bytes == 1) { + *o++ = avx2_base64_table_enc[state->carry]; + *o++ = '='; + *o++ = '='; + *outlen = 3; + return; + } + if (state->bytes == 2) { + *o++ = avx2_base64_table_enc[state->carry]; + *o++ = '='; + *outlen = 2; + return; + } + *outlen = 0; +} + +void +avx2_base64_stream_decode_init (struct avx2_base64_state *state) +{ + state->eof = 0; + state->bytes = 0; + state->carry = 0; +} + +void +avx2_base64_encode + ( const char *src + , size_t srclen + , char *out + , size_t *outlen + ) +{ + size_t s; + size_t t; + struct avx2_base64_state state; + + // Init the stream reader: + avx2_base64_stream_encode_init(&state); + + // Feed the whole string to the stream reader: + avx2_base64_stream_encode(&state, src, srclen, out, &s); + + // Finalize the stream by writing trailer if any: + avx2_base64_stream_encode_final(&state, out + s, &t); + + // Final output length is stream length plus tail: + *outlen = s + t; +} + +int +avx2_base64_decode + ( const char *src + , size_t srclen + , char *out + , size_t *outlen + ) +{ + struct avx2_base64_state state; + + // Init the stream reader: + avx2_base64_stream_decode_init(&state); + + // Feed the whole string to the stream reader: + return avx2_base64_stream_decode(&state, src, srclen, out, outlen); +} diff --git a/contrib/libs/base64/avx2/libbase64.h b/contrib/libs/base64/avx2/libbase64.h index 91a8ab1ed2e..2d63217c785 100644 --- a/contrib/libs/base64/avx2/libbase64.h +++ b/contrib/libs/base64/avx2/libbase64.h @@ -1,89 +1,89 @@ -#pragma once - -#ifdef __cplusplus -extern "C" { -#endif - -struct avx2_base64_state { - int eof; - int bytes; - unsigned char carry; -}; - -/* Wrapper function to encode a plain string of given length. Output is written - * to *out without trailing zero. Output length in bytes is written to *outlen. - * The buffer in `out` has been allocated by the caller and is at least 4/3 the - * size of the input. See above for `flags`; set to 0 for default operation: */ -void avx2_base64_encode - ( const char *src - , size_t srclen - , char *out - , size_t *outlen - ) ; - -/* Call this before calling base64_stream_encode() to init the state. See above - * for `flags`; set to 0 for default operation: */ -void avx2_base64_stream_encode_init - ( struct avx2_base64_state *state - ) ; - -/* Encodes the block of data of given length at `src`, into the buffer at - * `out`. Caller is responsible for allocating a large enough out-buffer; it - * must be at least 4/3 the size of the in-buffer, but take some margin. Places - * the number of new bytes written into `outlen` (which is set to zero when the - * function starts). Does not zero-terminate or finalize the output. */ -void avx2_base64_stream_encode - ( struct avx2_base64_state *state - , const char *src - , size_t srclen - , char *out - , size_t *outlen - ) ; - -/* Finalizes the output begun by previous calls to `base64_stream_encode()`. - * Adds the required end-of-stream markers if appropriate. `outlen` is modified - * and will contain the number of new bytes written at `out` (which will quite - * often be zero). */ -void avx2_base64_stream_encode_final - ( struct avx2_base64_state *state - , char *out - , size_t *outlen - ) ; - -/* Wrapper function to decode a plain string of given length. Output is written - * to *out without trailing zero. Output length in bytes is written to *outlen. - * The buffer in `out` has been allocated by the caller and is at least 3/4 the - * size of the input. See above for `flags`, set to 0 for default operation: */ -int avx2_base64_decode - ( const char *src - , size_t srclen - , char *out - , size_t *outlen - ) ; - -/* Call this before calling base64_stream_decode() to init the state. See above - * for `flags`; set to 0 for default operation: */ -void avx2_base64_stream_decode_init - ( struct avx2_base64_state *state - ) ; - -/* Decodes the block of data of given length at `src`, into the buffer at - * `out`. Caller is responsible for allocating a large enough out-buffer; it - * must be at least 3/4 the size of the in-buffer, but take some margin. Places - * the number of new bytes written into `outlen` (which is set to zero when the - * function starts). Does not zero-terminate the output. Returns 1 if all is - * well, and 0 if a decoding error was found, such as an invalid character. - * Returns -1 if the chosen codec is not included in the current build. Used by - * the test harness to check whether a codec is available for testing. */ -int avx2_base64_stream_decode - ( struct avx2_base64_state *state - , const char *src - , size_t srclen - , char *out - , size_t *outlen - ) ; - -#ifdef __cplusplus -} -#endif - +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +struct avx2_base64_state { + int eof; + int bytes; + unsigned char carry; +}; + +/* Wrapper function to encode a plain string of given length. Output is written + * to *out without trailing zero. Output length in bytes is written to *outlen. + * The buffer in `out` has been allocated by the caller and is at least 4/3 the + * size of the input. See above for `flags`; set to 0 for default operation: */ +void avx2_base64_encode + ( const char *src + , size_t srclen + , char *out + , size_t *outlen + ) ; + +/* Call this before calling base64_stream_encode() to init the state. See above + * for `flags`; set to 0 for default operation: */ +void avx2_base64_stream_encode_init + ( struct avx2_base64_state *state + ) ; + +/* Encodes the block of data of given length at `src`, into the buffer at + * `out`. Caller is responsible for allocating a large enough out-buffer; it + * must be at least 4/3 the size of the in-buffer, but take some margin. Places + * the number of new bytes written into `outlen` (which is set to zero when the + * function starts). Does not zero-terminate or finalize the output. */ +void avx2_base64_stream_encode + ( struct avx2_base64_state *state + , const char *src + , size_t srclen + , char *out + , size_t *outlen + ) ; + +/* Finalizes the output begun by previous calls to `base64_stream_encode()`. + * Adds the required end-of-stream markers if appropriate. `outlen` is modified + * and will contain the number of new bytes written at `out` (which will quite + * often be zero). */ +void avx2_base64_stream_encode_final + ( struct avx2_base64_state *state + , char *out + , size_t *outlen + ) ; + +/* Wrapper function to decode a plain string of given length. Output is written + * to *out without trailing zero. Output length in bytes is written to *outlen. + * The buffer in `out` has been allocated by the caller and is at least 3/4 the + * size of the input. See above for `flags`, set to 0 for default operation: */ +int avx2_base64_decode + ( const char *src + , size_t srclen + , char *out + , size_t *outlen + ) ; + +/* Call this before calling base64_stream_decode() to init the state. See above + * for `flags`; set to 0 for default operation: */ +void avx2_base64_stream_decode_init + ( struct avx2_base64_state *state + ) ; + +/* Decodes the block of data of given length at `src`, into the buffer at + * `out`. Caller is responsible for allocating a large enough out-buffer; it + * must be at least 3/4 the size of the in-buffer, but take some margin. Places + * the number of new bytes written into `outlen` (which is set to zero when the + * function starts). Does not zero-terminate the output. Returns 1 if all is + * well, and 0 if a decoding error was found, such as an invalid character. + * Returns -1 if the chosen codec is not included in the current build. Used by + * the test harness to check whether a codec is available for testing. */ +int avx2_base64_stream_decode + ( struct avx2_base64_state *state + , const char *src + , size_t srclen + , char *out + , size_t *outlen + ) ; + +#ifdef __cplusplus +} +#endif + diff --git a/contrib/libs/base64/avx2/ya.make b/contrib/libs/base64/avx2/ya.make index b0dc5ce7720..fe719768d82 100644 --- a/contrib/libs/base64/avx2/ya.make +++ b/contrib/libs/base64/avx2/ya.make @@ -1,11 +1,11 @@ -OWNER( - yazevnul +OWNER( + yazevnul g:contrib g:cpp-contrib -) - -LIBRARY() - +) + +LIBRARY() + LICENSE( BSD-2-Clause AND MIT @@ -13,14 +13,14 @@ LICENSE( LICENSE_TEXTS(.yandex_meta/licenses.list.txt) -NO_UTIL() - -SRCS( - codec_avx2.c - lib.c -) - -IF (ARCH_X86_64 OR ARCH_I386) +NO_UTIL() + +SRCS( + codec_avx2.c + lib.c +) + +IF (ARCH_X86_64 OR ARCH_I386) IF (MSVC AND NOT CLANG_CL) CONLYFLAGS(/D__AVX2__=1) ELSEIF (CLANG_CL) @@ -30,7 +30,7 @@ IF (ARCH_X86_64 OR ARCH_I386) -mavx2 -std=c11 ) - ENDIF() -ENDIF() - -END() + ENDIF() +ENDIF() + +END() diff --git a/contrib/libs/base64/neon32/codec_neon32.c b/contrib/libs/base64/neon32/codec_neon32.c index 2c9ae02f759..05fcfc3e63d 100644 --- a/contrib/libs/base64/neon32/codec_neon32.c +++ b/contrib/libs/base64/neon32/codec_neon32.c @@ -1,160 +1,160 @@ -#if (defined(__ARM_NEON) && !defined(__ARM_NEON__)) -#define __ARM_NEON__ -#endif - -#include <stdint.h> -#include <stddef.h> -#include <stdlib.h> -#ifdef __ARM_NEON__ -#include <arm_neon.h> -#endif - -#include "libbase64.h" -#include "codecs.h" - -#if (defined(__arm__) && defined(__ARM_NEON__)) - -#define CMPGT(s,n) vcgtq_u8((s), vdupq_n_u8(n)) -#define CMPEQ(s,n) vceqq_u8((s), vdupq_n_u8(n)) -#define REPLACE(s,n) vandq_u8((s), vdupq_n_u8(n)) -#define RANGE(s,a,b) vandq_u8(vcgeq_u8((s), vdupq_n_u8(a)), vcleq_u8((s), vdupq_n_u8(b))) - -static inline uint8x16x4_t -enc_reshuffle (uint8x16x3_t in) -{ - uint8x16x4_t out; - - // Divide bits of three input bytes over four output bytes: - out.val[0] = vshrq_n_u8(in.val[0], 2); - out.val[1] = vorrq_u8(vshrq_n_u8(in.val[1], 4), vshlq_n_u8(in.val[0], 4)); - out.val[2] = vorrq_u8(vshrq_n_u8(in.val[2], 6), vshlq_n_u8(in.val[1], 2)); - out.val[3] = in.val[2]; - - // Clear top two bits: - out.val[0] = vandq_u8(out.val[0], vdupq_n_u8(0x3F)); - out.val[1] = vandq_u8(out.val[1], vdupq_n_u8(0x3F)); - out.val[2] = vandq_u8(out.val[2], vdupq_n_u8(0x3F)); - out.val[3] = vandq_u8(out.val[3], vdupq_n_u8(0x3F)); - - return out; -} - -static inline uint8x16x4_t -enc_translate (uint8x16x4_t in) -{ - uint8x16x4_t mask1, mask2, mask3, mask4, out; - - // Translate values 0..63 to the Base64 alphabet. There are five sets: - // # From To Abs Delta Characters - // 0 [0..25] [65..90] +65 +65 ABCDEFGHIJKLMNOPQRSTUVWXYZ - // 1 [26..51] [97..122] +71 +6 abcdefghijklmnopqrstuvwxyz - // 2 [52..61] [48..57] -4 -75 0123456789 - // 3 [62] [43] -19 -15 + - // 4 [63] [47] -16 +3 / - - // Create cumulative masks for characters in sets [1,2,3,4], [2,3,4], - // [3,4], and [4]: - mask1.val[0] = CMPGT(in.val[0], 25); - mask1.val[1] = CMPGT(in.val[1], 25); - mask1.val[2] = CMPGT(in.val[2], 25); - mask1.val[3] = CMPGT(in.val[3], 25); - - mask2.val[0] = CMPGT(in.val[0], 51); - mask2.val[1] = CMPGT(in.val[1], 51); - mask2.val[2] = CMPGT(in.val[2], 51); - mask2.val[3] = CMPGT(in.val[3], 51); - - mask3.val[0] = CMPGT(in.val[0], 61); - mask3.val[1] = CMPGT(in.val[1], 61); - mask3.val[2] = CMPGT(in.val[2], 61); - mask3.val[3] = CMPGT(in.val[3], 61); - - mask4.val[0] = CMPEQ(in.val[0], 63); - mask4.val[1] = CMPEQ(in.val[1], 63); - mask4.val[2] = CMPEQ(in.val[2], 63); - mask4.val[3] = CMPEQ(in.val[3], 63); - - // All characters are at least in cumulative set 0, so add 'A': - out.val[0] = vaddq_u8(in.val[0], vdupq_n_u8(65)); - out.val[1] = vaddq_u8(in.val[1], vdupq_n_u8(65)); - out.val[2] = vaddq_u8(in.val[2], vdupq_n_u8(65)); - out.val[3] = vaddq_u8(in.val[3], vdupq_n_u8(65)); - - // For inputs which are also in any of the other cumulative sets, - // add delta values against the previous set(s) to correct the shift: - out.val[0] = vaddq_u8(out.val[0], REPLACE(mask1.val[0], 6)); - out.val[1] = vaddq_u8(out.val[1], REPLACE(mask1.val[1], 6)); - out.val[2] = vaddq_u8(out.val[2], REPLACE(mask1.val[2], 6)); - out.val[3] = vaddq_u8(out.val[3], REPLACE(mask1.val[3], 6)); - - out.val[0] = vsubq_u8(out.val[0], REPLACE(mask2.val[0], 75)); - out.val[1] = vsubq_u8(out.val[1], REPLACE(mask2.val[1], 75)); - out.val[2] = vsubq_u8(out.val[2], REPLACE(mask2.val[2], 75)); - out.val[3] = vsubq_u8(out.val[3], REPLACE(mask2.val[3], 75)); - - out.val[0] = vsubq_u8(out.val[0], REPLACE(mask3.val[0], 15)); - out.val[1] = vsubq_u8(out.val[1], REPLACE(mask3.val[1], 15)); - out.val[2] = vsubq_u8(out.val[2], REPLACE(mask3.val[2], 15)); - out.val[3] = vsubq_u8(out.val[3], REPLACE(mask3.val[3], 15)); - - out.val[0] = vaddq_u8(out.val[0], REPLACE(mask4.val[0], 3)); - out.val[1] = vaddq_u8(out.val[1], REPLACE(mask4.val[1], 3)); - out.val[2] = vaddq_u8(out.val[2], REPLACE(mask4.val[2], 3)); - out.val[3] = vaddq_u8(out.val[3], REPLACE(mask4.val[3], 3)); - - return out; -} - -#endif - -// Stride size is so large on these NEON 32-bit functions -// (48 bytes encode, 32 bytes decode) that we inline the -// uint32 codec to stay performant on smaller inputs. - -void -neon32_base64_stream_encode - ( struct neon32_base64_state *state - , const char *src - , size_t srclen - , char *out - , size_t *outlen - ) -{ -#if (defined(__arm__) && defined(__ARM_NEON__)) - #include "enc_head.c" - #include "enc_neon.c" - #include "enc_uint32.c" - #include "enc_tail.c" -#else - (void)state; - (void)src; - (void)srclen; - (void)out; - (void)outlen; - abort(); -#endif -} - -int -neon32_base64_stream_decode - ( struct neon32_base64_state *state - , const char *src - , size_t srclen - , char *out - , size_t *outlen - ) -{ -#if (defined(__arm__) && defined(__ARM_NEON__)) - #include "dec_head.c" - #include "dec_neon.c" - #include "dec_uint32.c" - #include "dec_tail.c" -#else - (void)state; - (void)src; - (void)srclen; - (void)out; - (void)outlen; - abort(); -#endif -} +#if (defined(__ARM_NEON) && !defined(__ARM_NEON__)) +#define __ARM_NEON__ +#endif + +#include <stdint.h> +#include <stddef.h> +#include <stdlib.h> +#ifdef __ARM_NEON__ +#include <arm_neon.h> +#endif + +#include "libbase64.h" +#include "codecs.h" + +#if (defined(__arm__) && defined(__ARM_NEON__)) + +#define CMPGT(s,n) vcgtq_u8((s), vdupq_n_u8(n)) +#define CMPEQ(s,n) vceqq_u8((s), vdupq_n_u8(n)) +#define REPLACE(s,n) vandq_u8((s), vdupq_n_u8(n)) +#define RANGE(s,a,b) vandq_u8(vcgeq_u8((s), vdupq_n_u8(a)), vcleq_u8((s), vdupq_n_u8(b))) + +static inline uint8x16x4_t +enc_reshuffle (uint8x16x3_t in) +{ + uint8x16x4_t out; + + // Divide bits of three input bytes over four output bytes: + out.val[0] = vshrq_n_u8(in.val[0], 2); + out.val[1] = vorrq_u8(vshrq_n_u8(in.val[1], 4), vshlq_n_u8(in.val[0], 4)); + out.val[2] = vorrq_u8(vshrq_n_u8(in.val[2], 6), vshlq_n_u8(in.val[1], 2)); + out.val[3] = in.val[2]; + + // Clear top two bits: + out.val[0] = vandq_u8(out.val[0], vdupq_n_u8(0x3F)); + out.val[1] = vandq_u8(out.val[1], vdupq_n_u8(0x3F)); + out.val[2] = vandq_u8(out.val[2], vdupq_n_u8(0x3F)); + out.val[3] = vandq_u8(out.val[3], vdupq_n_u8(0x3F)); + + return out; +} + +static inline uint8x16x4_t +enc_translate (uint8x16x4_t in) +{ + uint8x16x4_t mask1, mask2, mask3, mask4, out; + + // Translate values 0..63 to the Base64 alphabet. There are five sets: + // # From To Abs Delta Characters + // 0 [0..25] [65..90] +65 +65 ABCDEFGHIJKLMNOPQRSTUVWXYZ + // 1 [26..51] [97..122] +71 +6 abcdefghijklmnopqrstuvwxyz + // 2 [52..61] [48..57] -4 -75 0123456789 + // 3 [62] [43] -19 -15 + + // 4 [63] [47] -16 +3 / + + // Create cumulative masks for characters in sets [1,2,3,4], [2,3,4], + // [3,4], and [4]: + mask1.val[0] = CMPGT(in.val[0], 25); + mask1.val[1] = CMPGT(in.val[1], 25); + mask1.val[2] = CMPGT(in.val[2], 25); + mask1.val[3] = CMPGT(in.val[3], 25); + + mask2.val[0] = CMPGT(in.val[0], 51); + mask2.val[1] = CMPGT(in.val[1], 51); + mask2.val[2] = CMPGT(in.val[2], 51); + mask2.val[3] = CMPGT(in.val[3], 51); + + mask3.val[0] = CMPGT(in.val[0], 61); + mask3.val[1] = CMPGT(in.val[1], 61); + mask3.val[2] = CMPGT(in.val[2], 61); + mask3.val[3] = CMPGT(in.val[3], 61); + + mask4.val[0] = CMPEQ(in.val[0], 63); + mask4.val[1] = CMPEQ(in.val[1], 63); + mask4.val[2] = CMPEQ(in.val[2], 63); + mask4.val[3] = CMPEQ(in.val[3], 63); + + // All characters are at least in cumulative set 0, so add 'A': + out.val[0] = vaddq_u8(in.val[0], vdupq_n_u8(65)); + out.val[1] = vaddq_u8(in.val[1], vdupq_n_u8(65)); + out.val[2] = vaddq_u8(in.val[2], vdupq_n_u8(65)); + out.val[3] = vaddq_u8(in.val[3], vdupq_n_u8(65)); + + // For inputs which are also in any of the other cumulative sets, + // add delta values against the previous set(s) to correct the shift: + out.val[0] = vaddq_u8(out.val[0], REPLACE(mask1.val[0], 6)); + out.val[1] = vaddq_u8(out.val[1], REPLACE(mask1.val[1], 6)); + out.val[2] = vaddq_u8(out.val[2], REPLACE(mask1.val[2], 6)); + out.val[3] = vaddq_u8(out.val[3], REPLACE(mask1.val[3], 6)); + + out.val[0] = vsubq_u8(out.val[0], REPLACE(mask2.val[0], 75)); + out.val[1] = vsubq_u8(out.val[1], REPLACE(mask2.val[1], 75)); + out.val[2] = vsubq_u8(out.val[2], REPLACE(mask2.val[2], 75)); + out.val[3] = vsubq_u8(out.val[3], REPLACE(mask2.val[3], 75)); + + out.val[0] = vsubq_u8(out.val[0], REPLACE(mask3.val[0], 15)); + out.val[1] = vsubq_u8(out.val[1], REPLACE(mask3.val[1], 15)); + out.val[2] = vsubq_u8(out.val[2], REPLACE(mask3.val[2], 15)); + out.val[3] = vsubq_u8(out.val[3], REPLACE(mask3.val[3], 15)); + + out.val[0] = vaddq_u8(out.val[0], REPLACE(mask4.val[0], 3)); + out.val[1] = vaddq_u8(out.val[1], REPLACE(mask4.val[1], 3)); + out.val[2] = vaddq_u8(out.val[2], REPLACE(mask4.val[2], 3)); + out.val[3] = vaddq_u8(out.val[3], REPLACE(mask4.val[3], 3)); + + return out; +} + +#endif + +// Stride size is so large on these NEON 32-bit functions +// (48 bytes encode, 32 bytes decode) that we inline the +// uint32 codec to stay performant on smaller inputs. + +void +neon32_base64_stream_encode + ( struct neon32_base64_state *state + , const char *src + , size_t srclen + , char *out + , size_t *outlen + ) +{ +#if (defined(__arm__) && defined(__ARM_NEON__)) + #include "enc_head.c" + #include "enc_neon.c" + #include "enc_uint32.c" + #include "enc_tail.c" +#else + (void)state; + (void)src; + (void)srclen; + (void)out; + (void)outlen; + abort(); +#endif +} + +int +neon32_base64_stream_decode + ( struct neon32_base64_state *state + , const char *src + , size_t srclen + , char *out + , size_t *outlen + ) +{ +#if (defined(__arm__) && defined(__ARM_NEON__)) + #include "dec_head.c" + #include "dec_neon.c" + #include "dec_uint32.c" + #include "dec_tail.c" +#else + (void)state; + (void)src; + (void)srclen; + (void)out; + (void)outlen; + abort(); +#endif +} diff --git a/contrib/libs/base64/neon32/codecs.h b/contrib/libs/base64/neon32/codecs.h index 5c9ec309c20..23cca82c6f3 100644 --- a/contrib/libs/base64/neon32/codecs.h +++ b/contrib/libs/base64/neon32/codecs.h @@ -1,35 +1,35 @@ -#pragma once - -// Define machine endianness. This is for GCC: -#if (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__) - #define BASE64_NEON32_LITTLE_ENDIAN 1 -#else - #define BASE64_NEON32_LITTLE_ENDIAN 0 -#endif - -// This is for Clang: -#ifdef __LITTLE_ENDIAN__ - #define BASE64_NEON32_LITTLE_ENDIAN 1 -#endif - -#ifdef __BIG_ENDIAN__ - #define BASE64_NEON32_LITTLE_ENDIAN 0 -#endif - -// Endian conversion functions -#if BASE64_NEON32_LITTLE_ENDIAN - #define cpu_to_be32(x) __builtin_bswap32(x) - #define cpu_to_be64(x) __builtin_bswap64(x) - #define be32_to_cpu(x) __builtin_bswap32(x) - #define be64_to_cpu(x) __builtin_bswap64(x) -#else - #define cpu_to_be32(x) (x) - #define cpu_to_be64(x) (x) - #define be32_to_cpu(x) (x) - #define be64_to_cpu(x) (x) -#endif - -// These tables are used by all codecs -// for fallback plain encoding/decoding: -extern const uint8_t neon32_base64_table_enc[]; -extern const uint8_t neon32_base64_table_dec[]; +#pragma once + +// Define machine endianness. This is for GCC: +#if (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__) + #define BASE64_NEON32_LITTLE_ENDIAN 1 +#else + #define BASE64_NEON32_LITTLE_ENDIAN 0 +#endif + +// This is for Clang: +#ifdef __LITTLE_ENDIAN__ + #define BASE64_NEON32_LITTLE_ENDIAN 1 +#endif + +#ifdef __BIG_ENDIAN__ + #define BASE64_NEON32_LITTLE_ENDIAN 0 +#endif + +// Endian conversion functions +#if BASE64_NEON32_LITTLE_ENDIAN + #define cpu_to_be32(x) __builtin_bswap32(x) + #define cpu_to_be64(x) __builtin_bswap64(x) + #define be32_to_cpu(x) __builtin_bswap32(x) + #define be64_to_cpu(x) __builtin_bswap64(x) +#else + #define cpu_to_be32(x) (x) + #define cpu_to_be64(x) (x) + #define be32_to_cpu(x) (x) + #define be64_to_cpu(x) (x) +#endif + +// These tables are used by all codecs +// for fallback plain encoding/decoding: +extern const uint8_t neon32_base64_table_enc[]; +extern const uint8_t neon32_base64_table_dec[]; diff --git a/contrib/libs/base64/neon32/dec_head.c b/contrib/libs/base64/neon32/dec_head.c index bd023118ff5..28020935556 100644 --- a/contrib/libs/base64/neon32/dec_head.c +++ b/contrib/libs/base64/neon32/dec_head.c @@ -1,29 +1,29 @@ -int ret = 0; -const uint8_t *c = (const uint8_t *)src; -uint8_t *o = (uint8_t *)out; -uint8_t q; - -// Use local temporaries to avoid cache thrashing: -size_t outl = 0; -struct neon32_base64_state st; -st.eof = state->eof; -st.bytes = state->bytes; -st.carry = state->carry; - -// If we previously saw an EOF or an invalid character, bail out: -if (st.eof) { - *outlen = 0; - return 0; -} - -// Turn four 6-bit numbers into three bytes: -// out[0] = 11111122 -// out[1] = 22223333 -// out[2] = 33444444 - -// Duff's device again: -switch (st.bytes) -{ - for (;;) - { - case 0: +int ret = 0; +const uint8_t *c = (const uint8_t *)src; +uint8_t *o = (uint8_t *)out; +uint8_t q; + +// Use local temporaries to avoid cache thrashing: +size_t outl = 0; +struct neon32_base64_state st; +st.eof = state->eof; +st.bytes = state->bytes; +st.carry = state->carry; + +// If we previously saw an EOF or an invalid character, bail out: +if (st.eof) { + *outlen = 0; + return 0; +} + +// Turn four 6-bit numbers into three bytes: +// out[0] = 11111122 +// out[1] = 22223333 +// out[2] = 33444444 + +// Duff's device again: +switch (st.bytes) +{ + for (;;) + { + case 0: diff --git a/contrib/libs/base64/neon32/dec_neon.c b/contrib/libs/base64/neon32/dec_neon.c index 713d8ca9a43..30d846a9167 100644 --- a/contrib/libs/base64/neon32/dec_neon.c +++ b/contrib/libs/base64/neon32/dec_neon.c @@ -1,77 +1,77 @@ -// If we have NEON support, pick off 64 bytes at a time for as long as we can. -// Unlike the SSE codecs, we don't write trailing zero bytes to output, so we -// don't need to check if we have enough remaining input to cover them: -while (srclen >= 64) -{ - uint8x16x4_t set1, set2, set3, set4, set5, set6, set7, delta; - uint8x16x3_t dec; - - // Load 64 bytes and deinterleave: - uint8x16x4_t str = vld4q_u8((uint8_t *)c); - - // The input consists of six character sets in the Base64 alphabet, - // which we need to map back to the 6-bit values they represent. - // There are three ranges, two singles, and then there's the rest. - // - // # From To Add Characters - // 1 [43] [62] +19 + - // 2 [47] [63] +16 / - // 3 [48..57] [52..61] +4 0..9 - // 4 [65..90] [0..25] -65 A..Z - // 5 [97..122] [26..51] -71 a..z - // (6) Everything else => invalid input - - // Benchmarking on the Raspberry Pi 2B and Clang shows that looping - // generates slightly faster code than explicit unrolling: - for (int i = 0; i < 4; i++) { - set1.val[i] = CMPEQ(str.val[i], '+'); - set2.val[i] = CMPEQ(str.val[i], '/'); - set3.val[i] = RANGE(str.val[i], '0', '9'); - set4.val[i] = RANGE(str.val[i], 'A', 'Z'); - set5.val[i] = RANGE(str.val[i], 'a', 'z'); - set6.val[i] = CMPEQ(str.val[i], '-'); - set7.val[i] = CMPEQ(str.val[i], '_'); - - delta.val[i] = REPLACE(set1.val[i], 19); - delta.val[i] = vorrq_u8(delta.val[i], REPLACE(set2.val[i], 16)); - delta.val[i] = vorrq_u8(delta.val[i], REPLACE(set3.val[i], 4)); - delta.val[i] = vorrq_u8(delta.val[i], REPLACE(set4.val[i], -65)); - delta.val[i] = vorrq_u8(delta.val[i], REPLACE(set5.val[i], -71)); - delta.val[i] = vorrq_u8(delta.val[i], REPLACE(set6.val[i], 17)); - delta.val[i] = vorrq_u8(delta.val[i], REPLACE(set7.val[i], -32)); - } - - // Check for invalid input: if any of the delta values are zero, - // fall back on bytewise code to do error checking and reporting: - uint8x16_t classified = CMPEQ(delta.val[0], 0); - classified = vorrq_u8(classified, CMPEQ(delta.val[1], 0)); - classified = vorrq_u8(classified, CMPEQ(delta.val[2], 0)); - classified = vorrq_u8(classified, CMPEQ(delta.val[3], 0)); - - // Extract both 32-bit halves; check that all bits are zero: - if (vgetq_lane_u32((uint32x4_t)classified, 0) != 0 - || vgetq_lane_u32((uint32x4_t)classified, 1) != 0 - || vgetq_lane_u32((uint32x4_t)classified, 2) != 0 - || vgetq_lane_u32((uint32x4_t)classified, 3) != 0) { - break; - } - - // Now simply add the delta values to the input: - str.val[0] = vaddq_u8(str.val[0], delta.val[0]); - str.val[1] = vaddq_u8(str.val[1], delta.val[1]); - str.val[2] = vaddq_u8(str.val[2], delta.val[2]); - str.val[3] = vaddq_u8(str.val[3], delta.val[3]); - - // Compress four bytes into three: - dec.val[0] = vshlq_n_u8(str.val[0], 2) | vshrq_n_u8(str.val[1], 4); - dec.val[1] = vshlq_n_u8(str.val[1], 4) | vshrq_n_u8(str.val[2], 2); - dec.val[2] = vshlq_n_u8(str.val[2], 6) | str.val[3]; - - // Interleave and store decoded result: - vst3q_u8((uint8_t *)o, dec); - - c += 64; - o += 48; - outl += 48; - srclen -= 64; -} +// If we have NEON support, pick off 64 bytes at a time for as long as we can. +// Unlike the SSE codecs, we don't write trailing zero bytes to output, so we +// don't need to check if we have enough remaining input to cover them: +while (srclen >= 64) +{ + uint8x16x4_t set1, set2, set3, set4, set5, set6, set7, delta; + uint8x16x3_t dec; + + // Load 64 bytes and deinterleave: + uint8x16x4_t str = vld4q_u8((uint8_t *)c); + + // The input consists of six character sets in the Base64 alphabet, + // which we need to map back to the 6-bit values they represent. + // There are three ranges, two singles, and then there's the rest. + // + // # From To Add Characters + // 1 [43] [62] +19 + + // 2 [47] [63] +16 / + // 3 [48..57] [52..61] +4 0..9 + // 4 [65..90] [0..25] -65 A..Z + // 5 [97..122] [26..51] -71 a..z + // (6) Everything else => invalid input + + // Benchmarking on the Raspberry Pi 2B and Clang shows that looping + // generates slightly faster code than explicit unrolling: + for (int i = 0; i < 4; i++) { + set1.val[i] = CMPEQ(str.val[i], '+'); + set2.val[i] = CMPEQ(str.val[i], '/'); + set3.val[i] = RANGE(str.val[i], '0', '9'); + set4.val[i] = RANGE(str.val[i], 'A', 'Z'); + set5.val[i] = RANGE(str.val[i], 'a', 'z'); + set6.val[i] = CMPEQ(str.val[i], '-'); + set7.val[i] = CMPEQ(str.val[i], '_'); + + delta.val[i] = REPLACE(set1.val[i], 19); + delta.val[i] = vorrq_u8(delta.val[i], REPLACE(set2.val[i], 16)); + delta.val[i] = vorrq_u8(delta.val[i], REPLACE(set3.val[i], 4)); + delta.val[i] = vorrq_u8(delta.val[i], REPLACE(set4.val[i], -65)); + delta.val[i] = vorrq_u8(delta.val[i], REPLACE(set5.val[i], -71)); + delta.val[i] = vorrq_u8(delta.val[i], REPLACE(set6.val[i], 17)); + delta.val[i] = vorrq_u8(delta.val[i], REPLACE(set7.val[i], -32)); + } + + // Check for invalid input: if any of the delta values are zero, + // fall back on bytewise code to do error checking and reporting: + uint8x16_t classified = CMPEQ(delta.val[0], 0); + classified = vorrq_u8(classified, CMPEQ(delta.val[1], 0)); + classified = vorrq_u8(classified, CMPEQ(delta.val[2], 0)); + classified = vorrq_u8(classified, CMPEQ(delta.val[3], 0)); + + // Extract both 32-bit halves; check that all bits are zero: + if (vgetq_lane_u32((uint32x4_t)classified, 0) != 0 + || vgetq_lane_u32((uint32x4_t)classified, 1) != 0 + || vgetq_lane_u32((uint32x4_t)classified, 2) != 0 + || vgetq_lane_u32((uint32x4_t)classified, 3) != 0) { + break; + } + + // Now simply add the delta values to the input: + str.val[0] = vaddq_u8(str.val[0], delta.val[0]); + str.val[1] = vaddq_u8(str.val[1], delta.val[1]); + str.val[2] = vaddq_u8(str.val[2], delta.val[2]); + str.val[3] = vaddq_u8(str.val[3], delta.val[3]); + + // Compress four bytes into three: + dec.val[0] = vshlq_n_u8(str.val[0], 2) | vshrq_n_u8(str.val[1], 4); + dec.val[1] = vshlq_n_u8(str.val[1], 4) | vshrq_n_u8(str.val[2], 2); + dec.val[2] = vshlq_n_u8(str.val[2], 6) | str.val[3]; + + // Interleave and store decoded result: + vst3q_u8((uint8_t *)o, dec); + + c += 64; + o += 48; + outl += 48; + srclen -= 64; +} diff --git a/contrib/libs/base64/neon32/dec_tail.c b/contrib/libs/base64/neon32/dec_tail.c index 4844677e6db..beb453a4670 100644 --- a/contrib/libs/base64/neon32/dec_tail.c +++ b/contrib/libs/base64/neon32/dec_tail.c @@ -1,65 +1,65 @@ - if (srclen-- == 0) { - ret = 1; - break; - } - if ((q = neon32_base64_table_dec[*c++]) >= 254) { - st.eof = 1; - // Treat character '=' as invalid for byte 0: - break; - } - st.carry = q << 2; - st.bytes++; - - case 1: if (srclen-- == 0) { - ret = 1; - break; - } - if ((q = neon32_base64_table_dec[*c++]) >= 254) { - st.eof = 1; - // Treat character '=' as invalid for byte 1: - break; - } - *o++ = st.carry | (q >> 4); - st.carry = q << 4; - st.bytes++; - outl++; - - case 2: if (srclen-- == 0) { - ret = 1; - break; - } - if ((q = neon32_base64_table_dec[*c++]) >= 254) { - st.eof = 1; - // When q == 254, the input char is '='. Return 1 and EOF. - // Technically, should check if next byte is also '=', but never mind. - // When q == 255, the input char is invalid. Return 0 and EOF. - ret = (q == 254) ? 1 : 0; - break; - } - *o++ = st.carry | (q >> 2); - st.carry = q << 6; - st.bytes++; - outl++; - - case 3: if (srclen-- == 0) { - ret = 1; - break; - } - if ((q = neon32_base64_table_dec[*c++]) >= 254) { - st.eof = 1; - // When q == 254, the input char is '='. Return 1 and EOF. - // When q == 255, the input char is invalid. Return 0 and EOF. - ret = (q == 254) ? 1 : 0; - break; - } - *o++ = st.carry | q; - st.carry = 0; - st.bytes = 0; - outl++; - } -} -state->eof = st.eof; -state->bytes = st.bytes; -state->carry = st.carry; -*outlen = outl; -return ret; + if (srclen-- == 0) { + ret = 1; + break; + } + if ((q = neon32_base64_table_dec[*c++]) >= 254) { + st.eof = 1; + // Treat character '=' as invalid for byte 0: + break; + } + st.carry = q << 2; + st.bytes++; + + case 1: if (srclen-- == 0) { + ret = 1; + break; + } + if ((q = neon32_base64_table_dec[*c++]) >= 254) { + st.eof = 1; + // Treat character '=' as invalid for byte 1: + break; + } + *o++ = st.carry | (q >> 4); + st.carry = q << 4; + st.bytes++; + outl++; + + case 2: if (srclen-- == 0) { + ret = 1; + break; + } + if ((q = neon32_base64_table_dec[*c++]) >= 254) { + st.eof = 1; + // When q == 254, the input char is '='. Return 1 and EOF. + // Technically, should check if next byte is also '=', but never mind. + // When q == 255, the input char is invalid. Return 0 and EOF. + ret = (q == 254) ? 1 : 0; + break; + } + *o++ = st.carry | (q >> 2); + st.carry = q << 6; + st.bytes++; + outl++; + + case 3: if (srclen-- == 0) { + ret = 1; + break; + } + if ((q = neon32_base64_table_dec[*c++]) >= 254) { + st.eof = 1; + // When q == 254, the input char is '='. Return 1 and EOF. + // When q == 255, the input char is invalid. Return 0 and EOF. + ret = (q == 254) ? 1 : 0; + break; + } + *o++ = st.carry | q; + st.carry = 0; + st.bytes = 0; + outl++; + } +} +state->eof = st.eof; +state->bytes = st.bytes; +state->carry = st.carry; +*outlen = outl; +return ret; diff --git a/contrib/libs/base64/neon32/dec_uint32.c b/contrib/libs/base64/neon32/dec_uint32.c index 5856446861e..052284c7e67 100644 --- a/contrib/libs/base64/neon32/dec_uint32.c +++ b/contrib/libs/base64/neon32/dec_uint32.c @@ -1,48 +1,48 @@ -// If we have native uint32's, pick off 4 bytes at a time for as long as we -// can, but make sure that we quit before seeing any == markers at the end of -// the string. Also, because we write a zero at the end of the output, ensure -// that there are at least 2 valid bytes of input data remaining to close the -// gap. 4 + 2 + 2 = 8 bytes: -while (srclen >= 8) -{ - uint32_t str, res, dec; - - // Load string: - str = *(uint32_t *)c; - - // Shuffle bytes to 32-bit bigendian: - str = cpu_to_be32(str); - - // Lookup each byte in the decoding table; if we encounter any - // "invalid" values, fall back on the bytewise code: - if ((dec = neon32_base64_table_dec[str >> 24]) > 63) { - break; - } - res = dec << 26; - - if ((dec = neon32_base64_table_dec[(str >> 16) & 0xFF]) > 63) { - break; - } - res |= dec << 20; - - if ((dec = neon32_base64_table_dec[(str >> 8) & 0xFF]) > 63) { - break; - } - res |= dec << 14; - - if ((dec = neon32_base64_table_dec[str & 0xFF]) > 63) { - break; - } - res |= dec << 8; - - // Reshuffle and repack into 3-byte output format: - res = be32_to_cpu(res); - - // Store back: - *(uint32_t *)o = res; - - c += 4; - o += 3; - outl += 3; - srclen -= 4; -} +// If we have native uint32's, pick off 4 bytes at a time for as long as we +// can, but make sure that we quit before seeing any == markers at the end of +// the string. Also, because we write a zero at the end of the output, ensure +// that there are at least 2 valid bytes of input data remaining to close the +// gap. 4 + 2 + 2 = 8 bytes: +while (srclen >= 8) +{ + uint32_t str, res, dec; + + // Load string: + str = *(uint32_t *)c; + + // Shuffle bytes to 32-bit bigendian: + str = cpu_to_be32(str); + + // Lookup each byte in the decoding table; if we encounter any + // "invalid" values, fall back on the bytewise code: + if ((dec = neon32_base64_table_dec[str >> 24]) > 63) { + break; + } + res = dec << 26; + + if ((dec = neon32_base64_table_dec[(str >> 16) & 0xFF]) > 63) { + break; + } + res |= dec << 20; + + if ((dec = neon32_base64_table_dec[(str >> 8) & 0xFF]) > 63) { + break; + } + res |= dec << 14; + + if ((dec = neon32_base64_table_dec[str & 0xFF]) > 63) { + break; + } + res |= dec << 8; + + // Reshuffle and repack into 3-byte output format: + res = be32_to_cpu(res); + + // Store back: + *(uint32_t *)o = res; + + c += 4; + o += 3; + outl += 3; + srclen -= 4; +} diff --git a/contrib/libs/base64/neon32/enc_head.c b/contrib/libs/base64/neon32/enc_head.c index 2b8b88eba34..122ad246b1b 100644 --- a/contrib/libs/base64/neon32/enc_head.c +++ b/contrib/libs/base64/neon32/enc_head.c @@ -1,23 +1,23 @@ -// Assume that *out is large enough to contain the output. -// Theoretically it should be 4/3 the length of src. -const uint8_t *c = (const uint8_t *)src; -uint8_t *o = (uint8_t *)out; - -// Use local temporaries to avoid cache thrashing: -size_t outl = 0; -struct neon32_base64_state st; -st.bytes = state->bytes; -st.carry = state->carry; - -// Turn three bytes into four 6-bit numbers: -// in[0] = 00111111 -// in[1] = 00112222 -// in[2] = 00222233 -// in[3] = 00333333 - -// Duff's device, a for() loop inside a switch() statement. Legal! -switch (st.bytes) -{ - for (;;) - { - case 0: +// Assume that *out is large enough to contain the output. +// Theoretically it should be 4/3 the length of src. +const uint8_t *c = (const uint8_t *)src; +uint8_t *o = (uint8_t *)out; + +// Use local temporaries to avoid cache thrashing: +size_t outl = 0; +struct neon32_base64_state st; +st.bytes = state->bytes; +st.carry = state->carry; + +// Turn three bytes into four 6-bit numbers: +// in[0] = 00111111 +// in[1] = 00112222 +// in[2] = 00222233 +// in[3] = 00333333 + +// Duff's device, a for() loop inside a switch() statement. Legal! +switch (st.bytes) +{ + for (;;) + { + case 0: diff --git a/contrib/libs/base64/neon32/enc_neon.c b/contrib/libs/base64/neon32/enc_neon.c index 05d7eb41b59..effb7f9e079 100644 --- a/contrib/libs/base64/neon32/enc_neon.c +++ b/contrib/libs/base64/neon32/enc_neon.c @@ -1,23 +1,23 @@ -// If we have ARM NEON support, pick off 48 bytes at a time: -while (srclen >= 48) -{ - uint8x16x3_t str; - uint8x16x4_t res; - - // Load 48 bytes and deinterleave: - str = vld3q_u8((uint8_t *)c); - - // Reshuffle: - res = enc_reshuffle(str); - - // Translate reshuffled bytes to the Base64 alphabet: - res = enc_translate(res); - - // Interleave and store result: - vst4q_u8((uint8_t *)o, res); - - c += 48; // 3 * 16 bytes of input - o += 64; // 4 * 16 bytes of output - outl += 64; - srclen -= 48; -} +// If we have ARM NEON support, pick off 48 bytes at a time: +while (srclen >= 48) +{ + uint8x16x3_t str; + uint8x16x4_t res; + + // Load 48 bytes and deinterleave: + str = vld3q_u8((uint8_t *)c); + + // Reshuffle: + res = enc_reshuffle(str); + + // Translate reshuffled bytes to the Base64 alphabet: + res = enc_translate(res); + + // Interleave and store result: + vst4q_u8((uint8_t *)o, res); + + c += 48; // 3 * 16 bytes of input + o += 64; // 4 * 16 bytes of output + outl += 64; + srclen -= 48; +} diff --git a/contrib/libs/base64/neon32/enc_tail.c b/contrib/libs/base64/neon32/enc_tail.c index f19ae5f736c..83a5d897e29 100644 --- a/contrib/libs/base64/neon32/enc_tail.c +++ b/contrib/libs/base64/neon32/enc_tail.c @@ -1,28 +1,28 @@ - if (srclen-- == 0) { - break; - } - *o++ = neon32_base64_table_enc[*c >> 2]; - st.carry = (*c++ << 4) & 0x30; - st.bytes++; - outl += 1; - - case 1: if (srclen-- == 0) { - break; - } - *o++ = neon32_base64_table_enc[st.carry | (*c >> 4)]; - st.carry = (*c++ << 2) & 0x3C; - st.bytes++; - outl += 1; - - case 2: if (srclen-- == 0) { - break; - } - *o++ = neon32_base64_table_enc[st.carry | (*c >> 6)]; - *o++ = neon32_base64_table_enc[*c++ & 0x3F]; - st.bytes = 0; - outl += 2; - } -} -state->bytes = st.bytes; -state->carry = st.carry; -*outlen = outl; + if (srclen-- == 0) { + break; + } + *o++ = neon32_base64_table_enc[*c >> 2]; + st.carry = (*c++ << 4) & 0x30; + st.bytes++; + outl += 1; + + case 1: if (srclen-- == 0) { + break; + } + *o++ = neon32_base64_table_enc[st.carry | (*c >> 4)]; + st.carry = (*c++ << 2) & 0x3C; + st.bytes++; + outl += 1; + + case 2: if (srclen-- == 0) { + break; + } + *o++ = neon32_base64_table_enc[st.carry | (*c >> 6)]; + *o++ = neon32_base64_table_enc[*c++ & 0x3F]; + st.bytes = 0; + outl += 2; + } +} +state->bytes = st.bytes; +state->carry = st.carry; +*outlen = outl; diff --git a/contrib/libs/base64/neon32/enc_uint32.c b/contrib/libs/base64/neon32/enc_uint32.c index c7bc3cd2343..a9f49375bd8 100644 --- a/contrib/libs/base64/neon32/enc_uint32.c +++ b/contrib/libs/base64/neon32/enc_uint32.c @@ -1,24 +1,24 @@ -// If we have 32-bit ints, pick off 3 bytes at a time for as long as we can, -// but ensure that there are at least 4 bytes available to avoid segfaulting: -while (srclen >= 4) -{ - // Load string: - uint32_t str = *(uint32_t *)c; - - // Reorder to 32-bit big-endian, if not already in that format. The - // workset must be in big-endian, otherwise the shifted bits do not - // carry over properly among adjacent bytes: - str = cpu_to_be32(str); - - // Shift input by 6 bytes each round and mask in only the lower 6 bits; - // look up the character in the Base64 encoding table and write it to - // the output location: - *o++ = neon32_base64_table_enc[(str >> 26) & 0x3F]; - *o++ = neon32_base64_table_enc[(str >> 20) & 0x3F]; - *o++ = neon32_base64_table_enc[(str >> 14) & 0x3F]; - *o++ = neon32_base64_table_enc[(str >> 8) & 0x3F]; - - c += 3; // 3 bytes of input - outl += 4; // 4 bytes of output - srclen -= 3; -} +// If we have 32-bit ints, pick off 3 bytes at a time for as long as we can, +// but ensure that there are at least 4 bytes available to avoid segfaulting: +while (srclen >= 4) +{ + // Load string: + uint32_t str = *(uint32_t *)c; + + // Reorder to 32-bit big-endian, if not already in that format. The + // workset must be in big-endian, otherwise the shifted bits do not + // carry over properly among adjacent bytes: + str = cpu_to_be32(str); + + // Shift input by 6 bytes each round and mask in only the lower 6 bits; + // look up the character in the Base64 encoding table and write it to + // the output location: + *o++ = neon32_base64_table_enc[(str >> 26) & 0x3F]; + *o++ = neon32_base64_table_enc[(str >> 20) & 0x3F]; + *o++ = neon32_base64_table_enc[(str >> 14) & 0x3F]; + *o++ = neon32_base64_table_enc[(str >> 8) & 0x3F]; + + c += 3; // 3 bytes of input + outl += 4; // 4 bytes of output + srclen -= 3; +} diff --git a/contrib/libs/base64/neon32/lib.c b/contrib/libs/base64/neon32/lib.c index 52271e925a5..10f92c5032f 100644 --- a/contrib/libs/base64/neon32/lib.c +++ b/contrib/libs/base64/neon32/lib.c @@ -1,121 +1,121 @@ -#include <stdint.h> -#include <stddef.h> - -#include "libbase64.h" -#include "codecs.h" - -const uint8_t -neon32_base64_table_enc[] = - "ABCDEFGHIJKLMNOPQRSTUVWXYZ" - "abcdefghijklmnopqrstuvwxyz" - "0123456789+/"; - -// In the lookup table below, note that the value for '=' (character 61) is -// 254, not 255. This character is used for in-band signaling of the end of -// the datastream, and we will use that later. The characters A-Z, a-z, 0-9 -// and + / are mapped to their "decoded" values. The other bytes all map to -// the value 255, which flags them as "invalid input". - -const uint8_t -neon32_base64_table_dec[] = -{ - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, // 0..15 - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, // 16..31 - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 62, 254, 62, 255, 63, // 32..47 - 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 255, 255, 255, 254, 255, 255, // 48..63 - 255, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, // 64..79 - 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 255, 255, 255, 255, 63, // 80..95 - 255, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, // 96..111 - 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 255, 255, 255, 255, 255, // 112..127 - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, // 128..143 - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, -}; - -void -neon32_base64_stream_encode_init (struct neon32_base64_state *state) -{ - state->eof = 0; - state->bytes = 0; - state->carry = 0; -} - -void -neon32_base64_stream_encode_final - ( struct neon32_base64_state *state - , char *out - , size_t *outlen - ) -{ - uint8_t *o = (uint8_t *)out; - - if (state->bytes == 1) { - *o++ = neon32_base64_table_enc[state->carry]; - *o++ = '='; - *o++ = '='; - *outlen = 3; - return; - } - if (state->bytes == 2) { - *o++ = neon32_base64_table_enc[state->carry]; - *o++ = '='; - *outlen = 2; - return; - } - *outlen = 0; -} - -void -neon32_base64_stream_decode_init (struct neon32_base64_state *state) -{ - state->eof = 0; - state->bytes = 0; - state->carry = 0; -} - -void -neon32_base64_encode - ( const char *src - , size_t srclen - , char *out - , size_t *outlen - ) -{ - size_t s; - size_t t; - struct neon32_base64_state state; - - // Init the stream reader: - neon32_base64_stream_encode_init(&state); - - // Feed the whole string to the stream reader: - neon32_base64_stream_encode(&state, src, srclen, out, &s); - - // Finalize the stream by writing trailer if any: - neon32_base64_stream_encode_final(&state, out + s, &t); - - // Final output length is stream length plus tail: - *outlen = s + t; -} - -int -neon32_base64_decode - ( const char *src - , size_t srclen - , char *out - , size_t *outlen - ) -{ - struct neon32_base64_state state; - - // Init the stream reader: - neon32_base64_stream_decode_init(&state); - - // Feed the whole string to the stream reader: - return neon32_base64_stream_decode(&state, src, srclen, out, outlen); -} +#include <stdint.h> +#include <stddef.h> + +#include "libbase64.h" +#include "codecs.h" + +const uint8_t +neon32_base64_table_enc[] = + "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + "abcdefghijklmnopqrstuvwxyz" + "0123456789+/"; + +// In the lookup table below, note that the value for '=' (character 61) is +// 254, not 255. This character is used for in-band signaling of the end of +// the datastream, and we will use that later. The characters A-Z, a-z, 0-9 +// and + / are mapped to their "decoded" values. The other bytes all map to +// the value 255, which flags them as "invalid input". + +const uint8_t +neon32_base64_table_dec[] = +{ + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, // 0..15 + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, // 16..31 + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 62, 254, 62, 255, 63, // 32..47 + 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 255, 255, 255, 254, 255, 255, // 48..63 + 255, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, // 64..79 + 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 255, 255, 255, 255, 63, // 80..95 + 255, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, // 96..111 + 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 255, 255, 255, 255, 255, // 112..127 + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, // 128..143 + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, +}; + +void +neon32_base64_stream_encode_init (struct neon32_base64_state *state) +{ + state->eof = 0; + state->bytes = 0; + state->carry = 0; +} + +void +neon32_base64_stream_encode_final + ( struct neon32_base64_state *state + , char *out + , size_t *outlen + ) +{ + uint8_t *o = (uint8_t *)out; + + if (state->bytes == 1) { + *o++ = neon32_base64_table_enc[state->carry]; + *o++ = '='; + *o++ = '='; + *outlen = 3; + return; + } + if (state->bytes == 2) { + *o++ = neon32_base64_table_enc[state->carry]; + *o++ = '='; + *outlen = 2; + return; + } + *outlen = 0; +} + +void +neon32_base64_stream_decode_init (struct neon32_base64_state *state) +{ + state->eof = 0; + state->bytes = 0; + state->carry = 0; +} + +void +neon32_base64_encode + ( const char *src + , size_t srclen + , char *out + , size_t *outlen + ) +{ + size_t s; + size_t t; + struct neon32_base64_state state; + + // Init the stream reader: + neon32_base64_stream_encode_init(&state); + + // Feed the whole string to the stream reader: + neon32_base64_stream_encode(&state, src, srclen, out, &s); + + // Finalize the stream by writing trailer if any: + neon32_base64_stream_encode_final(&state, out + s, &t); + + // Final output length is stream length plus tail: + *outlen = s + t; +} + +int +neon32_base64_decode + ( const char *src + , size_t srclen + , char *out + , size_t *outlen + ) +{ + struct neon32_base64_state state; + + // Init the stream reader: + neon32_base64_stream_decode_init(&state); + + // Feed the whole string to the stream reader: + return neon32_base64_stream_decode(&state, src, srclen, out, outlen); +} diff --git a/contrib/libs/base64/neon32/libbase64.h b/contrib/libs/base64/neon32/libbase64.h index fa975550d8a..b78dcc4a7ef 100644 --- a/contrib/libs/base64/neon32/libbase64.h +++ b/contrib/libs/base64/neon32/libbase64.h @@ -1,89 +1,89 @@ -#pragma once - -#ifdef __cplusplus -extern "C" { -#endif - -struct neon32_base64_state { - int eof; - int bytes; - unsigned char carry; -}; - -/* Wrapper function to encode a plain string of given length. Output is written - * to *out without trailing zero. Output length in bytes is written to *outlen. - * The buffer in `out` has been allocated by the caller and is at least 4/3 the - * size of the input. See above for `flags`; set to 0 for default operation: */ -void neon32_base64_encode - ( const char *src - , size_t srclen - , char *out - , size_t *outlen - ) ; - -/* Call this before calling base64_stream_encode() to init the state. See above - * for `flags`; set to 0 for default operation: */ -void neon32_base64_stream_encode_init - ( struct neon32_base64_state *state - ) ; - -/* Encodes the block of data of given length at `src`, into the buffer at - * `out`. Caller is responsible for allocating a large enough out-buffer; it - * must be at least 4/3 the size of the in-buffer, but take some margin. Places - * the number of new bytes written into `outlen` (which is set to zero when the - * function starts). Does not zero-terminate or finalize the output. */ -void neon32_base64_stream_encode - ( struct neon32_base64_state *state - , const char *src - , size_t srclen - , char *out - , size_t *outlen - ) ; - -/* Finalizes the output begun by previous calls to `base64_stream_encode()`. - * Adds the required end-of-stream markers if appropriate. `outlen` is modified - * and will contain the number of new bytes written at `out` (which will quite - * often be zero). */ -void neon32_base64_stream_encode_final - ( struct neon32_base64_state *state - , char *out - , size_t *outlen - ) ; - -/* Wrapper function to decode a plain string of given length. Output is written - * to *out without trailing zero. Output length in bytes is written to *outlen. - * The buffer in `out` has been allocated by the caller and is at least 3/4 the - * size of the input. See above for `flags`, set to 0 for default operation: */ -int neon32_base64_decode - ( const char *src - , size_t srclen - , char *out - , size_t *outlen - ) ; - -/* Call this before calling base64_stream_decode() to init the state. See above - * for `flags`; set to 0 for default operation: */ -void neon32_base64_stream_decode_init - ( struct neon32_base64_state *state - ) ; - -/* Decodes the block of data of given length at `src`, into the buffer at - * `out`. Caller is responsible for allocating a large enough out-buffer; it - * must be at least 3/4 the size of the in-buffer, but take some margin. Places - * the number of new bytes written into `outlen` (which is set to zero when the - * function starts). Does not zero-terminate the output. Returns 1 if all is - * well, and 0 if a decoding error was found, such as an invalid character. - * Returns -1 if the chosen codec is not included in the current build. Used by - * the test harness to check whether a codec is available for testing. */ -int neon32_base64_stream_decode - ( struct neon32_base64_state *state - , const char *src - , size_t srclen - , char *out - , size_t *outlen - ) ; - -#ifdef __cplusplus -} -#endif - +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +struct neon32_base64_state { + int eof; + int bytes; + unsigned char carry; +}; + +/* Wrapper function to encode a plain string of given length. Output is written + * to *out without trailing zero. Output length in bytes is written to *outlen. + * The buffer in `out` has been allocated by the caller and is at least 4/3 the + * size of the input. See above for `flags`; set to 0 for default operation: */ +void neon32_base64_encode + ( const char *src + , size_t srclen + , char *out + , size_t *outlen + ) ; + +/* Call this before calling base64_stream_encode() to init the state. See above + * for `flags`; set to 0 for default operation: */ +void neon32_base64_stream_encode_init + ( struct neon32_base64_state *state + ) ; + +/* Encodes the block of data of given length at `src`, into the buffer at + * `out`. Caller is responsible for allocating a large enough out-buffer; it + * must be at least 4/3 the size of the in-buffer, but take some margin. Places + * the number of new bytes written into `outlen` (which is set to zero when the + * function starts). Does not zero-terminate or finalize the output. */ +void neon32_base64_stream_encode + ( struct neon32_base64_state *state + , const char *src + , size_t srclen + , char *out + , size_t *outlen + ) ; + +/* Finalizes the output begun by previous calls to `base64_stream_encode()`. + * Adds the required end-of-stream markers if appropriate. `outlen` is modified + * and will contain the number of new bytes written at `out` (which will quite + * often be zero). */ +void neon32_base64_stream_encode_final + ( struct neon32_base64_state *state + , char *out + , size_t *outlen + ) ; + +/* Wrapper function to decode a plain string of given length. Output is written + * to *out without trailing zero. Output length in bytes is written to *outlen. + * The buffer in `out` has been allocated by the caller and is at least 3/4 the + * size of the input. See above for `flags`, set to 0 for default operation: */ +int neon32_base64_decode + ( const char *src + , size_t srclen + , char *out + , size_t *outlen + ) ; + +/* Call this before calling base64_stream_decode() to init the state. See above + * for `flags`; set to 0 for default operation: */ +void neon32_base64_stream_decode_init + ( struct neon32_base64_state *state + ) ; + +/* Decodes the block of data of given length at `src`, into the buffer at + * `out`. Caller is responsible for allocating a large enough out-buffer; it + * must be at least 3/4 the size of the in-buffer, but take some margin. Places + * the number of new bytes written into `outlen` (which is set to zero when the + * function starts). Does not zero-terminate the output. Returns 1 if all is + * well, and 0 if a decoding error was found, such as an invalid character. + * Returns -1 if the chosen codec is not included in the current build. Used by + * the test harness to check whether a codec is available for testing. */ +int neon32_base64_stream_decode + ( struct neon32_base64_state *state + , const char *src + , size_t srclen + , char *out + , size_t *outlen + ) ; + +#ifdef __cplusplus +} +#endif + diff --git a/contrib/libs/base64/neon32/ya.make b/contrib/libs/base64/neon32/ya.make index 435b1127bb3..d17e5a0e70f 100644 --- a/contrib/libs/base64/neon32/ya.make +++ b/contrib/libs/base64/neon32/ya.make @@ -1,11 +1,11 @@ -OWNER( - yazevnul +OWNER( + yazevnul g:contrib g:cpp-contrib -) - -LIBRARY() - +) + +LIBRARY() + LICENSE( BSD-2-Clause AND MIT @@ -13,15 +13,15 @@ LICENSE( LICENSE_TEXTS(.yandex_meta/licenses.list.txt) -NO_UTIL() - -SRCS( - codec_neon32.c - lib.c -) - +NO_UTIL() + +SRCS( + codec_neon32.c + lib.c +) + IF (OS_LINUX OR OS_DARWIN OR OS_ANDROID) CONLYFLAGS(-std=c11) -ENDIF() - -END() +ENDIF() + +END() diff --git a/contrib/libs/base64/neon64/codec_neon64.c b/contrib/libs/base64/neon64/codec_neon64.c index 7a352c3adf9..0a954a6712d 100644 --- a/contrib/libs/base64/neon64/codec_neon64.c +++ b/contrib/libs/base64/neon64/codec_neon64.c @@ -1,98 +1,98 @@ -#if (defined(__ARM_NEON) && !defined(__ARM_NEON__)) -#define __ARM_NEON__ -#endif - -#include <stdint.h> -#include <stddef.h> -#include <stdlib.h> -#ifdef __ARM_NEON__ -#include <arm_neon.h> -#endif - -#include "libbase64.h" -#include "codecs.h" - -#if (defined(__aarch64__) && defined(__ARM_NEON__)) - -#define CMPGT(s,n) vcgtq_u8((s), vdupq_n_u8(n)) -#define CMPEQ(s,n) vceqq_u8((s), vdupq_n_u8(n)) -#define REPLACE(s,n) vandq_u8((s), vdupq_n_u8(n)) -#define RANGE(s,a,b) vandq_u8(vcgeq_u8((s), vdupq_n_u8(a)), vcleq_u8((s), vdupq_n_u8(b))) - -// With this transposed encoding table, we can use -// a 64-byte lookup to do the encoding. -// Read the table top to bottom, left to right. -static const char *neon64_base64_table_enc_transposed = -{ - "AQgw" - "BRhx" - "CSiy" - "DTjz" - "EUk0" - "FVl1" - "GWm2" - "HXn3" - "IYo4" - "JZp5" - "Kaq6" - "Lbr7" - "Mcs8" - "Ndt9" - "Oeu+" - "Pfv/" -}; -#endif - -// Stride size is so large on these NEON 64-bit functions -// (48 bytes encode, 64 bytes decode) that we inline the -// uint64 codec to stay performant on smaller inputs. - -void -neon64_base64_stream_encode - ( struct neon64_base64_state *state - , const char *src - , size_t srclen - , char *out - , size_t *outlen - ) -{ -#if (defined(__aarch64__) && defined(__ARM_NEON__)) - uint8x16x4_t tbl_enc = vld4q_u8((uint8_t const*)neon64_base64_table_enc_transposed); - - #include "enc_head.c" - #include "enc_neon.c" - #include "enc_uint64.c" - #include "enc_tail.c" -#else - (void)state; - (void)src; - (void)srclen; - (void)out; - (void)outlen; - abort(); -#endif -} - -int -neon64_base64_stream_decode - ( struct neon64_base64_state *state - , const char *src - , size_t srclen - , char *out - , size_t *outlen - ) -{ -#if (defined(__aarch64__) && defined(__ARM_NEON__)) - #include "dec_head.c" - #include "dec_neon.c" - #include "dec_uint64.c" - #include "dec_tail.c" -#else - (void)state; - (void)src; - (void)srclen; - (void)out; - (void)outlen; - abort(); -#endif -} +#if (defined(__ARM_NEON) && !defined(__ARM_NEON__)) +#define __ARM_NEON__ +#endif + +#include <stdint.h> +#include <stddef.h> +#include <stdlib.h> +#ifdef __ARM_NEON__ +#include <arm_neon.h> +#endif + +#include "libbase64.h" +#include "codecs.h" + +#if (defined(__aarch64__) && defined(__ARM_NEON__)) + +#define CMPGT(s,n) vcgtq_u8((s), vdupq_n_u8(n)) +#define CMPEQ(s,n) vceqq_u8((s), vdupq_n_u8(n)) +#define REPLACE(s,n) vandq_u8((s), vdupq_n_u8(n)) +#define RANGE(s,a,b) vandq_u8(vcgeq_u8((s), vdupq_n_u8(a)), vcleq_u8((s), vdupq_n_u8(b))) + +// With this transposed encoding table, we can use +// a 64-byte lookup to do the encoding. +// Read the table top to bottom, left to right. +static const char *neon64_base64_table_enc_transposed = +{ + "AQgw" + "BRhx" + "CSiy" + "DTjz" + "EUk0" + "FVl1" + "GWm2" + "HXn3" + "IYo4" + "JZp5" + "Kaq6" + "Lbr7" + "Mcs8" + "Ndt9" + "Oeu+" + "Pfv/" +}; +#endif + +// Stride size is so large on these NEON 64-bit functions +// (48 bytes encode, 64 bytes decode) that we inline the +// uint64 codec to stay performant on smaller inputs. + +void +neon64_base64_stream_encode + ( struct neon64_base64_state *state + , const char *src + , size_t srclen + , char *out + , size_t *outlen + ) +{ +#if (defined(__aarch64__) && defined(__ARM_NEON__)) + uint8x16x4_t tbl_enc = vld4q_u8((uint8_t const*)neon64_base64_table_enc_transposed); + + #include "enc_head.c" + #include "enc_neon.c" + #include "enc_uint64.c" + #include "enc_tail.c" +#else + (void)state; + (void)src; + (void)srclen; + (void)out; + (void)outlen; + abort(); +#endif +} + +int +neon64_base64_stream_decode + ( struct neon64_base64_state *state + , const char *src + , size_t srclen + , char *out + , size_t *outlen + ) +{ +#if (defined(__aarch64__) && defined(__ARM_NEON__)) + #include "dec_head.c" + #include "dec_neon.c" + #include "dec_uint64.c" + #include "dec_tail.c" +#else + (void)state; + (void)src; + (void)srclen; + (void)out; + (void)outlen; + abort(); +#endif +} diff --git a/contrib/libs/base64/neon64/codecs.h b/contrib/libs/base64/neon64/codecs.h index d97269a4a5f..0b8138c5bb1 100644 --- a/contrib/libs/base64/neon64/codecs.h +++ b/contrib/libs/base64/neon64/codecs.h @@ -1,35 +1,35 @@ -#pragma once - -// Define machine endianness. This is for GCC: -#if (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__) - #define BASE64_NEON64_LITTLE_ENDIAN 1 -#else - #define BASE64_NEON64_LITTLE_ENDIAN 0 -#endif - -// This is for Clang: -#ifdef __LITTLE_ENDIAN__ - #define BASE64_NEON64_LITTLE_ENDIAN 1 -#endif - -#ifdef __BIG_ENDIAN__ - #define BASE64_NEON64_LITTLE_ENDIAN 0 -#endif - -// Endian conversion functions -#if BASE64_NEON64_LITTLE_ENDIAN - #define cpu_to_be32(x) __builtin_bswap32(x) - #define cpu_to_be64(x) __builtin_bswap64(x) - #define be32_to_cpu(x) __builtin_bswap32(x) - #define be64_to_cpu(x) __builtin_bswap64(x) -#else - #define cpu_to_be32(x) (x) - #define cpu_to_be64(x) (x) - #define be32_to_cpu(x) (x) - #define be64_to_cpu(x) (x) -#endif - -// These tables are used by all codecs -// for fallback plain encoding/decoding: -extern const uint8_t neon64_base64_table_enc[]; -extern const uint8_t neon64_base64_table_dec[]; +#pragma once + +// Define machine endianness. This is for GCC: +#if (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__) + #define BASE64_NEON64_LITTLE_ENDIAN 1 +#else + #define BASE64_NEON64_LITTLE_ENDIAN 0 +#endif + +// This is for Clang: +#ifdef __LITTLE_ENDIAN__ + #define BASE64_NEON64_LITTLE_ENDIAN 1 +#endif + +#ifdef __BIG_ENDIAN__ + #define BASE64_NEON64_LITTLE_ENDIAN 0 +#endif + +// Endian conversion functions +#if BASE64_NEON64_LITTLE_ENDIAN + #define cpu_to_be32(x) __builtin_bswap32(x) + #define cpu_to_be64(x) __builtin_bswap64(x) + #define be32_to_cpu(x) __builtin_bswap32(x) + #define be64_to_cpu(x) __builtin_bswap64(x) +#else + #define cpu_to_be32(x) (x) + #define cpu_to_be64(x) (x) + #define be32_to_cpu(x) (x) + #define be64_to_cpu(x) (x) +#endif + +// These tables are used by all codecs +// for fallback plain encoding/decoding: +extern const uint8_t neon64_base64_table_enc[]; +extern const uint8_t neon64_base64_table_dec[]; diff --git a/contrib/libs/base64/neon64/dec_head.c b/contrib/libs/base64/neon64/dec_head.c index 10f0def5be7..89decb1be78 100644 --- a/contrib/libs/base64/neon64/dec_head.c +++ b/contrib/libs/base64/neon64/dec_head.c @@ -1,29 +1,29 @@ -int ret = 0; -const uint8_t *c = (const uint8_t *)src; -uint8_t *o = (uint8_t *)out; -uint8_t q; - -// Use local temporaries to avoid cache thrashing: -size_t outl = 0; -struct neon64_base64_state st; -st.eof = state->eof; -st.bytes = state->bytes; -st.carry = state->carry; - -// If we previously saw an EOF or an invalid character, bail out: -if (st.eof) { - *outlen = 0; - return 0; -} - -// Turn four 6-bit numbers into three bytes: -// out[0] = 11111122 -// out[1] = 22223333 -// out[2] = 33444444 - -// Duff's device again: -switch (st.bytes) -{ - for (;;) - { - case 0: +int ret = 0; +const uint8_t *c = (const uint8_t *)src; +uint8_t *o = (uint8_t *)out; +uint8_t q; + +// Use local temporaries to avoid cache thrashing: +size_t outl = 0; +struct neon64_base64_state st; +st.eof = state->eof; +st.bytes = state->bytes; +st.carry = state->carry; + +// If we previously saw an EOF or an invalid character, bail out: +if (st.eof) { + *outlen = 0; + return 0; +} + +// Turn four 6-bit numbers into three bytes: +// out[0] = 11111122 +// out[1] = 22223333 +// out[2] = 33444444 + +// Duff's device again: +switch (st.bytes) +{ + for (;;) + { + case 0: diff --git a/contrib/libs/base64/neon64/dec_neon.c b/contrib/libs/base64/neon64/dec_neon.c index 713d8ca9a43..30d846a9167 100644 --- a/contrib/libs/base64/neon64/dec_neon.c +++ b/contrib/libs/base64/neon64/dec_neon.c @@ -1,77 +1,77 @@ -// If we have NEON support, pick off 64 bytes at a time for as long as we can. -// Unlike the SSE codecs, we don't write trailing zero bytes to output, so we -// don't need to check if we have enough remaining input to cover them: -while (srclen >= 64) -{ - uint8x16x4_t set1, set2, set3, set4, set5, set6, set7, delta; - uint8x16x3_t dec; - - // Load 64 bytes and deinterleave: - uint8x16x4_t str = vld4q_u8((uint8_t *)c); - - // The input consists of six character sets in the Base64 alphabet, - // which we need to map back to the 6-bit values they represent. - // There are three ranges, two singles, and then there's the rest. - // - // # From To Add Characters - // 1 [43] [62] +19 + - // 2 [47] [63] +16 / - // 3 [48..57] [52..61] +4 0..9 - // 4 [65..90] [0..25] -65 A..Z - // 5 [97..122] [26..51] -71 a..z - // (6) Everything else => invalid input - - // Benchmarking on the Raspberry Pi 2B and Clang shows that looping - // generates slightly faster code than explicit unrolling: - for (int i = 0; i < 4; i++) { - set1.val[i] = CMPEQ(str.val[i], '+'); - set2.val[i] = CMPEQ(str.val[i], '/'); - set3.val[i] = RANGE(str.val[i], '0', '9'); - set4.val[i] = RANGE(str.val[i], 'A', 'Z'); - set5.val[i] = RANGE(str.val[i], 'a', 'z'); - set6.val[i] = CMPEQ(str.val[i], '-'); - set7.val[i] = CMPEQ(str.val[i], '_'); - - delta.val[i] = REPLACE(set1.val[i], 19); - delta.val[i] = vorrq_u8(delta.val[i], REPLACE(set2.val[i], 16)); - delta.val[i] = vorrq_u8(delta.val[i], REPLACE(set3.val[i], 4)); - delta.val[i] = vorrq_u8(delta.val[i], REPLACE(set4.val[i], -65)); - delta.val[i] = vorrq_u8(delta.val[i], REPLACE(set5.val[i], -71)); - delta.val[i] = vorrq_u8(delta.val[i], REPLACE(set6.val[i], 17)); - delta.val[i] = vorrq_u8(delta.val[i], REPLACE(set7.val[i], -32)); - } - - // Check for invalid input: if any of the delta values are zero, - // fall back on bytewise code to do error checking and reporting: - uint8x16_t classified = CMPEQ(delta.val[0], 0); - classified = vorrq_u8(classified, CMPEQ(delta.val[1], 0)); - classified = vorrq_u8(classified, CMPEQ(delta.val[2], 0)); - classified = vorrq_u8(classified, CMPEQ(delta.val[3], 0)); - - // Extract both 32-bit halves; check that all bits are zero: - if (vgetq_lane_u32((uint32x4_t)classified, 0) != 0 - || vgetq_lane_u32((uint32x4_t)classified, 1) != 0 - || vgetq_lane_u32((uint32x4_t)classified, 2) != 0 - || vgetq_lane_u32((uint32x4_t)classified, 3) != 0) { - break; - } - - // Now simply add the delta values to the input: - str.val[0] = vaddq_u8(str.val[0], delta.val[0]); - str.val[1] = vaddq_u8(str.val[1], delta.val[1]); - str.val[2] = vaddq_u8(str.val[2], delta.val[2]); - str.val[3] = vaddq_u8(str.val[3], delta.val[3]); - - // Compress four bytes into three: - dec.val[0] = vshlq_n_u8(str.val[0], 2) | vshrq_n_u8(str.val[1], 4); - dec.val[1] = vshlq_n_u8(str.val[1], 4) | vshrq_n_u8(str.val[2], 2); - dec.val[2] = vshlq_n_u8(str.val[2], 6) | str.val[3]; - - // Interleave and store decoded result: - vst3q_u8((uint8_t *)o, dec); - - c += 64; - o += 48; - outl += 48; - srclen -= 64; -} +// If we have NEON support, pick off 64 bytes at a time for as long as we can. +// Unlike the SSE codecs, we don't write trailing zero bytes to output, so we +// don't need to check if we have enough remaining input to cover them: +while (srclen >= 64) +{ + uint8x16x4_t set1, set2, set3, set4, set5, set6, set7, delta; + uint8x16x3_t dec; + + // Load 64 bytes and deinterleave: + uint8x16x4_t str = vld4q_u8((uint8_t *)c); + + // The input consists of six character sets in the Base64 alphabet, + // which we need to map back to the 6-bit values they represent. + // There are three ranges, two singles, and then there's the rest. + // + // # From To Add Characters + // 1 [43] [62] +19 + + // 2 [47] [63] +16 / + // 3 [48..57] [52..61] +4 0..9 + // 4 [65..90] [0..25] -65 A..Z + // 5 [97..122] [26..51] -71 a..z + // (6) Everything else => invalid input + + // Benchmarking on the Raspberry Pi 2B and Clang shows that looping + // generates slightly faster code than explicit unrolling: + for (int i = 0; i < 4; i++) { + set1.val[i] = CMPEQ(str.val[i], '+'); + set2.val[i] = CMPEQ(str.val[i], '/'); + set3.val[i] = RANGE(str.val[i], '0', '9'); + set4.val[i] = RANGE(str.val[i], 'A', 'Z'); + set5.val[i] = RANGE(str.val[i], 'a', 'z'); + set6.val[i] = CMPEQ(str.val[i], '-'); + set7.val[i] = CMPEQ(str.val[i], '_'); + + delta.val[i] = REPLACE(set1.val[i], 19); + delta.val[i] = vorrq_u8(delta.val[i], REPLACE(set2.val[i], 16)); + delta.val[i] = vorrq_u8(delta.val[i], REPLACE(set3.val[i], 4)); + delta.val[i] = vorrq_u8(delta.val[i], REPLACE(set4.val[i], -65)); + delta.val[i] = vorrq_u8(delta.val[i], REPLACE(set5.val[i], -71)); + delta.val[i] = vorrq_u8(delta.val[i], REPLACE(set6.val[i], 17)); + delta.val[i] = vorrq_u8(delta.val[i], REPLACE(set7.val[i], -32)); + } + + // Check for invalid input: if any of the delta values are zero, + // fall back on bytewise code to do error checking and reporting: + uint8x16_t classified = CMPEQ(delta.val[0], 0); + classified = vorrq_u8(classified, CMPEQ(delta.val[1], 0)); + classified = vorrq_u8(classified, CMPEQ(delta.val[2], 0)); + classified = vorrq_u8(classified, CMPEQ(delta.val[3], 0)); + + // Extract both 32-bit halves; check that all bits are zero: + if (vgetq_lane_u32((uint32x4_t)classified, 0) != 0 + || vgetq_lane_u32((uint32x4_t)classified, 1) != 0 + || vgetq_lane_u32((uint32x4_t)classified, 2) != 0 + || vgetq_lane_u32((uint32x4_t)classified, 3) != 0) { + break; + } + + // Now simply add the delta values to the input: + str.val[0] = vaddq_u8(str.val[0], delta.val[0]); + str.val[1] = vaddq_u8(str.val[1], delta.val[1]); + str.val[2] = vaddq_u8(str.val[2], delta.val[2]); + str.val[3] = vaddq_u8(str.val[3], delta.val[3]); + + // Compress four bytes into three: + dec.val[0] = vshlq_n_u8(str.val[0], 2) | vshrq_n_u8(str.val[1], 4); + dec.val[1] = vshlq_n_u8(str.val[1], 4) | vshrq_n_u8(str.val[2], 2); + dec.val[2] = vshlq_n_u8(str.val[2], 6) | str.val[3]; + + // Interleave and store decoded result: + vst3q_u8((uint8_t *)o, dec); + + c += 64; + o += 48; + outl += 48; + srclen -= 64; +} diff --git a/contrib/libs/base64/neon64/dec_tail.c b/contrib/libs/base64/neon64/dec_tail.c index 90a3eec2d33..b530aa62cc2 100644 --- a/contrib/libs/base64/neon64/dec_tail.c +++ b/contrib/libs/base64/neon64/dec_tail.c @@ -1,65 +1,65 @@ - if (srclen-- == 0) { - ret = 1; - break; - } - if ((q = neon64_base64_table_dec[*c++]) >= 254) { - st.eof = 1; - // Treat character '=' as invalid for byte 0: - break; - } - st.carry = q << 2; - st.bytes++; - - case 1: if (srclen-- == 0) { - ret = 1; - break; - } - if ((q = neon64_base64_table_dec[*c++]) >= 254) { - st.eof = 1; - // Treat character '=' as invalid for byte 1: - break; - } - *o++ = st.carry | (q >> 4); - st.carry = q << 4; - st.bytes++; - outl++; - - case 2: if (srclen-- == 0) { - ret = 1; - break; - } - if ((q = neon64_base64_table_dec[*c++]) >= 254) { - st.eof = 1; - // When q == 254, the input char is '='. Return 1 and EOF. - // Technically, should check if next byte is also '=', but never mind. - // When q == 255, the input char is invalid. Return 0 and EOF. - ret = (q == 254) ? 1 : 0; - break; - } - *o++ = st.carry | (q >> 2); - st.carry = q << 6; - st.bytes++; - outl++; - - case 3: if (srclen-- == 0) { - ret = 1; - break; - } - if ((q = neon64_base64_table_dec[*c++]) >= 254) { - st.eof = 1; - // When q == 254, the input char is '='. Return 1 and EOF. - // When q == 255, the input char is invalid. Return 0 and EOF. - ret = (q == 254) ? 1 : 0; - break; - } - *o++ = st.carry | q; - st.carry = 0; - st.bytes = 0; - outl++; - } -} -state->eof = st.eof; -state->bytes = st.bytes; -state->carry = st.carry; -*outlen = outl; -return ret; + if (srclen-- == 0) { + ret = 1; + break; + } + if ((q = neon64_base64_table_dec[*c++]) >= 254) { + st.eof = 1; + // Treat character '=' as invalid for byte 0: + break; + } + st.carry = q << 2; + st.bytes++; + + case 1: if (srclen-- == 0) { + ret = 1; + break; + } + if ((q = neon64_base64_table_dec[*c++]) >= 254) { + st.eof = 1; + // Treat character '=' as invalid for byte 1: + break; + } + *o++ = st.carry | (q >> 4); + st.carry = q << 4; + st.bytes++; + outl++; + + case 2: if (srclen-- == 0) { + ret = 1; + break; + } + if ((q = neon64_base64_table_dec[*c++]) >= 254) { + st.eof = 1; + // When q == 254, the input char is '='. Return 1 and EOF. + // Technically, should check if next byte is also '=', but never mind. + // When q == 255, the input char is invalid. Return 0 and EOF. + ret = (q == 254) ? 1 : 0; + break; + } + *o++ = st.carry | (q >> 2); + st.carry = q << 6; + st.bytes++; + outl++; + + case 3: if (srclen-- == 0) { + ret = 1; + break; + } + if ((q = neon64_base64_table_dec[*c++]) >= 254) { + st.eof = 1; + // When q == 254, the input char is '='. Return 1 and EOF. + // When q == 255, the input char is invalid. Return 0 and EOF. + ret = (q == 254) ? 1 : 0; + break; + } + *o++ = st.carry | q; + st.carry = 0; + st.bytes = 0; + outl++; + } +} +state->eof = st.eof; +state->bytes = st.bytes; +state->carry = st.carry; +*outlen = outl; +return ret; diff --git a/contrib/libs/base64/neon64/dec_uint64.c b/contrib/libs/base64/neon64/dec_uint64.c index 0ea70a34243..90d134af389 100644 --- a/contrib/libs/base64/neon64/dec_uint64.c +++ b/contrib/libs/base64/neon64/dec_uint64.c @@ -1,68 +1,68 @@ -// If we have native uint64's, pick off 8 bytes at a time for as long as we -// can, but make sure that we quit before seeing any == markers at the end of -// the string. Also, because we write two zeroes at the end of the output, -// ensure that there are at least 3 valid bytes of input data remaining to -// close the gap. 8 + 2 + 3 = 13 bytes: -while (srclen >= 13) -{ - uint64_t str, res, dec; - - // Load string: - str = *(uint64_t *)c; - - // Shuffle bytes to 64-bit bigendian: - str = cpu_to_be64(str); - - // Lookup each byte in the decoding table; if we encounter any - // "invalid" values, fall back on the bytewise code: - if ((dec = neon64_base64_table_dec[str >> 56]) > 63) { - break; - } - res = dec << 58; - - if ((dec = neon64_base64_table_dec[(str >> 48) & 0xFF]) > 63) { - break; - } - res |= dec << 52; - - if ((dec = neon64_base64_table_dec[(str >> 40) & 0xFF]) > 63) { - break; - } - res |= dec << 46; - - if ((dec = neon64_base64_table_dec[(str >> 32) & 0xFF]) > 63) { - break; - } - res |= dec << 40; - - if ((dec = neon64_base64_table_dec[(str >> 24) & 0xFF]) > 63) { - break; - } - res |= dec << 34; - - if ((dec = neon64_base64_table_dec[(str >> 16) & 0xFF]) > 63) { - break; - } - res |= dec << 28; - - if ((dec = neon64_base64_table_dec[(str >> 8) & 0xFF]) > 63) { - break; - } - res |= dec << 22; - - if ((dec = neon64_base64_table_dec[str & 0xFF]) > 63) { - break; - } - res |= dec << 16; - - // Reshuffle and repack into 6-byte output format: - res = be64_to_cpu(res); - - // Store back: - *(uint64_t *)o = res; - - c += 8; - o += 6; - outl += 6; - srclen -= 8; -} +// If we have native uint64's, pick off 8 bytes at a time for as long as we +// can, but make sure that we quit before seeing any == markers at the end of +// the string. Also, because we write two zeroes at the end of the output, +// ensure that there are at least 3 valid bytes of input data remaining to +// close the gap. 8 + 2 + 3 = 13 bytes: +while (srclen >= 13) +{ + uint64_t str, res, dec; + + // Load string: + str = *(uint64_t *)c; + + // Shuffle bytes to 64-bit bigendian: + str = cpu_to_be64(str); + + // Lookup each byte in the decoding table; if we encounter any + // "invalid" values, fall back on the bytewise code: + if ((dec = neon64_base64_table_dec[str >> 56]) > 63) { + break; + } + res = dec << 58; + + if ((dec = neon64_base64_table_dec[(str >> 48) & 0xFF]) > 63) { + break; + } + res |= dec << 52; + + if ((dec = neon64_base64_table_dec[(str >> 40) & 0xFF]) > 63) { + break; + } + res |= dec << 46; + + if ((dec = neon64_base64_table_dec[(str >> 32) & 0xFF]) > 63) { + break; + } + res |= dec << 40; + + if ((dec = neon64_base64_table_dec[(str >> 24) & 0xFF]) > 63) { + break; + } + res |= dec << 34; + + if ((dec = neon64_base64_table_dec[(str >> 16) & 0xFF]) > 63) { + break; + } + res |= dec << 28; + + if ((dec = neon64_base64_table_dec[(str >> 8) & 0xFF]) > 63) { + break; + } + res |= dec << 22; + + if ((dec = neon64_base64_table_dec[str & 0xFF]) > 63) { + break; + } + res |= dec << 16; + + // Reshuffle and repack into 6-byte output format: + res = be64_to_cpu(res); + + // Store back: + *(uint64_t *)o = res; + + c += 8; + o += 6; + outl += 6; + srclen -= 8; +} diff --git a/contrib/libs/base64/neon64/enc_head.c b/contrib/libs/base64/neon64/enc_head.c index 92d5ed50b4e..9f8147d6085 100644 --- a/contrib/libs/base64/neon64/enc_head.c +++ b/contrib/libs/base64/neon64/enc_head.c @@ -1,23 +1,23 @@ -// Assume that *out is large enough to contain the output. -// Theoretically it should be 4/3 the length of src. -const uint8_t *c = (const uint8_t *)src; -uint8_t *o = (uint8_t *)out; - -// Use local temporaries to avoid cache thrashing: -size_t outl = 0; -struct neon64_base64_state st; -st.bytes = state->bytes; -st.carry = state->carry; - -// Turn three bytes into four 6-bit numbers: -// in[0] = 00111111 -// in[1] = 00112222 -// in[2] = 00222233 -// in[3] = 00333333 - -// Duff's device, a for() loop inside a switch() statement. Legal! -switch (st.bytes) -{ - for (;;) - { - case 0: +// Assume that *out is large enough to contain the output. +// Theoretically it should be 4/3 the length of src. +const uint8_t *c = (const uint8_t *)src; +uint8_t *o = (uint8_t *)out; + +// Use local temporaries to avoid cache thrashing: +size_t outl = 0; +struct neon64_base64_state st; +st.bytes = state->bytes; +st.carry = state->carry; + +// Turn three bytes into four 6-bit numbers: +// in[0] = 00111111 +// in[1] = 00112222 +// in[2] = 00222233 +// in[3] = 00333333 + +// Duff's device, a for() loop inside a switch() statement. Legal! +switch (st.bytes) +{ + for (;;) + { + case 0: diff --git a/contrib/libs/base64/neon64/enc_neon.c b/contrib/libs/base64/neon64/enc_neon.c index 9cf28a11f8c..2ba5a561e9d 100644 --- a/contrib/libs/base64/neon64/enc_neon.c +++ b/contrib/libs/base64/neon64/enc_neon.c @@ -1,37 +1,37 @@ -// If we have ARM NEON support, pick off 48 bytes at a time: -while (srclen >= 48) -{ - uint8x16x3_t str; - uint8x16x4_t res; - - // Load 48 bytes and deinterleave: - str = vld3q_u8((uint8_t *)c); - - // Divide bits of three input bytes over four output bytes: - res.val[0] = vshrq_n_u8(str.val[0], 2); - res.val[1] = vshrq_n_u8(str.val[1], 4) | vshlq_n_u8(str.val[0], 4); - res.val[2] = vshrq_n_u8(str.val[2], 6) | vshlq_n_u8(str.val[1], 2); - res.val[3] = str.val[2]; - - // Clear top two bits: - res.val[0] &= vdupq_n_u8(0x3F); - res.val[1] &= vdupq_n_u8(0x3F); - res.val[2] &= vdupq_n_u8(0x3F); - res.val[3] &= vdupq_n_u8(0x3F); - - // The bits have now been shifted to the right locations; - // translate their values 0..63 to the Base64 alphabet. - // Use a 64-byte table lookup: - res.val[0] = vqtbl4q_u8(tbl_enc, res.val[0]); - res.val[1] = vqtbl4q_u8(tbl_enc, res.val[1]); - res.val[2] = vqtbl4q_u8(tbl_enc, res.val[2]); - res.val[3] = vqtbl4q_u8(tbl_enc, res.val[3]); - - // Interleave and store result: - vst4q_u8((uint8_t *)o, res); - - c += 48; // 3 * 16 bytes of input - o += 64; // 4 * 16 bytes of output - outl += 64; - srclen -= 48; -} +// If we have ARM NEON support, pick off 48 bytes at a time: +while (srclen >= 48) +{ + uint8x16x3_t str; + uint8x16x4_t res; + + // Load 48 bytes and deinterleave: + str = vld3q_u8((uint8_t *)c); + + // Divide bits of three input bytes over four output bytes: + res.val[0] = vshrq_n_u8(str.val[0], 2); + res.val[1] = vshrq_n_u8(str.val[1], 4) | vshlq_n_u8(str.val[0], 4); + res.val[2] = vshrq_n_u8(str.val[2], 6) | vshlq_n_u8(str.val[1], 2); + res.val[3] = str.val[2]; + + // Clear top two bits: + res.val[0] &= vdupq_n_u8(0x3F); + res.val[1] &= vdupq_n_u8(0x3F); + res.val[2] &= vdupq_n_u8(0x3F); + res.val[3] &= vdupq_n_u8(0x3F); + + // The bits have now been shifted to the right locations; + // translate their values 0..63 to the Base64 alphabet. + // Use a 64-byte table lookup: + res.val[0] = vqtbl4q_u8(tbl_enc, res.val[0]); + res.val[1] = vqtbl4q_u8(tbl_enc, res.val[1]); + res.val[2] = vqtbl4q_u8(tbl_enc, res.val[2]); + res.val[3] = vqtbl4q_u8(tbl_enc, res.val[3]); + + // Interleave and store result: + vst4q_u8((uint8_t *)o, res); + + c += 48; // 3 * 16 bytes of input + o += 64; // 4 * 16 bytes of output + outl += 64; + srclen -= 48; +} diff --git a/contrib/libs/base64/neon64/enc_tail.c b/contrib/libs/base64/neon64/enc_tail.c index 3c971419025..86b49fa6af5 100644 --- a/contrib/libs/base64/neon64/enc_tail.c +++ b/contrib/libs/base64/neon64/enc_tail.c @@ -1,28 +1,28 @@ - if (srclen-- == 0) { - break; - } - *o++ = neon64_base64_table_enc[*c >> 2]; - st.carry = (*c++ << 4) & 0x30; - st.bytes++; - outl += 1; - - case 1: if (srclen-- == 0) { - break; - } - *o++ = neon64_base64_table_enc[st.carry | (*c >> 4)]; - st.carry = (*c++ << 2) & 0x3C; - st.bytes++; - outl += 1; - - case 2: if (srclen-- == 0) { - break; - } - *o++ = neon64_base64_table_enc[st.carry | (*c >> 6)]; - *o++ = neon64_base64_table_enc[*c++ & 0x3F]; - st.bytes = 0; - outl += 2; - } -} -state->bytes = st.bytes; -state->carry = st.carry; -*outlen = outl; + if (srclen-- == 0) { + break; + } + *o++ = neon64_base64_table_enc[*c >> 2]; + st.carry = (*c++ << 4) & 0x30; + st.bytes++; + outl += 1; + + case 1: if (srclen-- == 0) { + break; + } + *o++ = neon64_base64_table_enc[st.carry | (*c >> 4)]; + st.carry = (*c++ << 2) & 0x3C; + st.bytes++; + outl += 1; + + case 2: if (srclen-- == 0) { + break; + } + *o++ = neon64_base64_table_enc[st.carry | (*c >> 6)]; + *o++ = neon64_base64_table_enc[*c++ & 0x3F]; + st.bytes = 0; + outl += 2; + } +} +state->bytes = st.bytes; +state->carry = st.carry; +*outlen = outl; diff --git a/contrib/libs/base64/neon64/enc_uint64.c b/contrib/libs/base64/neon64/enc_uint64.c index 2db3c0be97e..15e4436fe3e 100644 --- a/contrib/libs/base64/neon64/enc_uint64.c +++ b/contrib/libs/base64/neon64/enc_uint64.c @@ -1,28 +1,28 @@ -// If we have 64-bit ints, pick off 6 bytes at a time for as long as we can, -// but ensure that there are at least 8 bytes available to avoid segfaulting: -while (srclen >= 8) -{ - // Load string: - uint64_t str = *(uint64_t *)c; - - // Reorder to 64-bit big-endian, if not already in that format. The - // workset must be in big-endian, otherwise the shifted bits do not - // carry over properly among adjacent bytes: - str = cpu_to_be64(str); - - // Shift input by 6 bytes each round and mask in only the lower 6 bits; - // look up the character in the Base64 encoding table and write it to - // the output location: - *o++ = neon64_base64_table_enc[(str >> 58) & 0x3F]; - *o++ = neon64_base64_table_enc[(str >> 52) & 0x3F]; - *o++ = neon64_base64_table_enc[(str >> 46) & 0x3F]; - *o++ = neon64_base64_table_enc[(str >> 40) & 0x3F]; - *o++ = neon64_base64_table_enc[(str >> 34) & 0x3F]; - *o++ = neon64_base64_table_enc[(str >> 28) & 0x3F]; - *o++ = neon64_base64_table_enc[(str >> 22) & 0x3F]; - *o++ = neon64_base64_table_enc[(str >> 16) & 0x3F]; - - c += 6; // 6 bytes of input - outl += 8; // 8 bytes of output - srclen -= 6; -} +// If we have 64-bit ints, pick off 6 bytes at a time for as long as we can, +// but ensure that there are at least 8 bytes available to avoid segfaulting: +while (srclen >= 8) +{ + // Load string: + uint64_t str = *(uint64_t *)c; + + // Reorder to 64-bit big-endian, if not already in that format. The + // workset must be in big-endian, otherwise the shifted bits do not + // carry over properly among adjacent bytes: + str = cpu_to_be64(str); + + // Shift input by 6 bytes each round and mask in only the lower 6 bits; + // look up the character in the Base64 encoding table and write it to + // the output location: + *o++ = neon64_base64_table_enc[(str >> 58) & 0x3F]; + *o++ = neon64_base64_table_enc[(str >> 52) & 0x3F]; + *o++ = neon64_base64_table_enc[(str >> 46) & 0x3F]; + *o++ = neon64_base64_table_enc[(str >> 40) & 0x3F]; + *o++ = neon64_base64_table_enc[(str >> 34) & 0x3F]; + *o++ = neon64_base64_table_enc[(str >> 28) & 0x3F]; + *o++ = neon64_base64_table_enc[(str >> 22) & 0x3F]; + *o++ = neon64_base64_table_enc[(str >> 16) & 0x3F]; + + c += 6; // 6 bytes of input + outl += 8; // 8 bytes of output + srclen -= 6; +} diff --git a/contrib/libs/base64/neon64/lib.c b/contrib/libs/base64/neon64/lib.c index de5d49e7117..63d514476ef 100644 --- a/contrib/libs/base64/neon64/lib.c +++ b/contrib/libs/base64/neon64/lib.c @@ -1,122 +1,122 @@ -#include <stdint.h> -#include <stddef.h> -#include <stdlib.h> - -#include "libbase64.h" -#include "codecs.h" - -const uint8_t -neon64_base64_table_enc[] = - "ABCDEFGHIJKLMNOPQRSTUVWXYZ" - "abcdefghijklmnopqrstuvwxyz" - "0123456789+/"; - -// In the lookup table below, note that the value for '=' (character 61) is -// 254, not 255. This character is used for in-band signaling of the end of -// the datastream, and we will use that later. The characters A-Z, a-z, 0-9 -// and + / are mapped to their "decoded" values. The other bytes all map to -// the value 255, which flags them as "invalid input". - -const uint8_t -neon64_base64_table_dec[] = -{ - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, // 0..15 - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, // 16..31 - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 62, 254, 62, 255, 63, // 32..47 - 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 255, 255, 255, 254, 255, 255, // 48..63 - 255, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, // 64..79 - 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 255, 255, 255, 255, 63, // 80..95 - 255, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, // 96..111 - 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 255, 255, 255, 255, 255, // 112..127 - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, // 128..143 - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, -}; - -void -neon64_base64_stream_encode_init (struct neon64_base64_state *state) -{ - state->eof = 0; - state->bytes = 0; - state->carry = 0; -} - -void -neon64_base64_stream_encode_final - ( struct neon64_base64_state *state - , char *out - , size_t *outlen - ) -{ - uint8_t *o = (uint8_t *)out; - - if (state->bytes == 1) { - *o++ = neon64_base64_table_enc[state->carry]; - *o++ = '='; - *o++ = '='; - *outlen = 3; - return; - } - if (state->bytes == 2) { - *o++ = neon64_base64_table_enc[state->carry]; - *o++ = '='; - *outlen = 2; - return; - } - *outlen = 0; -} - -void -neon64_base64_stream_decode_init (struct neon64_base64_state *state) -{ - state->eof = 0; - state->bytes = 0; - state->carry = 0; -} - -void -neon64_base64_encode - ( const char *src - , size_t srclen - , char *out - , size_t *outlen - ) -{ - size_t s; - size_t t; - struct neon64_base64_state state; - - // Init the stream reader: - neon64_base64_stream_encode_init(&state); - - // Feed the whole string to the stream reader: - neon64_base64_stream_encode(&state, src, srclen, out, &s); - - // Finalize the stream by writing trailer if any: - neon64_base64_stream_encode_final(&state, out + s, &t); - - // Final output length is stream length plus tail: - *outlen = s + t; -} - -int -neon64_base64_decode - ( const char *src - , size_t srclen - , char *out - , size_t *outlen - ) -{ - struct neon64_base64_state state; - - // Init the stream reader: - neon64_base64_stream_decode_init(&state); - - // Feed the whole string to the stream reader: - return neon64_base64_stream_decode(&state, src, srclen, out, outlen); -} +#include <stdint.h> +#include <stddef.h> +#include <stdlib.h> + +#include "libbase64.h" +#include "codecs.h" + +const uint8_t +neon64_base64_table_enc[] = + "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + "abcdefghijklmnopqrstuvwxyz" + "0123456789+/"; + +// In the lookup table below, note that the value for '=' (character 61) is +// 254, not 255. This character is used for in-band signaling of the end of +// the datastream, and we will use that later. The characters A-Z, a-z, 0-9 +// and + / are mapped to their "decoded" values. The other bytes all map to +// the value 255, which flags them as "invalid input". + +const uint8_t +neon64_base64_table_dec[] = +{ + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, // 0..15 + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, // 16..31 + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 62, 254, 62, 255, 63, // 32..47 + 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 255, 255, 255, 254, 255, 255, // 48..63 + 255, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, // 64..79 + 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 255, 255, 255, 255, 63, // 80..95 + 255, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, // 96..111 + 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 255, 255, 255, 255, 255, // 112..127 + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, // 128..143 + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, +}; + +void +neon64_base64_stream_encode_init (struct neon64_base64_state *state) +{ + state->eof = 0; + state->bytes = 0; + state->carry = 0; +} + +void +neon64_base64_stream_encode_final + ( struct neon64_base64_state *state + , char *out + , size_t *outlen + ) +{ + uint8_t *o = (uint8_t *)out; + + if (state->bytes == 1) { + *o++ = neon64_base64_table_enc[state->carry]; + *o++ = '='; + *o++ = '='; + *outlen = 3; + return; + } + if (state->bytes == 2) { + *o++ = neon64_base64_table_enc[state->carry]; + *o++ = '='; + *outlen = 2; + return; + } + *outlen = 0; +} + +void +neon64_base64_stream_decode_init (struct neon64_base64_state *state) +{ + state->eof = 0; + state->bytes = 0; + state->carry = 0; +} + +void +neon64_base64_encode + ( const char *src + , size_t srclen + , char *out + , size_t *outlen + ) +{ + size_t s; + size_t t; + struct neon64_base64_state state; + + // Init the stream reader: + neon64_base64_stream_encode_init(&state); + + // Feed the whole string to the stream reader: + neon64_base64_stream_encode(&state, src, srclen, out, &s); + + // Finalize the stream by writing trailer if any: + neon64_base64_stream_encode_final(&state, out + s, &t); + + // Final output length is stream length plus tail: + *outlen = s + t; +} + +int +neon64_base64_decode + ( const char *src + , size_t srclen + , char *out + , size_t *outlen + ) +{ + struct neon64_base64_state state; + + // Init the stream reader: + neon64_base64_stream_decode_init(&state); + + // Feed the whole string to the stream reader: + return neon64_base64_stream_decode(&state, src, srclen, out, outlen); +} diff --git a/contrib/libs/base64/neon64/libbase64.h b/contrib/libs/base64/neon64/libbase64.h index a7224965d71..7566eb75458 100644 --- a/contrib/libs/base64/neon64/libbase64.h +++ b/contrib/libs/base64/neon64/libbase64.h @@ -1,89 +1,89 @@ -#pragma once - -#ifdef __cplusplus -extern "C" { -#endif - -struct neon64_base64_state { - int eof; - int bytes; - unsigned char carry; -}; - -/* Wrapper function to encode a plain string of given length. Output is written - * to *out without trailing zero. Output length in bytes is written to *outlen. - * The buffer in `out` has been allocated by the caller and is at least 4/3 the - * size of the input. See above for `flags`; set to 0 for default operation: */ -void neon64_base64_encode - ( const char *src - , size_t srclen - , char *out - , size_t *outlen - ) ; - -/* Call this before calling base64_stream_encode() to init the state. See above - * for `flags`; set to 0 for default operation: */ -void neon64_base64_stream_encode_init - ( struct neon64_base64_state *state - ) ; - -/* Encodes the block of data of given length at `src`, into the buffer at - * `out`. Caller is responsible for allocating a large enough out-buffer; it - * must be at least 4/3 the size of the in-buffer, but take some margin. Places - * the number of new bytes written into `outlen` (which is set to zero when the - * function starts). Does not zero-terminate or finalize the output. */ -void neon64_base64_stream_encode - ( struct neon64_base64_state *state - , const char *src - , size_t srclen - , char *out - , size_t *outlen - ) ; - -/* Finalizes the output begun by previous calls to `base64_stream_encode()`. - * Adds the required end-of-stream markers if appropriate. `outlen` is modified - * and will contain the number of new bytes written at `out` (which will quite - * often be zero). */ -void neon64_base64_stream_encode_final - ( struct neon64_base64_state *state - , char *out - , size_t *outlen - ) ; - -/* Wrapper function to decode a plain string of given length. Output is written - * to *out without trailing zero. Output length in bytes is written to *outlen. - * The buffer in `out` has been allocated by the caller and is at least 3/4 the - * size of the input. See above for `flags`, set to 0 for default operation: */ -int neon64_base64_decode - ( const char *src - , size_t srclen - , char *out - , size_t *outlen - ) ; - -/* Call this before calling base64_stream_decode() to init the state. See above - * for `flags`; set to 0 for default operation: */ -void neon64_base64_stream_decode_init - ( struct neon64_base64_state *state - ) ; - -/* Decodes the block of data of given length at `src`, into the buffer at - * `out`. Caller is responsible for allocating a large enough out-buffer; it - * must be at least 3/4 the size of the in-buffer, but take some margin. Places - * the number of new bytes written into `outlen` (which is set to zero when the - * function starts). Does not zero-terminate the output. Returns 1 if all is - * well, and 0 if a decoding error was found, such as an invalid character. - * Returns -1 if the chosen codec is not included in the current build. Used by - * the test harness to check whether a codec is available for testing. */ -int neon64_base64_stream_decode - ( struct neon64_base64_state *state - , const char *src - , size_t srclen - , char *out - , size_t *outlen - ) ; - -#ifdef __cplusplus -} -#endif - +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +struct neon64_base64_state { + int eof; + int bytes; + unsigned char carry; +}; + +/* Wrapper function to encode a plain string of given length. Output is written + * to *out without trailing zero. Output length in bytes is written to *outlen. + * The buffer in `out` has been allocated by the caller and is at least 4/3 the + * size of the input. See above for `flags`; set to 0 for default operation: */ +void neon64_base64_encode + ( const char *src + , size_t srclen + , char *out + , size_t *outlen + ) ; + +/* Call this before calling base64_stream_encode() to init the state. See above + * for `flags`; set to 0 for default operation: */ +void neon64_base64_stream_encode_init + ( struct neon64_base64_state *state + ) ; + +/* Encodes the block of data of given length at `src`, into the buffer at + * `out`. Caller is responsible for allocating a large enough out-buffer; it + * must be at least 4/3 the size of the in-buffer, but take some margin. Places + * the number of new bytes written into `outlen` (which is set to zero when the + * function starts). Does not zero-terminate or finalize the output. */ +void neon64_base64_stream_encode + ( struct neon64_base64_state *state + , const char *src + , size_t srclen + , char *out + , size_t *outlen + ) ; + +/* Finalizes the output begun by previous calls to `base64_stream_encode()`. + * Adds the required end-of-stream markers if appropriate. `outlen` is modified + * and will contain the number of new bytes written at `out` (which will quite + * often be zero). */ +void neon64_base64_stream_encode_final + ( struct neon64_base64_state *state + , char *out + , size_t *outlen + ) ; + +/* Wrapper function to decode a plain string of given length. Output is written + * to *out without trailing zero. Output length in bytes is written to *outlen. + * The buffer in `out` has been allocated by the caller and is at least 3/4 the + * size of the input. See above for `flags`, set to 0 for default operation: */ +int neon64_base64_decode + ( const char *src + , size_t srclen + , char *out + , size_t *outlen + ) ; + +/* Call this before calling base64_stream_decode() to init the state. See above + * for `flags`; set to 0 for default operation: */ +void neon64_base64_stream_decode_init + ( struct neon64_base64_state *state + ) ; + +/* Decodes the block of data of given length at `src`, into the buffer at + * `out`. Caller is responsible for allocating a large enough out-buffer; it + * must be at least 3/4 the size of the in-buffer, but take some margin. Places + * the number of new bytes written into `outlen` (which is set to zero when the + * function starts). Does not zero-terminate the output. Returns 1 if all is + * well, and 0 if a decoding error was found, such as an invalid character. + * Returns -1 if the chosen codec is not included in the current build. Used by + * the test harness to check whether a codec is available for testing. */ +int neon64_base64_stream_decode + ( struct neon64_base64_state *state + , const char *src + , size_t srclen + , char *out + , size_t *outlen + ) ; + +#ifdef __cplusplus +} +#endif + diff --git a/contrib/libs/base64/neon64/ya.make b/contrib/libs/base64/neon64/ya.make index 82d821b4eec..2b171abf95a 100644 --- a/contrib/libs/base64/neon64/ya.make +++ b/contrib/libs/base64/neon64/ya.make @@ -1,11 +1,11 @@ -OWNER( - yazevnul +OWNER( + yazevnul g:contrib g:cpp-contrib -) - -LIBRARY() - +) + +LIBRARY() + LICENSE( BSD-2-Clause AND MIT @@ -13,20 +13,20 @@ LICENSE( LICENSE_TEXTS(.yandex_meta/licenses.list.txt) -NO_UTIL() - -SRCS( - codec_neon64.c - lib.c -) - -IF (ARCH_AARCH64 OR ARCH_ARM64) +NO_UTIL() + +SRCS( + codec_neon64.c + lib.c +) + +IF (ARCH_AARCH64 OR ARCH_ARM64) IF (OS_LINUX OR OS_DARWIN OR OS_ANDROID) CONLYFLAGS( -march=armv8-a -std=c11 ) - ENDIF() -ENDIF() - -END() + ENDIF() +ENDIF() + +END() diff --git a/contrib/libs/base64/plain32/codec_plain.c b/contrib/libs/base64/plain32/codec_plain.c index 740d343468a..0960e8dfb95 100644 --- a/contrib/libs/base64/plain32/codec_plain.c +++ b/contrib/libs/base64/plain32/codec_plain.c @@ -1,35 +1,35 @@ -#include <stdint.h> -#include <stddef.h> -#include <stdlib.h> +#include <stdint.h> +#include <stddef.h> +#include <stdlib.h> #include <string.h> - -#include "libbase64.h" -#include "codecs.h" - -void -plain32_base64_stream_encode - ( struct plain32_base64_state *state - , const char *src - , size_t srclen - , char *out - , size_t *outlen - ) -{ - #include "enc_head.c" - #include "enc_uint32.c" - #include "enc_tail.c" -} - -int -plain32_base64_stream_decode - ( struct plain32_base64_state *state - , const char *src - , size_t srclen - , char *out - , size_t *outlen - ) -{ - #include "dec_head.c" - #include "dec_uint32.c" - #include "dec_tail.c" -} + +#include "libbase64.h" +#include "codecs.h" + +void +plain32_base64_stream_encode + ( struct plain32_base64_state *state + , const char *src + , size_t srclen + , char *out + , size_t *outlen + ) +{ + #include "enc_head.c" + #include "enc_uint32.c" + #include "enc_tail.c" +} + +int +plain32_base64_stream_decode + ( struct plain32_base64_state *state + , const char *src + , size_t srclen + , char *out + , size_t *outlen + ) +{ + #include "dec_head.c" + #include "dec_uint32.c" + #include "dec_tail.c" +} diff --git a/contrib/libs/base64/plain32/codecs.h b/contrib/libs/base64/plain32/codecs.h index 0b31c97cd7a..233814b09ff 100644 --- a/contrib/libs/base64/plain32/codecs.h +++ b/contrib/libs/base64/plain32/codecs.h @@ -1,42 +1,42 @@ -#pragma once - -// Define machine endianness. This is for GCC: -#if (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__) - #define PLAIN32_LITTLE_ENDIAN 1 -#else - #define PLAIN32_LITTLE_ENDIAN 0 -#endif - -// This is for Clang: -#ifdef __LITTLE_ENDIAN__ - #define PLAIN32_LITTLE_ENDIAN 1 -#endif - -#ifdef __BIG_ENDIAN__ - #define PLAIN32_LITTLE_ENDIAN 0 -#endif - -// Endian conversion functions -#if PLAIN32_LITTLE_ENDIAN -#if defined(_WIN64) || defined(__WIN32__) || defined(_WIN32) - #define cpu_to_be32(x) _byteswap_ulong(x) - #define cpu_to_be64(x) _byteswap_uint64(x) - #define be32_to_cpu(x) _byteswap_ulong(x) - #define be64_to_cpu(x) _byteswap_uint64(x) -#else - #define cpu_to_be32(x) __builtin_bswap32(x) - #define cpu_to_be64(x) __builtin_bswap64(x) - #define be32_to_cpu(x) __builtin_bswap32(x) - #define be64_to_cpu(x) __builtin_bswap64(x) -#endif -#else - #define cpu_to_be32(x) (x) - #define cpu_to_be64(x) (x) - #define be32_to_cpu(x) (x) - #define be64_to_cpu(x) (x) -#endif - -// These tables are used by all codecs -// for fallback plain encoding/decoding: -extern const uint8_t plain32_base64_table_enc[]; -extern const uint8_t plain32_base64_table_dec[]; +#pragma once + +// Define machine endianness. This is for GCC: +#if (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__) + #define PLAIN32_LITTLE_ENDIAN 1 +#else + #define PLAIN32_LITTLE_ENDIAN 0 +#endif + +// This is for Clang: +#ifdef __LITTLE_ENDIAN__ + #define PLAIN32_LITTLE_ENDIAN 1 +#endif + +#ifdef __BIG_ENDIAN__ + #define PLAIN32_LITTLE_ENDIAN 0 +#endif + +// Endian conversion functions +#if PLAIN32_LITTLE_ENDIAN +#if defined(_WIN64) || defined(__WIN32__) || defined(_WIN32) + #define cpu_to_be32(x) _byteswap_ulong(x) + #define cpu_to_be64(x) _byteswap_uint64(x) + #define be32_to_cpu(x) _byteswap_ulong(x) + #define be64_to_cpu(x) _byteswap_uint64(x) +#else + #define cpu_to_be32(x) __builtin_bswap32(x) + #define cpu_to_be64(x) __builtin_bswap64(x) + #define be32_to_cpu(x) __builtin_bswap32(x) + #define be64_to_cpu(x) __builtin_bswap64(x) +#endif +#else + #define cpu_to_be32(x) (x) + #define cpu_to_be64(x) (x) + #define be32_to_cpu(x) (x) + #define be64_to_cpu(x) (x) +#endif + +// These tables are used by all codecs +// for fallback plain encoding/decoding: +extern const uint8_t plain32_base64_table_enc[]; +extern const uint8_t plain32_base64_table_dec[]; diff --git a/contrib/libs/base64/plain32/dec_head.c b/contrib/libs/base64/plain32/dec_head.c index 472608fddf9..d95b8b477b8 100644 --- a/contrib/libs/base64/plain32/dec_head.c +++ b/contrib/libs/base64/plain32/dec_head.c @@ -1,29 +1,29 @@ -int ret = 0; -const uint8_t *c = (const uint8_t *)src; -uint8_t *o = (uint8_t *)out; -uint8_t q; - -// Use local temporaries to avoid cache thrashing: -size_t outl = 0; -struct plain32_base64_state st; -st.eof = state->eof; -st.bytes = state->bytes; -st.carry = state->carry; - -// If we previously saw an EOF or an invalid character, bail out: -if (st.eof) { - *outlen = 0; - return 0; -} - -// Turn four 6-bit numbers into three bytes: -// out[0] = 11111122 -// out[1] = 22223333 -// out[2] = 33444444 - -// Duff's device again: -switch (st.bytes) -{ - for (;;) - { - case 0: +int ret = 0; +const uint8_t *c = (const uint8_t *)src; +uint8_t *o = (uint8_t *)out; +uint8_t q; + +// Use local temporaries to avoid cache thrashing: +size_t outl = 0; +struct plain32_base64_state st; +st.eof = state->eof; +st.bytes = state->bytes; +st.carry = state->carry; + +// If we previously saw an EOF or an invalid character, bail out: +if (st.eof) { + *outlen = 0; + return 0; +} + +// Turn four 6-bit numbers into three bytes: +// out[0] = 11111122 +// out[1] = 22223333 +// out[2] = 33444444 + +// Duff's device again: +switch (st.bytes) +{ + for (;;) + { + case 0: diff --git a/contrib/libs/base64/plain32/dec_tail.c b/contrib/libs/base64/plain32/dec_tail.c index 06ab7848770..27870a94f0c 100644 --- a/contrib/libs/base64/plain32/dec_tail.c +++ b/contrib/libs/base64/plain32/dec_tail.c @@ -1,65 +1,65 @@ - if (srclen-- == 0) { - ret = 1; - break; - } - if ((q = plain32_base64_table_dec[*c++]) >= 254) { - st.eof = 1; - // Treat character '=' as invalid for byte 0: - break; - } - st.carry = q << 2; - st.bytes++; - - case 1: if (srclen-- == 0) { - ret = 1; - break; - } - if ((q = plain32_base64_table_dec[*c++]) >= 254) { - st.eof = 1; - // Treat character '=' as invalid for byte 1: - break; - } - *o++ = st.carry | (q >> 4); - st.carry = q << 4; - st.bytes++; - outl++; - - case 2: if (srclen-- == 0) { - ret = 1; - break; - } - if ((q = plain32_base64_table_dec[*c++]) >= 254) { - st.eof = 1; - // When q == 254, the input char is '='. Return 1 and EOF. - // Technically, should check if next byte is also '=', but never mind. - // When q == 255, the input char is invalid. Return 0 and EOF. - ret = (q == 254) ? 1 : 0; - break; - } - *o++ = st.carry | (q >> 2); - st.carry = q << 6; - st.bytes++; - outl++; - - case 3: if (srclen-- == 0) { - ret = 1; - break; - } - if ((q = plain32_base64_table_dec[*c++]) >= 254) { - st.eof = 1; - // When q == 254, the input char is '='. Return 1 and EOF. - // When q == 255, the input char is invalid. Return 0 and EOF. - ret = (q == 254) ? 1 : 0; - break; - } - *o++ = st.carry | q; - st.carry = 0; - st.bytes = 0; - outl++; - } -} -state->eof = st.eof; -state->bytes = st.bytes; -state->carry = st.carry; -*outlen = outl; -return ret; + if (srclen-- == 0) { + ret = 1; + break; + } + if ((q = plain32_base64_table_dec[*c++]) >= 254) { + st.eof = 1; + // Treat character '=' as invalid for byte 0: + break; + } + st.carry = q << 2; + st.bytes++; + + case 1: if (srclen-- == 0) { + ret = 1; + break; + } + if ((q = plain32_base64_table_dec[*c++]) >= 254) { + st.eof = 1; + // Treat character '=' as invalid for byte 1: + break; + } + *o++ = st.carry | (q >> 4); + st.carry = q << 4; + st.bytes++; + outl++; + + case 2: if (srclen-- == 0) { + ret = 1; + break; + } + if ((q = plain32_base64_table_dec[*c++]) >= 254) { + st.eof = 1; + // When q == 254, the input char is '='. Return 1 and EOF. + // Technically, should check if next byte is also '=', but never mind. + // When q == 255, the input char is invalid. Return 0 and EOF. + ret = (q == 254) ? 1 : 0; + break; + } + *o++ = st.carry | (q >> 2); + st.carry = q << 6; + st.bytes++; + outl++; + + case 3: if (srclen-- == 0) { + ret = 1; + break; + } + if ((q = plain32_base64_table_dec[*c++]) >= 254) { + st.eof = 1; + // When q == 254, the input char is '='. Return 1 and EOF. + // When q == 255, the input char is invalid. Return 0 and EOF. + ret = (q == 254) ? 1 : 0; + break; + } + *o++ = st.carry | q; + st.carry = 0; + st.bytes = 0; + outl++; + } +} +state->eof = st.eof; +state->bytes = st.bytes; +state->carry = st.carry; +*outlen = outl; +return ret; diff --git a/contrib/libs/base64/plain32/dec_uint32.c b/contrib/libs/base64/plain32/dec_uint32.c index db701d73d41..58fd78c7422 100644 --- a/contrib/libs/base64/plain32/dec_uint32.c +++ b/contrib/libs/base64/plain32/dec_uint32.c @@ -1,50 +1,50 @@ -// If we have native uint32's, pick off 4 bytes at a time for as long as we -// can, but make sure that we quit before seeing any == markers at the end of -// the string. Also, because we write a zero at the end of the output, ensure -// that there are at least 2 valid bytes of input data remaining to close the -// gap. 4 + 2 + 2 = 8 bytes: -while (srclen >= 8) -{ - uint32_t str, res, dec; - - // Load string: +// If we have native uint32's, pick off 4 bytes at a time for as long as we +// can, but make sure that we quit before seeing any == markers at the end of +// the string. Also, because we write a zero at the end of the output, ensure +// that there are at least 2 valid bytes of input data remaining to close the +// gap. 4 + 2 + 2 = 8 bytes: +while (srclen >= 8) +{ + uint32_t str, res, dec; + + // Load string: //str = *(uint32_t *)c; memcpy(&str, c, sizeof(str)); - - // Shuffle bytes to 32-bit bigendian: - str = cpu_to_be32(str); - - // Lookup each byte in the decoding table; if we encounter any - // "invalid" values, fall back on the bytewise code: - if ((dec = plain32_base64_table_dec[str >> 24]) > 63) { - break; - } - res = dec << 26; - - if ((dec = plain32_base64_table_dec[(str >> 16) & 0xFF]) > 63) { - break; - } - res |= dec << 20; - - if ((dec = plain32_base64_table_dec[(str >> 8) & 0xFF]) > 63) { - break; - } - res |= dec << 14; - - if ((dec = plain32_base64_table_dec[str & 0xFF]) > 63) { - break; - } - res |= dec << 8; - - // Reshuffle and repack into 3-byte output format: - res = be32_to_cpu(res); - - // Store back: + + // Shuffle bytes to 32-bit bigendian: + str = cpu_to_be32(str); + + // Lookup each byte in the decoding table; if we encounter any + // "invalid" values, fall back on the bytewise code: + if ((dec = plain32_base64_table_dec[str >> 24]) > 63) { + break; + } + res = dec << 26; + + if ((dec = plain32_base64_table_dec[(str >> 16) & 0xFF]) > 63) { + break; + } + res |= dec << 20; + + if ((dec = plain32_base64_table_dec[(str >> 8) & 0xFF]) > 63) { + break; + } + res |= dec << 14; + + if ((dec = plain32_base64_table_dec[str & 0xFF]) > 63) { + break; + } + res |= dec << 8; + + // Reshuffle and repack into 3-byte output format: + res = be32_to_cpu(res); + + // Store back: //*(uint32_t *)o = res; memcpy(o, &res, sizeof(res)); - - c += 4; - o += 3; - outl += 3; - srclen -= 4; -} + + c += 4; + o += 3; + outl += 3; + srclen -= 4; +} diff --git a/contrib/libs/base64/plain32/enc_head.c b/contrib/libs/base64/plain32/enc_head.c index 451f1bdad0b..e06f2b727ab 100644 --- a/contrib/libs/base64/plain32/enc_head.c +++ b/contrib/libs/base64/plain32/enc_head.c @@ -1,23 +1,23 @@ -// Assume that *out is large enough to contain the output. -// Theoretically it should be 4/3 the length of src. -const uint8_t *c = (const uint8_t *)src; -uint8_t *o = (uint8_t *)out; - -// Use local temporaries to avoid cache thrashing: -size_t outl = 0; -struct plain32_base64_state st; -st.bytes = state->bytes; -st.carry = state->carry; - -// Turn three bytes into four 6-bit numbers: -// in[0] = 00111111 -// in[1] = 00112222 -// in[2] = 00222233 -// in[3] = 00333333 - -// Duff's device, a for() loop inside a switch() statement. Legal! -switch (st.bytes) -{ - for (;;) - { - case 0: +// Assume that *out is large enough to contain the output. +// Theoretically it should be 4/3 the length of src. +const uint8_t *c = (const uint8_t *)src; +uint8_t *o = (uint8_t *)out; + +// Use local temporaries to avoid cache thrashing: +size_t outl = 0; +struct plain32_base64_state st; +st.bytes = state->bytes; +st.carry = state->carry; + +// Turn three bytes into four 6-bit numbers: +// in[0] = 00111111 +// in[1] = 00112222 +// in[2] = 00222233 +// in[3] = 00333333 + +// Duff's device, a for() loop inside a switch() statement. Legal! +switch (st.bytes) +{ + for (;;) + { + case 0: diff --git a/contrib/libs/base64/plain32/enc_tail.c b/contrib/libs/base64/plain32/enc_tail.c index 58400682645..f5a8c2756a5 100644 --- a/contrib/libs/base64/plain32/enc_tail.c +++ b/contrib/libs/base64/plain32/enc_tail.c @@ -1,28 +1,28 @@ - if (srclen-- == 0) { - break; - } - *o++ = plain32_base64_table_enc[*c >> 2]; - st.carry = (*c++ << 4) & 0x30; - st.bytes++; - outl += 1; - - case 1: if (srclen-- == 0) { - break; - } - *o++ = plain32_base64_table_enc[st.carry | (*c >> 4)]; - st.carry = (*c++ << 2) & 0x3C; - st.bytes++; - outl += 1; - - case 2: if (srclen-- == 0) { - break; - } - *o++ = plain32_base64_table_enc[st.carry | (*c >> 6)]; - *o++ = plain32_base64_table_enc[*c++ & 0x3F]; - st.bytes = 0; - outl += 2; - } -} -state->bytes = st.bytes; -state->carry = st.carry; -*outlen = outl; + if (srclen-- == 0) { + break; + } + *o++ = plain32_base64_table_enc[*c >> 2]; + st.carry = (*c++ << 4) & 0x30; + st.bytes++; + outl += 1; + + case 1: if (srclen-- == 0) { + break; + } + *o++ = plain32_base64_table_enc[st.carry | (*c >> 4)]; + st.carry = (*c++ << 2) & 0x3C; + st.bytes++; + outl += 1; + + case 2: if (srclen-- == 0) { + break; + } + *o++ = plain32_base64_table_enc[st.carry | (*c >> 6)]; + *o++ = plain32_base64_table_enc[*c++ & 0x3F]; + st.bytes = 0; + outl += 2; + } +} +state->bytes = st.bytes; +state->carry = st.carry; +*outlen = outl; diff --git a/contrib/libs/base64/plain32/enc_uint32.c b/contrib/libs/base64/plain32/enc_uint32.c index 1dbe5fbe536..a22f599ce4b 100644 --- a/contrib/libs/base64/plain32/enc_uint32.c +++ b/contrib/libs/base64/plain32/enc_uint32.c @@ -1,27 +1,27 @@ -// If we have 32-bit ints, pick off 3 bytes at a time for as long as we can, -// but ensure that there are at least 4 bytes available to avoid segfaulting: -while (srclen >= 4) -{ - // Load string: +// If we have 32-bit ints, pick off 3 bytes at a time for as long as we can, +// but ensure that there are at least 4 bytes available to avoid segfaulting: +while (srclen >= 4) +{ + // Load string: //uint32_t str = *(uint32_t *)c; uint32_t str; - + memcpy(&str, c, sizeof(str)); - // Reorder to 32-bit big-endian, if not already in that format. The - // workset must be in big-endian, otherwise the shifted bits do not - // carry over properly among adjacent bytes: - str = cpu_to_be32(str); - - // Shift input by 6 bytes each round and mask in only the lower 6 bits; - // look up the character in the Base64 encoding table and write it to - // the output location: - *o++ = plain32_base64_table_enc[(str >> 26) & 0x3F]; - *o++ = plain32_base64_table_enc[(str >> 20) & 0x3F]; - *o++ = plain32_base64_table_enc[(str >> 14) & 0x3F]; - *o++ = plain32_base64_table_enc[(str >> 8) & 0x3F]; - - c += 3; // 3 bytes of input - outl += 4; // 4 bytes of output - srclen -= 3; -} + // Reorder to 32-bit big-endian, if not already in that format. The + // workset must be in big-endian, otherwise the shifted bits do not + // carry over properly among adjacent bytes: + str = cpu_to_be32(str); + + // Shift input by 6 bytes each round and mask in only the lower 6 bits; + // look up the character in the Base64 encoding table and write it to + // the output location: + *o++ = plain32_base64_table_enc[(str >> 26) & 0x3F]; + *o++ = plain32_base64_table_enc[(str >> 20) & 0x3F]; + *o++ = plain32_base64_table_enc[(str >> 14) & 0x3F]; + *o++ = plain32_base64_table_enc[(str >> 8) & 0x3F]; + + c += 3; // 3 bytes of input + outl += 4; // 4 bytes of output + srclen -= 3; +} diff --git a/contrib/libs/base64/plain32/lib.c b/contrib/libs/base64/plain32/lib.c index 9eb2e705b40..d42ef50c36c 100644 --- a/contrib/libs/base64/plain32/lib.c +++ b/contrib/libs/base64/plain32/lib.c @@ -1,121 +1,121 @@ -#include <stdint.h> -#include <stddef.h> - -#include "libbase64.h" -#include "codecs.h" - -const uint8_t -plain32_base64_table_enc[] = - "ABCDEFGHIJKLMNOPQRSTUVWXYZ" - "abcdefghijklmnopqrstuvwxyz" - "0123456789+/"; - -// In the lookup table below, note that the value for '=' (character 61) is -// 254, not 255. This character is used for in-band signaling of the end of -// the datastream, and we will use that later. The characters A-Z, a-z, 0-9 -// and + / are mapped to their "decoded" values. The other bytes all map to -// the value 255, which flags them as "invalid input". - -const uint8_t -plain32_base64_table_dec[] = -{ - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, // 0..15 - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, // 16..31 - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 62, 254, 62, 255, 63, // 32..47 - 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 255, 255, 255, 254, 255, 255, // 48..63 - 255, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, // 64..79 - 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 255, 255, 255, 255, 63, // 80..95 - 255, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, // 96..111 - 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 255, 255, 255, 255, 255, // 112..127 - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, // 128..143 - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, -}; - -void -plain32_base64_stream_encode_init (struct plain32_base64_state *state) -{ - state->eof = 0; - state->bytes = 0; - state->carry = 0; -} - -void -plain32_base64_stream_encode_final - ( struct plain32_base64_state *state - , char *out - , size_t *outlen - ) -{ - uint8_t *o = (uint8_t *)out; - - if (state->bytes == 1) { - *o++ = plain32_base64_table_enc[state->carry]; - *o++ = '='; - *o++ = '='; - *outlen = 3; - return; - } - if (state->bytes == 2) { - *o++ = plain32_base64_table_enc[state->carry]; - *o++ = '='; - *outlen = 2; - return; - } - *outlen = 0; -} - -void -plain32_base64_stream_decode_init (struct plain32_base64_state *state) -{ - state->eof = 0; - state->bytes = 0; - state->carry = 0; -} - -void -plain32_base64_encode - ( const char *src - , size_t srclen - , char *out - , size_t *outlen - ) -{ - size_t s; - size_t t; - struct plain32_base64_state state; - - // Init the stream reader: - plain32_base64_stream_encode_init(&state); - - // Feed the whole string to the stream reader: - plain32_base64_stream_encode(&state, src, srclen, out, &s); - - // Finalize the stream by writing trailer if any: - plain32_base64_stream_encode_final(&state, out + s, &t); - - // Final output length is stream length plus tail: - *outlen = s + t; -} - -int -plain32_base64_decode - ( const char *src - , size_t srclen - , char *out - , size_t *outlen - ) -{ - struct plain32_base64_state state; - - // Init the stream reader: - plain32_base64_stream_decode_init(&state); - - // Feed the whole string to the stream reader: - return plain32_base64_stream_decode(&state, src, srclen, out, outlen); -} +#include <stdint.h> +#include <stddef.h> + +#include "libbase64.h" +#include "codecs.h" + +const uint8_t +plain32_base64_table_enc[] = + "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + "abcdefghijklmnopqrstuvwxyz" + "0123456789+/"; + +// In the lookup table below, note that the value for '=' (character 61) is +// 254, not 255. This character is used for in-band signaling of the end of +// the datastream, and we will use that later. The characters A-Z, a-z, 0-9 +// and + / are mapped to their "decoded" values. The other bytes all map to +// the value 255, which flags them as "invalid input". + +const uint8_t +plain32_base64_table_dec[] = +{ + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, // 0..15 + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, // 16..31 + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 62, 254, 62, 255, 63, // 32..47 + 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 255, 255, 255, 254, 255, 255, // 48..63 + 255, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, // 64..79 + 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 255, 255, 255, 255, 63, // 80..95 + 255, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, // 96..111 + 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 255, 255, 255, 255, 255, // 112..127 + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, // 128..143 + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, +}; + +void +plain32_base64_stream_encode_init (struct plain32_base64_state *state) +{ + state->eof = 0; + state->bytes = 0; + state->carry = 0; +} + +void +plain32_base64_stream_encode_final + ( struct plain32_base64_state *state + , char *out + , size_t *outlen + ) +{ + uint8_t *o = (uint8_t *)out; + + if (state->bytes == 1) { + *o++ = plain32_base64_table_enc[state->carry]; + *o++ = '='; + *o++ = '='; + *outlen = 3; + return; + } + if (state->bytes == 2) { + *o++ = plain32_base64_table_enc[state->carry]; + *o++ = '='; + *outlen = 2; + return; + } + *outlen = 0; +} + +void +plain32_base64_stream_decode_init (struct plain32_base64_state *state) +{ + state->eof = 0; + state->bytes = 0; + state->carry = 0; +} + +void +plain32_base64_encode + ( const char *src + , size_t srclen + , char *out + , size_t *outlen + ) +{ + size_t s; + size_t t; + struct plain32_base64_state state; + + // Init the stream reader: + plain32_base64_stream_encode_init(&state); + + // Feed the whole string to the stream reader: + plain32_base64_stream_encode(&state, src, srclen, out, &s); + + // Finalize the stream by writing trailer if any: + plain32_base64_stream_encode_final(&state, out + s, &t); + + // Final output length is stream length plus tail: + *outlen = s + t; +} + +int +plain32_base64_decode + ( const char *src + , size_t srclen + , char *out + , size_t *outlen + ) +{ + struct plain32_base64_state state; + + // Init the stream reader: + plain32_base64_stream_decode_init(&state); + + // Feed the whole string to the stream reader: + return plain32_base64_stream_decode(&state, src, srclen, out, outlen); +} diff --git a/contrib/libs/base64/plain32/libbase64.h b/contrib/libs/base64/plain32/libbase64.h index db54ea4fc21..2c2ec175e0b 100644 --- a/contrib/libs/base64/plain32/libbase64.h +++ b/contrib/libs/base64/plain32/libbase64.h @@ -1,89 +1,89 @@ -#pragma once - -#ifdef __cplusplus -extern "C" { -#endif - -struct plain32_base64_state { - int eof; - int bytes; - unsigned char carry; -}; - -/* Wrapper function to encode a plain string of given length. Output is written - * to *out without trailing zero. Output length in bytes is written to *outlen. - * The buffer in `out` has been allocated by the caller and is at least 4/3 the - * size of the input. See above for `flags`; set to 0 for default operation: */ -void plain32_base64_encode - ( const char *src - , size_t srclen - , char *out - , size_t *outlen - ) ; - -/* Call this before calling base64_stream_encode() to init the state. See above - * for `flags`; set to 0 for default operation: */ -void plain32_base64_stream_encode_init - ( struct plain32_base64_state *state - ) ; - -/* Encodes the block of data of given length at `src`, into the buffer at - * `out`. Caller is responsible for allocating a large enough out-buffer; it - * must be at least 4/3 the size of the in-buffer, but take some margin. Places - * the number of new bytes written into `outlen` (which is set to zero when the - * function starts). Does not zero-terminate or finalize the output. */ -void plain32_base64_stream_encode - ( struct plain32_base64_state *state - , const char *src - , size_t srclen - , char *out - , size_t *outlen - ) ; - -/* Finalizes the output begun by previous calls to `base64_stream_encode()`. - * Adds the required end-of-stream markers if appropriate. `outlen` is modified - * and will contain the number of new bytes written at `out` (which will quite - * often be zero). */ -void plain32_base64_stream_encode_final - ( struct plain32_base64_state *state - , char *out - , size_t *outlen - ) ; - -/* Wrapper function to decode a plain string of given length. Output is written - * to *out without trailing zero. Output length in bytes is written to *outlen. - * The buffer in `out` has been allocated by the caller and is at least 3/4 the - * size of the input. See above for `flags`, set to 0 for default operation: */ -int plain32_base64_decode - ( const char *src - , size_t srclen - , char *out - , size_t *outlen - ) ; - -/* Call this before calling base64_stream_decode() to init the state. See above - * for `flags`; set to 0 for default operation: */ -void plain32_base64_stream_decode_init - ( struct plain32_base64_state *state - ) ; - -/* Decodes the block of data of given length at `src`, into the buffer at - * `out`. Caller is responsible for allocating a large enough out-buffer; it - * must be at least 3/4 the size of the in-buffer, but take some margin. Places - * the number of new bytes written into `outlen` (which is set to zero when the - * function starts). Does not zero-terminate the output. Returns 1 if all is - * well, and 0 if a decoding error was found, such as an invalid character. - * Returns -1 if the chosen codec is not included in the current build. Used by - * the test harness to check whether a codec is available for testing. */ -int plain32_base64_stream_decode - ( struct plain32_base64_state *state - , const char *src - , size_t srclen - , char *out - , size_t *outlen - ) ; - -#ifdef __cplusplus -} -#endif - +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +struct plain32_base64_state { + int eof; + int bytes; + unsigned char carry; +}; + +/* Wrapper function to encode a plain string of given length. Output is written + * to *out without trailing zero. Output length in bytes is written to *outlen. + * The buffer in `out` has been allocated by the caller and is at least 4/3 the + * size of the input. See above for `flags`; set to 0 for default operation: */ +void plain32_base64_encode + ( const char *src + , size_t srclen + , char *out + , size_t *outlen + ) ; + +/* Call this before calling base64_stream_encode() to init the state. See above + * for `flags`; set to 0 for default operation: */ +void plain32_base64_stream_encode_init + ( struct plain32_base64_state *state + ) ; + +/* Encodes the block of data of given length at `src`, into the buffer at + * `out`. Caller is responsible for allocating a large enough out-buffer; it + * must be at least 4/3 the size of the in-buffer, but take some margin. Places + * the number of new bytes written into `outlen` (which is set to zero when the + * function starts). Does not zero-terminate or finalize the output. */ +void plain32_base64_stream_encode + ( struct plain32_base64_state *state + , const char *src + , size_t srclen + , char *out + , size_t *outlen + ) ; + +/* Finalizes the output begun by previous calls to `base64_stream_encode()`. + * Adds the required end-of-stream markers if appropriate. `outlen` is modified + * and will contain the number of new bytes written at `out` (which will quite + * often be zero). */ +void plain32_base64_stream_encode_final + ( struct plain32_base64_state *state + , char *out + , size_t *outlen + ) ; + +/* Wrapper function to decode a plain string of given length. Output is written + * to *out without trailing zero. Output length in bytes is written to *outlen. + * The buffer in `out` has been allocated by the caller and is at least 3/4 the + * size of the input. See above for `flags`, set to 0 for default operation: */ +int plain32_base64_decode + ( const char *src + , size_t srclen + , char *out + , size_t *outlen + ) ; + +/* Call this before calling base64_stream_decode() to init the state. See above + * for `flags`; set to 0 for default operation: */ +void plain32_base64_stream_decode_init + ( struct plain32_base64_state *state + ) ; + +/* Decodes the block of data of given length at `src`, into the buffer at + * `out`. Caller is responsible for allocating a large enough out-buffer; it + * must be at least 3/4 the size of the in-buffer, but take some margin. Places + * the number of new bytes written into `outlen` (which is set to zero when the + * function starts). Does not zero-terminate the output. Returns 1 if all is + * well, and 0 if a decoding error was found, such as an invalid character. + * Returns -1 if the chosen codec is not included in the current build. Used by + * the test harness to check whether a codec is available for testing. */ +int plain32_base64_stream_decode + ( struct plain32_base64_state *state + , const char *src + , size_t srclen + , char *out + , size_t *outlen + ) ; + +#ifdef __cplusplus +} +#endif + diff --git a/contrib/libs/base64/plain32/ya.make b/contrib/libs/base64/plain32/ya.make index 1f5a9ad2040..2055f8f5133 100644 --- a/contrib/libs/base64/plain32/ya.make +++ b/contrib/libs/base64/plain32/ya.make @@ -1,11 +1,11 @@ -OWNER( - yazevnul +OWNER( + yazevnul g:contrib g:cpp-contrib -) - -LIBRARY() - +) + +LIBRARY() + LICENSE( BSD-2-Clause AND MIT @@ -13,15 +13,15 @@ LICENSE( LICENSE_TEXTS(.yandex_meta/licenses.list.txt) -NO_UTIL() - -SRCS( - codec_plain.c - lib.c -) - +NO_UTIL() + +SRCS( + codec_plain.c + lib.c +) + IF (OS_LINUX OR OS_DARWIN) CONLYFLAGS(-std=c11) -ENDIF() - -END() +ENDIF() + +END() diff --git a/contrib/libs/base64/plain64/codec_plain.c b/contrib/libs/base64/plain64/codec_plain.c index 26a5af90979..841bd96bfd0 100644 --- a/contrib/libs/base64/plain64/codec_plain.c +++ b/contrib/libs/base64/plain64/codec_plain.c @@ -1,35 +1,35 @@ -#include <stdint.h> -#include <stddef.h> -#include <stdlib.h> +#include <stdint.h> +#include <stddef.h> +#include <stdlib.h> #include <string.h> - -#include "libbase64.h" -#include "codecs.h" - -void -plain64_base64_stream_encode - ( struct plain64_base64_state *state - , const char *src - , size_t srclen - , char *out - , size_t *outlen - ) -{ - #include "enc_head.c" - #include "enc_uint64.c" - #include "enc_tail.c" -} - -int -plain64_base64_stream_decode - ( struct plain64_base64_state *state - , const char *src - , size_t srclen - , char *out - , size_t *outlen - ) -{ - #include "dec_head.c" - #include "dec_uint64.c" - #include "dec_tail.c" -} + +#include "libbase64.h" +#include "codecs.h" + +void +plain64_base64_stream_encode + ( struct plain64_base64_state *state + , const char *src + , size_t srclen + , char *out + , size_t *outlen + ) +{ + #include "enc_head.c" + #include "enc_uint64.c" + #include "enc_tail.c" +} + +int +plain64_base64_stream_decode + ( struct plain64_base64_state *state + , const char *src + , size_t srclen + , char *out + , size_t *outlen + ) +{ + #include "dec_head.c" + #include "dec_uint64.c" + #include "dec_tail.c" +} diff --git a/contrib/libs/base64/plain64/codecs.h b/contrib/libs/base64/plain64/codecs.h index 25430f04c01..24cfbbc7d27 100644 --- a/contrib/libs/base64/plain64/codecs.h +++ b/contrib/libs/base64/plain64/codecs.h @@ -1,42 +1,42 @@ -#pragma once - -// Define machine endianness. This is for GCC: -#if (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__) - #define PLAIN64_LITTLE_ENDIAN 1 -#else - #define PLAIN64_LITTLE_ENDIAN 0 -#endif - -// This is for Clang: -#ifdef __LITTLE_ENDIAN__ - #define PLAIN64_LITTLE_ENDIAN 1 -#endif - -#ifdef __BIG_ENDIAN__ - #define PLAIN64_LITTLE_ENDIAN 0 -#endif - -// Endian conversion functions -#if PLAIN64_LITTLE_ENDIAN -#if defined(_WIN64) || defined(__WIN32__) || defined(_WIN32) - #define cpu_to_be32(x) _byteswap_ulong(x) - #define cpu_to_be64(x) _byteswap_uint64(x) - #define be32_to_cpu(x) _byteswap_ulong(x) - #define be64_to_cpu(x) _byteswap_uint64(x) -#else - #define cpu_to_be32(x) __builtin_bswap32(x) - #define cpu_to_be64(x) __builtin_bswap64(x) - #define be32_to_cpu(x) __builtin_bswap32(x) - #define be64_to_cpu(x) __builtin_bswap64(x) -#endif -#else - #define cpu_to_be32(x) (x) - #define cpu_to_be64(x) (x) - #define be32_to_cpu(x) (x) - #define be64_to_cpu(x) (x) -#endif - -// These tables are used by all codecs -// for fallback plain encoding/decoding: -extern const uint8_t plain64_base64_table_enc[]; -extern const uint8_t plain64_base64_table_dec[]; +#pragma once + +// Define machine endianness. This is for GCC: +#if (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__) + #define PLAIN64_LITTLE_ENDIAN 1 +#else + #define PLAIN64_LITTLE_ENDIAN 0 +#endif + +// This is for Clang: +#ifdef __LITTLE_ENDIAN__ + #define PLAIN64_LITTLE_ENDIAN 1 +#endif + +#ifdef __BIG_ENDIAN__ + #define PLAIN64_LITTLE_ENDIAN 0 +#endif + +// Endian conversion functions +#if PLAIN64_LITTLE_ENDIAN +#if defined(_WIN64) || defined(__WIN32__) || defined(_WIN32) + #define cpu_to_be32(x) _byteswap_ulong(x) + #define cpu_to_be64(x) _byteswap_uint64(x) + #define be32_to_cpu(x) _byteswap_ulong(x) + #define be64_to_cpu(x) _byteswap_uint64(x) +#else + #define cpu_to_be32(x) __builtin_bswap32(x) + #define cpu_to_be64(x) __builtin_bswap64(x) + #define be32_to_cpu(x) __builtin_bswap32(x) + #define be64_to_cpu(x) __builtin_bswap64(x) +#endif +#else + #define cpu_to_be32(x) (x) + #define cpu_to_be64(x) (x) + #define be32_to_cpu(x) (x) + #define be64_to_cpu(x) (x) +#endif + +// These tables are used by all codecs +// for fallback plain encoding/decoding: +extern const uint8_t plain64_base64_table_enc[]; +extern const uint8_t plain64_base64_table_dec[]; diff --git a/contrib/libs/base64/plain64/dec_head.c b/contrib/libs/base64/plain64/dec_head.c index b505833d525..f343f82ebaf 100644 --- a/contrib/libs/base64/plain64/dec_head.c +++ b/contrib/libs/base64/plain64/dec_head.c @@ -1,29 +1,29 @@ -int ret = 0; -const uint8_t *c = (const uint8_t *)src; -uint8_t *o = (uint8_t *)out; -uint8_t q; - -// Use local temporaries to avoid cache thrashing: -size_t outl = 0; -struct plain64_base64_state st; -st.eof = state->eof; -st.bytes = state->bytes; -st.carry = state->carry; - -// If we previously saw an EOF or an invalid character, bail out: -if (st.eof) { - *outlen = 0; - return 0; -} - -// Turn four 6-bit numbers into three bytes: -// out[0] = 11111122 -// out[1] = 22223333 -// out[2] = 33444444 - -// Duff's device again: -switch (st.bytes) -{ - for (;;) - { - case 0: +int ret = 0; +const uint8_t *c = (const uint8_t *)src; +uint8_t *o = (uint8_t *)out; +uint8_t q; + +// Use local temporaries to avoid cache thrashing: +size_t outl = 0; +struct plain64_base64_state st; +st.eof = state->eof; +st.bytes = state->bytes; +st.carry = state->carry; + +// If we previously saw an EOF or an invalid character, bail out: +if (st.eof) { + *outlen = 0; + return 0; +} + +// Turn four 6-bit numbers into three bytes: +// out[0] = 11111122 +// out[1] = 22223333 +// out[2] = 33444444 + +// Duff's device again: +switch (st.bytes) +{ + for (;;) + { + case 0: diff --git a/contrib/libs/base64/plain64/dec_tail.c b/contrib/libs/base64/plain64/dec_tail.c index 7db2408190a..66b279e741d 100644 --- a/contrib/libs/base64/plain64/dec_tail.c +++ b/contrib/libs/base64/plain64/dec_tail.c @@ -1,65 +1,65 @@ - if (srclen-- == 0) { - ret = 1; - break; - } - if ((q = plain64_base64_table_dec[*c++]) >= 254) { - st.eof = 1; - // Treat character '=' as invalid for byte 0: - break; - } - st.carry = q << 2; - st.bytes++; - - case 1: if (srclen-- == 0) { - ret = 1; - break; - } - if ((q = plain64_base64_table_dec[*c++]) >= 254) { - st.eof = 1; - // Treat character '=' as invalid for byte 1: - break; - } - *o++ = st.carry | (q >> 4); - st.carry = q << 4; - st.bytes++; - outl++; - - case 2: if (srclen-- == 0) { - ret = 1; - break; - } - if ((q = plain64_base64_table_dec[*c++]) >= 254) { - st.eof = 1; - // When q == 254, the input char is '='. Return 1 and EOF. - // Technically, should check if next byte is also '=', but never mind. - // When q == 255, the input char is invalid. Return 0 and EOF. - ret = (q == 254) ? 1 : 0; - break; - } - *o++ = st.carry | (q >> 2); - st.carry = q << 6; - st.bytes++; - outl++; - - case 3: if (srclen-- == 0) { - ret = 1; - break; - } - if ((q = plain64_base64_table_dec[*c++]) >= 254) { - st.eof = 1; - // When q == 254, the input char is '='. Return 1 and EOF. - // When q == 255, the input char is invalid. Return 0 and EOF. - ret = (q == 254) ? 1 : 0; - break; - } - *o++ = st.carry | q; - st.carry = 0; - st.bytes = 0; - outl++; - } -} -state->eof = st.eof; -state->bytes = st.bytes; -state->carry = st.carry; -*outlen = outl; -return ret; + if (srclen-- == 0) { + ret = 1; + break; + } + if ((q = plain64_base64_table_dec[*c++]) >= 254) { + st.eof = 1; + // Treat character '=' as invalid for byte 0: + break; + } + st.carry = q << 2; + st.bytes++; + + case 1: if (srclen-- == 0) { + ret = 1; + break; + } + if ((q = plain64_base64_table_dec[*c++]) >= 254) { + st.eof = 1; + // Treat character '=' as invalid for byte 1: + break; + } + *o++ = st.carry | (q >> 4); + st.carry = q << 4; + st.bytes++; + outl++; + + case 2: if (srclen-- == 0) { + ret = 1; + break; + } + if ((q = plain64_base64_table_dec[*c++]) >= 254) { + st.eof = 1; + // When q == 254, the input char is '='. Return 1 and EOF. + // Technically, should check if next byte is also '=', but never mind. + // When q == 255, the input char is invalid. Return 0 and EOF. + ret = (q == 254) ? 1 : 0; + break; + } + *o++ = st.carry | (q >> 2); + st.carry = q << 6; + st.bytes++; + outl++; + + case 3: if (srclen-- == 0) { + ret = 1; + break; + } + if ((q = plain64_base64_table_dec[*c++]) >= 254) { + st.eof = 1; + // When q == 254, the input char is '='. Return 1 and EOF. + // When q == 255, the input char is invalid. Return 0 and EOF. + ret = (q == 254) ? 1 : 0; + break; + } + *o++ = st.carry | q; + st.carry = 0; + st.bytes = 0; + outl++; + } +} +state->eof = st.eof; +state->bytes = st.bytes; +state->carry = st.carry; +*outlen = outl; +return ret; diff --git a/contrib/libs/base64/plain64/dec_uint64.c b/contrib/libs/base64/plain64/dec_uint64.c index fe26e9881bf..a09fca54380 100644 --- a/contrib/libs/base64/plain64/dec_uint64.c +++ b/contrib/libs/base64/plain64/dec_uint64.c @@ -1,70 +1,70 @@ -// If we have native uint64's, pick off 8 bytes at a time for as long as we -// can, but make sure that we quit before seeing any == markers at the end of -// the string. Also, because we write two zeroes at the end of the output, -// ensure that there are at least 3 valid bytes of input data remaining to -// close the gap. 8 + 2 + 3 = 13 bytes: -while (srclen >= 13) -{ - uint64_t str, res, dec; - - // Load string: +// If we have native uint64's, pick off 8 bytes at a time for as long as we +// can, but make sure that we quit before seeing any == markers at the end of +// the string. Also, because we write two zeroes at the end of the output, +// ensure that there are at least 3 valid bytes of input data remaining to +// close the gap. 8 + 2 + 3 = 13 bytes: +while (srclen >= 13) +{ + uint64_t str, res, dec; + + // Load string: //str = *(uint64_t *)c; memcpy(&str, c, sizeof(str)); - - // Shuffle bytes to 64-bit bigendian: - str = cpu_to_be64(str); - - // Lookup each byte in the decoding table; if we encounter any - // "invalid" values, fall back on the bytewise code: - if ((dec = plain64_base64_table_dec[str >> 56]) > 63) { - break; - } - res = dec << 58; - - if ((dec = plain64_base64_table_dec[(str >> 48) & 0xFF]) > 63) { - break; - } - res |= dec << 52; - - if ((dec = plain64_base64_table_dec[(str >> 40) & 0xFF]) > 63) { - break; - } - res |= dec << 46; - - if ((dec = plain64_base64_table_dec[(str >> 32) & 0xFF]) > 63) { - break; - } - res |= dec << 40; - - if ((dec = plain64_base64_table_dec[(str >> 24) & 0xFF]) > 63) { - break; - } - res |= dec << 34; - - if ((dec = plain64_base64_table_dec[(str >> 16) & 0xFF]) > 63) { - break; - } - res |= dec << 28; - - if ((dec = plain64_base64_table_dec[(str >> 8) & 0xFF]) > 63) { - break; - } - res |= dec << 22; - - if ((dec = plain64_base64_table_dec[str & 0xFF]) > 63) { - break; - } - res |= dec << 16; - - // Reshuffle and repack into 6-byte output format: - res = be64_to_cpu(res); - - // Store back: + + // Shuffle bytes to 64-bit bigendian: + str = cpu_to_be64(str); + + // Lookup each byte in the decoding table; if we encounter any + // "invalid" values, fall back on the bytewise code: + if ((dec = plain64_base64_table_dec[str >> 56]) > 63) { + break; + } + res = dec << 58; + + if ((dec = plain64_base64_table_dec[(str >> 48) & 0xFF]) > 63) { + break; + } + res |= dec << 52; + + if ((dec = plain64_base64_table_dec[(str >> 40) & 0xFF]) > 63) { + break; + } + res |= dec << 46; + + if ((dec = plain64_base64_table_dec[(str >> 32) & 0xFF]) > 63) { + break; + } + res |= dec << 40; + + if ((dec = plain64_base64_table_dec[(str >> 24) & 0xFF]) > 63) { + break; + } + res |= dec << 34; + + if ((dec = plain64_base64_table_dec[(str >> 16) & 0xFF]) > 63) { + break; + } + res |= dec << 28; + + if ((dec = plain64_base64_table_dec[(str >> 8) & 0xFF]) > 63) { + break; + } + res |= dec << 22; + + if ((dec = plain64_base64_table_dec[str & 0xFF]) > 63) { + break; + } + res |= dec << 16; + + // Reshuffle and repack into 6-byte output format: + res = be64_to_cpu(res); + + // Store back: //*(uint64_t *)o = res; memcpy(o, &res, sizeof(res)); - - c += 8; - o += 6; - outl += 6; - srclen -= 8; -} + + c += 8; + o += 6; + outl += 6; + srclen -= 8; +} diff --git a/contrib/libs/base64/plain64/enc_head.c b/contrib/libs/base64/plain64/enc_head.c index 037a1fff997..f898eb080a6 100644 --- a/contrib/libs/base64/plain64/enc_head.c +++ b/contrib/libs/base64/plain64/enc_head.c @@ -1,23 +1,23 @@ -// Assume that *out is large enough to contain the output. -// Theoretically it should be 4/3 the length of src. -const uint8_t *c = (const uint8_t *)src; -uint8_t *o = (uint8_t *)out; - -// Use local temporaries to avoid cache thrashing: -size_t outl = 0; -struct plain64_base64_state st; -st.bytes = state->bytes; -st.carry = state->carry; - -// Turn three bytes into four 6-bit numbers: -// in[0] = 00111111 -// in[1] = 00112222 -// in[2] = 00222233 -// in[3] = 00333333 - -// Duff's device, a for() loop inside a switch() statement. Legal! -switch (st.bytes) -{ - for (;;) - { - case 0: +// Assume that *out is large enough to contain the output. +// Theoretically it should be 4/3 the length of src. +const uint8_t *c = (const uint8_t *)src; +uint8_t *o = (uint8_t *)out; + +// Use local temporaries to avoid cache thrashing: +size_t outl = 0; +struct plain64_base64_state st; +st.bytes = state->bytes; +st.carry = state->carry; + +// Turn three bytes into four 6-bit numbers: +// in[0] = 00111111 +// in[1] = 00112222 +// in[2] = 00222233 +// in[3] = 00333333 + +// Duff's device, a for() loop inside a switch() statement. Legal! +switch (st.bytes) +{ + for (;;) + { + case 0: diff --git a/contrib/libs/base64/plain64/enc_tail.c b/contrib/libs/base64/plain64/enc_tail.c index f98414b7771..af3628192e6 100644 --- a/contrib/libs/base64/plain64/enc_tail.c +++ b/contrib/libs/base64/plain64/enc_tail.c @@ -1,28 +1,28 @@ - if (srclen-- == 0) { - break; - } - *o++ = plain64_base64_table_enc[*c >> 2]; - st.carry = (*c++ << 4) & 0x30; - st.bytes++; - outl += 1; - - case 1: if (srclen-- == 0) { - break; - } - *o++ = plain64_base64_table_enc[st.carry | (*c >> 4)]; - st.carry = (*c++ << 2) & 0x3C; - st.bytes++; - outl += 1; - - case 2: if (srclen-- == 0) { - break; - } - *o++ = plain64_base64_table_enc[st.carry | (*c >> 6)]; - *o++ = plain64_base64_table_enc[*c++ & 0x3F]; - st.bytes = 0; - outl += 2; - } -} -state->bytes = st.bytes; -state->carry = st.carry; -*outlen = outl; + if (srclen-- == 0) { + break; + } + *o++ = plain64_base64_table_enc[*c >> 2]; + st.carry = (*c++ << 4) & 0x30; + st.bytes++; + outl += 1; + + case 1: if (srclen-- == 0) { + break; + } + *o++ = plain64_base64_table_enc[st.carry | (*c >> 4)]; + st.carry = (*c++ << 2) & 0x3C; + st.bytes++; + outl += 1; + + case 2: if (srclen-- == 0) { + break; + } + *o++ = plain64_base64_table_enc[st.carry | (*c >> 6)]; + *o++ = plain64_base64_table_enc[*c++ & 0x3F]; + st.bytes = 0; + outl += 2; + } +} +state->bytes = st.bytes; +state->carry = st.carry; +*outlen = outl; diff --git a/contrib/libs/base64/plain64/enc_uint64.c b/contrib/libs/base64/plain64/enc_uint64.c index 3d5955af24d..8fd60e3b796 100644 --- a/contrib/libs/base64/plain64/enc_uint64.c +++ b/contrib/libs/base64/plain64/enc_uint64.c @@ -1,31 +1,31 @@ -// If we have 64-bit ints, pick off 6 bytes at a time for as long as we can, -// but ensure that there are at least 8 bytes available to avoid segfaulting: -while (srclen >= 8) -{ - // Load string: +// If we have 64-bit ints, pick off 6 bytes at a time for as long as we can, +// but ensure that there are at least 8 bytes available to avoid segfaulting: +while (srclen >= 8) +{ + // Load string: //uint64_t str = *(uint64_t *)c; uint64_t str; - + memcpy(&str, c, sizeof(str)); - // Reorder to 64-bit big-endian, if not already in that format. The - // workset must be in big-endian, otherwise the shifted bits do not - // carry over properly among adjacent bytes: - str = cpu_to_be64(str); - - // Shift input by 6 bytes each round and mask in only the lower 6 bits; - // look up the character in the Base64 encoding table and write it to - // the output location: - *o++ = plain64_base64_table_enc[(str >> 58) & 0x3F]; - *o++ = plain64_base64_table_enc[(str >> 52) & 0x3F]; - *o++ = plain64_base64_table_enc[(str >> 46) & 0x3F]; - *o++ = plain64_base64_table_enc[(str >> 40) & 0x3F]; - *o++ = plain64_base64_table_enc[(str >> 34) & 0x3F]; - *o++ = plain64_base64_table_enc[(str >> 28) & 0x3F]; - *o++ = plain64_base64_table_enc[(str >> 22) & 0x3F]; - *o++ = plain64_base64_table_enc[(str >> 16) & 0x3F]; - - c += 6; // 6 bytes of input - outl += 8; // 8 bytes of output - srclen -= 6; -} + // Reorder to 64-bit big-endian, if not already in that format. The + // workset must be in big-endian, otherwise the shifted bits do not + // carry over properly among adjacent bytes: + str = cpu_to_be64(str); + + // Shift input by 6 bytes each round and mask in only the lower 6 bits; + // look up the character in the Base64 encoding table and write it to + // the output location: + *o++ = plain64_base64_table_enc[(str >> 58) & 0x3F]; + *o++ = plain64_base64_table_enc[(str >> 52) & 0x3F]; + *o++ = plain64_base64_table_enc[(str >> 46) & 0x3F]; + *o++ = plain64_base64_table_enc[(str >> 40) & 0x3F]; + *o++ = plain64_base64_table_enc[(str >> 34) & 0x3F]; + *o++ = plain64_base64_table_enc[(str >> 28) & 0x3F]; + *o++ = plain64_base64_table_enc[(str >> 22) & 0x3F]; + *o++ = plain64_base64_table_enc[(str >> 16) & 0x3F]; + + c += 6; // 6 bytes of input + outl += 8; // 8 bytes of output + srclen -= 6; +} diff --git a/contrib/libs/base64/plain64/lib.c b/contrib/libs/base64/plain64/lib.c index 99d91d2c3ca..bb434ad5ecc 100644 --- a/contrib/libs/base64/plain64/lib.c +++ b/contrib/libs/base64/plain64/lib.c @@ -1,121 +1,121 @@ -#include <stdint.h> -#include <stddef.h> - -#include "libbase64.h" -#include "codecs.h" - -const uint8_t -plain64_base64_table_enc[] = - "ABCDEFGHIJKLMNOPQRSTUVWXYZ" - "abcdefghijklmnopqrstuvwxyz" - "0123456789+/"; - -// In the lookup table below, note that the value for '=' (character 61) is -// 254, not 255. This character is used for in-band signaling of the end of -// the datastream, and we will use that later. The characters A-Z, a-z, 0-9 -// and + / are mapped to their "decoded" values. The other bytes all map to -// the value 255, which flags them as "invalid input". - -const uint8_t -plain64_base64_table_dec[] = -{ - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, // 0..15 - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, // 16..31 - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 62, 254, 62, 255, 63, // 32..47 - 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 255, 255, 255, 254, 255, 255, // 48..63 - 255, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, // 64..79 - 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 255, 255, 255, 255, 63, // 80..95 - 255, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, // 96..111 - 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 255, 255, 255, 255, 255, // 112..127 - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, // 128..143 - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, -}; - -void -plain64_base64_stream_encode_init (struct plain64_base64_state *state) -{ - state->eof = 0; - state->bytes = 0; - state->carry = 0; -} - -void -plain64_base64_stream_encode_final - ( struct plain64_base64_state *state - , char *out - , size_t *outlen - ) -{ - uint8_t *o = (uint8_t *)out; - - if (state->bytes == 1) { - *o++ = plain64_base64_table_enc[state->carry]; - *o++ = '='; - *o++ = '='; - *outlen = 3; - return; - } - if (state->bytes == 2) { - *o++ = plain64_base64_table_enc[state->carry]; - *o++ = '='; - *outlen = 2; - return; - } - *outlen = 0; -} - -void -plain64_base64_stream_decode_init (struct plain64_base64_state *state) -{ - state->eof = 0; - state->bytes = 0; - state->carry = 0; -} - -void -plain64_base64_encode - ( const char *src - , size_t srclen - , char *out - , size_t *outlen - ) -{ - size_t s; - size_t t; - struct plain64_base64_state state; - - // Init the stream reader: - plain64_base64_stream_encode_init(&state); - - // Feed the whole string to the stream reader: - plain64_base64_stream_encode(&state, src, srclen, out, &s); - - // Finalize the stream by writing trailer if any: - plain64_base64_stream_encode_final(&state, out + s, &t); - - // Final output length is stream length plus tail: - *outlen = s + t; -} - -int -plain64_base64_decode - ( const char *src - , size_t srclen - , char *out - , size_t *outlen - ) -{ - struct plain64_base64_state state; - - // Init the stream reader: - plain64_base64_stream_decode_init(&state); - - // Feed the whole string to the stream reader: - return plain64_base64_stream_decode(&state, src, srclen, out, outlen); -} +#include <stdint.h> +#include <stddef.h> + +#include "libbase64.h" +#include "codecs.h" + +const uint8_t +plain64_base64_table_enc[] = + "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + "abcdefghijklmnopqrstuvwxyz" + "0123456789+/"; + +// In the lookup table below, note that the value for '=' (character 61) is +// 254, not 255. This character is used for in-band signaling of the end of +// the datastream, and we will use that later. The characters A-Z, a-z, 0-9 +// and + / are mapped to their "decoded" values. The other bytes all map to +// the value 255, which flags them as "invalid input". + +const uint8_t +plain64_base64_table_dec[] = +{ + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, // 0..15 + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, // 16..31 + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 62, 254, 62, 255, 63, // 32..47 + 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 255, 255, 255, 254, 255, 255, // 48..63 + 255, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, // 64..79 + 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 255, 255, 255, 255, 63, // 80..95 + 255, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, // 96..111 + 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 255, 255, 255, 255, 255, // 112..127 + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, // 128..143 + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, +}; + +void +plain64_base64_stream_encode_init (struct plain64_base64_state *state) +{ + state->eof = 0; + state->bytes = 0; + state->carry = 0; +} + +void +plain64_base64_stream_encode_final + ( struct plain64_base64_state *state + , char *out + , size_t *outlen + ) +{ + uint8_t *o = (uint8_t *)out; + + if (state->bytes == 1) { + *o++ = plain64_base64_table_enc[state->carry]; + *o++ = '='; + *o++ = '='; + *outlen = 3; + return; + } + if (state->bytes == 2) { + *o++ = plain64_base64_table_enc[state->carry]; + *o++ = '='; + *outlen = 2; + return; + } + *outlen = 0; +} + +void +plain64_base64_stream_decode_init (struct plain64_base64_state *state) +{ + state->eof = 0; + state->bytes = 0; + state->carry = 0; +} + +void +plain64_base64_encode + ( const char *src + , size_t srclen + , char *out + , size_t *outlen + ) +{ + size_t s; + size_t t; + struct plain64_base64_state state; + + // Init the stream reader: + plain64_base64_stream_encode_init(&state); + + // Feed the whole string to the stream reader: + plain64_base64_stream_encode(&state, src, srclen, out, &s); + + // Finalize the stream by writing trailer if any: + plain64_base64_stream_encode_final(&state, out + s, &t); + + // Final output length is stream length plus tail: + *outlen = s + t; +} + +int +plain64_base64_decode + ( const char *src + , size_t srclen + , char *out + , size_t *outlen + ) +{ + struct plain64_base64_state state; + + // Init the stream reader: + plain64_base64_stream_decode_init(&state); + + // Feed the whole string to the stream reader: + return plain64_base64_stream_decode(&state, src, srclen, out, outlen); +} diff --git a/contrib/libs/base64/plain64/libbase64.h b/contrib/libs/base64/plain64/libbase64.h index 27a9ce8626b..b91b6af9249 100644 --- a/contrib/libs/base64/plain64/libbase64.h +++ b/contrib/libs/base64/plain64/libbase64.h @@ -1,89 +1,89 @@ -#pragma once - -#ifdef __cplusplus -extern "C" { -#endif - -struct plain64_base64_state { - int eof; - int bytes; - unsigned char carry; -}; - -/* Wrapper function to encode a plain string of given length. Output is written - * to *out without trailing zero. Output length in bytes is written to *outlen. - * The buffer in `out` has been allocated by the caller and is at least 4/3 the - * size of the input. See above for `flags`; set to 0 for default operation: */ -void plain64_base64_encode - ( const char *src - , size_t srclen - , char *out - , size_t *outlen - ) ; - -/* Call this before calling base64_stream_encode() to init the state. See above - * for `flags`; set to 0 for default operation: */ -void plain64_base64_stream_encode_init - ( struct plain64_base64_state *state - ) ; - -/* Encodes the block of data of given length at `src`, into the buffer at - * `out`. Caller is responsible for allocating a large enough out-buffer; it - * must be at least 4/3 the size of the in-buffer, but take some margin. Places - * the number of new bytes written into `outlen` (which is set to zero when the - * function starts). Does not zero-terminate or finalize the output. */ -void plain64_base64_stream_encode - ( struct plain64_base64_state *state - , const char *src - , size_t srclen - , char *out - , size_t *outlen - ) ; - -/* Finalizes the output begun by previous calls to `base64_stream_encode()`. - * Adds the required end-of-stream markers if appropriate. `outlen` is modified - * and will contain the number of new bytes written at `out` (which will quite - * often be zero). */ -void plain64_base64_stream_encode_final - ( struct plain64_base64_state *state - , char *out - , size_t *outlen - ) ; - -/* Wrapper function to decode a plain string of given length. Output is written - * to *out without trailing zero. Output length in bytes is written to *outlen. - * The buffer in `out` has been allocated by the caller and is at least 3/4 the - * size of the input. See above for `flags`, set to 0 for default operation: */ -int plain64_base64_decode - ( const char *src - , size_t srclen - , char *out - , size_t *outlen - ) ; - -/* Call this before calling base64_stream_decode() to init the state. See above - * for `flags`; set to 0 for default operation: */ -void plain64_base64_stream_decode_init - ( struct plain64_base64_state *state - ) ; - -/* Decodes the block of data of given length at `src`, into the buffer at - * `out`. Caller is responsible for allocating a large enough out-buffer; it - * must be at least 3/4 the size of the in-buffer, but take some margin. Places - * the number of new bytes written into `outlen` (which is set to zero when the - * function starts). Does not zero-terminate the output. Returns 1 if all is - * well, and 0 if a decoding error was found, such as an invalid character. - * Returns -1 if the chosen codec is not included in the current build. Used by - * the test harness to check whether a codec is available for testing. */ -int plain64_base64_stream_decode - ( struct plain64_base64_state *state - , const char *src - , size_t srclen - , char *out - , size_t *outlen - ) ; - -#ifdef __cplusplus -} -#endif - +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +struct plain64_base64_state { + int eof; + int bytes; + unsigned char carry; +}; + +/* Wrapper function to encode a plain string of given length. Output is written + * to *out without trailing zero. Output length in bytes is written to *outlen. + * The buffer in `out` has been allocated by the caller and is at least 4/3 the + * size of the input. See above for `flags`; set to 0 for default operation: */ +void plain64_base64_encode + ( const char *src + , size_t srclen + , char *out + , size_t *outlen + ) ; + +/* Call this before calling base64_stream_encode() to init the state. See above + * for `flags`; set to 0 for default operation: */ +void plain64_base64_stream_encode_init + ( struct plain64_base64_state *state + ) ; + +/* Encodes the block of data of given length at `src`, into the buffer at + * `out`. Caller is responsible for allocating a large enough out-buffer; it + * must be at least 4/3 the size of the in-buffer, but take some margin. Places + * the number of new bytes written into `outlen` (which is set to zero when the + * function starts). Does not zero-terminate or finalize the output. */ +void plain64_base64_stream_encode + ( struct plain64_base64_state *state + , const char *src + , size_t srclen + , char *out + , size_t *outlen + ) ; + +/* Finalizes the output begun by previous calls to `base64_stream_encode()`. + * Adds the required end-of-stream markers if appropriate. `outlen` is modified + * and will contain the number of new bytes written at `out` (which will quite + * often be zero). */ +void plain64_base64_stream_encode_final + ( struct plain64_base64_state *state + , char *out + , size_t *outlen + ) ; + +/* Wrapper function to decode a plain string of given length. Output is written + * to *out without trailing zero. Output length in bytes is written to *outlen. + * The buffer in `out` has been allocated by the caller and is at least 3/4 the + * size of the input. See above for `flags`, set to 0 for default operation: */ +int plain64_base64_decode + ( const char *src + , size_t srclen + , char *out + , size_t *outlen + ) ; + +/* Call this before calling base64_stream_decode() to init the state. See above + * for `flags`; set to 0 for default operation: */ +void plain64_base64_stream_decode_init + ( struct plain64_base64_state *state + ) ; + +/* Decodes the block of data of given length at `src`, into the buffer at + * `out`. Caller is responsible for allocating a large enough out-buffer; it + * must be at least 3/4 the size of the in-buffer, but take some margin. Places + * the number of new bytes written into `outlen` (which is set to zero when the + * function starts). Does not zero-terminate the output. Returns 1 if all is + * well, and 0 if a decoding error was found, such as an invalid character. + * Returns -1 if the chosen codec is not included in the current build. Used by + * the test harness to check whether a codec is available for testing. */ +int plain64_base64_stream_decode + ( struct plain64_base64_state *state + , const char *src + , size_t srclen + , char *out + , size_t *outlen + ) ; + +#ifdef __cplusplus +} +#endif + diff --git a/contrib/libs/base64/plain64/ya.make b/contrib/libs/base64/plain64/ya.make index 1f5a9ad2040..2055f8f5133 100644 --- a/contrib/libs/base64/plain64/ya.make +++ b/contrib/libs/base64/plain64/ya.make @@ -1,11 +1,11 @@ -OWNER( - yazevnul +OWNER( + yazevnul g:contrib g:cpp-contrib -) - -LIBRARY() - +) + +LIBRARY() + LICENSE( BSD-2-Clause AND MIT @@ -13,15 +13,15 @@ LICENSE( LICENSE_TEXTS(.yandex_meta/licenses.list.txt) -NO_UTIL() - -SRCS( - codec_plain.c - lib.c -) - +NO_UTIL() + +SRCS( + codec_plain.c + lib.c +) + IF (OS_LINUX OR OS_DARWIN) CONLYFLAGS(-std=c11) -ENDIF() - -END() +ENDIF() + +END() diff --git a/contrib/libs/base64/ssse3/codec_ssse3.c b/contrib/libs/base64/ssse3/codec_ssse3.c index acf4109e7a9..c8c9c72c3f4 100644 --- a/contrib/libs/base64/ssse3/codec_ssse3.c +++ b/contrib/libs/base64/ssse3/codec_ssse3.c @@ -1,168 +1,168 @@ -#include <stdint.h> -#include <stddef.h> -#include <stdlib.h> - -#include "libbase64.h" -#include "codecs.h" - -#ifdef __SSSE3__ -#include <tmmintrin.h> - -#define CMPGT(s,n) _mm_cmpgt_epi8((s), _mm_set1_epi8(n)) -#define CMPEQ(s,n) _mm_cmpeq_epi8((s), _mm_set1_epi8(n)) -#define REPLACE(s,n) _mm_and_si128((s), _mm_set1_epi8(n)) -#define RANGE(s,a,b) _mm_andnot_si128(CMPGT((s), (b)), CMPGT((s), (a) - 1)) - -static inline __m128i -_mm_bswap_epi32 (const __m128i in) -{ - return _mm_shuffle_epi8(in, _mm_setr_epi8( - 3, 2, 1, 0, - 7, 6, 5, 4, - 11, 10, 9, 8, - 15, 14, 13, 12)); -} - -static inline __m128i -enc_reshuffle (__m128i in) -{ - // Slice into 32-bit chunks and operate on all chunks in parallel. - // All processing is done within the 32-bit chunk. First, shuffle: - // before: [eeeeeeff|ccdddddd|bbbbcccc|aaaaaabb] - // after: [00000000|aaaaaabb|bbbbcccc|ccdddddd] - in = _mm_shuffle_epi8(in, _mm_set_epi8( - -1, 9, 10, 11, - -1, 6, 7, 8, - -1, 3, 4, 5, - -1, 0, 1, 2)); - - // cd = [00000000|00000000|0000cccc|ccdddddd] - const __m128i cd = _mm_and_si128(in, _mm_set1_epi32(0x00000FFF)); - - // ab = [0000aaaa|aabbbbbb|00000000|00000000] - const __m128i ab = _mm_and_si128(_mm_slli_epi32(in, 4), _mm_set1_epi32(0x0FFF0000)); - - // merged = [0000aaaa|aabbbbbb|0000cccc|ccdddddd] - const __m128i merged = _mm_or_si128(ab, cd); - - // bd = [00000000|00bbbbbb|00000000|00dddddd] - const __m128i bd = _mm_and_si128(merged, _mm_set1_epi32(0x003F003F)); - - // ac = [00aaaaaa|00000000|00cccccc|00000000] - const __m128i ac = _mm_and_si128(_mm_slli_epi32(merged, 2), _mm_set1_epi32(0x3F003F00)); - - // indices = [00aaaaaa|00bbbbbb|00cccccc|00dddddd] - const __m128i indices = _mm_or_si128(ac, bd); - - // return = [00dddddd|00cccccc|00bbbbbb|00aaaaaa] - return _mm_bswap_epi32(indices); -} - -static inline __m128i -enc_translate (const __m128i in) -{ - // Translate values 0..63 to the Base64 alphabet. There are five sets: - // # From To Abs Delta Characters - // 0 [0..25] [65..90] +65 +65 ABCDEFGHIJKLMNOPQRSTUVWXYZ - // 1 [26..51] [97..122] +71 +6 abcdefghijklmnopqrstuvwxyz - // 2 [52..61] [48..57] -4 -75 0123456789 - // 3 [62] [43] -19 -15 + - // 4 [63] [47] -16 +3 / - - // Create cumulative masks for characters in sets [1,2,3,4], [2,3,4], - // [3,4], and [4]: - const __m128i mask1 = CMPGT(in, 25); - const __m128i mask2 = CMPGT(in, 51); - const __m128i mask3 = CMPGT(in, 61); - const __m128i mask4 = CMPEQ(in, 63); - - // All characters are at least in cumulative set 0, so add 'A': - __m128i out = _mm_add_epi8(in, _mm_set1_epi8(65)); - - // For inputs which are also in any of the other cumulative sets, - // add delta values against the previous set(s) to correct the shift: - out = _mm_add_epi8(out, REPLACE(mask1, 6)); - out = _mm_sub_epi8(out, REPLACE(mask2, 75)); - out = _mm_sub_epi8(out, REPLACE(mask3, 15)); - out = _mm_add_epi8(out, REPLACE(mask4, 3)); - - return out; -} - -static inline __m128i -dec_reshuffle (__m128i in) -{ - // Shuffle bytes to 32-bit bigendian: - in = _mm_bswap_epi32(in); - - // Mask in a single byte per shift: - __m128i mask = _mm_set1_epi32(0x3F000000); - - // Pack bytes together: - __m128i out = _mm_slli_epi32(_mm_and_si128(in, mask), 2); - mask = _mm_srli_epi32(mask, 8); - - out = _mm_or_si128(out, _mm_slli_epi32(_mm_and_si128(in, mask), 4)); - mask = _mm_srli_epi32(mask, 8); - - out = _mm_or_si128(out, _mm_slli_epi32(_mm_and_si128(in, mask), 6)); - mask = _mm_srli_epi32(mask, 8); - - out = _mm_or_si128(out, _mm_slli_epi32(_mm_and_si128(in, mask), 8)); - - // Reshuffle and repack into 12-byte output format: - return _mm_shuffle_epi8(out, _mm_setr_epi8( - 3, 2, 1, - 7, 6, 5, - 11, 10, 9, - 15, 14, 13, - -1, -1, -1, -1)); -} - -#endif // __SSSE3__ - -void -ssse3_base64_stream_encode - ( struct ssse3_base64_state *state - , const char *src - , size_t srclen - , char *out - , size_t *outlen - ) -{ -#ifdef __SSSE3__ - #include "enc_head.c" - #include "enc_ssse3.c" - #include "enc_tail.c" -#else - (void)state; - (void)src; - (void)srclen; - (void)out; - (void)outlen; - abort(); -#endif -} - -int -ssse3_base64_stream_decode - ( struct ssse3_base64_state *state - , const char *src - , size_t srclen - , char *out - , size_t *outlen - ) -{ -#ifdef __SSSE3__ - #include "dec_head.c" - #include "dec_ssse3.c" - #include "dec_tail.c" -#else - (void)state; - (void)src; - (void)srclen; - (void)out; - (void)outlen; - abort(); -#endif -} +#include <stdint.h> +#include <stddef.h> +#include <stdlib.h> + +#include "libbase64.h" +#include "codecs.h" + +#ifdef __SSSE3__ +#include <tmmintrin.h> + +#define CMPGT(s,n) _mm_cmpgt_epi8((s), _mm_set1_epi8(n)) +#define CMPEQ(s,n) _mm_cmpeq_epi8((s), _mm_set1_epi8(n)) +#define REPLACE(s,n) _mm_and_si128((s), _mm_set1_epi8(n)) +#define RANGE(s,a,b) _mm_andnot_si128(CMPGT((s), (b)), CMPGT((s), (a) - 1)) + +static inline __m128i +_mm_bswap_epi32 (const __m128i in) +{ + return _mm_shuffle_epi8(in, _mm_setr_epi8( + 3, 2, 1, 0, + 7, 6, 5, 4, + 11, 10, 9, 8, + 15, 14, 13, 12)); +} + +static inline __m128i +enc_reshuffle (__m128i in) +{ + // Slice into 32-bit chunks and operate on all chunks in parallel. + // All processing is done within the 32-bit chunk. First, shuffle: + // before: [eeeeeeff|ccdddddd|bbbbcccc|aaaaaabb] + // after: [00000000|aaaaaabb|bbbbcccc|ccdddddd] + in = _mm_shuffle_epi8(in, _mm_set_epi8( + -1, 9, 10, 11, + -1, 6, 7, 8, + -1, 3, 4, 5, + -1, 0, 1, 2)); + + // cd = [00000000|00000000|0000cccc|ccdddddd] + const __m128i cd = _mm_and_si128(in, _mm_set1_epi32(0x00000FFF)); + + // ab = [0000aaaa|aabbbbbb|00000000|00000000] + const __m128i ab = _mm_and_si128(_mm_slli_epi32(in, 4), _mm_set1_epi32(0x0FFF0000)); + + // merged = [0000aaaa|aabbbbbb|0000cccc|ccdddddd] + const __m128i merged = _mm_or_si128(ab, cd); + + // bd = [00000000|00bbbbbb|00000000|00dddddd] + const __m128i bd = _mm_and_si128(merged, _mm_set1_epi32(0x003F003F)); + + // ac = [00aaaaaa|00000000|00cccccc|00000000] + const __m128i ac = _mm_and_si128(_mm_slli_epi32(merged, 2), _mm_set1_epi32(0x3F003F00)); + + // indices = [00aaaaaa|00bbbbbb|00cccccc|00dddddd] + const __m128i indices = _mm_or_si128(ac, bd); + + // return = [00dddddd|00cccccc|00bbbbbb|00aaaaaa] + return _mm_bswap_epi32(indices); +} + +static inline __m128i +enc_translate (const __m128i in) +{ + // Translate values 0..63 to the Base64 alphabet. There are five sets: + // # From To Abs Delta Characters + // 0 [0..25] [65..90] +65 +65 ABCDEFGHIJKLMNOPQRSTUVWXYZ + // 1 [26..51] [97..122] +71 +6 abcdefghijklmnopqrstuvwxyz + // 2 [52..61] [48..57] -4 -75 0123456789 + // 3 [62] [43] -19 -15 + + // 4 [63] [47] -16 +3 / + + // Create cumulative masks for characters in sets [1,2,3,4], [2,3,4], + // [3,4], and [4]: + const __m128i mask1 = CMPGT(in, 25); + const __m128i mask2 = CMPGT(in, 51); + const __m128i mask3 = CMPGT(in, 61); + const __m128i mask4 = CMPEQ(in, 63); + + // All characters are at least in cumulative set 0, so add 'A': + __m128i out = _mm_add_epi8(in, _mm_set1_epi8(65)); + + // For inputs which are also in any of the other cumulative sets, + // add delta values against the previous set(s) to correct the shift: + out = _mm_add_epi8(out, REPLACE(mask1, 6)); + out = _mm_sub_epi8(out, REPLACE(mask2, 75)); + out = _mm_sub_epi8(out, REPLACE(mask3, 15)); + out = _mm_add_epi8(out, REPLACE(mask4, 3)); + + return out; +} + +static inline __m128i +dec_reshuffle (__m128i in) +{ + // Shuffle bytes to 32-bit bigendian: + in = _mm_bswap_epi32(in); + + // Mask in a single byte per shift: + __m128i mask = _mm_set1_epi32(0x3F000000); + + // Pack bytes together: + __m128i out = _mm_slli_epi32(_mm_and_si128(in, mask), 2); + mask = _mm_srli_epi32(mask, 8); + + out = _mm_or_si128(out, _mm_slli_epi32(_mm_and_si128(in, mask), 4)); + mask = _mm_srli_epi32(mask, 8); + + out = _mm_or_si128(out, _mm_slli_epi32(_mm_and_si128(in, mask), 6)); + mask = _mm_srli_epi32(mask, 8); + + out = _mm_or_si128(out, _mm_slli_epi32(_mm_and_si128(in, mask), 8)); + + // Reshuffle and repack into 12-byte output format: + return _mm_shuffle_epi8(out, _mm_setr_epi8( + 3, 2, 1, + 7, 6, 5, + 11, 10, 9, + 15, 14, 13, + -1, -1, -1, -1)); +} + +#endif // __SSSE3__ + +void +ssse3_base64_stream_encode + ( struct ssse3_base64_state *state + , const char *src + , size_t srclen + , char *out + , size_t *outlen + ) +{ +#ifdef __SSSE3__ + #include "enc_head.c" + #include "enc_ssse3.c" + #include "enc_tail.c" +#else + (void)state; + (void)src; + (void)srclen; + (void)out; + (void)outlen; + abort(); +#endif +} + +int +ssse3_base64_stream_decode + ( struct ssse3_base64_state *state + , const char *src + , size_t srclen + , char *out + , size_t *outlen + ) +{ +#ifdef __SSSE3__ + #include "dec_head.c" + #include "dec_ssse3.c" + #include "dec_tail.c" +#else + (void)state; + (void)src; + (void)srclen; + (void)out; + (void)outlen; + abort(); +#endif +} diff --git a/contrib/libs/base64/ssse3/codecs.h b/contrib/libs/base64/ssse3/codecs.h index 7b1afac872c..dcf91c2a602 100644 --- a/contrib/libs/base64/ssse3/codecs.h +++ b/contrib/libs/base64/ssse3/codecs.h @@ -1,35 +1,35 @@ -#pragma once - -// Define machine endianness. This is for GCC: -#if (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__) - #define BASE64_SSSE3_LITTLE_ENDIAN 1 -#else - #define BASE64_SSSE3_LITTLE_ENDIAN 0 -#endif - -// This is for Clang: -#ifdef __LITTLE_ENDIAN__ - #define BASE64_SSSE3_LITTLE_ENDIAN 1 -#endif - -#ifdef __BIG_ENDIAN__ - #define BASE64_SSSE3_LITTLE_ENDIAN 0 -#endif - -// Endian conversion functions -#if BASE64_SSSE3_LITTLE_ENDIAN - #define cpu_to_be32(x) __builtin_bswap32(x) - #define cpu_to_be64(x) __builtin_bswap64(x) - #define be32_to_cpu(x) __builtin_bswap32(x) - #define be64_to_cpu(x) __builtin_bswap64(x) -#else - #define cpu_to_be32(x) (x) - #define cpu_to_be64(x) (x) - #define be32_to_cpu(x) (x) - #define be64_to_cpu(x) (x) -#endif - -// These tables are used by all codecs -// for fallback plain encoding/decoding: -extern const uint8_t ssse3_base64_table_enc[]; -extern const uint8_t ssse3_base64_table_dec[]; +#pragma once + +// Define machine endianness. This is for GCC: +#if (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__) + #define BASE64_SSSE3_LITTLE_ENDIAN 1 +#else + #define BASE64_SSSE3_LITTLE_ENDIAN 0 +#endif + +// This is for Clang: +#ifdef __LITTLE_ENDIAN__ + #define BASE64_SSSE3_LITTLE_ENDIAN 1 +#endif + +#ifdef __BIG_ENDIAN__ + #define BASE64_SSSE3_LITTLE_ENDIAN 0 +#endif + +// Endian conversion functions +#if BASE64_SSSE3_LITTLE_ENDIAN + #define cpu_to_be32(x) __builtin_bswap32(x) + #define cpu_to_be64(x) __builtin_bswap64(x) + #define be32_to_cpu(x) __builtin_bswap32(x) + #define be64_to_cpu(x) __builtin_bswap64(x) +#else + #define cpu_to_be32(x) (x) + #define cpu_to_be64(x) (x) + #define be32_to_cpu(x) (x) + #define be64_to_cpu(x) (x) +#endif + +// These tables are used by all codecs +// for fallback plain encoding/decoding: +extern const uint8_t ssse3_base64_table_enc[]; +extern const uint8_t ssse3_base64_table_dec[]; diff --git a/contrib/libs/base64/ssse3/dec_head.c b/contrib/libs/base64/ssse3/dec_head.c index aa77d52aa6e..cdb284fa395 100644 --- a/contrib/libs/base64/ssse3/dec_head.c +++ b/contrib/libs/base64/ssse3/dec_head.c @@ -1,29 +1,29 @@ -int ret = 0; -const uint8_t *c = (const uint8_t *)src; -uint8_t *o = (uint8_t *)out; -uint8_t q; - -// Use local temporaries to avoid cache thrashing: -size_t outl = 0; -struct ssse3_base64_state st; -st.eof = state->eof; -st.bytes = state->bytes; -st.carry = state->carry; - -// If we previously saw an EOF or an invalid character, bail out: -if (st.eof) { - *outlen = 0; - return 0; -} - -// Turn four 6-bit numbers into three bytes: -// out[0] = 11111122 -// out[1] = 22223333 -// out[2] = 33444444 - -// Duff's device again: -switch (st.bytes) -{ - for (;;) - { - case 0: +int ret = 0; +const uint8_t *c = (const uint8_t *)src; +uint8_t *o = (uint8_t *)out; +uint8_t q; + +// Use local temporaries to avoid cache thrashing: +size_t outl = 0; +struct ssse3_base64_state st; +st.eof = state->eof; +st.bytes = state->bytes; +st.carry = state->carry; + +// If we previously saw an EOF or an invalid character, bail out: +if (st.eof) { + *outlen = 0; + return 0; +} + +// Turn four 6-bit numbers into three bytes: +// out[0] = 11111122 +// out[1] = 22223333 +// out[2] = 33444444 + +// Duff's device again: +switch (st.bytes) +{ + for (;;) + { + case 0: diff --git a/contrib/libs/base64/ssse3/dec_ssse3.c b/contrib/libs/base64/ssse3/dec_ssse3.c index ce11b3cb1b2..cf2e2781a42 100644 --- a/contrib/libs/base64/ssse3/dec_ssse3.c +++ b/contrib/libs/base64/ssse3/dec_ssse3.c @@ -1,58 +1,58 @@ -// If we have SSSE3 support, pick off 16 bytes at a time for as long as we can, -// but make sure that we quit before seeing any == markers at the end of the -// string. Also, because we write four zeroes at the end of the output, ensure -// that there are at least 6 valid bytes of input data remaining to close the -// gap. 16 + 2 + 6 = 24 bytes: -while (srclen >= 24) -{ - // Load string: - __m128i str = _mm_loadu_si128((__m128i *)c); - - // The input consists of six character sets in the Base64 alphabet, - // which we need to map back to the 6-bit values they represent. - // There are three ranges, two singles, and then there's the rest. - // - // # From To Add Characters - // 1 [43] [62] +19 + - // 2 [47] [63] +16 / - // 3 [48..57] [52..61] +4 0..9 - // 4 [65..90] [0..25] -65 A..Z - // 5 [97..122] [26..51] -71 a..z - // (6) Everything else => invalid input - - const __m128i set1 = CMPEQ(str, '+'); - const __m128i set2 = CMPEQ(str, '/'); - const __m128i set3 = RANGE(str, '0', '9'); - const __m128i set4 = RANGE(str, 'A', 'Z'); - const __m128i set5 = RANGE(str, 'a', 'z'); - const __m128i set6 = CMPEQ(str, '-'); - const __m128i set7 = CMPEQ(str, '_'); - - __m128i delta = REPLACE(set1, 19); - delta = _mm_or_si128(delta, REPLACE(set2, 16)); - delta = _mm_or_si128(delta, REPLACE(set3, 4)); - delta = _mm_or_si128(delta, REPLACE(set4, -65)); - delta = _mm_or_si128(delta, REPLACE(set5, -71)); - delta = _mm_or_si128(delta, REPLACE(set6, 17)); - delta = _mm_or_si128(delta, REPLACE(set7, -32)); - - // Check for invalid input: if any of the delta values are zero, - // fall back on bytewise code to do error checking and reporting: - if (_mm_movemask_epi8(CMPEQ(delta, 0))) { - break; - } - - // Now simply add the delta values to the input: - str = _mm_add_epi8(str, delta); - - // Reshuffle the input to packed 12-byte output format: - str = dec_reshuffle(str); - - // Store back: - _mm_storeu_si128((__m128i *)o, str); - - c += 16; - o += 12; - outl += 12; - srclen -= 16; -} +// If we have SSSE3 support, pick off 16 bytes at a time for as long as we can, +// but make sure that we quit before seeing any == markers at the end of the +// string. Also, because we write four zeroes at the end of the output, ensure +// that there are at least 6 valid bytes of input data remaining to close the +// gap. 16 + 2 + 6 = 24 bytes: +while (srclen >= 24) +{ + // Load string: + __m128i str = _mm_loadu_si128((__m128i *)c); + + // The input consists of six character sets in the Base64 alphabet, + // which we need to map back to the 6-bit values they represent. + // There are three ranges, two singles, and then there's the rest. + // + // # From To Add Characters + // 1 [43] [62] +19 + + // 2 [47] [63] +16 / + // 3 [48..57] [52..61] +4 0..9 + // 4 [65..90] [0..25] -65 A..Z + // 5 [97..122] [26..51] -71 a..z + // (6) Everything else => invalid input + + const __m128i set1 = CMPEQ(str, '+'); + const __m128i set2 = CMPEQ(str, '/'); + const __m128i set3 = RANGE(str, '0', '9'); + const __m128i set4 = RANGE(str, 'A', 'Z'); + const __m128i set5 = RANGE(str, 'a', 'z'); + const __m128i set6 = CMPEQ(str, '-'); + const __m128i set7 = CMPEQ(str, '_'); + + __m128i delta = REPLACE(set1, 19); + delta = _mm_or_si128(delta, REPLACE(set2, 16)); + delta = _mm_or_si128(delta, REPLACE(set3, 4)); + delta = _mm_or_si128(delta, REPLACE(set4, -65)); + delta = _mm_or_si128(delta, REPLACE(set5, -71)); + delta = _mm_or_si128(delta, REPLACE(set6, 17)); + delta = _mm_or_si128(delta, REPLACE(set7, -32)); + + // Check for invalid input: if any of the delta values are zero, + // fall back on bytewise code to do error checking and reporting: + if (_mm_movemask_epi8(CMPEQ(delta, 0))) { + break; + } + + // Now simply add the delta values to the input: + str = _mm_add_epi8(str, delta); + + // Reshuffle the input to packed 12-byte output format: + str = dec_reshuffle(str); + + // Store back: + _mm_storeu_si128((__m128i *)o, str); + + c += 16; + o += 12; + outl += 12; + srclen -= 16; +} diff --git a/contrib/libs/base64/ssse3/dec_tail.c b/contrib/libs/base64/ssse3/dec_tail.c index 69e00507101..69b6f2c9d33 100644 --- a/contrib/libs/base64/ssse3/dec_tail.c +++ b/contrib/libs/base64/ssse3/dec_tail.c @@ -1,65 +1,65 @@ - if (srclen-- == 0) { - ret = 1; - break; - } - if ((q = ssse3_base64_table_dec[*c++]) >= 254) { - st.eof = 1; - // Treat character '=' as invalid for byte 0: - break; - } - st.carry = q << 2; - st.bytes++; - - case 1: if (srclen-- == 0) { - ret = 1; - break; - } - if ((q = ssse3_base64_table_dec[*c++]) >= 254) { - st.eof = 1; - // Treat character '=' as invalid for byte 1: - break; - } - *o++ = st.carry | (q >> 4); - st.carry = q << 4; - st.bytes++; - outl++; - - case 2: if (srclen-- == 0) { - ret = 1; - break; - } - if ((q = ssse3_base64_table_dec[*c++]) >= 254) { - st.eof = 1; - // When q == 254, the input char is '='. Return 1 and EOF. - // Technically, should check if next byte is also '=', but never mind. - // When q == 255, the input char is invalid. Return 0 and EOF. - ret = (q == 254) ? 1 : 0; - break; - } - *o++ = st.carry | (q >> 2); - st.carry = q << 6; - st.bytes++; - outl++; - - case 3: if (srclen-- == 0) { - ret = 1; - break; - } - if ((q = ssse3_base64_table_dec[*c++]) >= 254) { - st.eof = 1; - // When q == 254, the input char is '='. Return 1 and EOF. - // When q == 255, the input char is invalid. Return 0 and EOF. - ret = (q == 254) ? 1 : 0; - break; - } - *o++ = st.carry | q; - st.carry = 0; - st.bytes = 0; - outl++; - } -} -state->eof = st.eof; -state->bytes = st.bytes; -state->carry = st.carry; -*outlen = outl; -return ret; + if (srclen-- == 0) { + ret = 1; + break; + } + if ((q = ssse3_base64_table_dec[*c++]) >= 254) { + st.eof = 1; + // Treat character '=' as invalid for byte 0: + break; + } + st.carry = q << 2; + st.bytes++; + + case 1: if (srclen-- == 0) { + ret = 1; + break; + } + if ((q = ssse3_base64_table_dec[*c++]) >= 254) { + st.eof = 1; + // Treat character '=' as invalid for byte 1: + break; + } + *o++ = st.carry | (q >> 4); + st.carry = q << 4; + st.bytes++; + outl++; + + case 2: if (srclen-- == 0) { + ret = 1; + break; + } + if ((q = ssse3_base64_table_dec[*c++]) >= 254) { + st.eof = 1; + // When q == 254, the input char is '='. Return 1 and EOF. + // Technically, should check if next byte is also '=', but never mind. + // When q == 255, the input char is invalid. Return 0 and EOF. + ret = (q == 254) ? 1 : 0; + break; + } + *o++ = st.carry | (q >> 2); + st.carry = q << 6; + st.bytes++; + outl++; + + case 3: if (srclen-- == 0) { + ret = 1; + break; + } + if ((q = ssse3_base64_table_dec[*c++]) >= 254) { + st.eof = 1; + // When q == 254, the input char is '='. Return 1 and EOF. + // When q == 255, the input char is invalid. Return 0 and EOF. + ret = (q == 254) ? 1 : 0; + break; + } + *o++ = st.carry | q; + st.carry = 0; + st.bytes = 0; + outl++; + } +} +state->eof = st.eof; +state->bytes = st.bytes; +state->carry = st.carry; +*outlen = outl; +return ret; diff --git a/contrib/libs/base64/ssse3/enc_head.c b/contrib/libs/base64/ssse3/enc_head.c index b8ad582df53..fc6ba5347e3 100644 --- a/contrib/libs/base64/ssse3/enc_head.c +++ b/contrib/libs/base64/ssse3/enc_head.c @@ -1,23 +1,23 @@ -// Assume that *out is large enough to contain the output. -// Theoretically it should be 4/3 the length of src. -const uint8_t *c = (const uint8_t *)src; -uint8_t *o = (uint8_t *)out; - -// Use local temporaries to avoid cache thrashing: -size_t outl = 0; -struct ssse3_base64_state st; -st.bytes = state->bytes; -st.carry = state->carry; - -// Turn three bytes into four 6-bit numbers: -// in[0] = 00111111 -// in[1] = 00112222 -// in[2] = 00222233 -// in[3] = 00333333 - -// Duff's device, a for() loop inside a switch() statement. Legal! -switch (st.bytes) -{ - for (;;) - { - case 0: +// Assume that *out is large enough to contain the output. +// Theoretically it should be 4/3 the length of src. +const uint8_t *c = (const uint8_t *)src; +uint8_t *o = (uint8_t *)out; + +// Use local temporaries to avoid cache thrashing: +size_t outl = 0; +struct ssse3_base64_state st; +st.bytes = state->bytes; +st.carry = state->carry; + +// Turn three bytes into four 6-bit numbers: +// in[0] = 00111111 +// in[1] = 00112222 +// in[2] = 00222233 +// in[3] = 00333333 + +// Duff's device, a for() loop inside a switch() statement. Legal! +switch (st.bytes) +{ + for (;;) + { + case 0: diff --git a/contrib/libs/base64/ssse3/enc_ssse3.c b/contrib/libs/base64/ssse3/enc_ssse3.c index 0518595e618..e8903cf6c4f 100644 --- a/contrib/libs/base64/ssse3/enc_ssse3.c +++ b/contrib/libs/base64/ssse3/enc_ssse3.c @@ -1,22 +1,22 @@ -// If we have SSSE3 support, pick off 12 bytes at a time for as long as we can. -// But because we read 16 bytes at a time, ensure we have enough room to do a -// full 16-byte read without segfaulting: -while (srclen >= 16) -{ - // Load string: - __m128i str = _mm_loadu_si128((__m128i *)c); - - // Reshuffle: - str = enc_reshuffle(str); - - // Translate reshuffled bytes to the Base64 alphabet: - str = enc_translate(str); - - // Store: - _mm_storeu_si128((__m128i *)o, str); - - c += 12; // 3 * 4 bytes of input - o += 16; // 4 * 4 bytes of output - outl += 16; - srclen -= 12; -} +// If we have SSSE3 support, pick off 12 bytes at a time for as long as we can. +// But because we read 16 bytes at a time, ensure we have enough room to do a +// full 16-byte read without segfaulting: +while (srclen >= 16) +{ + // Load string: + __m128i str = _mm_loadu_si128((__m128i *)c); + + // Reshuffle: + str = enc_reshuffle(str); + + // Translate reshuffled bytes to the Base64 alphabet: + str = enc_translate(str); + + // Store: + _mm_storeu_si128((__m128i *)o, str); + + c += 12; // 3 * 4 bytes of input + o += 16; // 4 * 4 bytes of output + outl += 16; + srclen -= 12; +} diff --git a/contrib/libs/base64/ssse3/enc_tail.c b/contrib/libs/base64/ssse3/enc_tail.c index 69e0644af31..83815b5eec8 100644 --- a/contrib/libs/base64/ssse3/enc_tail.c +++ b/contrib/libs/base64/ssse3/enc_tail.c @@ -1,28 +1,28 @@ - if (srclen-- == 0) { - break; - } - *o++ = ssse3_base64_table_enc[*c >> 2]; - st.carry = (*c++ << 4) & 0x30; - st.bytes++; - outl += 1; - - case 1: if (srclen-- == 0) { - break; - } - *o++ = ssse3_base64_table_enc[st.carry | (*c >> 4)]; - st.carry = (*c++ << 2) & 0x3C; - st.bytes++; - outl += 1; - - case 2: if (srclen-- == 0) { - break; - } - *o++ = ssse3_base64_table_enc[st.carry | (*c >> 6)]; - *o++ = ssse3_base64_table_enc[*c++ & 0x3F]; - st.bytes = 0; - outl += 2; - } -} -state->bytes = st.bytes; -state->carry = st.carry; -*outlen = outl; + if (srclen-- == 0) { + break; + } + *o++ = ssse3_base64_table_enc[*c >> 2]; + st.carry = (*c++ << 4) & 0x30; + st.bytes++; + outl += 1; + + case 1: if (srclen-- == 0) { + break; + } + *o++ = ssse3_base64_table_enc[st.carry | (*c >> 4)]; + st.carry = (*c++ << 2) & 0x3C; + st.bytes++; + outl += 1; + + case 2: if (srclen-- == 0) { + break; + } + *o++ = ssse3_base64_table_enc[st.carry | (*c >> 6)]; + *o++ = ssse3_base64_table_enc[*c++ & 0x3F]; + st.bytes = 0; + outl += 2; + } +} +state->bytes = st.bytes; +state->carry = st.carry; +*outlen = outl; diff --git a/contrib/libs/base64/ssse3/lib.c b/contrib/libs/base64/ssse3/lib.c index d6f94c4df54..3c9cf99fc2a 100644 --- a/contrib/libs/base64/ssse3/lib.c +++ b/contrib/libs/base64/ssse3/lib.c @@ -1,121 +1,121 @@ -#include <stdint.h> -#include <stddef.h> - -#include "libbase64.h" -#include "codecs.h" - -const uint8_t -ssse3_base64_table_enc[] = - "ABCDEFGHIJKLMNOPQRSTUVWXYZ" - "abcdefghijklmnopqrstuvwxyz" - "0123456789+/"; - -// In the lookup table below, note that the value for '=' (character 61) is -// 254, not 255. This character is used for in-band signaling of the end of -// the datastream, and we will use that later. The characters A-Z, a-z, 0-9 -// and + / are mapped to their "decoded" values. The other bytes all map to -// the value 255, which flags them as "invalid input". - -const uint8_t -ssse3_base64_table_dec[] = -{ - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, // 0..15 - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, // 16..31 - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 62, 254, 62, 255, 63, // 32..47 - 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 255, 255, 255, 254, 255, 255, // 48..63 - 255, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, // 64..79 - 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 255, 255, 255, 255, 63, // 80..95 - 255, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, // 96..111 - 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 255, 255, 255, 255, 255, // 112..127 - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, // 128..143 - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, -}; - -void -ssse3_base64_stream_encode_init (struct ssse3_base64_state *state) -{ - state->eof = 0; - state->bytes = 0; - state->carry = 0; -} - -void -ssse3_base64_stream_encode_final - ( struct ssse3_base64_state *state - , char *out - , size_t *outlen - ) -{ - uint8_t *o = (uint8_t *)out; - - if (state->bytes == 1) { - *o++ = ssse3_base64_table_enc[state->carry]; - *o++ = '='; - *o++ = '='; - *outlen = 3; - return; - } - if (state->bytes == 2) { - *o++ = ssse3_base64_table_enc[state->carry]; - *o++ = '='; - *outlen = 2; - return; - } - *outlen = 0; -} - -void -ssse3_base64_stream_decode_init (struct ssse3_base64_state *state) -{ - state->eof = 0; - state->bytes = 0; - state->carry = 0; -} - -void -ssse3_base64_encode - ( const char *src - , size_t srclen - , char *out - , size_t *outlen - ) -{ - size_t s; - size_t t; - struct ssse3_base64_state state; - - // Init the stream reader: - ssse3_base64_stream_encode_init(&state); - - // Feed the whole string to the stream reader: - ssse3_base64_stream_encode(&state, src, srclen, out, &s); - - // Finalize the stream by writing trailer if any: - ssse3_base64_stream_encode_final(&state, out + s, &t); - - // Final output length is stream length plus tail: - *outlen = s + t; -} - -int -ssse3_base64_decode - ( const char *src - , size_t srclen - , char *out - , size_t *outlen - ) -{ - struct ssse3_base64_state state; - - // Init the stream reader: - ssse3_base64_stream_decode_init(&state); - - // Feed the whole string to the stream reader: - return ssse3_base64_stream_decode(&state, src, srclen, out, outlen); -} +#include <stdint.h> +#include <stddef.h> + +#include "libbase64.h" +#include "codecs.h" + +const uint8_t +ssse3_base64_table_enc[] = + "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + "abcdefghijklmnopqrstuvwxyz" + "0123456789+/"; + +// In the lookup table below, note that the value for '=' (character 61) is +// 254, not 255. This character is used for in-band signaling of the end of +// the datastream, and we will use that later. The characters A-Z, a-z, 0-9 +// and + / are mapped to their "decoded" values. The other bytes all map to +// the value 255, which flags them as "invalid input". + +const uint8_t +ssse3_base64_table_dec[] = +{ + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, // 0..15 + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, // 16..31 + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 62, 254, 62, 255, 63, // 32..47 + 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 255, 255, 255, 254, 255, 255, // 48..63 + 255, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, // 64..79 + 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 255, 255, 255, 255, 63, // 80..95 + 255, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, // 96..111 + 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 255, 255, 255, 255, 255, // 112..127 + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, // 128..143 + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, +}; + +void +ssse3_base64_stream_encode_init (struct ssse3_base64_state *state) +{ + state->eof = 0; + state->bytes = 0; + state->carry = 0; +} + +void +ssse3_base64_stream_encode_final + ( struct ssse3_base64_state *state + , char *out + , size_t *outlen + ) +{ + uint8_t *o = (uint8_t *)out; + + if (state->bytes == 1) { + *o++ = ssse3_base64_table_enc[state->carry]; + *o++ = '='; + *o++ = '='; + *outlen = 3; + return; + } + if (state->bytes == 2) { + *o++ = ssse3_base64_table_enc[state->carry]; + *o++ = '='; + *outlen = 2; + return; + } + *outlen = 0; +} + +void +ssse3_base64_stream_decode_init (struct ssse3_base64_state *state) +{ + state->eof = 0; + state->bytes = 0; + state->carry = 0; +} + +void +ssse3_base64_encode + ( const char *src + , size_t srclen + , char *out + , size_t *outlen + ) +{ + size_t s; + size_t t; + struct ssse3_base64_state state; + + // Init the stream reader: + ssse3_base64_stream_encode_init(&state); + + // Feed the whole string to the stream reader: + ssse3_base64_stream_encode(&state, src, srclen, out, &s); + + // Finalize the stream by writing trailer if any: + ssse3_base64_stream_encode_final(&state, out + s, &t); + + // Final output length is stream length plus tail: + *outlen = s + t; +} + +int +ssse3_base64_decode + ( const char *src + , size_t srclen + , char *out + , size_t *outlen + ) +{ + struct ssse3_base64_state state; + + // Init the stream reader: + ssse3_base64_stream_decode_init(&state); + + // Feed the whole string to the stream reader: + return ssse3_base64_stream_decode(&state, src, srclen, out, outlen); +} diff --git a/contrib/libs/base64/ssse3/libbase64.h b/contrib/libs/base64/ssse3/libbase64.h index 064ee7e658e..8f19564e479 100644 --- a/contrib/libs/base64/ssse3/libbase64.h +++ b/contrib/libs/base64/ssse3/libbase64.h @@ -1,89 +1,89 @@ -#pragma once - -#ifdef __cplusplus -extern "C" { -#endif - -struct ssse3_base64_state { - int eof; - int bytes; - unsigned char carry; -}; - -/* Wrapper function to encode a plain string of given length. Output is written - * to *out without trailing zero. Output length in bytes is written to *outlen. - * The buffer in `out` has been allocated by the caller and is at least 4/3 the - * size of the input. See above for `flags`; set to 0 for default operation: */ -void ssse3_base64_encode - ( const char *src - , size_t srclen - , char *out - , size_t *outlen - ) ; - -/* Call this before calling base64_stream_encode() to init the state. See above - * for `flags`; set to 0 for default operation: */ -void ssse3_base64_stream_encode_init - ( struct ssse3_base64_state *state - ) ; - -/* Encodes the block of data of given length at `src`, into the buffer at - * `out`. Caller is responsible for allocating a large enough out-buffer; it - * must be at least 4/3 the size of the in-buffer, but take some margin. Places - * the number of new bytes written into `outlen` (which is set to zero when the - * function starts). Does not zero-terminate or finalize the output. */ -void ssse3_base64_stream_encode - ( struct ssse3_base64_state *state - , const char *src - , size_t srclen - , char *out - , size_t *outlen - ) ; - -/* Finalizes the output begun by previous calls to `base64_stream_encode()`. - * Adds the required end-of-stream markers if appropriate. `outlen` is modified - * and will contain the number of new bytes written at `out` (which will quite - * often be zero). */ -void ssse3_base64_stream_encode_final - ( struct ssse3_base64_state *state - , char *out - , size_t *outlen - ) ; - -/* Wrapper function to decode a plain string of given length. Output is written - * to *out without trailing zero. Output length in bytes is written to *outlen. - * The buffer in `out` has been allocated by the caller and is at least 3/4 the - * size of the input. See above for `flags`, set to 0 for default operation: */ -int ssse3_base64_decode - ( const char *src - , size_t srclen - , char *out - , size_t *outlen - ) ; - -/* Call this before calling base64_stream_decode() to init the state. See above - * for `flags`; set to 0 for default operation: */ -void ssse3_base64_stream_decode_init - ( struct ssse3_base64_state *state - ) ; - -/* Decodes the block of data of given length at `src`, into the buffer at - * `out`. Caller is responsible for allocating a large enough out-buffer; it - * must be at least 3/4 the size of the in-buffer, but take some margin. Places - * the number of new bytes written into `outlen` (which is set to zero when the - * function starts). Does not zero-terminate the output. Returns 1 if all is - * well, and 0 if a decoding error was found, such as an invalid character. - * Returns -1 if the chosen codec is not included in the current build. Used by - * the test harness to check whether a codec is available for testing. */ -int ssse3_base64_stream_decode - ( struct ssse3_base64_state *state - , const char *src - , size_t srclen - , char *out - , size_t *outlen - ) ; - -#ifdef __cplusplus -} -#endif - +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +struct ssse3_base64_state { + int eof; + int bytes; + unsigned char carry; +}; + +/* Wrapper function to encode a plain string of given length. Output is written + * to *out without trailing zero. Output length in bytes is written to *outlen. + * The buffer in `out` has been allocated by the caller and is at least 4/3 the + * size of the input. See above for `flags`; set to 0 for default operation: */ +void ssse3_base64_encode + ( const char *src + , size_t srclen + , char *out + , size_t *outlen + ) ; + +/* Call this before calling base64_stream_encode() to init the state. See above + * for `flags`; set to 0 for default operation: */ +void ssse3_base64_stream_encode_init + ( struct ssse3_base64_state *state + ) ; + +/* Encodes the block of data of given length at `src`, into the buffer at + * `out`. Caller is responsible for allocating a large enough out-buffer; it + * must be at least 4/3 the size of the in-buffer, but take some margin. Places + * the number of new bytes written into `outlen` (which is set to zero when the + * function starts). Does not zero-terminate or finalize the output. */ +void ssse3_base64_stream_encode + ( struct ssse3_base64_state *state + , const char *src + , size_t srclen + , char *out + , size_t *outlen + ) ; + +/* Finalizes the output begun by previous calls to `base64_stream_encode()`. + * Adds the required end-of-stream markers if appropriate. `outlen` is modified + * and will contain the number of new bytes written at `out` (which will quite + * often be zero). */ +void ssse3_base64_stream_encode_final + ( struct ssse3_base64_state *state + , char *out + , size_t *outlen + ) ; + +/* Wrapper function to decode a plain string of given length. Output is written + * to *out without trailing zero. Output length in bytes is written to *outlen. + * The buffer in `out` has been allocated by the caller and is at least 3/4 the + * size of the input. See above for `flags`, set to 0 for default operation: */ +int ssse3_base64_decode + ( const char *src + , size_t srclen + , char *out + , size_t *outlen + ) ; + +/* Call this before calling base64_stream_decode() to init the state. See above + * for `flags`; set to 0 for default operation: */ +void ssse3_base64_stream_decode_init + ( struct ssse3_base64_state *state + ) ; + +/* Decodes the block of data of given length at `src`, into the buffer at + * `out`. Caller is responsible for allocating a large enough out-buffer; it + * must be at least 3/4 the size of the in-buffer, but take some margin. Places + * the number of new bytes written into `outlen` (which is set to zero when the + * function starts). Does not zero-terminate the output. Returns 1 if all is + * well, and 0 if a decoding error was found, such as an invalid character. + * Returns -1 if the chosen codec is not included in the current build. Used by + * the test harness to check whether a codec is available for testing. */ +int ssse3_base64_stream_decode + ( struct ssse3_base64_state *state + , const char *src + , size_t srclen + , char *out + , size_t *outlen + ) ; + +#ifdef __cplusplus +} +#endif + diff --git a/contrib/libs/base64/ssse3/ya.make b/contrib/libs/base64/ssse3/ya.make index c9cf6470015..5a3191c9f1e 100644 --- a/contrib/libs/base64/ssse3/ya.make +++ b/contrib/libs/base64/ssse3/ya.make @@ -1,11 +1,11 @@ -OWNER( - yazevnul +OWNER( + yazevnul g:contrib g:cpp-contrib -) - -LIBRARY() - +) + +LIBRARY() + LICENSE( BSD-2-Clause AND MIT @@ -13,14 +13,14 @@ LICENSE( LICENSE_TEXTS(.yandex_meta/licenses.list.txt) -NO_UTIL() - -SRCS( - codec_ssse3.c - lib.c -) - -IF (ARCH_X86_64 OR ARCH_I386) +NO_UTIL() + +SRCS( + codec_ssse3.c + lib.c +) + +IF (ARCH_X86_64 OR ARCH_I386) IF (MSVC AND NOT CLANG_CL) CONLYFLAGS(/D__SSSE3__=1) ELSEIF (CLANG_CL) @@ -30,7 +30,7 @@ IF (ARCH_X86_64 OR ARCH_I386) -mssse3 -std=c11 ) - ENDIF() -ENDIF() - -END() + ENDIF() +ENDIF() + +END() diff --git a/contrib/libs/base64/ya.make b/contrib/libs/base64/ya.make index 659983fe66a..f86ded70d98 100644 --- a/contrib/libs/base64/ya.make +++ b/contrib/libs/base64/ya.make @@ -1,16 +1,16 @@ -OWNER( - yazevnul +OWNER( + yazevnul g:contrib g:cpp-contrib -) - +) + VERSION(0.3.0) -RECURSE( - avx2 - ssse3 - neon32 - neon64 - plain32 - plain64 -) +RECURSE( + avx2 + ssse3 + neon32 + neon64 + plain32 + plain64 +) diff --git a/contrib/libs/cxxsupp/libcxx/include/iosfwd b/contrib/libs/cxxsupp/libcxx/include/iosfwd index 477dd97260f..b31529ce6e8 100644 --- a/contrib/libs/cxxsupp/libcxx/include/iosfwd +++ b/contrib/libs/cxxsupp/libcxx/include/iosfwd @@ -250,7 +250,7 @@ typedef basic_string<char, char_traits<char>, allocator<char> > string; #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS typedef basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> > wstring; #endif -typedef basic_string<char16_t, char_traits<char16_t>, allocator<char16_t> > u16string; +typedef basic_string<char16_t, char_traits<char16_t>, allocator<char16_t> > u16string; template <class _CharT, class _Traits, class _Allocator> class _LIBCPP_PREFERRED_NAME(string) _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wstring)) basic_string; diff --git a/contrib/libs/cxxsupp/libcxx/include/stlfwd b/contrib/libs/cxxsupp/libcxx/include/stlfwd index adad6790dcc..3913623f98e 100644 --- a/contrib/libs/cxxsupp/libcxx/include/stlfwd +++ b/contrib/libs/cxxsupp/libcxx/include/stlfwd @@ -1,13 +1,13 @@ #pragma once -#include <__config> +#include <__config> #include <cstddef> -#include <iosfwd> - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -#pragma GCC system_header -#endif +#include <iosfwd> +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + _LIBCPP_BEGIN_NAMESPACE_STD template <class F, class S> @@ -42,18 +42,18 @@ _LIBCPP_BEGIN_NAMESPACE_STD constexpr void get(...) = delete; - template <class> - class _LIBCPP_TEMPLATE_VIS function; - - template <class _Tp> - struct _LIBCPP_TEMPLATE_VIS default_delete; - - template <class _Tp, class Deleter = default_delete<_Tp>> - class _LIBCPP_TEMPLATE_VIS unique_ptr; - - template <class T> - class _LIBCPP_TEMPLATE_VIS shared_ptr; - + template <class> + class _LIBCPP_TEMPLATE_VIS function; + + template <class _Tp> + struct _LIBCPP_TEMPLATE_VIS default_delete; + + template <class _Tp, class Deleter = default_delete<_Tp>> + class _LIBCPP_TEMPLATE_VIS unique_ptr; + + template <class T> + class _LIBCPP_TEMPLATE_VIS shared_ptr; + /* basic_string is already forward-declared in <iosfwd> */ template<class T, class Traits> diff --git a/contrib/libs/farmhash/test.cc b/contrib/libs/farmhash/test.cc index 08d191ae7c3..5bbf3e7a1eb 100644 --- a/contrib/libs/farmhash/test.cc +++ b/contrib/libs/farmhash/test.cc @@ -9855,8 +9855,8 @@ int main(int argc, char** argv) { } #endif -Y_UNIT_TEST_SUITE(FarmhashTest) { - Y_UNIT_TEST(Test) { +Y_UNIT_TEST_SUITE(FarmhashTest) { + Y_UNIT_TEST(Test) { UNIT_ASSERT(farmhashccTest::RunTest() == 0); UNIT_ASSERT(farmhashmkTest::RunTest() == 0); UNIT_ASSERT(farmhashnaTest::RunTest() == 0); diff --git a/contrib/libs/flatbuffers/ya.make b/contrib/libs/flatbuffers/ya.make index 4af01ae72c0..e91b7ebda48 100644 --- a/contrib/libs/flatbuffers/ya.make +++ b/contrib/libs/flatbuffers/ya.make @@ -1,7 +1,7 @@ # Generated by devtools/yamaker from nixpkgs 28acaac96f0cc203c63a3d50634541feff7fc31c. -LIBRARY() - +LIBRARY() + OWNER( eeight kirillovs diff --git a/contrib/libs/libunwind/ut/libunwind_ut.cpp b/contrib/libs/libunwind/ut/libunwind_ut.cpp index 93767c50c87..3e199d42105 100644 --- a/contrib/libs/libunwind/ut/libunwind_ut.cpp +++ b/contrib/libs/libunwind/ut/libunwind_ut.cpp @@ -10,14 +10,14 @@ Y_NO_INLINE void Except(int arg, ...) { throw std::exception(); } -Y_UNIT_TEST_SUITE(LibunwindSuite) { +Y_UNIT_TEST_SUITE(LibunwindSuite) { static void Y_NO_INLINE DoTestVarargs() { std::vector<int> v; v.push_back(0); Except(0x11, 0x22, 0x33, 0x44, 0xAA, 0xBB, 0xCC, 0xDD); } - Y_UNIT_TEST(TestVarargs) { + Y_UNIT_TEST(TestVarargs) { try { DoTestVarargs(); } catch (const std::exception& e) { diff --git a/contrib/libs/pire/pire/encoding.cpp b/contrib/libs/pire/pire/encoding.cpp index 842e2b534dd..9707c10d54d 100644 --- a/contrib/libs/pire/pire/encoding.cpp +++ b/contrib/libs/pire/pire/encoding.cpp @@ -95,7 +95,7 @@ namespace { size_t len; unsigned char* p = (unsigned char*) &*ret.begin(); if (SafeWriteUTF8Char(c, len, p, p + ret.size()) != RECODE_OK) - Y_ASSERT(!"Pire::UTF8::toLocal(): Internal error"); + Y_ASSERT(!"Pire::UTF8::toLocal(): Internal error"); return ret; } diff --git a/contrib/libs/pire/pire/extra/count.cpp b/contrib/libs/pire/pire/extra/count.cpp index 468ff61d924..5285aed998c 100644 --- a/contrib/libs/pire/pire/extra/count.cpp +++ b/contrib/libs/pire/pire/extra/count.cpp @@ -796,9 +796,9 @@ CountingScanner::CountingScanner(const Fsm& re, const Fsm& sep) const Fsm::StatesSet& br = sep_re.Destinations(states[curstate].second, letter); if (mr.size() != 1) - Y_ASSERT(!"Wrong transition size for main"); + Y_ASSERT(!"Wrong transition size for main"); if (br.size() != 1) - Y_ASSERT(!"Wrong transition size for backup"); + Y_ASSERT(!"Wrong transition size for backup"); NewState ns(*mr.begin(), *br.begin()); PIRE_IFDEBUG(NewState savedNs = ns); diff --git a/contrib/libs/pire/pire/fsm.cpp b/contrib/libs/pire/pire/fsm.cpp index 984d708dfab..5df0c7ec4ba 100644 --- a/contrib/libs/pire/pire/fsm.cpp +++ b/contrib/libs/pire/pire/fsm.cpp @@ -80,7 +80,7 @@ void Fsm::DumpState(yostream& s, size_t state) const for (auto&& transitionState : transition.second) { if (transitionState >= Size()) { std::cerr << "WTF?! Transition from " << state << " on letter " << transition.first << " leads to non-existing state " << transitionState << "\n"; - Y_ASSERT(false); + Y_ASSERT(false); } if (Letters().Contains(transition.first)) { const TVector<Char>& letters = Letters().Klass(Letters().Representative(transition.first)); @@ -977,7 +977,7 @@ public: void Connect(size_t from, size_t to, Char letter) { PIRE_IFDEBUG(Cdbg << "Connecting " << from << " --" << letter << "--> " << to << Endl); - Y_ASSERT(mNewTerminals.find(from) == mNewTerminals.end()); + Y_ASSERT(mNewTerminals.find(from) == mNewTerminals.end()); mNewFsm.Connect(from, to, letter); } typedef bool Result; diff --git a/contrib/libs/pire/pire/partition.h b/contrib/libs/pire/pire/partition.h index 85a9af88635..39a26b53e4f 100644 --- a/contrib/libs/pire/pire/partition.h +++ b/contrib/libs/pire/pire/partition.h @@ -98,7 +98,7 @@ public: if (it == m_inv.end()) throw Error("Partition::index(): attempted to obtain an index of nonexistent item"); auto it2 = m_set.find(it->second); - Y_ASSERT(it2 != m_set.end()); + Y_ASSERT(it2 != m_set.end()); return it2->second.first; } /// Returns the whole equivalence class of @p t (i.e. item @p i @@ -109,7 +109,7 @@ public: if (it == m_inv.end()) throw Error("Partition::index(): attempted to obtain an index of nonexistent item"); auto it2 = m_set.find(it->second); - Y_ASSERT(it2 != m_set.end()); + Y_ASSERT(it2 != m_set.end()); return it2->second.second; } diff --git a/contrib/libs/pire/pire/run.h b/contrib/libs/pire/pire/run.h index f6e1ff734d4..75959379ed4 100644 --- a/contrib/libs/pire/pire/run.h +++ b/contrib/libs/pire/pire/run.h @@ -54,7 +54,7 @@ template<class Scanner> PIRE_FORCED_INLINE PIRE_HOT_FUNCTION void Step(const Scanner& scanner, typename Scanner::State& state, Char ch) { - Y_ASSERT(ch < MaxCharUnaligned); + Y_ASSERT(ch < MaxCharUnaligned); typename Scanner::Action a = scanner.Next(state, ch); scanner.TakeAction(state, a); } @@ -112,9 +112,9 @@ namespace Impl { PIRE_FORCED_INLINE PIRE_HOT_FUNCTION Action SafeRunChunk(const Scanner& scanner, typename Scanner::State& state, const size_t* p, size_t pos, size_t size, Pred pred) { - Y_ASSERT(pos <= sizeof(size_t)); - Y_ASSERT(size <= sizeof(size_t)); - Y_ASSERT(pos + size <= sizeof(size_t)); + Y_ASSERT(pos <= sizeof(size_t)); + Y_ASSERT(size <= sizeof(size_t)); + Y_ASSERT(pos + size <= sizeof(size_t)); if (PIRE_UNLIKELY(size == 0)) return Continue; @@ -133,9 +133,9 @@ namespace Impl { PIRE_FORCED_INLINE PIRE_HOT_FUNCTION Action RunChunk(const Scanner& scanner, typename Scanner::State& state, const size_t* p, size_t pos, size_t size, Pred pred) { - Y_ASSERT(pos <= sizeof(size_t)); - Y_ASSERT(size <= sizeof(size_t)); - Y_ASSERT(pos + size <= sizeof(size_t)); + Y_ASSERT(pos <= sizeof(size_t)); + Y_ASSERT(size <= sizeof(size_t)); + Y_ASSERT(pos + size <= sizeof(size_t)); if (PIRE_UNLIKELY(size == 0)) return Continue; diff --git a/contrib/libs/pire/pire/scanner_io.cpp b/contrib/libs/pire/pire/scanner_io.cpp index 3956e3c6edb..4fd5e9792c7 100644 --- a/contrib/libs/pire/pire/scanner_io.cpp +++ b/contrib/libs/pire/pire/scanner_io.cpp @@ -43,7 +43,7 @@ void SimpleScanner::Save(yostream* s) const SavePodType(s, Empty()); Impl::AlignSave(s, sizeof(Empty())); if (!Empty()) { - Y_ASSERT(m_buffer); + Y_ASSERT(m_buffer); Impl::AlignedSaveArray(s, m_buffer.Get(), BufSize()); } } @@ -77,7 +77,7 @@ void SlowScanner::Save(yostream* s) const SavePodType(s, Empty()); Impl::AlignSave(s, sizeof(Empty())); if (!Empty()) { - Y_ASSERT(!m_vec.empty()); + Y_ASSERT(!m_vec.empty()); Impl::AlignedSaveArray(s, m_letters, MaxChar); Impl::AlignedSaveArray(s, m_finals, m.statesCount); diff --git a/contrib/libs/pire/pire/scanners/loaded.h b/contrib/libs/pire/pire/scanners/loaded.h index 120dc403b75..4d72d783a94 100644 --- a/contrib/libs/pire/pire/scanners/loaded.h +++ b/contrib/libs/pire/pire/scanners/loaded.h @@ -188,9 +188,9 @@ public: void SetJump(size_t oldState, Char c, size_t newState, Action action) { - Y_ASSERT(m_buffer); - Y_ASSERT(oldState < m.statesCount); - Y_ASSERT(newState < m.statesCount); + Y_ASSERT(m_buffer); + Y_ASSERT(oldState < m.statesCount); + Y_ASSERT(newState < m.statesCount); size_t shift = (newState - oldState) * StateSize(); Transition tr; @@ -201,8 +201,8 @@ public: Action RemapAction(Action action) { return action; } - void SetInitial(size_t state) { Y_ASSERT(m_buffer); m.initial = reinterpret_cast<size_t>(m_jumps + state * m.lettersCount); } - void SetTag(size_t state, Tag tag) { Y_ASSERT(m_buffer); m_tags[state] = tag; } + void SetInitial(size_t state) { Y_ASSERT(m_buffer); m.initial = reinterpret_cast<size_t>(m_jumps + state * m.lettersCount); } + void SetTag(size_t state, Tag tag) { Y_ASSERT(m_buffer); m_tags[state] = tag; } void FinishBuild() {} size_t StateIdx(InternalState s) const diff --git a/contrib/libs/pire/pire/scanners/multi.h b/contrib/libs/pire/pire/scanners/multi.h index 29679e416ed..52b97aadc10 100644 --- a/contrib/libs/pire/pire/scanners/multi.h +++ b/contrib/libs/pire/pire/scanners/multi.h @@ -170,17 +170,17 @@ public: Action NextTranslated(State& state, Char letter) const { PIRE_IFDEBUG( - Y_ASSERT(state >= (size_t)m_transitions); - Y_ASSERT(state < (size_t)(m_transitions + RowSize()*Size())); - Y_ASSERT((state - (size_t)m_transitions) % (RowSize()*sizeof(Transition)) == 0); + Y_ASSERT(state >= (size_t)m_transitions); + Y_ASSERT(state < (size_t)(m_transitions + RowSize()*Size())); + Y_ASSERT((state - (size_t)m_transitions) % (RowSize()*sizeof(Transition)) == 0); ); state = Relocation::Go(state, reinterpret_cast<const Transition*>(state)[letter]); PIRE_IFDEBUG( - Y_ASSERT(state >= (size_t)m_transitions); - Y_ASSERT(state < (size_t)(m_transitions + RowSize()*Size())); - Y_ASSERT((state - (size_t)m_transitions) % (RowSize()*sizeof(Transition)) == 0); + Y_ASSERT(state >= (size_t)m_transitions); + Y_ASSERT(state < (size_t)(m_transitions + RowSize()*Size())); + Y_ASSERT((state - (size_t)m_transitions) % (RowSize()*sizeof(Transition)) == 0); ); return 0; @@ -222,8 +222,8 @@ public: void Swap(Scanner& s) { - Y_ASSERT(m.relocationSignature == s.m.relocationSignature); - Y_ASSERT(m.shortcuttingSignature == s.m.shortcuttingSignature); + Y_ASSERT(m.relocationSignature == s.m.relocationSignature); + Y_ASSERT(m.shortcuttingSignature == s.m.shortcuttingSignature); DoSwap(m_buffer, s.m_buffer); DoSwap(m.statesCount, s.m.statesCount); DoSwap(m.lettersCount, s.m.lettersCount); @@ -413,8 +413,8 @@ protected: // Values in letter-to-leterclass table take into account row header size for (size_t c = 0; c < MaxChar; ++c) { m_letters[c] = s.m_letters[c] - s.HEADER_SIZE + HEADER_SIZE; - Y_ASSERT(c == Epsilon || m_letters[c] >= HEADER_SIZE); - Y_ASSERT(c == Epsilon || m_letters[c] < RowSize()); + Y_ASSERT(c == Epsilon || m_letters[c] >= HEADER_SIZE); + Y_ASSERT(c == Epsilon || m_letters[c] < RowSize()); } memcpy(m_final, s.m_final, m.finalTableSize * sizeof(*m_final)); memcpy(m_finalIndex, s.m_finalIndex, m.statesCount * sizeof(*m_finalIndex)); @@ -433,8 +433,8 @@ protected: size_t destIndex = s.StateIndex(AnotherRelocation::Go(oldstate, os[let + s.HEADER_SIZE])); Transition tr = Relocation::Diff(newstate, IndexToState(destIndex)); ns[let + HEADER_SIZE] = tr; - Y_ASSERT(Relocation::Go(newstate, tr) >= (size_t)m_transitions); - Y_ASSERT(Relocation::Go(newstate, tr) < (size_t)(m_transitions + RowSize()*Size())); + Y_ASSERT(Relocation::Go(newstate, tr) >= (size_t)m_transitions); + Y_ASSERT(Relocation::Go(newstate, tr) < (size_t)(m_transitions + RowSize()*Size())); } } } @@ -447,9 +447,9 @@ protected: void SetJump(size_t oldState, Char c, size_t newState, unsigned long /*payload*/ = 0) { - Y_ASSERT(m_buffer); - Y_ASSERT(oldState < m.statesCount); - Y_ASSERT(newState < m.statesCount); + Y_ASSERT(m_buffer); + Y_ASSERT(oldState < m.statesCount); + Y_ASSERT(newState < m.statesCount); m_transitions[oldState * RowSize() + m_letters[c]] = Relocation::Diff(IndexToState(oldState), IndexToState(newState)); @@ -459,20 +459,20 @@ protected: void SetInitial(size_t state) { - Y_ASSERT(m_buffer); + Y_ASSERT(m_buffer); m.initial = IndexToState(state); } void SetTag(size_t state, size_t value) { - Y_ASSERT(m_buffer); + Y_ASSERT(m_buffer); Header(IndexToState(state)).Common.Flags = value; } // Fill shortcut masks for all the states void BuildShortcuts() { - Y_ASSERT(m_buffer); + Y_ASSERT(m_buffer); // Build the mapping from letter classes to characters TVector< TVector<char> > letters(RowSize()); @@ -512,7 +512,7 @@ protected: // Fills final states table and builds shortcuts if possible void FinishBuild() { - Y_ASSERT(m_buffer); + Y_ASSERT(m_buffer); auto finalWriter = m_final; for (size_t state = 0; state != Size(); ++state) { m_finalIndex[state] = finalWriter - m_final; @@ -710,17 +710,17 @@ public: inline const Word& Mask(size_t i, size_t alignOffset) const { - Y_ASSERT(i < ExitMaskCount); - Y_ASSERT(alignOffset < SizeTInMaxSizeWord); + Y_ASSERT(i < ExitMaskCount); + Y_ASSERT(alignOffset < SizeTInMaxSizeWord); const Word* p = (const Word*)(ExitMasksArray + alignOffset + MaskSizeInSizeT * i); - Y_ASSERT(IsAligned(p, sizeof(Word))); + Y_ASSERT(IsAligned(p, sizeof(Word))); return *p; } PIRE_FORCED_INLINE PIRE_HOT_FUNCTION size_t Mask(size_t i) const { - Y_ASSERT(i < ExitMaskCount); + Y_ASSERT(i < ExitMaskCount); return ExitMasksArray[MaskSizeInSizeT*i]; } @@ -922,7 +922,7 @@ private: typename ScannerType::State stateBefore = st; for (const char* pos = begin; pos != end; ++pos) { Step(scanner, st, (unsigned char)*pos); - Y_ASSERT(st == stateBefore); + Y_ASSERT(st == stateBefore); } } @@ -951,7 +951,7 @@ public: } // Row size should be a multiple of MaxSizeWord size. Then alignOffset is the same for any state - Y_ASSERT((scanner.RowSize()*sizeof(typename ScannerType::Transition)) % sizeof(MaxSizeWord) == 0); + Y_ASSERT((scanner.RowSize()*sizeof(typename ScannerType::Transition)) % sizeof(MaxSizeWord) == 0); size_t alignOffset = (AlignUp((size_t)scanner.m_transitions, sizeof(Word)) - (size_t)scanner.m_transitions) / sizeof(size_t); bool noShortcut = Shortcutting::NoShortcut(scanner, state); diff --git a/contrib/libs/pire/pire/scanners/simple.h b/contrib/libs/pire/pire/scanners/simple.h index ef959aeed13..d70e699f15c 100644 --- a/contrib/libs/pire/pire/scanners/simple.h +++ b/contrib/libs/pire/pire/scanners/simple.h @@ -207,9 +207,9 @@ protected: void SetJump(size_t oldState, Char c, size_t newState) { - Y_ASSERT(m_buffer); - Y_ASSERT(oldState < m.statesCount); - Y_ASSERT(newState < m.statesCount); + Y_ASSERT(m_buffer); + Y_ASSERT(oldState < m.statesCount); + Y_ASSERT(newState < m.statesCount); m_transitions[oldState * STATE_ROW_SIZE + 1 + c] = (((newState - oldState) * STATE_ROW_SIZE) * sizeof(Transition)); } @@ -218,13 +218,13 @@ protected: void SetInitial(size_t state) { - Y_ASSERT(m_buffer); + Y_ASSERT(m_buffer); m.initial = reinterpret_cast<size_t>(m_transitions + state * STATE_ROW_SIZE + 1); } void SetTag(size_t state, size_t tag) { - Y_ASSERT(m_buffer); + Y_ASSERT(m_buffer); m_transitions[state * STATE_ROW_SIZE] = tag; } diff --git a/contrib/libs/pire/pire/scanners/slow.h b/contrib/libs/pire/pire/scanners/slow.h index 6adfcb8c1d0..dceb1ac65b7 100644 --- a/contrib/libs/pire/pire/scanners/slow.h +++ b/contrib/libs/pire/pire/scanners/slow.h @@ -383,9 +383,9 @@ private: void SetJump(size_t oldState, Char c, size_t newState, unsigned long action) { - Y_ASSERT(!m_vec.empty()); - Y_ASSERT(oldState < m.statesCount); - Y_ASSERT(newState < m.statesCount); + Y_ASSERT(!m_vec.empty()); + Y_ASSERT(oldState < m.statesCount); + Y_ASSERT(newState < m.statesCount); size_t idx = oldState * m.lettersCount + m_letters[c]; m_vec[idx].push_back(newState); diff --git a/contrib/libs/pire/pire/stub/stl.h b/contrib/libs/pire/pire/stub/stl.h index 98ebd9f7c6f..0211c062779 100644 --- a/contrib/libs/pire/pire/stub/stl.h +++ b/contrib/libs/pire/pire/stub/stl.h @@ -56,8 +56,8 @@ namespace Pire { Error(const ystring& msg) { *this << msg; } }; - typedef IOutputStream yostream; - typedef IInputStream yistream; + typedef IOutputStream yostream; + typedef IInputStream yistream; template<class Iter> ystring Join(Iter begin, Iter end, const ystring& separator) { return JoinStrings(begin, end, separator); } diff --git a/contrib/libs/protobuf/src/google/protobuf/json_util.cc b/contrib/libs/protobuf/src/google/protobuf/json_util.cc index 450ce1da570..7264b06814a 100644 --- a/contrib/libs/protobuf/src/google/protobuf/json_util.cc +++ b/contrib/libs/protobuf/src/google/protobuf/json_util.cc @@ -4,7 +4,7 @@ namespace google { namespace protobuf { namespace io { -void PrintJSONString(IOutputStream& stream, const TProtoStringType& string) { +void PrintJSONString(IOutputStream& stream, const TProtoStringType& string) { stream << '"'; for (const char c: string) { switch(c) { diff --git a/contrib/libs/protobuf/src/google/protobuf/json_util.h b/contrib/libs/protobuf/src/google/protobuf/json_util.h index ad3a4a5bfe1..52a4a69a578 100644 --- a/contrib/libs/protobuf/src/google/protobuf/json_util.h +++ b/contrib/libs/protobuf/src/google/protobuf/json_util.h @@ -6,7 +6,7 @@ namespace google { namespace protobuf { namespace io { -void PrintJSONString(IOutputStream& stream, const TProtoStringType& string); +void PrintJSONString(IOutputStream& stream, const TProtoStringType& string); template<class T> struct TAsJSON { @@ -20,7 +20,7 @@ public: }; template<class T> -inline IOutputStream& operator <<(IOutputStream& stream, const TAsJSON<T>& protoAsJSON) { +inline IOutputStream& operator <<(IOutputStream& stream, const TAsJSON<T>& protoAsJSON) { protoAsJSON.T_.PrintJSON(stream); return stream; }; diff --git a/contrib/libs/protobuf/src/google/protobuf/message.h b/contrib/libs/protobuf/src/google/protobuf/message.h index 37d92ea3937..43c795471aa 100644 --- a/contrib/libs/protobuf/src/google/protobuf/message.h +++ b/contrib/libs/protobuf/src/google/protobuf/message.h @@ -344,7 +344,7 @@ class PROTOBUF_EXPORT Message : public MessageLite { bool SerializeToArcadiaStream(IOutputStream* output) const; bool SerializePartialToArcadiaStream(IOutputStream* output) const; - virtual void PrintJSON(IOutputStream&) const; + virtual void PrintJSON(IOutputStream&) const; io::TAsJSON<Message> AsJSON() const { return io::TAsJSON<Message>(*this); diff --git a/contrib/libs/protobuf/src/google/protobuf/messagext.cc b/contrib/libs/protobuf/src/google/protobuf/messagext.cc index 1923205598e..e4cfa141f10 100644 --- a/contrib/libs/protobuf/src/google/protobuf/messagext.cc +++ b/contrib/libs/protobuf/src/google/protobuf/messagext.cc @@ -101,7 +101,7 @@ bool TOutputStreamProxy::Write(const void* buffer, int size) { } -void TProtoSerializer::Save(IOutputStream* out, const Message& msg) { +void TProtoSerializer::Save(IOutputStream* out, const Message& msg) { int size = msg.ByteSize(); if (size > MaxSizeBytes) { ythrow yexception() << "Message size " << size << " exceeds " << MaxSizeBytes; @@ -113,11 +113,11 @@ void TProtoSerializer::Save(IOutputStream* out, const Message& msg) { ythrow yexception() << "Cannot write protobuf::Message to output stream"; } -// Reading varint32 directly from IInputStream (might be slow if input requires buffering). +// Reading varint32 directly from IInputStream (might be slow if input requires buffering). // Copy-pasted with small modifications from protobuf/io/coded_stream (ReadVarint32FromArray) // Returns true if succeeded, false if stream has ended, throws exception if data is corrupted -static bool ReadVarint32(IInputStream* input, ui32& size) { +static bool ReadVarint32(IInputStream* input, ui32& size) { size_t res; ui8 b; @@ -166,7 +166,7 @@ private: ui8* Buffer; }; -void TProtoSerializer::Load(IInputStream* input, Message& msg) { +void TProtoSerializer::Load(IInputStream* input, Message& msg) { msg.Clear(); MergeFrom(input, msg); } @@ -184,7 +184,7 @@ void TProtoSerializer::MergeFrom(IInputStream* input, Message& msg) { ythrow yexception() << "Cannot read protobuf::Message (" << msg.GetTypeName() << ") from input stream"; } -TProtoReader::TProtoReader(IInputStream* input, const size_t bufferSize) +TProtoReader::TProtoReader(IInputStream* input, const size_t bufferSize) : IStream(input) , Buffer(bufferSize) { diff --git a/contrib/libs/protobuf/src/google/protobuf/messagext.h b/contrib/libs/protobuf/src/google/protobuf/messagext.h index 9176cee1e8d..b9cb169187b 100644 --- a/contrib/libs/protobuf/src/google/protobuf/messagext.h +++ b/contrib/libs/protobuf/src/google/protobuf/messagext.h @@ -2,7 +2,7 @@ #include <google/protobuf/stubs/port.h> #include <google/protobuf/io/coded_stream.h> -#include <util/stream/output.h> +#include <util/stream/output.h> #include <util/generic/buffer.h> #include <google/protobuf/io/zero_copy_stream_impl.h> @@ -32,13 +32,13 @@ namespace io { /// Parse*Seq methods read message size from stream to find a message boundary -/// there is not parse from IInputStream, because it is not push-backable +/// there is not parse from IInputStream, because it is not push-backable bool ParseFromCodedStreamSeq(Message* msg, io::CodedInputStream* input); bool ParseFromZeroCopyStreamSeq(Message* msg, io::ZeroCopyInputStream* input); /// Serialize*Seq methods write message size as varint before writing a message -/// there is no serialize to IOutputStream, because it is not push-backable +/// there is no serialize to IOutputStream, because it is not push-backable bool SerializePartialToCodedStreamSeq(const Message* msg, io::CodedOutputStream* output); bool SerializeToCodedStreamSeq(const Message* msg, io::CodedOutputStream* output); @@ -62,7 +62,7 @@ private: class TInputStreamProxy: public io::CopyingInputStream, public TErrorState { public: - inline TInputStreamProxy(IInputStream* slave) + inline TInputStreamProxy(IInputStream* slave) : mSlave(slave) { } @@ -70,12 +70,12 @@ class TInputStreamProxy: public io::CopyingInputStream, public TErrorState { virtual int Read(void* buffer, int size); private: - IInputStream* mSlave; + IInputStream* mSlave; }; class TOutputStreamProxy: public io::CopyingOutputStream, public TErrorState { public: - inline TOutputStreamProxy(IOutputStream* slave) + inline TOutputStreamProxy(IOutputStream* slave) : mSlave(slave) { } @@ -83,13 +83,13 @@ class TOutputStreamProxy: public io::CopyingOutputStream, public TErrorState { virtual bool Write(const void* buffer, int size); private: - IOutputStream* mSlave; + IOutputStream* mSlave; }; class TCopyingInputStreamAdaptor: public TInputStreamProxy, public CopyingInputStreamAdaptor { public: - TCopyingInputStreamAdaptor(IInputStream* inputStream) + TCopyingInputStreamAdaptor(IInputStream* inputStream) : TInputStreamProxy(inputStream) , CopyingInputStreamAdaptor(this) { } @@ -97,7 +97,7 @@ public: class TCopyingOutputStreamAdaptor: public TOutputStreamProxy, public CopyingOutputStreamAdaptor { public: - TCopyingOutputStreamAdaptor(IOutputStream* outputStream) + TCopyingOutputStreamAdaptor(IOutputStream* outputStream) : TOutputStreamProxy(outputStream) , CopyingOutputStreamAdaptor(this) { } @@ -106,8 +106,8 @@ public: class TProtoSerializer { public: - static void Save(IOutputStream* output, const Message& msg); - static void Load(IInputStream* input, Message& msg); + static void Save(IOutputStream* output, const Message& msg); + static void Load(IInputStream* input, Message& msg); static void MergeFrom(IInputStream* input, Message& msg); // similar interface for protobuf coded streams @@ -130,7 +130,7 @@ public: */ class TProtoReader { public: - TProtoReader(IInputStream* input, const size_t bufferSize = DefaultBufferSize); + TProtoReader(IInputStream* input, const size_t bufferSize = DefaultBufferSize); /** * Reads protobuf message @@ -143,7 +143,7 @@ public: bool Load(Message& msg); private: - IInputStream* IStream; + IInputStream* IStream; TBuffer Buffer; static const size_t DefaultBufferSize = (1 << 16); @@ -154,11 +154,11 @@ private: } // namespace google // arcadia-style serialization -inline void Save(IOutputStream* output, const google::protobuf::Message& msg) { +inline void Save(IOutputStream* output, const google::protobuf::Message& msg) { google::protobuf::io::TProtoSerializer::Save(output, msg); } -inline void Load(IInputStream* input, google::protobuf::Message& msg) { +inline void Load(IInputStream* input, google::protobuf::Message& msg) { google::protobuf::io::TProtoSerializer::Load(input, msg); } diff --git a/contrib/libs/ya.make b/contrib/libs/ya.make index 9c4640fdcf2..7006034df70 100644 --- a/contrib/libs/ya.make +++ b/contrib/libs/ya.make @@ -15,7 +15,7 @@ RECURSE( avs-device-sdk aws-sdk-cpp backtrace - base64 + base64 bdb bdb/ut benchmark @@ -209,9 +209,9 @@ RECURSE( llvm11 llvm12 llvm8 - lmdbxx - lmdbxx/check - lmdbxx/example + lmdbxx + lmdbxx/check + lmdbxx/example lua lua-cjson luajit_21 @@ -269,7 +269,7 @@ RECURSE( pffft pfr picohttpparser - #pire/ut + #pire/ut pixman poco portaudio @@ -277,7 +277,7 @@ RECURSE( proj protobuf protobuf/python - protobuf-mutator + protobuf-mutator protobuf_std protoc_std psimd @@ -312,7 +312,7 @@ RECURSE( sqlite3 srt stan - stan-math + stan-math stan/stan/command stxxl subversion diff --git a/contrib/python/decorator/ya.make b/contrib/python/decorator/ya.make index fbb7ebf6264..4ffa9016b18 100644 --- a/contrib/python/decorator/ya.make +++ b/contrib/python/decorator/ya.make @@ -5,7 +5,7 @@ LICENSE(BSD-3-Clause) OWNER(g:python-contrib borman) VERSION(4.4.2) - + NO_LINT() PY_SRCS( diff --git a/contrib/python/ya.make b/contrib/python/ya.make index d01ced9f3aa..2db5b5e2cc5 100644 --- a/contrib/python/ya.make +++ b/contrib/python/ya.make @@ -8,7 +8,7 @@ RECURSE( aio-pika aioboto3 aiobotocore - aioch + aioch aiochclient aiodns aiodocker @@ -35,13 +35,13 @@ RECURSE( aiosignal aiosmtpd aiosmtplib - aiosocksy + aiosocksy aiosqlite aiotg aiounittest aiozipkin aiozk - alabaster + alabaster alembic allpairspy amqp @@ -88,10 +88,10 @@ RECURSE( autobahn Automat awscli - Babel + Babel backcall - backports_abc - backports.csv + backports_abc + backports.csv backports.functools-lru-cache backports.lzma backports.shutil-get-terminal-size @@ -162,7 +162,7 @@ RECURSE( color colorama coloredlogs - colorhash + colorhash colorlog commoncode commonmark @@ -325,7 +325,7 @@ RECURSE( dpath dpkt drf-extensions - drf_ujson + drf_ujson drf-yasg easywebdav ecdsa @@ -367,7 +367,7 @@ RECURSE( fastsnmp faulthandler fbprophet - feedparser + feedparser ffmpeg-python fido2 filelock @@ -383,20 +383,20 @@ RECURSE( flaky Flask Flask-Admin - flask-appconfig + flask-appconfig Flask-Babel Flask-Bootstrap Flask-Bootstrap/example Flask-Caching flask-cors - flask_graphql + flask_graphql Flask-Humanize Flask-Log-Request-ID Flask-Login Flask-Mail flask-marshmallow Flask-Menu - flask_migrate + flask_migrate flask-mongoengine Flask-OpenTracing Flask-Principal @@ -678,7 +678,7 @@ RECURSE( odfpy Office365-REST-Python-Client olefile - openapi-codec + openapi-codec openapi-core openapi-schema-validator openapi-spec-validator @@ -712,7 +712,7 @@ RECURSE( parse parse-type parsedatetime - parsel + parsel Parsley parso partd @@ -720,7 +720,7 @@ RECURSE( patch patched path.py - pathlib2 + pathlib2 pathspec pathtools pathy @@ -789,7 +789,7 @@ RECURSE( py4j pyaes pyahocorasick - pyaml + pyaml pyasn1 pyasn1-modules pybreaker @@ -857,7 +857,7 @@ RECURSE( pystan/pystan_model pysyncobj pyTelegramBotAPI - pytest + pytest pytest-allure-adaptor pytest-asyncio pytest-bdd @@ -865,13 +865,13 @@ RECURSE( pytest-datafixtures pytest-django pytest-falcon - pytest-falcon-client + pytest-falcon-client pytest-fixture-config pytest-flake8 pytest-flakes pytest-flask pytest-forked - pytest-freezegun + pytest-freezegun pytest-httpretty pytest-lazy-fixture pytest-localserver @@ -899,7 +899,7 @@ RECURSE( python-geohash python-gnupg python-hglib - python-i18n + python-i18n python-jose python-json-logger python-ldap @@ -1003,7 +1003,7 @@ RECURSE( skynet_pyro4 slack-sdk slackclient - smart-open + smart-open smmap snappy sniffio @@ -1021,12 +1021,12 @@ RECURSE( spidev spintop-openhtf splunk-sdk-python - sqlalchemy + sqlalchemy SQLAlchemy-Continuum sqlalchemy-stubs SQLAlchemy-Utils sqlparse - sqltap + sqltap srptools srsly sshpubkeys @@ -1047,7 +1047,7 @@ RECURSE( swagger-spec-validator sympy sysv-ipc - tableauserverclient + tableauserverclient tablib tabulate tblib @@ -1080,7 +1080,7 @@ RECURSE( toro tqdm trace_event - traceback2 + traceback2 traitlets transfer_manager_client transitions @@ -1141,7 +1141,7 @@ RECURSE( webargs webauthn webcolors - webencodings + webencodings WebOb websocket-client websockets diff --git a/contrib/tools/protoc/plugins/cpp_styleguide/cpp_styleguide.cpp b/contrib/tools/protoc/plugins/cpp_styleguide/cpp_styleguide.cpp index cd96aa05657..b54e93a28a5 100644 --- a/contrib/tools/protoc/plugins/cpp_styleguide/cpp_styleguide.cpp +++ b/contrib/tools/protoc/plugins/cpp_styleguide/cpp_styleguide.cpp @@ -8,7 +8,7 @@ #include <google/protobuf/stubs/strutil.h> #include "cpp_styleguide.h" -#include <util/stream/output.h> +#include <util/stream/output.h> namespace NProtobuf { namespace NCompiler { @@ -843,7 +843,7 @@ namespace NPlugins { printer.Print("// Yandex JSON extension\n"); TVariables vars; vars["class"] = ClassName(Descriptor_, true); - printer.Print(vars, "inline void $class$::PrintJSON(IOutputStream& out) const {\n"); + printer.Print(vars, "inline void $class$::PrintJSON(IOutputStream& out) const {\n"); printer.Indent(); printer.Print("out << '{';\n"); @@ -894,7 +894,7 @@ namespace NPlugins { TVariables vars; vars["class"] = ClassName(Descriptor_, true); printer.Print("template<>\n"); - printer.Print(vars, "void Out< $class$>(IOutputStream& out, const $class$& msg) {\n"); + printer.Print(vars, "void Out< $class$>(IOutputStream& out, const $class$& msg) {\n"); printer.Print(" out << \"{ \" << msg.ShortUtf8DebugString() << \" }\";\n"); printer.Print("}\n"); printer.Print("// End of Yandex debug output extension\n"); diff --git a/contrib/tools/ya.make b/contrib/tools/ya.make index 750911c5878..3b09592ae24 100644 --- a/contrib/tools/ya.make +++ b/contrib/tools/ya.make @@ -5,7 +5,7 @@ RECURSE( bison chromaprinter file2c - flame-graph + flame-graph flatc flatc64 flex diff --git a/library/README.md b/library/README.md index fc418bef7bb..0ca63b59440 100644 --- a/library/README.md +++ b/library/README.md @@ -17,15 +17,15 @@ library 5. The library **MUST** depend only on a limited list of external components (currently it is `util/`, `contrib/`, `vendor/`, `library/`). - + 6. Any code in Arcadia (except `contrib/`, `vendor/` and `util/`) **MAY** depend on the `library/`. - + 7. The library **MUST** be accompanied by `README.md` file and a brief description of the project. 8. The library **MUST** be accompanied by unit-tests. 9. CPU- or/and RAM-bound algorithms **SHOULD** provide benchmarks. - + 10. There **MUST** be no trade secrets of Yandex in `library/`: anything that can cause harm on publishing as OpenSource. For example: * spam filter rules; * coefficients for ML; @@ -34,11 +34,11 @@ library 11. All OSS (OpenSource Software) ready code **MUST** be accompanied by macro [LICENCE](https://docs.yandex-team.ru/ya-make/manual/common/macros#licence(license...)) in `ya.make`. 12. All language specific aspects are defined by `<language>` committee: see `library/<language>/README.md`. - + 13. The library **MUST** satisfy `<language>` style-guide. 14. The existing library **SHOULD** be improved instead of creating a new one - if it is possible. - + Please do not create yet another library for the same thing: just improve existing one. Contacts diff --git a/library/cpp/accurate_accumulate/accurate_accumulate.h b/library/cpp/accurate_accumulate/accurate_accumulate.h index dacced17e9e..04e362019a8 100644 --- a/library/cpp/accurate_accumulate/accurate_accumulate.h +++ b/library/cpp/accurate_accumulate/accurate_accumulate.h @@ -1,37 +1,37 @@ #pragma once -#include <util/ysaveload.h> +#include <util/ysaveload.h> #include <util/generic/vector.h> #include <util/system/yassert.h> -//! See more details here http://en.wikipedia.org/wiki/Kahan_summation_algorithm +//! See more details here http://en.wikipedia.org/wiki/Kahan_summation_algorithm template <typename TAccumulateType> class TKahanAccumulator { public: using TValueType = TAccumulateType; - template <typename TFloatType> + template <typename TFloatType> explicit TKahanAccumulator(const TFloatType x) - : Sum_(x) - , Compensation_() - { - } - + : Sum_(x) + , Compensation_() + { + } + TKahanAccumulator() - : Sum_() - , Compensation_() + : Sum_() + , Compensation_() { } template <typename TFloatType> - TKahanAccumulator& operator=(const TFloatType& rhs) { - Sum_ = TValueType(rhs); - Compensation_ = TValueType(); + TKahanAccumulator& operator=(const TFloatType& rhs) { + Sum_ = TValueType(rhs); + Compensation_ = TValueType(); return *this; } TValueType Get() const { - return Sum_ + Compensation_; + return Sum_ + Compensation_; } template <typename TFloatType> @@ -40,77 +40,77 @@ public: } template <typename TFloatType> - inline bool operator<(const TKahanAccumulator<TFloatType>& other) const { + inline bool operator<(const TKahanAccumulator<TFloatType>& other) const { return Get() < other.Get(); } template <typename TFloatType> - inline bool operator<=(const TKahanAccumulator<TFloatType>& other) const { + inline bool operator<=(const TKahanAccumulator<TFloatType>& other) const { return !(other < *this); } template <typename TFloatType> - inline bool operator>(const TKahanAccumulator<TFloatType>& other) const { + inline bool operator>(const TKahanAccumulator<TFloatType>& other) const { return other < *this; } template <typename TFloatType> - inline bool operator>=(const TKahanAccumulator<TFloatType>& other) const { + inline bool operator>=(const TKahanAccumulator<TFloatType>& other) const { return !(*this < other); } template <typename TFloatType> - inline TKahanAccumulator& operator+=(const TFloatType x) { - const TValueType y = TValueType(x) - Compensation_; - const TValueType t = Sum_ + y; - Compensation_ = (t - Sum_) - y; - Sum_ = t; + inline TKahanAccumulator& operator+=(const TFloatType x) { + const TValueType y = TValueType(x) - Compensation_; + const TValueType t = Sum_ + y; + Compensation_ = (t - Sum_) - y; + Sum_ = t; return *this; } template <typename TFloatType> - inline TKahanAccumulator& operator-=(const TFloatType x) { - return *this += -TValueType(x); + inline TKahanAccumulator& operator-=(const TFloatType x) { + return *this += -TValueType(x); } template <typename TFloatType> - inline TKahanAccumulator& operator*=(const TFloatType x) { - return *this = TValueType(*this) * TValueType(x); + inline TKahanAccumulator& operator*=(const TFloatType x) { + return *this = TValueType(*this) * TValueType(x); } template <typename TFloatType> - inline TKahanAccumulator& operator/=(const TFloatType x) { - return *this = TValueType(*this) / TValueType(x); + inline TKahanAccumulator& operator/=(const TFloatType x) { + return *this = TValueType(*this) / TValueType(x); } - - Y_SAVELOAD_DEFINE(Sum_, Compensation_) - + + Y_SAVELOAD_DEFINE(Sum_, Compensation_) + private: - TValueType Sum_; - TValueType Compensation_; + TValueType Sum_; + TValueType Compensation_; }; template <typename TAccumulateType, typename TFloatType> inline const TKahanAccumulator<TAccumulateType> -operator+(TKahanAccumulator<TAccumulateType> lhs, const TFloatType rhs) { - return lhs += rhs; -} - +operator+(TKahanAccumulator<TAccumulateType> lhs, const TFloatType rhs) { + return lhs += rhs; +} + template <typename TAccumulateType, typename TFloatType> inline const TKahanAccumulator<TAccumulateType> -operator-(TKahanAccumulator<TAccumulateType> lhs, const TFloatType rhs) { - return lhs -= rhs; -} - +operator-(TKahanAccumulator<TAccumulateType> lhs, const TFloatType rhs) { + return lhs -= rhs; +} + template <typename TAccumulateType, typename TFloatType> inline const TKahanAccumulator<TAccumulateType> -operator*(TKahanAccumulator<TAccumulateType> lhs, const TFloatType rhs) { +operator*(TKahanAccumulator<TAccumulateType> lhs, const TFloatType rhs) { return lhs *= rhs; } template <typename TAccumulateType, typename TFloatType> inline const TKahanAccumulator<TAccumulateType> -operator/(TKahanAccumulator<TAccumulateType> lhs, const TFloatType rhs) { +operator/(TKahanAccumulator<TAccumulateType> lhs, const TFloatType rhs) { return lhs /= rhs; } @@ -190,7 +190,7 @@ static inline double FastAccumulate(const TVector<T>& sequence) { template <typename It> static inline double FastKahanAccumulate(It begin, It end) { - return TypedFastAccumulate<TKahanAccumulator<double>>(begin, end); + return TypedFastAccumulate<TKahanAccumulator<double>>(begin, end); } template <typename T> @@ -205,17 +205,17 @@ static inline double FastInnerProduct(It1 begin1, It1 end1, It2 begin2) { template <typename T> static inline double FastInnerProduct(const TVector<T>& lhs, const TVector<T>& rhs) { - Y_ASSERT(lhs.size() == rhs.size()); + Y_ASSERT(lhs.size() == rhs.size()); return FastInnerProduct(lhs.begin(), lhs.end(), rhs.begin()); } template <typename It1, typename It2> static inline double FastKahanInnerProduct(It1 begin1, It1 end1, It2 begin2) { - return TypedFastInnerProduct<TKahanAccumulator<double>>(begin1, end1, begin2); + return TypedFastInnerProduct<TKahanAccumulator<double>>(begin1, end1, begin2); } template <typename T> static inline double FastKahanInnerProduct(const TVector<T>& lhs, const TVector<T>& rhs) { - Y_ASSERT(lhs.size() == rhs.size()); + Y_ASSERT(lhs.size() == rhs.size()); return FastKahanInnerProduct(lhs.begin(), lhs.end(), rhs.begin()); } diff --git a/library/cpp/accurate_accumulate/benchmark/main.cpp b/library/cpp/accurate_accumulate/benchmark/main.cpp index 3c5e6e775de..6dcd8a96359 100644 --- a/library/cpp/accurate_accumulate/benchmark/main.cpp +++ b/library/cpp/accurate_accumulate/benchmark/main.cpp @@ -1,97 +1,97 @@ #include <library/cpp/accurate_accumulate/accurate_accumulate.h> #include <library/cpp/testing/benchmark/bench.h> - -#include <util/generic/algorithm.h> -#include <util/generic/singleton.h> -#include <util/generic/vector.h> -#include <util/generic/xrange.h> -#include <util/random/fast.h> - -namespace { - template <typename T, size_t N> - struct TNormalizedExamplesHolder { + +#include <util/generic/algorithm.h> +#include <util/generic/singleton.h> +#include <util/generic/vector.h> +#include <util/generic/xrange.h> +#include <util/random/fast.h> + +namespace { + template <typename T, size_t N> + struct TNormalizedExamplesHolder { TVector<T> Examples; - TNormalizedExamplesHolder() - : Examples(N) - { - TFastRng<ui64> prng{sizeof(T) * N * 42u}; - for (auto& x : Examples) { - x = prng.GenRandReal4(); - } - } - }; - - template <typename T, size_t N> - struct TExamplesHolder { + TNormalizedExamplesHolder() + : Examples(N) + { + TFastRng<ui64> prng{sizeof(T) * N * 42u}; + for (auto& x : Examples) { + x = prng.GenRandReal4(); + } + } + }; + + template <typename T, size_t N> + struct TExamplesHolder { TVector<T> Examples; - TExamplesHolder() - : Examples(N) - { - TFastRng<ui64> prng{sizeof(T) * N * 42u + 100500u}; - for (auto& x : Examples) { - // operations with non-normalized floating point numbers are rumored to work slower - x = prng.GenRandReal4() + prng.Uniform(1024u); - } - } - }; -} - -#define DEFINE_BENCHMARK(type, count) \ - Y_CPU_BENCHMARK(SimpleNorm_##type##_##count, iface) { \ - const auto& examples = Default<TNormalizedExamplesHolder<type, count>>().Examples; \ - for (const auto i : xrange(iface.Iterations())) { \ - Y_UNUSED(i); \ - Y_DO_NOT_OPTIMIZE_AWAY( \ - (type)Accumulate(std::cbegin(examples), std::cend(examples), type{})); \ - } \ - } \ - \ - Y_CPU_BENCHMARK(KahanNorm_##type##_##count, iface) { \ - const auto& examples = Default<TNormalizedExamplesHolder<type, count>>().Examples; \ - for (const auto i : xrange(iface.Iterations())) { \ - Y_UNUSED(i); \ - Y_DO_NOT_OPTIMIZE_AWAY( \ - (type)Accumulate(std::cbegin(examples), std::cend(examples), TKahanAccumulator<type>{})); \ - } \ - } \ - \ - Y_CPU_BENCHMARK(Simple_##type##_##count, iface) { \ - const auto& examples = Default<TExamplesHolder<type, count>>().Examples; \ - for (const auto i : xrange(iface.Iterations())) { \ - Y_UNUSED(i); \ - Y_DO_NOT_OPTIMIZE_AWAY( \ - (type)Accumulate(std::cbegin(examples), std::cend(examples), type{})); \ - } \ - } \ - \ - Y_CPU_BENCHMARK(Kahan_##type##_##count, iface) { \ - const auto& examples = Default<TExamplesHolder<type, count>>().Examples; \ - for (const auto i : xrange(iface.Iterations())) { \ - Y_UNUSED(i); \ - Y_DO_NOT_OPTIMIZE_AWAY( \ - (type)Accumulate(std::cbegin(examples), std::cend(examples), TKahanAccumulator<type>{})); \ - } \ - } - -DEFINE_BENCHMARK(float, 2) -DEFINE_BENCHMARK(float, 4) -DEFINE_BENCHMARK(float, 8) -DEFINE_BENCHMARK(float, 16) -DEFINE_BENCHMARK(float, 32) -DEFINE_BENCHMARK(float, 64) -DEFINE_BENCHMARK(float, 128) -DEFINE_BENCHMARK(float, 256) -DEFINE_BENCHMARK(float, 512) -DEFINE_BENCHMARK(float, 1024) -DEFINE_BENCHMARK(double, 2) -DEFINE_BENCHMARK(double, 4) -DEFINE_BENCHMARK(double, 8) -DEFINE_BENCHMARK(double, 16) -DEFINE_BENCHMARK(double, 32) -DEFINE_BENCHMARK(double, 64) -DEFINE_BENCHMARK(double, 128) -DEFINE_BENCHMARK(double, 256) -DEFINE_BENCHMARK(double, 512) -DEFINE_BENCHMARK(double, 1024) - -#undef DEFINE_BENCHMARK + TExamplesHolder() + : Examples(N) + { + TFastRng<ui64> prng{sizeof(T) * N * 42u + 100500u}; + for (auto& x : Examples) { + // operations with non-normalized floating point numbers are rumored to work slower + x = prng.GenRandReal4() + prng.Uniform(1024u); + } + } + }; +} + +#define DEFINE_BENCHMARK(type, count) \ + Y_CPU_BENCHMARK(SimpleNorm_##type##_##count, iface) { \ + const auto& examples = Default<TNormalizedExamplesHolder<type, count>>().Examples; \ + for (const auto i : xrange(iface.Iterations())) { \ + Y_UNUSED(i); \ + Y_DO_NOT_OPTIMIZE_AWAY( \ + (type)Accumulate(std::cbegin(examples), std::cend(examples), type{})); \ + } \ + } \ + \ + Y_CPU_BENCHMARK(KahanNorm_##type##_##count, iface) { \ + const auto& examples = Default<TNormalizedExamplesHolder<type, count>>().Examples; \ + for (const auto i : xrange(iface.Iterations())) { \ + Y_UNUSED(i); \ + Y_DO_NOT_OPTIMIZE_AWAY( \ + (type)Accumulate(std::cbegin(examples), std::cend(examples), TKahanAccumulator<type>{})); \ + } \ + } \ + \ + Y_CPU_BENCHMARK(Simple_##type##_##count, iface) { \ + const auto& examples = Default<TExamplesHolder<type, count>>().Examples; \ + for (const auto i : xrange(iface.Iterations())) { \ + Y_UNUSED(i); \ + Y_DO_NOT_OPTIMIZE_AWAY( \ + (type)Accumulate(std::cbegin(examples), std::cend(examples), type{})); \ + } \ + } \ + \ + Y_CPU_BENCHMARK(Kahan_##type##_##count, iface) { \ + const auto& examples = Default<TExamplesHolder<type, count>>().Examples; \ + for (const auto i : xrange(iface.Iterations())) { \ + Y_UNUSED(i); \ + Y_DO_NOT_OPTIMIZE_AWAY( \ + (type)Accumulate(std::cbegin(examples), std::cend(examples), TKahanAccumulator<type>{})); \ + } \ + } + +DEFINE_BENCHMARK(float, 2) +DEFINE_BENCHMARK(float, 4) +DEFINE_BENCHMARK(float, 8) +DEFINE_BENCHMARK(float, 16) +DEFINE_BENCHMARK(float, 32) +DEFINE_BENCHMARK(float, 64) +DEFINE_BENCHMARK(float, 128) +DEFINE_BENCHMARK(float, 256) +DEFINE_BENCHMARK(float, 512) +DEFINE_BENCHMARK(float, 1024) +DEFINE_BENCHMARK(double, 2) +DEFINE_BENCHMARK(double, 4) +DEFINE_BENCHMARK(double, 8) +DEFINE_BENCHMARK(double, 16) +DEFINE_BENCHMARK(double, 32) +DEFINE_BENCHMARK(double, 64) +DEFINE_BENCHMARK(double, 128) +DEFINE_BENCHMARK(double, 256) +DEFINE_BENCHMARK(double, 512) +DEFINE_BENCHMARK(double, 1024) + +#undef DEFINE_BENCHMARK diff --git a/library/cpp/accurate_accumulate/benchmark/metrics/main.py b/library/cpp/accurate_accumulate/benchmark/metrics/main.py index 311fc219cec..dc900606254 100644 --- a/library/cpp/accurate_accumulate/benchmark/metrics/main.py +++ b/library/cpp/accurate_accumulate/benchmark/metrics/main.py @@ -1,7 +1,7 @@ -import yatest.common as yc - - -def test_export_metrics(metrics): - metrics.set_benchmark(yc.execute_benchmark( +import yatest.common as yc + + +def test_export_metrics(metrics): + metrics.set_benchmark(yc.execute_benchmark( 'library/cpp/accurate_accumulate/benchmark/benchmark', - threads=8)) + threads=8)) diff --git a/library/cpp/accurate_accumulate/benchmark/metrics/ya.make b/library/cpp/accurate_accumulate/benchmark/metrics/ya.make index 5d532e14799..45ef7a464ec 100644 --- a/library/cpp/accurate_accumulate/benchmark/metrics/ya.make +++ b/library/cpp/accurate_accumulate/benchmark/metrics/ya.make @@ -1,17 +1,17 @@ OWNER(yazevnul) - + PY2TEST() - + SIZE(LARGE) - -TAG( + +TAG( ya:force_sandbox - sb:intel_e5_2660v1 + sb:intel_e5_2660v1 ya:fat -) - +) + TEST_SRCS(main.py) - + DEPENDS(library/cpp/accurate_accumulate/benchmark) - -END() + +END() diff --git a/library/cpp/accurate_accumulate/benchmark/ya.make b/library/cpp/accurate_accumulate/benchmark/ya.make index 20fd8773893..48b84869669 100644 --- a/library/cpp/accurate_accumulate/benchmark/ya.make +++ b/library/cpp/accurate_accumulate/benchmark/ya.make @@ -1,13 +1,13 @@ OWNER(yazevnul) - + Y_BENCHMARK() - -SRCS( - main.cpp -) - -PEERDIR( + +SRCS( + main.cpp +) + +PEERDIR( library/cpp/accurate_accumulate -) - -END() +) + +END() diff --git a/library/cpp/actors/core/actor_coroutine_ut.cpp b/library/cpp/actors/core/actor_coroutine_ut.cpp index 951512b8772..cbbb3326352 100644 --- a/library/cpp/actors/core/actor_coroutine_ut.cpp +++ b/library/cpp/actors/core/actor_coroutine_ut.cpp @@ -11,7 +11,7 @@ using namespace NActors; -Y_UNIT_TEST_SUITE(ActorCoro) { +Y_UNIT_TEST_SUITE(ActorCoro) { enum { Begin = EventSpaceBegin(TEvents::ES_USERSPACE), Request, @@ -127,7 +127,7 @@ Y_UNIT_TEST_SUITE(ActorCoro) { actorSystem.Stop(); } - Y_UNIT_TEST(Basic) { + Y_UNIT_TEST(Basic) { if (NSan::TSanIsOn()) { // TODO https://st.yandex-team.ru/DEVTOOLS-3154 return; @@ -135,7 +135,7 @@ Y_UNIT_TEST_SUITE(ActorCoro) { Check(MakeHolder<TEvEnough>()); } - Y_UNIT_TEST(PoisonPill) { + Y_UNIT_TEST(PoisonPill) { Check(MakeHolder<TEvents::TEvPoisonPill>()); } } diff --git a/library/cpp/actors/core/actorid.h b/library/cpp/actors/core/actorid.h index d972b1a0ff1..4b35790ab86 100644 --- a/library/cpp/actors/core/actorid.h +++ b/library/cpp/actors/core/actorid.h @@ -1,7 +1,7 @@ #pragma once #include "defs.h" -#include <util/stream/output.h> // for IOutputStream +#include <util/stream/output.h> // for IOutputStream #include <util/generic/hash.h> namespace NActors { @@ -175,7 +175,7 @@ namespace NActors { }; TString ToString() const; - void Out(IOutputStream& o) const; + void Out(IOutputStream& o) const; bool Parse(const char* buf, ui32 sz); }; diff --git a/library/cpp/actors/core/callstack.cpp b/library/cpp/actors/core/callstack.cpp index 9297c1a079e..2819999aa2b 100644 --- a/library/cpp/actors/core/callstack.cpp +++ b/library/cpp/actors/core/callstack.cpp @@ -5,11 +5,11 @@ namespace NActors { namespace { - void (*PreviousFormatBackTrace)(IOutputStream*) = 0; + void (*PreviousFormatBackTrace)(IOutputStream*) = 0; ui32 ActorBackTraceEnableCounter = 0; } - void ActorFormatBackTrace(IOutputStream* out) { + void ActorFormatBackTrace(IOutputStream* out) { TStringStream str; PreviousFormatBackTrace(&str); str << Endl; diff --git a/library/cpp/actors/core/event_pb_ut.cpp b/library/cpp/actors/core/event_pb_ut.cpp index a16c3092b3b..56f5adb4014 100644 --- a/library/cpp/actors/core/event_pb_ut.cpp +++ b/library/cpp/actors/core/event_pb_ut.cpp @@ -3,7 +3,7 @@ #include <library/cpp/testing/unittest/registar.h> #include <library/cpp/actors/protos/unittests.pb.h> -Y_UNIT_TEST_SUITE(TEventSerialization) { +Y_UNIT_TEST_SUITE(TEventSerialization) { struct TMockEvent: public NActors::IEventBase { TBigMessage* msg; bool @@ -24,7 +24,7 @@ Y_UNIT_TEST_SUITE(TEventSerialization) { }; }; - Y_UNIT_TEST(Coroutine) { + Y_UNIT_TEST(Coroutine) { TString strA(507, 'a'); TString strB(814, 'b'); TString strC(198, 'c'); diff --git a/library/cpp/actors/core/executor_pool_basic.cpp b/library/cpp/actors/core/executor_pool_basic.cpp index 4dce16939ae..f9709a4c780 100644 --- a/library/cpp/actors/core/executor_pool_basic.cpp +++ b/library/cpp/actors/core/executor_pool_basic.cpp @@ -323,7 +323,7 @@ namespace NActors { void TBasicExecutorPool::SetRealTimeMode() const { // TODO: musl-libc version of `sched_param` struct is for some reason different from pthread // version in Ubuntu 12.04 -#if defined(_linux_) && !defined(_musl_) +#if defined(_linux_) && !defined(_musl_) if (RealtimePriority != 0) { pthread_t threadSelf = pthread_self(); sched_param param = {RealtimePriority}; diff --git a/library/cpp/actors/core/executor_thread.cpp b/library/cpp/actors/core/executor_thread.cpp index 446b651efd2..9f155c30bca 100644 --- a/library/cpp/actors/core/executor_thread.cpp +++ b/library/cpp/actors/core/executor_thread.cpp @@ -475,7 +475,7 @@ namespace NActors { else if (state == TExecutionState::FreeExecuting) AtomicStore(&ExecutionState, (ui32)TExecutionState::FreeLeaving); else - Y_FAIL(); + Y_FAIL(); AtomicBarrier(); } diff --git a/library/cpp/actors/core/executor_thread.h b/library/cpp/actors/core/executor_thread.h index 9d3c573f0d6..0ecc6404387 100644 --- a/library/cpp/actors/core/executor_thread.h +++ b/library/cpp/actors/core/executor_thread.h @@ -14,7 +14,7 @@ namespace NActors { - class TExecutorThread: public ISimpleThread { + class TExecutorThread: public ISimpleThread { public: static constexpr TDuration DEFAULT_TIME_PER_MAILBOX = TDuration::MilliSeconds(10); diff --git a/library/cpp/actors/core/log.cpp b/library/cpp/actors/core/log.cpp index 5f63b5af580..8879083f19f 100644 --- a/library/cpp/actors/core/log.cpp +++ b/library/cpp/actors/core/log.cpp @@ -236,7 +236,7 @@ namespace NActors { } void TLoggerActor::HandleIgnoredEvent(TLogIgnored::TPtr& ev, const NActors::TActorContext& ctx) { - Y_UNUSED(ev); + Y_UNUSED(ev); LogIgnoredCount(ctx.Now()); IgnoredCount = 0; PassedCount = 0; @@ -309,7 +309,7 @@ namespace NActors { ctx.Send(ev->Sender, new TLogComponentLevelResponse(code, explanation)); } - void TLoggerActor::RenderComponentPriorities(IOutputStream& str) { + void TLoggerActor::RenderComponentPriorities(IOutputStream& str) { using namespace NLog; HTML(str) { H4() { @@ -690,7 +690,7 @@ namespace NActors { isOk = true; } catch (TSystemError err) { // Interrupted system call - Y_UNUSED(err); + Y_UNUSED(err); } } while (!isOk); } diff --git a/library/cpp/actors/core/log.h b/library/cpp/actors/core/log.h index c11a7cf3c19..a7d8ec058a1 100644 --- a/library/cpp/actors/core/log.h +++ b/library/cpp/actors/core/log.h @@ -252,7 +252,7 @@ namespace NActors { void HandleMonInfo(NMon::TEvHttpInfo::TPtr& ev, const TActorContext& ctx); void HandleWakeup(); [[nodiscard]] bool OutputRecord(TInstant time, NLog::EPrio priority, NLog::EComponent component, const TString& formatted) noexcept; - void RenderComponentPriorities(IOutputStream& str); + void RenderComponentPriorities(IOutputStream& str); void LogIgnoredCount(TInstant now); void WriteMessageStat(const NLog::TEvLog& ev); static const char* FormatLocalTimestamp(TInstant time, char* buf); diff --git a/library/cpp/actors/core/log_settings.cpp b/library/cpp/actors/core/log_settings.cpp index f52f2fc5d22..bfc5143a3e1 100644 --- a/library/cpp/actors/core/log_settings.cpp +++ b/library/cpp/actors/core/log_settings.cpp @@ -50,7 +50,7 @@ namespace NActors { void TSettings::Append(EComponent minVal, EComponent maxVal, EComponentToStringFunc func) { Y_VERIFY(minVal >= 0, "NLog::TSettings: minVal must be non-negative"); - Y_VERIFY(maxVal > minVal, "NLog::TSettings: maxVal must be greater than minVal"); + Y_VERIFY(maxVal > minVal, "NLog::TSettings: maxVal must be greater than minVal"); // update bounds if (!MaxVal || minVal < MinVal) { diff --git a/library/cpp/actors/core/log_settings.h b/library/cpp/actors/core/log_settings.h index 7fe4504edd9..f8aade260a2 100644 --- a/library/cpp/actors/core/log_settings.h +++ b/library/cpp/actors/core/log_settings.h @@ -144,13 +144,13 @@ namespace NActors { } inline TComponentSettings GetComponentSettings(EComponent component) const { - Y_VERIFY_DEBUG((component & Mask) == component); + Y_VERIFY_DEBUG((component & Mask) == component); // by using Mask we don't get outside of array boundaries return TComponentSettings(AtomicGet(ComponentInfo[component & Mask])); } const char* ComponentName(EComponent component) const { - Y_VERIFY_DEBUG((component & Mask) == component); + Y_VERIFY_DEBUG((component & Mask) == component); return ComponentNames[component & Mask].data(); } diff --git a/library/cpp/actors/core/mon.h b/library/cpp/actors/core/mon.h index c450f2338eb..a159c89469a 100644 --- a/library/cpp/actors/core/mon.h +++ b/library/cpp/actors/core/mon.h @@ -53,7 +53,7 @@ namespace NActors { virtual ~IEvHttpInfoRes() { } - virtual void Output(IOutputStream& out) const = 0; + virtual void Output(IOutputStream& out) const = 0; virtual EContentType GetContentType() const = 0; }; @@ -66,7 +66,7 @@ namespace NActors { { } - void Output(IOutputStream& out) const override { + void Output(IOutputStream& out) const override { out << Answer; } diff --git a/library/cpp/actors/core/scheduler_actor_ut.cpp b/library/cpp/actors/core/scheduler_actor_ut.cpp index 09b7369d360..23e292cd2d8 100644 --- a/library/cpp/actors/core/scheduler_actor_ut.cpp +++ b/library/cpp/actors/core/scheduler_actor_ut.cpp @@ -13,7 +13,7 @@ using namespace NActors; -Y_UNIT_TEST_SUITE(SchedulerActor) { +Y_UNIT_TEST_SUITE(SchedulerActor) { class TTestActor: public TActorBootstrapped<TTestActor> { TManualEvent& DoneEvent; TAtomic& EventsProcessed; @@ -86,15 +86,15 @@ Y_UNIT_TEST_SUITE(SchedulerActor) { actorSystem.Stop(); } - Y_UNIT_TEST(LongEvents) { + Y_UNIT_TEST(LongEvents) { Test(10, 500); } - Y_UNIT_TEST(MediumEvents) { + Y_UNIT_TEST(MediumEvents) { Test(100, 50); } - Y_UNIT_TEST(QuickEvents) { + Y_UNIT_TEST(QuickEvents) { Test(1000, 5); } } diff --git a/library/cpp/actors/dnscachelib/dnscache.cpp b/library/cpp/actors/dnscachelib/dnscache.cpp index 649339ddb22..886637046c1 100644 --- a/library/cpp/actors/dnscachelib/dnscache.cpp +++ b/library/cpp/actors/dnscachelib/dnscache.cpp @@ -176,7 +176,7 @@ TDnsCache::Resolve(const TString& hostname, int family, bool cacheOnly) { THostCache::iterator p; - Y_ASSERT(family == AF_INET || family == AF_INET6); + Y_ASSERT(family == AF_INET || family == AF_INET6); { TGuard<TMutex> lock(CacheMtx); @@ -317,7 +317,7 @@ void TDnsCache::WaitTask(TAtomic& flag) { } } - Y_ASSERT(nfds != 0); + Y_ASSERT(nfds != 0); const TDuration left = TInstant(TTimeKeeper::GetTimeval()) - start; const TDuration wait = Max(Timeout - left, TDuration::Zero()); @@ -363,7 +363,7 @@ void TDnsCache::GHBNCallback(void* arg, int status, int, struct hostent* info) { TGuard<TMutex> lock(ctx->Owner->CacheMtx); THostCache::iterator p = ctx->Owner->HostCache.find(ctx->Hostname); - Y_ASSERT(p != ctx->Owner->HostCache.end()); + Y_ASSERT(p != ctx->Owner->HostCache.end()); time_t& resolved = (ctx->Family == AF_INET ? p->second.ResolvedV4 : p->second.ResolvedV6); time_t& notfound = (ctx->Family == AF_INET ? p->second.NotFoundV4 : p->second.NotFoundV6); @@ -387,7 +387,7 @@ void TDnsCache::GHBNCallback(void* arg, int status, int, struct hostent* info) { p->second.AddrsV6.push_back(*(struct in6_addr*)(info->h_addr_list[i])); } } else { - Y_FAIL("unknown address type in ares callback"); + Y_FAIL("unknown address type in ares callback"); } resolved = TTimeKeeper::GetTime(); notfound = 0; @@ -403,7 +403,7 @@ void TDnsCache::GHBACallback(void* arg, int status, int, struct hostent* info) { TGuard<TMutex> lock(ctx->Owner->CacheMtx); TAddrCache::iterator p = ctx->Owner->AddrCache.find(ctx->Addr); - Y_ASSERT(p != ctx->Owner->AddrCache.end()); + Y_ASSERT(p != ctx->Owner->AddrCache.end()); if (status == ARES_SUCCESS) { p->second.Hostname = info->h_name; diff --git a/library/cpp/actors/helpers/selfping_actor_ut.cpp b/library/cpp/actors/helpers/selfping_actor_ut.cpp index 459635fa24a..397da9d8eb3 100644 --- a/library/cpp/actors/helpers/selfping_actor_ut.cpp +++ b/library/cpp/actors/helpers/selfping_actor_ut.cpp @@ -13,8 +13,8 @@ THolder<TTestActorRuntimeBase> CreateRuntime() { return runtime; } -Y_UNIT_TEST_SUITE(TSelfPingTest) { - Y_UNIT_TEST(Basic) +Y_UNIT_TEST_SUITE(TSelfPingTest) { + Y_UNIT_TEST(Basic) { auto runtime = CreateRuntime(); diff --git a/library/cpp/actors/http/http_ut.cpp b/library/cpp/actors/http/http_ut.cpp index 4c922f8d0fc..592a3412769 100644 --- a/library/cpp/actors/http/http_ut.cpp +++ b/library/cpp/actors/http/http_ut.cpp @@ -37,8 +37,8 @@ void EatPartialString(TIntrusivePtr<HttpType>& request, const TString& data) { } -Y_UNIT_TEST_SUITE(HttpProxy) { - Y_UNIT_TEST(BasicParsing) { +Y_UNIT_TEST_SUITE(HttpProxy) { + Y_UNIT_TEST(BasicParsing) { NHttp::THttpIncomingRequestPtr request = new NHttp::THttpIncomingRequest(); EatWholeString(request, "GET /test HTTP/1.1\r\nHost: test\r\nSome-Header: 32344\r\n\r\n"); UNIT_ASSERT_EQUAL(request->Stage, NHttp::THttpIncomingRequest::EParseStage::Done); @@ -50,7 +50,7 @@ Y_UNIT_TEST_SUITE(HttpProxy) { UNIT_ASSERT_EQUAL(request->Headers, "Host: test\r\nSome-Header: 32344\r\n\r\n"); } - Y_UNIT_TEST(BasicParsingChunkedBody) { + Y_UNIT_TEST(BasicParsingChunkedBody) { NHttp::THttpOutgoingRequestPtr request = nullptr; //new NHttp::THttpOutgoingRequest(); NHttp::THttpIncomingResponsePtr response = new NHttp::THttpIncomingResponse(request); EatWholeString(response, "HTTP/1.1 200 OK\r\nConnection: close\r\nTransfer-Encoding: chunked\r\n\r\n4\r\nthis\r\n4\r\n is \r\n5\r\ntest.\r\n0\r\n\r\n"); @@ -94,7 +94,7 @@ Y_UNIT_TEST_SUITE(HttpProxy) { UNIT_ASSERT_VALUES_EQUAL(compressedBody, response->Body); } - Y_UNIT_TEST(BasicPartialParsing) { + Y_UNIT_TEST(BasicPartialParsing) { NHttp::THttpIncomingRequestPtr request = new NHttp::THttpIncomingRequest(); EatPartialString(request, "GET /test HTTP/1.1\r\nHost: test\r\nSome-Header: 32344\r\n\r\n"); UNIT_ASSERT_EQUAL(request->Stage, NHttp::THttpIncomingRequest::EParseStage::Done); @@ -106,7 +106,7 @@ Y_UNIT_TEST_SUITE(HttpProxy) { UNIT_ASSERT_EQUAL(request->Headers, "Host: test\r\nSome-Header: 32344\r\n\r\n"); } - Y_UNIT_TEST(BasicPartialParsingChunkedBody) { + Y_UNIT_TEST(BasicPartialParsingChunkedBody) { NHttp::THttpOutgoingRequestPtr request = nullptr; //new NHttp::THttpOutgoingRequest(); NHttp::THttpIncomingResponsePtr response = new NHttp::THttpIncomingResponse(request); EatPartialString(response, "HTTP/1.1 200 OK\r\nConnection: close\r\nTransfer-Encoding: chunked\r\n\r\n4\r\nthis\r\n4\r\n is \r\n5\r\ntest.\r\n0\r\n\r\n"); @@ -119,7 +119,7 @@ Y_UNIT_TEST_SUITE(HttpProxy) { UNIT_ASSERT_EQUAL(response->Body, "this is test."); } - Y_UNIT_TEST(AdvancedParsing) { + Y_UNIT_TEST(AdvancedParsing) { NHttp::THttpIncomingRequestPtr request = new NHttp::THttpIncomingRequest(); EatWholeString(request, "GE"); EatWholeString(request, "T"); @@ -140,7 +140,7 @@ Y_UNIT_TEST_SUITE(HttpProxy) { UNIT_ASSERT_EQUAL(request->Headers, "Host: test\r\nSome-Header: 32344\r\n\r\n"); } - Y_UNIT_TEST(AdvancedPartialParsing) { + Y_UNIT_TEST(AdvancedPartialParsing) { NHttp::THttpIncomingRequestPtr request = new NHttp::THttpIncomingRequest(); EatPartialString(request, "GE"); EatPartialString(request, "T"); @@ -174,7 +174,7 @@ Y_UNIT_TEST_SUITE(HttpProxy) { UNIT_ASSERT_VALUES_EQUAL(requestData, "GET /data/url HTTP/1.1\r\nHost: www.yandex.ru\r\nAccept: */*\r\nCookie: cookie1=123456; cookie2=45678;\r\n"); } - Y_UNIT_TEST(BasicRunning) { + Y_UNIT_TEST(BasicRunning) { NActors::TTestActorRuntimeBase actorSystem; TPortManager portManager; TIpPort port = portManager.GetTcpPort(); @@ -304,7 +304,7 @@ CRA/5XcX13GJwHHj6LCoc3sL7mt8qV9HKY2AOZ88mpObzISZxgPpdKCfjsrdm63V UNIT_ASSERT_EQUAL(response->Response->Body, "passed"); } - /*Y_UNIT_TEST(AdvancedRunning) { + /*Y_UNIT_TEST(AdvancedRunning) { THolder<NActors::TActorSystemSetup> setup = MakeHolder<NActors::TActorSystemSetup>(); setup->NodeId = 1; setup->ExecutorsCount = 1; diff --git a/library/cpp/actors/interconnect/ut_fat/main.cpp b/library/cpp/actors/interconnect/ut_fat/main.cpp index 5d19bc30030..c3992549042 100644 --- a/library/cpp/actors/interconnect/ut_fat/main.cpp +++ b/library/cpp/actors/interconnect/ut_fat/main.cpp @@ -15,7 +15,7 @@ #include <util/system/atomic.h> #include <util/generic/set.h> -Y_UNIT_TEST_SUITE(InterconnectUnstableConnection) { +Y_UNIT_TEST_SUITE(InterconnectUnstableConnection) { using namespace NActors; class TSenderActor: public TSenderBaseActor { @@ -99,7 +99,7 @@ Y_UNIT_TEST_SUITE(InterconnectUnstableConnection) { } }; - Y_UNIT_TEST(InterconnectTestWithProxyUnsureUndelivered) { + Y_UNIT_TEST(InterconnectTestWithProxyUnsureUndelivered) { ui32 numNodes = 2; double bandWidth = 1000000; ui16 flags = IEventHandle::FlagTrackDelivery | IEventHandle::FlagGenerateUnsureUndelivered; @@ -115,7 +115,7 @@ Y_UNIT_TEST_SUITE(InterconnectUnstableConnection) { NanoSleep(30ULL * 1000 * 1000 * 1000); } - Y_UNIT_TEST(InterconnectTestWithProxy) { + Y_UNIT_TEST(InterconnectTestWithProxy) { ui32 numNodes = 2; double bandWidth = 1000000; ui16 flags = IEventHandle::FlagTrackDelivery; diff --git a/library/cpp/actors/testlib/test_runtime.cpp b/library/cpp/actors/testlib/test_runtime.cpp index 6fa25b99656..d876229f1f3 100644 --- a/library/cpp/actors/testlib/test_runtime.cpp +++ b/library/cpp/actors/testlib/test_runtime.cpp @@ -95,7 +95,7 @@ namespace NActors { } STFUNC(StateFunc) { - Y_UNUSED(ctx); + Y_UNUSED(ctx); TGuard<TMutex> guard(Runtime->Mutex); bool verbose = (Runtime->CurrentDispatchContext ? !Runtime->CurrentDispatchContext->Options->Quiet : true) && VERBOSE; if (Runtime->BlockedOutput.find(ev->Sender) != Runtime->BlockedOutput.end()) { @@ -109,7 +109,7 @@ namespace NActors { if (!Runtime->EventFilterFunc(*Runtime, ev)) { ui32 nodeId = ev->GetRecipientRewrite().NodeId(); - Y_VERIFY(nodeId != 0); + Y_VERIFY(nodeId != 0); ui32 mailboxHint = ev->GetRecipientRewrite().Hint(); Runtime->GetMailbox(nodeId, mailboxHint).Send(ev); Runtime->MailboxesHasEvents.Signal(); @@ -128,7 +128,7 @@ namespace NActors { void TEventMailBox::Send(TAutoPtr<IEventHandle> ev) { IEventHandle* ptr = ev.Get(); - Y_VERIFY(ptr); + Y_VERIFY(ptr); #ifdef DEBUG_ORDER_EVENTS ui64 counter = NextToSend++; TrackSent[ptr] = counter; @@ -142,7 +142,7 @@ namespace NActors { #ifdef DEBUG_ORDER_EVENTS auto it = TrackSent.find(result.Get()); if (it != TrackSent.end()) { - Y_VERIFY(ExpectedReceive == it->second); + Y_VERIFY(ExpectedReceive == it->second); TrackSent.erase(result.Get()); ++ExpectedReceive; } @@ -239,18 +239,18 @@ namespace NActors { : Runtime(runtime) , Node(node) { - Y_UNUSED(Runtime); + Y_UNUSED(Runtime); } void Prepare(TActorSystem *actorSystem, volatile ui64 *currentTimestamp, volatile ui64 *currentMonotonic) override { - Y_UNUSED(actorSystem); + Y_UNUSED(actorSystem); Node->ActorSystemTimestamp = currentTimestamp; Node->ActorSystemMonotonic = currentMonotonic; } void PrepareSchedules(NSchedulerQueue::TReader **readers, ui32 scheduleReadersCount) override { - Y_UNUSED(readers); - Y_UNUSED(scheduleReadersCount); + Y_UNUSED(readers); + Y_UNUSED(scheduleReadersCount); } void Start() override { @@ -284,8 +284,8 @@ namespace NActors { // for threads ui32 GetReadyActivation(TWorkerContext& wctx, ui64 revolvingCounter) override { Y_UNUSED(wctx); - Y_UNUSED(revolvingCounter); - Y_FAIL(); + Y_UNUSED(revolvingCounter); + Y_FAIL(); } void ReclaimMailbox(TMailboxType::EType mailboxType, ui32 hint, TWorkerId workerId, ui64 revolvingCounter) override { @@ -357,7 +357,7 @@ namespace NActors { if (!Runtime->EventFilterFunc(*Runtime, ev)) { ui32 nodeId = ev->GetRecipientRewrite().NodeId(); - Y_VERIFY(nodeId != 0); + Y_VERIFY(nodeId != 0); TNodeDataBase* node = Runtime->Nodes[nodeId].Get(); if (!AllowSendFrom(node, ev)) { @@ -394,12 +394,12 @@ namespace NActors { } void ScheduleActivation(ui32 activation) override { - Y_UNUSED(activation); + Y_UNUSED(activation); } void ScheduleActivationEx(ui32 activation, ui64 revolvingCounter) override { - Y_UNUSED(activation); - Y_UNUSED(revolvingCounter); + Y_UNUSED(activation); + Y_UNUSED(revolvingCounter); } TActorId Register(IActor *actor, TMailboxType::EType mailboxType, ui64 revolvingCounter, @@ -413,9 +413,9 @@ namespace NActors { // lifecycle stuff void Prepare(TActorSystem *actorSystem, NSchedulerQueue::TReader **scheduleReaders, ui32 *scheduleSz) override { - Y_UNUSED(actorSystem); - Y_UNUSED(scheduleReaders); - Y_UNUSED(scheduleSz); + Y_UNUSED(actorSystem); + Y_UNUSED(scheduleReaders); + Y_UNUSED(scheduleSz); } void Start() override { @@ -433,7 +433,7 @@ namespace NActors { // generic TAffinity* Affinity() const override { - Y_FAIL(); + Y_FAIL(); } private: @@ -553,20 +553,20 @@ namespace NActors { } TTestActorRuntimeBase::EEventAction TTestActorRuntimeBase::DefaultObserverFunc(TTestActorRuntimeBase& runtime, TAutoPtr<IEventHandle>& event) { - Y_UNUSED(runtime); - Y_UNUSED(event); + Y_UNUSED(runtime); + Y_UNUSED(event); return EEventAction::PROCESS; } void TTestActorRuntimeBase::DroppingScheduledEventsSelector(TTestActorRuntimeBase& runtime, TScheduledEventsList& scheduledEvents, TEventsList& queue) { - Y_UNUSED(runtime); - Y_UNUSED(queue); + Y_UNUSED(runtime); + Y_UNUSED(queue); scheduledEvents.clear(); } bool TTestActorRuntimeBase::DefaultFilterFunc(TTestActorRuntimeBase& runtime, TAutoPtr<IEventHandle>& event) { - Y_UNUSED(runtime); - Y_UNUSED(event); + Y_UNUSED(runtime); + Y_UNUSED(event); return false; } @@ -618,7 +618,7 @@ namespace NActors { } } - void Print(IOutputStream& stream, const TString& prefix) { + void Print(IOutputStream& stream, const TString& prefix) { for (auto it = Children.begin(); it != Children.end(); ++it) { bool lastChild = (std::next(it) == Children.end()); TString connectionPrefix = lastChild ? "└─ " : "├─ "; @@ -628,7 +628,7 @@ namespace NActors { } } - void Print(IOutputStream& stream) { + void Print(IOutputStream& stream) { stream << Name << " (" << Count << ")\n"; Print(stream, TString()); } @@ -726,8 +726,8 @@ namespace NActors { } void TTestActorRuntimeBase::AddLocalService(const TActorId& actorId, const TActorSetupCmd& cmd, ui32 nodeIndex) { - Y_VERIFY(!IsInitialized); - Y_VERIFY(nodeIndex < NodeCount); + Y_VERIFY(!IsInitialized); + Y_VERIFY(nodeIndex < NodeCount); auto node = Nodes[nodeIndex + FirstNodeId]; if (!node) { node = GetNodeFactory().CreateNode(); @@ -793,7 +793,7 @@ namespace NActors { TInstant TTestActorRuntimeBase::GetCurrentTime() const { TGuard<TMutex> guard(Mutex); - Y_VERIFY(!UseRealThreads); + Y_VERIFY(!UseRealThreads); return TInstant::MicroSeconds(CurrentTimestamp); } @@ -804,7 +804,7 @@ namespace NActors { Cerr << "UpdateCurrentTime(" << counter << "," << newTime << ")\n"; } TGuard<TMutex> guard(Mutex); - Y_VERIFY(!UseRealThreads); + Y_VERIFY(!UseRealThreads); if (newTime.MicroSeconds() > CurrentTimestamp) { CurrentTimestamp = newTime.MicroSeconds(); for (auto& kv : Nodes) { @@ -819,12 +819,12 @@ namespace NActors { } TIntrusivePtr<ITimeProvider> TTestActorRuntimeBase::GetTimeProvider() { - Y_VERIFY(!UseRealThreads); + Y_VERIFY(!UseRealThreads); return TimeProvider; } ui32 TTestActorRuntimeBase::GetNodeId(ui32 index) const { - Y_VERIFY(index < NodeCount); + Y_VERIFY(index < NodeCount); return FirstNodeId + index; } @@ -859,11 +859,11 @@ namespace NActors { TActorId TTestActorRuntimeBase::Register(IActor* actor, ui32 nodeIndex, ui32 poolId, TMailboxType::EType mailboxType, ui64 revolvingCounter, const TActorId& parentId) { - Y_VERIFY(nodeIndex < NodeCount); + Y_VERIFY(nodeIndex < NodeCount); TGuard<TMutex> guard(Mutex); TNodeDataBase* node = Nodes[FirstNodeId + nodeIndex].Get(); if (UseRealThreads) { - Y_VERIFY(poolId < node->ExecutorPools.size()); + Y_VERIFY(poolId < node->ExecutorPools.size()); return node->ExecutorPools[poolId]->Register(actor, mailboxType, revolvingCounter, parentId); } @@ -927,11 +927,11 @@ namespace NActors { TActorId TTestActorRuntimeBase::Register(IActor *actor, ui32 nodeIndex, ui32 poolId, TMailboxHeader *mailbox, ui32 hint, const TActorId& parentId) { - Y_VERIFY(nodeIndex < NodeCount); + Y_VERIFY(nodeIndex < NodeCount); TGuard<TMutex> guard(Mutex); TNodeDataBase* node = Nodes[FirstNodeId + nodeIndex].Get(); if (UseRealThreads) { - Y_VERIFY(poolId < node->ExecutorPools.size()); + Y_VERIFY(poolId < node->ExecutorPools.size()); return node->ExecutorPools[poolId]->Register(actor, mailbox, hint, parentId); } @@ -951,7 +951,7 @@ namespace NActors { TActorId TTestActorRuntimeBase::RegisterService(const TActorId& serviceId, const TActorId& actorId, ui32 nodeIndex) { TGuard<TMutex> guard(Mutex); - Y_VERIFY(nodeIndex < NodeCount); + Y_VERIFY(nodeIndex < NodeCount); TNodeDataBase* node = Nodes[FirstNodeId + nodeIndex].Get(); if (!UseRealThreads) { IActor* actor = FindActor(actorId, node); @@ -964,7 +964,7 @@ namespace NActors { TActorId TTestActorRuntimeBase::AllocateEdgeActor(ui32 nodeIndex) { TGuard<TMutex> guard(Mutex); - Y_VERIFY(nodeIndex < NodeCount); + Y_VERIFY(nodeIndex < NodeCount); TActorId edgeActor = Register(new TEdgeActor(this), nodeIndex); EdgeActors.insert(edgeActor); EdgeActorByMailbox[TEventMailboxId(edgeActor.NodeId(), edgeActor.Hint())] = edgeActor; @@ -983,7 +983,7 @@ namespace NActors { TEventsList TTestActorRuntimeBase::CaptureMailboxEvents(ui32 hint, ui32 nodeId) { TGuard<TMutex> guard(Mutex); - Y_VERIFY(nodeId >= FirstNodeId && nodeId < FirstNodeId + NodeCount); + Y_VERIFY(nodeId >= FirstNodeId && nodeId < FirstNodeId + NodeCount); TEventsList result; GetMailbox(nodeId, hint).Capture(result); return result; @@ -992,7 +992,7 @@ namespace NActors { void TTestActorRuntimeBase::PushFront(TAutoPtr<IEventHandle>& ev) { TGuard<TMutex> guard(Mutex); ui32 nodeId = ev->GetRecipientRewrite().NodeId(); - Y_VERIFY(nodeId != 0); + Y_VERIFY(nodeId != 0); GetMailbox(nodeId, ev->GetRecipientRewrite().Hint()).PushFront(ev); } @@ -1002,7 +1002,7 @@ namespace NActors { if (*rit) { auto& ev = *rit; ui32 nodeId = ev->GetRecipientRewrite().NodeId(); - Y_VERIFY(nodeId != 0); + Y_VERIFY(nodeId != 0); GetMailbox(nodeId, ev->GetRecipientRewrite().Hint()).PushFront(ev); } } @@ -1012,7 +1012,7 @@ namespace NActors { void TTestActorRuntimeBase::PushMailboxEventsFront(ui32 hint, ui32 nodeId, TEventsList& events) { TGuard<TMutex> guard(Mutex); - Y_VERIFY(nodeId >= FirstNodeId && nodeId < FirstNodeId + NodeCount); + Y_VERIFY(nodeId >= FirstNodeId && nodeId < FirstNodeId + NodeCount); TEventsList result; GetMailbox(nodeId, hint).PushFront(events); events.clear(); @@ -1081,7 +1081,7 @@ namespace NActors { Runtime.GetMailbox(edgeActor.NodeId(), edgeActor.Hint()).Capture(events); auto mboxId = TEventMailboxId(edgeActor.NodeId(), edgeActor.Hint()); auto storeIt = Store.find(mboxId); - Y_VERIFY(storeIt == Store.end()); + Y_VERIFY(storeIt == Store.end()); storeIt = Store.insert(std::make_pair(mboxId, new TEventMailBox)).first; storeIt->second->PushFront(events); if (!events.empty()) @@ -1213,13 +1213,13 @@ namespace NActors { break; } default: - Y_FAIL("Unknown action"); + Y_FAIL("Unknown action"); } } } } - Y_VERIFY(mboxIt != currentMailboxes.end()); + Y_VERIFY(mboxIt != currentMailboxes.end()); if (!isIgnored && !CurrentDispatchContext->PrevContext && !restrictedMailboxes && mboxIt->second->IsEmpty() && mboxIt->second->IsScheduledEmpty() && @@ -1230,7 +1230,7 @@ namespace NActors { if (mboxIt == currentMailboxes.end()) { mboxIt = currentMailboxes.begin(); } - Y_VERIFY(endWithMboxIt != currentMailboxes.end()); + Y_VERIFY(endWithMboxIt != currentMailboxes.end()); if (mboxIt == endWithMboxIt) { break; } @@ -1384,14 +1384,14 @@ namespace NActors { void TTestActorRuntimeBase::Send(IEventHandle* ev, ui32 senderNodeIndex, bool viaActorSystem) { TGuard<TMutex> guard(Mutex); - Y_VERIFY(senderNodeIndex < NodeCount, "senderNodeIndex# %" PRIu32 " < NodeCount# %" PRIu32, + Y_VERIFY(senderNodeIndex < NodeCount, "senderNodeIndex# %" PRIu32 " < NodeCount# %" PRIu32, senderNodeIndex, NodeCount); SendInternal(ev, senderNodeIndex, viaActorSystem); } void TTestActorRuntimeBase::Schedule(IEventHandle* ev, const TDuration& duration, ui32 nodeIndex) { TGuard<TMutex> guard(Mutex); - Y_VERIFY(nodeIndex < NodeCount); + Y_VERIFY(nodeIndex < NodeCount); ui32 nodeId = FirstNodeId + nodeIndex; ui32 mailboxHint = ev->GetRecipientRewrite().Hint(); TInstant deadline = TInstant::MicroSeconds(CurrentTimestamp) + duration; @@ -1416,7 +1416,7 @@ namespace NActors { TActorId TTestActorRuntimeBase::GetLocalServiceId(const TActorId& serviceId, ui32 nodeIndex) { TGuard<TMutex> guard(Mutex); - Y_VERIFY(nodeIndex < NodeCount); + Y_VERIFY(nodeIndex < NodeCount); TNodeDataBase* node = Nodes[FirstNodeId + nodeIndex].Get(); return node->ActorSystem->LookupLocalService(serviceId); } @@ -1456,15 +1456,15 @@ namespace NActors { } } - Y_VERIFY(dispatchCount < 1000, "Hard limit to prevent endless loop"); + Y_VERIFY(dispatchCount < 1000, "Hard limit to prevent endless loop"); } } TActorId TTestActorRuntimeBase::GetInterconnectProxy(ui32 nodeIndexFrom, ui32 nodeIndexTo) { TGuard<TMutex> guard(Mutex); - Y_VERIFY(nodeIndexFrom < NodeCount); - Y_VERIFY(nodeIndexTo < NodeCount); - Y_VERIFY(nodeIndexFrom != nodeIndexTo); + Y_VERIFY(nodeIndexFrom < NodeCount); + Y_VERIFY(nodeIndexTo < NodeCount); + Y_VERIFY(nodeIndexFrom != nodeIndexTo); TNodeDataBase* node = Nodes[FirstNodeId + nodeIndexFrom].Get(); return node->ActorSystem->InterconnectProxy(FirstNodeId + nodeIndexTo); } @@ -1483,13 +1483,13 @@ namespace NActors { IActor* TTestActorRuntimeBase::FindActor(const TActorId& actorId, ui32 nodeIndex) const { TGuard<TMutex> guard(Mutex); if (nodeIndex == Max<ui32>()) { - Y_VERIFY(actorId.NodeId()); + Y_VERIFY(actorId.NodeId()); nodeIndex = actorId.NodeId() - FirstNodeId; } - Y_VERIFY(nodeIndex < NodeCount); + Y_VERIFY(nodeIndex < NodeCount); auto nodeIt = Nodes.find(FirstNodeId + nodeIndex); - Y_VERIFY(nodeIt != Nodes.end()); + Y_VERIFY(nodeIt != Nodes.end()); TNodeDataBase* node = nodeIt->second.Get(); return FindActor(actorId, node); } @@ -1516,7 +1516,7 @@ namespace NActors { TIntrusivePtr<NMonitoring::TDynamicCounters> TTestActorRuntimeBase::GetDynamicCounters(ui32 nodeIndex) { TGuard<TMutex> guard(Mutex); - Y_VERIFY(nodeIndex < NodeCount); + Y_VERIFY(nodeIndex < NodeCount); ui32 nodeId = FirstNodeId + nodeIndex; TNodeDataBase* node = Nodes[nodeId].Get(); return node->DynamicCounters; @@ -1527,7 +1527,7 @@ namespace NActors { } void TTestActorRuntimeBase::SendInternal(IEventHandle* ev, ui32 nodeIndex, bool viaActorSystem) { - Y_VERIFY(nodeIndex < NodeCount); + Y_VERIFY(nodeIndex < NodeCount); ui32 nodeId = FirstNodeId + nodeIndex; TNodeDataBase* node = Nodes[nodeId].Get(); ui32 targetNode = ev->GetRecipientRewrite().NodeId(); @@ -1536,7 +1536,7 @@ namespace NActors { targetNodeIndex = nodeIndex; } else { targetNodeIndex = targetNode - FirstNodeId; - Y_VERIFY(targetNodeIndex < NodeCount); + Y_VERIFY(targetNodeIndex < NodeCount); } if (viaActorSystem || UseRealThreads || ev->GetRecipientRewrite().IsService() || (targetNodeIndex != nodeIndex)) { @@ -1544,7 +1544,7 @@ namespace NActors { return; } - Y_VERIFY(!ev->GetRecipientRewrite().IsService() && (targetNodeIndex == nodeIndex)); + Y_VERIFY(!ev->GetRecipientRewrite().IsService() && (targetNodeIndex == nodeIndex)); TAutoPtr<IEventHandle> evHolder(ev); if (!AllowSendFrom(node, evHolder)) { @@ -1705,7 +1705,7 @@ namespace NActors { for (auto& x : Nodes) { return x.second->ActorSystem.Get(); } - Y_FAIL("Don't use this method."); + Y_FAIL("Don't use this method."); } TActorSystem* TTestActorRuntimeBase::GetActorSystem(ui32 nodeId) { @@ -1785,7 +1785,7 @@ namespace NActors { , ReplyChecker(createReplyChecker()) { if (IsSync) { - Y_VERIFY(!runtime->IsRealThreads()); + Y_VERIFY(!runtime->IsRealThreads()); } } @@ -1811,7 +1811,7 @@ namespace NActors { } STFUNC(Reply) { - Y_VERIFY(!HasReply); + Y_VERIFY(!HasReply); IEventHandle *requestEv = Context->Queue->Head(); TActorId originalSender = requestEv->Sender; HasReply = !ReplyChecker->IsWaitingForMoreResponses(ev.Get()); diff --git a/library/cpp/actors/testlib/test_runtime.h b/library/cpp/actors/testlib/test_runtime.h index 26e3b45c984..ee85ddadfa6 100644 --- a/library/cpp/actors/testlib/test_runtime.h +++ b/library/cpp/actors/testlib/test_runtime.h @@ -292,7 +292,7 @@ namespace NActors { handle.Destroy(); const ui32 eventType = TEvent::EventType; WaitForEdgeEvents([&](TTestActorRuntimeBase& runtime, TAutoPtr<IEventHandle>& event) { - Y_UNUSED(runtime); + Y_UNUSED(runtime); if (event->GetTypeRewrite() != eventType) return false; @@ -306,7 +306,7 @@ namespace NActors { }, {}, simTimeout); if (simTimeout == TDuration::Max()) - Y_VERIFY(handle); + Y_VERIFY(handle); if (handle) { return reinterpret_cast<TAutoPtr<TEventHandle<TEvent>>&>(handle)->Get(); diff --git a/library/cpp/actors/util/affinity.cpp b/library/cpp/actors/util/affinity.cpp index cc1b6e70ec8..95ff465f37b 100644 --- a/library/cpp/actors/util/affinity.cpp +++ b/library/cpp/actors/util/affinity.cpp @@ -12,7 +12,7 @@ public: TImpl() { #ifdef _linux_ int ar = sched_getaffinity(0, sizeof(cpu_set_t), &Mask); - Y_VERIFY_DEBUG(ar == 0); + Y_VERIFY_DEBUG(ar == 0); #endif } @@ -33,7 +33,7 @@ public: void Set() const { #ifdef _linux_ int ar = sched_setaffinity(0, sizeof(cpu_set_t), &Mask); - Y_VERIFY_DEBUG(ar == 0); + Y_VERIFY_DEBUG(ar == 0); #endif } diff --git a/library/cpp/actors/util/queue_oneone_inplace.h b/library/cpp/actors/util/queue_oneone_inplace.h index d7ec8bb21c6..e00f05b20df 100644 --- a/library/cpp/actors/util/queue_oneone_inplace.h +++ b/library/cpp/actors/util/queue_oneone_inplace.h @@ -48,7 +48,7 @@ public: } ~TOneOneQueueInplace() { - Y_VERIFY_DEBUG(Head() == 0); + Y_VERIFY_DEBUG(Head() == 0); delete ReadFrom; } diff --git a/library/cpp/actors/util/ticket_lock.h b/library/cpp/actors/util/ticket_lock.h index 3b1fa803937..bf0e3d795b9 100644 --- a/library/cpp/actors/util/ticket_lock.h +++ b/library/cpp/actors/util/ticket_lock.h @@ -23,7 +23,7 @@ public: ui32 revolves = 0; const ui32 ticket = AtomicUi32Increment(&TicketIn) - 1; while (ticket != AtomicLoad(&TicketOut)) { - Y_VERIFY_DEBUG(ticket >= AtomicLoad(&TicketOut)); + Y_VERIFY_DEBUG(ticket >= AtomicLoad(&TicketOut)); SpinLockPause(); ++revolves; } diff --git a/library/cpp/actors/util/unordered_cache.h b/library/cpp/actors/util/unordered_cache.h index 76f036c0cf0..06e45714522 100644 --- a/library/cpp/actors/util/unordered_cache.h +++ b/library/cpp/actors/util/unordered_cache.h @@ -100,7 +100,7 @@ private: } void WriteOne(TLockedWriter& lock, T x) { - Y_VERIFY_DEBUG(x != 0); + Y_VERIFY_DEBUG(x != 0); const ui32 pos = AtomicLoad(&lock.Slot->WritePosition); if (pos != TChunk::EntriesCount) { @@ -127,7 +127,7 @@ public: } ~TUnorderedCache() { - Y_VERIFY(!Pop(0)); + Y_VERIFY(!Pop(0)); for (ui64 i = 0; i < Concurrency; ++i) { if (ReadSlots[i].ReadFrom) { diff --git a/library/cpp/actors/wilson/wilson_event.h b/library/cpp/actors/wilson/wilson_event.h index 7d89c33b518..18105826758 100644 --- a/library/cpp/actors/wilson/wilson_event.h +++ b/library/cpp/actors/wilson/wilson_event.h @@ -76,7 +76,7 @@ namespace NWilson { using TParamPack = N##EVENT_NAME##Params::TParamPack; \ TParamPack ParamPack; \ \ - void Output(IOutputStream& str) { \ + void Output(IOutputStream& str) { \ str << #EVENT_NAME << "{"; \ __UNROLL_PARAMS(__OUTPUT_PARAM, ##__VA_ARGS__) \ str << "}"; \ diff --git a/library/cpp/actors/wilson/wilson_trace.h b/library/cpp/actors/wilson/wilson_trace.h index 3d1ca505623..997d7e2462c 100644 --- a/library/cpp/actors/wilson/wilson_trace.h +++ b/library/cpp/actors/wilson/wilson_trace.h @@ -101,7 +101,7 @@ namespace NWilson { } // Output trace id into a string stream - void Output(IOutputStream& s, const TTraceId& parentTraceId) const { + void Output(IOutputStream& s, const TTraceId& parentTraceId) const { union { ui8 buffer[3 * sizeof(ui64)]; struct { @@ -122,7 +122,7 @@ namespace NWilson { } // output just span id into stream - void OutputSpanId(IOutputStream& s) const { + void OutputSpanId(IOutputStream& s) const { const size_t base64size = Base64EncodeBufSize(sizeof(SpanId)); char base64[base64size]; char* end = Base64Encode(base64, reinterpret_cast<const ui8*>(&SpanId), sizeof(SpanId)); diff --git a/library/cpp/archive/yarchive.cpp b/library/cpp/archive/yarchive.cpp index 1becc3e5dac..78aaa17525b 100644 --- a/library/cpp/archive/yarchive.cpp +++ b/library/cpp/archive/yarchive.cpp @@ -2,33 +2,33 @@ #include <util/generic/algorithm.h> #include <util/generic/hash.h> -#include <util/generic/utility.h> +#include <util/generic/utility.h> #include <util/generic/vector.h> #include <util/generic/yexception.h> -#include <util/memory/blob.h> -#include <util/memory/tempbuf.h> -#include <util/stream/input.h> -#include <util/stream/length.h> -#include <util/stream/mem.h> -#include <util/stream/output.h> -#include <util/stream/zlib.h> -#include <util/system/byteorder.h> -#include <util/ysaveload.h> +#include <util/memory/blob.h> +#include <util/memory/tempbuf.h> +#include <util/stream/input.h> +#include <util/stream/length.h> +#include <util/stream/mem.h> +#include <util/stream/output.h> +#include <util/stream/zlib.h> +#include <util/system/byteorder.h> +#include <util/ysaveload.h> template <class T> -static inline void ESSave(IOutputStream* out, const T& t_in) { +static inline void ESSave(IOutputStream* out, const T& t_in) { T t = HostToLittle(t_in); out->Write((const void*)&t, sizeof(t)); } -static inline void ESSave(IOutputStream* out, const TString& s) { +static inline void ESSave(IOutputStream* out, const TString& s) { ESSave(out, (ui32) s.size()); out->Write(s.data(), s.size()); } template <class T> -static inline T ESLoad(IInputStream* in) { +static inline T ESLoad(IInputStream* in) { T t = T(); if (in->Load(&t, sizeof(t)) != sizeof(t)) { @@ -39,7 +39,7 @@ static inline T ESLoad(IInputStream* in) { } template <> -inline TString ESLoad<TString>(IInputStream* in) { +inline TString ESLoad<TString>(IInputStream* in) { size_t len = ESLoad<ui32>(in); TString ret; TTempBuf tmp; @@ -69,7 +69,7 @@ namespace { { } - inline TArchiveRecordDescriptor(IInputStream* in) + inline TArchiveRecordDescriptor(IInputStream* in) : Off_(ESLoad<ui64>(in)) , Len_(ESLoad<ui64>(in)) , Name_(ESLoad<TString>(in)) @@ -78,7 +78,7 @@ namespace { inline ~TArchiveRecordDescriptor() = default; - inline void SaveTo(IOutputStream* out) const { + inline void SaveTo(IOutputStream* out) const { ESSave(out, Off_); ESSave(out, Len_); ESSave(out, Name_); @@ -109,7 +109,7 @@ class TArchiveWriter::TImpl { using TDict = THashMap<TString, TArchiveRecordDescriptorRef>; public: - inline TImpl(IOutputStream& out, bool compress) + inline TImpl(IOutputStream& out, bool compress) : Off_(0) , Out_(&out) , UseCompression(compress) @@ -123,15 +123,15 @@ public: } inline void Finish() { - TCountingOutput out(Out_); + TCountingOutput out(Out_); { TZLibCompress compress(&out); ESSave(&compress, (ui32)Dict_.size()); - for (const auto& kv : Dict_) { - kv.second->SaveTo(&compress); + for (const auto& kv : Dict_) { + kv.second->SaveTo(&compress); } ESSave(&compress, static_cast<ui8>(UseCompression)); @@ -139,15 +139,15 @@ public: compress.Finish(); } - ESSave(Out_, out.Counter()); + ESSave(Out_, out.Counter()); Out_->Flush(); } - inline void Add(const TString& key, IInputStream* src) { + inline void Add(const TString& key, IInputStream* src) { Y_ENSURE(!Dict_.contains(key), "key " << key.data() << " already stored"); - TCountingOutput out(Out_); + TCountingOutput out(Out_); if (UseCompression) { TZLibCompress compress(&out); TransferData(src, &compress); @@ -166,10 +166,10 @@ public: out.Finish(); } - TArchiveRecordDescriptorRef descr(new TArchiveRecordDescriptor(Off_, out.Counter(), key)); + TArchiveRecordDescriptorRef descr(new TArchiveRecordDescriptor(Off_, out.Counter(), key)); Dict_[key] = descr; - Off_ += out.Counter(); + Off_ += out.Counter(); } inline void AddSynonym(const TString& existingKey, const TString& newKey) { @@ -184,12 +184,12 @@ public: private: ui64 Off_; - IOutputStream* Out_; + IOutputStream* Out_; TDict Dict_; const bool UseCompression; }; -TArchiveWriter::TArchiveWriter(IOutputStream* out, bool compress) +TArchiveWriter::TArchiveWriter(IOutputStream* out, bool compress) : Impl_(new TImpl(*out, compress)) { } @@ -214,7 +214,7 @@ void TArchiveWriter::Finish() { } } -void TArchiveWriter::Add(const TString& key, IInputStream* src) { +void TArchiveWriter::Add(const TString& key, IInputStream* src) { Y_ENSURE(Impl_.Get(), "archive already closed"); Impl_->Add(key, src); @@ -287,8 +287,8 @@ public: Recs_.push_back(descr); Dict_[descr->Name()] = descr; } - Sort(Recs_.begin(), Recs_.end(), [](const auto& lhs, const auto& rhs) -> bool { - return lhs->Offset() < rhs->Offset(); + Sort(Recs_.begin(), Recs_.end(), [](const auto& lhs, const auto& rhs) -> bool { + return lhs->Offset() < rhs->Offset(); }); try { @@ -311,11 +311,11 @@ public: ythrow yexception() << "incorrect index"; } - inline bool Has(const TStringBuf key) const { + inline bool Has(const TStringBuf key) const { return Dict_.contains(key); } - inline TAutoPtr<IInputStream> ObjectByKey(const TStringBuf key) const { + inline TAutoPtr<IInputStream> ObjectByKey(const TStringBuf key) const { TBlob subBlob = BlobByKey(key); if (UseDecompression) { @@ -325,7 +325,7 @@ public: } } - inline TBlob ObjectBlobByKey(const TStringBuf key) const { + inline TBlob ObjectBlobByKey(const TStringBuf key) const { TBlob subBlob = BlobByKey(key); if (UseDecompression) { @@ -336,8 +336,8 @@ public: } } - inline TBlob BlobByKey(const TStringBuf key) const { - const auto it = Dict_.find(key); + inline TBlob BlobByKey(const TStringBuf key) const { + const auto it = Dict_.find(key); Y_ENSURE(it != Dict_.end(), "key " << key.data() << " not found"); @@ -377,19 +377,19 @@ TString TArchiveReader::KeyByIndex(size_t n) const { return Impl_->KeyByIndex(n); } -bool TArchiveReader::Has(const TStringBuf key) const { +bool TArchiveReader::Has(const TStringBuf key) const { return Impl_->Has(key); } -TAutoPtr<IInputStream> TArchiveReader::ObjectByKey(const TStringBuf key) const { +TAutoPtr<IInputStream> TArchiveReader::ObjectByKey(const TStringBuf key) const { return Impl_->ObjectByKey(key); } -TBlob TArchiveReader::ObjectBlobByKey(const TStringBuf key) const { +TBlob TArchiveReader::ObjectBlobByKey(const TStringBuf key) const { return Impl_->ObjectBlobByKey(key); } -TBlob TArchiveReader::BlobByKey(const TStringBuf key) const { +TBlob TArchiveReader::BlobByKey(const TStringBuf key) const { return Impl_->BlobByKey(key); } diff --git a/library/cpp/archive/yarchive.h b/library/cpp/archive/yarchive.h index 8120bcb9402..50aaa253f25 100644 --- a/library/cpp/archive/yarchive.h +++ b/library/cpp/archive/yarchive.h @@ -2,15 +2,15 @@ #include "models_archive_reader.h" -#include <util/generic/fwd.h> +#include <util/generic/fwd.h> #include <util/generic/ptr.h> -class IInputStream; -class IOutputStream; - -class TBlob; - +class IInputStream; +class IOutputStream; + +class TBlob; + //noncompressed data will be stored with default alignment DEVTOOLS-4384 static constexpr size_t ArchiveWriterDefaultDataAlignment = 16; @@ -21,7 +21,7 @@ public: void Flush(); void Finish(); - void Add(const TString& key, IInputStream* src); + void Add(const TString& key, IInputStream* src); void AddSynonym(const TString& existingKey, const TString& newKey); private: diff --git a/library/cpp/archive/yarchive_ut.cpp b/library/cpp/archive/yarchive_ut.cpp index 602a1cdbbde..21b9eec40f0 100644 --- a/library/cpp/archive/yarchive_ut.cpp +++ b/library/cpp/archive/yarchive_ut.cpp @@ -5,7 +5,7 @@ #include <util/string/cast.h> #include <util/stream/file.h> #include <util/system/tempfile.h> -#include <util/memory/blob.h> +#include <util/memory/blob.h> class TArchiveTest: public TTestBase { UNIT_TEST_SUITE(TArchiveTest) @@ -56,7 +56,7 @@ void TArchiveTest::TestRead() { for (size_t i = 0; i < 1000; ++i) { const TString key = "/" + ToString(i); - TAutoPtr<IInputStream> is = r.ObjectByKey(key); + TAutoPtr<IInputStream> is = r.ObjectByKey(key); const TString data = is->ReadAll(); UNIT_ASSERT_EQUAL(data, "data" + ToString(i * 1000) + "dataend"); diff --git a/library/cpp/balloc/balloc.cpp b/library/cpp/balloc/balloc.cpp index fab489db4c5..6b96e943b7c 100644 --- a/library/cpp/balloc/balloc.cpp +++ b/library/cpp/balloc/balloc.cpp @@ -248,7 +248,7 @@ extern "C" void* realloc(void* oldPtr, size_t newSize) { NBalloc::TAllocHeader* header = (NBalloc::TAllocHeader*)oldPtr - 1; const size_t oldSize = header->AllocSize & ~NBalloc::SIGNATURE_MASK; const size_t signature = header->AllocSize & NBalloc::SIGNATURE_MASK; - if (Y_LIKELY((signature == NBalloc::ALIVE_SIGNATURE) || (signature == NBalloc::DISABLED_SIGNATURE))) { + if (Y_LIKELY((signature == NBalloc::ALIVE_SIGNATURE) || (signature == NBalloc::DISABLED_SIGNATURE))) { memcpy(newPtr, oldPtr, oldSize < newSize ? oldSize : newSize); NBalloc::Free(oldPtr); return newPtr; diff --git a/library/cpp/balloc/ya.make b/library/cpp/balloc/ya.make index d4457fbba99..5238973d490 100644 --- a/library/cpp/balloc/ya.make +++ b/library/cpp/balloc/ya.make @@ -8,20 +8,20 @@ OWNER( NO_UTIL() NO_COMPILER_WARNINGS() -IF (OS_WINDOWS) - PEERDIR( +IF (OS_WINDOWS) + PEERDIR( library/cpp/lfalloc - ) -ELSE() - SRCS( - balloc.cpp - malloc-info.cpp - ) + ) +ELSE() + SRCS( + balloc.cpp + malloc-info.cpp + ) PEERDIR( library/cpp/balloc/lib ) -ENDIF() +ENDIF() END() diff --git a/library/cpp/binsaver/bin_saver.cpp b/library/cpp/binsaver/bin_saver.cpp index fe0775af9f2..9bc28d14906 100644 --- a/library/cpp/binsaver/bin_saver.cpp +++ b/library/cpp/binsaver/bin_saver.cpp @@ -3,7 +3,7 @@ TClassFactory<IObjectBase>* pSaverClasses; void StartRegisterSaveload() { if (!pSaverClasses) - pSaverClasses = new TClassFactory<IObjectBase>; + pSaverClasses = new TClassFactory<IObjectBase>; } struct SBasicChunkInit { ~SBasicChunkInit() { @@ -15,7 +15,7 @@ struct SBasicChunkInit { ////////////////////////////////////////////////////////////////////////// void IBinSaver::StoreObject(IObjectBase* pObject) { if (pObject) { - Y_ASSERT(pSaverClasses->GetObjectTypeID(pObject) != -1 && "trying to save unregistered object"); + Y_ASSERT(pSaverClasses->GetObjectTypeID(pObject) != -1 && "trying to save unregistered object"); } ui64 ptrId = ((char*)pObject) - ((char*)nullptr); @@ -62,7 +62,7 @@ IObjectBase* IBinSaver::LoadObject() { int typeId; DataChunk(&typeId, sizeof(typeId)); IObjectBase* pObj = pSaverClasses->CreateObject(typeId); - Y_ASSERT(pObj != nullptr); + Y_ASSERT(pObj != nullptr); if (pObj == nullptr) { fprintf(stderr, "IBinSaver: trying to load unregistered object\n"); abort(); diff --git a/library/cpp/binsaver/bin_saver.h b/library/cpp/binsaver/bin_saver.h index 412424889f3..f37612c4fcb 100644 --- a/library/cpp/binsaver/bin_saver.h +++ b/library/cpp/binsaver/bin_saver.h @@ -6,13 +6,13 @@ #include <library/cpp/containers/2d_array/2d_array.h> #include <util/generic/hash_set.h> -#include <util/generic/buffer.h> +#include <util/generic/buffer.h> #include <util/generic/list.h> #include <util/generic/maybe.h> #include <util/generic/bitmap.h> #include <util/generic/variant.h> #include <util/generic/ylimits.h> -#include <util/memory/blob.h> +#include <util/memory/blob.h> #include <util/digest/murmur.h> #include <array> @@ -267,7 +267,7 @@ private: // storing/loading pointers to objects void StoreObject(IObjectBase* pObject); - IObjectBase* LoadObject(); + IObjectBase* LoadObject(); bool bRead; TBufferedStream<> File; @@ -310,21 +310,21 @@ public: return 0; } int Add(const chunk_id, TBlob* blob) { - if (bRead) { - ui64 size = 0; - File.Read(&size, sizeof(size)); + if (bRead) { + ui64 size = 0; + File.Read(&size, sizeof(size)); TBuffer buffer; buffer.Advance(size); - if (size > 0) - File.Read(buffer.Data(), buffer.Size()); + if (size > 0) + File.Read(buffer.Data(), buffer.Size()); (*blob) = TBlob::FromBuffer(buffer); - } else { - const ui64 size = blob->Size(); - File.Write(&size, sizeof(size)); - File.Write(blob->Data(), blob->Size()); - } - return 0; - } + } else { + const ui64 size = blob->Size(); + File.Write(&size, sizeof(size)); + File.Write(blob->Data(), blob->Size()); + } + return 0; + } template <class T1, class TA> int Add(const chunk_id, TVector<T1, TA>* pVec) { if (HasNonTrivialSerializer<T1>(0u)) @@ -629,7 +629,7 @@ struct TRegisterSaveLoadType { int operator&(IBinSaver& f) override { \ f.AddMulti(__VA_ARGS__); \ return 0; \ - } + } #define SAVELOAD_OVERRIDE(base, ...) \ int operator&(IBinSaver& f) override { \ diff --git a/library/cpp/binsaver/blob_io.h b/library/cpp/binsaver/blob_io.h index abe518ef306..e0b7956a886 100644 --- a/library/cpp/binsaver/blob_io.h +++ b/library/cpp/binsaver/blob_io.h @@ -10,7 +10,7 @@ class TYaBlobStream: public IBinaryStream { i64 Pos; int WriteImpl(const void*, int) override { - Y_ASSERT(0); + Y_ASSERT(0); return 0; } int ReadImpl(void* userBuffer, int size) override { diff --git a/library/cpp/binsaver/buffered_io.cpp b/library/cpp/binsaver/buffered_io.cpp index dd88b04bc5d..073ba0c46ee 100644 --- a/library/cpp/binsaver/buffered_io.cpp +++ b/library/cpp/binsaver/buffered_io.cpp @@ -1,31 +1,31 @@ #include "buffered_io.h" i64 IBinaryStream::LongWrite(const void* userBuffer, i64 size) { - Y_VERIFY(size >= 0, "IBinaryStream::Write() called with a negative buffer size."); + Y_VERIFY(size >= 0, "IBinaryStream::Write() called with a negative buffer size."); i64 leftToWrite = size; while (leftToWrite != 0) { int writeSz = static_cast<int>(Min<i64>(leftToWrite, std::numeric_limits<int>::max())); int written = WriteImpl(userBuffer, writeSz); - Y_ASSERT(written <= writeSz); + Y_ASSERT(written <= writeSz); leftToWrite -= written; // Assumption: if WriteImpl(buf, writeSz) returns < writeSz, the stream is // full and there's no sense in continuing. if (written < writeSz) break; } - Y_ASSERT(size >= leftToWrite); + Y_ASSERT(size >= leftToWrite); return size - leftToWrite; } i64 IBinaryStream::LongRead(void* userBuffer, i64 size) { - Y_VERIFY(size >= 0, "IBinaryStream::Read() called with a negative buffer size."); + Y_VERIFY(size >= 0, "IBinaryStream::Read() called with a negative buffer size."); i64 leftToRead = size; while (leftToRead != 0) { int readSz = static_cast<int>(Min<i64>(leftToRead, std::numeric_limits<int>::max())); int read = ReadImpl(userBuffer, readSz); - Y_ASSERT(read <= readSz); + Y_ASSERT(read <= readSz); leftToRead -= read; // Assumption: if ReadImpl(buf, readSz) returns < readSz, the stream is // full and there's no sense in continuing. @@ -34,6 +34,6 @@ i64 IBinaryStream::LongRead(void* userBuffer, i64 size) { break; } } - Y_ASSERT(size >= leftToRead); + Y_ASSERT(size >= leftToRead); return size - leftToRead; } diff --git a/library/cpp/binsaver/buffered_io.h b/library/cpp/binsaver/buffered_io.h index 75465c9c5ca..bc5456923db 100644 --- a/library/cpp/binsaver/buffered_io.h +++ b/library/cpp/binsaver/buffered_io.h @@ -97,7 +97,7 @@ public: Flush(); } void Flush() { - Y_ASSERT(!bIsReading); + Y_ASSERT(!bIsReading); if (bIsReading) return; Stream.Write(Buf, Pos); @@ -108,7 +108,7 @@ public: return bIsEof; } inline void Read(void* userBuffer, i64 size) { - Y_ASSERT(bIsReading); + Y_ASSERT(bIsReading); if (!bIsEof && size + Pos <= BufSize) { memcpy(userBuffer, Buf + Pos, size); Pos += size; @@ -117,7 +117,7 @@ public: ReadComplex(userBuffer, size); } inline void Write(const void* userBuffer, i64 size) { - Y_ASSERT(!bIsReading); + Y_ASSERT(!bIsReading); if (Pos + size < N_SIZE) { memcpy(Buf + Pos, userBuffer, size); Pos += size; diff --git a/library/cpp/binsaver/class_factory.h b/library/cpp/binsaver/class_factory.h index e83512331ba..5069b5f161d 100644 --- a/library/cpp/binsaver/class_factory.h +++ b/library/cpp/binsaver/class_factory.h @@ -77,8 +77,8 @@ public: template <class T> void TClassFactory<T>::RegisterTypeBase(int nTypeID, newFunc func, VFT vft) { if (typeInfo.find(nTypeID) != typeInfo.end()) { - TObj<IObjectBase> o1 = typeInfo[nTypeID](); - TObj<IObjectBase> o2 = func(); + TObj<IObjectBase> o1 = typeInfo[nTypeID](); + TObj<IObjectBase> o2 = func(); // stupid clang warning auto& o1v = *o1; diff --git a/library/cpp/binsaver/ut/binsaver_ut.cpp b/library/cpp/binsaver/ut/binsaver_ut.cpp index 37eba5406f2..f8275d63d06 100644 --- a/library/cpp/binsaver/ut/binsaver_ut.cpp +++ b/library/cpp/binsaver/ut/binsaver_ut.cpp @@ -67,8 +67,8 @@ static bool operator==(const TBlob& l, const TBlob& r) { return TStringBuf(l.AsCharPtr(), l.Size()) == TStringBuf(r.AsCharPtr(), r.Size()); } -Y_UNIT_TEST_SUITE(BinSaver){ - Y_UNIT_TEST(HasTrivialSerializer){ +Y_UNIT_TEST_SUITE(BinSaver){ + Y_UNIT_TEST(HasTrivialSerializer){ UNIT_ASSERT(!IBinSaver::HasNonTrivialSerializer<TBinarySerializable>(0u)); UNIT_ASSERT(!IBinSaver::HasNonTrivialSerializer<TNonBinarySerializable>(0u)); UNIT_ASSERT(IBinSaver::HasNonTrivialSerializer<TCustomSerializer>(0u)); @@ -79,33 +79,33 @@ UNIT_ASSERT(IBinSaver::HasNonTrivialSerializer<TVector<TCustomSerializer>>(0u)); } -Y_UNIT_TEST(TestStroka) { +Y_UNIT_TEST(TestStroka) { TestBinSaverSerialization(TString("QWERTY")); } -Y_UNIT_TEST(TestMoveOnlyType) { +Y_UNIT_TEST(TestMoveOnlyType) { TestBinSaverSerializationToBuffer(TMoveOnlyType()); } -Y_UNIT_TEST(TestVectorStrok) { +Y_UNIT_TEST(TestVectorStrok) { TestBinSaverSerialization(TVector<TString>{"A", "B", "C"}); } -Y_UNIT_TEST(TestCArray) { +Y_UNIT_TEST(TestCArray) { TestBinSaverSerialization(TTypeWithArray()); } -Y_UNIT_TEST(TestSets) { +Y_UNIT_TEST(TestSets) { TestBinSaverSerialization(THashSet<TString>{"A", "B", "C"}); TestBinSaverSerialization(TSet<TString>{"A", "B", "C"}); } -Y_UNIT_TEST(TestMaps) { +Y_UNIT_TEST(TestMaps) { TestBinSaverSerialization(THashMap<TString, ui32>{{"A", 1}, {"B", 2}, {"C", 3}}); TestBinSaverSerialization(TMap<TString, ui32>{{"A", 1}, {"B", 2}, {"C", 3}}); } -Y_UNIT_TEST(TestBlob) { +Y_UNIT_TEST(TestBlob) { TestBinSaverSerialization(TBlob::FromStringSingleThreaded("qwerty")); } @@ -125,7 +125,7 @@ Y_UNIT_TEST(TestVariant) { } } -Y_UNIT_TEST(TestPod) { +Y_UNIT_TEST(TestPod) { struct TPod { ui32 A = 5; ui64 B = 7; @@ -141,7 +141,7 @@ Y_UNIT_TEST(TestPod) { TestBinSaverSerialization(TVector<TPod>{custom}); } -Y_UNIT_TEST(TestSubPod) { +Y_UNIT_TEST(TestSubPod) { struct TPod { struct TSub { ui32 X = 10; @@ -166,7 +166,7 @@ Y_UNIT_TEST(TestSubPod) { TestBinSaverSerialization(TVector<TPod>{custom}); } -Y_UNIT_TEST(TestMemberAndOpIsMain) { +Y_UNIT_TEST(TestMemberAndOpIsMain) { struct TBase { TString S; virtual int operator&(IBinSaver& f) { diff --git a/library/cpp/binsaver/util_stream_io.h b/library/cpp/binsaver/util_stream_io.h index d65d630b932..a00670e0332 100644 --- a/library/cpp/binsaver/util_stream_io.h +++ b/library/cpp/binsaver/util_stream_io.h @@ -10,7 +10,7 @@ class TYaStreamInput: public IBinaryStream { IInputStream& Stream; int WriteImpl(const void*, int) override { - Y_ASSERT(0); + Y_ASSERT(0); return 0; } int ReadImpl(void* userBuffer, int size) override { @@ -53,7 +53,7 @@ class TYaStreamOutput: public IBinaryStream { return size; } int ReadImpl(void*, int) override { - Y_ASSERT(0); + Y_ASSERT(0); return 0; } bool IsValid() const override { diff --git a/library/cpp/bit_io/bitinput_impl.h b/library/cpp/bit_io/bitinput_impl.h index b13fbef1012..05a57ecd71f 100644 --- a/library/cpp/bit_io/bitinput_impl.h +++ b/library/cpp/bit_io/bitinput_impl.h @@ -1,8 +1,8 @@ #pragma once -#include <util/generic/bitops.h> +#include <util/generic/bitops.h> #include <util/system/unaligned_mem.h> - + namespace NBitIO { class TBitInputImpl { i64 RealStart; @@ -51,7 +51,7 @@ namespace NBitIO { BOffset += bits; if (BOffset < FakeStart) return true; - if (Y_UNLIKELY(BOffset > Length)) { + if (Y_UNLIKELY(BOffset > Length)) { result = 0; BOffset -= bits; return false; @@ -84,7 +84,7 @@ namespace NBitIO { template <typename T> Y_FORCE_INLINE static void CopyToResult(T& result, ui64 r64, ui64 bits, ui64 skipbits) { - result = (result & InverseMaskLowerBits(bits, skipbits)) | (r64 << skipbits); + result = (result & InverseMaskLowerBits(bits, skipbits)) | (r64 << skipbits); } public: diff --git a/library/cpp/bit_io/bitoutput.h b/library/cpp/bit_io/bitoutput.h index 2b886c1f026..0b4766520ed 100644 --- a/library/cpp/bit_io/bitoutput.h +++ b/library/cpp/bit_io/bitoutput.h @@ -4,7 +4,7 @@ #include <util/stream/output.h> #include <util/system/yassert.h> -#include <util/generic/bitops.h> +#include <util/generic/bitops.h> #include <util/generic/vector.h> #include <util/generic/yexception.h> @@ -148,7 +148,7 @@ namespace NBitIO { public: void WriteData(const char* begin, const char* end) { size_t sz = end - begin; - Y_VERIFY(sz <= Left, " "); + Y_VERIFY(sz <= Left, " "); memcpy(Data, begin, sz); Data += sz; Left -= sz; @@ -172,21 +172,21 @@ namespace NBitIO { using TBitOutputYVector = TBitOutputVector<TVector<char>>; class TBitOutputStreamImpl { - IOutputStream* Out; + IOutputStream* Out; public: void WriteData(const char* begin, const char* end) { Out->Write(begin, end - begin); } - TBitOutputStreamImpl(IOutputStream* out) + TBitOutputStreamImpl(IOutputStream* out) : Out(out) { } }; struct TBitOutputStream: public TBitOutputStreamImpl, public TBitOutputBase<TBitOutputStreamImpl> { - inline TBitOutputStream(IOutputStream* out) + inline TBitOutputStream(IOutputStream* out) : TBitOutputStreamImpl(out) , TBitOutputBase<TBitOutputStreamImpl>(this) { diff --git a/library/cpp/blockcodecs/codecs_ut.cpp b/library/cpp/blockcodecs/codecs_ut.cpp index bfe5a236909..d94a151075a 100644 --- a/library/cpp/blockcodecs/codecs_ut.cpp +++ b/library/cpp/blockcodecs/codecs_ut.cpp @@ -7,7 +7,7 @@ #include <util/string/join.h> #include <util/digest/multi.h> -Y_UNIT_TEST_SUITE(TBlockCodecsTest) { +Y_UNIT_TEST_SUITE(TBlockCodecsTest) { using namespace NBlockCodecs; TBuffer Buffer(TStringBuf b) { @@ -67,79 +67,79 @@ Y_UNIT_TEST_SUITE(TBlockCodecsTest) { } } - Y_UNIT_TEST(TestAllAtOnce0) { + Y_UNIT_TEST(TestAllAtOnce0) { TestAllAtOnce(20, 0); } - Y_UNIT_TEST(TestAllAtOnce1) { + Y_UNIT_TEST(TestAllAtOnce1) { TestAllAtOnce(20, 1); } - Y_UNIT_TEST(TestAllAtOnce2) { + Y_UNIT_TEST(TestAllAtOnce2) { TestAllAtOnce(20, 2); } - Y_UNIT_TEST(TestAllAtOnce3) { + Y_UNIT_TEST(TestAllAtOnce3) { TestAllAtOnce(20, 3); } - Y_UNIT_TEST(TestAllAtOnce4) { + Y_UNIT_TEST(TestAllAtOnce4) { TestAllAtOnce(20, 4); } - Y_UNIT_TEST(TestAllAtOnce5) { + Y_UNIT_TEST(TestAllAtOnce5) { TestAllAtOnce(20, 5); } - Y_UNIT_TEST(TestAllAtOnce6) { + Y_UNIT_TEST(TestAllAtOnce6) { TestAllAtOnce(20, 6); } - Y_UNIT_TEST(TestAllAtOnce7) { + Y_UNIT_TEST(TestAllAtOnce7) { TestAllAtOnce(20, 7); } - Y_UNIT_TEST(TestAllAtOnce8) { + Y_UNIT_TEST(TestAllAtOnce8) { TestAllAtOnce(20, 8); } - Y_UNIT_TEST(TestAllAtOnce9) { + Y_UNIT_TEST(TestAllAtOnce9) { TestAllAtOnce(20, 9); } - Y_UNIT_TEST(TestAllAtOnce10) { + Y_UNIT_TEST(TestAllAtOnce10) { TestAllAtOnce(20, 10); } - Y_UNIT_TEST(TestAllAtOnce12) { + Y_UNIT_TEST(TestAllAtOnce12) { TestAllAtOnce(20, 12); } - Y_UNIT_TEST(TestAllAtOnce13) { + Y_UNIT_TEST(TestAllAtOnce13) { TestAllAtOnce(20, 13); } - Y_UNIT_TEST(TestAllAtOnce14) { + Y_UNIT_TEST(TestAllAtOnce14) { TestAllAtOnce(20, 14); } - Y_UNIT_TEST(TestAllAtOnce15) { + Y_UNIT_TEST(TestAllAtOnce15) { TestAllAtOnce(20, 15); } - Y_UNIT_TEST(TestAllAtOnce16) { + Y_UNIT_TEST(TestAllAtOnce16) { TestAllAtOnce(20, 16); } - Y_UNIT_TEST(TestAllAtOnce17) { + Y_UNIT_TEST(TestAllAtOnce17) { TestAllAtOnce(20, 17); } - Y_UNIT_TEST(TestAllAtOnce18) { + Y_UNIT_TEST(TestAllAtOnce18) { TestAllAtOnce(20, 18); } - Y_UNIT_TEST(TestAllAtOnce19) { + Y_UNIT_TEST(TestAllAtOnce19) { TestAllAtOnce(20, 19); } @@ -190,83 +190,83 @@ Y_UNIT_TEST_SUITE(TBlockCodecsTest) { } } - Y_UNIT_TEST(TestStreams0) { + Y_UNIT_TEST(TestStreams0) { TestStreams(20, 0); } - Y_UNIT_TEST(TestStreams1) { + Y_UNIT_TEST(TestStreams1) { TestStreams(20, 1); } - Y_UNIT_TEST(TestStreams2) { + Y_UNIT_TEST(TestStreams2) { TestStreams(20, 2); } - Y_UNIT_TEST(TestStreams3) { + Y_UNIT_TEST(TestStreams3) { TestStreams(20, 3); } - Y_UNIT_TEST(TestStreams4) { + Y_UNIT_TEST(TestStreams4) { TestStreams(20, 4); } - Y_UNIT_TEST(TestStreams5) { + Y_UNIT_TEST(TestStreams5) { TestStreams(20, 5); } - Y_UNIT_TEST(TestStreams6) { + Y_UNIT_TEST(TestStreams6) { TestStreams(20, 6); } - Y_UNIT_TEST(TestStreams7) { + Y_UNIT_TEST(TestStreams7) { TestStreams(20, 7); } - Y_UNIT_TEST(TestStreams8) { + Y_UNIT_TEST(TestStreams8) { TestStreams(20, 8); } - Y_UNIT_TEST(TestStreams9) { + Y_UNIT_TEST(TestStreams9) { TestStreams(20, 9); } - Y_UNIT_TEST(TestStreams10) { + Y_UNIT_TEST(TestStreams10) { TestStreams(20, 10); } - Y_UNIT_TEST(TestStreams11) { + Y_UNIT_TEST(TestStreams11) { TestStreams(20, 11); } - Y_UNIT_TEST(TestStreams12) { + Y_UNIT_TEST(TestStreams12) { TestStreams(20, 12); } - Y_UNIT_TEST(TestStreams13) { + Y_UNIT_TEST(TestStreams13) { TestStreams(20, 13); } - Y_UNIT_TEST(TestStreams14) { + Y_UNIT_TEST(TestStreams14) { TestStreams(20, 14); } - Y_UNIT_TEST(TestStreams15) { + Y_UNIT_TEST(TestStreams15) { TestStreams(20, 15); } - Y_UNIT_TEST(TestStreams16) { + Y_UNIT_TEST(TestStreams16) { TestStreams(20, 16); } - Y_UNIT_TEST(TestStreams17) { + Y_UNIT_TEST(TestStreams17) { TestStreams(20, 17); } - Y_UNIT_TEST(TestStreams18) { + Y_UNIT_TEST(TestStreams18) { TestStreams(20, 18); } - Y_UNIT_TEST(TestStreams19) { + Y_UNIT_TEST(TestStreams19) { TestStreams(20, 19); } diff --git a/library/cpp/blockcodecs/core/codecs.cpp b/library/cpp/blockcodecs/core/codecs.cpp index 21506e812b4..94e2d324ed7 100644 --- a/library/cpp/blockcodecs/core/codecs.cpp +++ b/library/cpp/blockcodecs/core/codecs.cpp @@ -38,8 +38,8 @@ namespace { } inline void ListCodecs(TCodecList& lst) const { - for (const auto& it : Registry) { - lst.push_back(it.first); + for (const auto& it : Registry) { + lst.push_back(it.first); } Sort(lst.begin(), lst.end()); diff --git a/library/cpp/blockcodecs/core/stream.cpp b/library/cpp/blockcodecs/core/stream.cpp index 4f7db3c32be..fe0347a2613 100644 --- a/library/cpp/blockcodecs/core/stream.cpp +++ b/library/cpp/blockcodecs/core/stream.cpp @@ -64,7 +64,7 @@ namespace { } } -TCodedOutput::TCodedOutput(IOutputStream* out, const ICodec* c, size_t bufLen) +TCodedOutput::TCodedOutput(IOutputStream* out, const ICodec* c, size_t bufLen) : C_(c) , D_(bufLen) , S_(out) @@ -95,7 +95,7 @@ void TCodedOutput::DoWrite(const void* buf, size_t len) { D_.Append(in, avail); - Y_ASSERT(!D_.Avail()); + Y_ASSERT(!D_.Avail()); in += avail; len -= avail; @@ -146,7 +146,7 @@ void TCodedOutput::DoFinish() { } } -TDecodedInput::TDecodedInput(IInputStream* in) +TDecodedInput::TDecodedInput(IInputStream* in) : S_(in) , C_(nullptr) { diff --git a/library/cpp/blockcodecs/core/stream.h b/library/cpp/blockcodecs/core/stream.h index fd44ef88f2c..a66c2e0c317 100644 --- a/library/cpp/blockcodecs/core/stream.h +++ b/library/cpp/blockcodecs/core/stream.h @@ -9,9 +9,9 @@ namespace NBlockCodecs { struct ICodec; - class TCodedOutput: public IOutputStream { + class TCodedOutput: public IOutputStream { public: - TCodedOutput(IOutputStream* out, const ICodec* c, size_t bufLen); + TCodedOutput(IOutputStream* out, const ICodec* c, size_t bufLen); ~TCodedOutput() override; private: @@ -25,12 +25,12 @@ namespace NBlockCodecs { const ICodec* C_; TBuffer D_; TBuffer O_; - IOutputStream* S_; + IOutputStream* S_; }; - class TDecodedInput: public IWalkInput { + class TDecodedInput: public IWalkInput { public: - TDecodedInput(IInputStream* in); + TDecodedInput(IInputStream* in); TDecodedInput(IInputStream* in, const ICodec* codec); ~TDecodedInput() override; @@ -40,7 +40,7 @@ namespace NBlockCodecs { private: TBuffer D_; - IInputStream* S_; + IInputStream* S_; const ICodec* C_; }; } diff --git a/library/cpp/blockcodecs/fuzz/main.cpp b/library/cpp/blockcodecs/fuzz/main.cpp index 763c6c5a10b..cddf79f7f62 100644 --- a/library/cpp/blockcodecs/fuzz/main.cpp +++ b/library/cpp/blockcodecs/fuzz/main.cpp @@ -1,84 +1,84 @@ -#include <contrib/libs/protobuf-mutator/src/libfuzzer/libfuzzer_macro.h> +#include <contrib/libs/protobuf-mutator/src/libfuzzer/libfuzzer_macro.h> #include <google/protobuf/stubs/logging.h> - + #include <library/cpp/blockcodecs/codecs.h> #include <library/cpp/blockcodecs/fuzz/proto/case.pb.h> #include <library/cpp/blockcodecs/stream.h> -#include <util/stream/input.h> -#include <util/stream/length.h> +#include <util/stream/input.h> +#include <util/stream/length.h> #include <util/stream/mem.h> -#include <util/stream/null.h> -#include <util/stream/str.h> - -using NBlockCodecs::NFuzz::TPackUnpackCase; -using NBlockCodecs::TCodedOutput; -using NBlockCodecs::TDecodedInput; +#include <util/stream/null.h> +#include <util/stream/str.h> -static void ValidateBufferSize(const ui32 size) { - Y_ENSURE(size > 0 && size <= 16ULL * 1024); -} +using NBlockCodecs::NFuzz::TPackUnpackCase; +using NBlockCodecs::TCodedOutput; +using NBlockCodecs::TDecodedInput; -static void DoOnlyDecode(const TPackUnpackCase& case_) { - if (!case_.GetPacked()) { - return; +static void ValidateBufferSize(const ui32 size) { + Y_ENSURE(size > 0 && size <= 16ULL * 1024); +} + +static void DoOnlyDecode(const TPackUnpackCase& case_) { + if (!case_.GetPacked()) { + return; } - TMemoryInput mi(case_.GetData().data(), case_.GetData().size()); - TDecodedInput di(&mi); - TNullOutput no; - TCountingOutput cno(&no); - TransferData(&di, &cno); -} - -static void DoDecodeEncode(const TPackUnpackCase& case_) { - auto* const codec = NBlockCodecs::Codec(case_.GetCodecName()); - Y_ENSURE(codec); - - TMemoryInput mi(case_.GetData().data(), case_.GetData().size()); - TDecodedInput di(&mi, codec); - TStringStream decoded; - TransferData(&di, &decoded); - TNullOutput no; - TCountingOutput cno(&no); - TCodedOutput co(&cno, codec, case_.GetBufferLength()); - TransferData(&decoded, &co); - co.Flush(); - - Y_VERIFY((case_.GetData().size() > 0) == (cno.Counter() > 0)); - Y_VERIFY((case_.GetData().size() > 0) == (decoded.Str().size() > 0)); -} - -static void DoEncodeDecode(const TPackUnpackCase& case_) { - auto* const codec = NBlockCodecs::Codec(case_.GetCodecName()); - Y_ENSURE(codec); - - TMemoryInput mi(case_.GetData().data(), case_.GetData().size()); - TStringStream encoded; - TCodedOutput co(&encoded, codec, case_.GetBufferLength()); - TransferData(&mi, &co); - co.Flush(); - TStringStream decoded; - TDecodedInput di(&encoded, codec); - TransferData(&di, &decoded); - - Y_VERIFY((case_.GetData().size() > 0) == (encoded.Str().size() > 0)); - Y_VERIFY(case_.GetData() == decoded.Str()); -} - -DEFINE_BINARY_PROTO_FUZZER(const TPackUnpackCase& case_) { - try { - if (!case_.GetCodecName()) { - DoOnlyDecode(case_); - return; - } - - ValidateBufferSize(case_.GetBufferLength()); - if (case_.GetPacked()) { - DoDecodeEncode(case_); - } else { - DoEncodeDecode(case_); - } - } catch (const std::exception&) { - } + TMemoryInput mi(case_.GetData().data(), case_.GetData().size()); + TDecodedInput di(&mi); + TNullOutput no; + TCountingOutput cno(&no); + TransferData(&di, &cno); } + +static void DoDecodeEncode(const TPackUnpackCase& case_) { + auto* const codec = NBlockCodecs::Codec(case_.GetCodecName()); + Y_ENSURE(codec); + + TMemoryInput mi(case_.GetData().data(), case_.GetData().size()); + TDecodedInput di(&mi, codec); + TStringStream decoded; + TransferData(&di, &decoded); + TNullOutput no; + TCountingOutput cno(&no); + TCodedOutput co(&cno, codec, case_.GetBufferLength()); + TransferData(&decoded, &co); + co.Flush(); + + Y_VERIFY((case_.GetData().size() > 0) == (cno.Counter() > 0)); + Y_VERIFY((case_.GetData().size() > 0) == (decoded.Str().size() > 0)); +} + +static void DoEncodeDecode(const TPackUnpackCase& case_) { + auto* const codec = NBlockCodecs::Codec(case_.GetCodecName()); + Y_ENSURE(codec); + + TMemoryInput mi(case_.GetData().data(), case_.GetData().size()); + TStringStream encoded; + TCodedOutput co(&encoded, codec, case_.GetBufferLength()); + TransferData(&mi, &co); + co.Flush(); + TStringStream decoded; + TDecodedInput di(&encoded, codec); + TransferData(&di, &decoded); + + Y_VERIFY((case_.GetData().size() > 0) == (encoded.Str().size() > 0)); + Y_VERIFY(case_.GetData() == decoded.Str()); +} + +DEFINE_BINARY_PROTO_FUZZER(const TPackUnpackCase& case_) { + try { + if (!case_.GetCodecName()) { + DoOnlyDecode(case_); + return; + } + + ValidateBufferSize(case_.GetBufferLength()); + if (case_.GetPacked()) { + DoDecodeEncode(case_); + } else { + DoEncodeDecode(case_); + } + } catch (const std::exception&) { + } +} diff --git a/library/cpp/blockcodecs/fuzz/proto/case.proto b/library/cpp/blockcodecs/fuzz/proto/case.proto index 85518b0da9e..622ed0ce475 100644 --- a/library/cpp/blockcodecs/fuzz/proto/case.proto +++ b/library/cpp/blockcodecs/fuzz/proto/case.proto @@ -1,10 +1,10 @@ -syntax="proto3"; - -package NBlockCodecs.NFuzz; - -message TPackUnpackCase { - bool Packed = 1; - uint32 BufferLength = 2; - string CodecName = 3; - bytes Data = 4; -} +syntax="proto3"; + +package NBlockCodecs.NFuzz; + +message TPackUnpackCase { + bool Packed = 1; + uint32 BufferLength = 2; + string CodecName = 3; + bytes Data = 4; +} diff --git a/library/cpp/blockcodecs/fuzz/proto/ya.make b/library/cpp/blockcodecs/fuzz/proto/ya.make index da840bc8c93..dbd32e0f1cd 100644 --- a/library/cpp/blockcodecs/fuzz/proto/ya.make +++ b/library/cpp/blockcodecs/fuzz/proto/ya.make @@ -1,14 +1,14 @@ -OWNER( - yazevnul - g:util -) - -PROTO_LIBRARY() - -SRCS( - case.proto -) - +OWNER( + yazevnul + g:util +) + +PROTO_LIBRARY() + +SRCS( + case.proto +) + EXCLUDE_TAGS(GO_PROTO) -END() +END() diff --git a/library/cpp/blockcodecs/fuzz/ya.make b/library/cpp/blockcodecs/fuzz/ya.make index bc8becc9e1d..dee86d56a26 100644 --- a/library/cpp/blockcodecs/fuzz/ya.make +++ b/library/cpp/blockcodecs/fuzz/ya.make @@ -3,21 +3,21 @@ OWNER( g:util ) -IF (NOT MSVC) - FUZZ() +IF (NOT MSVC) + FUZZ() - SIZE(MEDIUM) + SIZE(MEDIUM) - SRCS( - main.cpp - ) - - PEERDIR( - contrib/libs/protobuf - contrib/libs/protobuf-mutator + SRCS( + main.cpp + ) + + PEERDIR( + contrib/libs/protobuf + contrib/libs/protobuf-mutator library/cpp/blockcodecs library/cpp/blockcodecs/fuzz/proto - ) - - END() -ENDIF() + ) + + END() +ENDIF() diff --git a/library/cpp/cache/cache.h b/library/cpp/cache/cache.h index 6dc997076d9..93bd6614dbd 100644 --- a/library/cpp/cache/cache.h +++ b/library/cpp/cache/cache.h @@ -82,7 +82,7 @@ public: TItem* GetOldest() { typename TListType::TIterator it = List.Begin(); - Y_ASSERT(it != List.End()); + Y_ASSERT(it != List.End()); return &*it; } @@ -190,7 +190,7 @@ public: TItem* GetLeastFrequentlyUsed() { typename TListType::TIterator it = List.Begin(); - Y_ASSERT(it != List.End()); + Y_ASSERT(it != List.End()); return &*it; } @@ -310,7 +310,7 @@ public: TItem* GetLightest() { FixHeap(); - Y_ASSERT(!Heap.empty()); + Y_ASSERT(!Heap.empty()); return Heap.front(); } @@ -319,7 +319,7 @@ public: // Erased items are stored in Removed set // and will be deleted on-access (using FixHeap method) void Erase(TItem* item) { - Y_ASSERT(Size > 0); + Y_ASSERT(Size > 0); --Size; Removed.insert(item); @@ -460,14 +460,14 @@ public: // note: it shouldn't touch 'value' if it returns false. bool PickOut(const TKey& key, TValue* value) { - Y_ASSERT(value); + Y_ASSERT(value); TIndexIterator it = Index.find(TItem(key)); if (it == Index.end()) return false; *value = it->Value; List.Erase(const_cast<TItem*>(&*it)); Index.erase(it); - Y_ASSERT(Index.size() == List.GetSize()); + Y_ASSERT(Index.size() == List.GetSize()); return true; } @@ -492,7 +492,7 @@ public: } } - Y_ASSERT(Index.size() == List.GetSize()); + Y_ASSERT(Index.size() == List.GetSize()); return !insertedWasRemoved; } @@ -505,7 +505,7 @@ public: } Insert(key, value); - Y_ASSERT(Index.size() == List.GetSize()); + Y_ASSERT(Index.size() == List.GetSize()); } void Erase(TIterator it) { @@ -514,7 +514,7 @@ public: TDeleter::Destroy(item->Value); Index.erase(it.Iter); - Y_ASSERT(Index.size() == List.GetSize()); + Y_ASSERT(Index.size() == List.GetSize()); } bool Empty() const { @@ -527,7 +527,7 @@ public: List.Erase(item); TDeleter::Destroy(item->Value); } - Y_ASSERT(List.GetSize() == 0); + Y_ASSERT(List.GetSize() == 0); Index.clear(); } @@ -563,7 +563,7 @@ protected: void EraseFromIndex(TItem* item) { TDeleter::Destroy(item->Value); TIterator it = FindByItem(item); - Y_ASSERT(it != End()); + Y_ASSERT(it != End()); Index.erase(it.Iter); } }; diff --git a/library/cpp/cache/ut/cache_ut.cpp b/library/cpp/cache/ut/cache_ut.cpp index 329872cfdee..e92e07b12e8 100644 --- a/library/cpp/cache/ut/cache_ut.cpp +++ b/library/cpp/cache/ut/cache_ut.cpp @@ -8,8 +8,8 @@ struct TStrokaWeighter { } }; -Y_UNIT_TEST_SUITE(TCacheTest) { - Y_UNIT_TEST(LRUListTest) { +Y_UNIT_TEST_SUITE(TCacheTest) { + Y_UNIT_TEST(LRUListTest) { typedef TLRUList<int, TString> TListType; TListType list(2); @@ -65,7 +65,7 @@ Y_UNIT_TEST_SUITE(TCacheTest) { UNIT_ASSERT_EQUAL(list.GetOldest()->Key, 4); } - Y_UNIT_TEST(LFUListTest) { + Y_UNIT_TEST(LFUListTest) { typedef TLFUList<int, TString> TListType; TListType list(2); @@ -85,7 +85,7 @@ Y_UNIT_TEST_SUITE(TCacheTest) { UNIT_ASSERT_EQUAL(list.GetLeastFrequentlyUsed()->Key, 1); } - Y_UNIT_TEST(LWListTest) { + Y_UNIT_TEST(LWListTest) { typedef TLWList<int, TString, size_t, TStrokaWeighter> TListType; TListType list(2); @@ -114,7 +114,7 @@ Y_UNIT_TEST_SUITE(TCacheTest) { UNIT_ASSERT_EQUAL(list.GetSize(), 1); } - Y_UNIT_TEST(SimpleTest) { + Y_UNIT_TEST(SimpleTest) { typedef TLRUCache<int, TString> TCache; TCache s(2); // size 2 s.Insert(1, "abcd"); @@ -311,7 +311,7 @@ Y_UNIT_TEST_SUITE(TCacheTest) { UNIT_ASSERT(s.Find(6) != s.End()); } - Y_UNIT_TEST(MultiCacheTest) { + Y_UNIT_TEST(MultiCacheTest) { typedef TLRUCache<int, TString> TCache; TCache s(3, true); UNIT_ASSERT(s.Insert(1, "abcd")); @@ -333,7 +333,7 @@ Y_UNIT_TEST_SUITE(TCacheTest) { }; int TMyDelete::count = 0; - Y_UNIT_TEST(DeleterTest) { + Y_UNIT_TEST(DeleterTest) { typedef TLRUCache<int, TString, TMyDelete> TCache; TCache s(2); s.Insert(1, "123"); @@ -346,7 +346,7 @@ Y_UNIT_TEST_SUITE(TCacheTest) { UNIT_ASSERT(TMyDelete::count == 2); } - Y_UNIT_TEST(PromoteOnFind) { + Y_UNIT_TEST(PromoteOnFind) { typedef TLRUCache<int, TString> TCache; TCache s(2); s.Insert(1, "123"); @@ -357,7 +357,7 @@ Y_UNIT_TEST_SUITE(TCacheTest) { } } -Y_UNIT_TEST_SUITE(TThreadSafeCacheTest) { +Y_UNIT_TEST_SUITE(TThreadSafeCacheTest) { typedef TThreadSafeCache<ui32, TString, ui32> TCache; const char* VALS[] = {"abcd", "defg", "hjkl"}; @@ -375,7 +375,7 @@ Y_UNIT_TEST_SUITE(TThreadSafeCacheTest) { mutable i32 Creations = 0; }; - Y_UNIT_TEST(SimpleTest) { + Y_UNIT_TEST(SimpleTest) { for (ui32 i = 0; i < Y_ARRAY_SIZE(VALS); ++i) { const TString data = *TCache::Get<TCallbacks>(i); UNIT_ASSERT(data == VALS[i]); diff --git a/library/cpp/cgiparam/cgiparam.cpp b/library/cpp/cgiparam/cgiparam.cpp index f3277b8e4b2..c9bf98a357d 100644 --- a/library/cpp/cgiparam/cgiparam.cpp +++ b/library/cpp/cgiparam/cgiparam.cpp @@ -17,7 +17,7 @@ const TString& TCgiParameters::Get(const TStringBuf name, size_t numOfValue) con return end() == it ? Default<TString>() : it->second; } -bool TCgiParameters::Erase(const TStringBuf name, size_t pos) { +bool TCgiParameters::Erase(const TStringBuf name, size_t pos) { const auto pair = equal_range(name); for (auto it = pair.first; it != pair.second; ++it, --pos) { @@ -46,7 +46,7 @@ bool TCgiParameters::Erase(const TStringBuf name, const TStringBuf val) { return found; } -size_t TCgiParameters::EraseAll(const TStringBuf name) { +size_t TCgiParameters::EraseAll(const TStringBuf name) { size_t num = 0; const auto pair = equal_range(name); @@ -89,36 +89,36 @@ static inline TString DoUnescape(const TStringBuf s) { return res; } -void TCgiParameters::InsertEscaped(const TStringBuf name, const TStringBuf value) { +void TCgiParameters::InsertEscaped(const TStringBuf name, const TStringBuf value) { InsertUnescaped(DoUnescape(name), DoUnescape(value)); } template <bool addAll, class F> -static inline void DoScan(const TStringBuf s, F& f) { +static inline void DoScan(const TStringBuf s, F& f) { ScanKeyValue<addAll, '&', '='>(s, f); } struct TAddEscaped { TCgiParameters* C; - inline void operator()(const TStringBuf key, const TStringBuf val) { + inline void operator()(const TStringBuf key, const TStringBuf val) { C->InsertEscaped(key, val); } }; -void TCgiParameters::Scan(const TStringBuf query, bool form) { +void TCgiParameters::Scan(const TStringBuf query, bool form) { Flush(); form ? ScanAdd(query) : ScanAddAll(query); } -void TCgiParameters::ScanAdd(const TStringBuf query) { +void TCgiParameters::ScanAdd(const TStringBuf query) { TAddEscaped f = {this}; DoScan<false>(query, f); } -void TCgiParameters::ScanAddUnescaped(const TStringBuf query) { - auto f = [this](const TStringBuf key, const TStringBuf val) { +void TCgiParameters::ScanAddUnescaped(const TStringBuf query) { + auto f = [this](const TStringBuf key, const TStringBuf val) { this->InsertUnescaped(key, val); }; @@ -133,7 +133,7 @@ void TCgiParameters::ScanAddAllUnescaped(const TStringBuf query) { DoScan<true>(query, f); } -void TCgiParameters::ScanAddAll(const TStringBuf query) { +void TCgiParameters::ScanAddAll(const TStringBuf query) { TAddEscaped f = {this}; DoScan<true>(query, f); @@ -172,7 +172,7 @@ char* TCgiParameters::Print(char* res) const { size_t TCgiParameters::PrintSize() const noexcept { size_t res = size(); // for '&' - for (const auto& i : *this) { + for (const auto& i : *this) { res += CgiEscapeBufLen(i.first.size() + i.second.size()); // extra zero will be used for '=' } diff --git a/library/cpp/cgiparam/cgiparam.h b/library/cpp/cgiparam/cgiparam.h index 87d1ab0ad45..c14ddbf6f26 100644 --- a/library/cpp/cgiparam/cgiparam.h +++ b/library/cpp/cgiparam/cgiparam.h @@ -20,7 +20,7 @@ class TCgiParameters: public TMultiMap<TString, TString> { public: TCgiParameters() = default; - explicit TCgiParameters(const TStringBuf cgiParamStr) { + explicit TCgiParameters(const TStringBuf cgiParamStr) { Scan(cgiParamStr); } @@ -30,7 +30,7 @@ public: erase(begin(), end()); } - size_t EraseAll(const TStringBuf name); + size_t EraseAll(const TStringBuf name); size_t NumOfValues(const TStringBuf name) const noexcept { return count(name); @@ -40,11 +40,11 @@ public: return Print(); } - void Scan(const TStringBuf cgiParStr, bool form = true); - void ScanAdd(const TStringBuf cgiParStr); - void ScanAddUnescaped(const TStringBuf cgiParStr); + void Scan(const TStringBuf cgiParStr, bool form = true); + void ScanAdd(const TStringBuf cgiParStr); + void ScanAddUnescaped(const TStringBuf cgiParStr); void ScanAddAllUnescaped(const TStringBuf cgiParStr); - void ScanAddAll(const TStringBuf cgiParStr); + void ScanAddAll(const TStringBuf cgiParStr); /// Returns the string representation of all the stored parameters /** @@ -85,7 +85,7 @@ public: Y_PURE_FUNCTION const TString& Get(const TStringBuf name, size_t numOfValue = 0) const noexcept; - void InsertEscaped(const TStringBuf name, const TStringBuf value); + void InsertEscaped(const TStringBuf name, const TStringBuf value); #if !defined(__GLIBCXX__) template <typename TName, typename TValue> @@ -119,14 +119,14 @@ public: // if val is a [possibly empty] non-NULL string, append it as well void JoinUnescaped(const TStringBuf key, char sep, TStringBuf val = TStringBuf()); - bool Erase(const TStringBuf name, size_t numOfValue = 0); + bool Erase(const TStringBuf name, size_t numOfValue = 0); bool Erase(const TStringBuf name, const TStringBuf val); - inline const char* FormField(const TStringBuf name, size_t numOfValue = 0) const { + inline const char* FormField(const TStringBuf name, size_t numOfValue = 0) const { const_iterator it = Find(name, numOfValue); if (it == end()) { - return nullptr; + return nullptr; } return it->second.data(); diff --git a/library/cpp/cgiparam/cgiparam_ut.cpp b/library/cpp/cgiparam/cgiparam_ut.cpp index a5623420840..c9946462f9b 100644 --- a/library/cpp/cgiparam/cgiparam_ut.cpp +++ b/library/cpp/cgiparam/cgiparam_ut.cpp @@ -2,8 +2,8 @@ #include <library/cpp/testing/unittest/registar.h> -Y_UNIT_TEST_SUITE(TCgiParametersTest) { - Y_UNIT_TEST(TestScan1) { +Y_UNIT_TEST_SUITE(TCgiParametersTest) { + Y_UNIT_TEST(TestScan1) { TCgiParameters C; C.Scan("aaa=b%62b&ccc=ddd&ag0="); UNIT_ASSERT_EQUAL(C.Get("aaa") == "bbb", true); @@ -38,7 +38,7 @@ Y_UNIT_TEST_SUITE(TCgiParametersTest) { UNIT_ASSERT(!C.Has("aaa")); } - Y_UNIT_TEST(TestScan2) { + Y_UNIT_TEST(TestScan2) { const TString parsee("=000&aaa=bbb&ag0=&ccc=ddd"); TCgiParameters c; c.Scan(parsee); @@ -46,7 +46,7 @@ Y_UNIT_TEST_SUITE(TCgiParametersTest) { UNIT_ASSERT_VALUES_EQUAL(c.Print(), parsee); } - Y_UNIT_TEST(TestScan3) { + Y_UNIT_TEST(TestScan3) { const TString parsee("aaa=bbb&ag0=&ccc=ddd"); TCgiParameters c; c.Scan(parsee); @@ -56,7 +56,7 @@ Y_UNIT_TEST_SUITE(TCgiParametersTest) { UNIT_ASSERT_VALUES_EQUAL(c.Print(), parsee + "&d=xxx"); } - Y_UNIT_TEST(TestScanAddAll1) { + Y_UNIT_TEST(TestScanAddAll1) { TCgiParameters c; c.ScanAddAll("qw"); @@ -64,7 +64,7 @@ Y_UNIT_TEST_SUITE(TCgiParametersTest) { UNIT_ASSERT(c.Get("qw").empty()); } - Y_UNIT_TEST(TestScanAddAll2) { + Y_UNIT_TEST(TestScanAddAll2) { TCgiParameters c; c.ScanAddAll("qw&"); @@ -72,7 +72,7 @@ Y_UNIT_TEST_SUITE(TCgiParametersTest) { UNIT_ASSERT(c.Get("qw").empty()); } - Y_UNIT_TEST(TestScanAddAll3) { + Y_UNIT_TEST(TestScanAddAll3) { TCgiParameters c; c.ScanAddAll("qw=1&x"); @@ -81,7 +81,7 @@ Y_UNIT_TEST_SUITE(TCgiParametersTest) { UNIT_ASSERT(c.Get("x").empty()); } - Y_UNIT_TEST(TestScanAddAll4) { + Y_UNIT_TEST(TestScanAddAll4) { TCgiParameters c; c.ScanAddAll("ccc=1&aaa=1&ccc=3&bbb&ccc=2"); @@ -111,7 +111,7 @@ Y_UNIT_TEST_SUITE(TCgiParametersTest) { UNIT_ASSERT_VALUES_EQUAL(c.Get("text"), "%D0%9F%D1%80%D0%B8%D0%B2%D0%B5%D1%82%2C"); } - Y_UNIT_TEST(TestEraseAll) { + Y_UNIT_TEST(TestEraseAll) { TCgiParameters c; c.ScanAddAll("par=1&aaa=1&par=2&bbb&par=3"); c.EraseAll("par"); @@ -119,7 +119,7 @@ Y_UNIT_TEST_SUITE(TCgiParametersTest) { UNIT_ASSERT_VALUES_EQUAL(c.Print(), "aaa=1&bbb="); } - Y_UNIT_TEST(TestErase) { + Y_UNIT_TEST(TestErase) { TCgiParameters c; c.ScanAddAll("par=1&aaa=1&par=2&bbb&par=3&par=1"); @@ -130,7 +130,7 @@ Y_UNIT_TEST_SUITE(TCgiParametersTest) { UNIT_ASSERT_VALUES_EQUAL(c.Print(), "aaa=1&bbb=&par=3"); } - Y_UNIT_TEST(TestReplaceUnescaped1) { + Y_UNIT_TEST(TestReplaceUnescaped1) { TCgiParameters c; c.ScanAddAll("many_keys=1&aaa=1&many_keys=2&bbb&many_keys=3"); c.ReplaceUnescaped("many_keys", "new_value"); @@ -138,7 +138,7 @@ Y_UNIT_TEST_SUITE(TCgiParametersTest) { UNIT_ASSERT_VALUES_EQUAL(c.Print(), "aaa=1&bbb=&many_keys=new_value"); } - Y_UNIT_TEST(TestReplaceUnescaped2) { + Y_UNIT_TEST(TestReplaceUnescaped2) { TCgiParameters c; c.ScanAddAll("par=1&only_one=1&par=2&bbb&par=3"); c.ReplaceUnescaped("only_one", "new_value"); @@ -146,7 +146,7 @@ Y_UNIT_TEST_SUITE(TCgiParametersTest) { UNIT_ASSERT_VALUES_EQUAL(c.Print(), "bbb=&only_one=new_value&par=1&par=2&par=3"); } - Y_UNIT_TEST(TestReplaceUnescaped3) { + Y_UNIT_TEST(TestReplaceUnescaped3) { TCgiParameters c; c.ScanAddAll("par=1&aaa=1&par=2&bbb&par=3"); c.ReplaceUnescaped("no_such_key", "new_value"); @@ -154,7 +154,7 @@ Y_UNIT_TEST_SUITE(TCgiParametersTest) { UNIT_ASSERT_VALUES_EQUAL(c.Print(), "aaa=1&bbb=&no_such_key=new_value&par=1&par=2&par=3"); } - Y_UNIT_TEST(TestReplaceUnescapedRange1) { + Y_UNIT_TEST(TestReplaceUnescapedRange1) { TCgiParameters c; c.ScanAddAll("par=1&aaa=1&par=2&bbb&par=3"); c.ReplaceUnescaped("par", {"x", "y", "z"}); // 3 old values, 3 new values @@ -162,7 +162,7 @@ Y_UNIT_TEST_SUITE(TCgiParametersTest) { UNIT_ASSERT_VALUES_EQUAL(c.Print(), "aaa=1&bbb=&par=x&par=y&par=z"); } - Y_UNIT_TEST(TestReplaceUnescapedRange2) { + Y_UNIT_TEST(TestReplaceUnescapedRange2) { TCgiParameters c; c.ScanAddAll("par=1&aaa=1&par=2&bbb"); c.ReplaceUnescaped("par", {"x", "y", "z"}); // 2 old values, 3 new values @@ -170,7 +170,7 @@ Y_UNIT_TEST_SUITE(TCgiParametersTest) { UNIT_ASSERT_VALUES_EQUAL(c.Print(), "aaa=1&bbb=&par=x&par=y&par=z"); } - Y_UNIT_TEST(TestReplaceUnescapedRange3) { + Y_UNIT_TEST(TestReplaceUnescapedRange3) { TCgiParameters c; c.ScanAddAll("par=1&aaa=1&par=2&bbb&par=3"); c.ReplaceUnescaped("par", {"x", "y"}); // 3 old values, 2 new values @@ -178,23 +178,23 @@ Y_UNIT_TEST_SUITE(TCgiParametersTest) { UNIT_ASSERT_VALUES_EQUAL(c.Print(), "aaa=1&bbb=&par=x&par=y"); } - Y_UNIT_TEST(TestNumOfValues) { + Y_UNIT_TEST(TestNumOfValues) { TCgiParameters c; c.ScanAddAll("par=1&aaa=1&par=2&bbb&par=3"); UNIT_ASSERT_VALUES_EQUAL(c.NumOfValues("par"), 3u); } - Y_UNIT_TEST(TestUnscape) { + Y_UNIT_TEST(TestUnscape) { TCgiParameters c("f=1&t=%84R%84%7C%84%80%84%7E&reqenc=SHIFT_JIS&p=0"); UNIT_ASSERT_VALUES_EQUAL(c.Get("t"), "\x84R\x84\x7C\x84\x80\x84\x7E"); } - Y_UNIT_TEST(TestEmpty) { + Y_UNIT_TEST(TestEmpty) { UNIT_ASSERT(TCgiParameters().Print().empty()); } - Y_UNIT_TEST(TestJoinUnescaped) { + Y_UNIT_TEST(TestJoinUnescaped) { TCgiParameters c; c.Scan("foo=1&foo=2"); @@ -203,7 +203,7 @@ Y_UNIT_TEST_SUITE(TCgiParametersTest) { UNIT_ASSERT_VALUES_EQUAL(c.Print(), "foo=1;2;0"); } - Y_UNIT_TEST(TestContInit) { + Y_UNIT_TEST(TestContInit) { TCgiParameters c = {std::make_pair("a", "a1"), std::make_pair("b", "b1"), std::make_pair("a", "a2")}; UNIT_ASSERT_VALUES_EQUAL(c.NumOfValues("a"), 2u); diff --git a/library/cpp/charset/ci_string.cpp b/library/cpp/charset/ci_string.cpp index 6097e40131f..24b53c8efcc 100644 --- a/library/cpp/charset/ci_string.cpp +++ b/library/cpp/charset/ci_string.cpp @@ -36,6 +36,6 @@ size_t TCiString::hashVal(const char* s, size_t len, const CodePage& cp) { } template <> -void Out<TCiString>(IOutputStream& o, const TCiString& p) { +void Out<TCiString>(IOutputStream& o, const TCiString& p) { o.Write(p.data(), p.size()); } diff --git a/library/cpp/charset/codepage.cpp b/library/cpp/charset/codepage.cpp index 0431bef31bc..3e5fe09f854 100644 --- a/library/cpp/charset/codepage.cpp +++ b/library/cpp/charset/codepage.cpp @@ -4,7 +4,7 @@ #include "codepage.h" #include <util/string/cast.h> -#include <util/string/subst.h> +#include <util/string/subst.h> #include <util/string/util.h> #include <util/system/hi_lo.h> #include <util/system/yassert.h> @@ -90,7 +90,7 @@ static const CodePage UNSUPPORTED_CODEPAGE = { "unsupported", }, {}, - nullptr, + nullptr, }; static const CodePage UNKNOWN_CODEPAGE = { @@ -99,15 +99,15 @@ static const CodePage UNKNOWN_CODEPAGE = { "unknown", }, {}, - nullptr, + nullptr, }; void NCodepagePrivate::TCodepagesMap::SetData(const CodePage* cp) { - Y_ASSERT(cp); + Y_ASSERT(cp); int code = static_cast<int>(cp->CPEnum) + DataShift; - Y_ASSERT(code >= 0 && code < DataSize); - Y_ASSERT(Data[code] == nullptr); + Y_ASSERT(code >= 0 && code < DataSize); + Y_ASSERT(Data[code] == nullptr); Data[code] = cp; } @@ -138,7 +138,7 @@ private: if (Data.find(name.c_str()) == Data.end()) { Data.insert(TData::value_type(Pool.Append(name.data(), name.size() + 1), code)); } else { - Y_ASSERT(Data.find(name.c_str())->second == code); + Y_ASSERT(Data.find(name.c_str())->second == code); } } @@ -172,7 +172,7 @@ public: AddName(ToString(static_cast<int>(i)), e); - for (size_t j = 0; (name = page->Names[j]) != nullptr && name[0]; ++j) { + for (size_t j = 0; (name = page->Names[j]) != nullptr && name[0]; ++j) { AddName(name, e); AddName(xPrefix + name, e); @@ -199,7 +199,7 @@ ECharset CharsetByName(TStringBuf name) { ECharset CharsetByNameOrDie(TStringBuf name) { ECharset result = CharsetByName(name); if (result == CODES_UNKNOWN) - ythrow yexception() << "CharsetByNameOrDie: unknown charset '" << name << "'"; + ythrow yexception() << "CharsetByNameOrDie: unknown charset '" << name << "'"; return result; } @@ -280,7 +280,7 @@ void DoDecodeUnknownPlane(TxChar* str, TxChar*& ee, const ECharset enc) { *s = Lo8(Lo16(*s)); } } else { - Y_ASSERT(!SingleByteCodepage(enc)); + Y_ASSERT(!SingleByteCodepage(enc)); TxChar* s = str; TxChar* d = str; @@ -295,10 +295,10 @@ void DoDecodeUnknownPlane(TxChar* str, TxChar*& ee, const ECharset enc) { } else { if (!buf.empty()) { if (RecodeToUnicode(enc, buf.data(), d, buf.size(), e - d, read, written) == RECODE_OK) { - Y_ASSERT(read == buf.size()); + Y_ASSERT(read == buf.size()); d += written; } else { // just copying broken symbols - Y_ASSERT(buf.size() <= static_cast<size_t>(e - d)); + Y_ASSERT(buf.size() <= static_cast<size_t>(e - d)); Copy(buf.data(), buf.size(), d); d += buf.size(); } diff --git a/library/cpp/charset/codepage.h b/library/cpp/charset/codepage.h index 30a02a46106..9e73fbd6154 100644 --- a/library/cpp/charset/codepage.h +++ b/library/cpp/charset/codepage.h @@ -85,7 +85,7 @@ struct CodePage { static void Initialize(); inline bool SingleByteCodepage() const { - return DefaultChar != nullptr; + return DefaultChar != nullptr; } inline bool NativeCodepage() const { return SingleByteCodepage() || CPEnum == CODES_UTF8; @@ -103,7 +103,7 @@ namespace NCodepagePrivate { private: inline const CodePage* GetPrivate(ECharset e) const { - Y_ASSERT(e + DataShift >= 0 && e + DataShift < DataSize); + Y_ASSERT(e + DataShift >= 0 && e + DataShift < DataSize); return Data[e + DataShift]; } @@ -115,7 +115,7 @@ namespace NCodepagePrivate { inline const CodePage* Get(ECharset e) const { const CodePage* res = GetPrivate(e); if (!res->SingleByteCodepage()) { - ythrow yexception() << "CodePage (" << (int)e << ") structure can only be used for single byte encodings"; + ythrow yexception() << "CodePage (" << (int)e << ") structure can only be used for single byte encodings"; } return res; @@ -170,7 +170,7 @@ inline const char* NameByCharsetSafe(ECharset e) { if (CODES_UNKNOWN < e && e < CODES_MAX) return ::NCodepagePrivate::TCodepagesMap::Instance().NameByCharset(e); else - ythrow yexception() << "unknown encoding: " << (int)e; + ythrow yexception() << "unknown encoding: " << (int)e; } inline const char* NameByCodePage(const CodePage* CP) { @@ -180,7 +180,7 @@ inline const char* NameByCodePage(const CodePage* CP) { inline const CodePage* CodePageByName(const char* name) { ECharset code = CharsetByName(name); if (code == CODES_UNKNOWN) - return nullptr; + return nullptr; return CodePageByCharset(code); } @@ -204,7 +204,7 @@ struct Encoder { char code = Code(ch); if (code == 0 && ch != 0) code = DefaultChar[NUnicode::CharType(ch)]; - Y_ASSERT(code != 0 || ch == 0); + Y_ASSERT(code != 0 || ch == 0); return code; } diff --git a/library/cpp/charset/codepage_ut.cpp b/library/cpp/charset/codepage_ut.cpp index c3ac3ac478e..250e11bbf14 100644 --- a/library/cpp/charset/codepage_ut.cpp +++ b/library/cpp/charset/codepage_ut.cpp @@ -151,7 +151,7 @@ void TCodepageTest::TestUTF() { //"\xed\xbe\x80", //"\xed\xbf\xbf", }; - for (size_t i = 0; i < Y_ARRAY_SIZE(badStrings); ++i) { + for (size_t i = 0; i < Y_ARRAY_SIZE(badStrings); ++i) { wchar32 rune; const ui8* p = (const ui8*)badStrings[i]; size_t len; @@ -169,15 +169,15 @@ void TCodepageTest::TestBrokenMultibyte() { size_t nwritten = 0; size_t nread = 0; - RECODE_RESULT res = RecodeToUnicode(cp, sampletext, recodeResult, Y_ARRAY_SIZE(sampletext), Y_ARRAY_SIZE(recodeResult), nread, nwritten); + RECODE_RESULT res = RecodeToUnicode(cp, sampletext, recodeResult, Y_ARRAY_SIZE(sampletext), Y_ARRAY_SIZE(recodeResult), nread, nwritten); UNIT_ASSERT(res == RECODE_OK); UNIT_ASSERT(nread == 1); UNIT_ASSERT(nwritten == 0); const char bigSample[] = {'\xC3', '\x87', '\xC3', '\x8E', '\xC2', '\xB0', '\xC3', '\x85', '\xC3', '\x85', '\xC3', '\xB8'}; - res = RecodeToUnicode(cp, bigSample, recodeResult, Y_ARRAY_SIZE(bigSample), Y_ARRAY_SIZE(recodeResult), nread, nwritten); + res = RecodeToUnicode(cp, bigSample, recodeResult, Y_ARRAY_SIZE(bigSample), Y_ARRAY_SIZE(recodeResult), nread, nwritten); UNIT_ASSERT(res == RECODE_OK); - UNIT_ASSERT(nread == Y_ARRAY_SIZE(bigSample)); + UNIT_ASSERT(nread == Y_ARRAY_SIZE(bigSample)); } void TCodepageTest::TestUTFFromUnknownPlane() { @@ -191,7 +191,7 @@ void TCodepageTest::TestUTFFromUnknownPlane() { size_t readchars = 0; size_t writtenbytes = 0; - size_t samplelen = Y_ARRAY_SIZE(sampletext); + size_t samplelen = Y_ARRAY_SIZE(sampletext); RECODE_RESULT res = RecodeFromUnicode(CODES_UTF8, sampletext, bytebuffer, samplelen, BUFFER_SIZE, readchars, writtenbytes); @@ -291,11 +291,11 @@ static void TestSurrogates(const char* str, const wchar16* wide, size_t wideSize void TCodepageTest::TestSurrogatePairs() { const char* utf8NonBMP = "\xf4\x80\x89\x84\xf4\x80\x89\x87\xf4\x80\x88\xba"; wchar16 wNonBMPDummy[] = {0xDBC0, 0xDE44, 0xDBC0, 0xDE47, 0xDBC0, 0xDE3A}; - TestSurrogates(utf8NonBMP, wNonBMPDummy, Y_ARRAY_SIZE(wNonBMPDummy)); + TestSurrogates(utf8NonBMP, wNonBMPDummy, Y_ARRAY_SIZE(wNonBMPDummy)); const char* utf8NonBMP2 = "ab\xf4\x80\x89\x87n"; wchar16 wNonBMPDummy2[] = {'a', 'b', 0xDBC0, 0xDE47, 'n'}; - TestSurrogates(utf8NonBMP2, wNonBMPDummy2, Y_ARRAY_SIZE(wNonBMPDummy2)); + TestSurrogates(utf8NonBMP2, wNonBMPDummy2, Y_ARRAY_SIZE(wNonBMPDummy2)); } void TCodepageTest::TestEncodingHints() { @@ -329,7 +329,7 @@ void TCodepageTest::TestEncodingHints() { void TCodepageTest::TestToLower() { TTempBuf buf; char* data = buf.Data(); - const size_t n = Y_ARRAY_SIZE(yandexUpperCase); // including NTS + const size_t n = Y_ARRAY_SIZE(yandexUpperCase); // including NTS memcpy(data, yandexUpperCase, n); ToLower(data, n - 1); UNIT_ASSERT(strcmp(data, yandexLowerCase) == 0); @@ -338,7 +338,7 @@ void TCodepageTest::TestToLower() { void TCodepageTest::TestToUpper() { TTempBuf buf; char* data = buf.Data(); - const size_t n = Y_ARRAY_SIZE(yandexLowerCase); // including NTS + const size_t n = Y_ARRAY_SIZE(yandexLowerCase); // including NTS memcpy(data, yandexLowerCase, n); ToUpper(data, n - 1); UNIT_ASSERT(strcmp(data, yandexUpperCase) == 0); diff --git a/library/cpp/charset/cp_encrec.cpp b/library/cpp/charset/cp_encrec.cpp index e4570cd6284..d3c7a9db66b 100644 --- a/library/cpp/charset/cp_encrec.cpp +++ b/library/cpp/charset/cp_encrec.cpp @@ -16,7 +16,7 @@ void Encoder::Tr(const wchar32* in, char* out) const { void Recoder::Create(const CodePage& source, const Encoder* wideTarget) { for (size_t i = 0; i != 256; ++i) { Table[i] = wideTarget->Tr(source.unicode[i]); - Y_ASSERT(Table[i] != 0 || i == 0); + Y_ASSERT(Table[i] != 0 || i == 0); } } diff --git a/library/cpp/charset/generated/cp_data.cpp b/library/cpp/charset/generated/cp_data.cpp index 202362c596e..ebe37f1a157 100644 --- a/library/cpp/charset/generated/cp_data.cpp +++ b/library/cpp/charset/generated/cp_data.cpp @@ -126,28 +126,28 @@ static const CodePage CODES_BIG5_CODE_PAGE = { CODES_BIG5, {"BIG5", "BIGFIVE", "CN-BIG5", "CSBIG5",}, {}, - nullptr, + nullptr, }; // generated from multibyte.txt static const CodePage CODES_BIG5_HKSCS_CODE_PAGE = { CODES_BIG5_HKSCS, {"BIG5-HKSCS", "BIG5-HKSCS:2004",}, {}, - nullptr, + nullptr, }; // generated from multibyte.txt static const CodePage CODES_BIG5_HKSCS_1999_CODE_PAGE = { CODES_BIG5_HKSCS_1999, {"BIG5-HKSCS:1999",}, {}, - nullptr, + nullptr, }; // generated from multibyte.txt static const CodePage CODES_BIG5_HKSCS_2001_CODE_PAGE = { CODES_BIG5_HKSCS_2001, {"BIG5-HKSCS:2001",}, {}, - nullptr, + nullptr, }; // generated from multibyte.txt static const CodePage CODES_CP1046_CODE_PAGE = { @@ -1274,70 +1274,70 @@ static const CodePage CODES_CP932_CODE_PAGE = { CODES_CP932, {"CP932",}, {}, - nullptr, + nullptr, }; // generated from multibyte.txt static const CodePage CODES_CP936_CODE_PAGE = { CODES_CP936, {"CP936",}, {}, - nullptr, + nullptr, }; // generated from multibyte.txt static const CodePage CODES_CP949_CODE_PAGE = { CODES_CP949, {"CP949", "UHC",}, {}, - nullptr, + nullptr, }; // generated from multibyte.txt static const CodePage CODES_CP950_CODE_PAGE = { CODES_CP950, {"CP950",}, {}, - nullptr, + nullptr, }; // generated from multibyte.txt static const CodePage CODES_EUC_CN_CODE_PAGE = { CODES_EUC_CN, {"EUC-CN", "CN-GB", "GB2312", "CSGB2312",}, {}, - nullptr, + nullptr, }; // generated from multibyte.txt static const CodePage CODES_EUC_JP_CODE_PAGE = { CODES_EUC_JP, {"EUC-JP", "EXTENDED_UNIX_CODE_PACKED_FORMAT_FOR_JAPANESE", "CSEUCPKDFMTJAPANESE",}, {}, - nullptr, + nullptr, }; // generated from multibyte.txt static const CodePage CODES_EUC_KR_CODE_PAGE = { CODES_EUC_KR, {"EUC-KR", "ISO-IR-149", "KOREAN", "KSC_5601", "KS_C_5601-1987", "KS_C_5601-1989", "CSEUCKR", "CSKSC56011987",}, {}, - nullptr, + nullptr, }; // generated from multibyte.txt static const CodePage CODES_EUC_TW_CODE_PAGE = { CODES_EUC_TW, {"EUC-TW", "CSEUCTW",}, {}, - nullptr, + nullptr, }; // generated from multibyte.txt static const CodePage CODES_GB18030_CODE_PAGE = { CODES_GB18030, {"GB18030",}, {}, - nullptr, + nullptr, }; // generated from multibyte.txt static const CodePage CODES_GBK_CODE_PAGE = { CODES_GBK, {"GBK",}, {}, - nullptr, + nullptr, }; // generated from multibyte.txt static const CodePage CODES_GEO_ITA_CODE_PAGE = { @@ -1464,7 +1464,7 @@ static const CodePage CODES_HZ_CODE_PAGE = { CODES_HZ, {"HZ", "HZ-GB-2312",}, {}, - nullptr, + nullptr, }; // generated from multibyte.txt static const CodePage CODES_IBM855_CODE_PAGE = { @@ -1711,42 +1711,42 @@ static const CodePage CODES_ISO_2022_CN_CODE_PAGE = { CODES_ISO_2022_CN, {"ISO-2022-CN", "CSISO2022CN",}, {}, - nullptr, + nullptr, }; // generated from multibyte.txt static const CodePage CODES_ISO_2022_CN_EXT_CODE_PAGE = { CODES_ISO_2022_CN_EXT, {"ISO-2022-CN-EXT",}, {}, - nullptr, + nullptr, }; // generated from multibyte.txt static const CodePage CODES_ISO_2022_JP_CODE_PAGE = { CODES_ISO_2022_JP, {"ISO-2022-JP", "CPISO2022JP",}, {}, - nullptr, + nullptr, }; // generated from multibyte.txt static const CodePage CODES_ISO_2022_JP_1_CODE_PAGE = { CODES_ISO_2022_JP_1, {"ISO-2022-JP-1",}, {}, - nullptr, + nullptr, }; // generated from multibyte.txt static const CodePage CODES_ISO_2022_JP_2_CODE_PAGE = { CODES_ISO_2022_JP_2, {"ISO-2022-JP-2", "CPISO2022JP2",}, {}, - nullptr, + nullptr, }; // generated from multibyte.txt static const CodePage CODES_ISO_2022_KR_CODE_PAGE = { CODES_ISO_2022_KR, {"ISO-2022-KR", "CSISO2022KR",}, {}, - nullptr, + nullptr, }; // generated from multibyte.txt static const CodePage CODES_ISO_8859_13_CODE_PAGE = { @@ -2193,7 +2193,7 @@ static const CodePage CODES_JOHAB_CODE_PAGE = { CODES_JOHAB, {"JOHAB", "CP1361",}, {}, - nullptr, + nullptr, }; // generated from multibyte.txt static const CodePage CODES_KAZWIN_CODE_PAGE = { @@ -3080,7 +3080,7 @@ static const CodePage CODES_SHIFT_JIS_CODE_PAGE = { CODES_SHIFT_JIS, {"SHIFT_JIS", "MS_KANJI", "SJIS", "CSSHIFTJIS",}, {}, - nullptr, + nullptr, }; // generated from multibyte.txt static const CodePage CODES_TATWIN_CODE_PAGE = { @@ -3287,21 +3287,21 @@ static const CodePage CODES_UTF8_CODE_PAGE = { CODES_UTF8, {"utf-8",}, {}, - nullptr, + nullptr, }; // generated from multibyte.txt static const CodePage CODES_UTF_16BE_CODE_PAGE = { CODES_UTF_16BE, {"UTF-16BE",}, {}, - nullptr, + nullptr, }; // generated from multibyte.txt static const CodePage CODES_UTF_16LE_CODE_PAGE = { CODES_UTF_16LE, {"UTF-16LE", "UTF-16",}, {}, - nullptr, + nullptr, }; // generated from multibyte.txt static const CodePage CODES_VISCII_CODE_PAGE = { diff --git a/library/cpp/charset/generated/encrec_data.cpp b/library/cpp/charset/generated/encrec_data.cpp index ca59f8ddef0..3eb7fd3f2f1 100644 --- a/library/cpp/charset/generated/encrec_data.cpp +++ b/library/cpp/charset/generated/encrec_data.cpp @@ -8302,10 +8302,10 @@ const Encoder* const NCodepagePrivate::TCodePageData::EncodeTo[] = { &encoder_07, &encoder_08, &encoder_09, - nullptr, - nullptr, + nullptr, + nullptr, &encoder_12, - nullptr, + nullptr, &encoder_14, &encoder_15, &encoder_16, @@ -8382,29 +8382,29 @@ const Encoder* const NCodepagePrivate::TCodePageData::EncodeTo[] = { &encoder_87, &encoder_88, &encoder_89, - nullptr, - nullptr, - nullptr, - nullptr, - nullptr, - nullptr, - nullptr, - nullptr, - nullptr, - nullptr, - nullptr, - nullptr, - nullptr, - nullptr, - nullptr, - nullptr, - nullptr, - nullptr, - nullptr, - nullptr, - nullptr, - nullptr, - nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, }; const struct Encoder &WideCharToYandex = encoder_09; diff --git a/library/cpp/charset/iconv_ut.cpp b/library/cpp/charset/iconv_ut.cpp index e8c56f6d491..c60c97307df 100644 --- a/library/cpp/charset/iconv_ut.cpp +++ b/library/cpp/charset/iconv_ut.cpp @@ -76,11 +76,11 @@ public: void TestSurrogatePairs() { const char* utf8NonBMP = "\xf4\x80\x89\x84\xf4\x80\x89\x87\xf4\x80\x88\xba"; wchar16 wNonBMPDummy[] = {0xDBC0, 0xDE44, 0xDBC0, 0xDE47, 0xDBC0, 0xDE3A}; - TestSurrogates(utf8NonBMP, wNonBMPDummy, Y_ARRAY_SIZE(wNonBMPDummy)); + TestSurrogates(utf8NonBMP, wNonBMPDummy, Y_ARRAY_SIZE(wNonBMPDummy)); const char* utf8NonBMP2 = "ab\xf4\x80\x89\x87n"; wchar16 wNonBMPDummy2[] = {'a', 'b', 0xDBC0, 0xDE47, 'n'}; - TestSurrogates(utf8NonBMP2, wNonBMPDummy2, Y_ARRAY_SIZE(wNonBMPDummy2)); + TestSurrogates(utf8NonBMP2, wNonBMPDummy2, Y_ARRAY_SIZE(wNonBMPDummy2)); } }; diff --git a/library/cpp/charset/recyr.hh b/library/cpp/charset/recyr.hh index 5ec8734bcfb..5c560d770a4 100644 --- a/library/cpp/charset/recyr.hh +++ b/library/cpp/charset/recyr.hh @@ -47,7 +47,7 @@ inline RECODE_RESULT RecodeFromUnicode(ECharset to, const TCharType* in, char* o } inline RECODE_RESULT RecodeFromUnicode(ECharset theEncoding, const wchar16* chars, size_t length, - char* bytes, size_t size, size_t* read = nullptr, size_t* written = nullptr) { + char* bytes, size_t size, size_t* read = nullptr, size_t* written = nullptr) { size_t w = 0, r = 0; RECODE_RESULT rc = ::RecodeFromUnicode(theEncoding, chars, bytes, length, size, r, w); if (read) @@ -122,7 +122,7 @@ inline bool Recode(ECharset from, ECharset to, const TStringBuf& in, TString& ou size_t inRead = 0; size_t outWritten = 0; const RECODE_RESULT res = Recode(from, to, in.data(), out.begin(), inSize, outSize, inRead, outWritten); - Y_ENSURE(RECODE_OK == res, "Recode failed. "); + Y_ENSURE(RECODE_OK == res, "Recode failed. "); if (outWritten > outSize) ythrow yexception() << "Recode overrun the buffer: size=" << outSize << " need=" << outWritten; diff --git a/library/cpp/charset/recyr_int.hh b/library/cpp/charset/recyr_int.hh index 353af53305e..1ea917b70f0 100644 --- a/library/cpp/charset/recyr_int.hh +++ b/library/cpp/charset/recyr_int.hh @@ -49,7 +49,7 @@ namespace NCodepagePrivate { inline RECODE_RESULT _recodeFromUTF8(ECharset to, const char* in, char* out, size_t in_size, size_t out_size, size_t& in_readed, size_t& out_writed) { if (to == CODES_UTF8) return _recodeCopy(in, out, in_size, out_size, in_readed, out_writed); - Y_ASSERT(CODES_UNKNOWN < to && to < CODES_MAX); + Y_ASSERT(CODES_UNKNOWN < to && to < CODES_MAX); const Encoder* enc = &EncoderByCharset(to); const unsigned char* in_start = (const unsigned char*)in; diff --git a/library/cpp/charset/wide.h b/library/cpp/charset/wide.h index 32d30e849e9..6f17efabd97 100644 --- a/library/cpp/charset/wide.h +++ b/library/cpp/charset/wide.h @@ -18,7 +18,7 @@ //! @note @c dest buffer must fit at least @c len number of characters template <typename TCharType> inline size_t WideToChar(const TCharType* text, size_t len, char* dest, ECharset enc) { - Y_ASSERT(SingleByteCodepage(enc)); + Y_ASSERT(SingleByteCodepage(enc)); const char* start = dest; @@ -57,21 +57,21 @@ namespace NDetail { template <typename TCharType> inline TBasicStringBuf<TCharType> RecodeSingleByteChar(const TStringBuf src, TCharType* dst, const CodePage& cp) { - Y_ASSERT(cp.SingleByteCodepage()); + Y_ASSERT(cp.SingleByteCodepage()); ::CharToWide(src.data(), src.size(), dst, cp); return TBasicStringBuf<TCharType>(dst, src.size()); } template <typename TCharType> inline TStringBuf RecodeSingleByteChar(const TBasicStringBuf<TCharType> src, char* dst, const CodePage& cp) { - Y_ASSERT(cp.SingleByteCodepage()); + Y_ASSERT(cp.SingleByteCodepage()); ::WideToChar(src.data(), src.size(), dst, cp.CPEnum); return TStringBuf(dst, src.size()); } template <typename TCharType> inline TBasicStringBuf<TCharType> RecodeMultiByteChar(const TStringBuf src, TCharType* dst, ECharset encoding) { - Y_ASSERT(!NCodepagePrivate::NativeCodepage(encoding)); + Y_ASSERT(!NCodepagePrivate::NativeCodepage(encoding)); size_t read = 0; size_t written = 0; ::NICONVPrivate::RecodeToUnicode(encoding, src.data(), dst, src.size(), src.size(), read, written); @@ -80,7 +80,7 @@ namespace NDetail { template <typename TCharType> inline TStringBuf RecodeMultiByteChar(const TBasicStringBuf<TCharType> src, char* dst, ECharset encoding) { - Y_ASSERT(!NCodepagePrivate::NativeCodepage(encoding)); + Y_ASSERT(!NCodepagePrivate::NativeCodepage(encoding)); size_t read = 0; size_t written = 0; ::NICONVPrivate::RecodeFromUnicode(encoding, src.data(), dst, src.size(), src.size() * 3, read, written); diff --git a/library/cpp/charset/wide_ut.cpp b/library/cpp/charset/wide_ut.cpp index 78947d51bad..4acd822ea00 100644 --- a/library/cpp/charset/wide_ut.cpp +++ b/library/cpp/charset/wide_ut.cpp @@ -211,17 +211,17 @@ void TConversionTest::TestYandexEncoding() { const char* utf8NonBMP2 = "ab\xf4\x80\x89\x87n"; wchar16 wNonBMPDummy2[] = {'a', 'b', 0xDBC0, 0xDE47, 'n'}; - TestSurrogates(utf8NonBMP2, wNonBMPDummy2, Y_ARRAY_SIZE(wNonBMPDummy2), CODES_UTF8); + TestSurrogates(utf8NonBMP2, wNonBMPDummy2, Y_ARRAY_SIZE(wNonBMPDummy2), CODES_UTF8); { const char* yandexNonBMP2 = "ab?n"; - UNIT_ASSERT(yandexNonBMP2 == WideToChar(wNonBMPDummy2, Y_ARRAY_SIZE(wNonBMPDummy2), CODES_YANDEX)); + UNIT_ASSERT(yandexNonBMP2 == WideToChar(wNonBMPDummy2, Y_ARRAY_SIZE(wNonBMPDummy2), CODES_YANDEX)); TString temp; - temp.resize(Y_ARRAY_SIZE(wNonBMPDummy2)); + temp.resize(Y_ARRAY_SIZE(wNonBMPDummy2)); size_t read = 0; size_t written = 0; - RecodeFromUnicode(CODES_YANDEX, wNonBMPDummy2, temp.begin(), Y_ARRAY_SIZE(wNonBMPDummy2), temp.size(), read, written); + RecodeFromUnicode(CODES_YANDEX, wNonBMPDummy2, temp.begin(), Y_ARRAY_SIZE(wNonBMPDummy2), temp.size(), read, written); temp.remove(written); UNIT_ASSERT(yandexNonBMP2 == temp); @@ -337,7 +337,7 @@ void TConversionTest::TestRecodeAppend() { } template <> -void Out<RECODE_RESULT>(IOutputStream& out, RECODE_RESULT val) { +void Out<RECODE_RESULT>(IOutputStream& out, RECODE_RESULT val) { out << int(val); } @@ -390,7 +390,7 @@ void TConversionTest::TestUnicodeLimit() { continue; const CodePage* page = CodePageByCharset(code); - Y_ASSERT(page); + Y_ASSERT(page); for (int c = 0; c < 256; ++c) { UNIT_ASSERT(page->unicode[c] < 1 << 16); diff --git a/library/cpp/codecs/comptable_codec.cpp b/library/cpp/codecs/comptable_codec.cpp index 476b8ada80c..cd079dd52c6 100644 --- a/library/cpp/codecs/comptable_codec.cpp +++ b/library/cpp/codecs/comptable_codec.cpp @@ -54,11 +54,11 @@ namespace NCodecs { Init(); } - void Save(IOutputStream* out) const { + void Save(IOutputStream* out) const { ::Save(out, Table); } - void Load(IInputStream* in) { + void Load(IInputStream* in) { ::Load(in, Table); Init(); } @@ -97,11 +97,11 @@ namespace NCodecs { Impl->DoLearn(in); } - void TCompTableCodec::Save(IOutputStream* out) const { + void TCompTableCodec::Save(IOutputStream* out) const { Impl->Save(out); } - void TCompTableCodec::Load(IInputStream* in) { + void TCompTableCodec::Load(IInputStream* in) { Impl->Load(in); } diff --git a/library/cpp/codecs/greedy_dict/gd_builder.cpp b/library/cpp/codecs/greedy_dict/gd_builder.cpp index 561bfbca015..1c25299b11a 100644 --- a/library/cpp/codecs/greedy_dict/gd_builder.cpp +++ b/library/cpp/codecs/greedy_dict/gd_builder.cpp @@ -4,7 +4,7 @@ #include <util/generic/algorithm.h> #include <util/random/shuffle.h> -#include <util/stream/output.h> +#include <util/stream/output.h> #include <util/string/printf.h> #include <util/system/rusage.h> diff --git a/library/cpp/codecs/greedy_dict/ut/greedy_dict_ut.cpp b/library/cpp/codecs/greedy_dict/ut/greedy_dict_ut.cpp index 679089a11be..6f6fe0e4cb1 100644 --- a/library/cpp/codecs/greedy_dict/ut/greedy_dict_ut.cpp +++ b/library/cpp/codecs/greedy_dict/ut/greedy_dict_ut.cpp @@ -122,7 +122,7 @@ class TGreedyDictTest: public TTestBase { void FillData(NGreedyDict::TStringBufs& data) { static const char* urls[] = {"http://53.ru/car/motors/foreign/opel/tigra/", "http://abakan.24au.ru/tender/85904/", "http://anm15.gulaig.com/", "http://avto-parts.com/mercedes-benz/mercedes-benz-w220-1998-2005/category-442/category-443/", "http://ballooncousin.co.uk/", "http://benzol.ru/equipment/?id=1211&parent=514", "http://blazingseorank.com/blazing-seo-rank-free-website-analysis-to-increase-rank-and-traffic-450.html", "http://blogblaugrana.contadorwebmasters.com/", "http://bristolhash.org.uk/bh3cntct.php", "http://broker.borovichi.ru/category/item/3/1/0/8/28/257", "http://canoncompactcamerax.blogspot.com/", "http://classifieds.smashits.com/p,107881,email-to-friend.htm", "http://conferences.ksde.org/Portals/132/FallAssessment/SAVETHEDAY-FA09.pdf", "http://eway.vn/raovat/325-dien-tu-gia-dung/337-dieu-hoa/98041-b1-sua-may-lanh-quan-binh-tan-sua-may-lanh-quan-binh-chanh-hh-979676119-toan-quoc.html", "http://gallery.e2bn.org/asset73204_8-.html", "http://goplay.nsw.gov.au/activities-for-kids/by/historic-houses-trust/?startdate=2012-07-10", "http://grichards19067.multiply.com/", "http://hotkovo.egent.ru/user/89262269084/", "http://howimetyourself.com/?redirect_to=http://gomiso.com/m/suits/seasons/2/episodes/2", "http://islamqa.com/hi/ref/9014/DEAD%20PEOPLE%20GOOD%20DEEDS", "http://lapras.rutube.ru/", "http://nceluiko.ya.ru/", "http://nyanyanyanyaa.beon.ru/", "http://ozbo.com/Leaf-River-DV-7SS-7-0-MP-Game-Camera-K1-32541.html", "http://sbantom.ru/catalog/chasy/632753.html", "http://shopingoff.com/index.php?option=com_virtuemart&Itemid=65&category_id=&page=shop.browse&manufacturer_id=122&limit=32&limitstart=96", "http://shopingoff.com/katalog-odezhdy/manufacturer/62-christian-audigier.html?limit=32&start=448", "https://webwinkel.ah.nl/process?fh_location=//ecommerce/nl_NL/categories%3C%7Becommerce_shoc1%7D/it_show_product_code_1384%3E%7B10%3B20%7D/pr_startdate%3C20120519/pr_enddate%3E20120519/pr_ltc_allowed%3E%7Bbowi%7D/categories%3C%7Becommerce_shoc1_1al%7D/categories%3C%7Becommerce_shoc1_1al_1ahal%7D&&action=albert_noscript.modules.build", "http://top100.rambler.ru/navi/?theme=208/210/371&rgn=17", "http://volgogradskaya-oblast.extra-m.ru/classifieds/rabota/vakansii/banki-investicii/901467/", "http://wikien4.appspot.com/wiki/Warburg_hypothesis", "http://wola_baranowska.kamerzysta24.com.pl/", "http://www.10dot0dot0dot1.com/", "http://www.anima-redux.ru/index.php?key=gifts+teenage+girls", "http://www.aquaticabyseaworld.com/Calendar.aspx/CP/CP/CP/sp-us/CP/CP/ParkMap/Tickets/Weather.aspx", "http://www.autousa.com/360spin/2012_cadillac_ctssportwagon_3.6awdpremiumcollection.htm", "http://www.booking.com/city/gb/paignton-aireborough.html?inac=0&lang=pl", "http://www.booking.com/city/it/vodo-cadore.en.html", "http://www.booking.com/district/us/new-york/rockefeller-center.html&lang=no", "http://www.booking.com/hotel/bg/crown-fort-club.lv.html", "http://www.booking.com/hotel/ca/gouverneur-rimouski.ar.html", "http://www.booking.com/hotel/ch/l-auberge-du-chalet-a-gobet.fi.html", "http://www.booking.com/hotel/de/mark-garni.ru.html?aid=337384;label=yandex-hotel-mark-garni-68157-%7Bparam1%7D", "http://www.booking.com/hotel/de/mercure-goldschmieding-castrop-rauxel.ro.html", "http://www.booking.com/hotel/de/zollenspieker-fahrhaus.fr.html", "http://www.booking.com/hotel/es/jardin-metropolitano.ca.html", "http://www.booking.com/hotel/fr/clim.fr.html", "http://www.booking.com/hotel/fr/radisson-sas-toulouse-airport.et.html", "http://www.booking.com/hotel/gb/stgileshotel.ro.html?srfid=68c7fe42a03653a8796c84435c5299e4X16?tab=4", "http://www.booking.com/hotel/gr/rodos-park-suites.ru.html", "http://www.booking.com/hotel/id/le-grande-suites-bali.ru.html", "http://www.booking.com/hotel/it/mozart.it.html?aid=321655", "http://www.booking.com/hotel/ni/bahia-del-sol-villas.ru.html?dcid=1;dva=0", "http://www.booking.com/hotel/nl/cpschiphol.ro.html.ro.html?tab=4", "http://www.booking.com/hotel/th/laem-din.en-gb.html", "http://www.booking.com/hotel/th/tinidee-ranong.en.html", "http://www.booking.com/hotel/us/best-western-plus-merrimack-valley.hu.html", "http://www.booking.com/hotel/vn/tan-hai-long.km.html", "http://www.booking.com/landmark/au/royal-brisbane-women-s-hospital.vi.html", "http://www.booking.com/landmark/hk/nam-cheong-station.html&lang=id", "http://www.booking.com/landmark/it/spanish-steps.ca.html", "http://www.booking.com/landmark/sg/asian-civilisations-museum.html&lang=fi", "http://www.booking.com/place/fi-1376029.pt.html", "http://www.booking.com/place/tn257337.pl.html", "http://www.booking.com/region/ca/niagarafalls.ar.html&selected_currency=PLN", "http://www.booking.com/region/mx/queretaro.pt-pt.html&selected_currency=AUD", "http://www.booking.com/searchresults.en.html?city=20063074", "http://www.booking.com/searchresults.et.html?checkin=;checkout=;city=-394632", "http://www.booking.com/searchresults.lv.html?region=3936", "http://www.cevredanismanlari.com/index.php/component/k2/index.php/mevzuat/genel-yazlar/item/dosyalar/index.php?option=com_k2&view=item&id=16:iso-14001-%C3%A7evre-y%C3%B6netim-sistemi&Itemid=132&limitstart=107120", "http://www.dh-wholesaler.com/MENS-POLO-RACING-TEE-RL-p-417.html", "http://www.employabilityonline.net/", "http://www.esso.inc.ru/board/tools.php?event=profile&pname=Invinerrq", "http://www.filesurgery.ru/searchfw/kids_clothes-3.html", "http://www.furnitureandcarpetsource.com/Item.aspx?ItemID=-2107311899&ItemNum=53-T3048", "http://www.gets.cn/product/Gold-Sand-Lampwork-Glass-Beads--Flat-round--28x28x13mm_p260717.html", "http://www.gets.cn/wholesale-Sterling-Silver-Pendant-Findings-3577_S--L-Star-P-1.html?view=1&by=1", "http://www.homeandgardenadvice.com/diy/Mortgages_Loans_and_Financing/9221.html", "http://www.hongkongairport.com/eng/index.html/passenger/passenger/transport/to-from-airport/business/about-the-airport/transport/shopping/entertainment/t2/passenger/interactive-map.html", "http://www.hongkongairport.com/eng/index.html/shopping/insideshopping/all/passenger/transfer-transit/all/airline-information/shopping/entertainment/t2/business/about-the-airport/welcome.html", "http://www.hongkongairport.com/eng/index.html/transport/business/about-the-airport/transport/business/airport-authority/passenger/shopping/dining/all/dining.html", "http://www.idedge.com/index.cfm/fuseaction/category.display/category_id/298/index.cfm", "http://www.istanbulburda.com/aramalar.php", "http://www.jewelryinthenet.com/ads/AdDetail.aspx?AdID=1-0311002490689&stid=22-0111001020877", "http://www.johnnydepp.ru/forum/index.php?showtopic=1629&mode=linearplus&view=findpost&p=186977", "http://www.johnnydepp.ru/forum/index.php?showtopic=476&st=60&p=87379&", "http://www.joseleano.com/joomla/index.php/audio", "http://www.kaplicarehberi.com/tag/sakar-ilicali-kaplicalari/feed", "http://www.khaber.com.tr/arama.html?key=%C3%A7avdar", "http://www.kiz-oyunlari1.com/1783/4437/4363/1056/4170/Bump-Copter2-.html", "http://www.kiz-oyunlari1.com/3752/2612/4175/1166/3649/1047/Angelina-Oyunu.html", "http://www.kiz-oyunlari1.com/4266/3630/3665/3286/4121/301/3274/Sinir-Sinekler-.html", "http://www.kuldiga.lv/index.php?f=8&cat=371", "http://www.kuldiga.lv/index.php/img/index.php?l=lv&art_id=1836&show_c=&cat=85", "http://www.patronessa.ru/remontiruemsya/kuzovnie30raboti.html", "http://www.rapdict.org/Nu_Money?title=Talk:Nu_Money&action=edit", "http://www.serafin-phu.tabor24.com/?page=8", "http://www.shoes-store.org/brand1/Kids/Minnetonka.html", "http://www.shoes-store.org/shoes-store.xml", "http://www.way2allah.com/khotab-download-34695.htm"}; data.clear(); - data.insert(data.begin(), urls, urls + Y_ARRAY_SIZE(urls)); + data.insert(data.begin(), urls, urls + Y_ARRAY_SIZE(urls)); } typedef THashMap<TStringBuf, NGreedyDict::TEntry> TDict; @@ -140,9 +140,9 @@ class TGreedyDictTest: public TTestBase { TEntrySet& set = b.EntrySet(); - for (const auto& it : set) { - if (it.Score) { - res[it.Str] = it; + for (const auto& it : set) { + if (it.Score) { + res[it.Str] = it; } } diff --git a/library/cpp/codecs/greedy_dict/ut/ya.make b/library/cpp/codecs/greedy_dict/ut/ya.make index bd67d1a4522..ae57a20ccd1 100644 --- a/library/cpp/codecs/greedy_dict/ut/ya.make +++ b/library/cpp/codecs/greedy_dict/ut/ya.make @@ -1,7 +1,7 @@ UNITTEST_FOR(library/cpp/codecs/greedy_dict) -OWNER(velavokr) - +OWNER(velavokr) + SRCS( greedy_dict_ut.cpp ) diff --git a/library/cpp/codecs/greedy_dict/ya.make b/library/cpp/codecs/greedy_dict/ya.make index 2a57224f7e1..4deb99578e6 100644 --- a/library/cpp/codecs/greedy_dict/ya.make +++ b/library/cpp/codecs/greedy_dict/ya.make @@ -1,5 +1,5 @@ -OWNER(velavokr) - +OWNER(velavokr) + LIBRARY() SRCS( diff --git a/library/cpp/codecs/huffman_codec.cpp b/library/cpp/codecs/huffman_codec.cpp index 650fe7cdfdd..e45f92a9aa3 100644 --- a/library/cpp/codecs/huffman_codec.cpp +++ b/library/cpp/codecs/huffman_codec.cpp @@ -3,7 +3,7 @@ #include <library/cpp/bit_io/bitoutput.h> #include <util/generic/algorithm.h> -#include <util/generic/bitops.h> +#include <util/generic/bitops.h> #include <util/stream/buffer.h> #include <util/stream/length.h> #include <util/string/printf.h> diff --git a/library/cpp/codecs/static/static.cpp b/library/cpp/codecs/static/static.cpp index 44a07dd73a2..f7cc97142c4 100644 --- a/library/cpp/codecs/static/static.cpp +++ b/library/cpp/codecs/static/static.cpp @@ -19,7 +19,7 @@ namespace NCodecs { return STATIC_CODEC_INFO_MAGIC; } - void SaveCodecInfoToStream(IOutputStream& out, const TStaticCodecInfo& info) { + void SaveCodecInfoToStream(IOutputStream& out, const TStaticCodecInfo& info) { TBufferOutput bout; info.SerializeToArcadiaStream(&bout); ui64 hash = DataSignature(bout.Buffer()); @@ -28,7 +28,7 @@ namespace NCodecs { ::Save(&out, bout.Buffer()); } - TStaticCodecInfo LoadCodecInfoFromStream(IInputStream& in) { + TStaticCodecInfo LoadCodecInfoFromStream(IInputStream& in) { { TBuffer magic; magic.Resize(GetStaticCodecInfoMagic().size()); diff --git a/library/cpp/codecs/static/static.h b/library/cpp/codecs/static/static.h index c1eaed2a742..b5e1be3bb31 100644 --- a/library/cpp/codecs/static/static.h +++ b/library/cpp/codecs/static/static.h @@ -4,7 +4,7 @@ #include <util/generic/strbuf.h> #include <util/generic/string.h> -#include <util/stream/output.h> +#include <util/stream/output.h> namespace NCodecs { class TStaticCodecInfo; @@ -23,11 +23,11 @@ namespace NCodecs { TString SaveCodecInfoToString(const TStaticCodecInfo&); - void SaveCodecInfoToStream(IOutputStream& out, const TStaticCodecInfo&); + void SaveCodecInfoToStream(IOutputStream& out, const TStaticCodecInfo&); // misc - TStaticCodecInfo LoadCodecInfoFromStream(IInputStream& in); + TStaticCodecInfo LoadCodecInfoFromStream(IInputStream& in); TString FormatCodecInfo(const TStaticCodecInfo&); diff --git a/library/cpp/codecs/static/tools/common/ct_common.cpp b/library/cpp/codecs/static/tools/common/ct_common.cpp index fe776912805..99151a6d4d3 100644 --- a/library/cpp/codecs/static/tools/common/ct_common.cpp +++ b/library/cpp/codecs/static/tools/common/ct_common.cpp @@ -4,7 +4,7 @@ #include <library/cpp/codecs/static/static_codec_info.pb.h> #include <library/cpp/string_utils/base64/base64.h> -#include <util/stream/output.h> +#include <util/stream/output.h> #include <util/string/builder.h> #include <util/system/hp_timer.h> diff --git a/library/cpp/codecs/ut/codecs_ut.cpp b/library/cpp/codecs/ut/codecs_ut.cpp index caf6089aef7..823a9bf7480 100644 --- a/library/cpp/codecs/ut/codecs_ut.cpp +++ b/library/cpp/codecs/ut/codecs_ut.cpp @@ -1111,7 +1111,7 @@ private: { TVector<TBuffer> learn; - for (auto& textValue : TextValues) { + for (auto& textValue : TextValues) { learn.emplace_back(textValue, strlen(textValue)); } @@ -1199,7 +1199,7 @@ private: TVector<TBuffer> data; - for (auto& textValue : TextValues) { + for (auto& textValue : TextValues) { data.emplace_back(textValue, strlen(textValue)); } @@ -1221,15 +1221,15 @@ private: THuffmanCodec codec; std::pair<char, ui64> freqs[256]; - for (size_t i = 0; i < Y_ARRAY_SIZE(freqs); ++i) { + for (size_t i = 0; i < Y_ARRAY_SIZE(freqs); ++i) { freqs[i].first = (char)i; freqs[i].second = 0; } - for (auto& textValue : TextValues) { - size_t len = strlen(textValue); + for (auto& textValue : TextValues) { + size_t len = strlen(textValue); for (size_t j = 0; j < len; ++j) { - ++freqs[(ui32)(0xFF & textValue[j])].second; + ++freqs[(ui32)(0xFF & textValue[j])].second; } } @@ -1253,7 +1253,7 @@ private: { TVector<TBuffer> learn; - for (auto& textValue : TextValues) { + for (auto& textValue : TextValues) { learn.emplace_back(textValue, strlen(textValue)); } @@ -1345,14 +1345,14 @@ private: void TestRegistry() { using namespace NCodecs; TVector<TString> vs = ICodec::GetCodecsList(); - for (const auto& v : vs) { - TCodecPtr p = ICodec::GetInstance(v); - if (v == "none") { + for (const auto& v : vs) { + TCodecPtr p = ICodec::GetInstance(v); + if (v == "none") { UNIT_ASSERT(!p); continue; } - UNIT_ASSERT_C(!!p, v); - UNIT_ASSERT_C(TStringBuf(v).Head(3) == TStringBuf(p->GetName()).Head(3), v + " " + p->GetName()); + UNIT_ASSERT_C(!!p, v); + UNIT_ASSERT_C(TStringBuf(v).Head(3) == TStringBuf(p->GetName()).Head(3), v + " " + p->GetName()); } } }; diff --git a/library/cpp/codecs/ut/float_huffman_ut.cpp b/library/cpp/codecs/ut/float_huffman_ut.cpp index 3156fb1f461..2215a9c6d7c 100644 --- a/library/cpp/codecs/ut/float_huffman_ut.cpp +++ b/library/cpp/codecs/ut/float_huffman_ut.cpp @@ -8,7 +8,7 @@ namespace fh = NCodecs::NFloatHuff; -Y_UNIT_TEST_SUITE(FloatHuffmanTest) { +Y_UNIT_TEST_SUITE(FloatHuffmanTest) { static const float Factors[] = { 0.340582, 0.000974026, 0.487168, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0.411765, 0.921569, 0.00390625, 0.109371, 0, 1, 0, 0, 0, 0, 0.523322, 0, 1, 0, 0, 0, 0, 0.285714, 1, @@ -61,7 +61,7 @@ Y_UNIT_TEST_SUITE(FloatHuffmanTest) { 0.947855, 0, 0, 0, 0, 0, 0, 0, 0, 0.847059, 0.679841, 0, 0.156863, 0, 0, 1, 0, 0, 0, 0, 0.969697, 0, 0, 0.564706, 0, 0, 0, 0, 0, 1, 0.0367282, 0.0395228, 0, 0, 0, 0, 0, 0.0470588, 0.141176, 0.054902, 0, 0, 0, 0}; - static const size_t FactorCount = Y_ARRAY_SIZE(Factors); + static const size_t FactorCount = Y_ARRAY_SIZE(Factors); static const ui8 CodedFactors[] = { 0x24, 0x06, 0x73, 0xB5, 0xC7, 0x55, 0x7F, 0x3A, 0xB4, 0x70, 0xCB, 0xEF, 0xEE, 0xFE, 0xB3, 0x5B, @@ -133,7 +133,7 @@ Y_UNIT_TEST_SUITE(FloatHuffmanTest) { 0xC8, 0xFE, 0x08, 0xC2, 0x07, 0xC7, 0x27, 0x21, 0xE1, 0xBB, 0x3E, 0xC1, 0x59, 0x68, 0xAA, 0x78, 0xC8, 0x57, 0x5D, 0x60, 0x20, 0xC6, 0x41, 0x42, 0xE8, 0x3A, 0x38, 0xD8, 0x9B, 0xFF, 0xFF, 0xFF, 0xC4, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; - static const size_t CodedSize = Y_ARRAY_SIZE(CodedFactors); + static const size_t CodedSize = Y_ARRAY_SIZE(CodedFactors); static const TStringBuf CodedFactorsBuf(reinterpret_cast<const char*>(CodedFactors), CodedSize); void FillWithGarbage(float* factors, size_t count) { @@ -166,7 +166,7 @@ Y_UNIT_TEST_SUITE(FloatHuffmanTest) { Cerr << result.Str() << Endl; } - Y_UNIT_TEST(TestCompress) { + Y_UNIT_TEST(TestCompress) { const auto codedFactors = fh::Encode(Factors); UNIT_ASSERT_VALUES_EQUAL(codedFactors.size(), CodedSize); for (size_t i = 0; i < Min(codedFactors.size(), CodedSize); ++i) @@ -174,7 +174,7 @@ Y_UNIT_TEST_SUITE(FloatHuffmanTest) { //PrintCompressed(codedFactors); } - Y_UNIT_TEST(TestSimpleDecompress) { + Y_UNIT_TEST(TestSimpleDecompress) { TVector<float> factors = fh::Decode(CodedFactorsBuf); UNIT_ASSERT_VALUES_EQUAL(factors.size(), FactorCount); for (size_t i = 0; i < Min(factors.size(), FactorCount); ++i) @@ -197,7 +197,7 @@ Y_UNIT_TEST_SUITE(FloatHuffmanTest) { //PrintDecompressed(factors); } - Y_UNIT_TEST(TestSkip) { + Y_UNIT_TEST(TestSkip) { float factors[FactorCount]; FillWithGarbage(factors, FactorCount); fh::TDecoder decoder(CodedFactorsBuf); @@ -218,7 +218,7 @@ Y_UNIT_TEST_SUITE(FloatHuffmanTest) { //PrintDecompressed(factors); } - Y_UNIT_TEST(TestDecompressForgedData) { + Y_UNIT_TEST(TestDecompressForgedData) { // this coredumps without end-of-coded-stream check, see SEARCH-1156 for details TString brokenBase64Encoded = "NLjYltUWs5pqnd3d3f05Li4OAwCAEqrP6mv06jDt7PiAUVu7Y+PiMpuZmdzeM" diff --git a/library/cpp/codecs/ut/tls_cache_ut.cpp b/library/cpp/codecs/ut/tls_cache_ut.cpp index 8101af761fe..daa7249eaac 100644 --- a/library/cpp/codecs/ut/tls_cache_ut.cpp +++ b/library/cpp/codecs/ut/tls_cache_ut.cpp @@ -1,7 +1,7 @@ #include <library/cpp/testing/unittest/registar.h> #include <library/cpp/codecs/tls_cache.h> -Y_UNIT_TEST_SUITE(CodecsBufferFactoryTest){ +Y_UNIT_TEST_SUITE(CodecsBufferFactoryTest){ void AssignToBuffer(TBuffer & buf, TStringBuf val){ buf.Assign(val.data(), val.size()); } @@ -10,7 +10,7 @@ TStringBuf AsStringBuf(const TBuffer& b) { return TStringBuf(b.Data(), b.Size()); } -Y_UNIT_TEST(TestAcquireReleaseReuse) { +Y_UNIT_TEST(TestAcquireReleaseReuse) { NCodecs::TBufferTlsCache factory; // acquiring the first buffer auto buf1 = factory.Item(); diff --git a/library/cpp/codecs/zstd_dict_codec.cpp b/library/cpp/codecs/zstd_dict_codec.cpp index c42a2879e6c..5ae8dcd3246 100644 --- a/library/cpp/codecs/zstd_dict_codec.cpp +++ b/library/cpp/codecs/zstd_dict_codec.cpp @@ -183,11 +183,11 @@ namespace NCodecs { return true; } - void Save(IOutputStream* out) const { + void Save(IOutputStream* out) const { ::Save(out, Dict); } - void Load(IInputStream* in) { + void Load(IInputStream* in) { ::Load(in, Dict); InitContexts(); } @@ -255,11 +255,11 @@ namespace NCodecs { return Impl->Learn(in, false/*throwOnError*/); } - void TZStdDictCodec::Save(IOutputStream* out) const { + void TZStdDictCodec::Save(IOutputStream* out) const { Impl->Save(out); } - void TZStdDictCodec::Load(IInputStream* in) { + void TZStdDictCodec::Load(IInputStream* in) { Impl->Load(in); } diff --git a/library/cpp/colorizer/colors.cpp b/library/cpp/colorizer/colors.cpp index decc5c9847d..004adeee6ea 100644 --- a/library/cpp/colorizer/colors.cpp +++ b/library/cpp/colorizer/colors.cpp @@ -452,7 +452,7 @@ TColors& NColorizer::StdOut() { return *Singleton<TStdOutColors>(); } -TColors& NColorizer::AutoColors(IOutputStream& os) { +TColors& NColorizer::AutoColors(IOutputStream& os) { if (&os == &Cerr) { return StdErr(); } diff --git a/library/cpp/colorizer/colors.h b/library/cpp/colorizer/colors.h index 474a918994e..690090b7d3f 100644 --- a/library/cpp/colorizer/colors.h +++ b/library/cpp/colorizer/colors.h @@ -218,7 +218,7 @@ namespace NColorizer { /// Choose `TColors` depending on output stream. If passed stream is stderr/stdout, return a corresponding /// singletone. Otherwise, return a disabled singletone (which you can, but should *not* enable). - TColors& AutoColors(IOutputStream& os); + TColors& AutoColors(IOutputStream& os); /// Calculate total length of all ANSI escape codes in the text. size_t TotalAnsiEscapeCodeLen(TStringBuf text); diff --git a/library/cpp/colorizer/fwd.h b/library/cpp/colorizer/fwd.h index d71efdc0534..f07ed5dda27 100644 --- a/library/cpp/colorizer/fwd.h +++ b/library/cpp/colorizer/fwd.h @@ -1,11 +1,11 @@ #pragma once -class IOutputStream; +class IOutputStream; namespace NColorizer { class TColors; TColors& StdErr(); TColors& StdOut(); - TColors& AutoColors(IOutputStream&); + TColors& AutoColors(IOutputStream&); } diff --git a/library/cpp/colorizer/output.cpp b/library/cpp/colorizer/output.cpp index 66a56266751..70698d66f04 100644 --- a/library/cpp/colorizer/output.cpp +++ b/library/cpp/colorizer/output.cpp @@ -5,6 +5,6 @@ using namespace NColorizer; template <> -void Out<TColorHandle>(IOutputStream& o, const TColorHandle& h) { +void Out<TColorHandle>(IOutputStream& o, const TColorHandle& h) { o << (*(h.C).*h.F)(); } diff --git a/library/cpp/colorizer/ut/colorizer_ut.cpp b/library/cpp/colorizer/ut/colorizer_ut.cpp index 20341440aff..ec270d605ef 100644 --- a/library/cpp/colorizer/ut/colorizer_ut.cpp +++ b/library/cpp/colorizer/ut/colorizer_ut.cpp @@ -5,8 +5,8 @@ #include <util/string/escape.h> -Y_UNIT_TEST_SUITE(ColorizerTest) { - Y_UNIT_TEST(BasicTest) { +Y_UNIT_TEST_SUITE(ColorizerTest) { + Y_UNIT_TEST(BasicTest) { NColorizer::TColors colors; colors.Enable(); UNIT_ASSERT_STRINGS_EQUAL(EscapeC(colors.BlueColor()), "\\x1B[22;34m"); @@ -15,7 +15,7 @@ Y_UNIT_TEST_SUITE(ColorizerTest) { UNIT_ASSERT(colors.BlueColor().Empty()); } - Y_UNIT_TEST(ResettingTest) { + Y_UNIT_TEST(ResettingTest) { NColorizer::TColors colors; colors.Enable(); // 22;39, not 0, should be used so that only foreground changes diff --git a/library/cpp/compproto/compproto_ut.cpp b/library/cpp/compproto/compproto_ut.cpp index 9393be967a3..9dfb947e1c7 100644 --- a/library/cpp/compproto/compproto_ut.cpp +++ b/library/cpp/compproto/compproto_ut.cpp @@ -108,7 +108,7 @@ void Test(const TString& metainfo, const ECompMode mode) { } } -Y_UNIT_TEST_SUITE(CompProtoTestBasic) { +Y_UNIT_TEST_SUITE(CompProtoTestBasic) { using namespace NCompProto; const TString metainfo = @@ -254,7 +254,7 @@ Y_UNIT_TEST_SUITE(CompProtoTestBasic) { TMap<ui32, TRegInfo>::iterator RegIter; TMetaIterator<TVerifyingDecompressor>& GetDecompressor(size_t index) { - Y_UNUSED(index); + Y_UNUSED(index); return *Parent; } @@ -354,24 +354,24 @@ Y_UNIT_TEST_SUITE(CompProtoTestBasic) { } }; - Y_UNIT_TEST(VerifyDecompression) { + Y_UNIT_TEST(VerifyDecompression) { Test<TVerifyingDecompressor, TSerialize>(metainfo, CM_SINGLEPASS); } - Y_UNIT_TEST(VerifyHistDecompression) { + Y_UNIT_TEST(VerifyHistDecompression) { Test<TVerifyingDecompressor, TSerialize>(metainfo, CM_TWOPASS); } - Y_UNIT_TEST(VerifyDecompressionMulti) { + Y_UNIT_TEST(VerifyDecompressionMulti) { Test<TMultiDecompressor, TSerialize>(metainfo, CM_SINGLEPASS); } - Y_UNIT_TEST(VerifyHistDecompressionMulti) { + Y_UNIT_TEST(VerifyHistDecompressionMulti) { Test<TMultiDecompressor, TSerialize>(metainfo, CM_TWOPASS); } } -Y_UNIT_TEST_SUITE(CompProtoTestExtended) { +Y_UNIT_TEST_SUITE(CompProtoTestExtended) { using namespace NCompProto; const TString metainfo = "\n\ @@ -447,7 +447,7 @@ Y_UNIT_TEST_SUITE(CompProtoTestExtended) { } TMetaIterator<TVerifyingDecompressor>& GetDecompressor(size_t index) { - Y_UNUSED(index); + Y_UNUSED(index); return *Parent; } @@ -533,11 +533,11 @@ Y_UNIT_TEST_SUITE(CompProtoTestExtended) { } } }; - Y_UNIT_TEST(VerifyDecompression) { + Y_UNIT_TEST(VerifyDecompression) { Test<TVerifyingDecompressor, TSerialize>(metainfo, CM_SINGLEPASS); } - Y_UNIT_TEST(VerifyHistDecompression) { + Y_UNIT_TEST(VerifyHistDecompression) { Test<TVerifyingDecompressor, TSerialize>(metainfo, CM_TWOPASS); } } diff --git a/library/cpp/comptable/comptable.h b/library/cpp/comptable/comptable.h index d225fed7a0b..18f0b6ec819 100644 --- a/library/cpp/comptable/comptable.h +++ b/library/cpp/comptable/comptable.h @@ -66,10 +66,10 @@ namespace NCompTable { template <> class TSerializer<NCompTable::TCompressorTable> { public: - static inline void Save(IOutputStream* out, const NCompTable::TCompressorTable& entry) { + static inline void Save(IOutputStream* out, const NCompTable::TCompressorTable& entry) { SavePodType(out, entry); } - static inline void Load(IInputStream* in, NCompTable::TCompressorTable& entry) { + static inline void Load(IInputStream* in, NCompTable::TCompressorTable& entry) { LoadPodType(in, entry); } }; diff --git a/library/cpp/comptable/usage/usage.cpp b/library/cpp/comptable/usage/usage.cpp index 9997c83686a..9fb9cd6e3b1 100644 --- a/library/cpp/comptable/usage/usage.cpp +++ b/library/cpp/comptable/usage/usage.cpp @@ -69,7 +69,7 @@ int main(int argc, const char* argv[]) { DoTest<true>(table, lines); DoTest<false>(table, lines); - Y_UNUSED(argc); - Y_UNUSED(argv); + Y_UNUSED(argc); + Y_UNUSED(argv); return 0; } diff --git a/library/cpp/comptable/ut/comptable_ut.cpp b/library/cpp/comptable/ut/comptable_ut.cpp index 5901d0246fb..ff17b80aaef 100644 --- a/library/cpp/comptable/ut/comptable_ut.cpp +++ b/library/cpp/comptable/ut/comptable_ut.cpp @@ -39,8 +39,8 @@ void DoTest(const TCompressorTable& table, const TVector<TString>& lines) { UNIT_ASSERT(compSize < origSize); } -Y_UNIT_TEST_SUITE(TestComptable) { - Y_UNIT_TEST(TestComptableCompressDecompress) { +Y_UNIT_TEST_SUITE(TestComptable) { + Y_UNIT_TEST(TestComptableCompressDecompress) { TReallyFastRng32 rr(17); TVector<TString> lines; for (size_t i = 0; i < 1000000; ++i) { diff --git a/library/cpp/containers/2d_array/2d_array.h b/library/cpp/containers/2d_array/2d_array.h index 9e246506370..aa47f399331 100644 --- a/library/cpp/containers/2d_array/2d_array.h +++ b/library/cpp/containers/2d_array/2d_array.h @@ -13,7 +13,7 @@ struct TBoundCheck { Size = s; } T& operator[](size_t i) const { - Y_ASSERT(i >= 0 && i < Size); + Y_ASSERT(i >= 0 && i < Size); return Data[i]; } }; diff --git a/library/cpp/containers/bitseq/bititerator.h b/library/cpp/containers/bitseq/bititerator.h index 52dadd37982..bbeadb7295f 100644 --- a/library/cpp/containers/bitseq/bititerator.h +++ b/library/cpp/containers/bitseq/bititerator.h @@ -44,7 +44,7 @@ public: TWord Peek(ui8 count) const { if (!count) return 0; - Y_VERIFY_DEBUG(count <= TTraits::NumBits); + Y_VERIFY_DEBUG(count <= TTraits::NumBits); if (!Mask) return *Data & TTraits::ElemMask(count); @@ -64,7 +64,7 @@ public: TWord Read(ui8 count) { if (!count) return 0; - Y_VERIFY_DEBUG(count <= TTraits::NumBits); + Y_VERIFY_DEBUG(count <= TTraits::NumBits); if (!Mask) { Current = *Data++; diff --git a/library/cpp/containers/bitseq/bititerator_ut.cpp b/library/cpp/containers/bitseq/bititerator_ut.cpp index ed0925866f6..a7bbec119ff 100644 --- a/library/cpp/containers/bitseq/bititerator_ut.cpp +++ b/library/cpp/containers/bitseq/bititerator_ut.cpp @@ -3,7 +3,7 @@ #include <library/cpp/testing/unittest/registar.h> #include <util/generic/vector.h> -Y_UNIT_TEST_SUITE(TBitIteratorTest) { +Y_UNIT_TEST_SUITE(TBitIteratorTest) { TVector<ui16> GenWords() { TVector<ui16> words(1, 0); for (ui16 word = 1; word; ++word) @@ -19,7 +19,7 @@ Y_UNIT_TEST_SUITE(TBitIteratorTest) { UNIT_ASSERT_EQUAL(peek, expected); } - Y_UNIT_TEST(TestNextAndPeek) { + Y_UNIT_TEST(TestNextAndPeek) { const auto& words = GenWords(); TBitIterator<ui16> iter(words.data()); @@ -37,7 +37,7 @@ Y_UNIT_TEST_SUITE(TBitIteratorTest) { UNIT_ASSERT_EQUAL(iter.NextWord(), words.data() + words.size()); } - Y_UNIT_TEST(TestAlignedReadAndPeek) { + Y_UNIT_TEST(TestAlignedReadAndPeek) { const auto& words = GenWords(); TBitIterator<ui16> iter(words.data()); @@ -50,7 +50,7 @@ Y_UNIT_TEST_SUITE(TBitIteratorTest) { UNIT_ASSERT_EQUAL(iter.NextWord(), words.data() + words.size()); } - Y_UNIT_TEST(TestForward) { + Y_UNIT_TEST(TestForward) { TVector<ui32> words; words.push_back((1 << 10) | (1 << 20) | (1 << 25)); words.push_back(1 | (1 << 5) | (1 << 6) | (1 << 30)); @@ -89,7 +89,7 @@ Y_UNIT_TEST_SUITE(TBitIteratorTest) { UNIT_ASSERT_EQUAL(iter.NextWord(), words.data() + 6); } - Y_UNIT_TEST(TestUnalignedReadAndPeek) { + Y_UNIT_TEST(TestUnalignedReadAndPeek) { TVector<ui32> words; words.push_back((1 << 10) | (1 << 20) | (1 << 25)); words.push_back(1 | (1 << 5) | (1 << 6) | (1 << 30)); diff --git a/library/cpp/containers/bitseq/bitvector.h b/library/cpp/containers/bitseq/bitvector.h index 3f8fd81ee57..9d6471ea9a9 100644 --- a/library/cpp/containers/bitseq/bitvector.h +++ b/library/cpp/containers/bitseq/bitvector.h @@ -52,7 +52,7 @@ public: } bool Set(ui64 pos) { - Y_ASSERT(pos < Size_); + Y_ASSERT(pos < Size_); TWord& val = Data_[pos >> TTraits::DivShift]; if (val & TTraits::BitMask(pos & TTraits::ModMask)) return false; @@ -65,7 +65,7 @@ public: } void Reset(ui64 pos) { - Y_ASSERT(pos < Size_); + Y_ASSERT(pos < Size_); Data_[pos >> TTraits::DivShift] &= ~TTraits::BitMask(pos & TTraits::ModMask); } @@ -80,7 +80,7 @@ public: void Set(ui64 pos, TWord value, ui8 width, TWord mask) { if (!width) return; - Y_ASSERT((pos + width) <= Size_); + Y_ASSERT((pos + width) <= Size_); size_t word = pos >> TTraits::DivShift; TWord shift1 = pos & TTraits::ModMask; TWord shift2 = TTraits::NumBits - shift1; @@ -130,12 +130,12 @@ public: return Data_.data(); } - void Save(IOutputStream* out) const { + void Save(IOutputStream* out) const { ::Save(out, Size_); ::Save(out, Data_); } - void Load(IInputStream* inp) { + void Load(IInputStream* inp) { ::Load(inp, Size_); ::Load(inp, Data_); } @@ -145,7 +145,7 @@ public: Data_.size() * sizeof(TWord)); } - void Print(IOutputStream& out, size_t truncate = 128) { + void Print(IOutputStream& out, size_t truncate = 128) { for (size_t i = 0; i < Data_.size() && i < truncate; ++i) { for (int j = TTraits::NumBits - 1; j >= 0; --j) { size_t pos = TTraits::NumBits * i + j; diff --git a/library/cpp/containers/bitseq/bitvector_ut.cpp b/library/cpp/containers/bitseq/bitvector_ut.cpp index 6137adab1e8..3fd4df1de60 100644 --- a/library/cpp/containers/bitseq/bitvector_ut.cpp +++ b/library/cpp/containers/bitseq/bitvector_ut.cpp @@ -6,8 +6,8 @@ #include <util/memory/blob.h> #include <util/stream/buffer.h> -Y_UNIT_TEST_SUITE(TBitVectorTest) { - Y_UNIT_TEST(TestEmpty) { +Y_UNIT_TEST_SUITE(TBitVectorTest) { + Y_UNIT_TEST(TestEmpty) { TBitVector<ui64> v64; UNIT_ASSERT_EQUAL(v64.Size(), 0); UNIT_ASSERT_EQUAL(v64.Words(), 0); @@ -17,7 +17,7 @@ Y_UNIT_TEST_SUITE(TBitVectorTest) { UNIT_ASSERT_EQUAL(v32.Words(), 0); } - Y_UNIT_TEST(TestOneWord) { + Y_UNIT_TEST(TestOneWord) { TBitVector<ui32> v; v.Append(1, 1); v.Append(0, 1); @@ -42,7 +42,7 @@ Y_UNIT_TEST_SUITE(TBitVectorTest) { UNIT_ASSERT_EQUAL(v.Words(), 1); } - Y_UNIT_TEST(TestManyWords) { + Y_UNIT_TEST(TestManyWords) { static const int BITS = 10; TBitVector<ui64> v; @@ -55,7 +55,7 @@ Y_UNIT_TEST_SUITE(TBitVectorTest) { UNIT_ASSERT_EQUAL(v.Get(i * BITS, BITS), (ui64)i); } - Y_UNIT_TEST(TestMaxWordSize) { + Y_UNIT_TEST(TestMaxWordSize) { TBitVector<ui32> v; for (int i = 0; i < 100; ++i) v.Append(i, 32); @@ -67,7 +67,7 @@ Y_UNIT_TEST_SUITE(TBitVectorTest) { UNIT_ASSERT_EQUAL(v.Get(10 * 32, 32), 100500); } - Y_UNIT_TEST(TestReadonlyVector) { + Y_UNIT_TEST(TestReadonlyVector) { TBitVector<ui64> v(100); for (ui64 i = 0; i < v.Size(); ++i) { if (i % 3 == 0) { diff --git a/library/cpp/containers/bitseq/traits.h b/library/cpp/containers/bitseq/traits.h index 2330b1b4f29..a57f15d7b37 100644 --- a/library/cpp/containers/bitseq/traits.h +++ b/library/cpp/containers/bitseq/traits.h @@ -1,6 +1,6 @@ #pragma once -#include <util/generic/bitops.h> +#include <util/generic/bitops.h> #include <util/generic/typetraits.h> #include <util/system/yassert.h> @@ -12,7 +12,7 @@ struct TBitSeqTraits { static inline TWord ElemMask(ui8 count) { // NOTE: Shifting by the type's length is UB, so we need this workaround. - if (Y_LIKELY(count)) + if (Y_LIKELY(count)) return TWord(-1) >> (NumBits - count); return 0; } diff --git a/library/cpp/containers/compact_vector/compact_vector.h b/library/cpp/containers/compact_vector/compact_vector.h index dbe7473f0cc..434eda0f1a8 100644 --- a/library/cpp/containers/compact_vector/compact_vector.h +++ b/library/cpp/containers/compact_vector/compact_vector.h @@ -162,14 +162,14 @@ public: } TIterator Insert(TIterator pos, const T& elem) { - Y_ASSERT(pos >= Begin()); - Y_ASSERT(pos <= End()); + Y_ASSERT(pos >= Begin()); + Y_ASSERT(pos <= End()); size_t posn = pos - Begin(); if (pos == End()) { PushBack(elem); } else { - Y_ASSERT(Size() > 0); + Y_ASSERT(Size() > 0); Reserve(Size() + 1); @@ -198,12 +198,12 @@ public: } T& operator[](size_t index) { - Y_ASSERT(index < Size()); + Y_ASSERT(index < Size()); return Ptr[index]; } const T& operator[](size_t index) const { - Y_ASSERT(index < Size()); + Y_ASSERT(index < Size()); return Ptr[index]; } }; diff --git a/library/cpp/containers/compact_vector/compact_vector_ut.cpp b/library/cpp/containers/compact_vector/compact_vector_ut.cpp index 7d413d65759..4f5ec0ad100 100644 --- a/library/cpp/containers/compact_vector/compact_vector_ut.cpp +++ b/library/cpp/containers/compact_vector/compact_vector_ut.cpp @@ -2,11 +2,11 @@ #include "compact_vector.h" -Y_UNIT_TEST_SUITE(TCompactVectorTest) { - Y_UNIT_TEST(TestSimple1) { +Y_UNIT_TEST_SUITE(TCompactVectorTest) { + Y_UNIT_TEST(TestSimple1) { } - Y_UNIT_TEST(TestSimple) { + Y_UNIT_TEST(TestSimple) { TCompactVector<ui32> vector; for (ui32 i = 0; i < 10000; ++i) { vector.PushBack(i + 20); @@ -17,7 +17,7 @@ Y_UNIT_TEST_SUITE(TCompactVectorTest) { } } - Y_UNIT_TEST(TestInsert) { + Y_UNIT_TEST(TestInsert) { TCompactVector<ui32> vector; for (ui32 i = 0; i < 10; ++i) { diff --git a/library/cpp/containers/comptrie/chunked_helpers_trie.h b/library/cpp/containers/comptrie/chunked_helpers_trie.h index cfa35f5ba2a..993a9f800f9 100644 --- a/library/cpp/containers/comptrie/chunked_helpers_trie.h +++ b/library/cpp/containers/comptrie/chunked_helpers_trie.h @@ -48,7 +48,7 @@ public: return Builder.Find(key, strlen(key), &dummy); } - void Save(IOutputStream& out) const { + void Save(IOutputStream& out) const { Builder.Save(out); } @@ -164,7 +164,7 @@ public: } } - void Save(IOutputStream& out, bool minimize = false) const { + void Save(IOutputStream& out, bool minimize = false) const { if (minimize) { CompactTrieMinimize<TBuilder>(out, Builder, false); } else { @@ -191,7 +191,7 @@ public: Values.push_back(TValue(key, value)); } - void Save(IOutputStream& out) { + void Save(IOutputStream& out) { Sort(Values.begin(), Values.end()); TTrieMapWriter<T, true> writer; for (typename TValues::const_iterator toValue = Values.begin(); toValue != Values.end(); ++toValue) diff --git a/library/cpp/containers/comptrie/comptrie_builder.h b/library/cpp/containers/comptrie/comptrie_builder.h index cf7d2e39a34..8b5adf060c4 100644 --- a/library/cpp/containers/comptrie/comptrie_builder.h +++ b/library/cpp/containers/comptrie/comptrie_builder.h @@ -81,8 +81,8 @@ public: return FindLongestPrefix(key.data(), key.size(), prefixLen, value); } - size_t Save(IOutputStream& os) const; - size_t SaveAndDestroy(IOutputStream& os); + size_t Save(IOutputStream& os) const; + size_t SaveAndDestroy(IOutputStream& os); size_t SaveToFile(const TString& fileName) const { TFixedBufferFileOutput out(fileName); return Save(out); @@ -118,10 +118,10 @@ protected: // If you want both minimization and fast layout, do the minimization first. template <class TPacker> -size_t CompactTrieMinimize(IOutputStream& os, const char* data, size_t datalength, bool verbose = false, const TPacker& packer = TPacker(), NCompactTrie::EMinimizeMode mode = NCompactTrie::MM_DEFAULT); +size_t CompactTrieMinimize(IOutputStream& os, const char* data, size_t datalength, bool verbose = false, const TPacker& packer = TPacker(), NCompactTrie::EMinimizeMode mode = NCompactTrie::MM_DEFAULT); template <class TTrieBuilder> -size_t CompactTrieMinimize(IOutputStream& os, const TTrieBuilder& builder, bool verbose = false); +size_t CompactTrieMinimize(IOutputStream& os, const TTrieBuilder& builder, bool verbose = false); //---------------------------------------------------------------------------------------------------------------- // Lay the trie in memory in such a way that there are less cache misses when jumping from root to leaf. @@ -143,17 +143,17 @@ size_t CompactTrieMinimize(IOutputStream& os, const TTrieBuilder& builder, bool // (there is not much difference between these papers, actually). // template <class TPacker> -size_t CompactTrieMakeFastLayout(IOutputStream& os, const char* data, size_t datalength, bool verbose = false, const TPacker& packer = TPacker()); +size_t CompactTrieMakeFastLayout(IOutputStream& os, const char* data, size_t datalength, bool verbose = false, const TPacker& packer = TPacker()); template <class TTrieBuilder> -size_t CompactTrieMakeFastLayout(IOutputStream& os, const TTrieBuilder& builder, bool verbose = false); +size_t CompactTrieMakeFastLayout(IOutputStream& os, const TTrieBuilder& builder, bool verbose = false); // Composition of minimization and fast layout template <class TPacker> -size_t CompactTrieMinimizeAndMakeFastLayout(IOutputStream& os, const char* data, size_t datalength, bool verbose = false, const TPacker& packer = TPacker()); +size_t CompactTrieMinimizeAndMakeFastLayout(IOutputStream& os, const char* data, size_t datalength, bool verbose = false, const TPacker& packer = TPacker()); template <class TTrieBuilder> -size_t CompactTrieMinimizeAndMakeFastLayout(IOutputStream& os, const TTrieBuilder& builder, bool verbose = false); +size_t CompactTrieMinimizeAndMakeFastLayout(IOutputStream& os, const TTrieBuilder& builder, bool verbose = false); // Implementation details moved here. #include "comptrie_builder.inl" diff --git a/library/cpp/containers/comptrie/comptrie_builder.inl b/library/cpp/containers/comptrie/comptrie_builder.inl index f273fa65710..612a1bbe95d 100644 --- a/library/cpp/containers/comptrie/comptrie_builder.inl +++ b/library/cpp/containers/comptrie/comptrie_builder.inl @@ -53,18 +53,18 @@ protected: bool FindLongestPrefixImpl(const char* keyptr, size_t keylen, size_t* prefixLen, TData* value) const; size_t NodeMeasureSubtree(TNode* thiz) const; - ui64 NodeSaveSubtree(TNode* thiz, IOutputStream& os) const; - ui64 NodeSaveSubtreeAndDestroy(TNode* thiz, IOutputStream& osy); + ui64 NodeSaveSubtree(TNode* thiz, IOutputStream& os) const; + ui64 NodeSaveSubtreeAndDestroy(TNode* thiz, IOutputStream& osy); void NodeBufferSubtree(TNode* thiz); size_t NodeMeasureLeafValue(TNode* thiz) const; - ui64 NodeSaveLeafValue(TNode* thiz, IOutputStream& os) const; + ui64 NodeSaveLeafValue(TNode* thiz, IOutputStream& os) const; virtual ui64 ArcMeasure(const TArc* thiz, size_t leftsize, size_t rightsize) const; virtual ui64 ArcSaveSelf(const TArc* thiz, IOutputStream& os) const; - ui64 ArcSave(const TArc* thiz, IOutputStream& os) const; - ui64 ArcSaveAndDestroy(const TArc* thiz, IOutputStream& os); + ui64 ArcSave(const TArc* thiz, IOutputStream& os) const; + ui64 ArcSaveAndDestroy(const TArc* thiz, IOutputStream& os); public: TCompactTrieBuilderImpl(TCompactTrieBuilderFlags flags, TPacker packer, IAllocator* alloc); @@ -83,8 +83,8 @@ public: bool FindEntry(const TSymbol* key, size_t keylen, TData* value) const; bool FindLongestPrefix(const TSymbol* key, size_t keylen, size_t* prefixlen, TData* value) const; - size_t Save(IOutputStream& os) const; - size_t SaveAndDestroy(IOutputStream& os); + size_t Save(IOutputStream& os) const; + size_t SaveAndDestroy(IOutputStream& os); void Clear(); @@ -118,8 +118,8 @@ public: virtual ~ISubtree() = default; virtual bool IsLast() const = 0; virtual ui64 Measure(const TBuilderImpl* builder) const = 0; - virtual ui64 Save(const TBuilderImpl* builder, IOutputStream& os) const = 0; - virtual ui64 SaveAndDestroy(TBuilderImpl* builder, IOutputStream& os) = 0; + virtual ui64 Save(const TBuilderImpl* builder, IOutputStream& os) const = 0; + virtual ui64 SaveAndDestroy(TBuilderImpl* builder, IOutputStream& os) = 0; virtual void Destroy(TBuilderImpl*) { } // Tries to find key in subtree. @@ -135,7 +135,7 @@ public: typedef typename TCompactVector<TArc>::const_iterator const_iterator; TArcSet() { - Y_ASSERT(reinterpret_cast<ISubtree*>(this) == static_cast<void*>(this)); // This assumption is used in TNode::Subtree() + Y_ASSERT(reinterpret_cast<ISubtree*>(this) == static_cast<void*>(this)); // This assumption is used in TNode::Subtree() } iterator Find(char ch); @@ -166,17 +166,17 @@ public: return builder->ArcMeasure(&(*this)[median], leftsize, rightsize); } - ui64 Save(const TBuilderImpl* builder, IOutputStream& os) const override { + ui64 Save(const TBuilderImpl* builder, IOutputStream& os) const override { return SaveRange(builder, 0, this->size(), os); } - ui64 SaveAndDestroy(TBuilderImpl* builder, IOutputStream& os) override { + ui64 SaveAndDestroy(TBuilderImpl* builder, IOutputStream& os) override { ui64 result = SaveRangeAndDestroy(builder, 0, this->size(), os); Destroy(builder); return result; } - ui64 SaveRange(const TBuilderImpl* builder, size_t from, size_t to, IOutputStream& os) const { + ui64 SaveRange(const TBuilderImpl* builder, size_t from, size_t to, IOutputStream& os) const { if (from >= to) return 0; @@ -188,7 +188,7 @@ public: return written; } - ui64 SaveRangeAndDestroy(TBuilderImpl* builder, size_t from, size_t to, IOutputStream& os) { + ui64 SaveRangeAndDestroy(TBuilderImpl* builder, size_t from, size_t to, IOutputStream& os) { if (from >= to) return 0; @@ -209,7 +209,7 @@ public: } ~TArcSet() override { - Y_ASSERT(this->empty()); + Y_ASSERT(this->empty()); } }; @@ -218,7 +218,7 @@ public: TArrayWithSizeHolder<char> Buffer; TBufferedSubtree() { - Y_ASSERT(reinterpret_cast<ISubtree*>(this) == static_cast<void*>(this)); // This assumption is used in TNode::Subtree() + Y_ASSERT(reinterpret_cast<ISubtree*>(this) == static_cast<void*>(this)); // This assumption is used in TNode::Subtree() } bool IsLast() const override { @@ -255,12 +255,12 @@ public: return Buffer.Size(); } - ui64 Save(const TBuilderImpl*, IOutputStream& os) const override { + ui64 Save(const TBuilderImpl*, IOutputStream& os) const override { os.Write(Buffer.Get(), Buffer.Size()); return Buffer.Size(); } - ui64 SaveAndDestroy(TBuilderImpl* builder, IOutputStream& os) override { + ui64 SaveAndDestroy(TBuilderImpl* builder, IOutputStream& os) override { ui64 result = Save(builder, os); TArrayWithSizeHolder<char>().Swap(Buffer); return result; @@ -284,7 +284,7 @@ public: Data->FileName = fileName; Data->Size = size; - Y_ASSERT(reinterpret_cast<ISubtree*>(this) == static_cast<void*>(this)); // This assumption is used in TNode::Subtree() + Y_ASSERT(reinterpret_cast<ISubtree*>(this) == static_cast<void*>(this)); // This assumption is used in TNode::Subtree() } bool IsLast() const override { @@ -320,7 +320,7 @@ public: return Data->Size; } - ui64 Save(const TBuilderImpl*, IOutputStream& os) const override { + ui64 Save(const TBuilderImpl*, IOutputStream& os) const override { TUnbufferedFileInput is(Data->FileName); ui64 written = TransferData(&is, &os); if (written != Data->Size) @@ -328,7 +328,7 @@ public: return written; } - ui64 SaveAndDestroy(TBuilderImpl* builder, IOutputStream& os) override { + ui64 SaveAndDestroy(TBuilderImpl* builder, IOutputStream& os) override { return Save(builder, os); } }; @@ -412,7 +412,7 @@ public: ~TNode() { Subtree()->~ISubtree(); - Y_ASSERT(PayloadType == DATA_ABSENT); + Y_ASSERT(PayloadType == DATA_ABSENT); } }; @@ -457,12 +457,12 @@ bool TCompactTrieBuilder<T, D, S>::FindLongestPrefix( } template <class T, class D, class S> -size_t TCompactTrieBuilder<T, D, S>::Save(IOutputStream& os) const { +size_t TCompactTrieBuilder<T, D, S>::Save(IOutputStream& os) const { return Impl->Save(os); } template <class T, class D, class S> -size_t TCompactTrieBuilder<T, D, S>::SaveAndDestroy(IOutputStream& os) { +size_t TCompactTrieBuilder<T, D, S>::SaveAndDestroy(IOutputStream& os) { return Impl->SaveAndDestroy(os); } @@ -509,13 +509,13 @@ void TCompactTrieBuilder<T, D, S>::TCompactTrieBuilderImpl::ConvertSymbolArrayTo for (size_t i = 0; i < keylen; ++i) { TSymbol label = key[i]; for (int j = (int)NCompactTrie::ExtraBits<TSymbol>(); j >= 0; j -= 8) { - Y_ASSERT(ckeyptr < buf.Data() + buflen); + Y_ASSERT(ckeyptr < buf.Data() + buflen); *(ckeyptr++) = (char)(label >> j); } } buf.Proceed(buflen); - Y_ASSERT(ckeyptr == buf.Data() + buf.Filled()); + Y_ASSERT(ckeyptr == buf.Data() + buf.Filled()); } template <class T, class D, class S> @@ -750,7 +750,7 @@ void TCompactTrieBuilder<T, D, S>::TCompactTrieBuilderImpl::Clear() { } template <class T, class D, class S> -size_t TCompactTrieBuilder<T, D, S>::TCompactTrieBuilderImpl::Save(IOutputStream& os) const { +size_t TCompactTrieBuilder<T, D, S>::TCompactTrieBuilderImpl::Save(IOutputStream& os) const { const size_t len = NodeMeasureSubtree(Root); if (len != NodeSaveSubtree(Root, os)) ythrow yexception() << "something wrong"; @@ -759,7 +759,7 @@ size_t TCompactTrieBuilder<T, D, S>::TCompactTrieBuilderImpl::Save(IOutputStream } template <class T, class D, class S> -size_t TCompactTrieBuilder<T, D, S>::TCompactTrieBuilderImpl::SaveAndDestroy(IOutputStream& os) { +size_t TCompactTrieBuilder<T, D, S>::TCompactTrieBuilderImpl::SaveAndDestroy(IOutputStream& os) { const size_t len = NodeMeasureSubtree(Root); if (len != NodeSaveSubtreeAndDestroy(Root, os)) ythrow yexception() << "something wrong"; @@ -829,12 +829,12 @@ size_t TCompactTrieBuilder<T, D, S>::TCompactTrieBuilderImpl::NodeMeasureSubtree } template <class T, class D, class S> -ui64 TCompactTrieBuilder<T, D, S>::TCompactTrieBuilderImpl::NodeSaveSubtree(TNode* thiz, IOutputStream& os) const { +ui64 TCompactTrieBuilder<T, D, S>::TCompactTrieBuilderImpl::NodeSaveSubtree(TNode* thiz, IOutputStream& os) const { return thiz->Subtree()->Save(this, os); } template <class T, class D, class S> -ui64 TCompactTrieBuilder<T, D, S>::TCompactTrieBuilderImpl::NodeSaveSubtreeAndDestroy(TNode* thiz, IOutputStream& os) { +ui64 TCompactTrieBuilder<T, D, S>::TCompactTrieBuilderImpl::NodeSaveSubtreeAndDestroy(TNode* thiz, IOutputStream& os) { return thiz->Subtree()->SaveAndDestroy(this, os); } @@ -853,7 +853,7 @@ void TCompactTrieBuilder<T, D, S>::TCompactTrieBuilderImpl::NodeBufferSubtree(TN TMemoryOutput bufout(buffer.Get(), buffer.Size()); ui64 written = arcSet->Save(this, bufout); - Y_ASSERT(written == bufferLength); + Y_ASSERT(written == bufferLength); arcSet->Destroy(this); arcSet->~TArcSet(); @@ -872,7 +872,7 @@ size_t TCompactTrieBuilder<T, D, S>::TCompactTrieBuilderImpl::NodeMeasureLeafVal } template <class T, class D, class S> -ui64 TCompactTrieBuilder<T, D, S>::TCompactTrieBuilderImpl::NodeSaveLeafValue(TNode* thiz, IOutputStream& os) const { +ui64 TCompactTrieBuilder<T, D, S>::TCompactTrieBuilderImpl::NodeSaveLeafValue(TNode* thiz, IOutputStream& os) const { if (!thiz->IsFinal()) return 0; @@ -919,7 +919,7 @@ ui64 TCompactTrieBuilder<T, D, S>::TCompactTrieBuilderImpl::ArcMeasure( } template <class T, class D, class S> -ui64 TCompactTrieBuilder<T, D, S>::TCompactTrieBuilderImpl::ArcSaveSelf(const TArc* thiz, IOutputStream& os) const { +ui64 TCompactTrieBuilder<T, D, S>::TCompactTrieBuilderImpl::ArcSaveSelf(const TArc* thiz, IOutputStream& os) const { using namespace NCompactTrie; ui64 written = 0; @@ -962,14 +962,14 @@ ui64 TCompactTrieBuilder<T, D, S>::TCompactTrieBuilderImpl::ArcSaveSelf(const TA } template <class T, class D, class S> -ui64 TCompactTrieBuilder<T, D, S>::TCompactTrieBuilderImpl::ArcSave(const TArc* thiz, IOutputStream& os) const { +ui64 TCompactTrieBuilder<T, D, S>::TCompactTrieBuilderImpl::ArcSave(const TArc* thiz, IOutputStream& os) const { ui64 written = ArcSaveSelf(thiz, os); written += NodeSaveSubtree(thiz->Node, os); return written; } template <class T, class D, class S> -ui64 TCompactTrieBuilder<T, D, S>::TCompactTrieBuilderImpl::ArcSaveAndDestroy(const TArc* thiz, IOutputStream& os) { +ui64 TCompactTrieBuilder<T, D, S>::TCompactTrieBuilderImpl::ArcSaveAndDestroy(const TArc* thiz, IOutputStream& os) { ui64 written = ArcSaveSelf(thiz, os); written += NodeSaveSubtreeAndDestroy(thiz->Node, os); return written; @@ -1061,13 +1061,13 @@ const typename TCompactTrieBuilder<T, D, S>::TCompactTrieBuilderImpl::TNode* // as you expect it to, and can destroy the trie in the making. template <class TPacker> -size_t CompactTrieMinimize(IOutputStream& os, const char* data, size_t datalength, bool verbose /*= false*/, const TPacker& packer /*= TPacker()*/, NCompactTrie::EMinimizeMode mode) { +size_t CompactTrieMinimize(IOutputStream& os, const char* data, size_t datalength, bool verbose /*= false*/, const TPacker& packer /*= TPacker()*/, NCompactTrie::EMinimizeMode mode) { using namespace NCompactTrie; return CompactTrieMinimizeImpl(os, data, datalength, verbose, &packer, mode); } template <class TTrieBuilder> -size_t CompactTrieMinimize(IOutputStream& os, const TTrieBuilder& builder, bool verbose /*=false*/) { +size_t CompactTrieMinimize(IOutputStream& os, const TTrieBuilder& builder, bool verbose /*=false*/) { TBufferStream buftmp; size_t len = builder.Save(buftmp); return CompactTrieMinimize<typename TTrieBuilder::TPacker>(os, buftmp.Buffer().Data(), len, verbose); @@ -1093,27 +1093,27 @@ size_t CompactTrieMinimize(IOutputStream& os, const TTrieBuilder& builder, bool // (there is not much difference between these papers, actually). // template <class TPacker> -size_t CompactTrieMakeFastLayout(IOutputStream& os, const char* data, size_t datalength, bool verbose /*= false*/, const TPacker& packer /*= TPacker()*/) { +size_t CompactTrieMakeFastLayout(IOutputStream& os, const char* data, size_t datalength, bool verbose /*= false*/, const TPacker& packer /*= TPacker()*/) { using namespace NCompactTrie; return CompactTrieMakeFastLayoutImpl(os, data, datalength, verbose, &packer); } template <class TTrieBuilder> -size_t CompactTrieMakeFastLayout(IOutputStream& os, const TTrieBuilder& builder, bool verbose /*=false*/) { +size_t CompactTrieMakeFastLayout(IOutputStream& os, const TTrieBuilder& builder, bool verbose /*=false*/) { TBufferStream buftmp; size_t len = builder.Save(buftmp); return CompactTrieMakeFastLayout<typename TTrieBuilder::TPacker>(os, buftmp.Buffer().Data(), len, verbose); } template <class TPacker> -size_t CompactTrieMinimizeAndMakeFastLayout(IOutputStream& os, const char* data, size_t datalength, bool verbose/*=false*/, const TPacker& packer/*= TPacker()*/) { +size_t CompactTrieMinimizeAndMakeFastLayout(IOutputStream& os, const char* data, size_t datalength, bool verbose/*=false*/, const TPacker& packer/*= TPacker()*/) { TBufferStream buftmp; size_t len = CompactTrieMinimize(buftmp, data, datalength, verbose, packer); return CompactTrieMakeFastLayout(os, buftmp.Buffer().Data(), len, verbose, packer); } template <class TTrieBuilder> -size_t CompactTrieMinimizeAndMakeFastLayout(IOutputStream& os, const TTrieBuilder& builder, bool verbose /*=false*/) { +size_t CompactTrieMinimizeAndMakeFastLayout(IOutputStream& os, const TTrieBuilder& builder, bool verbose /*=false*/) { TBufferStream buftmp; size_t len = CompactTrieMinimize(buftmp, builder, verbose); return CompactTrieMakeFastLayout<typename TTrieBuilder::TPacker>(os, buftmp.Buffer().Data(), len, verbose); diff --git a/library/cpp/containers/comptrie/comptrie_impl.h b/library/cpp/containers/comptrie/comptrie_impl.h index f41c38311a4..607b8e5d323 100644 --- a/library/cpp/containers/comptrie/comptrie_impl.h +++ b/library/cpp/containers/comptrie/comptrie_impl.h @@ -18,7 +18,7 @@ namespace NCompactTrie { Y_FORCE_INLINE size_t UnpackOffset(const char* p, size_t len); size_t MeasureOffset(size_t offset); size_t PackOffset(char* buffer, size_t offset); - static inline ui64 ArcSaveOffset(size_t offset, IOutputStream& os); + static inline ui64 ArcSaveOffset(size_t offset, IOutputStream& os); Y_FORCE_INLINE char LeapByte(const char*& datapos, const char* dataend, char label); template <class T> @@ -37,7 +37,7 @@ namespace NCompactTrie { } const size_t offsetlength = flags & MT_SIZEMASK; const size_t offset = UnpackOffset(datapos + 1, offsetlength); - Y_ASSERT(offset); + Y_ASSERT(offset); datapos += offset; } @@ -89,7 +89,7 @@ namespace NCompTriePrivate { } namespace NCompactTrie { - static inline ui64 ArcSaveOffset(size_t offset, IOutputStream& os) { + static inline ui64 ArcSaveOffset(size_t offset, IOutputStream& os) { using namespace NCompactTrie; if (!offset) @@ -127,7 +127,7 @@ namespace NCompactTrie { // These links are created during minimization: original uncompressed // tree does not need them. (If we find a way to package 3 offset lengths // into 1 byte, we could get rid of them; but it looks like they do no harm. - Y_ASSERT(datapos < dataend); + Y_ASSERT(datapos < dataend); offsetlength = flags & MT_SIZEMASK; offset = UnpackOffset(datapos, offsetlength); if (!offset) @@ -185,7 +185,7 @@ namespace NCompactTrie { template <typename TSymbol, class TPacker> Y_FORCE_INLINE bool Advance(const char*& datapos, const char* const dataend, const char*& value, TSymbol label, TPacker packer) { - Y_ASSERT(datapos < dataend); + Y_ASSERT(datapos < dataend); char flags = MT_NEXT; for (int i = (int)ExtraBits<TSymbol>(); i >= 0; i -= 8) { flags = LeapByte(datapos, dataend, (char)(label >> i)); @@ -195,7 +195,7 @@ namespace NCompactTrie { value = nullptr; - Y_ASSERT(datapos <= dataend); + Y_ASSERT(datapos <= dataend); if ((flags & MT_FINAL)) { value = datapos; datapos += packer.SkipLeaf(datapos); diff --git a/library/cpp/containers/comptrie/comptrie_trie.h b/library/cpp/containers/comptrie/comptrie_trie.h index 40ec1e52b32..25a288f23d1 100644 --- a/library/cpp/containers/comptrie/comptrie_trie.h +++ b/library/cpp/containers/comptrie/comptrie_trie.h @@ -11,7 +11,7 @@ #include <util/generic/vector.h> #include <util/generic/yexception.h> #include <util/memory/blob.h> -#include <util/stream/input.h> +#include <util/stream/input.h> #include <utility> template <class T, class D, class S> @@ -54,16 +54,16 @@ protected: public: TCompactTrie() = default; - TCompactTrie(const char* d, size_t len, TPacker packer); - TCompactTrie(const char* d, size_t len) + TCompactTrie(const char* d, size_t len, TPacker packer); + TCompactTrie(const char* d, size_t len) : TCompactTrie{d, len, TPacker{}} { - } - - TCompactTrie(const TBlob& data, TPacker packer); - explicit TCompactTrie(const TBlob& data) + } + + TCompactTrie(const TBlob& data, TPacker packer); + explicit TCompactTrie(const TBlob& data) : TCompactTrie{data, TPacker{}} { - } - + } + // Skipper should be initialized with &Packer, not with &other.Packer, so you have to redefine these. TCompactTrie(const TCompactTrie& other); TCompactTrie(TCompactTrie&& other) noexcept; @@ -185,7 +185,7 @@ public: // LowerBound of X cannot be greater than X. TConstIterator UpperBound(const TKeyBuf& key) const; - void Print(IOutputStream& os); + void Print(IOutputStream& os); size_t Size() const; @@ -212,7 +212,7 @@ private: TArrayHolder<char> Storage; public: - TCompactTrieHolder(IInputStream& is, size_t len); + TCompactTrieHolder(IInputStream& is, size_t len); }; //------------------------// @@ -308,7 +308,7 @@ void TCompactTrie<T, D, S>::Init(const TBlob& data, TPacker packer) { const char* emptypos = datapos; char flags = LeapByte(emptypos, dataend, 0); if (emptypos && (flags & MT_FINAL)) { - Y_ASSERT(emptypos <= dataend); + Y_ASSERT(emptypos <= dataend); EmptyValue = emptypos; } } @@ -375,7 +375,7 @@ bool TCompactTrie<T, D, S>::FindTails(const TSymbol* key, size_t keylen, TCompac if (key == keyend) { if (datapos) { - Y_ASSERT(datapos >= datastart); + Y_ASSERT(datapos >= datastart); res = TCompactTrie<T, D, S>(TBlob::NoCopy(datapos, dataend - datapos), value); } else { res = TCompactTrie<T, D, S>(value); @@ -406,7 +406,7 @@ inline bool TCompactTrie<T, D, S>::FindTails(TSymbol label, TCompactTrie<T, D, S return false; if (datapos) { - Y_ASSERT(datapos >= datastart); + Y_ASSERT(datapos >= datastart); res = TCompactTrie<T, D, S>(TBlob::NoCopy(datapos, dataend - datapos), value); } else { res = TCompactTrie<T, D, S>(value); @@ -452,7 +452,7 @@ typename TCompactTrie<T, D, S>::TConstIterator TCompactTrie<T, D, S>::UpperBound } template <class T, class D, class S> -void TCompactTrie<T, D, S>::Print(IOutputStream& os) { +void TCompactTrie<T, D, S>::Print(IOutputStream& os) { typedef typename ::TCompactTrieKeySelector<T>::TKeyBuf TSBuffer; for (TConstIterator it = Begin(); it != End(); ++it) { os << TSBuffer((*it).first.data(), (*it).first.size()) << "\t" << (*it).second << Endl; @@ -504,7 +504,7 @@ bool TCompactTrie<T, D, S>::LookupLongestPrefix(const TSymbol* key, size_t keyle return found; // no such arc } - Y_ASSERT(datapos <= dataend); + Y_ASSERT(datapos <= dataend); if ((flags & MT_FINAL)) { prefixLen = keylen - (keyend - key) - (i ? 1 : 0); valuepos = datapos; @@ -558,7 +558,7 @@ void TCompactTrie<T, D, S>::LookupPhrases( // TCompactTrieHolder template <class T, class D, class S> -TCompactTrieHolder<T, D, S>::TCompactTrieHolder(IInputStream& is, size_t len) +TCompactTrieHolder<T, D, S>::TCompactTrieHolder(IInputStream& is, size_t len) : Storage(new char[len]) { if (is.Load(Storage.Get(), len) != len) { diff --git a/library/cpp/containers/comptrie/comptrie_ut.cpp b/library/cpp/containers/comptrie/comptrie_ut.cpp index 74bee09b5d6..6095f78cf8a 100644 --- a/library/cpp/containers/comptrie/comptrie_ut.cpp +++ b/library/cpp/containers/comptrie/comptrie_ut.cpp @@ -1,7 +1,7 @@ #include <util/random/shuffle.h> #include <library/cpp/testing/unittest/registar.h> -#include <util/stream/output.h> +#include <util/stream/output.h> #include <utility> #include <util/charset/wide.h> @@ -105,7 +105,7 @@ private: UNIT_TEST(TestFirstSymbolIteratorChar32); UNIT_TEST(TestArrayPacker); - + UNIT_TEST(TestBuilderFindLongestPrefix); UNIT_TEST(TestBuilderFindLongestPrefixWithEmptyValue); @@ -118,7 +118,7 @@ private: static const char* SampleData[]; template <class T> - void CreateTrie(IOutputStream& out, bool minimize, bool useFastLayout); + void CreateTrie(IOutputStream& out, bool minimize, bool useFastLayout); template <class T> void CheckData(const char* src, size_t len); @@ -241,7 +241,7 @@ public: void TestFirstSymbolIterator32(); void TestFirstSymbolIteratorChar32(); - void TestArrayPacker(); + void TestArrayPacker(); void TestBuilderFindLongestPrefix(); void TestBuilderFindLongestPrefix(size_t keysCount, double branchProbability, bool isPrefixGrouped, bool hasEmptyKey); @@ -297,17 +297,17 @@ typename TCompactTrie<T>::TKey MakeWideKey(const TStringBuf& buf) { } template <class T> -void TCompactTrieTest::CreateTrie(IOutputStream& out, bool minimize, bool useFastLayout) { +void TCompactTrieTest::CreateTrie(IOutputStream& out, bool minimize, bool useFastLayout) { TCompactTrieBuilder<T> builder; - for (auto& i : SampleData) { - size_t len = strlen(i); + for (auto& i : SampleData) { + size_t len = strlen(i); - builder.Add(MakeWideKey<T>(i, len), len * 2); + builder.Add(MakeWideKey<T>(i, len), len * 2); } TBufferOutput tmp2; - IOutputStream& currentOutput = useFastLayout ? tmp2 : out; + IOutputStream& currentOutput = useFastLayout ? tmp2 : out; if (minimize) { TBufferOutput buftmp; builder.Save(buftmp); @@ -361,14 +361,14 @@ template <class T> void TCompactTrieTest::CheckData(const char* data, size_t datalen) { TCompactTrie<T> trie(data, datalen); - UNIT_ASSERT_VALUES_EQUAL(Y_ARRAY_SIZE(SampleData), trie.Size()); + UNIT_ASSERT_VALUES_EQUAL(Y_ARRAY_SIZE(SampleData), trie.Size()); - for (auto& i : SampleData) { - size_t len = strlen(i); + for (auto& i : SampleData) { + size_t len = strlen(i); ui64 value = 0; size_t prefixLen = 0; - typename TCompactTrie<T>::TKey key = MakeWideKey<T>(i, len); + typename TCompactTrie<T>::TKey key = MakeWideKey<T>(i, len); UNIT_ASSERT(trie.Find(key, &value)); UNIT_ASSERT_EQUAL(len * 2, value); UNIT_ASSERT(trie.FindLongestPrefix(key, &prefixLen, &value)); @@ -376,7 +376,7 @@ void TCompactTrieTest::CheckData(const char* data, size_t datalen) { UNIT_ASSERT_EQUAL(len * 2, value); TString badkey("bb"); - badkey += i; + badkey += i; key = MakeWideKey<T>(badkey); UNIT_ASSERT(!trie.Find(key)); value = 123; @@ -386,7 +386,7 @@ void TCompactTrieTest::CheckData(const char* data, size_t datalen) { UNIT_ASSERT_EQUAL(1, prefixLen); UNIT_ASSERT_EQUAL(2, value); - badkey = i; + badkey = i; badkey += "x"; key = MakeWideKey<T>(badkey); UNIT_ASSERT(!trie.Find(key)); @@ -425,10 +425,10 @@ void TCompactTrieTest::CheckIterator(const char* data, size_t datalen) { typedef typename TCompactTrie<T>::TValueType TValue; TMap<TKey, ui64> stored; - for (auto& i : SampleData) { - size_t len = strlen(i); + for (auto& i : SampleData) { + size_t len = strlen(i); - stored[MakeWideKey<T>(i, len)] = len * 2; + stored[MakeWideKey<T>(i, len)] = len * 2; } TCompactTrie<T> trie(data, datalen); @@ -567,7 +567,7 @@ void TCompactTrieTest::TestPhraseSearch() { TBufferOutput bufout; TCompactTrieBuilder<char> builder; - for (size_t i = 0; i < Y_ARRAY_SIZE(phrases); i++) { + for (size_t i = 0; i < Y_ARRAY_SIZE(phrases); i++) { builder.Add(phrases[i], strlen(phrases[i]), i); } builder.Save(bufout); @@ -576,8 +576,8 @@ void TCompactTrieTest::TestPhraseSearch() { TVector<TCompactTrie<char>::TPhraseMatch> matches; trie.FindPhrases(goodphrase, strlen(goodphrase), matches); - UNIT_ASSERT(matches.size() == Y_ARRAY_SIZE(phrases)); - for (size_t i = 0; i < Y_ARRAY_SIZE(phrases); i++) { + UNIT_ASSERT(matches.size() == Y_ARRAY_SIZE(phrases)); + for (size_t i = 0; i < Y_ARRAY_SIZE(phrases); i++) { UNIT_ASSERT(matches[i].first == strlen(phrases[i])); UNIT_ASSERT(matches[i].second == i); } @@ -734,11 +734,11 @@ void TCompactTrieTest::TestFindTailsImpl(const TString& prefix) { TMap<TString, ui64> input; - for (auto& i : SampleData) { + for (auto& i : SampleData) { TString temp = i; ui64 val = temp.size() * 2; builder.Add(temp.data(), temp.size(), val); - if (temp.StartsWith(prefix)) { + if (temp.StartsWith(prefix)) { input[temp.substr(prefix.size())] = val; } } @@ -789,10 +789,10 @@ void TCompactTrieTest::TestPrefixGrouped() { "Tumen", }; - for (size_t i = 0; i < Y_ARRAY_SIZE(data); ++i) { + for (size_t i = 0; i < Y_ARRAY_SIZE(data); ++i) { ui32 val = strlen(data[i]) + 1; b1.Add(data[i], strlen(data[i]), val); - for (size_t j = 0; j < Y_ARRAY_SIZE(data); ++j) { + for (size_t j = 0; j < Y_ARRAY_SIZE(data); ++j) { ui32 mustHave = strlen(data[j]) + 1; ui32 found = 0; if (j <= i) { @@ -813,10 +813,10 @@ void TCompactTrieTest::TestPrefixGrouped() { //t1.Print(Cerr); - for (auto& i : data) { + for (auto& i : data) { ui32 v; - UNIT_ASSERT(t1.Find(i, strlen(i), &v)); - UNIT_ASSERT_VALUES_EQUAL(strlen(i) + 1, v); + UNIT_ASSERT(t1.Find(i, strlen(i), &v)); + UNIT_ASSERT_VALUES_EQUAL(strlen(i) + 1, v); } } @@ -831,7 +831,7 @@ void TCompactTrieTest::CrashTestPrefixGrouped() { }; bool wasException = false; try { - for (size_t i = 0; i < Y_ARRAY_SIZE(data); ++i) { + for (size_t i = 0; i < Y_ARRAY_SIZE(data); ++i) { builder.Add(data[i], strlen(data[i]), i + 1); } } catch (const yexception& e) { @@ -947,7 +947,7 @@ void TCompactTrieTest::TestUniqueImpl(bool isPrefixGrouped) { "Fry", "Tumen", }; - for (size_t i = 0; i < Y_ARRAY_SIZE(data); ++i) { + for (size_t i = 0; i < Y_ARRAY_SIZE(data); ++i) { UNIT_ASSERT_C(builder.Add(data[i], strlen(data[i]), i + 1), i); } bool wasException = false; @@ -973,7 +973,7 @@ void TCompactTrieTest::TestAddRetValue() { "Fry", "Tumen", }; - for (size_t i = 0; i < Y_ARRAY_SIZE(data); ++i) { + for (size_t i = 0; i < Y_ARRAY_SIZE(data); ++i) { UNIT_ASSERT(builder.Add(data[i], strlen(data[i]), i + 1)); UNIT_ASSERT(!builder.Add(data[i], strlen(data[i]), i + 2)); ui32 value; @@ -995,10 +995,10 @@ void TCompactTrieTest::TestClear() { "Fry", "Tumen", }; - for (size_t i = 0; i < Y_ARRAY_SIZE(data); ++i) { + for (size_t i = 0; i < Y_ARRAY_SIZE(data); ++i) { builder.Add(data[i], strlen(data[i]), i + 1); } - UNIT_ASSERT(builder.GetEntryCount() == Y_ARRAY_SIZE(data)); + UNIT_ASSERT(builder.GetEntryCount() == Y_ARRAY_SIZE(data)); builder.Clear(); UNIT_ASSERT(builder.GetEntryCount() == 0); UNIT_ASSERT(builder.GetNodeCount() == 1); @@ -1105,7 +1105,7 @@ void TCompactTrieTest::TestTrieSet() { // Tests for trie with vector (list, set) values TVector<TUtf16String> TCompactTrieTest::GetSampleKeys(size_t nKeys) const { - Y_ASSERT(nKeys <= 10); + Y_ASSERT(nKeys <= 10); TString sampleKeys[] = {"a", "b", "ac", "bd", "abe", "bcf", "deg", "ah", "xy", "abc"}; TVector<TUtf16String> result; for (size_t i = 0; i < nKeys; i++) @@ -1332,7 +1332,7 @@ void TCompactTrieTest::TestSearchIterImpl() { TStringBuf("abbbc"), TStringBuf("bdfaa"), }; - for (size_t i = 0; i < Y_ARRAY_SIZE(data); ++i) { + for (size_t i = 0; i < Y_ARRAY_SIZE(data); ++i) { builder.Add(TConvertKey<TChar>::Convert(data[i]), i + 1); } builder.Save(buffer); @@ -1434,37 +1434,37 @@ void TCompactTrieTest::TestFirstSymbolIteratorChar32() { } -void TCompactTrieTest::TestArrayPacker() { +void TCompactTrieTest::TestArrayPacker() { using TDataInt = std::array<int, 2>; const std::pair<TString, TDataInt> dataXxx{"xxx", {{15, 16}}}; const std::pair<TString, TDataInt> dataYyy{"yyy", {{20, 30}}}; - - TCompactTrieBuilder<char, TDataInt> trieBuilderOne; - trieBuilderOne.Add(dataXxx.first, dataXxx.second); - trieBuilderOne.Add(dataYyy.first, dataYyy.second); - - TBufferOutput bufferOne; - trieBuilderOne.Save(bufferOne); - - const TCompactTrie<char, TDataInt> trieOne(bufferOne.Buffer().Data(), bufferOne.Buffer().Size()); - UNIT_ASSERT_VALUES_EQUAL(dataXxx.second, trieOne.Get(dataXxx.first)); - UNIT_ASSERT_VALUES_EQUAL(dataYyy.second, trieOne.Get(dataYyy.first)); - + + TCompactTrieBuilder<char, TDataInt> trieBuilderOne; + trieBuilderOne.Add(dataXxx.first, dataXxx.second); + trieBuilderOne.Add(dataYyy.first, dataYyy.second); + + TBufferOutput bufferOne; + trieBuilderOne.Save(bufferOne); + + const TCompactTrie<char, TDataInt> trieOne(bufferOne.Buffer().Data(), bufferOne.Buffer().Size()); + UNIT_ASSERT_VALUES_EQUAL(dataXxx.second, trieOne.Get(dataXxx.first)); + UNIT_ASSERT_VALUES_EQUAL(dataYyy.second, trieOne.Get(dataYyy.first)); + using TDataStroka = std::array<TString, 2>; const std::pair<TString, TDataStroka> dataZzz{"zzz", {{"hello", "there"}}}; const std::pair<TString, TDataStroka> dataWww{"www", {{"half", "life"}}}; - - TCompactTrieBuilder<char, TDataStroka> trieBuilderTwo; - trieBuilderTwo.Add(dataZzz.first, dataZzz.second); - trieBuilderTwo.Add(dataWww.first, dataWww.second); - - TBufferOutput bufferTwo; - trieBuilderTwo.Save(bufferTwo); - - const TCompactTrie<char, TDataStroka> trieTwo(bufferTwo.Buffer().Data(), bufferTwo.Buffer().Size()); - UNIT_ASSERT_VALUES_EQUAL(dataZzz.second, trieTwo.Get(dataZzz.first)); - UNIT_ASSERT_VALUES_EQUAL(dataWww.second, trieTwo.Get(dataWww.first)); -} + + TCompactTrieBuilder<char, TDataStroka> trieBuilderTwo; + trieBuilderTwo.Add(dataZzz.first, dataZzz.second); + trieBuilderTwo.Add(dataWww.first, dataWww.second); + + TBufferOutput bufferTwo; + trieBuilderTwo.Save(bufferTwo); + + const TCompactTrie<char, TDataStroka> trieTwo(bufferTwo.Buffer().Data(), bufferTwo.Buffer().Size()); + UNIT_ASSERT_VALUES_EQUAL(dataZzz.second, trieTwo.Get(dataZzz.first)); + UNIT_ASSERT_VALUES_EQUAL(dataWww.second, trieTwo.Get(dataWww.first)); +} void TCompactTrieTest::TestBuilderFindLongestPrefix() { const size_t sizes[] = {10, 100}; @@ -1517,7 +1517,7 @@ void TCompactTrieTest::TestBuilderFindLongestPrefix(size_t keysCount, double bra } else { size_t max = 0; for (size_t k = 0; k < i; ++k) - if (keys[k].Size() < otherKey.Size() && keys[k].Size() > max && otherKey.StartsWith(keys[k])) + if (keys[k].Size() < otherKey.Size() && keys[k].Size() > max && otherKey.StartsWith(keys[k])) max = keys[k].Size(); expectedSize = max; } diff --git a/library/cpp/containers/comptrie/loader/loader.h b/library/cpp/containers/comptrie/loader/loader.h index ee10e9b451e..478c820abca 100644 --- a/library/cpp/containers/comptrie/loader/loader.h +++ b/library/cpp/containers/comptrie/loader/loader.h @@ -12,7 +12,7 @@ TrieType LoadTrieFromArchive(const TString& key, bool ignoreErrors = false) { TArchiveReader archive(TBlob::NoCopy(data, sizeof(data))); if (archive.Has(key)) { - TAutoPtr<IInputStream> trie = archive.ObjectByKey(key); + TAutoPtr<IInputStream> trie = archive.ObjectByKey(key); return TrieType(TBlob::FromStream(*trie)); } if (!ignoreErrors) { diff --git a/library/cpp/containers/comptrie/loader/loader_ut.cpp b/library/cpp/containers/comptrie/loader/loader_ut.cpp index 345063a31e4..f146bfaff55 100644 --- a/library/cpp/containers/comptrie/loader/loader_ut.cpp +++ b/library/cpp/containers/comptrie/loader/loader_ut.cpp @@ -10,8 +10,8 @@ namespace { }; } -Y_UNIT_TEST_SUITE(ArchiveLoaderTests) { - Y_UNIT_TEST(BaseTest) { +Y_UNIT_TEST_SUITE(ArchiveLoaderTests) { + Y_UNIT_TEST(BaseTest) { TDummyTrie trie = LoadTrieFromArchive<TDummyTrie>("/dummy.trie", DATA, true); UNIT_ASSERT_EQUAL(trie.Size(), 3); diff --git a/library/cpp/containers/comptrie/make_fast_layout.h b/library/cpp/containers/comptrie/make_fast_layout.h index b8fab5d65b8..6bb4ff0d559 100644 --- a/library/cpp/containers/comptrie/make_fast_layout.h +++ b/library/cpp/containers/comptrie/make_fast_layout.h @@ -3,7 +3,7 @@ #include "leaf_skipper.h" #include <cstddef> -class IOutputStream; +class IOutputStream; namespace NCompactTrie { // Return value: size of the resulting trie. diff --git a/library/cpp/containers/comptrie/minimize.h b/library/cpp/containers/comptrie/minimize.h index baaa431d044..5973564844c 100644 --- a/library/cpp/containers/comptrie/minimize.h +++ b/library/cpp/containers/comptrie/minimize.h @@ -3,7 +3,7 @@ #include "leaf_skipper.h" #include <cstddef> -class IOutputStream; +class IOutputStream; namespace NCompactTrie { size_t MeasureOffset(size_t offset); diff --git a/library/cpp/containers/comptrie/write_trie_backwards.h b/library/cpp/containers/comptrie/write_trie_backwards.h index 634e6b811a4..78e1e6ade4b 100644 --- a/library/cpp/containers/comptrie/write_trie_backwards.h +++ b/library/cpp/containers/comptrie/write_trie_backwards.h @@ -17,7 +17,7 @@ namespace NCompactTrie { struct TOpaqueTrie; - size_t WriteTrieBackwards(IOutputStream& os, TReverseNodeEnumerator& enumerator, bool verbose); - size_t WriteTrieBackwardsNoAlloc(IOutputStream& os, TReverseNodeEnumerator& enumerator, TOpaqueTrie& trie, EMinimizeMode mode); + size_t WriteTrieBackwards(IOutputStream& os, TReverseNodeEnumerator& enumerator, bool verbose); + size_t WriteTrieBackwardsNoAlloc(IOutputStream& os, TReverseNodeEnumerator& enumerator, TOpaqueTrie& trie, EMinimizeMode mode); } diff --git a/library/cpp/containers/intrusive_avl_tree/avltree.h b/library/cpp/containers/intrusive_avl_tree/avltree.h index a58c63b07c5..717c18cb140 100644 --- a/library/cpp/containers/intrusive_avl_tree/avltree.h +++ b/library/cpp/containers/intrusive_avl_tree/avltree.h @@ -28,11 +28,11 @@ class TAvlTree: public TNonCopyable { } inline bool IsEnd() const noexcept { - return Ptr_ == nullptr; + return Ptr_ == nullptr; } inline bool IsBegin() const noexcept { - return Ptr_ == nullptr; + return Ptr_ == nullptr; } inline bool IsFirst() const noexcept { @@ -107,10 +107,10 @@ class TAvlTree: public TNonCopyable { } inline static TIteratorBase FindPrev(TTreeItem* el) noexcept { - if (el->Left_ != nullptr) { + if (el->Left_ != nullptr) { el = el->Left_; - while (el->Right_ != nullptr) { + while (el->Right_ != nullptr) { el = el->Right_; } } else { @@ -118,7 +118,7 @@ class TAvlTree: public TNonCopyable { TTreeItem* last = el; el = el->Parent_; - if (el == nullptr || el->Right_ == last) { + if (el == nullptr || el->Right_ == last) { break; } } @@ -128,7 +128,7 @@ class TAvlTree: public TNonCopyable { } static TTreeItem* FindNext(TTreeItem* el) { - if (el->Right_ != nullptr) { + if (el->Right_ != nullptr) { el = el->Right_; while (el->Left_) { @@ -139,7 +139,7 @@ class TAvlTree: public TNonCopyable { TTreeItem* last = el; el = el->Parent_; - if (el == nullptr || el->Left_ == last) { + if (el == nullptr || el->Left_ == last) { break; } } @@ -202,14 +202,14 @@ public: el->Tree_ = this; TTreeItem* curEl = Root_; - TTreeItem* parentEl = nullptr; - TTreeItem* lastLess = nullptr; + TTreeItem* parentEl = nullptr; + TTreeItem* lastLess = nullptr; while (true) { - if (curEl == nullptr) { + if (curEl == nullptr) { AttachRebal(el, parentEl, lastLess); - if (lastFound != nullptr) { + if (lastFound != nullptr) { *lastFound = el; } @@ -223,11 +223,11 @@ public: parentEl = curEl; curEl = curEl->Right_; } else { - if (lastFound != nullptr) { + if (lastFound != nullptr) { *lastFound = curEl; } - return nullptr; + return nullptr; } } } @@ -245,12 +245,12 @@ public: } } - return nullptr; + return nullptr; } inline T* LowerBound(const TTreeItem* el) const noexcept { TTreeItem* curEl = Root_; - TTreeItem* lowerBound = nullptr; + TTreeItem* lowerBound = nullptr; while (curEl) { if (Compare(*el, *curEl)) { @@ -271,11 +271,11 @@ public: return this->EraseImpl(el); } - return nullptr; + return nullptr; } inline T* EraseImpl(TTreeItem* el) noexcept { - el->Tree_ = nullptr; + el->Tree_ = nullptr; TTreeItem* replacement; TTreeItem* fixfrom; @@ -330,10 +330,10 @@ public: Tail_ = el->Parent_; } - RemoveEl(el, nullptr); + RemoveEl(el, nullptr); } - if (fixfrom == nullptr) { + if (fixfrom == nullptr) { return AsT(el); } @@ -422,7 +422,7 @@ public: } inline iterator End() noexcept { - return iterator(nullptr, this); + return iterator(nullptr, this); } inline iterator begin() noexcept { @@ -507,7 +507,7 @@ private: } } - if (ggp == nullptr) { + if (ggp == nullptr) { Root_ = b; } else if (ggp->Left_ == gp) { ggp->Left_ = b; @@ -522,25 +522,25 @@ private: c->Parent_ = b; a->Left_ = t1; - if (t1 != nullptr) { + if (t1 != nullptr) { t1->Parent_ = a; } a->Right_ = t2; - if (t2 != nullptr) { + if (t2 != nullptr) { t2->Parent_ = a; } c->Left_ = t3; - if (t3 != nullptr) { + if (t3 != nullptr) { t3->Parent_ = c; } c->Right_ = t4; - if (t4 != nullptr) { + if (t4 != nullptr) { t4->Parent_ = c; } @@ -584,13 +584,13 @@ private: long lheight, rheight, balanceProp; TTreeItem* gp; - if (el == nullptr || el->Parent_ == nullptr || el->Parent_->Parent_ == nullptr) { - return nullptr; + if (el == nullptr || el->Parent_ == nullptr || el->Parent_->Parent_ == nullptr) { + return nullptr; } gp = el->Parent_->Parent_; - while (gp != nullptr) { + while (gp != nullptr) { lheight = gp->Left_ ? gp->Left_->Height_ : 0; rheight = gp->Right_ ? gp->Right_->Height_ : 0; balanceProp = lheight - rheight; @@ -603,12 +603,12 @@ private: gp = gp->Parent_; } - return nullptr; + return nullptr; } inline TTreeItem* FindFirstUnbalEl(TTreeItem* el) noexcept { - if (el == nullptr) { - return nullptr; + if (el == nullptr) { + return nullptr; } while (el) { @@ -623,7 +623,7 @@ private: el = el->Parent_; } - return nullptr; + return nullptr; } inline void ReplaceEl(TTreeItem* el, TTreeItem* replacement) noexcept { @@ -680,11 +680,11 @@ private: inline void AttachRebal(TTreeItem* el, TTreeItem* parentEl, TTreeItem* lastLess) { el->Parent_ = parentEl; - el->Left_ = nullptr; - el->Right_ = nullptr; + el->Left_ = nullptr; + el->Right_ = nullptr; el->Height_ = 1; - if (parentEl != nullptr) { + if (parentEl != nullptr) { if (lastLess == parentEl) { parentEl->Left_ = el; } else { @@ -707,7 +707,7 @@ private: TTreeItem* ub = FindFirstUnbalGP(el); - if (ub != nullptr) { + if (ub != nullptr) { Rebalance(ub); } } diff --git a/library/cpp/containers/intrusive_avl_tree/ut/avltree_ut.cpp b/library/cpp/containers/intrusive_avl_tree/ut/avltree_ut.cpp index cab2365ccec..737da8e1e24 100644 --- a/library/cpp/containers/intrusive_avl_tree/ut/avltree_ut.cpp +++ b/library/cpp/containers/intrusive_avl_tree/ut/avltree_ut.cpp @@ -59,7 +59,7 @@ void TAvlTreeTest::TestLowerBound() { TIt it_large(1000); UNIT_ASSERT_EQUAL(its.LowerBound(&it3), &it3); UNIT_ASSERT_EQUAL(its.LowerBound(&it_zero), &it5); - UNIT_ASSERT_EQUAL(its.LowerBound(&it_large), nullptr); + UNIT_ASSERT_EQUAL(its.LowerBound(&it_large), nullptr); } void TAvlTreeTest::TestIterator() { @@ -81,7 +81,7 @@ void TAvlTreeTest::TestIterator() { its.Insert(&it2); TVector<int> res; - for (const TIt& i : its) { + for (const TIt& i : its) { res.push_back(i.Val); } @@ -89,7 +89,7 @@ void TAvlTreeTest::TestIterator() { UNIT_ASSERT_EQUAL(res, expected); res.clear(); - for (TIt& i : its) { + for (TIt& i : its) { res.push_back(i.Val); } UNIT_ASSERT_EQUAL(res, expected); diff --git a/library/cpp/containers/intrusive_rb_tree/rb_tree.h b/library/cpp/containers/intrusive_rb_tree/rb_tree.h index 0259452a145..579b1d6fc3f 100644 --- a/library/cpp/containers/intrusive_rb_tree/rb_tree.h +++ b/library/cpp/containers/intrusive_rb_tree/rb_tree.h @@ -24,28 +24,28 @@ struct TRbTreeNodeBase { inline void ReInitNode() noexcept { Color_ = RBTreeBlack; - Parent_ = nullptr; - Left_ = nullptr; - Right_ = nullptr; + Parent_ = nullptr; + Left_ = nullptr; + Right_ = nullptr; Children_ = 1; } static TBasePtr MinimumNode(TBasePtr x) { - while (x->Left_ != nullptr) + while (x->Left_ != nullptr) x = x->Left_; return x; } static TBasePtr MaximumNode(TBasePtr x) { - while (x->Right_ != nullptr) + while (x->Right_ != nullptr) x = x->Right_; return x; } static TBasePtr ByIndex(TBasePtr x, size_t index) { - if (x->Left_ != nullptr) { + if (x->Left_ != nullptr) { if (index < x->Left_->Children_) return ByIndex(x->Left_, index); index -= x->Left_->Children_; @@ -178,7 +178,7 @@ public: class TRealNode: public TNodeBase { public: inline TRealNode() - : Tree_(nullptr) + : Tree_(nullptr) { } @@ -190,7 +190,7 @@ public: if (Tree_) { Tree_->EraseImpl(this); ReInitNode(); - Tree_ = nullptr; + Tree_ = nullptr; } } @@ -221,7 +221,7 @@ public: inline void Init() noexcept { Data_.Color_ = RBTreeRed; - Data_.Parent_ = nullptr; + Data_.Parent_ = nullptr; Data_.Left_ = &Data_; Data_.Right_ = &Data_; Data_.Children_ = 0; @@ -229,7 +229,7 @@ public: struct TDestroy { inline void operator()(TValue& v) const noexcept { - v.SetRbTreeParent(nullptr); + v.SetRbTreeParent(nullptr); v.ReInitNode(); } }; @@ -291,7 +291,7 @@ public: TBasePtr y = &this->Data_; TBasePtr x = Root(); - while (x != nullptr) { + while (x != nullptr) { ++(x->Children_); y = x; @@ -332,10 +332,10 @@ public: template <class T1> inline TValue* Find(const T1& k) const { - TBasePtr y = nullptr; + TBasePtr y = nullptr; TBasePtr x = Root(); // Current node. - while (x != nullptr) + while (x != nullptr) if (!KeyCompare_(ValueNode(x), k)) y = x, x = LeftNode(x); else @@ -343,7 +343,7 @@ public: if (y) { if (KeyCompare_(k, ValueNode(y))) { - y = nullptr; + y = nullptr; } } @@ -375,7 +375,7 @@ public: TBasePtr y = const_cast<TBasePtr>(&this->Data_); /* Last node which is not less than k. */ TBasePtr x = Root(); /* Current node. */ - while (x != nullptr) + while (x != nullptr) if (!KeyCompare_(ValueNode(x), k)) y = x, x = LeftNode(x); else @@ -389,7 +389,7 @@ public: TBasePtr y = const_cast<TBasePtr>(&this->Data_); /* Last node which is greater than k. */ TBasePtr x = Root(); /* Current node. */ - while (x != nullptr) + while (x != nullptr) if (KeyCompare_(k, ValueNode(x))) y = x, x = LeftNode(x); else @@ -402,11 +402,11 @@ public: inline size_t LessCount(const T1& k) const { auto x = LowerBound(k); if (x == const_cast<TBasePtr>(&this->Data_)) { - if (const auto root = Root()) { - return root->Children_; - } else { - return 0; - } + if (const auto root = Root()) { + return root->Children_; + } else { + return 0; + } } else { return GetIndex(x); } @@ -439,9 +439,9 @@ public: private: // CRP 7/10/00 inserted argument on_right, which is another hint (meant to // act like on_left and ignore a portion of the if conditions -- specify - // on_right != nullptr to bypass comparison as false or on_left != nullptr to bypass + // on_right != nullptr to bypass comparison as false or on_left != nullptr to bypass // comparison as true) - TIterator InsertImpl(TRbTreeNodeBase* parent, TRbTreeNodeBase* val, TRbTreeNodeBase* on_left = nullptr, TRbTreeNodeBase* on_right = nullptr) { + TIterator InsertImpl(TRbTreeNodeBase* parent, TRbTreeNodeBase* val, TRbTreeNodeBase* on_left = nullptr, TRbTreeNodeBase* on_right = nullptr) { ValueNode(val).SetRbTreeParent(this); TBasePtr new_node = val; @@ -450,10 +450,10 @@ private: // also makes LeftMost() = new_node Root() = new_node; RightMost() = new_node; - } else if (on_right == nullptr && - // If on_right != nullptr, the remainder fails to false - (on_left != nullptr || - // If on_left != nullptr, the remainder succeeds to true + } else if (on_right == nullptr && + // If on_right != nullptr, the remainder fails to false + (on_left != nullptr || + // If on_left != nullptr, the remainder succeeds to true KeyCompare_(ValueNode(val), ValueNode(parent)))) { LeftNode(parent) = new_node; @@ -532,7 +532,7 @@ template <class TDummy> void TRbGlobal<TDummy>::RotateLeft(TRbTreeNodeBase* x, TRbTreeNodeBase*& root) { TRbTreeNodeBase* y = x->Right_; x->Right_ = y->Left_; - if (y->Left_ != nullptr) + if (y->Left_ != nullptr) y->Left_->Parent_ = x; y->Parent_ = x->Parent_; @@ -552,7 +552,7 @@ template <class TDummy> void TRbGlobal<TDummy>::RotateRight(TRbTreeNodeBase* x, TRbTreeNodeBase*& root) { TRbTreeNodeBase* y = x->Left_; x->Left_ = y->Right_; - if (y->Right_ != nullptr) + if (y->Right_ != nullptr) y->Right_->Parent_ = x; y->Parent_ = x->Parent_; @@ -633,7 +633,7 @@ TRbTreeNodeBase* TRbGlobal<TDummy>::RebalanceForErase(TRbTreeNodeBase* z, TRbTreeNodeBase* x; TRbTreeNodeBase* x_parent; - if (y->Left_ == nullptr) // z has at most one non-null child. y == z. + if (y->Left_ == nullptr) // z has at most one non-null child. y == z. x = y->Right_; // x might be null. else { if (y->Right_ == nullptr) // z has exactly one non-null child. y == z. @@ -691,14 +691,14 @@ TRbTreeNodeBase* TRbGlobal<TDummy>::RebalanceForErase(TRbTreeNodeBase* z, } if (leftmost == z) { - if (z->Right_ == nullptr) // z->mLeft must be null also + if (z->Right_ == nullptr) // z->mLeft must be null also leftmost = z->Parent_; // makes leftmost == _M_header if z == root else leftmost = TRbTreeNodeBase::MinimumNode(x); } if (rightmost == z) { - if (z->Left_ == nullptr) // z->mRight must be null also + if (z->Left_ == nullptr) // z->mRight must be null also rightmost = z->Parent_; // makes rightmost == _M_header if z == root else // x == z->mLeft @@ -707,7 +707,7 @@ TRbTreeNodeBase* TRbGlobal<TDummy>::RebalanceForErase(TRbTreeNodeBase* z, } if (y->Color_ != RBTreeRed) { - while (x != root && (x == nullptr || x->Color_ == RBTreeBlack)) + while (x != root && (x == nullptr || x->Color_ == RBTreeBlack)) if (x == x_parent->Left_) { TRbTreeNodeBase* w = x_parent->Right_; if (w->Color_ == RBTreeRed) { @@ -716,9 +716,9 @@ TRbTreeNodeBase* TRbGlobal<TDummy>::RebalanceForErase(TRbTreeNodeBase* z, RotateLeft(x_parent, root); w = x_parent->Right_; } - if ((w->Left_ == nullptr || + if ((w->Left_ == nullptr || w->Left_->Color_ == RBTreeBlack) && - (w->Right_ == nullptr || + (w->Right_ == nullptr || w->Right_->Color_ == RBTreeBlack)) { w->Color_ = RBTreeRed; @@ -748,9 +748,9 @@ TRbTreeNodeBase* TRbGlobal<TDummy>::RebalanceForErase(TRbTreeNodeBase* z, RotateRight(x_parent, root); w = x_parent->Left_; } - if ((w->Right_ == nullptr || + if ((w->Right_ == nullptr || w->Right_->Color_ == RBTreeBlack) && - (w->Left_ == nullptr || + (w->Left_ == nullptr || w->Left_->Color_ == RBTreeBlack)) { w->Color_ = RBTreeRed; @@ -782,7 +782,7 @@ template <class TDummy> TRbTreeNodeBase* TRbGlobal<TDummy>::DecrementNode(TRbTreeNodeBase* Node_) { if (Node_->Color_ == RBTreeRed && Node_->Parent_->Parent_ == Node_) Node_ = Node_->Right_; - else if (Node_->Left_ != nullptr) { + else if (Node_->Left_ != nullptr) { Node_ = TRbTreeNodeBase::MaximumNode(Node_->Left_); } else { TBasePtr y = Node_->Parent_; @@ -797,7 +797,7 @@ TRbTreeNodeBase* TRbGlobal<TDummy>::DecrementNode(TRbTreeNodeBase* Node_) { template <class TDummy> TRbTreeNodeBase* TRbGlobal<TDummy>::IncrementNode(TRbTreeNodeBase* Node_) { - if (Node_->Right_ != nullptr) { + if (Node_->Right_ != nullptr) { Node_ = TRbTreeNodeBase::MinimumNode(Node_->Right_); } else { TBasePtr y = Node_->Parent_; diff --git a/library/cpp/containers/intrusive_rb_tree/rb_tree_ut.cpp b/library/cpp/containers/intrusive_rb_tree/rb_tree_ut.cpp index c34ed1fd9b4..6ee9acbf480 100644 --- a/library/cpp/containers/intrusive_rb_tree/rb_tree_ut.cpp +++ b/library/cpp/containers/intrusive_rb_tree/rb_tree_ut.cpp @@ -46,7 +46,7 @@ class TRedBlackTreeTest: public TTestBase { UNIT_TEST(TestCheckChildrenAfterErase) UNIT_TEST(TestGettingIndexWithDifferentValuesAfterErase) UNIT_TEST(TestGettingIndexWithEqualValues) - UNIT_TEST(TestLessCountOnEmptyTree) + UNIT_TEST(TestLessCountOnEmptyTree) UNIT_TEST_SUITE_END(); private: @@ -288,11 +288,11 @@ private: UNIT_ASSERT(tree.Empty()); } - - inline void TestLessCountOnEmptyTree() { - TTree tree; - UNIT_ASSERT_VALUES_EQUAL(0, tree.LessCount(TNode(1))); - } + + inline void TestLessCountOnEmptyTree() { + TTree tree; + UNIT_ASSERT_VALUES_EQUAL(0, tree.LessCount(TNode(1))); + } }; UNIT_TEST_SUITE_REGISTRATION(TRedBlackTreeTest); diff --git a/library/cpp/containers/ring_buffer/ring_buffer.cpp b/library/cpp/containers/ring_buffer/ring_buffer.cpp index 799dad631be..f603db72830 100644 --- a/library/cpp/containers/ring_buffer/ring_buffer.cpp +++ b/library/cpp/containers/ring_buffer/ring_buffer.cpp @@ -1 +1 @@ -#include "ring_buffer.h" +#include "ring_buffer.h" diff --git a/library/cpp/containers/ring_buffer/ring_buffer.h b/library/cpp/containers/ring_buffer/ring_buffer.h index 41220dcf6bf..d4eca72b34c 100644 --- a/library/cpp/containers/ring_buffer/ring_buffer.h +++ b/library/cpp/containers/ring_buffer/ring_buffer.h @@ -37,12 +37,12 @@ public: } const T& operator[](size_t index) const { - Y_ASSERT(IsAvail(index)); + Y_ASSERT(IsAvail(index)); return Items[RealIndex(index)]; } T& operator[](size_t index) { - Y_ASSERT(IsAvail(index)); + Y_ASSERT(IsAvail(index)); return Items[RealIndex(index)]; } diff --git a/library/cpp/containers/ring_buffer/ya.make b/library/cpp/containers/ring_buffer/ya.make index 51333978f7f..6d9967ba433 100644 --- a/library/cpp/containers/ring_buffer/ya.make +++ b/library/cpp/containers/ring_buffer/ya.make @@ -1,9 +1,9 @@ OWNER(mowgli) - -LIBRARY() - -SRCS( - ring_buffer.cpp -) - -END() + +LIBRARY() + +SRCS( + ring_buffer.cpp +) + +END() diff --git a/library/cpp/containers/stack_array/stack_array.h b/library/cpp/containers/stack_array/stack_array.h index 28e49bfc3c2..4be0a5171b3 100644 --- a/library/cpp/containers/stack_array/stack_array.h +++ b/library/cpp/containers/stack_array/stack_array.h @@ -23,10 +23,10 @@ namespace NStackArray { * as those might be called from a loop, and then stack overflow is in the cards. */ template <class T> - class TStackArray: public TArrayRef<T> { + class TStackArray: public TArrayRef<T> { public: inline TStackArray(void* data, size_t len) - : TArrayRef<T>((T*)data, len) + : TArrayRef<T>((T*)data, len) { NRangeOps::InitializeRange(this->begin(), this->end()); } diff --git a/library/cpp/containers/stack_array/ut/tests_ut.cpp b/library/cpp/containers/stack_array/ut/tests_ut.cpp index 3e96384f0e7..29476858e63 100644 --- a/library/cpp/containers/stack_array/ut/tests_ut.cpp +++ b/library/cpp/containers/stack_array/ut/tests_ut.cpp @@ -1,7 +1,7 @@ #include <library/cpp/containers/stack_array/stack_array.h> #include <library/cpp/testing/unittest/registar.h> -Y_UNIT_TEST_SUITE(TestStackArray) { +Y_UNIT_TEST_SUITE(TestStackArray) { using namespace NStackArray; static inline void* FillWithTrash(void* d, size_t l) { @@ -12,7 +12,7 @@ Y_UNIT_TEST_SUITE(TestStackArray) { #define ALLOC(type, len) FillWithTrash(alloca(sizeof(type) * len), sizeof(type) * len), len - Y_UNIT_TEST(Test1) { + Y_UNIT_TEST(Test1) { TStackArray<ui32> s(ALLOC(ui32, 10)); UNIT_ASSERT_VALUES_EQUAL(s.size(), 10); @@ -50,7 +50,7 @@ Y_UNIT_TEST_SUITE(TestStackArray) { } }; - Y_UNIT_TEST(Test2) { + Y_UNIT_TEST(Test2) { { TStackArray<TX1> s(ALLOC(TX1, 10)); @@ -78,7 +78,7 @@ Y_UNIT_TEST_SUITE(TestStackArray) { } }; - Y_UNIT_TEST(Test3) { + Y_UNIT_TEST(Test3) { bool haveException = false; try { diff --git a/library/cpp/containers/stack_vector/stack_vec_ut.cpp b/library/cpp/containers/stack_vector/stack_vec_ut.cpp index 19f9677781c..bcdec46ad42 100644 --- a/library/cpp/containers/stack_vector/stack_vec_ut.cpp +++ b/library/cpp/containers/stack_vector/stack_vec_ut.cpp @@ -43,13 +43,13 @@ namespace { }; } -Y_UNIT_TEST_SUITE(TStackBasedVectorTest) { - Y_UNIT_TEST(TestCreateEmpty) { +Y_UNIT_TEST_SUITE(TStackBasedVectorTest) { + Y_UNIT_TEST(TestCreateEmpty) { TStackVec<int> ints; UNIT_ASSERT_EQUAL(ints.size(), 0); } - Y_UNIT_TEST(TestCreateNonEmpty) { + Y_UNIT_TEST(TestCreateNonEmpty) { TStackVec<int> ints(5); UNIT_ASSERT_EQUAL(ints.size(), 5); @@ -58,7 +58,7 @@ Y_UNIT_TEST_SUITE(TStackBasedVectorTest) { } } - Y_UNIT_TEST(TestReallyOnStack) { + Y_UNIT_TEST(TestReallyOnStack) { const TStackVec<int> vec(5); UNIT_ASSERT( @@ -67,7 +67,7 @@ Y_UNIT_TEST_SUITE(TStackBasedVectorTest) { ); } - Y_UNIT_TEST(TestFallback) { + Y_UNIT_TEST(TestFallback) { TSmallVec<int> ints; for (int i = 0; i < 14; ++i) { ints.push_back(i); diff --git a/library/cpp/containers/top_keeper/top_keeper.h b/library/cpp/containers/top_keeper/top_keeper.h index 2f282b5a9e1..362e4307112 100644 --- a/library/cpp/containers/top_keeper/top_keeper.h +++ b/library/cpp/containers/top_keeper/top_keeper.h @@ -179,13 +179,13 @@ public: } const T& GetNext() { - Y_ENSURE(!IsEmpty(), "Trying GetNext from empty heap!"); + Y_ENSURE(!IsEmpty(), "Trying GetNext from empty heap!"); Finalize(); return Internal.Back(); } void Pop() { - Y_ENSURE(!IsEmpty(), "Trying Pop from empty heap!"); + Y_ENSURE(!IsEmpty(), "Trying Pop from empty heap!"); Finalize(); Internal.Pop(); if (IsEmpty()) { @@ -194,7 +194,7 @@ public: } T ExtractOne() { - Y_ENSURE(!IsEmpty(), "Trying ExtractOne from empty heap!"); + Y_ENSURE(!IsEmpty(), "Trying ExtractOne from empty heap!"); Finalize(); auto value = std::move(Internal.Back()); Internal.Pop(); @@ -243,7 +243,7 @@ public: } void SetMaxSize(size_t newMaxSize) { - Y_ENSURE(!Finalized, "Cannot resize after finalizing (Pop() / GetNext() / Finalize())! " + Y_ENSURE(!Finalized, "Cannot resize after finalizing (Pop() / GetNext() / Finalize())! " "Use TLimitedHeap for this scenario"); MaxSize = newMaxSize; Internal.SetMaxSize(newMaxSize); diff --git a/library/cpp/containers/top_keeper/top_keeper/top_keeper.h b/library/cpp/containers/top_keeper/top_keeper/top_keeper.h index 2f282b5a9e1..362e4307112 100644 --- a/library/cpp/containers/top_keeper/top_keeper/top_keeper.h +++ b/library/cpp/containers/top_keeper/top_keeper/top_keeper.h @@ -179,13 +179,13 @@ public: } const T& GetNext() { - Y_ENSURE(!IsEmpty(), "Trying GetNext from empty heap!"); + Y_ENSURE(!IsEmpty(), "Trying GetNext from empty heap!"); Finalize(); return Internal.Back(); } void Pop() { - Y_ENSURE(!IsEmpty(), "Trying Pop from empty heap!"); + Y_ENSURE(!IsEmpty(), "Trying Pop from empty heap!"); Finalize(); Internal.Pop(); if (IsEmpty()) { @@ -194,7 +194,7 @@ public: } T ExtractOne() { - Y_ENSURE(!IsEmpty(), "Trying ExtractOne from empty heap!"); + Y_ENSURE(!IsEmpty(), "Trying ExtractOne from empty heap!"); Finalize(); auto value = std::move(Internal.Back()); Internal.Pop(); @@ -243,7 +243,7 @@ public: } void SetMaxSize(size_t newMaxSize) { - Y_ENSURE(!Finalized, "Cannot resize after finalizing (Pop() / GetNext() / Finalize())! " + Y_ENSURE(!Finalized, "Cannot resize after finalizing (Pop() / GetNext() / Finalize())! " "Use TLimitedHeap for this scenario"); MaxSize = newMaxSize; Internal.SetMaxSize(newMaxSize); diff --git a/library/cpp/containers/top_keeper/top_keeper/ut/top_keeper_ut.cpp b/library/cpp/containers/top_keeper/top_keeper/ut/top_keeper_ut.cpp index a938279025d..5684a00377f 100644 --- a/library/cpp/containers/top_keeper/top_keeper/ut/top_keeper_ut.cpp +++ b/library/cpp/containers/top_keeper/top_keeper/ut/top_keeper_ut.cpp @@ -12,9 +12,9 @@ ui32 Rnd() { /* * Tests for TTopKeeper */ -Y_UNIT_TEST_SUITE(TTopKeeperTest) { +Y_UNIT_TEST_SUITE(TTopKeeperTest) { // Tests correctness on usual examples - Y_UNIT_TEST(CorrectnessTest) { + Y_UNIT_TEST(CorrectnessTest) { int m = 20000; TLimitedHeap<std::pair<int, int>> h1(m); @@ -40,7 +40,7 @@ Y_UNIT_TEST_SUITE(TTopKeeperTest) { } // Tests on zero-size correctness - Y_UNIT_TEST(ZeroSizeCorrectnes) { + Y_UNIT_TEST(ZeroSizeCorrectnes) { TTopKeeper<int> h(0); for (int i = 0; i < 100; ++i) { h.Insert(i % 10 + i / 10); @@ -50,7 +50,7 @@ Y_UNIT_TEST_SUITE(TTopKeeperTest) { } // Tests SetMaxSize behaviour - Y_UNIT_TEST(SetMaxSizeTest) { + Y_UNIT_TEST(SetMaxSizeTest) { int m = 20000; TLimitedHeap<int> h1(m); TTopKeeper<int> h2(m); @@ -77,7 +77,7 @@ Y_UNIT_TEST_SUITE(TTopKeeperTest) { } // Tests reuse behavior - Y_UNIT_TEST(ReuseTest) { + Y_UNIT_TEST(ReuseTest) { int m = 20000; TLimitedHeap<int> h1(m); TTopKeeper<int> h2(m); @@ -116,7 +116,7 @@ Y_UNIT_TEST_SUITE(TTopKeeperTest) { } // Tests reset behavior - Y_UNIT_TEST(ResetTest) { + Y_UNIT_TEST(ResetTest) { int m = 20000; TLimitedHeap<int> h1(m); TTopKeeper<int> h2(m); @@ -159,7 +159,7 @@ Y_UNIT_TEST_SUITE(TTopKeeperTest) { } } - Y_UNIT_TEST(PreRegressionTest) { + Y_UNIT_TEST(PreRegressionTest) { typedef std::pair<float, unsigned int> TElementType; const size_t randomTriesCount = 128; @@ -193,7 +193,7 @@ Y_UNIT_TEST_SUITE(TTopKeeperTest) { } } - Y_UNIT_TEST(CopyKeeperRegressionCase) { + Y_UNIT_TEST(CopyKeeperRegressionCase) { using TKeeper = TTopKeeper<float>; TVector<TKeeper> v(2, TKeeper(200)); auto& k = v[1]; diff --git a/library/cpp/containers/top_keeper/ut/top_keeper_ut.cpp b/library/cpp/containers/top_keeper/ut/top_keeper_ut.cpp index a938279025d..5684a00377f 100644 --- a/library/cpp/containers/top_keeper/ut/top_keeper_ut.cpp +++ b/library/cpp/containers/top_keeper/ut/top_keeper_ut.cpp @@ -12,9 +12,9 @@ ui32 Rnd() { /* * Tests for TTopKeeper */ -Y_UNIT_TEST_SUITE(TTopKeeperTest) { +Y_UNIT_TEST_SUITE(TTopKeeperTest) { // Tests correctness on usual examples - Y_UNIT_TEST(CorrectnessTest) { + Y_UNIT_TEST(CorrectnessTest) { int m = 20000; TLimitedHeap<std::pair<int, int>> h1(m); @@ -40,7 +40,7 @@ Y_UNIT_TEST_SUITE(TTopKeeperTest) { } // Tests on zero-size correctness - Y_UNIT_TEST(ZeroSizeCorrectnes) { + Y_UNIT_TEST(ZeroSizeCorrectnes) { TTopKeeper<int> h(0); for (int i = 0; i < 100; ++i) { h.Insert(i % 10 + i / 10); @@ -50,7 +50,7 @@ Y_UNIT_TEST_SUITE(TTopKeeperTest) { } // Tests SetMaxSize behaviour - Y_UNIT_TEST(SetMaxSizeTest) { + Y_UNIT_TEST(SetMaxSizeTest) { int m = 20000; TLimitedHeap<int> h1(m); TTopKeeper<int> h2(m); @@ -77,7 +77,7 @@ Y_UNIT_TEST_SUITE(TTopKeeperTest) { } // Tests reuse behavior - Y_UNIT_TEST(ReuseTest) { + Y_UNIT_TEST(ReuseTest) { int m = 20000; TLimitedHeap<int> h1(m); TTopKeeper<int> h2(m); @@ -116,7 +116,7 @@ Y_UNIT_TEST_SUITE(TTopKeeperTest) { } // Tests reset behavior - Y_UNIT_TEST(ResetTest) { + Y_UNIT_TEST(ResetTest) { int m = 20000; TLimitedHeap<int> h1(m); TTopKeeper<int> h2(m); @@ -159,7 +159,7 @@ Y_UNIT_TEST_SUITE(TTopKeeperTest) { } } - Y_UNIT_TEST(PreRegressionTest) { + Y_UNIT_TEST(PreRegressionTest) { typedef std::pair<float, unsigned int> TElementType; const size_t randomTriesCount = 128; @@ -193,7 +193,7 @@ Y_UNIT_TEST_SUITE(TTopKeeperTest) { } } - Y_UNIT_TEST(CopyKeeperRegressionCase) { + Y_UNIT_TEST(CopyKeeperRegressionCase) { using TKeeper = TTopKeeper<float>; TVector<TKeeper> v(2, TKeeper(200)); auto& k = v[1]; diff --git a/library/cpp/coroutine/engine/coroutine_ut.cpp b/library/cpp/coroutine/engine/coroutine_ut.cpp index 8b372496a2e..6749f2e076a 100644 --- a/library/cpp/coroutine/engine/coroutine_ut.cpp +++ b/library/cpp/coroutine/engine/coroutine_ut.cpp @@ -5,7 +5,7 @@ #include <library/cpp/testing/unittest/registar.h> #include <util/string/cast.h> -#include <util/system/pipe.h> +#include <util/system/pipe.h> #include <util/system/env.h> #include <util/system/info.h> #include <util/system/thread.h> diff --git a/library/cpp/coroutine/engine/events.h b/library/cpp/coroutine/engine/events.h index 07cc4d25e87..b5a77263433 100644 --- a/library/cpp/coroutine/engine/events.h +++ b/library/cpp/coroutine/engine/events.h @@ -69,7 +69,7 @@ public: } ~TContWaitQueue() { - Y_ASSERT(Waiters_.Empty()); + Y_ASSERT(Waiters_.Empty()); } int WaitD(TCont* current, TInstant deadline) { diff --git a/library/cpp/coroutine/engine/impl.cpp b/library/cpp/coroutine/engine/impl.cpp index 7ae6f74051e..5e2d7f66101 100644 --- a/library/cpp/coroutine/engine/impl.cpp +++ b/library/cpp/coroutine/engine/impl.cpp @@ -34,7 +34,7 @@ TCont::TCont(NCoro::NStack::IAllocator& allocator, {} -void TCont::PrintMe(IOutputStream& out) const noexcept { +void TCont::PrintMe(IOutputStream& out) const noexcept { out << "cont(" << "name = " << Name_ << ", " << "addr = " << Hex((size_t)this) diff --git a/library/cpp/coroutine/engine/impl.h b/library/cpp/coroutine/engine/impl.h index 283a96ecf11..d0041bf7892 100644 --- a/library/cpp/coroutine/engine/impl.h +++ b/library/cpp/coroutine/engine/impl.h @@ -66,7 +66,7 @@ public: return Name_; } - void PrintMe(IOutputStream& out) const noexcept; + void PrintMe(IOutputStream& out) const noexcept; void Yield() noexcept; diff --git a/library/cpp/coroutine/engine/mutex.h b/library/cpp/coroutine/engine/mutex.h index 93e9119503b..252d281c985 100644 --- a/library/cpp/coroutine/engine/mutex.h +++ b/library/cpp/coroutine/engine/mutex.h @@ -11,7 +11,7 @@ public: } ~TContMutex() { - Y_ASSERT(Token_); + Y_ASSERT(Token_); } int LockD(TCont* current, TInstant deadline) { @@ -37,7 +37,7 @@ public: } void UnLock() noexcept { - Y_ASSERT(!Token_); + Y_ASSERT(!Token_); Token_ = true; WaitQueue_.Signal(); diff --git a/library/cpp/coroutine/engine/poller.cpp b/library/cpp/coroutine/engine/poller.cpp index 61164fa56bf..cba6ae0c797 100644 --- a/library/cpp/coroutine/engine/poller.cpp +++ b/library/cpp/coroutine/engine/poller.cpp @@ -162,7 +162,7 @@ namespace { T* Get(size_t i) { TValRef& v = V_.Get(i); - if (Y_UNLIKELY(!v)) { + if (Y_UNLIKELY(!v)) { v.Reset(new (&P_) TVal()); I_.PushFront(v.Get()); } diff --git a/library/cpp/coroutine/engine/sockpool.cpp b/library/cpp/coroutine/engine/sockpool.cpp index b9482e780fe..8a61b19bcd0 100644 --- a/library/cpp/coroutine/engine/sockpool.cpp +++ b/library/cpp/coroutine/engine/sockpool.cpp @@ -21,7 +21,7 @@ void SetCommonSockOpts(SOCKET sock, const struct sockaddr* sa) { warn("bind6"); } } else { - Y_ASSERT(0); + Y_ASSERT(0); } SetNoDelay(sock, true); diff --git a/library/cpp/coroutine/engine/sockpool.h b/library/cpp/coroutine/engine/sockpool.h index 1ebb7e7b382..c58455d6f50 100644 --- a/library/cpp/coroutine/engine/sockpool.h +++ b/library/cpp/coroutine/engine/sockpool.h @@ -227,7 +227,7 @@ inline void TPooledSocket::TImpl::ReturnToPool() noexcept { } -class TContIO: public IInputStream, public IOutputStream { +class TContIO: public IInputStream, public IOutputStream { public: TContIO(SOCKET fd, TCont* cont) : Fd_(fd) diff --git a/library/cpp/coroutine/listener/listen.cpp b/library/cpp/coroutine/listener/listen.cpp index 3d4e711d1d5..11e91b5f6ed 100644 --- a/library/cpp/coroutine/listener/listen.cpp +++ b/library/cpp/coroutine/listener/listen.cpp @@ -181,7 +181,7 @@ private: class TListeners: public TIntrusiveListWithAutoDelete<TOneSocketListener, TDelete> { private: template <class T> - using TIt = std::conditional_t<std::is_const<T>::value, typename T::TConstIterator, typename T::TIterator>; + using TIt = std::conditional_t<std::is_const<T>::value, typename T::TConstIterator, typename T::TIterator>; template <class T> static inline TIt<T> FindImpl(T* t, const IRemoteAddr& addr) { diff --git a/library/cpp/dbg_output/auto.h b/library/cpp/dbg_output/auto.h index 8d96167f6ac..1fdfcae0e24 100644 --- a/library/cpp/dbg_output/auto.h +++ b/library/cpp/dbg_output/auto.h @@ -4,7 +4,7 @@ // int a = 1, b = 2; Cout << LabeledDump(a, b, 1 + 2); yields {"a": 1, "b": 2, "1 + 2": 3} #define LabeledDump(...) \ - '{' Y_PASS_VA_ARGS(Y_MAP_ARGS_WITH_LAST(__LABELED_DUMP_NONLAST__, __LABELED_DUMP_IMPL__, __VA_ARGS__)) << '}' + '{' Y_PASS_VA_ARGS(Y_MAP_ARGS_WITH_LAST(__LABELED_DUMP_NONLAST__, __LABELED_DUMP_IMPL__, __VA_ARGS__)) << '}' #define __LABELED_DUMP_IMPL__(x) << "\"" #x "\": " << DbgDump(x) #define __LABELED_DUMP_NONLAST__(x) __LABELED_DUMP_IMPL__(x) << ", " @@ -15,7 +15,7 @@ struct TDumper<C> { \ template <class S> \ static inline void Dump(S& s, const C& v) { \ - s << DumpRaw("{") Y_PASS_VA_ARGS(Y_MAP_ARGS_WITH_LAST(__DEFINE_DUMPER_NONLAST__, __DEFINE_DUMPER_IMPL__, __VA_ARGS__)) << DumpRaw("}"); \ + s << DumpRaw("{") Y_PASS_VA_ARGS(Y_MAP_ARGS_WITH_LAST(__DEFINE_DUMPER_NONLAST__, __DEFINE_DUMPER_IMPL__, __VA_ARGS__)) << DumpRaw("}"); \ } \ }; #define __DEFINE_DUMPER_IMPL__(x) << DumpRaw("\"" #x "\": ") << v.x diff --git a/library/cpp/dbg_output/colorscheme.h b/library/cpp/dbg_output/colorscheme.h index a5b9cf749a8..1d6862d76ac 100644 --- a/library/cpp/dbg_output/colorscheme.h +++ b/library/cpp/dbg_output/colorscheme.h @@ -17,27 +17,27 @@ namespace NDbgDump { struct TPlain { // Foreground color modifiers DBG_OUTPUT_COLOR_HANDLER(Markup) { - Y_UNUSED(stream); + Y_UNUSED(stream); } DBG_OUTPUT_COLOR_HANDLER(String) { - Y_UNUSED(stream); + Y_UNUSED(stream); } DBG_OUTPUT_COLOR_HANDLER(Literal) { - Y_UNUSED(stream); + Y_UNUSED(stream); } DBG_OUTPUT_COLOR_HANDLER(ResetType) { - Y_UNUSED(stream); + Y_UNUSED(stream); } // Background color modifiers DBG_OUTPUT_COLOR_HANDLER(Key) { - Y_UNUSED(stream); + Y_UNUSED(stream); } DBG_OUTPUT_COLOR_HANDLER(Value) { - Y_UNUSED(stream); + Y_UNUSED(stream); } DBG_OUTPUT_COLOR_HANDLER(ResetRole) { - Y_UNUSED(stream); + Y_UNUSED(stream); } }; diff --git a/library/cpp/dbg_output/dump.h b/library/cpp/dbg_output/dump.h index c7efa105ee6..448f1a8f5ae 100644 --- a/library/cpp/dbg_output/dump.h +++ b/library/cpp/dbg_output/dump.h @@ -71,7 +71,7 @@ namespace NPrivate { { } - inline void DumpTo(IOutputStream& out) const { + inline void DumpTo(IOutputStream& out) const { typename TTraits::TDump d(out, Indent); d << *T_; @@ -88,7 +88,7 @@ namespace NPrivate { }; template <class T, class TTraits> - static inline IOutputStream& operator<<(IOutputStream& out, const TDbgDump<T, TTraits>& d) { + static inline IOutputStream& operator<<(IOutputStream& out, const TDbgDump<T, TTraits>& d) { d.DumpTo(out); return out; diff --git a/library/cpp/dbg_output/dumpers.h b/library/cpp/dbg_output/dumpers.h index 4868e97da07..fca6c589206 100644 --- a/library/cpp/dbg_output/dumpers.h +++ b/library/cpp/dbg_output/dumpers.h @@ -48,7 +48,7 @@ struct TDumper<TCopyPtr<T, C, D>> { }; //small ints -// Default dumper prints them via IOutputStream << (value), which results in raw +// Default dumper prints them via IOutputStream << (value), which results in raw // chars, not integer values. Cast to a bigger int type to force printing as // integers. // NB: i8 = signed char != char != unsigned char = ui8 @@ -102,10 +102,10 @@ template <class T> struct TDumper<TArrayRef<T>>: public TSeqDumper { }; -template <class T, size_t N> +template <class T, size_t N> struct TDumper<std::array<T, N>>: public TSeqDumper { -}; - +}; + template <class T, class A> struct TDumper<TDeque<T, A>>: public TSeqDumper { }; diff --git a/library/cpp/dbg_output/engine.h b/library/cpp/dbg_output/engine.h index f13c728c391..111a00a0190 100644 --- a/library/cpp/dbg_output/engine.h +++ b/library/cpp/dbg_output/engine.h @@ -31,14 +31,14 @@ namespace NDumpPrivate { } struct TDumpBase: public ::NDumpPrivate::TADLBase { - inline TDumpBase(IOutputStream& out, bool indent) noexcept + inline TDumpBase(IOutputStream& out, bool indent) noexcept : Out(&out) , IndentLevel(0) , Indent(indent) { } - inline IOutputStream& Stream() const noexcept { + inline IOutputStream& Stream() const noexcept { return *Out; } @@ -50,7 +50,7 @@ struct TDumpBase: public ::NDumpPrivate::TADLBase { void Raw(const TStringBuf& s); - IOutputStream* Out; + IOutputStream* Out; size_t IndentLevel; bool Indent; }; diff --git a/library/cpp/dbg_output/ut/dbg_output_ut.cpp b/library/cpp/dbg_output/ut/dbg_output_ut.cpp index 7b285c84cb7..7406a76bef8 100644 --- a/library/cpp/dbg_output/ut/dbg_output_ut.cpp +++ b/library/cpp/dbg_output/ut/dbg_output_ut.cpp @@ -31,14 +31,14 @@ namespace TMyNS { } DEFINE_DUMPER(TMyNS::TMyStruct, A, B) -Y_UNIT_TEST_SUITE(TContainerPrintersTest) { - Y_UNIT_TEST(TestVectorInt) { +Y_UNIT_TEST_SUITE(TContainerPrintersTest) { + Y_UNIT_TEST(TestVectorInt) { TStringStream out; out << DbgDump(TVector<int>({1, 2, 3, 4, 5})); UNIT_ASSERT_STRINGS_EQUAL(out.Str(), "[1, 2, 3, 4, 5]"); } - Y_UNIT_TEST(TestMapCharToCharArray) { + Y_UNIT_TEST(TestMapCharToCharArray) { TStringStream out; TMap<char, const char*> m; @@ -51,7 +51,7 @@ Y_UNIT_TEST_SUITE(TContainerPrintersTest) { UNIT_ASSERT_STRINGS_EQUAL(out.Str(), "{'a' -> \"SMALL LETTER A\", 'b' -> (empty)}"); } - Y_UNIT_TEST(TestVectorOfVectors) { + Y_UNIT_TEST(TestVectorOfVectors) { TStringStream out; TVector<TVector<wchar16>> vec(2); vec[0].push_back(0); @@ -60,24 +60,24 @@ Y_UNIT_TEST_SUITE(TContainerPrintersTest) { UNIT_ASSERT_STRINGS_EQUAL(out.Str(), "[[w'\\0'], [w'a']]"); } - Y_UNIT_TEST(TestInfinite) { + Y_UNIT_TEST(TestInfinite) { UNIT_ASSERT(!!(TStringBuilder() << DbgDumpDeep(TX()))); } - Y_UNIT_TEST(TestLabeledDump) { + Y_UNIT_TEST(TestLabeledDump) { TStringStream out; int a = 1, b = 2; out << LabeledDump(a, b, 1 + 2); UNIT_ASSERT_STRINGS_EQUAL(out.Str(), "{\"a\": 1, \"b\": 2, \"1 + 2\": 3}"); } - Y_UNIT_TEST(TestStructDumper) { + Y_UNIT_TEST(TestStructDumper) { TStringStream out; out << DbgDump(TMyNS::TMyStruct{3, 4}); UNIT_ASSERT_STRINGS_EQUAL(out.Str(), "{\"A\": 3, \"B\": 4}"); } - Y_UNIT_TEST(TestColors) { + Y_UNIT_TEST(TestColors) { using TComplex = TMap<TString, TMap<int, char>>; TComplex test; test["a"][1] = '7'; @@ -95,7 +95,7 @@ Y_UNIT_TEST_SUITE(TContainerPrintersTest) { "\\x1B[1;31m'6'\\x1B[22;39m\\x1B[1;32m}\\x1B[22;39m\\x1B[22;39m\\x1B[49m\\x1B[1;32m}\\x1B[22;39m"); } - Y_UNIT_TEST(SmallIntOrChar) { + Y_UNIT_TEST(SmallIntOrChar) { char c = 'e'; i8 i = -100; ui8 u = 10; diff --git a/library/cpp/deprecated/accessors/accessors_impl.h b/library/cpp/deprecated/accessors/accessors_impl.h index 6b2b987351f..66ba8d2d719 100644 --- a/library/cpp/deprecated/accessors/accessors_impl.h +++ b/library/cpp/deprecated/accessors/accessors_impl.h @@ -27,8 +27,8 @@ namespace NAccessors { template <typename Tb> struct TIndirectMemoryRegionBegin { - Y_HAS_MEMBER(Begin); - Y_HAS_MEMBER(begin); + Y_HAS_MEMBER(Begin); + Y_HAS_MEMBER(begin); template <typename Tc> struct TByBegin { @@ -51,10 +51,10 @@ namespace NAccessors { } }; - using TGet = std::conditional_t< + using TGet = std::conditional_t< TMemoryAccessorBase<Ta>::SimpleMemory, TNoMemoryIndirectionBegin<Ta>, - std::conditional_t< + std::conditional_t< TMemoryAccessorBase<Ta>::ContinuousMemory, TIndirectMemoryRegionBegin<Ta>, typename TMemoryAccessorBase<Ta>::TBadAccessor>>; @@ -77,8 +77,8 @@ namespace NAccessors { template <typename Tb> struct TIndirectMemoryRegionEnd { - Y_HAS_MEMBER(End); - Y_HAS_MEMBER(end); + Y_HAS_MEMBER(End); + Y_HAS_MEMBER(end); template <typename Tc> struct TByEnd { @@ -101,10 +101,10 @@ namespace NAccessors { } }; - using TGet = std::conditional_t< + using TGet = std::conditional_t< TMemoryAccessorBase<Ta>::SimpleMemory, TNoMemoryIndirectionEnd<Ta>, - std::conditional_t< + std::conditional_t< TMemoryAccessorBase<Ta>::ContinuousMemory, TIndirectMemoryRegionEnd<Ta>, typename TMemoryAccessorBase<Ta>::TBadAccessor>>; @@ -125,8 +125,8 @@ namespace NAccessors { template <typename Tb> struct TIndirectMemoryRegionClear { - Y_HAS_MEMBER(Clear); - Y_HAS_MEMBER(clear); + Y_HAS_MEMBER(Clear); + Y_HAS_MEMBER(clear); template <typename Tc> struct TByClear { @@ -150,10 +150,10 @@ namespace NAccessors { } }; - using TDo = std::conditional_t< + using TDo = std::conditional_t< THasClear<Tb>::value, TByClear<Tb>, - std::conditional_t< + std::conditional_t< THasclear<Tb>::value, TByclear<Tb>, TByNone<Tb>>>; @@ -163,7 +163,7 @@ namespace NAccessors { } }; - using TDo = std::conditional_t<TMemoryAccessorBase<Ta>::SimpleMemory, TNoMemoryIndirectionClear<Ta>, TIndirectMemoryRegionClear<Ta>>; + using TDo = std::conditional_t<TMemoryAccessorBase<Ta>::SimpleMemory, TNoMemoryIndirectionClear<Ta>, TIndirectMemoryRegionClear<Ta>>; static void Do(Ta& b) { TDo::Do(b); @@ -172,8 +172,8 @@ namespace NAccessors { template <typename Tb> struct TReserve { - Y_HAS_MEMBER(Reserve); - Y_HAS_MEMBER(reserve); + Y_HAS_MEMBER(Reserve); + Y_HAS_MEMBER(reserve); template <typename Tc> struct TByReserve { @@ -195,10 +195,10 @@ namespace NAccessors { } }; - using TDo = std::conditional_t< + using TDo = std::conditional_t< THasReserve<Tb>::value, TByReserve<Tb>, - std::conditional_t< + std::conditional_t< THasreserve<Tb>::value, TByreserve<Tb>, TByNone<Tb>>>; @@ -210,8 +210,8 @@ namespace NAccessors { template <typename Tb> struct TResize { - Y_HAS_MEMBER(Resize); - Y_HAS_MEMBER(resize); + Y_HAS_MEMBER(Resize); + Y_HAS_MEMBER(resize); template <typename Tc> struct TByResize { @@ -236,9 +236,9 @@ namespace NAccessors { template <typename Tb> struct TAppend { - Y_HAS_MEMBER(Append); - Y_HAS_MEMBER(append); - Y_HAS_MEMBER(push_back); + Y_HAS_MEMBER(Append); + Y_HAS_MEMBER(append); + Y_HAS_MEMBER(push_back); template <typename Tc> struct TByAppend { @@ -267,10 +267,10 @@ namespace NAccessors { } }; - using TDo = std::conditional_t< + using TDo = std::conditional_t< THasAppend<Tb>::value, TByAppend<Tb>, - std::conditional_t< + std::conditional_t< THasappend<Tb>::value, TByappend<Tb>, TBypush_back<Tb>>>; @@ -284,9 +284,9 @@ namespace NAccessors { template <typename Tb> struct TAppendRegion { - Y_HAS_MEMBER(Append); - Y_HAS_MEMBER(append); - Y_HAS_MEMBER(insert); + Y_HAS_MEMBER(Append); + Y_HAS_MEMBER(append); + Y_HAS_MEMBER(insert); template <typename Tc> struct TByAppend { @@ -325,13 +325,13 @@ namespace NAccessors { } }; - using TDo = std::conditional_t< + using TDo = std::conditional_t< THasAppend<Tb>::value, TByAppend<Tb>, - std::conditional_t< + std::conditional_t< THasappend<Tb>::value, TByappend<Tb>, - std::conditional_t< + std::conditional_t< THasinsert<Tb>::value, TByinsert<Tb>, TByNone<Tb>>>>; @@ -362,8 +362,8 @@ namespace NAccessors { template <typename Tb> struct TIndirectMemoryRegionAssign { - Y_HAS_MEMBER(Assign); - Y_HAS_MEMBER(assign); + Y_HAS_MEMBER(Assign); + Y_HAS_MEMBER(assign); template <typename Tc> struct TByAssign { @@ -394,13 +394,13 @@ namespace NAccessors { } }; - using TDo = std::conditional_t< + using TDo = std::conditional_t< THasAssign<Tb>::value, TByAssign<Tb>, - std::conditional_t< + std::conditional_t< THasassign<Tb>::value, TByassign<Tb>, - std::conditional_t< + std::conditional_t< TMemoryTraits<Tb>::OwnsMemory, TByClearAppend<Tb>, TByConstruction<Tb>>>>; @@ -410,7 +410,7 @@ namespace NAccessors { } }; - using TDo = std::conditional_t<TMemoryAccessorBase<Ta>::SimpleMemory, TNoMemoryIndirectionAssign<Ta>, TIndirectMemoryRegionAssign<Ta>>; + using TDo = std::conditional_t<TMemoryAccessorBase<Ta>::SimpleMemory, TNoMemoryIndirectionAssign<Ta>, TIndirectMemoryRegionAssign<Ta>>; static void Do(Ta& b, const TElementType* beg, const TElementType* end) { TDo::Do(b, beg, end); diff --git a/library/cpp/deprecated/enum_codegen/enum_codegen.h b/library/cpp/deprecated/enum_codegen/enum_codegen.h index dfb04ecac29..26addd9495a 100644 --- a/library/cpp/deprecated/enum_codegen/enum_codegen.h +++ b/library/cpp/deprecated/enum_codegen/enum_codegen.h @@ -22,7 +22,7 @@ } \ } \ \ - static inline IOutputStream& operator<<(IOutputStream& os, type value) { \ + static inline IOutputStream& operator<<(IOutputStream& os, type value) { \ switch (value) { \ MAP(ENUM_LTLT_IMPL_ITEM) \ default: \ diff --git a/library/cpp/deprecated/enum_codegen/enum_codegen_ut.cpp b/library/cpp/deprecated/enum_codegen/enum_codegen_ut.cpp index f8f1c9b6dff..06ddb8107d3 100644 --- a/library/cpp/deprecated/enum_codegen/enum_codegen_ut.cpp +++ b/library/cpp/deprecated/enum_codegen/enum_codegen_ut.cpp @@ -26,12 +26,12 @@ enum EMultiplier { ENUM_TO_STRING(EMultiplier, MULTIPLIER_MAP) -Y_UNIT_TEST_SUITE(EnumCodegen) { - Y_UNIT_TEST(GenWithValue) { +Y_UNIT_TEST_SUITE(EnumCodegen) { + Y_UNIT_TEST(GenWithValue) { UNIT_ASSERT_VALUES_EQUAL(6, MB); } - Y_UNIT_TEST(ToCString) { + Y_UNIT_TEST(ToCString) { UNIT_ASSERT_VALUES_EQUAL("RED", ToCString(RED)); UNIT_ASSERT_VALUES_EQUAL("BLUE", ToCString(BLUE)); UNIT_ASSERT_VALUES_EQUAL("GREEN", (TStringBuilder() << GREEN)); diff --git a/library/cpp/deprecated/kmp/kmp.h b/library/cpp/deprecated/kmp/kmp.h index a7f72eece6a..ce7783e2fcc 100644 --- a/library/cpp/deprecated/kmp/kmp.h +++ b/library/cpp/deprecated/kmp/kmp.h @@ -18,9 +18,9 @@ void ComputePrefixFunction(const T* begin, const T* end, ssize_t** result) { j = resultHolder[j]; ++i; ++j; - Y_ASSERT(i >= 0); - Y_ASSERT(j >= 0); - Y_ASSERT(j < len); + Y_ASSERT(i >= 0); + Y_ASSERT(j >= 0); + Y_ASSERT(j < len); if ((i < len) && (begin[i] == begin[j])) resultHolder[i] = resultHolder[j]; else @@ -41,7 +41,7 @@ public: TKMPMatcher(const TString& pattern); bool SubStr(const char* begin, const char* end, const char*& result) const { - Y_ASSERT(begin <= end); + Y_ASSERT(begin <= end); ssize_t m = Pattern.size(); ssize_t n = end - begin; ssize_t i, j; diff --git a/library/cpp/deprecated/kmp/kmp_ut.cpp b/library/cpp/deprecated/kmp/kmp_ut.cpp index c2eda83c57a..dc60429596d 100644 --- a/library/cpp/deprecated/kmp/kmp_ut.cpp +++ b/library/cpp/deprecated/kmp/kmp_ut.cpp @@ -71,8 +71,8 @@ public: int data[] = {1, 2, 3, 5, 2, 2, 3, 2, 4, 3, 2}; TKMPSimpleCallback callback(pattern, pattern + 2); TKMPStreamMatcher<int> matcher(pattern, pattern + 2, &callback); - for (auto& i : data) - matcher.Push(i); + for (auto& i : data) + matcher.Push(i); UNIT_ASSERT_EQUAL(2, callback.GetCount()); } }; diff --git a/library/cpp/deprecated/mapped_file/mapped_file.cpp b/library/cpp/deprecated/mapped_file/mapped_file.cpp index b0e4511299b..90752ea2638 100644 --- a/library/cpp/deprecated/mapped_file/mapped_file.cpp +++ b/library/cpp/deprecated/mapped_file/mapped_file.cpp @@ -15,7 +15,7 @@ TMappedFile::TMappedFile(TFileMap* map, const char* dbgName) { } TMappedFile::TMappedFile(const TFile& file, TFileMap::EOpenMode om, const char* dbgName) - : Map_(nullptr) + : Map_(nullptr) { init(file, om, dbgName); } diff --git a/library/cpp/deprecated/mapped_file/mapped_file.h b/library/cpp/deprecated/mapped_file/mapped_file.h index 45859ed65a0..3245f742495 100644 --- a/library/cpp/deprecated/mapped_file/mapped_file.h +++ b/library/cpp/deprecated/mapped_file/mapped_file.h @@ -23,7 +23,7 @@ private: public: TMappedFile() { - Map_ = nullptr; + Map_ = nullptr; } ~TMappedFile() { @@ -31,7 +31,7 @@ public: } explicit TMappedFile(const TString& name) { - Map_ = nullptr; + Map_ = nullptr; init(name, TFileMap::oRdOnly); } @@ -51,7 +51,7 @@ public: if (Map_) { Map_->Unmap(); delete Map_; - Map_ = nullptr; + Map_ = nullptr; } } @@ -60,7 +60,7 @@ public: } void* getData(size_t pos = 0) const { - Y_ASSERT(!Map_ || (pos <= getSize())); + Y_ASSERT(!Map_ || (pos <= getSize())); return (Map_ ? (void*)((unsigned char*)Map_->Ptr() + pos) : nullptr); } diff --git a/library/cpp/deprecated/mapped_file/ut/mapped_file_ut.cpp b/library/cpp/deprecated/mapped_file/ut/mapped_file_ut.cpp index afbd5b33582..6eaa0635626 100644 --- a/library/cpp/deprecated/mapped_file/ut/mapped_file_ut.cpp +++ b/library/cpp/deprecated/mapped_file/ut/mapped_file_ut.cpp @@ -3,9 +3,9 @@ #include <util/system/fs.h> -Y_UNIT_TEST_SUITE(TMappedFileTest) { +Y_UNIT_TEST_SUITE(TMappedFileTest) { static const char* FileName_("./mappped_file"); - Y_UNIT_TEST(TestFileMapEmpty) { + Y_UNIT_TEST(TestFileMapEmpty) { TFile file(FileName_, CreateAlways | WrOnly); file.Close(); diff --git a/library/cpp/deprecated/split/delim_string_iter.h b/library/cpp/deprecated/split/delim_string_iter.h index 8e4ca171a09..af0d86872d8 100644 --- a/library/cpp/deprecated/split/delim_string_iter.h +++ b/library/cpp/deprecated/split/delim_string_iter.h @@ -173,8 +173,8 @@ public: TKeyValueDelimStringIter(const TStringBuf str, const TStringBuf delim); bool Valid() const; TKeyValueDelimStringIter& operator++(); - const TStringBuf& Key() const; - const TStringBuf& Value() const; + const TStringBuf& Key() const; + const TStringBuf& Value() const; private: TDelimStringIter DelimIter; diff --git a/library/cpp/deprecated/split/delim_string_iter_ut.cpp b/library/cpp/deprecated/split/delim_string_iter_ut.cpp index 18a8b2a1604..644d72e56fd 100644 --- a/library/cpp/deprecated/split/delim_string_iter_ut.cpp +++ b/library/cpp/deprecated/split/delim_string_iter_ut.cpp @@ -16,22 +16,22 @@ static void AssertStringSplit(const TString& str, const TString& delim, const TV UNIT_ASSERT(!it.Valid()); }; -Y_UNIT_TEST_SUITE(TDelimStrokaIterTestSuite) { - Y_UNIT_TEST(SingleCharacterAsDelimiter) { +Y_UNIT_TEST_SUITE(TDelimStrokaIterTestSuite) { + Y_UNIT_TEST(SingleCharacterAsDelimiter) { AssertStringSplit( "Hello words!", " ", {"Hello", "words!"}); } - Y_UNIT_TEST(MultipleCharactersAsDelimiter) { + Y_UNIT_TEST(MultipleCharactersAsDelimiter) { AssertStringSplit( "0, 1, 1, 2, 3, 5, 8, 13, 21, 34", "1, ", {"0, ", "", "2, 3, 5, 8, 13, 2", "34"}); } - Y_UNIT_TEST(NoDelimitersPresent) { + Y_UNIT_TEST(NoDelimitersPresent) { AssertStringSplit("This string could be yours", "\t", {"This string could be yours"}); } - Y_UNIT_TEST(Cdr) { + Y_UNIT_TEST(Cdr) { TDelimStringIter it("a\tc\t", "\t"); UNIT_ASSERT_STRINGS_EQUAL(*it, "a"); UNIT_ASSERT_STRINGS_EQUAL(it.Cdr(), "c\t"); @@ -39,7 +39,7 @@ Y_UNIT_TEST_SUITE(TDelimStrokaIterTestSuite) { UNIT_ASSERT_STRINGS_EQUAL(it.Cdr(), ""); } - Y_UNIT_TEST(ForIter) { + Y_UNIT_TEST(ForIter) { TVector<TStringBuf> expected = {"1", "", "3@4", ""}; TVector<TStringBuf> got; @@ -52,8 +52,8 @@ Y_UNIT_TEST_SUITE(TDelimStrokaIterTestSuite) { } static void AssertKeyValueStringSplit( - const TStringBuf str, - const TStringBuf delim, + const TStringBuf str, + const TStringBuf delim, const TVector<std::pair<TStringBuf, TStringBuf>>& expected) { TKeyValueDelimStringIter it(str, delim); @@ -66,28 +66,28 @@ static void AssertKeyValueStringSplit( UNIT_ASSERT(!it.Valid()); } -Y_UNIT_TEST_SUITE(TKeyValueDelimStringIterTestSuite) { - Y_UNIT_TEST(SingleCharacterAsDelimiter) { +Y_UNIT_TEST_SUITE(TKeyValueDelimStringIterTestSuite) { + Y_UNIT_TEST(SingleCharacterAsDelimiter) { AssertKeyValueStringSplit( "abc=123,cde=qwer", ",", {{"abc", "123"}, {"cde", "qwer"}}); } - Y_UNIT_TEST(MultipleCharactersAsDelimiter) { + Y_UNIT_TEST(MultipleCharactersAsDelimiter) { AssertKeyValueStringSplit( "abc=xyz@@qwerty=zxcv", "@@", {{"abc", "xyz"}, {"qwerty", "zxcv"}}); } - Y_UNIT_TEST(NoDelimiters) { + Y_UNIT_TEST(NoDelimiters) { AssertKeyValueStringSplit( "abc=zz", ",", {{"abc", "zz"}}); } - Y_UNIT_TEST(EmptyElements) { + Y_UNIT_TEST(EmptyElements) { AssertKeyValueStringSplit( "@@abc=zxy@@@@qwerty=y@@", "@@", {{"", ""}, diff --git a/library/cpp/deprecated/split/split_iterator.cpp b/library/cpp/deprecated/split/split_iterator.cpp index 32262d25bd1..ca46799dd6f 100644 --- a/library/cpp/deprecated/split/split_iterator.cpp +++ b/library/cpp/deprecated/split/split_iterator.cpp @@ -155,7 +155,7 @@ TDelimitersSplitWithoutTags::TDelimitersSplitWithoutTags(const TString& s, const } size_t TDelimitersSplitWithoutTags::SkipTag(size_t pos) const { - Y_ASSERT('<' == Str[pos]); + Y_ASSERT('<' == Str[pos]); while ((pos < Len) && ('>' != Str[pos])) ++pos; return pos + 1; @@ -236,7 +236,7 @@ TCharSplitWithoutTags::TCharSplitWithoutTags(const TString& s) } size_t TCharSplitWithoutTags::SkipTag(size_t pos) const { - Y_ASSERT('<' == Str[pos]); + Y_ASSERT('<' == Str[pos]); while ((pos < Len) && ('>' != Str[pos])) ++pos; return pos + 1; diff --git a/library/cpp/deprecated/split/split_iterator.h b/library/cpp/deprecated/split/split_iterator.h index 0eacc29228e..b1a39d81bea 100644 --- a/library/cpp/deprecated/split/split_iterator.h +++ b/library/cpp/deprecated/split/split_iterator.h @@ -25,7 +25,7 @@ struct TNumPair { : Begin(begin) , End(end) { - Y_ASSERT(begin <= end); + Y_ASSERT(begin <= end); } T Length() const { @@ -264,7 +264,7 @@ public: TSplitIterator(const TSplit& split) : Split(split) , Pos(Split.Begin()) - , CurrentStroka(nullptr) + , CurrentStroka(nullptr) { } diff --git a/library/cpp/diff/diff.cpp b/library/cpp/diff/diff.cpp index be57da7f396..776b686546c 100644 --- a/library/cpp/diff/diff.cpp +++ b/library/cpp/diff/diff.cpp @@ -66,8 +66,8 @@ size_t NDiff::InlineDiff(TVector<TChunk<char>>& chunks, const TStringBuf& left, TCollection<char> c2(right, delims); TVector<TChunk<ui64>> diff; const size_t dist = InlineDiff<ui64>(diff, c1.GetKeys(), c2.GetKeys()); - for (const auto& it : diff) { - chunks.push_back(TChunk<char>(c1.Remap(it.Left), c2.Remap(it.Right), c1.Remap(it.Common))); + for (const auto& it : diff) { + chunks.push_back(TChunk<char>(c1.Remap(it.Left), c2.Remap(it.Right), c1.Remap(it.Common))); } return dist; } @@ -80,7 +80,7 @@ size_t NDiff::InlineDiff(TVector<TChunk<wchar16>>& chunks, const TWtringBuf& lef TCollection<wchar16> c2(right, delims); TVector<TChunk<ui64>> diff; const size_t dist = InlineDiff<ui64>(diff, c1.GetKeys(), c2.GetKeys()); - for (const auto& it : diff) { + for (const auto& it : diff) { chunks.push_back(TChunk<wchar16>(c1.Remap(it.Left), c2.Remap(it.Right), c1.Remap(it.Common))); } return dist; diff --git a/library/cpp/diff/diff.h b/library/cpp/diff/diff.h index 94fb00cd0b3..252564f53ac 100644 --- a/library/cpp/diff/diff.h +++ b/library/cpp/diff/diff.h @@ -44,8 +44,8 @@ namespace NDiff { NLCS::MakeLCS<T>(s1, s2, &lcs, &ctx); // Start points of current common and diff parts - const T* c1 = nullptr; - const T* c2 = nullptr; + const T* c1 = nullptr; + const T* c2 = nullptr; const T* d1 = s1.begin(); const T* d2 = s2.begin(); diff --git a/library/cpp/diff/diff_ut.cpp b/library/cpp/diff/diff_ut.cpp index b82a7b000ee..dd75fa67541 100644 --- a/library/cpp/diff/diff_ut.cpp +++ b/library/cpp/diff/diff_ut.cpp @@ -36,7 +36,7 @@ struct TDiffTester { } }; -Y_UNIT_TEST_SUITE(DiffTokens) { +Y_UNIT_TEST_SUITE(DiffTokens) { Y_UNIT_TEST(ReturnValue) { TVector<TChunk<char>> res; UNIT_ASSERT_VALUES_EQUAL(InlineDiff(res, "aaa", "aaa"), 0); @@ -49,7 +49,7 @@ Y_UNIT_TEST_SUITE(DiffTokens) { UNIT_ASSERT_VALUES_EQUAL(InlineDiff(res, "abc", "xyz"), 3); } - Y_UNIT_TEST(EqualStringsOneToken) { + Y_UNIT_TEST(EqualStringsOneToken) { TDiffTester tester; tester.Test("aaa", "aaa"); @@ -57,7 +57,7 @@ Y_UNIT_TEST_SUITE(DiffTokens) { UNIT_ASSERT_VALUES_EQUAL(tester.Result(), "aaa"); } - Y_UNIT_TEST(NonCrossingStringsOneToken) { + Y_UNIT_TEST(NonCrossingStringsOneToken) { TDiffTester tester; tester.Test("aaa", "bbb"); @@ -69,7 +69,7 @@ Y_UNIT_TEST_SUITE(DiffTokens) { UNIT_ASSERT_VALUES_EQUAL(tester.Result(), "(aaa|bbbb)"); } - Y_UNIT_TEST(Simple) { + Y_UNIT_TEST(Simple) { TDiffTester tester; tester.Test("aaa", "abb", ""); @@ -89,7 +89,7 @@ Y_UNIT_TEST_SUITE(DiffTokens) { UNIT_ASSERT_VALUES_EQUAL(tester.Result(), "[1, (2|3), 3]"); } - Y_UNIT_TEST(CommonCharOneToken) { + Y_UNIT_TEST(CommonCharOneToken) { TDiffTester tester; tester.Test("abcde", "accfg"); @@ -97,7 +97,7 @@ Y_UNIT_TEST_SUITE(DiffTokens) { UNIT_ASSERT_VALUES_EQUAL(tester.Result(), "(abcde|accfg)"); } - Y_UNIT_TEST(EqualStringsTwoTokens) { + Y_UNIT_TEST(EqualStringsTwoTokens) { TDiffTester tester; TStringBuf str("aaa bbb"); @@ -107,7 +107,7 @@ Y_UNIT_TEST_SUITE(DiffTokens) { UNIT_ASSERT_VALUES_EQUAL(tester.Result(), "aaa bbb"); } - Y_UNIT_TEST(NonCrossingStringsTwoTokens) { + Y_UNIT_TEST(NonCrossingStringsTwoTokens) { TDiffTester tester; tester.Test("aaa bbb", "ccc ddd"); @@ -119,7 +119,7 @@ Y_UNIT_TEST_SUITE(DiffTokens) { UNIT_ASSERT_VALUES_EQUAL(tester.Result(), "(aaa|c) (bbb|d)"); } - Y_UNIT_TEST(SimpleTwoTokens) { + Y_UNIT_TEST(SimpleTwoTokens) { TDiffTester tester; tester.Test("aaa ccd", "abb cce"); @@ -131,7 +131,7 @@ Y_UNIT_TEST_SUITE(DiffTokens) { UNIT_ASSERT_VALUES_EQUAL(tester.Result(), "(aac|aa) (cbb|bb)"); } - Y_UNIT_TEST(MixedTwoTokens) { + Y_UNIT_TEST(MixedTwoTokens) { TDiffTester tester; tester.Test("aaa bbb", "bbb aaa"); @@ -151,7 +151,7 @@ Y_UNIT_TEST_SUITE(DiffTokens) { UNIT_ASSERT_VALUES_EQUAL(tester.Result(), "(aaa|) (bb|bbb aa)"); } - Y_UNIT_TEST(TwoTokensInOneString) { + Y_UNIT_TEST(TwoTokensInOneString) { TDiffTester tester; tester.Test("aaa bbb", "aaa"); @@ -171,7 +171,7 @@ Y_UNIT_TEST_SUITE(DiffTokens) { UNIT_ASSERT_VALUES_EQUAL(tester.Result(), "(aaa |)bbb"); } - Y_UNIT_TEST(Multiline) { + Y_UNIT_TEST(Multiline) { TDiffTester tester; tester.Test("aaa\nabc\nbbb", "aaa\nacc\nbbb"); @@ -183,7 +183,7 @@ Y_UNIT_TEST_SUITE(DiffTokens) { UNIT_ASSERT_VALUES_EQUAL(tester.Result(), "aaa\n(abc|ac)\nbbb"); } - Y_UNIT_TEST(DifferentDelimiters) { + Y_UNIT_TEST(DifferentDelimiters) { TDiffTester tester; tester.Test("aaa bbb", "aaa\tbbb"); diff --git a/library/cpp/digest/argonish/ut/ut.cpp b/library/cpp/digest/argonish/ut/ut.cpp index 12ef530a18c..e663ac15acd 100644 --- a/library/cpp/digest/argonish/ut/ut.cpp +++ b/library/cpp/digest/argonish/ut/ut.cpp @@ -2,7 +2,7 @@ #include <library/cpp/digest/argonish/blake2b.h> #include <library/cpp/testing/unittest/registar.h> -Y_UNIT_TEST_SUITE(ArgonishTest) { +Y_UNIT_TEST_SUITE(ArgonishTest) { const ui8 GenKatPassword[32] = { 0x01, 0x01, @@ -130,7 +130,7 @@ Y_UNIT_TEST_SUITE(ArgonishTest) { 0x04, }; - Y_UNIT_TEST(Argon2_Fr_Test) { + Y_UNIT_TEST(Argon2_Fr_Test) { const ui32 mcost = 16; const ui32 tcost = 1; TArrayHolder<ui8> memory(new ui8[mcost * 1024]); @@ -176,7 +176,7 @@ Y_UNIT_TEST_SUITE(ArgonishTest) { } } - Y_UNIT_TEST(Argon2_Factory_SelfTest) { + Y_UNIT_TEST(Argon2_Factory_SelfTest) { try { NArgonish::TArgon2Factory factory; factory.GetInstructionSet(); @@ -185,7 +185,7 @@ Y_UNIT_TEST_SUITE(ArgonishTest) { } } - Y_UNIT_TEST(Blake2B_Factory_SelfTest) { + Y_UNIT_TEST(Blake2B_Factory_SelfTest) { try { NArgonish::TBlake2BFactory factory; factory.GetInstructionSet(); @@ -194,7 +194,7 @@ Y_UNIT_TEST_SUITE(ArgonishTest) { } } - Y_UNIT_TEST(Argon2d) { + Y_UNIT_TEST(Argon2d) { const ui8 TResult[32] = { 0x7b, 0xa5, 0xa1, 0x7a, 0x72, 0xf7, 0xe5, 0x99, 0x77, 0xf7, 0xf2, 0x3d, 0x10, 0xe6, 0x21, 0x89, @@ -221,7 +221,7 @@ Y_UNIT_TEST_SUITE(ArgonishTest) { } } - Y_UNIT_TEST(Argon2i) { + Y_UNIT_TEST(Argon2i) { const ui8 TResult[32] = { 0x87, 0x4d, 0x23, 0xfb, 0x9f, 0x55, 0xe2, 0xff, 0x66, 0xbc, 0x19, 0x03, 0x46, 0xe7, 0x01, 0x19, @@ -248,7 +248,7 @@ Y_UNIT_TEST_SUITE(ArgonishTest) { } } - Y_UNIT_TEST(Argon2id) { + Y_UNIT_TEST(Argon2id) { const ui8 TResult[32] = { 0x99, 0xdf, 0xcf, 0xc2, 0x89, 0x76, 0x93, 0x9d, 0xa2, 0x97, 0x09, 0x44, 0x34, 0xd8, 0x6f, 0xd0, @@ -275,7 +275,7 @@ Y_UNIT_TEST_SUITE(ArgonishTest) { } } - Y_UNIT_TEST(Argon2d_2p) { + Y_UNIT_TEST(Argon2d_2p) { const ui8 TResult[32] = { 0x59, 0xb0, 0x94, 0x62, 0xcf, 0xdc, 0xd2, 0xb4, 0x0a, 0xbd, 0x17, 0x81, 0x0a, 0x47, 0x4a, 0x8e, @@ -302,7 +302,7 @@ Y_UNIT_TEST_SUITE(ArgonishTest) { } } - Y_UNIT_TEST(Argon2i_2p) { + Y_UNIT_TEST(Argon2i_2p) { const ui8 TResult[32] = { 0xc1, 0x0f, 0x00, 0x5e, 0xf8, 0x78, 0xc8, 0x07, 0x0e, 0x2c, 0xc5, 0x2f, 0x57, 0x75, 0x25, 0xc9, @@ -329,7 +329,7 @@ Y_UNIT_TEST_SUITE(ArgonishTest) { } } - Y_UNIT_TEST(Argon2id_2p) { + Y_UNIT_TEST(Argon2id_2p) { const ui8 TResult[32] = { 0x6c, 0x00, 0xb7, 0xa9, 0x00, 0xe5, 0x00, 0x4c, 0x24, 0x46, 0x9e, 0xc1, 0xe7, 0xc0, 0x1a, 0x99, @@ -356,7 +356,7 @@ Y_UNIT_TEST_SUITE(ArgonishTest) { } } - Y_UNIT_TEST(Argon2d_2p_2th) { + Y_UNIT_TEST(Argon2d_2p_2th) { const ui8 TResult[32] = { 0x2b, 0x47, 0x35, 0x39, 0x4a, 0x40, 0x3c, 0xc9, 0x05, 0xfb, 0x51, 0x25, 0x96, 0x68, 0x64, 0x43, @@ -383,7 +383,7 @@ Y_UNIT_TEST_SUITE(ArgonishTest) { } } - Y_UNIT_TEST(Argon2id_2p_4th) { + Y_UNIT_TEST(Argon2id_2p_4th) { const ui8 TResult[32] = { 0x4f, 0x93, 0xb5, 0xad, 0x78, 0xa4, 0xa9, 0x49, 0xfb, 0xe3, 0x55, 0x96, 0xd5, 0xa0, 0xc2, 0xab, @@ -410,7 +410,7 @@ Y_UNIT_TEST_SUITE(ArgonishTest) { } } - Y_UNIT_TEST(Argon2d_2p_4th) { + Y_UNIT_TEST(Argon2d_2p_4th) { const ui8 TResult[32] = { 0x8f, 0xa2, 0x7c, 0xed, 0x28, 0x38, 0x79, 0x0f, 0xba, 0x5c, 0x11, 0x85, 0x1c, 0xdf, 0x90, 0x88, @@ -437,7 +437,7 @@ Y_UNIT_TEST_SUITE(ArgonishTest) { } } - Y_UNIT_TEST(Argon2i_2p_4th) { + Y_UNIT_TEST(Argon2i_2p_4th) { const ui8 TResult[32] = { 0x61, 0x1c, 0x99, 0x3c, 0xb0, 0xb7, 0x23, 0x16, 0xbd, 0xa2, 0x6c, 0x4c, 0x2f, 0xe8, 0x2d, 0x39, @@ -464,7 +464,7 @@ Y_UNIT_TEST_SUITE(ArgonishTest) { } } - Y_UNIT_TEST(Argon2d_128) { + Y_UNIT_TEST(Argon2d_128) { const ui8 TResult[128] = { 0x4e, 0xc4, 0x6c, 0x4e, 0x8c, 0x32, 0x89, 0x65, 0xf9, 0x82, 0x2b, 0x00, 0x95, 0x00, 0x50, 0x0a, @@ -503,7 +503,7 @@ Y_UNIT_TEST_SUITE(ArgonishTest) { } } - Y_UNIT_TEST(Blake2B_16_ABC) { + Y_UNIT_TEST(Blake2B_16_ABC) { const ui8 TResult[16] = { 0xcf, 0x4a, 0xb7, 0x91, 0xc6, 0x2b, 0x8d, 0x2b, 0x21, 0x09, 0xc9, 0x02, 0x75, 0x28, 0x78, 0x16}; @@ -522,7 +522,7 @@ Y_UNIT_TEST_SUITE(ArgonishTest) { } } - Y_UNIT_TEST(Blake2B_64_ABC) { + Y_UNIT_TEST(Blake2B_64_ABC) { const ui8 TResult[64] = { 0xba, 0x80, 0xa5, 0x3f, 0x98, 0x1c, 0x4d, 0x0d, 0x6a, 0x27, 0x97, 0xb6, 0x9f, 0x12, 0xf6, 0xe9, diff --git a/library/cpp/digest/argonish/ut_fat/ut.cpp b/library/cpp/digest/argonish/ut_fat/ut.cpp index 41fa001685a..81bc9a696ab 100644 --- a/library/cpp/digest/argonish/ut_fat/ut.cpp +++ b/library/cpp/digest/argonish/ut_fat/ut.cpp @@ -2,7 +2,7 @@ #include <library/cpp/digest/argonish/blake2b.h> #include <library/cpp/testing/unittest/registar.h> -Y_UNIT_TEST_SUITE(ArgonishTest) { +Y_UNIT_TEST_SUITE(ArgonishTest) { const ui8 GenKatPassword[32] = { 0x01, 0x01, @@ -91,7 +91,7 @@ Y_UNIT_TEST_SUITE(ArgonishTest) { #endif ; - Y_UNIT_TEST(Argon2_Factory_SelfTest) { + Y_UNIT_TEST(Argon2_Factory_SelfTest) { try { NArgonish::TArgon2Factory factory; } catch (...) { @@ -99,7 +99,7 @@ Y_UNIT_TEST_SUITE(ArgonishTest) { } } - Y_UNIT_TEST(Argon2d) { + Y_UNIT_TEST(Argon2d) { const ui8 TResult[32] = { 0x7b, 0xa5, 0xa1, 0x7a, 0x72, 0xf7, 0xe5, 0x99, 0x77, 0xf7, 0xf2, 0x3d, 0x10, 0xe6, 0x21, 0x89, @@ -125,7 +125,7 @@ Y_UNIT_TEST_SUITE(ArgonishTest) { } } - Y_UNIT_TEST(Argon2i) { + Y_UNIT_TEST(Argon2i) { const ui8 TResult[32] = { 0x87, 0x4d, 0x23, 0xfb, 0x9f, 0x55, 0xe2, 0xff, 0x66, 0xbc, 0x19, 0x03, 0x46, 0xe7, 0x01, 0x19, @@ -151,7 +151,7 @@ Y_UNIT_TEST_SUITE(ArgonishTest) { } } - Y_UNIT_TEST(Argon2id) { + Y_UNIT_TEST(Argon2id) { const ui8 TResult[32] = { 0x99, 0xdf, 0xcf, 0xc2, 0x89, 0x76, 0x93, 0x9d, 0xa2, 0x97, 0x09, 0x44, 0x34, 0xd8, 0x6f, 0xd0, @@ -177,7 +177,7 @@ Y_UNIT_TEST_SUITE(ArgonishTest) { } } - Y_UNIT_TEST(Argon2d_2p) { + Y_UNIT_TEST(Argon2d_2p) { const ui8 TResult[32] = { 0x59, 0xb0, 0x94, 0x62, 0xcf, 0xdc, 0xd2, 0xb4, 0x0a, 0xbd, 0x17, 0x81, 0x0a, 0x47, 0x4a, 0x8e, @@ -203,7 +203,7 @@ Y_UNIT_TEST_SUITE(ArgonishTest) { } } - Y_UNIT_TEST(Argon2i_2p) { + Y_UNIT_TEST(Argon2i_2p) { const ui8 TResult[32] = { 0xc1, 0x0f, 0x00, 0x5e, 0xf8, 0x78, 0xc8, 0x07, 0x0e, 0x2c, 0xc5, 0x2f, 0x57, 0x75, 0x25, 0xc9, @@ -229,7 +229,7 @@ Y_UNIT_TEST_SUITE(ArgonishTest) { } } - Y_UNIT_TEST(Argon2id_2p) { + Y_UNIT_TEST(Argon2id_2p) { const ui8 TResult[32] = { 0x6c, 0x00, 0xb7, 0xa9, 0x00, 0xe5, 0x00, 0x4c, 0x24, 0x46, 0x9e, 0xc1, 0xe7, 0xc0, 0x1a, 0x99, @@ -255,7 +255,7 @@ Y_UNIT_TEST_SUITE(ArgonishTest) { } } - Y_UNIT_TEST(Argon2d_2p_2th) { + Y_UNIT_TEST(Argon2d_2p_2th) { const ui8 TResult[32] = { 0x2b, 0x47, 0x35, 0x39, 0x4a, 0x40, 0x3c, 0xc9, 0x05, 0xfb, 0x51, 0x25, 0x96, 0x68, 0x64, 0x43, @@ -281,7 +281,7 @@ Y_UNIT_TEST_SUITE(ArgonishTest) { } } - Y_UNIT_TEST(Argon2id_2p_4th) { + Y_UNIT_TEST(Argon2id_2p_4th) { const ui8 TResult[32] = { 0x4f, 0x93, 0xb5, 0xad, 0x78, 0xa4, 0xa9, 0x49, 0xfb, 0xe3, 0x55, 0x96, 0xd5, 0xa0, 0xc2, 0xab, @@ -307,7 +307,7 @@ Y_UNIT_TEST_SUITE(ArgonishTest) { } } - Y_UNIT_TEST(Argon2d_2p_4th) { + Y_UNIT_TEST(Argon2d_2p_4th) { const ui8 TResult[32] = { 0x8f, 0xa2, 0x7c, 0xed, 0x28, 0x38, 0x79, 0x0f, 0xba, 0x5c, 0x11, 0x85, 0x1c, 0xdf, 0x90, 0x88, @@ -333,7 +333,7 @@ Y_UNIT_TEST_SUITE(ArgonishTest) { } } - Y_UNIT_TEST(Argon2i_2p_4th) { + Y_UNIT_TEST(Argon2i_2p_4th) { const ui8 TResult[32] = { 0x61, 0x1c, 0x99, 0x3c, 0xb0, 0xb7, 0x23, 0x16, 0xbd, 0xa2, 0x6c, 0x4c, 0x2f, 0xe8, 0x2d, 0x39, @@ -359,7 +359,7 @@ Y_UNIT_TEST_SUITE(ArgonishTest) { } } - Y_UNIT_TEST(Argon2d_128) { + Y_UNIT_TEST(Argon2d_128) { const ui8 TResult[128] = { 0x4e, 0xc4, 0x6c, 0x4e, 0x8c, 0x32, 0x89, 0x65, 0xf9, 0x82, 0x2b, 0x00, 0x95, 0x00, 0x50, 0x0a, @@ -397,7 +397,7 @@ Y_UNIT_TEST_SUITE(ArgonishTest) { } } - Y_UNIT_TEST(Blake2B_16_ABC) { + Y_UNIT_TEST(Blake2B_16_ABC) { const ui8 TResult[16] = { 0xcf, 0x4a, 0xb7, 0x91, 0xc6, 0x2b, 0x8d, 0x2b, 0x21, 0x09, 0xc9, 0x02, 0x75, 0x28, 0x78, 0x16}; @@ -415,7 +415,7 @@ Y_UNIT_TEST_SUITE(ArgonishTest) { } } - Y_UNIT_TEST(Blake2B_64_ABC) { + Y_UNIT_TEST(Blake2B_64_ABC) { const ui8 TResult[64] = { 0xba, 0x80, 0xa5, 0x3f, 0x98, 0x1c, 0x4d, 0x0d, 0x6a, 0x27, 0x97, 0xb6, 0x9f, 0x12, 0xf6, 0xe9, diff --git a/library/cpp/digest/crc32c/crc32c_ut.cpp b/library/cpp/digest/crc32c/crc32c_ut.cpp index aa31b83422a..1343fb80c19 100644 --- a/library/cpp/digest/crc32c/crc32c_ut.cpp +++ b/library/cpp/digest/crc32c/crc32c_ut.cpp @@ -2,12 +2,12 @@ #include <library/cpp/testing/unittest/registar.h> -Y_UNIT_TEST_SUITE(TestCrc32c) { - Y_UNIT_TEST(TestCalc) { +Y_UNIT_TEST_SUITE(TestCrc32c) { + Y_UNIT_TEST(TestCalc) { UNIT_ASSERT_VALUES_EQUAL(Crc32c("abc", 3), ui32(910901175)); } - Y_UNIT_TEST(TestUnaligned) { + Y_UNIT_TEST(TestUnaligned) { const TString str(1000, 'a'); for (size_t substrLen = 0; substrLen <= str.length(); ++substrLen) { const ui32 crc = Crc32c(str.data(), substrLen); @@ -17,7 +17,7 @@ Y_UNIT_TEST_SUITE(TestCrc32c) { } } - Y_UNIT_TEST(TestExtend) { + Y_UNIT_TEST(TestExtend) { UNIT_ASSERT_VALUES_EQUAL(Crc32cExtend(1, "abc", 3), ui32(2466950601)); } } diff --git a/library/cpp/digest/lower_case/hash_ops_ut.cpp b/library/cpp/digest/lower_case/hash_ops_ut.cpp index a7ab0b86ea6..645ef7bb5cc 100644 --- a/library/cpp/digest/lower_case/hash_ops_ut.cpp +++ b/library/cpp/digest/lower_case/hash_ops_ut.cpp @@ -2,8 +2,8 @@ #include <library/cpp/testing/unittest/registar.h> -Y_UNIT_TEST_SUITE(TestCIHash) { - Y_UNIT_TEST(TestYHash1) { +Y_UNIT_TEST_SUITE(TestCIHash) { + Y_UNIT_TEST(TestYHash1) { THashMap<TStringBuf, int, TCIOps, TCIOps> h; h["Ab"] = 1; @@ -13,7 +13,7 @@ Y_UNIT_TEST_SUITE(TestCIHash) { UNIT_ASSERT_VALUES_EQUAL(h["ab"], 2); } - Y_UNIT_TEST(TestYHash2) { + Y_UNIT_TEST(TestYHash2) { THashMap<const char*, int, TCIOps, TCIOps> h; h["Ab"] = 1; @@ -29,7 +29,7 @@ Y_UNIT_TEST_SUITE(TestCIHash) { UNIT_ASSERT_VALUES_EQUAL(h["bc"], 3); } - Y_UNIT_TEST(Test1) { + Y_UNIT_TEST(Test1) { UNIT_ASSERT_VALUES_EQUAL(TCIOps()("aBc3"), TCIOps()(TStringBuf("AbC3"))); UNIT_ASSERT(TCIOps()("aBc4", "AbC4")); } diff --git a/library/cpp/digest/lower_case/lchash_ut.cpp b/library/cpp/digest/lower_case/lchash_ut.cpp index 5711fe7cd7e..acd9f64934a 100644 --- a/library/cpp/digest/lower_case/lchash_ut.cpp +++ b/library/cpp/digest/lower_case/lchash_ut.cpp @@ -2,19 +2,19 @@ #include <library/cpp/testing/unittest/registar.h> -Y_UNIT_TEST_SUITE(TWebDaemonHash) { - Y_UNIT_TEST(Stability) { +Y_UNIT_TEST_SUITE(TWebDaemonHash) { + Y_UNIT_TEST(Stability) { UNIT_ASSERT_VALUES_EQUAL(FnvCaseLess<ui64>("blah"), ULL(5923727754379976229)); UNIT_ASSERT_VALUES_EQUAL(FnvCaseLess<ui64>("blahminor"), ULL(8755704309003440816)); } - Y_UNIT_TEST(CaseLess) { + Y_UNIT_TEST(CaseLess) { UNIT_ASSERT_VALUES_EQUAL(FnvCaseLess<ui64>("blah"), FnvCaseLess<ui64>("bLah")); UNIT_ASSERT_VALUES_EQUAL(FnvCaseLess<ui64>("blah"), FnvCaseLess<ui64>("blAh")); UNIT_ASSERT_VALUES_EQUAL(FnvCaseLess<ui64>("blah"), FnvCaseLess<ui64>("BLAH")); } - Y_UNIT_TEST(Robustness) { + Y_UNIT_TEST(Robustness) { UNIT_ASSERT(FnvCaseLess<ui64>("x-real-ip") != FnvCaseLess<ui64>("x-req-id")); UNIT_ASSERT(FnvCaseLess<ui64>("x-real-ip") != FnvCaseLess<ui64>("x-start-time")); } diff --git a/library/cpp/digest/md5/md5.cpp b/library/cpp/digest/md5/md5.cpp index 24a5b69eefb..60eda2abea9 100644 --- a/library/cpp/digest/md5/md5.cpp +++ b/library/cpp/digest/md5/md5.cpp @@ -14,7 +14,7 @@ namespace { constexpr size_t MD5_PADDING_SHIFT = 56; constexpr size_t MD5_HEX_DIGEST_LENGTH = 32; - struct TMd5Stream: public IOutputStream { + struct TMd5Stream: public IOutputStream { inline TMd5Stream(MD5* md5) : M_(md5) { @@ -44,7 +44,7 @@ char* MD5::File(const char* filename, char* buf) { } catch (...) { } - return nullptr; + return nullptr; } TString MD5::File(const TString& filename) { @@ -61,7 +61,7 @@ char* MD5::Data(const TArrayRef<const ui8>& data, char* buf) { return MD5().Update(data).End(buf); } -char* MD5::Data(const void* data, size_t len, char* buf) { +char* MD5::Data(const void* data, size_t len, char* buf) { return Data(MakeUnsignedArrayRef(data, len), buf); } @@ -76,11 +76,11 @@ TString MD5::Data(TStringBuf data) { return Data(MakeUnsignedArrayRef(data)); } -char* MD5::Stream(IInputStream* in, char* buf) { +char* MD5::Stream(IInputStream* in, char* buf) { return MD5().Update(in).End(buf); } -MD5& MD5::Update(IInputStream* in) { +MD5& MD5::Update(IInputStream* in) { TMd5Stream md5(this); TransferData(in, &md5); @@ -179,7 +179,7 @@ char* MD5::End(char* buf) { if (!buf) buf = (char*)malloc(33); if (!buf) - return nullptr; + return nullptr; Final(digest); for (ui8 i = 0; i < MD5_HEX_DIGEST_LENGTH / 2; i++) { buf[i * 2] = hex[digest[i] >> 4]; @@ -194,10 +194,10 @@ char* MD5::End_b64(char* buf) { if (!buf) buf = (char*)malloc(25); if (!buf) - return nullptr; + return nullptr; Final(digest); Base64Encode(buf, digest, 16); - buf[24] = '\0'; + buf[24] = '\0'; return buf; } diff --git a/library/cpp/digest/md5/md5.h b/library/cpp/digest/md5/md5.h index 2c17aa05181..74c002a82c7 100644 --- a/library/cpp/digest/md5/md5.h +++ b/library/cpp/digest/md5/md5.h @@ -3,7 +3,7 @@ #include <util/generic/array_ref.h> #include <util/generic/strbuf.h> -class IInputStream; +class IInputStream; class MD5 { public: @@ -38,7 +38,7 @@ public: // 8-byte xor-based mix ui64 EndHalfMix(); - MD5& Update(IInputStream* in); + MD5& Update(IInputStream* in); /* * Return hex-encoded md5 checksum for given file. @@ -48,11 +48,11 @@ public: static char* File(const char* filename, char* buf); static TString File(const TString& filename); - static char* Data(const void* data, size_t len, char* buf); + static char* Data(const void* data, size_t len, char* buf); static char* Data(const TArrayRef<const ui8>& data, char* buf); static TString Data(const TArrayRef<const ui8>& data); static TString Data(TStringBuf data); - static char* Stream(IInputStream* in, char* buf); + static char* Stream(IInputStream* in, char* buf); static TString Calc(TStringBuf data); // 32-byte hex-encoded static TString Calc(const TArrayRef<const ui8>& data); // 32-byte hex-encoded diff --git a/library/cpp/digest/md5/md5_medium_ut.cpp b/library/cpp/digest/md5/md5_medium_ut.cpp index a940c5cb66c..4ea147ff36d 100644 --- a/library/cpp/digest/md5/md5_medium_ut.cpp +++ b/library/cpp/digest/md5/md5_medium_ut.cpp @@ -2,8 +2,8 @@ #include <library/cpp/testing/unittest/registar.h> -Y_UNIT_TEST_SUITE(TMD5MediumTest) { - Y_UNIT_TEST(TestOverflow) { +Y_UNIT_TEST_SUITE(TMD5MediumTest) { + Y_UNIT_TEST(TestOverflow) { if (sizeof(size_t) > sizeof(unsigned int)) { const size_t maxUi32 = (size_t)Max<unsigned int>(); TArrayHolder<char> buf(new char[maxUi32]); diff --git a/library/cpp/digest/md5/md5_ut.cpp b/library/cpp/digest/md5/md5_ut.cpp index 1c3e4ad0a9f..7c955f2f5a3 100644 --- a/library/cpp/digest/md5/md5_ut.cpp +++ b/library/cpp/digest/md5/md5_ut.cpp @@ -5,8 +5,8 @@ #include <util/system/fs.h> #include <util/stream/file.h> -Y_UNIT_TEST_SUITE(TMD5Test) { - Y_UNIT_TEST(TestMD5) { +Y_UNIT_TEST_SUITE(TMD5Test) { + Y_UNIT_TEST(TestMD5) { // echo -n 'qwertyuiopqwertyuiopasdfghjklasdfghjkl' | md5sum constexpr const char* b = "qwertyuiopqwertyuiopasdfghjklasdfghjkl"; @@ -25,7 +25,7 @@ Y_UNIT_TEST_SUITE(TMD5Test) { UNIT_ASSERT_NO_DIFF(result, TStringBuf("3ac00dd696b966fd74deee3c35a59d8f")); } - Y_UNIT_TEST(TestFile) { + Y_UNIT_TEST(TestFile) { TString s = NUnitTest::RandomString(1000000, 1); const TString tmpFile = "tmp"; @@ -49,7 +49,7 @@ Y_UNIT_TEST_SUITE(TMD5Test) { UNIT_ASSERT_EQUAL(fileHash.size(), 0); } - Y_UNIT_TEST(TestIsMD5) { + Y_UNIT_TEST(TestIsMD5) { UNIT_ASSERT_EQUAL(false, MD5::IsMD5(TStringBuf())); UNIT_ASSERT_EQUAL(false, MD5::IsMD5(TStringBuf("4136ebb0e4c45d21e2b09294c75cfa0"))); // length 31 UNIT_ASSERT_EQUAL(false, MD5::IsMD5(TStringBuf("4136ebb0e4c45d21e2b09294c75cfa000"))); // length 33 diff --git a/library/cpp/digest/md5/ya.make b/library/cpp/digest/md5/ya.make index c09ec1c326f..16575b39268 100644 --- a/library/cpp/digest/md5/ya.make +++ b/library/cpp/digest/md5/ya.make @@ -9,9 +9,9 @@ SRCS( md5.cpp ) -PEERDIR( +PEERDIR( contrib/libs/nayuki_md5 library/cpp/string_utils/base64 -) - +) + END() diff --git a/library/cpp/digest/old_crc/crc_ut.cpp b/library/cpp/digest/old_crc/crc_ut.cpp index 46e1d5d29b7..b53225729f2 100644 --- a/library/cpp/digest/old_crc/crc_ut.cpp +++ b/library/cpp/digest/old_crc/crc_ut.cpp @@ -2,7 +2,7 @@ #include <library/cpp/testing/unittest/registar.h> -#include <util/stream/output.h> +#include <util/stream/output.h> class TCrcTest: public TTestBase { UNIT_TEST_SUITE(TCrcTest); diff --git a/library/cpp/digest/old_crc/gencrc/main.cpp b/library/cpp/digest/old_crc/gencrc/main.cpp index d5821304ce3..d718fe67b74 100644 --- a/library/cpp/digest/old_crc/gencrc/main.cpp +++ b/library/cpp/digest/old_crc/gencrc/main.cpp @@ -1,4 +1,4 @@ -#include <util/stream/output.h> +#include <util/stream/output.h> #define POLY_16 0x1021 #define POLY_32 0xEDB88320UL diff --git a/library/cpp/digest/sfh/sfh.h b/library/cpp/digest/sfh/sfh.h index 372938654cb..38cd654e1e2 100644 --- a/library/cpp/digest/sfh/sfh.h +++ b/library/cpp/digest/sfh/sfh.h @@ -1,7 +1,7 @@ #pragma once #include <util/system/defaults.h> -#include <util/system/unaligned_mem.h> +#include <util/system/unaligned_mem.h> inline ui32 SuperFastHash(const void* d, size_t l) noexcept { ui32 hash = (ui32)l; diff --git a/library/cpp/digest/sfh/sfh_ut.cpp b/library/cpp/digest/sfh/sfh_ut.cpp index 912999bae75..d7b9c2fbf91 100644 --- a/library/cpp/digest/sfh/sfh_ut.cpp +++ b/library/cpp/digest/sfh/sfh_ut.cpp @@ -2,7 +2,7 @@ #include <library/cpp/testing/unittest/registar.h> -#include <util/stream/output.h> +#include <util/stream/output.h> class TSfhTest: public TTestBase { UNIT_TEST_SUITE(TSfhTest); diff --git a/library/cpp/dns/cache.cpp b/library/cpp/dns/cache.cpp index 05c14e82fce..fe2bf56496e 100644 --- a/library/cpp/dns/cache.cpp +++ b/library/cpp/dns/cache.cpp @@ -122,7 +122,7 @@ namespace { } else if (rt.Method == TResolveTask::Threaded) { na = ThreadedResolve(host, rt.Info.Port); } else { - Y_ASSERT(0); + Y_ASSERT(0); throw yexception() << TStringBuf("invalid resolve method"); } diff --git a/library/cpp/dns/ut/dns_ut.cpp b/library/cpp/dns/ut/dns_ut.cpp index aae05a742c4..edf8c8f431a 100644 --- a/library/cpp/dns/ut/dns_ut.cpp +++ b/library/cpp/dns/ut/dns_ut.cpp @@ -2,14 +2,14 @@ #include <library/cpp/dns/cache.h> #include <util/network/address.h> -Y_UNIT_TEST_SUITE(TestDNS) { +Y_UNIT_TEST_SUITE(TestDNS) { using namespace NDns; - Y_UNIT_TEST(TestMagic) { + Y_UNIT_TEST(TestMagic) { UNIT_ASSERT_EXCEPTION(CachedThrResolve(TResolveInfo("?", 80)), yexception); } - Y_UNIT_TEST(TestAsteriskAlias) { + Y_UNIT_TEST(TestAsteriskAlias) { AddHostAlias("*", "localhost"); const TResolvedHost* rh = CachedThrResolve(TResolveInfo("yandex.ru", 80)); UNIT_ASSERT(rh != nullptr); diff --git a/library/cpp/enumbitset/enumbitset.h b/library/cpp/enumbitset/enumbitset.h index 41864c3a04f..433132358ab 100644 --- a/library/cpp/enumbitset/enumbitset.h +++ b/library/cpp/enumbitset/enumbitset.h @@ -1,11 +1,11 @@ #pragma once -#include <util/ysaveload.h> -#include <util/generic/bitmap.h> +#include <util/ysaveload.h> +#include <util/generic/bitmap.h> #include <util/generic/serialized_enum.h> -#include <util/generic/yexception.h> -#include <util/string/cast.h> -#include <util/string/printf.h> +#include <util/generic/yexception.h> +#include <util/string/cast.h> +#include <util/string/printf.h> #include <util/system/yassert.h> // Stack memory bitmask for TEnum values [begin, end). @@ -134,7 +134,7 @@ public: } bool operator<(const TThis& right) const { - Y_ASSERT(this->GetChunkCount() == right.GetChunkCount()); + Y_ASSERT(this->GetChunkCount() == right.GetChunkCount()); for (size_t i = 0; i < this->GetChunkCount(); ++i) { if (this->GetChunks()[i] < right.GetChunks()[i]) return true; @@ -258,7 +258,7 @@ public: } //serialization to/from stream - void Save(IOutputStream* buffer) const { + void Save(IOutputStream* buffer) const { ::Save(buffer, (ui32)Count()); for (TEnum bit : *this) { ::Save(buffer, (ui32)bit); @@ -363,7 +363,7 @@ public: } TEnum operator*() const noexcept { - Y_ASSERT(Value < EndIndex); + Y_ASSERT(Value < EndIndex); return static_cast<TEnum>(Value); } @@ -372,7 +372,7 @@ public: } TIterator& operator++() noexcept { - Y_ASSERT(Value < EndIndex); + Y_ASSERT(Value < EndIndex); TEnum res; if (BitMap->FindNext(static_cast<TEnum>(Value), res)) { Value = static_cast<int>(res); @@ -399,7 +399,7 @@ public: private: static size_t Pos(TEnum c) { - Y_ASSERT(IsValid(c)); + Y_ASSERT(IsValid(c)); return static_cast<size_t>(int(c) - BeginIndex); } diff --git a/library/cpp/enumbitset/enumbitset_ut.cpp b/library/cpp/enumbitset/enumbitset_ut.cpp index e55b3251c34..2c956033477 100644 --- a/library/cpp/enumbitset/enumbitset_ut.cpp +++ b/library/cpp/enumbitset/enumbitset_ut.cpp @@ -21,8 +21,8 @@ enum ETestEnum { }; using TTestBitSet = TEnumBitSet<ETestEnum, TE_FIRST, TE_MAX>; -Y_UNIT_TEST_SUITE(TEnumBitSetTest) { - Y_UNIT_TEST(TestMainFunctions) { +Y_UNIT_TEST_SUITE(TEnumBitSetTest) { + Y_UNIT_TEST(TestMainFunctions) { auto ebs = TTestBitSet(TE_FIRST, TE_MIDDLE); UNIT_ASSERT(ebs.SafeTest(TE_FIRST)); @@ -36,7 +36,7 @@ Y_UNIT_TEST_SUITE(TEnumBitSetTest) { UNIT_ASSERT(!ebs.SafeTest(TE_OVERFLOW)); } - Y_UNIT_TEST(TestEmpty) { + Y_UNIT_TEST(TestEmpty) { TTestBitSet mask; UNIT_ASSERT(mask.Empty()); if (mask) @@ -49,7 +49,7 @@ Y_UNIT_TEST_SUITE(TEnumBitSetTest) { UNIT_ASSERT(false && "should not be empty"); } - Y_UNIT_TEST(TestIter) { + Y_UNIT_TEST(TestIter) { TTestBitSet mask = TTestBitSet(TE_1, TE_3, TE_7); TTestBitSet mask2; @@ -60,7 +60,7 @@ Y_UNIT_TEST_SUITE(TEnumBitSetTest) { UNIT_ASSERT(mask == mask2); } - Y_UNIT_TEST(TestSerialization) { + Y_UNIT_TEST(TestSerialization) { auto ebs = TTestBitSet(TE_MIDDLE, TE_6, TE_7); TStringStream ss; @@ -71,7 +71,7 @@ Y_UNIT_TEST_SUITE(TEnumBitSetTest) { UNIT_ASSERT_EQUAL(ebs, ebs2); } - Y_UNIT_TEST(TestStringRepresentation) { + Y_UNIT_TEST(TestStringRepresentation) { auto ebs = TTestBitSet(TE_MIDDLE, TE_6, TE_7); UNIT_ASSERT_EQUAL(ebs.ToString(), "D00000000000000000"); diff --git a/library/cpp/execprofile/profile.cpp b/library/cpp/execprofile/profile.cpp index d05de20203f..43559884e44 100644 --- a/library/cpp/execprofile/profile.cpp +++ b/library/cpp/execprofile/profile.cpp @@ -136,7 +136,7 @@ private: } ucontext_t* ucontext = reinterpret_cast<ucontext_t*>(context); - Y_ASSERT(SInstance != nullptr); + Y_ASSERT(SInstance != nullptr); SInstance->CaptureIP(GetIp(&ucontext->uc_mcontext)); } @@ -241,7 +241,7 @@ private: void Clear() { - Y_ASSERT(WriteFlag == 1); + Y_ASSERT(WriteFlag == 1); for (size_t i = 0; i < SZ; ++i) { Ips[i] = std::make_pair((void*)nullptr, (size_t)0); diff --git a/library/cpp/getopt/small/last_getopt_parser.cpp b/library/cpp/getopt/small/last_getopt_parser.cpp index 7668b12a035..aec0f972526 100644 --- a/library/cpp/getopt/small/last_getopt_parser.cpp +++ b/library/cpp/getopt/small/last_getopt_parser.cpp @@ -232,7 +232,7 @@ namespace NLastGetopt { Pos_ = pc; bool r = ParseOptArg(Pos_); - Y_ASSERT(r); + Y_ASSERT(r); while (Pos_ == pc) { Y_ASSERT(Sop_ > 0); r = ParseShortOptWithinArg(Pos_, Sop_); diff --git a/library/cpp/getopt/small/modchooser.cpp b/library/cpp/getopt/small/modchooser.cpp index 2fa5cfd0703..91cc88dc227 100644 --- a/library/cpp/getopt/small/modchooser.cpp +++ b/library/cpp/getopt/small/modchooser.cpp @@ -290,7 +290,7 @@ void TModChooser::PrintHelp(const TString& progName) const { } if (ShowSeparated) { - for (const auto& unsortedMode : UnsortedModes) + for (const auto& unsortedMode : UnsortedModes) if (!unsortedMode->Hidden) { if (unsortedMode->Name.size()) { Cerr << " " << unsortedMode->FormatFullName(maxModeLen + 4) << unsortedMode->Description << Endl; diff --git a/library/cpp/getopt/small/opt.cpp b/library/cpp/getopt/small/opt.cpp index 744501765cb..9cc4b9c6fe0 100644 --- a/library/cpp/getopt/small/opt.cpp +++ b/library/cpp/getopt/small/opt.cpp @@ -88,7 +88,7 @@ int Opt::Get(int* longOptionIndex) { } } -void Opt::DummyHelp(IOutputStream& os) { +void Opt::DummyHelp(IOutputStream& os) { Opts_->PrintUsage(GetProgramName(), os); } diff --git a/library/cpp/getopt/small/opt.h b/library/cpp/getopt/small/opt.h index ecb57439bcf..ad057edb673 100644 --- a/library/cpp/getopt/small/opt.h +++ b/library/cpp/getopt/small/opt.h @@ -106,7 +106,7 @@ public: int GetArgC() const; const char** GetArgV() const; - void DummyHelp(IOutputStream& os = Cerr); + void DummyHelp(IOutputStream& os = Cerr); }; // call before getopt. returns non-negative int, removing it from arguments (not found: -1) diff --git a/library/cpp/getopt/small/opt2.cpp b/library/cpp/getopt/small/opt2.cpp index 0cdc774e788..c3316ffe047 100644 --- a/library/cpp/getopt/small/opt2.cpp +++ b/library/cpp/getopt/small/opt2.cpp @@ -272,16 +272,16 @@ int Opt2::AutoUsage(const char* free_arg_names) { fprintf(where, "Usage: %s%s%s%s%s%s%s%s\n", prog, req ? " -" : "", req_str, nreq ? " [-" : "", nreq_str, nreq ? "]" : "", free_arg_names && *free_arg_names ? " " : "", free_arg_names); - for (auto& spec : Specs) { + for (auto& spec : Specs) { const char* hlp = !spec.HelpUsage.empty() ? spec.HelpUsage.data() : spec.HasArg ? "<arg>" : ""; - if (!spec.HasArg || spec.IsRequired) - fprintf(where, " -%c %s\n", spec.opt, hlp); - else if (!spec.IsNumeric) - fprintf(where, " -%c %s [Default: %s]\n", spec.opt, hlp, spec.DefValue); + if (!spec.HasArg || spec.IsRequired) + fprintf(where, " -%c %s\n", spec.opt, hlp); + else if (!spec.IsNumeric) + fprintf(where, " -%c %s [Default: %s]\n", spec.opt, hlp, spec.DefValue); else - fprintf(where, " -%c %s [Def.val: %li]\n", spec.opt, hlp, (long)(uintptr_t)spec.DefValue); - if (spec.LongOptName) - fprintf(where, " --%s%s - same as -%c\n", spec.LongOptName, spec.HasArg ? "=<argument>" : "", spec.opt); + fprintf(where, " -%c %s [Def.val: %li]\n", spec.opt, hlp, (long)(uintptr_t)spec.DefValue); + if (spec.LongOptName) + fprintf(where, " --%s%s - same as -%c\n", spec.LongOptName, spec.HasArg ? "=<argument>" : "", spec.opt); } if (OptionMissingArg) fprintf(where, " *** Option '%c' is missing required argument\n", OptionMissingArg); @@ -300,7 +300,7 @@ int Opt2::AutoUsage(const char* free_arg_names) { fprintf(where, " *** %i free argument(s) supplied, expected %i to %i\n", (int)Pos.size(), MinArgs, MaxArgs); if (BadPosCount && MinArgs == MaxArgs) fprintf(where, " *** %i free argument(s) supplied, expected %i\n", (int)Pos.size(), MinArgs); - for (const auto& userErrorMessage : UserErrorMessages) + for (const auto& userErrorMessage : UserErrorMessages) fprintf(where, " *** %s\n", userErrorMessage.data()); return UnknownOption == '?' ? 1 : 2; } diff --git a/library/cpp/getopt/ut/last_getopt_ut.cpp b/library/cpp/getopt/ut/last_getopt_ut.cpp index c99a1d053d1..393ef79d8e6 100644 --- a/library/cpp/getopt/ut/last_getopt_ut.cpp +++ b/library/cpp/getopt/ut/last_getopt_ut.cpp @@ -132,8 +132,8 @@ namespace { } } -Y_UNIT_TEST_SUITE(TLastGetoptTests) { - Y_UNIT_TEST(TestEqual) { +Y_UNIT_TEST_SUITE(TLastGetoptTests) { + Y_UNIT_TEST(TestEqual) { TOptsNoDefault opts; opts.AddLongOption("from"); opts.AddLongOption("to"); @@ -149,7 +149,7 @@ Y_UNIT_TEST_SUITE(TLastGetoptTests) { UNIT_ASSERT_EXCEPTION(r.Get("left"), TException); } - Y_UNIT_TEST(TestCharOptions) { + Y_UNIT_TEST(TestCharOptions) { TOptsNoDefault opts; opts.AddCharOption('R', NO_ARGUMENT); opts.AddCharOption('l', NO_ARGUMENT); @@ -165,7 +165,7 @@ Y_UNIT_TEST_SUITE(TLastGetoptTests) { UNIT_ASSERT_VALUES_EQUAL("/tmp/etc", r.GetFreeArgs()[1]); } - Y_UNIT_TEST(TestFreeArgs) { + Y_UNIT_TEST(TestFreeArgs) { TOptsNoDefault opts; opts.SetFreeArgsNum(1, 3); TOptsParseResultTestWrapper r11(&opts, V({"cp", "/etc"})); @@ -184,7 +184,7 @@ Y_UNIT_TEST_SUITE(TLastGetoptTests) { TOptsParseResultTestWrapper r22(&opts, V({"cp", "/etc", "/var/tmp"})); } - Y_UNIT_TEST(TestCharOptionsRequiredOptional) { + Y_UNIT_TEST(TestCharOptionsRequiredOptional) { TOptsNoDefault opts; opts.AddCharOption('d', REQUIRED_ARGUMENT); opts.AddCharOption('e', REQUIRED_ARGUMENT); @@ -198,7 +198,7 @@ Y_UNIT_TEST_SUITE(TLastGetoptTests) { UNIT_ASSERT_VALUES_EQUAL("44", r.Get('y')); } - Y_UNIT_TEST(TestReturnInOrder) { + Y_UNIT_TEST(TestReturnInOrder) { TOptsParserTester tester; tester.Opts_.AddLongOption('v', "value"); tester.Opts_.ArgPermutation_ = RETURN_IN_ORDER; @@ -222,7 +222,7 @@ Y_UNIT_TEST_SUITE(TLastGetoptTests) { tester.AcceptEndOfFreeArgs(); } - Y_UNIT_TEST(TestRequireOrder) { + Y_UNIT_TEST(TestRequireOrder) { TOptsParserTester tester; tester.Opts_.ArgPermutation_ = REQUIRE_ORDER; tester.Opts_.AddLongOption('v', "value"); @@ -242,7 +242,7 @@ Y_UNIT_TEST_SUITE(TLastGetoptTests) { tester.AcceptEndOfFreeArgs(); } - Y_UNIT_TEST(TestPlusForLongOption) { + Y_UNIT_TEST(TestPlusForLongOption) { TOptsParserTester tester; tester.Opts_.AddLongOption('v', "value"); tester.Opts_.AllowPlusForLong_ = true; @@ -261,7 +261,7 @@ Y_UNIT_TEST_SUITE(TLastGetoptTests) { tester.AcceptEndOfFreeArgs(); } - Y_UNIT_TEST(TestBug1) { + Y_UNIT_TEST(TestBug1) { TOptsParserTester tester; tester.Opts_.AddCharOptions("A:b:cd:"); @@ -283,7 +283,7 @@ Y_UNIT_TEST_SUITE(TLastGetoptTests) { tester.AcceptEndOfFreeArgs(); } - Y_UNIT_TEST(TestPermuteComplex) { + Y_UNIT_TEST(TestPermuteComplex) { TOptsParserTester tester; tester.Opts_.AddCharOption('x').NoArgument(); @@ -311,7 +311,7 @@ Y_UNIT_TEST_SUITE(TLastGetoptTests) { tester.AcceptEndOfFreeArgs(); } - Y_UNIT_TEST(TestFinalDashDash) { + Y_UNIT_TEST(TestFinalDashDash) { TOptsParserTester tester; tester.Opts_.AddLongOption("size"); @@ -322,7 +322,7 @@ Y_UNIT_TEST_SUITE(TLastGetoptTests) { tester.AcceptEndOfFreeArgs(); } - Y_UNIT_TEST(TestDashDashAfterDashDash) { + Y_UNIT_TEST(TestDashDashAfterDashDash) { TOptsParserTester tester; tester.Opts_.AddLongOption("size"); @@ -337,7 +337,7 @@ Y_UNIT_TEST_SUITE(TLastGetoptTests) { tester.AcceptEndOfFreeArgs(); } - Y_UNIT_TEST(TestUnexpectedUnknownOption) { + Y_UNIT_TEST(TestUnexpectedUnknownOption) { TOptsParserTester tester; tester.Argv_.push_back("cmd"); @@ -346,7 +346,7 @@ Y_UNIT_TEST_SUITE(TLastGetoptTests) { tester.AcceptUnexpectedOption(); } - Y_UNIT_TEST(TestDuplicatedOptionCrash) { + Y_UNIT_TEST(TestDuplicatedOptionCrash) { // this test is broken, cause UNIT_ASSERT(false) always throws return; @@ -363,7 +363,7 @@ Y_UNIT_TEST_SUITE(TLastGetoptTests) { UNIT_ASSERT(exception); } - Y_UNIT_TEST(TestPositionWhenNoArgs) { + Y_UNIT_TEST(TestPositionWhenNoArgs) { TOptsParserTester tester; tester.Argv_.push_back("cmd"); @@ -375,7 +375,7 @@ Y_UNIT_TEST_SUITE(TLastGetoptTests) { UNIT_ASSERT_VALUES_EQUAL(1u, tester.Parser_->Pos_); } - Y_UNIT_TEST(TestExpectedUnknownCharOption) { + Y_UNIT_TEST(TestExpectedUnknownCharOption) { TOptsParserTester tester; tester.Argv_.push_back("cmd"); @@ -400,7 +400,7 @@ Y_UNIT_TEST_SUITE(TLastGetoptTests) { } #if 0 - Y_UNIT_TEST(TestRequiredParams) { + Y_UNIT_TEST(TestRequiredParams) { TOptsParserTester tester; tester.Argv_.push_back("cmd"); @@ -415,7 +415,7 @@ Y_UNIT_TEST_SUITE(TLastGetoptTests) { } #endif - Y_UNIT_TEST(TestStoreResult) { + Y_UNIT_TEST(TestStoreResult) { TOptsNoDefault opts; TString data; int number; @@ -436,7 +436,7 @@ Y_UNIT_TEST_SUITE(TLastGetoptTests) { UNIT_ASSERT_VALUES_EQUAL(*optionalNumber1, 8); } - Y_UNIT_TEST(TestStoreValue) { + Y_UNIT_TEST(TestStoreValue) { int a = 0, b = 0; size_t c = 0; EHasArg e = NO_ARGUMENT; @@ -454,7 +454,7 @@ Y_UNIT_TEST_SUITE(TLastGetoptTests) { UNIT_ASSERT_VALUES_EQUAL(12345u, c); } - Y_UNIT_TEST(TestSetFlag) { + Y_UNIT_TEST(TestSetFlag) { bool a = false, b = true, c = false, d = true; TOptsNoDefault opts; @@ -471,7 +471,7 @@ Y_UNIT_TEST_SUITE(TLastGetoptTests) { UNIT_ASSERT(!d); } - Y_UNIT_TEST(TestDefaultValue) { + Y_UNIT_TEST(TestDefaultValue) { TOptsNoDefault opts; opts.AddLongOption("path").DefaultValue("/etc"); int value = 42; @@ -481,7 +481,7 @@ Y_UNIT_TEST_SUITE(TLastGetoptTests) { UNIT_ASSERT_VALUES_EQUAL(32, value); } - Y_UNIT_TEST(TestSplitValue) { + Y_UNIT_TEST(TestSplitValue) { TOptsNoDefault opts; TVector<TString> vals; opts.AddLongOption('s', "split").SplitHandler(&vals, ','); @@ -492,7 +492,7 @@ Y_UNIT_TEST_SUITE(TLastGetoptTests) { UNIT_ASSERT_EQUAL(vals[2], "c"); } - Y_UNIT_TEST(TestRangeSplitValue) { + Y_UNIT_TEST(TestRangeSplitValue) { TOptsNoDefault opts; TVector<ui32> vals; opts.AddLongOption('s', "split").RangeSplitHandler(&vals, ',', '-'); @@ -507,7 +507,7 @@ Y_UNIT_TEST_SUITE(TLastGetoptTests) { UNIT_ASSERT_EQUAL(vals[6], 14); } - Y_UNIT_TEST(TestParseArgs) { + Y_UNIT_TEST(TestParseArgs) { TOptsNoDefault o("AbCx:y:z::"); UNIT_ASSERT_EQUAL(o.GetCharOption('A').HasArg_, NO_ARGUMENT); UNIT_ASSERT_EQUAL(o.GetCharOption('b').HasArg_, NO_ARGUMENT); @@ -517,7 +517,7 @@ Y_UNIT_TEST_SUITE(TLastGetoptTests) { UNIT_ASSERT_EQUAL(o.GetCharOption('z').HasArg_, OPTIONAL_ARGUMENT); } - Y_UNIT_TEST(TestRequiredOpts) { + Y_UNIT_TEST(TestRequiredOpts) { TOptsNoDefault opts; TOpt& opt_d = opts.AddCharOption('d'); @@ -547,7 +547,7 @@ Y_UNIT_TEST_SUITE(TLastGetoptTests) { *Flag = true; } }; - Y_UNIT_TEST(TestHandlers) { + Y_UNIT_TEST(TestHandlers) { { TOptsNoDefault opts; bool flag = false; @@ -574,7 +574,7 @@ Y_UNIT_TEST_SUITE(TLastGetoptTests) { } } - Y_UNIT_TEST(TestTitleAndPrintUsage) { + Y_UNIT_TEST(TestTitleAndPrintUsage) { TOpts opts; const char* prog = "my_program"; TString title = TString("Sample ") + TString(prog).Quote() + " application"; @@ -590,7 +590,7 @@ Y_UNIT_TEST_SUITE(TLastGetoptTests) { UNIT_ASSERT(out.Str().find(" " + TString(prog) + " ") != TString::npos); } - Y_UNIT_TEST(TestCustomCmdLineDescr) { + Y_UNIT_TEST(TestCustomCmdLineDescr) { TOpts opts; const char* prog = "my_program"; TString customDescr = "<FILE|TABLE> USER [OPTIONS]"; @@ -604,7 +604,7 @@ Y_UNIT_TEST_SUITE(TLastGetoptTests) { UNIT_ASSERT(out.Str().find(customDescr) != TString::npos); } - Y_UNIT_TEST(TestColorPrint) { + Y_UNIT_TEST(TestColorPrint) { TOpts opts; const char* prog = "my_program"; opts.AddLongOption("long_option").Required(); @@ -658,7 +658,7 @@ Y_UNIT_TEST_SUITE(TLastGetoptTests) { UNIT_ASSERT(out2.Str().find(colors.OldColor()) == TString::npos); } - Y_UNIT_TEST(TestPadding) { + Y_UNIT_TEST(TestPadding) { const bool withColorsOpt[] = {false, true}; for (bool withColors : withColorsOpt) { TOpts opts; @@ -700,7 +700,7 @@ Y_UNIT_TEST_SUITE(TLastGetoptTests) { } } - Y_UNIT_TEST(TestAppendTo) { + Y_UNIT_TEST(TestAppendTo) { TVector<int> ints; TOptsNoDefault opts; @@ -726,7 +726,7 @@ Y_UNIT_TEST_SUITE(TLastGetoptTests) { UNIT_ASSERT_VALUES_EQUAL("//nice", std::get<0>(richPaths.at(1))); } - Y_UNIT_TEST(TestKVHandler) { + Y_UNIT_TEST(TestKVHandler) { TStringBuilder keyvals; TOptsNoDefault opts; @@ -737,7 +737,7 @@ Y_UNIT_TEST_SUITE(TLastGetoptTests) { UNIT_ASSERT_VALUES_EQUAL(keyvals, "x:1,y:2,z:3,"); } - Y_UNIT_TEST(TestEasySetup) { + Y_UNIT_TEST(TestEasySetup) { TEasySetup opts; bool flag = false; opts('v', "version", "print version information")('a', "abstract", "some abstract param", true)('b', "buffer", "SIZE", "some param with argument")('c', "count", "SIZE", "some param with required argument")('t', "true", HandlerStoreTrue(&flag), "Some arg with handler")("global", SimpleHander, "Another arg with handler"); @@ -768,7 +768,7 @@ Y_UNIT_TEST_SUITE(TLastGetoptTests) { } } - Y_UNIT_TEST(TestTOptsParseResultException) { + Y_UNIT_TEST(TestTOptsParseResultException) { // verify that TOptsParseResultException actually throws a TUsageException instead of exit() // not using wrapper here because it can hide bugs (see review #243810 and r2737774) TOptsNoDefault opts; diff --git a/library/cpp/getopt/ut/modchooser_ut.cpp b/library/cpp/getopt/ut/modchooser_ut.cpp index a14c8a58535..430582e3f68 100644 --- a/library/cpp/getopt/ut/modchooser_ut.cpp +++ b/library/cpp/getopt/ut/modchooser_ut.cpp @@ -37,17 +37,17 @@ int Five(int argc, const char** argv) { typedef int (*F_PTR)(int, const char**); static const F_PTR FUNCTIONS[] = {One, Two, Three, Four, Five}; static const char* NAMES[] = {"one", "two", "three", "four", "five"}; -static_assert(Y_ARRAY_SIZE(FUNCTIONS) == Y_ARRAY_SIZE(NAMES), "Incorrect input tests data"); +static_assert(Y_ARRAY_SIZE(FUNCTIONS) == Y_ARRAY_SIZE(NAMES), "Incorrect input tests data"); -Y_UNIT_TEST_SUITE(TModChooserTest) { - Y_UNIT_TEST(TestModesSimpleRunner) { +Y_UNIT_TEST_SUITE(TModChooserTest) { + Y_UNIT_TEST(TestModesSimpleRunner) { TModChooser chooser; - for (size_t idx = 0; idx < Y_ARRAY_SIZE(NAMES); ++idx) { + for (size_t idx = 0; idx < Y_ARRAY_SIZE(NAMES); ++idx) { chooser.AddMode(NAMES[idx], FUNCTIONS[idx], NAMES[idx]); } // test argc, argv - for (size_t idx = 0; idx < Y_ARRAY_SIZE(NAMES); ++idx) { + for (size_t idx = 0; idx < Y_ARRAY_SIZE(NAMES); ++idx) { int argc = 2; const char* argv[] = {"UNITTEST", NAMES[idx], nullptr}; UNIT_ASSERT_EQUAL(static_cast<int>(idx) + 1, chooser.Run(argc, argv)); @@ -60,7 +60,7 @@ Y_UNIT_TEST_SUITE(TModChooserTest) { } } - Y_UNIT_TEST(TestHelpMessage) { + Y_UNIT_TEST(TestHelpMessage) { TModChooser chooser; int argc = 2; diff --git a/library/cpp/getopt/ut/opt2_ut.cpp b/library/cpp/getopt/ut/opt2_ut.cpp index 0e7464747cb..74aa2fe1d60 100644 --- a/library/cpp/getopt/ut/opt2_ut.cpp +++ b/library/cpp/getopt/ut/opt2_ut.cpp @@ -4,8 +4,8 @@ //using namespace NLastGetopt; -Y_UNIT_TEST_SUITE(Opt2Test) { - Y_UNIT_TEST(TestSimple) { +Y_UNIT_TEST_SUITE(Opt2Test) { + Y_UNIT_TEST(TestSimple) { int argc = 8; char* argv[] = { (char*)"cmd", @@ -43,7 +43,7 @@ Y_UNIT_TEST_SUITE(Opt2Test) { UNIT_ASSERT_STRINGS_EQUAL("2", x.at(1)); } - Y_UNIT_TEST(TestErrors1) { + Y_UNIT_TEST(TestErrors1) { int argc = 4; char* argv[] = { (char*)"cmd", diff --git a/library/cpp/getopt/ut/opt_ut.cpp b/library/cpp/getopt/ut/opt_ut.cpp index 441aa493a0a..ad9d36a45fe 100644 --- a/library/cpp/getopt/ut/opt_ut.cpp +++ b/library/cpp/getopt/ut/opt_ut.cpp @@ -3,8 +3,8 @@ #include <library/cpp/testing/unittest/registar.h> #include <util/string/vector.h> -Y_UNIT_TEST_SUITE(OptTest) { - Y_UNIT_TEST(TestSimple) { +Y_UNIT_TEST_SUITE(OptTest) { + Y_UNIT_TEST(TestSimple) { int argc = 3; char* argv[] = { (char*)"cmd", (char*)"-x"}; @@ -16,7 +16,7 @@ Y_UNIT_TEST_SUITE(OptTest) { UNIT_ASSERT_VALUES_EQUAL(EOF, opt.Get()); } - Y_UNIT_TEST(TestFreeArguments) { + Y_UNIT_TEST(TestFreeArguments) { Opt::Ion options[] = { {"some-option", Opt::WithArg, nullptr, 123}, {nullptr, Opt::WithoutArg, nullptr, 0}}; @@ -27,7 +27,7 @@ Y_UNIT_TEST_SUITE(OptTest) { UNIT_ASSERT_VALUES_EQUAL(JoinStrings(opts.GetFreeArgs(), ", "), "ARG1, ARG3"); } - Y_UNIT_TEST(TestLongOption) { + Y_UNIT_TEST(TestLongOption) { const int SOME_OPTION_ID = 12345678; Opt::Ion options[] = { {"some-option", Opt::WithArg, nullptr, SOME_OPTION_ID}, diff --git a/library/cpp/getopt/ut/posix_getopt_ut.cpp b/library/cpp/getopt/ut/posix_getopt_ut.cpp index b6d374bf28b..9689717dab7 100644 --- a/library/cpp/getopt/ut/posix_getopt_ut.cpp +++ b/library/cpp/getopt/ut/posix_getopt_ut.cpp @@ -4,8 +4,8 @@ using namespace NLastGetopt; -Y_UNIT_TEST_SUITE(TPosixGetoptTest) { - Y_UNIT_TEST(TestSimple) { +Y_UNIT_TEST_SUITE(TPosixGetoptTest) { + Y_UNIT_TEST(TestSimple) { int argc = 6; const char* argv0[] = {"program", "-b", "-f1", "-f", "2", "zzzz"}; char** const argv = (char**)argv0; @@ -21,7 +21,7 @@ Y_UNIT_TEST_SUITE(TPosixGetoptTest) { UNIT_ASSERT_VALUES_EQUAL(5, NLastGetopt::optind); } - Y_UNIT_TEST(TestLong) { + Y_UNIT_TEST(TestLong) { int daggerset = 0; /* options descriptor */ const NLastGetopt::option longopts[] = { @@ -49,7 +49,7 @@ Y_UNIT_TEST_SUITE(TPosixGetoptTest) { UNIT_ASSERT_VALUES_EQUAL(6, NLastGetopt::optind); } - Y_UNIT_TEST(TestLongPermutation) { + Y_UNIT_TEST(TestLongPermutation) { int daggerset = 0; /* options descriptor */ const NLastGetopt::option longopts[] = { @@ -70,7 +70,7 @@ Y_UNIT_TEST_SUITE(TPosixGetoptTest) { UNIT_ASSERT_VALUES_EQUAL(3, NLastGetopt::optind); } - Y_UNIT_TEST(TestNoOptionsOptionsWithDoubleDash) { + Y_UNIT_TEST(TestNoOptionsOptionsWithDoubleDash) { const NLastGetopt::option longopts[] = { {"buffy", no_argument, nullptr, 'b'}, {"fluoride", no_argument, nullptr, 'f'}, @@ -84,7 +84,7 @@ Y_UNIT_TEST_SUITE(TPosixGetoptTest) { UNIT_ASSERT_VALUES_EQUAL('?', NLastGetopt::getopt_long(argc, argv, "bf", longopts, nullptr)); } - Y_UNIT_TEST(TestLongOnly) { + Y_UNIT_TEST(TestLongOnly) { const NLastGetopt::option longopts[] = { {"foo", no_argument, nullptr, 'F'}, {"fluoride", no_argument, nullptr, 'f'}, @@ -103,7 +103,7 @@ Y_UNIT_TEST_SUITE(TPosixGetoptTest) { UNIT_ASSERT_VALUES_EQUAL(-1, NLastGetopt::getopt_long_only(argc, argv, "fo", longopts, nullptr)); } - Y_UNIT_TEST(TestLongWithoutOnlySingleDashNowAllowed) { + Y_UNIT_TEST(TestLongWithoutOnlySingleDashNowAllowed) { const NLastGetopt::option longopts[] = { {"foo", no_argument, nullptr, 'F'}, {"zoo", no_argument, nullptr, 'z'}, diff --git a/library/cpp/histogram/adaptive/adaptive_histogram.cpp b/library/cpp/histogram/adaptive/adaptive_histogram.cpp index cbfc494021e..ce204de6fd0 100644 --- a/library/cpp/histogram/adaptive/adaptive_histogram.cpp +++ b/library/cpp/histogram/adaptive/adaptive_histogram.cpp @@ -80,7 +80,7 @@ namespace NKiwiAggr { histo.GetType() == HT_ADAPTIVE_WARD_HISTOGRAM || histo.GetType() == HT_ADAPTIVE_HISTOGRAM) { - Y_VERIFY(histo.FreqSize() == histo.PositionSize(), "Corrupted histo"); + Y_VERIFY(histo.FreqSize() == histo.PositionSize(), "Corrupted histo"); for (size_t j = 0; j < histo.FreqSize(); ++j) { double value = histo.GetPosition(j); double weight = histo.GetFreq(j); @@ -350,7 +350,7 @@ namespace NKiwiAggr { } double TAdaptiveHistogram::CalcUpperBound(double sum) { - Y_VERIFY(sum >= 0, "Sum must be >= 0"); + Y_VERIFY(sum >= 0, "Sum must be >= 0"); if (sum == 0.0) { return MinValue; } @@ -391,7 +391,7 @@ namespace NKiwiAggr { } double TAdaptiveHistogram::CalcLowerBound(double sum) { - Y_VERIFY(sum >= 0, "Sum must be >= 0"); + Y_VERIFY(sum >= 0, "Sum must be >= 0"); if (sum == 0.0) { return MaxValue; } @@ -509,13 +509,13 @@ namespace NKiwiAggr { ++rightBin; TWeightedValue newBin(value, weight + currentBin->second); if (rightBin != Bins.end()) { - Y_VERIFY(BinsByQuality.erase(CalcQuality(*currentBin, *rightBin)) == 1, "Erase failed"); + Y_VERIFY(BinsByQuality.erase(CalcQuality(*currentBin, *rightBin)) == 1, "Erase failed"); BinsByQuality.insert(CalcQuality(newBin, *rightBin)); } if (currentBin != Bins.begin()) { TPairSet::iterator leftBin = currentBin; --leftBin; - Y_VERIFY(BinsByQuality.erase(CalcQuality(*leftBin, *currentBin)) == 1, "Erase failed"); + Y_VERIFY(BinsByQuality.erase(CalcQuality(*leftBin, *currentBin)) == 1, "Erase failed"); BinsByQuality.insert(CalcQuality(*leftBin, newBin)); } Bins.erase(currentBin); @@ -530,7 +530,7 @@ namespace NKiwiAggr { if (rightBin == Bins.end()) { BinsByQuality.insert(CalcQuality(*leftBin, weightedValue)); } else { - Y_VERIFY(BinsByQuality.erase(CalcQuality(*leftBin, *rightBin)) == 1, "Erase failed"); + Y_VERIFY(BinsByQuality.erase(CalcQuality(*leftBin, *rightBin)) == 1, "Erase failed"); BinsByQuality.insert(CalcQuality(*leftBin, weightedValue)); BinsByQuality.insert(CalcQuality(weightedValue, *rightBin)); } @@ -543,20 +543,20 @@ namespace NKiwiAggr { void TAdaptiveHistogram::Erase(double value) { TPairSet::iterator currentBin = Bins.lower_bound(TWeightedValue(value, -1.0)); - Y_VERIFY(currentBin != Bins.end() && currentBin->first == value, "Can't find bin that should be erased"); + Y_VERIFY(currentBin != Bins.end() && currentBin->first == value, "Can't find bin that should be erased"); TPairSet::iterator rightBin = currentBin; ++rightBin; if (currentBin == Bins.begin()) { - Y_VERIFY(rightBin != Bins.end(), "No right bin for the first bin"); - Y_VERIFY(BinsByQuality.erase(CalcQuality(*currentBin, *rightBin)) != 0, "Erase failed"); + Y_VERIFY(rightBin != Bins.end(), "No right bin for the first bin"); + Y_VERIFY(BinsByQuality.erase(CalcQuality(*currentBin, *rightBin)) != 0, "Erase failed"); } else { TPairSet::iterator leftBin = currentBin; --leftBin; if (rightBin == Bins.end()) { - Y_VERIFY(BinsByQuality.erase(CalcQuality(*leftBin, *currentBin)) != 0, "Erase failed"); + Y_VERIFY(BinsByQuality.erase(CalcQuality(*leftBin, *currentBin)) != 0, "Erase failed"); } else { - Y_VERIFY(BinsByQuality.erase(CalcQuality(*leftBin, *currentBin)) != 0, "Erase failed"); - Y_VERIFY(BinsByQuality.erase(CalcQuality(*currentBin, *rightBin)) != 0, "Erase failed"); + Y_VERIFY(BinsByQuality.erase(CalcQuality(*leftBin, *currentBin)) != 0, "Erase failed"); + Y_VERIFY(BinsByQuality.erase(CalcQuality(*currentBin, *rightBin)) != 0, "Erase failed"); BinsByQuality.insert(CalcQuality(*leftBin, *rightBin)); } } @@ -565,12 +565,12 @@ namespace NKiwiAggr { void TAdaptiveHistogram::Shrink() { TPairSet::iterator worstBin = BinsByQuality.begin(); - Y_VERIFY(worstBin != BinsByQuality.end(), "No right bin for the first bin"); + Y_VERIFY(worstBin != BinsByQuality.end(), "No right bin for the first bin"); TPairSet::iterator leftBin = Bins.lower_bound(TWeightedValue(worstBin->second, -1.0)); - Y_VERIFY(leftBin != Bins.end() && leftBin->first == worstBin->second, "Can't find worst bin"); + Y_VERIFY(leftBin != Bins.end() && leftBin->first == worstBin->second, "Can't find worst bin"); TPairSet::iterator rightBin = leftBin; ++rightBin; - Y_VERIFY(rightBin != Bins.end(), "Can't find right bin"); + Y_VERIFY(rightBin != Bins.end(), "Can't find right bin"); TWeightedValue newBin((leftBin->first * leftBin->second + rightBin->first * rightBin->second) / (leftBin->second + rightBin->second), leftBin->second + rightBin->second); if (Bins.size() > 2) { diff --git a/library/cpp/histogram/adaptive/auto_histogram.h b/library/cpp/histogram/adaptive/auto_histogram.h index 9fdf0b9abe4..08e4e3d9d42 100644 --- a/library/cpp/histogram/adaptive/auto_histogram.h +++ b/library/cpp/histogram/adaptive/auto_histogram.h @@ -20,8 +20,8 @@ namespace NKiwiAggr { public: TAutoHistogram(size_t intervals, ui64 id = 0) { - Y_UNUSED(intervals); - Y_UNUSED(id); + Y_UNUSED(intervals); + Y_UNUSED(id); ythrow yexception() << "Empty constructor is not defined for TAutoHistogram"; } @@ -33,9 +33,9 @@ namespace NKiwiAggr { } TAutoHistogram(IHistogram* histo, size_t defaultIntervals = DEFAULT_INTERVALS, ui64 defaultId = 0) { - Y_UNUSED(histo); - Y_UNUSED(defaultIntervals); - Y_UNUSED(defaultId); + Y_UNUSED(histo); + Y_UNUSED(defaultIntervals); + Y_UNUSED(defaultId); ythrow yexception() << "IHistogram constructor is not defined for TAutoHistogram"; } diff --git a/library/cpp/histogram/adaptive/block_histogram.cpp b/library/cpp/histogram/adaptive/block_histogram.cpp index 6586d13ff62..70032559166 100644 --- a/library/cpp/histogram/adaptive/block_histogram.cpp +++ b/library/cpp/histogram/adaptive/block_histogram.cpp @@ -149,7 +149,7 @@ namespace NKiwiAggr { histo.GetType() == HT_ADAPTIVE_WARD_HISTOGRAM || histo.GetType() == HT_ADAPTIVE_HISTOGRAM) { - Y_VERIFY(histo.FreqSize() == histo.PositionSize(), "Corrupted histo"); + Y_VERIFY(histo.FreqSize() == histo.PositionSize(), "Corrupted histo"); for (size_t j = 0; j < histo.FreqSize(); ++j) { double value = histo.GetPosition(j); double weight = histo.GetFreq(j); @@ -189,7 +189,7 @@ namespace NKiwiAggr { } void TBlockHistogram::Merge(TVector<IHistogramPtr> histogramsToMerge) { - Y_UNUSED(histogramsToMerge); + Y_UNUSED(histogramsToMerge); ythrow yexception() << "IHistogram::Merge(TVector<IHistogramPtr>) is not defined for TBlockHistogram"; } @@ -286,7 +286,7 @@ namespace NKiwiAggr { } void TBlockHistogram::SortAndShrink(size_t intervals, bool final) { - Y_VERIFY(intervals > 0); + Y_VERIFY(intervals > 0); if (Bins.size() <= intervals) { return; @@ -382,7 +382,7 @@ namespace NKiwiAggr { ui32 a = (ui32)(bins[b].Prev() - bins); ui32 c = (ui32)(bins[b].Next() - bins); ui32 d = (ui32)(bins[b].Next()->Next() - bins); - Y_VERIFY(Bins[c].second != -1); + Y_VERIFY(Bins[c].second != -1); double mass = Bins[b].second + Bins[c].second; Bins[c].first = (Bins[b].first * Bins[b].second + Bins[c].first * Bins[c].second) / mass; @@ -411,48 +411,48 @@ namespace NKiwiAggr { Bins.resize(pos); PrevSize = pos; - Y_VERIFY(pos == intervals); + Y_VERIFY(pos == intervals); } double TBlockHistogram::GetSumInRange(double leftBound, double rightBound) { - Y_UNUSED(leftBound); - Y_UNUSED(rightBound); + Y_UNUSED(leftBound); + Y_UNUSED(rightBound); ythrow yexception() << "Method is not implemented for TBlockHistogram"; return 0; } double TBlockHistogram::GetSumAboveBound(double bound) { - Y_UNUSED(bound); + Y_UNUSED(bound); ythrow yexception() << "Method is not implemented for TBlockHistogram"; return 0; } double TBlockHistogram::GetSumBelowBound(double bound) { - Y_UNUSED(bound); + Y_UNUSED(bound); ythrow yexception() << "Method is not implemented for TBlockHistogram"; return 0; } double TBlockHistogram::CalcUpperBound(double sum) { - Y_UNUSED(sum); + Y_UNUSED(sum); ythrow yexception() << "Method is not implemented for TBlockHistogram"; return 0; } double TBlockHistogram::CalcLowerBound(double sum) { - Y_UNUSED(sum); + Y_UNUSED(sum); ythrow yexception() << "Method is not implemented for TBlockHistogram"; return 0; } double TBlockHistogram::CalcUpperBoundSafe(double sum) { - Y_UNUSED(sum); + Y_UNUSED(sum); ythrow yexception() << "Method is not implemented for TBlockHistogram"; return 0; } double TBlockHistogram::CalcLowerBoundSafe(double sum) { - Y_UNUSED(sum); + Y_UNUSED(sum); ythrow yexception() << "Method is not implemented for TBlockHistogram"; return 0; } @@ -528,7 +528,7 @@ namespace NKiwiAggr { } void TBlockWardHistogram::FastGreedyShrink(size_t intervals) { - Y_VERIFY(intervals > 0); + Y_VERIFY(intervals > 0); if (Bins.size() <= intervals) { return; diff --git a/library/cpp/histogram/adaptive/fixed_bin_histogram.cpp b/library/cpp/histogram/adaptive/fixed_bin_histogram.cpp index 558aba9e2d1..aa33174f2db 100644 --- a/library/cpp/histogram/adaptive/fixed_bin_histogram.cpp +++ b/library/cpp/histogram/adaptive/fixed_bin_histogram.cpp @@ -512,7 +512,7 @@ namespace NKiwiAggr { } void TFixedBinHistogram::Shrink(double newReferencePoint, double newMaxValue) { - Y_VERIFY(newReferencePoint < newMaxValue, "Invalid Shrink()"); + Y_VERIFY(newReferencePoint < newMaxValue, "Invalid Shrink()"); memset(&(ReserveFreqs[0]), 0, ReserveFreqs.size() * sizeof(double)); double newBinRange = CalcBinRange(newReferencePoint, newMaxValue); diff --git a/library/cpp/histogram/hdr/histogram_iter_ut.cpp b/library/cpp/histogram/hdr/histogram_iter_ut.cpp index 9c291a2547b..2d6ffc68d93 100644 --- a/library/cpp/histogram/hdr/histogram_iter_ut.cpp +++ b/library/cpp/histogram/hdr/histogram_iter_ut.cpp @@ -4,8 +4,8 @@ using namespace NHdr; -Y_UNIT_TEST_SUITE(THistogramIterTest) { - Y_UNIT_TEST(RecordedValues) { +Y_UNIT_TEST_SUITE(THistogramIterTest) { + Y_UNIT_TEST(RecordedValues) { THistogram h(TDuration::Hours(1).MicroSeconds(), 3); UNIT_ASSERT(h.RecordValues(1000, 1000)); UNIT_ASSERT(h.RecordValue(1000 * 1000)); @@ -32,7 +32,7 @@ Y_UNIT_TEST_SUITE(THistogramIterTest) { UNIT_ASSERT_EQUAL(index, 2); } - Y_UNIT_TEST(CorrectedRecordedValues) { + Y_UNIT_TEST(CorrectedRecordedValues) { THistogram h(TDuration::Hours(1).MicroSeconds(), 3); UNIT_ASSERT(h.RecordValuesWithExpectedInterval(1000, 1000, 1000)); UNIT_ASSERT(h.RecordValueWithExpectedInterval(1000 * 1000, 1000)); @@ -59,7 +59,7 @@ Y_UNIT_TEST_SUITE(THistogramIterTest) { UNIT_ASSERT_EQUAL(totalCount, 2000); } - Y_UNIT_TEST(LinearValues) { + Y_UNIT_TEST(LinearValues) { THistogram h(TDuration::Hours(1).MicroSeconds(), 3); UNIT_ASSERT(h.RecordValues(1000, 1000)); UNIT_ASSERT(h.RecordValue(1000 * 1000)); @@ -87,7 +87,7 @@ Y_UNIT_TEST_SUITE(THistogramIterTest) { UNIT_ASSERT_EQUAL(index, 1000); } - Y_UNIT_TEST(CorrectLinearValues) { + Y_UNIT_TEST(CorrectLinearValues) { THistogram h(TDuration::Hours(1).MicroSeconds(), 3); UNIT_ASSERT(h.RecordValuesWithExpectedInterval(1000, 1000, 1000)); UNIT_ASSERT(h.RecordValueWithExpectedInterval(1000 * 1000, 1000)); @@ -116,7 +116,7 @@ Y_UNIT_TEST_SUITE(THistogramIterTest) { UNIT_ASSERT_EQUAL(totalCount, 2000); } - Y_UNIT_TEST(LogarithmicValues) { + Y_UNIT_TEST(LogarithmicValues) { THistogram h(TDuration::Hours(1).MicroSeconds(), 3); UNIT_ASSERT(h.RecordValues(1000, 1000)); UNIT_ASSERT(h.RecordValue(1000 * 1000)); @@ -150,7 +150,7 @@ Y_UNIT_TEST_SUITE(THistogramIterTest) { UNIT_ASSERT_EQUAL(index, 11); } - Y_UNIT_TEST(CorrectedLogarithmicValues) { + Y_UNIT_TEST(CorrectedLogarithmicValues) { THistogram h(TDuration::Hours(1).MicroSeconds(), 3); UNIT_ASSERT(h.RecordValuesWithExpectedInterval(1000, 1000, 1000)); UNIT_ASSERT(h.RecordValueWithExpectedInterval(1000 * 1000, 1000)); @@ -181,7 +181,7 @@ Y_UNIT_TEST_SUITE(THistogramIterTest) { UNIT_ASSERT_EQUAL(totalCount, 2000); } - Y_UNIT_TEST(LinearIterBucketsCorrectly) { + Y_UNIT_TEST(LinearIterBucketsCorrectly) { THistogram h(255, 2); UNIT_ASSERT(h.RecordValue(193)); UNIT_ASSERT(h.RecordValue(255)); diff --git a/library/cpp/histogram/hdr/histogram_ut.cpp b/library/cpp/histogram/hdr/histogram_ut.cpp index 4841b76e71e..8974e60e2b1 100644 --- a/library/cpp/histogram/hdr/histogram_ut.cpp +++ b/library/cpp/histogram/hdr/histogram_ut.cpp @@ -16,14 +16,14 @@ void LoadData(THistogram* h1, THistogram* h2) { UNIT_ASSERT(h2->RecordValueWithExpectedInterval(1000 * 1000, 1000)); } -Y_UNIT_TEST_SUITE(THistogramTest) { - Y_UNIT_TEST(Creation) { +Y_UNIT_TEST_SUITE(THistogramTest) { + Y_UNIT_TEST(Creation) { THistogram h(TDuration::Hours(1).MicroSeconds(), 3); UNIT_ASSERT_EQUAL(h.GetMemorySize(), 188512); UNIT_ASSERT_EQUAL(h.GetCountsLen(), 23552); } - Y_UNIT_TEST(CreateWithLargeValues) { + Y_UNIT_TEST(CreateWithLargeValues) { THistogram h(20L * 1000 * 1000, 100L * 1000 * 1000, 5); UNIT_ASSERT(h.RecordValue(100L * 1000 * 1000)); UNIT_ASSERT(h.RecordValue(20L * 1000 * 1000)); @@ -45,18 +45,18 @@ Y_UNIT_TEST_SUITE(THistogramTest) { UNIT_ASSERT(h.ValuesAreEqual(v99, 100L * 1000 * 1000)); } - Y_UNIT_TEST(InvalidSignificantValueDigits) { + Y_UNIT_TEST(InvalidSignificantValueDigits) { UNIT_ASSERT_EXCEPTION(THistogram(1000, -1), yexception); UNIT_ASSERT_EXCEPTION(THistogram(1000, 0), yexception); UNIT_ASSERT_EXCEPTION(THistogram(1000, 6), yexception); } - Y_UNIT_TEST(InvalidLowestDiscernibleValue) { + Y_UNIT_TEST(InvalidLowestDiscernibleValue) { UNIT_ASSERT_EXCEPTION(THistogram(0, 100, 3), yexception); UNIT_ASSERT_EXCEPTION(THistogram(110, 100, 3), yexception); } - Y_UNIT_TEST(TotalCount) { + Y_UNIT_TEST(TotalCount) { i64 oneHour = SafeIntegerCast<i64>(TDuration::Hours(1).MicroSeconds()); THistogram h1(oneHour, 3); THistogram h2(oneHour, 3); @@ -66,7 +66,7 @@ Y_UNIT_TEST_SUITE(THistogramTest) { UNIT_ASSERT_EQUAL(h2.GetTotalCount(), 2000); } - Y_UNIT_TEST(StatsValues) { + Y_UNIT_TEST(StatsValues) { i64 oneHour = SafeIntegerCast<i64>(TDuration::Hours(1).MicroSeconds()); THistogram h1(oneHour, 3); THistogram h2(oneHour, 3); @@ -97,7 +97,7 @@ Y_UNIT_TEST_SUITE(THistogramTest) { } } - Y_UNIT_TEST(Percentiles) { + Y_UNIT_TEST(Percentiles) { i64 oneHour = SafeIntegerCast<i64>(TDuration::Hours(1).MicroSeconds()); THistogram h1(oneHour, 3); THistogram h2(oneHour, 3); @@ -156,13 +156,13 @@ Y_UNIT_TEST_SUITE(THistogramTest) { } } - Y_UNIT_TEST(OutOfRangeValues) { + Y_UNIT_TEST(OutOfRangeValues) { THistogram h(1000, 4); UNIT_ASSERT(h.RecordValue(32767)); UNIT_ASSERT(!h.RecordValue(32768)); } - Y_UNIT_TEST(Reset) { + Y_UNIT_TEST(Reset) { THistogram h(TDuration::Hours(1).MicroSeconds(), 3); UNIT_ASSERT(h.RecordValues(1000, 1000)); UNIT_ASSERT(h.RecordValue(1000 * 1000)); diff --git a/library/cpp/html/escape/ut/escape_ut.cpp b/library/cpp/html/escape/ut/escape_ut.cpp index cd7b9551385..7a28d7c12b8 100644 --- a/library/cpp/html/escape/ut/escape_ut.cpp +++ b/library/cpp/html/escape/ut/escape_ut.cpp @@ -3,8 +3,8 @@ using namespace NHtml; -Y_UNIT_TEST_SUITE(TEscapeHtml) { - Y_UNIT_TEST(Escape) { +Y_UNIT_TEST_SUITE(TEscapeHtml) { + Y_UNIT_TEST(Escape) { UNIT_ASSERT_EQUAL(EscapeText("in & out"), "in & out"); UNIT_ASSERT_EQUAL(EscapeText("&&"), "&&"); UNIT_ASSERT_EQUAL(EscapeText("&"), "&amp;"); diff --git a/library/cpp/html/pcdata/pcdata.cpp b/library/cpp/html/pcdata/pcdata.cpp index 740c240fd23..7cc0f6da854 100644 --- a/library/cpp/html/pcdata/pcdata.cpp +++ b/library/cpp/html/pcdata/pcdata.cpp @@ -61,7 +61,7 @@ TString EncodeHtmlPcdata(const TStringBuf str, bool qAmp) { TString DecodeHtmlPcdata(const TString& sz) { TString res; - const char* codes[] = {""", "<", ">", "'", "'", "&", "'", nullptr}; + const char* codes[] = {""", "<", ">", "'", "'", "&", "'", nullptr}; const char chars[] = {'\"', '<', '>', '\'', '\'', '&', '\''}; for (size_t i = 0; i < sz.length(); ++i) { char c = sz[i]; diff --git a/library/cpp/html/pcdata/pcdata.h b/library/cpp/html/pcdata/pcdata.h index 7dd741f53dc..786e98ac024 100644 --- a/library/cpp/html/pcdata/pcdata.h +++ b/library/cpp/html/pcdata/pcdata.h @@ -1,6 +1,6 @@ #pragma once -#include <util/generic/fwd.h> +#include <util/generic/fwd.h> /// Converts a text into HTML-code. Special characters of HTML («<», «>», ...) replaced with entities. TString EncodeHtmlPcdata(const TStringBuf str, bool qAmp = true); diff --git a/library/cpp/html/pcdata/pcdata_ut.cpp b/library/cpp/html/pcdata/pcdata_ut.cpp index 5833f8bc590..90088712e2e 100644 --- a/library/cpp/html/pcdata/pcdata_ut.cpp +++ b/library/cpp/html/pcdata/pcdata_ut.cpp @@ -2,8 +2,8 @@ #include <library/cpp/testing/unittest/registar.h> -Y_UNIT_TEST_SUITE(TPcdata) { - Y_UNIT_TEST(TestStress) { +Y_UNIT_TEST_SUITE(TPcdata) { + Y_UNIT_TEST(TestStress) { { ui64 key = 0x000017C0B76C4E87ull; TString res = EncodeHtmlPcdata(TStringBuf((const char*)&key, sizeof(key))); @@ -16,23 +16,23 @@ Y_UNIT_TEST_SUITE(TPcdata) { } } - Y_UNIT_TEST(Test1) { + Y_UNIT_TEST(Test1) { const TString tests[] = { "qw&qw", "&<", ">&qw", "\'&aaa"}; - for (auto s : tests) { + for (auto s : tests) { UNIT_ASSERT_VALUES_EQUAL(DecodeHtmlPcdata(EncodeHtmlPcdata(s)), s); } } - Y_UNIT_TEST(Test2) { + Y_UNIT_TEST(Test2) { UNIT_ASSERT_VALUES_EQUAL(EncodeHtmlPcdata("&qqq"), "&qqq"); } - Y_UNIT_TEST(TestEncodeHtmlPcdataAppend) { + Y_UNIT_TEST(TestEncodeHtmlPcdataAppend) { TString s; EncodeHtmlPcdataAppend("m&m", s); EncodeHtmlPcdataAppend("'s", s); @@ -40,7 +40,7 @@ Y_UNIT_TEST_SUITE(TPcdata) { UNIT_ASSERT_VALUES_EQUAL("m&m's", s); } - Y_UNIT_TEST(TestStrangeAmpParameter) { + Y_UNIT_TEST(TestStrangeAmpParameter) { UNIT_ASSERT_VALUES_EQUAL(EncodeHtmlPcdata("m&m's", true), "m&m's"); UNIT_ASSERT_VALUES_EQUAL(EncodeHtmlPcdata("m&m's"), "m&m's"); //default UNIT_ASSERT_VALUES_EQUAL(EncodeHtmlPcdata("m&m's", false), "m&m's"); diff --git a/library/cpp/http/fetch/http_digest.cpp b/library/cpp/http/fetch/http_digest.cpp index 1eaa02b7f24..480f4b0c515 100644 --- a/library/cpp/http/fetch/http_digest.cpp +++ b/library/cpp/http/fetch/http_digest.cpp @@ -1,8 +1,8 @@ #include "http_digest.h" #include <library/cpp/digest/md5/md5.h> -#include <util/stream/output.h> -#include <util/stream/str.h> +#include <util/stream/output.h> +#include <util/stream/str.h> /************************************************************/ /************************************************************/ diff --git a/library/cpp/http/fetch/httpfsm_ut.cpp b/library/cpp/http/fetch/httpfsm_ut.cpp index b018e80101b..63790456bc6 100644 --- a/library/cpp/http/fetch/httpfsm_ut.cpp +++ b/library/cpp/http/fetch/httpfsm_ut.cpp @@ -488,7 +488,7 @@ void THttpHeaderParserTestSuite::TestRepeatedContentEncoding() { UNIT_TEST_SUITE_REGISTRATION(THttpHeaderParserTestSuite); -Y_UNIT_TEST_SUITE(TestHttpChunkParser) { +Y_UNIT_TEST_SUITE(TestHttpChunkParser) { static THttpChunkParser initParser() { THttpChunkParser parser; parser.Init(); @@ -513,7 +513,7 @@ Y_UNIT_TEST_SUITE(TestHttpChunkParser) { return parseByteByByte(blob, states); } - Y_UNIT_TEST(TestWithoutEolHead) { + Y_UNIT_TEST(TestWithoutEolHead) { const TStringBuf blob{ "4\r\n" "____\r\n"}; @@ -527,7 +527,7 @@ Y_UNIT_TEST_SUITE(TestHttpChunkParser) { parseByteByByte(blob, states); } - Y_UNIT_TEST(TestTrivialChunk) { + Y_UNIT_TEST(TestTrivialChunk) { const TStringBuf blob{ "\r\n" "4\r\n"}; @@ -536,7 +536,7 @@ Y_UNIT_TEST_SUITE(TestHttpChunkParser) { UNIT_ASSERT_EQUAL(parser.cnt64, 4); } - Y_UNIT_TEST(TestNegative) { + Y_UNIT_TEST(TestNegative) { const TStringBuf blob{ "\r\n" "-1"}; @@ -547,7 +547,7 @@ Y_UNIT_TEST_SUITE(TestHttpChunkParser) { parseByteByByte(blob, states); } - Y_UNIT_TEST(TestLeadingZero) { + Y_UNIT_TEST(TestLeadingZero) { const TStringBuf blob{ "\r\n" "042\r\n"}; @@ -555,7 +555,7 @@ Y_UNIT_TEST_SUITE(TestHttpChunkParser) { UNIT_ASSERT_EQUAL(parser.chunk_length, 0x42); } - Y_UNIT_TEST(TestIntOverflow) { + Y_UNIT_TEST(TestIntOverflow) { const TStringBuf blob{ "\r\n" "deadbeef"}; @@ -564,7 +564,7 @@ Y_UNIT_TEST_SUITE(TestHttpChunkParser) { UNIT_ASSERT_EQUAL(parser.cnt64, 0xdeadbeef); } - Y_UNIT_TEST(TestTrivialChunkWithTail) { + Y_UNIT_TEST(TestTrivialChunkWithTail) { const TStringBuf blob{ "\r\n" "4\r\n" @@ -577,7 +577,7 @@ Y_UNIT_TEST_SUITE(TestHttpChunkParser) { parseByteByByte(blob, states); } - Y_UNIT_TEST(TestLastChunk) { + Y_UNIT_TEST(TestLastChunk) { // NB: current parser does not permit whitespace before `foo`, // but I've never seen the feature in real-life traffic const TStringBuf blob{ diff --git a/library/cpp/http/fetch/httpparser.h b/library/cpp/http/fetch/httpparser.h index 769828e4ae6..078eb5f99d1 100644 --- a/library/cpp/http/fetch/httpparser.h +++ b/library/cpp/http/fetch/httpparser.h @@ -207,7 +207,7 @@ protected: size -= long(ChunkParser.lastchar - (char*)buf + 1); buf = ChunkParser.lastchar + 1; ChunkSize = ChunkParser.chunk_length; - Y_ASSERT(ChunkSize >= 0); + Y_ASSERT(ChunkSize >= 0); State = ChunkSize ? hp_read_chunk : hp_eof; } else { Header->entity_size += size; @@ -264,7 +264,7 @@ public: return 0; } long Read(void*& buf) { - Y_ASSERT(Bufsize >= 0); + Y_ASSERT(Bufsize >= 0); if (!Bufsize) { Bufsize = -1; return 0; diff --git a/library/cpp/http/fetch/httpparser_ut.cpp b/library/cpp/http/fetch/httpparser_ut.cpp index 3b3b938e7ab..e63964c5f5c 100644 --- a/library/cpp/http/fetch/httpparser_ut.cpp +++ b/library/cpp/http/fetch/httpparser_ut.cpp @@ -9,7 +9,7 @@ } template <> -void Out<THttpParserBase::States>(IOutputStream& out, THttpParserBase::States st) { +void Out<THttpParserBase::States>(IOutputStream& out, THttpParserBase::States st) { using type = THttpParserBase::States; switch (st) { ENUM_OUT(hp_error) @@ -46,8 +46,8 @@ namespace { } -Y_UNIT_TEST_SUITE(TestHttpParser) { - Y_UNIT_TEST(TestTrivialRequest) { +Y_UNIT_TEST_SUITE(TestHttpParser) { + Y_UNIT_TEST(TestTrivialRequest) { const TString blob{ "GET /search?q=hi HTTP/1.1\r\n" "Host: www.google.ru:8080 \r\n" @@ -60,7 +60,7 @@ Y_UNIT_TEST_SUITE(TestHttpParser) { } // XXX: `entity_size` is i32 and `content_length` is i64! - Y_UNIT_TEST(TestTrivialResponse) { + Y_UNIT_TEST(TestTrivialResponse) { const TString blob{ "HTTP/1.1 200 Ok\r\n" "Content-Length: 2\r\n" @@ -80,7 +80,7 @@ Y_UNIT_TEST_SUITE(TestHttpParser) { } // XXX: `entity_size` is off by one in TE:chunked case. - Y_UNIT_TEST(TestChunkedResponse) { + Y_UNIT_TEST(TestChunkedResponse) { const TString blob{ "HTTP/1.1 200 OK\r\n" "Transfer-Encoding: chunked\r\n" @@ -130,7 +130,7 @@ Y_UNIT_TEST_SUITE(TestHttpParser) { "\r\n")); } - Y_UNIT_TEST(TestPipelineClenByteByByte) { + Y_UNIT_TEST(TestPipelineClenByteByByte) { const TString& blob = PipelineClenBlob_; THttpHeader hdr; TTestHttpParser parser; @@ -146,7 +146,7 @@ Y_UNIT_TEST_SUITE(TestHttpParser) { } // XXX: Content-Length is ignored, Body() looks unexpected! - Y_UNIT_TEST(TestPipelineClenOneChunk) { + Y_UNIT_TEST(TestPipelineClenOneChunk) { const TString& blob = PipelineClenBlob_; THttpHeader hdr; TTestHttpParser parser; @@ -205,7 +205,7 @@ Y_UNIT_TEST_SUITE(TestHttpParser) { "\r\n")); } - Y_UNIT_TEST(TestPipelineChunkedByteByByte) { + Y_UNIT_TEST(TestPipelineChunkedByteByByte) { const TString& blob = PipelineChunkedBlob_; THttpHeader hdr; TTestHttpParser parser; @@ -220,7 +220,7 @@ Y_UNIT_TEST_SUITE(TestHttpParser) { AssertPipelineChunked(parser, hdr); } - Y_UNIT_TEST(TestPipelineChunkedOneChunk) { + Y_UNIT_TEST(TestPipelineChunkedOneChunk) { const TString& blob = PipelineChunkedBlob_; THttpHeader hdr; TTestHttpParser parser; diff --git a/library/cpp/http/fetch/httpzreader.h b/library/cpp/http/fetch/httpzreader.h index 68eb00853d6..fe106dabf75 100644 --- a/library/cpp/http/fetch/httpzreader.h +++ b/library/cpp/http/fetch/httpzreader.h @@ -107,7 +107,7 @@ public: int err = inflate(&Stream, Z_SYNC_FLUSH); - //Y_ASSERT(Stream.avail_in == 0); + //Y_ASSERT(Stream.avail_in == 0); switch (err) { case Z_OK: diff --git a/library/cpp/http/io/chunk.cpp b/library/cpp/http/io/chunk.cpp index 6975d9eac1e..b43ca235f5d 100644 --- a/library/cpp/http/io/chunk.cpp +++ b/library/cpp/http/io/chunk.cpp @@ -50,7 +50,7 @@ static inline char* ToHex(size_t len, char* buf) { class TChunkedInput::TImpl { public: - inline TImpl(IInputStream* slave, TMaybe<THttpHeaders>* trailers) + inline TImpl(IInputStream* slave, TMaybe<THttpHeaders>* trailers) : Slave_(slave) , Trailers_(trailers) , Pending_(0) @@ -136,13 +136,13 @@ private: } private: - IInputStream* Slave_; + IInputStream* Slave_; TMaybe<THttpHeaders>* Trailers_; size_t Pending_; bool LastChunkReaded_; }; -TChunkedInput::TChunkedInput(IInputStream* slave, TMaybe<THttpHeaders>* trailers) +TChunkedInput::TChunkedInput(IInputStream* slave, TMaybe<THttpHeaders>* trailers) : Impl_(new TImpl(slave, trailers)) { } @@ -159,10 +159,10 @@ size_t TChunkedInput::DoSkip(size_t len) { } class TChunkedOutput::TImpl { - typedef IOutputStream::TPart TPart; + typedef IOutputStream::TPart TPart; public: - inline TImpl(IOutputStream* slave) + inline TImpl(IOutputStream* slave) : Slave_(slave) { } @@ -209,10 +209,10 @@ public: } private: - IOutputStream* Slave_; + IOutputStream* Slave_; }; -TChunkedOutput::TChunkedOutput(IOutputStream* slave) +TChunkedOutput::TChunkedOutput(IOutputStream* slave) : Impl_(new TImpl(slave)) { } diff --git a/library/cpp/http/io/chunk.h b/library/cpp/http/io/chunk.h index 88d89fafda2..340515b2f7b 100644 --- a/library/cpp/http/io/chunk.h +++ b/library/cpp/http/io/chunk.h @@ -1,6 +1,6 @@ #pragma once -#include <util/stream/output.h> +#include <util/stream/output.h> #include <util/generic/maybe.h> #include <util/generic/ptr.h> @@ -11,11 +11,11 @@ class THttpHeaders; /// Ввод данных порциями. /// @details Последовательное чтение блоков данных. Предполагается, что /// данные записаны в виде <длина блока><блок данных>. -class TChunkedInput: public IInputStream { +class TChunkedInput: public IInputStream { public: /// Если передан указатель на trailers, то туда будут записаны HTTP trailer'ы (возможно пустые), /// которые идут после чанков. - TChunkedInput(IInputStream* slave, TMaybe<THttpHeaders>* trailers = nullptr); + TChunkedInput(IInputStream* slave, TMaybe<THttpHeaders>* trailers = nullptr); ~TChunkedInput() override; private: @@ -30,9 +30,9 @@ private: /// Вывод данных порциями. /// @details Вывод данных блоками в виде <длина блока><блок данных>. Если объем /// данных превышает 64K, они записываются в виде n блоков по 64K + то, что осталось. -class TChunkedOutput: public IOutputStream { +class TChunkedOutput: public IOutputStream { public: - TChunkedOutput(IOutputStream* slave); + TChunkedOutput(IOutputStream* slave); ~TChunkedOutput() override; private: diff --git a/library/cpp/http/io/chunk_ut.cpp b/library/cpp/http/io/chunk_ut.cpp index da283f85680..44b2b9a66aa 100644 --- a/library/cpp/http/io/chunk_ut.cpp +++ b/library/cpp/http/io/chunk_ut.cpp @@ -4,11 +4,11 @@ #include <util/stream/file.h> #include <util/system/tempfile.h> -#include <util/stream/null.h> +#include <util/stream/null.h> #define CDATA "./chunkedio" -Y_UNIT_TEST_SUITE(TestChunkedIO) { +Y_UNIT_TEST_SUITE(TestChunkedIO) { static const char test_data[] = "87s6cfbsudg cuisg s igasidftasiy tfrcua6s"; TString CombString(const TString& s, size_t chunkSize) { @@ -18,7 +18,7 @@ Y_UNIT_TEST_SUITE(TestChunkedIO) { return result; } - void WriteTestData(IOutputStream * stream, TString * contents) { + void WriteTestData(IOutputStream * stream, TString * contents) { contents->clear(); for (size_t i = 0; i < sizeof(test_data); ++i) { stream->Write(test_data, i); @@ -26,7 +26,7 @@ Y_UNIT_TEST_SUITE(TestChunkedIO) { } } - void ReadInSmallChunks(IInputStream * stream, TString * contents) { + void ReadInSmallChunks(IInputStream * stream, TString * contents) { char buf[11]; size_t read = 0; @@ -37,8 +37,8 @@ Y_UNIT_TEST_SUITE(TestChunkedIO) { } while (read > 0); } - void ReadCombed(IInputStream * stream, TString * contents, size_t chunkSize) { - Y_ASSERT(chunkSize < 128); + void ReadCombed(IInputStream * stream, TString * contents, size_t chunkSize) { + Y_ASSERT(chunkSize < 128); char buf[128]; contents->clear(); @@ -57,7 +57,7 @@ Y_UNIT_TEST_SUITE(TestChunkedIO) { } } - Y_UNIT_TEST(TestChunkedIo) { + Y_UNIT_TEST(TestChunkedIo) { TTempFile tmpFile(CDATA); TString tmp; @@ -88,7 +88,7 @@ Y_UNIT_TEST_SUITE(TestChunkedIO) { } } - Y_UNIT_TEST(TestBadChunk) { + Y_UNIT_TEST(TestBadChunk) { bool hasError = false; try { diff --git a/library/cpp/http/io/headers.cpp b/library/cpp/http/io/headers.cpp index 4ec27a29e83..6358d23f01a 100644 --- a/library/cpp/http/io/headers.cpp +++ b/library/cpp/http/io/headers.cpp @@ -1,10 +1,10 @@ #include "headers.h" #include "stream.h" -#include <util/generic/strbuf.h> +#include <util/generic/strbuf.h> #include <util/generic/yexception.h> -#include <util/stream/output.h> -#include <util/string/ascii.h> +#include <util/stream/output.h> +#include <util/string/ascii.h> #include <util/string/cast.h> #include <util/string/strip.h> @@ -12,25 +12,25 @@ static inline TStringBuf Trim(const char* b, const char* e) noexcept { return StripString(TStringBuf(b, e)); } -THttpInputHeader::THttpInputHeader(const TStringBuf header) { +THttpInputHeader::THttpInputHeader(const TStringBuf header) { size_t pos = header.find(':'); if (pos == TString::npos) { ythrow THttpParseException() << "can not parse http header(" << TString{header}.Quote() << ")"; } - Name_ = TString(header.cbegin(), header.cbegin() + pos); - Value_ = ::ToString(Trim(header.cbegin() + pos + 1, header.cend())); + Name_ = TString(header.cbegin(), header.cbegin() + pos); + Value_ = ::ToString(Trim(header.cbegin() + pos + 1, header.cend())); } -THttpInputHeader::THttpInputHeader(TString name, TString value) - : Name_(std::move(name)) - , Value_(std::move(value)) +THttpInputHeader::THttpInputHeader(TString name, TString value) + : Name_(std::move(name)) + , Value_(std::move(value)) { } -void THttpInputHeader::OutTo(IOutputStream* stream) const { - typedef IOutputStream::TPart TPart; +void THttpInputHeader::OutTo(IOutputStream* stream) const { + typedef IOutputStream::TPart TPart; const TPart parts[] = { TPart(Name_), @@ -42,7 +42,7 @@ void THttpInputHeader::OutTo(IOutputStream* stream) const { stream->Write(parts, sizeof(parts) / sizeof(*parts)); } -THttpHeaders::THttpHeaders(IInputStream* stream) { +THttpHeaders::THttpHeaders(IInputStream* stream) { TString header; TString line; @@ -53,28 +53,28 @@ THttpHeaders::THttpHeaders(IInputStream* stream) { if (rdOk && ((line[0] == ' ') || (line[0] == '\t'))) { header += line; } else { - AddHeader(THttpInputHeader(header)); + AddHeader(THttpInputHeader(header)); header = line; } } } -bool THttpHeaders::HasHeader(const TStringBuf header) const { +bool THttpHeaders::HasHeader(const TStringBuf header) const { return FindHeader(header); } -const THttpInputHeader* THttpHeaders::FindHeader(const TStringBuf header) const { +const THttpInputHeader* THttpHeaders::FindHeader(const TStringBuf header) const { for (const auto& hdr : Headers_) { - if (AsciiCompareIgnoreCase(hdr.Name(), header) == 0) { + if (AsciiCompareIgnoreCase(hdr.Name(), header) == 0) { return &hdr; } } return nullptr; } -void THttpHeaders::RemoveHeader(const TStringBuf header) { - for (auto h = Headers_.begin(); h != Headers_.end(); ++h) { - if (AsciiCompareIgnoreCase(h->Name(), header) == 0) { +void THttpHeaders::RemoveHeader(const TStringBuf header) { + for (auto h = Headers_.begin(); h != Headers_.end(); ++h) { + if (AsciiCompareIgnoreCase(h->Name(), header) == 0) { Headers_.erase(h); return; } @@ -82,9 +82,9 @@ void THttpHeaders::RemoveHeader(const TStringBuf header) { } void THttpHeaders::AddOrReplaceHeader(const THttpInputHeader& header) { - for (auto& hdr : Headers_) { - if (AsciiCompareIgnoreCase(hdr.Name(), header.Name()) == 0) { - hdr = header; + for (auto& hdr : Headers_) { + if (AsciiCompareIgnoreCase(hdr.Name(), header.Name()) == 0) { + hdr = header; return; } } @@ -92,17 +92,17 @@ void THttpHeaders::AddOrReplaceHeader(const THttpInputHeader& header) { AddHeader(header); } -void THttpHeaders::AddHeader(THttpInputHeader header) { - Headers_.push_back(std::move(header)); +void THttpHeaders::AddHeader(THttpInputHeader header) { + Headers_.push_back(std::move(header)); } -void THttpHeaders::OutTo(IOutputStream* stream) const { +void THttpHeaders::OutTo(IOutputStream* stream) const { for (TConstIterator header = Begin(); header != End(); ++header) { header->OutTo(stream); } } template <> -void Out<THttpHeaders>(IOutputStream& out, const THttpHeaders& h) { +void Out<THttpHeaders>(IOutputStream& out, const THttpHeaders& h) { h.OutTo(&out); } diff --git a/library/cpp/http/io/headers.h b/library/cpp/http/io/headers.h index a71793d1c68..43c6818cd63 100644 --- a/library/cpp/http/io/headers.h +++ b/library/cpp/http/io/headers.h @@ -6,8 +6,8 @@ #include <util/generic/vector.h> #include <util/string/cast.h> -class IInputStream; -class IOutputStream; +class IInputStream; +class IOutputStream; /// @addtogroup Streams_HTTP /// @{ @@ -15,10 +15,10 @@ class IOutputStream; class THttpInputHeader { public: /// @param[in] header - строка вида 'параметр: значение'. - THttpInputHeader(TStringBuf header); + THttpInputHeader(TStringBuf header); /// @param[in] name - имя параметра. /// @param[in] value - значение параметра. - THttpInputHeader(TString name, TString value); + THttpInputHeader(TString name, TString value); /// Возвращает имя параметра. inline const TString& Name() const noexcept { @@ -31,7 +31,7 @@ public: } /// Записывает заголовок вида "имя параметра: значение\r\n" в поток. - void OutTo(IOutputStream* stream) const; + void OutTo(IOutputStream* stream) const; /// Возвращает строку "имя параметра: значение". inline TString ToString() const { @@ -45,15 +45,15 @@ private: /// Контейнер для хранения HTTP-заголовков class THttpHeaders { - using THeaders = TDeque<THttpInputHeader>; + using THeaders = TDeque<THttpInputHeader>; public: - using TConstIterator = THeaders::const_iterator; - - THttpHeaders() = default; + using TConstIterator = THeaders::const_iterator; + THttpHeaders() = default; + /// Добавляет каждую строку из потока в контейнер, считая ее правильным заголовком. - THttpHeaders(IInputStream* stream); + THttpHeaders(IInputStream* stream); /// Стандартный итератор. inline TConstIterator Begin() const noexcept { @@ -82,11 +82,11 @@ public: } /// Добавляет заголовок в контейнер. - void AddHeader(THttpInputHeader header); + void AddHeader(THttpInputHeader header); template <typename ValueType> - void AddHeader(TString name, const ValueType& value) { - AddHeader(THttpInputHeader(std::move(name), ToString(value))); + void AddHeader(TString name, const ValueType& value) { + AddHeader(THttpInputHeader(std::move(name), ToString(value))); } /// Добавляет заголовок в контейнер, если тот не содержит заголовка @@ -100,18 +100,18 @@ public: } // Проверяет, есть ли такой заголовок - bool HasHeader(TStringBuf header) const; + bool HasHeader(TStringBuf header) const; /// Удаляет заголовок, если он есть. - void RemoveHeader(TStringBuf header); + void RemoveHeader(TStringBuf header); /// Ищет заголовок по указанному имени /// Возвращает nullptr, если не нашел - const THttpInputHeader* FindHeader(TStringBuf header) const; + const THttpInputHeader* FindHeader(TStringBuf header) const; /// Записывает все заголовки контейнера в поток. /// @details Каждый заголовк записывается в виде "имя параметра: значение\r\n". - void OutTo(IOutputStream* stream) const; + void OutTo(IOutputStream* stream) const; /// Обменивает наборы заголовков двух контейнеров. void Swap(THttpHeaders& headers) noexcept { diff --git a/library/cpp/http/io/stream.cpp b/library/cpp/http/io/stream.cpp index 6689be684fc..317ce6a215b 100644 --- a/library/cpp/http/io/stream.cpp +++ b/library/cpp/http/io/stream.cpp @@ -6,7 +6,7 @@ #include <util/stream/buffered.h> #include <util/stream/length.h> #include <util/stream/multi.h> -#include <util/stream/null.h> +#include <util/stream/null.h> #include <util/stream/tee.h> #include <util/system/compat.h> @@ -15,7 +15,7 @@ #include <util/network/socket.h> #include <util/string/cast.h> -#include <util/string/strip.h> +#include <util/string/strip.h> #include <util/generic/string.h> #include <util/generic/utility.h> @@ -134,7 +134,7 @@ class THttpInput::TImpl { typedef THashSet<TString> TAcceptCodings; public: - inline TImpl(IInputStream* slave) + inline TImpl(IInputStream* slave) : Slave_(slave) , Buffered_(Slave_, SuggestBufferSize()) , ChunkedInput_(nullptr) @@ -148,7 +148,7 @@ public: , Expect100Continue_(false) { BuildInputChain(); - Y_ASSERT(Input_); + Y_ASSERT(Input_); } static TString ReadFirstLine(TBufferedInput& in) { @@ -361,19 +361,19 @@ private: } private: - IInputStream* Slave_; + IInputStream* Slave_; /* * input helpers */ TBufferedInput Buffered_; - TStreams<IInputStream, 8> Streams_; - IInputStream* ChunkedInput_; + TStreams<IInputStream, 8> Streams_; + IInputStream* ChunkedInput_; /* * final input stream */ - IInputStream* Input_; + IInputStream* Input_; TString FirstLine_; THttpHeaders Headers_; @@ -389,7 +389,7 @@ private: bool Expect100Continue_; }; -THttpInput::THttpInput(IInputStream* slave) +THttpInput::THttpInput(IInputStream* slave) : Impl_(new TImpl(slave)) { } @@ -457,7 +457,7 @@ bool THttpInput::HasExpect100Continue() const noexcept { } class THttpOutput::TImpl { - class TSizeCalculator: public IOutputStream { + class TSizeCalculator: public IOutputStream { public: inline TSizeCalculator() noexcept { } @@ -484,19 +484,19 @@ class THttpOutput::TImpl { }; struct TFlush { - inline void operator()(IOutputStream* s) { + inline void operator()(IOutputStream* s) { s->Flush(); } }; struct TFinish { - inline void operator()(IOutputStream* s) { + inline void operator()(IOutputStream* s) { s->Finish(); } }; public: - inline TImpl(IOutputStream* slave, THttpInput* request) + inline TImpl(IOutputStream* slave, THttpInput* request) : Slave_(slave) , State_(Begin) , Output_(Slave_) @@ -710,7 +710,7 @@ private: } inline void Process(const TString& s) { - Y_ASSERT(State_ != HeadersSent); + Y_ASSERT(State_ != HeadersSent); if (State_ == Begin) { FirstLine_ = s; @@ -722,12 +722,12 @@ private: WriteCached(); State_ = HeadersSent; } else { - AddHeader(THttpInputHeader(s)); + AddHeader(THttpInputHeader(s)); } } } - inline void WriteCachedImpl(IOutputStream* s) const { + inline void WriteCachedImpl(IOutputStream* s) const { s->Write(FirstLine_.data(), FirstLine_.size()); s->Write("\r\n", 2); Headers_.OutTo(s); @@ -855,10 +855,10 @@ private: } private: - IOutputStream* Slave_; + IOutputStream* Slave_; TState State_; - IOutputStream* Output_; - TStreams<IOutputStream, 8> Streams_; + IOutputStream* Output_; + TStreams<IOutputStream, 8> Streams_; TString Line_; TString FirstLine_; THttpHeaders Headers_; @@ -876,12 +876,12 @@ private: TSizeCalculator SizeCalculator_; }; -THttpOutput::THttpOutput(IOutputStream* slave) +THttpOutput::THttpOutput(IOutputStream* slave) : Impl_(new TImpl(slave, nullptr)) { } -THttpOutput::THttpOutput(IOutputStream* slave, THttpInput* request) +THttpOutput::THttpOutput(IOutputStream* slave, THttpInput* request) : Impl_(new TImpl(slave, request)) { } @@ -979,21 +979,21 @@ void SendMinimalHttpRequest(TSocket& s, const TStringBuf& host, const TStringBuf output.EnableKeepAlive(false); output.EnableCompression(false); - const IOutputStream::TPart parts[] = { + const IOutputStream::TPart parts[] = { IOutputStream::TPart(TStringBuf("GET ")), - IOutputStream::TPart(request), + IOutputStream::TPart(request), IOutputStream::TPart(TStringBuf(" HTTP/1.1")), - IOutputStream::TPart::CrLf(), + IOutputStream::TPart::CrLf(), IOutputStream::TPart(TStringBuf("Host: ")), - IOutputStream::TPart(host), - IOutputStream::TPart::CrLf(), + IOutputStream::TPart(host), + IOutputStream::TPart::CrLf(), IOutputStream::TPart(TStringBuf("User-Agent: ")), - IOutputStream::TPart(agent), - IOutputStream::TPart::CrLf(), + IOutputStream::TPart(agent), + IOutputStream::TPart::CrLf(), IOutputStream::TPart(TStringBuf("From: ")), - IOutputStream::TPart(from), - IOutputStream::TPart::CrLf(), - IOutputStream::TPart::CrLf(), + IOutputStream::TPart(from), + IOutputStream::TPart::CrLf(), + IOutputStream::TPart::CrLf(), }; output.Write(parts, sizeof(parts) / sizeof(*parts)); diff --git a/library/cpp/http/io/stream.h b/library/cpp/http/io/stream.h index 78ca4fc814c..10030422813 100644 --- a/library/cpp/http/io/stream.h +++ b/library/cpp/http/io/stream.h @@ -2,7 +2,7 @@ #include "headers.h" -#include <util/stream/output.h> +#include <util/stream/output.h> #include <util/generic/maybe.h> #include <util/generic/ptr.h> #include <util/generic/string.h> @@ -22,9 +22,9 @@ struct THttpReadException: public THttpException { }; /// Чтение ответа HTTP-сервера. -class THttpInput: public IInputStream { +class THttpInput: public IInputStream { public: - THttpInput(IInputStream* slave); + THttpInput(IInputStream* slave); THttpInput(THttpInput&& httpInput); ~THttpInput() override; @@ -96,10 +96,10 @@ private: }; /// Передача запроса HTTP-серверу. -class THttpOutput: public IOutputStream { +class THttpOutput: public IOutputStream { public: - THttpOutput(IOutputStream* slave); - THttpOutput(IOutputStream* slave, THttpInput* request); + THttpOutput(IOutputStream* slave); + THttpOutput(IOutputStream* slave, THttpInput* request); ~THttpOutput() override; /* diff --git a/library/cpp/http/io/stream_ut.cpp b/library/cpp/http/io/stream_ut.cpp index 1ea35df675a..9578b4e7e0a 100644 --- a/library/cpp/http/io/stream_ut.cpp +++ b/library/cpp/http/io/stream_ut.cpp @@ -8,11 +8,11 @@ #include <util/string/printf.h> #include <util/network/socket.h> -#include <util/stream/file.h> -#include <util/stream/output.h> -#include <util/stream/tee.h> +#include <util/stream/file.h> +#include <util/stream/output.h> +#include <util/stream/tee.h> #include <util/stream/zlib.h> -#include <util/stream/null.h> +#include <util/stream/null.h> Y_UNIT_TEST_SUITE(THttpStreamTest) { class TTestHttpServer: public THttpServer::ICallBack { @@ -78,11 +78,11 @@ Y_UNIT_TEST_SUITE(THttpStreamTest) { size_t LastRequestSentSize_ = 0; }; - Y_UNIT_TEST(TestCodings1) { + Y_UNIT_TEST(TestCodings1) { UNIT_ASSERT(SupportedCodings().size() > 0); } - Y_UNIT_TEST(TestHttpInput) { + Y_UNIT_TEST(TestHttpInput) { TString res = "I'm a teapot"; TPortManager pm; const ui16 port = pm.GetPort(); @@ -128,7 +128,7 @@ Y_UNIT_TEST_SUITE(THttpStreamTest) { server.Stop(); } - Y_UNIT_TEST(TestHttpInputDelete) { + Y_UNIT_TEST(TestHttpInputDelete) { TString res = "I'm a teapot"; TPortManager pm; const ui16 port = pm.GetPort(); @@ -174,11 +174,11 @@ Y_UNIT_TEST_SUITE(THttpStreamTest) { server.Stop(); } - Y_UNIT_TEST(TestParseHttpRetCode) { + Y_UNIT_TEST(TestParseHttpRetCode) { UNIT_ASSERT_VALUES_EQUAL(ParseHttpRetCode("HTTP/1.1 301"), 301u); } - Y_UNIT_TEST(TestKeepAlive) { + Y_UNIT_TEST(TestKeepAlive) { { TString s = "GET / HTTP/1.0\r\n\r\n"; TStringInput si(s); @@ -236,7 +236,7 @@ Y_UNIT_TEST_SUITE(THttpStreamTest) { } } - Y_UNIT_TEST(TestMinRequest) { + Y_UNIT_TEST(TestMinRequest) { TString res = "qqqqqq"; TPortManager pm; const ui16 port = pm.GetPort(); @@ -262,7 +262,7 @@ Y_UNIT_TEST_SUITE(THttpStreamTest) { server.Stop(); } - Y_UNIT_TEST(TestResponseWithBlanks) { + Y_UNIT_TEST(TestResponseWithBlanks) { TString res = "qqqqqq\r\n\r\nsdasdsad\r\n"; TPortManager pm; const ui16 port = pm.GetPort(); @@ -287,7 +287,7 @@ Y_UNIT_TEST_SUITE(THttpStreamTest) { server.Stop(); } - Y_UNIT_TEST(TestOutputFlush) { + Y_UNIT_TEST(TestOutputFlush) { TString str; TStringOutput strOut(str); TBufferedOutput bufOut(&strOut, 8192); @@ -307,7 +307,7 @@ Y_UNIT_TEST_SUITE(THttpStreamTest) { UNIT_ASSERT_VALUES_EQUAL(curLen + strlen(body), str.size()); } - Y_UNIT_TEST(TestOutputPostFlush) { + Y_UNIT_TEST(TestOutputPostFlush) { TString str; TString checkStr; TStringOutput strOut(str); @@ -372,7 +372,7 @@ Y_UNIT_TEST_SUITE(THttpStreamTest) { UNIT_ASSERT(MakeHttpOutputBody(body, true) == SimulateBodyEncoding(body)); } - Y_UNIT_TEST(TestOutputFinish) { + Y_UNIT_TEST(TestOutputFinish) { TString str; TStringOutput strOut(str); TBufferedOutput bufOut(&strOut, 8192); @@ -392,7 +392,7 @@ Y_UNIT_TEST_SUITE(THttpStreamTest) { UNIT_ASSERT_VALUES_EQUAL(curLen + strlen(body), str.size()); } - Y_UNIT_TEST(TestMultilineHeaders) { + Y_UNIT_TEST(TestMultilineHeaders) { const char* headerLine0 = "HTTP/1.1 200 OK"; const char* headerLine1 = "Content-Language: en"; const char* headerLine2 = "Vary: Accept-Encoding, "; @@ -419,7 +419,7 @@ Y_UNIT_TEST_SUITE(THttpStreamTest) { UNIT_ASSERT_VALUES_EQUAL((++it)->ToString(), TString(headerLine4)); } - Y_UNIT_TEST(ContentLengthRemoval) { + Y_UNIT_TEST(ContentLengthRemoval) { TMemoryInput request("GET / HTTP/1.1\r\nAccept-Encoding: gzip\r\n\r\n"); THttpInput i(&request); TString result; @@ -487,7 +487,7 @@ Y_UNIT_TEST_SUITE(THttpStreamTest) { UNIT_ASSERT(result.Contains("content-encoding: gzip")); } - Y_UNIT_TEST(HasTrailers) { + Y_UNIT_TEST(HasTrailers) { TMemoryInput response( "HTTP/1.1 200 OK\r\n" "Transfer-Encoding: chunked\r\n" @@ -506,7 +506,7 @@ Y_UNIT_TEST_SUITE(THttpStreamTest) { UNIT_ASSERT_VALUES_EQUAL(trailers.GetRef().Begin()->ToString(), "Bar: baz"); } - Y_UNIT_TEST(NoTrailersWithChunks) { + Y_UNIT_TEST(NoTrailersWithChunks) { TMemoryInput response( "HTTP/1.1 200 OK\r\n" "Transfer-Encoding: chunked\r\n" @@ -523,7 +523,7 @@ Y_UNIT_TEST_SUITE(THttpStreamTest) { UNIT_ASSERT_VALUES_EQUAL(trailers.GetRef().Count(), 0); } - Y_UNIT_TEST(NoTrailersNoChunks) { + Y_UNIT_TEST(NoTrailersNoChunks) { TMemoryInput response( "HTTP/1.1 200 OK\r\n" "Content-Length: 3\r\n" @@ -537,7 +537,7 @@ Y_UNIT_TEST_SUITE(THttpStreamTest) { UNIT_ASSERT_VALUES_EQUAL(trailers.GetRef().Count(), 0); } - Y_UNIT_TEST(RequestWithoutContentLength) { + Y_UNIT_TEST(RequestWithoutContentLength) { TStringStream request; { THttpOutput httpOutput(&request); @@ -565,7 +565,7 @@ Y_UNIT_TEST_SUITE(THttpStreamTest) { } } - Y_UNIT_TEST(TestInputHasContent) { + Y_UNIT_TEST(TestInputHasContent) { { TStringStream request; request << "POST / HTTP/1.1\r\n" @@ -611,7 +611,7 @@ Y_UNIT_TEST_SUITE(THttpStreamTest) { } } - Y_UNIT_TEST(TestHttpInputHeadRequest) { + Y_UNIT_TEST(TestHttpInputHeadRequest) { class THeadOnlyInput: public IInputStream { public: THeadOnlyInput() = default; @@ -645,7 +645,7 @@ Y_UNIT_TEST_SUITE(THttpStreamTest) { UNIT_ASSERT_VALUES_EQUAL(httpInput.ReadAll(), ""); } - Y_UNIT_TEST(TestHttpOutputResponseToHeadRequestNoZeroChunk) { + Y_UNIT_TEST(TestHttpOutputResponseToHeadRequestNoZeroChunk) { TStringStream request; request << "HEAD / HTTP/1.1\r\n" "Host: yandex.ru\r\n" diff --git a/library/cpp/http/io/stream_ut_medium.cpp b/library/cpp/http/io/stream_ut_medium.cpp index 2c125eb21e4..fb5c425b028 100644 --- a/library/cpp/http/io/stream_ut_medium.cpp +++ b/library/cpp/http/io/stream_ut_medium.cpp @@ -3,7 +3,7 @@ #include <util/stream/zlib.h> Y_UNIT_TEST_SUITE(THttpTestMedium) { - Y_UNIT_TEST(TestCodings2) { + Y_UNIT_TEST(TestCodings2) { TStringBuf data = "aaaaaaaaaaaaaaaaaaaaaaa"; for (auto codec : SupportedCodings()) { diff --git a/library/cpp/http/misc/httpdate.cpp b/library/cpp/http/misc/httpdate.cpp index 4a3031bbf4d..563f3567876 100644 --- a/library/cpp/http/misc/httpdate.cpp +++ b/library/cpp/http/misc/httpdate.cpp @@ -71,13 +71,13 @@ char* format_http_date(time_t when, char* buf, size_t buflen) { return nullptr; } - Y_ASSERT(len > 0 && size_t(len) < buflen); + Y_ASSERT(len > 0 && size_t(len) < buflen); return buf; } TString FormatHttpDate(time_t when) { char str[64] = {0}; - format_http_date(str, Y_ARRAY_SIZE(str), when); + format_http_date(str, Y_ARRAY_SIZE(str), when); return TString(str); } diff --git a/library/cpp/http/misc/httpdate_ut.cpp b/library/cpp/http/misc/httpdate_ut.cpp index c1a0103501b..30c8a1b19f0 100644 --- a/library/cpp/http/misc/httpdate_ut.cpp +++ b/library/cpp/http/misc/httpdate_ut.cpp @@ -2,14 +2,14 @@ #include "httpdate.h" -Y_UNIT_TEST_SUITE(TestHttpDate) { - Y_UNIT_TEST(Test1) { +Y_UNIT_TEST_SUITE(TestHttpDate) { + Y_UNIT_TEST(Test1) { char buf1[100]; char buf2[100]; UNIT_ASSERT((int)strlen(format_http_date(0, buf1, sizeof(buf1))) == format_http_date(buf2, sizeof(buf2), 0)); } - Y_UNIT_TEST(Test2) { + Y_UNIT_TEST(Test2) { UNIT_ASSERT_STRINGS_EQUAL(FormatHttpDate(1234567890), "Fri, 13 Feb 2009 23:31:30 GMT"); } } diff --git a/library/cpp/http/misc/httpreqdata.cpp b/library/cpp/http/misc/httpreqdata.cpp index f6951f68cd9..2ae2c363398 100644 --- a/library/cpp/http/misc/httpreqdata.cpp +++ b/library/cpp/http/misc/httpreqdata.cpp @@ -29,7 +29,7 @@ TBaseServerRequestData::TBaseServerRequestData(const char* qs, SOCKET s) void TBaseServerRequestData::AppendQueryString(const char* str, size_t length) { if (Y_UNLIKELY(Search)) { - Y_ASSERT(strlen(Search) == SearchLength); + Y_ASSERT(strlen(Search) == SearchLength); ModifiedQueryString.Reserve(SearchLength + length + 2); ModifiedQueryString.Assign(Search, SearchLength); if (SearchLength > 0 && Search[SearchLength - 1] != '&' && @@ -170,7 +170,7 @@ bool TBaseServerRequestData::Parse(const char* origReq) { ptrdiff_t delta = fragment - Search; // indeed, second case is a parse error SearchLength = (delta >= 0) ? delta : (urlEnd - Search); - Y_ASSERT(strlen(Search) == SearchLength); + Y_ASSERT(strlen(Search) == SearchLength); } else { SearchLength = 0; } diff --git a/library/cpp/http/misc/httpreqdata_ut.cpp b/library/cpp/http/misc/httpreqdata_ut.cpp index e7f16ef27c8..88ec48c6663 100644 --- a/library/cpp/http/misc/httpreqdata_ut.cpp +++ b/library/cpp/http/misc/httpreqdata_ut.cpp @@ -2,8 +2,8 @@ #include <library/cpp/testing/unittest/registar.h> -Y_UNIT_TEST_SUITE(TRequestServerDataTest) { - Y_UNIT_TEST(Headers) { +Y_UNIT_TEST_SUITE(TRequestServerDataTest) { + Y_UNIT_TEST(Headers) { TServerRequestData sd; sd.AddHeader("x-xx", "y-yy"); @@ -17,7 +17,7 @@ Y_UNIT_TEST_SUITE(TRequestServerDataTest) { UNIT_ASSERT_VALUES_EQUAL(TStringBuf(sd.HeaderIn("X-XXX")), TStringBuf("y-yyy")); } - Y_UNIT_TEST(ComplexHeaders) { + Y_UNIT_TEST(ComplexHeaders) { TServerRequestData sd; sd.SetHost("zzz", 1); @@ -42,7 +42,7 @@ Y_UNIT_TEST_SUITE(TRequestServerDataTest) { UNIT_ASSERT_VALUES_EQUAL(sd.ServerPort(), "678"); } - Y_UNIT_TEST(ParseScan) { + Y_UNIT_TEST(ParseScan) { TServerRequestData rd; // Parse parses url without host @@ -62,7 +62,7 @@ Y_UNIT_TEST_SUITE(TRequestServerDataTest) { rd.Clear(); } - Y_UNIT_TEST(Ctor) { + Y_UNIT_TEST(Ctor) { const TString qs("gta=fake&haha=da"); TServerRequestData rd(qs.c_str()); @@ -74,7 +74,7 @@ Y_UNIT_TEST_SUITE(TRequestServerDataTest) { UNIT_ASSERT(!rd.CgiParam.Has("no-param")); } - Y_UNIT_TEST(HashCut) { + Y_UNIT_TEST(HashCut) { const TString qs(">a=fake&haha=da"); const TString header = " /yandsearch?" + qs + "#&uberParam=yes&q=? HTTP 1.1 OK"; @@ -90,7 +90,7 @@ Y_UNIT_TEST_SUITE(TRequestServerDataTest) { UNIT_ASSERT(!rd.CgiParam.Has("uberParam")); } - Y_UNIT_TEST(MisplacedHashCut) { + Y_UNIT_TEST(MisplacedHashCut) { TServerRequestData rd; rd.Parse(" /y#ndsearch?>a=fake&haha=da&uberParam=yes&q=? HTTP 1.1 OK"); @@ -101,7 +101,7 @@ Y_UNIT_TEST_SUITE(TRequestServerDataTest) { UNIT_ASSERT(rd.CgiParam.empty()); } - Y_UNIT_TEST(CornerCase) { + Y_UNIT_TEST(CornerCase) { TServerRequestData rd; rd.Parse(" /yandsearch?#"); @@ -112,7 +112,7 @@ Y_UNIT_TEST_SUITE(TRequestServerDataTest) { UNIT_ASSERT(rd.CgiParam.empty()); } - Y_UNIT_TEST(AppendQueryString) { + Y_UNIT_TEST(AppendQueryString) { const TString qs("gta=fake&haha=da"); TServerRequestData rd(qs.c_str()); @@ -134,7 +134,7 @@ Y_UNIT_TEST_SUITE(TRequestServerDataTest) { UNIT_ASSERT(rd.CgiParam.Has("gta", "new")); } - Y_UNIT_TEST(SetRemoteAddrSimple) { + Y_UNIT_TEST(SetRemoteAddrSimple) { static const TString TEST = "abacaba.search.yandex.net"; TServerRequestData rd; @@ -142,7 +142,7 @@ Y_UNIT_TEST_SUITE(TRequestServerDataTest) { UNIT_ASSERT_STRINGS_EQUAL(TEST, rd.RemoteAddr()); } - Y_UNIT_TEST(SetRemoteAddrRandom) { + Y_UNIT_TEST(SetRemoteAddrRandom) { for (size_t size = 0; size < 2 * INET6_ADDRSTRLEN; ++size) { const TString test = NUnitTest::RandomString(size, size); TServerRequestData rd; diff --git a/library/cpp/http/misc/parsed_request.cpp b/library/cpp/http/misc/parsed_request.cpp index e332a24e917..d1092390549 100644 --- a/library/cpp/http/misc/parsed_request.cpp +++ b/library/cpp/http/misc/parsed_request.cpp @@ -1,6 +1,6 @@ #include "parsed_request.h" -#include <util/string/strip.h> +#include <util/string/strip.h> #include <util/generic/yexception.h> #include <util/string/cast.h> diff --git a/library/cpp/http/misc/parsed_request_ut.cpp b/library/cpp/http/misc/parsed_request_ut.cpp index da6d95c6ab5..095c7e59c8b 100644 --- a/library/cpp/http/misc/parsed_request_ut.cpp +++ b/library/cpp/http/misc/parsed_request_ut.cpp @@ -2,8 +2,8 @@ #include <library/cpp/testing/unittest/registar.h> -Y_UNIT_TEST_SUITE(THttpParse) { - Y_UNIT_TEST(TestParse) { +Y_UNIT_TEST_SUITE(THttpParse) { + Y_UNIT_TEST(TestParse) { TParsedHttpFull h("GET /yandsearch?text=nokia HTTP/1.1"); UNIT_ASSERT_EQUAL(h.Method, "GET"); @@ -14,7 +14,7 @@ Y_UNIT_TEST_SUITE(THttpParse) { UNIT_ASSERT_EQUAL(h.Cgi, "text=nokia"); } - Y_UNIT_TEST(TestError) { + Y_UNIT_TEST(TestError) { bool wasError = false; try { diff --git a/library/cpp/http/server/conn.cpp b/library/cpp/http/server/conn.cpp index 38a76c4c309..801656dc88b 100644 --- a/library/cpp/http/server/conn.cpp +++ b/library/cpp/http/server/conn.cpp @@ -1,7 +1,7 @@ #include "conn.h" #include <util/network/socket.h> -#include <util/stream/buffered.h> +#include <util/stream/buffered.h> class THttpServerConn::TImpl { public: diff --git a/library/cpp/http/server/http.cpp b/library/cpp/http/server/http.cpp index 128583bdd70..b8d634edec9 100644 --- a/library/cpp/http/server/http.cpp +++ b/library/cpp/http/server/http.cpp @@ -15,7 +15,7 @@ #include <util/system/defaults.h> #include <util/system/event.h> #include <util/system/mutex.h> -#include <util/system/pipe.h> +#include <util/system/pipe.h> #include <util/system/thread.h> #include <util/thread/factory.h> diff --git a/library/cpp/http/server/http_ut.cpp b/library/cpp/http/server/http_ut.cpp index cc62bb988e7..e60d67673d1 100644 --- a/library/cpp/http/server/http_ut.cpp +++ b/library/cpp/http/server/http_ut.cpp @@ -5,12 +5,12 @@ #include <library/cpp/testing/unittest/tests_data.h> #include <util/generic/cast.h> -#include <util/stream/output.h> +#include <util/stream/output.h> #include <util/stream/zlib.h> #include <util/system/datetime.h> #include <util/system/sem.h> -Y_UNIT_TEST_SUITE(THttpServerTest) { +Y_UNIT_TEST_SUITE(THttpServerTest) { class TEchoServer: public THttpServer::ICallBack { class TRequest: public THttpClientRequestEx { public: @@ -320,7 +320,7 @@ Y_UNIT_TEST_SUITE(THttpServerTest) { return res; } - Y_UNIT_TEST(TestEchoServer) { + Y_UNIT_TEST(TestEchoServer) { TString res = TestData(); TPortManager pm; const ui16 port = pm.GetPort(); @@ -368,7 +368,7 @@ Y_UNIT_TEST_SUITE(THttpServerTest) { } } - Y_UNIT_TEST(TestReusePortEnabled) { + Y_UNIT_TEST(TestReusePortEnabled) { if (!IsReusePortAvailable()) { return; // skip test } @@ -403,7 +403,7 @@ Y_UNIT_TEST_SUITE(THttpServerTest) { } } - Y_UNIT_TEST(TestReusePortDisabled) { + Y_UNIT_TEST(TestReusePortDisabled) { // check that with the ReusePort option disabled it's impossible to start two servers on the same port // check that ReusePort option is disabled by default (don't set it explicitly in the test) TPortManager pm; @@ -422,7 +422,7 @@ Y_UNIT_TEST_SUITE(THttpServerTest) { UNIT_ASSERT(false == server1.Start()); } - Y_UNIT_TEST(TestFailServer) { + Y_UNIT_TEST(TestFailServer) { /** * Emulate request processing failures * Data should be large enough not to fit into socket buffer @@ -541,7 +541,7 @@ Y_UNIT_TEST_SUITE(THttpServerTest) { server.Stop(); }; - Y_UNIT_TEST(TTestReleaseConnection) { + Y_UNIT_TEST(TTestReleaseConnection) { TPortManager pm; const ui16 port = pm.GetPort(); @@ -685,7 +685,7 @@ Y_UNIT_TEST_SUITE(THttpServerTest) { }; #if 0 - Y_UNIT_TEST(TestSocketsLeak) { + Y_UNIT_TEST(TestSocketsLeak) { const bool trueFalse[] = {true, false}; TPortManager portManager; const ui16 port = portManager.GetPort(); diff --git a/library/cpp/http/server/options.cpp b/library/cpp/http/server/options.cpp index 05c954384a2..3aed3757ed1 100644 --- a/library/cpp/http/server/options.cpp +++ b/library/cpp/http/server/options.cpp @@ -24,7 +24,7 @@ static inline TNetworkAddress ToNetworkAddr(const TString& address, ui16 port) { void THttpServerOptions::BindAddresses(TBindAddresses& ret) const { THashSet<TString> check; - for (auto addr : BindSockaddr) { + for (auto addr : BindSockaddr) { if (!addr.Port) { addr.Port = Port; } diff --git a/library/cpp/http/server/response.cpp b/library/cpp/http/server/response.cpp index 52d64c91cec..cbdb29aab7d 100644 --- a/library/cpp/http/server/response.cpp +++ b/library/cpp/http/server/response.cpp @@ -17,7 +17,7 @@ THttpResponse& THttpResponse::SetContentType(const TStringBuf& contentType) { return *this; } -void THttpResponse::OutTo(IOutputStream& os) const { +void THttpResponse::OutTo(IOutputStream& os) const { TVector<IOutputStream::TPart> parts; const size_t FIRST_LINE_PARTS = 3; const size_t HEADERS_PARTS = Headers.Count() * 4; @@ -26,15 +26,15 @@ void THttpResponse::OutTo(IOutputStream& os) const { // first line parts.push_back(IOutputStream::TPart(TStringBuf("HTTP/1.1 "))); - parts.push_back(IOutputStream::TPart(HttpCodeStrEx(Code))); - parts.push_back(IOutputStream::TPart::CrLf()); + parts.push_back(IOutputStream::TPart(HttpCodeStrEx(Code))); + parts.push_back(IOutputStream::TPart::CrLf()); // headers for (THttpHeaders::TConstIterator i = Headers.Begin(); i != Headers.End(); ++i) { - parts.push_back(IOutputStream::TPart(i->Name())); + parts.push_back(IOutputStream::TPart(i->Name())); parts.push_back(IOutputStream::TPart(TStringBuf(": "))); - parts.push_back(IOutputStream::TPart(i->Value())); - parts.push_back(IOutputStream::TPart::CrLf()); + parts.push_back(IOutputStream::TPart(i->Value())); + parts.push_back(IOutputStream::TPart::CrLf()); } char buf[50]; @@ -45,21 +45,21 @@ void THttpResponse::OutTo(IOutputStream& os) const { mo << Content.size(); parts.push_back(IOutputStream::TPart(TStringBuf("Content-Length: "))); - parts.push_back(IOutputStream::TPart(buf, mo.Buf() - buf)); - parts.push_back(IOutputStream::TPart::CrLf()); + parts.push_back(IOutputStream::TPart(buf, mo.Buf() - buf)); + parts.push_back(IOutputStream::TPart::CrLf()); } // content - parts.push_back(IOutputStream::TPart::CrLf()); + parts.push_back(IOutputStream::TPart::CrLf()); if (!Content.empty()) { - parts.push_back(IOutputStream::TPart(Content)); + parts.push_back(IOutputStream::TPart(Content)); } os.Write(parts.data(), parts.size()); } template <> -void Out<THttpResponse>(IOutputStream& os, const THttpResponse& resp) { +void Out<THttpResponse>(IOutputStream& os, const THttpResponse& resp) { resp.OutTo(os); } diff --git a/library/cpp/http/server/response.h b/library/cpp/http/server/response.h index a75cb85605f..2e68d873ac0 100644 --- a/library/cpp/http/server/response.h +++ b/library/cpp/http/server/response.h @@ -7,7 +7,7 @@ #include <util/string/cast.h> class THttpHeaders; -class IOutputStream; +class IOutputStream; class THttpResponse { public: @@ -42,8 +42,8 @@ public: /** * @note If @arg content isn't empty its size is automatically added as a - * "Content-Length" header during output to IOutputStream. - * @see IOutputStream& operator << (IOutputStream&, const THttpResponse&) + * "Content-Length" header during output to IOutputStream. + * @see IOutputStream& operator << (IOutputStream&, const THttpResponse&) */ THttpResponse& SetContent(const TString& content) { Content = content; @@ -57,8 +57,8 @@ public: /** * @note If @arg content isn't empty its size is automatically added as a - * "Content-Length" header during output to IOutputStream. - * @see IOutputStream& operator << (IOutputStream&, const THttpResponse&) + * "Content-Length" header during output to IOutputStream. + * @see IOutputStream& operator << (IOutputStream&, const THttpResponse&) */ THttpResponse& SetContent(const TString& content, const TStringBuf& contentType) { return SetContent(content).SetContentType(contentType); @@ -73,7 +73,7 @@ public: return *this; } - void OutTo(IOutputStream& out) const; + void OutTo(IOutputStream& out) const; private: HttpCodes Code; diff --git a/library/cpp/http/server/response_ut.cpp b/library/cpp/http/server/response_ut.cpp index 73e2112ad36..eb40ce67012 100644 --- a/library/cpp/http/server/response_ut.cpp +++ b/library/cpp/http/server/response_ut.cpp @@ -4,20 +4,20 @@ #include <util/string/cast.h> -Y_UNIT_TEST_SUITE(TestHttpResponse) { - Y_UNIT_TEST(TestCodeOnly) { +Y_UNIT_TEST_SUITE(TestHttpResponse) { + Y_UNIT_TEST(TestCodeOnly) { UNIT_ASSERT_STRINGS_EQUAL(ToString(THttpResponse()), "HTTP/1.1 200 Ok\r\n\r\n"); UNIT_ASSERT_STRINGS_EQUAL(ToString(THttpResponse(HTTP_NOT_FOUND)), "HTTP/1.1 404 Not found\r\n\r\n"); } - Y_UNIT_TEST(TestRedirect) { + Y_UNIT_TEST(TestRedirect) { THttpResponse resp = THttpResponse(HTTP_FOUND).AddHeader("Location", "yandex.ru"); UNIT_ASSERT_STRINGS_EQUAL(ToString(resp), "HTTP/1.1 302 Moved temporarily\r\n" "Location: yandex.ru\r\n" "\r\n"); } - Y_UNIT_TEST(TestAddHeader) { + Y_UNIT_TEST(TestAddHeader) { THttpResponse resp(HTTP_FORBIDDEN); resp.AddHeader(THttpInputHeader("X-Header-1", "ValueOne")); resp.AddHeader("X-Header-2", 10); @@ -31,7 +31,7 @@ Y_UNIT_TEST_SUITE(TestHttpResponse) { UNIT_ASSERT_STRINGS_EQUAL(ToString(resp), EXPECTED); } - Y_UNIT_TEST(TestAddMultipleHeaders) { + Y_UNIT_TEST(TestAddMultipleHeaders) { THttpHeaders headers; headers.AddHeader(THttpInputHeader("X-Header-1", "ValueOne")); headers.AddHeader(THttpInputHeader("X-Header-2", "ValueTwo")); @@ -65,7 +65,7 @@ Y_UNIT_TEST_SUITE(TestHttpResponse) { } - Y_UNIT_TEST(TestSetContent) { + Y_UNIT_TEST(TestSetContent) { const char* EXPECTED = "HTTP/1.1 200 Ok\r\n" "Content-Length: 10\r\n" "\r\n" @@ -74,7 +74,7 @@ Y_UNIT_TEST_SUITE(TestHttpResponse) { EXPECTED); } - Y_UNIT_TEST(TestSetContentWithContentType) { + Y_UNIT_TEST(TestSetContentWithContentType) { const char* EXPECTED = "HTTP/1.1 200 Ok\r\n" "Content-Type: text/xml\r\n" "Content-Length: 28\r\n" @@ -85,7 +85,7 @@ Y_UNIT_TEST_SUITE(TestHttpResponse) { UNIT_ASSERT_STRINGS_EQUAL(ToString(resp), EXPECTED); } - Y_UNIT_TEST(TestCopyConstructor) { + Y_UNIT_TEST(TestCopyConstructor) { THttpResponse resp(HTTP_FORBIDDEN); resp.AddHeader(THttpInputHeader("X-Header-1", "ValueOne")) .AddHeader("X-Header-2", "ValueTwo") @@ -97,7 +97,7 @@ Y_UNIT_TEST_SUITE(TestHttpResponse) { UNIT_ASSERT_STRINGS_EQUAL(ToString(copy), ToString(resp)); } - Y_UNIT_TEST(TestAssignment) { + Y_UNIT_TEST(TestAssignment) { THttpResponse resp(HTTP_FORBIDDEN); resp.AddHeader(THttpInputHeader("X-Header-1", "ValueOne")); resp.AddHeader(THttpInputHeader("X-Header-2", "ValueTwo")); @@ -109,11 +109,11 @@ Y_UNIT_TEST_SUITE(TestHttpResponse) { UNIT_ASSERT_STRINGS_EQUAL(ToString(copy), ToString(resp)); } - Y_UNIT_TEST(TestEmptyContent) { + Y_UNIT_TEST(TestEmptyContent) { UNIT_ASSERT_STRINGS_EQUAL(ToString(THttpResponse().SetContent("")), "HTTP/1.1 200 Ok\r\n\r\n"); } - Y_UNIT_TEST(TestReturnReference) { + Y_UNIT_TEST(TestReturnReference) { THttpResponse resp; UNIT_ASSERT_EQUAL(&resp, &resp.AddHeader("Header1", 1)); UNIT_ASSERT_EQUAL(&resp, &resp.AddHeader(THttpInputHeader("Header2", "2"))); diff --git a/library/cpp/hyperloglog/hyperloglog_ut.cpp b/library/cpp/hyperloglog/hyperloglog_ut.cpp index b987aa0fa4a..7973525e81d 100644 --- a/library/cpp/hyperloglog/hyperloglog_ut.cpp +++ b/library/cpp/hyperloglog/hyperloglog_ut.cpp @@ -8,8 +8,8 @@ #include <cmath> -Y_UNIT_TEST_SUITE(THyperLogLog) { - Y_UNIT_TEST(TestPrecision18) { +Y_UNIT_TEST_SUITE(THyperLogLog) { + Y_UNIT_TEST(TestPrecision18) { TMersenne<ui64> rand; auto counter = THyperLogLog::Create(18); diff --git a/library/cpp/int128/ut/int128_via_intrinsic_ut.cpp b/library/cpp/int128/ut/int128_via_intrinsic_ut.cpp index 9decc2fd482..d19ebc959a2 100644 --- a/library/cpp/int128/ut/int128_via_intrinsic_ut.cpp +++ b/library/cpp/int128/ut/int128_via_intrinsic_ut.cpp @@ -14,7 +14,7 @@ Y_UNIT_TEST_SUITE(Int128ViaIntrinsicSuite) { return res; } - Y_UNIT_TEST(bigintTest) { + Y_UNIT_TEST(bigintTest) { UNIT_ASSERT(guint128_t(127) == toGcc(ui128(127))); UNIT_ASSERT(guint128_t(127) * guint128_t(127) == toGcc(ui128(127) * ui128(127))); UNIT_ASSERT(guint128_t(127) + guint128_t(127) == toGcc(ui128(127) + ui128(127))); diff --git a/library/cpp/ipv6_address/ipv6_address.cpp b/library/cpp/ipv6_address/ipv6_address.cpp index be8fcbae13b..7924168a303 100644 --- a/library/cpp/ipv6_address/ipv6_address.cpp +++ b/library/cpp/ipv6_address/ipv6_address.cpp @@ -169,11 +169,11 @@ void TIpv6Address::ToSockaddrAndSocklen(sockaddr_in& sockAddrIPv4, sockAddrSize = sizeof(sockAddrIPv6); sockAddrPtr = reinterpret_cast<sockaddr*>(&sockAddrIPv6); } else - Y_VERIFY(false); + Y_VERIFY(false); } void TIpv6Address::ToInAddr(in_addr& Addr4) const { - Y_VERIFY(Type_ == TIpv6Address::Ipv4); + Y_VERIFY(Type_ == TIpv6Address::Ipv4); Zero(Addr4); ui32 Value = GetLow(Ip); @@ -182,7 +182,7 @@ void TIpv6Address::ToInAddr(in_addr& Addr4) const { Addr4.s_addr = SwapBytes(Value); } void TIpv6Address::ToIn6Addr(in6_addr& Addr6) const { - Y_VERIFY(Type_ == TIpv6Address::Ipv6); + Y_VERIFY(Type_ == TIpv6Address::Ipv6); Zero(Addr6); ui64 Raw[2] = {GetHigh(Ip), GetLow(Ip)}; @@ -237,7 +237,7 @@ TIpv6Address TIpv6Address::Normalized() const noexcept { return *this; TIpv6Address Result = TryToExtractIpv4From6(); - Y_VERIFY(Result.IsNull() == false); + Y_VERIFY(Result.IsNull() == false); return Result; } @@ -369,7 +369,7 @@ std::tuple<THostAddressAndPort, TString, TIpPort> ParseHostAndMayBePortFromStrin // --------------------------------------------------------------------- - const size_t ColPos = RawStr.find(':'); + const size_t ColPos = RawStr.find(':'); if (ColPos != TString::npos) { // host:port // ipv4:port diff --git a/library/cpp/ipv6_address/ipv6_address.h b/library/cpp/ipv6_address/ipv6_address.h index 1d7eb0b65fd..ef67b75aa0f 100644 --- a/library/cpp/ipv6_address/ipv6_address.h +++ b/library/cpp/ipv6_address/ipv6_address.h @@ -233,6 +233,6 @@ NAddr::IRemoteAddr* ToIRemoteAddr(const TIpv6Address& Address, TIpPort Port); // template <> // class TSerializer<TIpv6Address> { // public: -// static void Save(IOutputStream *out, const TIpv6Address &ip); -// static void Load(IInputStream *in, TIpv6Address &ip); +// static void Save(IOutputStream *out, const TIpv6Address &ip); +// static void Load(IInputStream *in, TIpv6Address &ip); //}; diff --git a/library/cpp/json/fast_sax/parser.rl6 b/library/cpp/json/fast_sax/parser.rl6 index edb4e9ee1b3..d25e26b02e7 100644 --- a/library/cpp/json/fast_sax/parser.rl6 +++ b/library/cpp/json/fast_sax/parser.rl6 @@ -124,7 +124,7 @@ struct TParserCtx { } bool OnString(TStringBuf s, EStoredStr t) { - if (Y_LIKELY(OnVal())) { + if (Y_LIKELY(OnVal())) { String = s; Stored = t; return true; @@ -210,21 +210,21 @@ machine fastjson; alphtype char; -action OnNull { if (Y_UNLIKELY(!OnNull())) goto TOKEN_ERROR; } -action OnTrue { if (Y_UNLIKELY(!OnTrue())) goto TOKEN_ERROR; } -action OnFalse { if (Y_UNLIKELY(!OnFalse())) goto TOKEN_ERROR; } -action OnPInt { if (Y_UNLIKELY(!OnPInt())) goto TOKEN_ERROR; } -action OnNInt { if (Y_UNLIKELY(!OnNInt())) goto TOKEN_ERROR; } -action OnFlt { if (Y_UNLIKELY(!OnFlt())) goto TOKEN_ERROR; } -action OnStrU { if (Y_UNLIKELY(!OnStrU())) goto TOKEN_ERROR; } -action OnStrQ { if (Y_UNLIKELY(!OnStrQ())) goto TOKEN_ERROR; } -action OnStrE { if (Y_UNLIKELY(!OnStrE())) goto TOKEN_ERROR; } -action OnDictO { if (Y_UNLIKELY(!OnMapOpen())) goto TOKEN_ERROR; } -action OnDictC { if (Y_UNLIKELY(!OnMapClose())) goto TOKEN_ERROR; } -action OnArrO { if (Y_UNLIKELY(!OnArrOpen())) goto TOKEN_ERROR; } -action OnArrC { if (Y_UNLIKELY(!OnArrClose())) goto TOKEN_ERROR; } -action OnComma { if (Y_UNLIKELY(!OnComma())) goto TOKEN_ERROR; } -action OnColon { if (Y_UNLIKELY(!OnColon())) goto TOKEN_ERROR; } +action OnNull { if (Y_UNLIKELY(!OnNull())) goto TOKEN_ERROR; } +action OnTrue { if (Y_UNLIKELY(!OnTrue())) goto TOKEN_ERROR; } +action OnFalse { if (Y_UNLIKELY(!OnFalse())) goto TOKEN_ERROR; } +action OnPInt { if (Y_UNLIKELY(!OnPInt())) goto TOKEN_ERROR; } +action OnNInt { if (Y_UNLIKELY(!OnNInt())) goto TOKEN_ERROR; } +action OnFlt { if (Y_UNLIKELY(!OnFlt())) goto TOKEN_ERROR; } +action OnStrU { if (Y_UNLIKELY(!OnStrU())) goto TOKEN_ERROR; } +action OnStrQ { if (Y_UNLIKELY(!OnStrQ())) goto TOKEN_ERROR; } +action OnStrE { if (Y_UNLIKELY(!OnStrE())) goto TOKEN_ERROR; } +action OnDictO { if (Y_UNLIKELY(!OnMapOpen())) goto TOKEN_ERROR; } +action OnDictC { if (Y_UNLIKELY(!OnMapClose())) goto TOKEN_ERROR; } +action OnArrO { if (Y_UNLIKELY(!OnArrOpen())) goto TOKEN_ERROR; } +action OnArrC { if (Y_UNLIKELY(!OnArrClose())) goto TOKEN_ERROR; } +action OnComma { if (Y_UNLIKELY(!OnComma())) goto TOKEN_ERROR; } +action OnColon { if (Y_UNLIKELY(!OnColon())) goto TOKEN_ERROR; } action OnError { goto TOKEN_ERROR; } comment1 = "/*" (any* -- "*/") "*/"; @@ -296,7 +296,7 @@ bool TParserCtx::Parse() { write exec; }%% ; - Y_UNUSED(fastjson_en_main); + Y_UNUSED(fastjson_en_main); } catch (const TFromStringException& e) { return OnError(e.what()); } diff --git a/library/cpp/json/rapidjson_helpers.h b/library/cpp/json/rapidjson_helpers.h index aeb96ff6703..945a9ff7ee8 100644 --- a/library/cpp/json/rapidjson_helpers.h +++ b/library/cpp/json/rapidjson_helpers.h @@ -58,7 +58,7 @@ namespace NJson { return Count; } - TInputStreamWrapper(IInputStream& helper) + TInputStreamWrapper(IInputStream& helper) : Helper(helper) , Eof(false) , Sz(0) @@ -69,7 +69,7 @@ namespace NJson { static const size_t BUF_SIZE = 1 << 12; - IInputStream& Helper; + IInputStream& Helper; mutable char Buf[BUF_SIZE]; mutable bool Eof; mutable size_t Sz; diff --git a/library/cpp/json/ut/json_prettifier_ut.cpp b/library/cpp/json/ut/json_prettifier_ut.cpp index ae5f8dd81a4..4ca9d5bd811 100644 --- a/library/cpp/json/ut/json_prettifier_ut.cpp +++ b/library/cpp/json/ut/json_prettifier_ut.cpp @@ -2,8 +2,8 @@ #include <library/cpp/testing/unittest/registar.h> -Y_UNIT_TEST_SUITE(JsonPrettifier) { - Y_UNIT_TEST(PrettifyJsonShort) { +Y_UNIT_TEST_SUITE(JsonPrettifier) { + Y_UNIT_TEST(PrettifyJsonShort) { UNIT_ASSERT_STRINGS_EQUAL(NJson::PrettifyJson(""), ""); UNIT_ASSERT_STRINGS_EQUAL(NJson::PrettifyJson("null"), "null"); UNIT_ASSERT_STRINGS_EQUAL(NJson::PrettifyJson("true"), "true"); @@ -34,7 +34,7 @@ Y_UNIT_TEST_SUITE(JsonPrettifier) { UNIT_ASSERT_STRINGS_EQUAL(NJson::PrettifyJson("{k:v}", true, 2), "{\n k : v\n}"); } - Y_UNIT_TEST(PrettifyJsonLong) { + Y_UNIT_TEST(PrettifyJsonLong) { UNIT_ASSERT_STRINGS_EQUAL(NJson::PrettifyJson("[{k:v},{a:b}]", false, 2, true), "[\n" " {\n" @@ -110,7 +110,7 @@ Y_UNIT_TEST_SUITE(JsonPrettifier) { "}"); } - Y_UNIT_TEST(PrettifyJsonInvalid) { + Y_UNIT_TEST(PrettifyJsonInvalid) { UNIT_ASSERT_STRINGS_EQUAL(NJson::PrettifyJson("}"), ""); UNIT_ASSERT_STRINGS_EQUAL(NJson::PrettifyJson("}}"), ""); UNIT_ASSERT_STRINGS_EQUAL(NJson::PrettifyJson("{}}"), ""); @@ -123,7 +123,7 @@ Y_UNIT_TEST_SUITE(JsonPrettifier) { UNIT_ASSERT_STRINGS_EQUAL(NJson::PrettifyJson("{,,,}"), ""); } - Y_UNIT_TEST(CompactifyJsonShort) { + Y_UNIT_TEST(CompactifyJsonShort) { UNIT_ASSERT_STRINGS_EQUAL(NJson::CompactifyJson(""), ""); UNIT_ASSERT_STRINGS_EQUAL(NJson::CompactifyJson("null"), "null"); UNIT_ASSERT_STRINGS_EQUAL(NJson::CompactifyJson("true"), "true"); @@ -142,7 +142,7 @@ Y_UNIT_TEST_SUITE(JsonPrettifier) { UNIT_ASSERT_STRINGS_EQUAL(NJson::CompactifyJson("{\n 'k' : 'v'\n}", true), "{k:v}"); } - Y_UNIT_TEST(CompactifyJsonLong) { + Y_UNIT_TEST(CompactifyJsonLong) { UNIT_ASSERT_STRINGS_EQUAL(NJson::CompactifyJson( "[\n" " {\n" diff --git a/library/cpp/json/ut/json_reader_ut.cpp b/library/cpp/json/ut/json_reader_ut.cpp index cd31afa0b8b..f4c9bf9df6f 100644 --- a/library/cpp/json/ut/json_reader_ut.cpp +++ b/library/cpp/json/ut/json_reader_ut.cpp @@ -66,8 +66,8 @@ public: } }; -Y_UNIT_TEST_SUITE(TJsonReaderTest) { - Y_UNIT_TEST(JsonReformatTest) { +Y_UNIT_TEST_SUITE(TJsonReaderTest) { + Y_UNIT_TEST(JsonReformatTest) { TString data = "{\"null value\": null, \"intkey\": 10, \"double key\": 11.11, \"string key\": \"string\", \"array\": [1,2,3,\"TString\"], \"bool key\": true}"; TString result1, result2; @@ -119,7 +119,7 @@ Y_UNIT_TEST_SUITE(TJsonReaderTest) { } } - Y_UNIT_TEST(TJsonTreeTest) { + Y_UNIT_TEST(TJsonTreeTest) { TString data = "{\"intkey\": 10, \"double key\": 11.11, \"null value\":null, \"string key\": \"string\", \"array\": [1,2,3,\"TString\"], \"bool key\": true}"; TStringStream in; in << data; @@ -154,7 +154,7 @@ Y_UNIT_TEST_SUITE(TJsonReaderTest) { UNIT_ASSERT_VALUES_EQUAL(value["array"][3].GetString(), (*array)[3].GetString()); } - Y_UNIT_TEST(TJsonRomaTest) { + Y_UNIT_TEST(TJsonRomaTest) { TString data = "{\"test\": [ {\"name\": \"A\"} ]}"; TStringStream in; @@ -165,7 +165,7 @@ Y_UNIT_TEST_SUITE(TJsonReaderTest) { UNIT_ASSERT_VALUES_EQUAL(value["test"][0]["name"].GetString(), TString("A")); } - Y_UNIT_TEST(TJsonReadTreeWithComments) { + Y_UNIT_TEST(TJsonReadTreeWithComments) { { TString leadingCommentData = "{ // \"test\" : 1 \n}"; { @@ -209,7 +209,7 @@ Y_UNIT_TEST_SUITE(TJsonReaderTest) { } } - Y_UNIT_TEST(TJsonSignedIntegerTest) { + Y_UNIT_TEST(TJsonSignedIntegerTest) { { TStringStream in; in << "{ \"test\" : " << Min<i64>() << " }"; @@ -234,7 +234,7 @@ Y_UNIT_TEST_SUITE(TJsonReaderTest) { } // Max<i64>() + 1 } - Y_UNIT_TEST(TJsonUnsignedIntegerTest) { + Y_UNIT_TEST(TJsonUnsignedIntegerTest) { { TStringStream in; in << "{ \"test\" : 1 }"; @@ -309,7 +309,7 @@ Y_UNIT_TEST_SUITE(TJsonReaderTest) { } } // TJsonUnsignedIntegerTest - Y_UNIT_TEST(TJsonDoubleTest) { + Y_UNIT_TEST(TJsonDoubleTest) { { TStringStream in; in << "{ \"test\" : 1.0 }"; @@ -355,7 +355,7 @@ Y_UNIT_TEST_SUITE(TJsonReaderTest) { } // Max<ui64>() } // TJsonDoubleTest - Y_UNIT_TEST(TJsonInvalidTest) { + Y_UNIT_TEST(TJsonInvalidTest) { { // No exceptions mode. TStringStream in; @@ -373,7 +373,7 @@ Y_UNIT_TEST_SUITE(TJsonReaderTest) { } } - Y_UNIT_TEST(TJsonMemoryLeakTest) { + Y_UNIT_TEST(TJsonMemoryLeakTest) { // after https://clubs.at.yandex-team.ru/stackoverflow/3691 TString s = "."; NJson::TJsonValue json; diff --git a/library/cpp/json/ut/json_writer_ut.cpp b/library/cpp/json/ut/json_writer_ut.cpp index ca11d34dad9..bda63e38075 100644 --- a/library/cpp/json/ut/json_writer_ut.cpp +++ b/library/cpp/json/ut/json_writer_ut.cpp @@ -5,8 +5,8 @@ using namespace NJson; -Y_UNIT_TEST_SUITE(TJsonWriterTest) { - Y_UNIT_TEST(SimpleWriteTest) { +Y_UNIT_TEST_SUITE(TJsonWriterTest) { + Y_UNIT_TEST(SimpleWriteTest) { TString expected1 = "{\"key1\":1,\"key2\":2,\"key3\":3"; TString expected2 = expected1 + ",\"array\":[\"stroka\",false]"; TString expected3 = expected2 + "}"; @@ -41,7 +41,7 @@ Y_UNIT_TEST_SUITE(TJsonWriterTest) { UNIT_ASSERT_VALUES_EQUAL(out.Str(), expected3); } - Y_UNIT_TEST(SimpleWriteValueTest) { + Y_UNIT_TEST(SimpleWriteValueTest) { TString expected = "{\"key1\":null,\"key2\":{\"subkey1\":[1,{\"subsubkey\":\"test2\"},null,true],\"subkey2\":\"test\"}}"; TJsonValue v; v["key1"] = JSON_NULL; @@ -55,7 +55,7 @@ Y_UNIT_TEST_SUITE(TJsonWriterTest) { UNIT_ASSERT_VALUES_EQUAL(out.Str(), expected); } - Y_UNIT_TEST(FormatOutput) { + Y_UNIT_TEST(FormatOutput) { TString expected = "{\n \"key1\":null,\n \"key2\":\n {\n \"subkey1\":\n [\n 1,\n {\n \"subsubkey\":\"test2\"\n },\n null,\n true\n ],\n \"subkey2\":\"test\"\n }\n}"; TJsonValue v; v["key1"] = JSON_NULL; @@ -69,7 +69,7 @@ Y_UNIT_TEST_SUITE(TJsonWriterTest) { UNIT_ASSERT_STRINGS_EQUAL(out.Str(), expected); } - Y_UNIT_TEST(SortKeys) { + Y_UNIT_TEST(SortKeys) { TString expected = "{\"a\":null,\"j\":null,\"n\":null,\"y\":null,\"z\":null}"; TJsonValue v; v["z"] = JSON_NULL; @@ -82,7 +82,7 @@ Y_UNIT_TEST_SUITE(TJsonWriterTest) { UNIT_ASSERT_STRINGS_EQUAL(out.Str(), expected); } - Y_UNIT_TEST(SimpleUnsignedIntegerWriteTest) { + Y_UNIT_TEST(SimpleUnsignedIntegerWriteTest) { { TString expected = "{\"test\":1}"; TJsonValue v; @@ -122,7 +122,7 @@ Y_UNIT_TEST_SUITE(TJsonWriterTest) { } // 18446744073709551615 } // SimpleUnsignedIntegerWriteTest - Y_UNIT_TEST(WriteOptionalTest) { + Y_UNIT_TEST(WriteOptionalTest) { { TString expected = "{\"test\":1}"; @@ -180,7 +180,7 @@ Y_UNIT_TEST_SUITE(TJsonWriterTest) { } } - Y_UNIT_TEST(Callback) { + Y_UNIT_TEST(Callback) { NJsonWriter::TBuf json; json.WriteString("A"); UNIT_ASSERT_VALUES_EQUAL(json.Str(), "\"A\""); @@ -188,7 +188,7 @@ Y_UNIT_TEST_SUITE(TJsonWriterTest) { UNIT_ASSERT_VALUES_EQUAL(WrapJsonToCallback(json, "Foo"), "Foo(\"A\")"); } - Y_UNIT_TEST(FloatPrecision) { + Y_UNIT_TEST(FloatPrecision) { const double value = 1517933989.4242; const NJson::TJsonValue json(value); NJson::TJsonWriterConfig config; diff --git a/library/cpp/json/ut/ya.make b/library/cpp/json/ut/ya.make index 8e0362d84b2..edc8f0f3f6e 100644 --- a/library/cpp/json/ut/ya.make +++ b/library/cpp/json/ut/ya.make @@ -1,5 +1,5 @@ -OWNER(velavokr) - +OWNER(velavokr) + UNITTEST_FOR(library/cpp/json) PEERDIR( diff --git a/library/cpp/json/writer/json.h b/library/cpp/json/writer/json.h index 0aae2531b94..94a19536305 100644 --- a/library/cpp/json/writer/json.h +++ b/library/cpp/json/writer/json.h @@ -41,7 +41,7 @@ namespace NJsonWriter { class TBuf : TNonCopyable { public: - TBuf(EHtmlEscapeMode mode = HEM_DONT_ESCAPE_HTML, IOutputStream* stream = nullptr); + TBuf(EHtmlEscapeMode mode = HEM_DONT_ESCAPE_HTML, IOutputStream* stream = nullptr); TValueContext WriteString(const TStringBuf& s, EHtmlEscapeMode hem); TValueContext WriteString(const TStringBuf& s); @@ -93,7 +93,7 @@ namespace NJsonWriter { /*** Dump and forget the string constructed so far. * You may only call it if the `stream' parameter was NULL * at construction time. */ - void FlushTo(IOutputStream* stream); + void FlushTo(IOutputStream* stream); /*** Write a literal string that represents a JSON value * (string, number, object, array, bool, or null). @@ -145,7 +145,7 @@ namespace NJsonWriter { TValueContext WriteFloatImpl(TFloat f, EFloatToStringMode mode, int ndigits); private: - IOutputStream* Stream; + IOutputStream* Stream; THolder<TStringStream> StringStream; typedef TVector<const TString*> TKeys; TKeys Keys; diff --git a/library/cpp/json/writer/json_ut.cpp b/library/cpp/json/writer/json_ut.cpp index 9980555683f..c2b2ccb95c9 100644 --- a/library/cpp/json/writer/json_ut.cpp +++ b/library/cpp/json/writer/json_ut.cpp @@ -6,8 +6,8 @@ #include <limits> -Y_UNIT_TEST_SUITE(JsonWriter) { - Y_UNIT_TEST(Struct) { +Y_UNIT_TEST_SUITE(JsonWriter) { + Y_UNIT_TEST(Struct) { NJsonWriter::TBuf w; w.BeginList(); w.BeginObject() @@ -29,21 +29,21 @@ Y_UNIT_TEST_SUITE(JsonWriter) { const char* exp = "[{\"key\":\"value\",\"xk\":13,\"key2\":[{},{}]},43,\"x\",\"...\"]"; UNIT_ASSERT_EQUAL(w.Str(), exp); } - Y_UNIT_TEST(EscapedString) { + Y_UNIT_TEST(EscapedString) { NJsonWriter::TBuf w(NJsonWriter::HEM_ESCAPE_HTML); w.WriteString(" \n \r \t \007 \b \f ' <tag> &ent; \"txt\" "); TString ws = w.Str(); const char* exp = "\" \\n \\r \\t \\u0007 \\b \\f ' <tag> &ent; "txt" \""; UNIT_ASSERT_STRINGS_EQUAL(ws.c_str(), exp); } - Y_UNIT_TEST(UnescapedString) { + Y_UNIT_TEST(UnescapedString) { NJsonWriter::TBuf w; w.WriteString(" \n \r \t \b \f '; -- <tag> &ent; \"txt\"", NJsonWriter::HEM_DONT_ESCAPE_HTML); TString ws = w.Str(); const char* exp = "\" \\n \\r \\t \\b \\f \\u0027; -- \\u003Ctag\\u003E &ent; \\\"txt\\\"\""; UNIT_ASSERT_STRINGS_EQUAL(ws.c_str(), exp); } - Y_UNIT_TEST(UnescapedChaining) { + Y_UNIT_TEST(UnescapedChaining) { NJsonWriter::TBuf w(NJsonWriter::HEM_DONT_ESCAPE_HTML); w.UnsafeWriteRawBytes("(", 1); w.BeginList().WriteString("<>&'\\").BeginList(); @@ -52,27 +52,27 @@ Y_UNIT_TEST_SUITE(JsonWriter) { const char* exp = "([\"\\u003C\\u003E&\\u0027\\\\\",[]]"; UNIT_ASSERT_STRINGS_EQUAL(ws.c_str(), exp); } - Y_UNIT_TEST(Utf8) { + Y_UNIT_TEST(Utf8) { TString ws = NJsonWriter::TBuf().WriteString("яЯ σΣ ש א").Str(); const char* exp = "\"яЯ σΣ ש א\""; UNIT_ASSERT_STRINGS_EQUAL(ws.c_str(), exp); } - Y_UNIT_TEST(WrongObject) { + Y_UNIT_TEST(WrongObject) { NJsonWriter::TBuf w; w.BeginObject(); UNIT_ASSERT_EXCEPTION(w.WriteString("hehe"), NJsonWriter::TError); } - Y_UNIT_TEST(WrongList) { + Y_UNIT_TEST(WrongList) { NJsonWriter::TBuf w; w.BeginList(); UNIT_ASSERT_EXCEPTION(w.WriteKey("hehe"), NJsonWriter::TError); } - Y_UNIT_TEST(Incomplete) { + Y_UNIT_TEST(Incomplete) { NJsonWriter::TBuf w; w.BeginList(); UNIT_ASSERT_EXCEPTION(w.Str(), NJsonWriter::TError); } - Y_UNIT_TEST(BareKey) { + Y_UNIT_TEST(BareKey) { NJsonWriter::TBuf w; w.BeginObject() .CompatWriteKeyWithoutQuotes("p") @@ -84,24 +84,24 @@ Y_UNIT_TEST_SUITE(JsonWriter) { const char* exp = "{p:1,n:0}"; UNIT_ASSERT_STRINGS_EQUAL(ws.c_str(), exp); } - Y_UNIT_TEST(UnescapedStringInObject) { + Y_UNIT_TEST(UnescapedStringInObject) { NJsonWriter::TBuf w(NJsonWriter::HEM_DONT_ESCAPE_HTML); w.BeginObject().WriteKey("key").WriteString("</&>'").EndObject(); TString ws = w.Str(); const char* exp = "{\"key\":\"\\u003C\\/&\\u003E\\u0027\"}"; UNIT_ASSERT_STRINGS_EQUAL(ws.c_str(), exp); } - Y_UNIT_TEST(ForeignStreamStr) { + Y_UNIT_TEST(ForeignStreamStr) { NJsonWriter::TBuf w(NJsonWriter::HEM_DONT_ESCAPE_HTML, &Cerr); UNIT_ASSERT_EXCEPTION(w.Str(), NJsonWriter::TError); } - Y_UNIT_TEST(ForeignStreamValue) { + Y_UNIT_TEST(ForeignStreamValue) { TStringStream ss; NJsonWriter::TBuf w(NJsonWriter::HEM_DONT_ESCAPE_HTML, &ss); w.WriteInt(1543); UNIT_ASSERT_STRINGS_EQUAL(ss.Str(), "1543"); } - Y_UNIT_TEST(Indentation) { + Y_UNIT_TEST(Indentation) { NJsonWriter::TBuf w(NJsonWriter::HEM_DONT_ESCAPE_HTML); w.SetIndentSpaces(2); w.BeginList() @@ -124,7 +124,7 @@ Y_UNIT_TEST_SUITE(JsonWriter) { "]"; UNIT_ASSERT_STRINGS_EQUAL(exp, w.Str()); } - Y_UNIT_TEST(WriteJsonValue) { + Y_UNIT_TEST(WriteJsonValue) { using namespace NJson; TJsonValue val; val.AppendValue(1); @@ -142,7 +142,7 @@ Y_UNIT_TEST_SUITE(JsonWriter) { const char exp[] = "[1,\"2\",3.5,{\"key\":\"value\"},null]"; UNIT_ASSERT_STRINGS_EQUAL(exp, w.Str()); } - Y_UNIT_TEST(WriteJsonValueSorted) { + Y_UNIT_TEST(WriteJsonValueSorted) { using namespace NJson; TJsonValue val; val.InsertValue("1", TJsonValue(1)); @@ -159,35 +159,35 @@ Y_UNIT_TEST_SUITE(JsonWriter) { const char exp[] = "{\"0\":{\"succ\":1,\"zero\":0},\"1\":1,\"2\":2}"; UNIT_ASSERT_STRINGS_EQUAL(exp, w.Str()); } - Y_UNIT_TEST(Unescaped) { + Y_UNIT_TEST(Unescaped) { NJsonWriter::TBuf buf(NJsonWriter::HEM_UNSAFE); buf.WriteString("</security>'"); UNIT_ASSERT_STRINGS_EQUAL("\"</security>'\"", buf.Str()); } - Y_UNIT_TEST(LittleBobbyJsonp) { + Y_UNIT_TEST(LittleBobbyJsonp) { NJsonWriter::TBuf buf; buf.WriteString("hello\xe2\x80\xa8\xe2\x80\xa9stranger"); UNIT_ASSERT_STRINGS_EQUAL("\"hello\\u2028\\u2029stranger\"", buf.Str()); } - Y_UNIT_TEST(LittleBobbyInvalid) { + Y_UNIT_TEST(LittleBobbyInvalid) { NJsonWriter::TBuf buf; TStringBuf incomplete("\xe2\x80\xa8", 2); buf.WriteString(incomplete); // garbage in - garbage out UNIT_ASSERT_STRINGS_EQUAL("\"\xe2\x80\"", buf.Str()); } - Y_UNIT_TEST(OverlyZealous) { + Y_UNIT_TEST(OverlyZealous) { NJsonWriter::TBuf buf; buf.WriteString("—"); UNIT_ASSERT_STRINGS_EQUAL("\"—\"", buf.Str()); } - Y_UNIT_TEST(RelaxedEscaping) { + Y_UNIT_TEST(RelaxedEscaping) { NJsonWriter::TBuf buf(NJsonWriter::HEM_RELAXED); buf.WriteString("</>"); UNIT_ASSERT_STRINGS_EQUAL("\"\\u003C/\\u003E\"", buf.Str()); } - Y_UNIT_TEST(FloatFormatting) { + Y_UNIT_TEST(FloatFormatting) { NJsonWriter::TBuf buf(NJsonWriter::HEM_DONT_ESCAPE_HTML); buf.BeginList() .WriteFloat(0.12345678987654321f) @@ -206,7 +206,7 @@ Y_UNIT_TEST_SUITE(JsonWriter) { UNIT_ASSERT_STRINGS_EQUAL(exp, buf.Str()); } - Y_UNIT_TEST(NanFormatting) { + Y_UNIT_TEST(NanFormatting) { { NJsonWriter::TBuf buf; buf.BeginObject(); diff --git a/library/cpp/json/writer/json_value.cpp b/library/cpp/json/writer/json_value.cpp index c61e8d1dc43..27da313fd4c 100644 --- a/library/cpp/json/writer/json_value.cpp +++ b/library/cpp/json/writer/json_value.cpp @@ -18,7 +18,7 @@ static bool AreJsonMapsEqual(const NJson::TJsonValue& lhs, const NJson::TJsonValue& rhs) { using namespace NJson; - Y_VERIFY(lhs.GetType() == JSON_MAP, "lhs has not a JSON_MAP type."); + Y_VERIFY(lhs.GetType() == JSON_MAP, "lhs has not a JSON_MAP type."); if (rhs.GetType() != JSON_MAP) return false; @@ -30,12 +30,12 @@ AreJsonMapsEqual(const NJson::TJsonValue& lhs, const NJson::TJsonValue& rhs) { if (lhsMap.size() != rhsMap.size()) return false; - for (const auto& lhsIt : lhsMap) { + for (const auto& lhsIt : lhsMap) { TMapType::const_iterator rhsIt = rhsMap.find(lhsIt.first); if (rhsIt == rhsMap.end()) return false; - if (lhsIt.second != rhsIt->second) + if (lhsIt.second != rhsIt->second) return false; } @@ -46,7 +46,7 @@ static bool AreJsonArraysEqual(const NJson::TJsonValue& lhs, const NJson::TJsonValue& rhs) { using namespace NJson; - Y_VERIFY(lhs.GetType() == JSON_ARRAY, "lhs has not a JSON_ARRAY type."); + Y_VERIFY(lhs.GetType() == JSON_ARRAY, "lhs has not a JSON_ARRAY type."); if (rhs.GetType() != JSON_ARRAY) return false; @@ -1099,7 +1099,7 @@ namespace NJson { } template <> -void Out<NJson::TJsonValue>(IOutputStream& out, const NJson::TJsonValue& v) { +void Out<NJson::TJsonValue>(IOutputStream& out, const NJson::TJsonValue& v) { NJsonWriter::TBuf buf(NJsonWriter::HEM_DONT_ESCAPE_HTML, &out); buf.WriteJsonValue(&v); } diff --git a/library/cpp/json/writer/json_value_ut.cpp b/library/cpp/json/writer/json_value_ut.cpp index dc7f6affdff..ea33ef08882 100644 --- a/library/cpp/json/writer/json_value_ut.cpp +++ b/library/cpp/json/writer/json_value_ut.cpp @@ -6,8 +6,8 @@ using namespace NJson; -Y_UNIT_TEST_SUITE(TJsonValueTest) { - Y_UNIT_TEST(UndefTest) { +Y_UNIT_TEST_SUITE(TJsonValueTest) { + Y_UNIT_TEST(UndefTest) { TJsonValue undef; TJsonValue null(JSON_NULL); TJsonValue _false(false); @@ -36,7 +36,7 @@ Y_UNIT_TEST_SUITE(TJsonValueTest) { UNIT_ASSERT(undef != emptyMap); } - Y_UNIT_TEST(DefaultCompareTest) { + Y_UNIT_TEST(DefaultCompareTest) { { TJsonValue lhs; TJsonValue rhs; @@ -52,14 +52,14 @@ Y_UNIT_TEST_SUITE(TJsonValueTest) { } } - Y_UNIT_TEST(NullCompareTest) { + Y_UNIT_TEST(NullCompareTest) { TJsonValue lhs(JSON_NULL); TJsonValue rhs(JSON_NULL); UNIT_ASSERT(lhs == rhs); UNIT_ASSERT(rhs == lhs); } - Y_UNIT_TEST(StringCompareTest) { + Y_UNIT_TEST(StringCompareTest) { { TJsonValue lhs(JSON_STRING); TJsonValue rhs(JSON_STRING); @@ -89,7 +89,7 @@ Y_UNIT_TEST_SUITE(TJsonValueTest) { } } - Y_UNIT_TEST(ArrayCompareTest) { + Y_UNIT_TEST(ArrayCompareTest) { { TJsonValue lhs(JSON_ARRAY); TJsonValue rhs(JSON_ARRAY); @@ -139,7 +139,7 @@ Y_UNIT_TEST_SUITE(TJsonValueTest) { } } - Y_UNIT_TEST(CompareTest) { + Y_UNIT_TEST(CompareTest) { { TJsonValue lhs; lhs.InsertValue("null value", TJsonValue(JSON_NULL)); @@ -209,7 +209,7 @@ Y_UNIT_TEST_SUITE(TJsonValueTest) { } } - Y_UNIT_TEST(SwapTest) { + Y_UNIT_TEST(SwapTest) { { TJsonValue lhs; lhs.InsertValue("a", "b"); @@ -233,7 +233,7 @@ Y_UNIT_TEST_SUITE(TJsonValueTest) { } } - Y_UNIT_TEST(GetValueByPathTest) { + Y_UNIT_TEST(GetValueByPathTest) { { TJsonValue lhs; TJsonValue first; @@ -285,7 +285,7 @@ Y_UNIT_TEST_SUITE(TJsonValueTest) { } } - Y_UNIT_TEST(GetValueByPathConstTest) { + Y_UNIT_TEST(GetValueByPathConstTest) { TJsonValue lhs; TJsonValue first; TJsonValue second; @@ -339,7 +339,7 @@ Y_UNIT_TEST_SUITE(TJsonValueTest) { UNIT_ASSERT(third.GetValueByPath("t.[1].c.e", '.')->GetStringRobust() == "f"); } - Y_UNIT_TEST(EraseValueFromArray) { + Y_UNIT_TEST(EraseValueFromArray) { { TJsonValue vec; vec.AppendValue(TJsonValue(0)); @@ -378,7 +378,7 @@ Y_UNIT_TEST_SUITE(TJsonValueTest) { } } - Y_UNIT_TEST(NonConstMethodsTest) { + Y_UNIT_TEST(NonConstMethodsTest) { { TJsonValue src; TJsonValue value1; @@ -506,7 +506,7 @@ Y_UNIT_TEST_SUITE(TJsonValueTest) { } } - Y_UNIT_TEST(NonexistentFieldAccessTest) { + Y_UNIT_TEST(NonexistentFieldAccessTest) { { TJsonValue json; json.InsertValue("some", "key"); @@ -518,7 +518,7 @@ Y_UNIT_TEST_SUITE(TJsonValueTest) { } } - Y_UNIT_TEST(DefaultValuesTest) { + Y_UNIT_TEST(DefaultValuesTest) { { TJsonValue json; json.InsertValue("some", "key"); @@ -540,7 +540,7 @@ Y_UNIT_TEST_SUITE(TJsonValueTest) { } } - Y_UNIT_TEST(GetArrayPointerInArrayTest) { + Y_UNIT_TEST(GetArrayPointerInArrayTest) { TJsonValue outer; { TJsonValue json; @@ -555,7 +555,7 @@ Y_UNIT_TEST_SUITE(TJsonValueTest) { UNIT_ASSERT_VALUES_EQUAL((*array)[1], 2); } - Y_UNIT_TEST(GetArrayPointerInMapTest) { + Y_UNIT_TEST(GetArrayPointerInMapTest) { TJsonValue outer; { TJsonValue json; @@ -570,7 +570,7 @@ Y_UNIT_TEST_SUITE(TJsonValueTest) { UNIT_ASSERT_VALUES_EQUAL((*array)[1], 2); } - Y_UNIT_TEST(GetMapPointerInArrayTest) { + Y_UNIT_TEST(GetMapPointerInArrayTest) { TJsonValue outer; { TJsonValue json; @@ -585,7 +585,7 @@ Y_UNIT_TEST_SUITE(TJsonValueTest) { UNIT_ASSERT_VALUES_EQUAL((*map).at("b"), 2); } - Y_UNIT_TEST(GetMapPointerInMapTest) { + Y_UNIT_TEST(GetMapPointerInMapTest) { TJsonValue outer; { TJsonValue json; @@ -600,14 +600,14 @@ Y_UNIT_TEST_SUITE(TJsonValueTest) { UNIT_ASSERT_VALUES_EQUAL((*map).at("b"), 2); } - Y_UNIT_TEST(GetIntegerRobustBignumStringTest) { + Y_UNIT_TEST(GetIntegerRobustBignumStringTest) { TString value = "1626862681464633683"; TJsonValue json(value); UNIT_ASSERT_VALUES_EQUAL(json.GetUIntegerRobust(), FromString<ui64>(value)); UNIT_ASSERT_VALUES_EQUAL(json.GetIntegerRobust(), FromString<i64>(value)); } - Y_UNIT_TEST(MoveSubpartToSelf) { + Y_UNIT_TEST(MoveSubpartToSelf) { TJsonValue json; json[0] = "testing 0"; json[1] = "testing 1"; diff --git a/library/cpp/json/yson/json2yson_ut.cpp b/library/cpp/json/yson/json2yson_ut.cpp index 9eb23354cf0..a486b625c2e 100644 --- a/library/cpp/json/yson/json2yson_ut.cpp +++ b/library/cpp/json/yson/json2yson_ut.cpp @@ -23,7 +23,7 @@ static TString GetRequestsWithDecoding(const TString& inputPath, const NBlockCod return requests; } -Y_UNIT_TEST_SUITE(Json2Yson) { +Y_UNIT_TEST_SUITE(Json2Yson) { Y_UNIT_TEST(NOAPACHE_REQUESTS) { const ui32 warmUpRetries = 5; const TVector<double> percentiles = {0.25, 0.5, 0.6, 0.7, 0.75, 0.8, 0.85, 0.9, 0.95, 0.97, 0.99, 1.0}; diff --git a/library/cpp/lfalloc/alloc_profiler/profiler.h b/library/cpp/lfalloc/alloc_profiler/profiler.h index 4ea49b9dcc8..db5cd610fc8 100644 --- a/library/cpp/lfalloc/alloc_profiler/profiler.h +++ b/library/cpp/lfalloc/alloc_profiler/profiler.h @@ -5,7 +5,7 @@ #include <library/cpp/lfalloc/dbg_info/dbg_info.h> #include <util/generic/noncopyable.h> -#include <util/stream/output.h> +#include <util/stream/output.h> namespace NAllocProfiler { diff --git a/library/cpp/lfalloc/alloc_profiler/stackcollect.h b/library/cpp/lfalloc/alloc_profiler/stackcollect.h index 80715ed7cb5..ac6aa9ebb91 100644 --- a/library/cpp/lfalloc/alloc_profiler/stackcollect.h +++ b/library/cpp/lfalloc/alloc_profiler/stackcollect.h @@ -5,7 +5,7 @@ #include <util/generic/noncopyable.h> #include <util/generic/ptr.h> -#include <util/stream/output.h> +#include <util/stream/output.h> namespace NAllocProfiler { diff --git a/library/cpp/lfalloc/lf_allocX64.h b/library/cpp/lfalloc/lf_allocX64.h index fd2a906d6ff..510d02da983 100644 --- a/library/cpp/lfalloc/lf_allocX64.h +++ b/library/cpp/lfalloc/lf_allocX64.h @@ -116,7 +116,7 @@ static inline long AtomicSub(TAtomic& a, long b) { #ifndef _darwin_ #ifndef Y_ARRAY_SIZE -#define Y_ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0])) +#define Y_ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0])) #endif #ifndef NDEBUG @@ -261,7 +261,7 @@ static volatile int freeChunkCount; static void AddFreeChunk(uintptr_t chunkId) { chunkSizeIdx[chunkId] = -1; - if (Y_UNLIKELY(freeChunkCount == FREE_CHUNK_ARR_BUF)) + if (Y_UNLIKELY(freeChunkCount == FREE_CHUNK_ARR_BUF)) NMalloc::AbortFromCorruptedAllocator("free chunks array overflowed"); freeChunkArr[freeChunkCount++] = chunkId; } @@ -303,7 +303,7 @@ enum EMMapMode { #ifndef _MSC_VER inline void VerifyMmapResult(void* result) { - if (Y_UNLIKELY(result == MAP_FAILED)) + if (Y_UNLIKELY(result == MAP_FAILED)) NMalloc::AbortFromCorruptedAllocator("negative size requested? or just out of mem"); } #endif @@ -336,7 +336,7 @@ static char* AllocWithMMapLinuxImpl(uintptr_t sz, EMMapMode mode) { char* prevAllocPtr = *areaPtr; char* nextAllocPtr = prevAllocPtr + sz; if (uintptr_t(nextAllocPtr - (char*)nullptr) >= areaFinish) { - if (Y_UNLIKELY(wrapped)) { + if (Y_UNLIKELY(wrapped)) { NMalloc::AbortFromCorruptedAllocator("virtual memory is over fragmented"); } // wrap after all area is used @@ -369,13 +369,13 @@ static char* AllocWithMMap(uintptr_t sz, EMMapMode mode) { char* largeBlock = (char*)VirtualAlloc(0, sz, MEM_RESERVE, PAGE_READWRITE); if (Y_UNLIKELY(largeBlock == nullptr)) NMalloc::AbortFromCorruptedAllocator("out of memory"); - if (Y_UNLIKELY(uintptr_t(((char*)largeBlock - ALLOC_START) + sz) >= N_MAX_WORKSET_SIZE)) + if (Y_UNLIKELY(uintptr_t(((char*)largeBlock - ALLOC_START) + sz) >= N_MAX_WORKSET_SIZE)) NMalloc::AbortFromCorruptedAllocator("out of working set, something has broken"); #else #if defined(_freebsd_) || !defined(_64_) char* largeBlock = (char*)mmap(0, sz, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, -1, 0); VerifyMmapResult(largeBlock); - if (Y_UNLIKELY(uintptr_t(((char*)largeBlock - ALLOC_START) + sz) >= N_MAX_WORKSET_SIZE)) + if (Y_UNLIKELY(uintptr_t(((char*)largeBlock - ALLOC_START) + sz) >= N_MAX_WORKSET_SIZE)) NMalloc::AbortFromCorruptedAllocator("out of working set, something has broken"); #else char* largeBlock = AllocWithMMapLinuxImpl(sz, mode); @@ -452,7 +452,7 @@ static void* LargeBlockAlloc(size_t _nSize, ELFAllocCounter counter) { size_t pgCount = (_nSize + 4095) / 4096; #ifdef _MSC_VER char* pRes = (char*)VirtualAlloc(0, (pgCount + 1) * 4096ll, MEM_COMMIT, PAGE_READWRITE); - if (Y_UNLIKELY(pRes == 0)) { + if (Y_UNLIKELY(pRes == 0)) { NMalloc::AbortFromCorruptedAllocator("out of memory"); } #else @@ -492,12 +492,12 @@ static void* LargeBlockAlloc(size_t _nSize, ELFAllocCounter counter) { #ifndef _MSC_VER static void FreeAllLargeBlockMem() { - for (auto& lbFreePtr : lbFreePtrs) { + for (auto& lbFreePtr : lbFreePtrs) { for (int i = 0; i < LB_BUF_SIZE; ++i) { - void* p = lbFreePtr[i]; + void* p = lbFreePtr[i]; if (p == nullptr) continue; - if (DoCas(&lbFreePtr[i], (void*)nullptr, p) == p) { + if (DoCas(&lbFreePtr[i], (void*)nullptr, p) == p) { int pgCount = TLargeBlk::As(p)->Pages; AtomicAdd(lbFreePageCount, -pgCount); LargeBlockUnmap(p, pgCount); @@ -782,7 +782,7 @@ static bool DefragmentMem() { IncrementCounter(CT_DEGRAGMENT_CNT, 1); int* nFreeCount = (int*)SystemAlloc(N_CHUNKS * sizeof(int)); - if (Y_UNLIKELY(!nFreeCount)) { + if (Y_UNLIKELY(!nFreeCount)) { //__debugbreak(); NMalloc::AbortFromCorruptedAllocator("debugbreak"); } @@ -792,7 +792,7 @@ static bool DefragmentMem() { for (int nSizeIdx = 0; nSizeIdx < N_SIZES; ++nSizeIdx) { wholeLists[nSizeIdx] = (TFreeListGroup*)globalFreeLists[nSizeIdx].GetWholeList(); for (TFreeListGroup* g = wholeLists[nSizeIdx]; g; g = g->Next) { - for (auto pData : g->Ptrs) { + for (auto pData : g->Ptrs) { if (pData) { uintptr_t nChunk = (pData - ALLOC_START) / N_CHUNK_SIZE; ++nFreeCount[nChunk]; @@ -816,12 +816,12 @@ static bool DefragmentMem() { } } if (bRes) { - for (auto& wholeList : wholeLists) { - TFreeListGroup** ppPtr = &wholeList; + for (auto& wholeList : wholeLists) { + TFreeListGroup** ppPtr = &wholeList; while (*ppPtr) { TFreeListGroup* g = *ppPtr; int dst = 0; - for (auto pData : g->Ptrs) { + for (auto pData : g->Ptrs) { if (pData) { uintptr_t nChunk = (pData - ALLOC_START) / N_CHUNK_SIZE; if (nFreeCount[nChunk] == 0) @@ -964,9 +964,9 @@ static Y_FORCE_INLINE int TakeBlocksFromGlobalFreeList(int nSizeIdx, char** buf) TFreeListGroup* g = (TFreeListGroup*)fl.Alloc(); if (g) { int resCount = 0; - for (auto& ptr : g->Ptrs) { - if (ptr) - buf[resCount++] = ptr; + for (auto& ptr : g->Ptrs) { + if (ptr) + buf[resCount++] = ptr; else break; } @@ -1116,8 +1116,8 @@ struct TThreadAllocInfo { void Init(TThreadAllocInfo** pHead) { memset(this, 0, sizeof(*this)); - for (auto& i : FreePtrIndex) - i = THREAD_BUF; + for (auto& i : FreePtrIndex) + i = THREAD_BUF; #ifdef _win_ BOOL b = DuplicateHandle( GetCurrentProcess(), GetCurrentThread(), @@ -1146,11 +1146,11 @@ struct TThreadAllocInfo { #endif } void Done() { - for (auto sizeIdx : FreePtrIndex) { + for (auto sizeIdx : FreePtrIndex) { Y_ASSERT_NOBT(sizeIdx == THREAD_BUF); } - for (auto& localCounter : LocalCounters) { - localCounter.Flush(); + for (auto& localCounter : LocalCounters) { + localCounter.Flush(); } #if defined(LFALLOC_DBG) for (int tag = 0; tag < DBG_ALLOC_MAX_TAG; ++tag) { @@ -1740,13 +1740,13 @@ static void DumpMemoryBlockUtilizationLocked() { int nEntriesTotal = N_CHUNK_SIZE / nSize; memset(entries, 0, nEntriesTotal); for (TFreeListGroup* g = wholeLists[nSizeIdx]; g; g = g->Next) { - for (auto& ptr : g->Ptrs) - cs.CheckBlock(ptr); + for (auto& ptr : g->Ptrs) + cs.CheckBlock(ptr); } TChunkStats csGB(k, nSize, entries); if (nSizeIdx == FREE_LIST_GROUP_SIZEIDX) { - for (auto g : wholeLists) { - for (; g; g = g->Next) + for (auto g : wholeLists) { + for (; g; g = g->Next) csGB.CheckBlock((char*)g); } for (char* blk = bfList; blk; blk = *(char**)blk) @@ -1769,9 +1769,9 @@ static void DumpMemoryBlockUtilizationLocked() { pages[(nShift + nDelta) / N_PAGE_SIZE] |= nBit; } i64 nBadPages = 0; - for (auto page : pages) { - nBadPages += page == 3; - nTotalPages += page != 1; + for (auto page : pages) { + nBadPages += page == 3; + nTotalPages += page != 1; } DebugTraceMMgr("entry = %lld; size = %lld; free = %lld; system %lld; utilisation = %g%%, fragmentation = %g%%\n", k, nSize, cs.FreeCount * nSize, csGB.FreeCount * nSize, @@ -1869,7 +1869,7 @@ static const char* LFAlloc_GetParam(const char* param) { } static Y_FORCE_INLINE int LFPosixMemalign(void** memptr, size_t alignment, size_t size) { - if (Y_UNLIKELY(alignment > 4096)) { + if (Y_UNLIKELY(alignment > 4096)) { const char* error = "Larger alignment are not guaranteed with this implementation\n"; #ifdef _win_ OutputDebugStringA(error); diff --git a/library/cpp/lfalloc/ya.make b/library/cpp/lfalloc/ya.make index cace05f9d80..7cb1ff85230 100644 --- a/library/cpp/lfalloc/ya.make +++ b/library/cpp/lfalloc/ya.make @@ -1,7 +1,7 @@ LIBRARY() -OWNER(gulin) - +OWNER(gulin) + NO_UTIL() NO_COMPILER_WARNINGS() diff --git a/library/cpp/linear_regression/linear_regression.h b/library/cpp/linear_regression/linear_regression.h index e57de5ff6cc..20b3ae1e539 100644 --- a/library/cpp/linear_regression/linear_regression.h +++ b/library/cpp/linear_regression/linear_regression.h @@ -146,12 +146,12 @@ public: bool Add(const double* featuresBegin, const double* featuresEnd, const double* goalsBegin, const double* weightsBegin); bool Add(const TVector<double>& features, const TVector<double>& goals) { - Y_ASSERT(features.size() == goals.size()); + Y_ASSERT(features.size() == goals.size()); return Add(features.data(), features.data() + features.size(), goals.data()); } bool Add(const TVector<double>& features, const TVector<double>& goals, const TVector<double>& weights) { - Y_ASSERT(features.size() == goals.size() && features.size() == weights.size()); + Y_ASSERT(features.size() == goals.size() && features.size() == weights.size()); return Add(features.data(), features.data() + features.size(), goals.data(), weights.data()); } @@ -239,7 +239,7 @@ struct TTransformationParameters { double FeatureOffset = 0.; double FeatureNormalizer = 1.; - Y_SAVELOAD_DEFINE(RegressionFactor, + Y_SAVELOAD_DEFINE(RegressionFactor, RegressionIntercept, FeatureOffset, FeatureNormalizer); @@ -251,7 +251,7 @@ private: TTransformationParameters TransformationParameters; public: - Y_SAVELOAD_DEFINE(TransformationType, TransformationParameters); + Y_SAVELOAD_DEFINE(TransformationType, TransformationParameters); TFeaturesTransformer() = default; @@ -273,7 +273,7 @@ public: return TransformationParameters.RegressionIntercept + TransformationParameters.RegressionFactor * transformedValue; } } - Y_ASSERT(0); + Y_ASSERT(0); return 0.; } }; diff --git a/library/cpp/linear_regression/linear_regression_ut.cpp b/library/cpp/linear_regression/linear_regression_ut.cpp index e71a16b67a1..991a95c0d09 100644 --- a/library/cpp/linear_regression/linear_regression_ut.cpp +++ b/library/cpp/linear_regression/linear_regression_ut.cpp @@ -13,8 +13,8 @@ namespace { } } -Y_UNIT_TEST_SUITE(TLinearRegressionTest) { - Y_UNIT_TEST(MeanAndDeviationTest) { +Y_UNIT_TEST_SUITE(TLinearRegressionTest) { + Y_UNIT_TEST(MeanAndDeviationTest) { TVector<double> arguments; TVector<double> weights; @@ -77,7 +77,7 @@ Y_UNIT_TEST_SUITE(TLinearRegressionTest) { ValueIsCorrect(deviationCalculator.GetDeviation(), checkRemovingDeviationCalculator.GetDeviation(), 1e-5); } - Y_UNIT_TEST(CovariationTest) { + Y_UNIT_TEST(CovariationTest) { TVector<double> firstValues; TVector<double> secondValues; TVector<double> weights; @@ -176,15 +176,15 @@ Y_UNIT_TEST_SUITE(TLinearRegressionTest) { } } - Y_UNIT_TEST(FastSLRTest) { + Y_UNIT_TEST(FastSLRTest) { SLRTest<TFastSLRSolver>(); } - Y_UNIT_TEST(KahanSLRTest) { + Y_UNIT_TEST(KahanSLRTest) { SLRTest<TKahanSLRSolver>(); } - Y_UNIT_TEST(SLRTest) { + Y_UNIT_TEST(SLRTest) { SLRTest<TSLRSolver>(); } @@ -231,11 +231,11 @@ Y_UNIT_TEST_SUITE(TLinearRegressionTest) { UNIT_ASSERT_DOUBLES_EQUAL(lrSolver.SumSquaredErrors(), expectedSumSquaredErrors, expectedSumSquaredErrors * 0.01); } - Y_UNIT_TEST(FastLRTest) { + Y_UNIT_TEST(FastLRTest) { LinearRegressionTest<TFastLinearRegressionSolver>(); } - Y_UNIT_TEST(LRTest) { + Y_UNIT_TEST(LRTest) { LinearRegressionTest<TLinearRegressionSolver>(); } @@ -275,31 +275,31 @@ Y_UNIT_TEST_SUITE(TLinearRegressionTest) { UNIT_ASSERT_DOUBLES_EQUAL(rmse, 0., 1e-3); } - Y_UNIT_TEST(SigmaTest100) { + Y_UNIT_TEST(SigmaTest100) { TransformationTest(ETransformationType::TT_SIGMA, 100); } - Y_UNIT_TEST(SigmaTest1000) { + Y_UNIT_TEST(SigmaTest1000) { TransformationTest(ETransformationType::TT_SIGMA, 1000); } - Y_UNIT_TEST(SigmaTest10000) { + Y_UNIT_TEST(SigmaTest10000) { TransformationTest(ETransformationType::TT_SIGMA, 10000); } - Y_UNIT_TEST(SigmaTest100000) { + Y_UNIT_TEST(SigmaTest100000) { TransformationTest(ETransformationType::TT_SIGMA, 100000); } - Y_UNIT_TEST(SigmaTest1000000) { + Y_UNIT_TEST(SigmaTest1000000) { TransformationTest(ETransformationType::TT_SIGMA, 1000000); } - Y_UNIT_TEST(SigmaTest10000000) { + Y_UNIT_TEST(SigmaTest10000000) { TransformationTest(ETransformationType::TT_SIGMA, 10000000); } - Y_UNIT_TEST(ResetCalculatorTest) { + Y_UNIT_TEST(ResetCalculatorTest) { TVector<double> arguments; TVector<double> weights; const double eps = 1e-10; diff --git a/library/cpp/linear_regression/welford.h b/library/cpp/linear_regression/welford.h index ee865d66937..a39800974c0 100644 --- a/library/cpp/linear_regression/welford.h +++ b/library/cpp/linear_regression/welford.h @@ -11,7 +11,7 @@ private: TKahanAccumulator<double> SumWeights; public: - Y_SAVELOAD_DEFINE(Mean, SumWeights); + Y_SAVELOAD_DEFINE(Mean, SumWeights); void Multiply(const double value); void Add(const double value, const double weight = 1.); @@ -40,7 +40,7 @@ private: TKahanAccumulator<double> SumWeights; public: - Y_SAVELOAD_DEFINE(Covariation, FirstValueMean, SecondValueMean, SumWeights); + Y_SAVELOAD_DEFINE(Covariation, FirstValueMean, SecondValueMean, SumWeights); void Add(const double firstValue, const double secondValue, const double weight = 1.); void Remove(const double firstValue, const double secondValue, const double weight = 1.); @@ -62,7 +62,7 @@ private: TMeanCalculator MeanCalculator; public: - Y_SAVELOAD_DEFINE(Deviation, MeanCalculator); + Y_SAVELOAD_DEFINE(Deviation, MeanCalculator); void Add(const double value, const double weight = 1.); void Remove(const double value, const double weight = 1.); diff --git a/library/cpp/logger/backend.cpp b/library/cpp/logger/backend.cpp index b26bf5e88ce..069c9768ef7 100644 --- a/library/cpp/logger/backend.cpp +++ b/library/cpp/logger/backend.cpp @@ -24,7 +24,7 @@ namespace { return; } } - Y_FAIL("Incorrect pointer for log backend"); + Y_FAIL("Incorrect pointer for log backend"); } void Reopen(bool flush) { diff --git a/library/cpp/logger/backend.h b/library/cpp/logger/backend.h index d088726d6d4..36023d048d7 100644 --- a/library/cpp/logger/backend.h +++ b/library/cpp/logger/backend.h @@ -1,14 +1,14 @@ #pragma once -#include "priority.h" - +#include "priority.h" + #include <util/generic/noncopyable.h> - + #include <cstddef> struct TLogRecord; -// NOTE: be aware that all `TLogBackend`s are registred in singleton. +// NOTE: be aware that all `TLogBackend`s are registred in singleton. class TLogBackend: public TNonCopyable { public: TLogBackend() noexcept; diff --git a/library/cpp/logger/element.h b/library/cpp/logger/element.h index fc9bff851ff..0066270efca 100644 --- a/library/cpp/logger/element.h +++ b/library/cpp/logger/element.h @@ -21,7 +21,7 @@ public: template <class T> inline TLogElement& operator<<(const T& t) { - static_cast<IOutputStream&>(*this) << t; + static_cast<IOutputStream&>(*this) << t; return *this; } diff --git a/library/cpp/logger/global/common.h b/library/cpp/logger/global/common.h index 7dcf650decb..6f06d6ae4c8 100644 --- a/library/cpp/logger/global/common.h +++ b/library/cpp/logger/global/common.h @@ -135,7 +135,7 @@ TSimpleSharedPtr<TLogElement> GetLoggerForce(TLog& log, const TLogRecordContext& namespace NPrivateGlobalLogger { struct TEatStream { - Y_FORCE_INLINE bool operator|(const IOutputStream&) const { + Y_FORCE_INLINE bool operator|(const IOutputStream&) const { return true; } }; diff --git a/library/cpp/logger/global/global.h b/library/cpp/logger/global/global.h index cbe71b16ea5..6940d06fb79 100644 --- a/library/cpp/logger/global/global.h +++ b/library/cpp/logger/global/global.h @@ -10,7 +10,7 @@ void DoInitGlobalLog(const TString& logType, const int logLevel, const bool rota void DoInitGlobalLog(THolder<TLogBackend> backend, THolder<ILoggerFormatter> formatter = {}); inline void InitGlobalLog2Null() { - DoInitGlobalLog("null", TLOG_EMERG, false, false); + DoInitGlobalLog("null", TLOG_EMERG, false, false); } inline void InitGlobalLog2Console(int loglevel = TLOG_INFO) { @@ -91,7 +91,7 @@ namespace NPrivateGlobalLogger { ~TVerifyEvent(); template <class T> inline TVerifyEvent& operator<<(const T& t) { - static_cast<IOutputStream&>(*this) << t; + static_cast<IOutputStream&>(*this) << t; return *this; } diff --git a/library/cpp/logger/global/rty_formater.h b/library/cpp/logger/global/rty_formater.h index 6532e1d7695..3872b22458c 100644 --- a/library/cpp/logger/global/rty_formater.h +++ b/library/cpp/logger/global/rty_formater.h @@ -34,7 +34,7 @@ namespace NLoggingImpl { TInstant Instant; }; - IOutputStream& operator<<(IOutputStream& out, TLocalTimeS localTimeS); + IOutputStream& operator<<(IOutputStream& out, TLocalTimeS localTimeS); inline TLocalTimeS GetLocalTimeS() { return TLocalTimeS(); diff --git a/library/cpp/logger/global/rty_formater_ut.cpp b/library/cpp/logger/global/rty_formater_ut.cpp index 551a97c5bfe..59376b5c3c8 100644 --- a/library/cpp/logger/global/rty_formater_ut.cpp +++ b/library/cpp/logger/global/rty_formater_ut.cpp @@ -7,23 +7,23 @@ namespace { const TStringBuf SampleRtyLog("2017-07-25 19:26:09.894 +0300"); } -Y_UNIT_TEST_SUITE(NLoggingImplTest) { - Y_UNIT_TEST(TestTLocalTimeSToStream) { +Y_UNIT_TEST_SUITE(NLoggingImplTest) { + Y_UNIT_TEST(TestTLocalTimeSToStream) { NLoggingImpl::TLocalTimeS lt(TInstant::ParseIso8601Deprecated(SampleISO8601)); TStringStream ss; ss << lt; UNIT_ASSERT_EQUAL(ss.Str(), SampleRtyLog); } - Y_UNIT_TEST(TestTLocalTimeSToString) { + Y_UNIT_TEST(TestTLocalTimeSToString) { NLoggingImpl::TLocalTimeS lt(TInstant::ParseIso8601Deprecated(SampleISO8601)); UNIT_ASSERT_EQUAL(TString(lt), SampleRtyLog); } - Y_UNIT_TEST(TestTLocalTimeSAddLeft) { + Y_UNIT_TEST(TestTLocalTimeSAddLeft) { NLoggingImpl::TLocalTimeS lt(TInstant::ParseIso8601Deprecated(SampleISO8601)); TStringBuf suffix("suffix"); UNIT_ASSERT_EQUAL(lt + suffix, TString(SampleRtyLog) + suffix); } - Y_UNIT_TEST(TestTLocalTimeSAddRight) { + Y_UNIT_TEST(TestTLocalTimeSAddRight) { NLoggingImpl::TLocalTimeS lt(TInstant::ParseIso8601Deprecated(SampleISO8601)); TString prefix("prefix"); UNIT_ASSERT_EQUAL(prefix + lt, prefix + SampleRtyLog); diff --git a/library/cpp/logger/log.cpp b/library/cpp/logger/log.cpp index e1d70cc3d28..c4419e75e94 100644 --- a/library/cpp/logger/log.cpp +++ b/library/cpp/logger/log.cpp @@ -27,7 +27,7 @@ THolder<TOwningThreadedLogBackend> CreateOwningThreadedLogBackend(const TString& } class TLog::TImpl: public TAtomicRefCount<TImpl> { - class TPriorityLogStream final: public IOutputStream { + class TPriorityLogStream final: public IOutputStream { public: inline TPriorityLogStream(ELogPriority p, const TImpl* parent) : Priority_(p) @@ -40,13 +40,13 @@ class TLog::TImpl: public TAtomicRefCount<TImpl> { } private: - ELogPriority Priority_ = LOG_DEF_PRIORITY; - const TImpl* Parent_ = nullptr; + ELogPriority Priority_ = LOG_DEF_PRIORITY; + const TImpl* Parent_ = nullptr; }; public: inline TImpl(THolder<TLogBackend> backend) - : Backend_(std::move(backend)) + : Backend_(std::move(backend)) { } @@ -55,7 +55,7 @@ public: return; } - Backend_->ReopenLog(); + Backend_->ReopenLog(); } inline void ReopenLogNoFlush() { @@ -63,7 +63,7 @@ public: return; } - Backend_->ReopenLogNoFlush(); + Backend_->ReopenLogNoFlush(); } inline void AddLog(ELogPriority priority, const char* format, va_list args) const { @@ -77,30 +77,30 @@ public: } inline void ResetBackend(THolder<TLogBackend> backend) noexcept { - Backend_ = std::move(backend); + Backend_ = std::move(backend); } inline THolder<TLogBackend> ReleaseBackend() noexcept { - return std::move(Backend_); + return std::move(Backend_); } inline bool IsNullLog() const noexcept { - return !IsOpen() || (dynamic_cast<TNullLogBackend*>(Backend_.Get()) != nullptr); + return !IsOpen() || (dynamic_cast<TNullLogBackend*>(Backend_.Get()) != nullptr); } inline bool IsOpen() const noexcept { - return nullptr != Backend_.Get(); + return nullptr != Backend_.Get(); } inline void CloseLog() noexcept { - Backend_.Destroy(); + Backend_.Destroy(); Y_ASSERT(!IsOpen()); } inline void WriteData(ELogPriority priority, const char* data, size_t len) const { if (IsOpen()) { - Backend_->WriteData(TLogRecord(priority, data, len)); + Backend_->WriteData(TLogRecord(priority, data, len)); } } @@ -113,38 +113,38 @@ public: } inline ELogPriority FiltrationLevel() const noexcept { - return Backend_->FiltrationLevel(); + return Backend_->FiltrationLevel(); } inline size_t BackEndQueueSize() const { - return Backend_->QueueSize(); + return Backend_->QueueSize(); } private: - THolder<TLogBackend> Backend_; - ELogPriority DefaultPriority_ = LOG_DEF_PRIORITY; + THolder<TLogBackend> Backend_; + ELogPriority DefaultPriority_ = LOG_DEF_PRIORITY; }; TLog::TLog() - : Impl_(MakeIntrusive<TImpl>(nullptr)) + : Impl_(MakeIntrusive<TImpl>(nullptr)) { } -TLog::TLog(const TString& fname, ELogPriority priority) +TLog::TLog(const TString& fname, ELogPriority priority) : TLog(CreateLogBackend(fname, priority, false)) -{ +{ } TLog::TLog(THolder<TLogBackend> backend) - : Impl_(MakeIntrusive<TImpl>(std::move(backend))) + : Impl_(MakeIntrusive<TImpl>(std::move(backend))) { } -TLog::TLog(const TLog&) = default; -TLog::TLog(TLog&&) = default; -TLog::~TLog() = default; -TLog& TLog::operator=(const TLog&) = default; -TLog& TLog::operator=(TLog&&) = default; +TLog::TLog(const TLog&) = default; +TLog::TLog(TLog&&) = default; +TLog::~TLog() = default; +TLog& TLog::operator=(const TLog&) = default; +TLog& TLog::operator=(TLog&&) = default; bool TLog::IsOpen() const noexcept { return Impl_->IsOpen(); @@ -177,13 +177,13 @@ void TLog::AddLogVAList(const char* format, va_list lst) { } void TLog::ReopenLog() { - if (const auto copy = Impl_) { + if (const auto copy = Impl_) { copy->ReopenLog(); } } void TLog::ReopenLogNoFlush() { - if (const auto copy = Impl_) { + if (const auto copy = Impl_) { copy->ReopenLogNoFlush(); } } @@ -227,9 +227,9 @@ THolder<TLogBackend> TLog::ReleaseBackend() noexcept { } void TLog::Write(ELogPriority priority, const char* data, size_t len) const { - if (Formatter_) { - const auto formated = Formatter_(priority, TStringBuf{data, len}); - Impl_->WriteData(priority, formated.data(), formated.size()); + if (Formatter_) { + const auto formated = Formatter_(priority, TStringBuf{data, len}); + Impl_->WriteData(priority, formated.data(), formated.size()); } else { Impl_->WriteData(priority, data, len); } @@ -244,7 +244,7 @@ void TLog::Write(const char* data, size_t len) const { } void TLog::SetFormatter(TLogFormatter formatter) noexcept { - Formatter_ = std::move(formatter); + Formatter_ = std::move(formatter); } size_t TLog::BackEndQueueSize() const { diff --git a/library/cpp/logger/log.h b/library/cpp/logger/log.h index 8be984ccc8d..e0d9e8998fc 100644 --- a/library/cpp/logger/log.h +++ b/library/cpp/logger/log.h @@ -14,81 +14,81 @@ using TLogFormatter = std::function<TString(ELogPriority priority, TStringBuf)>; -// Logging facilities interface. -// -// ```cpp -// TLog base; -// ... -// auto log = base; -// log.SetFormatter([reqId](ELogPriority p, TStringBuf msg) { -// return TStringBuilder() << "reqid=" << reqId << "; " << msg; -// }); -// -// log.Write(TLOG_INFO, "begin"); -// HandleRequest(...); -// log.Write(TLOG_INFO, "end"); -// ``` -// -// Users are encouraged to copy `TLog` instance. +// Logging facilities interface. +// +// ```cpp +// TLog base; +// ... +// auto log = base; +// log.SetFormatter([reqId](ELogPriority p, TStringBuf msg) { +// return TStringBuilder() << "reqid=" << reqId << "; " << msg; +// }); +// +// log.Write(TLOG_INFO, "begin"); +// HandleRequest(...); +// log.Write(TLOG_INFO, "end"); +// ``` +// +// Users are encouraged to copy `TLog` instance. class TLog { public: - // Construct empty logger all writes will be spilled. + // Construct empty logger all writes will be spilled. TLog(); - // Construct file logger. + // Construct file logger. TLog(const TString& fname, ELogPriority priority = LOG_MAX_PRIORITY); - // Construct any type of logger + // Construct any type of logger TLog(THolder<TLogBackend> backend); - TLog(const TLog&); - TLog(TLog&&); + TLog(const TLog&); + TLog(TLog&&); ~TLog(); - TLog& operator=(const TLog&); - TLog& operator=(TLog&&); + TLog& operator=(const TLog&); + TLog& operator=(TLog&&); - // Change underlying backend. - // NOTE: not thread safe. + // Change underlying backend. + // NOTE: not thread safe. void ResetBackend(THolder<TLogBackend> backend) noexcept; - // Reset underlying backend, `IsNullLog()` will return `true` after this call. - // NOTE: not thread safe. + // Reset underlying backend, `IsNullLog()` will return `true` after this call. + // NOTE: not thread safe. THolder<TLogBackend> ReleaseBackend() noexcept; - // Check if underlying backend is defined and is not null. - // NOTE: not thread safe with respect to `ResetBackend` and `ReleaseBackend`. + // Check if underlying backend is defined and is not null. + // NOTE: not thread safe with respect to `ResetBackend` and `ReleaseBackend`. bool IsNullLog() const noexcept; - // Write message to the log. - // - // @param[in] priority Message priority to use. - // @param[in] message Message to write. - void Write(ELogPriority priority, TStringBuf message) const; - // Write message to the log using `DefaultPriority()`. + // Write message to the log. + // + // @param[in] priority Message priority to use. + // @param[in] message Message to write. + void Write(ELogPriority priority, TStringBuf message) const; + // Write message to the log using `DefaultPriority()`. void Write(const char* data, size_t len) const; - // Write message to the log, but pass the message in a c-style. + // Write message to the log, but pass the message in a c-style. void Write(ELogPriority priority, const char* data, size_t len) const; - - // Write message to the log in a c-like printf style. - void Y_PRINTF_FORMAT(3, 4) AddLog(ELogPriority priority, const char* format, ...) const; - // Write message to the log in a c-like printf style with `DefaultPriority()` priority. + + // Write message to the log in a c-like printf style. + void Y_PRINTF_FORMAT(3, 4) AddLog(ELogPriority priority, const char* format, ...) const; + // Write message to the log in a c-like printf style with `DefaultPriority()` priority. void Y_PRINTF_FORMAT(2, 3) AddLog(const char* format, ...) const; - - // Call `ReopenLog()` of the underlying backend. + + // Call `ReopenLog()` of the underlying backend. void ReopenLog(); - // Call `ReopenLogNoFlush()` of the underlying backend. + // Call `ReopenLogNoFlush()` of the underlying backend. void ReopenLogNoFlush(); - // Call `QueueSize()` of the underlying backend. + // Call `QueueSize()` of the underlying backend. size_t BackEndQueueSize() const; - // Set log default priority. - // NOTE: not thread safe. + // Set log default priority. + // NOTE: not thread safe. void SetDefaultPriority(ELogPriority priority) noexcept; - // Get default priority + // Get default priority ELogPriority DefaultPriority() const noexcept; - // Call `FiltrationLevel()` of the underlying backend. + // Call `FiltrationLevel()` of the underlying backend. ELogPriority FiltrationLevel() const noexcept; - // Set current log formatter. - void SetFormatter(TLogFormatter formatter) noexcept; - + // Set current log formatter. + void SetFormatter(TLogFormatter formatter) noexcept; + template <class T> inline TLogElement operator<<(const T& t) const { TLogElement ret(this); @@ -96,18 +96,18 @@ public: return ret; } -public: - // These methods are deprecated and present here only for compatibility reasons (for 13 years - // already ...). Do not use them. - bool OpenLog(const char* path, ELogPriority lp = LOG_MAX_PRIORITY); - bool IsOpen() const noexcept; - void AddLogVAList(const char* format, va_list lst); - void CloseLog(); - +public: + // These methods are deprecated and present here only for compatibility reasons (for 13 years + // already ...). Do not use them. + bool OpenLog(const char* path, ELogPriority lp = LOG_MAX_PRIORITY); + bool IsOpen() const noexcept; + void AddLogVAList(const char* format, va_list lst); + void CloseLog(); + private: class TImpl; - TIntrusivePtr<TImpl> Impl_; - TLogFormatter Formatter_; + TIntrusivePtr<TImpl> Impl_; + TLogFormatter Formatter_; }; THolder<TLogBackend> CreateLogBackend(const TString& fname, ELogPriority priority = LOG_MAX_PRIORITY, bool threaded = false); diff --git a/library/cpp/logger/stream.cpp b/library/cpp/logger/stream.cpp index 96787ad94ba..a4c7c2e5b5f 100644 --- a/library/cpp/logger/stream.cpp +++ b/library/cpp/logger/stream.cpp @@ -3,7 +3,7 @@ #include <util/stream/output.h> -TStreamLogBackend::TStreamLogBackend(IOutputStream* slave) +TStreamLogBackend::TStreamLogBackend(IOutputStream* slave) : Slave_(slave) { } diff --git a/library/cpp/logger/stream.h b/library/cpp/logger/stream.h index feb240afcbd..69a7d3dd128 100644 --- a/library/cpp/logger/stream.h +++ b/library/cpp/logger/stream.h @@ -2,16 +2,16 @@ #include "backend.h" -class IOutputStream; +class IOutputStream; class TStreamLogBackend: public TLogBackend { public: - TStreamLogBackend(IOutputStream* slave); + TStreamLogBackend(IOutputStream* slave); ~TStreamLogBackend() override; void WriteData(const TLogRecord& rec) override; void ReopenLog() override; private: - IOutputStream* Slave_; + IOutputStream* Slave_; }; diff --git a/library/cpp/logger/system.cpp b/library/cpp/logger/system.cpp index 42233f63d25..1b228e3d24a 100644 --- a/library/cpp/logger/system.cpp +++ b/library/cpp/logger/system.cpp @@ -1,5 +1,5 @@ -#include <util/stream/output.h> -#include <util/stream/null.h> +#include <util/stream/output.h> +#include <util/stream/null.h> #include <util/system/compat.h> #include <util/system/yassert.h> #include <util/system/defaults.h> @@ -20,7 +20,7 @@ TSysLogBackend::TSysLogBackend(const char* ident, EFacility facility, int flags) , Flags(flags) { #if defined(_unix_) - Y_ASSERT(TSYSLOG_LOCAL0 <= facility && facility <= TSYSLOG_LOCAL7); + Y_ASSERT(TSYSLOG_LOCAL0 <= facility && facility <= TSYSLOG_LOCAL7); static const int f2sf[] = { LOG_LOCAL0, @@ -56,7 +56,7 @@ void TSysLogBackend::WriteData(const TLogRecord& rec) { #if defined(_unix_) syslog(ELogPriority2SyslogPriority(rec.Priority), "%.*s", (int)rec.Len, rec.Data); #else - Y_UNUSED(rec); + Y_UNUSED(rec); #endif } diff --git a/library/cpp/logger/ya.make b/library/cpp/logger/ya.make index 00a5263cba7..1cef3f66239 100644 --- a/library/cpp/logger/ya.make +++ b/library/cpp/logger/ya.make @@ -5,8 +5,8 @@ OWNER( g:base ) -LIBRARY() - +LIBRARY() + GENERATE_ENUM_SERIALIZATION(priority.h) PEERDIR ( @@ -43,5 +43,5 @@ SRCS( ) END() - -RECURSE_FOR_TESTS(ut) + +RECURSE_FOR_TESTS(ut) diff --git a/library/cpp/lwtrace/kill_action.cpp b/library/cpp/lwtrace/kill_action.cpp index 2b74dc4587c..60d7362d9a9 100644 --- a/library/cpp/lwtrace/kill_action.cpp +++ b/library/cpp/lwtrace/kill_action.cpp @@ -15,7 +15,7 @@ bool TKillActionExecutor::DoExecute(TOrbit&, const TParams&) { abort(); #else int r = kill(getpid(), SIGABRT); - Y_VERIFY(r == 0, "kill failed"); + Y_VERIFY(r == 0, "kill failed"); return true; #endif } diff --git a/library/cpp/lwtrace/mon/mon_lwtrace.cpp b/library/cpp/lwtrace/mon/mon_lwtrace.cpp index a61ee9ce22d..9a0b02d03fc 100644 --- a/library/cpp/lwtrace/mon/mon_lwtrace.cpp +++ b/library/cpp/lwtrace/mon/mon_lwtrace.cpp @@ -846,7 +846,7 @@ public: TraceEvents.emplace(ts, Event(shortId, ts, ph, cat, argsItem, name, id)); } - void Output(IOutputStream& os) + void Output(IOutputStream& os) { os << "{\"traceEvents\":["; bool first = true; @@ -1124,18 +1124,18 @@ template <> TString UrlErase<true>(const TCgiParameters& e, const TString& key, return MakeUrlEraseSub(e, key, value); } -void OutputCommonHeader(IOutputStream& out) +void OutputCommonHeader(IOutputStream& out) { out << NResource::Find("lwtrace/mon/static/header.html") << Endl; } -void OutputCommonFooter(IOutputStream& out) +void OutputCommonFooter(IOutputStream& out) { out << NResource::Find("lwtrace/mon/static/footer.html") << Endl; } struct TScopedHtmlInner { - explicit TScopedHtmlInner(IOutputStream& str) + explicit TScopedHtmlInner(IOutputStream& str) : Str(str) { Str << "<!DOCTYPE html>\n" @@ -1154,7 +1154,7 @@ struct TScopedHtmlInner { inline operator bool () const noexcept { return true; } - IOutputStream &Str; + IOutputStream &Str; }; TString NavbarHeader() @@ -1165,7 +1165,7 @@ TString NavbarHeader() } struct TSelectorsContainer { - TSelectorsContainer(IOutputStream& str) + TSelectorsContainer(IOutputStream& str) : Str(str) { Str << "<nav id=\"selectors-container\" class=\"navbar navbar-default\">" @@ -1192,11 +1192,11 @@ struct TSelectorsContainer { } catch(...) {} } - IOutputStream& Str; + IOutputStream& Str; }; struct TNullContainer { - TNullContainer(IOutputStream&) {} + TNullContainer(IOutputStream&) {} }; class TPageGenBase: public std::exception {}; @@ -1275,7 +1275,7 @@ TString BtnClass() { return "btn"; } -void SelectorTitle(IOutputStream& os, const TString& text) +void SelectorTitle(IOutputStream& os, const TString& text) { if (!text.empty()) { os << text; @@ -1283,7 +1283,7 @@ void SelectorTitle(IOutputStream& os, const TString& text) } template <ui64 flags> -void BtnHref(IOutputStream& os, const TString& text, const TString& href, bool push = false) +void BtnHref(IOutputStream& os, const TString& text, const TString& href, bool push = false) { if (flags & Button) { os << "<button type=\"button\" style=\"display: inline-block;margin:3px\" class=\"" @@ -1299,17 +1299,17 @@ void BtnHref(IOutputStream& os, const TString& text, const TString& href, bool p } } -void DropdownBeginSublist(IOutputStream& os, const TString& text) +void DropdownBeginSublist(IOutputStream& os, const TString& text) { os << "<li>" << text << "<ul class=\"dropdown-menu\">"; } -void DropdownEndSublist(IOutputStream& os) +void DropdownEndSublist(IOutputStream& os) { os << "</ul></li>"; } -void DropdownItem(IOutputStream& os, const TString& text, const TString& href, bool separated = false) +void DropdownItem(IOutputStream& os, const TString& text, const TString& href, bool separated = false) { if (separated) { os << "<li role=\"separator\" class=\"divider\"></li>"; @@ -1341,7 +1341,7 @@ TString GetDescription(const TString& value, const TVariants& variants) } template <ui64 flags, bool sub = false> -void DropdownSelector(IOutputStream& os, const TCgiParameters& e, const TString& param, const TString& value, +void DropdownSelector(IOutputStream& os, const TCgiParameters& e, const TString& param, const TString& value, const TString& text, const TVariants& variants, const TString& realValue = TString()) { HTML(os) { @@ -1567,7 +1567,7 @@ public: row.emplace_back(ToString(probe->GetExecutorsCount())); } - void Output(IOutputStream& os) + void Output(IOutputStream& os) { HTML(os) { TABLE() { @@ -1837,10 +1837,10 @@ public: class TTracesHtmlPrinter { private: - IOutputStream& Os; + IOutputStream& Os; TInstant Now; public: - explicit TTracesHtmlPrinter(IOutputStream& os) + explicit TTracesHtmlPrinter(IOutputStream& os) : Os(os) , Now(TInstant::Now()) {} @@ -2182,11 +2182,11 @@ static TString EscapeJSONString(const TString& s) class TLogJsonPrinter { private: - IOutputStream& Os; + IOutputStream& Os; bool FirstThread; bool FirstItem; public: - explicit TLogJsonPrinter(IOutputStream& os) + explicit TLogJsonPrinter(IOutputStream& os) : Os(os) , FirstThread(true) , FirstItem(true) @@ -2283,7 +2283,7 @@ public: Json }; - void Output(IOutputStream& os) const + void Output(IOutputStream& os) const { OutputItems<Text>(os); OutputDepot<Text>(os); @@ -2365,7 +2365,7 @@ private: } template <EFormat Format> - void OutputItems(IOutputStream& os) const + void OutputItems(IOutputStream& os) const { ui64 idx = 0; ui64 size = Items.size(); @@ -2390,7 +2390,7 @@ private: } template <EFormat Format> - void OutputDepot(IOutputStream& os) const + void OutputDepot(IOutputStream& os) const { ui64 idx = 0; ui64 size = Depot.size(); @@ -3283,7 +3283,7 @@ public: } // Tabular representation of tracks data - void OutputTable(IOutputStream& os, const TCgiParameters& e) + void OutputTable(IOutputStream& os, const TCgiParameters& e) { ui64 tracksTotal = Tree.GetRoot()->TrackCount; @@ -3390,7 +3390,7 @@ public: } // Chromium-compatible trace representation of tracks data - void OutputChromeTrace(IOutputStream& os, const TCgiParameters& e) + void OutputChromeTrace(IOutputStream& os, const TCgiParameters& e) { Y_UNUSED(e); TChromeTrace tr; @@ -3428,7 +3428,7 @@ public: tr.Output(os); } - void OutputSliceCovarianceMatrix(IOutputStream& os, const TCgiParameters& e) + void OutputSliceCovarianceMatrix(IOutputStream& os, const TCgiParameters& e) { Y_UNUSED(e); TPatternNode* node = Tree.GetSelectedNode(); @@ -3495,7 +3495,7 @@ private: return nullptr; } - void OutputPattern(IOutputStream& os, const TCgiParameters& e, TPatternNode* node) + void OutputPattern(IOutputStream& os, const TCgiParameters& e, TPatternNode* node) { // Fill pattern name TString patternName; @@ -3566,7 +3566,7 @@ private: } } - void OutputShare(IOutputStream& os, double share) + void OutputShare(IOutputStream& os, double share) { double lshare = share; double rshare = 100 - lshare; @@ -3610,7 +3610,7 @@ private: return ret; } - void OutputTimeline(IOutputStream& os, const TTimeline& timeline, double maxTime) + void OutputTimeline(IOutputStream& os, const TTimeline& timeline, double maxTime) { static const char *barClass[] = { "progress-bar-info", diff --git a/library/cpp/lwtrace/tests/trace_tests.cpp b/library/cpp/lwtrace/tests/trace_tests.cpp index 6762e344a75..8db02cd23fc 100644 --- a/library/cpp/lwtrace/tests/trace_tests.cpp +++ b/library/cpp/lwtrace/tests/trace_tests.cpp @@ -698,7 +698,7 @@ namespace NLWTrace { } template <> -void Out<NLWTrace::NTests::TMeasure>(IOutputStream& os, TTypeTraits<NLWTrace::NTests::TMeasure>::TFuncParam measure) { +void Out<NLWTrace::NTests::TMeasure>(IOutputStream& os, TTypeTraits<NLWTrace::NTests::TMeasure>::TFuncParam measure) { os << Sprintf("\n\t\t%.6lf +- %.6lf us,\tRPS: %30.3lf (%.1fM)", measure.Average, measure.Sigma, 1000000.0 / measure.Average, 1.0 / measure.Average); } diff --git a/library/cpp/lwtrace/trace_ut.cpp b/library/cpp/lwtrace/trace_ut.cpp index cb03e4fbde9..818c6d6535f 100644 --- a/library/cpp/lwtrace/trace_ut.cpp +++ b/library/cpp/lwtrace/trace_ut.cpp @@ -35,9 +35,9 @@ LWTRACE_USING(LWTRACE_UT_PROVIDER) using namespace NLWTrace; -Y_UNIT_TEST_SUITE(LWTraceTrace) { +Y_UNIT_TEST_SUITE(LWTraceTrace) { #ifndef LWTRACE_DISABLE - Y_UNIT_TEST(Smoke) { + Y_UNIT_TEST(Smoke) { TManager mngr(*Singleton<TProbeRegistry>(), true); TQuery q; bool parsed = NProtoBuf::TextFormat::ParseFromString(R"END( @@ -549,7 +549,7 @@ Y_UNIT_TEST_SUITE(LWTraceTrace) { UNIT_ASSERT_STRINGS_EQUAL(str, "OT_EQ (0)"); } - Y_UNIT_TEST(Track) { + Y_UNIT_TEST(Track) { TManager mngr(*Singleton<TProbeRegistry>(), true); TQuery q; bool parsed = NProtoBuf::TextFormat::ParseFromString(R"END( diff --git a/library/cpp/malloc/api/helpers/io.cpp b/library/cpp/malloc/api/helpers/io.cpp index 5177969f4d1..8d87e90d0ad 100644 --- a/library/cpp/malloc/api/helpers/io.cpp +++ b/library/cpp/malloc/api/helpers/io.cpp @@ -1,10 +1,10 @@ #include <library/cpp/malloc/api/malloc.h> -#include <util/stream/output.h> +#include <util/stream/output.h> using namespace NMalloc; template <> -void Out<TMallocInfo>(IOutputStream& out, const TMallocInfo& info) { +void Out<TMallocInfo>(IOutputStream& out, const TMallocInfo& info) { out << "malloc (name = " << info.Name << ")"; } diff --git a/library/cpp/malloc/api/ut/ut.cpp b/library/cpp/malloc/api/ut/ut.cpp index 7eccd0bf8d5..40f63245e9f 100644 --- a/library/cpp/malloc/api/ut/ut.cpp +++ b/library/cpp/malloc/api/ut/ut.cpp @@ -2,8 +2,8 @@ #include <library/cpp/malloc/api/malloc.h> -Y_UNIT_TEST_SUITE(MallocApi) { - Y_UNIT_TEST(ToStream) { +Y_UNIT_TEST_SUITE(MallocApi) { + Y_UNIT_TEST(ToStream) { TStringStream ss; ss << NMalloc::MallocInfo(); } diff --git a/library/cpp/messagebus/acceptor.cpp b/library/cpp/messagebus/acceptor.cpp index 64a38619c22..65db22c2172 100644 --- a/library/cpp/messagebus/acceptor.cpp +++ b/library/cpp/messagebus/acceptor.cpp @@ -113,8 +113,8 @@ void TAcceptor::SendStatus(TInstant now) { } void TAcceptor::HandleEvent(SOCKET socket, void* cookie) { - Y_UNUSED(socket); - Y_UNUSED(cookie); + Y_UNUSED(socket); + Y_UNUSED(cookie); GetActor()->Schedule(); } diff --git a/library/cpp/messagebus/acceptor_status.cpp b/library/cpp/messagebus/acceptor_status.cpp index 5006ff68aee..ff0e9d978b9 100644 --- a/library/cpp/messagebus/acceptor_status.cpp +++ b/library/cpp/messagebus/acceptor_status.cpp @@ -25,8 +25,8 @@ void TAcceptorStatus::ResetIncremental() { } TAcceptorStatus& TAcceptorStatus::operator+=(const TAcceptorStatus& that) { - Y_ASSERT(Summary); - Y_ASSERT(AcceptorId == 0); + Y_ASSERT(Summary); + Y_ASSERT(AcceptorId == 0); AcceptSuccessCount += that.AcceptSuccessCount; LastAcceptSuccessInstant = Max(LastAcceptSuccessInstant, that.LastAcceptSuccessInstant); diff --git a/library/cpp/messagebus/actor/actor_ut.cpp b/library/cpp/messagebus/actor/actor_ut.cpp index b76ab55bfa2..6d46c03a05e 100644 --- a/library/cpp/messagebus/actor/actor_ut.cpp +++ b/library/cpp/messagebus/actor/actor_ut.cpp @@ -92,8 +92,8 @@ struct TObjectCountChecker { } }; -Y_UNIT_TEST_SUITE(TActor) { - Y_UNIT_TEST(Simple) { +Y_UNIT_TEST_SUITE(TActor) { + Y_UNIT_TEST(Simple) { TObjectCountChecker objectCountChecker; TExecutor executor(4); @@ -105,7 +105,7 @@ Y_UNIT_TEST_SUITE(TActor) { actor->Acted.WaitFor(1u); } - Y_UNIT_TEST(ScheduleAfterStart) { + Y_UNIT_TEST(ScheduleAfterStart) { TObjectCountChecker objectCountChecker; TExecutor executor(4); @@ -147,11 +147,11 @@ Y_UNIT_TEST_SUITE(TActor) { } } - Y_UNIT_TEST(ComplexContention) { + Y_UNIT_TEST(ComplexContention) { ComplexImpl(4, 6); } - Y_UNIT_TEST(ComplexNoContention) { + Y_UNIT_TEST(ComplexNoContention) { ComplexImpl(6, 4); } } diff --git a/library/cpp/messagebus/actor/executor.cpp b/library/cpp/messagebus/actor/executor.cpp index 7a2227a4589..925e8e53880 100644 --- a/library/cpp/messagebus/actor/executor.cpp +++ b/library/cpp/messagebus/actor/executor.cpp @@ -178,7 +178,7 @@ void TExecutor::Init() { AtomicSet(ExitWorkers, 0); - Y_VERIFY(Config.WorkerCount > 0); + Y_VERIFY(Config.WorkerCount > 0); for (size_t i = 0; i < Config.WorkerCount; i++) { WorkerThreads.push_back(new TExecutorWorker(this)); @@ -215,7 +215,7 @@ void TExecutor::EnqueueWork(TArrayRef<IWorkItem* const> wis) { return; if (Y_UNLIKELY(AtomicGet(ExitWorkers) != 0)) { - Y_VERIFY(WorkItems.Empty(), "executor %s: cannot add tasks after queue shutdown", Config.Name); + Y_VERIFY(WorkItems.Empty(), "executor %s: cannot add tasks after queue shutdown", Config.Name); } TWhatThreadDoesPushPop pp("executor: EnqueueWork"); @@ -319,7 +319,7 @@ void TExecutor::ProcessWorkQueueHere() { } void TExecutor::RunWorker() { - Y_VERIFY(!ThreadCurrentExecutor, "state check"); + Y_VERIFY(!ThreadCurrentExecutor, "state check"); ThreadCurrentExecutor = this; SetCurrentThreadName("wrkr"); diff --git a/library/cpp/messagebus/actor/ring_buffer.h b/library/cpp/messagebus/actor/ring_buffer.h index ec5706f7c76..0cf401bfda1 100644 --- a/library/cpp/messagebus/actor/ring_buffer.h +++ b/library/cpp/messagebus/actor/ring_buffer.h @@ -17,12 +17,12 @@ private: TVector<T> Data; void StateCheck() const { - Y_ASSERT(Capacity == Data.size()); - Y_ASSERT(Capacity == (1u << CapacityPow)); - Y_ASSERT((Capacity & CapacityMask) == 0u); - Y_ASSERT(Capacity - CapacityMask == 1u); - Y_ASSERT(WritePos < Capacity); - Y_ASSERT(ReadPos < Capacity); + Y_ASSERT(Capacity == Data.size()); + Y_ASSERT(Capacity == (1u << CapacityPow)); + Y_ASSERT((Capacity & CapacityMask) == 0u); + Y_ASSERT(Capacity - CapacityMask == 1u); + Y_ASSERT(WritePos < Capacity); + Y_ASSERT(ReadPos < Capacity); } size_t Writable() const { diff --git a/library/cpp/messagebus/actor/ring_buffer_ut.cpp b/library/cpp/messagebus/actor/ring_buffer_ut.cpp index bdb379b3a92..2accea357c1 100644 --- a/library/cpp/messagebus/actor/ring_buffer_ut.cpp +++ b/library/cpp/messagebus/actor/ring_buffer_ut.cpp @@ -4,7 +4,7 @@ #include <util/random/random.h> -Y_UNIT_TEST_SUITE(RingBuffer) { +Y_UNIT_TEST_SUITE(RingBuffer) { struct TRingBufferTester { TRingBuffer<unsigned> RingBuffer; @@ -52,7 +52,7 @@ Y_UNIT_TEST_SUITE(RingBuffer) { } } - Y_UNIT_TEST(Random) { + Y_UNIT_TEST(Random) { for (unsigned i = 0; i < 100; ++i) { Iter(); } diff --git a/library/cpp/messagebus/actor/tasks_ut.cpp b/library/cpp/messagebus/actor/tasks_ut.cpp index d80e8451a50..270392330fe 100644 --- a/library/cpp/messagebus/actor/tasks_ut.cpp +++ b/library/cpp/messagebus/actor/tasks_ut.cpp @@ -4,8 +4,8 @@ using namespace NActor; -Y_UNIT_TEST_SUITE(TTasks) { - Y_UNIT_TEST(AddTask_FetchTask_Simple) { +Y_UNIT_TEST_SUITE(TTasks) { + Y_UNIT_TEST(AddTask_FetchTask_Simple) { TTasks tasks; UNIT_ASSERT(tasks.AddTask()); @@ -18,7 +18,7 @@ Y_UNIT_TEST_SUITE(TTasks) { UNIT_ASSERT(tasks.AddTask()); } - Y_UNIT_TEST(AddTask_FetchTask_AddTask) { + Y_UNIT_TEST(AddTask_FetchTask_AddTask) { TTasks tasks; UNIT_ASSERT(tasks.AddTask()); diff --git a/library/cpp/messagebus/actor/temp_tls_vector.h b/library/cpp/messagebus/actor/temp_tls_vector.h index 675d92f5b0b..02d7bf8c768 100644 --- a/library/cpp/messagebus/actor/temp_tls_vector.h +++ b/library/cpp/messagebus/actor/temp_tls_vector.h @@ -19,7 +19,7 @@ public: TTempTlsVector() { Vector = FastTlsSingletonWithTag<TVectorType<T, std::allocator<T>>, TTagForTls>(); - Y_ASSERT(Vector->empty()); + Y_ASSERT(Vector->empty()); } ~TTempTlsVector() { diff --git a/library/cpp/messagebus/actor/what_thread_does_guard_ut.cpp b/library/cpp/messagebus/actor/what_thread_does_guard_ut.cpp index e4b218a7ca3..96ddeb0f089 100644 --- a/library/cpp/messagebus/actor/what_thread_does_guard_ut.cpp +++ b/library/cpp/messagebus/actor/what_thread_does_guard_ut.cpp @@ -4,8 +4,8 @@ #include <util/system/mutex.h> -Y_UNIT_TEST_SUITE(WhatThreadDoesGuard) { - Y_UNIT_TEST(Simple) { +Y_UNIT_TEST_SUITE(WhatThreadDoesGuard) { + Y_UNIT_TEST(Simple) { TMutex mutex; TWhatThreadDoesAcquireGuard<TMutex> guard(mutex, "acquiring my mutex"); diff --git a/library/cpp/messagebus/async_result.h b/library/cpp/messagebus/async_result.h index d24dde284a3..2c6a42095cd 100644 --- a/library/cpp/messagebus/async_result.h +++ b/library/cpp/messagebus/async_result.h @@ -24,7 +24,7 @@ private: public: void SetResult(const T& result) { TGuard<TMutex> guard(Mutex); - Y_VERIFY(!Result, "cannot set result twice"); + Y_VERIFY(!Result, "cannot set result twice"); Result = result; CondVar.BroadCast(); @@ -47,7 +47,7 @@ public: if (!!Result) { onResult(*Result); } else { - Y_ASSERT(!OnResult); + Y_ASSERT(!OnResult); OnResult = std::function<TOnResult>(onResult); } } diff --git a/library/cpp/messagebus/async_result_ut.cpp b/library/cpp/messagebus/async_result_ut.cpp index 2e96492afd1..3508b6bd8e2 100644 --- a/library/cpp/messagebus/async_result_ut.cpp +++ b/library/cpp/messagebus/async_result_ut.cpp @@ -10,8 +10,8 @@ namespace { } -Y_UNIT_TEST_SUITE(TAsyncResult) { - Y_UNIT_TEST(AndThen_Here) { +Y_UNIT_TEST_SUITE(TAsyncResult) { + Y_UNIT_TEST(AndThen_Here) { TAsyncResult<int> r; int var = 1; @@ -23,7 +23,7 @@ Y_UNIT_TEST_SUITE(TAsyncResult) { UNIT_ASSERT_VALUES_EQUAL(17, var); } - Y_UNIT_TEST(AndThen_Later) { + Y_UNIT_TEST(AndThen_Later) { TAsyncResult<int> r; int var = 1; diff --git a/library/cpp/messagebus/cc_semaphore_ut.cpp b/library/cpp/messagebus/cc_semaphore_ut.cpp index 206bb7c96a7..0b37c7b9906 100644 --- a/library/cpp/messagebus/cc_semaphore_ut.cpp +++ b/library/cpp/messagebus/cc_semaphore_ut.cpp @@ -29,8 +29,8 @@ namespace { }; } -Y_UNIT_TEST_SUITE(TComplexConditionSemaphore) { - Y_UNIT_TEST(Simple) { +Y_UNIT_TEST_SUITE(TComplexConditionSemaphore) { + Y_UNIT_TEST(Simple) { TTestSemaphore sema; UNIT_ASSERT(!sema.TryWait()); sema.Release(); diff --git a/library/cpp/messagebus/config/netaddr.cpp b/library/cpp/messagebus/config/netaddr.cpp index 962ac538e27..a83c7d7bf16 100644 --- a/library/cpp/messagebus/config/netaddr.cpp +++ b/library/cpp/messagebus/config/netaddr.cpp @@ -178,6 +178,6 @@ namespace NBus { } template <> -void Out<NBus::TNetAddr>(IOutputStream& out, const NBus::TNetAddr& addr) { +void Out<NBus::TNetAddr>(IOutputStream& out, const NBus::TNetAddr& addr) { Out<NAddr::IRemoteAddr>(out, addr); } diff --git a/library/cpp/messagebus/config/session_config.cpp b/library/cpp/messagebus/config/session_config.cpp index fbbbb106c9d..5dc63273929 100644 --- a/library/cpp/messagebus/config/session_config.cpp +++ b/library/cpp/messagebus/config/session_config.cpp @@ -29,14 +29,14 @@ static int ParseDurationForMessageBus(const char* option) { static int ParseToSForMessageBus(const char* option) { int tos; TStringBuf str(option); - if (str.StartsWith("0x")) { + if (str.StartsWith("0x")) { str = str.Tail(2); - Y_VERIFY(str.length() == 2, "ToS must be a number between 0x00 and 0xFF"); + Y_VERIFY(str.length() == 2, "ToS must be a number between 0x00 and 0xFF"); tos = String2Byte(str.data()); } else { tos = FromString<int>(option); } - Y_VERIFY(tos >= 0 && tos <= 255, "ToS must be between 0x00 and 0xFF"); + Y_VERIFY(tos >= 0 && tos <= 255, "ToS must be between 0x00 and 0xFF"); return tos; } @@ -44,13 +44,13 @@ template <class T> static T ParseWithKmgSuffixT(const char* option) { TStringBuf str(option); T multiplier = 1; - if (str.EndsWith('k')) { + if (str.EndsWith('k')) { multiplier = 1024; str = str.Head(str.size() - 1); - } else if (str.EndsWith('m')) { + } else if (str.EndsWith('m')) { multiplier = 1024 * 1024; str = str.Head(str.size() - 1); - } else if (str.EndsWith('g')) { + } else if (str.EndsWith('g')) { multiplier = 1024 * 1024 * 1024; str = str.Head(str.size() - 1); } diff --git a/library/cpp/messagebus/coreconn_ut.cpp b/library/cpp/messagebus/coreconn_ut.cpp index beb6850f26f..64f760cf139 100644 --- a/library/cpp/messagebus/coreconn_ut.cpp +++ b/library/cpp/messagebus/coreconn_ut.cpp @@ -4,22 +4,22 @@ #include <util/generic/yexception.h> -Y_UNIT_TEST_SUITE(TMakeIpVersionTest) { +Y_UNIT_TEST_SUITE(TMakeIpVersionTest) { using namespace NBus; - Y_UNIT_TEST(IpV4Allowed) { + Y_UNIT_TEST(IpV4Allowed) { UNIT_ASSERT_EQUAL(MakeIpVersion(true, false), EIP_VERSION_4); } - Y_UNIT_TEST(IpV6Allowed) { + Y_UNIT_TEST(IpV6Allowed) { UNIT_ASSERT_EQUAL(MakeIpVersion(false, true), EIP_VERSION_6); } - Y_UNIT_TEST(AllAllowed) { + Y_UNIT_TEST(AllAllowed) { UNIT_ASSERT_EQUAL(MakeIpVersion(true, true), EIP_VERSION_ANY); } - Y_UNIT_TEST(NothingAllowed) { + Y_UNIT_TEST(NothingAllowed) { UNIT_ASSERT_EXCEPTION(MakeIpVersion(false, false), yexception); } } diff --git a/library/cpp/messagebus/debug_receiver/debug_receiver_proto.cpp b/library/cpp/messagebus/debug_receiver/debug_receiver_proto.cpp index 0c74f9ecc38..dbe325e2554 100644 --- a/library/cpp/messagebus/debug_receiver/debug_receiver_proto.cpp +++ b/library/cpp/messagebus/debug_receiver/debug_receiver_proto.cpp @@ -8,7 +8,7 @@ TDebugReceiverProtocol::TDebugReceiverProtocol() } void TDebugReceiverProtocol::Serialize(const NBus::TBusMessage*, TBuffer&) { - Y_FAIL("it is receiver only"); + Y_FAIL("it is receiver only"); } TAutoPtr<NBus::TBusMessage> TDebugReceiverProtocol::Deserialize(ui16, TArrayRef<const char> payload) { diff --git a/library/cpp/messagebus/duration_histogram.cpp b/library/cpp/messagebus/duration_histogram.cpp index 32a0001d414..44f6c752837 100644 --- a/library/cpp/messagebus/duration_histogram.cpp +++ b/library/cpp/messagebus/duration_histogram.cpp @@ -48,7 +48,7 @@ namespace { } TString TDurationHistogram::LabelBefore(unsigned i) { - Y_VERIFY(i < Buckets); + Y_VERIFY(i < Buckets); TDuration d = Singleton<TMarks>()->Marks[i]; @@ -67,8 +67,8 @@ TString TDurationHistogram::LabelBefore(unsigned i) { TString TDurationHistogram::PrintToString() const { TStringStream ss; - for (auto time : Times) { - ss << time << "\n"; + for (auto time : Times) { + ss << time << "\n"; } return ss.Str(); } diff --git a/library/cpp/messagebus/duration_histogram_ut.cpp b/library/cpp/messagebus/duration_histogram_ut.cpp index 01bcc095e99..f2fc1aa8a24 100644 --- a/library/cpp/messagebus/duration_histogram_ut.cpp +++ b/library/cpp/messagebus/duration_histogram_ut.cpp @@ -2,8 +2,8 @@ #include "duration_histogram.h" -Y_UNIT_TEST_SUITE(TDurationHistogramTest) { - Y_UNIT_TEST(BucketFor) { +Y_UNIT_TEST_SUITE(TDurationHistogramTest) { + Y_UNIT_TEST(BucketFor) { UNIT_ASSERT_VALUES_EQUAL(0u, TDurationHistogram::BucketFor(TDuration::MicroSeconds(0))); UNIT_ASSERT_VALUES_EQUAL(0u, TDurationHistogram::BucketFor(TDuration::MicroSeconds(1))); UNIT_ASSERT_VALUES_EQUAL(0u, TDurationHistogram::BucketFor(TDuration::MicroSeconds(900))); @@ -19,7 +19,7 @@ Y_UNIT_TEST_SUITE(TDurationHistogramTest) { UNIT_ASSERT_VALUES_EQUAL(TDurationHistogram::Buckets - 1, TDurationHistogram::BucketFor(TDuration::Hours(1))); } - Y_UNIT_TEST(Simple) { + Y_UNIT_TEST(Simple) { TDurationHistogram h1; h1.AddTime(TDuration::MicroSeconds(1)); UNIT_ASSERT_VALUES_EQUAL(1u, h1.Times.front()); @@ -29,7 +29,7 @@ Y_UNIT_TEST_SUITE(TDurationHistogramTest) { UNIT_ASSERT_VALUES_EQUAL(1u, h1.Times.back()); } - Y_UNIT_TEST(LabelFor) { + Y_UNIT_TEST(LabelFor) { for (unsigned i = 0; i < TDurationHistogram::Buckets; ++i) { TDurationHistogram::LabelBefore(i); //Cerr << TDurationHistogram::LabelBefore(i) << "\n"; diff --git a/library/cpp/messagebus/event_loop.cpp b/library/cpp/messagebus/event_loop.cpp index f685135bedd..1dbbec1657d 100644 --- a/library/cpp/messagebus/event_loop.cpp +++ b/library/cpp/messagebus/event_loop.cpp @@ -4,11 +4,11 @@ #include "thread_extra.h" #include <util/generic/hash.h> -#include <util/network/pair.h> +#include <util/network/pair.h> #include <util/network/poller.h> #include <util/system/event.h> #include <util/system/mutex.h> -#include <util/system/thread.h> +#include <util/system/thread.h> #include <util/system/yassert.h> #include <util/thread/lfqueue.h> @@ -161,7 +161,7 @@ TChannel::TImpl::TImpl(TEventLoop::TImpl* eventLoop, TSocket socket, TEventHandl } TChannel::TImpl::~TImpl() { - Y_ASSERT(Close); + Y_ASSERT(Close); } void TChannel::TImpl::EnableRead() { @@ -260,7 +260,7 @@ TEventLoop::TImpl::TImpl(const char* name) SOCKET wakeupSockets[2]; if (SocketPair(wakeupSockets) < 0) { - Y_FAIL("failed to create socket pair for wakeup sockets: %s", LastSystemErrorText()); + Y_FAIL("failed to create socket pair for wakeup sockets: %s", LastSystemErrorText()); } TSocketHolder wakeupReadSocket(wakeupSockets[0]); @@ -278,7 +278,7 @@ TEventLoop::TImpl::TImpl(const char* name) void TEventLoop::TImpl::Run() { bool res = AtomicCas(&RunningState, EVENT_LOOP_RUNNING, EVENT_LOOP_CREATED); - Y_VERIFY(res, "Invalid mbus event loop state"); + Y_VERIFY(res, "Invalid mbus event loop state"); if (!!Name) { SetCurrentThreadName(Name); @@ -286,7 +286,7 @@ void TEventLoop::TImpl::Run() { while (AtomicGet(StopSignal) == 0) { void* cookies[1024]; - const size_t count = Poller.WaitI(cookies, Y_ARRAY_SIZE(cookies)); + const size_t count = Poller.WaitI(cookies, Y_ARRAY_SIZE(cookies)); void** end = cookies + count; for (void** c = cookies; c != end; ++c) { @@ -295,7 +295,7 @@ void TEventLoop::TImpl::Run() { if (*c == this) { char buf[0x1000]; if (NBus::NPrivate::SocketRecv(WakeupReadSocket, buf) < 0) { - Y_FAIL("failed to recv from wakeup socket: %s", LastSystemErrorText()); + Y_FAIL("failed to recv from wakeup socket: %s", LastSystemErrorText()); } continue; } @@ -306,14 +306,14 @@ void TEventLoop::TImpl::Run() { SOCKET socket = -1; while (SocketsToRemove.Dequeue(&socket)) { TGuard<TMutex> guard(Mutex); - Y_VERIFY(Data.erase(socket) == 1, "must be removed once"); + Y_VERIFY(Data.erase(socket) == 1, "must be removed once"); } } { TGuard<TMutex> guard(Mutex); - for (auto& it : Data) { - it.second->Unregister(); + for (auto& it : Data) { + it.second->Unregister(); } // release file descriptors @@ -322,7 +322,7 @@ void TEventLoop::TImpl::Run() { res = AtomicCas(&RunningState, EVENT_LOOP_STOPPED, EVENT_LOOP_RUNNING); - Y_VERIFY(res); + Y_VERIFY(res); StoppedEvent.Signal(); } @@ -338,13 +338,13 @@ void TEventLoop::TImpl::Stop() { } TChannelPtr TEventLoop::TImpl::Register(TSocket socket, TEventHandlerPtr eventHandler, void* cookie) { - Y_VERIFY(socket != INVALID_SOCKET, "must be a valid socket"); + Y_VERIFY(socket != INVALID_SOCKET, "must be a valid socket"); TChannelPtr channel = new TChannel(new TChannel::TImpl(this, socket, eventHandler, cookie)); TGuard<TMutex> guard(Mutex); - Y_VERIFY(Data.insert(std::make_pair(socket, channel)).second, "must not be already inserted"); + Y_VERIFY(Data.insert(std::make_pair(socket, channel)).second, "must not be already inserted"); return channel; } @@ -352,7 +352,7 @@ TChannelPtr TEventLoop::TImpl::Register(TSocket socket, TEventHandlerPtr eventHa void TEventLoop::TImpl::Wakeup() { if (NBus::NPrivate::SocketSend(WakeupWriteSocket, TArrayRef<const char>("", 1)) < 0) { if (LastSystemError() != EAGAIN) { - Y_FAIL("failed to send to wakeup socket: %s", LastSystemErrorText()); + Y_FAIL("failed to send to wakeup socket: %s", LastSystemErrorText()); } } } @@ -365,6 +365,6 @@ void TEventLoop::TImpl::AddToPoller(SOCKET socket, void* cookie, int flags) { } else if (flags == OP_READ_WRITE) { Poller.WaitReadWriteOneShot(socket, cookie); } else { - Y_FAIL("Wrong flags: %d", int(flags)); + Y_FAIL("Wrong flags: %d", int(flags)); } } diff --git a/library/cpp/messagebus/extra_ref.h b/library/cpp/messagebus/extra_ref.h index 29271232668..99470152fcd 100644 --- a/library/cpp/messagebus/extra_ref.h +++ b/library/cpp/messagebus/extra_ref.h @@ -11,7 +11,7 @@ public: { } ~TExtraRef() { - Y_VERIFY(!Holds); + Y_VERIFY(!Holds); } template <typename TThis> diff --git a/library/cpp/messagebus/futex_like.cpp b/library/cpp/messagebus/futex_like.cpp index 7f965126db8..bf3bee4ef5d 100644 --- a/library/cpp/messagebus/futex_like.cpp +++ b/library/cpp/messagebus/futex_like.cpp @@ -25,13 +25,13 @@ namespace { #endif void TFutexLike::Wake(size_t count) { - Y_ASSERT(count > 0); + Y_ASSERT(count > 0); #ifdef _linux_ if (count > unsigned(Max<int>())) { count = Max<int>(); } int r = futex(&Value, FUTEX_WAKE, count, nullptr, nullptr, 0); - Y_VERIFY(r >= 0, "futex_wake failed: %s", strerror(errno)); + Y_VERIFY(r >= 0, "futex_wake failed: %s", strerror(errno)); #else TGuard<TMutex> guard(Mutex); if (count == 1) { @@ -45,7 +45,7 @@ void TFutexLike::Wake(size_t count) { void TFutexLike::Wait(int expected) { #ifdef _linux_ int r = futex(&Value, FUTEX_WAIT, expected, nullptr, nullptr, 0); - Y_VERIFY(r >= 0 || errno == EWOULDBLOCK, "futex_wait failed: %s", strerror(errno)); + Y_VERIFY(r >= 0 || errno == EWOULDBLOCK, "futex_wait failed: %s", strerror(errno)); #else TGuard<TMutex> guard(Mutex); if (expected == Get()) { diff --git a/library/cpp/messagebus/latch_ut.cpp b/library/cpp/messagebus/latch_ut.cpp index bfab04f5271..51a0a8baf15 100644 --- a/library/cpp/messagebus/latch_ut.cpp +++ b/library/cpp/messagebus/latch_ut.cpp @@ -2,8 +2,8 @@ #include "latch.h" -Y_UNIT_TEST_SUITE(TLatch) { - Y_UNIT_TEST(Simple) { +Y_UNIT_TEST_SUITE(TLatch) { + Y_UNIT_TEST(Simple) { TLatch latch; UNIT_ASSERT(latch.TryWait()); latch.Lock(); diff --git a/library/cpp/messagebus/lfqueue_batch_ut.cpp b/library/cpp/messagebus/lfqueue_batch_ut.cpp index f80434c0d46..71f854e7345 100644 --- a/library/cpp/messagebus/lfqueue_batch_ut.cpp +++ b/library/cpp/messagebus/lfqueue_batch_ut.cpp @@ -2,8 +2,8 @@ #include "lfqueue_batch.h" -Y_UNIT_TEST_SUITE(TLockFreeQueueBatch) { - Y_UNIT_TEST(Order1) { +Y_UNIT_TEST_SUITE(TLockFreeQueueBatch) { + Y_UNIT_TEST(Order1) { TLockFreeQueueBatch<unsigned> q; { TAutoPtr<TVector<unsigned>> v(new TVector<unsigned>); @@ -25,7 +25,7 @@ Y_UNIT_TEST_SUITE(TLockFreeQueueBatch) { UNIT_ASSERT_VALUES_EQUAL(0u, r.size()); } - Y_UNIT_TEST(Order2) { + Y_UNIT_TEST(Order2) { TLockFreeQueueBatch<unsigned> q; { TAutoPtr<TVector<unsigned>> v(new TVector<unsigned>); diff --git a/library/cpp/messagebus/local_flags_ut.cpp b/library/cpp/messagebus/local_flags_ut.cpp index 189d73eb0f3..afa8ac1a295 100644 --- a/library/cpp/messagebus/local_flags_ut.cpp +++ b/library/cpp/messagebus/local_flags_ut.cpp @@ -5,8 +5,8 @@ using namespace NBus; using namespace NBus::NPrivate; -Y_UNIT_TEST_SUITE(EMessageLocalFlags) { - Y_UNIT_TEST(TestLocalFlagSetToString) { +Y_UNIT_TEST_SUITE(EMessageLocalFlags) { + Y_UNIT_TEST(TestLocalFlagSetToString) { UNIT_ASSERT_VALUES_EQUAL("0", LocalFlagSetToString(0)); UNIT_ASSERT_VALUES_EQUAL("MESSAGE_REPLY_INTERNAL", LocalFlagSetToString(MESSAGE_REPLY_INTERNAL)); diff --git a/library/cpp/messagebus/memory_ut.cpp b/library/cpp/messagebus/memory_ut.cpp index 00654f28a17..8ceeca5f868 100644 --- a/library/cpp/messagebus/memory_ut.cpp +++ b/library/cpp/messagebus/memory_ut.cpp @@ -2,8 +2,8 @@ #include "memory.h" -Y_UNIT_TEST_SUITE(MallocAligned) { - Y_UNIT_TEST(Test) { +Y_UNIT_TEST_SUITE(MallocAligned) { + Y_UNIT_TEST(Test) { for (size_t size = 0; size < 1000; ++size) { void* ptr = MallocAligned(size, 128); UNIT_ASSERT(uintptr_t(ptr) % 128 == 0); diff --git a/library/cpp/messagebus/message.cpp b/library/cpp/messagebus/message.cpp index bfa7ed8e9ba..8e2a5cdd58a 100644 --- a/library/cpp/messagebus/message.cpp +++ b/library/cpp/messagebus/message.cpp @@ -193,6 +193,6 @@ namespace NBus { } template <> -void Out<TBusIdentity>(IOutputStream& os, TTypeTraits<TBusIdentity>::TFuncParam ident) { +void Out<TBusIdentity>(IOutputStream& os, TTypeTraits<TBusIdentity>::TFuncParam ident) { os << ident.ToString(); } diff --git a/library/cpp/messagebus/message_counter.cpp b/library/cpp/messagebus/message_counter.cpp index 04d9343f6a2..9b7cad9c462 100644 --- a/library/cpp/messagebus/message_counter.cpp +++ b/library/cpp/messagebus/message_counter.cpp @@ -25,7 +25,7 @@ TMessageCounter& TMessageCounter::operator+=(const TMessageCounter& that) { TString TMessageCounter::ToString(bool reader) const { if (reader) { - Y_ASSERT(CountCompressionRequests == 0); + Y_ASSERT(CountCompressionRequests == 0); } TStringStream readValue; diff --git a/library/cpp/messagebus/message_status_counter.cpp b/library/cpp/messagebus/message_status_counter.cpp index 891c8f5bb2b..8a6ea01460d 100644 --- a/library/cpp/messagebus/message_status_counter.cpp +++ b/library/cpp/messagebus/message_status_counter.cpp @@ -28,14 +28,14 @@ TString TMessageStatusCounter::PrintToString() const { bool hasZeros = false; for (size_t i = 0; i < MESSAGE_STATUS_COUNT; ++i) { if (i == MESSAGE_OK) { - Y_VERIFY(Counts[i] == 0); + Y_VERIFY(Counts[i] == 0); continue; } if (Counts[i] != 0) { p.AddRow(EMessageStatus(i), Counts[i]); const char* description = MessageStatusDescription(EMessageStatus(i)); // TODO: add third column - Y_UNUSED(description); + Y_UNUSED(description); hasNonZeros = true; } else { @@ -59,7 +59,7 @@ void TMessageStatusCounter::FillErrorsProtobuf(TConnectionStatusMonRecord* statu status->clear_errorcountbystatus(); for (size_t i = 0; i < MESSAGE_STATUS_COUNT; ++i) { if (i == MESSAGE_OK) { - Y_VERIFY(Counts[i] == 0); + Y_VERIFY(Counts[i] == 0); continue; } if (Counts[i] != 0) { diff --git a/library/cpp/messagebus/message_status_counter_ut.cpp b/library/cpp/messagebus/message_status_counter_ut.cpp index 95986513296..c5b7895490c 100644 --- a/library/cpp/messagebus/message_status_counter_ut.cpp +++ b/library/cpp/messagebus/message_status_counter_ut.cpp @@ -7,8 +7,8 @@ using namespace NBus; using namespace NBus::NPrivate; -Y_UNIT_TEST_SUITE(MessageStatusCounter) { - Y_UNIT_TEST(MessageStatusConversion) { +Y_UNIT_TEST_SUITE(MessageStatusCounter) { + Y_UNIT_TEST(MessageStatusConversion) { const ::google::protobuf::EnumDescriptor* descriptor = TMessageStatusRecord_EMessageStatus_descriptor(); diff --git a/library/cpp/messagebus/messqueue.cpp b/library/cpp/messagebus/messqueue.cpp index 3474d62705f..9b55f9061df 100644 --- a/library/cpp/messagebus/messqueue.cpp +++ b/library/cpp/messagebus/messqueue.cpp @@ -169,7 +169,7 @@ void TBusMessageQueue::Add(TIntrusivePtr<TBusSessionImpl> session) { void TBusMessageQueue::Remove(TBusSession* session) { TGuard<TMutex> scope(Lock); TList<TIntrusivePtr<TBusSessionImpl>>::iterator it = std::find(Sessions.begin(), Sessions.end(), session); - Y_VERIFY(it != Sessions.end(), "do not destroy session twice"); + Y_VERIFY(it != Sessions.end(), "do not destroy session twice"); Sessions.erase(it); } @@ -184,8 +184,8 @@ void TBusMessageQueue::DestroyAllSessions() { sessions = Sessions; } - for (auto& session : sessions) { - Y_VERIFY(session->IsDown(), "Session must be shut down prior to queue shutdown"); + for (auto& session : sessions) { + Y_VERIFY(session->IsDown(), "Session must be shut down prior to queue shutdown"); } } diff --git a/library/cpp/messagebus/misc/test_sync.h b/library/cpp/messagebus/misc/test_sync.h index be3f4f20b85..a74b5d6f3b5 100644 --- a/library/cpp/messagebus/misc/test_sync.h +++ b/library/cpp/messagebus/misc/test_sync.h @@ -32,7 +32,7 @@ public: void WaitFor(unsigned n) { TGuard<TMutex> guard(Mutex); - Y_VERIFY(Current <= n, "too late, waiting for %d, already %d", n, Current); + Y_VERIFY(Current <= n, "too late, waiting for %d, already %d", n, Current); while (n > Current) { CondVar.WaitI(Mutex); @@ -42,7 +42,7 @@ public: void WaitForAndIncrement(unsigned n) { TGuard<TMutex> guard(Mutex); - Y_VERIFY(Current <= n, "too late, waiting for %d, already %d", n, Current); + Y_VERIFY(Current <= n, "too late, waiting for %d, already %d", n, Current); while (n > Current) { CondVar.WaitI(Mutex); @@ -55,7 +55,7 @@ public: void CheckAndIncrement(unsigned n) { TGuard<TMutex> guard(Mutex); - Y_VERIFY(Current == n, "must be %d, currently %d", n, Current); + Y_VERIFY(Current == n, "must be %d, currently %d", n, Current); DoInc(); CondVar.BroadCast(); @@ -64,12 +64,12 @@ public: void Check(unsigned n) { TGuard<TMutex> guard(Mutex); - Y_VERIFY(Current == n, "must be %d, currently %d", n, Current); + Y_VERIFY(Current == n, "must be %d, currently %d", n, Current); } private: void DoInc() { unsigned r = ++Current; - Y_UNUSED(r); + Y_UNUSED(r); } }; diff --git a/library/cpp/messagebus/misc/tokenquota.h b/library/cpp/messagebus/misc/tokenquota.h index 190547fa54e..96b5f7c4b9f 100644 --- a/library/cpp/messagebus/misc/tokenquota.h +++ b/library/cpp/messagebus/misc/tokenquota.h @@ -22,7 +22,7 @@ namespace NBus { , WakeLev(wake < 1 ? Max<size_t>(1, tokens / 2) : 0) , Tokens_(tokens) { - Y_UNUSED(padd_); + Y_UNUSED(padd_); } bool Acquire(TAtomic level = 1, bool force = false) { @@ -37,7 +37,7 @@ namespace NBus { void Consume(size_t items) { if (Enabled) { - Y_ASSERT(Acquired >= TAtomicBase(items)); + Y_ASSERT(Acquired >= TAtomicBase(items)); Acquired -= items; } diff --git a/library/cpp/messagebus/misc/weak_ptr.h b/library/cpp/messagebus/misc/weak_ptr.h index 70fdeb0e2a5..20afeafa88d 100644 --- a/library/cpp/messagebus/misc/weak_ptr.h +++ b/library/cpp/messagebus/misc/weak_ptr.h @@ -23,13 +23,13 @@ private: void Release() { TGuard<TMutex> g(Mutex); - Y_ASSERT(!!Outer); + Y_ASSERT(!!Outer); Outer = nullptr; } TIntrusivePtr<TSelf> Get() { TGuard<TMutex> g(Mutex); - Y_ASSERT(!Outer || Outer->RefCount() > 0); + Y_ASSERT(!Outer || Outer->RefCount() > 0); return Outer; } }; diff --git a/library/cpp/messagebus/misc/weak_ptr_ut.cpp b/library/cpp/messagebus/misc/weak_ptr_ut.cpp index 5a325278dbe..b499ca7b1d1 100644 --- a/library/cpp/messagebus/misc/weak_ptr_ut.cpp +++ b/library/cpp/messagebus/misc/weak_ptr_ut.cpp @@ -2,7 +2,7 @@ #include "weak_ptr.h" -Y_UNIT_TEST_SUITE(TWeakPtrTest) { +Y_UNIT_TEST_SUITE(TWeakPtrTest) { struct TWeakPtrTester: public TWeakRefCounted<TWeakPtrTester> { int* const CounterPtr; @@ -15,7 +15,7 @@ Y_UNIT_TEST_SUITE(TWeakPtrTest) { } }; - Y_UNIT_TEST(Simple) { + Y_UNIT_TEST(Simple) { int destroyCount = 0; TIntrusivePtr<TWeakPtrTester> p(new TWeakPtrTester(&destroyCount)); diff --git a/library/cpp/messagebus/moved_ut.cpp b/library/cpp/messagebus/moved_ut.cpp index c1a07cce7ee..5345b81947f 100644 --- a/library/cpp/messagebus/moved_ut.cpp +++ b/library/cpp/messagebus/moved_ut.cpp @@ -2,8 +2,8 @@ #include "moved.h" -Y_UNIT_TEST_SUITE(TMovedTest) { - Y_UNIT_TEST(Simple) { +Y_UNIT_TEST_SUITE(TMovedTest) { + Y_UNIT_TEST(Simple) { TMoved<THolder<int>> h1(MakeHolder<int>(10)); TMoved<THolder<int>> h2 = h1; UNIT_ASSERT(!*h1); @@ -15,7 +15,7 @@ Y_UNIT_TEST_SUITE(TMovedTest) { UNIT_ASSERT_VALUES_EQUAL(11, **h); } - Y_UNIT_TEST(PassToFunction) { + Y_UNIT_TEST(PassToFunction) { THolder<int> h(new int(11)); Foo(h); } diff --git a/library/cpp/messagebus/netaddr_ut.cpp b/library/cpp/messagebus/netaddr_ut.cpp index e5c68bf402c..63b688e53be 100644 --- a/library/cpp/messagebus/netaddr_ut.cpp +++ b/library/cpp/messagebus/netaddr_ut.cpp @@ -5,17 +5,17 @@ using namespace NBus; -Y_UNIT_TEST_SUITE(TNetAddr) { - Y_UNIT_TEST(ResolveIpv4) { +Y_UNIT_TEST_SUITE(TNetAddr) { + Y_UNIT_TEST(ResolveIpv4) { ASSUME_IP_V4_ENABLED; UNIT_ASSERT(TNetAddr("ns1.yandex.ru", 80, EIP_VERSION_4).IsIpv4()); } - Y_UNIT_TEST(ResolveIpv6) { + Y_UNIT_TEST(ResolveIpv6) { UNIT_ASSERT(TNetAddr("ns1.yandex.ru", 80, EIP_VERSION_6).IsIpv6()); } - Y_UNIT_TEST(ResolveAny) { + Y_UNIT_TEST(ResolveAny) { TNetAddr("ns1.yandex.ru", 80, EIP_VERSION_ANY); } } diff --git a/library/cpp/messagebus/network.cpp b/library/cpp/messagebus/network.cpp index 304bedae5ac..7fe03a90103 100644 --- a/library/cpp/messagebus/network.cpp +++ b/library/cpp/messagebus/network.cpp @@ -11,7 +11,7 @@ using namespace NBus::NPrivate; namespace { TBindResult BindOnPortProto(int port, int af, bool reusePort) { - Y_VERIFY(af == AF_INET || af == AF_INET6, "wrong af"); + Y_VERIFY(af == AF_INET || af == AF_INET6, "wrong af"); SOCKET fd = ::socket(af, SOCK_STREAM, 0); if (fd == INVALID_SOCKET) { @@ -126,8 +126,8 @@ void NBus::NPrivate::SetSockOptTcpCork(SOCKET s, bool value) { #ifdef _linux_ CheckedSetSockOpt(s, IPPROTO_TCP, TCP_CORK, (int)value, "TCP_CORK"); #else - Y_UNUSED(s); - Y_UNUSED(value); + Y_UNUSED(s); + Y_UNUSED(value); #endif } @@ -138,7 +138,7 @@ ssize_t NBus::NPrivate::SocketSend(SOCKET s, TArrayRef<const char> data) { #endif ssize_t r = ::send(s, data.data(), data.size(), flags); if (r < 0) { - Y_VERIFY(LastSystemError() != EBADF, "bad fd"); + Y_VERIFY(LastSystemError() != EBADF, "bad fd"); } return r; } @@ -150,7 +150,7 @@ ssize_t NBus::NPrivate::SocketRecv(SOCKET s, TArrayRef<char> buffer) { #endif ssize_t r = ::recv(s, buffer.data(), buffer.size(), flags); if (r < 0) { - Y_VERIFY(LastSystemError() != EBADF, "bad fd"); + Y_VERIFY(LastSystemError() != EBADF, "bad fd"); } return r; } diff --git a/library/cpp/messagebus/network_ut.cpp b/library/cpp/messagebus/network_ut.cpp index f1798419db2..05f4cb63547 100644 --- a/library/cpp/messagebus/network_ut.cpp +++ b/library/cpp/messagebus/network_ut.cpp @@ -31,8 +31,8 @@ namespace { } } -Y_UNIT_TEST_SUITE(Network) { - Y_UNIT_TEST(BindOnPortConcrete) { +Y_UNIT_TEST_SUITE(Network) { + Y_UNIT_TEST(BindOnPortConcrete) { if (!IsFixedPortTestAllowed()) { return; } @@ -45,7 +45,7 @@ Y_UNIT_TEST_SUITE(Network) { } } - Y_UNIT_TEST(BindOnPortRandom) { + Y_UNIT_TEST(BindOnPortRandom) { TVector<TBindResult> r = BindOnPort(0, false).second; UNIT_ASSERT_VALUES_EQUAL(size_t(2), r.size()); @@ -57,7 +57,7 @@ Y_UNIT_TEST_SUITE(Network) { UNIT_ASSERT_VALUES_EQUAL(r.at(0).Addr.GetPort(), r.at(1).Addr.GetPort()); } - Y_UNIT_TEST(BindOnBusyPort) { + Y_UNIT_TEST(BindOnBusyPort) { auto r = BindOnPort(0, false); UNIT_ASSERT_EXCEPTION_CONTAINS(BindOnPort(r.first, false), TSystemError, "failed to bind on port " + ToString(r.first)); diff --git a/library/cpp/messagebus/nondestroying_holder.h b/library/cpp/messagebus/nondestroying_holder.h index f4725d696f7..b7d4efd2b4b 100644 --- a/library/cpp/messagebus/nondestroying_holder.h +++ b/library/cpp/messagebus/nondestroying_holder.h @@ -16,7 +16,7 @@ public: } ~TNonDestroyingHolder() { - Y_VERIFY(!*this, "stored object must be explicitly released"); + Y_VERIFY(!*this, "stored object must be explicitly released"); } }; @@ -34,6 +34,6 @@ public: } inline ~TNonDestroyingAutoPtr() { - Y_VERIFY(!*this, "stored object must be explicitly released"); + Y_VERIFY(!*this, "stored object must be explicitly released"); } }; diff --git a/library/cpp/messagebus/nondestroying_holder_ut.cpp b/library/cpp/messagebus/nondestroying_holder_ut.cpp index 208042a2ba6..02a417a8feb 100644 --- a/library/cpp/messagebus/nondestroying_holder_ut.cpp +++ b/library/cpp/messagebus/nondestroying_holder_ut.cpp @@ -2,8 +2,8 @@ #include "nondestroying_holder.h" -Y_UNIT_TEST_SUITE(TNonDestroyingHolder) { - Y_UNIT_TEST(ToAutoPtr) { +Y_UNIT_TEST_SUITE(TNonDestroyingHolder) { + Y_UNIT_TEST(ToAutoPtr) { TNonDestroyingHolder<int> h(new int(11)); TAutoPtr<int> i(h); UNIT_ASSERT_VALUES_EQUAL(11, *i); diff --git a/library/cpp/messagebus/oldmodule/module.cpp b/library/cpp/messagebus/oldmodule/module.cpp index 24bd778799f..fd08e223e82 100644 --- a/library/cpp/messagebus/oldmodule/module.cpp +++ b/library/cpp/messagebus/oldmodule/module.cpp @@ -774,7 +774,7 @@ void TBusModuleImpl::DestroyJob(TJobRunner* job) { { TWhatThreadDoesAcquireGuard<TMutex> G(Lock, "modules: acquiring lock for DestroyJob"); int jobCount = AtomicDecrement(JobCount); - Y_VERIFY(jobCount >= 0, "decremented too much"); + Y_VERIFY(jobCount >= 0, "decremented too much"); Jobs.erase(job->JobStorageIterator); if (AtomicGet(State) == STOPPED) { @@ -789,7 +789,7 @@ void TBusModuleImpl::DestroyJob(TJobRunner* job) { void TBusModuleImpl::OnMessageReceived(TAutoPtr<TBusMessage> msg0, TOnMessageContext& context) { TBusMessage* msg = !!msg0 ? msg0.Get() : context.GetMessage(); - Y_VERIFY(!!msg); + Y_VERIFY(!!msg); THolder<TJobRunner> jobRunner(new TJobRunner(Module->CreateJobInstance(msg))); jobRunner->Job->MessageHolder.Reset(msg0.Release()); @@ -810,11 +810,11 @@ void TBusModuleImpl::Shutdown() { } AtomicSet(State, TBusModuleImpl::STOPPED); - for (auto& clientSession : ClientSessions) { - clientSession->Shutdown(); + for (auto& clientSession : ClientSessions) { + clientSession->Shutdown(); } - for (auto& serverSession : ServerSessions) { - serverSession->Shutdown(); + for (auto& serverSession : ServerSessions) { + serverSession->Shutdown(); } for (size_t starter = 0; starter < Starters.size(); ++starter) { @@ -823,8 +823,8 @@ void TBusModuleImpl::Shutdown() { { TWhatThreadDoesAcquireGuard<TMutex> guard(Lock, "modules: acquiring lock for Shutdown"); - for (auto& Job : Jobs) { - Job->Schedule(); + for (auto& Job : Jobs) { + Job->Schedule(); } while (!Jobs.empty()) { @@ -834,8 +834,8 @@ void TBusModuleImpl::Shutdown() { } EMessageStatus TBusModule::StartJob(TAutoPtr<TBusMessage> message) { - Y_VERIFY(Impl->State == TBusModuleImpl::RUNNING); - Y_VERIFY(!!Impl->Queue); + Y_VERIFY(Impl->State == TBusModuleImpl::RUNNING); + Y_VERIFY(!!Impl->Queue); if ((unsigned)AtomicGet(Impl->JobCount) >= Impl->ModuleConfig.StarterMaxInFlight) { return MESSAGE_BUSY; @@ -853,16 +853,16 @@ void TModuleServerHandler::OnMessage(TOnMessageContext& msg) { void TModuleClientHandler::OnReply(TAutoPtr<TBusMessage> req, TAutoPtr<TBusMessage> resp) { TJobRunner* job = GetJob(req.Get()); - Y_ASSERT(job); - Y_ASSERT(job->Job->Message != req.Get()); + Y_ASSERT(job); + Y_ASSERT(job->Job->Message != req.Get()); job->EnqueueAndSchedule(TJobResponseMessage(req.Release(), resp.Release(), MESSAGE_OK)); job->UnRef(); } void TModuleClientHandler::OnMessageSentOneWay(TAutoPtr<TBusMessage> req) { TJobRunner* job = GetJob(req.Get()); - Y_ASSERT(job); - Y_ASSERT(job->Job->Message != req.Get()); + Y_ASSERT(job); + Y_ASSERT(job->Job->Message != req.Get()); job->EnqueueAndSchedule(TJobResponseMessage(req.Release(), nullptr, MESSAGE_OK)); job->UnRef(); } @@ -870,7 +870,7 @@ void TModuleClientHandler::OnMessageSentOneWay(TAutoPtr<TBusMessage> req) { void TModuleClientHandler::OnError(TAutoPtr<TBusMessage> msg, EMessageStatus status) { TJobRunner* job = GetJob(msg.Get()); if (job) { - Y_ASSERT(job->Job->Message != msg.Get()); + Y_ASSERT(job->Job->Message != msg.Get()); job->EnqueueAndSchedule(TJobResponseMessage(msg.Release(), nullptr, status)); job->UnRef(); } diff --git a/library/cpp/messagebus/protobuf/ybusbuf.cpp b/library/cpp/messagebus/protobuf/ybusbuf.cpp index 63415b3737f..ac4b5a9d17f 100644 --- a/library/cpp/messagebus/protobuf/ybusbuf.cpp +++ b/library/cpp/messagebus/protobuf/ybusbuf.cpp @@ -12,8 +12,8 @@ TBusBufferProtocol::TBusBufferProtocol(TBusService name, int port) } TBusBufferProtocol::~TBusBufferProtocol() { - for (auto& type : Types) { - delete type; + for (auto& type : Types) { + delete type; } } @@ -47,7 +47,7 @@ void TBusBufferProtocol::Serialize(const TBusMessage* mess, TBuffer& data) { const TBusHeader* header = mess->GetHeader(); if (!IsRegisteredType(header->Type)) { - Y_FAIL("unknown message type: %d", int(header->Type)); + Y_FAIL("unknown message type: %d", int(header->Type)); return; } @@ -58,7 +58,7 @@ void TBusBufferProtocol::Serialize(const TBusMessage* mess, TBuffer& data) { data.Reserve(data.Size() + size); char* after = (char*)bmess->GetRecord()->SerializeWithCachedSizesToArray((ui8*)data.Pos()); - Y_VERIFY(after - data.Pos() == size); + Y_VERIFY(after - data.Pos() == size); data.Advance(size); } @@ -69,7 +69,7 @@ TAutoPtr<TBusMessage> TBusBufferProtocol::Deserialize(ui16 messageType, TArrayRe TBusBufferBase* messageTemplate = FindType(messageType); if (messageTemplate == nullptr) { return nullptr; - //Y_FAIL("unknown message type: %d", unsigned(messageType)); + //Y_FAIL("unknown message type: %d", unsigned(messageType)); } // clone the base diff --git a/library/cpp/messagebus/rain_check/core/coro.cpp b/library/cpp/messagebus/rain_check/core/coro.cpp index 500841dd5b8..c79c6dfc5b2 100644 --- a/library/cpp/messagebus/rain_check/core/coro.cpp +++ b/library/cpp/messagebus/rain_check/core/coro.cpp @@ -23,7 +23,7 @@ TCoroTaskRunner::TCoroTaskRunner(IEnv* env, ISubtaskListener* parent, TAutoPtr<I } TCoroTaskRunner::~TCoroTaskRunner() { - Y_ASSERT(CoroDone); + Y_ASSERT(CoroDone); } Y_POD_STATIC_THREAD(TContMachineContext*) @@ -32,7 +32,7 @@ Y_POD_STATIC_THREAD(TCoroTaskRunner*) Task; bool TCoroTaskRunner::ReplyReceived() { - Y_ASSERT(!CoroDone); + Y_ASSERT(!CoroDone); TContMachineContext me; @@ -43,8 +43,8 @@ bool TCoroTaskRunner::ReplyReceived() { Stack.VerifyNoStackOverflow(); - Y_ASSERT(CallerContext == &me); - Y_ASSERT(Task == this); + Y_ASSERT(CallerContext == &me); + Y_ASSERT(Task == this); return !CoroDone; } diff --git a/library/cpp/messagebus/rain_check/core/coro_stack.cpp b/library/cpp/messagebus/rain_check/core/coro_stack.cpp index 83b984ca6e9..e4517393e4a 100644 --- a/library/cpp/messagebus/rain_check/core/coro_stack.cpp +++ b/library/cpp/messagebus/rain_check/core/coro_stack.cpp @@ -12,8 +12,8 @@ using namespace NRainCheck::NPrivate; TCoroStack::TCoroStack(size_t size) : SizeValue(size) { - Y_VERIFY(size % sizeof(ui32) == 0); - Y_VERIFY(size >= 0x1000); + Y_VERIFY(size % sizeof(ui32) == 0); + Y_VERIFY(size >= 0x1000); DataHolder.Reset(malloc(size)); diff --git a/library/cpp/messagebus/rain_check/core/coro_ut.cpp b/library/cpp/messagebus/rain_check/core/coro_ut.cpp index 61a33584a5f..7157230da73 100644 --- a/library/cpp/messagebus/rain_check/core/coro_ut.cpp +++ b/library/cpp/messagebus/rain_check/core/coro_ut.cpp @@ -7,7 +7,7 @@ using namespace NRainCheck; -Y_UNIT_TEST_SUITE(RainCheckCoro) { +Y_UNIT_TEST_SUITE(RainCheckCoro) { struct TSimpleCoroTask : ICoroTask { TTestSync* const TestSync; @@ -21,7 +21,7 @@ Y_UNIT_TEST_SUITE(RainCheckCoro) { } }; - Y_UNIT_TEST(Simple) { + Y_UNIT_TEST(Simple) { TTestSync testSync; TTestEnv env; @@ -49,7 +49,7 @@ Y_UNIT_TEST_SUITE(RainCheckCoro) { } }; - Y_UNIT_TEST(Sleep) { + Y_UNIT_TEST(Sleep) { TTestSync testSync; TTestEnv env; @@ -94,7 +94,7 @@ Y_UNIT_TEST_SUITE(RainCheckCoro) { } }; - Y_UNIT_TEST(Spawn) { + Y_UNIT_TEST(Spawn) { TTestSync testSync; TTestEnv env; diff --git a/library/cpp/messagebus/rain_check/core/simple.cpp b/library/cpp/messagebus/rain_check/core/simple.cpp index 70182b2f93e..22e721758e2 100644 --- a/library/cpp/messagebus/rain_check/core/simple.cpp +++ b/library/cpp/messagebus/rain_check/core/simple.cpp @@ -9,7 +9,7 @@ TSimpleTaskRunner::TSimpleTaskRunner(IEnv* env, ISubtaskListener* parentTask, TA } TSimpleTaskRunner::~TSimpleTaskRunner() { - Y_ASSERT(!ContinueFunc); + Y_ASSERT(!ContinueFunc); } bool TSimpleTaskRunner::ReplyReceived() { diff --git a/library/cpp/messagebus/rain_check/core/simple_ut.cpp b/library/cpp/messagebus/rain_check/core/simple_ut.cpp index d4545e05aa1..2eb5fad8f9f 100644 --- a/library/cpp/messagebus/rain_check/core/simple_ut.cpp +++ b/library/cpp/messagebus/rain_check/core/simple_ut.cpp @@ -8,7 +8,7 @@ using namespace NRainCheck; -Y_UNIT_TEST_SUITE(RainCheckSimple) { +Y_UNIT_TEST_SUITE(RainCheckSimple) { struct TTaskWithCompletionCallback: public ISimpleTask { TTestEnv* const Env; TTestSync* const TestSync; @@ -31,7 +31,7 @@ Y_UNIT_TEST_SUITE(RainCheckSimple) { } void SleepCompletionCallback(TSubtaskCompletion* completion) { - Y_VERIFY(completion == &SleepCompletion); + Y_VERIFY(completion == &SleepCompletion); TestSync->CheckAndIncrement(1); Env->SleepService.Sleep(&SleepCompletion, TDuration::MilliSeconds(1)); @@ -48,7 +48,7 @@ Y_UNIT_TEST_SUITE(RainCheckSimple) { } }; - Y_UNIT_TEST(CompletionCallback) { + Y_UNIT_TEST(CompletionCallback) { TTestEnv env; TTestSync testSync; diff --git a/library/cpp/messagebus/rain_check/core/sleep_ut.cpp b/library/cpp/messagebus/rain_check/core/sleep_ut.cpp index 2ae85a87b18..f38daf75d67 100644 --- a/library/cpp/messagebus/rain_check/core/sleep_ut.cpp +++ b/library/cpp/messagebus/rain_check/core/sleep_ut.cpp @@ -7,7 +7,7 @@ using namespace NRainCheck; using namespace NActor; -Y_UNIT_TEST_SUITE(Sleep) { +Y_UNIT_TEST_SUITE(Sleep) { struct TTestTask: public ISimpleTask { TSimpleEnv* const Env; TTestSync* const TestSync; @@ -34,7 +34,7 @@ Y_UNIT_TEST_SUITE(Sleep) { } }; - Y_UNIT_TEST(Test) { + Y_UNIT_TEST(Test) { TTestSync testSync; TSimpleEnv env; diff --git a/library/cpp/messagebus/rain_check/core/spawn_ut.cpp b/library/cpp/messagebus/rain_check/core/spawn_ut.cpp index ba5a5e41cf6..3aefde88f73 100644 --- a/library/cpp/messagebus/rain_check/core/spawn_ut.cpp +++ b/library/cpp/messagebus/rain_check/core/spawn_ut.cpp @@ -12,7 +12,7 @@ using namespace NRainCheck; using namespace NActor; -Y_UNIT_TEST_SUITE(Spawn) { +Y_UNIT_TEST_SUITE(Spawn) { struct TTestTask: public ISimpleTask { TTestSync* const TestSync; @@ -43,7 +43,7 @@ Y_UNIT_TEST_SUITE(Spawn) { } }; - Y_UNIT_TEST(Continuation) { + Y_UNIT_TEST(Continuation) { TTestSync testSync; TSimpleEnv env; @@ -94,7 +94,7 @@ Y_UNIT_TEST_SUITE(Spawn) { } }; - Y_UNIT_TEST(Subtask) { + Y_UNIT_TEST(Subtask) { TTestSync testSync; TTestEnv env; @@ -124,8 +124,8 @@ Y_UNIT_TEST_SUITE(Spawn) { return nullptr; } - for (auto& subtask : Subtasks) { - SpawnSubtask<TNopSimpleTask>(Env, &subtask, ""); + for (auto& subtask : Subtasks) { + SpawnSubtask<TNopSimpleTask>(Env, &subtask, ""); } ++I; @@ -133,7 +133,7 @@ Y_UNIT_TEST_SUITE(Spawn) { } }; - Y_UNIT_TEST(SubtaskLong) { + Y_UNIT_TEST(SubtaskLong) { TTestSync testSync; TTestEnv env; diff --git a/library/cpp/messagebus/rain_check/core/task.cpp b/library/cpp/messagebus/rain_check/core/task.cpp index a098437d534..3094890ed5f 100644 --- a/library/cpp/messagebus/rain_check/core/task.cpp +++ b/library/cpp/messagebus/rain_check/core/task.cpp @@ -31,7 +31,7 @@ TTaskRunnerBase::TTaskRunnerBase(IEnv* env, ISubtaskListener* parentTask, TAutoP } TTaskRunnerBase::~TTaskRunnerBase() { - Y_ASSERT(Done); + Y_ASSERT(Done); } namespace { @@ -40,19 +40,19 @@ namespace { TRunningInThisThreadGuard(TTaskRunnerBase* task) : Task(task) { - Y_ASSERT(!ThreadCurrentTask); + Y_ASSERT(!ThreadCurrentTask); ThreadCurrentTask = task; } ~TRunningInThisThreadGuard() { - Y_ASSERT(ThreadCurrentTask == Task); + Y_ASSERT(ThreadCurrentTask == Task); ThreadCurrentTask = nullptr; } }; } void NRainCheck::TTaskRunnerBase::Act(NActor::TDefaultTag) { - Y_ASSERT(RefCount() > 0); + Y_ASSERT(RefCount() > 0); TRunningInThisThreadGuard g(this); @@ -63,11 +63,11 @@ void NRainCheck::TTaskRunnerBase::Act(NActor::TDefaultTag) { temp.GetVector()->swap(Pending); - for (auto& pending : *temp.GetVector()) { - if (pending->IsComplete()) { - pending->FireCompletionCallback(GetImplBase()); + for (auto& pending : *temp.GetVector()) { + if (pending->IsComplete()) { + pending->FireCompletionCallback(GetImplBase()); } else { - Pending.push_back(pending); + Pending.push_back(pending); } } @@ -96,11 +96,11 @@ bool TTaskRunnerBase::IsRunningInThisThread() const { TSubtaskCompletion::~TSubtaskCompletion() { ESubtaskState state = State.Get(); - Y_ASSERT(state == CREATED || state == DONE || state == CANCELED); + Y_ASSERT(state == CREATED || state == DONE || state == CANCELED); } void TSubtaskCompletion::FireCompletionCallback(ITaskBase* task) { - Y_ASSERT(IsComplete()); + Y_ASSERT(IsComplete()); if (!!CompletionFunc) { TSubtaskCompletionFunc temp = CompletionFunc; @@ -130,8 +130,8 @@ void NRainCheck::TSubtaskCompletion::Cancel() { } void TSubtaskCompletion::SetRunning(TTaskRunnerBase* parent) { - Y_ASSERT(!TaskRunner); - Y_ASSERT(!!parent); + Y_ASSERT(!TaskRunner); + Y_ASSERT(!!parent); TaskRunner = parent; @@ -142,7 +142,7 @@ void TSubtaskCompletion::SetRunning(TTaskRunnerBase* parent) { for (;;) { ESubtaskState current = State.Get(); if (current != CREATED && current != DONE) { - Y_FAIL("current state should be CREATED or DONE: %s", ToCString(current)); + Y_FAIL("current state should be CREATED or DONE: %s", ToCString(current)); } if (State.CompareAndSet(current, RUNNING)) { return; @@ -151,7 +151,7 @@ void TSubtaskCompletion::SetRunning(TTaskRunnerBase* parent) { } void TSubtaskCompletion::SetDone() { - Y_ASSERT(!!TaskRunner); + Y_ASSERT(!!TaskRunner); TTaskRunnerBase* temp = TaskRunner; TaskRunner = nullptr; @@ -166,7 +166,7 @@ void TSubtaskCompletion::SetDone() { break; } } else { - Y_FAIL("cannot SetDone: unknown state: %s", ToCString(state)); + Y_FAIL("cannot SetDone: unknown state: %s", ToCString(state)); } } @@ -195,11 +195,11 @@ void NRainCheck::TTaskRunnerBase::ReleaseRef() #endif void TTaskRunnerBase::AssertInThisThread() const { - Y_ASSERT(IsRunningInThisThread()); + Y_ASSERT(IsRunningInThisThread()); } TTaskRunnerBase* TTaskRunnerBase::CurrentTask() { - Y_VERIFY(!!ThreadCurrentTask); + Y_VERIFY(!!ThreadCurrentTask); return ThreadCurrentTask; } diff --git a/library/cpp/messagebus/rain_check/core/track.cpp b/library/cpp/messagebus/rain_check/core/track.cpp index 092a51a2143..d41f6884ba2 100644 --- a/library/cpp/messagebus/rain_check/core/track.cpp +++ b/library/cpp/messagebus/rain_check/core/track.cpp @@ -17,7 +17,7 @@ TTaskTracker::TTaskTracker(NActor::TExecutor* executor) } TTaskTracker::~TTaskTracker() { - Y_ASSERT(Tasks.Empty()); + Y_ASSERT(Tasks.Empty()); } void TTaskTracker::Shutdown() { @@ -36,7 +36,7 @@ void TTaskTracker::ProcessItem(NActor::TDefaultTag, NActor::TDefaultTag, ITaskFa } void TTaskTracker::ProcessItem(NActor::TDefaultTag, NActor::TDefaultTag, TTaskTrackerReceipt* receipt) { - Y_ASSERT(!receipt->Empty()); + Y_ASSERT(!receipt->Empty()); receipt->Unlink(); delete receipt; } diff --git a/library/cpp/messagebus/rain_check/core/track_ut.cpp b/library/cpp/messagebus/rain_check/core/track_ut.cpp index 05f7de13195..22b9b65fe14 100644 --- a/library/cpp/messagebus/rain_check/core/track_ut.cpp +++ b/library/cpp/messagebus/rain_check/core/track_ut.cpp @@ -7,7 +7,7 @@ using namespace NRainCheck; -Y_UNIT_TEST_SUITE(TaskTracker) { +Y_UNIT_TEST_SUITE(TaskTracker) { struct TTaskForTracker: public ISimpleTask { TTestSync* const TestSync; @@ -23,7 +23,7 @@ Y_UNIT_TEST_SUITE(TaskTracker) { } }; - Y_UNIT_TEST(Simple) { + Y_UNIT_TEST(Simple) { TTestEnv env; TIntrusivePtr<TTaskTracker> tracker(new TTaskTracker(env.GetExecutor())); diff --git a/library/cpp/messagebus/rain_check/http/client_ut.cpp b/library/cpp/messagebus/rain_check/http/client_ut.cpp index 16281143911..07941acdf58 100644 --- a/library/cpp/messagebus/rain_check/http/client_ut.cpp +++ b/library/cpp/messagebus/rain_check/http/client_ut.cpp @@ -141,10 +141,10 @@ namespace { } // anonymous namespace -Y_UNIT_TEST_SUITE(RainCheckHttpClient) { +Y_UNIT_TEST_SUITE(RainCheckHttpClient) { static const TIpPort SERVER_PORT = 4000; - Y_UNIT_TEST(Simple) { + Y_UNIT_TEST(Simple) { // TODO: randomize port if (!IsFixedPortTestAllowed()) { return; @@ -159,7 +159,7 @@ Y_UNIT_TEST_SUITE(RainCheckHttpClient) { env.TestSync.WaitForAndIncrement(1); } - Y_UNIT_TEST(SimplePost) { + Y_UNIT_TEST(SimplePost) { // TODO: randomize port if (!IsFixedPortTestAllowed()) { return; @@ -174,7 +174,7 @@ Y_UNIT_TEST_SUITE(RainCheckHttpClient) { env.TestSync.WaitForAndIncrement(1); } - Y_UNIT_TEST(HttpCodeExtraction) { + Y_UNIT_TEST(HttpCodeExtraction) { // Find "request failed(" string, then copy len("HTTP/1.X NNN") chars and try to convert NNN to HTTP code. #define CHECK_VALID_LINE(line, code) \ diff --git a/library/cpp/messagebus/rain_check/messagebus/messagebus_client.cpp b/library/cpp/messagebus/rain_check/messagebus/messagebus_client.cpp index daac8d9a993..6a42e74c25e 100644 --- a/library/cpp/messagebus/rain_check/messagebus/messagebus_client.cpp +++ b/library/cpp/messagebus/rain_check/messagebus/messagebus_client.cpp @@ -66,7 +66,7 @@ void TBusClientService::OnReply( TAutoPtr<TBusMessage> request, TAutoPtr<TBusMessage> response) { TBusFuture* future = (TBusFuture*)request->Data; - Y_ASSERT(future->Request.Get() == request.Get()); + Y_ASSERT(future->Request.Get() == request.Get()); Y_UNUSED(request.Release()); future->SetDoneAndSchedule(MESSAGE_OK, response); } @@ -74,7 +74,7 @@ void TBusClientService::OnReply( void NRainCheck::TBusClientService::OnMessageSentOneWay( TAutoPtr<NBus::TBusMessage> request) { TBusFuture* future = (TBusFuture*)request->Data; - Y_ASSERT(future->Request.Get() == request.Get()); + Y_ASSERT(future->Request.Get() == request.Get()); Y_UNUSED(request.Release()); future->SetDoneAndSchedule(MESSAGE_OK, nullptr); } @@ -86,7 +86,7 @@ void TBusClientService::OnError( } TBusFuture* future = (TBusFuture*)message->Data; - Y_ASSERT(future->Request.Get() == message.Get()); + Y_ASSERT(future->Request.Get() == message.Get()); Y_UNUSED(message.Release()); future->SetDoneAndSchedule(status, nullptr); } diff --git a/library/cpp/messagebus/rain_check/messagebus/messagebus_client.h b/library/cpp/messagebus/rain_check/messagebus/messagebus_client.h index 0a291cdea69..6b267550833 100644 --- a/library/cpp/messagebus/rain_check/messagebus/messagebus_client.h +++ b/library/cpp/messagebus/rain_check/messagebus/messagebus_client.h @@ -31,12 +31,12 @@ namespace NRainCheck { } NBus::TBusMessage* GetResponse() const { - Y_ASSERT(IsDone()); + Y_ASSERT(IsDone()); return Response.Get(); } NBus::EMessageStatus GetStatus() const { - Y_ASSERT(IsDone()); + Y_ASSERT(IsDone()); return Status; } }; diff --git a/library/cpp/messagebus/rain_check/messagebus/messagebus_client_ut.cpp b/library/cpp/messagebus/rain_check/messagebus/messagebus_client_ut.cpp index 1b3618558b8..e0883b49b98 100644 --- a/library/cpp/messagebus/rain_check/messagebus/messagebus_client_ut.cpp +++ b/library/cpp/messagebus/rain_check/messagebus/messagebus_client_ut.cpp @@ -32,7 +32,7 @@ struct TMessageBusClientEnv: public TTestEnvTemplate<TMessageBusClientEnv> { } }; -Y_UNIT_TEST_SUITE(RainCheckMessageBusClient) { +Y_UNIT_TEST_SUITE(RainCheckMessageBusClient) { struct TSimpleTask: public ISimpleTask { TMessageBusClientEnv* const Env; @@ -58,7 +58,7 @@ Y_UNIT_TEST_SUITE(RainCheckMessageBusClient) { TContinueFunc GotReplies() { for (unsigned i = 0; i < Requests.size(); ++i) { - Y_VERIFY(Requests[i]->GetStatus() == MESSAGE_OK); + Y_VERIFY(Requests[i]->GetStatus() == MESSAGE_OK); VerifyDynamicCast<TExampleResponse*>(Requests[i]->GetResponse()); } Env->TestSync.CheckAndIncrement(0); @@ -66,7 +66,7 @@ Y_UNIT_TEST_SUITE(RainCheckMessageBusClient) { } }; - Y_UNIT_TEST(Simple) { + Y_UNIT_TEST(Simple) { TObjectCountCheck objectCountCheck; TExampleServer server; @@ -124,15 +124,15 @@ Y_UNIT_TEST_SUITE(RainCheckMessageBusClient) { TContinueFunc GotReplies() { for (unsigned i = 0; i < Requests.size(); ++i) { - Y_VERIFY(Requests[i]->GetStatus() == MESSAGE_OK); - Y_VERIFY(!Requests[i]->GetResponse()); + Y_VERIFY(Requests[i]->GetStatus() == MESSAGE_OK); + Y_VERIFY(!Requests[i]->GetResponse()); } Env->TestSync.WaitForAndIncrement(2); return nullptr; } }; - Y_UNIT_TEST(OneWay) { + Y_UNIT_TEST(OneWay) { TObjectCountCheck objectCountCheck; TMessageBusClientEnv env; diff --git a/library/cpp/messagebus/rain_check/messagebus/messagebus_server_ut.cpp b/library/cpp/messagebus/rain_check/messagebus/messagebus_server_ut.cpp index 7c11399f1be..af2084762f2 100644 --- a/library/cpp/messagebus/rain_check/messagebus/messagebus_server_ut.cpp +++ b/library/cpp/messagebus/rain_check/messagebus/messagebus_server_ut.cpp @@ -14,7 +14,7 @@ struct TMessageBusServerEnv: public TTestEnvTemplate<TMessageBusServerEnv> { TExampleProtocol Proto; }; -Y_UNIT_TEST_SUITE(RainCheckMessageBusServer) { +Y_UNIT_TEST_SUITE(RainCheckMessageBusServer) { struct TSimpleServerTask: public ISimpleTask { private: TMessageBusServerEnv* const Env; @@ -33,7 +33,7 @@ Y_UNIT_TEST_SUITE(RainCheckMessageBusServer) { } }; - Y_UNIT_TEST(Simple) { + Y_UNIT_TEST(Simple) { TMessageBusServerEnv env; THolder<TBusTaskStarter> starter(TBusTaskStarter::NewStarter<TSimpleServerTask>(&env)); diff --git a/library/cpp/messagebus/rain_check/test/helper/misc.cpp b/library/cpp/messagebus/rain_check/test/helper/misc.cpp index c0fcb272523..e0a88a8ab9f 100644 --- a/library/cpp/messagebus/rain_check/test/helper/misc.cpp +++ b/library/cpp/messagebus/rain_check/test/helper/misc.cpp @@ -5,7 +5,7 @@ using namespace NRainCheck; void TSpawnNopTasksCoroTask::Run() { - Y_VERIFY(Count <= Completion.size()); + Y_VERIFY(Count <= Completion.size()); for (unsigned i = 0; i < Count; ++i) { SpawnSubtask<TNopCoroTask>(Env, &Completion[i], ""); } @@ -14,7 +14,7 @@ void TSpawnNopTasksCoroTask::Run() { } TContinueFunc TSpawnNopTasksSimpleTask::Start() { - Y_VERIFY(Count <= Completion.size()); + Y_VERIFY(Count <= Completion.size()); for (unsigned i = 0; i < Count; ++i) { SpawnSubtask<TNopSimpleTask>(Env, &Completion[i], ""); } diff --git a/library/cpp/messagebus/rain_check/test/perftest/perftest.cpp b/library/cpp/messagebus/rain_check/test/perftest/perftest.cpp index 22edbd8c6ba..5a353da5bb0 100644 --- a/library/cpp/messagebus/rain_check/test/perftest/perftest.cpp +++ b/library/cpp/messagebus/rain_check/test/perftest/perftest.cpp @@ -137,8 +137,8 @@ struct TReproduceCrashTask: public ISimpleTask { }; int main(int argc, char** argv) { - Y_UNUSED(argc); - Y_UNUSED(argv); + Y_UNUSED(argc); + Y_UNUSED(argv); TRainCheckPerftestEnv env; diff --git a/library/cpp/messagebus/remote_client_connection.cpp b/library/cpp/messagebus/remote_client_connection.cpp index 8c7a6db3a8c..9e173706f5b 100644 --- a/library/cpp/messagebus/remote_client_connection.cpp +++ b/library/cpp/messagebus/remote_client_connection.cpp @@ -20,7 +20,7 @@ TRemoteClientConnection::TRemoteClientConnection(TRemoteClientSessionPtr session : TRemoteConnection(session.Get(), id, addr) , ClientHandler(GetSession()->ClientHandler) { - Y_VERIFY(addr.GetPort() > 0, "must connect to non-zero port"); + Y_VERIFY(addr.GetPort() > 0, "must connect to non-zero port"); ScheduleWrite(); } @@ -35,7 +35,7 @@ TBusMessage* TRemoteClientConnection::PopAck(TBusKey id) { SOCKET TRemoteClientConnection::CreateSocket(const TNetAddr& addr) { SOCKET handle = socket(addr.Addr()->sa_family, SOCK_STREAM, 0); - Y_VERIFY(handle != INVALID_SOCKET, "failed to create socket: %s", LastSystemErrorText()); + Y_VERIFY(handle != INVALID_SOCKET, "failed to create socket: %s", LastSystemErrorText()); TSocketHolder s(handle); @@ -61,7 +61,7 @@ void TRemoteClientConnection::TryConnect() { if (AtomicGet(WriterData.Down)) { return; } - Y_VERIFY(!WriterData.Status.Connected); + Y_VERIFY(!WriterData.Status.Connected); TInstant now = TInstant::Now(); @@ -119,8 +119,8 @@ void TRemoteClientConnection::TryConnect() { } void TRemoteClientConnection::HandleEvent(SOCKET socket, void* cookie) { - Y_UNUSED(socket); - Y_ASSERT(cookie == WriteCookie || cookie == ReadCookie); + Y_UNUSED(socket); + Y_ASSERT(cookie == WriteCookie || cookie == ReadCookie); if (cookie == ReadCookie) { ScheduleRead(); } else { @@ -181,18 +181,18 @@ void TRemoteClientConnection::ProcessReplyQueue() { workQueueTemp.GetVector()->reserve(replyQueueTemp.GetVector()->size()); } - for (auto& resp : *replyQueueTemp.GetVector()) { - TBusMessage* req = PopAck(resp.Header.Id); + for (auto& resp : *replyQueueTemp.GetVector()) { + TBusMessage* req = PopAck(resp.Header.Id); if (!req) { - WriterErrorMessage(resp.MessagePtr.Release(), MESSAGE_UNKNOWN); + WriterErrorMessage(resp.MessagePtr.Release(), MESSAGE_UNKNOWN); continue; } if (executeInWorkerPool) { - workQueueTemp.GetVector()->push_back(new TInvokeOnReply(GetSession(), req, resp)); + workQueueTemp.GetVector()->push_back(new TInvokeOnReply(GetSession(), req, resp)); } else { - GetSession()->ReleaseInFlightAndCallOnReply(req, resp); + GetSession()->ReleaseInFlightAndCallOnReply(req, resp); } } @@ -252,11 +252,11 @@ void TRemoteClientConnection::ReaderProcessMessageUnknownVersion(TArrayRef<const LWPROBE(Error, ToString(MESSAGE_INVALID_VERSION), ToString(PeerAddr), ""); ReaderData.Status.Incremental.StatusCounter[MESSAGE_INVALID_VERSION] += 1; // TODO: close connection - Y_FAIL("unknown message"); + Y_FAIL("unknown message"); } void TRemoteClientConnection::ClearOutgoingQueue(TMessagesPtrs& result, bool reconnect) { - Y_ASSERT(result.empty()); + Y_ASSERT(result.empty()); TRemoteConnection::ClearOutgoingQueue(result, reconnect); AckMessages.Clear(&result); @@ -266,26 +266,26 @@ void TRemoteClientConnection::ClearOutgoingQueue(TMessagesPtrs& result, bool rec } void TRemoteClientConnection::MessageSent(TArrayRef<TBusMessagePtrAndHeader> messages) { - for (auto& message : messages) { - bool oneWay = message.LocalFlags & MESSAGE_ONE_WAY_INTERNAL; + for (auto& message : messages) { + bool oneWay = message.LocalFlags & MESSAGE_ONE_WAY_INTERNAL; if (oneWay) { - message.MessagePtr->LocalFlags &= ~MESSAGE_ONE_WAY_INTERNAL; + message.MessagePtr->LocalFlags &= ~MESSAGE_ONE_WAY_INTERNAL; - TBusMessage* ackMsg = this->PopAck(message.Header.Id); + TBusMessage* ackMsg = this->PopAck(message.Header.Id); if (!ackMsg) { // TODO: expired? } - if (ackMsg != message.MessagePtr.Get()) { + if (ackMsg != message.MessagePtr.Get()) { // TODO: non-unique id? } GetSession()->ReleaseInFlight({message.MessagePtr.Get()}); - ClientHandler->OnMessageSentOneWay(message.MessagePtr.Release()); + ClientHandler->OnMessageSentOneWay(message.MessagePtr.Release()); } else { - ClientHandler->OnMessageSent(message.MessagePtr.Get()); - AckMessages.Push(message); + ClientHandler->OnMessageSent(message.MessagePtr.Get()); + AckMessages.Push(message); } } } @@ -306,7 +306,7 @@ EMessageStatus TRemoteClientConnection::SendMessageImpl(TBusMessage* msg, bool w } if (wait) { - Y_VERIFY(!Session->Queue->GetExecutor()->IsInExecutorThread()); + Y_VERIFY(!Session->Queue->GetExecutor()->IsInExecutorThread()); GetSession()->ClientRemoteInFlight.Wait(); } else { if (!GetSession()->ClientRemoteInFlight.TryWait()) { diff --git a/library/cpp/messagebus/remote_client_session.cpp b/library/cpp/messagebus/remote_client_session.cpp index 3bc421944f9..8fcbf6ba2d7 100644 --- a/library/cpp/messagebus/remote_client_session.cpp +++ b/library/cpp/messagebus/remote_client_session.cpp @@ -34,7 +34,7 @@ void TRemoteClientSession::OnMessageReceived(TRemoteConnection* c, TVectorSwaps< } EMessageStatus TRemoteClientSession::SendMessageImpl(TBusMessage* msg, const TNetAddr* addr, bool wait, bool oneWay) { - if (Y_UNLIKELY(IsDown())) { + if (Y_UNLIKELY(IsDown())) { return MESSAGE_SHUTDOWN; } @@ -47,7 +47,7 @@ EMessageStatus TRemoteClientSession::SendMessageImpl(TBusMessage* msg, const TNe msg->ReplyTo = resolvedAddr; TRemoteConnectionPtr c = ((TBusSessionImpl*)this)->GetConnection(resolvedAddr, true); - Y_ASSERT(!!c); + Y_ASSERT(!!c); return CheckedCast<TRemoteClientConnection*>(c.Get())->SendMessageImpl(msg, wait, oneWay); } @@ -72,24 +72,24 @@ void TRemoteClientSession::FillStatus() { } void TRemoteClientSession::AcquireInFlight(TArrayRef<TBusMessage* const> messages) { - for (auto message : messages) { - Y_ASSERT(!(message->LocalFlags & MESSAGE_IN_FLIGHT_ON_CLIENT)); - message->LocalFlags |= MESSAGE_IN_FLIGHT_ON_CLIENT; + for (auto message : messages) { + Y_ASSERT(!(message->LocalFlags & MESSAGE_IN_FLIGHT_ON_CLIENT)); + message->LocalFlags |= MESSAGE_IN_FLIGHT_ON_CLIENT; } ClientRemoteInFlight.IncrementMultiple(messages.size()); } void TRemoteClientSession::ReleaseInFlight(TArrayRef<TBusMessage* const> messages) { - for (auto message : messages) { - Y_ASSERT(message->LocalFlags & MESSAGE_IN_FLIGHT_ON_CLIENT); - message->LocalFlags &= ~MESSAGE_IN_FLIGHT_ON_CLIENT; + for (auto message : messages) { + Y_ASSERT(message->LocalFlags & MESSAGE_IN_FLIGHT_ON_CLIENT); + message->LocalFlags &= ~MESSAGE_IN_FLIGHT_ON_CLIENT; } ClientRemoteInFlight.ReleaseMultiple(messages.size()); } void TRemoteClientSession::ReleaseInFlightAndCallOnReply(TNonDestroyingAutoPtr<TBusMessage> request, TBusMessagePtrAndHeader& response) { ReleaseInFlight({request.Get()}); - if (Y_UNLIKELY(AtomicGet(Down))) { + if (Y_UNLIKELY(AtomicGet(Down))) { InvokeOnError(request, MESSAGE_SHUTDOWN); InvokeOnError(response.MessagePtr.Release(), MESSAGE_SHUTDOWN); diff --git a/library/cpp/messagebus/remote_client_session_semaphore.cpp b/library/cpp/messagebus/remote_client_session_semaphore.cpp index f877ed42570..573ef402c18 100644 --- a/library/cpp/messagebus/remote_client_session_semaphore.cpp +++ b/library/cpp/messagebus/remote_client_session_semaphore.cpp @@ -12,12 +12,12 @@ TRemoteClientSessionSemaphore::TRemoteClientSessionSemaphore(TAtomicBase limit, , Current(0) , StopSignal(0) { - Y_VERIFY(limit > 0, "limit must be > 0"); - Y_UNUSED(Name); + Y_VERIFY(limit > 0, "limit must be > 0"); + Y_UNUSED(Name); } TRemoteClientSessionSemaphore::~TRemoteClientSessionSemaphore() { - Y_VERIFY(AtomicGet(Current) == 0); + Y_VERIFY(AtomicGet(Current) == 0); } bool TRemoteClientSessionSemaphore::TryAcquire() { @@ -32,7 +32,7 @@ bool TRemoteClientSessionSemaphore::TryAcquire() { bool TRemoteClientSessionSemaphore::TryWait() { if (AtomicGet(Current) < Limit) return true; - if (Y_UNLIKELY(AtomicGet(StopSignal))) + if (Y_UNLIKELY(AtomicGet(StopSignal))) return true; return false; } diff --git a/library/cpp/messagebus/remote_connection_status.cpp b/library/cpp/messagebus/remote_connection_status.cpp index 2c48b2a287c..34d7973df71 100644 --- a/library/cpp/messagebus/remote_connection_status.cpp +++ b/library/cpp/messagebus/remote_connection_status.cpp @@ -25,8 +25,8 @@ static void Max(T& thiz, const T& that) { template <typename T> static void AssertZero(T& thiz, const T& that) { - Y_ASSERT(thiz == T()); - Y_UNUSED(that); + Y_ASSERT(thiz == T()); + Y_UNUSED(that); } TDurationCounter::TDurationCounter() diff --git a/library/cpp/messagebus/remote_server_connection.cpp b/library/cpp/messagebus/remote_server_connection.cpp index 74be34ded98..d98653f06a3 100644 --- a/library/cpp/messagebus/remote_server_connection.cpp +++ b/library/cpp/messagebus/remote_server_connection.cpp @@ -19,7 +19,7 @@ void TRemoteServerConnection::Init(SOCKET socket, TInstant now) { WriterData.Status.ConnectTime = now; WriterData.Status.Connected = true; - Y_VERIFY(socket != INVALID_SOCKET, "must be a valid socket"); + Y_VERIFY(socket != INVALID_SOCKET, "must be a valid socket"); TSocket readSocket(socket); TSocket writeSocket = readSocket; @@ -37,8 +37,8 @@ TRemoteServerSession* TRemoteServerConnection::GetSession() { } void TRemoteServerConnection::HandleEvent(SOCKET socket, void* cookie) { - Y_UNUSED(socket); - Y_ASSERT(cookie == ReadCookie || cookie == WriteCookie); + Y_UNUSED(socket); + Y_ASSERT(cookie == ReadCookie || cookie == WriteCookie); if (cookie == ReadCookie) { GetSession()->ServerOwnedMessages.Wait(); ScheduleRead(); @@ -55,9 +55,9 @@ void TRemoteServerConnection::MessageSent(TArrayRef<TBusMessagePtrAndHeader> mes TInstant now = TInstant::Now(); GetSession()->ReleaseInWorkResponses(messages); - for (auto& message : messages) { - TInstant recvTime = message.MessagePtr->RecvTime; - GetSession()->ServerHandler->OnSent(message.MessagePtr.Release()); + for (auto& message : messages) { + TInstant recvTime = message.MessagePtr->RecvTime; + GetSession()->ServerHandler->OnSent(message.MessagePtr.Release()); TDuration d = now - recvTime; WriterData.Status.DurationCounter.AddDuration(d); WriterData.Status.Incremental.ProcessDurationHistogram.AddTime(d); diff --git a/library/cpp/messagebus/remote_server_session.cpp b/library/cpp/messagebus/remote_server_session.cpp index 6abbf88a606..12f5408ea95 100644 --- a/library/cpp/messagebus/remote_server_session.cpp +++ b/library/cpp/messagebus/remote_server_session.cpp @@ -69,13 +69,13 @@ void TRemoteServerSession::OnMessageReceived(TRemoteConnection* c, TVectorSwaps< workQueueTemp.GetVector()->reserve(messages.size()); } - for (auto& message : messages) { + for (auto& message : messages) { // TODO: incref once TIntrusivePtr<TRemoteServerConnection> connection(CheckedCast<TRemoteServerConnection*>(c)); if (executeInPool) { - workQueueTemp.GetVector()->push_back(new TInvokeOnMessage(this, message, connection)); + workQueueTemp.GetVector()->push_back(new TInvokeOnMessage(this, message, connection)); } else { - InvokeOnMessage(message, connection); + InvokeOnMessage(message, connection); } } @@ -86,7 +86,7 @@ void TRemoteServerSession::OnMessageReceived(TRemoteConnection* c, TVectorSwaps< } void TRemoteServerSession::InvokeOnMessage(TBusMessagePtrAndHeader& request, TIntrusivePtr<TRemoteServerConnection>& conn) { - if (Y_UNLIKELY(AtomicGet(Down))) { + if (Y_UNLIKELY(AtomicGet(Down))) { ReleaseInWorkRequests(*conn.Get(), request.MessagePtr.Get()); InvokeOnError(request.MessagePtr.Release(), MESSAGE_SHUTDOWN); } else { @@ -97,7 +97,7 @@ void TRemoteServerSession::InvokeOnMessage(TBusMessagePtrAndHeader& request, TIn ident.Connection.Swap(conn); request.MessagePtr->GetIdentity(ident); - Y_ASSERT(request.MessagePtr->LocalFlags & MESSAGE_IN_WORK); + Y_ASSERT(request.MessagePtr->LocalFlags & MESSAGE_IN_WORK); DoSwap(request.MessagePtr->LocalFlags, ident.LocalFlags); ident.RecvTime = request.MessagePtr->RecvTime; @@ -146,7 +146,7 @@ void TRemoteServerSession::FillStatus() { void TRemoteServerSession::AcquireInWorkRequests(TArrayRef<const TBusMessagePtrAndHeader> messages) { TAtomicBase size = 0; for (auto message = messages.begin(); message != messages.end(); ++message) { - Y_ASSERT(!(message->MessagePtr->LocalFlags & MESSAGE_IN_WORK)); + Y_ASSERT(!(message->MessagePtr->LocalFlags & MESSAGE_IN_WORK)); message->MessagePtr->LocalFlags |= MESSAGE_IN_WORK; size += message->MessagePtr->GetHeader()->Size; } @@ -157,7 +157,7 @@ void TRemoteServerSession::AcquireInWorkRequests(TArrayRef<const TBusMessagePtrA void TRemoteServerSession::ReleaseInWorkResponses(TArrayRef<const TBusMessagePtrAndHeader> responses) { TAtomicBase size = 0; for (auto response = responses.begin(); response != responses.end(); ++response) { - Y_ASSERT((response->MessagePtr->LocalFlags & MESSAGE_REPLY_IS_BEGING_SENT)); + Y_ASSERT((response->MessagePtr->LocalFlags & MESSAGE_REPLY_IS_BEGING_SENT)); response->MessagePtr->LocalFlags &= ~MESSAGE_REPLY_IS_BEGING_SENT; size += response->MessagePtr->RequestSize; } @@ -166,7 +166,7 @@ void TRemoteServerSession::ReleaseInWorkResponses(TArrayRef<const TBusMessagePtr } void TRemoteServerSession::ReleaseInWorkRequests(TRemoteConnection& con, TBusMessage* request) { - Y_ASSERT((request->LocalFlags & MESSAGE_IN_WORK)); + Y_ASSERT((request->LocalFlags & MESSAGE_IN_WORK)); request->LocalFlags &= ~MESSAGE_IN_WORK; const size_t size = request->GetHeader()->Size; @@ -186,7 +186,7 @@ void TRemoteServerSession::ConvertInWork(TBusIdentity& req, TBusMessage* reply) reply->SetIdentity(req); req.SetInWork(false); - Y_ASSERT(!(reply->LocalFlags & MESSAGE_REPLY_IS_BEGING_SENT)); + Y_ASSERT(!(reply->LocalFlags & MESSAGE_REPLY_IS_BEGING_SENT)); reply->LocalFlags |= MESSAGE_REPLY_IS_BEGING_SENT; reply->RequestSize = req.Size; } @@ -201,6 +201,6 @@ void TRemoteServerSession::PauseInput(bool pause) { } unsigned TRemoteServerSession::GetActualListenPort() { - Y_VERIFY(Config.ListenPort > 0, "state check"); + Y_VERIFY(Config.ListenPort > 0, "state check"); return Config.ListenPort; } diff --git a/library/cpp/messagebus/remote_server_session_semaphore.cpp b/library/cpp/messagebus/remote_server_session_semaphore.cpp index 6094a3586e6..1d074dbcb7a 100644 --- a/library/cpp/messagebus/remote_server_session_semaphore.cpp +++ b/library/cpp/messagebus/remote_server_session_semaphore.cpp @@ -16,18 +16,18 @@ TRemoteServerSessionSemaphore::TRemoteServerSessionSemaphore( , PausedByUser(0) , StopSignal(0) { - Y_VERIFY(limitCount > 0, "limit must be > 0"); - Y_UNUSED(Name); + Y_VERIFY(limitCount > 0, "limit must be > 0"); + Y_UNUSED(Name); } TRemoteServerSessionSemaphore::~TRemoteServerSessionSemaphore() { - Y_VERIFY(AtomicGet(CurrentCount) == 0); + Y_VERIFY(AtomicGet(CurrentCount) == 0); // TODO: fix spider and enable - //Y_VERIFY(AtomicGet(CurrentSize) == 0); + //Y_VERIFY(AtomicGet(CurrentSize) == 0); } bool TRemoteServerSessionSemaphore::TryWait() { - if (Y_UNLIKELY(AtomicGet(StopSignal))) + if (Y_UNLIKELY(AtomicGet(StopSignal))) return true; if (AtomicGet(PausedByUser)) return false; diff --git a/library/cpp/messagebus/scheduler/scheduler.cpp b/library/cpp/messagebus/scheduler/scheduler.cpp index 5a5fe528943..506af354e60 100644 --- a/library/cpp/messagebus/scheduler/scheduler.cpp +++ b/library/cpp/messagebus/scheduler/scheduler.cpp @@ -23,7 +23,7 @@ TScheduler::TScheduler() } TScheduler::~TScheduler() { - Y_VERIFY(StopThread, "state check"); + Y_VERIFY(StopThread, "state check"); } size_t TScheduler::Size() const { @@ -34,7 +34,7 @@ size_t TScheduler::Size() const { void TScheduler::Stop() { { TGuard<TLock> guard(Lock); - Y_VERIFY(!StopThread, "Scheduler already stopped"); + Y_VERIFY(!StopThread, "Scheduler already stopped"); StopThread = true; CondVar.Signal(); } @@ -44,8 +44,8 @@ void TScheduler::Stop() { NextItem.Destroy(); } - for (auto& item : Items) { - item.Destroy(); + for (auto& item : Items) { + item.Destroy(); } } @@ -98,7 +98,7 @@ void TScheduler::SchedulerThread() { } // signal comes if either scheduler is to be stopped of there's work to do - Y_VERIFY(!!NextItem, "state check"); + Y_VERIFY(!!NextItem, "state check"); if (TInstant::Now() < NextItem->GetScheduleTime()) { // NextItem is updated since WaitD diff --git a/library/cpp/messagebus/scheduler/scheduler_ut.cpp b/library/cpp/messagebus/scheduler/scheduler_ut.cpp index a5ea641c108..afe89e9263c 100644 --- a/library/cpp/messagebus/scheduler/scheduler_ut.cpp +++ b/library/cpp/messagebus/scheduler/scheduler_ut.cpp @@ -7,7 +7,7 @@ using namespace NBus; using namespace NBus::NPrivate; -Y_UNIT_TEST_SUITE(TSchedulerTests) { +Y_UNIT_TEST_SUITE(TSchedulerTests) { struct TSimpleScheduleItem: public IScheduleItem { TTestSync* const TestSync; @@ -22,7 +22,7 @@ Y_UNIT_TEST_SUITE(TSchedulerTests) { } }; - Y_UNIT_TEST(Simple) { + Y_UNIT_TEST(Simple) { TTestSync testSync; TScheduler scheduler; diff --git a/library/cpp/messagebus/scheduler_actor_ut.cpp b/library/cpp/messagebus/scheduler_actor_ut.cpp index e81ffd31869..c885e40f590 100644 --- a/library/cpp/messagebus/scheduler_actor_ut.cpp +++ b/library/cpp/messagebus/scheduler_actor_ut.cpp @@ -7,7 +7,7 @@ using namespace NBus; using namespace NBus::NPrivate; using namespace NActor; -Y_UNIT_TEST_SUITE(TSchedulerActorTests) { +Y_UNIT_TEST_SUITE(TSchedulerActorTests) { struct TMyActor: public TAtomicRefCount<TMyActor>, public TActor<TMyActor>, public TScheduleActor<TMyActor> { TTestSync TestSync; @@ -22,7 +22,7 @@ Y_UNIT_TEST_SUITE(TSchedulerActorTests) { void Act(TDefaultTag) { if (!Alarm.FetchTask()) { - Y_FAIL("must not have no spurious wakeups in test"); + Y_FAIL("must not have no spurious wakeups in test"); } TestSync.WaitForAndIncrement(Iteration++); @@ -32,7 +32,7 @@ Y_UNIT_TEST_SUITE(TSchedulerActorTests) { } }; - Y_UNIT_TEST(Simple) { + Y_UNIT_TEST(Simple) { TExecutor executor(1); TScheduler scheduler; diff --git a/library/cpp/messagebus/session_impl.cpp b/library/cpp/messagebus/session_impl.cpp index ddf9f360c43..1552ee775f0 100644 --- a/library/cpp/messagebus/session_impl.cpp +++ b/library/cpp/messagebus/session_impl.cpp @@ -58,28 +58,28 @@ namespace { copy.TotalTimeout = TDuration::Seconds(60).MilliSeconds(); copy.SendTimeout = TDuration::Seconds(15).MilliSeconds(); } else if (copy.TotalTimeout == 0) { - Y_ASSERT(copy.SendTimeout != 0); + Y_ASSERT(copy.SendTimeout != 0); copy.TotalTimeout = config.SendTimeout + TDuration::MilliSeconds(10).MilliSeconds(); } else if (copy.SendTimeout == 0) { - Y_ASSERT(copy.TotalTimeout != 0); + Y_ASSERT(copy.TotalTimeout != 0); if ((ui64)copy.TotalTimeout > (ui64)TDuration::MilliSeconds(10).MilliSeconds()) { copy.SendTimeout = copy.TotalTimeout - TDuration::MilliSeconds(10).MilliSeconds(); } else { copy.SendTimeout = copy.TotalTimeout; } } else { - Y_ASSERT(copy.TotalTimeout != 0); - Y_ASSERT(copy.SendTimeout != 0); + Y_ASSERT(copy.TotalTimeout != 0); + Y_ASSERT(copy.SendTimeout != 0); } if (copy.ConnectTimeout == 0) { copy.ConnectTimeout = copy.SendTimeout; } - Y_VERIFY(copy.SendTimeout > 0, "SendTimeout must be > 0"); - Y_VERIFY(copy.TotalTimeout > 0, "TotalTimeout must be > 0"); - Y_VERIFY(copy.ConnectTimeout > 0, "ConnectTimeout must be > 0"); - Y_VERIFY(copy.TotalTimeout >= copy.SendTimeout, "TotalTimeout must be >= SendTimeout"); + Y_VERIFY(copy.SendTimeout > 0, "SendTimeout must be > 0"); + Y_VERIFY(copy.TotalTimeout > 0, "TotalTimeout must be > 0"); + Y_VERIFY(copy.ConnectTimeout > 0, "ConnectTimeout must be > 0"); + Y_VERIFY(copy.TotalTimeout >= copy.SendTimeout, "TotalTimeout must be >= SendTimeout"); if (!copy.Name) { copy.Name = name; @@ -117,10 +117,10 @@ TBusSessionImpl::TBusSessionImpl(bool isSource, TBusMessageQueue* queue, TBusPro } TBusSessionImpl::~TBusSessionImpl() { - Y_VERIFY(Down); - Y_VERIFY(ShutdownCompleteEvent.WaitT(TDuration::Zero())); - Y_VERIFY(!WriteEventLoop.IsRunning()); - Y_VERIFY(!ReadEventLoop.IsRunning()); + Y_VERIFY(Down); + Y_VERIFY(ShutdownCompleteEvent.WaitT(TDuration::Zero())); + Y_VERIFY(!WriteEventLoop.IsRunning()); + Y_VERIFY(!ReadEventLoop.IsRunning()); } TBusSessionStatus::TBusSessionStatus() @@ -136,7 +136,7 @@ void TBusSessionImpl::Shutdown() { return; } - Y_VERIFY(Queue->IsRunning(), "Session must be shut down prior to queue shutdown"); + Y_VERIFY(Queue->IsRunning(), "Session must be shut down prior to queue shutdown"); TUseAfterFreeCheckerGuard handlerAliveCheckedGuard(ErrorHandler->UseAfterFreeChecker); @@ -161,16 +161,16 @@ void TBusSessionImpl::Shutdown() { Acceptors.clear(); } - for (auto& acceptor : acceptors) { - acceptor->Shutdown(); + for (auto& acceptor : acceptors) { + acceptor->Shutdown(); } // shutdown connections TVector<TRemoteConnectionPtr> cs; GetConnections(&cs); - for (auto& c : cs) { - c->Shutdown(MESSAGE_SHUTDOWN); + for (auto& c : cs) { + c->Shutdown(MESSAGE_SHUTDOWN); } // shutdown connections actor @@ -205,7 +205,7 @@ size_t TBusSessionImpl::GetInFlightImpl(const TNetAddr& addr) const { } void TBusSessionImpl::GetInFlightBulk(TArrayRef<const TNetAddr> addrs, TArrayRef<size_t> results) const { - Y_VERIFY(addrs.size() == results.size(), "input.size != output.size"); + Y_VERIFY(addrs.size() == results.size(), "input.size != output.size"); for (size_t i = 0; i < addrs.size(); ++i) { results[i] = GetInFlightImpl(addrs[i]); } @@ -221,7 +221,7 @@ size_t TBusSessionImpl::GetConnectSyscallsNumForTestImpl(const TNetAddr& addr) c } void TBusSessionImpl::GetConnectSyscallsNumBulkForTest(TArrayRef<const TNetAddr> addrs, TArrayRef<size_t> results) const { - Y_VERIFY(addrs.size() == results.size(), "input.size != output.size"); + Y_VERIFY(addrs.size() == results.size(), "input.size != output.size"); for (size_t i = 0; i < addrs.size(); ++i) { results[i] = GetConnectSyscallsNumForTestImpl(addrs[i]); } @@ -232,7 +232,7 @@ void TBusSessionImpl::FillStatus() { TSessionDumpStatus TBusSessionImpl::GetStatusRecordInternal() { // Probably useless, because it returns cached info now - Y_VERIFY(!Queue->GetExecutor()->IsInExecutorThread(), + Y_VERIFY(!Queue->GetExecutor()->IsInExecutorThread(), "GetStatus must not be called from executor thread"); TGuard<TMutex> guard(StatusData.StatusDumpCachedMutex); @@ -242,13 +242,13 @@ TSessionDumpStatus TBusSessionImpl::GetStatusRecordInternal() { } TString TBusSessionImpl::GetStatus(ui16 flags) { - Y_UNUSED(flags); + Y_UNUSED(flags); return GetStatusRecordInternal().PrintToString(); } TConnectionStatusMonRecord TBusSessionImpl::GetStatusProtobuf() { - Y_VERIFY(!Queue->GetExecutor()->IsInExecutorThread(), + Y_VERIFY(!Queue->GetExecutor()->IsInExecutorThread(), "GetStatus must not be called from executor thread"); TGuard<TMutex> guard(StatusData.StatusDumpCachedMutex); @@ -319,12 +319,12 @@ void TBusSessionImpl::ProcessItem(TConnectionTag, TRemoveTag, TRemoteConnectionP void TBusSessionImpl::ProcessConnectionsAcceptorsShapshotQueueItem(TAtomicSharedPtr<TConnectionsAcceptorsSnapshot> snapshot) { for (TVector<TRemoteConnectionPtr>::const_iterator connection = snapshot->Connections.begin(); connection != snapshot->Connections.end(); ++connection) { - Y_ASSERT((*connection)->ConnectionId <= snapshot->LastConnectionId); + Y_ASSERT((*connection)->ConnectionId <= snapshot->LastConnectionId); } for (TVector<TAcceptorPtr>::const_iterator acceptor = snapshot->Acceptors.begin(); acceptor != snapshot->Acceptors.end(); ++acceptor) { - Y_ASSERT((*acceptor)->AcceptorId <= snapshot->LastAcceptorId); + Y_ASSERT((*acceptor)->AcceptorId <= snapshot->LastAcceptorId); } StatusData.ConnectionsAcceptorsSnapshot = snapshot; @@ -471,8 +471,8 @@ void TBusSessionImpl::Act(TConnectionTag) { EShutdownState shutdownState = ConnectionsData.ShutdownState.State.Get(); if (shutdownState == SS_SHUTDOWN_COMPLETE) { - Y_VERIFY(GetRemoveConnectionQueue()->IsEmpty()); - Y_VERIFY(GetOnAcceptQueue()->IsEmpty()); + Y_VERIFY(GetRemoveConnectionQueue()->IsEmpty()); + Y_VERIFY(GetOnAcceptQueue()->IsEmpty()); } GetRemoveConnectionQueue()->DequeueAllLikelyEmpty(); @@ -488,7 +488,7 @@ void TBusSessionImpl::Listen(int port, TBusMessageQueue* q) { } void TBusSessionImpl::Listen(const TVector<TBindResult>& bindTo, TBusMessageQueue* q) { - Y_ASSERT(q == Queue); + Y_ASSERT(q == Queue); int actualPort = -1; for (const TBindResult& br : bindTo) { @@ -511,7 +511,7 @@ void TBusSessionImpl::Listen(const TVector<TBindResult>& bindTo, TBusMessageQueu } void TBusSessionImpl::SendSnapshotToStatusActor() { - //Y_ASSERT(ConnectionsLock.IsLocked()); + //Y_ASSERT(ConnectionsLock.IsLocked()); TAtomicSharedPtr<TConnectionsAcceptorsSnapshot> snapshot(new TConnectionsAcceptorsSnapshot); GetAcceptorsLockAquired(&snapshot->Acceptors); @@ -523,7 +523,7 @@ void TBusSessionImpl::SendSnapshotToStatusActor() { } void TBusSessionImpl::InsertConnectionLockAcquired(TRemoteConnection* connection) { - //Y_ASSERT(ConnectionsLock.IsLocked()); + //Y_ASSERT(ConnectionsLock.IsLocked()); Connections.insert(std::make_pair(connection->PeerAddrSocketAddr, connection)); // connection for given adds may already exist at this point @@ -531,13 +531,13 @@ void TBusSessionImpl::InsertConnectionLockAcquired(TRemoteConnection* connection // after reconnect, if previous connections wasn't shutdown yet bool inserted2 = ConnectionsById.insert(std::make_pair(connection->ConnectionId, connection)).second; - Y_VERIFY(inserted2, "state check: must be inserted (2)"); + Y_VERIFY(inserted2, "state check: must be inserted (2)"); SendSnapshotToStatusActor(); } void TBusSessionImpl::InsertAcceptorLockAcquired(TAcceptor* acceptor) { - //Y_ASSERT(ConnectionsLock.IsLocked()); + //Y_ASSERT(ConnectionsLock.IsLocked()); Acceptors.push_back(acceptor); @@ -555,22 +555,22 @@ void TBusSessionImpl::GetAcceptors(TVector<TAcceptorPtr>* r) { } void TBusSessionImpl::GetConnectionsLockAquired(TVector<TRemoteConnectionPtr>* r) { - //Y_ASSERT(ConnectionsLock.IsLocked()); + //Y_ASSERT(ConnectionsLock.IsLocked()); r->reserve(Connections.size()); - for (auto& connection : Connections) { - r->push_back(connection.second); + for (auto& connection : Connections) { + r->push_back(connection.second); } } void TBusSessionImpl::GetAcceptorsLockAquired(TVector<TAcceptorPtr>* r) { - //Y_ASSERT(ConnectionsLock.IsLocked()); + //Y_ASSERT(ConnectionsLock.IsLocked()); r->reserve(Acceptors.size()); - for (auto& acceptor : Acceptors) { - r->push_back(acceptor); + for (auto& acceptor : Acceptors) { + r->push_back(acceptor); } } @@ -588,9 +588,9 @@ TRemoteConnectionPtr TBusSessionImpl::GetConnectionById(ui64 id) { TAcceptorPtr TBusSessionImpl::GetAcceptorById(ui64 id) { TGuard<TMutex> guard(ConnectionsLock); - for (const auto& Acceptor : Acceptors) { - if (Acceptor->AcceptorId == id) { - return Acceptor; + for (const auto& Acceptor : Acceptors) { + if (Acceptor->AcceptorId == id) { + return Acceptor; } } @@ -614,7 +614,7 @@ TRemoteConnectionPtr TBusSessionImpl::GetConnection(const TBusSocketAddr& addr, return TRemoteConnectionPtr(); } - Y_VERIFY(IsSource_, "must be source"); + Y_VERIFY(IsSource_, "must be source"); TRemoteConnectionPtr c(new TRemoteClientConnection(VerifyDynamicCast<TRemoteClientSession*>(this), ++LastConnectionId, addr.ToNetAddr())); InsertConnectionLockAcquired(c.Get()); @@ -626,8 +626,8 @@ void TBusSessionImpl::Cron() { TVector<TRemoteConnectionPtr> connections; GetConnections(&connections); - for (const auto& it : connections) { - TRemoteConnection* connection = it.Get(); + for (const auto& it : connections) { + TRemoteConnection* connection = it.Get(); if (IsSource_) { VerifyDynamicCast<TRemoteClientConnection*>(connection)->ScheduleTimeoutMessages(); } else { diff --git a/library/cpp/messagebus/session_job_count.cpp b/library/cpp/messagebus/session_job_count.cpp index 33322b19102..525bb1b1ef8 100644 --- a/library/cpp/messagebus/session_job_count.cpp +++ b/library/cpp/messagebus/session_job_count.cpp @@ -11,7 +11,7 @@ TBusSessionJobCount::TBusSessionJobCount() } TBusSessionJobCount::~TBusSessionJobCount() { - Y_VERIFY(JobCount == 0, "must be 0 job count to destroy job"); + Y_VERIFY(JobCount == 0, "must be 0 job count to destroy job"); } void TBusSessionJobCount::WaitForZero() { diff --git a/library/cpp/messagebus/shutdown_state.cpp b/library/cpp/messagebus/shutdown_state.cpp index a4e2bfa8b26..ce206a9772a 100644 --- a/library/cpp/messagebus/shutdown_state.cpp +++ b/library/cpp/messagebus/shutdown_state.cpp @@ -3,11 +3,11 @@ #include <util/system/yassert.h> void TAtomicShutdownState::ShutdownCommand() { - Y_VERIFY(State.CompareAndSet(SS_RUNNING, SS_SHUTDOWN_COMMAND)); + Y_VERIFY(State.CompareAndSet(SS_RUNNING, SS_SHUTDOWN_COMMAND)); } void TAtomicShutdownState::CompleteShutdown() { - Y_VERIFY(State.CompareAndSet(SS_SHUTDOWN_COMMAND, SS_SHUTDOWN_COMPLETE)); + Y_VERIFY(State.CompareAndSet(SS_SHUTDOWN_COMMAND, SS_SHUTDOWN_COMPLETE)); ShutdownComplete.Signal(); } @@ -16,5 +16,5 @@ bool TAtomicShutdownState::IsRunning() { } TAtomicShutdownState::~TAtomicShutdownState() { - Y_VERIFY(SS_SHUTDOWN_COMPLETE == State.Get()); + Y_VERIFY(SS_SHUTDOWN_COMPLETE == State.Get()); } diff --git a/library/cpp/messagebus/socket_addr.cpp b/library/cpp/messagebus/socket_addr.cpp index c1b3a28fbee..2e884949208 100644 --- a/library/cpp/messagebus/socket_addr.cpp +++ b/library/cpp/messagebus/socket_addr.cpp @@ -74,6 +74,6 @@ TNetAddr NBus::NPrivate::TBusSocketAddr::ToNetAddr() const { } template <> -void Out<TBusSocketAddr>(IOutputStream& out, const TBusSocketAddr& addr) { +void Out<TBusSocketAddr>(IOutputStream& out, const TBusSocketAddr& addr) { out << addr.ToNetAddr(); } diff --git a/library/cpp/messagebus/socket_addr_ut.cpp b/library/cpp/messagebus/socket_addr_ut.cpp index 783bb62a861..3f90d8d7759 100644 --- a/library/cpp/messagebus/socket_addr_ut.cpp +++ b/library/cpp/messagebus/socket_addr_ut.cpp @@ -8,8 +8,8 @@ using namespace NBus; using namespace NBus::NPrivate; -Y_UNIT_TEST_SUITE(TBusSocketAddr) { - Y_UNIT_TEST(Simple) { +Y_UNIT_TEST_SUITE(TBusSocketAddr) { + Y_UNIT_TEST(Simple) { UNIT_ASSERT_VALUES_EQUAL(TString("127.0.0.1:80"), ToString(TBusSocketAddr("127.0.0.1", 80))); } } diff --git a/library/cpp/messagebus/synchandler.cpp b/library/cpp/messagebus/synchandler.cpp index 8e891d66b30..5ae9adc39c6 100644 --- a/library/cpp/messagebus/synchandler.cpp +++ b/library/cpp/messagebus/synchandler.cpp @@ -58,12 +58,12 @@ public: } void OnMessageSent(TBusMessage* pMessage) override { - Y_UNUSED(pMessage); - Y_ASSERT(ExpectReply); + Y_UNUSED(pMessage); + Y_ASSERT(ExpectReply); } void OnMessageSentOneWay(TAutoPtr<TBusMessage> pMessage) override { - Y_ASSERT(!ExpectReply); + Y_ASSERT(!ExpectReply); TBusSyncMessageData* data = static_cast<TBusSyncMessageData*>(pMessage.Release()->Data); SignalResult(data, /*pReply=*/nullptr, MESSAGE_OK); } @@ -76,7 +76,7 @@ public: private: void SignalResult(TBusSyncMessageData* data, TBusMessage* pReply, EMessageStatus status) const { - Y_VERIFY(data, "Message data is set to NULL."); + Y_VERIFY(data, "Message data is set to NULL."); TGuard<TMutex> G(data->ReplyLock); data->Reply = pReply; data->ReplyStatus = status; diff --git a/library/cpp/messagebus/test/example/client/client.cpp b/library/cpp/messagebus/test/example/client/client.cpp index 89b5f2c9beb..5e18fd8990c 100644 --- a/library/cpp/messagebus/test/example/client/client.cpp +++ b/library/cpp/messagebus/test/example/client/client.cpp @@ -23,7 +23,7 @@ namespace NCalculator { } void OnReply(TAutoPtr<TBusMessage> request, TAutoPtr<TBusMessage> response0) override { - Y_VERIFY(response0->GetHeader()->Type == TResponse::MessageType, "wrong response"); + Y_VERIFY(response0->GetHeader()->Type == TResponse::MessageType, "wrong response"); TResponse* response = VerifyDynamicCast<TResponse*>(response0.Get()); if (request->GetHeader()->Type == TRequestSum::MessageType) { TRequestSum* requestSum = VerifyDynamicCast<TRequestSum*>(request.Get()); @@ -36,7 +36,7 @@ namespace NCalculator { int b = requestMul->Record.GetB(); Cerr << a << " * " << b << " = " << response->Record.GetResult() << "\n"; } else { - Y_FAIL("unknown request"); + Y_FAIL("unknown request"); } } diff --git a/library/cpp/messagebus/test/example/server/server.cpp b/library/cpp/messagebus/test/example/server/server.cpp index 13e52d75f58..27d427491bd 100644 --- a/library/cpp/messagebus/test/example/server/server.cpp +++ b/library/cpp/messagebus/test/example/server/server.cpp @@ -39,7 +39,7 @@ namespace NCalculator { response->Record.SetResult(result); request.SendReplyMove(response); } else { - Y_FAIL("unknown request"); + Y_FAIL("unknown request"); } } }; diff --git a/library/cpp/messagebus/test/helper/alloc_counter.h b/library/cpp/messagebus/test/helper/alloc_counter.h index ec9041cb152..0f7631166b9 100644 --- a/library/cpp/messagebus/test/helper/alloc_counter.h +++ b/library/cpp/messagebus/test/helper/alloc_counter.h @@ -16,6 +16,6 @@ public: } ~TAllocCounter() { - Y_VERIFY(AtomicDecrement(*CountPtr) >= 0, "released too many"); + Y_VERIFY(AtomicDecrement(*CountPtr) >= 0, "released too many"); } }; diff --git a/library/cpp/messagebus/test/helper/example.cpp b/library/cpp/messagebus/test/helper/example.cpp index 7c6d704042c..07b8e47c74d 100644 --- a/library/cpp/messagebus/test/helper/example.cpp +++ b/library/cpp/messagebus/test/helper/example.cpp @@ -68,11 +68,11 @@ TExampleProtocol::~TExampleProtocol() { // so it could be reported in test return; } - Y_VERIFY(0 == AtomicGet(RequestCount), "protocol %s: must be 0 requests allocated, actually %d", GetService(), int(RequestCount)); - Y_VERIFY(0 == AtomicGet(ResponseCount), "protocol %s: must be 0 responses allocated, actually %d", GetService(), int(ResponseCount)); - Y_VERIFY(0 == AtomicGet(RequestCountDeserialized), "protocol %s: must be 0 requests deserialized allocated, actually %d", GetService(), int(RequestCountDeserialized)); - Y_VERIFY(0 == AtomicGet(ResponseCountDeserialized), "protocol %s: must be 0 responses deserialized allocated, actually %d", GetService(), int(ResponseCountDeserialized)); - Y_VERIFY(0 == AtomicGet(StartCount), "protocol %s: must be 0 start objects allocated, actually %d", GetService(), int(StartCount)); + Y_VERIFY(0 == AtomicGet(RequestCount), "protocol %s: must be 0 requests allocated, actually %d", GetService(), int(RequestCount)); + Y_VERIFY(0 == AtomicGet(ResponseCount), "protocol %s: must be 0 responses allocated, actually %d", GetService(), int(ResponseCount)); + Y_VERIFY(0 == AtomicGet(RequestCountDeserialized), "protocol %s: must be 0 requests deserialized allocated, actually %d", GetService(), int(RequestCountDeserialized)); + Y_VERIFY(0 == AtomicGet(ResponseCountDeserialized), "protocol %s: must be 0 responses deserialized allocated, actually %d", GetService(), int(ResponseCountDeserialized)); + Y_VERIFY(0 == AtomicGet(StartCount), "protocol %s: must be 0 start objects allocated, actually %d", GetService(), int(StartCount)); } void TExampleProtocol::Serialize(const TBusMessage* message, TBuffer& buffer) { @@ -83,13 +83,13 @@ void TExampleProtocol::Serialize(const TBusMessage* message, TBuffer& buffer) { } else if (const TExampleResponse* exampleReply = dynamic_cast<const TExampleResponse*>(message)) { buffer.Append(exampleReply->Data.data(), exampleReply->Data.size()); } else { - Y_FAIL("unknown message type"); + Y_FAIL("unknown message type"); } } TAutoPtr<TBusMessage> TExampleProtocol::Deserialize(ui16 messageType, TArrayRef<const char> payload) { // TODO: check data - Y_UNUSED(payload); + Y_UNUSED(payload); if (messageType == 77) { TExampleRequest* exampleMessage = new TExampleRequest(MESSAGE_CREATE_UNINITIALIZED, &RequestCountDeserialized); @@ -194,8 +194,8 @@ void TExampleClient::SendMessagesWaitReplies(size_t count, const TNetAddr& addr) } void TExampleClient::OnReply(TAutoPtr<TBusMessage> mess, TAutoPtr<TBusMessage> reply) { - Y_UNUSED(mess); - Y_UNUSED(reply); + Y_UNUSED(mess); + Y_UNUSED(reply); if (AtomicIncrement(RepliesCount) == MessageCount) { WorkDone.Signal(); @@ -204,10 +204,10 @@ void TExampleClient::OnReply(TAutoPtr<TBusMessage> mess, TAutoPtr<TBusMessage> r void TExampleClient::OnError(TAutoPtr<TBusMessage> mess, EMessageStatus status) { if (CrashOnError) { - Y_FAIL("client failed: %s", ToCString(status)); + Y_FAIL("client failed: %s", ToCString(status)); } - Y_UNUSED(mess); + Y_UNUSED(mess); AtomicIncrement(Errors); LastError = status; diff --git a/library/cpp/messagebus/test/helper/message_handler_error.cpp b/library/cpp/messagebus/test/helper/message_handler_error.cpp index c09811ec67b..421e0ce3975 100644 --- a/library/cpp/messagebus/test/helper/message_handler_error.cpp +++ b/library/cpp/messagebus/test/helper/message_handler_error.cpp @@ -10,11 +10,11 @@ void TBusClientHandlerError::OnError(TAutoPtr<TBusMessage>, EMessageStatus statu } void TBusClientHandlerError::OnReply(TAutoPtr<TBusMessage>, TAutoPtr<TBusMessage>) { - Y_FAIL("must not be called"); + Y_FAIL("must not be called"); } void TBusClientHandlerError::OnMessageSentOneWay(TAutoPtr<TBusMessage>) { - Y_FAIL("must not be called"); + Y_FAIL("must not be called"); } void TBusServerHandlerError::OnError(TAutoPtr<TBusMessage>, EMessageStatus status) { @@ -22,5 +22,5 @@ void TBusServerHandlerError::OnError(TAutoPtr<TBusMessage>, EMessageStatus statu } void TBusServerHandlerError::OnMessage(TOnMessageContext&) { - Y_FAIL("must not be called"); + Y_FAIL("must not be called"); } diff --git a/library/cpp/messagebus/test/perftest/perftest.cpp b/library/cpp/messagebus/test/perftest/perftest.cpp index 84893192789..de1ee427a28 100644 --- a/library/cpp/messagebus/test/perftest/perftest.cpp +++ b/library/cpp/messagebus/test/perftest/perftest.cpp @@ -150,7 +150,7 @@ TAutoPtr<TBusMessage> NewRequest() { void CheckRequest(TPerftestRequest* request) { const TString& data = request->Record.GetData(); for (size_t i = 0; i != data.size(); ++i) { - Y_VERIFY(data.at(i) == '?', "must be question mark"); + Y_VERIFY(data.at(i) == '?', "must be question mark"); } } @@ -164,7 +164,7 @@ TAutoPtr<TPerftestResponse> NewResponse(TPerftestRequest* request) { void CheckResponse(TPerftestResponse* response) { const TString& data = response->Record.GetData(); for (size_t i = 0; i != data.size(); ++i) { - Y_VERIFY(data.at(i) == '.', "must be dot"); + Y_VERIFY(data.at(i) == '.', "must be dot"); } } @@ -279,7 +279,7 @@ public: //delete message; //Sleep(TDuration::MilliSeconds(1)); //continue; - Y_FAIL("unreachable"); + Y_FAIL("unreachable"); } else if (ret == MESSAGE_SHUTDOWN) { delete message; } else { @@ -295,7 +295,7 @@ public: /// actual work is being done here void OnReply(TAutoPtr<TBusMessage> mess, TAutoPtr<TBusMessage> reply) override { - Y_UNUSED(mess); + Y_UNUSED(mess); if (Config.SimpleProtocol) { VerifyDynamicCast<TSimpleMessage*>(reply.Get()); @@ -310,8 +310,8 @@ public: /// message that could not be delivered void OnError(TAutoPtr<TBusMessage> mess, EMessageStatus status) override { - Y_UNUSED(mess); - Y_UNUSED(status); + Y_UNUSED(mess); + Y_UNUSED(status); if (TheExit) { return; @@ -319,7 +319,7 @@ public: Stats.IncErrors(); - // Y_ASSERT(TheConfig->Failure > 0.0); + // Y_ASSERT(TheConfig->Failure > 0.0); } }; @@ -368,7 +368,7 @@ public: { /// register destination session Session = TBusServerSession::Create(Proto.Get(), this, Config.ServerSessionConfig, Bus); - Y_ASSERT(Session && "probably somebody is listening on the same port"); + Y_ASSERT(Session && "probably somebody is listening on the same port"); } /// when message comes, send reply @@ -416,8 +416,8 @@ public: : TPerftestServerCommon("server") , TBusModule("fast") { - Y_VERIFY(CreatePrivateSessions(Bus.Get()), "failed to initialize dupdetect module"); - Y_VERIFY(StartInput(), "failed to start input"); + Y_VERIFY(CreatePrivateSessions(Bus.Get()), "failed to initialize dupdetect module"); + Y_VERIFY(StartInput(), "failed to start input"); } ~TPerftestUsingModule() override { @@ -479,7 +479,7 @@ TVector<TNetAddr> ParseNodes(const TString nodes) { for (int i = 0; i < int(numh); i++) { const TNetworkAddress& networkAddress = ParseNetworkAddress(hosts[i].data()); - Y_VERIFY(networkAddress.Begin() != networkAddress.End(), "no addresses"); + Y_VERIFY(networkAddress.Begin() != networkAddress.End(), "no addresses"); r.push_back(TNetAddr(networkAddress, &*networkAddress.Begin())); } @@ -549,9 +549,9 @@ void TTestStats::PeriodicallyPrint() { (unsigned)ServerUsingModule->Bus->GetExecutor()->GetWorkQueueSize(), ServerUsingModule->Session->GetStatusSingleLine().data()); } - for (const auto& client : clients) { + for (const auto& client : clients) { fprintf(stderr, "client: q: %u %s\n", - (unsigned)client->Bus->GetExecutor()->GetWorkQueueSize(), + (unsigned)client->Bus->GetExecutor()->GetWorkQueueSize(), client->Session->GetStatusSingleLine().data()); } @@ -574,13 +574,13 @@ void TTestStats::PeriodicallyPrint() { stats << "server using modules:\n"; stats << IndentText(ServerUsingModule->Bus->GetStatus()); } - for (const auto& client : clients) { + for (const auto& client : clients) { if (!first) { stats << "\n"; } first = false; stats << "client:\n"; - stats << IndentText(client->Bus->GetStatus()); + stats << IndentText(client->Bus->GetStatus()); } TUnbufferedFileOutput("stats").Write(stats.Str()); @@ -693,15 +693,15 @@ int main(int argc, char* argv[]) { if (!clients.empty()) { Cerr << "Stopping clients\n"; - for (auto& client : clients) { - client->Stop(); + for (auto& client : clients) { + client->Stop(); } } wwwServer.Destroy(); - for (const auto& future : futures) { - future->Get(); + for (const auto& future : futures) { + future->Get(); } if (TheConfig->Profile) { diff --git a/library/cpp/messagebus/test/perftest/simple_proto.cpp b/library/cpp/messagebus/test/perftest/simple_proto.cpp index 19d6c15b9d9..e478bda0007 100644 --- a/library/cpp/messagebus/test/perftest/simple_proto.cpp +++ b/library/cpp/messagebus/test/perftest/simple_proto.cpp @@ -7,7 +7,7 @@ using namespace NBus; void TSimpleProtocol::Serialize(const TBusMessage* mess, TBuffer& data) { - Y_VERIFY(typeid(TSimpleMessage) == typeid(*mess)); + Y_VERIFY(typeid(TSimpleMessage) == typeid(*mess)); const TSimpleMessage* typed = static_cast<const TSimpleMessage*>(mess); data.Append((const char*)&typed->Payload, 4); } diff --git a/library/cpp/messagebus/test/ut/messagebus_ut.cpp b/library/cpp/messagebus/test/ut/messagebus_ut.cpp index 040f9b77022..b333e2fe23f 100644 --- a/library/cpp/messagebus/test/ut/messagebus_ut.cpp +++ b/library/cpp/messagebus/test/ut/messagebus_ut.cpp @@ -31,7 +31,7 @@ namespace { } void OnReply(TAutoPtr<TBusMessage> mess, TAutoPtr<TBusMessage> reply) override { - Y_VERIFY(AtomicGet(SentCompleted), "must be completed"); + Y_VERIFY(AtomicGet(SentCompleted), "must be completed"); TExampleClient::OnReply(mess, reply); @@ -46,7 +46,7 @@ namespace { } -Y_UNIT_TEST_SUITE(TMessageBusTests) { +Y_UNIT_TEST_SUITE(TMessageBusTests) { void TestDestinationTemplate(bool useCompression, bool ackMessageBeforeReply, const TBusServerSessionConfig& sessionConfig) { TObjectCountCheck objectCountCheck; @@ -66,19 +66,19 @@ Y_UNIT_TEST_SUITE(TMessageBusTests) { UNIT_ASSERT_EQUAL(client.Session->GetInFlight(), 0); } - Y_UNIT_TEST(TestDestination) { + Y_UNIT_TEST(TestDestination) { TestDestinationTemplate(false, false, TBusServerSessionConfig()); } - Y_UNIT_TEST(TestDestinationUsingAck) { + Y_UNIT_TEST(TestDestinationUsingAck) { TestDestinationTemplate(false, true, TBusServerSessionConfig()); } - Y_UNIT_TEST(TestDestinationWithCompression) { + Y_UNIT_TEST(TestDestinationWithCompression) { TestDestinationTemplate(true, false, TBusServerSessionConfig()); } - Y_UNIT_TEST(TestCork) { + Y_UNIT_TEST(TestCork) { TBusServerSessionConfig config; config.SendThreshold = 1000000000000; config.Cork = TDuration::MilliSeconds(10); @@ -86,7 +86,7 @@ Y_UNIT_TEST_SUITE(TMessageBusTests) { // TODO: test for cork hanging } - Y_UNIT_TEST(TestReconnect) { + Y_UNIT_TEST(TestReconnect) { if (!IsFixedPortTestAllowed()) { return; } @@ -136,7 +136,7 @@ Y_UNIT_TEST_SUITE(TMessageBusTests) { } void OnError(TAutoPtr<TBusMessage> message, EMessageStatus status) override { - Y_UNUSED(message); + Y_UNUSED(message); Y_VERIFY(status == MESSAGE_CONNECT_FAILED, "must be MESSAGE_CONNECT_FAILED, got %s", ToString(status).data()); @@ -194,7 +194,7 @@ Y_UNIT_TEST_SUITE(TMessageBusTests) { UNIT_ASSERT_VALUES_EQUAL(client.Session->GetConfig()->MaxInFlight, count); } - Y_UNIT_TEST(TestHangindServer) { + Y_UNIT_TEST(TestHangindServer) { TObjectCountCheck objectCountCheck; THangingServer server(0); @@ -202,13 +202,13 @@ Y_UNIT_TEST_SUITE(TMessageBusTests) { HangingServerImpl(server.GetPort()); } - Y_UNIT_TEST(TestNoServer) { + Y_UNIT_TEST(TestNoServer) { TObjectCountCheck objectCountCheck; TestNoServerImpl(17, false); } - Y_UNIT_TEST(PauseInput) { + Y_UNIT_TEST(PauseInput) { TObjectCountCheck objectCountCheck; TExampleServer server; @@ -283,15 +283,15 @@ Y_UNIT_TEST_SUITE(TMessageBusTests) { client.ErrorHappened.WaitI(); } - Y_UNIT_TEST(NoServer_SendTimeout_Callback_PeriodLess) { + Y_UNIT_TEST(NoServer_SendTimeout_Callback_PeriodLess) { NoServer_SendTimeout_Callback_Impl(true); } - Y_UNIT_TEST(NoServer_SendTimeout_Callback_TimeoutLess) { + Y_UNIT_TEST(NoServer_SendTimeout_Callback_TimeoutLess) { NoServer_SendTimeout_Callback_Impl(false); } - Y_UNIT_TEST(TestOnReplyCalledAfterOnMessageSent) { + Y_UNIT_TEST(TestOnReplyCalledAfterOnMessageSent) { TObjectCountCheck objectCountCheck; TExampleServer server; @@ -327,7 +327,7 @@ Y_UNIT_TEST_SUITE(TMessageBusTests) { } void OnMessage(TOnMessageContext& mess) override { - Y_VERIFY(mess.IsConnectionAlive(), "connection should be alive here"); + Y_VERIFY(mess.IsConnectionAlive(), "connection should be alive here"); TAutoPtr<TOnMessageContext> delayedMsg(new TOnMessageContext); delayedMsg->Swap(mess); auto g(Guard(Lock_)); @@ -337,8 +337,8 @@ Y_UNIT_TEST_SUITE(TMessageBusTests) { bool CheckClientIsAlive() { auto g(Guard(Lock_)); - for (auto& delayedMessage : DelayedMessages) { - if (!delayedMessage->IsConnectionAlive()) { + for (auto& delayedMessage : DelayedMessages) { + if (!delayedMessage->IsConnectionAlive()) { return false; } } @@ -347,8 +347,8 @@ Y_UNIT_TEST_SUITE(TMessageBusTests) { bool CheckClientIsDead() const { auto g(Guard(Lock_)); - for (const auto& delayedMessage : DelayedMessages) { - if (delayedMessage->IsConnectionAlive()) { + for (const auto& delayedMessage : DelayedMessages) { + if (delayedMessage->IsConnectionAlive()) { return false; } } @@ -377,12 +377,12 @@ Y_UNIT_TEST_SUITE(TMessageBusTests) { } void OnError(TAutoPtr<TBusMessage> mess, EMessageStatus status) override { - Y_UNUSED(mess); + Y_UNUSED(mess); Y_VERIFY(status == MESSAGE_SHUTDOWN, "only shutdown allowed, got %s", ToString(status).data()); } }; - Y_UNIT_TEST(TestReplyCalledAfterClientDisconnected) { + Y_UNIT_TEST(TestReplyCalledAfterClientDisconnected) { TObjectCountCheck objectCountCheck; TDelayReplyServer server; @@ -431,12 +431,12 @@ Y_UNIT_TEST_SUITE(TMessageBusTests) { } void OnError(TAutoPtr<TBusMessage> mess, EMessageStatus status) override { - Y_UNUSED(mess); - Y_VERIFY(status == MESSAGE_SHUTDOWN, "only shutdown allowed"); + Y_UNUSED(mess); + Y_VERIFY(status == MESSAGE_SHUTDOWN, "only shutdown allowed"); } }; - Y_UNIT_TEST(PackUnpack) { + Y_UNIT_TEST(PackUnpack) { TObjectCountCheck objectCountCheck; TPackUnpackServer server; @@ -446,7 +446,7 @@ Y_UNIT_TEST_SUITE(TMessageBusTests) { client->SendMessagesWaitReplies(1, TNetAddr("localhost", server.Session->GetActualListenPort())); } - Y_UNIT_TEST(ClientRequestTooLarge) { + Y_UNIT_TEST(ClientRequestTooLarge) { TObjectCountCheck objectCountCheck; TExampleServer server; @@ -505,11 +505,11 @@ Y_UNIT_TEST_SUITE(TMessageBusTests) { void OnError(TAutoPtr<TBusMessage>, EMessageStatus status) override { TestSync.WaitForAndIncrement(1); - Y_VERIFY(status == MESSAGE_MESSAGE_TOO_LARGE, "status"); + Y_VERIFY(status == MESSAGE_MESSAGE_TOO_LARGE, "status"); } }; - Y_UNIT_TEST(ServerResponseTooLarge) { + Y_UNIT_TEST(ServerResponseTooLarge) { TObjectCountCheck objectCountCheck; TServerForResponseTooLarge server; @@ -555,12 +555,12 @@ Y_UNIT_TEST_SUITE(TMessageBusTests) { TAutoPtr<TExampleResponse> resp(new TExampleResponse(&Proto.ResponseCount, 10)); req.SendReplyMove(resp); } else { - Y_FAIL("wrong"); + Y_FAIL("wrong"); } } }; - Y_UNIT_TEST(ServerRequestTooLarge) { + Y_UNIT_TEST(ServerRequestTooLarge) { TObjectCountCheck objectCountCheck; TServerForRequestTooLarge server; @@ -578,7 +578,7 @@ Y_UNIT_TEST_SUITE(TMessageBusTests) { client.WaitForError(MESSAGE_DELIVERY_FAILED); } - Y_UNIT_TEST(ClientResponseTooLarge) { + Y_UNIT_TEST(ClientResponseTooLarge) { TObjectCountCheck objectCountCheck; TExampleServer server; @@ -598,7 +598,7 @@ Y_UNIT_TEST_SUITE(TMessageBusTests) { client.WaitForError(MESSAGE_DELIVERY_FAILED); } - Y_UNIT_TEST(ServerUnknownMessage) { + Y_UNIT_TEST(ServerUnknownMessage) { TObjectCountCheck objectCountCheck; TExampleServer server; @@ -616,7 +616,7 @@ Y_UNIT_TEST_SUITE(TMessageBusTests) { client.WaitForError(MESSAGE_DELIVERY_FAILED); } - Y_UNIT_TEST(ServerMessageReservedIds) { + Y_UNIT_TEST(ServerMessageReservedIds) { TObjectCountCheck objectCountCheck; TExampleServer server; @@ -641,7 +641,7 @@ Y_UNIT_TEST_SUITE(TMessageBusTests) { client.WaitForError(MESSAGE_DELIVERY_FAILED); } - Y_UNIT_TEST(TestGetInFlightForDestination) { + Y_UNIT_TEST(TestGetInFlightForDestination) { TObjectCountCheck objectCountCheck; TDelayReplyServer server; @@ -703,7 +703,7 @@ Y_UNIT_TEST_SUITE(TMessageBusTests) { } }; - Y_UNIT_TEST(ResetAfterSendOneWayErrorInCallback) { + Y_UNIT_TEST(ResetAfterSendOneWayErrorInCallback) { TObjectCountCheck objectCountCheck; TNetAddr noServerAddr("localhost", 17); @@ -739,7 +739,7 @@ Y_UNIT_TEST_SUITE(TMessageBusTests) { } }; - Y_UNIT_TEST(ResetAfterSendMessageOneWayDuringShutdown) { + Y_UNIT_TEST(ResetAfterSendMessageOneWayDuringShutdown) { TObjectCountCheck objectCountCheck; TNetAddr noServerAddr("localhost", 17); @@ -764,7 +764,7 @@ Y_UNIT_TEST_SUITE(TMessageBusTests) { delete message; } - Y_UNIT_TEST(ResetAfterSendOneWayErrorInReturn) { + Y_UNIT_TEST(ResetAfterSendOneWayErrorInReturn) { TObjectCountCheck objectCountCheck; TestNoServerImpl(17, true); @@ -784,7 +784,7 @@ Y_UNIT_TEST_SUITE(TMessageBusTests) { } }; - Y_UNIT_TEST(ResetAfterSendOneWaySuccess) { + Y_UNIT_TEST(ResetAfterSendOneWaySuccess) { TObjectCountCheck objectCountCheck; TExampleServer server; @@ -800,7 +800,7 @@ Y_UNIT_TEST_SUITE(TMessageBusTests) { client.TestSync.WaitForAndIncrement(2); } - Y_UNIT_TEST(GetStatus) { + Y_UNIT_TEST(GetStatus) { TObjectCountCheck objectCountCheck; TExampleServer server; @@ -818,7 +818,7 @@ Y_UNIT_TEST_SUITE(TMessageBusTests) { client.Bus->GetStatus(); } - Y_UNIT_TEST(BindOnRandomPort) { + Y_UNIT_TEST(BindOnRandomPort) { TObjectCountCheck objectCountCheck; TBusServerSessionConfig serverConfig; @@ -829,7 +829,7 @@ Y_UNIT_TEST_SUITE(TMessageBusTests) { client.SendMessagesWaitReplies(3, &addr); } - Y_UNIT_TEST(UnbindOnShutdown) { + Y_UNIT_TEST(UnbindOnShutdown) { TBusMessageQueuePtr queue(CreateMessageQueue()); TExampleProtocol proto; @@ -846,7 +846,7 @@ Y_UNIT_TEST_SUITE(TMessageBusTests) { THangingServer hangingServer(port); } - Y_UNIT_TEST(VersionNegotiation) { + Y_UNIT_TEST(VersionNegotiation) { TObjectCountCheck objectCountCheck; TExampleServer server; @@ -928,7 +928,7 @@ Y_UNIT_TEST_SUITE(TMessageBusTests) { } }; - Y_UNIT_TEST(OnClientConnectionEvent_Shutdown) { + Y_UNIT_TEST(OnClientConnectionEvent_Shutdown) { TObjectCountCheck objectCountCheck; TOnConnectionEventServer server; @@ -946,7 +946,7 @@ Y_UNIT_TEST_SUITE(TMessageBusTests) { client.Sync.WaitForAndIncrement(3); } - Y_UNIT_TEST(OnClientConnectionEvent_Disconnect) { + Y_UNIT_TEST(OnClientConnectionEvent_Disconnect) { TObjectCountCheck objectCountCheck; THolder<TOnConnectionEventServer> server(new TOnConnectionEventServer); @@ -1010,7 +1010,7 @@ Y_UNIT_TEST_SUITE(TMessageBusTests) { } }; - Y_UNIT_TEST(WakeReaderOnQuota) { + Y_UNIT_TEST(WakeReaderOnQuota) { const size_t test_msg_count = 64; TBusClientSessionConfig clientConfig; @@ -1061,7 +1061,7 @@ Y_UNIT_TEST_SUITE(TMessageBusTests) { server.WaitForOnMessageCount(test_msg_count); }; - Y_UNIT_TEST(TestConnectionAttempts) { + Y_UNIT_TEST(TestConnectionAttempts) { TObjectCountCheck objectCountCheck; TNetAddr noServerAddr("localhost", 17); @@ -1093,7 +1093,7 @@ Y_UNIT_TEST_SUITE(TMessageBusTests) { } }; - Y_UNIT_TEST(TestConnectionAttemptsOnNoMessagesAndNotReconnectWhenIdle) { + Y_UNIT_TEST(TestConnectionAttemptsOnNoMessagesAndNotReconnectWhenIdle) { TObjectCountCheck objectCountCheck; TNetAddr noServerAddr("localhost", 17); @@ -1120,7 +1120,7 @@ Y_UNIT_TEST_SUITE(TMessageBusTests) { UNIT_ASSERT_EQUAL(client.Session->GetConnectSyscallsNumForTest(noServerAddr), 2); }; - Y_UNIT_TEST(TestConnectionAttemptsOnNoMessagesAndReconnectWhenIdle) { + Y_UNIT_TEST(TestConnectionAttemptsOnNoMessagesAndReconnectWhenIdle) { TObjectCountCheck objectCountCheck; TNetAddr noServerAddr("localhost", 17); diff --git a/library/cpp/messagebus/test/ut/module_client_one_way_ut.cpp b/library/cpp/messagebus/test/ut/module_client_one_way_ut.cpp index 4083cf3b7b7..e7f2f5bd11e 100644 --- a/library/cpp/messagebus/test/ut/module_client_one_way_ut.cpp +++ b/library/cpp/messagebus/test/ut/module_client_one_way_ut.cpp @@ -9,7 +9,7 @@ using namespace NBus; using namespace NBus::NTest; -Y_UNIT_TEST_SUITE(ModuleClientOneWay) { +Y_UNIT_TEST_SUITE(ModuleClientOneWay) { struct TTestServer: public TBusServerHandlerError { TExampleProtocol Proto; @@ -66,7 +66,7 @@ Y_UNIT_TEST_SUITE(ModuleClientOneWay) { } }; - Y_UNIT_TEST(Simple) { + Y_UNIT_TEST(Simple) { TTestSync testSync; TTestServer server(&testSync); @@ -122,7 +122,7 @@ Y_UNIT_TEST_SUITE(ModuleClientOneWay) { } }; - Y_UNIT_TEST(SendError) { + Y_UNIT_TEST(SendError) { TTestSync testSync; TBusQueueConfig queueConfig; diff --git a/library/cpp/messagebus/test/ut/module_client_ut.cpp b/library/cpp/messagebus/test/ut/module_client_ut.cpp index ebfe185cc6d..16d2f22335d 100644 --- a/library/cpp/messagebus/test/ut/module_client_ut.cpp +++ b/library/cpp/messagebus/test/ut/module_client_ut.cpp @@ -50,9 +50,9 @@ public: } }; -Y_UNIT_TEST_SUITE(BusJobTest) { +Y_UNIT_TEST_SUITE(BusJobTest) { #if 0 - Y_UNIT_TEST(TestPending) { + Y_UNIT_TEST(TestPending) { TObjectCountCheck objectCountCheck; TDupDetectModule module; @@ -69,7 +69,7 @@ Y_UNIT_TEST_SUITE(BusJobTest) { UNIT_ASSERT_EQUAL(msg, pending[0].Message); } - Y_UNIT_TEST(TestCallReplyHandler) { + Y_UNIT_TEST(TestCallReplyHandler) { TObjectCountCheck objectCountCheck; TDupDetectModule module; @@ -112,27 +112,27 @@ Y_UNIT_TEST_SUITE(BusJobTest) { } TJobHandler Start(TBusJob* job, TBusMessage* mess) override { - Y_UNUSED(mess); + Y_UNUSED(mess); job->Send(new TExampleRequest(&Proto.RequestCount), Source, TReplyHandler(&TParallelOnReplyModule::ReplyHandler), 0, ServerAddr); return &TParallelOnReplyModule::HandleReplies; } void ReplyHandler(TBusJob*, EMessageStatus status, TBusMessage* mess, TBusMessage* reply) { - Y_UNUSED(mess); - Y_UNUSED(reply); - Y_VERIFY(status == MESSAGE_OK, "failed to get reply: %s", ToCString(status)); + Y_UNUSED(mess); + Y_UNUSED(reply); + Y_VERIFY(status == MESSAGE_OK, "failed to get reply: %s", ToCString(status)); } TJobHandler HandleReplies(TBusJob* job, TBusMessage* mess) { - Y_UNUSED(mess); + Y_UNUSED(mess); RepliesLatch.CountDown(); - Y_VERIFY(RepliesLatch.Await(TDuration::Seconds(10)), "failed to get answers"); + Y_VERIFY(RepliesLatch.Await(TDuration::Seconds(10)), "failed to get answers"); job->Cancel(MESSAGE_UNKNOWN); return nullptr; } }; - Y_UNIT_TEST(TestReplyHandlerCalledInParallel) { + Y_UNIT_TEST(TestReplyHandlerCalledInParallel) { TObjectCountCheck objectCountCheck; TExampleServer server; @@ -170,7 +170,7 @@ Y_UNIT_TEST_SUITE(BusJobTest) { } TJobHandler Start(TBusJob* job, TBusMessage* mess) override { - Y_UNUSED(mess); + Y_UNUSED(mess); TExampleRequest* message = new TExampleRequest(&Proto.RequestCount); job->Send(message, Source, TReplyHandler(&TErrorHandlerCheckerModule::ReplyHandler), 0, ServerAddr); SentMessage = message; @@ -179,13 +179,13 @@ Y_UNIT_TEST_SUITE(BusJobTest) { void ReplyHandler(TBusJob*, EMessageStatus status, TBusMessage* req, TBusMessage* resp) { Y_VERIFY(status == MESSAGE_CONNECT_FAILED || status == MESSAGE_TIMEOUT, "got wrong status: %s", ToString(status).data()); - Y_VERIFY(req == SentMessage, "checking request"); - Y_VERIFY(resp == nullptr, "checking response"); + Y_VERIFY(req == SentMessage, "checking request"); + Y_VERIFY(resp == nullptr, "checking response"); GotReplyLatch.CountDown(); } TJobHandler HandleReplies(TBusJob* job, TBusMessage* mess) { - Y_UNUSED(mess); + Y_UNUSED(mess); job->Cancel(MESSAGE_UNKNOWN); GotReplyLatch.CountDown(); return nullptr; @@ -201,7 +201,7 @@ Y_UNIT_TEST_SUITE(BusJobTest) { } }; - Y_UNIT_TEST(ErrorHandler) { + Y_UNIT_TEST(ErrorHandler) { TExampleProtocol proto; TBusQueueConfig config; @@ -264,7 +264,7 @@ Y_UNIT_TEST_SUITE(BusJobTest) { } TJobHandler Start(TBusJob* job, TBusMessage* mess) override { - Y_UNUSED(mess); + Y_UNUSED(mess); for (unsigned i = 0; i < 2; ++i) { job->Send( new TExampleRequest(&Proto.RequestCount), @@ -277,9 +277,9 @@ Y_UNIT_TEST_SUITE(BusJobTest) { } void ReplyHandler(TBusJob* job, EMessageStatus status, TBusMessage* mess, TBusMessage* reply) { - Y_UNUSED(mess); - Y_UNUSED(reply); - Y_VERIFY(status == MESSAGE_OK, "failed to get reply"); + Y_UNUSED(mess); + Y_UNUSED(reply); + Y_VERIFY(status == MESSAGE_OK, "failed to get reply"); if (AtomicIncrement(ReplyCount) == 1) { TestSync->WaitForAndIncrement(1); job->SendReply(new TExampleResponse(&Proto.ResponseCount)); @@ -289,7 +289,7 @@ Y_UNIT_TEST_SUITE(BusJobTest) { } TJobHandler HandleReplies(TBusJob* job, TBusMessage* mess) { - Y_UNUSED(mess); + Y_UNUSED(mess); job->Cancel(MESSAGE_UNKNOWN); return nullptr; } @@ -301,7 +301,7 @@ Y_UNIT_TEST_SUITE(BusJobTest) { } }; - Y_UNIT_TEST(SendReplyCalledBeforeAllRepliesReceived) { + Y_UNIT_TEST(SendReplyCalledBeforeAllRepliesReceived) { TTestSync testSync; TSlowReplyServer slowReplyServer(&testSync); @@ -338,7 +338,7 @@ Y_UNIT_TEST_SUITE(BusJobTest) { } void HandleReply(TBusJob*, EMessageStatus status, TBusMessage*, TBusMessage*) { - Y_VERIFY(status == MESSAGE_SHUTDOWN, "got %s", ToCString(status)); + Y_VERIFY(status == MESSAGE_SHUTDOWN, "got %s", ToCString(status)); TestSync.CheckAndIncrement(1); } @@ -349,7 +349,7 @@ Y_UNIT_TEST_SUITE(BusJobTest) { } }; - Y_UNIT_TEST(ShutdownCalledBeforeReplyReceived) { + Y_UNIT_TEST(ShutdownCalledBeforeReplyReceived) { TExampleServer server; server.ForgetRequest = true; diff --git a/library/cpp/messagebus/test/ut/module_server_ut.cpp b/library/cpp/messagebus/test/ut/module_server_ut.cpp index 88fe1dd9b6d..4acc9e3f59d 100644 --- a/library/cpp/messagebus/test/ut/module_server_ut.cpp +++ b/library/cpp/messagebus/test/ut/module_server_ut.cpp @@ -15,8 +15,8 @@ using namespace NBus; using namespace NBus::NTest; -Y_UNIT_TEST_SUITE(ModuleServerTests) { - Y_UNIT_TEST(TestModule) { +Y_UNIT_TEST_SUITE(ModuleServerTests) { + Y_UNIT_TEST(TestModule) { TObjectCountCheck objectCountCheck; /// create or get instance of message queue, need one per application @@ -49,7 +49,7 @@ Y_UNIT_TEST_SUITE(ModuleServerTests) { TJobHandler Start(TBusJob* job, TBusMessage* mess) override { WaitTwoRequestsLatch.CountDown(); - Y_VERIFY(WaitTwoRequestsLatch.Await(TDuration::Seconds(5)), "oops"); + Y_VERIFY(WaitTwoRequestsLatch.Await(TDuration::Seconds(5)), "oops"); VerifyDynamicCast<TExampleRequest*>(mess); @@ -58,7 +58,7 @@ Y_UNIT_TEST_SUITE(ModuleServerTests) { } }; - Y_UNIT_TEST(TestOnMessageHandlerCalledInParallel) { + Y_UNIT_TEST(TestOnMessageHandlerCalledInParallel) { TObjectCountCheck objectCountCheck; TBusQueueConfig config; @@ -79,18 +79,18 @@ Y_UNIT_TEST_SUITE(ModuleServerTests) { TSystemEvent ClientDiedEvent; TJobHandler Start(TBusJob* job, TBusMessage* mess) override { - Y_UNUSED(mess); + Y_UNUSED(mess); MessageReceivedEvent.Signal(); - Y_VERIFY(ClientDiedEvent.WaitT(TDuration::Seconds(5)), "oops"); + Y_VERIFY(ClientDiedEvent.WaitT(TDuration::Seconds(5)), "oops"); job->SendReply(new TExampleResponse(&Proto.ResponseCount)); return nullptr; } }; - Y_UNIT_TEST(TestReplyCalledAfterClientDisconnected) { + Y_UNIT_TEST(TestReplyCalledAfterClientDisconnected) { TObjectCountCheck objectCountCheck; TBusQueueConfig config; diff --git a/library/cpp/messagebus/test/ut/one_way_ut.cpp b/library/cpp/messagebus/test/ut/one_way_ut.cpp index 9c21227e2bd..7f18da400e8 100644 --- a/library/cpp/messagebus/test/ut/one_way_ut.cpp +++ b/library/cpp/messagebus/test/ut/one_way_ut.cpp @@ -114,7 +114,7 @@ public: void OnMessage(TOnMessageContext& mess) override { TExampleRequest* fmess = static_cast<TExampleRequest*>(mess.GetMessage()); - Y_ASSERT(fmess->Data == "TADA"); + Y_ASSERT(fmess->Data == "TADA"); /// tell session to forget this message and never expect any reply mess.ForgetRequest(); @@ -124,13 +124,13 @@ public: /// this handler should not be called because this server does not send replies void OnSent(TAutoPtr<TBusMessage> mess) override { - Y_UNUSED(mess); - Y_FAIL("This server does not sent replies"); + Y_UNUSED(mess); + Y_FAIL("This server does not sent replies"); } }; -Y_UNIT_TEST_SUITE(TMessageBusTests_OneWay) { - Y_UNIT_TEST(Simple) { +Y_UNIT_TEST_SUITE(TMessageBusTests_OneWay) { + Y_UNIT_TEST(Simple) { TObjectCountCheck objectCountCheck; NullServer server; @@ -166,15 +166,15 @@ Y_UNIT_TEST_SUITE(TMessageBusTests_OneWay) { } void OnError(TAutoPtr<TBusMessage> mess, EMessageStatus status) override { - Y_UNUSED(mess); + Y_UNUSED(mess); - Y_VERIFY(status == MESSAGE_MESSAGE_TOO_LARGE, "wrong status: %s", ToCString(status)); + Y_VERIFY(status == MESSAGE_MESSAGE_TOO_LARGE, "wrong status: %s", ToCString(status)); GotTooLarge.Signal(); } }; - Y_UNIT_TEST(MessageTooLargeOnClient) { + Y_UNIT_TEST(MessageTooLargeOnClient) { TObjectCountCheck objectCountCheck; NullServer server; @@ -209,14 +209,14 @@ Y_UNIT_TEST_SUITE(TMessageBusTests_OneWay) { /// message that could not be delivered void OnError(TAutoPtr<TBusMessage> mess, EMessageStatus status) override { - Y_UNUSED(mess); - Y_UNUSED(status); // TODO: check status + Y_UNUSED(mess); + Y_UNUSED(status); // TODO: check status GotError.Signal(); } }; - Y_UNIT_TEST(SendTimeout_Callback_NoServer) { + Y_UNIT_TEST(SendTimeout_Callback_NoServer) { TObjectCountCheck objectCountCheck; TCheckTimeoutClient client(TNetAddr("localhost", 17)); @@ -227,7 +227,7 @@ Y_UNIT_TEST_SUITE(TMessageBusTests_OneWay) { client.GotError.WaitI(); } - Y_UNIT_TEST(SendTimeout_Callback_HangingServer) { + Y_UNIT_TEST(SendTimeout_Callback_HangingServer) { THangingServer server; TObjectCountCheck objectCountCheck; diff --git a/library/cpp/messagebus/test/ut/starter_ut.cpp b/library/cpp/messagebus/test/ut/starter_ut.cpp index dd4d3aaa5e3..76d688b62e3 100644 --- a/library/cpp/messagebus/test/ut/starter_ut.cpp +++ b/library/cpp/messagebus/test/ut/starter_ut.cpp @@ -7,7 +7,7 @@ using namespace NBus; using namespace NBus::NTest; -Y_UNIT_TEST_SUITE(TBusStarterTest) { +Y_UNIT_TEST_SUITE(TBusStarterTest) { struct TStartJobTestModule: public TExampleModule { using TBusModule::CreateDefaultStarter; @@ -19,21 +19,21 @@ Y_UNIT_TEST_SUITE(TBusStarterTest) { } TJobHandler Start(TBusJob* job, TBusMessage* mess) override { - Y_UNUSED(mess); + Y_UNUSED(mess); AtomicIncrement(StartCount); job->Sleep(10); return &TStartJobTestModule::End; } TJobHandler End(TBusJob* job, TBusMessage* mess) { - Y_UNUSED(mess); + Y_UNUSED(mess); AtomicIncrement(StartCount); job->Cancel(MESSAGE_UNKNOWN); return nullptr; } }; - Y_UNIT_TEST(Test) { + Y_UNIT_TEST(Test) { TObjectCountCheck objectCountCheck; TBusMessageQueuePtr bus(CreateMessageQueue()); @@ -55,7 +55,7 @@ Y_UNIT_TEST_SUITE(TBusStarterTest) { bus->Stop(); } - Y_UNIT_TEST(TestModuleStartJob) { + Y_UNIT_TEST(TestModuleStartJob) { TObjectCountCheck objectCountCheck; TExampleProtocol proto; @@ -79,7 +79,7 @@ Y_UNIT_TEST_SUITE(TBusStarterTest) { TSystemEvent MessageReceivedEvent; TJobHandler Start(TBusJob* job, TBusMessage* mess) override { - Y_UNUSED(mess); + Y_UNUSED(mess); MessageReceivedEvent.Signal(); @@ -89,12 +89,12 @@ Y_UNIT_TEST_SUITE(TBusStarterTest) { } TJobHandler Never(TBusJob*, TBusMessage*) { - Y_FAIL("happens"); + Y_FAIL("happens"); throw 1; } }; - Y_UNIT_TEST(StartJobDestroyDuringSleep) { + Y_UNIT_TEST(StartJobDestroyDuringSleep) { TObjectCountCheck objectCountCheck; TExampleProtocol proto; @@ -114,7 +114,7 @@ Y_UNIT_TEST_SUITE(TBusStarterTest) { TSystemEvent MessageReceivedEvent; TJobHandler Start(TBusJob* job, TBusMessage* mess) override { - Y_UNUSED(mess); + Y_UNUSED(mess); job->SendReply(new TExampleResponse(&Proto.ResponseCount)); @@ -124,7 +124,7 @@ Y_UNIT_TEST_SUITE(TBusStarterTest) { } }; - Y_UNIT_TEST(AllowSendReplyInStarted) { + Y_UNIT_TEST(AllowSendReplyInStarted) { TObjectCountCheck objectCountCheck; TExampleProtocol proto; diff --git a/library/cpp/messagebus/test/ut/sync_client_ut.cpp b/library/cpp/messagebus/test/ut/sync_client_ut.cpp index 400128193f9..735aa06569e 100644 --- a/library/cpp/messagebus/test/ut/sync_client_ut.cpp +++ b/library/cpp/messagebus/test/ut/sync_client_ut.cpp @@ -50,8 +50,8 @@ namespace NBus { } }; - Y_UNIT_TEST_SUITE(SyncClientTest) { - Y_UNIT_TEST(TestSync) { + Y_UNIT_TEST_SUITE(SyncClientTest) { + Y_UNIT_TEST(TestSync) { TObjectCountCheck objectCountCheck; TExampleServer server; diff --git a/library/cpp/messagebus/use_after_free_checker.cpp b/library/cpp/messagebus/use_after_free_checker.cpp index 4904e7c614a..5fc62f7b622 100644 --- a/library/cpp/messagebus/use_after_free_checker.cpp +++ b/library/cpp/messagebus/use_after_free_checker.cpp @@ -13,10 +13,10 @@ TUseAfterFreeChecker::TUseAfterFreeChecker() } TUseAfterFreeChecker::~TUseAfterFreeChecker() { - Y_VERIFY(Magic == VALID, "Corrupted"); + Y_VERIFY(Magic == VALID, "Corrupted"); Magic = INVALID; } void TUseAfterFreeChecker::CheckNotFreed() const { - Y_VERIFY(Magic == VALID, "Freed or corrupted"); + Y_VERIFY(Magic == VALID, "Freed or corrupted"); } diff --git a/library/cpp/messagebus/vector_swaps.h b/library/cpp/messagebus/vector_swaps.h index b920bcf03ea..2edcd991143 100644 --- a/library/cpp/messagebus/vector_swaps.h +++ b/library/cpp/messagebus/vector_swaps.h @@ -15,8 +15,8 @@ private: T* EndOfStorage; void StateCheck() { - Y_ASSERT(Start <= Finish); - Y_ASSERT(Finish <= EndOfStorage); + Y_ASSERT(Start <= Finish); + Y_ASSERT(Finish <= EndOfStorage); } public: @@ -69,12 +69,12 @@ public: } T& operator[](size_t index) { - Y_ASSERT(index < size()); + Y_ASSERT(index < size()); return Start[index]; } const T& operator[](size_t index) const { - Y_ASSERT(index < size()); + Y_ASSERT(index < size()); return Start[index]; } @@ -122,7 +122,7 @@ public: size_t newCapacity = FastClp2(n); TVectorSwaps<T> tmp; tmp.Start = (T*)malloc(sizeof(T) * newCapacity); - Y_VERIFY(!!tmp.Start); + Y_VERIFY(!!tmp.Start); tmp.EndOfStorage = tmp.Start + newCapacity; @@ -146,7 +146,7 @@ public: template <class TIterator> void insert(iterator pos, TIterator b, TIterator e) { - Y_VERIFY(pos == end(), "TODO: only insert at the end is implemented"); + Y_VERIFY(pos == end(), "TODO: only insert at the end is implemented"); size_t count = e - b; diff --git a/library/cpp/messagebus/vector_swaps_ut.cpp b/library/cpp/messagebus/vector_swaps_ut.cpp index 693cc6857bd..9994cb80b28 100644 --- a/library/cpp/messagebus/vector_swaps_ut.cpp +++ b/library/cpp/messagebus/vector_swaps_ut.cpp @@ -2,8 +2,8 @@ #include "vector_swaps.h" -Y_UNIT_TEST_SUITE(TVectorSwapsTest) { - Y_UNIT_TEST(Simple) { +Y_UNIT_TEST_SUITE(TVectorSwapsTest) { + Y_UNIT_TEST(Simple) { TVectorSwaps<THolder<unsigned>> v; for (unsigned i = 0; i < 100; ++i) { THolder<unsigned> tmp(new unsigned(i)); diff --git a/library/cpp/messagebus/www/html_output.h b/library/cpp/messagebus/www/html_output.h index 27e77adefa7..3cbf350c0ca 100644 --- a/library/cpp/messagebus/www/html_output.h +++ b/library/cpp/messagebus/www/html_output.h @@ -7,17 +7,17 @@ #include <library/cpp/html/pcdata/pcdata.h> #include <util/system/tls.h> -extern Y_POD_THREAD(IOutputStream*) HtmlOutputStreamPtr; +extern Y_POD_THREAD(IOutputStream*) HtmlOutputStreamPtr; -static IOutputStream& HtmlOutputStream() { - Y_VERIFY(!!HtmlOutputStreamPtr); +static IOutputStream& HtmlOutputStream() { + Y_VERIFY(!!HtmlOutputStreamPtr); return *HtmlOutputStreamPtr; } struct THtmlOutputStreamPushPop { - IOutputStream* const Prev; + IOutputStream* const Prev; - THtmlOutputStreamPushPop(IOutputStream* outputStream) + THtmlOutputStreamPushPop(IOutputStream* outputStream) : Prev(HtmlOutputStreamPtr) { HtmlOutputStreamPtr = outputStream; diff --git a/library/cpp/messagebus/www/www.cpp b/library/cpp/messagebus/www/www.cpp index 62ec241d852..b9540681b31 100644 --- a/library/cpp/messagebus/www/www.cpp +++ b/library/cpp/messagebus/www/www.cpp @@ -38,7 +38,7 @@ namespace { TVector<std::pair<TString, TValuePtr>> Entries; TValuePtr FindByName(TStringBuf name) { - Y_VERIFY(!!name); + Y_VERIFY(!!name); for (unsigned i = 0; i < Entries.size(); ++i) { if (Entries[i].first == name) { @@ -49,7 +49,7 @@ namespace { } TString FindNameByPtr(TValuePtr value) { - Y_VERIFY(!!value); + Y_VERIFY(!!value); for (unsigned i = 0; i < Entries.size(); ++i) { if (Entries[i].second.Get() == value.Get()) { @@ -57,11 +57,11 @@ namespace { } } - Y_FAIL("unregistered"); + Y_FAIL("unregistered"); } void Add(TValuePtr p) { - Y_VERIFY(!!p); + Y_VERIFY(!!p); // Do not add twice for (unsigned i = 0; i < Entries.size(); ++i) { @@ -187,27 +187,27 @@ struct TBusWww::TImpl { TMutex Mutex; void RegisterClientSession(TBusClientSessionPtr s) { - Y_VERIFY(!!s); + Y_VERIFY(!!s); TGuard<TMutex> g(Mutex); ClientSessions.Add(s.Get()); Queues.Add(s->GetQueue()); } void RegisterServerSession(TBusServerSessionPtr s) { - Y_VERIFY(!!s); + Y_VERIFY(!!s); TGuard<TMutex> g(Mutex); ServerSessions.Add(s.Get()); Queues.Add(s->GetQueue()); } void RegisterQueue(TBusMessageQueuePtr q) { - Y_VERIFY(!!q); + Y_VERIFY(!!q); TGuard<TMutex> g(Mutex); Queues.Add(q); } void RegisterModule(TBusModule* module) { - Y_VERIFY(!!module); + Y_VERIFY(!!module); TGuard<TMutex> g(Mutex); { @@ -239,17 +239,17 @@ struct TBusWww::TImpl { serverSession = ServerSessions.FindByName(sessionName); session = serverSession.Get(); } - Y_VERIFY(!!session); + Y_VERIFY(!!session); return Queues.FindNameByPtr(session->GetQueue()); } struct TRequest { TImpl* const Outer; - IOutputStream& Os; + IOutputStream& Os; const TCgiParameters& CgiParams; const TOptionalParams& Params; - TRequest(TImpl* outer, IOutputStream& os, const TCgiParameters& cgiParams, const TOptionalParams& params) + TRequest(TImpl* outer, IOutputStream& os, const TCgiParameters& cgiParams, const TOptionalParams& params) : Outer(outer) , Os(os) , CgiParams(cgiParams) @@ -681,9 +681,9 @@ struct TBusWww::TImpl { } void ServeSolomonJson(const TString& q, const TString& cs, const TString& ss) { - Y_UNUSED(q); - Y_UNUSED(cs); - Y_UNUSED(ss); + Y_UNUSED(q); + Y_UNUSED(cs); + Y_UNUSED(ss); bool all = q == "" && cs == "" && ss == ""; NMonitoring::TDeprecatedJsonWriter sj(&Os); @@ -720,10 +720,10 @@ struct TBusWww::TImpl { sj.CloseDocument(); } - void ServeStatic(IOutputStream& os, TStringBuf path) { - if (path.EndsWith(".js")) { + void ServeStatic(IOutputStream& os, TStringBuf path) { + if (path.EndsWith(".js")) { os << HTTP_OK_JS; - } else if (path.EndsWith(".png")) { + } else if (path.EndsWith(".png")) { os << HTTP_OK_PNG; } else { os << HTTP_OK_BIN; @@ -799,7 +799,7 @@ struct TBusWww::TImpl { } }; - void ServeHttp(IOutputStream& os, const TCgiParameters& queryArgs, const TBusWww::TOptionalParams& params) { + void ServeHttp(IOutputStream& os, const TCgiParameters& queryArgs, const TBusWww::TOptionalParams& params) { TGuard<TMutex> g(Mutex); TRequest request(this, os, queryArgs, params); @@ -832,7 +832,7 @@ void TBusWww::RegisterModule(TBusModule* module) { Impl->RegisterModule(module); } -void TBusWww::ServeHttp(IOutputStream& httpOutputStream, +void TBusWww::ServeHttp(IOutputStream& httpOutputStream, const TCgiParameters& queryArgs, const TBusWww::TOptionalParams& params) { Impl->ServeHttp(httpOutputStream, queryArgs, params); @@ -843,7 +843,7 @@ struct TBusWwwHttpServer::TImpl: public THttpServer::ICallBack { THttpServer HttpServer; static THttpServer::TOptions MakeHttpServerOptions(unsigned port) { - Y_VERIFY(port > 0); + Y_VERIFY(port > 0); THttpServer::TOptions r; r.Port = port; return r; diff --git a/library/cpp/mime/types/mime.cpp b/library/cpp/mime/types/mime.cpp index 706d776b24d..4a58562ee9c 100644 --- a/library/cpp/mime/types/mime.cpp +++ b/library/cpp/mime/types/mime.cpp @@ -114,7 +114,7 @@ TMimeTypes::TMimeTypes() } void TMimeTypes::SetContentTypes() { - for (int i = 0; i < (int)Y_ARRAY_SIZE(Records); ++i) { + for (int i = 0; i < (int)Y_ARRAY_SIZE(Records); ++i) { const TRecord& record(Records[i]); assert(i == record.Mime || i > MIME_MAX || record.Mime == MIME_UNKNOWN); if (!record.ContentType) @@ -127,7 +127,7 @@ void TMimeTypes::SetContentTypes() { } void TMimeTypes::SetExt() { - for (int i = 0; i < (int)Y_ARRAY_SIZE(Records); ++i) { + for (int i = 0; i < (int)Y_ARRAY_SIZE(Records); ++i) { const TRecord& record(Records[i]); if (!record.Ext) continue; diff --git a/library/cpp/monlib/counters/counters.cpp b/library/cpp/monlib/counters/counters.cpp index 50dca4c577a..bda7f8c4043 100644 --- a/library/cpp/monlib/counters/counters.cpp +++ b/library/cpp/monlib/counters/counters.cpp @@ -27,7 +27,7 @@ namespace NMonitoring { } char* PrettyNum(i64 val, char* buf, size_t size) { - Y_ASSERT(buf); + Y_ASSERT(buf); if (size < 4) { buf[0] = 0; return buf; @@ -37,7 +37,7 @@ namespace NMonitoring { *buf = '\0'; } else { size_t len = 2 + strnlen(buf + 2, size - 4); - Y_ASSERT(len < size); + Y_ASSERT(len < size); buf[0] = ' '; buf[1] = '('; buf[len] = ')'; diff --git a/library/cpp/monlib/counters/counters_ut.cpp b/library/cpp/monlib/counters/counters_ut.cpp index 2845efb97ba..4d488b3ece6 100644 --- a/library/cpp/monlib/counters/counters_ut.cpp +++ b/library/cpp/monlib/counters/counters_ut.cpp @@ -8,7 +8,7 @@ using namespace NMonitoring; Y_UNIT_TEST_SUITE(TDeprecatedCountersTest) { - Y_UNIT_TEST(CounterGroupsAreThreadSafe) { + Y_UNIT_TEST(CounterGroupsAreThreadSafe) { const static ui32 GROUPS_COUNT = 1000; const static ui32 THREADS_COUNT = 10; diff --git a/library/cpp/monlib/counters/histogram_ut.cpp b/library/cpp/monlib/counters/histogram_ut.cpp index 5a0800505ab..890063c577d 100644 --- a/library/cpp/monlib/counters/histogram_ut.cpp +++ b/library/cpp/monlib/counters/histogram_ut.cpp @@ -4,8 +4,8 @@ using namespace NMonitoring; -Y_UNIT_TEST_SUITE(THistorgamTest) { - Y_UNIT_TEST(TakeSnapshot) { +Y_UNIT_TEST_SUITE(THistorgamTest) { + Y_UNIT_TEST(TakeSnapshot) { THdrHistogram h(1, 10, 3); UNIT_ASSERT(h.RecordValue(1)); UNIT_ASSERT(h.RecordValue(2)); diff --git a/library/cpp/monlib/counters/meter_ut.cpp b/library/cpp/monlib/counters/meter_ut.cpp index b507d16fbdd..96ff37e2f5f 100644 --- a/library/cpp/monlib/counters/meter_ut.cpp +++ b/library/cpp/monlib/counters/meter_ut.cpp @@ -18,8 +18,8 @@ struct TMockClock { using TMockMeter = TMeterImpl<TMockClock>; -Y_UNIT_TEST_SUITE(TMeterTest) { - Y_UNIT_TEST(StartsOutWithNoRatesOrCount) { +Y_UNIT_TEST_SUITE(TMeterTest) { + Y_UNIT_TEST(StartsOutWithNoRatesOrCount) { TMeter meter; UNIT_ASSERT_EQUAL(meter.GetCount(), 0L); UNIT_ASSERT_DOUBLES_EQUAL(meter.GetMeanRate(), 0.0, 0.0001); @@ -28,7 +28,7 @@ Y_UNIT_TEST_SUITE(TMeterTest) { UNIT_ASSERT_DOUBLES_EQUAL(meter.GetFifteenMinutesRate(), 0.0, 0.0001); } - Y_UNIT_TEST(MarksEventsAndUpdatesRatesAndCount) { + Y_UNIT_TEST(MarksEventsAndUpdatesRatesAndCount) { TMockMeter meter; meter.Mark(); meter.Mark(2); diff --git a/library/cpp/monlib/counters/timer_ut.cpp b/library/cpp/monlib/counters/timer_ut.cpp index c5cd07e89d5..cdd8bc494d8 100644 --- a/library/cpp/monlib/counters/timer_ut.cpp +++ b/library/cpp/monlib/counters/timer_ut.cpp @@ -16,8 +16,8 @@ public: int Value_; }; -Y_UNIT_TEST_SUITE(TTimerTest) { - Y_UNIT_TEST(RecordValue) { +Y_UNIT_TEST_SUITE(TTimerTest) { + Y_UNIT_TEST(RecordValue) { TTimerNs timerNs(1ns, 1s); UNIT_ASSERT(timerNs.RecordValue(10us)); @@ -36,7 +36,7 @@ Y_UNIT_TEST_SUITE(TTimerTest) { UNIT_ASSERT_DOUBLES_EQUAL(snapshot.StdDeviation, 0.0, 1e-6); } - Y_UNIT_TEST(Measure) { + Y_UNIT_TEST(Measure) { TTimerNs timer(1ns, 1s); timer.Measure([]() { Sleep(TDuration::MilliSeconds(1)); @@ -49,7 +49,7 @@ Y_UNIT_TEST_SUITE(TTimerTest) { UNIT_ASSERT_DOUBLES_EQUAL(snapshot.StdDeviation, 0.0, 1e-6); } - Y_UNIT_TEST(TimerScope) { + Y_UNIT_TEST(TimerScope) { TTimerUs timer(1us, 1000s); { TTimerScope<TTimerUs> scope(&timer); @@ -63,7 +63,7 @@ Y_UNIT_TEST_SUITE(TTimerTest) { UNIT_ASSERT_DOUBLES_EQUAL(snapshot.StdDeviation, 0.0, 1e-6); } - Y_UNIT_TEST(TimerScopeWithCallback) { + Y_UNIT_TEST(TimerScopeWithCallback) { TCallback callback(0); TTimerUs timer(1us, 1000s); { diff --git a/library/cpp/monlib/deprecated/json/writer_ut.cpp b/library/cpp/monlib/deprecated/json/writer_ut.cpp index 1f9fc8f3933..39b199d2510 100644 --- a/library/cpp/monlib/deprecated/json/writer_ut.cpp +++ b/library/cpp/monlib/deprecated/json/writer_ut.cpp @@ -5,7 +5,7 @@ using namespace NMonitoring; Y_UNIT_TEST_SUITE(JsonWriterTests) { - Y_UNIT_TEST(One) { + Y_UNIT_TEST(One) { TStringStream ss; TDeprecatedJsonWriter w(&ss); w.OpenDocument(); diff --git a/library/cpp/monlib/dynamic_counters/counters.cpp b/library/cpp/monlib/dynamic_counters/counters.cpp index 3635d87d0d2..339b6c3a070 100644 --- a/library/cpp/monlib/dynamic_counters/counters.cpp +++ b/library/cpp/monlib/dynamic_counters/counters.cpp @@ -153,7 +153,7 @@ void TDynamicCounters::MergeWithSubgroup(const TString& name, const TString& val auto it = Counters.find({name, value}); Y_VERIFY(it != Counters.end()); TIntrusivePtr<TDynamicCounters> subgroup = AsDynamicCounters(it->second); - Y_VERIFY(subgroup); + Y_VERIFY(subgroup); Counters.erase(it); Counters.merge(subgroup->Resign()); AtomicAdd(ExpiringCount, AtomicSwap(&subgroup->ExpiringCount, 0)); @@ -200,7 +200,7 @@ void TDynamicCounters::EnumerateSubgroups(const std::function<void(const TString } } -void TDynamicCounters::OutputPlainText(IOutputStream& os, const TString& indent) const { +void TDynamicCounters::OutputPlainText(IOutputStream& os, const TString& indent) const { auto snap = ReadSnapshot(); // mark private records in plain text output auto outputVisibilityMarker = [] (EVisibility vis) { diff --git a/library/cpp/monlib/dynamic_counters/counters.h b/library/cpp/monlib/dynamic_counters/counters.h index dc178cfbe01..1f5fadd32dc 100644 --- a/library/cpp/monlib/dynamic_counters/counters.h +++ b/library/cpp/monlib/dynamic_counters/counters.h @@ -343,11 +343,11 @@ namespace NMonitoring { const TString& value, TIntrusivePtr<TDynamicCounters> subgroup); - void OutputHtml(IOutputStream& os) const; + void OutputHtml(IOutputStream& os) const; void EnumerateSubgroups(const std::function<void(const TString& name, const TString& value)>& output) const; // mostly for debugging purposes -- use accept with encoder instead - void OutputPlainText(IOutputStream& os, const TString& indent = "") const; + void OutputPlainText(IOutputStream& os, const TString& indent = "") const; void Accept( const TString& labelName, const TString& labelValue, diff --git a/library/cpp/monlib/dynamic_counters/counters_ut.cpp b/library/cpp/monlib/dynamic_counters/counters_ut.cpp index 3591037e0a7..8e79949be9d 100644 --- a/library/cpp/monlib/dynamic_counters/counters_ut.cpp +++ b/library/cpp/monlib/dynamic_counters/counters_ut.cpp @@ -6,7 +6,7 @@ using namespace NMonitoring; class TCountersPrinter: public ICountableConsumer { public: - TCountersPrinter(IOutputStream* out) + TCountersPrinter(IOutputStream* out) : Out_(out) , Level_(0) { @@ -41,7 +41,7 @@ private: Indent(Out_, --Level_) << "}\n"; } - static IOutputStream& Indent(IOutputStream* out, int level) { + static IOutputStream& Indent(IOutputStream* out, int level) { for (int i = 0; i < level; i++) { out->Write(" "); } @@ -49,12 +49,12 @@ private: } private: - IOutputStream* Out_; + IOutputStream* Out_; int Level_ = 0; }; -Y_UNIT_TEST_SUITE(TDynamicCountersTest) { - Y_UNIT_TEST(CountersConsumer) { +Y_UNIT_TEST_SUITE(TDynamicCountersTest) { + Y_UNIT_TEST(CountersConsumer) { TDynamicCounterPtr rootGroup(new TDynamicCounters()); auto usersCounter = rootGroup->GetNamedCounter("users", "count"); @@ -97,7 +97,7 @@ Y_UNIT_TEST_SUITE(TDynamicCountersTest) { "}\n"); } - Y_UNIT_TEST(MergeSubgroup) { + Y_UNIT_TEST(MergeSubgroup) { TDynamicCounterPtr rootGroup(new TDynamicCounters()); auto sensor1 = rootGroup->GetNamedCounter("sensor", "1"); @@ -127,7 +127,7 @@ Y_UNIT_TEST_SUITE(TDynamicCountersTest) { "}\n"); } - Y_UNIT_TEST(ResetCounters) { + Y_UNIT_TEST(ResetCounters) { TDynamicCounterPtr rootGroup(new TDynamicCounters()); auto sensor1 = rootGroup->GetNamedCounter("sensor", "1"); @@ -176,7 +176,7 @@ Y_UNIT_TEST_SUITE(TDynamicCountersTest) { "}\n"); } - Y_UNIT_TEST(RemoveCounter) { + Y_UNIT_TEST(RemoveCounter) { TDynamicCounterPtr rootGroup(new TDynamicCounters()); rootGroup->GetNamedCounter("label", "1"); @@ -202,7 +202,7 @@ Y_UNIT_TEST_SUITE(TDynamicCountersTest) { "}\n"); } - Y_UNIT_TEST(RemoveSubgroup) { + Y_UNIT_TEST(RemoveSubgroup) { TDynamicCounterPtr rootGroup(new TDynamicCounters()); rootGroup->GetSubgroup("group", "1"); diff --git a/library/cpp/monlib/dynamic_counters/encode_ut.cpp b/library/cpp/monlib/dynamic_counters/encode_ut.cpp index 52d77b6b413..bc60b2a9333 100644 --- a/library/cpp/monlib/dynamic_counters/encode_ut.cpp +++ b/library/cpp/monlib/dynamic_counters/encode_ut.cpp @@ -130,10 +130,10 @@ namespace NMonitoring { } } - Y_UNIT_TEST_SUITE(TDynamicCountersEncodeTest) { + Y_UNIT_TEST_SUITE(TDynamicCountersEncodeTest) { TTestData Data; - Y_UNIT_TEST(Json) { + Y_UNIT_TEST(Json) { TString result; { TStringOutput out(result); @@ -150,7 +150,7 @@ namespace NMonitoring { AssertResult(samples); } - Y_UNIT_TEST(Spack) { + Y_UNIT_TEST(Spack) { TBuffer result; { TBufferOutput out(result); diff --git a/library/cpp/monlib/dynamic_counters/golovan_page.cpp b/library/cpp/monlib/dynamic_counters/golovan_page.cpp index 49cf2d39bb6..0654519a7e4 100644 --- a/library/cpp/monlib/dynamic_counters/golovan_page.cpp +++ b/library/cpp/monlib/dynamic_counters/golovan_page.cpp @@ -59,7 +59,7 @@ public: } private: - IOutputStream& out; + IOutputStream& out; bool FirstCounter; TString prefix; }; diff --git a/library/cpp/monlib/encode/buffered/string_pool_ut.cpp b/library/cpp/monlib/encode/buffered/string_pool_ut.cpp index 9fc3421d0bb..1b360f5cdcd 100644 --- a/library/cpp/monlib/encode/buffered/string_pool_ut.cpp +++ b/library/cpp/monlib/encode/buffered/string_pool_ut.cpp @@ -4,8 +4,8 @@ using namespace NMonitoring; -Y_UNIT_TEST_SUITE(TStringPoolTest) { - Y_UNIT_TEST(PutIfAbsent) { +Y_UNIT_TEST_SUITE(TStringPoolTest) { + Y_UNIT_TEST(PutIfAbsent) { TStringPoolBuilder strPool; strPool.SetSorted(true); @@ -25,7 +25,7 @@ Y_UNIT_TEST_SUITE(TStringPoolTest) { UNIT_ASSERT_VALUES_EQUAL(strPool.Count(), 2); } - Y_UNIT_TEST(SortByFrequency) { + Y_UNIT_TEST(SortByFrequency) { TStringPoolBuilder strPool; strPool.SetSorted(true); @@ -47,7 +47,7 @@ Y_UNIT_TEST_SUITE(TStringPoolTest) { UNIT_ASSERT_VALUES_EQUAL(strPool.Count(), 2); } - Y_UNIT_TEST(ForEach) { + Y_UNIT_TEST(ForEach) { TStringPoolBuilder strPool; strPool.SetSorted(true); diff --git a/library/cpp/monlib/encode/format_ut.cpp b/library/cpp/monlib/encode/format_ut.cpp index 22a0e30c037..516d89cd3fc 100644 --- a/library/cpp/monlib/encode/format_ut.cpp +++ b/library/cpp/monlib/encode/format_ut.cpp @@ -9,7 +9,7 @@ using namespace NMonitoring; -Y_UNIT_TEST_SUITE(TFormatTest) { +Y_UNIT_TEST_SUITE(TFormatTest) { Y_UNIT_TEST(ContentTypeHeader) { UNIT_ASSERT_EQUAL(FormatFromContentType(""), EFormat::UNKNOWN); UNIT_ASSERT_EQUAL(FormatFromContentType("application/json;some=stuff"), EFormat::JSON); @@ -18,7 +18,7 @@ Y_UNIT_TEST_SUITE(TFormatTest) { UNIT_ASSERT_EQUAL(FormatFromContentType(";application/xml"), EFormat::UNKNOWN); } - Y_UNIT_TEST(AcceptHeader) { + Y_UNIT_TEST(AcceptHeader) { UNIT_ASSERT_EQUAL(FormatFromAcceptHeader(""), EFormat::UNKNOWN); UNIT_ASSERT_EQUAL(FormatFromAcceptHeader("*/*"), EFormat::UNKNOWN); @@ -63,7 +63,7 @@ Y_UNIT_TEST_SUITE(TFormatTest) { EFormat::PROMETHEUS); } - Y_UNIT_TEST(FormatToStrFromStr) { + Y_UNIT_TEST(FormatToStrFromStr) { const std::array<EFormat, 6> formats = {{ EFormat::UNKNOWN, EFormat::SPACK, @@ -80,7 +80,7 @@ Y_UNIT_TEST_SUITE(TFormatTest) { } } - Y_UNIT_TEST(AcceptEncodingHeader) { + Y_UNIT_TEST(AcceptEncodingHeader) { UNIT_ASSERT_EQUAL( CompressionFromAcceptEncodingHeader(""), ECompression::UNKNOWN); @@ -118,7 +118,7 @@ Y_UNIT_TEST_SUITE(TFormatTest) { ECompression::LZ4); } - Y_UNIT_TEST(CompressionToStrFromStr) { + Y_UNIT_TEST(CompressionToStrFromStr) { const std::array<ECompression, 5> algs = {{ ECompression::UNKNOWN, ECompression::IDENTITY, diff --git a/library/cpp/monlib/encode/json/json_ut.cpp b/library/cpp/monlib/encode/json/json_ut.cpp index 09e79092890..e76e6691f95 100644 --- a/library/cpp/monlib/encode/json/json_ut.cpp +++ b/library/cpp/monlib/encode/json/json_ut.cpp @@ -132,10 +132,10 @@ namespace { } // namespace -Y_UNIT_TEST_SUITE(TJsonTest) { +Y_UNIT_TEST_SUITE(TJsonTest) { const TInstant now = TInstant::ParseIso8601Deprecated("2017-11-05T01:02:03Z"); - Y_UNIT_TEST(Encode) { + Y_UNIT_TEST(Encode) { auto check = [](bool cloud, bool buffered, TStringBuf expectedResourceKey) { TString json; TStringOutput out(json); @@ -353,7 +353,7 @@ Y_UNIT_TEST_SUITE(TJsonTest) { AssertPointEqual(s.GetPoints(0), TInstant::Zero(), ui64(1)); } } - Y_UNIT_TEST(Decode1) { + Y_UNIT_TEST(Decode1) { NProto::TMultiSamplesList samples; { IMetricEncoderPtr e = EncoderProtobuf(&samples); diff --git a/library/cpp/monlib/encode/spack/spack_v1_ut.cpp b/library/cpp/monlib/encode/spack/spack_v1_ut.cpp index fe778eb7e02..ca3843f7e42 100644 --- a/library/cpp/monlib/encode/spack/spack_v1_ut.cpp +++ b/library/cpp/monlib/encode/spack/spack_v1_ut.cpp @@ -48,7 +48,7 @@ void AssertPointEqual(const NProto::TPoint& p, TInstant time, i64 value) { UNIT_ASSERT_VALUES_EQUAL(p.GetInt64(), value); } -Y_UNIT_TEST_SUITE(TSpackTest) { +Y_UNIT_TEST_SUITE(TSpackTest) { ui8 expectedHeader_v1_0[] = { 0x53, 0x50, // magic "SP" (fixed ui16) // minor, major @@ -261,7 +261,7 @@ Y_UNIT_TEST_SUITE(TSpackTest) { return MakeIntrusive<TSummaryDoubleSnapshot>(10.1, -0.45, 0.478, 0.3, 30u); } - Y_UNIT_TEST(Encode) { + Y_UNIT_TEST(Encode) { TBuffer buffer; TBufferOutput out(buffer); auto e = EncoderSpackV1( @@ -669,19 +669,19 @@ Y_UNIT_TEST_SUITE(TSpackTest) { } } - Y_UNIT_TEST(CompressionIdentity) { + Y_UNIT_TEST(CompressionIdentity) { TestCompression(ECompression::IDENTITY); } - Y_UNIT_TEST(CompressionZlib) { + Y_UNIT_TEST(CompressionZlib) { TestCompression(ECompression::ZLIB); } - Y_UNIT_TEST(CompressionZstd) { + Y_UNIT_TEST(CompressionZstd) { TestCompression(ECompression::ZSTD); } - Y_UNIT_TEST(CompressionLz4) { + Y_UNIT_TEST(CompressionLz4) { TestCompression(ECompression::LZ4); } diff --git a/library/cpp/monlib/encode/text/text_encoder_ut.cpp b/library/cpp/monlib/encode/text/text_encoder_ut.cpp index 554b6f5fa9e..3ae749dd515 100644 --- a/library/cpp/monlib/encode/text/text_encoder_ut.cpp +++ b/library/cpp/monlib/encode/text/text_encoder_ut.cpp @@ -6,7 +6,7 @@ using namespace NMonitoring; -Y_UNIT_TEST_SUITE(TTextText) { +Y_UNIT_TEST_SUITE(TTextText) { template <typename TFunc> TString EncodeToString(bool humanReadableTs, TFunc fn) { TStringStream ss; @@ -15,7 +15,7 @@ Y_UNIT_TEST_SUITE(TTextText) { return ss.Str(); } - Y_UNIT_TEST(Empty) { + Y_UNIT_TEST(Empty) { auto result = EncodeToString(true, [](IMetricEncoder* e) { e->OnStreamBegin(); e->OnStreamEnd(); @@ -23,7 +23,7 @@ Y_UNIT_TEST_SUITE(TTextText) { UNIT_ASSERT_STRINGS_EQUAL(result, ""); } - Y_UNIT_TEST(CommonPart) { + Y_UNIT_TEST(CommonPart) { auto result = EncodeToString(true, [](IMetricEncoder* e) { e->OnStreamBegin(); e->OnCommonTime(TInstant::ParseIso8601Deprecated("2017-01-02T03:04:05.006Z")); @@ -41,7 +41,7 @@ Y_UNIT_TEST_SUITE(TTextText) { "common labels: {project='solomon', cluster='man', service='stockpile'}\n"); } - Y_UNIT_TEST(Gauges) { + Y_UNIT_TEST(Gauges) { auto result = EncodeToString(true, [](IMetricEncoder* e) { e->OnStreamBegin(); { // no values @@ -157,7 +157,7 @@ Y_UNIT_TEST_SUITE(TTextText) { " IGAUGE bytesRx{host='solomon-sas-01', dc='sas'} [(2017-12-02T12:00:00Z, 2), (2017-12-02T12:00:05Z, 4), (2017-12-02T12:00:10Z, 8)]\n"); } - Y_UNIT_TEST(Counters) { + Y_UNIT_TEST(Counters) { auto doEncode = [](IMetricEncoder* e) { e->OnStreamBegin(); { // no values diff --git a/library/cpp/monlib/metrics/labels_ut.cpp b/library/cpp/monlib/metrics/labels_ut.cpp index f0e4f532aba..960e326d868 100644 --- a/library/cpp/monlib/metrics/labels_ut.cpp +++ b/library/cpp/monlib/metrics/labels_ut.cpp @@ -4,11 +4,11 @@ using namespace NMonitoring; -Y_UNIT_TEST_SUITE(TLabelsTest) { +Y_UNIT_TEST_SUITE(TLabelsTest) { TLabel pSolomon("project", "solomon"); TLabel pKikimr("project", "kikimr"); - Y_UNIT_TEST(Equals) { + Y_UNIT_TEST(Equals) { UNIT_ASSERT(pSolomon == TLabel("project", "solomon")); UNIT_ASSERT_STRINGS_EQUAL(pSolomon.Name(), "project"); @@ -17,12 +17,12 @@ Y_UNIT_TEST_SUITE(TLabelsTest) { UNIT_ASSERT(pSolomon != pKikimr); } - Y_UNIT_TEST(ToString) { + Y_UNIT_TEST(ToString) { UNIT_ASSERT_STRINGS_EQUAL(pSolomon.ToString(), "project=solomon"); UNIT_ASSERT_STRINGS_EQUAL(pKikimr.ToString(), "project=kikimr"); } - Y_UNIT_TEST(FromString) { + Y_UNIT_TEST(FromString) { auto pYql = TLabel::FromString("project=yql"); UNIT_ASSERT_EQUAL(pYql, TLabel("project", "yql")); @@ -54,7 +54,7 @@ Y_UNIT_TEST_SUITE(TLabelsTest) { "label value cannot be empty"); } - Y_UNIT_TEST(TryFromString) { + Y_UNIT_TEST(TryFromString) { TLabel pYql; UNIT_ASSERT(TLabel::TryFromString("project=yql", pYql)); UNIT_ASSERT_EQUAL(pYql, TLabel("project", "yql")); @@ -91,7 +91,7 @@ Y_UNIT_TEST_SUITE(TLabelsTest) { } } - Y_UNIT_TEST(Labels) { + Y_UNIT_TEST(Labels) { TLabels labels; UNIT_ASSERT(labels.Add(TStringBuf("name1"), TStringBuf("value1"))); UNIT_ASSERT(labels.Size() == 1); @@ -135,7 +135,7 @@ Y_UNIT_TEST_SUITE(TLabelsTest) { })); } - Y_UNIT_TEST(Hash) { + Y_UNIT_TEST(Hash) { TLabel label("name", "value"); UNIT_ASSERT_EQUAL(ULL(2378153472115172159), label.Hash()); diff --git a/library/cpp/monlib/metrics/metric_registry_ut.cpp b/library/cpp/monlib/metrics/metric_registry_ut.cpp index 86d9a52ec0c..8d030386ad9 100644 --- a/library/cpp/monlib/metrics/metric_registry_ut.cpp +++ b/library/cpp/monlib/metrics/metric_registry_ut.cpp @@ -38,7 +38,7 @@ void Out<NMonitoring::NProto::TSingleSample::ValueCase>(IOutputStream& os, NMoni } Y_UNIT_TEST_SUITE(TMetricRegistryTest) { - Y_UNIT_TEST(Gauge) { + Y_UNIT_TEST(Gauge) { TMetricRegistry registry(TLabels{{"common", "label"}}); TGauge* g = registry.Gauge({{"my", "gauge"}}); @@ -122,7 +122,7 @@ Y_UNIT_TEST_SUITE(TMetricRegistryTest) { UNIT_ASSERT_VALUES_EQUAL(g->Get(), val); } - Y_UNIT_TEST(Counter) { + Y_UNIT_TEST(Counter) { TMetricRegistry registry(TLabels{{"common", "label"}}); TCounter* c = registry.Counter({{"my", "counter"}}); @@ -155,7 +155,7 @@ Y_UNIT_TEST_SUITE(TMetricRegistryTest) { UNIT_ASSERT_VALUES_EQUAL(r->Get(), 42); } - Y_UNIT_TEST(DoubleCounter) { + Y_UNIT_TEST(DoubleCounter) { TMetricRegistry registry(TLabels{{"common", "label"}}); TCounter* c = registry.Counter({{"my", "counter"}}); @@ -166,7 +166,7 @@ Y_UNIT_TEST_SUITE(TMetricRegistryTest) { UNIT_ASSERT_VALUES_EQUAL(c->Get(), 10); } - Y_UNIT_TEST(Sample) { + Y_UNIT_TEST(Sample) { TMetricRegistry registry(TLabels{{"common", "label"}}); TGauge* g = registry.Gauge({{"my", "gauge"}}); diff --git a/library/cpp/monlib/service/mon_service_http_request.h b/library/cpp/monlib/service/mon_service_http_request.h index b4f2f8f0c59..26cf39a5e59 100644 --- a/library/cpp/monlib/service/mon_service_http_request.h +++ b/library/cpp/monlib/service/mon_service_http_request.h @@ -42,7 +42,7 @@ namespace NMonitoring { TMonService2HttpRequest* const Parent; TMonService2HttpRequest( - IOutputStream* out, const IHttpRequest* httpRequest, + IOutputStream* out, const IHttpRequest* httpRequest, TMonService2* monService, IMonPage* monPage, const TString& pathInfo, TMonService2HttpRequest* parent) diff --git a/library/cpp/monlib/service/monservice.cpp b/library/cpp/monlib/service/monservice.cpp index d1b9cda1d21..25d8922672f 100644 --- a/library/cpp/monlib/service/monservice.cpp +++ b/library/cpp/monlib/service/monservice.cpp @@ -23,7 +23,7 @@ TMonService2::TMonService2(const THttpServerOptions& options, const TString& tit , IndexMonPage(new TIndexMonPage("", Title)) , AuthProvider_{std::move(auth)} { - Y_VERIFY(!!title); + Y_VERIFY(!!title); time_t t = time(nullptr); ctime_r(&t, StartTime); } @@ -79,7 +79,7 @@ void TMonService2::OutputIndexBody(IOutputStream& out) { void TMonService2::ServeRequest(IOutputStream& out, const NMonitoring::IHttpRequest& request) { TString path = request.GetPath(); - Y_VERIFY(path.StartsWith('/')); + Y_VERIFY(path.StartsWith('/')); if (AuthProvider_) { const auto authResult = AuthProvider_->Check(request); diff --git a/library/cpp/monlib/service/pages/index_mon_page.cpp b/library/cpp/monlib/service/pages/index_mon_page.cpp index 83ff8b529ae..1d6227ff033 100644 --- a/library/cpp/monlib/service/pages/index_mon_page.cpp +++ b/library/cpp/monlib/service/pages/index_mon_page.cpp @@ -53,8 +53,8 @@ void TIndexMonPage::Output(IMonHttpRequest& request) { void TIndexMonPage::OutputIndex(IOutputStream& out, bool pathEndsWithSlash) { TGuard<TMutex> g(Mtx); - for (auto& Page : Pages) { - IMonPage* page = Page.Get(); + for (auto& Page : Pages) { + IMonPage* page = Page.Get(); if (page->IsInIndex()) { TString pathToDir = ""; if (!pathEndsWithSlash) { @@ -97,7 +97,7 @@ TIndexMonPage* TIndexMonPage::RegisterIndexPage(const TString& path, const TStri IMonPage* TIndexMonPage::FindPage(const TString& relativePath) { TGuard<TMutex> g(Mtx); - Y_VERIFY(!relativePath.StartsWith('/')); + Y_VERIFY(!relativePath.StartsWith('/')); TPagesByPath::iterator i = PagesByPath.find("/" + relativePath); if (i == PagesByPath.end()) { return nullptr; @@ -110,7 +110,7 @@ TIndexMonPage* TIndexMonPage::FindIndexPage(const TString& relativePath) { return VerifyDynamicCast<TIndexMonPage*>(FindPage(relativePath)); } -void TIndexMonPage::OutputCommonJsCss(IOutputStream& out) { +void TIndexMonPage::OutputCommonJsCss(IOutputStream& out) { out << "<link rel='stylesheet' href='https://yastatic.net/bootstrap/3.3.1/css/bootstrap.min.css'>\n"; out << "<script language='javascript' type='text/javascript' src='https://yastatic.net/jquery/2.1.3/jquery.min.js'></script>\n"; out << "<script language='javascript' type='text/javascript' src='https://yastatic.net/bootstrap/3.3.1/js/bootstrap.min.js'></script>\n"; diff --git a/library/cpp/monlib/service/pages/mon_page.cpp b/library/cpp/monlib/service/pages/mon_page.cpp index 72033b1699a..4d53beff063 100644 --- a/library/cpp/monlib/service/pages/mon_page.cpp +++ b/library/cpp/monlib/service/pages/mon_page.cpp @@ -6,8 +6,8 @@ IMonPage::IMonPage(const TString& path, const TString& title) : Path(path) , Title(title) { - Y_VERIFY(!Path.StartsWith('/')); - Y_VERIFY(!Path.EndsWith('/')); + Y_VERIFY(!Path.StartsWith('/')); + Y_VERIFY(!Path.EndsWith('/')); } void IMonPage::OutputNavBar(IOutputStream& out) { diff --git a/library/cpp/monlib/service/pages/templates.h b/library/cpp/monlib/service/pages/templates.h index b4656f059fa..ca98447ac56 100644 --- a/library/cpp/monlib/service/pages/templates.h +++ b/library/cpp/monlib/service/pages/templates.h @@ -188,12 +188,12 @@ namespace NMonitoring { }; struct TOutputStreamRef { - TOutputStreamRef(IOutputStream& str) + TOutputStreamRef(IOutputStream& str) : Str(str) { } - inline operator IOutputStream&() noexcept { + inline operator IOutputStream&() noexcept { return Str; } @@ -201,7 +201,7 @@ namespace NMonitoring { return true; // just to work with WITH_SCOPED } - IOutputStream& Str; + IOutputStream& Str; }; extern const char HtmlTag[5]; diff --git a/library/cpp/monlib/service/service.cpp b/library/cpp/monlib/service/service.cpp index 929efbf8162..e486b15dd41 100644 --- a/library/cpp/monlib/service/service.cpp +++ b/library/cpp/monlib/service/service.cpp @@ -8,7 +8,7 @@ #include <util/generic/buffer.h> #include <util/stream/str.h> -#include <util/stream/buffer.h> +#include <util/stream/buffer.h> #include <util/stream/zerocopy.h> #include <util/string/vector.h> @@ -30,7 +30,7 @@ namespace NMonitoring { return; } TString path = GetPath(); - if (!path.StartsWith('/')) { + if (!path.StartsWith('/')) { out << "HTTP/1.1 400 Bad request\r\nConnection: Close\r\n\r\n"; return; } @@ -165,7 +165,7 @@ namespace NMonitoring { throw; // just rethrow } - void TCoHttpServer::ProcessRequest(IOutputStream& out, const IHttpRequest& request) { + void TCoHttpServer::ProcessRequest(IOutputStream& out, const IHttpRequest& request) { try { TNetworkAddress addr(BindAddr, Port); TSocket sock(addr); @@ -257,7 +257,7 @@ namespace NMonitoring { CoServer.Stop(); } - void TMonService::DispatchRequest(IOutputStream& out, const IHttpRequest& request) { + void TMonService::DispatchRequest(IOutputStream& out, const IHttpRequest& request) { if (strcmp(request.GetPath(), "/") == 0) { out << "HTTP/1.1 200 Ok\nConnection: Close\n\n"; MtHandler(out, request); diff --git a/library/cpp/monlib/service/service.h b/library/cpp/monlib/service/service.h index 2f66dddaf87..6aa112902e6 100644 --- a/library/cpp/monlib/service/service.h +++ b/library/cpp/monlib/service/service.h @@ -41,7 +41,7 @@ namespace NMonitoring { // by forwarding it to the httpserver // @note this call may be blocking; don't use inside coroutines // @throws may throw in case of connection error, etc - void ProcessRequest(IOutputStream&, const IHttpRequest&); + void ProcessRequest(IOutputStream&, const IHttpRequest&); private: class TConnection; @@ -101,7 +101,7 @@ namespace NMonitoring { void Stop(); protected: - void DispatchRequest(IOutputStream& out, const IHttpRequest&); + void DispatchRequest(IOutputStream& out, const IHttpRequest&); private: TCoHttpServer CoServer; diff --git a/library/cpp/object_factory/object_factory_ut.cpp b/library/cpp/object_factory/object_factory_ut.cpp index 06fb0739ff0..be9558d8e95 100644 --- a/library/cpp/object_factory/object_factory_ut.cpp +++ b/library/cpp/object_factory/object_factory_ut.cpp @@ -142,8 +142,8 @@ struct TDirectOrderDSCreator: public IFactoryObjectCreator<ICommonInterface, con static TTestFactory::TRegistrator<TDirectOrderDifferentSignature> DirectDs("direct_ds", new TDirectOrderDSCreator); -Y_UNIT_TEST_SUITE(TestObjectFactory) { - Y_UNIT_TEST(TestParametrized) { +Y_UNIT_TEST_SUITE(TestObjectFactory) { + Y_UNIT_TEST(TestParametrized) { TArgument directArg{"Name", nullptr}; TArgument inverseArg{"Fake", nullptr}; THolder<ICommonInterface> direct(TTestFactory::Construct("direct", "prov", 0.42, directArg)); diff --git a/library/cpp/on_disk/chunks/chunked_helpers.cpp b/library/cpp/on_disk/chunks/chunked_helpers.cpp index b7adba27535..e0bd21bf7c5 100644 --- a/library/cpp/on_disk/chunks/chunked_helpers.cpp +++ b/library/cpp/on_disk/chunks/chunked_helpers.cpp @@ -37,7 +37,7 @@ TNamedChunkedDataReader::TNamedChunkedDataReader(const TBlob& blob) /*************************** TNamedChunkedDataWriter ***************************/ -TNamedChunkedDataWriter::TNamedChunkedDataWriter(IOutputStream& slave) +TNamedChunkedDataWriter::TNamedChunkedDataWriter(IOutputStream& slave) : TChunkedDataWriter(slave) { } diff --git a/library/cpp/on_disk/chunks/chunked_helpers.h b/library/cpp/on_disk/chunks/chunked_helpers.h index 5fa96afdca0..4b04771c316 100644 --- a/library/cpp/on_disk/chunks/chunked_helpers.h +++ b/library/cpp/on_disk/chunks/chunked_helpers.h @@ -8,15 +8,15 @@ #include <util/memory/blob.h> #include <util/stream/buffer.h> #include <util/stream/mem.h> -#include <util/system/unaligned_mem.h> +#include <util/system/unaligned_mem.h> #include <util/ysaveload.h> #include "reader.h" #include "writer.h" #include <cmath> -#include <cstddef> - +#include <cstddef> + template <typename T> class TYVector { private: @@ -25,14 +25,14 @@ private: public: TYVector(const TBlob& blob) - : Size(IntegerCast<ui32>(ReadUnaligned<ui64>(blob.Data()))) + : Size(IntegerCast<ui32>(ReadUnaligned<ui64>(blob.Data()))) , Data((const T*)((const char*)blob.Data() + sizeof(ui64))) { } void Get(size_t idx, T& t) const { assert(idx < (size_t)Size); - t = ReadUnaligned<T>(Data + idx); + t = ReadUnaligned<T>(Data + idx); } const T& At(size_t idx) const { @@ -63,7 +63,7 @@ public: Vector.push_back(value); } - void Save(IOutputStream& out) const { + void Save(IOutputStream& out) const { ui64 uSize = (ui64)Vector.size(); out.Write(&uSize, sizeof(uSize)); out.Write(Vector.data(), Vector.size() * sizeof(T)); @@ -172,16 +172,16 @@ protected: typename TTypeTraits<TValue>::TFuncParam Second() const { return Value; } - - static TKey GetFirst(const void* self) { - static constexpr size_t offset = offsetof(TThis, Key); + + static TKey GetFirst(const void* self) { + static constexpr size_t offset = offsetof(TThis, Key); return ReadUnaligned<TKey>(reinterpret_cast<const char*>(self) + offset); - } - - static TValue GetSecond(const void* self) { - static constexpr size_t offset = offsetof(TThis, Value); + } + + static TValue GetSecond(const void* self) { + static constexpr size_t offset = offsetof(TThis, Value); return ReadUnaligned<TValue>(reinterpret_cast<const char*>(self) + offset); - } + } }; #pragma pack(pop) @@ -221,10 +221,10 @@ protected: template <typename TKey> static ui32 KeyHash(typename TTypeTraits<TKey>::TFuncParam key, ui16 bits) { - Y_ASSERT(bits < 32); + Y_ASSERT(bits < 32); const ui32 res = ui32(key) & ((ui32(1) << bits) - 1); - Y_ASSERT(res < (ui32(1) << bits)); + Y_ASSERT(res < (ui32(1) << bits)); return res; } }; @@ -240,7 +240,7 @@ private: bool IsPlainEnought(ui16 bits) const { TVector<size_t> counts(1LL << bits, 0); for (size_t i = 0; i < Data.size(); ++i) { - size_t& count = counts[KeyHash<TKey>(TKeyValuePair::GetFirst(&Data[i]), bits)]; + size_t& count = counts[KeyHash<TKey>(TKeyValuePair::GetFirst(&Data[i]), bits)]; ++count; if (count > 2) return false; @@ -253,8 +253,8 @@ public: Data.push_back(TKeyValuePair(key, value)); } - void Save(IOutputStream& out) const { - Y_ASSERT(Data.size() < Max<ui32>()); + void Save(IOutputStream& out) const { + Y_ASSERT(Data.size() < Max<ui32>()); WriteBin<ui16>(&out, VERSION_ID); static const ui32 PAIR_SIZE = sizeof(TKeyValuePair); @@ -274,7 +274,7 @@ public: const ui32 nBuckets = ui32(1) << bits; TData2 data2(nBuckets); for (size_t i = 0; i < Data.size(); ++i) - data2[KeyHash<TKey>(TKeyValuePair::GetFirst(&Data[i]), bits)].push_back(Data[i]); + data2[KeyHash<TKey>(TKeyValuePair::GetFirst(&Data[i]), bits)].push_back(Data[i]); typedef TVector<TInterval> TIntervals; TIntervals intervals(nBuckets); @@ -288,7 +288,7 @@ public: for (ui32 i = 0; i < nBuckets; ++i) { for (size_t j = 0; j < data2[i].size(); ++j) for (size_t k = j + 1; k < data2[i].size(); ++k) - if (TKeyValuePair::GetFirst(&data2[i][j]) == TKeyValuePair::GetFirst(&data2[i][k])) + if (TKeyValuePair::GetFirst(&data2[i][j]) == TKeyValuePair::GetFirst(&data2[i][k])) ythrow yexception() << "key clash"; } #endif @@ -306,11 +306,11 @@ private: const char* P; ui16 GetBits() const { - return ReadUnaligned<ui16>(P + 6); + return ReadUnaligned<ui16>(P + 6); } ui32 GetSize() const { - return ReadUnaligned<ui32>(P + 8); + return ReadUnaligned<ui32>(P + 8); } const TInterval* GetIntervals() const { @@ -326,11 +326,11 @@ private: static_assert(sizeof(T) == 1, "expect sizeof(T) == 1"); P = reinterpret_cast<const char*>(p); #ifndef NDEBUG - ui16 version = ReadUnaligned<ui16>(p); + ui16 version = ReadUnaligned<ui16>(p); if (version != VERSION_ID) ythrow yexception() << "bad version: " << version; static const ui32 PAIR_SIZE = sizeof(TKeyValuePair); - const ui32 size = ReadUnaligned<ui32>(p + 2); + const ui32 size = ReadUnaligned<ui32>(p + 2); if (size != PAIR_SIZE) ythrow yexception() << "bad size " << size << " instead of " << PAIR_SIZE; #endif @@ -354,8 +354,8 @@ public: const TKeyValuePair* pair = GetData() + TInterval::GetOffset(intervalPtr + hash); const ui32 length = TInterval::GetLength(intervalPtr + hash); for (ui32 i = 0; i < length; ++i, ++pair) { - if (TKeyValuePair::GetFirst(pair) == key) { - *res = TKeyValuePair::GetSecond(pair); + if (TKeyValuePair::GetFirst(pair) == key) { + *res = TKeyValuePair::GetSecond(pair); return true; } } @@ -407,8 +407,8 @@ private: public: TSingleValue(const TBlob& blob) { - Y_ASSERT(blob.Length() >= sizeof(T)); - Y_ASSERT(blob.Length() <= sizeof(T) + 16); + Y_ASSERT(blob.Length() >= sizeof(T)); + Y_ASSERT(blob.Length() <= sizeof(T) + 16); Value = reinterpret_cast<const T*>(blob.Begin()); } @@ -434,7 +434,7 @@ public: Value = value; } - void Save(IOutputStream& out) const { + void Save(IOutputStream& out) const { out.Write(&Value, sizeof(Value)); } }; @@ -528,12 +528,12 @@ private: template <class T> struct TSaveLoadVectorNonPodElement { - static inline void Save(IOutputStream* out, const T& t) { + static inline void Save(IOutputStream* out, const T& t) { TSerializer<T>::Save(out, t); } - static inline void Load(IInputStream* in, T& t, size_t elementSize) { - Y_ASSERT(elementSize > 0); + static inline void Load(IInputStream* in, T& t, size_t elementSize) { + Y_ASSERT(elementSize > 0); TSerializer<T>::Load(in, t); } }; @@ -547,8 +547,8 @@ private: public: TVectorTakingIntoAccountThePodType(const TBlob& blob) { - SizeofOffsets = ReadUnaligned<ui64>(blob.Begin()); - Y_ASSERT(SizeofOffsets > 0); + SizeofOffsets = ReadUnaligned<ui64>(blob.Begin()); + Y_ASSERT(SizeofOffsets > 0); Offsets = reinterpret_cast<const ui64*>(blob.Begin() + sizeof(ui64)); Data = reinterpret_cast<const char*>(blob.Begin() + sizeof(ui64) + SizeofOffsets * sizeof(ui64)); } @@ -560,12 +560,12 @@ public: size_t GetLength(ui64 index) const { if (index + 1 >= SizeofOffsets) ythrow yexception() << "bad offset"; - return IntegerCast<size_t>(ReadUnaligned<ui64>(Offsets + index + 1) - ReadUnaligned<ui64>(Offsets + index)); + return IntegerCast<size_t>(ReadUnaligned<ui64>(Offsets + index + 1) - ReadUnaligned<ui64>(Offsets + index)); } void Get(ui64 index, T& t) const { const size_t len = GetLength(index); - TMemoryInput input(Data + ReadUnaligned<ui64>(Offsets + index), len); + TMemoryInput input(Data + ReadUnaligned<ui64>(Offsets + index), len); TSaveLoadVectorNonPodElement<T>::Load(&input, t, len); } @@ -603,7 +603,7 @@ public: return Offsets.size(); } - void Save(IOutputStream& out) const { + void Save(IOutputStream& out) const { ui64 sizeofOffsets = Offsets.size() + 1; out.Write(&sizeofOffsets, sizeof(sizeofOffsets)); out.Write(Offsets.data(), Offsets.size() * sizeof(Offsets[0])); @@ -656,12 +656,12 @@ struct TGeneralVectorG<TItem, true> { template <> struct TSaveLoadVectorNonPodElement<TString> { - static inline void Save(IOutputStream* out, const TString& s) { + static inline void Save(IOutputStream* out, const TString& s) { out->Write(s.data(), s.size() + 1); } static inline void Load(TMemoryInput* in, TString& s, size_t elementSize) { - Y_ASSERT(elementSize > 0 && in->Avail() >= elementSize); + Y_ASSERT(elementSize > 0 && in->Avail() >= elementSize); s.assign(in->Buf(), elementSize - 1); /// excluding 0 at the end } }; diff --git a/library/cpp/on_disk/chunks/chunks_ut.cpp b/library/cpp/on_disk/chunks/chunks_ut.cpp index f727647f7f2..2be71e91084 100644 --- a/library/cpp/on_disk/chunks/chunks_ut.cpp +++ b/library/cpp/on_disk/chunks/chunks_ut.cpp @@ -20,13 +20,13 @@ struct TPodStruct { template <> struct TSaveLoadVectorNonPodElement<TPodStruct> { typedef TPodStruct TItem; - static inline void Save(IOutputStream* out, const TItem& item) { + static inline void Save(IOutputStream* out, const TItem& item) { TSerializer<int>::Save(out, item.x); TSerializer<float>::Save(out, item.y); } - static inline void Load(IInputStream* in, TItem& item, size_t elementSize) { - Y_ASSERT(elementSize == sizeof(TItem)); + static inline void Load(IInputStream* in, TItem& item, size_t elementSize) { + Y_ASSERT(elementSize == sizeof(TItem)); TSerializer<int>::Load(in, item.x); TSerializer<float>::Load(in, item.y); } diff --git a/library/cpp/on_disk/chunks/reader.cpp b/library/cpp/on_disk/chunks/reader.cpp index 6e28cbf367d..c4ba350f11c 100644 --- a/library/cpp/on_disk/chunks/reader.cpp +++ b/library/cpp/on_disk/chunks/reader.cpp @@ -1,6 +1,6 @@ #include <util/generic/cast.h> #include <util/memory/blob.h> -#include <util/system/unaligned_mem.h> +#include <util/system/unaligned_mem.h> #include "reader.h" @@ -8,7 +8,7 @@ template <typename T> static inline void ReadAux(const char* data, T* aux, T count, TVector<const char*>* result) { result->resize(count); for (size_t i = 0; i < count; ++i) { - (*result)[i] = data + ReadUnaligned<T>(aux + i); + (*result)[i] = data + ReadUnaligned<T>(aux + i); } } @@ -17,7 +17,7 @@ TChunkedDataReader::TChunkedDataReader(const TBlob& blob) { const size_t size = blob.Size(); Y_ENSURE(size >= sizeof(ui32), "Empty file with chunks. "); - ui32 last = ReadUnaligned<ui32>((ui32*)(cdata + size) - 1); + ui32 last = ReadUnaligned<ui32>((ui32*)(cdata + size) - 1); if (last != 0) { // old version file ui32* aux = (ui32*)(cdata + size); @@ -32,10 +32,10 @@ TChunkedDataReader::TChunkedDataReader(const TBlob& blob) { Y_ENSURE(size >= 3 * sizeof(ui64), "Blob size must be >= 3 * sizeof(ui64). "); ui64* aux = (ui64*)(cdata + size); - Version = ReadUnaligned<ui64>(aux - 2); + Version = ReadUnaligned<ui64>(aux - 2); Y_ENSURE(Version > 0, "Invalid chunked array version. "); - ui64 count = ReadUnaligned<ui64>(aux - 3); + ui64 count = ReadUnaligned<ui64>(aux - 3); aux -= (count + 3); ReadAux<ui64>(cdata, aux, count, &Offsets); @@ -43,7 +43,7 @@ TChunkedDataReader::TChunkedDataReader(const TBlob& blob) { aux -= count; Lengths.resize(count); for (size_t i = 0; i < count; ++i) { - Lengths[i] = IntegerCast<size_t>(ReadUnaligned<ui64>(aux + i)); + Lengths[i] = IntegerCast<size_t>(ReadUnaligned<ui64>(aux + i)); } } diff --git a/library/cpp/on_disk/chunks/writer.cpp b/library/cpp/on_disk/chunks/writer.cpp index 6dc7397f09a..c605f1e79e3 100644 --- a/library/cpp/on_disk/chunks/writer.cpp +++ b/library/cpp/on_disk/chunks/writer.cpp @@ -8,7 +8,7 @@ static inline void WriteAux(IOutputStream* out, const TVector<ui64>& data) { /*************************** TBuffersWriter ***************************/ -TChunkedDataWriter::TChunkedDataWriter(IOutputStream& slave) +TChunkedDataWriter::TChunkedDataWriter(IOutputStream& slave) : Slave(slave) , Offset(0) { @@ -36,8 +36,8 @@ void TChunkedDataWriter::WriteFooter() { } size_t TChunkedDataWriter::GetCurrentBlockOffset() const { - Y_ASSERT(!Offsets.empty()); - Y_ASSERT(Offset >= Offsets.back()); + Y_ASSERT(!Offsets.empty()); + Y_ASSERT(Offset >= Offsets.back()); return Offset - Offsets.back(); } diff --git a/library/cpp/on_disk/chunks/writer.h b/library/cpp/on_disk/chunks/writer.h index ab14522bddd..aace0429492 100644 --- a/library/cpp/on_disk/chunks/writer.h +++ b/library/cpp/on_disk/chunks/writer.h @@ -4,11 +4,11 @@ #include <util/stream/output.h> template <typename T> -inline void WriteBin(IOutputStream* out, typename TTypeTraits<T>::TFuncParam t) { +inline void WriteBin(IOutputStream* out, typename TTypeTraits<T>::TFuncParam t) { out->Write(&t, sizeof(T)); } -class TChunkedDataWriter: public IOutputStream { +class TChunkedDataWriter: public IOutputStream { public: TChunkedDataWriter(IOutputStream& slave); ~TChunkedDataWriter() override; diff --git a/library/cpp/openssl/io/stream.cpp b/library/cpp/openssl/io/stream.cpp index 0b4be38c0e3..1eda85d00f5 100644 --- a/library/cpp/openssl/io/stream.cpp +++ b/library/cpp/openssl/io/stream.cpp @@ -122,7 +122,7 @@ namespace { }; struct TSslIO: public TSslInitOnDemand, public TOptions { - inline TSslIO(IInputStream* in, IOutputStream* out, const TOptions& opts) + inline TSslIO(IInputStream* in, IOutputStream* out, const TOptions& opts) : TOptions(opts) , Io(in, out) , Ctx(CreateClientContext()) @@ -240,18 +240,18 @@ namespace { } struct TOpenSslClientIO::TImpl: public TSslIO { - inline TImpl(IInputStream* in, IOutputStream* out, const TOptions& opts) + inline TImpl(IInputStream* in, IOutputStream* out, const TOptions& opts) : TSslIO(in, out, opts) { } }; -TOpenSslClientIO::TOpenSslClientIO(IInputStream* in, IOutputStream* out) +TOpenSslClientIO::TOpenSslClientIO(IInputStream* in, IOutputStream* out) : Impl_(new TImpl(in, out, TOptions())) { } -TOpenSslClientIO::TOpenSslClientIO(IInputStream* in, IOutputStream* out, const TOptions& options) +TOpenSslClientIO::TOpenSslClientIO(IInputStream* in, IOutputStream* out, const TOptions& options) : Impl_(new TImpl(in, out, options)) { } diff --git a/library/cpp/openssl/io/stream.h b/library/cpp/openssl/io/stream.h index 7bca8f80ef8..8131f8bd0d8 100644 --- a/library/cpp/openssl/io/stream.h +++ b/library/cpp/openssl/io/stream.h @@ -2,10 +2,10 @@ #include <util/generic/maybe.h> #include <util/generic/ptr.h> -#include <util/stream/input.h> -#include <util/stream/output.h> +#include <util/stream/input.h> +#include <util/stream/output.h> -class TOpenSslClientIO: public IInputStream, public IOutputStream { +class TOpenSslClientIO: public IInputStream, public IOutputStream { public: struct TOptions { struct TVerifyCert { @@ -25,8 +25,8 @@ public: // TODO - keys, cyphers, etc }; - TOpenSslClientIO(IInputStream* in, IOutputStream* out); - TOpenSslClientIO(IInputStream* in, IOutputStream* out, const TOptions& options); + TOpenSslClientIO(IInputStream* in, IOutputStream* out); + TOpenSslClientIO(IInputStream* in, IOutputStream* out, const TOptions& options); ~TOpenSslClientIO() override; private: diff --git a/library/cpp/packedtypes/longs.h b/library/cpp/packedtypes/longs.h index 084098d705e..91432bf007f 100644 --- a/library/cpp/packedtypes/longs.h +++ b/library/cpp/packedtypes/longs.h @@ -2,7 +2,7 @@ #include <util/system/defaults.h> // _BIDSCLASS _EXPCLASS #include <util/system/yassert.h> -#include <util/system/unaligned_mem.h> +#include <util/system/unaligned_mem.h> #define PUT_8(x, buf, shift) WriteUnaligned<ui8>((buf)++, (x) >> (shift)) #define GET_8_OR(x, buf, type, shift) (x) |= (type) * (buf)++ << (shift) @@ -310,9 +310,9 @@ template <typename T, typename C> inline const C* Unpack32(T& x, const C* src) { int pkLen = 0; const char* c = reinterpret_cast<const char*>(src); - Y_UNUSED(pkLen); + Y_UNUSED(pkLen); UNPACK_32(x, c, mem_traits, pkLen); - Y_ASSERT(pkLen); + Y_ASSERT(pkLen); return reinterpret_cast<const C*>(c); } @@ -320,28 +320,28 @@ template <typename T, typename C> inline const C* Unpack64(T& x, const C* src) { int pkLen = 0; const char* c = reinterpret_cast<const char*>(src); - Y_UNUSED(pkLen); + Y_UNUSED(pkLen); UNPACK_64(x, c, mem_traits, pkLen); - Y_ASSERT(pkLen); + Y_ASSERT(pkLen); return reinterpret_cast<const C*>(c); } template <typename T, typename C> inline C* Pack32(const T& x, C* dest) { int pkLen = 0; - Y_UNUSED(pkLen); + Y_UNUSED(pkLen); char* c = reinterpret_cast<char*>(dest); PACK_32(x, c, mem_traits, pkLen); - Y_ASSERT(pkLen); + Y_ASSERT(pkLen); return reinterpret_cast<C*>(c); } template <typename T, typename C> inline C* Pack64(const T& x, C* dest) { int pkLen = 0; - Y_UNUSED(pkLen); + Y_UNUSED(pkLen); char* c = reinterpret_cast<char*>(dest); PACK_64(x, c, mem_traits, pkLen); - Y_ASSERT(pkLen); + Y_ASSERT(pkLen); return reinterpret_cast<C*>(c); } diff --git a/library/cpp/packedtypes/longs_ut.cpp b/library/cpp/packedtypes/longs_ut.cpp index 8b06c934d2f..9ff51d21282 100644 --- a/library/cpp/packedtypes/longs_ut.cpp +++ b/library/cpp/packedtypes/longs_ut.cpp @@ -4,11 +4,11 @@ #include <library/cpp/digest/old_crc/crc.h> #include <util/string/util.h> -#include <util/stream/output.h> +#include <util/stream/output.h> #include <util/system/hi_lo.h> -Y_UNIT_TEST_SUITE(TLongsTest) { - Y_UNIT_TEST(TestLongs) { +Y_UNIT_TEST_SUITE(TLongsTest) { + Y_UNIT_TEST(TestLongs) { i16 x16 = 40; i64 x64 = 40; i64 y64; @@ -61,7 +61,7 @@ Y_UNIT_TEST_SUITE(TLongsTest) { } } - Y_UNIT_TEST(TestCornerCases) { + Y_UNIT_TEST(TestCornerCases) { TestCornerCasesImpl<i32>(31); TestCornerCasesImpl<i64>(63); } diff --git a/library/cpp/packedtypes/packed.h b/library/cpp/packedtypes/packed.h index 88cff26ae2a..b741fec77ee 100644 --- a/library/cpp/packedtypes/packed.h +++ b/library/cpp/packedtypes/packed.h @@ -2,34 +2,34 @@ #include <library/cpp/streams/zc_memory_input/zc_memory_input.h> -#include <util/stream/output.h> +#include <util/stream/output.h> #include <util/ysaveload.h> #include "longs.h" struct Stream_traits { template <typename T> - static T get(IInputStream& in) { + static T get(IInputStream& in) { T x; ::Load(&in, x); return x; } - static ui8 get_8(IInputStream& in) { + static ui8 get_8(IInputStream& in) { return get<ui8>(in); } - static ui16 get_16(IInputStream& in) { + static ui16 get_16(IInputStream& in) { return get<ui16>(in); } - static ui32 get_32(IInputStream& in) { + static ui32 get_32(IInputStream& in) { return get<ui32>(in); } - static void put_8(ui8 x, IOutputStream& out) { + static void put_8(ui8 x, IOutputStream& out) { ::Save(&out, x); } - static void put_16(ui16 x, IOutputStream& out) { + static void put_16(ui16 x, IOutputStream& out) { ::Save(&out, x); } - static void put_32(ui32 x, IOutputStream& out) { + static void put_32(ui32 x, IOutputStream& out) { ::Save(&out, x); } static int is_good(IInputStream& /*in*/) { diff --git a/library/cpp/packedtypes/packed_ut.cpp b/library/cpp/packedtypes/packed_ut.cpp index 70a22cf9c31..5d0d11b4278 100644 --- a/library/cpp/packedtypes/packed_ut.cpp +++ b/library/cpp/packedtypes/packed_ut.cpp @@ -14,7 +14,7 @@ static ui64 gSeed = 42; template<typename T> static T PseudoRandom(T max = Max<T>()) { - Y_ASSERT(max != 0); + Y_ASSERT(max != 0); // stupid and non-threadsafe, but very predictable chaos generator gSeed += 1; gSeed *= 419; @@ -24,7 +24,7 @@ static T PseudoRandom(T max = Max<T>()) { #endif } -Y_UNIT_TEST_SUITE(TPackedTest) { +Y_UNIT_TEST_SUITE(TPackedTest) { void TestPackUi32Sub(ui32 v, const TVector<char>& p) { TBufferOutput out; PackUI32(out, v); @@ -47,7 +47,7 @@ Y_UNIT_TEST_SUITE(TPackedTest) { } } - Y_UNIT_TEST(TestPackUi32) { + Y_UNIT_TEST(TestPackUi32) { ui32 v; TVector<char> pv; @@ -89,7 +89,7 @@ Y_UNIT_TEST_SUITE(TPackedTest) { } #if 0 - Y_UNIT_TEST(ReadWrite32) { + Y_UNIT_TEST(ReadWrite32) { TBuffer buffer(65536); char* writePtr = buffer.Data(); @@ -108,7 +108,7 @@ Y_UNIT_TEST_SUITE(TPackedTest) { } } - Y_UNIT_TEST(ReadWrite64) { + Y_UNIT_TEST(ReadWrite64) { TBuffer buffer(65536); char* writePtr = buffer.Data(); diff --git a/library/cpp/packedtypes/zigzag_ut.cpp b/library/cpp/packedtypes/zigzag_ut.cpp index 13b78b7481d..f7fd1f57106 100644 --- a/library/cpp/packedtypes/zigzag_ut.cpp +++ b/library/cpp/packedtypes/zigzag_ut.cpp @@ -2,7 +2,7 @@ #include <library/cpp/testing/unittest/registar.h> -Y_UNIT_TEST_SUITE(TZigZagTest) { +Y_UNIT_TEST_SUITE(TZigZagTest) { template <typename T> void TestEncodeDecode(T value) { auto encoded = ZigZagEncode(value); @@ -30,7 +30,7 @@ Y_UNIT_TEST_SUITE(TZigZagTest) { TestEncodeDecode((TSignedInt)-123); } - Y_UNIT_TEST(TestSigned) { + Y_UNIT_TEST(TestSigned) { TestImpl<i16>(); TestImpl<i32>(); TestImpl<i64>(); diff --git a/library/cpp/packers/packers.h b/library/cpp/packers/packers.h index 1bde1b59aaf..2e06a0d833c 100644 --- a/library/cpp/packers/packers.h +++ b/library/cpp/packers/packers.h @@ -5,7 +5,7 @@ #include <util/generic/set.h> #include <util/generic/list.h> #include <util/generic/vector.h> -#include <util/generic/bitops.h> +#include <util/generic/bitops.h> #include <array> // Data serialization strategy class. @@ -37,11 +37,11 @@ public: memcpy(&t, p, sizeof(T)); } void PackLeaf(char* buffer, const T& data, size_t computedSize) const { - Y_ASSERT(computedSize == sizeof(data)); + Y_ASSERT(computedSize == sizeof(data)); memcpy(buffer, &data, sizeof(T)); } size_t MeasureLeaf(const T& data) const { - Y_UNUSED(data); + Y_UNUSED(data); return sizeof(T); } size_t SkipLeaf(const char*) const { @@ -211,14 +211,14 @@ namespace NPackers { TFloat FromUInt(TUInt u) const { THelper h; - h.U = ReverseBytes(u); + h.U = ReverseBytes(u); return h.F; } TUInt ToUInt(TFloat f) const { THelper h; h.F = f; - return ReverseBytes(h.U); + return ReverseBytes(h.U); } public: @@ -416,7 +416,7 @@ namespace NPackers { TElementPacker().PackLeaf(buffer + curSize, *p, sizeChange); curSize += sizeChange; } - Y_ASSERT(curSize == size); + Y_ASSERT(curSize == size); } template <class C, class EP> @@ -430,7 +430,7 @@ namespace NPackers { // e.g. when curSize is 127 and stays in one byte, but curSize + 1 requires two bytes. extraSize = TIntegralPacker<size_t>().MeasureLeaf(curSize + extraSize); - Y_ASSERT(extraSize == TIntegralPacker<size_t>().MeasureLeaf(curSize + extraSize)); + Y_ASSERT(extraSize == TIntegralPacker<size_t>().MeasureLeaf(curSize + extraSize)); return curSize + extraSize; } @@ -469,7 +469,7 @@ namespace NPackers { TPacker1().PackLeaf(buffer, data.first, size1); size_t size2 = TPacker2().MeasureLeaf(data.second); TPacker2().PackLeaf(buffer + size1, data.second, size2); - Y_ASSERT(size == size1 + size2); + Y_ASSERT(size == size1 + size2); } template <class T1, class T2, class TPacker1, class TPacker2> @@ -600,12 +600,12 @@ namespace NPackers { class TPacker<TSet<T>>: public TContainerPacker<TSet<T>> { }; - template <class T1, class T2> + template <class T1, class T2> class TPacker<std::pair<T1, T2>>: public TPairPacker<T1, T2> { }; - template <class T, size_t N> + template <class T, size_t N> class TPacker<std::array<T, N>>: public TArrayPacker<std::array<T, N>> { - }; + }; } diff --git a/library/cpp/packers/ut/packers_ut.cpp b/library/cpp/packers/ut/packers_ut.cpp index 18ce2150d1e..9318782f801 100644 --- a/library/cpp/packers/ut/packers_ut.cpp +++ b/library/cpp/packers/ut/packers_ut.cpp @@ -1,6 +1,6 @@ #include <library/cpp/testing/unittest/registar.h> -#include <util/stream/output.h> +#include <util/stream/output.h> #include <utility> #include <util/charset/wide.h> @@ -75,7 +75,7 @@ void TPackersTest::TestPackers() { TestPacker<TString, NPackers::TPacker<TString>>(test, Y_ARRAY_SIZE(test)); - for (size_t i = 0; i != Y_ARRAY_SIZE(test); ++i) { + for (size_t i = 0; i != Y_ARRAY_SIZE(test); ++i) { TestPacker<TUtf16String, NPackers::TPacker<TUtf16String>>(UTF8ToWide(test[i])); } } diff --git a/library/cpp/packers/ut/proto_packer_ut.cpp b/library/cpp/packers/ut/proto_packer_ut.cpp index e4151ba68c8..a89d6a74a01 100644 --- a/library/cpp/packers/ut/proto_packer_ut.cpp +++ b/library/cpp/packers/ut/proto_packer_ut.cpp @@ -45,7 +45,7 @@ bool operator==(const TTestMessage& lhs, const TTestMessage& rhs) { return true; } -Y_UNIT_TEST_SUITE(ProtoPackerTestSuite) { +Y_UNIT_TEST_SUITE(ProtoPackerTestSuite) { TProtoMessagePacker<TTestMessage> Packer; TString Buffer; @@ -61,20 +61,20 @@ Y_UNIT_TEST_SUITE(ProtoPackerTestSuite) { UNIT_ASSERT_EQUAL(msg, checkMsg); } - Y_UNIT_TEST(TestPackUnpackOnlyRequired) { + Y_UNIT_TEST(TestPackUnpackOnlyRequired) { TTestMessage msg; FillRequiredFields(msg); DoPackUnpackTest(msg); } - Y_UNIT_TEST(TestPackUnpackRequiredAndOptional) { + Y_UNIT_TEST(TestPackUnpackRequiredAndOptional) { TTestMessage msg; FillRequiredFields(msg); FillOptionalFields(msg); DoPackUnpackTest(msg); } - Y_UNIT_TEST(TestPackUnpackAll) { + Y_UNIT_TEST(TestPackUnpackAll) { TTestMessage msg; FillRequiredFields(msg); FillOptionalFields(msg); @@ -82,7 +82,7 @@ Y_UNIT_TEST_SUITE(ProtoPackerTestSuite) { DoPackUnpackTest(msg); } - Y_UNIT_TEST(TestSkipLeaf) { + Y_UNIT_TEST(TestSkipLeaf) { TTestMessage msgFirst; FillRequiredFields(msgFirst); TTestMessage msgSecond; diff --git a/library/cpp/packers/ut/region_packer_ut.cpp b/library/cpp/packers/ut/region_packer_ut.cpp index 0cb08ccf652..1d71d40941f 100644 --- a/library/cpp/packers/ut/region_packer_ut.cpp +++ b/library/cpp/packers/ut/region_packer_ut.cpp @@ -9,7 +9,7 @@ void TestPacker() { TRegionPacker<TValue> p; using TValues = TArrayRef<TValue>; - TValues valueRegion = TValues(values, Y_ARRAY_SIZE(values)); + TValues valueRegion = TValues(values, Y_ARRAY_SIZE(values)); size_t sz = p.MeasureLeaf(valueRegion); UNIT_ASSERT_VALUES_EQUAL(sz, 1 + sizeof(values)); @@ -23,8 +23,8 @@ void TestPacker() { UNIT_ASSERT_EQUAL(0, memcmp(values, valueRegion.data(), sizeof(values))); } -Y_UNIT_TEST_SUITE(RegionPacker) { - Y_UNIT_TEST(Test0) { +Y_UNIT_TEST_SUITE(RegionPacker) { + Y_UNIT_TEST(Test0) { TestPacker<char>(); TestPacker<signed char>(); TestPacker<unsigned char>(); diff --git a/library/cpp/pop_count/popcount.h b/library/cpp/pop_count/popcount.h index 3d67737ed25..e22b7c0ccf1 100644 --- a/library/cpp/pop_count/popcount.h +++ b/library/cpp/pop_count/popcount.h @@ -99,7 +99,7 @@ static inline ui32 PopCountImpl(ui64 n) { template <class T> static inline ui32 PopCount(T n) { - using TCvt = TFixedWidthUnsignedInt<T>; + using TCvt = TFixedWidthUnsignedInt<T>; return PopCountImpl((TCvt)n); } diff --git a/library/cpp/pop_count/popcount_ut.cpp b/library/cpp/pop_count/popcount_ut.cpp index 5cd6605411f..0e0ad6dbccd 100644 --- a/library/cpp/pop_count/popcount_ut.cpp +++ b/library/cpp/pop_count/popcount_ut.cpp @@ -4,7 +4,7 @@ #include <util/random/random.h> -Y_UNIT_TEST_SUITE(TestPopCount) { +Y_UNIT_TEST_SUITE(TestPopCount) { template <class T> static inline ui32 SlowPopCount(T t) { ui32 ret = 0; @@ -29,23 +29,23 @@ Y_UNIT_TEST_SUITE(TestPopCount) { } } - Y_UNIT_TEST(Test8) { + Y_UNIT_TEST(Test8) { Test<ui8>(); } - Y_UNIT_TEST(Test16) { + Y_UNIT_TEST(Test16) { Test<ui16>(); } - Y_UNIT_TEST(Test32) { + Y_UNIT_TEST(Test32) { Test<ui32>(); } - Y_UNIT_TEST(Test64) { + Y_UNIT_TEST(Test64) { Test<ui64>(); } - Y_UNIT_TEST(TestPopCount) { + Y_UNIT_TEST(TestPopCount) { UNIT_ASSERT_VALUES_EQUAL(PopCount(0), 0); UNIT_ASSERT_VALUES_EQUAL(PopCount(1), 1); UNIT_ASSERT_VALUES_EQUAL(PopCount(1 << 10), 1); diff --git a/library/cpp/protobuf/json/json2proto.cpp b/library/cpp/protobuf/json/json2proto.cpp index 640c10f5a51..b70c39d3b5f 100644 --- a/library/cpp/protobuf/json/json2proto.cpp +++ b/library/cpp/protobuf/json/json2proto.cpp @@ -72,7 +72,7 @@ static TString GetFieldName(const google::protobuf::FieldDescriptor& field, NProtobufJson::ToSnakeCaseDense(&name); break; default: - Y_VERIFY_DEBUG(false, "Unknown FieldNameMode."); + Y_VERIFY_DEBUG(false, "Unknown FieldNameMode."); } return name; } @@ -85,7 +85,7 @@ JsonString2Field(const NJson::TJsonValue& json, using namespace google::protobuf; const Reflection* reflection = proto.GetReflection(); - Y_ASSERT(!!reflection); + Y_ASSERT(!!reflection); if (!json.IsString() && !config.CastRobust) { ythrow yexception() << "Invalid type of JSON field '" << field.name() << "': " @@ -94,7 +94,7 @@ JsonString2Field(const NJson::TJsonValue& json, } TString value = json.GetStringRobust(); for (size_t i = 0, endI = config.StringTransforms.size(); i < endI; ++i) { - Y_ASSERT(!!config.StringTransforms[i]); + Y_ASSERT(!!config.StringTransforms[i]); if (!!config.StringTransforms[i]) { if (field.type() == google::protobuf::FieldDescriptor::TYPE_BYTES) { config.StringTransforms[i]->TransformBytes(value); @@ -130,10 +130,10 @@ JsonEnum2Field(const NJson::TJsonValue& json, using namespace google::protobuf; const Reflection* reflection = proto.GetReflection(); - Y_ASSERT(!!reflection); + Y_ASSERT(!!reflection); const EnumDescriptor* enumField = field.enum_type(); - Y_ASSERT(!!enumField); + Y_ASSERT(!!enumField); /// @todo configure name/numerical value const EnumValueDescriptor* enumFieldValue = nullptr; @@ -343,7 +343,7 @@ Json2RepeatedField(const NJson::TJsonValue& json, } const Reflection* reflection = proto.GetReflection(); - Y_ASSERT(!!reflection); + Y_ASSERT(!!reflection); if (isMap) { const THashMap<TString, NJson::TJsonValue> jsonMap = fieldJson.GetMap(); diff --git a/library/cpp/protobuf/json/json_output_create.h b/library/cpp/protobuf/json/json_output_create.h index ad3889f5e99..42005bad28b 100644 --- a/library/cpp/protobuf/json/json_output_create.h +++ b/library/cpp/protobuf/json/json_output_create.h @@ -9,7 +9,7 @@ namespace NJson { struct TJsonWriterConfig; } -class IOutputStream; +class IOutputStream; class TStringStream; namespace NProtobufJson { diff --git a/library/cpp/protobuf/json/proto2json.h b/library/cpp/protobuf/json/proto2json.h index 89a1781a40d..2f7277be084 100644 --- a/library/cpp/protobuf/json/proto2json.h +++ b/library/cpp/protobuf/json/proto2json.h @@ -19,7 +19,7 @@ namespace NJson { class TJsonWriter; } -class IOutputStream; +class IOutputStream; class TStringStream; namespace NProtobufJson { diff --git a/library/cpp/protobuf/json/ut/filter_ut.cpp b/library/cpp/protobuf/json/ut/filter_ut.cpp index 95c227666fb..daa2d98af4c 100644 --- a/library/cpp/protobuf/json/ut/filter_ut.cpp +++ b/library/cpp/protobuf/json/ut/filter_ut.cpp @@ -19,8 +19,8 @@ static NProtobufJsonUt::TFilterTest GetTestMsg() { return msg; } -Y_UNIT_TEST_SUITE(TProto2JsonFilterTest){ - Y_UNIT_TEST(TestFilterPrinter){ +Y_UNIT_TEST_SUITE(TProto2JsonFilterTest){ + Y_UNIT_TEST(TestFilterPrinter){ NProtobufJsonUt::TFilterTest msg = GetTestMsg(); { TString expected = R"({"OptFiltered":"1","NotFiltered":"23","RepFiltered":[45,67],)" @@ -61,7 +61,7 @@ Y_UNIT_TEST_SUITE(TProto2JsonFilterTest){ } } -Y_UNIT_TEST(NoUnnecessaryCopyFunctor) { +Y_UNIT_TEST(NoUnnecessaryCopyFunctor) { size_t CopyCount = 0; struct TFunctorMock { TFunctorMock(size_t* copyCount) diff --git a/library/cpp/protobuf/json/ut/inline_ut.cpp b/library/cpp/protobuf/json/ut/inline_ut.cpp index c29ad32e7d6..548b6c29608 100644 --- a/library/cpp/protobuf/json/ut/inline_ut.cpp +++ b/library/cpp/protobuf/json/ut/inline_ut.cpp @@ -21,8 +21,8 @@ static NProtobufJsonUt::TInlineTest GetTestMsg() { return msg; } -Y_UNIT_TEST_SUITE(TProto2JsonInlineTest){ - Y_UNIT_TEST(TestNormalPrint){ +Y_UNIT_TEST_SUITE(TProto2JsonInlineTest){ + Y_UNIT_TEST(TestNormalPrint){ NProtobufJsonUt::TInlineTest msg = GetTestMsg(); // normal print should output these fields as just string values TString expRaw = R"({"OptJson":"{\"a\":1,\"b\":\"000\"}","NotJson":"12{}34","RepJson":["{}","[1,2]"],)" @@ -35,7 +35,7 @@ myRaw = PrintInlined(msg, [](const NProtoBuf::Message&, const NProtoBuf::FieldDe UNIT_ASSERT_STRINGS_EQUAL(myRaw, expRaw); // result is the same } -Y_UNIT_TEST(TestInliningPrinter) { +Y_UNIT_TEST(TestInliningPrinter) { NProtobufJsonUt::TInlineTest msg = GetTestMsg(); // inlined print should output these fields as inlined json sub-objects TString expInlined = R"({"OptJson":{"a":1,"b":"000"},"NotJson":"12{}34","RepJson":[{},[1,2]],)" @@ -54,7 +54,7 @@ Y_UNIT_TEST(TestInliningPrinter) { } } -Y_UNIT_TEST(TestNoValues) { +Y_UNIT_TEST(TestNoValues) { // no values - no printing NProtobufJsonUt::TInlineTest msg; msg.MutableInner()->AddNumber(100); @@ -66,7 +66,7 @@ Y_UNIT_TEST(TestNoValues) { UNIT_ASSERT_STRINGS_EQUAL(myInlined, expInlined); } -Y_UNIT_TEST(TestMissingKeyModeNull) { +Y_UNIT_TEST(TestMissingKeyModeNull) { NProtobufJsonUt::TInlineTest msg; msg.MutableInner()->AddNumber(100); msg.MutableInner()->AddNumber(200); @@ -79,7 +79,7 @@ Y_UNIT_TEST(TestMissingKeyModeNull) { UNIT_ASSERT_STRINGS_EQUAL(myInlined, expInlined); } -Y_UNIT_TEST(TestMissingKeyModeDefault) { +Y_UNIT_TEST(TestMissingKeyModeDefault) { NProtobufJsonUt::TInlineTestDefaultValues msg; TString expInlined = R"({"OptJson":{"default":1},"Number":0,"RepJson":[],"Inner":{"OptJson":{"default":2}}})"; @@ -90,7 +90,7 @@ Y_UNIT_TEST(TestMissingKeyModeDefault) { UNIT_ASSERT_STRINGS_EQUAL(myInlined, expInlined); } -Y_UNIT_TEST(NoUnnecessaryCopyFunctor) { +Y_UNIT_TEST(NoUnnecessaryCopyFunctor) { size_t CopyCount = 0; struct TFunctorMock { TFunctorMock(size_t* copyCount) diff --git a/library/cpp/protobuf/json/ut/json2proto_ut.cpp b/library/cpp/protobuf/json/ut/json2proto_ut.cpp index 0dfe57bc7a2..271db47dc4e 100644 --- a/library/cpp/protobuf/json/ut/json2proto_ut.cpp +++ b/library/cpp/protobuf/json/ut/json2proto_ut.cpp @@ -70,8 +70,8 @@ namespace { } } -Y_UNIT_TEST_SUITE(TJson2ProtoTest) { - Y_UNIT_TEST(TestFlatOptional){ +Y_UNIT_TEST_SUITE(TJson2ProtoTest) { + Y_UNIT_TEST(TestFlatOptional){ {const NJson::TJsonValue& json = CreateFlatJson(); TFlatOptional proto; Json2Proto(json, proto); @@ -96,7 +96,7 @@ Y_UNIT_TEST_SUITE(TJson2ProtoTest) { #undef DEFINE_FIELD } // TestFlatOptional -Y_UNIT_TEST(TestFlatRequired){ +Y_UNIT_TEST(TestFlatRequired){ {const NJson::TJsonValue& json = CreateFlatJson(); TFlatRequired proto; Json2Proto(json, proto); @@ -118,7 +118,7 @@ UNIT_ASSERT_PROTOS_EQUAL(proto, modelProto); #undef DEFINE_FIELD } // TestFlatRequired -Y_UNIT_TEST(TestNameGenerator) { +Y_UNIT_TEST(TestNameGenerator) { TJson2ProtoConfig cfg; cfg.SetNameGenerator([](const NProtoBuf::FieldDescriptor&) { return "42"; }); @@ -131,7 +131,7 @@ Y_UNIT_TEST(TestNameGenerator) { UNIT_ASSERT_PROTOS_EQUAL(expected, proto); } -Y_UNIT_TEST(TestFlatNoCheckRequired) { +Y_UNIT_TEST(TestFlatNoCheckRequired) { { const NJson::TJsonValue& json = CreateFlatJson(); TFlatRequired proto; @@ -157,7 +157,7 @@ Y_UNIT_TEST(TestFlatNoCheckRequired) { #undef DEFINE_FIELD } // TestFlatNoCheckRequired -Y_UNIT_TEST(TestFlatRepeated){ +Y_UNIT_TEST(TestFlatRepeated){ {const NJson::TJsonValue& json = CreateRepeatedFlatJson(); TFlatRepeated proto; Json2Proto(json, proto); @@ -182,7 +182,7 @@ UNIT_ASSERT_PROTOS_EQUAL(proto, modelProto); #undef DEFINE_REPEATED_FIELD } // TestFlatRepeated -Y_UNIT_TEST(TestCompositeOptional){ +Y_UNIT_TEST(TestCompositeOptional){ {const NJson::TJsonValue& json = CreateCompositeJson(); TCompositeOptional proto; Json2Proto(json, proto); @@ -207,7 +207,7 @@ UNIT_ASSERT_PROTOS_EQUAL(proto, modelProto); #undef DEFINE_FIELD } // TestCompositeOptional -Y_UNIT_TEST(TestCompositeOptionalStringBuf){ +Y_UNIT_TEST(TestCompositeOptionalStringBuf){ {NJson::TJsonValue json = CreateCompositeJson(); json["Part"]["Double"] = 42.5; TCompositeOptional proto; @@ -240,7 +240,7 @@ UNIT_ASSERT_PROTOS_EQUAL(proto, modelProto); #undef DEFINE_FIELD } // TestCompositeOptionalStringBuf -Y_UNIT_TEST(TestCompositeRequired) { +Y_UNIT_TEST(TestCompositeRequired) { { const NJson::TJsonValue& json = CreateCompositeJson(); TCompositeRequired proto; @@ -257,7 +257,7 @@ Y_UNIT_TEST(TestCompositeRequired) { } } // TestCompositeRequired -Y_UNIT_TEST(TestCompositeRepeated) { +Y_UNIT_TEST(TestCompositeRepeated) { { NJson::TJsonValue json; NJson::TJsonValue array; @@ -302,7 +302,7 @@ Y_UNIT_TEST(TestCompositeRepeated) { } } // TestCompositeRepeated -Y_UNIT_TEST(TestInvalidEnum) { +Y_UNIT_TEST(TestInvalidEnum) { { NJson::TJsonValue json; json.InsertValue("Enum", "E_100"); @@ -318,7 +318,7 @@ Y_UNIT_TEST(TestInvalidEnum) { } } -Y_UNIT_TEST(TestFieldNameMode) { +Y_UNIT_TEST(TestFieldNameMode) { // Original case 1 { TString modelStr(R"_({"String":"value"})_"); @@ -514,7 +514,7 @@ public: } }; -Y_UNIT_TEST(TestInvalidJson) { +Y_UNIT_TEST(TestInvalidJson) { NJson::TJsonValue val{"bad value"}; TFlatOptional proto; UNIT_ASSERT_EXCEPTION(Json2Proto(val, proto), yexception); @@ -527,7 +527,7 @@ Y_UNIT_TEST(TestInvalidRepeatedFieldWithMapAsObject) { UNIT_ASSERT_EXCEPTION(Json2Proto(TStringBuf(R"({"Part":{"Boo":{}}})"), proto, config), yexception); } -Y_UNIT_TEST(TestStringTransforms) { +Y_UNIT_TEST(TestStringTransforms) { // Check that strings and bytes are transformed { TString modelStr(R"_({"String":"value_str", "Bytes": "value_bytes"})_"); @@ -585,7 +585,7 @@ Y_UNIT_TEST(TestStringTransforms) { } } // TestStringTransforms -Y_UNIT_TEST(TestCastFromString) { +Y_UNIT_TEST(TestCastFromString) { // single fields { NJson::TJsonValue json; @@ -634,7 +634,7 @@ Y_UNIT_TEST(TestCastFromString) { } } // TestCastFromString -Y_UNIT_TEST(TestMap) { +Y_UNIT_TEST(TestMap) { TMapType modelProto; auto& items = *modelProto.MutableItems(); @@ -651,7 +651,7 @@ Y_UNIT_TEST(TestMap) { UNIT_ASSERT_PROTOS_EQUAL(proto, modelProto); } // TestMap -Y_UNIT_TEST(TestCastRobust) { +Y_UNIT_TEST(TestCastRobust) { NJson::TJsonValue json; json["I32"] = "5"; json["Bool"] = 1; @@ -741,7 +741,7 @@ Y_UNIT_TEST(TestValueVectorizer) { } } -Y_UNIT_TEST(TestMapAsObject) { +Y_UNIT_TEST(TestMapAsObject) { TMapType modelProto; auto& items = *modelProto.MutableItems(); @@ -759,7 +759,7 @@ Y_UNIT_TEST(TestMapAsObject) { UNIT_ASSERT_PROTOS_EQUAL(proto, modelProto); } // TestMapAsObject -Y_UNIT_TEST(TestComplexMapAsObject_I32) { +Y_UNIT_TEST(TestComplexMapAsObject_I32) { TestComplexMapAsObject( [](TComplexMapType& proto) { auto& items = *proto.MutableI32(); @@ -770,7 +770,7 @@ Y_UNIT_TEST(TestComplexMapAsObject_I32) { R"_({"I32":{"1":1,"-2":-2,"3":3}})_"); } // TestComplexMapAsObject_I32 -Y_UNIT_TEST(TestComplexMapAsObject_I64) { +Y_UNIT_TEST(TestComplexMapAsObject_I64) { TestComplexMapAsObject( [](TComplexMapType& proto) { auto& items = *proto.MutableI64(); @@ -781,7 +781,7 @@ Y_UNIT_TEST(TestComplexMapAsObject_I64) { R"_({"I64":{"2147483649":2147483649,"-2147483650":-2147483650,"2147483651":2147483651}})_"); } // TestComplexMapAsObject_I64 -Y_UNIT_TEST(TestComplexMapAsObject_UI32) { +Y_UNIT_TEST(TestComplexMapAsObject_UI32) { TestComplexMapAsObject( [](TComplexMapType& proto) { auto& items = *proto.MutableUI32(); @@ -792,7 +792,7 @@ Y_UNIT_TEST(TestComplexMapAsObject_UI32) { R"_({"UI32":{"1073741825":1073741825,"1073741826":1073741826,"1073741827":1073741827}})_"); } // TestComplexMapAsObject_UI32 -Y_UNIT_TEST(TestComplexMapAsObject_UI64) { +Y_UNIT_TEST(TestComplexMapAsObject_UI64) { TestComplexMapAsObject( [](TComplexMapType& proto) { auto& items = *proto.MutableUI64(); @@ -803,7 +803,7 @@ Y_UNIT_TEST(TestComplexMapAsObject_UI64) { R"_({"UI64":{"9223372036854775809":9223372036854775809,"9223372036854775810":9223372036854775810,"9223372036854775811":9223372036854775811}})_"); } // TestComplexMapAsObject_UI64 -Y_UNIT_TEST(TestComplexMapAsObject_SI32) { +Y_UNIT_TEST(TestComplexMapAsObject_SI32) { TestComplexMapAsObject( [](TComplexMapType& proto) { auto& items = *proto.MutableSI32(); @@ -814,7 +814,7 @@ Y_UNIT_TEST(TestComplexMapAsObject_SI32) { R"_({"SI32":{"1":1,"-2":-2,"3":3}})_"); } // TestComplexMapAsObject_SI32 -Y_UNIT_TEST(TestComplexMapAsObject_SI64) { +Y_UNIT_TEST(TestComplexMapAsObject_SI64) { TestComplexMapAsObject( [](TComplexMapType& proto) { auto& items = *proto.MutableSI64(); @@ -825,7 +825,7 @@ Y_UNIT_TEST(TestComplexMapAsObject_SI64) { R"_({"SI64":{"2147483649":2147483649,"-2147483650":-2147483650,"2147483651":2147483651}})_"); } // TestComplexMapAsObject_SI64 -Y_UNIT_TEST(TestComplexMapAsObject_FI32) { +Y_UNIT_TEST(TestComplexMapAsObject_FI32) { TestComplexMapAsObject( [](TComplexMapType& proto) { auto& items = *proto.MutableFI32(); @@ -836,7 +836,7 @@ Y_UNIT_TEST(TestComplexMapAsObject_FI32) { R"_({"FI32":{"1073741825":1073741825,"1073741826":1073741826,"1073741827":1073741827}})_"); } // TestComplexMapAsObject_FI32 -Y_UNIT_TEST(TestComplexMapAsObject_FI64) { +Y_UNIT_TEST(TestComplexMapAsObject_FI64) { TestComplexMapAsObject( [](TComplexMapType& proto) { auto& items = *proto.MutableFI64(); @@ -847,7 +847,7 @@ Y_UNIT_TEST(TestComplexMapAsObject_FI64) { R"_({"FI64":{"9223372036854775809":9223372036854775809,"9223372036854775810":9223372036854775810,"9223372036854775811":9223372036854775811}})_"); } // TestComplexMapAsObject_FI64 -Y_UNIT_TEST(TestComplexMapAsObject_SFI32) { +Y_UNIT_TEST(TestComplexMapAsObject_SFI32) { TestComplexMapAsObject( [](TComplexMapType& proto) { auto& items = *proto.MutableSFI32(); @@ -858,7 +858,7 @@ Y_UNIT_TEST(TestComplexMapAsObject_SFI32) { R"_({"SFI32":{"1":1,"-2":-2,"3":3}})_"); } // TestComplexMapAsObject_SFI32 -Y_UNIT_TEST(TestComplexMapAsObject_SFI64) { +Y_UNIT_TEST(TestComplexMapAsObject_SFI64) { TestComplexMapAsObject( [](TComplexMapType& proto) { auto& items = *proto.MutableSFI64(); @@ -869,7 +869,7 @@ Y_UNIT_TEST(TestComplexMapAsObject_SFI64) { R"_({"SFI64":{"2147483649":2147483649,"-2147483650":-2147483650,"2147483651":2147483651}})_"); } // TestComplexMapAsObject_SFI64 -Y_UNIT_TEST(TestComplexMapAsObject_Bool) { +Y_UNIT_TEST(TestComplexMapAsObject_Bool) { TestComplexMapAsObject( [](TComplexMapType& proto) { auto& items = *proto.MutableBool(); @@ -879,7 +879,7 @@ Y_UNIT_TEST(TestComplexMapAsObject_Bool) { R"_({"Bool":{"true":true,"false":false}})_"); } // TestComplexMapAsObject_Bool -Y_UNIT_TEST(TestComplexMapAsObject_String) { +Y_UNIT_TEST(TestComplexMapAsObject_String) { TestComplexMapAsObject( [](TComplexMapType& proto) { auto& items = *proto.MutableString(); @@ -891,7 +891,7 @@ Y_UNIT_TEST(TestComplexMapAsObject_String) { R"_({"String":{"key1":"value1","key2":"value2","key3":"value3","":"value4"}})_"); } // TestComplexMapAsObject_String -Y_UNIT_TEST(TestComplexMapAsObject_Enum) { +Y_UNIT_TEST(TestComplexMapAsObject_Enum) { TestComplexMapAsObject( [](TComplexMapType& proto) { auto& items = *proto.MutableEnum(); @@ -943,7 +943,7 @@ Y_UNIT_TEST(TestComplexMapAsObject_EnumStringSnakeCaseInsensitive) { ); } // TestComplexMapAsObject_EnumStringCaseInsensetive -Y_UNIT_TEST(TestComplexMapAsObject_Float) { +Y_UNIT_TEST(TestComplexMapAsObject_Float) { TestComplexMapAsObject( [](TComplexMapType& proto) { auto& items = *proto.MutableFloat(); @@ -954,7 +954,7 @@ Y_UNIT_TEST(TestComplexMapAsObject_Float) { R"_({"Float":{"key1":0.1,"key2":0.2,"key3":0.3}})_"); } // TestComplexMapAsObject_Float -Y_UNIT_TEST(TestComplexMapAsObject_Double) { +Y_UNIT_TEST(TestComplexMapAsObject_Double) { TestComplexMapAsObject( [](TComplexMapType& proto) { auto& items = *proto.MutableDouble(); @@ -965,7 +965,7 @@ Y_UNIT_TEST(TestComplexMapAsObject_Double) { R"_({"Double":{"key1":0.1,"key2":0.2,"key3":0.3}})_"); } // TestComplexMapAsObject_Double -Y_UNIT_TEST(TestComplexMapAsObject_Nested) { +Y_UNIT_TEST(TestComplexMapAsObject_Nested) { TestComplexMapAsObject( [](TComplexMapType& proto) { TComplexMapType inner; @@ -979,7 +979,7 @@ Y_UNIT_TEST(TestComplexMapAsObject_Nested) { R"_({"Nested":{"key1":{"String":{"key":"value"}},"key2":{"String":{"key":"value"}},"key3":{"String":{"key":"value"}}}})_"); } // TestComplexMapAsObject_Nested -Y_UNIT_TEST(TestMapAsObjectConfigNotSet) { +Y_UNIT_TEST(TestMapAsObjectConfigNotSet) { TString modelStr(R"_({"Items":{"key":"value"}})_"); TJson2ProtoConfig config; diff --git a/library/cpp/protobuf/json/ut/proto2json_ut.cpp b/library/cpp/protobuf/json/ut/proto2json_ut.cpp index 07e52d7f2f5..0a56cc2a8c5 100644 --- a/library/cpp/protobuf/json/ut/proto2json_ut.cpp +++ b/library/cpp/protobuf/json/ut/proto2json_ut.cpp @@ -25,8 +25,8 @@ using namespace NProtobufJson; using namespace NProtobufJsonTest; -Y_UNIT_TEST_SUITE(TProto2JsonFlatTest) { - Y_UNIT_TEST(TestFlatDefault) { +Y_UNIT_TEST_SUITE(TProto2JsonFlatTest) { + Y_UNIT_TEST(TestFlatDefault) { using namespace ::google::protobuf; TFlatDefault proto; NJson::TJsonValue json; @@ -74,7 +74,7 @@ Y_UNIT_TEST_SUITE(TProto2JsonFlatTest) { #undef DEFINE_FIELD } - Y_UNIT_TEST(TestNameGenerator) { + Y_UNIT_TEST(TestNameGenerator) { TNameGeneratorType proto; proto.SetField(42); @@ -87,7 +87,7 @@ Y_UNIT_TEST_SUITE(TProto2JsonFlatTest) { UNIT_ASSERT_STRINGS_EQUAL(R"({"42":42})", str.Str()); } - Y_UNIT_TEST(TestEnumValueGenerator) { + Y_UNIT_TEST(TestEnumValueGenerator) { TEnumValueGeneratorType proto; proto.SetEnum(TEnumValueGeneratorType::ENUM_42); @@ -100,7 +100,7 @@ Y_UNIT_TEST_SUITE(TProto2JsonFlatTest) { UNIT_ASSERT_STRINGS_EQUAL(R"({"Enum":"42"})", str.Str()); } - Y_UNIT_TEST(TestFlatOptional){ + Y_UNIT_TEST(TestFlatOptional){ {TFlatOptional proto; FillFlatProto(&proto); const NJson::TJsonValue& modelJson = CreateFlatJson(); @@ -141,7 +141,7 @@ Y_UNIT_TEST_SUITE(TProto2JsonFlatTest) { #undef DEFINE_FIELD } // TestFlatOptional -Y_UNIT_TEST(TestFlatRequired){ +Y_UNIT_TEST(TestFlatRequired){ {TFlatRequired proto; FillFlatProto(&proto); const NJson::TJsonValue& modelJson = CreateFlatJson(); @@ -182,7 +182,7 @@ const NJson::TJsonValue& modelJson = CreateFlatJson(); #undef DEFINE_FIELD } // TestFlatRequired -Y_UNIT_TEST(TestFlatRepeated) { +Y_UNIT_TEST(TestFlatRepeated) { { TFlatRepeated proto; FillRepeatedProto(&proto); @@ -227,7 +227,7 @@ Y_UNIT_TEST(TestFlatRepeated) { #undef DEFINE_REPEATED_FIELD } // TestFlatRepeated -Y_UNIT_TEST(TestCompositeOptional){ +Y_UNIT_TEST(TestCompositeOptional){ {TCompositeOptional proto; FillCompositeProto(&proto); const NJson::TJsonValue& modelJson = CreateCompositeJson(); @@ -268,7 +268,7 @@ const NJson::TJsonValue& modelJson = CreateCompositeJson(); #undef DEFINE_FIELD } // TestCompositeOptional -Y_UNIT_TEST(TestCompositeRequired){ +Y_UNIT_TEST(TestCompositeRequired){ {TCompositeRequired proto; FillCompositeProto(&proto); const NJson::TJsonValue& modelJson = CreateCompositeJson(); @@ -309,7 +309,7 @@ const NJson::TJsonValue& modelJson = CreateCompositeJson(); #undef DEFINE_FIELD } // TestCompositeRequired -Y_UNIT_TEST(TestCompositeRepeated) { +Y_UNIT_TEST(TestCompositeRepeated) { { TFlatOptional partProto; FillFlatProto(&partProto); @@ -371,7 +371,7 @@ Y_UNIT_TEST(TestCompositeRepeated) { } } // TestCompositeRepeated -Y_UNIT_TEST(TestEnumConfig) { +Y_UNIT_TEST(TestEnumConfig) { { TFlatOptional proto; proto.SetEnum(E_1); @@ -438,7 +438,7 @@ Y_UNIT_TEST(TestEnumConfig) { } } // TestEnumConfig -Y_UNIT_TEST(TestMissingSingleKeyConfig) { +Y_UNIT_TEST(TestMissingSingleKeyConfig) { { TFlatOptional proto; NJson::TJsonValue modelJson(NJson::JSON_MAP); @@ -513,7 +513,7 @@ Y_UNIT_TEST(TestMissingSingleKeyConfig) { } } // TestMissingSingleKeyConfig -Y_UNIT_TEST(TestMissingRepeatedKeyNoConfig) { +Y_UNIT_TEST(TestMissingRepeatedKeyNoConfig) { { TFlatRepeated proto; NJson::TJsonValue modelJson(NJson::JSON_MAP); @@ -524,7 +524,7 @@ Y_UNIT_TEST(TestMissingRepeatedKeyNoConfig) { } } // TestMissingRepeatedKeyNoConfig -Y_UNIT_TEST(TestMissingRepeatedKeyConfig) { +Y_UNIT_TEST(TestMissingRepeatedKeyConfig) { { TFlatRepeated proto; NJson::TJsonValue modelJson(NJson::JSON_MAP); @@ -564,7 +564,7 @@ Y_UNIT_TEST(TestMissingRepeatedKeyConfig) { } } // TestMissingRepeatedKeyConfig -Y_UNIT_TEST(TestEscaping) { +Y_UNIT_TEST(TestEscaping) { // No escape { TString modelStr(R"_({"String":"value\""})_"); @@ -632,7 +632,7 @@ public: } }; -Y_UNIT_TEST(TestBytesTransform) { +Y_UNIT_TEST(TestBytesTransform) { // Test that string field is not changed { TString modelStr(R"_({"String":"value"})_"); @@ -662,7 +662,7 @@ Y_UNIT_TEST(TestBytesTransform) { } } -Y_UNIT_TEST(TestFieldNameMode) { +Y_UNIT_TEST(TestFieldNameMode) { // Original case 1 { TString modelStr(R"_({"String":"value"})_"); @@ -888,21 +888,21 @@ Y_UNIT_TEST(TestFieldNameMode) { /// TODO: test missing keys } // TestFieldNameMode -Y_UNIT_TEST(TestNan) { +Y_UNIT_TEST(TestNan) { TFlatOptional proto; proto.SetDouble(std::numeric_limits<double>::quiet_NaN()); UNIT_ASSERT_EXCEPTION(Proto2Json(proto, TProto2JsonConfig()), yexception); } // TestNan -Y_UNIT_TEST(TestInf) { +Y_UNIT_TEST(TestInf) { TFlatOptional proto; proto.SetFloat(std::numeric_limits<float>::infinity()); UNIT_ASSERT_EXCEPTION(Proto2Json(proto, TProto2JsonConfig()), yexception); } // TestInf -Y_UNIT_TEST(TestMap) { +Y_UNIT_TEST(TestMap) { TMapType proto; auto& items = *proto.MutableItems(); @@ -931,7 +931,7 @@ Y_UNIT_TEST(TestMap) { UNIT_ASSERT_EQUAL(jsonItems, modelItems); } // TestMap -Y_UNIT_TEST(TestMapAsObject) { +Y_UNIT_TEST(TestMapAsObject) { TMapType proto; auto& items = *proto.MutableItems(); @@ -949,7 +949,7 @@ Y_UNIT_TEST(TestMapAsObject) { UNIT_ASSERT_JSON_STRINGS_EQUAL(jsonStr.Str(), modelStr); } // TestMapAsObject -Y_UNIT_TEST(TestMapWTF) { +Y_UNIT_TEST(TestMapWTF) { TMapType proto; auto& items = *proto.MutableItems(); @@ -965,7 +965,7 @@ Y_UNIT_TEST(TestMapWTF) { UNIT_ASSERT_JSON_STRINGS_EQUAL(jsonStr.Str(), modelStr); } // TestMapWTF -Y_UNIT_TEST(TestStringifyLongNumbers) { +Y_UNIT_TEST(TestStringifyLongNumbers) { #define TEST_SINGLE(flag, value, expectString) \ do { \ TFlatOptional proto; \ diff --git a/library/cpp/protobuf/json/ut/string_transform_ut.cpp b/library/cpp/protobuf/json/ut/string_transform_ut.cpp index a31dabcb0f0..7b0595e6cb4 100644 --- a/library/cpp/protobuf/json/ut/string_transform_ut.cpp +++ b/library/cpp/protobuf/json/ut/string_transform_ut.cpp @@ -3,8 +3,8 @@ #include <library/cpp/testing/unittest/registar.h> #include <library/cpp/protobuf/json/proto2json.h> -Y_UNIT_TEST_SUITE(TDoubleEscapeTransform) { - Y_UNIT_TEST(TestEmptyString) { +Y_UNIT_TEST_SUITE(TDoubleEscapeTransform) { + Y_UNIT_TEST(TestEmptyString) { const NProtobufJson::IStringTransform& transform = NProtobufJson::TDoubleEscapeTransform(); TString s; s = ""; @@ -12,7 +12,7 @@ Y_UNIT_TEST_SUITE(TDoubleEscapeTransform) { UNIT_ASSERT_EQUAL(s, ""); } - Y_UNIT_TEST(TestAlphabeticString) { + Y_UNIT_TEST(TestAlphabeticString) { const NProtobufJson::IStringTransform& transform = NProtobufJson::TDoubleEscapeTransform(); TString s; s = "abacaba"; @@ -20,7 +20,7 @@ Y_UNIT_TEST_SUITE(TDoubleEscapeTransform) { UNIT_ASSERT_EQUAL(s, "abacaba"); } - Y_UNIT_TEST(TestRussianSymbols) { + Y_UNIT_TEST(TestRussianSymbols) { const NProtobufJson::IStringTransform& transform = NProtobufJson::TDoubleEscapeTransform(); TString s; s = "тест"; @@ -28,7 +28,7 @@ Y_UNIT_TEST_SUITE(TDoubleEscapeTransform) { UNIT_ASSERT_EQUAL(s, "\\\\321\\\\202\\\\320\\\\265\\\\321\\\\201\\\\321\\\\202"); } - Y_UNIT_TEST(TestEscapeSpecialSymbols) { + Y_UNIT_TEST(TestEscapeSpecialSymbols) { const NProtobufJson::IStringTransform& transform = NProtobufJson::TDoubleEscapeTransform(); TString s; s = "aba\\ca\"ba"; @@ -38,8 +38,8 @@ Y_UNIT_TEST_SUITE(TDoubleEscapeTransform) { } } -Y_UNIT_TEST_SUITE(TDoubleUnescapeTransform) { - Y_UNIT_TEST(TestEmptyString) { +Y_UNIT_TEST_SUITE(TDoubleUnescapeTransform) { + Y_UNIT_TEST(TestEmptyString) { const NProtobufJson::IStringTransform& transform = NProtobufJson::TDoubleUnescapeTransform(); TString s; s = ""; @@ -47,7 +47,7 @@ Y_UNIT_TEST_SUITE(TDoubleUnescapeTransform) { UNIT_ASSERT_EQUAL("", s); } - Y_UNIT_TEST(TestAlphabeticString) { + Y_UNIT_TEST(TestAlphabeticString) { const NProtobufJson::IStringTransform& transform = NProtobufJson::TDoubleUnescapeTransform(); TString s; s = "abacaba"; @@ -56,7 +56,7 @@ Y_UNIT_TEST_SUITE(TDoubleUnescapeTransform) { UNIT_ASSERT_EQUAL("abacaba", s); } - Y_UNIT_TEST(TestRussianSymbols) { + Y_UNIT_TEST(TestRussianSymbols) { const NProtobufJson::IStringTransform& transform = NProtobufJson::TDoubleUnescapeTransform(); TString s; s = "\\\\321\\\\202\\\\320\\\\265\\\\321\\\\201\\\\321\\\\202"; @@ -64,7 +64,7 @@ Y_UNIT_TEST_SUITE(TDoubleUnescapeTransform) { UNIT_ASSERT_EQUAL("тест", s); } - Y_UNIT_TEST(TestEscapeSpecialSymbols) { + Y_UNIT_TEST(TestEscapeSpecialSymbols) { const NProtobufJson::IStringTransform& transform = NProtobufJson::TDoubleUnescapeTransform(); TString s; s = "aba\\\\\\\\ca\\\\\\\"ba"; @@ -72,7 +72,7 @@ Y_UNIT_TEST_SUITE(TDoubleUnescapeTransform) { UNIT_ASSERT_EQUAL("aba\\ca\"ba", s); } - Y_UNIT_TEST(TestEscapeSpecialSymbolsDifficultCases) { + Y_UNIT_TEST(TestEscapeSpecialSymbolsDifficultCases) { const NProtobufJson::IStringTransform& transform = NProtobufJson::TDoubleUnescapeTransform(); TString s; s = "\\\\\\\\\\\\\\\\"; diff --git a/library/cpp/protobuf/util/is_equal.h b/library/cpp/protobuf/util/is_equal.h index 13c0aae63d9..d47cb37cb72 100644 --- a/library/cpp/protobuf/util/is_equal.h +++ b/library/cpp/protobuf/util/is_equal.h @@ -1,22 +1,22 @@ #pragma once -#include <util/generic/fwd.h> +#include <util/generic/fwd.h> -namespace google { - namespace protobuf { - class Message; +namespace google { + namespace protobuf { + class Message; class FieldDescriptor; - } -} + } +} namespace NProtoBuf { using ::google::protobuf::FieldDescriptor; using ::google::protobuf::Message; -} +} -namespace NProtoBuf { +namespace NProtoBuf { // Reflection-based equality check for arbitrary protobuf messages - + // Strict comparison: optional field without value is NOT equal to // a field with explicitly set default value. bool IsEqual(const Message& m1, const Message& m2); diff --git a/library/cpp/protobuf/util/is_equal_ut.cpp b/library/cpp/protobuf/util/is_equal_ut.cpp index 3ca4c90dd5e..96e77c95c61 100644 --- a/library/cpp/protobuf/util/is_equal_ut.cpp +++ b/library/cpp/protobuf/util/is_equal_ut.cpp @@ -5,19 +5,19 @@ #include <google/protobuf/descriptor.h> -Y_UNIT_TEST_SUITE(ProtobufIsEqual) { +Y_UNIT_TEST_SUITE(ProtobufIsEqual) { const ::google::protobuf::Descriptor* Descr = TSampleForIsEqual::descriptor(); const ::google::protobuf::FieldDescriptor* NameDescr = Descr->field(0); const ::google::protobuf::FieldDescriptor* InnerDescr = Descr->field(1); - Y_UNIT_TEST(CheckDescriptors) { + Y_UNIT_TEST(CheckDescriptors) { UNIT_ASSERT(Descr); UNIT_ASSERT(NameDescr); UNIT_ASSERT_VALUES_EQUAL(NameDescr->name(), "Name"); UNIT_ASSERT_VALUES_EQUAL(InnerDescr->name(), "Inner"); } - Y_UNIT_TEST(IsEqual1) { + Y_UNIT_TEST(IsEqual1) { TSampleForIsEqual a; TSampleForIsEqual b; @@ -33,7 +33,7 @@ Y_UNIT_TEST_SUITE(ProtobufIsEqual) { UNIT_ASSERT(!NProtoBuf::IsEqualField(a, b, *NameDescr)); } - Y_UNIT_TEST(IsEqual2) { + Y_UNIT_TEST(IsEqual2) { TSampleForIsEqual a; TSampleForIsEqual b; @@ -50,7 +50,7 @@ Y_UNIT_TEST_SUITE(ProtobufIsEqual) { UNIT_ASSERT(!equalField); } - Y_UNIT_TEST(IsEqual3) { + Y_UNIT_TEST(IsEqual3) { TSampleForIsEqual a; TSampleForIsEqual b; @@ -74,7 +74,7 @@ Y_UNIT_TEST_SUITE(ProtobufIsEqual) { UNIT_ASSERT(!NProtoBuf::IsEqualField(a, b, *NameDescr)); } - Y_UNIT_TEST(IsEqualDefault) { + Y_UNIT_TEST(IsEqualDefault) { TSampleForIsEqual a; TSampleForIsEqual b; diff --git a/library/cpp/protobuf/util/iterators_ut.cpp b/library/cpp/protobuf/util/iterators_ut.cpp index 9ebcff29630..7a255f0188e 100644 --- a/library/cpp/protobuf/util/iterators_ut.cpp +++ b/library/cpp/protobuf/util/iterators_ut.cpp @@ -9,8 +9,8 @@ using NProtoBuf::TFieldsIterator; using NProtoBuf::TConstField; -Y_UNIT_TEST_SUITE(Iterators) { - Y_UNIT_TEST(Count) { +Y_UNIT_TEST_SUITE(Iterators) { + Y_UNIT_TEST(Count) { const NProtobufUtilUt::TWalkTest proto; const NProtoBuf::Descriptor* d = proto.GetDescriptor(); TFieldsIterator dbegin(d), dend(d, d->field_count()); @@ -36,7 +36,7 @@ Y_UNIT_TEST_SUITE(Iterators) { UNIT_ASSERT_VALUES_EQUAL(values, 1); } - Y_UNIT_TEST(AnyOf) { + Y_UNIT_TEST(AnyOf) { NProtobufUtilUt::TWalkTest proto; const NProtoBuf::Descriptor* d = proto.GetDescriptor(); TFieldsIterator begin(d), end(d, d->field_count()); diff --git a/library/cpp/protobuf/util/merge.cpp b/library/cpp/protobuf/util/merge.cpp index dc2b9cc8069..19e1e6bafcf 100644 --- a/library/cpp/protobuf/util/merge.cpp +++ b/library/cpp/protobuf/util/merge.cpp @@ -1,8 +1,8 @@ #include "merge.h" -#include "simple_reflection.h" - +#include "simple_reflection.h" + #include <google/protobuf/message.h> - + #include <library/cpp/protobuf/util/proto/merge.pb.h> namespace NProtoBuf { diff --git a/library/cpp/protobuf/util/merge.h b/library/cpp/protobuf/util/merge.h index 924975f141b..4acea08697c 100644 --- a/library/cpp/protobuf/util/merge.h +++ b/library/cpp/protobuf/util/merge.h @@ -1,14 +1,14 @@ #pragma once -namespace google { - namespace protobuf { - class Message; - } -} +namespace google { + namespace protobuf { + class Message; + } +} -namespace NProtoBuf { - using Message = ::google::protobuf::Message; -} +namespace NProtoBuf { + using Message = ::google::protobuf::Message; +} namespace NProtoBuf { // Similiar to Message::MergeFrom, overwrites existing repeated fields diff --git a/library/cpp/protobuf/util/merge_ut.cpp b/library/cpp/protobuf/util/merge_ut.cpp index 22217db1835..01bf3d1a485 100644 --- a/library/cpp/protobuf/util/merge_ut.cpp +++ b/library/cpp/protobuf/util/merge_ut.cpp @@ -5,7 +5,7 @@ using namespace NProtoBuf; -Y_UNIT_TEST_SUITE(ProtobufMerge) { +Y_UNIT_TEST_SUITE(ProtobufMerge) { static void InitProto(NProtobufUtilUt::TMergeTest & p, bool isSrc) { size_t start = isSrc ? 0 : 100; @@ -35,7 +35,7 @@ Y_UNIT_TEST_SUITE(ProtobufMerge) { mm3->AddB(start + 13); } - Y_UNIT_TEST(CustomMerge) { + Y_UNIT_TEST(CustomMerge) { NProtobufUtilUt::TMergeTest src, dst; InitProto(src, true); InitProto(dst, false); diff --git a/library/cpp/protobuf/util/pb_io.cpp b/library/cpp/protobuf/util/pb_io.cpp index 6270ee06243..ab808fd6f4c 100644 --- a/library/cpp/protobuf/util/pb_io.cpp +++ b/library/cpp/protobuf/util/pb_io.cpp @@ -8,11 +8,11 @@ #include <google/protobuf/text_format.h> #include <util/generic/string.h> -#include <util/stream/file.h> -#include <util/stream/str.h> +#include <util/stream/file.h> +#include <util/stream/str.h> #include <util/string/cast.h> -namespace NProtoBuf { +namespace NProtoBuf { class TEnumIdValuePrinter : public google::protobuf::TextFormat::FastFieldValuePrinter { public: @@ -34,7 +34,7 @@ namespace NProtoBuf { } catch (const std::exception&) { return false; } - } + } void SerializeToBase64String(const Message& m, TString& dataBase64) { TString rawData; @@ -58,8 +58,8 @@ namespace NProtoBuf { } catch (const std::exception&) { return false; } - } - + } + const TString ShortUtf8DebugString(const Message& message) { TextFormat::Printer printer; printer.SetSingleLineMode(true); @@ -93,21 +93,21 @@ int operator&(NProtoBuf::Message& m, IBinSaver& f) { return 0; } -void SerializeToTextFormat(const NProtoBuf::Message& m, IOutputStream& out) { - NProtoBuf::io::TCopyingOutputStreamAdaptor adaptor(&out); +void SerializeToTextFormat(const NProtoBuf::Message& m, IOutputStream& out) { + NProtoBuf::io::TCopyingOutputStreamAdaptor adaptor(&out); - if (!NProtoBuf::TextFormat::Print(m, &adaptor)) { + if (!NProtoBuf::TextFormat::Print(m, &adaptor)) { ythrow yexception() << "SerializeToTextFormat failed on Print"; - } + } } void SerializeToTextFormat(const NProtoBuf::Message& m, const TString& fileName) { /* TUnbufferedFileOutput is unbuffered, but TCopyingOutputStreamAdaptor adds - * a buffer on top of it. */ + * a buffer on top of it. */ TUnbufferedFileOutput stream(fileName); - SerializeToTextFormat(m, stream); -} - + SerializeToTextFormat(m, stream); +} + void SerializeToTextFormatWithEnumId(const NProtoBuf::Message& m, IOutputStream& out) { google::protobuf::TextFormat::Printer printer; printer.SetDefaultFieldValuePrinter(new NProtoBuf::TEnumIdValuePrinter()); @@ -130,20 +130,20 @@ void SerializeToTextFormatPretty(const NProtoBuf::Message& m, IOutputStream& out } } -static void ConfigureParser(const EParseFromTextFormatOptions options, - NProtoBuf::TextFormat::Parser& p) { - if (options & EParseFromTextFormatOption::AllowUnknownField) { - p.AllowUnknownField(true); - } -} - -void ParseFromTextFormat(IInputStream& in, NProtoBuf::Message& m, - const EParseFromTextFormatOptions options) { - NProtoBuf::io::TCopyingInputStreamAdaptor adaptor(&in); - NProtoBuf::TextFormat::Parser p; - ConfigureParser(options, p); - - if (!p.Parse(&adaptor, &m)) { +static void ConfigureParser(const EParseFromTextFormatOptions options, + NProtoBuf::TextFormat::Parser& p) { + if (options & EParseFromTextFormatOption::AllowUnknownField) { + p.AllowUnknownField(true); + } +} + +void ParseFromTextFormat(IInputStream& in, NProtoBuf::Message& m, + const EParseFromTextFormatOptions options) { + NProtoBuf::io::TCopyingInputStreamAdaptor adaptor(&in); + NProtoBuf::TextFormat::Parser p; + ConfigureParser(options, p); + + if (!p.Parse(&adaptor, &m)) { // remove everything that may have been read m.Clear(); ythrow yexception() << "ParseFromTextFormat failed on Parse for " << m.GetTypeName(); @@ -151,71 +151,71 @@ void ParseFromTextFormat(IInputStream& in, NProtoBuf::Message& m, } void ParseFromTextFormat(const TString& fileName, NProtoBuf::Message& m, - const EParseFromTextFormatOptions options) { + const EParseFromTextFormatOptions options) { /* TUnbufferedFileInput is unbuffered, but TCopyingInputStreamAdaptor adds - * a buffer on top of it. */ + * a buffer on top of it. */ TUnbufferedFileInput stream(fileName); - ParseFromTextFormat(stream, m, options); -} - + ParseFromTextFormat(stream, m, options); +} + bool TryParseFromTextFormat(const TString& fileName, NProtoBuf::Message& m, - const EParseFromTextFormatOptions options) { - try { - ParseFromTextFormat(fileName, m, options); - } catch (std::exception&) { - return false; - } - - return true; + const EParseFromTextFormatOptions options) { + try { + ParseFromTextFormat(fileName, m, options); + } catch (std::exception&) { + return false; + } + + return true; } -bool TryParseFromTextFormat(IInputStream& in, NProtoBuf::Message& m, - const EParseFromTextFormatOptions options) { - try { - ParseFromTextFormat(in, m, options); - } catch (std::exception&) { - return false; - } - - return true; -} - -void MergeFromTextFormat(IInputStream& in, NProtoBuf::Message& m, - const EParseFromTextFormatOptions options) { - NProtoBuf::io::TCopyingInputStreamAdaptor adaptor(&in); - NProtoBuf::TextFormat::Parser p; - ConfigureParser(options, p); - if (!p.Merge(&adaptor, &m)) { - ythrow yexception() << "MergeFromTextFormat failed on Merge for " << m.GetTypeName(); - } -} - -void MergeFromTextFormat(const TString& fileName, NProtoBuf::Message& m, - const EParseFromTextFormatOptions options) { +bool TryParseFromTextFormat(IInputStream& in, NProtoBuf::Message& m, + const EParseFromTextFormatOptions options) { + try { + ParseFromTextFormat(in, m, options); + } catch (std::exception&) { + return false; + } + + return true; +} + +void MergeFromTextFormat(IInputStream& in, NProtoBuf::Message& m, + const EParseFromTextFormatOptions options) { + NProtoBuf::io::TCopyingInputStreamAdaptor adaptor(&in); + NProtoBuf::TextFormat::Parser p; + ConfigureParser(options, p); + if (!p.Merge(&adaptor, &m)) { + ythrow yexception() << "MergeFromTextFormat failed on Merge for " << m.GetTypeName(); + } +} + +void MergeFromTextFormat(const TString& fileName, NProtoBuf::Message& m, + const EParseFromTextFormatOptions options) { /* TUnbufferedFileInput is unbuffered, but TCopyingInputStreamAdaptor adds - * a buffer on top of it. */ + * a buffer on top of it. */ TUnbufferedFileInput stream(fileName); - MergeFromTextFormat(stream, m, options); -} - -bool TryMergeFromTextFormat(const TString& fileName, NProtoBuf::Message& m, - const EParseFromTextFormatOptions options) { - try { - MergeFromTextFormat(fileName, m, options); - } catch (std::exception&) { - return false; - } - - return true; -} - -bool TryMergeFromTextFormat(IInputStream& in, NProtoBuf::Message& m, - const EParseFromTextFormatOptions options) { - try { - MergeFromTextFormat(in, m, options); - } catch (std::exception&) { - return false; - } - - return true; -} + MergeFromTextFormat(stream, m, options); +} + +bool TryMergeFromTextFormat(const TString& fileName, NProtoBuf::Message& m, + const EParseFromTextFormatOptions options) { + try { + MergeFromTextFormat(fileName, m, options); + } catch (std::exception&) { + return false; + } + + return true; +} + +bool TryMergeFromTextFormat(IInputStream& in, NProtoBuf::Message& m, + const EParseFromTextFormatOptions options) { + try { + MergeFromTextFormat(in, m, options); + } catch (std::exception&) { + return false; + } + + return true; +} diff --git a/library/cpp/protobuf/util/pb_io.h b/library/cpp/protobuf/util/pb_io.h index 493c84cb5f3..a431b4200b3 100644 --- a/library/cpp/protobuf/util/pb_io.h +++ b/library/cpp/protobuf/util/pb_io.h @@ -1,37 +1,37 @@ #pragma once -#include <util/generic/fwd.h> -#include <util/generic/flags.h> +#include <util/generic/fwd.h> +#include <util/generic/flags.h> -struct IBinSaver; +struct IBinSaver; -namespace google { - namespace protobuf { +namespace google { + namespace protobuf { class Message; - } -} - -namespace NProtoBuf { - using Message = ::google::protobuf::Message; -} - -class IInputStream; -class IOutputStream; - -namespace NProtoBuf { - /* Parse base64 URL encoded serialized message from string. - */ + } +} + +namespace NProtoBuf { + using Message = ::google::protobuf::Message; +} + +class IInputStream; +class IOutputStream; + +namespace NProtoBuf { + /* Parse base64 URL encoded serialized message from string. + */ void ParseFromBase64String(const TStringBuf dataBase64, Message& m, bool allowUneven = false); bool TryParseFromBase64String(const TStringBuf dataBase64, Message& m, bool allowUneven = false); - template <typename T> + template <typename T> static T ParseFromBase64String(const TStringBuf& dataBase64, bool allowUneven = false) { - T m; + T m; ParseFromBase64String(dataBase64, m, allowUneven); - return m; - } + return m; + } - /* Serialize message into string and apply base64 URL encoding. - */ + /* Serialize message into string and apply base64 URL encoding. + */ TString SerializeToBase64String(const Message& m); void SerializeToBase64String(const Message& m, TString& dataBase64); bool TrySerializeToBase64String(const Message& m, TString& dataBase64); @@ -44,10 +44,10 @@ namespace NProtoBuf { int operator&(NProtoBuf::Message& m, IBinSaver& f); -// Write a textual representation of the given message to the given file. +// Write a textual representation of the given message to the given file. void SerializeToTextFormat(const NProtoBuf::Message& m, const TString& fileName); -void SerializeToTextFormat(const NProtoBuf::Message& m, IOutputStream& out); - +void SerializeToTextFormat(const NProtoBuf::Message& m, IOutputStream& out); + // Write a textual representation of the given message to the given output stream // with flags UseShortRepeatedPrimitives and UseUtf8StringEscaping set to true. void SerializeToTextFormatPretty(const NProtoBuf::Message& m, IOutputStream& out); @@ -56,83 +56,83 @@ void SerializeToTextFormatPretty(const NProtoBuf::Message& m, IOutputStream& out // use enum id instead of enum name for all enum fields. void SerializeToTextFormatWithEnumId(const NProtoBuf::Message& m, IOutputStream& out); -enum class EParseFromTextFormatOption : ui64 { - // Unknown fields will be ignored by the parser - AllowUnknownField = 1 -}; - -Y_DECLARE_FLAGS(EParseFromTextFormatOptions, EParseFromTextFormatOption); - -// Parse a text-format protocol message from the given file into message object. +enum class EParseFromTextFormatOption : ui64 { + // Unknown fields will be ignored by the parser + AllowUnknownField = 1 +}; + +Y_DECLARE_FLAGS(EParseFromTextFormatOptions, EParseFromTextFormatOption); + +// Parse a text-format protocol message from the given file into message object. void ParseFromTextFormat(const TString& fileName, NProtoBuf::Message& m, - const EParseFromTextFormatOptions options = {}); -// NOTE: will read `in` till the end. -void ParseFromTextFormat(IInputStream& in, NProtoBuf::Message& m, - const EParseFromTextFormatOptions options = {}); - -/* @return `true` if parsing was successfull and `false` otherwise. - * - * @see `ParseFromTextFormat` - */ + const EParseFromTextFormatOptions options = {}); +// NOTE: will read `in` till the end. +void ParseFromTextFormat(IInputStream& in, NProtoBuf::Message& m, + const EParseFromTextFormatOptions options = {}); + +/* @return `true` if parsing was successfull and `false` otherwise. + * + * @see `ParseFromTextFormat` + */ bool TryParseFromTextFormat(const TString& fileName, NProtoBuf::Message& m, - const EParseFromTextFormatOptions options = {}); -// NOTE: will read `in` till the end. -bool TryParseFromTextFormat(IInputStream& in, NProtoBuf::Message& m, - const EParseFromTextFormatOptions options = {}); - -// @see `ParseFromTextFormat` -template <typename T> + const EParseFromTextFormatOptions options = {}); +// NOTE: will read `in` till the end. +bool TryParseFromTextFormat(IInputStream& in, NProtoBuf::Message& m, + const EParseFromTextFormatOptions options = {}); + +// @see `ParseFromTextFormat` +template <typename T> static T ParseFromTextFormat(const TString& fileName, - const EParseFromTextFormatOptions options = {}) { - T message; - ParseFromTextFormat(fileName, message, options); - return message; -} - -// @see `ParseFromTextFormat` -// NOTE: will read `in` till the end. -template <typename T> -static T ParseFromTextFormat(IInputStream& in, - const EParseFromTextFormatOptions options = {}) { - T message; - ParseFromTextFormat(in, message, options); - return message; -} - -// Merge a text-format protocol message from the given file into message object. -// -// NOTE: Even when parsing failed and exception was thrown `m` may be different from its original -// value. User must implement transactional logic around `MergeFromTextFormat` by himself. -void MergeFromTextFormat(const TString& fileName, NProtoBuf::Message& m, - const EParseFromTextFormatOptions options = {}); -// NOTE: will read `in` till the end. -void MergeFromTextFormat(IInputStream& in, NProtoBuf::Message& m, - const EParseFromTextFormatOptions options = {}); -/* @return `true` if parsing was successfull and `false` otherwise. - * - * @see `MergeFromTextFormat` - */ -bool TryMergeFromTextFormat(const TString& fileName, NProtoBuf::Message& m, - const EParseFromTextFormatOptions options = {}); -// NOTE: will read `in` till the end. -bool TryMergeFromTextFormat(IInputStream& in, NProtoBuf::Message& m, - const EParseFromTextFormatOptions options = {}); - -// @see `MergeFromTextFormat` -template <typename T> -static T MergeFromTextFormat(const TString& fileName, - const EParseFromTextFormatOptions options = {}) { - T message; - MergeFromTextFormat(fileName, message, options); - return message; -} - -// @see `MergeFromTextFormat` -// NOTE: will read `in` till the end. -template <typename T> -static T MergeFromTextFormat(IInputStream& in, - const EParseFromTextFormatOptions options = {}) { - T message; - MergeFromTextFormat(in, message, options); - return message; -} + const EParseFromTextFormatOptions options = {}) { + T message; + ParseFromTextFormat(fileName, message, options); + return message; +} + +// @see `ParseFromTextFormat` +// NOTE: will read `in` till the end. +template <typename T> +static T ParseFromTextFormat(IInputStream& in, + const EParseFromTextFormatOptions options = {}) { + T message; + ParseFromTextFormat(in, message, options); + return message; +} + +// Merge a text-format protocol message from the given file into message object. +// +// NOTE: Even when parsing failed and exception was thrown `m` may be different from its original +// value. User must implement transactional logic around `MergeFromTextFormat` by himself. +void MergeFromTextFormat(const TString& fileName, NProtoBuf::Message& m, + const EParseFromTextFormatOptions options = {}); +// NOTE: will read `in` till the end. +void MergeFromTextFormat(IInputStream& in, NProtoBuf::Message& m, + const EParseFromTextFormatOptions options = {}); +/* @return `true` if parsing was successfull and `false` otherwise. + * + * @see `MergeFromTextFormat` + */ +bool TryMergeFromTextFormat(const TString& fileName, NProtoBuf::Message& m, + const EParseFromTextFormatOptions options = {}); +// NOTE: will read `in` till the end. +bool TryMergeFromTextFormat(IInputStream& in, NProtoBuf::Message& m, + const EParseFromTextFormatOptions options = {}); + +// @see `MergeFromTextFormat` +template <typename T> +static T MergeFromTextFormat(const TString& fileName, + const EParseFromTextFormatOptions options = {}) { + T message; + MergeFromTextFormat(fileName, message, options); + return message; +} + +// @see `MergeFromTextFormat` +// NOTE: will read `in` till the end. +template <typename T> +static T MergeFromTextFormat(IInputStream& in, + const EParseFromTextFormatOptions options = {}) { + T message; + MergeFromTextFormat(in, message, options); + return message; +} diff --git a/library/cpp/protobuf/util/pb_io_ut.cpp b/library/cpp/protobuf/util/pb_io_ut.cpp index 875d6dc6026..32bba7bc405 100644 --- a/library/cpp/protobuf/util/pb_io_ut.cpp +++ b/library/cpp/protobuf/util/pb_io_ut.cpp @@ -1,22 +1,22 @@ -#include "pb_io.h" - -#include "is_equal.h" - +#include "pb_io.h" + +#include "is_equal.h" + #include <library/cpp/protobuf/util/ut/common_ut.pb.h> - + #include <library/cpp/testing/unittest/registar.h> - -#include <util/folder/path.h> -#include <util/folder/tempdir.h> -#include <util/stream/file.h> -#include <util/stream/str.h> - -static NProtobufUtilUt::TTextTest GetCorrectMessage() { - NProtobufUtilUt::TTextTest m; - m.SetFoo(42); - return m; -} - + +#include <util/folder/path.h> +#include <util/folder/tempdir.h> +#include <util/stream/file.h> +#include <util/stream/str.h> + +static NProtobufUtilUt::TTextTest GetCorrectMessage() { + NProtobufUtilUt::TTextTest m; + m.SetFoo(42); + return m; +} + static NProtobufUtilUt::TTextEnumTest GetCorrectEnumMessage() { NProtobufUtilUt::TTextEnumTest m; m.SetSlot(NProtobufUtilUt::TTextEnumTest::EET_SLOT_1); @@ -25,41 +25,41 @@ static NProtobufUtilUt::TTextEnumTest GetCorrectEnumMessage() { static const TString CORRECT_MESSAGE = R"(Foo: 42 -)"; +)"; static const TString CORRECT_ENUM_NAME_MESSAGE = R"(Slot: EET_SLOT_1 )"; static const TString CORRECT_ENUM_ID_MESSAGE = R"(Slot: 1 )"; - + static const TString INCORRECT_MESSAGE = R"(Bar: 1 -)"; +)"; static const TString INCORRECT_ENUM_NAME_MESSAGE = R"(Slot: EET_SLOT_3 )"; static const TString INCORRECT_ENUM_ID_MESSAGE = R"(Slot: 3 )"; - + static const TString CORRECT_BASE64_MESSAGE = "CCo,"; static const TString CORRECT_UNEVEN_BASE64_MESSAGE = "CCo"; static const TString INCORRECT_BASE64_MESSAGE = "CC"; -Y_UNIT_TEST_SUITE(TTestProtoBufIO) { - Y_UNIT_TEST(TestBase64) { - { - NProtobufUtilUt::TTextTest message; - UNIT_ASSERT(NProtoBuf::TryParseFromBase64String(CORRECT_BASE64_MESSAGE, message)); - } - { - NProtobufUtilUt::TTextTest message; - UNIT_ASSERT(!NProtoBuf::TryParseFromBase64String(INCORRECT_BASE64_MESSAGE, message)); - } - { +Y_UNIT_TEST_SUITE(TTestProtoBufIO) { + Y_UNIT_TEST(TestBase64) { + { + NProtobufUtilUt::TTextTest message; + UNIT_ASSERT(NProtoBuf::TryParseFromBase64String(CORRECT_BASE64_MESSAGE, message)); + } + { + NProtobufUtilUt::TTextTest message; + UNIT_ASSERT(!NProtoBuf::TryParseFromBase64String(INCORRECT_BASE64_MESSAGE, message)); + } + { NProtobufUtilUt::TTextTest message; UNIT_ASSERT(NProtoBuf::TryParseFromBase64String(CORRECT_UNEVEN_BASE64_MESSAGE , message, true)); } @@ -68,134 +68,134 @@ Y_UNIT_TEST_SUITE(TTestProtoBufIO) { UNIT_ASSERT(!NProtoBuf::TryParseFromBase64String(CORRECT_UNEVEN_BASE64_MESSAGE , message, false)); } { - UNIT_ASSERT_VALUES_EQUAL(CORRECT_BASE64_MESSAGE, NProtoBuf::SerializeToBase64String(GetCorrectMessage())); - } - { - const auto m = NProtoBuf::ParseFromBase64String<NProtobufUtilUt::TTextTest>(CORRECT_BASE64_MESSAGE); - UNIT_ASSERT(NProtoBuf::IsEqual(GetCorrectMessage(), m)); - } - } - - Y_UNIT_TEST(TestParseFromTextFormat) { - TTempDir tempDir; - const TFsPath correctFileName = TFsPath{tempDir()} / "correct.pb.txt"; - const TFsPath incorrectFileName = TFsPath{tempDir()} / "incorrect.pb.txt"; - + UNIT_ASSERT_VALUES_EQUAL(CORRECT_BASE64_MESSAGE, NProtoBuf::SerializeToBase64String(GetCorrectMessage())); + } + { + const auto m = NProtoBuf::ParseFromBase64String<NProtobufUtilUt::TTextTest>(CORRECT_BASE64_MESSAGE); + UNIT_ASSERT(NProtoBuf::IsEqual(GetCorrectMessage(), m)); + } + } + + Y_UNIT_TEST(TestParseFromTextFormat) { + TTempDir tempDir; + const TFsPath correctFileName = TFsPath{tempDir()} / "correct.pb.txt"; + const TFsPath incorrectFileName = TFsPath{tempDir()} / "incorrect.pb.txt"; + TFileOutput{correctFileName}.Write(CORRECT_MESSAGE); TFileOutput{incorrectFileName}.Write(INCORRECT_MESSAGE); - - { - NProtobufUtilUt::TTextTest message; - UNIT_ASSERT(TryParseFromTextFormat(correctFileName, message)); - } - { - NProtobufUtilUt::TTextTest message; - UNIT_ASSERT(!TryParseFromTextFormat(incorrectFileName, message)); - } - { - NProtobufUtilUt::TTextTest message; - TStringInput in{CORRECT_MESSAGE}; - UNIT_ASSERT(TryParseFromTextFormat(in, message)); - } - { - NProtobufUtilUt::TTextTest message; - TStringInput in{INCORRECT_MESSAGE}; - UNIT_ASSERT(!TryParseFromTextFormat(in, message)); - } - { - NProtobufUtilUt::TTextTest message; - UNIT_ASSERT_NO_EXCEPTION(TryParseFromTextFormat(incorrectFileName, message)); - } - { - NProtobufUtilUt::TTextTest message; - UNIT_ASSERT(!TryParseFromTextFormat("this_file_doesnt_exists", message)); - } - { - NProtobufUtilUt::TTextTest message; - UNIT_ASSERT_NO_EXCEPTION(TryParseFromTextFormat("this_file_doesnt_exists", message)); - } - { - NProtobufUtilUt::TTextTest message; + + { + NProtobufUtilUt::TTextTest message; + UNIT_ASSERT(TryParseFromTextFormat(correctFileName, message)); + } + { + NProtobufUtilUt::TTextTest message; + UNIT_ASSERT(!TryParseFromTextFormat(incorrectFileName, message)); + } + { + NProtobufUtilUt::TTextTest message; + TStringInput in{CORRECT_MESSAGE}; + UNIT_ASSERT(TryParseFromTextFormat(in, message)); + } + { + NProtobufUtilUt::TTextTest message; + TStringInput in{INCORRECT_MESSAGE}; + UNIT_ASSERT(!TryParseFromTextFormat(in, message)); + } + { + NProtobufUtilUt::TTextTest message; + UNIT_ASSERT_NO_EXCEPTION(TryParseFromTextFormat(incorrectFileName, message)); + } + { + NProtobufUtilUt::TTextTest message; + UNIT_ASSERT(!TryParseFromTextFormat("this_file_doesnt_exists", message)); + } + { + NProtobufUtilUt::TTextTest message; + UNIT_ASSERT_NO_EXCEPTION(TryParseFromTextFormat("this_file_doesnt_exists", message)); + } + { + NProtobufUtilUt::TTextTest message; UNIT_ASSERT_EXCEPTION(ParseFromTextFormat("this_file_doesnt_exists", message), TFileError); } { - NProtobufUtilUt::TTextTest message; - UNIT_ASSERT_NO_EXCEPTION(ParseFromTextFormat(correctFileName, message)); - } - { - NProtobufUtilUt::TTextTest message; - UNIT_ASSERT_EXCEPTION(ParseFromTextFormat(incorrectFileName, message), yexception); - } - { - NProtobufUtilUt::TTextTest message; - TStringInput in{CORRECT_MESSAGE}; - UNIT_ASSERT_NO_EXCEPTION(ParseFromTextFormat(in, message)); - } - { - NProtobufUtilUt::TTextTest message; - TStringInput in{INCORRECT_MESSAGE}; - UNIT_ASSERT_EXCEPTION(ParseFromTextFormat(in, message), yexception); - } - { - NProtobufUtilUt::TTextTest m; + NProtobufUtilUt::TTextTest message; + UNIT_ASSERT_NO_EXCEPTION(ParseFromTextFormat(correctFileName, message)); + } + { + NProtobufUtilUt::TTextTest message; + UNIT_ASSERT_EXCEPTION(ParseFromTextFormat(incorrectFileName, message), yexception); + } + { + NProtobufUtilUt::TTextTest message; + TStringInput in{CORRECT_MESSAGE}; + UNIT_ASSERT_NO_EXCEPTION(ParseFromTextFormat(in, message)); + } + { + NProtobufUtilUt::TTextTest message; + TStringInput in{INCORRECT_MESSAGE}; + UNIT_ASSERT_EXCEPTION(ParseFromTextFormat(in, message), yexception); + } + { + NProtobufUtilUt::TTextTest m; const auto f = [&correctFileName](NProtobufUtilUt::TTextTest& mm) { mm = ParseFromTextFormat<NProtobufUtilUt::TTextTest>(correctFileName); - }; - UNIT_ASSERT_NO_EXCEPTION(f(m)); - UNIT_ASSERT(NProtoBuf::IsEqual(GetCorrectMessage(), m)); - } - { - UNIT_ASSERT_EXCEPTION(ParseFromTextFormat<NProtobufUtilUt::TTextTest>(incorrectFileName), yexception); - } - { - NProtobufUtilUt::TTextTest m; - TStringInput in{CORRECT_MESSAGE}; + }; + UNIT_ASSERT_NO_EXCEPTION(f(m)); + UNIT_ASSERT(NProtoBuf::IsEqual(GetCorrectMessage(), m)); + } + { + UNIT_ASSERT_EXCEPTION(ParseFromTextFormat<NProtobufUtilUt::TTextTest>(incorrectFileName), yexception); + } + { + NProtobufUtilUt::TTextTest m; + TStringInput in{CORRECT_MESSAGE}; const auto f = [&in](NProtobufUtilUt::TTextTest& mm) { mm = ParseFromTextFormat<NProtobufUtilUt::TTextTest>(in); - }; - UNIT_ASSERT_NO_EXCEPTION(f(m)); - UNIT_ASSERT(NProtoBuf::IsEqual(GetCorrectMessage(), m)); - } - { - TStringInput in{INCORRECT_MESSAGE}; - UNIT_ASSERT_EXCEPTION(ParseFromTextFormat<NProtobufUtilUt::TTextTest>(in), yexception); - } - { + }; + UNIT_ASSERT_NO_EXCEPTION(f(m)); + UNIT_ASSERT(NProtoBuf::IsEqual(GetCorrectMessage(), m)); + } + { + TStringInput in{INCORRECT_MESSAGE}; + UNIT_ASSERT_EXCEPTION(ParseFromTextFormat<NProtobufUtilUt::TTextTest>(in), yexception); + } + { const TFsPath correctFileName2 = TFsPath{tempDir()} / "serialized.pb.txt"; - const auto original = GetCorrectMessage(); + const auto original = GetCorrectMessage(); UNIT_ASSERT_NO_EXCEPTION(SerializeToTextFormat(original, correctFileName2)); const auto serializedStr = TUnbufferedFileInput{correctFileName2}.ReadAll(); - UNIT_ASSERT_VALUES_EQUAL(serializedStr, CORRECT_MESSAGE); - } - { - const auto original = GetCorrectMessage(); - TStringStream out; - UNIT_ASSERT_NO_EXCEPTION(SerializeToTextFormat(original, out)); - UNIT_ASSERT_VALUES_EQUAL(out.Str(), CORRECT_MESSAGE); - } - { - NProtobufUtilUt::TTextTest m; + UNIT_ASSERT_VALUES_EQUAL(serializedStr, CORRECT_MESSAGE); + } + { + const auto original = GetCorrectMessage(); + TStringStream out; + UNIT_ASSERT_NO_EXCEPTION(SerializeToTextFormat(original, out)); + UNIT_ASSERT_VALUES_EQUAL(out.Str(), CORRECT_MESSAGE); + } + { + NProtobufUtilUt::TTextTest m; const auto f = [&correctFileName](NProtobufUtilUt::TTextTest& mm) { mm = ParseFromTextFormat<NProtobufUtilUt::TTextTest>( correctFileName, EParseFromTextFormatOption::AllowUnknownField); - }; - UNIT_ASSERT_NO_EXCEPTION(f(m)); - UNIT_ASSERT(NProtoBuf::IsEqual(GetCorrectMessage(), m)); - } - { - const NProtobufUtilUt::TTextTest empty; - NProtobufUtilUt::TTextTest m; + }; + UNIT_ASSERT_NO_EXCEPTION(f(m)); + UNIT_ASSERT(NProtoBuf::IsEqual(GetCorrectMessage(), m)); + } + { + const NProtobufUtilUt::TTextTest empty; + NProtobufUtilUt::TTextTest m; const auto f = [&incorrectFileName](NProtobufUtilUt::TTextTest& mm) { mm = ParseFromTextFormat<NProtobufUtilUt::TTextTest>( incorrectFileName, EParseFromTextFormatOption::AllowUnknownField); - }; - UNIT_ASSERT_NO_EXCEPTION(f(m)); - UNIT_ASSERT(NProtoBuf::IsEqual(empty, m)); - } - } - + }; + UNIT_ASSERT_NO_EXCEPTION(f(m)); + UNIT_ASSERT(NProtoBuf::IsEqual(empty, m)); + } + } + Y_UNIT_TEST(TestSerializeToTextFormatWithEnumId) { TTempDir tempDir; const TFsPath correctNameFileName = TFsPath{tempDir()} / "correct_name.pb.txt"; @@ -250,139 +250,139 @@ Y_UNIT_TEST_SUITE(TTestProtoBufIO) { } } - Y_UNIT_TEST(TestMergeFromTextFormat) { - // - // Tests cases below are identical to `Parse` tests - // - TTempDir tempDir; - const TFsPath correctFileName = TFsPath{tempDir()} / "correct.pb.txt"; - const TFsPath incorrectFileName = TFsPath{tempDir()} / "incorrect.pb.txt"; - + Y_UNIT_TEST(TestMergeFromTextFormat) { + // + // Tests cases below are identical to `Parse` tests + // + TTempDir tempDir; + const TFsPath correctFileName = TFsPath{tempDir()} / "correct.pb.txt"; + const TFsPath incorrectFileName = TFsPath{tempDir()} / "incorrect.pb.txt"; + TFileOutput{correctFileName}.Write(CORRECT_MESSAGE); TFileOutput{incorrectFileName}.Write(INCORRECT_MESSAGE); - - { - NProtobufUtilUt::TTextTest message; - UNIT_ASSERT(TryMergeFromTextFormat(correctFileName, message)); - } - { - NProtobufUtilUt::TTextTest message; - UNIT_ASSERT(!TryMergeFromTextFormat(incorrectFileName, message)); - } - { - NProtobufUtilUt::TTextTest message; - TStringInput in{CORRECT_MESSAGE}; - UNIT_ASSERT(TryMergeFromTextFormat(in, message)); - } - { - NProtobufUtilUt::TTextTest message; - TStringInput in{INCORRECT_MESSAGE}; - UNIT_ASSERT(!TryMergeFromTextFormat(in, message)); - } - { - NProtobufUtilUt::TTextTest message; - UNIT_ASSERT_NO_EXCEPTION(TryMergeFromTextFormat(incorrectFileName, message)); - } - { - NProtobufUtilUt::TTextTest message; - UNIT_ASSERT(!TryMergeFromTextFormat("this_file_doesnt_exists", message)); - } - { - NProtobufUtilUt::TTextTest message; - UNIT_ASSERT_NO_EXCEPTION(TryMergeFromTextFormat("this_file_doesnt_exists", message)); - } - { - NProtobufUtilUt::TTextTest message; - UNIT_ASSERT_EXCEPTION(MergeFromTextFormat("this_file_doesnt_exists", message), TFileError); - } - { - NProtobufUtilUt::TTextTest message; - UNIT_ASSERT_NO_EXCEPTION(MergeFromTextFormat(correctFileName, message)); - } - { - NProtobufUtilUt::TTextTest message; - UNIT_ASSERT_EXCEPTION(MergeFromTextFormat(incorrectFileName, message), yexception); - } - { - NProtobufUtilUt::TTextTest message; - TStringInput in{CORRECT_MESSAGE}; - UNIT_ASSERT_NO_EXCEPTION(MergeFromTextFormat(in, message)); - } - { - NProtobufUtilUt::TTextTest message; - TStringInput in{INCORRECT_MESSAGE}; - UNIT_ASSERT_EXCEPTION(MergeFromTextFormat(in, message), yexception); - } - { - NProtobufUtilUt::TTextTest m; - const auto f = [&correctFileName](NProtobufUtilUt::TTextTest& mm) { - mm = MergeFromTextFormat<NProtobufUtilUt::TTextTest>(correctFileName); - }; - UNIT_ASSERT_NO_EXCEPTION(f(m)); - UNIT_ASSERT(NProtoBuf::IsEqual(GetCorrectMessage(), m)); - } - { - UNIT_ASSERT_EXCEPTION(MergeFromTextFormat<NProtobufUtilUt::TTextTest>(incorrectFileName), yexception); - } - { - NProtobufUtilUt::TTextTest m; - TStringInput in{CORRECT_MESSAGE}; - const auto f = [&in](NProtobufUtilUt::TTextTest& mm) { - mm = MergeFromTextFormat<NProtobufUtilUt::TTextTest>(in); - }; - UNIT_ASSERT_NO_EXCEPTION(f(m)); - UNIT_ASSERT(NProtoBuf::IsEqual(GetCorrectMessage(), m)); - } - { - TStringInput in{INCORRECT_MESSAGE}; - UNIT_ASSERT_EXCEPTION(MergeFromTextFormat<NProtobufUtilUt::TTextTest>(in), yexception); - } - { - const TFsPath correctFileName2 = TFsPath{tempDir()} / "serialized.pb.txt"; - const auto original = GetCorrectMessage(); - UNIT_ASSERT_NO_EXCEPTION(SerializeToTextFormat(original, correctFileName2)); + + { + NProtobufUtilUt::TTextTest message; + UNIT_ASSERT(TryMergeFromTextFormat(correctFileName, message)); + } + { + NProtobufUtilUt::TTextTest message; + UNIT_ASSERT(!TryMergeFromTextFormat(incorrectFileName, message)); + } + { + NProtobufUtilUt::TTextTest message; + TStringInput in{CORRECT_MESSAGE}; + UNIT_ASSERT(TryMergeFromTextFormat(in, message)); + } + { + NProtobufUtilUt::TTextTest message; + TStringInput in{INCORRECT_MESSAGE}; + UNIT_ASSERT(!TryMergeFromTextFormat(in, message)); + } + { + NProtobufUtilUt::TTextTest message; + UNIT_ASSERT_NO_EXCEPTION(TryMergeFromTextFormat(incorrectFileName, message)); + } + { + NProtobufUtilUt::TTextTest message; + UNIT_ASSERT(!TryMergeFromTextFormat("this_file_doesnt_exists", message)); + } + { + NProtobufUtilUt::TTextTest message; + UNIT_ASSERT_NO_EXCEPTION(TryMergeFromTextFormat("this_file_doesnt_exists", message)); + } + { + NProtobufUtilUt::TTextTest message; + UNIT_ASSERT_EXCEPTION(MergeFromTextFormat("this_file_doesnt_exists", message), TFileError); + } + { + NProtobufUtilUt::TTextTest message; + UNIT_ASSERT_NO_EXCEPTION(MergeFromTextFormat(correctFileName, message)); + } + { + NProtobufUtilUt::TTextTest message; + UNIT_ASSERT_EXCEPTION(MergeFromTextFormat(incorrectFileName, message), yexception); + } + { + NProtobufUtilUt::TTextTest message; + TStringInput in{CORRECT_MESSAGE}; + UNIT_ASSERT_NO_EXCEPTION(MergeFromTextFormat(in, message)); + } + { + NProtobufUtilUt::TTextTest message; + TStringInput in{INCORRECT_MESSAGE}; + UNIT_ASSERT_EXCEPTION(MergeFromTextFormat(in, message), yexception); + } + { + NProtobufUtilUt::TTextTest m; + const auto f = [&correctFileName](NProtobufUtilUt::TTextTest& mm) { + mm = MergeFromTextFormat<NProtobufUtilUt::TTextTest>(correctFileName); + }; + UNIT_ASSERT_NO_EXCEPTION(f(m)); + UNIT_ASSERT(NProtoBuf::IsEqual(GetCorrectMessage(), m)); + } + { + UNIT_ASSERT_EXCEPTION(MergeFromTextFormat<NProtobufUtilUt::TTextTest>(incorrectFileName), yexception); + } + { + NProtobufUtilUt::TTextTest m; + TStringInput in{CORRECT_MESSAGE}; + const auto f = [&in](NProtobufUtilUt::TTextTest& mm) { + mm = MergeFromTextFormat<NProtobufUtilUt::TTextTest>(in); + }; + UNIT_ASSERT_NO_EXCEPTION(f(m)); + UNIT_ASSERT(NProtoBuf::IsEqual(GetCorrectMessage(), m)); + } + { + TStringInput in{INCORRECT_MESSAGE}; + UNIT_ASSERT_EXCEPTION(MergeFromTextFormat<NProtobufUtilUt::TTextTest>(in), yexception); + } + { + const TFsPath correctFileName2 = TFsPath{tempDir()} / "serialized.pb.txt"; + const auto original = GetCorrectMessage(); + UNIT_ASSERT_NO_EXCEPTION(SerializeToTextFormat(original, correctFileName2)); const auto serializedStr = TUnbufferedFileInput{correctFileName2}.ReadAll(); - UNIT_ASSERT_VALUES_EQUAL(serializedStr, CORRECT_MESSAGE); - } - { - const auto original = GetCorrectMessage(); - TStringStream out; - UNIT_ASSERT_NO_EXCEPTION(SerializeToTextFormat(original, out)); - UNIT_ASSERT_VALUES_EQUAL(out.Str(), CORRECT_MESSAGE); - } - { - NProtobufUtilUt::TTextTest m; - const auto f = [&correctFileName](NProtobufUtilUt::TTextTest& mm) { - mm = MergeFromTextFormat<NProtobufUtilUt::TTextTest>( + UNIT_ASSERT_VALUES_EQUAL(serializedStr, CORRECT_MESSAGE); + } + { + const auto original = GetCorrectMessage(); + TStringStream out; + UNIT_ASSERT_NO_EXCEPTION(SerializeToTextFormat(original, out)); + UNIT_ASSERT_VALUES_EQUAL(out.Str(), CORRECT_MESSAGE); + } + { + NProtobufUtilUt::TTextTest m; + const auto f = [&correctFileName](NProtobufUtilUt::TTextTest& mm) { + mm = MergeFromTextFormat<NProtobufUtilUt::TTextTest>( correctFileName, EParseFromTextFormatOption::AllowUnknownField); - }; - UNIT_ASSERT_NO_EXCEPTION(f(m)); - UNIT_ASSERT(NProtoBuf::IsEqual(GetCorrectMessage(), m)); - } - { - const NProtobufUtilUt::TTextTest empty; - NProtobufUtilUt::TTextTest m; - const auto f = [&incorrectFileName](NProtobufUtilUt::TTextTest& mm) { - mm = MergeFromTextFormat<NProtobufUtilUt::TTextTest>( + }; + UNIT_ASSERT_NO_EXCEPTION(f(m)); + UNIT_ASSERT(NProtoBuf::IsEqual(GetCorrectMessage(), m)); + } + { + const NProtobufUtilUt::TTextTest empty; + NProtobufUtilUt::TTextTest m; + const auto f = [&incorrectFileName](NProtobufUtilUt::TTextTest& mm) { + mm = MergeFromTextFormat<NProtobufUtilUt::TTextTest>( incorrectFileName, EParseFromTextFormatOption::AllowUnknownField); - }; - UNIT_ASSERT_NO_EXCEPTION(f(m)); - UNIT_ASSERT(NProtoBuf::IsEqual(empty, m)); - } - - // - // Test cases for `Merge` - // - { - NProtobufUtilUt::TTextTest message; - message.SetFoo(100500); - TStringInput in{CORRECT_MESSAGE}; - UNIT_ASSERT(TryMergeFromTextFormat(in, message)); - UNIT_ASSERT(NProtoBuf::IsEqual(message, GetCorrectMessage())); - } - } + }; + UNIT_ASSERT_NO_EXCEPTION(f(m)); + UNIT_ASSERT(NProtoBuf::IsEqual(empty, m)); + } + + // + // Test cases for `Merge` + // + { + NProtobufUtilUt::TTextTest message; + message.SetFoo(100500); + TStringInput in{CORRECT_MESSAGE}; + UNIT_ASSERT(TryMergeFromTextFormat(in, message)); + UNIT_ASSERT(NProtoBuf::IsEqual(message, GetCorrectMessage())); + } + } Y_UNIT_TEST(TestMergeFromString) { NProtobufUtilUt::TMergeTest message; @@ -415,4 +415,4 @@ Y_UNIT_TEST_SUITE(TTestProtoBufIO) { UNIT_ASSERT(NProtoBuf::IsEqual(message, m3)); } } -} +} diff --git a/library/cpp/protobuf/util/repeated_field_utils_ut.cpp b/library/cpp/protobuf/util/repeated_field_utils_ut.cpp index 58aaaa9e12f..d8944cad048 100644 --- a/library/cpp/protobuf/util/repeated_field_utils_ut.cpp +++ b/library/cpp/protobuf/util/repeated_field_utils_ut.cpp @@ -5,8 +5,8 @@ using namespace NProtoBuf; -Y_UNIT_TEST_SUITE(RepeatedFieldUtils) { - Y_UNIT_TEST(RemoveIf) { +Y_UNIT_TEST_SUITE(RepeatedFieldUtils) { + Y_UNIT_TEST(RemoveIf) { { NProtobufUtilUt::TWalkTest msg; msg.AddRepInt(0); diff --git a/library/cpp/protobuf/util/simple_reflection.h b/library/cpp/protobuf/util/simple_reflection.h index 61e877a7874..94723d8155f 100644 --- a/library/cpp/protobuf/util/simple_reflection.h +++ b/library/cpp/protobuf/util/simple_reflection.h @@ -145,7 +145,7 @@ namespace NProtoBuf { } /* void Swap(TMutableField& f) { - Y_ASSERT(Field() == f.Field()); + Y_ASSERT(Field() == f.Field()); // not implemented yet, TODO: implement when Reflection::Mutable(Ptr)RepeatedField // is ported into arcadia protobuf library from up-stream. diff --git a/library/cpp/protobuf/util/simple_reflection_ut.cpp b/library/cpp/protobuf/util/simple_reflection_ut.cpp index 169d4703c9c..bd5b32e463b 100644 --- a/library/cpp/protobuf/util/simple_reflection_ut.cpp +++ b/library/cpp/protobuf/util/simple_reflection_ut.cpp @@ -6,7 +6,7 @@ using namespace NProtoBuf; -Y_UNIT_TEST_SUITE(ProtobufSimpleReflection) { +Y_UNIT_TEST_SUITE(ProtobufSimpleReflection) { static TSample GenSampleForMergeFrom() { TSample smf; smf.SetOneStr("one str"); @@ -19,7 +19,7 @@ Y_UNIT_TEST_SUITE(ProtobufSimpleReflection) { return smf; } - Y_UNIT_TEST(MergeFromGeneric) { + Y_UNIT_TEST(MergeFromGeneric) { const TSample src(GenSampleForMergeFrom()); TSample dst; const Descriptor* descr = dst.GetDescriptor(); @@ -51,7 +51,7 @@ Y_UNIT_TEST_SUITE(ProtobufSimpleReflection) { } } - Y_UNIT_TEST(MergeFromSelf) { + Y_UNIT_TEST(MergeFromSelf) { const TSample sample(GenSampleForMergeFrom()); TSample msg(sample); const Descriptor* descr = msg.GetDescriptor(); @@ -65,7 +65,7 @@ Y_UNIT_TEST_SUITE(ProtobufSimpleReflection) { UNIT_ASSERT_VALUES_EQUAL(msg.GetOneMsg().RepIntSize(), sample.GetOneMsg().RepIntSize()); } - Y_UNIT_TEST(MergeFromAnotherFD) { + Y_UNIT_TEST(MergeFromAnotherFD) { const TSample sample(GenSampleForMergeFrom()); TSample msg(GenSampleForMergeFrom()); const Descriptor* descr = msg.GetDescriptor(); @@ -96,7 +96,7 @@ Y_UNIT_TEST_SUITE(ProtobufSimpleReflection) { } } - Y_UNIT_TEST(RemoveByIndex) { + Y_UNIT_TEST(RemoveByIndex) { TSample msg; const Descriptor* descr = msg.GetDescriptor(); @@ -142,7 +142,7 @@ Y_UNIT_TEST_SUITE(ProtobufSimpleReflection) { } } - Y_UNIT_TEST(GetFieldByPath) { + Y_UNIT_TEST(GetFieldByPath) { // Simple get by path { TSample msg; diff --git a/library/cpp/protobuf/util/ut/common_ut.proto b/library/cpp/protobuf/util/ut/common_ut.proto index 9cf803ffbf9..638f13778cd 100644 --- a/library/cpp/protobuf/util/ut/common_ut.proto +++ b/library/cpp/protobuf/util/ut/common_ut.proto @@ -58,10 +58,10 @@ message TMergeTest { repeated TMergeTestMerge NoMergeRepSub = 4 [(DontMergeField)=true]; optional TMergeTestNoMerge NoMergeOptSub = 5; } - -message TTextTest { - optional uint32 Foo = 1; -} + +message TTextTest { + optional uint32 Foo = 1; +} message TTextEnumTest { enum EnumTest { diff --git a/library/cpp/protobuf/util/ut/ya.make b/library/cpp/protobuf/util/ut/ya.make index 701ba9a8c85..c358aac35cc 100644 --- a/library/cpp/protobuf/util/ut/ya.make +++ b/library/cpp/protobuf/util/ut/ya.make @@ -7,7 +7,7 @@ SRCS( sample_for_is_equal.proto sample_for_simple_reflection.proto common_ut.proto - pb_io_ut.cpp + pb_io_ut.cpp is_equal_ut.cpp iterators_ut.cpp simple_reflection_ut.cpp diff --git a/library/cpp/protobuf/util/walk_ut.cpp b/library/cpp/protobuf/util/walk_ut.cpp index 2ea6071b172..319e87983ef 100644 --- a/library/cpp/protobuf/util/walk_ut.cpp +++ b/library/cpp/protobuf/util/walk_ut.cpp @@ -6,7 +6,7 @@ using namespace NProtoBuf; -Y_UNIT_TEST_SUITE(ProtobufWalk) { +Y_UNIT_TEST_SUITE(ProtobufWalk) { static void InitProto(NProtobufUtilUt::TWalkTest & p, int level = 0) { p.SetOptInt(1); p.AddRepInt(2); diff --git a/library/cpp/regex/hyperscan/ut/hyperscan_ut.cpp b/library/cpp/regex/hyperscan/ut/hyperscan_ut.cpp index 9caa53f2e7f..b12985579c4 100644 --- a/library/cpp/regex/hyperscan/ut/hyperscan_ut.cpp +++ b/library/cpp/regex/hyperscan/ut/hyperscan_ut.cpp @@ -7,11 +7,11 @@ #include <array> #include <algorithm> -Y_UNIT_TEST_SUITE(HyperscanWrappers) { +Y_UNIT_TEST_SUITE(HyperscanWrappers) { using namespace NHyperscan; using namespace NHyperscan::NPrivate; - Y_UNIT_TEST(CompileAndScan) { + Y_UNIT_TEST(CompileAndScan) { TDatabase db = Compile("a.c", HS_FLAG_DOTALL | HS_FLAG_SINGLEMATCH); TScratch scratch = MakeScratch(db); @@ -27,7 +27,7 @@ Y_UNIT_TEST_SUITE(HyperscanWrappers) { UNIT_ASSERT_EQUAL(foundId, 0); } - Y_UNIT_TEST(Matches) { + Y_UNIT_TEST(Matches) { NHyperscan::TDatabase db = NHyperscan::Compile( "a.c", HS_FLAG_DOTALL | HS_FLAG_SINGLEMATCH); @@ -36,7 +36,7 @@ Y_UNIT_TEST_SUITE(HyperscanWrappers) { UNIT_ASSERT(!NHyperscan::Matches(db, scratch, "foo")); } - Y_UNIT_TEST(Multi) { + Y_UNIT_TEST(Multi) { NHyperscan::TDatabase db = NHyperscan::CompileMulti( { "foo", @@ -72,7 +72,7 @@ Y_UNIT_TEST_SUITE(HyperscanWrappers) { } // https://ml.yandex-team.ru/thread/2370000002965712422/ - Y_UNIT_TEST(MultiRegression) { + Y_UNIT_TEST(MultiRegression) { NHyperscan::CompileMulti( { "aa.bb/cc.dd", @@ -85,7 +85,7 @@ Y_UNIT_TEST_SUITE(HyperscanWrappers) { }); } - Y_UNIT_TEST(Serialize) { + Y_UNIT_TEST(Serialize) { NHyperscan::TDatabase db = NHyperscan::Compile( "foo", HS_FLAG_DOTALL | HS_FLAG_SINGLEMATCH); @@ -98,7 +98,7 @@ Y_UNIT_TEST_SUITE(HyperscanWrappers) { UNIT_ASSERT(!NHyperscan::Matches(db2, scratch, "FOO")); } - Y_UNIT_TEST(GrowScratch) { + Y_UNIT_TEST(GrowScratch) { NHyperscan::TDatabase db1 = NHyperscan::Compile( "foo", HS_FLAG_DOTALL | HS_FLAG_SINGLEMATCH); @@ -111,7 +111,7 @@ Y_UNIT_TEST_SUITE(HyperscanWrappers) { UNIT_ASSERT(NHyperscan::Matches(db2, scratch, "longerWWWpattern")); } - Y_UNIT_TEST(CloneScratch) { + Y_UNIT_TEST(CloneScratch) { NHyperscan::TDatabase db = NHyperscan::Compile( "foo", HS_FLAG_DOTALL | HS_FLAG_SINGLEMATCH); diff --git a/library/cpp/regex/pcre/regexp_ut.cpp b/library/cpp/regex/pcre/regexp_ut.cpp index 5184e801cc6..3818fe59c30 100644 --- a/library/cpp/regex/pcre/regexp_ut.cpp +++ b/library/cpp/regex/pcre/regexp_ut.cpp @@ -1,6 +1,6 @@ #include <library/cpp/testing/unittest/registar.h> -#include <util/string/strip.h> +#include <util/string/strip.h> #include <library/cpp/regex/pcre/regexp.h> #include <util/stream/output.h> @@ -54,17 +54,17 @@ private: UNIT_TEST_SUITE_END(); inline void TestRe() { - for (const auto& regTest : REGTEST_DATA) { + for (const auto& regTest : REGTEST_DATA) { memset(Matches, 0, sizeof(Matches)); TString result; TRegExBase re(regTest.Regexp, regTest.CompileOptions); if (re.Exec(regTest.Data, Matches, regTest.RunOptions) == 0) { - for (auto& matche : Matches) { - if (matche.rm_so == -1) { + for (auto& matche : Matches) { + if (matche.rm_so == -1) { break; } - result.append(Sprintf("%i %i ", matche.rm_so, matche.rm_eo)); + result.append(Sprintf("%i %i ", matche.rm_so, matche.rm_eo)); } } else { result = "NM"; @@ -75,7 +75,7 @@ private: } inline void TestSubst() { - for (const auto& substTest : SUBSTTEST_DATA) { + for (const auto& substTest : SUBSTTEST_DATA) { TRegExSubst subst(substTest.Regexp, substTest.CompileOptions); subst.ParseReplacement(substTest.Replacement); TString result = subst.Replace(substTest.Data, substTest.RunOptions); diff --git a/library/cpp/regex/pire/regexp.h b/library/cpp/regex/pire/regexp.h index 94bba4064b7..9321863badc 100644 --- a/library/cpp/regex/pire/regexp.h +++ b/library/cpp/regex/pire/regexp.h @@ -58,8 +58,8 @@ namespace NRegExp { size_t outWritten = 0; int recodeRes = RecodeToUnicode(opts.Charset, regexp.data(), ucs4.data(), regexp.size(), regexp.size(), inRead, outWritten); - Y_ASSERT(recodeRes == RECODE_OK); - Y_ASSERT(outWritten < ucs4.size()); + Y_ASSERT(recodeRes == RECODE_OK); + Y_ASSERT(outWritten < ucs4.size()); ucs4[outWritten] = 0; lexer.Assign(ucs4.begin(), diff --git a/library/cpp/regex/pire/ut/regexp_ut.cpp b/library/cpp/regex/pire/ut/regexp_ut.cpp index e7206de9ad4..0bb72b3fde5 100644 --- a/library/cpp/regex/pire/ut/regexp_ut.cpp +++ b/library/cpp/regex/pire/ut/regexp_ut.cpp @@ -3,20 +3,20 @@ #include <library/cpp/regex/pire/regexp.h> #include <library/cpp/regex/pire/pcre2pire.h> -Y_UNIT_TEST_SUITE(TRegExp) { +Y_UNIT_TEST_SUITE(TRegExp) { using namespace NRegExp; - Y_UNIT_TEST(False) { + Y_UNIT_TEST(False) { UNIT_ASSERT(!TMatcher(TFsm::False()).Match("").Final()); UNIT_ASSERT(!TMatcher(TFsm::False()).Match(TStringBuf{}).Final()); } - Y_UNIT_TEST(Surround) { + Y_UNIT_TEST(Surround) { UNIT_ASSERT(TMatcher(TFsm("qw", TFsm::TOptions().SetSurround(true))).Match("aqwb").Final()); UNIT_ASSERT(!TMatcher(TFsm("qw", TFsm::TOptions().SetSurround(false))).Match("aqwb").Final()); } - Y_UNIT_TEST(Boundaries) { + Y_UNIT_TEST(Boundaries) { UNIT_ASSERT(!TMatcher(TFsm("qwb$", TFsm::TOptions().SetSurround(true))).Match("aqwb").Final()); UNIT_ASSERT(!TMatcher(TFsm("^aqw", TFsm::TOptions().SetSurround(true))).Match("aqwb").Final()); UNIT_ASSERT(TMatcher(TFsm("qwb$", TFsm::TOptions().SetSurround(true))).Match(TStringBuf("aqwb"), true, true).Final()); @@ -32,7 +32,7 @@ Y_UNIT_TEST_SUITE(TRegExp) { .Final()); } - Y_UNIT_TEST(Case) { + Y_UNIT_TEST(Case) { UNIT_ASSERT(TMatcher(TFsm("qw", TFsm::TOptions().SetCaseInsensitive(true))).Match("Qw").Final()); UNIT_ASSERT(!TMatcher(TFsm("qw", TFsm::TOptions().SetCaseInsensitive(false))).Match("Qw").Final()); } @@ -42,7 +42,7 @@ Y_UNIT_TEST_SUITE(TRegExp) { UNIT_ASSERT(!TMatcher(TFsm("\\x{61}\\x{62}", TFsm::TOptions().SetCaseInsensitive(false))).Match("Ab").Final()); } - Y_UNIT_TEST(Utf) { + Y_UNIT_TEST(Utf) { NRegExp::TFsmBase::TOptions opts; opts.Charset = CODES_UTF8; opts.Surround = true; @@ -83,7 +83,7 @@ Y_UNIT_TEST_SUITE(TRegExp) { } } - Y_UNIT_TEST(Glue) { + Y_UNIT_TEST(Glue) { TFsm glued = TFsm("qw", TFsm::TOptions().SetCaseInsensitive(true)) | TFsm("qw", TFsm::TOptions().SetCaseInsensitive(false)) | @@ -94,7 +94,7 @@ Y_UNIT_TEST_SUITE(TRegExp) { UNIT_ASSERT(!TMatcher(glued).Match("Abc").Final()); } - Y_UNIT_TEST(Capture1) { + Y_UNIT_TEST(Capture1) { TCapturingFsm fsm("here we have user_id=([a-z0-9]+);"); TSearcher searcher(fsm); @@ -103,7 +103,7 @@ Y_UNIT_TEST_SUITE(TRegExp) { UNIT_ASSERT_VALUES_EQUAL(searcher.GetCaptured(), TStringBuf("0x0d0a")); } - Y_UNIT_TEST(Capture2) { + Y_UNIT_TEST(Capture2) { TCapturingFsm fsm("w([abcdez]+)f"); TSearcher searcher(fsm); @@ -112,7 +112,7 @@ Y_UNIT_TEST_SUITE(TRegExp) { UNIT_ASSERT_VALUES_EQUAL(searcher.GetCaptured(), TStringBuf("abcde")); } - Y_UNIT_TEST(Capture3) { + Y_UNIT_TEST(Capture3) { TCapturingFsm fsm("http://vk(ontakte[.]ru|[.]com)/id(\\d+)([^0-9]|$)", TFsm::TOptions().SetCapture(2)); @@ -122,7 +122,7 @@ Y_UNIT_TEST_SUITE(TRegExp) { UNIT_ASSERT_VALUES_EQUAL(searcher.GetCaptured(), TStringBuf("100500")); } - Y_UNIT_TEST(Capture4) { + Y_UNIT_TEST(Capture4) { TCapturingFsm fsm("Здравствуйте, ((\\s|\\w|[()]|-)+)!", TFsm::TOptions().SetCharset(CODES_UTF8)); @@ -132,7 +132,7 @@ Y_UNIT_TEST_SUITE(TRegExp) { UNIT_ASSERT_VALUES_EQUAL(searcher.GetCaptured(), TStringBuf("Уважаемый (-ая)")); } - Y_UNIT_TEST(Capture5) { + Y_UNIT_TEST(Capture5) { TCapturingFsm fsm("away\\.php\\?to=http:([^\"])+\""); TSearcher searcher(fsm); searcher.Search("\"/away.php?to=http:some.addr\"&id=1"); @@ -140,7 +140,7 @@ Y_UNIT_TEST_SUITE(TRegExp) { //UNIT_ASSERT_VALUES_EQUAL(searcher.GetCaptured(), TStringBuf("some.addr")); } - Y_UNIT_TEST(Capture6) { + Y_UNIT_TEST(Capture6) { TCapturingFsm fsm("(/to-match-with)"); TSearcher searcher(fsm); searcher.Search("/some/table/path/to-match-with"); @@ -148,7 +148,7 @@ Y_UNIT_TEST_SUITE(TRegExp) { UNIT_ASSERT_VALUES_EQUAL(searcher.GetCaptured(), TStringBuf("/to-match-with")); } - Y_UNIT_TEST(Capture7) { + Y_UNIT_TEST(Capture7) { TCapturingFsm fsm("(pref.*suff)"); TSearcher searcher(fsm); searcher.Search("ala pref bla suff cla"); @@ -305,7 +305,7 @@ Y_UNIT_TEST_SUITE(TRegExp) { UNIT_ASSERT(!searcher.Captured()); } - Y_UNIT_TEST(Pcre2PireTest) { + Y_UNIT_TEST(Pcre2PireTest) { UNIT_ASSERT_VALUES_EQUAL(Pcre2Pire("(?:fake)"), "(fake)"); UNIT_ASSERT_VALUES_EQUAL(Pcre2Pire("(?:fake)??"), "(fake)?"); UNIT_ASSERT_VALUES_EQUAL(Pcre2Pire("(?:fake)*?fake"), "(fake)*fake"); diff --git a/library/cpp/resource/registry.cpp b/library/cpp/resource/registry.cpp index 66001c47693..f9e4ca0bf7f 100644 --- a/library/cpp/resource/registry.cpp +++ b/library/cpp/resource/registry.cpp @@ -69,8 +69,8 @@ namespace { } void FindMatch(const TStringBuf subkey, IMatch& cb) const override { - for (const auto& it : *this) { - if (it.first.StartsWith(subkey)) { + for (const auto& it : *this) { + if (it.first.StartsWith(subkey)) { // temporary // https://st.yandex-team.ru/DEVTOOLS-3985 try { diff --git a/library/cpp/resource/ut/resource_ut.cpp b/library/cpp/resource/ut/resource_ut.cpp index b6fa8e4df39..68b34485cfa 100644 --- a/library/cpp/resource/ut/resource_ut.cpp +++ b/library/cpp/resource/ut/resource_ut.cpp @@ -1,8 +1,8 @@ #include <library/cpp/resource/resource.h> #include <library/cpp/testing/unittest/registar.h> -Y_UNIT_TEST_SUITE(TestResource) { - Y_UNIT_TEST(Test1) { +Y_UNIT_TEST_SUITE(TestResource) { + Y_UNIT_TEST(Test1) { UNIT_ASSERT_VALUES_EQUAL(NResource::Find("/x"), "na gorshke sidel korol\n"); } } diff --git a/library/cpp/retry/retry.h b/library/cpp/retry/retry.h index c47ff5070fe..63a2b38967b 100644 --- a/library/cpp/retry/retry.h +++ b/library/cpp/retry/retry.h @@ -128,6 +128,6 @@ void DoWithRetry(std::function<void()> func, TRetryOptions retryOptions); bool DoWithRetryOnRetCode(std::function<bool()> func, TRetryOptions retryOptions); -Y_DECLARE_PODTYPE(TRetryOptions); +Y_DECLARE_PODTYPE(TRetryOptions); TRetryOptions MakeRetryOptions(const NRetry::TRetryOptionsPB& retryOptions); diff --git a/library/cpp/retry/retry_ut.cpp b/library/cpp/retry/retry_ut.cpp index 92153e987eb..c9cbb72a50f 100644 --- a/library/cpp/retry/retry_ut.cpp +++ b/library/cpp/retry/retry_ut.cpp @@ -27,8 +27,8 @@ namespace { }; } -Y_UNIT_TEST_SUITE(Retry) { - Y_UNIT_TEST(RetryOnExceptionSuccess) { +Y_UNIT_TEST_SUITE(Retry) { + Y_UNIT_TEST(RetryOnExceptionSuccess) { UNIT_ASSERT_NO_EXCEPTION(DoWithRetry(TDoOnSecondOrThrow{}, TRetryOptions(1, TDuration::Zero()))); } Y_UNIT_TEST(RetryOnExceptionSuccessWithOnFail) { @@ -37,7 +37,7 @@ Y_UNIT_TEST_SUITE(Retry) { UNIT_ASSERT_NO_EXCEPTION(DoWithRetry<ui32>(TDoOnSecondOrThrow{}, cb, TRetryOptions(1, TDuration::Zero()), true)); UNIT_ASSERT_EQUAL(value, 1); } - Y_UNIT_TEST(RetryOnExceptionFail) { + Y_UNIT_TEST(RetryOnExceptionFail) { UNIT_ASSERT_EXCEPTION(DoWithRetry(TDoOnSecondOrThrow{}, TRetryOptions(0, TDuration::Zero())), yexception); } Y_UNIT_TEST(RetryOnExceptionFailWithOnFail) { @@ -47,7 +47,7 @@ Y_UNIT_TEST_SUITE(Retry) { UNIT_ASSERT_EQUAL(value, 1); } - Y_UNIT_TEST(RetryOnExceptionSuccessWithValue) { + Y_UNIT_TEST(RetryOnExceptionSuccessWithValue) { std::function<ui32()> f = TDoOnSecondOrThrow{}; UNIT_ASSERT(42 == *DoWithRetry<ui32>(f, TRetryOptions(1, TDuration::Zero()), false)); } @@ -58,7 +58,7 @@ Y_UNIT_TEST_SUITE(Retry) { UNIT_ASSERT(42 == *DoWithRetry<ui32>(f, cb, TRetryOptions(1, TDuration::Zero()), false)); UNIT_ASSERT_EQUAL(value, 1); } - Y_UNIT_TEST(RetryOnExceptionFailWithValue) { + Y_UNIT_TEST(RetryOnExceptionFailWithValue) { std::function<ui32()> f = TDoOnSecondOrThrow{}; UNIT_ASSERT(!DoWithRetry<ui32>(f, TRetryOptions(0, TDuration::Zero()), false).Defined()); } @@ -70,7 +70,7 @@ Y_UNIT_TEST_SUITE(Retry) { UNIT_ASSERT_EQUAL(value, 1); } - Y_UNIT_TEST(RetryOnExceptionSuccessWithValueAndRethrow) { + Y_UNIT_TEST(RetryOnExceptionSuccessWithValueAndRethrow) { std::function<ui32()> f = TDoOnSecondOrThrow{}; UNIT_ASSERT(42 == *DoWithRetry<ui32>(f, TRetryOptions(1, TDuration::Zero()), true)); } @@ -81,7 +81,7 @@ Y_UNIT_TEST_SUITE(Retry) { UNIT_ASSERT(42 == *DoWithRetry<ui32>(f, cb, TRetryOptions(1, TDuration::Zero()), true)); UNIT_ASSERT_EQUAL(value, 1); } - Y_UNIT_TEST(RetryOnExceptionFailWithValueAndRethrow) { + Y_UNIT_TEST(RetryOnExceptionFailWithValueAndRethrow) { std::function<ui32()> f = TDoOnSecondOrThrow{}; UNIT_ASSERT_EXCEPTION(DoWithRetry<ui32>(f, TRetryOptions(0, TDuration::Zero()), true), yexception); } @@ -93,10 +93,10 @@ Y_UNIT_TEST_SUITE(Retry) { UNIT_ASSERT_EQUAL(value, 1); } - Y_UNIT_TEST(RetryOnRetCodeSuccess) { + Y_UNIT_TEST(RetryOnRetCodeSuccess) { UNIT_ASSERT(true == DoWithRetryOnRetCode(TDoOnSecondOrFail{}, TRetryOptions(1, TDuration::Zero()))); } - Y_UNIT_TEST(RetryOnRetCodeFail) { + Y_UNIT_TEST(RetryOnRetCodeFail) { UNIT_ASSERT(false == DoWithRetryOnRetCode(TDoOnSecondOrFail{}, TRetryOptions(0, TDuration::Zero()))); } Y_UNIT_TEST(MakeRetryOptionsFromProto) { diff --git a/library/cpp/scheme/scheme.cpp b/library/cpp/scheme/scheme.cpp index 3efd116d4f1..9ecdb4ac76e 100644 --- a/library/cpp/scheme/scheme.cpp +++ b/library/cpp/scheme/scheme.cpp @@ -593,6 +593,6 @@ namespace NSc { } template <> -void Out<NSc::TValue>(IOutputStream& o, TTypeTraits<NSc::TValue>::TFuncParam v) { +void Out<NSc::TValue>(IOutputStream& o, TTypeTraits<NSc::TValue>::TFuncParam v) { o.Write(v.ToJson(true)); } diff --git a/library/cpp/scheme/scheme.h b/library/cpp/scheme/scheme.h index 3d7c59f3c97..93ea9e24e40 100644 --- a/library/cpp/scheme/scheme.h +++ b/library/cpp/scheme/scheme.h @@ -302,15 +302,15 @@ namespace NSc { // TODO: Переименовать ToJson в ToJsonUnsafe, а ToJsonSafe в ToJson TString ToJson(const TJsonOpts& = TJsonOpts()) const; - const TValue& ToJson(IOutputStream&, const TJsonOpts& = TJsonOpts()) const; // returns self + const TValue& ToJson(IOutputStream&, const TJsonOpts& = TJsonOpts()) const; // returns self // ToJson(JO_SORT_KEYS | JO_SKIP_UNSAFE) TString ToJsonSafe(const TJsonOpts& = TJsonOpts()) const; - const TValue& ToJsonSafe(IOutputStream&, const TJsonOpts& = TJsonOpts()) const; + const TValue& ToJsonSafe(IOutputStream&, const TJsonOpts& = TJsonOpts()) const; // ToJson(JO_SORT_KEYS | JO_PRETTY | JO_SKIP_UNSAFE) TString ToJsonPretty(const TJsonOpts& = TJsonOpts()) const; - const TValue& ToJsonPretty(IOutputStream&, const TJsonOpts& = TJsonOpts()) const; + const TValue& ToJsonPretty(IOutputStream&, const TJsonOpts& = TJsonOpts()) const; NJson::TJsonValue ToJsonValue() const; @@ -400,7 +400,7 @@ namespace NSc { return DefaultValue(); } - void DoWriteJsonImpl(IOutputStream&, const TJsonOpts&, NImpl::TKeySortContext&, NImpl::TSelfLoopContext&) const; + void DoWriteJsonImpl(IOutputStream&, const TJsonOpts&, NImpl::TKeySortContext&, NImpl::TSelfLoopContext&) const; bool IsSameOrAncestorOf(const TValue& other) const; diff --git a/library/cpp/scheme/scheme_cast.h b/library/cpp/scheme/scheme_cast.h index 00839e8017c..0fa1242da5f 100644 --- a/library/cpp/scheme/scheme_cast.h +++ b/library/cpp/scheme/scheme_cast.h @@ -161,13 +161,13 @@ namespace NJsonConverters { typedef typename T::key_type TKey; typedef typename T::mapped_type TMapped; if (validate) - Y_ENSURE(x.IsDict() || x.IsNull(), "not valid input scheme"); + Y_ENSURE(x.IsDict() || x.IsNull(), "not valid input scheme"); out.clear(); if (x.IsDict()) { const NSc::TDict& dict = x.GetDict(); - for (const auto& it : dict) { - TKey key = NJsonConverters::FromString<TKey>(it.first, validate); - TMapped val = NJsonConverters::FromTValue<TMapped>(it.second, validate); + for (const auto& it : dict) { + TKey key = NJsonConverters::FromString<TKey>(it.first, validate); + TMapped val = NJsonConverters::FromTValue<TMapped>(it.second, validate); out.insert(std::pair<TKey, TMapped>(key, val)); } } @@ -187,13 +187,13 @@ namespace NJsonConverters { void FromTValueSet(const NSc::TValue& x, T& out, const bool validate) { typedef typename T::key_type TKey; if (validate) - Y_ENSURE(x.IsDict() || x.IsNull(), "not valid input scheme"); + Y_ENSURE(x.IsDict() || x.IsNull(), "not valid input scheme"); out.clear(); if (x.IsDict()) { const NSc::TDict& dict = x.GetDict(); - for (const auto& it : dict) { + for (const auto& it : dict) { TKey key; - NJsonConverters::FromString<TKey>(it.first, key, validate); + NJsonConverters::FromString<TKey>(it.first, key, validate); out.insert(key); } } @@ -215,14 +215,14 @@ namespace NJsonConverters { template <typename T, typename A> void FromTValue(const NSc::TValue& x, TVector<T, A>& out, const bool validate) { if (validate) - Y_ENSURE(x.IsArray() || x.IsNull(), "not valid input scheme"); + Y_ENSURE(x.IsArray() || x.IsNull(), "not valid input scheme"); out.clear(); if (x.IsArray()) { const NSc::TArray& arr = x.GetArray(); out.reserve(arr.size()); - for (const auto& it : arr) { + for (const auto& it : arr) { T val; - NJsonConverters::FromTValue(it, val, validate); + NJsonConverters::FromTValue(it, val, validate); out.push_back(val); } } @@ -289,7 +289,7 @@ namespace NJsonConverters { template <class T1, class T2> void FromTValue(const NSc::TValue& x, std::pair<T1, T2>& out, const bool validate) { if (validate) - Y_ENSURE(x.IsArray() || x.IsNull(), "not valid input scheme"); + Y_ENSURE(x.IsArray() || x.IsNull(), "not valid input scheme"); if (x.IsArray()) { const NSc::TArray& arr = x.GetArray(); if (arr.size() == 2) { diff --git a/library/cpp/scheme/scimpl_json_write.cpp b/library/cpp/scheme/scimpl_json_write.cpp index aadd7e6cd5f..f792851098b 100644 --- a/library/cpp/scheme/scimpl_json_write.cpp +++ b/library/cpp/scheme/scimpl_json_write.cpp @@ -18,7 +18,7 @@ namespace NSc { return IsFinite(d); } - static inline void WriteString(IOutputStream& out, TStringBuf s) { + static inline void WriteString(IOutputStream& out, TStringBuf s) { NEscJ::EscapeJ<true, true>(s, out); } @@ -39,7 +39,7 @@ namespace NSc { } template <typename TDictKeys> - static inline void WriteDict(IOutputStream& out, const TDictKeys& keys, const TDict& dict, + static inline void WriteDict(IOutputStream& out, const TDictKeys& keys, const TDict& dict, const TJsonOpts& jopts, NImpl::TKeySortContext& sortCtx, NImpl::TSelfLoopContext& loopCtx) { using const_iterator = typename TDictKeys::const_iterator; const_iterator begin = keys.begin(); @@ -63,7 +63,7 @@ namespace NSc { } } - void TValue::DoWriteJsonImpl(IOutputStream& out, const TJsonOpts& jopts, + void TValue::DoWriteJsonImpl(IOutputStream& out, const TJsonOpts& jopts, NImpl::TKeySortContext& sortCtx, NImpl::TSelfLoopContext& loopCtx) const { const TScCore& core = Core(); @@ -140,7 +140,7 @@ namespace NSc { } } - const TValue& TValue::ToJson(IOutputStream& out, const TJsonOpts& jopts) const { + const TValue& TValue::ToJson(IOutputStream& out, const TJsonOpts& jopts) const { using namespace NImpl; if (jopts.FormatJson) { @@ -179,7 +179,7 @@ namespace NSc { return ToJson(MakeOptsSafeForSerializer(jopts)); } - const TValue& TValue::ToJsonSafe(IOutputStream& out, const TJsonOpts& jopts) const { + const TValue& TValue::ToJsonSafe(IOutputStream& out, const TJsonOpts& jopts) const { return ToJson(out, MakeOptsSafeForSerializer(jopts)); } @@ -187,7 +187,7 @@ namespace NSc { return ToJson(MakeOptsPrettyForSerializer(jopts)); } - const TValue& TValue::ToJsonPretty(IOutputStream& out, const TJsonOpts& jopts) const { + const TValue& TValue::ToJsonPretty(IOutputStream& out, const TJsonOpts& jopts) const { return ToJson(out, MakeOptsPrettyForSerializer(jopts)); } } diff --git a/library/cpp/scheme/tests/ut/scheme_cast_ut.cpp b/library/cpp/scheme/tests/ut/scheme_cast_ut.cpp index 4f907157e92..b2eb7226b4f 100644 --- a/library/cpp/scheme/tests/ut/scheme_cast_ut.cpp +++ b/library/cpp/scheme/tests/ut/scheme_cast_ut.cpp @@ -16,8 +16,8 @@ using THSI = THashSet<int>; using TSI = TSet<int>; using TPI = std::pair<int, int>; -Y_UNIT_TEST_SUITE(TSchemeCastTest) { - Y_UNIT_TEST(TestYVector) { +Y_UNIT_TEST_SUITE(TSchemeCastTest) { + Y_UNIT_TEST(TestYVector) { TVI v; for (int i = 0; i < 3; ++i) v.push_back(i); @@ -29,7 +29,7 @@ Y_UNIT_TEST_SUITE(TSchemeCastTest) { UNIT_ASSERT(std::equal(v.begin(), v.end(), y.begin())); } - Y_UNIT_TEST(TestYHash) { + Y_UNIT_TEST(TestYHash) { THI h; for (int i = 0; i < 3; ++i) h[i] = i * i; @@ -41,7 +41,7 @@ Y_UNIT_TEST_SUITE(TSchemeCastTest) { UNIT_ASSERT_VALUES_EQUAL(ToJson(h2, true), ToJson(h, true)); } - Y_UNIT_TEST(TestYMap) { + Y_UNIT_TEST(TestYMap) { TMI h; for (int i = 0; i < 3; ++i) h[i] = i * i; @@ -53,7 +53,7 @@ Y_UNIT_TEST_SUITE(TSchemeCastTest) { UNIT_ASSERT_VALUES_EQUAL(ToJson(h2, true), ToJson(h, true)); } - Y_UNIT_TEST(TestYHashSet) { + Y_UNIT_TEST(TestYHashSet) { THSI h; for (int i = 0; i < 3; ++i) h.insert(i * i); @@ -65,7 +65,7 @@ Y_UNIT_TEST_SUITE(TSchemeCastTest) { UNIT_ASSERT_VALUES_EQUAL(ToJson(h2, true), ToJson(h, true)); } - Y_UNIT_TEST(TestYSet) { + Y_UNIT_TEST(TestYSet) { TSI h; for (int i = 0; i < 3; ++i) h.insert(i * i); @@ -77,7 +77,7 @@ Y_UNIT_TEST_SUITE(TSchemeCastTest) { UNIT_ASSERT_VALUES_EQUAL(ToJson(h2, true), ToJson(h, true)); } - Y_UNIT_TEST(TestTPair) { + Y_UNIT_TEST(TestTPair) { TPI p(1, 1); const TString etalon = "[1,1]"; @@ -113,7 +113,7 @@ Y_UNIT_TEST_SUITE(TSchemeCastTest) { } }; - Y_UNIT_TEST(TestTCustom) { + Y_UNIT_TEST(TestTCustom) { TCustom x(2, 3); const TString etalon = "{\"a\":2,\"b\":3}"; @@ -123,7 +123,7 @@ Y_UNIT_TEST_SUITE(TSchemeCastTest) { UNIT_ASSERT_VALUES_EQUAL(ToJson(x2, true), ToJson(x, true)); } - Y_UNIT_TEST(TestVectorOfPairs) { + Y_UNIT_TEST(TestVectorOfPairs) { typedef TVector<TPI> TVPI; TVPI v; @@ -137,7 +137,7 @@ Y_UNIT_TEST_SUITE(TSchemeCastTest) { UNIT_ASSERT_VALUES_EQUAL(ToJson(v2, true), ToJson(v, true)); } - Y_UNIT_TEST(TestSetOfCustom) { + Y_UNIT_TEST(TestSetOfCustom) { typedef TSet<TCustom> TSC; TSC s; s.insert(TCustom(2, 3)); @@ -149,7 +149,7 @@ Y_UNIT_TEST_SUITE(TSchemeCastTest) { UNIT_ASSERT_VALUES_EQUAL(ToJson(s2, true), ToJson(s, true)); } - Y_UNIT_TEST(TestExceptions) { + Y_UNIT_TEST(TestExceptions) { NSc::TValue v = 1; const TString json = v.ToJson(); UNIT_ASSERT_EXCEPTION(FromJson<TVI>(json, true), yexception); diff --git a/library/cpp/sliding_window/sliding_window_ut.cpp b/library/cpp/sliding_window/sliding_window_ut.cpp index 1e7343a8d3d..3b2366791a4 100644 --- a/library/cpp/sliding_window/sliding_window_ut.cpp +++ b/library/cpp/sliding_window/sliding_window_ut.cpp @@ -4,8 +4,8 @@ using namespace NSlidingWindow; -Y_UNIT_TEST_SUITE(TSlidingWindowTest) { - Y_UNIT_TEST(TestSlidingWindowMax) { +Y_UNIT_TEST_SUITE(TSlidingWindowTest) { + Y_UNIT_TEST(TestSlidingWindowMax) { TSlidingWindow<TMaxOperation<unsigned>> w(TDuration::Minutes(5), 5); TInstant start = TInstant::MicroSeconds(TDuration::Hours(1).MicroSeconds()); TInstant now = start; @@ -46,7 +46,7 @@ Y_UNIT_TEST_SUITE(TSlidingWindowTest) { UNIT_ASSERT_VALUES_EQUAL(w.Update(now), 0); } - Y_UNIT_TEST(TestSlidingWindowMin) { + Y_UNIT_TEST(TestSlidingWindowMin) { TSlidingWindow<TMinOperation<unsigned>> w(TDuration::Minutes(5), 5); TInstant start = TInstant::MicroSeconds(TDuration::Hours(1).MicroSeconds()); TInstant now = start; @@ -87,7 +87,7 @@ Y_UNIT_TEST_SUITE(TSlidingWindowTest) { UNIT_ASSERT_VALUES_EQUAL(w.Update(now), std::numeric_limits<unsigned>::max()); } - Y_UNIT_TEST(TestSlidingWindowSum) { + Y_UNIT_TEST(TestSlidingWindowSum) { TSlidingWindow<TSumOperation<unsigned>> w(TDuration::Minutes(5), 5); UNIT_ASSERT_VALUES_EQUAL(w.GetValue(), 0); // current sum diff --git a/library/cpp/streams/brotli/brotli_ut.cpp b/library/cpp/streams/brotli/brotli_ut.cpp index aeb2e284dc3..6dcec657b15 100644 --- a/library/cpp/streams/brotli/brotli_ut.cpp +++ b/library/cpp/streams/brotli/brotli_ut.cpp @@ -4,7 +4,7 @@ #include <util/random/fast.h> -Y_UNIT_TEST_SUITE(TBrotliTestSuite) { +Y_UNIT_TEST_SUITE(TBrotliTestSuite) { TString Compress(TString data) { TString compressed; TStringOutput output(compressed); @@ -37,7 +37,7 @@ Y_UNIT_TEST_SUITE(TBrotliTestSuite) { return result; } - Y_UNIT_TEST(TestHelloWorld) { + Y_UNIT_TEST(TestHelloWorld) { TestCase("hello world"); } @@ -58,7 +58,7 @@ Y_UNIT_TEST_SUITE(TBrotliTestSuite) { } } - Y_UNIT_TEST(TestSeveralStreams) { + Y_UNIT_TEST(TestSeveralStreams) { auto s1 = GenerateRandomString(1 << 15); auto s2 = GenerateRandomString(1 << 15); auto c1 = Compress(s1); @@ -66,24 +66,24 @@ Y_UNIT_TEST_SUITE(TBrotliTestSuite) { UNIT_ASSERT_VALUES_EQUAL(s1 + s2, Decompress(c1 + c2)); } - Y_UNIT_TEST(TestIncompleteStream) { + Y_UNIT_TEST(TestIncompleteStream) { TString manyAs(64 * 1024, 'a'); auto compressed = Compress(manyAs); TString truncated(compressed.data(), compressed.size() - 1); UNIT_CHECK_GENERATED_EXCEPTION(Decompress(truncated), std::exception); } - Y_UNIT_TEST(Test64KB) { + Y_UNIT_TEST(Test64KB) { auto manyAs = TString(64 * 1024, 'a'); TString str("Hello from the Matrix!@#% How are you?}{\n\t\a"); TestCase(manyAs + str + manyAs); } - Y_UNIT_TEST(Test1MB) { + Y_UNIT_TEST(Test1MB) { TestCase(GenerateRandomString(1 * 1024 * 1024)); } - Y_UNIT_TEST(TestEmpty) { + Y_UNIT_TEST(TestEmpty) { TestCase(""); } } diff --git a/library/cpp/streams/bzip2/bzip2.cpp b/library/cpp/streams/bzip2/bzip2.cpp index bccc5c68078..1fcb31c99c7 100644 --- a/library/cpp/streams/bzip2/bzip2.cpp +++ b/library/cpp/streams/bzip2/bzip2.cpp @@ -7,7 +7,7 @@ class TBZipDecompress::TImpl: public TAdditionalStorage<TImpl> { public: - inline TImpl(IInputStream* input) + inline TImpl(IInputStream* input) : Stream_(input) { Zero(BzStream_); @@ -70,11 +70,11 @@ public: } private: - IInputStream* Stream_; + IInputStream* Stream_; bz_stream BzStream_; }; -TBZipDecompress::TBZipDecompress(IInputStream* input, size_t bufLen) +TBZipDecompress::TBZipDecompress(IInputStream* input, size_t bufLen) : Impl_(new (bufLen) TImpl(input)) { } @@ -88,7 +88,7 @@ size_t TBZipDecompress::DoRead(void* buf, size_t size) { class TBZipCompress::TImpl: public TAdditionalStorage<TImpl> { public: - inline TImpl(IOutputStream* stream, size_t level) + inline TImpl(IOutputStream* stream, size_t level) : Stream_(stream) { Zero(BzStream_); @@ -165,11 +165,11 @@ private: } private: - IOutputStream* Stream_; + IOutputStream* Stream_; bz_stream BzStream_; }; -TBZipCompress::TBZipCompress(IOutputStream* out, size_t compressionLevel, size_t bufLen) +TBZipCompress::TBZipCompress(IOutputStream* out, size_t compressionLevel, size_t bufLen) : Impl_(new (bufLen) TImpl(out, compressionLevel)) { } diff --git a/library/cpp/streams/bzip2/bzip2.h b/library/cpp/streams/bzip2/bzip2.h index 2322277ef6f..1271b976dfe 100644 --- a/library/cpp/streams/bzip2/bzip2.h +++ b/library/cpp/streams/bzip2/bzip2.h @@ -22,9 +22,9 @@ class TBZipDecompressError: public TBZipException { class TBZipCompressError: public TBZipException { }; -class TBZipDecompress: public IInputStream { +class TBZipDecompress: public IInputStream { public: - TBZipDecompress(IInputStream* input, size_t bufLen = BZIP_BUF_LEN); + TBZipDecompress(IInputStream* input, size_t bufLen = BZIP_BUF_LEN); ~TBZipDecompress() override; private: @@ -35,9 +35,9 @@ private: THolder<TImpl> Impl_; }; -class TBZipCompress: public IOutputStream { +class TBZipCompress: public IOutputStream { public: - TBZipCompress(IOutputStream* out, size_t compressionLevel = BZIP_COMPRESSION_LEVEL, size_t bufLen = BZIP_BUF_LEN); + TBZipCompress(IOutputStream* out, size_t compressionLevel = BZIP_COMPRESSION_LEVEL, size_t bufLen = BZIP_BUF_LEN); ~TBZipCompress() override; private: diff --git a/library/cpp/streams/bzip2/bzip2_ut.cpp b/library/cpp/streams/bzip2/bzip2_ut.cpp index 69a98f296cd..cb7e11d099b 100644 --- a/library/cpp/streams/bzip2/bzip2_ut.cpp +++ b/library/cpp/streams/bzip2/bzip2_ut.cpp @@ -7,10 +7,10 @@ #define ZDATA "./zdata" -Y_UNIT_TEST_SUITE(TBZipTest) { +Y_UNIT_TEST_SUITE(TBZipTest) { static const TString data = "8s7d5vc6s5vc67sa4c65ascx6asd4xcv76adsfxv76s"; - Y_UNIT_TEST(TestCompress) { + Y_UNIT_TEST(TestCompress) { TUnbufferedFileOutput o(ZDATA); TBZipCompress c(&o); @@ -19,7 +19,7 @@ Y_UNIT_TEST_SUITE(TBZipTest) { o.Finish(); } - Y_UNIT_TEST(TestDecompress) { + Y_UNIT_TEST(TestDecompress) { TTempFile tmp(ZDATA); { @@ -30,7 +30,7 @@ Y_UNIT_TEST_SUITE(TBZipTest) { } } - Y_UNIT_TEST(TestCorrupted) { + Y_UNIT_TEST(TestCorrupted) { TMemoryInput i("blablabla", 10); TBZipDecompress d(&i); diff --git a/library/cpp/streams/lz/lz.cpp b/library/cpp/streams/lz/lz.cpp index b65bb3ed965..2bfa93a4aa6 100644 --- a/library/cpp/streams/lz/lz.cpp +++ b/library/cpp/streams/lz/lz.cpp @@ -32,7 +32,7 @@ const size_t SIGNATURE_SIZE = 4; template <class TCompressor, class TBase> class TCompressorBase: public TAdditionalStorage<TCompressorBase<TCompressor, TBase>>, public TCompressor, public TCommonData { public: - inline TCompressorBase(IOutputStream* slave, ui16 blockSize) + inline TCompressorBase(IOutputStream* slave, ui16 blockSize) : Slave_(slave) , BlockSize_(blockSize) { @@ -76,7 +76,7 @@ public: } template <class T> - static inline void Save(T t, IOutputStream* out) { + static inline void Save(T t, IOutputStream* out) { t = HostToLittle(t); out->Write(&t, sizeof(t)); @@ -97,14 +97,14 @@ private: } inline void WriteBlock(const void* ptr, ui16 len) { - Y_ASSERT(len <= this->BlockSize()); + Y_ASSERT(len <= this->BlockSize()); ui8 compressed = false; if (len) { const size_t out = this->Compress((const char*)ptr, len, (char*)Block(), this->AdditionalDataLength()); // catch compressor buffer overrun (e.g. SEARCH-2043) - //Y_VERIFY(out <= this->Hint(this->BlockSize())); + //Y_VERIFY(out <= this->Hint(this->BlockSize())); if (out < len || TCompressor::SaveIncompressibleChunks()) { compressed = true; @@ -119,7 +119,7 @@ private: this->Save(len, &header); this->Save(compressed, &header); - using TPart = IOutputStream::TPart; + using TPart = IOutputStream::TPart; if (ptr) { const TPart parts[] = { TPart(tmp, sizeof(tmp)), @@ -133,12 +133,12 @@ private: } private: - IOutputStream* Slave_; + IOutputStream* Slave_; const ui16 BlockSize_; }; template <class T> -static inline T GLoad(IInputStream* input) { +static inline T GLoad(IInputStream* input) { T t; if (input->Load(&t, sizeof(t)) != sizeof(t)) { @@ -150,7 +150,7 @@ static inline T GLoad(IInputStream* input) { class TDecompressSignature { public: - inline TDecompressSignature(IInputStream* input) { + inline TDecompressSignature(IInputStream* input) { if (input->Load(Buffer_, SIGNATURE_SIZE) != SIGNATURE_SIZE) { ythrow TDecompressorError() << "can not load stream signature"; } @@ -167,7 +167,7 @@ private: }; template <class TDecompressor> -static inline IInputStream* ConsumeSignature(IInputStream* input) { +static inline IInputStream* ConsumeSignature(IInputStream* input) { TDecompressSignature sign(input); if (!sign.Check<TDecompressor>()) { ythrow TDecompressorError() << "incorrect signature"; @@ -186,7 +186,7 @@ public: return v; } - inline TDecompressorBaseImpl(IInputStream* slave) + inline TDecompressorBaseImpl(IInputStream* slave) : Slave_(slave) , Input_(nullptr, 0) , Eof_(false) @@ -265,7 +265,7 @@ public: } protected: - IInputStream* Slave_; + IInputStream* Slave_; TMemoryInput Input_; bool Eof_; const ui32 Version_; @@ -279,7 +279,7 @@ protected: template <class TDecompressor, class TBase> class TDecompressorBase: public TDecompressorBaseImpl<TDecompressor> { public: - inline TDecompressorBase(IInputStream* slave) + inline TDecompressorBase(IInputStream* slave) : TDecompressorBaseImpl<TDecompressor>(ConsumeSignature<TDecompressor>(slave)) { } @@ -323,12 +323,12 @@ public: #define DEF_COMPRESSOR(rname, name) \ class rname::TImpl: public TCompressorBase<name, TImpl> { \ public: \ - inline TImpl(IOutputStream* out, ui16 blockSize) \ + inline TImpl(IOutputStream* out, ui16 blockSize) \ : TCompressorBase<name, TImpl>(out, blockSize) { \ } \ }; \ \ - rname::rname(IOutputStream* slave, ui16 blockSize) \ + rname::rname(IOutputStream* slave, ui16 blockSize) \ : Impl_(new (TImpl::Hint(blockSize)) TImpl(slave, blockSize)) { \ } \ \ @@ -337,12 +337,12 @@ public: #define DEF_DECOMPRESSOR(rname, name) \ class rname::TImpl: public TDecompressorBase<name, TImpl> { \ public: \ - inline TImpl(IInputStream* in) \ + inline TImpl(IInputStream* in) \ : TDecompressorBase<name, TImpl>(in) { \ } \ }; \ \ - rname::rname(IInputStream* slave) \ + rname::rname(IInputStream* slave) \ : Impl_(new TImpl(slave)) { \ } \ \ @@ -420,7 +420,7 @@ public: return ret; } - inline void InitFromStream(IInputStream*) const noexcept { + inline void InitFromStream(IInputStream*) const noexcept { } }; @@ -446,7 +446,7 @@ public: return fastlz_decompress(data, len, ptr, max); } - inline void InitFromStream(IInputStream*) const noexcept { + inline void InitFromStream(IInputStream*) const noexcept { } static inline bool SaveIncompressibleChunks() noexcept { @@ -481,7 +481,7 @@ public: return res; } - inline void InitFromStream(IInputStream*) const noexcept { + inline void InitFromStream(IInputStream*) const noexcept { } static inline bool SaveIncompressibleChunks() noexcept { @@ -518,7 +518,7 @@ public: return srclen; } - inline void InitFromStream(IInputStream*) const noexcept { + inline void InitFromStream(IInputStream*) const noexcept { } static inline bool SaveIncompressibleChunks() noexcept { @@ -586,7 +586,7 @@ public: return Table_->Decompress(data, ptr, (char*)Mem_.Get()); } - inline void InitFromStream(IInputStream* in) { + inline void InitFromStream(IInputStream* in) { const ui8 ver = ::GLoad<ui8>(in); const ui8 lev = ::GLoad<ui8>(in); const ui8 mod = ::GLoad<ui8>(in); @@ -597,7 +597,7 @@ public: class TLzqCompress::TImpl: public TCompressorBase<TQuickLZCompress, TImpl> { public: - inline TImpl(IOutputStream* out, ui16 blockSize, EVersion ver, unsigned level, EMode mode) + inline TImpl(IOutputStream* out, ui16 blockSize, EVersion ver, unsigned level, EMode mode) : TCompressorBase<TQuickLZCompress, TImpl>(out, blockSize) { memset(AdditionalData(), 0, AdditionalDataLength()); @@ -610,7 +610,7 @@ public: } }; -TLzqCompress::TLzqCompress(IOutputStream* slave, ui16 blockSize, EVersion ver, unsigned level, EMode mode) +TLzqCompress::TLzqCompress(IOutputStream* slave, ui16 blockSize, EVersion ver, unsigned level, EMode mode) : Impl_(new (TImpl::Hint(blockSize)) TImpl(slave, blockSize, ver, level, mode)) { } @@ -639,7 +639,7 @@ namespace { // Decompressing input streams without signature verification template <class TInput, class TDecompressor> - class TLzDecompressInput: public TInputHolder<TInput>, public IInputStream { + class TLzDecompressInput: public TInputHolder<TInput>, public IInputStream { public: inline TLzDecompressInput(TInput in) : Impl_(this->Set(in)) @@ -657,7 +657,7 @@ namespace { } template <class T> -static TAutoPtr<IInputStream> TryOpenLzDecompressorX(const TDecompressSignature& s, T input) { +static TAutoPtr<IInputStream> TryOpenLzDecompressorX(const TDecompressSignature& s, T input) { if (s.Check<TLZ4>()) return new TLzDecompressInput<T, TLZ4>(input); @@ -677,7 +677,7 @@ static TAutoPtr<IInputStream> TryOpenLzDecompressorX(const TDecompressSignature& } template <class T> -static inline TAutoPtr<IInputStream> TryOpenLzDecompressorImpl(const TStringBuf& signature, T input) { +static inline TAutoPtr<IInputStream> TryOpenLzDecompressorImpl(const TStringBuf& signature, T input) { if (signature.size() == SIGNATURE_SIZE) { TMemoryInput mem(signature.data(), signature.size()); TDecompressSignature s(&mem); @@ -689,15 +689,15 @@ static inline TAutoPtr<IInputStream> TryOpenLzDecompressorImpl(const TStringBuf& } template <class T> -static inline TAutoPtr<IInputStream> TryOpenLzDecompressorImpl(T input) { +static inline TAutoPtr<IInputStream> TryOpenLzDecompressorImpl(T input) { TDecompressSignature s(&*input); return TryOpenLzDecompressorX(s, input); } template <class T> -static inline TAutoPtr<IInputStream> OpenLzDecompressorImpl(T input) { - TAutoPtr<IInputStream> ret = TryOpenLzDecompressorImpl(input); +static inline TAutoPtr<IInputStream> OpenLzDecompressorImpl(T input) { + TAutoPtr<IInputStream> ret = TryOpenLzDecompressorImpl(input); if (!ret) { ythrow TDecompressorError() << "Unknown compression format"; @@ -706,26 +706,26 @@ static inline TAutoPtr<IInputStream> OpenLzDecompressorImpl(T input) { return ret; } -TAutoPtr<IInputStream> OpenLzDecompressor(IInputStream* input) { +TAutoPtr<IInputStream> OpenLzDecompressor(IInputStream* input) { return OpenLzDecompressorImpl(input); } -TAutoPtr<IInputStream> TryOpenLzDecompressor(IInputStream* input) { +TAutoPtr<IInputStream> TryOpenLzDecompressor(IInputStream* input) { return TryOpenLzDecompressorImpl(input); } -TAutoPtr<IInputStream> TryOpenLzDecompressor(const TStringBuf& signature, IInputStream* input) { +TAutoPtr<IInputStream> TryOpenLzDecompressor(const TStringBuf& signature, IInputStream* input) { return TryOpenLzDecompressorImpl(signature, input); } -TAutoPtr<IInputStream> OpenOwnedLzDecompressor(TAutoPtr<IInputStream> input) { +TAutoPtr<IInputStream> OpenOwnedLzDecompressor(TAutoPtr<IInputStream> input) { return OpenLzDecompressorImpl(input); } -TAutoPtr<IInputStream> TryOpenOwnedLzDecompressor(TAutoPtr<IInputStream> input) { +TAutoPtr<IInputStream> TryOpenOwnedLzDecompressor(TAutoPtr<IInputStream> input) { return TryOpenLzDecompressorImpl(input); } -TAutoPtr<IInputStream> TryOpenOwnedLzDecompressor(const TStringBuf& signature, TAutoPtr<IInputStream> input) { +TAutoPtr<IInputStream> TryOpenOwnedLzDecompressor(const TStringBuf& signature, TAutoPtr<IInputStream> input) { return TryOpenLzDecompressorImpl(signature, input); } diff --git a/library/cpp/streams/lz/lz.h b/library/cpp/streams/lz/lz.h index 3a2eaad88b0..2207a46fe59 100644 --- a/library/cpp/streams/lz/lz.h +++ b/library/cpp/streams/lz/lz.h @@ -30,9 +30,9 @@ struct TDecompressorError: public yexception { * * @see http://code.google.com/p/lz4/ */ -class TLz4Compress: public IOutputStream { +class TLz4Compress: public IOutputStream { public: - TLz4Compress(IOutputStream* slave, ui16 maxBlockSize = 1 << 15); + TLz4Compress(IOutputStream* slave, ui16 maxBlockSize = 1 << 15); ~TLz4Compress() override; private: @@ -50,9 +50,9 @@ private: * * @see http://code.google.com/p/lz4/ */ -class TLz4Decompress: public IInputStream { +class TLz4Decompress: public IInputStream { public: - TLz4Decompress(IInputStream* slave); + TLz4Decompress(IInputStream* slave); ~TLz4Decompress() override; private: @@ -68,9 +68,9 @@ private: * * @see http://code.google.com/p/snappy/ */ -class TSnappyCompress: public IOutputStream { +class TSnappyCompress: public IOutputStream { public: - TSnappyCompress(IOutputStream* slave, ui16 maxBlockSize = 1 << 15); + TSnappyCompress(IOutputStream* slave, ui16 maxBlockSize = 1 << 15); ~TSnappyCompress() override; private: @@ -88,9 +88,9 @@ private: * * @see http://code.google.com/p/snappy/ */ -class TSnappyDecompress: public IInputStream { +class TSnappyDecompress: public IInputStream { public: - TSnappyDecompress(IInputStream* slave); + TSnappyDecompress(IInputStream* slave); ~TSnappyDecompress() override; private: @@ -104,9 +104,9 @@ private: /** * MiniLZO compressing stream. */ -class TLzoCompress: public IOutputStream { +class TLzoCompress: public IOutputStream { public: - TLzoCompress(IOutputStream* slave, ui16 maxBlockSize = 1 << 15); + TLzoCompress(IOutputStream* slave, ui16 maxBlockSize = 1 << 15); ~TLzoCompress() override; private: @@ -122,9 +122,9 @@ private: /** * MiniLZO decompressing stream. */ -class TLzoDecompress: public IInputStream { +class TLzoDecompress: public IInputStream { public: - TLzoDecompress(IInputStream* slave); + TLzoDecompress(IInputStream* slave); ~TLzoDecompress() override; private: @@ -138,9 +138,9 @@ private: /** * FastLZ compressing stream. */ -class TLzfCompress: public IOutputStream { +class TLzfCompress: public IOutputStream { public: - TLzfCompress(IOutputStream* slave, ui16 maxBlockSize = 1 << 15); + TLzfCompress(IOutputStream* slave, ui16 maxBlockSize = 1 << 15); ~TLzfCompress() override; private: @@ -156,9 +156,9 @@ private: /** * FastLZ decompressing stream. */ -class TLzfDecompress: public IInputStream { +class TLzfDecompress: public IInputStream { public: - TLzfDecompress(IInputStream* slave); + TLzfDecompress(IInputStream* slave); ~TLzfDecompress() override; private: @@ -172,7 +172,7 @@ private: /** * QuickLZ compressing stream. */ -class TLzqCompress: public IOutputStream { +class TLzqCompress: public IOutputStream { public: enum EVersion { V_1_31 = 0, @@ -189,7 +189,7 @@ public: M_1000000 = 2 }; - TLzqCompress(IOutputStream* slave, ui16 maxBlockSize = 1 << 15, + TLzqCompress(IOutputStream* slave, ui16 maxBlockSize = 1 << 15, EVersion ver = V_1_31, unsigned level = 0, EMode mode = M_0); @@ -208,9 +208,9 @@ private: /** * QuickLZ decompressing stream. */ -class TLzqDecompress: public IInputStream { +class TLzqDecompress: public IInputStream { public: - TLzqDecompress(IInputStream* slave); + TLzqDecompress(IInputStream* slave); ~TLzqDecompress() override; private: @@ -233,10 +233,10 @@ private: * @param input Stream to decompress. * @return Decompressing proxy input stream. */ -TAutoPtr<IInputStream> OpenLzDecompressor(IInputStream* input); -TAutoPtr<IInputStream> TryOpenLzDecompressor(IInputStream* input); -TAutoPtr<IInputStream> TryOpenLzDecompressor(const TStringBuf& signature, IInputStream* input); +TAutoPtr<IInputStream> OpenLzDecompressor(IInputStream* input); +TAutoPtr<IInputStream> TryOpenLzDecompressor(IInputStream* input); +TAutoPtr<IInputStream> TryOpenLzDecompressor(const TStringBuf& signature, IInputStream* input); -TAutoPtr<IInputStream> OpenOwnedLzDecompressor(TAutoPtr<IInputStream> input); -TAutoPtr<IInputStream> TryOpenOwnedLzDecompressor(TAutoPtr<IInputStream> input); -TAutoPtr<IInputStream> TryOpenOwnedLzDecompressor(const TStringBuf& signature, TAutoPtr<IInputStream> input); +TAutoPtr<IInputStream> OpenOwnedLzDecompressor(TAutoPtr<IInputStream> input); +TAutoPtr<IInputStream> TryOpenOwnedLzDecompressor(TAutoPtr<IInputStream> input); +TAutoPtr<IInputStream> TryOpenOwnedLzDecompressor(const TStringBuf& signature, TAutoPtr<IInputStream> input); diff --git a/library/cpp/streams/lz/lz_ut.cpp b/library/cpp/streams/lz/lz_ut.cpp index 6876f070fc0..ffa0065f46c 100644 --- a/library/cpp/streams/lz/lz_ut.cpp +++ b/library/cpp/streams/lz/lz_ut.cpp @@ -31,7 +31,7 @@ namespace { seed += 1; } } while (!sym); - Y_ASSERT(sym); + Y_ASSERT(sym); j = (j + 1) % entropy.size(); result += char(sym + entropy[j]); } @@ -75,7 +75,7 @@ static const TVector<size_t> bufferSizes = { namespace { template <TLzqCompress::EVersion Ver, int Level, TLzqCompress::EMode Mode> struct TLzqCompressX: public TLzqCompress { - inline TLzqCompressX(IOutputStream* out, size_t bufLen) + inline TLzqCompressX(IOutputStream* out, size_t bufLen) : TLzqCompress(out, bufLen, Ver, Level, Mode) { } @@ -160,9 +160,9 @@ static inline void TestDecompress() { } } -class TMixedDecompress: public IInputStream { +class TMixedDecompress: public IInputStream { public: - TMixedDecompress(IInputStream* input) + TMixedDecompress(IInputStream* input) : Slave_(OpenLzDecompressor(input).Release()) { } @@ -173,7 +173,7 @@ private: } private: - THolder<IInputStream> Slave_; + THolder<IInputStream> Slave_; }; template <class C> @@ -188,63 +188,63 @@ static inline void TestDecompressError() { UNIT_ASSERT_EXCEPTION(TestDecompress<D>(), TDecompressorError); } -Y_UNIT_TEST_SUITE(TLzTest) { - Y_UNIT_TEST(TestLzo) { +Y_UNIT_TEST_SUITE(TLzTest) { + Y_UNIT_TEST(TestLzo) { TestCompress<TLzoCompress>(); TestDecompress<TLzoDecompress>(); } - Y_UNIT_TEST(TestLzf) { + Y_UNIT_TEST(TestLzf) { TestCompress<TLzfCompress>(); TestDecompress<TLzfDecompress>(); } - Y_UNIT_TEST(TestLzq) { + Y_UNIT_TEST(TestLzq) { TestCompress<TLzqCompress>(); TestDecompress<TLzqDecompress>(); } - Y_UNIT_TEST(TestLzq151_1) { + Y_UNIT_TEST(TestLzq151_1) { TestCompress<TLzqCompressX<TLzqCompress::V_1_51, 1, TLzqCompress::M_0>>(); TestDecompress<TLzqDecompress>(); } - Y_UNIT_TEST(TestLzq151_2) { + Y_UNIT_TEST(TestLzq151_2) { TestCompress<TLzqCompressX<TLzqCompress::V_1_51, 2, TLzqCompress::M_100000>>(); TestDecompress<TLzqDecompress>(); } - Y_UNIT_TEST(TestLzq151_3) { + Y_UNIT_TEST(TestLzq151_3) { TestCompress<TLzqCompressX<TLzqCompress::V_1_51, 3, TLzqCompress::M_1000000>>(); TestDecompress<TLzqDecompress>(); } - Y_UNIT_TEST(TestLzq140_1) { + Y_UNIT_TEST(TestLzq140_1) { TestCompress<TLzqCompressX<TLzqCompress::V_1_40, 1, TLzqCompress::M_0>>(); TestDecompress<TLzqDecompress>(); } - Y_UNIT_TEST(TestLzq140_2) { + Y_UNIT_TEST(TestLzq140_2) { TestCompress<TLzqCompressX<TLzqCompress::V_1_40, 2, TLzqCompress::M_100000>>(); TestDecompress<TLzqDecompress>(); } - Y_UNIT_TEST(TestLzq140_3) { + Y_UNIT_TEST(TestLzq140_3) { TestCompress<TLzqCompressX<TLzqCompress::V_1_40, 3, TLzqCompress::M_1000000>>(); TestDecompress<TLzqDecompress>(); } - Y_UNIT_TEST(TestLz4) { + Y_UNIT_TEST(TestLz4) { TestCompress<TLz4Compress>(); TestDecompress<TLz4Decompress>(); } - Y_UNIT_TEST(TestSnappy) { + Y_UNIT_TEST(TestSnappy) { TestCompress<TSnappyCompress>(); TestDecompress<TSnappyDecompress>(); } - Y_UNIT_TEST(TestGeneric) { + Y_UNIT_TEST(TestGeneric) { TestMixedDecompress<TLzoCompress>(); TestMixedDecompress<TLzfCompress>(); TestMixedDecompress<TLzqCompress>(); @@ -252,7 +252,7 @@ Y_UNIT_TEST_SUITE(TLzTest) { TestMixedDecompress<TSnappyCompress>(); } - Y_UNIT_TEST(TestDecompressorError) { + Y_UNIT_TEST(TestDecompressorError) { TestDecompressError<TLzoDecompress, TLzfCompress>(); TestDecompressError<TLzfDecompress, TLzqCompress>(); TestDecompressError<TLzqDecompress, TLz4Compress>(); @@ -261,7 +261,7 @@ Y_UNIT_TEST_SUITE(TLzTest) { TestDecompressError<TMixedDecompress, TBufferedOutput>(); } - Y_UNIT_TEST(TestFactory) { + Y_UNIT_TEST(TestFactory) { TStringStream ss; { @@ -271,7 +271,7 @@ Y_UNIT_TEST_SUITE(TLzTest) { c.Finish(); } - TAutoPtr<IInputStream> is(OpenOwnedLzDecompressor(new TStringInput(ss.Str()))); + TAutoPtr<IInputStream> is(OpenOwnedLzDecompressor(new TStringInput(ss.Str()))); UNIT_ASSERT_EQUAL(is->ReadAll(), "123456789"); } diff --git a/library/cpp/streams/lzma/lzma.cpp b/library/cpp/streams/lzma/lzma.cpp index f1942fa546e..0a8235d02b3 100644 --- a/library/cpp/streams/lzma/lzma.cpp +++ b/library/cpp/streams/lzma/lzma.cpp @@ -58,7 +58,7 @@ namespace { TInverseFilter* Parent_; }; - class TInput: public IInputStream { + class TInput: public IInputStream { public: inline TInput(TInverseFilter* parent) : Parent_(parent) @@ -76,7 +76,7 @@ namespace { TInverseFilter* Parent_; }; - class TOutput: public IOutputStream { + class TOutput: public IOutputStream { public: inline TOutput(TInverseFilter* parent) : Parent_(parent) @@ -95,7 +95,7 @@ namespace { }; public: - inline TInverseFilter(IOutputStream* slave, T* filter) + inline TInverseFilter(IOutputStream* slave, T* filter) : Slave_(slave) , Filter_(filter) , TrampoLine_(this) @@ -168,7 +168,7 @@ namespace { } inline void WriteImpl(const void* ptr, size_t len) { - Y_ASSERT(!Out_.Avail()); + Y_ASSERT(!Out_.Avail()); Out_.Reset(ptr, len); @@ -205,7 +205,7 @@ namespace { } private: - IOutputStream* Slave_; + IOutputStream* Slave_; T* Filter_; TTrampoLine TrampoLine_; char Stack_[16 * 1024]; @@ -221,7 +221,7 @@ namespace { public: class TLzmaInput: public ISeqInStream { public: - inline TLzmaInput(IInputStream* slave) + inline TLzmaInput(IInputStream* slave) : Slave_(slave) { Read = ReadFunc; @@ -235,12 +235,12 @@ namespace { } private: - IInputStream* Slave_; + IInputStream* Slave_; }; class TLzmaOutput: public ISeqOutStream { public: - inline TLzmaOutput(IOutputStream* slave) + inline TLzmaOutput(IOutputStream* slave) : Slave_(slave) { Write = WriteFunc; @@ -254,7 +254,7 @@ namespace { } private: - IOutputStream* Slave_; + IOutputStream* Slave_; }; class TAlloc: public ISzAlloc { @@ -321,7 +321,7 @@ namespace { LzmaEnc_Destroy(H_, Alloc(), Alloc()); } - inline void operator()(IInputStream* in, IOutputStream* out) { + inline void operator()(IInputStream* in, IOutputStream* out) { TLzmaInput input(in); TLzmaOutput output(out); @@ -339,7 +339,7 @@ namespace { class TLzmaCompress::TImpl: public TLzmaCompressBase, public TInverseFilter<TLzmaCompressBase> { public: - inline TImpl(IOutputStream* slave, size_t level) + inline TImpl(IOutputStream* slave, size_t level) : TLzmaCompressBase(level) , TInverseFilter<TLzmaCompressBase>(slave, this) { @@ -373,7 +373,7 @@ public: pos += bufLen; if (status == LZMA_STATUS_NEEDS_MORE_INPUT) { - Y_ASSERT(InEnd_ == InBegin_); + Y_ASSERT(InEnd_ == InBegin_); if (!Fill()) { ythrow yexception() << "incomplete lzma stream"; } @@ -395,7 +395,7 @@ protected: class TLzmaDecompress::TImplStream: public TImpl { public: - inline TImplStream(IInputStream* slave) + inline TImplStream(IInputStream* slave) : Slave_(slave) { Byte buf[LZMA_PROPS_SIZE]; @@ -417,13 +417,13 @@ private: } private: - IInputStream* Slave_; + IInputStream* Slave_; char In_[4096]; }; class TLzmaDecompress::TImplZeroCopy: public TLzmaDecompress::TImpl { public: - inline TImplZeroCopy(IZeroCopyInput* in) + inline TImplZeroCopy(IZeroCopyInput* in) : Input_(in) { if (!Fill()) @@ -475,10 +475,10 @@ private: return false; } - IZeroCopyInput* Input_; + IZeroCopyInput* Input_; }; -TLzmaCompress::TLzmaCompress(IOutputStream* slave, size_t level) +TLzmaCompress::TLzmaCompress(IOutputStream* slave, size_t level) : Impl_(new TImpl(slave, level)) { } @@ -502,12 +502,12 @@ void TLzmaCompress::DoFinish() { } } -TLzmaDecompress::TLzmaDecompress(IInputStream* slave) +TLzmaDecompress::TLzmaDecompress(IInputStream* slave) : Impl_(new TImplStream(slave)) { } -TLzmaDecompress::TLzmaDecompress(IZeroCopyInput* input) +TLzmaDecompress::TLzmaDecompress(IZeroCopyInput* input) : Impl_(new TImplZeroCopy(input)) { } diff --git a/library/cpp/streams/lzma/lzma.h b/library/cpp/streams/lzma/lzma.h index ca1e06e9ef4..9a86213655d 100644 --- a/library/cpp/streams/lzma/lzma.h +++ b/library/cpp/streams/lzma/lzma.h @@ -6,9 +6,9 @@ #include <util/generic/ptr.h> -class TLzmaCompress: public IOutputStream { +class TLzmaCompress: public IOutputStream { public: - TLzmaCompress(IOutputStream* slave, size_t level = 7); + TLzmaCompress(IOutputStream* slave, size_t level = 7); ~TLzmaCompress() override; private: @@ -20,10 +20,10 @@ private: THolder<TImpl> Impl_; }; -class TLzmaDecompress: public IInputStream { +class TLzmaDecompress: public IInputStream { public: - TLzmaDecompress(IInputStream* slave); - TLzmaDecompress(IZeroCopyInput* input); + TLzmaDecompress(IInputStream* slave); + TLzmaDecompress(IZeroCopyInput* input); ~TLzmaDecompress() override; private: diff --git a/library/cpp/streams/lzma/lzma_ut.cpp b/library/cpp/streams/lzma/lzma_ut.cpp index 847e98d1caa..e71e1bde49f 100644 --- a/library/cpp/streams/lzma/lzma_ut.cpp +++ b/library/cpp/streams/lzma/lzma_ut.cpp @@ -6,7 +6,7 @@ #include <util/random/fast.h> #include <util/random/random.h> -class TStrokaByOneByte: public IZeroCopyInput { +class TStrokaByOneByte: public IZeroCopyInput { public: TStrokaByOneByte(const TString& s) : Data(s) @@ -52,7 +52,7 @@ private: } inline void Test2() { - class TExcOutput: public IOutputStream { + class TExcOutput: public IOutputStream { public: ~TExcOutput() override { } @@ -93,7 +93,7 @@ private: { TMemoryInput mi(res.data(), res.size()); TStringOutput so(data1); - TLzmaDecompress d((IInputStream*)&mi); + TLzmaDecompress d((IInputStream*)&mi); TransferData(&d, &so); } diff --git a/library/cpp/string_utils/base64/base64.cpp b/library/cpp/string_utils/base64/base64.cpp index 05c201f0de7..9e90ed7bb1a 100644 --- a/library/cpp/string_utils/base64/base64.cpp +++ b/library/cpp/string_utils/base64/base64.cpp @@ -1,36 +1,36 @@ #include "base64.h" -#include <contrib/libs/base64/avx2/libbase64.h> -#include <contrib/libs/base64/ssse3/libbase64.h> -#include <contrib/libs/base64/neon32/libbase64.h> -#include <contrib/libs/base64/neon64/libbase64.h> -#include <contrib/libs/base64/plain32/libbase64.h> -#include <contrib/libs/base64/plain64/libbase64.h> - +#include <contrib/libs/base64/avx2/libbase64.h> +#include <contrib/libs/base64/ssse3/libbase64.h> +#include <contrib/libs/base64/neon32/libbase64.h> +#include <contrib/libs/base64/neon64/libbase64.h> +#include <contrib/libs/base64/plain32/libbase64.h> +#include <contrib/libs/base64/plain64/libbase64.h> + #include <util/generic/yexception.h> -#include <util/system/cpu_id.h> -#include <util/system/platform.h> - -#include <cstdlib> - -namespace { - struct TImpl { - void (*Encode)(const char* src, size_t srclen, char* out, size_t* outlen); - int (*Decode)(const char* src, size_t srclen, char* out, size_t* outlen); - - TImpl() { -#if defined(_arm32_) - const bool haveNEON32 = true; -#else - const bool haveNEON32 = false; -#endif - -#if defined(_arm64_) - const bool haveNEON64 = true; -#else - const bool haveNEON64 = false; -#endif - +#include <util/system/cpu_id.h> +#include <util/system/platform.h> + +#include <cstdlib> + +namespace { + struct TImpl { + void (*Encode)(const char* src, size_t srclen, char* out, size_t* outlen); + int (*Decode)(const char* src, size_t srclen, char* out, size_t* outlen); + + TImpl() { +#if defined(_arm32_) + const bool haveNEON32 = true; +#else + const bool haveNEON32 = false; +#endif + +#if defined(_arm64_) + const bool haveNEON64 = true; +#else + const bool haveNEON64 = false; +#endif + # ifdef _windows_ // msvc does something wrong in release-build, so we temprorary disable this branch on windows // https://developercommunity.visualstudio.com/content/problem/334085/release-build-has-made-wrong-optimizaion-in-base64.html @@ -39,59 +39,59 @@ namespace { const bool isWin = false; # endif if (!isWin && NX86::HaveAVX() && NX86::HaveAVX2()) { - Encode = avx2_base64_encode; - Decode = avx2_base64_decode; - } else if (NX86::HaveSSSE3()) { - Encode = ssse3_base64_encode; - Decode = ssse3_base64_decode; - } else if (haveNEON64) { - Encode = neon64_base64_encode; - Decode = neon64_base64_decode; - } else if (haveNEON32) { - Encode = neon32_base64_encode; - Decode = neon32_base64_decode; - } else if (sizeof(void*) == 8) { - // running on a 64 bit platform - Encode = plain64_base64_encode; - Decode = plain64_base64_decode; - } else if (sizeof(void*) == 4) { - // running on a 32 bit platform (actually impossible in Arcadia) - Encode = plain32_base64_encode; - Decode = plain32_base64_decode; - } else { - // failed to find appropriate implementation - std::abort(); - } - } - }; - + Encode = avx2_base64_encode; + Decode = avx2_base64_decode; + } else if (NX86::HaveSSSE3()) { + Encode = ssse3_base64_encode; + Decode = ssse3_base64_decode; + } else if (haveNEON64) { + Encode = neon64_base64_encode; + Decode = neon64_base64_decode; + } else if (haveNEON32) { + Encode = neon32_base64_encode; + Decode = neon32_base64_decode; + } else if (sizeof(void*) == 8) { + // running on a 64 bit platform + Encode = plain64_base64_encode; + Decode = plain64_base64_decode; + } else if (sizeof(void*) == 4) { + // running on a 32 bit platform (actually impossible in Arcadia) + Encode = plain32_base64_encode; + Decode = plain32_base64_decode; + } else { + // failed to find appropriate implementation + std::abort(); + } + } + }; + const TImpl GetImpl() { - static const TImpl IMPL; - return IMPL; - } -} - + static const TImpl IMPL; + return IMPL; + } +} + static const char base64_etab_std[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; -static const char base64_bkw[] = { - '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', // 0..15 - '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', // 16..31 - '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\76', '\0', '\76', '\0', '\77', // 32.47 - '\64', '\65', '\66', '\67', '\70', '\71', '\72', '\73', '\74', '\75', '\0', '\0', '\0', '\0', '\0', '\0', // 48..63 - '\0', '\0', '\1', '\2', '\3', '\4', '\5', '\6', '\7', '\10', '\11', '\12', '\13', '\14', '\15', '\16', // 64..79 - '\17', '\20', '\21', '\22', '\23', '\24', '\25', '\26', '\27', '\30', '\31', '\0', '\0', '\0', '\0', '\77', // 80..95 - '\0', '\32', '\33', '\34', '\35', '\36', '\37', '\40', '\41', '\42', '\43', '\44', '\45', '\46', '\47', '\50', // 96..111 - '\51', '\52', '\53', '\54', '\55', '\56', '\57', '\60', '\61', '\62', '\63', '\0', '\0', '\0', '\0', '\0', // 112..127 - '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', // 128..143 - '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', - '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', - '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', - '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', - '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', - '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', - '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0'}; - -static_assert(Y_ARRAY_SIZE(base64_bkw) == 256, "wrong size"); - +static const char base64_bkw[] = { + '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', // 0..15 + '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', // 16..31 + '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\76', '\0', '\76', '\0', '\77', // 32.47 + '\64', '\65', '\66', '\67', '\70', '\71', '\72', '\73', '\74', '\75', '\0', '\0', '\0', '\0', '\0', '\0', // 48..63 + '\0', '\0', '\1', '\2', '\3', '\4', '\5', '\6', '\7', '\10', '\11', '\12', '\13', '\14', '\15', '\16', // 64..79 + '\17', '\20', '\21', '\22', '\23', '\24', '\25', '\26', '\27', '\30', '\31', '\0', '\0', '\0', '\0', '\77', // 80..95 + '\0', '\32', '\33', '\34', '\35', '\36', '\37', '\40', '\41', '\42', '\43', '\44', '\45', '\46', '\47', '\50', // 96..111 + '\51', '\52', '\53', '\54', '\55', '\56', '\57', '\60', '\61', '\62', '\63', '\0', '\0', '\0', '\0', '\0', // 112..127 + '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', // 128..143 + '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', + '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', + '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', + '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', + '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', + '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', + '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0'}; + +static_assert(Y_ARRAY_SIZE(base64_bkw) == 256, "wrong size"); + // Base64 for url encoding, RFC3548 static const char base64_etab_url[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"; @@ -141,7 +141,7 @@ static inline char* Base64EncodeImpl(char* outstr, const unsigned char* instr, s return outstr; } -static char* Base64EncodePlain(char* outstr, const unsigned char* instr, size_t len) { +static char* Base64EncodePlain(char* outstr, const unsigned char* instr, size_t len) { return Base64EncodeImpl<false>(outstr, instr, len); } @@ -155,7 +155,7 @@ inline void uudecode_1(char* dst, unsigned char* src) { dst[2] = char((base64_bkw[src[2]] << 6) | base64_bkw[src[3]]); } -static size_t Base64DecodePlain(void* dst, const char* b, const char* e) { +static size_t Base64DecodePlain(void* dst, const char* b, const char* e) { size_t n = 0; while (b < e) { uudecode_1((char*)dst + n, (unsigned char*)b); @@ -193,7 +193,7 @@ size_t Base64StrictDecode(void* out, const char* b, const char* e) { const unsigned char* src = (unsigned char*)b; const unsigned char* const end = (unsigned char*)e; - Y_ENSURE(!((e - b) % 4), "incorrect input length for base64 decode"); + Y_ENSURE(!((e - b) % 4), "incorrect input length for base64 decode"); while (src < end) { const char zeroth = base64_bkw_strict[src[0]]; @@ -203,10 +203,10 @@ size_t Base64StrictDecode(void* out, const char* b, const char* e) { constexpr char invalid = 64; constexpr char padding = 65; - if (Y_UNLIKELY(zeroth == invalid || first == invalid || - second == invalid || third == invalid || - zeroth == padding || first == padding)) - { + if (Y_UNLIKELY(zeroth == invalid || first == invalid || + second == invalid || third == invalid || + zeroth == padding || first == padding)) + { ythrow yexception() << "invalid character in input"; } @@ -223,28 +223,28 @@ size_t Base64StrictDecode(void* out, const char* b, const char* e) { if (src[-2] == ',' || src[-2] == '=') { --dst; } - } else if (Y_UNLIKELY(src[-2] == ',' || src[-2] == '=')) { + } else if (Y_UNLIKELY(src[-2] == ',' || src[-2] == '=')) { ythrow yexception() << "incorrect padding"; } } return dst - (char*)out; } - -size_t Base64Decode(void* dst, const char* b, const char* e) { - static const TImpl IMPL = GetImpl(); - const auto size = e - b; - Y_ENSURE(!(size % 4), "incorrect input length for base64 decode"); - if (Y_LIKELY(size < 8)) { - return Base64DecodePlain(dst, b, e); - } - - size_t outLen; - IMPL.Decode(b, size, (char*)dst, &outLen); - - return outLen; -} - + +size_t Base64Decode(void* dst, const char* b, const char* e) { + static const TImpl IMPL = GetImpl(); + const auto size = e - b; + Y_ENSURE(!(size % 4), "incorrect input length for base64 decode"); + if (Y_LIKELY(size < 8)) { + return Base64DecodePlain(dst, b, e); + } + + size_t outLen; + IMPL.Decode(b, size, (char*)dst, &outLen); + + return outLen; +} + TString Base64DecodeUneven(const TStringBuf s) { if (s.length() % 4 == 0) { return Base64Decode(s); @@ -254,15 +254,15 @@ TString Base64DecodeUneven(const TStringBuf s) { return Base64Decode(TString(s) + TString(4 - (s.length() % 4), '=')); } -char* Base64Encode(char* outstr, const unsigned char* instr, size_t len) { - static const TImpl IMPL = GetImpl(); - if (Y_LIKELY(len < 8)) { - return Base64EncodePlain(outstr, instr, len); - } - - size_t outLen; - IMPL.Encode((char*)instr, len, outstr, &outLen); - - *(outstr + outLen) = '\0'; - return outstr + outLen; -} +char* Base64Encode(char* outstr, const unsigned char* instr, size_t len) { + static const TImpl IMPL = GetImpl(); + if (Y_LIKELY(len < 8)) { + return Base64EncodePlain(outstr, instr, len); + } + + size_t outLen; + IMPL.Encode((char*)instr, len, outstr, &outLen); + + *(outstr + outLen) = '\0'; + return outstr + outLen; +} diff --git a/library/cpp/string_utils/base64/base64.h b/library/cpp/string_utils/base64/base64.h index f778a6425aa..57a121537d5 100644 --- a/library/cpp/string_utils/base64/base64.h +++ b/library/cpp/string_utils/base64/base64.h @@ -4,26 +4,26 @@ #include <util/generic/strbuf.h> #include <util/generic/string.h> -/* @return Size of the buffer required to decode Base64 encoded data of size `len`. - */ -constexpr size_t Base64DecodeBufSize(const size_t len) noexcept { - return (len + 3) / 4 * 3; +/* @return Size of the buffer required to decode Base64 encoded data of size `len`. + */ +constexpr size_t Base64DecodeBufSize(const size_t len) noexcept { + return (len + 3) / 4 * 3; } -/* Decode Base64 encoded data. Can decode both regular Base64 and Base64URL encoded data. Can decode - * only valid Base64[URL] data, behaviour for invalid data is unspecified. - * - * @throws Throws exception in case of incorrect padding. - * - * @param dst memory for writing output. - * @param b pointer to the beginning of base64 encoded string. - * @param a pointer to the end of base64 encoded string - * - * @return Return number of bytes decoded. - */ +/* Decode Base64 encoded data. Can decode both regular Base64 and Base64URL encoded data. Can decode + * only valid Base64[URL] data, behaviour for invalid data is unspecified. + * + * @throws Throws exception in case of incorrect padding. + * + * @param dst memory for writing output. + * @param b pointer to the beginning of base64 encoded string. + * @param a pointer to the end of base64 encoded string + * + * @return Return number of bytes decoded. + */ size_t Base64Decode(void* dst, const char* b, const char* e); -inline TStringBuf Base64Decode(const TStringBuf src, void* dst) { +inline TStringBuf Base64Decode(const TStringBuf src, void* dst) { return TStringBuf((const char*)dst, Base64Decode(dst, src.begin(), src.end())); } @@ -63,7 +63,7 @@ size_t Base64StrictDecode(void* dst, const char* b, const char* e); /// /// @return Returns dst wrapped into TStringBuf. /// -inline TStringBuf Base64StrictDecode(const TStringBuf src, void* dst) { +inline TStringBuf Base64StrictDecode(const TStringBuf src, void* dst) { return TStringBuf((const char*)dst, Base64StrictDecode(dst, src.begin(), src.end())); } @@ -92,18 +92,18 @@ inline TString Base64StrictDecode(const TStringBuf src) { TString Base64DecodeUneven(const TStringBuf s); //encode -constexpr size_t Base64EncodeBufSize(const size_t len) noexcept { - return (len + 2) / 3 * 4 + 1; +constexpr size_t Base64EncodeBufSize(const size_t len) noexcept { + return (len + 2) / 3 * 4 + 1; } char* Base64Encode(char* outstr, const unsigned char* instr, size_t len); char* Base64EncodeUrl(char* outstr, const unsigned char* instr, size_t len); -inline TStringBuf Base64Encode(const TStringBuf src, void* tmp) { +inline TStringBuf Base64Encode(const TStringBuf src, void* tmp) { return TStringBuf((const char*)tmp, Base64Encode((char*)tmp, (const unsigned char*)src.data(), src.size())); } -inline TStringBuf Base64EncodeUrl(const TStringBuf src, void* tmp) { +inline TStringBuf Base64EncodeUrl(const TStringBuf src, void* tmp) { return TStringBuf((const char*)tmp, Base64EncodeUrl((char*)tmp, (const unsigned char*)src.data(), src.size())); } diff --git a/library/cpp/string_utils/base64/base64_ut.cpp b/library/cpp/string_utils/base64/base64_ut.cpp index bcc1e658791..28737063010 100644 --- a/library/cpp/string_utils/base64/base64_ut.cpp +++ b/library/cpp/string_utils/base64/base64_ut.cpp @@ -1,168 +1,168 @@ #include "base64.h" -#include <contrib/libs/base64/avx2/libbase64.h> -#include <contrib/libs/base64/neon32/libbase64.h> -#include <contrib/libs/base64/neon64/libbase64.h> -#include <contrib/libs/base64/plain32/libbase64.h> -#include <contrib/libs/base64/plain64/libbase64.h> -#include <contrib/libs/base64/ssse3/libbase64.h> - +#include <contrib/libs/base64/avx2/libbase64.h> +#include <contrib/libs/base64/neon32/libbase64.h> +#include <contrib/libs/base64/neon64/libbase64.h> +#include <contrib/libs/base64/plain32/libbase64.h> +#include <contrib/libs/base64/plain64/libbase64.h> +#include <contrib/libs/base64/ssse3/libbase64.h> + #include <library/cpp/testing/unittest/registar.h> -#include <util/generic/vector.h> -#include <util/random/fast.h> -#include <util/system/cpu_id.h> -#include <util/system/platform.h> - -#include <array> - +#include <util/generic/vector.h> +#include <util/random/fast.h> +#include <util/system/cpu_id.h> +#include <util/system/platform.h> + +#include <array> + using namespace std::string_view_literals; -#define BASE64_UT_DECLARE_BASE64_IMPL(prefix, encFunction, decFunction) \ - Y_DECLARE_UNUSED \ - static size_t prefix##Base64Decode(void* dst, const char* b, const char* e) { \ - const auto size = e - b; \ - Y_ENSURE(!(size % 4), "incorrect input length for base64 decode"); \ - \ - size_t outLen; \ - decFunction(b, size, (char*)dst, &outLen); \ - return outLen; \ - } \ - \ - Y_DECLARE_UNUSED \ - static inline TStringBuf prefix##Base64Decode(const TStringBuf& src, void* dst) { \ - return TStringBuf((const char*)dst, ::NB64Etalon::prefix##Base64Decode(dst, src.begin(), src.end())); \ - } \ - \ - Y_DECLARE_UNUSED \ - static inline void prefix##Base64Decode(const TStringBuf& src, TString& dst) { \ - dst.ReserveAndResize(Base64DecodeBufSize(src.size())); \ - dst.resize(::NB64Etalon::prefix##Base64Decode(src, dst.begin()).size()); \ - } \ - \ - Y_DECLARE_UNUSED \ - static inline TString prefix##Base64Decode(const TStringBuf& s) { \ - TString ret; \ - prefix##Base64Decode(s, ret); \ - return ret; \ - } \ - \ - Y_DECLARE_UNUSED \ - static char* prefix##Base64Encode(char* outstr, const unsigned char* instr, size_t len) { \ - size_t outLen; \ - encFunction((char*)instr, len, outstr, &outLen); \ - *(outstr + outLen) = '\0'; \ - return outstr + outLen; \ - } \ - \ - Y_DECLARE_UNUSED \ - static inline TStringBuf prefix##Base64Encode(const TStringBuf& src, void* tmp) { \ +#define BASE64_UT_DECLARE_BASE64_IMPL(prefix, encFunction, decFunction) \ + Y_DECLARE_UNUSED \ + static size_t prefix##Base64Decode(void* dst, const char* b, const char* e) { \ + const auto size = e - b; \ + Y_ENSURE(!(size % 4), "incorrect input length for base64 decode"); \ + \ + size_t outLen; \ + decFunction(b, size, (char*)dst, &outLen); \ + return outLen; \ + } \ + \ + Y_DECLARE_UNUSED \ + static inline TStringBuf prefix##Base64Decode(const TStringBuf& src, void* dst) { \ + return TStringBuf((const char*)dst, ::NB64Etalon::prefix##Base64Decode(dst, src.begin(), src.end())); \ + } \ + \ + Y_DECLARE_UNUSED \ + static inline void prefix##Base64Decode(const TStringBuf& src, TString& dst) { \ + dst.ReserveAndResize(Base64DecodeBufSize(src.size())); \ + dst.resize(::NB64Etalon::prefix##Base64Decode(src, dst.begin()).size()); \ + } \ + \ + Y_DECLARE_UNUSED \ + static inline TString prefix##Base64Decode(const TStringBuf& s) { \ + TString ret; \ + prefix##Base64Decode(s, ret); \ + return ret; \ + } \ + \ + Y_DECLARE_UNUSED \ + static char* prefix##Base64Encode(char* outstr, const unsigned char* instr, size_t len) { \ + size_t outLen; \ + encFunction((char*)instr, len, outstr, &outLen); \ + *(outstr + outLen) = '\0'; \ + return outstr + outLen; \ + } \ + \ + Y_DECLARE_UNUSED \ + static inline TStringBuf prefix##Base64Encode(const TStringBuf& src, void* tmp) { \ return TStringBuf((const char*)tmp, ::NB64Etalon::prefix##Base64Encode((char*)tmp, (const unsigned char*)src.data(), src.size())); \ - } \ - \ - Y_DECLARE_UNUSED \ - static inline void prefix##Base64Encode(const TStringBuf& src, TString& dst) { \ - dst.ReserveAndResize(Base64EncodeBufSize(src.size())); \ - dst.resize(::NB64Etalon::prefix##Base64Encode(src, dst.begin()).size()); \ - } \ - \ - Y_DECLARE_UNUSED \ - static inline TString prefix##Base64Encode(const TStringBuf& s) { \ - TString ret; \ - prefix##Base64Encode(s, ret); \ - return ret; \ - } - -namespace NB64Etalon { - BASE64_UT_DECLARE_BASE64_IMPL(PLAIN32, plain32_base64_encode, plain32_base64_decode); - BASE64_UT_DECLARE_BASE64_IMPL(PLAIN64, plain64_base64_encode, plain64_base64_decode); - BASE64_UT_DECLARE_BASE64_IMPL(NEON32, neon32_base64_encode, neon32_base64_decode); - BASE64_UT_DECLARE_BASE64_IMPL(NEON64, neon64_base64_encode, neon64_base64_decode); - BASE64_UT_DECLARE_BASE64_IMPL(AVX2, avx2_base64_encode, avx2_base64_decode); - BASE64_UT_DECLARE_BASE64_IMPL(SSSE3, ssse3_base64_encode, ssse3_base64_decode); - -#undef BASE64_UT_DECLARE_BASE64_IMPL - - struct TImpls { - enum EImpl : size_t { - PLAIN32_IMPL, - PLAIN64_IMPL, - NEON32_IMPL, - NEON64_IMPL, - AVX2_IMPL, - SSSE3_IMPL, - MAX_IMPL - }; - + } \ + \ + Y_DECLARE_UNUSED \ + static inline void prefix##Base64Encode(const TStringBuf& src, TString& dst) { \ + dst.ReserveAndResize(Base64EncodeBufSize(src.size())); \ + dst.resize(::NB64Etalon::prefix##Base64Encode(src, dst.begin()).size()); \ + } \ + \ + Y_DECLARE_UNUSED \ + static inline TString prefix##Base64Encode(const TStringBuf& s) { \ + TString ret; \ + prefix##Base64Encode(s, ret); \ + return ret; \ + } + +namespace NB64Etalon { + BASE64_UT_DECLARE_BASE64_IMPL(PLAIN32, plain32_base64_encode, plain32_base64_decode); + BASE64_UT_DECLARE_BASE64_IMPL(PLAIN64, plain64_base64_encode, plain64_base64_decode); + BASE64_UT_DECLARE_BASE64_IMPL(NEON32, neon32_base64_encode, neon32_base64_decode); + BASE64_UT_DECLARE_BASE64_IMPL(NEON64, neon64_base64_encode, neon64_base64_decode); + BASE64_UT_DECLARE_BASE64_IMPL(AVX2, avx2_base64_encode, avx2_base64_decode); + BASE64_UT_DECLARE_BASE64_IMPL(SSSE3, ssse3_base64_encode, ssse3_base64_decode); + +#undef BASE64_UT_DECLARE_BASE64_IMPL + + struct TImpls { + enum EImpl : size_t { + PLAIN32_IMPL, + PLAIN64_IMPL, + NEON32_IMPL, + NEON64_IMPL, + AVX2_IMPL, + SSSE3_IMPL, + MAX_IMPL + }; + using TEncodeF = void (*)(const TStringBuf&, TString&); using TDecodeF = void (*)(const TStringBuf&, TString&); - - struct TImpl { - TEncodeF Encode = nullptr; - TDecodeF Decode = nullptr; - }; - - std::array<TImpl, MAX_IMPL> Impl; - - TImpls() { - Impl[PLAIN32_IMPL].Encode = PLAIN32Base64Encode; - Impl[PLAIN32_IMPL].Decode = PLAIN32Base64Decode; - Impl[PLAIN64_IMPL].Encode = PLAIN64Base64Encode; - Impl[PLAIN64_IMPL].Decode = PLAIN64Base64Decode; -#if defined(_arm32_) - Impl[NEON32_IMPL].Encode = NEON32Base64Encode; - Impl[NEON32_IMPL].Decode = NEON32Base64Decode; -#elif defined(_arm64_) - Impl[NEON64_IMPL].Encode = NEON64Base64Encode; - Impl[NEON64_IMPL].Decode = NEON64Base64Decode; -#elif defined(_x86_64_) - if (NX86::HaveSSSE3()) { - Impl[SSSE3_IMPL].Encode = SSSE3Base64Encode; - Impl[SSSE3_IMPL].Decode = SSSE3Base64Decode; - } - - if (NX86::HaveAVX2()) { - Impl[AVX2_IMPL].Encode = AVX2Base64Encode; - Impl[AVX2_IMPL].Decode = AVX2Base64Decode; - } -#else - ythrow yexception() << "Failed to identify the platform"; -#endif - } - }; - - TImpls GetImpls() { - static const TImpls IMPLS; - return IMPLS; - } -} - -template <> -void Out<NB64Etalon::TImpls::EImpl>(IOutputStream& o, typename TTypeTraits<NB64Etalon::TImpls::EImpl>::TFuncParam v) { - switch (v) { - case NB64Etalon::TImpls::PLAIN32_IMPL: - o << TStringBuf{"PLAIN32"}; - return; - case NB64Etalon::TImpls::PLAIN64_IMPL: - o << TStringBuf{"PLAIN64"}; - return; - case NB64Etalon::TImpls::NEON64_IMPL: - o << TStringBuf{"NEON64"}; - return; - case NB64Etalon::TImpls::NEON32_IMPL: - o << TStringBuf{"NEON32"}; - return; - case NB64Etalon::TImpls::SSSE3_IMPL: - o << TStringBuf{"SSSE3"}; - return; - case NB64Etalon::TImpls::AVX2_IMPL: - o << TStringBuf{"AVX2"}; - return; - default: - ythrow yexception() << "invalid"; - } -} - + + struct TImpl { + TEncodeF Encode = nullptr; + TDecodeF Decode = nullptr; + }; + + std::array<TImpl, MAX_IMPL> Impl; + + TImpls() { + Impl[PLAIN32_IMPL].Encode = PLAIN32Base64Encode; + Impl[PLAIN32_IMPL].Decode = PLAIN32Base64Decode; + Impl[PLAIN64_IMPL].Encode = PLAIN64Base64Encode; + Impl[PLAIN64_IMPL].Decode = PLAIN64Base64Decode; +#if defined(_arm32_) + Impl[NEON32_IMPL].Encode = NEON32Base64Encode; + Impl[NEON32_IMPL].Decode = NEON32Base64Decode; +#elif defined(_arm64_) + Impl[NEON64_IMPL].Encode = NEON64Base64Encode; + Impl[NEON64_IMPL].Decode = NEON64Base64Decode; +#elif defined(_x86_64_) + if (NX86::HaveSSSE3()) { + Impl[SSSE3_IMPL].Encode = SSSE3Base64Encode; + Impl[SSSE3_IMPL].Decode = SSSE3Base64Decode; + } + + if (NX86::HaveAVX2()) { + Impl[AVX2_IMPL].Encode = AVX2Base64Encode; + Impl[AVX2_IMPL].Decode = AVX2Base64Decode; + } +#else + ythrow yexception() << "Failed to identify the platform"; +#endif + } + }; + + TImpls GetImpls() { + static const TImpls IMPLS; + return IMPLS; + } +} + +template <> +void Out<NB64Etalon::TImpls::EImpl>(IOutputStream& o, typename TTypeTraits<NB64Etalon::TImpls::EImpl>::TFuncParam v) { + switch (v) { + case NB64Etalon::TImpls::PLAIN32_IMPL: + o << TStringBuf{"PLAIN32"}; + return; + case NB64Etalon::TImpls::PLAIN64_IMPL: + o << TStringBuf{"PLAIN64"}; + return; + case NB64Etalon::TImpls::NEON64_IMPL: + o << TStringBuf{"NEON64"}; + return; + case NB64Etalon::TImpls::NEON32_IMPL: + o << TStringBuf{"NEON32"}; + return; + case NB64Etalon::TImpls::SSSE3_IMPL: + o << TStringBuf{"SSSE3"}; + return; + case NB64Etalon::TImpls::AVX2_IMPL: + o << TStringBuf{"AVX2"}; + return; + default: + ythrow yexception() << "invalid"; + } +} + static void TestEncodeDecodeIntoString(const TString& plain, const TString& encoded, const TString& encodedUrl) { TString a, b; @@ -195,15 +195,15 @@ static void TestEncodeStrictDecodeIntoString(const TString& plain, const TString UNIT_ASSERT_VALUES_EQUAL(b, plain); } -Y_UNIT_TEST_SUITE(TBase64) { - Y_UNIT_TEST(TestEncode) { +Y_UNIT_TEST_SUITE(TBase64) { + Y_UNIT_TEST(TestEncode) { UNIT_ASSERT_VALUES_EQUAL(Base64Encode("12z"), "MTJ6"); UNIT_ASSERT_VALUES_EQUAL(Base64Encode("123"), "MTIz"); UNIT_ASSERT_VALUES_EQUAL(Base64Encode("12"), "MTI="); UNIT_ASSERT_VALUES_EQUAL(Base64Encode("1"), "MQ=="); } - Y_UNIT_TEST(TestIntoString) { + Y_UNIT_TEST(TestIntoString) { { TString str; for (size_t i = 0; i < 256; ++i) @@ -241,7 +241,7 @@ Y_UNIT_TEST_SUITE(TBase64) { } } - Y_UNIT_TEST(TestDecode) { + Y_UNIT_TEST(TestDecode) { UNIT_ASSERT_EXCEPTION(Base64Decode("a"), yexception); UNIT_ASSERT_EXCEPTION(Base64StrictDecode("a"), yexception); @@ -285,7 +285,7 @@ Y_UNIT_TEST_SUITE(TBase64) { UNIT_ASSERT_VALUES_EQUAL(Base64DecodeUneven("dnluZHg"), "vyndx"); } - Y_UNIT_TEST(TestDecodeRandom) { + Y_UNIT_TEST(TestDecodeRandom) { TString input; constexpr size_t testSize = 240000; for (size_t i = 0; i < testSize; ++i) { @@ -296,202 +296,202 @@ Y_UNIT_TEST_SUITE(TBase64) { UNIT_ASSERT_VALUES_EQUAL(Base64Decode(encoded), input); UNIT_ASSERT_VALUES_EQUAL(Base64StrictDecode(encoded), input); } - - Y_UNIT_TEST(TestAllPossibleOctets) { + + Y_UNIT_TEST(TestAllPossibleOctets) { const TString x("\0\x01\x02\x03\x04\x05\x06\x07\b\t\n\x0B\f\r\x0E\x0F\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\x7F"sv); const TString xEnc = "AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gISIjJCUmJygpKissLS4vMDEyMzQ1Njc4OTo7PD0+P0BBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWltcXV5fYGFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6e3x9fn8="; const TString y = Base64Decode(xEnc); const TString yEnc = Base64Encode(x); - UNIT_ASSERT_VALUES_EQUAL(x, y); - UNIT_ASSERT_VALUES_EQUAL(xEnc, yEnc); - } - - Y_UNIT_TEST(TestTwoPaddingCharacters) { + UNIT_ASSERT_VALUES_EQUAL(x, y); + UNIT_ASSERT_VALUES_EQUAL(xEnc, yEnc); + } + + Y_UNIT_TEST(TestTwoPaddingCharacters) { const TString x("a"); const TString xEnc = "YQ=="; const TString y = Base64Decode(xEnc); const TString yEnc = Base64Encode(x); - UNIT_ASSERT_VALUES_EQUAL(x, y); - UNIT_ASSERT_VALUES_EQUAL(xEnc, yEnc); - } - - Y_UNIT_TEST(TestOnePaddingCharacter) { + UNIT_ASSERT_VALUES_EQUAL(x, y); + UNIT_ASSERT_VALUES_EQUAL(xEnc, yEnc); + } + + Y_UNIT_TEST(TestOnePaddingCharacter) { const TString x("aa"); const TString xEnc = "YWE="; const TString y = Base64Decode(xEnc); const TString yEnc = Base64Encode(x); - UNIT_ASSERT_VALUES_EQUAL(x, y); - UNIT_ASSERT_VALUES_EQUAL(xEnc, yEnc); - } - - Y_UNIT_TEST(TestNoPaddingCharacters) { + UNIT_ASSERT_VALUES_EQUAL(x, y); + UNIT_ASSERT_VALUES_EQUAL(xEnc, yEnc); + } + + Y_UNIT_TEST(TestNoPaddingCharacters) { const TString x("aaa"); const TString xEnc = "YWFh"; const TString y = Base64Decode(xEnc); const TString yEnc = Base64Encode(x); - UNIT_ASSERT_VALUES_EQUAL(x, y); - UNIT_ASSERT_VALUES_EQUAL(xEnc, yEnc); - } - - Y_UNIT_TEST(TestTrailingZero) { + UNIT_ASSERT_VALUES_EQUAL(x, y); + UNIT_ASSERT_VALUES_EQUAL(xEnc, yEnc); + } + + Y_UNIT_TEST(TestTrailingZero) { const TString x("foo\0"sv); const TString xEnc = "Zm9vAA=="; const TString y = Base64Decode(xEnc); const TString yEnc = Base64Encode(x); - UNIT_ASSERT_VALUES_EQUAL(x, y); - UNIT_ASSERT_VALUES_EQUAL(xEnc, yEnc); - } - - Y_UNIT_TEST(TestTwoTrailingZeroes) { + UNIT_ASSERT_VALUES_EQUAL(x, y); + UNIT_ASSERT_VALUES_EQUAL(xEnc, yEnc); + } + + Y_UNIT_TEST(TestTwoTrailingZeroes) { const TString x("foo\0\0"sv); const TString xEnc = "Zm9vAAA="; const TString y = Base64Decode(xEnc); const TString yEnc = Base64Encode(x); - UNIT_ASSERT_VALUES_EQUAL(x, y); - UNIT_ASSERT_VALUES_EQUAL(xEnc, yEnc); - } - - Y_UNIT_TEST(TestZero) { + UNIT_ASSERT_VALUES_EQUAL(x, y); + UNIT_ASSERT_VALUES_EQUAL(xEnc, yEnc); + } + + Y_UNIT_TEST(TestZero) { const TString x("\0"sv); const TString xEnc = "AA=="; const TString y = Base64Decode(xEnc); const TString yEnc = Base64Encode(x); - UNIT_ASSERT_VALUES_EQUAL(x, y); - UNIT_ASSERT_VALUES_EQUAL(xEnc, yEnc); - } - - Y_UNIT_TEST(TestSymbolsAfterZero) { + UNIT_ASSERT_VALUES_EQUAL(x, y); + UNIT_ASSERT_VALUES_EQUAL(xEnc, yEnc); + } + + Y_UNIT_TEST(TestSymbolsAfterZero) { const TString x("\0a"sv); const TString xEnc = "AGE="; const TString y = Base64Decode(xEnc); const TString yEnc = Base64Encode(x); - UNIT_ASSERT_VALUES_EQUAL(x, y); - UNIT_ASSERT_VALUES_EQUAL(xEnc, yEnc); - } - - Y_UNIT_TEST(TestEmptyString) { + UNIT_ASSERT_VALUES_EQUAL(x, y); + UNIT_ASSERT_VALUES_EQUAL(xEnc, yEnc); + } + + Y_UNIT_TEST(TestEmptyString) { const TString x = ""; const TString xEnc = ""; const TString y = Base64Decode(xEnc); const TString yEnc = Base64Encode(x); - UNIT_ASSERT_VALUES_EQUAL(x, y); - UNIT_ASSERT_VALUES_EQUAL(xEnc, yEnc); - } - - Y_UNIT_TEST(TestBackendsConsistencyOnRandomData) { - constexpr size_t TEST_CASES_COUNT = 1000; - constexpr size_t MAX_DATA_SIZE = 1000; - TFastRng<ui32> prng{42}; + UNIT_ASSERT_VALUES_EQUAL(x, y); + UNIT_ASSERT_VALUES_EQUAL(xEnc, yEnc); + } + + Y_UNIT_TEST(TestBackendsConsistencyOnRandomData) { + constexpr size_t TEST_CASES_COUNT = 1000; + constexpr size_t MAX_DATA_SIZE = 1000; + TFastRng<ui32> prng{42}; TVector<TString> xs{TEST_CASES_COUNT}; TString xEnc; TString xDec; TString yEnc; TString yDec; - - for (auto& x : xs) { - const size_t size = prng() % MAX_DATA_SIZE; - for (size_t j = 0; j < size; ++j) { - x += static_cast<char>(prng() % 256); - } - } - - static const auto IMPLS = NB64Etalon::GetImpls(); - for (size_t i = 0; i < static_cast<size_t>(NB64Etalon::TImpls::MAX_IMPL); ++i) { - for (size_t j = 0; j < static_cast<size_t>(NB64Etalon::TImpls::MAX_IMPL); ++j) { - const auto ei = static_cast<NB64Etalon::TImpls::EImpl>(i); - const auto ej = static_cast<NB64Etalon::TImpls::EImpl>(j); - const auto impl = IMPLS.Impl[i]; - const auto otherImpl = IMPLS.Impl[j]; - if (!impl.Encode && !impl.Decode || !otherImpl.Encode && !otherImpl.Decode) { - continue; - } - - for (const auto& x : xs) { - impl.Encode(x, xEnc); - impl.Decode(xEnc, xDec); - Y_ENSURE(x == xDec, "something is wrong with " << ei << " implementation"); - - otherImpl.Encode(x, yEnc); - otherImpl.Decode(xEnc, yDec); - Y_ENSURE(x == yDec, "something is wrong with " << ej << " implementation"); - - UNIT_ASSERT_VALUES_EQUAL(xEnc, yEnc); - UNIT_ASSERT_VALUES_EQUAL(xDec, yDec); - } - } - } - } - - Y_UNIT_TEST(TestIfEncodedDataIsZeroTerminatedOnRandomData) { - constexpr size_t TEST_CASES_COUNT = 1000; - constexpr size_t MAX_DATA_SIZE = 1000; - TFastRng<ui32> prng{42}; + + for (auto& x : xs) { + const size_t size = prng() % MAX_DATA_SIZE; + for (size_t j = 0; j < size; ++j) { + x += static_cast<char>(prng() % 256); + } + } + + static const auto IMPLS = NB64Etalon::GetImpls(); + for (size_t i = 0; i < static_cast<size_t>(NB64Etalon::TImpls::MAX_IMPL); ++i) { + for (size_t j = 0; j < static_cast<size_t>(NB64Etalon::TImpls::MAX_IMPL); ++j) { + const auto ei = static_cast<NB64Etalon::TImpls::EImpl>(i); + const auto ej = static_cast<NB64Etalon::TImpls::EImpl>(j); + const auto impl = IMPLS.Impl[i]; + const auto otherImpl = IMPLS.Impl[j]; + if (!impl.Encode && !impl.Decode || !otherImpl.Encode && !otherImpl.Decode) { + continue; + } + + for (const auto& x : xs) { + impl.Encode(x, xEnc); + impl.Decode(xEnc, xDec); + Y_ENSURE(x == xDec, "something is wrong with " << ei << " implementation"); + + otherImpl.Encode(x, yEnc); + otherImpl.Decode(xEnc, yDec); + Y_ENSURE(x == yDec, "something is wrong with " << ej << " implementation"); + + UNIT_ASSERT_VALUES_EQUAL(xEnc, yEnc); + UNIT_ASSERT_VALUES_EQUAL(xDec, yDec); + } + } + } + } + + Y_UNIT_TEST(TestIfEncodedDataIsZeroTerminatedOnRandomData) { + constexpr size_t TEST_CASES_COUNT = 1000; + constexpr size_t MAX_DATA_SIZE = 1000; + TFastRng<ui32> prng{42}; TString x; TVector<char> buf; - for (size_t i = 0; i < TEST_CASES_COUNT; ++i) { - const size_t size = prng() % MAX_DATA_SIZE; - x.clear(); - for (size_t j = 0; j < size; ++j) { - x += static_cast<char>(prng() % 256); - } - - buf.assign(Base64EncodeBufSize(x.size()), Max<char>()); + for (size_t i = 0; i < TEST_CASES_COUNT; ++i) { + const size_t size = prng() % MAX_DATA_SIZE; + x.clear(); + for (size_t j = 0; j < size; ++j) { + x += static_cast<char>(prng() % 256); + } + + buf.assign(Base64EncodeBufSize(x.size()), Max<char>()); const auto* const xEncEnd = Base64Encode(buf.data(), (const unsigned char*)x.data(), x.size()); - UNIT_ASSERT_VALUES_EQUAL(*xEncEnd, '\0'); - } - } - - Y_UNIT_TEST(TestDecodeURLEncodedNoPadding) { - const auto x = "123"; - const auto xDec = Base64Decode("MTIz"); - UNIT_ASSERT_VALUES_EQUAL(x, xDec); - } - - Y_UNIT_TEST(TestDecodeURLEncodedOnePadding) { - const auto x = "12"; - const auto xDec = Base64Decode("MTI,"); - UNIT_ASSERT_VALUES_EQUAL(x, xDec); - } - - Y_UNIT_TEST(TestDecodeURLEncodedTwoPadding) { - const auto x = "1"; - const auto xDec = Base64Decode("MQ,,"); - UNIT_ASSERT_VALUES_EQUAL(x, xDec); - } - - Y_UNIT_TEST(TestDecodeNoPaddingLongString) { - const auto x = "How do I convert between big-endian and little-endian values in C++?a"; - const auto xDec = Base64Decode("SG93IGRvIEkgY29udmVydCBiZXR3ZWVuIGJpZy1lbmRpYW4gYW5kIGxpdHRsZS1lbmRpYW4gdmFsdWVzIGluIEMrKz9h"); - UNIT_ASSERT_VALUES_EQUAL(x, xDec); - } - - Y_UNIT_TEST(TestDecodeOnePaddingLongString) { - const auto x = "How do I convert between big-endian and little-endian values in C++?"; - const auto xDec = Base64Decode("SG93IGRvIEkgY29udmVydCBiZXR3ZWVuIGJpZy1lbmRpYW4gYW5kIGxpdHRsZS1lbmRpYW4gdmFsdWVzIGluIEMrKz8="); - UNIT_ASSERT_VALUES_EQUAL(x, xDec); - } - - Y_UNIT_TEST(TestDecodeTwoPaddingLongString) { - const auto x = "How do I convert between big-endian and little-endian values in C++?aa"; - const auto xDec = Base64Decode("SG93IGRvIEkgY29udmVydCBiZXR3ZWVuIGJpZy1lbmRpYW4gYW5kIGxpdHRsZS1lbmRpYW4gdmFsdWVzIGluIEMrKz9hYQ=="); - UNIT_ASSERT_VALUES_EQUAL(x, xDec); - } - - Y_UNIT_TEST(TestDecodeURLEncodedNoPaddingLongString) { - const auto x = "How do I convert between big-endian and little-endian values in C++?a"; - const auto xDec = Base64Decode("SG93IGRvIEkgY29udmVydCBiZXR3ZWVuIGJpZy1lbmRpYW4gYW5kIGxpdHRsZS1lbmRpYW4gdmFsdWVzIGluIEMrKz9h"); - UNIT_ASSERT_VALUES_EQUAL(x, xDec); - } - - Y_UNIT_TEST(TestDecodeURLEncodedOnePaddingLongString) { - const auto x = "How do I convert between big-endian and little-endian values in C++?"; - const auto xDec = Base64Decode("SG93IGRvIEkgY29udmVydCBiZXR3ZWVuIGJpZy1lbmRpYW4gYW5kIGxpdHRsZS1lbmRpYW4gdmFsdWVzIGluIEMrKz8,"); - UNIT_ASSERT_VALUES_EQUAL(x, xDec); - } - - Y_UNIT_TEST(TestDecodeURLEncodedTwoPaddingLongString) { - const auto x = "How do I convert between big-endian and little-endian values in C++?aa"; - const auto xDec = Base64Decode("SG93IGRvIEkgY29udmVydCBiZXR3ZWVuIGJpZy1lbmRpYW4gYW5kIGxpdHRsZS1lbmRpYW4gdmFsdWVzIGluIEMrKz9hYQ,,"); - UNIT_ASSERT_VALUES_EQUAL(x, xDec); - } + UNIT_ASSERT_VALUES_EQUAL(*xEncEnd, '\0'); + } + } + + Y_UNIT_TEST(TestDecodeURLEncodedNoPadding) { + const auto x = "123"; + const auto xDec = Base64Decode("MTIz"); + UNIT_ASSERT_VALUES_EQUAL(x, xDec); + } + + Y_UNIT_TEST(TestDecodeURLEncodedOnePadding) { + const auto x = "12"; + const auto xDec = Base64Decode("MTI,"); + UNIT_ASSERT_VALUES_EQUAL(x, xDec); + } + + Y_UNIT_TEST(TestDecodeURLEncodedTwoPadding) { + const auto x = "1"; + const auto xDec = Base64Decode("MQ,,"); + UNIT_ASSERT_VALUES_EQUAL(x, xDec); + } + + Y_UNIT_TEST(TestDecodeNoPaddingLongString) { + const auto x = "How do I convert between big-endian and little-endian values in C++?a"; + const auto xDec = Base64Decode("SG93IGRvIEkgY29udmVydCBiZXR3ZWVuIGJpZy1lbmRpYW4gYW5kIGxpdHRsZS1lbmRpYW4gdmFsdWVzIGluIEMrKz9h"); + UNIT_ASSERT_VALUES_EQUAL(x, xDec); + } + + Y_UNIT_TEST(TestDecodeOnePaddingLongString) { + const auto x = "How do I convert between big-endian and little-endian values in C++?"; + const auto xDec = Base64Decode("SG93IGRvIEkgY29udmVydCBiZXR3ZWVuIGJpZy1lbmRpYW4gYW5kIGxpdHRsZS1lbmRpYW4gdmFsdWVzIGluIEMrKz8="); + UNIT_ASSERT_VALUES_EQUAL(x, xDec); + } + + Y_UNIT_TEST(TestDecodeTwoPaddingLongString) { + const auto x = "How do I convert between big-endian and little-endian values in C++?aa"; + const auto xDec = Base64Decode("SG93IGRvIEkgY29udmVydCBiZXR3ZWVuIGJpZy1lbmRpYW4gYW5kIGxpdHRsZS1lbmRpYW4gdmFsdWVzIGluIEMrKz9hYQ=="); + UNIT_ASSERT_VALUES_EQUAL(x, xDec); + } + + Y_UNIT_TEST(TestDecodeURLEncodedNoPaddingLongString) { + const auto x = "How do I convert between big-endian and little-endian values in C++?a"; + const auto xDec = Base64Decode("SG93IGRvIEkgY29udmVydCBiZXR3ZWVuIGJpZy1lbmRpYW4gYW5kIGxpdHRsZS1lbmRpYW4gdmFsdWVzIGluIEMrKz9h"); + UNIT_ASSERT_VALUES_EQUAL(x, xDec); + } + + Y_UNIT_TEST(TestDecodeURLEncodedOnePaddingLongString) { + const auto x = "How do I convert between big-endian and little-endian values in C++?"; + const auto xDec = Base64Decode("SG93IGRvIEkgY29udmVydCBiZXR3ZWVuIGJpZy1lbmRpYW4gYW5kIGxpdHRsZS1lbmRpYW4gdmFsdWVzIGluIEMrKz8,"); + UNIT_ASSERT_VALUES_EQUAL(x, xDec); + } + + Y_UNIT_TEST(TestDecodeURLEncodedTwoPaddingLongString) { + const auto x = "How do I convert between big-endian and little-endian values in C++?aa"; + const auto xDec = Base64Decode("SG93IGRvIEkgY29udmVydCBiZXR3ZWVuIGJpZy1lbmRpYW4gYW5kIGxpdHRsZS1lbmRpYW4gdmFsdWVzIGluIEMrKz9hYQ,,"); + UNIT_ASSERT_VALUES_EQUAL(x, xDec); + } } diff --git a/library/cpp/string_utils/base64/bench/main.cpp b/library/cpp/string_utils/base64/bench/main.cpp index 10e09bc1c75..f3f8280136a 100644 --- a/library/cpp/string_utils/base64/bench/main.cpp +++ b/library/cpp/string_utils/base64/bench/main.cpp @@ -1,110 +1,110 @@ #include <library/cpp/string_utils/base64/base64.h> - + #include <library/cpp/testing/benchmark/bench.h> - -#include <util/generic/buffer.h> -#include <util/generic/singleton.h> + +#include <util/generic/buffer.h> +#include <util/generic/singleton.h> #include <util/generic/string.h> -#include <util/generic/vector.h> -#include <util/generic/xrange.h> -#include <util/generic/yexception.h> -#include <util/random/random.h> - -#include <array> - +#include <util/generic/vector.h> +#include <util/generic/xrange.h> +#include <util/generic/yexception.h> +#include <util/random/random.h> + +#include <array> + static TString GenerateRandomData(const size_t minSize, const size_t maxSize) { - Y_ENSURE(minSize <= maxSize, "wow"); + Y_ENSURE(minSize <= maxSize, "wow"); TString r; - for (size_t i = 0; i < minSize; ++i) { - r.push_back(RandomNumber<char>()); - } - - if (minSize == maxSize) { - return r; - } - - const size_t size = RandomNumber<size_t>() % (maxSize - minSize + 1); - for (size_t i = 0; i < size; ++i) { - r.push_back(RandomNumber<char>()); - } - - return r; -} - -template <size_t N> + for (size_t i = 0; i < minSize; ++i) { + r.push_back(RandomNumber<char>()); + } + + if (minSize == maxSize) { + return r; + } + + const size_t size = RandomNumber<size_t>() % (maxSize - minSize + 1); + for (size_t i = 0; i < size; ++i) { + r.push_back(RandomNumber<char>()); + } + + return r; +} + +template <size_t N> static std::array<TString, N> GenerateRandomDataVector(const size_t minSize, const size_t maxSize) { std::array<TString, N> r; - for (size_t i = 0; i < N; ++i) { - r[i] = GenerateRandomData(minSize, maxSize); - } - - return r; -} - -template <size_t N> + for (size_t i = 0; i < N; ++i) { + r[i] = GenerateRandomData(minSize, maxSize); + } + + return r; +} + +template <size_t N> static std::array<TString, N> Encode(const std::array<TString, N>& d) { std::array<TString, N> r; - for (size_t i = 0, iEnd = d.size(); i < iEnd; ++i) { - r[i] = Base64Encode(d[i]); - } - - return r; -} - -namespace { - template <size_t N, size_t MinSize, size_t MaxSize> - struct TRandomDataHolder { - TRandomDataHolder() - : Data(GenerateRandomDataVector<N>(MinSize, MaxSize)) - , DataEncoded(Encode<N>(Data)) - { - for (size_t i = 0; i < N; ++i) { - const size_t size = Data[i].size(); - const size_t sizeEnc = DataEncoded[i].size(); - PlaceToEncode[i].Resize(Base64EncodeBufSize(size)); - PlaceToDecode[i].Resize(Base64DecodeBufSize(sizeEnc)); - } - } - - static constexpr size_t Size = N; + for (size_t i = 0, iEnd = d.size(); i < iEnd; ++i) { + r[i] = Base64Encode(d[i]); + } + + return r; +} + +namespace { + template <size_t N, size_t MinSize, size_t MaxSize> + struct TRandomDataHolder { + TRandomDataHolder() + : Data(GenerateRandomDataVector<N>(MinSize, MaxSize)) + , DataEncoded(Encode<N>(Data)) + { + for (size_t i = 0; i < N; ++i) { + const size_t size = Data[i].size(); + const size_t sizeEnc = DataEncoded[i].size(); + PlaceToEncode[i].Resize(Base64EncodeBufSize(size)); + PlaceToDecode[i].Resize(Base64DecodeBufSize(sizeEnc)); + } + } + + static constexpr size_t Size = N; const std::array<TString, N> Data; const std::array<TString, N> DataEncoded; - std::array<TBuffer, N> PlaceToEncode; - std::array<TBuffer, N> PlaceToDecode; - }; - - template <size_t N, size_t Size> - using TFixedSizeRandomDataHolder = TRandomDataHolder<N, Size, Size>; - - using FSRDH_1 = TFixedSizeRandomDataHolder<10, 1>; - using FSRDH_2 = TFixedSizeRandomDataHolder<10, 2>; - using FSRDH_4 = TFixedSizeRandomDataHolder<10, 4>; - using FSRDH_8 = TFixedSizeRandomDataHolder<10, 8>; - using FSRDH_16 = TFixedSizeRandomDataHolder<10, 16>; - using FSRDH_32 = TFixedSizeRandomDataHolder<10, 32>; - using FSRDH_64 = TFixedSizeRandomDataHolder<10, 64>; - using FSRDH_128 = TFixedSizeRandomDataHolder<10, 128>; - using FSRDH_1024 = TFixedSizeRandomDataHolder<10, 1024>; - using FSRDH_10240 = TFixedSizeRandomDataHolder<10, 10240>; - using FSRDH_102400 = TFixedSizeRandomDataHolder<10, 102400>; - using FSRDH_1048576 = TFixedSizeRandomDataHolder<10, 1048576>; - using FSRDH_10485760 = TFixedSizeRandomDataHolder<10, 10485760>; -} - -template <typename T> -static inline void BenchEncode(T& d, const NBench::NCpu::TParams& iface) { - for (const auto it : xrange(iface.Iterations())) { - Y_UNUSED(it); - for (size_t i = 0; i < d.Size; ++i) { + std::array<TBuffer, N> PlaceToEncode; + std::array<TBuffer, N> PlaceToDecode; + }; + + template <size_t N, size_t Size> + using TFixedSizeRandomDataHolder = TRandomDataHolder<N, Size, Size>; + + using FSRDH_1 = TFixedSizeRandomDataHolder<10, 1>; + using FSRDH_2 = TFixedSizeRandomDataHolder<10, 2>; + using FSRDH_4 = TFixedSizeRandomDataHolder<10, 4>; + using FSRDH_8 = TFixedSizeRandomDataHolder<10, 8>; + using FSRDH_16 = TFixedSizeRandomDataHolder<10, 16>; + using FSRDH_32 = TFixedSizeRandomDataHolder<10, 32>; + using FSRDH_64 = TFixedSizeRandomDataHolder<10, 64>; + using FSRDH_128 = TFixedSizeRandomDataHolder<10, 128>; + using FSRDH_1024 = TFixedSizeRandomDataHolder<10, 1024>; + using FSRDH_10240 = TFixedSizeRandomDataHolder<10, 10240>; + using FSRDH_102400 = TFixedSizeRandomDataHolder<10, 102400>; + using FSRDH_1048576 = TFixedSizeRandomDataHolder<10, 1048576>; + using FSRDH_10485760 = TFixedSizeRandomDataHolder<10, 10485760>; +} + +template <typename T> +static inline void BenchEncode(T& d, const NBench::NCpu::TParams& iface) { + for (const auto it : xrange(iface.Iterations())) { + Y_UNUSED(it); + for (size_t i = 0; i < d.Size; ++i) { NBench::Escape(d.PlaceToEncode[i].data()); - Y_DO_NOT_OPTIMIZE_AWAY( + Y_DO_NOT_OPTIMIZE_AWAY( Base64Encode(d.PlaceToEncode[i].data(), (const unsigned char*)d.Data[i].data(), d.Data[i].size())); - NBench::Clobber(); - } - } -} - -template <typename T> + NBench::Clobber(); + } + } +} + +template <typename T> static inline void BenchEncodeUrl(T& d, const NBench::NCpu::TParams& iface) { for (const auto it : xrange(iface.Iterations())) { Y_UNUSED(it); @@ -118,147 +118,147 @@ static inline void BenchEncodeUrl(T& d, const NBench::NCpu::TParams& iface) { } template <typename T> -static inline void BenchDecode(T& d, const NBench::NCpu::TParams& iface) { - for (const auto it : xrange(iface.Iterations())) { - Y_UNUSED(it); - for (size_t i = 0; i < d.Size; ++i) { +static inline void BenchDecode(T& d, const NBench::NCpu::TParams& iface) { + for (const auto it : xrange(iface.Iterations())) { + Y_UNUSED(it); + for (size_t i = 0; i < d.Size; ++i) { NBench::Escape(d.PlaceToDecode[i].data()); - Y_DO_NOT_OPTIMIZE_AWAY( + Y_DO_NOT_OPTIMIZE_AWAY( Base64Decode(d.PlaceToDecode[i].data(), (const char*)d.DataEncoded[i].data(), (const char*)(d.DataEncoded[i].data() + d.DataEncoded[i].size()))); - NBench::Clobber(); - } - } -} - -Y_CPU_BENCHMARK(EncodeF1, iface) { - auto& d = *Singleton<FSRDH_1>(); - BenchEncode(d, iface); -} - -Y_CPU_BENCHMARK(DecodeF1, iface) { - auto& d = *Singleton<FSRDH_1>(); - BenchDecode(d, iface); -} - -Y_CPU_BENCHMARK(EncodeF2, iface) { - auto& d = *Singleton<FSRDH_2>(); - BenchEncode(d, iface); -} - -Y_CPU_BENCHMARK(DecodeF2, iface) { - auto& d = *Singleton<FSRDH_2>(); - BenchDecode(d, iface); -} - -Y_CPU_BENCHMARK(EncodeF4, iface) { - auto& d = *Singleton<FSRDH_4>(); - BenchEncode(d, iface); -} - -Y_CPU_BENCHMARK(DecodeF4, iface) { - auto& d = *Singleton<FSRDH_4>(); - BenchDecode(d, iface); -} - -Y_CPU_BENCHMARK(EncodeF8, iface) { - auto& d = *Singleton<FSRDH_8>(); - BenchEncode(d, iface); -} - -Y_CPU_BENCHMARK(DecodeF8, iface) { - auto& d = *Singleton<FSRDH_8>(); - BenchDecode(d, iface); -} - -Y_CPU_BENCHMARK(EncodeF16, iface) { - auto& d = *Singleton<FSRDH_16>(); - BenchEncode(d, iface); -} - -Y_CPU_BENCHMARK(DecodeF16, iface) { - auto& d = *Singleton<FSRDH_16>(); - BenchDecode(d, iface); -} - -Y_CPU_BENCHMARK(EncodeF32, iface) { - auto& d = *Singleton<FSRDH_32>(); - BenchEncode(d, iface); -} - -Y_CPU_BENCHMARK(DecodeF32, iface) { - auto& d = *Singleton<FSRDH_32>(); - BenchDecode(d, iface); -} - -Y_CPU_BENCHMARK(EncodeF64, iface) { - auto& d = *Singleton<FSRDH_64>(); - BenchEncode(d, iface); -} - -Y_CPU_BENCHMARK(DecodeF64, iface) { - auto& d = *Singleton<FSRDH_64>(); - BenchDecode(d, iface); -} - -Y_CPU_BENCHMARK(EncodeF128, iface) { - auto& d = *Singleton<FSRDH_128>(); - BenchEncode(d, iface); -} - -Y_CPU_BENCHMARK(DecodeF128, iface) { - auto& d = *Singleton<FSRDH_128>(); - BenchDecode(d, iface); -} - -Y_CPU_BENCHMARK(EncodeF1024, iface) { - auto& d = *Singleton<FSRDH_1024>(); - BenchEncode(d, iface); -} - -Y_CPU_BENCHMARK(DecodeF1024, iface) { - auto& d = *Singleton<FSRDH_1024>(); - BenchDecode(d, iface); -} - -Y_CPU_BENCHMARK(EncodeF10240, iface) { - auto& d = *Singleton<FSRDH_10240>(); - BenchEncode(d, iface); -} - -Y_CPU_BENCHMARK(DecodeF10240, iface) { - auto& d = *Singleton<FSRDH_10240>(); - BenchDecode(d, iface); -} - -Y_CPU_BENCHMARK(EncodeF102400, iface) { - auto& d = *Singleton<FSRDH_102400>(); - BenchEncode(d, iface); -} - -Y_CPU_BENCHMARK(DecodeF102400, iface) { - auto& d = *Singleton<FSRDH_102400>(); - BenchDecode(d, iface); -} - -Y_CPU_BENCHMARK(EncodeF1048576, iface) { - auto& d = *Singleton<FSRDH_1048576>(); - BenchEncode(d, iface); -} - -Y_CPU_BENCHMARK(DecodeF1048576, iface) { - auto& d = *Singleton<FSRDH_1048576>(); - BenchDecode(d, iface); -} - -Y_CPU_BENCHMARK(EncodeF10485760, iface) { - auto& d = *Singleton<FSRDH_10485760>(); - BenchEncode(d, iface); -} - -Y_CPU_BENCHMARK(DecodeF10485760, iface) { - auto& d = *Singleton<FSRDH_10485760>(); - BenchDecode(d, iface); -} + NBench::Clobber(); + } + } +} + +Y_CPU_BENCHMARK(EncodeF1, iface) { + auto& d = *Singleton<FSRDH_1>(); + BenchEncode(d, iface); +} + +Y_CPU_BENCHMARK(DecodeF1, iface) { + auto& d = *Singleton<FSRDH_1>(); + BenchDecode(d, iface); +} + +Y_CPU_BENCHMARK(EncodeF2, iface) { + auto& d = *Singleton<FSRDH_2>(); + BenchEncode(d, iface); +} + +Y_CPU_BENCHMARK(DecodeF2, iface) { + auto& d = *Singleton<FSRDH_2>(); + BenchDecode(d, iface); +} + +Y_CPU_BENCHMARK(EncodeF4, iface) { + auto& d = *Singleton<FSRDH_4>(); + BenchEncode(d, iface); +} + +Y_CPU_BENCHMARK(DecodeF4, iface) { + auto& d = *Singleton<FSRDH_4>(); + BenchDecode(d, iface); +} + +Y_CPU_BENCHMARK(EncodeF8, iface) { + auto& d = *Singleton<FSRDH_8>(); + BenchEncode(d, iface); +} + +Y_CPU_BENCHMARK(DecodeF8, iface) { + auto& d = *Singleton<FSRDH_8>(); + BenchDecode(d, iface); +} + +Y_CPU_BENCHMARK(EncodeF16, iface) { + auto& d = *Singleton<FSRDH_16>(); + BenchEncode(d, iface); +} + +Y_CPU_BENCHMARK(DecodeF16, iface) { + auto& d = *Singleton<FSRDH_16>(); + BenchDecode(d, iface); +} + +Y_CPU_BENCHMARK(EncodeF32, iface) { + auto& d = *Singleton<FSRDH_32>(); + BenchEncode(d, iface); +} + +Y_CPU_BENCHMARK(DecodeF32, iface) { + auto& d = *Singleton<FSRDH_32>(); + BenchDecode(d, iface); +} + +Y_CPU_BENCHMARK(EncodeF64, iface) { + auto& d = *Singleton<FSRDH_64>(); + BenchEncode(d, iface); +} + +Y_CPU_BENCHMARK(DecodeF64, iface) { + auto& d = *Singleton<FSRDH_64>(); + BenchDecode(d, iface); +} + +Y_CPU_BENCHMARK(EncodeF128, iface) { + auto& d = *Singleton<FSRDH_128>(); + BenchEncode(d, iface); +} + +Y_CPU_BENCHMARK(DecodeF128, iface) { + auto& d = *Singleton<FSRDH_128>(); + BenchDecode(d, iface); +} + +Y_CPU_BENCHMARK(EncodeF1024, iface) { + auto& d = *Singleton<FSRDH_1024>(); + BenchEncode(d, iface); +} + +Y_CPU_BENCHMARK(DecodeF1024, iface) { + auto& d = *Singleton<FSRDH_1024>(); + BenchDecode(d, iface); +} + +Y_CPU_BENCHMARK(EncodeF10240, iface) { + auto& d = *Singleton<FSRDH_10240>(); + BenchEncode(d, iface); +} + +Y_CPU_BENCHMARK(DecodeF10240, iface) { + auto& d = *Singleton<FSRDH_10240>(); + BenchDecode(d, iface); +} + +Y_CPU_BENCHMARK(EncodeF102400, iface) { + auto& d = *Singleton<FSRDH_102400>(); + BenchEncode(d, iface); +} + +Y_CPU_BENCHMARK(DecodeF102400, iface) { + auto& d = *Singleton<FSRDH_102400>(); + BenchDecode(d, iface); +} + +Y_CPU_BENCHMARK(EncodeF1048576, iface) { + auto& d = *Singleton<FSRDH_1048576>(); + BenchEncode(d, iface); +} + +Y_CPU_BENCHMARK(DecodeF1048576, iface) { + auto& d = *Singleton<FSRDH_1048576>(); + BenchDecode(d, iface); +} + +Y_CPU_BENCHMARK(EncodeF10485760, iface) { + auto& d = *Singleton<FSRDH_10485760>(); + BenchEncode(d, iface); +} + +Y_CPU_BENCHMARK(DecodeF10485760, iface) { + auto& d = *Singleton<FSRDH_10485760>(); + BenchDecode(d, iface); +} Y_CPU_BENCHMARK(EncodeUrlF1, iface) { auto& d = *Singleton<FSRDH_1>(); diff --git a/library/cpp/string_utils/base64/bench/metrics/main.py b/library/cpp/string_utils/base64/bench/metrics/main.py index c35fd6d8cd4..79577bf4d4b 100644 --- a/library/cpp/string_utils/base64/bench/metrics/main.py +++ b/library/cpp/string_utils/base64/bench/metrics/main.py @@ -1,5 +1,5 @@ -import yatest.common as yc - - -def test_export_metrics(metrics): +import yatest.common as yc + + +def test_export_metrics(metrics): metrics.set_benchmark(yc.execute_benchmark('library/cpp/string_utils/base64/bench/bench')) diff --git a/library/cpp/string_utils/base64/bench/metrics/ya.make b/library/cpp/string_utils/base64/bench/metrics/ya.make index b0406516c37..14b57dae22d 100644 --- a/library/cpp/string_utils/base64/bench/metrics/ya.make +++ b/library/cpp/string_utils/base64/bench/metrics/ya.make @@ -1,20 +1,20 @@ -OWNER( - yazevnul +OWNER( + yazevnul g:util -) - +) + PY2TEST() - + SIZE(LARGE) - -TAG( + +TAG( ya:force_sandbox - sb:intel_e5_2660v1 + sb:intel_e5_2660v1 ya:fat -) - +) + TEST_SRCS(main.py) - + DEPENDS(library/cpp/string_utils/base64/bench) - -END() + +END() diff --git a/library/cpp/string_utils/base64/bench/ya.make b/library/cpp/string_utils/base64/bench/ya.make index 5ac5f3d6ced..30a13c65091 100644 --- a/library/cpp/string_utils/base64/bench/ya.make +++ b/library/cpp/string_utils/base64/bench/ya.make @@ -1,16 +1,16 @@ -OWNER( - yazevnul +OWNER( + yazevnul g:util -) - +) + Y_BENCHMARK() - -SRCS( - main.cpp -) - -PEERDIR( + +SRCS( + main.cpp +) + +PEERDIR( library/cpp/string_utils/base64 -) - -END() +) + +END() diff --git a/library/cpp/string_utils/base64/fuzz/generic/ya.make b/library/cpp/string_utils/base64/fuzz/generic/ya.make index d155e2b0a08..608c12a09e4 100644 --- a/library/cpp/string_utils/base64/fuzz/generic/ya.make +++ b/library/cpp/string_utils/base64/fuzz/generic/ya.make @@ -1,12 +1,12 @@ -OWNER( - yazevnul +OWNER( + yazevnul g:util -) - -FUZZ() - -PEERDIR( +) + +FUZZ() + +PEERDIR( library/cpp/string_utils/base64/fuzz/lib -) - -END() +) + +END() diff --git a/library/cpp/string_utils/base64/fuzz/lib/main.cpp b/library/cpp/string_utils/base64/fuzz/lib/main.cpp index 28547ae7a5b..aec5655eec6 100644 --- a/library/cpp/string_utils/base64/fuzz/lib/main.cpp +++ b/library/cpp/string_utils/base64/fuzz/lib/main.cpp @@ -1,13 +1,13 @@ #include <library/cpp/string_utils/base64/base64.h> - -#include <util/system/types.h> -#include <util/system/yassert.h> - -extern "C" int LLVMFuzzerTestOneInput(const ui8* data, size_t size) { - const TStringBuf example{reinterpret_cast<const char*>(data), size}; - const auto converted = Base64Decode(Base64Encode(example)); - - Y_VERIFY(example == converted); - - return 0; -} + +#include <util/system/types.h> +#include <util/system/yassert.h> + +extern "C" int LLVMFuzzerTestOneInput(const ui8* data, size_t size) { + const TStringBuf example{reinterpret_cast<const char*>(data), size}; + const auto converted = Base64Decode(Base64Encode(example)); + + Y_VERIFY(example == converted); + + return 0; +} diff --git a/library/cpp/string_utils/base64/fuzz/lib/ya.make b/library/cpp/string_utils/base64/fuzz/lib/ya.make index 7b981b86a30..6fee5c9f990 100644 --- a/library/cpp/string_utils/base64/fuzz/lib/ya.make +++ b/library/cpp/string_utils/base64/fuzz/lib/ya.make @@ -1,16 +1,16 @@ -OWNER( - yazevnul +OWNER( + yazevnul g:util -) - -LIBRARY() - -SRCS( - main.cpp -) - -PEERDIR( +) + +LIBRARY() + +SRCS( + main.cpp +) + +PEERDIR( library/cpp/string_utils/base64 -) - -END() +) + +END() diff --git a/library/cpp/string_utils/base64/fuzz/ya.make b/library/cpp/string_utils/base64/fuzz/ya.make index bef82061c46..a0ed64f2735 100644 --- a/library/cpp/string_utils/base64/fuzz/ya.make +++ b/library/cpp/string_utils/base64/fuzz/ya.make @@ -1,10 +1,10 @@ -OWNER( - yazevnul +OWNER( + yazevnul g:util -) - -RECURSE( - generic - lib +) + +RECURSE( + generic + lib uneven -) +) diff --git a/library/cpp/string_utils/base64/ut/ya.make b/library/cpp/string_utils/base64/ut/ya.make index 9b61241f0e5..560d96423f1 100644 --- a/library/cpp/string_utils/base64/ut/ya.make +++ b/library/cpp/string_utils/base64/ut/ya.make @@ -1,22 +1,22 @@ -OWNER( +OWNER( g:util - yazevnul -) - + yazevnul +) + UNITTEST_FOR(library/cpp/string_utils/base64) - -SRCS( - base64_ut.cpp + +SRCS( + base64_ut.cpp base64_decode_uneven_ut.cpp -) - -PEERDIR( - contrib/libs/base64/avx2 - contrib/libs/base64/ssse3 - contrib/libs/base64/neon32 - contrib/libs/base64/neon64 - contrib/libs/base64/plain32 - contrib/libs/base64/plain64 -) - -END() +) + +PEERDIR( + contrib/libs/base64/avx2 + contrib/libs/base64/ssse3 + contrib/libs/base64/neon32 + contrib/libs/base64/neon64 + contrib/libs/base64/plain32 + contrib/libs/base64/plain64 +) + +END() diff --git a/library/cpp/string_utils/base64/ya.make b/library/cpp/string_utils/base64/ya.make index f5258c446cf..ee1ec0e0237 100644 --- a/library/cpp/string_utils/base64/ya.make +++ b/library/cpp/string_utils/base64/ya.make @@ -1,23 +1,23 @@ -OWNER( +OWNER( g:util - yazevnul -) - -LIBRARY() - -SRCS( - base64.cpp -) - -PEERDIR( - contrib/libs/base64/avx2 - contrib/libs/base64/ssse3 - contrib/libs/base64/neon32 - contrib/libs/base64/neon64 - contrib/libs/base64/plain32 - contrib/libs/base64/plain64 -) - -END() + yazevnul +) + +LIBRARY() + +SRCS( + base64.cpp +) + +PEERDIR( + contrib/libs/base64/avx2 + contrib/libs/base64/ssse3 + contrib/libs/base64/neon32 + contrib/libs/base64/neon64 + contrib/libs/base64/plain32 + contrib/libs/base64/plain64 +) + +END() RECURSE_FOR_TESTS(ut) diff --git a/library/cpp/string_utils/levenshtein_diff/levenshtein_diff.h b/library/cpp/string_utils/levenshtein_diff/levenshtein_diff.h index 8a240bfed8f..ac33cd87d25 100644 --- a/library/cpp/string_utils/levenshtein_diff/levenshtein_diff.h +++ b/library/cpp/string_utils/levenshtein_diff/levenshtein_diff.h @@ -112,7 +112,7 @@ namespace NLevenshtein { } // Tracing the path from final point res.clear(); - res.reserve(Max<size_t>(l1, l2)); + res.reserve(Max<size_t>(l1, l2)); for (int i = l1, j = l2; ma[i][j].second != EMT_SPECIAL;) { res.push_back(ma[i][j].second); switch (ma[i][j].second) { diff --git a/library/cpp/string_utils/levenshtein_diff/levenshtein_diff_ut.cpp b/library/cpp/string_utils/levenshtein_diff/levenshtein_diff_ut.cpp index cf0f78637f3..f8bdc941c85 100644 --- a/library/cpp/string_utils/levenshtein_diff/levenshtein_diff_ut.cpp +++ b/library/cpp/string_utils/levenshtein_diff/levenshtein_diff_ut.cpp @@ -24,8 +24,8 @@ namespace { } -Y_UNIT_TEST_SUITE(Levenstein) { - Y_UNIT_TEST(Distance) { +Y_UNIT_TEST_SUITE(Levenstein) { + Y_UNIT_TEST(Distance) { UNIT_ASSERT_VALUES_EQUAL(NLevenshtein::Distance(TStringBuf("hello"), TStringBuf("hulloah")), 3); UNIT_ASSERT_VALUES_EQUAL(NLevenshtein::Distance(TStringBuf("yeoman"), TStringBuf("yo man")), 2); } diff --git a/library/cpp/string_utils/parse_size/parse_size.cpp b/library/cpp/string_utils/parse_size/parse_size.cpp index 39188d560bf..8c521b1e0c0 100644 --- a/library/cpp/string_utils/parse_size/parse_size.cpp +++ b/library/cpp/string_utils/parse_size/parse_size.cpp @@ -90,6 +90,6 @@ NSize::TSize FromStringImpl<NSize::TSize>(const char* data, size_t len) { } template <> -void Out<NSize::TSize>(IOutputStream& os, const NSize::TSize& size) { +void Out<NSize::TSize>(IOutputStream& os, const NSize::TSize& size) { os << size.GetValue(); } diff --git a/library/cpp/string_utils/quote/quote.cpp b/library/cpp/string_utils/quote/quote.cpp index e523350b80a..e7ce5667db6 100644 --- a/library/cpp/string_utils/quote/quote.cpp +++ b/library/cpp/string_utils/quote/quote.cpp @@ -166,7 +166,7 @@ TString CGIEscapeRet(const TStringBuf url) { TString to; to.ReserveAndResize(CgiEscapeBufLen(url.size())); to.resize(CGIEscape(to.begin(), url.data(), url.size()) - to.data()); - return to; + return to; } TString& AppendCgiEscaped(const TStringBuf value, TString& to) { @@ -203,7 +203,7 @@ char* Quote(char* to, const char* from, const char* safe) { return Quote(to, FixZero(from), TCStringEndIterator(), safe); } -char* Quote(char* to, const TStringBuf s, const char* safe) { +char* Quote(char* to, const TStringBuf s, const char* safe) { return Quote(to, s.data(), s.data() + s.size(), safe); } @@ -239,7 +239,7 @@ TString CGIUnescapeRet(const TStringBuf from) { TString to; to.ReserveAndResize(CgiUnescapeBufLen(from.size())); to.resize(CGIUnescape(to.begin(), from.data(), from.size()) - to.data()); - return to; + return to; } char* UrlUnescape(char* to, TStringBuf from) { diff --git a/library/cpp/string_utils/quote/quote.h b/library/cpp/string_utils/quote/quote.h index 3b7221154eb..3cea6feba1d 100644 --- a/library/cpp/string_utils/quote/quote.h +++ b/library/cpp/string_utils/quote/quote.h @@ -10,17 +10,17 @@ // Returns pointer to the end of the result string char* CGIEscape(char* to, const char* from); char* CGIEscape(char* to, const char* from, size_t len); -inline char* CGIEscape(char* to, const TStringBuf from) { +inline char* CGIEscape(char* to, const TStringBuf from) { return CGIEscape(to, from.data(), from.size()); } void CGIEscape(TString& url); TString CGIEscapeRet(const TStringBuf url); TString& AppendCgiEscaped(const TStringBuf value, TString& to); -inline TStringBuf CgiEscapeBuf(char* to, const TStringBuf from) { +inline TStringBuf CgiEscapeBuf(char* to, const TStringBuf from) { return TStringBuf(to, CGIEscape(to, from.data(), from.size())); } -inline TStringBuf CgiEscape(void* tmp, const TStringBuf s) { +inline TStringBuf CgiEscape(void* tmp, const TStringBuf s) { return CgiEscapeBuf(static_cast<char*>(tmp), s); } @@ -33,17 +33,17 @@ char* CGIUnescape(char* to, const char* from, size_t len); void CGIUnescape(TString& url); TString CGIUnescapeRet(const TStringBuf from); -inline TStringBuf CgiUnescapeBuf(char* to, const TStringBuf from) { +inline TStringBuf CgiUnescapeBuf(char* to, const TStringBuf from) { return TStringBuf(to, CGIUnescape(to, from.data(), from.size())); } -inline TStringBuf CgiUnescape(void* tmp, const TStringBuf s) { +inline TStringBuf CgiUnescape(void* tmp, const TStringBuf s) { return CgiUnescapeBuf(static_cast<char*>(tmp), s); } //Quote: // Is like CGIEscape, also skips encoding of user-supplied 'safe' characters. char* Quote(char* to, const char* from, const char* safe = "/"); -char* Quote(char* to, const TStringBuf s, const char* safe = "/"); +char* Quote(char* to, const TStringBuf s, const char* safe = "/"); void Quote(TString& url, const char* safe = "/"); //UrlEscape: @@ -63,10 +63,10 @@ void UrlUnescape(TString& url); TString UrlUnescapeRet(const TStringBuf from); //*BufLen: how much characters you should allocate for 'char* to' buffers. -constexpr size_t CgiEscapeBufLen(const size_t len) noexcept { +constexpr size_t CgiEscapeBufLen(const size_t len) noexcept { return 3 * len + 1; } -constexpr size_t CgiUnescapeBufLen(const size_t len) noexcept { +constexpr size_t CgiUnescapeBufLen(const size_t len) noexcept { return len + 1; } diff --git a/library/cpp/string_utils/quote/quote_ut.cpp b/library/cpp/string_utils/quote/quote_ut.cpp index 6c552b279e1..f505cf669a1 100644 --- a/library/cpp/string_utils/quote/quote_ut.cpp +++ b/library/cpp/string_utils/quote/quote_ut.cpp @@ -2,15 +2,15 @@ #include <library/cpp/testing/unittest/registar.h> -Y_UNIT_TEST_SUITE(TCGIEscapeTest) { - Y_UNIT_TEST(ReturnsEndOfTo) { +Y_UNIT_TEST_SUITE(TCGIEscapeTest) { + Y_UNIT_TEST(ReturnsEndOfTo) { char r[10]; const char* returned = CGIEscape(r, "123"); UNIT_ASSERT_VALUES_EQUAL(r + strlen("123"), returned); UNIT_ASSERT_VALUES_EQUAL('\0', *returned); } - Y_UNIT_TEST(NotZeroTerminated) { + Y_UNIT_TEST(NotZeroTerminated) { char r[] = {'1', '2', '3', '4'}; char buf[sizeof(r) * 3 + 2]; @@ -19,13 +19,13 @@ Y_UNIT_TEST_SUITE(TCGIEscapeTest) { UNIT_ASSERT_EQUAL(ret, "1234"); } - Y_UNIT_TEST(StringBuf) { + Y_UNIT_TEST(StringBuf) { char tmp[100]; UNIT_ASSERT_VALUES_EQUAL(CgiEscape(tmp, "!@#$%^&*(){}[]\" "), TStringBuf("!@%23$%25^%26*%28%29%7B%7D%5B%5D%22+")); } - Y_UNIT_TEST(StrokaRet) { + Y_UNIT_TEST(StrokaRet) { UNIT_ASSERT_VALUES_EQUAL(CGIEscapeRet("!@#$%^&*(){}[]\" "), TString("!@%23$%25^%26*%28%29%7B%7D%5B%5D%22+")); } @@ -47,14 +47,14 @@ Y_UNIT_TEST_SUITE(TCGIEscapeTest) { } -Y_UNIT_TEST_SUITE(TCGIUnescapeTest) { - Y_UNIT_TEST(StringBuf) { +Y_UNIT_TEST_SUITE(TCGIUnescapeTest) { + Y_UNIT_TEST(StringBuf) { char tmp[100]; UNIT_ASSERT_VALUES_EQUAL(CgiUnescape(tmp, "!@%23$%25^%26*%28%29"), TStringBuf("!@#$%^&*()")); } - Y_UNIT_TEST(TestValidZeroTerm) { + Y_UNIT_TEST(TestValidZeroTerm) { char r[10]; CGIUnescape(r, "1234"); @@ -67,7 +67,7 @@ Y_UNIT_TEST_SUITE(TCGIUnescapeTest) { UNIT_ASSERT_VALUES_EQUAL(r, "12=34"); } - Y_UNIT_TEST(TestInvalidZeroTerm) { + Y_UNIT_TEST(TestInvalidZeroTerm) { char r[10]; CGIUnescape(r, "%"); @@ -86,7 +86,7 @@ Y_UNIT_TEST_SUITE(TCGIUnescapeTest) { UNIT_ASSERT_VALUES_EQUAL(r, "%3u123"); } - Y_UNIT_TEST(TestValidNotZeroTerm) { + Y_UNIT_TEST(TestValidNotZeroTerm) { char r[10]; CGIUnescape(r, "123456789", 4); @@ -99,7 +99,7 @@ Y_UNIT_TEST_SUITE(TCGIUnescapeTest) { UNIT_ASSERT_VALUES_EQUAL(r, "12=34"); } - Y_UNIT_TEST(TestInvalidNotZeroTerm) { + Y_UNIT_TEST(TestInvalidNotZeroTerm) { char r[10]; CGIUnescape(r, "%3d", 1); @@ -124,7 +124,7 @@ Y_UNIT_TEST_SUITE(TCGIUnescapeTest) { UNIT_ASSERT_VALUES_EQUAL(r, "%3u1"); } - Y_UNIT_TEST(StrokaOutParameterInplace) { + Y_UNIT_TEST(StrokaOutParameterInplace) { TString s; s = "hello%3dworld"; @@ -148,7 +148,7 @@ Y_UNIT_TEST_SUITE(TCGIUnescapeTest) { UNIT_ASSERT_VALUES_EQUAL(s, ""); } - Y_UNIT_TEST(StrokaOutParameterNotInplace) { + Y_UNIT_TEST(StrokaOutParameterNotInplace) { TString s, sCopy; s = "hello%3dworld"; @@ -230,8 +230,8 @@ Y_UNIT_TEST_SUITE(TUrlEscapeTest) { } } -Y_UNIT_TEST_SUITE(TUrlUnescapeTest) { - Y_UNIT_TEST(StrokaOutParameterInplace) { +Y_UNIT_TEST_SUITE(TUrlUnescapeTest) { + Y_UNIT_TEST(StrokaOutParameterInplace) { TString s; s = "hello%3dworld"; @@ -255,7 +255,7 @@ Y_UNIT_TEST_SUITE(TUrlUnescapeTest) { UNIT_ASSERT_VALUES_EQUAL(s, ""); } - Y_UNIT_TEST(StrokaOutParameterNotInplace) { + Y_UNIT_TEST(StrokaOutParameterNotInplace) { TString s, sCopy; s = "hello%3dworld"; @@ -285,15 +285,15 @@ Y_UNIT_TEST_SUITE(TUrlUnescapeTest) { } } -Y_UNIT_TEST_SUITE(TQuoteTest) { - Y_UNIT_TEST(ReturnsEndOfTo) { +Y_UNIT_TEST_SUITE(TQuoteTest) { + Y_UNIT_TEST(ReturnsEndOfTo) { char r[10]; const char* returned = Quote(r, "123"); UNIT_ASSERT_VALUES_EQUAL(r + strlen("123"), returned); UNIT_ASSERT_VALUES_EQUAL('\0', *returned); } - Y_UNIT_TEST(SlashIsSafeByDefault) { + Y_UNIT_TEST(SlashIsSafeByDefault) { char r[100]; Quote(r, "/path;tail/path,tail/"); UNIT_ASSERT_VALUES_EQUAL("/path%3Btail/path%2Ctail/", r); @@ -302,7 +302,7 @@ Y_UNIT_TEST_SUITE(TQuoteTest) { UNIT_ASSERT_VALUES_EQUAL("/path%3Btail/path%2Ctail/", s.c_str()); } - Y_UNIT_TEST(SafeColons) { + Y_UNIT_TEST(SafeColons) { char r[100]; Quote(r, "/path;tail/path,tail/", ";,"); UNIT_ASSERT_VALUES_EQUAL("%2Fpath;tail%2Fpath,tail%2F", r); @@ -311,7 +311,7 @@ Y_UNIT_TEST_SUITE(TQuoteTest) { UNIT_ASSERT_VALUES_EQUAL("%2Fpath;tail%2Fpath,tail%2F", s.c_str()); } - Y_UNIT_TEST(StringBuf) { + Y_UNIT_TEST(StringBuf) { char r[100]; char* end = Quote(r, "abc\0/path", ""); UNIT_ASSERT_VALUES_EQUAL("abc\0%2Fpath", TStringBuf(r, end)); diff --git a/library/cpp/string_utils/relaxed_escaper/relaxed_escaper.h b/library/cpp/string_utils/relaxed_escaper/relaxed_escaper.h index d7ea7c12596..8620c7517b5 100644 --- a/library/cpp/string_utils/relaxed_escaper/relaxed_escaper.h +++ b/library/cpp/string_utils/relaxed_escaper/relaxed_escaper.h @@ -150,7 +150,7 @@ namespace NEscJ { } template <bool quote, bool tounicode> - inline void EscapeJ(TStringBuf in, IOutputStream& out, TStringBuf safe = TStringBuf(), TStringBuf unsafe = TStringBuf()) { + inline void EscapeJ(TStringBuf in, IOutputStream& out, TStringBuf safe = TStringBuf(), TStringBuf unsafe = TStringBuf()) { TTempBuf b(SuggestBuffer(in.size()) + 2); if (quote) @@ -192,7 +192,7 @@ namespace NEscJ { } template <bool quote> - inline void EscapeJ(TStringBuf in, IOutputStream& out, TStringBuf safe = TStringBuf(), TStringBuf unsafe = TStringBuf()) { + inline void EscapeJ(TStringBuf in, IOutputStream& out, TStringBuf safe = TStringBuf(), TStringBuf unsafe = TStringBuf()) { EscapeJ<quote, false>(in, out, safe, unsafe); } diff --git a/library/cpp/string_utils/relaxed_escaper/relaxed_escaper_ut.cpp b/library/cpp/string_utils/relaxed_escaper/relaxed_escaper_ut.cpp index 768555ea3ae..3cc25dc887c 100644 --- a/library/cpp/string_utils/relaxed_escaper/relaxed_escaper_ut.cpp +++ b/library/cpp/string_utils/relaxed_escaper/relaxed_escaper_ut.cpp @@ -25,10 +25,10 @@ static const TStringBuf CommonTestData[] = { RESC_FIXED_STR("There\\tare\\ttabs."), RESC_FIXED_STR("There\tare\ttabs.")}; #undef RESC_FIXED_STR -Y_UNIT_TEST_SUITE(TRelaxedEscaperTest) { - Y_UNIT_TEST(TestEscaper) { +Y_UNIT_TEST_SUITE(TRelaxedEscaperTest) { + Y_UNIT_TEST(TestEscaper) { using namespace NEscJ; - for (size_t i = 0; i < Y_ARRAY_SIZE(CommonTestData); i += 2) { + for (size_t i = 0; i < Y_ARRAY_SIZE(CommonTestData); i += 2) { TString expected(CommonTestData[i].data(), CommonTestData[i].size()); TString source(CommonTestData[i + 1].data(), CommonTestData[i + 1].size()); TString actual(EscapeJ<false>(source)); diff --git a/library/cpp/string_utils/url/url.cpp b/library/cpp/string_utils/url/url.cpp index 85f4ac5d693..284842f831e 100644 --- a/library/cpp/string_utils/url/url.cpp +++ b/library/cpp/string_utils/url/url.cpp @@ -124,7 +124,7 @@ TStringBuf CutSchemePrefix(const TStringBuf url) noexcept { } template <bool KeepPort> -static inline TStringBuf GetHostAndPortImpl(const TStringBuf url) { +static inline TStringBuf GetHostAndPortImpl(const TStringBuf url) { TStringBuf urlNoScheme = url; urlNoScheme.Skip(GetHttpPrefixSize(url)); @@ -324,8 +324,8 @@ static bool HasPrefix(const TStringBuf url) noexcept { TString AddSchemePrefix(const TString& url) { return AddSchemePrefix(url, TStringBuf("http")); -} - +} + TString AddSchemePrefix(const TString& url, TStringBuf scheme) { if (HasPrefix(url)) { return url; @@ -347,7 +347,7 @@ static inline int x2c(unsigned char* x) { static inline int Unescape(char* str) { char *to, *from; int dlen = 0; - if ((str = strchr(str, '%')) == nullptr) + if ((str = strchr(str, '%')) == nullptr) return dlen; for (to = str, from = str; *from; from++, to++) { if ((*to = *from) == '%') { @@ -361,7 +361,7 @@ static inline int Unescape(char* str) { return dlen; } -size_t NormalizeUrlName(char* dest, const TStringBuf source, size_t dest_size) { +size_t NormalizeUrlName(char* dest, const TStringBuf source, size_t dest_size) { if (source.empty() || source[0] == '?') return strlcpy(dest, "/", dest_size); size_t len = Min(dest_size - 1, source.length()); @@ -372,7 +372,7 @@ size_t NormalizeUrlName(char* dest, const TStringBuf source, size_t dest_size) { return len; } -size_t NormalizeHostName(char* dest, const TStringBuf source, size_t dest_size, ui16 defport) { +size_t NormalizeHostName(char* dest, const TStringBuf source, size_t dest_size, ui16 defport) { size_t len = Min(dest_size - 1, source.length()); memcpy(dest, source.data(), len); dest[len] = 0; diff --git a/library/cpp/string_utils/url/url.h b/library/cpp/string_utils/url/url.h index 84137ccc57d..287b42d3e33 100644 --- a/library/cpp/string_utils/url/url.h +++ b/library/cpp/string_utils/url/url.h @@ -1,6 +1,6 @@ #pragma once -#include <util/generic/fwd.h> +#include <util/generic/fwd.h> #include <util/generic/strbuf.h> namespace NUrl { @@ -60,9 +60,9 @@ TStringBuf CutSchemePrefix(const TStringBuf url) noexcept; //! @note if URL has scheme prefix already the function returns unchanged URL TString AddSchemePrefix(const TString& url, const TStringBuf scheme); -//! Same as `AddSchemePrefix(url, "http")`. +//! Same as `AddSchemePrefix(url, "http")`. TString AddSchemePrefix(const TString& url); - + Y_PURE_FUNCTION TStringBuf GetHost(const TStringBuf url) noexcept; @@ -159,8 +159,8 @@ TStringBuf CutMPrefix(const TStringBuf url) noexcept; Y_PURE_FUNCTION TStringBuf GetDomain(const TStringBuf host) noexcept; // should not be used -size_t NormalizeUrlName(char* dest, const TStringBuf source, size_t dest_size); -size_t NormalizeHostName(char* dest, const TStringBuf source, size_t dest_size, ui16 defport = 80); +size_t NormalizeUrlName(char* dest, const TStringBuf source, size_t dest_size); +size_t NormalizeHostName(char* dest, const TStringBuf source, size_t dest_size, ui16 defport = 80); Y_PURE_FUNCTION TStringBuf RemoveFinalSlash(TStringBuf str) noexcept; diff --git a/library/cpp/string_utils/url/url_ut.cpp b/library/cpp/string_utils/url/url_ut.cpp index 15880138939..2c2f5948a00 100644 --- a/library/cpp/string_utils/url/url_ut.cpp +++ b/library/cpp/string_utils/url/url_ut.cpp @@ -4,8 +4,8 @@ #include <library/cpp/testing/unittest/registar.h> -Y_UNIT_TEST_SUITE(TUtilUrlTest) { - Y_UNIT_TEST(TestGetHostAndGetHostAndPort) { +Y_UNIT_TEST_SUITE(TUtilUrlTest) { + Y_UNIT_TEST(TestGetHostAndGetHostAndPort) { UNIT_ASSERT_VALUES_EQUAL("ya.ru", GetHost("ya.ru/bebe")); UNIT_ASSERT_VALUES_EQUAL("ya.ru", GetHostAndPort("ya.ru/bebe")); UNIT_ASSERT_VALUES_EQUAL("ya.ru", GetHost("ya.ru")); @@ -27,7 +27,7 @@ Y_UNIT_TEST_SUITE(TUtilUrlTest) { UNIT_ASSERT_VALUES_EQUAL("", GetHost("")); } - Y_UNIT_TEST(TestGetPathAndQuery) { + Y_UNIT_TEST(TestGetPathAndQuery) { UNIT_ASSERT_VALUES_EQUAL("/", GetPathAndQuery("ru.wikipedia.org")); UNIT_ASSERT_VALUES_EQUAL("/", GetPathAndQuery("ru.wikipedia.org/")); UNIT_ASSERT_VALUES_EQUAL("/", GetPathAndQuery("ru.wikipedia.org:8080")); @@ -39,7 +39,7 @@ Y_UNIT_TEST_SUITE(TUtilUrlTest) { UNIT_ASSERT_VALUES_EQUAL("/?1#comment", GetPathAndQuery("ru.wikipedia.org/?1#comment", false)); } - Y_UNIT_TEST(TestGetDomain) { + Y_UNIT_TEST(TestGetDomain) { UNIT_ASSERT_VALUES_EQUAL("ya.ru", GetDomain("www.ya.ru")); UNIT_ASSERT_VALUES_EQUAL("ya.ru", GetDomain("ya.ru")); UNIT_ASSERT_VALUES_EQUAL("ya.ru", GetDomain("a.b.ya.ru")); @@ -48,7 +48,7 @@ Y_UNIT_TEST_SUITE(TUtilUrlTest) { UNIT_ASSERT_VALUES_EQUAL("", GetDomain("")); } - Y_UNIT_TEST(TestGetParentDomain) { + Y_UNIT_TEST(TestGetParentDomain) { UNIT_ASSERT_VALUES_EQUAL("", GetParentDomain("www.ya.ru", 0)); UNIT_ASSERT_VALUES_EQUAL("ru", GetParentDomain("www.ya.ru", 1)); UNIT_ASSERT_VALUES_EQUAL("ya.ru", GetParentDomain("www.ya.ru", 2)); @@ -62,7 +62,7 @@ Y_UNIT_TEST_SUITE(TUtilUrlTest) { UNIT_ASSERT_VALUES_EQUAL("", GetParentDomain("", 1)); } - Y_UNIT_TEST(TestGetZone) { + Y_UNIT_TEST(TestGetZone) { UNIT_ASSERT_VALUES_EQUAL("ru", GetZone("www.ya.ru")); UNIT_ASSERT_VALUES_EQUAL("com", GetZone("ya.com")); UNIT_ASSERT_VALUES_EQUAL("RU", GetZone("RU")); @@ -70,7 +70,7 @@ Y_UNIT_TEST_SUITE(TUtilUrlTest) { UNIT_ASSERT_VALUES_EQUAL("", GetZone("")); } - Y_UNIT_TEST(TestAddSchemePrefix) { + Y_UNIT_TEST(TestAddSchemePrefix) { UNIT_ASSERT_VALUES_EQUAL("http://yandex.ru", AddSchemePrefix("yandex.ru")); UNIT_ASSERT_VALUES_EQUAL("http://yandex.ru", AddSchemePrefix("http://yandex.ru")); UNIT_ASSERT_VALUES_EQUAL("https://yandex.ru", AddSchemePrefix("https://yandex.ru")); @@ -78,7 +78,7 @@ Y_UNIT_TEST_SUITE(TUtilUrlTest) { UNIT_ASSERT_VALUES_EQUAL("ftp://ya.ru", AddSchemePrefix("ya.ru", "ftp")); } - Y_UNIT_TEST(TestSchemeGet) { + Y_UNIT_TEST(TestSchemeGet) { UNIT_ASSERT_VALUES_EQUAL("http://", GetSchemePrefix("http://ya.ru/bebe")); UNIT_ASSERT_VALUES_EQUAL("", GetSchemePrefix("yaru")); UNIT_ASSERT_VALUES_EQUAL("yaru://", GetSchemePrefix("yaru://ya.ru://zzz")); @@ -87,7 +87,7 @@ Y_UNIT_TEST_SUITE(TUtilUrlTest) { UNIT_ASSERT_VALUES_EQUAL("https://", GetSchemePrefix("https://")); // is that right? } - Y_UNIT_TEST(TestSchemeCut) { + Y_UNIT_TEST(TestSchemeCut) { UNIT_ASSERT_VALUES_EQUAL("ya.ru/bebe", CutSchemePrefix("http://ya.ru/bebe")); UNIT_ASSERT_VALUES_EQUAL("yaru", CutSchemePrefix("yaru")); UNIT_ASSERT_VALUES_EQUAL("ya.ru://zzz", CutSchemePrefix("yaru://ya.ru://zzz")); @@ -104,7 +104,7 @@ Y_UNIT_TEST_SUITE(TUtilUrlTest) { UNIT_ASSERT_VALUES_EQUAL("https://", CutHttpPrefix("https://", true)); // is that right? } - Y_UNIT_TEST(TestMisc) { + Y_UNIT_TEST(TestMisc) { UNIT_ASSERT_VALUES_EQUAL("", CutWWWPrefix("www.")); UNIT_ASSERT_VALUES_EQUAL("", CutWWWPrefix("WwW.")); UNIT_ASSERT_VALUES_EQUAL("www", CutWWWPrefix("www")); @@ -127,7 +127,7 @@ Y_UNIT_TEST_SUITE(TUtilUrlTest) { UNIT_ASSERT_VALUES_EQUAL("ya.ru", CutMPrefix("m.ya.ru")); } - Y_UNIT_TEST(TestSplitUrlToHostAndPath) { + Y_UNIT_TEST(TestSplitUrlToHostAndPath) { TStringBuf host, path; SplitUrlToHostAndPath("https://yandex.ru/yandsearch", host, path); @@ -175,7 +175,7 @@ Y_UNIT_TEST_SUITE(TUtilUrlTest) { UNIT_ASSERT_STRINGS_EQUAL(fragment, "fragment"); } - Y_UNIT_TEST(TestGetSchemeHostAndPort) { + Y_UNIT_TEST(TestGetSchemeHostAndPort) { { // all components are present TStringBuf scheme("unknown"), host("unknown"); ui16 port = 0; diff --git a/library/cpp/terminate_handler/segv_handler.cpp b/library/cpp/terminate_handler/segv_handler.cpp index f24ece41250..f956f3bb97e 100644 --- a/library/cpp/terminate_handler/segv_handler.cpp +++ b/library/cpp/terminate_handler/segv_handler.cpp @@ -14,7 +14,7 @@ #ifndef _win_ static void SegvHandler(int sig) { - Y_UNUSED(sig); + Y_UNUSED(sig); const char msg[] = "Got SEGV\n"; Y_UNUSED(write(STDERR_FILENO, msg, sizeof(msg))); //PrintBackTrace(); @@ -29,6 +29,6 @@ static void SegvHandler(int sig) { void InstallSegvHandler() { #ifndef _win_ sig_t r = signal(SIGSEGV, &SegvHandler); - Y_VERIFY(r != SIG_ERR, "signal failed: %s", strerror(errno)); + Y_VERIFY(r != SIG_ERR, "signal failed: %s", strerror(errno)); #endif // !_win_ } diff --git a/library/cpp/testing/benchmark/bench.cpp b/library/cpp/testing/benchmark/bench.cpp index 08d8708005a..dc7f8b7856f 100644 --- a/library/cpp/testing/benchmark/bench.cpp +++ b/library/cpp/testing/benchmark/bench.cpp @@ -1,7 +1,7 @@ #include "bench.h" -#include <contrib/libs/re2/re2/re2.h> - +#include <contrib/libs/re2/re2/re2.h> + #include <library/cpp/colorizer/output.h> #include <library/cpp/getopt/small/last_getopt.h> #include <library/cpp/json/json_value.h> @@ -9,7 +9,7 @@ #include <library/cpp/threading/poor_man_openmp/thread_helper.h> #include <util/system/hp_timer.h> -#include <util/system/info.h> +#include <util/system/info.h> #include <util/stream/output.h> #include <util/datetime/base.h> #include <util/random/random.h> @@ -26,7 +26,7 @@ #include <util/system/yield.h> using re2::RE2; - + using namespace NBench; using namespace NColorizer; using namespace NLastGetopt; @@ -47,7 +47,7 @@ namespace { }; struct ITestRunner: public TIntrusiveListItem<ITestRunner> { - virtual ~ITestRunner() = default; + virtual ~ITestRunner() = default; void Register(); virtual TStringBuf Name() const noexcept = 0; @@ -278,115 +278,115 @@ namespace { F(params); }, opts.TimeBudget, *this); } - - enum EOutFormat { - F_CONSOLE = 0 /* "console" */, + + enum EOutFormat { + F_CONSOLE = 0 /* "console" */, F_CSV /* "csv" */, F_JSON /* "json" */ - }; - + }; + TAdaptiveLock STDOUT_LOCK; - + struct IReporter { - virtual void Report(TResult&& result) = 0; - - virtual void Finish() { - } - - virtual ~IReporter() { - } - }; - + virtual void Report(TResult&& result) = 0; + + virtual void Finish() { + } + + virtual ~IReporter() { + } + }; + class TConsoleReporter: public IReporter { - public: + public: ~TConsoleReporter() override { - } - - void Report(TResult&& r) override { - with_lock (STDOUT_LOCK) { - Cout << r; - } - } - }; - + } + + void Report(TResult&& r) override { + with_lock (STDOUT_LOCK) { + Cout << r; + } + } + }; + class TCSVReporter: public IReporter { - public: - TCSVReporter() { + public: + TCSVReporter() { Cout << "Name\tSamples\tIterations\tRun_time\tPer_iteration_sec\tPer_iteration_cycles" << Endl; - } - + } + ~TCSVReporter() override { - } - - void Report(TResult&& r) override { - with_lock (STDOUT_LOCK) { - Cout << r.TestName - << '\t' << r.Samples - << '\t' << r.Iterations - << '\t' << r.RunTime; - - Cout << '\t'; - if (r.CyclesPerIteration) { - Cout << TCycleTimer::FmtTime(*r.CyclesPerIteration); - } else { - Cout << '-'; - } - - Cout << '\t'; - if (r.SecondsPerIteration) { - Cout << DoFmtTime(*r.SecondsPerIteration); - } else { - Cout << '-'; - } - - Cout << Endl; - } - } - }; - + } + + void Report(TResult&& r) override { + with_lock (STDOUT_LOCK) { + Cout << r.TestName + << '\t' << r.Samples + << '\t' << r.Iterations + << '\t' << r.RunTime; + + Cout << '\t'; + if (r.CyclesPerIteration) { + Cout << TCycleTimer::FmtTime(*r.CyclesPerIteration); + } else { + Cout << '-'; + } + + Cout << '\t'; + if (r.SecondsPerIteration) { + Cout << DoFmtTime(*r.SecondsPerIteration); + } else { + Cout << '-'; + } + + Cout << Endl; + } + } + }; + class TJSONReporter: public IReporter { - public: + public: ~TJSONReporter() override { - } - - void Report(TResult&& r) override { - with_lock (ResultsLock_) { - Results_.emplace_back(std::move(r)); - } - } - - void Finish() override { - NJson::TJsonValue report; - auto& bench = report["benchmark"]; - bench.SetType(NJson::JSON_ARRAY); - - NJson::TJsonValue benchReport; - - for (const auto& result : Results_) { - NJson::TJsonValue{}.Swap(benchReport); - benchReport["name"] = result.TestName; - benchReport["samples"] = result.Samples; - benchReport["run_time"] = result.RunTime; - - if (result.CyclesPerIteration) { - benchReport["per_iteration_cycles"] = *result.CyclesPerIteration; - } - - if (result.SecondsPerIteration) { - benchReport["per_iteration_secons"] = *result.SecondsPerIteration; - } - - bench.AppendValue(benchReport); - } - - Cout << report << Endl; - } - - private: - TAdaptiveLock ResultsLock_; + } + + void Report(TResult&& r) override { + with_lock (ResultsLock_) { + Results_.emplace_back(std::move(r)); + } + } + + void Finish() override { + NJson::TJsonValue report; + auto& bench = report["benchmark"]; + bench.SetType(NJson::JSON_ARRAY); + + NJson::TJsonValue benchReport; + + for (const auto& result : Results_) { + NJson::TJsonValue{}.Swap(benchReport); + benchReport["name"] = result.TestName; + benchReport["samples"] = result.Samples; + benchReport["run_time"] = result.RunTime; + + if (result.CyclesPerIteration) { + benchReport["per_iteration_cycles"] = *result.CyclesPerIteration; + } + + if (result.SecondsPerIteration) { + benchReport["per_iteration_secons"] = *result.SecondsPerIteration; + } + + bench.AppendValue(benchReport); + } + + Cout << report << Endl; + } + + private: + TAdaptiveLock ResultsLock_; TVector<TResult> Results_; - }; - + }; + class TOrderedReporter: public IReporter { public: TOrderedReporter(THolder<IReporter> slave) @@ -421,22 +421,22 @@ namespace { }; THolder<IReporter> MakeReporter(const EOutFormat type) { - switch (type) { - case F_CONSOLE: - return MakeHolder<TConsoleReporter>(); - - case F_CSV: - return MakeHolder<TCSVReporter>(); + switch (type) { + case F_CONSOLE: + return MakeHolder<TConsoleReporter>(); + + case F_CSV: + return MakeHolder<TCSVReporter>(); - case F_JSON: - return MakeHolder<TJSONReporter>(); + case F_JSON: + return MakeHolder<TJSONReporter>(); default: break; - } + } return MakeHolder<TConsoleReporter>(); // make compiler happy - } + } THolder<IReporter> MakeOrderedReporter(const EOutFormat type) { return MakeHolder<TOrderedReporter>(MakeReporter(type)); @@ -448,24 +448,24 @@ namespace { } } } - -template <> -EOutFormat FromStringImpl<EOutFormat>(const char* data, size_t len) { - const auto s = TStringBuf{data, len}; + +template <> +EOutFormat FromStringImpl<EOutFormat>(const char* data, size_t len) { + const auto s = TStringBuf{data, len}; if (TStringBuf("console") == s) { - return F_CONSOLE; + return F_CONSOLE; } else if (TStringBuf("csv") == s) { - return F_CSV; + return F_CSV; } else if (TStringBuf("json") == s) { - return F_JSON; - } - - ythrow TFromStringException{} << "failed to convert '" << s << '\''; + return F_JSON; + } + + ythrow TFromStringException{} << "failed to convert '" << s << '\''; } template <> -void Out<TResult>(IOutputStream& out, const TResult& r) { +void Out<TResult>(IOutputStream& out, const TResult& r) { out << "----------- " << LightRed() << r.TestName << Old() << " ---------------" << Endl << " samples: " << White() << r.Samples << Old() << Endl << " iterations: " << White() << r.Iterations << Old() << Endl @@ -482,9 +482,9 @@ void Out<TResult>(IOutputStream& out, const TResult& r) { } NCpu::TRegistar::TRegistar(const char* name, TUserFunc func) { - static_assert(sizeof(TCpuBenchmark) + alignof(TCpuBenchmark) < sizeof(Buf), "fix Buf size"); + static_assert(sizeof(TCpuBenchmark) + alignof(TCpuBenchmark) < sizeof(Buf), "fix Buf size"); - new (AlignUp(Buf, alignof(TCpuBenchmark))) TCpuBenchmark(name, func); + new (AlignUp(Buf, alignof(TCpuBenchmark))) TCpuBenchmark(name, func); } namespace { @@ -496,36 +496,36 @@ namespace { opts.AddLongOption('b', "budget") .StoreResult(&TimeBudget) - .RequiredArgument("SEC") + .RequiredArgument("SEC") .Optional() .Help("overall time budget"); opts.AddLongOption('l', "list") - .NoArgument() - .StoreValue(&ListTests, true) + .NoArgument() + .StoreValue(&ListTests, true) .Help("list all tests"); opts.AddLongOption('t', "threads") .StoreResult(&Threads) - .OptionalValue(ToString((NSystemInfo::CachedNumberOfCpus() + 1) / 2), "JOBS") - .DefaultValue("1") + .OptionalValue(ToString((NSystemInfo::CachedNumberOfCpus() + 1) / 2), "JOBS") + .DefaultValue("1") .Help("run benchmarks in parallel"); - opts.AddLongOption('f', "format") + opts.AddLongOption('f', "format") .AddLongName("benchmark_format") - .StoreResult(&OutFormat) - .RequiredArgument("FORMAT") - .DefaultValue("console") - .Help("output format (console|csv|json)"); - - opts.SetFreeArgDefaultTitle("REGEXP", "RE2 regular expression to filter tests"); - - const TOptsParseResult parseResult{&opts, argc, argv}; - - for (const auto& regexp : parseResult.GetFreeArgs()) { + .StoreResult(&OutFormat) + .RequiredArgument("FORMAT") + .DefaultValue("console") + .Help("output format (console|csv|json)"); + + opts.SetFreeArgDefaultTitle("REGEXP", "RE2 regular expression to filter tests"); + + const TOptsParseResult parseResult{&opts, argc, argv}; + + for (const auto& regexp : parseResult.GetFreeArgs()) { Filters.push_back(MakeHolder<RE2>(regexp.data(), RE2::Quiet)); - Y_ENSURE(Filters.back()->ok(), "incorrect RE2 expression '" << regexp << "'"); - } + Y_ENSURE(Filters.back()->ok(), "incorrect RE2 expression '" << regexp << "'"); + } } bool MatchFilters(const TStringBuf& name) const { @@ -533,72 +533,72 @@ namespace { return true; } - for (auto&& re : Filters) { + for (auto&& re : Filters) { if (RE2::FullMatchN({name.data(), name.size()}, *re, nullptr, 0)) { - return true; - } - } - - return false; - } - + return true; + } + } + + return false; + } + bool ListTests = false; double TimeBudget = -1.0; TVector<THolder<RE2>> Filters; size_t Threads = 0; - EOutFormat OutFormat; + EOutFormat OutFormat; }; } -int NBench::Main(int argc, char** argv) { - const TProgOpts opts(argc, argv); +int NBench::Main(int argc, char** argv) { + const TProgOpts opts(argc, argv); TVector<ITestRunner*> tests; - - for (auto&& it : Tests()) { - if (opts.MatchFilters(it.Name())) { - tests.push_back(&it); + + for (auto&& it : Tests()) { + if (opts.MatchFilters(it.Name())) { + tests.push_back(&it); } - } + } EnumerateTests(tests); - if (opts.ListTests) { - for (const auto* const it : tests) { - Cout << it->Name() << Endl; + if (opts.ListTests) { + for (const auto* const it : tests) { + Cout << it->Name() << Endl; } - return 0; - } + return 0; + } - if (!tests) { - return 0; - } + if (!tests) { + return 0; + } - double timeBudget = opts.TimeBudget; + double timeBudget = opts.TimeBudget; - if (timeBudget < 0) { + if (timeBudget < 0) { timeBudget = 5.0 * tests.size(); - } + } const TOptions testOpts = {timeBudget / tests.size()}; const auto reporter = MakeOrderedReporter(opts.OutFormat); std::function<void(ITestRunner**)> func = [&](ITestRunner** it) { - auto&& res = (*it)->Run(testOpts); + auto&& res = (*it)->Run(testOpts); - reporter->Report(std::move(res)); - }; - - if (opts.Threads > 1) { - NYmp::SetThreadCount(opts.Threads); + reporter->Report(std::move(res)); + }; + + if (opts.Threads > 1) { + NYmp::SetThreadCount(opts.Threads); NYmp::ParallelForStaticChunk(tests.data(), tests.data() + tests.size(), 1, func); - } else { - for (auto it : tests) { - func(&it); - } + } else { + for (auto it : tests) { + func(&it); + } } - - reporter->Finish(); - - return 0; + + reporter->Finish(); + + return 0; } diff --git a/library/cpp/testing/benchmark/bench.h b/library/cpp/testing/benchmark/bench.h index 21551ad0dd4..5773fc1534f 100644 --- a/library/cpp/testing/benchmark/bench.h +++ b/library/cpp/testing/benchmark/bench.h @@ -26,62 +26,62 @@ namespace NBench { /** * Functions that states "I can read and write everywhere in memory". - * - * Use it to prevent optimizer from reordering or discarding memory writes prior to it's call, - * and force memory reads after it's call. - */ - void Clobber(); - + * + * Use it to prevent optimizer from reordering or discarding memory writes prior to it's call, + * and force memory reads after it's call. + */ + void Clobber(); + /** * Forces whatever `p` points to be in memory and not in register. - * - * @param Pointer to data. - */ - template <typename T> - void Escape(T* p); - -#if defined(__GNUC__) - Y_FORCE_INLINE void Clobber() { + * + * @param Pointer to data. + */ + template <typename T> + void Escape(T* p); + +#if defined(__GNUC__) + Y_FORCE_INLINE void Clobber() { asm volatile("" : : : "memory"); - } + } #elif defined(_MSC_VER) Y_FORCE_INLINE void Clobber() { _ReadWriteBarrier(); } -#else - Y_FORCE_INLINE void Clobber() { - } -#endif - -#if defined(__GNUC__) - template <typename T> - Y_FORCE_INLINE void Escape(T* p) { +#else + Y_FORCE_INLINE void Clobber() { + } +#endif + +#if defined(__GNUC__) + template <typename T> + Y_FORCE_INLINE void Escape(T* p) { asm volatile("" : : "g"(p) : "memory"); - } -#else - template <typename T> - Y_FORCE_INLINE void Escape(T*) { - } -#endif - + } +#else + template <typename T> + Y_FORCE_INLINE void Escape(T*) { + } +#endif + /** * Use this function to prevent unused variables elimination. * * @param Unused variable (e.g. return value of benchmarked function). */ - template <typename T> + template <typename T> Y_FORCE_INLINE void DoNotOptimize(T&& datum) { ::DoNotOptimizeAway(std::forward<T>(datum)); } - - int Main(int argc, char** argv); + + int Main(int argc, char** argv); } #define Y_CPU_BENCHMARK(name, cnt) \ diff --git a/library/cpp/testing/benchmark/examples/main.cpp b/library/cpp/testing/benchmark/examples/main.cpp index ddd8b05ffc7..745e636d4c8 100644 --- a/library/cpp/testing/benchmark/examples/main.cpp +++ b/library/cpp/testing/benchmark/examples/main.cpp @@ -120,9 +120,9 @@ Y_CPU_BENCHMARK(FunctionCallCost_StringBufVal1, iface) { for (auto i : xrange<size_t>(0, iface.Iterations())) { (void)i; - NBench::Escape(&x); + NBench::Escape(&x); Y_DO_NOT_OPTIMIZE_AWAY(FS1(x)); - NBench::Clobber(); + NBench::Clobber(); } } @@ -131,9 +131,9 @@ Y_CPU_BENCHMARK(FunctionCallCost_StringBufRef1, iface) { for (auto i : xrange<size_t>(0, iface.Iterations())) { (void)i; - NBench::Escape(&x); + NBench::Escape(&x); Y_DO_NOT_OPTIMIZE_AWAY(FS2(x)); - NBench::Clobber(); + NBench::Clobber(); } } @@ -143,10 +143,10 @@ Y_CPU_BENCHMARK(FunctionCallCost_StringBufVal2, iface) { for (auto i : xrange<size_t>(0, iface.Iterations())) { (void)i; - NBench::Escape(&x); - NBench::Escape(&y); + NBench::Escape(&x); + NBench::Escape(&y); Y_DO_NOT_OPTIMIZE_AWAY(FS1_2(x, y)); - NBench::Clobber(); + NBench::Clobber(); } } @@ -156,10 +156,10 @@ Y_CPU_BENCHMARK(FunctionCallCost_StringBufRef2, iface) { for (auto i : xrange<size_t>(0, iface.Iterations())) { (void)i; - NBench::Escape(&x); - NBench::Escape(&y); + NBench::Escape(&x); + NBench::Escape(&y); Y_DO_NOT_OPTIMIZE_AWAY(FS2_2(x, y)); - NBench::Clobber(); + NBench::Clobber(); } } @@ -181,35 +181,35 @@ Y_CPU_BENCHMARK(FunctionCallCost_TwoArg, iface) { Y_DO_NOT_OPTIMIZE_AWAY(FFF(i, i)); } } - -/* An example of incorrect benchmark. As of r2581591 Clang 3.7 produced following assembly: - * @code - * │ push %rbp - * │ mov %rsp,%rbp - * │ push %rbx - * │ push %rax - * │ mov (%rdi),%rbx - * │ test %rbx,%rbx - * │ ↓ je 25 - * │ xor %edi,%edi - * │ xor %esi,%esi + +/* An example of incorrect benchmark. As of r2581591 Clang 3.7 produced following assembly: + * @code + * │ push %rbp + * │ mov %rsp,%rbp + * │ push %rbx + * │ push %rax + * │ mov (%rdi),%rbx + * │ test %rbx,%rbx + * │ ↓ je 25 + * │ xor %edi,%edi + * │ xor %esi,%esi * │ → callq FS1(TBasicStringBuf<char, std::char_traits<char - * │ nop - * 100.00 │20:┌─→dec %rbx - * │ └──jne 20 - * │25: add $0x8,%rsp - * │ pop %rbx - * │ pop %rbp - * │ ← retq - * @endcode - * - * So, this benchmark is measuring empty loop! - */ -Y_CPU_BENCHMARK(Incorrect_FunctionCallCost_StringBufVal1, iface) { - TStringBuf x; - - for (auto i : xrange<size_t>(0, iface.Iterations())) { - (void)i; - Y_DO_NOT_OPTIMIZE_AWAY(FS1(x)); - } -} + * │ nop + * 100.00 │20:┌─→dec %rbx + * │ └──jne 20 + * │25: add $0x8,%rsp + * │ pop %rbx + * │ pop %rbp + * │ ← retq + * @endcode + * + * So, this benchmark is measuring empty loop! + */ +Y_CPU_BENCHMARK(Incorrect_FunctionCallCost_StringBufVal1, iface) { + TStringBuf x; + + for (auto i : xrange<size_t>(0, iface.Iterations())) { + (void)i; + Y_DO_NOT_OPTIMIZE_AWAY(FS1(x)); + } +} diff --git a/library/cpp/testing/benchmark/examples/metrics/main.py b/library/cpp/testing/benchmark/examples/metrics/main.py index 8f9d9d06aeb..d8264504007 100644 --- a/library/cpp/testing/benchmark/examples/metrics/main.py +++ b/library/cpp/testing/benchmark/examples/metrics/main.py @@ -1,7 +1,7 @@ -import yatest.common as yc - - -def test_export_metrics(metrics): - metrics.set_benchmark(yc.execute_benchmark( +import yatest.common as yc + + +def test_export_metrics(metrics): + metrics.set_benchmark(yc.execute_benchmark( 'library/cpp/testing/benchmark/examples/examples', - threads=8)) + threads=8)) diff --git a/library/cpp/testing/benchmark/examples/metrics/ya.make b/library/cpp/testing/benchmark/examples/metrics/ya.make index a9dbdca9fad..a2c773a2d04 100644 --- a/library/cpp/testing/benchmark/examples/metrics/ya.make +++ b/library/cpp/testing/benchmark/examples/metrics/ya.make @@ -1,20 +1,20 @@ -OWNER( - pg - yazevnul -) - +OWNER( + pg + yazevnul +) + PY2TEST() - + SIZE(LARGE) - -TAG( + +TAG( ya:force_sandbox - sb:intel_e5_2660v1 + sb:intel_e5_2660v1 ya:fat -) - +) + TEST_SRCS(main.py) - + DEPENDS(library/cpp/testing/benchmark/examples) - -END() + +END() diff --git a/library/cpp/testing/benchmark/examples/ya.make b/library/cpp/testing/benchmark/examples/ya.make index 7e696e127ab..d0d5bdca2c4 100644 --- a/library/cpp/testing/benchmark/examples/ya.make +++ b/library/cpp/testing/benchmark/examples/ya.make @@ -1,8 +1,8 @@ -OWNER( - pg - yazevnul -) - +OWNER( + pg + yazevnul +) + Y_BENCHMARK() SRCS( diff --git a/library/cpp/testing/benchmark/main/main.cpp b/library/cpp/testing/benchmark/main/main.cpp index aabcb89c435..b464c790233 100644 --- a/library/cpp/testing/benchmark/main/main.cpp +++ b/library/cpp/testing/benchmark/main/main.cpp @@ -1,16 +1,16 @@ #include <library/cpp/testing/benchmark/bench.h> - -#include <util/generic/yexception.h> -#include <util/stream/output.h> - -#include <cstdlib> - -int main(int argc, char** argv) { - try { - return NBench::Main(argc, argv); + +#include <util/generic/yexception.h> +#include <util/stream/output.h> + +#include <cstdlib> + +int main(int argc, char** argv) { + try { + return NBench::Main(argc, argv); } catch (...) { - Cerr << CurrentExceptionMessage() << Endl; - } + Cerr << CurrentExceptionMessage() << Endl; + } return EXIT_FAILURE; -} +} diff --git a/library/cpp/testing/benchmark/main/ya.make b/library/cpp/testing/benchmark/main/ya.make index d00cdcf9fca..a434d426750 100644 --- a/library/cpp/testing/benchmark/main/ya.make +++ b/library/cpp/testing/benchmark/main/ya.make @@ -1,16 +1,16 @@ -LIBRARY() - +LIBRARY() + OWNER( pg yazevnul ) - -SRCS( + +SRCS( GLOBAL main.cpp -) - -PEERDIR( +) + +PEERDIR( library/cpp/testing/benchmark -) - -END() +) + +END() diff --git a/library/cpp/testing/benchmark/ya.make b/library/cpp/testing/benchmark/ya.make index f42be80698e..661e1602383 100644 --- a/library/cpp/testing/benchmark/ya.make +++ b/library/cpp/testing/benchmark/ya.make @@ -4,19 +4,19 @@ OWNER( pg yazevnul ) - -SRCS( + +SRCS( bench.cpp dummy.cpp -) - -PEERDIR( - contrib/libs/re2 +) + +PEERDIR( + contrib/libs/re2 library/cpp/colorizer library/cpp/getopt/small library/cpp/json library/cpp/linear_regression library/cpp/threading/poor_man_openmp -) - -END() +) + +END() diff --git a/library/cpp/testing/gmock_in_unittest/example_ut/example_ut.cpp b/library/cpp/testing/gmock_in_unittest/example_ut/example_ut.cpp index 97f19050e42..9d0a72fb476 100644 --- a/library/cpp/testing/gmock_in_unittest/example_ut/example_ut.cpp +++ b/library/cpp/testing/gmock_in_unittest/example_ut/example_ut.cpp @@ -27,8 +27,8 @@ public: using namespace testing; -Y_UNIT_TEST_SUITE(TExampleGMockTest) { - Y_UNIT_TEST(TSimpleTest) { +Y_UNIT_TEST_SUITE(TExampleGMockTest) { + Y_UNIT_TEST(TSimpleTest) { TTestMock mock; EXPECT_CALL(mock, Func1()) .Times(AtLeast(1)); @@ -38,7 +38,7 @@ Y_UNIT_TEST_SUITE(TExampleGMockTest) { } } - Y_UNIT_TEST(TNonExpectedCallTest) { + Y_UNIT_TEST(TNonExpectedCallTest) { TTestMock mock; EXPECT_CALL(mock, Func1()) .Times(AtMost(1)); @@ -48,7 +48,7 @@ Y_UNIT_TEST_SUITE(TExampleGMockTest) { } } - Y_UNIT_TEST(TReturnValuesTest) { + Y_UNIT_TEST(TReturnValuesTest) { TTestMock mock; EXPECT_CALL(mock, Func2(TString("1"))) .WillOnce(Return(1)) @@ -70,7 +70,7 @@ Y_UNIT_TEST_SUITE(TExampleGMockTest) { } } - Y_UNIT_TEST(TStrictCallSequenceTest) { + Y_UNIT_TEST(TStrictCallSequenceTest) { TTestMock mock; { InSequence seq; @@ -93,7 +93,7 @@ Y_UNIT_TEST_SUITE(TExampleGMockTest) { } } - Y_UNIT_TEST(TUninterestingMethodIsFailureTest) { + Y_UNIT_TEST(TUninterestingMethodIsFailureTest) { StrictMock<TTestMock> mock; EXPECT_CALL(mock, Func1()) .Times(1); diff --git a/library/cpp/testing/unittest/checks.cpp b/library/cpp/testing/unittest/checks.cpp index c5712ae9d21..70d6bb3410b 100644 --- a/library/cpp/testing/unittest/checks.cpp +++ b/library/cpp/testing/unittest/checks.cpp @@ -1,5 +1,5 @@ #include <util/generic/string.h> -#include <util/string/type.h> +#include <util/string/type.h> bool CheckExceptionMessage(const char* msg, TString& err) { static const char* badMsg[] = { @@ -10,7 +10,7 @@ bool CheckExceptionMessage(const char* msg, TString& err) { err.clear(); - if (msg == nullptr) { + if (msg == nullptr) { err = "Error message is null"; return false; } @@ -20,8 +20,8 @@ bool CheckExceptionMessage(const char* msg, TString& err) { return false; } - for (auto& i : badMsg) { - if (strstr(msg, i) != nullptr) { + for (auto& i : badMsg) { + if (strstr(msg, i) != nullptr) { err = "Invalid error message: " + TString(msg); return false; } diff --git a/library/cpp/testing/unittest/example_ut.cpp b/library/cpp/testing/unittest/example_ut.cpp index bcc1ce33f05..e53d6a30fbc 100644 --- a/library/cpp/testing/unittest/example_ut.cpp +++ b/library/cpp/testing/unittest/example_ut.cpp @@ -4,8 +4,8 @@ * just copy-paste it for good start point */ -Y_UNIT_TEST_SUITE(TUnitTest) { - Y_UNIT_TEST(TestEqual) { +Y_UNIT_TEST_SUITE(TUnitTest) { + Y_UNIT_TEST(TestEqual) { UNIT_ASSERT_EQUAL(0, 0); UNIT_ASSERT_EQUAL(1, 1); } diff --git a/library/cpp/testing/unittest/registar.cpp b/library/cpp/testing/unittest/registar.cpp index 3679b768ed4..945f70d1de0 100644 --- a/library/cpp/testing/unittest/registar.cpp +++ b/library/cpp/testing/unittest/registar.cpp @@ -59,7 +59,7 @@ void ::NUnitTest::SetRaiseErrorHandler(::NUnitTest::TRaiseErrorHandler handler) } void ::NUnitTest::NPrivate::SetUnittestThread(bool unittestThread) { - Y_VERIFY(UnittestThread != unittestThread, "state check"); + Y_VERIFY(UnittestThread != unittestThread, "state check"); UnittestThread = unittestThread; } diff --git a/library/cpp/testing/unittest/registar.h b/library/cpp/testing/unittest/registar.h index 44517a00924..8fb8f95e250 100644 --- a/library/cpp/testing/unittest/registar.h +++ b/library/cpp/testing/unittest/registar.h @@ -293,7 +293,7 @@ private: \ /* If you see this message - delete multiple UNIT_TEST(TestName) with same TestName. */ \ /* It's forbidden to declare same test twice because it breaks --fork-tests logic. */ \ int You_have_declared_test_##F##_multiple_times_This_is_forbidden; \ - Y_UNUSED(You_have_declared_test_##F##_multiple_times_This_is_forbidden); + Y_UNUSED(You_have_declared_test_##F##_multiple_times_This_is_forbidden); #define UNIT_TEST_RUN(F, FF, context) \ this->BeforeTest((#F)); \ @@ -914,7 +914,7 @@ public: \ #define UNIT_TEST_SUITE_REGISTRATION(T) \ static const ::NUnitTest::TTestBaseFactory<T> Y_GENERATE_UNIQUE_ID(UTREG_); -#define Y_UNIT_TEST_SUITE_IMPL_F(N, T, F) \ +#define Y_UNIT_TEST_SUITE_IMPL_F(N, T, F) \ namespace NTestSuite##N { \ class TCurrentTestCase: public F { \ }; \ @@ -982,12 +982,12 @@ public: \ } \ namespace NTestSuite##N -#define Y_UNIT_TEST_SUITE_IMPL(N, T) Y_UNIT_TEST_SUITE_IMPL_F(N, T, ::NUnitTest::TBaseTestCase) -#define Y_UNIT_TEST_SUITE(N) Y_UNIT_TEST_SUITE_IMPL(N, TTestBase) -#define Y_UNIT_TEST_SUITE_F(N, F) Y_UNIT_TEST_SUITE_IMPL_F(N, TTestBase, F) -#define RUSAGE_UNIT_TEST_SUITE(N) Y_UNIT_TEST_SUITE_IMPL(N, NUnitTest::TRusageTest, ::NUnitTest::TBaseTestCase) +#define Y_UNIT_TEST_SUITE_IMPL(N, T) Y_UNIT_TEST_SUITE_IMPL_F(N, T, ::NUnitTest::TBaseTestCase) +#define Y_UNIT_TEST_SUITE(N) Y_UNIT_TEST_SUITE_IMPL(N, TTestBase) +#define Y_UNIT_TEST_SUITE_F(N, F) Y_UNIT_TEST_SUITE_IMPL_F(N, TTestBase, F) +#define RUSAGE_UNIT_TEST_SUITE(N) Y_UNIT_TEST_SUITE_IMPL(N, NUnitTest::TRusageTest, ::NUnitTest::TBaseTestCase) -#define Y_UNIT_TEST_IMPL_REGISTER(N, FF, F) \ +#define Y_UNIT_TEST_IMPL_REGISTER(N, FF, F) \ struct TTestCase##N : public F { \ TTestCase##N() \ : F() \ @@ -1007,21 +1007,21 @@ public: \ }; \ static const TTestRegistration##N testRegistration##N; -#define Y_UNIT_TEST_IMPL(N, FF, F) \ - Y_UNIT_TEST_IMPL_REGISTER(N, FF, F) \ +#define Y_UNIT_TEST_IMPL(N, FF, F) \ + Y_UNIT_TEST_IMPL_REGISTER(N, FF, F) \ void TTestCase##N::Execute_(NUnitTest::TTestContext& ut_context Y_DECLARE_UNUSED) -#define Y_UNIT_TEST(N) Y_UNIT_TEST_IMPL(N, false, TCurrentTestCase) -#define Y_UNIT_TEST_F(N, F) Y_UNIT_TEST_IMPL(N, false, F) -#define SIMPLE_UNIT_FORKED_TEST(N) Y_UNIT_TEST_IMPL(N, true, TCurrentTestCase) +#define Y_UNIT_TEST(N) Y_UNIT_TEST_IMPL(N, false, TCurrentTestCase) +#define Y_UNIT_TEST_F(N, F) Y_UNIT_TEST_IMPL(N, false, F) +#define SIMPLE_UNIT_FORKED_TEST(N) Y_UNIT_TEST_IMPL(N, true, TCurrentTestCase) -#define Y_UNIT_TEST_SUITE_IMPLEMENTATION(N) \ +#define Y_UNIT_TEST_SUITE_IMPLEMENTATION(N) \ namespace NTestSuite##N -#define Y_UNIT_TEST_DECLARE(N) \ +#define Y_UNIT_TEST_DECLARE(N) \ struct TTestCase##N -#define Y_UNIT_TEST_FRIEND(N, T) \ +#define Y_UNIT_TEST_FRIEND(N, T) \ friend NTestSuite##N::TTestCase##T \ TString RandomString(size_t len, ui32 seed = 0); diff --git a/library/cpp/testing/unittest/registar_ut.cpp b/library/cpp/testing/unittest/registar_ut.cpp index 1f36d53abbe..46b455281be 100644 --- a/library/cpp/testing/unittest/registar_ut.cpp +++ b/library/cpp/testing/unittest/registar_ut.cpp @@ -1,7 +1,7 @@ #include <library/cpp/testing/unittest/registar.h> -Y_UNIT_TEST_SUITE(TUnitTestMacroTest) { - Y_UNIT_TEST(Assert) { +Y_UNIT_TEST_SUITE(TUnitTestMacroTest) { + Y_UNIT_TEST(Assert) { auto unitAssert = [] { UNIT_ASSERT(false); }; @@ -10,7 +10,7 @@ Y_UNIT_TEST_SUITE(TUnitTestMacroTest) { UNIT_ASSERT(true); } - Y_UNIT_TEST(TypesEqual) { + Y_UNIT_TEST(TypesEqual) { auto typesEqual = [] { UNIT_ASSERT_TYPES_EQUAL(int, long); }; @@ -19,7 +19,7 @@ Y_UNIT_TEST_SUITE(TUnitTestMacroTest) { UNIT_ASSERT_TYPES_EQUAL(TString, TString); } - Y_UNIT_TEST(DoublesEqual) { + Y_UNIT_TEST(DoublesEqual) { auto doublesEqual = [](double d1, double d2, double precision) { UNIT_ASSERT_DOUBLES_EQUAL(d1, d2, precision); }; @@ -35,7 +35,7 @@ Y_UNIT_TEST_SUITE(TUnitTestMacroTest) { UNIT_ASSERT_DOUBLES_EQUAL(nan, nan, 0.1); } - Y_UNIT_TEST(StringsEqual) { + Y_UNIT_TEST(StringsEqual) { auto stringsEqual = [](auto s1, auto s2) { UNIT_ASSERT_STRINGS_EQUAL(s1, s2); }; @@ -54,7 +54,7 @@ Y_UNIT_TEST_SUITE(TUnitTestMacroTest) { UNIT_ASSERT_STRINGS_EQUAL("", static_cast<const char*>(nullptr)); } - Y_UNIT_TEST(StringContains) { + Y_UNIT_TEST(StringContains) { auto stringContains = [](auto s, auto substr) { UNIT_ASSERT_STRING_CONTAINS(s, substr); }; @@ -67,7 +67,7 @@ Y_UNIT_TEST_SUITE(TUnitTestMacroTest) { UNIT_ASSERT_STRING_CONTAINS("lurkmore", "more"); } - Y_UNIT_TEST(NoDiff) { + Y_UNIT_TEST(NoDiff) { auto noDiff = [](auto s1, auto s2) { UNIT_ASSERT_NO_DIFF(s1, s2); }; @@ -78,7 +78,7 @@ Y_UNIT_TEST_SUITE(TUnitTestMacroTest) { UNIT_ASSERT_NO_DIFF("a", "a"); } - Y_UNIT_TEST(StringsUnequal) { + Y_UNIT_TEST(StringsUnequal) { auto stringsUnequal = [](auto s1, auto s2) { UNIT_ASSERT_STRINGS_UNEQUAL(s1, s2); }; @@ -101,7 +101,7 @@ Y_UNIT_TEST_SUITE(TUnitTestMacroTest) { UNIT_ASSERT_STRINGS_UNEQUAL(TStringBuf("C++"), TString("python")); } - Y_UNIT_TEST(Equal) { + Y_UNIT_TEST(Equal) { auto equal = [](auto v1, auto v2) { UNIT_ASSERT_EQUAL(v1, v2); }; @@ -114,7 +114,7 @@ Y_UNIT_TEST_SUITE(TUnitTestMacroTest) { UNIT_ASSERT_EQUAL(55, 55); } - Y_UNIT_TEST(Unequal) { + Y_UNIT_TEST(Unequal) { auto unequal = [](auto v1, auto v2) { UNIT_ASSERT_UNEQUAL(v1, v2); }; @@ -235,7 +235,7 @@ Y_UNIT_TEST_SUITE(TUnitTestMacroTest) { UNIT_ASSERT_GE(100ul, static_cast<unsigned short>(42)); } - Y_UNIT_TEST(ValuesEqual) { + Y_UNIT_TEST(ValuesEqual) { auto valuesEqual = [](auto v1, auto v2) { UNIT_ASSERT_VALUES_EQUAL(v1, v2); }; @@ -246,7 +246,7 @@ Y_UNIT_TEST_SUITE(TUnitTestMacroTest) { UNIT_ASSERT_VALUES_EQUAL(1.0, 1.0); } - Y_UNIT_TEST(ValuesUnequal) { + Y_UNIT_TEST(ValuesUnequal) { auto valuesUnequal = [](auto v1, auto v2) { UNIT_ASSERT_VALUES_UNEQUAL(v1, v2); }; @@ -325,7 +325,7 @@ Y_UNIT_TEST_SUITE(TUnitTestMacroTest) { } }; - Y_UNIT_TEST(Exception) { + Y_UNIT_TEST(Exception) { UNIT_ASSERT_TEST_FAILS(TTestException("", false).AssertException<TTestException>()); UNIT_ASSERT_TEST_FAILS(TTestException().AssertException<TOtherTestException>()); @@ -333,7 +333,7 @@ Y_UNIT_TEST_SUITE(TUnitTestMacroTest) { UNIT_ASSERT_EXCEPTION(TTestException().Throw(), TTestException); } - Y_UNIT_TEST(ExceptionAssertionContainsOtherExceptionMessage) { + Y_UNIT_TEST(ExceptionAssertionContainsOtherExceptionMessage) { NUnitTest::TUnitTestFailChecker checker; { auto guard = checker.InvokeGuard(); @@ -343,14 +343,14 @@ Y_UNIT_TEST_SUITE(TUnitTestMacroTest) { UNIT_ASSERT_STRING_CONTAINS(checker.Msg(), "custom exception message"); } - Y_UNIT_TEST(NoException) { + Y_UNIT_TEST(NoException) { UNIT_ASSERT_TEST_FAILS(TTestException().AssertNoException()); UNIT_ASSERT_TEST_FAILS(TTestException().AssertNoExceptionRet()); UNIT_ASSERT_NO_EXCEPTION(TTestException("", false).Throw()); } - Y_UNIT_TEST(ExceptionContains) { + Y_UNIT_TEST(ExceptionContains) { UNIT_ASSERT_TEST_FAILS(TTestException("abc").AssertExceptionContains<TTestException>("cba")); UNIT_ASSERT_TEST_FAILS(TTestException("abc").AssertExceptionContains<TTestException>(TStringBuf("cba"))); UNIT_ASSERT_TEST_FAILS(TTestException("abc").AssertExceptionContains<TTestException>(TString("cba"))); diff --git a/library/cpp/testing/unittest/ut/main.cpp b/library/cpp/testing/unittest/ut/main.cpp index e303e21e30a..13c7642dd99 100644 --- a/library/cpp/testing/unittest/ut/main.cpp +++ b/library/cpp/testing/unittest/ut/main.cpp @@ -61,25 +61,25 @@ TEST(ETest, Test1) { UNIT_CHECK_GENERATED_NO_EXCEPTION(true, yexception); } -Y_UNIT_TEST_SUITE(TestSingleTestFixture) +Y_UNIT_TEST_SUITE(TestSingleTestFixture) { - Y_UNIT_TEST_F(Test3, TSimpleFixture) { + Y_UNIT_TEST_F(Test3, TSimpleFixture) { UNIT_ASSERT_EQUAL(Value, 24); } } -Y_UNIT_TEST_SUITE_F(TestSuiteFixture, TSimpleFixture) +Y_UNIT_TEST_SUITE_F(TestSuiteFixture, TSimpleFixture) { - Y_UNIT_TEST(Test1) { + Y_UNIT_TEST(Test1) { UNIT_ASSERT(Value == 24); Value = 25; } - Y_UNIT_TEST(Test2) { + Y_UNIT_TEST(Test2) { UNIT_ASSERT_EQUAL(Value, 24); } - Y_UNIT_TEST_F(Test3, TOtherFixture) { + Y_UNIT_TEST_F(Test3, TOtherFixture) { UNIT_ASSERT_EQUAL(TheAnswer, 42); } } diff --git a/library/cpp/testing/unittest/utmain.cpp b/library/cpp/testing/unittest/utmain.cpp index 305bc6b40fc..09605828a6a 100644 --- a/library/cpp/testing/unittest/utmain.cpp +++ b/library/cpp/testing/unittest/utmain.cpp @@ -20,7 +20,7 @@ #include <util/network/init.h> #include <util/stream/file.h> -#include <util/stream/output.h> +#include <util/stream/output.h> #include <util/string/join.h> #include <util/string/util.h> @@ -502,7 +502,7 @@ private: ythrow yexception() << "Forked test finished with unknown status"; } case TShellCommand::SHELL_RUNNING: { - Y_VERIFY(false, "This can't happen, we used sync mode, it's a bug!"); + Y_VERIFY(false, "This can't happen, we used sync mode, it's a bug!"); } case TShellCommand::SHELL_INTERNAL_ERROR: { ythrow yexception() << "Forked test failed with internal error: " << cmd.GetInternalError(); @@ -539,7 +539,7 @@ const char* const TColoredProcessor::ForkCorrectExitMsg = "--END--"; class TEnumeratingProcessor: public ITestSuiteProcessor { public: - TEnumeratingProcessor(bool verbose, IOutputStream& stream) noexcept + TEnumeratingProcessor(bool verbose, IOutputStream& stream) noexcept : Verbose_(verbose) , Stream_(stream) { @@ -564,7 +564,7 @@ public: private: bool Verbose_; - IOutputStream& Stream_; + IOutputStream& Stream_; }; #ifdef _win_ @@ -600,7 +600,7 @@ private: static const TWinEnvironment Instance; #endif // _win_ -static int DoList(bool verbose, IOutputStream& stream) { +static int DoList(bool verbose, IOutputStream& stream) { TEnumeratingProcessor eproc(verbose, stream); TTestFactory::Instance().SetProcessor(&eproc); TTestFactory::Instance().Execute(); @@ -665,8 +665,8 @@ int NUnitTest::RunMain(int argc, char** argv) { Y_DEFER { NPlugin::OnStopMain(argc, argv); }; TColoredProcessor processor(GetExecPath()); - IOutputStream* listStream = &Cout; - THolder<IOutputStream> listFile; + IOutputStream* listStream = &Cout; + THolder<IOutputStream> listFile; enum EListType { DONT_LIST, diff --git a/library/cpp/threading/atomic/bool_ut.cpp b/library/cpp/threading/atomic/bool_ut.cpp index 9481f41d8dc..86ea26a23dd 100644 --- a/library/cpp/threading/atomic/bool_ut.cpp +++ b/library/cpp/threading/atomic/bool_ut.cpp @@ -2,8 +2,8 @@ #include <library/cpp/testing/unittest/registar.h> -Y_UNIT_TEST_SUITE(AtomicBool) { - Y_UNIT_TEST(ReadWrite) { +Y_UNIT_TEST_SUITE(AtomicBool) { + Y_UNIT_TEST(ReadWrite) { NAtomic::TBool v; UNIT_ASSERT_VALUES_EQUAL((bool)v, false); diff --git a/library/cpp/threading/chunk_queue/queue_ut.cpp b/library/cpp/threading/chunk_queue/queue_ut.cpp index 8cb36d8dd19..3913bd2545b 100644 --- a/library/cpp/threading/chunk_queue/queue_ut.cpp +++ b/library/cpp/threading/chunk_queue/queue_ut.cpp @@ -7,8 +7,8 @@ namespace NThreading { //////////////////////////////////////////////////////////////////////////////// - Y_UNIT_TEST_SUITE(TOneOneQueueTest){ - Y_UNIT_TEST(ShouldBeEmptyAtStart){ + Y_UNIT_TEST_SUITE(TOneOneQueueTest){ + Y_UNIT_TEST(ShouldBeEmptyAtStart){ TOneOneQueue<int> queue; int result = 0; @@ -16,7 +16,7 @@ namespace NThreading { UNIT_ASSERT(!queue.Dequeue(result)); } -Y_UNIT_TEST(ShouldReturnEntries) { +Y_UNIT_TEST(ShouldReturnEntries) { TOneOneQueue<int> queue; queue.Enqueue(1); queue.Enqueue(2); @@ -39,7 +39,7 @@ Y_UNIT_TEST(ShouldReturnEntries) { UNIT_ASSERT(!queue.Dequeue(result)); } -Y_UNIT_TEST(ShouldStoreMultipleChunks) { +Y_UNIT_TEST(ShouldStoreMultipleChunks) { TOneOneQueue<int, 100> queue; for (int i = 0; i < 1000; ++i) { queue.Enqueue(i); @@ -57,8 +57,8 @@ Y_UNIT_TEST(ShouldStoreMultipleChunks) { //////////////////////////////////////////////////////////////////////////////// -Y_UNIT_TEST_SUITE(TManyOneQueueTest){ - Y_UNIT_TEST(ShouldBeEmptyAtStart){ +Y_UNIT_TEST_SUITE(TManyOneQueueTest){ + Y_UNIT_TEST(ShouldBeEmptyAtStart){ TManyOneQueue<int> queue; int result; @@ -66,7 +66,7 @@ UNIT_ASSERT(queue.IsEmpty()); UNIT_ASSERT(!queue.Dequeue(result)); } -Y_UNIT_TEST(ShouldReturnEntries) { +Y_UNIT_TEST(ShouldReturnEntries) { TManyOneQueue<int> queue; queue.Enqueue(1); queue.Enqueue(2); @@ -93,8 +93,8 @@ Y_UNIT_TEST(ShouldReturnEntries) { //////////////////////////////////////////////////////////////////////////////// -Y_UNIT_TEST_SUITE(TManyManyQueueTest){ - Y_UNIT_TEST(ShouldBeEmptyAtStart){ +Y_UNIT_TEST_SUITE(TManyManyQueueTest){ + Y_UNIT_TEST(ShouldBeEmptyAtStart){ TManyManyQueue<int> queue; int result = 0; @@ -102,7 +102,7 @@ UNIT_ASSERT(queue.IsEmpty()); UNIT_ASSERT(!queue.Dequeue(result)); } -Y_UNIT_TEST(ShouldReturnEntries) { +Y_UNIT_TEST(ShouldReturnEntries) { TManyManyQueue<int> queue; queue.Enqueue(1); queue.Enqueue(2); @@ -129,8 +129,8 @@ Y_UNIT_TEST(ShouldReturnEntries) { //////////////////////////////////////////////////////////////////////////////// -Y_UNIT_TEST_SUITE(TRelaxedManyOneQueueTest){ - Y_UNIT_TEST(ShouldBeEmptyAtStart){ +Y_UNIT_TEST_SUITE(TRelaxedManyOneQueueTest){ + Y_UNIT_TEST(ShouldBeEmptyAtStart){ TRelaxedManyOneQueue<int> queue; int result; @@ -138,7 +138,7 @@ UNIT_ASSERT(queue.IsEmpty()); UNIT_ASSERT(!queue.Dequeue(result)); } -Y_UNIT_TEST(ShouldReturnEntries) { +Y_UNIT_TEST(ShouldReturnEntries) { TSet<int> items = {1, 2, 3}; TRelaxedManyOneQueue<int> queue; @@ -167,8 +167,8 @@ Y_UNIT_TEST(ShouldReturnEntries) { //////////////////////////////////////////////////////////////////////////////// -Y_UNIT_TEST_SUITE(TRelaxedManyManyQueueTest){ - Y_UNIT_TEST(ShouldBeEmptyAtStart){ +Y_UNIT_TEST_SUITE(TRelaxedManyManyQueueTest){ + Y_UNIT_TEST(ShouldBeEmptyAtStart){ TRelaxedManyManyQueue<int> queue; int result = 0; @@ -176,7 +176,7 @@ UNIT_ASSERT(queue.IsEmpty()); UNIT_ASSERT(!queue.Dequeue(result)); } -Y_UNIT_TEST(ShouldReturnEntries) { +Y_UNIT_TEST(ShouldReturnEntries) { TSet<int> items = {1, 2, 3}; TRelaxedManyManyQueue<int> queue; diff --git a/library/cpp/threading/equeue/equeue_ut.cpp b/library/cpp/threading/equeue/equeue_ut.cpp index 9cf2aced44e..a2072f9a830 100644 --- a/library/cpp/threading/equeue/equeue_ut.cpp +++ b/library/cpp/threading/equeue/equeue_ut.cpp @@ -6,7 +6,7 @@ #include <util/datetime/base.h> #include <util/generic/vector.h> -Y_UNIT_TEST_SUITE(TElasticQueueTest) { +Y_UNIT_TEST_SUITE(TElasticQueueTest) { const size_t MaxQueueSize = 20; const size_t ThreadCount = 10; const size_t N = 100000; @@ -37,7 +37,7 @@ Y_UNIT_TEST_SUITE(TElasticQueueTest) { //fill test -- fill queue with "endless" jobs TSystemEvent WaitEvent; - Y_UNIT_TEST(FillTest) { + Y_UNIT_TEST(FillTest) { Counters.Reset(); struct TWaitJob: public IObjectInQueue { @@ -91,7 +91,7 @@ Y_UNIT_TEST_SUITE(TElasticQueueTest) { static size_t TryCounter; - Y_UNIT_TEST(ConcurrentTest) { + Y_UNIT_TEST(ConcurrentTest) { Counters.Reset(); TryCounter = 0; diff --git a/library/cpp/threading/future/async_ut.cpp b/library/cpp/threading/future/async_ut.cpp index a3699744e48..07f2a669517 100644 --- a/library/cpp/threading/future/async_ut.cpp +++ b/library/cpp/threading/future/async_ut.cpp @@ -27,15 +27,15 @@ namespace NThreading { } -Y_UNIT_TEST_SUITE(Async) { - Y_UNIT_TEST(ExtensionExample) { +Y_UNIT_TEST_SUITE(Async) { + Y_UNIT_TEST(ExtensionExample) { TMySuperTaskQueue queue; auto future = NThreading::Async([]() { return 5; }, queue); future.Wait(); UNIT_ASSERT_VALUES_EQUAL(future.GetValue(), 5); } - Y_UNIT_TEST(WorksWithIMtpQueue) { + Y_UNIT_TEST(WorksWithIMtpQueue) { auto queue = MakeHolder<TThreadPool>(); queue->Start(1); @@ -44,7 +44,7 @@ Y_UNIT_TEST_SUITE(Async) { UNIT_ASSERT_VALUES_EQUAL(future.GetValue(), 5); } - Y_UNIT_TEST(ProperlyDeducesFutureType) { + Y_UNIT_TEST(ProperlyDeducesFutureType) { // Compileability test auto queue = CreateThreadPool(1); diff --git a/library/cpp/threading/future/core/future.h b/library/cpp/threading/future/core/future.h index 2e82bb953eb..4ab56efb30f 100644 --- a/library/cpp/threading/future/core/future.h +++ b/library/cpp/threading/future/core/future.h @@ -1,7 +1,7 @@ #pragma once -#include "fwd.h" - +#include "fwd.h" + #include <util/datetime/base.h> #include <util/generic/function.h> #include <util/generic/maybe.h> diff --git a/library/cpp/threading/future/future_ut.cpp b/library/cpp/threading/future/future_ut.cpp index 05950a568d4..f45fc84e23a 100644 --- a/library/cpp/threading/future/future_ut.cpp +++ b/library/cpp/threading/future/future_ut.cpp @@ -64,8 +64,8 @@ namespace { //////////////////////////////////////////////////////////////////////////////// - Y_UNIT_TEST_SUITE(TFutureTest) { - Y_UNIT_TEST(ShouldInitiallyHasNoValue) { + Y_UNIT_TEST_SUITE(TFutureTest) { + Y_UNIT_TEST(ShouldInitiallyHasNoValue) { TPromise<int> promise; UNIT_ASSERT(!promise.HasValue()); @@ -79,7 +79,7 @@ namespace { UNIT_ASSERT(!future.HasValue()); } - Y_UNIT_TEST(ShouldInitiallyHasNoValueVoid) { + Y_UNIT_TEST(ShouldInitiallyHasNoValueVoid) { TPromise<void> promise; UNIT_ASSERT(!promise.HasValue()); @@ -93,7 +93,7 @@ namespace { UNIT_ASSERT(!future.HasValue()); } - Y_UNIT_TEST(ShouldStoreValue) { + Y_UNIT_TEST(ShouldStoreValue) { TPromise<int> promise = NewPromise<int>(); promise.SetValue(123); UNIT_ASSERT(promise.HasValue()); @@ -108,7 +108,7 @@ namespace { UNIT_ASSERT_EQUAL(future.GetValue(), 345); } - Y_UNIT_TEST(ShouldStoreValueVoid) { + Y_UNIT_TEST(ShouldStoreValueVoid) { TPromise<void> promise = NewPromise(); promise.SetValue(); UNIT_ASSERT(promise.HasValue()); @@ -151,7 +151,7 @@ namespace { } }; - Y_UNIT_TEST(ShouldInvokeCallback) { + Y_UNIT_TEST(ShouldInvokeCallback) { TPromise<int> promise = NewPromise<int>(); TTestCallback callback(123); @@ -163,7 +163,7 @@ namespace { UNIT_ASSERT_EQUAL(callback.Value, 123 + 456); } - Y_UNIT_TEST(ShouldApplyFunc) { + Y_UNIT_TEST(ShouldApplyFunc) { TPromise<int> promise = NewPromise<int>(); TTestCallback callback(123); @@ -175,7 +175,7 @@ namespace { UNIT_ASSERT_EQUAL(callback.Value, 123 + 456); } - Y_UNIT_TEST(ShouldApplyVoidFunc) { + Y_UNIT_TEST(ShouldApplyVoidFunc) { TPromise<int> promise = NewPromise<int>(); TTestCallback callback(123); @@ -186,7 +186,7 @@ namespace { UNIT_ASSERT(future.HasValue()); } - Y_UNIT_TEST(ShouldApplyFutureFunc) { + Y_UNIT_TEST(ShouldApplyFutureFunc) { TPromise<int> promise = NewPromise<int>(); TTestCallback callback(123); @@ -198,7 +198,7 @@ namespace { UNIT_ASSERT_EQUAL(callback.Value, 123 + 456); } - Y_UNIT_TEST(ShouldApplyFutureVoidFunc) { + Y_UNIT_TEST(ShouldApplyFutureVoidFunc) { TPromise<int> promise = NewPromise<int>(); TTestCallback callback(123); @@ -212,7 +212,7 @@ namespace { UNIT_ASSERT(future.HasValue()); } - Y_UNIT_TEST(ShouldIgnoreResultIfAsked) { + Y_UNIT_TEST(ShouldIgnoreResultIfAsked) { TPromise<int> promise = NewPromise<int>(); TTestCallback callback(123); @@ -225,7 +225,7 @@ namespace { class TCustomException: public yexception { }; - Y_UNIT_TEST(ShouldRethrowException) { + Y_UNIT_TEST(ShouldRethrowException) { TPromise<int> promise = NewPromise<int>(); try { ythrow TCustomException(); @@ -335,7 +335,7 @@ namespace { UNIT_ASSERT(future.HasValue()); } - Y_UNIT_TEST(ShouldWaitAnyVector) { + Y_UNIT_TEST(ShouldWaitAnyVector) { TPromise<void> promise1 = NewPromise(); TPromise<void> promise2 = NewPromise(); @@ -372,7 +372,7 @@ namespace { UNIT_ASSERT(future.HasValue()); } - Y_UNIT_TEST(ShouldWaitAnyList) { + Y_UNIT_TEST(ShouldWaitAnyList) { TPromise<void> promise1 = NewPromise(); TPromise<void> promise2 = NewPromise(); @@ -390,14 +390,14 @@ namespace { UNIT_ASSERT(future.HasValue()); } - Y_UNIT_TEST(ShouldWaitAnyVectorEmpty) { + Y_UNIT_TEST(ShouldWaitAnyVectorEmpty) { TVector<TFuture<void>> promises; TFuture<void> future = WaitAny(promises); UNIT_ASSERT(future.HasValue()); } - Y_UNIT_TEST(ShouldWaitAny) { + Y_UNIT_TEST(ShouldWaitAny) { TPromise<void> promise1 = NewPromise(); TPromise<void> promise2 = NewPromise(); @@ -411,7 +411,7 @@ namespace { UNIT_ASSERT(future.HasValue()); } - Y_UNIT_TEST(ShouldStoreTypesWithoutDefaultConstructor) { + Y_UNIT_TEST(ShouldStoreTypesWithoutDefaultConstructor) { // compileability test struct TRec { explicit TRec(int) { @@ -426,7 +426,7 @@ namespace { Y_UNUSED(rec); } - Y_UNIT_TEST(ShouldStoreMovableTypes) { + Y_UNIT_TEST(ShouldStoreMovableTypes) { // compileability test struct TRec : TMoveOnly { explicit TRec(int) { @@ -441,7 +441,7 @@ namespace { Y_UNUSED(rec); } - Y_UNIT_TEST(ShouldMoveMovableTypes) { + Y_UNIT_TEST(ShouldMoveMovableTypes) { // compileability test struct TRec : TMoveOnly { explicit TRec(int) { @@ -456,7 +456,7 @@ namespace { Y_UNUSED(rec); } - Y_UNIT_TEST(ShouldNotExtractAfterGet) { + Y_UNIT_TEST(ShouldNotExtractAfterGet) { TPromise<int> promise = NewPromise<int>(); promise.SetValue(123); UNIT_ASSERT(promise.HasValue()); @@ -464,7 +464,7 @@ namespace { UNIT_CHECK_GENERATED_EXCEPTION(promise.ExtractValue(), TFutureException); } - Y_UNIT_TEST(ShouldNotGetAfterExtract) { + Y_UNIT_TEST(ShouldNotGetAfterExtract) { TPromise<int> promise = NewPromise<int>(); promise.SetValue(123); UNIT_ASSERT(promise.HasValue()); @@ -472,7 +472,7 @@ namespace { UNIT_CHECK_GENERATED_EXCEPTION(promise.GetValue(), TFutureException); } - Y_UNIT_TEST(ShouldNotExtractAfterExtract) { + Y_UNIT_TEST(ShouldNotExtractAfterExtract) { TPromise<int> promise = NewPromise<int>(); promise.SetValue(123); UNIT_ASSERT(promise.HasValue()); diff --git a/library/cpp/threading/future/fwd.cpp b/library/cpp/threading/future/fwd.cpp index 4214b6df83e..2261ef316c5 100644 --- a/library/cpp/threading/future/fwd.cpp +++ b/library/cpp/threading/future/fwd.cpp @@ -1 +1 @@ -#include "fwd.h" +#include "fwd.h" diff --git a/library/cpp/threading/future/fwd.h b/library/cpp/threading/future/fwd.h index 0cd25dd288c..b51d9b00190 100644 --- a/library/cpp/threading/future/fwd.h +++ b/library/cpp/threading/future/fwd.h @@ -1,8 +1,8 @@ -#pragma once - +#pragma once + #include "core/fwd.h" -namespace NThreading { - template <typename TR = void, bool IgnoreException = false> - class TLegacyFuture; -} +namespace NThreading { + template <typename TR = void, bool IgnoreException = false> + class TLegacyFuture; +} diff --git a/library/cpp/threading/future/legacy_future.h b/library/cpp/threading/future/legacy_future.h index 6f1eabad73b..9bb126e76b8 100644 --- a/library/cpp/threading/future/legacy_future.h +++ b/library/cpp/threading/future/legacy_future.h @@ -1,6 +1,6 @@ #pragma once -#include "fwd.h" +#include "fwd.h" #include "future.h" #include <util/thread/factory.h> @@ -8,7 +8,7 @@ #include <functional> namespace NThreading { - template <typename TR, bool IgnoreException> + template <typename TR, bool IgnoreException> class TLegacyFuture: public IThreadFactory::IThreadAble, TNonCopyable { public: typedef TR(TFunctionSignature)(); diff --git a/library/cpp/threading/future/legacy_future_ut.cpp b/library/cpp/threading/future/legacy_future_ut.cpp index ff63db17250..b0c9dc21aa1 100644 --- a/library/cpp/threading/future/legacy_future_ut.cpp +++ b/library/cpp/threading/future/legacy_future_ut.cpp @@ -3,12 +3,12 @@ #include <library/cpp/testing/unittest/registar.h> namespace NThreading { - Y_UNIT_TEST_SUITE(TLegacyFutureTest) { + Y_UNIT_TEST_SUITE(TLegacyFutureTest) { int intf() { return 17; } - Y_UNIT_TEST(TestIntFunction) { + Y_UNIT_TEST(TestIntFunction) { TLegacyFuture<int> f((&intf)); UNIT_ASSERT_VALUES_EQUAL(17, f.Get()); } @@ -19,7 +19,7 @@ namespace NThreading { r = 18; } - Y_UNIT_TEST(TestVoidFunction) { + Y_UNIT_TEST(TestVoidFunction) { r = 0; TLegacyFuture<> f((&voidf)); f.Get(); @@ -39,7 +39,7 @@ namespace NThreading { } }; - Y_UNIT_TEST(TestMethod) { + Y_UNIT_TEST(TestMethod) { TLegacyFuture<int> f11(std::bind(&TSampleClass::Calc, TSampleClass(3))); UNIT_ASSERT_VALUES_EQUAL(4, f11.Get()); @@ -57,7 +57,7 @@ namespace NThreading { struct TSomeThreadPool: public IThreadFactory {}; - Y_UNIT_TEST(TestFunction) { + Y_UNIT_TEST(TestFunction) { std::function<int()> f((&intf)); UNIT_ASSERT_VALUES_EQUAL(17, TLegacyFuture<int>(f).Get()); diff --git a/library/cpp/threading/future/wait/wait.h b/library/cpp/threading/future/wait/wait.h index 6ff7d57baac..6497574cec2 100644 --- a/library/cpp/threading/future/wait/wait.h +++ b/library/cpp/threading/future/wait/wait.h @@ -1,7 +1,7 @@ #pragma once -#include "fwd.h" - +#include "fwd.h" + #include <library/cpp/threading/future/core/future.h> #include <library/cpp/threading/future/wait/wait_group.h> diff --git a/library/cpp/threading/future/ya.make b/library/cpp/threading/future/ya.make index 6591031f460..d3ad13fa8e0 100644 --- a/library/cpp/threading/future/ya.make +++ b/library/cpp/threading/future/ya.make @@ -1,14 +1,14 @@ -OWNER( - g:rtmr -) - +OWNER( + g:rtmr +) + LIBRARY() SRCS( async.cpp core/future.cpp core/fwd.cpp - fwd.cpp + fwd.cpp wait/fwd.cpp wait/wait.cpp wait/wait_group.cpp diff --git a/library/cpp/threading/local_executor/local_executor.cpp b/library/cpp/threading/local_executor/local_executor.cpp index 1d3fbb4bf44..6e62d09d859 100644 --- a/library/cpp/threading/local_executor/local_executor.cpp +++ b/library/cpp/threading/local_executor/local_executor.cpp @@ -1,17 +1,17 @@ #include "local_executor.h" #include <library/cpp/threading/future/future.h> - -#include <util/generic/utility.h> -#include <util/system/atomic.h> -#include <util/system/event.h> + +#include <util/generic/utility.h> +#include <util/system/atomic.h> +#include <util/system/event.h> #include <util/system/thread.h> -#include <util/system/tls.h> +#include <util/system/tls.h> #include <util/system/yield.h> -#include <util/thread/lfqueue.h> - -#include <utility> +#include <util/thread/lfqueue.h> +#include <utility> + #ifdef _win_ static void RegularYield() { } @@ -23,11 +23,11 @@ static void RegularYield() { } #endif -namespace { - struct TFunctionWrapper : NPar::ILocallyExecutable { - NPar::TLocallyExecutableFunction Exec; - TFunctionWrapper(NPar::TLocallyExecutableFunction exec) - : Exec(std::move(exec)) +namespace { + struct TFunctionWrapper : NPar::ILocallyExecutable { + NPar::TLocallyExecutableFunction Exec; + TFunctionWrapper(NPar::TLocallyExecutableFunction exec) + : Exec(std::move(exec)) { } void LocalExec(int id) override { @@ -35,15 +35,15 @@ namespace { } }; - class TFunctionWrapperWithPromise: public NPar::ILocallyExecutable { + class TFunctionWrapperWithPromise: public NPar::ILocallyExecutable { private: - NPar::TLocallyExecutableFunction Exec; + NPar::TLocallyExecutableFunction Exec; int FirstId, LastId; TVector<NThreading::TPromise<void>> Promises; public: - TFunctionWrapperWithPromise(NPar::TLocallyExecutableFunction exec, int firstId, int lastId) - : Exec(std::move(exec)) + TFunctionWrapperWithPromise(NPar::TLocallyExecutableFunction exec, int firstId, int lastId) + : Exec(std::move(exec)) , FirstId(firstId) , LastId(lastId) { @@ -70,300 +70,300 @@ namespace { } }; - struct TSingleJob { - TIntrusivePtr<NPar::ILocallyExecutable> Exec; - int Id{0}; + struct TSingleJob { + TIntrusivePtr<NPar::ILocallyExecutable> Exec; + int Id{0}; - TSingleJob() = default; - TSingleJob(TIntrusivePtr<NPar::ILocallyExecutable> exec, int id) - : Exec(std::move(exec)) - , Id(id) - { + TSingleJob() = default; + TSingleJob(TIntrusivePtr<NPar::ILocallyExecutable> exec, int id) + : Exec(std::move(exec)) + , Id(id) + { } - }; + }; - class TLocalRangeExecutor: public NPar::ILocallyExecutable { - TIntrusivePtr<NPar::ILocallyExecutable> Exec; + class TLocalRangeExecutor: public NPar::ILocallyExecutable { + TIntrusivePtr<NPar::ILocallyExecutable> Exec; alignas(64) TAtomic Counter; alignas(64) TAtomic WorkerCount; - int LastId; - - void LocalExec(int) override { - AtomicAdd(WorkerCount, 1); - for (;;) { - if (!DoSingleOp()) - break; - } - AtomicAdd(WorkerCount, -1); + int LastId; + + void LocalExec(int) override { + AtomicAdd(WorkerCount, 1); + for (;;) { + if (!DoSingleOp()) + break; + } + AtomicAdd(WorkerCount, -1); } - public: - TLocalRangeExecutor(TIntrusivePtr<ILocallyExecutable> exec, int firstId, int lastId) - : Exec(std::move(exec)) - , Counter(firstId) - , WorkerCount(0) - , LastId(lastId) - { + public: + TLocalRangeExecutor(TIntrusivePtr<ILocallyExecutable> exec, int firstId, int lastId) + : Exec(std::move(exec)) + , Counter(firstId) + , WorkerCount(0) + , LastId(lastId) + { } - bool DoSingleOp() { + bool DoSingleOp() { const int id = AtomicAdd(Counter, 1) - 1; - if (id >= LastId) - return false; - Exec->LocalExec(id); - RegularYield(); - return true; + if (id >= LastId) + return false; + Exec->LocalExec(id); + RegularYield(); + return true; } - void WaitComplete() { - while (AtomicGet(WorkerCount) > 0) - RegularYield(); + void WaitComplete() { + while (AtomicGet(WorkerCount) > 0) + RegularYield(); } - int GetRangeSize() const { - return Max<int>(LastId - Counter, 0); + int GetRangeSize() const { + return Max<int>(LastId - Counter, 0); } - }; + }; } - -////////////////////////////////////////////////////////////////////////// -class NPar::TLocalExecutor::TImpl { -public: - TLockFreeQueue<TSingleJob> JobQueue; - TLockFreeQueue<TSingleJob> MedJobQueue; - TLockFreeQueue<TSingleJob> LowJobQueue; + +////////////////////////////////////////////////////////////////////////// +class NPar::TLocalExecutor::TImpl { +public: + TLockFreeQueue<TSingleJob> JobQueue; + TLockFreeQueue<TSingleJob> MedJobQueue; + TLockFreeQueue<TSingleJob> LowJobQueue; alignas(64) TSystemEvent HasJob; - - TAtomic ThreadCount{0}; + + TAtomic ThreadCount{0}; alignas(64) TAtomic QueueSize{0}; - TAtomic MPQueueSize{0}; - TAtomic LPQueueSize{0}; - TAtomic ThreadId{0}; - - Y_THREAD(int) - CurrentTaskPriority; - Y_THREAD(int) - WorkerThreadId; - - static void* HostWorkerThread(void* p); - bool GetJob(TSingleJob* job); - void RunNewThread(); - void LaunchRange(TIntrusivePtr<TLocalRangeExecutor> execRange, int queueSizeLimit, - TAtomic* queueSize, TLockFreeQueue<TSingleJob>* jobQueue); - - TImpl() = default; - ~TImpl(); -}; - -NPar::TLocalExecutor::TImpl::~TImpl() { - AtomicAdd(QueueSize, 1); - JobQueue.Enqueue(TSingleJob(nullptr, 0)); - HasJob.Signal(); - while (AtomicGet(ThreadCount)) { - ThreadYield(); - } -} - -void* NPar::TLocalExecutor::TImpl::HostWorkerThread(void* p) { - static const int FAST_ITERATIONS = 200; - - auto* const ctx = (TImpl*)p; + TAtomic MPQueueSize{0}; + TAtomic LPQueueSize{0}; + TAtomic ThreadId{0}; + + Y_THREAD(int) + CurrentTaskPriority; + Y_THREAD(int) + WorkerThreadId; + + static void* HostWorkerThread(void* p); + bool GetJob(TSingleJob* job); + void RunNewThread(); + void LaunchRange(TIntrusivePtr<TLocalRangeExecutor> execRange, int queueSizeLimit, + TAtomic* queueSize, TLockFreeQueue<TSingleJob>* jobQueue); + + TImpl() = default; + ~TImpl(); +}; + +NPar::TLocalExecutor::TImpl::~TImpl() { + AtomicAdd(QueueSize, 1); + JobQueue.Enqueue(TSingleJob(nullptr, 0)); + HasJob.Signal(); + while (AtomicGet(ThreadCount)) { + ThreadYield(); + } +} + +void* NPar::TLocalExecutor::TImpl::HostWorkerThread(void* p) { + static const int FAST_ITERATIONS = 200; + + auto* const ctx = (TImpl*)p; TThread::SetCurrentThreadName("ParLocalExecutor"); - ctx->WorkerThreadId = AtomicAdd(ctx->ThreadId, 1); - for (bool cont = true; cont;) { - TSingleJob job; - bool gotJob = false; - for (int iter = 0; iter < FAST_ITERATIONS; ++iter) { - if (ctx->GetJob(&job)) { - gotJob = true; - break; - } - } - if (!gotJob) { - ctx->HasJob.Reset(); - if (!ctx->GetJob(&job)) { - ctx->HasJob.Wait(); - continue; - } - } - if (job.Exec.Get()) { - job.Exec->LocalExec(job.Id); - RegularYield(); - } else { - AtomicAdd(ctx->QueueSize, 1); - ctx->JobQueue.Enqueue(job); - ctx->HasJob.Signal(); - cont = false; - } - } - AtomicAdd(ctx->ThreadCount, -1); - return nullptr; -} - -bool NPar::TLocalExecutor::TImpl::GetJob(TSingleJob* job) { - if (JobQueue.Dequeue(job)) { - CurrentTaskPriority = TLocalExecutor::HIGH_PRIORITY; - AtomicAdd(QueueSize, -1); - return true; - } else if (MedJobQueue.Dequeue(job)) { - CurrentTaskPriority = TLocalExecutor::MED_PRIORITY; - AtomicAdd(MPQueueSize, -1); - return true; - } else if (LowJobQueue.Dequeue(job)) { - CurrentTaskPriority = TLocalExecutor::LOW_PRIORITY; - AtomicAdd(LPQueueSize, -1); - return true; - } - return false; -} - -void NPar::TLocalExecutor::TImpl::RunNewThread() { - AtomicAdd(ThreadCount, 1); - TThread thr(HostWorkerThread, this); - thr.Start(); - thr.Detach(); -} - -void NPar::TLocalExecutor::TImpl::LaunchRange(TIntrusivePtr<TLocalRangeExecutor> rangeExec, - int queueSizeLimit, - TAtomic* queueSize, - TLockFreeQueue<TSingleJob>* jobQueue) { - int count = Min<int>(ThreadCount + 1, rangeExec->GetRangeSize()); - if (queueSizeLimit >= 0 && AtomicGet(*queueSize) >= queueSizeLimit) { - return; - } - AtomicAdd(*queueSize, count); + ctx->WorkerThreadId = AtomicAdd(ctx->ThreadId, 1); + for (bool cont = true; cont;) { + TSingleJob job; + bool gotJob = false; + for (int iter = 0; iter < FAST_ITERATIONS; ++iter) { + if (ctx->GetJob(&job)) { + gotJob = true; + break; + } + } + if (!gotJob) { + ctx->HasJob.Reset(); + if (!ctx->GetJob(&job)) { + ctx->HasJob.Wait(); + continue; + } + } + if (job.Exec.Get()) { + job.Exec->LocalExec(job.Id); + RegularYield(); + } else { + AtomicAdd(ctx->QueueSize, 1); + ctx->JobQueue.Enqueue(job); + ctx->HasJob.Signal(); + cont = false; + } + } + AtomicAdd(ctx->ThreadCount, -1); + return nullptr; +} + +bool NPar::TLocalExecutor::TImpl::GetJob(TSingleJob* job) { + if (JobQueue.Dequeue(job)) { + CurrentTaskPriority = TLocalExecutor::HIGH_PRIORITY; + AtomicAdd(QueueSize, -1); + return true; + } else if (MedJobQueue.Dequeue(job)) { + CurrentTaskPriority = TLocalExecutor::MED_PRIORITY; + AtomicAdd(MPQueueSize, -1); + return true; + } else if (LowJobQueue.Dequeue(job)) { + CurrentTaskPriority = TLocalExecutor::LOW_PRIORITY; + AtomicAdd(LPQueueSize, -1); + return true; + } + return false; +} + +void NPar::TLocalExecutor::TImpl::RunNewThread() { + AtomicAdd(ThreadCount, 1); + TThread thr(HostWorkerThread, this); + thr.Start(); + thr.Detach(); +} + +void NPar::TLocalExecutor::TImpl::LaunchRange(TIntrusivePtr<TLocalRangeExecutor> rangeExec, + int queueSizeLimit, + TAtomic* queueSize, + TLockFreeQueue<TSingleJob>* jobQueue) { + int count = Min<int>(ThreadCount + 1, rangeExec->GetRangeSize()); + if (queueSizeLimit >= 0 && AtomicGet(*queueSize) >= queueSizeLimit) { + return; + } + AtomicAdd(*queueSize, count); jobQueue->EnqueueAll(TVector<TSingleJob>{size_t(count), TSingleJob(rangeExec, 0)}); - HasJob.Signal(); -} - -NPar::TLocalExecutor::TLocalExecutor() - : Impl_{MakeHolder<TImpl>()} { -} - -NPar::TLocalExecutor::~TLocalExecutor() = default; - -void NPar::TLocalExecutor::RunAdditionalThreads(int threadCount) { - for (int i = 0; i < threadCount; i++) - Impl_->RunNewThread(); -} - -void NPar::TLocalExecutor::Exec(TIntrusivePtr<ILocallyExecutable> exec, int id, int flags) { - Y_ASSERT((flags & WAIT_COMPLETE) == 0); // unsupported - int prior = Max<int>(Impl_->CurrentTaskPriority, flags & PRIORITY_MASK); - switch (prior) { - case HIGH_PRIORITY: - AtomicAdd(Impl_->QueueSize, 1); - Impl_->JobQueue.Enqueue(TSingleJob(std::move(exec), id)); - break; - case MED_PRIORITY: - AtomicAdd(Impl_->MPQueueSize, 1); - Impl_->MedJobQueue.Enqueue(TSingleJob(std::move(exec), id)); - break; - case LOW_PRIORITY: - AtomicAdd(Impl_->LPQueueSize, 1); - Impl_->LowJobQueue.Enqueue(TSingleJob(std::move(exec), id)); - break; - default: - Y_ASSERT(0); - break; - } - Impl_->HasJob.Signal(); -} - + HasJob.Signal(); +} + +NPar::TLocalExecutor::TLocalExecutor() + : Impl_{MakeHolder<TImpl>()} { +} + +NPar::TLocalExecutor::~TLocalExecutor() = default; + +void NPar::TLocalExecutor::RunAdditionalThreads(int threadCount) { + for (int i = 0; i < threadCount; i++) + Impl_->RunNewThread(); +} + +void NPar::TLocalExecutor::Exec(TIntrusivePtr<ILocallyExecutable> exec, int id, int flags) { + Y_ASSERT((flags & WAIT_COMPLETE) == 0); // unsupported + int prior = Max<int>(Impl_->CurrentTaskPriority, flags & PRIORITY_MASK); + switch (prior) { + case HIGH_PRIORITY: + AtomicAdd(Impl_->QueueSize, 1); + Impl_->JobQueue.Enqueue(TSingleJob(std::move(exec), id)); + break; + case MED_PRIORITY: + AtomicAdd(Impl_->MPQueueSize, 1); + Impl_->MedJobQueue.Enqueue(TSingleJob(std::move(exec), id)); + break; + case LOW_PRIORITY: + AtomicAdd(Impl_->LPQueueSize, 1); + Impl_->LowJobQueue.Enqueue(TSingleJob(std::move(exec), id)); + break; + default: + Y_ASSERT(0); + break; + } + Impl_->HasJob.Signal(); +} + void NPar::ILocalExecutor::Exec(TLocallyExecutableFunction exec, int id, int flags) { - Exec(new TFunctionWrapper(std::move(exec)), id, flags); -} - -void NPar::TLocalExecutor::ExecRange(TIntrusivePtr<ILocallyExecutable> exec, int firstId, int lastId, int flags) { - Y_ASSERT(lastId >= firstId); + Exec(new TFunctionWrapper(std::move(exec)), id, flags); +} + +void NPar::TLocalExecutor::ExecRange(TIntrusivePtr<ILocallyExecutable> exec, int firstId, int lastId, int flags) { + Y_ASSERT(lastId >= firstId); if (TryExecRangeSequentially([=] (int id) { exec->LocalExec(id); }, firstId, lastId, flags)) { - return; - } - auto rangeExec = MakeIntrusive<TLocalRangeExecutor>(std::move(exec), firstId, lastId); - int queueSizeLimit = (flags & WAIT_COMPLETE) ? 10000 : -1; - int prior = Max<int>(Impl_->CurrentTaskPriority, flags & PRIORITY_MASK); - switch (prior) { - case HIGH_PRIORITY: - Impl_->LaunchRange(rangeExec, queueSizeLimit, &Impl_->QueueSize, &Impl_->JobQueue); - break; - case MED_PRIORITY: - Impl_->LaunchRange(rangeExec, queueSizeLimit, &Impl_->MPQueueSize, &Impl_->MedJobQueue); - break; - case LOW_PRIORITY: - Impl_->LaunchRange(rangeExec, queueSizeLimit, &Impl_->LPQueueSize, &Impl_->LowJobQueue); - break; - default: - Y_ASSERT(0); - break; - } - if (flags & WAIT_COMPLETE) { - int keepPrior = Impl_->CurrentTaskPriority; - Impl_->CurrentTaskPriority = prior; - while (rangeExec->DoSingleOp()) { - } - Impl_->CurrentTaskPriority = keepPrior; - rangeExec->WaitComplete(); - } -} - + return; + } + auto rangeExec = MakeIntrusive<TLocalRangeExecutor>(std::move(exec), firstId, lastId); + int queueSizeLimit = (flags & WAIT_COMPLETE) ? 10000 : -1; + int prior = Max<int>(Impl_->CurrentTaskPriority, flags & PRIORITY_MASK); + switch (prior) { + case HIGH_PRIORITY: + Impl_->LaunchRange(rangeExec, queueSizeLimit, &Impl_->QueueSize, &Impl_->JobQueue); + break; + case MED_PRIORITY: + Impl_->LaunchRange(rangeExec, queueSizeLimit, &Impl_->MPQueueSize, &Impl_->MedJobQueue); + break; + case LOW_PRIORITY: + Impl_->LaunchRange(rangeExec, queueSizeLimit, &Impl_->LPQueueSize, &Impl_->LowJobQueue); + break; + default: + Y_ASSERT(0); + break; + } + if (flags & WAIT_COMPLETE) { + int keepPrior = Impl_->CurrentTaskPriority; + Impl_->CurrentTaskPriority = prior; + while (rangeExec->DoSingleOp()) { + } + Impl_->CurrentTaskPriority = keepPrior; + rangeExec->WaitComplete(); + } +} + void NPar::ILocalExecutor::ExecRange(TLocallyExecutableFunction exec, int firstId, int lastId, int flags) { if (TryExecRangeSequentially(exec, firstId, lastId, flags)) { return; } - ExecRange(new TFunctionWrapper(exec), firstId, lastId, flags); -} - + ExecRange(new TFunctionWrapper(exec), firstId, lastId, flags); +} + void NPar::ILocalExecutor::ExecRangeWithThrow(TLocallyExecutableFunction exec, int firstId, int lastId, int flags) { - Y_VERIFY((flags & WAIT_COMPLETE) != 0, "ExecRangeWithThrow() requires WAIT_COMPLETE to wait if exceptions arise."); + Y_VERIFY((flags & WAIT_COMPLETE) != 0, "ExecRangeWithThrow() requires WAIT_COMPLETE to wait if exceptions arise."); if (TryExecRangeSequentially(exec, firstId, lastId, flags)) { return; } - TVector<NThreading::TFuture<void>> currentRun = ExecRangeWithFutures(exec, firstId, lastId, flags); - for (auto& result : currentRun) { - result.GetValueSync(); // Exception will be rethrown if exists. If several exception - only the one with minimal id is rethrown. - } -} - -TVector<NThreading::TFuture<void>> + TVector<NThreading::TFuture<void>> currentRun = ExecRangeWithFutures(exec, firstId, lastId, flags); + for (auto& result : currentRun) { + result.GetValueSync(); // Exception will be rethrown if exists. If several exception - only the one with minimal id is rethrown. + } +} + +TVector<NThreading::TFuture<void>> NPar::ILocalExecutor::ExecRangeWithFutures(TLocallyExecutableFunction exec, int firstId, int lastId, int flags) { - TFunctionWrapperWithPromise* execWrapper = new TFunctionWrapperWithPromise(exec, firstId, lastId); - TVector<NThreading::TFuture<void>> out = execWrapper->GetFutures(); - ExecRange(execWrapper, firstId, lastId, flags); - return out; -} - -void NPar::TLocalExecutor::ClearLPQueue() { - for (bool cont = true; cont;) { - cont = false; - TSingleJob job; - while (Impl_->LowJobQueue.Dequeue(&job)) { - AtomicAdd(Impl_->LPQueueSize, -1); - cont = true; - } - while (Impl_->MedJobQueue.Dequeue(&job)) { - AtomicAdd(Impl_->MPQueueSize, -1); - cont = true; - } - } -} - -int NPar::TLocalExecutor::GetQueueSize() const noexcept { - return AtomicGet(Impl_->QueueSize); -} - -int NPar::TLocalExecutor::GetMPQueueSize() const noexcept { - return AtomicGet(Impl_->MPQueueSize); -} - -int NPar::TLocalExecutor::GetLPQueueSize() const noexcept { - return AtomicGet(Impl_->LPQueueSize); -} - + TFunctionWrapperWithPromise* execWrapper = new TFunctionWrapperWithPromise(exec, firstId, lastId); + TVector<NThreading::TFuture<void>> out = execWrapper->GetFutures(); + ExecRange(execWrapper, firstId, lastId, flags); + return out; +} + +void NPar::TLocalExecutor::ClearLPQueue() { + for (bool cont = true; cont;) { + cont = false; + TSingleJob job; + while (Impl_->LowJobQueue.Dequeue(&job)) { + AtomicAdd(Impl_->LPQueueSize, -1); + cont = true; + } + while (Impl_->MedJobQueue.Dequeue(&job)) { + AtomicAdd(Impl_->MPQueueSize, -1); + cont = true; + } + } +} + +int NPar::TLocalExecutor::GetQueueSize() const noexcept { + return AtomicGet(Impl_->QueueSize); +} + +int NPar::TLocalExecutor::GetMPQueueSize() const noexcept { + return AtomicGet(Impl_->MPQueueSize); +} + +int NPar::TLocalExecutor::GetLPQueueSize() const noexcept { + return AtomicGet(Impl_->LPQueueSize); +} + int NPar::TLocalExecutor::GetWorkerThreadId() const noexcept { - return Impl_->WorkerThreadId; -} - -int NPar::TLocalExecutor::GetThreadCount() const noexcept { - return AtomicGet(Impl_->ThreadCount); -} - -////////////////////////////////////////////////////////////////////////// + return Impl_->WorkerThreadId; +} + +int NPar::TLocalExecutor::GetThreadCount() const noexcept { + return AtomicGet(Impl_->ThreadCount); +} + +////////////////////////////////////////////////////////////////////////// diff --git a/library/cpp/threading/local_executor/local_executor.h b/library/cpp/threading/local_executor/local_executor.h index c1c824f67cb..aa500d34d3d 100644 --- a/library/cpp/threading/local_executor/local_executor.h +++ b/library/cpp/threading/local_executor/local_executor.h @@ -1,23 +1,23 @@ #pragma once #include <library/cpp/threading/future/future.h> - + #include <util/generic/cast.h> -#include <util/generic/fwd.h> -#include <util/generic/noncopyable.h> +#include <util/generic/fwd.h> +#include <util/generic/noncopyable.h> #include <util/generic/ptr.h> -#include <util/generic/singleton.h> +#include <util/generic/singleton.h> #include <util/generic/ymath.h> - + #include <functional> namespace NPar { struct ILocallyExecutable : virtual public TThrRefBase { - // Must be implemented by the end user to define job that will be processed by one of - // executor threads. - // - // @param id Job parameter, typically an index pointing somewhere in array, or just - // some dummy value, e.g. `0`. + // Must be implemented by the end user to define job that will be processed by one of + // executor threads. + // + // @param id Job parameter, typically an index pointing somewhere in array, or just + // some dummy value, e.g. `0`. virtual void LocalExec(int id) = 0; }; @@ -31,7 +31,7 @@ namespace NPar { ILocalExecutor() = default; virtual ~ILocalExecutor() = default; - enum EFlags : int { + enum EFlags : int { HIGH_PRIORITY = 0, MED_PRIORITY = 1, LOW_PRIORITY = 2, @@ -58,8 +58,8 @@ namespace NPar { virtual int GetWorkerThreadId() const noexcept = 0; virtual int GetThreadCount() const noexcept = 0; - // Describes a range of tasks with parameters from integer range [FirstId, LastId). - // + // Describes a range of tasks with parameters from integer range [FirstId, LastId). + // class TExecRangeParams { public: template <typename TFirst, typename TLast> @@ -70,9 +70,9 @@ namespace NPar { Y_ASSERT(LastId >= FirstId); SetBlockSize(1); } - // Partition tasks into `blockCount` blocks of approximately equal size, each of which - // will be executed as a separate bigger task. - // + // Partition tasks into `blockCount` blocks of approximately equal size, each of which + // will be executed as a separate bigger task. + // template <typename TBlockCount> TExecRangeParams& SetBlockCount(TBlockCount blockCount) { Y_ASSERT(SafeIntegerCast<int>(blockCount) > 0 || FirstId == LastId); @@ -81,9 +81,9 @@ namespace NPar { BlockEqualToThreads = false; return *this; } - // Partition tasks into blocks of approximately `blockSize` size, each of which will - // be executed as a separate bigger task. - // + // Partition tasks into blocks of approximately `blockSize` size, each of which will + // be executed as a separate bigger task. + // template <typename TBlockSize> TExecRangeParams& SetBlockSize(TBlockSize blockSize) { Y_ASSERT(SafeIntegerCast<int>(blockSize) > 0 || FirstId == LastId); @@ -92,9 +92,9 @@ namespace NPar { BlockEqualToThreads = false; return *this; } - // Partition tasks into thread count blocks of approximately equal size, each of which - // will be executed as a separate bigger task. - // + // Partition tasks into thread count blocks of approximately equal size, each of which + // will be executed as a separate bigger task. + // TExecRangeParams& SetBlockCountToThreadCount() { BlockEqualToThreads = true; return *this; @@ -107,9 +107,9 @@ namespace NPar { Y_ASSERT(!BlockEqualToThreads); return BlockSize; } - bool GetBlockEqualToThreads() { - return BlockEqualToThreads; - } + bool GetBlockEqualToThreads() { + return BlockEqualToThreads; + } const int FirstId = 0; const int LastId = 0; @@ -120,26 +120,26 @@ namespace NPar { bool BlockEqualToThreads; }; - // `Exec` and `ExecRange` versions that accept functions. - // - void Exec(TLocallyExecutableFunction exec, int id, int flags); - void ExecRange(TLocallyExecutableFunction exec, int firstId, int lastId, int flags); - - // Version of `ExecRange` that throws exception from task with minimal id if at least one of - // task threw an exception. - // - void ExecRangeWithThrow(TLocallyExecutableFunction exec, int firstId, int lastId, int flags); - - // Version of `ExecRange` that returns vector of futures, thus allowing to retry any task if - // it fails. - // - TVector<NThreading::TFuture<void>> ExecRangeWithFutures(TLocallyExecutableFunction exec, int firstId, int lastId, int flags); - + // `Exec` and `ExecRange` versions that accept functions. + // + void Exec(TLocallyExecutableFunction exec, int id, int flags); + void ExecRange(TLocallyExecutableFunction exec, int firstId, int lastId, int flags); + + // Version of `ExecRange` that throws exception from task with minimal id if at least one of + // task threw an exception. + // + void ExecRangeWithThrow(TLocallyExecutableFunction exec, int firstId, int lastId, int flags); + + // Version of `ExecRange` that returns vector of futures, thus allowing to retry any task if + // it fails. + // + TVector<NThreading::TFuture<void>> ExecRangeWithFutures(TLocallyExecutableFunction exec, int firstId, int lastId, int flags); + template <typename TBody> static inline auto BlockedLoopBody(const TExecRangeParams& params, const TBody& body) { return [=](int blockId) { - const int blockFirstId = params.FirstId + blockId * params.GetBlockSize(); - const int blockLastId = Min(params.LastId, blockFirstId + params.GetBlockSize()); + const int blockFirstId = params.FirstId + blockId * params.GetBlockSize(); + const int blockLastId = Min(params.LastId, blockFirstId + params.GetBlockSize()); for (int i = blockFirstId; i < blockLastId; ++i) { body(i); } @@ -151,10 +151,10 @@ namespace NPar { if (TryExecRangeSequentially(body, params.FirstId, params.LastId, flags)) { return; } - if (params.GetBlockEqualToThreads()) { - params.SetBlockCount(GetThreadCount() + ((flags & WAIT_COMPLETE) != 0)); // ThreadCount or ThreadCount+1 depending on WaitFlag + if (params.GetBlockEqualToThreads()) { + params.SetBlockCount(GetThreadCount() + ((flags & WAIT_COMPLETE) != 0)); // ThreadCount or ThreadCount+1 depending on WaitFlag } - ExecRange(BlockedLoopBody(params, body), 0, params.GetBlockCount(), flags); + ExecRange(BlockedLoopBody(params, body), 0, params.GetBlockCount(), flags); } template <typename TBody> @@ -269,7 +269,7 @@ namespace NPar { THolder<TImpl> Impl_; }; - static inline TLocalExecutor& LocalExecutor() { + static inline TLocalExecutor& LocalExecutor() { return *Singleton<TLocalExecutor>(); } diff --git a/library/cpp/threading/local_executor/ut/local_executor_ut.cpp b/library/cpp/threading/local_executor/ut/local_executor_ut.cpp index ac5737717cd..fe7dab08994 100644 --- a/library/cpp/threading/local_executor/ut/local_executor_ut.cpp +++ b/library/cpp/threading/local_executor/ut/local_executor_ut.cpp @@ -1,10 +1,10 @@ #include <library/cpp/threading/local_executor/local_executor.h> #include <library/cpp/threading/future/future.h> - + #include <library/cpp/testing/unittest/registar.h> #include <util/system/mutex.h> #include <util/system/rwlock.h> -#include <util/generic/algorithm.h> +#include <util/generic/algorithm.h> using namespace NPar; @@ -14,7 +14,7 @@ class TTestException: public yexception { static const int DefaultThreadsCount = 41; static const int DefaultRangeSize = 999; -Y_UNIT_TEST_SUITE(ExecRangeWithFutures){ +Y_UNIT_TEST_SUITE(ExecRangeWithFutures){ bool AllOf(const TVector<int>& vec, int value){ return AllOf(vec, [value](int element) { return value == element; }); } @@ -41,23 +41,23 @@ void AsyncRunAndWaitFuturesReady(int rangeSize, int threads) { UNIT_ASSERT(AllOf(data, 1)); } -Y_UNIT_TEST(AsyncRunRangeAndWaitFuturesReady) { +Y_UNIT_TEST(AsyncRunRangeAndWaitFuturesReady) { AsyncRunAndWaitFuturesReady(DefaultRangeSize, DefaultThreadsCount); } -Y_UNIT_TEST(AsyncRunOneTaskAndWaitFuturesReady) { +Y_UNIT_TEST(AsyncRunOneTaskAndWaitFuturesReady) { AsyncRunAndWaitFuturesReady(1, DefaultThreadsCount); } -Y_UNIT_TEST(AsyncRunRangeAndWaitFuturesReadyOneExtraThread) { +Y_UNIT_TEST(AsyncRunRangeAndWaitFuturesReadyOneExtraThread) { AsyncRunAndWaitFuturesReady(DefaultRangeSize, 1); } -Y_UNIT_TEST(AsyncRunOneThreadAndWaitFuturesReadyOneExtraThread) { +Y_UNIT_TEST(AsyncRunOneThreadAndWaitFuturesReadyOneExtraThread) { AsyncRunAndWaitFuturesReady(1, 1); } -Y_UNIT_TEST(AsyncRunTwoRangesAndWaitFuturesReady) { +Y_UNIT_TEST(AsyncRunTwoRangesAndWaitFuturesReady) { TLocalExecutor localExecutor; localExecutor.RunAdditionalThreads(DefaultThreadsCount); TAtomic signal = 0; @@ -118,23 +118,23 @@ void AsyncRunRangeAndWaitExceptions(int rangeSize, int threadsCount) { UNIT_ASSERT(AllOf(data, 1)); } -Y_UNIT_TEST(AsyncRunRangeAndWaitExceptions) { +Y_UNIT_TEST(AsyncRunRangeAndWaitExceptions) { AsyncRunRangeAndWaitExceptions(DefaultRangeSize, DefaultThreadsCount); } -Y_UNIT_TEST(AsyncRunOneTaskAndWaitExceptions) { +Y_UNIT_TEST(AsyncRunOneTaskAndWaitExceptions) { AsyncRunRangeAndWaitExceptions(1, DefaultThreadsCount); } -Y_UNIT_TEST(AsyncRunRangeAndWaitExceptionsOneExtraThread) { +Y_UNIT_TEST(AsyncRunRangeAndWaitExceptionsOneExtraThread) { AsyncRunRangeAndWaitExceptions(DefaultRangeSize, 1); } -Y_UNIT_TEST(AsyncRunOneTaskAndWaitExceptionsOneExtraThread) { +Y_UNIT_TEST(AsyncRunOneTaskAndWaitExceptionsOneExtraThread) { AsyncRunRangeAndWaitExceptions(1, 1); } -Y_UNIT_TEST(AsyncRunTwoRangesAndWaitExceptions) { +Y_UNIT_TEST(AsyncRunTwoRangesAndWaitExceptions) { TLocalExecutor localExecutor; localExecutor.RunAdditionalThreads(DefaultThreadsCount); TAtomic signal = 0; @@ -209,33 +209,33 @@ void RunRangeAndCheckExceptionsWithWaitComplete(int rangeSize, int threadsCount) UNIT_ASSERT(AllOf(data, 1)); } -Y_UNIT_TEST(RunRangeAndCheckExceptionsWithWaitComplete) { +Y_UNIT_TEST(RunRangeAndCheckExceptionsWithWaitComplete) { RunRangeAndCheckExceptionsWithWaitComplete(DefaultRangeSize, DefaultThreadsCount); } -Y_UNIT_TEST(RunOneAndCheckExceptionsWithWaitComplete) { +Y_UNIT_TEST(RunOneAndCheckExceptionsWithWaitComplete) { RunRangeAndCheckExceptionsWithWaitComplete(1, DefaultThreadsCount); } -Y_UNIT_TEST(RunRangeAndCheckExceptionsWithWaitCompleteOneExtraThread) { +Y_UNIT_TEST(RunRangeAndCheckExceptionsWithWaitCompleteOneExtraThread) { RunRangeAndCheckExceptionsWithWaitComplete(DefaultRangeSize, 1); } -Y_UNIT_TEST(RunOneAndCheckExceptionsWithWaitCompleteOneExtraThread) { +Y_UNIT_TEST(RunOneAndCheckExceptionsWithWaitCompleteOneExtraThread) { RunRangeAndCheckExceptionsWithWaitComplete(1, 1); } -Y_UNIT_TEST(RunRangeAndCheckExceptionsWithWaitCompleteZeroExtraThreads) { +Y_UNIT_TEST(RunRangeAndCheckExceptionsWithWaitCompleteZeroExtraThreads) { RunRangeAndCheckExceptionsWithWaitComplete(DefaultRangeSize, 0); } -Y_UNIT_TEST(RunOneAndCheckExceptionsWithWaitCompleteZeroExtraThreads) { +Y_UNIT_TEST(RunOneAndCheckExceptionsWithWaitCompleteZeroExtraThreads) { RunRangeAndCheckExceptionsWithWaitComplete(1, 0); } } ; -Y_UNIT_TEST_SUITE(ExecRangeWithThrow){ +Y_UNIT_TEST_SUITE(ExecRangeWithThrow){ void RunParallelWhichThrowsTTestException(int rangeStart, int rangeSize, int threadsCount, int flags, TAtomic& processed){ AtomicSet(processed, 0); TLocalExecutor localExecutor; @@ -247,7 +247,7 @@ localExecutor.ExecRangeWithThrow([&processed](int) { rangeStart, rangeStart + rangeSize, flags); } -Y_UNIT_TEST(RunParallelWhichThrowsTTestException) { +Y_UNIT_TEST(RunParallelWhichThrowsTTestException) { TAtomic processed = 0; UNIT_ASSERT_EXCEPTION( RunParallelWhichThrowsTTestException(10, 40, DefaultThreadsCount, @@ -264,32 +264,32 @@ void ThrowAndCatchTTestException(int rangeSize, int threadsCount, int flags) { UNIT_ASSERT(AtomicGet(processed) == rangeSize); } -Y_UNIT_TEST(ThrowAndCatchTTestExceptionLowPriority) { +Y_UNIT_TEST(ThrowAndCatchTTestExceptionLowPriority) { ThrowAndCatchTTestException(DefaultRangeSize, DefaultThreadsCount, TLocalExecutor::EFlags::WAIT_COMPLETE | TLocalExecutor::EFlags::LOW_PRIORITY); } -Y_UNIT_TEST(ThrowAndCatchTTestExceptionMedPriority) { +Y_UNIT_TEST(ThrowAndCatchTTestExceptionMedPriority) { ThrowAndCatchTTestException(DefaultRangeSize, DefaultThreadsCount, TLocalExecutor::EFlags::WAIT_COMPLETE | TLocalExecutor::EFlags::MED_PRIORITY); } -Y_UNIT_TEST(ThrowAndCatchTTestExceptionHighPriority) { +Y_UNIT_TEST(ThrowAndCatchTTestExceptionHighPriority) { ThrowAndCatchTTestException(DefaultRangeSize, DefaultThreadsCount, TLocalExecutor::EFlags::WAIT_COMPLETE | TLocalExecutor::EFlags::HIGH_PRIORITY); } -Y_UNIT_TEST(ThrowAndCatchTTestExceptionWaitComplete) { +Y_UNIT_TEST(ThrowAndCatchTTestExceptionWaitComplete) { ThrowAndCatchTTestException(DefaultRangeSize, DefaultThreadsCount, TLocalExecutor::EFlags::WAIT_COMPLETE); } -Y_UNIT_TEST(RethrowExeptionSequentialWaitComplete) { +Y_UNIT_TEST(RethrowExeptionSequentialWaitComplete) { ThrowAndCatchTTestException(DefaultRangeSize, 0, TLocalExecutor::EFlags::WAIT_COMPLETE); } -Y_UNIT_TEST(RethrowExeptionOneExtraThreadWaitComplete) { +Y_UNIT_TEST(RethrowExeptionOneExtraThreadWaitComplete) { ThrowAndCatchTTestException(DefaultRangeSize, 1, TLocalExecutor::EFlags::WAIT_COMPLETE); } @@ -314,7 +314,7 @@ void CatchTTestExceptionFromNested(TAtomic& processed1, TAtomic& processed2) { 0, DefaultRangeSize, TLocalExecutor::EFlags::WAIT_COMPLETE); } -Y_UNIT_TEST(NestedParallelExceptionsDoNotLeak) { +Y_UNIT_TEST(NestedParallelExceptionsDoNotLeak) { TAtomic processed1 = 0; TAtomic processed2 = 0; UNIT_ASSERT_NO_EXCEPTION( diff --git a/library/cpp/threading/local_executor/ut/ya.make b/library/cpp/threading/local_executor/ut/ya.make index be579a5ca06..2983c4f4669 100644 --- a/library/cpp/threading/local_executor/ut/ya.make +++ b/library/cpp/threading/local_executor/ut/ya.make @@ -1,10 +1,10 @@ OWNER( g:matrixnet - gulin -) + gulin +) UNITTEST_FOR(library/cpp/threading/local_executor) - + SRCS( local_executor_ut.cpp ) diff --git a/library/cpp/threading/local_executor/ya.make b/library/cpp/threading/local_executor/ya.make index df210f92bb6..516be667034 100644 --- a/library/cpp/threading/local_executor/ya.make +++ b/library/cpp/threading/local_executor/ya.make @@ -5,8 +5,8 @@ OWNER( espetrov ) -LIBRARY() - +LIBRARY() + SRCS( local_executor.cpp tbb_local_executor.cpp diff --git a/library/cpp/threading/poor_man_openmp/thread_helper_ut.cpp b/library/cpp/threading/poor_man_openmp/thread_helper_ut.cpp index 74176368643..0f91c1ce4a4 100644 --- a/library/cpp/threading/poor_man_openmp/thread_helper_ut.cpp +++ b/library/cpp/threading/poor_man_openmp/thread_helper_ut.cpp @@ -5,8 +5,8 @@ #include <util/generic/string.h> #include <util/generic/yexception.h> -Y_UNIT_TEST_SUITE(TestMP) { - Y_UNIT_TEST(TestErr) { +Y_UNIT_TEST_SUITE(TestMP) { + Y_UNIT_TEST(TestErr) { std::function<void(int)> f = [](int x) { if (x == 5) { ythrow yexception() << "oops"; diff --git a/library/cpp/threading/queue/basic_ut.cpp b/library/cpp/threading/queue/basic_ut.cpp index 5f56f8583ec..a52b46c8a63 100644 --- a/library/cpp/threading/queue/basic_ut.cpp +++ b/library/cpp/threading/queue/basic_ut.cpp @@ -51,7 +51,7 @@ public: template <size_t NUMBER_OF_THREADS> void RepeatPush1Pop1_InManyThreads() { - class TCycleThread: public ISimpleThread { + class TCycleThread: public ISimpleThread { public: void* ThreadProc() override { TQueueType queue; diff --git a/library/cpp/threading/queue/queue_ut.cpp b/library/cpp/threading/queue/queue_ut.cpp index 80eca147da9..eb77e51e19e 100644 --- a/library/cpp/threading/queue/queue_ut.cpp +++ b/library/cpp/threading/queue/queue_ut.cpp @@ -43,7 +43,7 @@ public: void Threads2_Push1M_Threads1_Pop2M() { TQueueType queue; - class TPusherThread: public ISimpleThread { + class TPusherThread: public ISimpleThread { public: TPusherThread(TQueueType& theQueue, char* start) : Queue(theQueue) @@ -81,7 +81,7 @@ public: void Threads4_Push1M_Threads1_Pop4M() { TQueueType queue; - class TPusherThread: public ISimpleThread { + class TPusherThread: public ISimpleThread { public: TPusherThread(TQueueType& theQueue, char* start) : Queue(theQueue) @@ -124,7 +124,7 @@ public: void ManyRndPush100K_ManyQueues() { TQueueType queue[NUMBER_OF_QUEUES]; - class TPusherThread: public ISimpleThread { + class TPusherThread: public ISimpleThread { public: TPusherThread(TQueueType* queues, char* start) : Queues(queues) @@ -155,7 +155,7 @@ public: } }; - class TPopperThread: public ISimpleThread { + class TPopperThread: public ISimpleThread { public: TPopperThread(TQueueType* theQueue, char* base) : Queue(theQueue) diff --git a/library/cpp/threading/queue/tune_ut.cpp b/library/cpp/threading/queue/tune_ut.cpp index 7e980d3e27e..34086ccf0fe 100644 --- a/library/cpp/threading/queue/tune_ut.cpp +++ b/library/cpp/threading/queue/tune_ut.cpp @@ -19,8 +19,8 @@ DeclareTuneTypeParam(TweakStructB, TStructB); DeclareTuneValueParam(TweakParam1, ui32, Param1); DeclareTuneValueParam(TweakParam2, ui32, Param2); -Y_UNIT_TEST_SUITE(TestTuning) { - Y_UNIT_TEST(Defaults) { +Y_UNIT_TEST_SUITE(TestTuning) { + Y_UNIT_TEST(Defaults) { using TTuned = TTune<TDefaults>; using TunedA = TTuned::TStructA; using TunedB = TTuned::TStructB; @@ -35,7 +35,7 @@ Y_UNIT_TEST_SUITE(TestTuning) { UNIT_ASSERT_EQUAL(param2, 42); } - Y_UNIT_TEST(TuneStructA) { + Y_UNIT_TEST(TuneStructA) { struct TMyStruct { }; @@ -56,7 +56,7 @@ Y_UNIT_TEST_SUITE(TestTuning) { UNIT_ASSERT_EQUAL(param2, 42); } - Y_UNIT_TEST(TuneParam1) { + Y_UNIT_TEST(TuneParam1) { using TTuned = TTune<TDefaults, TweakParam1<24>>; using TunedA = TTuned::TStructA; @@ -72,7 +72,7 @@ Y_UNIT_TEST_SUITE(TestTuning) { UNIT_ASSERT_EQUAL(param2, 42); } - Y_UNIT_TEST(TuneStructAAndParam1) { + Y_UNIT_TEST(TuneStructAAndParam1) { struct TMyStruct { }; @@ -94,7 +94,7 @@ Y_UNIT_TEST_SUITE(TestTuning) { UNIT_ASSERT_EQUAL(param2, 42); } - Y_UNIT_TEST(TuneParam1AndStructA) { + Y_UNIT_TEST(TuneParam1AndStructA) { struct TMyStruct { }; diff --git a/library/cpp/threading/queue/unordered_ut.cpp b/library/cpp/threading/queue/unordered_ut.cpp index a43b7f520e5..1310559c469 100644 --- a/library/cpp/threading/queue/unordered_ut.cpp +++ b/library/cpp/threading/queue/unordered_ut.cpp @@ -56,7 +56,7 @@ public: void ManyThreadsRndExchange() { TQueueType queues[COUNT]; - class TWorker: public ISimpleThread { + class TWorker: public ISimpleThread { public: TWorker( TQueueType* queues_, diff --git a/library/cpp/threading/skip_list/skiplist_ut.cpp b/library/cpp/threading/skip_list/skiplist_ut.cpp index 52fcffda661..9c483de1369 100644 --- a/library/cpp/threading/skip_list/skiplist_ut.cpp +++ b/library/cpp/threading/skip_list/skiplist_ut.cpp @@ -35,15 +35,15 @@ namespace NThreading { //////////////////////////////////////////////////////////////////////////////// - Y_UNIT_TEST_SUITE(TSkipListTest) { - Y_UNIT_TEST(ShouldBeEmptyAfterCreation) { + Y_UNIT_TEST_SUITE(TSkipListTest) { + Y_UNIT_TEST(ShouldBeEmptyAfterCreation) { TMemoryPool pool(1024); TSkipList<int> list(pool); UNIT_ASSERT_EQUAL(list.GetSize(), 0); } - Y_UNIT_TEST(ShouldAllowInsertion) { + Y_UNIT_TEST(ShouldAllowInsertion) { TMemoryPool pool(1024); TSkipList<int> list(pool); @@ -51,7 +51,7 @@ namespace NThreading { UNIT_ASSERT_EQUAL(list.GetSize(), 1); } - Y_UNIT_TEST(ShouldNotAllowDuplicates) { + Y_UNIT_TEST(ShouldNotAllowDuplicates) { TMemoryPool pool(1024); TSkipList<int> list(pool); @@ -62,7 +62,7 @@ namespace NThreading { UNIT_ASSERT_EQUAL(list.GetSize(), 1); } - Y_UNIT_TEST(ShouldContainInsertedItem) { + Y_UNIT_TEST(ShouldContainInsertedItem) { TMemoryPool pool(1024); TSkipList<int> list(pool); @@ -70,7 +70,7 @@ namespace NThreading { UNIT_ASSERT(list.Contains(12345678)); } - Y_UNIT_TEST(ShouldNotContainNotInsertedItem) { + Y_UNIT_TEST(ShouldNotContainNotInsertedItem) { TMemoryPool pool(1024); TSkipList<int> list(pool); @@ -78,7 +78,7 @@ namespace NThreading { UNIT_ASSERT(!list.Contains(87654321)); } - Y_UNIT_TEST(ShouldIterateAllItems) { + Y_UNIT_TEST(ShouldIterateAllItems) { TMemoryPool pool(1024); TSkipList<int> list(pool); @@ -95,7 +95,7 @@ namespace NThreading { UNIT_ASSERT(!it.IsValid()); } - Y_UNIT_TEST(ShouldIterateAllItemsInReverseDirection) { + Y_UNIT_TEST(ShouldIterateAllItemsInReverseDirection) { TMemoryPool pool(1024); TSkipList<int> list(pool); @@ -112,7 +112,7 @@ namespace NThreading { UNIT_ASSERT(!it.IsValid()); } - Y_UNIT_TEST(ShouldSeekToFirstItem) { + Y_UNIT_TEST(ShouldSeekToFirstItem) { TMemoryPool pool(1024); TSkipList<int> list(pool); @@ -125,7 +125,7 @@ namespace NThreading { UNIT_ASSERT_EQUAL(it.GetValue(), 1); } - Y_UNIT_TEST(ShouldSeekToLastItem) { + Y_UNIT_TEST(ShouldSeekToLastItem) { TMemoryPool pool(1024); TSkipList<int> list(pool); @@ -138,7 +138,7 @@ namespace NThreading { UNIT_ASSERT_EQUAL(it.GetValue(), 9); } - Y_UNIT_TEST(ShouldSeekToExistingItem) { + Y_UNIT_TEST(ShouldSeekToExistingItem) { TMemoryPool pool(1024); TSkipList<int> list(pool); @@ -148,7 +148,7 @@ namespace NThreading { UNIT_ASSERT(it.IsValid()); } - Y_UNIT_TEST(ShouldSeekAfterMissedItem) { + Y_UNIT_TEST(ShouldSeekAfterMissedItem) { TMemoryPool pool(1024); TSkipList<int> list(pool); @@ -164,7 +164,7 @@ namespace NThreading { UNIT_ASSERT_EQUAL(it.GetValue(), 100); } - Y_UNIT_TEST(ShouldCallDtorsOfNonPodTypes) { + Y_UNIT_TEST(ShouldCallDtorsOfNonPodTypes) { UNIT_ASSERT(!TTypeTraits<TTestObject>::IsPod); UNIT_ASSERT_EQUAL(TTestObject::Count, 0); diff --git a/library/cpp/threading/task_scheduler/task_scheduler.cpp b/library/cpp/threading/task_scheduler/task_scheduler.cpp index 174dde4bf75..95bd27d7cf3 100644 --- a/library/cpp/threading/task_scheduler/task_scheduler.cpp +++ b/library/cpp/threading/task_scheduler/task_scheduler.cpp @@ -2,7 +2,7 @@ #include <util/system/thread.h> #include <util/string/cast.h> -#include <util/stream/output.h> +#include <util/stream/output.h> TTaskScheduler::ITask::~ITask() {} TTaskScheduler::IRepeatedTask::~IRepeatedTask() {} @@ -10,7 +10,7 @@ TTaskScheduler::IRepeatedTask::~IRepeatedTask() {} class TTaskScheduler::TWorkerThread - : public ISimpleThread + : public ISimpleThread { public: TWorkerThread(TTaskScheduler& state) @@ -152,8 +152,8 @@ const bool debugOutput = false; void TTaskScheduler::ChangeDebugState(TWorkerThread* thread, const TString& state) { if (!debugOutput) { - Y_UNUSED(thread); - Y_UNUSED(state); + Y_UNUSED(thread); + Y_UNUSED(state); return; } diff --git a/library/cpp/threading/task_scheduler/task_scheduler_ut.cpp b/library/cpp/threading/task_scheduler/task_scheduler_ut.cpp index 3b5203194a3..8f21984b779 100644 --- a/library/cpp/threading/task_scheduler/task_scheduler_ut.cpp +++ b/library/cpp/threading/task_scheduler/task_scheduler_ut.cpp @@ -1,7 +1,7 @@ #include <algorithm> #include <library/cpp/testing/unittest/registar.h> -#include <util/stream/output.h> +#include <util/stream/output.h> #include <util/system/atomic.h> #include <util/generic/vector.h> diff --git a/library/cpp/timezone_conversion/README.md b/library/cpp/timezone_conversion/README.md index 828f1880bc9..66ee7ca4403 100644 --- a/library/cpp/timezone_conversion/README.md +++ b/library/cpp/timezone_conversion/README.md @@ -1,16 +1,16 @@ -A library for translating between absolute times (i.e., `TInstant`) and civil times (i.e., -`NDatetime::TSimpleTM`) using the rules defined by a time zone (i.e., `NDatetime::TTimeZone`). +A library for translating between absolute times (i.e., `TInstant`) and civil times (i.e., +`NDatetime::TSimpleTM`) using the rules defined by a time zone (i.e., `NDatetime::TTimeZone`). -(the terms `absolute` and `civil` come from [cctz#fundamental-concepts][cctz-fundamental-concepts]) +(the terms `absolute` and `civil` come from [cctz#fundamental-concepts][cctz-fundamental-concepts]) -This is basically a wrapper around [CCTZ][cctz] with one important change: the time zone database is -in Arcadia and is compiled with the library (which means your executable will end up ~2MB larger). - -See [contrib/libs/cctz/README][update] if you think zone database is outdated. +This is basically a wrapper around [CCTZ][cctz] with one important change: the time zone database is +in Arcadia and is compiled with the library (which means your executable will end up ~2MB larger). +See [contrib/libs/cctz/README][update] if you think zone database is outdated. + Quick start: ============ -``` +``` #include <library/cpp/timezone_conversion/convert.h> // NDatetime::{GetLocalTimeZone(),GetUtcTimeZone()} are also available. @@ -20,8 +20,8 @@ NDatetime::TSimpleTM civil = NDatetime::ToCivilTime(now, msk); Cout << "Local time in Moscow is " << civil.ToString() << Endl; TInstant absolute = NDatetime::ToAbsoluteTime(civil, msk); Cout << "The current UNIX time is " << absolute.Seconds() << Endl; -``` - -[cctz-fundamental-concepts]: https://github.com/google/cctz#fundamental-concepts -[cctz]: https://github.com/google/cctz -[update]: https://a.yandex-team.ru/arc/trunk/arcadia/contrib/libs/cctz/tzdata/README?rev=2286180 +``` + +[cctz-fundamental-concepts]: https://github.com/google/cctz#fundamental-concepts +[cctz]: https://github.com/google/cctz +[update]: https://a.yandex-team.ru/arc/trunk/arcadia/contrib/libs/cctz/tzdata/README?rev=2286180 diff --git a/library/cpp/timezone_conversion/civil.cpp b/library/cpp/timezone_conversion/civil.cpp index 5986318b9a8..4d3d0454d1c 100644 --- a/library/cpp/timezone_conversion/civil.cpp +++ b/library/cpp/timezone_conversion/civil.cpp @@ -176,37 +176,37 @@ namespace NDatetime { } template <> -void Out<NDatetime::TCivilYear>(IOutputStream& out, const NDatetime::TCivilYear& y) { +void Out<NDatetime::TCivilYear>(IOutputStream& out, const NDatetime::TCivilYear& y) { out << y.year(); } template <> -void Out<NDatetime::TCivilMonth>(IOutputStream& out, const NDatetime::TCivilMonth& m) { +void Out<NDatetime::TCivilMonth>(IOutputStream& out, const NDatetime::TCivilMonth& m) { out << NDatetime::TCivilYear(m) << '-' << LeftPad(m.month(), 2, '0'); } template <> -void Out<NDatetime::TCivilDay>(IOutputStream& out, const NDatetime::TCivilDay& d) { +void Out<NDatetime::TCivilDay>(IOutputStream& out, const NDatetime::TCivilDay& d) { out << NDatetime::TCivilMonth(d) << '-' << LeftPad(d.day(), 2, '0'); } template <> -void Out<NDatetime::TCivilHour>(IOutputStream& out, const NDatetime::TCivilHour& h) { +void Out<NDatetime::TCivilHour>(IOutputStream& out, const NDatetime::TCivilHour& h) { out << NDatetime::TCivilDay(h) << 'T' << LeftPad(h.hour(), 2, '0'); } template <> -void Out<NDatetime::TCivilMinute>(IOutputStream& out, const NDatetime::TCivilMinute& m) { +void Out<NDatetime::TCivilMinute>(IOutputStream& out, const NDatetime::TCivilMinute& m) { out << NDatetime::TCivilHour(m) << ':' << LeftPad(m.minute(), 2, '0'); } template <> -void Out<NDatetime::TCivilSecond>(IOutputStream& out, const NDatetime::TCivilSecond& s) { +void Out<NDatetime::TCivilSecond>(IOutputStream& out, const NDatetime::TCivilSecond& s) { out << NDatetime::TCivilMinute(s) << ':' << LeftPad(s.second(), 2, '0'); } template <> -void Out<NDatetime::TWeekday>(IOutputStream& out, NDatetime::TWeekday wd) { +void Out<NDatetime::TWeekday>(IOutputStream& out, NDatetime::TWeekday wd) { using namespace cctz; switch (wd) { case weekday::monday: diff --git a/library/cpp/timezone_conversion/ut/civil_ut.cpp b/library/cpp/timezone_conversion/ut/civil_ut.cpp index a21bd4bd7df..4f46dbb91fd 100644 --- a/library/cpp/timezone_conversion/ut/civil_ut.cpp +++ b/library/cpp/timezone_conversion/ut/civil_ut.cpp @@ -15,20 +15,20 @@ inline void Out<NDatetime::TCivilDiff>(IOutputStream& out, const NDatetime::TCiv out << "(" << diff.Value << "," << diff.Unit << ")"; } -Y_UNIT_TEST_SUITE(DateTime) { - Y_UNIT_TEST(Calc) { +Y_UNIT_TEST_SUITE(DateTime) { + Y_UNIT_TEST(Calc) { NDatetime::TCivilSecond s(2017, 2, 1, 10, 12, 9); UNIT_ASSERT_VALUES_EQUAL(NDatetime::Calc<NDatetime::TCivilDay>(s, 2), NDatetime::TCivilDay(2017, 2, 3)); UNIT_ASSERT_VALUES_EQUAL(NDatetime::Calc<NDatetime::TCivilDay>(s, -2), NDatetime::TCivilDay(2017, 1, 30)); } - Y_UNIT_TEST(Adds) { + Y_UNIT_TEST(Adds) { NDatetime::TCivilSecond s(2017, 2, 1, 10, 12, 9); UNIT_ASSERT_VALUES_EQUAL(NDatetime::AddDays(s, 2), NDatetime::TCivilSecond(2017, 2, 3, 10, 12, 9)); UNIT_ASSERT_VALUES_EQUAL(NDatetime::AddMonths(s, -2), NDatetime::TCivilSecond(2016, 12, 1, 10, 12, 9)); UNIT_ASSERT_VALUES_EQUAL(NDatetime::AddYears(s, -55), NDatetime::TCivilSecond(1962, 2, 1, 10, 12, 9)); UNIT_ASSERT_VALUES_EQUAL(NDatetime::AddHours(s, 40), NDatetime::TCivilSecond(2017, 2, 3, 2, 12, 9)); } - Y_UNIT_TEST(Convert) { + Y_UNIT_TEST(Convert) { TInstant absTime = TInstant::Seconds(1500299239); NDatetime::TTimeZone lax = NDatetime::GetTimeZone("America/Los_Angeles"); NDatetime::TCivilSecond dt1 = NDatetime::Convert(absTime, lax); @@ -66,13 +66,13 @@ Y_UNIT_TEST_SUITE(DateTime) { UNIT_ASSERT_EXCEPTION(NDatetime::GetTimeZone("UTC+20:60"), NDatetime::TInvalidTimezone); UNIT_ASSERT_EXCEPTION(NDatetime::GetTimeZone("UTC+20:30:"), NDatetime::TInvalidTimezone); } - Y_UNIT_TEST(Format) { + Y_UNIT_TEST(Format) { NDatetime::TTimeZone lax = NDatetime::GetTimeZone("America/Los_Angeles"); NDatetime::TCivilSecond tp(2013, 1, 2, 3, 4, 5); UNIT_ASSERT_VALUES_EQUAL(NDatetime::Format("%H:%M:%S", tp, lax), "03:04:05"); UNIT_ASSERT_VALUES_EQUAL(NDatetime::Format("%H:%M:%E3S", tp, lax), "03:04:05.000"); } - Y_UNIT_TEST(Weekday) { + Y_UNIT_TEST(Weekday) { NDatetime::TCivilDay d(2013, 1, 2); NDatetime::TWeekday wd = NDatetime::GetWeekday(d); UNIT_ASSERT_VALUES_EQUAL(wd, NDatetime::TWeekday::wednesday); @@ -82,7 +82,7 @@ Y_UNIT_TEST_SUITE(DateTime) { UNIT_ASSERT_VALUES_EQUAL(NDatetime::WeekdayOnTheWeek(d, NDatetime::TWeekday::wednesday), NDatetime::TCivilDay(2013, 1, 2)); UNIT_ASSERT_VALUES_EQUAL(NDatetime::WeekdayOnTheWeek(d, NDatetime::TWeekday::friday), NDatetime::TCivilDay(2013, 1, 4)); } - Y_UNIT_TEST(CivilUnit) { + Y_UNIT_TEST(CivilUnit) { using namespace NDatetime; UNIT_ASSERT_VALUES_EQUAL(GetCivilUnit<TCivilMonth>(), ECivilUnit::Month); diff --git a/library/cpp/timezone_conversion/ut/convert_ut.cpp b/library/cpp/timezone_conversion/ut/convert_ut.cpp index bbf9e9b8263..cf25cbaefed 100644 --- a/library/cpp/timezone_conversion/ut/convert_ut.cpp +++ b/library/cpp/timezone_conversion/ut/convert_ut.cpp @@ -4,7 +4,7 @@ using namespace NDatetime; template <> -void Out<TSimpleTM>(IOutputStream& os, TTypeTraits<TSimpleTM>::TFuncParam value) { +void Out<TSimpleTM>(IOutputStream& os, TTypeTraits<TSimpleTM>::TFuncParam value) { os << value.ToString() << ", dst: " << int(value.IsDst); } diff --git a/library/cpp/tld/tld_ut.cpp b/library/cpp/tld/tld_ut.cpp index 733200f2b55..ee4c1541d8a 100644 --- a/library/cpp/tld/tld_ut.cpp +++ b/library/cpp/tld/tld_ut.cpp @@ -6,8 +6,8 @@ using namespace NTld; -Y_UNIT_TEST_SUITE(TTldTest) { - Y_UNIT_TEST(TestFindTld) { +Y_UNIT_TEST_SUITE(TTldTest) { + Y_UNIT_TEST(TestFindTld) { UNIT_ASSERT(FindTld("yandex.ru") == "ru"); UNIT_ASSERT(FindTld("YandeX.Ru") == "Ru"); UNIT_ASSERT(FindTld("yandex.com.tr") == "tr"); @@ -22,7 +22,7 @@ Y_UNIT_TEST_SUITE(TTldTest) { UNIT_ASSERT(FindTld("") == ""); } - Y_UNIT_TEST(TestTLDs) { + Y_UNIT_TEST(TestTLDs) { UNIT_ASSERT(IsTld("ru")); UNIT_ASSERT(IsTld("Ru")); UNIT_ASSERT(IsTld("BMW")); @@ -37,7 +37,7 @@ Y_UNIT_TEST_SUITE(TTldTest) { UNIT_ASSERT(!InTld("ru.xn")); } - Y_UNIT_TEST(TestVeryGoodTlds) { + Y_UNIT_TEST(TestVeryGoodTlds) { UNIT_ASSERT(IsVeryGoodTld("ru")); UNIT_ASSERT(IsVeryGoodTld("Ru")); UNIT_ASSERT(!IsVeryGoodTld("BMW")); diff --git a/library/cpp/tvmauth/client/ut/checker_ut.cpp b/library/cpp/tvmauth/client/ut/checker_ut.cpp index 54a25974c14..bec6fb1ec76 100644 --- a/library/cpp/tvmauth/client/ut/checker_ut.cpp +++ b/library/cpp/tvmauth/client/ut/checker_ut.cpp @@ -11,7 +11,7 @@ using namespace NTvmAuth; -Y_UNIT_TEST_SUITE(ClientChecker) { +Y_UNIT_TEST_SUITE(ClientChecker) { static const TTvmId OK_CLIENT = 100500; static const TString PROD_TICKET = "3:user:CAsQ__________9_Gg4KAgh7EHsg0oXYzAQoAA:N8PvrDNLh-5JywinxJntLeQGDEHBUxfzjuvB8-_BEUv1x9CALU7do8irDlDYVeVVDr4AIpR087YPZVzWPAqmnBuRJS0tJXekmDDvrivLnbRrzY4IUXZ_fImB0fJhTyVetKv6RD11bGqnAJeDpIukBwPTbJc_EMvKDt8V490CJFw"; static const TString TEST_TICKET = "3:user:CA0Q__________9_Gg4KAgh7EHsg0oXYzAQoAQ:FSADps3wNGm92Vyb1E9IVq5M6ZygdGdt1vafWWEhfDDeCLoVA-sJesxMl2pGW4OxJ8J1r_MfpG3ZoBk8rLVMHUFrPa6HheTbeXFAWl8quEniauXvKQe4VyrpA1SPgtRoFqi5upSDIJzEAe1YRJjq1EClQ_slMt8R0kA_JjKUX54"; @@ -20,7 +20,7 @@ Y_UNIT_TEST_SUITE(ClientChecker) { static const TString STRESS_TICKET = "3:user:CA8Q__________9_Gg4KAgh7EHsg0oXYzAQoBA:GBuG_TLo6SL2OYFxp7Zly04HPNzmAF7Fu2E8E9SnwQDoxq9rf7VThSPtTmnBSAl5UVRRPkMsRtzzHZ87qtj6l-PvF0K7PrDu7-yS_xiFTgAl9sEfXAIHJVzZLoksGRgpoBtpBUg9vVaJsPns0kWFKJgq8M-Mk9agrSk7sb2VUeQ"; static const TString SRV_TICKET = "3:serv:CBAQ__________9_IgYIexCUkQY:GioCM49Ob6_f80y6FY0XBVN4hLXuMlFeyMvIMiDuQnZkbkLpRpQOuQo5YjWoBjM0Vf-XqOm8B7xtrvxSYHDD7Q4OatN2l-Iwg7i71lE3scUeD36x47st3nd0OThvtjrFx_D8mw_c0GT5KcniZlqq1SjhLyAk1b_zJsx8viRAhCU"; - Y_UNIT_TEST(User) { + Y_UNIT_TEST(User) { NTvmApi::TClientSettings s; s.SetSelfTvmId(OK_CLIENT); s.EnableServiceTicketChecking(); @@ -103,7 +103,7 @@ Y_UNIT_TEST_SUITE(ClientChecker) { } } - Y_UNIT_TEST(Service) { + Y_UNIT_TEST(Service) { NTvmApi::TClientSettings s; s.EnableUserTicketChecking(EBlackboxEnv::Stress); s.SetSelfTvmId(OK_CLIENT); @@ -140,7 +140,7 @@ Y_UNIT_TEST_SUITE(ClientChecker) { UNIT_ASSERT_C(l->Stream.Str().find("was successfully fetched") == TString::npos, l->Stream.Str()); } - Y_UNIT_TEST(Tickets) { + Y_UNIT_TEST(Tickets) { NTvmApi::TClientSettings s; s.SetSelfTvmId(OK_CLIENT); s.EnableServiceTicketsFetchOptions("qwerty", {{"blackbox", 19}}); diff --git a/library/cpp/tvmauth/client/ut/disk_cache_ut.cpp b/library/cpp/tvmauth/client/ut/disk_cache_ut.cpp index 7dd851c9b30..48f4877a52e 100644 --- a/library/cpp/tvmauth/client/ut/disk_cache_ut.cpp +++ b/library/cpp/tvmauth/client/ut/disk_cache_ut.cpp @@ -16,15 +16,15 @@ using namespace NTvmAuth; -Y_UNIT_TEST_SUITE(ClientDisk) { - Y_UNIT_TEST(Hash) { +Y_UNIT_TEST_SUITE(ClientDisk) { + Y_UNIT_TEST(Hash) { TString hash = TDiskReader::GetHash("asd"); UNIT_ASSERT(hash); UNIT_ASSERT_VALUES_EQUAL(32, hash.size()); UNIT_ASSERT_VALUES_EQUAL("Zj5_qYg31bPlqjBW76z8IV0rCsHmv-iN-McV6ybS1-g", NUtils::Bin2base64url(hash)); } - Y_UNIT_TEST(Timestamp) { + Y_UNIT_TEST(Timestamp) { time_t t = 100500; TString s = TDiskWriter::WriteTimestamp(t); @@ -44,7 +44,7 @@ Y_UNIT_TEST_SUITE(ClientDisk) { const TInstant TIME = TInstant::Seconds(100500); const TString DATA = "oiweuhn \n vw3ut hweoi uhgewproritjhwequtherwoiughfdsv 8ty34q01u 34 1=3"; - Y_UNIT_TEST(ParseData_Ok) { + Y_UNIT_TEST(ParseData_Ok) { TLogger l; const TInstant time = TInstant::Seconds(1523446554789); @@ -62,7 +62,7 @@ Y_UNIT_TEST_SUITE(ClientDisk) { l.Stream.Str()); } - Y_UNIT_TEST(ParseData_SmallFile) { + Y_UNIT_TEST(ParseData_SmallFile) { TLogger l; TString toFile = TDiskWriter::PrepareData(TIME, DATA); @@ -72,7 +72,7 @@ Y_UNIT_TEST_SUITE(ClientDisk) { l.Stream.Str()); } - Y_UNIT_TEST(ParseData_Changed) { + Y_UNIT_TEST(ParseData_Changed) { TLogger l; TString toFile = TDiskWriter::PrepareData(TIME, DATA); @@ -83,7 +83,7 @@ Y_UNIT_TEST_SUITE(ClientDisk) { l.Stream.Str()); } - Y_UNIT_TEST(Read_Ok) { + Y_UNIT_TEST(Read_Ok) { TLogger l; TDiskReader r(GetFilePath("ok.cache"), &l); @@ -93,7 +93,7 @@ Y_UNIT_TEST_SUITE(ClientDisk) { UNIT_ASSERT_C(l.Stream.Str().find("was successfully read") != TString::npos, l.Stream.Str()); } - Y_UNIT_TEST(Read_NoFile) { + Y_UNIT_TEST(Read_NoFile) { TLogger l; TDiskReader r("missing", &l); @@ -103,7 +103,7 @@ Y_UNIT_TEST_SUITE(ClientDisk) { } #ifdef _unix_ - Y_UNIT_TEST(Read_NoPermitions) { + Y_UNIT_TEST(Read_NoPermitions) { TLogger l; const TString path = GetWorkPath() + "/123"; @@ -121,7 +121,7 @@ Y_UNIT_TEST_SUITE(ClientDisk) { } #endif - Y_UNIT_TEST(Write_Ok) { + Y_UNIT_TEST(Write_Ok) { TLogger l; const TString path = "./tmp_file"; @@ -139,7 +139,7 @@ Y_UNIT_TEST_SUITE(ClientDisk) { NFs::Remove(path); } - Y_UNIT_TEST(Write_NoPermitions) { + Y_UNIT_TEST(Write_NoPermitions) { TLogger l; TDiskWriter w("/some_file", &l); diff --git a/library/cpp/tvmauth/client/ut/facade_ut.cpp b/library/cpp/tvmauth/client/ut/facade_ut.cpp index 62e8e6c731a..d839aa46692 100644 --- a/library/cpp/tvmauth/client/ut/facade_ut.cpp +++ b/library/cpp/tvmauth/client/ut/facade_ut.cpp @@ -9,7 +9,7 @@ using namespace NTvmAuth; -Y_UNIT_TEST_SUITE(ClientFacade) { +Y_UNIT_TEST_SUITE(ClientFacade) { static const TTvmId OK_CLIENT = 100500; static const TString SRV_TICKET_123 = "3:serv:CBAQ__________9_IgYIexCUkQY:GioCM49Ob6_f80y6FY0XBVN4hLXuMlFeyMvIMiDuQnZkbkLpRpQOuQo5YjWoBjM0Vf-XqOm8B7xtrvxSYHDD7Q4OatN2l-Iwg7i71lE3scUeD36x47st3nd0OThvtjrFx_D8mw_c0GT5KcniZlqq1SjhLyAk1b_zJsx8viRAhCU"; static const TString SRV_TICKET_456 = "3:serv:CBAQ__________9_IgcIyAMQlJEG:VrnqRhpoiDnJeAQbySJluJ1moQ5Kemic99iWzOrHLGfuh7iTw_xMT7KewRAmZMUwDKzE6otj7V86Xsnxbv5xZl8746wbvNcyUXu-nGWmbByZjO7xpSIcY07sISqEhP9n9C_yMSvqDP7ho_PRIfpGCDMXxKlFZ_BhBLLp0kHEvw4"; @@ -27,7 +27,7 @@ Y_UNIT_TEST_SUITE(ClientFacade) { return f; } - Y_UNIT_TEST(Service) { + Y_UNIT_TEST(Service) { NTvmApi::TClientSettings s; s.SetSelfTvmId(OK_CLIENT); s.EnableServiceTicketChecking(); @@ -44,7 +44,7 @@ Y_UNIT_TEST_SUITE(ClientFacade) { UNIT_ASSERT_EXCEPTION(f.CheckUserTicket(TEST_TICKET), yexception); } - Y_UNIT_TEST(User) { + Y_UNIT_TEST(User) { NTvmApi::TClientSettings s; s.EnableUserTicketChecking(EBlackboxEnv::Prod); s.SetDiskCacheDir(GetCachePath()); @@ -55,7 +55,7 @@ Y_UNIT_TEST_SUITE(ClientFacade) { UNIT_ASSERT(!f.CheckUserTicket(TEST_TICKET)); } - Y_UNIT_TEST(Ctors) { + Y_UNIT_TEST(Ctors) { NTvmApi::TClientSettings s; s.EnableUserTicketChecking(EBlackboxEnv::Prod); s.SetDiskCacheDir(GetCachePath()); @@ -68,7 +68,7 @@ Y_UNIT_TEST_SUITE(ClientFacade) { v.front() = std::move(*v.begin()); } - Y_UNIT_TEST(Tickets) { + Y_UNIT_TEST(Tickets) { NTvmApi::TClientSettings s; s.SetSelfTvmId(OK_CLIENT); s.EnableServiceTicketsFetchOptions("qwerty", {{"blackbox", 19}}); diff --git a/library/cpp/tvmauth/client/ut/logger_ut.cpp b/library/cpp/tvmauth/client/ut/logger_ut.cpp index 76236e8913b..eded8528df8 100644 --- a/library/cpp/tvmauth/client/ut/logger_ut.cpp +++ b/library/cpp/tvmauth/client/ut/logger_ut.cpp @@ -6,35 +6,35 @@ using namespace NTvmAuth; -Y_UNIT_TEST_SUITE(ClientLogger) { +Y_UNIT_TEST_SUITE(ClientLogger) { int i = 0; - Y_UNIT_TEST(Debug) { + Y_UNIT_TEST(Debug) { TLogger l; l.Debug("qwerty"); UNIT_ASSERT_VALUES_EQUAL("7: qwerty\n", l.Stream.Str()); } - Y_UNIT_TEST(Info) { + Y_UNIT_TEST(Info) { TLogger l; l.Info("qwerty"); UNIT_ASSERT_VALUES_EQUAL("6: qwerty\n", l.Stream.Str()); } - Y_UNIT_TEST(Warning) { + Y_UNIT_TEST(Warning) { TLogger l; l.Warning("qwerty"); UNIT_ASSERT_VALUES_EQUAL("4: qwerty\n", l.Stream.Str()); } - Y_UNIT_TEST(Error) { + Y_UNIT_TEST(Error) { TLogger l; l.Error("qwerty"); UNIT_ASSERT_VALUES_EQUAL("3: qwerty\n", l.Stream.Str()); } #ifdef _unix_ - Y_UNIT_TEST(Cerr_) { + Y_UNIT_TEST(Cerr_) { TCerrLogger l(5); l.Error("hit"); l.Debug("miss"); diff --git a/library/cpp/tvmauth/client/ut/settings_ut.cpp b/library/cpp/tvmauth/client/ut/settings_ut.cpp index 76c9542442e..47554dd73d9 100644 --- a/library/cpp/tvmauth/client/ut/settings_ut.cpp +++ b/library/cpp/tvmauth/client/ut/settings_ut.cpp @@ -6,7 +6,7 @@ using namespace NTvmAuth; -Y_UNIT_TEST_SUITE(ClientSettings) { +Y_UNIT_TEST_SUITE(ClientSettings) { #if !defined(_win_) Y_UNIT_TEST(CheckValid) { struct TTestCase { diff --git a/library/cpp/tvmauth/src/rw/ut/rw_ut.cpp b/library/cpp/tvmauth/src/rw/ut/rw_ut.cpp index 73f1b1d7691..94f58b33324 100644 --- a/library/cpp/tvmauth/src/rw/ut/rw_ut.cpp +++ b/library/cpp/tvmauth/src/rw/ut/rw_ut.cpp @@ -127,14 +127,14 @@ namespace NTvmAuth { } using namespace NTvmAuth; -Y_UNIT_TEST_SUITE(Rw) { - Y_UNIT_TEST(SignVerify) { +Y_UNIT_TEST_SUITE(Rw) { + Y_UNIT_TEST(SignVerify) { for (int i = 1; i < 10; ++i) { UNIT_ASSERT_VALUES_EQUAL(1, TestSignVerify()); } } - Y_UNIT_TEST(TKeysPriv) { + Y_UNIT_TEST(TKeysPriv) { NRw::TRwPrivateKey priv(Base64Decode("MIIEmwKCAQBwsRd4frsVARIVSfj_vCdfvA3Q9SsGhSybdBDhbm8L6rPqxdoSNLCdNXzDWj7Ppf0o8uWHMxC-5Lfw0I18ri68nhm9-ndixcnbn6ti1uetgkc28eiEP6Q8ILD_JmkynbUl1aKDNAa5XsK2vFSEX402uydRomsTn46kRY23hfqcIi0ohh5VxIrpclRsRZus0JFu-RJzhqTbKYV4y4dglWPGHh5BuTv9k_Oh0_Ra8Xp5Rith5vjaKZUQ5Hyh9UtBYTkNWdvXP9OpmbiLVeRLuMzBm4HEFHDwMZ1h6LSVP-wB_spJPaMLTn3Q3JIHe-wGBYRWzU51RRYDqv4O_H12w5C1AoGBALAwCQ7fdAPG1lGclL7iWFjUofwPCFwPyDjicDT_MRRu6_Ta4GjqOGO9zuOp0o_ePgvR-7nA0fbaspM4LZNrPZwmoYBCJMtKXetg68ylu2DO-RRSN2SSh1AIZSA_8UTABk69bPzNL31j4PyZWxrgZ3zP9uZvzggveuKt5ZhCMoB7AoGBAKO9oC2AZjLdh2RaEFotTL_dY6lVcm38VA6PnigB8gB_TMuSrd4xtRw5BxvHpOCnBcUAJE0dN4_DDe5mrotKYMD2_3_lcq9PaLZadrPDCSDL89wtoVxNQNAJTqFjBFXYNu4Ze63lrsqg45TF5XmVRemyBHzXw3erd0pJaeoUDaSPAoGAJhGoHx_nVw8sDoLzeRkOJ1_6-uh_wVmVr6407_LPjrrySEq-GiYu43M3-QDp8J_J9e3S1Rpm4nQX2bEf5Gx9n4wKz7Hp0cwkOqBOWhvrAu6YLpv59wslEtkx0LYcJy6yQk5mpU8l29rPO7b50NyLnfnE2za-9DyK038FKlr5VgICgYAUd7QFsAzGW7Dsi0ILRamX-6x1Kq5Nv4qB0fPFAD5AD-mZclW7xjajhyDjePScFOC4oASJo6bx-GG9zNXRaUwYHt_v_K5V6e0Wy07WeGEkGX57hbQriagaASnULGCKuwbdwy91vLXZVBxymLyvMqi9NkCPmvhu9W7pSS09QoG0kgKBgBYGASHb7oB42sozkpfcSwsalD-B4QuB-QccTgaf5iKN3X6bXA0dRwx3udx1OlH7x8F6P3c4Gj7bVlJnBbJtZ7OE1DAIRJlpS71sHXmUt2wZ3yKKRuySUOoBDKQH_iiYAMnXrZ-Zpe-sfB-TK2NcDO-Z_tzN-cEF71xVvLMIRlAPAoGAdeikZPh1O57RxnVY72asiMRZheMBhK-9uSNPyYEZv3bUnIjg4XdMYStF2yTHNu014XvkDSQTe-drv2BDs9ExKplM4xFOtDtPQQ3mMB3GoK1qVhM_9n1QEElreurMicahkalnPo6tU4Z6PFL7PTpjRnCN67lJp0J0fxNDL13YSagCgYBA9VJrMtPjzcAx5ZCIYJjrYUPqEG_ttQN2RJIHN3MVpdpLAMIgX3tnlfyLwQFVKK45D1JgFa_1HHcxTWGtdIX4nsIjPWt-cWCCCkkw9rM5_Iqcb-YLSood6IP2OK0w0XLD1STnFRy_BRwdjPbGOYmp6YrJDZAlajDkFSdRvsz9Vg=="), 0); NRw::TRwPrivateKey priv2(Base64Decode("MIIEnAKCAQEA4RATOfumLD1n6ICrW5biaAl9VldinczmkNPjpUWwc3gs8PnkCrtdnPFmpBwW3gjHdSNU1OuEg5A6K1o1xiGv9sU-jd88zQBOdK6E2zwnJnkK6bNusKE2H2CLqg3aMWCmTa9JbzSy1uO7wa-xCqqNUuCko-2lyv12HhL1ICIH951SHDa4qO1U5xZhhlUAnqWi9R4tYDeMiF41WdOjwT2fg8UkbusThmxa3yjCXjD7OyjshPtukN8Tl3UyGtV_s2CLnE3f28VAi-AVW8FtgL22xbGhuyEplXRrtF1E5oV7NSqxH1FS0SYROA8ffYQGV5tfx5WDFHiXDEP6BzoVfeBDRQKBgQDzidelKZNFMWar_yj-r_cniMkZXNaNVEQbMg1A401blGjkU1r-ufGH5mkdNx4IgEoCEYBTM834Z88fYV1lOVfdT0OqtiVoC9NkLu3xhQ1r9_r6RMaAenwsV7leH8jWMOKvhkB0KNI49oznTGDqLp0AbDbtP66xdNH4dr3rw3WFywKBgQDslDdv4sdnRKN27h2drhn4Pp_Lgw2U-6MfHiyjp6BKR8Qtlld3hdb-ZjU9F0h38DqECmFIEe35_flKfd7X21CBQs9EuKR8EdaF3OAgzA-TRWeQhyHmaV7Fas1RlNqZHm8lckaZT8dX9Ygsxn0I_vUbm9pkFivwGvQnnwNQ7Te5LwKBgCVMYOzLHW911l6EbCZE6XU2HUrTKEd1bdqWCgtxPEmDl3BZcXpnyKpqSHmlH1F7s65WBfejxDM2hjin3OnXSog_x35ql_-Azu93-79QAzbQc6Z13BuWPpQxV8iw4ijqRRhzjD2pcvXlIxgebp5-H0eDt-Md2Y8rkrzyhm8EH7mwAoGAHZKG7fxY7OiUbt3Ds7XDPwfT-XBhsp90Y-PFlHT0CUj4hbLK7vC638zGp6LpDv4HUIFMKQI9vz-_KU-72vtqEChZ6JcUj4I60LucBBmB8mis8hDkPM0r2K1ZqjKbUyPN5K5I0yn46v6xBZjPoR_eo3N7TILFfgNehPPgah2m9yYCgYAecTr0pTJopizVf-Uf1f7k8RkjK5rRqoiDZkGoHGmrco0cimtf1z4w_M0jpuPBEAlAQjAKZnm_DPnj7Cuspyr7qeh1VsStAXpshd2-MKGtfv9fSJjQD0-Fivcrw_kaxhxV8MgOhRpHHtGc6YwdRdOgDYbdp_XWLpo_Dte9eG6wuQKBgDzo0e8d8pTyvCP23825rVzvrSHBZkliGkCEu0iggDnfKOreejFhQN9JeBo8sYdQFCRBptEU6k4b5O6J3NQ1Sspiez15ddqmFMD4uhJY6VsV-JFnL9YhLqVd355xZCyU4b07mReU9-LuqK2m2chjxH_HDAgUoEvO_yzR9EDYqHbNAoGAf529Ah9HIT5aG6IGTlwQdk-M7guy63U4vj4uC7z98qgvFEsV6cr4miT6RE8Aw5yAeN5pW59rZNjBNr9i-8n8kouasho2xNMTPKP8YuSNg2PNNS5T1Ou56mgsBCY5i10TIHKNIm2RVSUgzJ97BMEOZY6jQRytFfwgYkvnFzbuA9c="), @@ -150,7 +150,7 @@ Y_UNIT_TEST_SUITE(Rw) { UNIT_ASSERT(!priv.SignTicket("").empty()); } - Y_UNIT_TEST(TKeysPub) { + Y_UNIT_TEST(TKeysPub) { NRw::TRwPublicKey pub(Base64Decode("MIIBBAKCAQBwsRd4frsVARIVSfj_vCdfvA3Q9SsGhSybdBDhbm8L6rPqxdoSNLCdNXzDWj7Ppf0o8uWHMxC-5Lfw0I18ri68nhm9-ndixcnbn6ti1uetgkc28eiEP6Q8ILD_JmkynbUl1aKDNAa5XsK2vFSEX402uydRomsTn46kRY23hfqcIi0ohh5VxIrpclRsRZus0JFu-RJzhqTbKYV4y4dglWPGHh5BuTv9k_Oh0_Ra8Xp5Rith5vjaKZUQ5Hyh9UtBYTkNWdvXP9OpmbiLVeRLuMzBm4HEFHDwMZ1h6LSVP-wB_spJPaMLTn3Q3JIHe-wGBYRWzU51RRYDqv4O_H12w5C1")); NRw::TRwPublicKey pub2(Base64Decode("MIIBBQKCAQEA4RATOfumLD1n6ICrW5biaAl9VldinczmkNPjpUWwc3gs8PnkCrtdnPFmpBwW3gjHdSNU1OuEg5A6K1o1xiGv9sU-jd88zQBOdK6E2zwnJnkK6bNusKE2H2CLqg3aMWCmTa9JbzSy1uO7wa-xCqqNUuCko-2lyv12HhL1ICIH951SHDa4qO1U5xZhhlUAnqWi9R4tYDeMiF41WdOjwT2fg8UkbusThmxa3yjCXjD7OyjshPtukN8Tl3UyGtV_s2CLnE3f28VAi-AVW8FtgL22xbGhuyEplXRrtF1E5oV7NSqxH1FS0SYROA8ffYQGV5tfx5WDFHiXDEP6BzoVfeBDRQ==")); NRw::TRwPublicKey pub3(Base64Decode("MIGDAoGAX23ZgkYAmRFEWrp9aGLebVMVbVQ4TR_pmt9iEcCSmoaUqWHRBV95M0-l4mGLvnFfMJ7qhF5FSb7QNuoM2FNKELu4ZS_Ug1idEFBYfoT7kVzletsMVK4ZDDYRiM18fL8d58clfFAoCo-_EEMowqQeBXnxa0zqsLyNGL2x1f-KDY0=")); @@ -161,7 +161,7 @@ Y_UNIT_TEST_SUITE(Rw) { UNIT_ASSERT(!pub.CheckSign("~~~", "~~~")); } - Y_UNIT_TEST(TKeys) { + Y_UNIT_TEST(TKeys) { NRw::TRwPrivateKey priv(Base64Decode("MIIEmwKCAQBwsRd4frsVARIVSfj_vCdfvA3Q9SsGhSybdBDhbm8L6rPqxdoSNLCdNXzDWj7Ppf0o8uWHMxC-5Lfw0I18ri68nhm9-ndixcnbn6ti1uetgkc28eiEP6Q8ILD_JmkynbUl1aKDNAa5XsK2vFSEX402uydRomsTn46kRY23hfqcIi0ohh5VxIrpclRsRZus0JFu-RJzhqTbKYV4y4dglWPGHh5BuTv9k_Oh0_Ra8Xp5Rith5vjaKZUQ5Hyh9UtBYTkNWdvXP9OpmbiLVeRLuMzBm4HEFHDwMZ1h6LSVP-wB_spJPaMLTn3Q3JIHe-wGBYRWzU51RRYDqv4O_H12w5C1AoGBALAwCQ7fdAPG1lGclL7iWFjUofwPCFwPyDjicDT_MRRu6_Ta4GjqOGO9zuOp0o_ePgvR-7nA0fbaspM4LZNrPZwmoYBCJMtKXetg68ylu2DO-RRSN2SSh1AIZSA_8UTABk69bPzNL31j4PyZWxrgZ3zP9uZvzggveuKt5ZhCMoB7AoGBAKO9oC2AZjLdh2RaEFotTL_dY6lVcm38VA6PnigB8gB_TMuSrd4xtRw5BxvHpOCnBcUAJE0dN4_DDe5mrotKYMD2_3_lcq9PaLZadrPDCSDL89wtoVxNQNAJTqFjBFXYNu4Ze63lrsqg45TF5XmVRemyBHzXw3erd0pJaeoUDaSPAoGAJhGoHx_nVw8sDoLzeRkOJ1_6-uh_wVmVr6407_LPjrrySEq-GiYu43M3-QDp8J_J9e3S1Rpm4nQX2bEf5Gx9n4wKz7Hp0cwkOqBOWhvrAu6YLpv59wslEtkx0LYcJy6yQk5mpU8l29rPO7b50NyLnfnE2za-9DyK038FKlr5VgICgYAUd7QFsAzGW7Dsi0ILRamX-6x1Kq5Nv4qB0fPFAD5AD-mZclW7xjajhyDjePScFOC4oASJo6bx-GG9zNXRaUwYHt_v_K5V6e0Wy07WeGEkGX57hbQriagaASnULGCKuwbdwy91vLXZVBxymLyvMqi9NkCPmvhu9W7pSS09QoG0kgKBgBYGASHb7oB42sozkpfcSwsalD-B4QuB-QccTgaf5iKN3X6bXA0dRwx3udx1OlH7x8F6P3c4Gj7bVlJnBbJtZ7OE1DAIRJlpS71sHXmUt2wZ3yKKRuySUOoBDKQH_iiYAMnXrZ-Zpe-sfB-TK2NcDO-Z_tzN-cEF71xVvLMIRlAPAoGAdeikZPh1O57RxnVY72asiMRZheMBhK-9uSNPyYEZv3bUnIjg4XdMYStF2yTHNu014XvkDSQTe-drv2BDs9ExKplM4xFOtDtPQQ3mMB3GoK1qVhM_9n1QEElreurMicahkalnPo6tU4Z6PFL7PTpjRnCN67lJp0J0fxNDL13YSagCgYBA9VJrMtPjzcAx5ZCIYJjrYUPqEG_ttQN2RJIHN3MVpdpLAMIgX3tnlfyLwQFVKK45D1JgFa_1HHcxTWGtdIX4nsIjPWt-cWCCCkkw9rM5_Iqcb-YLSood6IP2OK0w0XLD1STnFRy_BRwdjPbGOYmp6YrJDZAlajDkFSdRvsz9Vg=="), 0); NRw::TRwPublicKey pub(Base64Decode("MIIBBAKCAQBwsRd4frsVARIVSfj_vCdfvA3Q9SsGhSybdBDhbm8L6rPqxdoSNLCdNXzDWj7Ppf0o8uWHMxC-5Lfw0I18ri68nhm9-ndixcnbn6ti1uetgkc28eiEP6Q8ILD_JmkynbUl1aKDNAa5XsK2vFSEX402uydRomsTn46kRY23hfqcIi0ohh5VxIrpclRsRZus0JFu-RJzhqTbKYV4y4dglWPGHh5BuTv9k_Oh0_Ra8Xp5Rith5vjaKZUQ5Hyh9UtBYTkNWdvXP9OpmbiLVeRLuMzBm4HEFHDwMZ1h6LSVP-wB_spJPaMLTn3Q3JIHe-wGBYRWzU51RRYDqv4O_H12w5C1")); @@ -180,7 +180,7 @@ Y_UNIT_TEST_SUITE(Rw) { Base64Decode("FeMZtDP-yuoNqK2HYw3JxTV9v7p8IoQEuRMtuHddafh4bq1ZOeEqg7g7Su6M3iq_kN9DZ_fVhuhuVcbZmNYPIvJ8oL5DE80KI3d1Qbs9mS8_X4Oq2TJpZgNfFG-z_LPRZSNRP9Q8sQhlAoSZHOSZkBFcYj1EuqEp6nSSSbX8Ji4Se-TfhIh3YFQkr-Ivk_3NmSXhDXUaW7CHo2rVm58QJ2cgSEuxzBH-Q8E8tGDCEmk4p3_iot9XY8RRN-_j0yi15etmXCUIKFbpDogtHdT8CyAEVHMYvsLqkLux9pzy3RdvNQmoPjol3wIm-H0wMtF_pMw4G2QLNev6he6xWeckxw=="))); } - Y_UNIT_TEST(Keygen) { + Y_UNIT_TEST(Keygen) { for (size_t idx = 0; idx < 100; ++idx) { NRw::TKeyPair pair = NRw::GenKeyPair(1024); NRw::TRwPrivateKey priv(pair.Private, 0); diff --git a/library/cpp/tvmauth/src/ut/parser_ut.cpp b/library/cpp/tvmauth/src/ut/parser_ut.cpp index 530f45331a2..e5c892c6d9c 100644 --- a/library/cpp/tvmauth/src/ut/parser_ut.cpp +++ b/library/cpp/tvmauth/src/ut/parser_ut.cpp @@ -6,10 +6,10 @@ #include <library/cpp/testing/unittest/registar.h> -Y_UNIT_TEST_SUITE(ParserTestSuite) { +Y_UNIT_TEST_SUITE(ParserTestSuite) { using namespace NTvmAuth; - Y_UNIT_TEST(Keys) { + Y_UNIT_TEST(Keys) { UNIT_ASSERT_EXCEPTION(TParserTvmKeys::ParseStrV1("2:asds"), TMalformedTvmKeysException); UNIT_ASSERT_EXCEPTION(TParserTvmKeys::ParseStrV1("3:asds"), TMalformedTvmKeysException); UNIT_ASSERT_EXCEPTION(TParserTvmKeys::ParseStrV1("1:+a/sds"), TMalformedTvmKeysException); @@ -17,7 +17,7 @@ Y_UNIT_TEST_SUITE(ParserTestSuite) { UNIT_ASSERT_VALUES_EQUAL("sdsd", NUtils::Bin2base64url(TParserTvmKeys::ParseStrV1("1:sdsd"))); } - Y_UNIT_TEST(TicketsStrV3) { + Y_UNIT_TEST(TicketsStrV3) { UNIT_ASSERT_EQUAL(TParserTickets::TStrRes({ETicketStatus::Ok, NUtils::Base64url2bin("CgYIDRCUkQYQDBgcIgdiYjpzZXNzIghiYjpzZXNzMg"), NUtils::Base64url2bin("ERmeH_yzC7K_QsoHTyw7llCsyExEz3CoEopPIuivA0ZAtTaFq_Pa0l9Fhhx_NX9WpOp2CPyY5cFc4PXhcO83jCB7-EGvHNxGN-j2NQalERzPiKqkDCO0Q5etLzSzrfTlvMz7sXDvELNBHyA0PkAQnbz4supY0l-0Q6JBYSEF3zOVMjjE-HeQIFL3ats3_PakaUMWRvgQQ88pVdYZqAtbDw9PlTla7ommygVZQjcfNFXV1pJKRgOCLs-YyCjOJHLKL04zYj0X6KsOCTUeqhj7ml96wLZ-g1X9tyOR2WAr2Ctq7wIEHwqhxOLgOSKqm05xH6Vi3E_hekf50oe2jPfKEA"), @@ -88,7 +88,7 @@ Y_UNIT_TEST_SUITE(ParserTestSuite) { TParserTickets::ServiceFlag())); } - Y_UNIT_TEST(TicketsV3) { + Y_UNIT_TEST(TicketsV3) { NRw::TPublicKeys pub; UNIT_ASSERT_EQUAL(ETicketStatus::Malformed, diff --git a/library/cpp/tvmauth/src/ut/public_ut.cpp b/library/cpp/tvmauth/src/ut/public_ut.cpp index 74a483d57bd..ffecee5b475 100644 --- a/library/cpp/tvmauth/src/ut/public_ut.cpp +++ b/library/cpp/tvmauth/src/ut/public_ut.cpp @@ -10,8 +10,8 @@ using namespace NTvmAuth; -Y_UNIT_TEST_SUITE(CommonPublicInterfaceTestSuite){ - Y_UNIT_TEST(StatusTest){ +Y_UNIT_TEST_SUITE(CommonPublicInterfaceTestSuite){ + Y_UNIT_TEST(StatusTest){ UNIT_ASSERT_VALUES_EQUAL("OK", StatusToString(ETicketStatus::Ok)); UNIT_ASSERT_VALUES_EQUAL("Expired ticket", @@ -33,7 +33,7 @@ Y_UNIT_TEST_SUITE(CommonPublicInterfaceTestSuite){ } } -Y_UNIT_TEST_SUITE(PublicInterfaceServiceTestSuite) { +Y_UNIT_TEST_SUITE(PublicInterfaceServiceTestSuite) { static const TString EMPTY_TVM_KEYS = "1:CpgCCpMCCAEQABqIAjCCAQQCggEAcLEXeH67FQESFUn4_7wnX7wN0PUrBoUsm3QQ4W5vC-qz6sXaEjSwnTV8w1o-z6X9KPLlhzMQvuS38NCNfK4uvJ4Zvfp3YsXJ25-rYtbnrYJHNvHohD-kPCCw_yZpMp21JdWigzQGuV7CtrxUhF-NNrsnUaJrE5-OpEWNt4X6nCItKIYeVcSK6XJUbEWbrNCRbvkSc4ak2ymFeMuHYJVjxh4eQbk7_ZPzodP0WvF6eUYrYeb42imVEOR8ofVLQWE5DVnb1z_TqZm4i1XkS7jMwZuBxBRw8DGdYei0lT_sAf7KST2jC0590NySB3vsBgWEVs1OdUUWA6r-Dvx9dsOQtSCVkQYQAAqZAgqUAggCEAAaiQIwggEFAoIBAQDhEBM5-6YsPWfogKtbluJoCX1WV2KdzOaQ0-OlRbBzeCzw-eQKu12c8WakHBbeCMd1I1TU64SDkDorWjXGIa_2xT6N3zzNAE50roTbPCcmeQrps26woTYfYIuqDdoxYKZNr0lvNLLW47vBr7EKqo1S4KSj7aXK_XYeEvUgIgf3nVIcNrio7VTnFmGGVQCepaL1Hi1gN4yIXjVZ06PBPZ-DxSRu6xOGbFrfKMJeMPs7KOyE-26Q3xOXdTIa1X-zYIucTd_bxUCL4BVbwW2AvbbFsaG7ISmVdGu0XUTmhXs1KrEfUVLRJhE4Dx99hAZXm1_HlYMUeJcMQ_oHOhV94ENFIJaRBhACCpYBCpEBCAMQABqGATCBgwKBgF9t2YJGAJkRRFq6fWhi3m1TFW1UOE0f6ZrfYhHAkpqGlKlh0QVfeTNPpeJhi75xXzCe6oReRUm-0DbqDNhTShC7uGUv1INYnRBQWH6E-5Fc5XrbDFSuGQw2EYjNfHy_HefHJXxQKAqPvxBDKMKkHgV58WtM6rC8jRi9sdX_ig2NIJeRBhABCpYBCpEBCAQQABqGATCBgwKBgGB4d6eLGUBv-Q6EPLehC4S-yuE2HB-_rJ7WkeYwyp-xIPolPrd-PQme2utHB4ZgpXHIu_OFksDe_0bPgZniNRSVRbl7W49DgS5Ya3kMfrYB4DnF5Fta5tn1oV6EwxYD4JONpFTenOJALPGTPawxXEfon_peiHOSBuQMu3_Vn-l1IJiRBhADCpcBCpIBCAUQABqHATCBhAKBgQCTJMKIfmfeZpaI7Q9rnsc29gdWawK7TnpVKRHws1iY7EUlYROeVcMdAwEqVM6f8BVCKLGgzQ7Gar_uuxfUGKwqEQzoppDraw4F75J464-7D5f6_oJQuGIBHZxqbMONtLjBCXRUhQW5szBLmTQ_R3qaJb5vf-h0APZfkYhq1cTttSCZkQYQBAqWAQqRAQgLEAAahgEwgYMCgYBvvGVH_M2H8qxxv94yaDYUTWbRnJ1uiIYc59KIQlfFimMPhSS7x2tqUa2-hI55JiII0Xym6GNkwLhyc1xtWChpVuIdSnbvttbrt4weDMLHqTwNOF6qAsVKGKT1Yh8yf-qb-DSmicgvFc74mBQm_6gAY1iQsf33YX8578ClhKBWHSCVkQYQAAqXAQqSAQgMEAAahwEwgYQCgYEAkuzFcd5TJu7lYWYe2hQLFfUWIIj91BvQQLa_Thln4YtGCO8gG1KJqJm-YlmJOWQG0B7H_5RVhxUxV9KpmFnsDVkzUFKOsCBaYGXc12xPVioawUlAwp5qp3QQtZyx_se97YIoLzuLr46UkLcLnkIrp-Jo46QzYi_QHq45WTm8MQ0glpEGEAIKlwEKkgEIDRAAGocBMIGEAoGBAIUzbxOknXf_rNt17_ir8JlWvrtnCWsQd1MAnl5mgArvavDtKeBYHzi5_Ak7DHlLzuA6YE8W175FxLFKpN2hkz-l-M7ltUSd8N1BvJRhK4t6WffWfC_1wPyoAbeSN2Yb1jygtZJQ8wGoXHcJQUXiMit3eFNyylwsJFj1gzAR4JCdIJeRBhABCpYBCpEBCA4QABqGATCBgwKBgFMcbEpl9ukVR6AO_R6sMyiU11I8b8MBSUCEC15iKsrVO8v_m47_TRRjWPYtQ9eZ7o1ocNJHaGUU7qqInFqtFaVnIceP6NmCsXhjs3MLrWPS8IRAy4Zf4FKmGOx3N9O2vemjUygZ9vUiSkULdVrecinRaT8JQ5RG4bUMY04XGIwFIJiRBhADCpYBCpEBCA8QABqGATCBgwKBgGpCkW-NR3li8GlRvqpq2YZGSIgm_PTyDI2Zwfw69grsBmPpVFW48Vw7xoMN35zcrojEpialB_uQzlpLYOvsMl634CRIuj-n1QE3-gaZTTTE8mg-AR4mcxnTKThPnRQpbuOlYAnriwiasWiQEMbGjq_HmWioYYxFo9USlklQn4-9IJmRBhAE"; static const TString EXPIRED_SERVICE_TICKET = "3:serv:CBAQACIZCOUBEBwaCGJiOnNlc3MxGghiYjpzZXNzMg:IwfMNJYEqStY_SixwqJnyHOMCPR7-3HHk4uylB2oVRkthtezq-OOA7QizDvx7VABLs_iTlXuD1r5IjufNei_EiV145eaa3HIg4xCdJXCojMexf2UYJz8mF2b0YzFAy6_KWagU7xo13CyKAqzJuQf5MJcSUf0ecY9hVh36cJ51aw"; static const TString MALFORMED_TVM_KEYS = "1:CpgCCpMCCAEQABqIAjCCAQQCggEAcLEXeH67FQESFUn4_7wnX7wN0PUrBoUsm3QQ4W5vC-qz6sXaEjSwnTV8w1o-z6X9KPLlhzMQvuS38NCNfK4uvJ4Zvfp3YsXJ25-rYtbnrYJHNvHohD-kPCCw_yZpMp21JdWigzQGuV7CtrxUhF-NNrsnUaJrE5-OpEWNt4X6nCItKIYeVcSK6XJUbEWbrNCRbvkSc4ak2ymFeMuHYJVjxh4eQbk7_ZPzodP0WvF6eUYrYeb42imVEOR8ofVLQWE5DVnb1z_TqZm4i1XkS7jMwZuBxBRw8DGdYei0lT_sAf7KST2jC0590NySB3vsBgWEVs1OdUUWA6r-Dvx9dsOQtSCVkQYQAAqZAgqUAggCEAAaiQIwggEFAoIBAQDhEBM5-6YsPWfogKtbluJoCX1WV2KdzOaQ0-OlRbBzeCzw-eQKu12c8WakHBbeCMd1I1TU64SDkDorWjXGIa_2xT6N3zzNAE50roTbPCcmeQrps26woTYfYIuqDdoxYKZNr0lvNLLW47vBr7EKqo1S4KSj7aXK_XYeEvUgIgf3nVIcNrio7VTnFmGGVQCepaL1Hi1gN4yIXjVZ06PBPZ-DxSRu6xOGbFrfKMJeMPs7KOyE-26Q3xOXdTIa1X-zYIucTd_bxUCL4BVbwW2AvbbFsaG7ISmVdGu0XUTmhXs1KrEfUVLRJhE4Dx99hAZXm1_HlYMUeJcMQ_oHOhV94ENFIJaRBhACCpYBCpEBCAMQABqGATCBgwKBgF9t2YJGAJkRRFq6fWhi3m1TFW1UOE0f6ZrfYhHAkpqGlKlh0QVfeTNPpeJhi75xXzCe6oReRUm-0DbqDNhTShC7uGUv1INYnRBQWH6E-5Fc5XrbDFSuGQw2EYjNfHy_HefHJXxQKAqPvxBDKMKkHgV58WtM6rC8jRi9sdX_ig2NIJeRBhABCpYBCpEBCAQQABqGATCBgwKBgGB4d6eLGUBv-Q6EPLehC4S-yuE2HB-_rJ7WkeYwyp-xIPolPrd-PQme2utHB4ZgpXHIu_OFksDe_0bPgZniNRSVRbl7W49DgS5Ya3kMfrYB4DnF5Fta5tn1oV6EwxYD4JONpFTenOJALPGTPawxXEfon_peiHOSBuQMu3_Vn-l1IJiRBhADCpcBCpIBCAUQABqHATCBhAKBgQCTJMKIfmfeZpaI7Q9rnsc29gdWawK7TnpVKRHws1iY7EUlYROeVcMdAwEqVM6f8BVCKLGgzQ7Gar_uuxfUGKwqEQzoppDraw4F75J464-7D5f6_oJQuGIBHZxqbMONtLjBCXRUhQW5szBLmTQ_R3qaJb5vf-h0APZfkYhq1cTttSCZkQYQBAqWAQqRAQgLEAAahgEwgYMCgYBvvGVH_M2H8qxxv94yaDYUTWbRnJ1uiIYc59KIQlfFimMPhSS7x2tqUa2-hI55JiII0Xym6GNkwLhyc1xtWChpVuIdSnbvttbrt4weDMLHqTwNOF6qAsVKGKT1Yh8yf-qb-DSmicgvFc74mBQm_6gAY1iQsf33YX8578ClhKBWHSCVkQYQAAqXAQqSAQgMEAAahwEwgYQCgYEAkuzFcd5TJu7lYWYe2hQLFfUWIIj91BvQQLa_Thln4YtGCO8gG1KJqJm-YlmJOWQG0B7H_5RVhxUxV9KpmFnsDVkzUFKOsCBaYGXc12xPVioawUlAwp5qp3QQtZyx_se97YIoLzuLr46UkLcLnkIrp-Jo46QzYi_QHq45WTm8MQ0glpEGEAIKlwEKkgEIDRAAGocBMIGEAoGBAIUzbxOknXf_rNt17_ir8JlWvrtnCWsQd1MAnl5mgArvavDtKeBYHzi5_Ak7DHlLzuA6YE8W175FxLFKpN2hkz-l-M7ltUSd8N1BvJRhK4t6WffWfC_1wPyoAbeSN2Yb1jygtZJQ8wGoXHcJQUXiMit3eFNyylwsJFj1gzAR4JCdIJeRBhABCpYBCpEBCA4QABqGATCBgwKBgFMcbEpl9ukVR6AO_R6sMyiU11I8b8MBSUCEC15iKsrVO8v_m47_TRRjWPYtQ9eZ7o1ocNJHaGUU7qqInFqtFaVnIceP6NmCsXhjs3MLrWPS8IRAy4Zf4FKmGOx3N9O2vemjUygZ9vUiSkULdVrecinRaT8JQ5RG4bUMY04XGIwFIJiRBhADCpYBCpEBCA8QABqGATCBgwKBgGpCkW-NR3li8GlRvqpq2YZGSIgm_PTyDI2Zwfw69grsBmPpVFW48Vw7xoMN35zcrojEpialB_uQzlpLYOvsMl634CRIuj-n1QE3-gaZTTTE8mg-AR4mcxnTKThPnRQpbuOlYAnriwiasWiQEMbGjq_HmWioYYxFo9USlklQn4-9IJmRBhAEEpUBCpIBCAYQABqHATCBhAKBgQCoZkFGm9oLTqjeXZAq6j5S6i7K20V0lNdBBLqfmFBIRuTkYxhs4vUYnWjZrKRAd5bp6_py0csmFmpl_5Yh0b-2pdo_E5PNP7LGRzKyKSiFddyykKKzVOazH8YYldDAfE8Z5HoS9e48an5JsPg0jr-TPu34DnJq3yv2a6dqiKL9zSCakQYSlQEKkgEIEBAAGocBMIGEAoGBALhrihbf3EpjDQS2sCQHazoFgN0nBbE9eesnnFTfzQELXb2gnJU9enmV_aDqaHKjgtLIPpCgn40lHrn5k6mvH5OdedyI6cCzE-N-GFp3nAq0NDJyMe0fhtIRD__CbT0ulcvkeow65ubXWfw6dBC2gR_34rdMe_L_TGRLMWjDULbNIJ"; @@ -57,7 +57,7 @@ Y_UNIT_TEST_SUITE(PublicInterfaceServiceTestSuite) { UNIT_ASSERT_VALUES_EQUAL("239", NBlackboxTvmId::Mimino); } - Y_UNIT_TEST(Case1Test) { + Y_UNIT_TEST(Case1Test) { TServiceContext context1(SECRET, OUR_ID, NUnittest::TVMKNIFE_PUBLIC_KEYS); TServiceContext context2 = std::move(context1); TServiceContext context3(std::move(context2)); @@ -69,20 +69,20 @@ Y_UNIT_TEST_SUITE(PublicInterfaceServiceTestSuite) { UNIT_ASSERT_EQUAL(ETicketStatus::Ok, checkedTicket3.GetStatus()); } - Y_UNIT_TEST(ContextExceptionsTest) { + Y_UNIT_TEST(ContextExceptionsTest) { UNIT_ASSERT_EXCEPTION(TServiceContext(SECRET, OUR_ID, MALFORMED_TVM_KEYS), TMalformedTvmKeysException); UNIT_ASSERT_EXCEPTION(TServiceContext(SECRET, OUR_ID, EMPTY_TVM_KEYS), TEmptyTvmKeysException); UNIT_ASSERT_EXCEPTION(TServiceContext(MALFORMED_TVM_SECRET, OUR_ID, NUnittest::TVMKNIFE_PUBLIC_KEYS), TMalformedTvmSecretException); } - Y_UNIT_TEST(ContextSignTest) { + Y_UNIT_TEST(ContextSignTest) { TServiceContext context(SECRET, OUR_ID, NUnittest::TVMKNIFE_PUBLIC_KEYS); UNIT_ASSERT_VALUES_EQUAL( "NsPTYak4Cfk-4vgau5lab3W4GPiTtb2etuj3y4MDPrk", context.SignCgiParamsForTvm(IntToString<10>(std::numeric_limits<time_t>::max()), "13,28", "")); } - Y_UNIT_TEST(ContextSignExceptionTest) { + Y_UNIT_TEST(ContextSignExceptionTest) { TServiceContext context = TServiceContext::CheckingFactory(OUR_ID, NUnittest::TVMKNIFE_PUBLIC_KEYS); UNIT_ASSERT_EXCEPTION( context.SignCgiParamsForTvm(IntToString<10>(std::numeric_limits<time_t>::max()), "13,28", ""), @@ -95,7 +95,7 @@ Y_UNIT_TEST_SUITE(PublicInterfaceServiceTestSuite) { ); } - Y_UNIT_TEST(ContextCheckExceptionTest) { + Y_UNIT_TEST(ContextCheckExceptionTest) { TServiceContext context = TServiceContext::CheckingFactory(OUR_ID, NUnittest::TVMKNIFE_PUBLIC_KEYS); UNIT_ASSERT_NO_EXCEPTION( context.Check("ABCDE") @@ -109,12 +109,12 @@ Y_UNIT_TEST_SUITE(PublicInterfaceServiceTestSuite) { } - Y_UNIT_TEST(ContextTest) { + Y_UNIT_TEST(ContextTest) { TServiceContext context1(SECRET, OUR_ID, NUnittest::TVMKNIFE_PUBLIC_KEYS); TServiceContext context2 = TServiceContext::CheckingFactory(OUR_ID, NUnittest::TVMKNIFE_PUBLIC_KEYS); } - Y_UNIT_TEST(Ticket1Test) { + Y_UNIT_TEST(Ticket1Test) { TServiceContext context(SECRET, OUR_ID, NUnittest::TVMKNIFE_PUBLIC_KEYS); auto checkedTicket = context.Check(VALID_SERVICE_TICKET_1); UNIT_ASSERT_EQUAL(ETicketStatus::Ok, checkedTicket.GetStatus()); @@ -122,28 +122,28 @@ Y_UNIT_TEST_SUITE(PublicInterfaceServiceTestSuite) { UNIT_ASSERT_EQUAL("ticket_type=serv;expiration_time=9223372036854775807;src=229;dst=28;scope=bb:sess1;scope=bb:sess2;", checkedTicket.DebugInfo()); } - Y_UNIT_TEST(Ticket2Test) { + Y_UNIT_TEST(Ticket2Test) { TServiceContext context(SECRET, OUR_ID, NUnittest::TVMKNIFE_PUBLIC_KEYS); auto checkedTicket = context.Check(VALID_SERVICE_TICKET_2); UNIT_ASSERT_EQUAL(ETicketStatus::Ok, checkedTicket.GetStatus()); UNIT_ASSERT_VALUES_EQUAL("ticket_type=serv;expiration_time=9223372036854775807;src=229;dst=28;scope=bb:sess1;scope=bb:sess10;scope=bb:sess100;scope=bb:sess11;scope=bb:sess12;scope=bb:sess13;scope=bb:sess14;scope=bb:sess15;scope=bb:sess16;scope=bb:sess17;scope=bb:sess18;scope=bb:sess19;scope=bb:sess2;scope=bb:sess20;scope=bb:sess21;scope=bb:sess22;scope=bb:sess23;scope=bb:sess24;scope=bb:sess25;scope=bb:sess26;scope=bb:sess27;scope=bb:sess28;scope=bb:sess29;scope=bb:sess3;scope=bb:sess30;scope=bb:sess31;scope=bb:sess32;scope=bb:sess33;scope=bb:sess34;scope=bb:sess35;scope=bb:sess36;scope=bb:sess37;scope=bb:sess38;scope=bb:sess39;scope=bb:sess4;scope=bb:sess40;scope=bb:sess41;scope=bb:sess42;scope=bb:sess43;scope=bb:sess44;scope=bb:sess45;scope=bb:sess46;scope=bb:sess47;scope=bb:sess48;scope=bb:sess49;scope=bb:sess5;scope=bb:sess50;scope=bb:sess51;scope=bb:sess52;scope=bb:sess53;scope=bb:sess54;scope=bb:sess55;scope=bb:sess56;scope=bb:sess57;scope=bb:sess58;scope=bb:sess59;scope=bb:sess6;scope=bb:sess60;scope=bb:sess61;scope=bb:sess62;scope=bb:sess63;scope=bb:sess64;scope=bb:sess65;scope=bb:sess66;scope=bb:sess67;scope=bb:sess68;scope=bb:sess69;scope=bb:sess7;scope=bb:sess70;scope=bb:sess71;scope=bb:sess72;scope=bb:sess73;scope=bb:sess74;scope=bb:sess75;scope=bb:sess76;scope=bb:sess77;scope=bb:sess78;scope=bb:sess79;scope=bb:sess8;scope=bb:sess80;scope=bb:sess81;scope=bb:sess82;scope=bb:sess83;scope=bb:sess84;scope=bb:sess85;scope=bb:sess86;scope=bb:sess87;scope=bb:sess88;scope=bb:sess89;scope=bb:sess9;scope=bb:sess90;scope=bb:sess91;scope=bb:sess92;scope=bb:sess93;scope=bb:sess94;scope=bb:sess95;scope=bb:sess96;scope=bb:sess97;scope=bb:sess98;scope=bb:sess99;", checkedTicket.DebugInfo()); } - Y_UNIT_TEST(Ticket3Test) { + Y_UNIT_TEST(Ticket3Test) { TServiceContext context(SECRET, OUR_ID, NUnittest::TVMKNIFE_PUBLIC_KEYS); auto checkedTicket = context.Check(VALID_SERVICE_TICKET_3); UNIT_ASSERT_EQUAL(ETicketStatus::Ok, checkedTicket.GetStatus()); UNIT_ASSERT_VALUES_EQUAL("ticket_type=serv;expiration_time=9223372036854775807;src=229;dst=28;", checkedTicket.DebugInfo()); } - Y_UNIT_TEST(TicketCheckingTest) { + Y_UNIT_TEST(TicketCheckingTest) { TServiceContext context(SECRET, OUR_ID, NUnittest::TVMKNIFE_PUBLIC_KEYS); auto ticket = context.Check(VALID_SERVICE_TICKET_1); UNIT_ASSERT_EQUAL(ETicketStatus::Ok, ticket.GetStatus()); UNIT_ASSERT_EQUAL(SRC_ID, ticket.GetSrc()); } - Y_UNIT_TEST(TicketErrorsTest) { + Y_UNIT_TEST(TicketErrorsTest) { TServiceContext context(SECRET, NOT_OUR_ID, NUnittest::TVMKNIFE_PUBLIC_KEYS); auto checkedTicket1 = context.Check(VALID_SERVICE_TICKET_1); UNIT_ASSERT_EQUAL(ETicketStatus::InvalidDst, checkedTicket1.GetStatus()); @@ -155,7 +155,7 @@ Y_UNIT_TEST_SUITE(PublicInterfaceServiceTestSuite) { UNIT_ASSERT_EQUAL(ETicketStatus::Expired, checkedTicket3.GetStatus()); } - Y_UNIT_TEST(TicketExceptionsTest) { + Y_UNIT_TEST(TicketExceptionsTest) { TServiceContext context(SECRET, OUR_ID, NUnittest::TVMKNIFE_PUBLIC_KEYS); auto checkedTicket = context.Check(EXPIRED_SERVICE_TICKET); UNIT_ASSERT_EQUAL(ETicketStatus::Expired, checkedTicket.GetStatus()); @@ -167,7 +167,7 @@ Y_UNIT_TEST_SUITE(PublicInterfaceServiceTestSuite) { UNIT_ASSERT_NO_EXCEPTION(checkedTicket.GetStatus()); } - Y_UNIT_TEST(RemoveSignatureTest) { + Y_UNIT_TEST(RemoveSignatureTest) { UNIT_ASSERT_VALUES_EQUAL("1:serv:ASDkljbjhsdbfLJHABFJHBslfbsfjs:asdxcvbxcvniueliuweklsvds", NUtils::RemoveTicketSignature("1:serv:ASDkljbjhsdbfLJHABFJHBslfbsfjs:asdxcvbxcvniueliuweklsvds")); UNIT_ASSERT_VALUES_EQUAL("2:serv:ASDkljbjhsdbfLJHABFJHBslfbsfjs:asdxcvbxcvniueliuweklsvds", @@ -186,14 +186,14 @@ Y_UNIT_TEST_SUITE(PublicInterfaceServiceTestSuite) { NUtils::RemoveTicketSignature("asdxcbvfgdsgfasdfxczvdsgfxcdvbcbvf")); } - Y_UNIT_TEST(ResetKeysTest) { + Y_UNIT_TEST(ResetKeysTest) { TServiceContext context(SECRET, OUR_ID, NUnittest::TVMKNIFE_PUBLIC_KEYS); TCheckedServiceTicket checkedTicket = context.Check(VALID_SERVICE_TICKET_1); UNIT_ASSERT_EQUAL(ETicketStatus::Ok, checkedTicket.GetStatus()); } } -Y_UNIT_TEST_SUITE(PublicInterfaceUserTestSuite) { +Y_UNIT_TEST_SUITE(PublicInterfaceUserTestSuite) { static const TString EMPTY_TVM_KEYS = "1:EpUBCpIBCAYQABqHATCBhAKBgQCoZkFGm9oLTqjeXZAq6j5S6i7K20V0lNdBBLqfmFBIRuTkYxhs4vUYnWjZrKRAd5bp6_py0csmFmpl_5Yh0b-2pdo_E5PNP7LGRzKyKSiFddyykKKzVOazH8YYldDAfE8Z5HoS9e48an5JsPg0jr-TPu34DnJq3yv2a6dqiKL9zSCakQY"; static const TString EXPIRED_USER_TICKET = "3:user:CA0QABokCgMIyAMKAgh7EMgDGghiYjpzZXNzMRoIYmI6c2VzczIgEigB:D0CmYVwWg91LDYejjeQ2UP8AeiA_mr1q1CUD_lfJ9zQSEYEOYGDTafg4Um2rwOOvQnsD1JHM4zHyMUJ6Jtp9GAm5pmhbXBBZqaCcJpyxLTEC8a81MhJFCCJRvu_G1FiAgRgB25gI3HIbkvHFUEqAIC_nANy7NFQnbKk2S-EQPGY"; static const TString MALFORMED_TVM_KEYS = "1:CpgCCpMCCAEQABqIAjCCAQQCggEAcLEXeH67FQESFUn4_7wnX7wN0PUrBoUsm3QQ4W5vC-qz6sXaEjSwnTV8w1o-z6X9KPLlhzMQvuS38NCNfK4uvJ4Zvfp3YsXJ25-rYtbnrYJHNvHohD-kPCCw_yZpMp21JdWigzQGuV7CtrxUhF-NNrsnUaJrE5-OpEWNt4X6nCItKIYeVcSK6XJUbEWbrNCRbvkSc4ak2ymFeMuHYJVjxh4eQbk7_ZPzodP0WvF6eUYrYeb42imVEOR8ofVLQWE5DVnb1z_TqZm4i1XkS7jMwZuBxBRw8DGdYei0lT_sAf7KST2jC0590NySB3vsBgWEVs1OdUUWA6r-Dvx9dsOQtSCVkQYQAAqZAgqUAggCEAAaiQIwggEFAoIBAQDhEBM5-6YsPWfogKtbluJoCX1WV2KdzOaQ0-OlRbBzeCzw-eQKu12c8WakHBbeCMd1I1TU64SDkDorWjXGIa_2xT6N3zzNAE50roTbPCcmeQrps26woTYfYIuqDdoxYKZNr0lvNLLW47vBr7EKqo1S4KSj7aXK_XYeEvUgIgf3nVIcNrio7VTnFmGGVQCepaL1Hi1gN4yIXjVZ06PBPZ-DxSRu6xOGbFrfKMJeMPs7KOyE-26Q3xOXdTIa1X-zYIucTd_bxUCL4BVbwW2AvbbFsaG7ISmVdGu0XUTmhXs1KrEfUVLRJhE4Dx99hAZXm1_HlYMUeJcMQ_oHOhV94ENFIJaRBhACCpYBCpEBCAMQABqGATCBgwKBgF9t2YJGAJkRRFq6fWhi3m1TFW1UOE0f6ZrfYhHAkpqGlKlh0QVfeTNPpeJhi75xXzCe6oReRUm-0DbqDNhTShC7uGUv1INYnRBQWH6E-5Fc5XrbDFSuGQw2EYjNfHy_HefHJXxQKAqPvxBDKMKkHgV58WtM6rC8jRi9sdX_ig2NIJeRBhABCpYBCpEBCAQQABqGATCBgwKBgGB4d6eLGUBv-Q6EPLehC4S-yuE2HB-_rJ7WkeYwyp-xIPolPrd-PQme2utHB4ZgpXHIu_OFksDe_0bPgZniNRSVRbl7W49DgS5Ya3kMfrYB4DnF5Fta5tn1oV6EwxYD4JONpFTenOJALPGTPawxXEfon_peiHOSBuQMu3_Vn-l1IJiRBhADCpcBCpIBCAUQABqHATCBhAKBgQCTJMKIfmfeZpaI7Q9rnsc29gdWawK7TnpVKRHws1iY7EUlYROeVcMdAwEqVM6f8BVCKLGgzQ7Gar_uuxfUGKwqEQzoppDraw4F75J464-7D5f6_oJQuGIBHZxqbMONtLjBCXRUhQW5szBLmTQ_R3qaJb5vf-h0APZfkYhq1cTttSCZkQYQBAqWAQqRAQgLEAAahgEwgYMCgYBvvGVH_M2H8qxxv94yaDYUTWbRnJ1uiIYc59KIQlfFimMPhSS7x2tqUa2-hI55JiII0Xym6GNkwLhyc1xtWChpVuIdSnbvttbrt4weDMLHqTwNOF6qAsVKGKT1Yh8yf-qb-DSmicgvFc74mBQm_6gAY1iQsf33YX8578ClhKBWHSCVkQYQAAqXAQqSAQgMEAAahwEwgYQCgYEAkuzFcd5TJu7lYWYe2hQLFfUWIIj91BvQQLa_Thln4YtGCO8gG1KJqJm-YlmJOWQG0B7H_5RVhxUxV9KpmFnsDVkzUFKOsCBaYGXc12xPVioawUlAwp5qp3QQtZyx_se97YIoLzuLr46UkLcLnkIrp-Jo46QzYi_QHq45WTm8MQ0glpEGEAIKlwEKkgEIDRAAGocBMIGEAoGBAIUzbxOknXf_rNt17_ir8JlWvrtnCWsQd1MAnl5mgArvavDtKeBYHzi5_Ak7DHlLzuA6YE8W175FxLFKpN2hkz-l-M7ltUSd8N1BvJRhK4t6WffWfC_1wPyoAbeSN2Yb1jygtZJQ8wGoXHcJQUXiMit3eFNyylwsJFj1gzAR4JCdIJeRBhABCpYBCpEBCA4QABqGATCBgwKBgFMcbEpl9ukVR6AO_R6sMyiU11I8b8MBSUCEC15iKsrVO8v_m47_TRRjWPYtQ9eZ7o1ocNJHaGUU7qqInFqtFaVnIceP6NmCsXhjs3MLrWPS8IRAy4Zf4FKmGOx3N9O2vemjUygZ9vUiSkULdVrecinRaT8JQ5RG4bUMY04XGIwFIJiRBhADCpYBCpEBCA8QABqGATCBgwKBgGpCkW-NR3li8GlRvqpq2YZGSIgm_PTyDI2Zwfw69grsBmPpVFW48Vw7xoMN35zcrojEpialB_uQzlpLYOvsMl634CRIuj-n1QE3-gaZTTTE8mg-AR4mcxnTKThPnRQpbuOlYAnriwiasWiQEMbGjq_HmWioYYxFo9USlklQn4-9IJmRBhAEEpUBCpIBCAYQABqHATCBhAKBgQCoZkFGm9oLTqjeXZAq6j5S6i7K20V0lNdBBLqfmFBIRuTkYxhs4vUYnWjZrKRAd5bp6_py0csmFmpl_5Yh0b-2pdo_E5PNP7LGRzKyKSiFddyykKKzVOazH8YYldDAfE8Z5HoS9e48an5JsPg0jr-TPu34DnJq3yv2a6dqiKL9zSCakQYSlQEKkgEIEBAAGocBMIGEAoGBALhrihbf3EpjDQS2sCQHazoFgN0nBbE9eesnnFTfzQELXb2gnJU9enmV_aDqaHKjgtLIPpCgn40lHrn5k6mvH5OdedyI6cCzE-N-GFp3nAq0NDJyMe0fhtIRD__CbT0ulcvkeow65ubXWfw6dBC2gR_34rdMe_L_TGRLMWjDULbNIJ"; @@ -203,7 +203,7 @@ Y_UNIT_TEST_SUITE(PublicInterfaceUserTestSuite) { static const TString VALID_USER_TICKET_2 = "3:user:CA0Q__________9_GhAKAwjIAwoCCHsQyAMgEigB:KRibGYTJUA2ns0Fn7VYqeMZ1-GdscB1o9pRzELyr7QJrJsfsE8Y_HoVvB8Npr-oalv6AXOpagSc8HpZjAQz8zKMAVE_tI0tL-9DEsHirpawEbpy7OWV7-k18o1m-RaDaKeTlIB45KHbBul1-9aeKkortBfbbXtz_Qy9r_mfFPiQ"; static const TString VALID_USER_TICKET_3 = "3:user:CA0Q__________9_Go8bCgIIAAoCCAEKAggCCgIIAwoCCAQKAggFCgIIBgoCCAcKAggICgIICQoCCAoKAggLCgIIDAoCCA0KAggOCgIIDwoCCBAKAggRCgIIEgoCCBMKAggUCgIIFQoCCBYKAggXCgIIGAoCCBkKAggaCgIIGwoCCBwKAggdCgIIHgoCCB8KAgggCgIIIQoCCCIKAggjCgIIJAoCCCUKAggmCgIIJwoCCCgKAggpCgIIKgoCCCsKAggsCgIILQoCCC4KAggvCgIIMAoCCDEKAggyCgIIMwoCCDQKAgg1CgIINgoCCDcKAgg4CgIIOQoCCDoKAgg7CgIIPAoCCD0KAgg-CgIIPwoCCEAKAghBCgIIQgoCCEMKAghECgIIRQoCCEYKAghHCgIISAoCCEkKAghKCgIISwoCCEwKAghNCgIITgoCCE8KAghQCgIIUQoCCFIKAghTCgIIVAoCCFUKAghWCgIIVwoCCFgKAghZCgIIWgoCCFsKAghcCgIIXQoCCF4KAghfCgIIYAoCCGEKAghiCgIIYwoCCGQKAghlCgIIZgoCCGcKAghoCgIIaQoCCGoKAghrCgIIbAoCCG0KAghuCgIIbwoCCHAKAghxCgIIcgoCCHMKAgh0CgIIdQoCCHYKAgh3CgIIeAoCCHkKAgh6CgIIewoCCHwKAgh9CgIIfgoCCH8KAwiAAQoDCIEBCgMIggEKAwiDAQoDCIQBCgMIhQEKAwiGAQoDCIcBCgMIiAEKAwiJAQoDCIoBCgMIiwEKAwiMAQoDCI0BCgMIjgEKAwiPAQoDCJABCgMIkQEKAwiSAQoDCJMBCgMIlAEKAwiVAQoDCJYBCgMIlwEKAwiYAQoDCJkBCgMImgEKAwibAQoDCJwBCgMInQEKAwieAQoDCJ8BCgMIoAEKAwihAQoDCKIBCgMIowEKAwikAQoDCKUBCgMIpgEKAwinAQoDCKgBCgMIqQEKAwiqAQoDCKsBCgMIrAEKAwitAQoDCK4BCgMIrwEKAwiwAQoDCLEBCgMIsgEKAwizAQoDCLQBCgMItQEKAwi2AQoDCLcBCgMIuAEKAwi5AQoDCLoBCgMIuwEKAwi8AQoDCL0BCgMIvgEKAwi_AQoDCMABCgMIwQEKAwjCAQoDCMMBCgMIxAEKAwjFAQoDCMYBCgMIxwEKAwjIAQoDCMkBCgMIygEKAwjLAQoDCMwBCgMIzQEKAwjOAQoDCM8BCgMI0AEKAwjRAQoDCNIBCgMI0wEKAwjUAQoDCNUBCgMI1gEKAwjXAQoDCNgBCgMI2QEKAwjaAQoDCNsBCgMI3AEKAwjdAQoDCN4BCgMI3wEKAwjgAQoDCOEBCgMI4gEKAwjjAQoDCOQBCgMI5QEKAwjmAQoDCOcBCgMI6AEKAwjpAQoDCOoBCgMI6wEKAwjsAQoDCO0BCgMI7gEKAwjvAQoDCPABCgMI8QEKAwjyAQoDCPMBCgMI9AEKAwj1AQoDCPYBCgMI9wEKAwj4AQoDCPkBCgMI-gEKAwj7AQoDCPwBCgMI_QEKAwj-AQoDCP8BCgMIgAIKAwiBAgoDCIICCgMIgwIKAwiEAgoDCIUCCgMIhgIKAwiHAgoDCIgCCgMIiQIKAwiKAgoDCIsCCgMIjAIKAwiNAgoDCI4CCgMIjwIKAwiQAgoDCJECCgMIkgIKAwiTAgoDCJQCCgMIlQIKAwiWAgoDCJcCCgMImAIKAwiZAgoDCJoCCgMImwIKAwicAgoDCJ0CCgMIngIKAwifAgoDCKACCgMIoQIKAwiiAgoDCKMCCgMIpAIKAwilAgoDCKYCCgMIpwIKAwioAgoDCKkCCgMIqgIKAwirAgoDCKwCCgMIrQIKAwiuAgoDCK8CCgMIsAIKAwixAgoDCLICCgMIswIKAwi0AgoDCLUCCgMItgIKAwi3AgoDCLgCCgMIuQIKAwi6AgoDCLsCCgMIvAIKAwi9AgoDCL4CCgMIvwIKAwjAAgoDCMECCgMIwgIKAwjDAgoDCMQCCgMIxQIKAwjGAgoDCMcCCgMIyAIKAwjJAgoDCMoCCgMIywIKAwjMAgoDCM0CCgMIzgIKAwjPAgoDCNACCgMI0QIKAwjSAgoDCNMCCgMI1AIKAwjVAgoDCNYCCgMI1wIKAwjYAgoDCNkCCgMI2gIKAwjbAgoDCNwCCgMI3QIKAwjeAgoDCN8CCgMI4AIKAwjhAgoDCOICCgMI4wIKAwjkAgoDCOUCCgMI5gIKAwjnAgoDCOgCCgMI6QIKAwjqAgoDCOsCCgMI7AIKAwjtAgoDCO4CCgMI7wIKAwjwAgoDCPECCgMI8gIKAwjzAgoDCPQCCgMI9QIKAwj2AgoDCPcCCgMI-AIKAwj5AgoDCPoCCgMI-wIKAwj8AgoDCP0CCgMI_gIKAwj_AgoDCIADCgMIgQMKAwiCAwoDCIMDCgMIhAMKAwiFAwoDCIYDCgMIhwMKAwiIAwoDCIkDCgMIigMKAwiLAwoDCIwDCgMIjQMKAwiOAwoDCI8DCgMIkAMKAwiRAwoDCJIDCgMIkwMKAwiUAwoDCJUDCgMIlgMKAwiXAwoDCJgDCgMImQMKAwiaAwoDCJsDCgMInAMKAwidAwoDCJ4DCgMInwMKAwigAwoDCKEDCgMIogMKAwijAwoDCKQDCgMIpQMKAwimAwoDCKcDCgMIqAMKAwipAwoDCKoDCgMIqwMKAwisAwoDCK0DCgMIrgMKAwivAwoDCLADCgMIsQMKAwiyAwoDCLMDCgMItAMKAwi1AwoDCLYDCgMItwMKAwi4AwoDCLkDCgMIugMKAwi7AwoDCLwDCgMIvQMKAwi-AwoDCL8DCgMIwAMKAwjBAwoDCMIDCgMIwwMKAwjEAwoDCMUDCgMIxgMKAwjHAwoDCMgDCgMIyQMKAwjKAwoDCMsDCgMIzAMKAwjNAwoDCM4DCgMIzwMKAwjQAwoDCNEDCgMI0gMKAwjTAwoDCNQDCgMI1QMKAwjWAwoDCNcDCgMI2AMKAwjZAwoDCNoDCgMI2wMKAwjcAwoDCN0DCgMI3gMKAwjfAwoDCOADCgMI4QMKAwjiAwoDCOMDCgMI5AMKAwjlAwoDCOYDCgMI5wMKAwjoAwoDCOkDCgMI6gMKAwjrAwoDCOwDCgMI7QMKAwjuAwoDCO8DCgMI8AMKAwjxAwoDCPIDCgMI8wMQyAMaCGJiOnNlc3MxGgliYjpzZXNzMTAaCmJiOnNlc3MxMDAaCWJiOnNlc3MxMRoJYmI6c2VzczEyGgliYjpzZXNzMTMaCWJiOnNlc3MxNBoJYmI6c2VzczE1GgliYjpzZXNzMTYaCWJiOnNlc3MxNxoJYmI6c2VzczE4GgliYjpzZXNzMTkaCGJiOnNlc3MyGgliYjpzZXNzMjAaCWJiOnNlc3MyMRoJYmI6c2VzczIyGgliYjpzZXNzMjMaCWJiOnNlc3MyNBoJYmI6c2VzczI1GgliYjpzZXNzMjYaCWJiOnNlc3MyNxoJYmI6c2VzczI4GgliYjpzZXNzMjkaCGJiOnNlc3MzGgliYjpzZXNzMzAaCWJiOnNlc3MzMRoJYmI6c2VzczMyGgliYjpzZXNzMzMaCWJiOnNlc3MzNBoJYmI6c2VzczM1GgliYjpzZXNzMzYaCWJiOnNlc3MzNxoJYmI6c2VzczM4GgliYjpzZXNzMzkaCGJiOnNlc3M0GgliYjpzZXNzNDAaCWJiOnNlc3M0MRoJYmI6c2VzczQyGgliYjpzZXNzNDMaCWJiOnNlc3M0NBoJYmI6c2VzczQ1GgliYjpzZXNzNDYaCWJiOnNlc3M0NxoJYmI6c2VzczQ4GgliYjpzZXNzNDkaCGJiOnNlc3M1GgliYjpzZXNzNTAaCWJiOnNlc3M1MRoJYmI6c2VzczUyGgliYjpzZXNzNTMaCWJiOnNlc3M1NBoJYmI6c2VzczU1GgliYjpzZXNzNTYaCWJiOnNlc3M1NxoJYmI6c2VzczU4GgliYjpzZXNzNTkaCGJiOnNlc3M2GgliYjpzZXNzNjAaCWJiOnNlc3M2MRoJYmI6c2VzczYyGgliYjpzZXNzNjMaCWJiOnNlc3M2NBoJYmI6c2VzczY1GgliYjpzZXNzNjYaCWJiOnNlc3M2NxoJYmI6c2VzczY4GgliYjpzZXNzNjkaCGJiOnNlc3M3GgliYjpzZXNzNzAaCWJiOnNlc3M3MRoJYmI6c2VzczcyGgliYjpzZXNzNzMaCWJiOnNlc3M3NBoJYmI6c2Vzczc1GgliYjpzZXNzNzYaCWJiOnNlc3M3NxoJYmI6c2Vzczc4GgliYjpzZXNzNzkaCGJiOnNlc3M4GgliYjpzZXNzODAaCWJiOnNlc3M4MRoJYmI6c2VzczgyGgliYjpzZXNzODMaCWJiOnNlc3M4NBoJYmI6c2Vzczg1GgliYjpzZXNzODYaCWJiOnNlc3M4NxoJYmI6c2Vzczg4GgliYjpzZXNzODkaCGJiOnNlc3M5GgliYjpzZXNzOTAaCWJiOnNlc3M5MRoJYmI6c2VzczkyGgliYjpzZXNzOTMaCWJiOnNlc3M5NBoJYmI6c2Vzczk1GgliYjpzZXNzOTYaCWJiOnNlc3M5NxoJYmI6c2Vzczk4GgliYjpzZXNzOTkgEigB:CX8PIOrxJnQqFXl7wAsiHJ_1VGjoI-asNlCXb8SE8jtI2vdh9x6CqbAurSgIlAAEgotVP-nuUR38x_a9YJuXzmG5AvJ458apWQtODHIDIX6ZaIwMxjS02R7S5LNqXa0gAuU_R6bCWpZdWe2uLMkdpu5KHbDgW08g-uaP_nceDOk"; - Y_UNIT_TEST(Case1Test) { + Y_UNIT_TEST(Case1Test) { TUserContext context1(EBlackboxEnv::Test, NUnittest::TVMKNIFE_PUBLIC_KEYS); TCheckedUserTicket checkedTicket1 = context1.Check("2:serv:CgYIDRCUkQYQDBgcIgdiYjpzZXNzIghiYjpzZXNzMg:ERmeH_yzC7K_QsoHTyw7llCsyExEz3CoEopPIuivA0ZAtTaFq_Pa0l9Fhhx_NX9WpOp2CPyY5cFc4PXhcO83jCB7-EGvHNxGN-j2NQalERzPiKqkDCO0Q5etLzSzrfTlvMz7sXDvELNBHyA0PkAQnbz4supY0l-0Q6JBYSEF3zOVMjjE-HeQIFL3ats3_PakaUMWRvgQQ88pVdYZqAtbDw9PlTla7ommygVZQjcfNFXV1pJKRgOCLs-YyCjOJHLKL04zYj0X6KsOCTUeqhj7ml96wLZ-g1X9tyOR2WAr2Ctq7wIEHwqhxOLgOSKqm05xH6Vi3E_hekf50oe2jPfKEA"); @@ -219,16 +219,16 @@ Y_UNIT_TEST_SUITE(PublicInterfaceUserTestSuite) { UNIT_ASSERT_EQUAL(ETicketStatus::Ok, checkedTicket4.GetStatus()); } - Y_UNIT_TEST(ContextTest) { + Y_UNIT_TEST(ContextTest) { TUserContext context(EBlackboxEnv::Prod, NUnittest::TVMKNIFE_PUBLIC_KEYS); } - Y_UNIT_TEST(ContextExceptionsTest) { + Y_UNIT_TEST(ContextExceptionsTest) { UNIT_ASSERT_EXCEPTION(TUserContext(EBlackboxEnv::Prod, EMPTY_TVM_KEYS), TEmptyTvmKeysException); UNIT_ASSERT_EXCEPTION(TUserContext(EBlackboxEnv::Prod, MALFORMED_TVM_KEYS), TMalformedTvmKeysException); } - Y_UNIT_TEST(Ticket1Test) { + Y_UNIT_TEST(Ticket1Test) { TUserContext context(EBlackboxEnv::Test, NUnittest::TVMKNIFE_PUBLIC_KEYS); auto checkedTicket = context.Check(VALID_USER_TICKET_1); UNIT_ASSERT_EQUAL(ETicketStatus::Ok, checkedTicket.GetStatus()); @@ -241,21 +241,21 @@ Y_UNIT_TEST_SUITE(PublicInterfaceUserTestSuite) { UNIT_ASSERT_EQUAL("ticket_type=user;expiration_time=9223372036854775807;scope=bb:sess1;scope=bb:sess2;default_uid=456;uid=456;uid=123;env=Test;", checkedTicket.DebugInfo()); } - Y_UNIT_TEST(Ticket2Test) { + Y_UNIT_TEST(Ticket2Test) { TUserContext context(EBlackboxEnv::Test, NUnittest::TVMKNIFE_PUBLIC_KEYS); auto checkedTicket = context.Check(VALID_USER_TICKET_2); UNIT_ASSERT_EQUAL(ETicketStatus::Ok, checkedTicket.GetStatus()); UNIT_ASSERT_VALUES_EQUAL("ticket_type=user;expiration_time=9223372036854775807;default_uid=456;uid=456;uid=123;env=Test;", checkedTicket.DebugInfo()); } - Y_UNIT_TEST(Ticket3Test) { + Y_UNIT_TEST(Ticket3Test) { TUserContext context(EBlackboxEnv::Test, NUnittest::TVMKNIFE_PUBLIC_KEYS); auto checkedTicket = context.Check(VALID_USER_TICKET_3); UNIT_ASSERT_EQUAL(ETicketStatus::Ok, checkedTicket.GetStatus()); UNIT_ASSERT_VALUES_EQUAL("ticket_type=user;expiration_time=9223372036854775807;scope=bb:sess1;scope=bb:sess10;scope=bb:sess100;scope=bb:sess11;scope=bb:sess12;scope=bb:sess13;scope=bb:sess14;scope=bb:sess15;scope=bb:sess16;scope=bb:sess17;scope=bb:sess18;scope=bb:sess19;scope=bb:sess2;scope=bb:sess20;scope=bb:sess21;scope=bb:sess22;scope=bb:sess23;scope=bb:sess24;scope=bb:sess25;scope=bb:sess26;scope=bb:sess27;scope=bb:sess28;scope=bb:sess29;scope=bb:sess3;scope=bb:sess30;scope=bb:sess31;scope=bb:sess32;scope=bb:sess33;scope=bb:sess34;scope=bb:sess35;scope=bb:sess36;scope=bb:sess37;scope=bb:sess38;scope=bb:sess39;scope=bb:sess4;scope=bb:sess40;scope=bb:sess41;scope=bb:sess42;scope=bb:sess43;scope=bb:sess44;scope=bb:sess45;scope=bb:sess46;scope=bb:sess47;scope=bb:sess48;scope=bb:sess49;scope=bb:sess5;scope=bb:sess50;scope=bb:sess51;scope=bb:sess52;scope=bb:sess53;scope=bb:sess54;scope=bb:sess55;scope=bb:sess56;scope=bb:sess57;scope=bb:sess58;scope=bb:sess59;scope=bb:sess6;scope=bb:sess60;scope=bb:sess61;scope=bb:sess62;scope=bb:sess63;scope=bb:sess64;scope=bb:sess65;scope=bb:sess66;scope=bb:sess67;scope=bb:sess68;scope=bb:sess69;scope=bb:sess7;scope=bb:sess70;scope=bb:sess71;scope=bb:sess72;scope=bb:sess73;scope=bb:sess74;scope=bb:sess75;scope=bb:sess76;scope=bb:sess77;scope=bb:sess78;scope=bb:sess79;scope=bb:sess8;scope=bb:sess80;scope=bb:sess81;scope=bb:sess82;scope=bb:sess83;scope=bb:sess84;scope=bb:sess85;scope=bb:sess86;scope=bb:sess87;scope=bb:sess88;scope=bb:sess89;scope=bb:sess9;scope=bb:sess90;scope=bb:sess91;scope=bb:sess92;scope=bb:sess93;scope=bb:sess94;scope=bb:sess95;scope=bb:sess96;scope=bb:sess97;scope=bb:sess98;scope=bb:sess99;default_uid=456;uid=0;uid=1;uid=2;uid=3;uid=4;uid=5;uid=6;uid=7;uid=8;uid=9;uid=10;uid=11;uid=12;uid=13;uid=14;uid=15;uid=16;uid=17;uid=18;uid=19;uid=20;uid=21;uid=22;uid=23;uid=24;uid=25;uid=26;uid=27;uid=28;uid=29;uid=30;uid=31;uid=32;uid=33;uid=34;uid=35;uid=36;uid=37;uid=38;uid=39;uid=40;uid=41;uid=42;uid=43;uid=44;uid=45;uid=46;uid=47;uid=48;uid=49;uid=50;uid=51;uid=52;uid=53;uid=54;uid=55;uid=56;uid=57;uid=58;uid=59;uid=60;uid=61;uid=62;uid=63;uid=64;uid=65;uid=66;uid=67;uid=68;uid=69;uid=70;uid=71;uid=72;uid=73;uid=74;uid=75;uid=76;uid=77;uid=78;uid=79;uid=80;uid=81;uid=82;uid=83;uid=84;uid=85;uid=86;uid=87;uid=88;uid=89;uid=90;uid=91;uid=92;uid=93;uid=94;uid=95;uid=96;uid=97;uid=98;uid=99;uid=100;uid=101;uid=102;uid=103;uid=104;uid=105;uid=106;uid=107;uid=108;uid=109;uid=110;uid=111;uid=112;uid=113;uid=114;uid=115;uid=116;uid=117;uid=118;uid=119;uid=120;uid=121;uid=122;uid=123;uid=124;uid=125;uid=126;uid=127;uid=128;uid=129;uid=130;uid=131;uid=132;uid=133;uid=134;uid=135;uid=136;uid=137;uid=138;uid=139;uid=140;uid=141;uid=142;uid=143;uid=144;uid=145;uid=146;uid=147;uid=148;uid=149;uid=150;uid=151;uid=152;uid=153;uid=154;uid=155;uid=156;uid=157;uid=158;uid=159;uid=160;uid=161;uid=162;uid=163;uid=164;uid=165;uid=166;uid=167;uid=168;uid=169;uid=170;uid=171;uid=172;uid=173;uid=174;uid=175;uid=176;uid=177;uid=178;uid=179;uid=180;uid=181;uid=182;uid=183;uid=184;uid=185;uid=186;uid=187;uid=188;uid=189;uid=190;uid=191;uid=192;uid=193;uid=194;uid=195;uid=196;uid=197;uid=198;uid=199;uid=200;uid=201;uid=202;uid=203;uid=204;uid=205;uid=206;uid=207;uid=208;uid=209;uid=210;uid=211;uid=212;uid=213;uid=214;uid=215;uid=216;uid=217;uid=218;uid=219;uid=220;uid=221;uid=222;uid=223;uid=224;uid=225;uid=226;uid=227;uid=228;uid=229;uid=230;uid=231;uid=232;uid=233;uid=234;uid=235;uid=236;uid=237;uid=238;uid=239;uid=240;uid=241;uid=242;uid=243;uid=244;uid=245;uid=246;uid=247;uid=248;uid=249;uid=250;uid=251;uid=252;uid=253;uid=254;uid=255;uid=256;uid=257;uid=258;uid=259;uid=260;uid=261;uid=262;uid=263;uid=264;uid=265;uid=266;uid=267;uid=268;uid=269;uid=270;uid=271;uid=272;uid=273;uid=274;uid=275;uid=276;uid=277;uid=278;uid=279;uid=280;uid=281;uid=282;uid=283;uid=284;uid=285;uid=286;uid=287;uid=288;uid=289;uid=290;uid=291;uid=292;uid=293;uid=294;uid=295;uid=296;uid=297;uid=298;uid=299;uid=300;uid=301;uid=302;uid=303;uid=304;uid=305;uid=306;uid=307;uid=308;uid=309;uid=310;uid=311;uid=312;uid=313;uid=314;uid=315;uid=316;uid=317;uid=318;uid=319;uid=320;uid=321;uid=322;uid=323;uid=324;uid=325;uid=326;uid=327;uid=328;uid=329;uid=330;uid=331;uid=332;uid=333;uid=334;uid=335;uid=336;uid=337;uid=338;uid=339;uid=340;uid=341;uid=342;uid=343;uid=344;uid=345;uid=346;uid=347;uid=348;uid=349;uid=350;uid=351;uid=352;uid=353;uid=354;uid=355;uid=356;uid=357;uid=358;uid=359;uid=360;uid=361;uid=362;uid=363;uid=364;uid=365;uid=366;uid=367;uid=368;uid=369;uid=370;uid=371;uid=372;uid=373;uid=374;uid=375;uid=376;uid=377;uid=378;uid=379;uid=380;uid=381;uid=382;uid=383;uid=384;uid=385;uid=386;uid=387;uid=388;uid=389;uid=390;uid=391;uid=392;uid=393;uid=394;uid=395;uid=396;uid=397;uid=398;uid=399;uid=400;uid=401;uid=402;uid=403;uid=404;uid=405;uid=406;uid=407;uid=408;uid=409;uid=410;uid=411;uid=412;uid=413;uid=414;uid=415;uid=416;uid=417;uid=418;uid=419;uid=420;uid=421;uid=422;uid=423;uid=424;uid=425;uid=426;uid=427;uid=428;uid=429;uid=430;uid=431;uid=432;uid=433;uid=434;uid=435;uid=436;uid=437;uid=438;uid=439;uid=440;uid=441;uid=442;uid=443;uid=444;uid=445;uid=446;uid=447;uid=448;uid=449;uid=450;uid=451;uid=452;uid=453;uid=454;uid=455;uid=456;uid=457;uid=458;uid=459;uid=460;uid=461;uid=462;uid=463;uid=464;uid=465;uid=466;uid=467;uid=468;uid=469;uid=470;uid=471;uid=472;uid=473;uid=474;uid=475;uid=476;uid=477;uid=478;uid=479;uid=480;uid=481;uid=482;uid=483;uid=484;uid=485;uid=486;uid=487;uid=488;uid=489;uid=490;uid=491;uid=492;uid=493;uid=494;uid=495;uid=496;uid=497;uid=498;uid=499;env=Test;", checkedTicket.DebugInfo()); } - Y_UNIT_TEST(TicketErrorsTest) { + Y_UNIT_TEST(TicketErrorsTest) { TUserContext contextTest(EBlackboxEnv::Test, NUnittest::TVMKNIFE_PUBLIC_KEYS); auto checkedTicket1 = contextTest.Check(UNSUPPORTED_VERSION_USER_TICKET); UNIT_ASSERT_EQUAL(ETicketStatus::UnsupportedVersion, checkedTicket1.GetStatus()); @@ -268,7 +268,7 @@ Y_UNIT_TEST_SUITE(PublicInterfaceUserTestSuite) { UNIT_ASSERT_EQUAL(ETicketStatus::InvalidBlackboxEnv, checkedTicket3.GetStatus()); } - Y_UNIT_TEST(TicketExceptionsTest) { + Y_UNIT_TEST(TicketExceptionsTest) { TUserContext contextTest(EBlackboxEnv::Test, NUnittest::TVMKNIFE_PUBLIC_KEYS); auto checkedTicket = contextTest.Check(EXPIRED_USER_TICKET); UNIT_ASSERT_EQUAL(ETicketStatus::Expired, checkedTicket.GetStatus()); @@ -282,7 +282,7 @@ Y_UNIT_TEST_SUITE(PublicInterfaceUserTestSuite) { UNIT_ASSERT_NO_EXCEPTION(checkedTicket.GetStatus()); } - Y_UNIT_TEST(ResetKeysTest) { + Y_UNIT_TEST(ResetKeysTest) { TUserContext context(EBlackboxEnv::Test, NUnittest::TVMKNIFE_PUBLIC_KEYS); auto checkedTicket = context.Check(VALID_USER_TICKET_1); UNIT_ASSERT_EQUAL(ETicketStatus::Ok, checkedTicket.GetStatus()); diff --git a/library/cpp/tvmauth/src/ut/service_ut.cpp b/library/cpp/tvmauth/src/ut/service_ut.cpp index 5b6b5143bd3..e20cdcc65e6 100644 --- a/library/cpp/tvmauth/src/ut/service_ut.cpp +++ b/library/cpp/tvmauth/src/ut/service_ut.cpp @@ -10,16 +10,16 @@ using namespace NTvmAuth; -Y_UNIT_TEST_SUITE(ServiceTestSuite) { - Y_UNIT_TEST_DECLARE(TicketProtoTest); +Y_UNIT_TEST_SUITE(ServiceTestSuite) { + Y_UNIT_TEST_DECLARE(TicketProtoTest); } class TTestServiceTicketImpl: public TCheckedServiceTicket::TImpl { using TCheckedServiceTicket::TImpl::TImpl; - Y_UNIT_TEST_FRIEND(ServiceTestSuite, TicketProtoTest); + Y_UNIT_TEST_FRIEND(ServiceTestSuite, TicketProtoTest); }; -Y_UNIT_TEST_SUITE_IMPLEMENTATION(ServiceTestSuite) { +Y_UNIT_TEST_SUITE_IMPLEMENTATION(ServiceTestSuite) { static const TString EMPTY_TVM_KEYS = "1:CpgCCpMCCAEQABqIAjCCAQQCggEAcLEXeH67FQESFUn4_7wnX7wN0PUrBoUsm3QQ4W5vC-qz6sXaEjSwnTV8w1o-z6X9KPLlhzMQvuS38NCNfK4uvJ4Zvfp3YsXJ25-rYtbnrYJHNvHohD-kPCCw_yZpMp21JdWigzQGuV7CtrxUhF-NNrsnUaJrE5-OpEWNt4X6nCItKIYeVcSK6XJUbEWbrNCRbvkSc4ak2ymFeMuHYJVjxh4eQbk7_ZPzodP0WvF6eUYrYeb42imVEOR8ofVLQWE5DVnb1z_TqZm4i1XkS7jMwZuBxBRw8DGdYei0lT_sAf7KST2jC0590NySB3vsBgWEVs1OdUUWA6r-Dvx9dsOQtSCVkQYQAAqZAgqUAggCEAAaiQIwggEFAoIBAQDhEBM5-6YsPWfogKtbluJoCX1WV2KdzOaQ0-OlRbBzeCzw-eQKu12c8WakHBbeCMd1I1TU64SDkDorWjXGIa_2xT6N3zzNAE50roTbPCcmeQrps26woTYfYIuqDdoxYKZNr0lvNLLW47vBr7EKqo1S4KSj7aXK_XYeEvUgIgf3nVIcNrio7VTnFmGGVQCepaL1Hi1gN4yIXjVZ06PBPZ-DxSRu6xOGbFrfKMJeMPs7KOyE-26Q3xOXdTIa1X-zYIucTd_bxUCL4BVbwW2AvbbFsaG7ISmVdGu0XUTmhXs1KrEfUVLRJhE4Dx99hAZXm1_HlYMUeJcMQ_oHOhV94ENFIJaRBhACCpYBCpEBCAMQABqGATCBgwKBgF9t2YJGAJkRRFq6fWhi3m1TFW1UOE0f6ZrfYhHAkpqGlKlh0QVfeTNPpeJhi75xXzCe6oReRUm-0DbqDNhTShC7uGUv1INYnRBQWH6E-5Fc5XrbDFSuGQw2EYjNfHy_HefHJXxQKAqPvxBDKMKkHgV58WtM6rC8jRi9sdX_ig2NIJeRBhABCpYBCpEBCAQQABqGATCBgwKBgGB4d6eLGUBv-Q6EPLehC4S-yuE2HB-_rJ7WkeYwyp-xIPolPrd-PQme2utHB4ZgpXHIu_OFksDe_0bPgZniNRSVRbl7W49DgS5Ya3kMfrYB4DnF5Fta5tn1oV6EwxYD4JONpFTenOJALPGTPawxXEfon_peiHOSBuQMu3_Vn-l1IJiRBhADCpcBCpIBCAUQABqHATCBhAKBgQCTJMKIfmfeZpaI7Q9rnsc29gdWawK7TnpVKRHws1iY7EUlYROeVcMdAwEqVM6f8BVCKLGgzQ7Gar_uuxfUGKwqEQzoppDraw4F75J464-7D5f6_oJQuGIBHZxqbMONtLjBCXRUhQW5szBLmTQ_R3qaJb5vf-h0APZfkYhq1cTttSCZkQYQBAqWAQqRAQgLEAAahgEwgYMCgYBvvGVH_M2H8qxxv94yaDYUTWbRnJ1uiIYc59KIQlfFimMPhSS7x2tqUa2-hI55JiII0Xym6GNkwLhyc1xtWChpVuIdSnbvttbrt4weDMLHqTwNOF6qAsVKGKT1Yh8yf-qb-DSmicgvFc74mBQm_6gAY1iQsf33YX8578ClhKBWHSCVkQYQAAqXAQqSAQgMEAAahwEwgYQCgYEAkuzFcd5TJu7lYWYe2hQLFfUWIIj91BvQQLa_Thln4YtGCO8gG1KJqJm-YlmJOWQG0B7H_5RVhxUxV9KpmFnsDVkzUFKOsCBaYGXc12xPVioawUlAwp5qp3QQtZyx_se97YIoLzuLr46UkLcLnkIrp-Jo46QzYi_QHq45WTm8MQ0glpEGEAIKlwEKkgEIDRAAGocBMIGEAoGBAIUzbxOknXf_rNt17_ir8JlWvrtnCWsQd1MAnl5mgArvavDtKeBYHzi5_Ak7DHlLzuA6YE8W175FxLFKpN2hkz-l-M7ltUSd8N1BvJRhK4t6WffWfC_1wPyoAbeSN2Yb1jygtZJQ8wGoXHcJQUXiMit3eFNyylwsJFj1gzAR4JCdIJeRBhABCpYBCpEBCA4QABqGATCBgwKBgFMcbEpl9ukVR6AO_R6sMyiU11I8b8MBSUCEC15iKsrVO8v_m47_TRRjWPYtQ9eZ7o1ocNJHaGUU7qqInFqtFaVnIceP6NmCsXhjs3MLrWPS8IRAy4Zf4FKmGOx3N9O2vemjUygZ9vUiSkULdVrecinRaT8JQ5RG4bUMY04XGIwFIJiRBhADCpYBCpEBCA8QABqGATCBgwKBgGpCkW-NR3li8GlRvqpq2YZGSIgm_PTyDI2Zwfw69grsBmPpVFW48Vw7xoMN35zcrojEpialB_uQzlpLYOvsMl634CRIuj-n1QE3-gaZTTTE8mg-AR4mcxnTKThPnRQpbuOlYAnriwiasWiQEMbGjq_HmWioYYxFo9USlklQn4-9IJmRBhAE"; static const TString EXPIRED_SERVICE_TICKET = "3:serv:CBAQACIZCOUBEBwaCGJiOnNlc3MxGghiYjpzZXNzMg:IwfMNJYEqStY_SixwqJnyHOMCPR7-3HHk4uylB2oVRkthtezq-OOA7QizDvx7VABLs_iTlXuD1r5IjufNei_EiV145eaa3HIg4xCdJXCojMexf2UYJz8mF2b0YzFAy6_KWagU7xo13CyKAqzJuQf5MJcSUf0ecY9hVh36cJ51aw"; static const TString MALFORMED_TVM_KEYS = "1:CpgCCpMCCAEQABqIAjCCAQQCggEAcLEXeH67FQESFUn4_7wnX7wN0PUrBoUsm3QQ4W5vC-qz6sXaEjSwnTV8w1o-z6X9KPLlhzMQvuS38NCNfK4uvJ4Zvfp3YsXJ25-rYtbnrYJHNvHohD-kPCCw_yZpMp21JdWigzQGuV7CtrxUhF-NNrsnUaJrE5-OpEWNt4X6nCItKIYeVcSK6XJUbEWbrNCRbvkSc4ak2ymFeMuHYJVjxh4eQbk7_ZPzodP0WvF6eUYrYeb42imVEOR8ofVLQWE5DVnb1z_TqZm4i1XkS7jMwZuBxBRw8DGdYei0lT_sAf7KST2jC0590NySB3vsBgWEVs1OdUUWA6r-Dvx9dsOQtSCVkQYQAAqZAgqUAggCEAAaiQIwggEFAoIBAQDhEBM5-6YsPWfogKtbluJoCX1WV2KdzOaQ0-OlRbBzeCzw-eQKu12c8WakHBbeCMd1I1TU64SDkDorWjXGIa_2xT6N3zzNAE50roTbPCcmeQrps26woTYfYIuqDdoxYKZNr0lvNLLW47vBr7EKqo1S4KSj7aXK_XYeEvUgIgf3nVIcNrio7VTnFmGGVQCepaL1Hi1gN4yIXjVZ06PBPZ-DxSRu6xOGbFrfKMJeMPs7KOyE-26Q3xOXdTIa1X-zYIucTd_bxUCL4BVbwW2AvbbFsaG7ISmVdGu0XUTmhXs1KrEfUVLRJhE4Dx99hAZXm1_HlYMUeJcMQ_oHOhV94ENFIJaRBhACCpYBCpEBCAMQABqGATCBgwKBgF9t2YJGAJkRRFq6fWhi3m1TFW1UOE0f6ZrfYhHAkpqGlKlh0QVfeTNPpeJhi75xXzCe6oReRUm-0DbqDNhTShC7uGUv1INYnRBQWH6E-5Fc5XrbDFSuGQw2EYjNfHy_HefHJXxQKAqPvxBDKMKkHgV58WtM6rC8jRi9sdX_ig2NIJeRBhABCpYBCpEBCAQQABqGATCBgwKBgGB4d6eLGUBv-Q6EPLehC4S-yuE2HB-_rJ7WkeYwyp-xIPolPrd-PQme2utHB4ZgpXHIu_OFksDe_0bPgZniNRSVRbl7W49DgS5Ya3kMfrYB4DnF5Fta5tn1oV6EwxYD4JONpFTenOJALPGTPawxXEfon_peiHOSBuQMu3_Vn-l1IJiRBhADCpcBCpIBCAUQABqHATCBhAKBgQCTJMKIfmfeZpaI7Q9rnsc29gdWawK7TnpVKRHws1iY7EUlYROeVcMdAwEqVM6f8BVCKLGgzQ7Gar_uuxfUGKwqEQzoppDraw4F75J464-7D5f6_oJQuGIBHZxqbMONtLjBCXRUhQW5szBLmTQ_R3qaJb5vf-h0APZfkYhq1cTttSCZkQYQBAqWAQqRAQgLEAAahgEwgYMCgYBvvGVH_M2H8qxxv94yaDYUTWbRnJ1uiIYc59KIQlfFimMPhSS7x2tqUa2-hI55JiII0Xym6GNkwLhyc1xtWChpVuIdSnbvttbrt4weDMLHqTwNOF6qAsVKGKT1Yh8yf-qb-DSmicgvFc74mBQm_6gAY1iQsf33YX8578ClhKBWHSCVkQYQAAqXAQqSAQgMEAAahwEwgYQCgYEAkuzFcd5TJu7lYWYe2hQLFfUWIIj91BvQQLa_Thln4YtGCO8gG1KJqJm-YlmJOWQG0B7H_5RVhxUxV9KpmFnsDVkzUFKOsCBaYGXc12xPVioawUlAwp5qp3QQtZyx_se97YIoLzuLr46UkLcLnkIrp-Jo46QzYi_QHq45WTm8MQ0glpEGEAIKlwEKkgEIDRAAGocBMIGEAoGBAIUzbxOknXf_rNt17_ir8JlWvrtnCWsQd1MAnl5mgArvavDtKeBYHzi5_Ak7DHlLzuA6YE8W175FxLFKpN2hkz-l-M7ltUSd8N1BvJRhK4t6WffWfC_1wPyoAbeSN2Yb1jygtZJQ8wGoXHcJQUXiMit3eFNyylwsJFj1gzAR4JCdIJeRBhABCpYBCpEBCA4QABqGATCBgwKBgFMcbEpl9ukVR6AO_R6sMyiU11I8b8MBSUCEC15iKsrVO8v_m47_TRRjWPYtQ9eZ7o1ocNJHaGUU7qqInFqtFaVnIceP6NmCsXhjs3MLrWPS8IRAy4Zf4FKmGOx3N9O2vemjUygZ9vUiSkULdVrecinRaT8JQ5RG4bUMY04XGIwFIJiRBhADCpYBCpEBCA8QABqGATCBgwKBgGpCkW-NR3li8GlRvqpq2YZGSIgm_PTyDI2Zwfw69grsBmPpVFW48Vw7xoMN35zcrojEpialB_uQzlpLYOvsMl634CRIuj-n1QE3-gaZTTTE8mg-AR4mcxnTKThPnRQpbuOlYAnriwiasWiQEMbGjq_HmWioYYxFo9USlklQn4-9IJmRBhAEEpUBCpIBCAYQABqHATCBhAKBgQCoZkFGm9oLTqjeXZAq6j5S6i7K20V0lNdBBLqfmFBIRuTkYxhs4vUYnWjZrKRAd5bp6_py0csmFmpl_5Yh0b-2pdo_E5PNP7LGRzKyKSiFddyykKKzVOazH8YYldDAfE8Z5HoS9e48an5JsPg0jr-TPu34DnJq3yv2a6dqiKL9zSCakQYSlQEKkgEIEBAAGocBMIGEAoGBALhrihbf3EpjDQS2sCQHazoFgN0nBbE9eesnnFTfzQELXb2gnJU9enmV_aDqaHKjgtLIPpCgn40lHrn5k6mvH5OdedyI6cCzE-N-GFp3nAq0NDJyMe0fhtIRD__CbT0ulcvkeow65ubXWfw6dBC2gR_34rdMe_L_TGRLMWjDULbNIJ"; @@ -35,20 +35,20 @@ Y_UNIT_TEST_SUITE_IMPLEMENTATION(ServiceTestSuite) { static const TString VALID_SERVICE_TICKET_3 = "3:serv:CBAQ__________9_IgUI5QEQHA:Sd6tmA1CNy2Nf7XevC3x7zr2DrGNRmcl-TxUsDtDW2xI3YXyCxBltWeg0-KtDlqyYuPOP5Jd_-XXNA12KlOPnNzrz3jm-5z8uQl6CjCcrVHUHJ75pGC8r9UOlS8cOgeXQB5dYP-fOWyo5CNadlozx1S2meCIxncbQRV1kCBi4KU"; static const TString VALID_SERVICE_TICKET_ISSUER = "3:serv:CBAQ__________9_IgsI5QEQHCDr1MT4Ag:Gu66XJT_nKnIRJjFy1561wFhIqkJItcSTGftLo7Yvi7i5wIdV-QuKT_-IMPpgjxnnGbt1Dy3Ys2TEoeJAb0TdaCYG1uy3vpoLONmTx9AenN5dx1HHf46cypLK5D3OdiTjxvqI9uGmSIKrSdRxU8gprpu5QiBDPZqVCWhM60FVSY"; - Y_UNIT_TEST(ContextExceptionsTest) { + Y_UNIT_TEST(ContextExceptionsTest) { UNIT_ASSERT_EXCEPTION(TServiceContext::TImpl(SECRET, OUR_ID, MALFORMED_TVM_KEYS), TMalformedTvmKeysException); UNIT_ASSERT_EXCEPTION(TServiceContext::TImpl(SECRET, OUR_ID, EMPTY_TVM_KEYS), TEmptyTvmKeysException); UNIT_ASSERT_EXCEPTION(TServiceContext::TImpl(MALFORMED_TVM_SECRET, OUR_ID, NUnittest::TVMKNIFE_PUBLIC_KEYS), TMalformedTvmSecretException); } - Y_UNIT_TEST(ContextSignTest) { + Y_UNIT_TEST(ContextSignTest) { TServiceContext::TImpl context(SECRET, OUR_ID, NUnittest::TVMKNIFE_PUBLIC_KEYS); UNIT_ASSERT_VALUES_EQUAL( "NsPTYak4Cfk-4vgau5lab3W4GPiTtb2etuj3y4MDPrk", context.SignCgiParamsForTvm(IntToString<10>(std::numeric_limits<time_t>::max()), "13,28", "")); } - Y_UNIT_TEST(Ticket1Test) { + Y_UNIT_TEST(Ticket1Test) { TServiceContext::TImpl context(SECRET, OUR_ID, NUnittest::TVMKNIFE_PUBLIC_KEYS); auto checkedTicket = context.Check(VALID_SERVICE_TICKET_1); UNIT_ASSERT_EQUAL(ETicketStatus::Ok, checkedTicket->GetStatus()); @@ -62,7 +62,7 @@ Y_UNIT_TEST_SUITE_IMPLEMENTATION(ServiceTestSuite) { UNIT_ASSERT(!checkedTicket->GetIssuerUid()); } - Y_UNIT_TEST(Ticket2Test) { + Y_UNIT_TEST(Ticket2Test) { TServiceContext::TImpl context(SECRET, OUR_ID, NUnittest::TVMKNIFE_PUBLIC_KEYS); auto checkedTicket = context.Check(VALID_SERVICE_TICKET_2); UNIT_ASSERT_EQUAL(ETicketStatus::Ok, checkedTicket->GetStatus()); @@ -70,7 +70,7 @@ Y_UNIT_TEST_SUITE_IMPLEMENTATION(ServiceTestSuite) { UNIT_ASSERT(!checkedTicket->GetIssuerUid()); } - Y_UNIT_TEST(Ticket3Test) { + Y_UNIT_TEST(Ticket3Test) { TServiceContext::TImpl context(SECRET, OUR_ID, NUnittest::TVMKNIFE_PUBLIC_KEYS); auto checkedTicket = context.Check(VALID_SERVICE_TICKET_3); UNIT_ASSERT_EQUAL(ETicketStatus::Ok, checkedTicket->GetStatus()); @@ -78,7 +78,7 @@ Y_UNIT_TEST_SUITE_IMPLEMENTATION(ServiceTestSuite) { UNIT_ASSERT(!checkedTicket->GetIssuerUid()); } - Y_UNIT_TEST(TicketIssuerTest) { + Y_UNIT_TEST(TicketIssuerTest) { TServiceContext::TImpl context(SECRET, OUR_ID, NUnittest::TVMKNIFE_PUBLIC_KEYS); auto checkedTicket = context.Check(VALID_SERVICE_TICKET_ISSUER); UNIT_ASSERT_EQUAL(ETicketStatus::Ok, checkedTicket->GetStatus()); @@ -88,7 +88,7 @@ Y_UNIT_TEST_SUITE_IMPLEMENTATION(ServiceTestSuite) { UNIT_ASSERT_VALUES_EQUAL(789654123, *checkedTicket->GetIssuerUid()); } - Y_UNIT_TEST(TicketErrorsTest) { + Y_UNIT_TEST(TicketErrorsTest) { TServiceContext::TImpl context(SECRET, NOT_OUR_ID, NUnittest::TVMKNIFE_PUBLIC_KEYS); auto checkedTicket1 = context.Check(VALID_SERVICE_TICKET_1); UNIT_ASSERT_EQUAL(ETicketStatus::InvalidDst, checkedTicket1->GetStatus()); @@ -100,7 +100,7 @@ Y_UNIT_TEST_SUITE_IMPLEMENTATION(ServiceTestSuite) { UNIT_ASSERT_EQUAL(ETicketStatus::Expired, checkedTicket3->GetStatus()); } - Y_UNIT_TEST(TicketExceptionTest) { + Y_UNIT_TEST(TicketExceptionTest) { TServiceContext::TImpl context(SECRET, OUR_ID, NUnittest::TVMKNIFE_PUBLIC_KEYS); auto checkedTicket = context.Check(EXPIRED_SERVICE_TICKET); @@ -113,7 +113,7 @@ Y_UNIT_TEST_SUITE_IMPLEMENTATION(ServiceTestSuite) { UNIT_ASSERT_NO_EXCEPTION(checkedTicket->DebugInfo()); } - Y_UNIT_TEST(TicketProtoTest) { + Y_UNIT_TEST(TicketProtoTest) { ticket2::Ticket protobufTicket; UNIT_ASSERT(protobufTicket.ParseFromString(NUtils::Base64url2bin(SERVICE_TICKET_PROTOBUF))); TTestServiceTicketImpl checkedTicket(ETicketStatus::Ok, std::move(protobufTicket)); @@ -122,7 +122,7 @@ Y_UNIT_TEST_SUITE_IMPLEMENTATION(ServiceTestSuite) { UNIT_ASSERT_EQUAL(SRC_ID, checkedTicket.GetSrc()); } - Y_UNIT_TEST(ResetKeysTest) { + Y_UNIT_TEST(ResetKeysTest) { TServiceContext::TImpl context(SECRET, OUR_ID, NUnittest::TVMKNIFE_PUBLIC_KEYS); context.ResetKeys(NUnittest::TVMKNIFE_PUBLIC_KEYS); auto checkedTicket = context.Check(VALID_SERVICE_TICKET_1); diff --git a/library/cpp/tvmauth/src/ut/user_ut.cpp b/library/cpp/tvmauth/src/ut/user_ut.cpp index c040e94974b..706df2df8d3 100644 --- a/library/cpp/tvmauth/src/ut/user_ut.cpp +++ b/library/cpp/tvmauth/src/ut/user_ut.cpp @@ -8,16 +8,16 @@ using namespace NTvmAuth; -Y_UNIT_TEST_SUITE(UserTestSuite) { - Y_UNIT_TEST_DECLARE(TicketProtoTest); +Y_UNIT_TEST_SUITE(UserTestSuite) { + Y_UNIT_TEST_DECLARE(TicketProtoTest); } class TTestUserTicketImpl: TCheckedUserTicket::TImpl { using TCheckedUserTicket::TImpl::TImpl; - Y_UNIT_TEST_FRIEND(UserTestSuite, TicketProtoTest); + Y_UNIT_TEST_FRIEND(UserTestSuite, TicketProtoTest); }; -Y_UNIT_TEST_SUITE_IMPLEMENTATION(UserTestSuite) { +Y_UNIT_TEST_SUITE_IMPLEMENTATION(UserTestSuite) { static const TString EMPTY_TVM_KEYS = "1:EpUBCpIBCAYQABqHATCBhAKBgQCoZkFGm9oLTqjeXZAq6j5S6i7K20V0lNdBBLqfmFBIRuTkYxhs4vUYnWjZrKRAd5bp6_py0csmFmpl_5Yh0b-2pdo_E5PNP7LGRzKyKSiFddyykKKzVOazH8YYldDAfE8Z5HoS9e48an5JsPg0jr-TPu34DnJq3yv2a6dqiKL9zSCakQY"; static const TString EXPIRED_USER_TICKET = "3:user:CA0QABokCgMIyAMKAgh7EMgDGghiYjpzZXNzMRoIYmI6c2VzczIgEigB:D0CmYVwWg91LDYejjeQ2UP8AeiA_mr1q1CUD_lfJ9zQSEYEOYGDTafg4Um2rwOOvQnsD1JHM4zHyMUJ6Jtp9GAm5pmhbXBBZqaCcJpyxLTEC8a81MhJFCCJRvu_G1FiAgRgB25gI3HIbkvHFUEqAIC_nANy7NFQnbKk2S-EQPGY"; static const TString MALFORMED_TVM_KEYS = "1:CpgCCpMCCAEQABqIAjCCAQQCggEAcLEXeH67FQESFUn4_7wnX7wN0PUrBoUsm3QQ4W5vC-qz6sXaEjSwnTV8w1o-z6X9KPLlhzMQvuS38NCNfK4uvJ4Zvfp3YsXJ25-rYtbnrYJHNvHohD-kPCCw_yZpMp21JdWigzQGuV7CtrxUhF-NNrsnUaJrE5-OpEWNt4X6nCItKIYeVcSK6XJUbEWbrNCRbvkSc4ak2ymFeMuHYJVjxh4eQbk7_ZPzodP0WvF6eUYrYeb42imVEOR8ofVLQWE5DVnb1z_TqZm4i1XkS7jMwZuBxBRw8DGdYei0lT_sAf7KST2jC0590NySB3vsBgWEVs1OdUUWA6r-Dvx9dsOQtSCVkQYQAAqZAgqUAggCEAAaiQIwggEFAoIBAQDhEBM5-6YsPWfogKtbluJoCX1WV2KdzOaQ0-OlRbBzeCzw-eQKu12c8WakHBbeCMd1I1TU64SDkDorWjXGIa_2xT6N3zzNAE50roTbPCcmeQrps26woTYfYIuqDdoxYKZNr0lvNLLW47vBr7EKqo1S4KSj7aXK_XYeEvUgIgf3nVIcNrio7VTnFmGGVQCepaL1Hi1gN4yIXjVZ06PBPZ-DxSRu6xOGbFrfKMJeMPs7KOyE-26Q3xOXdTIa1X-zYIucTd_bxUCL4BVbwW2AvbbFsaG7ISmVdGu0XUTmhXs1KrEfUVLRJhE4Dx99hAZXm1_HlYMUeJcMQ_oHOhV94ENFIJaRBhACCpYBCpEBCAMQABqGATCBgwKBgF9t2YJGAJkRRFq6fWhi3m1TFW1UOE0f6ZrfYhHAkpqGlKlh0QVfeTNPpeJhi75xXzCe6oReRUm-0DbqDNhTShC7uGUv1INYnRBQWH6E-5Fc5XrbDFSuGQw2EYjNfHy_HefHJXxQKAqPvxBDKMKkHgV58WtM6rC8jRi9sdX_ig2NIJeRBhABCpYBCpEBCAQQABqGATCBgwKBgGB4d6eLGUBv-Q6EPLehC4S-yuE2HB-_rJ7WkeYwyp-xIPolPrd-PQme2utHB4ZgpXHIu_OFksDe_0bPgZniNRSVRbl7W49DgS5Ya3kMfrYB4DnF5Fta5tn1oV6EwxYD4JONpFTenOJALPGTPawxXEfon_peiHOSBuQMu3_Vn-l1IJiRBhADCpcBCpIBCAUQABqHATCBhAKBgQCTJMKIfmfeZpaI7Q9rnsc29gdWawK7TnpVKRHws1iY7EUlYROeVcMdAwEqVM6f8BVCKLGgzQ7Gar_uuxfUGKwqEQzoppDraw4F75J464-7D5f6_oJQuGIBHZxqbMONtLjBCXRUhQW5szBLmTQ_R3qaJb5vf-h0APZfkYhq1cTttSCZkQYQBAqWAQqRAQgLEAAahgEwgYMCgYBvvGVH_M2H8qxxv94yaDYUTWbRnJ1uiIYc59KIQlfFimMPhSS7x2tqUa2-hI55JiII0Xym6GNkwLhyc1xtWChpVuIdSnbvttbrt4weDMLHqTwNOF6qAsVKGKT1Yh8yf-qb-DSmicgvFc74mBQm_6gAY1iQsf33YX8578ClhKBWHSCVkQYQAAqXAQqSAQgMEAAahwEwgYQCgYEAkuzFcd5TJu7lYWYe2hQLFfUWIIj91BvQQLa_Thln4YtGCO8gG1KJqJm-YlmJOWQG0B7H_5RVhxUxV9KpmFnsDVkzUFKOsCBaYGXc12xPVioawUlAwp5qp3QQtZyx_se97YIoLzuLr46UkLcLnkIrp-Jo46QzYi_QHq45WTm8MQ0glpEGEAIKlwEKkgEIDRAAGocBMIGEAoGBAIUzbxOknXf_rNt17_ir8JlWvrtnCWsQd1MAnl5mgArvavDtKeBYHzi5_Ak7DHlLzuA6YE8W175FxLFKpN2hkz-l-M7ltUSd8N1BvJRhK4t6WffWfC_1wPyoAbeSN2Yb1jygtZJQ8wGoXHcJQUXiMit3eFNyylwsJFj1gzAR4JCdIJeRBhABCpYBCpEBCA4QABqGATCBgwKBgFMcbEpl9ukVR6AO_R6sMyiU11I8b8MBSUCEC15iKsrVO8v_m47_TRRjWPYtQ9eZ7o1ocNJHaGUU7qqInFqtFaVnIceP6NmCsXhjs3MLrWPS8IRAy4Zf4FKmGOx3N9O2vemjUygZ9vUiSkULdVrecinRaT8JQ5RG4bUMY04XGIwFIJiRBhADCpYBCpEBCA8QABqGATCBgwKBgGpCkW-NR3li8GlRvqpq2YZGSIgm_PTyDI2Zwfw69grsBmPpVFW48Vw7xoMN35zcrojEpialB_uQzlpLYOvsMl634CRIuj-n1QE3-gaZTTTE8mg-AR4mcxnTKThPnRQpbuOlYAnriwiasWiQEMbGjq_HmWioYYxFo9USlklQn4-9IJmRBhAEEpUBCpIBCAYQABqHATCBhAKBgQCoZkFGm9oLTqjeXZAq6j5S6i7K20V0lNdBBLqfmFBIRuTkYxhs4vUYnWjZrKRAd5bp6_py0csmFmpl_5Yh0b-2pdo_E5PNP7LGRzKyKSiFddyykKKzVOazH8YYldDAfE8Z5HoS9e48an5JsPg0jr-TPu34DnJq3yv2a6dqiKL9zSCakQYSlQEKkgEIEBAAGocBMIGEAoGBALhrihbf3EpjDQS2sCQHazoFgN0nBbE9eesnnFTfzQELXb2gnJU9enmV_aDqaHKjgtLIPpCgn40lHrn5k6mvH5OdedyI6cCzE-N-GFp3nAq0NDJyMe0fhtIRD__CbT0ulcvkeow65ubXWfw6dBC2gR_34rdMe_L_TGRLMWjDULbNIJ"; @@ -27,14 +27,14 @@ Y_UNIT_TEST_SUITE_IMPLEMENTATION(UserTestSuite) { static const TString VALID_USER_TICKET_2 = "3:user:CA0Q__________9_GhAKAwjIAwoCCHsQyAMgEigB:KRibGYTJUA2ns0Fn7VYqeMZ1-GdscB1o9pRzELyr7QJrJsfsE8Y_HoVvB8Npr-oalv6AXOpagSc8HpZjAQz8zKMAVE_tI0tL-9DEsHirpawEbpy7OWV7-k18o1m-RaDaKeTlIB45KHbBul1-9aeKkortBfbbXtz_Qy9r_mfFPiQ"; static const TString VALID_USER_TICKET_3 = "3:user:CA0Q__________9_Go8bCgIIAAoCCAEKAggCCgIIAwoCCAQKAggFCgIIBgoCCAcKAggICgIICQoCCAoKAggLCgIIDAoCCA0KAggOCgIIDwoCCBAKAggRCgIIEgoCCBMKAggUCgIIFQoCCBYKAggXCgIIGAoCCBkKAggaCgIIGwoCCBwKAggdCgIIHgoCCB8KAgggCgIIIQoCCCIKAggjCgIIJAoCCCUKAggmCgIIJwoCCCgKAggpCgIIKgoCCCsKAggsCgIILQoCCC4KAggvCgIIMAoCCDEKAggyCgIIMwoCCDQKAgg1CgIINgoCCDcKAgg4CgIIOQoCCDoKAgg7CgIIPAoCCD0KAgg-CgIIPwoCCEAKAghBCgIIQgoCCEMKAghECgIIRQoCCEYKAghHCgIISAoCCEkKAghKCgIISwoCCEwKAghNCgIITgoCCE8KAghQCgIIUQoCCFIKAghTCgIIVAoCCFUKAghWCgIIVwoCCFgKAghZCgIIWgoCCFsKAghcCgIIXQoCCF4KAghfCgIIYAoCCGEKAghiCgIIYwoCCGQKAghlCgIIZgoCCGcKAghoCgIIaQoCCGoKAghrCgIIbAoCCG0KAghuCgIIbwoCCHAKAghxCgIIcgoCCHMKAgh0CgIIdQoCCHYKAgh3CgIIeAoCCHkKAgh6CgIIewoCCHwKAgh9CgIIfgoCCH8KAwiAAQoDCIEBCgMIggEKAwiDAQoDCIQBCgMIhQEKAwiGAQoDCIcBCgMIiAEKAwiJAQoDCIoBCgMIiwEKAwiMAQoDCI0BCgMIjgEKAwiPAQoDCJABCgMIkQEKAwiSAQoDCJMBCgMIlAEKAwiVAQoDCJYBCgMIlwEKAwiYAQoDCJkBCgMImgEKAwibAQoDCJwBCgMInQEKAwieAQoDCJ8BCgMIoAEKAwihAQoDCKIBCgMIowEKAwikAQoDCKUBCgMIpgEKAwinAQoDCKgBCgMIqQEKAwiqAQoDCKsBCgMIrAEKAwitAQoDCK4BCgMIrwEKAwiwAQoDCLEBCgMIsgEKAwizAQoDCLQBCgMItQEKAwi2AQoDCLcBCgMIuAEKAwi5AQoDCLoBCgMIuwEKAwi8AQoDCL0BCgMIvgEKAwi_AQoDCMABCgMIwQEKAwjCAQoDCMMBCgMIxAEKAwjFAQoDCMYBCgMIxwEKAwjIAQoDCMkBCgMIygEKAwjLAQoDCMwBCgMIzQEKAwjOAQoDCM8BCgMI0AEKAwjRAQoDCNIBCgMI0wEKAwjUAQoDCNUBCgMI1gEKAwjXAQoDCNgBCgMI2QEKAwjaAQoDCNsBCgMI3AEKAwjdAQoDCN4BCgMI3wEKAwjgAQoDCOEBCgMI4gEKAwjjAQoDCOQBCgMI5QEKAwjmAQoDCOcBCgMI6AEKAwjpAQoDCOoBCgMI6wEKAwjsAQoDCO0BCgMI7gEKAwjvAQoDCPABCgMI8QEKAwjyAQoDCPMBCgMI9AEKAwj1AQoDCPYBCgMI9wEKAwj4AQoDCPkBCgMI-gEKAwj7AQoDCPwBCgMI_QEKAwj-AQoDCP8BCgMIgAIKAwiBAgoDCIICCgMIgwIKAwiEAgoDCIUCCgMIhgIKAwiHAgoDCIgCCgMIiQIKAwiKAgoDCIsCCgMIjAIKAwiNAgoDCI4CCgMIjwIKAwiQAgoDCJECCgMIkgIKAwiTAgoDCJQCCgMIlQIKAwiWAgoDCJcCCgMImAIKAwiZAgoDCJoCCgMImwIKAwicAgoDCJ0CCgMIngIKAwifAgoDCKACCgMIoQIKAwiiAgoDCKMCCgMIpAIKAwilAgoDCKYCCgMIpwIKAwioAgoDCKkCCgMIqgIKAwirAgoDCKwCCgMIrQIKAwiuAgoDCK8CCgMIsAIKAwixAgoDCLICCgMIswIKAwi0AgoDCLUCCgMItgIKAwi3AgoDCLgCCgMIuQIKAwi6AgoDCLsCCgMIvAIKAwi9AgoDCL4CCgMIvwIKAwjAAgoDCMECCgMIwgIKAwjDAgoDCMQCCgMIxQIKAwjGAgoDCMcCCgMIyAIKAwjJAgoDCMoCCgMIywIKAwjMAgoDCM0CCgMIzgIKAwjPAgoDCNACCgMI0QIKAwjSAgoDCNMCCgMI1AIKAwjVAgoDCNYCCgMI1wIKAwjYAgoDCNkCCgMI2gIKAwjbAgoDCNwCCgMI3QIKAwjeAgoDCN8CCgMI4AIKAwjhAgoDCOICCgMI4wIKAwjkAgoDCOUCCgMI5gIKAwjnAgoDCOgCCgMI6QIKAwjqAgoDCOsCCgMI7AIKAwjtAgoDCO4CCgMI7wIKAwjwAgoDCPECCgMI8gIKAwjzAgoDCPQCCgMI9QIKAwj2AgoDCPcCCgMI-AIKAwj5AgoDCPoCCgMI-wIKAwj8AgoDCP0CCgMI_gIKAwj_AgoDCIADCgMIgQMKAwiCAwoDCIMDCgMIhAMKAwiFAwoDCIYDCgMIhwMKAwiIAwoDCIkDCgMIigMKAwiLAwoDCIwDCgMIjQMKAwiOAwoDCI8DCgMIkAMKAwiRAwoDCJIDCgMIkwMKAwiUAwoDCJUDCgMIlgMKAwiXAwoDCJgDCgMImQMKAwiaAwoDCJsDCgMInAMKAwidAwoDCJ4DCgMInwMKAwigAwoDCKEDCgMIogMKAwijAwoDCKQDCgMIpQMKAwimAwoDCKcDCgMIqAMKAwipAwoDCKoDCgMIqwMKAwisAwoDCK0DCgMIrgMKAwivAwoDCLADCgMIsQMKAwiyAwoDCLMDCgMItAMKAwi1AwoDCLYDCgMItwMKAwi4AwoDCLkDCgMIugMKAwi7AwoDCLwDCgMIvQMKAwi-AwoDCL8DCgMIwAMKAwjBAwoDCMIDCgMIwwMKAwjEAwoDCMUDCgMIxgMKAwjHAwoDCMgDCgMIyQMKAwjKAwoDCMsDCgMIzAMKAwjNAwoDCM4DCgMIzwMKAwjQAwoDCNEDCgMI0gMKAwjTAwoDCNQDCgMI1QMKAwjWAwoDCNcDCgMI2AMKAwjZAwoDCNoDCgMI2wMKAwjcAwoDCN0DCgMI3gMKAwjfAwoDCOADCgMI4QMKAwjiAwoDCOMDCgMI5AMKAwjlAwoDCOYDCgMI5wMKAwjoAwoDCOkDCgMI6gMKAwjrAwoDCOwDCgMI7QMKAwjuAwoDCO8DCgMI8AMKAwjxAwoDCPIDCgMI8wMQyAMaCGJiOnNlc3MxGgliYjpzZXNzMTAaCmJiOnNlc3MxMDAaCWJiOnNlc3MxMRoJYmI6c2VzczEyGgliYjpzZXNzMTMaCWJiOnNlc3MxNBoJYmI6c2VzczE1GgliYjpzZXNzMTYaCWJiOnNlc3MxNxoJYmI6c2VzczE4GgliYjpzZXNzMTkaCGJiOnNlc3MyGgliYjpzZXNzMjAaCWJiOnNlc3MyMRoJYmI6c2VzczIyGgliYjpzZXNzMjMaCWJiOnNlc3MyNBoJYmI6c2VzczI1GgliYjpzZXNzMjYaCWJiOnNlc3MyNxoJYmI6c2VzczI4GgliYjpzZXNzMjkaCGJiOnNlc3MzGgliYjpzZXNzMzAaCWJiOnNlc3MzMRoJYmI6c2VzczMyGgliYjpzZXNzMzMaCWJiOnNlc3MzNBoJYmI6c2VzczM1GgliYjpzZXNzMzYaCWJiOnNlc3MzNxoJYmI6c2VzczM4GgliYjpzZXNzMzkaCGJiOnNlc3M0GgliYjpzZXNzNDAaCWJiOnNlc3M0MRoJYmI6c2VzczQyGgliYjpzZXNzNDMaCWJiOnNlc3M0NBoJYmI6c2VzczQ1GgliYjpzZXNzNDYaCWJiOnNlc3M0NxoJYmI6c2VzczQ4GgliYjpzZXNzNDkaCGJiOnNlc3M1GgliYjpzZXNzNTAaCWJiOnNlc3M1MRoJYmI6c2VzczUyGgliYjpzZXNzNTMaCWJiOnNlc3M1NBoJYmI6c2VzczU1GgliYjpzZXNzNTYaCWJiOnNlc3M1NxoJYmI6c2VzczU4GgliYjpzZXNzNTkaCGJiOnNlc3M2GgliYjpzZXNzNjAaCWJiOnNlc3M2MRoJYmI6c2VzczYyGgliYjpzZXNzNjMaCWJiOnNlc3M2NBoJYmI6c2VzczY1GgliYjpzZXNzNjYaCWJiOnNlc3M2NxoJYmI6c2VzczY4GgliYjpzZXNzNjkaCGJiOnNlc3M3GgliYjpzZXNzNzAaCWJiOnNlc3M3MRoJYmI6c2VzczcyGgliYjpzZXNzNzMaCWJiOnNlc3M3NBoJYmI6c2Vzczc1GgliYjpzZXNzNzYaCWJiOnNlc3M3NxoJYmI6c2Vzczc4GgliYjpzZXNzNzkaCGJiOnNlc3M4GgliYjpzZXNzODAaCWJiOnNlc3M4MRoJYmI6c2VzczgyGgliYjpzZXNzODMaCWJiOnNlc3M4NBoJYmI6c2Vzczg1GgliYjpzZXNzODYaCWJiOnNlc3M4NxoJYmI6c2Vzczg4GgliYjpzZXNzODkaCGJiOnNlc3M5GgliYjpzZXNzOTAaCWJiOnNlc3M5MRoJYmI6c2VzczkyGgliYjpzZXNzOTMaCWJiOnNlc3M5NBoJYmI6c2Vzczk1GgliYjpzZXNzOTYaCWJiOnNlc3M5NxoJYmI6c2Vzczk4GgliYjpzZXNzOTkgEigB:CX8PIOrxJnQqFXl7wAsiHJ_1VGjoI-asNlCXb8SE8jtI2vdh9x6CqbAurSgIlAAEgotVP-nuUR38x_a9YJuXzmG5AvJ458apWQtODHIDIX6ZaIwMxjS02R7S5LNqXa0gAuU_R6bCWpZdWe2uLMkdpu5KHbDgW08g-uaP_nceDOk"; - Y_UNIT_TEST(ContextText) { + Y_UNIT_TEST(ContextText) { TUserContext::TImpl context(EBlackboxEnv::Prod, NUnittest::TVMKNIFE_PUBLIC_KEYS); UNIT_ASSERT_EQUAL(2, context.GetKeys().size()); UNIT_ASSERT_NO_EXCEPTION(context.ResetKeys(NUnittest::TVMKNIFE_PUBLIC_KEYS)); UNIT_ASSERT_EQUAL(2, context.GetKeys().size()); } - Y_UNIT_TEST(ContextEnvTest) { + Y_UNIT_TEST(ContextEnvTest) { TUserContext::TImpl p(EBlackboxEnv::Prod, NUnittest::TVMKNIFE_PUBLIC_KEYS); UNIT_ASSERT_EQUAL(2, p.GetKeys().size()); UNIT_ASSERT(p.IsAllowed(tvm_keys::Prod)); @@ -76,13 +76,13 @@ Y_UNIT_TEST_SUITE_IMPLEMENTATION(UserTestSuite) { UNIT_ASSERT(s.IsAllowed(tvm_keys::Stress)); } - Y_UNIT_TEST(ContextExceptionsText) { + Y_UNIT_TEST(ContextExceptionsText) { UNIT_ASSERT_EXCEPTION(TUserContext::TImpl(EBlackboxEnv::Prod, EMPTY_TVM_KEYS), TEmptyTvmKeysException); UNIT_ASSERT_EXCEPTION(TUserContext::TImpl(EBlackboxEnv::Prod, MALFORMED_TVM_KEYS), TMalformedTvmKeysException); UNIT_ASSERT_EXCEPTION(TUserContext::TImpl(EBlackboxEnv::Prod, "adcvxcv./-+"), TMalformedTvmKeysException); } - Y_UNIT_TEST(Ticket1Test) { + Y_UNIT_TEST(Ticket1Test) { TUserContext::TImpl context(EBlackboxEnv::Test, NUnittest::TVMKNIFE_PUBLIC_KEYS); auto checkedTicket = context.Check(VALID_USER_TICKET_1); UNIT_ASSERT_EQUAL(ETicketStatus::Ok, checkedTicket->GetStatus()); @@ -96,21 +96,21 @@ Y_UNIT_TEST_SUITE_IMPLEMENTATION(UserTestSuite) { UNIT_ASSERT_EQUAL("ticket_type=user;expiration_time=9223372036854775807;scope=bb:sess1;scope=bb:sess2;default_uid=456;uid=456;uid=123;env=Test;", checkedTicket->DebugInfo()); } - Y_UNIT_TEST(Ticket2Test) { + Y_UNIT_TEST(Ticket2Test) { TUserContext::TImpl context(EBlackboxEnv::Test, NUnittest::TVMKNIFE_PUBLIC_KEYS); auto checkedTicket = context.Check(VALID_USER_TICKET_2); UNIT_ASSERT_EQUAL(ETicketStatus::Ok, checkedTicket->GetStatus()); UNIT_ASSERT_VALUES_EQUAL("ticket_type=user;expiration_time=9223372036854775807;default_uid=456;uid=456;uid=123;env=Test;", checkedTicket->DebugInfo()); } - Y_UNIT_TEST(Ticket3Test) { + Y_UNIT_TEST(Ticket3Test) { TUserContext::TImpl context(EBlackboxEnv::Test, NUnittest::TVMKNIFE_PUBLIC_KEYS); auto checkedTicket = context.Check(VALID_USER_TICKET_3); UNIT_ASSERT_EQUAL(ETicketStatus::Ok, checkedTicket->GetStatus()); UNIT_ASSERT_VALUES_EQUAL("ticket_type=user;expiration_time=9223372036854775807;scope=bb:sess1;scope=bb:sess10;scope=bb:sess100;scope=bb:sess11;scope=bb:sess12;scope=bb:sess13;scope=bb:sess14;scope=bb:sess15;scope=bb:sess16;scope=bb:sess17;scope=bb:sess18;scope=bb:sess19;scope=bb:sess2;scope=bb:sess20;scope=bb:sess21;scope=bb:sess22;scope=bb:sess23;scope=bb:sess24;scope=bb:sess25;scope=bb:sess26;scope=bb:sess27;scope=bb:sess28;scope=bb:sess29;scope=bb:sess3;scope=bb:sess30;scope=bb:sess31;scope=bb:sess32;scope=bb:sess33;scope=bb:sess34;scope=bb:sess35;scope=bb:sess36;scope=bb:sess37;scope=bb:sess38;scope=bb:sess39;scope=bb:sess4;scope=bb:sess40;scope=bb:sess41;scope=bb:sess42;scope=bb:sess43;scope=bb:sess44;scope=bb:sess45;scope=bb:sess46;scope=bb:sess47;scope=bb:sess48;scope=bb:sess49;scope=bb:sess5;scope=bb:sess50;scope=bb:sess51;scope=bb:sess52;scope=bb:sess53;scope=bb:sess54;scope=bb:sess55;scope=bb:sess56;scope=bb:sess57;scope=bb:sess58;scope=bb:sess59;scope=bb:sess6;scope=bb:sess60;scope=bb:sess61;scope=bb:sess62;scope=bb:sess63;scope=bb:sess64;scope=bb:sess65;scope=bb:sess66;scope=bb:sess67;scope=bb:sess68;scope=bb:sess69;scope=bb:sess7;scope=bb:sess70;scope=bb:sess71;scope=bb:sess72;scope=bb:sess73;scope=bb:sess74;scope=bb:sess75;scope=bb:sess76;scope=bb:sess77;scope=bb:sess78;scope=bb:sess79;scope=bb:sess8;scope=bb:sess80;scope=bb:sess81;scope=bb:sess82;scope=bb:sess83;scope=bb:sess84;scope=bb:sess85;scope=bb:sess86;scope=bb:sess87;scope=bb:sess88;scope=bb:sess89;scope=bb:sess9;scope=bb:sess90;scope=bb:sess91;scope=bb:sess92;scope=bb:sess93;scope=bb:sess94;scope=bb:sess95;scope=bb:sess96;scope=bb:sess97;scope=bb:sess98;scope=bb:sess99;default_uid=456;uid=0;uid=1;uid=2;uid=3;uid=4;uid=5;uid=6;uid=7;uid=8;uid=9;uid=10;uid=11;uid=12;uid=13;uid=14;uid=15;uid=16;uid=17;uid=18;uid=19;uid=20;uid=21;uid=22;uid=23;uid=24;uid=25;uid=26;uid=27;uid=28;uid=29;uid=30;uid=31;uid=32;uid=33;uid=34;uid=35;uid=36;uid=37;uid=38;uid=39;uid=40;uid=41;uid=42;uid=43;uid=44;uid=45;uid=46;uid=47;uid=48;uid=49;uid=50;uid=51;uid=52;uid=53;uid=54;uid=55;uid=56;uid=57;uid=58;uid=59;uid=60;uid=61;uid=62;uid=63;uid=64;uid=65;uid=66;uid=67;uid=68;uid=69;uid=70;uid=71;uid=72;uid=73;uid=74;uid=75;uid=76;uid=77;uid=78;uid=79;uid=80;uid=81;uid=82;uid=83;uid=84;uid=85;uid=86;uid=87;uid=88;uid=89;uid=90;uid=91;uid=92;uid=93;uid=94;uid=95;uid=96;uid=97;uid=98;uid=99;uid=100;uid=101;uid=102;uid=103;uid=104;uid=105;uid=106;uid=107;uid=108;uid=109;uid=110;uid=111;uid=112;uid=113;uid=114;uid=115;uid=116;uid=117;uid=118;uid=119;uid=120;uid=121;uid=122;uid=123;uid=124;uid=125;uid=126;uid=127;uid=128;uid=129;uid=130;uid=131;uid=132;uid=133;uid=134;uid=135;uid=136;uid=137;uid=138;uid=139;uid=140;uid=141;uid=142;uid=143;uid=144;uid=145;uid=146;uid=147;uid=148;uid=149;uid=150;uid=151;uid=152;uid=153;uid=154;uid=155;uid=156;uid=157;uid=158;uid=159;uid=160;uid=161;uid=162;uid=163;uid=164;uid=165;uid=166;uid=167;uid=168;uid=169;uid=170;uid=171;uid=172;uid=173;uid=174;uid=175;uid=176;uid=177;uid=178;uid=179;uid=180;uid=181;uid=182;uid=183;uid=184;uid=185;uid=186;uid=187;uid=188;uid=189;uid=190;uid=191;uid=192;uid=193;uid=194;uid=195;uid=196;uid=197;uid=198;uid=199;uid=200;uid=201;uid=202;uid=203;uid=204;uid=205;uid=206;uid=207;uid=208;uid=209;uid=210;uid=211;uid=212;uid=213;uid=214;uid=215;uid=216;uid=217;uid=218;uid=219;uid=220;uid=221;uid=222;uid=223;uid=224;uid=225;uid=226;uid=227;uid=228;uid=229;uid=230;uid=231;uid=232;uid=233;uid=234;uid=235;uid=236;uid=237;uid=238;uid=239;uid=240;uid=241;uid=242;uid=243;uid=244;uid=245;uid=246;uid=247;uid=248;uid=249;uid=250;uid=251;uid=252;uid=253;uid=254;uid=255;uid=256;uid=257;uid=258;uid=259;uid=260;uid=261;uid=262;uid=263;uid=264;uid=265;uid=266;uid=267;uid=268;uid=269;uid=270;uid=271;uid=272;uid=273;uid=274;uid=275;uid=276;uid=277;uid=278;uid=279;uid=280;uid=281;uid=282;uid=283;uid=284;uid=285;uid=286;uid=287;uid=288;uid=289;uid=290;uid=291;uid=292;uid=293;uid=294;uid=295;uid=296;uid=297;uid=298;uid=299;uid=300;uid=301;uid=302;uid=303;uid=304;uid=305;uid=306;uid=307;uid=308;uid=309;uid=310;uid=311;uid=312;uid=313;uid=314;uid=315;uid=316;uid=317;uid=318;uid=319;uid=320;uid=321;uid=322;uid=323;uid=324;uid=325;uid=326;uid=327;uid=328;uid=329;uid=330;uid=331;uid=332;uid=333;uid=334;uid=335;uid=336;uid=337;uid=338;uid=339;uid=340;uid=341;uid=342;uid=343;uid=344;uid=345;uid=346;uid=347;uid=348;uid=349;uid=350;uid=351;uid=352;uid=353;uid=354;uid=355;uid=356;uid=357;uid=358;uid=359;uid=360;uid=361;uid=362;uid=363;uid=364;uid=365;uid=366;uid=367;uid=368;uid=369;uid=370;uid=371;uid=372;uid=373;uid=374;uid=375;uid=376;uid=377;uid=378;uid=379;uid=380;uid=381;uid=382;uid=383;uid=384;uid=385;uid=386;uid=387;uid=388;uid=389;uid=390;uid=391;uid=392;uid=393;uid=394;uid=395;uid=396;uid=397;uid=398;uid=399;uid=400;uid=401;uid=402;uid=403;uid=404;uid=405;uid=406;uid=407;uid=408;uid=409;uid=410;uid=411;uid=412;uid=413;uid=414;uid=415;uid=416;uid=417;uid=418;uid=419;uid=420;uid=421;uid=422;uid=423;uid=424;uid=425;uid=426;uid=427;uid=428;uid=429;uid=430;uid=431;uid=432;uid=433;uid=434;uid=435;uid=436;uid=437;uid=438;uid=439;uid=440;uid=441;uid=442;uid=443;uid=444;uid=445;uid=446;uid=447;uid=448;uid=449;uid=450;uid=451;uid=452;uid=453;uid=454;uid=455;uid=456;uid=457;uid=458;uid=459;uid=460;uid=461;uid=462;uid=463;uid=464;uid=465;uid=466;uid=467;uid=468;uid=469;uid=470;uid=471;uid=472;uid=473;uid=474;uid=475;uid=476;uid=477;uid=478;uid=479;uid=480;uid=481;uid=482;uid=483;uid=484;uid=485;uid=486;uid=487;uid=488;uid=489;uid=490;uid=491;uid=492;uid=493;uid=494;uid=495;uid=496;uid=497;uid=498;uid=499;env=Test;", checkedTicket->DebugInfo()); } - Y_UNIT_TEST(TicketExceptionsTest) { + Y_UNIT_TEST(TicketExceptionsTest) { TUserContext::TImpl contextTest(EBlackboxEnv::Test, NUnittest::TVMKNIFE_PUBLIC_KEYS); auto checkedTicket1 = contextTest.Check(UNSUPPORTED_VERSION_USER_TICKET); UNIT_ASSERT_EQUAL(ETicketStatus::UnsupportedVersion, checkedTicket1->GetStatus()); @@ -131,7 +131,7 @@ Y_UNIT_TEST_SUITE_IMPLEMENTATION(UserTestSuite) { UNIT_ASSERT_NO_EXCEPTION(checkedTicket3->GetStatus()); } - Y_UNIT_TEST(TicketProtoTest) { + Y_UNIT_TEST(TicketProtoTest) { ticket2::Ticket protobufTicket; UNIT_ASSERT(protobufTicket.ParseFromString(NUtils::Base64url2bin(USER_TICKET_PROTOBUF))); TTestUserTicketImpl userTicket(ETicketStatus::Ok, std::move(protobufTicket)); @@ -145,7 +145,7 @@ Y_UNIT_TEST_SUITE_IMPLEMENTATION(UserTestSuite) { UNIT_ASSERT(!userTicket.HasScope("bb:sess3")); } - Y_UNIT_TEST(ResetKeysTest) { + Y_UNIT_TEST(ResetKeysTest) { TUserContext::TImpl context(EBlackboxEnv::Test, NUnittest::TVMKNIFE_PUBLIC_KEYS); context.ResetKeys(NUnittest::TVMKNIFE_PUBLIC_KEYS); auto checkedTicket = context.Check(VALID_USER_TICKET_1); diff --git a/library/cpp/tvmauth/src/ut/utils_ut.cpp b/library/cpp/tvmauth/src/ut/utils_ut.cpp index c9cb81c36fa..676804ce7de 100644 --- a/library/cpp/tvmauth/src/ut/utils_ut.cpp +++ b/library/cpp/tvmauth/src/ut/utils_ut.cpp @@ -4,12 +4,12 @@ #include <util/generic/maybe.h> -Y_UNIT_TEST_SUITE(UtilsTestSuite) { +Y_UNIT_TEST_SUITE(UtilsTestSuite) { static const TString VALID_SERVICE_TICKET_1 = "3:serv:CBAQ__________9_IhkI5QEQHBoIYmI6c2VzczEaCGJiOnNlc3My:WUPx1cTf05fjD1exB35T5j2DCHWH1YaLJon_a4rN-D7JfXHK1Ai4wM4uSfboHD9xmGQH7extqtlEk1tCTCGm5qbRVloJwWzCZBXo3zKX6i1oBYP_89WcjCNPVe1e8jwGdLsnu6PpxL5cn0xCksiStILH5UmDR6xfkJdnmMG94o8"; static const TString EXPIRED_SERVICE_TICKET = "3:serv:CBAQACIZCOUBEBwaCGJiOnNlc3MxGghiYjpzZXNzMg:IwfMNJYEqStY_SixwqJnyHOMCPR7-3HHk4uylB2oVRkthtezq-OOA7QizDvx7VABLs_iTlXuD1r5IjufNei_EiV145eaa3HIg4xCdJXCojMexf2UYJz8mF2b0YzFAy6_KWagU7xo13CyKAqzJuQf5MJcSUf0ecY9hVh36cJ51aw"; using namespace NTvmAuth; - Y_UNIT_TEST(base64Test) { + Y_UNIT_TEST(base64Test) { UNIT_ASSERT_VALUES_EQUAL("-hHx", NUtils::Bin2base64url("\xfa\x11\xf1")); UNIT_ASSERT_VALUES_EQUAL("-hHx_g", NUtils::Bin2base64url("\xfa\x11\xf1\xfe")); UNIT_ASSERT_VALUES_EQUAL("-hHx_v8", NUtils::Bin2base64url("\xfa\x11\xf1\xfe\xff")); @@ -36,7 +36,7 @@ Y_UNIT_TEST_SUITE(UtilsTestSuite) { NUtils::Base64url2bin(("VGhlIE1hZ2ljIFdvcmRzIGFyZSBTcXVlYW1pc2ggT3NzaWZyYWdl"))); } - Y_UNIT_TEST(sign) { + Y_UNIT_TEST(sign) { UNIT_ASSERT_VALUES_EQUAL("wkGfeuopf709ozPAeGcDMqtZXPzsWvuNJ1BL586dSug", NUtils::SignCgiParamsForTvm(NUtils::Base64url2bin("GRMJrKnj4fOVnvOqe-WyD1"), "1490000000", diff --git a/library/cpp/unicode/normalization/custom_encoder.cpp b/library/cpp/unicode/normalization/custom_encoder.cpp index c6f186405f1..72279027910 100644 --- a/library/cpp/unicode/normalization/custom_encoder.cpp +++ b/library/cpp/unicode/normalization/custom_encoder.cpp @@ -15,7 +15,7 @@ void TCustomEncoder::addToTable(wchar32 ucode, unsigned char code, const CodePag if (Table[plane][pos] == 0) { Table[plane][pos] = code; } else { - Y_ASSERT(target && *target->Names); + Y_ASSERT(target && *target->Names); if (static_cast<unsigned char>(Table[plane][pos]) > 127 && code) { Cerr << "WARNING: Only lower part of ASCII should have duplicate encodings " << target->Names[0] @@ -37,7 +37,7 @@ bool isGoodDecomp(wchar32 rune, wchar32 decomp) { } void TCustomEncoder::Create(const CodePage* target, bool extended) { - Y_ASSERT(target); + Y_ASSERT(target); DefaultChar = (const char*)target->DefaultChar; @@ -61,7 +61,7 @@ void TCustomEncoder::Create(const CodePage* target, bool extended) { wchar32 dw = w; while (IsComposed(dw) && Code(dw) == 0) { const wchar32* decomp_p = NUnicode::Decomposition<true>(dw); - Y_ASSERT(decomp_p != nullptr); + Y_ASSERT(decomp_p != nullptr); dw = decomp_p[0]; if (std::char_traits<wchar32>::length(decomp_p) > 1 && (dw == (wchar32)' ' || dw == (wchar32)'(')) diff --git a/library/cpp/unicode/normalization/generated/composition.cpp b/library/cpp/unicode/normalization/generated/composition.cpp index 7cc4dc7b756..8a93147d09c 100644 --- a/library/cpp/unicode/normalization/generated/composition.cpp +++ b/library/cpp/unicode/normalization/generated/composition.cpp @@ -947,4 +947,4 @@ const NUnicode::NPrivate::TComposition::TRawData NUnicode::NPrivate::TCompositio { 0x115B9, 0x115AF, 0x115BB }, }; // TRawData -const size_t NUnicode::NPrivate::TComposition::RawDataSize = Y_ARRAY_SIZE(NUnicode::NPrivate::TComposition::RawData); +const size_t NUnicode::NPrivate::TComposition::RawDataSize = Y_ARRAY_SIZE(NUnicode::NPrivate::TComposition::RawData); diff --git a/library/cpp/unicode/normalization/normalization.cpp b/library/cpp/unicode/normalization/normalization.cpp index 7da72115143..de7625abeae 100644 --- a/library/cpp/unicode/normalization/normalization.cpp +++ b/library/cpp/unicode/normalization/normalization.cpp @@ -56,7 +56,7 @@ NUnicode::NPrivate::TComposition::TComposition() { while (*decompBegin) { wchar32 tail = *(decompBegin++); wchar32 comp = ComposeHangul(lead, tail); - Y_ASSERT(comp != 0); + Y_ASSERT(comp != 0); Data[TKey(lead, tail)] = comp; diff --git a/library/cpp/unicode/normalization/normalization.h b/library/cpp/unicode/normalization/normalization.h index 4f5f57881c3..f458e85b7e6 100644 --- a/library/cpp/unicode/normalization/normalization.h +++ b/library/cpp/unicode/normalization/normalization.h @@ -136,7 +136,7 @@ namespace NUnicode { class TCompositor<false> { public: inline void DoComposition(TBuffer& buffer) { - Y_UNUSED(buffer); + Y_UNUSED(buffer); } }; @@ -182,7 +182,7 @@ namespace NUnicode { } } while (oneMoreTurnPlease); - Y_ASSERT(DecompositionCombining(lead) == 0); + Y_ASSERT(DecompositionCombining(lead) == 0); buffer[0] = TSymbol(lead, 0); } }; @@ -280,7 +280,7 @@ namespace NUnicode { const wchar32* decompBegin = Decompositor.Decomposition(c); if (decompBegin) { while (*decompBegin) { - Y_ASSERT(Decompositor.Decomposition(*decompBegin) == nullptr); + Y_ASSERT(Decompositor.Decomposition(*decompBegin) == nullptr); AddCharNoDecomposition(*(decompBegin++), out); } return; @@ -377,8 +377,8 @@ inline TBasicString<TCharType> Normalize(const TBasicString<TCharType>& str) { ::NUnicode::TNormalizer<N> dec; return dec.Normalize(str); } - + template <NUnicode::ENormalization N, typename TCharType> inline TBasicString<TCharType> Normalize(const TBasicStringBuf<TCharType> str) { - return Normalize<N>(str.data(), str.size()); -} + return Normalize<N>(str.data(), str.size()); +} diff --git a/library/cpp/unicode/normalization/ut/normalization_ut.cpp b/library/cpp/unicode/normalization/ut/normalization_ut.cpp index 54d4940a268..6f9eb3ef6c7 100644 --- a/library/cpp/unicode/normalization/ut/normalization_ut.cpp +++ b/library/cpp/unicode/normalization/ut/normalization_ut.cpp @@ -4,7 +4,7 @@ #include <library/cpp/unicode/normalization/normalization.h> -Y_UNIT_TEST_SUITE(TUnicodeNormalizationTest) { +Y_UNIT_TEST_SUITE(TUnicodeNormalizationTest) { template <NUnicode::ENormalization NormType> void TestInit() { NUnicode::TNormalizer<NormType> normalizer; @@ -14,19 +14,19 @@ Y_UNIT_TEST_SUITE(TUnicodeNormalizationTest) { normalizer.Normalize(w); } - Y_UNIT_TEST(TestInitNFD) { + Y_UNIT_TEST(TestInitNFD) { TestInit<NUnicode::NFD>(); } - Y_UNIT_TEST(TestInitNFC) { + Y_UNIT_TEST(TestInitNFC) { TestInit<NUnicode::NFC>(); } - Y_UNIT_TEST(TestInitNFKD) { + Y_UNIT_TEST(TestInitNFKD) { TestInit<NUnicode::NFKD>(); } - Y_UNIT_TEST(TestInitNFKC) { + Y_UNIT_TEST(TestInitNFKC) { TestInit<NUnicode::NFKC>(); } } diff --git a/library/cpp/unicode/punycode/punycode.cpp b/library/cpp/unicode/punycode/punycode.cpp index 800d1f19fe4..e2b9bab2a21 100644 --- a/library/cpp/unicode/punycode/punycode.cpp +++ b/library/cpp/unicode/punycode/punycode.cpp @@ -135,7 +135,7 @@ bool CanBePunycodeHostName(const TStringBuf& host) { TStringBuf tail(host); while (tail) { const TStringBuf label = tail.NextTok('.'); - if (label.StartsWith(ACE)) + if (label.StartsWith(ACE)) return true; } diff --git a/library/cpp/unicode/punycode/punycode_ut.cpp b/library/cpp/unicode/punycode/punycode_ut.cpp index 97271cf0d80..1423e540a5a 100644 --- a/library/cpp/unicode/punycode/punycode_ut.cpp +++ b/library/cpp/unicode/punycode/punycode_ut.cpp @@ -10,7 +10,7 @@ namespace { } } -Y_UNIT_TEST_SUITE(TPunycodeTest) { +Y_UNIT_TEST_SUITE(TPunycodeTest) { static bool TestRaw(const TString& utf8, const TString& punycode) { TUtf16String unicode = UTF8ToWide(utf8); TString buf1; @@ -18,7 +18,7 @@ Y_UNIT_TEST_SUITE(TPunycodeTest) { return HasSameBuffer(WideToPunycode(unicode, buf1), buf1) && buf1 == punycode && HasSameBuffer(PunycodeToWide(punycode, buf2), buf2) && buf2 == unicode && WideToPunycode(unicode) == punycode && PunycodeToWide(punycode) == unicode; } - Y_UNIT_TEST(RawEncodeDecode) { + Y_UNIT_TEST(RawEncodeDecode) { UNIT_ASSERT(TestRaw("", "")); UNIT_ASSERT(TestRaw(" ", " -")); UNIT_ASSERT(TestRaw("-", "--")); @@ -70,7 +70,7 @@ Y_UNIT_TEST_SUITE(TPunycodeTest) { return ForceHostNameToPunycode(UTF8ToWide(bad)) == bad && ForcePunycodeToHostName(bad) == UTF8ToWide(bad); } - Y_UNIT_TEST(HostNameEncodeDecode) { + Y_UNIT_TEST(HostNameEncodeDecode) { UNIT_ASSERT(TestHostName("президент.рф", "xn--d1abbgf6aiiy.xn--p1ai", true)); UNIT_ASSERT(TestHostName("яндекс.ru", "xn--d1acpjx3f.ru", true)); UNIT_ASSERT(TestHostName("пример", "xn--e1afmkfd", true)); diff --git a/library/cpp/uri/location_ut.cpp b/library/cpp/uri/location_ut.cpp index 26a0f644711..9c997f41ac5 100644 --- a/library/cpp/uri/location_ut.cpp +++ b/library/cpp/uri/location_ut.cpp @@ -2,36 +2,36 @@ #include <library/cpp/testing/unittest/registar.h> -Y_UNIT_TEST_SUITE(TResolveRedirectTests) { - Y_UNIT_TEST(Absolute) { +Y_UNIT_TEST_SUITE(TResolveRedirectTests) { + Y_UNIT_TEST(Absolute) { UNIT_ASSERT_EQUAL( NUri::ResolveRedirectLocation("http://example.com", "http://redir-example.com/sub"), "http://redir-example.com/sub"); } - Y_UNIT_TEST(AbsWithFragment) { + Y_UNIT_TEST(AbsWithFragment) { UNIT_ASSERT_EQUAL( NUri::ResolveRedirectLocation("http://example.com", "http://redir-example.com/sub#Hello"), "http://redir-example.com/sub#Hello"); UNIT_ASSERT_EQUAL( NUri::ResolveRedirectLocation("http://example.com/#Hello", "http://redir-example.com/sub"), "http://redir-example.com/sub#Hello"); } - Y_UNIT_TEST(Rel) { + Y_UNIT_TEST(Rel) { UNIT_ASSERT_EQUAL( NUri::ResolveRedirectLocation("http://example.com", "/sub"), "http://example.com/sub"); } - Y_UNIT_TEST(RelWithFragment) { + Y_UNIT_TEST(RelWithFragment) { UNIT_ASSERT_EQUAL( NUri::ResolveRedirectLocation("http://example.com", "/sub#Hello"), "http://example.com/sub#Hello"); UNIT_ASSERT_EQUAL( NUri::ResolveRedirectLocation("http://example.com/#Hello", "/sub"), "http://example.com/sub#Hello"); } - Y_UNIT_TEST(WrongLocation) { + Y_UNIT_TEST(WrongLocation) { UNIT_ASSERT_EQUAL( NUri::ResolveRedirectLocation("http://example.com", ""), ""); } - Y_UNIT_TEST(WrongBase) { + Y_UNIT_TEST(WrongBase) { UNIT_ASSERT_EQUAL( NUri::ResolveRedirectLocation("", "http://example.com"), ""); } - Y_UNIT_TEST(HashBangIsNothingSpecial) { + Y_UNIT_TEST(HashBangIsNothingSpecial) { UNIT_ASSERT_EQUAL( NUri::ResolveRedirectLocation("http://example.com", "http://redir-example.com/sub#!Hello"), "http://redir-example.com/sub#!Hello"); UNIT_ASSERT_EQUAL( diff --git a/library/cpp/uri/uri-ru_ut.cpp b/library/cpp/uri/uri-ru_ut.cpp index ec35a164d29..ac5b19160db 100644 --- a/library/cpp/uri/uri-ru_ut.cpp +++ b/library/cpp/uri/uri-ru_ut.cpp @@ -13,8 +13,8 @@ namespace NUri { } } - Y_UNIT_TEST_SUITE(URLTestRU) { - Y_UNIT_TEST(test_httpURL2) { + Y_UNIT_TEST_SUITE(URLTestRU) { + Y_UNIT_TEST(test_httpURL2) { TUri url; UNIT_ASSERT_VALUES_EQUAL(url.Parse("g:h"), TState::ParsedBadScheme); UNIT_ASSERT_VALUES_EQUAL(url.Parse("http:g"), TState::ParsedBadFormat); @@ -120,7 +120,7 @@ namespace NUri { AsWin1251("mailto:kampa@ukr.net?subject=Арабский язык"), "mailto:kampa@ukr.net?subject=%C0%F0%E0%E1%F1%EA%E8%E9%20%FF%E7%FB%EA", {}}; - Y_UNIT_TEST(testHtLinkDecode) { + Y_UNIT_TEST(testHtLinkDecode) { char decodedlink[URL_MAXLEN + 10]; for (int i = 0; links[i]; i += 2) { UNIT_ASSERT(HtLinkDecode(links[i].c_str(), decodedlink, sizeof(decodedlink))); @@ -128,7 +128,7 @@ namespace NUri { } } - Y_UNIT_TEST(testRuIDNA) { + Y_UNIT_TEST(testRuIDNA) { { #define DEC "\xD7\xE5\xF0\xE5\xEf\xEE\xE2\xE5\xF6.\xF0\xF4" /* "Череповец.рф" in Windows-1251 */ #define ENC "%D7%E5%F0%E5%EF%EE%E2%E5%F6.%F0%F4" diff --git a/library/cpp/uri/uri_ut.cpp b/library/cpp/uri/uri_ut.cpp index 2ebd83fc93a..852356ac268 100644 --- a/library/cpp/uri/uri_ut.cpp +++ b/library/cpp/uri/uri_ut.cpp @@ -6,7 +6,7 @@ #include <util/system/maxlen.h> namespace NUri { - Y_UNIT_TEST_SUITE(URLTest) { + Y_UNIT_TEST_SUITE(URLTest) { static const char* urls[] = { "http://a/b/c/d;p?q#r", "g", "http://a/b/c/g", @@ -60,7 +60,7 @@ namespace NUri { // "%2zy", "http://a/b/c/%2zy", nullptr}; - Y_UNIT_TEST(test_httpURL) { + Y_UNIT_TEST(test_httpURL) { TUri rel, base, abs; TState::EParsed er = base.Parse(urls[0]); UNIT_ASSERT_VALUES_EQUAL(er, TState::ParsedOK); @@ -91,7 +91,7 @@ namespace NUri { } } - Y_UNIT_TEST(test_Schemes) { + Y_UNIT_TEST(test_Schemes) { TUri url; UNIT_ASSERT_VALUES_EQUAL(url.Parse("www.ya.ru/index.html"), TState::ParsedOK); UNIT_ASSERT_EQUAL(url.GetScheme(), TScheme::SchemeEmpty); @@ -128,7 +128,7 @@ namespace NUri { {nullptr, nullptr, nullptr, TUri::LinkIsBad}, }; - Y_UNIT_TEST(test_httpURLNormalize) { + Y_UNIT_TEST(test_httpURLNormalize) { TUri normalizedLink; for (int i = 0; link4Norm[i].link; i++) { @@ -149,7 +149,7 @@ namespace NUri { "http://a/b//c", "http://a/b/c", nullptr, nullptr}; - Y_UNIT_TEST(test_httpURLPathOperation) { + Y_UNIT_TEST(test_httpURLPathOperation) { char copyUrl[URL_MAXLEN]; for (int i = 0; urlsWithMultipleSlash[i]; i += 2) { const TStringBuf url(urlsWithMultipleSlash[i]); @@ -187,14 +187,14 @@ namespace NUri { TState::ParsedBadHost, }; - Y_UNIT_TEST(test_httpURLCheckHost) { + Y_UNIT_TEST(test_httpURLCheckHost) { for (size_t index = 0; hostsForCheckHost[index]; ++index) { TState::EParsed state = TUri::CheckHost(hostsForCheckHost[index]); UNIT_ASSERT_VALUES_EQUAL(state, answersForCheckHost[index]); } } - Y_UNIT_TEST(test_httpURLSet) { + Y_UNIT_TEST(test_httpURLSet) { // set port { TUri parsedUrl; @@ -232,7 +232,7 @@ namespace NUri { } } - Y_UNIT_TEST(test_httpURLAuth) { + Y_UNIT_TEST(test_httpURLAuth) { { TUri parsedUrl; TState::EParsed st = parsedUrl.Parse("http://@www.host.com/path", TFeature::FeaturesRobot); @@ -258,28 +258,28 @@ namespace NUri { } } - Y_UNIT_TEST(test01) { + Y_UNIT_TEST(test01) { TTest test = { "user:pass@host:8080", TFeature::FeaturesAll, TState::ParsedRootless, "user", "", "", "", 0, "", "", ""}; TUri url; URL_TEST(url, test); } - Y_UNIT_TEST(test02) { + Y_UNIT_TEST(test02) { TTest test = { "http://host", TFeature::FeaturesAll, TState::ParsedOK, "http", "", "", "host", 80, "/", "", ""}; TUri url; URL_TEST(url, test); } - Y_UNIT_TEST(test03) { + Y_UNIT_TEST(test03) { TTest test = { "https://host", TFeature::FeatureSchemeFlexible | TFeature::FeatureAllowHostIDN, TState::ParsedOK, "https", "", "", "host", 443, "/", "", ""}; TUri url; URL_TEST(url, test); } - Y_UNIT_TEST(test04) { + Y_UNIT_TEST(test04) { TTest test = { "user:pass@host:8080", TFeature::FeaturesAll | TFeature::FeatureNoRelPath | TFeature::FeatureAllowRootless, TState::ParsedOK, "user", "", "", "", 0, "pass@host:8080", "", ""}; TUri url; @@ -289,7 +289,7 @@ namespace NUri { URL_EQ(url, url2); } - Y_UNIT_TEST(test05) { + Y_UNIT_TEST(test05) { TTest test = { "host:8080", TFeature::FeaturesAll | TFeature::FeatureNoRelPath | TFeature::FeatureAllowRootless, TState::ParsedOK, "host", "", "", "", 0, "8080", "", ""}; TUri url; @@ -297,7 +297,7 @@ namespace NUri { UNIT_ASSERT_VALUES_EQUAL(url.PrintS(), "host:8080"); } - Y_UNIT_TEST(test06) { + Y_UNIT_TEST(test06) { TTest test = { "http://user:pass@host?q", TFeature::FeaturesAll, TState::ParsedOK, "http", "user", "pass", "host", 80, "/", "q", ""}; TUri url; @@ -359,7 +359,7 @@ namespace NUri { URL_EQ(url, url2); } - Y_UNIT_TEST(test07) { + Y_UNIT_TEST(test07) { { TTest test = { "http://host/path//", TFeature::FeaturesAll | TFeature::FeatureNoRelPath, TState::ParsedOK, "http", "", "", "host", 80, "/path/", "", ""}; @@ -385,7 +385,7 @@ namespace NUri { } } - Y_UNIT_TEST(test08) { + Y_UNIT_TEST(test08) { { TTest test = { "mailto://user@host.com", TFeature::FeaturesAll | TFeature::FeatureNoRelPath, TState::ParsedOK, "mailto", "user", "", "host.com", 0, "", "", ""}; @@ -472,7 +472,7 @@ namespace NUri { } } - Y_UNIT_TEST(test09) { + Y_UNIT_TEST(test09) { { TTest test = { "mailto:user@host.com", TFeature::FeaturesAll | TFeature::FeatureAllowRootless, TState::ParsedOK, "mailto", "", "", "", 0, "user@host.com", "", ""}; @@ -493,7 +493,7 @@ namespace NUri { } } - Y_UNIT_TEST(test10) { + Y_UNIT_TEST(test10) { // test some escaping madness, note the ehost vs host { TString host = "президент.рф"; @@ -553,7 +553,7 @@ namespace NUri { } } - Y_UNIT_TEST(test11) { + Y_UNIT_TEST(test11) { { TTest test = { "HtTp://HoSt/%50aTh/?Query#Frag", TFeature::FeaturesAll | TFeature::FeatureNoRelPath, TState::ParsedOK, "http", "", "", "host", 80, "/PaTh/", "Query", "Frag"}; @@ -569,7 +569,7 @@ namespace NUri { } } - Y_UNIT_TEST(test12) { + Y_UNIT_TEST(test12) { // test characters which are not always safe { #define RAW "/:" @@ -666,7 +666,7 @@ namespace NUri { } } - Y_UNIT_TEST(testFlexibleAuthority) { + Y_UNIT_TEST(testFlexibleAuthority) { TUri uri; UNIT_ASSERT_EQUAL(uri.Parse("http://hello_world", TFeature::FeatureCheckHost), TState::ParsedBadHost); UNIT_ASSERT_EQUAL(uri.Parse("http://hello_world", TFeature::FeatureSchemeFlexible), TState::ParsedOK); @@ -683,7 +683,7 @@ namespace NUri { UNIT_ASSERT_VALUES_EQUAL(uri.GetField(TField::FieldQuery), ""); } - Y_UNIT_TEST(testSpecialChar) { + Y_UNIT_TEST(testSpecialChar) { // test characters which are not always allowed { TTest test = { @@ -729,7 +729,7 @@ namespace NUri { } } - Y_UNIT_TEST(testIPv6) { + Y_UNIT_TEST(testIPv6) { { #define RAW "[1080:0:0:0:8:800:200C:417A]" #define DEC "[1080:0:0:0:8:800:200c:417a]" @@ -743,7 +743,7 @@ namespace NUri { } } - Y_UNIT_TEST(testEscapedFragment) { + Y_UNIT_TEST(testEscapedFragment) { { TTest test = { "http://host.com#!a=b&c=d#e+g%41%25", TParseFlags(TFeature::FeaturesAll | TFeature::FeatureHashBangToEscapedFragment), TState::ParsedOK, "http", "", "", "host.com", 80, "/", "_escaped_fragment_=a=b%26c=d%23e%2BgA%2525", ""}; @@ -760,7 +760,7 @@ namespace NUri { } } - Y_UNIT_TEST(testReEncode) { + Y_UNIT_TEST(testReEncode) { { TStringStream out; TUri::ReEncode(out, "foo bar"); @@ -782,7 +782,7 @@ namespace NUri { "http://translate.yandex.net/api/v1/tr.json/translate?lang=en-ru&text=>", nullptr}; - Y_UNIT_TEST(test_NonRfcUrls) { + Y_UNIT_TEST(test_NonRfcUrls) { TUri url; const long flags = TFeature::FeaturesRobot; for (size_t i = 0;; ++i) { @@ -797,7 +797,7 @@ namespace NUri { "http://www.'>'.com/?.net/", nullptr}; - Y_UNIT_TEST(test_CheckParseException) { + Y_UNIT_TEST(test_CheckParseException) { TUri url; const long flags = TFeature::FeaturesRobot | TFeature::FeaturesEncode; for (size_t i = 0;; ++i) { @@ -818,7 +818,7 @@ namespace NUri { } } - Y_UNIT_TEST(test_PrintPort) { + Y_UNIT_TEST(test_PrintPort) { TUri uri; { uri.Parse("http://srv.net:9100/print", TFeature::FeaturesRecommended); @@ -834,7 +834,7 @@ namespace NUri { } } - Y_UNIT_TEST(test_ParseFailures) { + Y_UNIT_TEST(test_ParseFailures) { { TTest test = { "http://host:port", TFeature::FeaturesAll | TFeature::FeatureNoRelPath, TState::ParsedBadFormat, "", "", "", "", Max<ui16>(), "", "", ""}; @@ -901,8 +901,8 @@ namespace NUri { } } - Y_UNIT_TEST_SUITE(TInvertDomainTest) { - Y_UNIT_TEST(TestInvert) { + Y_UNIT_TEST_SUITE(TInvertDomainTest) { + Y_UNIT_TEST(TestInvert) { TString a; UNIT_ASSERT_EQUAL(InvertDomain(a), ""); TString aa(".:/foo"); @@ -954,8 +954,8 @@ namespace NUri { return r; } - Y_UNIT_TEST_SUITE(QargsTest) { - Y_UNIT_TEST(TestSorting) { + Y_UNIT_TEST_SUITE(QargsTest) { + Y_UNIT_TEST(TestSorting) { UNIT_ASSERT_STRINGS_EQUAL(SortQargs("http://ya.ru/"), "http://ya.ru/"); UNIT_ASSERT_STRINGS_EQUAL(SortQargs("http://ya.ru/?"), "http://ya.ru/?"); UNIT_ASSERT_STRINGS_EQUAL(SortQargs("http://ya.ru/?some=value"), "http://ya.ru/?some=value"); @@ -973,7 +973,7 @@ namespace NUri { UNIT_ASSERT_STRINGS_EQUAL(SortQargs("http://ya.ru/?b==&a=&&c="), "http://ya.ru/?a=&b==&c="); } - Y_UNIT_TEST(TestParsingCorners) { + Y_UNIT_TEST(TestParsingCorners) { TString s; UNIT_ASSERT_EQUAL(ProcessQargs("http://ya.ru/?=", s), TQueryArg::ProcessedOK); @@ -992,14 +992,14 @@ namespace NUri { UNIT_ASSERT_STRINGS_EQUAL(SortQargs("http://ya.ru/?a"), "http://ya.ru/?a"); } - Y_UNIT_TEST(TestFiltering) { + Y_UNIT_TEST(TestFiltering) { UNIT_ASSERT_STRINGS_EQUAL(FilterQargs("http://ya.ru/?some=value", "missing"), "http://ya.ru/?some=value"); UNIT_ASSERT_STRINGS_EQUAL(FilterQargs("http://ya.ru/?b=1&a=2", "b"), "http://ya.ru/?a=2"); UNIT_ASSERT_STRINGS_EQUAL(FilterQargs("http://ya.ru/?b=1&a=2&a=3", "a"), "http://ya.ru/?b=1"); UNIT_ASSERT_STRINGS_EQUAL(FilterQargs("http://ya.ru/?some=&another=", "another"), "http://ya.ru/?some="); } - Y_UNIT_TEST(TestRemoveEmptyFeature) { + Y_UNIT_TEST(TestRemoveEmptyFeature) { TUri uri; uri.Parse("http://ya.ru/?", NUri::TFeature::FeaturesRecommended); @@ -1009,7 +1009,7 @@ namespace NUri { UNIT_ASSERT_STRINGS_EQUAL(uri.PrintS(), "http://ya.ru/"); } - Y_UNIT_TEST(TestNoRemoveEmptyFeature) { + Y_UNIT_TEST(TestNoRemoveEmptyFeature) { TUri uri; uri.Parse("http://ya.ru/?", NUri::TFeature::FeaturesRecommended); diff --git a/library/cpp/xml/document/xml-document.cpp b/library/cpp/xml/document/xml-document.cpp index 18a554d7321..eb2729f8db0 100644 --- a/library/cpp/xml/document/xml-document.cpp +++ b/library/cpp/xml/document/xml-document.cpp @@ -308,7 +308,7 @@ namespace NXml { static int XmlWriteToOstream(void* context, const char* buffer, int len) { // possibly use to save doc as well - IOutputStream* out = (IOutputStream*)context; + IOutputStream* out = (IOutputStream*)context; out->Write(buffer, len); return len; } diff --git a/library/cpp/xml/document/xml-document_ut.cpp b/library/cpp/xml/document/xml-document_ut.cpp index 9f537b75c4c..78e9cdf52ba 100644 --- a/library/cpp/xml/document/xml-document_ut.cpp +++ b/library/cpp/xml/document/xml-document_ut.cpp @@ -3,8 +3,8 @@ #include "xml-document.h" -Y_UNIT_TEST_SUITE(TestXmlDocument) { - Y_UNIT_TEST(Iteration) { +Y_UNIT_TEST_SUITE(TestXmlDocument) { + Y_UNIT_TEST(Iteration) { NXml::TDocument xml( "<?xml version=\"1.0\"?>\n" "<root>qq<a><b></b></a>ww<c></c></root>", @@ -18,7 +18,7 @@ Y_UNIT_TEST_SUITE(TestXmlDocument) { UNIT_ASSERT_EQUAL(n.Name(), "c"); } - Y_UNIT_TEST(ParseString) { + Y_UNIT_TEST(ParseString) { NXml::TDocument xml( "<?xml version=\"1.0\"?>\n" "<root>\n" @@ -35,7 +35,7 @@ Y_UNIT_TEST_SUITE(TestXmlDocument) { NXml::TConstNode text = root.Node("text"); UNIT_ASSERT_EQUAL(text.Value<TString>(), "Некоторый текст"); } - Y_UNIT_TEST(SerializeString) { + Y_UNIT_TEST(SerializeString) { NXml::TDocument xml("frob", NXml::TDocument::RootName); xml.Root().SetAttr("xyzzy", "Frobozz"); xml.Root().SetAttr("kulness", 0.3); @@ -63,7 +63,7 @@ Y_UNIT_TEST_SUITE(TestXmlDocument) { "<frob xyzzy=\"привет =)\"/>\n"); } } - Y_UNIT_TEST(XPathNs) { + Y_UNIT_TEST(XPathNs) { using namespace NXml; TDocument xml( "<?xml version=\"1.0\"?>\n" @@ -91,7 +91,7 @@ Y_UNIT_TEST_SUITE(TestXmlDocument) { UNIT_ASSERT_EXCEPTION(root.Node("text", false, *ctxt), yexception); UNIT_ASSERT_EQUAL(root.Node("h:text", false, *ctxt).Value<TString>(), "Некоторый текст"); } - Y_UNIT_TEST(XmlNodes) { + Y_UNIT_TEST(XmlNodes) { using namespace NXml; TDocument xml("<?xml version=\"1.0\"?>\n" "<root>qq<a><b>asdfg</b></a>ww<c></c></root>", @@ -151,14 +151,14 @@ Y_UNIT_TEST_SUITE(TestXmlDocument) { UNIT_ASSERT_EXCEPTION(node.Value<TString>(), yexception); UNIT_ASSERT_EXCEPTION(node.IsText(), yexception); } - Y_UNIT_TEST(DefVal) { + Y_UNIT_TEST(DefVal) { using namespace NXml; TDocument xml("<?xml version=\"1.0\"?>\n" "<root><a></a></root>", NXml::TDocument::String); UNIT_ASSERT_EQUAL(xml.Root().Node("a", true).Node("b", true).Value<int>(3), 3); } - Y_UNIT_TEST(NodesVsXPath) { + Y_UNIT_TEST(NodesVsXPath) { using namespace NXml; TDocument xml("<?xml version=\"1.0\"?>\n" "<root><a x=\"y\"></a></root>", @@ -166,7 +166,7 @@ Y_UNIT_TEST_SUITE(TestXmlDocument) { UNIT_ASSERT_EXCEPTION(xml.Root().Nodes("/root/a/@x"), yexception); UNIT_ASSERT_VALUES_EQUAL(xml.Root().XPath("/root/a/@x").Size(), 1); } - Y_UNIT_TEST(NodeIsFirst) { + Y_UNIT_TEST(NodeIsFirst) { using namespace NXml; TDocument xml("<?xml version=\"1.0\"?>\n" "<root><a x=\"y\">first</a>" @@ -175,7 +175,7 @@ Y_UNIT_TEST_SUITE(TestXmlDocument) { UNIT_ASSERT_EXCEPTION(xml.Root().Node("/root/a/@x"), yexception); UNIT_ASSERT_STRINGS_EQUAL(xml.Root().Node("/root/a").Value<TString>(), "first"); } - Y_UNIT_TEST(CopyNode) { + Y_UNIT_TEST(CopyNode) { using namespace NXml; // default-construct empty node TNode empty; @@ -204,7 +204,7 @@ Y_UNIT_TEST_SUITE(TestXmlDocument) { "<root><a><node><b>bold</b><i>ita</i></node></a></root>\n"); } - Y_UNIT_TEST(RenderNode) { + Y_UNIT_TEST(RenderNode) { using namespace NXml; { // no namespaces @@ -236,7 +236,7 @@ Y_UNIT_TEST_SUITE(TestXmlDocument) { } } - Y_UNIT_TEST(ReuseXPathContext) { + Y_UNIT_TEST(ReuseXPathContext) { using namespace NXml; TDocument xml( @@ -279,7 +279,7 @@ Y_UNIT_TEST_SUITE(TestXmlDocument) { UNIT_ASSERT_EQUAL(ys[0].Value<int>(), 20); } - Y_UNIT_TEST(Html) { + Y_UNIT_TEST(Html) { using namespace NXml; TDocument htmlChunk("video", TDocument::RootName); diff --git a/library/cpp/xml/document/xml-options_ut.cpp b/library/cpp/xml/document/xml-options_ut.cpp index 9be16baf3d3..63f2ed4f594 100644 --- a/library/cpp/xml/document/xml-options_ut.cpp +++ b/library/cpp/xml/document/xml-options_ut.cpp @@ -2,19 +2,19 @@ #include <library/cpp/testing/unittest/registar.h> -Y_UNIT_TEST_SUITE(TestXmlOptions) { - Y_UNIT_TEST(SetHuge) { +Y_UNIT_TEST_SUITE(TestXmlOptions) { + Y_UNIT_TEST(SetHuge) { NXml::TOptions opts; opts.Set(NXml::EOption::Huge); UNIT_ASSERT_EQUAL(XML_PARSE_HUGE, opts.GetMask()); } - Y_UNIT_TEST(VariadicContructor) { + Y_UNIT_TEST(VariadicContructor) { NXml::TOptions opts(NXml::EOption::Huge, NXml::EOption::Compact, NXml::EOption::SAX1); UNIT_ASSERT_EQUAL(XML_PARSE_HUGE | XML_PARSE_COMPACT | XML_PARSE_SAX1, opts.GetMask()); } - Y_UNIT_TEST(Chaining) { + Y_UNIT_TEST(Chaining) { NXml::TOptions opts; opts diff --git a/library/cpp/xml/document/xml-textreader.cpp b/library/cpp/xml/document/xml-textreader.cpp index b946f1fbf2f..557fe9d3d44 100644 --- a/library/cpp/xml/document/xml-textreader.cpp +++ b/library/cpp/xml/document/xml-textreader.cpp @@ -7,7 +7,7 @@ #include <util/system/compiler.h> namespace NXml { - TTextReader::TTextReader(IInputStream& stream, const TOptions& options) + TTextReader::TTextReader(IInputStream& stream, const TOptions& options) : Stream(stream) , IsError(false) { @@ -169,12 +169,12 @@ namespace NXml { // It is almost "noexcept" (std::bad_alloc may happen when saving exception message to new TString). // Waiting for std::exception_ptr and std::rethrow_exception from C++11 in Arcadia to make it really "noexcept". int TTextReader::ReadFromInputStreamCallback(void* context, char* buffer, int len) { - Y_ASSERT(len >= 0); + Y_ASSERT(len >= 0); TTextReader* reader = static_cast<TTextReader*>(context); int result = -1; - // Exception may be thrown by IInputStream::Read(). + // Exception may be thrown by IInputStream::Read(). // It is caught unconditionally because exceptions cannot safely pass through libxml2 plain C code // (no destructors, no RAII, raw pointers, so in case of stack unwinding some memory gets leaked). @@ -191,7 +191,7 @@ namespace NXml { void TTextReader::OnLibxmlError(void* arg, const char* msg, xmlParserSeverities severity, xmlTextReaderLocatorPtr locator) { TTextReader* reader = static_cast<TTextReader*>(arg); - Y_ASSERT(reader != nullptr); + Y_ASSERT(reader != nullptr); TStringStream& out = reader->LogError(); @@ -247,7 +247,7 @@ namespace NXml { } void TTextReader::CheckForExceptions() const { - if (Y_LIKELY(!IsError)) { + if (Y_LIKELY(!IsError)) { return; } @@ -266,28 +266,28 @@ namespace NXml { } bool TTextReader::BoolResult(int value) const { - if (Y_UNLIKELY(value == -1)) { + if (Y_UNLIKELY(value == -1)) { ThrowException(); } return (value != 0); } int TTextReader::IntResult(int value) const { - if (Y_UNLIKELY(value == -1)) { + if (Y_UNLIKELY(value == -1)) { ThrowException(); } return value; } char TTextReader::CharResult(int value) const { - if (Y_UNLIKELY(value == -1)) { + if (Y_UNLIKELY(value == -1)) { ThrowException(); } return static_cast<char>(value); } TStringBuf TTextReader::ConstStringResult(const xmlChar* value) const { - if (Y_UNLIKELY(value == nullptr)) { + if (Y_UNLIKELY(value == nullptr)) { ThrowException(); } return CAST2CHAR(value); @@ -299,7 +299,7 @@ namespace NXml { } TString TTextReader::TempStringResult(TCharPtr value) const { - if (Y_UNLIKELY(value == nullptr)) { + if (Y_UNLIKELY(value == nullptr)) { ThrowException(); } return TString(CAST2CHAR(value.Get())); diff --git a/library/cpp/xml/document/xml-textreader.h b/library/cpp/xml/document/xml-textreader.h index ab4c329d26d..a1309c10196 100644 --- a/library/cpp/xml/document/xml-textreader.h +++ b/library/cpp/xml/document/xml-textreader.h @@ -77,7 +77,7 @@ namespace NXml { }; public: - TTextReader(IInputStream& stream, const TOptions& options = TOptions()); + TTextReader(IInputStream& stream, const TOptions& options = TOptions()); ~TTextReader(); /** @@ -313,7 +313,7 @@ namespace NXml { TString TempStringOrEmptyResult(TCharPtr value) const; private: - IInputStream& Stream; + IInputStream& Stream; mutable bool IsError; mutable TStringStream ErrorBuffer; diff --git a/library/cpp/xml/document/xml-textreader_ut.cpp b/library/cpp/xml/document/xml-textreader_ut.cpp index 6232dfe47e2..81e11e33483 100644 --- a/library/cpp/xml/document/xml-textreader_ut.cpp +++ b/library/cpp/xml/document/xml-textreader_ut.cpp @@ -29,8 +29,8 @@ namespace { } } -Y_UNIT_TEST_SUITE(TestXmlTextReader) { - Y_UNIT_TEST(BasicExample) { +Y_UNIT_TEST_SUITE(TestXmlTextReader) { + Y_UNIT_TEST(BasicExample) { const TString xml = "<?xml version=\"1.0\"?>\n" "<example toto=\"1\">\n" " <examplechild id=\"1\">\n" @@ -134,7 +134,7 @@ Y_UNIT_TEST_SUITE(TestXmlTextReader) { "" "</root>"; - Y_UNIT_TEST(ParseXmlSimple) { + Y_UNIT_TEST(ParseXmlSimple) { struct TCountry { TString Name; TVector<TString> Cities; @@ -150,7 +150,7 @@ Y_UNIT_TEST_SUITE(TestXmlTextReader) { c.Name = node.FirstChild("name").Value<TString>(); const NXml::TConstNodes cityNodes = node.Nodes("cities/city"); - for (auto cityNode : cityNodes) { + for (auto cityNode : cityNodes) { c.Cities.push_back(cityNode.Value<TString>()); } }; @@ -179,7 +179,7 @@ Y_UNIT_TEST_SUITE(TestXmlTextReader) { UNIT_ASSERT_EQUAL(ukraine.Cities[0], "Киев"); } - Y_UNIT_TEST(ParseXmlDeepLevel) { + Y_UNIT_TEST(ParseXmlDeepLevel) { TVector<TString> cities; auto handler = [&cities](NXml::TConstNode node) { @@ -195,7 +195,7 @@ Y_UNIT_TEST_SUITE(TestXmlTextReader) { UNIT_ASSERT_EQUAL(cities[3], "Киев"); } - Y_UNIT_TEST(ParseXmlException) { + Y_UNIT_TEST(ParseXmlException) { // Check that exception properly passes through plain C code of libxml, // no leaks are detected by valgrind. auto handler = [](NXml::TConstNode node) { @@ -251,7 +251,7 @@ Y_UNIT_TEST_SUITE(TestXmlTextReader) { "" "</Companies>"; - Y_UNIT_TEST(NamespaceHell) { + Y_UNIT_TEST(NamespaceHell) { using TNS = NXml::TNamespaceForXPath; const NXml::TNamespacesForXPath ns = { TNS{"b", "http://maps.yandex.ru/backa/1.x"}, diff --git a/library/cpp/ya.make b/library/cpp/ya.make index 8c1193b0077..1ee2a6cc49b 100644 --- a/library/cpp/ya.make +++ b/library/cpp/ya.make @@ -4,8 +4,8 @@ RECURSE( accurate_accumulate accurate_accumulate/benchmark accurate_accumulate/benchmark/metrics - actors - actors/ut + actors + actors/ut aio any any/ut @@ -14,7 +14,7 @@ RECURSE( barcode barcode/ut binsaver - binsaver/ut + binsaver/ut binsaver/ut_util bit_io bit_io/ut @@ -62,8 +62,8 @@ RECURSE( config/ut consistent_hash_ring consistent_hash_ring/ut - consistent_hashing - consistent_hashing/ut + consistent_hashing + consistent_hashing/ut containers coroutine cppparser @@ -136,7 +136,7 @@ RECURSE( geohash/tile geohash/tile/ut geohash/ut - geolocation + geolocation geotarget getopt getopt/last_getopt_demo @@ -195,8 +195,8 @@ RECURSE( langmask/proto langmask/serialization langmask/ut - langs - langs/ut + langs + langs/ut lcookie lcookie/ut lcs @@ -243,8 +243,8 @@ RECURSE( minhash minhash/tools minhash/ut - mongo - monlib + mongo + monlib msgpack msgpack2json msgpack2json/ut @@ -338,8 +338,8 @@ RECURSE( solve_ambig/ut sorter sorter/ut - sqlite3 - sqlite3/ut + sqlite3 + sqlite3/ut sse ssh ssh/ut diff --git a/library/cpp/yson/node/node.cpp b/library/cpp/yson/node/node.cpp index b39e0707187..c5933fa9438 100644 --- a/library/cpp/yson/node/node.cpp +++ b/library/cpp/yson/node/node.cpp @@ -7,7 +7,7 @@ #include <util/generic/overloaded.h> namespace NYT { - + //////////////////////////////////////////////////////////////////////////////// bool TNode::TNull::operator==(const TNull&) const { @@ -346,51 +346,51 @@ TNode::TMapType& TNode::AsMap() return std::get<TMapType>(Value_); } -const TString& TNode::UncheckedAsString() const noexcept -{ +const TString& TNode::UncheckedAsString() const noexcept +{ return std::get<TString>(Value_); -} - -i64 TNode::UncheckedAsInt64() const noexcept -{ +} + +i64 TNode::UncheckedAsInt64() const noexcept +{ return std::get<i64>(Value_); -} - -ui64 TNode::UncheckedAsUint64() const noexcept -{ +} + +ui64 TNode::UncheckedAsUint64() const noexcept +{ return std::get<ui64>(Value_); -} - -double TNode::UncheckedAsDouble() const noexcept -{ +} + +double TNode::UncheckedAsDouble() const noexcept +{ return std::get<double>(Value_); -} - -bool TNode::UncheckedAsBool() const noexcept -{ +} + +bool TNode::UncheckedAsBool() const noexcept +{ return std::get<bool>(Value_); -} - +} + const TNode::TListType& TNode::UncheckedAsList() const noexcept -{ +{ return std::get<TListType>(Value_); -} - +} + const TNode::TMapType& TNode::UncheckedAsMap() const noexcept -{ +{ return std::get<TMapType>(Value_); -} - +} + TNode::TListType& TNode::UncheckedAsList() noexcept -{ +{ return std::get<TListType>(Value_); -} - +} + TNode::TMapType& TNode::UncheckedAsMap() noexcept -{ +{ return std::get<TMapType>(Value_); -} - +} + TNode TNode::CreateList() { TNode node; @@ -850,12 +850,12 @@ void TNode::CreateAttributes() Attributes_->Value_ = TMapType(); } -void TNode::Save(IOutputStream* out) const +void TNode::Save(IOutputStream* out) const { NodeToYsonStream(*this, out, NYson::EYsonFormat::Binary); } -void TNode::Load(IInputStream* in) +void TNode::Load(IInputStream* in) { Clear(); *this = NodeFromYsonStream(in, ::NYson::EYsonType::Node); diff --git a/library/cpp/yson/node/node.h b/library/cpp/yson/node/node.h index 5f90f95df07..971b5355be7 100644 --- a/library/cpp/yson/node/node.h +++ b/library/cpp/yson/node/node.h @@ -12,8 +12,8 @@ #include <cmath> #include <variant> -class IInputStream; -class IOutputStream; +class IInputStream; +class IOutputStream; namespace NYT { @@ -149,16 +149,16 @@ public: TListType& AsList(); TMapType& AsMap(); - const TString& UncheckedAsString() const noexcept; - i64 UncheckedAsInt64() const noexcept; - ui64 UncheckedAsUint64() const noexcept; - double UncheckedAsDouble() const noexcept; - bool UncheckedAsBool() const noexcept; + const TString& UncheckedAsString() const noexcept; + i64 UncheckedAsInt64() const noexcept; + ui64 UncheckedAsUint64() const noexcept; + double UncheckedAsDouble() const noexcept; + bool UncheckedAsBool() const noexcept; const TListType& UncheckedAsList() const noexcept; const TMapType& UncheckedAsMap() const noexcept; TListType& UncheckedAsList() noexcept; TMapType& UncheckedAsMap() noexcept; - + // integer types cast // makes overflow checks template<typename T> @@ -264,8 +264,8 @@ public: // Serialize TNode using binary yson format. // Methods for ysaveload. - void Save(IOutputStream* output) const; - void Load(IInputStream* input); + void Save(IOutputStream* output) const; + void Load(IInputStream* input); private: void Move(TNode&& rhs); diff --git a/library/cpp/yson/node/node_ut.cpp b/library/cpp/yson/node/node_ut.cpp index 448e99f5753..f6922f7d012 100644 --- a/library/cpp/yson/node/node_ut.cpp +++ b/library/cpp/yson/node/node_ut.cpp @@ -8,13 +8,13 @@ using namespace NYT; template<> -void Out<NYT::TNode>(IOutputStream& s, const NYT::TNode& node) +void Out<NYT::TNode>(IOutputStream& s, const NYT::TNode& node) { s << "TNode:" << NodeToYsonString(node); } -Y_UNIT_TEST_SUITE(YtNodeTest) { - Y_UNIT_TEST(TestConstsructors) { +Y_UNIT_TEST_SUITE(YtNodeTest) { + Y_UNIT_TEST(TestConstsructors) { TNode nodeEmpty; UNIT_ASSERT_EQUAL(nodeEmpty.GetType(), TNode::Undefined); @@ -82,7 +82,7 @@ Y_UNIT_TEST_SUITE(YtNodeTest) { UNIT_ASSERT_VALUES_EQUAL(mapNode.AsMap(), expectedMapValue); } - Y_UNIT_TEST(TestNodeMap) { + Y_UNIT_TEST(TestNodeMap) { TNode nodeMap = TNode()("foo", "bar")("bar", "baz"); UNIT_ASSERT(nodeMap.IsMap()); UNIT_ASSERT_EQUAL(nodeMap.GetType(), TNode::Map); @@ -113,7 +113,7 @@ Y_UNIT_TEST_SUITE(YtNodeTest) { UNIT_ASSERT_EQUAL(copyNode["rock!!!"]["Purple"], TNode("Deep")); } - Y_UNIT_TEST(TestNodeList) { + Y_UNIT_TEST(TestNodeList) { TNode nodeList = TNode().Add("foo").Add(42).Add(3.14); UNIT_ASSERT(nodeList.IsList()); UNIT_ASSERT_EQUAL(nodeList.GetType(), TNode::List); @@ -128,7 +128,7 @@ Y_UNIT_TEST_SUITE(YtNodeTest) { UNIT_ASSERT_EQUAL(copyNode[3][1], TNode("pwd")); } - Y_UNIT_TEST(TestInsertingMethodsFromTemporaryObjects) { + Y_UNIT_TEST(TestInsertingMethodsFromTemporaryObjects) { // check that .Add(...) doesn't return lvalue reference to temporary object { const TNode& nodeList = TNode().Add(0).Add("pass").Add(0); @@ -142,7 +142,7 @@ Y_UNIT_TEST_SUITE(YtNodeTest) { } } - Y_UNIT_TEST(TestAttributes) { + Y_UNIT_TEST(TestAttributes) { TNode node = TNode()("lee", 42)("faa", 54); UNIT_ASSERT(!node.HasAttributes()); node.Attributes()("foo", true)("bar", false); @@ -185,7 +185,7 @@ Y_UNIT_TEST_SUITE(YtNodeTest) { } } - Y_UNIT_TEST(TestEq) { + Y_UNIT_TEST(TestEq) { TNode nodeNoAttributes = TNode()("lee", 42)("faa", 54); TNode node = nodeNoAttributes; node.Attributes()("foo", true)("bar", false); @@ -260,7 +260,7 @@ Y_UNIT_TEST_SUITE(YtNodeTest) { } } - Y_UNIT_TEST(TestSaveLoad) { + Y_UNIT_TEST(TestSaveLoad) { TNode node = TNode()("foo", "bar")("baz", 42); node.Attributes()["attr_name"] = "attr_value"; @@ -279,7 +279,7 @@ Y_UNIT_TEST_SUITE(YtNodeTest) { UNIT_ASSERT_VALUES_EQUAL(node, nodeCopy); } - Y_UNIT_TEST(TestIntCast) { + Y_UNIT_TEST(TestIntCast) { TNode node = 1ull << 31; UNIT_ASSERT(node.IsUint64()); UNIT_ASSERT_EXCEPTION(node.IntCast<i32>(), TNode::TTypeError); @@ -315,7 +315,7 @@ Y_UNIT_TEST_SUITE(YtNodeTest) { UNIT_ASSERT_EXCEPTION(node.IntCast<ui64>(), TNode::TTypeError); } - Y_UNIT_TEST(TestConvertToString) { + Y_UNIT_TEST(TestConvertToString) { UNIT_ASSERT_VALUES_EQUAL(TNode(5).ConvertTo<TString>(), "5"); UNIT_ASSERT_VALUES_EQUAL(TNode(123432423).ConvertTo<TString>(), "123432423"); UNIT_ASSERT_VALUES_EQUAL(TNode(123456789012345678ll).ConvertTo<TString>(), "123456789012345678"); @@ -326,7 +326,7 @@ Y_UNIT_TEST_SUITE(YtNodeTest) { UNIT_ASSERT_VALUES_EQUAL(TNode(5.3).ConvertTo<TString>(), "5.3"); } - Y_UNIT_TEST(TestConvertFromString) { + Y_UNIT_TEST(TestConvertFromString) { UNIT_ASSERT_VALUES_EQUAL(TNode("123456789012345678").ConvertTo<ui64>(), 123456789012345678ull); UNIT_ASSERT_VALUES_EQUAL(TNode("123456789012345678").ConvertTo<i64>(), 123456789012345678); UNIT_ASSERT_VALUES_EQUAL(TNode(ToString(1ull << 63)).ConvertTo<ui64>(), 1ull << 63); @@ -334,7 +334,7 @@ Y_UNIT_TEST_SUITE(YtNodeTest) { UNIT_ASSERT_VALUES_EQUAL(TNode("5.34").ConvertTo<double>(), 5.34); } - Y_UNIT_TEST(TestConvertDoubleInt) { + Y_UNIT_TEST(TestConvertDoubleInt) { UNIT_ASSERT_VALUES_EQUAL(TNode(5.3).ConvertTo<i8>(), 5); UNIT_ASSERT_VALUES_EQUAL(TNode(5.3).ConvertTo<ui8>(), 5); UNIT_ASSERT_VALUES_EQUAL(TNode(5.3).ConvertTo<i64>(), 5); @@ -372,7 +372,7 @@ Y_UNIT_TEST_SUITE(YtNodeTest) { UNIT_ASSERT_EXCEPTION(TNode(INFINITY).ConvertTo<i64>(), TNode::TTypeError); } - Y_UNIT_TEST(TestConvertToBool) { + Y_UNIT_TEST(TestConvertToBool) { UNIT_ASSERT_VALUES_EQUAL(TNode("true").ConvertTo<bool>(), true); UNIT_ASSERT_VALUES_EQUAL(TNode("TRUE").ConvertTo<bool>(), true); UNIT_ASSERT_VALUES_EQUAL(TNode("false").ConvertTo<bool>(), false); @@ -383,7 +383,7 @@ Y_UNIT_TEST_SUITE(YtNodeTest) { UNIT_ASSERT_EXCEPTION(TNode("").ConvertTo<bool>(), TFromStringException); } - Y_UNIT_TEST(TestCanonicalSerialization) { + Y_UNIT_TEST(TestCanonicalSerialization) { auto node = TNode() ("ca", "ca")("c", "c")("a", "a")("b", "b") ("bb", TNode() diff --git a/library/cpp/yson/parser.cpp b/library/cpp/yson/parser.cpp index 783f9b90479..99d2e55b9c8 100644 --- a/library/cpp/yson/parser.cpp +++ b/library/cpp/yson/parser.cpp @@ -47,7 +47,7 @@ namespace NYson { TYsonParser::TYsonParser( NYT::NYson::IYsonConsumer* consumer, - IInputStream* stream, + IInputStream* stream, EYsonType type, bool enableLinePositionInfo, TMaybe<ui64> memoryLimit) @@ -160,7 +160,7 @@ namespace NYson { TYsonListParser::TYsonListParser( NYT::NYson::IYsonConsumer* consumer, - IInputStream* stream, + IInputStream* stream, bool enableLinePositionInfo, TMaybe<ui64> memoryLimit) : Impl(new TImpl(consumer, stream, enableLinePositionInfo, memoryLimit)) diff --git a/library/cpp/yson/parser.h b/library/cpp/yson/parser.h index dce35a8cd40..1cb6fa0919f 100644 --- a/library/cpp/yson/parser.h +++ b/library/cpp/yson/parser.h @@ -5,7 +5,7 @@ #include <util/generic/maybe.h> #include <util/generic/ptr.h> -class IInputStream; +class IInputStream; namespace NYT::NYson { struct IYsonConsumer; diff --git a/library/cpp/yson/writer.h b/library/cpp/yson/writer.h index 40f5d7d5014..a43cce58f3b 100644 --- a/library/cpp/yson/writer.h +++ b/library/cpp/yson/writer.h @@ -6,8 +6,8 @@ #include <util/generic/noncopyable.h> -class IOutputStream; -class IZeroCopyInput; +class IOutputStream; +class IZeroCopyInput; namespace NYson { //////////////////////////////////////////////////////////////////////////////// diff --git a/library/cpp/yson_pull/detail/input/stream.h b/library/cpp/yson_pull/detail/input/stream.h index 791cd5a3f52..dfc1fc98bae 100644 --- a/library/cpp/yson_pull/detail/input/stream.h +++ b/library/cpp/yson_pull/detail/input/stream.h @@ -14,7 +14,7 @@ namespace NYsonPull { namespace NInput { class TStreamBase: public NYsonPull::NInput::IStream { protected: - result DoFillBufferFrom(IZeroCopyInput& input) { + result DoFillBufferFrom(IZeroCopyInput& input) { void* ptr = nullptr; size_t size = input.Next(&ptr); if (Y_UNLIKELY(size == 0)) { @@ -26,10 +26,10 @@ namespace NYsonPull { }; class TZeroCopy: public TStreamBase { - IZeroCopyInput* Input; + IZeroCopyInput* Input; public: - explicit TZeroCopy(IZeroCopyInput* input) + explicit TZeroCopy(IZeroCopyInput* input) : Input(input) { } diff --git a/library/cpp/yson_pull/detail/output/stream.h b/library/cpp/yson_pull/detail/output/stream.h index d4810f33538..494e2980685 100644 --- a/library/cpp/yson_pull/detail/output/stream.h +++ b/library/cpp/yson_pull/detail/output/stream.h @@ -13,10 +13,10 @@ namespace NYsonPull { namespace NDetail { namespace NOutput { class TStream: public TBuffered<TStream> { - IOutputStream* Output; + IOutputStream* Output; public: - TStream(IOutputStream* output, size_t buffer_size) + TStream(IOutputStream* output, size_t buffer_size) : TBuffered<TStream>(buffer_size) , Output(output) { diff --git a/library/cpp/yson_pull/event.cpp b/library/cpp/yson_pull/event.cpp index b7ede494b60..b75d97fd8fb 100644 --- a/library/cpp/yson_pull/event.cpp +++ b/library/cpp/yson_pull/event.cpp @@ -7,7 +7,7 @@ using namespace NYsonPull; template <> -void Out<TEvent>(IOutputStream& out, const TEvent& value) { +void Out<TEvent>(IOutputStream& out, const TEvent& value) { out << '(' << value.Type(); if (value.Type() == EEventType::Scalar) { out << ' ' << value.AsScalar(); diff --git a/library/cpp/yson_pull/input.cpp b/library/cpp/yson_pull/input.cpp index 1373c898689..9b75c4c297b 100644 --- a/library/cpp/yson_pull/input.cpp +++ b/library/cpp/yson_pull/input.cpp @@ -24,10 +24,10 @@ THolder<IStream> NInput::FromMemory(TStringBuf data) { return MakeHolder<TOwned<TMemoryInput>>(data); } -THolder<IStream> NInput::FromInputStream(IInputStream* input, size_t buffer_size) { +THolder<IStream> NInput::FromInputStream(IInputStream* input, size_t buffer_size) { return MakeHolder<TOwned<TBufferedInput>>(input, buffer_size); } -THolder<IStream> NInput::FromZeroCopyInput(IZeroCopyInput* input) { +THolder<IStream> NInput::FromZeroCopyInput(IZeroCopyInput* input) { return MakeHolder<TZeroCopy>(input); } diff --git a/library/cpp/yson_pull/input.h b/library/cpp/yson_pull/input.h index 2cdfae857eb..66184de034b 100644 --- a/library/cpp/yson_pull/input.h +++ b/library/cpp/yson_pull/input.h @@ -10,8 +10,8 @@ #include <cstddef> #include <memory> -class IInputStream; -class IZeroCopyInput; +class IInputStream; +class IZeroCopyInput; namespace NYsonPull { namespace NInput { @@ -74,8 +74,8 @@ namespace NYsonPull { //! Does not take ownership on streambuf. THolder<IStream> FromPosixFd(int fd, size_t buffer_size = 65536); - THolder<IStream> FromZeroCopyInput(IZeroCopyInput* input); + THolder<IStream> FromZeroCopyInput(IZeroCopyInput* input); - THolder<IStream> FromInputStream(IInputStream* input, size_t buffer_size = 65536); + THolder<IStream> FromInputStream(IInputStream* input, size_t buffer_size = 65536); } } diff --git a/library/cpp/yson_pull/output.cpp b/library/cpp/yson_pull/output.cpp index 27c9ef9e694..5d58966dbe6 100644 --- a/library/cpp/yson_pull/output.cpp +++ b/library/cpp/yson_pull/output.cpp @@ -24,6 +24,6 @@ THolder<IStream> NOutput::FromString(TString* output, size_t buffer_size) { return MakeHolder<TOwned<TStringOutput>>(buffer_size, *output); } -THolder<IStream> NOutput::FromOutputStream(IOutputStream* output, size_t buffer_size) { +THolder<IStream> NOutput::FromOutputStream(IOutputStream* output, size_t buffer_size) { return MakeHolder<TStream>(output, buffer_size); } diff --git a/library/cpp/yson_pull/output.h b/library/cpp/yson_pull/output.h index 2d78107a93f..32d55a6b0b5 100644 --- a/library/cpp/yson_pull/output.h +++ b/library/cpp/yson_pull/output.h @@ -58,7 +58,7 @@ namespace NYsonPull { //! \brief Write data to POSIX file descriptor THolder<IStream> FromPosixFd(int fd, size_t buffer_size = 65536); - THolder<IStream> FromOutputStream(IOutputStream* output, size_t buffer_size = 65536); + THolder<IStream> FromOutputStream(IOutputStream* output, size_t buffer_size = 65536); THolder<IStream> FromString(TString* output, size_t buffer_size = 1024); } diff --git a/library/cpp/yson_pull/scalar.cpp b/library/cpp/yson_pull/scalar.cpp index 4325542e7ac..a538a07ecff 100644 --- a/library/cpp/yson_pull/scalar.cpp +++ b/library/cpp/yson_pull/scalar.cpp @@ -7,7 +7,7 @@ using namespace NYsonPull; template <> -void Out<TScalar>(IOutputStream& out, const TScalar& value) { +void Out<TScalar>(IOutputStream& out, const TScalar& value) { out << '(' << value.Type(); if (value.Type() != EScalarType::Entity) { out << ' '; diff --git a/library/cpp/yson_pull/ut/cescape_ut.cpp b/library/cpp/yson_pull/ut/cescape_ut.cpp index 6628ba1d156..8e1547cdacb 100644 --- a/library/cpp/yson_pull/ut/cescape_ut.cpp +++ b/library/cpp/yson_pull/ut/cescape_ut.cpp @@ -39,20 +39,20 @@ namespace { } // anonymous namespace -Y_UNIT_TEST_SUITE(CEscape) { - Y_UNIT_TEST(ExhaustiveOneChar) { +Y_UNIT_TEST_SUITE(CEscape) { + Y_UNIT_TEST(ExhaustiveOneChar) { test_exhaustive<1>(); } - Y_UNIT_TEST(ExhaustiveTwoChars) { + Y_UNIT_TEST(ExhaustiveTwoChars) { test_exhaustive<2>(); } - Y_UNIT_TEST(ExhaustiveThreeChars) { + Y_UNIT_TEST(ExhaustiveThreeChars) { test_exhaustive<3>(); } - Y_UNIT_TEST(SpecialEscapeEncode) { + Y_UNIT_TEST(SpecialEscapeEncode) { //UNIT_ASSERT_VALUES_EQUAL(R"(\b)", NCEscape::encode("\b")); //UNIT_ASSERT_VALUES_EQUAL(R"(\f)", NCEscape::encode("\f")); UNIT_ASSERT_VALUES_EQUAL(R"(\n)", NCEscape::encode("\n")); @@ -60,7 +60,7 @@ Y_UNIT_TEST_SUITE(CEscape) { UNIT_ASSERT_VALUES_EQUAL(R"(\t)", NCEscape::encode("\t")); } - Y_UNIT_TEST(SpecialEscapeDecode) { + Y_UNIT_TEST(SpecialEscapeDecode) { UNIT_ASSERT_VALUES_EQUAL("\b", NCEscape::decode(R"(\b)")); UNIT_ASSERT_VALUES_EQUAL("\f", NCEscape::decode(R"(\f)")); UNIT_ASSERT_VALUES_EQUAL("\n", NCEscape::decode(R"(\n)")); @@ -68,4 +68,4 @@ Y_UNIT_TEST_SUITE(CEscape) { UNIT_ASSERT_VALUES_EQUAL("\t", NCEscape::decode(R"(\t)")); } -} // Y_UNIT_TEST_SUITE(CEscape) +} // Y_UNIT_TEST_SUITE(CEscape) diff --git a/library/cpp/yson_pull/ut/loop_ut.cpp b/library/cpp/yson_pull/ut/loop_ut.cpp index 8c7b11dd1cd..8ca651dc304 100644 --- a/library/cpp/yson_pull/ut/loop_ut.cpp +++ b/library/cpp/yson_pull/ut/loop_ut.cpp @@ -202,7 +202,7 @@ namespace { class sys_error {}; - IOutputStream& operator<<(IOutputStream& stream, const sys_error&) { + IOutputStream& operator<<(IOutputStream& stream, const sys_error&) { stream << strerror(errno); return stream; } @@ -317,66 +317,66 @@ namespace { } // anonymous namespace -Y_UNIT_TEST_SUITE(Loop) { - Y_UNIT_TEST(memory_pretty_text) { +Y_UNIT_TEST_SUITE(Loop) { + Y_UNIT_TEST(memory_pretty_text) { test_memory(pretty_text, 100); } - Y_UNIT_TEST(memory_text) { + Y_UNIT_TEST(memory_text) { test_memory(text, 100); } - Y_UNIT_TEST(memory_binary) { + Y_UNIT_TEST(memory_binary) { test_memory(binary, 100); } #ifdef _unix_ - Y_UNIT_TEST(posix_fd_pretty_text_buffered) { + Y_UNIT_TEST(posix_fd_pretty_text_buffered) { test_posix_fd(pretty_text, 100, 1024, 1024); } - Y_UNIT_TEST(posix_fd_pretty_text_unbuffered) { + Y_UNIT_TEST(posix_fd_pretty_text_unbuffered) { test_posix_fd(pretty_text, 100, 1, 0); } - Y_UNIT_TEST(posix_fd_text_buffered) { + Y_UNIT_TEST(posix_fd_text_buffered) { test_posix_fd(text, 100, 1024, 1024); } - Y_UNIT_TEST(posix_fd_text_unbuffered) { + Y_UNIT_TEST(posix_fd_text_unbuffered) { test_posix_fd(text, 100, 1, 0); } - Y_UNIT_TEST(posix_fd_binary_buffered) { + Y_UNIT_TEST(posix_fd_binary_buffered) { test_posix_fd(binary, 100, 1024, 1024); } - Y_UNIT_TEST(posix_fd_binary_unbuffered) { + Y_UNIT_TEST(posix_fd_binary_unbuffered) { test_posix_fd(binary, 100, 1, 0); } - Y_UNIT_TEST(stdio_file_pretty_text_buffered) { + Y_UNIT_TEST(stdio_file_pretty_text_buffered) { test_stdio_file(pretty_text, 100, 1024, 1024); } - Y_UNIT_TEST(stdio_file_pretty_text_unbuffered) { + Y_UNIT_TEST(stdio_file_pretty_text_unbuffered) { test_stdio_file(pretty_text, 100, 1, 0); } - Y_UNIT_TEST(stdio_file_text_buffered) { + Y_UNIT_TEST(stdio_file_text_buffered) { test_stdio_file(text, 100, 1024, 1024); } - Y_UNIT_TEST(stdio_file_text_unbuffered) { + Y_UNIT_TEST(stdio_file_text_unbuffered) { test_stdio_file(text, 100, 1, 0); } - Y_UNIT_TEST(stdio_file_binary_buffered) { + Y_UNIT_TEST(stdio_file_binary_buffered) { test_stdio_file(binary, 100, 1024, 1024); } - Y_UNIT_TEST(stdio_file_binary_unbuffered) { + Y_UNIT_TEST(stdio_file_binary_unbuffered) { test_stdio_file(binary, 100, 1, 0); } #endif -} // Y_UNIT_TEST_SUITE(Loop) +} // Y_UNIT_TEST_SUITE(Loop) diff --git a/library/cpp/yson_pull/ut/reader_ut.cpp b/library/cpp/yson_pull/ut/reader_ut.cpp index 1184265ddbc..21fb5e01a45 100644 --- a/library/cpp/yson_pull/ut/reader_ut.cpp +++ b/library/cpp/yson_pull/ut/reader_ut.cpp @@ -73,12 +73,12 @@ namespace { } // anonymous namespace -Y_UNIT_TEST_SUITE(Reader) { - Y_UNIT_TEST(ScalarEntity) { +Y_UNIT_TEST_SUITE(Reader) { + Y_UNIT_TEST(ScalarEntity) { test_scalar(TStringBuf("#"), NYsonPull::TScalar{}); } - Y_UNIT_TEST(ScalarBoolean) { + Y_UNIT_TEST(ScalarBoolean) { test_scalar(TStringBuf("%true"), true); test_scalar(TStringBuf("%false"), false); @@ -93,7 +93,7 @@ Y_UNIT_TEST_SUITE(Reader) { REJECT("%hithere"); } - Y_UNIT_TEST(ScalarInt64) { + Y_UNIT_TEST(ScalarInt64) { test_scalar(TStringBuf("1"), i64{1}); test_scalar(TStringBuf("+1"), i64{1}); test_scalar(TStringBuf("100000"), i64{100000}); @@ -112,7 +112,7 @@ Y_UNIT_TEST_SUITE(Reader) { REJECT("1+0"); } - Y_UNIT_TEST(SclarUInt64) { + Y_UNIT_TEST(SclarUInt64) { test_scalar(TStringBuf("1u"), ui64{1}); test_scalar(TStringBuf("+1u"), ui64{1}); test_scalar(TStringBuf("100000u"), ui64{100000}); @@ -129,7 +129,7 @@ Y_UNIT_TEST_SUITE(Reader) { // TODO: binary } - Y_UNIT_TEST(ScalarFloat64) { + Y_UNIT_TEST(ScalarFloat64) { test_scalar(TStringBuf("0.0"), double{0.0}); test_scalar(TStringBuf("+0.0"), double{0.0}); test_scalar(TStringBuf("+.0"), double{0.0}); @@ -193,7 +193,7 @@ Y_UNIT_TEST_SUITE(Reader) { REJECT("%-in"); } - Y_UNIT_TEST(ScalarString) { + Y_UNIT_TEST(ScalarString) { test_scalar(TStringBuf(R"(foobar)"), TStringBuf("foobar")); test_scalar(TStringBuf(R"(foobar11)"), TStringBuf("foobar11")); test_scalar(TStringBuf(R"("foobar")"), TStringBuf("foobar")); @@ -206,7 +206,7 @@ Y_UNIT_TEST_SUITE(Reader) { REJECT("\x01\x0d" "foobar"sv); // negative length } - Y_UNIT_TEST(EmptyList) { + Y_UNIT_TEST(EmptyList) { auto reader = memory_reader("[]", NYsonPull::EStreamType::Node); UNIT_ASSERT_VALUES_EQUAL(NYsonPull::EEventType::BeginStream, reader.NextEvent().Type()); @@ -218,7 +218,7 @@ Y_UNIT_TEST_SUITE(Reader) { REJECT("]"); } - Y_UNIT_TEST(EmptyMap) { + Y_UNIT_TEST(EmptyMap) { auto reader = memory_reader("{}", NYsonPull::EStreamType::Node); UNIT_ASSERT_VALUES_EQUAL(NYsonPull::EEventType::BeginStream, reader.NextEvent().Type()); @@ -230,7 +230,7 @@ Y_UNIT_TEST_SUITE(Reader) { REJECT("}"); } - Y_UNIT_TEST(Sample) { + Y_UNIT_TEST(Sample) { auto reader = memory_reader( R"({"11"=11;"nothing"=#;"zero"=0.;"foo"="bar";"list"=[1;2;3]})", NYsonPull::EStreamType::Node); @@ -309,7 +309,7 @@ Y_UNIT_TEST_SUITE(Reader) { UNIT_ASSERT_VALUES_EQUAL(NYsonPull::EEventType::EndStream, reader.NextEvent().Type()); } - Y_UNIT_TEST(Accept) { + Y_UNIT_TEST(Accept) { ACCEPT("[]"); ACCEPT("{}"); ACCEPT("<>[]"); @@ -330,7 +330,7 @@ Y_UNIT_TEST_SUITE(Reader) { ACCEPT("{foo=<foo=foo>[foo;foo]}"); } - Y_UNIT_TEST(Reject) { + Y_UNIT_TEST(Reject) { REJECT("["); REJECT("{"); REJECT("<"); @@ -352,7 +352,7 @@ Y_UNIT_TEST_SUITE(Reader) { REJECT("@"); } - Y_UNIT_TEST(ReadPastEnd) { + Y_UNIT_TEST(ReadPastEnd) { auto reader = memory_reader("#", NYsonPull::EStreamType::Node); UNIT_ASSERT_VALUES_EQUAL(NYsonPull::EEventType::BeginStream, reader.NextEvent().Type()); UNIT_ASSERT_VALUES_EQUAL(NYsonPull::EEventType::Scalar, reader.NextEvent().Type()); @@ -369,7 +369,7 @@ Y_UNIT_TEST_SUITE(Reader) { UNIT_ASSERT_EXCEPTION(reader.NextEvent(), NYsonPull::NException::TBadInput); } - Y_UNIT_TEST(StreamType) { + Y_UNIT_TEST(StreamType) { REJECT2("", NYsonPull::EStreamType::Node); ACCEPT2("", NYsonPull::EStreamType::ListFragment); ACCEPT2("", NYsonPull::EStreamType::MapFragment); @@ -407,4 +407,4 @@ Y_UNIT_TEST_SUITE(Reader) { ACCEPT2("a=[1]; b=foobar", NYsonPull::EStreamType::MapFragment); } -} // Y_UNIT_TEST_SUITE(Reader) +} // Y_UNIT_TEST_SUITE(Reader) diff --git a/library/cpp/yson_pull/ut/writer_ut.cpp b/library/cpp/yson_pull/ut/writer_ut.cpp index 5c304bad0f3..79e19930dfe 100644 --- a/library/cpp/yson_pull/ut/writer_ut.cpp +++ b/library/cpp/yson_pull/ut/writer_ut.cpp @@ -44,14 +44,14 @@ namespace { // =================== Text format ===================== -Y_UNIT_TEST_SUITE(Writer) { - Y_UNIT_TEST(TextEntity) { +Y_UNIT_TEST_SUITE(Writer) { + Y_UNIT_TEST(TextEntity) { UNIT_ASSERT_VALUES_EQUAL( "#", to_yson_text_string(NYsonPull::TScalar{})); } - Y_UNIT_TEST(TextBoolean) { + Y_UNIT_TEST(TextBoolean) { UNIT_ASSERT_VALUES_EQUAL( "%false", to_yson_text_string(NYsonPull::TScalar{false})); @@ -60,7 +60,7 @@ Y_UNIT_TEST_SUITE(Writer) { to_yson_text_string(NYsonPull::TScalar{true})); } - Y_UNIT_TEST(TextInt64) { + Y_UNIT_TEST(TextInt64) { UNIT_ASSERT_VALUES_EQUAL( "0", to_yson_text_string(NYsonPull::TScalar{i64{0}})); @@ -97,7 +97,7 @@ Y_UNIT_TEST_SUITE(Writer) { to_yson_text_string(NYsonPull::TScalar{i64{INT64_MIN}})); } - Y_UNIT_TEST(TextUInt64) { + Y_UNIT_TEST(TextUInt64) { UNIT_ASSERT_VALUES_EQUAL( "0u", to_yson_text_string(NYsonPull::TScalar{ui64{0}})); @@ -121,7 +121,7 @@ Y_UNIT_TEST_SUITE(Writer) { to_yson_text_string(NYsonPull::TScalar{ui64{UINT64_MAX}})); } - Y_UNIT_TEST(TextFloat64) { + Y_UNIT_TEST(TextFloat64) { UNIT_ASSERT_VALUES_EQUAL( "%inf", to_yson_text_string(NYsonPull::TScalar{std::numeric_limits<double>::infinity()})); @@ -133,7 +133,7 @@ Y_UNIT_TEST_SUITE(Writer) { to_yson_text_string(NYsonPull::TScalar{std::numeric_limits<double>::quiet_NaN()})); } - Y_UNIT_TEST(TextString) { + Y_UNIT_TEST(TextString) { UNIT_ASSERT_VALUES_EQUAL( R"("")", to_yson_text_string(NYsonPull::TScalar{""})); @@ -147,13 +147,13 @@ Y_UNIT_TEST_SUITE(Writer) { // =================== Binary format ===================== - Y_UNIT_TEST(BinaryEntity) { + Y_UNIT_TEST(BinaryEntity) { UNIT_ASSERT_VALUES_EQUAL( "#", to_yson_binary_string(NYsonPull::TScalar{})); } - Y_UNIT_TEST(BinaryBoolean) { + Y_UNIT_TEST(BinaryBoolean) { UNIT_ASSERT_VALUES_EQUAL( TStringBuf("\x4"), to_yson_binary_string(NYsonPull::TScalar{false})); @@ -162,7 +162,7 @@ Y_UNIT_TEST_SUITE(Writer) { to_yson_binary_string(NYsonPull::TScalar{true})); } - Y_UNIT_TEST(BinaryInt64) { + Y_UNIT_TEST(BinaryInt64) { UNIT_ASSERT_VALUES_EQUAL( TStringBuf("\x2\0"sv), to_yson_binary_string(NYsonPull::TScalar{i64{0}})); @@ -199,7 +199,7 @@ Y_UNIT_TEST_SUITE(Writer) { to_yson_binary_string(NYsonPull::TScalar{i64{INT64_MIN}})); } - Y_UNIT_TEST(BinaryUInt64) { + Y_UNIT_TEST(BinaryUInt64) { UNIT_ASSERT_VALUES_EQUAL( TStringBuf("\x6\0"sv), to_yson_binary_string(NYsonPull::TScalar{ui64{0}})); @@ -223,7 +223,7 @@ Y_UNIT_TEST_SUITE(Writer) { to_yson_binary_string(NYsonPull::TScalar{ui64{UINT64_MAX}})); } - Y_UNIT_TEST(BinaryFloat64) { + Y_UNIT_TEST(BinaryFloat64) { UNIT_ASSERT_VALUES_EQUAL( TStringBuf("\x03\x00\x00\x00\x00\x00\x00\xf0\x7f"sv), to_yson_binary_string(NYsonPull::TScalar{std::numeric_limits<double>::infinity()})); @@ -241,7 +241,7 @@ Y_UNIT_TEST_SUITE(Writer) { to_yson_binary_string(NYsonPull::TScalar{double{-1.1}})); } - Y_UNIT_TEST(BinaryString) { + Y_UNIT_TEST(BinaryString) { UNIT_ASSERT_VALUES_EQUAL( TStringBuf("\x1\0"sv), to_yson_binary_string(NYsonPull::TScalar{""})); @@ -253,4 +253,4 @@ Y_UNIT_TEST_SUITE(Writer) { to_yson_binary_string(NYsonPull::TScalar{"hello\nworld"})); } -} // Y_UNIT_TEST_SUITE(Writer) +} // Y_UNIT_TEST_SUITE(Writer) diff --git a/library/python/cores/__init__.py b/library/python/cores/__init__.py index fdb1f82a465..3622acdfd72 100644 --- a/library/python/cores/__init__.py +++ b/library/python/cores/__init__.py @@ -1,193 +1,193 @@ -# coding: utf-8 - -import os -import re -import glob -import socket -import logging -import platform -import subprocess - +# coding: utf-8 + +import os +import re +import glob +import socket +import logging +import platform +import subprocess + import six -from library.python.reservoir_sampling import reservoir_sampling - - -logger = logging.getLogger(__name__) - - -def _read_file(filename): - with open(filename) as afile: - return afile.read().strip("\n") - - -def recover_core_dump_file(binary_path, cwd, pid): - - class CoreFilePattern(object): - def __init__(self, path, mask): - self.path = path - self.mask = mask - +from library.python.reservoir_sampling import reservoir_sampling + + +logger = logging.getLogger(__name__) + + +def _read_file(filename): + with open(filename) as afile: + return afile.read().strip("\n") + + +def recover_core_dump_file(binary_path, cwd, pid): + + class CoreFilePattern(object): + def __init__(self, path, mask): + self.path = path + self.mask = mask + cwd = cwd or os.getcwd() - system = platform.system().lower() - if system.startswith("linux"): - import stat - import resource - - logger.debug("hostname = '%s'", socket.gethostname()) - logger.debug("rlimit_core = '%s'", str(resource.getrlimit(resource.RLIMIT_CORE))) - core_pattern = _read_file("/proc/sys/kernel/core_pattern") - logger.debug("core_pattern = '%s'", core_pattern) - if core_pattern.startswith("/"): - default_pattern = CoreFilePattern(os.path.dirname(core_pattern), '*') - else: - default_pattern = CoreFilePattern(cwd, '*') - - def resolve_core_mask(core_mask): - def resolve(text): - if text == "%p": - return str(pid) - elif text == "%e": - # https://github.com/torvalds/linux/blob/7876320f88802b22d4e2daf7eb027dd14175a0f8/include/linux/sched.h#L847 - # https://github.com/torvalds/linux/blob/7876320f88802b22d4e2daf7eb027dd14175a0f8/fs/coredump.c#L278 - return os.path.basename(binary_path)[:15] - elif text == "%E": - return binary_path.replace("/", "!") - elif text == "%%": - return "%" - elif text.startswith("%"): - return "*" - return text - - parts = filter(None, re.split(r"(%.)", core_mask)) - return "".join([resolve(p) for p in parts]) - - # don't interpret a program for piping core dumps as a pattern - if core_pattern and not core_pattern.startswith("|"): - default_pattern.mask = os.path.basename(core_pattern) - else: - core_uses_pid = int(_read_file("/proc/sys/kernel/core_uses_pid")) - logger.debug("core_uses_pid = '%d'", core_uses_pid) - if core_uses_pid == 0: - default_pattern.mask = "core" - else: - default_pattern.mask = "core.%p" - - # widely distributed core dump dir and mask (see DEVTOOLS-4408) - yandex_pattern = CoreFilePattern('/coredumps', '%e.%p.%s') + system = platform.system().lower() + if system.startswith("linux"): + import stat + import resource + + logger.debug("hostname = '%s'", socket.gethostname()) + logger.debug("rlimit_core = '%s'", str(resource.getrlimit(resource.RLIMIT_CORE))) + core_pattern = _read_file("/proc/sys/kernel/core_pattern") + logger.debug("core_pattern = '%s'", core_pattern) + if core_pattern.startswith("/"): + default_pattern = CoreFilePattern(os.path.dirname(core_pattern), '*') + else: + default_pattern = CoreFilePattern(cwd, '*') + + def resolve_core_mask(core_mask): + def resolve(text): + if text == "%p": + return str(pid) + elif text == "%e": + # https://github.com/torvalds/linux/blob/7876320f88802b22d4e2daf7eb027dd14175a0f8/include/linux/sched.h#L847 + # https://github.com/torvalds/linux/blob/7876320f88802b22d4e2daf7eb027dd14175a0f8/fs/coredump.c#L278 + return os.path.basename(binary_path)[:15] + elif text == "%E": + return binary_path.replace("/", "!") + elif text == "%%": + return "%" + elif text.startswith("%"): + return "*" + return text + + parts = filter(None, re.split(r"(%.)", core_mask)) + return "".join([resolve(p) for p in parts]) + + # don't interpret a program for piping core dumps as a pattern + if core_pattern and not core_pattern.startswith("|"): + default_pattern.mask = os.path.basename(core_pattern) + else: + core_uses_pid = int(_read_file("/proc/sys/kernel/core_uses_pid")) + logger.debug("core_uses_pid = '%d'", core_uses_pid) + if core_uses_pid == 0: + default_pattern.mask = "core" + else: + default_pattern.mask = "core.%p" + + # widely distributed core dump dir and mask (see DEVTOOLS-4408) + yandex_pattern = CoreFilePattern('/coredumps', '%e.%p.%s') yandex_market_pattern = CoreFilePattern('/var/tmp/cores', 'core.%..%e.%s.%p.*') - + for pattern in [default_pattern, yandex_pattern, yandex_market_pattern]: - pattern.mask = resolve_core_mask(pattern.mask) - - if not os.path.exists(pattern.path): - logger.warning("Core dump dir doesn't exist: %s", pattern.path) - continue - - logger.debug( - "Core dump dir (%s) permission mask: %s (expected: %s (%s-dir, %s-sticky bit))", - pattern.path, - oct(os.stat(pattern.path)[stat.ST_MODE]), - oct(stat.S_IFDIR | stat.S_ISVTX | 0o777), - oct(stat.S_IFDIR), - oct(stat.S_ISVTX), - ) - logger.debug("Search for core dump files match pattern '%s' in '%s'", pattern.mask, pattern.path) - cores = glob.glob(os.path.join(pattern.path, pattern.mask)) - files = os.listdir(pattern.path) - logger.debug( - "Matched core dump files (%d/%d): [%s] (mismatched samples: %s)", - len(cores), - len(files), - ", ".join(cores), - ", ".join(reservoir_sampling(files, 5)), - ) - - if len(cores) == 1: - return cores[0] - elif len(cores) > 1: - stat = [(filename, os.stat(filename).st_mtime) for filename in cores] - entry = sorted(stat, key=lambda x: x[1])[-1] - logger.debug("Latest core dump file: '%s' with %d mtime", entry[0], entry[1]) - return entry[0] - else: - logger.debug("Core dump file recovering is not supported on '%s'", system) - return None - - -def get_gdb_full_backtrace(binary, core, gdb_path): - cmd = [ - gdb_path, binary, core, - "--eval-command", "set print thread-events off", - "--eval-command", "thread apply all backtrace full", - "--batch", - "--quiet", - ] - proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) - output, stderr = proc.communicate() + pattern.mask = resolve_core_mask(pattern.mask) + + if not os.path.exists(pattern.path): + logger.warning("Core dump dir doesn't exist: %s", pattern.path) + continue + + logger.debug( + "Core dump dir (%s) permission mask: %s (expected: %s (%s-dir, %s-sticky bit))", + pattern.path, + oct(os.stat(pattern.path)[stat.ST_MODE]), + oct(stat.S_IFDIR | stat.S_ISVTX | 0o777), + oct(stat.S_IFDIR), + oct(stat.S_ISVTX), + ) + logger.debug("Search for core dump files match pattern '%s' in '%s'", pattern.mask, pattern.path) + cores = glob.glob(os.path.join(pattern.path, pattern.mask)) + files = os.listdir(pattern.path) + logger.debug( + "Matched core dump files (%d/%d): [%s] (mismatched samples: %s)", + len(cores), + len(files), + ", ".join(cores), + ", ".join(reservoir_sampling(files, 5)), + ) + + if len(cores) == 1: + return cores[0] + elif len(cores) > 1: + stat = [(filename, os.stat(filename).st_mtime) for filename in cores] + entry = sorted(stat, key=lambda x: x[1])[-1] + logger.debug("Latest core dump file: '%s' with %d mtime", entry[0], entry[1]) + return entry[0] + else: + logger.debug("Core dump file recovering is not supported on '%s'", system) + return None + + +def get_gdb_full_backtrace(binary, core, gdb_path): + cmd = [ + gdb_path, binary, core, + "--eval-command", "set print thread-events off", + "--eval-command", "thread apply all backtrace full", + "--batch", + "--quiet", + ] + proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + output, stderr = proc.communicate() output = six.ensure_str(output) - if stderr: + if stderr: output += "\nstderr >>\n" + six.ensure_str(stderr) - return output - - -def get_problem_stack(backtrace): - stack = [] - found_thread1 = False - regex = re.compile(r'[Tt]hread (\d+)') - - for line in backtrace.split("\n"): - match = regex.search(line) - if match: - if found_thread1: - break - if int(match.group(1)) == 1: - found_thread1 = True - if found_thread1: - stack.append(line) - - if not stack: - return backtrace - return "\n".join(stack) - - -# XXX -def colorize_backtrace(text): - filters = [ - # Function names and the class they belong to - (re.compile(r"^(#[0-9]+ .*?)([a-zA-Z0-9_:\.@]+)(\s?\()", flags=re.MULTILINE), r"\1[[c:cyan]]\2[[rst]]\3"), - # Function argument names - (re.compile(r"([a-zA-Z0-9_#]*)(\s?=\s?)"), r"[[c:green]]\1[[rst]]\2"), - # Stack frame number - (re.compile(r"^(#[0-9]+)", flags=re.MULTILINE), r"[[c:red]]\1[[rst]]"), - # Thread id colorization - (re.compile(r"^([ \*]) ([0-9]+)", flags=re.MULTILINE), r"[[c:light-cyan]]\1 [[c:red]]\2[[rst]]"), - # File path and line number - (re.compile(r"(\.*[/A-Za-z0-9\+_\.\-]*):(([0-9]+)(:[0-9]+)?)$", flags=re.MULTILINE), r"[[c:light-grey]]\1[[rst]]:[[c:magenta]]\2[[rst]]"), - # Addresses - (re.compile(r"\b(0x[a-f0-9]{6,})\b"), r"[[c:light-grey]]\1[[rst]]"), - ] - - for regex, substitution in filters: - text = regex.sub(substitution, text) - return text - - -def resolve_addresses(addresses, symbolizer, binary): - addresses = list(set(addresses)) - cmd = [ - symbolizer, - "-demangle", - "-obj", - binary, - ] - proc = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) - out, err = proc.communicate(input="\n".join(addresses)) - if proc.returncode: - raise Exception("Symbolizer failed with rc:{}\nstderr: {}".format(proc.returncode, err)) - - resolved = filter(None, out.split("\n\n")) - if len(addresses) != len(resolved): - raise Exception("llvm-symbolizer can not extract lines from addresses (count mismatch: {}-{})".format(len(addresses), len(resolved))) - - return {k: v.strip(" \n") for k, v in zip(addresses, resolved)} + return output + + +def get_problem_stack(backtrace): + stack = [] + found_thread1 = False + regex = re.compile(r'[Tt]hread (\d+)') + + for line in backtrace.split("\n"): + match = regex.search(line) + if match: + if found_thread1: + break + if int(match.group(1)) == 1: + found_thread1 = True + if found_thread1: + stack.append(line) + + if not stack: + return backtrace + return "\n".join(stack) + + +# XXX +def colorize_backtrace(text): + filters = [ + # Function names and the class they belong to + (re.compile(r"^(#[0-9]+ .*?)([a-zA-Z0-9_:\.@]+)(\s?\()", flags=re.MULTILINE), r"\1[[c:cyan]]\2[[rst]]\3"), + # Function argument names + (re.compile(r"([a-zA-Z0-9_#]*)(\s?=\s?)"), r"[[c:green]]\1[[rst]]\2"), + # Stack frame number + (re.compile(r"^(#[0-9]+)", flags=re.MULTILINE), r"[[c:red]]\1[[rst]]"), + # Thread id colorization + (re.compile(r"^([ \*]) ([0-9]+)", flags=re.MULTILINE), r"[[c:light-cyan]]\1 [[c:red]]\2[[rst]]"), + # File path and line number + (re.compile(r"(\.*[/A-Za-z0-9\+_\.\-]*):(([0-9]+)(:[0-9]+)?)$", flags=re.MULTILINE), r"[[c:light-grey]]\1[[rst]]:[[c:magenta]]\2[[rst]]"), + # Addresses + (re.compile(r"\b(0x[a-f0-9]{6,})\b"), r"[[c:light-grey]]\1[[rst]]"), + ] + + for regex, substitution in filters: + text = regex.sub(substitution, text) + return text + + +def resolve_addresses(addresses, symbolizer, binary): + addresses = list(set(addresses)) + cmd = [ + symbolizer, + "-demangle", + "-obj", + binary, + ] + proc = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + out, err = proc.communicate(input="\n".join(addresses)) + if proc.returncode: + raise Exception("Symbolizer failed with rc:{}\nstderr: {}".format(proc.returncode, err)) + + resolved = filter(None, out.split("\n\n")) + if len(addresses) != len(resolved): + raise Exception("llvm-symbolizer can not extract lines from addresses (count mismatch: {}-{})".format(len(addresses), len(resolved))) + + return {k: v.strip(" \n") for k, v in zip(addresses, resolved)} diff --git a/library/python/cores/ya.make b/library/python/cores/ya.make index 76264e9cce0..13bfe64950f 100644 --- a/library/python/cores/ya.make +++ b/library/python/cores/ya.make @@ -1,15 +1,15 @@ -OWNER( - prettyboy +OWNER( + prettyboy g:yatest -) - -PY23_LIBRARY() - +) + +PY23_LIBRARY() + PY_SRCS(__init__.py) - -PEERDIR( + +PEERDIR( contrib/python/six - library/python/reservoir_sampling -) - -END() + library/python/reservoir_sampling +) + +END() diff --git a/library/python/reservoir_sampling/__init__.py b/library/python/reservoir_sampling/__init__.py index 4ee46ee5e11..7fc579feb43 100644 --- a/library/python/reservoir_sampling/__init__.py +++ b/library/python/reservoir_sampling/__init__.py @@ -1,16 +1,16 @@ -import random - - -def reservoir_sampling(data, nsamples, prng=None): - if prng is None: - prng = random - - result = [] - for i, entry in enumerate(data): - if i < nsamples: - result.append(entry) - else: - j = prng.randint(0, i) - if j < nsamples: - result[j] = entry - return result +import random + + +def reservoir_sampling(data, nsamples, prng=None): + if prng is None: + prng = random + + result = [] + for i, entry in enumerate(data): + if i < nsamples: + result.append(entry) + else: + j = prng.randint(0, i) + if j < nsamples: + result[j] = entry + return result diff --git a/library/python/reservoir_sampling/ya.make b/library/python/reservoir_sampling/ya.make index 24cac20157d..f94ff6a90bb 100644 --- a/library/python/reservoir_sampling/ya.make +++ b/library/python/reservoir_sampling/ya.make @@ -1,10 +1,10 @@ -OWNER( - prettyboy - g:yatool -) - -PY23_LIBRARY() - +OWNER( + prettyboy + g:yatool +) + +PY23_LIBRARY() + PY_SRCS(__init__.py) - -END() + +END() diff --git a/library/python/svn_version/ut/lib/test_simple.py b/library/python/svn_version/ut/lib/test_simple.py index 2c27af6c682..dc999ad5ac9 100644 --- a/library/python/svn_version/ut/lib/test_simple.py +++ b/library/python/svn_version/ut/lib/test_simple.py @@ -1,8 +1,8 @@ -import library.python.svn_version as sv +import library.python.svn_version as sv def test_simple(): - assert sv.svn_version() + assert sv.svn_version() assert isinstance(sv.svn_version(), str) assert sv.svn_revision() assert isinstance(sv.svn_revision(), int) diff --git a/library/python/svn_version/ya.make b/library/python/svn_version/ya.make index 747a663f00e..c6fd54f5d27 100644 --- a/library/python/svn_version/ya.make +++ b/library/python/svn_version/ya.make @@ -8,8 +8,8 @@ PEERDIR( ) PY_SRCS( - __init__.py - __svn_version.pyx + __init__.py + __svn_version.pyx ) END() diff --git a/library/python/testing/yatest_common/ya.make b/library/python/testing/yatest_common/ya.make index 5662db4c5d3..a2bca9185bc 100644 --- a/library/python/testing/yatest_common/ya.make +++ b/library/python/testing/yatest_common/ya.make @@ -26,7 +26,7 @@ PY_SRCS( PEERDIR( contrib/python/six - library/python/cores + library/python/cores library/python/filelock library/python/fs ) diff --git a/library/python/testing/yatest_common/yatest/common/__init__.py b/library/python/testing/yatest_common/yatest/common/__init__.py index cf57779e27e..75c75ba3c6b 100644 --- a/library/python/testing/yatest_common/yatest/common/__init__.py +++ b/library/python/testing/yatest_common/yatest/common/__init__.py @@ -1,8 +1,8 @@ -from .benchmark import * # noqa -from .canonical import * # noqa -from .errors import * # noqa -from .misc import * # noqa +from .benchmark import * # noqa +from .canonical import * # noqa +from .errors import * # noqa +from .misc import * # noqa from .path import * # noqa from .process import * # noqa -from .runtime import * # noqa +from .runtime import * # noqa from .tags import * # noqa diff --git a/library/python/ya.make b/library/python/ya.make index 2e1eb6e0e1f..359e1cbc5b4 100644 --- a/library/python/ya.make +++ b/library/python/ya.make @@ -2,7 +2,7 @@ OWNER(g:python-contrib) RECURSE( aho_corasick - aho_corasick/ut + aho_corasick/ut archive archive/benchmark archive/test @@ -41,7 +41,7 @@ RECURSE( compress/tests cookiemy coredump_filter - cores + cores coverage cpp_test cppdemangle @@ -92,17 +92,17 @@ RECURSE( guid guid/test guid/at_fork_test - gunicorn + gunicorn hnsw ids - import_test + import_test infected_masks infected_masks/ut init_log - init_log/example + init_log/example intrasearch_fetcher json - json/compare + json/compare json/perf json/test json/test/py2 @@ -112,7 +112,7 @@ RECURSE( langs luigi luigi/data - luigi/example + luigi/example luigi/luigid_static maths messagebus @@ -151,7 +151,7 @@ RECURSE( python-django-yauth reactor redis_utils - reservoir_sampling + reservoir_sampling refsclient resource retry @@ -201,8 +201,8 @@ RECURSE( type_info/test unique_id vault_client - watch_dog - watch_dog/example + watch_dog + watch_dog/example wiki windows windows/ut diff --git a/tools/archiver/main.cpp b/tools/archiver/main.cpp index 6cda54c1ea8..29d68531965 100644 --- a/tools/archiver/main.cpp +++ b/tools/archiver/main.cpp @@ -19,9 +19,9 @@ #include <cstring> namespace { - class TStringArrayOutput: public IOutputStream { + class TStringArrayOutput: public IOutputStream { public: - TStringArrayOutput(IOutputStream* slave, size_t stride) + TStringArrayOutput(IOutputStream* slave, size_t stride) : Slave(*slave) , Stride(stride) { @@ -46,14 +46,14 @@ namespace { } private: - IOutputStream& Slave; + IOutputStream& Slave; const size_t Stride; TString Buf; }; - class THexOutput: public IOutputStream { + class THexOutput: public IOutputStream { public: - inline THexOutput(IOutputStream* slave) + inline THexOutput(IOutputStream* slave) : Slave_(slave) { } @@ -112,11 +112,11 @@ namespace { // width in source chars static const size_t Columns = 10; ui64 Count_ = 0; - IOutputStream* Slave_ = nullptr; + IOutputStream* Slave_ = nullptr; }; - struct TYasmOutput: public IOutputStream { - inline TYasmOutput(IOutputStream* out, const TString& base) + struct TYasmOutput: public IOutputStream { + inline TYasmOutput(IOutputStream* out, const TString& base) : Out_(out) , Base_(base) { @@ -157,13 +157,13 @@ namespace { } } - IOutputStream* Out_ = nullptr; + IOutputStream* Out_ = nullptr; const TString Base_; ui64 Count_ = 0; }; struct TCOutput: public THexOutput { - inline TCOutput(IOutputStream* out, const TString& base) + inline TCOutput(IOutputStream* out, const TString& base) : THexOutput(out) , B(base) { @@ -180,8 +180,8 @@ namespace { const TString B; }; - struct TCStringOutput: public IOutputStream { - inline TCStringOutput(IOutputStream* out, const TString& base) + struct TCStringOutput: public IOutputStream { + inline TCStringOutput(IOutputStream* out, const TString& base) : O(out) , B(base) { @@ -200,7 +200,7 @@ namespace { *O << ";\nextern const unsigned int " << B << "Size = sizeof(" << B << ") / sizeof(" << B << "[0]) - 1;\n}\n"; } - IOutputStream* O = nullptr; + IOutputStream* O = nullptr; const TString B; }; @@ -276,7 +276,7 @@ namespace { }; struct TDeduplicationArchiveWriter { - TDeduplicationArchiveWriter(const TDuplicatesMap& duplicatesMap, IOutputStream* out, bool compress) + TDeduplicationArchiveWriter(const TDuplicatesMap& duplicatesMap, IOutputStream* out, bool compress) : DuplicatesMap(duplicatesMap) , Writer(out, compress) {} @@ -290,7 +290,7 @@ namespace { }; } -static inline TAutoPtr<IOutputStream> OpenOutput(const TString& url) { +static inline TAutoPtr<IOutputStream> OpenOutput(const TString& url) { if (url.empty()) { return new TBuffered<TUnbufferedFileOutput>(8192, Duplicate(1)); } else { @@ -328,14 +328,14 @@ static inline TString Fix(TString f) { static bool Quiet = false; -static inline void Append(IOutputStream& w, const TString& fname, const TString& rname) { +static inline void Append(IOutputStream& w, const TString& fname, const TString& rname) { TMappedFileInput in(fname); if (!Quiet) { Cerr << "--> " << rname << Endl; } - TransferData((IInputStream*)&in, &w); + TransferData((IInputStream*)&in, &w); } static inline void Append(TDuplicatesMap& w, const TString& fname, const TString& rname) { @@ -447,7 +447,7 @@ static void UnpackArchive(const TString& archive, const TFsPath& dir = TFsPath() } const TFsPath path(dir / fileName); path.Parent().MkDirs(); - TAutoPtr<IInputStream> in = reader.ObjectByKey(key); + TAutoPtr<IInputStream> in = reader.ObjectByKey(key); TFixedBufferFileOutput out(path); TransferData(in.Get(), &out); out.Finish(); @@ -647,9 +647,9 @@ int main(int argc, char** argv) { UnpackArchive(rec.Path, dir); } } else { - TAutoPtr<IOutputStream> outf(OpenOutput(outputf)); - IOutputStream* out = outf.Get(); - THolder<IOutputStream> hexout; + TAutoPtr<IOutputStream> outf(OpenOutput(outputf)); + IOutputStream* out = outf.Get(); + THolder<IOutputStream> hexout; if (hexdump) { hexout.Reset(new THexOutput(out)); diff --git a/tools/enum_parser/enum_parser/main.cpp b/tools/enum_parser/enum_parser/main.cpp index 0943c69c1da..24ea1a13ed4 100644 --- a/tools/enum_parser/enum_parser/main.cpp +++ b/tools/enum_parser/enum_parser/main.cpp @@ -24,7 +24,7 @@ #include <util/system/fs.h> #include <util/folder/path.h> -void WriteHeader(const TString& headerName, IOutputStream& out, IOutputStream* headerOutPtr = nullptr) { +void WriteHeader(const TString& headerName, IOutputStream& out, IOutputStream* headerOutPtr = nullptr) { out << "// This file was auto-generated. Do not edit!!!\n"; out << "#include " << headerName << "\n"; out << "#include <tools/enum_parser/enum_serialization_runtime/enum_runtime.h>\n\n"; @@ -64,7 +64,7 @@ static inline TString JsonQuote(const TString& s) { /// Simplifed JSON map encoder for generic types template<typename T> -void OutKey(IOutputStream& out, const TString& key, const T& value, bool escape = true) { +void OutKey(IOutputStream& out, const TString& key, const T& value, bool escape = true) { TString quoted = ToString(value); if (escape) { quoted = JsonQuote(quoted); @@ -73,7 +73,7 @@ void OutKey(IOutputStream& out, const TString& key, const T& value, bool escape } /// Simplifed JSON map encoder for TMaybe -void OutKey(IOutputStream& out, const TString& key, const TMaybe<TString>& value) { +void OutKey(IOutputStream& out, const TString& key, const TMaybe<TString>& value) { TString quoted; if (value) { quoted = JsonQuote(ToString(*value)); @@ -85,14 +85,14 @@ void OutKey(IOutputStream& out, const TString& key, const TMaybe<TString>& value /// Simplifed JSON map encoder for bool values -void OutKey(IOutputStream& out, const TString& key, const bool& value) { +void OutKey(IOutputStream& out, const TString& key, const bool& value) { out << "\"" << key << "\": " << (value ? "true" : "false") << ",\n"; } /// Simplifed JSON map encoder for array items template<typename T> -void OutItem(IOutputStream& out, const T& value, bool escape = true) { +void OutItem(IOutputStream& out, const T& value, bool escape = true) { TString quoted = ToString(value); if (escape) { quoted = JsonQuote(quoted); @@ -134,9 +134,9 @@ static TString WrapStringBuf(const TStringBuf str) { void GenerateEnum( const TEnumParser::TEnum& en, - IOutputStream& out, - IOutputStream* jsonEnumOut = nullptr, - IOutputStream* headerOutPtr = nullptr + IOutputStream& out, + IOutputStream* jsonEnumOut = nullptr, + IOutputStream* headerOutPtr = nullptr ) { TStringStream jEnum; OpenMap(jEnum); @@ -318,7 +318,7 @@ void GenerateEnum( // outer Out out << "template<>\n"; - out << "void Out<" << name << ">(IOutputStream& os, TTypeTraits<" << name << ">::TFuncParam n) {\n"; + out << "void Out<" << name << ">(IOutputStream& os, TTypeTraits<" << name << ">::TFuncParam n) {\n"; out << " const " << nsName << "::TNameBufs& names = " << nsName << "::TNameBufs::Instance();\n"; out << " return names.Out(&os, n);\n"; out << "}\n\n"; @@ -411,12 +411,12 @@ int main(int argc, char** argv) { TVector<TString> freeArgs = res.GetFreeArgs(); TString inputFileName = freeArgs[0]; - THolder<IOutputStream> hOut; - IOutputStream* out = &Cout; + THolder<IOutputStream> hOut; + IOutputStream* out = &Cout; - THolder<IOutputStream> headerOut; + THolder<IOutputStream> headerOut; - THolder<IOutputStream> jsonOut; + THolder<IOutputStream> jsonOut; if (outputFileName) { diff --git a/tools/fix_elf/patch.cpp b/tools/fix_elf/patch.cpp index d49ebab307d..11befd05d96 100644 --- a/tools/fix_elf/patch.cpp +++ b/tools/fix_elf/patch.cpp @@ -107,7 +107,7 @@ private: TSection StrSect; }; -void Patch(const TString& path, const TString& library, IOutputStream& verboseOut) { +void Patch(const TString& path, const TString& library, IOutputStream& verboseOut) { TElf elf(path); TVerneedSection verneedSect(&elf); @@ -237,7 +237,7 @@ int main(int argc, char* argv[]) { TOptsParseResult res(&opts, argc, argv); TVector<TString> files = res.GetFreeArgs(); - IOutputStream& verboseOut = verbose ? Cout : Cnull; + IOutputStream& verboseOut = verbose ? Cout : Cnull; bool first = true; for (auto path : files) { diff --git a/tools/ya.make b/tools/ya.make index 51a6b8b4263..21696138774 100644 --- a/tools/ya.make +++ b/tools/ya.make @@ -44,8 +44,8 @@ RECURSE( fml_sweeper_api frq_index_print geo - geodb_ops - geodb_ops/tests + geodb_ops + geodb_ops/tests geograph_compiler go_test_miner go_fake_xcrun @@ -65,7 +65,7 @@ RECURSE( langdiscr-test lemmas_merger_builder lemmer-test - lemmer-test/tests + lemmer-test/tests lenval_debug lua memcheck @@ -81,7 +81,7 @@ RECURSE( nehc nlp_test nodeiter_test - nodeiter_test/tests + nodeiter_test/tests normalize_requests nots oauth_token @@ -95,9 +95,9 @@ RECURSE( printlinks printphones printreqs - printreqs/tests + printreqs/tests printrichnode - printrichnode/tests + printrichnode/tests printtrie printurls printwzrd @@ -116,8 +116,8 @@ RECURSE( qlz query_marker_builder queryrectest - queryrectest/tests - queryrectest/tests/data + queryrectest/tests + queryrectest/tests/data rcgtest re_check recode @@ -157,11 +157,11 @@ RECURSE( tomaparsertest trans_str triecompiler - triecompiler/build_tool - triecompiler/lib - trie_ops - trie_ops/lib - trie_ops/tests + triecompiler/build_tool + triecompiler/lib + trie_ops + trie_ops/lib + trie_ops/tests trigram_index_print uc unpackrichtree diff --git a/util/README.md b/util/README.md index 496efa633c1..2a5429b2eb0 100644 --- a/util/README.md +++ b/util/README.md @@ -8,11 +8,11 @@ Style guide for the util folder is a stricter version of * &, * tied closer to a type, not to variable * always use `using` not `typedef` * even a single line block must be in braces {}: - ``` + ``` if (A) { B(); } - ``` + ``` * _ at the end of private data member of a class - `First_`, `Second_` * every .h file must be accompanied with corresponding .cpp to avoid a leakage and check that it is self contained * prohibited to use `printf`-like functions diff --git a/util/charset/benchmark/to_lower/main.cpp b/util/charset/benchmark/to_lower/main.cpp index e95fdc23716..30260e532d7 100644 --- a/util/charset/benchmark/to_lower/main.cpp +++ b/util/charset/benchmark/to_lower/main.cpp @@ -1,25 +1,25 @@ #include <library/cpp/testing/benchmark/bench.h> - -#include <util/charset/wide.h> -#include <util/generic/singleton.h> -#include <util/generic/vector.h> -#include <util/generic/string.h> - -static const auto ShortAscii = UTF8ToWide("hELlo"); -static const auto LongAscii = UTF8ToWide( - "The first plane, plane 0, the Basic Multilingual Plane (BMP) contains characters for almost " - "all modern languages, and a large number of symbols. A primary objective for the BMP is to " - "support the unification of prior character sets as well as characters for writing. Most of " - "the assigned code points in the BMP are used to encode Chinese, Japanese, and Korean (CJK) " - "characters."); - -static const auto ShortRussian = UTF8ToWide("пРИвет"); -static const auto LongRussian = UTF8ToWide( - "Плоскость 0 (Основная многоязычная плоскость, англ. Basic Multilingual Plane, BMP) отведена " - "для символов практически всех современных письменностей и большого числа специальных символов. " - "Большая часть таблицы занята китайско-японскими иероглифами и своеобразными корейскими" - "буквами. В Юникоде 10.0 в этой плоскости представлены следующие блоки"); - + +#include <util/charset/wide.h> +#include <util/generic/singleton.h> +#include <util/generic/vector.h> +#include <util/generic/string.h> + +static const auto ShortAscii = UTF8ToWide("hELlo"); +static const auto LongAscii = UTF8ToWide( + "The first plane, plane 0, the Basic Multilingual Plane (BMP) contains characters for almost " + "all modern languages, and a large number of symbols. A primary objective for the BMP is to " + "support the unification of prior character sets as well as characters for writing. Most of " + "the assigned code points in the BMP are used to encode Chinese, Japanese, and Korean (CJK) " + "characters."); + +static const auto ShortRussian = UTF8ToWide("пРИвет"); +static const auto LongRussian = UTF8ToWide( + "Плоскость 0 (Основная многоязычная плоскость, англ. Basic Multilingual Plane, BMP) отведена " + "для символов практически всех современных письменностей и большого числа специальных символов. " + "Большая часть таблицы занята китайско-японскими иероглифами и своеобразными корейскими" + "буквами. В Юникоде 10.0 в этой плоскости представлены следующие блоки"); + #define DEFINE_INPLACE_BENCH(s) \ Y_CPU_BENCHMARK(s##CopyDetach, iface) { \ for (size_t i = 0, iEnd = iface.Iterations(); i < iEnd; ++i) { \ @@ -38,8 +38,8 @@ static const auto LongRussian = UTF8ToWide( NBench::Escape(copy.data()); \ NBench::Clobber(); \ } \ - } - + } + #define DEFINE_RET_BENCH(s) \ Y_CPU_BENCHMARK(s##Ret, iface) { \ for (size_t i = 0, iEnd = iface.Iterations(); i < iEnd; ++i) { \ @@ -48,14 +48,14 @@ static const auto LongRussian = UTF8ToWide( NBench::Escape(res.data()); \ NBench::Clobber(); \ } \ - } - -DEFINE_INPLACE_BENCH(ShortAscii) -DEFINE_INPLACE_BENCH(LongAscii) -DEFINE_INPLACE_BENCH(ShortRussian) -DEFINE_INPLACE_BENCH(LongRussian) - -DEFINE_RET_BENCH(ShortAscii) -DEFINE_RET_BENCH(LongAscii) -DEFINE_RET_BENCH(ShortRussian) -DEFINE_RET_BENCH(LongRussian) + } + +DEFINE_INPLACE_BENCH(ShortAscii) +DEFINE_INPLACE_BENCH(LongAscii) +DEFINE_INPLACE_BENCH(ShortRussian) +DEFINE_INPLACE_BENCH(LongRussian) + +DEFINE_RET_BENCH(ShortAscii) +DEFINE_RET_BENCH(LongAscii) +DEFINE_RET_BENCH(ShortRussian) +DEFINE_RET_BENCH(LongRussian) diff --git a/util/charset/benchmark/to_lower/metrics/main.py b/util/charset/benchmark/to_lower/metrics/main.py index e7495d432ba..d6a4625fa60 100644 --- a/util/charset/benchmark/to_lower/metrics/main.py +++ b/util/charset/benchmark/to_lower/metrics/main.py @@ -1,5 +1,5 @@ -import yatest.common as yc - - -def test_export_metrics(metrics): - metrics.set_benchmark(yc.execute_benchmark('util/charset/benchmark/to_lower/to_lower')) +import yatest.common as yc + + +def test_export_metrics(metrics): + metrics.set_benchmark(yc.execute_benchmark('util/charset/benchmark/to_lower/to_lower')) diff --git a/util/charset/benchmark/to_lower/metrics/ya.make b/util/charset/benchmark/to_lower/metrics/ya.make index 5bb3461a8dd..675cdb7aab7 100644 --- a/util/charset/benchmark/to_lower/metrics/ya.make +++ b/util/charset/benchmark/to_lower/metrics/ya.make @@ -1,21 +1,21 @@ -OWNER( - agorodilov +OWNER( + agorodilov g:util -) +) SUBSCRIBER(g:util-subscribers) - + PY2TEST() - + SIZE(LARGE) - -TAG( + +TAG( ya:force_sandbox - sb:intel_e5_2660v1 + sb:intel_e5_2660v1 ya:fat -) - +) + TEST_SRCS(main.py) - + DEPENDS(util/charset/benchmark/to_lower) - -END() + +END() diff --git a/util/charset/benchmark/to_lower/ya.make b/util/charset/benchmark/to_lower/ya.make index 74c47e6de52..2de20e626d0 100644 --- a/util/charset/benchmark/to_lower/ya.make +++ b/util/charset/benchmark/to_lower/ya.make @@ -1,11 +1,11 @@ OWNER(yazevnul) - + Y_BENCHMARK() - -ALLOCATOR(B) - -SRCS( - main.cpp -) - -END() + +ALLOCATOR(B) + +SRCS( + main.cpp +) + +END() diff --git a/util/charset/benchmark/utf8_to_wide/main.cpp b/util/charset/benchmark/utf8_to_wide/main.cpp index 09fa567fe55..bdd234bfc6f 100644 --- a/util/charset/benchmark/utf8_to_wide/main.cpp +++ b/util/charset/benchmark/utf8_to_wide/main.cpp @@ -12,7 +12,7 @@ namespace { template <size_t N> struct TRandomAsciiString: public TVector<char> { inline TRandomAsciiString() { - reserve(N); + reserve(N); for (size_t i = 0; i < N; ++i) { push_back(RandomNumber<char>(127)); } diff --git a/util/charset/benchmark/utf8_to_wide/metrics/main.py b/util/charset/benchmark/utf8_to_wide/metrics/main.py index ffbd8f68fd5..adadfac791c 100644 --- a/util/charset/benchmark/utf8_to_wide/metrics/main.py +++ b/util/charset/benchmark/utf8_to_wide/metrics/main.py @@ -1,5 +1,5 @@ -import yatest.common as yc - - -def test_export_metrics(metrics): - metrics.set_benchmark(yc.execute_benchmark('util/charset/benchmark/utf8_to_wide/utf8_to_wide')) +import yatest.common as yc + + +def test_export_metrics(metrics): + metrics.set_benchmark(yc.execute_benchmark('util/charset/benchmark/utf8_to_wide/utf8_to_wide')) diff --git a/util/charset/benchmark/utf8_to_wide/metrics/ya.make b/util/charset/benchmark/utf8_to_wide/metrics/ya.make index c406e25bee5..997c41fbca0 100644 --- a/util/charset/benchmark/utf8_to_wide/metrics/ya.make +++ b/util/charset/benchmark/utf8_to_wide/metrics/ya.make @@ -1,21 +1,21 @@ -OWNER( - agorodilov +OWNER( + agorodilov g:util -) +) SUBSCRIBER(g:util-subscribers) - + PY2TEST() - + SIZE(LARGE) - -TAG( + +TAG( ya:force_sandbox - sb:intel_e5_2660v1 + sb:intel_e5_2660v1 ya:fat -) - +) + TEST_SRCS(main.py) - + DEPENDS(util/charset/benchmark/utf8_to_wide) - -END() + +END() diff --git a/util/charset/benchmark/ya.make b/util/charset/benchmark/ya.make index de3e04ef22c..9344fc39042 100644 --- a/util/charset/benchmark/ya.make +++ b/util/charset/benchmark/ya.make @@ -1,12 +1,12 @@ -OWNER( - agorodilov +OWNER( + agorodilov g:util -) +) SUBSCRIBER(g:util-subscribers) - -RECURSE( - to_lower - to_lower/metrics - utf8_to_wide - utf8_to_wide/metrics -) + +RECURSE( + to_lower + to_lower/metrics + utf8_to_wide + utf8_to_wide/metrics +) diff --git a/util/charset/utf8.cpp b/util/charset/utf8.cpp index efe3a52f615..a45229c33f9 100644 --- a/util/charset/utf8.cpp +++ b/util/charset/utf8.cpp @@ -93,13 +93,13 @@ static const char* SkipUTF8Chars(const char* begin, const char* end, size_t numC ythrow yexception() << "invalid UTF-8 char"; } begin += runeLen; - Y_ASSERT(begin <= end); + Y_ASSERT(begin <= end); --numChars; } return begin; } -TStringBuf SubstrUTF8(const TStringBuf str, size_t pos, size_t len) { +TStringBuf SubstrUTF8(const TStringBuf str, size_t pos, size_t len) { const char* start = SkipUTF8Chars(str.begin(), str.end(), pos); const char* end = SkipUTF8Chars(start, str.end(), len); return TStringBuf(start, end - start); diff --git a/util/charset/utf8.h b/util/charset/utf8.h index 5039b46ae9b..d64bd3c61dc 100644 --- a/util/charset/utf8.h +++ b/util/charset/utf8.h @@ -11,7 +11,7 @@ extern const wchar32 BROKEN_RUNE; inline unsigned char UTF8LeadByteMask(size_t utf8_rune_len) { - // Y_ASSERT (utf8_rune_len <= 4); + // Y_ASSERT (utf8_rune_len <= 4); return "\0\0\037\017\007"[utf8_rune_len]; } @@ -70,7 +70,7 @@ inline bool IsUTF8ContinuationByte(unsigned char c) { //! @param p pointer to the current character //! @param e end of the character sequence inline RECODE_RESULT GetUTF8CharLen(size_t& n, const unsigned char* p, const unsigned char* e) { - Y_ASSERT(p < e); // since p < e then we will check RECODE_EOINPUT only for n > 1 (see calls of this functions) + Y_ASSERT(p < e); // since p < e then we will check RECODE_EOINPUT only for n > 1 (see calls of this functions) switch (UTF8RuneLen(*p)) { case 0: return RECODE_BROKENSYMBOL; //[BROKENSYMBOL] in first byte @@ -125,7 +125,7 @@ inline bool GetNumberOfUTF8Chars(const char* text, size_t len, size_t& number) { break; } cur += runeLen; - Y_ASSERT(cur <= last); + Y_ASSERT(cur <= last); ++number; } return res; @@ -195,7 +195,7 @@ inline RECODE_RESULT SafeReadUTF8Char(wchar32& rune, size_t& rune_len, const uns //! @param p pointer to the current character, it will be changed in case of valid UTF8 byte sequence //! @param e the end of the character sequence Y_FORCE_INLINE RECODE_RESULT ReadUTF8CharAndAdvance(wchar32& rune, const unsigned char*& p, const unsigned char* e) noexcept { - Y_ASSERT(p < e); // since p < e then we will check RECODE_EOINPUT only for n > 1 (see calls of this functions) + Y_ASSERT(p < e); // since p < e then we will check RECODE_EOINPUT only for n > 1 (see calls of this functions) switch (UTF8RuneLen(*p)) { case 0: rune = BROKEN_RUNE; @@ -345,7 +345,7 @@ inline void WriteUTF8Char(wchar32 rune, size_t& rune_len, unsigned char* s) { } } -TStringBuf SubstrUTF8(const TStringBuf str, size_t pos, size_t len); +TStringBuf SubstrUTF8(const TStringBuf str, size_t pos, size_t len); enum EUTF8Detect { NotUTF8, @@ -355,7 +355,7 @@ enum EUTF8Detect { EUTF8Detect UTF8Detect(const char* s, size_t len); -inline EUTF8Detect UTF8Detect(const TStringBuf input) { +inline EUTF8Detect UTF8Detect(const TStringBuf input) { return UTF8Detect(input.data(), input.size()); } @@ -363,7 +363,7 @@ inline bool IsUtf(const char* input, size_t len) { return UTF8Detect(input, len) != NotUTF8; } -inline bool IsUtf(const TStringBuf input) { +inline bool IsUtf(const TStringBuf input) { return IsUtf(input.data(), input.size()); } diff --git a/util/charset/utf8_ut.cpp b/util/charset/utf8_ut.cpp index 9e68881cca2..70b78747401 100644 --- a/util/charset/utf8_ut.cpp +++ b/util/charset/utf8_ut.cpp @@ -7,12 +7,12 @@ #include <library/cpp/testing/unittest/registar.h> #include <library/cpp/testing/unittest/env.h> -Y_UNIT_TEST_SUITE(TUtfUtilTest) { - Y_UNIT_TEST(TestUTF8Len) { +Y_UNIT_TEST_SUITE(TUtfUtilTest) { + Y_UNIT_TEST(TestUTF8Len) { UNIT_ASSERT_EQUAL(GetNumberOfUTF8Chars("привет!"), 7); } - Y_UNIT_TEST(TestToLowerUtfString) { + Y_UNIT_TEST(TestToLowerUtfString) { UNIT_ASSERT_VALUES_EQUAL(ToLowerUTF8("xyz XYZ ПРИВЕТ!"), "xyz xyz привет!"); UNIT_ASSERT_VALUES_EQUAL(ToLowerUTF8(TStringBuf("xyz")), "xyz"); @@ -92,14 +92,14 @@ Y_UNIT_TEST_SUITE(TUtfUtilTest) { } } - Y_UNIT_TEST(TestUTF8ToWide) { + Y_UNIT_TEST(TestUTF8ToWide) { TFileInput in(ArcadiaSourceRoot() + TStringBuf("/util/charset/ut/utf8/test1.txt")); TString text = in.ReadAll(); UNIT_ASSERT(WideToUTF8(UTF8ToWide(text)) == text); } - Y_UNIT_TEST(TestInvalidUTF8) { + Y_UNIT_TEST(TestInvalidUTF8) { TVector<TString> testData; TFileInput input(ArcadiaSourceRoot() + TStringBuf("/util/charset/ut/utf8/invalid_UTF8.bin")); Load(&input, testData); @@ -109,7 +109,7 @@ Y_UNIT_TEST_SUITE(TUtfUtilTest) { } } - Y_UNIT_TEST(TestUTF8ToWideScalar) { + Y_UNIT_TEST(TestUTF8ToWideScalar) { TFileInput in(ArcadiaSourceRoot() + TStringBuf("/util/charset/ut/utf8/test1.txt")); TString text = in.ReadAll(); diff --git a/util/charset/wide.cpp b/util/charset/wide.cpp index a287438ddde..5c0dc0faed4 100644 --- a/util/charset/wide.cpp +++ b/util/charset/wide.cpp @@ -15,16 +15,16 @@ namespace { inline size_t EscapedLen(wchar16 c) { switch (c) { case '<': - return Y_ARRAY_SIZE(LT); + return Y_ARRAY_SIZE(LT); case '>': - return Y_ARRAY_SIZE(GT); + return Y_ARRAY_SIZE(GT); case '&': - return Y_ARRAY_SIZE(AMP); + return Y_ARRAY_SIZE(AMP); case '\"': - return Y_ARRAY_SIZE(QUOT); + return Y_ARRAY_SIZE(QUOT); default: if (insertBr && (c == '\r' || c == '\n')) - return Y_ARRAY_SIZE(BR); + return Y_ARRAY_SIZE(BR); else return 1; } @@ -39,192 +39,192 @@ size_t Collapse(wchar16* s, size_t n) { return CollapseImpl(s, n, IsWhitespace); } -TWtringBuf StripLeft(const TWtringBuf text) noexcept { - const auto* p = text.data(); - const auto* const pe = text.data() + text.size(); - - for (; p != pe && IsWhitespace(*p); ++p) { - } - - return {p, pe}; -} - -void StripLeft(TUtf16String& text) { - const auto stripped = StripLeft(TWtringBuf(text)); - if (stripped.size() == text.size()) { - return; - } - - text = stripped; -} - -TWtringBuf StripRight(const TWtringBuf text) noexcept { - if (!text) { - return {}; - } - - const auto* const pe = text.data() - 1; - const auto* p = text.data() + text.size() - 1; - - for (; p != pe && IsWhitespace(*p); --p) { - } - - return {pe + 1, p + 1}; -} - -void StripRight(TUtf16String& text) { - const auto stripped = StripRight(TWtringBuf(text)); - if (stripped.size() == text.size()) { - return; - } - - text.resize(stripped.size()); -} - -TWtringBuf Strip(const TWtringBuf text) noexcept { - return StripRight(StripLeft(text)); -} - -void Strip(TUtf16String& text) { - StripLeft(text); - StripRight(text); -} - -template <typename T> -static bool IsReductionOnSymbolsTrue(const TWtringBuf text, T&& f) { - const auto* p = text.data(); - const auto* const pe = text.data() + text.length(); - while (p != pe) { - const auto symbol = ReadSymbolAndAdvance(p, pe); - if (!f(symbol)) { - return false; - } - } - - return true; -} - -bool IsLowerWord(const TWtringBuf text) noexcept { - return IsReductionOnSymbolsTrue(text, [](const wchar32 s) { return IsLower(s); }); -} - -bool IsUpperWord(const TWtringBuf text) noexcept { - return IsReductionOnSymbolsTrue(text, [](const wchar32 s) { return IsUpper(s); }); -} - -bool IsLower(const TWtringBuf text) noexcept { - return IsReductionOnSymbolsTrue(text, [](const wchar32 s) { - if (IsAlpha(s)) { - return IsLower(s); - } - return true; - }); -} - -bool IsUpper(const TWtringBuf text) noexcept { - return IsReductionOnSymbolsTrue(text, [](const wchar32 s) { - if (IsAlpha(s)) { - return IsUpper(s); - } - return true; - }); -} - -bool IsTitleWord(const TWtringBuf text) noexcept { - if (!text) { - return false; - } - - const auto* p = text.data(); - const auto* pe = text.data() + text.size(); - - const auto firstSymbol = ReadSymbolAndAdvance(p, pe); - if (firstSymbol != ToTitle(firstSymbol)) { - return false; - } - - return IsLowerWord({p, pe}); -} - +TWtringBuf StripLeft(const TWtringBuf text) noexcept { + const auto* p = text.data(); + const auto* const pe = text.data() + text.size(); + + for (; p != pe && IsWhitespace(*p); ++p) { + } + + return {p, pe}; +} + +void StripLeft(TUtf16String& text) { + const auto stripped = StripLeft(TWtringBuf(text)); + if (stripped.size() == text.size()) { + return; + } + + text = stripped; +} + +TWtringBuf StripRight(const TWtringBuf text) noexcept { + if (!text) { + return {}; + } + + const auto* const pe = text.data() - 1; + const auto* p = text.data() + text.size() - 1; + + for (; p != pe && IsWhitespace(*p); --p) { + } + + return {pe + 1, p + 1}; +} + +void StripRight(TUtf16String& text) { + const auto stripped = StripRight(TWtringBuf(text)); + if (stripped.size() == text.size()) { + return; + } + + text.resize(stripped.size()); +} + +TWtringBuf Strip(const TWtringBuf text) noexcept { + return StripRight(StripLeft(text)); +} + +void Strip(TUtf16String& text) { + StripLeft(text); + StripRight(text); +} + +template <typename T> +static bool IsReductionOnSymbolsTrue(const TWtringBuf text, T&& f) { + const auto* p = text.data(); + const auto* const pe = text.data() + text.length(); + while (p != pe) { + const auto symbol = ReadSymbolAndAdvance(p, pe); + if (!f(symbol)) { + return false; + } + } + + return true; +} + +bool IsLowerWord(const TWtringBuf text) noexcept { + return IsReductionOnSymbolsTrue(text, [](const wchar32 s) { return IsLower(s); }); +} + +bool IsUpperWord(const TWtringBuf text) noexcept { + return IsReductionOnSymbolsTrue(text, [](const wchar32 s) { return IsUpper(s); }); +} + +bool IsLower(const TWtringBuf text) noexcept { + return IsReductionOnSymbolsTrue(text, [](const wchar32 s) { + if (IsAlpha(s)) { + return IsLower(s); + } + return true; + }); +} + +bool IsUpper(const TWtringBuf text) noexcept { + return IsReductionOnSymbolsTrue(text, [](const wchar32 s) { + if (IsAlpha(s)) { + return IsUpper(s); + } + return true; + }); +} + +bool IsTitleWord(const TWtringBuf text) noexcept { + if (!text) { + return false; + } + + const auto* p = text.data(); + const auto* pe = text.data() + text.size(); + + const auto firstSymbol = ReadSymbolAndAdvance(p, pe); + if (firstSymbol != ToTitle(firstSymbol)) { + return false; + } + + return IsLowerWord({p, pe}); +} + template <bool stopOnFirstModification, typename TCharType, typename F> static bool ModifySequence(TCharType*& p, const TCharType* const pe, F&& f) { - while (p != pe) { - const auto symbol = ReadSymbol(p, pe); - const auto modified = f(symbol); - if (symbol != modified) { - if (stopOnFirstModification) { - return true; - } - + while (p != pe) { + const auto symbol = ReadSymbol(p, pe); + const auto modified = f(symbol); + if (symbol != modified) { + if (stopOnFirstModification) { + return true; + } + WriteSymbol(modified, p); // also moves `p` forward - } else { - p = SkipSymbol(p, pe); - } - } - - return false; -} - + } else { + p = SkipSymbol(p, pe); + } + } + + return false; +} + template <bool stopOnFirstModification, typename TCharType, typename F> static bool ModifySequence(const TCharType*& p, const TCharType* const pe, TCharType*& out, F&& f) { - while (p != pe) { - const auto symbol = stopOnFirstModification ? ReadSymbol(p, pe) : ReadSymbolAndAdvance(p, pe); - const auto modified = f(symbol); - - if (stopOnFirstModification) { - if (symbol != modified) { - return true; - } - - p = SkipSymbol(p, pe); - } - - WriteSymbol(modified, out); - } - - return false; -} - + while (p != pe) { + const auto symbol = stopOnFirstModification ? ReadSymbol(p, pe) : ReadSymbolAndAdvance(p, pe); + const auto modified = f(symbol); + + if (stopOnFirstModification) { + if (symbol != modified) { + return true; + } + + p = SkipSymbol(p, pe); + } + + WriteSymbol(modified, out); + } + + return false; +} + template <class TStringType> static void DetachAndFixPointers(TStringType& text, typename TStringType::value_type*& p, const typename TStringType::value_type*& pe) { - const auto pos = p - text.data(); - const auto count = pe - p; - p = text.Detach() + pos; - pe = p + count; -} - + const auto pos = p - text.data(); + const auto count = pe - p; + p = text.Detach() + pos; + pe = p + count; +} + template <class TStringType, typename F> static bool ModifyStringSymbolwise(TStringType& text, size_t pos, size_t count, F&& f) { - // TODO(yazevnul): this is done for consistency with `TUtf16String::to_lower` and friends - // at r2914050, maybe worth replacing them with asserts. Also see the same code in `ToTitle`. - pos = pos < text.size() ? pos : text.size(); - count = count < text.size() - pos ? count : text.size() - pos; - - // TUtf16String is refcounted and it's `data` method return pointer to the constant memory. - // To simplify the code we do a `const_cast`, though first write to the memory will be done only - // after we call `Detach()` and get pointer to a writable piece of memory. + // TODO(yazevnul): this is done for consistency with `TUtf16String::to_lower` and friends + // at r2914050, maybe worth replacing them with asserts. Also see the same code in `ToTitle`. + pos = pos < text.size() ? pos : text.size(); + count = count < text.size() - pos ? count : text.size() - pos; + + // TUtf16String is refcounted and it's `data` method return pointer to the constant memory. + // To simplify the code we do a `const_cast`, though first write to the memory will be done only + // after we call `Detach()` and get pointer to a writable piece of memory. auto* p = const_cast<typename TStringType::value_type*>(text.data() + pos); - const auto* pe = text.data() + pos + count; - - if (ModifySequence<true>(p, pe, f)) { - DetachAndFixPointers(text, p, pe); - ModifySequence<false>(p, pe, f); - return true; - } - - return false; -} - -bool ToLower(TUtf16String& text, size_t pos, size_t count) { - const auto f = [](const wchar32 s) { return ToLower(s); }; - return ModifyStringSymbolwise(text, pos, count, f); -} - -bool ToUpper(TUtf16String& text, size_t pos, size_t count) { - const auto f = [](const wchar32 s) { return ToUpper(s); }; - return ModifyStringSymbolwise(text, pos, count, f); -} - + const auto* pe = text.data() + pos + count; + + if (ModifySequence<true>(p, pe, f)) { + DetachAndFixPointers(text, p, pe); + ModifySequence<false>(p, pe, f); + return true; + } + + return false; +} + +bool ToLower(TUtf16String& text, size_t pos, size_t count) { + const auto f = [](const wchar32 s) { return ToLower(s); }; + return ModifyStringSymbolwise(text, pos, count, f); +} + +bool ToUpper(TUtf16String& text, size_t pos, size_t count) { + const auto f = [](const wchar32 s) { return ToUpper(s); }; + return ModifyStringSymbolwise(text, pos, count, f); +} + bool ToLower(TUtf32String& text, size_t pos, size_t count) { const auto f = [](const wchar32 s) { return ToLower(s); }; return ModifyStringSymbolwise(text, pos, count, f); @@ -235,37 +235,37 @@ bool ToUpper(TUtf32String& text, size_t pos, size_t count) { return ModifyStringSymbolwise(text, pos, count, f); } -bool ToTitle(TUtf16String& text, size_t pos, size_t count) { - if (!text) { - return false; - } - - pos = pos < text.size() ? pos : text.size(); - count = count < text.size() - pos ? count : text.size() - pos; - - const auto toLower = [](const wchar32 s) { return ToLower(s); }; - - auto* p = const_cast<wchar16*>(text.data() + pos); - const auto* pe = text.data() + pos + count; - - const auto firstSymbol = ReadSymbol(p, pe); - if (firstSymbol == ToTitle(firstSymbol)) { - p = SkipSymbol(p, pe); - if (ModifySequence<true>(p, pe, toLower)) { - DetachAndFixPointers(text, p, pe); - ModifySequence<false>(p, pe, toLower); - return true; - } - } else { - DetachAndFixPointers(text, p, pe); +bool ToTitle(TUtf16String& text, size_t pos, size_t count) { + if (!text) { + return false; + } + + pos = pos < text.size() ? pos : text.size(); + count = count < text.size() - pos ? count : text.size() - pos; + + const auto toLower = [](const wchar32 s) { return ToLower(s); }; + + auto* p = const_cast<wchar16*>(text.data() + pos); + const auto* pe = text.data() + pos + count; + + const auto firstSymbol = ReadSymbol(p, pe); + if (firstSymbol == ToTitle(firstSymbol)) { + p = SkipSymbol(p, pe); + if (ModifySequence<true>(p, pe, toLower)) { + DetachAndFixPointers(text, p, pe); + ModifySequence<false>(p, pe, toLower); + return true; + } + } else { + DetachAndFixPointers(text, p, pe); WriteSymbol(ToTitle(ReadSymbol(p, pe)), p); // also moves `p` forward - ModifySequence<false>(p, pe, toLower); - return true; - } - - return false; -} - + ModifySequence<false>(p, pe, toLower); + return true; + } + + return false; +} + bool ToTitle(TUtf32String& text, size_t pos, size_t count) { if (!text) { return false; @@ -297,21 +297,21 @@ bool ToTitle(TUtf32String& text, size_t pos, size_t count) { return false; } -TUtf16String ToLowerRet(TUtf16String text, size_t pos, size_t count) { - ToLower(text, pos, count); - return text; -} - -TUtf16String ToUpperRet(TUtf16String text, size_t pos, size_t count) { - ToUpper(text, pos, count); - return text; -} - -TUtf16String ToTitleRet(TUtf16String text, size_t pos, size_t count) { - ToTitle(text, pos, count); - return text; -} - +TUtf16String ToLowerRet(TUtf16String text, size_t pos, size_t count) { + ToLower(text, pos, count); + return text; +} + +TUtf16String ToUpperRet(TUtf16String text, size_t pos, size_t count) { + ToUpper(text, pos, count); + return text; +} + +TUtf16String ToTitleRet(TUtf16String text, size_t pos, size_t count) { + ToTitle(text, pos, count); + return text; +} + TUtf32String ToLowerRet(TUtf32String text, size_t pos, size_t count) { ToLower(text, pos, count); return text; @@ -327,87 +327,87 @@ TUtf32String ToTitleRet(TUtf32String text, size_t pos, size_t count) { return text; } -bool ToLower(const wchar16* text, size_t length, wchar16* out) noexcept { - // TODO(yazevnul): get rid of `text == out` case (it is probably used only in lemmer) and then - // we can declare text and out as `__restrict__` - Y_ASSERT(text == out || !(out >= text && out < text + length)); - const auto f = [](const wchar32 s) { return ToLower(s); }; - const auto* p = text; - const auto* const pe = text + length; - if (ModifySequence<true>(p, pe, out, f)) { - ModifySequence<false>(p, pe, out, f); - return true; - } - return false; -} - -bool ToUpper(const wchar16* text, size_t length, wchar16* out) noexcept { - Y_ASSERT(text == out || !(out >= text && out < text + length)); - const auto f = [](const wchar32 s) { return ToUpper(s); }; - const auto* p = text; - const auto* const pe = text + length; - if (ModifySequence<true>(p, pe, out, f)) { - ModifySequence<false>(p, pe, out, f); - return true; - } - return false; -} - -bool ToTitle(const wchar16* text, size_t length, wchar16* out) noexcept { - if (!length) { - return false; - } - - Y_ASSERT(text == out || !(out >= text && out < text + length)); - - const auto* const textEnd = text + length; - const auto firstSymbol = ReadSymbolAndAdvance(text, textEnd); - const auto firstSymbolTitle = ToTitle(firstSymbol); - - WriteSymbol(firstSymbolTitle, out); - - return ToLower(text, textEnd - text, out) || firstSymbol != firstSymbolTitle; -} - -bool ToLower(wchar16* text, size_t length) noexcept { - const auto f = [](const wchar32 s) { return ToLower(s); }; - const auto* const textEnd = text + length; - if (ModifySequence<true>(text, textEnd, f)) { - ModifySequence<false>(text, textEnd, f); - return true; - } - return false; -} - -bool ToUpper(wchar16* text, size_t length) noexcept { - const auto f = [](const wchar32 s) { return ToUpper(s); }; - const auto* const textEnd = text + length; - if (ModifySequence<true>(text, textEnd, f)) { - ModifySequence<false>(text, textEnd, f); - return true; - } - return false; -} - -bool ToTitle(wchar16* text, size_t length) noexcept { - if (!length) { - return false; - } - - const auto* textEnd = text + length; - const auto firstSymbol = ReadSymbol(text, textEnd); - const auto firstSymbolTitle = ToTitle(firstSymbol); - - // avoid unnacessary writes to the memory - if (firstSymbol != firstSymbolTitle) { - WriteSymbol(firstSymbolTitle, text); - } else { - text = SkipSymbol(text, textEnd); - } - - return ToLower(text, textEnd - text) || firstSymbol != firstSymbolTitle; -} - +bool ToLower(const wchar16* text, size_t length, wchar16* out) noexcept { + // TODO(yazevnul): get rid of `text == out` case (it is probably used only in lemmer) and then + // we can declare text and out as `__restrict__` + Y_ASSERT(text == out || !(out >= text && out < text + length)); + const auto f = [](const wchar32 s) { return ToLower(s); }; + const auto* p = text; + const auto* const pe = text + length; + if (ModifySequence<true>(p, pe, out, f)) { + ModifySequence<false>(p, pe, out, f); + return true; + } + return false; +} + +bool ToUpper(const wchar16* text, size_t length, wchar16* out) noexcept { + Y_ASSERT(text == out || !(out >= text && out < text + length)); + const auto f = [](const wchar32 s) { return ToUpper(s); }; + const auto* p = text; + const auto* const pe = text + length; + if (ModifySequence<true>(p, pe, out, f)) { + ModifySequence<false>(p, pe, out, f); + return true; + } + return false; +} + +bool ToTitle(const wchar16* text, size_t length, wchar16* out) noexcept { + if (!length) { + return false; + } + + Y_ASSERT(text == out || !(out >= text && out < text + length)); + + const auto* const textEnd = text + length; + const auto firstSymbol = ReadSymbolAndAdvance(text, textEnd); + const auto firstSymbolTitle = ToTitle(firstSymbol); + + WriteSymbol(firstSymbolTitle, out); + + return ToLower(text, textEnd - text, out) || firstSymbol != firstSymbolTitle; +} + +bool ToLower(wchar16* text, size_t length) noexcept { + const auto f = [](const wchar32 s) { return ToLower(s); }; + const auto* const textEnd = text + length; + if (ModifySequence<true>(text, textEnd, f)) { + ModifySequence<false>(text, textEnd, f); + return true; + } + return false; +} + +bool ToUpper(wchar16* text, size_t length) noexcept { + const auto f = [](const wchar32 s) { return ToUpper(s); }; + const auto* const textEnd = text + length; + if (ModifySequence<true>(text, textEnd, f)) { + ModifySequence<false>(text, textEnd, f); + return true; + } + return false; +} + +bool ToTitle(wchar16* text, size_t length) noexcept { + if (!length) { + return false; + } + + const auto* textEnd = text + length; + const auto firstSymbol = ReadSymbol(text, textEnd); + const auto firstSymbolTitle = ToTitle(firstSymbol); + + // avoid unnacessary writes to the memory + if (firstSymbol != firstSymbolTitle) { + WriteSymbol(firstSymbolTitle, text); + } else { + text = SkipSymbol(text, textEnd); + } + + return ToLower(text, textEnd - text) || firstSymbol != firstSymbolTitle; +} + bool ToLower(const wchar32* text, size_t length, wchar32* out) noexcept { // TODO(yazevnul): get rid of `text == out` case (it is probably used only in lemmer) and then // we can declare text and out as `__restrict__` @@ -489,27 +489,27 @@ bool ToTitle(wchar32* text, size_t length) noexcept { return ToLower(text, textEnd - text) || firstSymbol != firstSymbolTitle; } -template <typename F> -static TUtf16String ToSmthRet(const TWtringBuf text, size_t pos, size_t count, F&& f) { - pos = pos < text.size() ? pos : text.size(); - count = count < text.size() - pos ? count : text.size() - pos; - - auto res = TUtf16String::Uninitialized(text.size()); - auto* const resBegin = res.Detach(); - - if (pos) { - MemCopy(resBegin, text.data(), pos); - } - - f(text.data() + pos, count, resBegin + pos); - - if (count - pos != text.size()) { - MemCopy(resBegin + pos + count, text.data() + pos + count, text.size() - pos - count); - } - - return res; -} - +template <typename F> +static TUtf16String ToSmthRet(const TWtringBuf text, size_t pos, size_t count, F&& f) { + pos = pos < text.size() ? pos : text.size(); + count = count < text.size() - pos ? count : text.size() - pos; + + auto res = TUtf16String::Uninitialized(text.size()); + auto* const resBegin = res.Detach(); + + if (pos) { + MemCopy(resBegin, text.data(), pos); + } + + f(text.data() + pos, count, resBegin + pos); + + if (count - pos != text.size()) { + MemCopy(resBegin + pos + count, text.data() + pos + count, text.size() - pos - count); + } + + return res; +} + template <typename F> static TUtf32String ToSmthRet(const TUtf32StringBuf text, size_t pos, size_t count, F&& f) { pos = pos < text.size() ? pos : text.size(); @@ -531,24 +531,24 @@ static TUtf32String ToSmthRet(const TUtf32StringBuf text, size_t pos, size_t cou return res; } -TUtf16String ToLowerRet(const TWtringBuf text, size_t pos, size_t count) { +TUtf16String ToLowerRet(const TWtringBuf text, size_t pos, size_t count) { return ToSmthRet(text, pos, count, [](const wchar16* theText, size_t length, wchar16* out) { ToLower(theText, length, out); - }); -} - -TUtf16String ToUpperRet(const TWtringBuf text, size_t pos, size_t count) { + }); +} + +TUtf16String ToUpperRet(const TWtringBuf text, size_t pos, size_t count) { return ToSmthRet(text, pos, count, [](const wchar16* theText, size_t length, wchar16* out) { ToUpper(theText, length, out); - }); -} - -TUtf16String ToTitleRet(const TWtringBuf text, size_t pos, size_t count) { + }); +} + +TUtf16String ToTitleRet(const TWtringBuf text, size_t pos, size_t count) { return ToSmthRet(text, pos, count, [](const wchar16* theText, size_t length, wchar16* out) { ToTitle(theText, length, out); - }); -} - + }); +} + TUtf32String ToLowerRet(const TUtf32StringBuf text, size_t pos, size_t count) { return ToSmthRet(text, pos, count, [](const wchar32* theText, size_t length, wchar32* out) { ToLower(theText, length, out); diff --git a/util/charset/wide.h b/util/charset/wide.h index 04e6928aab3..81e7282f907 100644 --- a/util/charset/wide.h +++ b/util/charset/wide.h @@ -5,12 +5,12 @@ #include "utf8.h" #include "wide_specific.h" -#include <util/generic/algorithm.h> +#include <util/generic/algorithm.h> #include <util/generic/string.h> #include <util/generic/yexception.h> #include <util/memory/tempbuf.h> -#include <util/system/compiler.h> -#include <util/system/cpu_id.h> +#include <util/system/compiler.h> +#include <util/system/cpu_id.h> #include <util/system/yassert.h> #include <cstring> @@ -79,7 +79,7 @@ inline const wchar32* SkipSymbol(const wchar32* begin, const wchar32* end) noexc } inline wchar32 ReadSymbol(const wchar16* begin, const wchar16* end) noexcept { - Y_ASSERT(begin < end); + Y_ASSERT(begin < end); if (IsW16SurrogateLead(*begin)) { if (begin + 1 < end && IsW16SurrogateTail(*(begin + 1))) return ::NDetail::ReadSurrogatePair(begin); @@ -99,10 +99,10 @@ inline wchar32 ReadSymbol(const wchar32* begin, const wchar32* end) noexcept { //! presuming input data is either big enought of null terminated inline wchar32 ReadSymbolAndAdvance(const wchar16*& begin) noexcept { - Y_ASSERT(*begin); + Y_ASSERT(*begin); if (IsW16SurrogateLead(begin[0])) { if (IsW16SurrogateTail(begin[1])) { - Y_ASSERT(begin[1] != 0); + Y_ASSERT(begin[1] != 0); const wchar32 c = ::NDetail::ReadSurrogatePair(begin); begin += 2; return c; @@ -123,7 +123,7 @@ inline wchar32 ReadSymbolAndAdvance(const wchar32*& begin) noexcept { } inline wchar32 ReadSymbolAndAdvance(const wchar16*& begin, const wchar16* end) noexcept { - Y_ASSERT(begin < end); + Y_ASSERT(begin < end); if (IsW16SurrogateLead(begin[0])) { if (begin + 1 != end && IsW16SurrogateTail(begin[1])) { const wchar32 c = ::NDetail::ReadSurrogatePair(begin); @@ -140,7 +140,7 @@ inline wchar32 ReadSymbolAndAdvance(const wchar16*& begin, const wchar16* end) n } inline wchar32 ReadSymbolAndAdvance(const wchar32*& begin, const wchar32* end) noexcept { - Y_ASSERT(begin < end); + Y_ASSERT(begin < end); return *(begin++); } @@ -165,7 +165,7 @@ inline size_t WriteSymbol(wchar32 s, T& dest) noexcept { } inline bool WriteSymbol(wchar32 s, wchar16*& dest, const wchar16* destEnd) noexcept { - Y_ASSERT(dest < destEnd); + Y_ASSERT(dest < destEnd); if (s > 0xFFFF) { if (s >= NUnicode::UnicodeInstancesLimit()) { @@ -190,7 +190,7 @@ inline size_t WriteSymbol(wchar32 s, wchar32*& dest) noexcept { } inline bool WriteSymbol(wchar32 s, wchar32*& dest, const wchar32* destEnd) noexcept { - Y_ASSERT(dest < destEnd); + Y_ASSERT(dest < destEnd); *(dest++) = s; @@ -200,7 +200,7 @@ inline bool WriteSymbol(wchar32 s, wchar32*& dest, const wchar32* destEnd) noexc template <class T> inline void ::NDetail::WriteSurrogatePair(wchar32 s, T& dest) noexcept { const wchar32 LEAD_OFFSET = 0xD800 - (0x10000 >> 10); - Y_ASSERT(s > 0xFFFF && s < ::NUnicode::UnicodeInstancesLimit()); + Y_ASSERT(s > 0xFFFF && s < ::NUnicode::UnicodeInstancesLimit()); wchar16 lead = LEAD_OFFSET + (static_cast<wchar16>(s >> 10)); wchar16 tail = 0xDC00 + static_cast<wchar16>(s & 0x3FF); @@ -327,7 +327,7 @@ inline TUtf16String UTF8ToWide(const char* text, size_t len) { size_t pos = UTF8ToWideImpl<robust>(text, len, w.begin(), written); if (pos != len) ythrow yexception() << "failed to decode UTF-8 string at pos " << pos << ::NDetail::InStringMsg(text, len); - Y_ASSERT(w.size() >= written); + Y_ASSERT(w.size() >= written); w.remove(written); return w; } @@ -400,7 +400,7 @@ inline void WideToUTF8(const TCharType* text, size_t len, char* dest, size_t& wr size_t runeLen; for (const TCharType* cur = text; cur != last;) { WriteUTF8Char(ReadSymbolAndAdvance(cur, last), runeLen, p); - Y_ASSERT(runeLen <= 4); + Y_ASSERT(runeLen <= 4); p += runeLen; } written = p - reinterpret_cast<unsigned char*>(dest); @@ -414,7 +414,7 @@ inline TStringBuf WideToUTF8(const TWtringBuf src, TString& dst) { dst.ReserveAndResize(WideToUTF8BufferSize(src.size())); size_t written = 0; WideToUTF8(src.data(), src.size(), dst.begin(), written); - Y_ASSERT(dst.size() >= written); + Y_ASSERT(dst.size() >= written); dst.remove(written); return dst; } @@ -423,7 +423,7 @@ inline TString WideToUTF8(const wchar16* text, size_t len) { TString s = TString::Uninitialized(WideToUTF8BufferSize(len)); size_t written = 0; WideToUTF8(text, len, s.begin(), written); - Y_ASSERT(s.size() >= written); + Y_ASSERT(s.size() >= written); s.remove(written); return s; } @@ -469,49 +469,49 @@ namespace NDetail { return !(reinterpret_cast<TMachineWord>(pointer) & kMachineWordAlignmentMask); } - template <typename T> + template <typename T> inline T* AlignToMachineWord(T* pointer) { return reinterpret_cast<T*>(reinterpret_cast<TMachineWord>(pointer) & ~kMachineWordAlignmentMask); } - template <size_t size, typename CharacterType> + template <size_t size, typename CharacterType> struct NonASCIIMask; - template <> - struct - NonASCIIMask<4, wchar16> { - static constexpr ui32 Value() { - return 0xFF80FF80U; - } + template <> + struct + NonASCIIMask<4, wchar16> { + static constexpr ui32 Value() { + return 0xFF80FF80U; + } }; - template <> - struct - NonASCIIMask<4, char> { - static constexpr ui32 Value() { - return 0x80808080U; - } + template <> + struct + NonASCIIMask<4, char> { + static constexpr ui32 Value() { + return 0x80808080U; + } }; - template <> - struct - NonASCIIMask<8, wchar16> { - static constexpr ui64 Value() { - return 0xFF80FF80FF80FF80ULL; - } + template <> + struct + NonASCIIMask<8, wchar16> { + static constexpr ui64 Value() { + return 0xFF80FF80FF80FF80ULL; + } }; - template <> - struct - NonASCIIMask<8, char> { - static constexpr ui64 Value() { - return 0x8080808080808080ULL; - } + template <> + struct + NonASCIIMask<8, char> { + static constexpr ui64 Value() { + return 0x8080808080808080ULL; + } }; template <typename TChar> inline bool DoIsStringASCIISlow(const TChar* first, const TChar* last) { - using TUnsignedChar = std::make_unsigned_t<TChar>; + using TUnsignedChar = std::make_unsigned_t<TChar>; Y_ASSERT(first <= last); for (; first != last; ++first) { if (static_cast<TUnsignedChar>(*first) > 0x7F) { @@ -573,7 +573,7 @@ namespace NDetail { int asciiMask = _mm_movemask_epi8(chunk); if (asciiMask) { return false; - } + } first += 16; } @@ -630,7 +630,7 @@ inline void Copy(const TChar1* first, size_t len, TChar2* result) { //! and the family of template member functions: append, assign, insert, replace. template <typename TStringType, typename TChar> inline TStringType CopyTo(const TChar* first, const TChar* last) { - Y_ASSERT(first <= last); + Y_ASSERT(first <= last); TStringType str = TStringType::Uninitialized(last - first); Copy(first, last, str.begin()); return str; @@ -644,12 +644,12 @@ inline TStringType CopyTo(const TChar* s, size_t n) { } inline TString WideToASCII(const TWtringBuf w) { - Y_ASSERT(IsStringASCII(w.begin(), w.end())); + Y_ASSERT(IsStringASCII(w.begin(), w.end())); return CopyTo<TString>(w.begin(), w.end()); } inline TUtf16String ASCIIToWide(const TStringBuf s) { - Y_ASSERT(IsStringASCII(s.begin(), s.end())); + Y_ASSERT(IsStringASCII(s.begin(), s.end())); return CopyTo<TUtf16String>(s.begin(), s.end()); } @@ -663,7 +663,7 @@ inline bool IsSpace(const wchar16* s, size_t n) { if (n == 0) return false; - Y_ASSERT(s); + Y_ASSERT(s); const wchar16* const e = s + n; for (const wchar16* p = s; p != e; ++p) { @@ -674,7 +674,7 @@ inline bool IsSpace(const wchar16* s, size_t n) { } //! returns @c true if string contains whitespace characters only -inline bool IsSpace(const TWtringBuf s) { +inline bool IsSpace(const TWtringBuf s) { return IsSpace(s.data(), s.length()); } @@ -684,61 +684,61 @@ void Collapse(TUtf16String& w); //! @return new length size_t Collapse(wchar16* s, size_t n); -//! Removes leading whitespace characters -TWtringBuf StripLeft(const TWtringBuf text) noexcept Y_WARN_UNUSED_RESULT; -void StripLeft(TUtf16String& text); - -//! Removes trailing whitespace characters -TWtringBuf StripRight(const TWtringBuf text) noexcept Y_WARN_UNUSED_RESULT; -void StripRight(TUtf16String& text); - -//! Removes leading and trailing whitespace characters -TWtringBuf Strip(const TWtringBuf text) noexcept Y_WARN_UNUSED_RESULT; -void Strip(TUtf16String& text); - -/* Check if given word is lowercase/uppercase. Will return false if string contains any - * non-alphabetical symbols. It is expected that `text` is a correct UTF-16 string. - * - * For example `IsLowerWord("hello")` will return `true`, when `IsLowerWord("hello there")` will - * return false because of the space in the middle of the string. Empty string is also considered - * lowercase. - */ -bool IsLowerWord(const TWtringBuf text) noexcept; -bool IsUpperWord(const TWtringBuf text) noexcept; - -/* Will check if given word starts with capital letter and the rest of the word is lowercase. Will - * return `false` for empty string. See also `IsLowerWord`. - */ -bool IsTitleWord(const TWtringBuf text) noexcept; - -/* Check if given string is lowercase/uppercase. Will return `true` if all alphabetic symbols are - * in proper case, all other symbols are ignored. It is expected that `text` is a correct UTF-16 - * string. - * - * For example `IsLowerWord("hello")` will return `true` and `IsLowerWord("hello there")` will - * also return true because. Empty string is also considered lowercase. - * - * NOTE: for any case where `IsLowerWord` returns `true` `IsLower` will also return `true`. - */ -bool IsLower(const TWtringBuf text) noexcept; -bool IsUpper(const TWtringBuf text) noexcept; - -/* Lowercase/uppercase given string inplace. Any alphabetic symbol will be converted to a proper - * case, the rest of the symbols will be kept the same. It is expected that `text` is a correct - * UTF-16 string. - * - * For example `ToLower("heLLo")` will return `"hello"`. - * - * @param text String to modify - * @param pos Position of the first character to modify - * @param count Length of the substring - * @returns `true` if `text` was changed - * - * NOTE: `pos` and `count` are measured in `wchar16`, not in codepoints. - */ -bool ToLower(TUtf16String& text, size_t pos = 0, size_t count = TUtf16String::npos); -bool ToUpper(TUtf16String& text, size_t pos = 0, size_t count = TUtf16String::npos); - +//! Removes leading whitespace characters +TWtringBuf StripLeft(const TWtringBuf text) noexcept Y_WARN_UNUSED_RESULT; +void StripLeft(TUtf16String& text); + +//! Removes trailing whitespace characters +TWtringBuf StripRight(const TWtringBuf text) noexcept Y_WARN_UNUSED_RESULT; +void StripRight(TUtf16String& text); + +//! Removes leading and trailing whitespace characters +TWtringBuf Strip(const TWtringBuf text) noexcept Y_WARN_UNUSED_RESULT; +void Strip(TUtf16String& text); + +/* Check if given word is lowercase/uppercase. Will return false if string contains any + * non-alphabetical symbols. It is expected that `text` is a correct UTF-16 string. + * + * For example `IsLowerWord("hello")` will return `true`, when `IsLowerWord("hello there")` will + * return false because of the space in the middle of the string. Empty string is also considered + * lowercase. + */ +bool IsLowerWord(const TWtringBuf text) noexcept; +bool IsUpperWord(const TWtringBuf text) noexcept; + +/* Will check if given word starts with capital letter and the rest of the word is lowercase. Will + * return `false` for empty string. See also `IsLowerWord`. + */ +bool IsTitleWord(const TWtringBuf text) noexcept; + +/* Check if given string is lowercase/uppercase. Will return `true` if all alphabetic symbols are + * in proper case, all other symbols are ignored. It is expected that `text` is a correct UTF-16 + * string. + * + * For example `IsLowerWord("hello")` will return `true` and `IsLowerWord("hello there")` will + * also return true because. Empty string is also considered lowercase. + * + * NOTE: for any case where `IsLowerWord` returns `true` `IsLower` will also return `true`. + */ +bool IsLower(const TWtringBuf text) noexcept; +bool IsUpper(const TWtringBuf text) noexcept; + +/* Lowercase/uppercase given string inplace. Any alphabetic symbol will be converted to a proper + * case, the rest of the symbols will be kept the same. It is expected that `text` is a correct + * UTF-16 string. + * + * For example `ToLower("heLLo")` will return `"hello"`. + * + * @param text String to modify + * @param pos Position of the first character to modify + * @param count Length of the substring + * @returns `true` if `text` was changed + * + * NOTE: `pos` and `count` are measured in `wchar16`, not in codepoints. + */ +bool ToLower(TUtf16String& text, size_t pos = 0, size_t count = TUtf16String::npos); +bool ToUpper(TUtf16String& text, size_t pos = 0, size_t count = TUtf16String::npos); + /* Lowercase/uppercase given string inplace. Any alphabetic symbol will be converted to a proper * case, the rest of the symbols will be kept the same. It is expected that `text` is a correct * UTF-32 string. @@ -755,54 +755,54 @@ bool ToUpper(TUtf16String& text, size_t pos = 0, size_t count = TUtf16String::np bool ToLower(TUtf32String& /*text*/, size_t /*pos*/ = 0, size_t /*count*/ = TUtf16String::npos); bool ToUpper(TUtf32String& /*text*/, size_t /*pos*/ = 0, size_t /*count*/ = TUtf16String::npos); -/* Titlecase first symbol and lowercase the rest, see `ToLower` for more details. - */ -bool ToTitle(TUtf16String& text, size_t pos = 0, size_t count = TUtf16String::npos); - +/* Titlecase first symbol and lowercase the rest, see `ToLower` for more details. + */ +bool ToTitle(TUtf16String& text, size_t pos = 0, size_t count = TUtf16String::npos); + /* Titlecase first symbol and lowercase the rest, see `ToLower` for more details. */ bool ToTitle(TUtf32String& /*text*/, size_t /*pos*/ = 0, size_t /*count*/ = TUtf16String::npos); -/* @param text Pointer to the string to modify - * @param length Length of the string to modify - * @param out Pointer to the character array to write to - * - * NOTE: [text, text+length) and [out, out+length) should not interleave. - * - * TODO(yazevnul): replace these functions with `bool(const TWtringBuf, const TArrayRef<wchar16>)` - * overload. - */ -bool ToLower(const wchar16* text, size_t length, wchar16* out) noexcept; -bool ToUpper(const wchar16* text, size_t length, wchar16* out) noexcept; -bool ToTitle(const wchar16* text, size_t length, wchar16* out) noexcept; - +/* @param text Pointer to the string to modify + * @param length Length of the string to modify + * @param out Pointer to the character array to write to + * + * NOTE: [text, text+length) and [out, out+length) should not interleave. + * + * TODO(yazevnul): replace these functions with `bool(const TWtringBuf, const TArrayRef<wchar16>)` + * overload. + */ +bool ToLower(const wchar16* text, size_t length, wchar16* out) noexcept; +bool ToUpper(const wchar16* text, size_t length, wchar16* out) noexcept; +bool ToTitle(const wchar16* text, size_t length, wchar16* out) noexcept; + bool ToLower(const wchar32* text, size_t length, wchar32* out) noexcept; bool ToUpper(const wchar32* text, size_t length, wchar32* out) noexcept; bool ToTitle(const wchar32* text, size_t length, wchar32* out) noexcept; -/* @param text Pointer to the string to modify - * @param length Length of the string to modify - * - * TODO(yazevnul): replace these functions with `bool(const TArrayRef<wchar16>)` overload. - */ -bool ToLower(wchar16* text, size_t length) noexcept; -bool ToUpper(wchar16* text, size_t length) noexcept; -bool ToTitle(wchar16* text, size_t length) noexcept; - +/* @param text Pointer to the string to modify + * @param length Length of the string to modify + * + * TODO(yazevnul): replace these functions with `bool(const TArrayRef<wchar16>)` overload. + */ +bool ToLower(wchar16* text, size_t length) noexcept; +bool ToUpper(wchar16* text, size_t length) noexcept; +bool ToTitle(wchar16* text, size_t length) noexcept; + bool ToLower(wchar32* text, size_t length) noexcept; bool ToUpper(wchar32* text, size_t length) noexcept; bool ToTitle(wchar32* text, size_t length) noexcept; -/* Convenience wrappers for `ToLower`, `ToUpper` and `ToTitle`. - */ -TUtf16String ToLowerRet(TUtf16String text, size_t pos = 0, size_t count = TUtf16String::npos) Y_WARN_UNUSED_RESULT; -TUtf16String ToUpperRet(TUtf16String text, size_t pos = 0, size_t count = TUtf16String::npos) Y_WARN_UNUSED_RESULT; -TUtf16String ToTitleRet(TUtf16String text, size_t pos = 0, size_t count = TUtf16String::npos) Y_WARN_UNUSED_RESULT; - -TUtf16String ToLowerRet(const TWtringBuf text, size_t pos = 0, size_t count = TWtringBuf::npos) Y_WARN_UNUSED_RESULT; -TUtf16String ToUpperRet(const TWtringBuf text, size_t pos = 0, size_t count = TWtringBuf::npos) Y_WARN_UNUSED_RESULT; -TUtf16String ToTitleRet(const TWtringBuf text, size_t pos = 0, size_t count = TWtringBuf::npos) Y_WARN_UNUSED_RESULT; - +/* Convenience wrappers for `ToLower`, `ToUpper` and `ToTitle`. + */ +TUtf16String ToLowerRet(TUtf16String text, size_t pos = 0, size_t count = TUtf16String::npos) Y_WARN_UNUSED_RESULT; +TUtf16String ToUpperRet(TUtf16String text, size_t pos = 0, size_t count = TUtf16String::npos) Y_WARN_UNUSED_RESULT; +TUtf16String ToTitleRet(TUtf16String text, size_t pos = 0, size_t count = TUtf16String::npos) Y_WARN_UNUSED_RESULT; + +TUtf16String ToLowerRet(const TWtringBuf text, size_t pos = 0, size_t count = TWtringBuf::npos) Y_WARN_UNUSED_RESULT; +TUtf16String ToUpperRet(const TWtringBuf text, size_t pos = 0, size_t count = TWtringBuf::npos) Y_WARN_UNUSED_RESULT; +TUtf16String ToTitleRet(const TWtringBuf text, size_t pos = 0, size_t count = TWtringBuf::npos) Y_WARN_UNUSED_RESULT; + TUtf32String ToLowerRet(const TUtf32StringBuf text, size_t pos = 0, size_t count = TWtringBuf::npos) Y_WARN_UNUSED_RESULT; TUtf32String ToUpperRet(const TUtf32StringBuf text, size_t pos = 0, size_t count = TWtringBuf::npos) Y_WARN_UNUSED_RESULT; TUtf32String ToTitleRet(const TUtf32StringBuf text, size_t pos = 0, size_t count = TWtringBuf::npos) Y_WARN_UNUSED_RESULT; @@ -823,7 +823,7 @@ inline size_t CountWideChars(const wchar16* b, const wchar16* e) { return count; } -inline size_t CountWideChars(const TWtringBuf str) { +inline size_t CountWideChars(const TWtringBuf str) { return CountWideChars(str.begin(), str.end()); } @@ -838,6 +838,6 @@ inline bool IsValidUTF16(const wchar16* b, const wchar16* e) { return true; } -inline bool IsValidUTF16(const TWtringBuf str) { +inline bool IsValidUTF16(const TWtringBuf str) { return IsValidUTF16(str.begin(), str.end()); } diff --git a/util/charset/wide_ut.cpp b/util/charset/wide_ut.cpp index d8f3233e732..3d176b61c13 100644 --- a/util/charset/wide_ut.cpp +++ b/util/charset/wide_ut.cpp @@ -592,20 +592,20 @@ class TWideUtilTest: public TTestBase { UNIT_TEST(TestCountWideChars); UNIT_TEST(TestIsValidUTF16); UNIT_TEST(TestIsStringASCII); - UNIT_TEST(TestIsLowerWordStr); - UNIT_TEST(TestIsUpperWordStr); - UNIT_TEST(TestIsTitleStr); - UNIT_TEST(TestIsLowerStr); - UNIT_TEST(TestIsUpperStr); - UNIT_TEST(TestToLowerStr); - UNIT_TEST(TestToUpperStr); - UNIT_TEST(TestToTitleStr); + UNIT_TEST(TestIsLowerWordStr); + UNIT_TEST(TestIsUpperWordStr); + UNIT_TEST(TestIsTitleStr); + UNIT_TEST(TestIsLowerStr); + UNIT_TEST(TestIsUpperStr); + UNIT_TEST(TestToLowerStr); + UNIT_TEST(TestToUpperStr); + UNIT_TEST(TestToTitleStr); UNIT_TEST_SUITE_END(); public: void TestCollapse() { TUtf16String s; - s.append(ws, Y_ARRAY_SIZE(ws)).append(3, 'a').append(ws, Y_ARRAY_SIZE(ws)).append(3, 'b').append(ws, Y_ARRAY_SIZE(ws)); + s.append(ws, Y_ARRAY_SIZE(ws)).append(3, 'a').append(ws, Y_ARRAY_SIZE(ws)).append(3, 'b').append(ws, Y_ARRAY_SIZE(ws)); Collapse(s); UNIT_ASSERT(s == ASCIIToWide(" aaa bbb ")); { @@ -664,7 +664,7 @@ public: void TestCollapseBuffer() { TUtf16String s; - s.append(ws, Y_ARRAY_SIZE(ws)).append(3, 'a').append(ws, Y_ARRAY_SIZE(ws)).append(3, 'b').append(ws, Y_ARRAY_SIZE(ws)); + s.append(ws, Y_ARRAY_SIZE(ws)).append(3, 'a').append(ws, Y_ARRAY_SIZE(ws)).append(3, 'b').append(ws, Y_ARRAY_SIZE(ws)); size_t n = Collapse(s.begin(), s.size()); s.resize(n); UNIT_ASSERT(s == ASCIIToWide(" aaa bbb ")); @@ -735,40 +735,40 @@ public: Strip(s); UNIT_ASSERT(s == TUtf16String()); - StripLeft(s); - UNIT_ASSERT(s == TUtf16String()); - StripRight(s); - UNIT_ASSERT(s == TUtf16String()); + StripLeft(s); + UNIT_ASSERT(s == TUtf16String()); + StripRight(s); + UNIT_ASSERT(s == TUtf16String()); s = ASCIIToWide(" \t\r\n"); Strip(s); UNIT_ASSERT(s == TUtf16String()); - s = ASCIIToWide(" \t\r\n"); - StripLeft(s); - UNIT_ASSERT(s == TUtf16String()); - s = ASCIIToWide(" \t\r\n"); - StripRight(s); - UNIT_ASSERT(s == TUtf16String()); + s = ASCIIToWide(" \t\r\n"); + StripLeft(s); + UNIT_ASSERT(s == TUtf16String()); + s = ASCIIToWide(" \t\r\n"); + StripRight(s); + UNIT_ASSERT(s == TUtf16String()); s = ASCIIToWide("\t\f\va \r\n"); Strip(s); UNIT_ASSERT(s == ASCIIToWide("a")); - s = ASCIIToWide("\t\f\va \r\n"); - StripLeft(s); - UNIT_ASSERT(s == ASCIIToWide("a \r\n")); - s = ASCIIToWide("\t\f\va \r\n"); - StripRight(s); - UNIT_ASSERT(s == ASCIIToWide("\t\f\va")); + s = ASCIIToWide("\t\f\va \r\n"); + StripLeft(s); + UNIT_ASSERT(s == ASCIIToWide("a \r\n")); + s = ASCIIToWide("\t\f\va \r\n"); + StripRight(s); + UNIT_ASSERT(s == ASCIIToWide("\t\f\va")); s = ASCIIToWide("\r\na\r\nb\t\tc\r\n"); Strip(s); UNIT_ASSERT(s == ASCIIToWide("a\r\nb\t\tc")); - s = ASCIIToWide("\r\na\r\nb\t\tc\r\n"); - StripLeft(s); - UNIT_ASSERT(s == ASCIIToWide("a\r\nb\t\tc\r\n")); - s = ASCIIToWide("\r\na\r\nb\t\tc\r\n"); - StripRight(s); - UNIT_ASSERT(s == ASCIIToWide("\r\na\r\nb\t\tc")); + s = ASCIIToWide("\r\na\r\nb\t\tc\r\n"); + StripLeft(s); + UNIT_ASSERT(s == ASCIIToWide("a\r\nb\t\tc\r\n")); + s = ASCIIToWide("\r\na\r\nb\t\tc\r\n"); + StripRight(s); + UNIT_ASSERT(s == ASCIIToWide("\r\na\r\nb\t\tc")); const TUtf16String w(ASCIIToWide("a b")); s = w; @@ -777,24 +777,24 @@ public: #ifndef TSTRING_IS_STD_STRING UNIT_ASSERT(s.c_str() == w.c_str()); // Strip() does not change the string at all #endif - s = w; - StripLeft(s); - UNIT_ASSERT(s == w); + s = w; + StripLeft(s); + UNIT_ASSERT(s == w); #ifndef TSTRING_IS_STD_STRING - UNIT_ASSERT(s.c_str() == w.c_str()); // Strip() does not change the string at all + UNIT_ASSERT(s.c_str() == w.c_str()); // Strip() does not change the string at all #endif - s = w; - StripRight(s); - UNIT_ASSERT(s == w); + s = w; + StripRight(s); + UNIT_ASSERT(s == w); #ifndef TSTRING_IS_STD_STRING - UNIT_ASSERT(s.c_str() == w.c_str()); // Strip() does not change the string at all + UNIT_ASSERT(s.c_str() == w.c_str()); // Strip() does not change the string at all #endif } void TestIsSpace() { UNIT_ASSERT(!IsSpace(TUtf16String())); - UNIT_ASSERT(IsSpace(ws, Y_ARRAY_SIZE(ws))); + UNIT_ASSERT(IsSpace(ws, Y_ARRAY_SIZE(ws))); TUtf16String w; w.assign(ws, Y_ARRAY_SIZE(ws)).append(TUtf16String(1, '!')); @@ -983,760 +983,760 @@ public: } } } - - void TestIsLowerWordStr() { - UNIT_ASSERT(IsLowerWord(TWtringBuf())); - UNIT_ASSERT(IsLowerWord(UTF8ToWide(""))); - UNIT_ASSERT(IsLowerWord(UTF8ToWide("test"))); + + void TestIsLowerWordStr() { + UNIT_ASSERT(IsLowerWord(TWtringBuf())); + UNIT_ASSERT(IsLowerWord(UTF8ToWide(""))); + UNIT_ASSERT(IsLowerWord(UTF8ToWide("test"))); UNIT_ASSERT(IsLowerWord(UTF8ToWide("тест"))); // "тест" is "test" in russian (cyrrilic) - UNIT_ASSERT(!IsLowerWord(UTF8ToWide("тест тест"))); - UNIT_ASSERT(!IsLowerWord(UTF8ToWide("тест100500"))); - - UNIT_ASSERT(!IsLowerWord(UTF8ToWide("Test"))); - UNIT_ASSERT(!IsLowerWord(UTF8ToWide("tesT"))); - UNIT_ASSERT(!IsLowerWord(UTF8ToWide("tEst"))); - - UNIT_ASSERT(!IsLowerWord(UTF8ToWide("Тест"))); - UNIT_ASSERT(!IsLowerWord(UTF8ToWide("теСт"))); - UNIT_ASSERT(!IsLowerWord(UTF8ToWide("тесТ"))); - } - - void TestIsUpperWordStr() { - UNIT_ASSERT(IsUpperWord(TWtringBuf())); - UNIT_ASSERT(IsUpperWord(UTF8ToWide(""))); - UNIT_ASSERT(IsUpperWord(UTF8ToWide("TEST"))); - UNIT_ASSERT(IsUpperWord(UTF8ToWide("ТЕСТ"))); - UNIT_ASSERT(!IsUpperWord(UTF8ToWide("тест тест"))); - UNIT_ASSERT(!IsUpperWord(UTF8ToWide("тест100500"))); - - UNIT_ASSERT(!IsUpperWord(UTF8ToWide("Test"))); - UNIT_ASSERT(!IsUpperWord(UTF8ToWide("tesT"))); - UNIT_ASSERT(!IsUpperWord(UTF8ToWide("tEst"))); - - UNIT_ASSERT(!IsUpperWord(UTF8ToWide("Тест"))); - UNIT_ASSERT(!IsUpperWord(UTF8ToWide("теСт"))); - UNIT_ASSERT(!IsUpperWord(UTF8ToWide("тесТ"))); - } - - void TestIsTitleStr() { - UNIT_ASSERT(!IsTitleWord(TWtringBuf())); - UNIT_ASSERT(!IsTitleWord(UTF8ToWide(""))); - UNIT_ASSERT(!IsTitleWord(UTF8ToWide("t"))); - UNIT_ASSERT(!IsTitleWord(UTF8ToWide("й"))); - UNIT_ASSERT(IsTitleWord(UTF8ToWide("T"))); - UNIT_ASSERT(IsTitleWord(UTF8ToWide("Й"))); - UNIT_ASSERT(IsTitleWord(UTF8ToWide("Test"))); - UNIT_ASSERT(IsTitleWord(UTF8ToWide("Тест"))); - UNIT_ASSERT(!IsTitleWord(UTF8ToWide("тест тест"))); - UNIT_ASSERT(!IsTitleWord(UTF8ToWide("тест100500"))); - UNIT_ASSERT(!IsTitleWord(UTF8ToWide("Тест тест"))); - UNIT_ASSERT(!IsTitleWord(UTF8ToWide("Тест100500"))); - - UNIT_ASSERT(!IsTitleWord(UTF8ToWide("tesT"))); - UNIT_ASSERT(!IsTitleWord(UTF8ToWide("tEst"))); - - UNIT_ASSERT(!IsTitleWord(UTF8ToWide("теСт"))); - UNIT_ASSERT(!IsTitleWord(UTF8ToWide("тесТ"))); - } - - void TestIsLowerStr() { - UNIT_ASSERT(IsLower(TWtringBuf())); - UNIT_ASSERT(IsLower(UTF8ToWide(""))); - UNIT_ASSERT(IsLower(UTF8ToWide("test"))); + UNIT_ASSERT(!IsLowerWord(UTF8ToWide("тест тест"))); + UNIT_ASSERT(!IsLowerWord(UTF8ToWide("тест100500"))); + + UNIT_ASSERT(!IsLowerWord(UTF8ToWide("Test"))); + UNIT_ASSERT(!IsLowerWord(UTF8ToWide("tesT"))); + UNIT_ASSERT(!IsLowerWord(UTF8ToWide("tEst"))); + + UNIT_ASSERT(!IsLowerWord(UTF8ToWide("Тест"))); + UNIT_ASSERT(!IsLowerWord(UTF8ToWide("теСт"))); + UNIT_ASSERT(!IsLowerWord(UTF8ToWide("тесТ"))); + } + + void TestIsUpperWordStr() { + UNIT_ASSERT(IsUpperWord(TWtringBuf())); + UNIT_ASSERT(IsUpperWord(UTF8ToWide(""))); + UNIT_ASSERT(IsUpperWord(UTF8ToWide("TEST"))); + UNIT_ASSERT(IsUpperWord(UTF8ToWide("ТЕСТ"))); + UNIT_ASSERT(!IsUpperWord(UTF8ToWide("тест тест"))); + UNIT_ASSERT(!IsUpperWord(UTF8ToWide("тест100500"))); + + UNIT_ASSERT(!IsUpperWord(UTF8ToWide("Test"))); + UNIT_ASSERT(!IsUpperWord(UTF8ToWide("tesT"))); + UNIT_ASSERT(!IsUpperWord(UTF8ToWide("tEst"))); + + UNIT_ASSERT(!IsUpperWord(UTF8ToWide("Тест"))); + UNIT_ASSERT(!IsUpperWord(UTF8ToWide("теСт"))); + UNIT_ASSERT(!IsUpperWord(UTF8ToWide("тесТ"))); + } + + void TestIsTitleStr() { + UNIT_ASSERT(!IsTitleWord(TWtringBuf())); + UNIT_ASSERT(!IsTitleWord(UTF8ToWide(""))); + UNIT_ASSERT(!IsTitleWord(UTF8ToWide("t"))); + UNIT_ASSERT(!IsTitleWord(UTF8ToWide("й"))); + UNIT_ASSERT(IsTitleWord(UTF8ToWide("T"))); + UNIT_ASSERT(IsTitleWord(UTF8ToWide("Й"))); + UNIT_ASSERT(IsTitleWord(UTF8ToWide("Test"))); + UNIT_ASSERT(IsTitleWord(UTF8ToWide("Тест"))); + UNIT_ASSERT(!IsTitleWord(UTF8ToWide("тест тест"))); + UNIT_ASSERT(!IsTitleWord(UTF8ToWide("тест100500"))); + UNIT_ASSERT(!IsTitleWord(UTF8ToWide("Тест тест"))); + UNIT_ASSERT(!IsTitleWord(UTF8ToWide("Тест100500"))); + + UNIT_ASSERT(!IsTitleWord(UTF8ToWide("tesT"))); + UNIT_ASSERT(!IsTitleWord(UTF8ToWide("tEst"))); + + UNIT_ASSERT(!IsTitleWord(UTF8ToWide("теСт"))); + UNIT_ASSERT(!IsTitleWord(UTF8ToWide("тесТ"))); + } + + void TestIsLowerStr() { + UNIT_ASSERT(IsLower(TWtringBuf())); + UNIT_ASSERT(IsLower(UTF8ToWide(""))); + UNIT_ASSERT(IsLower(UTF8ToWide("test"))); UNIT_ASSERT(IsLower(UTF8ToWide("тест"))); // "тест" is "test" in russian (cyrrilic) - UNIT_ASSERT(IsLower(UTF8ToWide("тест тест"))); - UNIT_ASSERT(IsLower(UTF8ToWide("тест100500"))); - - UNIT_ASSERT(!IsLower(UTF8ToWide("Test"))); - UNIT_ASSERT(!IsLower(UTF8ToWide("tesT"))); - UNIT_ASSERT(!IsLower(UTF8ToWide("tEst"))); - - UNIT_ASSERT(!IsLower(UTF8ToWide("Тест"))); - UNIT_ASSERT(!IsLower(UTF8ToWide("теСт"))); - UNIT_ASSERT(!IsLower(UTF8ToWide("тесТ"))); - } - - void TestIsUpperStr() { - UNIT_ASSERT(IsUpper(TWtringBuf())); - UNIT_ASSERT(IsUpper(UTF8ToWide(""))); - UNIT_ASSERT(IsUpper(UTF8ToWide("TEST"))); - UNIT_ASSERT(IsUpper(UTF8ToWide("ТЕСТ"))); - UNIT_ASSERT(IsUpper(UTF8ToWide("ТЕСТ ТЕСТ"))); - UNIT_ASSERT(IsUpper(UTF8ToWide("ТЕСТ100500"))); - - UNIT_ASSERT(!IsUpper(UTF8ToWide("Test"))); - UNIT_ASSERT(!IsUpper(UTF8ToWide("tesT"))); - UNIT_ASSERT(!IsUpper(UTF8ToWide("tEst"))); - - UNIT_ASSERT(!IsUpper(UTF8ToWide("Тест"))); - UNIT_ASSERT(!IsUpper(UTF8ToWide("теСт"))); - UNIT_ASSERT(!IsUpper(UTF8ToWide("тесТ"))); - } - - void TestToLowerStr() { - // In these test and test for `ToUpper` and `ToTitle` we are checking that string keep - // pointing to the same piece of memory we are doing it the following way: - // - // TUtf16String s = ... - // const auto copy = s; - // ... - // UNIT_ASSERT(s.data() == copy.data()) - // - // It saves us a couple lines (we are reusing `copy` later) and if one day `TString` will - // become non-refcounted we'll need to rewrite it to something like: - // - // TUtf16String s = ... - // const auto* const data = s.data(); - // const auto length = s.length(); - // ... - // UNIT_ASSERT(s.data() == data); - // UNIT_ASSERT(s.length() == length); - { - TUtf16String s; - auto writableCopy = s; - const auto copy = s; - const TUtf16String lower; - - UNIT_ASSERT(!ToLower(s)); - UNIT_ASSERT(s == lower); + UNIT_ASSERT(IsLower(UTF8ToWide("тест тест"))); + UNIT_ASSERT(IsLower(UTF8ToWide("тест100500"))); + + UNIT_ASSERT(!IsLower(UTF8ToWide("Test"))); + UNIT_ASSERT(!IsLower(UTF8ToWide("tesT"))); + UNIT_ASSERT(!IsLower(UTF8ToWide("tEst"))); + + UNIT_ASSERT(!IsLower(UTF8ToWide("Тест"))); + UNIT_ASSERT(!IsLower(UTF8ToWide("теСт"))); + UNIT_ASSERT(!IsLower(UTF8ToWide("тесТ"))); + } + + void TestIsUpperStr() { + UNIT_ASSERT(IsUpper(TWtringBuf())); + UNIT_ASSERT(IsUpper(UTF8ToWide(""))); + UNIT_ASSERT(IsUpper(UTF8ToWide("TEST"))); + UNIT_ASSERT(IsUpper(UTF8ToWide("ТЕСТ"))); + UNIT_ASSERT(IsUpper(UTF8ToWide("ТЕСТ ТЕСТ"))); + UNIT_ASSERT(IsUpper(UTF8ToWide("ТЕСТ100500"))); + + UNIT_ASSERT(!IsUpper(UTF8ToWide("Test"))); + UNIT_ASSERT(!IsUpper(UTF8ToWide("tesT"))); + UNIT_ASSERT(!IsUpper(UTF8ToWide("tEst"))); + + UNIT_ASSERT(!IsUpper(UTF8ToWide("Тест"))); + UNIT_ASSERT(!IsUpper(UTF8ToWide("теСт"))); + UNIT_ASSERT(!IsUpper(UTF8ToWide("тесТ"))); + } + + void TestToLowerStr() { + // In these test and test for `ToUpper` and `ToTitle` we are checking that string keep + // pointing to the same piece of memory we are doing it the following way: + // + // TUtf16String s = ... + // const auto copy = s; + // ... + // UNIT_ASSERT(s.data() == copy.data()) + // + // It saves us a couple lines (we are reusing `copy` later) and if one day `TString` will + // become non-refcounted we'll need to rewrite it to something like: + // + // TUtf16String s = ... + // const auto* const data = s.data(); + // const auto length = s.length(); + // ... + // UNIT_ASSERT(s.data() == data); + // UNIT_ASSERT(s.length() == length); + { + TUtf16String s; + auto writableCopy = s; + const auto copy = s; + const TUtf16String lower; + + UNIT_ASSERT(!ToLower(s)); + UNIT_ASSERT(s == lower); #ifndef TSTRING_IS_STD_STRING - UNIT_ASSERT(s.data() == copy.data()); + UNIT_ASSERT(s.data() == copy.data()); #endif - - UNIT_ASSERT(!ToLower(writableCopy.Detach(), writableCopy.size())); - UNIT_ASSERT(writableCopy == lower); - - UNIT_ASSERT(!ToLower(copy.data(), copy.size(), writableCopy.Detach())); - UNIT_ASSERT(writableCopy == lower); - - UNIT_ASSERT(ToLowerRet(copy) == lower); - UNIT_ASSERT(ToLowerRet(TWtringBuf(copy)) == lower); - } - { - TUtf16String s = UTF8ToWide(""); - auto writableCopy = s; - const auto copy = s; - const TUtf16String lower; - - UNIT_ASSERT(!ToLower(s)); - UNIT_ASSERT(s == lower); + + UNIT_ASSERT(!ToLower(writableCopy.Detach(), writableCopy.size())); + UNIT_ASSERT(writableCopy == lower); + + UNIT_ASSERT(!ToLower(copy.data(), copy.size(), writableCopy.Detach())); + UNIT_ASSERT(writableCopy == lower); + + UNIT_ASSERT(ToLowerRet(copy) == lower); + UNIT_ASSERT(ToLowerRet(TWtringBuf(copy)) == lower); + } + { + TUtf16String s = UTF8ToWide(""); + auto writableCopy = s; + const auto copy = s; + const TUtf16String lower; + + UNIT_ASSERT(!ToLower(s)); + UNIT_ASSERT(s == lower); #ifndef TSTRING_IS_STD_STRING - UNIT_ASSERT(s.data() == copy.data()); + UNIT_ASSERT(s.data() == copy.data()); #endif - - UNIT_ASSERT(!ToLower(writableCopy.Detach(), writableCopy.size())); - UNIT_ASSERT(writableCopy == lower); - - UNIT_ASSERT(!ToLower(copy.data(), copy.size(), writableCopy.Detach())); - UNIT_ASSERT(writableCopy == lower); - - UNIT_ASSERT(ToLowerRet(copy) == lower); - UNIT_ASSERT(ToLowerRet(TWtringBuf(copy)) == lower); - } - { - TUtf16String s; - const auto copy = s; - const TUtf16String lower; - - UNIT_ASSERT(!ToLower(s, 100500)); - UNIT_ASSERT(s == lower); + + UNIT_ASSERT(!ToLower(writableCopy.Detach(), writableCopy.size())); + UNIT_ASSERT(writableCopy == lower); + + UNIT_ASSERT(!ToLower(copy.data(), copy.size(), writableCopy.Detach())); + UNIT_ASSERT(writableCopy == lower); + + UNIT_ASSERT(ToLowerRet(copy) == lower); + UNIT_ASSERT(ToLowerRet(TWtringBuf(copy)) == lower); + } + { + TUtf16String s; + const auto copy = s; + const TUtf16String lower; + + UNIT_ASSERT(!ToLower(s, 100500)); + UNIT_ASSERT(s == lower); #ifndef TSTRING_IS_STD_STRING - UNIT_ASSERT(s.data() == copy.data()); + UNIT_ASSERT(s.data() == copy.data()); #endif - - UNIT_ASSERT(ToLowerRet(copy, 100500) == lower); - UNIT_ASSERT(ToLowerRet(TWtringBuf(copy), 100500) == lower); - } - { - TUtf16String s; - const auto copy = s; - const TUtf16String lower; - - UNIT_ASSERT(!ToLower(s, 100500, 1111)); - UNIT_ASSERT(s == lower); + + UNIT_ASSERT(ToLowerRet(copy, 100500) == lower); + UNIT_ASSERT(ToLowerRet(TWtringBuf(copy), 100500) == lower); + } + { + TUtf16String s; + const auto copy = s; + const TUtf16String lower; + + UNIT_ASSERT(!ToLower(s, 100500, 1111)); + UNIT_ASSERT(s == lower); #ifndef TSTRING_IS_STD_STRING - UNIT_ASSERT(s.data() == copy.data()); + UNIT_ASSERT(s.data() == copy.data()); #endif - - UNIT_ASSERT(ToLowerRet(copy, 100500, 1111) == lower); - UNIT_ASSERT(ToLowerRet(TWtringBuf(copy), 100500, 1111) == lower); - } - { - auto s = UTF8ToWide("Й"); - auto writableCopy = s; - const auto copy = s; - const auto lower = UTF8ToWide("й"); - - UNIT_ASSERT(ToLower(s)); - UNIT_ASSERT(s == lower); - - UNIT_ASSERT(ToLower(writableCopy.Detach(), writableCopy.size())); - UNIT_ASSERT(writableCopy == lower); - - UNIT_ASSERT(ToLower(copy.data(), copy.size(), writableCopy.Detach())); - UNIT_ASSERT(writableCopy == lower); - - UNIT_ASSERT(ToLowerRet(copy) == lower); - UNIT_ASSERT(ToLowerRet(TWtringBuf(copy)) == lower); - } - { - auto s = UTF8ToWide("й"); - auto writableCopy = s; - const auto copy = s; - const auto lower = UTF8ToWide("й"); - - UNIT_ASSERT(!ToLower(s)); - UNIT_ASSERT(s == lower); + + UNIT_ASSERT(ToLowerRet(copy, 100500, 1111) == lower); + UNIT_ASSERT(ToLowerRet(TWtringBuf(copy), 100500, 1111) == lower); + } + { + auto s = UTF8ToWide("Й"); + auto writableCopy = s; + const auto copy = s; + const auto lower = UTF8ToWide("й"); + + UNIT_ASSERT(ToLower(s)); + UNIT_ASSERT(s == lower); + + UNIT_ASSERT(ToLower(writableCopy.Detach(), writableCopy.size())); + UNIT_ASSERT(writableCopy == lower); + + UNIT_ASSERT(ToLower(copy.data(), copy.size(), writableCopy.Detach())); + UNIT_ASSERT(writableCopy == lower); + + UNIT_ASSERT(ToLowerRet(copy) == lower); + UNIT_ASSERT(ToLowerRet(TWtringBuf(copy)) == lower); + } + { + auto s = UTF8ToWide("й"); + auto writableCopy = s; + const auto copy = s; + const auto lower = UTF8ToWide("й"); + + UNIT_ASSERT(!ToLower(s)); + UNIT_ASSERT(s == lower); #ifndef TSTRING_IS_STD_STRING - UNIT_ASSERT(s.data() == copy.data()); + UNIT_ASSERT(s.data() == copy.data()); #endif - - UNIT_ASSERT(!ToLower(writableCopy.Detach(), writableCopy.size())); - UNIT_ASSERT(writableCopy == lower); - - UNIT_ASSERT(!ToLower(copy.data(), copy.size(), writableCopy.Detach())); - UNIT_ASSERT(writableCopy == lower); - - UNIT_ASSERT(ToLowerRet(copy) == lower); - UNIT_ASSERT(ToLowerRet(TWtringBuf(copy)) == lower); - } - { - auto s = UTF8ToWide("тест"); - auto writableCopy = s; - const auto copy = s; - const auto lower = UTF8ToWide("тест"); - - UNIT_ASSERT(!ToLower(s)); - UNIT_ASSERT(s == lower); + + UNIT_ASSERT(!ToLower(writableCopy.Detach(), writableCopy.size())); + UNIT_ASSERT(writableCopy == lower); + + UNIT_ASSERT(!ToLower(copy.data(), copy.size(), writableCopy.Detach())); + UNIT_ASSERT(writableCopy == lower); + + UNIT_ASSERT(ToLowerRet(copy) == lower); + UNIT_ASSERT(ToLowerRet(TWtringBuf(copy)) == lower); + } + { + auto s = UTF8ToWide("тест"); + auto writableCopy = s; + const auto copy = s; + const auto lower = UTF8ToWide("тест"); + + UNIT_ASSERT(!ToLower(s)); + UNIT_ASSERT(s == lower); #ifndef TSTRING_IS_STD_STRING - UNIT_ASSERT(s.data() == copy.data()); + UNIT_ASSERT(s.data() == copy.data()); #endif - - UNIT_ASSERT(!ToLower(writableCopy.Detach(), writableCopy.size())); - UNIT_ASSERT(writableCopy == lower); - - UNIT_ASSERT(!ToLower(copy.data(), copy.size(), writableCopy.Detach())); - UNIT_ASSERT(writableCopy == lower); - - UNIT_ASSERT(ToLowerRet(copy) == lower); - UNIT_ASSERT(ToLowerRet(TWtringBuf(copy)) == lower); - } - { - auto s = UTF8ToWide("Тест"); - auto writableCopy = s; - const auto copy = s; - const auto lower = UTF8ToWide("тест"); - - UNIT_ASSERT(ToLower(s)); - UNIT_ASSERT(s == lower); - - UNIT_ASSERT(ToLower(writableCopy.Detach(), writableCopy.size())); - UNIT_ASSERT(writableCopy == lower); - - UNIT_ASSERT(ToLower(copy.data(), copy.size(), writableCopy.Detach())); - UNIT_ASSERT(writableCopy == lower); - - UNIT_ASSERT(ToLowerRet(copy) == lower); - UNIT_ASSERT(ToLowerRet(TWtringBuf(copy)) == lower); - } - { - TUtf16String s = UTF8ToWide("тЕст"); - const auto copy = s; - const auto lower = UTF8ToWide("тест"); - - UNIT_ASSERT(ToLower(s)); - UNIT_ASSERT(s == UTF8ToWide("тест")); - - UNIT_ASSERT(ToLowerRet(copy) == lower); - UNIT_ASSERT(ToLowerRet(TWtringBuf(copy)) == lower); - } - { - auto s = UTF8ToWide("тЕст"); - const auto copy = s; - const auto lower = UTF8ToWide("тЕст"); - - UNIT_ASSERT(!ToLower(s, 2)); - UNIT_ASSERT(s == lower); + + UNIT_ASSERT(!ToLower(writableCopy.Detach(), writableCopy.size())); + UNIT_ASSERT(writableCopy == lower); + + UNIT_ASSERT(!ToLower(copy.data(), copy.size(), writableCopy.Detach())); + UNIT_ASSERT(writableCopy == lower); + + UNIT_ASSERT(ToLowerRet(copy) == lower); + UNIT_ASSERT(ToLowerRet(TWtringBuf(copy)) == lower); + } + { + auto s = UTF8ToWide("Тест"); + auto writableCopy = s; + const auto copy = s; + const auto lower = UTF8ToWide("тест"); + + UNIT_ASSERT(ToLower(s)); + UNIT_ASSERT(s == lower); + + UNIT_ASSERT(ToLower(writableCopy.Detach(), writableCopy.size())); + UNIT_ASSERT(writableCopy == lower); + + UNIT_ASSERT(ToLower(copy.data(), copy.size(), writableCopy.Detach())); + UNIT_ASSERT(writableCopy == lower); + + UNIT_ASSERT(ToLowerRet(copy) == lower); + UNIT_ASSERT(ToLowerRet(TWtringBuf(copy)) == lower); + } + { + TUtf16String s = UTF8ToWide("тЕст"); + const auto copy = s; + const auto lower = UTF8ToWide("тест"); + + UNIT_ASSERT(ToLower(s)); + UNIT_ASSERT(s == UTF8ToWide("тест")); + + UNIT_ASSERT(ToLowerRet(copy) == lower); + UNIT_ASSERT(ToLowerRet(TWtringBuf(copy)) == lower); + } + { + auto s = UTF8ToWide("тЕст"); + const auto copy = s; + const auto lower = UTF8ToWide("тЕст"); + + UNIT_ASSERT(!ToLower(s, 2)); + UNIT_ASSERT(s == lower); #ifndef TSTRING_IS_STD_STRING - UNIT_ASSERT(s.data() == copy.data()); + UNIT_ASSERT(s.data() == copy.data()); #endif - - UNIT_ASSERT(ToLowerRet(copy, 2) == lower); - UNIT_ASSERT(ToLowerRet(TWtringBuf(copy), 2) == lower); - } - { - auto s = UTF8ToWide("теСт"); - const auto copy = s; - const auto lower = UTF8ToWide("тест"); - - UNIT_ASSERT(ToLower(s, 2)); - UNIT_ASSERT(s == lower); - - UNIT_ASSERT(ToLowerRet(copy, 2) == lower); - UNIT_ASSERT(ToLowerRet(TWtringBuf(copy), 2) == lower); - } - { - auto s = UTF8ToWide("теСт"); - const auto copy = s; - const auto lower = UTF8ToWide("теСт"); - - UNIT_ASSERT(!ToLower(s, 3, 1)); - UNIT_ASSERT(s == copy); + + UNIT_ASSERT(ToLowerRet(copy, 2) == lower); + UNIT_ASSERT(ToLowerRet(TWtringBuf(copy), 2) == lower); + } + { + auto s = UTF8ToWide("теСт"); + const auto copy = s; + const auto lower = UTF8ToWide("тест"); + + UNIT_ASSERT(ToLower(s, 2)); + UNIT_ASSERT(s == lower); + + UNIT_ASSERT(ToLowerRet(copy, 2) == lower); + UNIT_ASSERT(ToLowerRet(TWtringBuf(copy), 2) == lower); + } + { + auto s = UTF8ToWide("теСт"); + const auto copy = s; + const auto lower = UTF8ToWide("теСт"); + + UNIT_ASSERT(!ToLower(s, 3, 1)); + UNIT_ASSERT(s == copy); #ifndef TSTRING_IS_STD_STRING - UNIT_ASSERT(s.data() == copy.data()); + UNIT_ASSERT(s.data() == copy.data()); #endif - - UNIT_ASSERT(ToLowerRet(copy, 3, 1) == lower); - UNIT_ASSERT(ToLowerRet(TWtringBuf(copy), 3, 1) == lower); - } - { - auto s = UTF8ToWide("теСт"); - const auto copy = s; - const auto lower = UTF8ToWide("теСт"); - - UNIT_ASSERT(!ToLower(s, 3, 100500)); - UNIT_ASSERT(s == copy); + + UNIT_ASSERT(ToLowerRet(copy, 3, 1) == lower); + UNIT_ASSERT(ToLowerRet(TWtringBuf(copy), 3, 1) == lower); + } + { + auto s = UTF8ToWide("теСт"); + const auto copy = s; + const auto lower = UTF8ToWide("теСт"); + + UNIT_ASSERT(!ToLower(s, 3, 100500)); + UNIT_ASSERT(s == copy); #ifndef TSTRING_IS_STD_STRING - UNIT_ASSERT(s.data() == copy.data()); + UNIT_ASSERT(s.data() == copy.data()); #endif - - UNIT_ASSERT(ToLowerRet(copy, 3, 100500) == lower); - UNIT_ASSERT(ToLowerRet(TWtringBuf(copy), 3, 100500) == lower); - } - } - - void TestToUpperStr() { - { - TUtf16String s; - auto writableCopy = s; - const auto copy = s; - const TUtf16String upper; - - UNIT_ASSERT(!ToUpper(s)); - UNIT_ASSERT(s == upper); + + UNIT_ASSERT(ToLowerRet(copy, 3, 100500) == lower); + UNIT_ASSERT(ToLowerRet(TWtringBuf(copy), 3, 100500) == lower); + } + } + + void TestToUpperStr() { + { + TUtf16String s; + auto writableCopy = s; + const auto copy = s; + const TUtf16String upper; + + UNIT_ASSERT(!ToUpper(s)); + UNIT_ASSERT(s == upper); #ifndef TSTRING_IS_STD_STRING - UNIT_ASSERT(s.data() == copy.data()); + UNIT_ASSERT(s.data() == copy.data()); #endif - - UNIT_ASSERT(!ToUpper(writableCopy.Detach(), writableCopy.size())); - UNIT_ASSERT(writableCopy == upper); - - UNIT_ASSERT(!ToUpper(copy.data(), copy.size(), writableCopy.Detach())); - UNIT_ASSERT(writableCopy == upper); - - UNIT_ASSERT(ToUpperRet(copy) == upper); - UNIT_ASSERT(ToUpperRet(TWtringBuf(copy)) == upper); - } - { - auto s = UTF8ToWide(""); - auto writableCopy = s; - const auto copy = s; - const TUtf16String upper; - - UNIT_ASSERT(!ToUpper(s)); - UNIT_ASSERT(s == upper); + + UNIT_ASSERT(!ToUpper(writableCopy.Detach(), writableCopy.size())); + UNIT_ASSERT(writableCopy == upper); + + UNIT_ASSERT(!ToUpper(copy.data(), copy.size(), writableCopy.Detach())); + UNIT_ASSERT(writableCopy == upper); + + UNIT_ASSERT(ToUpperRet(copy) == upper); + UNIT_ASSERT(ToUpperRet(TWtringBuf(copy)) == upper); + } + { + auto s = UTF8ToWide(""); + auto writableCopy = s; + const auto copy = s; + const TUtf16String upper; + + UNIT_ASSERT(!ToUpper(s)); + UNIT_ASSERT(s == upper); #ifndef TSTRING_IS_STD_STRING - UNIT_ASSERT(s.data() == copy.data()); + UNIT_ASSERT(s.data() == copy.data()); #endif - - UNIT_ASSERT(!ToUpper(writableCopy.Detach(), writableCopy.size())); - UNIT_ASSERT(writableCopy == upper); - - UNIT_ASSERT(!ToUpper(copy.data(), copy.size(), writableCopy.Detach())); - UNIT_ASSERT(writableCopy == upper); - - UNIT_ASSERT(ToUpperRet(copy) == upper); - UNIT_ASSERT(ToUpperRet(TWtringBuf(copy)) == upper); - } - { - TUtf16String s; - auto writableCopy = s; - const auto copy = s; - const TUtf16String upper; - - UNIT_ASSERT(!ToUpper(s, 100500)); - UNIT_ASSERT(s == upper); + + UNIT_ASSERT(!ToUpper(writableCopy.Detach(), writableCopy.size())); + UNIT_ASSERT(writableCopy == upper); + + UNIT_ASSERT(!ToUpper(copy.data(), copy.size(), writableCopy.Detach())); + UNIT_ASSERT(writableCopy == upper); + + UNIT_ASSERT(ToUpperRet(copy) == upper); + UNIT_ASSERT(ToUpperRet(TWtringBuf(copy)) == upper); + } + { + TUtf16String s; + auto writableCopy = s; + const auto copy = s; + const TUtf16String upper; + + UNIT_ASSERT(!ToUpper(s, 100500)); + UNIT_ASSERT(s == upper); #ifndef TSTRING_IS_STD_STRING - UNIT_ASSERT(s.data() == copy.data()); + UNIT_ASSERT(s.data() == copy.data()); #endif - - UNIT_ASSERT(!ToUpper(writableCopy.Detach(), writableCopy.size())); - UNIT_ASSERT(writableCopy == upper); - - UNIT_ASSERT(!ToUpper(copy.data(), copy.size(), writableCopy.Detach())); - UNIT_ASSERT(writableCopy == upper); - - UNIT_ASSERT(ToUpperRet(copy, 100500) == upper); - UNIT_ASSERT(ToUpperRet(TWtringBuf(copy), 100500) == upper); - } - { - TUtf16String s; - const auto copy = s; - const TUtf16String upper; - - UNIT_ASSERT(!ToUpper(s, 100500, 1111)); - UNIT_ASSERT(s == upper); + + UNIT_ASSERT(!ToUpper(writableCopy.Detach(), writableCopy.size())); + UNIT_ASSERT(writableCopy == upper); + + UNIT_ASSERT(!ToUpper(copy.data(), copy.size(), writableCopy.Detach())); + UNIT_ASSERT(writableCopy == upper); + + UNIT_ASSERT(ToUpperRet(copy, 100500) == upper); + UNIT_ASSERT(ToUpperRet(TWtringBuf(copy), 100500) == upper); + } + { + TUtf16String s; + const auto copy = s; + const TUtf16String upper; + + UNIT_ASSERT(!ToUpper(s, 100500, 1111)); + UNIT_ASSERT(s == upper); #ifndef TSTRING_IS_STD_STRING - UNIT_ASSERT(s.data() == copy.data()); + UNIT_ASSERT(s.data() == copy.data()); #endif - - UNIT_ASSERT(ToUpperRet(copy, 100500, 1111) == upper); - UNIT_ASSERT(ToUpperRet(TWtringBuf(copy), 100500, 1111) == upper); - } - { - auto s = UTF8ToWide("й"); - auto writableCopy = s; - const auto copy = s; - const auto upper = UTF8ToWide("Й"); - - UNIT_ASSERT(ToUpper(s)); - UNIT_ASSERT(s == upper); - - UNIT_ASSERT(ToUpper(writableCopy.Detach(), writableCopy.size())); - UNIT_ASSERT(writableCopy == upper); - - UNIT_ASSERT(ToUpper(copy.data(), copy.size(), writableCopy.Detach())); - UNIT_ASSERT(writableCopy == upper); - - UNIT_ASSERT(ToUpperRet(copy) == upper); - UNIT_ASSERT(ToUpperRet(TWtringBuf(copy)) == upper); - } - { - auto s = UTF8ToWide("Й"); - auto writableCopy = s; - const auto copy = s; - const auto upper = UTF8ToWide("Й"); - - UNIT_ASSERT(!ToUpper(s)); - UNIT_ASSERT(s == copy); + + UNIT_ASSERT(ToUpperRet(copy, 100500, 1111) == upper); + UNIT_ASSERT(ToUpperRet(TWtringBuf(copy), 100500, 1111) == upper); + } + { + auto s = UTF8ToWide("й"); + auto writableCopy = s; + const auto copy = s; + const auto upper = UTF8ToWide("Й"); + + UNIT_ASSERT(ToUpper(s)); + UNIT_ASSERT(s == upper); + + UNIT_ASSERT(ToUpper(writableCopy.Detach(), writableCopy.size())); + UNIT_ASSERT(writableCopy == upper); + + UNIT_ASSERT(ToUpper(copy.data(), copy.size(), writableCopy.Detach())); + UNIT_ASSERT(writableCopy == upper); + + UNIT_ASSERT(ToUpperRet(copy) == upper); + UNIT_ASSERT(ToUpperRet(TWtringBuf(copy)) == upper); + } + { + auto s = UTF8ToWide("Й"); + auto writableCopy = s; + const auto copy = s; + const auto upper = UTF8ToWide("Й"); + + UNIT_ASSERT(!ToUpper(s)); + UNIT_ASSERT(s == copy); #ifndef TSTRING_IS_STD_STRING - UNIT_ASSERT(s.data() == copy.data()); + UNIT_ASSERT(s.data() == copy.data()); #endif - - UNIT_ASSERT(!ToUpper(writableCopy.Detach(), writableCopy.size())); - UNIT_ASSERT(writableCopy == upper); - - UNIT_ASSERT(!ToUpper(copy.data(), copy.size(), writableCopy.Detach())); - UNIT_ASSERT(writableCopy == upper); - - UNIT_ASSERT(ToUpperRet(copy) == upper); - UNIT_ASSERT(ToUpperRet(TWtringBuf(copy)) == upper); - } - { - auto s = UTF8ToWide("тест"); - auto writableCopy = s; - const auto copy = s; - const auto upper = UTF8ToWide("ТЕСТ"); - - UNIT_ASSERT(ToUpper(s)); - UNIT_ASSERT(s == upper); - - UNIT_ASSERT(ToUpper(writableCopy.Detach(), writableCopy.size())); - UNIT_ASSERT(writableCopy == upper); - - UNIT_ASSERT(ToUpper(copy.data(), copy.size(), writableCopy.Detach())); - UNIT_ASSERT(writableCopy == upper); - - UNIT_ASSERT(ToUpperRet(copy) == upper); - UNIT_ASSERT(ToUpperRet(TWtringBuf(copy)) == upper); - } - { - auto s = UTF8ToWide("Тест"); - auto writableCopy = s; - const auto copy = s; - const auto upper = UTF8ToWide("ТЕСТ"); - - UNIT_ASSERT(ToUpper(s)); - UNIT_ASSERT(s == upper); - - UNIT_ASSERT(ToUpper(writableCopy.Detach(), writableCopy.size())); - UNIT_ASSERT(writableCopy == upper); - - UNIT_ASSERT(ToUpper(copy.data(), copy.size(), writableCopy.Detach())); - UNIT_ASSERT(writableCopy == upper); - - UNIT_ASSERT(ToUpperRet(copy) == upper); - UNIT_ASSERT(ToUpperRet(TWtringBuf(copy)) == upper); - } - { - auto s = UTF8ToWide("тЕст"); - auto writableCopy = s; - const auto copy = s; - const auto upper = UTF8ToWide("ТЕСТ"); - - UNIT_ASSERT(ToUpper(s)); - UNIT_ASSERT(s == upper); - - UNIT_ASSERT(ToUpper(writableCopy.Detach(), writableCopy.size())); - UNIT_ASSERT(writableCopy == upper); - - UNIT_ASSERT(ToUpper(copy.data(), copy.size(), writableCopy.Detach())); - UNIT_ASSERT(writableCopy == upper); - - UNIT_ASSERT(ToUpperRet(copy) == upper); - UNIT_ASSERT(ToUpperRet(TWtringBuf(copy)) == upper); - } - { - auto s = UTF8ToWide("тЕст"); - const auto copy = s; - const auto upper = UTF8ToWide("тЕСТ"); - - UNIT_ASSERT(ToUpper(s, 2)); - UNIT_ASSERT(s == upper); - - UNIT_ASSERT(ToUpperRet(copy, 2) == upper); - UNIT_ASSERT(ToUpperRet(TWtringBuf(copy), 2) == upper); - } - { - auto s = UTF8ToWide("теСт"); - const auto copy = s; - const auto upper = UTF8ToWide("теСТ"); - - UNIT_ASSERT(ToUpper(s, 2)); - UNIT_ASSERT(s == upper); - - UNIT_ASSERT(ToUpperRet(copy, 2) == upper); - UNIT_ASSERT(ToUpperRet(TWtringBuf(copy), 2) == upper); - } - { - auto s = UTF8ToWide("теСт"); - const auto copy = s; - const auto upper = UTF8ToWide("теСТ"); - - UNIT_ASSERT(ToUpper(s, 3, 1)); - UNIT_ASSERT(s == upper); - - UNIT_ASSERT(ToUpperRet(copy, 3, 1) == upper); - UNIT_ASSERT(ToUpperRet(TWtringBuf(copy), 3, 1) == upper); - } - { - auto s = UTF8ToWide("теСт"); - const auto copy = s; - const auto upper = UTF8ToWide("теСТ"); - - UNIT_ASSERT(ToUpper(s, 3, 100500)); - UNIT_ASSERT(s == upper); - - UNIT_ASSERT(ToUpperRet(copy, 3, 100500) == upper); - UNIT_ASSERT(ToUpperRet(TWtringBuf(copy), 3, 100500) == upper); - } - } - - void TestToTitleStr() { - { - TUtf16String s; - auto writableCopy = s; - const auto copy = s; - const TUtf16String title; - - UNIT_ASSERT(!ToTitle(s)); - UNIT_ASSERT(s == title); + + UNIT_ASSERT(!ToUpper(writableCopy.Detach(), writableCopy.size())); + UNIT_ASSERT(writableCopy == upper); + + UNIT_ASSERT(!ToUpper(copy.data(), copy.size(), writableCopy.Detach())); + UNIT_ASSERT(writableCopy == upper); + + UNIT_ASSERT(ToUpperRet(copy) == upper); + UNIT_ASSERT(ToUpperRet(TWtringBuf(copy)) == upper); + } + { + auto s = UTF8ToWide("тест"); + auto writableCopy = s; + const auto copy = s; + const auto upper = UTF8ToWide("ТЕСТ"); + + UNIT_ASSERT(ToUpper(s)); + UNIT_ASSERT(s == upper); + + UNIT_ASSERT(ToUpper(writableCopy.Detach(), writableCopy.size())); + UNIT_ASSERT(writableCopy == upper); + + UNIT_ASSERT(ToUpper(copy.data(), copy.size(), writableCopy.Detach())); + UNIT_ASSERT(writableCopy == upper); + + UNIT_ASSERT(ToUpperRet(copy) == upper); + UNIT_ASSERT(ToUpperRet(TWtringBuf(copy)) == upper); + } + { + auto s = UTF8ToWide("Тест"); + auto writableCopy = s; + const auto copy = s; + const auto upper = UTF8ToWide("ТЕСТ"); + + UNIT_ASSERT(ToUpper(s)); + UNIT_ASSERT(s == upper); + + UNIT_ASSERT(ToUpper(writableCopy.Detach(), writableCopy.size())); + UNIT_ASSERT(writableCopy == upper); + + UNIT_ASSERT(ToUpper(copy.data(), copy.size(), writableCopy.Detach())); + UNIT_ASSERT(writableCopy == upper); + + UNIT_ASSERT(ToUpperRet(copy) == upper); + UNIT_ASSERT(ToUpperRet(TWtringBuf(copy)) == upper); + } + { + auto s = UTF8ToWide("тЕст"); + auto writableCopy = s; + const auto copy = s; + const auto upper = UTF8ToWide("ТЕСТ"); + + UNIT_ASSERT(ToUpper(s)); + UNIT_ASSERT(s == upper); + + UNIT_ASSERT(ToUpper(writableCopy.Detach(), writableCopy.size())); + UNIT_ASSERT(writableCopy == upper); + + UNIT_ASSERT(ToUpper(copy.data(), copy.size(), writableCopy.Detach())); + UNIT_ASSERT(writableCopy == upper); + + UNIT_ASSERT(ToUpperRet(copy) == upper); + UNIT_ASSERT(ToUpperRet(TWtringBuf(copy)) == upper); + } + { + auto s = UTF8ToWide("тЕст"); + const auto copy = s; + const auto upper = UTF8ToWide("тЕСТ"); + + UNIT_ASSERT(ToUpper(s, 2)); + UNIT_ASSERT(s == upper); + + UNIT_ASSERT(ToUpperRet(copy, 2) == upper); + UNIT_ASSERT(ToUpperRet(TWtringBuf(copy), 2) == upper); + } + { + auto s = UTF8ToWide("теСт"); + const auto copy = s; + const auto upper = UTF8ToWide("теСТ"); + + UNIT_ASSERT(ToUpper(s, 2)); + UNIT_ASSERT(s == upper); + + UNIT_ASSERT(ToUpperRet(copy, 2) == upper); + UNIT_ASSERT(ToUpperRet(TWtringBuf(copy), 2) == upper); + } + { + auto s = UTF8ToWide("теСт"); + const auto copy = s; + const auto upper = UTF8ToWide("теСТ"); + + UNIT_ASSERT(ToUpper(s, 3, 1)); + UNIT_ASSERT(s == upper); + + UNIT_ASSERT(ToUpperRet(copy, 3, 1) == upper); + UNIT_ASSERT(ToUpperRet(TWtringBuf(copy), 3, 1) == upper); + } + { + auto s = UTF8ToWide("теСт"); + const auto copy = s; + const auto upper = UTF8ToWide("теСТ"); + + UNIT_ASSERT(ToUpper(s, 3, 100500)); + UNIT_ASSERT(s == upper); + + UNIT_ASSERT(ToUpperRet(copy, 3, 100500) == upper); + UNIT_ASSERT(ToUpperRet(TWtringBuf(copy), 3, 100500) == upper); + } + } + + void TestToTitleStr() { + { + TUtf16String s; + auto writableCopy = s; + const auto copy = s; + const TUtf16String title; + + UNIT_ASSERT(!ToTitle(s)); + UNIT_ASSERT(s == title); #ifndef TSTRING_IS_STD_STRING - UNIT_ASSERT(s.data() == copy.data()); + UNIT_ASSERT(s.data() == copy.data()); #endif - - UNIT_ASSERT(!ToTitle(writableCopy.Detach(), writableCopy.size())); - UNIT_ASSERT(writableCopy == title); - - UNIT_ASSERT(!ToTitle(copy.data(), copy.size(), writableCopy.Detach())); - UNIT_ASSERT(writableCopy == title); - - UNIT_ASSERT(ToTitleRet(copy) == title); - UNIT_ASSERT(ToTitleRet(TWtringBuf(copy)) == title); - } - { - auto s = UTF8ToWide(""); - auto writableCopy = s; - const auto copy = s; - const TUtf16String title; - - UNIT_ASSERT(!ToTitle(s)); - UNIT_ASSERT(s == title); + + UNIT_ASSERT(!ToTitle(writableCopy.Detach(), writableCopy.size())); + UNIT_ASSERT(writableCopy == title); + + UNIT_ASSERT(!ToTitle(copy.data(), copy.size(), writableCopy.Detach())); + UNIT_ASSERT(writableCopy == title); + + UNIT_ASSERT(ToTitleRet(copy) == title); + UNIT_ASSERT(ToTitleRet(TWtringBuf(copy)) == title); + } + { + auto s = UTF8ToWide(""); + auto writableCopy = s; + const auto copy = s; + const TUtf16String title; + + UNIT_ASSERT(!ToTitle(s)); + UNIT_ASSERT(s == title); #ifndef TSTRING_IS_STD_STRING - UNIT_ASSERT(s.data() == copy.data()); + UNIT_ASSERT(s.data() == copy.data()); #endif - - UNIT_ASSERT(!ToTitle(writableCopy.Detach(), writableCopy.size())); - UNIT_ASSERT(writableCopy == title); - - UNIT_ASSERT(!ToTitle(copy.data(), copy.size(), writableCopy.Detach())); - UNIT_ASSERT(writableCopy == title); - - UNIT_ASSERT(ToTitleRet(copy) == title); - UNIT_ASSERT(ToTitleRet(TWtringBuf(copy)) == title); - } - { - TUtf16String s; - const auto copy = s; - const TUtf16String title; - - UNIT_ASSERT(!ToTitle(s, 100500)); - UNIT_ASSERT(s == title); + + UNIT_ASSERT(!ToTitle(writableCopy.Detach(), writableCopy.size())); + UNIT_ASSERT(writableCopy == title); + + UNIT_ASSERT(!ToTitle(copy.data(), copy.size(), writableCopy.Detach())); + UNIT_ASSERT(writableCopy == title); + + UNIT_ASSERT(ToTitleRet(copy) == title); + UNIT_ASSERT(ToTitleRet(TWtringBuf(copy)) == title); + } + { + TUtf16String s; + const auto copy = s; + const TUtf16String title; + + UNIT_ASSERT(!ToTitle(s, 100500)); + UNIT_ASSERT(s == title); #ifndef TSTRING_IS_STD_STRING - UNIT_ASSERT(s.data() == copy.data()); + UNIT_ASSERT(s.data() == copy.data()); #endif - - UNIT_ASSERT(ToTitleRet(copy) == title); - UNIT_ASSERT(ToTitleRet(TWtringBuf(copy)) == title); - } - { - TUtf16String s; - const auto copy = s; - const TUtf16String title; - - UNIT_ASSERT(!ToTitle(s, 100500, 1111)); - UNIT_ASSERT(s == title); + + UNIT_ASSERT(ToTitleRet(copy) == title); + UNIT_ASSERT(ToTitleRet(TWtringBuf(copy)) == title); + } + { + TUtf16String s; + const auto copy = s; + const TUtf16String title; + + UNIT_ASSERT(!ToTitle(s, 100500, 1111)); + UNIT_ASSERT(s == title); #ifndef TSTRING_IS_STD_STRING - UNIT_ASSERT(s.data() == copy.data()); + UNIT_ASSERT(s.data() == copy.data()); #endif - - UNIT_ASSERT(ToTitleRet(copy) == title); - UNIT_ASSERT(ToTitleRet(TWtringBuf(copy)) == title); - } - { - auto s = UTF8ToWide("й"); - auto writableCopy = s; - const auto copy = s; - const auto title = UTF8ToWide("Й"); - - UNIT_ASSERT(ToTitle(s)); - UNIT_ASSERT(s == title); - - UNIT_ASSERT(ToTitle(writableCopy.Detach(), writableCopy.size())); - UNIT_ASSERT(writableCopy == title); - - UNIT_ASSERT(ToTitle(copy.data(), copy.size(), writableCopy.Detach())); - UNIT_ASSERT(writableCopy == title); - - UNIT_ASSERT(ToTitleRet(copy) == title); - UNIT_ASSERT(ToTitleRet(TWtringBuf(copy)) == title); - } - { - auto s = UTF8ToWide("Й"); - auto writableCopy = s; - const auto copy = s; - const auto title = UTF8ToWide("Й"); - - UNIT_ASSERT(!ToTitle(s)); - UNIT_ASSERT(s == title); + + UNIT_ASSERT(ToTitleRet(copy) == title); + UNIT_ASSERT(ToTitleRet(TWtringBuf(copy)) == title); + } + { + auto s = UTF8ToWide("й"); + auto writableCopy = s; + const auto copy = s; + const auto title = UTF8ToWide("Й"); + + UNIT_ASSERT(ToTitle(s)); + UNIT_ASSERT(s == title); + + UNIT_ASSERT(ToTitle(writableCopy.Detach(), writableCopy.size())); + UNIT_ASSERT(writableCopy == title); + + UNIT_ASSERT(ToTitle(copy.data(), copy.size(), writableCopy.Detach())); + UNIT_ASSERT(writableCopy == title); + + UNIT_ASSERT(ToTitleRet(copy) == title); + UNIT_ASSERT(ToTitleRet(TWtringBuf(copy)) == title); + } + { + auto s = UTF8ToWide("Й"); + auto writableCopy = s; + const auto copy = s; + const auto title = UTF8ToWide("Й"); + + UNIT_ASSERT(!ToTitle(s)); + UNIT_ASSERT(s == title); #ifndef TSTRING_IS_STD_STRING - UNIT_ASSERT(s.data() == copy.data()); + UNIT_ASSERT(s.data() == copy.data()); #endif - - UNIT_ASSERT(!ToTitle(writableCopy.Detach(), writableCopy.size())); - UNIT_ASSERT(writableCopy == title); - - UNIT_ASSERT(!ToTitle(copy.data(), copy.size(), writableCopy.Detach())); - UNIT_ASSERT(writableCopy == title); - - UNIT_ASSERT(ToTitleRet(copy) == title); - UNIT_ASSERT(ToTitleRet(TWtringBuf(copy)) == title); - } - { - auto s = UTF8ToWide("тест"); - auto writableCopy = s; - const auto copy = s; - const auto title = UTF8ToWide("Тест"); - - UNIT_ASSERT(ToTitle(s)); - UNIT_ASSERT(s == title); - - UNIT_ASSERT(ToTitle(writableCopy.Detach(), writableCopy.size())); - UNIT_ASSERT(writableCopy == title); - - UNIT_ASSERT(ToTitle(copy.data(), copy.size(), writableCopy.Detach())); - UNIT_ASSERT(writableCopy == title); - - UNIT_ASSERT(ToTitleRet(copy) == title); - UNIT_ASSERT(ToTitleRet(TWtringBuf(copy)) == title); - } - { - auto s = UTF8ToWide("Тест"); - auto writableCopy = s; - const auto copy = s; - const auto title = UTF8ToWide("Тест"); - - UNIT_ASSERT(!ToTitle(s)); - UNIT_ASSERT(s == title); + + UNIT_ASSERT(!ToTitle(writableCopy.Detach(), writableCopy.size())); + UNIT_ASSERT(writableCopy == title); + + UNIT_ASSERT(!ToTitle(copy.data(), copy.size(), writableCopy.Detach())); + UNIT_ASSERT(writableCopy == title); + + UNIT_ASSERT(ToTitleRet(copy) == title); + UNIT_ASSERT(ToTitleRet(TWtringBuf(copy)) == title); + } + { + auto s = UTF8ToWide("тест"); + auto writableCopy = s; + const auto copy = s; + const auto title = UTF8ToWide("Тест"); + + UNIT_ASSERT(ToTitle(s)); + UNIT_ASSERT(s == title); + + UNIT_ASSERT(ToTitle(writableCopy.Detach(), writableCopy.size())); + UNIT_ASSERT(writableCopy == title); + + UNIT_ASSERT(ToTitle(copy.data(), copy.size(), writableCopy.Detach())); + UNIT_ASSERT(writableCopy == title); + + UNIT_ASSERT(ToTitleRet(copy) == title); + UNIT_ASSERT(ToTitleRet(TWtringBuf(copy)) == title); + } + { + auto s = UTF8ToWide("Тест"); + auto writableCopy = s; + const auto copy = s; + const auto title = UTF8ToWide("Тест"); + + UNIT_ASSERT(!ToTitle(s)); + UNIT_ASSERT(s == title); #ifndef TSTRING_IS_STD_STRING - UNIT_ASSERT(s.data() == copy.data()); + UNIT_ASSERT(s.data() == copy.data()); #endif - - UNIT_ASSERT(!ToTitle(writableCopy.Detach(), writableCopy.size())); - UNIT_ASSERT(writableCopy == title); - - UNIT_ASSERT(!ToTitle(copy.data(), copy.size(), writableCopy.Detach())); - UNIT_ASSERT(writableCopy == title); - - UNIT_ASSERT(ToTitleRet(copy) == title); - UNIT_ASSERT(ToTitleRet(TWtringBuf(copy)) == title); - } - { - auto s = UTF8ToWide("тЕст"); - auto writableCopy = s; - const auto copy = s; - const auto title = UTF8ToWide("Тест"); - - UNIT_ASSERT(ToTitle(s)); - UNIT_ASSERT(s == title); - - UNIT_ASSERT(ToTitle(writableCopy.Detach(), writableCopy.size())); - UNIT_ASSERT(writableCopy == title); - - UNIT_ASSERT(ToTitle(copy.data(), copy.size(), writableCopy.Detach())); - UNIT_ASSERT(writableCopy == title); - - UNIT_ASSERT(ToTitleRet(copy) == title); - UNIT_ASSERT(ToTitleRet(TWtringBuf(copy)) == title); - } - { - auto s = UTF8ToWide("тЕст"); - const auto copy = s; - const auto title = UTF8ToWide("тЕСт"); - - UNIT_ASSERT(ToTitle(s, 2)); - UNIT_ASSERT(s == title); - - UNIT_ASSERT(ToTitleRet(copy, 2) == title); - UNIT_ASSERT(ToTitleRet(TWtringBuf(copy), 2) == title); - } - { - auto s = UTF8ToWide("теСт"); - const auto copy = s; - const auto title = UTF8ToWide("теСт"); - - UNIT_ASSERT(!ToTitle(s, 2)); - UNIT_ASSERT(s == title); + + UNIT_ASSERT(!ToTitle(writableCopy.Detach(), writableCopy.size())); + UNIT_ASSERT(writableCopy == title); + + UNIT_ASSERT(!ToTitle(copy.data(), copy.size(), writableCopy.Detach())); + UNIT_ASSERT(writableCopy == title); + + UNIT_ASSERT(ToTitleRet(copy) == title); + UNIT_ASSERT(ToTitleRet(TWtringBuf(copy)) == title); + } + { + auto s = UTF8ToWide("тЕст"); + auto writableCopy = s; + const auto copy = s; + const auto title = UTF8ToWide("Тест"); + + UNIT_ASSERT(ToTitle(s)); + UNIT_ASSERT(s == title); + + UNIT_ASSERT(ToTitle(writableCopy.Detach(), writableCopy.size())); + UNIT_ASSERT(writableCopy == title); + + UNIT_ASSERT(ToTitle(copy.data(), copy.size(), writableCopy.Detach())); + UNIT_ASSERT(writableCopy == title); + + UNIT_ASSERT(ToTitleRet(copy) == title); + UNIT_ASSERT(ToTitleRet(TWtringBuf(copy)) == title); + } + { + auto s = UTF8ToWide("тЕст"); + const auto copy = s; + const auto title = UTF8ToWide("тЕСт"); + + UNIT_ASSERT(ToTitle(s, 2)); + UNIT_ASSERT(s == title); + + UNIT_ASSERT(ToTitleRet(copy, 2) == title); + UNIT_ASSERT(ToTitleRet(TWtringBuf(copy), 2) == title); + } + { + auto s = UTF8ToWide("теСт"); + const auto copy = s; + const auto title = UTF8ToWide("теСт"); + + UNIT_ASSERT(!ToTitle(s, 2)); + UNIT_ASSERT(s == title); #ifndef TSTRING_IS_STD_STRING - UNIT_ASSERT(s.data() == copy.data()); + UNIT_ASSERT(s.data() == copy.data()); #endif - - UNIT_ASSERT(ToTitleRet(copy, 2) == title); - UNIT_ASSERT(ToTitleRet(TWtringBuf(copy), 2) == title); - } - { - auto s = UTF8ToWide("теСт"); - const auto copy = s; - const auto title = UTF8ToWide("теСТ"); - - UNIT_ASSERT(ToTitle(s, 3, 1)); - UNIT_ASSERT(s == title); - - UNIT_ASSERT(ToTitleRet(copy, 3, 1) == title); - UNIT_ASSERT(ToTitleRet(TWtringBuf(copy), 3, 1) == title); - } - { - auto s = UTF8ToWide("теСт"); - const auto copy = s; + + UNIT_ASSERT(ToTitleRet(copy, 2) == title); + UNIT_ASSERT(ToTitleRet(TWtringBuf(copy), 2) == title); + } + { + auto s = UTF8ToWide("теСт"); + const auto copy = s; + const auto title = UTF8ToWide("теСТ"); + + UNIT_ASSERT(ToTitle(s, 3, 1)); + UNIT_ASSERT(s == title); + + UNIT_ASSERT(ToTitleRet(copy, 3, 1) == title); + UNIT_ASSERT(ToTitleRet(TWtringBuf(copy), 3, 1) == title); + } + { + auto s = UTF8ToWide("теСт"); + const auto copy = s; const auto title = UTF8ToWide("теСТ"); - - UNIT_ASSERT(ToTitle(s, 3, 100500)); - UNIT_ASSERT(s == title); - - UNIT_ASSERT(ToTitleRet(copy, 3, 100500) == title); - UNIT_ASSERT(ToTitleRet(TWtringBuf(copy), 3, 100500) == title); - } - } + + UNIT_ASSERT(ToTitle(s, 3, 100500)); + UNIT_ASSERT(s == title); + + UNIT_ASSERT(ToTitleRet(copy, 3, 100500) == title); + UNIT_ASSERT(ToTitleRet(TWtringBuf(copy), 3, 100500) == title); + } + } }; UNIT_TEST_SUITE_REGISTRATION(TWideUtilTest); diff --git a/util/datetime/base.cpp b/util/datetime/base.cpp index 38ecc3ab962..39c49b7133d 100644 --- a/util/datetime/base.cpp +++ b/util/datetime/base.cpp @@ -42,7 +42,7 @@ namespace { return {i}; } - inline IOutputStream& operator<<(IOutputStream& o, const TPad<2>& p) { + inline IOutputStream& operator<<(IOutputStream& o, const TPad<2>& p) { if (p.I < 10) { if (p.I >= 0) { o << '0'; @@ -52,7 +52,7 @@ namespace { return o << p.I; } - inline IOutputStream& operator<<(IOutputStream& o, const TPad<4>& p) { + inline IOutputStream& operator<<(IOutputStream& o, const TPad<4>& p) { if (p.I < 1000) { if (p.I >= 0) { if (p.I < 10) { @@ -68,7 +68,7 @@ namespace { return o << p.I; } - inline IOutputStream& operator<<(IOutputStream& o, const TPad<6>& p) { + inline IOutputStream& operator<<(IOutputStream& o, const TPad<6>& p) { if (p.I < 100000) { if (p.I >= 0) { if (p.I < 10) { @@ -88,11 +88,11 @@ namespace { return o << p.I; } - void WriteMicroSecondsToStream(IOutputStream& os, ui32 microSeconds) { + void WriteMicroSecondsToStream(IOutputStream& os, ui32 microSeconds) { os << '.' << Pad<6>(microSeconds); } - void WriteTmToStream(IOutputStream& os, const struct tm& theTm) { + void WriteTmToStream(IOutputStream& os, const struct tm& theTm) { os << Pad<4>(theTm.tm_year + 1900) << '-' << Pad<2>(theTm.tm_mon + 1) << '-' << Pad<2>(theTm.tm_mday) << 'T' << Pad<2>(theTm.tm_hour) << ':' << Pad<2>(theTm.tm_min) << ':' << Pad<2>(theTm.tm_sec); } @@ -134,20 +134,20 @@ namespace { } template <> -void Out<TDuration>(IOutputStream& os, TTypeTraits<TDuration>::TFuncParam duration) { +void Out<TDuration>(IOutputStream& os, TTypeTraits<TDuration>::TFuncParam duration) { os << duration.Seconds(); WriteMicroSecondsToStream(os, duration.MicroSecondsOfSecond()); os << 's'; } template <> -void Out<TInstant>(IOutputStream& os, TTypeTraits<TInstant>::TFuncParam instant) { +void Out<TInstant>(IOutputStream& os, TTypeTraits<TInstant>::TFuncParam instant) { char buf[64]; auto len = FormatDate8601(buf, sizeof(buf), instant.TimeT()); - + // shouldn't happen due to current implementation of FormatDate8601() and GmTimeR() Y_ENSURE(len, TStringBuf("Out<TInstant>: year does not fit into an integer")); - + os.Write(buf, len - 1 /* 'Z' */); WriteMicroSecondsToStream(os, instant.MicroSecondsOfSecond()); os << 'Z'; diff --git a/util/datetime/base.h b/util/datetime/base.h index 5e902b8f633..11666de71e8 100644 --- a/util/datetime/base.h +++ b/util/datetime/base.h @@ -49,7 +49,7 @@ constexpr long seconds(const struct tm& theTm) { return 60 * (60 * theTm.tm_hour + theTm.tm_min) + theTm.tm_sec; } -void sprint_gm_date(char* buf, time_t when, long* sec = nullptr); +void sprint_gm_date(char* buf, time_t when, long* sec = nullptr); bool sscan_date(const char* date, struct tm& theTm); const int DATE_8601_LEN = 21; // strlen("YYYY-MM-DDThh:mm:ssZ") = 20 + '\0' @@ -120,7 +120,7 @@ public: } constexpr double SecondsFloat() const noexcept { - return Value_ * (1 / 1000000.0); + return Value_ * (1 / 1000000.0); } constexpr double MillisecondsFloat() const noexcept { @@ -152,7 +152,7 @@ public: } constexpr TValue NanoSeconds() const noexcept { - return MicroSeconds() >= (Max<TValue>() / (TValue)1000) ? Max<TValue>() : MicroSeconds() * (TValue)1000; + return MicroSeconds() >= (Max<TValue>() / (TValue)1000) ? Max<TValue>() : MicroSeconds() * (TValue)1000; } constexpr ui32 MicroSecondsOfSecond() const noexcept { @@ -308,11 +308,11 @@ public: } /// parses strings like 10s, 15ms, 15.05s, 20us, or just 25 (s). See parser_ut.cpp for details - static TDuration Parse(const TStringBuf input); + static TDuration Parse(const TStringBuf input); - static bool TryParse(const TStringBuf input, TDuration& result); + static bool TryParse(const TStringBuf input, TDuration& result); - // note global Out method is defined for TDuration, so it could be written to IOutputStream as text + // note global Out method is defined for TDuration, so it could be written to IOutputStream as text template <class T> inline TDuration& operator+=(const T& t) noexcept { @@ -337,7 +337,7 @@ public: TString ToString() const; }; -Y_DECLARE_PODTYPE(TDuration); +Y_DECLARE_PODTYPE(TDuration); template <> struct THash<TDuration> { @@ -447,7 +447,7 @@ public: * Formats the instant using the UTC time zone, with microsecond precision. * * @returns An ISO 8601 formatted string, e.g. '2015-11-21T23:30:27.991669Z'. - * @note Global Out method is defined to TInstant, so it can be written as text to IOutputStream. + * @note Global Out method is defined to TInstant, so it can be written as text to IOutputStream. */ TString ToString() const; @@ -507,45 +507,45 @@ public: TString FormatLocalTime(const char* format) const noexcept; TString FormatGmTime(const char* format) const noexcept; - /// See #TryParseIso8601. - static TInstant ParseIso8601(TStringBuf); - /// See #TryParseRfc822. + /// See #TryParseIso8601. + static TInstant ParseIso8601(TStringBuf); + /// See #TryParseRfc822. static TInstant ParseRfc822(TStringBuf); - /// See #TryParseHttp. - static TInstant ParseHttp(TStringBuf); - /// See #TryParseX509. - static TInstant ParseX509Validity(TStringBuf); - - /// ISO 8601 Representation of Dates and Times - /// - /// @link https://www.iso.org/standard/40874.html Description of format. - static bool TryParseIso8601(TStringBuf input, TInstant& instant); - - /// RFC 822 Date and Time specification - /// - /// @link https://tools.ietf.org/html/rfc822#section-5 Description of format. - static bool TryParseRfc822(TStringBuf input, TInstant& instant); - - /// RFC 2616 3.3.1 Full Date - /// - /// @link https://tools.ietf.org/html/rfc2616#section-3.3.1 Description of format. - static bool TryParseHttp(TStringBuf input, TInstant& instant); - - /// X.509 certificate validity time (see rfc5280 4.1.2.5.*) - /// - /// @link https://tools.ietf.org/html/rfc5280#section-4.1.2.5 Description of format. - static bool TryParseX509(TStringBuf input, TInstant& instant); - - static TInstant ParseIso8601Deprecated(TStringBuf); - static TInstant ParseRfc822Deprecated(TStringBuf); - static TInstant ParseHttpDeprecated(TStringBuf); - static TInstant ParseX509ValidityDeprecated(TStringBuf); - - static bool TryParseIso8601Deprecated(TStringBuf input, TInstant& instant); - static bool TryParseRfc822Deprecated(TStringBuf input, TInstant& instant); - static bool TryParseHttpDeprecated(TStringBuf input, TInstant& instant); - static bool TryParseX509Deprecated(TStringBuf input, TInstant& instant); - + /// See #TryParseHttp. + static TInstant ParseHttp(TStringBuf); + /// See #TryParseX509. + static TInstant ParseX509Validity(TStringBuf); + + /// ISO 8601 Representation of Dates and Times + /// + /// @link https://www.iso.org/standard/40874.html Description of format. + static bool TryParseIso8601(TStringBuf input, TInstant& instant); + + /// RFC 822 Date and Time specification + /// + /// @link https://tools.ietf.org/html/rfc822#section-5 Description of format. + static bool TryParseRfc822(TStringBuf input, TInstant& instant); + + /// RFC 2616 3.3.1 Full Date + /// + /// @link https://tools.ietf.org/html/rfc2616#section-3.3.1 Description of format. + static bool TryParseHttp(TStringBuf input, TInstant& instant); + + /// X.509 certificate validity time (see rfc5280 4.1.2.5.*) + /// + /// @link https://tools.ietf.org/html/rfc5280#section-4.1.2.5 Description of format. + static bool TryParseX509(TStringBuf input, TInstant& instant); + + static TInstant ParseIso8601Deprecated(TStringBuf); + static TInstant ParseRfc822Deprecated(TStringBuf); + static TInstant ParseHttpDeprecated(TStringBuf); + static TInstant ParseX509ValidityDeprecated(TStringBuf); + + static bool TryParseIso8601Deprecated(TStringBuf input, TInstant& instant); + static bool TryParseRfc822Deprecated(TStringBuf input, TInstant& instant); + static bool TryParseHttpDeprecated(TStringBuf input, TInstant& instant); + static bool TryParseX509Deprecated(TStringBuf input, TInstant& instant); + template <class T> inline TInstant& operator+=(const T& t) noexcept { return (*this = (*this + t)); @@ -557,7 +557,7 @@ public: } }; -Y_DECLARE_PODTYPE(TInstant); +Y_DECLARE_PODTYPE(TInstant); template <> struct THash<TInstant> { @@ -578,9 +578,9 @@ namespace NPrivate { }; } -/** @name Helpers for printing local times to `IOutputStream`s. +/** @name Helpers for printing local times to `IOutputStream`s. * The FormatLocal* functions create an opaque object that, when written to - * a `IOutputStream`, outputs this instant as an ISO 8601 formatted string + * a `IOutputStream`, outputs this instant as an ISO 8601 formatted string * using the system time zone. * * @note The only reason behind this set of functions is to avoid excessive @@ -634,14 +634,14 @@ static constexpr bool operator>=(const TTimeBase<S>& l, const TTimeBase<S>& r) n namespace NDateTimeHelpers { template <typename T> static constexpr T SumWithSaturation(T a, T b) { - static_assert(!std::numeric_limits<T>::is_signed, "expect !std::numeric_limits<T>::is_signed"); + static_assert(!std::numeric_limits<T>::is_signed, "expect !std::numeric_limits<T>::is_signed"); return Max<T>() - a < b ? Max<T>() : a + b; } template <typename T> static constexpr T DiffWithSaturation(T a, T b) { - static_assert(!std::numeric_limits<T>::is_signed, "expect !std::numeric_limits<T>::is_signed"); + static_assert(!std::numeric_limits<T>::is_signed, "expect !std::numeric_limits<T>::is_signed"); return a < b ? 0 : a - b; } @@ -773,8 +773,8 @@ constexpr TInstant operator-(const TInstant& l, const std::chrono::duration<T, T template <class T> inline TDuration operator*(TDuration d, T t) noexcept { - Y_ASSERT(t >= T()); - Y_ASSERT(t == T() || Max<TDuration::TValue>() / t >= d.GetValue()); + Y_ASSERT(t >= T()); + Y_ASSERT(t == T() || Max<TDuration::TValue>() / t >= d.GetValue()); return TDuration::FromValue(d.GetValue() * t); } @@ -794,7 +794,7 @@ inline TDuration operator*(T t, TDuration d) noexcept { return d * t; } -template <class T, std::enable_if_t<!std::is_same<TDuration, T>::value, int> = 0> +template <class T, std::enable_if_t<!std::is_same<TDuration, T>::value, int> = 0> constexpr TDuration operator/(const TDuration& d, const T& t) noexcept { return TDuration::FromValue(d.GetValue() / t); } diff --git a/util/datetime/base_ut.cpp b/util/datetime/base_ut.cpp index afc3f802eb2..605bcfd4526 100644 --- a/util/datetime/base_ut.cpp +++ b/util/datetime/base_ut.cpp @@ -47,8 +47,8 @@ namespace { } } -Y_UNIT_TEST_SUITE(TestSprintDate) { - Y_UNIT_TEST(Year9999) { +Y_UNIT_TEST_SUITE(TestSprintDate) { + Y_UNIT_TEST(Year9999) { struct tm t; t.tm_year = 9999 - 1900; t.tm_mday = 1; @@ -61,7 +61,7 @@ Y_UNIT_TEST_SUITE(TestSprintDate) { UNIT_ASSERT_VALUES_EQUAL(expectedDate, ToString(buf)); } - Y_UNIT_TEST(YearAfter9999) { + Y_UNIT_TEST(YearAfter9999) { struct tm t; t.tm_year = 123456 - 1900; t.tm_mday = 1; @@ -70,7 +70,7 @@ Y_UNIT_TEST_SUITE(TestSprintDate) { char buf[DATE_BUF_LEN]; UNIT_ASSERT_EXCEPTION(DateToString(buf, t), yexception); } - Y_UNIT_TEST(SmallYear) { + Y_UNIT_TEST(SmallYear) { struct tm t; t.tm_year = 0 - 1900; t.tm_mday = 1; @@ -83,7 +83,7 @@ Y_UNIT_TEST_SUITE(TestSprintDate) { UNIT_ASSERT_VALUES_EQUAL(expectedDate, ToString(buf)); } - Y_UNIT_TEST(SmallYearAndMonth) { + Y_UNIT_TEST(SmallYearAndMonth) { struct tm t; t.tm_year = 99 - 1900; t.tm_mday = 1; @@ -338,18 +338,18 @@ Y_UNIT_TEST_SUITE(TDateTimeTest) { } } -Y_UNIT_TEST_SUITE(DateTimeTest) { - Y_UNIT_TEST(TestDurationFromFloat) { +Y_UNIT_TEST_SUITE(DateTimeTest) { + Y_UNIT_TEST(TestDurationFromFloat) { UNIT_ASSERT_EQUAL(TDuration::MilliSeconds(500), TDuration::Seconds(0.5)); UNIT_ASSERT_EQUAL(TDuration::MilliSeconds(500), TDuration::Seconds(0.5f)); } - Y_UNIT_TEST(TestSecondsLargeValue) { + Y_UNIT_TEST(TestSecondsLargeValue) { unsigned int seconds = UINT_MAX; UNIT_ASSERT_VALUES_EQUAL(((ui64)seconds) * 1000000, TDuration::Seconds(seconds).MicroSeconds()); } - Y_UNIT_TEST(TestToString) { + Y_UNIT_TEST(TestToString) { #define CHECK_CONVERTIBLE(v) \ do { \ UNIT_ASSERT_VALUES_EQUAL(v, ToString(TDuration::Parse(v))); \ @@ -371,7 +371,7 @@ Y_UNIT_TEST_SUITE(DateTimeTest) { CHECK_CONVERTIBLE("33.011122s"); } - Y_UNIT_TEST(TestFromString) { + Y_UNIT_TEST(TestFromString) { static const struct T { const char* const Str; const TDuration::TValue MicroSeconds; @@ -384,7 +384,7 @@ Y_UNIT_TEST_SUITE(DateTimeTest) { {"x3ms", 0, false}, }; - for (const T* t = tests; t != std::end(tests); ++t) { + for (const T* t = tests; t != std::end(tests); ++t) { // FromString bool parsed = false; try { @@ -403,14 +403,14 @@ Y_UNIT_TEST_SUITE(DateTimeTest) { } } - Y_UNIT_TEST(TestSleep) { + Y_UNIT_TEST(TestSleep) { // check does not throw Sleep(TDuration::Seconds(0)); Sleep(TDuration::MicroSeconds(1)); Sleep(TDuration::MilliSeconds(1)); } - Y_UNIT_TEST(TestInstantToString) { + Y_UNIT_TEST(TestInstantToString) { UNIT_ASSERT_VALUES_EQUAL(TString("2009-08-06T15:19:06.023455Z"), ToString(TInstant::Seconds(1249571946) + TDuration::MicroSeconds(23455))); UNIT_ASSERT_VALUES_EQUAL(TString("2009-08-06T15:19:06.023455Z"), (TInstant::Seconds(1249571946) + TDuration::MicroSeconds(23455)).ToString()); UNIT_ASSERT_VALUES_EQUAL(TString("2009-08-06T15:19:06Z"), (TInstant::Seconds(1249571946) + TDuration::MicroSeconds(23455)).ToStringUpToSeconds()); @@ -420,7 +420,7 @@ Y_UNIT_TEST_SUITE(DateTimeTest) { UNIT_ASSERT_VALUES_EQUAL(TString("Thu, 06 Aug 2009 15:19:06 GMT"), (TInstant::Seconds(1249571946) + TDuration::MicroSeconds(23455)).ToRfc822String()); } - Y_UNIT_TEST(TestInstantMath) { + Y_UNIT_TEST(TestInstantMath) { UNIT_ASSERT_VALUES_EQUAL(TInstant::Seconds(1719), TInstant::Seconds(1700) + TDuration::Seconds(19)); // overflow UNIT_ASSERT_VALUES_EQUAL(TInstant::Max(), TInstant::Max() - TDuration::Seconds(10) + TDuration::Seconds(19)); @@ -429,7 +429,7 @@ Y_UNIT_TEST_SUITE(DateTimeTest) { UNIT_ASSERT_VALUES_EQUAL(TDuration::Zero(), TInstant::Seconds(1000) - TInstant::Seconds(2000)); } - Y_UNIT_TEST(TestDurationMath) { + Y_UNIT_TEST(TestDurationMath) { TDuration empty; UNIT_ASSERT(!empty); // ensure that this compiles too @@ -484,20 +484,20 @@ Y_UNIT_TEST_SUITE(DateTimeTest) { UNIT_ASSERT_VALUES_EQUAL(onlyDays.Days(), days); } - Y_UNIT_TEST(TestInstantUnits) { + Y_UNIT_TEST(TestInstantUnits) { TestTimeUnits<TInstant>(); } - Y_UNIT_TEST(TestDurationUnits) { + Y_UNIT_TEST(TestDurationUnits) { TestTimeUnits<TDuration>(); } - Y_UNIT_TEST(TestNoexceptConstruction) { + Y_UNIT_TEST(TestNoexceptConstruction) { UNIT_ASSERT_EXCEPTION(TDuration::MilliSeconds(FromString(TStringBuf("not a number"))), yexception); UNIT_ASSERT_EXCEPTION(TDuration::Seconds(FromString(TStringBuf("not a number"))), yexception); } - Y_UNIT_TEST(TestFromValueForTDuration) { + Y_UNIT_TEST(TestFromValueForTDuration) { // check that FromValue creates the same TDuration TDuration d1 = TDuration::MicroSeconds(12345); TDuration d2 = TDuration::FromValue(d1.GetValue()); @@ -505,7 +505,7 @@ Y_UNIT_TEST_SUITE(DateTimeTest) { UNIT_ASSERT_VALUES_EQUAL(d1, d2); } - Y_UNIT_TEST(TestFromValueForTInstant) { + Y_UNIT_TEST(TestFromValueForTInstant) { // check that FromValue creates the same TInstant TInstant i1 = TInstant::MicroSeconds(12345); TInstant i2 = TInstant::FromValue(i1.GetValue()); diff --git a/util/datetime/cputimer.cpp b/util/datetime/cputimer.cpp index 516d372c374..978d41254e5 100644 --- a/util/datetime/cputimer.cpp +++ b/util/datetime/cputimer.cpp @@ -2,7 +2,7 @@ #include <util/system/defaults.h> #include <util/system/hp_timer.h> -#include <util/string/printf.h> +#include <util/string/printf.h> #include <util/stream/output.h> #include <util/generic/singleton.h> @@ -16,7 +16,7 @@ #include <util/system/winint.h> #endif -TTimer::TTimer(const TStringBuf message) { +TTimer::TTimer(const TStringBuf message) { static const int SMALL_DURATION_CHAR_LENGTH = 9; // strlen("0.123456s") Message_.Reserve(message.length() + SMALL_DURATION_CHAR_LENGTH + 1); // +"\n" Message_ << message; @@ -77,7 +77,7 @@ TString FormatCycles(ui64 cycles) { return result; } -TFormattedPrecisionTimer::TFormattedPrecisionTimer(const char* message, IOutputStream* out) +TFormattedPrecisionTimer::TFormattedPrecisionTimer(const char* message, IOutputStream* out) : Message(message) , Out(out) { @@ -106,7 +106,7 @@ TTimeLogger::TTimeLogger(const TString& message, bool verbose) : Message(message) , Verbose(verbose) , OK(false) - , Begin(time(nullptr)) + , Begin(time(nullptr)) , BeginCycles(GetCycleCount()) { if (Verbose) { @@ -116,7 +116,7 @@ TTimeLogger::TTimeLogger(const TString& message, bool verbose) } double TTimeLogger::ElapsedTime() const { - return time(nullptr) - Begin; + return time(nullptr) - Begin; } void TTimeLogger::SetOK() { @@ -124,7 +124,7 @@ void TTimeLogger::SetOK() { } TTimeLogger::~TTimeLogger() { - time_t tim = time(nullptr); + time_t tim = time(nullptr); ui64 endCycles = GetCycleCount(); if (Verbose) { const char* prefix = (OK) ? "" : "!"; diff --git a/util/datetime/cputimer.h b/util/datetime/cputimer.h index 7d38d5bdb38..61042402640 100644 --- a/util/datetime/cputimer.h +++ b/util/datetime/cputimer.h @@ -78,10 +78,10 @@ class TFormattedPrecisionTimer { private: ui64 Start; const char* Message; - IOutputStream* Out; + IOutputStream* Out; public: - TFormattedPrecisionTimer(const char* message = "took ", IOutputStream* out = &Cout); + TFormattedPrecisionTimer(const char* message = "took ", IOutputStream* out = &Cout); ~TFormattedPrecisionTimer(); }; diff --git a/util/datetime/parser.rl6 b/util/datetime/parser.rl6 index 931f09eae11..184b646a2d0 100644 --- a/util/datetime/parser.rl6 +++ b/util/datetime/parser.rl6 @@ -395,27 +395,27 @@ bool TX509Validity4yDateTimeParser::ParsePart(const char *input, size_t len) { } TInstant TIso8601DateTimeParserDeprecated::GetResult(TInstant defaultValue) const { - Y_UNUSED(ISO8601DateTimeParser_en_main); + Y_UNUSED(ISO8601DateTimeParser_en_main); return TDateTimeParserBaseDeprecated::GetResult(ISO8601DateTimeParser_first_final, defaultValue); } TInstant TRfc822DateTimeParserDeprecated::GetResult(TInstant defaultValue) const { - Y_UNUSED(RFC822DateParser_en_main); + Y_UNUSED(RFC822DateParser_en_main); return TDateTimeParserBaseDeprecated::GetResult(RFC822DateParser_first_final, defaultValue); } TInstant THttpDateTimeParserDeprecated::GetResult(TInstant defaultValue) const { - Y_UNUSED(HttpDateTimeParserStandalone_en_main); + Y_UNUSED(HttpDateTimeParserStandalone_en_main); return TDateTimeParserBaseDeprecated::GetResult(HttpDateTimeParserStandalone_first_final, defaultValue); } TInstant TX509ValidityDateTimeParserDeprecated::GetResult(TInstant defaultValue) const { - Y_UNUSED(X509ValidityDateTimeParser_en_main); + Y_UNUSED(X509ValidityDateTimeParser_en_main); return TDateTimeParserBaseDeprecated::GetResult(X509ValidityDateTimeParser_first_final, defaultValue); } TInstant TX509Validity4yDateTimeParserDeprecated::GetResult(TInstant defaultValue) const { - Y_UNUSED(X509Validity4yDateTimeParser_en_main); + Y_UNUSED(X509Validity4yDateTimeParser_en_main); return TDateTimeParserBaseDeprecated::GetResult(X509Validity4yDateTimeParser_first_final, defaultValue); } @@ -452,10 +452,10 @@ static inline TResult Parse(const char* input, size_t len, TResult defaultValue) return parser.GetResult(defaultValue); } -template<class TParser, class TResult, bool ThrowExceptionOnFailure = true> +template<class TParser, class TResult, bool ThrowExceptionOnFailure = true> static inline TResult ParseUnsafe(const char* input, size_t len) { TResult r = Parse<TParser, TResult>(input, len, TResult::Max()); - if (ThrowExceptionOnFailure && r == TResult::Max()) + if (ThrowExceptionOnFailure && r == TResult::Max()) ythrow TDateTimeParseException() << "error in datetime parsing. Input data: " << TStringBuf(input, len); return r; } @@ -479,56 +479,56 @@ TInstant TInstant::ParseX509ValidityDeprecated(const TStringBuf input) { case 15: return ParseUnsafe<TX509Validity4yDateTimeParserDeprecated, TInstant>(input.data(), 15); default: - ythrow TDateTimeParseException(); + ythrow TDateTimeParseException(); } } bool TInstant::TryParseIso8601Deprecated(const TStringBuf input, TInstant& instant) { const auto parsed = ParseUnsafe<TIso8601DateTimeParserDeprecated, TInstant, false>(input.data(), input.size()); - if (TInstant::Max() == parsed) { - return false; - } - instant = parsed; - return true; -} + if (TInstant::Max() == parsed) { + return false; + } + instant = parsed; + return true; +} bool TInstant::TryParseRfc822Deprecated(const TStringBuf input, TInstant& instant) { const auto parsed = ParseUnsafe<TRfc822DateTimeParserDeprecated, TInstant, false>(input.data(), input.size()); - if (TInstant::Max() == parsed) { - return false; - } - instant = parsed; - return true; -} - + if (TInstant::Max() == parsed) { + return false; + } + instant = parsed; + return true; +} + bool TInstant::TryParseHttpDeprecated(const TStringBuf input, TInstant& instant) { const auto parsed = ParseUnsafe<THttpDateTimeParserDeprecated, TInstant, false>(input.data(), input.size()); - if (TInstant::Max() == parsed) { - return false; - } - instant = parsed; - return true; -} - + if (TInstant::Max() == parsed) { + return false; + } + instant = parsed; + return true; +} + bool TInstant::TryParseX509Deprecated(const TStringBuf input, TInstant& instant) { - TInstant parsed; + TInstant parsed; switch (input.size()) { - case 13: + case 13: parsed = ParseUnsafe<TX509ValidityDateTimeParserDeprecated, TInstant, false>(input.data(), 13); - break; - case 15: + break; + case 15: parsed = ParseUnsafe<TX509Validity4yDateTimeParserDeprecated, TInstant, false>(input.data(), 15); - break; - default: - return false; - } - if (TInstant::Max() == parsed) { - return false; - } - instant = parsed; - return true; -} - + break; + default: + return false; + } + if (TInstant::Max() == parsed) { + return false; + } + instant = parsed; + return true; +} + TInstant TInstant::ParseIso8601(const TStringBuf input) { return ParseUnsafe<TIso8601DateTimeParser, TInstant>(input.data(), input.size()); } @@ -761,7 +761,7 @@ TDurationParser::TDurationParser() , FractionPart(0) , FractionDigits(0) { - Y_UNUSED(TDurationParser_en_main); + Y_UNUSED(TDurationParser_en_main); %% write init; } @@ -788,7 +788,7 @@ TDuration TDurationParser::GetResult(TDuration defaultValue) const { return TDuration::MicroSeconds(us); } -bool TDuration::TryParse(const TStringBuf input, TDuration& result) { +bool TDuration::TryParse(const TStringBuf input, TDuration& result) { TDuration r = ::Parse<TDurationParser, TDuration>(input.data(), input.size(), TDuration::Max()); if (r == TDuration::Max()) return false; @@ -796,6 +796,6 @@ bool TDuration::TryParse(const TStringBuf input, TDuration& result) { return true; } -TDuration TDuration::Parse(const TStringBuf input) { +TDuration TDuration::Parse(const TStringBuf input) { return ParseUnsafe<TDurationParser, TDuration>(input.data(), input.size()); } diff --git a/util/datetime/parser_ut.cpp b/util/datetime/parser_ut.cpp index 61364af997f..44834bd0ef7 100644 --- a/util/datetime/parser_ut.cpp +++ b/util/datetime/parser_ut.cpp @@ -5,8 +5,8 @@ static const time_t SECONDS_PER_HOUR = 3600; static const time_t SECONDS_PER_MINUTE = 60; -Y_UNIT_TEST_SUITE(TDateTimeParseTest) { - Y_UNIT_TEST(TestRfc822Correct) { +Y_UNIT_TEST_SUITE(TDateTimeParseTest) { + Y_UNIT_TEST(TestRfc822Correct) { bool r = false; time_t t = 0; @@ -159,14 +159,14 @@ Y_UNIT_TEST_SUITE(TDateTimeParseTest) { } } - Y_UNIT_TEST(TestRfc822MilitaryZones) { + Y_UNIT_TEST(TestRfc822MilitaryZones) { DoTestMilitaryZones('A', 'I'); DoTestMilitaryZones('K', 'Z'); DoTestMilitaryZones('a', 'i'); DoTestMilitaryZones('k', 'z'); } - Y_UNIT_TEST(TestRfc822IncorrectDates) { + Y_UNIT_TEST(TestRfc822IncorrectDates) { bool r = true; time_t t = 0; @@ -255,7 +255,7 @@ Y_UNIT_TEST_SUITE(TDateTimeParseTest) { UNIT_ASSERT(!r); } - Y_UNIT_TEST(TestRfc822Partial) { + Y_UNIT_TEST(TestRfc822Partial) { TRfc822DateTimeParser p; const char* part1 = "Fri, 4 Mar 05 1"; const char* part2 = "9:34:45 +0300"; @@ -268,7 +268,7 @@ Y_UNIT_TEST_SUITE(TDateTimeParseTest) { UNIT_ASSERT_VALUES_EQUAL(TInstant::Seconds(1109954086), p.GetResult(TInstant::Zero())); } - Y_UNIT_TEST(TestIso8601Partial) { + Y_UNIT_TEST(TestIso8601Partial) { TIso8601DateTimeParser p; const char* part1 = "1990-03-15T15:1"; const char* part2 = "6:17+0732"; @@ -281,7 +281,7 @@ Y_UNIT_TEST_SUITE(TDateTimeParseTest) { UNIT_ASSERT_VALUES_EQUAL(TInstant::Seconds(637487058), p.GetResult(TInstant::Zero())); } - Y_UNIT_TEST(TestIso8601Correct) { + Y_UNIT_TEST(TestIso8601Correct) { bool ret; time_t t; @@ -361,7 +361,7 @@ Y_UNIT_TEST_SUITE(TDateTimeParseTest) { UNIT_ASSERT_VALUES_EQUAL(t, 1269775620); } - Y_UNIT_TEST(TestIso8601TimeZone) { + Y_UNIT_TEST(TestIso8601TimeZone) { time_t t1, t2, t3, t4; UNIT_ASSERT(ParseISO8601DateTime("2010-03-28T04:27:00.000+07:00", t1)); UNIT_ASSERT(ParseISO8601DateTime("2010-03-27T21:27:00.000Z", t2)); @@ -372,7 +372,7 @@ Y_UNIT_TEST_SUITE(TDateTimeParseTest) { UNIT_ASSERT_VALUES_EQUAL(t3, t4); } - Y_UNIT_TEST(TestIso8601Incorrect) { + Y_UNIT_TEST(TestIso8601Incorrect) { bool ret; time_t t; @@ -406,7 +406,7 @@ Y_UNIT_TEST_SUITE(TDateTimeParseTest) { UNIT_ASSERT(!ret); } - Y_UNIT_TEST(TestIso8601Fractions) { + Y_UNIT_TEST(TestIso8601Fractions) { UNIT_ASSERT_VALUES_EQUAL( TInstant::ParseIso8601("2009-09-19 03:37:08.1+04:00"), TInstant::Seconds(1253317028) + TDuration::MilliSeconds(100)); @@ -471,7 +471,7 @@ Y_UNIT_TEST_SUITE(TDateTimeParseTest) { } } - Y_UNIT_TEST(TestHttpDate) { + Y_UNIT_TEST(TestHttpDate) { UNIT_ASSERT_VALUES_EQUAL( TInstant::ParseHttp("Sun, 06 Nov 1994 08:49:37 GMT"), TInstant::ParseIso8601("1994-11-06T08:49:37Z")); @@ -486,14 +486,14 @@ Y_UNIT_TEST_SUITE(TDateTimeParseTest) { TInstant::ParseIso8601("2037-01-19T08:49:37Z")); } - Y_UNIT_TEST(TestHttpDateIncorrect) { + Y_UNIT_TEST(TestHttpDateIncorrect) { bool ret; time_t t = 0; ret = ParseHTTPDateTime("1990-03-15T15:16:17Z", t); UNIT_ASSERT(!ret); } - Y_UNIT_TEST(TestX509ValidityTime) { + Y_UNIT_TEST(TestX509ValidityTime) { UNIT_ASSERT_VALUES_EQUAL( TInstant::ParseX509Validity("20091014165533Z"), TInstant::ParseRfc822("Wed, 14 Oct 2009 16:55:33 GMT")); @@ -505,7 +505,7 @@ Y_UNIT_TEST_SUITE(TDateTimeParseTest) { TInstant::ParseRfc822("31 Dec 2019 23:59:59 GMT")); } - Y_UNIT_TEST(TestX509ValidityTimeIncorrect) { + Y_UNIT_TEST(TestX509ValidityTimeIncorrect) { bool ret; time_t t = 0; ret = ParseX509ValidityDateTime("500101000000Z", t); @@ -513,65 +513,65 @@ Y_UNIT_TEST_SUITE(TDateTimeParseTest) { ret = ParseX509ValidityDateTime("091014165533+0300", t); UNIT_ASSERT(!ret); } - - Y_UNIT_TEST(TestTInstantTryParse) { - { + + Y_UNIT_TEST(TestTInstantTryParse) { + { const TStringBuf s = "2009-09-19 03:37:08.1+04:00"; const auto i = TInstant::ParseIso8601(s); - TInstant iTry; + TInstant iTry; UNIT_ASSERT(TInstant::TryParseIso8601(s, iTry)); - UNIT_ASSERT_VALUES_EQUAL(i, iTry); - } - { + UNIT_ASSERT_VALUES_EQUAL(i, iTry); + } + { const TStringBuf s = "2009-09aslkdjfkljasdjfl4:00"; - TInstant iTry; + TInstant iTry; UNIT_ASSERT_EXCEPTION(TInstant::ParseIso8601(s), TDateTimeParseException); UNIT_ASSERT(!TInstant::TryParseIso8601(s, iTry)); - } - { + } + { const TStringBuf s = "Wed, 14 Oct 2009 16:55:33 GMT"; const auto i = TInstant::ParseRfc822(s); - TInstant iTry; + TInstant iTry; UNIT_ASSERT(TInstant::TryParseRfc822(s, iTry)); - UNIT_ASSERT_VALUES_EQUAL(i, iTry); - } - { + UNIT_ASSERT_VALUES_EQUAL(i, iTry); + } + { const TStringBuf s = "Wed, alsdjflkasjdfl:55:33 GMT"; - TInstant iTry; + TInstant iTry; UNIT_ASSERT_EXCEPTION(TInstant::ParseRfc822(s), TDateTimeParseException); UNIT_ASSERT(!TInstant::TryParseRfc822(s, iTry)); - } - { + } + { const TStringBuf s = "20091014165533Z"; const auto i = TInstant::ParseX509Validity(s); - TInstant iTry; + TInstant iTry; UNIT_ASSERT(TInstant::TryParseX509(s, iTry)); - UNIT_ASSERT_VALUES_EQUAL(i, iTry); - } - { + UNIT_ASSERT_VALUES_EQUAL(i, iTry); + } + { const TStringBuf s = "200asdfasdf533Z"; - TInstant iTry; + TInstant iTry; UNIT_ASSERT_EXCEPTION(TInstant::ParseX509Validity(s), TDateTimeParseException); UNIT_ASSERT(!TInstant::TryParseX509(s, iTry)); - } - { + } + { const TStringBuf s = "990104074212Z"; const auto i = TInstant::ParseX509Validity(s); - TInstant iTry; + TInstant iTry; UNIT_ASSERT(TInstant::TryParseX509(s, iTry)); - UNIT_ASSERT_VALUES_EQUAL(i, iTry); - } - { + UNIT_ASSERT_VALUES_EQUAL(i, iTry); + } + { const TStringBuf s = "9901asdf4212Z"; - TInstant iTry; + TInstant iTry; UNIT_ASSERT_EXCEPTION(TInstant::ParseX509Validity(s), TDateTimeParseException); UNIT_ASSERT(!TInstant::TryParseX509(s, iTry)); - } - } + } + } } -Y_UNIT_TEST_SUITE(TDurationParseTest) { - Y_UNIT_TEST(TestParse) { +Y_UNIT_TEST_SUITE(TDurationParseTest) { + Y_UNIT_TEST(TestParse) { UNIT_ASSERT_VALUES_EQUAL(TDuration::Seconds(60 * 60 * 24 * 7), TDuration::Parse("1w")); UNIT_ASSERT_VALUES_EQUAL(TDuration::Seconds(60), TDuration::Parse("1m")); UNIT_ASSERT_VALUES_EQUAL(TDuration::Seconds(90), TDuration::Parse("1.5m")); diff --git a/util/digest/city.cpp b/util/digest/city.cpp index c25f175d544..7596cd96a0e 100644 --- a/util/digest/city.cpp +++ b/util/digest/city.cpp @@ -201,7 +201,7 @@ uint64 CityHash64WithSeed(const char* s, size_t len, uint64 seed) noexcept { } uint64 CityHash64WithSeeds(const char* s, size_t len, - uint64 seed0, uint64 seed1) noexcept { + uint64 seed0, uint64 seed1) noexcept { return HashLen16(CityHash64(s, len) - seed0, seed1); } @@ -310,7 +310,7 @@ uint128 CityHash128(const char* s, size_t len) noexcept { } } -// TODO(yazevnul): move this function to unittests +// TODO(yazevnul): move this function to unittests void TestCompilationOfCityHashTemplates() { TStringBuf s; CityHash64(s); diff --git a/util/digest/city.h b/util/digest/city.h index 675a798074f..2d8cd8ead1e 100644 --- a/util/digest/city.h +++ b/util/digest/city.h @@ -5,16 +5,16 @@ #include <utility> -// NOTE: These functions provide CityHash 1.0 implementation whose results are *different* from -// the mainline version of CityHash. - +// NOTE: These functions provide CityHash 1.0 implementation whose results are *different* from +// the mainline version of CityHash. + using uint128 = std::pair<ui64, ui64>; -constexpr ui64 Uint128Low64(const uint128& x) { +constexpr ui64 Uint128Low64(const uint128& x) { return x.first; } -constexpr ui64 Uint128High64(const uint128& x) { +constexpr ui64 Uint128High64(const uint128& x) { return x.second; } @@ -33,7 +33,7 @@ Y_PURE_FUNCTION uint128 CityHash128WithSeed(const char* s, size_t len, uint128 s // Hash 128 input bits down to 64 bits of output. // This is intended to be a reasonably good hash function. -inline ui64 Hash128to64(const uint128& x) { +inline ui64 Hash128to64(const uint128& x) { // Murmur-inspired hashing. const ui64 kMul = 0x9ddfea08eb382d69ULL; ui64 a = (Uint128Low64(x) ^ Uint128High64(x)) * kMul; @@ -44,40 +44,40 @@ inline ui64 Hash128to64(const uint128& x) { return b; } -namespace NPrivateCityHash { - template <class TStringType> - inline TStringBuf GetBufFromStr(const TStringType& str) { - static_assert(std::is_integral<std::remove_reference_t<decltype(*str.data())>>::value, "invalid type passed to hash function"); - return TStringBuf(reinterpret_cast<const char*>(str.data()), (str.size()) * sizeof(*str.data())); - } +namespace NPrivateCityHash { + template <class TStringType> + inline TStringBuf GetBufFromStr(const TStringType& str) { + static_assert(std::is_integral<std::remove_reference_t<decltype(*str.data())>>::value, "invalid type passed to hash function"); + return TStringBuf(reinterpret_cast<const char*>(str.data()), (str.size()) * sizeof(*str.data())); + } } template <class TStringType> inline ui64 CityHash64(const TStringType& str) { - TStringBuf buf = NPrivateCityHash::GetBufFromStr(str); - return CityHash64(buf.data(), buf.size()); + TStringBuf buf = NPrivateCityHash::GetBufFromStr(str); + return CityHash64(buf.data(), buf.size()); } template <class TStringType> inline ui64 CityHash64WithSeeds(const TStringType& str, ui64 seed0, ui64 seed1) { - TStringBuf buf = NPrivateCityHash::GetBufFromStr(str); - return CityHash64WithSeeds(buf.data(), buf.size(), seed0, seed1); + TStringBuf buf = NPrivateCityHash::GetBufFromStr(str); + return CityHash64WithSeeds(buf.data(), buf.size(), seed0, seed1); } template <class TStringType> inline ui64 CityHash64WithSeed(const TStringType& str, ui64 seed) { - TStringBuf buf = NPrivateCityHash::GetBufFromStr(str); - return CityHash64WithSeed(buf.data(), buf.size(), seed); + TStringBuf buf = NPrivateCityHash::GetBufFromStr(str); + return CityHash64WithSeed(buf.data(), buf.size(), seed); } template <class TStringType> inline uint128 CityHash128(const TStringType& str) { - TStringBuf buf = NPrivateCityHash::GetBufFromStr(str); - return CityHash128(buf.data(), buf.size()); + TStringBuf buf = NPrivateCityHash::GetBufFromStr(str); + return CityHash128(buf.data(), buf.size()); } template <class TStringType> inline uint128 CityHash128WithSeed(const TStringType& str, uint128 seed) { - TStringBuf buf = NPrivateCityHash::GetBufFromStr(str); - return CityHash128WithSeed(buf.data(), buf.size(), seed); + TStringBuf buf = NPrivateCityHash::GetBufFromStr(str); + return CityHash128WithSeed(buf.data(), buf.size(), seed); } diff --git a/util/digest/fnv.h b/util/digest/fnv.h index 87b41a3de7e..957ba9b9f10 100644 --- a/util/digest/fnv.h +++ b/util/digest/fnv.h @@ -9,7 +9,7 @@ namespace NFnvPrivate { template <class It> - constexpr ui32 FnvHash32(It b, It e, ui32 init) { + constexpr ui32 FnvHash32(It b, It e, ui32 init) { while (b != e) { init = (init * FNV32PRIME) ^ (unsigned char)*b++; } @@ -18,7 +18,7 @@ namespace NFnvPrivate { } template <class It> - constexpr ui64 FnvHash64(It b, It e, ui64 init) { + constexpr ui64 FnvHash64(It b, It e, ui64 init) { while (b != e) { init = (init * FNV64PRIME) ^ (unsigned char)*b++; } @@ -34,7 +34,7 @@ namespace NFnvPrivate { struct TFnvHelper<t> { \ static const ui##t Init = FNV##t##INIT; \ template <class It> \ - static constexpr ui##t FnvHash(It b, It e, ui##t init) { \ + static constexpr ui##t FnvHash(It b, It e, ui##t init) { \ return FnvHash##t(b, e, init); \ } \ }; @@ -46,28 +46,28 @@ namespace NFnvPrivate { } template <class T, class It> -static constexpr T FnvHash(It b, It e, T init) { +static constexpr T FnvHash(It b, It e, T init) { static_assert(sizeof(*b) == 1, "expect sizeof(*b) == 1"); return (T)NFnvPrivate::TFnvHelper<8 * sizeof(T)>::FnvHash(b, e, init); } template <class T, class It> -static constexpr T FnvHash(It b, It e) { +static constexpr T FnvHash(It b, It e) { return FnvHash<T>(b, e, (T)NFnvPrivate::TFnvHelper<8 * sizeof(T)>::Init); } template <class T> -static constexpr T FnvHash(const void* buf, size_t len, T init) { +static constexpr T FnvHash(const void* buf, size_t len, T init) { return FnvHash<T>((const unsigned char*)buf, (const unsigned char*)buf + len, init); } template <class T> -static constexpr T FnvHash(const void* buf, size_t len) { +static constexpr T FnvHash(const void* buf, size_t len) { return FnvHash<T>((const unsigned char*)buf, (const unsigned char*)buf + len); } template <class T, class Buf> -static constexpr T FnvHash(const Buf& buf) { +static constexpr T FnvHash(const Buf& buf) { return FnvHash<T>(buf.data(), buf.size() * sizeof(*buf.data())); } diff --git a/util/digest/multi.h b/util/digest/multi.h index 8e4597c9dcf..92de71e7837 100644 --- a/util/digest/multi.h +++ b/util/digest/multi.h @@ -5,7 +5,7 @@ #include "numeric.h" template <typename TOne> -constexpr size_t MultiHash(const TOne& one) noexcept { +constexpr size_t MultiHash(const TOne& one) noexcept { return THash<TOne>()(one); } template <typename THead, typename... TTail> diff --git a/util/digest/multi_ut.cpp b/util/digest/multi_ut.cpp index dff64ff0cc1..71c188c39a7 100644 --- a/util/digest/multi_ut.cpp +++ b/util/digest/multi_ut.cpp @@ -2,7 +2,7 @@ #include <library/cpp/testing/unittest/registar.h> -#include <util/stream/output.h> +#include <util/stream/output.h> class TMultiHashTest: public TTestBase { UNIT_TEST_SUITE(TMultiHashTest); diff --git a/util/digest/murmur.cpp b/util/digest/murmur.cpp index b041d3e5f23..8fe21d3a046 100644 --- a/util/digest/murmur.cpp +++ b/util/digest/murmur.cpp @@ -1,7 +1,7 @@ #include "murmur.h" -#include <util/system/unaligned_mem.h> - +#include <util/system/unaligned_mem.h> + namespace NMurmurPrivate { //----------------------------------------------------------------------------- // MurmurHash2, by Austin Appleby diff --git a/util/digest/murmur_ut.cpp b/util/digest/murmur_ut.cpp index 29287668bc4..ecb10a9dac4 100644 --- a/util/digest/murmur_ut.cpp +++ b/util/digest/murmur_ut.cpp @@ -76,7 +76,7 @@ private: } template <class E, class T> - inline void TestWrapper(const TArrayRef<E>& array, T expected) { + inline void TestWrapper(const TArrayRef<E>& array, T expected) { auto val = TMurmurHash<T>()(array); UNIT_ASSERT_EQUAL(val, expected); } diff --git a/util/digest/numeric.h b/util/digest/numeric.h index e20bd908e4c..59b60d1c2e0 100644 --- a/util/digest/numeric.h +++ b/util/digest/numeric.h @@ -8,7 +8,7 @@ * copy: https://gist.github.com/badboy/6267743 */ -static constexpr ui8 IntHashImpl(ui8 key8) noexcept { +static constexpr ui8 IntHashImpl(ui8 key8) noexcept { size_t key = key8; key += ~(key << 15); @@ -21,7 +21,7 @@ static constexpr ui8 IntHashImpl(ui8 key8) noexcept { return static_cast<ui8>(key); } -static constexpr ui16 IntHashImpl(ui16 key16) noexcept { +static constexpr ui16 IntHashImpl(ui16 key16) noexcept { size_t key = key16; key += ~(key << 15); @@ -34,7 +34,7 @@ static constexpr ui16 IntHashImpl(ui16 key16) noexcept { return static_cast<ui16>(key); } -static constexpr ui32 IntHashImpl(ui32 key) noexcept { +static constexpr ui32 IntHashImpl(ui32 key) noexcept { key += ~(key << 15); key ^= (key >> 10); key += (key << 3); @@ -45,7 +45,7 @@ static constexpr ui32 IntHashImpl(ui32 key) noexcept { return key; } -static constexpr ui64 IntHashImpl(ui64 key) noexcept { +static constexpr ui64 IntHashImpl(ui64 key) noexcept { key += ~(key << 32); key ^= (key >> 22); key += ~(key << 13); @@ -59,8 +59,8 @@ static constexpr ui64 IntHashImpl(ui64 key) noexcept { } template <class T> -static constexpr T IntHash(T t) noexcept { - using TCvt = TFixedWidthUnsignedInt<T>; +static constexpr T IntHash(T t) noexcept { + using TCvt = TFixedWidthUnsignedInt<T>; return IntHashImpl((TCvt)(t)); } @@ -69,8 +69,8 @@ static constexpr T IntHash(T t) noexcept { * can handle floats && pointers */ template <class T> -static constexpr size_t NumericHash(T t) noexcept { - using TCvt = TFixedWidthUnsignedInt<T>; +static constexpr size_t NumericHash(T t) noexcept { + using TCvt = TFixedWidthUnsignedInt<T>; union Y_HIDDEN { T t; @@ -81,6 +81,6 @@ static constexpr size_t NumericHash(T t) noexcept { } template <class T> -static constexpr T CombineHashes(T l, T r) noexcept { +static constexpr T CombineHashes(T l, T r) noexcept { return IntHash(l) ^ r; } diff --git a/util/digest/sequence.h b/util/digest/sequence.h index 712331007b8..3329ac70c30 100644 --- a/util/digest/sequence.h +++ b/util/digest/sequence.h @@ -42,7 +42,7 @@ public: } template <typename ElementType> - auto operator()(const TArrayRef<ElementType>& data) const { + auto operator()(const TArrayRef<ElementType>& data) const { return TBase<ElementType>()(data); } }; diff --git a/util/digest/sequence_ut.cpp b/util/digest/sequence_ut.cpp index 87d6102ee59..369339f7301 100644 --- a/util/digest/sequence_ut.cpp +++ b/util/digest/sequence_ut.cpp @@ -54,7 +54,7 @@ private: int arr[] = {1, 2, 3}; const size_t canonicalHash = static_cast<size_t>(ULL(3903918011533391876)); TContiguousHash<TSimpleRangeHash> hasher; - UNIT_ASSERT_EQUAL(canonicalHash, hasher(TArrayRef<int>(arr, arr + 3))); + UNIT_ASSERT_EQUAL(canonicalHash, hasher(TArrayRef<int>(arr, arr + 3))); } }; diff --git a/util/draft/date.h b/util/draft/date.h index e3eb616fe5d..13d86032b7a 100644 --- a/util/draft/date.h +++ b/util/draft/date.h @@ -1,7 +1,7 @@ #pragma once -#include <util/stream/output.h> -#include <util/stream/input.h> +#include <util/stream/output.h> +#include <util/stream/input.h> #include <util/generic/string.h> #include <util/datetime/constants.h> @@ -83,8 +83,8 @@ public: friend bool operator==(const TDate& left, const TDate& right); friend int operator-(const TDate& left, const TDate& right); - friend IInputStream& operator>>(IInputStream& left, TDate& right); - friend IOutputStream& operator<<(IOutputStream& left, const TDate& right); + friend IInputStream& operator>>(IInputStream& left, TDate& right); + friend IOutputStream& operator<<(IOutputStream& left, const TDate& right); }; Y_DECLARE_PODTYPE(TDate); @@ -116,7 +116,7 @@ inline int operator-(const TDate& left, const TDate& right) { return static_cast<int>((left.Timestamp + SECONDS_IN_DAY / 2 - right.Timestamp) / SECONDS_IN_DAY); } -inline IInputStream& operator>>(IInputStream& left, TDate& right) { +inline IInputStream& operator>>(IInputStream& left, TDate& right) { TString stroka; left >> stroka; TDate date(stroka.c_str()); @@ -124,6 +124,6 @@ inline IInputStream& operator>>(IInputStream& left, TDate& right) { return left; } -inline IOutputStream& operator<<(IOutputStream& left, const TDate& right) { +inline IOutputStream& operator<<(IOutputStream& left, const TDate& right) { return left << right.ToStroka(); } diff --git a/util/draft/date_ut.cpp b/util/draft/date_ut.cpp index 8c33a6c1cfd..0efb5c5a364 100644 --- a/util/draft/date_ut.cpp +++ b/util/draft/date_ut.cpp @@ -2,8 +2,8 @@ #include <library/cpp/testing/unittest/registar.h> -Y_UNIT_TEST_SUITE(TDateTest) { - Y_UNIT_TEST(ComponentsTest) { +Y_UNIT_TEST_SUITE(TDateTest) { + Y_UNIT_TEST(ComponentsTest) { { TDate d("20110215"); UNIT_ASSERT_EQUAL(d.GetYear(), 2011); diff --git a/util/draft/datetime.cpp b/util/draft/datetime.cpp index 5cbe7d88477..902431734d2 100644 --- a/util/draft/datetime.cpp +++ b/util/draft/datetime.cpp @@ -6,7 +6,7 @@ #include <util/system/fasttime.h> #include <util/datetime/base.h> #include <util/datetime/systime.h> -#include <util/stream/output.h> +#include <util/stream/output.h> #include <util/stream/mem.h> #include <util/string/cast.h> #include <util/string/printf.h> @@ -28,12 +28,12 @@ namespace NDatetime { // [31, ..., 365] or [31, ..., 366] (12 elements) const ui32* pos = UpperBound(begin, end, yday); - Y_ENSURE(pos != end, "day no. " << yday << " does not exist in " << (isleap ? "leap" : "non-leap") << " year"); + Y_ENSURE(pos != end, "day no. " << yday << " does not exist in " << (isleap ? "leap" : "non-leap") << " year"); *month = pos - begin; *mday = yday - *(pos - 1) + 1; - Y_ASSERT((*month < 12) && (1 <= *mday) && (*mday <= MonthDays[isleap][*month])); + Y_ASSERT((*month < 12) && (1 <= *mday) && (*mday <= MonthDays[isleap][*month])); } struct TTimeData { @@ -215,7 +215,7 @@ namespace NDatetime { } template <> -void In<TMonth>(IInputStream& in, TMonth& t) { +void In<TMonth>(IInputStream& in, TMonth& t) { char buf[4]; LoadPodArray(&in, buf, 4); t.Year = FromString<ui16>(buf, 4); @@ -224,7 +224,7 @@ void In<TMonth>(IInputStream& in, TMonth& t) { } template <> -void Out<TMonth>(IOutputStream& o, const TMonth& t) { +void Out<TMonth>(IOutputStream& o, const TMonth& t) { o << t.Year << Sprintf("%.2hu", (ui16)(t.Month + 1)); } diff --git a/util/draft/datetime_ut.cpp b/util/draft/datetime_ut.cpp index a5e065ef6e8..b64fdaa36a1 100644 --- a/util/draft/datetime_ut.cpp +++ b/util/draft/datetime_ut.cpp @@ -4,7 +4,7 @@ #include <util/string/builder.h> -Y_UNIT_TEST_SUITE(TSimpleTMTest) { +Y_UNIT_TEST_SUITE(TSimpleTMTest) { TString PrintMarker(const TString& test, int line) { return TStringBuilder() << "test " << test << " at line " << line; } @@ -52,7 +52,7 @@ Y_UNIT_TEST_SUITE(TSimpleTMTest) { UNIT_ASSERT_VALUES_EQUAL_C((int)tms.Sec, sec, marker); } - Y_UNIT_TEST(TestLeap) { + Y_UNIT_TEST(TestLeap) { using namespace NDatetime; UNIT_ASSERT(LeapYearAD(2000)); UNIT_ASSERT(LeapYearAD(2012)); @@ -61,7 +61,7 @@ Y_UNIT_TEST_SUITE(TSimpleTMTest) { UNIT_ASSERT(!LeapYearAD(1900)); } - Y_UNIT_TEST(TestYDayConversion) { + Y_UNIT_TEST(TestYDayConversion) { using namespace NDatetime; ui32 month; ui32 mday; @@ -79,7 +79,7 @@ Y_UNIT_TEST_SUITE(TSimpleTMTest) { UNIT_ASSERT_EXCEPTION(YDayToMonthAndDay(366, true, &month, &mday), yexception); } - Y_UNIT_TEST(SimpleTMTest) { + Y_UNIT_TEST(SimpleTMTest) { using namespace NDatetime; tzset(); diff --git a/util/draft/enum.h b/util/draft/enum.h index 18002b7df20..cdee12564bb 100644 --- a/util/draft/enum.h +++ b/util/draft/enum.h @@ -11,13 +11,13 @@ class TEnumNotFoundException: public yexception { }; -#define EnumFromString(key, entries) EnumFromStringImpl(key, entries, Y_ARRAY_SIZE(entries)) +#define EnumFromString(key, entries) EnumFromStringImpl(key, entries, Y_ARRAY_SIZE(entries)) #define EnumFromStringWithSize(key, entries, size) EnumFromStringImpl(key, entries, size) -#define FindEnumFromString(key, entries) FindEnumFromStringImpl(key, entries, Y_ARRAY_SIZE(entries)) +#define FindEnumFromString(key, entries) FindEnumFromStringImpl(key, entries, Y_ARRAY_SIZE(entries)) #define FindEnumFromStringWithSize(key, entries, size) FindEnumFromStringImpl(key, entries, size) -#define EnumToString(key, entries) EnumToStringImpl(key, entries, Y_ARRAY_SIZE(entries)) +#define EnumToString(key, entries) EnumToStringImpl(key, entries, Y_ARRAY_SIZE(entries)) #define EnumToStringWithSize(key, entries, size) EnumToStringImpl(key, entries, size) -#define PrintEnumItems(entries) PrintEnumItemsImpl(entries, Y_ARRAY_SIZE(entries)) +#define PrintEnumItems(entries) PrintEnumItemsImpl(entries, Y_ARRAY_SIZE(entries)) template <class K1, class K2, class V> const V* FindEnumFromStringImpl(K1 key, const std::pair<K2, V>* entries, size_t arraySize) { diff --git a/util/draft/holder_vector.h b/util/draft/holder_vector.h index 1c62055bd95..022f83cff21 100644 --- a/util/draft/holder_vector.h +++ b/util/draft/holder_vector.h @@ -52,7 +52,7 @@ public: void Reset(size_t i, THolder<T> t) { T* current = (*this)[i]; if (current) { - Y_ASSERT(current != t.Get()); + Y_ASSERT(current != t.Get()); D::Destroy(current); } (*this)[i] = t.Release(); diff --git a/util/draft/holder_vector_ut.cpp b/util/draft/holder_vector_ut.cpp index f64393860af..babcfe8ea03 100644 --- a/util/draft/holder_vector_ut.cpp +++ b/util/draft/holder_vector_ut.cpp @@ -2,14 +2,14 @@ #include <library/cpp/testing/unittest/registar.h> -Y_UNIT_TEST_SUITE(THolderVectorTest) { - Y_UNIT_TEST(TestCreateEmpty) { +Y_UNIT_TEST_SUITE(THolderVectorTest) { + Y_UNIT_TEST(TestCreateEmpty) { THolderVector<int> ints; UNIT_ASSERT_EQUAL(ints.Size(), 0); UNIT_ASSERT(!ints); } - Y_UNIT_TEST(TestCreateNonEmpty) { + Y_UNIT_TEST(TestCreateNonEmpty) { THolderVector<int> ints(5); UNIT_ASSERT_EQUAL(ints.Size(), 5); UNIT_ASSERT(ints); @@ -19,7 +19,7 @@ Y_UNIT_TEST_SUITE(THolderVectorTest) { } } - Y_UNIT_TEST(TestResetValue) { + Y_UNIT_TEST(TestResetValue) { THolderVector<int> ints; ints.PushBack(new int(0)); ints.PushBack(new int(1)); @@ -31,7 +31,7 @@ Y_UNIT_TEST_SUITE(THolderVectorTest) { UNIT_ASSERT_VALUES_EQUAL(*ints[1], 3); } - Y_UNIT_TEST(TestResetNoValue) { + Y_UNIT_TEST(TestResetNoValue) { THolderVector<int> ints; ints.Resize(1); UNIT_ASSERT_EQUAL(ints[0], (int*)nullptr); @@ -40,7 +40,7 @@ Y_UNIT_TEST_SUITE(THolderVectorTest) { UNIT_ASSERT_VALUES_EQUAL(*ints[0], 1); } - Y_UNIT_TEST(TestResetSmartPtr) { + Y_UNIT_TEST(TestResetSmartPtr) { THolderVector<int> ints; ints.Resize(2); @@ -50,7 +50,7 @@ Y_UNIT_TEST_SUITE(THolderVectorTest) { UNIT_ASSERT(!holder); } - Y_UNIT_TEST(TestSwap) { + Y_UNIT_TEST(TestSwap) { THolderVector<int> v1; v1.PushBack(new int(1)); @@ -59,7 +59,7 @@ Y_UNIT_TEST_SUITE(THolderVectorTest) { UNIT_ASSERT(v1.empty() && v2.size() == 1 && *v2.front() == 1); } - Y_UNIT_TEST(TestUniquePtr) { + Y_UNIT_TEST(TestUniquePtr) { THolderVector<TString> v; std::unique_ptr<TString> str(new TString("hello")); v.PushBack(std::move(str)); diff --git a/util/draft/ip.h b/util/draft/ip.h index eb947cd2cd5..97ddba39d58 100644 --- a/util/draft/ip.h +++ b/util/draft/ip.h @@ -87,7 +87,7 @@ static inline TString Ip6ToString(const TIp6& ip) { } template <> -inline void Out<TIp6>(IOutputStream& os, const TIp6& a) { +inline void Out<TIp6>(IOutputStream& os, const TIp6& a) { os << Ip6ToString(a); } diff --git a/util/draft/matrix.h b/util/draft/matrix.h index 154d00b35ea..5b366d32b9a 100644 --- a/util/draft/matrix.h +++ b/util/draft/matrix.h @@ -47,7 +47,7 @@ public: } void ReDim(size_t m, size_t n) { - Y_ASSERT(m >= 1 && n >= 1); + Y_ASSERT(m >= 1 && n >= 1); size_t newSize = m * n; if (newSize > BufSize) { T* newBuf = new T[newSize]; @@ -69,25 +69,25 @@ public: // Access element matrix[i][j] T* operator[](size_t i) { - Y_ASSERT(i >= 0 && i < M); + Y_ASSERT(i >= 0 && i < M); return Arr + i * N; } // Access element matrix[i][j] const T* operator[](size_t i) const { - Y_ASSERT(i >= 0 && i < M); + Y_ASSERT(i >= 0 && i < M); return Arr + i * N; } // Access element matrix(i, j) T& operator()(size_t i, size_t j) { - Y_ASSERT(i >= 0 && i < M && j >= 0 && j < N); + Y_ASSERT(i >= 0 && i < M && j >= 0 && j < N); return Arr[i * N + j]; } // Access element matrix(i, j) const T& operator()(size_t i, size_t j) const { - Y_ASSERT(i >= 0 && i < M && j >= 0 && j < N); + Y_ASSERT(i >= 0 && i < M && j >= 0 && j < N); return Arr[i * N + j]; } diff --git a/util/draft/memory_ut.cpp b/util/draft/memory_ut.cpp index 76bee30549f..ef416705d55 100644 --- a/util/draft/memory_ut.cpp +++ b/util/draft/memory_ut.cpp @@ -23,8 +23,8 @@ struct Y_PACKED TSampleStruct3 { #pragma pack() -Y_UNIT_TEST_SUITE(TUtilDraftMemoryTest) { - Y_UNIT_TEST(IsZeroTest) { +Y_UNIT_TEST_SUITE(TUtilDraftMemoryTest) { + Y_UNIT_TEST(IsZeroTest) { ui8 a1 = 0; UNIT_ASSERT(IsZero(a1)); a1 = 0xF0; diff --git a/util/folder/dirent_win.c b/util/folder/dirent_win.c index 7e6db74ce53..3eef8c9762a 100644 --- a/util/folder/dirent_win.c +++ b/util/folder/dirent_win.c @@ -39,7 +39,7 @@ struct DIR* opendir(const char* dirname) { closedir(dir); return NULL; } - dir->fff_templ = (WCHAR*)malloc((len_converted + 5) * sizeof(WCHAR)); + dir->fff_templ = (WCHAR*)malloc((len_converted + 5) * sizeof(WCHAR)); if (!dir->fff_templ) { closedir(dir); return NULL; diff --git a/util/folder/dirut.cpp b/util/folder/dirut.cpp index ffc9b09f967..ebb1854c28a 100644 --- a/util/folder/dirut.cpp +++ b/util/folder/dirut.cpp @@ -5,8 +5,8 @@ #include "pathsplit.h" #include "path.h" -#include <util/generic/yexception.h> -#include <util/system/compiler.h> +#include <util/generic/yexception.h> +#include <util/system/compiler.h> #include <util/system/fs.h> #include <util/system/maxlen.h> #include <util/system/yassert.h> @@ -30,13 +30,13 @@ bool correctpath(TString& folder) { } bool resolvepath(TString& folder, const TString& home) { - Y_ASSERT(home && home.at(0) == '/'); + Y_ASSERT(home && home.at(0) == '/'); if (!folder) { return false; } // may be from windows char* ptr = folder.begin(); - while ((ptr = strchr(ptr, '\\')) != nullptr) + while ((ptr = strchr(ptr, '\\')) != nullptr) *ptr = '/'; if (folder.at(0) == '~') { @@ -383,14 +383,14 @@ void RemoveDirWithContents(TString dirName) { for (auto it = dir.begin(); it != dir.end(); ++it) { switch (it->fts_info) { - case FTS_F: - case FTS_DEFAULT: - case FTS_DP: - case FTS_SL: - case FTS_SLNONE: - if (!NFs::Remove(it->fts_path)) - ythrow TSystemError() << "error while removing " << it->fts_path; - break; + case FTS_F: + case FTS_DEFAULT: + case FTS_DP: + case FTS_SL: + case FTS_SLNONE: + if (!NFs::Remove(it->fts_path)) + ythrow TSystemError() << "error while removing " << it->fts_path; + break; } } } @@ -404,7 +404,7 @@ int mkpath(char* path, int mode) { // if it does not). Use RealLocation if that behaviour is required. TString RealPath(const TString& path) { TTempBuf result; - Y_ASSERT(result.Size() > MAX_PATH); //TMP_BUF_LEN > MAX_PATH + Y_ASSERT(result.Size() > MAX_PATH); //TMP_BUF_LEN > MAX_PATH #ifdef _win_ if (GetFullPathName(path.data(), result.Size(), result.Data(), nullptr) == 0) #else @@ -437,7 +437,7 @@ int MakeTempDir(char path[/*FILENAME_MAX*/], const char* prefix) { prefix = sysTmp.data(); } - if ((ret = ResolvePath(prefix, nullptr, path, 1)) != 0) + if ((ret = ResolvePath(prefix, nullptr, path, 1)) != 0) return ret; if (!TFileStat(path).IsDir()) return ENOENT; @@ -457,7 +457,7 @@ TString GetHomeDir() { TString s(getenv("HOME")); if (!s) { #ifndef _win32_ - passwd* pw = nullptr; + passwd* pw = nullptr; s = getenv("USER"); if (s) pw = getpwnam(s.data()); @@ -468,7 +468,7 @@ TString GetHomeDir() { else #endif { - char* cur_dir = getcwd(nullptr, 0); + char* cur_dir = getcwd(nullptr, 0); s = cur_dir; free(cur_dir); } @@ -477,8 +477,8 @@ TString GetHomeDir() { } void MakeDirIfNotExist(const char* path, int mode) { - if (!NFs::MakeDirectory(path, NFs::EFilePermission(mode)) && !NFs::Exists(path)) { - ythrow TSystemError() << "failed to create directory " << path; + if (!NFs::MakeDirectory(path, NFs::EFilePermission(mode)) && !NFs::Exists(path)) { + ythrow TSystemError() << "failed to create directory " << path; } } diff --git a/util/folder/dirut.h b/util/folder/dirut.h index 2537027b12d..c2b870ae0cd 100644 --- a/util/folder/dirut.h +++ b/util/folder/dirut.h @@ -106,11 +106,11 @@ public: const char* Check(const char* fname) const { if (!fname || !*fname) - return nullptr; + return nullptr; if (Strict) { NFs::EnsureExists(fname); } else if (!NFs::Exists(fname)) - fname = nullptr; + fname = nullptr; return fname; } diff --git a/util/folder/filelist.cpp b/util/folder/filelist.cpp index b21fcdbf208..87f2c69b2da 100644 --- a/util/folder/filelist.cpp +++ b/util/folder/filelist.cpp @@ -26,7 +26,7 @@ void TFileEntitiesList::Fill(const TString& dirname, TStringBuf prefix, TStringB TStringBuf filename = file->fts_path + dirNameLength + 1; - if (filename.empty() || !filename.StartsWith(prefix) || !filename.EndsWith(suffix)) { + if (filename.empty() || !filename.StartsWith(prefix) || !filename.EndsWith(suffix)) { continue; } diff --git a/util/folder/filelist.h b/util/folder/filelist.h index 3f615fa4c2e..a0f6e86ead4 100644 --- a/util/folder/filelist.h +++ b/util/folder/filelist.h @@ -26,14 +26,14 @@ public: } void Clear() { - Cur = nullptr; + Cur = nullptr; FileNamesSize = CurName = 0; FileNames.Clear(); FileNames.Append("", 1); } const char* Next() { - return Cur = (CurName++ < FileNamesSize ? strchr(Cur, 0) + 1 : nullptr); + return Cur = (CurName++ < FileNamesSize ? strchr(Cur, 0) + 1 : nullptr); } size_t Size() { diff --git a/util/folder/filelist_ut.cpp b/util/folder/filelist_ut.cpp index 0cdcdf3d003..ec023f5094c 100644 --- a/util/folder/filelist_ut.cpp +++ b/util/folder/filelist_ut.cpp @@ -27,7 +27,7 @@ void TFileListTest::TestSimple() { fileList.Fill(tempDir().data(), "", "", 1000); TString fileName(fileList.Next()); UNIT_ASSERT_EQUAL(fileName, "subdir" LOCSLASH_S "file"); - UNIT_ASSERT_EQUAL(fileList.Next(), nullptr); + UNIT_ASSERT_EQUAL(fileList.Next(), nullptr); } void TFileListTest::TestPrefix() { diff --git a/util/folder/fts.cpp b/util/folder/fts.cpp index 0e6a6f86eb9..4ab22a94bf9 100644 --- a/util/folder/fts.cpp +++ b/util/folder/fts.cpp @@ -33,9 +33,9 @@ * $OpenBSD: fts.c,v 1.22 1999/10/03 19:22:22 millert Exp $ */ -#include <util/memory/tempbuf.h> -#include <util/system/compat.h> -#include <util/system/compiler.h> +#include <util/memory/tempbuf.h> +#include <util/system/compat.h> +#include <util/system/compiler.h> #include <util/system/defaults.h> #include <util/system/error.h> @@ -110,14 +110,14 @@ int stat64UTF(dird path, struct _stat64* _Stat) { return _wstat64(path, _Stat); } -const dird invalidDirD = nullptr; +const dird invalidDirD = nullptr; dird get_cwdd() { return _wgetcwd(nullptr, 0); } int valid_dird(dird fd) { - return fd == nullptr; + return fd == nullptr; } void close_dird(dird fd) { @@ -258,19 +258,19 @@ FTS* yfts_open(char* const* argv, int options, int (*compar)(const FTSENT**, con /* Options check. */ if (options & ~FTS_OPTIONMASK) { errno = EINVAL; - return nullptr; + return nullptr; } /* Allocate/initialize the stream */ if ((sp = (FTS*)malloc(sizeof(FTS))) == nullptr) { - return nullptr; + return nullptr; } memset(sp, 0, sizeof(FTS)); sp->fts_compar = compar; sp->fts_options = options; /* Shush, GCC. */ - tmp = nullptr; + tmp = nullptr; /* Logical walks turn on NOCHDIR; symbolic links are too hard. */ if (ISSET(FTS_LOGICAL)) { @@ -292,7 +292,7 @@ FTS* yfts_open(char* const* argv, int options, int (*compar)(const FTSENT**, con parent->fts_level = FTS_ROOTPARENTLEVEL; /* Allocate/initialize root(s). */ - for (root = nullptr, nitems = 0; *argv; ++argv, ++nitems) { + for (root = nullptr, nitems = 0; *argv; ++argv, ++nitems) { /* Don't allow zero-length paths. */ len = strlen(*argv); @@ -329,7 +329,7 @@ FTS* yfts_open(char* const* argv, int options, int (*compar)(const FTSENT**, con p->fts_link = root; root = p; } else { - p->fts_link = nullptr; + p->fts_link = nullptr; if (root == nullptr) { tmp = root = p; } else { @@ -375,7 +375,7 @@ mem2: free(sp->fts_path); mem1: free(sp); - return nullptr; + return nullptr; } static void @@ -393,7 +393,7 @@ fts_load(FTS* sp, FTSENT* p) */ len = p->fts_pathlen = p->fts_namelen; memmove((void*)sp->fts_path, (void*)p->fts_name, len + 1); - if ((cp = strrchr(p->fts_name, LOCSLASH_C)) != nullptr && (cp != p->fts_name || cp[1])) { + if ((cp = strrchr(p->fts_name, LOCSLASH_C)) != nullptr && (cp != p->fts_name || cp[1])) { len = strlen(++cp); memmove((void*)p->fts_name, (void*)cp, len + 1); p->fts_namelen = (u_short)len; @@ -469,7 +469,7 @@ yfts_read(FTS* sp) { /* If finished or unrecoverable error, return NULL. */ if (sp->fts_cur == nullptr || ISSET(FTS_STOP)) { - return nullptr; + return nullptr; } /* Set current node pointer. */ @@ -517,7 +517,7 @@ yfts_read(FTS* sp) { } if (sp->fts_child) { fts_lfree(sp->fts_child); - sp->fts_child = nullptr; + sp->fts_child = nullptr; } p->fts_info = FTS_DP; return (p); @@ -527,7 +527,7 @@ yfts_read(FTS* sp) { if (sp->fts_child && ISSET(FTS_NAMEONLY)) { CLR(FTS_NAMEONLY); fts_lfree(sp->fts_child); - sp->fts_child = nullptr; + sp->fts_child = nullptr; } /* @@ -551,21 +551,21 @@ yfts_read(FTS* sp) { p->fts_parent->fts_accpath; } } - } else if ((sp->fts_child = fts_build(sp, BREAD)) == nullptr) { + } else if ((sp->fts_child = fts_build(sp, BREAD)) == nullptr) { if (ISSET(FTS_STOP)) { - return nullptr; + return nullptr; } return (p); } p = sp->fts_child; - sp->fts_child = nullptr; + sp->fts_child = nullptr; goto name; } /* Move to the next node on this level. */ next: tmp = p; - if ((p = p->fts_link) != nullptr) { + if ((p = p->fts_link) != nullptr) { free(tmp); /* @@ -575,7 +575,7 @@ next: if (p->fts_level == FTS_ROOTLEVEL) { if (FCHDIR(sp, sp->fts_rfd)) { SET(FTS_STOP); - return nullptr; + return nullptr; } fts_load(sp, p); return (sp->fts_cur = p); @@ -622,7 +622,7 @@ next: */ free(p); errno = 0; - return (sp->fts_cur = nullptr); + return (sp->fts_cur = nullptr); } /* NUL terminate the pathname. */ @@ -636,7 +636,7 @@ next: if (p->fts_level == FTS_ROOTLEVEL) { if (FCHDIR(sp, sp->fts_rfd)) { SET(FTS_STOP); - return nullptr; + return nullptr; } } else if (p->fts_flags & FTS_SYMFOLLOW) { if (FCHDIR(sp, p->fts_symfd)) { @@ -644,7 +644,7 @@ next: close_dird(p->fts_symfd); errno = saved_errno; SET(FTS_STOP); - return nullptr; + return nullptr; } close_dird(p->fts_symfd); } else if (!(p->fts_flags & FTS_DONTCHDIR) && @@ -682,7 +682,7 @@ yfts_children(FTS* sp, int instr) dird fd; if (instr && instr != FTS_NAMEONLY) { errno = EINVAL; - return nullptr; + return nullptr; } /* Set current node pointer. */ @@ -696,7 +696,7 @@ yfts_children(FTS* sp, int instr) /* Fatal errors stop here. */ if (ISSET(FTS_STOP)) { - return nullptr; + return nullptr; } /* Return logical hierarchy of user's arguments. */ @@ -710,7 +710,7 @@ yfts_children(FTS* sp, int instr) * same effect is available with FTS_AGAIN. */ if (p->fts_info != FTS_D /* && p->fts_info != FTS_DNR */) { - return nullptr; + return nullptr; } /* Free up any previous child list. */ @@ -738,28 +738,28 @@ yfts_children(FTS* sp, int instr) } if (valid_dird(fd = get_cwdd())) { - return nullptr; + return nullptr; } sp->fts_child = fts_build(sp, instr); if (chdir_dird(fd)) { close_dird(fd); - return nullptr; + return nullptr; } close_dird(fd); return (sp->fts_child); } static inline struct dirent* yreaddir(DIR* dir, struct dirent* de) { - // TODO(yazevnul|IGNIETFERRO-1070): remove these macroses by replacing `readdir_r` with proper - // alternative - Y_PRAGMA_DIAGNOSTIC_PUSH - Y_PRAGMA_NO_DEPRECATED + // TODO(yazevnul|IGNIETFERRO-1070): remove these macroses by replacing `readdir_r` with proper + // alternative + Y_PRAGMA_DIAGNOSTIC_PUSH + Y_PRAGMA_NO_DEPRECATED if (readdir_r(dir, de, &de) == 0) { Y_PRAGMA_DIAGNOSTIC_POP return de; } - return nullptr; + return nullptr; } /* @@ -811,12 +811,12 @@ fts_build(FTS* sp, int type) #else #define __opendir2(path, flag) opendir(path) #endif - if ((dirp = __opendir2(cur->fts_accpath, oflag)) == nullptr) { + if ((dirp = __opendir2(cur->fts_accpath, oflag)) == nullptr) { if (type == BREAD) { cur->fts_info = FTS_DNR; cur->fts_errno = errno; } - return nullptr; + return nullptr; } #ifdef _win_ @@ -858,7 +858,7 @@ fts_build(FTS* sp, int type) cderrno = 0; if (nlinks || type == BREAD) { #ifndef _win_ - if (fts_safe_changedir(sp, cur, dirfd(dirp), nullptr)) { + if (fts_safe_changedir(sp, cur, dirfd(dirp), nullptr)) { #else if (fts_safe_changedir(sp, cur, -1, dirpd)) { #endif @@ -870,12 +870,12 @@ fts_build(FTS* sp, int type) descend = 0; cderrno = errno; (void)closedir(dirp); - dirp = nullptr; + dirp = nullptr; #ifdef _win_ close_dird(dirpd); dirpd = invalidDirD; #else - Y_UNUSED(invalidDirD); + Y_UNUSED(invalidDirD); #endif } else { descend = 1; @@ -900,7 +900,7 @@ fts_build(FTS* sp, int type) *cp++ = LOCSLASH_C; } else { /* GCC, you're too verbose. */ - cp = nullptr; + cp = nullptr; } ++len; maxlen = sp->fts_pathlen - len; @@ -913,7 +913,7 @@ fts_build(FTS* sp, int type) //to ensure enough buffer TTempBuf dpe; - for (head = tail = nullptr, nitems = 0; dirp && (dp = yreaddir(dirp, (struct dirent*)dpe.Data())) != nullptr;) { + for (head = tail = nullptr, nitems = 0; dirp && (dp = yreaddir(dirp, (struct dirent*)dpe.Data())) != nullptr;) { if (!ISSET(FTS_SEEDOT) && ISDOT(dp->d_name)) { continue; } @@ -942,7 +942,7 @@ fts_build(FTS* sp, int type) cur->fts_info = FTS_ERR; SET(FTS_STOP); errno = saved_errno; - return nullptr; + return nullptr; } /* Did realloc() change the pointer? */ if (oldaddr != sp->fts_path) { @@ -970,7 +970,7 @@ fts_build(FTS* sp, int type) cur->fts_info = FTS_ERR; SET(FTS_STOP); errno = ENAMETOOLONG; - return nullptr; + return nullptr; } p->fts_level = (short)level; p->fts_parent = sp->fts_cur; @@ -1029,7 +1029,7 @@ fts_build(FTS* sp, int type) } /* We walk in directory order so "ls -f" doesn't get upset. */ - p->fts_link = nullptr; + p->fts_link = nullptr; if (head == nullptr) { head = tail = p; } else { @@ -1076,7 +1076,7 @@ fts_build(FTS* sp, int type) cur->fts_info = FTS_ERR; SET(FTS_STOP); fts_lfree(head); - return nullptr; + return nullptr; } /* If didn't find anything, return NULL. */ @@ -1085,7 +1085,7 @@ fts_build(FTS* sp, int type) cur->fts_info = FTS_DP; } fts_lfree(head); - return nullptr; + return nullptr; } /* Sort the entries. */ @@ -1206,7 +1206,7 @@ fts_sort(FTS* sp, FTSENT* head, int nitems) if (sp->fts_array) { free(sp->fts_array); } - sp->fts_array = nullptr; + sp->fts_array = nullptr; sp->fts_nitems = 0; return (head); } @@ -1219,7 +1219,7 @@ fts_sort(FTS* sp, FTSENT* head, int nitems) for (head = *(ap = sp->fts_array); --nitems; ++ap) { ap[0]->fts_link = ap[1]; } - ap[0]->fts_link = nullptr; + ap[0]->fts_link = nullptr; return (head); } @@ -1242,7 +1242,7 @@ fts_alloc(FTS* sp, const char* name, int namelen) len += sizeof(stat_struct) + ALIGNBYTES; } if ((p = (FTSENT*)malloc(len)) == nullptr) { - return nullptr; + return nullptr; } /* Copy the name and guarantee NUL termination. */ @@ -1258,7 +1258,7 @@ fts_alloc(FTS* sp, const char* name, int namelen) p->fts_flags = 0; p->fts_instr = FTS_NOINSTR; p->fts_number = 0; - p->fts_pointer = nullptr; + p->fts_pointer = nullptr; p->fts_type = FTS_NSOK; return (p); } @@ -1269,7 +1269,7 @@ fts_lfree(FTSENT* head) FTSENT* p; /* Free a linked list of structures. */ - while ((p = head) != nullptr) { + while ((p = head) != nullptr) { head = head->fts_link; free(p); } @@ -1286,7 +1286,7 @@ fts_palloc(FTS* sp, size_t more) { sp->fts_pathlen += more + 256; sp->fts_path = (char*)yreallocf(sp->fts_path, (size_t)sp->fts_pathlen); - return (sp->fts_path == nullptr); + return (sp->fts_path == nullptr); } static void diff --git a/util/folder/fts.h b/util/folder/fts.h index f3c799e8c88..8b25d9eacd9 100644 --- a/util/folder/fts.h +++ b/util/folder/fts.h @@ -17,7 +17,7 @@ typedef struct _stat64 stat_struct; #define STAT_FUNC stat64UTF //TODO: remove from global scope stat64UTF stat64UTF #ifdef __cplusplus -int stat64UTF(const char* path, struct _stat64* _Stat); +int stat64UTF(const char* path, struct _stat64* _Stat); int stat64UTF(dird path, struct _stat64* _Stat); #endif #endif diff --git a/util/folder/fts_ut.cpp b/util/folder/fts_ut.cpp index c5d59e35f42..7fffa5ecb05 100644 --- a/util/folder/fts_ut.cpp +++ b/util/folder/fts_ut.cpp @@ -54,7 +54,7 @@ private: }; void TFtsTest::TestSimple() { - const char* dotPath[2] = {"." LOCSLASH_S, nullptr}; + const char* dotPath[2] = {"." LOCSLASH_S, nullptr}; TFileTree currentDirTree((char* const*)dotPath, 0, FtsCmp); UNIT_ASSERT(currentDirTree()); TTempDir tempDir = MakeTempName(yfts_read(currentDirTree())->fts_path); @@ -79,7 +79,7 @@ void TFtsTest::TestSimple() { CheckEnt(yfts_read(fileTree()), (tempDir() + LOCSLASH_S "dir2" LOCSLASH_S "file4").data(), FTS_F); CheckEnt(yfts_read(fileTree()), (tempDir() + LOCSLASH_S "dir2").data(), FTS_DP); CheckEnt(yfts_read(fileTree()), (tempDir()).data(), FTS_DP); - UNIT_ASSERT_EQUAL(yfts_read(fileTree()), nullptr); + UNIT_ASSERT_EQUAL(yfts_read(fileTree()), nullptr); } class TTempDirWithLostAccess: public TTempDir { diff --git a/util/folder/iterator.h b/util/folder/iterator.h index 69e025b9c49..04a254c3bb5 100644 --- a/util/folder/iterator.h +++ b/util/folder/iterator.h @@ -58,7 +58,7 @@ public: inline void Init(int opts) noexcept { FtsOptions = opts | FTS_NOCHDIR; MaxLevel = Max<size_t>(); - Cmp = nullptr; + Cmp = nullptr; } }; @@ -67,7 +67,7 @@ public: , Path_(path) { Trees_[0] = Path_.begin(); - Trees_[1] = nullptr; + Trees_[1] = nullptr; ClearLastSystemError(); FileTree_.Reset(yfts_open(Trees_, Options_.FtsOptions, Options_.Cmp)); diff --git a/util/folder/iterator_ut.cpp b/util/folder/iterator_ut.cpp index 936becd139b..2dccaadff13 100644 --- a/util/folder/iterator_ut.cpp +++ b/util/folder/iterator_ut.cpp @@ -11,8 +11,8 @@ static TString JoinWithNewline(const TVector<TString>& strings) { TStringStream ss; - for (const auto& string : strings) { - ss << string << "\n"; + for (const auto& string : strings) { + ss << string << "\n"; } return ss.Str(); } diff --git a/util/folder/path.cpp b/util/folder/path.cpp index bfe0c67d687..309fed0446f 100644 --- a/util/folder/path.cpp +++ b/util/folder/path.cpp @@ -1,15 +1,15 @@ -#include "dirut.h" +#include "dirut.h" #include "path.h" #include "pathsplit.h" -#include <util/generic/yexception.h> +#include <util/generic/yexception.h> #include <util/string/cast.h> -#include <util/system/compiler.h> -#include <util/system/file.h> +#include <util/system/compiler.h> +#include <util/system/file.h> #include <util/system/fs.h> struct TFsPath::TSplit: public TAtomicRefCount<TSplit>, public TPathSplit { - inline TSplit(const TStringBuf path) + inline TSplit(const TStringBuf path) : TPathSplit(path) { } @@ -187,7 +187,7 @@ TFsPath::TSplit& TFsPath::GetSplit() const { } static Y_FORCE_INLINE void VerifyPath(const TStringBuf path) { - Y_VERIFY(!path.Contains('\0'), "wrong format of TFsPath"); + Y_VERIFY(!path.Contains('\0'), "wrong format of TFsPath"); } TFsPath::TFsPath() { @@ -199,7 +199,7 @@ TFsPath::TFsPath(const TString& path) VerifyPath(Path_); } -TFsPath::TFsPath(const TStringBuf path) +TFsPath::TFsPath(const TStringBuf path) : Path_(ToString(path)) { VerifyPath(Path_); @@ -231,19 +231,19 @@ struct TClosedir { void TFsPath::ListNames(TVector<TString>& children) const { CheckDefined(); THolder<DIR, TClosedir> dir(opendir(this->c_str())); - if (!dir) { + if (!dir) { ythrow TIoSystemError() << "failed to opendir " << Path_; - } - + } + for (;;) { struct dirent de; struct dirent* ok; - // TODO(yazevnul|IGNIETFERRO-1070): remove these macroses by replacing `readdir_r` with proper - // alternative - Y_PRAGMA_DIAGNOSTIC_PUSH - Y_PRAGMA_NO_DEPRECATED + // TODO(yazevnul|IGNIETFERRO-1070): remove these macroses by replacing `readdir_r` with proper + // alternative + Y_PRAGMA_DIAGNOSTIC_PUSH + Y_PRAGMA_NO_DEPRECATED int r = readdir_r(dir.Get(), &de, &ok); - Y_PRAGMA_DIAGNOSTIC_POP + Y_PRAGMA_DIAGNOSTIC_POP if (r != 0) { ythrow TIoSystemError() << "failed to readdir " << Path_; } @@ -278,8 +278,8 @@ bool TFsPath::Contains(const TString& component) const { void TFsPath::List(TVector<TFsPath>& files) const { TVector<TString> names; ListNames(names); - for (auto& name : names) { - files.push_back(Child(name)); + for (auto& name : names) { + files.push_back(Child(name)); } } @@ -409,8 +409,8 @@ void TFsPath::ForceDelete() const { if (stat.IsDir()) { TVector<TFsPath> children; List(children); - for (auto& i : children) { - i.ForceDelete(); + for (auto& i : children) { + i.ForceDelete(); } ::rmdir(this->c_str()); } else { @@ -467,21 +467,21 @@ const TPathSplit& TFsPath::PathSplit() const { } template <> -void Out<TFsPath>(IOutputStream& os, const TFsPath& f) { +void Out<TFsPath>(IOutputStream& os, const TFsPath& f) { os << f.GetPath(); } template <> -TFsPath FromStringImpl<TFsPath>(const char* s, size_t len) { - return TFsPath{TStringBuf{s, len}}; -} - -template <> -bool TryFromStringImpl(const char* s, size_t len, TFsPath& result) { - try { - result = TStringBuf{s, len}; - return true; +TFsPath FromStringImpl<TFsPath>(const char* s, size_t len) { + return TFsPath{TStringBuf{s, len}}; +} + +template <> +bool TryFromStringImpl(const char* s, size_t len, TFsPath& result) { + try { + result = TStringBuf{s, len}; + return true; } catch (std::exception&) { - return false; - } -} + return false; + } +} diff --git a/util/folder/path.h b/util/folder/path.h index 2fb4d6b4ef3..9a85acc637c 100644 --- a/util/folder/path.h +++ b/util/folder/path.h @@ -3,15 +3,15 @@ #include "fwd.h" #include "pathsplit.h" -#include <util/generic/ptr.h> -#include <util/generic/strbuf.h> +#include <util/generic/ptr.h> +#include <util/generic/strbuf.h> #include <util/generic/string.h> -#include <util/generic/vector.h> -#include <util/string/cast.h> +#include <util/generic/vector.h> +#include <util/string/cast.h> #include <util/system/fstat.h> #include <util/system/platform.h> #include <util/system/sysstat.h> -#include <util/system/yassert.h> +#include <util/system/yassert.h> #include <utility> @@ -26,7 +26,7 @@ private: public: TFsPath(); TFsPath(const TString& path); - TFsPath(const TStringBuf path); + TFsPath(const TStringBuf path); TFsPath(const char* path); TFsPath(const std::string& path) diff --git a/util/folder/path_ut.cpp b/util/folder/path_ut.cpp index e6a34510164..7c8f12865ab 100644 --- a/util/folder/path_ut.cpp +++ b/util/folder/path_ut.cpp @@ -39,7 +39,7 @@ namespace { }; TTestDirectory::TTestDirectory(const TString& name) { - Y_VERIFY(name.length() > 0, "have to specify name"); + Y_VERIFY(name.length() > 0, "have to specify name"); Y_VERIFY(name.find('.') == TString::npos, "must be simple name"); Y_VERIFY(name.find('/') == TString::npos, "must be simple name"); Y_VERIFY(name.find('\\') == TString::npos, "must be simple name"); @@ -54,8 +54,8 @@ namespace { } } -Y_UNIT_TEST_SUITE(TFsPathTests) { - Y_UNIT_TEST(TestMkDirs) { +Y_UNIT_TEST_SUITE(TFsPathTests) { + Y_UNIT_TEST(TestMkDirs) { const TFsPath path = "a/b/c/d/e/f"; path.ForceDelete(); TFsPath current = path; @@ -77,7 +77,7 @@ Y_UNIT_TEST_SUITE(TFsPathTests) { } } - Y_UNIT_TEST(MkDirFreak) { + Y_UNIT_TEST(MkDirFreak) { TFsPath path; UNIT_ASSERT_EXCEPTION(path.MkDir(), TIoException); UNIT_ASSERT_EXCEPTION(path.MkDirs(), TIoException); @@ -86,7 +86,7 @@ Y_UNIT_TEST_SUITE(TFsPathTests) { path.MkDirs(); } - Y_UNIT_TEST(Parent) { + Y_UNIT_TEST(Parent) { #ifdef _win_ UNIT_ASSERT_VALUES_EQUAL(TFsPath("\\etc/passwd").Parent(), TFsPath("\\etc")); UNIT_ASSERT_VALUES_EQUAL(TFsPath("\\etc").Parent(), TFsPath("\\")); @@ -117,7 +117,7 @@ Y_UNIT_TEST_SUITE(TFsPathTests) { #endif } - Y_UNIT_TEST(GetName) { + Y_UNIT_TEST(GetName) { TTestDirectory d("GetName"); UNIT_ASSERT_VALUES_EQUAL(TString("dfgh"), d.Child("dfgh").GetName()); @@ -129,7 +129,7 @@ Y_UNIT_TEST_SUITE(TFsPathTests) { #endif } - Y_UNIT_TEST(GetExtension) { + Y_UNIT_TEST(GetExtension) { TTestDirectory d("GetExtension"); UNIT_ASSERT_VALUES_EQUAL("", d.Child("a").GetExtension()); UNIT_ASSERT_VALUES_EQUAL("", d.Child(".a").GetExtension()); @@ -138,7 +138,7 @@ Y_UNIT_TEST_SUITE(TFsPathTests) { UNIT_ASSERT_VALUES_EQUAL("zlib", d.Child("file.ylib.zlib").GetExtension()); } - Y_UNIT_TEST(TestRename) { + Y_UNIT_TEST(TestRename) { TTestDirectory xx("TestRename"); TFsPath f1 = xx.Child("f1"); TFsPath f2 = xx.Child("f2"); @@ -148,7 +148,7 @@ Y_UNIT_TEST_SUITE(TFsPathTests) { UNIT_ASSERT(f2.Exists()); } - Y_UNIT_TEST(TestForceRename) { + Y_UNIT_TEST(TestForceRename) { TTestDirectory xx("TestForceRename"); TFsPath fMain = xx.Child("main"); @@ -168,12 +168,12 @@ Y_UNIT_TEST_SUITE(TFsPathTests) { UNIT_ASSERT(xx.Child("main1").Child("f1").Child("f1child").Exists()); } - Y_UNIT_TEST(TestRenameFail) { + Y_UNIT_TEST(TestRenameFail) { UNIT_ASSERT_EXCEPTION(TFsPath("sfsfsfsdfsfsdfdf").RenameTo("sdfsdf"), TIoException); } #ifndef _win_ - Y_UNIT_TEST(TestRealPath) { + Y_UNIT_TEST(TestRealPath) { UNIT_ASSERT(TFsPath(".").RealPath().IsDirectory()); TTestDirectory td("TestRealPath"); @@ -190,7 +190,7 @@ Y_UNIT_TEST_SUITE(TFsPathTests) { } #endif - Y_UNIT_TEST(TestSlashesAndBasename) { + Y_UNIT_TEST(TestSlashesAndBasename) { TFsPath p("/db/BASE/primus121-025-1380131338//"); UNIT_ASSERT_VALUES_EQUAL(p.Basename(), TString("primus121-025-1380131338")); TFsPath testP = p / "test"; @@ -201,7 +201,7 @@ Y_UNIT_TEST_SUITE(TFsPathTests) { #endif } - Y_UNIT_TEST(TestSlashesAndBasenameWin) { + Y_UNIT_TEST(TestSlashesAndBasenameWin) { TFsPath p("\\db\\BASE\\primus121-025-1380131338\\\\"); TFsPath testP = p / "test"; #ifdef _win_ @@ -213,7 +213,7 @@ Y_UNIT_TEST_SUITE(TFsPathTests) { #endif } - Y_UNIT_TEST(TestSlashesAndBasenameWinDrive) { + Y_UNIT_TEST(TestSlashesAndBasenameWinDrive) { TFsPath p("C:\\db\\BASE\\primus121-025-1380131338\\\\"); TFsPath testP = p / "test"; #ifdef _win_ @@ -225,7 +225,7 @@ Y_UNIT_TEST_SUITE(TFsPathTests) { #endif } - Y_UNIT_TEST(TestList) { + Y_UNIT_TEST(TestList) { TTestDirectory td("TestList-dir"); TFsPath dir = td.GetFsPath(); @@ -249,7 +249,7 @@ Y_UNIT_TEST_SUITE(TFsPathTests) { } #ifdef _unix_ - Y_UNIT_TEST(MkDirMode) { + Y_UNIT_TEST(MkDirMode) { TTestDirectory td("MkDirMode"); TFsPath subDir = td.Child("subdir"); const int mode = MODE0775; @@ -263,11 +263,11 @@ Y_UNIT_TEST_SUITE(TFsPathTests) { } #endif - Y_UNIT_TEST(Cwd) { + Y_UNIT_TEST(Cwd) { UNIT_ASSERT_VALUES_EQUAL(TFsPath::Cwd().RealPath(), TFsPath(".").RealPath()); } - Y_UNIT_TEST(TestSubpathOf) { + Y_UNIT_TEST(TestSubpathOf) { UNIT_ASSERT(TFsPath("/a/b/c/d").IsSubpathOf("/a/b")); UNIT_ASSERT(TFsPath("/a").IsSubpathOf("/")); @@ -334,7 +334,7 @@ Y_UNIT_TEST_SUITE(TFsPathTests) { #endif } - Y_UNIT_TEST(TestRelativePath) { + Y_UNIT_TEST(TestRelativePath) { UNIT_ASSERT_VALUES_EQUAL(TFsPath("/a/b/c/d").RelativePath(TFsPath("/a/b")), TFsPath("c/d")); UNIT_ASSERT_VALUES_EQUAL(TFsPath("/a/b/c/d").RelativePath(TFsPath("/a/b/e/f")), TFsPath("../../c/d")); UNIT_ASSERT_VALUES_EQUAL(TFsPath("/").RelativePath(TFsPath("/")), TFsPath()); @@ -345,7 +345,7 @@ Y_UNIT_TEST_SUITE(TFsPathTests) { UNIT_ASSERT_EXCEPTION(TFsPath("a/b/c").RelativePath(TFsPath("d/e")), TIoException); } - Y_UNIT_TEST(TestUndefined) { + Y_UNIT_TEST(TestUndefined) { UNIT_ASSERT_VALUES_EQUAL(TFsPath(), TFsPath("")); UNIT_ASSERT_VALUES_EQUAL(TFsPath(), TFsPath().Fix()); @@ -393,7 +393,7 @@ Y_UNIT_TEST_SUITE(TFsPathTests) { UNIT_ASSERT(!TFsPath().Stat(stat)); } - Y_UNIT_TEST(TestJoinFsPaths) { + Y_UNIT_TEST(TestJoinFsPaths) { #ifdef _win_ UNIT_ASSERT_VALUES_EQUAL(JoinFsPaths("a\\b", "c\\d"), "a\\b\\c\\d"); UNIT_ASSERT_VALUES_EQUAL(JoinFsPaths("a\\b", "..\\c"), "a\\b\\..\\c"); @@ -410,23 +410,23 @@ Y_UNIT_TEST_SUITE(TFsPathTests) { UNIT_ASSERT_VALUES_EQUAL(JoinFsPaths("a/b", ""), "a/b"); #endif } - - Y_UNIT_TEST(TestStringCast) { - TFsPath pathOne; - UNIT_ASSERT(TryFromString<TFsPath>("/a/b", pathOne)); - UNIT_ASSERT_VALUES_EQUAL(pathOne, TFsPath{"/a/b"}); - - TFsPath pathTwo; - UNIT_ASSERT_NO_EXCEPTION(TryFromString<TFsPath>("/a/b", pathTwo)); - - UNIT_ASSERT_VALUES_EQUAL(FromString<TFsPath>("/a/b"), TFsPath{"/a/b"}); - - TFsPath pathThree{"/a/b"}; - UNIT_ASSERT_VALUES_EQUAL(ToString(pathThree), "/a/b"); - } + + Y_UNIT_TEST(TestStringCast) { + TFsPath pathOne; + UNIT_ASSERT(TryFromString<TFsPath>("/a/b", pathOne)); + UNIT_ASSERT_VALUES_EQUAL(pathOne, TFsPath{"/a/b"}); + + TFsPath pathTwo; + UNIT_ASSERT_NO_EXCEPTION(TryFromString<TFsPath>("/a/b", pathTwo)); + + UNIT_ASSERT_VALUES_EQUAL(FromString<TFsPath>("/a/b"), TFsPath{"/a/b"}); + + TFsPath pathThree{"/a/b"}; + UNIT_ASSERT_VALUES_EQUAL(ToString(pathThree), "/a/b"); + } #ifdef _unix_ - Y_UNIT_TEST(TestRemoveSymlinkToDir) { + Y_UNIT_TEST(TestRemoveSymlinkToDir) { TTempDir tempDir; TFsPath tempDirPath(tempDir()); @@ -449,7 +449,7 @@ Y_UNIT_TEST_SUITE(TFsPathTests) { UNIT_ASSERT(NFs::Exists(originDir)); } - Y_UNIT_TEST(TestRemoveSymlinkToFile) { + Y_UNIT_TEST(TestRemoveSymlinkToFile) { TTempDir tempDir; TFsPath tempDirPath(tempDir()); @@ -472,7 +472,7 @@ Y_UNIT_TEST_SUITE(TFsPathTests) { UNIT_ASSERT(NFs::Exists(originDir)); } - Y_UNIT_TEST(TestRemoveDirWithSymlinkToDir) { + Y_UNIT_TEST(TestRemoveDirWithSymlinkToDir) { TTempDir tempDir; TFsPath tempDirPath(tempDir()); @@ -499,7 +499,7 @@ Y_UNIT_TEST_SUITE(TFsPathTests) { UNIT_ASSERT(NFs::Exists(originDir)); } - Y_UNIT_TEST(TestRemoveDirWithSymlinkToFile) { + Y_UNIT_TEST(TestRemoveDirWithSymlinkToFile) { TTempDir tempDir; TFsPath tempDirPath(tempDir()); diff --git a/util/folder/pathsplit.cpp b/util/folder/pathsplit.cpp index 81d439a727b..c2abc131414 100644 --- a/util/folder/pathsplit.cpp +++ b/util/folder/pathsplit.cpp @@ -16,7 +16,7 @@ static inline size_t ToReserve(const T& t) { return ret; } -void TPathSplitTraitsUnix::DoParseFirstPart(const TStringBuf part) { +void TPathSplitTraitsUnix::DoParseFirstPart(const TStringBuf part) { if (part == TStringBuf(".")) { push_back(TStringBuf(".")); @@ -30,7 +30,7 @@ void TPathSplitTraitsUnix::DoParseFirstPart(const TStringBuf part) { DoParsePart(part); } -void TPathSplitTraitsUnix::DoParsePart(const TStringBuf part0) { +void TPathSplitTraitsUnix::DoParsePart(const TStringBuf part0) { DoAppendHint(part0.size() / 8); TStringBuf next(part0); @@ -43,7 +43,7 @@ void TPathSplitTraitsUnix::DoParsePart(const TStringBuf part0) { AppendComponent(next); } -void TPathSplitTraitsWindows::DoParseFirstPart(const TStringBuf part0) { +void TPathSplitTraitsWindows::DoParseFirstPart(const TStringBuf part0) { TStringBuf part(part0); if (part == TStringBuf(".")) { @@ -64,7 +64,7 @@ void TPathSplitTraitsWindows::DoParseFirstPart(const TStringBuf part0) { DoParsePart(part); } -void TPathSplitTraitsWindows::DoParsePart(const TStringBuf part0) { +void TPathSplitTraitsWindows::DoParsePart(const TStringBuf part0) { DoAppendHint(part0.size() / 8); size_t pos = 0; @@ -106,7 +106,7 @@ TString TPathSplitStore::DoReconstruct(const TStringBuf slash) const { return r; } -void TPathSplitStore::AppendComponent(const TStringBuf comp) { +void TPathSplitStore::AppendComponent(const TStringBuf comp) { if (!comp || comp == TStringBuf(".")) { ; // ignore } else if (comp == TStringBuf("..") && !empty() && back() != TStringBuf("..")) { @@ -122,7 +122,7 @@ TStringBuf TPathSplitStore::Extension() const { } template <> -void Out<TPathSplit>(IOutputStream& o, const TPathSplit& ps) { +void Out<TPathSplit>(IOutputStream& o, const TPathSplit& ps) { o << ps.Reconstruct(); } @@ -134,7 +134,7 @@ TString JoinPaths(const TPathSplit& p1, const TPathSplit& p2) { return TPathSplit(p1).AppendMany(p2.begin(), p2.end()).Reconstruct(); } -TStringBuf CutExtension(const TStringBuf fileName) { +TStringBuf CutExtension(const TStringBuf fileName) { if (fileName.empty()) { return fileName; } diff --git a/util/folder/pathsplit.h b/util/folder/pathsplit.h index d134338e35d..c7f5d55197b 100644 --- a/util/folder/pathsplit.h +++ b/util/folder/pathsplit.h @@ -10,7 +10,7 @@ struct TPathSplitStore: public TVector<TStringBuf> { TStringBuf Drive; bool IsAbsolute = false; - void AppendComponent(const TStringBuf comp); + void AppendComponent(const TStringBuf comp); TStringBuf Extension() const; protected: @@ -22,41 +22,41 @@ protected: }; struct TPathSplitTraitsUnix: public TPathSplitStore { - static constexpr char MainPathSep = '/'; + static constexpr char MainPathSep = '/'; inline TString Reconstruct() const { return DoReconstruct(TStringBuf("/")); } - static constexpr bool IsPathSep(const char c) noexcept { + static constexpr bool IsPathSep(const char c) noexcept { return c == '/'; } - static inline bool IsAbsolutePath(const TStringBuf path) noexcept { + static inline bool IsAbsolutePath(const TStringBuf path) noexcept { return path && IsPathSep(path[0]); } - void DoParseFirstPart(const TStringBuf part); - void DoParsePart(const TStringBuf part); + void DoParseFirstPart(const TStringBuf part); + void DoParsePart(const TStringBuf part); }; struct TPathSplitTraitsWindows: public TPathSplitStore { - static constexpr char MainPathSep = '\\'; + static constexpr char MainPathSep = '\\'; inline TString Reconstruct() const { return DoReconstruct(TStringBuf("\\")); } - static constexpr bool IsPathSep(char c) noexcept { + static constexpr bool IsPathSep(char c) noexcept { return c == '/' || c == '\\'; } - static inline bool IsAbsolutePath(const TStringBuf path) noexcept { + static inline bool IsAbsolutePath(const TStringBuf path) noexcept { return path && (IsPathSep(path[0]) || (path.size() > 1 && path[1] == ':' && IsAsciiAlpha(path[0]) && (path.size() == 2 || IsPathSep(path[2])))); } - void DoParseFirstPart(const TStringBuf part); - void DoParsePart(const TStringBuf part); + void DoParseFirstPart(const TStringBuf part); + void DoParsePart(const TStringBuf part); }; #if defined(_unix_) @@ -70,7 +70,7 @@ class TPathSplitBase: public TTraits { public: inline TPathSplitBase() = default; - inline TPathSplitBase(const TStringBuf part) { + inline TPathSplitBase(const TStringBuf part) { this->ParseFirstPart(part); } @@ -80,13 +80,13 @@ public: return *this; } - inline TPathSplitBase& ParseFirstPart(const TStringBuf part) { + inline TPathSplitBase& ParseFirstPart(const TStringBuf part) { this->DoParseFirstPart(part); return *this; } - inline TPathSplitBase& ParsePart(const TStringBuf part) { + inline TPathSplitBase& ParsePart(const TStringBuf part) { this->DoParsePart(part); return *this; @@ -110,4 +110,4 @@ using TPathSplitWindows = TPathSplitBase<TPathSplitTraitsWindows>; TString JoinPaths(const TPathSplit& p1, const TPathSplit& p2); -TStringBuf CutExtension(const TStringBuf fileName); +TStringBuf CutExtension(const TStringBuf fileName); diff --git a/util/folder/pathsplit_ut.cpp b/util/folder/pathsplit_ut.cpp index 0e97afd0d00..baa23c9f77f 100644 --- a/util/folder/pathsplit_ut.cpp +++ b/util/folder/pathsplit_ut.cpp @@ -63,50 +63,50 @@ #define TRUE_ONLY_WIN false #endif -Y_UNIT_TEST_SUITE(PSUF(PathSplit)) { - Y_UNIT_TEST(Empty) { +Y_UNIT_TEST_SUITE(PSUF(PathSplit)) { + Y_UNIT_TEST(Empty) { PSUF(TPathSplit) ps; PS_CHECK(ps); UNIT_ASSERT_EQUAL(ps.IsAbsolute, false); } - Y_UNIT_TEST(Relative) { + Y_UNIT_TEST(Relative) { PSUF(TPathSplit) ps("some/usual/path"); PS_CHECK(ps, "some", "usual", "path"); UNIT_ASSERT_EQUAL(ps.IsAbsolute, false); } - Y_UNIT_TEST(Absolute) { + Y_UNIT_TEST(Absolute) { PSUF(TPathSplit) ps("/some/usual/path"); PS_CHECK(ps, "some", "usual", "path"); UNIT_ASSERT_EQUAL(ps.IsAbsolute, true); } - Y_UNIT_TEST(Self) { + Y_UNIT_TEST(Self) { PSUF(TPathSplit) ps("."); PS_CHECK(ps, "."); UNIT_ASSERT_EQUAL(ps.IsAbsolute, false); } - Y_UNIT_TEST(Parent) { + Y_UNIT_TEST(Parent) { PSUF(TPathSplit) ps(".."); PS_CHECK(ps, ".."); UNIT_ASSERT_EQUAL(ps.IsAbsolute, false); } - Y_UNIT_TEST(Root) { + Y_UNIT_TEST(Root) { PSUF(TPathSplit) ps("/"); PS_CHECK(ps); UNIT_ASSERT_EQUAL(ps.IsAbsolute, true); } - Y_UNIT_TEST(Reconstruct) { + Y_UNIT_TEST(Reconstruct) { PSUF(TPathSplit) ps("some/usual/path/../../other/././//path"); #ifdef _win_ @@ -123,7 +123,7 @@ Y_UNIT_TEST_SUITE(PSUF(PathSplit)) { #endif } - Y_UNIT_TEST(ParseFirstPart) { + Y_UNIT_TEST(ParseFirstPart) { PSUF(TPathSplit) ps; ps.ParseFirstPart("some/usual/path"); @@ -136,7 +136,7 @@ Y_UNIT_TEST_SUITE(PSUF(PathSplit)) { UNIT_ASSERT_EQUAL(ps.IsAbsolute, true); } - Y_UNIT_TEST(ParsePart) { + Y_UNIT_TEST(ParsePart) { PSUF(TPathSplit) ps("some/usual/path"); ps.ParsePart("sub/path"); @@ -149,7 +149,7 @@ Y_UNIT_TEST_SUITE(PSUF(PathSplit)) { UNIT_ASSERT_EQUAL(ps.IsAbsolute, false); } - Y_UNIT_TEST(ParsePartSelf) { + Y_UNIT_TEST(ParsePartSelf) { PSUF(TPathSplit) ps("some/usual/path"); ps.ParsePart("."); @@ -160,7 +160,7 @@ Y_UNIT_TEST_SUITE(PSUF(PathSplit)) { PS_CHECK(ps, "some", "usual", "path"); } - Y_UNIT_TEST(ParsePartParent) { + Y_UNIT_TEST(ParsePartParent) { PSUF(TPathSplit) ps("some/usual/path"); ps.ParsePart(".."); @@ -181,7 +181,7 @@ Y_UNIT_TEST_SUITE(PSUF(PathSplit)) { UNIT_ASSERT_EQUAL(ps.IsAbsolute, true); } - Y_UNIT_TEST(ParsePartOverflow) { + Y_UNIT_TEST(ParsePartOverflow) { PSUF(TPathSplit) ps("some/usual/path"); ps.ParsePart("../../../../.."); @@ -194,7 +194,7 @@ Y_UNIT_TEST_SUITE(PSUF(PathSplit)) { UNIT_ASSERT_EQUAL(ps.IsAbsolute, true); } - Y_UNIT_TEST(WinRelative) { + Y_UNIT_TEST(WinRelative) { PSUF(TPathSplit) ps("some\\usual\\path"); #ifdef _win_ @@ -205,7 +205,7 @@ Y_UNIT_TEST_SUITE(PSUF(PathSplit)) { UNIT_ASSERT_EQUAL(ps.IsAbsolute, false); } - Y_UNIT_TEST(WinAbsolute) { + Y_UNIT_TEST(WinAbsolute) { PSUF(TPathSplit) ps("\\some\\usual\\path"); #ifdef _win_ @@ -236,7 +236,7 @@ Y_UNIT_TEST_SUITE(PSUF(PathSplit)) { UNIT_ASSERT_EQUAL(psDrive2.IsAbsolute, TRUE_ONLY_WIN); } - Y_UNIT_TEST(WinRoot) { + Y_UNIT_TEST(WinRoot) { PSUF(TPathSplit) ps("\\"); #ifdef _win_ @@ -257,7 +257,7 @@ Y_UNIT_TEST_SUITE(PSUF(PathSplit)) { UNIT_ASSERT_EQUAL(psDrive.IsAbsolute, TRUE_ONLY_WIN); } - Y_UNIT_TEST(WinReconstruct) { + Y_UNIT_TEST(WinReconstruct) { PSUF(TPathSplit) ps("some\\usual\\path\\..\\..\\other\\.\\.\\\\\\path"); #ifdef _win_ @@ -274,7 +274,7 @@ Y_UNIT_TEST_SUITE(PSUF(PathSplit)) { #endif } - Y_UNIT_TEST(WinParseFirstPart) { + Y_UNIT_TEST(WinParseFirstPart) { PSUF(TPathSplit) ps; ps.ParseFirstPart("some\\usual\\path"); @@ -295,7 +295,7 @@ Y_UNIT_TEST_SUITE(PSUF(PathSplit)) { UNIT_ASSERT_EQUAL(ps.IsAbsolute, TRUE_ONLY_WIN); } - Y_UNIT_TEST(WinParsePart) { + Y_UNIT_TEST(WinParsePart) { PSUF(TPathSplit) ps("some\\usual\\path"); ps.ParsePart("sub\\path"); @@ -317,7 +317,7 @@ Y_UNIT_TEST_SUITE(PSUF(PathSplit)) { } #ifdef _win_ - Y_UNIT_TEST(WinParsePartSelf) { + Y_UNIT_TEST(WinParsePartSelf) { PSUF(TPathSplit) ps("some\\usual\\path"); ps.ParsePart("."); @@ -328,7 +328,7 @@ Y_UNIT_TEST_SUITE(PSUF(PathSplit)) { PS_CHECK(ps, "some", "usual", "path"); } - Y_UNIT_TEST(WinParsePartParent) { + Y_UNIT_TEST(WinParsePartParent) { PSUF(TPathSplit) ps("some\\usual\\path"); ps.ParsePart(".."); @@ -355,7 +355,7 @@ Y_UNIT_TEST_SUITE(PSUF(PathSplit)) { UNIT_ASSERT_EQUAL(ps.Drive, "C:"); } - Y_UNIT_TEST(WinParsePartOverflow) { + Y_UNIT_TEST(WinParsePartOverflow) { PSUF(TPathSplit) ps("some\\usual\\path"); ps.ParsePart("..\\..\\..\\..\\.."); @@ -375,7 +375,7 @@ Y_UNIT_TEST_SUITE(PSUF(PathSplit)) { } #endif - Y_UNIT_TEST(WinMixed) { + Y_UNIT_TEST(WinMixed) { PSUF(TPathSplit) ps("some\\usual/path"); #ifdef _win_ @@ -386,7 +386,7 @@ Y_UNIT_TEST_SUITE(PSUF(PathSplit)) { UNIT_ASSERT_EQUAL(ps.IsAbsolute, false); } - Y_UNIT_TEST(WinParsePartMixed) { + Y_UNIT_TEST(WinParsePartMixed) { PSUF(TPathSplit) ps("some\\usual/path"); ps.ParsePart("sub/sub\\path"); @@ -398,7 +398,7 @@ Y_UNIT_TEST_SUITE(PSUF(PathSplit)) { UNIT_ASSERT_EQUAL(ps.IsAbsolute, false); } - Y_UNIT_TEST(BeginWithSelf) { + Y_UNIT_TEST(BeginWithSelf) { PSUF(TPathSplit) ps("./some/usual/path"); PS_CHECK(ps, "some", "usual", "path"); @@ -409,7 +409,7 @@ Y_UNIT_TEST_SUITE(PSUF(PathSplit)) { #endif } - Y_UNIT_TEST(BeginWithParent) { + Y_UNIT_TEST(BeginWithParent) { PSUF(TPathSplit) ps("../some/usual/path"); PS_CHECK(ps, "..", "some", "usual", "path"); @@ -420,14 +420,14 @@ Y_UNIT_TEST_SUITE(PSUF(PathSplit)) { #endif } - Y_UNIT_TEST(InOut) { + Y_UNIT_TEST(InOut) { PSUF(TPathSplit) ps("path/.."); PS_CHECK(ps); UNIT_ASSERT_STRINGS_EQUAL(ps.Reconstruct(), ""); } - Y_UNIT_TEST(OutIn) { + Y_UNIT_TEST(OutIn) { PSUF(TPathSplit) ps("../path"); PS_CHECK(ps, "..", "path"); @@ -439,14 +439,14 @@ Y_UNIT_TEST_SUITE(PSUF(PathSplit)) { } } -Y_UNIT_TEST_SUITE(PSUF(PathSplitTraits)) { - Y_UNIT_TEST(IsPathSep) { +Y_UNIT_TEST_SUITE(PSUF(PathSplitTraits)) { + Y_UNIT_TEST(IsPathSep) { UNIT_ASSERT_EQUAL(PSUF_LOCAL(TPathSplitTraits)::IsPathSep('/'), true); UNIT_ASSERT_EQUAL(PSUF_LOCAL(TPathSplitTraits)::IsPathSep('\\'), TRUE_ONLY_WIN); UNIT_ASSERT_EQUAL(PSUF_LOCAL(TPathSplitTraits)::IsPathSep(' '), false); } - Y_UNIT_TEST(IsAbsolutePath) { + Y_UNIT_TEST(IsAbsolutePath) { UNIT_ASSERT_EQUAL(PSUF_LOCAL(TPathSplitTraits)::IsAbsolutePath(""), false); UNIT_ASSERT_EQUAL(PSUF_LOCAL(TPathSplitTraits)::IsAbsolutePath("/"), true); UNIT_ASSERT_EQUAL(PSUF_LOCAL(TPathSplitTraits)::IsAbsolutePath("some/usual/path"), false); @@ -457,7 +457,7 @@ Y_UNIT_TEST_SUITE(PSUF(PathSplitTraits)) { UNIT_ASSERT_EQUAL(PSUF_LOCAL(TPathSplitTraits)::IsAbsolutePath("/.."), true); } - Y_UNIT_TEST(WinIsAbsolutePath) { + Y_UNIT_TEST(WinIsAbsolutePath) { UNIT_ASSERT_EQUAL(PSUF_LOCAL(TPathSplitTraits)::IsAbsolutePath("somepath"), false); UNIT_ASSERT_EQUAL(PSUF_LOCAL(TPathSplitTraits)::IsAbsolutePath("\\"), TRUE_ONLY_WIN); UNIT_ASSERT_EQUAL(PSUF_LOCAL(TPathSplitTraits)::IsAbsolutePath("\\somepath"), TRUE_ONLY_WIN); diff --git a/util/folder/tempdir.cpp b/util/folder/tempdir.cpp index 6fdf8f753c1..fdf66d5de31 100644 --- a/util/folder/tempdir.cpp +++ b/util/folder/tempdir.cpp @@ -16,7 +16,7 @@ TTempDir::TTempDir(const char* prefix, TCreationToken) { char tempDir[MAX_PATH]; if (MakeTempDir(tempDir, prefix) != 0) { - ythrow TSystemError() << "Can't create temporary directory"; + ythrow TSystemError() << "Can't create temporary directory"; } TempDir = tempDir; } diff --git a/util/generic/adaptor_ut.cpp b/util/generic/adaptor_ut.cpp index 721f849f934..1a14b942b44 100644 --- a/util/generic/adaptor_ut.cpp +++ b/util/generic/adaptor_ut.cpp @@ -32,8 +32,8 @@ struct TState { } }; -Y_UNIT_TEST_SUITE(TReverseAdaptor) { - Y_UNIT_TEST(ReadTest) { +Y_UNIT_TEST_SUITE(TReverseAdaptor) { + Y_UNIT_TEST(ReadTest) { TVector<int> cont = {1, 2, 3}; TVector<int> etalon = {3, 2, 1}; size_t idx = 0; @@ -46,7 +46,7 @@ Y_UNIT_TEST_SUITE(TReverseAdaptor) { } } - Y_UNIT_TEST(WriteTest) { + Y_UNIT_TEST(WriteTest) { TVector<int> cont = {1, 2, 3}; TVector<int> etalon = {3, 6, 9}; size_t idx = 0; @@ -59,7 +59,7 @@ Y_UNIT_TEST_SUITE(TReverseAdaptor) { } } - Y_UNIT_TEST(InnerTypeTest) { + Y_UNIT_TEST(InnerTypeTest) { using TStub = TVector<int>; TStub stub; const TStub cstub; @@ -69,7 +69,7 @@ Y_UNIT_TEST_SUITE(TReverseAdaptor) { UNIT_ASSERT_TYPES_EQUAL(decltype(Reversed(cstub)), TReverseRange<const TStub&>); } - Y_UNIT_TEST(CopyMoveTest) { + Y_UNIT_TEST(CopyMoveTest) { TState lvalue; const TState clvalue; UNIT_ASSERT_NO_EXCEPTION(Reversed(lvalue)); diff --git a/util/generic/algorithm.h b/util/generic/algorithm.h index badfb889933..fce4c9c695e 100644 --- a/util/generic/algorithm.h +++ b/util/generic/algorithm.h @@ -181,7 +181,7 @@ static inline bool AnyOf(const C& c, P pred) { template <class I, class P> static inline auto FindIfPtr(I f, I l, P pred) -> decltype(&*f) { I found = FindIf(f, l, pred); - return (found != l) ? &*found : nullptr; + return (found != l) ? &*found : nullptr; } template <class C, class P> @@ -218,16 +218,16 @@ inline bool EqualToOneOf(const T& x, const U& y, const Other&... other) { return x == y || EqualToOneOf(x, other...); } -template <typename T> -static inline size_t CountOf(const T&) { - return 0; -} - -template <typename T, typename U, typename... Other> -static inline size_t CountOf(const T& x, const U& y, const Other&... other) { - return static_cast<size_t>(x == y) + CountOf(x, other...); -} - +template <typename T> +static inline size_t CountOf(const T&) { + return 0; +} + +template <typename T, typename U, typename... Other> +static inline size_t CountOf(const T& x, const U& y, const Other&... other) { + return static_cast<size_t>(x == y) + CountOf(x, other...); +} + template <class I> static inline void PushHeap(I f, I l) { std::push_heap(f, l); @@ -438,7 +438,7 @@ static inline void Fill(I f, I l, const T& v) { std::fill(f, l, v); } -template <typename I, typename S, typename T> +template <typename I, typename S, typename T> static inline I FillN(I f, S n, const T& v) { return std::fill_n(f, n, v); } diff --git a/util/generic/algorithm_ut.cpp b/util/generic/algorithm_ut.cpp index 8d732fcc0cf..fc2a05efb9b 100644 --- a/util/generic/algorithm_ut.cpp +++ b/util/generic/algorithm_ut.cpp @@ -6,8 +6,8 @@ static auto isOne = [](char c) { return c == '1'; }; -Y_UNIT_TEST_SUITE(TAlgorithm) { - Y_UNIT_TEST(AnyTest) { +Y_UNIT_TEST_SUITE(TAlgorithm) { + Y_UNIT_TEST(AnyTest) { UNIT_ASSERT(0 == AnyOf(TStringBuf("00"), isOne)); UNIT_ASSERT(1 == AnyOf(TStringBuf("01"), isOne)); UNIT_ASSERT(1 == AnyOf(TStringBuf("10"), isOne)); @@ -20,7 +20,7 @@ Y_UNIT_TEST_SUITE(TAlgorithm) { UNIT_ASSERT(1 == AnyOf(array01, isOne)); } - Y_UNIT_TEST(AllOfTest) { + Y_UNIT_TEST(AllOfTest) { UNIT_ASSERT(0 == AllOf(TStringBuf("00"), isOne)); UNIT_ASSERT(0 == AllOf(TStringBuf("01"), isOne)); UNIT_ASSERT(0 == AllOf(TStringBuf("10"), isOne)); @@ -33,7 +33,7 @@ Y_UNIT_TEST_SUITE(TAlgorithm) { UNIT_ASSERT(1 == AllOf(array11, isOne)); } - Y_UNIT_TEST(CountIfTest) { + Y_UNIT_TEST(CountIfTest) { UNIT_ASSERT(3 == CountIf(TStringBuf("____1________1____1_______"), isOne)); UNIT_ASSERT(5 == CountIf(TStringBuf("1____1________1____1_______1"), isOne)); UNIT_ASSERT(0 == CountIf(TStringBuf("___________"), isOne)); @@ -68,40 +68,40 @@ Y_UNIT_TEST_SUITE(TAlgorithm) { void operator=(const TStrokaNoCopy&); }; - Y_UNIT_TEST(CountOfTest) { - UNIT_ASSERT_VALUES_EQUAL(CountOf(1, 2), 0); - UNIT_ASSERT_VALUES_EQUAL(CountOf(1, 1), 1); - UNIT_ASSERT_VALUES_EQUAL(CountOf(2, 4, 5), 0); - UNIT_ASSERT_VALUES_EQUAL(CountOf(2, 4, 2), 1); - UNIT_ASSERT_VALUES_EQUAL(CountOf(3, 3, 3), 2); - - // Checking comparison of different types. - UNIT_ASSERT_VALUES_EQUAL(CountOf(0x61, 'x', 'y', 'z'), 0); - UNIT_ASSERT_VALUES_EQUAL(CountOf(0x61, 'a', 'b', 'c', 0x61), 2); - UNIT_ASSERT_VALUES_EQUAL(CountOf(0x61, 'a', 'b', 'c', 0x61ll), 2); - + Y_UNIT_TEST(CountOfTest) { + UNIT_ASSERT_VALUES_EQUAL(CountOf(1, 2), 0); + UNIT_ASSERT_VALUES_EQUAL(CountOf(1, 1), 1); + UNIT_ASSERT_VALUES_EQUAL(CountOf(2, 4, 5), 0); + UNIT_ASSERT_VALUES_EQUAL(CountOf(2, 4, 2), 1); + UNIT_ASSERT_VALUES_EQUAL(CountOf(3, 3, 3), 2); + + // Checking comparison of different types. + UNIT_ASSERT_VALUES_EQUAL(CountOf(0x61, 'x', 'y', 'z'), 0); + UNIT_ASSERT_VALUES_EQUAL(CountOf(0x61, 'a', 'b', 'c', 0x61), 2); + UNIT_ASSERT_VALUES_EQUAL(CountOf(0x61, 'a', 'b', 'c', 0x61ll), 2); + // TString and const char * UNIT_ASSERT_VALUES_EQUAL(CountOf(TString("xyz"), "123", "poi"), 0); UNIT_ASSERT_VALUES_EQUAL(CountOf(TString("xyz"), "123", "poi", "xyz"), 1); - + // TString and TStringBuf UNIT_ASSERT_VALUES_EQUAL(CountOf(TString("xyz"), TStringBuf("123"), TStringBuf("poi")), 0); UNIT_ASSERT_VALUES_EQUAL(CountOf(TString("xyz"), TStringBuf("123"), TStringBuf("poi"), TStringBuf("xyz")), 1); - - // TStringBuf and const char * + + // TStringBuf and const char * UNIT_ASSERT_VALUES_EQUAL(CountOf(TStringBuf("xyz"), "123", "poi"), 0); UNIT_ASSERT_VALUES_EQUAL(CountOf(TStringBuf("xyz"), "123", "poi", "xyz"), 1); - + // TStringBuf and TString UNIT_ASSERT_VALUES_EQUAL(CountOf(TStringBuf("xyz"), TString("123"), TString("poi")), 0); UNIT_ASSERT_VALUES_EQUAL(CountOf(TStringBuf("xyz"), TString("123"), TString("poi"), TString("xyz")), 1); - } - - Y_UNIT_TEST(EqualToOneOfTest) { + } + + Y_UNIT_TEST(EqualToOneOfTest) { UNIT_ASSERT(1 == EqualToOneOf(1, 1, 2)); UNIT_ASSERT(1 == EqualToOneOf(2, 1, 2)); UNIT_ASSERT(0 == EqualToOneOf(3, 1, 2)); @@ -141,7 +141,7 @@ Y_UNIT_TEST_SUITE(TAlgorithm) { template <class TTestConstPtr> void TestFindIfPtrFoundValue(int j, TTestConstPtr root) { if (j == 3) { - UNIT_ASSERT(root == nullptr); + UNIT_ASSERT(root == nullptr); } else if (j == 4) { UNIT_ASSERT(root && *root == 2); } else { @@ -203,7 +203,7 @@ Y_UNIT_TEST_SUITE(TAlgorithm) { } } - Y_UNIT_TEST(FindIndexTest) { + Y_UNIT_TEST(FindIndexTest) { TVectorNoCopy v; v.push_back(1); v.push_back(2); @@ -247,7 +247,7 @@ Y_UNIT_TEST_SUITE(TAlgorithm) { UNIT_ASSERT_EQUAL(NPOS, FindIndexIf(empty, [](int x) { return x == 3; })); } - Y_UNIT_TEST(SortUniqueTest) { + Y_UNIT_TEST(SortUniqueTest) { { TVector<TString> v; SortUnique(v); @@ -266,21 +266,21 @@ Y_UNIT_TEST_SUITE(TAlgorithm) { } } - Y_UNIT_TEST(EraseTest) { + Y_UNIT_TEST(EraseTest) { TVector<int> data = {5, 4, 3, 2, 1, 0}; TVector<int> expected = {5, 4, 2, 1, 0}; Erase(data, 3); UNIT_ASSERT_EQUAL(data, expected); } - Y_UNIT_TEST(EraseIfTest) { + Y_UNIT_TEST(EraseIfTest) { TVector<int> data = {5, 4, 3, 2, 1, 0}; TVector<int> expected = {2, 1, 0}; EraseIf(data, [](int i) { return i >= 3; }); UNIT_ASSERT_EQUAL(data, expected); } - Y_UNIT_TEST(EraseNodesIfTest) { + Y_UNIT_TEST(EraseNodesIfTest) { TMap<int, int> map{{1, 1}, {2, 2}, {3, 5}}; TMap<int, int> expectedMap{{1, 1}}; EraseNodesIf(map, [](auto p) { return p.first >= 2; }); @@ -312,7 +312,7 @@ Y_UNIT_TEST_SUITE(TAlgorithm) { UNIT_ASSERT_EQUAL(hashMultiMap, expectedHashMultiMap); } - Y_UNIT_TEST(NthElementTest) { + Y_UNIT_TEST(NthElementTest) { { TVector<TString> v; NthElement(v.begin(), v.begin(), v.end()); @@ -348,7 +348,7 @@ Y_UNIT_TEST_SUITE(TAlgorithm) { } } - Y_UNIT_TEST(BinarySearchTest) { + Y_UNIT_TEST(BinarySearchTest) { { TVector<TString> v; bool test = BinarySearch(v.begin(), v.end(), "test"); @@ -358,10 +358,10 @@ Y_UNIT_TEST_SUITE(TAlgorithm) { { int data[] = {1, 2, 3, 4, 5, 6, 7, 8, 9}; - bool test = BinarySearch(data, data + Y_ARRAY_SIZE(data), 2); + bool test = BinarySearch(data, data + Y_ARRAY_SIZE(data), 2); UNIT_ASSERT_EQUAL(test, true); - test = BinarySearch(data, data + Y_ARRAY_SIZE(data), 10); + test = BinarySearch(data, data + Y_ARRAY_SIZE(data), 10); UNIT_ASSERT_EQUAL(test, false); } @@ -379,7 +379,7 @@ Y_UNIT_TEST_SUITE(TAlgorithm) { } } - Y_UNIT_TEST(EqualRangeTest) { + Y_UNIT_TEST(EqualRangeTest) { { TVector<TString> v; using PairOfVector = std::pair<TVector<TString>::iterator, TVector<TString>::iterator>; @@ -392,11 +392,11 @@ Y_UNIT_TEST_SUITE(TAlgorithm) { { int data[] = {1, 1, 1, 1, 1, 2, 2, 3, 3, 3, 3, 4, 5}; using PairOfInt = std::pair<int*, int*>; - PairOfInt tmp = EqualRange(data, data + Y_ARRAY_SIZE(data), 3); + PairOfInt tmp = EqualRange(data, data + Y_ARRAY_SIZE(data), 3); UNIT_ASSERT_EQUAL(tmp.second - tmp.first, 4); UNIT_ASSERT_EQUAL(tmp.first - data, 7); - UNIT_ASSERT_EQUAL(data + Y_ARRAY_SIZE(data) - tmp.second, 2); + UNIT_ASSERT_EQUAL(data + Y_ARRAY_SIZE(data) - tmp.second, 2); } { @@ -416,7 +416,7 @@ Y_UNIT_TEST_SUITE(TAlgorithm) { } } - Y_UNIT_TEST(IsSortedTest) { + Y_UNIT_TEST(IsSortedTest) { TVector<int> v0; UNIT_ASSERT_VALUES_EQUAL(IsSorted(v0.begin(), v0.end()), true); @@ -445,91 +445,91 @@ Y_UNIT_TEST_SUITE(TAlgorithm) { UNIT_ASSERT_VALUES_EQUAL(IsSortedBy(v3.begin(), v3.end(), std::negate<int>()), false); } - Y_UNIT_TEST(SortTestTwoIterators) { + Y_UNIT_TEST(SortTestTwoIterators) { TVector<int> collection = {10, 2, 7}; Sort(collection.begin(), collection.end()); TVector<int> expected = {2, 7, 10}; UNIT_ASSERT_VALUES_EQUAL(collection, expected); } - Y_UNIT_TEST(SortTestTwoIteratorsAndComparator) { + Y_UNIT_TEST(SortTestTwoIteratorsAndComparator) { TVector<int> collection = {10, 2, 7}; Sort(collection.begin(), collection.end(), [](int l, int r) { return l > r; }); TVector<int> expected = {10, 7, 2}; UNIT_ASSERT_VALUES_EQUAL(collection, expected); } - Y_UNIT_TEST(SortTestContainer) { + Y_UNIT_TEST(SortTestContainer) { TVector<int> collection = {10, 2, 7}; Sort(collection); TVector<int> expected = {2, 7, 10}; UNIT_ASSERT_VALUES_EQUAL(collection, expected); } - Y_UNIT_TEST(SortTestContainerAndComparator) { + Y_UNIT_TEST(SortTestContainerAndComparator) { TVector<int> collection = {10, 2, 7}; Sort(collection, [](int l, int r) { return l > r; }); TVector<int> expected = {10, 7, 2}; UNIT_ASSERT_VALUES_EQUAL(collection, expected); } - Y_UNIT_TEST(StableSortTestTwoIterators) { + Y_UNIT_TEST(StableSortTestTwoIterators) { TVector<int> collection = {10, 2, 7}; StableSort(collection.begin(), collection.end()); TVector<int> expected = {2, 7, 10}; UNIT_ASSERT_VALUES_EQUAL(collection, expected); } - Y_UNIT_TEST(StableSortTestTwoIteratorsAndComparator) { + Y_UNIT_TEST(StableSortTestTwoIteratorsAndComparator) { TVector<int> collection = {404, 101, 106, 203, 102, 205, 401}; StableSort(collection.begin(), collection.end(), [](int l, int r) { return (l / 100) < (r / 100); }); TVector<int> expected = {101, 106, 102, 203, 205, 404, 401}; UNIT_ASSERT_VALUES_EQUAL(collection, expected); } - Y_UNIT_TEST(StableSortTestContainer) { + Y_UNIT_TEST(StableSortTestContainer) { TVector<int> collection = {10, 2, 7}; StableSort(collection); TVector<int> expected = {2, 7, 10}; UNIT_ASSERT_VALUES_EQUAL(collection, expected); } - Y_UNIT_TEST(StableSortTestContainerAndComparator) { + Y_UNIT_TEST(StableSortTestContainerAndComparator) { TVector<int> collection = {404, 101, 106, 203, 102, 205, 401}; StableSort(collection, [](int l, int r) { return (l / 100) < (r / 100); }); TVector<int> expected = {101, 106, 102, 203, 205, 404, 401}; UNIT_ASSERT_VALUES_EQUAL(collection, expected); } - Y_UNIT_TEST(SortByTest) { + Y_UNIT_TEST(SortByTest) { TVector<int> collection = {10, 2, 7}; SortBy(collection, [](int x) { return -x; }); TVector<int> expected = {10, 7, 2}; UNIT_ASSERT_VALUES_EQUAL(collection, expected); } - Y_UNIT_TEST(StableSortByTest) { + Y_UNIT_TEST(StableSortByTest) { TVector<int> collection = {404, 101, 106, 203, 102, 205, 401}; StableSortBy(collection, [](int x) { return x / 100; }); TVector<int> expected = {101, 106, 102, 203, 205, 404, 401}; UNIT_ASSERT_VALUES_EQUAL(collection, expected); } - Y_UNIT_TEST(SortUniqueByTest) { + Y_UNIT_TEST(SortUniqueByTest) { TVector<int> collection = {404, 101, 101, 203, 101, 203, 404}; StableSortUniqueBy(collection, [](int x) { return x / 100; }); TVector<int> expected = {101, 203, 404}; UNIT_ASSERT_VALUES_EQUAL(collection, expected); } - Y_UNIT_TEST(StableSortUniqueByTest) { + Y_UNIT_TEST(StableSortUniqueByTest) { TVector<int> collection = {404, 101, 106, 203, 102, 205, 401}; StableSortUniqueBy(collection, [](int x) { return x / 100; }); TVector<int> expected = {101, 203, 404}; UNIT_ASSERT_VALUES_EQUAL(collection, expected); } - Y_UNIT_TEST(IotaTest) { + Y_UNIT_TEST(IotaTest) { TVector<int> v(10); Iota(v.begin(), v.end(), 0); @@ -543,7 +543,7 @@ Y_UNIT_TEST_SUITE(TAlgorithm) { UNIT_ASSERT_VALUES_EQUAL(v[9], 9); } - Y_UNIT_TEST(CopyNTest) { + Y_UNIT_TEST(CopyNTest) { int data[] = {1, 2, 3, 4, 8, 7, 6, 5}; const size_t vSize = 10; TVector<int> result(10, 0); @@ -575,7 +575,7 @@ Y_UNIT_TEST_SUITE(TAlgorithm) { } } - Y_UNIT_TEST(CopyIfTest) { + Y_UNIT_TEST(CopyIfTest) { const size_t count = 9; int data[] = {1, 2, 3, 4, 5, 6, 7, 8, 9}; const size_t vSize = 10; @@ -590,7 +590,7 @@ Y_UNIT_TEST_SUITE(TAlgorithm) { } } - Y_UNIT_TEST(MinMaxElementTest) { + Y_UNIT_TEST(MinMaxElementTest) { TVector<int> v(10); Iota(v.begin(), v.end(), 0); UNIT_ASSERT_EQUAL(*MinMaxElement(v.begin(), v.end()).first, 0); @@ -602,7 +602,7 @@ Y_UNIT_TEST_SUITE(TAlgorithm) { UNIT_ASSERT_EQUAL(*MinMaxElement(v.begin(), v.end()).second, 11); } - Y_UNIT_TEST(MinMaxTest) { + Y_UNIT_TEST(MinMaxTest) { std::pair<int, int> p1 = MinMax(5, 12); UNIT_ASSERT_EQUAL(p1.first, 5); UNIT_ASSERT_EQUAL(p1.second, 12); @@ -612,7 +612,7 @@ Y_UNIT_TEST_SUITE(TAlgorithm) { UNIT_ASSERT_EQUAL(p2.second, TString("test")); } - Y_UNIT_TEST(TestMaxElementBy) { + Y_UNIT_TEST(TestMaxElementBy) { const int array[] = {1, 2, 5, 3, 4, 5}; UNIT_ASSERT_VALUES_EQUAL(*MaxElementBy(array, [](int x) { return x * x; @@ -638,7 +638,7 @@ Y_UNIT_TEST_SUITE(TAlgorithm) { UNIT_ASSERT_STRINGS_EQUAL(*MaxElementBy(strings, [](TString s) { return s.size(); }), "three"); } - Y_UNIT_TEST(TestMinElementBy) { + Y_UNIT_TEST(TestMinElementBy) { const int array[] = {2, 3, 4, 1, 5}; UNIT_ASSERT_VALUES_EQUAL(*MinElementBy(array, [](int x) -> char { return 'a' + x; @@ -668,12 +668,12 @@ Y_UNIT_TEST_SUITE(TAlgorithm) { UNIT_ASSERT_STRINGS_EQUAL(*MinElementBy(strings.rbegin(), strings.rend(), stringLength), "two"); } - Y_UNIT_TEST(MaxElementByReturnsEndForEmptyRange) { + Y_UNIT_TEST(MaxElementByReturnsEndForEmptyRange) { const TVector<int> empty; UNIT_ASSERT_EQUAL(MaxElementBy(empty, [](int) { return 0; }), empty.end()); } - Y_UNIT_TEST(MaxElementByDoesntCallFunctorForEmptyRange) { + Y_UNIT_TEST(MaxElementByDoesntCallFunctorForEmptyRange) { const TVector<int> empty; auto functor = [](int) { UNIT_ASSERT(false); @@ -682,12 +682,12 @@ Y_UNIT_TEST_SUITE(TAlgorithm) { MaxElementBy(empty, functor); } - Y_UNIT_TEST(MinElementByReturnsEndForEmptyRange) { + Y_UNIT_TEST(MinElementByReturnsEndForEmptyRange) { const TVector<int> empty; UNIT_ASSERT_EQUAL(MinElementBy(empty, [](int) { return 0; }), empty.end()); } - Y_UNIT_TEST(MinElementByDoesntCallFunctorForEmptyRange) { + Y_UNIT_TEST(MinElementByDoesntCallFunctorForEmptyRange) { const TVector<int> empty; auto functor = [](int) { UNIT_ASSERT(false); @@ -756,7 +756,7 @@ Y_UNIT_TEST_SUITE(TAlgorithm) { } } - Y_UNIT_TEST(FindIfForContainer) { + Y_UNIT_TEST(FindIfForContainer) { using std::begin; using std::end; @@ -790,14 +790,14 @@ Y_UNIT_TEST_SUITE(TAlgorithm) { return &r + 1; } - Y_UNIT_TEST(FindIfForUserType) { + Y_UNIT_TEST(FindIfForUserType) { // Compileability test. Should work for user types with begin/end overloads TRange range; auto i = FindIf(range, [](auto) { return false; }); Y_UNUSED(i); } - Y_UNIT_TEST(TestLowerBoundBy) { + Y_UNIT_TEST(TestLowerBoundBy) { using TIntPairs = TVector<std::pair<i32, i32>>; auto data = TIntPairs{{1, 5}, {3, 2}, {3, 4}, {8, 0}, {5, 4}}; @@ -817,7 +817,7 @@ Y_UNIT_TEST_SUITE(TAlgorithm) { UNIT_ASSERT_EQUAL((it + 1)->second, 4); } - Y_UNIT_TEST(TestUpperBoundBy) { + Y_UNIT_TEST(TestUpperBoundBy) { using TIntPairs = TVector<std::pair<i32, i32>>; auto data = TIntPairs{{1, 5}, {3, 2}, {3, 4}, {8, 0}, {5, 4}}; @@ -836,7 +836,7 @@ Y_UNIT_TEST_SUITE(TAlgorithm) { UNIT_ASSERT((it + 1) == data.end()); } - Y_UNIT_TEST(TestFindInContainer) { + Y_UNIT_TEST(TestFindInContainer) { std::vector<int> v = {1, 2, 1000, 15, 100}; UNIT_ASSERT(Find(v, 5) == v.end()); UNIT_ASSERT(Find(v, 1) == v.begin()); diff --git a/util/generic/array_ref.h b/util/generic/array_ref.h index 1ac60ac7d3c..ae3eff8e19b 100644 --- a/util/generic/array_ref.h +++ b/util/generic/array_ref.h @@ -259,16 +259,16 @@ constexpr TArrayRef<typename Range::value_type> MakeArrayRef(Range& range) { return TArrayRef<typename Range::value_type>(range); } -template <class Range> -constexpr TArrayRef<const typename Range::value_type> MakeConstArrayRef(const Range& range) { - return TArrayRef<const typename Range::value_type>(range); -} - -template <class Range> -constexpr TArrayRef<const typename Range::value_type> MakeConstArrayRef(Range& range) { - return TArrayRef<const typename Range::value_type>(range); -} - +template <class Range> +constexpr TArrayRef<const typename Range::value_type> MakeConstArrayRef(const Range& range) { + return TArrayRef<const typename Range::value_type>(range); +} + +template <class Range> +constexpr TArrayRef<const typename Range::value_type> MakeConstArrayRef(Range& range) { + return TArrayRef<const typename Range::value_type>(range); +} + template <class T> constexpr TArrayRef<T> MakeArrayRef(T* data, size_t size) { return TArrayRef<T>(data, size); diff --git a/util/generic/array_ref_ut.cpp b/util/generic/array_ref_ut.cpp index 4c8eaf7135a..33ae908a712 100644 --- a/util/generic/array_ref_ut.cpp +++ b/util/generic/array_ref_ut.cpp @@ -2,7 +2,7 @@ #include <library/cpp/testing/unittest/registar.h> -Y_UNIT_TEST_SUITE(TestArrayRef) { +Y_UNIT_TEST_SUITE(TestArrayRef) { Y_UNIT_TEST(TestDefaultConstructor) { TArrayRef<int> defaulted; UNIT_ASSERT_VALUES_EQUAL(defaulted.data(), nullptr); @@ -195,7 +195,7 @@ Y_UNIT_TEST_SUITE(TestArrayRef) { UNIT_ASSERT_EQUAL(aRef.subspan(1, 3), MakeArrayRef(std::vector<int>{2, 3, 4})); } - Y_UNIT_TEST(TestSlice) { + Y_UNIT_TEST(TestSlice) { const int a0[] = {1, 2, 3}; TArrayRef<const int> r0(a0); TArrayRef<const int> s0 = r0.Slice(2); @@ -278,7 +278,7 @@ Y_UNIT_TEST_SUITE(TestArrayRef) { a[0] = 8; } - Y_UNIT_TEST(TestConst) { + Y_UNIT_TEST(TestConst) { int a[] = {1, 2}; Do(a); UNIT_ASSERT_VALUES_EQUAL(a[0], 8); @@ -298,25 +298,25 @@ Y_UNIT_TEST_SUITE(TestArrayRef) { static_assert(r2.size() == 4, "r2.size() is not equal to 4"); static_assert(r2.data()[2] == -3, "r2.data()[2] is not equal to -3"); } - - template <typename T> - static void Foo(const TConstArrayRef<T>) { - // noop - } - - Y_UNIT_TEST(TestMakeConstArrayRef) { - TVector<int> data; - - // Won't compile because can't deduce `T` for `Foo` - // Foo(data); - - // Won't compile because again can't deduce `T` for `Foo` - // Foo(MakeArrayRef(data)); - - // Success! - Foo(MakeConstArrayRef(data)); - - const TVector<int> constData; - Foo(MakeConstArrayRef(constData)); - } + + template <typename T> + static void Foo(const TConstArrayRef<T>) { + // noop + } + + Y_UNIT_TEST(TestMakeConstArrayRef) { + TVector<int> data; + + // Won't compile because can't deduce `T` for `Foo` + // Foo(data); + + // Won't compile because again can't deduce `T` for `Foo` + // Foo(MakeArrayRef(data)); + + // Success! + Foo(MakeConstArrayRef(data)); + + const TVector<int> constData; + Foo(MakeConstArrayRef(constData)); + } } diff --git a/util/generic/array_size.h b/util/generic/array_size.h index 4d5f18ce631..a56944b4aec 100644 --- a/util/generic/array_size.h +++ b/util/generic/array_size.h @@ -21,4 +21,4 @@ namespace NArraySizePrivate { }; } -#define Y_ARRAY_SIZE(arr) ((size_t)::NArraySizePrivate::TArraySize<decltype(arr)>::Result) +#define Y_ARRAY_SIZE(arr) ((size_t)::NArraySizePrivate::TArraySize<decltype(arr)>::Result) diff --git a/util/generic/array_size_ut.cpp b/util/generic/array_size_ut.cpp index 13f45903c51..b3243425a91 100644 --- a/util/generic/array_size_ut.cpp +++ b/util/generic/array_size_ut.cpp @@ -2,21 +2,21 @@ #include <library/cpp/testing/unittest/registar.h> -Y_UNIT_TEST_SUITE(ArraySizeTest) { - Y_UNIT_TEST(Test1) { +Y_UNIT_TEST_SUITE(ArraySizeTest) { + Y_UNIT_TEST(Test1) { int x[100]; - Y_UNUSED(x); /* Make MSVC happy. */ + Y_UNUSED(x); /* Make MSVC happy. */ - UNIT_ASSERT_VALUES_EQUAL(Y_ARRAY_SIZE(x), 100); + UNIT_ASSERT_VALUES_EQUAL(Y_ARRAY_SIZE(x), 100); } - Y_UNIT_TEST(Test2) { + Y_UNIT_TEST(Test2) { struct T { }; T x[1]; - Y_UNUSED(x); /* Make MSVC happy. */ + Y_UNUSED(x); /* Make MSVC happy. */ - UNIT_ASSERT_VALUES_EQUAL(Y_ARRAY_SIZE(x), 1); + UNIT_ASSERT_VALUES_EQUAL(Y_ARRAY_SIZE(x), 1); } } diff --git a/util/generic/benchmark/fastclp2/main.cpp b/util/generic/benchmark/fastclp2/main.cpp index 49277db077c..69bf1dc960f 100644 --- a/util/generic/benchmark/fastclp2/main.cpp +++ b/util/generic/benchmark/fastclp2/main.cpp @@ -1,50 +1,50 @@ #include <library/cpp/testing/benchmark/bench.h> - -#include <util/generic/bitops.h> -#include <util/generic/vector.h> -#include <util/generic/xrange.h> -#include <util/generic/singleton.h> - -#include <util/random/fast.h> - -namespace { - template <typename T, size_t N> - struct TExamplesHolder { - TExamplesHolder() + +#include <util/generic/bitops.h> +#include <util/generic/vector.h> +#include <util/generic/xrange.h> +#include <util/generic/singleton.h> + +#include <util/random/fast.h> + +namespace { + template <typename T, size_t N> + struct TExamplesHolder { + TExamplesHolder() : Examples(N) { - TFastRng<ui64> prng{42u * sizeof(T) * N}; - for (auto& x : Examples) { - x = prng(); - } - } - + TFastRng<ui64> prng{42u * sizeof(T) * N}; + for (auto& x : Examples) { + x = prng(); + } + } + TVector<T> Examples; - }; -} - + }; +} + #define DEFINE_BENCHMARK(type, count) \ - Y_CPU_BENCHMARK(FastClp2_##type##_##count, iface) { \ - const auto& examples = Default<TExamplesHolder<type, count>>().Examples; \ - for (const auto i : xrange(iface.Iterations())) { \ - Y_UNUSED(i); \ - for (const auto e : examples) { \ - Y_DO_NOT_OPTIMIZE_AWAY(FastClp2(e)); \ - } \ - } \ - } - -DEFINE_BENCHMARK(ui8, 1) -DEFINE_BENCHMARK(ui8, 10) -DEFINE_BENCHMARK(ui8, 100) -DEFINE_BENCHMARK(ui16, 1) -DEFINE_BENCHMARK(ui16, 10) -DEFINE_BENCHMARK(ui16, 100) -DEFINE_BENCHMARK(ui32, 1) -DEFINE_BENCHMARK(ui32, 10) -DEFINE_BENCHMARK(ui32, 100) -DEFINE_BENCHMARK(ui64, 1) -DEFINE_BENCHMARK(ui64, 10) -DEFINE_BENCHMARK(ui64, 100) - -#undef DEFINE_BENCHMARKS + Y_CPU_BENCHMARK(FastClp2_##type##_##count, iface) { \ + const auto& examples = Default<TExamplesHolder<type, count>>().Examples; \ + for (const auto i : xrange(iface.Iterations())) { \ + Y_UNUSED(i); \ + for (const auto e : examples) { \ + Y_DO_NOT_OPTIMIZE_AWAY(FastClp2(e)); \ + } \ + } \ + } + +DEFINE_BENCHMARK(ui8, 1) +DEFINE_BENCHMARK(ui8, 10) +DEFINE_BENCHMARK(ui8, 100) +DEFINE_BENCHMARK(ui16, 1) +DEFINE_BENCHMARK(ui16, 10) +DEFINE_BENCHMARK(ui16, 100) +DEFINE_BENCHMARK(ui32, 1) +DEFINE_BENCHMARK(ui32, 10) +DEFINE_BENCHMARK(ui32, 100) +DEFINE_BENCHMARK(ui64, 1) +DEFINE_BENCHMARK(ui64, 10) +DEFINE_BENCHMARK(ui64, 100) + +#undef DEFINE_BENCHMARKS diff --git a/util/generic/benchmark/fastclp2/metrics/main.py b/util/generic/benchmark/fastclp2/metrics/main.py index 5573c6a5d7f..4baa3fe2564 100644 --- a/util/generic/benchmark/fastclp2/metrics/main.py +++ b/util/generic/benchmark/fastclp2/metrics/main.py @@ -1,5 +1,5 @@ -import yatest.common as yc - - -def test_export_metrics(metrics): +import yatest.common as yc + + +def test_export_metrics(metrics): metrics.set_benchmark(yc.execute_benchmark('util/generic/benchmark/fastclp2/fastclp2', threads=8)) diff --git a/util/generic/benchmark/fastclp2/metrics/ya.make b/util/generic/benchmark/fastclp2/metrics/ya.make index b2d17ebad34..9411e3d5d54 100644 --- a/util/generic/benchmark/fastclp2/metrics/ya.make +++ b/util/generic/benchmark/fastclp2/metrics/ya.make @@ -1,21 +1,21 @@ -OWNER( - yazevnul +OWNER( + yazevnul g:util -) +) SUBSCRIBER(g:util-subscribers) - + PY2TEST() - + SIZE(LARGE) - -TAG( + +TAG( ya:force_sandbox - sb:intel_e5_2660v1 + sb:intel_e5_2660v1 ya:fat -) - +) + TEST_SRCS(main.py) - + DEPENDS(util/generic/benchmark/fastclp2) - -END() + +END() diff --git a/util/generic/benchmark/fastclp2/ya.make b/util/generic/benchmark/fastclp2/ya.make index 976977014f6..a475d0c67fe 100644 --- a/util/generic/benchmark/fastclp2/ya.make +++ b/util/generic/benchmark/fastclp2/ya.make @@ -1,13 +1,13 @@ -OWNER( - yazevnul +OWNER( + yazevnul g:util -) +) SUBSCRIBER(g:util-subscribers) - + Y_BENCHMARK() - -SRCS( - main.cpp -) - -END() + +SRCS( + main.cpp +) + +END() diff --git a/util/generic/benchmark/log2/main.cpp b/util/generic/benchmark/log2/main.cpp index 969f09a3090..a5490aba674 100644 --- a/util/generic/benchmark/log2/main.cpp +++ b/util/generic/benchmark/log2/main.cpp @@ -1,30 +1,30 @@ #include <library/cpp/testing/benchmark/bench.h> - + #include <library/cpp/fast_log/fast_log.h> - -#include <util/generic/singleton.h> -#include <util/generic/vector.h> -#include <util/random/fast.h> -#include <util/generic/xrange.h> - -#include <cmath> -namespace { - template <typename T, size_t N> - struct TExamplesHolder { + +#include <util/generic/singleton.h> +#include <util/generic/vector.h> +#include <util/random/fast.h> +#include <util/generic/xrange.h> + +#include <cmath> +namespace { + template <typename T, size_t N> + struct TExamplesHolder { TVector<T> Examples; - - TExamplesHolder() + + TExamplesHolder() : Examples(N) { - TFastRng<ui64> prng{N * 42}; - for (auto& x : Examples) { - x = prng.GenRandReal4() + prng.Uniform(1932); // 1934 is just a random number - } - } - }; -} - -#define DEFINE_BENCHMARK(type, count) \ + TFastRng<ui64> prng{N * 42}; + for (auto& x : Examples) { + x = prng.GenRandReal4() + prng.Uniform(1932); // 1934 is just a random number + } + } + }; +} + +#define DEFINE_BENCHMARK(type, count) \ Y_CPU_BENCHMARK(libm_log2f_##type##_##count, iface) { \ const auto& examples = Default<TExamplesHolder<type, count>>().Examples; \ for (const auto i : xrange(iface.Iterations())) { \ @@ -44,64 +44,64 @@ namespace { } \ } \ } \ - Y_CPU_BENCHMARK(STL_Log2_##type##_##count, iface) { \ - const auto& examples = Default<TExamplesHolder<type, count>>().Examples; \ - for (const auto i : xrange(iface.Iterations())) { \ - Y_UNUSED(i); \ - for (const auto e : examples) { \ - Y_DO_NOT_OPTIMIZE_AWAY(std::log2(e)); \ - } \ - } \ - } \ - \ - Y_CPU_BENCHMARK(STL_Log_##type##_##count, iface) { \ - const auto& examples = Default<TExamplesHolder<type, count>>().Examples; \ - for (const auto i : xrange(iface.Iterations())) { \ - Y_UNUSED(i); \ - for (const auto e : examples) { \ - Y_DO_NOT_OPTIMIZE_AWAY(std::log(e)); \ - } \ - } \ - } \ - \ - Y_CPU_BENCHMARK(Fast_Log2_##type##_##count, iface) { \ - const auto& examples = Default<TExamplesHolder<type, count>>().Examples; \ - for (const auto i : xrange(iface.Iterations())) { \ - Y_UNUSED(i); \ - for (const auto e : examples) { \ - Y_DO_NOT_OPTIMIZE_AWAY(FastLog2f(e)); \ - } \ - } \ - } \ - \ + Y_CPU_BENCHMARK(STL_Log2_##type##_##count, iface) { \ + const auto& examples = Default<TExamplesHolder<type, count>>().Examples; \ + for (const auto i : xrange(iface.Iterations())) { \ + Y_UNUSED(i); \ + for (const auto e : examples) { \ + Y_DO_NOT_OPTIMIZE_AWAY(std::log2(e)); \ + } \ + } \ + } \ + \ + Y_CPU_BENCHMARK(STL_Log_##type##_##count, iface) { \ + const auto& examples = Default<TExamplesHolder<type, count>>().Examples; \ + for (const auto i : xrange(iface.Iterations())) { \ + Y_UNUSED(i); \ + for (const auto e : examples) { \ + Y_DO_NOT_OPTIMIZE_AWAY(std::log(e)); \ + } \ + } \ + } \ + \ + Y_CPU_BENCHMARK(Fast_Log2_##type##_##count, iface) { \ + const auto& examples = Default<TExamplesHolder<type, count>>().Examples; \ + for (const auto i : xrange(iface.Iterations())) { \ + Y_UNUSED(i); \ + for (const auto e : examples) { \ + Y_DO_NOT_OPTIMIZE_AWAY(FastLog2f(e)); \ + } \ + } \ + } \ + \ Y_CPU_BENCHMARK(FastLogf##type##_##count, iface) { \ - const auto& examples = Default<TExamplesHolder<type, count>>().Examples; \ - for (const auto i : xrange(iface.Iterations())) { \ - Y_UNUSED(i); \ - for (const auto e : examples) { \ - Y_DO_NOT_OPTIMIZE_AWAY(FastLogf(e)); \ - } \ - } \ - } \ - \ - Y_CPU_BENCHMARK(Faster_Log2_##type##_##count, iface) { \ - const auto& examples = Default<TExamplesHolder<type, count>>().Examples; \ - for (const auto i : xrange(iface.Iterations())) { \ - Y_UNUSED(i); \ - for (const auto e : examples) { \ + const auto& examples = Default<TExamplesHolder<type, count>>().Examples; \ + for (const auto i : xrange(iface.Iterations())) { \ + Y_UNUSED(i); \ + for (const auto e : examples) { \ + Y_DO_NOT_OPTIMIZE_AWAY(FastLogf(e)); \ + } \ + } \ + } \ + \ + Y_CPU_BENCHMARK(Faster_Log2_##type##_##count, iface) { \ + const auto& examples = Default<TExamplesHolder<type, count>>().Examples; \ + for (const auto i : xrange(iface.Iterations())) { \ + Y_UNUSED(i); \ + for (const auto e : examples) { \ Y_DO_NOT_OPTIMIZE_AWAY(FasterLog2f(e)); \ - } \ - } \ - } \ - \ - Y_CPU_BENCHMARK(Faster_Log_##type##_##count, iface) { \ - const auto& examples = Default<TExamplesHolder<type, count>>().Examples; \ - for (const auto i : xrange(iface.Iterations())) { \ - Y_UNUSED(i); \ - for (const auto e : examples) { \ + } \ + } \ + } \ + \ + Y_CPU_BENCHMARK(Faster_Log_##type##_##count, iface) { \ + const auto& examples = Default<TExamplesHolder<type, count>>().Examples; \ + for (const auto i : xrange(iface.Iterations())) { \ + Y_UNUSED(i); \ + for (const auto e : examples) { \ Y_DO_NOT_OPTIMIZE_AWAY(FasterLogf(e)); \ - } \ - } \ + } \ + } \ } \ \ Y_CPU_BENCHMARK(Fastest_Log2f_##type##_##count, iface) { \ @@ -122,19 +122,19 @@ namespace { Y_DO_NOT_OPTIMIZE_AWAY(FastestLogf(e)); \ } \ } \ - } - -DEFINE_BENCHMARK(float, 1) -DEFINE_BENCHMARK(float, 2) -DEFINE_BENCHMARK(float, 4) -DEFINE_BENCHMARK(float, 8) -DEFINE_BENCHMARK(float, 16) -DEFINE_BENCHMARK(float, 32) -DEFINE_BENCHMARK(float, 64) -DEFINE_BENCHMARK(float, 128) -DEFINE_BENCHMARK(float, 256) -DEFINE_BENCHMARK(float, 1024) -DEFINE_BENCHMARK(float, 2048) -DEFINE_BENCHMARK(float, 4096) - -#undef DEFINE_BENCHMARK + } + +DEFINE_BENCHMARK(float, 1) +DEFINE_BENCHMARK(float, 2) +DEFINE_BENCHMARK(float, 4) +DEFINE_BENCHMARK(float, 8) +DEFINE_BENCHMARK(float, 16) +DEFINE_BENCHMARK(float, 32) +DEFINE_BENCHMARK(float, 64) +DEFINE_BENCHMARK(float, 128) +DEFINE_BENCHMARK(float, 256) +DEFINE_BENCHMARK(float, 1024) +DEFINE_BENCHMARK(float, 2048) +DEFINE_BENCHMARK(float, 4096) + +#undef DEFINE_BENCHMARK diff --git a/util/generic/benchmark/log2/metrics/main.py b/util/generic/benchmark/log2/metrics/main.py index 26f6b57812b..873f17664cf 100644 --- a/util/generic/benchmark/log2/metrics/main.py +++ b/util/generic/benchmark/log2/metrics/main.py @@ -1,5 +1,5 @@ -import yatest.common as yc - - -def test_export_metrics(metrics): +import yatest.common as yc + + +def test_export_metrics(metrics): metrics.set_benchmark(yc.execute_benchmark('util/generic/benchmark/log2/log2', threads=8)) diff --git a/util/generic/benchmark/log2/metrics/ya.make b/util/generic/benchmark/log2/metrics/ya.make index eb987e38d25..5afd7de2003 100644 --- a/util/generic/benchmark/log2/metrics/ya.make +++ b/util/generic/benchmark/log2/metrics/ya.make @@ -1,21 +1,21 @@ -OWNER( - yazevnul +OWNER( + yazevnul g:util -) +) SUBSCRIBER(g:util-subscribers) - + PY2TEST() - + SIZE(LARGE) - -TAG( + +TAG( ya:force_sandbox - sb:intel_e5_2660v1 + sb:intel_e5_2660v1 ya:fat -) - +) + TEST_SRCS(main.py) - + DEPENDS(util/generic/benchmark/log2) - -END() + +END() diff --git a/util/generic/benchmark/log2/ya.make b/util/generic/benchmark/log2/ya.make index 45d751909ea..eeef80523ba 100644 --- a/util/generic/benchmark/log2/ya.make +++ b/util/generic/benchmark/log2/ya.make @@ -1,17 +1,17 @@ -OWNER( - yazevnul +OWNER( + yazevnul g:util -) +) SUBSCRIBER(g:util-subscribers) - + Y_BENCHMARK() - -SRCS( - main.cpp -) - -PEERDIR( + +SRCS( + main.cpp +) + +PEERDIR( library/cpp/fast_log -) - -END() +) + +END() diff --git a/util/generic/benchmark/rotate_bits/main.cpp b/util/generic/benchmark/rotate_bits/main.cpp index 057edbe864f..929d2c4ca92 100644 --- a/util/generic/benchmark/rotate_bits/main.cpp +++ b/util/generic/benchmark/rotate_bits/main.cpp @@ -1,66 +1,66 @@ #include <library/cpp/testing/benchmark/bench.h> - -#include <util/generic/vector.h> -#include <util/generic/xrange.h> -#include <util/generic/singleton.h> - -#include <util/random/fast.h> - -namespace { - template <typename T> - struct TExample { - T Value; - ui8 Shift; - }; - - template <typename T, size_t N> - struct TExamplesHolder { - TExamplesHolder() + +#include <util/generic/vector.h> +#include <util/generic/xrange.h> +#include <util/generic/singleton.h> + +#include <util/random/fast.h> + +namespace { + template <typename T> + struct TExample { + T Value; + ui8 Shift; + }; + + template <typename T, size_t N> + struct TExamplesHolder { + TExamplesHolder() : Examples(N) { - TFastRng<ui64> prng{42u * sizeof(T) * N}; - for (auto& e : Examples) { - e.Value = prng(); - e.Shift = prng() % (8 * sizeof(T)); - } - } - + TFastRng<ui64> prng{42u * sizeof(T) * N}; + for (auto& e : Examples) { + e.Value = prng(); + e.Shift = prng() % (8 * sizeof(T)); + } + } + TVector<TExample<T>> Examples; - }; -} - -#define DEFINE_BENCHMARKS_FOR_UNSIGNED_TYPES(type, count) \ - Y_CPU_BENCHMARK(LeftRotate_##type##_##count, iface) { \ - const auto& examples = Default<TExamplesHolder<type, count>>().Examples; \ - for (const auto i : xrange(iface.Iterations())) { \ - Y_UNUSED(i); \ - for (const auto e : examples) { \ - Y_DO_NOT_OPTIMIZE_AWAY(RotateBitsLeft(e.Value, e.Shift)); \ - } \ - } \ - } \ - \ - Y_CPU_BENCHMARK(RightRotate_##type##_##count, iface) { \ - const auto& examples = Default<TExamplesHolder<type, count>>().Examples; \ - for (const auto i : xrange(iface.Iterations())) { \ - Y_UNUSED(i); \ - for (const auto e : examples) { \ - Y_DO_NOT_OPTIMIZE_AWAY(RotateBitsRight(e.Value, e.Shift)); \ - } \ - } \ - } - -DEFINE_BENCHMARKS_FOR_UNSIGNED_TYPES(ui8, 1) -DEFINE_BENCHMARKS_FOR_UNSIGNED_TYPES(ui8, 10) -DEFINE_BENCHMARKS_FOR_UNSIGNED_TYPES(ui8, 100) -DEFINE_BENCHMARKS_FOR_UNSIGNED_TYPES(ui16, 1) -DEFINE_BENCHMARKS_FOR_UNSIGNED_TYPES(ui16, 10) -DEFINE_BENCHMARKS_FOR_UNSIGNED_TYPES(ui16, 100) -DEFINE_BENCHMARKS_FOR_UNSIGNED_TYPES(ui32, 1) -DEFINE_BENCHMARKS_FOR_UNSIGNED_TYPES(ui32, 10) -DEFINE_BENCHMARKS_FOR_UNSIGNED_TYPES(ui32, 100) -DEFINE_BENCHMARKS_FOR_UNSIGNED_TYPES(ui64, 1) -DEFINE_BENCHMARKS_FOR_UNSIGNED_TYPES(ui64, 10) -DEFINE_BENCHMARKS_FOR_UNSIGNED_TYPES(ui64, 100) - -#undef DEFINE_BENCHMARKS_FOR_UNSIGNED_TYPES + }; +} + +#define DEFINE_BENCHMARKS_FOR_UNSIGNED_TYPES(type, count) \ + Y_CPU_BENCHMARK(LeftRotate_##type##_##count, iface) { \ + const auto& examples = Default<TExamplesHolder<type, count>>().Examples; \ + for (const auto i : xrange(iface.Iterations())) { \ + Y_UNUSED(i); \ + for (const auto e : examples) { \ + Y_DO_NOT_OPTIMIZE_AWAY(RotateBitsLeft(e.Value, e.Shift)); \ + } \ + } \ + } \ + \ + Y_CPU_BENCHMARK(RightRotate_##type##_##count, iface) { \ + const auto& examples = Default<TExamplesHolder<type, count>>().Examples; \ + for (const auto i : xrange(iface.Iterations())) { \ + Y_UNUSED(i); \ + for (const auto e : examples) { \ + Y_DO_NOT_OPTIMIZE_AWAY(RotateBitsRight(e.Value, e.Shift)); \ + } \ + } \ + } + +DEFINE_BENCHMARKS_FOR_UNSIGNED_TYPES(ui8, 1) +DEFINE_BENCHMARKS_FOR_UNSIGNED_TYPES(ui8, 10) +DEFINE_BENCHMARKS_FOR_UNSIGNED_TYPES(ui8, 100) +DEFINE_BENCHMARKS_FOR_UNSIGNED_TYPES(ui16, 1) +DEFINE_BENCHMARKS_FOR_UNSIGNED_TYPES(ui16, 10) +DEFINE_BENCHMARKS_FOR_UNSIGNED_TYPES(ui16, 100) +DEFINE_BENCHMARKS_FOR_UNSIGNED_TYPES(ui32, 1) +DEFINE_BENCHMARKS_FOR_UNSIGNED_TYPES(ui32, 10) +DEFINE_BENCHMARKS_FOR_UNSIGNED_TYPES(ui32, 100) +DEFINE_BENCHMARKS_FOR_UNSIGNED_TYPES(ui64, 1) +DEFINE_BENCHMARKS_FOR_UNSIGNED_TYPES(ui64, 10) +DEFINE_BENCHMARKS_FOR_UNSIGNED_TYPES(ui64, 100) + +#undef DEFINE_BENCHMARKS_FOR_UNSIGNED_TYPES diff --git a/util/generic/benchmark/rotate_bits/metrics/main.py b/util/generic/benchmark/rotate_bits/metrics/main.py index b30555775f9..d752885779b 100644 --- a/util/generic/benchmark/rotate_bits/metrics/main.py +++ b/util/generic/benchmark/rotate_bits/metrics/main.py @@ -1,5 +1,5 @@ -import yatest.common as yc - - -def test_export_metrics(metrics): +import yatest.common as yc + + +def test_export_metrics(metrics): metrics.set_benchmark(yc.execute_benchmark('util/generic/benchmark/rotate_bits/rotate_bits', threads=8)) diff --git a/util/generic/benchmark/rotate_bits/metrics/ya.make b/util/generic/benchmark/rotate_bits/metrics/ya.make index ac27d2f845f..3bef9fae8a3 100644 --- a/util/generic/benchmark/rotate_bits/metrics/ya.make +++ b/util/generic/benchmark/rotate_bits/metrics/ya.make @@ -1,21 +1,21 @@ -OWNER( - yazevnul +OWNER( + yazevnul g:util -) +) SUBSCRIBER(g:util-subscribers) - + PY2TEST() - + SIZE(LARGE) - -TAG( + +TAG( ya:force_sandbox - sb:intel_e5_2660v1 + sb:intel_e5_2660v1 ya:fat -) - +) + TEST_SRCS(main.py) - + DEPENDS(util/generic/benchmark/rotate_bits) - -END() + +END() diff --git a/util/generic/benchmark/rotate_bits/ya.make b/util/generic/benchmark/rotate_bits/ya.make index 976977014f6..a475d0c67fe 100644 --- a/util/generic/benchmark/rotate_bits/ya.make +++ b/util/generic/benchmark/rotate_bits/ya.make @@ -1,13 +1,13 @@ -OWNER( - yazevnul +OWNER( + yazevnul g:util -) +) SUBSCRIBER(g:util-subscribers) - + Y_BENCHMARK() - -SRCS( - main.cpp -) - -END() + +SRCS( + main.cpp +) + +END() diff --git a/util/generic/benchmark/vector_count_ctor/f.cpp b/util/generic/benchmark/vector_count_ctor/f.cpp index b89e351ba72..e5d0a2ba25e 100644 --- a/util/generic/benchmark/vector_count_ctor/f.cpp +++ b/util/generic/benchmark/vector_count_ctor/f.cpp @@ -1,25 +1,25 @@ -#include "f.h" - +#include "f.h" + #include <library/cpp/testing/benchmark/bench.h> - -#include <util/generic/vector.h> -#include <util/generic/ptr.h> - -void CreateYvector(const size_t size, const size_t count) { - for (size_t i = 0; i < count; ++i) { - NBench::Clobber(); + +#include <util/generic/vector.h> +#include <util/generic/ptr.h> + +void CreateYvector(const size_t size, const size_t count) { + for (size_t i = 0; i < count; ++i) { + NBench::Clobber(); TVector<ui8> v(size); - NBench::Escape(v.data()); - NBench::Clobber(); - } -} - -void CreateCarray(const size_t size, const size_t count) { - for (size_t i = 0; i < count; ++i) { - NBench::Clobber(); - TArrayHolder<ui8> v(new ui8[size]); - memset(v.Get(), 0, size * sizeof(ui8)); - NBench::Escape(v.Get()); - NBench::Clobber(); - } -} + NBench::Escape(v.data()); + NBench::Clobber(); + } +} + +void CreateCarray(const size_t size, const size_t count) { + for (size_t i = 0; i < count; ++i) { + NBench::Clobber(); + TArrayHolder<ui8> v(new ui8[size]); + memset(v.Get(), 0, size * sizeof(ui8)); + NBench::Escape(v.Get()); + NBench::Clobber(); + } +} diff --git a/util/generic/benchmark/vector_count_ctor/f.h b/util/generic/benchmark/vector_count_ctor/f.h index a568341a456..c0b9e488032 100644 --- a/util/generic/benchmark/vector_count_ctor/f.h +++ b/util/generic/benchmark/vector_count_ctor/f.h @@ -1,9 +1,9 @@ -#pragma once - -#include <cstddef> - -// functions are declared in a separate translation unit so that compiler won't be able to see the -// value of `size` during compilation. - -void CreateYvector(const size_t size, const size_t count); -void CreateCarray(const size_t size, const size_t count); +#pragma once + +#include <cstddef> + +// functions are declared in a separate translation unit so that compiler won't be able to see the +// value of `size` during compilation. + +void CreateYvector(const size_t size, const size_t count); +void CreateCarray(const size_t size, const size_t count); diff --git a/util/generic/benchmark/vector_count_ctor/main.cpp b/util/generic/benchmark/vector_count_ctor/main.cpp index 6fb1fda9c94..715186b40a1 100644 --- a/util/generic/benchmark/vector_count_ctor/main.cpp +++ b/util/generic/benchmark/vector_count_ctor/main.cpp @@ -1,30 +1,30 @@ -#include "f.h" - +#include "f.h" + #include <library/cpp/testing/benchmark/bench.h> - -#define DEFINE_BENCHMARK(N) \ - Y_CPU_BENCHMARK(Yvector_##N, iface) { \ - CreateYvector(N, iface.Iterations()); \ - } \ - Y_CPU_BENCHMARK(Carray_##N, iface) { \ - CreateCarray(N, iface.Iterations()); \ - } - -DEFINE_BENCHMARK(1) -DEFINE_BENCHMARK(2) -DEFINE_BENCHMARK(8) -DEFINE_BENCHMARK(10) -DEFINE_BENCHMARK(16) -DEFINE_BENCHMARK(20) -DEFINE_BENCHMARK(1000) -DEFINE_BENCHMARK(1024) -DEFINE_BENCHMARK(8192) -DEFINE_BENCHMARK(10000) -DEFINE_BENCHMARK(65536) -DEFINE_BENCHMARK(100000) -DEFINE_BENCHMARK(4194304) -DEFINE_BENCHMARK(1000000) -DEFINE_BENCHMARK(33554432) -DEFINE_BENCHMARK(10000000) -DEFINE_BENCHMARK(268435456) -DEFINE_BENCHMARK(100000000) + +#define DEFINE_BENCHMARK(N) \ + Y_CPU_BENCHMARK(Yvector_##N, iface) { \ + CreateYvector(N, iface.Iterations()); \ + } \ + Y_CPU_BENCHMARK(Carray_##N, iface) { \ + CreateCarray(N, iface.Iterations()); \ + } + +DEFINE_BENCHMARK(1) +DEFINE_BENCHMARK(2) +DEFINE_BENCHMARK(8) +DEFINE_BENCHMARK(10) +DEFINE_BENCHMARK(16) +DEFINE_BENCHMARK(20) +DEFINE_BENCHMARK(1000) +DEFINE_BENCHMARK(1024) +DEFINE_BENCHMARK(8192) +DEFINE_BENCHMARK(10000) +DEFINE_BENCHMARK(65536) +DEFINE_BENCHMARK(100000) +DEFINE_BENCHMARK(4194304) +DEFINE_BENCHMARK(1000000) +DEFINE_BENCHMARK(33554432) +DEFINE_BENCHMARK(10000000) +DEFINE_BENCHMARK(268435456) +DEFINE_BENCHMARK(100000000) diff --git a/util/generic/benchmark/vector_count_ctor/metrics/main.py b/util/generic/benchmark/vector_count_ctor/metrics/main.py index 835b44fe5f7..f2602ed3ffa 100644 --- a/util/generic/benchmark/vector_count_ctor/metrics/main.py +++ b/util/generic/benchmark/vector_count_ctor/metrics/main.py @@ -1,5 +1,5 @@ -import yatest.common as yc - - -def test_export_metrics(metrics): +import yatest.common as yc + + +def test_export_metrics(metrics): metrics.set_benchmark(yc.execute_benchmark('util/generic/benchmark/vector_count_ctor/vector_count_ctor', threads=8)) diff --git a/util/generic/benchmark/vector_count_ctor/metrics/ya.make b/util/generic/benchmark/vector_count_ctor/metrics/ya.make index c48f89b564a..1441bcbf3a9 100644 --- a/util/generic/benchmark/vector_count_ctor/metrics/ya.make +++ b/util/generic/benchmark/vector_count_ctor/metrics/ya.make @@ -1,21 +1,21 @@ -OWNER( - yazevnul +OWNER( + yazevnul g:util -) +) SUBSCRIBER(g:util-subscribers) - + PY2TEST() - + SIZE(LARGE) - -TAG( + +TAG( ya:force_sandbox - sb:intel_e5_2660v1 + sb:intel_e5_2660v1 ya:fat -) - +) + TEST_SRCS(main.py) - + DEPENDS(util/generic/benchmark/vector_count_ctor) - -END() + +END() diff --git a/util/generic/benchmark/vector_count_ctor/ya.make b/util/generic/benchmark/vector_count_ctor/ya.make index 42ce4428194..735d8cf3971 100644 --- a/util/generic/benchmark/vector_count_ctor/ya.make +++ b/util/generic/benchmark/vector_count_ctor/ya.make @@ -1,16 +1,16 @@ -OWNER( - yazevnul - g:util -) +OWNER( + yazevnul + g:util +) SUBSCRIBER(g:util-subscribers) - + Y_BENCHMARK() - -ALLOCATOR(B) - -SRCS( - main.cpp - f.cpp -) - -END() + +ALLOCATOR(B) + +SRCS( + main.cpp + f.cpp +) + +END() diff --git a/util/generic/benchmark/ya.make b/util/generic/benchmark/ya.make index 635860a646c..9c18713826f 100644 --- a/util/generic/benchmark/ya.make +++ b/util/generic/benchmark/ya.make @@ -1,19 +1,19 @@ OWNER(yazevnul g:util) SUBSCRIBER(g:util-subscribers) - -RECURSE( - fastclp2 - fastclp2/metrics - log2 - log2/metrics - rotate_bits - rotate_bits/metrics - singleton + +RECURSE( + fastclp2 + fastclp2/metrics + log2 + log2/metrics + rotate_bits + rotate_bits/metrics + singleton smart_pointers sort string - vector_count_ctor + vector_count_ctor vector_count_ctor/metrics cont_speed -) +) diff --git a/util/generic/bitmap.h b/util/generic/bitmap.h index f77d1824607..dde98739365 100644 --- a/util/generic/bitmap.h +++ b/util/generic/bitmap.h @@ -31,12 +31,12 @@ namespace NBitMapPrivate { template <typename TChunkType, size_t ExtraBits> struct TSanitizeMask { - static constexpr TChunkType Value = ~((~TChunkType(0)) << ExtraBits); + static constexpr TChunkType Value = ~((~TChunkType(0)) << ExtraBits); }; template <typename TChunkType> struct TSanitizeMask<TChunkType, 0> { - static constexpr TChunkType Value = (TChunkType)~TChunkType(0u); + static constexpr TChunkType Value = (TChunkType)~TChunkType(0u); }; template <typename TTargetChunk, typename TSourceChunk> @@ -44,7 +44,7 @@ namespace NBitMapPrivate { static_assert(sizeof(TTargetChunk) < sizeof(TSourceChunk), "expect sizeof(TTargetChunk) < sizeof(TSourceChunk)"); static_assert(0 == sizeof(TSourceChunk) % sizeof(TTargetChunk), "expect 0 == sizeof(TSourceChunk) % sizeof(TTargetChunk)"); - static constexpr size_t BLOCK_SIZE = sizeof(TSourceChunk) / sizeof(TTargetChunk); + static constexpr size_t BLOCK_SIZE = sizeof(TSourceChunk) / sizeof(TTargetChunk); union TCnv { TSourceChunk BigData; @@ -55,14 +55,14 @@ namespace NBitMapPrivate { TCnv c; c.BigData = source; #if defined(_big_endian_) - ::ReverseCopy(c.SmallData, c.SmallData + Y_ARRAY_SIZE(c.SmallData), target); + ::ReverseCopy(c.SmallData, c.SmallData + Y_ARRAY_SIZE(c.SmallData), target); #else - ::Copy(c.SmallData, c.SmallData + Y_ARRAY_SIZE(c.SmallData), target); + ::Copy(c.SmallData, c.SmallData + Y_ARRAY_SIZE(c.SmallData), target); #endif } static inline void Copy(TTargetChunk* target, size_t targetSize, const TSourceChunk* source, size_t sourceSize) { - Y_ASSERT(targetSize >= sourceSize * BLOCK_SIZE); + Y_ASSERT(targetSize >= sourceSize * BLOCK_SIZE); if (targetSize > sourceSize * BLOCK_SIZE) { ::Fill(target + sourceSize * BLOCK_SIZE, target + targetSize, 0); } @@ -77,7 +77,7 @@ namespace NBitMapPrivate { static_assert(sizeof(TTargetChunk) > sizeof(TSourceChunk), "expect sizeof(TTargetChunk) > sizeof(TSourceChunk)"); static_assert(0 == sizeof(TTargetChunk) % sizeof(TSourceChunk), "expect 0 == sizeof(TTargetChunk) % sizeof(TSourceChunk)"); - static constexpr size_t BLOCK_SIZE = sizeof(TTargetChunk) / sizeof(TSourceChunk); + static constexpr size_t BLOCK_SIZE = sizeof(TTargetChunk) / sizeof(TSourceChunk); union TCnv { TSourceChunk SmallData[BLOCK_SIZE]; @@ -95,7 +95,7 @@ namespace NBitMapPrivate { } static inline TTargetChunk CopyPartChunk(const TSourceChunk* source, size_t count) { - Y_ASSERT(count <= BLOCK_SIZE); + Y_ASSERT(count <= BLOCK_SIZE); TCnv c; c.BigData = 0; #if defined(_big_endian_) @@ -107,7 +107,7 @@ namespace NBitMapPrivate { } static inline void Copy(TTargetChunk* target, size_t targetSize, const TSourceChunk* source, size_t sourceSize) { - Y_ASSERT(targetSize * BLOCK_SIZE >= sourceSize); + Y_ASSERT(targetSize * BLOCK_SIZE >= sourceSize); if (targetSize * BLOCK_SIZE > sourceSize) { ::Fill(target + sourceSize / BLOCK_SIZE, target + targetSize, 0); } @@ -124,7 +124,7 @@ namespace NBitMapPrivate { template <typename TChunk> struct TUniformDataCopier { static inline void Copy(TChunk* target, size_t targetSize, const TChunk* source, size_t sourceSize) { - Y_ASSERT(targetSize >= sourceSize); + Y_ASSERT(targetSize >= sourceSize); for (size_t i = 0; i < sourceSize; ++i) { target[i] = source[i]; } @@ -142,7 +142,7 @@ namespace NBitMapPrivate { }; template <typename TTargetChunk, typename TSourceChunk> - struct TDataCopier: public std::conditional_t<std::is_same<TTargetChunk, TSourceChunk>::value, TUniformDataCopier<TTargetChunk>, std::conditional_t<TIsSmaller<TTargetChunk, TSourceChunk>::Result, TBigToSmallDataCopier<TTargetChunk, TSourceChunk>, TSmallToBigDataCopier<TTargetChunk, TSourceChunk>>> { + struct TDataCopier: public std::conditional_t<std::is_same<TTargetChunk, TSourceChunk>::value, TUniformDataCopier<TTargetChunk>, std::conditional_t<TIsSmaller<TTargetChunk, TSourceChunk>::Result, TBigToSmallDataCopier<TTargetChunk, TSourceChunk>, TSmallToBigDataCopier<TTargetChunk, TSourceChunk>>> { }; template <typename TTargetChunk, typename TSourceChunk> @@ -154,7 +154,7 @@ namespace NBitMapPrivate { struct TFixedStorage { using TChunk = TChunkType; - static constexpr size_t Size = (BitCount + 8 * sizeof(TChunk) - 1) / (8 * sizeof(TChunk)); + static constexpr size_t Size = (BitCount + 8 * sizeof(TChunk) - 1) / (8 * sizeof(TChunk)); TChunk Data[Size]; @@ -170,7 +170,7 @@ namespace NBitMapPrivate { template <typename TOtherChunk> TFixedStorage(const TOtherChunk* data, size_t size) { - Y_VERIFY(Size * sizeof(TChunk) >= size * sizeof(TOtherChunk), "Exceeding bitmap storage capacity"); + Y_VERIFY(Size * sizeof(TChunk) >= size * sizeof(TOtherChunk), "Exceeding bitmap storage capacity"); CopyData(Data, Size, data, size); } @@ -180,16 +180,16 @@ namespace NBitMapPrivate { } } - Y_FORCE_INLINE static constexpr size_t GetBitCapacity() noexcept { + Y_FORCE_INLINE static constexpr size_t GetBitCapacity() noexcept { return BitCount; } - Y_FORCE_INLINE static constexpr size_t GetChunkCapacity() noexcept { + Y_FORCE_INLINE static constexpr size_t GetChunkCapacity() noexcept { return Size; } // Returns true if the resulting storage capacity is enough to fit the requested size - Y_FORCE_INLINE static constexpr bool ExpandBitSize(const size_t bitSize) noexcept { + Y_FORCE_INLINE static constexpr bool ExpandBitSize(const size_t bitSize) noexcept { return bitSize <= BitCount; } @@ -286,12 +286,12 @@ namespace NBitMapPrivate { template <size_t num> struct TDivCount { - static constexpr size_t Value = 1 + TDivCount<(num >> 1)>::Value; + static constexpr size_t Value = 1 + TDivCount<(num >> 1)>::Value; }; template <> struct TDivCount<0> { - static constexpr size_t Value = 0; + static constexpr size_t Value = 0; }; } @@ -317,10 +317,10 @@ public: private: static_assert(std::is_unsigned<TChunk>::value, "expect std::is_unsigned<TChunk>::value"); - static constexpr size_t BitsPerChunk = 8 * sizeof(TChunk); - static constexpr TChunk ModMask = static_cast<TChunk>(BitsPerChunk - 1); - static constexpr size_t DivCount = NBitMapPrivate::TDivCount<BitsPerChunk>::Value - 1; - static constexpr TChunk FullChunk = (TChunk)~TChunk(0); + static constexpr size_t BitsPerChunk = 8 * sizeof(TChunk); + static constexpr TChunk ModMask = static_cast<TChunk>(BitsPerChunk - 1); + static constexpr size_t DivCount = NBitMapPrivate::TDivCount<BitsPerChunk>::Value - 1; + static constexpr TChunk FullChunk = (TChunk)~TChunk(0); template <class> friend class TBitMapOps; @@ -328,7 +328,7 @@ private: using TStorage = typename TTraits::TStorage; // The smallest unsigned type, which can be used in bit ops - using TIntType = std::conditional_t<sizeof(TChunk) < sizeof(unsigned int), unsigned int, TChunk>; + using TIntType = std::conditional_t<sizeof(TChunk) < sizeof(unsigned int), unsigned int, TChunk>; TStorage Mask; @@ -383,13 +383,13 @@ public: private: struct TSetOp { - static constexpr TChunk Op(const TChunk src, const TChunk mask) noexcept { + static constexpr TChunk Op(const TChunk src, const TChunk mask) noexcept { return src | mask; } }; struct TResetOp { - static constexpr TChunk Op(const TChunk src, const TChunk mask) noexcept { + static constexpr TChunk Op(const TChunk src, const TChunk mask) noexcept { return src & ~mask; } }; @@ -510,7 +510,7 @@ public: Y_FORCE_INLINE TReference operator[](size_t pos) { const bool fitStorage = Mask.ExpandBitSize(pos + 1); - Y_ASSERT(fitStorage); + Y_ASSERT(fitStorage); return TReference(&Mask.Data[pos >> DivCount], ModMask & pos); } @@ -520,14 +520,14 @@ public: Y_FORCE_INLINE TThis& Set(size_t pos) { const bool fitStorage = Mask.ExpandBitSize(pos + 1); - Y_ASSERT(fitStorage); + Y_ASSERT(fitStorage); Mask.Data[pos >> DivCount] |= static_cast<TChunk>(1) << (pos & ModMask); return *this; } // Fills the specified [start, end) bit range by the 1. Other bits are kept unchanged TThis& Set(size_t start, size_t end) { - Y_ASSERT(start <= end); + Y_ASSERT(start <= end); if (start < end) { Reserve(end); UpdateRange<TSetOp>(start, end); @@ -544,7 +544,7 @@ public: // Clears the specified [start, end) bit range. Other bits are kept unchanged TThis& Reset(size_t start, size_t end) { - Y_ASSERT(start <= end); + Y_ASSERT(start <= end); if (start < end && (start >> DivCount) < Mask.GetChunkCapacity()) { UpdateRange<TResetOp>(start, Min(end, Mask.GetBitCapacity())); } @@ -553,7 +553,7 @@ public: Y_FORCE_INLINE TThis& Flip(size_t pos) { const bool fitStorage = Mask.ExpandBitSize(pos + 1); - Y_ASSERT(fitStorage); + Y_ASSERT(fitStorage); Mask.Data[pos >> DivCount] ^= static_cast<TChunk>(1) << (pos & ModMask); return *this; } @@ -580,7 +580,7 @@ public: } else if ((pos & (sizeof(TTo) * 8 - 1)) == 0 && sizeof(TChunk) >= 2 * sizeof(TTo)) to = (TTo)(Mask.Data[chunkpos] >> (pos & ModMask)); else { - static constexpr size_t copyToSize = (sizeof(TChunk) >= sizeof(TTo)) ? (sizeof(TChunk) / sizeof(TTo)) + 2 : 3; + static constexpr size_t copyToSize = (sizeof(TChunk) >= sizeof(TTo)) ? (sizeof(TChunk) / sizeof(TTo)) + 2 : 3; TTo temp[copyToSize] = {0, 0}; //or use non defined by now TBitmap<copyToSize, TTo>::CopyData,RShift(pos & ModMask),Export(0,to) NBitMapPrivate::CopyData(temp, copyToSize, Mask.Data + chunkpos, Min((sizeof(TTo) / sizeof(TChunk)) + 1, Mask.GetChunkCapacity() - chunkpos)); @@ -611,12 +611,12 @@ public: } // Returns bits capacity - Y_FORCE_INLINE constexpr size_t Size() const noexcept { + Y_FORCE_INLINE constexpr size_t Size() const noexcept { return Mask.GetBitCapacity(); } Y_FORCE_INLINE void Reserve(size_t bitCount) { - Y_VERIFY(Mask.ExpandBitSize(bitCount), "Exceeding bitmap storage capacity"); + Y_VERIFY(Mask.ExpandBitSize(bitCount), "Exceeding bitmap storage capacity"); } Y_FORCE_INLINE size_t ValueBitCount() const { @@ -624,7 +624,7 @@ public: while (nonZeroChunk != 0 && !Mask.Data[nonZeroChunk]) --nonZeroChunk; return nonZeroChunk || Mask.Data[nonZeroChunk] - ? nonZeroChunk * BitsPerChunk + GetValueBitCount(TIntType(Mask.Data[nonZeroChunk])) + ? nonZeroChunk * BitsPerChunk + GetValueBitCount(TIntType(Mask.Data[nonZeroChunk])) : 0; } @@ -926,7 +926,7 @@ public: // for (size_t pos = bits.FirstNonZeroBit(); pos != bits.Size(); pos = bits.NextNonZeroBit(pos)) { // ... // } - // See Y_FOR_EACH_BIT macro definition at the bottom + // See Y_FOR_EACH_BIT macro definition at the bottom size_t NextNonZeroBit(size_t pos) const { size_t i = (pos + 1) >> DivCount; if (i < Mask.GetChunkCapacity()) { @@ -958,16 +958,16 @@ public: return count; } - void Save(IOutputStream* out) const { + void Save(IOutputStream* out) const { ::Save(out, ui8(sizeof(TChunk))); ::Save(out, ui64(Size())); ::SavePodArray(out, Mask.Data, Mask.GetChunkCapacity()); } - void Load(IInputStream* inp) { + void Load(IInputStream* inp) { ui8 chunkSize = 0; ::Load(inp, chunkSize); - Y_VERIFY(size_t(chunkSize) == sizeof(TChunk), "Chunk size is not the same"); + Y_VERIFY(size_t(chunkSize) == sizeof(TChunk), "Chunk size is not the same"); ui64 bitCount64 = 0; ::Load(inp, bitCount64); @@ -1005,7 +1005,7 @@ public: return Mask.Data; } - constexpr size_t GetChunkCount() const noexcept { + constexpr size_t GetChunkCount() const noexcept { return Mask.GetChunkCapacity(); } }; @@ -1104,7 +1104,7 @@ public: using TDynBitMap = TBitMapOps<TDynamicBitMapTraits<ui64>>; -#define Y_FOR_EACH_BIT(var, bitmap) for (size_t var = (bitmap).FirstNonZeroBit(); var != (bitmap).Size(); var = (bitmap).NextNonZeroBit(var)) +#define Y_FOR_EACH_BIT(var, bitmap) for (size_t var = (bitmap).FirstNonZeroBit(); var != (bitmap).Size(); var = (bitmap).NextNonZeroBit(var)) template <typename TTraits> struct THash<TBitMapOps<TTraits>> { diff --git a/util/generic/bitmap_ut.cpp b/util/generic/bitmap_ut.cpp index 087d34a8dcc..47032bfe53e 100644 --- a/util/generic/bitmap_ut.cpp +++ b/util/generic/bitmap_ut.cpp @@ -37,8 +37,8 @@ } \ } -Y_UNIT_TEST_SUITE(TBitMapTest) { - Y_UNIT_TEST(TestBitMap) { +Y_UNIT_TEST_SUITE(TBitMapTest) { + Y_UNIT_TEST(TestBitMap) { TBitMap<101> bitmap; UNIT_ASSERT_EQUAL(bitmap.Size(), 101); @@ -69,7 +69,7 @@ Y_UNIT_TEST_SUITE(TBitMapTest) { UNIT_ASSERT_EQUAL(bitmap.Empty(), true); } - Y_UNIT_TEST(TestDynBitMap) { + Y_UNIT_TEST(TestDynBitMap) { TDynBitMap bitmap; UNIT_ASSERT_EQUAL(bitmap.Size(), 64); // Initial capacity @@ -124,11 +124,11 @@ Y_UNIT_TEST_SUITE(TBitMapTest) { CHECK_BITMAP(bitmap2, initBits2); } - Y_UNIT_TEST(TestAndFixed) { + Y_UNIT_TEST(TestAndFixed) { TestAndImpl<TBitMap<101>>(); } - Y_UNIT_TEST(TestAndDyn) { + Y_UNIT_TEST(TestAndDyn) { TestAndImpl<TDynBitMap>(); } @@ -165,15 +165,15 @@ Y_UNIT_TEST_SUITE(TBitMapTest) { UNIT_ASSERT_EQUAL(bitmap2 | (bitmap1 << 66), TBitMapImpl(bitmap2).Or(bitmap1, 66)); } - Y_UNIT_TEST(TestOrFixed) { + Y_UNIT_TEST(TestOrFixed) { TestOrImpl<TBitMap<145>>(); } - Y_UNIT_TEST(TestOrDyn) { + Y_UNIT_TEST(TestOrDyn) { TestOrImpl<TDynBitMap>(); } - Y_UNIT_TEST(TestCopy) { + Y_UNIT_TEST(TestCopy) { TBitMap<101> bitmap1; size_t initBits[] = {0, 10, 11, 76, 100}; @@ -239,7 +239,7 @@ Y_UNIT_TEST_SUITE(TBitMapTest) { CHECK_BITMAP(bitmap16, initBits); } - Y_UNIT_TEST(TestOps) { + Y_UNIT_TEST(TestOps) { TBitMap<16> bitmap1; TBitMap<12> bitmap2; size_t initBits1[] = {0, 3, 7, 11}; @@ -286,7 +286,7 @@ Y_UNIT_TEST_SUITE(TBitMapTest) { UNIT_ASSERT_EQUAL(tst3, (1 << 14)); } - Y_UNIT_TEST(TestShiftFixed) { + Y_UNIT_TEST(TestShiftFixed) { size_t initBits[] = {0, 3, 7, 11}; TBitMap<128> bitmap1; @@ -330,7 +330,7 @@ Y_UNIT_TEST_SUITE(TBitMapTest) { UNIT_ASSERT_EQUAL(bitmap1.Empty(), true); } - Y_UNIT_TEST(TestShiftDyn) { + Y_UNIT_TEST(TestShiftDyn) { size_t initBits[] = {0, 3, 7, 11}; TDynBitMap bitmap1; @@ -371,7 +371,7 @@ Y_UNIT_TEST_SUITE(TBitMapTest) { } // Test that we don't expand bitmap in LShift when high-order bits are zero - Y_UNIT_TEST(TestShiftExpansion) { + Y_UNIT_TEST(TestShiftExpansion) { UNIT_ASSERT_EQUAL(TDynBitMap().LShift(1).Size(), 64); UNIT_ASSERT_EQUAL(TDynBitMap().LShift(65).Size(), 64); UNIT_ASSERT_EQUAL(TDynBitMap().LShift(128).Size(), 64); @@ -402,7 +402,7 @@ Y_UNIT_TEST_SUITE(TBitMapTest) { UNIT_ASSERT_EQUAL(bitmap.Size(), 256); } - Y_UNIT_TEST(TestFixedSanity) { + Y_UNIT_TEST(TestFixedSanity) { // test extra-bit cleanup UNIT_ASSERT_EQUAL(TBitMap<33>().Set(0).LShift(34).RShift(34).Empty(), true); UNIT_ASSERT_EQUAL(TBitMap<88>().Set(0).Set(1).Set(2).LShift(90).RShift(90).Empty(), true); @@ -416,7 +416,7 @@ Y_UNIT_TEST_SUITE(TBitMapTest) { UNIT_ASSERT_EQUAL(TBitMap<33>().Xor(TBitMap<40>().Set(39)).Empty(), true); } - Y_UNIT_TEST(TestIterate) { + Y_UNIT_TEST(TestIterate) { TDynBitMap bitmap1; TDynBitMap bitmap2; @@ -475,7 +475,7 @@ Y_UNIT_TEST_SUITE(TBitMapTest) { UNIT_ASSERT_EQUAL(bitmap4.NextNonZeroBit(533), bitmap4.Size()); } - Y_UNIT_TEST(TestHashFixed) { + Y_UNIT_TEST(TestHashFixed) { TBitMap<32, ui8> bitmap32; TBitMap<32, ui8> bitmap322; TBitMap<64, ui8> bitmap64; @@ -507,7 +507,7 @@ Y_UNIT_TEST_SUITE(TBitMapTest) { UNIT_ASSERT_UNEQUAL(bitmap32.Hash(), bitmap64.Hash()); } - Y_UNIT_TEST(TestHashDynamic) { + Y_UNIT_TEST(TestHashDynamic) { TDynBitMap bitmap1; TDynBitMap bitmap2; @@ -528,7 +528,7 @@ Y_UNIT_TEST_SUITE(TBitMapTest) { UNIT_ASSERT_EQUAL(bitmap1.Hash(), bitmap2.Hash()); } - Y_UNIT_TEST(TestHashMixed) { + Y_UNIT_TEST(TestHashMixed) { static_assert((std::is_same<TDynBitMap::TChunk, ui64>::value), "expect (TSameType<TDynBitMap::TChunk, ui64>::Result)"); TBitMap<sizeof(ui64) * 16, ui64> bitmapFixed; @@ -549,7 +549,7 @@ Y_UNIT_TEST_SUITE(TBitMapTest) { UNIT_ASSERT_UNEQUAL(bitmapFixed.Hash(), bitmapDynamic.Hash()); } - Y_UNIT_TEST(TestSetResetRange) { + Y_UNIT_TEST(TestSetResetRange) { // Single chunk using TBitMap1Chunk = TBitMap<64>; UNIT_ASSERT_EQUAL(TBitMap1Chunk().Flip().Reset(10, 50), TBitMap1Chunk().Set(0, 10).Set(50, 64)); @@ -572,7 +572,7 @@ Y_UNIT_TEST_SUITE(TBitMapTest) { UNIT_ASSERT_EQUAL(TBitMap4Chunks().Flip().Reset(0, 10).Reset(50, 64), TBitMap4Chunks().Set(10, 50)); } - Y_UNIT_TEST(TestSetRangeDyn) { + Y_UNIT_TEST(TestSetRangeDyn) { for (size_t start = 0; start < 192; ++start) { for (size_t end = start; end < 192; ++end) { TDynBitMap bm; diff --git a/util/generic/bitops.cpp b/util/generic/bitops.cpp index db5667a21f6..cee2667f4b4 100644 --- a/util/generic/bitops.cpp +++ b/util/generic/bitops.cpp @@ -1,141 +1,141 @@ #include "bitops.h" - -namespace NBitOps { - namespace NPrivate { - const ui64 WORD_MASK[] = { - 0x0000000000000000ULL, - 0x0000000000000001ULL, - 0x0000000000000003ULL, - 0x0000000000000007ULL, - 0x000000000000000FULL, - 0x000000000000001FULL, - 0x000000000000003FULL, - 0x000000000000007FULL, - 0x00000000000000FFULL, - 0x00000000000001FFULL, - 0x00000000000003FFULL, - 0x00000000000007FFULL, - 0x0000000000000FFFULL, - 0x0000000000001FFFULL, - 0x0000000000003FFFULL, - 0x0000000000007FFFULL, - 0x000000000000FFFFULL, - 0x000000000001FFFFULL, - 0x000000000003FFFFULL, - 0x000000000007FFFFULL, - 0x00000000000FFFFFULL, - 0x00000000001FFFFFULL, - 0x00000000003FFFFFULL, - 0x00000000007FFFFFULL, - 0x0000000000FFFFFFULL, - 0x0000000001FFFFFFULL, - 0x0000000003FFFFFFULL, - 0x0000000007FFFFFFULL, - 0x000000000FFFFFFFULL, - 0x000000001FFFFFFFULL, - 0x000000003FFFFFFFULL, - 0x000000007FFFFFFFULL, - 0x00000000FFFFFFFFULL, - 0x00000001FFFFFFFFULL, - 0x00000003FFFFFFFFULL, - 0x00000007FFFFFFFFULL, - 0x0000000FFFFFFFFFULL, - 0x0000001FFFFFFFFFULL, - 0x0000003FFFFFFFFFULL, - 0x0000007FFFFFFFFFULL, - 0x000000FFFFFFFFFFULL, - 0x000001FFFFFFFFFFULL, - 0x000003FFFFFFFFFFULL, - 0x000007FFFFFFFFFFULL, - 0x00000FFFFFFFFFFFULL, - 0x00001FFFFFFFFFFFULL, - 0x00003FFFFFFFFFFFULL, - 0x00007FFFFFFFFFFFULL, - 0x0000FFFFFFFFFFFFULL, - 0x0001FFFFFFFFFFFFULL, - 0x0003FFFFFFFFFFFFULL, - 0x0007FFFFFFFFFFFFULL, - 0x000FFFFFFFFFFFFFULL, - 0x001FFFFFFFFFFFFFULL, - 0x003FFFFFFFFFFFFFULL, - 0x007FFFFFFFFFFFFFULL, - 0x00FFFFFFFFFFFFFFULL, - 0x01FFFFFFFFFFFFFFULL, - 0x03FFFFFFFFFFFFFFULL, - 0x07FFFFFFFFFFFFFFULL, - 0x0FFFFFFFFFFFFFFFULL, - 0x1FFFFFFFFFFFFFFFULL, - 0x3FFFFFFFFFFFFFFFULL, - 0x7FFFFFFFFFFFFFFFULL, - 0xFFFFFFFFFFFFFFFFULL, - }; - - const ui64 INVERSE_WORD_MASK[] = { - ~0x0000000000000000ULL, - ~0x0000000000000001ULL, - ~0x0000000000000003ULL, - ~0x0000000000000007ULL, - ~0x000000000000000FULL, - ~0x000000000000001FULL, - ~0x000000000000003FULL, - ~0x000000000000007FULL, - ~0x00000000000000FFULL, - ~0x00000000000001FFULL, - ~0x00000000000003FFULL, - ~0x00000000000007FFULL, - ~0x0000000000000FFFULL, - ~0x0000000000001FFFULL, - ~0x0000000000003FFFULL, - ~0x0000000000007FFFULL, - ~0x000000000000FFFFULL, - ~0x000000000001FFFFULL, - ~0x000000000003FFFFULL, - ~0x000000000007FFFFULL, - ~0x00000000000FFFFFULL, - ~0x00000000001FFFFFULL, - ~0x00000000003FFFFFULL, - ~0x00000000007FFFFFULL, - ~0x0000000000FFFFFFULL, - ~0x0000000001FFFFFFULL, - ~0x0000000003FFFFFFULL, - ~0x0000000007FFFFFFULL, - ~0x000000000FFFFFFFULL, - ~0x000000001FFFFFFFULL, - ~0x000000003FFFFFFFULL, - ~0x000000007FFFFFFFULL, - ~0x00000000FFFFFFFFULL, - ~0x00000001FFFFFFFFULL, - ~0x00000003FFFFFFFFULL, - ~0x00000007FFFFFFFFULL, - ~0x0000000FFFFFFFFFULL, - ~0x0000001FFFFFFFFFULL, - ~0x0000003FFFFFFFFFULL, - ~0x0000007FFFFFFFFFULL, - ~0x000000FFFFFFFFFFULL, - ~0x000001FFFFFFFFFFULL, - ~0x000003FFFFFFFFFFULL, - ~0x000007FFFFFFFFFFULL, - ~0x00000FFFFFFFFFFFULL, - ~0x00001FFFFFFFFFFFULL, - ~0x00003FFFFFFFFFFFULL, - ~0x00007FFFFFFFFFFFULL, - ~0x0000FFFFFFFFFFFFULL, - ~0x0001FFFFFFFFFFFFULL, - ~0x0003FFFFFFFFFFFFULL, - ~0x0007FFFFFFFFFFFFULL, - ~0x000FFFFFFFFFFFFFULL, - ~0x001FFFFFFFFFFFFFULL, - ~0x003FFFFFFFFFFFFFULL, - ~0x007FFFFFFFFFFFFFULL, - ~0x00FFFFFFFFFFFFFFULL, - ~0x01FFFFFFFFFFFFFFULL, - ~0x03FFFFFFFFFFFFFFULL, - ~0x07FFFFFFFFFFFFFFULL, - ~0x0FFFFFFFFFFFFFFFULL, - ~0x1FFFFFFFFFFFFFFFULL, - ~0x3FFFFFFFFFFFFFFFULL, - ~0x7FFFFFFFFFFFFFFFULL, - ~0xFFFFFFFFFFFFFFFFULL, - }; + +namespace NBitOps { + namespace NPrivate { + const ui64 WORD_MASK[] = { + 0x0000000000000000ULL, + 0x0000000000000001ULL, + 0x0000000000000003ULL, + 0x0000000000000007ULL, + 0x000000000000000FULL, + 0x000000000000001FULL, + 0x000000000000003FULL, + 0x000000000000007FULL, + 0x00000000000000FFULL, + 0x00000000000001FFULL, + 0x00000000000003FFULL, + 0x00000000000007FFULL, + 0x0000000000000FFFULL, + 0x0000000000001FFFULL, + 0x0000000000003FFFULL, + 0x0000000000007FFFULL, + 0x000000000000FFFFULL, + 0x000000000001FFFFULL, + 0x000000000003FFFFULL, + 0x000000000007FFFFULL, + 0x00000000000FFFFFULL, + 0x00000000001FFFFFULL, + 0x00000000003FFFFFULL, + 0x00000000007FFFFFULL, + 0x0000000000FFFFFFULL, + 0x0000000001FFFFFFULL, + 0x0000000003FFFFFFULL, + 0x0000000007FFFFFFULL, + 0x000000000FFFFFFFULL, + 0x000000001FFFFFFFULL, + 0x000000003FFFFFFFULL, + 0x000000007FFFFFFFULL, + 0x00000000FFFFFFFFULL, + 0x00000001FFFFFFFFULL, + 0x00000003FFFFFFFFULL, + 0x00000007FFFFFFFFULL, + 0x0000000FFFFFFFFFULL, + 0x0000001FFFFFFFFFULL, + 0x0000003FFFFFFFFFULL, + 0x0000007FFFFFFFFFULL, + 0x000000FFFFFFFFFFULL, + 0x000001FFFFFFFFFFULL, + 0x000003FFFFFFFFFFULL, + 0x000007FFFFFFFFFFULL, + 0x00000FFFFFFFFFFFULL, + 0x00001FFFFFFFFFFFULL, + 0x00003FFFFFFFFFFFULL, + 0x00007FFFFFFFFFFFULL, + 0x0000FFFFFFFFFFFFULL, + 0x0001FFFFFFFFFFFFULL, + 0x0003FFFFFFFFFFFFULL, + 0x0007FFFFFFFFFFFFULL, + 0x000FFFFFFFFFFFFFULL, + 0x001FFFFFFFFFFFFFULL, + 0x003FFFFFFFFFFFFFULL, + 0x007FFFFFFFFFFFFFULL, + 0x00FFFFFFFFFFFFFFULL, + 0x01FFFFFFFFFFFFFFULL, + 0x03FFFFFFFFFFFFFFULL, + 0x07FFFFFFFFFFFFFFULL, + 0x0FFFFFFFFFFFFFFFULL, + 0x1FFFFFFFFFFFFFFFULL, + 0x3FFFFFFFFFFFFFFFULL, + 0x7FFFFFFFFFFFFFFFULL, + 0xFFFFFFFFFFFFFFFFULL, + }; + + const ui64 INVERSE_WORD_MASK[] = { + ~0x0000000000000000ULL, + ~0x0000000000000001ULL, + ~0x0000000000000003ULL, + ~0x0000000000000007ULL, + ~0x000000000000000FULL, + ~0x000000000000001FULL, + ~0x000000000000003FULL, + ~0x000000000000007FULL, + ~0x00000000000000FFULL, + ~0x00000000000001FFULL, + ~0x00000000000003FFULL, + ~0x00000000000007FFULL, + ~0x0000000000000FFFULL, + ~0x0000000000001FFFULL, + ~0x0000000000003FFFULL, + ~0x0000000000007FFFULL, + ~0x000000000000FFFFULL, + ~0x000000000001FFFFULL, + ~0x000000000003FFFFULL, + ~0x000000000007FFFFULL, + ~0x00000000000FFFFFULL, + ~0x00000000001FFFFFULL, + ~0x00000000003FFFFFULL, + ~0x00000000007FFFFFULL, + ~0x0000000000FFFFFFULL, + ~0x0000000001FFFFFFULL, + ~0x0000000003FFFFFFULL, + ~0x0000000007FFFFFFULL, + ~0x000000000FFFFFFFULL, + ~0x000000001FFFFFFFULL, + ~0x000000003FFFFFFFULL, + ~0x000000007FFFFFFFULL, + ~0x00000000FFFFFFFFULL, + ~0x00000001FFFFFFFFULL, + ~0x00000003FFFFFFFFULL, + ~0x00000007FFFFFFFFULL, + ~0x0000000FFFFFFFFFULL, + ~0x0000001FFFFFFFFFULL, + ~0x0000003FFFFFFFFFULL, + ~0x0000007FFFFFFFFFULL, + ~0x000000FFFFFFFFFFULL, + ~0x000001FFFFFFFFFFULL, + ~0x000003FFFFFFFFFFULL, + ~0x000007FFFFFFFFFFULL, + ~0x00000FFFFFFFFFFFULL, + ~0x00001FFFFFFFFFFFULL, + ~0x00003FFFFFFFFFFFULL, + ~0x00007FFFFFFFFFFFULL, + ~0x0000FFFFFFFFFFFFULL, + ~0x0001FFFFFFFFFFFFULL, + ~0x0003FFFFFFFFFFFFULL, + ~0x0007FFFFFFFFFFFFULL, + ~0x000FFFFFFFFFFFFFULL, + ~0x001FFFFFFFFFFFFFULL, + ~0x003FFFFFFFFFFFFFULL, + ~0x007FFFFFFFFFFFFFULL, + ~0x00FFFFFFFFFFFFFFULL, + ~0x01FFFFFFFFFFFFFFULL, + ~0x03FFFFFFFFFFFFFFULL, + ~0x07FFFFFFFFFFFFFFULL, + ~0x0FFFFFFFFFFFFFFFULL, + ~0x1FFFFFFFFFFFFFFFULL, + ~0x3FFFFFFFFFFFFFFFULL, + ~0x7FFFFFFFFFFFFFFFULL, + ~0xFFFFFFFFFFFFFFFFULL, + }; } } diff --git a/util/generic/bitops.h b/util/generic/bitops.h index 2db15fc59b6..2c60e3437f4 100644 --- a/util/generic/bitops.h +++ b/util/generic/bitops.h @@ -3,16 +3,16 @@ #include "ylimits.h" #include "typelist.h" -#include <util/system/compiler.h> +#include <util/system/compiler.h> #include <util/system/yassert.h> -#ifdef _MSC_VER +#ifdef _MSC_VER #include <intrin.h> -#endif - +#endif + namespace NBitOps { namespace NPrivate { - template <unsigned N, typename T> + template <unsigned N, typename T> struct TClp2Helper { static Y_FORCE_INLINE T Calc(T t) noexcept { const T prev = TClp2Helper<N / 2, T>::Calc(t); @@ -21,272 +21,272 @@ namespace NBitOps { } }; - template <typename T> + template <typename T> struct TClp2Helper<0u, T> { static Y_FORCE_INLINE T Calc(T t) noexcept { return t - 1; } }; - extern const ui64 WORD_MASK[]; - extern const ui64 INVERSE_WORD_MASK[]; - - // see http://www-graphics.stanford.edu/~seander/bithacks.html#ReverseParallel - + extern const ui64 WORD_MASK[]; + extern const ui64 INVERSE_WORD_MASK[]; + + // see http://www-graphics.stanford.edu/~seander/bithacks.html#ReverseParallel + Y_FORCE_INLINE ui64 SwapOddEvenBits(ui64 v) { - return ((v >> 1ULL) & 0x5555555555555555ULL) | ((v & 0x5555555555555555ULL) << 1ULL); - } - + return ((v >> 1ULL) & 0x5555555555555555ULL) | ((v & 0x5555555555555555ULL) << 1ULL); + } + Y_FORCE_INLINE ui64 SwapBitPairs(ui64 v) { - return ((v >> 2ULL) & 0x3333333333333333ULL) | ((v & 0x3333333333333333ULL) << 2ULL); - } - + return ((v >> 2ULL) & 0x3333333333333333ULL) | ((v & 0x3333333333333333ULL) << 2ULL); + } + Y_FORCE_INLINE ui64 SwapNibbles(ui64 v) { - return ((v >> 4ULL) & 0x0F0F0F0F0F0F0F0FULL) | ((v & 0x0F0F0F0F0F0F0F0FULL) << 4ULL); - } - + return ((v >> 4ULL) & 0x0F0F0F0F0F0F0F0FULL) | ((v & 0x0F0F0F0F0F0F0F0FULL) << 4ULL); + } + Y_FORCE_INLINE ui64 SwapOddEvenBytes(ui64 v) { - return ((v >> 8ULL) & 0x00FF00FF00FF00FFULL) | ((v & 0x00FF00FF00FF00FFULL) << 8ULL); - } - + return ((v >> 8ULL) & 0x00FF00FF00FF00FFULL) | ((v & 0x00FF00FF00FF00FFULL) << 8ULL); + } + Y_FORCE_INLINE ui64 SwapBytePairs(ui64 v) { - return ((v >> 16ULL) & 0x0000FFFF0000FFFFULL) | ((v & 0x0000FFFF0000FFFFULL) << 16ULL); - } - + return ((v >> 16ULL) & 0x0000FFFF0000FFFFULL) | ((v & 0x0000FFFF0000FFFFULL) << 16ULL); + } + Y_FORCE_INLINE ui64 SwapByteQuads(ui64 v) { - return (v >> 32ULL) | (v << 32ULL); - } - + return (v >> 32ULL) | (v << 32ULL); + } + #if defined(__GNUC__) inline unsigned GetValueBitCountImpl(unsigned int value) noexcept { - Y_ASSERT(value); // because __builtin_clz* have undefined result for zero. - return std::numeric_limits<unsigned int>::digits - __builtin_clz(value); - } + Y_ASSERT(value); // because __builtin_clz* have undefined result for zero. + return std::numeric_limits<unsigned int>::digits - __builtin_clz(value); + } inline unsigned GetValueBitCountImpl(unsigned long value) noexcept { - Y_ASSERT(value); // because __builtin_clz* have undefined result for zero. - return std::numeric_limits<unsigned long>::digits - __builtin_clzl(value); - } + Y_ASSERT(value); // because __builtin_clz* have undefined result for zero. + return std::numeric_limits<unsigned long>::digits - __builtin_clzl(value); + } inline unsigned GetValueBitCountImpl(unsigned long long value) noexcept { - Y_ASSERT(value); // because __builtin_clz* have undefined result for zero. - return std::numeric_limits<unsigned long long>::digits - __builtin_clzll(value); - } -#else - /// Stupid realization for non-GCC. Can use BSR from x86 instructions set. - template <typename T> + Y_ASSERT(value); // because __builtin_clz* have undefined result for zero. + return std::numeric_limits<unsigned long long>::digits - __builtin_clzll(value); + } +#else + /// Stupid realization for non-GCC. Can use BSR from x86 instructions set. + template <typename T> inline unsigned GetValueBitCountImpl(T value) noexcept { - Y_ASSERT(value); // because __builtin_clz* have undefined result for zero. - unsigned result = 1; // result == 0 - impossible value, see Y_ASSERT(). - value >>= 1; - while (value) { - value >>= 1; + Y_ASSERT(value); // because __builtin_clz* have undefined result for zero. + unsigned result = 1; // result == 0 - impossible value, see Y_ASSERT(). + value >>= 1; + while (value) { + value >>= 1; ++result; - } + } - return result; - } -#endif + return result; + } +#endif #if defined(__GNUC__) inline unsigned CountTrailingZeroBitsImpl(unsigned int value) noexcept { - Y_ASSERT(value); // because __builtin_ctz* have undefined result for zero. - return __builtin_ctz(value); - } + Y_ASSERT(value); // because __builtin_ctz* have undefined result for zero. + return __builtin_ctz(value); + } inline unsigned CountTrailingZeroBitsImpl(unsigned long value) noexcept { - Y_ASSERT(value); // because __builtin_ctz* have undefined result for zero. - return __builtin_ctzl(value); - } + Y_ASSERT(value); // because __builtin_ctz* have undefined result for zero. + return __builtin_ctzl(value); + } inline unsigned CountTrailingZeroBitsImpl(unsigned long long value) noexcept { - Y_ASSERT(value); // because __builtin_ctz* have undefined result for zero. - return __builtin_ctzll(value); - } -#else - /// Stupid realization for non-GCC. Can use BSF from x86 instructions set. - template <typename T> + Y_ASSERT(value); // because __builtin_ctz* have undefined result for zero. + return __builtin_ctzll(value); + } +#else + /// Stupid realization for non-GCC. Can use BSF from x86 instructions set. + template <typename T> inline unsigned CountTrailingZeroBitsImpl(T value) noexcept { - Y_ASSERT(value); // because __builtin_ctz* have undefined result for zero. - unsigned result = 0; - while (!(value & 1)) { - value >>= 1; - ++result; - } - - return result; - } -#endif - - template <typename T> - Y_FORCE_INLINE T RotateBitsLeftImpl(T value, const ui8 shift) noexcept { - constexpr ui8 bits = sizeof(T) * 8; - constexpr ui8 mask = bits - 1; - Y_ASSERT(shift <= mask); - - // do trick with mask to avoid undefined behaviour - return (value << shift) | (value >> ((-shift) & mask)); - } - - template <typename T> - Y_FORCE_INLINE T RotateBitsRightImpl(T value, const ui8 shift) noexcept { - constexpr ui8 bits = sizeof(T) * 8; - constexpr ui8 mask = bits - 1; - Y_ASSERT(shift <= mask); - - // do trick with mask to avoid undefined behaviour - return (value >> shift) | (value << ((-shift) & mask)); - } - -#if defined(_x86_) && defined(__GNUC__) - Y_FORCE_INLINE ui8 RotateBitsRightImpl(ui8 value, ui8 shift) noexcept { - __asm__("rorb %%cl, %0" - : "=r"(value) - : "0"(value), "c"(shift)); - return value; - } - - Y_FORCE_INLINE ui16 RotateBitsRightImpl(ui16 value, ui8 shift) noexcept { - __asm__("rorw %%cl, %0" - : "=r"(value) - : "0"(value), "c"(shift)); - return value; - } - - Y_FORCE_INLINE ui32 RotateBitsRightImpl(ui32 value, ui8 shift) noexcept { - __asm__("rorl %%cl, %0" - : "=r"(value) - : "0"(value), "c"(shift)); - return value; - } - - Y_FORCE_INLINE ui8 RotateBitsLeftImpl(ui8 value, ui8 shift) noexcept { - __asm__("rolb %%cl, %0" - : "=r"(value) - : "0"(value), "c"(shift)); - return value; - } - - Y_FORCE_INLINE ui16 RotateBitsLeftImpl(ui16 value, ui8 shift) noexcept { - __asm__("rolw %%cl, %0" - : "=r"(value) - : "0"(value), "c"(shift)); - return value; - } - - Y_FORCE_INLINE ui32 RotateBitsLeftImpl(ui32 value, ui8 shift) noexcept { - __asm__("roll %%cl, %0" - : "=r"(value) - : "0"(value), "c"(shift)); - return value; - } - + Y_ASSERT(value); // because __builtin_ctz* have undefined result for zero. + unsigned result = 0; + while (!(value & 1)) { + value >>= 1; + ++result; + } + + return result; + } +#endif + + template <typename T> + Y_FORCE_INLINE T RotateBitsLeftImpl(T value, const ui8 shift) noexcept { + constexpr ui8 bits = sizeof(T) * 8; + constexpr ui8 mask = bits - 1; + Y_ASSERT(shift <= mask); + + // do trick with mask to avoid undefined behaviour + return (value << shift) | (value >> ((-shift) & mask)); + } + + template <typename T> + Y_FORCE_INLINE T RotateBitsRightImpl(T value, const ui8 shift) noexcept { + constexpr ui8 bits = sizeof(T) * 8; + constexpr ui8 mask = bits - 1; + Y_ASSERT(shift <= mask); + + // do trick with mask to avoid undefined behaviour + return (value >> shift) | (value << ((-shift) & mask)); + } + +#if defined(_x86_) && defined(__GNUC__) + Y_FORCE_INLINE ui8 RotateBitsRightImpl(ui8 value, ui8 shift) noexcept { + __asm__("rorb %%cl, %0" + : "=r"(value) + : "0"(value), "c"(shift)); + return value; + } + + Y_FORCE_INLINE ui16 RotateBitsRightImpl(ui16 value, ui8 shift) noexcept { + __asm__("rorw %%cl, %0" + : "=r"(value) + : "0"(value), "c"(shift)); + return value; + } + + Y_FORCE_INLINE ui32 RotateBitsRightImpl(ui32 value, ui8 shift) noexcept { + __asm__("rorl %%cl, %0" + : "=r"(value) + : "0"(value), "c"(shift)); + return value; + } + + Y_FORCE_INLINE ui8 RotateBitsLeftImpl(ui8 value, ui8 shift) noexcept { + __asm__("rolb %%cl, %0" + : "=r"(value) + : "0"(value), "c"(shift)); + return value; + } + + Y_FORCE_INLINE ui16 RotateBitsLeftImpl(ui16 value, ui8 shift) noexcept { + __asm__("rolw %%cl, %0" + : "=r"(value) + : "0"(value), "c"(shift)); + return value; + } + + Y_FORCE_INLINE ui32 RotateBitsLeftImpl(ui32 value, ui8 shift) noexcept { + __asm__("roll %%cl, %0" + : "=r"(value) + : "0"(value), "c"(shift)); + return value; + } + #if defined(_x86_64_) - Y_FORCE_INLINE ui64 RotateBitsRightImpl(ui64 value, ui8 shift) noexcept { - __asm__("rorq %%cl, %0" - : "=r"(value) - : "0"(value), "c"(shift)); - return value; - } - - Y_FORCE_INLINE ui64 RotateBitsLeftImpl(ui64 value, ui8 shift) noexcept { - __asm__("rolq %%cl, %0" - : "=r"(value) - : "0"(value), "c"(shift)); - return value; - } + Y_FORCE_INLINE ui64 RotateBitsRightImpl(ui64 value, ui8 shift) noexcept { + __asm__("rorq %%cl, %0" + : "=r"(value) + : "0"(value), "c"(shift)); + return value; + } + + Y_FORCE_INLINE ui64 RotateBitsLeftImpl(ui64 value, ui8 shift) noexcept { + __asm__("rolq %%cl, %0" + : "=r"(value) + : "0"(value), "c"(shift)); + return value; + } #endif -#endif +#endif } } - -/** + +/** * Computes the next power of 2 higher or equal to the integer parameter `t`. - * If `t` is a power of 2 will return `t`. - * Result is undefined for `t == 0`. - */ + * If `t` is a power of 2 will return `t`. + * Result is undefined for `t == 0`. + */ template <typename T> static inline T FastClp2(T t) noexcept { - Y_ASSERT(t > 0); + Y_ASSERT(t > 0); using TCvt = typename ::TUnsignedInts::template TSelectBy<TSizeOfPredicate<sizeof(T)>::template TResult>::type; - return 1 + ::NBitOps::NPrivate::TClp2Helper<sizeof(TCvt) * 4, T>::Calc(static_cast<TCvt>(t)); + return 1 + ::NBitOps::NPrivate::TClp2Helper<sizeof(TCvt) * 4, T>::Calc(static_cast<TCvt>(t)); } -/** - * Check if integer is a power of 2. - */ -template <typename T> +/** + * Check if integer is a power of 2. + */ +template <typename T> Y_CONST_FUNCTION constexpr bool IsPowerOf2(T v) noexcept { - return v > 0 && (v & (v - 1)) == 0; -} + return v > 0 && (v & (v - 1)) == 0; +} -/** - * Returns the number of leading 0-bits in `value`, starting at the most significant bit position. - */ +/** + * Returns the number of leading 0-bits in `value`, starting at the most significant bit position. + */ template <typename T> static inline unsigned GetValueBitCount(T value) noexcept { - Y_ASSERT(value > 0); + Y_ASSERT(value > 0); using TCvt = typename ::TUnsignedInts::template TSelectBy<TSizeOfPredicate<sizeof(T)>::template TResult>::type; - return ::NBitOps::NPrivate::GetValueBitCountImpl(static_cast<TCvt>(value)); + return ::NBitOps::NPrivate::GetValueBitCountImpl(static_cast<TCvt>(value)); } -/** - * Returns the number of trailing 0-bits in `value`, starting at the least significant bit position - */ -template <typename T> +/** + * Returns the number of trailing 0-bits in `value`, starting at the least significant bit position + */ +template <typename T> static inline unsigned CountTrailingZeroBits(T value) noexcept { - Y_ASSERT(value > 0); + Y_ASSERT(value > 0); using TCvt = typename ::TUnsignedInts::template TSelectBy<TSizeOfPredicate<sizeof(T)>::template TResult>::type; - return ::NBitOps::NPrivate::CountTrailingZeroBitsImpl(static_cast<TCvt>(value)); + return ::NBitOps::NPrivate::CountTrailingZeroBitsImpl(static_cast<TCvt>(value)); } - -/* - * Returns 64-bit mask with `bits` lower bits set. - */ + +/* + * Returns 64-bit mask with `bits` lower bits set. + */ Y_FORCE_INLINE ui64 MaskLowerBits(ui64 bits) { - return ::NBitOps::NPrivate::WORD_MASK[bits]; -} - -/* - * Return 64-bit mask with `bits` set starting from `skipbits`. - */ + return ::NBitOps::NPrivate::WORD_MASK[bits]; +} + +/* + * Return 64-bit mask with `bits` set starting from `skipbits`. + */ Y_FORCE_INLINE ui64 MaskLowerBits(ui64 bits, ui64 skipbits) { - return MaskLowerBits(bits) << skipbits; -} - -/* - * Return 64-bit mask with all bits set except for `bits` lower bits. - */ + return MaskLowerBits(bits) << skipbits; +} + +/* + * Return 64-bit mask with all bits set except for `bits` lower bits. + */ Y_FORCE_INLINE ui64 InverseMaskLowerBits(ui64 bits) { - return ::NBitOps::NPrivate::INVERSE_WORD_MASK[bits]; -} - -/* - * Return 64-bit mask with all bits set except for `bits` bitst starting from `skipbits`. - */ + return ::NBitOps::NPrivate::INVERSE_WORD_MASK[bits]; +} + +/* + * Return 64-bit mask with all bits set except for `bits` bitst starting from `skipbits`. + */ Y_FORCE_INLINE ui64 InverseMaskLowerBits(ui64 bits, ui64 skipbits) { - return ~MaskLowerBits(bits, skipbits); -} - -/* + return ~MaskLowerBits(bits, skipbits); +} + +/* * Returns 0-based position of the most significant bit that is set. 0 for 0. - */ + */ Y_FORCE_INLINE ui64 MostSignificantBit(ui64 v) { -#ifdef __GNUC__ - ui64 res = v ? (63 - __builtin_clzll(v)) : 0; -#elif defined(_MSC_VER) && defined(_64_) - unsigned long res = 0; - if (v) - _BitScanReverse64(&res, v); -#else - ui64 res = 0; - if (v) - while (v >>= 1) +#ifdef __GNUC__ + ui64 res = v ? (63 - __builtin_clzll(v)) : 0; +#elif defined(_MSC_VER) && defined(_64_) + unsigned long res = 0; + if (v) + _BitScanReverse64(&res, v); +#else + ui64 res = 0; + if (v) + while (v >>= 1) ++res; -#endif - return res; -} - +#endif + return res; +} + /** * Returns 0-based position of the least significant bit that is set. 0 for 0. */ @@ -309,7 +309,7 @@ Y_FORCE_INLINE ui64 LeastSignificantBit(ui64 v) { return res; } -/* +/* * Returns 0 - based position of the most significant bit (compile time) * 0 for 0. */ @@ -318,112 +318,112 @@ constexpr ui64 MostSignificantBitCT(ui64 x) { } /* - * Return rounded up binary logarithm of `x`. - */ + * Return rounded up binary logarithm of `x`. + */ Y_FORCE_INLINE ui8 CeilLog2(ui64 x) { - return static_cast<ui8>(MostSignificantBit(x - 1)) + 1; -} - + return static_cast<ui8>(MostSignificantBit(x - 1)) + 1; +} + Y_FORCE_INLINE ui8 ReverseBytes(ui8 t) { - return t; -} - + return t; +} + Y_FORCE_INLINE ui16 ReverseBytes(ui16 t) { - return static_cast<ui16>(::NBitOps::NPrivate::SwapOddEvenBytes(t)); -} - + return static_cast<ui16>(::NBitOps::NPrivate::SwapOddEvenBytes(t)); +} + Y_FORCE_INLINE ui32 ReverseBytes(ui32 t) { - return static_cast<ui32>(::NBitOps::NPrivate::SwapBytePairs( - ::NBitOps::NPrivate::SwapOddEvenBytes(t))); -} - + return static_cast<ui32>(::NBitOps::NPrivate::SwapBytePairs( + ::NBitOps::NPrivate::SwapOddEvenBytes(t))); +} + Y_FORCE_INLINE ui64 ReverseBytes(ui64 t) { - return ::NBitOps::NPrivate::SwapByteQuads((::NBitOps::NPrivate::SwapOddEvenBytes(t))); -} - + return ::NBitOps::NPrivate::SwapByteQuads((::NBitOps::NPrivate::SwapOddEvenBytes(t))); +} + Y_FORCE_INLINE ui8 ReverseBits(ui8 t) { - return static_cast<ui8>(::NBitOps::NPrivate::SwapNibbles( - ::NBitOps::NPrivate::SwapBitPairs( - ::NBitOps::NPrivate::SwapOddEvenBits(t)))); -} - + return static_cast<ui8>(::NBitOps::NPrivate::SwapNibbles( + ::NBitOps::NPrivate::SwapBitPairs( + ::NBitOps::NPrivate::SwapOddEvenBits(t)))); +} + Y_FORCE_INLINE ui16 ReverseBits(ui16 t) { - return static_cast<ui16>(::NBitOps::NPrivate::SwapOddEvenBytes( - ::NBitOps::NPrivate::SwapNibbles( - ::NBitOps::NPrivate::SwapBitPairs( - ::NBitOps::NPrivate::SwapOddEvenBits(t))))); -} - + return static_cast<ui16>(::NBitOps::NPrivate::SwapOddEvenBytes( + ::NBitOps::NPrivate::SwapNibbles( + ::NBitOps::NPrivate::SwapBitPairs( + ::NBitOps::NPrivate::SwapOddEvenBits(t))))); +} + Y_FORCE_INLINE ui32 ReverseBits(ui32 t) { - return static_cast<ui32>(::NBitOps::NPrivate::SwapBytePairs( - ::NBitOps::NPrivate::SwapOddEvenBytes( - ::NBitOps::NPrivate::SwapNibbles( - ::NBitOps::NPrivate::SwapBitPairs( - ::NBitOps::NPrivate::SwapOddEvenBits(t)))))); -} - + return static_cast<ui32>(::NBitOps::NPrivate::SwapBytePairs( + ::NBitOps::NPrivate::SwapOddEvenBytes( + ::NBitOps::NPrivate::SwapNibbles( + ::NBitOps::NPrivate::SwapBitPairs( + ::NBitOps::NPrivate::SwapOddEvenBits(t)))))); +} + Y_FORCE_INLINE ui64 ReverseBits(ui64 t) { - return ::NBitOps::NPrivate::SwapByteQuads( - ::NBitOps::NPrivate::SwapBytePairs( - ::NBitOps::NPrivate::SwapOddEvenBytes( - ::NBitOps::NPrivate::SwapNibbles( - ::NBitOps::NPrivate::SwapBitPairs( - ::NBitOps::NPrivate::SwapOddEvenBits(t)))))); -} - -/* - * Reverse first `bits` bits - * 1000111000111000 , bits = 6 => 1000111000000111 - */ -template <typename T> + return ::NBitOps::NPrivate::SwapByteQuads( + ::NBitOps::NPrivate::SwapBytePairs( + ::NBitOps::NPrivate::SwapOddEvenBytes( + ::NBitOps::NPrivate::SwapNibbles( + ::NBitOps::NPrivate::SwapBitPairs( + ::NBitOps::NPrivate::SwapOddEvenBits(t)))))); +} + +/* + * Reverse first `bits` bits + * 1000111000111000 , bits = 6 => 1000111000000111 + */ +template <typename T> Y_FORCE_INLINE T ReverseBits(T v, ui64 bits) { return bits ? (T(v & ::InverseMaskLowerBits(bits)) | T(ReverseBits(T(v & ::MaskLowerBits(bits)))) >> ((ui64{sizeof(T)} << ui64{3}) - bits)) : v; -} - -/* - * Referse first `bits` bits starting from `skipbits` bits - * 1000111000111000 , bits = 4, skipbits = 2 => 1000111000011100 - */ -template <typename T> +} + +/* + * Referse first `bits` bits starting from `skipbits` bits + * 1000111000111000 , bits = 4, skipbits = 2 => 1000111000011100 + */ +template <typename T> Y_FORCE_INLINE T ReverseBits(T v, ui64 bits, ui64 skipbits) { - return (T(ReverseBits((v >> skipbits), bits)) << skipbits) | T(v & MaskLowerBits(skipbits)); -} - -/* Rotate bits left. Also known as left circular shift. - */ -template <typename T> -Y_FORCE_INLINE T RotateBitsLeft(T value, const ui8 shift) noexcept { - static_assert(std::is_unsigned<T>::value, "must be unsigned arithmetic type"); - return ::NBitOps::NPrivate::RotateBitsLeftImpl((TFixedWidthUnsignedInt<T>)value, shift); -} - -/* Rotate bits right. Also known as right circular shift. - */ -template <typename T> -Y_FORCE_INLINE T RotateBitsRight(T value, const ui8 shift) noexcept { - static_assert(std::is_unsigned<T>::value, "must be unsigned arithmetic type"); - return ::NBitOps::NPrivate::RotateBitsRightImpl((TFixedWidthUnsignedInt<T>)value, shift); -} - -/* Rotate bits left. Also known as left circular shift. - */ -template <typename T> -constexpr T RotateBitsLeftCT(T value, const ui8 shift) noexcept { - static_assert(std::is_unsigned<T>::value, "must be unsigned arithmetic type"); - - // do trick with mask to avoid undefined behaviour - return (value << shift) | (value >> ((-shift) & (sizeof(T) * 8 - 1))); -} - -/* Rotate bits right. Also known as right circular shift. - */ -template <typename T> -constexpr T RotateBitsRightCT(T value, const ui8 shift) noexcept { - static_assert(std::is_unsigned<T>::value, "must be unsigned arithmetic type"); - - // do trick with mask to avoid undefined behaviour - return (value >> shift) | (value << ((-shift) & (sizeof(T) * 8 - 1))); -} + return (T(ReverseBits((v >> skipbits), bits)) << skipbits) | T(v & MaskLowerBits(skipbits)); +} + +/* Rotate bits left. Also known as left circular shift. + */ +template <typename T> +Y_FORCE_INLINE T RotateBitsLeft(T value, const ui8 shift) noexcept { + static_assert(std::is_unsigned<T>::value, "must be unsigned arithmetic type"); + return ::NBitOps::NPrivate::RotateBitsLeftImpl((TFixedWidthUnsignedInt<T>)value, shift); +} + +/* Rotate bits right. Also known as right circular shift. + */ +template <typename T> +Y_FORCE_INLINE T RotateBitsRight(T value, const ui8 shift) noexcept { + static_assert(std::is_unsigned<T>::value, "must be unsigned arithmetic type"); + return ::NBitOps::NPrivate::RotateBitsRightImpl((TFixedWidthUnsignedInt<T>)value, shift); +} + +/* Rotate bits left. Also known as left circular shift. + */ +template <typename T> +constexpr T RotateBitsLeftCT(T value, const ui8 shift) noexcept { + static_assert(std::is_unsigned<T>::value, "must be unsigned arithmetic type"); + + // do trick with mask to avoid undefined behaviour + return (value << shift) | (value >> ((-shift) & (sizeof(T) * 8 - 1))); +} + +/* Rotate bits right. Also known as right circular shift. + */ +template <typename T> +constexpr T RotateBitsRightCT(T value, const ui8 shift) noexcept { + static_assert(std::is_unsigned<T>::value, "must be unsigned arithmetic type"); + + // do trick with mask to avoid undefined behaviour + return (value >> shift) | (value << ((-shift) & (sizeof(T) * 8 - 1))); +} /* Remain `size` bits to current `offset` of `value` size, offset are less than number of bits in size_type diff --git a/util/generic/bitops_ut.cpp b/util/generic/bitops_ut.cpp index d23c2b5c27e..4a1a6b799e1 100644 --- a/util/generic/bitops_ut.cpp +++ b/util/generic/bitops_ut.cpp @@ -4,45 +4,45 @@ #include <util/string/builder.h> -template <typename T> -static void TestCTZ() { - for (unsigned int i = 0; i < (sizeof(T) << 3); ++i) { - UNIT_ASSERT_VALUES_EQUAL(CountTrailingZeroBits(T(1) << i), i); - } -} - -template <typename T> -static void TestFastClp2ForEachPowerOf2() { - for (size_t i = 0; i < sizeof(T) * 8 - 1; ++i) { - const auto current = T(1) << i; - UNIT_ASSERT_VALUES_EQUAL(FastClp2(current), current); - } - - UNIT_ASSERT_VALUES_EQUAL(FastClp2(T(1)), T(1)); - for (size_t i = 1; i < sizeof(T) * 8 - 1; ++i) { - for (size_t j = 0; j < i; ++j) { - const auto value = (T(1) << i) | (T(1) << j); - const auto next = T(1) << (i + 1); - UNIT_ASSERT_VALUES_EQUAL(FastClp2(value), next); - } - } -} - -template <typename T> -static T ReverseBitsSlow(T v) { - T r = v; // r will be reversed bits of v; first get LSB of v - ui32 s = sizeof(v) * 8 - 1; // extra shift needed at end - - for (v >>= 1; v; v >>= 1) { - r <<= 1; - r |= v & 1; +template <typename T> +static void TestCTZ() { + for (unsigned int i = 0; i < (sizeof(T) << 3); ++i) { + UNIT_ASSERT_VALUES_EQUAL(CountTrailingZeroBits(T(1) << i), i); + } +} + +template <typename T> +static void TestFastClp2ForEachPowerOf2() { + for (size_t i = 0; i < sizeof(T) * 8 - 1; ++i) { + const auto current = T(1) << i; + UNIT_ASSERT_VALUES_EQUAL(FastClp2(current), current); + } + + UNIT_ASSERT_VALUES_EQUAL(FastClp2(T(1)), T(1)); + for (size_t i = 1; i < sizeof(T) * 8 - 1; ++i) { + for (size_t j = 0; j < i; ++j) { + const auto value = (T(1) << i) | (T(1) << j); + const auto next = T(1) << (i + 1); + UNIT_ASSERT_VALUES_EQUAL(FastClp2(value), next); + } + } +} + +template <typename T> +static T ReverseBitsSlow(T v) { + T r = v; // r will be reversed bits of v; first get LSB of v + ui32 s = sizeof(v) * 8 - 1; // extra shift needed at end + + for (v >>= 1; v; v >>= 1) { + r <<= 1; + r |= v & 1; --s; - } - - r <<= s; // shift when v's highest bits are zero - return r; -} - + } + + r <<= s; // shift when v's highest bits are zero + return r; +} + // DO_NOT_STYLE Y_UNIT_TEST_SUITE(TBitOpsTest) { Y_UNIT_TEST(TestCountTrailingZeroBits) { @@ -71,7 +71,7 @@ Y_UNIT_TEST_SUITE(TBitOpsTest) { TestFastClp2ForEachPowerOf2<unsigned long>(); TestFastClp2ForEachPowerOf2<unsigned long long>(); } - + Y_UNIT_TEST(TestMask) { for (ui32 i = 0; i < 64; ++i) { UNIT_ASSERT_VALUES_EQUAL(MaskLowerBits(i), (ui64{1} << i) - 1); @@ -79,8 +79,8 @@ Y_UNIT_TEST_SUITE(TBitOpsTest) { UNIT_ASSERT_VALUES_EQUAL(MaskLowerBits(i, i / 2), (ui64{1} << i) - 1 << (i / 2)); UNIT_ASSERT_VALUES_EQUAL(InverseMaskLowerBits(i, i / 2), ~MaskLowerBits(i, i / 2)); } - } - + } + Y_UNIT_TEST(TestMostSignificantBit) { static_assert(MostSignificantBitCT(0) == 0, "."); static_assert(MostSignificantBitCT(1) == 0, "."); @@ -93,8 +93,8 @@ Y_UNIT_TEST_SUITE(TBitOpsTest) { for (ui32 i = 0; i < 63; ++i) { UNIT_ASSERT_VALUES_EQUAL(i + 1, MostSignificantBit(ui64{3} << i)); } - } - + } + Y_UNIT_TEST(TestLeastSignificantBit) { for (ui32 i = 0; i < 64; ++i) { UNIT_ASSERT_VALUES_EQUAL(i, LeastSignificantBit(ui64{1} << i)); @@ -112,13 +112,13 @@ Y_UNIT_TEST_SUITE(TBitOpsTest) { Y_UNIT_TEST(TestCeilLog2) { UNIT_ASSERT_VALUES_EQUAL(CeilLog2(ui64{1}), 1); - + for (ui32 i = 2; i < 64; ++i) { UNIT_ASSERT_VALUES_EQUAL(CeilLog2(ui64{1} << i), i); UNIT_ASSERT_VALUES_EQUAL(CeilLog2((ui64{1} << i) | ui64{1}), i + 1); } - } - + } + Y_UNIT_TEST(TestReverse) { for (ui64 i = 0; i < 0x100; ++i) { UNIT_ASSERT_VALUES_EQUAL(ReverseBits((ui8)i), ReverseBitsSlow((ui8)i)); @@ -129,23 +129,23 @@ Y_UNIT_TEST_SUITE(TBitOpsTest) { UNIT_ASSERT_VALUES_EQUAL(ReverseBits((ui32)~i), ReverseBitsSlow((ui32)~i)); UNIT_ASSERT_VALUES_EQUAL(ReverseBits((ui64)~i), ReverseBitsSlow((ui64)~i)); } - + ui32 v = 0xF0F0F0F0; // 11110000111100001111000011110000 for (ui32 i = 0; i < 4; ++i) { UNIT_ASSERT_VALUES_EQUAL(ReverseBits(v, i + 1), v); UNIT_ASSERT_VALUES_EQUAL(ReverseBits(v, 4 + 2 * i, 4 - i), v); } - + UNIT_ASSERT_VALUES_EQUAL(ReverseBits(v, 8), 0xF0F0F00Fu); UNIT_ASSERT_VALUES_EQUAL(ReverseBits(v, 8, 4), 0xF0F0FF00u); - + for (ui32 i = 0; i < 0x10000; ++i) { for (ui32 j = 0; j <= 32; ++j) { UNIT_ASSERT_VALUES_EQUAL_C(i, ReverseBits(ReverseBits(i, j), j), (TString)(TStringBuilder() << i << " " << j)); } - } - } - + } + } + Y_UNIT_TEST(TestRotateBitsLeft) { static_assert(RotateBitsLeftCT<ui8>(0b00000000u, 0) == 0b00000000u, ""); static_assert(RotateBitsLeftCT<ui8>(0b00000001u, 0) == 0b00000001u, ""); @@ -155,7 +155,7 @@ Y_UNIT_TEST_SUITE(TBitOpsTest) { static_assert(RotateBitsLeftCT<ui8>(0b00000101u, 1) == 0b00001010u, ""); static_assert(RotateBitsLeftCT<ui8>(0b10100000u, 1) == 0b01000001u, ""); static_assert(RotateBitsLeftCT<ui8>(0b10000000u, 7) == 0b01000000u, ""); - + UNIT_ASSERT_VALUES_EQUAL(RotateBitsLeft<ui8>(0b00000000u, 0), 0b00000000u); UNIT_ASSERT_VALUES_EQUAL(RotateBitsLeft<ui8>(0b00000001u, 0), 0b00000001u); UNIT_ASSERT_VALUES_EQUAL(RotateBitsLeft<ui8>(0b10000000u, 0), 0b10000000u); @@ -164,7 +164,7 @@ Y_UNIT_TEST_SUITE(TBitOpsTest) { UNIT_ASSERT_VALUES_EQUAL(RotateBitsLeft<ui8>(0b00000101u, 1), 0b00001010u); UNIT_ASSERT_VALUES_EQUAL(RotateBitsLeft<ui8>(0b10100000u, 1), 0b01000001u); UNIT_ASSERT_VALUES_EQUAL(RotateBitsLeft<ui8>(0b10000000u, 7), 0b01000000u); - + static_assert(RotateBitsLeftCT<ui16>(0b0000000000000000u, 0) == 0b0000000000000000u, ""); static_assert(RotateBitsLeftCT<ui16>(0b0000000000000001u, 0) == 0b0000000000000001u, ""); static_assert(RotateBitsLeftCT<ui16>(0b1000000000000000u, 0) == 0b1000000000000000u, ""); @@ -173,7 +173,7 @@ Y_UNIT_TEST_SUITE(TBitOpsTest) { static_assert(RotateBitsLeftCT<ui16>(0b0000000000000101u, 1) == 0b0000000000001010u, ""); static_assert(RotateBitsLeftCT<ui16>(0b1010000000000000u, 1) == 0b0100000000000001u, ""); static_assert(RotateBitsLeftCT<ui16>(0b1000000000000000u, 15) == 0b0100000000000000u, ""); - + UNIT_ASSERT_VALUES_EQUAL(RotateBitsLeft<ui16>(0b0000000000000000u, 0), 0b0000000000000000u); UNIT_ASSERT_VALUES_EQUAL(RotateBitsLeft<ui16>(0b0000000000000001u, 0), 0b0000000000000001u); UNIT_ASSERT_VALUES_EQUAL(RotateBitsLeft<ui16>(0b1000000000000000u, 0), 0b1000000000000000u); @@ -182,7 +182,7 @@ Y_UNIT_TEST_SUITE(TBitOpsTest) { UNIT_ASSERT_VALUES_EQUAL(RotateBitsLeft<ui16>(0b0000000000000101u, 1), 0b0000000000001010u); UNIT_ASSERT_VALUES_EQUAL(RotateBitsLeft<ui16>(0b1010000000000000u, 1), 0b0100000000000001u); UNIT_ASSERT_VALUES_EQUAL(RotateBitsLeft<ui16>(0b1000000000000000u, 15), 0b0100000000000000u); - + static_assert(RotateBitsLeftCT<ui32>(0b00000000000000000000000000000000u, 0) == 0b00000000000000000000000000000000u, ""); static_assert(RotateBitsLeftCT<ui32>(0b00000000000000000000000000000001u, 0) == 0b00000000000000000000000000000001u, ""); static_assert(RotateBitsLeftCT<ui32>(0b10000000000000000000000000000000u, 0) == 0b10000000000000000000000000000000u, ""); @@ -191,7 +191,7 @@ Y_UNIT_TEST_SUITE(TBitOpsTest) { static_assert(RotateBitsLeftCT<ui32>(0b00000000000000000000000000000101u, 1) == 0b00000000000000000000000000001010u, ""); static_assert(RotateBitsLeftCT<ui32>(0b10100000000000000000000000000000u, 1) == 0b01000000000000000000000000000001u, ""); static_assert(RotateBitsLeftCT<ui32>(0b10000000000000000000000000000000u, 31) == 0b01000000000000000000000000000000u, ""); - + UNIT_ASSERT_VALUES_EQUAL(RotateBitsLeft<ui32>(0b00000000000000000000000000000000u, 0), 0b00000000000000000000000000000000u); UNIT_ASSERT_VALUES_EQUAL(RotateBitsLeft<ui32>(0b00000000000000000000000000000001u, 0), 0b00000000000000000000000000000001u); UNIT_ASSERT_VALUES_EQUAL(RotateBitsLeft<ui32>(0b10000000000000000000000000000000u, 0), 0b10000000000000000000000000000000u); @@ -200,7 +200,7 @@ Y_UNIT_TEST_SUITE(TBitOpsTest) { UNIT_ASSERT_VALUES_EQUAL(RotateBitsLeft<ui32>(0b00000000000000000000000000000101u, 1), 0b00000000000000000000000000001010u); UNIT_ASSERT_VALUES_EQUAL(RotateBitsLeft<ui32>(0b10100000000000000000000000000000u, 1), 0b01000000000000000000000000000001u); UNIT_ASSERT_VALUES_EQUAL(RotateBitsLeft<ui32>(0b10000000000000000000000000000000u, 31), 0b01000000000000000000000000000000u); - + static_assert(RotateBitsLeftCT<ui64>(0b0000000000000000000000000000000000000000000000000000000000000000u, 0) == 0b0000000000000000000000000000000000000000000000000000000000000000u, ""); static_assert(RotateBitsLeftCT<ui64>(0b0000000000000000000000000000000000000000000000000000000000000001u, 0) == 0b0000000000000000000000000000000000000000000000000000000000000001u, ""); static_assert(RotateBitsLeftCT<ui64>(0b1000000000000000000000000000000000000000000000000000000000000000u, 0) == 0b1000000000000000000000000000000000000000000000000000000000000000u, ""); @@ -209,7 +209,7 @@ Y_UNIT_TEST_SUITE(TBitOpsTest) { static_assert(RotateBitsLeftCT<ui64>(0b0000000000000000000000000000000000000000000000000000000000000101u, 1) == 0b0000000000000000000000000000000000000000000000000000000000001010u, ""); static_assert(RotateBitsLeftCT<ui64>(0b1010000000000000000000000000000000000000000000000000000000000000u, 1) == 0b0100000000000000000000000000000000000000000000000000000000000001u, ""); static_assert(RotateBitsLeftCT<ui64>(0b1000000000000000000000000000000000000000000000000000000000000000u, 63) == 0b0100000000000000000000000000000000000000000000000000000000000000u, ""); - + UNIT_ASSERT_VALUES_EQUAL(RotateBitsLeft<ui64>(0b0000000000000000000000000000000000000000000000000000000000000000u, 0), 0b0000000000000000000000000000000000000000000000000000000000000000u); UNIT_ASSERT_VALUES_EQUAL(RotateBitsLeft<ui64>(0b0000000000000000000000000000000000000000000000000000000000000001u, 0), 0b0000000000000000000000000000000000000000000000000000000000000001u); UNIT_ASSERT_VALUES_EQUAL(RotateBitsLeft<ui64>(0b1000000000000000000000000000000000000000000000000000000000000000u, 0), 0b1000000000000000000000000000000000000000000000000000000000000000u); @@ -219,7 +219,7 @@ Y_UNIT_TEST_SUITE(TBitOpsTest) { UNIT_ASSERT_VALUES_EQUAL(RotateBitsLeft<ui64>(0b1010000000000000000000000000000000000000000000000000000000000000u, 1), 0b0100000000000000000000000000000000000000000000000000000000000001u); UNIT_ASSERT_VALUES_EQUAL(RotateBitsLeft<ui64>(0b1000000000000000000000000000000000000000000000000000000000000000u, 63), 0b0100000000000000000000000000000000000000000000000000000000000000u); } - + Y_UNIT_TEST(TestRotateBitsRight) { static_assert(RotateBitsRightCT<ui8>(0b00000000u, 0) == 0b00000000u, ""); static_assert(RotateBitsRightCT<ui8>(0b00000001u, 0) == 0b00000001u, ""); @@ -229,7 +229,7 @@ Y_UNIT_TEST_SUITE(TBitOpsTest) { static_assert(RotateBitsRightCT<ui8>(0b00000101u, 1) == 0b10000010u, ""); static_assert(RotateBitsRightCT<ui8>(0b10100000u, 1) == 0b01010000u, ""); static_assert(RotateBitsRightCT<ui8>(0b00000001u, 7) == 0b00000010u, ""); - + UNIT_ASSERT_VALUES_EQUAL(RotateBitsRight<ui8>(0b00000000u, 0), 0b00000000u); UNIT_ASSERT_VALUES_EQUAL(RotateBitsRight<ui8>(0b00000001u, 0), 0b00000001u); UNIT_ASSERT_VALUES_EQUAL(RotateBitsRight<ui8>(0b10000000u, 0), 0b10000000u); @@ -238,7 +238,7 @@ Y_UNIT_TEST_SUITE(TBitOpsTest) { UNIT_ASSERT_VALUES_EQUAL(RotateBitsRight<ui8>(0b00000101u, 1), 0b10000010u); UNIT_ASSERT_VALUES_EQUAL(RotateBitsRight<ui8>(0b10100000u, 1), 0b01010000u); UNIT_ASSERT_VALUES_EQUAL(RotateBitsRight<ui8>(0b00000001u, 7), 0b00000010u); - + static_assert(RotateBitsRightCT<ui16>(0b0000000000000000u, 0) == 0b0000000000000000u, ""); static_assert(RotateBitsRightCT<ui16>(0b0000000000000001u, 0) == 0b0000000000000001u, ""); static_assert(RotateBitsRightCT<ui16>(0b1000000000000000u, 0) == 0b1000000000000000u, ""); @@ -247,7 +247,7 @@ Y_UNIT_TEST_SUITE(TBitOpsTest) { static_assert(RotateBitsRightCT<ui16>(0b0000000000000101u, 1) == 0b1000000000000010u, ""); static_assert(RotateBitsRightCT<ui16>(0b1010000000000000u, 1) == 0b0101000000000000u, ""); static_assert(RotateBitsRightCT<ui16>(0b0000000000000001u, 15) == 0b0000000000000010u, ""); - + UNIT_ASSERT_VALUES_EQUAL(RotateBitsRight<ui16>(0b0000000000000000u, 0), 0b0000000000000000u); UNIT_ASSERT_VALUES_EQUAL(RotateBitsRight<ui16>(0b0000000000000001u, 0), 0b0000000000000001u); UNIT_ASSERT_VALUES_EQUAL(RotateBitsRight<ui16>(0b1000000000000000u, 0), 0b1000000000000000u); @@ -256,7 +256,7 @@ Y_UNIT_TEST_SUITE(TBitOpsTest) { UNIT_ASSERT_VALUES_EQUAL(RotateBitsRight<ui16>(0b0000000000000101u, 1), 0b1000000000000010u); UNIT_ASSERT_VALUES_EQUAL(RotateBitsRight<ui16>(0b1010000000000000u, 1), 0b0101000000000000u); UNIT_ASSERT_VALUES_EQUAL(RotateBitsRight<ui16>(0b0000000000000001u, 15), 0b0000000000000010u); - + static_assert(RotateBitsRightCT<ui32>(0b00000000000000000000000000000000u, 0) == 0b00000000000000000000000000000000u, ""); static_assert(RotateBitsRightCT<ui32>(0b00000000000000000000000000000001u, 0) == 0b00000000000000000000000000000001u, ""); static_assert(RotateBitsRightCT<ui32>(0b10000000000000000000000000000000u, 0) == 0b10000000000000000000000000000000u, ""); @@ -265,7 +265,7 @@ Y_UNIT_TEST_SUITE(TBitOpsTest) { static_assert(RotateBitsRightCT<ui32>(0b00000000000000000000000000000101u, 1) == 0b10000000000000000000000000000010u, ""); static_assert(RotateBitsRightCT<ui32>(0b10100000000000000000000000000000u, 1) == 0b01010000000000000000000000000000u, ""); static_assert(RotateBitsRightCT<ui32>(0b00000000000000000000000000000001u, 31) == 0b00000000000000000000000000000010u, ""); - + UNIT_ASSERT_VALUES_EQUAL(RotateBitsRight<ui32>(0b00000000000000000000000000000000u, 0), 0b00000000000000000000000000000000u); UNIT_ASSERT_VALUES_EQUAL(RotateBitsRight<ui32>(0b00000000000000000000000000000001u, 0), 0b00000000000000000000000000000001u); UNIT_ASSERT_VALUES_EQUAL(RotateBitsRight<ui32>(0b10000000000000000000000000000000u, 0), 0b10000000000000000000000000000000u); @@ -274,7 +274,7 @@ Y_UNIT_TEST_SUITE(TBitOpsTest) { UNIT_ASSERT_VALUES_EQUAL(RotateBitsRight<ui32>(0b00000000000000000000000000000101u, 1), 0b10000000000000000000000000000010u); UNIT_ASSERT_VALUES_EQUAL(RotateBitsRight<ui32>(0b10100000000000000000000000000000u, 1), 0b01010000000000000000000000000000u); UNIT_ASSERT_VALUES_EQUAL(RotateBitsRight<ui32>(0b00000000000000000000000000000001u, 31), 0b00000000000000000000000000000010u); - + static_assert(RotateBitsRightCT<ui64>(0b0000000000000000000000000000000000000000000000000000000000000000u, 0) == 0b0000000000000000000000000000000000000000000000000000000000000000u, ""); static_assert(RotateBitsRightCT<ui64>(0b0000000000000000000000000000000000000000000000000000000000000001u, 0) == 0b0000000000000000000000000000000000000000000000000000000000000001u, ""); static_assert(RotateBitsRightCT<ui64>(0b1000000000000000000000000000000000000000000000000000000000000000u, 0) == 0b1000000000000000000000000000000000000000000000000000000000000000u, ""); @@ -283,7 +283,7 @@ Y_UNIT_TEST_SUITE(TBitOpsTest) { static_assert(RotateBitsRightCT<ui64>(0b0000000000000000000000000000000000000000000000000000000000000101u, 1) == 0b1000000000000000000000000000000000000000000000000000000000000010u, ""); static_assert(RotateBitsRightCT<ui64>(0b1010000000000000000000000000000000000000000000000000000000000000u, 1) == 0b0101000000000000000000000000000000000000000000000000000000000000u, ""); static_assert(RotateBitsRightCT<ui64>(0b0000000000000000000000000000000000000000000000000000000000000001u, 63) == 0b0000000000000000000000000000000000000000000000000000000000000010u, ""); - + UNIT_ASSERT_VALUES_EQUAL(RotateBitsRight<ui64>(0b0000000000000000000000000000000000000000000000000000000000000000u, 0), 0b0000000000000000000000000000000000000000000000000000000000000000u); UNIT_ASSERT_VALUES_EQUAL(RotateBitsRight<ui64>(0b0000000000000000000000000000000000000000000000000000000000000001u, 0), 0b0000000000000000000000000000000000000000000000000000000000000001u); UNIT_ASSERT_VALUES_EQUAL(RotateBitsRight<ui64>(0b1000000000000000000000000000000000000000000000000000000000000000u, 0), 0b1000000000000000000000000000000000000000000000000000000000000000u); diff --git a/util/generic/buffer.cpp b/util/generic/buffer.cpp index b92697e1d00..dd60963873b 100644 --- a/util/generic/buffer.cpp +++ b/util/generic/buffer.cpp @@ -7,7 +7,7 @@ #include <util/system/sanitizers.h> TBuffer::TBuffer(size_t len) - : Data_(nullptr) + : Data_(nullptr) , Len_(0) , Pos_(0) { @@ -23,7 +23,7 @@ TBuffer::TBuffer(TBuffer&& b) noexcept } TBuffer::TBuffer(const char* buf, size_t len) - : Data_(nullptr) + : Data_(nullptr) , Len_(0) , Pos_(0) { @@ -76,14 +76,14 @@ void TBuffer::DoReserve(size_t realLen) { // FastClp2<T>(x) returns 0 on x from [Max<T>/2 + 2, Max<T>] const size_t len = Max<size_t>(FastClp2(realLen), realLen); - Y_ASSERT(realLen > Len_); - Y_ASSERT(len >= realLen); + Y_ASSERT(realLen > Len_); + Y_ASSERT(len >= realLen); Realloc(len); } void TBuffer::Realloc(size_t len) { - Y_ASSERT(Pos_ <= len); + Y_ASSERT(Pos_ <= len); Data_ = (char*)y_reallocate(Data_, len); Len_ = len; diff --git a/util/generic/buffer.h b/util/generic/buffer.h index 95764674049..ee3e92e90d5 100644 --- a/util/generic/buffer.h +++ b/util/generic/buffer.h @@ -42,7 +42,7 @@ public: } inline void EraseBack(size_t n) noexcept { - Y_ASSERT(n <= Pos_); + Y_ASSERT(n <= Pos_); Pos_ -= n; } @@ -131,7 +131,7 @@ public: } inline void Proceed(size_t pos) { - //Y_ASSERT(pos <= Len_); // see discussion in REVIEW:29021 + //Y_ASSERT(pos <= Len_); // see discussion in REVIEW:29021 Resize(pos); } diff --git a/util/generic/buffer_ut.cpp b/util/generic/buffer_ut.cpp index 437d7122ec2..3f1114018cc 100644 --- a/util/generic/buffer_ut.cpp +++ b/util/generic/buffer_ut.cpp @@ -5,8 +5,8 @@ #include "vector.h" #include "buffer.h" -Y_UNIT_TEST_SUITE(TBufferTest) { - Y_UNIT_TEST(TestEraseBack) { +Y_UNIT_TEST_SUITE(TBufferTest) { + Y_UNIT_TEST(TestEraseBack) { TBuffer buf; buf.Append("1234567", 7); @@ -17,7 +17,7 @@ Y_UNIT_TEST_SUITE(TBufferTest) { UNIT_ASSERT_EQUAL(TString(buf.data(), buf.size()), "1234"); } - Y_UNIT_TEST(TestAppend) { + Y_UNIT_TEST(TestAppend) { const char data[] = "1234567890qwertyuiop"; TBuffer buf(13); @@ -35,7 +35,7 @@ Y_UNIT_TEST_SUITE(TBufferTest) { UNIT_ASSERT_EQUAL(TString(buf.data(), buf.size()), str); } - Y_UNIT_TEST(TestReset) { + Y_UNIT_TEST(TestReset) { char content[] = "some text"; TBuffer buf; @@ -50,7 +50,7 @@ Y_UNIT_TEST_SUITE(TBufferTest) { UNIT_ASSERT_EQUAL(buf.Capacity(), 0); } - Y_UNIT_TEST(TestResize) { + Y_UNIT_TEST(TestResize) { char content[] = "some text"; TBuffer buf; @@ -68,7 +68,7 @@ Y_UNIT_TEST_SUITE(TBufferTest) { UNIT_ASSERT_VALUES_EQUAL(TString(buf.data(), buf.size()), "some"); } - Y_UNIT_TEST(TestReserve) { + Y_UNIT_TEST(TestReserve) { TBuffer buf; UNIT_ASSERT_EQUAL(buf.Capacity(), 0); @@ -101,7 +101,7 @@ Y_UNIT_TEST_SUITE(TBufferTest) { UNIT_ASSERT_EQUAL(buf.Capacity(), 2048); } - Y_UNIT_TEST(TestShrinkToFit) { + Y_UNIT_TEST(TestShrinkToFit) { TBuffer buf; TString content = "some text"; @@ -126,7 +126,7 @@ Y_UNIT_TEST_SUITE(TBufferTest) { } #if 0 -Y_UNIT_TEST(TestAlignUp) { +Y_UNIT_TEST(TestAlignUp) { char content[] = "some text"; TBuffer buf; @@ -145,7 +145,7 @@ Y_UNIT_TEST(TestAlignUp) { #endif #if 0 -Y_UNIT_TEST(TestSpeed) { +Y_UNIT_TEST(TestSpeed) { const char data[] = "1234567890qwertyuiop"; const size_t c = 100000; ui64 t1 = 0; @@ -179,7 +179,7 @@ Y_UNIT_TEST(TestSpeed) { } #endif - Y_UNIT_TEST(TestFillAndChop) { + Y_UNIT_TEST(TestFillAndChop) { TBuffer buf; buf.Append("Some ", 5); buf.Fill('!', 5); diff --git a/util/generic/cast.h b/util/generic/cast.h index 0d4a41f385b..e1807ce1d80 100644 --- a/util/generic/cast.h +++ b/util/generic/cast.h @@ -13,12 +13,12 @@ template <class T, class F> static inline T VerifyDynamicCast(F f) { if (!f) { - return nullptr; + return nullptr; } T ret = dynamic_cast<T>(f); - Y_VERIFY(ret, "verify cast failed"); + Y_VERIFY(ret, "verify cast failed"); return ret; } @@ -68,7 +68,7 @@ template <> class TInteger<true> { public: template <class TUnsigned> - static constexpr bool IsNegative(TUnsigned) noexcept { + static constexpr bool IsNegative(TUnsigned) noexcept { return false; } }; @@ -77,13 +77,13 @@ template <> class TInteger<false> { public: template <class TSigned> - static constexpr bool IsNegative(const TSigned value) noexcept { + static constexpr bool IsNegative(const TSigned value) noexcept { return value < 0; } }; template <class TType> -constexpr bool IsNegative(const TType value) noexcept { +constexpr bool IsNegative(const TType value) noexcept { return TInteger<std::is_unsigned<TType>::value>::IsNegative(value); } @@ -93,7 +93,7 @@ namespace NPrivate { std::is_enum<T>::value, std::underlying_type<T>, // Lazy evaluatuion: do not call ::type here, because underlying_type<T> is undefined if T is not an enum. std::enable_if<true, T> // Wrapping T in a class, that has member ::type typedef. - >::type::type; // Left ::type is for std::conditional, right ::type is for underlying_type/enable_if + >::type::type; // Left ::type is for std::conditional, right ::type is for underlying_type/enable_if template <class TSmall, class TLarge> struct TSafelyConvertible { @@ -112,15 +112,15 @@ constexpr std::enable_if_t<::NPrivate::TSafelyConvertible<TSmallInt, TLargeInt>: } template <class TSmall, class TLarge> -inline std::enable_if_t<!::NPrivate::TSafelyConvertible<TSmall, TLarge>::Result, TSmall> SafeIntegerCast(TLarge largeInt) { +inline std::enable_if_t<!::NPrivate::TSafelyConvertible<TSmall, TLarge>::Result, TSmall> SafeIntegerCast(TLarge largeInt) { using TSmallInt = ::NPrivate::TUnderlyingTypeOrSelf<TSmall>; using TLargeInt = ::NPrivate::TUnderlyingTypeOrSelf<TLarge>; if (std::is_unsigned<TSmallInt>::value && std::is_signed<TLargeInt>::value) { if (IsNegative(largeInt)) { ythrow TBadCastException() << "Conversion '" << TypeName<TLarge>() << '{' << TLargeInt(largeInt) << "}' to '" - << TypeName<TSmallInt>() - << "', negative value converted to unsigned"; + << TypeName<TSmallInt>() + << "', negative value converted to unsigned"; } } @@ -129,14 +129,14 @@ inline std::enable_if_t<!::NPrivate::TSafelyConvertible<TSmall, TLarge>::Result, if (std::is_signed<TSmallInt>::value && std::is_unsigned<TLargeInt>::value) { if (IsNegative(smallInt)) { ythrow TBadCastException() << "Conversion '" << TypeName<TLarge>() << '{' << TLargeInt(largeInt) << "}' to '" - << TypeName<TSmallInt>() - << "', positive value converted to negative"; + << TypeName<TSmallInt>() + << "', positive value converted to negative"; } } if (TLargeInt(smallInt) != largeInt) { ythrow TBadCastException() << "Conversion '" << TypeName<TLarge>() << '{' << TLargeInt(largeInt) << "}' to '" - << TypeName<TSmallInt>() << "', loss of data"; + << TypeName<TSmallInt>() << "', loss of data"; } return static_cast<TSmall>(smallInt); @@ -147,17 +147,17 @@ inline TSmallInt IntegerCast(TLargeInt largeInt) noexcept { try { return SafeIntegerCast<TSmallInt>(largeInt); } catch (const yexception& exc) { - Y_FAIL("IntegerCast: %s", exc.what()); + Y_FAIL("IntegerCast: %s", exc.what()); } } - -/* Convert given enum value to its underlying type. This is just a shortcut for - * `static_cast<std::underlying_type_t<EEnum>>(enum_)`. - */ -template <typename T> -constexpr std::underlying_type_t<T> ToUnderlying(const T enum_) noexcept { - return static_cast<std::underlying_type_t<T>>(enum_); -} + +/* Convert given enum value to its underlying type. This is just a shortcut for + * `static_cast<std::underlying_type_t<EEnum>>(enum_)`. + */ +template <typename T> +constexpr std::underlying_type_t<T> ToUnderlying(const T enum_) noexcept { + return static_cast<std::underlying_type_t<T>>(enum_); +} // std::bit_cast from c++20 template <class TTarget, class TSource> diff --git a/util/generic/cast_ut.cpp b/util/generic/cast_ut.cpp index 718a8de79de..0ab58f2efca 100644 --- a/util/generic/cast_ut.cpp +++ b/util/generic/cast_ut.cpp @@ -7,7 +7,7 @@ class TGenericCastsTest: public TTestBase { UNIT_TEST(TestVerifyDynamicCast) UNIT_TEST(TestIntegralCast) UNIT_TEST(TestEnumCast) - UNIT_TEST(TestToUnderlying) + UNIT_TEST(TestToUnderlying) UNIT_TEST(TestBitCast) UNIT_TEST_SUITE_END(); @@ -55,32 +55,32 @@ private: UNIT_ASSERT(SafeIntegerCast<B>(-1) == BM1); UNIT_ASSERT(SafeIntegerCast<C>(1) == C::CM1); } - - void TestToUnderlying() { - enum A { - AM1 = -1 - }; - + + void TestToUnderlying() { + enum A { + AM1 = -1 + }; + enum B: int { - BM1 = -1 - }; - + BM1 = -1 + }; + enum class C: unsigned short { - CM1 = 1 - }; - - static_assert(static_cast<std::underlying_type_t<A>>(AM1) == ToUnderlying(AM1), ""); - static_assert(static_cast<std::underlying_type_t<B>>(BM1) == ToUnderlying(BM1), ""); - static_assert(static_cast<std::underlying_type_t<C>>(C::CM1) == ToUnderlying(C::CM1), ""); - - static_assert(std::is_same<std::underlying_type_t<A>, decltype(ToUnderlying(AM1))>::value, ""); - static_assert(std::is_same<std::underlying_type_t<B>, decltype(ToUnderlying(BM1))>::value, ""); - static_assert(std::is_same<std::underlying_type_t<C>, decltype(ToUnderlying(C::CM1))>::value, ""); - - UNIT_ASSERT_VALUES_EQUAL(static_cast<std::underlying_type_t<A>>(AM1), ToUnderlying(AM1)); - UNIT_ASSERT_VALUES_EQUAL(static_cast<std::underlying_type_t<B>>(BM1), ToUnderlying(BM1)); - UNIT_ASSERT_VALUES_EQUAL(static_cast<std::underlying_type_t<C>>(C::CM1), ToUnderlying(C::CM1)); - } + CM1 = 1 + }; + + static_assert(static_cast<std::underlying_type_t<A>>(AM1) == ToUnderlying(AM1), ""); + static_assert(static_cast<std::underlying_type_t<B>>(BM1) == ToUnderlying(BM1), ""); + static_assert(static_cast<std::underlying_type_t<C>>(C::CM1) == ToUnderlying(C::CM1), ""); + + static_assert(std::is_same<std::underlying_type_t<A>, decltype(ToUnderlying(AM1))>::value, ""); + static_assert(std::is_same<std::underlying_type_t<B>, decltype(ToUnderlying(BM1))>::value, ""); + static_assert(std::is_same<std::underlying_type_t<C>, decltype(ToUnderlying(C::CM1))>::value, ""); + + UNIT_ASSERT_VALUES_EQUAL(static_cast<std::underlying_type_t<A>>(AM1), ToUnderlying(AM1)); + UNIT_ASSERT_VALUES_EQUAL(static_cast<std::underlying_type_t<B>>(BM1), ToUnderlying(BM1)); + UNIT_ASSERT_VALUES_EQUAL(static_cast<std::underlying_type_t<C>>(C::CM1), ToUnderlying(C::CM1)); + } void TestBitCast() { // Change sign of float diff --git a/util/generic/explicit_type.h b/util/generic/explicit_type.h index 34e269f1551..e43b8455f7d 100644 --- a/util/generic/explicit_type.h +++ b/util/generic/explicit_type.h @@ -24,7 +24,7 @@ template <class T> class TExplicitType { public: template <class OtherT> - TExplicitType(const OtherT& value, std::enable_if_t<std::is_same<OtherT, T>::value>* = nullptr) noexcept + TExplicitType(const OtherT& value, std::enable_if_t<std::is_same<OtherT, T>::value>* = nullptr) noexcept : Value_(value) { } diff --git a/util/generic/explicit_type_ut.cpp b/util/generic/explicit_type_ut.cpp index 50a745f090e..2811e789f23 100644 --- a/util/generic/explicit_type_ut.cpp +++ b/util/generic/explicit_type_ut.cpp @@ -38,8 +38,8 @@ struct IntConstructible { } }; -Y_UNIT_TEST_SUITE(TestExplicitType) { - Y_UNIT_TEST(Test1) { +Y_UNIT_TEST_SUITE(TestExplicitType) { + Y_UNIT_TEST(Test1) { UNIT_ASSERT_VALUES_EQUAL(static_cast<bool>(TCallable<TExplicitlyCallable<char>, char>::Result), true); UNIT_ASSERT_VALUES_EQUAL(static_cast<bool>(TCallable<TExplicitlyCallable<char>, int>::Result), false); UNIT_ASSERT_VALUES_EQUAL(static_cast<bool>(TCallable<TExplicitlyCallable<char>, wchar_t>::Result), false); diff --git a/util/generic/fastqueue.h b/util/generic/fastqueue.h index 1fee5b86f6e..6f01fec4d63 100644 --- a/util/generic/fastqueue.h +++ b/util/generic/fastqueue.h @@ -27,7 +27,7 @@ public: } inline T Pop() { - Y_ASSERT(!this->Empty()); + Y_ASSERT(!this->Empty()); THolder<THelper> tmp(Queue_.PopBack()); --Size_; diff --git a/util/generic/flags.cpp b/util/generic/flags.cpp index 2ee52188a0d..f16a6435624 100644 --- a/util/generic/flags.cpp +++ b/util/generic/flags.cpp @@ -3,26 +3,26 @@ #include <util/stream/format.h> #include <util/system/yassert.h> -void ::NPrivate::PrintFlags(IOutputStream& stream, ui64 value, size_t size) { +void ::NPrivate::PrintFlags(IOutputStream& stream, ui64 value, size_t size) { /* Note that this function is in cpp because we need to break circular * dependency between TFlags and ENumberFormat. */ stream << "TFlags("; switch (size) { - case 1: - stream << Bin(static_cast<ui8>(value), HF_FULL); - break; - case 2: - stream << Bin(static_cast<ui16>(value), HF_FULL); - break; - case 4: - stream << Bin(static_cast<ui32>(value), HF_FULL); - break; - case 8: - stream << Bin(static_cast<ui64>(value), HF_FULL); - break; - default: - Y_VERIFY(false); + case 1: + stream << Bin(static_cast<ui8>(value), HF_FULL); + break; + case 2: + stream << Bin(static_cast<ui16>(value), HF_FULL); + break; + case 4: + stream << Bin(static_cast<ui32>(value), HF_FULL); + break; + case 8: + stream << Bin(static_cast<ui64>(value), HF_FULL); + break; + default: + Y_VERIFY(false); } stream << ")"; diff --git a/util/generic/flags.h b/util/generic/flags.h index a1f5921d423..3b0eb4a2e20 100644 --- a/util/generic/flags.h +++ b/util/generic/flags.h @@ -6,9 +6,9 @@ #include <util/generic/typetraits.h> #include <util/generic/fwd.h> -class IOutputStream; +class IOutputStream; namespace NPrivate { - void PrintFlags(IOutputStream& stream, ui64 value, size_t size); + void PrintFlags(IOutputStream& stream, ui64 value, size_t size); } /** @@ -34,10 +34,10 @@ namespace NPrivate { template <class Enum> class TFlags { static_assert(std::is_enum<Enum>::value, "Expecting an enumeration here."); - + public: using TEnum = Enum; - using TInt = std::underlying_type_t<Enum>; + using TInt = std::underlying_type_t<Enum>; constexpr TFlags(std::nullptr_t = 0) : Value_(0) @@ -79,18 +79,18 @@ public: return TFlags(TFlag(l.Value_ ^ r.Value_)); } - constexpr friend TFlags - operator^(TEnum l, TFlags r) { + constexpr friend TFlags + operator^(TEnum l, TFlags r) { return TFlags(TFlag(static_cast<TInt>(l) ^ r.Value_)); } - constexpr friend TFlags - operator^(TFlags l, TEnum r) { + constexpr friend TFlags + operator^(TFlags l, TEnum r) { return TFlags(TFlag(l.Value_ ^ static_cast<TInt>(r))); } - constexpr friend TFlags - operator&(TFlags l, TFlags r) { + constexpr friend TFlags + operator&(TFlags l, TFlags r) { return TFlags(TFlag(l.Value_ & r.Value_)); } @@ -177,7 +177,7 @@ public: return *this; } - friend IOutputStream& operator<<(IOutputStream& stream, const TFlags& flags) { + friend IOutputStream& operator<<(IOutputStream& stream, const TFlags& flags) { ::NPrivate::PrintFlags(stream, static_cast<ui64>(flags.Value_), sizeof(TInt)); return stream; } diff --git a/util/generic/flags_ut.cpp b/util/generic/flags_ut.cpp index 5377c6a0580..9290f55099c 100644 --- a/util/generic/flags_ut.cpp +++ b/util/generic/flags_ut.cpp @@ -31,7 +31,7 @@ namespace { Y_DECLARE_OPERATORS_FOR_FLAGS(ETestFlags3) } -Y_UNIT_TEST_SUITE(TFlagsTest) { +Y_UNIT_TEST_SUITE(TFlagsTest) { template <class Enum> void TestEnum() { { @@ -66,12 +66,12 @@ Y_UNIT_TEST_SUITE(TFlagsTest) { } } - Y_UNIT_TEST(TestFlags) { + Y_UNIT_TEST(TestFlags) { TestEnum<ETestFlag1>(); TestEnum<ETestFlag2>(); } - Y_UNIT_TEST(TestZero) { + Y_UNIT_TEST(TestZero) { /* This code should simply compile. */ ETest1 f = 0; @@ -82,7 +82,7 @@ Y_UNIT_TEST_SUITE(TFlagsTest) { ff = 0; } - Y_UNIT_TEST(TestOutput) { + Y_UNIT_TEST(TestOutput) { ETest1 value0 = nullptr, value1 = Test1, value7 = Test1 | Test2 | Test4; UNIT_ASSERT_VALUES_EQUAL(ToString(value0), "TFlags(0000000000000000)"); @@ -90,7 +90,7 @@ Y_UNIT_TEST_SUITE(TFlagsTest) { UNIT_ASSERT_VALUES_EQUAL(ToString(value7), "TFlags(0000000000000111)"); } - Y_UNIT_TEST(TestHash) { + Y_UNIT_TEST(TestHash) { ETest1 value0 = nullptr, value1 = Test1; THashMap<ETest1, int> hash; @@ -101,7 +101,7 @@ Y_UNIT_TEST_SUITE(TFlagsTest) { UNIT_ASSERT_VALUES_EQUAL(hash[value1], 1); } - Y_UNIT_TEST(TestBaseType) { + Y_UNIT_TEST(TestBaseType) { ui16 goodValue = 7; auto goodFlags = ETest1::FromBaseType(goodValue); UNIT_ASSERT(goodFlags& ETestFlag1::Test1); diff --git a/util/generic/function_ut.cpp b/util/generic/function_ut.cpp index 3880295a9fc..730d2dc7de1 100644 --- a/util/generic/function_ut.cpp +++ b/util/generic/function_ut.cpp @@ -3,7 +3,7 @@ #include <library/cpp/testing/unittest/registar.h> -Y_UNIT_TEST_SUITE(TestFunctionSignature) { +Y_UNIT_TEST_SUITE(TestFunctionSignature) { int FF(double x) { return (int)x; } @@ -18,15 +18,15 @@ Y_UNIT_TEST_SUITE(TestFunctionSignature) { } }; - Y_UNIT_TEST(TestPlainFunc) { + Y_UNIT_TEST(TestPlainFunc) { UNIT_ASSERT_TYPES_EQUAL(TFunctionSignature<decltype(FF)>, decltype(FF)); } - Y_UNIT_TEST(TestMethod) { + Y_UNIT_TEST(TestMethod) { UNIT_ASSERT_TYPES_EQUAL(TFunctionSignature<decltype(&A::F)>, decltype(FF)); } - Y_UNIT_TEST(TestLambda) { + Y_UNIT_TEST(TestLambda) { auto f = [](double x) -> int { return FF(x); }; @@ -34,7 +34,7 @@ Y_UNIT_TEST_SUITE(TestFunctionSignature) { UNIT_ASSERT_TYPES_EQUAL(TFunctionSignature<decltype(f)>, decltype(FF)); } - Y_UNIT_TEST(TestFunction) { + Y_UNIT_TEST(TestFunction) { std::function<int(double)> f(FF); UNIT_ASSERT_TYPES_EQUAL(TFunctionSignature<decltype(f)>, decltype(FF)); @@ -51,15 +51,15 @@ Y_UNIT_TEST_SUITE(TestFunctionSignature) { #undef FA } - Y_UNIT_TEST(TestTypeErasureTraits) { + Y_UNIT_TEST(TestTypeErasureTraits) { TestCT<std::function<int(double, char)>>(); } - Y_UNIT_TEST(TestPlainFunctionTraits) { + Y_UNIT_TEST(TestPlainFunctionTraits) { TestCT<decltype(FFF)>(); } - Y_UNIT_TEST(TestLambdaTraits) { + Y_UNIT_TEST(TestLambdaTraits) { auto fff = [](double xx, char xxx) -> int { return FFF(xx, xxx); }; diff --git a/util/generic/fuzz/vector/main.cpp b/util/generic/fuzz/vector/main.cpp index 0a0293f7954..b5ad0813e3d 100644 --- a/util/generic/fuzz/vector/main.cpp +++ b/util/generic/fuzz/vector/main.cpp @@ -2,7 +2,7 @@ #include <util/stream/mem.h> template <class T> -static inline T Read(IInputStream& in) { +static inline T Read(IInputStream& in) { T t; in.LoadOrFail(&t, sizeof(t)); diff --git a/util/generic/fwd.h b/util/generic/fwd.h index 5cc2da40e51..53766a91fa5 100644 --- a/util/generic/fwd.h +++ b/util/generic/fwd.h @@ -99,8 +99,8 @@ class TBitMap; //autopointers class TDelete; -class TDeleteArray; -class TFree; +class TDeleteArray; +class TFree; class TCopyNew; template <class T, class D = TDelete> @@ -112,57 +112,57 @@ class THolder; template <class T, class C, class D = TDelete> class TRefCounted; -template <class T> -class TDefaultIntrusivePtrOps; - +template <class T> +class TDefaultIntrusivePtrOps; + template <class T, class Ops> -class TSimpleIntrusiveOps; - -template <class T, class Ops = TDefaultIntrusivePtrOps<T>> +class TSimpleIntrusiveOps; + +template <class T, class Ops = TDefaultIntrusivePtrOps<T>> class TIntrusivePtr; -template <class T, class Ops = TDefaultIntrusivePtrOps<T>> -class TIntrusiveConstPtr; - -template <class T, class Ops = TDefaultIntrusivePtrOps<T>> -using TSimpleIntrusivePtr = TIntrusivePtr<T, TSimpleIntrusiveOps<T, Ops>>; - +template <class T, class Ops = TDefaultIntrusivePtrOps<T>> +class TIntrusiveConstPtr; + +template <class T, class Ops = TDefaultIntrusivePtrOps<T>> +using TSimpleIntrusivePtr = TIntrusivePtr<T, TSimpleIntrusiveOps<T, Ops>>; + template <class T, class C, class D = TDelete> class TSharedPtr; template <class T, class C = TCopyNew, class D = TDelete> class TCopyPtr; -template <class TPtr, class TCopy = TCopyNew> -class TCowPtr; - -template <typename T> -class TPtrArg; - -template <typename T> -using TArrayHolder = THolder<T, TDeleteArray>; - -template <typename T> -using TMallocHolder = THolder<T, TFree>; - -template <typename T> -using TArrayPtr = TAutoPtr<T, TDeleteArray>; - -template <typename T> -using TMallocPtr = TAutoPtr<T, TFree>; - +template <class TPtr, class TCopy = TCopyNew> +class TCowPtr; + +template <typename T> +class TPtrArg; + +template <typename T> +using TArrayHolder = THolder<T, TDeleteArray>; + +template <typename T> +using TMallocHolder = THolder<T, TFree>; + +template <typename T> +using TArrayPtr = TAutoPtr<T, TDeleteArray>; + +template <typename T> +using TMallocPtr = TAutoPtr<T, TFree>; + //maybe namespace NMaybe { struct TPolicyUndefinedExcept; } - + template <class T, class Policy = ::NMaybe::TPolicyUndefinedExcept> class TMaybe; - -struct TGUID; - -template <class T> -class TArrayRef; - -template <class T> -using TConstArrayRef = TArrayRef<const T>; + +struct TGUID; + +template <class T> +class TArrayRef; + +template <class T> +using TConstArrayRef = TArrayRef<const T>; diff --git a/util/generic/guid.cpp b/util/generic/guid.cpp index 8b907457bc6..c403c9b182a 100644 --- a/util/generic/guid.cpp +++ b/util/generic/guid.cpp @@ -87,7 +87,7 @@ static bool GetDigit(const char c, ui32& digit) { return true; } -bool GetGuid(const TStringBuf s, TGUID& result) { +bool GetGuid(const TStringBuf s, TGUID& result) { size_t partId = 0; ui64 partValue = 0; bool isEmptyPart = true; @@ -129,7 +129,7 @@ bool GetGuid(const TStringBuf s, TGUID& result) { // Parses GUID from s and checks that it's valid. // In case of error returns TGUID(). -TGUID GetGuid(const TStringBuf s) { +TGUID GetGuid(const TStringBuf s) { TGUID result; if (GetGuid(s, result)) { @@ -139,7 +139,7 @@ TGUID GetGuid(const TStringBuf s) { return TGUID(); } -bool GetUuid(const TStringBuf s, TGUID& result) { +bool GetUuid(const TStringBuf s, TGUID& result) { if (s.size() != 36) { return false; } @@ -175,7 +175,7 @@ bool GetUuid(const TStringBuf s, TGUID& result) { // Parses GUID from uuid and checks that it's valid. // In case of error returns TGUID(). -TGUID GetUuid(const TStringBuf s) { +TGUID GetUuid(const TStringBuf s) { TGUID result; if (GetUuid(s, result)) { diff --git a/util/generic/guid.h b/util/generic/guid.h index 2bf6c8ad99c..7c1884d96ec 100644 --- a/util/generic/guid.h +++ b/util/generic/guid.h @@ -1,7 +1,7 @@ #pragma once -#include "fwd.h" - +#include "fwd.h" + #include <util/str_stl.h> /** @@ -15,13 +15,13 @@ * and https://st.yandex-team.ru/IGNIETFERRO-768 for details. */ struct TGUID { - ui32 dw[4] = {}; + ui32 dw[4] = {}; - constexpr bool IsEmpty() const noexcept { + constexpr bool IsEmpty() const noexcept { return (dw[0] | dw[1] | dw[2] | dw[3]) == 0; } - constexpr explicit operator bool() const noexcept { + constexpr explicit operator bool() const noexcept { return !IsEmpty(); } @@ -44,23 +44,23 @@ struct TGUID { static TGUID CreateTimebased(); }; -constexpr bool operator==(const TGUID& a, const TGUID& b) noexcept { - return a.dw[0] == b.dw[0] && a.dw[1] == b.dw[1] && a.dw[2] == b.dw[2] && a.dw[3] == b.dw[3]; +constexpr bool operator==(const TGUID& a, const TGUID& b) noexcept { + return a.dw[0] == b.dw[0] && a.dw[1] == b.dw[1] && a.dw[2] == b.dw[2] && a.dw[3] == b.dw[3]; } -constexpr bool operator!=(const TGUID& a, const TGUID& b) noexcept { +constexpr bool operator!=(const TGUID& a, const TGUID& b) noexcept { return !(a == b); } struct TGUIDHash { - constexpr int operator()(const TGUID& a) const noexcept { + constexpr int operator()(const TGUID& a) const noexcept { return a.dw[0] + a.dw[1] + a.dw[2] + a.dw[3]; } }; template <> struct THash<TGUID> { - constexpr size_t operator()(const TGUID& g) const noexcept { + constexpr size_t operator()(const TGUID& g) const noexcept { return (unsigned int)TGUIDHash()(g); } }; @@ -68,12 +68,12 @@ struct THash<TGUID> { void CreateGuid(TGUID* res); TString GetGuidAsString(const TGUID& g); TString CreateGuidAsString(); -TGUID GetGuid(TStringBuf s); -bool GetGuid(TStringBuf s, TGUID& result); +TGUID GetGuid(TStringBuf s); +bool GetGuid(TStringBuf s, TGUID& result); /** * Functions for correct parsing RFC4122 GUID, which described in * https://en.wikipedia.org/wiki/Universally_unique_identifier **/ -TGUID GetUuid(TStringBuf s); -bool GetUuid(TStringBuf s, TGUID& result); +TGUID GetUuid(TStringBuf s); +bool GetUuid(TStringBuf s, TGUID& result); diff --git a/util/generic/guid_ut.cpp b/util/generic/guid_ut.cpp index 048354ff399..b9c974b072d 100644 --- a/util/generic/guid_ut.cpp +++ b/util/generic/guid_ut.cpp @@ -2,7 +2,7 @@ #include "guid.h" -Y_UNIT_TEST_SUITE(TGuidTest) { +Y_UNIT_TEST_SUITE(TGuidTest) { //TODO - make real constructor static TGUID Construct(ui32 d1, ui32 d2, ui32 d3, ui32 d4) { TGUID ret; @@ -20,7 +20,7 @@ Y_UNIT_TEST_SUITE(TGuidTest) { TString S; }; - Y_UNIT_TEST(Test1) { + Y_UNIT_TEST(Test1) { for (size_t i = 0; i < 1000; ++i) { TGUID g; @@ -30,7 +30,7 @@ Y_UNIT_TEST_SUITE(TGuidTest) { } } - Y_UNIT_TEST(Test2) { + Y_UNIT_TEST(Test2) { const TTest tests[] = { {Construct(1, 1, 1, 1), "1-1-1-1"}, {Construct(0, 0, 0, 0), "0-0-0-0"}, @@ -60,19 +60,19 @@ Y_UNIT_TEST_SUITE(TGuidTest) { {Construct(0, 0, 0, 0), "000000000000-000000000000000000000000000000000000000-000-0"}, }; - for (const auto& t : tests) { + for (const auto& t : tests) { UNIT_ASSERT_EQUAL(t.G, GetGuid(t.S)); } } - Y_UNIT_TEST(Test3) { + Y_UNIT_TEST(Test3) { //if this test failed, please, fix buffer size in GetGuidAsString() TGUID max = Construct(Max<ui32>(), Max<ui32>(), Max<ui32>(), Max<ui32>()); UNIT_ASSERT_EQUAL(GetGuidAsString(max).length(), 35); } - Y_UNIT_TEST(Test4) { + Y_UNIT_TEST(Test4) { UNIT_ASSERT_VALUES_EQUAL(GetGuidAsString(Construct(1, 2, 3, 4)), "1-2-3-4"); UNIT_ASSERT_VALUES_EQUAL(GetGuidAsString(Construct(1, 2, 0xFFFFFF, 4)), "1-2-ffffff-4"); UNIT_ASSERT_VALUES_EQUAL(GetGuidAsString(Construct(0xFAFA, 2, 3, 4)), "fafa-2-3-4"); @@ -80,7 +80,7 @@ Y_UNIT_TEST_SUITE(TGuidTest) { UNIT_ASSERT_VALUES_EQUAL(GetGuidAsString(Construct(1, 2, 3, 0xDEAD)), "1-2-3-dead"); } - Y_UNIT_TEST(Test5) { + Y_UNIT_TEST(Test5) { const TTest tests[] = { {TGUID(), "1-1-1-1-1"}, {TGUID(), "00000001-0001-0001-0001-00000000001-"}, diff --git a/util/generic/hash.h b/util/generic/hash.h index e46db21fa97..3375f616895 100644 --- a/util/generic/hash.h +++ b/util/generic/hash.h @@ -223,17 +223,17 @@ public: _yhashtable_buckets(const Alloc& other) : base_type(other) - , Data(nullptr) + , Data(nullptr) , Size() { } ~_yhashtable_buckets() { - Y_ASSERT(!Data); + Y_ASSERT(!Data); } void initialize_dynamic(TBucketDivisor size) { - Y_ASSERT(!Data); + Y_ASSERT(!Data); Data = this->_get_alloc().allocate(size() + 2) + 1; Size = size; @@ -242,7 +242,7 @@ public: } void deinitialize_dynamic() { - Y_ASSERT(Data); + Y_ASSERT(Data); this->_get_alloc().deallocate(Data - 1, *reinterpret_cast<size_type*>(Data - 1)); Data = pointer(); @@ -257,7 +257,7 @@ public: } void deinitialize_static() { - Y_ASSERT(Data); + Y_ASSERT(Data); Data = pointer(); Size = TBucketDivisor(); @@ -500,7 +500,7 @@ private: node* get_node() { node* result = this->_get_alloc().allocate(1); - Y_ASSERT((reinterpret_cast<uintptr_t>(result) & 1) == 0); /* We're using the last bit of the node pointer. */ + Y_ASSERT((reinterpret_cast<uintptr_t>(result) & 1) == 0); /* We're using the last bit of the node pointer. */ return result; } void put_node(node* p) { @@ -640,7 +640,7 @@ public: } iterator end() { - return iterator(nullptr); + return iterator(nullptr); } /*y*/ const_iterator begin() const { @@ -651,7 +651,7 @@ public: } const_iterator end() const { - return const_iterator(nullptr); + return const_iterator(nullptr); } /*y*/ public: @@ -767,7 +767,7 @@ public: node* first; for (first = buckets[n]; first && !equals(get_key(first->val), key); - first = ((uintptr_t)first->next & 1) ? nullptr : first->next) /*y*/ + first = ((uintptr_t)first->next & 1) ? nullptr : first->next) /*y*/ { } return iterator(first); /*y*/ @@ -779,7 +779,7 @@ public: const node* first; for (first = buckets[n]; first && !equals(get_key(first->val), key); - first = ((uintptr_t)first->next & 1) ? nullptr : first->next) /*y*/ + first = ((uintptr_t)first->next & 1) ? nullptr : first->next) /*y*/ { } return const_iterator(first); /*y*/ @@ -839,7 +839,7 @@ public: // implemented in save_stl.h template <class KeySaver> - int save_for_st(IOutputStream* stream, KeySaver& ks, sthash<int, int, THash<int>, TEqualTo<int>, typename KeySaver::TSizeType>* stHash = nullptr) const; + int save_for_st(IOutputStream* stream, KeySaver& ks, sthash<int, int, THash<int>, TEqualTo<int>, typename KeySaver::TSizeType>* stHash = nullptr) const; void clear(size_type downsize) { basic_clear(); @@ -956,13 +956,13 @@ private: template <class V> __yhashtable_iterator<V>& __yhashtable_iterator<V>::operator++() { - Y_ASSERT(cur); + Y_ASSERT(cur); cur = cur->next; if ((uintptr_t)cur & 1) { node** bucket = (node**)((uintptr_t)cur & ~1); - while (*bucket == nullptr) + while (*bucket == nullptr) ++bucket; - Y_ASSERT(*bucket != nullptr); + Y_ASSERT(*bucket != nullptr); cur = (node*)((uintptr_t)*bucket & ~1); } return *this; @@ -977,13 +977,13 @@ inline __yhashtable_iterator<V> __yhashtable_iterator<V>::operator++(int) { template <class V> __yhashtable_const_iterator<V>& __yhashtable_const_iterator<V>::operator++() { - Y_ASSERT(cur); + Y_ASSERT(cur); cur = cur->next; if ((uintptr_t)cur & 1) { node** bucket = (node**)((uintptr_t)cur & ~1); - while (*bucket == nullptr) + while (*bucket == nullptr) ++bucket; - Y_ASSERT(*bucket != nullptr); + Y_ASSERT(*bucket != nullptr); cur = (node*)((uintptr_t)*bucket & ~1); } return *this; @@ -1166,7 +1166,7 @@ typename THashTable<V, K, HF, Ex, Eq, A>::size_type THashTable<V, K, HF, Ex, Eq, } } if (equals(get_key(first->val), key)) { - buckets[n] = ((uintptr_t)first->next & 1) ? nullptr : first->next; /*y*/ + buckets[n] = ((uintptr_t)first->next & 1) ? nullptr : first->next; /*y*/ ++erased; --num_elements; delete_node(first); @@ -1196,7 +1196,7 @@ typename THashTable<V, K, HF, Ex, Eq, A>::size_type THashTable<V, K, HF, Ex, Eq, } } if (equals(get_key(first->val), key)) { - buckets[n] = ((uintptr_t)first->next & 1) ? nullptr : first->next; /*y*/ + buckets[n] = ((uintptr_t)first->next & 1) ? nullptr : first->next; /*y*/ --num_elements; delete_node(first); return 1; @@ -1212,7 +1212,7 @@ void THashTable<V, K, HF, Ex, Eq, A>::erase(const iterator& it) { node* cur = buckets[n]; if (cur == p) { - buckets[n] = ((uintptr_t)cur->next & 1) ? nullptr : cur->next; /*y*/ + buckets[n] = ((uintptr_t)cur->next & 1) ? nullptr : cur->next; /*y*/ delete_node(cur); --num_elements; } else { @@ -1280,7 +1280,7 @@ bool THashTable<V, K, HF, Ex, Eq, A>::reserve(size_type num_elements_hint) { while (first) { size_type new_bucket = bkt_num(first->val, n); node* next = first->next; - buckets[bucket] = ((uintptr_t)next & 1) ? nullptr : next; /*y*/ + buckets[bucket] = ((uintptr_t)next & 1) ? nullptr : next; /*y*/ next = tmp[new_bucket]; first->next = next ? next : (node*)((uintptr_t) & (tmp[new_bucket + 1]) | 1); /*y*/ tmp[new_bucket] = first; @@ -1298,7 +1298,7 @@ bool THashTable<V, K, HF, Ex, Eq, A>::reserve(size_type num_elements_hint) { while (tmp[bucket]) { node* next = tmp[bucket]->next; delete_node(tmp[bucket]); - tmp[bucket] = ((uintptr_t)next & 1) ? nullptr : next /*y*/; + tmp[bucket] = ((uintptr_t)next & 1) ? nullptr : next /*y*/; } } throw; @@ -1356,7 +1356,7 @@ void THashTable<V, K, HF, Ex, Eq, A>::basic_clear() { delete_node(cur); cur = next; } - *first = nullptr; + *first = nullptr; } } num_elements = 0; @@ -1364,7 +1364,7 @@ void THashTable<V, K, HF, Ex, Eq, A>::basic_clear() { template <class V, class K, class HF, class Ex, class Eq, class A> void THashTable<V, K, HF, Ex, Eq, A>::copy_from_dynamic(const THashTable& ht) { - Y_ASSERT(buckets.size() == ht.buckets.size() && !ht.empty()); + Y_ASSERT(buckets.size() == ht.buckets.size() && !ht.empty()); #ifdef __STL_USE_EXCEPTIONS try { @@ -1637,7 +1637,7 @@ public: template <class TKey> T& operator[](const TKey& key) { - insert_ctx ctx = nullptr; + insert_ctx ctx = nullptr; iterator it = find(key, ctx); if (it != end()) { @@ -1712,7 +1712,7 @@ public: // if (stHash != NULL) bucket_count() must be equal to stHash->bucket_count() template <class KeySaver> - int save_for_st(IOutputStream* stream, KeySaver& ks, sthash<int, int, THash<int>, TEqualTo<int>, typename KeySaver::TSizeType>* stHash = nullptr) const { + int save_for_st(IOutputStream* stream, KeySaver& ks, sthash<int, int, THash<int>, TEqualTo<int>, typename KeySaver::TSizeType>* stHash = nullptr) const { return rep.template save_for_st<KeySaver>(stream, ks, stHash); } @@ -1978,7 +1978,7 @@ public: // if (stHash != NULL) bucket_count() must be equal to stHash->bucket_count() template <class KeySaver> - int save_for_st(IOutputStream* stream, KeySaver& ks, sthash<int, int, THash<int>, TEqualTo<int>, typename KeySaver::TSizeType>* stHash = nullptr) const { + int save_for_st(IOutputStream* stream, KeySaver& ks, sthash<int, int, THash<int>, TEqualTo<int>, typename KeySaver::TSizeType>* stHash = nullptr) const { return rep.template save_for_st<KeySaver>(stream, ks, stHash); } diff --git a/util/generic/hash_primes_ut.cpp b/util/generic/hash_primes_ut.cpp index 7b5bf8b5c9a..31ae562af3d 100644 --- a/util/generic/hash_primes_ut.cpp +++ b/util/generic/hash_primes_ut.cpp @@ -6,8 +6,8 @@ #include <util/string/builder.h> #include <util/random/fast.h> -Y_UNIT_TEST_SUITE(TestHashPrimes) { - Y_UNIT_TEST(Test1) { +Y_UNIT_TEST_SUITE(TestHashPrimes) { + Y_UNIT_TEST(Test1) { UNIT_ASSERT_VALUES_EQUAL(HashBucketCount(1), 7); UNIT_ASSERT_VALUES_EQUAL(HashBucketCount(6), 7); UNIT_ASSERT_VALUES_EQUAL(HashBucketCount(7), 7); diff --git a/util/generic/hash_set.h b/util/generic/hash_set.h index e8088cf23b4..8da03fd597e 100644 --- a/util/generic/hash_set.h +++ b/util/generic/hash_set.h @@ -241,7 +241,7 @@ public: } template <class KeySaver> - int save_for_st(IOutputStream* stream, KeySaver& ks) const { + int save_for_st(IOutputStream* stream, KeySaver& ks) const { return rep.template save_for_st<KeySaver>(stream, ks); } diff --git a/util/generic/hash_ut.cpp b/util/generic/hash_ut.cpp index 0551d587708..060d6176504 100644 --- a/util/generic/hash_ut.cpp +++ b/util/generic/hash_ut.cpp @@ -57,7 +57,7 @@ class THashTest: public TTestBase { UNIT_TEST(TestHMMapInitializerList); UNIT_TEST(TestHSetInitializerList); UNIT_TEST(TestHMSetInitializerList); - UNIT_TEST(TestHSetInsertInitializerList); + UNIT_TEST(TestHSetInsertInitializerList); UNIT_TEST(TestTupleHash); UNIT_TEST_SUITE_END(); @@ -108,7 +108,7 @@ protected: void TestHMMapInitializerList(); void TestHSetInitializerList(); void TestHMSetInitializerList(); - void TestHSetInsertInitializerList(); + void TestHSetInsertInitializerList(); void TestTupleHash(); }; @@ -798,7 +798,7 @@ public: TCountingAllocator(TAllocatorCounters* counters) : Counters_(counters) { - Y_ASSERT(counters); + Y_ASSERT(counters); } template <class Other> @@ -1187,44 +1187,44 @@ void THashTest::TestHMSetInitializerList() { h2.insert("baz"); UNIT_ASSERT_EQUAL(h1, h2); } - -namespace { - struct TFoo { - int A; - int B; - + +namespace { + struct TFoo { + int A; + int B; + bool operator==(const TFoo& o) const { - return A == o.A && B == o.B; - } - }; -} - -template <> -struct THash<TFoo> { - size_t operator()(const TFoo& v) const { - return v.A ^ v.B; - } -}; - -template <> -void Out<TFoo>(IOutputStream& o, const TFoo& v) { - o << '{' << v.A << ';' << v.B << '}'; -} - -void THashTest::TestHSetInsertInitializerList() { - { + return A == o.A && B == o.B; + } + }; +} + +template <> +struct THash<TFoo> { + size_t operator()(const TFoo& v) const { + return v.A ^ v.B; + } +}; + +template <> +void Out<TFoo>(IOutputStream& o, const TFoo& v) { + o << '{' << v.A << ';' << v.B << '}'; +} + +void THashTest::TestHSetInsertInitializerList() { + { const THashSet<int> x = {1}; THashSet<int> y; - y.insert({1}); - UNIT_ASSERT_VALUES_EQUAL(x, y); - } - { + y.insert({1}); + UNIT_ASSERT_VALUES_EQUAL(x, y); + } + { const THashSet<int> x = {1, 2}; THashSet<int> y; - y.insert({1, 2}); - UNIT_ASSERT_VALUES_EQUAL(x, y); - } - { + y.insert({1, 2}); + UNIT_ASSERT_VALUES_EQUAL(x, y); + } + { const THashSet<int> x = {1, 2, 3, 4, 5}; THashSet<int> y; y.insert({ @@ -1234,21 +1234,21 @@ void THashTest::TestHSetInsertInitializerList() { 4, 5, }); - UNIT_ASSERT_VALUES_EQUAL(x, y); - } - { + UNIT_ASSERT_VALUES_EQUAL(x, y); + } + { const THashSet<TFoo> x = {{1, 2}}; THashSet<TFoo> y; - y.insert({{1, 2}}); - UNIT_ASSERT_VALUES_EQUAL(x, y); - } - { + y.insert({{1, 2}}); + UNIT_ASSERT_VALUES_EQUAL(x, y); + } + { const THashSet<TFoo> x = {{1, 2}, {3, 4}}; THashSet<TFoo> y; - y.insert({{1, 2}, {3, 4}}); - UNIT_ASSERT_VALUES_EQUAL(x, y); - } -} + y.insert({{1, 2}, {3, 4}}); + UNIT_ASSERT_VALUES_EQUAL(x, y); + } +} /* * Sequence for MultiHash is reversed as it calculates hash as diff --git a/util/generic/intrlist.h b/util/generic/intrlist.h index b5d3f2051b5..93112c37f70 100644 --- a/util/generic/intrlist.h +++ b/util/generic/intrlist.h @@ -332,11 +332,11 @@ public: TIntrusiveList temp; temp.Append(right); - Y_ASSERT(right.Empty()); + Y_ASSERT(right.Empty()); right.Append(*this); - Y_ASSERT(this->Empty()); + Y_ASSERT(this->Empty()); this->Append(temp); - Y_ASSERT(temp.Empty()); + Y_ASSERT(temp.Empty()); } public: @@ -823,12 +823,12 @@ public: } inline T* Front() noexcept { - Y_ASSERT(Begin_); + Y_ASSERT(Begin_); return Begin_->Node(); } inline const T* Front() const noexcept { - Y_ASSERT(Begin_); + Y_ASSERT(Begin_); return Begin_->Node(); } @@ -838,7 +838,7 @@ public: } inline T* PopFront() noexcept { - Y_ASSERT(Begin_); + Y_ASSERT(Begin_); TListItem* const ret = Begin_; Begin_ = Begin_->Next(); diff --git a/util/generic/intrlist_ut.cpp b/util/generic/intrlist_ut.cpp index eff7cdf2eee..96a7b19e071 100644 --- a/util/generic/intrlist_ut.cpp +++ b/util/generic/intrlist_ut.cpp @@ -2,7 +2,7 @@ #include <library/cpp/testing/unittest/registar.h> -#include <util/stream/output.h> +#include <util/stream/output.h> class TListTest: public TTestBase { UNIT_TEST_SUITE(TListTest); diff --git a/util/generic/is_in.h b/util/generic/is_in.h index 4f175ea5ebd..acfd5ec350a 100644 --- a/util/generic/is_in.h +++ b/util/generic/is_in.h @@ -12,9 +12,9 @@ template <class C, class T> static inline bool IsIn(const C& c, const T& e); namespace NIsInHelper { - Y_HAS_MEMBER(find, FindMethod); - Y_HAS_SUBTYPE(const_iterator, ConstIterator); - Y_HAS_SUBTYPE(key_type, KeyType); + Y_HAS_MEMBER(find, FindMethod); + Y_HAS_SUBTYPE(const_iterator, ConstIterator); + Y_HAS_SUBTYPE(key_type, KeyType); template <class T> using TIsAssocCont = TConjunction<THasFindMethod<T>, THasConstIterator<T>, THasKeyType<T>>; @@ -44,7 +44,7 @@ static inline bool IsIn(I f, I l, const T& v) { template <class C, class T> static inline bool IsIn(const C& c, const T& e) { using namespace NIsInHelper; - return TIsInTraits<C, T, TIsAssocCont<C>::value>::IsIn(c, e); + return TIsInTraits<C, T, TIsAssocCont<C>::value>::IsIn(c, e); } template <class T, class U> diff --git a/util/generic/is_in_ut.cpp b/util/generic/is_in_ut.cpp index c668bce8078..b60f7a82393 100644 --- a/util/generic/is_in_ut.cpp +++ b/util/generic/is_in_ut.cpp @@ -9,7 +9,7 @@ #include "strbuf.h" #include "string.h" -Y_UNIT_TEST_SUITE(TIsIn) { +Y_UNIT_TEST_SUITE(TIsIn) { template <class TCont, class T> void TestIsInWithCont(const T& elem) { class TMapMock: public TCont { @@ -40,7 +40,7 @@ Y_UNIT_TEST_SUITE(TIsIn) { m.FindCalled = 0; } - Y_UNIT_TEST(IsInTest) { + Y_UNIT_TEST(IsInTest) { TestIsInWithCont<TMap<TString, TString>>(std::make_pair("found", "1")); TestIsInWithCont<TMultiMap<TString, TString>>(std::make_pair("found", "1")); TestIsInWithCont<THashMap<TString, TString>>(std::make_pair("found", "1")); @@ -71,7 +71,7 @@ Y_UNIT_TEST_SUITE(TIsIn) { UNIT_ASSERT(!IsIn(b, 'z')); } - Y_UNIT_TEST(IsInInitListTest) { + Y_UNIT_TEST(IsInInitListTest) { const char* abc = "abc"; const char* def = "def"; @@ -94,9 +94,9 @@ Y_UNIT_TEST_SUITE(TIsIn) { UNIT_ASSERT(IsIn({"abc", "def"}, TStringBuf{str.data(), 3})); } - Y_UNIT_TEST(ConfOfTest) { - UNIT_ASSERT(IsIn({1, 2, 3}, 1)); - UNIT_ASSERT(!IsIn({1, 2, 3}, 4)); + Y_UNIT_TEST(ConfOfTest) { + UNIT_ASSERT(IsIn({1, 2, 3}, 1)); + UNIT_ASSERT(!IsIn({1, 2, 3}, 4)); const TString b = "b"; diff --git a/util/generic/iterator.h b/util/generic/iterator.h index 19e9d20976d..21fa5d781db 100644 --- a/util/generic/iterator.h +++ b/util/generic/iterator.h @@ -1,6 +1,6 @@ #pragma once -#include <iterator> +#include <iterator> #include <utility> namespace NStlIterator { @@ -130,10 +130,10 @@ public: /** * Transform given reverse iterator into forward iterator pointing to the same element. - * + * * @see http://stackoverflow.com/a/1830240 - */ + */ template <class TIterator> auto ToForwardIterator(TIterator iter) { - return std::next(iter).base(); + return std::next(iter).base(); } diff --git a/util/generic/iterator_range_ut.cpp b/util/generic/iterator_range_ut.cpp index a7e3670ae10..fa6cb3c0ad9 100644 --- a/util/generic/iterator_range_ut.cpp +++ b/util/generic/iterator_range_ut.cpp @@ -4,8 +4,8 @@ #include <util/generic/algorithm.h> #include <util/generic/vector.h> -Y_UNIT_TEST_SUITE(IteratorRange) { - Y_UNIT_TEST(DefaultConstructor) { +Y_UNIT_TEST_SUITE(IteratorRange) { + Y_UNIT_TEST(DefaultConstructor) { TIteratorRange<int*> range; UNIT_ASSERT(range.empty()); } @@ -15,7 +15,7 @@ Y_UNIT_TEST_SUITE(IteratorRange) { UNIT_ASSERT(range.empty()); } - Y_UNIT_TEST(RangeBasedForLoop) { + Y_UNIT_TEST(RangeBasedForLoop) { // compileability test for (int i : TIteratorRange<int*>()) { Y_UNUSED(i); @@ -29,7 +29,7 @@ Y_UNIT_TEST_SUITE(IteratorRange) { } } - Y_UNIT_TEST(Works) { + Y_UNIT_TEST(Works) { const int values[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; auto range = MakeIteratorRange(values, values + Y_ARRAY_SIZE(values)); UNIT_ASSERT_VALUES_EQUAL(range.size(), Y_ARRAY_SIZE(values)); @@ -68,7 +68,7 @@ Y_UNIT_TEST_SUITE(IteratorRange) { UNIT_ASSERT_VALUES_EQUAL(i, 10); } - Y_UNIT_TEST(OperatorsAndReferences) { + Y_UNIT_TEST(OperatorsAndReferences) { TVector<size_t> values{1, 2, 3, 4, 5}; auto range = MakeIteratorRange(values.begin(), values.end()); UNIT_ASSERT_VALUES_EQUAL(range[2], 3); @@ -88,7 +88,7 @@ Y_UNIT_TEST_SUITE(IteratorRange) { UNIT_ASSERT_VALUES_EQUAL(rangeBVector[6], false); } - Y_UNIT_TEST(CanUseInAlgorithms) { + Y_UNIT_TEST(CanUseInAlgorithms) { const int values[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; auto range = MakeIteratorRange(values, values + Y_ARRAY_SIZE(values)); // more like compileability test diff --git a/util/generic/iterator_ut.cpp b/util/generic/iterator_ut.cpp index 00be19e10ec..068dcb5f9b7 100644 --- a/util/generic/iterator_ut.cpp +++ b/util/generic/iterator_ut.cpp @@ -2,11 +2,11 @@ #include <library/cpp/testing/unittest/registar.h> -Y_UNIT_TEST_SUITE(TIterator) { - Y_UNIT_TEST(ToForwardIteratorTest) { +Y_UNIT_TEST_SUITE(TIterator) { + Y_UNIT_TEST(ToForwardIteratorTest) { TVector<int> x = {1, 2}; - UNIT_ASSERT_VALUES_EQUAL(*std::prev(x.end()), *ToForwardIterator(x.rbegin())); - UNIT_ASSERT_VALUES_EQUAL(*ToForwardIterator(std::prev(x.rend())), *x.begin()); + UNIT_ASSERT_VALUES_EQUAL(*std::prev(x.end()), *ToForwardIterator(x.rbegin())); + UNIT_ASSERT_VALUES_EQUAL(*ToForwardIterator(std::prev(x.rend())), *x.begin()); } } diff --git a/util/generic/lazy_value.h b/util/generic/lazy_value.h index 3c720f76b5a..49aa46bee36 100644 --- a/util/generic/lazy_value.h +++ b/util/generic/lazy_value.h @@ -39,7 +39,7 @@ public: } void InitDefault() const { - Y_ASSERT(Initializer); + Y_ASSERT(Initializer); ValueHolder = Initializer(); } diff --git a/util/generic/lazy_value_ut.cpp b/util/generic/lazy_value_ut.cpp index f6135880c3c..8d9cb496733 100644 --- a/util/generic/lazy_value_ut.cpp +++ b/util/generic/lazy_value_ut.cpp @@ -2,8 +2,8 @@ #include <library/cpp/testing/unittest/registar.h> -Y_UNIT_TEST_SUITE(TLazyValueTestSuite) { - Y_UNIT_TEST(TestLazyValue) { +Y_UNIT_TEST_SUITE(TLazyValueTestSuite) { + Y_UNIT_TEST(TestLazyValue) { TLazyValue<int> value([]() { return 5; }); @@ -12,7 +12,7 @@ Y_UNIT_TEST_SUITE(TLazyValueTestSuite) { UNIT_ASSERT(value); } - Y_UNIT_TEST(TestLazyValueInitialization) { + Y_UNIT_TEST(TestLazyValueInitialization) { TLazyValue<int> value1([]() { return 5; }); TLazyValue<int> value2 = []() { return 5; }; @@ -24,7 +24,7 @@ Y_UNIT_TEST_SUITE(TLazyValueTestSuite) { copy1 = value2; } - Y_UNIT_TEST(TestLazyValueCopy) { + Y_UNIT_TEST(TestLazyValueCopy) { TLazyValue<int> value([]() { return 5; }); UNIT_ASSERT(!value); @@ -113,13 +113,13 @@ Y_UNIT_TEST_SUITE(TLazyValueTestSuite) { size_t TValueProvider::CountParseDataCalled = 0; - Y_UNIT_TEST(TestValueProvider) { + Y_UNIT_TEST(TestValueProvider) { TValueProvider provider; UNIT_ASSERT(provider.GetData() == "hi"); } - Y_UNIT_TEST(TestValueProviderCopy) { + Y_UNIT_TEST(TestValueProviderCopy) { TValueProvider provider; provider.GetData(); const auto countParsed = TValueProvider::CountParseDataCalled; @@ -132,7 +132,7 @@ Y_UNIT_TEST_SUITE(TLazyValueTestSuite) { UNIT_ASSERT_EQUAL(countParsed, TValueProvider::CountParseDataCalled); } - Y_UNIT_TEST(TestEmptyProviderCopy) { + Y_UNIT_TEST(TestEmptyProviderCopy) { TValueProvider provider; TValueProvider copy(provider); @@ -146,7 +146,7 @@ Y_UNIT_TEST_SUITE(TLazyValueTestSuite) { UNIT_ASSERT_EQUAL(countParsed + 2, TValueProvider::CountParseDataCalled); } - Y_UNIT_TEST(TestMakeLazy) { + Y_UNIT_TEST(TestMakeLazy) { auto lv = MakeLazy([] { return 100500; }); diff --git a/util/generic/list_ut.cpp b/util/generic/list_ut.cpp index 9e60ecf01b4..3d97b66b605 100644 --- a/util/generic/list_ut.cpp +++ b/util/generic/list_ut.cpp @@ -2,8 +2,8 @@ #include <library/cpp/testing/unittest/registar.h> -Y_UNIT_TEST_SUITE(TYListSuite) { - Y_UNIT_TEST(TestInitializerList) { +Y_UNIT_TEST_SUITE(TYListSuite) { + Y_UNIT_TEST(TestInitializerList) { TList<int> l = {3, 42, 6}; TList<int> expected; expected.push_back(3); diff --git a/util/generic/map_ut.cpp b/util/generic/map_ut.cpp index 79e832b024f..5f6acd181f6 100644 --- a/util/generic/map_ut.cpp +++ b/util/generic/map_ut.cpp @@ -4,14 +4,14 @@ #include <util/memory/pool.h> #include <algorithm> -Y_UNIT_TEST_SUITE(TYMapTest) { +Y_UNIT_TEST_SUITE(TYMapTest) { template <typename TAlloc> void DoTestMap1(TMap<char, int, TLess<char>, TAlloc>& m); template <typename TAlloc> void DoTestMMap1(TMultiMap<char, int, TLess<char>, TAlloc>& mm); - Y_UNIT_TEST(TestMap1) { + Y_UNIT_TEST(TestMap1) { { TMap<char, int, TLess<char>> m; DoTestMap1(m); @@ -23,7 +23,7 @@ Y_UNIT_TEST_SUITE(TYMapTest) { } } - Y_UNIT_TEST(TestMMap1) { + Y_UNIT_TEST(TestMMap1) { { TMultiMap<char, int, TLess<char>> mm; DoTestMMap1(mm); @@ -93,7 +93,7 @@ Y_UNIT_TEST_SUITE(TYMapTest) { UNIT_ASSERT(count == 2); } - Y_UNIT_TEST(TestMMap2) { + Y_UNIT_TEST(TestMMap2) { using pair_type = std::pair<const int, char>; pair_type p1(3, 'c'); @@ -124,7 +124,7 @@ Y_UNIT_TEST_SUITE(TYMapTest) { UNIT_ASSERT((*i).second == 'f'); } - Y_UNIT_TEST(TestIterators) { + Y_UNIT_TEST(TestIterators) { using int_map = TMap<int, char, TLess<int>>; int_map imap; @@ -187,7 +187,7 @@ Y_UNIT_TEST_SUITE(TYMapTest) { UNIT_ASSERT((*rci).second == 'f'); } - Y_UNIT_TEST(TestEqualRange) { + Y_UNIT_TEST(TestEqualRange) { using maptype = TMap<char, int, TLess<char>>; { @@ -274,7 +274,7 @@ Y_UNIT_TEST_SUITE(TYMapTest) { using is_transparent = void; }; - Y_UNIT_TEST(TestTemplateMethods) { + Y_UNIT_TEST(TestTemplateMethods) { { using Container = TMap<TKey, int, TKeyCmp>; using value = Container::value_type; @@ -398,7 +398,7 @@ Y_UNIT_TEST_SUITE(TYMapTest) { UNIT_ASSERT(c); } - Y_UNIT_TEST(TestEmpty) { + Y_UNIT_TEST(TestEmpty) { EmptyAndInsertTest<TMap<char, int, TLess<char>>>(std::pair<char, int>('a', 1)); EmptyAndInsertTest<TMultiMap<char, int, TLess<char>>>(std::pair<char, int>('a', 1)); } @@ -420,7 +420,7 @@ Y_UNIT_TEST_SUITE(TYMapTest) { } }; - Y_UNIT_TEST(TestMoveComparator) { + Y_UNIT_TEST(TestMoveComparator) { using Container = TMultiMap<TKey, int, TParametrizedKeyCmp>; TParametrizedKeyCmp direct(false); @@ -435,8 +435,8 @@ Y_UNIT_TEST_SUITE(TYMapTest) { c.insert(std::make_pair(TKey(3), 103)); TVector<int> values; - for (auto& i : c) { - values.push_back(i.second); + for (auto& i : c) { + values.push_back(i.second); } UNIT_ASSERT_VALUES_EQUAL(values.size(), 3); @@ -446,7 +446,7 @@ Y_UNIT_TEST_SUITE(TYMapTest) { } } - Y_UNIT_TEST(TestMapInitializerList) { + Y_UNIT_TEST(TestMapInitializerList) { TMap<TString, int> m = { {"one", 1}, {"two", 2}, @@ -461,7 +461,7 @@ Y_UNIT_TEST_SUITE(TYMapTest) { UNIT_ASSERT_VALUES_EQUAL(m["four"], 4); } - Y_UNIT_TEST(TestMMapInitializerList) { + Y_UNIT_TEST(TestMMapInitializerList) { TMultiMap<TString, int> mm = { {"one", 1}, {"two", 2}, @@ -477,7 +477,7 @@ Y_UNIT_TEST_SUITE(TYMapTest) { UNIT_ASSERT_VALUES_EQUAL(mm, expected); } - Y_UNIT_TEST(TestMovePoolAlloc) { + Y_UNIT_TEST(TestMovePoolAlloc) { using TMapInPool = TMap<int, int, TLess<int>, TPoolAllocator>; TMemoryPool pool(1); diff --git a/util/generic/mapfindptr.h b/util/generic/mapfindptr.h index bc10cac60f8..e7d1b310004 100644 --- a/util/generic/mapfindptr.h +++ b/util/generic/mapfindptr.h @@ -14,14 +14,14 @@ template <class Map, class K> inline auto MapFindPtr(Map& map, const K& key) { auto i = map.find(key); - return (i == map.end() ? nullptr : &i->second); + return (i == map.end() ? nullptr : &i->second); } template <class Map, class K> inline auto MapFindPtr(const Map& map, const K& key) { auto i = map.find(key); - return (i == map.end() ? nullptr : &i->second); + return (i == map.end() ? nullptr : &i->second); } /** helper for THashMap/TMap */ diff --git a/util/generic/mapfindptr_ut.cpp b/util/generic/mapfindptr_ut.cpp index 613da7a96b7..10ed7992fe1 100644 --- a/util/generic/mapfindptr_ut.cpp +++ b/util/generic/mapfindptr_ut.cpp @@ -7,16 +7,16 @@ #include "mapfindptr.h" -Y_UNIT_TEST_SUITE(TMapFindPtrTest) { +Y_UNIT_TEST_SUITE(TMapFindPtrTest) { struct TTestMap: std::map<int, TString>, TMapOps<TTestMap> {}; - Y_UNIT_TEST(TestDerivedClass) { + Y_UNIT_TEST(TestDerivedClass) { TTestMap a; a[42] = "cat"; UNIT_ASSERT(a.FindPtr(42)); UNIT_ASSERT_EQUAL(*a.FindPtr(42), "cat"); - UNIT_ASSERT_EQUAL(a.FindPtr(0), nullptr); + UNIT_ASSERT_EQUAL(a.FindPtr(0), nullptr); //test mutation if (TString* p = a.FindPtr(42)) { @@ -28,13 +28,13 @@ Y_UNIT_TEST_SUITE(TMapFindPtrTest) { //test const-overloaded functions too const TTestMap& b = a; UNIT_ASSERT(b.FindPtr(42) && *b.FindPtr(42) == "dog"); - UNIT_ASSERT_EQUAL(b.FindPtr(0), nullptr); + UNIT_ASSERT_EQUAL(b.FindPtr(0), nullptr); UNIT_ASSERT_STRINGS_EQUAL(b.Value(42, "cat"), "dog"); UNIT_ASSERT_STRINGS_EQUAL(b.Value(0, "alien"), "alien"); } - Y_UNIT_TEST(TestTemplateFind) { + Y_UNIT_TEST(TestTemplateFind) { THashMap<TString, int> m; m[TString("x")] = 2; @@ -43,7 +43,7 @@ Y_UNIT_TEST_SUITE(TMapFindPtrTest) { UNIT_ASSERT_EQUAL(*m.FindPtr(TStringBuf("x")), 2); } - Y_UNIT_TEST(TestValue) { + Y_UNIT_TEST(TestValue) { TTestMap a; a[1] = "lol"; @@ -52,7 +52,7 @@ Y_UNIT_TEST_SUITE(TMapFindPtrTest) { UNIT_ASSERT_VALUES_EQUAL(a.Value(2, "123"), "123"); } - Y_UNIT_TEST(TestValueRef) { + Y_UNIT_TEST(TestValueRef) { TTestMap a; a[1] = "lol"; diff --git a/util/generic/maybe.h b/util/generic/maybe.h index 34d21aebcdc..63427876da5 100644 --- a/util/generic/maybe.h +++ b/util/generic/maybe.h @@ -6,7 +6,7 @@ #include "yexception.h" #include <util/system/align.h> -#include <util/stream/output.h> +#include <util/stream/output.h> #include <util/ysaveload.h> namespace NMaybe { @@ -386,7 +386,7 @@ public: return Defined(); } - void Save(IOutputStream* out) const { + void Save(IOutputStream* out) const { const bool defined = Defined(); ::Save<bool>(out, defined); @@ -396,7 +396,7 @@ public: } } - void Load(IInputStream* in) { + void Load(IInputStream* in) { bool defined; ::Load(in, defined); @@ -709,7 +709,7 @@ constexpr bool operator>=(const U& value, const TMaybe<T, TPolicy>& maybe) { return !(value < maybe); } -class IOutputStream; +class IOutputStream; template <class T, class TPolicy> inline IOutputStream& operator<<(IOutputStream& out, const TMaybe<T, TPolicy>& maybe) { diff --git a/util/generic/maybe_ut.cpp b/util/generic/maybe_ut.cpp index 2c1a425c5ef..c30e9d96026 100644 --- a/util/generic/maybe_ut.cpp +++ b/util/generic/maybe_ut.cpp @@ -20,7 +20,7 @@ public: } }; -Y_UNIT_TEST_SUITE(TMaybeTest) { +Y_UNIT_TEST_SUITE(TMaybeTest) { Y_UNIT_TEST(TestStatic) { using T1 = TMaybe<int>; static_assert(std::is_trivially_copy_constructible<T1>::value, ""); @@ -39,7 +39,7 @@ Y_UNIT_TEST_SUITE(TMaybeTest) { static_assert(!std::is_trivially_destructible<T4>::value, ""); } - Y_UNIT_TEST(TestWarning) { + Y_UNIT_TEST(TestWarning) { TMaybe<size_t> x; TStringStream ss; TString line; @@ -53,7 +53,7 @@ Y_UNIT_TEST_SUITE(TMaybeTest) { } } - Y_UNIT_TEST(TTestConstructorDestructor) { + Y_UNIT_TEST(TTestConstructorDestructor) { int a = 0; int b = 0; @@ -98,7 +98,7 @@ Y_UNIT_TEST_SUITE(TMaybeTest) { } } - Y_UNIT_TEST(TestAssignmentClear) { + Y_UNIT_TEST(TestAssignmentClear) { TMaybe<int> m5; UNIT_ASSERT(!m5.Defined()); UNIT_ASSERT(m5.Empty()); @@ -141,7 +141,7 @@ Y_UNIT_TEST_SUITE(TMaybeTest) { UNIT_ASSERT(m5.Empty()); } - Y_UNIT_TEST(TestInPlace) { + Y_UNIT_TEST(TestInPlace) { TMaybe<int> m; UNIT_ASSERT(!m); @@ -157,7 +157,7 @@ Y_UNIT_TEST_SUITE(TMaybeTest) { UNIT_ASSERT(m == 7); } - Y_UNIT_TEST(TestMove) { + Y_UNIT_TEST(TestMove) { struct TMovable { int Flag = 0; @@ -209,7 +209,7 @@ Y_UNIT_TEST_SUITE(TMaybeTest) { UNIT_ASSERT_VALUES_EQUAL(o6.Flag, 6); } - Y_UNIT_TEST(TestCast) { + Y_UNIT_TEST(TestCast) { // Undefined maybe casts to undefined maybe TMaybe<short> shortMaybe; const auto undefinedMaybe = shortMaybe.Cast<long>(); @@ -222,7 +222,7 @@ Y_UNIT_TEST_SUITE(TMaybeTest) { UNIT_ASSERT_VALUES_EQUAL(34, longMaybe.GetRef()); } - Y_UNIT_TEST(TestGetOr) { + Y_UNIT_TEST(TestGetOr) { UNIT_ASSERT_VALUES_EQUAL(TMaybe<TString>().GetOrElse("xxx"), TString("xxx")); UNIT_ASSERT_VALUES_EQUAL(TMaybe<TString>("yyy").GetOrElse("xxx"), TString("yyy")); @@ -248,7 +248,7 @@ Y_UNIT_TEST_SUITE(TMaybeTest) { >= */ - Y_UNIT_TEST(TestCompareEqualEmpty) { + Y_UNIT_TEST(TestCompareEqualEmpty) { TMaybe<int> m1; TMaybe<int> m2; @@ -260,7 +260,7 @@ Y_UNIT_TEST_SUITE(TMaybeTest) { UNIT_ASSERT(m1 >= m2); } - Y_UNIT_TEST(TestCompareEqualNonEmpty) { + Y_UNIT_TEST(TestCompareEqualNonEmpty) { TMaybe<int> m1{1}; TMaybe<int> m2{1}; @@ -272,7 +272,7 @@ Y_UNIT_TEST_SUITE(TMaybeTest) { UNIT_ASSERT(m1 >= m2); } - Y_UNIT_TEST(TestCompareOneLessThanOther) { + Y_UNIT_TEST(TestCompareOneLessThanOther) { TMaybe<int> m1{1}; TMaybe<int> m2{2}; @@ -284,7 +284,7 @@ Y_UNIT_TEST_SUITE(TMaybeTest) { UNIT_ASSERT(!(m1 >= m2)); } - Y_UNIT_TEST(TestCompareTMaybeAndT_Equal) { + Y_UNIT_TEST(TestCompareTMaybeAndT_Equal) { TMaybe<int> m{1}; int v{1}; @@ -303,7 +303,7 @@ Y_UNIT_TEST_SUITE(TMaybeTest) { UNIT_ASSERT(v >= m); } - Y_UNIT_TEST(TestCompareTMaybeAndT_TMaybeLessThanT) { + Y_UNIT_TEST(TestCompareTMaybeAndT_TMaybeLessThanT) { TMaybe<int> m{1}; int v{2}; @@ -322,7 +322,7 @@ Y_UNIT_TEST_SUITE(TMaybeTest) { UNIT_ASSERT(v >= m); } - Y_UNIT_TEST(TestCompareTMaybeAndT_TMaybeGreaterThanT) { + Y_UNIT_TEST(TestCompareTMaybeAndT_TMaybeGreaterThanT) { TMaybe<int> m{2}; int v{1}; @@ -341,7 +341,7 @@ Y_UNIT_TEST_SUITE(TMaybeTest) { UNIT_ASSERT(!(v >= m)); } - Y_UNIT_TEST(TestCompareEmptyTMaybeAndT) { + Y_UNIT_TEST(TestCompareEmptyTMaybeAndT) { TMaybe<int> m; int v{1}; @@ -360,7 +360,7 @@ Y_UNIT_TEST_SUITE(TMaybeTest) { UNIT_ASSERT(v >= m); } - Y_UNIT_TEST(TestCompareEmptyTMaybeAndNothing) { + Y_UNIT_TEST(TestCompareEmptyTMaybeAndNothing) { TMaybe<int> m; auto n = Nothing(); @@ -379,7 +379,7 @@ Y_UNIT_TEST_SUITE(TMaybeTest) { UNIT_ASSERT(n >= m); } - Y_UNIT_TEST(TestCompareNonEmptyTMaybeAndNothing) { + Y_UNIT_TEST(TestCompareNonEmptyTMaybeAndNothing) { TMaybe<int> m{1}; auto n = Nothing(); @@ -398,7 +398,7 @@ Y_UNIT_TEST_SUITE(TMaybeTest) { UNIT_ASSERT(!(n >= m)); } - Y_UNIT_TEST(TestCompareTMaybeAndConvertibleT_Equal) { + Y_UNIT_TEST(TestCompareTMaybeAndConvertibleT_Equal) { TMaybe<size_t> m{1}; unsigned int v{1}; @@ -417,7 +417,7 @@ Y_UNIT_TEST_SUITE(TMaybeTest) { UNIT_ASSERT(v >= m); } - Y_UNIT_TEST(TestCompareTMaybeAndConvertibleT_TMaybeLessThanT) { + Y_UNIT_TEST(TestCompareTMaybeAndConvertibleT_TMaybeLessThanT) { TMaybe<size_t> m{1}; unsigned int v{2}; @@ -436,7 +436,7 @@ Y_UNIT_TEST_SUITE(TMaybeTest) { UNIT_ASSERT(v >= m); } - Y_UNIT_TEST(TestCompareTMaybeAndConvertibleT_TMaybeGreaterThanT) { + Y_UNIT_TEST(TestCompareTMaybeAndConvertibleT_TMaybeGreaterThanT) { TMaybe<size_t> m{2}; unsigned int v{1}; @@ -455,7 +455,7 @@ Y_UNIT_TEST_SUITE(TMaybeTest) { UNIT_ASSERT(!(v >= m)); } - Y_UNIT_TEST(TestCompareEmptyTMaybeAndConvertibleT) { + Y_UNIT_TEST(TestCompareEmptyTMaybeAndConvertibleT) { TMaybe<size_t> m; unsigned int v{1}; @@ -474,7 +474,7 @@ Y_UNIT_TEST_SUITE(TMaybeTest) { UNIT_ASSERT(v >= m); } - Y_UNIT_TEST(TestMakeMaybe) { + Y_UNIT_TEST(TestMakeMaybe) { { auto m1 = MakeMaybe<int>(1); UNIT_ASSERT(*m1 == 1); @@ -583,7 +583,7 @@ Y_UNIT_TEST_SUITE(TMaybeTest) { } } - Y_UNIT_TEST(TestSwappingUsingMemberSwap) { + Y_UNIT_TEST(TestSwappingUsingMemberSwap) { { TMaybe<int> m1 = 1; TMaybe<int> m2 = 2; @@ -624,7 +624,7 @@ Y_UNIT_TEST_SUITE(TMaybeTest) { } } - Y_UNIT_TEST(TestSwappingUsingMemberLittleSwap) { + Y_UNIT_TEST(TestSwappingUsingMemberLittleSwap) { { TMaybe<int> m1 = 1; TMaybe<int> m2 = 2; @@ -665,7 +665,7 @@ Y_UNIT_TEST_SUITE(TMaybeTest) { } } - Y_UNIT_TEST(TestSwappingUsingGlobalSwap) { + Y_UNIT_TEST(TestSwappingUsingGlobalSwap) { { TMaybe<int> m1 = 1; TMaybe<int> m2 = 2; @@ -706,7 +706,7 @@ Y_UNIT_TEST_SUITE(TMaybeTest) { } } - Y_UNIT_TEST(TestSwappingUsingGlobalDoSwap) { + Y_UNIT_TEST(TestSwappingUsingGlobalDoSwap) { { TMaybe<int> m1 = 1; TMaybe<int> m2 = 2; @@ -747,7 +747,7 @@ Y_UNIT_TEST_SUITE(TMaybeTest) { } } - Y_UNIT_TEST(TestSwappingUsingStdSwap) { + Y_UNIT_TEST(TestSwappingUsingStdSwap) { { TMaybe<int> m1 = 1; TMaybe<int> m2 = 2; @@ -788,28 +788,28 @@ Y_UNIT_TEST_SUITE(TMaybeTest) { } } - Y_UNIT_TEST(TestOutputStreamEmptyMaybe) { + Y_UNIT_TEST(TestOutputStreamEmptyMaybe) { TString s; TStringOutput output(s); output << TMaybe<int>(); UNIT_ASSERT_EQUAL("(empty maybe)", s); } - Y_UNIT_TEST(TestOutputStreamNothing) { + Y_UNIT_TEST(TestOutputStreamNothing) { TString s; TStringOutput output(s); output << Nothing(); UNIT_ASSERT_VALUES_EQUAL("(empty maybe)", s); } - Y_UNIT_TEST(TestOutputStreamDefinedMaybe) { + Y_UNIT_TEST(TestOutputStreamDefinedMaybe) { TString s; TStringOutput output(s); output << TMaybe<int>(42); UNIT_ASSERT_EQUAL("42", s); } - Y_UNIT_TEST(TestMaybeCovarianceImplicit) { + Y_UNIT_TEST(TestMaybeCovarianceImplicit) { struct TestStruct { TestStruct(int value) : Value_(value) @@ -835,7 +835,7 @@ Y_UNIT_TEST_SUITE(TMaybeTest) { UNIT_ASSERT(!testMaybeEmpty.Defined()); } - Y_UNIT_TEST(TestMaybeCovarianceExplicit) { + Y_UNIT_TEST(TestMaybeCovarianceExplicit) { struct TestStruct { explicit TestStruct(int value) : Value_(value) @@ -853,7 +853,7 @@ Y_UNIT_TEST_SUITE(TMaybeTest) { UNIT_ASSERT(!testStructMaybeEmpty.Defined()); } - Y_UNIT_TEST(TestMaybeCovarianceAssign) { + Y_UNIT_TEST(TestMaybeCovarianceAssign) { struct TestStruct { explicit TestStruct(int value) : Value_(value) @@ -881,7 +881,7 @@ Y_UNIT_TEST_SUITE(TMaybeTest) { UNIT_ASSERT(!testStructMaybe.Defined()); } - Y_UNIT_TEST(TestMaybeCovarianceNonTrivial) { + Y_UNIT_TEST(TestMaybeCovarianceNonTrivial) { struct TestStruct { enum { FromValue, @@ -918,7 +918,7 @@ Y_UNIT_TEST_SUITE(TMaybeTest) { UNIT_ASSERT_EQUAL(testStructFromValue.GetRef().Value_, 23); } - Y_UNIT_TEST(TestMaybeCovarianceNonTrivialAssign) { + Y_UNIT_TEST(TestMaybeCovarianceNonTrivialAssign) { struct TestStruct { enum { FromValue, diff --git a/util/generic/mem_copy.h b/util/generic/mem_copy.h index b68c852953a..ad6c253143c 100644 --- a/util/generic/mem_copy.h +++ b/util/generic/mem_copy.h @@ -7,10 +7,10 @@ #include <cstring> template <class T> -using TIfPOD = std::enable_if_t<TTypeTraits<T>::IsPod, T*>; +using TIfPOD = std::enable_if_t<TTypeTraits<T>::IsPod, T*>; template <class T> -using TIfNotPOD = std::enable_if_t<!TTypeTraits<T>::IsPod, T*>; +using TIfNotPOD = std::enable_if_t<!TTypeTraits<T>::IsPod, T*>; template <class T> static inline TIfPOD<T> MemCopy(T* to, const T* from, size_t n) noexcept { diff --git a/util/generic/mem_copy_ut.cpp b/util/generic/mem_copy_ut.cpp index 8b55a11cf68..891827b7213 100644 --- a/util/generic/mem_copy_ut.cpp +++ b/util/generic/mem_copy_ut.cpp @@ -18,10 +18,10 @@ namespace { }; } -Y_DECLARE_PODTYPE(TB); +Y_DECLARE_PODTYPE(TB); -Y_UNIT_TEST_SUITE(TestMemCopy) { - Y_UNIT_TEST(Test1) { +Y_UNIT_TEST_SUITE(TestMemCopy) { + Y_UNIT_TEST(Test1) { char buf[] = "123"; char buf1[sizeof(buf)]; @@ -42,7 +42,7 @@ Y_UNIT_TEST_SUITE(TestMemCopy) { int X; }; - Y_UNIT_TEST(Test2) { + Y_UNIT_TEST(Test2) { x = 0; TA a1[5]; @@ -58,14 +58,14 @@ Y_UNIT_TEST_SUITE(TestMemCopy) { } } - Y_UNIT_TEST(Test3) { + Y_UNIT_TEST(Test3) { TB b1[5]; TB b2[5]; MemCopy(b2, b1, 5); } - Y_UNIT_TEST(Test4) { + Y_UNIT_TEST(Test4) { TC c1[5]; TC c2[5]; @@ -81,7 +81,7 @@ Y_UNIT_TEST_SUITE(TestMemCopy) { } } - Y_UNIT_TEST(Test5) { + Y_UNIT_TEST(Test5) { struct TD { int X; }; @@ -104,7 +104,7 @@ Y_UNIT_TEST_SUITE(TestMemCopy) { } } - Y_UNIT_TEST(TestEmpty) { + Y_UNIT_TEST(TestEmpty) { char* tmp = nullptr; UNIT_ASSERT(MemCopy(tmp, tmp, 0) == nullptr); diff --git a/util/generic/objects_counter_ut.cpp b/util/generic/objects_counter_ut.cpp index 4d5da37a56f..cfa6ca6a3c5 100644 --- a/util/generic/objects_counter_ut.cpp +++ b/util/generic/objects_counter_ut.cpp @@ -2,11 +2,11 @@ #include <library/cpp/testing/unittest/registar.h> -Y_UNIT_TEST_SUITE(ObjectsCounter) { +Y_UNIT_TEST_SUITE(ObjectsCounter) { struct TObject: public TObjectCounter<TObject> { }; - Y_UNIT_TEST(Test1) { + Y_UNIT_TEST(Test1) { TObject obj; TVector<TObject> objects; for (ui32 i = 0; i < 100; ++i) { @@ -15,7 +15,7 @@ Y_UNIT_TEST_SUITE(ObjectsCounter) { UNIT_ASSERT_EQUAL(TObjectCounter<TObject>::ObjectCount(), 101); } - Y_UNIT_TEST(TestEq) { + Y_UNIT_TEST(TestEq) { TObject obj; { TObject obj1 = obj; @@ -24,7 +24,7 @@ Y_UNIT_TEST_SUITE(ObjectsCounter) { UNIT_ASSERT_EQUAL(TObjectCounter<TObject>::ObjectCount(), 1); } - Y_UNIT_TEST(TestMove) { + Y_UNIT_TEST(TestMove) { TObject obj; UNIT_ASSERT_EQUAL(TObjectCounter<TObject>::ObjectCount(), 1); { diff --git a/util/generic/ptr.h b/util/generic/ptr.h index 19db0e3ec55..221519cb38d 100644 --- a/util/generic/ptr.h +++ b/util/generic/ptr.h @@ -122,7 +122,7 @@ public: #endif inline explicit operator bool() const noexcept { - return nullptr != AsT(); + return nullptr != AsT(); } protected: @@ -132,7 +132,7 @@ protected: static inline T* DoRelease(T*& t) noexcept { T* ret = t; - t = nullptr; + t = nullptr; return ret; } }; @@ -141,13 +141,13 @@ template <class Base, class T> class TPointerBase: public TPointerCommon<Base, T> { public: inline T& operator*() const noexcept { - Y_ASSERT(this->AsT()); + Y_ASSERT(this->AsT()); return *(this->AsT()); } inline T& operator[](size_t n) const noexcept { - Y_ASSERT(this->AsT()); + Y_ASSERT(this->AsT()); return (this->AsT())[n]; } @@ -253,11 +253,11 @@ public: } template <class U, class = TGuardConversion<T, U>> - inline THolder(TAutoPtr<U, D> t) noexcept - : T_(t.Release()) - { - } - + inline THolder(TAutoPtr<U, D> t) noexcept + : T_(t.Release()) + { + } + inline THolder(THolder&& that) noexcept : T_(that.Release()) { @@ -277,7 +277,7 @@ public: } inline void Destroy() noexcept { - Reset(nullptr); + Reset(nullptr); } inline T* Release() noexcept Y_WARN_UNUSED_RESULT { @@ -379,7 +379,7 @@ public: inline void UnRef(TAtomicBase d) noexcept { auto resultCount = Counter_.Sub(d); - Y_ASSERT(resultCount >= 0); + Y_ASSERT(resultCount >= 0); if (resultCount == 0) { D::Destroy(static_cast<T*>(this)); } @@ -427,7 +427,7 @@ struct TThrRefBase: public TRefCounted<TThrRefBase, TAtomicCounter> { * * @warning Additional care should be taken with regard to inheritance. If used * as a base class, @p T should either declare a virtual destructor, or be - * derived from @p TThrRefBase instead. Otherwise, only destructor of class @p T + * derived from @p TThrRefBase instead. Otherwise, only destructor of class @p T * would be called, potentially slicing the object and creating memory leaks. * * @note To avoid accidental inheritance when it is not originally intended, @@ -449,31 +449,31 @@ template <class T> class TDefaultIntrusivePtrOps { public: static inline void Ref(T* t) noexcept { - Y_ASSERT(t); + Y_ASSERT(t); t->Ref(); } static inline void UnRef(T* t) noexcept { - Y_ASSERT(t); + Y_ASSERT(t); t->UnRef(); } static inline void DecRef(T* t) noexcept { - Y_ASSERT(t); + Y_ASSERT(t); t->DecRef(); } static inline long RefCount(const T* t) noexcept { - Y_ASSERT(t); + Y_ASSERT(t); return t->RefCount(); } }; -template <class T, class Ops> +template <class T, class Ops> class TIntrusivePtr: public TPointerBase<TIntrusivePtr<T, Ops>, T> { template <class U, class O> friend class TIntrusivePtr; @@ -509,7 +509,7 @@ public: } // NOTE: - // without std::enable_if_t compiler sometimes tries to use this constructor inappropriately + // without std::enable_if_t compiler sometimes tries to use this constructor inappropriately // e.g. // struct A {}; // struct B {}; @@ -611,7 +611,7 @@ struct THash<TIntrusivePtr<T, Ops>>: THash<const T*> { }; // Behaves like TIntrusivePtr but returns const T* to prevent user from accidentally modifying the referenced object. -template <class T, class Ops> +template <class T, class Ops> class TIntrusiveConstPtr: public TPointerBase<TIntrusiveConstPtr<T, Ops>, const T> { public: inline TIntrusiveConstPtr(T* t = nullptr) noexcept // we need a non-const pointer to Ref(), UnRef() and eventually delete it. @@ -683,7 +683,7 @@ public: } inline void Drop() noexcept { - TIntrusiveConstPtr(nullptr).Swap(*this); + TIntrusiveConstPtr(nullptr).Swap(*this); } inline long RefCount() const noexcept { @@ -698,13 +698,13 @@ public: #endif private: inline void Ref() noexcept { - if (T_ != nullptr) { + if (T_ != nullptr) { Ops::Ref(T_); } } inline void UnRef() noexcept { - if (T_ != nullptr) { + if (T_ != nullptr) { Ops::UnRef(T_); } } @@ -773,10 +773,10 @@ private: }; template <class T, class Ops> -typename TSimpleIntrusiveOps<T, Ops>::TFunc TSimpleIntrusiveOps<T, Ops>::Ref_ = nullptr; +typename TSimpleIntrusiveOps<T, Ops>::TFunc TSimpleIntrusiveOps<T, Ops>::Ref_ = nullptr; template <class T, class Ops> -typename TSimpleIntrusiveOps<T, Ops>::TFunc TSimpleIntrusiveOps<T, Ops>::UnRef_ = nullptr; +typename TSimpleIntrusiveOps<T, Ops>::TFunc TSimpleIntrusiveOps<T, Ops>::UnRef_ = nullptr; template <typename T, class Ops = TDefaultIntrusivePtrOps<T>, typename... Args> [[nodiscard]] TIntrusivePtr<T, Ops> MakeIntrusive(Args&&... args) { @@ -903,7 +903,7 @@ public: private: template <class X> inline void Init(X& t) { - C_ = !!t ? new C(1) : nullptr; + C_ = !!t ? new C(1) : nullptr; T_ = t.Release(); } @@ -968,7 +968,7 @@ public: static inline T* Copy(T* t) { if (t) return t->Clone(); - return nullptr; + return nullptr; } }; @@ -978,7 +978,7 @@ public: static inline T* Copy(T* t) { if (t) return new T(*t); - return nullptr; + return nullptr; } }; @@ -1027,7 +1027,7 @@ public: } inline void Destroy() noexcept { - Reset(nullptr); + Reset(nullptr); } inline void Swap(TCopyPtr& r) noexcept { @@ -1055,7 +1055,7 @@ private: }; // Copy-on-write pointer -template <class TPtr, class TCopy> +template <class TPtr, class TCopy> class TCowPtr: public TPointerBase<TCowPtr<TPtr, TCopy>, const typename TPtr::TValueType> { using T = typename TPtr::TValueType; diff --git a/util/generic/ptr_ut.cpp b/util/generic/ptr_ut.cpp index c2dcff23f6b..fa4d206128c 100644 --- a/util/generic/ptr_ut.cpp +++ b/util/generic/ptr_ut.cpp @@ -6,7 +6,7 @@ #include <util/generic/hash_set.h> #include <util/generic/is_in.h> -#include <util/stream/output.h> +#include <util/stream/output.h> #include <util/system/thread.h> class TPointerTest: public TTestBase { @@ -41,7 +41,7 @@ private: struct S: public TAtomicRefCount<S> { }; - struct TLocalThread: public ISimpleThread { + struct TLocalThread: public ISimpleThread { void* ThreadProc() override { TSimpleIntrusivePtr<S> ptr; return nullptr; @@ -259,23 +259,23 @@ void TPointerTest::TestAutoToHolder() { } UNIT_ASSERT_VALUES_EQUAL(cnt, 0); - - { - TAutoPtr<A> x(new A()); - THolder<const A> y = x; - } - - UNIT_ASSERT_VALUES_EQUAL(cnt, 0); - - { + + { + TAutoPtr<A> x(new A()); + THolder<const A> y = x; + } + + UNIT_ASSERT_VALUES_EQUAL(cnt, 0); + + { class B1: public A { - }; - + }; + TAutoPtr<B1> x(new B1()); - THolder<A> y = x; - } - - UNIT_ASSERT_VALUES_EQUAL(cnt, 0); + THolder<A> y = x; + } + + UNIT_ASSERT_VALUES_EQUAL(cnt, 0); } void TPointerTest::TestCopyPtr() { diff --git a/util/generic/queue_ut.cpp b/util/generic/queue_ut.cpp index a33399e1048..3bccb506b9c 100644 --- a/util/generic/queue_ut.cpp +++ b/util/generic/queue_ut.cpp @@ -6,8 +6,8 @@ #include <utility> -Y_UNIT_TEST_SUITE(TYQueueTest) { - Y_UNIT_TEST(ConstructorsAndAssignments) { +Y_UNIT_TEST_SUITE(TYQueueTest) { + Y_UNIT_TEST(ConstructorsAndAssignments) { { using container = TQueue<int>; @@ -73,7 +73,7 @@ Y_UNIT_TEST_SUITE(TYQueueTest) { } } - Y_UNIT_TEST(pqueue1) { + Y_UNIT_TEST(pqueue1) { TPriorityQueue<int, TDeque<int>, TLess<int>> q; q.push(42); @@ -91,7 +91,7 @@ Y_UNIT_TEST_SUITE(TYQueueTest) { UNIT_ASSERT(q.empty()); } - Y_UNIT_TEST(pqueue2) { + Y_UNIT_TEST(pqueue2) { using TPQueue = TPriorityQueue<int, TDeque<int>, TLess<int>>; TPQueue q; @@ -117,7 +117,7 @@ Y_UNIT_TEST_SUITE(TYQueueTest) { UNIT_ASSERT(q.empty()); } - Y_UNIT_TEST(pqueue3) { + Y_UNIT_TEST(pqueue3) { TPriorityQueue<int, TDeque<int>, TLess<int>> q; q.push(42); @@ -128,7 +128,7 @@ Y_UNIT_TEST_SUITE(TYQueueTest) { UNIT_ASSERT(q.empty()); } - Y_UNIT_TEST(pqueue4) { + Y_UNIT_TEST(pqueue4) { TDeque<int> c; c.push_back(42); c.push_back(101); @@ -152,7 +152,7 @@ Y_UNIT_TEST_SUITE(TYQueueTest) { UNIT_ASSERT(q.empty()); } - Y_UNIT_TEST(queue1) { + Y_UNIT_TEST(queue1) { TQueue<int, TList<int>> q; q.push(42); @@ -170,7 +170,7 @@ Y_UNIT_TEST_SUITE(TYQueueTest) { UNIT_ASSERT(q.empty()); } - Y_UNIT_TEST(queue2) { + Y_UNIT_TEST(queue2) { using TQueueType = TQueue<int>; TQueueType q; @@ -196,7 +196,7 @@ Y_UNIT_TEST_SUITE(TYQueueTest) { UNIT_ASSERT(q.empty()); } - Y_UNIT_TEST(queue3) { + Y_UNIT_TEST(queue3) { using TQueueType = TQueue<int>; TQueueType q; diff --git a/util/generic/refcount.h b/util/generic/refcount.h index 966e853b77f..9aee4279901 100644 --- a/util/generic/refcount.h +++ b/util/generic/refcount.h @@ -74,7 +74,7 @@ public: protected: inline void Check() const { - Y_VERIFY(ThreadId == SystemCurrentThreadId(), "incorrect usage of TSimpleCounter"); + Y_VERIFY(ThreadId == SystemCurrentThreadId(), "incorrect usage of TSimpleCounter"); } private: diff --git a/util/generic/scope.h b/util/generic/scope.h index b2c33af61e7..a54ffc26447 100644 --- a/util/generic/scope.h +++ b/util/generic/scope.h @@ -38,28 +38,28 @@ namespace NPrivate { }; } -// \brief `Y_SCOPE_EXIT(captures) { body };` -// -// General implementaion of RAII idiom (resource acquisition is initialization). Executes -// function upon return from the current scope. -// +// \brief `Y_SCOPE_EXIT(captures) { body };` +// +// General implementaion of RAII idiom (resource acquisition is initialization). Executes +// function upon return from the current scope. +// // @note expects `body` to provide no-throw guarantee, otherwise whenever an exception // is thrown and leaves the outermost block of `body`, the function `std::terminate` is called. -// @see http://drdobbs.com/184403758 for detailed motivation. +// @see http://drdobbs.com/184403758 for detailed motivation. #define Y_SCOPE_EXIT(...) const auto Y_GENERATE_UNIQUE_ID(scopeGuard) Y_DECLARE_UNUSED = ::NPrivate::TMakeGuardHelper{} | [__VA_ARGS__]() mutable -> void - -// \brief `Y_DEFER { body };` -// -// Same as `Y_SCOPE_EXIT` but doesn't require user to provide capture-list explicitly (it + +// \brief `Y_DEFER { body };` +// +// Same as `Y_SCOPE_EXIT` but doesn't require user to provide capture-list explicitly (it // implicitly uses `[&]` capture). Have same requirements for `body`. -// -// Inspired by `defer` statement in languages like Swift and Go. -// -// \code -// auto item = s.pop(); -// bool ok = false; -// Y_DEFER { if (!ok) { s.push(std::move(item)); } }; -// ... try handle `item` ... -// ok = true; -// \endcode +// +// Inspired by `defer` statement in languages like Swift and Go. +// +// \code +// auto item = s.pop(); +// bool ok = false; +// Y_DEFER { if (!ok) { s.push(std::move(item)); } }; +// ... try handle `item` ... +// ok = true; +// \endcode #define Y_DEFER Y_SCOPE_EXIT(&) diff --git a/util/generic/scope_ut.cpp b/util/generic/scope_ut.cpp index bdb434d4875..d5aec0e8b6d 100644 --- a/util/generic/scope_ut.cpp +++ b/util/generic/scope_ut.cpp @@ -3,8 +3,8 @@ #include <util/generic/ptr.h> #include <library/cpp/testing/unittest/registar.h> -Y_UNIT_TEST_SUITE(ScopeToolsTest) { - Y_UNIT_TEST(OnScopeExitTest) { +Y_UNIT_TEST_SUITE(ScopeToolsTest) { + Y_UNIT_TEST(OnScopeExitTest) { int i = 0; { @@ -20,7 +20,7 @@ Y_UNIT_TEST_SUITE(ScopeToolsTest) { UNIT_ASSERT_VALUES_EQUAL(2, i); } - Y_UNIT_TEST(OnScopeExitMoveTest) { + Y_UNIT_TEST(OnScopeExitMoveTest) { THolder<int> i{new int{10}}; int p = 0; diff --git a/util/generic/set_ut.cpp b/util/generic/set_ut.cpp index d2769d327f7..6c335080c0f 100644 --- a/util/generic/set_ut.cpp +++ b/util/generic/set_ut.cpp @@ -6,8 +6,8 @@ #include <algorithm> -Y_UNIT_TEST_SUITE(YSetTest) { - Y_UNIT_TEST(TestSet1) { +Y_UNIT_TEST_SUITE(YSetTest) { + Y_UNIT_TEST(TestSet1) { TSet<int, TLess<int>> s; UNIT_ASSERT(!s); UNIT_ASSERT(s.count(42) == 0); @@ -20,7 +20,7 @@ Y_UNIT_TEST_SUITE(YSetTest) { UNIT_ASSERT(count == 1); } - Y_UNIT_TEST(TestSet2) { + Y_UNIT_TEST(TestSet2) { using int_set = TSet<int, TLess<int>>; int_set s; std::pair<int_set::iterator, bool> p = s.insert(42); @@ -45,7 +45,7 @@ Y_UNIT_TEST_SUITE(YSetTest) { UNIT_ASSERT(distance(s3.begin(), s3.end()) == 5); } - Y_UNIT_TEST(TestErase) { + Y_UNIT_TEST(TestErase) { TSet<int, TLess<int>> s; s.insert(1); s.erase(s.begin()); @@ -55,13 +55,13 @@ Y_UNIT_TEST_SUITE(YSetTest) { UNIT_ASSERT(nb == 0); } - Y_UNIT_TEST(TestInsert) { + Y_UNIT_TEST(TestInsert) { TSet<int> s; TSet<int>::iterator i = s.insert(s.end(), 0); UNIT_ASSERT(*i == 0); } - Y_UNIT_TEST(TestFind) { + Y_UNIT_TEST(TestFind) { TSet<int> s; UNIT_ASSERT(s.find(0) == s.end()); @@ -71,7 +71,7 @@ Y_UNIT_TEST_SUITE(YSetTest) { UNIT_ASSERT(crs.find(0) == crs.end()); } - Y_UNIT_TEST(TestHas) { + Y_UNIT_TEST(TestHas) { TSet<int> s; UNIT_ASSERT(!s.contains(0)); @@ -89,7 +89,7 @@ Y_UNIT_TEST_SUITE(YSetTest) { UNIT_ASSERT(s.contains(100)); } - Y_UNIT_TEST(TestBounds) { + Y_UNIT_TEST(TestBounds) { int array1[] = {1, 3, 6, 7}; TSet<int> s(array1, array1 + sizeof(array1) / sizeof(array1[0])); TSet<int> const& crs = s; @@ -155,7 +155,7 @@ Y_UNIT_TEST_SUITE(YSetTest) { UNIT_ASSERT(*pcit.second == 7); } - Y_UNIT_TEST(TestImplementationCheck) { + Y_UNIT_TEST(TestImplementationCheck) { TSet<int> tree; tree.insert(1); TSet<int>::iterator it = tree.begin(); @@ -170,7 +170,7 @@ Y_UNIT_TEST_SUITE(YSetTest) { UNIT_ASSERT(int_cref == 1); } - Y_UNIT_TEST(TestReverseIteratorTest) { + Y_UNIT_TEST(TestReverseIteratorTest) { TSet<int> tree; tree.insert(1); tree.insert(2); @@ -191,7 +191,7 @@ Y_UNIT_TEST_SUITE(YSetTest) { } } - Y_UNIT_TEST(TestConstructorsAndAssignments) { + Y_UNIT_TEST(TestConstructorsAndAssignments) { { using container = TSet<int>; @@ -309,7 +309,7 @@ Y_UNIT_TEST_SUITE(YSetTest) { using is_transparent = void; }; - Y_UNIT_TEST(TestTemplateMethods) { + Y_UNIT_TEST(TestTemplateMethods) { { using KeySet = TSet<TKey, TKeyCmp>; KeySet keySet; diff --git a/util/generic/singleton.cpp b/util/generic/singleton.cpp index eb5a0662f8d..cfe51e5e44a 100644 --- a/util/generic/singleton.cpp +++ b/util/generic/singleton.cpp @@ -29,8 +29,8 @@ namespace { void NPrivate::FillWithTrash(void* ptr, size_t len) { #if defined(NDEBUG) - Y_UNUSED(ptr); - Y_UNUSED(len); + Y_UNUSED(ptr); + Y_UNUSED(len); #else if constexpr (NSan::TSanIsOn()) { Y_UNUSED(ptr); @@ -44,7 +44,7 @@ void NPrivate::FillWithTrash(void* ptr, size_t len) { void NPrivate::LockRecursive(TAtomic& lock) noexcept { const TAtomicBase id = MyThreadId(); - Y_VERIFY(AtomicGet(lock) != id, "recursive singleton initialization"); + Y_VERIFY(AtomicGet(lock) != id, "recursive singleton initialization"); if (!MyAtomicTryLock(lock, id)) { TSpinWait sw; @@ -56,6 +56,6 @@ void NPrivate::LockRecursive(TAtomic& lock) noexcept { } void NPrivate::UnlockRecursive(TAtomic& lock) noexcept { - Y_VERIFY(AtomicGet(lock) == MyThreadId(), "unlock from another thread?!?!"); + Y_VERIFY(AtomicGet(lock) == MyThreadId(), "unlock from another thread?!?!"); AtomicUnlock(&lock); } diff --git a/util/generic/singleton.h b/util/generic/singleton.h index f5fa047f5c9..38ee989c85a 100644 --- a/util/generic/singleton.h +++ b/util/generic/singleton.h @@ -8,7 +8,7 @@ template <class T> struct TSingletonTraits { - static constexpr size_t Priority = 65536; + static constexpr size_t Priority = 65536; }; namespace NPrivate { diff --git a/util/generic/singleton_ut.cpp b/util/generic/singleton_ut.cpp index 35ba90cd760..45a9852da35 100644 --- a/util/generic/singleton_ut.cpp +++ b/util/generic/singleton_ut.cpp @@ -2,13 +2,13 @@ #include <library/cpp/testing/unittest/registar.h> -Y_UNIT_TEST_SUITE(TestSingleton) { +Y_UNIT_TEST_SUITE(TestSingleton) { struct THuge { char Buf[1000000]; int V = 1234; }; - Y_UNIT_TEST(TestHuge) { + Y_UNIT_TEST(TestHuge) { UNIT_ASSERT_VALUES_EQUAL(*HugeSingleton<int>(), 0); UNIT_ASSERT_VALUES_EQUAL(HugeSingleton<THuge>()->V, 1234); } @@ -24,13 +24,13 @@ Y_UNIT_TEST_SUITE(TestSingleton) { TString Data2; }; - Y_UNIT_TEST(TestConstructorParamsOrder) { + Y_UNIT_TEST(TestConstructorParamsOrder) { UNIT_ASSERT_VALUES_EQUAL(Singleton<TWithParams>(10, "123123")->Data1, 10); UNIT_ASSERT_VALUES_EQUAL(Singleton<TWithParams>(20, "123123")->Data1, 10); UNIT_ASSERT_VALUES_EQUAL(Singleton<TWithParams>(10, "456456")->Data2, "123123"); } - Y_UNIT_TEST(TestInstantiationWithConstructorParams) { + Y_UNIT_TEST(TestInstantiationWithConstructorParams) { UNIT_ASSERT_VALUES_EQUAL(Singleton<TWithParams>(10)->Data1, 10); UNIT_ASSERT_VALUES_EQUAL(HugeSingleton<TWithParams>(20, "123123")->Data2, "123123"); { diff --git a/util/generic/stack_ut.cpp b/util/generic/stack_ut.cpp index 248127d3260..b63e23711eb 100644 --- a/util/generic/stack_ut.cpp +++ b/util/generic/stack_ut.cpp @@ -2,8 +2,8 @@ #include <library/cpp/testing/unittest/registar.h> -Y_UNIT_TEST_SUITE(TYStackTest) { - Y_UNIT_TEST(ExplicitBool) { +Y_UNIT_TEST_SUITE(TYStackTest) { + Y_UNIT_TEST(ExplicitBool) { TStack<int> s; UNIT_ASSERT(!s); diff --git a/util/generic/strbase.h b/util/generic/strbase.h index ab39fc7537f..862a4270772 100644 --- a/util/generic/strbase.h +++ b/util/generic/strbase.h @@ -46,7 +46,7 @@ public: using size_type = size_t; using difference_type = ptrdiff_t; - static constexpr size_t npos = size_t(-1); + static constexpr size_t npos = size_t(-1); using const_iterator = const TCharType*; using const_reference = const TCharType&; @@ -144,13 +144,13 @@ public: } inline const_iterator cbegin() const noexcept { - return begin(); - } - + return begin(); + } + inline const_iterator cend() const noexcept { - return end(); - } - + return end(); + } + inline const_reverse_iterator rbegin() const noexcept { return const_reverse_iterator(Ptr() + size()); } @@ -294,35 +294,35 @@ public: return equal(LegacySubString(*this, p, n), LegacySubString(t, 0, n1)); } - static inline bool StartsWith(const TCharType* what, size_t whatLen, const TCharType* with, size_t withLen) noexcept { + static inline bool StartsWith(const TCharType* what, size_t whatLen, const TCharType* with, size_t withLen) noexcept { return withLen <= whatLen && TStringViewWithTraits(what, withLen) == TStringViewWithTraits(with, withLen); } - static inline bool EndsWith(const TCharType* what, size_t whatLen, const TCharType* with, size_t withLen) noexcept { + static inline bool EndsWith(const TCharType* what, size_t whatLen, const TCharType* with, size_t withLen) noexcept { return withLen <= whatLen && TStringViewWithTraits(what + whatLen - withLen, withLen) == TStringViewWithTraits(with, withLen); } - inline bool StartsWith(const TCharType* s, size_t n) const noexcept { - return StartsWith(Ptr(), Len(), s, n); + inline bool StartsWith(const TCharType* s, size_t n) const noexcept { + return StartsWith(Ptr(), Len(), s, n); } inline bool StartsWith(const TStringView s) const noexcept { return StartsWith(s.data(), s.length()); } - inline bool StartsWith(TCharType ch) const noexcept { + inline bool StartsWith(TCharType ch) const noexcept { return !empty() && TTraits::eq(*Ptr(), ch); } - inline bool EndsWith(const TCharType* s, size_t n) const noexcept { - return EndsWith(Ptr(), Len(), s, n); + inline bool EndsWith(const TCharType* s, size_t n) const noexcept { + return EndsWith(Ptr(), Len(), s, n); } inline bool EndsWith(const TStringView s) const noexcept { return EndsWith(s.data(), s.length()); } - inline bool EndsWith(TCharType ch) const noexcept { + inline bool EndsWith(TCharType ch) const noexcept { return !empty() && TTraits::eq(Ptr()[Len() - 1], ch); } @@ -432,7 +432,7 @@ public: // ~~ Read access ~~ inline TCharType at(size_t pos) const noexcept { - if (Y_LIKELY(pos < Len())) { + if (Y_LIKELY(pos < Len())) { return (Ptr())[pos]; } return 0; diff --git a/util/generic/strbuf.h b/util/generic/strbuf.h index 70b9360d580..3c046ea8a30 100644 --- a/util/generic/strbuf.h +++ b/util/generic/strbuf.h @@ -153,9 +153,9 @@ public: inline TBasicStringBuf(const TBasicStringBuf& src, size_t pos) noexcept : TBasicStringBuf(src, pos, TBase::npos) - { - } - + { + } + Y_PURE_FUNCTION inline TBasicStringBuf SubString(size_t pos, size_t n) const noexcept { pos = Min(pos, size()); n = Min(n, size() - pos); @@ -290,7 +290,7 @@ public: SplitOn(pos, l, r, 0); } - /* + /* // Not implemented intentionally, use TrySplitOn() instead void RSplitOn(size_t pos, TdSelf& l, TdSelf& r) const noexcept; void RSplitAt(size_t pos, TdSelf& l, TdSelf& r) const noexcept; @@ -319,7 +319,7 @@ public: public: inline bool AfterPrefix(const TdSelf& prefix, TdSelf& result) const noexcept { - if (this->StartsWith(prefix)) { + if (this->StartsWith(prefix)) { result = Tail(prefix.size()); return true; } @@ -327,7 +327,7 @@ public: } inline bool BeforeSuffix(const TdSelf& suffix, TdSelf& result) const noexcept { - if (this->EndsWith(suffix)) { + if (this->EndsWith(suffix)) { result = Head(size() - suffix.size()); return true; } @@ -370,7 +370,7 @@ public: SplitOn(pos, tok, *this); return tok; } - /* + /* // See comment on RSplitOn() above TdSelf RSplitOffOn(size_t pos); TdSelf RNextTokOn(size_t pos); diff --git a/util/generic/strbuf_ut.cpp b/util/generic/strbuf_ut.cpp index 69cde785af0..106bb097d53 100644 --- a/util/generic/strbuf_ut.cpp +++ b/util/generic/strbuf_ut.cpp @@ -4,7 +4,7 @@ #include <string_view> -Y_UNIT_TEST_SUITE(TStrBufTest) { +Y_UNIT_TEST_SUITE(TStrBufTest) { Y_UNIT_TEST(TestConstructorsAndOperators) { TStringBuf str("qwerty"); @@ -27,7 +27,7 @@ Y_UNIT_TEST_SUITE(TStrBufTest) { UNIT_ASSERT_EQUAL(helloWorld.size(), fromStringBuf.size()); } - Y_UNIT_TEST(TestConstExpr) { + Y_UNIT_TEST(TestConstExpr) { static constexpr TStringBuf str1("qwe\0rty", 7); static constexpr TStringBuf str2(str1.data(), str1.size()); static constexpr TStringBuf str3 = "qwe\0rty"sv; @@ -49,7 +49,7 @@ Y_UNIT_TEST_SUITE(TStrBufTest) { static_assert(str1.size() == str4.size()); } - Y_UNIT_TEST(TestAfter) { + Y_UNIT_TEST(TestAfter) { TStringBuf str("qwerty"); UNIT_ASSERT_VALUES_EQUAL(str.After('w'), TStringBuf("erty")); @@ -62,7 +62,7 @@ Y_UNIT_TEST_SUITE(TStrBufTest) { UNIT_ASSERT_STRINGS_EQUAL(empty.After('x'), empty); } - Y_UNIT_TEST(TestBefore) { + Y_UNIT_TEST(TestBefore) { TStringBuf str("qwerty"); UNIT_ASSERT_VALUES_EQUAL(str.Before('w'), TStringBuf("q")); @@ -71,7 +71,7 @@ Y_UNIT_TEST_SUITE(TStrBufTest) { UNIT_ASSERT_VALUES_EQUAL(str.Before('q'), TStringBuf()); } - Y_UNIT_TEST(TestRAfterBefore) { + Y_UNIT_TEST(TestRAfterBefore) { TStringBuf str("a/b/c"); UNIT_ASSERT_STRINGS_EQUAL(str.RAfter('/'), "c"); UNIT_ASSERT_STRINGS_EQUAL(str.RAfter('_'), str); @@ -81,7 +81,7 @@ Y_UNIT_TEST_SUITE(TStrBufTest) { UNIT_ASSERT_STRINGS_EQUAL(str.RBefore('a'), ""); } - Y_UNIT_TEST(TestAfterPrefix) { + Y_UNIT_TEST(TestAfterPrefix) { TStringBuf str("cat_dog"); TStringBuf r = "the_same"; @@ -108,7 +108,7 @@ Y_UNIT_TEST_SUITE(TStrBufTest) { UNIT_ASSERT(!a.SkipPrefix("def") && a == ""); } - Y_UNIT_TEST(TestBeforeSuffix) { + Y_UNIT_TEST(TestBeforeSuffix) { TStringBuf str("cat_dog"); TStringBuf r = "the_same"; @@ -135,12 +135,12 @@ Y_UNIT_TEST_SUITE(TStrBufTest) { UNIT_ASSERT(!a.ChopSuffix("abc") && a == ""); } - Y_UNIT_TEST(TestEmpty) { + Y_UNIT_TEST(TestEmpty) { UNIT_ASSERT(TStringBuf().empty()); UNIT_ASSERT(!TStringBuf("q").empty()); } - Y_UNIT_TEST(TestShift) { + Y_UNIT_TEST(TestShift) { TStringBuf qw("qwerty"); TStringBuf str; @@ -155,7 +155,7 @@ Y_UNIT_TEST_SUITE(TStrBufTest) { UNIT_ASSERT_EQUAL(str, TStringBuf("rt")); } - Y_UNIT_TEST(TestSplit) { + Y_UNIT_TEST(TestSplit) { TStringBuf qw("qwerty"); TStringBuf lt, rt; @@ -176,7 +176,7 @@ Y_UNIT_TEST_SUITE(TStrBufTest) { UNIT_ASSERT_EQUAL(ty, TStringBuf("ty")); } - Y_UNIT_TEST(TestNextTok) { + Y_UNIT_TEST(TestNextTok) { TStringBuf buf("12q45q"); TStringBuf tok; @@ -185,7 +185,7 @@ Y_UNIT_TEST_SUITE(TStrBufTest) { UNIT_ASSERT(!buf.NextTok('q', tok)); } - Y_UNIT_TEST(TestNextStringTok) { + Y_UNIT_TEST(TestNextStringTok) { TStringBuf buf1("a@@b@@c"); UNIT_ASSERT_EQUAL(buf1.NextTok("@@"), TStringBuf("a")); UNIT_ASSERT_EQUAL(buf1.NextTok("@@"), TStringBuf("b")); @@ -203,7 +203,7 @@ Y_UNIT_TEST_SUITE(TStrBufTest) { UNIT_ASSERT_EQUAL(buf3, TStringBuf()); } - Y_UNIT_TEST(TestReadLine) { + Y_UNIT_TEST(TestReadLine) { TStringBuf buf("12\n45\r\n\r\n23"); TStringBuf tok; @@ -222,7 +222,7 @@ Y_UNIT_TEST_SUITE(TStrBufTest) { UNIT_ASSERT(!buf.ReadLine(tok)); } - Y_UNIT_TEST(TestRFind) { + Y_UNIT_TEST(TestRFind) { TStringBuf buf1 = "123123456"; UNIT_ASSERT_EQUAL(buf1.rfind('3'), 5); UNIT_ASSERT_EQUAL(buf1.rfind('4'), 6); @@ -240,7 +240,7 @@ Y_UNIT_TEST_SUITE(TStrBufTest) { UNIT_ASSERT_EQUAL(buf4.rfind('3'), 2); } - Y_UNIT_TEST(TestRNextTok) { + Y_UNIT_TEST(TestRNextTok) { TStringBuf buf1("a.b.c"); UNIT_ASSERT_EQUAL(buf1.RNextTok('.'), TStringBuf("c")); UNIT_ASSERT_EQUAL(buf1, TStringBuf("a.b")); @@ -256,7 +256,7 @@ Y_UNIT_TEST_SUITE(TStrBufTest) { UNIT_ASSERT(!buf3.RNextTok(' ', tok) && tok == "ab" && buf3 == ""); // not modified } - Y_UNIT_TEST(TestRSplitOff) { + Y_UNIT_TEST(TestRSplitOff) { TStringBuf buf1("a.b.c"); UNIT_ASSERT_EQUAL(buf1.RSplitOff('.'), TStringBuf("a.b")); UNIT_ASSERT_EQUAL(buf1, TStringBuf("c")); @@ -265,18 +265,18 @@ Y_UNIT_TEST_SUITE(TStrBufTest) { UNIT_ASSERT_EQUAL(buf2.RSplitOff('.'), TStringBuf()); UNIT_ASSERT_EQUAL(buf2, TStringBuf("a")); } - - Y_UNIT_TEST(TestCBeginCEnd) { - const char helloThere[] = "Hello there"; - TStringBuf s{helloThere}; - - size_t index = 0; - for (auto it = s.cbegin(); s.cend() != it; ++it, ++index) { - UNIT_ASSERT_VALUES_EQUAL(helloThere[index], *it); - } - } - - Y_UNIT_TEST(TestSplitOnAt) { + + Y_UNIT_TEST(TestCBeginCEnd) { + const char helloThere[] = "Hello there"; + TStringBuf s{helloThere}; + + size_t index = 0; + for (auto it = s.cbegin(); s.cend() != it; ++it, ++index) { + UNIT_ASSERT_VALUES_EQUAL(helloThere[index], *it); + } + } + + Y_UNIT_TEST(TestSplitOnAt) { TStringBuf s = "abcabc"; TStringBuf l, r; @@ -296,28 +296,28 @@ Y_UNIT_TEST_SUITE(TStrBufTest) { // out of range pos = 100500; - UNIT_ASSERT(s.TrySplitOn(pos, l, r)); // still true + UNIT_ASSERT(s.TrySplitOn(pos, l, r)); // still true UNIT_ASSERT(l == "abcabc" && r == ""); - l = "111"; - r = "222"; - UNIT_ASSERT(s.TrySplitAt(pos, l, r)); // still true + l = "111"; + r = "222"; + UNIT_ASSERT(s.TrySplitAt(pos, l, r)); // still true UNIT_ASSERT(l == "abcabc" && r == ""); // npos pos = s.find("missing"); - l = "111"; - r = "222"; + l = "111"; + r = "222"; UNIT_ASSERT(!s.TrySplitOn(pos, l, r)); - UNIT_ASSERT(l == "111" && r == "222"); // not modified + UNIT_ASSERT(l == "111" && r == "222"); // not modified s.SplitOn(pos, l, r); - UNIT_ASSERT(l == "abcabc" && r == ""); // modified + UNIT_ASSERT(l == "abcabc" && r == ""); // modified - l = "111"; - r = "222"; + l = "111"; + r = "222"; UNIT_ASSERT(!s.TrySplitAt(pos, l, r)); - UNIT_ASSERT(l == "111" && r == "222"); // not modified + UNIT_ASSERT(l == "111" && r == "222"); // not modified s.SplitAt(pos, l, r); - UNIT_ASSERT(l == "abcabc" && r == ""); // modified + UNIT_ASSERT(l == "abcabc" && r == ""); // modified } template <class T> @@ -328,7 +328,7 @@ Y_UNIT_TEST_SUITE(TStrBufTest) { UNIT_ASSERT(TStringBuf(val).size() == 5); } - Y_UNIT_TEST(TestPassingArraysByConstReference) { + Y_UNIT_TEST(TestPassingArraysByConstReference) { char data[] = "Hello\0word"; PassByConstReference(data); } diff --git a/util/generic/string.h b/util/generic/string.h index 8cd8aa6917f..fc2109198a9 100644 --- a/util/generic/string.h +++ b/util/generic/string.h @@ -1067,7 +1067,7 @@ public: } TBasicString& pop_back() Y_NOEXCEPT { - Y_ASSERT(!this->empty()); + Y_ASSERT(!this->empty()); MutRef().pop_back(); diff --git a/util/generic/string_transparent_hash_ut.cpp b/util/generic/string_transparent_hash_ut.cpp index b87fa2843e6..00c9f3bafa1 100644 --- a/util/generic/string_transparent_hash_ut.cpp +++ b/util/generic/string_transparent_hash_ut.cpp @@ -1,19 +1,19 @@ #include "string.h" #include "vector.h" -#include "strbuf.h" +#include "strbuf.h" #include <library/cpp/testing/unittest/registar.h> #include <library/cpp/containers/absl_flat_hash/flat_hash_set.h> -#include <util/str_stl.h> +#include <util/str_stl.h> -Y_UNIT_TEST_SUITE(StringHashFunctorTests) { - Y_UNIT_TEST(TestTransparencyWithUnorderedSet) { - // Using Abseil hash set because `std::unordered_set` is transparent only from C++20 (while - // we stuck with C++17 right now). - absl::flat_hash_set<TString, THash<TString>, TEqualTo<TString>> s = {"foo"}; - // If either `THash` or `TEqualTo` is not transparent compilation will fail. - UNIT_ASSERT_UNEQUAL(s.find(TStringBuf("foo")), s.end()); - UNIT_ASSERT_EQUAL(s.find(TStringBuf("bar")), s.end()); +Y_UNIT_TEST_SUITE(StringHashFunctorTests) { + Y_UNIT_TEST(TestTransparencyWithUnorderedSet) { + // Using Abseil hash set because `std::unordered_set` is transparent only from C++20 (while + // we stuck with C++17 right now). + absl::flat_hash_set<TString, THash<TString>, TEqualTo<TString>> s = {"foo"}; + // If either `THash` or `TEqualTo` is not transparent compilation will fail. + UNIT_ASSERT_UNEQUAL(s.find(TStringBuf("foo")), s.end()); + UNIT_ASSERT_EQUAL(s.find(TStringBuf("bar")), s.end()); } } diff --git a/util/generic/string_ut.cpp b/util/generic/string_ut.cpp index ac82e9091db..f96bec64805 100644 --- a/util/generic/string_ut.cpp +++ b/util/generic/string_ut.cpp @@ -5,7 +5,7 @@ #include "yexception.h" #include <util/charset/wide.h> -#include <util/str_stl.h> +#include <util/str_stl.h> #include <util/stream/output.h> #include <util/string/subst.h> @@ -30,8 +30,8 @@ public: const char data[] = "abc\0def\0"; TString s(data, sizeof(data)); UNIT_ASSERT(s.size() == sizeof(data)); - UNIT_ASSERT(s.StartsWith(s)); - UNIT_ASSERT(s.EndsWith(s)); + UNIT_ASSERT(s.StartsWith(s)); + UNIT_ASSERT(s.EndsWith(s)); UNIT_ASSERT(s.Contains('\0')); const char raw_def[] = "def"; @@ -54,7 +54,7 @@ public: UNIT_ASSERT(s == copy); TString prefix(data, 5); - UNIT_ASSERT(s.StartsWith(prefix)); + UNIT_ASSERT(s.StartsWith(prefix)); UNIT_ASSERT(s != prefix); UNIT_ASSERT(s > prefix); UNIT_ASSERT(s > s.data()); @@ -269,7 +269,7 @@ protected: TStringType xx; // ISO-IEC-14882:1998(E), 21.3.6, paragraph 3 - UNIT_ASSERT(xx.data() != nullptr); + UNIT_ASSERT(xx.data() != nullptr); } void c_str() { @@ -537,15 +537,15 @@ protected: } } - void cbegin_cend() { - const char helloThere[] = "Hello there"; + void cbegin_cend() { + const char helloThere[] = "Hello there"; TString s = helloThere; - size_t index = 0; - for (auto it = s.cbegin(); s.cend() != it; ++it, ++index) { - UNIT_ASSERT_VALUES_EQUAL(helloThere[index], *it); - } - } - + size_t index = 0; + for (auto it = s.cbegin(); s.cend() != it; ++it, ++index) { + UNIT_ASSERT_VALUES_EQUAL(helloThere[index], *it); + } + } + void compare() { TStringType str1(Data_.abcdef()); TStringType str2; @@ -1128,7 +1128,7 @@ public: UNIT_TEST(capacity); UNIT_TEST(assign); UNIT_TEST(copy); - UNIT_TEST(cbegin_cend); + UNIT_TEST(cbegin_cend); UNIT_TEST(compare); UNIT_TEST(find_last_of); #if 0 @@ -1164,7 +1164,7 @@ public: UNIT_TEST(capacity); UNIT_TEST(assign); UNIT_TEST(copy); - UNIT_TEST(cbegin_cend); + UNIT_TEST(cbegin_cend); UNIT_TEST(compare); UNIT_TEST(find_last_of); #if 0 @@ -1190,19 +1190,19 @@ Y_UNIT_TEST_SUITE(TStringConversionTest) { UNIT_ASSERT_VALUES_EQUAL(stdAbra, "cadabra"); } } - -Y_UNIT_TEST_SUITE(HashFunctorTests) { - Y_UNIT_TEST(TestTransparency) { - THash<TString> h; - const char* ptr = "a"; - const TStringBuf strbuf = ptr; - const TString str = ptr; - const std::string stdStr = ptr; - UNIT_ASSERT_VALUES_EQUAL(h(ptr), h(strbuf)); - UNIT_ASSERT_VALUES_EQUAL(h(ptr), h(str)); - UNIT_ASSERT_VALUES_EQUAL(h(ptr), h(stdStr)); - } -} + +Y_UNIT_TEST_SUITE(HashFunctorTests) { + Y_UNIT_TEST(TestTransparency) { + THash<TString> h; + const char* ptr = "a"; + const TStringBuf strbuf = ptr; + const TString str = ptr; + const std::string stdStr = ptr; + UNIT_ASSERT_VALUES_EQUAL(h(ptr), h(strbuf)); + UNIT_ASSERT_VALUES_EQUAL(h(ptr), h(str)); + UNIT_ASSERT_VALUES_EQUAL(h(ptr), h(stdStr)); + } +} #if !defined(TSTRING_IS_STD_STRING) Y_UNIT_TEST_SUITE(StdNonConformant) { diff --git a/util/generic/string_ut.h b/util/generic/string_ut.h index 44bb10bdebe..cd9db7876be 100644 --- a/util/generic/string_ut.h +++ b/util/generic/string_ut.h @@ -981,21 +981,21 @@ public: void TestPrefixSuffix() { const TStringType emptyStr; - UNIT_ASSERT_EQUAL(emptyStr.StartsWith('x'), false); - UNIT_ASSERT_EQUAL(emptyStr.EndsWith('x'), false); - UNIT_ASSERT_EQUAL(emptyStr.StartsWith(0), false); - UNIT_ASSERT_EQUAL(emptyStr.EndsWith(0), false); - UNIT_ASSERT_EQUAL(emptyStr.StartsWith(emptyStr), true); - UNIT_ASSERT_EQUAL(emptyStr.EndsWith(emptyStr), true); + UNIT_ASSERT_EQUAL(emptyStr.StartsWith('x'), false); + UNIT_ASSERT_EQUAL(emptyStr.EndsWith('x'), false); + UNIT_ASSERT_EQUAL(emptyStr.StartsWith(0), false); + UNIT_ASSERT_EQUAL(emptyStr.EndsWith(0), false); + UNIT_ASSERT_EQUAL(emptyStr.StartsWith(emptyStr), true); + UNIT_ASSERT_EQUAL(emptyStr.EndsWith(emptyStr), true); const char_type chars[] = {'h', 'e', 'l', 'l', 'o', 0}; const TStringType str(chars); - UNIT_ASSERT_EQUAL(str.StartsWith('h'), true); - UNIT_ASSERT_EQUAL(str.StartsWith('o'), false); - UNIT_ASSERT_EQUAL(str.EndsWith('o'), true); - UNIT_ASSERT_EQUAL(str.EndsWith('h'), false); - UNIT_ASSERT_EQUAL(str.StartsWith(emptyStr), true); - UNIT_ASSERT_EQUAL(str.EndsWith(emptyStr), true); + UNIT_ASSERT_EQUAL(str.StartsWith('h'), true); + UNIT_ASSERT_EQUAL(str.StartsWith('o'), false); + UNIT_ASSERT_EQUAL(str.EndsWith('o'), true); + UNIT_ASSERT_EQUAL(str.EndsWith('h'), false); + UNIT_ASSERT_EQUAL(str.StartsWith(emptyStr), true); + UNIT_ASSERT_EQUAL(str.EndsWith(emptyStr), true); } #ifndef TSTRING_IS_STD_STRING diff --git a/util/generic/typelist.h b/util/generic/typelist.h index 5ce26ab97c7..90d7e4239ea 100644 --- a/util/generic/typelist.h +++ b/util/generic/typelist.h @@ -1,7 +1,7 @@ #pragma once -#include <util/system/types.h> - +#include <util/system/types.h> + #include <util/generic/typetraits.h> #include <type_traits> @@ -109,6 +109,6 @@ using TFixedWidthSignedInt = typename TFixedWidthSignedInts::template TSelectBy< template <typename T> using TFixedWidthUnsignedInt = typename TFixedWidthUnsignedInts::template TSelectBy<TSizeOfPredicate<sizeof(T)>::template TResult>::type; - -template <typename T> -using TFixedWidthFloat = typename TFloats::template TSelectBy<TSizeOfPredicate<sizeof(T)>::template TResult>::type; + +template <typename T> +using TFixedWidthFloat = typename TFloats::template TSelectBy<TSizeOfPredicate<sizeof(T)>::template TResult>::type; diff --git a/util/generic/typelist_ut.cpp b/util/generic/typelist_ut.cpp index eeabfa97b17..e2872feab7b 100644 --- a/util/generic/typelist_ut.cpp +++ b/util/generic/typelist_ut.cpp @@ -10,7 +10,7 @@ class TTypeListTest: public TTestBase { UNIT_TEST(TestSimple); UNIT_TEST(TestHave); UNIT_TEST(TestGet); - UNIT_TEST(TestFloatList); + UNIT_TEST(TestFloatList); UNIT_TEST(TestSelectBy); UNIT_TEST_SUITE_END(); @@ -73,13 +73,13 @@ public: using TMyMapPTATB = TMyMap<TA*, TB>; UNIT_ASSERT_TYPES_EQUAL(TListType::TSelectBy<TIsNArgTemplate>::type, TMyMapPTATB); } - - void TestFloatList() { - UNIT_ASSERT_TYPES_EQUAL(TFixedWidthFloat<ui32>, float); - UNIT_ASSERT_TYPES_EQUAL(TFixedWidthFloat<i32>, float); - UNIT_ASSERT_TYPES_EQUAL(TFixedWidthFloat<ui64>, double); - UNIT_ASSERT_TYPES_EQUAL(TFixedWidthFloat<i64>, double); - } + + void TestFloatList() { + UNIT_ASSERT_TYPES_EQUAL(TFixedWidthFloat<ui32>, float); + UNIT_ASSERT_TYPES_EQUAL(TFixedWidthFloat<i32>, float); + UNIT_ASSERT_TYPES_EQUAL(TFixedWidthFloat<ui64>, double); + UNIT_ASSERT_TYPES_EQUAL(TFixedWidthFloat<i64>, double); + } }; UNIT_TEST_SUITE_REGISTRATION(TTypeListTest); diff --git a/util/generic/typetraits.h b/util/generic/typetraits.h index d165bd1a068..57d07c62ff4 100644 --- a/util/generic/typetraits.h +++ b/util/generic/typetraits.h @@ -1,6 +1,6 @@ #pragma once -#include "va_args.h" +#include "va_args.h" #include <util/system/defaults.h> @@ -115,7 +115,7 @@ public: /* * can be used in function templates for effective parameters passing */ - using TFuncParam = std::conditional_t<IsValueType, T, const std::remove_reference_t<T>&>; + using TFuncParam = std::conditional_t<IsValueType, T, const std::remove_reference_t<T>&>; }; template <> @@ -162,79 +162,79 @@ class TTypeTraits<void>: public TTypeTraitsBase<void> {}; struct THas##name \ : TBaseHas##name<T, std::is_class<T>::value || std::is_union<T>::value> {} -#define Y_HAS_MEMBER_IMPL_1(name) Y_HAS_MEMBER_IMPL_2(name, name) +#define Y_HAS_MEMBER_IMPL_1(name) Y_HAS_MEMBER_IMPL_2(name, name) -/* @def Y_HAS_MEMBER - * - * This macro should be used to define compile-time introspection helper classes for template - * metaprogramming. - * - * Macro accept one or two parameters, when used with two parameters e.g. `Y_HAS_MEMBER(xyz, ABC)` +/* @def Y_HAS_MEMBER + * + * This macro should be used to define compile-time introspection helper classes for template + * metaprogramming. + * + * Macro accept one or two parameters, when used with two parameters e.g. `Y_HAS_MEMBER(xyz, ABC)` * will define class `THasABC` with static member `value` of type bool. Usage with one parameter - * e.g. `Y_HAS_MEMBER(xyz)` will produce the same result as `Y_HAS_MEMBER(xyz, xyz)`. - * - * @code - * #include <type_traits> - * - * Y_HAS_MEMBER(push_front, PushFront); - * - * template <typename T, typename U> + * e.g. `Y_HAS_MEMBER(xyz)` will produce the same result as `Y_HAS_MEMBER(xyz, xyz)`. + * + * @code + * #include <type_traits> + * + * Y_HAS_MEMBER(push_front, PushFront); + * + * template <typename T, typename U> * std::enable_if_t<THasPushFront<T>::value, void> - * PushFront(T& container, const U value) { - * container.push_front(x); - * } - * - * template <typename T, typename U> + * PushFront(T& container, const U value) { + * container.push_front(x); + * } + * + * template <typename T, typename U> * std::enable_if_t<!THasPushFront<T>::value, void> - * PushFront(T& container, const U value) { - * container.insert(container.begin(), x); - * } - * @endcode - */ -#define Y_HAS_MEMBER(...) Y_PASS_VA_ARGS(Y_MACRO_IMPL_DISPATCHER_2(__VA_ARGS__, Y_HAS_MEMBER_IMPL_2, Y_HAS_MEMBER_IMPL_1)(__VA_ARGS__)) - + * PushFront(T& container, const U value) { + * container.insert(container.begin(), x); + * } + * @endcode + */ +#define Y_HAS_MEMBER(...) Y_PASS_VA_ARGS(Y_MACRO_IMPL_DISPATCHER_2(__VA_ARGS__, Y_HAS_MEMBER_IMPL_2, Y_HAS_MEMBER_IMPL_1)(__VA_ARGS__)) + #define Y_HAS_SUBTYPE_IMPL_2(subtype, name) \ template <class T, class = void> \ struct THas##name: std::false_type {}; \ template <class T> \ struct THas##name<T, ::TVoidT<typename T::subtype>>: std::true_type {}; -#define Y_HAS_SUBTYPE_IMPL_1(name) Y_HAS_SUBTYPE_IMPL_2(name, name) +#define Y_HAS_SUBTYPE_IMPL_1(name) Y_HAS_SUBTYPE_IMPL_2(name, name) -/* @def Y_HAS_SUBTYPE - * - * This macro should be used to define compile-time introspection helper classes for template - * metaprogramming. - * - * Macro accept one or two parameters, when used with two parameters e.g. `Y_HAS_SUBTYPE(xyz, ABC)` +/* @def Y_HAS_SUBTYPE + * + * This macro should be used to define compile-time introspection helper classes for template + * metaprogramming. + * + * Macro accept one or two parameters, when used with two parameters e.g. `Y_HAS_SUBTYPE(xyz, ABC)` * will define class `THasABC` with static member `value` of type bool. Usage with one parameter - * e.g. `Y_HAS_SUBTYPE(xyz)` will produce the same result as `Y_HAS_SUBTYPE(xyz, xyz)`. - * - * @code - * Y_HAS_MEMBER(find, FindMethod); - * Y_HAS_SUBTYPE(const_iterator, ConstIterator); - * Y_HAS_SUBTYPE(key_type, KeyType); - * - * template <typename T> - * using TIsAssocCont = std::conditional_t< + * e.g. `Y_HAS_SUBTYPE(xyz)` will produce the same result as `Y_HAS_SUBTYPE(xyz, xyz)`. + * + * @code + * Y_HAS_MEMBER(find, FindMethod); + * Y_HAS_SUBTYPE(const_iterator, ConstIterator); + * Y_HAS_SUBTYPE(key_type, KeyType); + * + * template <typename T> + * using TIsAssocCont = std::conditional_t< * THasFindMethod<T>::value && THasConstIterator<T>::value && THasKeyType<T>::value, - * std::true_type, - * std::false_type, - * >; - * + * std::true_type, + * std::false_type, + * >; + * * static_assert(TIsAssocCont<TVector<int>>::value == false, ""); * static_assert(TIsAssocCont<THashMap<int>>::value == true, ""); - * @endcode - */ -#define Y_HAS_SUBTYPE(...) Y_PASS_VA_ARGS(Y_MACRO_IMPL_DISPATCHER_2(__VA_ARGS__, Y_HAS_SUBTYPE_IMPL_2, Y_HAS_SUBTYPE_IMPL_1)(__VA_ARGS__)) - + * @endcode + */ +#define Y_HAS_SUBTYPE(...) Y_PASS_VA_ARGS(Y_MACRO_IMPL_DISPATCHER_2(__VA_ARGS__, Y_HAS_SUBTYPE_IMPL_2, Y_HAS_SUBTYPE_IMPL_1)(__VA_ARGS__)) + template <class T1, class T2> struct TPodTraits<std::pair<T1, T2>> { enum { IsPod = TTypeTraits<T1>::IsPod && TTypeTraits<T2>::IsPod }; }; - + template <class T> struct TIsPointerToConstMemberFunction: std::false_type { }; diff --git a/util/generic/typetraits_ut.cpp b/util/generic/typetraits_ut.cpp index e7571c75ece..496e357dd71 100644 --- a/util/generic/typetraits_ut.cpp +++ b/util/generic/typetraits_ut.cpp @@ -78,13 +78,13 @@ namespace { UNIT_ASSERT_C(x_, #x " != " #y); \ } -Y_UNIT_TEST_SUITE(TTypeTraitsTest) { - Y_UNIT_TEST(TestIsSame) { +Y_UNIT_TEST_SUITE(TTypeTraitsTest) { + Y_UNIT_TEST(TestIsSame) { UNIT_ASSERT((std::is_same<int, int>::value)); UNIT_ASSERT(!(std::is_same<signed int, unsigned int>::value)); } - Y_UNIT_TEST(TestRemoveReference) { + Y_UNIT_TEST(TestRemoveReference) { ASSERT_SAME_TYPE(std::remove_reference_t<int>, int); ASSERT_SAME_TYPE(std::remove_reference_t<const int>, const int); ASSERT_SAME_TYPE(std::remove_reference_t<int&>, int); @@ -96,23 +96,23 @@ Y_UNIT_TEST_SUITE(TTypeTraitsTest) { ASSERT_SAME_TYPE(std::remove_reference_t<TIncompleteType&>, TIncompleteType); } - Y_UNIT_TEST(TestRemoveConst) { + Y_UNIT_TEST(TestRemoveConst) { ASSERT_SAME_TYPE(std::remove_const_t<const int>, int); } - Y_UNIT_TEST(TestRemoveVolatile) { + Y_UNIT_TEST(TestRemoveVolatile) { ASSERT_SAME_TYPE(std::remove_volatile_t<volatile int>, int); } - Y_UNIT_TEST(TestRemoveCV) { + Y_UNIT_TEST(TestRemoveCV) { ASSERT_SAME_TYPE(std::remove_cv_t<const volatile int>, int); } - Y_UNIT_TEST(TestAddCV) { + Y_UNIT_TEST(TestAddCV) { ASSERT_SAME_TYPE(std::add_cv_t<int>, const volatile int); } - Y_UNIT_TEST(TestClass) { + Y_UNIT_TEST(TestClass) { UNIT_ASSERT(std::is_class<TString>::value); UNIT_ASSERT(!std::is_class<ETestEnum>::value); UNIT_ASSERT(!std::is_class<int>::value); @@ -168,35 +168,35 @@ Y_UNIT_TEST_SUITE(TTypeTraitsTest) { UNIT_ASSERT(!std::is_signed<ETypedEnum>::value); } - Y_UNIT_TEST(TestBool) { + Y_UNIT_TEST(TestBool) { TestArithmeticType<bool>(); TestUnsignedIntType<bool>(); } - Y_UNIT_TEST(TestUnsignedChar) { + Y_UNIT_TEST(TestUnsignedChar) { TestArithmeticType<unsigned char>(); TestUnsignedIntType<unsigned char>(); } - Y_UNIT_TEST(TestSizeT) { + Y_UNIT_TEST(TestSizeT) { TestArithmeticType<size_t>(); TestUnsignedIntType<size_t>(); } - Y_UNIT_TEST(TestInt) { + Y_UNIT_TEST(TestInt) { TestArithmeticType<int>(); TestSignedIntType<int>(); } - Y_UNIT_TEST(TestDouble) { + Y_UNIT_TEST(TestDouble) { TestArithmeticType<double>(); } - Y_UNIT_TEST(TestLongDouble) { + Y_UNIT_TEST(TestLongDouble) { TestArithmeticType<long double>(); } - Y_UNIT_TEST(TestAddRValueReference) { + Y_UNIT_TEST(TestAddRValueReference) { ASSERT_SAME_TYPE(std::add_rvalue_reference_t<int>, int&&); ASSERT_SAME_TYPE(std::add_rvalue_reference_t<int const&>, int const&); ASSERT_SAME_TYPE(std::add_rvalue_reference_t<int*>, int*&&); @@ -205,7 +205,7 @@ Y_UNIT_TEST_SUITE(TTypeTraitsTest) { ASSERT_SAME_TYPE(std::add_rvalue_reference_t<void>, void); } - Y_UNIT_TEST(TestIsEmpty) { + Y_UNIT_TEST(TestIsEmpty) { UNIT_ASSERT(std::is_empty<TEmptyClass>::value); UNIT_ASSERT(std::is_empty<TEmptyDerivedClass>::value); UNIT_ASSERT(std::is_empty<TAnotherEmptyClass>::value); @@ -218,7 +218,7 @@ Y_UNIT_TEST_SUITE(TTypeTraitsTest) { UNIT_ASSERT(!std::is_empty<TNonEmptyDerivedClass>::value); } - Y_UNIT_TEST(TestIsStandardLayout) { + Y_UNIT_TEST(TestIsStandardLayout) { UNIT_ASSERT(std::is_standard_layout<TStdLayoutClass1>::value); UNIT_ASSERT(std::is_standard_layout<TStdLayoutClass2>::value); UNIT_ASSERT(!std::is_standard_layout<TNonStdLayoutClass1>::value); @@ -230,10 +230,10 @@ Y_UNIT_TEST_SUITE(TTypeTraitsTest) { template <class T> using TTrySum = decltype(std::declval<T>() + std::declval<T>()); - Y_UNIT_TEST(TestIsTriviallyCopyable) { - struct TPod { - int value; - }; + Y_UNIT_TEST(TestIsTriviallyCopyable) { + struct TPod { + int value; + }; struct TNontriviallyCopyAssignable { TNontriviallyCopyAssignable(const TNontriviallyCopyAssignable&) = default; @@ -381,7 +381,7 @@ namespace { #define UNIT_ASSERT_EQUAL_ENUM(expected, actual) UNIT_ASSERT_VALUES_EQUAL((bool)(expected), (bool)(actual)) -Y_UNIT_TEST_SUITE(TTypeTraitsTestNg) { +Y_UNIT_TEST_SUITE(TTypeTraitsTestNg) { template <typename T> void TestImpl() { //UNIT_ASSERT_EQUAL_ENUM(TTypeTraitsExpected<T>::IsPod, TTypeTraits<T>::IsPod); @@ -434,22 +434,22 @@ enum class E8: ui8 { X }; -// test for std::underlying_type_t -static_assert(sizeof(std::underlying_type_t<E4>) == sizeof(int), ""); -static_assert(sizeof(std::underlying_type_t<E64>) == sizeof(ui64), ""); -static_assert(sizeof(std::underlying_type_t<E8>) == sizeof(ui8), ""); - -// tests for TFixedWidthUnsignedInt -static_assert(std::is_same<ui8, TFixedWidthUnsignedInt<i8>>::value, ""); -static_assert(std::is_same<ui16, TFixedWidthUnsignedInt<i16>>::value, ""); -static_assert(std::is_same<ui32, TFixedWidthUnsignedInt<i32>>::value, ""); -static_assert(std::is_same<ui64, TFixedWidthUnsignedInt<i64>>::value, ""); - -// tests for TFixedWidthSignedInt -static_assert(std::is_same<i8, TFixedWidthSignedInt<ui8>>::value, ""); -static_assert(std::is_same<i16, TFixedWidthSignedInt<ui16>>::value, ""); -static_assert(std::is_same<i32, TFixedWidthSignedInt<ui32>>::value, ""); -static_assert(std::is_same<i64, TFixedWidthSignedInt<ui64>>::value, ""); +// test for std::underlying_type_t +static_assert(sizeof(std::underlying_type_t<E4>) == sizeof(int), ""); +static_assert(sizeof(std::underlying_type_t<E64>) == sizeof(ui64), ""); +static_assert(sizeof(std::underlying_type_t<E8>) == sizeof(ui8), ""); + +// tests for TFixedWidthUnsignedInt +static_assert(std::is_same<ui8, TFixedWidthUnsignedInt<i8>>::value, ""); +static_assert(std::is_same<ui16, TFixedWidthUnsignedInt<i16>>::value, ""); +static_assert(std::is_same<ui32, TFixedWidthUnsignedInt<i32>>::value, ""); +static_assert(std::is_same<ui64, TFixedWidthUnsignedInt<i64>>::value, ""); + +// tests for TFixedWidthSignedInt +static_assert(std::is_same<i8, TFixedWidthSignedInt<ui8>>::value, ""); +static_assert(std::is_same<i16, TFixedWidthSignedInt<ui16>>::value, ""); +static_assert(std::is_same<i32, TFixedWidthSignedInt<ui32>>::value, ""); +static_assert(std::is_same<i64, TFixedWidthSignedInt<ui64>>::value, ""); // test for TIsSpecializationOf static_assert(TIsSpecializationOf<std::vector, std::vector<int>>::value, ""); diff --git a/util/generic/ut/ya.make b/util/generic/ut/ya.make index 6eaf24cc5fe..fbe31ffc32b 100644 --- a/util/generic/ut/ya.make +++ b/util/generic/ut/ya.make @@ -58,16 +58,16 @@ SRCS( INCLUDE(${ARCADIA_ROOT}/util/tests/ya_util_tests.inc) -IF (NOT OS_IOS AND NOT ARCH_PPC64LE) - # Abseil fails to build (with linkage error) on ios and with compilation error on PowerPC - # (somewhere in unscaledcycleclock.cc). - PEERDIR( +IF (NOT OS_IOS AND NOT ARCH_PPC64LE) + # Abseil fails to build (with linkage error) on ios and with compilation error on PowerPC + # (somewhere in unscaledcycleclock.cc). + PEERDIR( library/cpp/containers/absl_flat_hash - ) - - SRCS( - generic/string_transparent_hash_ut.cpp - ) -ENDIF() - + ) + + SRCS( + generic/string_transparent_hash_ut.cpp + ) +ENDIF() + END() diff --git a/util/generic/utility.h b/util/generic/utility.h index 43b98eeafc7..0deda97bb74 100644 --- a/util/generic/utility.h +++ b/util/generic/utility.h @@ -66,8 +66,8 @@ static inline void SecureZero(T& t) noexcept { } namespace NSwapCheck { - Y_HAS_MEMBER(swap); - Y_HAS_MEMBER(Swap); + Y_HAS_MEMBER(swap); + Y_HAS_MEMBER(Swap); template <class T, class = void> struct TSwapSelector { diff --git a/util/generic/va_args.cpp b/util/generic/va_args.cpp index 2266d05a0dd..6b66aec5a4f 100644 --- a/util/generic/va_args.cpp +++ b/util/generic/va_args.cpp @@ -2,14 +2,14 @@ // Test that it compiles #define __DUMMY__(x) -Y_MAP_ARGS(__DUMMY__, 1, 2, 3); +Y_MAP_ARGS(__DUMMY__, 1, 2, 3); #define __DUMMY_LAST__(x) -Y_MAP_ARGS_WITH_LAST(__DUMMY__, __DUMMY_LAST__, 1, 2, 3); +Y_MAP_ARGS_WITH_LAST(__DUMMY__, __DUMMY_LAST__, 1, 2, 3); #undef __DUMMY_LAST__ #undef __DUMMY__ #define __MULTI_DUMMY__(x, y) #define __MULTI_DUMMY_PROXY__(x) __MULTI_DUMMY__ x -Y_MAP_ARGS(__MULTI_DUMMY_PROXY__, (1, 2), (3, 4)); +Y_MAP_ARGS(__MULTI_DUMMY_PROXY__, (1, 2), (3, 4)); #undef __MULTI_DUMMY_PROXY__ #undef __MULTI_DUMMY__ diff --git a/util/generic/va_args.h b/util/generic/va_args.h index 33498d47ed3..90eb5c17ade 100644 --- a/util/generic/va_args.h +++ b/util/generic/va_args.h @@ -16,7 +16,7 @@ * Used merely for working around an MSVC++ bug. * See http://stackoverflow.com/questions/5134523/msvc-doesnt-expand-va-args-correctly */ -#define Y_PASS_VA_ARGS(x) x +#define Y_PASS_VA_ARGS(x) x /** * Count number of arguments in `__VA_ARGS__`. @@ -768,16 +768,16 @@ /** * Macros for implementing overload by number of arguments. - * + * * Example usage: - * + * * @code{cpp} * #define I1(arg1) Cout << Y_STRINGIZE(arg1) << Endl; * #define I2(arg1, arg2) Cout << Y_STRINGIZE(arg1) << ';' << Y_STRINGIZE(arg2) << Endl; - * + * * #define Y_PRINT(...) Y_PASS_VA_ARGS(Y_MACRO_IMPL_DISPATCHER_2(__VA_ARGS__, I2, I1)(__VA_ARGS__)) - * @endcode - */ + * @endcode + */ /// @{ #define Y_MACRO_IMPL_DISPATCHER_2(_0, _1, IMPL, ...) IMPL #define Y_MACRO_IMPL_DISPATCHER_3(_0, _1, _2, IMPL, ...) IMPL diff --git a/util/generic/va_args_gen.py b/util/generic/va_args_gen.py index 232b53fca6d..2dc5346f566 100755 --- a/util/generic/va_args_gen.py +++ b/util/generic/va_args_gen.py @@ -65,7 +65,7 @@ def count(limit): print('#define Y_COUNT_ARGS(...) Y_PASS_VA_ARGS(' '__Y_COUNT_ARGS(__VA_ARGS__, {}))'.format(numbers)) print('#define __Y_COUNT_ARGS({}, N, ...) N'.format(u_numbers)) - + def get_elem(limit): print(textwrap.dedent(''' diff --git a/util/generic/va_args_ut.cpp b/util/generic/va_args_ut.cpp index a9c96a0f55a..b07109095c7 100644 --- a/util/generic/va_args_ut.cpp +++ b/util/generic/va_args_ut.cpp @@ -2,16 +2,16 @@ #include <library/cpp/testing/unittest/registar.h> -Y_UNIT_TEST_SUITE(TMacroVarargMapTest) { - Y_UNIT_TEST(TestMapArgs) { - static const char COMBINED[] = Y_MAP_ARGS(Y_STRINGIZE, 1, 2, 3); +Y_UNIT_TEST_SUITE(TMacroVarargMapTest) { + Y_UNIT_TEST(TestMapArgs) { + static const char COMBINED[] = Y_MAP_ARGS(Y_STRINGIZE, 1, 2, 3); UNIT_ASSERT_STRINGS_EQUAL(COMBINED, "123"); } - Y_UNIT_TEST(TestMapArgsWithLast) { + Y_UNIT_TEST(TestMapArgsWithLast) { #define ADD(x) x + #define ID(x) x - static const int SUM = Y_MAP_ARGS_WITH_LAST(ADD, ID, 1, 2, 3, 4 + 5); + static const int SUM = Y_MAP_ARGS_WITH_LAST(ADD, ID, 1, 2, 3, 4 + 5); UNIT_ASSERT_VALUES_EQUAL(SUM, 1 + 2 + 3 + 4 + 5); #undef ADD #undef ID diff --git a/util/generic/vector_ut.cpp b/util/generic/vector_ut.cpp index 0f6b4037a00..19475a78ef5 100644 --- a/util/generic/vector_ut.cpp +++ b/util/generic/vector_ut.cpp @@ -566,7 +566,7 @@ private: void CheckInitializeList(const TVector<int>& v) { for (size_t i = 0; i < v.size(); ++i) { - UNIT_ASSERT_EQUAL(v[i], static_cast<int>(i)); + UNIT_ASSERT_EQUAL(v[i], static_cast<int>(i)); } } diff --git a/util/generic/xrange.h b/util/generic/xrange.h index 5fc8c829121..6d1b86eb442 100644 --- a/util/generic/xrange.h +++ b/util/generic/xrange.h @@ -24,7 +24,7 @@ namespace NPrivate { using TDiff = decltype(T() - T()); public: - constexpr TSimpleXRange(T start, T finish) noexcept + constexpr TSimpleXRange(T start, T finish) noexcept : Start(start) , Finish(Max(start, finish)) { @@ -38,20 +38,20 @@ namespace NPrivate { using reference = const T&; using iterator_category = std::random_access_iterator_tag; - constexpr TIterator(T value) noexcept + constexpr TIterator(T value) noexcept : Value(value) { } - constexpr T operator*() const noexcept { + constexpr T operator*() const noexcept { return Value; } - constexpr bool operator!=(const TIterator& other) const noexcept { + constexpr bool operator!=(const TIterator& other) const noexcept { return Value != other.Value; } - constexpr bool operator==(const TIterator& other) const noexcept { + constexpr bool operator==(const TIterator& other) const noexcept { return Value == other.Value; } @@ -65,23 +65,23 @@ namespace NPrivate { return *this; } - constexpr TDiff operator-(const TIterator& b) const noexcept { + constexpr TDiff operator-(const TIterator& b) const noexcept { return Value - b.Value; } template <typename IntType> - constexpr TIterator operator+(const IntType& b) const noexcept { + constexpr TIterator operator+(const IntType& b) const noexcept { return TIterator(Value + b); } template <typename IntType> - TIterator& operator+=(const IntType& b) noexcept { + TIterator& operator+=(const IntType& b) noexcept { Value += b; return *this; } template <typename IntType> - constexpr TIterator operator-(const IntType& b) const noexcept { + constexpr TIterator operator-(const IntType& b) const noexcept { return TIterator(Value - b); } @@ -103,15 +103,15 @@ namespace NPrivate { using iterator = TIterator; using const_iterator = TIterator; - constexpr TIterator begin() const noexcept { + constexpr TIterator begin() const noexcept { return TIterator(Start); } - constexpr TIterator end() const noexcept { + constexpr TIterator end() const noexcept { return TIterator(Finish); } - constexpr T size() const noexcept { + constexpr T size() const noexcept { return Finish - Start; } @@ -130,7 +130,7 @@ namespace NPrivate { using TDiff = decltype(T() - T()); public: - constexpr TSteppedXRange(T start, T finish, TDiff step) noexcept + constexpr TSteppedXRange(T start, T finish, TDiff step) noexcept : Start_(start) , Step_(step) , Finish_(CalcRealFinish(Start_, finish, Step_)) @@ -146,21 +146,21 @@ namespace NPrivate { using reference = const T&; using iterator_category = std::random_access_iterator_tag; - constexpr TIterator(T value, const TSteppedXRange& parent) noexcept + constexpr TIterator(T value, const TSteppedXRange& parent) noexcept : Value_(value) , Parent_(&parent) { } - constexpr T operator*() const noexcept { + constexpr T operator*() const noexcept { return Value_; } - constexpr bool operator!=(const TIterator& other) const noexcept { + constexpr bool operator!=(const TIterator& other) const noexcept { return Value_ != other.Value_; } - constexpr bool operator==(const TIterator& other) const noexcept { + constexpr bool operator==(const TIterator& other) const noexcept { return Value_ == other.Value_; } @@ -174,23 +174,23 @@ namespace NPrivate { return *this; } - constexpr TDiff operator-(const TIterator& b) const noexcept { + constexpr TDiff operator-(const TIterator& b) const noexcept { return (Value_ - b.Value_) / Parent_->Step_; } template <typename IntType> - constexpr TIterator operator+(const IntType& b) const noexcept { + constexpr TIterator operator+(const IntType& b) const noexcept { return TIterator(*this) += b; } template <typename IntType> - TIterator& operator+=(const IntType& b) noexcept { + TIterator& operator+=(const IntType& b) noexcept { Value_ += b * Parent_->Step_; return *this; } template <typename IntType> - constexpr TIterator operator-(const IntType& b) const noexcept { + constexpr TIterator operator-(const IntType& b) const noexcept { return TIterator(*this) -= b; } @@ -209,16 +209,16 @@ namespace NPrivate { using iterator = TIterator; using const_iterator = TIterator; - constexpr TIterator begin() const noexcept { + constexpr TIterator begin() const noexcept { return TIterator(Start_, *this); } - constexpr TIterator end() const noexcept { + constexpr TIterator end() const noexcept { return TIterator(Finish_, *this); } static T CalcRealFinish(T start, T expFinish, TDiff step) { - Y_ASSERT(step != 0); + Y_ASSERT(step != 0); if (step > 0) { if (expFinish > start) { return start + step * ((expFinish - 1 - start) / step + 1); @@ -228,7 +228,7 @@ namespace NPrivate { return start - TSteppedXRange<TDiff>::CalcRealFinish(0, start - expFinish, -step); } - constexpr T size() const noexcept { + constexpr T size() const noexcept { return (Finish_ - Start_) / Step_; } @@ -251,18 +251,18 @@ namespace NPrivate { * @param step must be non-zero */ template <typename T> -constexpr ::NPrivate::TSteppedXRange<T> xrange(T start, T finish, decltype(T() - T()) step) noexcept { +constexpr ::NPrivate::TSteppedXRange<T> xrange(T start, T finish, decltype(T() - T()) step) noexcept { return {start, finish, step}; } /// generate sequence [start; finish) template <typename T> -constexpr ::NPrivate::TSimpleXRange<T> xrange(T start, T finish) noexcept { +constexpr ::NPrivate::TSimpleXRange<T> xrange(T start, T finish) noexcept { return {start, finish}; } /// generate sequence [0; finish) template <typename T> -constexpr auto xrange(T finish) noexcept -> decltype(xrange(T(), finish)) { +constexpr auto xrange(T finish) noexcept -> decltype(xrange(T(), finish)) { return xrange(T(), finish); } diff --git a/util/generic/xrange_ut.cpp b/util/generic/xrange_ut.cpp index 8106da03e7f..d0a43637cf3 100644 --- a/util/generic/xrange_ut.cpp +++ b/util/generic/xrange_ut.cpp @@ -6,7 +6,7 @@ #include <library/cpp/testing/unittest/registar.h> #include <util/string/builder.h> -Y_UNIT_TEST_SUITE(XRange) { +Y_UNIT_TEST_SUITE(XRange) { void TestXRangeImpl(size_t begin, size_t end) { size_t count = 0; size_t sum = 0; @@ -40,18 +40,18 @@ Y_UNIT_TEST_SUITE(XRange) { UNIT_ASSERT_VALUES_EQUAL(expInd, expected.size()); } - Y_UNIT_TEST(IncrementWorks) { + Y_UNIT_TEST(IncrementWorks) { TestXRangeImpl(0, 10); TestXRangeImpl(10, 20); } - Y_UNIT_TEST(DecrementWorks) { + Y_UNIT_TEST(DecrementWorks) { TestSteppedXRangeImpl(10, 0, -1, {10, 9, 8, 7, 6, 5, 4, 3, 2, 1}); TestSteppedXRangeImpl(10, -1, -1, {10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0}); TestSteppedXRangeImpl(20, 9, -1, {20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10}); } - Y_UNIT_TEST(StepWorks) { + Y_UNIT_TEST(StepWorks) { TestSteppedXRangeImpl(0, 0, 1, {}); TestSteppedXRangeImpl(0, 9, 3, {0, 3, 6}); TestSteppedXRangeImpl(0, 10, 3, {0, 3, 6, 9}); @@ -64,7 +64,7 @@ Y_UNIT_TEST_SUITE(XRange) { TestSteppedXRangeImpl(15, -2, -4, {15, 11, 7, 3, -1}); } - Y_UNIT_TEST(PointersWorks) { + Y_UNIT_TEST(PointersWorks) { TVector<size_t> data = {3, 1, 4, 1, 5, 9, 2, 6}; const size_t digSumExpected = Accumulate(data.begin(), data.end(), static_cast<size_t>(0)); size_t digSumByIt = 0; @@ -79,7 +79,7 @@ Y_UNIT_TEST_SUITE(XRange) { UNIT_ASSERT_VALUES_EQUAL(digSumByPtr, digSumExpected); } - Y_UNIT_TEST(SizeMethodCheck) { + Y_UNIT_TEST(SizeMethodCheck) { UNIT_ASSERT_VALUES_EQUAL(xrange(5).size(), 5); UNIT_ASSERT_VALUES_EQUAL(xrange(0, 5, 2).size(), 3); UNIT_ASSERT_VALUES_EQUAL(xrange(0, 6, 2).size(), 3); @@ -94,7 +94,7 @@ Y_UNIT_TEST_SUITE(XRange) { } }; - Y_UNIT_TEST(ConvertionWorks) { + Y_UNIT_TEST(ConvertionWorks) { TVector<size_t> data = {0, 1, 2, 3, 4, 5, 6, 7, 8}; TVector<size_t> convertionResults[] = {xrange<size_t>(9), @@ -119,7 +119,7 @@ Y_UNIT_TEST_SUITE(XRange) { UNIT_ASSERT_VALUES_EQUAL(emptyRange.size(), 0); for (auto i : emptyRange) { - Y_UNUSED(i); + Y_UNUSED(i); UNIT_ASSERT(false); } @@ -129,7 +129,7 @@ Y_UNIT_TEST_SUITE(XRange) { } } - Y_UNIT_TEST(EmptySimpleRange) { + Y_UNIT_TEST(EmptySimpleRange) { using TSimpleRange = decltype(xrange(1)); const TSimpleRange emptySimpleRanges[] = { @@ -143,7 +143,7 @@ Y_UNIT_TEST_SUITE(XRange) { TestEmptyRanges(emptySimpleRanges); } - Y_UNIT_TEST(EmptySteppedRange) { + Y_UNIT_TEST(EmptySteppedRange) { using TSteppedRange = decltype(xrange(1, 10, 1)); const TSteppedRange emptySteppedRanges[] = { diff --git a/util/generic/yexception.cpp b/util/generic/yexception.cpp index 2ce6c4369da..630aaa42e23 100644 --- a/util/generic/yexception.cpp +++ b/util/generic/yexception.cpp @@ -75,22 +75,22 @@ void TSystemError::Init() { exc << TStringBuf(") "); } -NPrivateException::yexception::yexception() { - ZeroTerminate(); -} - -TStringBuf NPrivateException::yexception::AsStrBuf() const { - if (Buf_.Left()) { - return TStringBuf(Buf_.Data(), Buf_.Filled()); - } - - return TStringBuf(Buf_.Data(), Buf_.Filled() - 1); -} - -void NPrivateException::yexception::ZeroTerminate() noexcept { - char* end = (char*)Buf_.Current(); - - if (!Buf_.Left()) { +NPrivateException::yexception::yexception() { + ZeroTerminate(); +} + +TStringBuf NPrivateException::yexception::AsStrBuf() const { + if (Buf_.Left()) { + return TStringBuf(Buf_.Data(), Buf_.Filled()); + } + + return TStringBuf(Buf_.Data(), Buf_.Filled() - 1); +} + +void NPrivateException::yexception::ZeroTerminate() noexcept { + char* end = (char*)Buf_.Current(); + + if (!Buf_.Left()) { --end; } @@ -98,11 +98,11 @@ void NPrivateException::yexception::ZeroTerminate() noexcept { } const char* NPrivateException::yexception::what() const noexcept { - return Buf_.Data(); + return Buf_.Data(); } const TBackTrace* NPrivateException::yexception::BackTrace() const noexcept { - return nullptr; + return nullptr; } void fputs(const std::exception& e, FILE* f) { diff --git a/util/generic/yexception.h b/util/generic/yexception.h index b0c604e8c45..49917a342b1 100644 --- a/util/generic/yexception.h +++ b/util/generic/yexception.h @@ -4,13 +4,13 @@ #include "strbuf.h" #include "string.h" #include "utility.h" -#include "va_args.h" +#include "va_args.h" #include <utility> -#include <util/stream/tempbuf.h> -#include <util/system/compat.h> -#include <util/system/compiler.h> -#include <util/system/defaults.h> +#include <util/stream/tempbuf.h> +#include <util/system/compat.h> +#include <util/system/compiler.h> +#include <util/system/defaults.h> #include <util/system/error.h> #include <util/system/src_location.h> #include <util/system/platform.h> @@ -39,30 +39,30 @@ namespace NPrivateException { class yexception: public std::exception { public: - yexception(); - yexception(const yexception&) = default; - yexception(yexception&&) = default; - - yexception& operator=(const yexception&) = default; - yexception& operator=(yexception&&) = default; - + yexception(); + yexception(const yexception&) = default; + yexception(yexception&&) = default; + + yexception& operator=(const yexception&) = default; + yexception& operator=(yexception&&) = default; + const char* what() const noexcept override; virtual const TBackTrace* BackTrace() const noexcept; template <class T> inline void Append(const T& t) { TTempBufCuttingWrapperOutput tempBuf(Buf_); - static_cast<IOutputStream&>(tempBuf) << t; - ZeroTerminate(); + static_cast<IOutputStream&>(tempBuf) << t; + ZeroTerminate(); } - TStringBuf AsStrBuf() const; - - private: - void ZeroTerminate() noexcept; + TStringBuf AsStrBuf() const; private: - TTempBuf Buf_; + void ZeroTerminate() noexcept; + + private: + TTempBuf Buf_; }; template <class E, class T> @@ -82,7 +82,7 @@ namespace NPrivateException { class yexception: public NPrivateException::yexception { }; -Y_DECLARE_OUT_SPEC(inline, yexception, stream, value) { +Y_DECLARE_OUT_SPEC(inline, yexception, stream, value) { stream << value.AsStrBuf(); } @@ -175,13 +175,13 @@ std::string CurrentExceptionTypeName(); TString FormatExc(const std::exception& exception); -#define Y_ENSURE_EX(CONDITION, THROW_EXPRESSION) \ - do { \ - if (Y_UNLIKELY(!(CONDITION))) { \ - ythrow THROW_EXPRESSION; \ - } \ +#define Y_ENSURE_EX(CONDITION, THROW_EXPRESSION) \ + do { \ + if (Y_UNLIKELY(!(CONDITION))) { \ + ythrow THROW_EXPRESSION; \ + } \ } while (false) - + /// @def Y_ENSURE_SIMPLE /// This macro works like the Y_ENSURE, but requires the second argument to be a constant string view. /// Should not be used directly. @@ -195,25 +195,25 @@ TString FormatExc(const std::exception& exception); } while (false) #define Y_ENSURE_IMPL_1(CONDITION) Y_ENSURE_SIMPLE(CONDITION, ::TStringBuf("Condition violated: `" Y_STRINGIZE(CONDITION) "'"), ::NPrivate::ThrowYException) -#define Y_ENSURE_IMPL_2(CONDITION, MESSAGE) Y_ENSURE_EX(CONDITION, yexception() << MESSAGE) - +#define Y_ENSURE_IMPL_2(CONDITION, MESSAGE) Y_ENSURE_EX(CONDITION, yexception() << MESSAGE) + #define Y_ENSURE_BT_IMPL_1(CONDITION) Y_ENSURE_SIMPLE(CONDITION, ::TStringBuf("Condition violated: `" Y_STRINGIZE(CONDITION) "'"), ::NPrivate::ThrowYExceptionWithBacktrace) #define Y_ENSURE_BT_IMPL_2(CONDITION, MESSAGE) Y_ENSURE_EX(CONDITION, TWithBackTrace<yexception>() << MESSAGE) -/** - * @def Y_ENSURE - * - * This macro is inteded to use as a shortcut for `if () { throw }`. - * - * @code - * void DoSomethingLovely(const int x, const int y) { - * Y_ENSURE(x > y, "`x` must be greater than `y`"); - * Y_ENSURE(x > y); // if you are too lazy - * // actually doing something nice here - * } - * @endcode - */ -#define Y_ENSURE(...) Y_PASS_VA_ARGS(Y_MACRO_IMPL_DISPATCHER_2(__VA_ARGS__, Y_ENSURE_IMPL_2, Y_ENSURE_IMPL_1)(__VA_ARGS__)) +/** + * @def Y_ENSURE + * + * This macro is inteded to use as a shortcut for `if () { throw }`. + * + * @code + * void DoSomethingLovely(const int x, const int y) { + * Y_ENSURE(x > y, "`x` must be greater than `y`"); + * Y_ENSURE(x > y); // if you are too lazy + * // actually doing something nice here + * } + * @endcode + */ +#define Y_ENSURE(...) Y_PASS_VA_ARGS(Y_MACRO_IMPL_DISPATCHER_2(__VA_ARGS__, Y_ENSURE_IMPL_2, Y_ENSURE_IMPL_1)(__VA_ARGS__)) /** * @def Y_ENSURE_BT diff --git a/util/generic/yexception_ut.cpp b/util/generic/yexception_ut.cpp index cb3e29fed84..81fb0f19da5 100644 --- a/util/generic/yexception_ut.cpp +++ b/util/generic/yexception_ut.cpp @@ -13,7 +13,7 @@ static inline void Throw2DontMove() { #include <util/generic/algorithm.h> #include <util/memory/tempbuf.h> #include <util/random/mersenne.h> -#include <util/stream/output.h> +#include <util/stream/output.h> #include <util/string/subst.h> #include "yexception_ut.h" @@ -27,7 +27,7 @@ static void CallbackFun(int i) { throw i; } -static IOutputStream* OUTS = nullptr; +static IOutputStream* OUTS = nullptr; namespace NOuter::NInner { void Compare10And20() { @@ -49,7 +49,7 @@ class TExceptionTest: public TTestBase { UNIT_TEST(TestEnsureWithBackTrace1) UNIT_TEST(TestEnsureWithBackTrace2) UNIT_TEST(TestRethrowAppend) - UNIT_TEST(TestMacroOverload) + UNIT_TEST(TestMacroOverload) UNIT_TEST(TestMessageCrop) UNIT_TEST(TestTIoSystemErrorSpecialMethods) UNIT_TEST(TestCurrentExceptionTypeNameMethod) @@ -260,26 +260,26 @@ private: UNIT_ASSERT_VALUES_EQUAL(i, N); } } - - void TestMacroOverload() { - try { - Y_ENSURE(10 > 20); - } catch (const yexception& e) { - UNIT_ASSERT(e.AsStrBuf().Contains("10 > 20")); - } - - try { - Y_ENSURE(10 > 20, "exception message to search for"); - } catch (const yexception& e) { - UNIT_ASSERT(e.AsStrBuf().Contains("exception message to search for")); - } + + void TestMacroOverload() { + try { + Y_ENSURE(10 > 20); + } catch (const yexception& e) { + UNIT_ASSERT(e.AsStrBuf().Contains("10 > 20")); + } + + try { + Y_ENSURE(10 > 20, "exception message to search for"); + } catch (const yexception& e) { + UNIT_ASSERT(e.AsStrBuf().Contains("exception message to search for")); + } try { NOuter::NInner::Compare10And20(); } catch (const yexception& e) { UNIT_ASSERT(e.AsStrBuf().Contains("10 > 20")); } - } + } void TestMessageCrop() { TTempBuf tmp; @@ -293,7 +293,7 @@ private: } yexception e; e << s; - UNIT_ASSERT_EQUAL(e.AsStrBuf(), s.substr(0, tmp.Size() - 1)); + UNIT_ASSERT_EQUAL(e.AsStrBuf(), s.substr(0, tmp.Size() - 1)); } } diff --git a/util/generic/ylimits.h b/util/generic/ylimits.h index fe42b4dfc0e..f6964b8a6a0 100644 --- a/util/generic/ylimits.h +++ b/util/generic/ylimits.h @@ -8,12 +8,12 @@ template <class T> static constexpr T Max() noexcept { - return std::numeric_limits<T>::max(); + return std::numeric_limits<T>::max(); } template <class T> static constexpr T Min() noexcept { - return std::numeric_limits<T>::min(); + return std::numeric_limits<T>::min(); } namespace NPrivate { diff --git a/util/generic/ylimits_ut.cpp b/util/generic/ylimits_ut.cpp index f1b3c6858cf..60dc5c53909 100644 --- a/util/generic/ylimits_ut.cpp +++ b/util/generic/ylimits_ut.cpp @@ -34,7 +34,7 @@ static inline bool ValidSignInfo(bool limitIsSigned, const T&) { template <class T> static inline bool TestIntegralLimits(const T&, bool unknownSign = true, bool isSigned = true) { - using lim = std::numeric_limits<T>; + using lim = std::numeric_limits<T>; CHECK_COND(lim::is_specialized); CHECK_COND(lim::is_integer); @@ -66,7 +66,7 @@ static inline bool TestUnsignedIntegralLimits(const T& val) { template <class T> static inline bool TestFloatLimits(const T&) { - using lim = std::numeric_limits<T>; + using lim = std::numeric_limits<T>; CHECK_COND(lim::is_specialized); CHECK_COND(!lim::is_modulo); @@ -96,7 +96,7 @@ static inline bool TestFloatLimits(const T&) { template <class T> static inline bool TestNan(const T&) { - using lim = std::numeric_limits<T>; + using lim = std::numeric_limits<T>; if (lim::has_quiet_NaN) { const T qnan = lim::quiet_NaN(); diff --git a/util/generic/ymath.cpp b/util/generic/ymath.cpp index 31270728f46..c7dfc0260a5 100644 --- a/util/generic/ymath.cpp +++ b/util/generic/ymath.cpp @@ -11,8 +11,8 @@ float Exp2f(float x) { #ifdef _MSC_VER double Erf(double x) { - static constexpr double _M_2_SQRTPI = 1.12837916709551257390; - static constexpr double eps = 1.0e-7; + static constexpr double _M_2_SQRTPI = 1.12837916709551257390; + static constexpr double eps = 1.0e-7; if (fabs(x) >= 3.75) return x > 0 ? 1.0 : -1.0; double r = _M_2_SQRTPI * x; @@ -29,12 +29,12 @@ double Erf(double x) { #endif // _MSC_VER double LogGammaImpl(double x) { - static constexpr double lnSqrt2Pi = 0.91893853320467274178; // log(sqrt(2.0 * PI)) - static constexpr double coeff9 = 1.0 / 1188.0; - static constexpr double coeff7 = -1.0 / 1680.0; - static constexpr double coeff5 = 1.0 / 1260.0; - static constexpr double coeff3 = -1.0 / 360.0; - static constexpr double coeff1 = 1.0 / 12.0; + static constexpr double lnSqrt2Pi = 0.91893853320467274178; // log(sqrt(2.0 * PI)) + static constexpr double coeff9 = 1.0 / 1188.0; + static constexpr double coeff7 = -1.0 / 1680.0; + static constexpr double coeff5 = 1.0 / 1260.0; + static constexpr double coeff3 = -1.0 / 360.0; + static constexpr double coeff1 = 1.0 / 12.0; if ((x == 1.0) || (x == 2.0)) { return 0.0; // 0! = 1 diff --git a/util/generic/ymath.h b/util/generic/ymath.h index 9ff9ae2abe2..5fe17e26088 100644 --- a/util/generic/ymath.h +++ b/util/generic/ymath.h @@ -10,9 +10,9 @@ #include "typetraits.h" #include "utility.h" -constexpr double PI = M_PI; -constexpr double M_LOG2_10 = 3.32192809488736234787; // log2(10) -constexpr double M_LN2_INV = M_LOG2E; // 1 / ln(2) == log2(e) +constexpr double PI = M_PI; +constexpr double M_LOG2_10 = 3.32192809488736234787; // log2(10) +constexpr double M_LN2_INV = M_LOG2E; // 1 / ln(2) == log2(e) /** * \returns Absolute value of the provided argument. @@ -42,7 +42,7 @@ inline float Log2(float value) { * @returns Base 2 logarithm of the provided integral value. */ template <class T> -inline std::enable_if_t<std::is_integral<T>::value, double> +inline std::enable_if_t<std::is_integral<T>::value, double> Log2(T value) { return Log2(static_cast<double>(value)); } @@ -52,7 +52,7 @@ double Exp2(double); float Exp2f(float); template <class T> -static constexpr T Sqr(const T t) noexcept { +static constexpr T Sqr(const T t) noexcept { return t * t; } diff --git a/util/generic/ymath_ut.cpp b/util/generic/ymath_ut.cpp index 29190b55eb4..cf4f7cd5f79 100644 --- a/util/generic/ymath_ut.cpp +++ b/util/generic/ymath_ut.cpp @@ -3,14 +3,14 @@ #include <library/cpp/testing/unittest/registar.h> -#include <util/stream/output.h> +#include <util/stream/output.h> #include <util/datetime/cputimer.h> #include <limits> template <class T> static inline T SlowClp2(T t) noexcept { - Y_ASSERT(t > 0); + Y_ASSERT(t > 0); T ret = 1; diff --git a/util/memory/blob.cpp b/util/memory/blob.cpp index 91da5cadca3..e9936c2bcbc 100644 --- a/util/memory/blob.cpp +++ b/util/memory/blob.cpp @@ -4,7 +4,7 @@ #include <util/system/yassert.h> #include <util/system/filemap.h> #include <util/system/mlock.h> -#include <util/stream/buffer.h> +#include <util/stream/buffer.h> #include <util/generic/ptr.h> #include <util/generic/string.h> #include <util/generic/buffer.h> @@ -174,7 +174,7 @@ static inline TBlob CopyConstruct(const void* data, size_t len) { using Base = TDynamicBlobBase<TCounter>; THolder<Base> base(new (len) Base); - Y_ASSERT(base->Length() == len); + Y_ASSERT(base->Length() == len); memcpy(base->Data(), data, len); @@ -305,7 +305,7 @@ static inline TBlob ReadFromFile(const TFile& file, ui64 offset, size_t length) using TBase = TDynamicBlobBase<TCounter>; THolder<TBase> base(new (length) TBase); - Y_ASSERT(base->Length() == length); + Y_ASSERT(base->Length() == length); file.Pload(base->Data(), length, offset); @@ -362,7 +362,7 @@ static inline TBlob ConstructFromBuffer(TBuffer& in) { } template <class TCounter> -static inline TBlob ConstructFromStream(IInputStream& in) { +static inline TBlob ConstructFromStream(IInputStream& in) { TBuffer buf; { @@ -374,11 +374,11 @@ static inline TBlob ConstructFromStream(IInputStream& in) { return ConstructFromBuffer<TCounter>(buf); } -TBlob TBlob::FromStreamSingleThreaded(IInputStream& in) { +TBlob TBlob::FromStreamSingleThreaded(IInputStream& in) { return ConstructFromStream<TSimpleCounter>(in); } -TBlob TBlob::FromStream(IInputStream& in) { +TBlob TBlob::FromStream(IInputStream& in) { return ConstructFromStream<TAtomicCounter>(in); } diff --git a/util/memory/blob.h b/util/memory/blob.h index 20c02a68dfb..b5a610bce81 100644 --- a/util/memory/blob.h +++ b/util/memory/blob.h @@ -6,7 +6,7 @@ #include <util/system/defaults.h> class TMemoryMap; -class IInputStream; +class IInputStream; class TFile; class TBuffer; @@ -281,10 +281,10 @@ public: static TBlob FromFileContent(const TFile& file, ui64 offset, size_t length); /// Creates a blob from the stream content with a single-threaded (non atomic) refcounter. - static TBlob FromStreamSingleThreaded(IInputStream& in); + static TBlob FromStreamSingleThreaded(IInputStream& in); /// Creates a blob from the stream content with a multi-threaded (atomic) refcounter. - static TBlob FromStream(IInputStream& in); + static TBlob FromStream(IInputStream& in); /// Creates a blob with a single-threaded (non atomic) refcounter. No memory allocation, no content copy. /// @details The input object becomes empty. diff --git a/util/memory/blob_ut.cpp b/util/memory/blob_ut.cpp index 023f9a04871..d5b14b8672d 100644 --- a/util/memory/blob_ut.cpp +++ b/util/memory/blob_ut.cpp @@ -4,7 +4,7 @@ #include <util/system/tempfile.h> #include <util/folder/path.h> -#include <util/stream/output.h> +#include <util/stream/output.h> #include <util/stream/file.h> #include <util/generic/buffer.h> #include <util/generic/array_ref.h> diff --git a/util/memory/pool.h b/util/memory/pool.h index 13c8b6b9ede..0de54677015 100644 --- a/util/memory/pool.h +++ b/util/memory/pool.h @@ -33,7 +33,7 @@ private: : Cur_((char*)(this + 1)) , Left_(len) { - Y_ASSERT((((size_t)Cur_) % PLATFORM_DATA_ALIGN) == 0); + Y_ASSERT((((size_t)Cur_) % PLATFORM_DATA_ALIGN) == 0); } inline void* Allocate(size_t len) noexcept { @@ -46,7 +46,7 @@ private: return ret; } - return nullptr; + return nullptr; } inline void* Allocate(size_t len, size_t align) noexcept { @@ -57,7 +57,7 @@ private: return static_cast<char*>(ret) + pad; } - return nullptr; + return nullptr; } inline size_t BlockLength() const noexcept { diff --git a/util/memory/pool_ut.cpp b/util/memory/pool_ut.cpp index 1158a8ca423..dd79864f721 100644 --- a/util/memory/pool_ut.cpp +++ b/util/memory/pool_ut.cpp @@ -2,7 +2,7 @@ #include <library/cpp/testing/unittest/registar.h> -#include <util/stream/output.h> +#include <util/stream/output.h> class TCheckedAllocator: public TDefaultAllocator { public: diff --git a/util/memory/segmented_string_pool.h b/util/memory/segmented_string_pool.h index a40aa408f51..ecc3ca3c1a2 100644 --- a/util/memory/segmented_string_pool.h +++ b/util/memory/segmented_string_pool.h @@ -23,7 +23,7 @@ protected: size_t _size; // size of allocated chunk in sizeof(T)-units size_t freepos; // offset to free chunk's memory in bytes seg_inf() - : data(nullptr) + : data(nullptr) , _size(0) , freepos(0) { @@ -46,23 +46,23 @@ protected: const char* Name; // for debug memory usage protected: void check_capacity(size_t len) { - if (Y_UNLIKELY(!last_free || len > last_free)) { + if (Y_UNLIKELY(!last_free || len > last_free)) { if (curseg != segs.end() && curseg->freepos > 0) ++curseg; last_free = (len > segment_size ? len : segment_size); if (curseg == segs.end() || curseg->_size < last_free) { segs.push_back(seg_inf(seg_allocator.allocate(last_free), last_free)); - if (Y_UNLIKELY(Name)) + if (Y_UNLIKELY(Name)) printf("Pool \"%s\" was increased by %" PRISZT " bytes to %" PRISZT " Mb.\n", Name, last_free * sizeof(T), capacity() / 0x100000); curseg = segs.end() - 1; } - Y_ASSERT(curseg->freepos == 0); - Y_ASSERT(curseg->_size >= last_free); + Y_ASSERT(curseg->freepos == 0); + Y_ASSERT(curseg->_size >= last_free); } } public: - explicit segmented_pool(size_t segsz, const char* name = nullptr) + explicit segmented_pool(size_t segsz, const char* name = nullptr) : segment_size(segsz) , last_free(0) , last_ins_size(0) @@ -131,18 +131,18 @@ public: last_ins_size = 0; } void undo_last_append() { - Y_ASSERT(curseg != segs.end()); // do not use before append() + Y_ASSERT(curseg != segs.end()); // do not use before append() if (last_ins_size) { - Y_ASSERT(last_ins_size <= curseg->freepos); + Y_ASSERT(last_ins_size <= curseg->freepos); curseg->freepos -= last_ins_size; last_free += last_ins_size / sizeof(T); last_ins_size = 0; } } void alloc_first_seg() { - Y_ASSERT(capacity() == 0); + Y_ASSERT(capacity() == 0); check_capacity(segment_size); - Y_ASSERT(capacity() == segment_size * sizeof(T)); + Y_ASSERT(capacity() == segment_size * sizeof(T)); } }; @@ -151,27 +151,27 @@ private: using _Base = segmented_pool<char>; public: - segmented_string_pool() - : segmented_string_pool(1024 * 1024) - { - } - - explicit segmented_string_pool(size_t segsz) + segmented_string_pool() + : segmented_string_pool(1024 * 1024) + { + } + + explicit segmented_string_pool(size_t segsz) : _Base(segsz) { } char* append(const char* src) { - Y_ASSERT(src); + Y_ASSERT(src); return _Base::append(src, strlen(src) + 1); } char* append(const char* src, size_t len) { - char* rv = _Base::append(nullptr, len + 1); + char* rv = _Base::append(nullptr, len + 1); if (src) memcpy(rv, src, len); rv[len] = 0; return rv; } - char* Append(const TStringBuf s) { + char* Append(const TStringBuf s) { return append(s.data(), s.size()); } void align_4() { @@ -180,7 +180,7 @@ public: curseg->freepos = t; } char* Allocate(size_t len) { - return append(nullptr, len); + return append(nullptr, len); } }; diff --git a/util/memory/segpool_alloc.h b/util/memory/segpool_alloc.h index 1a83b7a5437..ce23fd63925 100644 --- a/util/memory/segpool_alloc.h +++ b/util/memory/segpool_alloc.h @@ -45,40 +45,40 @@ struct segpool_alloc { segpool_alloc() : pool(nullptr) { - Y_IF_DEBUG(pool_count = malloc_count = pool_free_count = malloc_free_count = 0); + Y_IF_DEBUG(pool_count = malloc_count = pool_free_count = malloc_free_count = 0); } segpool_alloc(pool_type* p) : pool(p) { - Y_IF_DEBUG(pool_count = malloc_count = pool_free_count = malloc_free_count = 0); + Y_IF_DEBUG(pool_count = malloc_count = pool_free_count = malloc_free_count = 0); } segpool_alloc(const segpool_alloc& a) : pool(a.pool) { - Y_IF_DEBUG(pool_count = malloc_count = pool_free_count = malloc_free_count = 0); + Y_IF_DEBUG(pool_count = malloc_count = pool_free_count = malloc_free_count = 0); } template <class _Tp1> segpool_alloc(const segpool_alloc<_Tp1>& a) : pool(a.pool) { - Y_IF_DEBUG(pool_count = malloc_count = pool_free_count = malloc_free_count = 0); + Y_IF_DEBUG(pool_count = malloc_count = pool_free_count = malloc_free_count = 0); } _Tp* allocate(size_t __n) { if (!pool) { _Tp* data = (_Tp*)malloc(__n * sizeof(_Tp)); - Y_IF_DEBUG(if (data) malloc_count++); + Y_IF_DEBUG(if (data) malloc_count++); return data; } _Tp* data = (_Tp*)pool->append(nullptr, __n * sizeof(_Tp)); - Y_IF_DEBUG(pool_count++); + Y_IF_DEBUG(pool_count++); return data; } void deallocate(pointer __p, size_t /*__n*/) { if (!pool) { - Y_IF_DEBUG(malloc_free_count++); + Y_IF_DEBUG(malloc_free_count++); free(__p); } else { - Y_IF_DEBUG(pool_free_count++); + Y_IF_DEBUG(pool_free_count++); ; } } diff --git a/util/memory/smallobj.h b/util/memory/smallobj.h index 63de666bae0..6fbfa836655 100644 --- a/util/memory/smallobj.h +++ b/util/memory/smallobj.h @@ -55,7 +55,7 @@ public: } inline void* Allocate() { - if (Y_UNLIKELY(Free_.Empty())) { + if (Y_UNLIKELY(Free_.Empty())) { return Pool_.Allocate(AllocSize_, AlignSize_); } diff --git a/util/memory/smallobj_ut.cpp b/util/memory/smallobj_ut.cpp index 86003d1d534..8730e97e228 100644 --- a/util/memory/smallobj_ut.cpp +++ b/util/memory/smallobj_ut.cpp @@ -17,7 +17,7 @@ class TSmallObjAllocTest: public TTestBase { } }; - struct TClass64: public TObjectFromPool<TClass64> { + struct TClass64: public TObjectFromPool<TClass64> { alignas(64) ui64 Data = 0; }; @@ -30,10 +30,10 @@ class TSmallObjAllocTest: public TTestBase { private: void TestAlign() { TClass64::TPool pool(TDefaultAllocator::Instance()); - TClass64* f1 = new (&pool) TClass64; - TClass64* f2 = new (&pool) TClass64; - TClass64* f3 = new (&pool) TClass64; - TClass64* f4 = new (&pool) TClass64; + TClass64* f1 = new (&pool) TClass64; + TClass64* f2 = new (&pool) TClass64; + TClass64* f3 = new (&pool) TClass64; + TClass64* f4 = new (&pool) TClass64; UNIT_ASSERT_VALUES_EQUAL(64u, alignof(TClass64)); UNIT_ASSERT_VALUES_EQUAL((size_t)0, (size_t)(f1) & (alignof(TClass64) - 1)); UNIT_ASSERT_VALUES_EQUAL((size_t)0, (size_t)(f2) & (alignof(TClass64) - 1)); @@ -70,8 +70,8 @@ private: alloced.insert(c); } - for (auto it : alloced) { - delete it; + for (auto it : alloced) { + delete it; } for (size_t i = 0; i < 10000; ++i) { diff --git a/util/memory/tempbuf.cpp b/util/memory/tempbuf.cpp index 09a2d0f140b..6e87d94c491 100644 --- a/util/memory/tempbuf.cpp +++ b/util/memory/tempbuf.cpp @@ -54,12 +54,12 @@ public: } void SetPos(size_t off) { - Y_ASSERT(off <= Size()); + Y_ASSERT(off <= Size()); Offset_ = off; } inline void Proceed(size_t off) { - Y_ASSERT(off <= Left()); + Y_ASSERT(off <= Left()); Offset_ += off; } diff --git a/util/memory/tempbuf.h b/util/memory/tempbuf.h index 334670eb1e5..2cc3ebe8676 100644 --- a/util/memory/tempbuf.h +++ b/util/memory/tempbuf.h @@ -59,10 +59,10 @@ private: static const T* TypedPointer(const char* pointer) noexcept { return reinterpret_cast<const T*>(pointer); } - static constexpr size_t RawSize(const size_t size) noexcept { + static constexpr size_t RawSize(const size_t size) noexcept { return size * sizeof(T); } - static constexpr size_t TypedSize(const size_t size) noexcept { + static constexpr size_t TypedSize(const size_t size) noexcept { return size / sizeof(T); } diff --git a/util/network/address.cpp b/util/network/address.cpp index a81a9e69941..906608d30f3 100644 --- a/util/network/address.cpp +++ b/util/network/address.cpp @@ -10,7 +10,7 @@ using namespace NAddr; template <bool printPort> -static inline void PrintAddr(IOutputStream& out, const IRemoteAddr& addr) { +static inline void PrintAddr(IOutputStream& out, const IRemoteAddr& addr) { const sockaddr* a = addr.Addr(); char buf[INET6_ADDRSTRLEN + 10]; @@ -90,7 +90,7 @@ static inline void PrintAddr(IOutputStream& out, const IRemoteAddr& addr) { } template <> -void Out<IRemoteAddr>(IOutputStream& out, const IRemoteAddr& addr) { +void Out<IRemoteAddr>(IOutputStream& out, const IRemoteAddr& addr) { PrintAddr<true>(out, addr); } @@ -114,7 +114,7 @@ void Out<NAddr::TOpaqueAddr>(IOutputStream& out, const NAddr::TOpaqueAddr& addr) PrintAddr<true>(out, addr); } -void NAddr::PrintHost(IOutputStream& out, const IRemoteAddr& addr) { +void NAddr::PrintHost(IOutputStream& out, const IRemoteAddr& addr) { PrintAddr<false>(out, addr); } diff --git a/util/network/address.h b/util/network/address.h index 448fcac0c9d..d9f310ae9d6 100644 --- a/util/network/address.h +++ b/util/network/address.h @@ -20,7 +20,7 @@ namespace NAddr { IRemoteAddrPtr GetSockAddr(SOCKET s); IRemoteAddrPtr GetPeerAddr(SOCKET s); - void PrintHost(IOutputStream& out, const IRemoteAddr& addr); + void PrintHost(IOutputStream& out, const IRemoteAddr& addr); TString PrintHost(const IRemoteAddr& addr); TString PrintHostAndPort(const IRemoteAddr& addr); diff --git a/util/network/address_ut.cpp b/util/network/address_ut.cpp index 28f45172ffe..98f75d95f47 100644 --- a/util/network/address_ut.cpp +++ b/util/network/address_ut.cpp @@ -4,8 +4,8 @@ using namespace NAddr; -Y_UNIT_TEST_SUITE(IRemoteAddr_ToString) { - Y_UNIT_TEST(Raw) { +Y_UNIT_TEST_SUITE(IRemoteAddr_ToString) { + Y_UNIT_TEST(Raw) { THolder<TOpaqueAddr> opaque(new TOpaqueAddr); IRemoteAddr* addr = opaque.Get(); @@ -16,11 +16,11 @@ Y_UNIT_TEST_SUITE(IRemoteAddr_ToString) { TString t = ToString(*addr); - UNIT_ASSERT_C(t.StartsWith("(raw 0 0"), t); - UNIT_ASSERT_C(t.EndsWith(')'), t); + UNIT_ASSERT_C(t.StartsWith("(raw 0 0"), t); + UNIT_ASSERT_C(t.EndsWith(')'), t); } - Y_UNIT_TEST(Ipv6) { + Y_UNIT_TEST(Ipv6) { TNetworkAddress address("::1", 22); TNetworkAddress::TIterator it = address.Begin(); UNIT_ASSERT(it != address.End()); diff --git a/util/network/endpoint_ut.cpp b/util/network/endpoint_ut.cpp index d5e40dd6e1c..f8120658050 100644 --- a/util/network/endpoint_ut.cpp +++ b/util/network/endpoint_ut.cpp @@ -5,8 +5,8 @@ #include <util/generic/hash_set.h> #include <util/generic/strbuf.h> -Y_UNIT_TEST_SUITE(TEndpointTest) { - Y_UNIT_TEST(TestSimple) { +Y_UNIT_TEST_SUITE(TEndpointTest) { + Y_UNIT_TEST(TestSimple) { TVector<TNetworkAddress> addrs; TEndpoint ep0; @@ -86,7 +86,7 @@ Y_UNIT_TEST_SUITE(TEndpointTest) { UNIT_ASSERT_VALUES_EQUAL(5u, he.size()); } - Y_UNIT_TEST(TestEqual) { + Y_UNIT_TEST(TestEqual) { const TString ip1 = "2a02:6b8:0:1410::5f6c:f3c2"; const TString ip2 = "2a02:6b8:0:1410::5f6c:f3c3"; diff --git a/util/network/hostip.cpp b/util/network/hostip.cpp index cb8d43bf903..62085e7c5b9 100644 --- a/util/network/hostip.cpp +++ b/util/network/hostip.cpp @@ -28,8 +28,8 @@ int NResolver::GetHostIP(const char* hostname, ui32* ip, size_t* slots) { memset(&hints, 0, sizeof(hints)); hints.ai_family = AF_INET; hints.ai_socktype = SOCK_STREAM; - struct addrinfo* gai_res = nullptr; - int gai_ret = getaddrinfo(hostname, nullptr, &hints, &gai_res); + struct addrinfo* gai_res = nullptr; + int gai_ret = getaddrinfo(hostname, nullptr, &hints, &gai_res); if (gai_ret == 0 && gai_res->ai_addr) { struct addrinfo* cur = gai_res; for (i = 0; i < *slots && cur; i++, cur = cur->ai_next, ipsFound++) { diff --git a/util/network/init.cpp b/util/network/init.cpp index 366e65682c3..26561c173a9 100644 --- a/util/network/init.cpp +++ b/util/network/init.cpp @@ -8,26 +8,26 @@ #include <cstdio> #include <cstdlib> -namespace { - class TNetworkInit { - public: - inline TNetworkInit() { +namespace { + class TNetworkInit { + public: + inline TNetworkInit() { #ifndef ROBOT_SIGPIPE - signal(SIGPIPE, SIG_IGN); + signal(SIGPIPE, SIG_IGN); #endif #if defined(_win_) #pragma comment(lib, "ws2_32.lib") - WSADATA wsaData; - int result = WSAStartup(MAKEWORD(2, 2), &wsaData); - Y_ASSERT(!result); - if (result) { - exit(-1); - } -#endif + WSADATA wsaData; + int result = WSAStartup(MAKEWORD(2, 2), &wsaData); + Y_ASSERT(!result); + if (result) { + exit(-1); + } +#endif } - }; -} + }; +} void InitNetworkSubSystem() { (void)Singleton<TNetworkInit>(); diff --git a/util/network/init.h b/util/network/init.h index 08a79c0fcaa..33a3e7f435c 100644 --- a/util/network/init.h +++ b/util/network/init.h @@ -49,7 +49,7 @@ struct sockaddr_un { #ifndef MSG_NOSIGNAL #define MSG_NOSIGNAL 0 #endif -#endif // _win_ or _darwin_ +#endif // _win_ or _darwin_ void InitNetworkSubSystem(); diff --git a/util/network/interface.cpp b/util/network/interface.cpp index 256776c6d3f..1ad5f211912 100644 --- a/util/network/interface.cpp +++ b/util/network/interface.cpp @@ -11,7 +11,7 @@ namespace NAddr { static bool IsInetAddress(sockaddr* addr) { - return (addr != nullptr) && ((addr->sa_family == AF_INET) || (addr->sa_family == AF_INET6)); + return (addr != nullptr) && ((addr->sa_family == AF_INET) || (addr->sa_family == AF_INET6)); } TNetworkInterfaceList GetNetworkInterfaces() { @@ -23,7 +23,7 @@ namespace NAddr { PIP_ADAPTER_ADDRESSES adapterBuf = (PIP_ADAPTER_ADDRESSES)&buf[0]; ULONG bufSize = buf.ysize(); - if (GetAdaptersAddresses(AF_UNSPEC, 0, nullptr, adapterBuf, &bufSize) == ERROR_SUCCESS) { + if (GetAdaptersAddresses(AF_UNSPEC, 0, nullptr, adapterBuf, &bufSize) == ERROR_SUCCESS) { for (PIP_ADAPTER_ADDRESSES ptr = adapterBuf; ptr != 0; ptr = ptr->Next) { // The check below makes code working on Vista+ if ((ptr->Flags & (IP_ADAPTER_IPV4_ENABLED | IP_ADAPTER_IPV6_ENABLED)) == 0) { @@ -59,7 +59,7 @@ namespace NAddr { #else ifaddrs* ifap; if (getifaddrs(&ifap) != -1) { - for (ifaddrs* ifa = ifap; ifa != nullptr; ifa = ifa->ifa_next) { + for (ifaddrs* ifa = ifap; ifa != nullptr; ifa = ifa->ifa_next) { if (IsInetAddress(ifa->ifa_addr)) { TNetworkInterface interface; interface.Name = ifa->ifa_name; diff --git a/util/network/iovec.h b/util/network/iovec.h index ac15a41f545..cabc4534924 100644 --- a/util/network/iovec.h +++ b/util/network/iovec.h @@ -5,7 +5,7 @@ #include <util/system/yassert.h> class TContIOVector { - using TPart = IOutputStream::TPart; + using TPart = IOutputStream::TPart; public: inline TContIOVector(TPart* parts, size_t count) diff --git a/util/network/ip_ut.cpp b/util/network/ip_ut.cpp index 6716c6a6999..71fbba21f3e 100644 --- a/util/network/ip_ut.cpp +++ b/util/network/ip_ut.cpp @@ -29,7 +29,7 @@ void TSysIpTest::TestIpFromString() { const char* ipStr[] = {"192.168.0.1", "87.255.18.167", "255.255.0.31", "188.225.124.255"}; ui8 ipArr[][4] = {{192, 168, 0, 1}, {87, 255, 18, 167}, {255, 255, 0, 31}, {188, 225, 124, 255}}; - for (size_t i = 0; i < Y_ARRAY_SIZE(ipStr); ++i) { + for (size_t i = 0; i < Y_ARRAY_SIZE(ipStr); ++i) { const ui32 ip = IpFromString(ipStr[i]); UNIT_ASSERT(memcmp(&ip, ipArr[i], sizeof(ui32)) == 0); @@ -57,7 +57,7 @@ void TSysIpTest::TestIpToString() { const char* ipStr[] = {"192.168.0.1", "87.255.18.167", "255.255.0.31", "188.225.124.255"}; - for (size_t i = 0; i < Y_ARRAY_SIZE(ipStr); ++i) { + for (size_t i = 0; i < Y_ARRAY_SIZE(ipStr); ++i) { UNIT_ASSERT(IpToString(*reinterpret_cast<TIpHost*>(&(ipArr[i]))) == ipStr[i]); } } diff --git a/util/network/nonblock.cpp b/util/network/nonblock.cpp index e515c27cc51..dcc7360e622 100644 --- a/util/network/nonblock.cpp +++ b/util/network/nonblock.cpp @@ -17,7 +17,7 @@ namespace { struct TFeatureCheck { inline TFeatureCheck() - : Accept4(nullptr) + : Accept4(nullptr) , HaveSockNonBlock(false) { #if defined(_unix_) && defined(SOCK_NONBLOCK) @@ -32,10 +32,10 @@ namespace { #endif if (Accept4) { - Accept4(-1, nullptr, nullptr, SOCK_NONBLOCK); + Accept4(-1, nullptr, nullptr, SOCK_NONBLOCK); if (errno == ENOSYS) { - Accept4 = nullptr; + Accept4 = nullptr; } } } diff --git a/util/network/pair.cpp b/util/network/pair.cpp index 9751ef5c966..384fd03620b 100644 --- a/util/network/pair.cpp +++ b/util/network/pair.cpp @@ -50,13 +50,13 @@ int SocketPair(SOCKET socks[2], bool overlapped, bool cloexec) { if (listen(listener, 1) == SOCKET_ERROR) break; - if ((socks[0] = WSASocket(AF_INET, SOCK_STREAM, 0, nullptr, 0, flags)) == INVALID_SOCKET) + if ((socks[0] = WSASocket(AF_INET, SOCK_STREAM, 0, nullptr, 0, flags)) == INVALID_SOCKET) break; if (connect(socks[0], (const struct sockaddr*)&addr, sizeof(addr)) == SOCKET_ERROR) break; - if ((socks[1] = accept(listener, nullptr, nullptr)) == INVALID_SOCKET) + if ((socks[1] = accept(listener, nullptr, nullptr)) == INVALID_SOCKET) break; closesocket(listener); diff --git a/util/network/poller.h b/util/network/poller.h index 8dccd731407..8ae414d4f33 100644 --- a/util/network/poller.h +++ b/util/network/poller.h @@ -41,7 +41,7 @@ public: return ret; } - return nullptr; + return nullptr; } inline void* WaitT(const TDuration& timeOut) { diff --git a/util/network/poller_ut.cpp b/util/network/poller_ut.cpp index 6df0dda8ec5..0e19bff4c13 100644 --- a/util/network/poller_ut.cpp +++ b/util/network/poller_ut.cpp @@ -1,12 +1,12 @@ #include <library/cpp/testing/unittest/registar.h> #include <util/system/error.h> -#include "pair.h" +#include "pair.h" #include "poller.h" #include "pollerimpl.h" -Y_UNIT_TEST_SUITE(TSocketPollerTest) { - Y_UNIT_TEST(TestSimple) { +Y_UNIT_TEST_SUITE(TSocketPollerTest) { + Y_UNIT_TEST(TestSimple) { SOCKET sockets[2]; UNIT_ASSERT(SocketPair(sockets) == 0); @@ -16,8 +16,8 @@ Y_UNIT_TEST_SUITE(TSocketPollerTest) { TSocketPoller poller; poller.WaitRead(sockets[1], (void*)17); - UNIT_ASSERT_VALUES_EQUAL(nullptr, poller.WaitT(TDuration::Zero())); - UNIT_ASSERT_VALUES_EQUAL(nullptr, poller.WaitT(TDuration::Zero())); + UNIT_ASSERT_VALUES_EQUAL(nullptr, poller.WaitT(TDuration::Zero())); + UNIT_ASSERT_VALUES_EQUAL(nullptr, poller.WaitT(TDuration::Zero())); for (ui32 i = 0; i < 3; ++i) { char buf[] = {18}; @@ -28,12 +28,12 @@ Y_UNIT_TEST_SUITE(TSocketPollerTest) { UNIT_ASSERT_VALUES_EQUAL(1, recv(sockets[1], buf, 1, 0)); UNIT_ASSERT_VALUES_EQUAL(18, buf[0]); - UNIT_ASSERT_VALUES_EQUAL(nullptr, poller.WaitT(TDuration::Zero())); - UNIT_ASSERT_VALUES_EQUAL(nullptr, poller.WaitT(TDuration::Zero())); + UNIT_ASSERT_VALUES_EQUAL(nullptr, poller.WaitT(TDuration::Zero())); + UNIT_ASSERT_VALUES_EQUAL(nullptr, poller.WaitT(TDuration::Zero())); } } - Y_UNIT_TEST(TestSimpleOneShot) { + Y_UNIT_TEST(TestSimpleOneShot) { SOCKET sockets[2]; UNIT_ASSERT(SocketPair(sockets) == 0); @@ -42,8 +42,8 @@ Y_UNIT_TEST_SUITE(TSocketPollerTest) { TSocketPoller poller; - UNIT_ASSERT_VALUES_EQUAL(nullptr, poller.WaitT(TDuration::Zero())); - UNIT_ASSERT_VALUES_EQUAL(nullptr, poller.WaitT(TDuration::Zero())); + UNIT_ASSERT_VALUES_EQUAL(nullptr, poller.WaitT(TDuration::Zero())); + UNIT_ASSERT_VALUES_EQUAL(nullptr, poller.WaitT(TDuration::Zero())); for (ui32 i = 0; i < 3; ++i) { poller.WaitReadOneShot(sockets[1], (void*)17); @@ -59,23 +59,23 @@ Y_UNIT_TEST_SUITE(TSocketPollerTest) { UNIT_ASSERT_VALUES_EQUAL(1, recv(sockets[1], buf, 1, 0)); UNIT_ASSERT_VALUES_EQUAL(char(i + 20), buf[0]); - UNIT_ASSERT_VALUES_EQUAL(nullptr, poller.WaitT(TDuration::Zero())); - UNIT_ASSERT_VALUES_EQUAL(nullptr, poller.WaitT(TDuration::Zero())); + UNIT_ASSERT_VALUES_EQUAL(nullptr, poller.WaitT(TDuration::Zero())); + UNIT_ASSERT_VALUES_EQUAL(nullptr, poller.WaitT(TDuration::Zero())); buf[0] = i + 21; UNIT_ASSERT_VALUES_EQUAL(1, send(sockets[0], buf, 1, 0)); // this fails if socket is not oneshot - UNIT_ASSERT_VALUES_EQUAL(nullptr, poller.WaitT(TDuration::Zero())); - UNIT_ASSERT_VALUES_EQUAL(nullptr, poller.WaitT(TDuration::Zero())); + UNIT_ASSERT_VALUES_EQUAL(nullptr, poller.WaitT(TDuration::Zero())); + UNIT_ASSERT_VALUES_EQUAL(nullptr, poller.WaitT(TDuration::Zero())); UNIT_ASSERT_VALUES_EQUAL(1, recv(sockets[1], buf, 1, 0)); UNIT_ASSERT_VALUES_EQUAL(char(i + 21), buf[0]); } } - Y_UNIT_TEST(TestItIsSafeToUnregisterUnregisteredDescriptor) { + Y_UNIT_TEST(TestItIsSafeToUnregisterUnregisteredDescriptor) { SOCKET sockets[2]; UNIT_ASSERT(SocketPair(sockets) == 0); @@ -87,7 +87,7 @@ Y_UNIT_TEST_SUITE(TSocketPollerTest) { poller.Unwait(s1); } - Y_UNIT_TEST(TestItIsSafeToReregisterDescriptor) { + Y_UNIT_TEST(TestItIsSafeToReregisterDescriptor) { SOCKET sockets[2]; UNIT_ASSERT(SocketPair(sockets) == 0); @@ -96,9 +96,9 @@ Y_UNIT_TEST_SUITE(TSocketPollerTest) { TSocketPoller poller; - poller.WaitRead(s1, nullptr); - poller.WaitRead(s1, nullptr); - poller.WaitWrite(s1, nullptr); + poller.WaitRead(s1, nullptr); + poller.WaitRead(s1, nullptr); + poller.WaitWrite(s1, nullptr); } Y_UNIT_TEST(TestSimpleEdgeTriggered) { diff --git a/util/network/pollerimpl.h b/util/network/pollerimpl.h index e8c7e40fbaf..103df45afe5 100644 --- a/util/network/pollerimpl.h +++ b/util/network/pollerimpl.h @@ -126,7 +126,7 @@ public: EV_SET(e + 0, fd, EVFILT_READ, flags | ((what & CONT_POLL_READ) ? EV_ENABLE : EV_DISABLE), 0, 0, data); EV_SET(e + 1, fd, EVFILT_WRITE, flags | ((what & CONT_POLL_WRITE) ? EV_ENABLE : EV_DISABLE), 0, 0, data); - if (Kevent(Fd_, e, 2, nullptr, 0, nullptr) == -1) { + if (Kevent(Fd_, e, 2, nullptr, 0, nullptr) == -1) { ythrow TSystemError() << "kevent add failed"; } } @@ -139,7 +139,7 @@ public: EV_SET(e + 0, fd, EVFILT_READ, EV_DELETE, 0, 0, 0); EV_SET(e + 1, fd, EVFILT_WRITE, EV_DELETE, 0, 0, 0); - Y_VERIFY(!(Kevent(Fd_, e, 2, nullptr, 0, nullptr) == -1 && errno != ENOENT), "kevent remove failed: %s", LastSystemErrorText()); + Y_VERIFY(!(Kevent(Fd_, e, 2, nullptr, 0, nullptr) == -1 && errno != ENOENT), "kevent remove failed: %s", LastSystemErrorText()); } inline size_t Wait(TEvent* events, size_t len, int timeout) noexcept { @@ -148,9 +148,9 @@ public: ts.tv_sec = timeout / 1000000; ts.tv_nsec = (timeout % 1000000) * 1000; - const int ret = Kevent(Fd_, nullptr, 0, events, len, &ts); + const int ret = Kevent(Fd_, nullptr, 0, events, len, &ts); - Y_VERIFY(ret >= 0, "kevent failed: %s", LastSystemErrorText()); + Y_VERIFY(ret >= 0, "kevent failed: %s", LastSystemErrorText()); return (size_t)ret; } @@ -269,7 +269,7 @@ public: inline size_t Wait(TEvent* events, size_t len, int timeout) noexcept { const int ret = ContEpollWait(Fd_, events, len, MicroToMilli(timeout)); - Y_VERIFY(ret >= 0, "epoll wait error: %s", LastSystemErrorText()); + Y_VERIFY(ret >= 0, "epoll wait error: %s", LastSystemErrorText()); return (size_t)ret; } @@ -331,7 +331,7 @@ struct TSelectPollerNoTemplate { int Filter_; inline THandle() - : Data_(nullptr) + : Data_(nullptr) , Filter_(0) { } @@ -367,9 +367,9 @@ struct TSelectPollerNoTemplate { inline SOCKET Build(fd_set* r, fd_set* w, fd_set* e) const noexcept { SOCKET ret = 0; - for (const auto& it : *this) { - const SOCKET fd = it.first; - const THandle& handle = it.second; + for (const auto& it : *this) { + const SOCKET fd = it.first; + const THandle& handle = it.second; FD_SET(fd, e); @@ -411,8 +411,8 @@ class TSelectPoller: public TSelectPollerNoTemplate { public: inline TSelectPoller() - : Begin_(nullptr) - , End_(nullptr) + : Begin_(nullptr) + , End_(nullptr) { SocketPair(Signal_); SetNonBlock(WaitSock()); @@ -519,7 +519,7 @@ public: TryWait(); } - Y_VERIFY(ret >= 0 && (size_t)ret <= len, "select error: %s", LastSystemErrorText()); + Y_VERIFY(ret >= 0 && (size_t)ret <= len, "select error: %s", LastSystemErrorText()); TEvent* eventsStart = events; @@ -598,7 +598,7 @@ private: char ch[32]; while (recv(WaitSock(), ch, sizeof(ch), 0) > 0) { - Y_ASSERT(ch[0] == 13); + Y_ASSERT(ch[0] == 13); } } diff --git a/util/network/sock.h b/util/network/sock.h index b10be2f7156..ea558f22e1e 100644 --- a/util/network/sock.h +++ b/util/network/sock.h @@ -3,7 +3,7 @@ #include <util/folder/path.h> #include <util/system/defaults.h> #include <util/string/cast.h> -#include <util/stream/output.h> +#include <util/stream/output.h> #include <util/system/sysstat.h> #if defined(_win_) || defined(_cygwin_) @@ -17,11 +17,11 @@ #include "ip.h" #include "socket.h" -constexpr ui16 DEF_LOCAL_SOCK_MODE = 00644; +constexpr ui16 DEF_LOCAL_SOCK_MODE = 00644; // Base abstract class for socket address -struct ISockAddr { - virtual ~ISockAddr() = default; +struct ISockAddr { + virtual ~ISockAddr() = default; // Max size of the address that we can store (arg of recvfrom) virtual socklen_t Size() const = 0; // Real length of the address (arg of sendto) @@ -47,7 +47,7 @@ protected: #if defined(_win_) || defined(_cygwin_) #define YAF_LOCAL AF_INET -struct TSockAddrLocal: public ISockAddr { +struct TSockAddrLocal: public ISockAddr { TSockAddrLocal() { Clear(); } @@ -111,7 +111,7 @@ struct TSockAddrLocal: public ISockAddr { } int Bind(SOCKET s, ui16 mode) const { - Y_UNUSED(mode); + Y_UNUSED(mode); int ret = 0; // 1. open file TFileHandle f(Path, CreateAlways | WrOnly); @@ -137,13 +137,13 @@ struct TSockAddrLocal: public ISockAddr { return 0; } - static constexpr size_t PathSize = 128; + static constexpr size_t PathSize = 128; mutable struct sockaddr_in in; char Path[PathSize]; }; #else #define YAF_LOCAL AF_LOCAL -struct TSockAddrLocal: public sockaddr_un, public ISockAddr { +struct TSockAddrLocal: public sockaddr_un, public ISockAddr { TSockAddrLocal() { Clear(); } @@ -201,7 +201,7 @@ struct TSockAddrLocal: public sockaddr_un, public ISockAddr { }; #endif // _win_ -struct TSockAddrInet: public sockaddr_in, public ISockAddr { +struct TSockAddrInet: public sockaddr_in, public ISockAddr { TSockAddrInet() { Clear(); } @@ -246,7 +246,7 @@ struct TSockAddrInet: public sockaddr_in, public ISockAddr { } int Bind(SOCKET s, ui16 mode) const override { - Y_UNUSED(mode); + Y_UNUSED(mode); int ret = bind(s, SockAddr(), Len()); if (ret < 0) return -errno; @@ -271,7 +271,7 @@ struct TSockAddrInet: public sockaddr_in, public ISockAddr { } }; -struct TSockAddrInet6: public sockaddr_in6, public ISockAddr { +struct TSockAddrInet6: public sockaddr_in6, public ISockAddr { TSockAddrInet6() { Clear(); } @@ -312,7 +312,7 @@ struct TSockAddrInet6: public sockaddr_in6, public ISockAddr { } int Bind(SOCKET s, ui16 mode) const override { - Y_UNUSED(mode); + Y_UNUSED(mode); int ret = bind(s, SockAddr(), Len()); if (ret < 0) { return -errno; @@ -354,7 +354,7 @@ protected: } public: - int Bind(const ISockAddr* addr, ui16 mode = DEF_LOCAL_SOCK_MODE) { + int Bind(const ISockAddr* addr, ui16 mode = DEF_LOCAL_SOCK_MODE) { return addr->Bind((SOCKET) * this, mode); } @@ -378,7 +378,7 @@ protected: } public: - ssize_t SendTo(const void* msg, size_t len, const ISockAddr* toAddr) { + ssize_t SendTo(const void* msg, size_t len, const ISockAddr* toAddr) { ssize_t ret = toAddr->ResolveAddr(); if (ret < 0) { return -LastSystemError(); @@ -392,7 +392,7 @@ public: return ret; } - ssize_t RecvFrom(void* buf, size_t len, ISockAddr* fromAddr) { + ssize_t RecvFrom(void* buf, size_t len, ISockAddr* fromAddr) { socklen_t fromSize = fromAddr->Size(); const ssize_t ret = recvfrom((SOCKET) * this, (char*)buf, (int)len, 0, fromAddr->SockAddr(), &fromSize); if (ret < 0) { @@ -432,7 +432,7 @@ public: return ret; } - int Connect(const ISockAddr* addr) { + int Connect(const ISockAddr* addr) { int ret = addr->ResolveAddr(); if (ret < 0) return -errno; @@ -548,7 +548,7 @@ public: } }; -class TStreamSocketInput: public IInputStream { +class TStreamSocketInput: public IInputStream { public: TStreamSocketInput(TStreamSocket* socket) : Socket(socket) @@ -562,7 +562,7 @@ protected: TStreamSocket* Socket; size_t DoRead(void* buf, size_t len) override { - Y_VERIFY(Socket, "TStreamSocketInput: socket isn't set"); + Y_VERIFY(Socket, "TStreamSocketInput: socket isn't set"); const ssize_t ret = Socket->Recv(buf, len); if (ret >= 0) { @@ -573,7 +573,7 @@ protected: } }; -class TStreamSocketOutput: public IOutputStream { +class TStreamSocketOutput: public IOutputStream { public: TStreamSocketOutput(TStreamSocket* socket) : Socket(socket) @@ -590,7 +590,7 @@ protected: TStreamSocket* Socket; void DoWrite(const void* buf, size_t len) override { - Y_VERIFY(Socket, "TStreamSocketOutput: socket isn't set"); + Y_VERIFY(Socket, "TStreamSocketOutput: socket isn't set"); const char* ptr = (const char*)buf; while (len) { @@ -600,7 +600,7 @@ protected: ythrow TSystemError(-(int)ret) << "can not write to socket output stream"; } - Y_ASSERT((size_t)ret <= len); + Y_ASSERT((size_t)ret <= len); len -= (size_t)ret; ptr += (size_t)ret; } diff --git a/util/network/sock_ut.cpp b/util/network/sock_ut.cpp index fd8c7837478..3ba7eafc75a 100644 --- a/util/network/sock_ut.cpp +++ b/util/network/sock_ut.cpp @@ -5,8 +5,8 @@ #include <util/system/fs.h> -Y_UNIT_TEST_SUITE(TSocketTest) { - Y_UNIT_TEST(InetDgramTest) { +Y_UNIT_TEST_SUITE(TSocketTest) { + Y_UNIT_TEST(InetDgramTest) { char buf[256]; TSockAddrInetDgram servAddr(IpFromString("127.0.0.1"), 0); TSockAddrInetDgram cliAddr(IpFromString("127.0.0.1"), 0); @@ -64,7 +64,7 @@ Y_UNIT_TEST_SUITE(TSocketTest) { UNIT_ASSERT(strcmp(repStr, buf) == 0); } - Y_UNIT_TEST(LocalDgramTest) { + Y_UNIT_TEST(LocalDgramTest) { const char* localServerSockName = "./serv_sock"; const char* localClientSockName = "./cli_sock"; RunLocalDgramTest(localServerSockName, localClientSockName); @@ -111,11 +111,11 @@ Y_UNIT_TEST_SUITE(TSocketTest) { UNIT_ASSERT(strcmp(repStr, buf) == 0); } - Y_UNIT_TEST(InetStreamTest) { + Y_UNIT_TEST(InetStreamTest) { RunInetStreamTest<TSockAddrInetStream, TInetStreamSocket>("127.0.0.1"); } - Y_UNIT_TEST(Inet6StreamTest) { + Y_UNIT_TEST(Inet6StreamTest) { RunInetStreamTest<TSockAddrInet6Stream, TInet6StreamSocket>("::1"); } @@ -159,7 +159,7 @@ Y_UNIT_TEST_SUITE(TSocketTest) { UNIT_ASSERT(strcmp(repStr, buf) == 0); } - Y_UNIT_TEST(LocalStreamTest) { + Y_UNIT_TEST(LocalStreamTest) { const char* localServerSockName = "./serv_sock2"; RunLocalStreamTest(localServerSockName); NFs::Remove(localServerSockName); diff --git a/util/network/socket.cpp b/util/network/socket.cpp index 4f6e8043462..0d44f7bac78 100644 --- a/util/network/socket.cpp +++ b/util/network/socket.cpp @@ -36,7 +36,7 @@ #include <util/generic/ylimits.h> #include <util/string/cast.h> -#include <util/stream/mem.h> +#include <util/stream/mem.h> #include <util/system/datetime.h> #include <util/system/error.h> #include <util/memory/tempbuf.h> @@ -54,7 +54,7 @@ int inet_aton(const char* cp, struct in_addr* inp) { sockaddr_in addr; addr.sin_family = AF_INET; int psz = sizeof(addr); - if (0 == WSAStringToAddress((char*)cp, AF_INET, nullptr, (LPSOCKADDR)&addr, &psz)) { + if (0 == WSAStringToAddress((char*)cp, AF_INET, nullptr, (LPSOCKADDR)&addr, &psz)) { memcpy(inp, &addr.sin_addr, sizeof(in_addr)); return 1; } @@ -180,7 +180,7 @@ int poll(struct pollfd fds[], nfds_t nfds, int timeout) noexcept { if (fd->events & POLLOUT) { FD_SET(fd->fd, &writefds); } - int error = select(0, &readfds, &writefds, nullptr, &timeout); + int error = select(0, &readfds, &writefds, nullptr, &timeout); if (error > 0) { if (FD_ISSET(fd->fd, &readfds)) { fd->revents |= POLLIN; @@ -315,8 +315,8 @@ void SetReusePort(SOCKET s, bool value) { #if defined(SO_REUSEPORT) CheckedSetSockOpt(s, SOL_SOCKET, SO_REUSEPORT, (int)value, "reuse port"); #else - Y_UNUSED(s); - Y_UNUSED(value); + Y_UNUSED(s); + Y_UNUSED(value); ythrow TSystemError(ENOSYS) << "SO_REUSEPORT is not defined"; #endif } @@ -340,8 +340,8 @@ void SetCloseOnExec(SOCKET s, bool value) { ythrow TSystemError() << "fcntl() failed"; } #else - Y_UNUSED(s); - Y_UNUSED(value); + Y_UNUSED(s); + Y_UNUSED(value); #endif } @@ -485,8 +485,8 @@ void SetTcpFastOpen(SOCKET s, int qlen) { #if defined(TCP_FASTOPEN) TTcpFastOpenFeature::Instance()->SetFastOpen(s, qlen); #else - Y_UNUSED(s); - Y_UNUSED(qlen); + Y_UNUSED(s); + Y_UNUSED(qlen); #endif } @@ -561,9 +561,9 @@ void TSocketHolder::Close() noexcept { // because often it means double close // that is disasterous #ifdef _win_ - Y_VERIFY(WSAGetLastError() != WSAENOTSOCK, "must not quietly close bad socket descriptor"); + Y_VERIFY(WSAGetLastError() != WSAENOTSOCK, "must not quietly close bad socket descriptor"); #elif defined(_unix_) - Y_VERIFY(errno != EBADF, "must not quietly close bad descriptor: fd=%d", int(Fd_)); + Y_VERIFY(errno != EBADF, "must not quietly close bad descriptor: fd=%d", int(Fd_)); #else #error unsupported platform #endif @@ -611,7 +611,7 @@ private: }; template <> -void Out<const struct addrinfo*>(IOutputStream& os, const struct addrinfo* ai) { +void Out<const struct addrinfo*>(IOutputStream& os, const struct addrinfo* ai) { if (ai->ai_flags & AI_CANONNAME) { os << "`" << ai->ai_canonname << "' "; } @@ -628,12 +628,12 @@ void Out<const struct addrinfo*>(IOutputStream& os, const struct addrinfo* ai) { } template <> -void Out<struct addrinfo*>(IOutputStream& os, struct addrinfo* ai) { +void Out<struct addrinfo*>(IOutputStream& os, struct addrinfo* ai) { Out<const struct addrinfo*>(os, static_cast<const struct addrinfo*>(ai)); } template <> -void Out<TNetworkAddress>(IOutputStream& os, const TNetworkAddress& addr) { +void Out<TNetworkAddress>(IOutputStream& os, const TNetworkAddress& addr) { os << &*addr.Begin(); } @@ -919,16 +919,16 @@ TSocketOutput::~TSocketOutput() { } void TSocketOutput::DoWrite(const void* buf, size_t len) { - size_t send = 0; + size_t send = 0; while (len) { const ssize_t ret = S_.Send(buf, len); if (ret < 0) { - ythrow TSystemError(-(int)ret) << "can not write to socket output stream; " << send << " bytes already send"; + ythrow TSystemError(-(int)ret) << "can not write to socket output stream; " << send << " bytes already send"; } buf = (const char*)buf + ret; len -= ret; - send += ret; + send += ret; } } @@ -1080,7 +1080,7 @@ TNetworkAddress::TNetworkAddress(const TString& host, ui16 port) } TNetworkAddress::TNetworkAddress(ui16 port) - : Impl_(new TImpl(nullptr, port, 0)) + : Impl_(new TImpl(nullptr, port, 0)) { } @@ -1091,7 +1091,7 @@ struct addrinfo* TNetworkAddress::Info() const noexcept { } TNetworkResolutionError::TNetworkResolutionError(int error) { - const char* errMsg = nullptr; + const char* errMsg = nullptr; #ifdef _win_ errMsg = LastSystemErrorText(error); // gai_strerror is not thread-safe on Windows #else @@ -1163,7 +1163,7 @@ static inline void SetNonBlockSocket(SOCKET fd, int value) { DWORD written = 0; if (!inbuf) { - WSAEventSelect(fd, nullptr, 0); + WSAEventSelect(fd, nullptr, 0); } if (WSAIoctl(fd, FIONBIO, &inbuf, sizeof(inbuf), &outbuf, sizeof(outbuf), &written, 0, 0) == SOCKET_ERROR) { @@ -1185,7 +1185,7 @@ static inline bool IsNonBlockSocket(SOCKET fd) { void SetNonBlock(SOCKET fd, bool value) { #if defined(_unix_) #if defined(FIONBIO) - Y_UNUSED(SetFlag); // shut up clang about unused function + Y_UNUSED(SetFlag); // shut up clang about unused function int nb = value; if (ioctl(fd, FIONBIO, &nb) < 0) { diff --git a/util/network/socket.h b/util/network/socket.h index 40c8648b409..9f0e35e1d20 100644 --- a/util/network/socket.h +++ b/util/network/socket.h @@ -5,8 +5,8 @@ #include <util/system/yassert.h> #include <util/system/defaults.h> #include <util/system/error.h> -#include <util/stream/output.h> -#include <util/stream/input.h> +#include <util/stream/output.h> +#include <util/stream/input.h> #include <util/generic/ptr.h> #include <util/generic/yexception.h> #include <util/generic/noncopyable.h> @@ -223,7 +223,7 @@ public: } inline TIterator End() const noexcept { - return TIterator(nullptr); + return TIterator(nullptr); } private: @@ -297,7 +297,7 @@ private: class TSocket { public: - using TPart = IOutputStream::TPart; + using TPart = IOutputStream::TPart; class TOps { public: @@ -389,7 +389,7 @@ private: TSimpleIntrusivePtr<TImpl> Impl_; }; -class TSocketInput: public IInputStream { +class TSocketInput: public IInputStream { public: TSocketInput(const TSocket& s) noexcept; ~TSocketInput() override; @@ -408,7 +408,7 @@ private: TSocket S_; }; -class TSocketOutput: public IOutputStream { +class TSocketOutput: public IOutputStream { public: TSocketOutput(const TSocket& s) noexcept; ~TSocketOutput() override; diff --git a/util/network/socket_ut.cpp b/util/network/socket_ut.cpp index 6b20e11f70a..7156161699a 100644 --- a/util/network/socket_ut.cpp +++ b/util/network/socket_ut.cpp @@ -219,7 +219,7 @@ class TPollTest: public TTestBase { public: inline TPollTest() { - srand(static_cast<unsigned int>(time(nullptr))); + srand(static_cast<unsigned int>(time(nullptr))); } void TestPollInOut(); @@ -273,7 +273,7 @@ SOCKET TPollTest::StartClientSocket(ui32 ip, ui16 port) { } SOCKET TPollTest::AcceptConnection(SOCKET serverSocket) { - SOCKET connectedSocket = accept(serverSocket, nullptr, nullptr); + SOCKET connectedSocket = accept(serverSocket, nullptr, nullptr); if (connectedSocket == INVALID_SOCKET) { ythrow yexception() << "Can not accept connection on server socket (" << LastSystemErrorText() << ")"; } diff --git a/util/random/benchmark/prng/main.cpp b/util/random/benchmark/prng/main.cpp index 2c6279ff71c..4c3fc3872ee 100644 --- a/util/random/benchmark/prng/main.cpp +++ b/util/random/benchmark/prng/main.cpp @@ -1,12 +1,12 @@ #include <library/cpp/testing/benchmark/bench.h> - -#include <util/random/entropy.h> -#include <util/random/fast.h> + +#include <util/random/entropy.h> +#include <util/random/fast.h> #include <util/random/normal.h> -#include <util/random/mersenne.h> -#include <util/system/compiler.h> +#include <util/random/mersenne.h> +#include <util/system/compiler.h> #include <util/generic/xrange.h> - + #include <random> // double part @@ -15,36 +15,36 @@ Y_CPU_BENCHMARK(Mersenne32_Double, p) { for (auto i : xrange<size_t>(0, p.Iterations())) { (void)i; - Y_DO_NOT_OPTIMIZE_AWAY(rng.GenRandReal1()); - } -} - + Y_DO_NOT_OPTIMIZE_AWAY(rng.GenRandReal1()); + } +} + Y_CPU_BENCHMARK(Mersenne64_Double, p) { TMersenne<ui64> rng(Seed()); for (auto i : xrange<size_t>(0, p.Iterations())) { (void)i; - Y_DO_NOT_OPTIMIZE_AWAY(rng.GenRandReal1()); - } -} - + Y_DO_NOT_OPTIMIZE_AWAY(rng.GenRandReal1()); + } +} + Y_CPU_BENCHMARK(Fast32_Double, p) { TFastRng<ui32> rng(Seed()); for (auto i : xrange<size_t>(0, p.Iterations())) { (void)i; - Y_DO_NOT_OPTIMIZE_AWAY(rng.GenRandReal1()); - } -} - + Y_DO_NOT_OPTIMIZE_AWAY(rng.GenRandReal1()); + } +} + Y_CPU_BENCHMARK(Fast64_Double, p) { TFastRng<ui64> rng(Seed()); for (auto i : xrange<size_t>(0, p.Iterations())) { (void)i; - Y_DO_NOT_OPTIMIZE_AWAY(rng.GenRandReal1()); - } -} + Y_DO_NOT_OPTIMIZE_AWAY(rng.GenRandReal1()); + } +} // integer part Y_CPU_BENCHMARK(mt19937_32, p) { diff --git a/util/random/benchmark/prng/metrics/main.py b/util/random/benchmark/prng/metrics/main.py index 15b371fe75f..7b8174a647a 100644 --- a/util/random/benchmark/prng/metrics/main.py +++ b/util/random/benchmark/prng/metrics/main.py @@ -1,5 +1,5 @@ -import yatest.common as yc - - -def test_export_metrics(metrics): +import yatest.common as yc + + +def test_export_metrics(metrics): metrics.set_benchmark(yc.execute_benchmark('util/random/benchmark/prng/prng', threads=8)) diff --git a/util/random/benchmark/prng/metrics/ya.make b/util/random/benchmark/prng/metrics/ya.make index 1f56aac0bd0..45f0ab09238 100644 --- a/util/random/benchmark/prng/metrics/ya.make +++ b/util/random/benchmark/prng/metrics/ya.make @@ -1,21 +1,21 @@ -OWNER( - yazevnul +OWNER( + yazevnul g:util -) +) SUBSCRIBER(g:util-subscribers) - + PY2TEST() - + SIZE(LARGE) - -TAG( + +TAG( ya:force_sandbox - sb:intel_e5_2660v1 + sb:intel_e5_2660v1 ya:fat -) - +) + TEST_SRCS(main.py) - + DEPENDS(util/random/benchmark/prng) - -END() + +END() diff --git a/util/random/benchmark/prng/ya.make b/util/random/benchmark/prng/ya.make index 976977014f6..a475d0c67fe 100644 --- a/util/random/benchmark/prng/ya.make +++ b/util/random/benchmark/prng/ya.make @@ -1,13 +1,13 @@ -OWNER( - yazevnul +OWNER( + yazevnul g:util -) +) SUBSCRIBER(g:util-subscribers) - + Y_BENCHMARK() - -SRCS( - main.cpp -) - -END() + +SRCS( + main.cpp +) + +END() diff --git a/util/random/benchmark/ya.make b/util/random/benchmark/ya.make index 7d753ae6e76..a4ae9d27287 100644 --- a/util/random/benchmark/ya.make +++ b/util/random/benchmark/ya.make @@ -1,10 +1,10 @@ -OWNER( - yazevnul +OWNER( + yazevnul g:util -) +) SUBSCRIBER(g:util-subscribers) - -RECURSE( - prng - prng/metrics -) + +RECURSE( + prng + prng/metrics +) diff --git a/util/random/common_ops.h b/util/random/common_ops.h index 602eede3511..373046cdce3 100644 --- a/util/random/common_ops.h +++ b/util/random/common_ops.h @@ -4,31 +4,31 @@ #include <util/system/yassert.h> namespace NPrivate { - constexpr double ToRandReal1(const ui32 x) noexcept { + constexpr double ToRandReal1(const ui32 x) noexcept { return x * (double)(1.0 / 4294967295.0); } - constexpr double ToRandReal2(const ui32 x) noexcept { + constexpr double ToRandReal2(const ui32 x) noexcept { return x * (double)(1.0 / 4294967296.0); } - constexpr double ToRandReal3(const ui32 x) noexcept { + constexpr double ToRandReal3(const ui32 x) noexcept { return ((double)x + 0.5) * (double)(1.0 / 4294967296.0); } - constexpr double ToRandReal1(const ui64 x) noexcept { + constexpr double ToRandReal1(const ui64 x) noexcept { return (x >> 11) * (double)(1.0 / 9007199254740991.0); } - constexpr double ToRandReal2(const ui64 x) noexcept { + constexpr double ToRandReal2(const ui64 x) noexcept { return (x >> 11) * (double)(1.0 / 9007199254740992.0); } - constexpr double ToRandReal3(const ui64 x) noexcept { + constexpr double ToRandReal3(const ui64 x) noexcept { return ((x >> 12) + 0.5) * (double)(1.0 / 4503599627370496.0); } - constexpr double ToRandReal4(const ui64 x) noexcept { + constexpr double ToRandReal4(const ui64 x) noexcept { return double(x * (double)(1.0 / 18446744073709551616.0L)); } @@ -38,7 +38,7 @@ namespace NPrivate { } template <class T> - static constexpr ui64 ToRand64(T&&, ui64 x) noexcept { + static constexpr ui64 ToRand64(T&&, ui64 x) noexcept { return x; } @@ -47,7 +47,7 @@ namespace NPrivate { */ template <class T, class TRandGen> static T GenUniform(T max, TRandGen&& gen) { - Y_VERIFY(max > 0, "Invalid random number range [0, 0)"); + Y_VERIFY(max > 0, "Invalid random number range [0, 0)"); const T randmax = gen.RandMax() - gen.RandMax() % max; T rand; @@ -63,7 +63,7 @@ namespace NPrivate { template <class TRandType, class T> struct TCommonRNG { using TResult = TRandType; - using result_type = TRandType; + using result_type = TRandType; inline T& Engine() noexcept { return static_cast<T&>(*this); @@ -72,11 +72,11 @@ struct TCommonRNG { static constexpr TResult _Min = TResult(0); static constexpr TResult _Max = TResult(-1); - static constexpr TResult RandMax() noexcept { + static constexpr TResult RandMax() noexcept { return _Max; } - static constexpr TResult RandMin() noexcept { + static constexpr TResult RandMin() noexcept { return _Min; } @@ -120,11 +120,11 @@ struct TCommonRNG { return Engine().GenRand(); } - static constexpr TResult max() noexcept { + static constexpr TResult max() noexcept { return T::RandMax(); } - static constexpr TResult min() noexcept { + static constexpr TResult min() noexcept { return T::RandMin(); } }; diff --git a/util/random/common_ops_ut.cpp b/util/random/common_ops_ut.cpp index 905912bd1ed..4eea0eaf3f9 100644 --- a/util/random/common_ops_ut.cpp +++ b/util/random/common_ops_ut.cpp @@ -7,7 +7,7 @@ #include <random> -Y_UNIT_TEST_SUITE(TestCommonRNG) { +Y_UNIT_TEST_SUITE(TestCommonRNG) { template <class T> struct TRng: public TCommonRNG<T, TRng<T>> { inline T GenRand() noexcept { @@ -17,7 +17,7 @@ Y_UNIT_TEST_SUITE(TestCommonRNG) { T C_ = RandomNumber<T>(); }; - Y_UNIT_TEST(TestUniform1) { + Y_UNIT_TEST(TestUniform1) { TRng<ui32> r; for (size_t i = 0; i < 1000; ++i) { @@ -25,7 +25,7 @@ Y_UNIT_TEST_SUITE(TestCommonRNG) { } } - Y_UNIT_TEST(TestUniform2) { + Y_UNIT_TEST(TestUniform2) { TRng<ui32> r; for (size_t i = 0; i < 1000; ++i) { @@ -33,7 +33,7 @@ Y_UNIT_TEST_SUITE(TestCommonRNG) { } } - Y_UNIT_TEST(TestUniform3) { + Y_UNIT_TEST(TestUniform3) { TRng<ui32> r; for (size_t i = 0; i < 1000; ++i) { @@ -44,7 +44,7 @@ Y_UNIT_TEST_SUITE(TestCommonRNG) { } } - Y_UNIT_TEST(TestStlCompatibility) { + Y_UNIT_TEST(TestStlCompatibility) { { TRng<ui32> r; r.C_ = 17; diff --git a/util/random/easy_ut.cpp b/util/random/easy_ut.cpp index d1d024a91fe..d8ac86dd290 100644 --- a/util/random/easy_ut.cpp +++ b/util/random/easy_ut.cpp @@ -2,8 +2,8 @@ #include <library/cpp/testing/unittest/registar.h> -Y_UNIT_TEST_SUITE(TEasyRndInterface) { - Y_UNIT_TEST(Test1) { +Y_UNIT_TEST_SUITE(TEasyRndInterface) { + Y_UNIT_TEST(Test1) { { ui32 x = 0; diff --git a/util/random/entropy.cpp b/util/random/entropy.cpp index 3617edb83d7..7450f390c23 100644 --- a/util/random/entropy.cpp +++ b/util/random/entropy.cpp @@ -5,10 +5,10 @@ #include "shuffle.h" #include "init_atfork.h" -#include <util/stream/output.h> -#include <util/stream/mem.h> +#include <util/stream/output.h> +#include <util/stream/mem.h> #include <util/stream/zlib.h> -#include <util/stream/buffer.h> +#include <util/stream/buffer.h> #include <util/system/fs.h> #include <util/system/info.h> @@ -102,7 +102,7 @@ namespace { }; //not thread-safe - class TMersenneInput: public IInputStream { + class TMersenneInput: public IInputStream { using TKey = ui64; using TRnd = TMersenne<TKey>; @@ -134,7 +134,7 @@ namespace { TRnd Rnd_; }; - class TEntropyPoolStream: public IInputStream { + class TEntropyPoolStream: public IInputStream { public: inline explicit TEntropyPoolStream(const TBuffer& buffer) : Mi_(buffer) @@ -154,7 +154,7 @@ namespace { TBufferedInput Bi_; }; - struct TSeedStream: public IInputStream { + struct TSeedStream: public IInputStream { size_t DoRead(void* inbuf, size_t len) override { char* buf = (char*)inbuf; @@ -184,11 +184,11 @@ namespace { Reset(); } - inline IInputStream& EntropyPool() noexcept { + inline IInputStream& EntropyPool() noexcept { return *EP; } - inline IInputStream& Seed() noexcept { + inline IInputStream& Seed() noexcept { return SS; } @@ -208,11 +208,11 @@ namespace { using TRandomTraits = TDefaultTraits; } -IInputStream& EntropyPool() { +IInputStream& EntropyPool() { return TRandomTraits::Instance().EntropyPool(); } -IInputStream& Seed() { +IInputStream& Seed() { return TRandomTraits::Instance().Seed(); } diff --git a/util/random/entropy.h b/util/random/entropy.h index 62029c1b636..9cb3b2abaea 100644 --- a/util/random/entropy.h +++ b/util/random/entropy.h @@ -1,19 +1,19 @@ #pragma once class TBuffer; -class IInputStream; +class IInputStream; /* * fast entropy pool, based on good prng, can lock for some time * initialized with some bits from system entropy pool * think as /dev/urandom replacement */ -IInputStream& EntropyPool(); +IInputStream& EntropyPool(); /* * fast(non-blocking) entropy pool, useful for seeding PRNGs */ -IInputStream& Seed(); +IInputStream& Seed(); /* * Re-initialize entropy pool - useful after forking in multi-process programs. diff --git a/util/random/entropy_ut.cpp b/util/random/entropy_ut.cpp index 1ff27203f04..ed976a9c64c 100644 --- a/util/random/entropy_ut.cpp +++ b/util/random/entropy_ut.cpp @@ -2,8 +2,8 @@ #include <library/cpp/testing/unittest/registar.h> -Y_UNIT_TEST_SUITE(TestEntropy) { - Y_UNIT_TEST(TestSeed) { +Y_UNIT_TEST_SUITE(TestEntropy) { + Y_UNIT_TEST(TestSeed) { char buf[100]; for (size_t i = 0; i < sizeof(buf); ++i) { diff --git a/util/random/fast.cpp b/util/random/fast.cpp index 2f98dfc5d35..82d3c9bf761 100644 --- a/util/random/fast.cpp +++ b/util/random/fast.cpp @@ -27,13 +27,13 @@ TFastRng64::TArgs::TArgs(ui64 seed) noexcept { Seq2 = rng.GenRand(); } -TFastRng64::TArgs::TArgs(IInputStream& entropy) { +TFastRng64::TArgs::TArgs(IInputStream& entropy) { static_assert(sizeof(*this) == 3 * sizeof(ui64), "please, fix me"); entropy.LoadOrFail(this, sizeof(*this)); } template <class T> -static inline T Read(IInputStream& in) noexcept { +static inline T Read(IInputStream& in) noexcept { T t = T(); in.LoadOrFail(&t, sizeof(t)); @@ -41,12 +41,12 @@ static inline T Read(IInputStream& in) noexcept { return t; } -TFastRng32::TFastRng32(IInputStream& entropy) +TFastRng32::TFastRng32(IInputStream& entropy) : TFastRng32(Read<ui64>(entropy), Read<ui32>(entropy)) { } -TReallyFastRng32::TReallyFastRng32(IInputStream& entropy) +TReallyFastRng32::TReallyFastRng32(IInputStream& entropy) : TReallyFastRng32(Read<ui64>(entropy)) { } diff --git a/util/random/fast.h b/util/random/fast.h index ddc57116416..194524d4b9a 100644 --- a/util/random/fast.h +++ b/util/random/fast.h @@ -3,7 +3,7 @@ #include "lcg_engine.h" #include "common_ops.h" -#include <util/generic/bitops.h> +#include <util/generic/bitops.h> #include <util/system/platform.h> // based on http://www.pcg-random.org/. See T*FastRng* family below. @@ -13,14 +13,14 @@ struct TPCGMixer { const ui32 xorshifted = ((x >> 18u) ^ x) >> 27u; const ui32 rot = x >> 59u; - return RotateBitsRight(xorshifted, rot); + return RotateBitsRight(xorshifted, rot); } }; using TFastRng32Base = TLcgRngBase<TLcgIterator<ui64, ULL(6364136223846793005)>, TPCGMixer>; using TReallyFastRng32Base = TLcgRngBase<TFastLcgIterator<ui64, ULL(6364136223846793005), ULL(1)>, TPCGMixer>; -class IInputStream; +class IInputStream; struct TFastRng32: public TCommonRNG<ui32, TFastRng32>, public TFastRng32Base { inline TFastRng32(ui64 seed, ui32 seq) @@ -28,7 +28,7 @@ struct TFastRng32: public TCommonRNG<ui32, TFastRng32>, public TFastRng32Base { { } - TFastRng32(IInputStream& entropy); + TFastRng32(IInputStream& entropy); }; // faster than TFastRng32, but have only one possible stream sequence @@ -38,14 +38,14 @@ struct TReallyFastRng32: public TCommonRNG<ui32, TReallyFastRng32>, public TReal { } - TReallyFastRng32(IInputStream& entropy); + TReallyFastRng32(IInputStream& entropy); }; class TFastRng64: public TCommonRNG<ui64, TFastRng64> { public: struct TArgs { TArgs(ui64 seed) noexcept; - TArgs(IInputStream& entropy); + TArgs(IInputStream& entropy); ui64 Seed1; ui64 Seed2; @@ -58,7 +58,7 @@ public: /* * simplify constructions like * TFastRng64 rng(17); - * TFastRng64 rng(Seek()); //from any IInputStream + * TFastRng64 rng(Seek()); //from any IInputStream */ inline TFastRng64(const TArgs& args) noexcept : TFastRng64(args.Seed1, args.Seq1, args.Seed2, args.Seq2) diff --git a/util/random/fast_ut.cpp b/util/random/fast_ut.cpp index 60994a98b06..a513a973b1f 100644 --- a/util/random/fast_ut.cpp +++ b/util/random/fast_ut.cpp @@ -2,8 +2,8 @@ #include <library/cpp/testing/unittest/registar.h> -Y_UNIT_TEST_SUITE(TTestFastRng) { - Y_UNIT_TEST(Test1) { +Y_UNIT_TEST_SUITE(TTestFastRng) { + Y_UNIT_TEST(Test1) { TFastRng32 rng1(17, 0); TReallyFastRng32 rng2(17); @@ -35,15 +35,15 @@ Y_UNIT_TEST_SUITE(TTestFastRng) { 75, }; - Y_UNIT_TEST(Test2) { + Y_UNIT_TEST(Test2) { TFastRng64 rng(0, 1, 2, 3); - for (auto& i : R1) { - UNIT_ASSERT_VALUES_EQUAL(rng.Uniform(100u), i); + for (auto& i : R1) { + UNIT_ASSERT_VALUES_EQUAL(rng.Uniform(100u), i); } } - Y_UNIT_TEST(TestAdvance) { + Y_UNIT_TEST(TestAdvance) { TReallyFastRng32 rng1(17); TReallyFastRng32 rng2(17); for (size_t i = 0; i < 100; i++) { @@ -61,7 +61,7 @@ Y_UNIT_TEST_SUITE(TTestFastRng) { UNIT_ASSERT_VALUES_EQUAL(rng3.GenRand(), rng4.GenRand()); } - Y_UNIT_TEST(TestAdvanceBoundaries) { + Y_UNIT_TEST(TestAdvanceBoundaries) { TReallyFastRng32 rng1(17); TReallyFastRng32 rng2(17); TReallyFastRng32 rng3(17); @@ -71,7 +71,7 @@ Y_UNIT_TEST_SUITE(TTestFastRng) { UNIT_ASSERT_VALUES_EQUAL(rng1.GenRand(), rng3.GenRand()); } - Y_UNIT_TEST(TestCopy) { + Y_UNIT_TEST(TestCopy) { TReallyFastRng32 r1(1); TReallyFastRng32 r2(2); @@ -82,13 +82,13 @@ Y_UNIT_TEST_SUITE(TTestFastRng) { UNIT_ASSERT_VALUES_EQUAL(r1.GenRand(), r2.GenRand()); } - Y_UNIT_TEST(Test3) { + Y_UNIT_TEST(Test3) { TFastRng64 rng(17); UNIT_ASSERT_VALUES_EQUAL(rng.GenRand(), ULL(14895365814383052362)); } - Y_UNIT_TEST(TestCompile) { + Y_UNIT_TEST(TestCompile) { TFastRng<ui32> rng1(1); TFastRng<ui64> rng2(2); TFastRng<size_t> rng3(3); @@ -103,14 +103,14 @@ Y_UNIT_TEST_SUITE(TTestFastRng) { "But apparently I made a blunder here -" "Doha does not warm ... Absolutely."; - Y_UNIT_TEST(TestStreamCtor1) { + Y_UNIT_TEST(TestStreamCtor1) { TMemoryInput mi(RNG_DATA, strlen(RNG_DATA)); TFastRng<ui32> rng(mi); UNIT_ASSERT_VALUES_EQUAL(rng.GenRand(), 1449109131u); } - Y_UNIT_TEST(TestStreamCtor2) { + Y_UNIT_TEST(TestStreamCtor2) { TMemoryInput mi(RNG_DATA, strlen(RNG_DATA)); TFastRng<ui64> rng(mi); diff --git a/util/random/lcg_engine.h b/util/random/lcg_engine.h index 08cc93c8457..bee44db16cd 100644 --- a/util/random/lcg_engine.h +++ b/util/random/lcg_engine.h @@ -15,7 +15,7 @@ template <typename T, T A, T C> struct TFastLcgIterator { static_assert(C % 2 == 1, "C must be odd"); - static constexpr T Iterate(T x) noexcept { + static constexpr T Iterate(T x) noexcept { return x * A + C; } diff --git a/util/random/mersenne.h b/util/random/mersenne.h index b2044604ac7..567fafc362a 100644 --- a/util/random/mersenne.h +++ b/util/random/mersenne.h @@ -19,7 +19,7 @@ namespace NPrivate { }; } -class IInputStream; +class IInputStream; template <class T> class TMersenne: public TCommonRNG<T, TMersenne<T>>, public ::NPrivate::TMersenneTraits<T>::TImpl { @@ -34,7 +34,7 @@ public: { } - inline TMersenne(IInputStream& pool) + inline TMersenne(IInputStream& pool) : TBase(pool) { } diff --git a/util/random/mersenne32.cpp b/util/random/mersenne32.cpp index cb8aad8b039..04a2af59e41 100644 --- a/util/random/mersenne32.cpp +++ b/util/random/mersenne32.cpp @@ -83,13 +83,13 @@ void TMersenne32::InitNext() noexcept { mti = 0; } -TMersenne32::TMersenne32(IInputStream& input) +TMersenne32::TMersenne32(IInputStream& input) : mti(N + 1) { ui32 buf[128]; input.LoadOrFail(buf, sizeof(buf)); - InitByArray(buf, Y_ARRAY_SIZE(buf)); + InitByArray(buf, Y_ARRAY_SIZE(buf)); } #undef M diff --git a/util/random/mersenne32.h b/util/random/mersenne32.h index 861f3a3d387..75096e68a00 100644 --- a/util/random/mersenne32.h +++ b/util/random/mersenne32.h @@ -2,11 +2,11 @@ #include <util/system/defaults.h> -class IInputStream; +class IInputStream; namespace NPrivate { class TMersenne32 { - static constexpr int N = 624; + static constexpr int N = 624; public: inline TMersenne32(ui32 s = 19650218UL) noexcept @@ -21,7 +21,7 @@ namespace NPrivate { InitByArray(init_key, key_length); } - TMersenne32(IInputStream& input); + TMersenne32(IInputStream& input); inline ui32 GenRand() noexcept { if (mti >= N) { diff --git a/util/random/mersenne64.cpp b/util/random/mersenne64.cpp index 4ede2c6dca4..9426e58e5e9 100644 --- a/util/random/mersenne64.cpp +++ b/util/random/mersenne64.cpp @@ -85,13 +85,13 @@ void TMersenne64::InitNext() noexcept { mti = 0; } -TMersenne64::TMersenne64(IInputStream& input) +TMersenne64::TMersenne64(IInputStream& input) : mti(NN + 1) { ui64 buf[128]; input.LoadOrFail(buf, sizeof(buf)); - InitByArray(buf, Y_ARRAY_SIZE(buf)); + InitByArray(buf, Y_ARRAY_SIZE(buf)); } #undef MM diff --git a/util/random/mersenne64.h b/util/random/mersenne64.h index 12ca43b6afc..db40a939acb 100644 --- a/util/random/mersenne64.h +++ b/util/random/mersenne64.h @@ -2,11 +2,11 @@ #include <util/system/defaults.h> -class IInputStream; +class IInputStream; namespace NPrivate { class TMersenne64 { - static constexpr int NN = 312; + static constexpr int NN = 312; public: inline TMersenne64(ui64 s = ULL(19650218)) @@ -21,7 +21,7 @@ namespace NPrivate { InitByArray(keys, len); } - TMersenne64(IInputStream& input); + TMersenne64(IInputStream& input); inline ui64 GenRand() noexcept { if (mti >= NN) { diff --git a/util/random/mersenne_ut.cpp b/util/random/mersenne_ut.cpp index a4b84efa3d1..27bd979debc 100644 --- a/util/random/mersenne_ut.cpp +++ b/util/random/mersenne_ut.cpp @@ -2,11 +2,11 @@ #include <library/cpp/testing/unittest/registar.h> -#include <util/stream/output.h> +#include <util/stream/output.h> #define UI32(x) x##ul -Y_UNIT_TEST_SUITE(TMersenneRndTest) { +Y_UNIT_TEST_SUITE(TMersenneRndTest) { template <class T> inline void Test(const T* res, size_t len) { TMersenne<T> m; @@ -16,7 +16,7 @@ Y_UNIT_TEST_SUITE(TMersenneRndTest) { } } - Y_UNIT_TEST(Test32) { + Y_UNIT_TEST(Test32) { const ui32 res[] = { UI32(2325592414), UI32(482149846), @@ -30,10 +30,10 @@ Y_UNIT_TEST_SUITE(TMersenneRndTest) { UI32(3882134983), }; - Test<ui32>(res, Y_ARRAY_SIZE(res)); + Test<ui32>(res, Y_ARRAY_SIZE(res)); } - Y_UNIT_TEST(Test64) { + Y_UNIT_TEST(Test64) { const ui64 res[] = { ULL(13735441942630277712), ULL(10468394322237346228), @@ -47,10 +47,10 @@ Y_UNIT_TEST_SUITE(TMersenneRndTest) { ULL(11231499428520958715), }; - Test<ui64>(res, Y_ARRAY_SIZE(res)); + Test<ui64>(res, Y_ARRAY_SIZE(res)); } - Y_UNIT_TEST(TestGenRand64) { + Y_UNIT_TEST(TestGenRand64) { TMersenne<ui32> rng; for (size_t i = 0; i < 100; ++i) { @@ -58,7 +58,7 @@ Y_UNIT_TEST_SUITE(TMersenneRndTest) { } } - Y_UNIT_TEST(TestCopy32) { + Y_UNIT_TEST(TestCopy32) { TMersenne<ui32> r1(1); TMersenne<ui32> r2(2); @@ -69,7 +69,7 @@ Y_UNIT_TEST_SUITE(TMersenneRndTest) { UNIT_ASSERT_VALUES_EQUAL(r1.GenRand(), r2.GenRand()); } - Y_UNIT_TEST(TestCopy64) { + Y_UNIT_TEST(TestCopy64) { TMersenne<ui64> r1(1); TMersenne<ui64> r2(2); diff --git a/util/random/normal_ut.cpp b/util/random/normal_ut.cpp index 42b6cc4ba2f..23311c80790 100644 --- a/util/random/normal_ut.cpp +++ b/util/random/normal_ut.cpp @@ -7,8 +7,8 @@ #include <functional> -Y_UNIT_TEST_SUITE(TestNormalDistribution) { - Y_UNIT_TEST(TestDefined) { +Y_UNIT_TEST_SUITE(TestNormalDistribution) { + Y_UNIT_TEST(TestDefined) { volatile auto x = NormalRandom<float>(0, 1) + NormalRandom<double>(0, 1) + NormalRandom<long double>(0, 1); (void)x; @@ -45,7 +45,7 @@ Y_UNIT_TEST_SUITE(TestNormalDistribution) { UNIT_ASSERT_DOUBLES_EQUAL(d, dd, (d + 1) * 0.05); } - Y_UNIT_TEST(Test1) { + Y_UNIT_TEST(Test1) { TestMD<float>(&StdNormalRandom<float>, 0, 1); TestMD<double>(&StdNormalRandom<double>, 0, 1); TestMD<long double>(&StdNormalRandom<long double>, 0, 1); @@ -67,13 +67,13 @@ Y_UNIT_TEST_SUITE(TestNormalDistribution) { }; } - Y_UNIT_TEST(Test2) { + Y_UNIT_TEST(Test2) { TestMD<float>(GenFunc1<float>(2, 3), 2, 3); TestMD<double>(GenFunc1<double>(3, 4), 3, 4); TestMD<long double>(GenFunc1<long double>(4, 5), 4, 5); } - Y_UNIT_TEST(Test3) { + Y_UNIT_TEST(Test3) { TestMD<float>(GenFunc2<float>(20, 30), 20, 30); TestMD<double>(GenFunc2<double>(30, 40), 30, 40); TestMD<long double>(GenFunc2<long double>(40, 50), 40, 50); diff --git a/util/random/random_ut.cpp b/util/random/random_ut.cpp index 30427676f36..1f52efe2fa7 100644 --- a/util/random/random_ut.cpp +++ b/util/random/random_ut.cpp @@ -10,7 +10,7 @@ static inline void AssertRange(T v, T r1, T r2) { UNIT_ASSERT(v < r2); } -Y_UNIT_TEST_SUITE(TRandomNumberTest) { +Y_UNIT_TEST_SUITE(TRandomNumberTest) { template <typename T> void TestAll(T n) { for (T i = 0; i < n; ++i) { @@ -49,32 +49,32 @@ Y_UNIT_TEST_SUITE(TRandomNumberTest) { TestSome<T>(Max<T>() - 22222); } - Y_UNIT_TEST(TestWithLimit) { + Y_UNIT_TEST(TestWithLimit) { TestType<unsigned short>(); TestType<unsigned int>(); TestType<unsigned long>(); TestType<unsigned long long>(); } - Y_UNIT_TEST(TestRandomNumberFloat) { + Y_UNIT_TEST(TestRandomNumberFloat) { for (size_t i = 0; i < 1000; ++i) { AssertRange<float>(RandomNumber<float>(), 0.0, 1.0); } } - Y_UNIT_TEST(TestRandomNumberDouble) { + Y_UNIT_TEST(TestRandomNumberDouble) { for (size_t i = 0; i < 1000; ++i) { AssertRange<double>(RandomNumber<double>(), 0.0, 1.0); } } - Y_UNIT_TEST(TestRandomNumberLongDouble) { + Y_UNIT_TEST(TestRandomNumberLongDouble) { for (size_t i = 0; i < 1000; ++i) { AssertRange<long double>(RandomNumber<long double>(), 0.0, 1.0); } } - Y_UNIT_TEST(TestBoolean) { + Y_UNIT_TEST(TestBoolean) { while (RandomNumber<bool>()) { } while (!RandomNumber<bool>()) { diff --git a/util/random/shuffle_ut.cpp b/util/random/shuffle_ut.cpp index 87cbae94c00..5da99b0b485 100644 --- a/util/random/shuffle_ut.cpp +++ b/util/random/shuffle_ut.cpp @@ -6,7 +6,7 @@ #include <util/generic/ylimits.h> -Y_UNIT_TEST_SUITE(TRandUtilsTest) { +Y_UNIT_TEST_SUITE(TRandUtilsTest) { template <typename... A> static void TestRange(A&&... args) { TString s0, s1; @@ -55,19 +55,19 @@ Y_UNIT_TEST_SUITE(TRandUtilsTest) { TestRange(prng); } - Y_UNIT_TEST(TestShuffleMersenne32) { + Y_UNIT_TEST(TestShuffleMersenne32) { TMersenne<ui32> prng(24); TestIter(prng); } - Y_UNIT_TEST(TestShuffleFast32) { + Y_UNIT_TEST(TestShuffleFast32) { TFastRng32 prng(24, 0); TestIter(prng); } - Y_UNIT_TEST(TestShuffleFast64) { + Y_UNIT_TEST(TestShuffleFast64) { TFastRng64 prng(24, 0, 25, 1); TestIter(prng); diff --git a/util/str_stl.h b/util/str_stl.h index f1e137181d2..d91ef1a7cbb 100644 --- a/util/str_stl.h +++ b/util/str_stl.h @@ -46,15 +46,15 @@ namespace NHashPrivate { return NumericHash(t); } }; - - template <typename C> - struct TStringHash { - using is_transparent = void; - - inline size_t operator()(const TBasicStringBuf<C> s) const noexcept { + + template <typename C> + struct TStringHash { + using is_transparent = void; + + inline size_t operator()(const TBasicStringBuf<C> s) const noexcept { return NHashPrivate::ComputeStringHash(s.data(), s.size()); - } - }; + } + }; } template <class T> @@ -88,18 +88,18 @@ template <> struct hash<TUtf16String>: ::NHashPrivate::TStringHash<wchar16> { }; -template <> +template <> struct THash<TWtringBuf>: ::NHashPrivate::TStringHash<wchar16> { -}; +}; -template <> +template <> struct hash<TUtf32String>: ::NHashPrivate::TStringHash<wchar32> { -}; - -template <> +}; + +template <> struct THash<TUtf32StringBuf>: ::NHashPrivate::TStringHash<wchar32> { -}; - +}; + template <class C, class T, class A> struct hash<std::basic_string<C, T, A>>: ::NHashPrivate::TStringHash<C> { }; @@ -221,7 +221,7 @@ struct TCIEqualTo<const char*> { template <> struct TCIEqualTo<TStringBuf> { - inline bool operator()(const TStringBuf a, const TStringBuf b) const { + inline bool operator()(const TStringBuf a, const TStringBuf b) const { return a.size() == b.size() && strnicmp(a.data(), b.data(), a.size()) == 0; } }; diff --git a/util/stream/aligned.cpp b/util/stream/aligned.cpp index 2fd12d15b74..2b5ec6d41be 100644 --- a/util/stream/aligned.cpp +++ b/util/stream/aligned.cpp @@ -18,7 +18,7 @@ size_t TAlignedInput::DoReadTo(TString& st, char ch) { return ret; } -ui64 TAlignedInput::DoReadAll(IOutputStream& out) { +ui64 TAlignedInput::DoReadAll(IOutputStream& out) { ui64 ret = Stream_->ReadAll(out); Position_ += ret; return ret; diff --git a/util/stream/aligned.h b/util/stream/aligned.h index 70e7be05a99..672ea254949 100644 --- a/util/stream/aligned.h +++ b/util/stream/aligned.h @@ -15,9 +15,9 @@ * Proxy input stream that provides additional functions that make reading * aligned data easier. */ -class TAlignedInput: public IInputStream { +class TAlignedInput: public IInputStream { public: - TAlignedInput(IInputStream* s) + TAlignedInput(IInputStream* s) : Stream_(s) , Position_(0) { @@ -30,7 +30,7 @@ public: * @param alignment Alignment. Must be a power of 2. */ void Align(size_t alignment = sizeof(void*)) { - Y_ASSERT(IsPowerOf2(alignment)); + Y_ASSERT(IsPowerOf2(alignment)); if (Position_ & (alignment - 1)) { size_t len = alignment - (Position_ & (alignment - 1)); @@ -45,10 +45,10 @@ private: size_t DoRead(void* ptr, size_t len) override; size_t DoSkip(size_t len) override; size_t DoReadTo(TString& st, char ch) override; - ui64 DoReadAll(IOutputStream& out) override; + ui64 DoReadAll(IOutputStream& out) override; private: - IInputStream* Stream_; + IInputStream* Stream_; ui64 Position_; }; @@ -56,9 +56,9 @@ private: * Proxy output stream that provides additional functions that make writing * aligned data easier. */ -class TAlignedOutput: public IOutputStream { +class TAlignedOutput: public IOutputStream { public: - TAlignedOutput(IOutputStream* s) + TAlignedOutput(IOutputStream* s) : Stream_(s) , Position_(0) { @@ -78,10 +78,10 @@ public: * @param alignment Alignment. Must be a power of 2. */ void Align(size_t alignment = sizeof(void*)) { - Y_ASSERT(IsPowerOf2(alignment)); + Y_ASSERT(IsPowerOf2(alignment)); static char unused[sizeof(void*) * 2]; - Y_ASSERT(alignment <= sizeof(unused)); + Y_ASSERT(alignment <= sizeof(unused)); if (Position_ & (alignment - 1)) { DoWrite(unused, alignment - (Position_ & (alignment - 1))); @@ -92,7 +92,7 @@ private: void DoWrite(const void* ptr, size_t len) override; private: - IOutputStream* Stream_; + IOutputStream* Stream_; ui64 Position_; }; diff --git a/util/stream/aligned_ut.cpp b/util/stream/aligned_ut.cpp index e980d05cf71..b8eaeea4378 100644 --- a/util/stream/aligned_ut.cpp +++ b/util/stream/aligned_ut.cpp @@ -2,7 +2,7 @@ #include <library/cpp/testing/unittest/registar.h> -class TNastyInputStream: public IInputStream { +class TNastyInputStream: public IInputStream { public: TNastyInputStream() : Pos_(0) @@ -33,8 +33,8 @@ private: size_t Pos_; }; -Y_UNIT_TEST_SUITE(TAlignedTest) { - Y_UNIT_TEST(AlignInput) { +Y_UNIT_TEST_SUITE(TAlignedTest) { + Y_UNIT_TEST(AlignInput) { TNastyInputStream input0; TAlignedInput alignedInput(&input0); diff --git a/util/stream/buffer.h b/util/stream/buffer.h index 9dc99dbe49f..3520be22de0 100644 --- a/util/stream/buffer.h +++ b/util/stream/buffer.h @@ -58,7 +58,7 @@ private: /** * Input stream that reads from an external `TBuffer`. */ -class TBufferInput: public IZeroCopyInputFastReadTo { +class TBufferInput: public IZeroCopyInputFastReadTo { public: /** * Constructs a stream that reads from an external buffer. It's up to the diff --git a/util/stream/buffer_ut.cpp b/util/stream/buffer_ut.cpp index 34946961907..4958f3bacab 100644 --- a/util/stream/buffer_ut.cpp +++ b/util/stream/buffer_ut.cpp @@ -8,8 +8,8 @@ #include "str.h" -Y_UNIT_TEST_SUITE(TBufferTest) { - Y_UNIT_TEST(Transfer) { +Y_UNIT_TEST_SUITE(TBufferTest) { + Y_UNIT_TEST(Transfer) { TBuffer buffer("razrazraz", 9); TBufferInput input(buffer); @@ -21,7 +21,7 @@ Y_UNIT_TEST_SUITE(TBufferTest) { UNIT_ASSERT_VALUES_EQUAL(output.Str(), "razraz"); } - Y_UNIT_TEST(ReadTo) { + Y_UNIT_TEST(ReadTo) { TBuffer buffer("1234567890", 10); TBufferInput input(buffer); @@ -58,7 +58,7 @@ Y_UNIT_TEST_SUITE(TBufferTest) { UNIT_ASSERT(0 == memcmp(buffer.data(), str.begin(), buffer.size())); } - Y_UNIT_TEST(Write) { + Y_UNIT_TEST(Write) { TBuffer buffer; TBufferOutput output(buffer); output << "1" @@ -75,7 +75,7 @@ Y_UNIT_TEST_SUITE(TBufferTest) { buffer.size())); } - Y_UNIT_TEST(WriteChars) { + Y_UNIT_TEST(WriteChars) { TBuffer buffer; TBufferOutput output(buffer); output << '1' << '2' << '3' << '4' << '5' << '6' << '7' << '8' << '9' << '0'; diff --git a/util/stream/buffered.cpp b/util/stream/buffered.cpp index a00e592e1c4..230b7436882 100644 --- a/util/stream/buffered.cpp +++ b/util/stream/buffered.cpp @@ -7,9 +7,9 @@ class TBufferedInput::TImpl: public TAdditionalStorage<TImpl> { public: - inline TImpl(IInputStream* slave) + inline TImpl(IInputStream* slave) : Slave_(slave) - , MemInput_(nullptr, 0) + , MemInput_(nullptr, 0) { } @@ -99,7 +99,7 @@ public: return ret; } - inline void Reset(IInputStream* slave) { + inline void Reset(IInputStream* slave) { Slave_ = slave; } @@ -113,11 +113,11 @@ private: } private: - IInputStream* Slave_; + IInputStream* Slave_; TMemoryInput MemInput_; }; -TBufferedInput::TBufferedInput(IInputStream* slave, size_t buflen) +TBufferedInput::TBufferedInput(IInputStream* slave, size_t buflen) : Impl_(new (buflen) TImpl(slave)) { } @@ -143,13 +143,13 @@ size_t TBufferedInput::DoReadTo(TString& st, char ch) { return Impl_->ReadTo(st, ch); } -void TBufferedInput::Reset(IInputStream* slave) { +void TBufferedInput::Reset(IInputStream* slave) { Impl_->Reset(slave); } class TBufferedOutputBase::TImpl { public: - inline TImpl(IOutputStream* slave) + inline TImpl(IOutputStream* slave) : Slave_(slave) , MemOut_(nullptr, 0) , PropagateFlush_(false) @@ -191,7 +191,7 @@ public: const size_t good_len = DownToBufferGranularity(full_len); const size_t write_from_buf = good_len - stored; - using TPart = IOutputStream::TPart; + using TPart = IOutputStream::TPart; alignas(TPart) char data[2 * sizeof(TPart)]; TPart* parts = reinterpret_cast<TPart*>(data); @@ -282,7 +282,7 @@ private: virtual size_t Len() const noexcept = 0; private: - IOutputStream* Slave_; + IOutputStream* Slave_; TMemoryOutput MemOut_; bool PropagateFlush_; bool PropagateFinish_; @@ -290,7 +290,7 @@ private: namespace { struct TSimpleImpl: public TBufferedOutputBase::TImpl, public TAdditionalStorage<TSimpleImpl> { - inline TSimpleImpl(IOutputStream* slave) + inline TSimpleImpl(IOutputStream* slave) : TBufferedOutputBase::TImpl(slave) { Reset(); @@ -315,7 +315,7 @@ namespace { Step = 4096 }; - inline TAdaptiveImpl(IOutputStream* slave) + inline TAdaptiveImpl(IOutputStream* slave) : TBufferedOutputBase::TImpl(slave) , N_(0) { @@ -346,12 +346,12 @@ namespace { }; } -TBufferedOutputBase::TBufferedOutputBase(IOutputStream* slave) +TBufferedOutputBase::TBufferedOutputBase(IOutputStream* slave) : Impl_(new TAdaptiveImpl(slave)) { } -TBufferedOutputBase::TBufferedOutputBase(IOutputStream* slave, size_t buflen) +TBufferedOutputBase::TBufferedOutputBase(IOutputStream* slave, size_t buflen) : Impl_(new (buflen) TSimpleImpl(slave)) { } @@ -413,14 +413,14 @@ void TBufferedOutputBase::SetFinishPropagateMode(bool propagate) noexcept { } } -TBufferedOutput::TBufferedOutput(IOutputStream* slave, size_t buflen) +TBufferedOutput::TBufferedOutput(IOutputStream* slave, size_t buflen) : TBufferedOutputBase(slave, buflen) { } TBufferedOutput::~TBufferedOutput() = default; -TAdaptiveBufferedOutput::TAdaptiveBufferedOutput(IOutputStream* slave) +TAdaptiveBufferedOutput::TAdaptiveBufferedOutput(IOutputStream* slave) : TBufferedOutputBase(slave) { } diff --git a/util/stream/buffered.h b/util/stream/buffered.h index 0847186141f..3e57740e248 100644 --- a/util/stream/buffered.h +++ b/util/stream/buffered.h @@ -20,9 +20,9 @@ * Note that it does not claim ownership of the underlying stream, so it's up * to the user to free it. */ -class TBufferedInput: public IZeroCopyInput { +class TBufferedInput: public IZeroCopyInput { public: - TBufferedInput(IInputStream* slave, size_t buflen = 8192); + TBufferedInput(IInputStream* slave, size_t buflen = 8192); TBufferedInput(TBufferedInput&&) noexcept; TBufferedInput& operator=(TBufferedInput&&) noexcept; @@ -35,7 +35,7 @@ public: * * @param slave New underlying stream. */ - void Reset(IInputStream* slave); + void Reset(IInputStream* slave); protected: size_t DoRead(void* buf, size_t len) override; @@ -69,7 +69,7 @@ public: * * @param slave Underlying stream. */ - TBufferedOutputBase(IOutputStream* slave); + TBufferedOutputBase(IOutputStream* slave); /** * Constructs a buffered stream with the given size of the buffer. @@ -77,7 +77,7 @@ public: * @param slave Underlying stream. * @param buflen Size of the buffer. */ - TBufferedOutputBase(IOutputStream* slave, size_t buflen); + TBufferedOutputBase(IOutputStream* slave, size_t buflen); TBufferedOutputBase(TBufferedOutputBase&&) noexcept; TBufferedOutputBase& operator=(TBufferedOutputBase&&) noexcept; @@ -129,7 +129,7 @@ private: */ class TBufferedOutput: public TBufferedOutputBase { public: - TBufferedOutput(IOutputStream* slave, size_t buflen = 8192); + TBufferedOutput(IOutputStream* slave, size_t buflen = 8192); ~TBufferedOutput() override; TBufferedOutput(TBufferedOutput&&) noexcept = default; @@ -144,7 +144,7 @@ public: */ class TAdaptiveBufferedOutput: public TBufferedOutputBase { public: - TAdaptiveBufferedOutput(IOutputStream* slave); + TAdaptiveBufferedOutput(IOutputStream* slave); ~TAdaptiveBufferedOutput() override; TAdaptiveBufferedOutput(TAdaptiveBufferedOutput&&) noexcept = default; @@ -153,7 +153,7 @@ public: namespace NPrivate { struct TMyBufferedOutput: public TBufferedOutput { - inline TMyBufferedOutput(IOutputStream* slave, size_t buflen) + inline TMyBufferedOutput(IOutputStream* slave, size_t buflen) : TBufferedOutput(slave, buflen) { SetFinishPropagateMode(true); @@ -162,7 +162,7 @@ namespace NPrivate { template <class T> struct TBufferedStreamFor { - using TResult = std::conditional_t<std::is_base_of<IInputStream, T>::value, TBufferedInput, TMyBufferedOutput>; + using TResult = std::conditional_t<std::is_base_of<IInputStream, T>::value, TBufferedInput, TMyBufferedOutput>; }; } diff --git a/util/stream/buffered_ut.cpp b/util/stream/buffered_ut.cpp index 41d2fc30308..4d97247175d 100644 --- a/util/stream/buffered_ut.cpp +++ b/util/stream/buffered_ut.cpp @@ -5,7 +5,7 @@ #include <util/generic/string.h> #include <util/random/mersenne.h> -Y_UNIT_TEST_SUITE(TestBufferedIO) { +Y_UNIT_TEST_SUITE(TestBufferedIO) { template <class TOut> inline void Run(TOut&& out) { TMersenne<ui64> r; @@ -22,7 +22,7 @@ Y_UNIT_TEST_SUITE(TestBufferedIO) { } } - Y_UNIT_TEST(TestEqual) { + Y_UNIT_TEST(TestEqual) { TString s1; TString s2; @@ -32,7 +32,7 @@ Y_UNIT_TEST_SUITE(TestBufferedIO) { UNIT_ASSERT_VALUES_EQUAL(s1, s2); } - Y_UNIT_TEST(Test1) { + Y_UNIT_TEST(Test1) { TString s; TBuffered<TStringOutput>(100, s).Write("1", 1); @@ -40,7 +40,7 @@ Y_UNIT_TEST_SUITE(TestBufferedIO) { UNIT_ASSERT_VALUES_EQUAL(s, "1"); } - Y_UNIT_TEST(Test2) { + Y_UNIT_TEST(Test2) { TString s; TBuffered<TStringOutput>(1, s).Write("12", 2); @@ -48,7 +48,7 @@ Y_UNIT_TEST_SUITE(TestBufferedIO) { UNIT_ASSERT_VALUES_EQUAL(s, "12"); } - Y_UNIT_TEST(Test3) { + Y_UNIT_TEST(Test3) { TString s; auto&& b = TBuffered<TStringOutput>(1, s); @@ -60,7 +60,7 @@ Y_UNIT_TEST_SUITE(TestBufferedIO) { UNIT_ASSERT_VALUES_EQUAL(s, "112"); } - Y_UNIT_TEST(Test4) { + Y_UNIT_TEST(Test4) { TString s; auto&& b = TBuffered<TStringOutput>(1, s); @@ -107,7 +107,7 @@ Y_UNIT_TEST_SUITE(TestBufferedIO) { UNIT_ASSERT_STRINGS_EQUAL(str1, str2); } - Y_UNIT_TEST(TestInput) { + Y_UNIT_TEST(TestInput) { TString s("0123456789abcdefghijklmn"); TBuffered<TStringInput> in(5, s); char c; @@ -128,7 +128,7 @@ Y_UNIT_TEST_SUITE(TestBufferedIO) { UNIT_ASSERT_VALUES_EQUAL(in.Skip(6), 3); //24 eof } - Y_UNIT_TEST(TestReadTo) { + Y_UNIT_TEST(TestReadTo) { TString s("0123456789abc"); TBuffered<TStringInput> in(2, s); TString t; diff --git a/util/stream/debug.cpp b/util/stream/debug.cpp index afd5b3e1c73..3ccb1abf380 100644 --- a/util/stream/debug.cpp +++ b/util/stream/debug.cpp @@ -31,7 +31,7 @@ namespace { } } - IOutputStream* Out; + IOutputStream* Out; int Level; }; } @@ -41,7 +41,7 @@ struct TSingletonTraits<TDbgSelector> { static constexpr size_t Priority = 8; }; -IOutputStream& StdDbgStream() noexcept { +IOutputStream& StdDbgStream() noexcept { return *(Singleton<TDbgSelector>()->Out); } diff --git a/util/stream/debug.h b/util/stream/debug.h index 92d6d4b42da..6faaf8d7c1b 100644 --- a/util/stream/debug.h +++ b/util/stream/debug.h @@ -10,7 +10,7 @@ /** * Debug output stream. Writes into `stderr`. */ -class TDebugOutput: public IOutputStream { +class TDebugOutput: public IOutputStream { public: inline TDebugOutput() noexcept = default; ~TDebugOutput() override = default; @@ -26,7 +26,7 @@ private: * @returns Standard debug stream. * @see Cdbg */ -IOutputStream& StdDbgStream() noexcept; +IOutputStream& StdDbgStream() noexcept; /** * This function returns the current debug level as set via `DBGOUT` environment diff --git a/util/stream/direct_io.h b/util/stream/direct_io.h index 2e1f2e07dd7..dff843b35cd 100644 --- a/util/stream/direct_io.h +++ b/util/stream/direct_io.h @@ -4,7 +4,7 @@ #include "output.h" #include <util/system/direct_io.h> -class TRandomAccessFileInput: public IInputStream { +class TRandomAccessFileInput: public IInputStream { public: TRandomAccessFileInput(TDirectIOBufferedFile& file, ui64 position); @@ -17,7 +17,7 @@ private: ui64 Position; }; -class TRandomAccessFileOutput: public IOutputStream { +class TRandomAccessFileOutput: public IOutputStream { public: TRandomAccessFileOutput(TDirectIOBufferedFile& file); diff --git a/util/stream/direct_io_ut.cpp b/util/stream/direct_io_ut.cpp index 01d09db232c..04784f5b0d1 100644 --- a/util/stream/direct_io_ut.cpp +++ b/util/stream/direct_io_ut.cpp @@ -1,71 +1,71 @@ #include <library/cpp/testing/unittest/registar.h> #include <util/generic/string.h> -#include <util/generic/array_size.h> -#include <util/system/env.h> +#include <util/generic/array_size.h> +#include <util/system/env.h> -#include "buffered.h" -#include "direct_io.h" +#include "buffered.h" +#include "direct_io.h" -Y_UNIT_TEST_SUITE(TDirectIOTests) { +Y_UNIT_TEST_SUITE(TDirectIOTests) { // Decrease numBufToWrite further if tests continue to time out static void Y_NO_INLINE Test(EOpenMode mode, size_t numBufToWrite) { - const char TEMPLATE[] = "qwertyuiopQWERTYUIOPasdfghjklASD"; - const auto TEMPLATE_SIZE = Y_ARRAY_SIZE(TEMPLATE) - 1; - static_assert(TEMPLATE_SIZE > 0, "must be greater than zero"); - - const size_t BUFFER_SIZE = 32 * 1024; - static_assert(0 == BUFFER_SIZE % TEMPLATE_SIZE, "must be divisible"); - - const size_t CHUNK_SIZE_TO_READ = 512; - static_assert(0 == CHUNK_SIZE_TO_READ % TEMPLATE_SIZE, "must be divisible"); - - // filling buffer - // TEMPLATE|TEMPLATE|TEMPLATE|... - auto&& buffer = TBuffer{BUFFER_SIZE}; - for (size_t i = 0; i < BUFFER_SIZE / TEMPLATE_SIZE; ++i) { - buffer.Append(TEMPLATE, TEMPLATE_SIZE); - } - - // filling file - // TEMPLATE|TEMPLATE|TEMPLATE|... + const char TEMPLATE[] = "qwertyuiopQWERTYUIOPasdfghjklASD"; + const auto TEMPLATE_SIZE = Y_ARRAY_SIZE(TEMPLATE) - 1; + static_assert(TEMPLATE_SIZE > 0, "must be greater than zero"); + + const size_t BUFFER_SIZE = 32 * 1024; + static_assert(0 == BUFFER_SIZE % TEMPLATE_SIZE, "must be divisible"); + + const size_t CHUNK_SIZE_TO_READ = 512; + static_assert(0 == CHUNK_SIZE_TO_READ % TEMPLATE_SIZE, "must be divisible"); + + // filling buffer + // TEMPLATE|TEMPLATE|TEMPLATE|... + auto&& buffer = TBuffer{BUFFER_SIZE}; + for (size_t i = 0; i < BUFFER_SIZE / TEMPLATE_SIZE; ++i) { + buffer.Append(TEMPLATE, TEMPLATE_SIZE); + } + + // filling file + // TEMPLATE|TEMPLATE|TEMPLATE|... const auto fileName = TString("test.file"); - auto&& directIOBuffer = TDirectIOBufferedFile{fileName, RdWr | CreateAlways | mode}; - { - auto&& output = TRandomAccessFileOutput{directIOBuffer}; + auto&& directIOBuffer = TDirectIOBufferedFile{fileName, RdWr | CreateAlways | mode}; + { + auto&& output = TRandomAccessFileOutput{directIOBuffer}; for (size_t i = 0; i < numBufToWrite; ++i) { - output.Write(buffer.Data(), BUFFER_SIZE); - } - } - - auto&& reader = TRandomAccessFileInput{directIOBuffer, 0}; - auto&& input = TBufferedInput{&reader, 1 << 17}; - auto bytesRead = size_t{}; - while (auto len = input.Read(buffer.Data(), CHUNK_SIZE_TO_READ)) { - bytesRead += len; - while (len) { - if (len < TEMPLATE_SIZE) { - UNIT_ASSERT(!memcmp(buffer.Data(), TEMPLATE, len)); - len = 0; - } else { - UNIT_ASSERT(!memcmp(buffer.Data(), TEMPLATE, TEMPLATE_SIZE)); - len -= TEMPLATE_SIZE; - } - } - } - + output.Write(buffer.Data(), BUFFER_SIZE); + } + } + + auto&& reader = TRandomAccessFileInput{directIOBuffer, 0}; + auto&& input = TBufferedInput{&reader, 1 << 17}; + auto bytesRead = size_t{}; + while (auto len = input.Read(buffer.Data(), CHUNK_SIZE_TO_READ)) { + bytesRead += len; + while (len) { + if (len < TEMPLATE_SIZE) { + UNIT_ASSERT(!memcmp(buffer.Data(), TEMPLATE, len)); + len = 0; + } else { + UNIT_ASSERT(!memcmp(buffer.Data(), TEMPLATE, TEMPLATE_SIZE)); + len -= TEMPLATE_SIZE; + } + } + } + UNIT_ASSERT_VALUES_EQUAL(bytesRead, numBufToWrite * BUFFER_SIZE); } - Y_UNIT_TEST(ReadWriteTest) { + Y_UNIT_TEST(ReadWriteTest) { Test(0, 100 * 32); - } - - Y_UNIT_TEST(ReadWriteDirectTest) { + } + + Y_UNIT_TEST(ReadWriteDirectTest) { Test(Direct, 100 * 4); - } - - Y_UNIT_TEST(ReadWriteDirectSeqTest) { + } + + Y_UNIT_TEST(ReadWriteDirectSeqTest) { Test(Direct | Seq, 100 * 4); } } diff --git a/util/stream/file.cpp b/util/stream/file.cpp index dc5d2f63112..348a7bfced9 100644 --- a/util/stream/file.cpp +++ b/util/stream/file.cpp @@ -30,7 +30,7 @@ size_t TUnbufferedFileInput::DoSkip(size_t len) { * actually doing one read is cheaper. Experiments show that the * border that separates two implementations performance-wise lies * in the range of 384-512 bytes (assuming that the file is in OS cache). */ - return IInputStream::DoSkip(len); + return IInputStream::DoSkip(len); } /* TFile::Seek can seek beyond the end of file, so we need to do @@ -81,14 +81,14 @@ public: }; TMappedFileInput::TMappedFileInput(const TFile& file) - : TMemoryInput(nullptr, 0) + : TMemoryInput(nullptr, 0) , Impl_(new TImpl(file)) { Reset(Impl_->Data(), Impl_->Size()); } TMappedFileInput::TMappedFileInput(const TString& path) - : TMemoryInput(nullptr, 0) + : TMemoryInput(nullptr, 0) , Impl_(new TImpl(TFile(path, OpenExisting | RdOnly))) { Reset(Impl_->Data(), Impl_->Size()); diff --git a/util/stream/file.h b/util/stream/file.h index c1cf4f591d4..1e5217debc1 100644 --- a/util/stream/file.h +++ b/util/stream/file.h @@ -1,6 +1,6 @@ #pragma once -#include "fwd.h" +#include "fwd.h" #include "input.h" #include "output.h" #include "buffered.h" diff --git a/util/stream/file_ut.cpp b/util/stream/file_ut.cpp index ac0f09796ee..b39e0d56f59 100644 --- a/util/stream/file_ut.cpp +++ b/util/stream/file_ut.cpp @@ -8,8 +8,8 @@ static const char* TmpFileName = "./fileio"; static const char* TmpFileContents = "To do good to Mankind is the chivalrous plan"; static const char* TmpFileSubstring = strstr(TmpFileContents, "chivalrous"); -Y_UNIT_TEST_SUITE(TFileTest) { - Y_UNIT_TEST(InputTest) { +Y_UNIT_TEST_SUITE(TFileTest) { + Y_UNIT_TEST(InputTest) { TTempFile tmp(TmpFileName); { @@ -42,7 +42,7 @@ Y_UNIT_TEST_SUITE(TFileTest) { } } - Y_UNIT_TEST(EmptyMapTest) { + Y_UNIT_TEST(EmptyMapTest) { TTempFile tmp(TmpFileName); { diff --git a/util/stream/format.cpp b/util/stream/format.cpp index 3996130df5d..25f01625526 100644 --- a/util/stream/format.cpp +++ b/util/stream/format.cpp @@ -11,7 +11,7 @@ namespace NFormatPrivate { return (value - res1 < res2 - value) ? (i64)res1 : (i64)res2; } - static inline IOutputStream& PrintDoubleShortly(IOutputStream& os, const double& d) { + static inline IOutputStream& PrintDoubleShortly(IOutputStream& os, const double& d) { // General case: request 3 significant digits // Side-effect: allows exponential representation EFloatToStringMode mode = PREC_NDIGITS; @@ -37,7 +37,7 @@ namespace NFormatPrivate { } template <> -void Out<NFormatPrivate::THumanReadableSize>(IOutputStream& stream, const NFormatPrivate::THumanReadableSize& value) { +void Out<NFormatPrivate::THumanReadableSize>(IOutputStream& stream, const NFormatPrivate::THumanReadableSize& value) { ui64 base = value.Format == SF_BYTES ? 1024 : 1000; ui64 base2 = base * base; ui64 base3 = base * base2; @@ -71,7 +71,7 @@ void Out<NFormatPrivate::THumanReadableSize>(IOutputStream& stream, const NForma } template <> -void Out<NFormatPrivate::THumanReadableDuration>(IOutputStream& os, const NFormatPrivate::THumanReadableDuration& hr) { +void Out<NFormatPrivate::THumanReadableDuration>(IOutputStream& os, const NFormatPrivate::THumanReadableDuration& hr) { TTempBuf buf; TMemoryOutput ss(buf.Data(), buf.Size()); @@ -107,7 +107,7 @@ void Out<NFormatPrivate::THumanReadableDuration>(IOutputStream& os, const NForma char names[] = {'d', 'h', 'm', 's'}; bool first = true; - for (size_t i = 0; i < Y_ARRAY_SIZE(times); ++i) { + for (size_t i = 0; i < Y_ARRAY_SIZE(times); ++i) { if (times[i] > 0) { if (!first) { ss << ' '; @@ -122,13 +122,13 @@ void Out<NFormatPrivate::THumanReadableDuration>(IOutputStream& os, const NForma os.Write(buf.Data(), written); } -void Time(IOutputStream& l) { +void Time(IOutputStream& l) { l << millisec(); } -void TimeHumanReadable(IOutputStream& l) { +void TimeHumanReadable(IOutputStream& l) { char timeStr[30]; - const time_t t = time(nullptr); + const time_t t = time(nullptr); l << ctime_r(&t, timeStr); } diff --git a/util/stream/format.h b/util/stream/format.h index b033208a1b0..98e5964f7ef 100644 --- a/util/stream/format.h +++ b/util/stream/format.h @@ -22,13 +22,13 @@ enum ESizeFormat { }; namespace NFormatPrivate { - template <size_t Value> + template <size_t Value> struct TLog2: std::integral_constant<size_t, TLog2<Value / 2>::value + 1> {}; - template <> + template <> struct TLog2<1>: std::integral_constant<size_t, 0> {}; - static inline void WriteChars(IOutputStream& os, char c, size_t count) { + static inline void WriteChars(IOutputStream& os, char c, size_t count) { if (count == 0) return; TTempBuf buf(count); @@ -51,7 +51,7 @@ namespace NFormatPrivate { }; template <typename T> - IOutputStream& operator<<(IOutputStream& o, const TLeftPad<T>& lp) { + IOutputStream& operator<<(IOutputStream& o, const TLeftPad<T>& lp) { TTempBuf buf; TMemoryOutput ss(buf.Data(), buf.Size()); ss << lp.Value; @@ -78,7 +78,7 @@ namespace NFormatPrivate { }; template <typename T> - IOutputStream& operator<<(IOutputStream& o, const TRightPad<T>& lp) { + IOutputStream& operator<<(IOutputStream& o, const TRightPad<T>& lp) { TTempBuf buf; TMemoryOutput ss(buf.Data(), buf.Size()); ss << lp.Value; @@ -107,7 +107,7 @@ namespace NFormatPrivate { using TUnsignedBaseNumber = TBaseNumber<std::make_unsigned_t<std::remove_cv_t<T>>, Base>; template <typename T, size_t Base> - IOutputStream& operator<<(IOutputStream& stream, const TBaseNumber<T, Base>& value) { + IOutputStream& operator<<(IOutputStream& stream, const TBaseNumber<T, Base>& value) { char buf[8 * sizeof(T) + 1]; /* Add 1 for sign. */ TStringBuf str(buf, IntToString<Base>(value.Value, buf, sizeof(buf))); @@ -143,7 +143,7 @@ namespace NFormatPrivate { }; template <typename Char, size_t Base> - IOutputStream& operator<<(IOutputStream& os, const TBaseText<Char, Base>& text) { + IOutputStream& operator<<(IOutputStream& os, const TBaseText<Char, Base>& text) { for (size_t i = 0; i < text.Text.size(); ++i) { if (i != 0) { os << ' '; @@ -164,7 +164,7 @@ namespace NFormatPrivate { }; template <typename T> - IOutputStream& operator<<(IOutputStream& o, const TFloatPrecision<T>& prec) { + IOutputStream& operator<<(IOutputStream& o, const TFloatPrecision<T>& prec) { char buf[512]; size_t count = FloatToString(prec.Value, buf, sizeof(buf), prec.Mode, prec.NDigits); o << TStringBuf(buf, count); @@ -174,7 +174,7 @@ namespace NFormatPrivate { struct THumanReadableDuration { TDuration Value; - constexpr THumanReadableDuration(const TDuration& value) + constexpr THumanReadableDuration(const TDuration& value) : Value(value) { } @@ -190,7 +190,7 @@ namespace NFormatPrivate { * Output manipulator basically equivalent to `std::setw` and `std::setfill` * combined. * - * When written into a `IOutputStream`, writes out padding characters first, + * When written into a `IOutputStream`, writes out padding characters first, * and then provided value. * * Example usage: @@ -204,7 +204,7 @@ namespace NFormatPrivate { * @see RightPad */ template <typename T> -static constexpr ::NFormatPrivate::TLeftPad<T> LeftPad(const T& value, const size_t width, const char padc = ' ') noexcept { +static constexpr ::NFormatPrivate::TLeftPad<T> LeftPad(const T& value, const size_t width, const char padc = ' ') noexcept { return ::NFormatPrivate::TLeftPad<T>(value, width, padc); } @@ -216,7 +216,7 @@ static constexpr ::NFormatPrivate::TLeftPad<const T*> LeftPad(const T (&value)[N /** * Output manipulator similar to `std::setw` and `std::setfill`. * - * When written into a `IOutputStream`, writes provided value first, and then + * When written into a `IOutputStream`, writes provided value first, and then * the padding characters. * * Example usage: @@ -230,7 +230,7 @@ static constexpr ::NFormatPrivate::TLeftPad<const T*> LeftPad(const T (&value)[N * @see LeftPad */ template <typename T> -static constexpr ::NFormatPrivate::TRightPad<T> RightPad(const T& value, const size_t width, const char padc = ' ') noexcept { +static constexpr ::NFormatPrivate::TRightPad<T> RightPad(const T& value, const size_t width, const char padc = ' ') noexcept { return ::NFormatPrivate::TRightPad<T>(value, width, padc); } @@ -242,7 +242,7 @@ static constexpr ::NFormatPrivate::TRightPad<const T*> RightPad(const T (&value) /** * Output manipulator similar to `std::setbase(16)`. * - * When written into a `IOutputStream`, writes out the provided value in + * When written into a `IOutputStream`, writes out the provided value in * hexadecimal form. The value is treated as unsigned, even if its type is in * fact signed. * @@ -263,7 +263,7 @@ static constexpr ::NFormatPrivate::TUnsignedBaseNumber<T, 16> Hex(const T& value /** * Output manipulator similar to `std::setbase(16)`. * - * When written into a `IOutputStream`, writes out the provided value in + * When written into a `IOutputStream`, writes out the provided value in * hexadecimal form. * * Example usage: @@ -283,7 +283,7 @@ static constexpr ::NFormatPrivate::TBaseNumber<T, 16> SHex(const T& value, const /** * Output manipulator similar to `std::setbase(2)`. * - * When written into a `IOutputStream`, writes out the provided value in + * When written into a `IOutputStream`, writes out the provided value in * binary form. The value is treated as unsigned, even if its type is in * fact signed. * @@ -304,7 +304,7 @@ static constexpr ::NFormatPrivate::TUnsignedBaseNumber<T, 2> Bin(const T& value, /** * Output manipulator similar to `std::setbase(2)`. * - * When written into a `IOutputStream`, writes out the provided value in + * When written into a `IOutputStream`, writes out the provided value in * binary form. * * Example usage: @@ -324,7 +324,7 @@ static constexpr ::NFormatPrivate::TBaseNumber<T, 2> SBin(const T& value, const /** * Output manipulator for hexadecimal string output. * - * When written into a `IOutputStream`, writes out the provided characters + * When written into a `IOutputStream`, writes out the provided characters * in hexadecimal form divided by space character. * * Example usage: @@ -343,7 +343,7 @@ static inline ::NFormatPrivate::TBaseText<TChar, 16> HexText(const TBasicStringB /** * Output manipulator for binary string output. * - * When written into a `IOutputStream`, writes out the provided characters + * When written into a `IOutputStream`, writes out the provided characters * in binary form divided by space character. * * Example usage: @@ -361,7 +361,7 @@ static inline ::NFormatPrivate::TBaseText<TChar, 2> BinText(const TBasicStringBu /** * Output manipulator for printing `TDuration` values. * - * When written into a `IOutputStream`, writes out the provided `TDuration` + * When written into a `IOutputStream`, writes out the provided `TDuration` * in auto-adjusted human-readable format. * * Example usage: @@ -372,7 +372,7 @@ static inline ::NFormatPrivate::TBaseText<TChar, 2> BinText(const TBasicStringBu * * @param value Value to output. */ -static constexpr ::NFormatPrivate::THumanReadableDuration HumanReadable(const TDuration duration) noexcept { +static constexpr ::NFormatPrivate::THumanReadableDuration HumanReadable(const TDuration duration) noexcept { return ::NFormatPrivate::THumanReadableDuration(duration); } @@ -380,7 +380,7 @@ static constexpr ::NFormatPrivate::THumanReadableDuration HumanReadable(const TD * Output manipulator for writing out human-readable number of elements / memory * amount in `ls -h` style. * - * When written into a `IOutputStream`, writes out the provided unsigned integer + * When written into a `IOutputStream`, writes out the provided unsigned integer * variable with small precision and a suffix (like 'K', 'M', 'G' for numbers, or * 'B', 'KiB', 'MiB', 'GiB' for bytes). * @@ -400,13 +400,13 @@ static constexpr ::NFormatPrivate::THumanReadableSize HumanReadableSize(const do return {size, format}; } -void Time(IOutputStream& l); -void TimeHumanReadable(IOutputStream& l); +void Time(IOutputStream& l); +void TimeHumanReadable(IOutputStream& l); /** * Output manipulator for adjusting precision of floating point values. * - * When written into a `IOutputStream`, writes out the provided floating point + * When written into a `IOutputStream`, writes out the provided floating point * variable with given precision. The behavior depends on provided `mode`. * * Example usage: @@ -420,14 +420,14 @@ void TimeHumanReadable(IOutputStream& l); * @see EFloatToStringMode */ template <typename T> -static constexpr ::NFormatPrivate::TFloatPrecision<T> Prec(const T& value, const EFloatToStringMode mode, const int ndigits = 0) noexcept { +static constexpr ::NFormatPrivate::TFloatPrecision<T> Prec(const T& value, const EFloatToStringMode mode, const int ndigits = 0) noexcept { return {value, mode, ndigits}; } /** * Output manipulator for adjusting precision of floating point values. * - * When written into a `IOutputStream`, writes out the provided floating point + * When written into a `IOutputStream`, writes out the provided floating point * variable with given precision. The behavior is equivalent to `Prec(value, PREC_NDIGITS, ndigits)`. * * Example usage: @@ -439,6 +439,6 @@ static constexpr ::NFormatPrivate::TFloatPrecision<T> Prec(const T& value, const * @param ndigits Number of significant digits. */ template <typename T> -static constexpr ::NFormatPrivate::TFloatPrecision<T> Prec(const T& value, const int ndigits) noexcept { +static constexpr ::NFormatPrivate::TFloatPrecision<T> Prec(const T& value, const int ndigits) noexcept { return {value, PREC_NDIGITS, ndigits}; } diff --git a/util/stream/format_ut.cpp b/util/stream/format_ut.cpp index 43245aeb48e..a51d8307f9c 100644 --- a/util/stream/format_ut.cpp +++ b/util/stream/format_ut.cpp @@ -3,8 +3,8 @@ #include <library/cpp/testing/unittest/registar.h> #include <util/charset/wide.h> -Y_UNIT_TEST_SUITE(TOutputStreamFormattingTest) { - Y_UNIT_TEST(TestLeftPad) { +Y_UNIT_TEST_SUITE(TOutputStreamFormattingTest) { + Y_UNIT_TEST(TestLeftPad) { TStringStream ss; ss << LeftPad(10, 4, '0'); UNIT_ASSERT_VALUES_EQUAL("0010", ss.Str()); @@ -14,7 +14,7 @@ Y_UNIT_TEST_SUITE(TOutputStreamFormattingTest) { UNIT_ASSERT_VALUES_EQUAL("222", ss.Str()); } - Y_UNIT_TEST(TestRightPad) { + Y_UNIT_TEST(TestRightPad) { TStringStream ss; ss << RightPad("aa", 4); UNIT_ASSERT_VALUES_EQUAL("aa ", ss.Str()); @@ -24,14 +24,14 @@ Y_UNIT_TEST_SUITE(TOutputStreamFormattingTest) { UNIT_ASSERT_VALUES_EQUAL("aa", ss.Str()); } - Y_UNIT_TEST(TestTime) { + Y_UNIT_TEST(TestTime) { TStringStream ss; ss << "[" << Time << "] " << "qwqw" << TimeHumanReadable << Endl; } - Y_UNIT_TEST(TestHexReference) { + Y_UNIT_TEST(TestHexReference) { /* One possible implementation of Hex() stores a reference to the given object. This can lead to wrong results if the given object is a temporary @@ -46,7 +46,7 @@ Y_UNIT_TEST_SUITE(TOutputStreamFormattingTest) { UNIT_ASSERT_VALUES_EQUAL("0x01234567", ss->Str()); } - Y_UNIT_TEST(TestHexText) { + Y_UNIT_TEST(TestHexText) { { TStringStream ss; ss << HexText(TStringBuf("abcи")); @@ -60,13 +60,13 @@ Y_UNIT_TEST_SUITE(TOutputStreamFormattingTest) { } } - Y_UNIT_TEST(TestBin) { + Y_UNIT_TEST(TestBin) { UNIT_ASSERT_VALUES_EQUAL(ToString(Bin(static_cast<ui32>(2), nullptr)), "10"); UNIT_ASSERT_VALUES_EQUAL(ToString(SBin(static_cast<i32>(-2), nullptr)), "-10"); UNIT_ASSERT_VALUES_EQUAL(ToString(SBin(static_cast<i32>(-2))), "-0b00000000000000000000000000000010"); UNIT_ASSERT_VALUES_EQUAL(ToString(SBin(static_cast<i32>(-2), HF_FULL)), "-00000000000000000000000000000010"); UNIT_ASSERT_VALUES_EQUAL(ToString(Bin(static_cast<ui32>(15), nullptr)), "1111"); - UNIT_ASSERT_VALUES_EQUAL(ToString(Bin(static_cast<ui32>(1))), "0b00000000000000000000000000000001"); + UNIT_ASSERT_VALUES_EQUAL(ToString(Bin(static_cast<ui32>(1))), "0b00000000000000000000000000000001"); UNIT_ASSERT_VALUES_EQUAL(ToString(Bin(static_cast<ui32>(-1))), "0b11111111111111111111111111111111"); UNIT_ASSERT_VALUES_EQUAL(ToString(Bin(static_cast<i32>(-1))), "0b11111111111111111111111111111111"); UNIT_ASSERT_VALUES_EQUAL(ToString(Bin(static_cast<i32>(-1), nullptr)), "11111111111111111111111111111111"); @@ -75,13 +75,13 @@ Y_UNIT_TEST_SUITE(TOutputStreamFormattingTest) { UNIT_ASSERT_VALUES_EQUAL(ToString(Bin(static_cast<ui64>(1234587912357ull))), "0b0000000000000000000000010001111101110011001011001000100010100101"); } - Y_UNIT_TEST(TestBinText) { + Y_UNIT_TEST(TestBinText) { UNIT_ASSERT_VALUES_EQUAL(ToString(BinText(TStringBuf("\1"))), "00000001"); UNIT_ASSERT_VALUES_EQUAL(ToString(BinText(TStringBuf("\1\1"))), "00000001 00000001"); UNIT_ASSERT_VALUES_EQUAL(ToString(BinText(TStringBuf("aaa"))), "01100001 01100001 01100001"); } - Y_UNIT_TEST(TestPrec) { + Y_UNIT_TEST(TestPrec) { TStringStream ss; ss << Prec(1.2345678901234567, PREC_AUTO); UNIT_ASSERT_VALUES_EQUAL("1.2345678901234567", ss.Str()); @@ -95,7 +95,7 @@ Y_UNIT_TEST_SUITE(TOutputStreamFormattingTest) { UNIT_ASSERT_VALUES_EQUAL("1.235", ss.Str()); } - Y_UNIT_TEST(TestHumanReadableSize1000) { + Y_UNIT_TEST(TestHumanReadableSize1000) { UNIT_ASSERT_VALUES_EQUAL(ToString(HumanReadableSize(0, SF_QUANTITY)), "0"); UNIT_ASSERT_VALUES_EQUAL(ToString(HumanReadableSize(1, SF_QUANTITY)), "1"); @@ -111,7 +111,7 @@ Y_UNIT_TEST_SUITE(TOutputStreamFormattingTest) { UNIT_ASSERT_VALUES_EQUAL(ToString(HumanReadableSize(-12345678 * 1000ll, SF_QUANTITY)), "-12.3G"); } - Y_UNIT_TEST(TestHumanReadableSize1024) { + Y_UNIT_TEST(TestHumanReadableSize1024) { UNIT_ASSERT_VALUES_EQUAL(ToString(HumanReadableSize(0, SF_BYTES)), "0B"); UNIT_ASSERT_VALUES_EQUAL(ToString(HumanReadableSize(100, SF_BYTES)), "100B"); @@ -161,7 +161,7 @@ Y_UNIT_TEST_SUITE(TOutputStreamFormattingTest) { UNIT_ASSERT_VALUES_EQUAL(ToString(HumanReadableSize(-1010ll * 1024 * 1024 * 1024 * 1024, SF_BYTES)), "-1010TiB"); } - Y_UNIT_TEST(TestHumanReadableDuration) { + Y_UNIT_TEST(TestHumanReadableDuration) { UNIT_ASSERT_VALUES_EQUAL(ToString(HumanReadable(TDuration::MicroSeconds(0))), "0us"); UNIT_ASSERT_VALUES_EQUAL(ToString(HumanReadable(TDuration::MicroSeconds(1))), "1us"); UNIT_ASSERT_VALUES_EQUAL(ToString(HumanReadable(TDuration::MicroSeconds(100))), "100us"); diff --git a/util/stream/fwd.cpp b/util/stream/fwd.cpp index 4214b6df83e..2261ef316c5 100644 --- a/util/stream/fwd.cpp +++ b/util/stream/fwd.cpp @@ -1 +1 @@ -#include "fwd.h" +#include "fwd.h" diff --git a/util/stream/fwd.h b/util/stream/fwd.h index 307676c6a7f..3f0b89299ba 100644 --- a/util/stream/fwd.h +++ b/util/stream/fwd.h @@ -1,100 +1,100 @@ -#pragma once - -#include <util/system/types.h> - -class IInputStream; -class IOutputStream; - -class IZeroCopyInput; -class IZeroCopyInputFastReadTo; +#pragma once + +#include <util/system/types.h> + +class IInputStream; +class IOutputStream; + +class IZeroCopyInput; +class IZeroCopyInputFastReadTo; class IZeroCopyOutput; - -using TStreamManipulator = void (*)(IOutputStream&); - -class TLengthLimitedInput; -class TCountingInput; -class TCountingOutput; - -class TMemoryInput; -class TMemoryOutput; -class TMemoryWriteBuffer; - -class TMultiInput; - -class TNullInput; -class TNullOutput; -class TNullIO; - -class TPipeBase; -class TPipeInput; -class TPipeOutput; -class TPipedBase; -class TPipedInput; -class TPipedOutput; - -class TStringInput; -class TStringOutput; -class TStringStream; - -class TTeeOutput; - + +using TStreamManipulator = void (*)(IOutputStream&); + +class TLengthLimitedInput; +class TCountingInput; +class TCountingOutput; + +class TMemoryInput; +class TMemoryOutput; +class TMemoryWriteBuffer; + +class TMultiInput; + +class TNullInput; +class TNullOutput; +class TNullIO; + +class TPipeBase; +class TPipeInput; +class TPipeOutput; +class TPipedBase; +class TPipedInput; +class TPipedOutput; + +class TStringInput; +class TStringOutput; +class TStringStream; + +class TTeeOutput; + class TTempBufOutput; - -struct TEol; - -template <typename TEndOfToken> -class TStreamTokenizer; - + +struct TEol; + +template <typename TEndOfToken> +class TStreamTokenizer; + enum ETraceLevel: ui8; - -class IWalkInput; - -struct TZLibError; -struct TZLibCompressorError; -struct TZLibDecompressorError; - -namespace ZLib { + +class IWalkInput; + +struct TZLibError; +struct TZLibCompressorError; +struct TZLibDecompressorError; + +namespace ZLib { enum StreamType: ui8; -} - +} + class TZLibDecompress; -class TZLibCompress; -class TBufferedZLibDecompress; - -using TZDecompress = TBufferedZLibDecompress; - -class TAlignedInput; -class TAlignedOutput; - -class TBufferInput; -class TBufferOutput; -class TBufferStream; - -class TBufferedInput; -class TBufferedOutputBase; -class TBufferedOutput; -class TAdaptiveBufferedOutput; - -template <class TSlave> -class TBuffered; - -template <class TSlave> -class TAdaptivelyBuffered; - -class TDebugOutput; - -class TRandomAccessFileInput; -class TRandomAccessFileOutput; -class TBufferedFileOutputEx; - -class TUnbufferedFileInput; -class TMappedFileInput; -class TUnbufferedFileOutput; - -class TFileInput; -using TIFStream = TFileInput; - -class TFixedBufferFileOutput; -using TOFStream = TFixedBufferFileOutput; - -using TFileOutput = TAdaptivelyBuffered<TUnbufferedFileOutput>; +class TZLibCompress; +class TBufferedZLibDecompress; + +using TZDecompress = TBufferedZLibDecompress; + +class TAlignedInput; +class TAlignedOutput; + +class TBufferInput; +class TBufferOutput; +class TBufferStream; + +class TBufferedInput; +class TBufferedOutputBase; +class TBufferedOutput; +class TAdaptiveBufferedOutput; + +template <class TSlave> +class TBuffered; + +template <class TSlave> +class TAdaptivelyBuffered; + +class TDebugOutput; + +class TRandomAccessFileInput; +class TRandomAccessFileOutput; +class TBufferedFileOutputEx; + +class TUnbufferedFileInput; +class TMappedFileInput; +class TUnbufferedFileOutput; + +class TFileInput; +using TIFStream = TFileInput; + +class TFixedBufferFileOutput; +using TOFStream = TFixedBufferFileOutput; + +using TFileOutput = TAdaptivelyBuffered<TUnbufferedFileOutput>; diff --git a/util/stream/hex.cpp b/util/stream/hex.cpp index 1c05330504a..639a7d93700 100644 --- a/util/stream/hex.cpp +++ b/util/stream/hex.cpp @@ -3,7 +3,7 @@ #include "output.h" #include <util/string/hex.h> -void HexEncode(const void* in, size_t len, IOutputStream& out) { +void HexEncode(const void* in, size_t len, IOutputStream& out) { static const size_t NUM_OF_BYTES = 32; char buffer[NUM_OF_BYTES * 2]; @@ -15,7 +15,7 @@ void HexEncode(const void* in, size_t len, IOutputStream& out) { } } -void HexDecode(const void* in, size_t len, IOutputStream& out) { +void HexDecode(const void* in, size_t len, IOutputStream& out) { Y_ENSURE(!(len & 1), TStringBuf("Odd buffer length passed to HexDecode")); static const size_t NUM_OF_BYTES = 32; diff --git a/util/stream/hex.h b/util/stream/hex.h index a018933b1b3..abe13e30cab 100644 --- a/util/stream/hex.h +++ b/util/stream/hex.h @@ -2,7 +2,7 @@ #include <util/system/types.h> -class IOutputStream; +class IOutputStream; -void HexEncode(const void* in, size_t len, IOutputStream& out); -void HexDecode(const void* in, size_t len, IOutputStream& out); +void HexEncode(const void* in, size_t len, IOutputStream& out); +void HexDecode(const void* in, size_t len, IOutputStream& out); diff --git a/util/stream/hex_ut.cpp b/util/stream/hex_ut.cpp index 5074a0b6168..81c26b27c24 100644 --- a/util/stream/hex_ut.cpp +++ b/util/stream/hex_ut.cpp @@ -3,7 +3,7 @@ #include <library/cpp/testing/unittest/registar.h> #include "str.h" -Y_UNIT_TEST_SUITE(THexCodingTest) { +Y_UNIT_TEST_SUITE(THexCodingTest) { void TestImpl(const TString& data) { TString encoded; TStringOutput encodedOut(encoded); @@ -18,12 +18,12 @@ Y_UNIT_TEST_SUITE(THexCodingTest) { UNIT_ASSERT_EQUAL(decoded, data); } - Y_UNIT_TEST(TestEncodeDecodeToStream) { + Y_UNIT_TEST(TestEncodeDecodeToStream) { TString data = "100ABAcaba500,$%0987123456 \n\t\x01\x02\x03."; TestImpl(data); } - Y_UNIT_TEST(TestEmpty) { + Y_UNIT_TEST(TestEmpty) { TestImpl(""); } } diff --git a/util/stream/holder.h b/util/stream/holder.h index c60a4e510ca..fabbc860b15 100644 --- a/util/stream/holder.h +++ b/util/stream/holder.h @@ -5,18 +5,18 @@ #include <utility> #include <type_traits> -class IInputStream; -class IOutputStream; +class IInputStream; +class IOutputStream; namespace NPrivate { - template <class Stream, bool isInput = std::is_base_of<IInputStream, Stream>::value> + template <class Stream, bool isInput = std::is_base_of<IInputStream, Stream>::value> struct TStreamBase { - using TType = IInputStream; + using TType = IInputStream; }; template <class Stream> struct TStreamBase<Stream, false> { - using TType = IOutputStream; + using TType = IOutputStream; }; } diff --git a/util/stream/input.cpp b/util/stream/input.cpp index 6e8170f2f9f..a365b9c0d06 100644 --- a/util/stream/input.cpp +++ b/util/stream/input.cpp @@ -13,11 +13,11 @@ #include <cstdlib> -IInputStream::IInputStream() noexcept = default; +IInputStream::IInputStream() noexcept = default; -IInputStream::~IInputStream() = default; +IInputStream::~IInputStream() = default; -size_t IInputStream::DoReadTo(TString& st, char to) { +size_t IInputStream::DoReadTo(TString& st, char to) { char ch; if (!Read(&ch, 1)) { @@ -40,7 +40,7 @@ size_t IInputStream::DoReadTo(TString& st, char to) { return result; } -ui64 IInputStream::DoReadAll(IOutputStream& out) { +ui64 IInputStream::DoReadAll(IOutputStream& out) { TTempBuf buffer; void* ptr = buffer.Data(); size_t size = buffer.Size(); @@ -54,7 +54,7 @@ ui64 IInputStream::DoReadAll(IOutputStream& out) { return result; } -size_t IInputStream::Load(void* buf_in, size_t len) { +size_t IInputStream::Load(void* buf_in, size_t len) { char* buf = (char*)buf_in; while (len) { @@ -71,14 +71,14 @@ size_t IInputStream::Load(void* buf_in, size_t len) { return buf - (char*)buf_in; } -void IInputStream::LoadOrFail(void* buf, size_t len) { +void IInputStream::LoadOrFail(void* buf, size_t len) { const size_t realLen = Load(buf, len); - if (Y_UNLIKELY(realLen != len)) { + if (Y_UNLIKELY(realLen != len)) { ythrow yexception() << "Failed to read required number of bytes from stream! Expected: " << len << ", gained: " << realLen << "!"; } } -size_t IInputStream::ReadLine(TString& st) { +size_t IInputStream::ReadLine(TString& st) { const size_t ret = ReadTo(st, '\n'); if (ret && !st.empty() && st.back() == '\r') { @@ -88,7 +88,7 @@ size_t IInputStream::ReadLine(TString& st) { return ret; } -size_t IInputStream::ReadLine(TUtf16String& w) { +size_t IInputStream::ReadLine(TUtf16String& w) { TString s; size_t result = ReadLine(s); @@ -99,7 +99,7 @@ size_t IInputStream::ReadLine(TUtf16String& w) { return result; } -TString IInputStream::ReadLine() { +TString IInputStream::ReadLine() { TString ret; if (!ReadLine(ret)) { @@ -109,7 +109,7 @@ TString IInputStream::ReadLine() { return ret; } -TString IInputStream::ReadTo(char ch) { +TString IInputStream::ReadTo(char ch) { TString ret; if (!ReadTo(ret, ch)) { @@ -119,11 +119,11 @@ TString IInputStream::ReadTo(char ch) { return ret; } -size_t IInputStream::Skip(size_t sz) { +size_t IInputStream::Skip(size_t sz) { return DoSkip(sz); } -size_t IInputStream::DoSkip(size_t sz) { +size_t IInputStream::DoSkip(size_t sz) { if (sz < 128) { return Load(alloca(sz), sz); } @@ -145,7 +145,7 @@ size_t IInputStream::DoSkip(size_t sz) { return total; } -TString IInputStream::ReadAll() { +TString IInputStream::ReadAll() { TString result; TStringOutput stream(result); @@ -154,16 +154,16 @@ TString IInputStream::ReadAll() { return result; } -ui64 IInputStream::ReadAll(IOutputStream& out) { +ui64 IInputStream::ReadAll(IOutputStream& out) { return DoReadAll(out); } -ui64 TransferData(IInputStream* in, IOutputStream* out) { +ui64 TransferData(IInputStream* in, IOutputStream* out) { return in->ReadAll(*out); } namespace { - struct TStdIn: public IInputStream { + struct TStdIn: public IInputStream { ~TStdIn() override = default; size_t DoRead(void* buf, size_t len) override { @@ -250,7 +250,7 @@ namespace { #endif } -IInputStream& NPrivate::StdInStream() noexcept { +IInputStream& NPrivate::StdInStream() noexcept { return *SingletonWithPriority<TGetLine, 4>(); } @@ -262,7 +262,7 @@ static inline bool IsStdDelimiter(char c) { return (c == '\0') || (c == ' ') || (c == '\r') || (c == '\n') || (c == '\t'); } -static void ReadUpToDelimiter(IInputStream& i, TString& s) { +static void ReadUpToDelimiter(IInputStream& i, TString& s) { char c; while (i.ReadChar(c)) { // skip delimiters if (!IsStdDelimiter(c)) { @@ -278,13 +278,13 @@ static void ReadUpToDelimiter(IInputStream& i, TString& s) { // specialization for string-related stuff template <> -void In<TString>(IInputStream& i, TString& s) { +void In<TString>(IInputStream& i, TString& s) { s.resize(0); ReadUpToDelimiter(i, s); } template <> -void In<TUtf16String>(IInputStream& i, TUtf16String& w) { +void In<TUtf16String>(IInputStream& i, TUtf16String& w) { TString s; ReadUpToDelimiter(i, s); @@ -299,7 +299,7 @@ void In<TUtf16String>(IInputStream& i, TUtf16String& w) { #define SPEC_FOR_CHAR(T) \ template <> \ - void In<T>(IInputStream & i, T & t) { \ + void In<T>(IInputStream & i, T & t) { \ i.ReadChar((char&)t); \ } @@ -313,7 +313,7 @@ SPEC_FOR_CHAR(signed char) #define SPEC_FOR_NUMBER(T) \ template <> \ - void In<T>(IInputStream & i, T & t) { \ + void In<T>(IInputStream & i, T & t) { \ char buf[128]; \ size_t pos = 0; \ while (i.ReadChar(buf[0])) { \ diff --git a/util/stream/input.h b/util/stream/input.h index f0d5807ed27..4858660457f 100644 --- a/util/stream/input.h +++ b/util/stream/input.h @@ -4,7 +4,7 @@ #include <util/generic/noncopyable.h> #include <util/system/defaults.h> -class IOutputStream; +class IOutputStream; /** * @addtogroup Streams_Base @@ -14,15 +14,15 @@ class IOutputStream; /** * Abstract input stream. */ -class IInputStream: public TNonCopyable { +class IInputStream: public TNonCopyable { public: - IInputStream() noexcept; - virtual ~IInputStream(); + IInputStream() noexcept; + virtual ~IInputStream(); - IInputStream(IInputStream&&) noexcept { + IInputStream(IInputStream&&) noexcept { } - IInputStream& operator=(IInputStream&&) noexcept { + IInputStream& operator=(IInputStream&&) noexcept { return *this; } @@ -107,7 +107,7 @@ public: * @param out Output stream to use. * @returns Total number of characters read from the stream. */ - ui64 ReadAll(IOutputStream& out); + ui64 ReadAll(IOutputStream& out); /** * Reads all data from the stream until the first occurrence of '\n'. Also @@ -215,7 +215,7 @@ protected: * this stream. * @throws yexception If IO error occurs. */ - virtual ui64 DoReadAll(IOutputStream& out); + virtual ui64 DoReadAll(IOutputStream& out); }; /** @@ -224,10 +224,10 @@ protected: * @param in Input stream. * @param out Output stream. */ -ui64 TransferData(IInputStream* in, IOutputStream* out); +ui64 TransferData(IInputStream* in, IOutputStream* out); /** - * `operator>>` for `IInputStream` by default delegates to this function. + * `operator>>` for `IInputStream` by default delegates to this function. * * Note that while `operator>>` uses overloading (and thus argument-dependent * lookup), `In` uses template specializations. This makes it possible to @@ -241,10 +241,10 @@ ui64 TransferData(IInputStream* in, IOutputStream* out); * @param in Input stream to read from. * @param[out] value Value to read. * @throws `yexception` on invalid input or end of stream. - * @see Out(IOutputStream&, T&) + * @see Out(IOutputStream&, T&) */ template <typename T> -void In(IInputStream& in, T& value); +void In(IInputStream& in, T& value); /** * Reads a value from the stream. @@ -253,16 +253,16 @@ void In(IInputStream& in, T& value); * @param[out] value Value to read. * @returns Input stream. * @throws `yexception` on invalid input or end of stream. - * @see operator<<(IOutputStream&, T&) + * @see operator<<(IOutputStream&, T&) */ template <typename T> -inline IInputStream& operator>>(IInputStream& in, T& value) { +inline IInputStream& operator>>(IInputStream& in, T& value) { In<T>(in, value); return in; } namespace NPrivate { - IInputStream& StdInStream() noexcept; + IInputStream& StdInStream() noexcept; } /** diff --git a/util/stream/input_ut.cpp b/util/stream/input_ut.cpp index 4a93f5458e6..63e2d08c887 100644 --- a/util/stream/input_ut.cpp +++ b/util/stream/input_ut.cpp @@ -21,7 +21,7 @@ public: } template <typename FuncType> - void ForInput(const TStringBuf text, const FuncType& func) { + void ForInput(const TStringBuf text, const FuncType& func) { TFile tempFile(TFile::Temporary("input_ut")); tempFile.Write(text.data(), text.size()); tempFile.FlushData(); @@ -41,7 +41,7 @@ private: int StdInCopy_; }; -class TNoInput: public IInputStream { +class TNoInput: public IInputStream { public: TNoInput(ui64 size) : Size_(size) @@ -59,7 +59,7 @@ private: ui64 Size_; }; -class TNoOutput: public IOutputStream { +class TNoOutput: public IOutputStream { public: TNoOutput() = default; @@ -68,7 +68,7 @@ protected: } }; -class TSimpleStringInput: public IInputStream { +class TSimpleStringInput: public IInputStream { public: TSimpleStringInput(const TString& string) : String_(string) @@ -77,7 +77,7 @@ public: protected: size_t DoRead(void* buf, size_t len) override { - Y_ASSERT(len != 0); + Y_ASSERT(len != 0); if (String_.empty()) { return 0; @@ -92,8 +92,8 @@ private: TString String_; }; -Y_UNIT_TEST_SUITE(TInputTest) { - Y_UNIT_TEST(BigTransfer) { +Y_UNIT_TEST_SUITE(TInputTest) { + Y_UNIT_TEST(BigTransfer) { ui64 size = 1024ull * 1024ull * 1024ull * 5; TNoInput input(size); TNoOutput output; @@ -103,7 +103,7 @@ Y_UNIT_TEST_SUITE(TInputTest) { UNIT_ASSERT_VALUES_EQUAL(transferred, size); } - Y_UNIT_TEST(TestReadTo) { + Y_UNIT_TEST(TestReadTo) { /* This one tests default implementation of ReadTo. */ TSimpleStringInput in("0123456789abc"); @@ -117,7 +117,7 @@ Y_UNIT_TEST_SUITE(TInputTest) { UNIT_ASSERT_VALUES_EQUAL(t, "89abc"); } - Y_UNIT_TEST(TestReadLine) { + Y_UNIT_TEST(TestReadLine) { TSimpleStringInput in("1\n22\n333"); TString t; @@ -131,7 +131,7 @@ Y_UNIT_TEST_SUITE(TInputTest) { UNIT_ASSERT_VALUES_EQUAL(t, "333"); } - Y_UNIT_TEST(TestStdInReadTo) { + Y_UNIT_TEST(TestStdInReadTo) { std::pair<std::pair<TStringBuf, char>, TStringBuf> testPairs[] = { {{"", '\n'}, ""}, {{"\n", '\n'}, ""}, diff --git a/util/stream/ios_ut.cpp b/util/stream/ios_ut.cpp index 139f4296e50..30ae17cdf4a 100644 --- a/util/stream/ios_ut.cpp +++ b/util/stream/ios_ut.cpp @@ -1,7 +1,7 @@ -#include "output.h" +#include "output.h" #include "tokenizer.h" -#include "buffer.h" -#include "buffered.h" +#include "buffer.h" +#include "buffered.h" #include "walk.h" #include <library/cpp/testing/unittest/registar.h> @@ -169,7 +169,7 @@ void TStreamsTest::TestMemoryStream() { } } -class TMyStringOutput: public IOutputStream { +class TMyStringOutput: public IOutputStream { public: inline TMyStringOutput(TString& s, size_t buflen) noexcept : S_(s) @@ -279,7 +279,7 @@ void TStreamsTest::TestBufferStream() { } namespace { - class TStringListInput: public IWalkInput { + class TStringListInput: public IWalkInput { public: TStringListInput(const TVector<TString>& data) : Data_(data) @@ -331,7 +331,7 @@ namespace { "\rone two", "123", "\t\r "}; - void TestStreamReadTo1(IInputStream& input, const char* comment) { + void TestStreamReadTo1(IInputStream& input, const char* comment) { TString tmp; input.ReadTo(tmp, 'c'); UNIT_ASSERT_VALUES_EQUAL_C(tmp, "111a222b333", comment); @@ -347,7 +347,7 @@ namespace { UNIT_ASSERT_VALUES_EQUAL_C(tmp, "66f", comment); } - void TestStreamReadTo2(IInputStream& input, const char* comment) { + void TestStreamReadTo2(IInputStream& input, const char* comment) { TString s; size_t i = 0; while (input.ReadLine(s)) { @@ -357,17 +357,17 @@ namespace { } } - void TestStreamReadTo3(IInputStream& input, const char* comment) { + void TestStreamReadTo3(IInputStream& input, const char* comment) { UNIT_ASSERT_VALUES_EQUAL_C(input.ReadLine(), "111a222b333c444d555e666f", comment); } - void TestStreamReadTo4(IInputStream& input, const char* comment) { + void TestStreamReadTo4(IInputStream& input, const char* comment) { UNIT_ASSERT_VALUES_EQUAL_C(input.ReadTo('\0'), "one", comment); UNIT_ASSERT_VALUES_EQUAL_C(input.ReadTo('\0'), "two", comment); UNIT_ASSERT_VALUES_EQUAL_C(input.ReadTo('\0'), "three", comment); } - void TestStrokaInput(IInputStream& input, const char* comment) { + void TestStrokaInput(IInputStream& input, const char* comment) { TString line; ui32 i = 0; TInstant start = Now(); @@ -392,7 +392,7 @@ namespace { test(bdi, "TBufferedInput"); TVector<TString> lst(1, text); TStringListInput sli(lst); - test(sli, "IWalkInput"); + test(sli, "IWalkInput"); } } @@ -422,7 +422,7 @@ void TStreamsTest::TestWtrokaInput() { size_t i = 0; while (is.ReadLine(w)) { - UNIT_ASSERT(i < Y_ARRAY_SIZE(Expected)); + UNIT_ASSERT(i < Y_ARRAY_SIZE(Expected)); UNIT_ASSERT_VALUES_EQUAL(w, UTF8ToWide(Expected[i])); ++i; diff --git a/util/stream/labeled.h b/util/stream/labeled.h index 2cc539d241d..cd0017b00fe 100644 --- a/util/stream/labeled.h +++ b/util/stream/labeled.h @@ -13,7 +13,7 @@ * // Outputs "a = 1, b = 2, c = 3, a + b + c = 6" * @endcode */ -#define LabeledOutput(...) "" Y_PASS_VA_ARGS(Y_MAP_ARGS_WITH_LAST(__LABELED_OUTPUT_NONLAST__, __LABELED_OUTPUT_IMPL__, __VA_ARGS__)) +#define LabeledOutput(...) "" Y_PASS_VA_ARGS(Y_MAP_ARGS_WITH_LAST(__LABELED_OUTPUT_NONLAST__, __LABELED_OUTPUT_IMPL__, __VA_ARGS__)) #define __LABELED_OUTPUT_IMPL__(x) << #x " = " << (x) #define __LABELED_OUTPUT_NONLAST__(x) __LABELED_OUTPUT_IMPL__(x) << ", " diff --git a/util/stream/labeled_ut.cpp b/util/stream/labeled_ut.cpp index 12d0dc50040..f30fdebe8bb 100644 --- a/util/stream/labeled_ut.cpp +++ b/util/stream/labeled_ut.cpp @@ -2,8 +2,8 @@ #include <library/cpp/testing/unittest/registar.h> -Y_UNIT_TEST_SUITE(TLabeledOutputTest) { - Y_UNIT_TEST(TBasicTest) { +Y_UNIT_TEST_SUITE(TLabeledOutputTest) { + Y_UNIT_TEST(TBasicTest) { TStringStream out; int x = 3; out << LabeledOutput(x, 1, 2, 3 + 4); diff --git a/util/stream/length.cpp b/util/stream/length.cpp index 9907fe2ac94..04dfcedb492 100644 --- a/util/stream/length.cpp +++ b/util/stream/length.cpp @@ -34,7 +34,7 @@ size_t TCountingInput::DoReadTo(TString& st, char ch) { return ret; } -ui64 TCountingInput::DoReadAll(IOutputStream& out) { +ui64 TCountingInput::DoReadAll(IOutputStream& out) { const ui64 ret = Slave_->ReadAll(out); Count_ += ret; return ret; diff --git a/util/stream/length.h b/util/stream/length.h index 4d508ae24d2..79eb59e2e02 100644 --- a/util/stream/length.h +++ b/util/stream/length.h @@ -12,9 +12,9 @@ * This can be useful for breaking up the slave stream into small chunks and * treat these as separate streams. */ -class TLengthLimitedInput: public IInputStream { +class TLengthLimitedInput: public IInputStream { public: - inline TLengthLimitedInput(IInputStream* slave, ui64 length) noexcept + inline TLengthLimitedInput(IInputStream* slave, ui64 length) noexcept : Slave_(slave) , Length_(length) { @@ -31,16 +31,16 @@ private: size_t DoSkip(size_t len) override; private: - IInputStream* Slave_; + IInputStream* Slave_; ui64 Length_; }; /** * Proxy input stream that counts the number of characters read. */ -class TCountingInput: public IInputStream { +class TCountingInput: public IInputStream { public: - inline TCountingInput(IInputStream* slave) noexcept + inline TCountingInput(IInputStream* slave) noexcept : Slave_(slave) , Count_() { @@ -60,19 +60,19 @@ private: size_t DoRead(void* buf, size_t len) override; size_t DoSkip(size_t len) override; size_t DoReadTo(TString& st, char ch) override; - ui64 DoReadAll(IOutputStream& out) override; + ui64 DoReadAll(IOutputStream& out) override; private: - IInputStream* Slave_; + IInputStream* Slave_; ui64 Count_; }; /** * Proxy output stream that counts the number of characters written. */ -class TCountingOutput: public IOutputStream { +class TCountingOutput: public IOutputStream { public: - inline TCountingOutput(IOutputStream* slave) noexcept + inline TCountingOutput(IOutputStream* slave) noexcept : Slave_(slave) , Count_() { @@ -95,6 +95,6 @@ private: void DoWrite(const void* buf, size_t len) override; private: - IOutputStream* Slave_; + IOutputStream* Slave_; ui64 Count_; }; diff --git a/util/stream/length_ut.cpp b/util/stream/length_ut.cpp index 89684489544..9cc46216246 100644 --- a/util/stream/length_ut.cpp +++ b/util/stream/length_ut.cpp @@ -4,8 +4,8 @@ #include <util/generic/string.h> -Y_UNIT_TEST_SUITE(TestLengthIO) { - Y_UNIT_TEST(TestLengthLimitedInput) { +Y_UNIT_TEST_SUITE(TestLengthIO) { + Y_UNIT_TEST(TestLengthLimitedInput) { char buf[16]; TStringStream s1("abcd"); @@ -14,7 +14,7 @@ Y_UNIT_TEST_SUITE(TestLengthIO) { UNIT_ASSERT_VALUES_EQUAL(l1.Read(buf, 1), 0); } - Y_UNIT_TEST(TestCountingInput) { + Y_UNIT_TEST(TestCountingInput) { char buf[16]; TStringStream s1("abc\ndef\n"); @@ -34,7 +34,7 @@ Y_UNIT_TEST_SUITE(TestLengthIO) { UNIT_ASSERT_VALUES_EQUAL(l1.Counter(), 8); } - Y_UNIT_TEST(TestCountingOutput) { + Y_UNIT_TEST(TestCountingOutput) { TStringStream s1; TCountingOutput l1(&s1); diff --git a/util/stream/mem.cpp b/util/stream/mem.cpp index 22a3339e274..c352eb38947 100644 --- a/util/stream/mem.cpp +++ b/util/stream/mem.cpp @@ -14,7 +14,7 @@ TMemoryInput::TMemoryInput(const void* buf, size_t len) noexcept { } -TMemoryInput::TMemoryInput(const TStringBuf buf) noexcept +TMemoryInput::TMemoryInput(const TStringBuf buf) noexcept : Buf_(buf.data()) , Len_(buf.size()) { diff --git a/util/stream/mem.h b/util/stream/mem.h index 18a5d467729..bde672528d6 100644 --- a/util/stream/mem.h +++ b/util/stream/mem.h @@ -13,7 +13,7 @@ /** * Input stream that reads data from a memory block. */ -class TMemoryInput: public IZeroCopyInputFastReadTo { +class TMemoryInput: public IZeroCopyInputFastReadTo { public: TMemoryInput() noexcept; @@ -26,11 +26,11 @@ public: * @param len Size of the memory block. */ TMemoryInput(const void* buf, size_t len) noexcept; - explicit TMemoryInput(const TStringBuf buf) noexcept; + explicit TMemoryInput(const TStringBuf buf) noexcept; ~TMemoryInput() override; TMemoryInput(const TMemoryInput& other) noexcept - : IZeroCopyInputFastReadTo() + : IZeroCopyInputFastReadTo() , Buf_(other.Buf_) , Len_(other.Len_) { @@ -89,10 +89,10 @@ public: * * @param stream Zero copy stream to initialize from. */ - void Fill(IZeroCopyInput* stream) { + void Fill(IZeroCopyInput* stream) { Len_ = stream->Next(&Buf_); if (!Len_) { - Reset(nullptr, 0); + Reset(nullptr, 0); } } @@ -229,7 +229,7 @@ public: * this stream uses. */ void SetPos(char* ptr) { - Y_ASSERT(Beg_ <= ptr); + Y_ASSERT(Beg_ <= ptr); SetPosImpl(ptr); } @@ -244,7 +244,7 @@ public: protected: void SetPosImpl(char* ptr) { - Y_ASSERT(End_ >= ptr); + Y_ASSERT(End_ >= ptr); Buf_ = ptr; } diff --git a/util/stream/mem_ut.cpp b/util/stream/mem_ut.cpp index f388ae66acf..cd8c0474358 100644 --- a/util/stream/mem_ut.cpp +++ b/util/stream/mem_ut.cpp @@ -2,8 +2,8 @@ #include <library/cpp/testing/unittest/registar.h> -Y_UNIT_TEST_SUITE(TestMemIO) { - Y_UNIT_TEST(TestReadTo) { +Y_UNIT_TEST_SUITE(TestMemIO) { + Y_UNIT_TEST(TestReadTo) { TString s("0123456789abc"); TMemoryInput in(s); @@ -50,7 +50,7 @@ Y_UNIT_TEST_SUITE(TestMemIO) { UNIT_ASSERT(0 == memcmp(buffer, result, strlen(result))); } - Y_UNIT_TEST(Write) { + Y_UNIT_TEST(Write) { char buffer[20]; TMemoryOutput output(buffer, sizeof(buffer)); output << "1" @@ -67,7 +67,7 @@ Y_UNIT_TEST_SUITE(TestMemIO) { UNIT_ASSERT(0 == memcmp(buffer, result, strlen(result))); } - Y_UNIT_TEST(WriteChars) { + Y_UNIT_TEST(WriteChars) { char buffer[20]; TMemoryOutput output(buffer, sizeof(buffer)); output << '1' << '2' << '3' << '4' << '5' << '6' << '7' << '8' << '9' << '0'; diff --git a/util/stream/multi.cpp b/util/stream/multi.cpp index b2354298a0c..5866bad44a7 100644 --- a/util/stream/multi.cpp +++ b/util/stream/multi.cpp @@ -1,7 +1,7 @@ #include "null.h" #include "multi.h" -TMultiInput::TMultiInput(IInputStream* f, IInputStream* s) noexcept +TMultiInput::TMultiInput(IInputStream* f, IInputStream* s) noexcept : C_(f) , N_(s) { diff --git a/util/stream/multi.h b/util/stream/multi.h index 8bfd462d99e..aad061f23cd 100644 --- a/util/stream/multi.h +++ b/util/stream/multi.h @@ -10,9 +10,9 @@ /** * A proxy input stream that concatenates two slave streams into one. */ -class TMultiInput: public IInputStream { +class TMultiInput: public IInputStream { public: - TMultiInput(IInputStream* f, IInputStream* s) noexcept; + TMultiInput(IInputStream* f, IInputStream* s) noexcept; ~TMultiInput() override; private: @@ -21,8 +21,8 @@ private: size_t DoReadTo(TString& st, char ch) override; private: - IInputStream* C_; - IInputStream* N_; + IInputStream* C_; + IInputStream* N_; }; /** diff --git a/util/stream/multi_ut.cpp b/util/stream/multi_ut.cpp index fc2553b5339..2f16772196c 100644 --- a/util/stream/multi_ut.cpp +++ b/util/stream/multi_ut.cpp @@ -3,12 +3,12 @@ #include "str.h" #include <library/cpp/testing/unittest/registar.h> -Y_UNIT_TEST_SUITE(TestMultiInput) { +Y_UNIT_TEST_SUITE(TestMultiInput) { struct TTestCase { TMemoryInput Input1; TMemoryInput Input2; TMultiInput MultiInput; - TTestCase(const TStringBuf in1, const TStringBuf in2) + TTestCase(const TStringBuf in1, const TStringBuf in2) : Input1(in1) , Input2(in2) , MultiInput(&Input1, &Input2) @@ -23,7 +23,7 @@ Y_UNIT_TEST_SUITE(TestMultiInput) { } }; - Y_UNIT_TEST(TestReadTo) { + Y_UNIT_TEST(TestReadTo) { TString t; TTestCase simpleCase("0123456789abc", "defghijk"); @@ -32,7 +32,7 @@ Y_UNIT_TEST_SUITE(TestMultiInput) { simpleCase.TestReadToResult('z', 5, "ghijk"); } - Y_UNIT_TEST(TestReadToBetweenStreams) { + Y_UNIT_TEST(TestReadToBetweenStreams) { TTestCase case1("0123456789abc", "defghijk"); case1.TestReadToResult('c', 13, "0123456789ab"); case1.TestReadToResult('k', 8, "defghij"); diff --git a/util/stream/null.h b/util/stream/null.h index 8c335a9a789..a87df475bc2 100644 --- a/util/stream/null.h +++ b/util/stream/null.h @@ -11,7 +11,7 @@ /** * Null input stream. Does nothing, contains no data. */ -class TNullInput: public IZeroCopyInput { +class TNullInput: public IZeroCopyInput { public: TNullInput() noexcept; ~TNullInput() override; @@ -25,7 +25,7 @@ private: /** * Null output stream. Just ignores whatever is written into it. */ -class TNullOutput: public IOutputStream { +class TNullOutput: public IOutputStream { public: TNullOutput() noexcept; ~TNullOutput() override; diff --git a/util/stream/output.cpp b/util/stream/output.cpp index db81b81b701..a71f46ac489 100644 --- a/util/stream/output.cpp +++ b/util/stream/output.cpp @@ -20,27 +20,27 @@ #include <string_view> #include <cstdio> -#if defined(_win_) +#if defined(_win_) #include <io.h> -#endif +#endif constexpr size_t MAX_UTF8_BYTES = 4; // UTF-8-encoded code point takes between 1 and 4 bytes -IOutputStream::IOutputStream() noexcept = default; +IOutputStream::IOutputStream() noexcept = default; -IOutputStream::~IOutputStream() = default; +IOutputStream::~IOutputStream() = default; -void IOutputStream::DoFlush() { +void IOutputStream::DoFlush() { /* * do nothing */ } -void IOutputStream::DoFinish() { +void IOutputStream::DoFinish() { Flush(); } -void IOutputStream::DoWriteV(const TPart* parts, size_t count) { +void IOutputStream::DoWriteV(const TPart* parts, size_t count) { for (size_t i = 0; i < count; ++i) { const TPart& part = parts[i]; @@ -69,7 +69,7 @@ void Out<wchar32>(IOutputStream& o, wchar32 ch) { o.Write(buffer, length); } -static void WriteString(IOutputStream& o, const wchar16* w, size_t n) { +static void WriteString(IOutputStream& o, const wchar16* w, size_t n) { const size_t buflen = (n * MAX_UTF8_BYTES); // * 4 because the conversion functions can convert unicode character into maximum 4 bytes of UTF8 TTempBuf buffer(buflen + 1); char* const data = buffer.Data(); @@ -90,12 +90,12 @@ static void WriteString(IOutputStream& o, const wchar32* w, size_t n) { } template <> -void Out<TString>(IOutputStream& o, const TString& p) { +void Out<TString>(IOutputStream& o, const TString& p) { o.Write(p.data(), p.size()); } template <> -void Out<std::string>(IOutputStream& o, const std::string& p) { +void Out<std::string>(IOutputStream& o, const std::string& p) { o.Write(p.data(), p.length()); } @@ -130,7 +130,7 @@ void Out<TUtf32StringBuf>(IOutputStream& o, const TUtf32StringBuf& p) { } template <> -void Out<const wchar16*>(IOutputStream& o, const wchar16* w) { +void Out<const wchar16*>(IOutputStream& o, const wchar16* w) { if (w) { WriteString(o, w, std::char_traits<wchar16>::length(w)); } else { @@ -148,7 +148,7 @@ void Out<const wchar32*>(IOutputStream& o, const wchar32* w) { } template <> -void Out<TUtf16String>(IOutputStream& o, const TUtf16String& w) { +void Out<TUtf16String>(IOutputStream& o, const TUtf16String& w) { WriteString(o, w.c_str(), w.size()); } @@ -159,19 +159,19 @@ void Out<TUtf32String>(IOutputStream& o, const TUtf32String& w) { #define DEF_CONV_DEFAULT(type) \ template <> \ - void Out<type>(IOutputStream & o, type p) { \ + void Out<type>(IOutputStream & o, type p) { \ o << ToString(p); \ } #define DEF_CONV_CHR(type) \ template <> \ - void Out<type>(IOutputStream & o, type p) { \ + void Out<type>(IOutputStream & o, type p) { \ o.Write((char)p); \ } #define DEF_CONV_NUM(type, len) \ template <> \ - void Out<type>(IOutputStream & o, type p) { \ + void Out<type>(IOutputStream & o, type p) { \ char buf[len]; \ o.Write(buf, ToString(p, buf, sizeof(buf))); \ } \ @@ -211,12 +211,12 @@ void Out<typename std::vector<bool>::reference>(IOutputStream& o, const std::vec #ifndef TSTRING_IS_STD_STRING template <> -void Out<TBasicCharRef<TString>>(IOutputStream& o, const TBasicCharRef<TString>& c) { +void Out<TBasicCharRef<TString>>(IOutputStream& o, const TBasicCharRef<TString>& c) { o << static_cast<char>(c); } template <> -void Out<TBasicCharRef<TUtf16String>>(IOutputStream& o, const TBasicCharRef<TUtf16String>& c) { +void Out<TBasicCharRef<TUtf16String>>(IOutputStream& o, const TBasicCharRef<TUtf16String>& c) { o << static_cast<wchar16>(c); } @@ -227,19 +227,19 @@ void Out<TBasicCharRef<TUtf32String>>(IOutputStream& o, const TBasicCharRef<TUtf #endif template <> -void Out<const void*>(IOutputStream& o, const void* t) { +void Out<const void*>(IOutputStream& o, const void* t) { o << Hex(size_t(t)); } template <> -void Out<void*>(IOutputStream& o, void* t) { +void Out<void*>(IOutputStream& o, void* t) { Out<const void*>(o, t); } using TNullPtr = decltype(nullptr); template <> -void Out<TNullPtr>(IOutputStream& o, TTypeTraits<TNullPtr>::TFuncParam) { +void Out<TNullPtr>(IOutputStream& o, TTypeTraits<TNullPtr>::TFuncParam) { o << TStringBuf("nullptr"); } @@ -258,7 +258,7 @@ namespace { public: using TLogFuncPtr = void (*)(int, const char*, const char*); - class TAndroidStdOutput: public IOutputStream { + class TAndroidStdOutput: public IOutputStream { public: inline TAndroidStdOutput(TLogFuncPtr logFuncPtr) noexcept : Buffer() @@ -339,7 +339,7 @@ namespace { #endif // _android_ namespace { - class TStdOutput: public IOutputStream { + class TStdOutput: public IOutputStream { public: inline TStdOutput(FILE* f) noexcept : F_(f) @@ -355,7 +355,7 @@ namespace { // On Windows, if 'F_' is console -- 'fwrite' returns count of written characters. // If, for example, console output codepage is UTF-8, then returned value is // not equal to 'len'. So, we ignore some 'errno' values... - if ((errno == 0 || errno == EINVAL || errno == EILSEQ) && _isatty(fileno(F_))) { + if ((errno == 0 || errno == EINVAL || errno == EILSEQ) && _isatty(fileno(F_))) { return; } #endif @@ -401,7 +401,7 @@ namespace { }; } -IOutputStream& NPrivate::StdErrStream() noexcept { +IOutputStream& NPrivate::StdErrStream() noexcept { #if defined(_android_) if (TAndroidStdIOStreams::Enabled) { return TAndroidStdIOStreams::Instance().Err; @@ -410,7 +410,7 @@ IOutputStream& NPrivate::StdErrStream() noexcept { return TStdIOStreams::Instance().Err; } -IOutputStream& NPrivate::StdOutStream() noexcept { +IOutputStream& NPrivate::StdOutStream() noexcept { #if defined(_android_) if (TAndroidStdIOStreams::Enabled) { return TAndroidStdIOStreams::Instance().Out; @@ -423,6 +423,6 @@ void RedirectStdioToAndroidLog(bool redirect) { #if defined(_android_) TAndroidStdIOStreams::Enabled = redirect; #else - Y_UNUSED(redirect); + Y_UNUSED(redirect); #endif } diff --git a/util/stream/output.h b/util/stream/output.h index 00eef50b958..3b40c4396fb 100644 --- a/util/stream/output.h +++ b/util/stream/output.h @@ -1,6 +1,6 @@ #pragma once -#include "fwd.h" +#include "fwd.h" #include "labeled.h" #include <util/generic/noncopyable.h> @@ -18,7 +18,7 @@ /** * Abstract output stream. */ -class IOutputStream: public TNonCopyable { +class IOutputStream: public TNonCopyable { public: /** * Data block for output. @@ -30,7 +30,7 @@ public: { } - inline TPart(const TStringBuf s) noexcept + inline TPart(const TStringBuf s) noexcept : buf(s.data()) , len(s.size()) { @@ -52,13 +52,13 @@ public: size_t len; }; - IOutputStream() noexcept; - virtual ~IOutputStream(); + IOutputStream() noexcept; + virtual ~IOutputStream(); - IOutputStream(IOutputStream&&) noexcept { + IOutputStream(IOutputStream&&) noexcept { } - IOutputStream& operator=(IOutputStream&&) noexcept { + IOutputStream& operator=(IOutputStream&&) noexcept { return *this; }; @@ -79,7 +79,7 @@ public: * * @param st String to write. */ - inline void Write(const TStringBuf st) { + inline void Write(const TStringBuf st) { Write(st.data(), st.size()); } @@ -171,7 +171,7 @@ protected: }; /** - * `operator<<` for `IOutputStream` by default delegates to this function. + * `operator<<` for `IOutputStream` by default delegates to this function. * * Note that while `operator<<` uses overloading (and thus argument-dependent * lookup), `Out` uses template specializations. This makes it possible to @@ -186,14 +186,14 @@ protected: * @param value Value to write. */ template <class T> -void Out(IOutputStream& out, typename TTypeTraits<T>::TFuncParam value); +void Out(IOutputStream& out, typename TTypeTraits<T>::TFuncParam value); -#define Y_DECLARE_OUT_SPEC(MODIF, T, stream, value) \ - template <> \ - MODIF void Out<T>(IOutputStream & stream, TTypeTraits<T>::TFuncParam value) +#define Y_DECLARE_OUT_SPEC(MODIF, T, stream, value) \ + template <> \ + MODIF void Out<T>(IOutputStream & stream, TTypeTraits<T>::TFuncParam value) template <> -inline void Out<const char*>(IOutputStream& o, const char* t) { +inline void Out<const char*>(IOutputStream& o, const char* t) { if (t) { o.Write(t); } else { @@ -202,24 +202,24 @@ inline void Out<const char*>(IOutputStream& o, const char* t) { } template <> -void Out<const wchar16*>(IOutputStream& o, const wchar16* w); +void Out<const wchar16*>(IOutputStream& o, const wchar16* w); template <> void Out<const wchar32*>(IOutputStream& o, const wchar32* w); -static inline IOutputStream& operator<<(IOutputStream& o, TStreamManipulator m) { +static inline IOutputStream& operator<<(IOutputStream& o, TStreamManipulator m) { m(o); return o; } -static inline IOutputStream& operator<<(IOutputStream& o, const char* t) { +static inline IOutputStream& operator<<(IOutputStream& o, const char* t) { Out<const char*>(o, t); return o; } -static inline IOutputStream& operator<<(IOutputStream& o, char* t) { +static inline IOutputStream& operator<<(IOutputStream& o, char* t) { Out<const char*>(o, t); return o; @@ -239,12 +239,12 @@ static inline std::enable_if_t<!std::is_scalar<T>::value, IOutputStream&> operat return o; } -static inline IOutputStream& operator<<(IOutputStream& o, const wchar16* t) { +static inline IOutputStream& operator<<(IOutputStream& o, const wchar16* t) { Out<const wchar16*>(o, t); return o; } -static inline IOutputStream& operator<<(IOutputStream& o, wchar16* t) { +static inline IOutputStream& operator<<(IOutputStream& o, wchar16* t) { Out<const wchar16*>(o, t); return o; } @@ -260,8 +260,8 @@ static inline IOutputStream& operator<<(IOutputStream& o, wchar32* t) { } namespace NPrivate { - IOutputStream& StdOutStream() noexcept; - IOutputStream& StdErrStream() noexcept; + IOutputStream& StdOutStream() noexcept; + IOutputStream& StdErrStream() noexcept; } /** @@ -282,14 +282,14 @@ namespace NPrivate { /** * End-of-line output manipulator, basically the same as `std::endl`. */ -static inline void Endl(IOutputStream& o) { +static inline void Endl(IOutputStream& o) { (o << '\n').Flush(); } /** * Flushing stream manipulator, basically the same as `std::flush`. */ -static inline void Flush(IOutputStream& o) { +static inline void Flush(IOutputStream& o) { o.Flush(); } diff --git a/util/stream/pipe.cpp b/util/stream/pipe.cpp index 51be1934a75..ff5b7788021 100644 --- a/util/stream/pipe.cpp +++ b/util/stream/pipe.cpp @@ -8,7 +8,7 @@ class TPipeBase::TImpl { public: inline TImpl(const TString& command, const char* mode) - : Pipe_(nullptr) + : Pipe_(nullptr) { #ifndef _freebsd_ if (strcmp(mode, "r+") == 0) { @@ -16,13 +16,13 @@ public: } #endif Pipe_ = ::popen(command.data(), mode); - if (Pipe_ == nullptr) { + if (Pipe_ == nullptr) { ythrow TSystemError() << "failed to open pipe: " << command.Quote(); } } inline ~TImpl() { - if (Pipe_ != nullptr) { + if (Pipe_ != nullptr) { ::pclose(Pipe_); } } @@ -44,14 +44,14 @@ TPipeInput::TPipeInput(const TString& command) } size_t TPipeInput::DoRead(void* buf, size_t len) { - if (Impl_->Pipe_ == nullptr) { + if (Impl_->Pipe_ == nullptr) { return 0; } size_t bytesRead = ::fread(buf, 1, len, Impl_->Pipe_); if (bytesRead == 0) { int exitStatus = ::pclose(Impl_->Pipe_); - Impl_->Pipe_ = nullptr; + Impl_->Pipe_ = nullptr; if (exitStatus == -1) { ythrow TSystemError() << "pclose() failed"; } else if (exitStatus != 0) { @@ -67,14 +67,14 @@ TPipeOutput::TPipeOutput(const TString& command) } void TPipeOutput::DoWrite(const void* buf, size_t len) { - if (Impl_->Pipe_ == nullptr || len != ::fwrite(buf, 1, len, Impl_->Pipe_)) { + if (Impl_->Pipe_ == nullptr || len != ::fwrite(buf, 1, len, Impl_->Pipe_)) { ythrow TSystemError() << "fwrite failed"; } } void TPipeOutput::Close() { int exitStatus = ::pclose(Impl_->Pipe_); - Impl_->Pipe_ = nullptr; + Impl_->Pipe_ = nullptr; if (exitStatus == -1) { ythrow TSystemError() << "pclose() failed"; } else if (exitStatus != 0) { diff --git a/util/stream/pipe.h b/util/stream/pipe.h index 18525b9517d..e736860a3ab 100644 --- a/util/stream/pipe.h +++ b/util/stream/pipe.h @@ -88,7 +88,7 @@ protected: /** * Input stream that binds to a standard output stream of an existing process. */ -class TPipedInput: public TPipedBase, public IInputStream { +class TPipedInput: public TPipedBase, public IInputStream { public: TPipedInput(PIPEHANDLE fd); ~TPipedInput() override; @@ -100,7 +100,7 @@ private: /** * Output stream that binds to a standard input stream of an existing process. */ -class TPipedOutput: public TPipedBase, public IOutputStream { +class TPipedOutput: public TPipedBase, public IOutputStream { public: TPipedOutput(PIPEHANDLE fd); ~TPipedOutput() override; diff --git a/util/stream/printf.cpp b/util/stream/printf.cpp index f3eeca7afcb..f7adaa2b2ab 100644 --- a/util/stream/printf.cpp +++ b/util/stream/printf.cpp @@ -1,11 +1,11 @@ -#include "output.h" +#include "output.h" #include "printf.h" #include <util/generic/scope.h> #include <util/memory/tempbuf.h> #include <util/generic/yexception.h> -size_t Printf(IOutputStream& out, const char* fmt, ...) { +size_t Printf(IOutputStream& out, const char* fmt, ...) { va_list lst; va_start(lst, fmt); @@ -16,7 +16,7 @@ size_t Printf(IOutputStream& out, const char* fmt, ...) { return Printf(out, fmt, lst); } -static inline size_t TryPrintf(void* ptr, size_t len, IOutputStream& out, const char* fmt, va_list params) { +static inline size_t TryPrintf(void* ptr, size_t len, IOutputStream& out, const char* fmt, va_list params) { va_list lst; va_copy(lst, params); const int ret = vsnprintf((char*)ptr, len, fmt, lst); @@ -33,7 +33,7 @@ static inline size_t TryPrintf(void* ptr, size_t len, IOutputStream& out, const return (size_t)ret; } -size_t Printf(IOutputStream& out, const char* fmt, va_list params) { +size_t Printf(IOutputStream& out, const char* fmt, va_list params) { size_t guess = 0; while (true) { diff --git a/util/stream/printf.h b/util/stream/printf.h index 1c7ddc06646..c6199a15efd 100644 --- a/util/stream/printf.h +++ b/util/stream/printf.h @@ -2,7 +2,7 @@ #include <util/system/compat.h> -class IOutputStream; +class IOutputStream; /** * Stream-based `printf` function. Prints formatted data into the provided stream. @@ -12,7 +12,7 @@ class IOutputStream; * @param fmt Format string. * @param ... Additional arguments. */ -size_t Y_PRINTF_FORMAT(2, 3) Printf(IOutputStream& out, const char* fmt, ...); +size_t Y_PRINTF_FORMAT(2, 3) Printf(IOutputStream& out, const char* fmt, ...); /** * Stream-based `vprintf` function. Prints formatted data from variable argument @@ -22,4 +22,4 @@ size_t Y_PRINTF_FORMAT(2, 3) Printf(IOutputStream& out, const char* fmt, ...); * @param fmt Format string. * @param params Additional arguments as a variable argument list. */ -size_t Y_PRINTF_FORMAT(2, 0) Printf(IOutputStream& out, const char* fmt, va_list params); +size_t Y_PRINTF_FORMAT(2, 0) Printf(IOutputStream& out, const char* fmt, va_list params); diff --git a/util/stream/printf_ut.cpp b/util/stream/printf_ut.cpp index 0eab1670625..fbfee58af4f 100644 --- a/util/stream/printf_ut.cpp +++ b/util/stream/printf_ut.cpp @@ -1,13 +1,13 @@ -#include "null.h" +#include "null.h" #include "printf.h" -#include "str.h" +#include "str.h" #include <util/generic/string.h> - + #include <library/cpp/testing/unittest/registar.h> -Y_UNIT_TEST_SUITE(TStreamPrintfTest) { - Y_UNIT_TEST(TestPrintf) { +Y_UNIT_TEST_SUITE(TStreamPrintfTest) { + Y_UNIT_TEST(TestPrintf) { TStringStream ss; UNIT_ASSERT_EQUAL(Printf(ss, "qw %s %d", "er", 1), 7); @@ -18,11 +18,11 @@ Y_UNIT_TEST_SUITE(TStreamPrintfTest) { #pragma GCC diagnostic ignored "-Wformat-zero-length" #endif // __GNUC__ - Y_UNIT_TEST(TestZeroString) { + Y_UNIT_TEST(TestZeroString) { UNIT_ASSERT_EQUAL(Printf(Cnull, ""), 0); } - Y_UNIT_TEST(TestLargePrintf) { + Y_UNIT_TEST(TestLargePrintf) { TString s = NUnitTest::RandomString(1000000); TStringStream ss; diff --git a/util/stream/str.h b/util/stream/str.h index 028bd572c03..07dc24861a1 100644 --- a/util/stream/str.h +++ b/util/stream/str.h @@ -15,7 +15,7 @@ /** * Input stream for reading data from a string. */ -class TStringInput: public IZeroCopyInputFastReadTo { +class TStringInput: public IZeroCopyInputFastReadTo { public: /** * Constructs a string input stream that reads character data from the @@ -109,7 +109,7 @@ private: */ class TStringStream: private TEmbedPolicy<TString>, public TStringInput, public TStringOutput { using TEmbeddedString = TEmbedPolicy<TString>; - + public: inline TStringStream() : TEmbeddedString() diff --git a/util/stream/str_ut.cpp b/util/stream/str_ut.cpp index fc6b46c31a4..930c5eac951 100644 --- a/util/stream/str_ut.cpp +++ b/util/stream/str_ut.cpp @@ -7,7 +7,7 @@ template <typename T> const T ReturnConstTemp(); Y_UNIT_TEST_SUITE(TStringInputOutputTest) { - Y_UNIT_TEST(Lvalue) { + Y_UNIT_TEST(Lvalue) { TString str = "Hello, World!"; TStringInput input(str); @@ -16,7 +16,7 @@ Y_UNIT_TEST_SUITE(TStringInputOutputTest) { UNIT_ASSERT_VALUES_EQUAL(result, str); } - Y_UNIT_TEST(ConstRef) { + Y_UNIT_TEST(ConstRef) { TString str = "Hello, World!"; const TString& r = str; TStringInput input(r); @@ -26,7 +26,7 @@ Y_UNIT_TEST_SUITE(TStringInputOutputTest) { UNIT_ASSERT_VALUES_EQUAL(result, str); } - Y_UNIT_TEST(NonConstRef) { + Y_UNIT_TEST(NonConstRef) { TString str = "Hello, World!"; TString& r = str; TStringInput input(r); @@ -36,7 +36,7 @@ Y_UNIT_TEST_SUITE(TStringInputOutputTest) { UNIT_ASSERT_VALUES_EQUAL(result, str); } - Y_UNIT_TEST(Transfer) { + Y_UNIT_TEST(Transfer) { TString inputString = "some_string"; TStringInput input(inputString); @@ -48,7 +48,7 @@ Y_UNIT_TEST_SUITE(TStringInputOutputTest) { UNIT_ASSERT_VALUES_EQUAL(inputString, outputString); } - Y_UNIT_TEST(SkipReadAll) { + Y_UNIT_TEST(SkipReadAll) { TString string0 = "All animals are equal, but some animals are more equal than others."; TString string1; @@ -68,7 +68,7 @@ Y_UNIT_TEST_SUITE(TStringInputOutputTest) { UNIT_ASSERT_VALUES_EQUAL(string2, string1.substr(5)); } - Y_UNIT_TEST(OperatorBool) { + Y_UNIT_TEST(OperatorBool) { TStringStream str; UNIT_ASSERT(!str); str << "data"; @@ -77,7 +77,7 @@ Y_UNIT_TEST_SUITE(TStringInputOutputTest) { UNIT_ASSERT(!str); } - Y_UNIT_TEST(TestReadTo) { + Y_UNIT_TEST(TestReadTo) { TString s("0123456789abc"); TString t; @@ -113,7 +113,7 @@ Y_UNIT_TEST_SUITE(TStringInputOutputTest) { UNIT_ASSERT_STRINGS_EQUAL(str1, str2); } - Y_UNIT_TEST(Write) { + Y_UNIT_TEST(Write) { TString str; TStringOutput output(str); output << "1" @@ -129,7 +129,7 @@ Y_UNIT_TEST_SUITE(TStringInputOutputTest) { "55555"); } - Y_UNIT_TEST(WriteChars) { + Y_UNIT_TEST(WriteChars) { TString str; TStringOutput output(str); output << '1' << '2' << '3' << '4' << '5' << '6' << '7' << '8' << '9' << '0'; diff --git a/util/stream/tee.cpp b/util/stream/tee.cpp index 99873b95ba3..ffa597648a5 100644 --- a/util/stream/tee.cpp +++ b/util/stream/tee.cpp @@ -1,6 +1,6 @@ #include "tee.h" -TTeeOutput::TTeeOutput(IOutputStream* l, IOutputStream* r) noexcept +TTeeOutput::TTeeOutput(IOutputStream* l, IOutputStream* r) noexcept : L_(l) , R_(r) { diff --git a/util/stream/tee.h b/util/stream/tee.h index c69e232fb9f..83711d70591 100644 --- a/util/stream/tee.h +++ b/util/stream/tee.h @@ -10,9 +10,9 @@ /** * A proxy output stream that writes into two slave streams simultaneously. */ -class TTeeOutput: public IOutputStream { +class TTeeOutput: public IOutputStream { public: - TTeeOutput(IOutputStream* l, IOutputStream* r) noexcept; + TTeeOutput(IOutputStream* l, IOutputStream* r) noexcept; ~TTeeOutput() override; private: @@ -21,8 +21,8 @@ private: void DoFinish() override; private: - IOutputStream* L_; - IOutputStream* R_; + IOutputStream* L_; + IOutputStream* R_; }; /** @} */ diff --git a/util/stream/tempbuf.cpp b/util/stream/tempbuf.cpp index 801a1fabb05..4fd8fc8112d 100644 --- a/util/stream/tempbuf.cpp +++ b/util/stream/tempbuf.cpp @@ -7,7 +7,7 @@ namespace { } void TTempBufOutput::DoWrite(const void* data, size_t len) { - if (Y_LIKELY(len <= Left())) { + if (Y_LIKELY(len <= Left())) { Append(data, len); } else { const size_t filled = Filled(); diff --git a/util/stream/tokenizer.h b/util/stream/tokenizer.h index b2398efdd1a..bc27650ce44 100644 --- a/util/stream/tokenizer.h +++ b/util/stream/tokenizer.h @@ -2,10 +2,10 @@ #include "input.h" -#include <util/generic/buffer.h> -#include <util/generic/mem_copy.h> -#include <util/generic/strbuf.h> -#include <util/system/compiler.h> +#include <util/generic/buffer.h> +#include <util/generic/mem_copy.h> +#include <util/generic/strbuf.h> +#include <util/system/compiler.h> #include <util/system/yassert.h> /** @@ -20,12 +20,12 @@ * @tparam TEndOfToken Predicate for token delimiter characters. * @see TEol */ -template <typename TEndOfToken> +template <typename TEndOfToken> class TStreamTokenizer { public: class TIterator { public: - inline TIterator(TStreamTokenizer* const parent) + inline TIterator(TStreamTokenizer* const parent) : Parent_(parent) , AtEnd_(!Parent_->Next(Data_, Len_)) { @@ -53,21 +53,21 @@ public: return !(*this == l); } - /** - * @return Return null-terminated character array with current token. - * The pointer may be invalid after iterator increment. - */ + /** + * @return Return null-terminated character array with current token. + * The pointer may be invalid after iterator increment. + */ inline const char* Data() const noexcept { - Y_ASSERT(!AtEnd_); + Y_ASSERT(!AtEnd_); return Data_; } - /** - * @return Length of current token. - */ + /** + * @return Length of current token. + */ inline size_t Length() const noexcept { - Y_ASSERT(!AtEnd_); + Y_ASSERT(!AtEnd_); return Len_; } @@ -77,27 +77,27 @@ public: } inline TStringBuf operator*() noexcept { - return TStringBuf{Data_, Len_}; + return TStringBuf{Data_, Len_}; } private: inline void Next() { - Y_ASSERT(Parent_); + Y_ASSERT(Parent_); AtEnd_ = !Parent_->Next(Data_, Len_); } private: - TStreamTokenizer* const Parent_; + TStreamTokenizer* const Parent_; char* Data_; size_t Len_; bool AtEnd_; }; - inline TStreamTokenizer(IInputStream* const input, const TEndOfToken& eot = TEndOfToken(), - const size_t initial = 1024) + inline TStreamTokenizer(IInputStream* const input, const TEndOfToken& eot = TEndOfToken(), + const size_t initial = 1024) : Input_(input) - , Buf_(initial) + , Buf_(initial) , Cur_(BufBegin()) , End_(BufBegin()) , Eot_(eot) @@ -112,7 +112,7 @@ public: do { while (it != End_) { if (Eot_(*it)) { - *it = '\0'; + *it = '\0'; buf = Cur_; len = it - Cur_; @@ -125,7 +125,7 @@ public: } if (Fill() == 0 && End_ != BufEnd()) { - *it = '\0'; + *it = '\0'; buf = Cur_; len = it - Cur_; @@ -135,25 +135,25 @@ public: } } while (it != BufEnd()); - Y_ASSERT(it == BufEnd()); - Y_ASSERT(End_ == BufEnd()); + Y_ASSERT(it == BufEnd()); + Y_ASSERT(End_ == BufEnd()); const size_t blen = End_ - Cur_; if (Cur_ == BufBegin()) { - Y_ASSERT(blen == Buf_.Capacity()); + Y_ASSERT(blen == Buf_.Capacity()); /* * do reallocate */ - Buf_.Reserve(Buf_.Capacity() * 4); + Buf_.Reserve(Buf_.Capacity() * 4); CheckBuf(); } else { /* * do move */ - MemMove(BufBegin(), Cur_, blen); + MemMove(BufBegin(), Cur_, blen); } Cur_ = BufBegin(); @@ -162,14 +162,14 @@ public: } } - inline TIterator begin() { - return TIterator{this}; - } - + inline TIterator begin() { + return TIterator{this}; + } + inline TIterator end() noexcept { - return {}; - } - + return {}; + } + private: inline size_t Fill() { const size_t avail = BufEnd() - End_; @@ -181,22 +181,22 @@ private: } inline char* BufBegin() noexcept { - return Buf_.Data(); + return Buf_.Data(); } inline char* BufEnd() noexcept { - return Buf_.Data() + Buf_.Capacity(); + return Buf_.Data() + Buf_.Capacity(); } inline void CheckBuf() const { - if (!Buf_.Data()) { + if (!Buf_.Data()) { throw std::bad_alloc(); } } private: - IInputStream* const Input_; - TBuffer Buf_; + IInputStream* const Input_; + TBuffer Buf_; char* Cur_; char* End_; TEndOfToken Eot_; diff --git a/util/stream/tokenizer_ut.cpp b/util/stream/tokenizer_ut.cpp index afc566da86e..37bb12e7d22 100644 --- a/util/stream/tokenizer_ut.cpp +++ b/util/stream/tokenizer_ut.cpp @@ -1,264 +1,264 @@ #include <library/cpp/testing/unittest/registar.h> - -#include <util/generic/array_size.h> -#include <util/generic/strbuf.h> - -#include "mem.h" -#include "null.h" -#include "tokenizer.h" - -static inline void CheckIfNullTerminated(const TStringBuf str) { + +#include <util/generic/array_size.h> +#include <util/generic/strbuf.h> + +#include "mem.h" +#include "null.h" +#include "tokenizer.h" + +static inline void CheckIfNullTerminated(const TStringBuf str) { UNIT_ASSERT_VALUES_EQUAL('\0', *(str.data() + str.size())); -} - -Y_UNIT_TEST_SUITE(TStreamTokenizerTests) { - Y_UNIT_TEST(EmptyStreamTest) { - auto&& input = TNullInput{}; - auto&& tokenizer = TStreamTokenizer<TEol>{&input}; - auto tokensCount = size_t{}; - for (auto it = tokenizer.begin(); tokenizer.end() != it; ++it) { - CheckIfNullTerminated(TStringBuf{it->Data(), it->Length()}); - ++tokensCount; - } - UNIT_ASSERT_VALUES_EQUAL(0, tokensCount); - } - - Y_UNIT_TEST(EmptyTokensTest) { - const char data[] = "\n\n"; - const auto dataSize = Y_ARRAY_SIZE(data) - 1; - auto&& input = TMemoryInput{data, dataSize}; - auto&& tokenizer = TStreamTokenizer<TEol>{&input}; - auto tokensCount = size_t{}; - for (auto it = tokenizer.begin(); tokenizer.end() != it; ++it) { - CheckIfNullTerminated(TStringBuf{it->Data(), it->Length()}); - UNIT_ASSERT_VALUES_EQUAL(0, it->Length()); - ++tokensCount; - } - UNIT_ASSERT_VALUES_EQUAL(2, tokensCount); - } - - Y_UNIT_TEST(LastTokenendDoesntSatisfyPredicateTest) { - const char data[] = "abc\ndef\nxxxxxx"; - const auto dataSize = Y_ARRAY_SIZE(data) - 1; +} + +Y_UNIT_TEST_SUITE(TStreamTokenizerTests) { + Y_UNIT_TEST(EmptyStreamTest) { + auto&& input = TNullInput{}; + auto&& tokenizer = TStreamTokenizer<TEol>{&input}; + auto tokensCount = size_t{}; + for (auto it = tokenizer.begin(); tokenizer.end() != it; ++it) { + CheckIfNullTerminated(TStringBuf{it->Data(), it->Length()}); + ++tokensCount; + } + UNIT_ASSERT_VALUES_EQUAL(0, tokensCount); + } + + Y_UNIT_TEST(EmptyTokensTest) { + const char data[] = "\n\n"; + const auto dataSize = Y_ARRAY_SIZE(data) - 1; + auto&& input = TMemoryInput{data, dataSize}; + auto&& tokenizer = TStreamTokenizer<TEol>{&input}; + auto tokensCount = size_t{}; + for (auto it = tokenizer.begin(); tokenizer.end() != it; ++it) { + CheckIfNullTerminated(TStringBuf{it->Data(), it->Length()}); + UNIT_ASSERT_VALUES_EQUAL(0, it->Length()); + ++tokensCount; + } + UNIT_ASSERT_VALUES_EQUAL(2, tokensCount); + } + + Y_UNIT_TEST(LastTokenendDoesntSatisfyPredicateTest) { + const char data[] = "abc\ndef\nxxxxxx"; + const auto dataSize = Y_ARRAY_SIZE(data) - 1; const TStringBuf tokens[] = {TStringBuf("abc"), TStringBuf("def"), TStringBuf("xxxxxx")}; - const auto tokensSize = Y_ARRAY_SIZE(tokens); - auto&& input = TMemoryInput{data, dataSize}; - auto&& tokenizer = TStreamTokenizer<TEol>{&input}; - auto tokensCount = size_t{}; - for (auto it = tokenizer.begin(); tokenizer.end() != it; ++it) { - UNIT_ASSERT(tokensCount < tokensSize); - const auto token = TStringBuf{it->Data(), it->Length()}; - CheckIfNullTerminated(token); - UNIT_ASSERT_VALUES_EQUAL(tokens[tokensCount], token); - ++tokensCount; - } - UNIT_ASSERT_VALUES_EQUAL(tokensSize, tokensCount); - } - - Y_UNIT_TEST(FirstTokenIsEmptyTest) { - const char data[] = "\ndef\nxxxxxx"; - const auto dataSize = Y_ARRAY_SIZE(data) - 1; + const auto tokensSize = Y_ARRAY_SIZE(tokens); + auto&& input = TMemoryInput{data, dataSize}; + auto&& tokenizer = TStreamTokenizer<TEol>{&input}; + auto tokensCount = size_t{}; + for (auto it = tokenizer.begin(); tokenizer.end() != it; ++it) { + UNIT_ASSERT(tokensCount < tokensSize); + const auto token = TStringBuf{it->Data(), it->Length()}; + CheckIfNullTerminated(token); + UNIT_ASSERT_VALUES_EQUAL(tokens[tokensCount], token); + ++tokensCount; + } + UNIT_ASSERT_VALUES_EQUAL(tokensSize, tokensCount); + } + + Y_UNIT_TEST(FirstTokenIsEmptyTest) { + const char data[] = "\ndef\nxxxxxx"; + const auto dataSize = Y_ARRAY_SIZE(data) - 1; const TStringBuf tokens[] = {TStringBuf(), TStringBuf("def"), TStringBuf("xxxxxx")}; - const auto tokensSize = Y_ARRAY_SIZE(tokens); - auto&& input = TMemoryInput{data, dataSize}; - auto&& tokenizer = TStreamTokenizer<TEol>{&input}; - auto tokensCount = size_t{}; - for (auto it = tokenizer.begin(); tokenizer.end() != it; ++it) { - UNIT_ASSERT(tokensCount < tokensSize); - const auto token = TStringBuf{it->Data(), it->Length()}; - CheckIfNullTerminated(token); - UNIT_ASSERT_VALUES_EQUAL(tokens[tokensCount], token); - ++tokensCount; - } - UNIT_ASSERT_VALUES_EQUAL(tokensSize, tokensCount); - } - - Y_UNIT_TEST(PredicateDoesntMatch) { - const char data[] = "1234567890-=!@#$%^&*()_+QWERTYUIOP{}qwertyuiop[]ASDFGHJKL:"; - const auto dataSize = Y_ARRAY_SIZE(data) - 1; - auto&& input = TMemoryInput{data, dataSize}; - auto&& tokenizer = TStreamTokenizer<TEol>{&input}; - auto tokensCount = size_t{}; - for (auto it = tokenizer.begin(); tokenizer.end() != it; ++it) { - const auto token = TStringBuf{it->Data(), it->Length()}; - CheckIfNullTerminated(token); - UNIT_ASSERT_VALUES_EQUAL(data, token); - ++tokensCount; - } - UNIT_ASSERT_VALUES_EQUAL(1, tokensCount); - } - - Y_UNIT_TEST(SimpleTest) { - const char data[] = "qwerty\n1234567890\n"; - const auto dataSize = Y_ARRAY_SIZE(data) - 1; + const auto tokensSize = Y_ARRAY_SIZE(tokens); + auto&& input = TMemoryInput{data, dataSize}; + auto&& tokenizer = TStreamTokenizer<TEol>{&input}; + auto tokensCount = size_t{}; + for (auto it = tokenizer.begin(); tokenizer.end() != it; ++it) { + UNIT_ASSERT(tokensCount < tokensSize); + const auto token = TStringBuf{it->Data(), it->Length()}; + CheckIfNullTerminated(token); + UNIT_ASSERT_VALUES_EQUAL(tokens[tokensCount], token); + ++tokensCount; + } + UNIT_ASSERT_VALUES_EQUAL(tokensSize, tokensCount); + } + + Y_UNIT_TEST(PredicateDoesntMatch) { + const char data[] = "1234567890-=!@#$%^&*()_+QWERTYUIOP{}qwertyuiop[]ASDFGHJKL:"; + const auto dataSize = Y_ARRAY_SIZE(data) - 1; + auto&& input = TMemoryInput{data, dataSize}; + auto&& tokenizer = TStreamTokenizer<TEol>{&input}; + auto tokensCount = size_t{}; + for (auto it = tokenizer.begin(); tokenizer.end() != it; ++it) { + const auto token = TStringBuf{it->Data(), it->Length()}; + CheckIfNullTerminated(token); + UNIT_ASSERT_VALUES_EQUAL(data, token); + ++tokensCount; + } + UNIT_ASSERT_VALUES_EQUAL(1, tokensCount); + } + + Y_UNIT_TEST(SimpleTest) { + const char data[] = "qwerty\n1234567890\n"; + const auto dataSize = Y_ARRAY_SIZE(data) - 1; const TStringBuf tokens[] = {TStringBuf("qwerty"), TStringBuf("1234567890")}; - const auto tokensSize = Y_ARRAY_SIZE(tokens); - auto&& input = TMemoryInput{data, dataSize}; - auto&& tokenizer = TStreamTokenizer<TEol>{&input}; - auto tokensCount = size_t{}; - for (auto it = tokenizer.begin(); tokenizer.end() != it; ++it) { - UNIT_ASSERT(tokensCount < tokensSize); - const auto token = TStringBuf{it->Data(), it->Length()}; - CheckIfNullTerminated(token); - UNIT_ASSERT_VALUES_EQUAL(tokens[tokensCount], token); - ++tokensCount; - } - UNIT_ASSERT_VALUES_EQUAL(tokensSize, tokensCount); - } - - Y_UNIT_TEST(CustomPredicateTest) { - struct TIsVerticalBar { + const auto tokensSize = Y_ARRAY_SIZE(tokens); + auto&& input = TMemoryInput{data, dataSize}; + auto&& tokenizer = TStreamTokenizer<TEol>{&input}; + auto tokensCount = size_t{}; + for (auto it = tokenizer.begin(); tokenizer.end() != it; ++it) { + UNIT_ASSERT(tokensCount < tokensSize); + const auto token = TStringBuf{it->Data(), it->Length()}; + CheckIfNullTerminated(token); + UNIT_ASSERT_VALUES_EQUAL(tokens[tokensCount], token); + ++tokensCount; + } + UNIT_ASSERT_VALUES_EQUAL(tokensSize, tokensCount); + } + + Y_UNIT_TEST(CustomPredicateTest) { + struct TIsVerticalBar { inline bool operator()(const char ch) const noexcept { - return '|' == ch; - } - }; - - const char data[] = "abc|def|xxxxxx"; - const auto dataSize = Y_ARRAY_SIZE(data) - 1; + return '|' == ch; + } + }; + + const char data[] = "abc|def|xxxxxx"; + const auto dataSize = Y_ARRAY_SIZE(data) - 1; const TStringBuf tokens[] = {TStringBuf("abc"), TStringBuf("def"), TStringBuf("xxxxxx")}; - const auto tokensSize = Y_ARRAY_SIZE(tokens); - auto&& input = TMemoryInput{data, dataSize}; - auto&& tokenizer = TStreamTokenizer<TIsVerticalBar>{&input}; - auto tokensCount = size_t{}; - for (auto it = tokenizer.begin(); tokenizer.end() != it; ++it) { - UNIT_ASSERT(tokensCount < tokensSize); - const auto token = TStringBuf{it->Data(), it->Length()}; - CheckIfNullTerminated(token); - UNIT_ASSERT_VALUES_EQUAL(tokens[tokensCount], token); - ++tokensCount; - } - UNIT_ASSERT_VALUES_EQUAL(tokensSize, tokensCount); - } - - Y_UNIT_TEST(CustomPredicateSecondTest) { - struct TIsVerticalBar { + const auto tokensSize = Y_ARRAY_SIZE(tokens); + auto&& input = TMemoryInput{data, dataSize}; + auto&& tokenizer = TStreamTokenizer<TIsVerticalBar>{&input}; + auto tokensCount = size_t{}; + for (auto it = tokenizer.begin(); tokenizer.end() != it; ++it) { + UNIT_ASSERT(tokensCount < tokensSize); + const auto token = TStringBuf{it->Data(), it->Length()}; + CheckIfNullTerminated(token); + UNIT_ASSERT_VALUES_EQUAL(tokens[tokensCount], token); + ++tokensCount; + } + UNIT_ASSERT_VALUES_EQUAL(tokensSize, tokensCount); + } + + Y_UNIT_TEST(CustomPredicateSecondTest) { + struct TIsVerticalBar { inline bool operator()(const char ch) const noexcept { - return '|' == ch || ',' == ch; - } - }; - - const char data[] = "abc|def|xxxxxx,abc|def|xxxxxx"; - const auto dataSize = Y_ARRAY_SIZE(data) - 1; + return '|' == ch || ',' == ch; + } + }; + + const char data[] = "abc|def|xxxxxx,abc|def|xxxxxx"; + const auto dataSize = Y_ARRAY_SIZE(data) - 1; const TStringBuf tokens[] = {TStringBuf("abc"), TStringBuf("def"), TStringBuf("xxxxxx"), TStringBuf("abc"), TStringBuf("def"), TStringBuf("xxxxxx")}; - const auto tokensSize = Y_ARRAY_SIZE(tokens); - auto&& input = TMemoryInput{data, dataSize}; - auto&& tokenizer = TStreamTokenizer<TIsVerticalBar>{&input}; - auto tokensCount = size_t{}; - for (auto it = tokenizer.begin(); tokenizer.end() != it; ++it) { - UNIT_ASSERT(tokensCount < tokensSize); - const auto token = TStringBuf{it->Data(), it->Length()}; - CheckIfNullTerminated(token); - UNIT_ASSERT_VALUES_EQUAL(tokens[tokensCount], token); - ++tokensCount; - } - UNIT_ASSERT_VALUES_EQUAL(tokensSize, tokensCount); - } - - Y_UNIT_TEST(FalsePredicateTest) { - struct TAlwaysFalse { + const auto tokensSize = Y_ARRAY_SIZE(tokens); + auto&& input = TMemoryInput{data, dataSize}; + auto&& tokenizer = TStreamTokenizer<TIsVerticalBar>{&input}; + auto tokensCount = size_t{}; + for (auto it = tokenizer.begin(); tokenizer.end() != it; ++it) { + UNIT_ASSERT(tokensCount < tokensSize); + const auto token = TStringBuf{it->Data(), it->Length()}; + CheckIfNullTerminated(token); + UNIT_ASSERT_VALUES_EQUAL(tokens[tokensCount], token); + ++tokensCount; + } + UNIT_ASSERT_VALUES_EQUAL(tokensSize, tokensCount); + } + + Y_UNIT_TEST(FalsePredicateTest) { + struct TAlwaysFalse { inline bool operator()(const char) const noexcept { - return false; - } - }; - - const char data[] = "1234567890-=!@#$%^&*()_+QWERTYUIOP{}qwertyuiop[]ASDFGHJKL:"; - const auto dataSize = Y_ARRAY_SIZE(data) - 1; - auto&& input = TMemoryInput{data, dataSize}; - auto&& tokenizer = TStreamTokenizer<TAlwaysFalse>{&input}; - auto tokensCount = size_t{}; - for (auto it = tokenizer.begin(); tokenizer.end() != it; ++it) { - const auto token = TStringBuf{it->Data(), it->Length()}; - CheckIfNullTerminated(token); - UNIT_ASSERT_VALUES_EQUAL(data, token); - ++tokensCount; - } - UNIT_ASSERT_VALUES_EQUAL(1, tokensCount); - } - - Y_UNIT_TEST(TruePredicateTest) { - struct TAlwaysTrue { + return false; + } + }; + + const char data[] = "1234567890-=!@#$%^&*()_+QWERTYUIOP{}qwertyuiop[]ASDFGHJKL:"; + const auto dataSize = Y_ARRAY_SIZE(data) - 1; + auto&& input = TMemoryInput{data, dataSize}; + auto&& tokenizer = TStreamTokenizer<TAlwaysFalse>{&input}; + auto tokensCount = size_t{}; + for (auto it = tokenizer.begin(); tokenizer.end() != it; ++it) { + const auto token = TStringBuf{it->Data(), it->Length()}; + CheckIfNullTerminated(token); + UNIT_ASSERT_VALUES_EQUAL(data, token); + ++tokensCount; + } + UNIT_ASSERT_VALUES_EQUAL(1, tokensCount); + } + + Y_UNIT_TEST(TruePredicateTest) { + struct TAlwaysTrue { inline bool operator()(const char) const noexcept { - return true; - } - }; - - const char data[] = "1234567890-=!@#$%^&*()_+QWERTYUIOP{}qwertyuiop[]ASDFGHJKL:"; - const auto dataSize = Y_ARRAY_SIZE(data) - 1; - auto&& input = TMemoryInput{data, dataSize}; - auto&& tokenizer = TStreamTokenizer<TAlwaysTrue>{&input}; - auto tokensCount = size_t{}; - for (auto it = tokenizer.begin(); tokenizer.end() != it; ++it) { - CheckIfNullTerminated(TStringBuf{it->Data(), it->Length()}); - UNIT_ASSERT_VALUES_EQUAL(0, it->Length()); - ++tokensCount; - } - UNIT_ASSERT_VALUES_EQUAL(dataSize, tokensCount); - } - - Y_UNIT_TEST(FirstTokenHasSizeOfTheBufferTest) { - const char data[] = "xxxxx\nxx"; - const auto dataSize = Y_ARRAY_SIZE(data) - 1; + return true; + } + }; + + const char data[] = "1234567890-=!@#$%^&*()_+QWERTYUIOP{}qwertyuiop[]ASDFGHJKL:"; + const auto dataSize = Y_ARRAY_SIZE(data) - 1; + auto&& input = TMemoryInput{data, dataSize}; + auto&& tokenizer = TStreamTokenizer<TAlwaysTrue>{&input}; + auto tokensCount = size_t{}; + for (auto it = tokenizer.begin(); tokenizer.end() != it; ++it) { + CheckIfNullTerminated(TStringBuf{it->Data(), it->Length()}); + UNIT_ASSERT_VALUES_EQUAL(0, it->Length()); + ++tokensCount; + } + UNIT_ASSERT_VALUES_EQUAL(dataSize, tokensCount); + } + + Y_UNIT_TEST(FirstTokenHasSizeOfTheBufferTest) { + const char data[] = "xxxxx\nxx"; + const auto dataSize = Y_ARRAY_SIZE(data) - 1; const TStringBuf tokens[] = {TStringBuf("xxxxx"), TStringBuf("xx")}; - const auto tokensSize = Y_ARRAY_SIZE(tokens); - auto&& input = TMemoryInput{data, dataSize}; - auto&& tokenizer = TStreamTokenizer<TEol>{&input, TEol{}, tokens[0].size()}; - auto tokensCount = size_t{}; - for (auto it = tokenizer.begin(); tokenizer.end() != it; ++it) { - const auto token = TStringBuf{it->Data(), it->Length()}; - CheckIfNullTerminated(token); - UNIT_ASSERT_VALUES_EQUAL(tokens[tokensCount], token); - ++tokensCount; - } - UNIT_ASSERT_VALUES_EQUAL(tokensSize, tokensCount); - } - - Y_UNIT_TEST(OnlyTokenHasSizeOfTheBufferTest) { - const char data[] = "xxxxx"; - const auto dataSize = Y_ARRAY_SIZE(data) - 1; - auto&& input = TMemoryInput{data, dataSize}; - auto&& tokenizer = TStreamTokenizer<TEol>{&input, TEol{}, dataSize}; - auto tokensCount = size_t{}; - for (auto it = tokenizer.begin(); tokenizer.end() != it; ++it) { - const auto token = TStringBuf{it->Data(), it->Length()}; - CheckIfNullTerminated(token); - UNIT_ASSERT_VALUES_EQUAL(data, token); - ++tokensCount; - } - UNIT_ASSERT_VALUES_EQUAL(1, tokensCount); - } - - Y_UNIT_TEST(BufferSizeInitialSizeSmallerThanTokenTest) { - const char data[] = "xxxxx\nxx"; - const auto dataSize = Y_ARRAY_SIZE(data) - 1; + const auto tokensSize = Y_ARRAY_SIZE(tokens); + auto&& input = TMemoryInput{data, dataSize}; + auto&& tokenizer = TStreamTokenizer<TEol>{&input, TEol{}, tokens[0].size()}; + auto tokensCount = size_t{}; + for (auto it = tokenizer.begin(); tokenizer.end() != it; ++it) { + const auto token = TStringBuf{it->Data(), it->Length()}; + CheckIfNullTerminated(token); + UNIT_ASSERT_VALUES_EQUAL(tokens[tokensCount], token); + ++tokensCount; + } + UNIT_ASSERT_VALUES_EQUAL(tokensSize, tokensCount); + } + + Y_UNIT_TEST(OnlyTokenHasSizeOfTheBufferTest) { + const char data[] = "xxxxx"; + const auto dataSize = Y_ARRAY_SIZE(data) - 1; + auto&& input = TMemoryInput{data, dataSize}; + auto&& tokenizer = TStreamTokenizer<TEol>{&input, TEol{}, dataSize}; + auto tokensCount = size_t{}; + for (auto it = tokenizer.begin(); tokenizer.end() != it; ++it) { + const auto token = TStringBuf{it->Data(), it->Length()}; + CheckIfNullTerminated(token); + UNIT_ASSERT_VALUES_EQUAL(data, token); + ++tokensCount; + } + UNIT_ASSERT_VALUES_EQUAL(1, tokensCount); + } + + Y_UNIT_TEST(BufferSizeInitialSizeSmallerThanTokenTest) { + const char data[] = "xxxxx\nxx"; + const auto dataSize = Y_ARRAY_SIZE(data) - 1; const TStringBuf tokens[] = {TStringBuf("xxxxx"), TStringBuf("xx")}; - const auto tokensSize = Y_ARRAY_SIZE(tokens); - auto&& input = TMemoryInput{data, dataSize}; - auto&& tokenizer = TStreamTokenizer<TEol>{&input, TEol{}, 1}; - auto tokensCount = size_t{}; - for (auto it = tokenizer.begin(); tokenizer.end() != it; ++it) { - const auto token = TStringBuf{it->Data(), it->Length()}; - CheckIfNullTerminated(token); - UNIT_ASSERT_VALUES_EQUAL(tokens[tokensCount], token); - ++tokensCount; - } - UNIT_ASSERT_VALUES_EQUAL(tokensSize, tokensCount); - } - - Y_UNIT_TEST(RangeBasedForTest) { - const char data[] = "abc\ndef\nxxxxxx"; - const auto dataSize = Y_ARRAY_SIZE(data) - 1; + const auto tokensSize = Y_ARRAY_SIZE(tokens); + auto&& input = TMemoryInput{data, dataSize}; + auto&& tokenizer = TStreamTokenizer<TEol>{&input, TEol{}, 1}; + auto tokensCount = size_t{}; + for (auto it = tokenizer.begin(); tokenizer.end() != it; ++it) { + const auto token = TStringBuf{it->Data(), it->Length()}; + CheckIfNullTerminated(token); + UNIT_ASSERT_VALUES_EQUAL(tokens[tokensCount], token); + ++tokensCount; + } + UNIT_ASSERT_VALUES_EQUAL(tokensSize, tokensCount); + } + + Y_UNIT_TEST(RangeBasedForTest) { + const char data[] = "abc\ndef\nxxxxxx"; + const auto dataSize = Y_ARRAY_SIZE(data) - 1; const TStringBuf tokens[] = {TStringBuf("abc"), TStringBuf("def"), TStringBuf("xxxxxx")}; - const auto tokensSize = Y_ARRAY_SIZE(tokens); - auto&& input = TMemoryInput{data, dataSize}; - auto&& tokenizer = TStreamTokenizer<TEol>{&input}; - auto tokensCount = size_t{}; - for (const auto& token : tokenizer) { - UNIT_ASSERT(tokensCount < tokensSize); - CheckIfNullTerminated(token); - UNIT_ASSERT_VALUES_EQUAL(tokens[tokensCount], token); - ++tokensCount; - } - UNIT_ASSERT_VALUES_EQUAL(tokensSize, tokensCount); - } -} + const auto tokensSize = Y_ARRAY_SIZE(tokens); + auto&& input = TMemoryInput{data, dataSize}; + auto&& tokenizer = TStreamTokenizer<TEol>{&input}; + auto tokensCount = size_t{}; + for (const auto& token : tokenizer) { + UNIT_ASSERT(tokensCount < tokensSize); + CheckIfNullTerminated(token); + UNIT_ASSERT_VALUES_EQUAL(tokens[tokensCount], token); + ++tokensCount; + } + UNIT_ASSERT_VALUES_EQUAL(tokensSize, tokensCount); + } +} diff --git a/util/stream/trace.h b/util/stream/trace.h index e74b6ecf3e0..9674dc7481b 100644 --- a/util/stream/trace.h +++ b/util/stream/trace.h @@ -15,21 +15,21 @@ enum ETraceLevel: ui8 { TRACE_VERBOSE = 7 }; -#if !defined(NDEBUG) && !defined(Y_ENABLE_TRACE) +#if !defined(NDEBUG) && !defined(Y_ENABLE_TRACE) #define Y_ENABLE_TRACE #endif -#ifdef Y_ENABLE_TRACE +#ifdef Y_ENABLE_TRACE /** * Writes the given data into standard debug stream if current debug level set * via `DBGOUT` environment variable permits it. * - * Does nothing in release builds unless `Y_ENABLE_TRACE` is defined. + * Does nothing in release builds unless `Y_ENABLE_TRACE` is defined. * * Example usage: * @code - * Y_DBGTRACE(DEBUG, "Advance from " << node1 << " to " << node2); + * Y_DBGTRACE(DEBUG, "Advance from " << node1 << " to " << node2); * @endcode * * @param elevel Debug level of this trace command, e.g. diff --git a/util/stream/walk.cpp b/util/stream/walk.cpp index 57dc9ab036c..02439393980 100644 --- a/util/stream/walk.cpp +++ b/util/stream/walk.cpp @@ -1,13 +1,13 @@ #include "walk.h" #include <util/generic/string.h> - -void IWalkInput::DoUndo(size_t len) { + +void IWalkInput::DoUndo(size_t len) { Len_ += len; Buf_ = static_cast<const char*>(Buf_) - len; } -size_t IWalkInput::DoNext(const void** ptr, size_t len) { +size_t IWalkInput::DoNext(const void** ptr, size_t len) { if (!Len_) { Len_ = DoUnboundedNext(&Buf_); } diff --git a/util/stream/walk.h b/util/stream/walk.h index 7e62cb44dc9..36b50727e79 100644 --- a/util/stream/walk.h +++ b/util/stream/walk.h @@ -7,10 +7,10 @@ * * Derived classes must implement `DoUnboundedNext` method. */ -class IWalkInput: public IZeroCopyInputFastReadTo { +class IWalkInput: public IZeroCopyInputFastReadTo { public: - IWalkInput() - : Buf_(nullptr) + IWalkInput() + : Buf_(nullptr) , Len_(0) { } diff --git a/util/stream/walk_ut.cpp b/util/stream/walk_ut.cpp index e0a783799f2..b5a8057b1bb 100644 --- a/util/stream/walk_ut.cpp +++ b/util/stream/walk_ut.cpp @@ -2,7 +2,7 @@ #include <library/cpp/testing/unittest/registar.h> -class TStringListInput: public IWalkInput { +class TStringListInput: public IWalkInput { public: TStringListInput(const TVector<TString>& data) : Data_(data) @@ -27,8 +27,8 @@ private: size_t Index_; }; -Y_UNIT_TEST_SUITE(TWalkTest) { - Y_UNIT_TEST(ReadTo) { +Y_UNIT_TEST_SUITE(TWalkTest) { + Y_UNIT_TEST(ReadTo) { TVector<TString> data; data.push_back("111a"); data.push_back("222b"); diff --git a/util/stream/zerocopy.cpp b/util/stream/zerocopy.cpp index dc2982ad553..b8b378014cc 100644 --- a/util/stream/zerocopy.cpp +++ b/util/stream/zerocopy.cpp @@ -1,9 +1,9 @@ #include "zerocopy.h" #include "output.h" -IZeroCopyInput::~IZeroCopyInput() = default; +IZeroCopyInput::~IZeroCopyInput() = default; -size_t IZeroCopyInput::DoRead(void* buf, size_t len) { +size_t IZeroCopyInput::DoRead(void* buf, size_t len) { const void* ptr; size_t result = DoNext(&ptr, len); @@ -14,7 +14,7 @@ size_t IZeroCopyInput::DoRead(void* buf, size_t len) { return result; } -ui64 IZeroCopyInput::DoReadAll(IOutputStream& out) { +ui64 IZeroCopyInput::DoReadAll(IOutputStream& out) { ui64 result = 0; const void* ptr; @@ -26,15 +26,15 @@ ui64 IZeroCopyInput::DoReadAll(IOutputStream& out) { return result; } -size_t IZeroCopyInput::DoSkip(size_t len) { +size_t IZeroCopyInput::DoSkip(size_t len) { const void* ptr; return DoNext(&ptr, len); } -IZeroCopyInputFastReadTo::~IZeroCopyInputFastReadTo() = default; +IZeroCopyInputFastReadTo::~IZeroCopyInputFastReadTo() = default; -size_t IZeroCopyInputFastReadTo::DoReadTo(TString& st, char ch) { +size_t IZeroCopyInputFastReadTo::DoReadTo(TString& st, char ch) { const char* ptr; size_t len = Next(&ptr); if (!len) { diff --git a/util/stream/zerocopy.h b/util/stream/zerocopy.h index 3315aa3a517..9c99326d556 100644 --- a/util/stream/zerocopy.h +++ b/util/stream/zerocopy.h @@ -6,7 +6,7 @@ #include "input.h" -class IOutputStream; +class IOutputStream; /** * @addtogroup Streams @@ -18,13 +18,13 @@ class IOutputStream; * * Derived classes must implement `DoNext` method. */ -class IZeroCopyInput: public IInputStream { +class IZeroCopyInput: public IInputStream { public: - IZeroCopyInput() noexcept = default; - ~IZeroCopyInput() override; + IZeroCopyInput() noexcept = default; + ~IZeroCopyInput() override; - IZeroCopyInput(IZeroCopyInput&&) noexcept = default; - IZeroCopyInput& operator=(IZeroCopyInput&&) noexcept = default; + IZeroCopyInput(IZeroCopyInput&&) noexcept = default; + IZeroCopyInput& operator=(IZeroCopyInput&&) noexcept = default; /** * Returns the next data chunk from this input stream. @@ -39,7 +39,7 @@ public: */ template <class T> inline size_t Next(T** ptr, size_t len) { - Y_ASSERT(ptr); + Y_ASSERT(ptr); return DoNext((const void**)ptr, len); } @@ -52,7 +52,7 @@ public: protected: size_t DoRead(void* buf, size_t len) override; size_t DoSkip(size_t len) override; - ui64 DoReadAll(IOutputStream& out) override; + ui64 DoReadAll(IOutputStream& out) override; virtual size_t DoNext(const void** ptr, size_t len) = 0; }; @@ -61,13 +61,13 @@ protected: * * Derived classes must implement `DoUndo` method. */ -class IZeroCopyInputFastReadTo: public IZeroCopyInput { +class IZeroCopyInputFastReadTo: public IZeroCopyInput { public: - IZeroCopyInputFastReadTo() noexcept = default; - ~IZeroCopyInputFastReadTo() override; + IZeroCopyInputFastReadTo() noexcept = default; + ~IZeroCopyInputFastReadTo() override; - IZeroCopyInputFastReadTo(IZeroCopyInputFastReadTo&&) noexcept = default; - IZeroCopyInputFastReadTo& operator=(IZeroCopyInputFastReadTo&&) noexcept = default; + IZeroCopyInputFastReadTo(IZeroCopyInputFastReadTo&&) noexcept = default; + IZeroCopyInputFastReadTo& operator=(IZeroCopyInputFastReadTo&&) noexcept = default; protected: size_t DoReadTo(TString& st, char ch) override; diff --git a/util/stream/zlib.cpp b/util/stream/zlib.cpp index 60f4e9439f0..2893cc044ba 100644 --- a/util/stream/zlib.cpp +++ b/util/stream/zlib.cpp @@ -29,7 +29,7 @@ namespace { inline ~TZLibCommon() = default; inline const char* GetErrMsg() const noexcept { - return Z()->msg != nullptr ? Z()->msg : "unknown error"; + return Z()->msg != nullptr ? Z()->msg : "unknown error"; } inline z_stream* Z() const noexcept { @@ -45,9 +45,9 @@ namespace { } struct TChunkedZeroCopyInput { - inline TChunkedZeroCopyInput(IZeroCopyInput* in) + inline TChunkedZeroCopyInput(IZeroCopyInput* in) : In(in) - , Buf(nullptr) + , Buf(nullptr) , Len(0) { } @@ -72,7 +72,7 @@ namespace { return true; } - IZeroCopyInput* In; + IZeroCopyInput* In; const char* Buf; size_t Len; }; @@ -162,7 +162,7 @@ private: }; namespace { - class TDecompressStream: public IZeroCopyInput, public TZLibDecompress::TImpl, public TAdditionalStorage<TDecompressStream> { + class TDecompressStream: public IZeroCopyInput, public TZLibDecompress::TImpl, public TAdditionalStorage<TDecompressStream> { public: inline TDecompressStream(IInputStream* input, ZLib::StreamType type, TStringBuf dict) : TZLibDecompress::TImpl(this, type, dict) @@ -181,7 +181,7 @@ namespace { } private: - IInputStream* Stream_; + IInputStream* Stream_; }; using TZeroCopyDecompress = TZLibDecompress::TImpl; @@ -314,7 +314,7 @@ private: } private: - IOutputStream* Stream_; + IOutputStream* Stream_; THolder<gz_header> GZHeader_; }; diff --git a/util/stream/zlib.h b/util/stream/zlib.h index e7de7c81b74..8abf255b53f 100644 --- a/util/stream/zlib.h +++ b/util/stream/zlib.h @@ -1,6 +1,6 @@ #pragma once -#include "fwd.h" +#include "fwd.h" #include "input.h" #include "output.h" #include "buffered.h" @@ -45,7 +45,7 @@ namespace ZLib { * benchmark). For fast buffered ZLib stream reading use `TBufferedZLibDecompress` * aka `TZDecompress`. */ -class TZLibDecompress: public IInputStream { +class TZLibDecompress: public IInputStream { public: TZLibDecompress(IZeroCopyInput* input, ZLib::StreamType type = ZLib::Auto, TStringBuf dict = {}); TZLibDecompress(IInputStream* input, ZLib::StreamType type = ZLib::Auto, size_t buflen = ZLib::ZLIB_BUF_LEN, @@ -56,7 +56,7 @@ public: * * If multiple streams are allowed, their decompressed content will be concatenated. * If multiple streams are disabled, then only first stream is decompressed. After that end - * of IInputStream will have happen, i.e. method Read() will return 0. + * of IInputStream will have happen, i.e. method Read() will return 0. * * @param allowMultipleStreams - flag to allow (true) or disable (false) multiple streams. */ @@ -75,10 +75,10 @@ public: /** * Non-buffered ZLib compressing stream. */ -class TZLibCompress: public IOutputStream { +class TZLibCompress: public IOutputStream { public: struct TParams { - inline TParams(IOutputStream* out) + inline TParams(IOutputStream* out) : Out(out) , Type(ZLib::ZLib) , CompressionLevel(6) @@ -104,13 +104,13 @@ public: return *this; } - inline TParams& SetDict(const TStringBuf dict) noexcept { + inline TParams& SetDict(const TStringBuf dict) noexcept { Dict = dict; return *this; } - IOutputStream* Out; + IOutputStream* Out; ZLib::StreamType Type; size_t CompressionLevel; size_t BufLen; @@ -121,15 +121,15 @@ public: Init(params); } - inline TZLibCompress(IOutputStream* out, ZLib::StreamType type) { + inline TZLibCompress(IOutputStream* out, ZLib::StreamType type) { Init(TParams(out).SetType(type)); } - inline TZLibCompress(IOutputStream* out, ZLib::StreamType type, size_t compression_level) { + inline TZLibCompress(IOutputStream* out, ZLib::StreamType type, size_t compression_level) { Init(TParams(out).SetType(type).SetCompressionLevel(compression_level)); } - inline TZLibCompress(IOutputStream* out, ZLib::StreamType type, size_t compression_level, size_t buflen) { + inline TZLibCompress(IOutputStream* out, ZLib::StreamType type, size_t compression_level, size_t buflen) { Init(TParams(out).SetType(type).SetCompressionLevel(compression_level).SetBufLen(buflen)); } diff --git a/util/stream/zlib_ut.cpp b/util/stream/zlib_ut.cpp index 2290b4a9dee..b145da317f9 100644 --- a/util/stream/zlib_ut.cpp +++ b/util/stream/zlib_ut.cpp @@ -51,11 +51,11 @@ private: int Limit_; }; -Y_UNIT_TEST_SUITE(TZLibTest) { +Y_UNIT_TEST_SUITE(TZLibTest) { static const TString DATA = "8s7d5vc6s5vc67sa4c65ascx6asd4xcv76adsfxv76s"; static const TString DATA2 = "cn8wk2bd9vb3vdfif83g1ks94bfiovtwv"; - Y_UNIT_TEST(Compress) { + Y_UNIT_TEST(Compress) { TUnbufferedFileOutput o(ZDATA); TZLibCompress c(&o, ZLib::ZLib); @@ -64,7 +64,7 @@ Y_UNIT_TEST_SUITE(TZLibTest) { o.Finish(); } - Y_UNIT_TEST(Decompress) { + Y_UNIT_TEST(Decompress) { TTempFile tmpFile(ZDATA); { @@ -90,7 +90,7 @@ Y_UNIT_TEST_SUITE(TZLibTest) { } } - Y_UNIT_TEST(DecompressTwoStreams) { + Y_UNIT_TEST(DecompressTwoStreams) { // Check that Decompress(Compress(X) + Compress(Y)) == X + Y TTempFile tmpFile(ZDATA); { @@ -126,7 +126,7 @@ Y_UNIT_TEST_SUITE(TZLibTest) { TVector<char>().swap(buf); } - Y_UNIT_TEST(DecompressFirstOfTwoStreams) { + Y_UNIT_TEST(DecompressFirstOfTwoStreams) { // Check that Decompress(Compress(X) + Compress(Y)) == X when single stream is allowed TTempFile tmpFile(ZDATA); { diff --git a/util/string/ascii.h b/util/string/ascii.h index 10344384d33..9c2c090df1a 100644 --- a/util/string/ascii.h +++ b/util/string/ascii.h @@ -60,7 +60,7 @@ namespace NPrivate { #endif } -constexpr bool IsAscii(const int c) noexcept { +constexpr bool IsAscii(const int c) noexcept { return !(c & ~0x7f); } diff --git a/util/string/ascii_ut.cpp b/util/string/ascii_ut.cpp index 89069fee50a..94fea01a0e6 100644 --- a/util/string/ascii_ut.cpp +++ b/util/string/ascii_ut.cpp @@ -3,8 +3,8 @@ #include <library/cpp/testing/unittest/registar.h> -Y_UNIT_TEST_SUITE(TAsciiTest) { - Y_UNIT_TEST(TestAscii) { +Y_UNIT_TEST_SUITE(TAsciiTest) { + Y_UNIT_TEST(TestAscii) { UNIT_ASSERT(IsAsciiDigit('3')); UNIT_ASSERT(!IsAsciiDigit('x')); @@ -38,7 +38,7 @@ Y_UNIT_TEST_SUITE(TAsciiTest) { } } - Y_UNIT_TEST(Test1) { + Y_UNIT_TEST(Test1) { for (int i = 128; i < 1000; ++i) { UNIT_ASSERT(!IsAsciiHex(i)); UNIT_ASSERT(!IsAsciiSpace(i)); @@ -62,7 +62,7 @@ Y_UNIT_TEST_SUITE(TAsciiTest) { } } - Y_UNIT_TEST(CompareTest) { + Y_UNIT_TEST(CompareTest) { UNIT_ASSERT(AsciiEqualsIgnoreCase("qqq", "qQq")); UNIT_ASSERT(AsciiEqualsIgnoreCase("qqq", TStringBuf("qQq"))); TString qq = "qq"; diff --git a/util/string/benchmark/float_to_string/main.cpp b/util/string/benchmark/float_to_string/main.cpp index 1c7c0684a31..c15b6009ad9 100644 --- a/util/string/benchmark/float_to_string/main.cpp +++ b/util/string/benchmark/float_to_string/main.cpp @@ -1,253 +1,253 @@ #include <library/cpp/testing/benchmark/bench.h> - -#include <util/generic/singleton.h> -#include <util/generic/vector.h> -#include <util/generic/xrange.h> -#include <util/generic/ymath.h> -#include <util/random/fast.h> -#include <util/string/cast.h> -#include <util/string/printf.h> - -#include <limits> - -#include <cmath> - -/* Please be careful before making any decisions based on this benchmark. - * - * Only `Sprintf("%.<decimals>f", x)` and `FloatToString(x, PREC_POINT_DIGITS, decimals` produce - * equal results in general case. However, results for cases when x \in [0, 1) must be equal for - * both `Sprintf` and `FloatToString`. - * - * Read more about formatting in STL [1, 2] and Yandex Util formatting [3] - * - * [1] http://www.cplusplus.com/reference/cstdio/printf/ - * [2] http://en.cppreference.com/w/c/io/fprintf - * [3] https://a.yandex-team.ru/arc/trunk/arcadia/util/string/cast.h?rev=2432660#L29 - */ - -namespace { - template <typename T> - struct TExample { - T Value{}; - int DigitsCount{}; - }; - - template <typename T, size_t N> - struct TExamplesHolder { + +#include <util/generic/singleton.h> +#include <util/generic/vector.h> +#include <util/generic/xrange.h> +#include <util/generic/ymath.h> +#include <util/random/fast.h> +#include <util/string/cast.h> +#include <util/string/printf.h> + +#include <limits> + +#include <cmath> + +/* Please be careful before making any decisions based on this benchmark. + * + * Only `Sprintf("%.<decimals>f", x)` and `FloatToString(x, PREC_POINT_DIGITS, decimals` produce + * equal results in general case. However, results for cases when x \in [0, 1) must be equal for + * both `Sprintf` and `FloatToString`. + * + * Read more about formatting in STL [1, 2] and Yandex Util formatting [3] + * + * [1] http://www.cplusplus.com/reference/cstdio/printf/ + * [2] http://en.cppreference.com/w/c/io/fprintf + * [3] https://a.yandex-team.ru/arc/trunk/arcadia/util/string/cast.h?rev=2432660#L29 + */ + +namespace { + template <typename T> + struct TExample { + T Value{}; + int DigitsCount{}; + }; + + template <typename T, size_t N> + struct TExamplesHolder { TVector<TExample<T>> Examples; - - TExamplesHolder() + + TExamplesHolder() : Examples(N) { - TFastRng<ui64> prng{N * sizeof(T) * 42}; - for (auto& x : Examples) { - x.Value = prng.GenRandReal4() + prng.Uniform(Max<ui16>()); - x.DigitsCount = prng.Uniform(std::numeric_limits<T>::max_digits10 + 1); - } - } - }; - - template <typename T, size_t N> - struct TNearZeroExamplesHolder { + TFastRng<ui64> prng{N * sizeof(T) * 42}; + for (auto& x : Examples) { + x.Value = prng.GenRandReal4() + prng.Uniform(Max<ui16>()); + x.DigitsCount = prng.Uniform(std::numeric_limits<T>::max_digits10 + 1); + } + } + }; + + template <typename T, size_t N> + struct TNearZeroExamplesHolder { TVector<TExample<T>> Examples; - - TNearZeroExamplesHolder() + + TNearZeroExamplesHolder() : Examples(N) { - TFastRng<ui64> prng{N * sizeof(T) * 42}; - for (auto& x : Examples) { - x.Value = prng.GenRandReal4(); - x.DigitsCount = prng.Uniform(std::numeric_limits<T>::max_digits10 + 1); - } - } - }; -} - -static const char* FORMAT_FIXED[] = { - "%.0f", - "%.1f", - "%.2f", - "%.3f", - "%.4f", - "%.5f", - "%.6f", - "%.7f", - "%.8f", - "%.9f", - "%.10f", - "%.11f", - "%.12f", - "%.13f", - "%.14f", - "%.15f", - "%.16f", - "%.17f", -}; - -static const char* FORMAT_SIGNIFICANT[] = { - "%.0g", - "%.1g", - "%.2g", - "%.3g", - "%.4g", - "%.5g", - "%.6g", - "%.7g", - "%.8g", - "%.9g", - "%.10g", - "%.11g", - "%.12g", - "%.13g", - "%.14g", - "%.15g", - "%.16g", - "%.17g", -}; - -#define DEFINE_BENCHMARK(type, count) \ - Y_CPU_BENCHMARK(SprintfAuto_##type##_##count, iface) { \ - const auto& examples = Default<TExamplesHolder<type, count>>().Examples; \ - for (const auto i : xrange(iface.Iterations())) { \ - Y_UNUSED(i); \ - for (const auto e : examples) { \ - /* this is in fact equal to Sprintf("%.6f", e.Value) and that is why it is faster */ \ - /* than FloatToString(e.Value) */ \ - Y_DO_NOT_OPTIMIZE_AWAY(Sprintf("%f", e.Value)); \ - } \ - } \ - } \ - \ - Y_CPU_BENCHMARK(FloatToStringAuto_##type##_##count, iface) { \ - const auto& examples = Default<TExamplesHolder<type, count>>().Examples; \ - for (const auto i : xrange(iface.Iterations())) { \ - Y_UNUSED(i); \ - for (const auto e : examples) { \ - Y_DO_NOT_OPTIMIZE_AWAY(FloatToString(e.Value)); \ - } \ - } \ - } \ - \ - Y_CPU_BENCHMARK(SprintfFixed_##type##_##count, iface) { \ - const auto& examples = Default<TExamplesHolder<type, count>>().Examples; \ - for (const auto i : xrange(iface.Iterations())) { \ - Y_UNUSED(i); \ - for (const auto e : examples) { \ - Y_DO_NOT_OPTIMIZE_AWAY(Sprintf(FORMAT_FIXED[e.DigitsCount], e.Value)); \ - } \ - } \ - } \ - \ - Y_CPU_BENCHMARK(FloatToStringFixed_##type##_##count, iface) { \ - const auto& examples = Default<TExamplesHolder<type, count>>().Examples; \ - for (const auto i : xrange(iface.Iterations())) { \ - Y_UNUSED(i); \ - for (const auto e : examples) { \ - Y_DO_NOT_OPTIMIZE_AWAY(FloatToString(e.Value, PREC_NDIGITS, e.DigitsCount)); \ - } \ - } \ - } \ - \ - Y_CPU_BENCHMARK(SprintfSignificant_##type##_##count, iface) { \ - const auto& examples = Default<TExamplesHolder<type, count>>().Examples; \ - for (const auto i : xrange(iface.Iterations())) { \ - Y_UNUSED(i); \ - for (const auto e : examples) { \ - Y_DO_NOT_OPTIMIZE_AWAY(Sprintf(FORMAT_SIGNIFICANT[e.DigitsCount], e.Value)); \ - } \ - } \ - } \ - \ - Y_CPU_BENCHMARK(FloatToStringSignificant_##type##_##count, iface) { \ - const auto& examples = Default<TExamplesHolder<type, count>>().Examples; \ - for (const auto i : xrange(iface.Iterations())) { \ - Y_UNUSED(i); \ - for (const auto e : examples) { \ - Y_DO_NOT_OPTIMIZE_AWAY(FloatToString(e.Value, PREC_POINT_DIGITS, e.DigitsCount)); \ - } \ - } \ - } \ - \ - Y_CPU_BENCHMARK(NearZeroSprintfAuto_##type##_##count, iface) { \ - const auto& examples = Default<TNearZeroExamplesHolder<type, count>>().Examples; \ - for (const auto i : xrange(iface.Iterations())) { \ - Y_UNUSED(i); \ - for (const auto e : examples) { \ - /* this is in fact equal to Sprintf("%.6f", e.Value) and that is why it is faster */ \ - /* than FloatToString(e.Value) */ \ - Y_DO_NOT_OPTIMIZE_AWAY(Sprintf("%f", e.Value)); \ - } \ - } \ - } \ - \ - Y_CPU_BENCHMARK(NearZeroFloatToStringAuto_##type##_##count, iface) { \ - const auto& examples = Default<TNearZeroExamplesHolder<type, count>>().Examples; \ - for (const auto i : xrange(iface.Iterations())) { \ - Y_UNUSED(i); \ - for (const auto e : examples) { \ - Y_DO_NOT_OPTIMIZE_AWAY(FloatToString(e.Value)); \ - } \ - } \ - } \ - \ - Y_CPU_BENCHMARK(NearZeroSprintfFixed_##type##_##count, iface) { \ - const auto& examples = Default<TNearZeroExamplesHolder<type, count>>().Examples; \ - for (const auto i : xrange(iface.Iterations())) { \ - Y_UNUSED(i); \ - for (const auto e : examples) { \ - Y_DO_NOT_OPTIMIZE_AWAY(Sprintf(FORMAT_FIXED[e.DigitsCount], e.Value)); \ - } \ - } \ - } \ - \ - Y_CPU_BENCHMARK(NearZeroFloatToStringFixed_##type##_##count, iface) { \ - const auto& examples = Default<TNearZeroExamplesHolder<type, count>>().Examples; \ - for (const auto i : xrange(iface.Iterations())) { \ - Y_UNUSED(i); \ - for (const auto e : examples) { \ - Y_DO_NOT_OPTIMIZE_AWAY(FloatToString(e.Value, PREC_NDIGITS, e.DigitsCount)); \ - } \ - } \ - } \ - \ - Y_CPU_BENCHMARK(NearZeroSprintfSignificant_##type##_##count, iface) { \ - const auto& examples = Default<TNearZeroExamplesHolder<type, count>>().Examples; \ - for (const auto i : xrange(iface.Iterations())) { \ - Y_UNUSED(i); \ - for (const auto e : examples) { \ - Y_DO_NOT_OPTIMIZE_AWAY(Sprintf(FORMAT_SIGNIFICANT[e.DigitsCount], e.Value)); \ - } \ - } \ - } \ - \ - Y_CPU_BENCHMARK(NearZeroFloatToStringSignificant_##type##_##count, iface) { \ - const auto& examples = Default<TNearZeroExamplesHolder<type, count>>().Examples; \ - for (const auto i : xrange(iface.Iterations())) { \ - Y_UNUSED(i); \ - for (const auto e : examples) { \ - Y_DO_NOT_OPTIMIZE_AWAY(FloatToString(e.Value, PREC_POINT_DIGITS, e.DigitsCount)); \ - } \ - } \ - } - -DEFINE_BENCHMARK(float, 1); -DEFINE_BENCHMARK(float, 2); -DEFINE_BENCHMARK(float, 4); -DEFINE_BENCHMARK(float, 8); -DEFINE_BENCHMARK(float, 16); -DEFINE_BENCHMARK(float, 32); -DEFINE_BENCHMARK(float, 64); -DEFINE_BENCHMARK(float, 128); -DEFINE_BENCHMARK(float, 256); - -DEFINE_BENCHMARK(double, 1); -DEFINE_BENCHMARK(double, 2); -DEFINE_BENCHMARK(double, 4); -DEFINE_BENCHMARK(double, 8); -DEFINE_BENCHMARK(double, 16); -DEFINE_BENCHMARK(double, 32); -DEFINE_BENCHMARK(double, 64); -DEFINE_BENCHMARK(double, 128); -DEFINE_BENCHMARK(double, 256); - -#undef DEFINE_BENCHMARK + TFastRng<ui64> prng{N * sizeof(T) * 42}; + for (auto& x : Examples) { + x.Value = prng.GenRandReal4(); + x.DigitsCount = prng.Uniform(std::numeric_limits<T>::max_digits10 + 1); + } + } + }; +} + +static const char* FORMAT_FIXED[] = { + "%.0f", + "%.1f", + "%.2f", + "%.3f", + "%.4f", + "%.5f", + "%.6f", + "%.7f", + "%.8f", + "%.9f", + "%.10f", + "%.11f", + "%.12f", + "%.13f", + "%.14f", + "%.15f", + "%.16f", + "%.17f", +}; + +static const char* FORMAT_SIGNIFICANT[] = { + "%.0g", + "%.1g", + "%.2g", + "%.3g", + "%.4g", + "%.5g", + "%.6g", + "%.7g", + "%.8g", + "%.9g", + "%.10g", + "%.11g", + "%.12g", + "%.13g", + "%.14g", + "%.15g", + "%.16g", + "%.17g", +}; + +#define DEFINE_BENCHMARK(type, count) \ + Y_CPU_BENCHMARK(SprintfAuto_##type##_##count, iface) { \ + const auto& examples = Default<TExamplesHolder<type, count>>().Examples; \ + for (const auto i : xrange(iface.Iterations())) { \ + Y_UNUSED(i); \ + for (const auto e : examples) { \ + /* this is in fact equal to Sprintf("%.6f", e.Value) and that is why it is faster */ \ + /* than FloatToString(e.Value) */ \ + Y_DO_NOT_OPTIMIZE_AWAY(Sprintf("%f", e.Value)); \ + } \ + } \ + } \ + \ + Y_CPU_BENCHMARK(FloatToStringAuto_##type##_##count, iface) { \ + const auto& examples = Default<TExamplesHolder<type, count>>().Examples; \ + for (const auto i : xrange(iface.Iterations())) { \ + Y_UNUSED(i); \ + for (const auto e : examples) { \ + Y_DO_NOT_OPTIMIZE_AWAY(FloatToString(e.Value)); \ + } \ + } \ + } \ + \ + Y_CPU_BENCHMARK(SprintfFixed_##type##_##count, iface) { \ + const auto& examples = Default<TExamplesHolder<type, count>>().Examples; \ + for (const auto i : xrange(iface.Iterations())) { \ + Y_UNUSED(i); \ + for (const auto e : examples) { \ + Y_DO_NOT_OPTIMIZE_AWAY(Sprintf(FORMAT_FIXED[e.DigitsCount], e.Value)); \ + } \ + } \ + } \ + \ + Y_CPU_BENCHMARK(FloatToStringFixed_##type##_##count, iface) { \ + const auto& examples = Default<TExamplesHolder<type, count>>().Examples; \ + for (const auto i : xrange(iface.Iterations())) { \ + Y_UNUSED(i); \ + for (const auto e : examples) { \ + Y_DO_NOT_OPTIMIZE_AWAY(FloatToString(e.Value, PREC_NDIGITS, e.DigitsCount)); \ + } \ + } \ + } \ + \ + Y_CPU_BENCHMARK(SprintfSignificant_##type##_##count, iface) { \ + const auto& examples = Default<TExamplesHolder<type, count>>().Examples; \ + for (const auto i : xrange(iface.Iterations())) { \ + Y_UNUSED(i); \ + for (const auto e : examples) { \ + Y_DO_NOT_OPTIMIZE_AWAY(Sprintf(FORMAT_SIGNIFICANT[e.DigitsCount], e.Value)); \ + } \ + } \ + } \ + \ + Y_CPU_BENCHMARK(FloatToStringSignificant_##type##_##count, iface) { \ + const auto& examples = Default<TExamplesHolder<type, count>>().Examples; \ + for (const auto i : xrange(iface.Iterations())) { \ + Y_UNUSED(i); \ + for (const auto e : examples) { \ + Y_DO_NOT_OPTIMIZE_AWAY(FloatToString(e.Value, PREC_POINT_DIGITS, e.DigitsCount)); \ + } \ + } \ + } \ + \ + Y_CPU_BENCHMARK(NearZeroSprintfAuto_##type##_##count, iface) { \ + const auto& examples = Default<TNearZeroExamplesHolder<type, count>>().Examples; \ + for (const auto i : xrange(iface.Iterations())) { \ + Y_UNUSED(i); \ + for (const auto e : examples) { \ + /* this is in fact equal to Sprintf("%.6f", e.Value) and that is why it is faster */ \ + /* than FloatToString(e.Value) */ \ + Y_DO_NOT_OPTIMIZE_AWAY(Sprintf("%f", e.Value)); \ + } \ + } \ + } \ + \ + Y_CPU_BENCHMARK(NearZeroFloatToStringAuto_##type##_##count, iface) { \ + const auto& examples = Default<TNearZeroExamplesHolder<type, count>>().Examples; \ + for (const auto i : xrange(iface.Iterations())) { \ + Y_UNUSED(i); \ + for (const auto e : examples) { \ + Y_DO_NOT_OPTIMIZE_AWAY(FloatToString(e.Value)); \ + } \ + } \ + } \ + \ + Y_CPU_BENCHMARK(NearZeroSprintfFixed_##type##_##count, iface) { \ + const auto& examples = Default<TNearZeroExamplesHolder<type, count>>().Examples; \ + for (const auto i : xrange(iface.Iterations())) { \ + Y_UNUSED(i); \ + for (const auto e : examples) { \ + Y_DO_NOT_OPTIMIZE_AWAY(Sprintf(FORMAT_FIXED[e.DigitsCount], e.Value)); \ + } \ + } \ + } \ + \ + Y_CPU_BENCHMARK(NearZeroFloatToStringFixed_##type##_##count, iface) { \ + const auto& examples = Default<TNearZeroExamplesHolder<type, count>>().Examples; \ + for (const auto i : xrange(iface.Iterations())) { \ + Y_UNUSED(i); \ + for (const auto e : examples) { \ + Y_DO_NOT_OPTIMIZE_AWAY(FloatToString(e.Value, PREC_NDIGITS, e.DigitsCount)); \ + } \ + } \ + } \ + \ + Y_CPU_BENCHMARK(NearZeroSprintfSignificant_##type##_##count, iface) { \ + const auto& examples = Default<TNearZeroExamplesHolder<type, count>>().Examples; \ + for (const auto i : xrange(iface.Iterations())) { \ + Y_UNUSED(i); \ + for (const auto e : examples) { \ + Y_DO_NOT_OPTIMIZE_AWAY(Sprintf(FORMAT_SIGNIFICANT[e.DigitsCount], e.Value)); \ + } \ + } \ + } \ + \ + Y_CPU_BENCHMARK(NearZeroFloatToStringSignificant_##type##_##count, iface) { \ + const auto& examples = Default<TNearZeroExamplesHolder<type, count>>().Examples; \ + for (const auto i : xrange(iface.Iterations())) { \ + Y_UNUSED(i); \ + for (const auto e : examples) { \ + Y_DO_NOT_OPTIMIZE_AWAY(FloatToString(e.Value, PREC_POINT_DIGITS, e.DigitsCount)); \ + } \ + } \ + } + +DEFINE_BENCHMARK(float, 1); +DEFINE_BENCHMARK(float, 2); +DEFINE_BENCHMARK(float, 4); +DEFINE_BENCHMARK(float, 8); +DEFINE_BENCHMARK(float, 16); +DEFINE_BENCHMARK(float, 32); +DEFINE_BENCHMARK(float, 64); +DEFINE_BENCHMARK(float, 128); +DEFINE_BENCHMARK(float, 256); + +DEFINE_BENCHMARK(double, 1); +DEFINE_BENCHMARK(double, 2); +DEFINE_BENCHMARK(double, 4); +DEFINE_BENCHMARK(double, 8); +DEFINE_BENCHMARK(double, 16); +DEFINE_BENCHMARK(double, 32); +DEFINE_BENCHMARK(double, 64); +DEFINE_BENCHMARK(double, 128); +DEFINE_BENCHMARK(double, 256); + +#undef DEFINE_BENCHMARK diff --git a/util/string/benchmark/float_to_string/metrics/main.py b/util/string/benchmark/float_to_string/metrics/main.py index e9d4b7ac1d2..fdcfd71b0b3 100644 --- a/util/string/benchmark/float_to_string/metrics/main.py +++ b/util/string/benchmark/float_to_string/metrics/main.py @@ -1,5 +1,5 @@ -import yatest.common as yc - - -def test_export_metrics(metrics): +import yatest.common as yc + + +def test_export_metrics(metrics): metrics.set_benchmark(yc.execute_benchmark('util/string/benchmark/float_to_string/float_to_string', threads=8)) diff --git a/util/string/benchmark/float_to_string/metrics/ya.make b/util/string/benchmark/float_to_string/metrics/ya.make index 4b8c4cc07dd..3081301d1dc 100644 --- a/util/string/benchmark/float_to_string/metrics/ya.make +++ b/util/string/benchmark/float_to_string/metrics/ya.make @@ -1,21 +1,21 @@ -OWNER( - yazevnul +OWNER( + yazevnul g:util -) +) SUBSCRIBER(g:util-subscribers) - + PY2TEST() - + SIZE(LARGE) - -TAG( + +TAG( ya:force_sandbox - sb:intel_e5_2660v1 + sb:intel_e5_2660v1 ya:fat -) - +) + TEST_SRCS(main.py) - + DEPENDS(util/string/benchmark/float_to_string) - -END() + +END() diff --git a/util/string/benchmark/float_to_string/ya.make b/util/string/benchmark/float_to_string/ya.make index 8136ad34f0f..30955f3189f 100644 --- a/util/string/benchmark/float_to_string/ya.make +++ b/util/string/benchmark/float_to_string/ya.make @@ -1,12 +1,12 @@ OWNER(yazevnul) - + Y_BENCHMARK() - + # to minimize allocations overhead ALLOCATOR(B) - -SRCS( - main.cpp -) - -END() + +SRCS( + main.cpp +) + +END() diff --git a/util/string/benchmark/subst_global/main.cpp b/util/string/benchmark/subst_global/main.cpp index e0decfa042e..c9b14a52112 100644 --- a/util/string/benchmark/subst_global/main.cpp +++ b/util/string/benchmark/subst_global/main.cpp @@ -1,203 +1,203 @@ #include <library/cpp/testing/benchmark/bench.h> - -#include <util/generic/cast.h> -#include <util/generic/singleton.h> + +#include <util/generic/cast.h> +#include <util/generic/singleton.h> #include <util/generic/string.h> -#include <util/generic/xrange.h> -#include <util/random/fast.h> -#include <util/string/cast.h> -#include <util/string/subst.h> - -namespace { - template <size_t N, char What, char With> - struct TNoMatches { - enum : char { - WHAT = What, - WITH = With - }; +#include <util/generic/xrange.h> +#include <util/random/fast.h> +#include <util/string/cast.h> +#include <util/string/subst.h> + +namespace { + template <size_t N, char What, char With> + struct TNoMatches { + enum : char { + WHAT = What, + WITH = With + }; TString Str; - - TNoMatches() { - for (const auto dummy : xrange(N)) { - Y_UNUSED(dummy); - Str += WHAT + 1; - } - } - }; - - template <size_t N, char What, char With> - struct TOneMatchInTheBeginning { - enum : char { - WHAT = What, - WITH = With - }; + + TNoMatches() { + for (const auto dummy : xrange(N)) { + Y_UNUSED(dummy); + Str += WHAT + 1; + } + } + }; + + template <size_t N, char What, char With> + struct TOneMatchInTheBeginning { + enum : char { + WHAT = What, + WITH = With + }; TString Str; - - TOneMatchInTheBeginning() { - if (!N) { - return; - } - - Str += WHAT; - if (N > 1) { - for (const auto dummy : xrange(N - 1)) { - Y_UNUSED(dummy); - Str += WHAT + 1; - } - } - } - }; - - template <size_t N, char What, char With> - struct TOneMatchInTheEnd { - enum : char { - WHAT = What, - WITH = With - }; + + TOneMatchInTheBeginning() { + if (!N) { + return; + } + + Str += WHAT; + if (N > 1) { + for (const auto dummy : xrange(N - 1)) { + Y_UNUSED(dummy); + Str += WHAT + 1; + } + } + } + }; + + template <size_t N, char What, char With> + struct TOneMatchInTheEnd { + enum : char { + WHAT = What, + WITH = With + }; TString Str; - - TOneMatchInTheEnd() { - if (!N) { - return; - } - - if (N > 1) { - for (const auto dummy : xrange(N - 1)) { - Y_UNUSED(dummy); - Str += WHAT + 1; - } - } - Str += WHAT; - } - }; - - template <size_t N, char What, char With> - struct TOneMatchInTheMiddle { - enum : char { - WHAT = What, - WITH = With - }; + + TOneMatchInTheEnd() { + if (!N) { + return; + } + + if (N > 1) { + for (const auto dummy : xrange(N - 1)) { + Y_UNUSED(dummy); + Str += WHAT + 1; + } + } + Str += WHAT; + } + }; + + template <size_t N, char What, char With> + struct TOneMatchInTheMiddle { + enum : char { + WHAT = What, + WITH = With + }; TString Str; - - TOneMatchInTheMiddle() { - if (!N) { - return; - } - - for (size_t i = 0; i < N / 2; ++i) { - Str += WHAT + 1; - } - Str += WHAT; - for (; Str.size() < N;) { - Str += WHAT + 1; - } - } - }; - - template <size_t N, char What, char With> - struct TFirstHalfMatches { - enum : char { - WHAT = What, - WITH = With - }; + + TOneMatchInTheMiddle() { + if (!N) { + return; + } + + for (size_t i = 0; i < N / 2; ++i) { + Str += WHAT + 1; + } + Str += WHAT; + for (; Str.size() < N;) { + Str += WHAT + 1; + } + } + }; + + template <size_t N, char What, char With> + struct TFirstHalfMatches { + enum : char { + WHAT = What, + WITH = With + }; TString Str; - - TFirstHalfMatches() { - for (size_t i = 0; i < N / 2; ++i) { - Str += WHAT; - } - for (; Str.size() != N;) { - Str += WHAT + 1; - } - } - }; - - template <size_t N, char What, char With> - struct TSecondHalfMatches { - enum : char { - WHAT = What, - WITH = With - }; + + TFirstHalfMatches() { + for (size_t i = 0; i < N / 2; ++i) { + Str += WHAT; + } + for (; Str.size() != N;) { + Str += WHAT + 1; + } + } + }; + + template <size_t N, char What, char With> + struct TSecondHalfMatches { + enum : char { + WHAT = What, + WITH = With + }; TString Str; - - TSecondHalfMatches() { - for (size_t i = 0; i < N / 2; ++i) { - Str += WHAT + 1; - } - for (; Str.size() != N;) { - Str += WHAT; - } - } - }; - - template <size_t N, size_t K, char What, char With> - struct TEveryKth { - enum : char { - WHAT = What, - WITH = With - }; + + TSecondHalfMatches() { + for (size_t i = 0; i < N / 2; ++i) { + Str += WHAT + 1; + } + for (; Str.size() != N;) { + Str += WHAT; + } + } + }; + + template <size_t N, size_t K, char What, char With> + struct TEveryKth { + enum : char { + WHAT = What, + WITH = With + }; TString Str; - - TEveryKth() { - TFastRng<ui64> prng{N * K * 101}; - for (size_t i = 0; i < N; ++i) { - Str += (prng() % K) ? (WHAT + 1) : WHAT; - } - } - }; -} - -#define DEFINE_BENCHMARK(type, N) \ - Y_CPU_BENCHMARK(type##_##N, i) { \ - using D = T##type<N, 'a', 'z'>; \ - const auto& str = Default<D>().Str; \ - for (const auto dummy : xrange(i.Iterations())) { \ - Y_UNUSED(dummy); \ - auto s = str; \ + + TEveryKth() { + TFastRng<ui64> prng{N * K * 101}; + for (size_t i = 0; i < N; ++i) { + Str += (prng() % K) ? (WHAT + 1) : WHAT; + } + } + }; +} + +#define DEFINE_BENCHMARK(type, N) \ + Y_CPU_BENCHMARK(type##_##N, i) { \ + using D = T##type<N, 'a', 'z'>; \ + const auto& str = Default<D>().Str; \ + for (const auto dummy : xrange(i.Iterations())) { \ + Y_UNUSED(dummy); \ + auto s = str; \ NBench::Escape(s.data()); \ - Y_DO_NOT_OPTIMIZE_AWAY(SubstGlobal(s, ToUnderlying(D::WHAT), ToUnderlying(D::WITH))); \ - NBench::Clobber(); \ - } \ - } - -#define DEFINE_RNG_BENCHMARK(N, K) \ - Y_CPU_BENCHMARK(Random_##N##_##K, i) { \ - using D = TEveryKth<N, K, 'a', 'z'>; \ - const auto& str = Default<D>().Str; \ - for (const auto dummy : xrange(i.Iterations())) { \ - Y_UNUSED(dummy); \ - auto s = str; \ + Y_DO_NOT_OPTIMIZE_AWAY(SubstGlobal(s, ToUnderlying(D::WHAT), ToUnderlying(D::WITH))); \ + NBench::Clobber(); \ + } \ + } + +#define DEFINE_RNG_BENCHMARK(N, K) \ + Y_CPU_BENCHMARK(Random_##N##_##K, i) { \ + using D = TEveryKth<N, K, 'a', 'z'>; \ + const auto& str = Default<D>().Str; \ + for (const auto dummy : xrange(i.Iterations())) { \ + Y_UNUSED(dummy); \ + auto s = str; \ NBench::Escape(s.data()); \ - Y_DO_NOT_OPTIMIZE_AWAY(SubstGlobal(s, ToUnderlying(D::WHAT), ToUnderlying(D::WITH))); \ - NBench::Clobber(); \ - } \ - } - -DEFINE_BENCHMARK(NoMatches, 0) -DEFINE_BENCHMARK(NoMatches, 1) -DEFINE_BENCHMARK(NoMatches, 128) -DEFINE_BENCHMARK(NoMatches, 4096) -DEFINE_BENCHMARK(OneMatchInTheBeginning, 1) -DEFINE_BENCHMARK(OneMatchInTheBeginning, 16) -DEFINE_BENCHMARK(OneMatchInTheBeginning, 128) -DEFINE_BENCHMARK(OneMatchInTheBeginning, 4096) -DEFINE_BENCHMARK(OneMatchInTheEnd, 16) -DEFINE_BENCHMARK(OneMatchInTheEnd, 128) -DEFINE_BENCHMARK(OneMatchInTheEnd, 4096) -DEFINE_BENCHMARK(OneMatchInTheMiddle, 16) -DEFINE_BENCHMARK(OneMatchInTheMiddle, 128) -DEFINE_BENCHMARK(OneMatchInTheMiddle, 4096) -DEFINE_BENCHMARK(FirstHalfMatches, 16) -DEFINE_BENCHMARK(FirstHalfMatches, 128) -DEFINE_BENCHMARK(FirstHalfMatches, 4096) -DEFINE_BENCHMARK(SecondHalfMatches, 16) -DEFINE_BENCHMARK(SecondHalfMatches, 128) -DEFINE_BENCHMARK(SecondHalfMatches, 4096) - -DEFINE_RNG_BENCHMARK(4096, 1) -DEFINE_RNG_BENCHMARK(4096, 2) -DEFINE_RNG_BENCHMARK(4096, 3) -DEFINE_RNG_BENCHMARK(4096, 4) -DEFINE_RNG_BENCHMARK(4096, 10) -DEFINE_RNG_BENCHMARK(4096, 32) -DEFINE_RNG_BENCHMARK(4096, 100) + Y_DO_NOT_OPTIMIZE_AWAY(SubstGlobal(s, ToUnderlying(D::WHAT), ToUnderlying(D::WITH))); \ + NBench::Clobber(); \ + } \ + } + +DEFINE_BENCHMARK(NoMatches, 0) +DEFINE_BENCHMARK(NoMatches, 1) +DEFINE_BENCHMARK(NoMatches, 128) +DEFINE_BENCHMARK(NoMatches, 4096) +DEFINE_BENCHMARK(OneMatchInTheBeginning, 1) +DEFINE_BENCHMARK(OneMatchInTheBeginning, 16) +DEFINE_BENCHMARK(OneMatchInTheBeginning, 128) +DEFINE_BENCHMARK(OneMatchInTheBeginning, 4096) +DEFINE_BENCHMARK(OneMatchInTheEnd, 16) +DEFINE_BENCHMARK(OneMatchInTheEnd, 128) +DEFINE_BENCHMARK(OneMatchInTheEnd, 4096) +DEFINE_BENCHMARK(OneMatchInTheMiddle, 16) +DEFINE_BENCHMARK(OneMatchInTheMiddle, 128) +DEFINE_BENCHMARK(OneMatchInTheMiddle, 4096) +DEFINE_BENCHMARK(FirstHalfMatches, 16) +DEFINE_BENCHMARK(FirstHalfMatches, 128) +DEFINE_BENCHMARK(FirstHalfMatches, 4096) +DEFINE_BENCHMARK(SecondHalfMatches, 16) +DEFINE_BENCHMARK(SecondHalfMatches, 128) +DEFINE_BENCHMARK(SecondHalfMatches, 4096) + +DEFINE_RNG_BENCHMARK(4096, 1) +DEFINE_RNG_BENCHMARK(4096, 2) +DEFINE_RNG_BENCHMARK(4096, 3) +DEFINE_RNG_BENCHMARK(4096, 4) +DEFINE_RNG_BENCHMARK(4096, 10) +DEFINE_RNG_BENCHMARK(4096, 32) +DEFINE_RNG_BENCHMARK(4096, 100) diff --git a/util/string/benchmark/subst_global/metrics/main.py b/util/string/benchmark/subst_global/metrics/main.py index 62f2f3d76d2..8aa05013511 100644 --- a/util/string/benchmark/subst_global/metrics/main.py +++ b/util/string/benchmark/subst_global/metrics/main.py @@ -1,5 +1,5 @@ -import yatest.common as yc - - -def test_export_metrics(metrics): +import yatest.common as yc + + +def test_export_metrics(metrics): metrics.set_benchmark(yc.execute_benchmark('util/string/benchmark/subst_global/subst_global', threads=8)) diff --git a/util/string/benchmark/subst_global/metrics/ya.make b/util/string/benchmark/subst_global/metrics/ya.make index d8c30ad4601..73757bebcb0 100644 --- a/util/string/benchmark/subst_global/metrics/ya.make +++ b/util/string/benchmark/subst_global/metrics/ya.make @@ -1,21 +1,21 @@ -OWNER( - yazevnul +OWNER( + yazevnul g:util -) +) SUBSCRIBER(g:util-subscribers) - + PY2TEST() - + SIZE(LARGE) - -TAG( + +TAG( ya:force_sandbox - sb:intel_e5_2660v1 + sb:intel_e5_2660v1 ya:fat -) - +) + TEST_SRCS(main.py) - + DEPENDS(util/string/benchmark/subst_global) - -END() + +END() diff --git a/util/string/benchmark/subst_global/ya.make b/util/string/benchmark/subst_global/ya.make index 8136ad34f0f..30955f3189f 100644 --- a/util/string/benchmark/subst_global/ya.make +++ b/util/string/benchmark/subst_global/ya.make @@ -1,12 +1,12 @@ OWNER(yazevnul) - + Y_BENCHMARK() - + # to minimize allocations overhead ALLOCATOR(B) - -SRCS( - main.cpp -) - -END() + +SRCS( + main.cpp +) + +END() diff --git a/util/string/benchmark/ya.make b/util/string/benchmark/ya.make index 266b53c7b33..09b112034d2 100644 --- a/util/string/benchmark/ya.make +++ b/util/string/benchmark/ya.make @@ -1,16 +1,16 @@ -OWNER( +OWNER( g:util - yazevnul -) + yazevnul +) SUBSCRIBER(g:util-subscribers) - -RECURSE( + +RECURSE( ascii cast - float_to_string - float_to_string/metrics + float_to_string + float_to_string/metrics join join/metrics - subst_global - subst_global/metrics -) + subst_global + subst_global/metrics +) diff --git a/util/string/builder.cpp b/util/string/builder.cpp index a3821d33991..e1f696c9315 100644 --- a/util/string/builder.cpp +++ b/util/string/builder.cpp @@ -3,6 +3,6 @@ #include <util/stream/output.h> template <> -void Out<TStringBuilder>(IOutputStream& os, const TStringBuilder& sb) { +void Out<TStringBuilder>(IOutputStream& os, const TStringBuilder& sb) { os << static_cast<const TString&>(sb); } diff --git a/util/string/builder_ut.cpp b/util/string/builder_ut.cpp index 22def683ec2..49d18822666 100644 --- a/util/string/builder_ut.cpp +++ b/util/string/builder_ut.cpp @@ -17,19 +17,19 @@ struct TClassWithStreamOperator { } }; -IOutputStream& operator<<(IOutputStream& out, const TClassWithStreamOperator& value) { +IOutputStream& operator<<(IOutputStream& out, const TClassWithStreamOperator& value) { return out << value.Id << " " << value.Name; } -Y_UNIT_TEST_SUITE(TStringBuilderTest) { - Y_UNIT_TEST(TestStringBuilder) { +Y_UNIT_TEST_SUITE(TStringBuilderTest) { + Y_UNIT_TEST(TestStringBuilder) { TestEquals("", TStringBuilder()); TestEquals("a", TStringBuilder() << "a"); TestEquals("a1", TStringBuilder() << "a" << 1); TestEquals("value: 123 name", TStringBuilder() << "value: " << TClassWithStreamOperator(123, "name")); } - Y_UNIT_TEST(TestStringBuilderOut) { + Y_UNIT_TEST(TestStringBuilderOut) { TString s; TStringOutput out(s); TStringBuilder sb; @@ -38,7 +38,7 @@ Y_UNIT_TEST_SUITE(TStringBuilderTest) { TestEquals("a", s); } - Y_UNIT_TEST(TestStringBuilderRValue) { + Y_UNIT_TEST(TestStringBuilderRValue) { struct TRValueAcceptTester { static bool IsRValue(const TString&) { return false; diff --git a/util/string/cast.cpp b/util/string/cast.cpp index aa1e65a8e90..d1165cade12 100644 --- a/util/string/cast.cpp +++ b/util/string/cast.cpp @@ -30,123 +30,123 @@ using double_conversion::StringToDoubleConverter; * ------------------------------ formatters ------------------------------ */ -namespace { +namespace { constexpr char IntToChar[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'}; - - static_assert(Y_ARRAY_SIZE(IntToChar) == 16, "expect Y_ARRAY_SIZE(IntToChar) == 16"); - + + static_assert(Y_ARRAY_SIZE(IntToChar) == 16, "expect Y_ARRAY_SIZE(IntToChar) == 16"); + // clang-format off constexpr int LetterToIntMap[] = { - 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, - 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, - 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, - 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, - 20, 20, 20, 20, 20, 20, 20, 20, 0, 1, - 2, 3, 4, 5, 6, 7, 8, 9, 20, 20, - 20, 20, 20, 20, 20, 10, 11, 12, 13, 14, - 15, 20, 20, 20, 20, 20, 20, 20, 20, 20, - 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, - 20, 20, 20, 20, 20, 20, 20, 10, 11, 12, - 13, 14, 15, - }; + 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, + 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, + 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, + 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, + 20, 20, 20, 20, 20, 20, 20, 20, 0, 1, + 2, 3, 4, 5, 6, 7, 8, 9, 20, 20, + 20, 20, 20, 20, 20, 10, 11, 12, 13, 14, + 15, 20, 20, 20, 20, 20, 20, 20, 20, 20, + 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, + 20, 20, 20, 20, 20, 20, 20, 10, 11, 12, + 13, 14, 15, + }; // clang-format on - - template <class T> + + template <class T> std::enable_if_t<std::is_signed<T>::value, std::make_unsigned_t<T>> NegateNegativeSigned(T value) noexcept { return std::make_unsigned_t<T>(-(value + 1)) + std::make_unsigned_t<T>(1); } - template <class T> + template <class T> std::enable_if_t<std::is_unsigned<T>::value, std::make_unsigned_t<T>> NegateNegativeSigned(T) noexcept { Y_UNREACHABLE(); - } + } template <class T> std::make_signed_t<T> NegatePositiveSigned(T value) noexcept { return value > 0 ? (-std::make_signed_t<T>(value - 1) - 1) : 0; } - template <class T, unsigned base, class TChar> - struct TBasicIntFormatter { - static_assert(1 < base && base < 17, "expect 1 < base && base < 17"); + template <class T, unsigned base, class TChar> + struct TBasicIntFormatter { + static_assert(1 < base && base < 17, "expect 1 < base && base < 17"); static_assert(std::is_unsigned<T>::value, "TBasicIntFormatter can only handle unsigned integers."); - static inline size_t Format(T value, TChar* buf, size_t len) { + static inline size_t Format(T value, TChar* buf, size_t len) { Y_ENSURE(len, TStringBuf("zero length")); - TChar* tmp = buf; - - do { + TChar* tmp = buf; + + do { // divide only once, do not use mod const T nextVal = static_cast<T>(value / base); *tmp++ = IntToChar[base == 2 || base == 4 || base == 8 || base == 16 ? value & (base - 1) : value - base * nextVal]; value = nextVal; - } while (value && --len); - + } while (value && --len); + Y_ENSURE(!value, TStringBuf("not enough room in buffer")); - - const size_t result = tmp - buf; - - --tmp; - - while (buf < tmp) { - TChar c = *buf; - - *buf = *tmp; - *tmp = c; - ++buf; - --tmp; - } - - return result; + + const size_t result = tmp - buf; + + --tmp; + + while (buf < tmp) { + TChar c = *buf; + + *buf = *tmp; + *tmp = c; + ++buf; + --tmp; + } + + return result; } - }; + }; - template <class T, unsigned base, class TChar> - struct TIntFormatter { - static_assert(1 < base && base < 17, "expect 1 < base && base < 17"); + template <class T, unsigned base, class TChar> + struct TIntFormatter { + static_assert(1 < base && base < 17, "expect 1 < base && base < 17"); static_assert(std::is_integral<T>::value, "T must be an integral type."); - static inline size_t Format(T value, TChar* buf, size_t len) { + static inline size_t Format(T value, TChar* buf, size_t len) { using TUFmt = TBasicIntFormatter<std::make_unsigned_t<T>, base, TChar>; - + if (std::is_signed<T>::value && value < 0) { Y_ENSURE(len >= 2, TStringBuf("not enough room in buffer")); - - *buf = '-'; + + *buf = '-'; return 1 + TUFmt::Format(NegateNegativeSigned(value), buf + 1, len - 1); - } - + } + return TUFmt::Format(value, buf, len); } - }; + }; - template <class T> - struct TFltModifiers; + template <class T> + struct TFltModifiers; - template <class T, int base, class TChar> + template <class T, int base, class TChar> Y_NO_INLINE size_t FormatInt(T value, TChar* buf, size_t len) { - return TIntFormatter<T, base, TChar>::Format(value, buf, len); - } + return TIntFormatter<T, base, TChar>::Format(value, buf, len); + } - template <class T> + template <class T> inline size_t FormatFlt(T t, char* buf, size_t len) { - const int ret = snprintf(buf, len, TFltModifiers<T>::ModifierWrite, t); + const int ret = snprintf(buf, len, TFltModifiers<T>::ModifierWrite, t); Y_ENSURE(ret >= 0 && (size_t)ret <= len, TStringBuf("cannot format float")); - return (size_t)ret; + return (size_t)ret; } - enum EParseStatus { - PS_OK = 0, - PS_EMPTY_STRING, - PS_PLUS_STRING, - PS_MINUS_STRING, - PS_BAD_SYMBOL, - PS_OVERFLOW, - }; + enum EParseStatus { + PS_OK = 0, + PS_EMPTY_STRING, + PS_PLUS_STRING, + PS_MINUS_STRING, + PS_BAD_SYMBOL, + PS_OVERFLOW, + }; constexpr ui8 SAFE_LENS[4][17] = { {0, 0, 7, 5, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1}, @@ -177,19 +177,19 @@ namespace { return (c >= '0') && ((*digit = (c - '0')) < BASE); } - template <class T, unsigned base, class TChar> - struct TBasicIntParser { - static_assert(1 < base && base < 17, "Expect 1 < base && base < 17."); + template <class T, unsigned base, class TChar> + struct TBasicIntParser { + static_assert(1 < base && base < 17, "Expect 1 < base && base < 17."); static_assert(std::is_unsigned<T>::value, "TBasicIntParser can only handle unsigned integers."); - + enum : unsigned { BASE_POW_2 = base * base, }; static inline EParseStatus Parse(const TChar** ppos, const TChar* end, T max, T* target) noexcept { - Y_ASSERT(*ppos != end); /* This check should be somewhere up the stack. */ + Y_ASSERT(*ppos != end); /* This check should be somewhere up the stack. */ const size_t maxSafeLen = SAFE_LENS[ConstLog2(sizeof(T))][base]; - + // can parse without overflow if (size_t(end - *ppos) <= maxSafeLen) { T result; @@ -205,7 +205,7 @@ namespace { } static inline bool ParseFast(const TChar* pos, const TChar* end, T* target) noexcept { - T result = T(); + T result = T(); T d1; T d2; @@ -229,164 +229,164 @@ namespace { static inline EParseStatus ParseSlow(const TChar** ppos, const TChar* end, T max, T* target) noexcept { T result = T(); - T preMulMax = max / base; - const TChar* pos = *ppos; - - while (pos != end) { - T digit; + T preMulMax = max / base; + const TChar* pos = *ppos; + + while (pos != end) { + T digit; if (!CharToDigit<base>(*pos, &digit)) { - *ppos = pos; - - return PS_BAD_SYMBOL; - } - - if (result > preMulMax) { - return PS_OVERFLOW; - } - - result *= base; - - if (result > max - digit) { - return PS_OVERFLOW; - } - - result += digit; - pos++; - } - - *target = result; - - return PS_OK; - } + *ppos = pos; + + return PS_BAD_SYMBOL; + } + + if (result > preMulMax) { + return PS_OVERFLOW; + } + + result *= base; + + if (result > max - digit) { + return PS_OVERFLOW; + } + + result += digit; + pos++; + } + + *target = result; + + return PS_OK; + } }; - template <class T> - struct TBounds { - T PositiveMax; - T NegativeMax; - }; + template <class T> + struct TBounds { + T PositiveMax; + T NegativeMax; + }; - template <class T, unsigned base, class TChar> - struct TIntParser { - static_assert(1 < base && base < 17, "Expect 1 < base && base < 17."); + template <class T, unsigned base, class TChar> + struct TIntParser { + static_assert(1 < base && base < 17, "Expect 1 < base && base < 17."); static_assert(std::is_integral<T>::value, "T must be an integral type."); - enum { + enum { IsSigned = std::is_signed<T>::value - }; - - using TUnsigned = std::make_unsigned_t<T>; - - static inline EParseStatus Parse(const TChar** ppos, const TChar* end, const TBounds<TUnsigned>& bounds, T* target) { - const TChar* pos = *ppos; - if (pos == end) { - return PS_EMPTY_STRING; + }; + + using TUnsigned = std::make_unsigned_t<T>; + + static inline EParseStatus Parse(const TChar** ppos, const TChar* end, const TBounds<TUnsigned>& bounds, T* target) { + const TChar* pos = *ppos; + if (pos == end) { + return PS_EMPTY_STRING; } bool negative = false; - TUnsigned max; - if (*pos == '+') { - pos++; - max = bounds.PositiveMax; - - if (pos == end) { - return PS_PLUS_STRING; - } - } else if (IsSigned && *pos == '-') { - pos++; - max = bounds.NegativeMax; - negative = true; - - if (pos == end) { - return PS_MINUS_STRING; - } - } else { - max = bounds.PositiveMax; - } - - TUnsigned result; - EParseStatus error = TBasicIntParser<TUnsigned, base, TChar>::Parse(&pos, end, max, &result); - if (error != PS_OK) { + TUnsigned max; + if (*pos == '+') { + pos++; + max = bounds.PositiveMax; + + if (pos == end) { + return PS_PLUS_STRING; + } + } else if (IsSigned && *pos == '-') { + pos++; + max = bounds.NegativeMax; + negative = true; + + if (pos == end) { + return PS_MINUS_STRING; + } + } else { + max = bounds.PositiveMax; + } + + TUnsigned result; + EParseStatus error = TBasicIntParser<TUnsigned, base, TChar>::Parse(&pos, end, max, &result); + if (error != PS_OK) { *ppos = pos; - return error; - } - - if (IsSigned) { + return error; + } + + if (IsSigned) { *target = negative ? NegatePositiveSigned(result) : static_cast<T>(result); - } else { - *target = result; - } - return PS_OK; + } else { + *target = result; + } + return PS_OK; } - }; + }; - template <class TChar> + template <class TChar> [[noreturn]] static Y_NO_INLINE void ThrowParseError(EParseStatus status, const TChar* data, size_t len, const TChar* pos) { - Y_ASSERT(status != PS_OK); - + Y_ASSERT(status != PS_OK); + typedef TBasicString<TChar> TStringType; - - switch (status) { - case PS_EMPTY_STRING: + + switch (status) { + case PS_EMPTY_STRING: ythrow TFromStringException() << TStringBuf("Cannot parse empty string as number. "); - case PS_PLUS_STRING: + case PS_PLUS_STRING: ythrow TFromStringException() << TStringBuf("Cannot parse string \"+\" as number. "); - case PS_MINUS_STRING: + case PS_MINUS_STRING: ythrow TFromStringException() << TStringBuf("Cannot parse string \"-\" as number. "); - case PS_BAD_SYMBOL: + case PS_BAD_SYMBOL: ythrow TFromStringException() << TStringBuf("Unexpected symbol \"") << EscapeC(*pos) << TStringBuf("\" at pos ") << (pos - data) << TStringBuf(" in string ") << TStringType(data, len).Quote() << TStringBuf(". "); - case PS_OVERFLOW: + case PS_OVERFLOW: ythrow TFromStringException() << TStringBuf("Integer overflow in string ") << TStringType(data, len).Quote() << TStringBuf(". "); - default: + default: ythrow yexception() << TStringBuf("Unknown error code in string converter. "); - } + } } - template <typename T, typename TUnsigned, int base, typename TChar> + template <typename T, typename TUnsigned, int base, typename TChar> Y_NO_INLINE T ParseInt(const TChar* data, size_t len, const TBounds<TUnsigned>& bounds) { - T result; - const TChar* pos = data; - EParseStatus status = TIntParser<T, base, TChar>::Parse(&pos, pos + len, bounds, &result); - - if (status == PS_OK) { - return result; - } else { - ThrowParseError(status, data, len, pos); - } - } - - template <typename T, typename TUnsigned, int base, typename TChar> + T result; + const TChar* pos = data; + EParseStatus status = TIntParser<T, base, TChar>::Parse(&pos, pos + len, bounds, &result); + + if (status == PS_OK) { + return result; + } else { + ThrowParseError(status, data, len, pos); + } + } + + template <typename T, typename TUnsigned, int base, typename TChar> Y_NO_INLINE bool TryParseInt(const TChar* data, size_t len, const TBounds<TUnsigned>& bounds, T* result) { - return TIntParser<T, base, TChar>::Parse(&data, data + len, bounds, result) == PS_OK; - } - - template <class T> + return TIntParser<T, base, TChar>::Parse(&data, data + len, bounds, result) == PS_OK; + } + + template <class T> inline T ParseFlt(const char* data, size_t len) { - /* - * TODO - */ - - if (len > 256) { - len = 256; - } - - char* c = (char*)alloca(len + 1); - memcpy(c, data, len); - c[len] = 0; - - T ret; - char ec; - - // try to read a value and an extra character in order to catch cases when - // the string start with a valid float but is followed by unexpected characters - if (sscanf(c, TFltModifiers<T>::ModifierReadAndChar, &ret, &ec) == 1) { - return ret; - } - + /* + * TODO + */ + + if (len > 256) { + len = 256; + } + + char* c = (char*)alloca(len + 1); + memcpy(c, data, len); + c[len] = 0; + + T ret; + char ec; + + // try to read a value and an extra character in order to catch cases when + // the string start with a valid float but is followed by unexpected characters + if (sscanf(c, TFltModifiers<T>::ModifierReadAndChar, &ret, &ec) == 1) { + return ret; + } + ythrow TFromStringException() << TStringBuf("cannot parse float(") << TStringBuf(data, len) << TStringBuf(")"); - } - + } + #define DEF_FLT_MOD(type, modifierWrite, modifierRead) \ template <> \ struct TFltModifiers<type> { \ @@ -397,14 +397,14 @@ namespace { const char* const TFltModifiers<type>::ModifierWrite = modifierWrite; \ const char* const TFltModifiers<type>::ModifierReadAndChar = modifierRead "%c"; - DEF_FLT_MOD(long double, "%.10Lg", "%Lg") + DEF_FLT_MOD(long double, "%.10Lg", "%Lg") #undef DEF_FLT_MOD - /* The following constants are initialized in terms of <climits> constants to make - * sure they go into binary as actual values and there is no associated - * initialization code. - * */ + /* The following constants are initialized in terms of <climits> constants to make + * sure they go into binary as actual values and there is no associated + * initialization code. + * */ constexpr TBounds<ui64> bSBounds = {static_cast<ui64>(SCHAR_MAX), static_cast<ui64>(UCHAR_MAX - SCHAR_MAX)}; constexpr TBounds<ui64> bUBounds = {static_cast<ui64>(UCHAR_MAX), 0}; constexpr TBounds<ui64> sSBounds = {static_cast<ui64>(SHRT_MAX), static_cast<ui64>(USHRT_MAX - SHRT_MAX)}; @@ -450,8 +450,8 @@ size_t ToStringImpl<char8_t>(char8_t value, char* buf, size_t len) { } #endif -using TCharIType = std::conditional_t<std::is_signed<char>::value, i64, ui64>; -using TWCharIType = std::conditional_t<std::is_signed<wchar_t>::value, i64, ui64>; +using TCharIType = std::conditional_t<std::is_signed<char>::value, i64, ui64>; +using TWCharIType = std::conditional_t<std::is_signed<wchar_t>::value, i64, ui64>; DEF_INT_SPEC_I(char, TCharIType) DEF_INT_SPEC_I(wchar_t, TWCharIType) @@ -472,13 +472,13 @@ DEF_FLT_SPEC(long double) #undef DEF_FLT_SPEC -template <> -size_t ToStringImpl<bool>(bool t, char* buf, size_t len) { +template <> +size_t ToStringImpl<bool>(bool t, char* buf, size_t len) { Y_ENSURE(len, TStringBuf("zero length")); - *buf = t ? '1' : '0'; - return 1; -} - + *buf = t ? '1' : '0'; + return 1; +} + /* * ------------------------------ parsers ------------------------------ */ @@ -543,12 +543,12 @@ TWtringBuf FromStringImpl<TWtringBuf>(const wchar16* data, size_t len) { // Try-versions template <> -bool TryFromStringImpl<TStringBuf>(const char* data, size_t len, TStringBuf& result) { - result = {data, len}; - return true; -} - -template <> +bool TryFromStringImpl<TStringBuf>(const char* data, size_t len, TStringBuf& result) { + result = {data, len}; + return true; +} + +template <> bool TryFromStringImpl<TString>(const char* data, size_t len, TString& result) { result = TString(data, len); return true; @@ -561,12 +561,12 @@ bool TryFromStringImpl<std::string>(const char* data, size_t len, std::string& r } template <> -bool TryFromStringImpl<TWtringBuf>(const wchar16* data, size_t len, TWtringBuf& result) { - result = {data, len}; - return true; -} - -template <> +bool TryFromStringImpl<TWtringBuf>(const wchar16* data, size_t len, TWtringBuf& result) { + result = {data, len}; + return true; +} + +template <> bool TryFromStringImpl<TUtf16String>(const wchar16* data, size_t len, TUtf16String& result) { result = TUtf16String(data, len); return true; @@ -648,7 +648,7 @@ bool TryFromStringImpl<double>(const char* data, size_t len, double& result) { return false; } - char* se = nullptr; + char* se = nullptr; double d = StrToD(data, data + len, &se); if (se != data + len) { diff --git a/util/string/cast_ut.cpp b/util/string/cast_ut.cpp index 033450c38c4..e6fec11e2c8 100644 --- a/util/string/cast_ut.cpp +++ b/util/string/cast_ut.cpp @@ -149,7 +149,7 @@ inline void CheckConvertToBuffer(const T& value, const size_t size, const TStrin } #endif -Y_UNIT_TEST_SUITE(TCastTest) { +Y_UNIT_TEST_SUITE(TCastTest) { template <class A> inline TRet<A> F() { return TRet<A>(); @@ -173,10 +173,10 @@ Y_UNIT_TEST_SUITE(TCastTest) { UNIT_ASSERT_VALUES_EQUAL(res, false); UNIT_ASSERT_DOUBLES_EQUAL(f, 42.0, eps); // check value was not trashed UNIT_ASSERT_EXCEPTION(f = FromString<TFloat>(str), TFromStringException); - Y_UNUSED(f); // shut up compiler about 'assigned value that is not used' + Y_UNUSED(f); // shut up compiler about 'assigned value that is not used' } - Y_UNIT_TEST(TestToFrom) { + Y_UNIT_TEST(TestToFrom) { test1(bool, true); test1(bool, false); test2(bool, ""); @@ -229,18 +229,18 @@ Y_UNIT_TEST_SUITE(TCastTest) { test1(long long int, LLONG_MIN + 1); } - Y_UNIT_TEST(TestVolatile) { + Y_UNIT_TEST(TestVolatile) { volatile int x = 1; UNIT_ASSERT_VALUES_EQUAL(ToString(x), "1"); } - Y_UNIT_TEST(TestStrToD) { - UNIT_ASSERT_DOUBLES_EQUAL(StrToD("1.1", nullptr), 1.1, EPS); - UNIT_ASSERT_DOUBLES_EQUAL(StrToD("1.12345678", nullptr), 1.12345678, EPS); - UNIT_ASSERT_DOUBLES_EQUAL(StrToD("10E-5", nullptr), 10E-5, EPS); - UNIT_ASSERT_DOUBLES_EQUAL(StrToD("1.1E+5", nullptr), 1.1E+5, EPS); + Y_UNIT_TEST(TestStrToD) { + UNIT_ASSERT_DOUBLES_EQUAL(StrToD("1.1", nullptr), 1.1, EPS); + UNIT_ASSERT_DOUBLES_EQUAL(StrToD("1.12345678", nullptr), 1.12345678, EPS); + UNIT_ASSERT_DOUBLES_EQUAL(StrToD("10E-5", nullptr), 10E-5, EPS); + UNIT_ASSERT_DOUBLES_EQUAL(StrToD("1.1E+5", nullptr), 1.1E+5, EPS); - char* ret = nullptr; + char* ret = nullptr; UNIT_ASSERT_DOUBLES_EQUAL(StrToD("1.1y", &ret), 1.1, EPS); UNIT_ASSERT_VALUES_EQUAL(*ret, 'y'); @@ -252,7 +252,7 @@ Y_UNIT_TEST_SUITE(TCastTest) { UNIT_ASSERT_VALUES_EQUAL(*ret, 'z'); } - Y_UNIT_TEST(TestFloats) { + Y_UNIT_TEST(TestFloats) { // "%g" mode UNIT_ASSERT_VALUES_EQUAL(FloatToString(0.1f, PREC_NDIGITS, 6), "0.1"); // drop trailing zeroes UNIT_ASSERT_VALUES_EQUAL(FloatToString(0.12345678f, PREC_NDIGITS, 6), "0.123457"); @@ -289,7 +289,7 @@ Y_UNIT_TEST_SUITE(TCastTest) { UNIT_ASSERT_STRINGS_EQUAL(FloatToString(-std::numeric_limits<float>::infinity()), "-inf"); } - Y_UNIT_TEST(TestReadFloats) { + Y_UNIT_TEST(TestReadFloats) { GoodFloatTester<float>("0.0001", 0.0001f, EPS); GoodFloatTester<double>("0.0001", 0.0001, EPS); GoodFloatTester<long double>("0.0001", 0.0001, EPS); @@ -303,24 +303,24 @@ Y_UNIT_TEST_SUITE(TCastTest) { //BadFloatTester<float>("10E"); //BadFloatTester<float>("10.E"); BadFloatTester<float>("..0"); - BadFloatTester<float>(""); // IGNIETFERRO-300 + BadFloatTester<float>(""); // IGNIETFERRO-300 BadFloatTester<double>("1.00.01"); BadFloatTester<double>("1.0001E5b"); BadFloatTester<double>("1.0001s"); BadFloatTester<double>("1..01"); - BadFloatTester<double>(""); // IGNIETFERRO-300 + BadFloatTester<double>(""); // IGNIETFERRO-300 BadFloatTester<long double>(".1.00"); BadFloatTester<long double>("1.00."); BadFloatTester<long double>("1.0001e5-"); BadFloatTester<long double>("10e 2"); - BadFloatTester<long double>(""); // IGNIETFERRO-300 + BadFloatTester<long double>(""); // IGNIETFERRO-300 } - Y_UNIT_TEST(TestLiteral) { + Y_UNIT_TEST(TestLiteral) { UNIT_ASSERT_VALUES_EQUAL(ToString("abc"), TString("abc")); } - Y_UNIT_TEST(TestFromStringStringBuf) { + Y_UNIT_TEST(TestFromStringStringBuf) { TString a = "xyz"; TStringBuf b = FromString<TStringBuf>(a); UNIT_ASSERT_VALUES_EQUAL(a, b); @@ -328,7 +328,7 @@ Y_UNIT_TEST_SUITE(TCastTest) { } #if 0 - Y_UNIT_TEST(TestBufferOverflow) { + Y_UNIT_TEST(TestBufferOverflow) { CheckConvertToBuffer<float>(1.f, 5, "1"); CheckConvertToBuffer<float>(1.005f, 3, "1.005"); CheckConvertToBuffer<float>(1.00000000f, 3, "1"); @@ -349,7 +349,7 @@ Y_UNIT_TEST_SUITE(TCastTest) { } #endif - Y_UNIT_TEST(TestWide) { + Y_UNIT_TEST(TestWide) { TUtf16String iw = u"-100500"; int iv = 0; UNIT_ASSERT_VALUES_EQUAL(TryFromString(iw, iv), true); @@ -371,7 +371,7 @@ Y_UNIT_TEST_SUITE(TCastTest) { UNIT_ASSERT_VALUES_EQUAL(uv, 21474836470ull); } - Y_UNIT_TEST(TestDefault) { + Y_UNIT_TEST(TestDefault) { size_t res = 0; const size_t def1 = 42; @@ -437,7 +437,7 @@ Y_UNIT_TEST_SUITE(TCastTest) { UNIT_ASSERT_VALUES_EQUAL(FromStringWithDefault<size_t>(s4), size_t()); } - Y_UNIT_TEST(TestBool) { + Y_UNIT_TEST(TestBool) { // True cases UNIT_ASSERT_VALUES_EQUAL(FromString<bool>("yes"), true); UNIT_ASSERT_VALUES_EQUAL(FromString<bool>("1"), true); @@ -449,7 +449,7 @@ Y_UNIT_TEST_SUITE(TCastTest) { UNIT_ASSERT_EXCEPTION(FromString<bool>("something"), yexception); } - Y_UNIT_TEST(TestAutoDetectType) { + Y_UNIT_TEST(TestAutoDetectType) { UNIT_ASSERT_DOUBLES_EQUAL((float)FromString("0.0001"), 0.0001, EPS); UNIT_ASSERT_DOUBLES_EQUAL((double)FromString("0.0015", sizeof("0.0015") - 2), 0.001, EPS); UNIT_ASSERT_DOUBLES_EQUAL((long double)FromString(TStringBuf("0.0001")), 0.0001, EPS); @@ -472,7 +472,7 @@ Y_UNIT_TEST_SUITE(TCastTest) { } } - Y_UNIT_TEST(ErrorMessages) { + Y_UNIT_TEST(ErrorMessages) { try { FromString<ui32>(""); UNIT_ASSERT(false); @@ -509,47 +509,47 @@ Y_UNIT_TEST_SUITE(TCastTest) { CheckMessage(e, "Unexpected symbol \".\" at pos 1 in string \"0.328413745072\""); } } - - Y_UNIT_TEST(TryStringBuf) { - { + + Y_UNIT_TEST(TryStringBuf) { + { constexpr TStringBuf hello = "hello"; - TStringBuf out; - UNIT_ASSERT(TryFromString(hello, out)); + TStringBuf out; + UNIT_ASSERT(TryFromString(hello, out)); UNIT_ASSERT_VALUES_EQUAL(hello, out); - } - { + } + { constexpr TStringBuf empty = ""; - TStringBuf out; - UNIT_ASSERT(TryFromString(empty, out)); + TStringBuf out; + UNIT_ASSERT(TryFromString(empty, out)); UNIT_ASSERT_VALUES_EQUAL(empty, out); - } - { - constexpr TStringBuf empty; - TStringBuf out; - UNIT_ASSERT(TryFromString(empty, out)); + } + { + constexpr TStringBuf empty; + TStringBuf out; + UNIT_ASSERT(TryFromString(empty, out)); UNIT_ASSERT_VALUES_EQUAL(empty, out); - } - { + } + { const auto hello = u"hello"; - TWtringBuf out; - UNIT_ASSERT(TryFromString(hello, out)); + TWtringBuf out; + UNIT_ASSERT(TryFromString(hello, out)); UNIT_ASSERT_VALUES_EQUAL(hello, out); - } - { + } + { const TUtf16String empty; - TWtringBuf out; - UNIT_ASSERT(TryFromString(empty, out)); + TWtringBuf out; + UNIT_ASSERT(TryFromString(empty, out)); UNIT_ASSERT_VALUES_EQUAL(empty, out); - } - { - constexpr TWtringBuf empty; - TWtringBuf out; - UNIT_ASSERT(TryFromString(empty, out)); + } + { + constexpr TWtringBuf empty; + TWtringBuf out; + UNIT_ASSERT(TryFromString(empty, out)); UNIT_ASSERT_VALUES_EQUAL(empty, out); - } - } + } + } - Y_UNIT_TEST(Nan) { + Y_UNIT_TEST(Nan) { double xx = 0; UNIT_ASSERT(!TryFromString("NaN", xx)); @@ -557,7 +557,7 @@ Y_UNIT_TEST_SUITE(TCastTest) { UNIT_ASSERT(!TryFromString("nan", xx)); } - Y_UNIT_TEST(Infinity) { + Y_UNIT_TEST(Infinity) { double xx = 0; UNIT_ASSERT(!TryFromString("Infinity", xx)); @@ -565,7 +565,7 @@ Y_UNIT_TEST_SUITE(TCastTest) { UNIT_ASSERT(!TryFromString("infinity", xx)); } - Y_UNIT_TEST(TestBorderCases) { + Y_UNIT_TEST(TestBorderCases) { UNIT_ASSERT_VALUES_EQUAL(ToString(0.0), "0"); UNIT_ASSERT_VALUES_EQUAL(ToString(1.0), "1"); UNIT_ASSERT_VALUES_EQUAL(ToString(10.0), "10"); diff --git a/util/string/escape.cpp b/util/string/escape.cpp index cd09a7dbd02..0a79bd30d06 100644 --- a/util/string/escape.cpp +++ b/util/string/escape.cpp @@ -43,7 +43,7 @@ namespace { template <typename TChar> static inline char HexDigit(TChar value) { - Y_ASSERT(value < 16); + Y_ASSERT(value < 16); if (value < 10) { return '0' + value; } else { @@ -53,7 +53,7 @@ namespace { template <typename TChar> static inline char OctDigit(TChar value) { - Y_ASSERT(value < 8); + Y_ASSERT(value < 8); return '0' + value; } diff --git a/util/string/escape_ut.cpp b/util/string/escape_ut.cpp index cd38ecffd34..b1bd7f2a94d 100644 --- a/util/string/escape_ut.cpp +++ b/util/string/escape_ut.cpp @@ -7,20 +7,20 @@ using namespace std::string_view_literals; -namespace { - struct TExample { +namespace { + struct TExample { TString Expected; TString Source; - - TExample(const TStringBuf expected, const TStringBuf source) - : Expected{expected} + + TExample(const TStringBuf expected, const TStringBuf source) + : Expected{expected} , Source{source} { - } - }; -} - -static const TExample CommonTestData[] = { + } + }; +} + +static const TExample CommonTestData[] = { // Should be valid UTF-8. {"http://ya.ru/", "http://ya.ru/"}, {"http://ya.ru/\\x17\\n", "http://ya.ru/\x17\n"}, @@ -46,16 +46,16 @@ static const TExample CommonTestData[] = { {"There are questions \\x3F?", "There are questions ??"}, }; -Y_UNIT_TEST_SUITE(TEscapeCTest) { - Y_UNIT_TEST(TestStrokaEscapeC) { - for (const auto& e : CommonTestData) { +Y_UNIT_TEST_SUITE(TEscapeCTest) { + Y_UNIT_TEST(TestStrokaEscapeC) { + for (const auto& e : CommonTestData) { TString expected(e.Expected); TString source(e.Source); TString actual(EscapeC(e.Source)); TString actual2(UnescapeC(e.Expected)); - UNIT_ASSERT_VALUES_EQUAL(e.Expected, actual); - UNIT_ASSERT_VALUES_EQUAL(e.Source, actual2); + UNIT_ASSERT_VALUES_EQUAL(e.Expected, actual); + UNIT_ASSERT_VALUES_EQUAL(e.Source, actual2); } UNIT_ASSERT_VALUES_EQUAL("http://ya.ru/\\x17\\n\\xAB", EscapeC(TString("http://ya.ru/\x17\n\xab"))); @@ -79,8 +79,8 @@ Y_UNIT_TEST_SUITE(TEscapeCTest) { UNIT_ASSERT_VALUES_EQUAL("Странный компроматтест", UnescapeC(TString("\\u0421\\u0442\\u0440\\u0430\\u043d\\u043d\\u044b\\u0439 \\u043a\\u043e\\u043c\\u043f\\u0440\\u043e\\u043c\\u0430\\u0442тест"))); } - Y_UNIT_TEST(TestWtrokaEscapeC) { - for (const auto& e : CommonTestData) { + Y_UNIT_TEST(TestWtrokaEscapeC) { + for (const auto& e : CommonTestData) { TUtf16String expected(UTF8ToWide(e.Expected)); TUtf16String source(UTF8ToWide(e.Source)); TUtf16String actual(EscapeC(source)); @@ -95,7 +95,7 @@ Y_UNIT_TEST_SUITE(TEscapeCTest) { UNIT_ASSERT_VALUES_EQUAL(u"\\xFF", EscapeC(wchar16(255))); } - Y_UNIT_TEST(TestEscapeTrigraphs) { + Y_UNIT_TEST(TestEscapeTrigraphs) { UNIT_ASSERT_VALUES_EQUAL("?", EscapeC(TString("?"))); UNIT_ASSERT_VALUES_EQUAL("\\x3F?", EscapeC(TString("??"))); UNIT_ASSERT_VALUES_EQUAL("\\x3F\\x3F?", EscapeC(TString("???"))); @@ -104,7 +104,7 @@ Y_UNIT_TEST_SUITE(TEscapeCTest) { UNIT_ASSERT_VALUES_EQUAL("\\x3F?x\\x3F\\x3F?z", EscapeC(TString("??x???z"))); } - Y_UNIT_TEST(TestUnescapeCCharLen) { + Y_UNIT_TEST(TestUnescapeCCharLen) { auto test = [](const char* str, size_t len) { UNIT_ASSERT_EQUAL(UnescapeCCharLen(str, str + strlen(str)), len); }; @@ -131,7 +131,7 @@ Y_UNIT_TEST_SUITE(TEscapeCTest) { test("\\4xxx", 2); } - Y_UNIT_TEST(TestUnbounded) { + Y_UNIT_TEST(TestUnbounded) { char buf[100000]; for (const auto& x : CommonTestData) { diff --git a/util/string/fuzzing/escape_c/main.cpp b/util/string/fuzzing/escape_c/main.cpp index 742126416a6..aa733cec76d 100644 --- a/util/string/fuzzing/escape_c/main.cpp +++ b/util/string/fuzzing/escape_c/main.cpp @@ -1,11 +1,11 @@ -#include <util/generic/string.h> -#include <util/string/escape.h> - -extern "C" int LLVMFuzzerTestOneInput(const ui8* const data, const size_t size) { - const TString src(reinterpret_cast<const char*>(data), size); - const auto escaped = EscapeC(src); - const auto dst = UnescapeC(escaped); - - Y_VERIFY(src == dst); - return 0; -} +#include <util/generic/string.h> +#include <util/string/escape.h> + +extern "C" int LLVMFuzzerTestOneInput(const ui8* const data, const size_t size) { + const TString src(reinterpret_cast<const char*>(data), size); + const auto escaped = EscapeC(src); + const auto dst = UnescapeC(escaped); + + Y_VERIFY(src == dst); + return 0; +} diff --git a/util/string/fuzzing/escape_c/ya.make b/util/string/fuzzing/escape_c/ya.make index 61e64ac9de5..0cdee23d316 100644 --- a/util/string/fuzzing/escape_c/ya.make +++ b/util/string/fuzzing/escape_c/ya.make @@ -1,13 +1,13 @@ -OWNER( - yazevnul - g:util -) +OWNER( + yazevnul + g:util +) SUBSCRIBER(g:util-subscribers) - -FUZZ() - -SRCS( - main.cpp -) - -END() + +FUZZ() + +SRCS( + main.cpp +) + +END() diff --git a/util/string/fuzzing/ya.make b/util/string/fuzzing/ya.make index 617e0f2b1d4..e3a87d37403 100644 --- a/util/string/fuzzing/ya.make +++ b/util/string/fuzzing/ya.make @@ -1,11 +1,11 @@ -OWNER( +OWNER( g:util - pg -) + pg +) SUBSCRIBER(g:util-subscribers) - + RECURSE( - collapse - escape_c + collapse + escape_c strtod ) diff --git a/util/string/hex.h b/util/string/hex.h index af3d2d528fa..08f7398129f 100644 --- a/util/string/hex.h +++ b/util/string/hex.h @@ -16,7 +16,7 @@ extern const char* const Char2DigitTable; inline static int Char2Digit(char ch) { char result = Char2DigitTable[(unsigned char)ch]; - Y_ENSURE(result != '\xff', "invalid hex character " << (int)ch); + Y_ENSURE(result != '\xff', "invalid hex character " << (int)ch); return result; } diff --git a/util/string/hex_ut.cpp b/util/string/hex_ut.cpp index 39a83d5e62b..485583ce353 100644 --- a/util/string/hex_ut.cpp +++ b/util/string/hex_ut.cpp @@ -2,16 +2,16 @@ #include <library/cpp/testing/unittest/registar.h> -Y_UNIT_TEST_SUITE(THexCodingTest) { - Y_UNIT_TEST(TestEncode) { +Y_UNIT_TEST_SUITE(THexCodingTest) { + Y_UNIT_TEST(TestEncode) { UNIT_ASSERT_EQUAL(HexEncode("i1634iqwbf,&msdb"), "693136333469717762662C266D736462"); } - Y_UNIT_TEST(TestDecode) { + Y_UNIT_TEST(TestDecode) { UNIT_ASSERT_EQUAL(HexDecode("693136333469717762662C266D736462"), "i1634iqwbf,&msdb"); } - Y_UNIT_TEST(TestDecodeCase) { + Y_UNIT_TEST(TestDecodeCase) { UNIT_ASSERT_EQUAL(HexDecode("12ABCDEF"), HexDecode("12abcdef")); UNIT_ASSERT_EXCEPTION(HexDecode("Hello"), yexception); //< incorrect chars UNIT_ASSERT_EXCEPTION(HexDecode("123"), yexception); //< odd length diff --git a/util/string/join_ut.cpp b/util/string/join_ut.cpp index 3ed2b2459c4..fde333a37df 100644 --- a/util/string/join_ut.cpp +++ b/util/string/join_ut.cpp @@ -3,7 +3,7 @@ #include <library/cpp/testing/unittest/registar.h> #include <util/generic/vector.h> -#include <util/stream/output.h> +#include <util/stream/output.h> struct TCustomData { TVector<int> Ints; @@ -13,8 +13,8 @@ TString ToString(const TCustomData& d) { return JoinSeq("__", d.Ints); } -Y_UNIT_TEST_SUITE(JoinStringTest) { - Y_UNIT_TEST(ScalarItems) { +Y_UNIT_TEST_SUITE(JoinStringTest) { + Y_UNIT_TEST(ScalarItems) { UNIT_ASSERT_EQUAL(Join(',', 10, 11.1, "foobar"), "10,11.1,foobar"); UNIT_ASSERT_EQUAL(Join(", ", 10, 11.1, "foobar"), "10, 11.1, foobar"); UNIT_ASSERT_EQUAL(Join(", ", 10, 11.1, TString("foobar")), "10, 11.1, foobar"); @@ -26,7 +26,7 @@ Y_UNIT_TEST_SUITE(JoinStringTest) { UNIT_ASSERT_EQUAL(Join(" ", "a", "b", "", "c"), "a b c"); } - Y_UNIT_TEST(IntContainerItems) { + Y_UNIT_TEST(IntContainerItems) { int v[] = {1, 2, 3}; TVector<int> vv(v, v + 3); UNIT_ASSERT_EQUAL(JoinSeq(" ", vv), "1 2 3"); @@ -38,7 +38,7 @@ Y_UNIT_TEST_SUITE(JoinStringTest) { UNIT_ASSERT_VALUES_EQUAL(JoinSeq(" ", v), "1 2 3"); } - Y_UNIT_TEST(StrContainerItems) { + Y_UNIT_TEST(StrContainerItems) { // try various overloads and template type arguments static const char* const result = "1 22 333"; static const char* const v[] = {"1", "22", "333"}; @@ -148,13 +148,13 @@ Y_UNIT_TEST_SUITE(JoinStringTest) { UNIT_ASSERT_VALUES_EQUAL(JoinSeq(" ", v), result); } - Y_UNIT_TEST(CustomToString) { - TCustomData d1{{1, 2, 3, 4, 5}}; - TCustomData d2{{0, -1, -2}}; + Y_UNIT_TEST(CustomToString) { + TCustomData d1{{1, 2, 3, 4, 5}}; + TCustomData d2{{0, -1, -2}}; UNIT_ASSERT_EQUAL(Join(" ", d1, d2), "1__2__3__4__5 0__-1__-2"); } - Y_UNIT_TEST(JoinChars) { + Y_UNIT_TEST(JoinChars) { // Note that char delimeter is printed as single char string, // but joined char values are printed as their numeric codes! O_o UNIT_ASSERT_EQUAL(Join('a', 'a', 'a'), "97a97"); diff --git a/util/string/printf.cpp b/util/string/printf.cpp index 5b7c34d4e14..a8a2e71c9de 100644 --- a/util/string/printf.cpp +++ b/util/string/printf.cpp @@ -1,7 +1,7 @@ #include "printf.h" #include <util/stream/printf.h> -#include <util/stream/str.h> +#include <util/stream/str.h> int vsprintf(TString& s, const char* c, va_list params) { TStringOutput so(s.remove()); diff --git a/util/string/printf.h b/util/string/printf.h index 925c6edaff1..742bf1e5844 100644 --- a/util/string/printf.h +++ b/util/string/printf.h @@ -1,10 +1,10 @@ #pragma once #include <util/generic/fwd.h> -#include <util/system/compiler.h> - -#include <cstdarg> +#include <util/system/compiler.h> +#include <cstdarg> + /// formatted print. return printed length: int Y_PRINTF_FORMAT(2, 0) vsprintf(TString& s, const char* c, va_list params); /// formatted print. return printed length: diff --git a/util/string/printf_ut.cpp b/util/string/printf_ut.cpp index 2b2f980b70e..b6d43cb3a2b 100644 --- a/util/string/printf_ut.cpp +++ b/util/string/printf_ut.cpp @@ -2,15 +2,15 @@ #include <library/cpp/testing/unittest/registar.h> -Y_UNIT_TEST_SUITE(TStringPrintf) { - Y_UNIT_TEST(TestSprintf) { +Y_UNIT_TEST_SUITE(TStringPrintf) { + Y_UNIT_TEST(TestSprintf) { TString s; int len = sprintf(s, "Hello %s", "world"); UNIT_ASSERT_EQUAL(s, TString("Hello world")); UNIT_ASSERT_EQUAL(len, 11); } - Y_UNIT_TEST(TestFcat) { + Y_UNIT_TEST(TestFcat) { TString s; int len = sprintf(s, "Hello %s", "world"); UNIT_ASSERT_EQUAL(s, TString("Hello world")); @@ -20,11 +20,11 @@ Y_UNIT_TEST_SUITE(TStringPrintf) { UNIT_ASSERT_EQUAL(len, 7); } - Y_UNIT_TEST(TestSpecial) { + Y_UNIT_TEST(TestSpecial) { UNIT_ASSERT_EQUAL("4294967295", Sprintf("%" PRIu32, (ui32)(-1))); } - Y_UNIT_TEST(TestExplicitPositions) { + Y_UNIT_TEST(TestExplicitPositions) { UNIT_ASSERT_EQUAL("abc xyz abc", Sprintf("%1$s %2$s %1$s", "abc", "xyz")); } } diff --git a/util/string/split.h b/util/string/split.h index bc46d9e64c6..58d8f81c5e1 100644 --- a/util/string/split.h +++ b/util/string/split.h @@ -261,7 +261,7 @@ struct TSetDelimiter: private TFindFirstOf<const Char> { }; namespace NSplitTargetHasPushBack { - Y_HAS_MEMBER(push_back, PushBack); + Y_HAS_MEMBER(push_back, PushBack); } template <class T, class = void> diff --git a/util/string/split_ut.cpp b/util/string/split_ut.cpp index 43e59f2d754..0135d5c3afe 100644 --- a/util/string/split_ut.cpp +++ b/util/string/split_ut.cpp @@ -2,7 +2,7 @@ #include <library/cpp/testing/unittest/registar.h> -#include <util/stream/output.h> +#include <util/stream/output.h> #include <util/charset/wide.h> #include <util/datetime/cputimer.h> #include <util/generic/maybe.h> @@ -119,8 +119,8 @@ void TestLimitingConsumerOnRange(TVector<TString>& good, const char* b, const ch UNIT_ASSERT_EQUAL(TString(limits.Last), TString(last)); } -Y_UNIT_TEST_SUITE(SplitStringTest) { - Y_UNIT_TEST(TestCharSingleDelimiter) { +Y_UNIT_TEST_SUITE(SplitStringTest) { + Y_UNIT_TEST(TestCharSingleDelimiter) { TString data("qw ab qwabcab"); TString canonic[] = {"qw", "ab", "", "qwabcab"}; TVector<TString> good(canonic, canonic + 4); @@ -130,7 +130,7 @@ Y_UNIT_TEST_SUITE(SplitStringTest) { TestDelimiterOnRange<TContainerConsumer>(good, data.data(), data.end(), delim); } - Y_UNIT_TEST(TestWideSingleDelimiter) { + Y_UNIT_TEST(TestWideSingleDelimiter) { TUtf16String data(u"qw ab qwabcab"); TUtf16String canonic[] = {u"qw", u"ab", TUtf16String(), u"qwabcab"}; TVector<TUtf16String> good(canonic, canonic + 4); @@ -140,7 +140,7 @@ Y_UNIT_TEST_SUITE(SplitStringTest) { TestDelimiterOnRange<TContainerConsumer>(good, data.data(), data.end(), delim); } - Y_UNIT_TEST(TestConvertToIntCharSingleDelimiter) { + Y_UNIT_TEST(TestConvertToIntCharSingleDelimiter) { TString data("42 4242 -12345 0"); i32 canonic[] = {42, 4242, -12345, 0}; TVector<i32> good(canonic, canonic + 4); @@ -159,7 +159,7 @@ Y_UNIT_TEST_SUITE(SplitStringTest) { TestConsumerOnRange<TSkipEmptyTokens<TStrokaConsumer>>(good, data.data(), data.end(), " "); } - Y_UNIT_TEST(TestCharKeepDelimiters) { + Y_UNIT_TEST(TestCharKeepDelimiters) { TString data("qw ab qwabcab "); TString canonic[] = {"qw", " ", "ab", " ", "", " ", "qwabcab", " ", ""}; TVector<TString> good(canonic, canonic + 9); @@ -168,7 +168,7 @@ Y_UNIT_TEST_SUITE(SplitStringTest) { TestConsumerOnRange<TKeepDelimiters<TStrokaConsumer>>(good, data.data(), data.end(), " "); } - Y_UNIT_TEST(TestCharLimit) { + Y_UNIT_TEST(TestCharLimit) { TString data("qw ab qwabcab "); TString canonic[] = {"qw", "ab"}; TVector<TString> good(canonic, canonic + 2); @@ -177,7 +177,7 @@ Y_UNIT_TEST_SUITE(SplitStringTest) { TestLimitingConsumerOnRange(good, data.data(), data.end(), " ", 3, " qwabcab "); } - Y_UNIT_TEST(TestCharStringDelimiter) { + Y_UNIT_TEST(TestCharStringDelimiter) { TString data("qw ab qwababcab"); TString canonic[] = {"qw ", " qw", "", "c", ""}; TVector<TString> good(canonic, canonic + 5); @@ -187,7 +187,7 @@ Y_UNIT_TEST_SUITE(SplitStringTest) { TestDelimiterOnRange<TContainerConsumer>(good, data.data(), data.end(), delim); } - Y_UNIT_TEST(TestWideStringDelimiter) { + Y_UNIT_TEST(TestWideStringDelimiter) { TUtf16String data(u"qw ab qwababcab"); TUtf16String canonic[] = {u"qw ", u" qw", TUtf16String(), u"c", TUtf16String()}; TVector<TUtf16String> good(canonic, canonic + 5); @@ -198,7 +198,7 @@ Y_UNIT_TEST_SUITE(SplitStringTest) { TestDelimiterOnRange<TContainerConsumer>(good, data.data(), data.end(), delim); } - Y_UNIT_TEST(TestCharSetDelimiter) { + Y_UNIT_TEST(TestCharSetDelimiter) { TString data("qw ab qwababccab"); TString canonic[] = {"q", " ab q", "abab", "", "ab"}; TVector<TString> good(canonic, canonic + 5); @@ -208,7 +208,7 @@ Y_UNIT_TEST_SUITE(SplitStringTest) { TestDelimiterOnRange<TContainerConsumer>(good, data.data(), data.end(), delim); } - Y_UNIT_TEST(TestWideSetDelimiter) { + Y_UNIT_TEST(TestWideSetDelimiter) { TUtf16String data(u"qw ab qwababccab"); TUtf16String canonic[] = {u"q", u" ab q", u"abab", TUtf16String(), u"ab"}; TVector<TUtf16String> good(canonic, canonic + 5); @@ -218,7 +218,7 @@ Y_UNIT_TEST_SUITE(SplitStringTest) { TestDelimiterOnString<TContainerConsumer>(good, data.data(), delim); } - Y_UNIT_TEST(TestWideSetDelimiterRange) { + Y_UNIT_TEST(TestWideSetDelimiterRange) { TUtf16String data(u"qw ab qwababccab"); TUtf16String canonic[] = {u"q", u" ab q", u"abab", TUtf16String(), u"ab"}; TVector<TUtf16String> good(1); @@ -237,7 +237,7 @@ Y_UNIT_TEST_SUITE(SplitStringTest) { Cmp(good, test); } - Y_UNIT_TEST(TestSplit) { + Y_UNIT_TEST(TestSplit) { TString data("qw ab qwababcba"); TString canonic[] = {"qw ", " qw", "c"}; TVector<TString> good(canonic, canonic + 3); @@ -251,7 +251,7 @@ Y_UNIT_TEST_SUITE(SplitStringTest) { Cmp(good, test1); } - Y_UNIT_TEST(ConvenientSplitTest) { + Y_UNIT_TEST(ConvenientSplitTest) { TString data("abc 22 33.5 xyz"); TString str; int num1 = 0; @@ -264,7 +264,7 @@ Y_UNIT_TEST_SUITE(SplitStringTest) { UNIT_ASSERT_VALUES_EQUAL(strBuf, "xyz"); } - Y_UNIT_TEST(ConvenientSplitTestWithMaybe) { + Y_UNIT_TEST(ConvenientSplitTestWithMaybe) { TString data("abc 42"); TString str; TMaybe<double> num2 = 1; @@ -277,7 +277,7 @@ Y_UNIT_TEST_SUITE(SplitStringTest) { UNIT_ASSERT(!maybe); } - Y_UNIT_TEST(ConvenientSplitTestExceptions) { + Y_UNIT_TEST(ConvenientSplitTestExceptions) { TString data("abc 22 33"); TString s1, s2, s3, s4; @@ -286,7 +286,7 @@ Y_UNIT_TEST_SUITE(SplitStringTest) { UNIT_ASSERT_EXCEPTION(Split(data, ' ', s1, s2, s3, s4), yexception); } - Y_UNIT_TEST(ConvenientSplitTestMaybeExceptions) { + Y_UNIT_TEST(ConvenientSplitTestMaybeExceptions) { TString data("abc 22 33"); TString s1, s2; TMaybe<TString> m1, m2; diff --git a/util/string/strip_ut.cpp b/util/string/strip_ut.cpp index d1029d1498a..663b648a21e 100644 --- a/util/string/strip_ut.cpp +++ b/util/string/strip_ut.cpp @@ -4,8 +4,8 @@ #include <util/charset/wide.h> -Y_UNIT_TEST_SUITE(TStripStringTest) { - Y_UNIT_TEST(TestStrip) { +Y_UNIT_TEST_SUITE(TStripStringTest) { + Y_UNIT_TEST(TestStrip) { struct TTest { const char* Str; const char* StripLeftRes; @@ -26,25 +26,25 @@ Y_UNIT_TEST_SUITE(TStripStringTest) { {"a c", "a c", "a c", "a c"}, }; - for (const auto& test : tests) { + for (const auto& test : tests) { TString inputStr(test.Str); TString s; Strip(inputStr, s); - UNIT_ASSERT_EQUAL(s, test.StripRes); + UNIT_ASSERT_EQUAL(s, test.StripRes); - UNIT_ASSERT_EQUAL(StripString(inputStr), test.StripRes); - UNIT_ASSERT_EQUAL(StripStringLeft(inputStr), test.StripLeftRes); - UNIT_ASSERT_EQUAL(StripStringRight(inputStr), test.StripRightRes); + UNIT_ASSERT_EQUAL(StripString(inputStr), test.StripRes); + UNIT_ASSERT_EQUAL(StripStringLeft(inputStr), test.StripLeftRes); + UNIT_ASSERT_EQUAL(StripStringRight(inputStr), test.StripRightRes); - TStringBuf inputStrBuf(test.Str); - UNIT_ASSERT_EQUAL(StripString(inputStrBuf), test.StripRes); - UNIT_ASSERT_EQUAL(StripStringLeft(inputStrBuf), test.StripLeftRes); - UNIT_ASSERT_EQUAL(StripStringRight(inputStrBuf), test.StripRightRes); + TStringBuf inputStrBuf(test.Str); + UNIT_ASSERT_EQUAL(StripString(inputStrBuf), test.StripRes); + UNIT_ASSERT_EQUAL(StripStringLeft(inputStrBuf), test.StripLeftRes); + UNIT_ASSERT_EQUAL(StripStringRight(inputStrBuf), test.StripRightRes); }; } - Y_UNIT_TEST(TestCustomStrip) { + Y_UNIT_TEST(TestCustomStrip) { struct TTest { const char* Str; const char* Result; @@ -56,14 +56,14 @@ Y_UNIT_TEST_SUITE(TStripStringTest) { {"012//", "012"}, }; - for (auto test : tests) { + for (auto test : tests) { UNIT_ASSERT_EQUAL( StripString(TString(test.Str), EqualsStripAdapter('/')), - test.Result); + test.Result); }; } - Y_UNIT_TEST(TestCustomStripLeftRight) { + Y_UNIT_TEST(TestCustomStripLeftRight) { struct TTest { const char* Str; const char* ResultLeft; @@ -76,30 +76,30 @@ Y_UNIT_TEST_SUITE(TStripStringTest) { {"012//", "012//", "012"}, }; - for (const auto& test : tests) { + for (const auto& test : tests) { UNIT_ASSERT_EQUAL( StripStringLeft(TString(test.Str), EqualsStripAdapter('/')), - test.ResultLeft); + test.ResultLeft); UNIT_ASSERT_EQUAL( StripStringRight(TString(test.Str), EqualsStripAdapter('/')), - test.ResultRight); + test.ResultRight); }; } - Y_UNIT_TEST(TestNullStringStrip) { - TStringBuf nullString(nullptr, nullptr); + Y_UNIT_TEST(TestNullStringStrip) { + TStringBuf nullString(nullptr, nullptr); UNIT_ASSERT_EQUAL( StripString(nullString), TString()); } - Y_UNIT_TEST(TestWtrokaStrip) { + Y_UNIT_TEST(TestWtrokaStrip) { UNIT_ASSERT_EQUAL(StripString(TWtringBuf(u" abc ")), u"abc"); UNIT_ASSERT_EQUAL(StripStringLeft(TWtringBuf(u" abc ")), u"abc "); UNIT_ASSERT_EQUAL(StripStringRight(TWtringBuf(u" abc ")), u" abc"); } - Y_UNIT_TEST(TestWtrokaCustomStrip) { + Y_UNIT_TEST(TestWtrokaCustomStrip) { UNIT_ASSERT_EQUAL( StripString( TWtringBuf(u"/abc/"), @@ -107,7 +107,7 @@ Y_UNIT_TEST_SUITE(TStripStringTest) { u"abc"); } - Y_UNIT_TEST(TestCollapse) { + Y_UNIT_TEST(TestCollapse) { TString s; Collapse(TString(" 123 456 "), s); UNIT_ASSERT(s == " 123 456 "); @@ -124,7 +124,7 @@ Y_UNIT_TEST_SUITE(TStripStringTest) { #endif } - Y_UNIT_TEST(TestCollapseText) { + Y_UNIT_TEST(TestCollapseText) { TString abs1("Very long description string written in unknown language."); TString abs2(abs1); TString abs3(abs1); diff --git a/util/string/subst.cpp b/util/string/subst.cpp index b2df328dc18..8daef0708ba 100644 --- a/util/string/subst.cpp +++ b/util/string/subst.cpp @@ -1,200 +1,200 @@ #include "subst.h" - -#include <util/generic/strbuf.h> -#include <util/generic/string.h> -#include <util/system/compiler.h> - -#include <string> -#include <type_traits> - -// a bit of template magic (to be fast and unreadable) -template <class TStringType, class TTo, bool Main> -static Y_FORCE_INLINE void MoveBlock(typename TStringType::value_type* ptr, size_t& srcPos, size_t& dstPos, const size_t off, const TTo to, const size_t toSize) { - const size_t unchangedSize = off - srcPos; - if (dstPos < srcPos) { - for (size_t i = 0; i < unchangedSize; ++i) { - ptr[dstPos++] = ptr[srcPos++]; - } - } else { - dstPos += unchangedSize; - srcPos += unchangedSize; - } - - if (Main) { - for (size_t i = 0; i < toSize; ++i) { - ptr[dstPos++] = to[i]; - } - } -} - -template <typename T, typename U> -static bool IsIntersect(const T& a, const U& b) noexcept { - if (b.data() < a.data()) { - return IsIntersect(b, a); - } - - return !a.empty() && !b.empty() && - ((a.data() <= b.data() && b.data() < a.data() + a.size()) || - (a.data() < b.data() + b.size() && b.data() + b.size() <= a.data() + a.size())); -} - -/** - * Replaces all occurences of substring @c from in string @c s to string @c to. - * Uses two separate implementations (inplace for shrink and append for grow case) - * See IGNIETFERRO-394 - **/ + +#include <util/generic/strbuf.h> +#include <util/generic/string.h> +#include <util/system/compiler.h> + +#include <string> +#include <type_traits> + +// a bit of template magic (to be fast and unreadable) +template <class TStringType, class TTo, bool Main> +static Y_FORCE_INLINE void MoveBlock(typename TStringType::value_type* ptr, size_t& srcPos, size_t& dstPos, const size_t off, const TTo to, const size_t toSize) { + const size_t unchangedSize = off - srcPos; + if (dstPos < srcPos) { + for (size_t i = 0; i < unchangedSize; ++i) { + ptr[dstPos++] = ptr[srcPos++]; + } + } else { + dstPos += unchangedSize; + srcPos += unchangedSize; + } + + if (Main) { + for (size_t i = 0; i < toSize; ++i) { + ptr[dstPos++] = to[i]; + } + } +} + +template <typename T, typename U> +static bool IsIntersect(const T& a, const U& b) noexcept { + if (b.data() < a.data()) { + return IsIntersect(b, a); + } + + return !a.empty() && !b.empty() && + ((a.data() <= b.data() && b.data() < a.data() + a.size()) || + (a.data() < b.data() + b.size() && b.data() + b.size() <= a.data() + a.size())); +} + +/** + * Replaces all occurences of substring @c from in string @c s to string @c to. + * Uses two separate implementations (inplace for shrink and append for grow case) + * See IGNIETFERRO-394 + **/ template <class TStringType, typename TStringViewType = TBasicStringBuf<typename TStringType::value_type>> -static inline size_t SubstGlobalImpl(TStringType& s, const TStringViewType from, const TStringViewType to, size_t fromPos = 0) { +static inline size_t SubstGlobalImpl(TStringType& s, const TStringViewType from, const TStringViewType to, size_t fromPos = 0) { if (from.empty()) { - return 0; - } - - Y_ASSERT(!IsIntersect(s, from)); - Y_ASSERT(!IsIntersect(s, to)); - - const size_t fromSize = from.size(); - const size_t toSize = to.size(); - size_t replacementsCount = 0; - size_t off = fromPos; - size_t srcPos = 0; - - if (toSize > fromSize) { - // string will grow: append to another string - TStringType result; - for (; (off = TStringViewType(s).find(from, off)) != TStringType::npos; off += fromSize) { - if (!replacementsCount) { - // first replacement occured, we can prepare result string - result.reserve(s.size() + s.size() / 3); - } - result.append(s.begin() + srcPos, s.begin() + off); + return 0; + } + + Y_ASSERT(!IsIntersect(s, from)); + Y_ASSERT(!IsIntersect(s, to)); + + const size_t fromSize = from.size(); + const size_t toSize = to.size(); + size_t replacementsCount = 0; + size_t off = fromPos; + size_t srcPos = 0; + + if (toSize > fromSize) { + // string will grow: append to another string + TStringType result; + for (; (off = TStringViewType(s).find(from, off)) != TStringType::npos; off += fromSize) { + if (!replacementsCount) { + // first replacement occured, we can prepare result string + result.reserve(s.size() + s.size() / 3); + } + result.append(s.begin() + srcPos, s.begin() + off); result.append(to.data(), to.size()); - srcPos = off + fromSize; - ++replacementsCount; - } - if (replacementsCount) { - // append tail - result.append(s.begin() + srcPos, s.end()); - s = std::move(result); - } - return replacementsCount; - } - - // string will not grow: use inplace algo - size_t dstPos = 0; + srcPos = off + fromSize; + ++replacementsCount; + } + if (replacementsCount) { + // append tail + result.append(s.begin() + srcPos, s.end()); + s = std::move(result); + } + return replacementsCount; + } + + // string will not grow: use inplace algo + size_t dstPos = 0; typename TStringType::value_type* ptr = &*s.begin(); - for (; (off = TStringViewType(s).find(from, off)) != TStringType::npos; off += fromSize) { - Y_ASSERT(dstPos <= srcPos); - MoveBlock<TStringType, TStringViewType, true>(ptr, srcPos, dstPos, off, to, toSize); - srcPos = off + fromSize; - ++replacementsCount; - } - - if (replacementsCount) { - // append tail - MoveBlock<TStringType, TStringViewType, false>(ptr, srcPos, dstPos, s.size(), to, toSize); - s.resize(dstPos); - } - return replacementsCount; -} - -/// Replaces all occurences of the 'from' symbol in a string to the 'to' symbol. -template <class TStringType> -inline size_t SubstCharGlobalImpl(TStringType& s, typename TStringType::value_type from, typename TStringType::value_type to, size_t fromPos = 0) { - if (fromPos >= s.size()) { - return 0; - } - - size_t result = 0; - fromPos = s.find(from, fromPos); - - // s.begin() might cause memory copying, so call it only if needed - if (fromPos != TStringType::npos) { + for (; (off = TStringViewType(s).find(from, off)) != TStringType::npos; off += fromSize) { + Y_ASSERT(dstPos <= srcPos); + MoveBlock<TStringType, TStringViewType, true>(ptr, srcPos, dstPos, off, to, toSize); + srcPos = off + fromSize; + ++replacementsCount; + } + + if (replacementsCount) { + // append tail + MoveBlock<TStringType, TStringViewType, false>(ptr, srcPos, dstPos, s.size(), to, toSize); + s.resize(dstPos); + } + return replacementsCount; +} + +/// Replaces all occurences of the 'from' symbol in a string to the 'to' symbol. +template <class TStringType> +inline size_t SubstCharGlobalImpl(TStringType& s, typename TStringType::value_type from, typename TStringType::value_type to, size_t fromPos = 0) { + if (fromPos >= s.size()) { + return 0; + } + + size_t result = 0; + fromPos = s.find(from, fromPos); + + // s.begin() might cause memory copying, so call it only if needed + if (fromPos != TStringType::npos) { auto* it = &*s.begin() + fromPos; - *it = to; - ++result; - // at this point string is copied and it's safe to use constant s.end() to iterate + *it = to; + ++result; + // at this point string is copied and it's safe to use constant s.end() to iterate const auto* const sEnd = &*s.end(); - // unrolled loop goes first because it is more likely that `it` will be properly aligned - for (const auto* const end = sEnd - (sEnd - it) % 4; it < end;) { - if (*it == from) { - *it = to; - ++result; - } - ++it; - if (*it == from) { - *it = to; - ++result; - } - ++it; - if (*it == from) { - *it = to; - ++result; - } - ++it; - if (*it == from) { - *it = to; - ++result; - } - ++it; - } - for (; it < sEnd; ++it) { - if (*it == from) { - *it = to; - ++result; - } - } - } - - return result; -} - -/* Standard says that `char16_t` is a distinct type and has same size, signedness and alignment as - * `std::uint_least16_t`, so we check if `char16_t` has same signedness and size as `wchar16` to be - * sure that we can make safe casts between values of these types and pointers. - */ -static_assert(sizeof(wchar16) == sizeof(char16_t), ""); + // unrolled loop goes first because it is more likely that `it` will be properly aligned + for (const auto* const end = sEnd - (sEnd - it) % 4; it < end;) { + if (*it == from) { + *it = to; + ++result; + } + ++it; + if (*it == from) { + *it = to; + ++result; + } + ++it; + if (*it == from) { + *it = to; + ++result; + } + ++it; + if (*it == from) { + *it = to; + ++result; + } + ++it; + } + for (; it < sEnd; ++it) { + if (*it == from) { + *it = to; + ++result; + } + } + } + + return result; +} + +/* Standard says that `char16_t` is a distinct type and has same size, signedness and alignment as + * `std::uint_least16_t`, so we check if `char16_t` has same signedness and size as `wchar16` to be + * sure that we can make safe casts between values of these types and pointers. + */ +static_assert(sizeof(wchar16) == sizeof(char16_t), ""); static_assert(sizeof(wchar32) == sizeof(char32_t), ""); -static_assert(std::is_unsigned<wchar16>::value == std::is_unsigned<char16_t>::value, ""); +static_assert(std::is_unsigned<wchar16>::value == std::is_unsigned<char16_t>::value, ""); static_assert(std::is_unsigned<wchar32>::value == std::is_unsigned<char32_t>::value, ""); - -size_t SubstGlobal(TString& text, const TStringBuf what, const TStringBuf with, size_t from) { - return SubstGlobalImpl(text, what, with, from); -} - -size_t SubstGlobal(std::string& text, const TStringBuf what, const TStringBuf with, size_t from) { - return SubstGlobalImpl(text, what, with, from); -} - -size_t SubstGlobal(TUtf16String& text, const TWtringBuf what, const TWtringBuf with, size_t from) { - return SubstGlobalImpl(text, what, with, from); -} - + +size_t SubstGlobal(TString& text, const TStringBuf what, const TStringBuf with, size_t from) { + return SubstGlobalImpl(text, what, with, from); +} + +size_t SubstGlobal(std::string& text, const TStringBuf what, const TStringBuf with, size_t from) { + return SubstGlobalImpl(text, what, with, from); +} + +size_t SubstGlobal(TUtf16String& text, const TWtringBuf what, const TWtringBuf with, size_t from) { + return SubstGlobalImpl(text, what, with, from); +} + size_t SubstGlobal(TUtf32String& text, const TUtf32StringBuf what, const TUtf32StringBuf with, size_t from) { return SubstGlobalImpl(text, what, with, from); } -size_t SubstGlobal(std::u16string& text, const TWtringBuf what, const TWtringBuf with, size_t from) { +size_t SubstGlobal(std::u16string& text, const TWtringBuf what, const TWtringBuf with, size_t from) { return SubstGlobalImpl(text, std::u16string_view(reinterpret_cast<const char16_t*>(what.data()), what.size()), std::u16string_view(reinterpret_cast<const char16_t*>(with.data()), with.size()), from); -} - -size_t SubstGlobal(TString& text, char what, char with, size_t from) { - return SubstCharGlobalImpl(text, what, with, from); -} - -size_t SubstGlobal(std::string& text, char what, char with, size_t from) { - return SubstCharGlobalImpl(text, what, with, from); -} - -size_t SubstGlobal(TUtf16String& text, wchar16 what, wchar16 with, size_t from) { - return SubstCharGlobalImpl(text, (char16_t)what, (char16_t)with, from); -} - -size_t SubstGlobal(std::u16string& text, wchar16 what, wchar16 with, size_t from) { - return SubstCharGlobalImpl(text, (char16_t)what, (char16_t)with, from); -} +} + +size_t SubstGlobal(TString& text, char what, char with, size_t from) { + return SubstCharGlobalImpl(text, what, with, from); +} + +size_t SubstGlobal(std::string& text, char what, char with, size_t from) { + return SubstCharGlobalImpl(text, what, with, from); +} + +size_t SubstGlobal(TUtf16String& text, wchar16 what, wchar16 with, size_t from) { + return SubstCharGlobalImpl(text, (char16_t)what, (char16_t)with, from); +} + +size_t SubstGlobal(std::u16string& text, wchar16 what, wchar16 with, size_t from) { + return SubstCharGlobalImpl(text, (char16_t)what, (char16_t)with, from); +} size_t SubstGlobal(TUtf32String& text, wchar32 what, wchar32 with, size_t from) { return SubstCharGlobalImpl(text, (char32_t)what, (char32_t)with, from); diff --git a/util/string/subst.h b/util/string/subst.h index 45b622fbefd..32a27898010 100644 --- a/util/string/subst.h +++ b/util/string/subst.h @@ -1,44 +1,44 @@ #pragma once -#include <util/generic/fwd.h> +#include <util/generic/fwd.h> -#include <stlfwd> +#include <stlfwd> -/* Replace all occurences of substring `what` with string `with` starting from position `from`. - * - * @param text String to modify. - * @param what Substring to replace. - * @param with Substring to use as replacement. - * @param from Position at with to start replacement. - * - * @return Number of replacements occured. - */ -size_t SubstGlobal(TString& text, TStringBuf what, TStringBuf with, size_t from = 0); -size_t SubstGlobal(std::string& text, TStringBuf what, TStringBuf with, size_t from = 0); -size_t SubstGlobal(TUtf16String& text, TWtringBuf what, TWtringBuf with, size_t from = 0); -size_t SubstGlobal(std::u16string& text, TWtringBuf what, TWtringBuf with, size_t from = 0); +/* Replace all occurences of substring `what` with string `with` starting from position `from`. + * + * @param text String to modify. + * @param what Substring to replace. + * @param with Substring to use as replacement. + * @param from Position at with to start replacement. + * + * @return Number of replacements occured. + */ +size_t SubstGlobal(TString& text, TStringBuf what, TStringBuf with, size_t from = 0); +size_t SubstGlobal(std::string& text, TStringBuf what, TStringBuf with, size_t from = 0); +size_t SubstGlobal(TUtf16String& text, TWtringBuf what, TWtringBuf with, size_t from = 0); +size_t SubstGlobal(std::u16string& text, TWtringBuf what, TWtringBuf with, size_t from = 0); size_t SubstGlobal(TUtf32String& text, TUtf32StringBuf what, TUtf32StringBuf with, size_t from = 0); -/* Replace all occurences of character `what` with character `with` starting from position `from`. - * - * @param text String to modify. - * @param what Character to replace. - * @param with Character to use as replacement. - * @param from Position at with to start replacement. - * - * @return Number of replacements occured. - */ -size_t SubstGlobal(TString& text, char what, char with, size_t from = 0); -size_t SubstGlobal(std::string& text, char what, char with, size_t from = 0); -size_t SubstGlobal(TUtf16String& text, wchar16 what, wchar16 with, size_t from = 0); -size_t SubstGlobal(std::u16string& text, wchar16 what, wchar16 with, size_t from = 0); +/* Replace all occurences of character `what` with character `with` starting from position `from`. + * + * @param text String to modify. + * @param what Character to replace. + * @param with Character to use as replacement. + * @param from Position at with to start replacement. + * + * @return Number of replacements occured. + */ +size_t SubstGlobal(TString& text, char what, char with, size_t from = 0); +size_t SubstGlobal(std::string& text, char what, char with, size_t from = 0); +size_t SubstGlobal(TUtf16String& text, wchar16 what, wchar16 with, size_t from = 0); +size_t SubstGlobal(std::u16string& text, wchar16 what, wchar16 with, size_t from = 0); size_t SubstGlobal(TUtf32String& text, wchar32 what, wchar32 with, size_t from = 0); -// TODO(yazevnul): -// - rename `SubstGlobal` to `ReplaceAll` for convenience +// TODO(yazevnul): +// - rename `SubstGlobal` to `ReplaceAll` for convenience // - add `SubstGlobalCopy(TStringBuf)` for convenience -// - add `RemoveAll(text, what, from)` as a shortcut for `SubstGlobal(text, what, "", from)` -// - rename file to `replace.h` +// - add `RemoveAll(text, what, from)` as a shortcut for `SubstGlobal(text, what, "", from)` +// - rename file to `replace.h` /* Replace all occurences of substring or character `what` with string or character `with` starting from position `from`, and return result string. * diff --git a/util/string/subst_ut.cpp b/util/string/subst_ut.cpp index 21eccef7795..fc88469ceb9 100644 --- a/util/string/subst_ut.cpp +++ b/util/string/subst_ut.cpp @@ -4,7 +4,7 @@ #include <library/cpp/testing/unittest/registar.h> -Y_UNIT_TEST_SUITE(TStringSubst) { +Y_UNIT_TEST_SUITE(TStringSubst) { static const size_t MIN_FROM_CTX = 4; static const TVector<TString> ALL_FROM{TString("F"), TString("FF")}; static const TVector<TString> ALL_TO{TString(""), TString("T"), TString("TT"), TString("TTT")}; @@ -24,7 +24,7 @@ Y_UNIT_TEST_SUITE(TStringSubst) { } } - Y_UNIT_TEST(TestSubstGlobalNoSubstA) { + Y_UNIT_TEST(TestSubstGlobalNoSubstA) { for (const auto& from : ALL_FROM) { const size_t fromSz = from.size(); const size_t minSz = fromSz; @@ -40,7 +40,7 @@ Y_UNIT_TEST_SUITE(TStringSubst) { } } - Y_UNIT_TEST(TestSubstGlobalNoSubstB) { + Y_UNIT_TEST(TestSubstGlobalNoSubstB) { for (const auto& from : ALL_FROM) { const size_t fromSz = from.size(); const size_t minSz = fromSz; @@ -103,23 +103,23 @@ Y_UNIT_TEST_SUITE(TStringSubst) { } } - Y_UNIT_TEST(TestSubstGlobalSubst1) { + Y_UNIT_TEST(TestSubstGlobalSubst1) { DoTestSubstGlobal(1); } - Y_UNIT_TEST(TestSubstGlobalSubst2) { + Y_UNIT_TEST(TestSubstGlobalSubst2) { DoTestSubstGlobal(2); } - Y_UNIT_TEST(TestSubstGlobalSubst3) { + Y_UNIT_TEST(TestSubstGlobalSubst3) { DoTestSubstGlobal(3); } - Y_UNIT_TEST(TestSubstGlobalSubst4) { + Y_UNIT_TEST(TestSubstGlobalSubst4) { DoTestSubstGlobal(4); } - Y_UNIT_TEST(TestSubstGlobalOld) { + Y_UNIT_TEST(TestSubstGlobalOld) { TString s; s = "aaa"; SubstGlobal(s, "a", "bb"); @@ -160,7 +160,7 @@ Y_UNIT_TEST_SUITE(TStringSubst) { UNIT_ASSERT_EQUAL(s10, TString("Москва Париж")); } - Y_UNIT_TEST(TestSubstCharGlobal) { + Y_UNIT_TEST(TestSubstCharGlobal) { TUtf16String w = u"abcdabcd"; SubstGlobal(w, wchar16('b'), wchar16('B'), 3); UNIT_ASSERT_EQUAL(w, u"abcdaBcd"); @@ -180,74 +180,74 @@ Y_UNIT_TEST_SUITE(TStringSubst) { UNIT_ASSERT_EQUAL(s2, TString("abb")); } - Y_UNIT_TEST(TestSubstStdString) { + Y_UNIT_TEST(TestSubstStdString) { std::string s = "aaa"; SubstGlobal(s, "a", "b", 1); UNIT_ASSERT_EQUAL(s, "abb"); } - + Y_UNIT_TEST(TestSubstStdStringRet) { const std::string s1 = "aaa"; const std::string s2 = SubstGlobalCopy(s1, "a", "b", 1); UNIT_ASSERT_EQUAL(s2, "abb"); } - Y_UNIT_TEST(TestSubstGlobalChar) { - { + Y_UNIT_TEST(TestSubstGlobalChar) { + { const TString s = "a"; const TString st = "b"; TString ss = s; - UNIT_ASSERT_VALUES_EQUAL(s.size(), SubstGlobal(ss, 'a', 'b')); - UNIT_ASSERT_VALUES_EQUAL(st, ss); - } - { + UNIT_ASSERT_VALUES_EQUAL(s.size(), SubstGlobal(ss, 'a', 'b')); + UNIT_ASSERT_VALUES_EQUAL(st, ss); + } + { const TString s = "aa"; const TString st = "bb"; TString ss = s; - UNIT_ASSERT_VALUES_EQUAL(s.size(), SubstGlobal(ss, 'a', 'b')); - UNIT_ASSERT_VALUES_EQUAL(st, ss); - } - { + UNIT_ASSERT_VALUES_EQUAL(s.size(), SubstGlobal(ss, 'a', 'b')); + UNIT_ASSERT_VALUES_EQUAL(st, ss); + } + { const TString s = "aaa"; const TString st = "bbb"; TString ss = s; - UNIT_ASSERT_VALUES_EQUAL(s.size(), SubstGlobal(ss, 'a', 'b')); - UNIT_ASSERT_VALUES_EQUAL(st, ss); - } - { + UNIT_ASSERT_VALUES_EQUAL(s.size(), SubstGlobal(ss, 'a', 'b')); + UNIT_ASSERT_VALUES_EQUAL(st, ss); + } + { const TString s = "aaaa"; const TString st = "bbbb"; TString ss = s; - UNIT_ASSERT_VALUES_EQUAL(s.size(), SubstGlobal(ss, 'a', 'b')); - UNIT_ASSERT_VALUES_EQUAL(st, ss); - } - { + UNIT_ASSERT_VALUES_EQUAL(s.size(), SubstGlobal(ss, 'a', 'b')); + UNIT_ASSERT_VALUES_EQUAL(st, ss); + } + { const TString s = "aaaaa"; const TString st = "bbbbb"; TString ss = s; - UNIT_ASSERT_VALUES_EQUAL(s.size(), SubstGlobal(ss, 'a', 'b')); - UNIT_ASSERT_VALUES_EQUAL(st, ss); - } - { + UNIT_ASSERT_VALUES_EQUAL(s.size(), SubstGlobal(ss, 'a', 'b')); + UNIT_ASSERT_VALUES_EQUAL(st, ss); + } + { const TString s = "aaaaaa"; const TString st = "bbbbbb"; TString ss = s; - UNIT_ASSERT_VALUES_EQUAL(s.size(), SubstGlobal(ss, 'a', 'b')); - UNIT_ASSERT_VALUES_EQUAL(st, ss); - } - { + UNIT_ASSERT_VALUES_EQUAL(s.size(), SubstGlobal(ss, 'a', 'b')); + UNIT_ASSERT_VALUES_EQUAL(st, ss); + } + { const TString s = "aaaaaaa"; const TString st = "bbbbbbb"; TString ss = s; - UNIT_ASSERT_VALUES_EQUAL(s.size(), SubstGlobal(ss, 'a', 'b')); - UNIT_ASSERT_VALUES_EQUAL(st, ss); - } - { + UNIT_ASSERT_VALUES_EQUAL(s.size(), SubstGlobal(ss, 'a', 'b')); + UNIT_ASSERT_VALUES_EQUAL(st, ss); + } + { const TString s = "aaaaaaaa"; const TString st = "bbbbbbbb"; TString ss = s; - UNIT_ASSERT_VALUES_EQUAL(s.size(), SubstGlobal(ss, 'a', 'b')); - UNIT_ASSERT_VALUES_EQUAL(st, ss); - } - } + UNIT_ASSERT_VALUES_EQUAL(s.size(), SubstGlobal(ss, 'a', 'b')); + UNIT_ASSERT_VALUES_EQUAL(st, ss); + } + } } diff --git a/util/string/type.cpp b/util/string/type.cpp index 49671c02c2c..668b445afa2 100644 --- a/util/string/type.cpp +++ b/util/string/type.cpp @@ -24,11 +24,11 @@ static bool IsNumberT(const TStringType& s) noexcept { return std::all_of(s.begin(), s.end(), IsAsciiDigit<typename TStringType::value_type>); } -bool IsNumber(const TStringBuf s) noexcept { +bool IsNumber(const TStringBuf s) noexcept { return IsNumberT(s); } -bool IsNumber(const TWtringBuf s) noexcept { +bool IsNumber(const TWtringBuf s) noexcept { return IsNumberT(s); } @@ -41,11 +41,11 @@ static bool IsHexNumberT(const TStringType& s) noexcept { return std::all_of(s.begin(), s.end(), IsAsciiHex<typename TStringType::value_type>); } -bool IsHexNumber(const TStringBuf s) noexcept { +bool IsHexNumber(const TStringBuf s) noexcept { return IsHexNumberT(s); } -bool IsHexNumber(const TWtringBuf s) noexcept { +bool IsHexNumber(const TWtringBuf s) noexcept { return IsHexNumberT(s); } diff --git a/util/string/type_ut.cpp b/util/string/type_ut.cpp index 03e7af62bd0..7f342a8e249 100644 --- a/util/string/type_ut.cpp +++ b/util/string/type_ut.cpp @@ -4,15 +4,15 @@ #include <util/charset/wide.h> -Y_UNIT_TEST_SUITE(TStringClassify) { - Y_UNIT_TEST(TestIsSpace) { +Y_UNIT_TEST_SUITE(TStringClassify) { + Y_UNIT_TEST(TestIsSpace) { UNIT_ASSERT_EQUAL(IsSpace(" "), true); UNIT_ASSERT_EQUAL(IsSpace("\t\r\n"), true); UNIT_ASSERT_EQUAL(IsSpace(""), false); UNIT_ASSERT_EQUAL(IsSpace(" a"), false); } - Y_UNIT_TEST(TestIsTrue) { + Y_UNIT_TEST(TestIsTrue) { UNIT_ASSERT(IsTrue("1")); UNIT_ASSERT(IsTrue("yes")); UNIT_ASSERT(IsTrue("YeS")); @@ -26,7 +26,7 @@ Y_UNIT_TEST_SUITE(TStringClassify) { UNIT_ASSERT(!IsTrue("foobar")); } - Y_UNIT_TEST(TestIsFalse) { + Y_UNIT_TEST(TestIsFalse) { UNIT_ASSERT(IsFalse("0")); UNIT_ASSERT(IsFalse("no")); UNIT_ASSERT(IsFalse("off")); @@ -39,7 +39,7 @@ Y_UNIT_TEST_SUITE(TStringClassify) { UNIT_ASSERT(!IsFalse("foobar")); } - Y_UNIT_TEST(TestIsNumber) { + Y_UNIT_TEST(TestIsNumber) { UNIT_ASSERT(IsNumber("0")); UNIT_ASSERT(IsNumber("12345678901234567890")); UNIT_ASSERT(!IsNumber("1234567890a")); @@ -54,7 +54,7 @@ Y_UNIT_TEST_SUITE(TStringClassify) { UNIT_ASSERT(!IsNumber(u"foobar")); } - Y_UNIT_TEST(TestIsHexNumber) { + Y_UNIT_TEST(TestIsHexNumber) { UNIT_ASSERT(IsHexNumber("0")); UNIT_ASSERT(IsHexNumber("aaaadddAAAAA")); UNIT_ASSERT(IsHexNumber("0123456789ABCDEFabcdef")); diff --git a/util/string/util.h b/util/string/util.h index 0d77a5042b8..4c9732fcaf8 100644 --- a/util/string/util.h +++ b/util/string/util.h @@ -132,7 +132,7 @@ public: /// strsep + remember character that was destroyed char* sep(char*& s, char& sep_char) const { if (!s) - return nullptr; + return nullptr; char* ret = s; char* next = brk(ret); if (*next) { @@ -141,7 +141,7 @@ public: s = next + 1; } else { sep_char = 0; - s = nullptr; + s = nullptr; } return ret; } diff --git a/util/string/util_ut.cpp b/util/string/util_ut.cpp index 18a2d8e1957..706b63cfdc9 100644 --- a/util/string/util_ut.cpp +++ b/util/string/util_ut.cpp @@ -20,7 +20,7 @@ public: UNIT_ASSERT_EQUAL(strcmp(rul.sep(s1), ""), 0); UNIT_ASSERT_EQUAL(strcmp(rul.sep(s1), "%^&"), 0); UNIT_ASSERT_EQUAL(strcmp(rul.sep(s1), "+-"), 0); - UNIT_ASSERT_EQUAL(rul.sep(s1), nullptr); + UNIT_ASSERT_EQUAL(rul.sep(s1), nullptr); } void TestRemoveAll() { @@ -35,7 +35,7 @@ public: {"hello world", 'x', "hello world"}, }; - for (const T* t = tests; t != std::end(tests); ++t) { + for (const T* t = tests; t != std::end(tests); ++t) { TString str(t->Str); RemoveAll(str, t->Ch); UNIT_ASSERT_EQUAL(t->Result, str); diff --git a/util/string/vector.h b/util/string/vector.h index e36c348bbef..fce7e4ab00e 100644 --- a/util/string/vector.h +++ b/util/string/vector.h @@ -1,14 +1,14 @@ #pragma once -#include "cast.h" +#include "cast.h" #include "split.h" - + #include <util/generic/map.h> -#include <util/generic/strbuf.h> +#include <util/generic/strbuf.h> #include <util/generic/string.h> #include <util/generic/vector.h> #include <util/string/cast.h> -#include <util/system/yassert.h> +#include <util/system/yassert.h> #define KEEP_EMPTY_TOKENS 0x01 @@ -120,8 +120,8 @@ inline TString JoinVectorIntoString(const TVector<T>& v, size_t index, size_t co TUtf16String JoinStrings(const TVector<TUtf16String>& v, const TWtringBuf delim); TUtf16String JoinStrings(const TVector<TUtf16String>& v, size_t index, size_t count, const TWtringBuf delim); -//! Converts vector of strings to vector of type T variables -template <typename T, typename TStringType> +//! Converts vector of strings to vector of type T variables +template <typename T, typename TStringType> TVector<T> Scan(const TVector<TStringType>& input) { TVector<T> output; output.reserve(input.size()); diff --git a/util/string/vector_ut.cpp b/util/string/vector_ut.cpp index 817120f2683..9c4222f9ee2 100644 --- a/util/string/vector_ut.cpp +++ b/util/string/vector_ut.cpp @@ -4,14 +4,14 @@ #include "cast.h" #include "vector.h" -Y_UNIT_TEST_SUITE(TStringJoinTest) { - Y_UNIT_TEST(Test1) { +Y_UNIT_TEST_SUITE(TStringJoinTest) { + Y_UNIT_TEST(Test1) { TVector<TUtf16String> v; UNIT_ASSERT_EQUAL(JoinStrings(v, ToWtring("")), ToWtring("")); } - Y_UNIT_TEST(Test2) { + Y_UNIT_TEST(Test2) { TVector<TUtf16String> v; v.push_back(ToWtring("1")); @@ -20,7 +20,7 @@ Y_UNIT_TEST_SUITE(TStringJoinTest) { UNIT_ASSERT_EQUAL(JoinStrings(v, ToWtring(" ")), ToWtring("1 2")); } - Y_UNIT_TEST(Test3) { + Y_UNIT_TEST(Test3) { TVector<TUtf16String> v; v.push_back(ToWtring("1")); @@ -29,7 +29,7 @@ Y_UNIT_TEST_SUITE(TStringJoinTest) { UNIT_ASSERT_EQUAL(JoinStrings(v, 1, 10, ToWtring(" ")), ToWtring("2")); } - Y_UNIT_TEST(TestJoinWStrings) { + Y_UNIT_TEST(TestJoinWStrings) { const TUtf16String str = u"Яндекс"; const TVector<TUtf16String> v(1, str); diff --git a/util/system/atexit.cpp b/util/system/atexit.cpp index 74fb10b6b1d..2ff9284f765 100644 --- a/util/system/atexit.cpp +++ b/util/system/atexit.cpp @@ -42,7 +42,7 @@ namespace { while (Items_) { auto c = Items_.top(); - Y_ASSERT(c); + Y_ASSERT(c); Items_.pop(); diff --git a/util/system/atomic_ops.h b/util/system/atomic_ops.h index 76766b4a0aa..ec2e0959e20 100644 --- a/util/system/atomic_ops.h +++ b/util/system/atomic_ops.h @@ -22,7 +22,7 @@ struct TAtomicTraits { }; template <typename T, typename TT> -using TEnableIfCastable = std::enable_if_t<TAtomicTraits<T>::Castable, TT>; +using TEnableIfCastable = std::enable_if_t<TAtomicTraits<T>::Castable, TT>; template <typename T> inline TEnableIfCastable<T, T> AtomicGet(T const volatile& target) { diff --git a/util/system/backtrace.cpp b/util/system/backtrace.cpp index b77fe58fb11..b7499578869 100644 --- a/util/system/backtrace.cpp +++ b/util/system/backtrace.cpp @@ -3,7 +3,7 @@ #include "platform.h" #include "backtrace.h" -#include <util/stream/output.h> +#include <util/stream/output.h> #include <util/stream/format.h> #include <util/generic/array_ref.h> #include <util/generic/string.h> @@ -233,13 +233,13 @@ TResolvedSymbol ResolveSymbol(void* sym, char*, size_t) { } #endif -void FormatBackTrace(IOutputStream* out, void* const* backtrace, size_t backtraceSize) { +void FormatBackTrace(IOutputStream* out, void* const* backtrace, size_t backtraceSize) { char tmpBuf[1024]; for (size_t i = 0; i < backtraceSize; ++i) { TResolvedSymbol rs = ResolveSymbol(backtrace[i], tmpBuf, sizeof(tmpBuf)); - *out << rs.Name << "+" << ((ptrdiff_t)backtrace[i] - (ptrdiff_t)rs.NearestSymbol) << " (" << Hex((ptrdiff_t)backtrace[i], HF_ADDX) << ')' << '\n'; + *out << rs.Name << "+" << ((ptrdiff_t)backtrace[i] - (ptrdiff_t)rs.NearestSymbol) << " (" << Hex((ptrdiff_t)backtrace[i], HF_ADDX) << ')' << '\n'; } } @@ -274,7 +274,7 @@ void TBackTrace::Capture() { Size = BackTrace(Data, CAPACITY); } -void TBackTrace::PrintTo(IOutputStream& out) const { +void TBackTrace::PrintTo(IOutputStream& out) const { FormatBackTraceFn(&out, Data, Size); } diff --git a/util/system/backtrace.h b/util/system/backtrace.h index 2fce7585c3a..d19502953d2 100644 --- a/util/system/backtrace.h +++ b/util/system/backtrace.h @@ -3,7 +3,7 @@ #include <util/generic/fwd.h> #include <util/system/defaults.h> -class IOutputStream; +class IOutputStream; size_t BackTrace(void** p, size_t len); @@ -14,8 +14,8 @@ struct TResolvedSymbol { TResolvedSymbol ResolveSymbol(void* sym, char* buf, size_t len); -void FormatBackTrace(IOutputStream* out, void* const* backtrace, size_t backtraceSize); -void FormatBackTrace(IOutputStream* out); +void FormatBackTrace(IOutputStream* out, void* const* backtrace, size_t backtraceSize); +void FormatBackTrace(IOutputStream* out); void PrintBackTrace(); using TFormatBackTraceFn = void (*)(IOutputStream*, void* const* backtrace, size_t backtraceSize); @@ -34,7 +34,7 @@ private: public: TBackTrace(); void Capture(); - void PrintTo(IOutputStream&) const; + void PrintTo(IOutputStream&) const; TString PrintToString() const; size_t size() const; const void* const* data() const; diff --git a/util/system/backtrace_ut.cpp b/util/system/backtrace_ut.cpp index 9b5ead71bc1..a1413083451 100644 --- a/util/system/backtrace_ut.cpp +++ b/util/system/backtrace_ut.cpp @@ -3,7 +3,7 @@ #include <util/generic/array_ref.h> #include <library/cpp/testing/unittest/registar.h> -#include <util/stream/output.h> +#include <util/stream/output.h> using PFunc = int (*)(void**, size_t); diff --git a/util/system/benchmark/cpu_id/main.cpp b/util/system/benchmark/cpu_id/main.cpp index 8efe5399838..11f29deda8d 100644 --- a/util/system/benchmark/cpu_id/main.cpp +++ b/util/system/benchmark/cpu_id/main.cpp @@ -1,51 +1,51 @@ #include <library/cpp/testing/benchmark/bench.h> - -#include <util/system/cpu_id.h> - -#include <util/generic/xrange.h> - -#define DEFINE_BENCHMARK_PAIR(name) \ - Y_CPU_BENCHMARK(Have##name, iface) { \ - for (const auto i : xrange(iface.Iterations())) { \ - Y_UNUSED(i); \ - Y_DO_NOT_OPTIMIZE_AWAY(NX86::Have##name()); \ - } \ - } \ - \ - Y_CPU_BENCHMARK(CachedHave##name, iface) { \ - for (const auto i : xrange(iface.Iterations())) { \ - Y_UNUSED(i); \ - Y_DO_NOT_OPTIMIZE_AWAY(NX86::CachedHave##name()); \ - } \ - } - -DEFINE_BENCHMARK_PAIR(SSE) -DEFINE_BENCHMARK_PAIR(SSE2) -DEFINE_BENCHMARK_PAIR(SSE3) -DEFINE_BENCHMARK_PAIR(SSSE3) -DEFINE_BENCHMARK_PAIR(SSE41) -DEFINE_BENCHMARK_PAIR(SSE42) -DEFINE_BENCHMARK_PAIR(POPCNT) -DEFINE_BENCHMARK_PAIR(BMI1) -DEFINE_BENCHMARK_PAIR(AES) -DEFINE_BENCHMARK_PAIR(AVX) -DEFINE_BENCHMARK_PAIR(AVX2) -DEFINE_BENCHMARK_PAIR(AVX512F) -DEFINE_BENCHMARK_PAIR(AVX512DQ) -DEFINE_BENCHMARK_PAIR(AVX512IFMA) -DEFINE_BENCHMARK_PAIR(AVX512PF) -DEFINE_BENCHMARK_PAIR(AVX512ER) -DEFINE_BENCHMARK_PAIR(AVX512CD) -DEFINE_BENCHMARK_PAIR(AVX512BW) -DEFINE_BENCHMARK_PAIR(AVX512VL) -DEFINE_BENCHMARK_PAIR(AVX512VBMI) -DEFINE_BENCHMARK_PAIR(PREFETCHWT1) -DEFINE_BENCHMARK_PAIR(SHA) -DEFINE_BENCHMARK_PAIR(ADX) -DEFINE_BENCHMARK_PAIR(RDRAND) -DEFINE_BENCHMARK_PAIR(RDSEED) -DEFINE_BENCHMARK_PAIR(PCOMMIT) -DEFINE_BENCHMARK_PAIR(CLFLUSHOPT) -DEFINE_BENCHMARK_PAIR(CLWB) - -#undef DEFINE_BENCHMARK_PAIR + +#include <util/system/cpu_id.h> + +#include <util/generic/xrange.h> + +#define DEFINE_BENCHMARK_PAIR(name) \ + Y_CPU_BENCHMARK(Have##name, iface) { \ + for (const auto i : xrange(iface.Iterations())) { \ + Y_UNUSED(i); \ + Y_DO_NOT_OPTIMIZE_AWAY(NX86::Have##name()); \ + } \ + } \ + \ + Y_CPU_BENCHMARK(CachedHave##name, iface) { \ + for (const auto i : xrange(iface.Iterations())) { \ + Y_UNUSED(i); \ + Y_DO_NOT_OPTIMIZE_AWAY(NX86::CachedHave##name()); \ + } \ + } + +DEFINE_BENCHMARK_PAIR(SSE) +DEFINE_BENCHMARK_PAIR(SSE2) +DEFINE_BENCHMARK_PAIR(SSE3) +DEFINE_BENCHMARK_PAIR(SSSE3) +DEFINE_BENCHMARK_PAIR(SSE41) +DEFINE_BENCHMARK_PAIR(SSE42) +DEFINE_BENCHMARK_PAIR(POPCNT) +DEFINE_BENCHMARK_PAIR(BMI1) +DEFINE_BENCHMARK_PAIR(AES) +DEFINE_BENCHMARK_PAIR(AVX) +DEFINE_BENCHMARK_PAIR(AVX2) +DEFINE_BENCHMARK_PAIR(AVX512F) +DEFINE_BENCHMARK_PAIR(AVX512DQ) +DEFINE_BENCHMARK_PAIR(AVX512IFMA) +DEFINE_BENCHMARK_PAIR(AVX512PF) +DEFINE_BENCHMARK_PAIR(AVX512ER) +DEFINE_BENCHMARK_PAIR(AVX512CD) +DEFINE_BENCHMARK_PAIR(AVX512BW) +DEFINE_BENCHMARK_PAIR(AVX512VL) +DEFINE_BENCHMARK_PAIR(AVX512VBMI) +DEFINE_BENCHMARK_PAIR(PREFETCHWT1) +DEFINE_BENCHMARK_PAIR(SHA) +DEFINE_BENCHMARK_PAIR(ADX) +DEFINE_BENCHMARK_PAIR(RDRAND) +DEFINE_BENCHMARK_PAIR(RDSEED) +DEFINE_BENCHMARK_PAIR(PCOMMIT) +DEFINE_BENCHMARK_PAIR(CLFLUSHOPT) +DEFINE_BENCHMARK_PAIR(CLWB) + +#undef DEFINE_BENCHMARK_PAIR diff --git a/util/system/benchmark/cpu_id/metrics/main.py b/util/system/benchmark/cpu_id/metrics/main.py index d9a86e825cc..80ce8193b36 100644 --- a/util/system/benchmark/cpu_id/metrics/main.py +++ b/util/system/benchmark/cpu_id/metrics/main.py @@ -1,5 +1,5 @@ -import yatest.common as yc - - -def test_export_metrics(metrics): +import yatest.common as yc + + +def test_export_metrics(metrics): metrics.set_benchmark(yc.execute_benchmark('util/system/benchmark/cpu_id/cpu_id', threads=8)) diff --git a/util/system/benchmark/cpu_id/metrics/ya.make b/util/system/benchmark/cpu_id/metrics/ya.make index 8c55def99b7..46f950de288 100644 --- a/util/system/benchmark/cpu_id/metrics/ya.make +++ b/util/system/benchmark/cpu_id/metrics/ya.make @@ -1,21 +1,21 @@ -OWNER( - yazevnul +OWNER( + yazevnul g:util -) +) SUBSCRIBER(g:util-subscribers) - + PY2TEST() - + SIZE(LARGE) - -TAG( + +TAG( ya:force_sandbox - sb:intel_e5_2660v1 + sb:intel_e5_2660v1 ya:fat -) - +) + TEST_SRCS(main.py) - + DEPENDS(util/system/benchmark/cpu_id) - -END() + +END() diff --git a/util/system/benchmark/cpu_id/ya.make b/util/system/benchmark/cpu_id/ya.make index 976977014f6..a475d0c67fe 100644 --- a/util/system/benchmark/cpu_id/ya.make +++ b/util/system/benchmark/cpu_id/ya.make @@ -1,13 +1,13 @@ -OWNER( - yazevnul +OWNER( + yazevnul g:util -) +) SUBSCRIBER(g:util-subscribers) - + Y_BENCHMARK() - -SRCS( - main.cpp -) - -END() + +SRCS( + main.cpp +) + +END() diff --git a/util/system/benchmark/create_destroy_thread/main.cpp b/util/system/benchmark/create_destroy_thread/main.cpp index 0ca2a9d96f3..8f9f5c9850d 100644 --- a/util/system/benchmark/create_destroy_thread/main.cpp +++ b/util/system/benchmark/create_destroy_thread/main.cpp @@ -1,26 +1,26 @@ #include <library/cpp/testing/benchmark/bench.h> - -#include <util/system/thread.h> - -static void* DoNothing(void*) noexcept { - return nullptr; -} - -Y_CPU_BENCHMARK(CreateDestroyThread, iface) { - for (size_t i = 0, iEnd = iface.Iterations(); i < iEnd; ++i) { - NBench::Clobber(); - TThread t(&DoNothing, nullptr); - Y_DO_NOT_OPTIMIZE_AWAY(t); - NBench::Clobber(); - } -} - -Y_CPU_BENCHMARK(CreateRunDestroyThread, iface) { - for (size_t i = 0, iEnd = iface.Iterations(); i < iEnd; ++i) { - NBench::Clobber(); - TThread t(&DoNothing, nullptr); - t.Start(); - NBench::Escape(t.Join()); - NBench::Clobber(); - } -} + +#include <util/system/thread.h> + +static void* DoNothing(void*) noexcept { + return nullptr; +} + +Y_CPU_BENCHMARK(CreateDestroyThread, iface) { + for (size_t i = 0, iEnd = iface.Iterations(); i < iEnd; ++i) { + NBench::Clobber(); + TThread t(&DoNothing, nullptr); + Y_DO_NOT_OPTIMIZE_AWAY(t); + NBench::Clobber(); + } +} + +Y_CPU_BENCHMARK(CreateRunDestroyThread, iface) { + for (size_t i = 0, iEnd = iface.Iterations(); i < iEnd; ++i) { + NBench::Clobber(); + TThread t(&DoNothing, nullptr); + t.Start(); + NBench::Escape(t.Join()); + NBench::Clobber(); + } +} diff --git a/util/system/benchmark/create_destroy_thread/metrics/main.py b/util/system/benchmark/create_destroy_thread/metrics/main.py index 45564cda7f6..3ee8f8a2eae 100644 --- a/util/system/benchmark/create_destroy_thread/metrics/main.py +++ b/util/system/benchmark/create_destroy_thread/metrics/main.py @@ -1,7 +1,7 @@ -import yatest.common as yc - - -def test_export_metrics(metrics): +import yatest.common as yc + + +def test_export_metrics(metrics): metrics.set_benchmark( yc.execute_benchmark('util/system/benchmark/create_destroy_thread/create_destroy_thread', threads=8) ) diff --git a/util/system/benchmark/create_destroy_thread/metrics/ya.make b/util/system/benchmark/create_destroy_thread/metrics/ya.make index d526487e1a5..9498e478121 100644 --- a/util/system/benchmark/create_destroy_thread/metrics/ya.make +++ b/util/system/benchmark/create_destroy_thread/metrics/ya.make @@ -1,21 +1,21 @@ -OWNER( - yazevnul +OWNER( + yazevnul g:util -) +) SUBSCRIBER(g:util-subscribers) - + PY2TEST() - + SIZE(LARGE) - -TAG( + +TAG( ya:force_sandbox - sb:intel_e5_2660v1 + sb:intel_e5_2660v1 ya:fat -) - +) + TEST_SRCS(main.py) - + DEPENDS(util/system/benchmark/create_destroy_thread) - -END() + +END() diff --git a/util/system/benchmark/create_destroy_thread/ya.make b/util/system/benchmark/create_destroy_thread/ya.make index 03eb0ec8e07..c50840aaad8 100644 --- a/util/system/benchmark/create_destroy_thread/ya.make +++ b/util/system/benchmark/create_destroy_thread/ya.make @@ -1,9 +1,9 @@ OWNER(yazevnul) - + Y_BENCHMARK() - -SRCS( - main.cpp -) - -END() + +SRCS( + main.cpp +) + +END() diff --git a/util/system/benchmark/ya.make b/util/system/benchmark/ya.make index 12fa9af9d60..262bc5b0900 100644 --- a/util/system/benchmark/ya.make +++ b/util/system/benchmark/ya.make @@ -1,15 +1,15 @@ -OWNER( - yazevnul +OWNER( + yazevnul g:util -) +) SUBSCRIBER(g:util-subscribers) - -RECURSE( - cpu_id - cpu_id/metrics - create_destroy_thread - create_destroy_thread/metrics -) + +RECURSE( + cpu_id + cpu_id/metrics + create_destroy_thread + create_destroy_thread/metrics +) IF (NOT OS_WINDOWS) RECURSE( diff --git a/util/system/compat_ut.cpp b/util/system/compat_ut.cpp index dbd9289c17c..ead2e588659 100644 --- a/util/system/compat_ut.cpp +++ b/util/system/compat_ut.cpp @@ -5,8 +5,8 @@ #include <util/folder/dirut.h> #include <util/stream/output.h> -Y_UNIT_TEST_SUITE(TCompatTest) { - Y_UNIT_TEST(TestGetprogname) { +Y_UNIT_TEST_SUITE(TCompatTest) { + Y_UNIT_TEST(TestGetprogname) { getprogname(); // just check it links } } diff --git a/util/system/compiler.h b/util/system/compiler.h index b373edcc466..8b8373f5843 100644 --- a/util/system/compiler.h +++ b/util/system/compiler.h @@ -6,36 +6,36 @@ // useful cross-platfrom definitions for compilers -/** - * @def Y_FUNC_SIGNATURE - * - * Use this macro to get pretty function name (see example). - * - * @code - * void Hi() { - * Cout << Y_FUNC_SIGNATURE << Endl; - * } - - * template <typename T> - * void Do() { - * Cout << Y_FUNC_SIGNATURE << Endl; - * } - - * int main() { - * Hi(); // void Hi() - * Do<int>(); // void Do() [T = int] +/** + * @def Y_FUNC_SIGNATURE + * + * Use this macro to get pretty function name (see example). + * + * @code + * void Hi() { + * Cout << Y_FUNC_SIGNATURE << Endl; + * } + + * template <typename T> + * void Do() { + * Cout << Y_FUNC_SIGNATURE << Endl; + * } + + * int main() { + * Hi(); // void Hi() + * Do<int>(); // void Do() [T = int] * Do<TString>(); // void Do() [T = TString] - * } - * @endcode - */ -#if defined(__GNUC__) + * } + * @endcode + */ +#if defined(__GNUC__) #define Y_FUNC_SIGNATURE __PRETTY_FUNCTION__ -#elif defined(_MSC_VER) +#elif defined(_MSC_VER) #define Y_FUNC_SIGNATURE __FUNCSIG__ -#else +#else #define Y_FUNC_SIGNATURE "" -#endif - +#endif + #ifdef __GNUC__ #define Y_PRINTF_FORMAT(n, m) __attribute__((__format__(__printf__, n, m))) #endif @@ -53,26 +53,26 @@ #endif /** - * @def Y_DECLARE_UNUSED - * - * Macro is needed to silence compiler warning about unused entities (e.g. function or argument). - * - * @code - * Y_DECLARE_UNUSED int FunctionUsedSolelyForDebugPurposes(); - * assert(FunctionUsedSolelyForDebugPurposes() == 42); - * - * void Foo(const int argumentUsedOnlyForDebugPurposes Y_DECLARE_UNUSED) { - * assert(argumentUsedOnlyForDebugPurposes == 42); - * // however you may as well omit `Y_DECLARE_UNUSED` and use `UNUSED` macro instead - * Y_UNUSED(argumentUsedOnlyForDebugPurposes); - * } - * @endcode - */ + * @def Y_DECLARE_UNUSED + * + * Macro is needed to silence compiler warning about unused entities (e.g. function or argument). + * + * @code + * Y_DECLARE_UNUSED int FunctionUsedSolelyForDebugPurposes(); + * assert(FunctionUsedSolelyForDebugPurposes() == 42); + * + * void Foo(const int argumentUsedOnlyForDebugPurposes Y_DECLARE_UNUSED) { + * assert(argumentUsedOnlyForDebugPurposes == 42); + * // however you may as well omit `Y_DECLARE_UNUSED` and use `UNUSED` macro instead + * Y_UNUSED(argumentUsedOnlyForDebugPurposes); + * } + * @endcode + */ #ifdef __GNUC__ #define Y_DECLARE_UNUSED __attribute__((unused)) #endif -#ifndef Y_DECLARE_UNUSED +#ifndef Y_DECLARE_UNUSED #define Y_DECLARE_UNUSED #endif @@ -152,7 +152,7 @@ #define Y_PREFETCH_WRITE(Pointer, Priority) (void)(const void*)(Pointer), (void)Priority #endif -#ifndef Y_LIKELY +#ifndef Y_LIKELY #define Y_LIKELY(Cond) (Cond) #define Y_UNLIKELY(Cond) (Cond) #endif diff --git a/util/system/compiler_ut.cpp b/util/system/compiler_ut.cpp index f93b1c08507..aaeb935b162 100644 --- a/util/system/compiler_ut.cpp +++ b/util/system/compiler_ut.cpp @@ -2,8 +2,8 @@ #include <library/cpp/testing/unittest/registar.h> -Y_UNIT_TEST_SUITE(TCompilerTest) { - Y_UNIT_TEST(TestPragmaNoWshadow) { +Y_UNIT_TEST_SUITE(TCompilerTest) { + Y_UNIT_TEST(TestPragmaNoWshadow) { Y_PRAGMA_DIAGNOSTIC_PUSH Y_PRAGMA_NO_WSHADOW @@ -34,7 +34,7 @@ Y_UNIT_TEST_SUITE(TCompilerTest) { UNIT_ASSERT_EQUAL(Foo(1), 0); } - Y_UNIT_TEST(TestHaveInt128) { + Y_UNIT_TEST(TestHaveInt128) { #ifdef Y_HAVE_INT128 // will be compiled without errors unsigned __int128 a = 1; diff --git a/util/system/condvar.cpp b/util/system/condvar.cpp index 62f3d22356c..2eeb720f9fa 100644 --- a/util/system/condvar.cpp +++ b/util/system/condvar.cpp @@ -28,7 +28,7 @@ namespace { public: inline ~TCondVarImpl() { - Y_ASSERT(Events_.Empty()); + Y_ASSERT(Events_.Empty()); } inline void Signal() noexcept { @@ -81,25 +81,25 @@ class TCondVar::TImpl: public TCondVarImpl { class TCondVar::TImpl { public: inline TImpl() { - if (pthread_cond_init(&Cond_, nullptr)) { + if (pthread_cond_init(&Cond_, nullptr)) { ythrow yexception() << "can not create condvar(" << LastSystemErrorText() << ")"; } } inline ~TImpl() { int ret = pthread_cond_destroy(&Cond_); - Y_VERIFY(ret == 0, "pthread_cond_destroy failed: %s", LastSystemErrorText(ret)); + Y_VERIFY(ret == 0, "pthread_cond_destroy failed: %s", LastSystemErrorText(ret)); } inline void Signal() noexcept { int ret = pthread_cond_signal(&Cond_); - Y_VERIFY(ret == 0, "pthread_cond_signal failed: %s", LastSystemErrorText(ret)); + Y_VERIFY(ret == 0, "pthread_cond_signal failed: %s", LastSystemErrorText(ret)); } inline bool WaitD(TMutex& lock, TInstant deadLine) noexcept { if (deadLine == TInstant::Max()) { int ret = pthread_cond_wait(&Cond_, (pthread_mutex_t*)lock.Handle()); - Y_VERIFY(ret == 0, "pthread_cond_wait failed: %s", LastSystemErrorText(ret)); + Y_VERIFY(ret == 0, "pthread_cond_wait failed: %s", LastSystemErrorText(ret)); return true; } else { struct timespec spec; @@ -111,7 +111,7 @@ public: int ret = pthread_cond_timedwait(&Cond_, (pthread_mutex_t*)lock.Handle(), &spec); - Y_VERIFY(ret == 0 || ret == ETIMEDOUT, "pthread_cond_timedwait failed: %s", LastSystemErrorText(ret)); + Y_VERIFY(ret == 0 || ret == ETIMEDOUT, "pthread_cond_timedwait failed: %s", LastSystemErrorText(ret)); return ret == 0; } @@ -119,7 +119,7 @@ public: inline void BroadCast() noexcept { int ret = pthread_cond_broadcast(&Cond_); - Y_VERIFY(ret == 0, "pthread_cond_broadcast failed: %s", LastSystemErrorText(ret)); + Y_VERIFY(ret == 0, "pthread_cond_broadcast failed: %s", LastSystemErrorText(ret)); } private: diff --git a/util/system/condvar.h b/util/system/condvar.h index 569162717cb..911ace52c6a 100644 --- a/util/system/condvar.h +++ b/util/system/condvar.h @@ -6,8 +6,8 @@ #include <util/generic/noncopyable.h> #include <util/datetime/base.h> -#include <utility> - +#include <utility> + class TCondVar { public: TCondVar(); @@ -19,30 +19,30 @@ public: /* * returns false if failed by timeout */ - bool WaitD(TMutex& m, TInstant deadline) noexcept; - - template <typename P> - inline bool WaitD(TMutex& m, TInstant deadline, P pred) noexcept { - while (!pred()) { - if (!WaitD(m, deadline)) { - return pred(); - } - } - return true; - } + bool WaitD(TMutex& m, TInstant deadline) noexcept; + template <typename P> + inline bool WaitD(TMutex& m, TInstant deadline, P pred) noexcept { + while (!pred()) { + if (!WaitD(m, deadline)) { + return pred(); + } + } + return true; + } + /* * returns false if failed by timeout */ - inline bool WaitT(TMutex& m, TDuration timeout) noexcept { - return WaitD(m, timeout.ToDeadLine()); - } - - template <typename P> - inline bool WaitT(TMutex& m, TDuration timeout, P pred) noexcept { - return WaitD(m, timeout.ToDeadLine(), std::move(pred)); + inline bool WaitT(TMutex& m, TDuration timeout) noexcept { + return WaitD(m, timeout.ToDeadLine()); } + template <typename P> + inline bool WaitT(TMutex& m, TDuration timeout, P pred) noexcept { + return WaitD(m, timeout.ToDeadLine(), std::move(pred)); + } + /* * infinite wait */ @@ -50,21 +50,21 @@ public: WaitD(m, TInstant::Max()); } - template <typename P> - inline void WaitI(TMutex& m, P pred) noexcept { - WaitD(m, TInstant::Max(), std::move(pred)); - } - + template <typename P> + inline void WaitI(TMutex& m, P pred) noexcept { + WaitD(m, TInstant::Max(), std::move(pred)); + } + //deprecated inline void Wait(TMutex& m) noexcept { WaitI(m); } - template <typename P> - inline void Wait(TMutex& m, P pred) noexcept { - WaitI(m, std::move(pred)); - } - + template <typename P> + inline void Wait(TMutex& m, P pred) noexcept { + WaitI(m, std::move(pred)); + } + private: class TImpl; THolder<TImpl> Impl_; diff --git a/util/system/condvar_ut.cpp b/util/system/condvar_ut.cpp index 5130a18d32a..696516c810b 100644 --- a/util/system/condvar_ut.cpp +++ b/util/system/condvar_ut.cpp @@ -4,8 +4,8 @@ #include <library/cpp/testing/unittest/registar.h> -#include <util/system/atomic.h> -#include <util/system/atomic_ops.h> +#include <util/system/atomic.h> +#include <util/system/atomic_ops.h> #include <util/thread/pool.h> class TCondVarTest: public TTestBase { @@ -28,12 +28,12 @@ class TCondVarTest: public TTestBase { TCondVar condVar1; TCondVar condVar2; - TAtomic stopWaiting; + TAtomic stopWaiting; - TAtomic in; - TAtomic out; + TAtomic in; + TAtomic out; - TAtomic waited; + TAtomic waited; bool failed; }; @@ -61,36 +61,17 @@ class TCondVarTest: public TTestBase { Data_.failed = true; \ } void RunBasics() { - Y_ASSERT(TotalIds_ == 3); + Y_ASSERT(TotalIds_ == 3); if (Id_ < 2) { TGuard<TMutex> guard(Data_.mutex); - while (!AtomicGet(Data_.stopWaiting)) { + while (!AtomicGet(Data_.stopWaiting)) { bool res = Data_.condVar1.WaitT(Data_.mutex, TDuration::Seconds(1)); FAIL_ASSERT(res == true); } } else { usleep(100000); - AtomicSet(Data_.stopWaiting, true); - - TGuard<TMutex> guard(Data_.mutex); - Data_.condVar1.Signal(); - Data_.condVar1.Signal(); - } - } - - void RunBasicsWithPredicate() { - Y_ASSERT(TotalIds_ == 3); - - if (Id_ < 2) { - TGuard<TMutex> guard(Data_.mutex); - const auto res = Data_.condVar1.WaitT(Data_.mutex, TDuration::Seconds(1), [&] { - return AtomicGet(Data_.stopWaiting); - }); - FAIL_ASSERT(res == true); - } else { - usleep(100000); - AtomicSet(Data_.stopWaiting, true); + AtomicSet(Data_.stopWaiting, true); TGuard<TMutex> guard(Data_.mutex); Data_.condVar1.Signal(); @@ -98,63 +79,82 @@ class TCondVarTest: public TTestBase { } } + void RunBasicsWithPredicate() { + Y_ASSERT(TotalIds_ == 3); + + if (Id_ < 2) { + TGuard<TMutex> guard(Data_.mutex); + const auto res = Data_.condVar1.WaitT(Data_.mutex, TDuration::Seconds(1), [&] { + return AtomicGet(Data_.stopWaiting); + }); + FAIL_ASSERT(res == true); + } else { + usleep(100000); + AtomicSet(Data_.stopWaiting, true); + + TGuard<TMutex> guard(Data_.mutex); + Data_.condVar1.Signal(); + Data_.condVar1.Signal(); + } + } + void RunSyncronize() { for (size_t i = 0; i < 10; ++i) { TGuard<TMutex> guard(Data_.mutex); - AtomicIncrement(Data_.in); - if (AtomicGet(Data_.in) == TotalIds_) { - AtomicSet(Data_.out, 0); + AtomicIncrement(Data_.in); + if (AtomicGet(Data_.in) == TotalIds_) { + AtomicSet(Data_.out, 0); Data_.condVar1.BroadCast(); } else { - AtomicIncrement(Data_.waited); - while (AtomicGet(Data_.in) < TotalIds_) { + AtomicIncrement(Data_.waited); + while (AtomicGet(Data_.in) < TotalIds_) { bool res = Data_.condVar1.WaitT(Data_.mutex, TDuration::Seconds(1)); FAIL_ASSERT(res == true); } } - AtomicIncrement(Data_.out); - if (AtomicGet(Data_.out) == TotalIds_) { - AtomicSet(Data_.in, 0); + AtomicIncrement(Data_.out); + if (AtomicGet(Data_.out) == TotalIds_) { + AtomicSet(Data_.in, 0); Data_.condVar2.BroadCast(); } else { - while (AtomicGet(Data_.out) < TotalIds_) { + while (AtomicGet(Data_.out) < TotalIds_) { bool res = Data_.condVar2.WaitT(Data_.mutex, TDuration::Seconds(1)); FAIL_ASSERT(res == true); } } } - FAIL_ASSERT(AtomicGet(Data_.waited) == (TotalIds_ - 1) * 10); - } - - void RunSyncronizeWithPredicate() { - for (size_t i = 0; i < 10; ++i) { - TGuard<TMutex> guard(Data_.mutex); - AtomicIncrement(Data_.in); - if (AtomicGet(Data_.in) == TotalIds_) { - AtomicSet(Data_.out, 0); - Data_.condVar1.BroadCast(); - } else { - AtomicIncrement(Data_.waited); - const auto res = Data_.condVar1.WaitT(Data_.mutex, TDuration::Seconds(1), [&] { - return AtomicGet(Data_.in) >= TotalIds_; - }); - FAIL_ASSERT(res == true); - } - - AtomicIncrement(Data_.out); - if (AtomicGet(Data_.out) == TotalIds_) { - AtomicSet(Data_.in, 0); - Data_.condVar2.BroadCast(); - } else { - const auto res = Data_.condVar2.WaitT(Data_.mutex, TDuration::Seconds(1), [&] { - return AtomicGet(Data_.out) >= TotalIds_; - }); - FAIL_ASSERT(res == true); - } - } - + FAIL_ASSERT(AtomicGet(Data_.waited) == (TotalIds_ - 1) * 10); + } + + void RunSyncronizeWithPredicate() { + for (size_t i = 0; i < 10; ++i) { + TGuard<TMutex> guard(Data_.mutex); + AtomicIncrement(Data_.in); + if (AtomicGet(Data_.in) == TotalIds_) { + AtomicSet(Data_.out, 0); + Data_.condVar1.BroadCast(); + } else { + AtomicIncrement(Data_.waited); + const auto res = Data_.condVar1.WaitT(Data_.mutex, TDuration::Seconds(1), [&] { + return AtomicGet(Data_.in) >= TotalIds_; + }); + FAIL_ASSERT(res == true); + } + + AtomicIncrement(Data_.out); + if (AtomicGet(Data_.out) == TotalIds_) { + AtomicSet(Data_.in, 0); + Data_.condVar2.BroadCast(); + } else { + const auto res = Data_.condVar2.WaitT(Data_.mutex, TDuration::Seconds(1), [&] { + return AtomicGet(Data_.out) >= TotalIds_; + }); + FAIL_ASSERT(res == true); + } + } + FAIL_ASSERT(Data_.waited == (TotalIds_ - 1) * 10); } #undef FAIL_ASSERT @@ -162,7 +162,7 @@ class TCondVarTest: public TTestBase { private: PFunc Func_; size_t Id_; - TAtomicBase TotalIds_; + TAtomicBase TotalIds_; TSharedData& Data_; }; @@ -181,17 +181,17 @@ private: RUN_CYCLE(RunBasics, 3); } - inline void TestBasicsWithPredicate() { - RUN_CYCLE(RunBasicsWithPredicate, 3); - } - + inline void TestBasicsWithPredicate() { + RUN_CYCLE(RunBasicsWithPredicate, 3); + } + inline void TestSyncronize() { RUN_CYCLE(RunSyncronize, 6); } - - inline void TestSyncronizeWithPredicate() { - RUN_CYCLE(RunSyncronizeWithPredicate, 6); - } + + inline void TestSyncronizeWithPredicate() { + RUN_CYCLE(RunSyncronizeWithPredicate, 6); + } #undef RUN_CYCLE TSharedData Data_; TThreadPool Q_; diff --git a/util/system/context.cpp b/util/system/context.cpp index ad993090884..d108105da0c 100644 --- a/util/system/context.cpp +++ b/util/system/context.cpp @@ -127,7 +127,7 @@ namespace { Y_NO_SANITIZE("address") Y_NO_SANITIZE("memory") static void ContextTrampoLine() { void** argPtr = (void**)((char*)AlignUp(&argPtr + EXTRA_PUSH_ARGS, STACK_ALIGN) + STACK_ALIGN); - Y_ASSERT(*(argPtr - 1) == *(argPtr - 2)); + Y_ASSERT(*(argPtr - 1) == *(argPtr - 2)); Run(*(argPtr - 1)); } @@ -183,7 +183,7 @@ TContMachineContext::TContMachineContext(const TContClosure& c) * fake return address */ for (size_t i = 0; i < EXTRA_PUSH_ARGS; ++i) { - stack.Push(nullptr); + stack.Push(nullptr); } #endif @@ -249,7 +249,7 @@ void TContMachineContext::SwitchTo(TContMachineContext* next) noexcept { struct TContMachineContext::TImpl { inline TImpl() - : TL(nullptr) + : TL(nullptr) , Finish(false) { } diff --git a/util/system/context_ut.cpp b/util/system/context_ut.cpp index 45cb0249f74..9fac04fc085 100644 --- a/util/system/context_ut.cpp +++ b/util/system/context_ut.cpp @@ -5,7 +5,7 @@ #include <util/generic/deque.h> #include <util/generic/yexception.h> -Y_UNIT_TEST_SUITE(TestContext) { +Y_UNIT_TEST_SUITE(TestContext) { template <class F> static TContClosure Wrap(F& f) { struct TW: public ITrampoLine { @@ -29,7 +29,7 @@ Y_UNIT_TEST_SUITE(TestContext) { return {&tw, TArrayRef(tw.Buf, sizeof(tw.Buf))}; } - Y_UNIT_TEST(TestExceptionSafety) { + Y_UNIT_TEST(TestExceptionSafety) { TExceptionSafeContext main; TExceptionSafeContext* volatile nextPtr = nullptr; diff --git a/util/system/cpu_id.cpp b/util/system/cpu_id.cpp index 598c71f4d91..37f923932a5 100644 --- a/util/system/cpu_id.cpp +++ b/util/system/cpu_id.cpp @@ -4,53 +4,53 @@ #include <util/generic/singleton.h> -#if defined(_win_) +#if defined(_win_) #include <intrin.h> #include <immintrin.h> -#elif defined(_x86_) +#elif defined(_x86_) #include <cpuid.h> #endif #include <string.h> -#if defined(_x86_) && !defined(_win_) -static ui64 _xgetbv(ui32 xcr) { - ui32 eax; - ui32 edx; +#if defined(_x86_) && !defined(_win_) +static ui64 _xgetbv(ui32 xcr) { + ui32 eax; + ui32 edx; __asm__ volatile( "xgetbv" : "=a"(eax), "=d"(edx) : "c"(xcr)); - return (static_cast<ui64>(edx) << 32) | eax; -} -#endif - -bool NX86::CpuId(ui32 op, ui32 subOp, ui32* res) noexcept { -#if defined(_x86_) + return (static_cast<ui64>(edx) << 32) | eax; +} +#endif + +bool NX86::CpuId(ui32 op, ui32 subOp, ui32* res) noexcept { +#if defined(_x86_) #if defined(_MSC_VER) - static_assert(sizeof(int) == sizeof(ui32), "ups, something wrong here"); - __cpuidex((int*)res, op, subOp); + static_assert(sizeof(int) == sizeof(ui32), "ups, something wrong here"); + __cpuidex((int*)res, op, subOp); #else - __cpuid_count(op, subOp, res[0], res[1], res[2], res[3]); + __cpuid_count(op, subOp, res[0], res[1], res[2], res[3]); #endif - return true; -#else - (void)op; - (void)subOp; - - memset(res, 0, 4 * sizeof(ui32)); - - return false; -#endif -} - -bool NX86::CpuId(ui32 op, ui32* res) noexcept { + return true; +#else + (void)op; + (void)subOp; + + memset(res, 0, 4 * sizeof(ui32)); + + return false; +#endif +} + +bool NX86::CpuId(ui32 op, ui32* res) noexcept { #if defined(_x86_) #if defined(_MSC_VER) static_assert(sizeof(int) == sizeof(ui32), "ups, something wrong here"); __cpuid((int*)res, op); #else - __cpuid(op, res[0], res[1], res[2], res[3]); + __cpuid(op, res[0], res[1], res[2], res[3]); #endif return true; #else @@ -73,13 +73,13 @@ namespace { ui32 EDX; }; - inline TX86CpuInfo(ui32 op) noexcept { + inline TX86CpuInfo(ui32 op) noexcept { NX86::CpuId(op, Info); } - - inline TX86CpuInfo(ui32 op, ui32 subOp) noexcept { - NX86::CpuId(op, subOp, Info); - } + + inline TX86CpuInfo(ui32 op, ui32 subOp) noexcept { + NX86::CpuId(op, subOp, Info); + } }; static_assert(sizeof(TX86CpuInfo) == 16, "please, fix me"); @@ -90,15 +90,15 @@ bool NX86::HaveRDTSCP() noexcept { return (TX86CpuInfo(0x80000001).EDX >> 27) & 1u; } -bool NX86::HaveSSE() noexcept { +bool NX86::HaveSSE() noexcept { return (TX86CpuInfo(0x1).EDX >> 25) & 1u; } -bool NX86::HaveSSE2() noexcept { +bool NX86::HaveSSE2() noexcept { return (TX86CpuInfo(0x1).EDX >> 26) & 1u; } -bool NX86::HaveSSE3() noexcept { +bool NX86::HaveSSE3() noexcept { return TX86CpuInfo(0x1).ECX & 1u; } @@ -106,15 +106,15 @@ bool NX86::HavePCLMUL() noexcept { return (TX86CpuInfo(0x1).ECX >> 1) & 1u; } -bool NX86::HaveSSSE3() noexcept { +bool NX86::HaveSSSE3() noexcept { return (TX86CpuInfo(0x1).ECX >> 9) & 1u; } -bool NX86::HaveSSE41() noexcept { +bool NX86::HaveSSE41() noexcept { return (TX86CpuInfo(0x1).ECX >> 19) & 1u; } -bool NX86::HaveSSE42() noexcept { +bool NX86::HaveSSE42() noexcept { return (TX86CpuInfo(0x1).ECX >> 20) & 1u; } @@ -122,51 +122,51 @@ bool NX86::HaveF16C() noexcept { return (TX86CpuInfo(0x1).ECX >> 29) & 1u; } -bool NX86::HavePOPCNT() noexcept { +bool NX86::HavePOPCNT() noexcept { return (TX86CpuInfo(0x1).ECX >> 23) & 1u; } -bool NX86::HaveAES() noexcept { +bool NX86::HaveAES() noexcept { return (TX86CpuInfo(0x1).ECX >> 25) & 1u; } -bool NX86::HaveXSAVE() noexcept { - return (TX86CpuInfo(0x1).ECX >> 26) & 1u; -} - -bool NX86::HaveOSXSAVE() noexcept { - return (TX86CpuInfo(0x1).ECX >> 27) & 1u; -} - -bool NX86::HaveAVX() noexcept { +bool NX86::HaveXSAVE() noexcept { + return (TX86CpuInfo(0x1).ECX >> 26) & 1u; +} + +bool NX86::HaveOSXSAVE() noexcept { + return (TX86CpuInfo(0x1).ECX >> 27) & 1u; +} + +bool NX86::HaveAVX() noexcept { #if defined(_x86_) // http://www.intel.com/content/dam/www/public/us/en/documents/manuals/64-ia-32-architectures-optimization-manual.pdf - // https://bugs.chromium.org/p/chromium/issues/detail?id=375968 + // https://bugs.chromium.org/p/chromium/issues/detail?id=375968 return HaveOSXSAVE() // implies HaveXSAVE() && (_xgetbv(0) & 6u) == 6u // XMM state and YMM state are enabled by OS && ((TX86CpuInfo(0x1).ECX >> 28) & 1u); // AVX bit -#else +#else return false; -#endif +#endif } -bool NX86::HaveFMA() noexcept { +bool NX86::HaveFMA() noexcept { return HaveAVX() && ((TX86CpuInfo(0x1).ECX >> 12) & 1u); } -bool NX86::HaveAVX2() noexcept { +bool NX86::HaveAVX2() noexcept { return HaveAVX() && ((TX86CpuInfo(0x7, 0).EBX >> 5) & 1u); -} - -bool NX86::HaveBMI1() noexcept { - return (TX86CpuInfo(0x7, 0).EBX >> 3) & 1u; -} - +} + +bool NX86::HaveBMI1() noexcept { + return (TX86CpuInfo(0x7, 0).EBX >> 3) & 1u; +} + bool NX86::HaveBMI2() noexcept { return (TX86CpuInfo(0x7, 0).EBX >> 8) & 1u; } -bool NX86::HaveAVX512F() noexcept { +bool NX86::HaveAVX512F() noexcept { #if defined(_x86_) // https://software.intel.com/en-us/articles/how-to-detect-knl-instruction-support return HaveOSXSAVE() // implies HaveXSAVE() @@ -177,73 +177,73 @@ bool NX86::HaveAVX512F() noexcept { #else return false; #endif -} - -bool NX86::HaveAVX512DQ() noexcept { +} + +bool NX86::HaveAVX512DQ() noexcept { return HaveAVX512F() && ((TX86CpuInfo(0x7, 0).EBX >> 17) & 1u); -} - -bool NX86::HaveRDSEED() noexcept { +} + +bool NX86::HaveRDSEED() noexcept { return TX86CpuInfo(0x0).EAX >= 0x7 && ((TX86CpuInfo(0x7, 0).EBX >> 18) & 1u); -} - -bool NX86::HaveADX() noexcept { +} + +bool NX86::HaveADX() noexcept { return TX86CpuInfo(0x0).EAX >= 0x7 && ((TX86CpuInfo(0x7, 0).EBX >> 19) & 1u); -} - -bool NX86::HaveAVX512IFMA() noexcept { +} + +bool NX86::HaveAVX512IFMA() noexcept { return HaveAVX512F() && ((TX86CpuInfo(0x7, 0).EBX >> 21) & 1u); -} - -bool NX86::HavePCOMMIT() noexcept { +} + +bool NX86::HavePCOMMIT() noexcept { return TX86CpuInfo(0x0).EAX >= 0x7 && ((TX86CpuInfo(0x7, 0).EBX >> 22) & 1u); -} - -bool NX86::HaveCLFLUSHOPT() noexcept { +} + +bool NX86::HaveCLFLUSHOPT() noexcept { return TX86CpuInfo(0x0).EAX >= 0x7 && ((TX86CpuInfo(0x7, 0).EBX >> 23) & 1u); -} - -bool NX86::HaveCLWB() noexcept { +} + +bool NX86::HaveCLWB() noexcept { return TX86CpuInfo(0x0).EAX >= 0x7 && ((TX86CpuInfo(0x7, 0).EBX >> 24) & 1u); -} - -bool NX86::HaveAVX512PF() noexcept { +} + +bool NX86::HaveAVX512PF() noexcept { return HaveAVX512F() && ((TX86CpuInfo(0x7, 0).EBX >> 26) & 1u); -} - -bool NX86::HaveAVX512ER() noexcept { +} + +bool NX86::HaveAVX512ER() noexcept { return HaveAVX512F() && ((TX86CpuInfo(0x7, 0).EBX >> 27) & 1u); -} - -bool NX86::HaveAVX512CD() noexcept { +} + +bool NX86::HaveAVX512CD() noexcept { return HaveAVX512F() && ((TX86CpuInfo(0x7, 0).EBX >> 28) & 1u); -} - -bool NX86::HaveSHA() noexcept { +} + +bool NX86::HaveSHA() noexcept { return TX86CpuInfo(0x0).EAX >= 0x7 && ((TX86CpuInfo(0x7, 0).EBX >> 29) & 1u); -} - -bool NX86::HaveAVX512BW() noexcept { +} + +bool NX86::HaveAVX512BW() noexcept { return HaveAVX512F() && ((TX86CpuInfo(0x7, 0).EBX >> 30) & 1u); -} - -bool NX86::HaveAVX512VL() noexcept { +} + +bool NX86::HaveAVX512VL() noexcept { return HaveAVX512F() && ((TX86CpuInfo(0x7, 0).EBX >> 31) & 1u); -} - -bool NX86::HavePREFETCHWT1() noexcept { +} + +bool NX86::HavePREFETCHWT1() noexcept { return TX86CpuInfo(0x0).EAX >= 0x7 && ((TX86CpuInfo(0x7, 0).ECX >> 0) & 1u); -} - -bool NX86::HaveAVX512VBMI() noexcept { +} + +bool NX86::HaveAVX512VBMI() noexcept { return HaveAVX512F() && ((TX86CpuInfo(0x7, 0).ECX >> 1) & 1u); -} - -bool NX86::HaveRDRAND() noexcept { +} + +bool NX86::HaveRDRAND() noexcept { return TX86CpuInfo(0x0).EAX >= 0x7 && ((TX86CpuInfo(0x1).ECX >> 30) & 1u); } -const char* CpuBrand(ui32* store) noexcept { +const char* CpuBrand(ui32* store) noexcept { memset(store, 0, 12 * sizeof(*store)); #if defined(_x86_) diff --git a/util/system/cpu_id.h b/util/system/cpu_id.h index 3c49e728a7d..5f30c415c17 100644 --- a/util/system/cpu_id.h +++ b/util/system/cpu_id.h @@ -75,13 +75,13 @@ namespace NX86 { /** * returns false on non-x86 platforms */ - bool CpuId(ui32 op, ui32 res[4]) noexcept; - bool CpuId(ui32 op, ui32 subOp, ui32 res[4]) noexcept; - + bool CpuId(ui32 op, ui32 res[4]) noexcept; + bool CpuId(ui32 op, ui32 subOp, ui32 res[4]) noexcept; + #define Y_DEF_NAME(X) Y_CONST_FUNCTION bool Have##X() noexcept; Y_CPU_ID_ENUMERATE(Y_DEF_NAME) #undef Y_DEF_NAME - + #define Y_DEF_NAME(X) Y_CONST_FUNCTION bool CachedHave##X() noexcept; Y_CPU_ID_ENUMERATE_OUTLINED_CACHED_DEFINE(Y_DEF_NAME) #undef Y_DEF_NAME @@ -154,4 +154,4 @@ namespace NX86 { } -const char* CpuBrand(ui32 store[12]) noexcept; +const char* CpuBrand(ui32 store[12]) noexcept; diff --git a/util/system/cpu_id_ut.cpp b/util/system/cpu_id_ut.cpp index 68f1f8aac7f..11641964790 100644 --- a/util/system/cpu_id_ut.cpp +++ b/util/system/cpu_id_ut.cpp @@ -1,51 +1,51 @@ #include "cpu_id.h" -#include "platform.h" - +#include "platform.h" + #include <library/cpp/testing/unittest/registar.h> -// There are no tests yet for instructions that use 512-bit wide registers because they are not -// supported by some compilers yet. -// Relevant review in LLVM https://reviews.llvm.org/D16757, we should wait untill it will be in our -// version of Clang. -// -// There are also no tests for PREFETCHWT1, PCOMMIT, CLFLUSHOPT and CLWB as they are not supported -// by our compilers yet (and there are no available processors yet :). - -static void ExecuteSSEInstruction(); -static void ExecuteSSE2Instruction(); -static void ExecuteSSE3Instruction(); -static void ExecuteSSSE3Instruction(); -static void ExecuteSSE41Instruction(); -static void ExecuteSSE42Instruction(); +// There are no tests yet for instructions that use 512-bit wide registers because they are not +// supported by some compilers yet. +// Relevant review in LLVM https://reviews.llvm.org/D16757, we should wait untill it will be in our +// version of Clang. +// +// There are also no tests for PREFETCHWT1, PCOMMIT, CLFLUSHOPT and CLWB as they are not supported +// by our compilers yet (and there are no available processors yet :). + +static void ExecuteSSEInstruction(); +static void ExecuteSSE2Instruction(); +static void ExecuteSSE3Instruction(); +static void ExecuteSSSE3Instruction(); +static void ExecuteSSE41Instruction(); +static void ExecuteSSE42Instruction(); static void ExecuteF16CInstruction(); -static void ExecuteAVXInstruction(); -static void ExecuteAVX2Instruction(); -static void ExecutePOPCNTInstruction(); -static void ExecuteBMI1Instruction(); +static void ExecuteAVXInstruction(); +static void ExecuteAVX2Instruction(); +static void ExecutePOPCNTInstruction(); +static void ExecuteBMI1Instruction(); static void ExecuteBMI2Instruction(); static void ExecutePCLMULInstruction(); -static void ExecuteAESInstruction(); -static void ExecuteAVXInstruction(); -static void ExecuteAVX2Instruction(); -static void ExecuteAVX512FInstruction(); -static void ExecuteAVX512DQInstruction(); -static void ExecuteAVX512IFMAInstruction(); -static void ExecuteAVX512PFInstruction(); -static void ExecuteAVX512ERInstruction(); -static void ExecuteAVX512CDInstruction(); -static void ExecuteAVX512BWInstruction(); -static void ExecuteAVX512VLInstruction(); -static void ExecuteAVX512VBMIInstruction(); -static void ExecutePREFETCHWT1Instruction(); -static void ExecuteSHAInstruction(); -static void ExecuteADXInstruction(); -static void ExecuteRDRANDInstruction(); -static void ExecuteRDSEEDInstruction(); -static void ExecutePCOMMITInstruction(); -static void ExecuteCLFLUSHOPTInstruction(); -static void ExecuteCLWBInstruction(); - +static void ExecuteAESInstruction(); +static void ExecuteAVXInstruction(); +static void ExecuteAVX2Instruction(); +static void ExecuteAVX512FInstruction(); +static void ExecuteAVX512DQInstruction(); +static void ExecuteAVX512IFMAInstruction(); +static void ExecuteAVX512PFInstruction(); +static void ExecuteAVX512ERInstruction(); +static void ExecuteAVX512CDInstruction(); +static void ExecuteAVX512BWInstruction(); +static void ExecuteAVX512VLInstruction(); +static void ExecuteAVX512VBMIInstruction(); +static void ExecutePREFETCHWT1Instruction(); +static void ExecuteSHAInstruction(); +static void ExecuteADXInstruction(); +static void ExecuteRDRANDInstruction(); +static void ExecuteRDSEEDInstruction(); +static void ExecutePCOMMITInstruction(); +static void ExecuteCLFLUSHOPTInstruction(); +static void ExecuteCLWBInstruction(); + static void ExecuteFMAInstruction() { } @@ -58,82 +58,82 @@ static void ExecuteXSAVEInstruction() { static void ExecuteOSXSAVEInstruction() { } -Y_UNIT_TEST_SUITE(TestCpuId) { -#define DECLARE_TEST_HAVE_INSTRUCTION(name) \ +Y_UNIT_TEST_SUITE(TestCpuId) { +#define DECLARE_TEST_HAVE_INSTRUCTION(name) \ Y_UNIT_TEST(Test##Have##name) { \ - if (NX86::Have##name()) { \ - Execute##name##Instruction(); \ - } \ + if (NX86::Have##name()) { \ + Execute##name##Instruction(); \ + } \ } Y_CPU_ID_ENUMERATE(DECLARE_TEST_HAVE_INSTRUCTION) -#undef DECLARE_TEST_HAVE_INSTRUCTION - - Y_UNIT_TEST(TestSSE2) { +#undef DECLARE_TEST_HAVE_INSTRUCTION + + Y_UNIT_TEST(TestSSE2) { #if defined(_x86_64_) UNIT_ASSERT(NX86::HaveSSE2()); #endif } - Y_UNIT_TEST(TestCpuBrand) { + Y_UNIT_TEST(TestCpuBrand) { ui32 store[12]; //Cout << CpuBrand(store) << Endl;; UNIT_ASSERT(strlen(CpuBrand(store)) > 0); } - - Y_UNIT_TEST(TestCachedAndNoncached) { + + Y_UNIT_TEST(TestCachedAndNoncached) { #define Y_DEF_NAME(X) UNIT_ASSERT_VALUES_EQUAL(NX86::Have##X(), NX86::CachedHave##X()); Y_CPU_ID_ENUMERATE(Y_DEF_NAME) #undef Y_DEF_NAME - } + } } - -#if defined(_x86_64_) + +#if defined(_x86_64_) #if defined(__GNUC__) -void ExecuteSSEInstruction() { +void ExecuteSSEInstruction() { __asm__ __volatile__("xorps %%xmm0, %%xmm0\n" : : : "xmm0"); -} - -void ExecuteSSE2Instruction() { +} + +void ExecuteSSE2Instruction() { __asm__ __volatile__("psrldq $0, %%xmm0\n" : : : "xmm0"); -} - -void ExecuteSSE3Instruction() { +} + +void ExecuteSSE3Instruction() { __asm__ __volatile__("addsubpd %%xmm0, %%xmm0\n" : : : "xmm0"); -} - -void ExecuteSSSE3Instruction() { +} + +void ExecuteSSSE3Instruction() { __asm__ __volatile__("psignb %%xmm0, %%xmm0\n" : : : "xmm0"); -} - -void ExecuteSSE41Instruction() { +} + +void ExecuteSSE41Instruction() { __asm__ __volatile__("pmuldq %%xmm0, %%xmm0\n" : : : "xmm0"); -} - -void ExecuteSSE42Instruction() { +} + +void ExecuteSSE42Instruction() { __asm__ __volatile__("crc32 %%eax, %%eax\n" : : : "eax"); -} - +} + void ExecuteF16CInstruction() { __asm__ __volatile__("vcvtph2ps %%xmm0, %%ymm0\n" : @@ -141,34 +141,34 @@ void ExecuteF16CInstruction() { : "xmm0"); } -void ExecuteAVXInstruction() { +void ExecuteAVXInstruction() { __asm__ __volatile__("vzeroupper\n" : : : "xmm0"); -} - -void ExecuteAVX2Instruction() { +} + +void ExecuteAVX2Instruction() { __asm__ __volatile__("vpunpcklbw %%ymm0, %%ymm0, %%ymm0\n" : : : "xmm0"); -} - -void ExecutePOPCNTInstruction() { +} + +void ExecutePOPCNTInstruction() { __asm__ __volatile__("popcnt %%eax, %%eax\n" : : : "eax"); -} - -void ExecuteBMI1Instruction() { +} + +void ExecuteBMI1Instruction() { __asm__ __volatile__("tzcnt %%eax, %%eax\n" : : : "eax"); -} - +} + void ExecuteBMI2Instruction() { __asm__ __volatile__("pdep %%rax, %%rdi, %%rax\n" : @@ -183,268 +183,268 @@ void ExecutePCLMULInstruction() { : "xmm0"); } -void ExecuteAESInstruction() { +void ExecuteAESInstruction() { __asm__ __volatile__("aesimc %%xmm0, %%xmm0\n" : : : "xmm0"); -} - -void ExecuteAVX512FInstruction() { -} - -void ExecuteAVX512DQInstruction() { -} - -void ExecuteAVX512IFMAInstruction() { -} - -void ExecuteAVX512PFInstruction() { -} - -void ExecuteAVX512ERInstruction() { -} - -void ExecuteAVX512CDInstruction() { -} - -void ExecuteAVX512BWInstruction() { -} - -void ExecuteAVX512VLInstruction() { -} - -void ExecuteAVX512VBMIInstruction() { -} - -void ExecutePREFETCHWT1Instruction() { -} - -void ExecuteSHAInstruction() { +} + +void ExecuteAVX512FInstruction() { +} + +void ExecuteAVX512DQInstruction() { +} + +void ExecuteAVX512IFMAInstruction() { +} + +void ExecuteAVX512PFInstruction() { +} + +void ExecuteAVX512ERInstruction() { +} + +void ExecuteAVX512CDInstruction() { +} + +void ExecuteAVX512BWInstruction() { +} + +void ExecuteAVX512VLInstruction() { +} + +void ExecuteAVX512VBMIInstruction() { +} + +void ExecutePREFETCHWT1Instruction() { +} + +void ExecuteSHAInstruction() { __asm__ __volatile__("sha1msg1 %%xmm0, %%xmm0\n" : : : "xmm0"); -} - -void ExecuteADXInstruction() { +} + +void ExecuteADXInstruction() { __asm__ __volatile__("adcx %%eax, %%eax\n" : : : "eax"); -} - -void ExecuteRDRANDInstruction() { +} + +void ExecuteRDRANDInstruction() { __asm__ __volatile__("rdrand %%eax" : : : "eax"); -} - -void ExecuteRDSEEDInstruction() { +} + +void ExecuteRDSEEDInstruction() { __asm__ __volatile__("rdseed %%eax" : : : "eax"); -} - -void ExecutePCOMMITInstruction() { -} - -void ExecuteCLFLUSHOPTInstruction() { -} - -void ExecuteCLWBInstruction() { -} - +} + +void ExecutePCOMMITInstruction() { +} + +void ExecuteCLFLUSHOPTInstruction() { +} + +void ExecuteCLWBInstruction() { +} + #elif defined(_MSC_VER) -void ExecuteSSEInstruction() { -} - -void ExecuteSSE2Instruction() { -} - -void ExecuteSSE3Instruction() { -} - -void ExecuteSSSE3Instruction() { -} - -void ExecuteSSE41Instruction() { -} - -void ExecuteSSE42Instruction() { -} - +void ExecuteSSEInstruction() { +} + +void ExecuteSSE2Instruction() { +} + +void ExecuteSSE3Instruction() { +} + +void ExecuteSSSE3Instruction() { +} + +void ExecuteSSE41Instruction() { +} + +void ExecuteSSE42Instruction() { +} + void ExecuteF16CInstruction() { } -void ExecuteAVXInstruction() { -} - -void ExecuteAVX2Instruction() { -} - -void ExecutePOPCNTInstruction() { -} - -void ExecuteBMI1Instruction() { -} - +void ExecuteAVXInstruction() { +} + +void ExecuteAVX2Instruction() { +} + +void ExecutePOPCNTInstruction() { +} + +void ExecuteBMI1Instruction() { +} + void ExecuteBMI2Instruction() { } void ExecutePCLMULInstruction() { } -void ExecuteAESInstruction() { -} - -void ExecuteAVX512FInstruction() { -} - -void ExecuteAVX512DQInstruction() { -} - -void ExecuteAVX512IFMAInstruction() { -} - -void ExecuteAVX512PFInstruction() { -} - -void ExecuteAVX512ERInstruction() { -} - -void ExecuteAVX512CDInstruction() { -} - -void ExecuteAVX512BWInstruction() { -} - -void ExecuteAVX512VLInstruction() { -} - -void ExecuteAVX512VBMIInstruction() { -} - -void ExecutePREFETCHWT1Instruction() { -} - -void ExecuteSHAInstruction() { -} - -void ExecuteADXInstruction() { -} - -void ExecuteRDRANDInstruction() { -} - -void ExecuteRDSEEDInstruction() { -} - -void ExecutePCOMMITInstruction() { -} - -void ExecuteCLFLUSHOPTInstruction() { -} - -void ExecuteCLWBInstruction() { -} - +void ExecuteAESInstruction() { +} + +void ExecuteAVX512FInstruction() { +} + +void ExecuteAVX512DQInstruction() { +} + +void ExecuteAVX512IFMAInstruction() { +} + +void ExecuteAVX512PFInstruction() { +} + +void ExecuteAVX512ERInstruction() { +} + +void ExecuteAVX512CDInstruction() { +} + +void ExecuteAVX512BWInstruction() { +} + +void ExecuteAVX512VLInstruction() { +} + +void ExecuteAVX512VBMIInstruction() { +} + +void ExecutePREFETCHWT1Instruction() { +} + +void ExecuteSHAInstruction() { +} + +void ExecuteADXInstruction() { +} + +void ExecuteRDRANDInstruction() { +} + +void ExecuteRDSEEDInstruction() { +} + +void ExecutePCOMMITInstruction() { +} + +void ExecuteCLFLUSHOPTInstruction() { +} + +void ExecuteCLWBInstruction() { +} + #else #error "unknown compiler" #endif -#else -void ExecuteSSEInstruction() { -} - -void ExecuteSSE2Instruction() { -} - -void ExecuteSSE3Instruction() { -} - -void ExecuteSSSE3Instruction() { -} - -void ExecuteSSE41Instruction() { -} - -void ExecuteSSE42Instruction() { -} - +#else +void ExecuteSSEInstruction() { +} + +void ExecuteSSE2Instruction() { +} + +void ExecuteSSE3Instruction() { +} + +void ExecuteSSSE3Instruction() { +} + +void ExecuteSSE41Instruction() { +} + +void ExecuteSSE42Instruction() { +} + void ExecuteF16CInstruction() { } -void ExecuteAVXInstruction() { -} - -void ExecuteAVX2Instruction() { -} - -void ExecutePOPCNTInstruction() { -} - -void ExecuteBMI1Instruction() { -} - +void ExecuteAVXInstruction() { +} + +void ExecuteAVX2Instruction() { +} + +void ExecutePOPCNTInstruction() { +} + +void ExecuteBMI1Instruction() { +} + void ExecuteBMI2Instruction() { } void ExecutePCLMULInstruction() { } -void ExecuteAESInstruction() { -} - -void ExecuteAVX512FInstruction() { -} - -void ExecuteAVX512DQInstruction() { -} - -void ExecuteAVX512IFMAInstruction() { -} - -void ExecuteAVX512PFInstruction() { -} - -void ExecuteAVX512ERInstruction() { -} - -void ExecuteAVX512CDInstruction() { -} - -void ExecuteAVX512BWInstruction() { -} - -void ExecuteAVX512VLInstruction() { -} - -void ExecuteAVX512VBMIInstruction() { -} - -void ExecutePREFETCHWT1Instruction() { -} - -void ExecuteSHAInstruction() { -} - -void ExecuteADXInstruction() { -} - -void ExecuteRDRANDInstruction() { -} - -void ExecuteRDSEEDInstruction() { -} - -void ExecutePCOMMITInstruction() { -} - -void ExecuteCLFLUSHOPTInstruction() { -} - -void ExecuteCLWBInstruction() { -} -#endif +void ExecuteAESInstruction() { +} + +void ExecuteAVX512FInstruction() { +} + +void ExecuteAVX512DQInstruction() { +} + +void ExecuteAVX512IFMAInstruction() { +} + +void ExecuteAVX512PFInstruction() { +} + +void ExecuteAVX512ERInstruction() { +} + +void ExecuteAVX512CDInstruction() { +} + +void ExecuteAVX512BWInstruction() { +} + +void ExecuteAVX512VLInstruction() { +} + +void ExecuteAVX512VBMIInstruction() { +} + +void ExecutePREFETCHWT1Instruction() { +} + +void ExecuteSHAInstruction() { +} + +void ExecuteADXInstruction() { +} + +void ExecuteRDRANDInstruction() { +} + +void ExecuteRDSEEDInstruction() { +} + +void ExecutePCOMMITInstruction() { +} + +void ExecuteCLFLUSHOPTInstruction() { +} + +void ExecuteCLWBInstruction() { +} +#endif diff --git a/util/system/datetime.cpp b/util/system/datetime.cpp index b07b50679a6..5bb9716fbbb 100644 --- a/util/system/datetime.cpp +++ b/util/system/datetime.cpp @@ -17,12 +17,12 @@ #define Y_HAS_CLOCK_GETTIME #endif -static ui64 ToMicroSeconds(const struct timeval& tv) { +static ui64 ToMicroSeconds(const struct timeval& tv) { return (ui64)tv.tv_sec * 1000000 + (ui64)tv.tv_usec; } #if defined(_win_) -static ui64 ToMicroSeconds(const FILETIME& ft) { +static ui64 ToMicroSeconds(const FILETIME& ft) { return (((ui64)ft.dwHighDateTime << 32) + (ui64)ft.dwLowDateTime) / (ui64)10; } #elif defined(Y_HAS_CLOCK_GETTIME) @@ -31,9 +31,9 @@ static ui64 ToMicroSeconds(const struct timespec& ts) { } #endif -ui64 MicroSeconds() noexcept { +ui64 MicroSeconds() noexcept { struct timeval tv; - gettimeofday(&tv, nullptr); + gettimeofday(&tv, nullptr); return ToMicroSeconds(tv); } @@ -48,7 +48,7 @@ ui64 ThreadCPUUserTime() noexcept { #endif } -ui64 ThreadCPUSystemTime() noexcept { +ui64 ThreadCPUSystemTime() noexcept { #if defined(_win_) FILETIME creationTime, exitTime, kernelTime, userTime; GetThreadTimes(GetCurrentThread(), &creationTime, &exitTime, &kernelTime, &userTime); @@ -58,7 +58,7 @@ ui64 ThreadCPUSystemTime() noexcept { #endif } -ui64 ThreadCPUTime() noexcept { +ui64 ThreadCPUTime() noexcept { #if defined(_win_) FILETIME creationTime, exitTime, kernelTime, userTime; GetThreadTimes(GetCurrentThread(), &creationTime, &exitTime, &kernelTime, &userTime); @@ -72,13 +72,13 @@ ui64 ThreadCPUTime() noexcept { #endif } -ui32 Seconds() noexcept { +ui32 Seconds() noexcept { struct timeval tv; - gettimeofday(&tv, nullptr); + gettimeofday(&tv, nullptr); return tv.tv_sec; } -void NanoSleep(ui64 ns) noexcept { +void NanoSleep(ui64 ns) noexcept { #if defined(_win_) Sleep(ns / 1000000); #else @@ -88,7 +88,7 @@ void NanoSleep(ui64 ns) noexcept { req.tv_nsec = ns % NS; struct timespec left; while (nanosleep(&req, &left) < 0) { - Y_ASSERT(errno == EINTR); + Y_ASSERT(errno == EINTR); req = left; } #endif diff --git a/util/system/datetime.h b/util/system/datetime.h index aa009974e09..21f127d1d5a 100644 --- a/util/system/datetime.h +++ b/util/system/datetime.h @@ -16,7 +16,7 @@ /// for handy datetime utilities include util/datetime/base.h /// Current time in microseconds since epoch -ui64 MicroSeconds() noexcept; +ui64 MicroSeconds() noexcept; /// Current time in milliseconds since epoch inline ui64 MilliSeconds() { return MicroSeconds() / ui64(1000); @@ -26,13 +26,13 @@ inline ui64 millisec() { return MilliSeconds(); } /// Current time in seconds since epoch -ui32 Seconds() noexcept; +ui32 Seconds() noexcept; ///Current thread time in microseconds -ui64 ThreadCPUUserTime() noexcept; -ui64 ThreadCPUSystemTime() noexcept; -ui64 ThreadCPUTime() noexcept; +ui64 ThreadCPUUserTime() noexcept; +ui64 ThreadCPUSystemTime() noexcept; +ui64 ThreadCPUTime() noexcept; -void NanoSleep(ui64 ns) noexcept; +void NanoSleep(ui64 ns) noexcept; // GetCycleCount guarantees to return synchronous values on different cores // and provide constant rate only on modern Intel and AMD processors @@ -41,7 +41,7 @@ void NanoSleep(ui64 ns) noexcept; // with preceding instructions // PERFORMANCE: rdtsc - 15 cycles per call , rdtscp - 19 cycles per call // WARNING: following instruction can be executed out-of-order -Y_FORCE_INLINE ui64 GetCycleCount() noexcept { +Y_FORCE_INLINE ui64 GetCycleCount() noexcept { #if defined(_MSC_VER) // Generates the rdtscp instruction, which returns the processor time stamp. // The processor time stamp records the number of clock cycles since the last reset. diff --git a/util/system/defaults.h b/util/system/defaults.h index dcd7abea38e..b2b5756b345 100644 --- a/util/system/defaults.h +++ b/util/system/defaults.h @@ -74,7 +74,7 @@ #endif #include "compiler.h" - + #ifdef _win_ #include <malloc.h> #elif defined(_sun_) @@ -93,33 +93,33 @@ constexpr bool Y_IS_DEBUG_BUILD = true; #endif #endif -/** - * @def Y_ARRAY_SIZE - * - * This macro is needed to get number of elements in a statically allocated fixed size array. The - * expression is a compile-time constant and therefore can be used in compile time computations. - * - * @code - * enum ENumbers { - * EN_ONE, - * EN_TWO, - * EN_SIZE - * } - * - * const char* NAMES[] = { - * "one", - * "two" - * } - * - * static_assert(Y_ARRAY_SIZE(NAMES) == EN_SIZE, "you should define `NAME` for each enumeration"); - * @endcode - * - * This macro also catches type errors. If you see a compiler error like "warning: division by zero - * is undefined" when using `Y_ARRAY_SIZE` then you are probably giving it a pointer. - * - * Since all of our code is expected to work on a 64 bit platform where pointers are 8 bytes we may - * falsefully accept pointers to types of sizes that are divisors of 8 (1, 2, 4 and 8). - */ +/** + * @def Y_ARRAY_SIZE + * + * This macro is needed to get number of elements in a statically allocated fixed size array. The + * expression is a compile-time constant and therefore can be used in compile time computations. + * + * @code + * enum ENumbers { + * EN_ONE, + * EN_TWO, + * EN_SIZE + * } + * + * const char* NAMES[] = { + * "one", + * "two" + * } + * + * static_assert(Y_ARRAY_SIZE(NAMES) == EN_SIZE, "you should define `NAME` for each enumeration"); + * @endcode + * + * This macro also catches type errors. If you see a compiler error like "warning: division by zero + * is undefined" when using `Y_ARRAY_SIZE` then you are probably giving it a pointer. + * + * Since all of our code is expected to work on a 64 bit platform where pointers are 8 bytes we may + * falsefully accept pointers to types of sizes that are divisors of 8 (1, 2, 4 and 8). + */ #if defined(__cplusplus) #include <util/generic/array_size.h> #else @@ -128,11 +128,11 @@ constexpr bool Y_IS_DEBUG_BUILD = true; ((sizeof(arr) / sizeof((arr)[0])) / static_cast<size_t>(!(sizeof(arr) % sizeof((arr)[0])))) #endif -#undef Y_ARRAY_BEGIN -#define Y_ARRAY_BEGIN(arr) (arr) +#undef Y_ARRAY_BEGIN +#define Y_ARRAY_BEGIN(arr) (arr) -#undef Y_ARRAY_END -#define Y_ARRAY_END(arr) ((arr) + Y_ARRAY_SIZE(arr)) +#undef Y_ARRAY_END +#define Y_ARRAY_END(arr) ((arr) + Y_ARRAY_SIZE(arr)) /** * Concatenates two symbols, even if one of them is itself a macro. @@ -148,7 +148,7 @@ constexpr bool Y_IS_DEBUG_BUILD = true; #define Y_GENERATE_UNIQUE_ID(N) Y_CAT(N, __COUNTER__) #endif -#if !defined(Y_GENERATE_UNIQUE_ID) +#if !defined(Y_GENERATE_UNIQUE_ID) #define Y_GENERATE_UNIQUE_ID(N) Y_CAT(N, __LINE__) #endif diff --git a/util/system/direct_io.cpp b/util/system/direct_io.cpp index f59c54b0cbd..73a55007a0a 100644 --- a/util/system/direct_io.cpp +++ b/util/system/direct_io.cpp @@ -19,7 +19,7 @@ namespace { #ifdef _linux_ utsname sysInfo; - Y_VERIFY(!uname(&sysInfo), "Error while call uname: %s", LastSystemErrorText()); + Y_VERIFY(!uname(&sysInfo), "Error while call uname: %s", LastSystemErrorText()); TStringBuf release(sysInfo.release); release = release.substr(0, release.find_first_not_of(".0123456789")); diff --git a/util/system/direct_io_ut.cpp b/util/system/direct_io_ut.cpp index 839c3de7ca4..96e2de66379 100644 --- a/util/system/direct_io_ut.cpp +++ b/util/system/direct_io_ut.cpp @@ -9,8 +9,8 @@ static const char* FileName_("./test.file"); -Y_UNIT_TEST_SUITE(TDirectIoTestSuite) { - Y_UNIT_TEST(TestDirectFile) { +Y_UNIT_TEST_SUITE(TDirectIoTestSuite) { + Y_UNIT_TEST(TestDirectFile) { TDirectIOBufferedFile file(FileName_, RdWr | Direct | Seq | CreateAlways, 1 << 15); TVector<ui64> data((1 << 15) + 1); TVector<ui64> readResult(data.size()); diff --git a/util/system/dynlib.cpp b/util/system/dynlib.cpp index 9d2541c25f1..3ce77e5540e 100644 --- a/util/system/dynlib.cpp +++ b/util/system/dynlib.cpp @@ -33,7 +33,7 @@ inline TString DLLERR() { #ifdef _win32_ char* msg = 0; DWORD cnt = FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, - nullptr, GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (char*)&msg, 0, nullptr); + nullptr, GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (char*)&msg, 0, nullptr); if (!msg) return "DLLERR() unknown error"; while (cnt && isspace(msg[cnt - 1])) @@ -80,7 +80,7 @@ public: inline void* Sym(const char* name) { void* symbol = SymOptional(name); - if (symbol == nullptr) { + if (symbol == nullptr) { ythrow yexception() << DLLERR().data(); } @@ -115,7 +115,7 @@ void TDynamicLibrary::Close() noexcept { void* TDynamicLibrary::SymOptional(const char* name) noexcept { if (!IsLoaded()) { - return nullptr; + return nullptr; } return Impl_->SymOptional(name); diff --git a/util/system/dynlib.h b/util/system/dynlib.h index 66eaf4a5c1c..13ce0bf4b5f 100644 --- a/util/system/dynlib.h +++ b/util/system/dynlib.h @@ -5,8 +5,8 @@ #include <util/generic/ptr.h> #include <util/generic/string.h> -#define Y_GET_FUNC(dll, name) FUNC_##name((dll).Sym(#name)) -#define Y_GET_FUNC_OPTIONAL(dll, name) FUNC_##name((dll).SymOptional(#name)) +#define Y_GET_FUNC(dll, name) FUNC_##name((dll).Sym(#name)) +#define Y_GET_FUNC_OPTIONAL(dll, name) FUNC_##name((dll).SymOptional(#name)) #ifdef _win32_ #define DEFAULT_DLLOPEN_FLAGS 0 diff --git a/util/system/env.cpp b/util/system/env.cpp index ead9b566a5f..97cdd2cb31e 100644 --- a/util/system/env.cpp +++ b/util/system/env.cpp @@ -11,16 +11,16 @@ #include <cstdlib> #endif -/** +/** * On Windows there may be many copies of enviroment variables, there at least two known, one is * manipulated by Win32 API, another by C runtime, so we must be consistent in the choice of - * functions used to manipulate them. - * - * Relevant links: - * - http://bugs.python.org/issue16633 + * functions used to manipulate them. + * + * Relevant links: + * - http://bugs.python.org/issue16633 * - https://a.yandex-team.ru/review/108892/details - */ - + */ + TString GetEnv(const TString& key, const TString& def) { #ifdef _win_ size_t len = GetEnvironmentVariableA(key.data(), nullptr, 0); diff --git a/util/system/env.h b/util/system/env.h index e2ccdd1e954..7f4c3cc70f3 100644 --- a/util/system/env.h +++ b/util/system/env.h @@ -2,31 +2,31 @@ #include <util/generic/string.h> -/** - * Search the environment list provided by the host environment for associated variable. - * +/** + * Search the environment list provided by the host environment for associated variable. + * * @param key String identifying the name of the environmental variable to look for * @param def String that returns if environmental variable not found by key - * - * @return String that is associated with the matched environment variable or empty string if - * such variable is missing. - * + * + * @return String that is associated with the matched environment variable or empty string if + * such variable is missing. + * * @note Use it only in pair with `SetEnv` as there may be inconsistency in their behaviour - * otherwise. - * @note Calls to `GetEnv` and `SetEnv` from different threads must be synchronized. - * @see SetEnv - */ + * otherwise. + * @note Calls to `GetEnv` and `SetEnv` from different threads must be synchronized. + * @see SetEnv + */ TString GetEnv(const TString& key, const TString& def = TString()); - -/** - * Add or change environment variable provided by the host environment. - * - * @key String identifying the name of the environment variable to set or change - * @value Value to assign - + +/** + * Add or change environment variable provided by the host environment. + * + * @key String identifying the name of the environment variable to set or change + * @value Value to assign + * @note Use it only in pair with `GetEnv` as there may be inconsistency in their behaviour - * otherwise. - * @note Calls to `GetEnv` and `SetEnv` from different threads must be synchronized. - * @see GetEnv - */ + * otherwise. + * @note Calls to `GetEnv` and `SetEnv` from different threads must be synchronized. + * @see GetEnv + */ void SetEnv(const TString& key, const TString& value); diff --git a/util/system/env_ut.cpp b/util/system/env_ut.cpp index e03cc016589..865acf8e125 100644 --- a/util/system/env_ut.cpp +++ b/util/system/env_ut.cpp @@ -3,19 +3,19 @@ #include <util/generic/string.h> #include "env.h" -Y_UNIT_TEST_SUITE(EnvTest) { - Y_UNIT_TEST(GetSetEnvTest) { +Y_UNIT_TEST_SUITE(EnvTest) { + Y_UNIT_TEST(GetSetEnvTest) { TString key = "util_GETENV_TestVar"; TString value = "Some value for env var"; TString def = "Some default value for env var"; - // first of all, it should be clear + // first of all, it should be clear UNIT_ASSERT_VALUES_EQUAL(GetEnv(key), TString()); UNIT_ASSERT_VALUES_EQUAL(GetEnv(key, def), def); - SetEnv(key, value); - // set and see what value we get here - UNIT_ASSERT_VALUES_EQUAL(GetEnv(key), value); + SetEnv(key, value); + // set and see what value we get here + UNIT_ASSERT_VALUES_EQUAL(GetEnv(key), value); UNIT_ASSERT_VALUES_EQUAL(GetEnv(key, def), value); - // set empty value + // set empty value SetEnv(key, TString()); UNIT_ASSERT_VALUES_EQUAL(GetEnv(key), TString()); @@ -27,5 +27,5 @@ Y_UNIT_TEST_SUITE(EnvTest) { UNIT_ASSERT_VALUES_EQUAL(GetEnv(longKey), longValue); SetEnv(longKey, TString()); UNIT_ASSERT_VALUES_EQUAL(GetEnv(longKey), TString()); - } + } } diff --git a/util/system/error.cpp b/util/system/error.cpp index f778ec42cbe..b3be00e7fe0 100644 --- a/util/system/error.cpp +++ b/util/system/error.cpp @@ -1,7 +1,7 @@ #include "tls.h" #include "error.h" -#include <util/string/strip.h> +#include <util/string/strip.h> #include <util/generic/strfcpy.h> #include <cerrno> diff --git a/util/system/event.cpp b/util/system/event.cpp index 79b3cdb2917..36ba4b7bcd1 100644 --- a/util/system/event.cpp +++ b/util/system/event.cpp @@ -16,7 +16,7 @@ class TSystemEvent::TEvImpl: public TAtomicRefCount<TSystemEvent::TEvImpl> { public: #ifdef _win_ inline TEvImpl(ResetMode rmode) { - cond = CreateEvent(nullptr, rmode == rManual ? true : false, false, nullptr); + cond = CreateEvent(nullptr, rmode == rManual ? true : false, false, nullptr); } inline ~TEvImpl() { diff --git a/util/system/event_ut.cpp b/util/system/event_ut.cpp index 2506cb7a913..650ba4641ae 100644 --- a/util/system/event_ut.cpp +++ b/util/system/event_ut.cpp @@ -82,8 +82,8 @@ namespace { } -Y_UNIT_TEST_SUITE(EventTest) { - Y_UNIT_TEST(WaitAndSignalTest) { +Y_UNIT_TEST_SUITE(EventTest) { + Y_UNIT_TEST(WaitAndSignalTest) { TSharedData data; TThreadPool queue; queue.Start(5); @@ -95,7 +95,7 @@ Y_UNIT_TEST_SUITE(EventTest) { UNIT_ASSERT(!data.failed); } - Y_UNIT_TEST(ConcurrentSignalAndWaitTest) { + Y_UNIT_TEST(ConcurrentSignalAndWaitTest) { // test for problem detected by thread-sanitizer (signal/wait race) SEARCH-2113 const size_t limit = 200; TManualEvent event[limit]; @@ -113,7 +113,7 @@ Y_UNIT_TEST_SUITE(EventTest) { } /** Test for a problem: http://nga.at.yandex-team.ru/5772 */ - Y_UNIT_TEST(DestructorBeforeSignalFinishTest) { + Y_UNIT_TEST(DestructorBeforeSignalFinishTest) { return; TVector<THolder<IObjectInQueue>> tasks; for (size_t i = 0; i < 1000; ++i) { diff --git a/util/system/execpath.cpp b/util/system/execpath.cpp index 33198af58b0..10f08cea3e1 100644 --- a/util/system/execpath.cpp +++ b/util/system/execpath.cpp @@ -39,7 +39,7 @@ static inline bool GoodPath(const TString& path) { static inline int FreeBSDSysCtl(int* mib, size_t mibSize, TTempBuf& res) { for (size_t i = 0; i < 2; ++i) { size_t cb = res.Size(); - if (sysctl(mib, mibSize, res.Data(), &cb, nullptr, 0) == 0) { + if (sysctl(mib, mibSize, res.Data(), &cb, nullptr, 0) == 0) { res.Proceed(cb); return 0; } else if (errno == ENOMEM) { @@ -54,7 +54,7 @@ static inline int FreeBSDSysCtl(int* mib, size_t mibSize, TTempBuf& res) { static inline TString FreeBSDGetExecPath() { int mib[] = {CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1}; TTempBuf buf; - int r = FreeBSDSysCtl(mib, Y_ARRAY_SIZE(mib), buf); + int r = FreeBSDSysCtl(mib, Y_ARRAY_SIZE(mib), buf); if (r == 0) { return TString(buf.Data(), buf.Filled() - 1); } else if (r == ENOTSUP) { // older FreeBSD version @@ -73,7 +73,7 @@ static inline TString FreeBSDGetExecPath() { static inline TString FreeBSDGetArgv0() { int mib[] = {CTL_KERN, KERN_PROC, KERN_PROC_ARGS, getpid()}; TTempBuf buf; - int r = FreeBSDSysCtl(mib, Y_ARRAY_SIZE(mib), buf); + int r = FreeBSDSysCtl(mib, Y_ARRAY_SIZE(mib), buf); if (r == 0) { return TString(buf.Data()); } else if (r == ENOTSUP) { @@ -118,7 +118,7 @@ static TString GetExecPathImpl() { #elif defined(_win_) TTempBuf execNameBuf; for (;;) { - DWORD r = GetModuleFileName(nullptr, execNameBuf.Data(), execNameBuf.Size()); + DWORD r = GetModuleFileName(nullptr, execNameBuf.Data(), execNameBuf.Size()); if (r == execNameBuf.Size()) { execNameBuf = TTempBuf(execNameBuf.Size() * 2); } else if (r == 0) { diff --git a/util/system/execpath_ut.cpp b/util/system/execpath_ut.cpp index 16b01466f55..d1d23fcf721 100644 --- a/util/system/execpath_ut.cpp +++ b/util/system/execpath_ut.cpp @@ -5,8 +5,8 @@ #include "platform.h" #include <util/folder/dirut.h> -Y_UNIT_TEST_SUITE(TExecPathTest) { - Y_UNIT_TEST(TestIt) { +Y_UNIT_TEST_SUITE(TExecPathTest) { + Y_UNIT_TEST(TestIt) { TString execPath = GetExecPath(); TString persistentExecPath = GetPersistentExecPath(); diff --git a/util/system/fasttime.cpp b/util/system/fasttime.cpp index 057a814f0a4..82f199e230b 100644 --- a/util/system/fasttime.cpp +++ b/util/system/fasttime.cpp @@ -31,7 +31,7 @@ namespace { using TFunc = int (*)(struct timeval*, struct timezone*); inline TSymbols() - : Func(nullptr) + : Func(nullptr) { // not DEFAULT, cause library/cpp/gettimeofday Func = reinterpret_cast<TFunc>(dlsym(RTLD_NEXT, "gettimeofday")); @@ -52,7 +52,7 @@ namespace { Zero(tv); - Func(&tv, nullptr); + Func(&tv, nullptr); return (((TTime)1000000) * (TTime)tv.tv_sec) + (TTime)tv.tv_usec; } @@ -64,7 +64,7 @@ namespace { "/lib/libc.so.6", }; - for (auto& lib : libs) { + for (auto& lib : libs) { try { return MakeHolder<TDynamicLibrary>(lib); } catch (...) { diff --git a/util/system/file.cpp b/util/system/file.cpp index 4a261d020cb..0ba1a890623 100644 --- a/util/system/file.cpp +++ b/util/system/file.cpp @@ -274,8 +274,8 @@ bool TFileHandle::Close() noexcept { isOk = (::CloseHandle(Fd_) != 0); } if (!isOk) { - Y_VERIFY(GetLastError() != ERROR_INVALID_HANDLE, - "must not quietly close invalid handle"); + Y_VERIFY(GetLastError() != ERROR_INVALID_HANDLE, + "must not quietly close invalid handle"); } #elif defined(_unix_) if (Fd_ != INVALID_FHANDLE) { @@ -285,7 +285,7 @@ bool TFileHandle::Close() noexcept { // Do not quietly close bad descriptor, // because often it means double close // that is disasterous - Y_VERIFY(errno != EBADF, "must not quietly close bad descriptor: fd=%d", int(Fd_)); + Y_VERIFY(errno != EBADF, "must not quietly close bad descriptor: fd=%d", int(Fd_)); } #else #error unsupported platform @@ -1288,15 +1288,15 @@ bool PosixDisableReadAhead(FHANDLE fileHandle, void* addr) noexcept { #if HAVE_POSIX_FADVISE #if defined(_linux_) - Y_UNUSED(fileHandle); + Y_UNUSED(fileHandle); ret = madvise(addr, 0, MADV_RANDOM); // according to klamm@ posix_fadvise does not work under linux, madvise does work #else - Y_UNUSED(addr); + Y_UNUSED(addr); ret = ::posix_fadvise(fileHandle, 0, 0, POSIX_FADV_RANDOM); #endif #else - Y_UNUSED(fileHandle); - Y_UNUSED(addr); + Y_UNUSED(fileHandle); + Y_UNUSED(addr); #endif return ret == 0; } diff --git a/util/system/file_ut.cpp b/util/system/file_ut.cpp index 941e6a50f3d..22a2f5c6254 100644 --- a/util/system/file_ut.cpp +++ b/util/system/file_ut.cpp @@ -113,7 +113,7 @@ public: const TString data = TUnbufferedFileInput(tmp.Name()).ReadAll(); UNIT_ASSERT_EQUAL(data.length(), 12); - UNIT_ASSERT(data.StartsWith("12345")); + UNIT_ASSERT(data.StartsWith("12345")); } }; @@ -202,7 +202,7 @@ void TFileTest::TestRW() { void TFileTest::TestLocale() { #ifdef _unix_ - const char* loc = setlocale(LC_CTYPE, nullptr); + const char* loc = setlocale(LC_CTYPE, nullptr); setlocale(LC_CTYPE, "ru_RU.UTF-8"); #endif TFile f("Имя.txt", CreateNew); @@ -405,8 +405,8 @@ UNIT_ASSERT_VALUES_EQUAL(file.CountCache(0, 12345), -1); #endif } -Y_UNIT_TEST_SUITE(TTestDecodeOpenMode) { - Y_UNIT_TEST(It) { +Y_UNIT_TEST_SUITE(TTestDecodeOpenMode) { + Y_UNIT_TEST(It) { UNIT_ASSERT_VALUES_EQUAL("0", DecodeOpenMode(0)); UNIT_ASSERT_VALUES_EQUAL("RdOnly", DecodeOpenMode(RdOnly)); UNIT_ASSERT_VALUES_EQUAL("RdWr", DecodeOpenMode(RdWr)); diff --git a/util/system/filemap.cpp b/util/system/filemap.cpp index 7454a4cb948..45733c74220 100644 --- a/util/system/filemap.cpp +++ b/util/system/filemap.cpp @@ -128,12 +128,12 @@ class TMemoryMap::TImpl: public TAtomicRefCount<TImpl> { public: inline void CreateMapping() { #if defined(_win_) - Mapping_ = nullptr; + Mapping_ = nullptr; if (Length_) { - Mapping_ = CreateFileMapping(File_.GetHandle(), nullptr, + Mapping_ = CreateFileMapping(File_.GetHandle(), nullptr, (Mode_ & oAccessMask) == TFileMap::oRdWr ? PAGE_READWRITE : PAGE_READONLY, - (DWORD)(Length_ >> 32), (DWORD)(Length_ & 0xFFFFFFFF), nullptr); - if (Mapping_ == nullptr) { + (DWORD)(Length_ >> 32), (DWORD)(Length_ & 0xFFFFFFFF), nullptr); + if (Mapping_ == nullptr) { ythrow yexception() << "Can't create file mapping of '" << DbgName_ << "': " << LastSystemErrorText(); } } else { @@ -147,7 +147,7 @@ public: ythrow yexception() << "Can't map " << (unsigned long)Length_ << " bytes of file '" << DbgName_ << "' at offset 0: " << LastSystemErrorText(); } } else { - PtrStart_ = nullptr; + PtrStart_ = nullptr; } #endif } @@ -209,7 +209,7 @@ public: inline bool IsOpen() const noexcept { return File_.IsOpen() #if defined(_win_) - && Mapping_ != nullptr + && Mapping_ != nullptr #endif ; } @@ -247,15 +247,15 @@ public: result.Ptr = mmap((caddr_t) nullptr, size, ModeToMmapProt(Mode_), ModeToMmapFlags(Mode_), File_.GetHandle(), base); if (result.Ptr == (char*)(-1)) { - result.Ptr = nullptr; + result.Ptr = nullptr; } #if defined(_unix_) } else { - result.Ptr = PtrStart_ ? static_cast<caddr_t>(PtrStart_) + base : nullptr; + result.Ptr = PtrStart_ ? static_cast<caddr_t>(PtrStart_) + base : nullptr; } #endif #endif - if (result.Ptr != nullptr || size == 0) { // allow map of size 0 + if (result.Ptr != nullptr || size == 0) { // allow map of size 0 result.Size = size; } else { ythrow yexception() << "Can't map " << (unsigned long)size << " bytes at offset " << offset << " of '" << DbgName_ << "': " << LastSystemErrorText(); @@ -308,7 +308,7 @@ public: #if defined(_win_) if (Mapping_) { ::CloseHandle(Mapping_); // != FALSE - Mapping_ = nullptr; + Mapping_ = nullptr; } #elif defined(_unix_) if (PtrStart_) { @@ -475,8 +475,8 @@ TFileMap::TFileMap(const TFileMap& fm) noexcept } void TFileMap::Flush(void* ptr, size_t size, bool sync) { - Y_ASSERT(ptr >= Ptr()); - Y_ASSERT(static_cast<char*>(ptr) + size <= static_cast<char*>(Ptr()) + MappedSize()); + Y_ASSERT(ptr >= Ptr()); + Y_ASSERT(static_cast<char*>(ptr) + size <= static_cast<char*>(Ptr()) + MappedSize()); if (!Region_.IsMapped()) { return; @@ -530,11 +530,11 @@ void TFileMap::Precharge(size_t pos, size_t size) const { } TMappedAllocation::TMappedAllocation(size_t size, bool shared, void* addr) - : Ptr_(nullptr) + : Ptr_(nullptr) , Size_(0) , Shared_(shared) #if defined(_win_) - , Mapping_(nullptr) + , Mapping_(nullptr) #endif { if (size != 0) { @@ -543,16 +543,16 @@ TMappedAllocation::TMappedAllocation(size_t size, bool shared, void* addr) } void* TMappedAllocation::Alloc(size_t size, void* addr) { - assert(Ptr_ == nullptr); + assert(Ptr_ == nullptr); #if defined(_win_) (void)addr; - Mapping_ = CreateFileMapping((HANDLE)-1, nullptr, PAGE_READWRITE, 0, size ? size : 1, nullptr); + Mapping_ = CreateFileMapping((HANDLE)-1, nullptr, PAGE_READWRITE, 0, size ? size : 1, nullptr); Ptr_ = MapViewOfFile(Mapping_, FILE_MAP_WRITE, 0, 0, size ? size : 1); #else Ptr_ = mmap(addr, size, PROT_READ | PROT_WRITE, (Shared_ ? MAP_SHARED : MAP_PRIVATE) | MAP_ANON, -1, 0); if (Ptr_ == (void*)MAP_FAILED) { - Ptr_ = nullptr; + Ptr_ = nullptr; } #endif if (Ptr_ != nullptr) { @@ -568,11 +568,11 @@ void TMappedAllocation::Dealloc() { #if defined(_win_) UnmapViewOfFile(Ptr_); CloseHandle(Mapping_); - Mapping_ = nullptr; + Mapping_ = nullptr; #else munmap((caddr_t)Ptr_, Size_); #endif - Ptr_ = nullptr; + Ptr_ = nullptr; Size_ = 0; } diff --git a/util/system/filemap.h b/util/system/filemap.h index 11be64bff47..262b5cd9766 100644 --- a/util/system/filemap.h +++ b/util/system/filemap.h @@ -26,15 +26,15 @@ struct TMemoryMapCommon { } inline void* MappedData() const noexcept { - return Ptr ? (void*)((char*)Ptr + Head) : nullptr; + return Ptr ? (void*)((char*)Ptr + Head) : nullptr; } inline bool IsMapped() const noexcept { - return Ptr != nullptr; + return Ptr != nullptr; } inline void Reset() noexcept { - Ptr = nullptr; + Ptr = nullptr; Size = 0; Head = 0; } @@ -195,14 +195,14 @@ private: public: TFileMappedArray() - : Ptr_(nullptr) - , End_(nullptr) + : Ptr_(nullptr) + , End_(nullptr) , Size_(0) { } ~TFileMappedArray() { - Ptr_ = nullptr; - End_ = nullptr; + Ptr_ = nullptr; + End_ = nullptr; } void Init(const char* name) { DataHolder_.Reset(new TFileMap(name)); @@ -214,15 +214,15 @@ public: } void Term() { DataHolder_.Destroy(); - Ptr_ = nullptr; + Ptr_ = nullptr; Size_ = 0; - End_ = nullptr; + End_ = nullptr; } void Precharge() { DataHolder_->Precharge(); } const T& operator[](size_t pos) const { - Y_ASSERT(pos < size()); + Y_ASSERT(pos < size()); return Ptr_[pos]; } /// for STL compatibility only, Size() usage is recommended @@ -289,7 +289,7 @@ private: class TMappedAllocation: TMoveOnly { public: - TMappedAllocation(size_t size = 0, bool shared = false, void* addr = nullptr); + TMappedAllocation(size_t size = 0, bool shared = false, void* addr = nullptr); ~TMappedAllocation() { Dealloc(); } @@ -300,13 +300,13 @@ public: this->swap(other); return *this; } - void* Alloc(size_t size, void* addr = nullptr); + void* Alloc(size_t size, void* addr = nullptr); void Dealloc(); void* Ptr() const { return Ptr_; } char* Data(ui32 pos = 0) const { - return (char*)(Ptr_ ? ((char*)Ptr_ + pos) : nullptr); + return (char*)(Ptr_ ? ((char*)Ptr_ + pos) : nullptr); } char* Begin() const noexcept { return (char*)Ptr(); @@ -341,11 +341,11 @@ public: Destroy(); } T* Create(size_t siz) { - Y_ASSERT(MappedSize() == 0 && Ptr() == nullptr); + Y_ASSERT(MappedSize() == 0 && Ptr() == nullptr); T* arr = (T*)Alloc((sizeof(T) * siz)); if (!arr) - return nullptr; - Y_ASSERT(MappedSize() == sizeof(T) * siz); + return nullptr; + Y_ASSERT(MappedSize() == sizeof(T) * siz); for (size_t n = 0; n < siz; n++) new (&arr[n]) T(); return arr; @@ -359,11 +359,11 @@ public: } } T& operator[](size_t pos) { - Y_ASSERT(pos < size()); + Y_ASSERT(pos < size()); return ((T*)Ptr())[pos]; } const T& operator[](size_t pos) const { - Y_ASSERT(pos < size()); + Y_ASSERT(pos < size()); return ((T*)Ptr())[pos]; } T* begin() { diff --git a/util/system/filemap_ut.cpp b/util/system/filemap_ut.cpp index 73f109dc880..a0ec2296815 100644 --- a/util/system/filemap_ut.cpp +++ b/util/system/filemap_ut.cpp @@ -11,7 +11,7 @@ #include <cstring> #include <cstdio> -Y_UNIT_TEST_SUITE(TFileMapTest) { +Y_UNIT_TEST_SUITE(TFileMapTest) { static const char* FileName_("./mappped_file"); void BasicTest(TMemoryMapCommon::EOpenMode mode) { @@ -59,7 +59,7 @@ Y_UNIT_TEST_SUITE(TFileMapTest) { BasicTest(TMemoryMapCommon::oRdWr | TMemoryMapCommon::oPopulate); } - Y_UNIT_TEST(TestFileRemap) { + Y_UNIT_TEST(TestFileRemap) { const char data1[] = "01234"; const char data2[] = "abcdefg"; const char data3[] = "COPY"; @@ -104,7 +104,7 @@ Y_UNIT_TEST_SUITE(TFileMapTest) { NFs::Remove(FileName_); } - Y_UNIT_TEST(TestFileMapDbgName) { + Y_UNIT_TEST(TestFileMapDbgName) { // This test checks that dbgName passed to the TFileMap constructor is saved inside the object and appears // in subsequent error messages. const char* const dbgName = "THIS_IS_A_TEST"; @@ -131,7 +131,7 @@ Y_UNIT_TEST_SUITE(TFileMapTest) { #elif defined(_cygwin_) //cygwin is not real unix :( #else - Y_UNIT_TEST(TestNotGreedy) { + Y_UNIT_TEST(TestNotGreedy) { unsigned page[4096 / sizeof(unsigned)]; #if defined(_unix_) @@ -211,7 +211,7 @@ Y_UNIT_TEST_SUITE(TFileMapTest) { } #endif - Y_UNIT_TEST(TestFileMappedArray) { + Y_UNIT_TEST(TestFileMappedArray) { { TFileMappedArray<ui32> mappedArray; ui32 data[] = {123, 456, 789, 10}; @@ -268,13 +268,13 @@ Y_UNIT_TEST_SUITE(TFileMapTest) { NFs::Remove(FileName_); } - Y_UNIT_TEST(TestMappedArray) { + Y_UNIT_TEST(TestMappedArray) { ui32 sz = 10; TMappedArray<ui32> mappedArray; ui32* ptr = mappedArray.Create(sz); - UNIT_ASSERT(ptr != nullptr); + UNIT_ASSERT(ptr != nullptr); UNIT_ASSERT(mappedArray.size() == sz); UNIT_ASSERT(mappedArray.begin() + sz == mappedArray.end()); @@ -290,12 +290,12 @@ Y_UNIT_TEST_SUITE(TFileMapTest) { UNIT_ASSERT(mappedArray.size() == 1000 && mappedArray2.size() == sz); } - Y_UNIT_TEST(TestMemoryMap) { + Y_UNIT_TEST(TestMemoryMap) { TFile file(FileName_, CreateAlways | WrOnly); file.Close(); FILE* f = fopen(FileName_, "rb"); - UNIT_ASSERT(f != nullptr); + UNIT_ASSERT(f != nullptr); try { TMemoryMap mappedMem(f); mappedMem.Map(mappedMem.Length() / 2, mappedMem.Length() + 100); // overflow @@ -318,7 +318,7 @@ Y_UNIT_TEST_SUITE(TFileMapTest) { NFs::Remove(FileName_); } - Y_UNIT_TEST(TestMemoryMapIsWritable) { + Y_UNIT_TEST(TestMemoryMapIsWritable) { TFile file(FileName_, CreateAlways | WrOnly); file.Close(); @@ -333,7 +333,7 @@ Y_UNIT_TEST_SUITE(TFileMapTest) { NFs::Remove(FileName_); } - Y_UNIT_TEST(TestFileMapIsWritable) { + Y_UNIT_TEST(TestFileMapIsWritable) { TFile file(FileName_, CreateAlways | WrOnly); file.Close(); { diff --git a/util/system/flock_ut.cpp b/util/system/flock_ut.cpp index b5f6cb53287..6a1caec83e6 100644 --- a/util/system/flock_ut.cpp +++ b/util/system/flock_ut.cpp @@ -5,15 +5,15 @@ #include <library/cpp/testing/unittest/registar.h> -Y_UNIT_TEST_SUITE(TFileLockTest) { - Y_UNIT_TEST(TestFlock) { +Y_UNIT_TEST_SUITE(TFileLockTest) { + Y_UNIT_TEST(TestFlock) { TTempFileHandle tmp("./file"); UNIT_ASSERT_EQUAL(Flock(tmp.GetHandle(), LOCK_EX), 0); UNIT_ASSERT_EQUAL(Flock(tmp.GetHandle(), LOCK_UN), 0); } - Y_UNIT_TEST(TestFileLocker) { + Y_UNIT_TEST(TestFileLocker) { TTempFileHandle tmp("./file.locker"); TFileLock fileLockExclusive1("./file.locker"); TFileLock fileLockExclusive2("./file.locker"); diff --git a/util/system/fs.cpp b/util/system/fs.cpp index d2611a8ccc4..c95e77e4df9 100644 --- a/util/system/fs.cpp +++ b/util/system/fs.cpp @@ -43,7 +43,7 @@ void NFs::RemoveRecursive(const TString& path) { switch (it->fts_info) { case FTS_DOT: case FTS_D: - break; + break; default: if (!NFs::Remove(it->fts_path)) { ythrow TSystemError() << errStr << it->fts_path << " with cwd (" << NFs::CurrentWorkingDirectory() << ")"; @@ -55,7 +55,7 @@ void NFs::RemoveRecursive(const TString& path) { bool NFs::MakeDirectory(const TString& path, EFilePermissions mode) { #if defined(_win_) - Y_UNUSED(mode); + Y_UNUSED(mode); return NFsPrivate::WinMakeDirectory(path); #else return mkdir(path.data(), mode) == 0; @@ -65,8 +65,8 @@ bool NFs::MakeDirectory(const TString& path, EFilePermissions mode) { bool NFs::MakeDirectoryRecursive(const TString& path, EFilePermissions mode, bool alwaysCreate) { if (NFs::Exists(path) && TFileStat(path).IsDir()) { if (alwaysCreate) { - ythrow TIoException() << "path " << path << " already exists" - << " with cwd (" << NFs::CurrentWorkingDirectory() << ")"; + ythrow TIoException() << "path " << path << " already exists" + << " with cwd (" << NFs::CurrentWorkingDirectory() << ")"; } return true; } else { diff --git a/util/system/fs.h b/util/system/fs.h index 237daf2d2d7..344adccc4cf 100644 --- a/util/system/fs.h +++ b/util/system/fs.h @@ -6,18 +6,18 @@ namespace NFs { enum EFilePermission { - FP_ALL_EXEC = 01, - FP_ALL_WRITE = 02, - FP_ALL_READ = 04, - FP_GROUP_READ = 040, - FP_GROUP_WRITE = 020, - FP_GROUP_EXEC = 010, - FP_OWNER_READ = 0400, - FP_OWNER_WRITE = 0200, - FP_OWNER_EXEC = 0100, - - FP_COMMON_FILE = 0777, - FP_SECRET_FILE = 0700, + FP_ALL_EXEC = 01, + FP_ALL_WRITE = 02, + FP_ALL_READ = 04, + FP_GROUP_READ = 040, + FP_GROUP_WRITE = 020, + FP_GROUP_EXEC = 010, + FP_OWNER_READ = 0400, + FP_OWNER_WRITE = 0200, + FP_OWNER_EXEC = 0100, + + FP_COMMON_FILE = 0777, + FP_SECRET_FILE = 0700, FP_NONSECRET_FILE = 0744, }; @@ -148,7 +148,7 @@ namespace NFs { /// @param[in] path Path to check /// @returns input argument inline const TString& EnsureExists(const TString& path) { - Y_ENSURE_EX(Exists(path), TFileError{} << "Path " << path << " does not exists (checked from cwd:" << NFs::CurrentWorkingDirectory() << ")"); + Y_ENSURE_EX(Exists(path), TFileError{} << "Path " << path << " does not exists (checked from cwd:" << NFs::CurrentWorkingDirectory() << ")"); return path; } } diff --git a/util/system/fs_ut.cpp b/util/system/fs_ut.cpp index de071ebf55b..02a0c8d9ae3 100644 --- a/util/system/fs_ut.cpp +++ b/util/system/fs_ut.cpp @@ -313,8 +313,8 @@ void TFsTest::TestEnsureExists() { TStringBuilder expected; TString got; try { - NFs::EnsureExists(nonExists); - expected << __LOCATION__; + NFs::EnsureExists(nonExists); + expected << __LOCATION__; } catch (const TFileError& err) { got = err.what(); } diff --git a/util/system/fs_win.cpp b/util/system/fs_win.cpp index a410ccac06d..04adf6b3c16 100644 --- a/util/system/fs_win.cpp +++ b/util/system/fs_win.cpp @@ -13,7 +13,7 @@ namespace NFsPrivate { wstr.resize(str.size()); size_t written = 0; if (!UTF8ToWide(str.data(), str.size(), wstr.begin(), written)) - return nullptr; + return nullptr; wstr.erase(written); static_assert(sizeof(WCHAR) == sizeof(wchar16), "expect sizeof(WCHAR) == sizeof(wchar16)"); return (const WCHAR*)wstr.data(); @@ -25,7 +25,7 @@ namespace NFsPrivate { return WideToUTF8((wchar16*)wstr, len); } - HANDLE CreateFileWithUtf8Name(const TStringBuf fName, ui32 accessMode, ui32 shareMode, ui32 createMode, ui32 attributes, bool inheritHandle) { + HANDLE CreateFileWithUtf8Name(const TStringBuf fName, ui32 accessMode, ui32 shareMode, ui32 createMode, ui32 attributes, bool inheritHandle) { TUtf16String wstr; LPCWSTR wname = UTF8ToWCHAR(fName, wstr); if (!wname) { @@ -34,9 +34,9 @@ namespace NFsPrivate { } SECURITY_ATTRIBUTES secAttrs; secAttrs.bInheritHandle = inheritHandle ? TRUE : FALSE; - secAttrs.lpSecurityDescriptor = nullptr; + secAttrs.lpSecurityDescriptor = nullptr; secAttrs.nLength = sizeof(secAttrs); - return ::CreateFileW(wname, accessMode, shareMode, &secAttrs, createMode, attributes, nullptr); + return ::CreateFileW(wname, accessMode, shareMode, &secAttrs, createMode, attributes, nullptr); } bool WinRename(const TString& oldPath, const TString& newPath) { @@ -110,7 +110,7 @@ namespace NFsPrivate { return false; } - return (CreateHardLinkW(npPtr, epPtr, nullptr) != 0); + return (CreateHardLinkW(npPtr, epPtr, nullptr) != 0); } bool WinExists(const TString& path) { @@ -186,7 +186,7 @@ namespace NFsPrivate { TTempBuf buf; while (true) { DWORD bytesReturned = 0; - BOOL res = DeviceIoControl(h, FSCTL_GET_REPARSE_POINT, nullptr, 0, buf.Data(), buf.Size(), &bytesReturned, nullptr); + BOOL res = DeviceIoControl(h, FSCTL_GET_REPARSE_POINT, nullptr, 0, buf.Data(), buf.Size(), &bytesReturned, nullptr); if (res) { REPARSE_DATA_BUFFER* rdb = (REPARSE_DATA_BUFFER*)buf.Data(); if (rdb->ReparseTag == IO_REPARSE_TAG_SYMLINK) { @@ -219,8 +219,8 @@ bool GetObjectId(const char* path, GUID* id) { if (h.IsOpen()) { FILE_OBJECTID_BUFFER fob; DWORD resSize = 0; - if (DeviceIoControl(h, FSCTL_CREATE_OR_GET_OBJECT_ID, nullptr, 0, &fob, sizeof(fob), &resSize, nullptr)) { - Y_ASSERT(resSize == sizeof(fob)); + if (DeviceIoControl(h, FSCTL_CREATE_OR_GET_OBJECT_ID, nullptr, 0, &fob, sizeof(fob), &resSize, nullptr)) { + Y_ASSERT(resSize == sizeof(fob)); memcpy(id, &fob.ObjectId, sizeof(GUID)); return true; } diff --git a/util/system/fs_win.h b/util/system/fs_win.h index 80861298284..a3deaef6608 100644 --- a/util/system/fs_win.h +++ b/util/system/fs_win.h @@ -15,7 +15,7 @@ namespace NFsPrivate { TString WinReadLink(const TString& path); - HANDLE CreateFileWithUtf8Name(const TStringBuf fName, ui32 accessMode, ui32 shareMode, ui32 createMode, ui32 attributes, bool inheritHandle); + HANDLE CreateFileWithUtf8Name(const TStringBuf fName, ui32 accessMode, ui32 shareMode, ui32 createMode, ui32 attributes, bool inheritHandle); bool WinRemove(const TString& path); diff --git a/util/system/fstat.cpp b/util/system/fstat.cpp index 81e98cbc6bb..d25651621ab 100644 --- a/util/system/fstat.cpp +++ b/util/system/fstat.cpp @@ -132,23 +132,23 @@ TFileStat::TFileStat(const char* fileName, bool nofollow) { MakeFromFileName(fileName, nofollow); } -bool TFileStat::IsNull() const noexcept { +bool TFileStat::IsNull() const noexcept { return *this == TFileStat(); } -bool TFileStat::IsFile() const noexcept { +bool TFileStat::IsFile() const noexcept { return S_ISREG(Mode); } -bool TFileStat::IsDir() const noexcept { +bool TFileStat::IsDir() const noexcept { return S_ISDIR(Mode); } -bool TFileStat::IsSymlink() const noexcept { +bool TFileStat::IsSymlink() const noexcept { return S_ISLNK(Mode); } -bool operator==(const TFileStat& l, const TFileStat& r) noexcept { +bool operator==(const TFileStat& l, const TFileStat& r) noexcept { return l.Mode == r.Mode && l.Uid == r.Uid && l.Gid == r.Gid && @@ -159,7 +159,7 @@ bool operator==(const TFileStat& l, const TFileStat& r) noexcept { l.CTime == r.CTime; } -bool operator!=(const TFileStat& l, const TFileStat& r) noexcept { +bool operator!=(const TFileStat& l, const TFileStat& r) noexcept { return !(l == r); } diff --git a/util/system/fstat.h b/util/system/fstat.h index 64e79e1b559..46d3db8a056 100644 --- a/util/system/fstat.h +++ b/util/system/fstat.h @@ -23,11 +23,11 @@ struct TFileStat { public: TFileStat(); - bool IsNull() const noexcept; + bool IsNull() const noexcept; - bool IsFile() const noexcept; - bool IsDir() const noexcept; - bool IsSymlink() const noexcept; + bool IsFile() const noexcept; + bool IsDir() const noexcept; + bool IsSymlink() const noexcept; explicit TFileStat(const TFile& f); explicit TFileStat(FHANDLE f); @@ -35,8 +35,8 @@ public: TFileStat(const TString& fileName, bool nofollow = false); TFileStat(const char* fileName, bool nofollow = false); - friend bool operator==(const TFileStat& l, const TFileStat& r) noexcept; - friend bool operator!=(const TFileStat& l, const TFileStat& r) noexcept; + friend bool operator==(const TFileStat& l, const TFileStat& r) noexcept; + friend bool operator!=(const TFileStat& l, const TFileStat& r) noexcept; private: void MakeFromFileName(const char* fileName, bool nofollow); diff --git a/util/system/fstat_ut.cpp b/util/system/fstat_ut.cpp index 160ecd936e6..c7f0f27f15c 100644 --- a/util/system/fstat_ut.cpp +++ b/util/system/fstat_ut.cpp @@ -6,10 +6,10 @@ #include <library/cpp/testing/unittest/registar.h> #include <library/cpp/testing/unittest/tests_data.h> -#include <util/folder/path.h> - -Y_UNIT_TEST_SUITE(TestFileStat) { - Y_UNIT_TEST(FileTest) { +#include <util/folder/path.h> + +Y_UNIT_TEST_SUITE(TestFileStat) { + Y_UNIT_TEST(FileTest) { TString fileName = "f1.txt"; TFileStat oFs; { @@ -46,7 +46,7 @@ Y_UNIT_TEST_SUITE(TestFileStat) { UNIT_ASSERT(unlink(fileName.data()) == 0); } - Y_UNIT_TEST(DirTest) { + Y_UNIT_TEST(DirTest) { Mkdir("tmpd", MODE0777); TFileStat fs("tmpd"); UNIT_ASSERT(!fs.IsFile()); @@ -62,77 +62,77 @@ Y_UNIT_TEST_SUITE(TestFileStat) { UNIT_ASSERT(fs.CTime == 0); } - Y_UNIT_TEST(SymlinkToExistingFileTest) { - const auto path = GetOutputPath() / "file_1"; - const auto link = GetOutputPath() / "symlink_1"; - TFile(path, EOpenModeFlag::CreateNew | EOpenModeFlag::RdWr); - UNIT_ASSERT(NFs::SymLink(path, link)); - - const TFileStat statNoFollow(link, false); - UNIT_ASSERT_VALUES_EQUAL_C(false, statNoFollow.IsNull(), ToString(statNoFollow.Mode)); - UNIT_ASSERT_VALUES_EQUAL_C(true, statNoFollow.IsFile(), ToString(statNoFollow.Mode)); - UNIT_ASSERT_VALUES_EQUAL_C(false, statNoFollow.IsSymlink(), ToString(statNoFollow.Mode)); - UNIT_ASSERT_VALUES_EQUAL_C(false, statNoFollow.IsDir(), ToString(statNoFollow.Mode)); - - const TFileStat statFollow(link, true); - UNIT_ASSERT_VALUES_EQUAL_C(false, statFollow.IsNull(), ToString(statFollow.Mode)); - UNIT_ASSERT_VALUES_EQUAL_C(false, statFollow.IsFile(), ToString(statFollow.Mode)); - UNIT_ASSERT_VALUES_EQUAL_C(true, statFollow.IsSymlink(), ToString(statFollow.Mode)); - UNIT_ASSERT_VALUES_EQUAL_C(false, statFollow.IsDir(), ToString(statFollow.Mode)); - } - - Y_UNIT_TEST(SymlinkToNonExistingFileTest) { - const auto path = GetOutputPath() / "file_2"; - const auto link = GetOutputPath() / "symlink_2"; - UNIT_ASSERT(NFs::SymLink(path, link)); - - const TFileStat statNoFollow(link, false); - UNIT_ASSERT_VALUES_EQUAL_C(true, statNoFollow.IsNull(), ToString(statNoFollow.Mode)); - UNIT_ASSERT_VALUES_EQUAL_C(false, statNoFollow.IsFile(), ToString(statNoFollow.Mode)); - UNIT_ASSERT_VALUES_EQUAL_C(false, statNoFollow.IsSymlink(), ToString(statNoFollow.Mode)); - UNIT_ASSERT_VALUES_EQUAL_C(false, statNoFollow.IsDir(), ToString(statNoFollow.Mode)); - - const TFileStat statFollow(link, true); - UNIT_ASSERT_VALUES_EQUAL_C(false, statFollow.IsNull(), ToString(statFollow.Mode)); - UNIT_ASSERT_VALUES_EQUAL_C(false, statFollow.IsFile(), ToString(statFollow.Mode)); - UNIT_ASSERT_VALUES_EQUAL_C(true, statFollow.IsSymlink(), ToString(statFollow.Mode)); - UNIT_ASSERT_VALUES_EQUAL_C(false, statFollow.IsDir(), ToString(statFollow.Mode)); - } - - Y_UNIT_TEST(SymlinkToFileThatCantExistTest) { - const auto path = TFsPath("/path") / "that" / "does" / "not" / "exists"; - const auto link = GetOutputPath() / "symlink_3"; - UNIT_ASSERT(NFs::SymLink(path, link)); - - const TFileStat statNoFollow(link, false); - UNIT_ASSERT_VALUES_EQUAL_C(true, statNoFollow.IsNull(), ToString(statNoFollow.Mode)); - UNIT_ASSERT_VALUES_EQUAL_C(false, statNoFollow.IsFile(), ToString(statNoFollow.Mode)); - UNIT_ASSERT_VALUES_EQUAL_C(false, statNoFollow.IsSymlink(), ToString(statNoFollow.Mode)); - UNIT_ASSERT_VALUES_EQUAL_C(false, statNoFollow.IsDir(), ToString(statNoFollow.Mode)); - - const TFileStat statFollow(link, true); - UNIT_ASSERT_VALUES_EQUAL_C(false, statFollow.IsNull(), ToString(statFollow.Mode)); - UNIT_ASSERT_VALUES_EQUAL_C(false, statFollow.IsFile(), ToString(statFollow.Mode)); - UNIT_ASSERT_VALUES_EQUAL_C(true, statFollow.IsSymlink(), ToString(statFollow.Mode)); - UNIT_ASSERT_VALUES_EQUAL_C(false, statFollow.IsDir(), ToString(statFollow.Mode)); - } - - Y_UNIT_TEST(FileDoesNotExistTest) { - const auto path = TFsPath("/path") / "that" / "does" / "not" / "exists"; - - const TFileStat statNoFollow(path, false); - UNIT_ASSERT_VALUES_EQUAL_C(true, statNoFollow.IsNull(), ToString(statNoFollow.Mode)); - UNIT_ASSERT_VALUES_EQUAL_C(false, statNoFollow.IsFile(), ToString(statNoFollow.Mode)); - UNIT_ASSERT_VALUES_EQUAL_C(false, statNoFollow.IsSymlink(), ToString(statNoFollow.Mode)); - UNIT_ASSERT_VALUES_EQUAL_C(false, statNoFollow.IsDir(), ToString(statNoFollow.Mode)); - - const TFileStat statFollow(path, true); - UNIT_ASSERT_VALUES_EQUAL_C(true, statFollow.IsNull(), ToString(statFollow.Mode)); - UNIT_ASSERT_VALUES_EQUAL_C(false, statFollow.IsFile(), ToString(statFollow.Mode)); - UNIT_ASSERT_VALUES_EQUAL_C(false, statFollow.IsSymlink(), ToString(statFollow.Mode)); - UNIT_ASSERT_VALUES_EQUAL_C(false, statFollow.IsDir(), ToString(statFollow.Mode)); - } - + Y_UNIT_TEST(SymlinkToExistingFileTest) { + const auto path = GetOutputPath() / "file_1"; + const auto link = GetOutputPath() / "symlink_1"; + TFile(path, EOpenModeFlag::CreateNew | EOpenModeFlag::RdWr); + UNIT_ASSERT(NFs::SymLink(path, link)); + + const TFileStat statNoFollow(link, false); + UNIT_ASSERT_VALUES_EQUAL_C(false, statNoFollow.IsNull(), ToString(statNoFollow.Mode)); + UNIT_ASSERT_VALUES_EQUAL_C(true, statNoFollow.IsFile(), ToString(statNoFollow.Mode)); + UNIT_ASSERT_VALUES_EQUAL_C(false, statNoFollow.IsSymlink(), ToString(statNoFollow.Mode)); + UNIT_ASSERT_VALUES_EQUAL_C(false, statNoFollow.IsDir(), ToString(statNoFollow.Mode)); + + const TFileStat statFollow(link, true); + UNIT_ASSERT_VALUES_EQUAL_C(false, statFollow.IsNull(), ToString(statFollow.Mode)); + UNIT_ASSERT_VALUES_EQUAL_C(false, statFollow.IsFile(), ToString(statFollow.Mode)); + UNIT_ASSERT_VALUES_EQUAL_C(true, statFollow.IsSymlink(), ToString(statFollow.Mode)); + UNIT_ASSERT_VALUES_EQUAL_C(false, statFollow.IsDir(), ToString(statFollow.Mode)); + } + + Y_UNIT_TEST(SymlinkToNonExistingFileTest) { + const auto path = GetOutputPath() / "file_2"; + const auto link = GetOutputPath() / "symlink_2"; + UNIT_ASSERT(NFs::SymLink(path, link)); + + const TFileStat statNoFollow(link, false); + UNIT_ASSERT_VALUES_EQUAL_C(true, statNoFollow.IsNull(), ToString(statNoFollow.Mode)); + UNIT_ASSERT_VALUES_EQUAL_C(false, statNoFollow.IsFile(), ToString(statNoFollow.Mode)); + UNIT_ASSERT_VALUES_EQUAL_C(false, statNoFollow.IsSymlink(), ToString(statNoFollow.Mode)); + UNIT_ASSERT_VALUES_EQUAL_C(false, statNoFollow.IsDir(), ToString(statNoFollow.Mode)); + + const TFileStat statFollow(link, true); + UNIT_ASSERT_VALUES_EQUAL_C(false, statFollow.IsNull(), ToString(statFollow.Mode)); + UNIT_ASSERT_VALUES_EQUAL_C(false, statFollow.IsFile(), ToString(statFollow.Mode)); + UNIT_ASSERT_VALUES_EQUAL_C(true, statFollow.IsSymlink(), ToString(statFollow.Mode)); + UNIT_ASSERT_VALUES_EQUAL_C(false, statFollow.IsDir(), ToString(statFollow.Mode)); + } + + Y_UNIT_TEST(SymlinkToFileThatCantExistTest) { + const auto path = TFsPath("/path") / "that" / "does" / "not" / "exists"; + const auto link = GetOutputPath() / "symlink_3"; + UNIT_ASSERT(NFs::SymLink(path, link)); + + const TFileStat statNoFollow(link, false); + UNIT_ASSERT_VALUES_EQUAL_C(true, statNoFollow.IsNull(), ToString(statNoFollow.Mode)); + UNIT_ASSERT_VALUES_EQUAL_C(false, statNoFollow.IsFile(), ToString(statNoFollow.Mode)); + UNIT_ASSERT_VALUES_EQUAL_C(false, statNoFollow.IsSymlink(), ToString(statNoFollow.Mode)); + UNIT_ASSERT_VALUES_EQUAL_C(false, statNoFollow.IsDir(), ToString(statNoFollow.Mode)); + + const TFileStat statFollow(link, true); + UNIT_ASSERT_VALUES_EQUAL_C(false, statFollow.IsNull(), ToString(statFollow.Mode)); + UNIT_ASSERT_VALUES_EQUAL_C(false, statFollow.IsFile(), ToString(statFollow.Mode)); + UNIT_ASSERT_VALUES_EQUAL_C(true, statFollow.IsSymlink(), ToString(statFollow.Mode)); + UNIT_ASSERT_VALUES_EQUAL_C(false, statFollow.IsDir(), ToString(statFollow.Mode)); + } + + Y_UNIT_TEST(FileDoesNotExistTest) { + const auto path = TFsPath("/path") / "that" / "does" / "not" / "exists"; + + const TFileStat statNoFollow(path, false); + UNIT_ASSERT_VALUES_EQUAL_C(true, statNoFollow.IsNull(), ToString(statNoFollow.Mode)); + UNIT_ASSERT_VALUES_EQUAL_C(false, statNoFollow.IsFile(), ToString(statNoFollow.Mode)); + UNIT_ASSERT_VALUES_EQUAL_C(false, statNoFollow.IsSymlink(), ToString(statNoFollow.Mode)); + UNIT_ASSERT_VALUES_EQUAL_C(false, statNoFollow.IsDir(), ToString(statNoFollow.Mode)); + + const TFileStat statFollow(path, true); + UNIT_ASSERT_VALUES_EQUAL_C(true, statFollow.IsNull(), ToString(statFollow.Mode)); + UNIT_ASSERT_VALUES_EQUAL_C(false, statFollow.IsFile(), ToString(statFollow.Mode)); + UNIT_ASSERT_VALUES_EQUAL_C(false, statFollow.IsSymlink(), ToString(statFollow.Mode)); + UNIT_ASSERT_VALUES_EQUAL_C(false, statFollow.IsDir(), ToString(statFollow.Mode)); + } + Y_UNIT_TEST(ChmodTest) { const TString fileName = "m.txt"; TFile file(fileName.c_str(), OpenAlways | WrOnly); diff --git a/util/system/guard.h b/util/system/guard.h index efc091d5f8d..49d7a4b335b 100644 --- a/util/system/guard.h +++ b/util/system/guard.h @@ -48,7 +48,7 @@ public: inline TGuard(TGuard&& g) noexcept : T_(g.T_) { - g.T_ = nullptr; + g.T_ = nullptr; } inline ~TGuard() { @@ -58,7 +58,7 @@ public: inline void Release() noexcept { if (WasAcquired()) { TOps::Release(T_); - T_ = nullptr; + T_ = nullptr; } } @@ -67,7 +67,7 @@ public: } inline bool WasAcquired() const noexcept { - return T_ != nullptr; + return T_ != nullptr; } inline T* GetMutex() const noexcept { @@ -150,12 +150,12 @@ public: inline void Release() noexcept { if (WasAcquired()) { TOps::Release(T_); - T_ = nullptr; + T_ = nullptr; } } inline bool WasAcquired() const noexcept { - return T_ != nullptr; + return T_ != nullptr; } explicit inline operator bool() const noexcept { @@ -164,7 +164,7 @@ public: private: inline void Init(const T* t) noexcept { - T_ = nullptr; + T_ = nullptr; T* tMutable = const_cast<T*>(t); if (TOps::TryAcquire(tMutable)) { T_ = tMutable; diff --git a/util/system/hostname.cpp b/util/system/hostname.cpp index 386f646d6bd..2003c6d4d3c 100644 --- a/util/system/hostname.cpp +++ b/util/system/hostname.cpp @@ -82,7 +82,7 @@ const char* GetFQDNHostName() { bool IsFQDN(const TString& name) { TString absName = name; - if (!absName.EndsWith('.')) { + if (!absName.EndsWith('.')) { absName.append("."); } diff --git a/util/system/hp_timer.cpp b/util/system/hp_timer.cpp index e4c3f21e6b4..310db999e66 100644 --- a/util/system/hp_timer.cpp +++ b/util/system/hp_timer.cpp @@ -66,8 +66,8 @@ namespace { double vec[N_VEC]; - for (auto& i : vec) { - i = EstimateCPUClock(); + for (auto& i : vec) { + i = EstimateCPUClock(); } Sort(vec, vec + N_VEC); @@ -93,23 +93,23 @@ namespace { }; } -double NHPTimer::GetSeconds(const STime& a) noexcept { +double NHPTimer::GetSeconds(const STime& a) noexcept { return TFreq::Instance().GetSeconds(a); } -double NHPTimer::GetClockRate() noexcept { +double NHPTimer::GetClockRate() noexcept { return TFreq::Instance().GetClockRate(); } -ui64 NHPTimer::GetCyclesPerSecond() noexcept { +ui64 NHPTimer::GetCyclesPerSecond() noexcept { return TFreq::Instance().GetCyclesPerSecond(); } -void NHPTimer::GetTime(STime* pTime) noexcept { +void NHPTimer::GetTime(STime* pTime) noexcept { *pTime = GetCycleCount(); } -double NHPTimer::GetTimePassed(STime* pTime) noexcept { +double NHPTimer::GetTimePassed(STime* pTime) noexcept { STime old(*pTime); *pTime = GetCycleCount(); diff --git a/util/system/hp_timer.h b/util/system/hp_timer.h index 0a4c252ec26..ea02b660ed4 100644 --- a/util/system/hp_timer.h +++ b/util/system/hp_timer.h @@ -5,29 +5,29 @@ namespace NHPTimer { using STime = i64; // May delay for ~50ms to compute frequency - double GetSeconds(const STime& a) noexcept; + double GetSeconds(const STime& a) noexcept; // Returns the current time - void GetTime(STime* pTime) noexcept; + void GetTime(STime* pTime) noexcept; // Returns the time passed since *pTime, and writes the current time into *pTime. - double GetTimePassed(STime* pTime) noexcept; + double GetTimePassed(STime* pTime) noexcept; // Get TSC frequency, may delay for ~50ms to compute frequency - double GetClockRate() noexcept; - // same as GetClockRate, but in integer - ui64 GetCyclesPerSecond() noexcept; + double GetClockRate() noexcept; + // same as GetClockRate, but in integer + ui64 GetCyclesPerSecond() noexcept; } struct THPTimer { THPTimer() noexcept { Reset(); } - void Reset() noexcept { + void Reset() noexcept { NHPTimer::GetTime(&Start); } - double Passed() const noexcept { + double Passed() const noexcept { NHPTimer::STime tmp = Start; return NHPTimer::GetTimePassed(&tmp); } - double PassedReset() noexcept { + double PassedReset() noexcept { return NHPTimer::GetTimePassed(&Start); } diff --git a/util/system/info.cpp b/util/system/info.cpp index cf6681e89a9..78db83cd61d 100644 --- a/util/system/info.cpp +++ b/util/system/info.cpp @@ -134,7 +134,7 @@ size_t NSystemInfo::NumberOfCpus() { mib[0] = CTL_HW; mib[1] = HW_NCPU; len = sizeof(ncpus); - if (sysctl(mib, 2, &ncpus, &len, nullptr, 0) == -1) { + if (sysctl(mib, 2, &ncpus, &len, nullptr, 0) == -1) { abort(); } diff --git a/util/system/mem_info.cpp b/util/system/mem_info.cpp index aa51ae3b16d..e5f60b49be8 100644 --- a/util/system/mem_info.cpp +++ b/util/system/mem_info.cpp @@ -134,7 +134,7 @@ namespace NMemInfo { Zero(proc); errno = 0; - if (sysctl((int*)mib, 4, &proc, &size, nullptr, 0) == -1) { + if (sysctl((int*)mib, 4, &proc, &size, nullptr, 0) == -1) { int err = errno; TString errtxt = LastSystemErrorText(err); ythrow yexception() << "sysctl({CTL_KERN,KERN_PROC,KERN_PROC_PID,pid},4,proc,&size,NULL,0) returned -1, errno: " << err << " (" << errtxt << ")" << Endl; diff --git a/util/system/mutex.cpp b/util/system/mutex.cpp index 4041402db9a..b4513615a2f 100644 --- a/util/system/mutex.cpp +++ b/util/system/mutex.cpp @@ -35,7 +35,7 @@ public: inline ~T() { int result = pthread_mutexattr_destroy(&Attr); - Y_VERIFY(result == 0, "mutexattr destroy(%s)", LastSystemErrorText(result)); + Y_VERIFY(result == 0, "mutexattr destroy(%s)", LastSystemErrorText(result)); } } pma; @@ -51,7 +51,7 @@ public: DeleteCriticalSection(&Obj); #else int result = pthread_mutex_destroy(&Obj); - Y_VERIFY(result == 0, "mutex destroy failure (%s)", LastSystemErrorText(result)); + Y_VERIFY(result == 0, "mutex destroy failure (%s)", LastSystemErrorText(result)); #endif } @@ -60,7 +60,7 @@ public: EnterCriticalSection(&Obj); #else int result = pthread_mutex_lock(&Obj); - Y_VERIFY(result == 0, "mutex lock failure (%s)", LastSystemErrorText(result)); + Y_VERIFY(result == 0, "mutex lock failure (%s)", LastSystemErrorText(result)); #endif } @@ -95,7 +95,7 @@ public: if (result == 0 || result == EBUSY) { return result == 0; } - Y_FAIL("mutex trylock failure (%s)", LastSystemErrorText(result)); + Y_FAIL("mutex trylock failure (%s)", LastSystemErrorText(result)); #endif } @@ -104,7 +104,7 @@ public: LeaveCriticalSection(&Obj); #else int result = pthread_mutex_unlock(&Obj); - Y_VERIFY(result == 0, "mutex unlock failure (%s)", LastSystemErrorText(result)); + Y_VERIFY(result == 0, "mutex unlock failure (%s)", LastSystemErrorText(result)); #endif } diff --git a/util/system/nice_ut.cpp b/util/system/nice_ut.cpp index ae0051f285a..bc8d942da82 100644 --- a/util/system/nice_ut.cpp +++ b/util/system/nice_ut.cpp @@ -12,13 +12,13 @@ static int GetPriority() { } #endif -Y_UNIT_TEST_SUITE(NiceTest) { - Y_UNIT_TEST(TestNiceZero) { +Y_UNIT_TEST_SUITE(NiceTest) { + Y_UNIT_TEST(TestNiceZero) { UNIT_ASSERT(Nice(0)); UNIT_ASSERT(Nice(0)); } #ifdef _unix_ - Y_UNIT_TEST(TestNice) { + Y_UNIT_TEST(TestNice) { int prio = GetPriority(); if (prio >= 10) { diff --git a/util/system/pipe.cpp b/util/system/pipe.cpp index a543bd74720..6bb915513be 100644 --- a/util/system/pipe.cpp +++ b/util/system/pipe.cpp @@ -1,6 +1,6 @@ #include "pipe.h" -#include <util/stream/output.h> +#include <util/stream/output.h> #include <util/generic/yexception.h> ssize_t TPipeHandle::Read(void* buffer, size_t byteCount) const noexcept { diff --git a/util/system/pipe_ut.cpp b/util/system/pipe_ut.cpp index 6d53432de8d..d120804e4bf 100644 --- a/util/system/pipe_ut.cpp +++ b/util/system/pipe_ut.cpp @@ -2,8 +2,8 @@ #include <library/cpp/testing/unittest/registar.h> -Y_UNIT_TEST_SUITE(TPipeTest) { - Y_UNIT_TEST(TestPipe) { +Y_UNIT_TEST_SUITE(TPipeTest) { + Y_UNIT_TEST(TestPipe) { TPipe r; TPipe w; TPipe::Pipe(r, w); diff --git a/util/system/progname.cpp b/util/system/progname.cpp index 2c291193203..9ed924ad4c7 100644 --- a/util/system/progname.cpp +++ b/util/system/progname.cpp @@ -18,7 +18,7 @@ namespace { } const TString& GetProgramName() { - return Singleton<TProgramNameHolder>()->ProgName; + return Singleton<TProgramNameHolder>()->ProgName; } void SetProgramName(const char* argv0) { diff --git a/util/system/progname_ut.cpp b/util/system/progname_ut.cpp index 11f3d9308b0..6c2709e26e3 100644 --- a/util/system/progname_ut.cpp +++ b/util/system/progname_ut.cpp @@ -2,8 +2,8 @@ #include <library/cpp/testing/unittest/registar.h> -Y_UNIT_TEST_SUITE(TProgramNameTest) { - Y_UNIT_TEST(TestIt) { +Y_UNIT_TEST_SUITE(TProgramNameTest) { + Y_UNIT_TEST(TestIt) { TString progName = GetProgramName(); try { diff --git a/util/system/rusage_ut.cpp b/util/system/rusage_ut.cpp index 0d4e0fe54b4..dcb771be713 100644 --- a/util/system/rusage_ut.cpp +++ b/util/system/rusage_ut.cpp @@ -2,8 +2,8 @@ #include <library/cpp/testing/unittest/registar.h> -Y_UNIT_TEST_SUITE(TRusageTest) { - Y_UNIT_TEST(TestRusage) { +Y_UNIT_TEST_SUITE(TRusageTest) { + Y_UNIT_TEST(TestRusage) { TRusage r; // just check it returns something r.Fill(); diff --git a/util/system/rwlock.cpp b/util/system/rwlock.cpp index bb3dcbf1881..067cbd51406 100644 --- a/util/system/rwlock.cpp +++ b/util/system/rwlock.cpp @@ -164,7 +164,7 @@ private: }; TRWMutex::TImpl::TImpl() { - int result = pthread_rwlock_init(&Lock_, nullptr); + int result = pthread_rwlock_init(&Lock_, nullptr); if (result != 0) { ythrow yexception() << "rwlock init failed (" << LastSystemErrorText(result) << ")"; } @@ -172,44 +172,44 @@ TRWMutex::TImpl::TImpl() { TRWMutex::TImpl::~TImpl() { const int result = pthread_rwlock_destroy(&Lock_); - Y_VERIFY(result == 0, "rwlock destroy failed (%s)", LastSystemErrorText(result)); + Y_VERIFY(result == 0, "rwlock destroy failed (%s)", LastSystemErrorText(result)); } void TRWMutex::TImpl::AcquireRead() noexcept { const int result = pthread_rwlock_rdlock(&Lock_); - Y_VERIFY(result == 0, "rwlock rdlock failed (%s)", LastSystemErrorText(result)); + Y_VERIFY(result == 0, "rwlock rdlock failed (%s)", LastSystemErrorText(result)); } bool TRWMutex::TImpl::TryAcquireRead() noexcept { const int result = pthread_rwlock_tryrdlock(&Lock_); - Y_VERIFY(result == 0 || result == EBUSY, "rwlock tryrdlock failed (%s)", LastSystemErrorText(result)); + Y_VERIFY(result == 0 || result == EBUSY, "rwlock tryrdlock failed (%s)", LastSystemErrorText(result)); return result == 0; } void TRWMutex::TImpl::ReleaseRead() noexcept { const int result = pthread_rwlock_unlock(&Lock_); - Y_VERIFY(result == 0, "rwlock (read) unlock failed (%s)", LastSystemErrorText(result)); + Y_VERIFY(result == 0, "rwlock (read) unlock failed (%s)", LastSystemErrorText(result)); } void TRWMutex::TImpl::AcquireWrite() noexcept { const int result = pthread_rwlock_wrlock(&Lock_); - Y_VERIFY(result == 0, "rwlock wrlock failed (%s)", LastSystemErrorText(result)); + Y_VERIFY(result == 0, "rwlock wrlock failed (%s)", LastSystemErrorText(result)); } bool TRWMutex::TImpl::TryAcquireWrite() noexcept { const int result = pthread_rwlock_trywrlock(&Lock_); - Y_VERIFY(result == 0 || result == EBUSY, "rwlock trywrlock failed (%s)", LastSystemErrorText(result)); + Y_VERIFY(result == 0 || result == EBUSY, "rwlock trywrlock failed (%s)", LastSystemErrorText(result)); return result == 0; } void TRWMutex::TImpl::ReleaseWrite() noexcept { const int result = pthread_rwlock_unlock(&Lock_); - Y_VERIFY(result == 0, "rwlock (write) unlock failed (%s)", LastSystemErrorText(result)); + Y_VERIFY(result == 0, "rwlock (write) unlock failed (%s)", LastSystemErrorText(result)); } void TRWMutex::TImpl::Release() noexcept { const int result = pthread_rwlock_unlock(&Lock_); - Y_VERIFY(result == 0, "rwlock unlock failed (%s)", LastSystemErrorText(result)); + Y_VERIFY(result == 0, "rwlock unlock failed (%s)", LastSystemErrorText(result)); } #endif diff --git a/util/system/sanitizers_ut.cpp b/util/system/sanitizers_ut.cpp index 5de096e14b1..99480202a6b 100644 --- a/util/system/sanitizers_ut.cpp +++ b/util/system/sanitizers_ut.cpp @@ -3,8 +3,8 @@ #include <library/cpp/testing/unittest/registar.h> -Y_UNIT_TEST_SUITE(Sanitizers) { - Y_UNIT_TEST(MarkAsIntentionallyLeaked) { +Y_UNIT_TEST_SUITE(Sanitizers) { + Y_UNIT_TEST(MarkAsIntentionallyLeaked) { auto* p1 = new i32[100]; NSan::MarkAsIntentionallyLeaked(p1); @@ -12,4 +12,4 @@ Y_UNIT_TEST_SUITE(Sanitizers) { NSan::MarkAsIntentionallyLeaked(p2); } -} // Y_UNIT_TEST_SUITE(Sanitizers) +} // Y_UNIT_TEST_SUITE(Sanitizers) diff --git a/util/system/sem.cpp b/util/system/sem.cpp index 4a93b903b5c..8263992de46 100644 --- a/util/system/sem.cpp +++ b/util/system/sem.cpp @@ -129,7 +129,7 @@ namespace { #else int ret = sem_post(Handle); #endif - Y_VERIFY(ret == 0, "can not release semaphore"); + Y_VERIFY(ret == 0, "can not release semaphore"); #endif } @@ -137,7 +137,7 @@ namespace { //hence to maintain consistancy, for win32 case we use INFINITE or 0 timeout. inline void Acquire() noexcept { #ifdef _win_ - Y_VERIFY(::WaitForSingleObject(Handle, INFINITE) == WAIT_OBJECT_0, "can not acquire semaphore"); + Y_VERIFY(::WaitForSingleObject(Handle, INFINITE) == WAIT_OBJECT_0, "can not acquire semaphore"); #else #ifdef USE_SYSV_SEMAPHORES struct sembuf ops[] = {{0, -1, SEM_UNDO}}; @@ -145,7 +145,7 @@ namespace { #else int ret = sem_wait(Handle); #endif - Y_VERIFY(ret == 0, "can not acquire semaphore"); + Y_VERIFY(ret == 0, "can not acquire semaphore"); #endif } @@ -183,20 +183,20 @@ namespace { } inline ~TPosixSemaphore() { - Y_VERIFY(sem_destroy(&S_) == 0, "semaphore destroy failed"); + Y_VERIFY(sem_destroy(&S_) == 0, "semaphore destroy failed"); } inline void Acquire() noexcept { - Y_VERIFY(sem_wait(&S_) == 0, "semaphore acquire failed"); + Y_VERIFY(sem_wait(&S_) == 0, "semaphore acquire failed"); } inline void Release() noexcept { - Y_VERIFY(sem_post(&S_) == 0, "semaphore release failed"); + Y_VERIFY(sem_post(&S_) == 0, "semaphore release failed"); } inline bool TryAcquire() noexcept { if (sem_trywait(&S_)) { - Y_VERIFY(errno == EAGAIN, "semaphore try wait failed"); + Y_VERIFY(errno == EAGAIN, "semaphore try wait failed"); return false; } diff --git a/util/system/shellcommand.cpp b/util/system/shellcommand.cpp index b1989b5c8c3..7ba438be12c 100644 --- a/util/system/shellcommand.cpp +++ b/util/system/shellcommand.cpp @@ -2,16 +2,16 @@ #include "user.h" #include "nice.h" #include "sigset.h" -#include "atomic.h" - +#include "atomic.h" + #include <util/folder/dirut.h> -#include <util/generic/algorithm.h> -#include <util/generic/buffer.h> -#include <util/generic/vector.h> -#include <util/generic/yexception.h> -#include <util/memory/tempbuf.h> +#include <util/generic/algorithm.h> +#include <util/generic/buffer.h> +#include <util/generic/vector.h> +#include <util/generic/yexception.h> +#include <util/memory/tempbuf.h> #include <util/network/socket.h> -#include <util/stream/pipe.h> +#include <util/stream/pipe.h> #include <util/stream/str.h> #include <util/string/cast.h> #include <util/system/info.h> @@ -157,13 +157,13 @@ public: ssize_t Read(void* buffer, size_t byteCount) const noexcept { DWORD doneBytes; - if (!ReadFile(Fd_, buffer, byteCount, &doneBytes, nullptr)) + if (!ReadFile(Fd_, buffer, byteCount, &doneBytes, nullptr)) return -1; return doneBytes; } ssize_t Write(const void* buffer, size_t byteCount) const noexcept { DWORD doneBytes; - if (!WriteFile(Fd_, buffer, byteCount, &doneBytes, nullptr)) + if (!WriteFile(Fd_, buffer, byteCount, &doneBytes, nullptr)) return -1; return doneBytes; } @@ -196,9 +196,9 @@ private: TString WorkDir; TAtomic ExecutionStatus; // TShellCommand::ECommandStatus TMaybe<int> ExitCode; - IInputStream* InputStream; - IOutputStream* OutputStream; - IOutputStream* ErrorStream; + IInputStream* InputStream; + IOutputStream* OutputStream; + IOutputStream* ErrorStream; TString CollectedOutput; TString CollectedError; TString InternalError; @@ -289,7 +289,7 @@ public: , InputStream(options.InputStream) , OutputStream(options.OutputStream) , ErrorStream(options.ErrorStream) - , WatchThread(nullptr) + , WatchThread(nullptr) , TerminateFlag(false) , ClearSignalMask(options.ClearSignalMask) , CloseAllFdsOnExec(options.CloseAllFdsOnExec) @@ -330,36 +330,36 @@ public: #endif } - inline void AppendArgument(const TStringBuf argument) { - if (AtomicGet(ExecutionStatus) == SHELL_RUNNING) { + inline void AppendArgument(const TStringBuf argument) { + if (AtomicGet(ExecutionStatus) == SHELL_RUNNING) { ythrow yexception() << "You cannot change command parameters while process is running"; } Arguments.push_back(ToString(argument)); } inline const TString& GetOutput() const { - if (AtomicGet(ExecutionStatus) == SHELL_RUNNING) { + if (AtomicGet(ExecutionStatus) == SHELL_RUNNING) { ythrow yexception() << "You cannot retrieve output while process is running."; } return CollectedOutput; } inline const TString& GetError() const { - if (AtomicGet(ExecutionStatus) == SHELL_RUNNING) { + if (AtomicGet(ExecutionStatus) == SHELL_RUNNING) { ythrow yexception() << "You cannot retrieve output while process is running."; } return CollectedError; } inline const TString& GetInternalError() const { - if (AtomicGet(ExecutionStatus) != SHELL_INTERNAL_ERROR) { + if (AtomicGet(ExecutionStatus) != SHELL_INTERNAL_ERROR) { ythrow yexception() << "Internal error hasn't occured so can't be retrieved."; } return InternalError; } inline ECommandStatus GetStatus() const { - return static_cast<ECommandStatus>(AtomicGet(ExecutionStatus)); + return static_cast<ECommandStatus>(AtomicGet(ExecutionStatus)); } inline TMaybe<int> GetExitCode() const { @@ -390,7 +390,7 @@ public: void Run(); inline void Terminate() { - if (!!Pid && (AtomicGet(ExecutionStatus) == SHELL_RUNNING)) { + if (!!Pid && (AtomicGet(ExecutionStatus) == SHELL_RUNNING)) { bool ok = #if defined(_unix_) kill(DetachSession ? -1 * Pid : Pid, SIGTERM) == 0; @@ -446,7 +446,7 @@ public: inline static void* WatchProcess(void* data) { TProcessInfo* pi = reinterpret_cast<TProcessInfo*>(data); Communicate(pi); - return nullptr; + return nullptr; } inline static void* ReadStream(void* data) noexcept { @@ -573,7 +573,7 @@ void TShellCommand::TImpl::StartProcess(TShellCommand::TImpl::TPipes& pipes) { cwd = cwdBuff.c_str(); } - void* lpEnvironment = nullptr; + void* lpEnvironment = nullptr; TString env; if (!Environment.empty()) { for (auto e = Environment.begin(); e != Environment.end(); ++e) { @@ -590,7 +590,7 @@ void TShellCommand::TImpl::StartProcess(TShellCommand::TImpl::TPipes& pipes) { BOOL res = 0; if (User.Name.empty() || GetUsername() == User.Name) { res = CreateProcessW( - nullptr, // image name + nullptr, // image name cmdcopy.Data(), nullptr, // process security attributes nullptr, // thread security attributes @@ -603,7 +603,7 @@ void TShellCommand::TImpl::StartProcess(TShellCommand::TImpl::TPipes& pipes) { } else { res = CreateProcessWithLogonW( GetWString(User.Name.data()).c_str(), - nullptr, // domain (if this parameter is NULL, the user name must be specified in UPN format) + nullptr, // domain (if this parameter is NULL, the user name must be specified in UPN format) GetWString(User.Password.data()).c_str(), 0, // logon flags NULL, // image name @@ -616,7 +616,7 @@ void TShellCommand::TImpl::StartProcess(TShellCommand::TImpl::TPipes& pipes) { } if (!res) { - AtomicSet(ExecutionStatus, SHELL_ERROR); + AtomicSet(ExecutionStatus, SHELL_ERROR); /// @todo: write to error stream if set TStringOutput out(CollectedError); out << "Process was not created: " << LastSystemErrorText() << " command text was: '" << GetAString(cmdcopy.Data()) << "'"; @@ -653,12 +653,12 @@ bool ArgNeedsQuotes(TStringBuf arg) noexcept { TString TShellCommand::TImpl::GetQuotedCommand() const { TString quoted = Command; /// @todo command itself should be quoted too - for (const auto& argument : Arguments) { + for (const auto& argument : Arguments) { // Don't add unnecessary quotes. It's especially important for the windows with a 32k command line length limit. if (QuoteArguments && ArgNeedsQuotes(argument)) { - ::ShellQuoteArgSp(quoted, argument); + ::ShellQuoteArgSp(quoted, argument); } else { - quoted.append(" ").append(argument); + quoted.append(" ").append(argument); } } return quoted; @@ -678,13 +678,13 @@ void TShellCommand::TImpl::OnFork(TPipes& pipes, sigset_t oldmask, char* const* SigEmptySet(&sa.sa_mask); for (int i = 0; i < NSIG; ++i) { // some signals cannot be caught, so just ignore return value - sigaction(i, &sa, nullptr); + sigaction(i, &sa, nullptr); } if (ClearSignalMask) { SigEmptySet(&oldmask); } // clear / restore signal mask - if (SigProcMask(SIG_SETMASK, &oldmask, nullptr) != 0) { + if (SigProcMask(SIG_SETMASK, &oldmask, nullptr) != 0) { ythrow TSystemError() << "Cannot " << (ClearSignalMask ? "clear" : "restore") << " signal mask in child"; } @@ -772,7 +772,7 @@ void TShellCommand::TImpl::Run() { TRealPipeHandle::Pipe(pipes.InputPipeFd[0], pipes.InputPipeFd[1], CloseOnExec); } - AtomicSet(ExecutionStatus, SHELL_RUNNING); + AtomicSet(ExecutionStatus, SHELL_RUNNING); #if defined(_unix_) // block all signals to avoid signal handler race after fork() @@ -819,7 +819,7 @@ void TShellCommand::TImpl::Run() { pid_t pid = fork(); if (pid == -1) { - AtomicSet(ExecutionStatus, SHELL_ERROR); + AtomicSet(ExecutionStatus, SHELL_ERROR); /// @todo check if pipes are still open ythrow TSystemError() << "Cannot fork"; } else if (pid == 0) { // child @@ -830,7 +830,7 @@ void TShellCommand::TImpl::Run() { } } else { // parent // restore signal mask - if (SigProcMask(SIG_SETMASK, &oldmask, nullptr) != 0) { + if (SigProcMask(SIG_SETMASK, &oldmask, nullptr) != 0) { ythrow TSystemError() << "Cannot restore signal mask in parent"; } } @@ -873,19 +873,19 @@ void TShellCommand::TImpl::Run() { } void TShellCommand::TImpl::Communicate(TProcessInfo* pi) { - THolder<IOutputStream> outputHolder; - IOutputStream* output = pi->Parent->OutputStream; + THolder<IOutputStream> outputHolder; + IOutputStream* output = pi->Parent->OutputStream; if (!output) { outputHolder.Reset(output = new TStringOutput(pi->Parent->CollectedOutput)); } - THolder<IOutputStream> errorHolder; - IOutputStream* error = pi->Parent->ErrorStream; + THolder<IOutputStream> errorHolder; + IOutputStream* error = pi->Parent->ErrorStream; if (!error) { errorHolder.Reset(error = new TStringOutput(pi->Parent->CollectedError)); } - IInputStream*& input = pi->Parent->InputStream; + IInputStream*& input = pi->Parent->InputStream; #if defined(_unix_) // not really needed, io is done via poll @@ -922,7 +922,7 @@ void TShellCommand::TImpl::Communicate(TProcessInfo* pi) { TBuffer inputBuffer(DATA_BUFFER_SIZE); int bytes; int bytesToWrite = 0; - char* bufPos = nullptr; + char* bufPos = nullptr; #endif TWaitResult waitPidResult; TExitStatus status = 0; @@ -940,7 +940,7 @@ void TShellCommand::TImpl::Communicate(TProcessInfo* pi) { waitpid(pi->Parent->Pid, &status, WNOHANG); #else WaitForSingleObject(pi->Parent->Pid /* process_info.hProcess */, pi->Parent->PollDelayMs /* ms */); - Y_UNUSED(status); + Y_UNUSED(status); #endif // DBG(Cerr << "wait result: " << waitPidResult << Endl); if (waitPidResult != WAIT_PROCEED) { @@ -999,13 +999,13 @@ void TShellCommand::TImpl::Communicate(TProcessInfo* pi) { if ((fds[1].revents & POLLIN) == POLLIN) { haveOut = true; } else if (fds[1].revents & (POLLERR | POLLHUP)) { - output = nullptr; + output = nullptr; } if ((fds[2].revents & POLLIN) == POLLIN) { haveErr = true; } else if (fds[2].revents & (POLLERR | POLLHUP)) { - error = nullptr; + error = nullptr; } if (input && ((fds[0].revents & POLLOUT) == POLLOUT)) { @@ -1018,7 +1018,7 @@ void TShellCommand::TImpl::Communicate(TProcessInfo* pi) { if (bytes > 0) { output->Write(buffer.Data(), bytes); } else { - output = nullptr; + output = nullptr; } } if (haveErr) { @@ -1027,7 +1027,7 @@ void TShellCommand::TImpl::Communicate(TProcessInfo* pi) { if (bytes > 0) { error->Write(buffer.Data(), bytes); } else { - error = nullptr; + error = nullptr; } } @@ -1048,7 +1048,7 @@ void TShellCommand::TImpl::Communicate(TProcessInfo* pi) { bytesToWrite -= bytes; bufPos += bytes; } else { - input = nullptr; + input = nullptr; } DBG(Cerr << "transferred " << bytes << " bytes of input" << Endl); @@ -1084,9 +1084,9 @@ void TShellCommand::TImpl::Communicate(TProcessInfo* pi) { #endif pi->Parent->ExitCode = processExitCode; if (cleanExit) { - AtomicSet(pi->Parent->ExecutionStatus, SHELL_FINISHED); + AtomicSet(pi->Parent->ExecutionStatus, SHELL_FINISHED); } else { - AtomicSet(pi->Parent->ExecutionStatus, SHELL_ERROR); + AtomicSet(pi->Parent->ExecutionStatus, SHELL_ERROR); } #if defined(_win_) @@ -1109,7 +1109,7 @@ void TShellCommand::TImpl::Communicate(TProcessInfo* pi) { #endif } catch (const yexception& e) { // Some error in watch occured, set result to error - AtomicSet(pi->Parent->ExecutionStatus, SHELL_INTERNAL_ERROR); + AtomicSet(pi->Parent->ExecutionStatus, SHELL_INTERNAL_ERROR); pi->Parent->InternalError = e.what(); if (input) { pi->InputFd.Close(); @@ -1134,7 +1134,7 @@ TShellCommand::TShellCommand(const TStringBuf cmd, const TShellCommandOptions& o TShellCommand::~TShellCommand() = default; -TShellCommand& TShellCommand::operator<<(const TStringBuf argument) { +TShellCommand& TShellCommand::operator<<(const TStringBuf argument) { Impl->AppendArgument(argument); return *this; } diff --git a/util/system/shellcommand.h b/util/system/shellcommand.h index 8730627fe5b..6141b8ae0e3 100644 --- a/util/system/shellcommand.h +++ b/util/system/shellcommand.h @@ -129,7 +129,7 @@ public: * * @return self */ - inline TShellCommandOptions& SetInputStream(IInputStream* stream) { + inline TShellCommandOptions& SetInputStream(IInputStream* stream) { InputStream = stream; if (InputStream == nullptr) { InputMode = HANDLE_INHERIT; @@ -148,7 +148,7 @@ public: * * @return self */ - inline TShellCommandOptions& SetOutputStream(IOutputStream* stream) { + inline TShellCommandOptions& SetOutputStream(IOutputStream* stream) { OutputStream = stream; return *this; } @@ -162,7 +162,7 @@ public: * * @return self */ - inline TShellCommandOptions& SetErrorStream(IOutputStream* stream) { + inline TShellCommandOptions& SetErrorStream(IOutputStream* stream) { ErrorStream = stream; return *this; } @@ -313,10 +313,10 @@ public: // bool SearchPath // search exe name in $PATH // bool UnicodeConsole // bool EmulateConsole // provide isatty == true - /// @todo command's stdin should be exposet as IOutputStream to support dialogue - IInputStream* InputStream; - IOutputStream* OutputStream; - IOutputStream* ErrorStream; + /// @todo command's stdin should be exposet as IOutputStream to support dialogue + IInputStream* InputStream; + IOutputStream* OutputStream; + IOutputStream* ErrorStream; TUserOptions User; THashMap<TString, TString> Environment; int Nice = 0; @@ -364,7 +364,7 @@ public: * * @return self */ - TShellCommand& operator<<(const TStringBuf argument); + TShellCommand& operator<<(const TStringBuf argument); /** * @brief return the collected output from the command. diff --git a/util/system/shellcommand_ut.cpp b/util/system/shellcommand_ut.cpp index 9d849279d23..5546c41dd30 100644 --- a/util/system/shellcommand_ut.cpp +++ b/util/system/shellcommand_ut.cpp @@ -27,7 +27,7 @@ const char catCommand[] = "/bin/cat"; const size_t textSize = 20000; #endif -class TGuardedStringStream: public IInputStream, public IOutputStream { +class TGuardedStringStream: public IInputStream, public IOutputStream { public: TGuardedStringStream() { Stream_.Reserve(100); @@ -59,8 +59,8 @@ private: TStringStream Stream_; }; -Y_UNIT_TEST_SUITE(TShellQuoteTest) { - Y_UNIT_TEST(TestQuoteArg) { +Y_UNIT_TEST_SUITE(TShellQuoteTest) { + Y_UNIT_TEST(TestQuoteArg) { TString cmd; ShellQuoteArg(cmd, "/pr f/krev/prev.exe"); ShellQuoteArgSp(cmd, "-DVal=\"W Quotes\""); @@ -70,8 +70,8 @@ Y_UNIT_TEST_SUITE(TShellQuoteTest) { } } -Y_UNIT_TEST_SUITE(TShellCommandTest) { - Y_UNIT_TEST(TestNoQuotes) { +Y_UNIT_TEST_SUITE(TShellCommandTest) { + Y_UNIT_TEST(TestNoQuotes) { TShellCommandOptions options; options.SetQuoteArguments(false); TShellCommand cmd("echo hello"); @@ -97,7 +97,7 @@ Y_UNIT_TEST_SUITE(TShellCommandTest) { UNIT_ASSERT(cmd.GetExitCode().Defined() && 0 == cmd.GetExitCode()); } - Y_UNIT_TEST(TestRun) { + Y_UNIT_TEST(TestRun) { TShellCommand cmd("echo"); cmd << "hello"; cmd.Run(); @@ -112,7 +112,7 @@ Y_UNIT_TEST_SUITE(TShellCommandTest) { } // running with no shell is not implemented for win // there should be no problem with it as long as SearchPath is on - Y_UNIT_TEST(TestNoShell) { + Y_UNIT_TEST(TestNoShell) { #if defined(_win_) const char dir[] = "dir"; #else @@ -143,7 +143,7 @@ Y_UNIT_TEST_SUITE(TShellCommandTest) { UNIT_ASSERT(cmd.GetExitCode().Defined() && 0 == cmd.GetExitCode()); } } - Y_UNIT_TEST(TestAsyncRun) { + Y_UNIT_TEST(TestAsyncRun) { TShellCommandOptions options; options.SetAsync(true); #if defined(_win_) @@ -168,7 +168,7 @@ Y_UNIT_TEST_SUITE(TShellCommandTest) { UNIT_ASSERT(cmd.GetExitCode().Defined() && 0 == cmd.GetExitCode()); #endif } - Y_UNIT_TEST(TestQuotes) { + Y_UNIT_TEST(TestQuotes) { TShellCommandOptions options; TString input = TString("a\"a a"); TString output; @@ -185,14 +185,14 @@ Y_UNIT_TEST_SUITE(TShellCommandTest) { #endif UNIT_ASSERT_VALUES_EQUAL(cmd.GetError().size(), 0u); } - Y_UNIT_TEST(TestRunNonexistent) { + Y_UNIT_TEST(TestRunNonexistent) { TShellCommand cmd("iwerognweiofnewio"); // some nonexistent command name cmd.Run().Wait(); UNIT_ASSERT(TShellCommand::SHELL_ERROR == cmd.GetStatus()); UNIT_ASSERT_VALUES_UNEQUAL(cmd.GetError().size(), 0u); UNIT_ASSERT(cmd.GetExitCode().Defined() && 0 != cmd.GetExitCode()); } - Y_UNIT_TEST(TestExitCode) { + Y_UNIT_TEST(TestExitCode) { TShellCommand cmd("grep qwerty qwerty"); // some nonexistent file name cmd.Run().Wait(); UNIT_ASSERT(TShellCommand::SHELL_ERROR == cmd.GetStatus()); @@ -200,7 +200,7 @@ Y_UNIT_TEST_SUITE(TShellCommandTest) { UNIT_ASSERT(cmd.GetExitCode().Defined() && 2 == cmd.GetExitCode()); } // 'type con' and 'copy con con' want real console, not stdin, use sort - Y_UNIT_TEST(TestInput) { + Y_UNIT_TEST(TestInput) { TShellCommandOptions options; TString input = (TString("a") * 2000).append(NL) * textSize; TStringInput inputStream(input); @@ -210,7 +210,7 @@ Y_UNIT_TEST_SUITE(TShellCommandTest) { UNIT_ASSERT_VALUES_EQUAL(input, cmd.GetOutput()); UNIT_ASSERT_VALUES_EQUAL(cmd.GetError().size(), 0u); } - Y_UNIT_TEST(TestOutput) { + Y_UNIT_TEST(TestOutput) { TShellCommandOptions options; TString input = (TString("a") * 2000).append(NL) * textSize; TStringInput inputStream(input); @@ -223,7 +223,7 @@ Y_UNIT_TEST_SUITE(TShellCommandTest) { UNIT_ASSERT_VALUES_EQUAL(input, output); UNIT_ASSERT_VALUES_EQUAL(cmd.GetError().size(), 0u); } - Y_UNIT_TEST(TestIO) { + Y_UNIT_TEST(TestIO) { // descriptive test: use all options TShellCommandOptions options; options.SetAsync(true); @@ -260,12 +260,12 @@ Y_UNIT_TEST_SUITE(TShellCommandTest) { UNIT_ASSERT_VALUES_EQUAL(read.Str(), "alpha" NL "omega" NL "zeta" NL); UNIT_ASSERT(cmd.GetExitCode().Defined() && 0 == cmd.GetExitCode()); } - Y_UNIT_TEST(TestStreamClose) { - struct TStream: public IOutputStream { + Y_UNIT_TEST(TestStreamClose) { + struct TStream: public IOutputStream { size_t NumCloses = 0; void DoWrite(const void* buf, size_t len) override { - Y_UNUSED(buf); - Y_UNUSED(len); + Y_UNUSED(buf); + Y_UNUSED(len); } void DoFinish() override { ++NumCloses; @@ -280,7 +280,7 @@ Y_UNIT_TEST_SUITE(TShellCommandTest) { TShellCommand("echo hello", options).Run().Wait(); UNIT_ASSERT_VALUES_EQUAL(stream.NumCloses, 2); } - Y_UNIT_TEST(TestInterruptSimple) { + Y_UNIT_TEST(TestInterruptSimple) { TShellCommandOptions options; options.SetAsync(true); options.SetCloseInput(false); @@ -296,7 +296,7 @@ Y_UNIT_TEST_SUITE(TShellCommandTest) { } #if !defined(_win_) // this ut is unix-only, port to win using %TEMP% - Y_UNIT_TEST(TestInterrupt) { + Y_UNIT_TEST(TestInterrupt) { TString tmpfile = TString("shellcommand_ut.interrupt.") + ToString(RandomNumber<ui32>()); TShellCommandOptions options; @@ -318,7 +318,7 @@ Y_UNIT_TEST_SUITE(TShellCommandTest) { UNIT_ASSERT(!NFs::Exists(tmpfile)); } // this ut is unix-only (win has no signal mask) - Y_UNIT_TEST(TestSignalMask) { + Y_UNIT_TEST(TestSignalMask) { // block SIGTERM int rc; sigset_t newmask, oldmask; @@ -365,7 +365,7 @@ Y_UNIT_TEST_SUITE(TShellCommandTest) { UNIT_ASSERT(!NFs::Exists(tmpfile)); // restore signal mask - rc = SigProcMask(SIG_SETMASK, &oldmask, nullptr); + rc = SigProcMask(SIG_SETMASK, &oldmask, nullptr); UNIT_ASSERT(rc == 0); } #else @@ -380,10 +380,10 @@ Y_UNIT_TEST_SUITE(TShellCommandTest) { UNIT_ASSERT(cmd.GetExitCode().Defined() && 0 == cmd.GetExitCode()); } #endif - Y_UNIT_TEST(TestInternalError) { + Y_UNIT_TEST(TestInternalError) { TString input = (TString("a") * 2000).append("\n"); TStringInput inputStream(input); - TMemoryOutput outputStream(nullptr, 0); + TMemoryOutput outputStream(nullptr, 0); TShellCommandOptions options; options.SetInputStream(&inputStream); options.SetOutputStream(&outputStream); diff --git a/util/system/shmat.cpp b/util/system/shmat.cpp index 07ff0d6caa4..663e63bc123 100644 --- a/util/system/shmat.cpp +++ b/util/system/shmat.cpp @@ -91,7 +91,7 @@ namespace { TSharedMemory::TSharedMemory() : Handle(INVALID_FHANDLE) - , Data(nullptr) + , Data(nullptr) , Size(0) { } @@ -102,7 +102,7 @@ static void FormatName(char* buf, const TGUID& id) { } bool TSharedMemory::Open(const TGUID& id, int size) { - //Y_ASSERT(Data == 0); + //Y_ASSERT(Data == 0); Id = id; Size = size; @@ -117,7 +117,7 @@ bool TSharedMemory::Open(const TGUID& id, int size) { Data = MapViewOfFile(Handle, FILE_MAP_ALL_ACCESS, 0, 0, size); if (Data == 0) { - //Y_ASSERT(0); + //Y_ASSERT(0); CloseHandle(Handle); Handle = INVALID_OS_HANDLE; @@ -128,7 +128,7 @@ bool TSharedMemory::Open(const TGUID& id, int size) { } bool TSharedMemory::Create(int size) { - //Y_ASSERT(Data == 0); + //Y_ASSERT(Data == 0); Size = size; CreateGuid(&Id); @@ -138,14 +138,14 @@ bool TSharedMemory::Create(int size) { Handle = CreateFileMappingA(INVALID_OS_HANDLE, nullptr, PAGE_READWRITE, 0, size, name); if (Handle == 0) { - //Y_ASSERT(0); + //Y_ASSERT(0); return false; } Data = MapViewOfFile(Handle, FILE_MAP_ALL_ACCESS, 0, 0, size); if (Data == 0) { - //Y_ASSERT(0); + //Y_ASSERT(0); CloseHandle(Handle); Handle = INVALID_OS_HANDLE; @@ -172,7 +172,7 @@ static key_t GetKey(const TGUID& id) { bool TSharedMemory::Open(const TGUID& id, int size) { Y_VERIFY(id, "invalid shared memory guid: %s", GetGuidAsString(id).data()); - //Y_ASSERT(Data == 0); + //Y_ASSERT(Data == 0); Size = size; key_t k = GetKey(id); @@ -182,10 +182,10 @@ bool TSharedMemory::Open(const TGUID& id, int size) { return false; } - Data = shmat(shmId, nullptr, 0); + Data = shmat(shmId, nullptr, 0); - if (Data == nullptr) { - //Y_ASSERT(0); + if (Data == nullptr) { + //Y_ASSERT(0); return false; } @@ -193,7 +193,7 @@ bool TSharedMemory::Open(const TGUID& id, int size) { } bool TSharedMemory::Create(int size) { - //Y_ASSERT(Data == 0); + //Y_ASSERT(Data == 0); Size = size; CreateGuid(&Id); @@ -202,14 +202,14 @@ bool TSharedMemory::Create(int size) { Handle = shmget(k, Size, IPC_CREAT | IPC_EXCL | 0777); if (Handle < 0) { - //Y_ASSERT(0); + //Y_ASSERT(0); return false; } Data = shmat(Handle, nullptr, 0); if (Data == (void*)-1) { - //Y_ASSERT(0); + //Y_ASSERT(0); shmctl(Handle, IPC_RMID, nullptr); Handle = -1; diff --git a/util/system/shmat_ut.cpp b/util/system/shmat_ut.cpp index 9d92243ae7f..45921aaa88b 100644 --- a/util/system/shmat_ut.cpp +++ b/util/system/shmat_ut.cpp @@ -2,8 +2,8 @@ #include <library/cpp/testing/unittest/registar.h> -Y_UNIT_TEST_SUITE(TTestSharedMemory) { - Y_UNIT_TEST(TestInProc) { +Y_UNIT_TEST_SUITE(TTestSharedMemory) { + Y_UNIT_TEST(TestInProc) { TSharedMemory m1; TSharedMemory m2; diff --git a/util/system/sigset.h b/util/system/sigset.h index 8dd02fd8171..ed6f768e02a 100644 --- a/util/system/sigset.h +++ b/util/system/sigset.h @@ -22,7 +22,7 @@ inline int SigEmptySet(sigset_t* set) { #if defined _unix_ return sigemptyset(set); #else - Y_UNUSED(set); + Y_UNUSED(set); return 0; #endif } @@ -31,7 +31,7 @@ inline int SigFillSet(sigset_t* set) { #if defined _unix_ return sigfillset(set); #else - Y_UNUSED(set); + Y_UNUSED(set); return 0; #endif } @@ -40,8 +40,8 @@ inline int SigAddSet(sigset_t* set, int signo) { #if defined _unix_ return sigaddset(set, signo); #else - Y_UNUSED(set); - Y_UNUSED(signo); + Y_UNUSED(set); + Y_UNUSED(signo); return 0; #endif } @@ -50,8 +50,8 @@ inline int SigDelSet(sigset_t* set, int signo) { #if defined _unix_ return sigdelset(set, signo); #else - Y_UNUSED(set); - Y_UNUSED(signo); + Y_UNUSED(set); + Y_UNUSED(signo); return 0; #endif } @@ -60,8 +60,8 @@ inline int SigIsMember(const sigset_t* set, int signo) { #if defined _unix_ return sigismember(const_cast<sigset_t*>(set), signo); #else - Y_UNUSED(set); - Y_UNUSED(signo); + Y_UNUSED(set); + Y_UNUSED(signo); return 0; #endif } @@ -70,9 +70,9 @@ inline int SigProcMask(int how, const sigset_t* set, sigset_t* oset) { #if defined _unix_ return pthread_sigmask(how, set, oset); #else - Y_UNUSED(set); - Y_UNUSED(oset); - Y_UNUSED(how); + Y_UNUSED(set); + Y_UNUSED(oset); + Y_UNUSED(how); return 0; #endif } diff --git a/util/system/spinlock_ut.cpp b/util/system/spinlock_ut.cpp index e8639a6404c..384aafab0bf 100644 --- a/util/system/spinlock_ut.cpp +++ b/util/system/spinlock_ut.cpp @@ -2,7 +2,7 @@ #include "spinlock.h" -Y_UNIT_TEST_SUITE(TSpinLock) { +Y_UNIT_TEST_SUITE(TSpinLock) { template <typename TLock> void TestLock() { TLock lock; @@ -27,11 +27,11 @@ Y_UNIT_TEST_SUITE(TSpinLock) { UNIT_ASSERT(!lock.IsLocked()); } - Y_UNIT_TEST(TSpinLock_IsLocked) { + Y_UNIT_TEST(TSpinLock_IsLocked) { TestLock<TSpinLock>(); } - Y_UNIT_TEST(TAdaptiveLock_IsLocked) { + Y_UNIT_TEST(TAdaptiveLock_IsLocked) { TestLock<TAdaptiveLock>(); } } diff --git a/util/system/src_location.cpp b/util/system/src_location.cpp index 13ff1f24b37..5d9ce4fd135 100644 --- a/util/system/src_location.cpp +++ b/util/system/src_location.cpp @@ -5,7 +5,7 @@ #include <algorithm> template <> -void Out<TSourceLocation>(IOutputStream& o, const TSourceLocation& t) { +void Out<TSourceLocation>(IOutputStream& o, const TSourceLocation& t) { #if defined(_win_) TString file(t.File); std::replace(file.begin(), file.vend(), '\\', '/'); diff --git a/util/system/src_location.h b/util/system/src_location.h index 12ba6e063e9..ed911e0169f 100644 --- a/util/system/src_location.h +++ b/util/system/src_location.h @@ -5,7 +5,7 @@ #include <util/generic/strbuf.h> struct TSourceLocation { - constexpr TSourceLocation(const TStringBuf f, int l) noexcept + constexpr TSourceLocation(const TStringBuf f, int l) noexcept : File(f) , Line(l) { diff --git a/util/system/src_location_ut.cpp b/util/system/src_location_ut.cpp index 5b86cb86efc..400bf6d8d3f 100644 --- a/util/system/src_location_ut.cpp +++ b/util/system/src_location_ut.cpp @@ -8,8 +8,8 @@ static inline TString GenLoc() { return TStringBuilder() << __LOCATION__; } -Y_UNIT_TEST_SUITE(TestLocation) { - Y_UNIT_TEST(Test1) { +Y_UNIT_TEST_SUITE(TestLocation) { + Y_UNIT_TEST(Test1) { UNIT_ASSERT_VALUES_EQUAL(GenLoc(), "util/system/src_location_ut.cpp:8"); static constexpr TSourceLocation location = __LOCATION__; diff --git a/util/system/src_root.h b/util/system/src_root.h index 4f2d9f5ee6c..25f380f7235 100644 --- a/util/system/src_root.h +++ b/util/system/src_root.h @@ -7,19 +7,19 @@ namespace NPrivate { struct TStaticBuf { - constexpr TStaticBuf(const char* data, unsigned len) noexcept + constexpr TStaticBuf(const char* data, unsigned len) noexcept : Data(data) , Len(len) { } template <class T> - constexpr T As() const noexcept { + constexpr T As() const noexcept { return T(Data, Len); } template <class T> - constexpr operator T() const noexcept { + constexpr operator T() const noexcept { return this->As<T>(); } diff --git a/util/system/src_root_ut.cpp b/util/system/src_root_ut.cpp index e9a675eb9ab..57255786d44 100644 --- a/util/system/src_root_ut.cpp +++ b/util/system/src_root_ut.cpp @@ -3,8 +3,8 @@ #include <util/folder/pathsplit.h> #include <library/cpp/testing/unittest/registar.h> -Y_UNIT_TEST_SUITE(TestSourceRoot) { - Y_UNIT_TEST(TestStrip) { +Y_UNIT_TEST_SUITE(TestSourceRoot) { + Y_UNIT_TEST(TestStrip) { // Reconstruct() converts "\" -> "/" on Windows const TString path = TPathSplit(__SOURCE_FILE_IMPL__.As<TStringBuf>()).Reconstruct(); UNIT_ASSERT_EQUAL(path, "util" LOCSLASH_S "system" LOCSLASH_S "src_root_ut.cpp"); diff --git a/util/system/sys_alloc.h b/util/system/sys_alloc.h index 4221a28f8cc..0a4516bc536 100644 --- a/util/system/sys_alloc.h +++ b/util/system/sys_alloc.h @@ -1,14 +1,14 @@ #pragma once -#include <util/system/compiler.h> - +#include <util/system/compiler.h> + #include <cstdlib> #include <new> inline void* y_allocate(size_t n) { void* r = malloc(n); - if (r == nullptr) { + if (r == nullptr) { throw std::bad_alloc(); } @@ -35,7 +35,7 @@ inline void* y_reallocate(void* p, size_t new_sz) { void* r = realloc(p, new_sz); - if (r == nullptr) { + if (r == nullptr) { throw std::bad_alloc(); } diff --git a/util/system/tempfile_ut.cpp b/util/system/tempfile_ut.cpp index e4a0923d0bc..f8e2bb5e5b2 100644 --- a/util/system/tempfile_ut.cpp +++ b/util/system/tempfile_ut.cpp @@ -8,8 +8,8 @@ #include <algorithm> -Y_UNIT_TEST_SUITE(TTempFileHandle) { - Y_UNIT_TEST(Create) { +Y_UNIT_TEST_SUITE(TTempFileHandle) { + Y_UNIT_TEST(Create) { TString path; { TTempFileHandle tmp; diff --git a/util/system/thread.cpp b/util/system/thread.cpp index 6236746c2d9..f51bc31d1de 100644 --- a/util/system/thread.cpp +++ b/util/system/thread.cpp @@ -128,9 +128,9 @@ namespace { //do not do this, kids, at home P_->Ref(); #if _WIN32_WINNT < 0x0502 - Handle = reinterpret_cast<HANDLE>(::_beginthreadex(nullptr, (unsigned)StackSize(*P_), Proxy, (void*)P_.Get(), 0, &ThreadId)); + Handle = reinterpret_cast<HANDLE>(::_beginthreadex(nullptr, (unsigned)StackSize(*P_), Proxy, (void*)P_.Get(), 0, &ThreadId)); #else - Handle = reinterpret_cast<HANDLE>(::_beginthreadex(nullptr, (unsigned)StackSize(*P_), Proxy, (void*)P_.Get(), 0, nullptr)); + Handle = reinterpret_cast<HANDLE>(::_beginthreadex(nullptr, (unsigned)StackSize(*P_), Proxy, (void*)P_.Get(), 0, nullptr)); #endif if (!Handle) { @@ -163,7 +163,7 @@ namespace { public: inline TPosixThread(const TParams& params) : P_(new TParams(params)) - , H_() + , H_() { static_assert(sizeof(H_) == sizeof(TId), "expect sizeof(H_) == sizeof(TId)"); } @@ -173,7 +173,7 @@ namespace { } inline void* Join() { - void* tec = nullptr; + void* tec = nullptr; PCHECK(pthread_join(H_, &tec), "can not join thread"); return tec; @@ -188,7 +188,7 @@ namespace { } inline void Start() { - pthread_attr_t* pattrs = nullptr; + pthread_attr_t* pattrs = nullptr; pthread_attr_t attrs; if (P_->StackSize > 0) { @@ -302,7 +302,7 @@ void* TThread::Join() { return ret; } - return nullptr; + return nullptr; } void TThread::Detach() { @@ -363,8 +363,8 @@ namespace { } } -ISimpleThread::ISimpleThread(size_t stackSize) - : TThread(TParams(ThreadProcWrapper<ISimpleThread>, reinterpret_cast<void*>(this), stackSize)) +ISimpleThread::ISimpleThread(size_t stackSize) + : TThread(TParams(ThreadProcWrapper<ISimpleThread>, reinterpret_cast<void*>(this), stackSize)) { } @@ -470,36 +470,36 @@ void TThread::SetCurrentThreadName(const char* name) { } TString TThread::CurrentThreadName() { -#if defined(_freebsd_) +#if defined(_freebsd_) // TODO: check pthread_get_name_np API availability -#elif defined(_linux_) - // > The buffer should allow space for up to 16 bytes; the returned string will be - // > null-terminated. - // via `man prctl` - char name[16]; - memset(name, 0, sizeof(name)); - Y_VERIFY(prctl(PR_GET_NAME, name, 0, 0, 0) == 0, "pctl failed: %s", strerror(errno)); - return name; -#elif defined(_darwin_) - // available on Mac OS 10.6+ - const auto thread = pthread_self(); - char name[256]; - memset(name, 0, sizeof(name)); - Y_VERIFY(pthread_getname_np(thread, name, sizeof(name)) == 0, "pthread_getname_np failed: %s", strerror(errno)); - return name; +#elif defined(_linux_) + // > The buffer should allow space for up to 16 bytes; the returned string will be + // > null-terminated. + // via `man prctl` + char name[16]; + memset(name, 0, sizeof(name)); + Y_VERIFY(prctl(PR_GET_NAME, name, 0, 0, 0) == 0, "pctl failed: %s", strerror(errno)); + return name; +#elif defined(_darwin_) + // available on Mac OS 10.6+ + const auto thread = pthread_self(); + char name[256]; + memset(name, 0, sizeof(name)); + Y_VERIFY(pthread_getname_np(thread, name, sizeof(name)) == 0, "pthread_getname_np failed: %s", strerror(errno)); + return name; #elif defined(_win_) auto api = Singleton<TWinThreadDescrAPI>(); if (api->HasAPI()) { return api->GetDescr(); } return {}; -#else +#else // no idea -#endif // OS - - return {}; -} - +#endif // OS + + return {}; +} + bool TThread::CanGetCurrentThreadName() { #if defined(_linux_) || defined(_darwin_) return true; diff --git a/util/system/thread.h b/util/system/thread.h index a6e8abdb5be..1db7af6adbb 100644 --- a/util/system/thread.h +++ b/util/system/thread.h @@ -8,7 +8,7 @@ #include <util/generic/string.h> #include "defaults.h" -#include "progname.h" +#include "progname.h" bool SetHighestThreadPriority(); @@ -27,11 +27,11 @@ public: size_t StackSize; void* StackPointer; // See comments for `SetCurrentThreadName` - TString Name = GetProgramName(); + TString Name = GetProgramName(); inline TParams() - : Proc(nullptr) - , Data(nullptr) + : Proc(nullptr) + , Data(nullptr) , StackSize(0) , StackPointer(nullptr) { @@ -103,24 +103,24 @@ public: static TId ImpossibleThreadId() noexcept; static TId CurrentThreadId() noexcept; - + /* * Returns numeric thread id, as visible in e. g. htop. * Consider using this value for logging. */ static TId CurrentThreadNumericId() noexcept; - // NOTE: Content of `name` will be copied. - // - // NOTE: On Linux thread name is limited to 15 symbols which is probably the smallest one among + // NOTE: Content of `name` will be copied. + // + // NOTE: On Linux thread name is limited to 15 symbols which is probably the smallest one among // all platforms. If you provide a name longer than 15 symbols it will be cut. So if you expect // `CurrentThreadName` to return the same name as `name` make sure it's not longer than 15 - // symbols. + // symbols. static void SetCurrentThreadName(const char* name); // NOTE: Will return empty string where CanGetCurrentThreadName() returns false. static TString CurrentThreadName(); - + // NOTE: Depends on a platform version. // Will return true for Darwin, Linux or fresh Windows 10. static bool CanGetCurrentThreadName(); @@ -157,11 +157,11 @@ private: THolder<TImpl> Impl_; }; -class ISimpleThread: public TThread { +class ISimpleThread: public TThread { public: - ISimpleThread(size_t stackSize = 0); + ISimpleThread(size_t stackSize = 0); - virtual ~ISimpleThread() = default; + virtual ~ISimpleThread() = default; virtual void* ThreadProc() = 0; }; diff --git a/util/system/thread_ut.cpp b/util/system/thread_ut.cpp index d820898fd56..d47c4097657 100644 --- a/util/system/thread_ut.cpp +++ b/util/system/thread_ut.cpp @@ -4,10 +4,10 @@ #include <atomic> -Y_UNIT_TEST_SUITE(TSysThreadTest) { +Y_UNIT_TEST_SUITE(TSysThreadTest) { struct TIdTester { inline TIdTester() - : Thr(nullptr) + : Thr(nullptr) , Cur(0) , Real(0) { @@ -16,7 +16,7 @@ Y_UNIT_TEST_SUITE(TSysThreadTest) { static inline void* DoRun(void* ptr) { ((TIdTester*)ptr)->Run(); - return nullptr; + return nullptr; } inline void Run() { @@ -31,7 +31,7 @@ Y_UNIT_TEST_SUITE(TSysThreadTest) { TThread::TId Numeric; }; - Y_UNIT_TEST(TestThreadId) { + Y_UNIT_TEST(TestThreadId) { TIdTester tst; TThread thr(tst.DoRun, &tst); @@ -48,131 +48,131 @@ Y_UNIT_TEST_SUITE(TSysThreadTest) { void* ThreadProc(void*) { TThread::SetCurrentThreadName("CurrentThreadSetNameTest"); - return nullptr; + return nullptr; } void* ThreadProc2(void*) { - return nullptr; + return nullptr; } - void* ThreadProc3(void*) { + void* ThreadProc3(void*) { const auto name = TThread::CurrentThreadName(); - Y_FAKE_READ(name); - return nullptr; - } - - void* ThreadProc4(void*) { - const TString setName = "ThreadName"; + Y_FAKE_READ(name); + return nullptr; + } + + void* ThreadProc4(void*) { + const TString setName = "ThreadName"; TThread::SetCurrentThreadName(setName.data()); - + const auto getName = TThread::CurrentThreadName(); if (TThread::CanGetCurrentThreadName()) { UNIT_ASSERT_VALUES_EQUAL(setName, getName); } else { UNIT_ASSERT_VALUES_EQUAL("", getName); } - return nullptr; - } - - void* ThreadProcChild(void*) { + return nullptr; + } + + void* ThreadProcChild(void*) { const auto name = TThread::CurrentThreadName(); - const auto defaultName = GetProgramName(); - - (void)name; - (void)defaultName; - -#if defined(_darwin_) || defined(_linux_) - UNIT_ASSERT_VALUES_EQUAL(name, defaultName); -#endif - return nullptr; - } - - void* ThreadProcParent(void*) { - const TString setName = "Parent"; + const auto defaultName = GetProgramName(); + + (void)name; + (void)defaultName; + +#if defined(_darwin_) || defined(_linux_) + UNIT_ASSERT_VALUES_EQUAL(name, defaultName); +#endif + return nullptr; + } + + void* ThreadProcParent(void*) { + const TString setName = "Parent"; TThread::SetCurrentThreadName(setName.data()); - - TThread thread(&ThreadProcChild, nullptr); - - thread.Start(); - thread.Join(); - + + TThread thread(&ThreadProcChild, nullptr); + + thread.Start(); + thread.Join(); + const auto getName = TThread::CurrentThreadName(); if (TThread::CanGetCurrentThreadName()) { UNIT_ASSERT_VALUES_EQUAL(setName, getName); } else { UNIT_ASSERT_VALUES_EQUAL("", getName); } - return nullptr; - } - - Y_UNIT_TEST(TestSetThreadName) { - TThread thread(&ThreadProc, nullptr); + return nullptr; + } + + Y_UNIT_TEST(TestSetThreadName) { + TThread thread(&ThreadProc, nullptr); // just check it doesn't crash thread.Start(); thread.Join(); } - Y_UNIT_TEST(TestSetThreadName2) { - TThread thread(TThread::TParams(&ThreadProc, nullptr, 0).SetName("XXX")); - - thread.Start(); - thread.Join(); - } - - Y_UNIT_TEST(TestGetThreadName) { - TThread thread(&ThreadProc3, nullptr); - thread.Start(); - thread.Join(); - } - - Y_UNIT_TEST(TestSetGetThreadName) { - TThread thread(&ThreadProc4, nullptr); - thread.Start(); - thread.Join(); - } + Y_UNIT_TEST(TestSetThreadName2) { + TThread thread(TThread::TParams(&ThreadProc, nullptr, 0).SetName("XXX")); - Y_UNIT_TEST(TestSetGetThreadNameInChildThread) { - TThread thread(&ThreadProcParent, nullptr); thread.Start(); thread.Join(); } - Y_UNIT_TEST(TestDoubleJoin) { - TThread thread(&ThreadProc, nullptr); + Y_UNIT_TEST(TestGetThreadName) { + TThread thread(&ThreadProc3, nullptr); + thread.Start(); + thread.Join(); + } + + Y_UNIT_TEST(TestSetGetThreadName) { + TThread thread(&ThreadProc4, nullptr); + thread.Start(); + thread.Join(); + } + + Y_UNIT_TEST(TestSetGetThreadNameInChildThread) { + TThread thread(&ThreadProcParent, nullptr); + thread.Start(); + thread.Join(); + } + + Y_UNIT_TEST(TestDoubleJoin) { + TThread thread(&ThreadProc, nullptr); thread.Start(); thread.Join(); - UNIT_ASSERT_EQUAL(thread.Join(), nullptr); + UNIT_ASSERT_EQUAL(thread.Join(), nullptr); } - Y_UNIT_TEST(TestDoubleStart) { - TThread thread(&ThreadProc, nullptr); + Y_UNIT_TEST(TestDoubleStart) { + TThread thread(&ThreadProc, nullptr); thread.Start(); UNIT_ASSERT_EXCEPTION(thread.Start(), yexception); thread.Join(); } - Y_UNIT_TEST(TestNoStart) { - TThread thread(&ThreadProc, nullptr); + Y_UNIT_TEST(TestNoStart) { + TThread thread(&ThreadProc, nullptr); } - Y_UNIT_TEST(TestNoStartJoin) { - TThread thread(&ThreadProc, nullptr); + Y_UNIT_TEST(TestNoStartJoin) { + TThread thread(&ThreadProc, nullptr); - UNIT_ASSERT_EQUAL(thread.Join(), nullptr); + UNIT_ASSERT_EQUAL(thread.Join(), nullptr); } - Y_UNIT_TEST(TestStackPointer) { + Y_UNIT_TEST(TestStackPointer) { TArrayHolder<char> buf(new char[64000]); - TThread thr(TThread::TParams(ThreadProc2, nullptr).SetStackPointer(buf.Get()).SetStackSize(64000)); + TThread thr(TThread::TParams(ThreadProc2, nullptr).SetStackPointer(buf.Get()).SetStackSize(64000)); thr.Start(); UNIT_ASSERT_VALUES_EQUAL(thr.Join(), nullptr); } - Y_UNIT_TEST(TestStackLimits) { + Y_UNIT_TEST(TestStackLimits) { TCurrentThreadLimits sl; UNIT_ASSERT(sl.StackBegin); diff --git a/util/system/tls.cpp b/util/system/tls.cpp index c2f1a04a148..74400efea24 100644 --- a/util/system/tls.cpp +++ b/util/system/tls.cpp @@ -41,7 +41,7 @@ namespace { class TStoredValue: public TIntrusiveListItem<TStoredValue> { public: inline TStoredValue(const TKey* key) - : Data_(nullptr) + : Data_(nullptr) , Dtor_(key->Dtor) { } @@ -98,7 +98,7 @@ namespace { }; inline TPerThreadStorage* MyStorage() { -#if defined(Y_HAVE_FAST_POD_TLS) +#if defined(Y_HAVE_FAST_POD_TLS) Y_POD_STATIC_THREAD(TPerThreadStorage*) my(nullptr); @@ -123,14 +123,14 @@ namespace { class TMasterTls: public TGenericTlsBase { public: inline TMasterTls() { - Y_VERIFY(!pthread_key_create(&Key_, Dtor), "pthread_key_create failed"); + Y_VERIFY(!pthread_key_create(&Key_, Dtor), "pthread_key_create failed"); } inline ~TMasterTls() override { //explicitly call dtor for main thread Dtor(pthread_getspecific(Key_)); - Y_VERIFY(!pthread_key_delete(Key_), "pthread_key_delete failed"); + Y_VERIFY(!pthread_key_delete(Key_), "pthread_key_delete failed"); } static inline TMasterTls* Instance() { @@ -144,7 +144,7 @@ namespace { if (!ret) { ret = new TPerThreadStorage(); - Y_VERIFY(!pthread_setspecific(Key_, ret), "pthread_setspecific failed"); + Y_VERIFY(!pthread_setspecific(Key_, ret), "pthread_setspecific failed"); } return (TPerThreadStorage*)ret; diff --git a/util/system/tls.h b/util/system/tls.h index 3c4f56dbeb7..3cc297b8aea 100644 --- a/util/system/tls.h +++ b/util/system/tls.h @@ -20,7 +20,7 @@ #endif /** - @def Y_THREAD(TType) + @def Y_THREAD(TType) A thread-local wrapper for a given class. Suitable for POD and classes with a constructor with a single argument. @@ -46,7 +46,7 @@ Example: @code //the field declaration in header - Y_THREAD(TBuffer) TmpBuffer; + Y_THREAD(TBuffer) TmpBuffer; //...later somewhere in cpp... TmpBuffer.Clear(); for (size_t i = 0; i < sz && TrieCursor[i].second.IsFork(); ++i) { @@ -57,10 +57,10 @@ Example: @code //the field decalrataion in header - Y_THREAD(TMyWriter*) ThreadLocalWriter; + Y_THREAD(TMyWriter*) ThreadLocalWriter; //...later somewhere in cpp... TMyWriter*& writerRef = ThreadLocalWriter.Get(); - if (writerRef == nullptr) { + if (writerRef == nullptr) { THolder<TMyWriter> threadLocalWriter( new TMyWriter( *Session, MinLogError, @@ -84,7 +84,7 @@ Example: @code - Y_THREAD(TScoreCalcer*) ScoreCalcerPtr; + Y_THREAD(TScoreCalcer*) ScoreCalcerPtr; static TScoreCalcer* GetScoreCalcer(yint maxElemCount) { if (ScoreCalcerPtr == 0) { ScoreCalcerPtr = new TScoreCalcer(); @@ -98,35 +98,35 @@ **/ /** - @def Y_STATIC_THREAD(TType) + @def Y_STATIC_THREAD(TType) - Equivalent to "static Y_THREAD(TType)" + Equivalent to "static Y_THREAD(TType)" - @see Y_THREAD(TType) + @see Y_THREAD(TType) **/ /** - @def Y_POD_THREAD(TType) + @def Y_POD_THREAD(TType) - Same interface as Y_THREAD(TType), but TType must be a POD. - Implemented (based on the compiler) as Y_THREAD(TType) or as native tls. + Same interface as Y_THREAD(TType), but TType must be a POD. + Implemented (based on the compiler) as Y_THREAD(TType) or as native tls. - @see Y_THREAD(TType) + @see Y_THREAD(TType) **/ /** @def STATIC_POD_THREAD(TType) - Equivalent to "static Y_POD_THREAD(TType)" + Equivalent to "static Y_POD_THREAD(TType)" - @see Y_POD_THREAD(TType) + @see Y_POD_THREAD(TType) **/ -#define Y_THREAD(T) ::NTls::TValue<T> -#define Y_STATIC_THREAD(T) static Y_THREAD(T) +#define Y_THREAD(T) ::NTls::TValue<T> +#define Y_STATIC_THREAD(T) static Y_THREAD(T) // gcc and msvc support automatic tls for POD types -#if defined(Y_DISABLE_THRKEY_OPTIMIZATION) +#if defined(Y_DISABLE_THRKEY_OPTIMIZATION) // nothing to do #elif defined(__clang__) #define Y_POD_THREAD(T) thread_local T @@ -140,7 +140,7 @@ #define Y_POD_STATIC_THREAD(T) __declspec(thread) static T #endif -#if !defined(Y_POD_THREAD) || !defined(Y_POD_STATIC_THREAD) +#if !defined(Y_POD_THREAD) || !defined(Y_POD_STATIC_THREAD) #define Y_POD_THREAD(T) Y_THREAD(T) #define Y_POD_STATIC_THREAD(T) Y_STATIC_THREAD(T) #else diff --git a/util/system/tls_ut.cpp b/util/system/tls_ut.cpp index e84d34b42a3..586919b7812 100644 --- a/util/system/tls_ut.cpp +++ b/util/system/tls_ut.cpp @@ -3,7 +3,7 @@ #include <library/cpp/testing/unittest/registar.h> -Y_UNIT_TEST_SUITE(TTestTLS) { +Y_UNIT_TEST_SUITE(TTestTLS) { struct X { inline X() : V(0) @@ -22,10 +22,10 @@ Y_UNIT_TEST_SUITE(TTestTLS) { V; }; - Y_UNIT_TEST(TestHugeSetup) { + Y_UNIT_TEST(TestHugeSetup) { TArrayHolder<X> x(new X[100000]); - struct TThr: public ISimpleThread { + struct TThr: public ISimpleThread { inline TThr(X* ptr) : P(ptr) { diff --git a/util/system/type_name.cpp b/util/system/type_name.cpp index 0377da42128..811b90b85f8 100644 --- a/util/system/type_name.cpp +++ b/util/system/type_name.cpp @@ -29,7 +29,7 @@ const char* NPrivate::TCppDemangler::Demangle(const char* name) { return name; #else int status; - TmpBuf_.Reset(__cxxabiv1::__cxa_demangle(name, nullptr, nullptr, &status)); + TmpBuf_.Reset(__cxxabiv1::__cxa_demangle(name, nullptr, nullptr, &status)); if (!TmpBuf_) { return name; diff --git a/util/system/type_name_ut.cpp b/util/system/type_name_ut.cpp index 86597f4232c..518b257965b 100644 --- a/util/system/type_name_ut.cpp +++ b/util/system/type_name_ut.cpp @@ -8,8 +8,8 @@ #include <stdexcept> #include <string> -Y_UNIT_TEST_SUITE(TDemangleTest) { - Y_UNIT_TEST(SimpleTest) { +Y_UNIT_TEST_SUITE(TDemangleTest) { + Y_UNIT_TEST(SimpleTest) { // just check it does not crash or leak CppDemangle("hello"); CppDemangle(""); diff --git a/util/system/types_ut.cpp b/util/system/types_ut.cpp index 19e40cef460..4a7c96cfa75 100644 --- a/util/system/types_ut.cpp +++ b/util/system/types_ut.cpp @@ -2,8 +2,8 @@ #include <library/cpp/testing/unittest/registar.h> -Y_UNIT_TEST_SUITE(TestTypes) { - Y_UNIT_TEST(TestScanf) { +Y_UNIT_TEST_SUITE(TestTypes) { + Y_UNIT_TEST(TestScanf) { i32 val32 = 0; sscanf("-123", "%" SCNi32, &val32); UNIT_ASSERT(val32 == -123); diff --git a/util/system/unaligned_mem.h b/util/system/unaligned_mem.h index 4b84686f2f2..6985270d9e5 100644 --- a/util/system/unaligned_mem.h +++ b/util/system/unaligned_mem.h @@ -1,7 +1,7 @@ #pragma once #include "defaults.h" -#include "yassert.h" +#include "yassert.h" #include <string.h> #include <type_traits> @@ -23,45 +23,45 @@ template <class T> inline void WriteUnaligned(void* to, const std::remove_reference_t<T>& t) noexcept { memcpy(to, &t, sizeof(T)); } - -template <class T, unsigned Align = sizeof(T)> -class TUnalignedMemoryIterator { -public: - inline TUnalignedMemoryIterator(const void* buf, size_t len) - : C_((const unsigned char*)buf) - , E_(C_ + len) - , L_(E_ - (len % Align)) - { - Y_FAKE_READ(buf); - } - - inline bool AtEnd() const noexcept { - return C_ == L_; - } - - inline T Cur() const noexcept { + +template <class T, unsigned Align = sizeof(T)> +class TUnalignedMemoryIterator { +public: + inline TUnalignedMemoryIterator(const void* buf, size_t len) + : C_((const unsigned char*)buf) + , E_(C_ + len) + , L_(E_ - (len % Align)) + { + Y_FAKE_READ(buf); + } + + inline bool AtEnd() const noexcept { + return C_ == L_; + } + + inline T Cur() const noexcept { Y_ASSERT(C_ < L_ || sizeof(T) < Align); - return ::ReadUnaligned<T>(C_); - } - - inline T Next() noexcept { - T ret(Cur()); - - C_ += sizeof(T); - - return ret; - } - - inline const unsigned char* Last() const noexcept { - return C_; - } - - inline size_t Left() const noexcept { - return E_ - C_; - } - -private: - const unsigned char* C_; - const unsigned char* E_; - const unsigned char* L_; -}; + return ::ReadUnaligned<T>(C_); + } + + inline T Next() noexcept { + T ret(Cur()); + + C_ += sizeof(T); + + return ret; + } + + inline const unsigned char* Last() const noexcept { + return C_; + } + + inline size_t Left() const noexcept { + return E_ - C_; + } + +private: + const unsigned char* C_; + const unsigned char* E_; + const unsigned char* L_; +}; diff --git a/util/system/unaligned_mem_ut.cpp b/util/system/unaligned_mem_ut.cpp index 9de3f3e9311..fddf98f8dee 100644 --- a/util/system/unaligned_mem_ut.cpp +++ b/util/system/unaligned_mem_ut.cpp @@ -29,8 +29,8 @@ namespace { } #endif -Y_UNIT_TEST_SUITE(UnalignedMem) { - Y_UNIT_TEST(TestReadWrite) { +Y_UNIT_TEST_SUITE(UnalignedMem) { + Y_UNIT_TEST(TestReadWrite) { alignas(ui64) char buf[100]; WriteUnaligned<ui16>(buf + 1, (ui16)1); @@ -42,7 +42,7 @@ Y_UNIT_TEST_SUITE(UnalignedMem) { UNIT_ASSERT_VALUES_EQUAL(ReadUnaligned<ui64>(buf + 1 + 2 + 4), 3); } - Y_UNIT_TEST(TestReadWriteRuntime) { + Y_UNIT_TEST(TestReadWriteRuntime) { // Unlike the test above, this test avoids compile-time execution by a smart compiler. // It is required to catch the SIGSEGV in case compiler emits an alignment-sensitive instruction. @@ -69,14 +69,14 @@ Y_UNIT_TEST_SUITE(UnalignedMem) { UNIT_ASSERT_VALUES_EQUAL(val3, 3); } #ifdef Y_HAVE_INT128 - Y_UNIT_TEST(TestReadWrite128) { + Y_UNIT_TEST(TestReadWrite128) { alignas(TUInt128) char buf[100] = {0}; WriteUnaligned<TUInt128>(buf + 1, TUInt128::Max()); auto val = ReadUnaligned<TUInt128>(buf + 1); UNIT_ASSERT(val == TUInt128::Max()); } - Y_UNIT_TEST(TestReadWriteRuntime128) { + Y_UNIT_TEST(TestReadWriteRuntime128) { // Unlike the test above, this test avoids compile-time execution by a smart compiler. // It is required to catch the SIGSEGV in case compiler emits an alignment-sensitive instruction. diff --git a/util/system/user_ut.cpp b/util/system/user_ut.cpp index 4f8a5ce2efc..49ed2644751 100644 --- a/util/system/user_ut.cpp +++ b/util/system/user_ut.cpp @@ -2,8 +2,8 @@ #include <library/cpp/testing/unittest/registar.h> -Y_UNIT_TEST_SUITE(TestUser) { - Y_UNIT_TEST(TestNotEmpty) { +Y_UNIT_TEST_SUITE(TestUser) { + Y_UNIT_TEST(TestNotEmpty) { UNIT_ASSERT(GetUsername()); } } diff --git a/util/system/utime.cpp b/util/system/utime.cpp index c7bfc4bf3da..347467f28fe 100644 --- a/util/system/utime.cpp +++ b/util/system/utime.cpp @@ -9,7 +9,7 @@ #endif int TouchFile(const char* filePath) { - return utime(filePath, nullptr); + return utime(filePath, nullptr); } int SetModTime(const char* filePath, time_t modtime, time_t actime) { diff --git a/util/system/yassert.cpp b/util/system/yassert.cpp index 0f586648b78..cf53876f499 100644 --- a/util/system/yassert.cpp +++ b/util/system/yassert.cpp @@ -1,21 +1,21 @@ #include "yassert.h" -#include "backtrace.h" +#include "backtrace.h" #include "guard.h" #include "spinlock.h" -#include "src_root.h" - +#include "src_root.h" + #include <util/datetime/base.h> -#include <util/generic/singleton.h> +#include <util/generic/singleton.h> #include <util/generic/strbuf.h> #include <util/generic/string.h> -#include <util/stream/output.h> -#include <util/stream/str.h> -#include <util/string/printf.h> +#include <util/stream/output.h> +#include <util/stream/str.h> +#include <util/string/printf.h> -#include <cstdlib> -#include <stdarg.h> -#include <stdio.h> +#include <cstdlib> +#include <stdarg.h> +#include <stdio.h> #ifdef CLANG_COVERAGE extern "C" { diff --git a/util/system/yassert.h b/util/system/yassert.h index 529823440cb..530a82174c8 100644 --- a/util/system/yassert.h +++ b/util/system/yassert.h @@ -54,7 +54,7 @@ inline void YaDebugBreak() { __debugbreak(); } -#undef Y_ASSERT +#undef Y_ASSERT #if !defined(NDEBUG) && !defined(__GCCXML__) #define Y_ASSERT(a) \ @@ -95,16 +95,16 @@ namespace NPrivate { } /// Assert that does not depend on NDEBUG macro and outputs message like printf -#define Y_VERIFY(expr, ...) \ +#define Y_VERIFY(expr, ...) \ do { \ if (Y_UNLIKELY(!(expr))) { \ ::NPrivate::Panic(__SOURCE_FILE_IMPL__, __LINE__, __FUNCTION__, #expr, " " __VA_ARGS__); \ } \ } while (false) -#define Y_FAIL(...) \ - do { \ - ::NPrivate::Panic(__SOURCE_FILE_IMPL__, __LINE__, __FUNCTION__, nullptr, " " __VA_ARGS__); \ +#define Y_FAIL(...) \ + do { \ + ::NPrivate::Panic(__SOURCE_FILE_IMPL__, __LINE__, __FUNCTION__, nullptr, " " __VA_ARGS__); \ } while (false) #ifndef NDEBUG diff --git a/util/system/yassert_ut.cpp b/util/system/yassert_ut.cpp index ddd392666c8..56d6122d0fd 100644 --- a/util/system/yassert_ut.cpp +++ b/util/system/yassert_ut.cpp @@ -4,32 +4,32 @@ #include <library/cpp/testing/unittest/registar.h> -Y_UNIT_TEST_SUITE(YassertTest) { - Y_UNIT_TEST(TestAcsLikeFunctionCall) { +Y_UNIT_TEST_SUITE(YassertTest) { + Y_UNIT_TEST(TestAcsLikeFunctionCall) { if (true) { - Y_ASSERT(true); // this cannot be compiled if Y_ASSERT is "if (!cond) { ... }" + Y_ASSERT(true); // this cannot be compiled if Y_ASSERT is "if (!cond) { ... }" } else { - Y_ASSERT(false); + Y_ASSERT(false); } bool var = false; if (false) { - Y_ASSERT(false); + Y_ASSERT(false); } else { - var = true; // this is unreachable if Y_ASSERT is "if (!cond) { ... }" + var = true; // this is unreachable if Y_ASSERT is "if (!cond) { ... }" } UNIT_ASSERT(var); } - Y_UNIT_TEST(TestFailCompiles) { + Y_UNIT_TEST(TestFailCompiles) { if (false) { - Y_FAIL("%d is a lucky number", 7); - Y_FAIL(); + Y_FAIL("%d is a lucky number", 7); + Y_FAIL(); } } - Y_UNIT_TEST(TestVerify) { - Y_VERIFY(true, "hi %s", "there"); - Y_VERIFY(true); + Y_UNIT_TEST(TestVerify) { + Y_VERIFY(true, "hi %s", "there"); + Y_VERIFY(true); } } diff --git a/util/tests/benchmark/ya.make b/util/tests/benchmark/ya.make index 134cbfabd15..6d10166908c 100644 --- a/util/tests/benchmark/ya.make +++ b/util/tests/benchmark/ya.make @@ -1,11 +1,11 @@ OWNER(g:util) SUBSCRIBER(g:util-subscribers) - -RECURSE_ROOT_RELATIVE( - util/charset/benchmark - util/generic/benchmark - util/random/benchmark + +RECURSE_ROOT_RELATIVE( + util/charset/benchmark + util/generic/benchmark + util/random/benchmark util/memory/benchmark - util/string/benchmark - util/system/benchmark -) + util/string/benchmark + util/system/benchmark +) diff --git a/util/tests/fuzzing/ya.make b/util/tests/fuzzing/ya.make index d9a8f9df9f7..e80168e3bc4 100644 --- a/util/tests/fuzzing/ya.make +++ b/util/tests/fuzzing/ya.make @@ -1,7 +1,7 @@ OWNER(g:util) SUBSCRIBER(g:util-subscribers) - -RECURSE_ROOT_RELATIVE( - util/string/fuzzing + +RECURSE_ROOT_RELATIVE( + util/string/fuzzing util/generic/fuzz -) +) diff --git a/util/thread/factory.cpp b/util/thread/factory.cpp index 48e898f32dc..0336a258762 100644 --- a/util/thread/factory.cpp +++ b/util/thread/factory.cpp @@ -35,7 +35,7 @@ namespace { static void* ThreadProc(void* func) { ((IThreadAble*)(func))->Execute(); - return nullptr; + return nullptr; } private: diff --git a/util/thread/fwd.cpp b/util/thread/fwd.cpp index 4214b6df83e..2261ef316c5 100644 --- a/util/thread/fwd.cpp +++ b/util/thread/fwd.cpp @@ -1 +1 @@ -#include "fwd.h" +#include "fwd.h" diff --git a/util/thread/fwd.h b/util/thread/fwd.h index 6f1caed21c4..78f81c8c520 100644 --- a/util/thread/fwd.h +++ b/util/thread/fwd.h @@ -1,30 +1,30 @@ -#pragma once - -#include <stlfwd> - -struct TDefaultLFCounter; - -template <class T, class TCounter = TDefaultLFCounter> -class TLockFreeQueue; - -template <class T, class TCounter = TDefaultLFCounter> -class TAutoLockFreeQueue; - -template <class T> +#pragma once + +#include <stlfwd> + +struct TDefaultLFCounter; + +template <class T, class TCounter = TDefaultLFCounter> +class TLockFreeQueue; + +template <class T, class TCounter = TDefaultLFCounter> +class TAutoLockFreeQueue; + +template <class T> class TLockFreeStack; - + class IThreadFactory; - -struct IObjectInQueue; + +struct IObjectInQueue; class TThreadFactoryHolder; - -using TThreadFunction = std::function<void()>; - + +using TThreadFunction = std::function<void()>; + class IThreadPool; class TFakeThreadPool; class TThreadPool; class TAdaptiveThreadPool; class TSimpleThreadPool; - -template <class TQueueType, class TSlave> + +template <class TQueueType, class TSlave> class TThreadPoolBinder; diff --git a/util/thread/lfqueue.h b/util/thread/lfqueue.h index ab523631e4f..116e1d4c85d 100644 --- a/util/thread/lfqueue.h +++ b/util/thread/lfqueue.h @@ -1,7 +1,7 @@ #pragma once -#include "fwd.h" - +#include "fwd.h" + #include <util/generic/ptr.h> #include <util/system/atomic.h> #include <util/system/yassert.h> @@ -23,8 +23,8 @@ struct TDefaultLFCounter { // @tparam TCounter, a observer class to count number of items in queue // be carifull, IncCount and DecCount can be called on a moved object and // it is TCounter class responsibility to check validity of passed object -template <class T, class TCounter> -class TLockFreeQueue: public TNonCopyable { +template <class T, class TCounter> +class TLockFreeQueue: public TNonCopyable { struct TListNode { template <typename U> TListNode(U&& u, TListNode* next) @@ -51,10 +51,10 @@ class TLockFreeQueue: public TNonCopyable { TRootNode* volatile NextFree; TRootNode() - : PushQueue(nullptr) - , PopQueue(nullptr) - , ToDelete(nullptr) - , NextFree(nullptr) + : PushQueue(nullptr) + , PopQueue(nullptr) + , ToDelete(nullptr) + , NextFree(nullptr) { } void CopyCounter(TRootNode* x) { @@ -78,7 +78,7 @@ class TLockFreeQueue: public TNonCopyable { void TryToFreeAsyncMemory() { TAtomic keepCounter = AtomicAdd(FreeingTaskCounter, 0); TRootNode* current = AtomicGet(FreePtr); - if (current == nullptr) + if (current == nullptr) return; if (AtomicAdd(FreememCounter, 0) == 1) { // we are the last thread, try to cleanup @@ -86,7 +86,7 @@ class TLockFreeQueue: public TNonCopyable { if (keepCounter != AtomicAdd(FreeingTaskCounter, 0)) { return; } - if (AtomicCas(&FreePtr, (TRootNode*)nullptr, current)) { + if (AtomicCas(&FreePtr, (TRootNode*)nullptr, current)) { // free list while (current) { TRootNode* p = AtomicGet(current->NextFree); @@ -131,29 +131,29 @@ class TLockFreeQueue: public TNonCopyable { TListNode* PrevFirst; TListInvertor() - : Copy(nullptr) - , Tail(nullptr) - , PrevFirst(nullptr) + : Copy(nullptr) + , Tail(nullptr) + , PrevFirst(nullptr) { } ~TListInvertor() { EraseList(Copy); } void CopyWasUsed() { - Copy = nullptr; - Tail = nullptr; - PrevFirst = nullptr; + Copy = nullptr; + Tail = nullptr; + PrevFirst = nullptr; } void DoCopy(TListNode* ptr) { TListNode* newFirst = ptr; - TListNode* newCopy = nullptr; - TListNode* newTail = nullptr; + TListNode* newCopy = nullptr; + TListNode* newTail = nullptr; while (ptr) { if (ptr == PrevFirst) { // short cut, we have copied this part already AtomicSet(Tail->Next, newCopy); newCopy = Copy; - Copy = nullptr; // do not destroy prev try + Copy = nullptr; // do not destroy prev try if (!newTail) newTail = Tail; // tried to invert same list break; @@ -188,7 +188,7 @@ class TLockFreeQueue: public TNonCopyable { } if (AtomicCas(&JobQueue, newRoot, curRoot)) { - AsyncUnref(curRoot, nullptr); + AsyncUnref(curRoot, nullptr); break; } } @@ -229,7 +229,7 @@ public: : JobQueue(new TRootNode) , FreememCounter(0) , FreeingTaskCounter(0) - , FreePtr(nullptr) + , FreePtr(nullptr) { } ~TLockFreeQueue() { @@ -272,7 +272,7 @@ public: EnqueueImpl(node, tail); } bool Dequeue(T* data) { - TRootNode* newRoot = nullptr; + TRootNode* newRoot = nullptr; TListInvertor listInvertor; AsyncRef(); for (;;) { @@ -310,7 +310,7 @@ public: newRoot->CopyCounter(curRoot); Y_ASSERT(AtomicGet(curRoot->PopQueue) == nullptr); if (AtomicCas(&JobQueue, newRoot, curRoot)) { - newRoot = nullptr; + newRoot = nullptr; listInvertor.CopyWasUsed(); AsyncDel(curRoot, AtomicGet(curRoot->PushQueue)); } else { @@ -359,7 +359,7 @@ public: } }; -template <class T, class TCounter> +template <class T, class TCounter> class TAutoLockFreeQueue { public: using TRef = THolder<T>; @@ -372,7 +372,7 @@ public: } inline bool Dequeue(TRef* t) { - T* res = nullptr; + T* res = nullptr; if (Queue.Dequeue(&res)) { t->Reset(res); diff --git a/util/thread/lfqueue_ut.cpp b/util/thread/lfqueue_ut.cpp index 83bca100cf9..aa6b21afeb3 100644 --- a/util/thread/lfqueue_ut.cpp +++ b/util/thread/lfqueue_ut.cpp @@ -102,8 +102,8 @@ int TOperationsChecker::CopyCtor_ = 0; int TOperationsChecker::MoveAssign_ = 0; int TOperationsChecker::CopyAssign_ = 0; -Y_UNIT_TEST_SUITE(TLockFreeQueueTests) { - Y_UNIT_TEST(TestMoveEnqueue) { +Y_UNIT_TEST_SUITE(TLockFreeQueueTests) { + Y_UNIT_TEST(TestMoveEnqueue) { TMoveTest value(0xFF, 0xAA); TMoveTest tmp; @@ -121,7 +121,7 @@ Y_UNIT_TEST_SUITE(TLockFreeQueueTests) { UNIT_ASSERT_VALUES_EQUAL(tmp.Value(), 0xAA); } - Y_UNIT_TEST(TestSimpleEnqueueDequeue) { + Y_UNIT_TEST(TestSimpleEnqueueDequeue) { TLockFreeQueue<int> queue; int i = -1; @@ -153,7 +153,7 @@ Y_UNIT_TEST_SUITE(TLockFreeQueueTests) { UNIT_ASSERT_VALUES_EQUAL(i, tmp); } - Y_UNIT_TEST(TestSimpleEnqueueAllDequeue) { + Y_UNIT_TEST(TestSimpleEnqueueAllDequeue) { TLockFreeQueue<int> queue; int i = -1; @@ -302,7 +302,7 @@ Y_UNIT_TEST_SUITE(TLockFreeQueueTests) { UNIT_ASSERT_VALUES_EQUAL(v[2], 3); } - Y_UNIT_TEST(CleanInDestructor) { + Y_UNIT_TEST(CleanInDestructor) { TSimpleSharedPtr<bool> p(new bool); UNIT_ASSERT_VALUES_EQUAL(1u, p.RefCount()); @@ -318,7 +318,7 @@ Y_UNIT_TEST_SUITE(TLockFreeQueueTests) { UNIT_ASSERT_VALUES_EQUAL(1, p.RefCount()); } - Y_UNIT_TEST(CheckOperationsCount) { + Y_UNIT_TEST(CheckOperationsCount) { TOperationsChecker o; o.Check(1, 0, 0, 0, 0); TLockFreeQueue<TOperationsChecker> queue; diff --git a/util/thread/lfstack.h b/util/thread/lfstack.h index ca3d95f3c39..bfdb9f68792 100644 --- a/util/thread/lfstack.h +++ b/util/thread/lfstack.h @@ -16,7 +16,7 @@ class TLockFreeStack: TNonCopyable { template <class U> explicit TNode(U&& val) : Value(std::forward<U>(val)) - , Next(nullptr) + , Next(nullptr) { } }; @@ -31,7 +31,7 @@ class TLockFreeStack: TNonCopyable { return; if (AtomicAdd(DequeueCount, 0) == 1) { // node current is in free list, we are the last thread so try to cleanup - if (AtomicCas(&FreePtr, (TNode*)nullptr, current)) + if (AtomicCas(&FreePtr, (TNode*)nullptr, current)) EraseList(current); } } @@ -57,8 +57,8 @@ class TLockFreeStack: TNonCopyable { public: TLockFreeStack() - : Head(nullptr) - , FreePtr(nullptr) + : Head(nullptr) + , FreePtr(nullptr) , DequeueCount(0) { } @@ -127,7 +127,7 @@ public: void DequeueAll(TCollection* res) { AtomicAdd(DequeueCount, 1); for (TNode* current = AtomicGet(Head); current; current = AtomicGet(Head)) { - if (AtomicCas(&Head, (TNode*)nullptr, current)) { + if (AtomicCas(&Head, (TNode*)nullptr, current)) { for (TNode* x = current; x;) { res->push_back(std::move(x->Value)); x = x->Next; @@ -171,7 +171,7 @@ public: template <typename TCollection> void DequeueAllSingleConsumer(TCollection* res) { for (TNode* current = AtomicGet(Head); current; current = AtomicGet(Head)) { - if (AtomicCas(&Head, (TNode*)nullptr, current)) { + if (AtomicCas(&Head, (TNode*)nullptr, current)) { for (TNode* x = current; x;) { res->push_back(std::move(x->Value)); x = x->Next; @@ -182,7 +182,7 @@ public: } } bool IsEmpty() { - AtomicAdd(DequeueCount, 0); // mem barrier + AtomicAdd(DequeueCount, 0); // mem barrier return AtomicGet(Head) == nullptr; // without lock, so result is approximate } }; diff --git a/util/thread/lfstack_ut.cpp b/util/thread/lfstack_ut.cpp index e20a838f95b..9021220e880 100644 --- a/util/thread/lfstack_ut.cpp +++ b/util/thread/lfstack_ut.cpp @@ -8,7 +8,7 @@ #include "lfstack.h" -Y_UNIT_TEST_SUITE(TLockFreeStackTests) { +Y_UNIT_TEST_SUITE(TLockFreeStackTests) { class TCountDownLatch { private: TAtomic Current_; @@ -106,15 +106,15 @@ Y_UNIT_TEST_SUITE(TLockFreeStackTests) { } }; - Y_UNIT_TEST(TestDequeueAll) { + Y_UNIT_TEST(TestDequeueAll) { TDequeueAllTester<false>().Run(); } - Y_UNIT_TEST(TestDequeueAllSingleConsumer) { + Y_UNIT_TEST(TestDequeueAllSingleConsumer) { TDequeueAllTester<true>().Run(); } - Y_UNIT_TEST(TestDequeueAllEmptyStack) { + Y_UNIT_TEST(TestDequeueAllEmptyStack) { TLockFreeStack<int> stack; TVector<int> r; @@ -123,7 +123,7 @@ Y_UNIT_TEST_SUITE(TLockFreeStackTests) { UNIT_ASSERT(r.empty()); } - Y_UNIT_TEST(TestDequeueAllReturnsInReverseOrder) { + Y_UNIT_TEST(TestDequeueAllReturnsInReverseOrder) { TLockFreeStack<int> stack; stack.Enqueue(17); @@ -140,7 +140,7 @@ Y_UNIT_TEST_SUITE(TLockFreeStackTests) { UNIT_ASSERT_VALUES_EQUAL(17, r.at(2)); } - Y_UNIT_TEST(TestEnqueueAll) { + Y_UNIT_TEST(TestEnqueueAll) { TLockFreeStack<int> stack; TVector<int> v; @@ -174,7 +174,7 @@ Y_UNIT_TEST_SUITE(TLockFreeStackTests) { } } - Y_UNIT_TEST(CleanInDestructor) { + Y_UNIT_TEST(CleanInDestructor) { TSimpleSharedPtr<bool> p(new bool); UNIT_ASSERT_VALUES_EQUAL(1u, p.RefCount()); @@ -307,7 +307,7 @@ Y_UNIT_TEST_SUITE(TLockFreeStackTests) { }; // Test for catching thread sanitizer problems - Y_UNIT_TEST(TestFreeList) { + Y_UNIT_TEST(TestFreeList) { TMultiThreadTester<TFreeListTest>().Run(); } diff --git a/util/thread/pool.cpp b/util/thread/pool.cpp index 05fad02e9b9..f280a29f9cf 100644 --- a/util/thread/pool.cpp +++ b/util/thread/pool.cpp @@ -13,7 +13,7 @@ #include <util/generic/singleton.h> #include <util/generic/fastqueue.h> -#include <util/stream/output.h> +#include <util/stream/output.h> #include <util/string/builder.h> #include <util/system/event.h> @@ -94,7 +94,7 @@ public: } TAtforkQueueRestarter::Get().UnregisterObject(this); - Y_ASSERT(Tharr.empty()); + Y_ASSERT(Tharr.empty()); } inline bool Add(IObjectInQueue* obj) { @@ -209,7 +209,7 @@ private: } while (true) { - IObjectInQueue* job = nullptr; + IObjectInQueue* job = nullptr; with_lock (QueueMutex) { while (Queue.Empty() && !AtomicGet(ShouldTerminate)) { @@ -309,7 +309,7 @@ private: #if defined(_bionic_) //no pthread_atfork on android libc #elif defined(_unix_) - pthread_atfork(nullptr, nullptr, ProcessChildAction); + pthread_atfork(nullptr, nullptr, ProcessChildAction); #endif } }; @@ -395,7 +395,7 @@ public: TTsr tsr(Impl_->Parent_); IObjectInQueue* obj; - while ((obj = Impl_->WaitForJob()) != nullptr) { + while ((obj = Impl_->WaitForJob()) != nullptr) { if (Impl_->Catching) { try { try { @@ -424,7 +424,7 @@ public: , Namer(params) , ThrCount_(0) , AllDone_(false) - , Obj_(nullptr) + , Obj_(nullptr) , Free_(0) , IdleTime_(TDuration::Max()) { @@ -445,7 +445,7 @@ public: inline void Add(IObjectInQueue* obj) { with_lock (Mutex_) { - while (Obj_ != nullptr) { + while (Obj_ != nullptr) { CondFree_.Wait(Mutex_); } @@ -522,7 +522,7 @@ private: } IObjectInQueue* ret = Obj_; - Obj_ = nullptr; + Obj_ = nullptr; --Free_; @@ -746,7 +746,7 @@ namespace { void DoJoin() noexcept override { if (Impl_) { Impl_->WaitForComplete(); - Impl_ = nullptr; + Impl_ = nullptr; } } diff --git a/util/thread/pool.h b/util/thread/pool.h index d1ea3a67cb6..d7d56651e8a 100644 --- a/util/thread/pool.h +++ b/util/thread/pool.h @@ -1,6 +1,6 @@ #pragma once -#include "fwd.h" +#include "fwd.h" #include "factory.h" #include <util/system/yassert.h> @@ -217,12 +217,12 @@ public: * Created resource is passed to IObjectInQueue::Proccess function. */ virtual void* CreateThreadSpecificResource() { - return nullptr; + return nullptr; } virtual void DestroyThreadSpecificResource(void* resource) { - if (resource != nullptr) { - Y_ASSERT(resource == nullptr); + if (resource != nullptr) { + Y_ASSERT(resource == nullptr); } } diff --git a/util/thread/pool_ut.cpp b/util/thread/pool_ut.cpp index 893770d0c47..18f4549dc26 100644 --- a/util/thread/pool_ut.cpp +++ b/util/thread/pool_ut.cpp @@ -2,7 +2,7 @@ #include <library/cpp/testing/unittest/registar.h> -#include <util/stream/output.h> +#include <util/stream/output.h> #include <util/random/fast.h> #include <util/system/spinlock.h> #include <util/system/thread.h> @@ -113,7 +113,7 @@ Y_UNIT_TEST_SUITE(TThreadPoolTest) { } } - Y_UNIT_TEST(TestAddAndOwn) { + Y_UNIT_TEST(TestAddAndOwn) { TThreadPool q; q.Start(2); bool processed = false; @@ -125,7 +125,7 @@ Y_UNIT_TEST_SUITE(TThreadPoolTest) { UNIT_ASSERT_C(destructed, "Not destructed"); } - Y_UNIT_TEST(TestAddFunc) { + Y_UNIT_TEST(TestAddFunc) { TFailAddQueue queue; bool added = queue.AddFunc( []() {} // Lambda, I call him 'Lambda'! @@ -138,7 +138,7 @@ Y_UNIT_TEST_SUITE(TThreadPoolTest) { UNIT_CHECK_GENERATED_EXCEPTION(queue.SafeAddFunc([] {}), TThreadPoolException); } - Y_UNIT_TEST(TestFunctionNotCopied) { + Y_UNIT_TEST(TestFunctionNotCopied) { struct TFailOnCopy { TFailOnCopy() { } diff --git a/util/thread/singleton.h b/util/thread/singleton.h index 4a1e05aea04..8d3bdda992d 100644 --- a/util/thread/singleton.h +++ b/util/thread/singleton.h @@ -12,10 +12,10 @@ namespace NPrivate { } static inline T* Get() { -#if defined(Y_HAVE_FAST_POD_TLS) +#if defined(Y_HAVE_FAST_POD_TLS) Y_POD_STATIC_THREAD(T*) fast(nullptr); - if (Y_UNLIKELY(!fast)) { + if (Y_UNLIKELY(!fast)) { fast = GetSlow(); } diff --git a/util/thread/singleton_ut.cpp b/util/thread/singleton_ut.cpp index 164b1cc184d..d4a31b36f11 100644 --- a/util/thread/singleton_ut.cpp +++ b/util/thread/singleton_ut.cpp @@ -12,8 +12,8 @@ namespace { }; } -Y_UNIT_TEST_SUITE(Tls) { - Y_UNIT_TEST(FastThread) { +Y_UNIT_TEST_SUITE(Tls) { + Y_UNIT_TEST(FastThread) { UNIT_ASSERT_VALUES_EQUAL(0, FastTlsSingleton<TFoo>()->i); FastTlsSingleton<TFoo>()->i += 3; UNIT_ASSERT_VALUES_EQUAL(3, FastTlsSingleton<TFoo>()->i); diff --git a/util/ya.make b/util/ya.make index 6ebe7e40cfe..bed6c571067 100644 --- a/util/ya.make +++ b/util/ya.make @@ -23,7 +23,7 @@ PEERDIR( JOIN_SRCS( all_datetime.cpp datetime/base.cpp - datetime/constants.cpp + datetime/constants.cpp datetime/cputimer.cpp datetime/systime.cpp datetime/uptime.cpp @@ -45,8 +45,8 @@ ENDIF() # digest JOIN_SRCS( all_digest.cpp - digest/fnv.cpp - digest/multi.cpp + digest/fnv.cpp + digest/multi.cpp digest/murmur.cpp digest/numeric.cpp digest/sequence.cpp @@ -62,11 +62,11 @@ JOIN_SRCS( # folder JOIN_SRCS( all_folder.cpp - folder/dirut.cpp - folder/filelist.cpp + folder/dirut.cpp + folder/filelist.cpp folder/fts.cpp folder/fwd.cpp - folder/iterator.cpp + folder/iterator.cpp folder/path.cpp folder/pathsplit.cpp folder/tempdir.cpp @@ -84,25 +84,25 @@ JOIN_SRCS( all_generic.cpp generic/scope.cpp generic/adaptor.cpp - generic/algorithm.cpp + generic/algorithm.cpp generic/array_ref.cpp generic/array_size.cpp generic/bitmap.cpp generic/bitops.cpp generic/bt_exception.cpp - generic/buffer.cpp + generic/buffer.cpp generic/cast.cpp generic/deque.cpp - generic/explicit_type.cpp + generic/explicit_type.cpp generic/fastqueue.cpp generic/flags.cpp - generic/function.cpp + generic/function.cpp generic/fwd.cpp - generic/guid.cpp - generic/hash.cpp - generic/hash_primes.cpp + generic/guid.cpp + generic/hash.cpp + generic/hash_primes.cpp generic/hash_set.cpp - generic/hide_ptr.cpp + generic/hide_ptr.cpp generic/intrlist.cpp generic/is_in.cpp generic/iterator.cpp @@ -112,63 +112,63 @@ JOIN_SRCS( generic/map.cpp generic/mapfindptr.cpp generic/maybe.cpp - generic/mem_copy.cpp + generic/mem_copy.cpp generic/noncopyable.cpp generic/object_counter.cpp generic/overloaded.cpp - generic/ptr.cpp + generic/ptr.cpp generic/queue.cpp generic/refcount.cpp generic/serialized_enum.cpp generic/set.cpp - generic/singleton.cpp + generic/singleton.cpp generic/size_literals.cpp generic/stack.cpp generic/store_policy.cpp - generic/strbuf.cpp - generic/strfcpy.cpp - generic/string.cpp - generic/typelist.cpp + generic/strbuf.cpp + generic/strfcpy.cpp + generic/string.cpp + generic/typelist.cpp generic/typetraits.cpp - generic/utility.cpp - generic/va_args.cpp + generic/utility.cpp + generic/va_args.cpp generic/vector.cpp - generic/xrange.cpp - generic/yexception.cpp + generic/xrange.cpp + generic/yexception.cpp generic/ylimits.cpp - generic/ymath.cpp + generic/ymath.cpp ) # memory JOIN_SRCS( all_memory.cpp - memory/addstorage.cpp - memory/alloc.cpp + memory/addstorage.cpp + memory/alloc.cpp memory/blob.cpp memory/mmapalloc.cpp memory/pool.cpp memory/segmented_string_pool.cpp memory/segpool_alloc.cpp memory/smallobj.cpp - memory/tempbuf.cpp + memory/tempbuf.cpp ) # network JOIN_SRCS( all_network.cpp - network/address.cpp - network/endpoint.cpp + network/address.cpp + network/endpoint.cpp network/hostip.cpp network/init.cpp network/interface.cpp network/iovec.cpp network/ip.cpp - network/nonblock.cpp - network/pair.cpp - network/poller.cpp + network/nonblock.cpp + network/pair.cpp + network/poller.cpp network/pollerimpl.cpp network/sock.cpp - network/socket.cpp + network/socket.cpp ) # random @@ -176,12 +176,12 @@ JOIN_SRCS( all_random.cpp random/common_ops.cpp random/easy.cpp - random/entropy.cpp + random/entropy.cpp random/fast.cpp random/lcg_engine.cpp random/mersenne32.cpp random/mersenne64.cpp - random/mersenne.cpp + random/mersenne.cpp random/normal.cpp random/shuffle.cpp random/init_atfork.cpp @@ -189,53 +189,53 @@ JOIN_SRCS( JOIN_SRCS( all_stream.cpp - stream/aligned.cpp + stream/aligned.cpp stream/buffer.cpp stream/buffered.cpp stream/debug.cpp stream/direct_io.cpp stream/file.cpp - stream/format.cpp - stream/fwd.cpp + stream/format.cpp + stream/fwd.cpp stream/hex.cpp - stream/holder.cpp + stream/holder.cpp stream/input.cpp - stream/labeled.cpp + stream/labeled.cpp stream/length.cpp stream/mem.cpp stream/multi.cpp stream/null.cpp stream/output.cpp stream/pipe.cpp - stream/printf.cpp + stream/printf.cpp stream/str.cpp stream/tee.cpp stream/tempbuf.cpp stream/tokenizer.cpp stream/trace.cpp - stream/walk.cpp - stream/zerocopy.cpp + stream/walk.cpp + stream/zerocopy.cpp stream/zerocopy_output.cpp - stream/zlib.cpp + stream/zlib.cpp ) JOIN_SRCS( all_string.cpp - string/ascii.cpp + string/ascii.cpp string/builder.cpp - string/cstriter.cpp + string/cstriter.cpp string/escape.cpp string/hex.cpp string/join.cpp - string/printf.cpp + string/printf.cpp string/reverse.cpp - string/split.cpp - string/strip.cpp + string/split.cpp + string/strip.cpp string/strspn.cpp string/subst.cpp - string/type.cpp - string/util.cpp - string/vector.cpp + string/type.cpp + string/util.cpp + string/vector.cpp ) IF (ARCH_ARM) @@ -264,7 +264,7 @@ JOIN_SRCS( system/execpath.cpp system/fasttime.cpp system/file.cpp - system/file_lock.cpp + system/file_lock.cpp system/filemap.cpp system/flock.cpp system/fs.cpp @@ -282,15 +282,15 @@ ENDIF() JOIN_SRCS( all_system_2.cpp - system/align.cpp - system/atomic.cpp - system/byteorder.cpp - system/cpu_id.cpp - system/fhandle.cpp - system/guard.cpp + system/align.cpp + system/atomic.cpp + system/byteorder.cpp + system/cpu_id.cpp + system/fhandle.cpp + system/guard.cpp system/interrupt_signals.cpp system/madvise.cpp - system/maxlen.cpp + system/maxlen.cpp system/mem_info.cpp system/mincore.cpp system/mktemp.cpp @@ -305,22 +305,22 @@ JOIN_SRCS( system/rwlock.cpp system/sanitizers.cpp system/sem.cpp - system/shellcommand.cpp + system/shellcommand.cpp system/shmat.cpp - system/sigset.cpp - system/spinlock.cpp + system/sigset.cpp + system/spinlock.cpp system/spin_wait.cpp - system/src_location.cpp - system/sys_alloc.cpp + system/src_location.cpp + system/sys_alloc.cpp system/sysstat.cpp system/tempfile.cpp system/thread.cpp system/tls.cpp system/types.cpp system/type_name.cpp - system/unaligned_mem.cpp + system/unaligned_mem.cpp system/user.cpp - system/utime.cpp + system/utime.cpp system/yassert.cpp system/yield.cpp ) @@ -373,9 +373,9 @@ ENDIF() JOIN_SRCS( all_thread.cpp thread/factory.cpp - thread/fwd.cpp - thread/lfqueue.cpp - thread/lfstack.cpp + thread/fwd.cpp + thread/lfqueue.cpp + thread/lfstack.cpp thread/pool.cpp thread/singleton.cpp ) diff --git a/util/ysafeptr.cpp b/util/ysafeptr.cpp index 96f25140673..d19af156f03 100644 --- a/util/ysafeptr.cpp +++ b/util/ysafeptr.cpp @@ -2,10 +2,10 @@ #ifdef CHECK_YPTR2 Y_POD_THREAD(bool) -IObjectBase::DisableThreadCheck; +IObjectBase::DisableThreadCheck; #endif //////////////////////////////////////////////////////////////////////////////////////////////////// -void IObjectBase::ReleaseObjComplete(int nMask) { +void IObjectBase::ReleaseObjComplete(int nMask) { if ((ObjData & 0x3fffffff) == 0 && RefData == 0) { assert((ObjData & 0x40000000) == 0); // object not being invalidated delete this; @@ -24,7 +24,7 @@ void IObjectBase::ReleaseObjComplete(int nMask) { } } //////////////////////////////////////////////////////////////////////////////////////////////////// -void IObjectBase::ReleaseRefComplete() { +void IObjectBase::ReleaseRefComplete() { assert(RefData == 0); if ((ObjData & 0x3fffffff) == 0) { assert((ObjData & 0x40000000) == 0); // object not being invalidated diff --git a/util/ysafeptr.h b/util/ysafeptr.h index af7dfd4bedb..f663e8b3565 100644 --- a/util/ysafeptr.h +++ b/util/ysafeptr.h @@ -27,15 +27,15 @@ struct IBinSaver; -class IObjectBase { +class IObjectBase { private: #ifdef CHECK_YPTR2 - static Y_POD_THREAD(bool) DisableThreadCheck; + static Y_POD_THREAD(bool) DisableThreadCheck; void CheckThreadId() { if (dwThreadId == 0) dwThreadId = GetCurrentThreadId(); else - Y_ASSERT(dwThreadId == GetCurrentThreadId() || DisableThreadCheck); + Y_ASSERT(dwThreadId == GetCurrentThreadId() || DisableThreadCheck); } void AddRef() { CheckThreadId(); @@ -87,14 +87,14 @@ protected: // function should clear contents of object, easy to implement via consequent calls to // destructor and constructor, this function should not be called directly, use Clear() virtual void DestroyContents() = 0; - virtual ~IObjectBase() = default; - inline void CopyValidFlag(const IObjectBase& a) { + virtual ~IObjectBase() = default; + inline void CopyValidFlag(const IObjectBase& a) { ObjData &= 0x7fffffff; ObjData |= a.ObjData & 0x80000000; } public: - IObjectBase() + IObjectBase() : ObjData(0) , RefData(0) { @@ -103,7 +103,7 @@ public: #endif } // do not copy refcount when copy object - IObjectBase(const IObjectBase& a) + IObjectBase(const IObjectBase& a) : ObjData(0) , RefData(0) { @@ -112,7 +112,7 @@ public: #endif CopyValidFlag(a); } - IObjectBase& operator=(const IObjectBase& a) { + IObjectBase& operator=(const IObjectBase& a) { CopyValidFlag(a); return *this; } @@ -121,7 +121,7 @@ public: DisableThreadCheck = !val; } void ResetThreadId() { - Y_ASSERT(RefData == 0 && ObjData == 0); // can reset thread check only for ref free objects + Y_ASSERT(RefData == 0 && ObjData == 0); // can reset thread check only for ref free objects dwThreadId = 0; } #else @@ -152,41 +152,41 @@ public: } struct TRefO { - void AddRef(IObjectBase* pObj) { + void AddRef(IObjectBase* pObj) { pObj->AddObj(1); } - void DecRef(IObjectBase* pObj) { + void DecRef(IObjectBase* pObj) { pObj->DecObj(1); } - void Release(IObjectBase* pObj) { + void Release(IObjectBase* pObj) { pObj->ReleaseObj(1, 0x000fffff); } }; struct TRefM { - void AddRef(IObjectBase* pObj) { + void AddRef(IObjectBase* pObj) { pObj->AddObj(0x100000); } - void DecRef(IObjectBase* pObj) { + void DecRef(IObjectBase* pObj) { pObj->DecObj(0x100000); } - void Release(IObjectBase* pObj) { + void Release(IObjectBase* pObj) { pObj->ReleaseObj(0x100000, 0x3ff00000); } }; struct TRef { - void AddRef(IObjectBase* pObj) { + void AddRef(IObjectBase* pObj) { pObj->AddRef(); } - void DecRef(IObjectBase* pObj) { + void DecRef(IObjectBase* pObj) { pObj->DecRef(); } - void Release(IObjectBase* pObj) { + void Release(IObjectBase* pObj) { pObj->ReleaseRef(); } }; - friend struct IObjectBase::TRef; - friend struct IObjectBase::TRefO; - friend struct IObjectBase::TRefM; + friend struct IObjectBase::TRef; + friend struct IObjectBase::TRefO; + friend struct IObjectBase::TRefM; }; //////////////////////////////////////////////////////////////////////////////////////////////////// // macro that helps to create neccessary members for proper operation of refcount system @@ -196,7 +196,7 @@ public: \ virtual const char* GetClassName() const override { \ return #classname; \ } \ - static IObjectBase* NewSaveLoadNullItem() { \ + static IObjectBase* NewSaveLoadNullItem() { \ return new classname(); \ } \ \ @@ -215,38 +215,38 @@ private: Y_PRAGMA_DIAGNOSTIC_PUSH \ Y_PRAGMA_NO_UNUSED_FUNCTION \ template <> \ - IObjectBase* CastToObjectBaseImpl<classname>(classname * p, void*) { \ + IObjectBase* CastToObjectBaseImpl<classname>(classname * p, void*) { \ return p; \ } \ template <> \ - classname* CastToUserObjectImpl<classname>(IObjectBase * p, classname*, void*) { \ + classname* CastToUserObjectImpl<classname>(IObjectBase * p, classname*, void*) { \ return dynamic_cast<classname*>(p); \ } \ Y_PRAGMA_DIAGNOSTIC_POP //////////////////////////////////////////////////////////////////////////////////////////////////// template <class TUserObj> -IObjectBase* CastToObjectBaseImpl(TUserObj* p, void*); +IObjectBase* CastToObjectBaseImpl(TUserObj* p, void*); template <class TUserObj> -IObjectBase* CastToObjectBaseImpl(TUserObj* p, IObjectBase*) { +IObjectBase* CastToObjectBaseImpl(TUserObj* p, IObjectBase*) { return p; } template <class TUserObj> -TUserObj* CastToUserObjectImpl(IObjectBase* p, TUserObj*, void*); +TUserObj* CastToUserObjectImpl(IObjectBase* p, TUserObj*, void*); template <class TUserObj> -TUserObj* CastToUserObjectImpl(IObjectBase* _p, TUserObj*, IObjectBase*) { +TUserObj* CastToUserObjectImpl(IObjectBase* _p, TUserObj*, IObjectBase*) { return dynamic_cast<TUserObj*>(_p); } template <class TUserObj> -inline IObjectBase* CastToObjectBase(TUserObj* p) { +inline IObjectBase* CastToObjectBase(TUserObj* p) { return CastToObjectBaseImpl(p, p); } template <class TUserObj> -inline const IObjectBase* CastToObjectBase(const TUserObj* p) { +inline const IObjectBase* CastToObjectBase(const TUserObj* p) { return p; } template <class TUserObj> -inline TUserObj* CastToUserObject(IObjectBase* p, TUserObj* pu) { +inline TUserObj* CastToUserObject(IObjectBase* p, TUserObj* pu) { return CastToUserObjectImpl(p, pu, pu); } //////////////////////////////////////////////////////////////////////////////////////////////////// @@ -333,7 +333,7 @@ public: TUserObj* Get() const { return ptr; } - IObjectBase* GetBarePtr() const { + IObjectBase* GetBarePtr() const { return CastToObjectBase(ptr); } int operator&(IBinSaver& f); @@ -378,9 +378,9 @@ inline bool IsValid(const TPtrBase<T, TRef>& p) { } \ }; -BASIC_PTR_DECLARE(TPtr, IObjectBase::TRef) -BASIC_PTR_DECLARE(TObj, IObjectBase::TRefO) -BASIC_PTR_DECLARE(TMObj, IObjectBase::TRefM) +BASIC_PTR_DECLARE(TPtr, IObjectBase::TRef) +BASIC_PTR_DECLARE(TObj, IObjectBase::TRefO) +BASIC_PTR_DECLARE(TMObj, IObjectBase::TRefM) // misuse guard template <class T> inline bool IsValid(TObj<T>* p) { @@ -395,7 +395,7 @@ inline bool IsValid(TMObj<T>* p) { return p->YouHaveMadeMistake(); } //////////////////////////////////////////////////////////////////////////////////////////////////// -// assumes base class is IObjectBase +// assumes base class is IObjectBase template <class T> class TDynamicCast { T* ptr; diff --git a/util/ysaveload.cpp b/util/ysaveload.cpp index 1ae3acb01ea..f3f07595f62 100644 --- a/util/ysaveload.cpp +++ b/util/ysaveload.cpp @@ -2,12 +2,12 @@ #include <util/generic/buffer.h> -void TSerializer<TBuffer>::Save(IOutputStream* rh, const TBuffer& buf) { +void TSerializer<TBuffer>::Save(IOutputStream* rh, const TBuffer& buf) { ::SaveSize(rh, buf.Size()); ::SavePodArray(rh, buf.Data(), buf.Size()); } -void TSerializer<TBuffer>::Load(IInputStream* rh, TBuffer& buf) { +void TSerializer<TBuffer>::Load(IInputStream* rh, TBuffer& buf) { const size_t s = ::LoadSize(rh); buf.Resize(s); ::LoadPodArray(rh, buf.Data(), buf.Size()); diff --git a/util/ysaveload.h b/util/ysaveload.h index 02efb4049b6..818ea118010 100644 --- a/util/ysaveload.h +++ b/util/ysaveload.h @@ -6,8 +6,8 @@ #include <util/generic/yexception.h> #include <util/generic/typetraits.h> #include <util/generic/algorithm.h> -#include <util/stream/output.h> -#include <util/stream/input.h> +#include <util/stream/output.h> +#include <util/stream/input.h> #ifndef __NVCC__ // cuda is compiled in C++14 mode at the time @@ -32,25 +32,25 @@ struct TLoadEOF: public TSerializeException { }; template <class T> -static inline void Save(IOutputStream* out, const T& t); +static inline void Save(IOutputStream* out, const T& t); template <class T> -static inline void SaveArray(IOutputStream* out, const T* t, size_t len); +static inline void SaveArray(IOutputStream* out, const T* t, size_t len); template <class T> -static inline void Load(IInputStream* in, T& t); +static inline void Load(IInputStream* in, T& t); template <class T> -static inline void LoadArray(IInputStream* in, T* t, size_t len); +static inline void LoadArray(IInputStream* in, T* t, size_t len); template <class T, class TStorage> -static inline void Load(IInputStream* in, T& t, TStorage& pool); +static inline void Load(IInputStream* in, T& t, TStorage& pool); template <class T, class TStorage> -static inline void LoadArray(IInputStream* in, T* t, size_t len, TStorage& pool); +static inline void LoadArray(IInputStream* in, T* t, size_t len, TStorage& pool); template <class T> -static inline void SavePodType(IOutputStream* rh, const T& t) { +static inline void SavePodType(IOutputStream* rh, const T& t) { rh->Write(&t, sizeof(T)); } @@ -60,7 +60,7 @@ namespace NPrivate { } template <class T> -static inline void LoadPodType(IInputStream* rh, T& t) { +static inline void LoadPodType(IInputStream* rh, T& t) { const size_t res = rh->Load(&t, sizeof(T)); if (Y_UNLIKELY(res != sizeof(T))) { @@ -69,12 +69,12 @@ static inline void LoadPodType(IInputStream* rh, T& t) { } template <class T> -static inline void SavePodArray(IOutputStream* rh, const T* arr, size_t count) { +static inline void SavePodArray(IOutputStream* rh, const T* arr, size_t count) { rh->Write(arr, sizeof(T) * count); } template <class T> -static inline void LoadPodArray(IInputStream* rh, T* arr, size_t count) { +static inline void LoadPodArray(IInputStream* rh, T* arr, size_t count) { const size_t len = sizeof(T) * count; const size_t res = rh->Load(arr, len); @@ -84,21 +84,21 @@ static inline void LoadPodArray(IInputStream* rh, T* arr, size_t count) { } template <class It> -static inline void SaveIterRange(IOutputStream* rh, It b, It e) { +static inline void SaveIterRange(IOutputStream* rh, It b, It e) { while (b != e) { ::Save(rh, *b++); } } template <class It> -static inline void LoadIterRange(IInputStream* rh, It b, It e) { +static inline void LoadIterRange(IInputStream* rh, It b, It e) { while (b != e) { ::Load(rh, *b++); } } template <class It, class TStorage> -static inline void LoadIterRange(IInputStream* rh, It b, It e, TStorage& pool) { +static inline void LoadIterRange(IInputStream* rh, It b, It e, TStorage& pool) { while (b != e) { ::Load(rh, *b++, pool); } @@ -106,24 +106,24 @@ static inline void LoadIterRange(IInputStream* rh, It b, It e, TStorage& pool) { template <class T, bool isPod> struct TSerializerTakingIntoAccountThePodType { - static inline void Save(IOutputStream* out, const T& t) { + static inline void Save(IOutputStream* out, const T& t) { ::SavePodType(out, t); } - static inline void Load(IInputStream* in, T& t) { + static inline void Load(IInputStream* in, T& t) { ::LoadPodType(in, t); } template <class TStorage> - static inline void Load(IInputStream* in, T& t, TStorage& /*pool*/) { + static inline void Load(IInputStream* in, T& t, TStorage& /*pool*/) { ::LoadPodType(in, t); } - static inline void SaveArray(IOutputStream* out, const T* t, size_t len) { + static inline void SaveArray(IOutputStream* out, const T* t, size_t len) { ::SavePodArray(out, t, len); } - static inline void LoadArray(IInputStream* in, T* t, size_t len) { + static inline void LoadArray(IInputStream* in, T* t, size_t len) { ::LoadPodArray(in, t, len); } }; @@ -137,97 +137,97 @@ struct TSerializerMethodSelector; template <class T> struct TSerializerMethodSelector<T, std::enable_if_t<NHasSaveLoad::THasSaveLoad<T>::value>> { - static inline void Save(IOutputStream* out, const T& t) { + static inline void Save(IOutputStream* out, const T& t) { //assume Save clause do not change t (const_cast<T&>(t)).SaveLoad(out); } - static inline void Load(IInputStream* in, T& t) { + static inline void Load(IInputStream* in, T& t) { t.SaveLoad(in); } template <class TStorage> - static inline void Load(IInputStream* in, T& t, TStorage& pool) { + static inline void Load(IInputStream* in, T& t, TStorage& pool) { t.SaveLoad(in, pool); } }; template <class T> struct TSerializerMethodSelector<T, std::enable_if_t<!NHasSaveLoad::THasSaveLoad<T>::value>> { - static inline void Save(IOutputStream* out, const T& t) { + static inline void Save(IOutputStream* out, const T& t) { t.Save(out); } - static inline void Load(IInputStream* in, T& t) { + static inline void Load(IInputStream* in, T& t) { t.Load(in); } template <class TStorage> - static inline void Load(IInputStream* in, T& t, TStorage& pool) { + static inline void Load(IInputStream* in, T& t, TStorage& pool) { t.Load(in, pool); } }; template <class T> struct TSerializerTakingIntoAccountThePodType<T, false>: public TSerializerMethodSelector<T> { - static inline void SaveArray(IOutputStream* out, const T* t, size_t len) { + static inline void SaveArray(IOutputStream* out, const T* t, size_t len) { ::SaveIterRange(out, t, t + len); } - static inline void LoadArray(IInputStream* in, T* t, size_t len) { + static inline void LoadArray(IInputStream* in, T* t, size_t len) { ::LoadIterRange(in, t, t + len); } template <class TStorage> - static inline void LoadArray(IInputStream* in, T* t, size_t len, TStorage& pool) { + static inline void LoadArray(IInputStream* in, T* t, size_t len, TStorage& pool) { ::LoadIterRange(in, t, t + len, pool); } }; template <class It, bool isPtr> struct TRangeSerialize { - static inline void Save(IOutputStream* rh, It b, It e) { + static inline void Save(IOutputStream* rh, It b, It e) { SaveArray(rh, b, e - b); } - static inline void Load(IInputStream* rh, It b, It e) { + static inline void Load(IInputStream* rh, It b, It e) { LoadArray(rh, b, e - b); } template <class TStorage> - static inline void Load(IInputStream* rh, It b, It e, TStorage& pool) { + static inline void Load(IInputStream* rh, It b, It e, TStorage& pool) { LoadArray(rh, b, e - b, pool); } }; template <class It> struct TRangeSerialize<It, false> { - static inline void Save(IOutputStream* rh, It b, It e) { + static inline void Save(IOutputStream* rh, It b, It e) { SaveIterRange(rh, b, e); } - static inline void Load(IInputStream* rh, It b, It e) { + static inline void Load(IInputStream* rh, It b, It e) { LoadIterRange(rh, b, e); } template <class TStorage> - static inline void Load(IInputStream* rh, It b, It e, TStorage& pool) { + static inline void Load(IInputStream* rh, It b, It e, TStorage& pool) { LoadIterRange(rh, b, e, pool); } }; template <class It> -static inline void SaveRange(IOutputStream* rh, It b, It e) { +static inline void SaveRange(IOutputStream* rh, It b, It e) { TRangeSerialize<It, std::is_pointer<It>::value>::Save(rh, b, e); } template <class It> -static inline void LoadRange(IInputStream* rh, It b, It e) { +static inline void LoadRange(IInputStream* rh, It b, It e) { TRangeSerialize<It, std::is_pointer<It>::value>::Load(rh, b, e); } template <class It, class TStorage> -static inline void LoadRange(IInputStream* rh, It b, It e, TStorage& pool) { +static inline void LoadRange(IInputStream* rh, It b, It e, TStorage& pool) { TRangeSerialize<It, std::is_pointer<It>::value>::Load(rh, b, e, pool); } @@ -240,36 +240,36 @@ class TArraySerializer: public TSerializerTakingIntoAccountThePodType<T, TSerial }; template <class T> -static inline void Save(IOutputStream* out, const T& t) { +static inline void Save(IOutputStream* out, const T& t) { TSerializer<T>::Save(out, t); } template <class T> -static inline void SaveArray(IOutputStream* out, const T* t, size_t len) { +static inline void SaveArray(IOutputStream* out, const T* t, size_t len) { TArraySerializer<T>::SaveArray(out, t, len); } template <class T> -static inline void Load(IInputStream* in, T& t) { +static inline void Load(IInputStream* in, T& t) { TSerializer<T>::Load(in, t); } template <class T> -static inline void LoadArray(IInputStream* in, T* t, size_t len) { +static inline void LoadArray(IInputStream* in, T* t, size_t len) { TArraySerializer<T>::LoadArray(in, t, len); } template <class T, class TStorage> -static inline void Load(IInputStream* in, T& t, TStorage& pool) { +static inline void Load(IInputStream* in, T& t, TStorage& pool) { TSerializer<T>::Load(in, t, pool); } template <class T, class TStorage> -static inline void LoadArray(IInputStream* in, T* t, size_t len, TStorage& pool) { +static inline void LoadArray(IInputStream* in, T* t, size_t len, TStorage& pool) { TArraySerializer<T>::LoadArray(in, t, len, pool); } -static inline void SaveSize(IOutputStream* rh, size_t len) { +static inline void SaveSize(IOutputStream* rh, size_t len) { if ((ui64)len < 0xffffffff) { ::Save(rh, (ui32)len); } else { @@ -278,7 +278,7 @@ static inline void SaveSize(IOutputStream* rh, size_t len) { } } -static inline size_t LoadSize(IInputStream* rh) { +static inline size_t LoadSize(IInputStream* rh) { ui32 oldVerSize; ui64 newVerSize; ::Load(rh, oldVerSize); @@ -291,7 +291,7 @@ static inline size_t LoadSize(IInputStream* rh) { } template <class C> -static inline void LoadSizeAndResize(IInputStream* rh, C& c) { +static inline void LoadSizeAndResize(IInputStream* rh, C& c) { c.resize(LoadSize(rh)); } @@ -303,14 +303,14 @@ static inline char* AllocateFromPool(TStorage& pool, size_t len) { template <> class TSerializer<const char*> { public: - static inline void Save(IOutputStream* rh, const char* s) { + static inline void Save(IOutputStream* rh, const char* s) { size_t length = strlen(s); ::SaveSize(rh, length); ::SavePodArray(rh, s, length); } template <class Char, class TStorage> - static inline void Load(IInputStream* rh, Char*& s, TStorage& pool) { + static inline void Load(IInputStream* rh, Char*& s, TStorage& pool) { const size_t len = LoadSize(rh); char* res = AllocateFromPool(pool, len + 1); @@ -325,12 +325,12 @@ class TVectorSerializer { using TIter = typename TVec::iterator; public: - static inline void Save(IOutputStream* rh, const TVec& v) { + static inline void Save(IOutputStream* rh, const TVec& v) { ::SaveSize(rh, v.size()); ::SaveRange(rh, v.begin(), v.end()); } - static inline void Load(IInputStream* rh, TVec& v) { + static inline void Load(IInputStream* rh, TVec& v) { ::LoadSizeAndResize(rh, v); TIter b = v.begin(); TIter e = (TIter)v.end(); @@ -338,7 +338,7 @@ public: } template <class TStorage> - static inline void Load(IInputStream* rh, TVec& v, TStorage& pool) { + static inline void Load(IInputStream* rh, TVec& v, TStorage& pool) { ::LoadSizeAndResize(rh, v); TIter b = v.begin(); TIter e = (TIter)v.end(); @@ -385,11 +385,11 @@ class TSerializer<std::deque<T, A>>: public TVectorSerializer<std::deque<T, A>> template <class TArray> class TStdArraySerializer { public: - static inline void Save(IOutputStream* rh, const TArray& a) { + static inline void Save(IOutputStream* rh, const TArray& a) { ::SaveArray(rh, a.data(), a.size()); } - static inline void Load(IInputStream* rh, TArray& a) { + static inline void Load(IInputStream* rh, TArray& a) { ::LoadArray(rh, a.data(), a.size()); } }; @@ -403,18 +403,18 @@ class TSerializer<std::pair<A, B>> { using TPair = std::pair<A, B>; public: - static inline void Save(IOutputStream* rh, const TPair& p) { + static inline void Save(IOutputStream* rh, const TPair& p) { ::Save(rh, p.first); ::Save(rh, p.second); } - static inline void Load(IInputStream* rh, TPair& p) { + static inline void Load(IInputStream* rh, TPair& p) { ::Load(rh, p.first); ::Load(rh, p.second); } template <class TStorage> - static inline void Load(IInputStream* rh, TPair& p, TStorage& pool) { + static inline void Load(IInputStream* rh, TPair& p, TStorage& pool) { ::Load(rh, p.first, pool); ::Load(rh, p.second, pool); } @@ -449,8 +449,8 @@ struct TSerializer<std::tuple<TArgs...>>: TTupleSerializer<std::tuple<TArgs...>> template <> class TSerializer<TBuffer> { public: - static void Save(IOutputStream* rh, const TBuffer& buf); - static void Load(IInputStream* rh, TBuffer& buf); + static void Save(IOutputStream* rh, const TBuffer& buf); + static void Load(IInputStream* rh, TBuffer& buf); }; template <class TSetOrMap, class TValue> @@ -471,26 +471,26 @@ protected: }; template <class TSetOrMap, class TValue, bool sorted> -class TSetSerializerInserter: public TSetSerializerInserterBase<TSetOrMap, TValue> { +class TSetSerializerInserter: public TSetSerializerInserterBase<TSetOrMap, TValue> { using TBase = TSetSerializerInserterBase<TSetOrMap, TValue>; - + public: inline TSetSerializerInserter(TSetOrMap& s, size_t cnt) : TBase(s) { - Y_UNUSED(cnt); + Y_UNUSED(cnt); } }; template <class TSetType, class TValue> class TSetSerializerInserter<TSetType, TValue, true>: public TSetSerializerInserterBase<TSetType, TValue> { using TBase = TSetSerializerInserterBase<TSetType, TValue>; - + public: inline TSetSerializerInserter(TSetType& s, size_t cnt) : TBase(s) { - Y_UNUSED(cnt); + Y_UNUSED(cnt); P_ = this->S_.begin(); } @@ -506,7 +506,7 @@ template <class T1, class T2, class T3, class T4, class T5, class TValue> class TSetSerializerInserter<THashMap<T1, T2, T3, T4, T5>, TValue, false>: public TSetSerializerInserterBase<THashMap<T1, T2, T3, T4, T5>, TValue> { using TMapType = THashMap<T1, T2, T3, T4, T5>; using TBase = TSetSerializerInserterBase<TMapType, TValue>; - + public: inline TSetSerializerInserter(TMapType& m, size_t cnt) : TBase(m) @@ -532,7 +532,7 @@ template <class T1, class T2, class T3, class T4, class TValue> class TSetSerializerInserter<THashSet<T1, T2, T3, T4>, TValue, false>: public TSetSerializerInserterBase<THashSet<T1, T2, T3, T4>, TValue> { using TSetType = THashSet<T1, T2, T3, T4>; using TBase = TSetSerializerInserterBase<TSetType, TValue>; - + public: inline TSetSerializerInserter(TSetType& s, size_t cnt) : TBase(s) @@ -684,12 +684,12 @@ private: #endif template <class T> -static inline void SaveLoad(IOutputStream* out, const T& t) { +static inline void SaveLoad(IOutputStream* out, const T& t) { Save(out, t); } template <class T> -static inline void SaveLoad(IInputStream* in, T& t) { +static inline void SaveLoad(IInputStream* in, T& t) { Load(in, t); } @@ -703,12 +703,12 @@ static inline void LoadMany(S* s, Ts&... t) { ApplyToMany([&](auto& v) { Load(s, v); }, t...); } -#define Y_SAVELOAD_DEFINE(...) \ - inline void Save(IOutputStream* s) const { \ +#define Y_SAVELOAD_DEFINE(...) \ + inline void Save(IOutputStream* s) const { \ ::SaveMany(s, __VA_ARGS__); \ } \ \ - inline void Load(IInputStream* s) { \ + inline void Load(IInputStream* s) { \ ::LoadMany(s, __VA_ARGS__); \ } diff --git a/util/ysaveload_ut.cpp b/util/ysaveload_ut.cpp index 723c68f391e..74935a9d255 100644 --- a/util/ysaveload_ut.cpp +++ b/util/ysaveload_ut.cpp @@ -34,11 +34,11 @@ class TSaveLoadTest: public TTestBase { UNIT_TEST_SUITE_END(); struct TSaveHelper { - inline void Save(IOutputStream* o) const { + inline void Save(IOutputStream* o) const { o->Write("qwerty", 7); } - inline void Load(IInputStream* i) { + inline void Load(IInputStream* i) { char buf[7]; UNIT_ASSERT_EQUAL(i->Load(buf, 7), 7); @@ -59,7 +59,7 @@ class TSaveLoadTest: public TTestBase { TString Str; ui32 Int; - Y_SAVELOAD_DEFINE(Str, Int) + Y_SAVELOAD_DEFINE(Str, Int) }; private: diff --git a/ydb/core/actorlib_impl/actor_bootstrapped_ut.cpp b/ydb/core/actorlib_impl/actor_bootstrapped_ut.cpp index 990330b321b..3c098c9f1bc 100644 --- a/ydb/core/actorlib_impl/actor_bootstrapped_ut.cpp +++ b/ydb/core/actorlib_impl/actor_bootstrapped_ut.cpp @@ -5,7 +5,7 @@ using namespace NActors; -Y_UNIT_TEST_SUITE(ActorBootstrapped) { +Y_UNIT_TEST_SUITE(ActorBootstrapped) { class TTestBoostrapped: public TActorBootstrapped<TTestBoostrapped> { public: @@ -46,11 +46,11 @@ Y_UNIT_TEST_SUITE(ActorBootstrapped) { } - Y_UNIT_TEST(TestBootstrapped) { + Y_UNIT_TEST(TestBootstrapped) { TestBootrappedActor<TTestBoostrapped>(); } - Y_UNIT_TEST(TestBootstrappedParent) { + Y_UNIT_TEST(TestBootstrappedParent) { TestBootrappedActor<TTestBoostrappedParent>(); } } diff --git a/ydb/core/actorlib_impl/actor_tracker_ut.cpp b/ydb/core/actorlib_impl/actor_tracker_ut.cpp index d804e3b9240..c94608c3a12 100644 --- a/ydb/core/actorlib_impl/actor_tracker_ut.cpp +++ b/ydb/core/actorlib_impl/actor_tracker_ut.cpp @@ -99,9 +99,9 @@ public: } }; -Y_UNIT_TEST_SUITE(TActorTracker) { +Y_UNIT_TEST_SUITE(TActorTracker) { - Y_UNIT_TEST(Basic) { + Y_UNIT_TEST(Basic) { { TTestBasicRuntime runtime; runtime.Initialize(NKikimr::TAppPrepare().Unwrap()); diff --git a/ydb/core/actorlib_impl/mad_squirrel.cpp b/ydb/core/actorlib_impl/mad_squirrel.cpp index 3f9629d0996..67f3b819c4a 100644 --- a/ydb/core/actorlib_impl/mad_squirrel.cpp +++ b/ydb/core/actorlib_impl/mad_squirrel.cpp @@ -19,7 +19,7 @@ public: {} STFUNC(StateFunc) { - Y_UNUSED(ev); + Y_UNUSED(ev); ctx.Send(ctx.SelfID, new TEvents::TEvWakeup()); } }; diff --git a/ydb/core/actorlib_impl/melancholic_gopher.cpp b/ydb/core/actorlib_impl/melancholic_gopher.cpp index 52a895aae4a..ed725c20874 100644 --- a/ydb/core/actorlib_impl/melancholic_gopher.cpp +++ b/ydb/core/actorlib_impl/melancholic_gopher.cpp @@ -77,7 +77,7 @@ public: , ShotsInRound(shotsInRound) , WaitFor(0) { - Y_VERIFY(!LineProfile.empty()); + Y_VERIFY(!LineProfile.empty()); } void Bootstrap(const TActorContext &ctx) { diff --git a/ydb/core/actorlib_impl/router_rr.h b/ydb/core/actorlib_impl/router_rr.h index f78f61d2be5..b59b2a2dacb 100644 --- a/ydb/core/actorlib_impl/router_rr.h +++ b/ydb/core/actorlib_impl/router_rr.h @@ -54,7 +54,7 @@ namespace NActors { } virtual TAutoPtr<NActors::IEventHandle> AfterRegister(const NActors::TActorId &self, const TActorId& parentId) override { - Y_UNUSED(parentId); + Y_UNUSED(parentId); return new NActors::IEventHandle(self, self, new TEvents::TEvBootstrap(), 0); } diff --git a/ydb/core/actorlib_impl/test_interconnect_ut.cpp b/ydb/core/actorlib_impl/test_interconnect_ut.cpp index 0d9d3535ef6..e9dfff526d4 100644 --- a/ydb/core/actorlib_impl/test_interconnect_ut.cpp +++ b/ydb/core/actorlib_impl/test_interconnect_ut.cpp @@ -17,7 +17,7 @@ namespace NKikimr { using namespace NActors; -Y_UNIT_TEST_SUITE(TInterconnectTest) { +Y_UNIT_TEST_SUITE(TInterconnectTest) { class TWall : public NActors::TActor<TWall> { public: TWall() noexcept @@ -117,7 +117,7 @@ Y_UNIT_TEST_SUITE(TInterconnectTest) { return serev; } - Y_UNIT_TEST(TestSimplePingPong) { + Y_UNIT_TEST(TestSimplePingPong) { TTestBasicRuntime runtime(2); runtime.SetLogPriority(NActorsServices::INTERCONNECT, NActors::NLog::PRI_DEBUG); @@ -132,7 +132,7 @@ Y_UNIT_TEST_SUITE(TInterconnectTest) { UNIT_ASSERT_EQUAL(handle->GetChannel(), 7); } - Y_UNIT_TEST(TestManyEvents) { + Y_UNIT_TEST(TestManyEvents) { TTestBasicRuntime runtime(2); runtime.Initialize(TAppPrepare().Unwrap()); const auto edge = runtime.AllocateEdgeActor(0); @@ -142,7 +142,7 @@ Y_UNIT_TEST_SUITE(TInterconnectTest) { runtime.GrabEdgeEvent<TEvents::TEvWakeup>(handle); } - Y_UNIT_TEST(TestCrossConnect) { + Y_UNIT_TEST(TestCrossConnect) { TInstant time = TInstant::Now(); constexpr ui64 iterations = NSan::PlainOrUnderSanitizer(200, 50); for (ui64 i = 0; i < iterations; ++i) { @@ -165,7 +165,7 @@ Y_UNIT_TEST_SUITE(TInterconnectTest) { } } - Y_UNIT_TEST(TestConnectAndDisconnect) { + Y_UNIT_TEST(TestConnectAndDisconnect) { TTestBasicRuntime runtime(2); runtime.Initialize(TAppPrepare().Unwrap()); const auto edge = runtime.AllocateEdgeActor(0); @@ -186,7 +186,7 @@ Y_UNIT_TEST_SUITE(TInterconnectTest) { } - Y_UNIT_TEST(TestBlobEvent) { + Y_UNIT_TEST(TestBlobEvent) { TTestBasicRuntime runtime(2); runtime.Initialize(TAppPrepare().Unwrap()); const auto edge = runtime.AllocateEdgeActor(1); @@ -203,7 +203,7 @@ Y_UNIT_TEST_SUITE(TInterconnectTest) { UNIT_ASSERT_EQUAL(event->Blob, blob); } - Y_UNIT_TEST(TestBlobEventPreSerialized) { + Y_UNIT_TEST(TestBlobEventPreSerialized) { TTestBasicRuntime runtime(2); runtime.SetDispatchTimeout(TDuration::Seconds(1)); runtime.Initialize(TAppPrepare().Unwrap()); @@ -229,7 +229,7 @@ Y_UNIT_TEST_SUITE(TInterconnectTest) { } } - Y_UNIT_TEST(TestNotifyUndelivered) { + Y_UNIT_TEST(TestNotifyUndelivered) { TTestBasicRuntime runtime(2); runtime.Initialize(TAppPrepare().Unwrap()); const auto edge0 = runtime.AllocateEdgeActor(0); @@ -250,7 +250,7 @@ Y_UNIT_TEST_SUITE(TInterconnectTest) { UNIT_ASSERT_EQUAL(event->Reason, TEvents::TEvUndelivered::Disconnected); } - Y_UNIT_TEST(TestSubscribeByFlag) { + Y_UNIT_TEST(TestSubscribeByFlag) { TTestBasicRuntime runtime(2); runtime.Initialize(TAppPrepare().Unwrap()); const auto edge = runtime.AllocateEdgeActor(0); @@ -269,7 +269,7 @@ Y_UNIT_TEST_SUITE(TInterconnectTest) { } } - Y_UNIT_TEST(TestReconnect) { + Y_UNIT_TEST(TestReconnect) { TTestBasicRuntime runtime(2); runtime.SetUseRealInterconnect(); runtime.SetLogPriority(NActorsServices::INTERCONNECT, NActors::NLog::PRI_DEBUG); @@ -305,7 +305,7 @@ Y_UNIT_TEST_SUITE(TInterconnectTest) { UNIT_ASSERT_EQUAL(handle->Sender, session); } - Y_UNIT_TEST(TestSubscribeAndUnsubsribeByEvent) { + Y_UNIT_TEST(TestSubscribeAndUnsubsribeByEvent) { TTestBasicRuntime runtime(3); runtime.Initialize(TAppPrepare().Unwrap()); const auto edge0 = runtime.AllocateEdgeActor(0); @@ -353,7 +353,7 @@ Y_UNIT_TEST_SUITE(TInterconnectTest) { } } - Y_UNIT_TEST(TestManyEventsWithReconnect) { + Y_UNIT_TEST(TestManyEventsWithReconnect) { TTestBasicRuntime runtime(2); runtime.SetLogPriority(NActorsServices::INTERCONNECT, NActors::NLog::PRI_DEBUG); SOCKET s = INVALID_SOCKET; @@ -389,7 +389,7 @@ Y_UNIT_TEST_SUITE(TInterconnectTest) { runtime.GrabEdgeEvent<TEvents::TEvWakeup>(handle); } - Y_UNIT_TEST(TestBlobEvent220Bytes) { + Y_UNIT_TEST(TestBlobEvent220Bytes) { TTestBasicRuntime runtime(2); runtime.Initialize(TAppPrepare().Unwrap()); const auto edge = runtime.AllocateEdgeActor(1); @@ -409,7 +409,7 @@ Y_UNIT_TEST_SUITE(TInterconnectTest) { UNIT_ASSERT_EQUAL(event->Blob, blob); } - Y_UNIT_TEST(TestBlobEvent220BytesPreSerialized) { + Y_UNIT_TEST(TestBlobEvent220BytesPreSerialized) { TTestBasicRuntime runtime(2); runtime.SetDispatchTimeout(TDuration::Seconds(1)); runtime.Initialize(TAppPrepare().Unwrap()); @@ -431,7 +431,7 @@ Y_UNIT_TEST_SUITE(TInterconnectTest) { UNIT_ASSERT_EQUAL(event->Blob, blob); } - Y_UNIT_TEST(TestBlobEventDifferentSizes) { + Y_UNIT_TEST(TestBlobEventDifferentSizes) { TTestBasicRuntime runtime(2); runtime.SetLogPriority(NActorsServices::INTERCONNECT, NActors::NLog::PRI_DEBUG); runtime.Initialize(TAppPrepare().Unwrap()); @@ -452,7 +452,7 @@ Y_UNIT_TEST_SUITE(TInterconnectTest) { } } - Y_UNIT_TEST(TestBlobEventDifferentSizesPreSerialized) { + Y_UNIT_TEST(TestBlobEventDifferentSizesPreSerialized) { TTestBasicRuntime runtime(2); runtime.SetDispatchTimeout(TDuration::Seconds(1)); runtime.Initialize(TAppPrepare().Unwrap()); @@ -474,7 +474,7 @@ Y_UNIT_TEST_SUITE(TInterconnectTest) { } } - Y_UNIT_TEST(TestBlobEventDifferentSizesPreSerializedAndRaw) { + Y_UNIT_TEST(TestBlobEventDifferentSizesPreSerializedAndRaw) { TTestBasicRuntime runtime(2); runtime.SetDispatchTimeout(TDuration::Seconds(1)); runtime.Initialize(TAppPrepare().Unwrap()); @@ -502,7 +502,7 @@ Y_UNIT_TEST_SUITE(TInterconnectTest) { } } - Y_UNIT_TEST(TestNotifyUndeliveredOnMissedActor) { + Y_UNIT_TEST(TestNotifyUndeliveredOnMissedActor) { TTestBasicRuntime runtime(2); runtime.Initialize(TAppPrepare().Unwrap()); const auto edge = runtime.AllocateEdgeActor(0); @@ -527,7 +527,7 @@ Y_UNIT_TEST_SUITE(TInterconnectTest) { UNIT_ASSERT_EQUAL(event->Reason, TEvents::TEvUndelivered::ReasonActorUnknown); } - Y_UNIT_TEST(TestBlobEventUpToMebibytes) { + Y_UNIT_TEST(TestBlobEventUpToMebibytes) { TTestBasicRuntime runtime(2); runtime.Initialize(TAppPrepare().Unwrap()); const auto edge = runtime.AllocateEdgeActor(1); @@ -545,7 +545,7 @@ Y_UNIT_TEST_SUITE(TInterconnectTest) { } } - Y_UNIT_TEST(TestPreSerializedBlobEventUpToMebibytes) { + Y_UNIT_TEST(TestPreSerializedBlobEventUpToMebibytes) { TTestBasicRuntime runtime(2); runtime.SetDispatchTimeout(TDuration::Seconds(1)); runtime.Initialize(TAppPrepare().Unwrap()); @@ -568,7 +568,7 @@ Y_UNIT_TEST_SUITE(TInterconnectTest) { } } - Y_UNIT_TEST(TestPingPongThroughSubChannel) { + Y_UNIT_TEST(TestPingPongThroughSubChannel) { TTestBasicRuntime runtime(2); runtime.Initialize(TAppPrepare().Unwrap()); const auto edge = runtime.AllocateEdgeActor(0); @@ -582,7 +582,7 @@ Y_UNIT_TEST_SUITE(TInterconnectTest) { UNIT_ASSERT_EQUAL(handle->GetSubChannel(), wall.LocalId()); } - Y_UNIT_TEST(TestBlobEventsThroughSubChannels) { + Y_UNIT_TEST(TestBlobEventsThroughSubChannels) { TTestBasicRuntime runtime(2); runtime.Initialize(TAppPrepare().Unwrap()); @@ -606,7 +606,7 @@ Y_UNIT_TEST_SUITE(TInterconnectTest) { } } - Y_UNIT_TEST(TestTraceIdPassThrough) { + Y_UNIT_TEST(TestTraceIdPassThrough) { TTestBasicRuntime runtime(2); runtime.SetLogPriority(NActorsServices::INTERCONNECT, NActors::NLog::PRI_DEBUG); @@ -633,7 +633,7 @@ Y_UNIT_TEST_SUITE(TInterconnectTest) { UNIT_ASSERT(handle->TraceId.IsFromSameTree(sentTraceId)); } - Y_UNIT_TEST(TestAddressResolve) { + Y_UNIT_TEST(TestAddressResolve) { TTestBasicRuntime runtime(2); runtime.Initialize(TAppPrepare().Unwrap()); const auto edge = runtime.AllocateEdgeActor(0); diff --git a/ydb/core/actorlib_impl/test_protocols_ut.cpp b/ydb/core/actorlib_impl/test_protocols_ut.cpp index 2e622406a05..ba82eb24ac1 100644 --- a/ydb/core/actorlib_impl/test_protocols_ut.cpp +++ b/ydb/core/actorlib_impl/test_protocols_ut.cpp @@ -103,7 +103,7 @@ namespace { }; } -Y_UNIT_TEST_SUITE(TestProtocols) { +Y_UNIT_TEST_SUITE(TestProtocols) { class TResolveTester : public TProtoReadyActor<TActorBootstrapped, TResolveTester> , public TResolveClientProtocol @@ -140,7 +140,7 @@ Y_UNIT_TEST_SUITE(TestProtocols) { }; - Y_UNIT_TEST(TestResolveProtocol) { + Y_UNIT_TEST(TestResolveProtocol) { for (size_t i = 0; i < 10; ++i) { TTestBasicRuntime runtime(2); runtime.Initialize(NKikimr::TAppPrepare().Unwrap()); @@ -217,7 +217,7 @@ Y_UNIT_TEST_SUITE(TestProtocols) { }; - Y_UNIT_TEST(TestConnectProtocol) { + Y_UNIT_TEST(TestConnectProtocol) { TPortManager portManager; const ui16 port = portManager.GetPort(); THTTP200OkServer serverImpl(""); @@ -346,7 +346,7 @@ Y_UNIT_TEST_SUITE(TestProtocols) { }; - Y_UNIT_TEST(TestHTTPCollected) { + Y_UNIT_TEST(TestHTTPCollected) { TPortManager portManager; const ui16 port = portManager.GetPort(); THTTP200OkServer serverImpl(""); @@ -681,7 +681,7 @@ Y_UNIT_TEST_SUITE(TestProtocols) { }; - Y_UNIT_TEST(TestHTTPRequest) { + Y_UNIT_TEST(TestHTTPRequest) { TPortManager portManager; const ui16 port = portManager.GetPort(); THTTP200OkServer serverImpl(""); diff --git a/ydb/core/base/appdata.h b/ydb/core/base/appdata.h index c666f7468c0..cd56f657fa0 100644 --- a/ydb/core/base/appdata.h +++ b/ydb/core/base/appdata.h @@ -183,7 +183,7 @@ struct TAppData { inline TAppData* AppData(TActorSystem* actorSystem) { Y_VERIFY_DEBUG(actorSystem); TAppData * const x = actorSystem->AppData<TAppData>(); - Y_VERIFY_DEBUG(x && x->Magic == TAppData::MagicTag); + Y_VERIFY_DEBUG(x && x->Magic == TAppData::MagicTag); return x; } diff --git a/ydb/core/base/blobstorage.h b/ydb/core/base/blobstorage.h index a2faee326e5..2d04d85f0fa 100644 --- a/ydb/core/base/blobstorage.h +++ b/ydb/core/base/blobstorage.h @@ -70,7 +70,7 @@ struct TStorageStatusFlags { return str.Str(); } - void Output(IOutputStream &out) const { + void Output(IOutputStream &out) const { out << "{" << ((Raw & NKikimrBlobStorage::StatusIsValid) ? " Valid" : "") << ((Raw & NKikimrBlobStorage::StatusDiskSpaceCyan) ? " Cyan" : "") @@ -255,7 +255,7 @@ struct TTabletChannelInfo { ui32 GroupForGeneration(ui32 gen) const { const size_t historySize = History.size(); - Y_VERIFY(historySize > 0, "empty channel history"); + Y_VERIFY(historySize > 0, "empty channel history"); const THistoryEntry * const first = &*History.begin(); if (historySize == 1) { @@ -405,7 +405,7 @@ inline ui32 GroupIDFromBlobStorageProxyID(TActorId actorId) { (((actorId.RawX2() >> (0 * 8)) & 0xff) << 8) | (((actorId.RawX2() >> (1 * 8)) & 0xff) << 16) | (((actorId.RawX2() >> (2 * 8)) & 0xff) << 24)); - Y_VERIFY(MakeBlobStorageProxyID(blobStorageGroup) == actorId); + Y_VERIFY(MakeBlobStorageProxyID(blobStorageGroup) == actorId); return blobStorageGroup; } @@ -954,7 +954,7 @@ struct TEvBlobStorage { {} TString Print(bool isFull) const { - Y_UNUSED(isFull); + Y_UNUSED(isFull); TStringStream str; str << "TEvPutResult {Id# " << Id.ToString(); str << " Status# " << NKikimrProto::EReplyStatus_Name(Status).data(); @@ -1067,7 +1067,7 @@ struct TEvBlobStorage { } TString Print(bool isFull) const { - Y_UNUSED(isFull); + Y_UNUSED(isFull); TStringStream str; str << "TEvGet {MustRestoreFirst# " << (MustRestoreFirst ? "true" : "false"); str << " GetHandleClass# " << NKikimrBlobStorage::EGetHandleClass_Name(GetHandleClass); @@ -1222,7 +1222,7 @@ struct TEvBlobStorage { {} TString Print(bool isFull) const { - Y_UNUSED(isFull); + Y_UNUSED(isFull); TStringStream str; str << "TEvBlock {TabletId# " << TabletId << " Generation# " << Generation @@ -1253,7 +1253,7 @@ struct TEvBlobStorage { {} TString Print(bool isFull) const { - Y_UNUSED(isFull); + Y_UNUSED(isFull); TStringStream str; str << "TEvBlockResult {Status# " << NKikimrProto::EReplyStatus_Name(Status).data(); if (ErrorReason.size()) { @@ -1576,7 +1576,7 @@ struct TEvBlobStorage { {} TString Print(bool isFull) const { - Y_UNUSED(isFull); + Y_UNUSED(isFull); TStringStream str; str << "TEvDiscover {TabletId# " << TabletId; str << " MinGeneration# " << MinGeneration; @@ -1613,7 +1613,7 @@ struct TEvBlobStorage { , MinGeneration(minGeneration) , BlockedGeneration(blockedGeneration) { - Y_VERIFY_DEBUG(status != NKikimrProto::OK); + Y_VERIFY_DEBUG(status != NKikimrProto::OK); } TEvDiscoverResult(const TLogoBlobID &id, ui32 minGeneration, const TString &buffer) @@ -1676,7 +1676,7 @@ struct TEvBlobStorage { {} TString Print(bool isFull) const { - Y_UNUSED(isFull); + Y_UNUSED(isFull); TStringStream str; str << "TEvRange {TabletId# " << TabletId; str << " From# " << From.ToString(); @@ -1823,7 +1823,7 @@ struct TEvBlobStorage { } TString Print(bool isFull) const { - Y_UNUSED(isFull); + Y_UNUSED(isFull); TStringStream str; str << "TEvCollectGarbage {TabletId# " << TabletId; str << " RecordGeneration# " << RecordGeneration; @@ -1900,7 +1900,7 @@ struct TEvBlobStorage { {} TString Print(bool isFull) const { - Y_UNUSED(isFull); + Y_UNUSED(isFull); TStringStream str; str << "TEvCollectGarbageResult {TabletId# " << TabletId; str << " RecordGeneration# " << RecordGeneration; @@ -2075,7 +2075,7 @@ static inline NKikimrBlobStorage::EVDiskQueueId HandleClassToQueueId(NKikimrBlob case NKikimrBlobStorage::EPutHandleClass::UserData: return NKikimrBlobStorage::EVDiskQueueId::PutUserData; default: - Y_FAIL("Unexpected case"); + Y_FAIL("Unexpected case"); } } diff --git a/ydb/core/base/blobstorage_grouptype_ut.cpp b/ydb/core/base/blobstorage_grouptype_ut.cpp index 1907b8e1274..12801e78f73 100644 --- a/ydb/core/base/blobstorage_grouptype_ut.cpp +++ b/ydb/core/base/blobstorage_grouptype_ut.cpp @@ -4,15 +4,15 @@ #include <library/cpp/testing/unittest/registar.h> #include <util/string/printf.h> -#include <util/stream/null.h> +#include <util/stream/null.h> namespace NKikimr { #define STR Cnull -Y_UNIT_TEST_SUITE(TBlobStorageGroupTypeTest) { +Y_UNIT_TEST_SUITE(TBlobStorageGroupTypeTest) { - Y_UNIT_TEST(TestCorrectLayout) { + Y_UNIT_TEST(TestCorrectLayout) { TBlobStorageGroupType groupType(TBlobStorageGroupType::Erasure3Plus1Stripe); ui32 blobSubgroupSize = groupType.BlobSubgroupSize(); @@ -124,7 +124,7 @@ Y_UNIT_TEST_SUITE(TBlobStorageGroupTypeTest) { #undef CORRECTION_DESCRIPTION } - Y_UNIT_TEST(OutputInfoAboutErasureSpecies) { + Y_UNIT_TEST(OutputInfoAboutErasureSpecies) { for (int i = TErasureType::ErasureNone; i < TErasureType::ErasureSpeciesCount; i++) { auto es = (TErasureType::EErasureSpecies)i; TBlobStorageGroupType groupType(es); diff --git a/ydb/core/base/domain.h b/ydb/core/base/domain.h index 05346e474aa..18ec955072b 100644 --- a/ydb/core/base/domain.h +++ b/ydb/core/base/domain.h @@ -284,19 +284,19 @@ struct TDomainsInfo : public TThrRefBase { ui32 GetDefaultStateStorageGroup(ui32 domainUid) const { auto it = Domains.find(domainUid); - Y_VERIFY(it != Domains.end(), "domainUid = %" PRIu32, domainUid); + Y_VERIFY(it != Domains.end(), "domainUid = %" PRIu32, domainUid); return it->second->DefaultStateStorageGroup; } ui32 GetDefaultHiveUid(ui32 domainUid) const { auto it = Domains.find(domainUid); - Y_VERIFY(it != Domains.end(), "domainUid = %" PRIu32, domainUid); + Y_VERIFY(it != Domains.end(), "domainUid = %" PRIu32, domainUid); return it->second->DefaultHiveUid; } ui32 GetStateStorageGroupDomainUid(ui32 stateStorageGroup) const { auto it = DomainByStateStorageGroup.find(stateStorageGroup); - Y_VERIFY(it != DomainByStateStorageGroup.end(), "stateStorageGroup = %" PRIu32, stateStorageGroup); + Y_VERIFY(it != DomainByStateStorageGroup.end(), "stateStorageGroup = %" PRIu32, stateStorageGroup); return it->second->DomainUid; } @@ -310,7 +310,7 @@ struct TDomainsInfo : public TThrRefBase { const TDomain& GetDomain(ui32 domainUid) const { auto it = Domains.find(domainUid); - Y_VERIFY(it != Domains.end(), "domainUid = %" PRIu32, domainUid); + Y_VERIFY(it != Domains.end(), "domainUid = %" PRIu32, domainUid); return *(it->second); } diff --git a/ydb/core/base/localdb.cpp b/ydb/core/base/localdb.cpp index d07ee26fc1f..d1b3e2d91c7 100644 --- a/ydb/core/base/localdb.cpp +++ b/ydb/core/base/localdb.cpp @@ -150,7 +150,7 @@ TCompactionPolicy::TCompactionPolicy(const NKikimrSchemeOp::TCompactionPolicy& p Generations.reserve(policyPb.GenerationSize()); for (ui32 i = 0; i < policyPb.GenerationSize(); ++i) { const auto& g = policyPb.GetGeneration(i); - Y_VERIFY_DEBUG(g.GetGenerationId() == i); + Y_VERIFY_DEBUG(g.GetGenerationId() == i); Generations.emplace_back(g); } if (policyPb.HasShardPolicy()) { diff --git a/ydb/core/base/logoblob.cpp b/ydb/core/base/logoblob.cpp index 4bea376f60a..44d65ccff45 100644 --- a/ydb/core/base/logoblob.cpp +++ b/ydb/core/base/logoblob.cpp @@ -16,7 +16,7 @@ TString TLogoBlobID::ToString() const { PartId()).data(); } -void TLogoBlobID::Out(IOutputStream &o) const { +void TLogoBlobID::Out(IOutputStream &o) const { char buf[240]; sprintf(buf, "[%" PRIu64 ":%" PRIu32 ":%" PRIu32 ":%" PRIu32 ":%" PRIu32 ":%" PRIu32 ":%" PRIu32 "]", diff --git a/ydb/core/base/logoblob.h b/ydb/core/base/logoblob.h index 36eea54393a..f8a2112de1c 100644 --- a/ydb/core/base/logoblob.h +++ b/ydb/core/base/logoblob.h @@ -21,7 +21,7 @@ namespace NKikimr { explicit TLogoBlobID(const TLogoBlobID &source, ui32 partId) { - Y_VERIFY_DEBUG(partId < 16); + Y_VERIFY_DEBUG(partId < 16); Raw.X[0] = source.Raw.X[0]; Raw.X[1] = source.Raw.X[1]; Raw.X[2] = (source.Raw.X[2] & 0xFFFFFFFFFFFFFFF0ull) | partId; @@ -34,7 +34,7 @@ namespace NKikimr { explicit TLogoBlobID(ui64 tabletId, ui32 generation, ui32 step, ui32 channel, ui32 blobSize, ui32 cookie, ui32 partId) { - Y_VERIFY_DEBUG(partId != 0); + Y_VERIFY_DEBUG(partId != 0); Set(tabletId, generation, step, channel, blobSize, cookie, partId, 0); } @@ -101,7 +101,7 @@ namespace NKikimr { const ui64* GetRaw() const { return Raw.X; } TString ToString() const; - void Out(IOutputStream &o) const; + void Out(IOutputStream &o) const; static bool Parse(TLogoBlobID &out, const TString &buf, TString &errorExplanation); static void Out(IOutputStream &o, const TVector<TLogoBlobID> &vec); @@ -201,10 +201,10 @@ namespace NKikimr { void Set(ui64 tabletId, ui32 generation, ui32 step, ui32 channel, ui32 blobSize, ui32 cookie, ui32 partId, ui32 crcMode) { - Y_VERIFY_DEBUG(channel <= MaxChannel); + Y_VERIFY_DEBUG(channel <= MaxChannel); Y_VERIFY(blobSize <= MaxBlobSize); - Y_VERIFY_DEBUG(cookie <= MaxCookie); - Y_VERIFY_DEBUG(partId <= MaxPartId); + Y_VERIFY_DEBUG(cookie <= MaxCookie); + Y_VERIFY_DEBUG(partId <= MaxPartId); Y_VERIFY(crcMode <= MaxCrcMode); Raw.N.TabletID = tabletId; @@ -305,7 +305,7 @@ namespace NKikimr { } template<> -inline void Out<NKikimr::TLogoBlobID>(IOutputStream& o, const NKikimr::TLogoBlobID &x) { +inline void Out<NKikimr::TLogoBlobID>(IOutputStream& o, const NKikimr::TLogoBlobID &x) { return x.Out(o); } diff --git a/ydb/core/base/logoblob_ut.cpp b/ydb/core/base/logoblob_ut.cpp index 75d9d2b833b..30555f5d059 100644 --- a/ydb/core/base/logoblob_ut.cpp +++ b/ydb/core/base/logoblob_ut.cpp @@ -4,9 +4,9 @@ #include <util/generic/ptr.h> namespace NKikimr { - Y_UNIT_TEST_SUITE(TLogoBlobTest) { + Y_UNIT_TEST_SUITE(TLogoBlobTest) { - Y_UNIT_TEST(LogoBlobParse) { + Y_UNIT_TEST(LogoBlobParse) { TLogoBlobID id; TString explanation; bool res = false; @@ -24,7 +24,7 @@ namespace NKikimr { UNIT_ASSERT(res); } - Y_UNIT_TEST(LogoBlobCompare) { + Y_UNIT_TEST(LogoBlobCompare) { bool res = false; const TLogoBlobID left(1, 0x30002C2D, 0x50005F6F, 1, 0x3333, 0x0001A01B); @@ -73,7 +73,7 @@ namespace NKikimr { UNIT_ASSERT(left.IsSameBlob(TLogoBlobID(1, 0x30002C2D, 0x50005F6F, 1, 0x3333, 0x0001A01B, 1))); } - Y_UNIT_TEST(LogoBlobSort) { + Y_UNIT_TEST(LogoBlobSort) { TVector<TLogoBlobID> vec; vec.emplace_back(TLogoBlobID(66, 1, 0, 0, 110, 20)); vec.emplace_back(TLogoBlobID(66, 1, 0, 0, 109, 21)); @@ -113,8 +113,8 @@ namespace NKikimr { } } - Y_UNIT_TEST_SUITE(TLogoBlobIdHashTest) { - Y_UNIT_TEST(SimpleTest) { + Y_UNIT_TEST_SUITE(TLogoBlobIdHashTest) { + Y_UNIT_TEST(SimpleTest) { // ui64 tabletId, ui32 generation, ui32 step, ui32 channel, ui32 blobSize, ui32 cookie UNIT_ASSERT_VALUES_EQUAL(0x13150f70, TLogoBlobID(42, 1, 1, 0, 100, 15).Hash()); UNIT_ASSERT_VALUES_EQUAL(0xc05a9a80, TLogoBlobID(42, 2, 1, 0, 100, 15).Hash()); @@ -124,7 +124,7 @@ namespace NKikimr { UNIT_ASSERT_VALUES_EQUAL(0x6b67039d, TLogoBlobID(42, 1, 1, 0, 100, 16).Hash()); } - Y_UNIT_TEST(SimpleTestPartIdDoesNotMatter) { + Y_UNIT_TEST(SimpleTestPartIdDoesNotMatter) { // ui64 tabletId, ui32 generation, ui32 step, ui32 channel, ui32 blobSize, ui32 cookie, ui32 partId ui32 partId = 1; UNIT_ASSERT_VALUES_EQUAL(0x13150f70, TLogoBlobID(42, 1, 1, 0, 100, 15, partId).Hash()); @@ -151,7 +151,7 @@ namespace NKikimr { UNIT_ASSERT_VALUES_EQUAL(0x6b67039d, TLogoBlobID(42, 1, 1, 0, 100, 16, partId).Hash()); } - Y_UNIT_TEST(SimpleTestBlobSizeDoesNotMatter) { + Y_UNIT_TEST(SimpleTestBlobSizeDoesNotMatter) { // ui64 tabletId, ui32 generation, ui32 step, ui32 channel, ui32 blobSize, ui32 cookie, ui32 partId ui32 partId = 1; UNIT_ASSERT_VALUES_EQUAL(0x13150f70, TLogoBlobID(42, 1, 1, 0, 32423523, 15, partId).Hash()); @@ -162,7 +162,7 @@ namespace NKikimr { UNIT_ASSERT_VALUES_EQUAL(0x6b67039d, TLogoBlobID(42, 1, 1, 0, 58435455, 16, partId).Hash()); } - Y_UNIT_TEST(SimpleTestWithDifferentTabletId) { + Y_UNIT_TEST(SimpleTestWithDifferentTabletId) { // ui64 tabletId, ui32 generation, ui32 step, ui32 channel, ui32 blobSize, ui32 cookie UNIT_ASSERT_VALUES_EQUAL(0x13150f70, TLogoBlobID(42, 1, 1, 0, 100, 15).Hash()); UNIT_ASSERT_VALUES_EQUAL(0x13330eae, TLogoBlobID(43, 1, 1, 0, 100, 15).Hash()); @@ -173,7 +173,7 @@ namespace NKikimr { UNIT_ASSERT_VALUES_EQUAL(0x13ab0ba4, TLogoBlobID(47, 1, 1, 0, 100, 15).Hash()); } - Y_UNIT_TEST(SimpleTestWithDifferentSteps) { + Y_UNIT_TEST(SimpleTestWithDifferentSteps) { // ui64 tabletId, ui32 generation, ui32 step, ui32 channel, ui32 blobSize, ui32 cookie UNIT_ASSERT_VALUES_EQUAL(0x13150f70, TLogoBlobID(42, 1, 1, 0, 100, 15).Hash()); UNIT_ASSERT_VALUES_EQUAL(0xc05a9a80, TLogoBlobID(42, 2, 1, 0, 100, 15).Hash()); @@ -183,7 +183,7 @@ namespace NKikimr { UNIT_ASSERT_VALUES_EQUAL(0x7570c6bf, TLogoBlobID(42, 6, 1, 0, 100, 15).Hash()); } - Y_UNIT_TEST(SimpleTestWithDifferentChannel) { + Y_UNIT_TEST(SimpleTestWithDifferentChannel) { // ui64 tabletId, ui32 generation, ui32 step, ui32 channel, ui32 blobSize, ui32 cookie UNIT_ASSERT_VALUES_EQUAL(0x13150f70, TLogoBlobID(42, 1, 1, 0, 100, 15).Hash()); UNIT_ASSERT_VALUES_EQUAL(0x6dbe758a, TLogoBlobID(42, 1, 1, 1, 100, 15).Hash()); diff --git a/ydb/core/base/statestorage.cpp b/ydb/core/base/statestorage.cpp index de39a327ae1..0e856b0d43d 100644 --- a/ydb/core/base/statestorage.cpp +++ b/ydb/core/base/statestorage.cpp @@ -54,7 +54,7 @@ public: , Delta(Primes[hash % 128]) , A(hash + Delta) { - Y_VERIFY_DEBUG(Delta > Sz); + Y_VERIFY_DEBUG(Delta > Sz); } ui32 Next() { diff --git a/ydb/core/base/statestorage_guardian.cpp b/ydb/core/base/statestorage_guardian.cpp index f1df97896b5..2ab3329a2fb 100644 --- a/ydb/core/base/statestorage_guardian.cpp +++ b/ydb/core/base/statestorage_guardian.cpp @@ -167,7 +167,7 @@ class TReplicaGuardian : public TActorBootstrapped<TReplicaGuardian> { } else if (status == NKikimrProto::ERROR) { return UpdateInfo(); } else { - Y_FAIL(); + Y_FAIL(); } } public: @@ -357,7 +357,7 @@ class TTabletGuardian : public TActorBootstrapped<TTabletGuardian> { void Handle(TEvStateStorage::TEvResolveReplicasList::TPtr &ev) { const TVector<TActorId> &replicasList = ev->Get()->Replicas; - Y_VERIFY(!replicasList.empty(), "must not happens, guardian must be created over active tablet"); + Y_VERIFY(!replicasList.empty(), "must not happens, guardian must be created over active tablet"); const ui32 replicaSz = replicasList.size(); @@ -402,8 +402,8 @@ class TTabletGuardian : public TActorBootstrapped<TTabletGuardian> { } void Handle(TEvents::TEvUndelivered::TPtr &ev) { - Y_UNUSED(ev); - Y_FAIL("must not happens, guardian must be created over active tablet"); + Y_UNUSED(ev); + Y_FAIL("must not happens, guardian must be created over active tablet"); } bool ReplicaDown(TActorId guardian) { diff --git a/ydb/core/base/statestorage_monitoring.cpp b/ydb/core/base/statestorage_monitoring.cpp index 5bcc3ec67fa..1cfa941679c 100644 --- a/ydb/core/base/statestorage_monitoring.cpp +++ b/ydb/core/base/statestorage_monitoring.cpp @@ -150,7 +150,7 @@ class TStateStorageMonitoringActor : public TActorBootstrapped<TStateStorageMoni void Handle(TEvStateStorage::TEvReplicaInfo::TPtr &ev, const TActorContext &ctx) { const NKikimrStateStorage::TEvInfo &record = ev->Get()->Record; const ui64 cookie = record.GetCookie(); - Y_VERIFY(cookie < ReplicasInfo.size()); + Y_VERIFY(cookie < ReplicasInfo.size()); auto &xinfo = ReplicasInfo[cookie]; @@ -175,7 +175,7 @@ class TStateStorageMonitoringActor : public TActorBootstrapped<TStateStorageMoni } void HandleInit(TEvents::TEvUndelivered::TPtr &ev, const TActorContext &ctx) { - Y_UNUSED(ev); + Y_UNUSED(ev); return Reply("unknown state storage", ctx); } diff --git a/ydb/core/base/statestorage_proxy.cpp b/ydb/core/base/statestorage_proxy.cpp index 13d396cb0f1..4a368c3ce53 100644 --- a/ydb/core/base/statestorage_proxy.cpp +++ b/ydb/core/base/statestorage_proxy.cpp @@ -173,7 +173,7 @@ class TStateStorageProxyRequest : public TActor<TStateStorageProxyRequest> { } void MergeConnectionError(ui64 cookie) { - Y_VERIFY(cookie < Replicas); + Y_VERIFY(cookie < Replicas); if (Signature[cookie] == 0) { Signature[cookie] = Max<ui64>(); @@ -226,7 +226,7 @@ class TStateStorageProxyRequest : public TActor<TStateStorageProxyRequest> { } else if (status == NKikimrProto::ERROR) { ReplicaSelection->MergeReply(TStateStorageInfo::TSelection::StatusNoInfo, &ReplyStatus, cookie, false); } else { - Y_FAIL(); + Y_FAIL(); } for (ui32 i = 0, end = record.FollowerSize(); i < end; ++i) { @@ -319,7 +319,7 @@ class TStateStorageProxyRequest : public TActor<TStateStorageProxyRequest> { ReplyAndDie(NKikimrProto::RACE); return; } - Y_VERIFY_DEBUG(false); + Y_VERIFY_DEBUG(false); PassAway(); } @@ -390,7 +390,7 @@ class TStateStorageProxyRequest : public TActor<TStateStorageProxyRequest> { ReplyAndDie(NKikimrProto::RACE); return; } - Y_VERIFY_DEBUG(false); + Y_VERIFY_DEBUG(false); PassAway(); } @@ -455,7 +455,7 @@ class TStateStorageProxyRequest : public TActor<TStateStorageProxyRequest> { } void UpdateSigFor(ui64 cookie, ui64 sig) { - Y_VERIFY(cookie < Replicas); + Y_VERIFY(cookie < Replicas); if (Signature[cookie] == 0) { Signature[cookie] = sig; diff --git a/ydb/core/base/statestorage_replica.cpp b/ydb/core/base/statestorage_replica.cpp index aca41acb16a..acaad5f0dc4 100644 --- a/ydb/core/base/statestorage_replica.cpp +++ b/ydb/core/base/statestorage_replica.cpp @@ -180,7 +180,7 @@ class TStateStorageReplica : public TActor<TStateStorageReplica> { TEvStateStorage::TEvReplicaLookup *msg = ev->Get(); BLOG_D("Replica::Handle ev: " << msg->ToString()); const ui64 tabletId = msg->Record.GetTabletID(); - Y_VERIFY_DEBUG(StateStorageGroupFromTabletID(tabletId) == Info->StateStorageGroup, + Y_VERIFY_DEBUG(StateStorageGroupFromTabletID(tabletId) == Info->StateStorageGroup, "tabletId# %" PRIu64 " SSGFTID# %" PRIu64 " SSG# %" PRIu64, (ui64)tabletId, (ui64)StateStorageGroupFromTabletID(tabletId), (ui64)Info->StateStorageGroup); TTablets::const_iterator it = Tablets.find(msg->Record.GetTabletID()); @@ -210,7 +210,7 @@ class TStateStorageReplica : public TActor<TStateStorageReplica> { TEvStateStorage::TEvReplicaUpdate *msg = ev->Get(); BLOG_D("Replica::Handle ev: " << msg->ToString()); const ui64 tabletId = msg->Record.GetTabletID(); - Y_VERIFY_DEBUG(StateStorageGroupFromTabletID(tabletId) == Info->StateStorageGroup); + Y_VERIFY_DEBUG(StateStorageGroupFromTabletID(tabletId) == Info->StateStorageGroup); TEntry *x = nullptr; auto tabletIt = Tablets.find(tabletId); @@ -298,7 +298,7 @@ class TStateStorageReplica : public TActor<TStateStorageReplica> { TEvStateStorage::TEvReplicaLock *msg = ev->Get(); BLOG_D("Replica::Handle ev: " << msg->ToString()); const ui64 tabletId = msg->Record.GetTabletID(); - Y_VERIFY_DEBUG(StateStorageGroupFromTabletID(tabletId) == Info->StateStorageGroup); + Y_VERIFY_DEBUG(StateStorageGroupFromTabletID(tabletId) == Info->StateStorageGroup); const TActorId &sender = ev->Sender; if (CheckSignature(msg)) { @@ -426,7 +426,7 @@ public: , Info(info) , ReplicaIndex(replicaIndex) { - Y_UNUSED(ReplicaIndex); + Y_UNUSED(ReplicaIndex); } STATEFN(StateInit) { diff --git a/ydb/core/base/tablet.h b/ydb/core/base/tablet.h index 602e39c6000..7cce449ee4c 100644 --- a/ydb/core/base/tablet.h +++ b/ydb/core/base/tablet.h @@ -368,7 +368,7 @@ struct TEvTablet { TABLET_DEAD_REASON_MAP(ENUM_VALUE_GEN) }; - static void Out(IOutputStream& o, EReason x); + static void Out(IOutputStream& o, EReason x); static const char* Str(EReason status); const ui64 TabletID; @@ -786,7 +786,7 @@ IActor* CreateTabletReqReset(const TActorId &replyTo, const TIntrusivePtr<TTable } template<> -inline void Out<NKikimr::TEvTablet::TEvTabletDead::EReason>(IOutputStream& o, NKikimr::TEvTablet::TEvTabletDead::EReason x) { +inline void Out<NKikimr::TEvTablet::TEvTabletDead::EReason>(IOutputStream& o, NKikimr::TEvTablet::TEvTabletDead::EReason x) { return NKikimr::TEvTablet::TEvTabletDead::Out(o, x); } diff --git a/ydb/core/base/tabletid.h b/ydb/core/base/tabletid.h index cd0a7cb58f0..9584e001b34 100644 --- a/ydb/core/base/tabletid.h +++ b/ydb/core/base/tabletid.h @@ -45,19 +45,19 @@ namespace NKikimr { // 8 + 12 + 44 inline ui64 MakeTabletID(ui64 stateStorageGroup, ui64 hiveUid, ui64 uniqPart) { - Y_VERIFY(stateStorageGroup < (1ull << 8ull) && hiveUid < (1ull << 12ull) && uniqPart < (1ull << 44ull)); + Y_VERIFY(stateStorageGroup < (1ull << 8ull) && hiveUid < (1ull << 12ull) && uniqPart < (1ull << 44ull)); return (stateStorageGroup << 56ull) | (hiveUid << 44ull) | uniqPart; } // blob storage controller (exactly one per domain in default state storage group) inline ui64 MakeBSControllerID(ui64 stateStorageGroup) { - Y_VERIFY_DEBUG(stateStorageGroup < (1ull << 8ull)); + Y_VERIFY_DEBUG(stateStorageGroup < (1ull << 8ull)); return MakeTabletID(stateStorageGroup, 0, 0x1001); } // one default hive per domain (in default state storage group!) inline ui64 MakeDefaultHiveID(ui64 stateStorageGroup) { - Y_VERIFY_DEBUG(stateStorageGroup < (1ull << 8ull)); + Y_VERIFY_DEBUG(stateStorageGroup < (1ull << 8ull)); return MakeTabletID(stateStorageGroup, 0, 1); } @@ -88,7 +88,7 @@ namespace NKikimr { // TODO: think about encoding scheme for sibling group hive inline TActorId MakeStateStorageProxyID(ui64 stateStorageGroup) { - Y_VERIFY_DEBUG(stateStorageGroup < (1ull << 8ull)); + Y_VERIFY_DEBUG(stateStorageGroup < (1ull << 8ull)); char x[12] = { 's', 't', 's', 'p', 'r', 'o', 'x', 'y' }; x[8] = (char)stateStorageGroup; return TActorId(0, TStringBuf(x, 12)); diff --git a/ydb/core/blobstorage/backpressure/queue_backpressure_client_ut.cpp b/ydb/core/blobstorage/backpressure/queue_backpressure_client_ut.cpp index af14a13f2d0..d81ae2e28c4 100644 --- a/ydb/core/blobstorage/backpressure/queue_backpressure_client_ut.cpp +++ b/ydb/core/blobstorage/backpressure/queue_backpressure_client_ut.cpp @@ -281,9 +281,9 @@ public: } }; -Y_UNIT_TEST_SUITE(TBlobStorageQueueTest) { +Y_UNIT_TEST_SUITE(TBlobStorageQueueTest) { - Y_UNIT_TEST(TMessageLost) { + Y_UNIT_TEST(TMessageLost) { // https://st.yandex-team.ru/KIKIMR-9570 this test not is incorrect because we don't allow 'lost messages' // without proper interconnect notification; local messages can't be just lost while VDisk is operational return; // TODO(alexvru) diff --git a/ydb/core/blobstorage/backpressure/queue_backpressure_server.h b/ydb/core/blobstorage/backpressure/queue_backpressure_server.h index c1f8a7e3952..d12cf3c3819 100644 --- a/ydb/core/blobstorage/backpressure/queue_backpressure_server.h +++ b/ydb/core/blobstorage/backpressure/queue_backpressure_server.h @@ -27,7 +27,7 @@ namespace NKikimr { return ::NKikimr::NBackpressure::Good(TBase::first.Status); } - void Output(IOutputStream &str) const { + void Output(IOutputStream &str) const { str << TBase::first.ToString(); } }; @@ -66,7 +66,7 @@ namespace NKikimr { , NHighWatermarkOverflow(0) {} - void Output(IOutputStream &str) const { + void Output(IOutputStream &str) const { str << "NSuccess# " << NSuccess << " NWindowUpdate# " << NWindowUpdate << " NProcessed# " << NProcessed << " NIncorrectMsgId# " << NIncorrectMsgId << " NHighWatermarkOverflow# " << NHighWatermarkOverflow; @@ -123,7 +123,7 @@ namespace NKikimr { } void UpdateCountdown(ui64 costChange) { - Y_VERIFY_DEBUG(costChange); + Y_VERIFY_DEBUG(costChange); if (CostChangeUntilFrozenCountdown > 0) { if (CostChangeUntilFrozenCountdown >= costChange) { CostChangeUntilFrozenCountdown -= costChange; @@ -168,8 +168,8 @@ namespace NKikimr { void Push(bool checkMsgId, const TMessageId &msgId, ui64 cost, TWindowStatus *opStatus, TInstant now) { - Y_VERIFY_DEBUG(LowWatermark != 0); - Y_VERIFY_DEBUG(LowWatermark <= HighWatermark); + Y_VERIFY_DEBUG(LowWatermark != 0); + Y_VERIFY_DEBUG(LowWatermark <= HighWatermark); Y_VERIFY_DEBUG(cost > 0); if ((msgId.MsgId == ExpectedMsgId.MsgId && msgId.SequenceId >= ExpectedMsgId.SequenceId) || !checkMsgId) { @@ -197,9 +197,9 @@ namespace NKikimr { } TWindowStatus *Processed(bool checkMsgId, const TMessageId &msgId, ui64 cost, TWindowStatus *opStatus) { - Y_UNUSED(checkMsgId); - Y_UNUSED(msgId); - Y_VERIFY(Cost >= cost); + Y_UNUSED(checkMsgId); + Y_UNUSED(msgId); + Y_VERIFY(Cost >= cost); Cost -= cost; --InFlight; SetStatus(opStatus, NKikimrBlobStorage::TWindowFeedback::Processed, true); @@ -219,7 +219,7 @@ namespace NKikimr { // ... check difference between LastMaxWindowSize and LowWatermark ui64 diff = (LowWatermark >= LastMaxWindowSize) ? (LowWatermark - LastMaxWindowSize) : (LastMaxWindowSize - LowWatermark); - Y_VERIFY(LowWatermark != 0); + Y_VERIFY(LowWatermark != 0); notify = (diff * 100u / LowWatermark >= PercentThreshold); } @@ -243,7 +243,7 @@ namespace NKikimr { } void Fade(EWindowState state, ui64 costChange, TInstant now) { - Y_VERIFY(state == GetState(now)); + Y_VERIFY(state == GetState(now)); // TODO: we can implement more gracefull fading, take into account that beside this fading // we recalculate windows on regular basis @@ -252,7 +252,7 @@ namespace NKikimr { case EWindowState::Fading: case EWindowState::Frozen: break; - default: Y_FAIL("Unexpected case"); + default: Y_FAIL("Unexpected case"); } UpdateCountdown(costChange); } @@ -265,7 +265,7 @@ namespace NKikimr { return ExpectedMsgId; } - void Output(IOutputStream &str) const { + void Output(IOutputStream &str) const { str << "ClientId# " << ClientId << " ExpectedMsgId# " << ExpectedMsgId << " Cost# " << Cost << " LowWatermark# " << LowWatermark << " HighWatermark# " << HighWatermark @@ -328,7 +328,7 @@ namespace NKikimr { } case EWindowState::Fading: { // until frozen we use this window for recalculation - Y_VERIFY(wPtr->GetCost() == 0); + Y_VERIFY(wPtr->GetCost() == 0); ActiveWindowsCache.push_back(wPtr); totalCost += wPtr->GetCost(); wPtr->Fade(windowState, actualCostChange, now); @@ -336,19 +336,19 @@ namespace NKikimr { break; } case EWindowState::Frozen: { - Y_VERIFY(wPtr->GetCost() == 0); + Y_VERIFY(wPtr->GetCost() == 0); wPtr->Fade(windowState, actualCostChange, now); ++it; break; } case EWindowState::Dead: { - Y_VERIFY(wPtr->GetCost() == 0); + Y_VERIFY(wPtr->GetCost() == 0); TIterator prev = it++; AllWindows.erase(prev); break; } default: - Y_FAIL("Unexpected case"); + Y_FAIL("Unexpected case"); } } @@ -430,7 +430,7 @@ namespace NKikimr { WindowTimeout, now)); auto res = AllWindows.emplace(actorId, window); it = res.first; - Y_VERIFY(res.second); + Y_VERIFY(res.second); newWindow = true; } TWindow &window = *(it->second); @@ -447,7 +447,7 @@ namespace NKikimr { // find window auto it = AllWindows.find(actorId); - Y_VERIFY(it != AllWindows.end()); + Y_VERIFY(it != AllWindows.end()); TWindow &window = *(it->second); // perform action @@ -464,7 +464,7 @@ namespace NKikimr { } } - void Output(IOutputStream &str, TInstant now) const { + void Output(IOutputStream &str, TInstant now) const { str << "MaxCost# " << MaxCost; ui64 actualCost = 0; ui32 windowTypesHisto[unsigned(EWindowState::Max)]; @@ -494,13 +494,13 @@ namespace NKikimr { } // NKikimr template<> -inline void Out<NKikimr::NBackpressure::TMessageId>(IOutputStream& o, +inline void Out<NKikimr::NBackpressure::TMessageId>(IOutputStream& o, const NKikimr::NBackpressure::TMessageId &x) { return x.Out(o); } template<> -inline void Out<NKikimr::NBackpressure::TQueueClientId>(IOutputStream& o, +inline void Out<NKikimr::NBackpressure::TQueueClientId>(IOutputStream& o, const NKikimr::NBackpressure::TQueueClientId &x) { return x.Output(o); } diff --git a/ydb/core/blobstorage/backpressure/queue_backpressure_server_ut.cpp b/ydb/core/blobstorage/backpressure/queue_backpressure_server_ut.cpp index 4c6e357de6b..0d72fa8c4db 100644 --- a/ydb/core/blobstorage/backpressure/queue_backpressure_server_ut.cpp +++ b/ydb/core/blobstorage/backpressure/queue_backpressure_server_ut.cpp @@ -1,21 +1,21 @@ #include "queue_backpressure_server.h" #include <library/cpp/testing/unittest/registar.h> -#include <util/stream/null.h> - +#include <util/stream/null.h> + #define STR Cnull #define VERBOSE_STR Cnull namespace NKikimr { - Y_UNIT_TEST_SUITE(TQueueBackpressureTest) { + Y_UNIT_TEST_SUITE(TQueueBackpressureTest) { using namespace NBackpressure; using TFeedback = ::NKikimr::NBackpressure::TFeedback<ui64>; - Y_UNIT_TEST(CreateDelete) { + Y_UNIT_TEST(CreateDelete) { TQueueBackpressure<ui64> qb(true, 100u, 10u); TInstant now = Now(); @@ -33,7 +33,7 @@ namespace NKikimr { } - Y_UNIT_TEST(IncorrectMessageId) { + Y_UNIT_TEST(IncorrectMessageId) { TQueueBackpressure<ui64> qb(true, 100u, 10u); TInstant now = Now(); @@ -117,13 +117,13 @@ namespace NKikimr { if (InFlight == MaxInFlight) { const TMessageId temp(MsgId.SequenceId, MsgId.MsgId - InFlight); auto res = qb.Processed(ActorId, temp, 1, now); - Y_VERIFY(Good(res.first.Status)); + Y_VERIFY(Good(res.first.Status)); VERBOSE_STR << "LOAD: Processed: MsgId# " << temp.ToString() << "\n"; InFlight--; return res; } else { auto res = qb.Push(Id, ActorId, MsgId, 1, now); - Y_VERIFY(Good(res.first.Status)); + Y_VERIFY(Good(res.first.Status)); VERBOSE_STR << "LOAD: Push: MsgId# " << MsgId.ToString() << "\n"; InFlight++; MsgId.MsgId++; @@ -141,7 +141,7 @@ namespace NKikimr { }; - Y_UNIT_TEST(PerfTrivial) { + Y_UNIT_TEST(PerfTrivial) { TQueueBackpressure<ui64> qb(true, 100u, 10u); TVector<IClientPtr> clients; @@ -173,7 +173,7 @@ namespace NKikimr { } } - Y_UNIT_TEST(PerfInFlight) { + Y_UNIT_TEST(PerfInFlight) { TQueueBackpressure<ui64> qb(true, 100u, 10u); TInstant now = Now(); diff --git a/ydb/core/blobstorage/base/blobstorage_syncstate.h b/ydb/core/blobstorage/base/blobstorage_syncstate.h index 52c21a94504..e45ab46a75d 100644 --- a/ydb/core/blobstorage/base/blobstorage_syncstate.h +++ b/ydb/core/blobstorage/base/blobstorage_syncstate.h @@ -37,12 +37,12 @@ namespace NKikimr { return !operator ==(x); } - void Serialize(IOutputStream &s) const { + void Serialize(IOutputStream &s) const { s.Write(&Guid, sizeof(Guid)); s.Write(&SyncedLsn, sizeof(SyncedLsn)); } - bool Deserialize(IInputStream &s) { + bool Deserialize(IInputStream &s) { if (s.Load(&Guid, sizeof(Guid)) != sizeof(Guid)) return false; if (s.Load(&SyncedLsn, sizeof(SyncedLsn)) != sizeof(SyncedLsn)) @@ -50,7 +50,7 @@ namespace NKikimr { return true; } - void Output(IOutputStream &str) const { + void Output(IOutputStream &str) const { str << "[" << Guid << " " << SyncedLsn << "]"; } diff --git a/ydb/core/blobstorage/base/blobstorage_vdiskid.cpp b/ydb/core/blobstorage/base/blobstorage_vdiskid.cpp index e5a6cb7d42f..a96d94ad952 100644 --- a/ydb/core/blobstorage/base/blobstorage_vdiskid.cpp +++ b/ydb/core/blobstorage/base/blobstorage_vdiskid.cpp @@ -16,7 +16,7 @@ namespace NKikimr { , VDisk(vdiskIdShort.VDisk) {} - TVDiskID::TVDiskID(IInputStream &str) { + TVDiskID::TVDiskID(IInputStream &str) { if (!Deserialize(str)) ythrow yexception() << "incorrect format"; } @@ -36,7 +36,7 @@ namespace NKikimr { GroupID, FailRealm, FailDomain, VDisk).data(); } - void TVDiskID::Serialize(IOutputStream &s) const { + void TVDiskID::Serialize(IOutputStream &s) const { s.Write(&GroupID, sizeof(GroupID)); s.Write(&GroupGeneration, sizeof(GroupGeneration)); s.Write(&FailRealm, sizeof(FailRealm)); @@ -44,7 +44,7 @@ namespace NKikimr { s.Write(&VDisk, sizeof(VDisk)); } - bool TVDiskID::Deserialize(IInputStream &s) { + bool TVDiskID::Deserialize(IInputStream &s) { if (s.Load(&GroupID, sizeof(GroupID)) != sizeof(GroupID)) return false; if (s.Load(&GroupGeneration, sizeof(GroupGeneration)) != sizeof(GroupGeneration)) diff --git a/ydb/core/blobstorage/base/blobstorage_vdiskid.h b/ydb/core/blobstorage/base/blobstorage_vdiskid.h index c8d5a818b15..a41ede51ead 100644 --- a/ydb/core/blobstorage/base/blobstorage_vdiskid.h +++ b/ydb/core/blobstorage/base/blobstorage_vdiskid.h @@ -26,7 +26,7 @@ struct TVDiskID { TVDiskID() = default; TVDiskID(ui32 groupId, ui32 groupGen, TVDiskIdShort vdiskIdShort); - TVDiskID(IInputStream &str); + TVDiskID(IInputStream &str); TVDiskID(ui32 groupId, ui32 groupGen, ui8 failRealm, ui8 failDomain, ui8 vdisk) : GroupID(groupId) @@ -64,8 +64,8 @@ struct TVDiskID { TString ToString() const; TString ToStringWOGeneration() const; - void Serialize(IOutputStream &s) const; - bool Deserialize(IInputStream &s); + void Serialize(IOutputStream &s) const; + bool Deserialize(IInputStream &s); ui64 Hash() const { ui32 x = (((ui32(FailRealm) << 8) | ui32(FailDomain)) << 8) | ui32(VDisk); @@ -167,11 +167,11 @@ struct THash<NKikimr::TVDiskIdShort> { }; template<> -inline void Out<NKikimr::TVDiskID>(IOutputStream& os, const NKikimr::TVDiskID& vdiskId) { +inline void Out<NKikimr::TVDiskID>(IOutputStream& os, const NKikimr::TVDiskID& vdiskId) { os << vdiskId.ToString(); } template<> -inline void Out<NKikimr::TVDiskIdShort>(IOutputStream& os, const NKikimr::TVDiskIdShort& vdiskId) { +inline void Out<NKikimr::TVDiskIdShort>(IOutputStream& os, const NKikimr::TVDiskIdShort& vdiskId) { os << vdiskId.ToString(); } diff --git a/ydb/core/blobstorage/base/bufferwithgaps.h b/ydb/core/blobstorage/base/bufferwithgaps.h index 28fc2f78ed9..6fb4b6156eb 100644 --- a/ydb/core/blobstorage/base/bufferwithgaps.h +++ b/ydb/core/blobstorage/base/bufferwithgaps.h @@ -66,19 +66,19 @@ namespace NKikimr { } TString ToString() const { - Y_VERIFY(IsReadable(), "returned data is corrupt (or was never written) and therefore could not be used safely"); + Y_VERIFY(IsReadable(), "returned data is corrupt (or was never written) and therefore could not be used safely"); return Data; } TString Substr(ui32 offset, ui32 len) const { - Y_VERIFY(IsReadable(offset, len), "returned data is corrupt (or was never written) at offset# %" PRIu32 + Y_VERIFY(IsReadable(offset, len), "returned data is corrupt (or was never written) at offset# %" PRIu32 " len# %" PRIu32 " and therefore could not be used safely", offset, len); return Data.substr(offset, len); } template<typename T> const T *DataPtr(ui32 offset, ui32 len = sizeof(T)) const { - Y_VERIFY(IsReadable(offset, len), "returned data is corrupt (or was never written) at offset# %" PRIu32 + Y_VERIFY(IsReadable(offset, len), "returned data is corrupt (or was never written) at offset# %" PRIu32 " len# %" PRIu32 " and therefore could not be used safely", offset, len); return reinterpret_cast<T *>(Data.data() + offset); } diff --git a/ydb/core/blobstorage/base/bufferwithgaps_ut.cpp b/ydb/core/blobstorage/base/bufferwithgaps_ut.cpp index 71e1e1a5eb3..75f0860ec0f 100644 --- a/ydb/core/blobstorage/base/bufferwithgaps_ut.cpp +++ b/ydb/core/blobstorage/base/bufferwithgaps_ut.cpp @@ -3,16 +3,16 @@ using NKikimr::TBufferWithGaps; -Y_UNIT_TEST_SUITE(BufferWithGaps) { +Y_UNIT_TEST_SUITE(BufferWithGaps) { - Y_UNIT_TEST(Basic) { + Y_UNIT_TEST(Basic) { TBufferWithGaps buffer(0); TString data = "Hello!"; buffer.SetData(TString(data)); UNIT_ASSERT_STRINGS_EQUAL(data, buffer.Substr(0, buffer.Size())); } - Y_UNIT_TEST(IsReadable) { + Y_UNIT_TEST(IsReadable) { TBufferWithGaps buffer(0); TString data = "Hello! How are you? I'm fine, and you? Me too, thanks!"; TString gaps = "G GGGG GG GGG G G"; diff --git a/ydb/core/blobstorage/base/html.cpp b/ydb/core/blobstorage/base/html.cpp index 6658530a949..1fad1890205 100644 --- a/ydb/core/blobstorage/base/html.cpp +++ b/ydb/core/blobstorage/base/html.cpp @@ -15,7 +15,7 @@ namespace NKikimr { {"label label-danger", {}}, }; - void THtmlLightSignalRenderer::Output(IOutputStream &str) const { + void THtmlLightSignalRenderer::Output(IOutputStream &str) const { HTML(str) { SPAN_CLASS_STYLE (Lights[Light].first, Lights[Light].second) { str << Value; diff --git a/ydb/core/blobstorage/base/html.h b/ydb/core/blobstorage/base/html.h index c592112f307..16595a67cf2 100644 --- a/ydb/core/blobstorage/base/html.h +++ b/ydb/core/blobstorage/base/html.h @@ -19,7 +19,7 @@ namespace NKikimr { , Value(value) {} - void Output(IOutputStream &str) const; + void Output(IOutputStream &str) const; private: NKikimrWhiteboard::EFlag Light; diff --git a/ydb/core/blobstorage/base/ptr_ut.cpp b/ydb/core/blobstorage/base/ptr_ut.cpp index 5554167ab26..2c681ae0a77 100644 --- a/ydb/core/blobstorage/base/ptr_ut.cpp +++ b/ydb/core/blobstorage/base/ptr_ut.cpp @@ -4,7 +4,7 @@ using namespace NKikimr; -Y_UNIT_TEST_SUITE(PtrTest) { +Y_UNIT_TEST_SUITE(PtrTest) { ////////////////////////////////////////////////////////////////////////////////////////// // Basic test for TAtomicRefCountWithDeleter @@ -40,7 +40,7 @@ Y_UNIT_TEST_SUITE(PtrTest) { using TTest1Ptr = TIntrusivePtr<TTest1>; - Y_UNIT_TEST(Test1) { + Y_UNIT_TEST(Test1) { TSimpleTestDeleter deleter; UNIT_ASSERT_EQUAL(deleter.GetNum(), 0); diff --git a/ydb/core/blobstorage/base/utility.h b/ydb/core/blobstorage/base/utility.h index afb519dcb86..a7275eb4920 100644 --- a/ydb/core/blobstorage/base/utility.h +++ b/ydb/core/blobstorage/base/utility.h @@ -88,7 +88,7 @@ namespace NKikimr { } void DecrementUndertakerCounter(const TActorContext &ctx) { - Y_VERIFY_DEBUG(UndertakerCounter > 0); + Y_VERIFY_DEBUG(UndertakerCounter > 0); --UndertakerCounter; UndertakerCheckToDie(ctx); } diff --git a/ydb/core/blobstorage/base/vdisk_lsn.h b/ydb/core/blobstorage/base/vdisk_lsn.h index 1960ed08ebd..a20fe4efc78 100644 --- a/ydb/core/blobstorage/base/vdisk_lsn.h +++ b/ydb/core/blobstorage/base/vdisk_lsn.h @@ -33,7 +33,7 @@ namespace NKikimr { return str.Str(); } - void Output(IOutputStream &str) const { + void Output(IOutputStream &str) const { str << "[" << First << ", " << Last << "]"; } diff --git a/ydb/core/blobstorage/crypto/chacha.cpp b/ydb/core/blobstorage/crypto/chacha.cpp index 8945982887e..f9275c86d5a 100644 --- a/ydb/core/blobstorage/crypto/chacha.cpp +++ b/ydb/core/blobstorage/crypto/chacha.cpp @@ -41,7 +41,7 @@ constexpr size_t ChaCha::BLOCK_SIZE; void ChaCha::SetKey(const ui8* key, size_t size) { const char *constants; - Y_ASSERT((size == 16 || size == 32) && "key must be 16 or 32 bytes long"); + Y_ASSERT((size == 16 || size == 32) && "key must be 16 or 32 bytes long"); state_[4] = U8TO32_LITTLE(key + 0); state_[5] = U8TO32_LITTLE(key + 4); diff --git a/ydb/core/blobstorage/crypto/chacha_ut.cpp b/ydb/core/blobstorage/crypto/chacha_ut.cpp index 18db0f8df64..29c74c56369 100644 --- a/ydb/core/blobstorage/crypto/chacha_ut.cpp +++ b/ydb/core/blobstorage/crypto/chacha_ut.cpp @@ -4,7 +4,7 @@ #include <ydb/core/blobstorage/crypto/ut/chacha_test_vectors.h> -Y_UNIT_TEST_SUITE(TChaCha) +Y_UNIT_TEST_SUITE(TChaCha) { void RunTest(int rounds, const ui8 key[KEY_SIZE], const ui8 iv[IV_SIZE], const ui8 expected[][DATA_SIZE]) @@ -24,62 +24,62 @@ Y_UNIT_TEST_SUITE(TChaCha) } // TC1: All zero key and IV. - Y_UNIT_TEST(KeystreamTest1) { + Y_UNIT_TEST(KeystreamTest1) { RunTest(8, tc1_key, tc1_iv, tc1_expected_8); RunTest(12, tc1_key, tc1_iv, tc1_expected_12); RunTest(20, tc1_key, tc1_iv, tc1_expected_20); } // TC2: Single bit in key set. All zero IV - Y_UNIT_TEST(KeystreamTest2) { + Y_UNIT_TEST(KeystreamTest2) { RunTest(8, tc2_key, tc2_iv, tc2_expected_8); RunTest(12, tc2_key, tc2_iv, tc2_expected_12); RunTest(20, tc2_key, tc2_iv, tc2_expected_20); } // TC3: Single bit in IV set. All zero key - Y_UNIT_TEST(KeystreamTest3) { + Y_UNIT_TEST(KeystreamTest3) { RunTest(8, tc3_key, tc3_iv, tc3_expected_8); RunTest(12, tc3_key, tc3_iv, tc3_expected_12); RunTest(20, tc3_key, tc3_iv, tc3_expected_20); } // TC4: All bits in key and IV are set - Y_UNIT_TEST(KeystreamTest4) { + Y_UNIT_TEST(KeystreamTest4) { RunTest(8, tc4_key, tc4_iv, tc4_expected_8); RunTest(12, tc4_key, tc4_iv, tc4_expected_12); RunTest(20, tc4_key, tc4_iv, tc4_expected_20); } // TC5: Every even bit set in key and IV - Y_UNIT_TEST(KeystreamTest5) { + Y_UNIT_TEST(KeystreamTest5) { RunTest(8, tc5_key, tc5_iv, tc5_expected_8); RunTest(12, tc5_key, tc5_iv, tc5_expected_12); RunTest(20, tc5_key, tc5_iv, tc5_expected_20); } // TC6: Every odd bit set in key and IV - Y_UNIT_TEST(KeystreamTest6) { + Y_UNIT_TEST(KeystreamTest6) { RunTest(8, tc6_key, tc6_iv, tc6_expected_8); RunTest(12, tc6_key, tc6_iv, tc6_expected_12); RunTest(20, tc6_key, tc6_iv, tc6_expected_20); } // TC7: Sequence patterns in key and IV - Y_UNIT_TEST(KeystreamTest7) { + Y_UNIT_TEST(KeystreamTest7) { RunTest(8, tc7_key, tc7_iv, tc7_expected_8); RunTest(12, tc7_key, tc7_iv, tc7_expected_12); RunTest(20, tc7_key, tc7_iv, tc7_expected_20); } // TC8: key: 'All your base are belong to us!, IV: 'IETF2013' - Y_UNIT_TEST(KeystreamTest8) { + Y_UNIT_TEST(KeystreamTest8) { RunTest(8, tc8_key, tc8_iv, tc8_expected_8); RunTest(12, tc8_key, tc8_iv, tc8_expected_12); RunTest(20, tc8_key, tc8_iv, tc8_expected_20); } - Y_UNIT_TEST(MultiEncipherOneDecipher) { + Y_UNIT_TEST(MultiEncipherOneDecipher) { TStringBuf lorem = "Lorem ipsum dolor sit amet, consectetur adipisicing elit, " "sed do eiusmod tempor incididunt ut labore et dolore magna " diff --git a/ydb/core/blobstorage/crypto/chacha_vec.cpp b/ydb/core/blobstorage/crypto/chacha_vec.cpp index 870c63e2e43..13666e9ebab 100644 --- a/ydb/core/blobstorage/crypto/chacha_vec.cpp +++ b/ydb/core/blobstorage/crypto/chacha_vec.cpp @@ -158,7 +158,7 @@ alignas(16) ui32 chacha_const[] = { void ChaChaVec::SetKey(const ui8* key, size_t size) { - Y_ASSERT((size == KEY_SIZE) && "key must be 32 bytes long"); + Y_ASSERT((size == KEY_SIZE) && "key must be 32 bytes long"); alignas(16) ui8 aligned_key[KEY_SIZE]; memcpy(aligned_key, key, size); diff --git a/ydb/core/blobstorage/crypto/chacha_vec_ut.cpp b/ydb/core/blobstorage/crypto/chacha_vec_ut.cpp index 823348e8321..ae9b393564a 100644 --- a/ydb/core/blobstorage/crypto/chacha_vec_ut.cpp +++ b/ydb/core/blobstorage/crypto/chacha_vec_ut.cpp @@ -6,7 +6,7 @@ #include <ydb/core/blobstorage/crypto/ut/chacha_test_vectors.h> -Y_UNIT_TEST_SUITE(TChaChaVec) +Y_UNIT_TEST_SUITE(TChaChaVec) { void RunTest(int rounds, const ui8 key[KEY_SIZE], const ui8 iv[IV_SIZE], const ui8 expected[][DATA_SIZE]) @@ -26,62 +26,62 @@ Y_UNIT_TEST_SUITE(TChaChaVec) } // TC1: All zero key and IV. - Y_UNIT_TEST(KeystreamTest1) { + Y_UNIT_TEST(KeystreamTest1) { RunTest(8, tc1_key, tc1_iv, tc1_expected_8); RunTest(12, tc1_key, tc1_iv, tc1_expected_12); RunTest(20, tc1_key, tc1_iv, tc1_expected_20); } // TC2: Single bit in key set. All zero IV - Y_UNIT_TEST(KeystreamTest2) { + Y_UNIT_TEST(KeystreamTest2) { RunTest(8, tc2_key, tc2_iv, tc2_expected_8); RunTest(12, tc2_key, tc2_iv, tc2_expected_12); RunTest(20, tc2_key, tc2_iv, tc2_expected_20); } // TC3: Single bit in IV set. All zero key - Y_UNIT_TEST(KeystreamTest3) { + Y_UNIT_TEST(KeystreamTest3) { RunTest(8, tc3_key, tc3_iv, tc3_expected_8); RunTest(12, tc3_key, tc3_iv, tc3_expected_12); RunTest(20, tc3_key, tc3_iv, tc3_expected_20); } // TC4: All bits in key and IV are set - Y_UNIT_TEST(KeystreamTest4) { + Y_UNIT_TEST(KeystreamTest4) { RunTest(8, tc4_key, tc4_iv, tc4_expected_8); RunTest(12, tc4_key, tc4_iv, tc4_expected_12); RunTest(20, tc4_key, tc4_iv, tc4_expected_20); } // TC5: Every even bit set in key and IV - Y_UNIT_TEST(KeystreamTest5) { + Y_UNIT_TEST(KeystreamTest5) { RunTest(8, tc5_key, tc5_iv, tc5_expected_8); RunTest(12, tc5_key, tc5_iv, tc5_expected_12); RunTest(20, tc5_key, tc5_iv, tc5_expected_20); } // TC6: Every odd bit set in key and IV - Y_UNIT_TEST(KeystreamTest6) { + Y_UNIT_TEST(KeystreamTest6) { RunTest(8, tc6_key, tc6_iv, tc6_expected_8); RunTest(12, tc6_key, tc6_iv, tc6_expected_12); RunTest(20, tc6_key, tc6_iv, tc6_expected_20); } // TC7: Sequence patterns in key and IV - Y_UNIT_TEST(KeystreamTest7) { + Y_UNIT_TEST(KeystreamTest7) { RunTest(8, tc7_key, tc7_iv, tc7_expected_8); RunTest(12, tc7_key, tc7_iv, tc7_expected_12); RunTest(20, tc7_key, tc7_iv, tc7_expected_20); } // TC8: key: 'All your base are belong to us!, IV: 'IETF2013' - Y_UNIT_TEST(KeystreamTest8) { + Y_UNIT_TEST(KeystreamTest8) { RunTest(8, tc8_key, tc8_iv, tc8_expected_8); RunTest(12, tc8_key, tc8_iv, tc8_expected_12); RunTest(20, tc8_key, tc8_iv, tc8_expected_20); } - Y_UNIT_TEST(MultiEncipherOneDecipher) { + Y_UNIT_TEST(MultiEncipherOneDecipher) { TStringBuf lorem = "Lorem ipsum dolor sit amet, consectetur adipisicing elit, " "sed do eiusmod tempor incididunt ut labore et dolore magna " diff --git a/ydb/core/blobstorage/crypto/poly1305.cpp b/ydb/core/blobstorage/crypto/poly1305.cpp index 60ed46cb436..04ef702826e 100644 --- a/ydb/core/blobstorage/crypto/poly1305.cpp +++ b/ydb/core/blobstorage/crypto/poly1305.cpp @@ -136,7 +136,7 @@ constexpr size_t Poly1305::MAC_SIZE; void Poly1305::SetKey(const ui8* key, size_t size) { - Y_ASSERT((size == KEY_SIZE) && "key must be 32 bytes long"); + Y_ASSERT((size == KEY_SIZE) && "key must be 32 bytes long"); poly1305_state_st *st = (poly1305_state_st *)&state; ui32 t0, t1, t2, t3; diff --git a/ydb/core/blobstorage/crypto/poly1305_ut.cpp b/ydb/core/blobstorage/crypto/poly1305_ut.cpp index 41632d764b6..1c2e8d2a9fb 100644 --- a/ydb/core/blobstorage/crypto/poly1305_ut.cpp +++ b/ydb/core/blobstorage/crypto/poly1305_ut.cpp @@ -3,7 +3,7 @@ #include <ydb/core/blobstorage/crypto/ut/poly1305_test_vectors.h> -Y_UNIT_TEST_SUITE(TPoly1305) +Y_UNIT_TEST_SUITE(TPoly1305) { inline void RunTest(const ui8* input, size_t input_size, const ui8 key[32], const ui8 expectedMac[16]) @@ -26,19 +26,19 @@ Y_UNIT_TEST_SUITE(TPoly1305) UNIT_ASSERT_ARRAYS_EQUAL(mac, expectedMac, sizeof(mac)); } - Y_UNIT_TEST(TestVector1) { + Y_UNIT_TEST(TestVector1) { RunTest(tc1_data, sizeof(tc1_data), tc1_key, tc1_tag); } - Y_UNIT_TEST(TestVector2) { + Y_UNIT_TEST(TestVector2) { RunTest(tc2_data, sizeof(tc2_data) - 1, tc2_key, tc2_tag); } - Y_UNIT_TEST(TestVector3) { + Y_UNIT_TEST(TestVector3) { RunTest(tc3_data, sizeof(tc3_data) - 1, tc3_key, tc3_tag); } - Y_UNIT_TEST(TestVector4) { + Y_UNIT_TEST(TestVector4) { RunTest(tc4_data, sizeof(tc4_data) - 1, tc4_key, tc4_tag); } } diff --git a/ydb/core/blobstorage/crypto/poly1305_vec.cpp b/ydb/core/blobstorage/crypto/poly1305_vec.cpp index 25f8308f793..7c5afc60deb 100644 --- a/ydb/core/blobstorage/crypto/poly1305_vec.cpp +++ b/ydb/core/blobstorage/crypto/poly1305_vec.cpp @@ -475,7 +475,7 @@ constexpr size_t Poly1305Vec::MAC_SIZE; void Poly1305Vec::SetKey(const ui8* key, size_t size) { - Y_ASSERT((size == KEY_SIZE) && "key must be 32 bytes long"); + Y_ASSERT((size == KEY_SIZE) && "key must be 32 bytes long"); poly1305_state_internal *st = poly1305_aligned_state(&state); poly1305_power *p; diff --git a/ydb/core/blobstorage/crypto/poly1305_vec_ut.cpp b/ydb/core/blobstorage/crypto/poly1305_vec_ut.cpp index 491c49b4c7f..92d26fb2274 100644 --- a/ydb/core/blobstorage/crypto/poly1305_vec_ut.cpp +++ b/ydb/core/blobstorage/crypto/poly1305_vec_ut.cpp @@ -3,7 +3,7 @@ #include <ydb/core/blobstorage/crypto/ut/poly1305_test_vectors.h> -Y_UNIT_TEST_SUITE(TPoly1305Vec) +Y_UNIT_TEST_SUITE(TPoly1305Vec) { inline void RunTest(const ui8* input, size_t input_size, const ui8 key[32], const ui8 expectedMac[16]) @@ -26,19 +26,19 @@ Y_UNIT_TEST_SUITE(TPoly1305Vec) UNIT_ASSERT_ARRAYS_EQUAL(mac, expectedMac, sizeof(mac)); } - Y_UNIT_TEST(TestVector1) { + Y_UNIT_TEST(TestVector1) { RunTest(tc1_data, sizeof(tc1_data), tc1_key, tc1_tag); } - Y_UNIT_TEST(TestVector2) { + Y_UNIT_TEST(TestVector2) { RunTest(tc2_data, sizeof(tc2_data) - 1, tc2_key, tc2_tag); } - Y_UNIT_TEST(TestVector3) { + Y_UNIT_TEST(TestVector3) { RunTest(tc3_data, sizeof(tc3_data) - 1, tc3_key, tc3_tag); } - Y_UNIT_TEST(TestVector4) { + Y_UNIT_TEST(TestVector4) { RunTest(tc4_data, sizeof(tc4_data) - 1, tc4_key, tc4_tag); } } diff --git a/ydb/core/blobstorage/crypto/secured_block.cpp b/ydb/core/blobstorage/crypto/secured_block.cpp index 5c52c4a4296..2c1266a6709 100644 --- a/ydb/core/blobstorage/crypto/secured_block.cpp +++ b/ydb/core/blobstorage/crypto/secured_block.cpp @@ -65,7 +65,7 @@ ui8* AlignedAllocate(size_t size) p[-1] = (ui8)adjustment; #endif - Y_ASSERT(IsAlignedOn(p, 16)); + Y_ASSERT(IsAlignedOn(p, 16)); return p; } diff --git a/ydb/core/blobstorage/crypto/secured_block.h b/ydb/core/blobstorage/crypto/secured_block.h index 9992d70933d..3a7818c94a4 100644 --- a/ydb/core/blobstorage/crypto/secured_block.h +++ b/ydb/core/blobstorage/crypto/secured_block.h @@ -15,7 +15,7 @@ template <class T1, class T2> inline T2 ModPowerOf2(const T1& a, const T2& b) { - Y_ASSERT(IsPowerOf2(b)); + Y_ASSERT(IsPowerOf2(b)); return T2(a) & (b-1); } @@ -94,15 +94,15 @@ class TFixedAllocator { public: ui8* Allocate(size_t n) { - Y_UNUSED(n); + Y_UNUSED(n); // TODO: use static assert - Y_ASSERT(IsAlignedOn(Array_, alignment)); + Y_ASSERT(IsAlignedOn(Array_, alignment)); return GetAlignedArray(); } void Deallocate(ui8* ptr, size_t n) { - Y_UNUSED(n); + Y_UNUSED(n); Y_UNUSED(ptr); ui8 *p = GetAlignedArray(); @@ -110,7 +110,7 @@ public: } ui8* Reallocate(ui8* ptr, size_t oldSize, size_t newSize, bool preserve) { - Y_UNUSED(preserve); + Y_UNUSED(preserve); if (oldSize > newSize) SecureWipeBuffer(ptr + newSize, oldSize - newSize); diff --git a/ydb/core/blobstorage/dsproxy/blobstorage_backoff.cpp b/ydb/core/blobstorage/dsproxy/blobstorage_backoff.cpp index 67165728170..14f1a16b654 100644 --- a/ydb/core/blobstorage/dsproxy/blobstorage_backoff.cpp +++ b/ydb/core/blobstorage/dsproxy/blobstorage_backoff.cpp @@ -12,7 +12,7 @@ TBackoffTimer::TBackoffTimer(ui64 initialMs, ui64 maxMs) , CurrentBackoffMs(0ull) , PreviousBackoffMs(0ull) { - Y_VERIFY(initialMs <= maxMs); + Y_VERIFY(initialMs <= maxMs); } ui64 TBackoffTimer::NextBackoffMs() { diff --git a/ydb/core/blobstorage/dsproxy/dsproxy_blob_tracker.h b/ydb/core/blobstorage/dsproxy/dsproxy_blob_tracker.h index 147083490be..c61afc9916a 100644 --- a/ydb/core/blobstorage/dsproxy/dsproxy_blob_tracker.h +++ b/ydb/core/blobstorage/dsproxy/dsproxy_blob_tracker.h @@ -23,7 +23,7 @@ namespace NKikimr { , FaultyDisks(&info->GetTopology()) {} - void Output(IOutputStream& str, const TBlobStorageGroupInfo *info) const { + void Output(IOutputStream& str, const TBlobStorageGroupInfo *info) const { str << "{FullId# " << FullId.ToString() << " PresentParts# "; PresentParts.Output(str, info->Type); str << " FaultyDisks# "; diff --git a/ydb/core/blobstorage/dsproxy/dsproxy_block.cpp b/ydb/core/blobstorage/dsproxy/dsproxy_block.cpp index dba0a2fd434..8b6f3b34fce 100644 --- a/ydb/core/blobstorage/dsproxy/dsproxy_block.cpp +++ b/ydb/core/blobstorage/dsproxy/dsproxy_block.cpp @@ -24,9 +24,9 @@ class TBlobStorageGroupBlockRequest : public TBlobStorageGroupRequestActor<TBlob void Handle(TEvBlobStorage::TEvVBlockResult::TPtr &ev) { ProcessReplyFromQueue(ev); const NKikimrBlobStorage::TEvVBlockResult &record = ev->Get()->Record; - Y_VERIFY(record.HasStatus()); + Y_VERIFY(record.HasStatus()); const NKikimrProto::EReplyStatus status = record.GetStatus(); - Y_VERIFY(record.HasVDiskID()); + Y_VERIFY(record.HasVDiskID()); const TVDiskID vdisk = VDiskIDFromVDiskID(record.GetVDiskID()); const TVDiskIdShort shortId(ev->Cookie); diff --git a/ydb/core/blobstorage/dsproxy/dsproxy_collect.cpp b/ydb/core/blobstorage/dsproxy/dsproxy_collect.cpp index d12c819a745..0d1628b5a1d 100644 --- a/ydb/core/blobstorage/dsproxy/dsproxy_collect.cpp +++ b/ydb/core/blobstorage/dsproxy/dsproxy_collect.cpp @@ -35,9 +35,9 @@ class TBlobStorageGroupCollectGarbageRequest : public TBlobStorageGroupRequestAc ProcessReplyFromQueue(ev); ResponsesReceived++; const NKikimrBlobStorage::TEvVCollectGarbageResult &record = ev->Get()->Record; - Y_VERIFY(record.HasStatus()); + Y_VERIFY(record.HasStatus()); const NKikimrProto::EReplyStatus status = record.GetStatus(); - Y_VERIFY(record.HasVDiskID()); + Y_VERIFY(record.HasVDiskID()); const TVDiskID vdisk = VDiskIDFromVDiskID(record.GetVDiskID()); A_LOG_LOG_S(false, PriorityForStatusInbound(status), "DSPC01", "received" diff --git a/ydb/core/blobstorage/dsproxy/dsproxy_discover.cpp b/ydb/core/blobstorage/dsproxy/dsproxy_discover.cpp index 2605a19a2e9..987bba1eecd 100644 --- a/ydb/core/blobstorage/dsproxy/dsproxy_discover.cpp +++ b/ydb/core/blobstorage/dsproxy/dsproxy_discover.cpp @@ -320,13 +320,13 @@ class TBlobStorageGroupDiscoverRequest : public TBlobStorageGroupRequestActor<TB TotalRecieved++; NKikimrBlobStorage::TEvVGetBlockResult &record = ev->Get()->Record; - Y_VERIFY(record.HasStatus()); + Y_VERIFY(record.HasStatus()); const NKikimrProto::EReplyStatus status = record.GetStatus(); - Y_VERIFY(record.HasVDiskID()); + Y_VERIFY(record.HasVDiskID()); const TVDiskID vdisk = VDiskIDFromVDiskID(record.GetVDiskID()); - Y_VERIFY(status == NKikimrProto::OK || status == NKikimrProto::NODATA || status == NKikimrProto::ERROR + Y_VERIFY(status == NKikimrProto::OK || status == NKikimrProto::NODATA || status == NKikimrProto::ERROR || status == NKikimrProto::VDISK_ERROR_STATE, "status# %" PRIu32, ui32(status)); A_LOG_LOG_S(false, PriorityForStatusInbound(status), "BSD03", @@ -338,7 +338,7 @@ class TBlobStorageGroupDiscoverRequest : public TBlobStorageGroupRequestActor<TB if (status == NKikimrProto::NODATA) { // nothing } else if (status == NKikimrProto::OK) { - Y_VERIFY(record.HasGeneration()); + Y_VERIFY(record.HasGeneration()); BlockedGen = Max(BlockedGen, record.GetGeneration()); } else if (status == NKikimrProto::ERROR || status == NKikimrProto::VDISK_ERROR_STATE) { ++GetBlockErrors; @@ -384,10 +384,10 @@ class TBlobStorageGroupDiscoverRequest : public TBlobStorageGroupRequestActor<TB TotalRecieved++; NKikimrBlobStorage::TEvVGetResult &record = ev->Get()->Record; - Y_VERIFY(record.HasStatus()); + Y_VERIFY(record.HasStatus()); const NKikimrProto::EReplyStatus status = record.GetStatus(); - Y_VERIFY(record.HasVDiskID()); + Y_VERIFY(record.HasVDiskID()); const TVDiskID vdisk = VDiskIDFromVDiskID(record.GetVDiskID()); Y_VERIFY(status == NKikimrProto::OK || status == NKikimrProto::ERROR || status == NKikimrProto::VDISK_ERROR_STATE); @@ -751,7 +751,7 @@ class TBlobStorageGroupDiscoverRequest : public TBlobStorageGroupRequestActor<TB switch (status) { case NKikimrProto::OK: { - Y_VERIFY(msg->ResponseSz == 1); + Y_VERIFY(msg->ResponseSz == 1); TEvBlobStorage::TEvGetResult::TResponse &response = msg->Responses[0]; switch (response.Status) { case NKikimrProto::OK: diff --git a/ydb/core/blobstorage/dsproxy/dsproxy_get.cpp b/ydb/core/blobstorage/dsproxy/dsproxy_get.cpp index 9b08b418619..bd43126213a 100644 --- a/ydb/core/blobstorage/dsproxy/dsproxy_get.cpp +++ b/ydb/core/blobstorage/dsproxy/dsproxy_get.cpp @@ -188,7 +188,7 @@ class TBlobStorageGroupGetRequest : public TBlobStorageGroupRequestActor<TBlobSt const ui64 cyclesPerUs = NHPTimer::GetCyclesPerSecond() / 1000000; ev->Get()->Record.MutableTimestamps()->SetReceivedByDSProxyUs(GetCycleCountFast() / cyclesPerUs); const NKikimrBlobStorage::TEvVGetResult &record = ev->Get()->Record; - Y_VERIFY(record.HasStatus()); + Y_VERIFY(record.HasStatus()); ui64 totalSize = 0; ui64 tabletId = 0; @@ -349,7 +349,7 @@ class TBlobStorageGroupGetRequest : public TBlobStorageGroupRequestActor<TBlobSt template <typename TPutEvent, typename TPutEventResult> void HandleVPutResult(typename TPutEventResult::TPtr &ev) { - Y_VERIFY(ev->Get()->Record.HasStatus()); + Y_VERIFY(ev->Get()->Record.HasStatus()); WILSON_TRACE_FROM_ACTOR(*TlsActivationContext, *this, &TraceId, EvVPutResultReceived, MergedNode = std::move(ev->TraceId)); diff --git a/ydb/core/blobstorage/dsproxy/dsproxy_mon.h b/ydb/core/blobstorage/dsproxy/dsproxy_mon.h index 941bea6664a..00f723c4183 100644 --- a/ydb/core/blobstorage/dsproxy/dsproxy_mon.h +++ b/ydb/core/blobstorage/dsproxy/dsproxy_mon.h @@ -280,7 +280,7 @@ public: ++*EventPut; *EventPutBytes += size; auto bucketIt = EventPutBytesBuckets.upper_bound(size); - Y_VERIFY(bucketIt != EventPutBytesBuckets.begin()); + Y_VERIFY(bucketIt != EventPutBytesBuckets.begin()); ++*std::prev(bucketIt)->second; } diff --git a/ydb/core/blobstorage/dsproxy/dsproxy_multiget.cpp b/ydb/core/blobstorage/dsproxy/dsproxy_multiget.cpp index 02d7849855c..4337aa72cc1 100644 --- a/ydb/core/blobstorage/dsproxy/dsproxy_multiget.cpp +++ b/ydb/core/blobstorage/dsproxy/dsproxy_multiget.cpp @@ -48,11 +48,11 @@ class TBlobStorageGroupMultiGetRequest : public TBlobStorageGroupRequestActor<TB return; } - Y_VERIFY(ev->Cookie < RequestInfos.size()); + Y_VERIFY(ev->Cookie < RequestInfos.size()); TRequestInfo &info = RequestInfos[ev->Cookie]; - Y_VERIFY(!info.IsReplied); + Y_VERIFY(!info.IsReplied); info.IsReplied = true; - Y_VERIFY(res.ResponseSz == info.EndIdx - info.BeginIdx); + Y_VERIFY(res.ResponseSz == info.EndIdx - info.BeginIdx); for (ui64 offset = 0; offset < res.ResponseSz; ++offset) { Responses[info.BeginIdx + offset] = res.Responses[offset]; @@ -159,7 +159,7 @@ public: << " Query# " << dumpQuery() << " Deadline# " << Deadline); - Y_VERIFY(QuerySize != 0); // reply with error? + Y_VERIFY(QuerySize != 0); // reply with error? ui32 beginIdx = 0; TLogoBlobID lastBlobId; TQueryResultSizeTracker resultSize; diff --git a/ydb/core/blobstorage/dsproxy/dsproxy_range.cpp b/ydb/core/blobstorage/dsproxy/dsproxy_range.cpp index e234f8c18e1..4b139249fac 100644 --- a/ydb/core/blobstorage/dsproxy/dsproxy_range.cpp +++ b/ydb/core/blobstorage/dsproxy/dsproxy_range.cpp @@ -78,7 +78,7 @@ class TBlobStorageGroupRangeRequest : public TBlobStorageGroupRequestActor<TBlob CountEvent(*ev->Get()); const auto& record = ev->Get()->Record; - Y_VERIFY(record.HasStatus()); + Y_VERIFY(record.HasStatus()); NKikimrProto::EReplyStatus status = record.GetStatus(); Y_VERIFY(record.HasVDiskID()); diff --git a/ydb/core/blobstorage/dsproxy/dsproxy_timestats.h b/ydb/core/blobstorage/dsproxy/dsproxy_timestats.h index 943b93858df..1c765f93403 100644 --- a/ydb/core/blobstorage/dsproxy/dsproxy_timestats.h +++ b/ydb/core/blobstorage/dsproxy/dsproxy_timestats.h @@ -133,7 +133,7 @@ public: } } - void Render(IOutputStream& str) { + void Render(IOutputStream& str) { const TInstant now = TAppData::TimeProvider->Now(); #define PARAM(NAME, V) \ diff --git a/ydb/core/blobstorage/dsproxy/ut/dsproxy_fault_tolerance_ut.cpp b/ydb/core/blobstorage/dsproxy/ut/dsproxy_fault_tolerance_ut.cpp index 6a8fbff0e28..3d765a486cf 100644 --- a/ydb/core/blobstorage/dsproxy/ut/dsproxy_fault_tolerance_ut.cpp +++ b/ydb/core/blobstorage/dsproxy/ut/dsproxy_fault_tolerance_ut.cpp @@ -43,10 +43,10 @@ void RunTest(TBlobStorageGroupType groupType, bool minimum = false, ui32 testPar } } -Y_UNIT_TEST_SUITE(TBsProxyFaultToleranceTest) { +Y_UNIT_TEST_SUITE(TBsProxyFaultToleranceTest) { #define FAULT_TOLERANCE_TEST(ERASURE, T) \ - Y_UNIT_TEST(Check##T##ERASURE) { \ + Y_UNIT_TEST(Check##T##ERASURE) { \ RunTest<T>(TBlobStorageGroupType::ERASURE); \ } diff --git a/ydb/core/blobstorage/dsproxy/ut/dsproxy_get_ut.cpp b/ydb/core/blobstorage/dsproxy/ut/dsproxy_get_ut.cpp index 85e16c2aef3..ec628e59230 100644 --- a/ydb/core/blobstorage/dsproxy/ut/dsproxy_get_ut.cpp +++ b/ydb/core/blobstorage/dsproxy/ut/dsproxy_get_ut.cpp @@ -26,7 +26,7 @@ do { \ } while (false) \ -Y_UNIT_TEST_SUITE(TDSProxyGetTest) { +Y_UNIT_TEST_SUITE(TDSProxyGetTest) { void TestIntervalsAndCrcAllOk(TErasureType::EErasureSpecies erasureSpecies, bool isVerboseNoDataEnabled, bool checkCrc) { TActorSystemStub actorSystemStub; @@ -128,15 +128,15 @@ void TestIntervalsAndCrcAllOk(TErasureType::EErasureSpecies erasureSpecies, bool } // Without CRC -Y_UNIT_TEST(TestBlock42GetIntervalsAllOk) { +Y_UNIT_TEST(TestBlock42GetIntervalsAllOk) { TestIntervalsAndCrcAllOk(TErasureType::Erasure4Plus2Block, false, false); } -Y_UNIT_TEST(TestBlock42GetIntervalsAllOkVerbose) { +Y_UNIT_TEST(TestBlock42GetIntervalsAllOkVerbose) { TestIntervalsAndCrcAllOk(TErasureType::Erasure4Plus2Block, true, false); } -Y_UNIT_TEST(TestMirror32GetIntervalsAllOk) { +Y_UNIT_TEST(TestMirror32GetIntervalsAllOk) { TestIntervalsAndCrcAllOk(TErasureType::ErasureMirror3Plus2, false, false); } @@ -1232,11 +1232,11 @@ void TestWipedErrorWithTwoBlobs(TErasureType::EErasureSpecies erasureSpecies, bo return; } -Y_UNIT_TEST(TestBlock42GetIntervalsWipedAllOk) { +Y_UNIT_TEST(TestBlock42GetIntervalsWipedAllOk) { TestIntervalsWipedAllOk(TErasureType::Erasure4Plus2Block); } -Y_UNIT_TEST(TestBlock42GetIntervalsWipedAllOkVerbose) { +Y_UNIT_TEST(TestBlock42GetIntervalsWipedAllOkVerbose) { TestIntervalsWipedAllOk(TErasureType::Erasure4Plus2Block, true); } @@ -1264,7 +1264,7 @@ Y_UNIT_TEST(TestBlock42WipedErrorWithTwoBlobs) { TestWipedErrorWithTwoBlobs(TErasureType::Erasure4Plus2Block); } -Y_UNIT_TEST(TestMirror32GetIntervalsWipedAllOk) { +Y_UNIT_TEST(TestMirror32GetIntervalsWipedAllOk) { TestIntervalsWipedAllOk(TErasureType::ErasureMirror3Plus2); } @@ -1356,7 +1356,7 @@ Y_UNIT_TEST(TestBlock42GetSpecific3) { } -Y_UNIT_TEST_SUITE(TDSProxyLooksLikeLostTheBlob) { +Y_UNIT_TEST_SUITE(TDSProxyLooksLikeLostTheBlob) { class TTestPossibleBlobLost { TErasureType::EErasureSpecies ErasureSpecies; @@ -1560,7 +1560,7 @@ public: } }; -Y_UNIT_TEST(TDSProxyLooksLikeLostTheBlobBlock42) { +Y_UNIT_TEST(TDSProxyLooksLikeLostTheBlobBlock42) { const ui64 blobSize = 128; for (ui32 i = 1; i < 3; ++i) { TTestPossibleBlobLost test(TErasureType::Erasure4Plus2Block, blobSize, i, {NKikimrProto::ERROR, NKikimrProto::ERROR}); @@ -1770,6 +1770,6 @@ Y_UNIT_TEST(TDSProxyErrorRegressionBlock42) { test.Run(); } -} // Y_UNIT_TEST_SUITE TDSProxyLooksLikeLostTheBlob +} // Y_UNIT_TEST_SUITE TDSProxyLooksLikeLostTheBlob } // namespace NDSProxyGetTest } // namespace NKikimr diff --git a/ydb/core/blobstorage/dsproxy/ut/dsproxy_quorum_tracker_ut.cpp b/ydb/core/blobstorage/dsproxy/ut/dsproxy_quorum_tracker_ut.cpp index dcdd375c18c..ba13e84b4f2 100644 --- a/ydb/core/blobstorage/dsproxy/ut/dsproxy_quorum_tracker_ut.cpp +++ b/ydb/core/blobstorage/dsproxy/ut/dsproxy_quorum_tracker_ut.cpp @@ -32,10 +32,10 @@ void RunCheckFailModel(TBlobStorageGroupType::EErasureSpecies erasure) { } } -Y_UNIT_TEST_SUITE(TDsProxyQuorumTracker) { +Y_UNIT_TEST_SUITE(TDsProxyQuorumTracker) { #define UNIT_TEST_FOR_ERASURE(ERASURE) \ - Y_UNIT_TEST(CheckFailModel##ERASURE) { \ + Y_UNIT_TEST(CheckFailModel##ERASURE) { \ RunCheckFailModel(TBlobStorageGroupType::ERASURE); \ } diff --git a/ydb/core/blobstorage/dsproxy/ut/dsproxy_sequence_ut.cpp b/ydb/core/blobstorage/dsproxy/ut/dsproxy_sequence_ut.cpp index fdd7a92ea30..c0e13c0d3a3 100644 --- a/ydb/core/blobstorage/dsproxy/ut/dsproxy_sequence_ut.cpp +++ b/ydb/core/blobstorage/dsproxy/ut/dsproxy_sequence_ut.cpp @@ -343,7 +343,7 @@ void SendVGetResult(ui32 blobIdx, ui32 vDiskIdx, NKikimrProto::EReplyStatus stat runtime.Send(new IEventHandle(request.Sender, request.ActorId, result.release(), 0, request.Cookie)); return; } else { - Y_FAIL(); + Y_FAIL(); } } @@ -406,7 +406,7 @@ void PrepareBlobSubgroup(TLogoBlobID logoblobid, TString data, TVector<TVDiskSta -Y_UNIT_TEST_SUITE(TBlobStorageProxySequenceTest) { +Y_UNIT_TEST_SUITE(TBlobStorageProxySequenceTest) { struct TGeneralDecorator : public TDecorator { @@ -746,7 +746,7 @@ Y_UNIT_TEST(TestGivenMirror3DCGetWithFirstSlowDisk) { TEvBlobStorage::TEvVGet::TPtr vget = testState.GrabEventPtr<TEvBlobStorage::TEvVGet>(); } -Y_UNIT_TEST(TestGivenBlock42GetThenVGetResponseParts2523Nodata4ThenGetOk) { +Y_UNIT_TEST(TestGivenBlock42GetThenVGetResponseParts2523Nodata4ThenGetOk) { TTestBasicRuntime runtime(1, false); TBlobStorageGroupType type = {TErasureType::Erasure4Plus2Block}; Setup(runtime, type); @@ -974,7 +974,7 @@ Y_UNIT_TEST(TestProtobufSizeWithMultiGet) { MakeTestProtobufSizeWithMultiGet(blobPacks, {224, 223, 1}); } -Y_UNIT_TEST(TestGivenStripe42GetThenVGetResponsePartsNodata263451ThenGetOk) { +Y_UNIT_TEST(TestGivenStripe42GetThenVGetResponsePartsNodata263451ThenGetOk) { TTestBasicRuntime runtime(1, false); TBlobStorageGroupType type = {TErasureType::Erasure4Plus2Stripe}; Setup(runtime, type); @@ -1085,7 +1085,7 @@ Y_UNIT_TEST(TestGivenStripe42WhenGet2PartsOfBlobThenGetOk) { } } -Y_UNIT_TEST(TestGivenBlock42IntersectingPutWhenNodataOkThenOk) { +Y_UNIT_TEST(TestGivenBlock42IntersectingPutWhenNodataOkThenOk) { TTestBasicRuntime runtime(1, false); TBlobStorageGroupType type = {TErasureType::Erasure4Plus2Block}; Setup(runtime, type); @@ -1145,7 +1145,7 @@ Y_UNIT_TEST(TestGivenBlock42IntersectingPutWhenNodataOkThenOk) { } } -Y_UNIT_TEST(TestGivenBlock42PutWhenPartialGetThenSingleDiskRequestOk) { +Y_UNIT_TEST(TestGivenBlock42PutWhenPartialGetThenSingleDiskRequestOk) { TTestBasicRuntime runtime(1, false); TBlobStorageGroupType type = {TErasureType::Erasure4Plus2Block}; Setup(runtime, type); @@ -1254,7 +1254,7 @@ Y_UNIT_TEST(TestGivenBlock42PutWhenPartialGetThenSingleDiskRequestOk) { } } -Y_UNIT_TEST(TestGivenBlock42Put6PartsOnOneVDiskWhenDiscoverThenRecoverFirst) { +Y_UNIT_TEST(TestGivenBlock42Put6PartsOnOneVDiskWhenDiscoverThenRecoverFirst) { TTestBasicRuntime runtime(1, false); TBlobStorageGroupType type = {TErasureType::Erasure4Plus2Block}; Setup(runtime, type); @@ -1374,6 +1374,6 @@ Y_UNIT_TEST(TestGivenBlock42Put6PartsOnOneVDiskWhenDiscoverThenRecoverFirst) { } -} // Y_UNIT_TEST_SUITE TBlobStorageProxySequenceTest +} // Y_UNIT_TEST_SUITE TBlobStorageProxySequenceTest } // namespace NBlobStorageProxySequenceTest } // namespace NKikimr diff --git a/ydb/core/blobstorage/groupinfo/blobstorage_groupinfo.cpp b/ydb/core/blobstorage/groupinfo/blobstorage_groupinfo.cpp index 054d5be6653..37a5d061fb1 100644 --- a/ydb/core/blobstorage/groupinfo/blobstorage_groupinfo.cpp +++ b/ydb/core/blobstorage/groupinfo/blobstorage_groupinfo.cpp @@ -1066,7 +1066,7 @@ bool TFailDomain::IsDifferentAt(const TLevelIds &id, const TFailDomain &other) c while (key != id.Ids.end()) { while (true) { if (a == Levels.end()) { - Y_FAIL("Not enough a levels for FailDomain comparison"); + Y_FAIL("Not enough a levels for FailDomain comparison"); } if (a->first < *key) { ++a; @@ -1074,7 +1074,7 @@ bool TFailDomain::IsDifferentAt(const TLevelIds &id, const TFailDomain &other) c while (true) { if (b == other.Levels.end()) { - Y_FAIL("Not enough b levels for FailDomain comparison"); + Y_FAIL("Not enough b levels for FailDomain comparison"); } if (b->first < *key) { ++b; @@ -1087,12 +1087,12 @@ bool TFailDomain::IsDifferentAt(const TLevelIds &id, const TFailDomain &other) c ++b; break; } else { - Y_FAIL("Missing b level for FailDomain comparison"); + Y_FAIL("Missing b level for FailDomain comparison"); } } break; } else { - Y_FAIL("Missing a level for FailDomain comparison"); + Y_FAIL("Missing a level for FailDomain comparison"); } } } diff --git a/ydb/core/blobstorage/groupinfo/blobstorage_groupinfo_blobmap_ut.cpp b/ydb/core/blobstorage/groupinfo/blobstorage_groupinfo_blobmap_ut.cpp index 9147c6a8715..6ce8a451213 100644 --- a/ydb/core/blobstorage/groupinfo/blobstorage_groupinfo_blobmap_ut.cpp +++ b/ydb/core/blobstorage/groupinfo/blobstorage_groupinfo_blobmap_ut.cpp @@ -95,7 +95,7 @@ namespace { } // anon -Y_UNIT_TEST_SUITE(TBlobStorageGroupInfoBlobMapTest) { +Y_UNIT_TEST_SUITE(TBlobStorageGroupInfoBlobMapTest) { void MakeBelongsToSubgroupBenchmark(TBlobStorageGroupType::EErasureSpecies erasure, ui32 numFailDomains, NUnitTest::TTestContext& ut_context) { @@ -206,7 +206,7 @@ Y_UNIT_TEST_SUITE(TBlobStorageGroupInfoBlobMapTest) { } } - Y_UNIT_TEST(BasicChecks) { + Y_UNIT_TEST(BasicChecks) { for (auto erasure : {TBlobStorageGroupType::ErasureNone, TBlobStorageGroupType::ErasureMirror3, TBlobStorageGroupType::Erasure3Plus1Block, TBlobStorageGroupType::Erasure3Plus1Stripe, TBlobStorageGroupType::Erasure4Plus2Block, TBlobStorageGroupType::Erasure3Plus2Block, @@ -233,7 +233,7 @@ Y_UNIT_TEST_SUITE(TBlobStorageGroupInfoBlobMapTest) { BasicCheck(groupInfo, orig, id, blobSubgroupSize); } - Y_UNIT_TEST(Mirror3dcMapper) { + Y_UNIT_TEST(Mirror3dcMapper) { auto groupInfo = std::make_unique<TBlobStorageGroupInfo>(TBlobStorageGroupType::ErasureMirror3, 3U, 5U, 4U); std::unique_ptr<IBlobToDiskMapper> mapper{IBlobToDiskMapper::CreateMirror3dcMapper(&groupInfo->GetTopology())}; diff --git a/ydb/core/blobstorage/groupinfo/blobstorage_groupinfo_iter_ut.cpp b/ydb/core/blobstorage/groupinfo/blobstorage_groupinfo_iter_ut.cpp index 3810d6ef988..13248f69e2d 100644 --- a/ydb/core/blobstorage/groupinfo/blobstorage_groupinfo_iter_ut.cpp +++ b/ydb/core/blobstorage/groupinfo/blobstorage_groupinfo_iter_ut.cpp @@ -11,8 +11,8 @@ TIntrusivePtr<TBlobStorageGroupInfo> CreateTestGroupInfo(TVector<TVDiskID>& vdis return info; } -Y_UNIT_TEST_SUITE(TBlobStorageGroupInfoIterTest) { - Y_UNIT_TEST(IteratorForward) { +Y_UNIT_TEST_SUITE(TBlobStorageGroupInfoIterTest) { + Y_UNIT_TEST(IteratorForward) { TVector<TVDiskID> vdisks; TIntrusivePtr<TBlobStorageGroupInfo> info = CreateTestGroupInfo(vdisks); ui32 pos = 0; @@ -22,7 +22,7 @@ Y_UNIT_TEST_SUITE(TBlobStorageGroupInfoIterTest) { } } - Y_UNIT_TEST(IteratorBackward) { + Y_UNIT_TEST(IteratorBackward) { TVector<TVDiskID> vdisks; TIntrusivePtr<TBlobStorageGroupInfo> info = CreateTestGroupInfo(vdisks); auto end = info->VDisksEnd(); @@ -34,7 +34,7 @@ Y_UNIT_TEST_SUITE(TBlobStorageGroupInfoIterTest) { } } - Y_UNIT_TEST(IteratorForwardAndBackward) { + Y_UNIT_TEST(IteratorForwardAndBackward) { TVector<TVDiskID> vdisks; TIntrusivePtr<TBlobStorageGroupInfo> info = CreateTestGroupInfo(vdisks); ui32 pos = 0; @@ -52,7 +52,7 @@ Y_UNIT_TEST_SUITE(TBlobStorageGroupInfoIterTest) { UNIT_ASSERT_EQUAL(pos, vdisks.size()); } - Y_UNIT_TEST(PerRealmIterator) { + Y_UNIT_TEST(PerRealmIterator) { TVector<TVDiskID> vdisks; TIntrusivePtr<TBlobStorageGroupInfo> info = CreateTestGroupInfo(vdisks); for (auto realmIt = info->FailRealmsBegin(); realmIt != info->FailRealmsEnd(); ++realmIt) { @@ -79,7 +79,7 @@ Y_UNIT_TEST_SUITE(TBlobStorageGroupInfoIterTest) { } } - Y_UNIT_TEST(PerFailDomainRange) { + Y_UNIT_TEST(PerFailDomainRange) { TVector<TVDiskID> vdisks; TIntrusivePtr<TBlobStorageGroupInfo> info = CreateTestGroupInfo(vdisks); for (auto it = info->FailRealmsBegin(); it != info->FailRealmsEnd(); ++it) { @@ -102,7 +102,7 @@ Y_UNIT_TEST_SUITE(TBlobStorageGroupInfoIterTest) { } } - Y_UNIT_TEST(Domains) { + Y_UNIT_TEST(Domains) { TVector<TVDiskID> vdisks; TIntrusivePtr<TBlobStorageGroupInfo> info = CreateTestGroupInfo(vdisks); TVector<std::pair<ui32, ui32>> x1, x2; @@ -117,7 +117,7 @@ Y_UNIT_TEST_SUITE(TBlobStorageGroupInfoIterTest) { UNIT_ASSERT_VALUES_EQUAL(x1, x2); } - Y_UNIT_TEST(Indexes) { + Y_UNIT_TEST(Indexes) { TVector<TVDiskID> vdisks; TIntrusivePtr<TBlobStorageGroupInfo> info = CreateTestGroupInfo(vdisks); for (auto it = info->VDisksBegin(); it != info->VDisksEnd(); ++it) { @@ -127,7 +127,7 @@ Y_UNIT_TEST_SUITE(TBlobStorageGroupInfoIterTest) { } } - Y_UNIT_TEST(WalkFailRealms) { + Y_UNIT_TEST(WalkFailRealms) { TVector<TVDiskID> vdisks; TIntrusivePtr<TBlobStorageGroupInfo> info = CreateTestGroupInfo(vdisks); ui32 num = 0; diff --git a/ydb/core/blobstorage/groupinfo/blobstorage_groupinfo_partlayout.h b/ydb/core/blobstorage/groupinfo/blobstorage_groupinfo_partlayout.h index 77a6aa30e24..04b8caaff53 100644 --- a/ydb/core/blobstorage/groupinfo/blobstorage_groupinfo_partlayout.h +++ b/ydb/core/blobstorage/groupinfo/blobstorage_groupinfo_partlayout.h @@ -53,7 +53,7 @@ namespace NKikimr { // Return a set of subgroup's disk contaning any replicas TBlobStorageGroupInfo::TSubgroupVDisks GetInvolvedDisks(const TBlobStorageGroupInfo::TTopology *top) const; - void Output(IOutputStream& str, const TBlobStorageGroupType >ype) const { + void Output(IOutputStream& str, const TBlobStorageGroupType >ype) const { const ui32 totalPartCount = gtype.TotalPartCount(); str << "{"; for (ui32 i = 0; i < totalPartCount; ++i) { diff --git a/ydb/core/blobstorage/groupinfo/blobstorage_groupinfo_sets.h b/ydb/core/blobstorage/groupinfo/blobstorage_groupinfo_sets.h index 132e0cce852..cc5fd35e72e 100644 --- a/ydb/core/blobstorage/groupinfo/blobstorage_groupinfo_sets.h +++ b/ydb/core/blobstorage/groupinfo/blobstorage_groupinfo_sets.h @@ -226,7 +226,7 @@ namespace NKikimr { return Top; } - void Output(IOutputStream& str) const { + void Output(IOutputStream& str) const { const ui32 numBits = static_cast<const TDerived&>(*this).GetNumBits(); for (ui32 i = 0; i < numBits; ++i) { str << ((Mask >> (numBits - i - 1)) & 1); diff --git a/ydb/core/blobstorage/groupinfo/blobstorage_groupinfo_ut.cpp b/ydb/core/blobstorage/groupinfo/blobstorage_groupinfo_ut.cpp index e93d36aaa2c..e72548b081c 100644 --- a/ydb/core/blobstorage/groupinfo/blobstorage_groupinfo_ut.cpp +++ b/ydb/core/blobstorage/groupinfo/blobstorage_groupinfo_ut.cpp @@ -7,9 +7,9 @@ namespace NKikimr { -Y_UNIT_TEST_SUITE(TBlobStorageGroupInfoTest) { +Y_UNIT_TEST_SUITE(TBlobStorageGroupInfoTest) { - Y_UNIT_TEST(TestBelongsToSubgroup) { + Y_UNIT_TEST(TestBelongsToSubgroup) { for (ui32 disks = 1; disks < 4; ++disks) { for (ui32 species = 0; species < TBlobStorageGroupType::ErasureSpeciesCount; ++species) { if (species == TBlobStorageGroupType::ErasureMirror3dc) { @@ -62,7 +62,7 @@ Y_UNIT_TEST_SUITE(TBlobStorageGroupInfoTest) { } } - Y_UNIT_TEST(SubgroupPartLayout) { + Y_UNIT_TEST(SubgroupPartLayout) { TLogoBlobID id(1, 1, 1, 0, 100, 0); for (ui32 species = 0; species < TBlobStorageGroupType::ErasureSpeciesCount; ++species) { @@ -128,7 +128,7 @@ Y_UNIT_TEST_SUITE(TBlobStorageGroupInfoTest) { } } - Y_UNIT_TEST(GroupQuorumCheckerOrdinary) { + Y_UNIT_TEST(GroupQuorumCheckerOrdinary) { for (ui32 i = 0; i < TBlobStorageGroupType::ErasureSpeciesCount; ++i) { auto erasure = static_cast<TBlobStorageGroupType::EErasureSpecies>(i); if (erasure == TBlobStorageGroupType::ErasureMirror3dc || erasure == TBlobStorageGroupType::ErasureMirror3of4) { @@ -173,7 +173,7 @@ Y_UNIT_TEST_SUITE(TBlobStorageGroupInfoTest) { } } - Y_UNIT_TEST(GroupQuorumCheckerMirror3dc) { + Y_UNIT_TEST(GroupQuorumCheckerMirror3dc) { const ui32 numFailRealms = 3; const ui32 numFailDomains = 4; TBlobStorageGroupInfo info(TBlobStorageGroupType::ErasureMirror3dc, 1, numFailDomains, numFailRealms); diff --git a/ydb/core/blobstorage/incrhuge/ut/incrhuge_basic_ut.cpp b/ydb/core/blobstorage/incrhuge/ut/incrhuge_basic_ut.cpp index 59d3cb999cf..f87327044b2 100644 --- a/ydb/core/blobstorage/incrhuge/ut/incrhuge_basic_ut.cpp +++ b/ydb/core/blobstorage/incrhuge/ut/incrhuge_basic_ut.cpp @@ -131,8 +131,8 @@ public: } }; -Y_UNIT_TEST_SUITE(TIncrHugeBasicTest) { - Y_UNIT_TEST(WriteReadDeleteEnum) { +Y_UNIT_TEST_SUITE(TIncrHugeBasicTest) { + Y_UNIT_TEST(WriteReadDeleteEnum) { return; /* TODO(alexvru): https://st.yandex-team.ru/KIKIMR-7588 */ TTestEnv env; @@ -150,7 +150,7 @@ Y_UNIT_TEST_SUITE(TIncrHugeBasicTest) { env.Stop(); } - Y_UNIT_TEST(WriteReadDeleteEnumRecover) { + Y_UNIT_TEST(WriteReadDeleteEnumRecover) { return; /* TODO(alexvru): https://st.yandex-team.ru/KIKIMR-7588 */ TTestActorConcurrent::TTestActorState state; @@ -179,7 +179,7 @@ Y_UNIT_TEST_SUITE(TIncrHugeBasicTest) { } } - Y_UNIT_TEST(Defrag) { + Y_UNIT_TEST(Defrag) { TTestEnv env; env.Setup(true, 0, nullptr, 1000); env.Start(); @@ -207,7 +207,7 @@ Y_UNIT_TEST_SUITE(TIncrHugeBasicTest) { env.Stop(); } - Y_UNIT_TEST(Recovery) { + Y_UNIT_TEST(Recovery) { return; // TODO https://st.yandex-team.ru/KIKIMR-3065 TTestEnv env; env.Setup(true, 0, nullptr, 2000, 128 << 20); @@ -232,7 +232,7 @@ Y_UNIT_TEST_SUITE(TIncrHugeBasicTest) { env.Stop(); } -/* Y_UNIT_TEST(FaultyPDisk) { +/* Y_UNIT_TEST(FaultyPDisk) { for (ui32 counter = 20; counter < 1000; ++counter) { TTestActorSeq::TTestActorState state; TTestActorSeq *actor; diff --git a/ydb/core/blobstorage/incrhuge/ut/incrhuge_id_dict_ut.cpp b/ydb/core/blobstorage/incrhuge/ut/incrhuge_id_dict_ut.cpp index 0d66d7f13a5..1c0ef81d8d3 100644 --- a/ydb/core/blobstorage/incrhuge/ut/incrhuge_id_dict_ut.cpp +++ b/ydb/core/blobstorage/incrhuge/ut/incrhuge_id_dict_ut.cpp @@ -3,8 +3,8 @@ using namespace NKikimr::NIncrHuge; -Y_UNIT_TEST_SUITE(TIncrHugeBlobIdDict) { - Y_UNIT_TEST(Basic) { +Y_UNIT_TEST_SUITE(TIncrHugeBlobIdDict) { + Y_UNIT_TEST(Basic) { TVector<std::pair<TIncrHugeBlobId, ui8>> values; auto callback = [&](TIncrHugeBlobId id, ui8 value) { values.emplace_back(id, value); diff --git a/ydb/core/blobstorage/incrhuge/ut/incrhuge_log_merger_ut.cpp b/ydb/core/blobstorage/incrhuge/ut/incrhuge_log_merger_ut.cpp index 617f7f68a39..ee62764e71b 100644 --- a/ydb/core/blobstorage/incrhuge/ut/incrhuge_log_merger_ut.cpp +++ b/ydb/core/blobstorage/incrhuge/ut/incrhuge_log_merger_ut.cpp @@ -4,5 +4,5 @@ using namespace NKikimr; using namespace NKikimr::NIncrHuge; -Y_UNIT_TEST_SUITE(TIncrHugeLogMerge) { +Y_UNIT_TEST_SUITE(TIncrHugeLogMerge) { } diff --git a/ydb/core/blobstorage/nodewarden/blobstorage_node_warden_ut.cpp b/ydb/core/blobstorage/nodewarden/blobstorage_node_warden_ut.cpp index e3c74cce7b4..feeb4da25c4 100644 --- a/ydb/core/blobstorage/nodewarden/blobstorage_node_warden_ut.cpp +++ b/ydb/core/blobstorage/nodewarden/blobstorage_node_warden_ut.cpp @@ -20,7 +20,7 @@ #include <ydb/library/pdisk_io/sector_map.h> #include <util/random/entropy.h> #include <util/string/printf.h> -#include <util/string/subst.h> +#include <util/string/subst.h> #include <util/stream/file.h> #include <google/protobuf/text_format.h> @@ -41,7 +41,7 @@ namespace NBlobStorageNodeWardenTest{ #if ENABLE_FORKED_TESTS # define CUSTOM_UNIT_TEST(a) SIMPLE_UNIT_FORKED_TEST(a) #else -#define CUSTOM_UNIT_TEST(a) Y_UNIT_TEST(a) +#define CUSTOM_UNIT_TEST(a) Y_UNIT_TEST(a) #endif //ENABLE_FORKED_TESTS #define VERBOSE_COUT(str) \ @@ -275,7 +275,7 @@ void Setup(TTestActorRuntime &runtime, TString extraPath, TIntrusivePtr<NPDisk:: // runtime.SetLogPriority(NKikimrServices::BS_QUEUE, NLog::PRI_DEBUG); } -Y_UNIT_TEST_SUITE(TBlobStorageWardenTest) { +Y_UNIT_TEST_SUITE(TBlobStorageWardenTest) { ui64 GetBsc(TTestActorRuntime &runtime) { ui64 defaultStateStorageGroup = runtime.GetAppData(0).DomainsInfo->GetDefaultStateStorageGroup(DOMAIN_ID); ui64 bsController = MakeBSControllerID(defaultStateStorageGroup); diff --git a/ydb/core/blobstorage/pdisk/blobstorage_pdisk_actor.cpp b/ydb/core/blobstorage/pdisk/blobstorage_pdisk_actor.cpp index d92b19c6cca..255ef055179 100644 --- a/ydb/core/blobstorage/pdisk/blobstorage_pdisk_actor.cpp +++ b/ydb/core/blobstorage/pdisk/blobstorage_pdisk_actor.cpp @@ -177,7 +177,7 @@ class TPDiskActor : public TActorBootstrapped<TPDiskActor> { return LastFlag; } - void Render(IOutputStream& os) const { + void Render(IOutputStream& os) const { switch (LastFlag) { case NKikimrWhiteboard::Grey: break; diff --git a/ydb/core/blobstorage/pdisk/blobstorage_pdisk_blockdevice_async.cpp b/ydb/core/blobstorage/pdisk/blobstorage_pdisk_blockdevice_async.cpp index 34c20999b7b..f1b9b2d70d2 100644 --- a/ydb/core/blobstorage/pdisk/blobstorage_pdisk_blockdevice_async.cpp +++ b/ydb/core/blobstorage/pdisk/blobstorage_pdisk_blockdevice_async.cpp @@ -301,7 +301,7 @@ class TRealBlockDevice : public IBlockDevice { void Exec() { bool isOk = SetHighestThreadPriority(); // TODO: ckeck isOk - Y_UNUSED(isOk); + Y_UNUSED(isOk); TAsyncIoOperationResult events[MaxEvents]; @@ -933,7 +933,7 @@ protected: void PreadAsync(void *data, ui32 size, ui64 offset, TCompletionAction *completionAction, TReqId reqId, NWilson::TTraceId *traceId) override { - Y_VERIFY(completionAction); + Y_VERIFY(completionAction); if (!IsInitialized) { completionAction->Release(ActorSystem); return; @@ -953,7 +953,7 @@ protected: void PwriteAsync(const void *data, ui64 size, ui64 offset, TCompletionAction *completionAction, TReqId reqId, NWilson::TTraceId *traceId) override { - Y_VERIFY(completionAction); + Y_VERIFY(completionAction); if (!IsInitialized) { completionAction->Release(ActorSystem); return; @@ -972,7 +972,7 @@ protected: } void FlushAsync(TCompletionAction *completionAction, TReqId reqId) override { - Y_VERIFY(completionAction); + Y_VERIFY(completionAction); if (!IsInitialized) { completionAction->Release(ActorSystem); return; @@ -1014,7 +1014,7 @@ protected: } void TrimAsync(ui32 size, ui64 offset, TCompletionAction *completionAction, TReqId reqId) override { - Y_VERIFY(completionAction); + Y_VERIFY(completionAction); if (!IsInitialized || QuitCounter.IsBlocked()) { return; } diff --git a/ydb/core/blobstorage/pdisk/blobstorage_pdisk_blockdevice_ut.cpp b/ydb/core/blobstorage/pdisk/blobstorage_pdisk_blockdevice_ut.cpp index 90816f5a22f..2579176cf58 100644 --- a/ydb/core/blobstorage/pdisk/blobstorage_pdisk_blockdevice_ut.cpp +++ b/ydb/core/blobstorage/pdisk/blobstorage_pdisk_blockdevice_ut.cpp @@ -33,7 +33,7 @@ public: {} void Exec(TActorSystem *actorSystem) override { - Y_UNUSED(actorSystem); + Y_UNUSED(actorSystem); AtomicIncrement(*Counter); if (GenerationsToSpawn > 0) { REQUEST_VALGRIND_CHECK_MEM_IS_DEFINED(Buffer->Data(), Buffer->Size()); @@ -46,7 +46,7 @@ public: } void Release(TActorSystem *actorSystem) override { - Y_UNUSED(actorSystem); + Y_UNUSED(actorSystem); delete this; } }; @@ -63,7 +63,7 @@ public: {} void Exec(TActorSystem *actorSystem) override { - Y_UNUSED(actorSystem); + Y_UNUSED(actorSystem); AtomicIncrement(*Counter); if (GenerationsToSpawn > 0) { Device.FlushAsync(new TFlusher(Device, GenerationsToSpawn - 1, Counter), NPDisk::TReqId(NPDisk::TReqId::Test0, 0)); @@ -73,7 +73,7 @@ public: } void Release(TActorSystem *actorSystem) override { - Y_UNUSED(actorSystem); + Y_UNUSED(actorSystem); delete this; } }; @@ -92,7 +92,7 @@ public: {} void Exec(TActorSystem *actorSystem) override { - Y_UNUSED(actorSystem); + Y_UNUSED(actorSystem); AtomicIncrement(*Counter); if (GenerationsToSpawn > 0) { REQUEST_VALGRIND_CHECK_MEM_IS_DEFINED(Buffer->Data(), Buffer->Size()); @@ -106,7 +106,7 @@ public: } void Release(TActorSystem *actorSystem) override { - Y_UNUSED(actorSystem); + Y_UNUSED(actorSystem); delete this; } }; @@ -212,7 +212,7 @@ void RunTestDestructionWithMultipleFlushesFromCompletionAction() { Ctest << "Done" << Endl; } -Y_UNIT_TEST_SUITE(TBlockDeviceTest) { +Y_UNIT_TEST_SUITE(TBlockDeviceTest) { Y_UNIT_TEST(TestMultipleRequestsFromCompletionAction) { RunTestMultipleRequestsFromCompletionAction(); @@ -244,7 +244,7 @@ Y_UNIT_TEST_SUITE(TBlockDeviceTest) { } /* - Y_UNIT_TEST(TestRabbitCompletionAction) { + Y_UNIT_TEST(TestRabbitCompletionAction) { const TIntrusivePtr<NMonitoring::TDynamicCounters> counters = new NMonitoring::TDynamicCounters; THolder<TPDiskMon> mon(new TPDiskMon(counters, 0, nullptr)); const ui32 dataSize = 4 << 10; diff --git a/ydb/core/blobstorage/pdisk/blobstorage_pdisk_crypto_ut.cpp b/ydb/core/blobstorage/pdisk/blobstorage_pdisk_crypto_ut.cpp index 1ca02078cf6..6c64f745fb7 100644 --- a/ydb/core/blobstorage/pdisk/blobstorage_pdisk_crypto_ut.cpp +++ b/ydb/core/blobstorage/pdisk/blobstorage_pdisk_crypto_ut.cpp @@ -6,8 +6,8 @@ namespace NKikimr { -Y_UNIT_TEST_SUITE(TBlobStoragePDiskCrypto) { - Y_UNIT_TEST(TestMixedStreamCypher) { +Y_UNIT_TEST_SUITE(TBlobStoragePDiskCrypto) { + Y_UNIT_TEST(TestMixedStreamCypher) { for (ui32 enableEnctyption = 0; enableEnctyption < 2; ++enableEnctyption) { NPDisk::TPDiskStreamCypher cypher1(enableEnctyption); NPDisk::TPDiskStreamCypher cypher2(enableEnctyption); @@ -43,7 +43,7 @@ Y_UNIT_TEST_SUITE(TBlobStoragePDiskCrypto) { } } - Y_UNIT_TEST(TestInplaceStreamCypher) { + Y_UNIT_TEST(TestInplaceStreamCypher) { for (ui32 enableEnctyption = 0; enableEnctyption < 2; ++enableEnctyption) { NPDisk::TPDiskStreamCypher cypher1(enableEnctyption); NPDisk::TPDiskStreamCypher cypher2(enableEnctyption); diff --git a/ydb/core/blobstorage/pdisk/blobstorage_pdisk_impl.h b/ydb/core/blobstorage/pdisk/blobstorage_pdisk_impl.h index a9b910cb0c1..426d6df3976 100644 --- a/ydb/core/blobstorage/pdisk/blobstorage_pdisk_impl.h +++ b/ydb/core/blobstorage/pdisk/blobstorage_pdisk_impl.h @@ -277,7 +277,7 @@ public: //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Whiteboard and HTTP reports creation void WhiteboardReport(TWhiteboardReport &whiteboardReport); // Called by actor - void RenderState(IOutputStream &str, THttpInfo &httpInfo); + void RenderState(IOutputStream &str, THttpInfo &httpInfo); void OutputHtmlOwners(TStringStream &str); void OutputHtmlLogChunksDetails(TStringStream &str); void OutputHtmlChunksLockUnlockInfo(TStringStream &str); diff --git a/ydb/core/blobstorage/pdisk/blobstorage_pdisk_restore_ut.cpp b/ydb/core/blobstorage/pdisk/blobstorage_pdisk_restore_ut.cpp index 2e0cc9c9a74..13fb5ccab5a 100644 --- a/ydb/core/blobstorage/pdisk/blobstorage_pdisk_restore_ut.cpp +++ b/ydb/core/blobstorage/pdisk/blobstorage_pdisk_restore_ut.cpp @@ -10,7 +10,7 @@ namespace NKikimr { -Y_UNIT_TEST_SUITE(TYardTestRestore) { +Y_UNIT_TEST_SUITE(TYardTestRestore) { YARD_UNIT_TEST(TestRestore15) { TTestContext tc(false, true); diff --git a/ydb/core/blobstorage/pdisk/blobstorage_pdisk_ut.cpp b/ydb/core/blobstorage/pdisk/blobstorage_pdisk_ut.cpp index b49b5bd206f..ae7fc88ef40 100644 --- a/ydb/core/blobstorage/pdisk/blobstorage_pdisk_ut.cpp +++ b/ydb/core/blobstorage/pdisk/blobstorage_pdisk_ut.cpp @@ -19,7 +19,7 @@ Y_UNIT_TEST_SUITE(TPDiskTest) { pDisk->Wakeup(); } - Y_UNIT_TEST(TestThatEveryValueOfEStateEnumKeepsItIntegerValue) { + Y_UNIT_TEST(TestThatEveryValueOfEStateEnumKeepsItIntegerValue) { //////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Warning! // Kikimr Admins use Integer values of EState in their scripts! diff --git a/ydb/core/blobstorage/pdisk/blobstorage_pdisk_util_flightcontrol.cpp b/ydb/core/blobstorage/pdisk/blobstorage_pdisk_util_flightcontrol.cpp index ed9b5e0faea..15bbf3b2b55 100644 --- a/ydb/core/blobstorage/pdisk/blobstorage_pdisk_util_flightcontrol.cpp +++ b/ydb/core/blobstorage/pdisk/blobstorage_pdisk_util_flightcontrol.cpp @@ -14,7 +14,7 @@ TFlightControl::TFlightControl(ui64 bits) , Mask(~((~0ull) << bits)) , IsCompleteLoop(1ull << bits) { - Y_VERIFY(bits > 0 && bits < 16); + Y_VERIFY(bits > 0 && bits < 16); } // Returns 0 in case of scheduling error @@ -62,8 +62,8 @@ void TFlightControl::WakeUp() { void TFlightControl::MarkComplete(ui64 idx) { ui64 beginIdx = AtomicGet(BeginIdx); - Y_VERIFY(idx >= beginIdx); - Y_VERIFY(idx < beginIdx + MaxSize); + Y_VERIFY(idx >= beginIdx); + Y_VERIFY(idx < beginIdx + MaxSize); if (idx == beginIdx) { // It's the first item we are waiting for if (beginIdx == EndIdx) { diff --git a/ydb/core/blobstorage/pdisk/blobstorage_pdisk_util_ut.cpp b/ydb/core/blobstorage/pdisk/blobstorage_pdisk_util_ut.cpp index 97938cfcdc4..7792cb35a76 100644 --- a/ydb/core/blobstorage/pdisk/blobstorage_pdisk_util_ut.cpp +++ b/ydb/core/blobstorage/pdisk/blobstorage_pdisk_util_ut.cpp @@ -23,9 +23,9 @@ namespace NKikimr { namespace NPDisk { -Y_UNIT_TEST_SUITE(TPDiskUtil) { +Y_UNIT_TEST_SUITE(TPDiskUtil) { - Y_UNIT_TEST(AtomicBlockCounterFunctional) { + Y_UNIT_TEST(AtomicBlockCounterFunctional) { TAtomicBlockCounter counter; UNIT_ASSERT_EQUAL(counter.Get(), 0); UNIT_ASSERT_EQUAL(counter.Increment(), 1); @@ -47,7 +47,7 @@ Y_UNIT_TEST_SUITE(TPDiskUtil) { UNIT_ASSERT_EQUAL(counter.Add(5), 10); } - Y_UNIT_TEST(AtomicBlockCounterSeqno) { + Y_UNIT_TEST(AtomicBlockCounterSeqno) { TAtomicBlockCounter counter; TAtomicBlockCounter::TResult res; counter.BlockA(res); @@ -89,7 +89,7 @@ Y_UNIT_TEST_SUITE(TPDiskUtil) { } } - Y_UNIT_TEST(Light) { + Y_UNIT_TEST(Light) { TLight l; TIntrusivePtr<NMonitoring::TDynamicCounters> c(new NMonitoring::TDynamicCounters()); l.Initialize(c, "l"); @@ -218,7 +218,7 @@ Y_UNIT_TEST_SUITE(TPDiskUtil) { } } - Y_UNIT_TEST(LightOverflow) { + Y_UNIT_TEST(LightOverflow) { TLight l; TIntrusivePtr<NMonitoring::TDynamicCounters> c(new NMonitoring::TDynamicCounters()); l.Initialize(c, "l"); @@ -236,7 +236,7 @@ Y_UNIT_TEST_SUITE(TPDiskUtil) { } } - Y_UNIT_TEST(DriveEstimator) { + Y_UNIT_TEST(DriveEstimator) { TTempFileHandle file; file.Resize(1 << 30); TDriveEstimator estimator(file.Name()); diff --git a/ydb/core/blobstorage/pdisk/blobstorage_pdisk_writer.cpp b/ydb/core/blobstorage/pdisk/blobstorage_pdisk_writer.cpp index b638c55ed8d..2ee86193444 100644 --- a/ydb/core/blobstorage/pdisk/blobstorage_pdisk_writer.cpp +++ b/ydb/core/blobstorage/pdisk/blobstorage_pdisk_writer.cpp @@ -64,8 +64,8 @@ void TBufferedWriter::SetupWithBuffer(ui64 startOffset, ui64 currentOffset, TBuf ui8* TBufferedWriter::Seek(ui64 offset, ui32 count, ui32 reserve, TReqId reqId, NWilson::TTraceId *traceId, ui32 chunkIdx) { - Y_VERIFY(count > 0); - Y_VERIFY(count <= 16); + Y_VERIFY(count > 0); + Y_VERIFY(count <= 16); if (NextOffset != offset || NextOffset + SectorSize * reserve - StartOffset > CurrentBuffer->Size()) { WriteBufferWithFlush(LastReqId, traceId, nullptr, chunkIdx); StartOffset = offset; @@ -79,7 +79,7 @@ ui8* TBufferedWriter::Seek(ui64 offset, ui32 count, ui32 reserve, TReqId reqId, } ui8* TBufferedWriter::Get() const { - Y_VERIFY(CurrentSector); + Y_VERIFY(CurrentSector); return CurrentSector; } diff --git a/ydb/core/blobstorage/pdisk/blobstorage_pdisk_writer.h b/ydb/core/blobstorage/pdisk/blobstorage_pdisk_writer.h index 6b818645dd9..ab60f253819 100644 --- a/ydb/core/blobstorage/pdisk/blobstorage_pdisk_writer.h +++ b/ydb/core/blobstorage/pdisk/blobstorage_pdisk_writer.h @@ -133,7 +133,7 @@ public: ui64 sectorOffset = Format.Offset(ChunkIdx, SectorIdx); if (buffer) { - Y_VERIFY(IsLog); + Y_VERIFY(IsLog); Y_VERIFY(!IsSysLog); ui64 startOffset = Format.Offset(ChunkIdx, SectorIdx); BufferedWriter->SetupWithBuffer(startOffset, sectorOffset, buffer, 1, @@ -344,7 +344,7 @@ public: } void Write(const void* data, ui64 size, TReqId reqId, NWilson::TTraceId *traceId) { - Y_VERIFY(data != nullptr); + Y_VERIFY(data != nullptr); Cypher.Encrypt(BufferedWriter->Get() + CurrentPosition, data, (ui32)size); FinalizeWrite(size, reqId, traceId); } @@ -490,7 +490,7 @@ public: protected: void FinalizeWrite(ui64 size, TReqId reqId, NWilson::TTraceId *traceId) { CurrentPosition += size; - Y_VERIFY(SectorBytesFree >= size); + Y_VERIFY(SectorBytesFree >= size); SectorBytesFree -= size; RecordBytesLeft -= size; if (size) { diff --git a/ydb/core/blobstorage/testload/test_load_write.cpp b/ydb/core/blobstorage/testload/test_load_write.cpp index 3169c1609ed..d498f0ebb72 100644 --- a/ydb/core/blobstorage/testload/test_load_write.cpp +++ b/ydb/core/blobstorage/testload/test_load_write.cpp @@ -411,7 +411,7 @@ class TLogWriterTestLoadActor : public TActorBootstrapped<TLogWriterTestLoadActo std::bind(&TTabletWriter::ExposeCounters, this, _1), ctx); } - void DumpState(IOutputStream& str) { + void DumpState(IOutputStream& str) { #define DUMP_PARAM(NAME) \ TABLER() { \ TABLED() { str << #NAME; } \ diff --git a/ydb/core/blobstorage/ut_pdiskfit/ut/main.cpp b/ydb/core/blobstorage/ut_pdiskfit/ut/main.cpp index 011d7cf8398..7627b85d4d1 100644 --- a/ydb/core/blobstorage/ut_pdiskfit/ut/main.cpp +++ b/ydb/core/blobstorage/ut_pdiskfit/ut/main.cpp @@ -4,7 +4,7 @@ #include <util/system/sanitizers.h> -class TWatchdogThread : public ISimpleThread { +class TWatchdogThread : public ISimpleThread { TMutex Mutex; TCondVar Stop; TAtomic QuitFlag = 0; @@ -30,8 +30,8 @@ public: } }; -Y_UNIT_TEST_SUITE(TPDiskFIT) { - Y_UNIT_TEST(Basic) { +Y_UNIT_TEST_SUITE(TPDiskFIT) { + Y_UNIT_TEST(Basic) { TWatchdogThread watchdog; watchdog.Start(); TPDiskFailureInjectionTest test; diff --git a/ydb/core/blobstorage/ut_vdisk/lib/helpers.cpp b/ydb/core/blobstorage/ut_vdisk/lib/helpers.cpp index b73da3df8db..d2624f0cc8c 100644 --- a/ydb/core/blobstorage/ut_vdisk/lib/helpers.cpp +++ b/ydb/core/blobstorage/ut_vdisk/lib/helpers.cpp @@ -134,14 +134,14 @@ class TRangeGet : public TActorBootstrapped<TRangeGet> { for (ui32 i = 1; i < size; i++) { const NKikimrBlobStorage::TQueryResult &qq = rec.GetResult(i); const TLogoBlobID nextId = LogoBlobIDFromLogoBlobID(qq.GetBlobID()); - Y_VERIFY(cmp(id, nextId)); + Y_VERIFY(cmp(id, nextId)); id = nextId; } } } void Handle(TEvBlobStorage::TEvVGetResult::TPtr &ev, const TActorContext &ctx) { - Y_VERIFY(ev->Get()->Record.GetStatus() == NKikimrProto::OK); + Y_VERIFY(ev->Get()->Record.GetStatus() == NKikimrProto::OK); LOG_NOTICE(ctx, NActorsServices::TEST, " TEvVGetResult succeded"); // check result order @@ -587,14 +587,14 @@ class TManyGets : public TActorBootstrapped<TManyGets> { } void Check(const TActorContext &ctx, const NKikimrBlobStorage::TEvVGetResult &rec) { - Y_UNUSED(ctx); + Y_UNUSED(ctx); int size = rec.GetResult().size(); - Y_VERIFY(size == 1, "size=%d", size); + Y_VERIFY(size == 1, "size=%d", size); const NKikimrBlobStorage::TQueryResult &q = rec.GetResult(0); if (q.GetBuffer() != MsgData) { fprintf(stderr, "Original: %s\n", MsgData.data()); fprintf(stderr, "Received: %s\n", q.GetBuffer().data()); - Y_VERIFY(q.GetBuffer() == MsgData); + Y_VERIFY(q.GetBuffer() == MsgData); } } @@ -820,7 +820,7 @@ class TPutGC : public TActorBootstrapped<TPutGC> { } void Handle(TEvBlobStorage::TEvVCollectGarbageResult::TPtr &ev, const TActorContext &ctx) { - Y_VERIFY(ev->Get()->Record.GetStatus() == NKikimrProto::OK, "Status=%d", ev->Get()->Record.GetStatus()); + Y_VERIFY(ev->Get()->Record.GetStatus() == NKikimrProto::OK, "Status=%d", ev->Get()->Record.GetStatus()); LOG_NOTICE(ctx, NActorsServices::TEST, " TEvVCollectGarbageResult succeded"); ctx.Send(NotifyID, new TEvents::TEvCompleted()); TThis::Die(ctx); @@ -884,7 +884,7 @@ class TWaitForCompactionOneDisk : public TActorBootstrapped<TWaitForCompactionOn } void Handle(TEvBlobStorage::TEvVStatusResult::TPtr &ev, const TActorContext &ctx) { - Y_VERIFY(ev->Get()->Record.GetStatus() == NKikimrProto::OK); + Y_VERIFY(ev->Get()->Record.GetStatus() == NKikimrProto::OK); const NKikimrBlobStorage::TEvVStatusResult &record = ev->Get()->Record; bool logoBlobsCompacted = record.GetLogoBlobs().GetCompacted(); @@ -1211,7 +1211,7 @@ class TWaitForSync : public TActorBootstrapped<TWaitForSync> { } void Handle(TEvBlobStorage::TEvVStatusResult::TPtr &ev, const TActorContext &ctx) { - Y_VERIFY(ev->Get()->Record.GetStatus() == NKikimrProto::OK); + Y_VERIFY(ev->Get()->Record.GetStatus() == NKikimrProto::OK); const NKikimrBlobStorage::TEvVStatusResult &record = ev->Get()->Record; TVDiskID vdisk = VDiskIDFromVDiskID(record.GetVDiskID()); @@ -1264,13 +1264,13 @@ class TCheckDbEmptynessActor : public TActorBootstrapped<TCheckDbEmptynessActor> } void Handle(TEvBlobStorage::TEvVStatusResult::TPtr &ev, const TActorContext &ctx) { - Y_UNUSED(ctx); - Y_VERIFY(ev->Get()->Record.GetStatus() == NKikimrProto::OK); + Y_UNUSED(ctx); + Y_VERIFY(ev->Get()->Record.GetStatus() == NKikimrProto::OK); const NKikimrBlobStorage::TEvVStatusResult &record = ev->Get()->Record; auto status = record.GetLocalRecoveryInfo(); ui64 startLsn = status.GetStartLsn(); - Y_VERIFY((ExpectEmpty && startLsn == 0) || (!ExpectEmpty && startLsn != 0)); + Y_VERIFY((ExpectEmpty && startLsn == 0) || (!ExpectEmpty && startLsn != 0)); ctx.Send(NotifyID, new TEvents::TEvCompleted()); TThis::Die(ctx); } @@ -1330,7 +1330,7 @@ class TPutGCToCorrespondingVDisksActor : public TActorBootstrapped<TPutGCToCorre } void Handle(TEvBlobStorage::TEvVCollectGarbageResult::TPtr &ev, const TActorContext &ctx) { - Y_VERIFY(ev->Get()->Record.GetStatus() == NKikimrProto::OK, "Status=%d", ev->Get()->Record.GetStatus()); + Y_VERIFY(ev->Get()->Record.GetStatus() == NKikimrProto::OK, "Status=%d", ev->Get()->Record.GetStatus()); LOG_NOTICE(ctx, NActorsServices::TEST, " TEvVCollectGarbageResult succeded"); --Counter; @@ -1399,7 +1399,7 @@ void PutLogoBlobToVDisk(const TActorContext &ctx, const TActorId &actorID, const // returns number of messages sent ui32 PutLogoBlobToCorrespondingVDisks(const TActorContext &ctx, NKikimr::TBlobStorageGroupInfo *info, const TLogoBlobID &id, const TString &data, NKikimrBlobStorage::EPutHandleClass cls) { - Y_ASSERT(id.PartId() == 0); + Y_ASSERT(id.PartId() == 0); ui32 msgsSent = 0; TBlobStorageGroupInfo::TVDiskIds outVDisks; TBlobStorageGroupInfo::TServiceIds outServIds; @@ -1415,7 +1415,7 @@ ui32 PutLogoBlobToCorrespondingVDisks(const TActorContext &ctx, NKikimr::TBlobSt ui32 GetLogoBlobFromCorrespondingVDisks(const NActors::TActorContext &ctx, NKikimr::TBlobStorageGroupInfo *info, const NKikimr::TLogoBlobID &id) { - Y_ASSERT(id.PartId() == 0); + Y_ASSERT(id.PartId() == 0); ui32 msgsSent = 0; TBlobStorageGroupInfo::TVDiskIds outVDisks; TBlobStorageGroupInfo::TServiceIds outServIds; @@ -1461,12 +1461,12 @@ TDataSnapshot::TDataSnapshot(TIntrusivePtr<NKikimr::TBlobStorageGroupInfo> info) void TDataSnapshot::PutExact(const TVDiskID &vdisk, const TActorId &service, const NKikimr::TLogoBlobID &id, const TString &data, const TIngress &ingress) { - Y_ASSERT(id.PartId() != 0); + Y_ASSERT(id.PartId() != 0); Data.push_back(TItem(vdisk, service, id, data, ingress)); } void TDataSnapshot::PutCorresponding(const NKikimr::TLogoBlobID &id, const TString &data) { - Y_ASSERT(id.PartId() == 0); + Y_ASSERT(id.PartId() == 0); TBlobStorageGroupInfo::TVDiskIds outVDisks; TBlobStorageGroupInfo::TServiceIds outServIds; @@ -1491,7 +1491,7 @@ void TDataSnapshot::SortAndCheck() { disk = i.VDiskID; id = i.Id; } else { - Y_VERIFY(i.Id != id, "NOT IMPLEMENTED"); + Y_VERIFY(i.Id != id, "NOT IMPLEMENTED"); } } } @@ -1621,12 +1621,12 @@ class TCheckDataSnapshotActor : public TActorBootstrapped<TCheckDataSnapshotActo // check result const auto &rec = ev->Get()->Record; int size = rec.GetResult().size(); - Y_VERIFY(size == 1); + Y_VERIFY(size == 1); const NKikimrBlobStorage::TQueryResult &q = rec.GetResult(0); const TLogoBlobID id = LogoBlobIDFromLogoBlobID(q.GetBlobID()); TIngress ingress(q.GetIngress()); if (q.GetStatus() == NKikimrProto::OK) { - Y_VERIFY(id == Cur->Id); + Y_VERIFY(id == Cur->Id); Y_VERIFY(ingress.Raw() == Cur->Ingress.Raw() && q.GetBuffer() == Cur->Data, "vdiskId# %s id# %s ingress# %s Cur->Ingress# %s" " ingress.Raw# %" PRIu64 " Cur->Ingress.Raw# %" PRIu64 @@ -1640,7 +1640,7 @@ class TCheckDataSnapshotActor : public TActorBootstrapped<TCheckDataSnapshotActo q.GetBuffer().data(), Cur->Data.data()); } else if (q.GetStatus() == NKikimrProto::NODATA) { - Y_VERIFY(Cur->Data.empty()); + Y_VERIFY(Cur->Data.empty()); Y_VERIFY(ingress.Raw() == Cur->Ingress.Raw(), "vdiskId# %s id# %s ingress# %s Cur->Ingress# %s" " ingress.Raw# %" PRIu64 " Cur->Ingress.Raw# %" PRIu64, @@ -1686,25 +1686,25 @@ void CheckQueryResult(NKikimr::TEvBlobStorage::TEvVGetResult::TPtr &ev, const NA EQueryResult eqr, TExpectedSet *expSet, bool fullResult) { switch (eqr) { case EQR_OK_NODATA: { - Y_VERIFY(ev->Get()->Record.GetStatus() == NKikimrProto::OK); + Y_VERIFY(ev->Get()->Record.GetStatus() == NKikimrProto::OK); LOG_NOTICE(ctx, NActorsServices::TEST, " TEvVGetResult succeded"); const NKikimrBlobStorage::TEvVGetResult &rec = ev->Get()->Record; int size = rec.GetResult().size(); - Y_VERIFY(size == 1); + Y_VERIFY(size == 1); const NKikimrBlobStorage::TQueryResult &q = rec.GetResult(0); - Y_VERIFY(q.GetStatus() == NKikimrProto::NODATA); + Y_VERIFY(q.GetStatus() == NKikimrProto::NODATA); break; } case EQR_OK_EMPTY: { - Y_VERIFY(ev->Get()->Record.GetStatus() == NKikimrProto::OK); + Y_VERIFY(ev->Get()->Record.GetStatus() == NKikimrProto::OK); LOG_NOTICE(ctx, NActorsServices::TEST, " TEvVGetResult succeded"); const NKikimrBlobStorage::TEvVGetResult &rec = ev->Get()->Record; int size = rec.GetResult().size(); - Y_VERIFY(size == 0); + Y_VERIFY(size == 0); break; } case EQR_OK_EXPECTED_SET: { - Y_VERIFY(ev->Get()->Record.GetStatus() == NKikimrProto::OK, "Status=%d", ev->Get()->Record.GetStatus()); + Y_VERIFY(ev->Get()->Record.GetStatus() == NKikimrProto::OK, "Status=%d", ev->Get()->Record.GetStatus()); LOG_NOTICE(ctx, NActorsServices::TEST, " TEvVGetResult succeded"); const NKikimrBlobStorage::TEvVGetResult &rec = ev->Get()->Record; int size = rec.GetResult().size(); @@ -1720,7 +1720,7 @@ void CheckQueryResult(NKikimr::TEvBlobStorage::TEvVGetResult::TPtr &ev, const NA expSet->Finish(); break; } - default: Y_FAIL("Impossible case"); + default: Y_FAIL("Impossible case"); } } /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -1728,7 +1728,7 @@ void CheckQueryResult(NKikimr::TEvBlobStorage::TEvVGetResult::TPtr &ev, const NA /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void PrintDebug(NKikimr::TEvBlobStorage::TEvVGetResult::TPtr &ev, const NActors::TActorContext &ctx, NKikimr::TBlobStorageGroupInfo *info, const NKikimr::TVDiskID &vdisk) { - Y_VERIFY(ev->Get()->Record.GetStatus() == NKikimrProto::OK); + Y_VERIFY(ev->Get()->Record.GetStatus() == NKikimrProto::OK); // output result const NKikimrBlobStorage::TEvVGetResult &rec = ev->Get()->Record; @@ -1759,7 +1759,7 @@ TExpectedSet::TExpectedResult::TExpectedResult(NKikimrProto::EReplyStatus status void TExpectedSet::Put(const TLogoBlobID &id, NKikimrProto::EReplyStatus status, const TString &data) { bool res = Map.insert(TMapType::value_type(id, TExpectedResult(status, data))).second; - Y_VERIFY(res); + Y_VERIFY(res); } TString TExpectedSet::ToString() const { @@ -1776,20 +1776,20 @@ void TExpectedSet::Check(const TLogoBlobID &id, NKikimrProto::EReplyStatus statu TMapType::iterator it = Map.find(id); Y_VERIFY(it != Map.end(), "TExpectedSet::Check: can't find id=%s; data# '%s' map# %s", id.ToString().data(), data.data(), ToString().data()); - Y_VERIFY(it->second.Status == status, "TExpectedSet::Check: incorrect status %s instead of %s for %s", + Y_VERIFY(it->second.Status == status, "TExpectedSet::Check: incorrect status %s instead of %s for %s", NKikimrProto::EReplyStatus_Name(status).data(), NKikimrProto::EReplyStatus_Name(it->second.Status).data(), id.ToString().data()); - Y_VERIFY(it->second.Data == data, "TExpectedSet::Check: incorrect data '%s' instead of '%s' for %s; " + Y_VERIFY(it->second.Data == data, "TExpectedSet::Check: incorrect data '%s' instead of '%s' for %s; " "got string of size %u instead of string of size %u", data.data(), it->second.Data.data(), id.ToString().data(), unsigned(data.size()), unsigned(it->second.Data.size())); Map.erase(it); } void TExpectedSet::Finish() { - Y_VERIFY(Map.empty()); + Y_VERIFY(Map.empty()); } -Y_DECLARE_OUT_SPEC(, TExpectedSet::TExpectedResult, stream, value) { +Y_DECLARE_OUT_SPEC(, TExpectedSet::TExpectedResult, stream, value) { stream << "Status# " << NKikimrProto::EReplyStatus_Name(value.Status) << " Data# " << value.Data; } diff --git a/ydb/core/blobstorage/ut_vdisk/lib/http_client.cpp b/ydb/core/blobstorage/ut_vdisk/lib/http_client.cpp index abde48cedfa..28b86a55bc3 100644 --- a/ydb/core/blobstorage/ut_vdisk/lib/http_client.cpp +++ b/ydb/core/blobstorage/ut_vdisk/lib/http_client.cpp @@ -33,7 +33,7 @@ THttpClient::~THttpClient() = default; void THttpClient::SendHttpRequest(const TStringBuf relativeUrl, const TString& body, const TString& method, - IOutputStream* output, + IOutputStream* output, const THeaders& headers) const { auto addr = Resolve(); @@ -43,31 +43,31 @@ void THttpClient::SendHttpRequest(const TStringBuf relativeUrl, TString contentLength; parts.reserve(16); - parts.push_back(IOutputStream::TPart(method)); + parts.push_back(IOutputStream::TPart(method)); parts.push_back(TStringBuf(" ")); parts.push_back(relativeUrl); parts.push_back(TStringBuf(" HTTP/1.1")); - parts.push_back(IOutputStream::TPart::CrLf()); + parts.push_back(IOutputStream::TPart::CrLf()); parts.push_back(TStringBuf("Host: ")); parts.push_back(TStringBuf(Host)); - parts.push_back(IOutputStream::TPart::CrLf()); + parts.push_back(IOutputStream::TPart::CrLf()); parts.push_back(TStringBuf("From: oxygen@yandex-team.ru")); - parts.push_back(IOutputStream::TPart::CrLf()); + parts.push_back(IOutputStream::TPart::CrLf()); if (body.size() > 0) { contentLength = ToString(body.size()); parts.push_back(TStringBuf("Content-Length: ")); parts.push_back(TStringBuf(contentLength)); - parts.push_back(IOutputStream::TPart::CrLf()); + parts.push_back(IOutputStream::TPart::CrLf()); } for (const auto& entry: headers) { - parts.push_back(IOutputStream::TPart(entry.first)); + parts.push_back(IOutputStream::TPart(entry.first)); parts.push_back(IOutputStream::TPart(TStringBuf(": "))); - parts.push_back(IOutputStream::TPart(entry.second)); - parts.push_back(IOutputStream::TPart::CrLf()); + parts.push_back(IOutputStream::TPart(entry.second)); + parts.push_back(IOutputStream::TPart::CrLf()); } - parts.push_back(IOutputStream::TPart::CrLf()); + parts.push_back(IOutputStream::TPart::CrLf()); if (body.size() > 0) { - parts.push_back(IOutputStream::TPart(body)); + parts.push_back(IOutputStream::TPart(body)); } TSocketOutput sockOutput(*socket); @@ -108,7 +108,7 @@ std::unique_ptr<TSocket> THttpClient::Connect(TNetworkAddress& addr) const { } -void THttpClient::ProcessResponse(const TStringBuf relativeUrl, THttpInput& input, IOutputStream* output, +void THttpClient::ProcessResponse(const TStringBuf relativeUrl, THttpInput& input, IOutputStream* output, const unsigned statusCode) const { if (output) { @@ -121,7 +121,7 @@ void THttpClient::ProcessResponse(const TStringBuf relativeUrl, THttpInput& inpu } } -void THttpClient::ReadAndTransferHttp(const TStringBuf relativeUrl, THttpInput& input, IOutputStream* output) const { +void THttpClient::ReadAndTransferHttp(const TStringBuf relativeUrl, THttpInput& input, IOutputStream* output) const { unsigned statusCode; try { statusCode = ParseHttpRetCode(input.FirstLine()); diff --git a/ydb/core/blobstorage/ut_vdisk/lib/http_client.h b/ydb/core/blobstorage/ut_vdisk/lib/http_client.h index 3370f0eb00b..4e3a0062fdb 100644 --- a/ydb/core/blobstorage/ut_vdisk/lib/http_client.h +++ b/ydb/core/blobstorage/ut_vdisk/lib/http_client.h @@ -11,7 +11,7 @@ // Simple http client based on library/cpp/http/simple. class TNetworkAddress; -class IOutputStream; +class IOutputStream; class TSocket; class THttpRequestException : public yexception { @@ -38,15 +38,15 @@ public: void SendHttpRequest(const TStringBuf relativeUrl, const TString& body, const TString& method, - IOutputStream* output, + IOutputStream* output, const THeaders& headers = THeaders()) const; private: - void ReadAndTransferHttp(const TStringBuf relativeUrl, THttpInput& inp, IOutputStream* output) const; + void ReadAndTransferHttp(const TStringBuf relativeUrl, THttpInput& inp, IOutputStream* output) const; std::unique_ptr<TNetworkAddress> Resolve() const; std::unique_ptr<TSocket> Connect(TNetworkAddress& addr) const; - void ProcessResponse(const TStringBuf relativeUrl, THttpInput& input, IOutputStream* output, + void ProcessResponse(const TStringBuf relativeUrl, THttpInput& input, IOutputStream* output, const unsigned statusCode) const; private: diff --git a/ydb/core/blobstorage/ut_vdisk/lib/prepare.cpp b/ydb/core/blobstorage/ut_vdisk/lib/prepare.cpp index b2c020c3d21..c7138ca3925 100644 --- a/ydb/core/blobstorage/ut_vdisk/lib/prepare.cpp +++ b/ydb/core/blobstorage/ut_vdisk/lib/prepare.cpp @@ -163,7 +163,7 @@ void TAllPDisks::ActorSetupCmd(NActors::TActorSystemSetup *setup, ui32 node, } TOnePDisk &TAllPDisks::Get(ui32 pDiskID) { - Y_ASSERT(pDiskID > 0); + Y_ASSERT(pDiskID > 0); return PDisks.at(pDiskID - 1); } @@ -434,7 +434,7 @@ class TDbInitWaitActor : public TActorBootstrapped<TDbInitWaitActor> { } void Handle(TEvBlobStorage::TEvVReadyNotify::TPtr &ev, const TActorContext &ctx) { - Y_UNUSED(ev); + Y_UNUSED(ev); --Count; if (Count == 0) Finish(ctx, true); @@ -470,5 +470,5 @@ void TConfiguration::PoisonVDisks() { void TConfiguration::PoisonPDisks() { // FIXME: implement - Y_VERIFY_DEBUG(false); + Y_VERIFY_DEBUG(false); } diff --git a/ydb/core/blobstorage/ut_vdisk/lib/test_faketablet.cpp b/ydb/core/blobstorage/ut_vdisk/lib/test_faketablet.cpp index b4d5cf9de33..b7a2a34fa51 100644 --- a/ydb/core/blobstorage/ut_vdisk/lib/test_faketablet.cpp +++ b/ydb/core/blobstorage/ut_vdisk/lib/test_faketablet.cpp @@ -31,7 +31,7 @@ class TFakeTabletLogChannelActor : public NActors::TActorBootstrapped<TFakeTable } void Handle(TEvents::TEvCompleted::TPtr &ev, const TActorContext &ctx) { - Y_UNUSED(ev); + Y_UNUSED(ev); Iteration(ctx); } @@ -78,7 +78,7 @@ class TFakeTabletHugeBlobChannelActor : public NActors::TActorBootstrapped<TFake } void Handle(TEvents::TEvCompleted::TPtr &ev, const TActorContext &ctx) { - Y_UNUSED(ev); + Y_UNUSED(ev); ctx.Schedule(WaitTime, new TEvents::TEvWakeup()); } @@ -137,7 +137,7 @@ class TFakeTabletActor : public NActors::TActorBootstrapped<TFakeTabletActor> { } void Handle(TEvents::TEvCompleted::TPtr &ev, const TActorContext &ctx) { - Y_UNUSED(ev); + Y_UNUSED(ev); Counter--; if (Counter == 0) Finish(ctx); @@ -190,7 +190,7 @@ class TFakeTabletLoadActor : public NActors::TActorBootstrapped<TFakeTabletLoadA } void Handle(TEvents::TEvCompleted::TPtr &ev, const TActorContext &ctx) { - Y_UNUSED(ev); + Y_UNUSED(ev); Counter--; if (Counter == 0) Finish(ctx); diff --git a/ydb/core/blobstorage/ut_vdisk/lib/test_gc.cpp b/ydb/core/blobstorage/ut_vdisk/lib/test_gc.cpp index eb602a0b46f..9c851583fc4 100644 --- a/ydb/core/blobstorage/ut_vdisk/lib/test_gc.cpp +++ b/ydb/core/blobstorage/ut_vdisk/lib/test_gc.cpp @@ -295,7 +295,7 @@ virtual void Scenario(const TActorContext &ctx) { }; auto checkFunc = [&done](TEvBlobStorage::TEvVGetResult::TPtr &ev, const TActorContext &ctx) { TEvBlobStorage::TEvVGetResult *msg = ev->Get(); - Y_VERIFY(msg->Record.GetStatus() == NKikimrProto::OK); + Y_VERIFY(msg->Record.GetStatus() == NKikimrProto::OK); done = msg->Record.ResultSize() == 0; LOG_NOTICE(ctx, NActorsServices::TEST, " Test: emptyDb=%s", (done ? "true" : "false")); }; diff --git a/ydb/core/blobstorage/ut_vdisk/lib/test_huge.cpp b/ydb/core/blobstorage/ut_vdisk/lib/test_huge.cpp index 7364483b0c5..5b2c6609661 100644 --- a/ydb/core/blobstorage/ut_vdisk/lib/test_huge.cpp +++ b/ydb/core/blobstorage/ut_vdisk/lib/test_huge.cpp @@ -65,16 +65,16 @@ public: return false; } case 1: - Y_FAIL(); + Y_FAIL(); case 2: return true; default: - Y_FAIL(); + Y_FAIL(); } } void Handle(TEvHullLogHugeBlob::TPtr &ev, const TActorContext &ctx) override { - Y_VERIFY(State == 1); + Y_VERIFY(State == 1); // FIXME: log const auto *msg = ev->Get(); diff --git a/ydb/core/blobstorage/ut_vdisk/lib/test_localrecovery.cpp b/ydb/core/blobstorage/ut_vdisk/lib/test_localrecovery.cpp index b65c601f86e..a78ba4cc916 100644 --- a/ydb/core/blobstorage/ut_vdisk/lib/test_localrecovery.cpp +++ b/ydb/core/blobstorage/ut_vdisk/lib/test_localrecovery.cpp @@ -149,7 +149,7 @@ class TChaoticManyPutsActor : public NActors::TActorBootstrapped<TChaoticManyPut friend class NActors::TActorBootstrapped<TChaoticManyPutsActor>; void Bootstrap(const NActors::TActorContext &ctx) { - Y_UNUSED(ctx); + Y_UNUSED(ctx); for (ui32 i = 0; i < Parallel; i++) { ui64 tabletId = i + 1; ui32 channel = 0; @@ -172,7 +172,7 @@ class TChaoticManyPutsActor : public NActors::TActorBootstrapped<TChaoticManyPut } void Handle(TEvents::TEvCompleted::TPtr &ev, const TActorContext &ctx) { - Y_UNUSED(ev); + Y_UNUSED(ev); Counter++; if (Counter == Parallel) Finish(ctx); diff --git a/ydb/core/blobstorage/ut_vdisk/lib/test_simplebs.cpp b/ydb/core/blobstorage/ut_vdisk/lib/test_simplebs.cpp index 583b2beb1b1..3059abfecbc 100644 --- a/ydb/core/blobstorage/ut_vdisk/lib/test_simplebs.cpp +++ b/ydb/core/blobstorage/ut_vdisk/lib/test_simplebs.cpp @@ -28,7 +28,7 @@ private: } void Handle(TEvBlobStorage::TEvVPutResult::TPtr &ev, const TActorContext &ctx) { - Y_VERIFY(ev->Get()->Record.GetStatus() == NKikimrProto::OK, "Status=%s", + Y_VERIFY(ev->Get()->Record.GetStatus() == NKikimrProto::OK, "Status=%s", NKikimrProto::EReplyStatus_Name(ev->Get()->Record.GetStatus()).data()); LOG_NOTICE(ctx, NActorsServices::TEST, " TEvVPutResult succeded"); diff --git a/ydb/core/blobstorage/ut_vdisk/lib/test_synclog.cpp b/ydb/core/blobstorage/ut_vdisk/lib/test_synclog.cpp index b5608c382d2..c527549d36d 100644 --- a/ydb/core/blobstorage/ut_vdisk/lib/test_synclog.cpp +++ b/ydb/core/blobstorage/ut_vdisk/lib/test_synclog.cpp @@ -181,7 +181,7 @@ class TSyncLogTestWriteActor : public TActorBootstrapped<TSyncLogTestWriteActor> void Handle(NPDisk::TEvYardInitResult::TPtr &ev, const TActorContext &ctx) { NKikimrProto::EReplyStatus status = ev->Get()->Status; - Y_VERIFY(ev->Get()->Status == status != NKikimrProto::OK); + Y_VERIFY(ev->Get()->Status == status != NKikimrProto::OK); const auto &m = ev->Get(); TestCtx->PDiskCtx = TPDiskCtx::Create(m->PDiskParams, VDiskConfig); diff --git a/ydb/core/blobstorage/ut_vdisk/mon_reregister_ut.cpp b/ydb/core/blobstorage/ut_vdisk/mon_reregister_ut.cpp index 36a2eca81f8..3c4cfb93d04 100644 --- a/ydb/core/blobstorage/ut_vdisk/mon_reregister_ut.cpp +++ b/ydb/core/blobstorage/ut_vdisk/mon_reregister_ut.cpp @@ -22,7 +22,7 @@ using namespace NKikimr; -Y_UNIT_TEST_SUITE(TMonitoring) { +Y_UNIT_TEST_SUITE(TMonitoring) { //////////////////////////////////////////////////////////////////// // TMyWorker @@ -137,7 +137,7 @@ Y_UNIT_TEST_SUITE(TMonitoring) { //////////////////////////////////////////////////////////////////// // Unit test //////////////////////////////////////////////////////////////////// - Y_UNIT_TEST(ReregisterTest) { + Y_UNIT_TEST(ReregisterTest) { std::shared_ptr<TTestWithActorSystem> test(new TTestWithActorSystem(0)); test->Run(new TMyTest(test)); } diff --git a/ydb/core/blobstorage/ut_vdisk/vdisk_test.cpp b/ydb/core/blobstorage/ut_vdisk/vdisk_test.cpp index 694828c9f8c..1ac63c0edb6 100644 --- a/ydb/core/blobstorage/ut_vdisk/vdisk_test.cpp +++ b/ydb/core/blobstorage/ut_vdisk/vdisk_test.cpp @@ -72,8 +72,8 @@ IDataSetPtr DataSetSelector(EDataSet t, ui32 minHugeBlobSize) { } /////////////////////////////////////////////////////////////////////////////////////////////////////// -#define Y_UNIT_TEST_COMP_DISK(TestName, ClassName, Setup, CompParam, VDiskNumParam, g) \ -Y_UNIT_TEST(TestName) { \ +#define Y_UNIT_TEST_COMP_DISK(TestName, ClassName, Setup, CompParam, VDiskNumParam, g) \ +Y_UNIT_TEST(TestName) { \ IDataSetPtr ds = DataSetSelector(g, 64u << 10u); \ ClassName test(ds, CompParam, VDiskNumParam); \ TestRun<ClassName, Setup>(&test, TIMEOUT); \ @@ -82,33 +82,33 @@ Y_UNIT_TEST(TestName) { /////////////////////////////////////////////////////////////////////////////////////////////////////// // SIMPLE BS /////////////////////////////////////////////////////////////////////////////////////////////////////// -Y_UNIT_TEST_SUITE(TBsVDiskExtreme) { +Y_UNIT_TEST_SUITE(TBsVDiskExtreme) { - Y_UNIT_TEST(SimpleGetFromEmptyDB) { + Y_UNIT_TEST(SimpleGetFromEmptyDB) { TSimpleGetFromEmptyDB test; TestRun<TSimpleGetFromEmptyDB, TFastVDiskSetup>(&test, TIMEOUT); } Y_UNIT_TEST_COMP_DISK(Simple3Put3GetFresh, TSimple3Put3Get, TFastVDiskSetup, false, 0, DG_3PUT) - Y_UNIT_TEST_COMP_DISK(Simple3Put3GetCompaction, TSimple3Put3Get, TFastVDiskSetupCompacted, true, 0, DG_3PUT) + Y_UNIT_TEST_COMP_DISK(Simple3Put3GetCompaction, TSimple3Put3Get, TFastVDiskSetupCompacted, true, 0, DG_3PUT) Y_UNIT_TEST_COMP_DISK(Simple3Put1SeqGetAllFresh, TSimple3Put1SeqGetAll, TFastVDiskSetup, false, 0, DG_3PUT) - Y_UNIT_TEST_COMP_DISK(Simple3Put1SeqGetAllCompaction, TSimple3Put1SeqGetAll, TFastVDiskSetupCompacted, true, 0, DG_3PUT) + Y_UNIT_TEST_COMP_DISK(Simple3Put1SeqGetAllCompaction, TSimple3Put1SeqGetAll, TFastVDiskSetupCompacted, true, 0, DG_3PUT) Y_UNIT_TEST_COMP_DISK(Simple3Put1SeqGet2Fresh, TSimple3Put1SeqGet2, TFastVDiskSetup, false, 0, DG_3PUT) - Y_UNIT_TEST_COMP_DISK(Simple3Put1SeqGet2Compaction, TSimple3Put1SeqGet2, TFastVDiskSetupCompacted, true, 0, DG_3PUT) + Y_UNIT_TEST_COMP_DISK(Simple3Put1SeqGet2Compaction, TSimple3Put1SeqGet2, TFastVDiskSetupCompacted, true, 0, DG_3PUT) Y_UNIT_TEST_COMP_DISK(Simple3Put1SeqSubsOkFresh, TSimple3Put1SeqSubsOk, TFastVDiskSetup, false, 0, DG_3PUT) - Y_UNIT_TEST_COMP_DISK(Simple3Put1SeqSubsOkCompaction, TSimple3Put1SeqSubsOk, TFastVDiskSetupCompacted, true, 0, DG_3PUT) + Y_UNIT_TEST_COMP_DISK(Simple3Put1SeqSubsOkCompaction, TSimple3Put1SeqSubsOk, TFastVDiskSetupCompacted, true, 0, DG_3PUT) Y_UNIT_TEST_COMP_DISK(Simple3Put1SeqSubsErrorFresh, TSimple3Put1SeqSubsError, TFastVDiskSetup, false, 0, DG_3PUT) - Y_UNIT_TEST_COMP_DISK(Simple3Put1SeqSubsErrorCompaction, TSimple3Put1SeqSubsError, TFastVDiskSetupCompacted, true, 0, DG_3PUT) + Y_UNIT_TEST_COMP_DISK(Simple3Put1SeqSubsErrorCompaction, TSimple3Put1SeqSubsError, TFastVDiskSetupCompacted, true, 0, DG_3PUT) Y_UNIT_TEST_COMP_DISK(Simple3Put1GetMissingKeyFresh, TSimple3Put1GetMissingKey, TFastVDiskSetup, false, 0, DG_3PUT) - Y_UNIT_TEST_COMP_DISK(Simple3Put1GetMissingKeyCompaction, TSimple3Put1GetMissingKey, TFastVDiskSetupCompacted, true, 0, DG_3PUT) + Y_UNIT_TEST_COMP_DISK(Simple3Put1GetMissingKeyCompaction, TSimple3Put1GetMissingKey, TFastVDiskSetupCompacted, true, 0, DG_3PUT) Y_UNIT_TEST_COMP_DISK(Simple3Put1GetMissingPartFresh, TSimple3Put1GetMissingPart, TFastVDiskSetup, false, 0, DG_3PUT) - Y_UNIT_TEST_COMP_DISK(Simple3Put1GetMissingPartCompaction, TSimple3Put1GetMissingPart, TFastVDiskSetupCompacted, true, 0, DG_3PUT) + Y_UNIT_TEST_COMP_DISK(Simple3Put1GetMissingPartCompaction, TSimple3Put1GetMissingPart, TFastVDiskSetupCompacted, true, 0, DG_3PUT) // TODO: Make range queries // TODO: Block and read block } @@ -117,86 +117,86 @@ Y_UNIT_TEST_SUITE(TBsVDiskExtreme) { /////////////////////////////////////////////////////////////////////////////////////////////////////// // SIMPLE BS /////////////////////////////////////////////////////////////////////////////////////////////////////// -Y_UNIT_TEST_SUITE(TBsVDiskExtremeHuge) { +Y_UNIT_TEST_SUITE(TBsVDiskExtremeHuge) { Y_UNIT_TEST_COMP_DISK(Simple3Put3GetFresh, TSimple3Put3Get, TFastVDiskSetup, false, 0, DG_3PUT_HUGE) - Y_UNIT_TEST_COMP_DISK(Simple3Put3GetCompaction, TSimple3Put3Get, TFastVDiskSetupCompacted, true, 0, DG_3PUT_HUGE) + Y_UNIT_TEST_COMP_DISK(Simple3Put3GetCompaction, TSimple3Put3Get, TFastVDiskSetupCompacted, true, 0, DG_3PUT_HUGE) Y_UNIT_TEST_COMP_DISK(Simple3Put1SeqGetAllFresh, TSimple3Put1SeqGetAll, TFastVDiskSetup, false, 0, DG_3PUT_HUGE) - Y_UNIT_TEST_COMP_DISK(Simple3Put1SeqGetAllCompaction, TSimple3Put1SeqGetAll, TFastVDiskSetupCompacted, true, 0, DG_3PUT_HUGE) + Y_UNIT_TEST_COMP_DISK(Simple3Put1SeqGetAllCompaction, TSimple3Put1SeqGetAll, TFastVDiskSetupCompacted, true, 0, DG_3PUT_HUGE) Y_UNIT_TEST_COMP_DISK(Simple3Put1SeqGet2Fresh, TSimple3Put1SeqGet2, TFastVDiskSetup, false, 0, DG_3PUT_HUGE) - Y_UNIT_TEST_COMP_DISK(Simple3Put1SeqGet2Compaction, TSimple3Put1SeqGet2, TFastVDiskSetupCompacted, true, 0, DG_3PUT_HUGE) + Y_UNIT_TEST_COMP_DISK(Simple3Put1SeqGet2Compaction, TSimple3Put1SeqGet2, TFastVDiskSetupCompacted, true, 0, DG_3PUT_HUGE) Y_UNIT_TEST_COMP_DISK(Simple3Put1SeqSubsOkFresh, TSimple3Put1SeqSubsOk, TFastVDiskSetup, false, 0, DG_3PUT_HUGE) - Y_UNIT_TEST_COMP_DISK(Simple3Put1SeqSubsOkCompaction, TSimple3Put1SeqSubsOk, TFastVDiskSetupCompacted, true, 0, DG_3PUT_HUGE) + Y_UNIT_TEST_COMP_DISK(Simple3Put1SeqSubsOkCompaction, TSimple3Put1SeqSubsOk, TFastVDiskSetupCompacted, true, 0, DG_3PUT_HUGE) Y_UNIT_TEST_COMP_DISK(Simple3Put1SeqSubsErrorFresh, TSimple3Put1SeqSubsError, TFastVDiskSetup, false, 0, DG_3PUT_HUGE) - Y_UNIT_TEST_COMP_DISK(Simple3Put1SeqSubsErrorCompaction, TSimple3Put1SeqSubsError, TFastVDiskSetupCompacted, true, 0, DG_3PUT_HUGE) + Y_UNIT_TEST_COMP_DISK(Simple3Put1SeqSubsErrorCompaction, TSimple3Put1SeqSubsError, TFastVDiskSetupCompacted, true, 0, DG_3PUT_HUGE) } /////////////////////////////////////////////////////////////////////////////////////////////////////// // SIMPLE BS /////////////////////////////////////////////////////////////////////////////////////////////////////// -Y_UNIT_TEST_SUITE(TBsVDiskExtremeHandoff) { +Y_UNIT_TEST_SUITE(TBsVDiskExtremeHandoff) { Y_UNIT_TEST_COMP_DISK(SimpleHnd6Put1SeqGetFresh, TSimpleHnd6Put1SeqGet, TFastVDiskSetupHndOff, false, 7, DB_3PUT2HND) - Y_UNIT_TEST_COMP_DISK(SimpleHnd6Put1SeqGetCompaction, TSimpleHnd6Put1SeqGet, TFastVDiskSetupCompactedHndOff, true, 7, DB_3PUT2HND) + Y_UNIT_TEST_COMP_DISK(SimpleHnd6Put1SeqGetCompaction, TSimpleHnd6Put1SeqGet, TFastVDiskSetupCompactedHndOff, true, 7, DB_3PUT2HND) Y_UNIT_TEST_COMP_DISK(SimpleHnd2Put1GetFresh, TSimpleHnd2Put1Get, TFastVDiskSetupHndOff, false, 7, DB_1PUT2HND) - Y_UNIT_TEST_COMP_DISK(SimpleHnd2Put1GetCompaction, TSimpleHnd2Put1Get, TFastVDiskSetupCompactedHndOff, true, 7, DB_1PUT2HND) + Y_UNIT_TEST_COMP_DISK(SimpleHnd2Put1GetCompaction, TSimpleHnd2Put1Get, TFastVDiskSetupCompactedHndOff, true, 7, DB_1PUT2HND) } /////////////////////////////////////////////////////////////////////////////////////////////////////// // SIMPLE BS /////////////////////////////////////////////////////////////////////////////////////////////////////// -Y_UNIT_TEST_SUITE(TBsVDiskExtremeHandoffHuge) { +Y_UNIT_TEST_SUITE(TBsVDiskExtremeHandoffHuge) { Y_UNIT_TEST_COMP_DISK(SimpleHndPut1SeqGetFresh, TSimpleHnd6Put1SeqGet, TFastVDiskSetupHndOff, false, 7, DB_3PUT2HND_HUGE) // FIXME: turn this test on after implementing handoffs for huge blobs - //Y_UNIT_TEST_COMP_DISK(SimpleHndPut1SeqGetCompaction, TSimpleHnd6Put1SeqGet, TFastVDiskSetupCompactedHndOff, true, 7, DB_3PUT2HND_HUGE) + //Y_UNIT_TEST_COMP_DISK(SimpleHndPut1SeqGetCompaction, TSimpleHnd6Put1SeqGet, TFastVDiskSetupCompactedHndOff, true, 7, DB_3PUT2HND_HUGE) Y_UNIT_TEST_COMP_DISK(SimpleHnd2Put1GetFresh, TSimpleHnd2Put1Get, TFastVDiskSetupHndOff, false, 7, DB_1PUT2HND_HUGE) - Y_UNIT_TEST_COMP_DISK(SimpleHnd2Put1GetCompaction, TSimpleHnd2Put1Get, TFastVDiskSetupCompactedHndOff, true, 7, DB_1PUT2HND_HUGE) + Y_UNIT_TEST_COMP_DISK(SimpleHnd2Put1GetCompaction, TSimpleHnd2Put1Get, TFastVDiskSetupCompactedHndOff, true, 7, DB_1PUT2HND_HUGE) } /////////////////////////////////////////////////////////////////////////////////////////////////////// // RANGE BS /////////////////////////////////////////////////////////////////////////////////////////////////////// -Y_UNIT_TEST_SUITE(TBsVDiskRange) { +Y_UNIT_TEST_SUITE(TBsVDiskRange) { - Y_UNIT_TEST(RangeGetFromEmptyDB) { + Y_UNIT_TEST(RangeGetFromEmptyDB) { TRangeGetFromEmptyDB test; TestRun<TRangeGetFromEmptyDB, TFastVDiskSetup>(&test, TIMEOUT); } - Y_UNIT_TEST_COMP_DISK(Simple3PutRangeGetAllForwardFresh, TSimple3PutRangeGetAllForward, + Y_UNIT_TEST_COMP_DISK(Simple3PutRangeGetAllForwardFresh, TSimple3PutRangeGetAllForward, TFastVDiskSetup, false, 0, DG_3PUT) - Y_UNIT_TEST_COMP_DISK(Simple3PutRangeGetAllForwardCompaction, TSimple3PutRangeGetAllForward, + Y_UNIT_TEST_COMP_DISK(Simple3PutRangeGetAllForwardCompaction, TSimple3PutRangeGetAllForward, TFastVDiskSetupCompacted, true, 0, DG_3PUT) - Y_UNIT_TEST_COMP_DISK(Simple3PutRangeGetAllBackwardFresh, TSimple3PutRangeGetAllBackward, + Y_UNIT_TEST_COMP_DISK(Simple3PutRangeGetAllBackwardFresh, TSimple3PutRangeGetAllBackward, TFastVDiskSetup, false, 0, DG_3PUT) - Y_UNIT_TEST_COMP_DISK(Simple3PutRangeGetAllBackwardCompaction, TSimple3PutRangeGetAllBackward, + Y_UNIT_TEST_COMP_DISK(Simple3PutRangeGetAllBackwardCompaction, TSimple3PutRangeGetAllBackward, TFastVDiskSetupCompacted, true, 0, DG_3PUT) - Y_UNIT_TEST_COMP_DISK(Simple3PutRangeGetNothingForwardFresh, TSimple3PutRangeGetNothingForward, + Y_UNIT_TEST_COMP_DISK(Simple3PutRangeGetNothingForwardFresh, TSimple3PutRangeGetNothingForward, TFastVDiskSetup, false, 0, DG_3PUT) - Y_UNIT_TEST_COMP_DISK(Simple3PutRangeGetNothingForwardCompaction, TSimple3PutRangeGetNothingForward, + Y_UNIT_TEST_COMP_DISK(Simple3PutRangeGetNothingForwardCompaction, TSimple3PutRangeGetNothingForward, TFastVDiskSetupCompacted, true, 0, DG_3PUT) - Y_UNIT_TEST_COMP_DISK(Simple3PutRangeGetNothingBackwardFresh, TSimple3PutRangeGetNothingBackward, + Y_UNIT_TEST_COMP_DISK(Simple3PutRangeGetNothingBackwardFresh, TSimple3PutRangeGetNothingBackward, TFastVDiskSetup, false, 0, DG_3PUT) - Y_UNIT_TEST_COMP_DISK(Simple3PutRangeGetNothingBackwardCompaction, TSimple3PutRangeGetNothingBackward, + Y_UNIT_TEST_COMP_DISK(Simple3PutRangeGetNothingBackwardCompaction, TSimple3PutRangeGetNothingBackward, TFastVDiskSetupCompacted, true, 0, DG_3PUT) - Y_UNIT_TEST_COMP_DISK(Simple3PutRangeGetMiddleForwardFresh, TSimple3PutRangeGetMiddleForward, + Y_UNIT_TEST_COMP_DISK(Simple3PutRangeGetMiddleForwardFresh, TSimple3PutRangeGetMiddleForward, TFastVDiskSetup, false, 0, DG_3PUT) - Y_UNIT_TEST_COMP_DISK(Simple3PutRangeGetMiddleForwardCompaction, TSimple3PutRangeGetMiddleForward, + Y_UNIT_TEST_COMP_DISK(Simple3PutRangeGetMiddleForwardCompaction, TSimple3PutRangeGetMiddleForward, TFastVDiskSetupCompacted, true, 0, DG_3PUT) - Y_UNIT_TEST_COMP_DISK(Simple3PutRangeGetMiddleBackwardFresh, TSimple3PutRangeGetMiddleBackward, + Y_UNIT_TEST_COMP_DISK(Simple3PutRangeGetMiddleBackwardFresh, TSimple3PutRangeGetMiddleBackward, TFastVDiskSetup, false, 0, DG_3PUT) - Y_UNIT_TEST_COMP_DISK(Simple3PutRangeGetMiddleBackwardCompaction, TSimple3PutRangeGetMiddleBackward, + Y_UNIT_TEST_COMP_DISK(Simple3PutRangeGetMiddleBackwardCompaction, TSimple3PutRangeGetMiddleBackward, TFastVDiskSetupCompacted, true, 0, DG_3PUT) // FIXME: We need a test when we read from VDisk that got its data from other VDisk during syncing @@ -207,36 +207,36 @@ Y_UNIT_TEST_SUITE(TBsVDiskRange) { /////////////////////////////////////////////////////////////////////////////////////////////////////// // RANGE BS /////////////////////////////////////////////////////////////////////////////////////////////////////// -Y_UNIT_TEST_SUITE(TBsVDiskRangeHuge) { +Y_UNIT_TEST_SUITE(TBsVDiskRangeHuge) { - Y_UNIT_TEST_COMP_DISK(Simple3PutRangeGetAllForwardFresh, TSimple3PutRangeGetAllForward, + Y_UNIT_TEST_COMP_DISK(Simple3PutRangeGetAllForwardFresh, TSimple3PutRangeGetAllForward, TFastVDiskSetup, false, 0, DG_3PUT_HUGE) - Y_UNIT_TEST_COMP_DISK(Simple3PutRangeGetAllForwardCompaction, TSimple3PutRangeGetAllForward, + Y_UNIT_TEST_COMP_DISK(Simple3PutRangeGetAllForwardCompaction, TSimple3PutRangeGetAllForward, TFastVDiskSetupCompacted, true, 0, DG_3PUT_HUGE) - Y_UNIT_TEST_COMP_DISK(Simple3PutRangeGetAllBackwardFresh, TSimple3PutRangeGetAllBackward, + Y_UNIT_TEST_COMP_DISK(Simple3PutRangeGetAllBackwardFresh, TSimple3PutRangeGetAllBackward, TFastVDiskSetup, false, 0, DG_3PUT_HUGE) - Y_UNIT_TEST_COMP_DISK(Simple3PutRangeGetAllBackwardCompaction, TSimple3PutRangeGetAllBackward, + Y_UNIT_TEST_COMP_DISK(Simple3PutRangeGetAllBackwardCompaction, TSimple3PutRangeGetAllBackward, TFastVDiskSetupCompacted, true, 0, DG_3PUT_HUGE) - Y_UNIT_TEST_COMP_DISK(Simple3PutRangeGetNothingForwardFresh, TSimple3PutRangeGetNothingForward, + Y_UNIT_TEST_COMP_DISK(Simple3PutRangeGetNothingForwardFresh, TSimple3PutRangeGetNothingForward, TFastVDiskSetup, false, 0, DG_3PUT_HUGE) - Y_UNIT_TEST_COMP_DISK(Simple3PutRangeGetNothingForwardCompaction, TSimple3PutRangeGetNothingForward, + Y_UNIT_TEST_COMP_DISK(Simple3PutRangeGetNothingForwardCompaction, TSimple3PutRangeGetNothingForward, TFastVDiskSetupCompacted, true, 0, DG_3PUT_HUGE) - Y_UNIT_TEST_COMP_DISK(Simple3PutRangeGetNothingBackwardFresh, TSimple3PutRangeGetNothingBackward, + Y_UNIT_TEST_COMP_DISK(Simple3PutRangeGetNothingBackwardFresh, TSimple3PutRangeGetNothingBackward, TFastVDiskSetup, false, 0, DG_3PUT_HUGE) - Y_UNIT_TEST_COMP_DISK(Simple3PutRangeGetNothingBackwardCompaction, TSimple3PutRangeGetNothingBackward, + Y_UNIT_TEST_COMP_DISK(Simple3PutRangeGetNothingBackwardCompaction, TSimple3PutRangeGetNothingBackward, TFastVDiskSetupCompacted, true, 0, DG_3PUT_HUGE) - Y_UNIT_TEST_COMP_DISK(Simple3PutRangeGetMiddleForwardFresh, TSimple3PutRangeGetMiddleForward, + Y_UNIT_TEST_COMP_DISK(Simple3PutRangeGetMiddleForwardFresh, TSimple3PutRangeGetMiddleForward, TFastVDiskSetup, false, 0, DG_3PUT_HUGE) - Y_UNIT_TEST_COMP_DISK(Simple3PutRangeGetMiddleForwardCompaction, TSimple3PutRangeGetMiddleForward, + Y_UNIT_TEST_COMP_DISK(Simple3PutRangeGetMiddleForwardCompaction, TSimple3PutRangeGetMiddleForward, TFastVDiskSetupCompacted, true, 0, DG_3PUT_HUGE) - Y_UNIT_TEST_COMP_DISK(Simple3PutRangeGetMiddleBackwardFresh, TSimple3PutRangeGetMiddleBackward, + Y_UNIT_TEST_COMP_DISK(Simple3PutRangeGetMiddleBackwardFresh, TSimple3PutRangeGetMiddleBackward, TFastVDiskSetup, false, 0, DG_3PUT_HUGE) - Y_UNIT_TEST_COMP_DISK(Simple3PutRangeGetMiddleBackwardCompaction, TSimple3PutRangeGetMiddleBackward, + Y_UNIT_TEST_COMP_DISK(Simple3PutRangeGetMiddleBackwardCompaction, TSimple3PutRangeGetMiddleBackward, TFastVDiskSetupCompacted, true, 0, DG_3PUT_HUGE) } @@ -276,7 +276,7 @@ Y_UNIT_TEST_SUITE(TBsVDiskManyPutGetCheckSize) { } Y_UNIT_TEST_SUITE(TBsVDiskManyPutGet) { //// Group - Y_UNIT_TEST(ManyPutGet) { + Y_UNIT_TEST(ManyPutGet) { TManyPutGet test(false, LARGE_MSG_NUM, 100, UNK); TestRun<TManyPutGet, TFastVDiskSetupHndOff>(&test, TDuration::Minutes(100)); } @@ -296,24 +296,24 @@ Y_UNIT_TEST_SUITE(TBsVDiskManyPutGet) { TestRun<TManyMultiPutGet, TFastVDiskSetupHndOff>(&test, TDuration::Minutes(100)); } - Y_UNIT_TEST(ManyPutGetWaitCompaction) { + Y_UNIT_TEST(ManyPutGetWaitCompaction) { TManyPutGet test(true, SMALL_MSG_NUM, 100, UNK); TestRun<TManyPutGet, TFastVDiskSetupHndOff>(&test, TDuration::Minutes(100)); } //// Group - Y_UNIT_TEST(ManyPutRangeGetFreshIndexOnly) { + Y_UNIT_TEST(ManyPutRangeGetFreshIndexOnly) { TManyPutRangeGet test(false, true, MIDDLE_MSG_NUM, 100, UNK); TestRun<TManyPutRangeGet, TFastVDiskSetup>(&test, TDuration::Minutes(100)); } - Y_UNIT_TEST(ManyPutRangeGetCompactionIndexOnly) { + Y_UNIT_TEST(ManyPutRangeGetCompactionIndexOnly) { TManyPutRangeGet test(true, true, MIDDLE_MSG_NUM, 100, UNK); TestRun<TManyPutRangeGet, TFastVDiskSetupCompacted>(&test, TDuration::Minutes(100)); } /// Group (read is mixed, fresh and compacted) - Y_UNIT_TEST(ManyPutRangeGet2ChannelsIndexOnly) { + Y_UNIT_TEST(ManyPutRangeGet2ChannelsIndexOnly) { TManyPutRangeGet2Channels test(false, true, LARGE_MSG_NUM, 100, UNK); TestRun<TManyPutRangeGet2Channels, TFastVDiskSetup>(&test, TDuration::Minutes(100)); } @@ -323,38 +323,38 @@ Y_UNIT_TEST_SUITE(TBsVDiskManyPutGet) { /////////////////////////////////////////////////////////////////////////////////////////////////////// // GC /////////////////////////////////////////////////////////////////////////////////////////////////////// -Y_UNIT_TEST_SUITE(TBsVDiskGC) { - Y_UNIT_TEST(GCPutKeepIntoEmptyDB) { +Y_UNIT_TEST_SUITE(TBsVDiskGC) { + Y_UNIT_TEST(GCPutKeepIntoEmptyDB) { TGCPutKeepIntoEmptyDB test; TestRun<TGCPutKeepIntoEmptyDB, TFastVDiskSetupCompacted>(&test, TIMEOUT); } // FIXME: Fresh??? - Y_UNIT_TEST(GCPutBarrierVDisk0NoSync) { + Y_UNIT_TEST(GCPutBarrierVDisk0NoSync) { TGCPutBarrierVDisk0 test; TestRun<TGCPutBarrierVDisk0, TFastCompactionGCNoSyncVDiskSetup>(&test, TIMEOUT); } - Y_UNIT_TEST(GCPutBarrierSync) { + Y_UNIT_TEST(GCPutBarrierSync) { TGCPutBarrier test; TestRun<TGCPutBarrier, TFastVDiskSetupCompacted>(&test, TIMEOUT); } - Y_UNIT_TEST(GCPutKeepBarrierSync) { + Y_UNIT_TEST(GCPutKeepBarrierSync) { TGCPutKeepBarrier test; TestRun<TGCPutKeepBarrier, TFastVDiskSetupCompacted>(&test, TIMEOUT); } - Y_UNIT_TEST(GCPutManyBarriersNoSync) { + Y_UNIT_TEST(GCPutManyBarriersNoSync) { TGCPutManyBarriers test; TestRun<TGCPutManyBarriers, TFastCompactionGCNoSyncVDiskSetup>(&test, TIMEOUT); } - Y_UNIT_TEST(TGCManyVPutsCompactGCAllTest) { + Y_UNIT_TEST(TGCManyVPutsCompactGCAllTest) { TGCManyVPutsCompactGCAll test; TestRun<TGCManyVPutsCompactGCAll, TFastVDiskSetupCompacted>(&test, TIMEOUT); } - Y_UNIT_TEST(TGCManyVPutsDelTabletTest) { + Y_UNIT_TEST(TGCManyVPutsDelTabletTest) { TGCManyVPutsDelTablet test; TestRun<TGCManyVPutsDelTablet, TFastVDiskSetupCompacted>(&test, TIMEOUT); } @@ -366,8 +366,8 @@ Y_UNIT_TEST_SUITE(TBsVDiskGC) { /////////////////////////////////////////////////////////////////////////////////////////////////////// // OUT OF SPACE /////////////////////////////////////////////////////////////////////////////////////////////////////// -Y_UNIT_TEST_SUITE(TBsVDiskOutOfSpace) { - Y_UNIT_TEST(WriteUntilOrangeZone) { +Y_UNIT_TEST_SUITE(TBsVDiskOutOfSpace) { + Y_UNIT_TEST(WriteUntilOrangeZone) { return; // Test is ignored. FIX: KIKIMR-8019 TWriteUntilOrangeZone test; @@ -376,7 +376,7 @@ Y_UNIT_TEST_SUITE(TBsVDiskOutOfSpace) { TestRun<TWriteUntilOrangeZone, TFastVDiskSetupCompacted>(&test, TIMEOUT, chunkSize, diskSize); } - Y_UNIT_TEST(WriteUntilYellowZone) { + Y_UNIT_TEST(WriteUntilYellowZone) { TWriteUntilYellowZone test; const ui32 chunkSize = 512u << 10u; const ui64 diskSize = 700ull << 20ull; @@ -414,8 +414,8 @@ Y_UNIT_TEST_SUITE(TBsVDiskBrokenPDisk) { /////////////////////////////////////////////////////////////////////////////////////////////////////// // HANDOFF MOVE DEL /////////////////////////////////////////////////////////////////////////////////////////////////////// -Y_UNIT_TEST_SUITE(TBsVDiskHandoffMoveDel) { - Y_UNIT_TEST(HandoffMoveDel) { +Y_UNIT_TEST_SUITE(TBsVDiskHandoffMoveDel) { + Y_UNIT_TEST(HandoffMoveDel) { TTestHandoffMoveDel test; TestRun<TTestHandoffMoveDel, TFastVDiskSetupCompacted>(&test, TIMEOUT); } @@ -424,13 +424,13 @@ Y_UNIT_TEST_SUITE(TBsVDiskHandoffMoveDel) { /////////////////////////////////////////////////////////////////////////////////////////////////////// // Huge /////////////////////////////////////////////////////////////////////////////////////////////////////// -Y_UNIT_TEST_SUITE(TBsHuge) { - Y_UNIT_TEST(Simple) { +Y_UNIT_TEST_SUITE(TBsHuge) { + Y_UNIT_TEST(Simple) { THugeModuleTest test; TestRun<THugeModuleTest, TFastVDiskSetupCompacted>(&test, TIMEOUT); } - Y_UNIT_TEST(SimpleErasureNone) { + Y_UNIT_TEST(SimpleErasureNone) { THugeModuleTest test; TestRun<THugeModuleTest, TFastVDiskSetupCompacted>(&test, TIMEOUT, @@ -445,8 +445,8 @@ Y_UNIT_TEST_SUITE(TBsHuge) { /////////////////////////////////////////////////////////////////////////////////////////////////////// // Local Recovery /////////////////////////////////////////////////////////////////////////////////////////////////////// -Y_UNIT_TEST_SUITE(TBsLocalRecovery) { - Y_UNIT_TEST(StartStopNotEmptyDB) { +Y_UNIT_TEST_SUITE(TBsLocalRecovery) { + Y_UNIT_TEST(StartStopNotEmptyDB) { const ui32 numIterations = NValgrind::PlainOrUnderValgrind(10, 2); TConfiguration Conf; TFastVDiskSetup vdiskSetup; @@ -468,13 +468,13 @@ Y_UNIT_TEST_SUITE(TBsLocalRecovery) { } } - Y_UNIT_TEST(WriteRestartRead) { + Y_UNIT_TEST(WriteRestartRead) { auto vdiskSetup = std::make_shared<TFastVDiskSetup>(); auto settings = TWriteRestartReadSettings::OneSetup(1000, 10, UNK, vdiskSetup); WriteRestartRead(settings, TIMEOUT); } - Y_UNIT_TEST(WriteRestartReadHuge) { + Y_UNIT_TEST(WriteRestartReadHuge) { auto vdiskSetup = std::make_shared<TFastVDiskSetup>(); auto settings = TWriteRestartReadSettings::OneSetup(1000, 65u << 10u, HUGEB, vdiskSetup); WriteRestartRead(settings, TIMEOUT); @@ -526,7 +526,7 @@ Y_UNIT_TEST_SUITE(TBsLocalRecovery) { } */ - Y_UNIT_TEST(ChaoticWriteRestart) { + Y_UNIT_TEST(ChaoticWriteRestart) { auto vdiskSetup = std::make_shared<TFastVDiskSetup>(); TChaoticWriteRestartWriteSettings settings( TWriteRestartReadSettings::OneSetup(100000, 10, UNK, vdiskSetup), @@ -536,7 +536,7 @@ Y_UNIT_TEST_SUITE(TBsLocalRecovery) { ChaoticWriteRestartWrite(settings, TIMEOUT); } - Y_UNIT_TEST(ChaoticWriteRestartHuge) { + Y_UNIT_TEST(ChaoticWriteRestartHuge) { return; // https://st.yandex-team.ru/KIKIMR-5314 auto vdiskSetup = std::make_shared<TFastVDiskSetup>(); TChaoticWriteRestartWriteSettings settings( @@ -547,7 +547,7 @@ Y_UNIT_TEST_SUITE(TBsLocalRecovery) { ChaoticWriteRestartWrite(settings, TIMEOUT); } - Y_UNIT_TEST(ChaoticWriteRestartHugeXXX) { + Y_UNIT_TEST(ChaoticWriteRestartHugeXXX) { auto vdiskSetup = std::make_shared<TFastVDiskSetup>(); TChaoticWriteRestartWriteSettings settings( TWriteRestartReadSettings::OneSetup(300, 65u << 10u, HUGEB, vdiskSetup), @@ -563,7 +563,7 @@ Y_UNIT_TEST_SUITE(TBsLocalRecovery) { /////////////////////////////////////////////////////////////////////////////////////////////////////// Y_UNIT_TEST_SUITE(TBsOther1) { - Y_UNIT_TEST(PoisonPill) { + Y_UNIT_TEST(PoisonPill) { TManyPutRangeGet2Channels test(false, true, LARGE_MSG_NUM, 100, UNK); TConfiguration Conf; TFastVDiskSetup vdiskSetup; @@ -590,7 +590,7 @@ Y_UNIT_TEST_SUITE(TBsOther1) { Conf.Shutdown(); } - Y_UNIT_TEST(ChaoticParallelWrite) { + Y_UNIT_TEST(ChaoticParallelWrite) { auto cls = std::make_shared<TPutHandleClassGenerator>(UNK); NTestSuiteTBsOther1::ChaoticParallelWriteGeneric<TFastVDiskSetup>( 5000, 100, 10, cls, TDuration::Seconds(600), TDuration()); @@ -652,18 +652,18 @@ Y_UNIT_TEST_SUITE(TBsDbStat) { // Sync/Repl /////////////////////////////////////////////////////////////////////////////////////////////////////// Y_UNIT_TEST_SUITE(TBsVDiskRepl1) { - Y_UNIT_TEST(ReplProxyData) { + Y_UNIT_TEST(ReplProxyData) { TTestReplProxyData test; TestRun<TTestReplProxyData, TFastVDiskSetupCompacted>(&test, TIMEOUT); } - Y_UNIT_TEST(ReplProxyKeepBits) { + Y_UNIT_TEST(ReplProxyKeepBits) { TTestReplProxyKeepBits test; TestRun<TTestReplProxyKeepBits, TFastVDiskSetupCompacted>(&test, TIMEOUT); } - Y_UNIT_TEST(ReplEraseDiskRestore) { + Y_UNIT_TEST(ReplEraseDiskRestore) { TSmallCommonDataSet dataSet; ui32 domainsNum = 4u; ui32 disksInDomain = 2u; @@ -686,7 +686,7 @@ Y_UNIT_TEST_SUITE(TBsVDiskRepl1) { } Y_UNIT_TEST_SUITE(TBsVDiskRepl2) { - Y_UNIT_TEST(ReplEraseDiskRestoreWOOneDisk) { + Y_UNIT_TEST(ReplEraseDiskRestoreWOOneDisk) { TSmallCommonDataSet dataSet; ui32 domainsNum = 4u; ui32 disksInDomain = 2u; @@ -710,7 +710,7 @@ Y_UNIT_TEST_SUITE(TBsVDiskRepl2) { } Y_UNIT_TEST_SUITE(TBsVDiskRepl3) { - Y_UNIT_TEST(ReplEraseDiskRestoreMultipart) { + Y_UNIT_TEST(ReplEraseDiskRestoreMultipart) { TSmallCommonDataSet dataSet; ui32 domainsNum = 4u; ui32 disksInDomain = 1u; @@ -731,7 +731,7 @@ Y_UNIT_TEST_SUITE(TBsVDiskRepl3) { UNIT_ASSERT(success2); } - Y_UNIT_TEST(AnubisTest) { + Y_UNIT_TEST(AnubisTest) { // ignored return; @@ -775,7 +775,7 @@ Y_UNIT_TEST_SUITE(TBsVDiskRepl3) { } } - Y_UNIT_TEST(ReplPerf) { + Y_UNIT_TEST(ReplPerf) { const ui64 maxDataSize = 10 << 20; const ui32 maxBlobs = 2000; // FIXME: set up -1 const ui32 minBlobSize = 128; @@ -845,7 +845,7 @@ Y_UNIT_TEST_SUITE(TBsVDiskRepl3) { UNIT_ASSERT(success3); } - Y_UNIT_TEST(SyncLogTest) { + Y_UNIT_TEST(SyncLogTest) { TConfiguration Conf; TNoVDiskSetup vdiskSetup; Conf.Prepare(&vdiskSetup); diff --git a/ydb/core/blobstorage/vdisk/anubis_osiris/blobstorage_anubis_algo_ut.cpp b/ydb/core/blobstorage/vdisk/anubis_osiris/blobstorage_anubis_algo_ut.cpp index 9cbe02a2e96..9d2d3461b53 100644 --- a/ydb/core/blobstorage/vdisk/anubis_osiris/blobstorage_anubis_algo_ut.cpp +++ b/ydb/core/blobstorage/vdisk/anubis_osiris/blobstorage_anubis_algo_ut.cpp @@ -10,7 +10,7 @@ namespace NKikimr { #define STR Cnull - Y_UNIT_TEST_SUITE(TBlobStorageAnubisAlgo) { + Y_UNIT_TEST_SUITE(TBlobStorageAnubisAlgo) { void OutputVector(const TVector<TLogoBlobID> &vec, IOutputStream &str) { str << "{"; @@ -42,7 +42,7 @@ namespace NKikimr { } - Y_UNIT_TEST(Mirror3) { + Y_UNIT_TEST(Mirror3) { TBlobStorageGroupInfo info(TErasureType::ErasureMirror3, 1, 4); TBlobsStatusMngr mngr(&info.GetTopology()); diff --git a/ydb/core/blobstorage/vdisk/anubis_osiris/blobstorage_anubisfinder.h b/ydb/core/blobstorage/vdisk/anubis_osiris/blobstorage_anubisfinder.h index b09fd9d50e8..9f3a6598513 100644 --- a/ydb/core/blobstorage/vdisk/anubis_osiris/blobstorage_anubisfinder.h +++ b/ydb/core/blobstorage/vdisk/anubis_osiris/blobstorage_anubisfinder.h @@ -40,7 +40,7 @@ namespace NKikimr { return Candidates.empty(); } - void Output(IOutputStream &str) const { + void Output(IOutputStream &str) const { str << "{Pos# " << Pos << " Candidates# ["; bool prev = false; for (const auto &x : Candidates) { diff --git a/ydb/core/blobstorage/vdisk/common/align.h b/ydb/core/blobstorage/vdisk/common/align.h index 4039e3c93ba..eb5263e5e53 100644 --- a/ydb/core/blobstorage/vdisk/common/align.h +++ b/ydb/core/blobstorage/vdisk/common/align.h @@ -18,7 +18,7 @@ namespace NKikimr { static inline void AlignUpAppendBlockSize(T &buf, ui32 appendBlockSize) { ui32 bufSize = buf.Size(); ui32 expected = AlignUpAppendBlockSize(bufSize, appendBlockSize); - Y_VERIFY(expected >= bufSize); + Y_VERIFY(expected >= bufSize); ui32 padding = expected - bufSize; struct TZeroPadder { diff --git a/ydb/core/blobstorage/vdisk/common/blobstorage_dblogcutter.cpp b/ydb/core/blobstorage/vdisk/common/blobstorage_dblogcutter.cpp index 5f176b61b75..b11d3ffba61 100644 --- a/ydb/core/blobstorage/vdisk/common/blobstorage_dblogcutter.cpp +++ b/ydb/core/blobstorage/vdisk/common/blobstorage_dblogcutter.cpp @@ -93,7 +93,7 @@ namespace NKikimr { update(ScrubLsnToKeep, ScrubLastTime, "Scrub"); break; default: - Y_FAIL("Unexpected case: %d", msg->Component); + Y_FAIL("Unexpected case: %d", msg->Component); } Process(ctx); @@ -146,7 +146,7 @@ namespace NKikimr { } void Handle(NMon::TEvHttpInfo::TPtr &ev, const TActorContext &ctx) { - Y_VERIFY_DEBUG(ev->Get()->SubRequestId == TDbMon::LogCutterId); + Y_VERIFY_DEBUG(ev->Get()->SubRequestId == TDbMon::LogCutterId); TStringStream str; str << "\n"; diff --git a/ydb/core/blobstorage/vdisk/common/blobstorage_dblogcutter.h b/ydb/core/blobstorage/vdisk/common/blobstorage_dblogcutter.h index b98c5061259..1ccca578b68 100644 --- a/ydb/core/blobstorage/vdisk/common/blobstorage_dblogcutter.h +++ b/ydb/core/blobstorage/vdisk/common/blobstorage_dblogcutter.h @@ -31,7 +31,7 @@ namespace NKikimr { , LastKeepLsn(lastKeepLsn) , GenerationTime(TAppData::TimeProvider->Now()) { - Y_VERIFY_DEBUG(Start <= component && component < Max); + Y_VERIFY_DEBUG(Start <= component && component < Max); } }; diff --git a/ydb/core/blobstorage/vdisk/common/blobstorage_status.cpp b/ydb/core/blobstorage/vdisk/common/blobstorage_status.cpp index 4d770a40370..656a8597c1c 100644 --- a/ydb/core/blobstorage/vdisk/common/blobstorage_status.cpp +++ b/ydb/core/blobstorage/vdisk/common/blobstorage_status.cpp @@ -62,7 +62,7 @@ namespace NKikimr { } void Handle(TEvLocalStatusResult::TPtr &ev, const TActorContext &ctx) { - Y_VERIFY_DEBUG(Counter > 0); + Y_VERIFY_DEBUG(Counter > 0); --Counter; Result->Record.MergeFrom(ev->Get()->Record); diff --git a/ydb/core/blobstorage/vdisk/common/blobstorage_vdisk_guids.h b/ydb/core/blobstorage/vdisk/common/blobstorage_vdisk_guids.h index ece3e32dfd1..684b3040915 100644 --- a/ydb/core/blobstorage/vdisk/common/blobstorage_vdisk_guids.h +++ b/ydb/core/blobstorage/vdisk/common/blobstorage_vdisk_guids.h @@ -26,7 +26,7 @@ namespace NKikimr { return Guid == g.Guid; } - void Output(IOutputStream &str) const { + void Output(IOutputStream &str) const { str << Guid; } @@ -67,7 +67,7 @@ namespace NKikimr { return Guid == g.Guid; } - void Output(IOutputStream &str) const { + void Output(IOutputStream &str) const { str << Guid; } diff --git a/ydb/core/blobstorage/vdisk/common/circlebuf.h b/ydb/core/blobstorage/vdisk/common/circlebuf.h index ace4a4372d7..4312a2809f5 100644 --- a/ydb/core/blobstorage/vdisk/common/circlebuf.h +++ b/ydb/core/blobstorage/vdisk/common/circlebuf.h @@ -34,7 +34,7 @@ public: } bool operator ==(const TIterator &i) { - Y_VERIFY_DEBUG(Vec == i.Vec); + Y_VERIFY_DEBUG(Vec == i.Vec); return Pos == i.Pos; } diff --git a/ydb/core/blobstorage/vdisk/common/circlebuf_ut.cpp b/ydb/core/blobstorage/vdisk/common/circlebuf_ut.cpp index 2623c6fc640..7a4dfd74641 100644 --- a/ydb/core/blobstorage/vdisk/common/circlebuf_ut.cpp +++ b/ydb/core/blobstorage/vdisk/common/circlebuf_ut.cpp @@ -6,9 +6,9 @@ namespace NKikimr { - Y_UNIT_TEST_SUITE(TCircleBufTest) { + Y_UNIT_TEST_SUITE(TCircleBufTest) { - Y_UNIT_TEST(SimpleTest) { + Y_UNIT_TEST(SimpleTest) { TCircleBuf<int> buf(10); buf.Push(1); buf.Push(2); @@ -48,14 +48,14 @@ namespace NKikimr { } } - Y_UNIT_TEST(EmptyTest) { + Y_UNIT_TEST(EmptyTest) { TCircleBuf<int> buf(10); TCircleBuf<int>::TIterator it = buf.Begin(), e = buf.End(); UNIT_ASSERT(it == e); } - Y_UNIT_TEST(OverflowTest) { + Y_UNIT_TEST(OverflowTest) { TCircleBuf<int> buf(3); buf.Push(1); buf.Push(2); @@ -100,7 +100,7 @@ namespace NKikimr { }; typedef TIntrusivePtr<TStruct> TStructPtr; - Y_UNIT_TEST(PtrTest) { + Y_UNIT_TEST(PtrTest) { TCircleBuf<TStructPtr> buf(3); TStructPtr val1(new TStruct()); buf.Push(val1); diff --git a/ydb/core/blobstorage/vdisk/common/circlebufstream_ut.cpp b/ydb/core/blobstorage/vdisk/common/circlebufstream_ut.cpp index cfb9335a8d3..f5f338b428b 100644 --- a/ydb/core/blobstorage/vdisk/common/circlebufstream_ut.cpp +++ b/ydb/core/blobstorage/vdisk/common/circlebufstream_ut.cpp @@ -5,9 +5,9 @@ #define STR Cnull -Y_UNIT_TEST_SUITE(TCircleBufStringStreamTest) { +Y_UNIT_TEST_SUITE(TCircleBufStringStreamTest) { - Y_UNIT_TEST(TestAligned) { + Y_UNIT_TEST(TestAligned) { TCircleBufStringStream<32> str; UNIT_ASSERT_EQUAL(str.Str(), TString()); // empty string @@ -28,7 +28,7 @@ Y_UNIT_TEST_SUITE(TCircleBufStringStreamTest) { UNIT_ASSERT_EQUAL(str.Str(), CircleBufStringStreamSkipPrefix + hexDigits + hexDigits); } - Y_UNIT_TEST(TestNotAligned) { + Y_UNIT_TEST(TestNotAligned) { TCircleBufStringStream<32> str; UNIT_ASSERT_EQUAL(str.Str(), TString()); // empty string @@ -54,7 +54,7 @@ Y_UNIT_TEST_SUITE(TCircleBufStringStreamTest) { TString("456789ABCDEF__0123456789ABCDEF__")); } - Y_UNIT_TEST(TestOverflow) { + Y_UNIT_TEST(TestOverflow) { TCircleBufStringStream<16> str; UNIT_ASSERT_EQUAL(str.Str(), TString()); // empty string diff --git a/ydb/core/blobstorage/vdisk/common/disk_part.h b/ydb/core/blobstorage/vdisk/common/disk_part.h index f8916ba6ee8..2408c4a46f7 100644 --- a/ydb/core/blobstorage/vdisk/common/disk_part.h +++ b/ydb/core/blobstorage/vdisk/common/disk_part.h @@ -83,23 +83,23 @@ namespace NKikimr { bool Empty() const { bool empty = ChunkIdx == 0; - Y_VERIFY_DEBUG((empty && Offset == 0 && Size == 0) || !empty); + Y_VERIFY_DEBUG((empty && Offset == 0 && Size == 0) || !empty); return empty; } - void Save(IOutputStream *s) const { + void Save(IOutputStream *s) const { ::Save(s, ChunkIdx); ::Save(s, Offset); ::Save(s, Size); } - void Load(IInputStream *s) { + void Load(IInputStream *s) { ::Load(s, ChunkIdx); ::Load(s, Offset); ::Load(s, Size); } - void Serialize(IOutputStream &s) const { + void Serialize(IOutputStream &s) const { s.Write(&ChunkIdx, sizeof(ui32)); s.Write(&Offset, sizeof(ui32)); s.Write(&Size, sizeof(ui32)); @@ -206,7 +206,7 @@ namespace NKikimr { } static bool Check(const TString &data) { - Y_UNUSED(data); + Y_UNUSED(data); return true; } diff --git a/ydb/core/blobstorage/vdisk/common/memusage.h b/ydb/core/blobstorage/vdisk/common/memusage.h index b045c1e3d50..2d12e4ea24c 100644 --- a/ydb/core/blobstorage/vdisk/common/memusage.h +++ b/ydb/core/blobstorage/vdisk/common/memusage.h @@ -105,7 +105,7 @@ namespace NKikimr { , InitialCapacity(Base.GetCapacity()) { #ifndef NDEBUG - Y_VERIFY(InitialCapacity == Base.LastCapacity, "InitialCapacity# %zu Base.LastCapacity# %zu", + Y_VERIFY(InitialCapacity == Base.LastCapacity, "InitialCapacity# %zu Base.LastCapacity# %zu", InitialCapacity, Base.LastCapacity); #endif } @@ -136,7 +136,7 @@ namespace NKikimr { ~TTrackableBase() { size_t capacity = GetCapacity(); #ifndef NDEBUG - Y_VERIFY(capacity == LastCapacity, "capacity# %zu LastCapacity# %zu", capacity, LastCapacity); + Y_VERIFY(capacity == LastCapacity, "capacity# %zu LastCapacity# %zu", capacity, LastCapacity); #endif Consumer.Subtract(capacity); } @@ -437,8 +437,8 @@ namespace NKikimr { WRAP_METHOD(data, const) WRAP_METHOD(compare, const) WRAP_METHOD(equal, const) - WRAP_METHOD(StartsWith, const) - WRAP_METHOD(EndsWith, const) + WRAP_METHOD(StartsWith, const) + WRAP_METHOD(EndsWith, const) WRAP_METHOD(at, const) WRAP_METHOD(operator[], const) WRAP_METHOD(find, const) diff --git a/ydb/core/blobstorage/vdisk/common/memusage_ut.cpp b/ydb/core/blobstorage/vdisk/common/memusage_ut.cpp index 79022e4ab3d..5c2620c50b9 100644 --- a/ydb/core/blobstorage/vdisk/common/memusage_ut.cpp +++ b/ydb/core/blobstorage/vdisk/common/memusage_ut.cpp @@ -3,8 +3,8 @@ using namespace NKikimr; -Y_UNIT_TEST_SUITE(TTrackable) { - Y_UNIT_TEST(TVector) { +Y_UNIT_TEST_SUITE(TTrackable) { + Y_UNIT_TEST(TVector) { NMonitoring::TDynamicCounters::TCounterPtr cntr(new NMonitoring::TCounterForPtr); TMemoryConsumer cons(cntr); NMonitoring::TDynamicCounters::TCounterPtr cntr2(new NMonitoring::TCounterForPtr); @@ -36,7 +36,7 @@ Y_UNIT_TEST_SUITE(TTrackable) { UNIT_ASSERT_EQUAL(*cntr, 0); } - Y_UNIT_TEST(TList) { + Y_UNIT_TEST(TList) { NMonitoring::TDynamicCounters::TCounterPtr cntr(new NMonitoring::TCounterForPtr); TMemoryConsumer cons(cntr); TTrackableList<ui32> list{TMemoryConsumer(cons)}; @@ -44,12 +44,12 @@ Y_UNIT_TEST_SUITE(TTrackable) { UNIT_ASSERT_VALUES_EQUAL(static_cast<size_t>(*cntr), 3 * sizeof(void *)); } - Y_UNIT_TEST(TString) { + Y_UNIT_TEST(TString) { NMonitoring::TDynamicCounters::TCounterPtr cntr(new NMonitoring::TCounterForPtr); TMemoryConsumer cons(cntr); } - Y_UNIT_TEST(TBuffer) { + Y_UNIT_TEST(TBuffer) { NMonitoring::TDynamicCounters::TCounterPtr cntr(new NMonitoring::TCounterForPtr); TMemoryConsumer cons(cntr); } diff --git a/ydb/core/blobstorage/vdisk/common/sublog.h b/ydb/core/blobstorage/vdisk/common/sublog.h index d9d5310682e..1863a8494af 100644 --- a/ydb/core/blobstorage/vdisk/common/sublog.h +++ b/ydb/core/blobstorage/vdisk/common/sublog.h @@ -23,7 +23,7 @@ namespace NKikimr { // Start a new line of the log // USAGE: // Sublog.Log() << "My component got a message " << message << "\n"; - IOutputStream &Log() const { + IOutputStream &Log() const { ++Recs; if (PrefixWithTime) { Out << TAppData::TimeProvider->Now().ToStringLocalUpToSeconds() << " "; @@ -79,7 +79,7 @@ namespace NKikimr { Ctx.Send(Aid, Ev.release()); } - IOutputStream &GetStream() { + IOutputStream &GetStream() { return Ev->Stream; } private: diff --git a/ydb/core/blobstorage/vdisk/common/vdisk_config_ut.cpp b/ydb/core/blobstorage/vdisk/common/vdisk_config_ut.cpp index 941df64a10b..69a87944cfc 100644 --- a/ydb/core/blobstorage/vdisk/common/vdisk_config_ut.cpp +++ b/ydb/core/blobstorage/vdisk/common/vdisk_config_ut.cpp @@ -5,7 +5,7 @@ namespace NKikimr { - Y_UNIT_TEST_SUITE(TVDiskConfigTest) { + Y_UNIT_TEST_SUITE(TVDiskConfigTest) { Y_UNIT_TEST(JustConfig) { @@ -18,7 +18,7 @@ namespace NKikimr { TPDiskCategory::DEVICE_TYPE_ROT, 0x01, kind, 1, {}); } - Y_UNIT_TEST(Basic) { + Y_UNIT_TEST(Basic) { TString prototext = R"___( VDiskKinds { Kind: Test1 @@ -42,7 +42,7 @@ namespace NKikimr { UNIT_ASSERT_VALUES_EQUAL(cfg->FreshReadReadyMode, false); } - Y_UNIT_TEST(RtmrProblem1) { + Y_UNIT_TEST(RtmrProblem1) { TString prototext = R"___( VDiskKinds { Kind: Log @@ -60,7 +60,7 @@ namespace NKikimr { UNIT_ASSERT_VALUES_EQUAL(cfg->FreshUseDreg, true); } - Y_UNIT_TEST(RtmrProblem2) { + Y_UNIT_TEST(RtmrProblem2) { TString prototext = R"___( VDiskKinds { Kind: Log @@ -86,7 +86,7 @@ namespace NKikimr { UNIT_ASSERT_VALUES_EQUAL(cfg->FreshUseDreg, true); } - Y_UNIT_TEST(ThreeLevels) { + Y_UNIT_TEST(ThreeLevels) { TString prototext = R"___( VDiskKinds { Kind: Test1 @@ -118,7 +118,7 @@ namespace NKikimr { UNIT_ASSERT_VALUES_EQUAL(cfgGrand->FreshBufSizeLogoBlobs, 64); } - Y_UNIT_TEST(NoMoneyNoHoney) { + Y_UNIT_TEST(NoMoneyNoHoney) { TString prototext; TAllVDiskKinds kinds(prototext); TIntrusivePtr<TVDiskConfig> cfg; diff --git a/ydb/core/blobstorage/vdisk/common/vdisk_events.h b/ydb/core/blobstorage/vdisk/common/vdisk_events.h index 47fbd959c96..7c27e132427 100644 --- a/ydb/core/blobstorage/vdisk/common/vdisk_events.h +++ b/ydb/core/blobstorage/vdisk/common/vdisk_events.h @@ -295,7 +295,7 @@ namespace NKikimr { , ActorId(ActorIdFromProto(msgQoS.GetSenderActorId())) {} - void Output(IOutputStream &str) const { + void Output(IOutputStream &str) const { str << "{ClientId# " << ClientId << " RecByteSize# " << RecByteSize << " MsgId# " << MsgId @@ -321,8 +321,8 @@ namespace NKikimr { : Ctx(ctx) , Event(std::move(event)) { - Y_VERIFY_DEBUG(Ctx.ExtQueueId != NKikimrBlobStorage::EVDiskQueueId::Unknown); - Y_VERIFY_DEBUG(Ctx.IntQueueId != NKikimrBlobStorage::EVDiskInternalQueueId::IntUnknown); + Y_VERIFY_DEBUG(Ctx.ExtQueueId != NKikimrBlobStorage::EVDiskQueueId::Unknown); + Y_VERIFY_DEBUG(Ctx.IntQueueId != NKikimrBlobStorage::EVDiskInternalQueueId::IntUnknown); } }; @@ -364,11 +364,11 @@ namespace NKikimr { {} virtual ~TEvVResultBase() { - //Y_VERIFY(Finalized); + //Y_VERIFY(Finalized); } virtual void FinalizeAndSend(const TActorContext& /*ctx*/, std::unique_ptr<IEventHandle> ev) { - Y_VERIFY(!Finalized); // call Finalize only once + Y_VERIFY(!Finalized); // call Finalize only once Finalized = true; if (CounterPtr) { @@ -1358,7 +1358,7 @@ namespace NKikimr { size_t size = request.ExtremeQueriesSize(); for (unsigned i = 0; i < size; i++) { const NKikimrBlobStorage::TExtremeQuery &query = request.GetExtremeQueries(i); - Y_VERIFY(request.HasVDiskID()); + Y_VERIFY(request.HasVDiskID()); TLogoBlobID id = LogoBlobIDFromLogoBlobID(query.GetId()); ui64 shift = (query.HasShift() ? query.GetShift() : 0); ui64 *cookie = nullptr; @@ -1752,11 +1752,11 @@ namespace NKikimr { void MakeError(NKikimrProto::EReplyStatus status, const TString& /*errorReason*/, const NKikimrBlobStorage::TEvVBlock &request) { Record.SetStatus(status); - Y_VERIFY(request.HasTabletId()); + Y_VERIFY(request.HasTabletId()); Record.SetTabletId(request.GetTabletId()); - Y_VERIFY(request.HasGeneration()); + Y_VERIFY(request.HasGeneration()); Record.SetGeneration(request.GetGeneration()); - Y_VERIFY(request.HasVDiskID()); + Y_VERIFY(request.HasVDiskID()); TVDiskID vDiskId = VDiskIDFromVDiskID(request.GetVDiskID()); VDiskIDFromVDiskID(vDiskId, Record.MutableVDiskID()); } @@ -2127,10 +2127,10 @@ namespace NKikimr { void MakeError(NKikimrProto::EReplyStatus status, const TString& /*errorReason*/, const NKikimrBlobStorage::TEvVGetBlock &request) { Record.SetStatus(status); - Y_VERIFY(request.HasTabletId()); + Y_VERIFY(request.HasTabletId()); Record.SetTabletId(request.GetTabletId()); // WARNING: Generation is not set! - Y_VERIFY(request.HasVDiskID()); + Y_VERIFY(request.HasVDiskID()); TVDiskID vDiskId = VDiskIDFromVDiskID(request.GetVDiskID()); VDiskIDFromVDiskID(vDiskId, Record.MutableVDiskID()); } @@ -2251,13 +2251,13 @@ namespace NKikimr { void MakeError(NKikimrProto::EReplyStatus status, const TString& /*errorReason*/, const NKikimrBlobStorage::TEvVCollectGarbage &request) { Record.SetStatus(status); - Y_VERIFY(request.HasTabletId()); + Y_VERIFY(request.HasTabletId()); Record.SetTabletId(request.GetTabletId()); - Y_VERIFY(request.HasRecordGeneration()); + Y_VERIFY(request.HasRecordGeneration()); Record.SetRecordGeneration(request.GetRecordGeneration()); - Y_VERIFY(request.HasChannel()); + Y_VERIFY(request.HasChannel()); Record.SetChannel(request.GetChannel()); - Y_VERIFY(request.HasVDiskID()); + Y_VERIFY(request.HasVDiskID()); TVDiskID vDiskId = VDiskIDFromVDiskID(request.GetVDiskID()); VDiskIDFromVDiskID(vDiskId, Record.MutableVDiskID()); } @@ -2564,7 +2564,7 @@ namespace NKikimr { VDiskIDFromVDiskID(vdisk, Record.MutableVDiskID()); } - void Output(IOutputStream &str) const { + void Output(IOutputStream &str) const { auto vd = VDiskIDFromVDiskID(Record.GetVDiskID()); str << "{TEvVSyncGuidResult: Status# " << Record.GetStatus(); str << " VDiskId# " << vd.ToString() << "}"; diff --git a/ydb/core/blobstorage/vdisk/common/vdisk_handle_class.cpp b/ydb/core/blobstorage/vdisk/common/vdisk_handle_class.cpp index c79b4b59bed..93db0af9cc2 100644 --- a/ydb/core/blobstorage/vdisk/common/vdisk_handle_class.cpp +++ b/ydb/core/blobstorage/vdisk/common/vdisk_handle_class.cpp @@ -21,7 +21,7 @@ namespace NKikimr { case NKikimrBlobStorage::UserData: return (hugeBlobSize >= minREALHugeBlobSize ? HugeForeground : Log); default: - Y_FAIL("Unexpected case"); + Y_FAIL("Unexpected case"); } } diff --git a/ydb/core/blobstorage/vdisk/common/vdisk_lsnmngr.h b/ydb/core/blobstorage/vdisk/common/vdisk_lsnmngr.h index dde57d68b2e..bc02ebeac92 100644 --- a/ydb/core/blobstorage/vdisk/common/vdisk_lsnmngr.h +++ b/ydb/core/blobstorage/vdisk/common/vdisk_lsnmngr.h @@ -47,7 +47,7 @@ namespace NKikimr { return static_cast<ui64>(AtomicGet(ConfirmedLsn)); } - void Output(IOutputStream &str) const { + void Output(IOutputStream &str) const { str << "{InFly# ["; TAllocFreeQueue<TLsnSeg>::TIterator it(InFly); it.SeekToFirst(); diff --git a/ydb/core/blobstorage/vdisk/common/vdisk_lsnmngr_ut.cpp b/ydb/core/blobstorage/vdisk/common/vdisk_lsnmngr_ut.cpp index b581b758bcb..b53fd88756d 100644 --- a/ydb/core/blobstorage/vdisk/common/vdisk_lsnmngr_ut.cpp +++ b/ydb/core/blobstorage/vdisk/common/vdisk_lsnmngr_ut.cpp @@ -42,7 +42,7 @@ namespace NKikimr { // Below are some performance tests for Lsn allocation with and without contention - Y_UNIT_TEST_SUITE(TLsnMngrTests) { + Y_UNIT_TEST_SUITE(TLsnMngrTests) { struct TParam { TLsnMngr *Mngr; @@ -60,7 +60,7 @@ namespace NKikimr { return nullptr; } - Y_UNIT_TEST(AllocLsnForLocalUse) { + Y_UNIT_TEST(AllocLsnForLocalUse) { TLsnMngr mngr(0, 0, false); TParam p {&mngr, Its}; auto start = Now(); @@ -69,7 +69,7 @@ namespace NKikimr { STR << "Working time: " << (finish - start) << "\n"; } - Y_UNIT_TEST(AllocLsnForLocalUse2Threads) { + Y_UNIT_TEST(AllocLsnForLocalUse2Threads) { TLsnMngr mngr(0, 0, false); TParam p {&mngr, Its / 2}; auto start = Now(); @@ -83,7 +83,7 @@ namespace NKikimr { STR << "Working time: " << (finish - start) << "\n"; } - Y_UNIT_TEST(AllocLsnForLocalUse10Threads) { + Y_UNIT_TEST(AllocLsnForLocalUse10Threads) { const ui64 threads = 10; TLsnMngr mngr(0, 0, false); TParam p {&mngr, Its / threads}; diff --git a/ydb/core/blobstorage/vdisk/common/vdisk_recoverylogwriter.cpp b/ydb/core/blobstorage/vdisk/common/vdisk_recoverylogwriter.cpp index f0ec9c15e40..a44840fad46 100644 --- a/ydb/core/blobstorage/vdisk/common/vdisk_recoverylogwriter.cpp +++ b/ydb/core/blobstorage/vdisk/common/vdisk_recoverylogwriter.cpp @@ -73,7 +73,7 @@ LWTRACE_USING(BLOBSTORAGE_PROVIDER); , LsnSegmentStart(lsnSegmentStart) , Lsn(lsn) { - Y_VERIFY_DEBUG(lsn >= lsnSegmentStart); + Y_VERIFY_DEBUG(lsn >= lsnSegmentStart); } struct TGreater { @@ -97,7 +97,7 @@ LWTRACE_USING(BLOBSTORAGE_PROVIDER); friend class TActorBootstrapped<TRecoveryLogWriter>; void Bootstrap(const TActorContext &ctx) { - Y_UNUSED(ctx); + Y_UNUSED(ctx); Become(&TThis::StateFunc); } @@ -184,7 +184,7 @@ LWTRACE_USING(BLOBSTORAGE_PROVIDER); } void Handle(TEvBlobStorage::TEvVCompact::TPtr &ev, const TActorContext &ctx) { - Y_UNUSED(ev); + Y_UNUSED(ev); ui64 lsn = CurSentLsn + 1; ctx.Send(SkeletonID, new NPDisk::TEvCutLog(Owner, OwnerRound, lsn, 0, 0, 0, 0)); } diff --git a/ydb/core/blobstorage/vdisk/common/vdisk_syncneighbors.h b/ydb/core/blobstorage/vdisk/common/vdisk_syncneighbors.h index b014da97b04..07315d3cb08 100644 --- a/ydb/core/blobstorage/vdisk/common/vdisk_syncneighbors.h +++ b/ydb/core/blobstorage/vdisk/common/vdisk_syncneighbors.h @@ -340,7 +340,7 @@ namespace NKikimr { } template <class TPrinter> - void OutputHtml(IOutputStream &str, TPrinter &printer, const TString &name, const TString &divClass) const { + void OutputHtml(IOutputStream &str, TPrinter &printer, const TString &name, const TString &divClass) const { str << "\n"; HTML(str) { DIV_CLASS (divClass) { @@ -356,7 +356,7 @@ namespace NKikimr { } template <class TPrinter> - void OutputHtmlTable(IOutputStream &str, TPrinter &printer) const { + void OutputHtmlTable(IOutputStream &str, TPrinter &printer) const { TVector<TConstIterator> its; HTML(str) { TABLE_CLASS ("table table-condensed") { diff --git a/ydb/core/blobstorage/vdisk/common/vdisk_syncneighbors_ut.cpp b/ydb/core/blobstorage/vdisk/common/vdisk_syncneighbors_ut.cpp index e03e6a461c8..c633e727eca 100644 --- a/ydb/core/blobstorage/vdisk/common/vdisk_syncneighbors_ut.cpp +++ b/ydb/core/blobstorage/vdisk/common/vdisk_syncneighbors_ut.cpp @@ -34,7 +34,7 @@ namespace { class TSer { public: - TSer(IOutputStream &str) + TSer(IOutputStream &str) : Str(str) {} @@ -45,12 +45,12 @@ namespace { void Finish() {} private: - IOutputStream &Str; + IOutputStream &Str; }; class TDes { public: - TDes(IInputStream &str) + TDes(IInputStream &str) : Str(str) {} @@ -65,14 +65,14 @@ namespace { } private: - IInputStream &Str; + IInputStream &Str; }; } -Y_UNIT_TEST_SUITE(TBlobStorageSyncNeighborsTest) { +Y_UNIT_TEST_SUITE(TBlobStorageSyncNeighborsTest) { - Y_UNIT_TEST(IterateOverAllDisks) { + Y_UNIT_TEST(IterateOverAllDisks) { const ui32 numDomains = 8; TIntrusivePtr<TBlobStorageGroupInfo> info = CreateTestGroup(numDomains, 2); TVector<TVDiskID> vdisks = GetVDisks(info); @@ -87,7 +87,7 @@ Y_UNIT_TEST_SUITE(TBlobStorageSyncNeighborsTest) { UNIT_ASSERT_VALUES_EQUAL(temp.size(), 0); } - Y_UNIT_TEST(CheckRevLookup) { + Y_UNIT_TEST(CheckRevLookup) { const ui32 numDomains = 8; TIntrusivePtr<TBlobStorageGroupInfo> info = CreateTestGroup(numDomains, 2); TVector<TVDiskID> vdisks = GetVDisks(info); @@ -99,7 +99,7 @@ Y_UNIT_TEST_SUITE(TBlobStorageSyncNeighborsTest) { } } - Y_UNIT_TEST(CheckIsMyDomain) { + Y_UNIT_TEST(CheckIsMyDomain) { const ui32 numDomains = 8; TIntrusivePtr<TBlobStorageGroupInfo> info = CreateTestGroup(numDomains, 2); TVector<TVDiskID> vdisks = GetVDisks(info); @@ -116,7 +116,7 @@ Y_UNIT_TEST_SUITE(TBlobStorageSyncNeighborsTest) { } } - Y_UNIT_TEST(SerDes) { + Y_UNIT_TEST(SerDes) { const ui32 numDomains = 8; TIntrusivePtr<TBlobStorageGroupInfo> info = CreateTestGroup(numDomains, 2); TVector<TVDiskID> vdisks = GetVDisks(info); @@ -142,7 +142,7 @@ Y_UNIT_TEST_SUITE(TBlobStorageSyncNeighborsTest) { } } - Y_UNIT_TEST(CheckVDiskIterators) { + Y_UNIT_TEST(CheckVDiskIterators) { TBlobStorageGroupInfo info(TBlobStorageGroupType::ErasureMirror3dc, 2, 3, 3); const TBlobStorageGroupInfo::TTopology& topo = info.GetTopology(); for (ui32 i = 0; i < topo.GetTotalVDisksNum(); ++i) { @@ -160,7 +160,7 @@ Y_UNIT_TEST_SUITE(TBlobStorageSyncNeighborsTest) { } } - Y_UNIT_TEST(CheckFailDomainsIterators) { + Y_UNIT_TEST(CheckFailDomainsIterators) { TBlobStorageGroupInfo info(TBlobStorageGroupType::ErasureMirror3dc, 2, 3, 3); const TBlobStorageGroupInfo::TTopology& topo = info.GetTopology(); for (ui32 i = 0; i < topo.GetTotalVDisksNum(); ++i) { @@ -187,7 +187,7 @@ Y_UNIT_TEST_SUITE(TBlobStorageSyncNeighborsTest) { } } - Y_UNIT_TEST(CheckVDiskDistance) { + Y_UNIT_TEST(CheckVDiskDistance) { TBlobStorageGroupInfo info(TBlobStorageGroupType::ErasureMirror3dc, 2, 3, 3); const TBlobStorageGroupInfo::TTopology& topo = info.GetTopology(); const TVDiskIdShort& self = topo.GetVDiskId(0); diff --git a/ydb/core/blobstorage/vdisk/handoff/handoff_basic.cpp b/ydb/core/blobstorage/vdisk/handoff/handoff_basic.cpp index da29a8822b2..9d4805e0d69 100644 --- a/ydb/core/blobstorage/vdisk/handoff/handoff_basic.cpp +++ b/ydb/core/blobstorage/vdisk/handoff/handoff_basic.cpp @@ -74,7 +74,7 @@ namespace NKikimr { , Initialized(false) {} - TProxyState::TProxyState(IInputStream &) { + TProxyState::TProxyState(IInputStream &) { Y_FAIL("Not supported"); } @@ -94,10 +94,10 @@ namespace NKikimr { const TLogoBlobID &id, ui64 fullDataSize, TRope&& data) { - Y_VERIFY(Initialized, "Restore(%p): SelfVDiskID# %s TargetVDiskID# %s id# %s", + Y_VERIFY(Initialized, "Restore(%p): SelfVDiskID# %s TargetVDiskID# %s id# %s", this, SelfVDiskID.ToString().data(), TargetVDiskID.ToString().data(), id.ToString().data()); ui32 byteSize = TEvLocalHandoff::ByteSize(data.GetSize()); - Y_VERIFY_DEBUG(byteSize < MaxBytes); + Y_VERIFY_DEBUG(byteSize < MaxBytes); while (true) { ui64 monitor = AtomicGet(Monitor); @@ -121,7 +121,7 @@ namespace NKikimr { } void TProxyState::FreeElement(ui32 byteSize) { - Y_VERIFY_DEBUG(Initialized); + Y_VERIFY_DEBUG(Initialized); bool done = false; while (!done) { ui64 monitor = AtomicGet(Monitor); diff --git a/ydb/core/blobstorage/vdisk/handoff/handoff_map.h b/ydb/core/blobstorage/vdisk/handoff/handoff_map.h index 9e7480f60fe..b767f54a46a 100644 --- a/ydb/core/blobstorage/vdisk/handoff/handoff_map.h +++ b/ydb/core/blobstorage/vdisk/handoff/handoff_map.h @@ -90,9 +90,9 @@ namespace NKikimr { const TActorId ¬ifyID) { // do nothing by default, all work is done in template specialization for logo blobs - Y_UNUSED(ctx); + Y_UNUSED(ctx); Y_UNUSED(levelSnap); - Y_UNUSED(i); + Y_UNUSED(i); NotifyID = notifyID; return ProxyID; } @@ -102,8 +102,8 @@ namespace NKikimr { const TTransformedItem *Transform(const TActorContext &ctx, const TKey &key, const TMemRec *memRec, const TDataMerger *dataMerger, bool keepData) { // do nothing by default, all work is done in template specialization for logo blobs - Y_UNUSED(ctx); - Y_UNUSED(keepData); + Y_UNUSED(ctx); + Y_UNUSED(keepData); Counter++; Y_VERIFY(dataMerger->Empty()); return TrRes.SetRaw(key, memRec, dataMerger); diff --git a/ydb/core/blobstorage/vdisk/handoff/handoff_mon.cpp b/ydb/core/blobstorage/vdisk/handoff/handoff_mon.cpp index 5aa0e92348f..bbb344fadbe 100644 --- a/ydb/core/blobstorage/vdisk/handoff/handoff_mon.cpp +++ b/ydb/core/blobstorage/vdisk/handoff/handoff_mon.cpp @@ -18,7 +18,7 @@ namespace NKikimr { NHandoff::TPrivateProxyStatePtr PrState; TInfo() = default; - TInfo(IInputStream &) { + TInfo(IInputStream &) { Y_FAIL("Not supported"); } TInfo(const NHandoff::TCountersPtr &c, const NHandoff::TPrivateProxyStatePtr &p) @@ -59,7 +59,7 @@ namespace NKikimr { } void Handle(TEvHandoffProxyMonResult::TPtr &ev, const TActorContext &ctx) { - Y_VERIFY_DEBUG(Counter > 0); + Y_VERIFY_DEBUG(Counter > 0); auto d = ev->Get(); Cells[d->VDiskID].Get() = TInfo(d->CountersPtr, d->PrivateProxyStatePtr); @@ -96,7 +96,7 @@ namespace NKikimr { // outputs state in HTML struct TPrinter { - void operator() (IOutputStream &str, TCells::TConstIterator it) { + void operator() (IOutputStream &str, TCells::TConstIterator it) { if (it->Myself) { HTML(str) { PARA_CLASS("text-info") {str << "Self";} @@ -139,7 +139,7 @@ namespace NKikimr { TActiveActors ActiveActors; void Handle(NMon::TEvHttpInfo::TPtr &ev, const TActorContext &ctx) { - Y_VERIFY_DEBUG(ev->Get()->SubRequestId == TDbMon::HandoffMonId); + Y_VERIFY_DEBUG(ev->Get()->SubRequestId == TDbMon::HandoffMonId); auto actor = std::make_unique<THandoffMonRequestActor>(ctx.SelfID, SelfVDisk, Top, ProxiesPtr, ev); auto aid = ctx.Register(actor.release()); ActiveActors.Insert(aid); diff --git a/ydb/core/blobstorage/vdisk/handoff/handoff_proxy.cpp b/ydb/core/blobstorage/vdisk/handoff/handoff_proxy.cpp index 9a2d1676e0e..3f3d8920b78 100644 --- a/ydb/core/blobstorage/vdisk/handoff/handoff_proxy.cpp +++ b/ydb/core/blobstorage/vdisk/handoff/handoff_proxy.cpp @@ -36,7 +36,7 @@ namespace NKikimr { bool WaitQueueIsEmpty() const { bool empty = WaitQueue.Empty(); - Y_VERIFY_DEBUG(empty && State.WaitQueueSize == 0 || !empty && State.WaitQueueSize != 0); + Y_VERIFY_DEBUG(empty && State.WaitQueueSize == 0 || !empty && State.WaitQueueSize != 0); return empty; } @@ -50,7 +50,7 @@ namespace NKikimr { bool InFlightQueueIsEmpty() const { bool empty = InFlightQueue.Empty(); - Y_VERIFY_DEBUG(empty && State.InFlightQueueSize == 0 || !empty && State.InFlightQueueSize != 0); + Y_VERIFY_DEBUG(empty && State.InFlightQueueSize == 0 || !empty && State.InFlightQueueSize != 0); return empty; } @@ -124,7 +124,7 @@ namespace NKikimr { SendQueuedMessagesUntilAllowed(ctx); if (!InFlightQueueIsFull(byteSize)) { - //Y_VERIFY_DEBUG(WaitQueueIsEmpty()); // FIXME: it seems that assert is invalid + //Y_VERIFY_DEBUG(WaitQueueIsEmpty()); // FIXME: it seems that assert is invalid item->Cookie = GenerateCookie(); SendItem(ctx, std::move(item)); Counters.LocalHandoffSendRightAway++; @@ -168,7 +168,7 @@ namespace NKikimr { } void SwitchToGoodState(const TActorContext &ctx) { - Y_UNUSED(ctx); + Y_UNUSED(ctx); if (State.BadnessState != TPrivateProxyState::GOOD) { LOG_NOTICE(ctx, BS_HANDOFF, VDISKP(VDiskLogPrefix, @@ -213,7 +213,7 @@ namespace NKikimr { if (record.GetStatus() == NKikimrProto::OK) { if (State.InFlightQueueSize == 0) { // in flight queue is empty (we have restarted?) - Y_VERIFY_DEBUG(InFlightQueue.Empty()); + Y_VERIFY_DEBUG(InFlightQueue.Empty()); // just ignore this message (update counters and log) LOG_ERROR(ctx, BS_HANDOFF, VDISKP(VDiskLogPrefix, @@ -247,7 +247,7 @@ namespace NKikimr { return; } - Y_FAIL("Unexpected case"); + Y_FAIL("Unexpected case"); } void Handle(TEvents::TEvUndelivered::TPtr& ev, const TActorContext& ctx) { @@ -260,11 +260,11 @@ namespace NKikimr { Counters.ReplyUndelivered++; SwitchToBadState(ctx); } else - Y_FAIL("Unknown undelivered"); + Y_FAIL("Unknown undelivered"); } void HandleWakeup(const TActorContext &ctx) { - Y_UNUSED(ctx); + Y_UNUSED(ctx); State.WakeupCounter--; if (State.BadnessState == TPrivateProxyState::GOOD) { @@ -282,8 +282,8 @@ namespace NKikimr { } void Handle(TEvBlobStorage::TEvVWindowChange::TPtr &ev, const TActorContext &ctx) { - Y_UNUSED(ev); - Y_UNUSED(ctx); + Y_UNUSED(ev); + Y_UNUSED(ctx); // ignore TEvVWindowChange } diff --git a/ydb/core/blobstorage/vdisk/huge/blobstorage_hullhuge.cpp b/ydb/core/blobstorage/vdisk/huge/blobstorage_hullhuge.cpp index 30d2aeece40..64eaea7e3e4 100644 --- a/ydb/core/blobstorage/vdisk/huge/blobstorage_hullhuge.cpp +++ b/ydb/core/blobstorage/vdisk/huge/blobstorage_hullhuge.cpp @@ -171,11 +171,11 @@ namespace NKikimr { void Bootstrap(const TActorContext &ctx) { // prepare write const ui8 partId = Item->LogoBlobId.PartId(); - Y_VERIFY(partId != 0); + Y_VERIFY(partId != 0); const ui32 storedBlobSize = Item->Data.GetSize(); const ui32 writtenSize = AlignUpAppendBlockSize(storedBlobSize, HugeKeeperCtx->PDiskCtx->Dsk->AppendBlockSize); - Y_VERIFY(writtenSize <= HugeSlot.GetSize()); + Y_VERIFY(writtenSize <= HugeSlot.GetSize()); NPDisk::TEvChunkWrite::TPartsPtr partsPtr(new NPDisk::TEvChunkWrite::TRopeAlignedParts(std::move(Item->Data), writtenSize)); ui32 chunkId = HugeSlot.GetChunkId(); @@ -264,7 +264,7 @@ namespace NKikimr { void Handle(NPDisk::TEvChunkReserveResult::TPtr &ev, const TActorContext &ctx) { CHECK_PDISK_RESPONSE(HugeKeeperCtx->VCtx, ev, ctx); - Y_VERIFY(ev->Get()->ChunkIds.size() == 1); + Y_VERIFY(ev->Get()->ChunkIds.size() == 1); ChunkId = ev->Get()->ChunkIds.front(); Lsn = HugeKeeperCtx->LsnMngr->AllocLsnForLocalUse().Point(); @@ -344,7 +344,7 @@ namespace NKikimr { void Bootstrap(const TActorContext &ctx) { // prepare log record - Y_VERIFY_DEBUG(!ChunksToFree.empty()); + Y_VERIFY_DEBUG(!ChunksToFree.empty()); NHuge::TFreeChunkRecoveryLogRec logRec(ChunksToFree); TString data = logRec.Serialize(); @@ -354,7 +354,7 @@ namespace NKikimr { // prepare commit record, i.e. commit reserved chunk NPDisk::TCommitRecord commitRecord; commitRecord.FirstLsnToKeep = 0; - Y_VERIFY_DEBUG(!ChunksToFree.empty()); + Y_VERIFY_DEBUG(!ChunksToFree.empty()); commitRecord.DeleteChunks = ChunksToFree; commitRecord.IsStartingPoint = false; @@ -436,7 +436,7 @@ namespace NKikimr { void Handle(NPDisk::TEvLogResult::TPtr &ev, const TActorContext &ctx) { CHECK_PDISK_RESPONSE(HugeKeeperCtx->VCtx, ev, ctx); - Y_VERIFY(ev->Get()->Results.size() == 1 && ev->Get()->Results.front().Lsn == EntryPointLsn); + Y_VERIFY(ev->Get()->Results.size() == 1 && ev->Get()->Results.front().Lsn == EntryPointLsn); LOG_DEBUG(ctx, BS_HULLHUGE, VDISKP(HugeKeeperCtx->VCtx->VDiskLogPrefix, @@ -565,7 +565,7 @@ namespace NKikimr { return str.Str(); } - void RenderHtml(IOutputStream &str) { + void RenderHtml(IOutputStream &str) { auto boolToString = [] (bool x) { return x ? "true" : "false"; }; str << "WaitQueueSize: " << WaitQueueSize << "<br>"; str << "WaitQueueByteSize: " << WaitQueueByteSize << "<br>"; @@ -795,7 +795,7 @@ namespace NKikimr { checkAndSet(State.Pers->LogPos.BarriersDbSlotDelLsn); break; default: - Y_FAIL("Impossible case"); + Y_FAIL("Impossible case"); } ProcessQueue(ctx); FreeChunks(ctx); @@ -839,7 +839,7 @@ namespace NKikimr { const TDiskPart &hugeBlob = msg->HugeBlob; NHuge::THugeSlot hugeSlot(State.Pers->Heap->ConvertDiskPartToHugeSlot(hugeBlob)); auto nErased = State.Pers->AllocatedSlots.erase(hugeSlot); - Y_VERIFY(nErased == 1); + Y_VERIFY(nErased == 1); // depending on SlotIsUsed... if (msg->SlotIsUsed) { Y_VERIFY_S(State.Pers->LogPos.HugeBlobLoggedLsn < msg->RecLsn, @@ -891,7 +891,7 @@ namespace NKikimr { } void Handle(NMon::TEvHttpInfo::TPtr &ev, const TActorContext &ctx) { - Y_VERIFY_DEBUG(ev->Get()->SubRequestId == TDbMon::HugeKeeperId); + Y_VERIFY_DEBUG(ev->Get()->SubRequestId == TDbMon::HugeKeeperId); TStringStream str; HTML(str) { DIV_CLASS("panel panel-default") { diff --git a/ydb/core/blobstorage/vdisk/huge/blobstorage_hullhuge_ut.cpp b/ydb/core/blobstorage/vdisk/huge/blobstorage_hullhuge_ut.cpp index ed64a07678e..61c833631b9 100644 --- a/ydb/core/blobstorage/vdisk/huge/blobstorage_hullhuge_ut.cpp +++ b/ydb/core/blobstorage/vdisk/huge/blobstorage_hullhuge_ut.cpp @@ -1,9 +1,9 @@ #include "blobstorage_hullhuge.h" #include <library/cpp/testing/unittest/registar.h> -#include <util/stream/null.h> - +#include <util/stream/null.h> + // change to Cerr if you want logging #define STR Cnull @@ -12,9 +12,9 @@ namespace NKikimr { using namespace NHuge; - Y_UNIT_TEST_SUITE(TBlobStorageHullHugeKeeperPersState) { + Y_UNIT_TEST_SUITE(TBlobStorageHullHugeKeeperPersState) { - Y_UNIT_TEST(SerializeParse) { + Y_UNIT_TEST(SerializeParse) { ui32 chunkSize = 134274560u; ui32 appendBlockSize = 56896u; ui32 minHugeBlobInBytes = 512u << 10u; diff --git a/ydb/core/blobstorage/vdisk/huge/blobstorage_hullhugedefs.cpp b/ydb/core/blobstorage/vdisk/huge/blobstorage_hullhugedefs.cpp index 03c05488f61..dc131a590f2 100644 --- a/ydb/core/blobstorage/vdisk/huge/blobstorage_hullhugedefs.cpp +++ b/ydb/core/blobstorage/vdisk/huge/blobstorage_hullhugedefs.cpp @@ -114,7 +114,7 @@ namespace NKikimr { LogoBlobIDFromLogoBlobID(LogoBlobID, &proto); TString lbSerialized; bool res = proto.SerializeToString(&lbSerialized); - Y_VERIFY(res); + Y_VERIFY(res); ui16 lbSerializedSize = lbSerialized.size(); str.Write(&lbSerializedSize, sizeof(ui16)); str.Write(lbSerialized.data(), lbSerializedSize); diff --git a/ydb/core/blobstorage/vdisk/huge/blobstorage_hullhugedefs.h b/ydb/core/blobstorage/vdisk/huge/blobstorage_hullhugedefs.h index 9bb8e64c080..bd05bcfa346 100644 --- a/ydb/core/blobstorage/vdisk/huge/blobstorage_hullhugedefs.h +++ b/ydb/core/blobstorage/vdisk/huge/blobstorage_hullhugedefs.h @@ -136,7 +136,7 @@ namespace NKikimr { return x; } - void Serialize(IOutputStream &str) const { + void Serialize(IOutputStream &str) const { str.Write(&ChunkId, sizeof(ui32)); str.Write(&Offset, sizeof(ui32)); str.Write(&Size, sizeof(ui32)); @@ -261,7 +261,7 @@ namespace NKikimr { } TBlobType::EType GetBlobType() const { - Y_VERIFY(!Empty()); + Y_VERIFY(!Empty()); return DiskPtrs.size() == 1 ? TBlobType::HugeBlob : TBlobType::ManyHugeBlobs; } @@ -342,12 +342,12 @@ namespace NKikimr { ++locIt; ++it; } else if (Parts.Get(i)) { - Y_VERIFY_DEBUG(locIt != locEnd); + Y_VERIFY_DEBUG(locIt != locEnd); newDiskPtrs.push_back(*locIt); newCircaLsns.push_back(CircaLsns[locIt - locBegin]); ++locIt; } else if (parts.Get(i)) { - Y_VERIFY_DEBUG(it != end); + Y_VERIFY_DEBUG(it != end); newDiskPtrs.push_back(*it); newCircaLsns.push_back(circaLsn); ++it; diff --git a/ydb/core/blobstorage/vdisk/huge/blobstorage_hullhugeheap.cpp b/ydb/core/blobstorage/vdisk/huge/blobstorage_hullhugeheap.cpp index e60200de987..bed9ad91b46 100644 --- a/ydb/core/blobstorage/vdisk/huge/blobstorage_hullhugeheap.cpp +++ b/ydb/core/blobstorage/vdisk/huge/blobstorage_hullhugeheap.cpp @@ -286,7 +286,7 @@ namespace NKikimr { return str.Str(); } - void TChain::RenderHtml(IOutputStream &str) const { + void TChain::RenderHtml(IOutputStream &str) const { auto output = [&str] (const TFreeSpace &c) { for (const auto &x : c) { size_t freeSlots = 0; @@ -375,7 +375,7 @@ namespace NKikimr { ChainPtr->GetOwnedChunks(chunks); } - void TChainDelegator::RenderHtml(IOutputStream &str) const { + void TChainDelegator::RenderHtml(IOutputStream &str) const { HTML(str) { TABLER() { TABLED() {str << SlotSize << " / " << SlotsInChunk;} @@ -384,7 +384,7 @@ namespace NKikimr { } } - void TChainDelegator::RenderHtmlForUsage(IOutputStream &str) const { + void TChainDelegator::RenderHtmlForUsage(IOutputStream &str) const { HTML(str) { TABLER() { TABLED() {str << SlotSize;} @@ -559,7 +559,7 @@ namespace NKikimr { return str.Str(); } - void TAllChains::RenderHtml(IOutputStream &str) const { + void TAllChains::RenderHtml(IOutputStream &str) const { HTML(str) { TABLE_CLASS ("table table-condensed") { TABLEHEAD() { @@ -576,7 +576,7 @@ namespace NKikimr { } } - void TAllChains::RenderHtmlForUsage(IOutputStream &str) const { + void TAllChains::RenderHtmlForUsage(IOutputStream &str) const { HTML(str) { TABLE_CLASS ("table table-condensed") { TABLEHEAD() { @@ -852,7 +852,7 @@ namespace NKikimr { ////////////////////////////////////////////////////////////////////////////////////////// // THeap: Output ////////////////////////////////////////////////////////////////////////////////////////// - void THeap::RenderHtml(IOutputStream &str) const { + void THeap::RenderHtml(IOutputStream &str) const { str << "\n"; HTML(str) { COLLAPSED_BUTTON_CONTENT("hugeheapusageid", "Heap Usage") { diff --git a/ydb/core/blobstorage/vdisk/huge/blobstorage_hullhugeheap.h b/ydb/core/blobstorage/vdisk/huge/blobstorage_hullhugeheap.h index 651117f2b94..87875a1dfbb 100644 --- a/ydb/core/blobstorage/vdisk/huge/blobstorage_hullhugeheap.h +++ b/ydb/core/blobstorage/vdisk/huge/blobstorage_hullhugeheap.h @@ -128,7 +128,7 @@ namespace NKikimr { void Load(IInputStream *s); bool HaveBeenUsed() const; TString ToString() const; - void RenderHtml(IOutputStream &str) const; + void RenderHtml(IOutputStream &str) const; ui32 GetAllocatedSlots() const; void GetOwnedChunks(TSet<TChunkIdx>& chunks) const; }; @@ -162,8 +162,8 @@ namespace NKikimr { bool HaveBeenUsed() const; TString ToString() const; void GetOwnedChunks(TSet<TChunkIdx>& chunks) const; - void RenderHtml(IOutputStream &str) const; - void RenderHtmlForUsage(IOutputStream &str) const; + void RenderHtml(IOutputStream &str) const; + void RenderHtmlForUsage(IOutputStream &str) const; }; @@ -318,10 +318,10 @@ namespace NKikimr { ////////////////////////////////////////////////////////////////////////////////////////// // Output ////////////////////////////////////////////////////////////////////////////////////////// - void RenderHtml(IOutputStream &str) const; + void RenderHtml(IOutputStream &str) const; TString ToString() const; - void PrintOutSearchTable(IOutputStream &str) { + void PrintOutSearchTable(IOutputStream &str) { Chains.PrintOutSearchTable(str); } diff --git a/ydb/core/blobstorage/vdisk/huge/blobstorage_hullhugeheap_ut.cpp b/ydb/core/blobstorage/vdisk/huge/blobstorage_hullhugeheap_ut.cpp index 638269fdfd2..84baa26261d 100644 --- a/ydb/core/blobstorage/vdisk/huge/blobstorage_hullhugeheap_ut.cpp +++ b/ydb/core/blobstorage/vdisk/huge/blobstorage_hullhugeheap_ut.cpp @@ -1,9 +1,9 @@ #include "blobstorage_hullhugeheap.h" #include <library/cpp/testing/unittest/registar.h> -#include <util/stream/null.h> - +#include <util/stream/null.h> + // change to Cerr if you want logging #define STR Cnull @@ -11,9 +11,9 @@ namespace NKikimr { using namespace NHuge; - Y_UNIT_TEST_SUITE(TBlobStorageHullHugeDefs) { + Y_UNIT_TEST_SUITE(TBlobStorageHullHugeDefs) { - Y_UNIT_TEST(FreeRes1) { + Y_UNIT_TEST(FreeRes1) { TMask mask; mask.Set(0, 8); mask.Reset(1); @@ -38,7 +38,7 @@ namespace NKikimr { } - Y_UNIT_TEST_SUITE(TBlobStorageHullHugeChain) { + Y_UNIT_TEST_SUITE(TBlobStorageHullHugeChain) { ///////////////////////////////////////////////////////////////////////////////////////////////////////// void AllocateScenaryOneChunk(TChain &chain, TVector<NPrivate::TChunkSlot> &arr, ui32 slotsInChunk) { @@ -85,15 +85,15 @@ namespace NKikimr { FreeScenaryOneChunk(chain, arr, slotsInChunk); } - Y_UNIT_TEST(HeapAllocSmall) { + Y_UNIT_TEST(HeapAllocSmall) { AllocFreeOneChunk(8); } - Y_UNIT_TEST(HeapAllocLargeStandard) { + Y_UNIT_TEST(HeapAllocLargeStandard) { AllocFreeOneChunk(128); } - Y_UNIT_TEST(HeapAllocLargeNonStandard) { + Y_UNIT_TEST(HeapAllocLargeNonStandard) { AllocFreeOneChunk(143); } @@ -184,11 +184,11 @@ namespace NKikimr { } } - Y_UNIT_TEST(AllocFreeAllocTest) { + Y_UNIT_TEST(AllocFreeAllocTest) { AllocFreeAlloc(8); } - Y_UNIT_TEST(AllocFreeRestartAllocTest) { + Y_UNIT_TEST(AllocFreeRestartAllocTest) { AllocFreeRestartAlloc(8); } } @@ -247,7 +247,7 @@ namespace NKikimr { } } - Y_UNIT_TEST_SUITE(TBlobStorageHullHugeLayout) { + Y_UNIT_TEST_SUITE(TBlobStorageHullHugeLayout) { Y_UNIT_TEST(TestOldAppendBlockSize) { TAllChains all("vdisk", 134274560, 56896, 512 << 10, 512 << 10, 10 << 20, 8, false); @@ -279,9 +279,9 @@ namespace NKikimr { } - Y_UNIT_TEST_SUITE(TBlobStorageHullHugeHeap) { + Y_UNIT_TEST_SUITE(TBlobStorageHullHugeHeap) { - Y_UNIT_TEST(AllocateAllFromOneChunk) { + Y_UNIT_TEST(AllocateAllFromOneChunk) { ui32 chunkSize = 134274560u; ui32 appendBlockSize = 56896u; ui32 minHugeBlobInBytes = 512u << 10u; @@ -348,7 +348,7 @@ namespace NKikimr { UNIT_ASSERT_EQUAL(c1 + c2, 8); } - Y_UNIT_TEST(AllocateAllReleaseAll) { + Y_UNIT_TEST(AllocateAllReleaseAll) { ui32 chunkSize = 134274560u; ui32 appendBlockSize = 56896u; ui32 minHugeBlobInBytes = 512u << 10u; @@ -363,7 +363,7 @@ namespace NKikimr { FreeScenary(heap, arr); } - Y_UNIT_TEST(AllocateAllSerializeDeserializeReleaseAll) { + Y_UNIT_TEST(AllocateAllSerializeDeserializeReleaseAll) { ui32 chunkSize = 134274560u; ui32 appendBlockSize = 56896u; ui32 minHugeBlobInBytes = 512u << 10u; @@ -383,7 +383,7 @@ namespace NKikimr { FreeScenary(newHeap, arr); } - Y_UNIT_TEST(RecoveryMode) { + Y_UNIT_TEST(RecoveryMode) { ui32 chunkSize = 134274560u; ui32 appendBlockSize = 56896u; ui32 minHugeBlobInBytes = 512u << 10u; @@ -412,7 +412,7 @@ namespace NKikimr { heap.RecoveryModeAllocate(TDiskPart(34, 0, 6u << 20u)); } - Y_UNIT_TEST(BorderValues) { + Y_UNIT_TEST(BorderValues) { ui32 chunkSize = 134274560u; ui32 appendBlockSize = 56896u; ui32 minHugeBlobInBytes = 512u << 10u; diff --git a/ydb/core/blobstorage/vdisk/huge/blobstorage_hullhugerecovery.cpp b/ydb/core/blobstorage/vdisk/huge/blobstorage_hullhugerecovery.cpp index 77572ecfb6b..99017c3a950 100644 --- a/ydb/core/blobstorage/vdisk/huge/blobstorage_hullhugerecovery.cpp +++ b/ydb/core/blobstorage/vdisk/huge/blobstorage_hullhugerecovery.cpp @@ -203,7 +203,7 @@ namespace NKikimr { , Guid(TAppData::RandomProvider->GenRand64()) { ParseFromString(entryPointData); - Y_VERIFY(entryPointLsn == LogPos.EntryPointLsn); + Y_VERIFY(entryPointLsn == LogPos.EntryPointLsn); logFunc(VDISKP(VCtx->VDiskLogPrefix, "Recovery started (guid# %" PRIu64 " entryLsn# %" PRIu64 "): State# %s", Guid, entryPointLsn, ToString().data())); @@ -276,7 +276,7 @@ namespace NKikimr { cur += NHuge::THugeSlot::SerializedSize; cur += sizeof(ui64); // refPointLsn (for backward compatibility, can be removed) bool inserted = AllocatedSlots.insert(hugeSlot).second; - Y_VERIFY(inserted); + Y_VERIFY(inserted); } } @@ -348,7 +348,7 @@ namespace NKikimr { return str.Str(); } - void THullHugeKeeperPersState::RenderHtml(IOutputStream &str) const { + void THullHugeKeeperPersState::RenderHtml(IOutputStream &str) const { str << "LogPos: " << LogPos.ToString() << "<br>"; str << "AllocatedSlots:"; if (!AllocatedSlots.empty()) { @@ -482,7 +482,7 @@ namespace NKikimr { logPosDelLsn = &LogPos.BarriersDbSlotDelLsn; break; default: - Y_FAIL("Unexpected case"); + Y_FAIL("Unexpected case"); } if (lsn > *logPosDelLsn) { // apply diff --git a/ydb/core/blobstorage/vdisk/huge/blobstorage_hullhugerecovery.h b/ydb/core/blobstorage/vdisk/huge/blobstorage_hullhugerecovery.h index 7d6bbca7937..b5925dbcc28 100644 --- a/ydb/core/blobstorage/vdisk/huge/blobstorage_hullhugerecovery.h +++ b/ydb/core/blobstorage/vdisk/huge/blobstorage_hullhugerecovery.h @@ -158,7 +158,7 @@ namespace NKikimr { static TString ExtractLogPosition(const TString &data); static bool CheckEntryPoint(const TString &data); TString ToString() const; - void RenderHtml(IOutputStream &str) const; + void RenderHtml(IOutputStream &str) const; ui32 GetMinREALHugeBlobInBytes() const; ui64 FirstLsnToKeep() const; TString FirstLsnToKeepDecomposed() const; diff --git a/ydb/core/blobstorage/vdisk/huge/booltt.h b/ydb/core/blobstorage/vdisk/huge/booltt.h index 13a29604491..72e3b881fb3 100644 --- a/ydb/core/blobstorage/vdisk/huge/booltt.h +++ b/ydb/core/blobstorage/vdisk/huge/booltt.h @@ -41,7 +41,7 @@ public: Y_FAIL("Unexpected case: curValue# %d newValue# %d", int(curValue), int(newValue)); } - void Output(IOutputStream &str) { + void Output(IOutputStream &str) { TContainer c = Top.GetContainer(); // copy, cause we want to sort it auto cmp = [] (const TRec &x, const TRec &y) { return x.Duration > y.Duration; @@ -73,7 +73,7 @@ public: Value = v; } - void Output(const TString &name, IOutputStream &str) { + void Output(const TString &name, IOutputStream &str) { str << name << ": " << (Value ? "true" : "false") << " "; History.Output(str); } diff --git a/ydb/core/blobstorage/vdisk/huge/top.h b/ydb/core/blobstorage/vdisk/huge/top.h index 92de9267814..295046a670a 100644 --- a/ydb/core/blobstorage/vdisk/huge/top.h +++ b/ydb/core/blobstorage/vdisk/huge/top.h @@ -40,7 +40,7 @@ public: return Cont; } - void Output(IOutputStream &str) { + void Output(IOutputStream &str) { bool first = true; for (const auto &x : Cont) { if (!first) { diff --git a/ydb/core/blobstorage/vdisk/huge/top_ut.cpp b/ydb/core/blobstorage/vdisk/huge/top_ut.cpp index b3a45696f67..1e0bdbbe1ad 100644 --- a/ydb/core/blobstorage/vdisk/huge/top_ut.cpp +++ b/ydb/core/blobstorage/vdisk/huge/top_ut.cpp @@ -1,15 +1,15 @@ #include "top.h" #include <library/cpp/testing/unittest/registar.h> -#include <util/stream/null.h> - +#include <util/stream/null.h> + using namespace NKikimr; #define STR Cnull -Y_UNIT_TEST_SUITE(TopTest) { +Y_UNIT_TEST_SUITE(TopTest) { - Y_UNIT_TEST(Test1) { + Y_UNIT_TEST(Test1) { TTop<int, 3> top; top.Push(15); @@ -29,7 +29,7 @@ Y_UNIT_TEST_SUITE(TopTest) { STR << "\n"; } - Y_UNIT_TEST(Test2) { + Y_UNIT_TEST(Test2) { TTop<int, 4> top; top.Push(2); diff --git a/ydb/core/blobstorage/vdisk/hulldb/barriers/hullds_gcessence_defs.h b/ydb/core/blobstorage/vdisk/hulldb/barriers/hullds_gcessence_defs.h index 40132629ced..812682c3161 100644 --- a/ydb/core/blobstorage/vdisk/hulldb/barriers/hullds_gcessence_defs.h +++ b/ydb/core/blobstorage/vdisk/hulldb/barriers/hullds_gcessence_defs.h @@ -49,7 +49,7 @@ namespace NKikimr { return KeepIndex; } - void Output(IOutputStream &str) { + void Output(IOutputStream &str) { str << "[index# " << KeepIndex << " data# " << KeepData << " barrier# " << KeepByBarrier << "]"; } @@ -86,7 +86,7 @@ namespace NKikimr { return std::make_tuple(TabletId, Channel); } - void Output(IOutputStream& str) const { + void Output(IOutputStream& str) const { str << TabletId << ":" << Channel; } @@ -134,7 +134,7 @@ namespace NKikimr { return *this != TBarrier(); } - void Output(IOutputStream& str) const { + void Output(IOutputStream& str) const { str << "Issued:[" << BarrierGen << ":" << BarrierGenCounter << "]" << " -> Collect:[" << CollectGen << ":" << CollectStep << "]"; } diff --git a/ydb/core/blobstorage/vdisk/hulldb/base/blobstorage_blob_ut.cpp b/ydb/core/blobstorage/vdisk/hulldb/base/blobstorage_blob_ut.cpp index 5774a53a39d..4f536930d7e 100644 --- a/ydb/core/blobstorage/vdisk/hulldb/base/blobstorage_blob_ut.cpp +++ b/ydb/core/blobstorage/vdisk/hulldb/base/blobstorage_blob_ut.cpp @@ -11,9 +11,9 @@ namespace NKikimr { const TBlobStorageGroupType GType(TBlobStorageGroupType::ErasureNone); - Y_UNIT_TEST_SUITE(TBlobStorageDiskBlob) { + Y_UNIT_TEST_SUITE(TBlobStorageDiskBlob) { - Y_UNIT_TEST(CreateFromDistinctParts) { + Y_UNIT_TEST(CreateFromDistinctParts) { const ui8 totalParts = MaxTotalPartCount; const ui32 partSize = 6; const ui64 fullDataSize = partSize * totalParts / 2; @@ -54,7 +54,7 @@ namespace NKikimr { } } - Y_UNIT_TEST(CreateIterate) { + Y_UNIT_TEST(CreateIterate) { ui8 partId = 2; TString data("abcdefgh"); TRope buf = TDiskBlob::Create(16, partId, 3, TRope(data), Arena); @@ -67,7 +67,7 @@ namespace NKikimr { } } - Y_UNIT_TEST(Merge) { + Y_UNIT_TEST(Merge) { TString data("abcdefgh"); // blob1 @@ -133,7 +133,7 @@ namespace NKikimr { } } - Y_UNIT_TEST(FilterMask) { + Y_UNIT_TEST(FilterMask) { const ui8 numParts = 6; for (ui32 mask1 = 1; mask1 < (1 << numParts); ++mask1) { for (ui32 mask2 = 1; mask2 < (1 << numParts); ++mask2) { diff --git a/ydb/core/blobstorage/vdisk/hulldb/base/blobstorage_hulldefs.cpp b/ydb/core/blobstorage/vdisk/hulldb/base/blobstorage_hulldefs.cpp index a603cc28c20..961ba149582 100644 --- a/ydb/core/blobstorage/vdisk/hulldb/base/blobstorage_hulldefs.cpp +++ b/ydb/core/blobstorage/vdisk/hulldb/base/blobstorage_hulldefs.cpp @@ -58,7 +58,7 @@ namespace NKikimr { return str.Str(); } - void TPutRecoveryLogRecOpt::Output(IOutputStream &str) const { + void TPutRecoveryLogRecOpt::Output(IOutputStream &str) const { str << "{Id# " << Id << "}"; } diff --git a/ydb/core/blobstorage/vdisk/hulldb/base/blobstorage_hulldefs.h b/ydb/core/blobstorage/vdisk/hulldb/base/blobstorage_hulldefs.h index 4719a39e728..8c7e5a11781 100644 --- a/ydb/core/blobstorage/vdisk/hulldb/base/blobstorage_hulldefs.h +++ b/ydb/core/blobstorage/vdisk/hulldb/base/blobstorage_hulldefs.h @@ -52,7 +52,7 @@ namespace NKikimr { } const TDiskPart &SwearOne() const { - Y_VERIFY_DEBUG(Begin + 1 == End); + Y_VERIFY_DEBUG(Begin + 1 == End); return *Begin; } @@ -190,7 +190,7 @@ namespace NKikimr { static TString Serialize(const TBlobStorageGroupType >ype, const TLogoBlobID &id, const TRope &rope); bool ParseFromString(const TBlobStorageGroupType >ype, const TString &data); TString ToString() const; - void Output(IOutputStream &str) const; + void Output(IOutputStream &str) const; }; } // NKikimr diff --git a/ydb/core/blobstorage/vdisk/hulldb/base/blobstorage_hullsatisfactionrank.cpp b/ydb/core/blobstorage/vdisk/hulldb/base/blobstorage_hullsatisfactionrank.cpp index 74ed554356b..b85b2520c85 100644 --- a/ydb/core/blobstorage/vdisk/hulldb/base/blobstorage_hullsatisfactionrank.cpp +++ b/ydb/core/blobstorage/vdisk/hulldb/base/blobstorage_hullsatisfactionrank.cpp @@ -97,7 +97,7 @@ namespace NKikimr { "response from Yard: msg# %s", res.ToString().data())); } - void TDynamicPDiskWeightsManager::RenderHtml(IOutputStream &str) const { + void TDynamicPDiskWeightsManager::RenderHtml(IOutputStream &str) const { HTML(str) { TABLE_CLASS ("table table-condensed") { TABLEHEAD() { diff --git a/ydb/core/blobstorage/vdisk/hulldb/base/blobstorage_hullsatisfactionrank.h b/ydb/core/blobstorage/vdisk/hulldb/base/blobstorage_hullsatisfactionrank.h index faefa8ac859..9ec199de6b4 100644 --- a/ydb/core/blobstorage/vdisk/hulldb/base/blobstorage_hullsatisfactionrank.h +++ b/ydb/core/blobstorage/vdisk/hulldb/base/blobstorage_hullsatisfactionrank.h @@ -72,7 +72,7 @@ namespace NKikimr { return c2; } - void Output(IOutputStream &str) const { + void Output(IOutputStream &str) const { str << Val; } @@ -145,7 +145,7 @@ namespace NKikimr { return Val / Base; } - void Output(IOutputStream &str) const { + void Output(IOutputStream &str) const { ui64 intPart = Val / Base; ui64 fractPart = Val % Base; @@ -203,7 +203,7 @@ namespace NKikimr { return Changed == s.Changed && Weight == s.Weight; } - void Output(IOutputStream &str) const { + void Output(IOutputStream &str) const { str << "[" << (Changed ? "true" : "false") << ", " << Weight << "]"; } @@ -244,7 +244,7 @@ namespace NKikimr { return CurRank; } - void RenderHtml(IOutputStream &str) const { + void RenderHtml(IOutputStream &str) const { NKikimrWhiteboard::EFlag light; if (CurRank <= YellowThreshold) light = NKikimrWhiteboard::EFlag::Green; @@ -371,7 +371,7 @@ namespace NKikimr { TDynamicPDiskWeightsManager(const TVDiskContextPtr &vctx, const TPDiskCtxPtr &pdiskCtx); void ApplyUpdates(const TActorContext &ctx); void Feedback(const NPDisk::TEvConfigureSchedulerResult &res, const TActorContext &ctx); - void RenderHtml(IOutputStream &str) const; + void RenderHtml(IOutputStream &str) const; void ToWhiteboard(NKikimrWhiteboard::TVDiskSatisfactionRank &v) const; static void DefWhiteboard(NKikimrWhiteboard::TVDiskSatisfactionRank &v); diff --git a/ydb/core/blobstorage/vdisk/hulldb/base/blobstorage_hullsatisfactionrank_ut.cpp b/ydb/core/blobstorage/vdisk/hulldb/base/blobstorage_hullsatisfactionrank_ut.cpp index 2af22dc6f52..0acb40026f7 100644 --- a/ydb/core/blobstorage/vdisk/hulldb/base/blobstorage_hullsatisfactionrank_ut.cpp +++ b/ydb/core/blobstorage/vdisk/hulldb/base/blobstorage_hullsatisfactionrank_ut.cpp @@ -1,18 +1,18 @@ #include "blobstorage_hullsatisfactionrank.h" #include <library/cpp/testing/unittest/registar.h> -#include <util/stream/null.h> - +#include <util/stream/null.h> + #define STR Cnull namespace NKikimr { using namespace NSat; - Y_UNIT_TEST_SUITE(TBlobStorageHullDecimal) { + Y_UNIT_TEST_SUITE(TBlobStorageHullDecimal) { using TDecimal = ::NKikimr::NSat::TDecimal<3>; - Y_UNIT_TEST(TestMkRatio) { + Y_UNIT_TEST(TestMkRatio) { TDecimal d1 = TDecimal::MkRatio(1, 3); STR << d1 << "\n"; UNIT_ASSERT_VALUES_EQUAL(d1.GetRaw(), 333); @@ -26,7 +26,7 @@ namespace NKikimr { UNIT_ASSERT_VALUES_EQUAL(d3.GetRaw(), 3333); } - Y_UNIT_TEST(TestMkDecimal) { + Y_UNIT_TEST(TestMkDecimal) { TDecimal d1 = TDecimal::MkDecimal(1, 400); STR << d1 << "\n"; UNIT_ASSERT_VALUES_EQUAL(d1.GetRaw(), 1400); @@ -38,7 +38,7 @@ namespace NKikimr { UNIT_ASSERT_VALUES_EQUAL((d2 * d3).GetRaw(), 11438); } - Y_UNIT_TEST(TestMult) { + Y_UNIT_TEST(TestMult) { { TDecimal d1 = TDecimal::MkRatio(1, 3); TDecimal d2 = d1 * 5; @@ -62,7 +62,7 @@ namespace NKikimr { } } - Y_UNIT_TEST(TestRoundToInt) { + Y_UNIT_TEST(TestRoundToInt) { // round to 1 { TDecimal d1 = TDecimal::MkRatio(1, 3); @@ -101,7 +101,7 @@ namespace NKikimr { } } - Y_UNIT_TEST(TestToUi64) { + Y_UNIT_TEST(TestToUi64) { // < 100% { TDecimal d1 = TDecimal::MkRatio(1, 3); @@ -122,7 +122,7 @@ namespace NKikimr { } - Y_UNIT_TEST_SUITE(TBlobStorageLinearTrackBar) { + Y_UNIT_TEST_SUITE(TBlobStorageLinearTrackBar) { template <class TTrackBar, class TDecimal> void Update(TTrackBar &tb, TDecimal v, typename TTrackBar::TStatus expectedRes) { @@ -133,7 +133,7 @@ namespace NKikimr { UNIT_ASSERT_VALUES_EQUAL(status, expectedRes); } - Y_UNIT_TEST(TestLinearTrackBarDouble) { + Y_UNIT_TEST(TestLinearTrackBarDouble) { using TDecimal = ::NKikimr::NSat::TDecimalViaDouble; using TTrackBar = TLinearTrackBar<TDecimal>; using TStatus = typename TTrackBar::TStatus; @@ -147,7 +147,7 @@ namespace NKikimr { Update(tb, 0.45, TStatus(true, 2)); } - Y_UNIT_TEST(TestLinearTrackBarWithDecimal) { + Y_UNIT_TEST(TestLinearTrackBarWithDecimal) { using TDecimal = ::NKikimr::NSat::TDecimal<3>; using TTrackBar = TLinearTrackBar<TDecimal>; using TStatus = typename TTrackBar::TStatus; diff --git a/ydb/core/blobstorage/vdisk/hulldb/base/blobstorage_hullstorageratio.h b/ydb/core/blobstorage/vdisk/hulldb/base/blobstorage_hullstorageratio.h index 5d8f3fa51d1..f0b1c45840c 100644 --- a/ydb/core/blobstorage/vdisk/hulldb/base/blobstorage_hullstorageratio.h +++ b/ydb/core/blobstorage/vdisk/hulldb/base/blobstorage_hullstorageratio.h @@ -56,7 +56,7 @@ namespace NKikimr { return IndexItemsKeep == 0; } - void Output(IOutputStream &str) const { + void Output(IOutputStream &str) const { str << "{IndexItemsTotal: " << IndexItemsTotal << " IndexItemsKeep: " << IndexItemsKeep << " IndexBytesTotal: " << IndexBytesTotal diff --git a/ydb/core/blobstorage/vdisk/hulldb/base/blobstorage_hullstorageratio_ut.cpp b/ydb/core/blobstorage/vdisk/hulldb/base/blobstorage_hullstorageratio_ut.cpp index 8c5ce32eb5c..d82ebabcc4c 100644 --- a/ydb/core/blobstorage/vdisk/hulldb/base/blobstorage_hullstorageratio_ut.cpp +++ b/ydb/core/blobstorage/vdisk/hulldb/base/blobstorage_hullstorageratio_ut.cpp @@ -1,17 +1,17 @@ #include "blobstorage_hullstorageratio.h" #include <library/cpp/testing/unittest/registar.h> -#include <util/stream/null.h> - +#include <util/stream/null.h> + namespace NKikimr { #define STR Cnull using namespace NHullComp; - Y_UNIT_TEST_SUITE(TBlobStorageHullStorageRatio) { + Y_UNIT_TEST_SUITE(TBlobStorageHullStorageRatio) { - Y_UNIT_TEST(Test) { + Y_UNIT_TEST(Test) { TSstRatio Ratio; // item diff --git a/ydb/core/blobstorage/vdisk/hulldb/base/hullbase_barrier.h b/ydb/core/blobstorage/vdisk/hulldb/base/hullbase_barrier.h index 4afce21c055..75dcc481887 100644 --- a/ydb/core/blobstorage/vdisk/hulldb/base/hullbase_barrier.h +++ b/ydb/core/blobstorage/vdisk/hulldb/base/hullbase_barrier.h @@ -138,7 +138,7 @@ namespace NKikimr { {} void Merge(const TMemRecBarrier& rec, const TKeyBarrier& key) { - Y_VERIFY(CollectGen == rec.CollectGen && CollectStep == rec.CollectStep, + Y_VERIFY(CollectGen == rec.CollectGen && CollectStep == rec.CollectStep, "Barriers MUST be equal; CollectGen# %" PRIu32 " CollectStep# %" PRIu32 " rec.CollectGen# %" PRIu32 " rec.CollectStep %" PRIu32 " key# %s", CollectGen, CollectStep, rec.CollectGen, rec.CollectStep, @@ -155,28 +155,28 @@ namespace NKikimr { } void SetDiskBlob(const TDiskPart &dataAddr) { - Y_UNUSED(dataAddr); + Y_UNUSED(dataAddr); // nothing to do } void SetHugeBlob(const TDiskPart &) { - Y_FAIL("Must not be called"); + Y_FAIL("Must not be called"); } void SetManyHugeBlobs(ui32, ui32, ui32) { - Y_FAIL("Must not be called"); + Y_FAIL("Must not be called"); } void SetMemBlob(ui64, ui32) { - Y_FAIL("Must not be called"); + Y_FAIL("Must not be called"); } void SetNoBlob() { } void SetType(TBlobType::EType t) { - Y_VERIFY_DEBUG(t == TBlobType::DiskBlob); - Y_UNUSED(t); + Y_VERIFY_DEBUG(t == TBlobType::DiskBlob); + Y_UNUSED(t); } TDiskDataExtractor *GetDiskData(TDiskDataExtractor *extr, const TDiskPart *) const { @@ -185,7 +185,7 @@ namespace NKikimr { } TMemPart GetMemData() const { - Y_FAIL("Must not be called"); + Y_FAIL("Must not be called"); } NMatrix::TVectorType GetLocalParts(TBlobStorageGroupType) const { @@ -200,7 +200,7 @@ namespace NKikimr { } TString ToString(const TIngressCache *cache, const TDiskPart *outbound = nullptr) const { - Y_UNUSED(outbound); + Y_UNUSED(outbound); return Sprintf("{CollectGen: %" PRIu32 " CollectStep: %" PRIu32 " Ingress: %s}", CollectGen, CollectStep, Ingress.ToString(cache).data()); diff --git a/ydb/core/blobstorage/vdisk/hulldb/base/hullbase_barrier_ut.cpp b/ydb/core/blobstorage/vdisk/hulldb/base/hullbase_barrier_ut.cpp index 644c9290a86..97b3e0410d9 100644 --- a/ydb/core/blobstorage/vdisk/hulldb/base/hullbase_barrier_ut.cpp +++ b/ydb/core/blobstorage/vdisk/hulldb/base/hullbase_barrier_ut.cpp @@ -3,9 +3,9 @@ namespace NKikimr { - Y_UNIT_TEST_SUITE(TBlobStorageKeyBarrierTest) { + Y_UNIT_TEST_SUITE(TBlobStorageKeyBarrierTest) { - Y_UNIT_TEST(ParseTest) { + Y_UNIT_TEST(ParseTest) { TKeyBarrier id; TKeyBarrier expected; TString explanation; diff --git a/ydb/core/blobstorage/vdisk/hulldb/base/hullbase_block.h b/ydb/core/blobstorage/vdisk/hulldb/base/hullbase_block.h index 72e38257f2a..e567cac5de6 100644 --- a/ydb/core/blobstorage/vdisk/hulldb/base/hullbase_block.h +++ b/ydb/core/blobstorage/vdisk/hulldb/base/hullbase_block.h @@ -104,28 +104,28 @@ namespace NKikimr { } void SetDiskBlob(const TDiskPart &dataAddr) { - Y_UNUSED(dataAddr); + Y_UNUSED(dataAddr); // nothing to do } void SetHugeBlob(const TDiskPart &) { - Y_FAIL("Must not be called"); + Y_FAIL("Must not be called"); } void SetManyHugeBlobs(ui32, ui32, ui32) { - Y_FAIL("Must not be called"); + Y_FAIL("Must not be called"); } void SetMemBlob(ui64, ui32) { - Y_FAIL("Must not be called"); + Y_FAIL("Must not be called"); } void SetNoBlob() { } void SetType(TBlobType::EType t) { - Y_VERIFY_DEBUG(t == TBlobType::DiskBlob); - Y_UNUSED(t); + Y_VERIFY_DEBUG(t == TBlobType::DiskBlob); + Y_UNUSED(t); } TDiskDataExtractor *GetDiskData(TDiskDataExtractor *extr, const TDiskPart *) const { @@ -134,7 +134,7 @@ namespace NKikimr { } TMemPart GetMemData() const { - Y_FAIL("Must not be called"); + Y_FAIL("Must not be called"); } NMatrix::TVectorType GetLocalParts(TBlobStorageGroupType) const { @@ -149,8 +149,8 @@ namespace NKikimr { } TString ToString(const TIngressCache *cache, const TDiskPart *outbound = nullptr) const { - Y_UNUSED(cache); - Y_UNUSED(outbound); + Y_UNUSED(cache); + Y_UNUSED(outbound); return Sprintf("{BlockedGen: %" PRIu32 "}", BlockedGeneration); } }; diff --git a/ydb/core/blobstorage/vdisk/hulldb/base/hullbase_logoblob.h b/ydb/core/blobstorage/vdisk/hulldb/base/hullbase_logoblob.h index 95d32d80f4c..8a83ec1d22b 100644 --- a/ydb/core/blobstorage/vdisk/hulldb/base/hullbase_logoblob.h +++ b/ydb/core/blobstorage/vdisk/hulldb/base/hullbase_logoblob.h @@ -167,7 +167,7 @@ namespace NKikimr { } void SetType(TBlobType::EType t) { - Y_VERIFY_DEBUG(t == TBlobType::DiskBlob || t == TBlobType::HugeBlob || t == TBlobType::ManyHugeBlobs); + Y_VERIFY_DEBUG(t == TBlobType::DiskBlob || t == TBlobType::HugeBlob || t == TBlobType::ManyHugeBlobs); Type = t; } @@ -176,7 +176,7 @@ namespace NKikimr { if (t == TBlobType::DiskBlob || t == TBlobType::HugeBlob) { extr->Set(t, TDiskPart(Id, Offset, Size)); } else { - Y_VERIFY(t == TBlobType::ManyHugeBlobs && outbound); + Y_VERIFY(t == TBlobType::ManyHugeBlobs && outbound); const TDiskPart *begin = &(outbound[Id]); extr->Set(TBlobType::ManyHugeBlobs, begin, begin + Offset); } @@ -184,7 +184,7 @@ namespace NKikimr { } TMemPart GetMemData() const { - Y_VERIFY_DEBUG(GetType() == TBlobType::MemBlob); + Y_VERIFY_DEBUG(GetType() == TBlobType::MemBlob); return TMemPart(ui64(Id) << 32 | Offset, Size); } @@ -205,7 +205,7 @@ namespace NKikimr { } TString ToString(const TIngressCache *cache, const TDiskPart *outbound) const { - Y_UNUSED(cache); + Y_UNUSED(cache); TStringStream str; TBlobType::EType t = GetType(); str << "{" << TBlobType::TypeToStr(t) << " " << CollectMode2String(Ingress.GetCollectMode( diff --git a/ydb/core/blobstorage/vdisk/hulldb/base/hullds_generic_it.h b/ydb/core/blobstorage/vdisk/hulldb/base/hullds_generic_it.h index 204aaec7e7b..5a6993ee2c2 100644 --- a/ydb/core/blobstorage/vdisk/hulldb/base/hullds_generic_it.h +++ b/ydb/core/blobstorage/vdisk/hulldb/base/hullds_generic_it.h @@ -40,7 +40,7 @@ namespace NKikimr { } void Next() { - Y_VERIFY_DEBUG(Valid()); + Y_VERIFY_DEBUG(Valid()); if (!Iter1.Valid()) { Iter2.Next(); @@ -79,7 +79,7 @@ namespace NKikimr { Iter2.SeekToFirst(); } - void DumpAll(IOutputStream &str) const { + void DumpAll(IOutputStream &str) const { Iter1.DumpAll(str); Iter2.DumpAll(str); } @@ -125,7 +125,7 @@ namespace NKikimr { } void Prev() { - Y_VERIFY_DEBUG(Valid()); + Y_VERIFY_DEBUG(Valid()); if (!Iter1.Valid()) { Iter2.Prev(); diff --git a/ydb/core/blobstorage/vdisk/hulldb/blobstorage_hullgcmap.h b/ydb/core/blobstorage/vdisk/hulldb/blobstorage_hullgcmap.h index 5161a503f7b..ab810981f09 100644 --- a/ydb/core/blobstorage/vdisk/hulldb/blobstorage_hullgcmap.h +++ b/ydb/core/blobstorage/vdisk/hulldb/blobstorage_hullgcmap.h @@ -75,11 +75,11 @@ namespace NKikimr { : GcMap(gcMap) , Pos(0) { - Y_VERIFY_DEBUG(GcMap); + Y_VERIFY_DEBUG(GcMap); } void Next() { - Y_VERIFY_DEBUG(Valid()); + Y_VERIFY_DEBUG(Valid()); Pos++; } @@ -88,14 +88,14 @@ namespace NKikimr { } bool KeepItem() const { - Y_VERIFY_DEBUG(Valid()); + Y_VERIFY_DEBUG(Valid()); bool keepIndex = GcMap->IndexKeepMap.Get(Pos); bool keepData = GcMap->DataKeepMap.Get(Pos); return keepIndex || keepData; } bool KeepData() const { - Y_VERIFY_DEBUG(Valid()); + Y_VERIFY_DEBUG(Valid()); bool keepData = GcMap->DataKeepMap.Get(Pos); return keepData; } @@ -128,15 +128,15 @@ namespace NKikimr { // dbMerger must return max circaLsn for the record with _data_ // we must switch to a special kind of TIndexRecordMerger auto newItem = [] (const TIterator &subsIt, const TIndexRecordMerger &subsMerger) { - Y_UNUSED(subsIt); - Y_UNUSED(subsMerger); + Y_UNUSED(subsIt); + Y_UNUSED(subsMerger); }; auto doMerge = [this, barriersEssence] (const TIterator &subsIt, const TLevelIt &dbIt, const TIndexRecordMerger &subsMerger, const TIndexRecordMerger &dbMerger) { - Y_UNUSED(subsIt); - Y_UNUSED(subsMerger); + Y_UNUSED(subsIt); + Y_UNUSED(subsMerger); bool allowKeepFlags = HullCtx->AllowKeepFlags; NGc::TKeepStatus keep = barriersEssence->Keep(dbIt.GetCurKey(), dbMerger.GetMemRec(), dbMerger.GetMemRecsMerged(), allowKeepFlags); diff --git a/ydb/core/blobstorage/vdisk/hulldb/compstrat/hulldb_compstrat_selector.h b/ydb/core/blobstorage/vdisk/hulldb/compstrat/hulldb_compstrat_selector.h index f269d15b952..7a09e53bc18 100644 --- a/ydb/core/blobstorage/vdisk/hulldb/compstrat/hulldb_compstrat_selector.h +++ b/ydb/core/blobstorage/vdisk/hulldb/compstrat/hulldb_compstrat_selector.h @@ -39,7 +39,7 @@ namespace NKikimr { , Task(task) , Params(params) { - Y_VERIFY_DEBUG(Task); + Y_VERIFY_DEBUG(Task); Task->Clear(); Task->FullCompactionInfo.first = Params.FullCompactionAttrs; } diff --git a/ydb/core/blobstorage/vdisk/hulldb/fresh/fresh_data_ut.cpp b/ydb/core/blobstorage/vdisk/hulldb/fresh/fresh_data_ut.cpp index 061f2b71ed8..825f00a047a 100644 --- a/ydb/core/blobstorage/vdisk/hulldb/fresh/fresh_data_ut.cpp +++ b/ydb/core/blobstorage/vdisk/hulldb/fresh/fresh_data_ut.cpp @@ -5,8 +5,8 @@ #include <ydb/core/blobstorage/vdisk/hulldb/base/hullbase_logoblob.h> #include <library/cpp/testing/unittest/registar.h> -#include <util/stream/null.h> - +#include <util/stream/null.h> + // change to Cerr if you want logging #define STR Cnull @@ -14,7 +14,7 @@ namespace NKikimr { static std::shared_ptr<TRopeArena> Arena = std::make_shared<TRopeArena>(&TRopeArenaBackend::Allocate); - Y_UNIT_TEST_SUITE(TBlobStorageHullFresh) { + Y_UNIT_TEST_SUITE(TBlobStorageHullFresh) { //////////////////////////////////////////////////////////////////////////////////////// // Definitions @@ -96,7 +96,7 @@ namespace NKikimr { //////////////////////////////////////////////////////////////////////////////////////// // Test SimpleForward //////////////////////////////////////////////////////////////////////////////////////// - Y_UNIT_TEST(SimpleForward) { + Y_UNIT_TEST(SimpleForward) { const TFreshData::TFreshDataSnapshot &snapshot = *DsSimple.Snap3; THullCtxPtr hullCtx = TestCtx.GetHullCtx(); TFreshData::TFreshDataSnapshot::TForwardIterator it(hullCtx, &snapshot); @@ -172,23 +172,23 @@ namespace NKikimr { } - Y_UNIT_TEST(SimpleBackwardEnd) { + Y_UNIT_TEST(SimpleBackwardEnd) { SimpleBackwardEnd<TDatasetSimple>(DsSimple); } - Y_UNIT_TEST(SimpleBackWardEnd2Times) { + Y_UNIT_TEST(SimpleBackWardEnd2Times) { SimpleBackwardEnd<TDatasetSimple2Times>(DsSimple2Times); } - Y_UNIT_TEST(SimpleBackwardMiddle) { + Y_UNIT_TEST(SimpleBackwardMiddle) { SimpleBackwardMiddle<TDatasetSimple>(DsSimple); } - Y_UNIT_TEST(SimpleBackWardMiddle2Times) { + Y_UNIT_TEST(SimpleBackWardMiddle2Times) { SimpleBackwardMiddle<TDatasetSimple2Times>(DsSimple2Times); } - Y_UNIT_TEST(SolomonStandCrash) { + Y_UNIT_TEST(SolomonStandCrash) { TFreshDataPtr fresh(new TFreshData(GetLevelIndexSetting(), CreateDefaultTimeProvider(), Arena)); @@ -217,7 +217,7 @@ namespace NKikimr { UNIT_ASSERT_VALUES_EQUAL(it.GetCurKey().ToString(), "[72075186224037891:2:22744:0:0:0:0]"); } - Y_UNIT_TEST(Perf) { + Y_UNIT_TEST(Perf) { TFreshDataPtr fresh(new TFreshData(GetLevelIndexSetting(), CreateDefaultTimeProvider(), Arena)); using TIdxKey = TFreshIndex<TKeyLogoBlob, TMemRecLogoBlob>::TIdxKey; diff --git a/ydb/core/blobstorage/vdisk/hulldb/fresh/fresh_segment_impl.h b/ydb/core/blobstorage/vdisk/hulldb/fresh/fresh_segment_impl.h index 3ebf8e8bea3..1cc0e84aeb3 100644 --- a/ydb/core/blobstorage/vdisk/hulldb/fresh/fresh_segment_impl.h +++ b/ydb/core/blobstorage/vdisk/hulldb/fresh/fresh_segment_impl.h @@ -62,7 +62,7 @@ namespace NKikimr { return str.Str(); } - void DebugPrint(IOutputStream &str) const { + void DebugPrint(IOutputStream &str) const { str << "key=" << Key.ToString() << " lsn=" << Lsn; } }; @@ -345,11 +345,11 @@ namespace NKikimr { // append chunk ids to the vector void FillInChunkIds(TVector<ui32> &vec) const { // fresh doesn't have chunks - Y_UNUSED(vec); + Y_UNUSED(vec); } // dump all data of the segment accessible by this iterator - void DumpAll(IOutputStream &str) const { + void DumpAll(IOutputStream &str) const { str << "=== Fresh (lsn=" << Lsn << ")===\n"; TIterator it(Seg->Index.get()); it.SeekToFirst(); diff --git a/ydb/core/blobstorage/vdisk/hulldb/generic/blobstorage_hulloptlsn.h b/ydb/core/blobstorage/vdisk/hulldb/generic/blobstorage_hulloptlsn.h index bfa5df36289..71c03687286 100644 --- a/ydb/core/blobstorage/vdisk/hulldb/generic/blobstorage_hulloptlsn.h +++ b/ydb/core/blobstorage/vdisk/hulldb/generic/blobstorage_hulloptlsn.h @@ -47,7 +47,7 @@ namespace NKikimr { return Lsn; } - void Output(IOutputStream &out) const { + void Output(IOutputStream &out) const { if (Lsn == NotSetLsn) out << "NotSet"; else diff --git a/ydb/core/blobstorage/vdisk/hulldb/generic/blobstorage_hullrecmerger.h b/ydb/core/blobstorage/vdisk/hulldb/generic/blobstorage_hullrecmerger.h index 76654ea7aa9..c4e9a2194a0 100644 --- a/ydb/core/blobstorage/vdisk/hulldb/generic/blobstorage_hullrecmerger.h +++ b/ydb/core/blobstorage/vdisk/hulldb/generic/blobstorage_hullrecmerger.h @@ -15,7 +15,7 @@ namespace NKikimr { } const TMemRec &GetMemRec() const { - Y_VERIFY_DEBUG(Finished); + Y_VERIFY_DEBUG(Finished); return MemRec; } @@ -93,7 +93,7 @@ namespace NKikimr { } void Finish() { - Y_VERIFY_DEBUG(!Empty()); + Y_VERIFY_DEBUG(!Empty()); Finished = true; } }; @@ -165,7 +165,7 @@ namespace NKikimr { break; } default: - Y_FAIL("Impossible case"); + Y_FAIL("Impossible case"); } VerifyConsistency(memRec, outbound); } @@ -183,7 +183,7 @@ namespace NKikimr { // intentionally do nothing: don't add any data to DataMerger, because we don't need it } } else { - Y_VERIFY(memRec.GetType() == TBlobType::HugeBlob); + Y_VERIFY(memRec.GetType() == TBlobType::HugeBlob); TDiskDataExtractor extr; memRec.GetDiskData(&extr, nullptr); const NMatrix::TVectorType v = memRec.GetLocalParts(GType); @@ -229,7 +229,7 @@ namespace NKikimr { } void Finish() { - Y_VERIFY_DEBUG(!Empty()); + Y_VERIFY_DEBUG(!Empty()); VerifyConsistency(); // in case when we keep data and disk merger contains small blobs, we set up small blob record -- this logic @@ -249,7 +249,7 @@ namespace NKikimr { } const TDataMerger *GetDataMerger() const { - Y_VERIFY_DEBUG(Finished); + Y_VERIFY_DEBUG(Finished); return &DataMerger; } @@ -454,7 +454,7 @@ namespace NKikimr { } void Finish() { - Y_VERIFY_DEBUG(!Empty()); + Y_VERIFY_DEBUG(!Empty()); LastWriteWinsMerger.Finish(Callback); Finished = true; } diff --git a/ydb/core/blobstorage/vdisk/hulldb/generic/blobstorage_hullwritesst.h b/ydb/core/blobstorage/vdisk/hulldb/generic/blobstorage_hullwritesst.h index 930fce08e65..5210a2eb8ed 100644 --- a/ydb/core/blobstorage/vdisk/hulldb/generic/blobstorage_hullwritesst.h +++ b/ydb/core/blobstorage/vdisk/hulldb/generic/blobstorage_hullwritesst.h @@ -23,7 +23,7 @@ namespace NKikimr { case EWriterDataType::Fresh: return data ? vctx->CompDataFresh : vctx->CompIndexFresh; case EWriterDataType::Comp: return data ? vctx->CompData : vctx->CompIndex; case EWriterDataType::Replication: return vctx->Replication; - default: Y_FAIL("incorrect EWriterDataType provided"); + default: Y_FAIL("incorrect EWriterDataType provided"); } } @@ -60,7 +60,7 @@ namespace NKikimr { } void Push(const void *data, size_t len) { - Y_VERIFY(Offset + len <= ChunkSize && !Finished); + Y_VERIFY(Offset + len <= ChunkSize && !Finished); while (len) { if (!HasBuffer) { @@ -83,7 +83,7 @@ namespace NKikimr { } void FinishChunk() { - Y_VERIFY(!Finished); + Y_VERIFY(!Finished); Finished = true; if (Offset == ChunkSize) @@ -195,7 +195,7 @@ namespace NKikimr { } TDiskPart result = ChunkWriter->GetDiskPartForBookmark(); static const char padding[3] = {0, 0, 0}; - Y_VERIFY_DEBUG(alignedLen - len <= 3); + Y_VERIFY_DEBUG(alignedLen - len <= 3); ChunkWriter->Push(padding, alignedLen - len); return result; @@ -352,14 +352,14 @@ namespace NKikimr { // there is no space to fit in current chunk -- restart base writer with new chunk TBase::FinishChunk(); result = TBase::AppendAligned(buffer); - Y_VERIFY(result); + Y_VERIFY(result); } return *result; } TDataWriterConclusion Finish() { - Y_VERIFY(!Finished); + Y_VERIFY(!Finished); const ui32 alignedOffset = AlignUpAppendBlockSize(Offset, AppendBlockSize); if (const size_t num = alignedOffset - Offset) { char *buffer = (char*)alloca(num); @@ -516,7 +516,7 @@ namespace NKikimr { } case TBlobType::HugeBlob: { const TVector<TDiskPart> &saved = dataMerger->GetHugeBlobMerger().SavedData(); - Y_VERIFY(saved.size() == 1); + Y_VERIFY(saved.size() == 1); TMemRec memRecTmp(memRec); memRecTmp.SetHugeBlob(saved.at(0)); @@ -529,7 +529,7 @@ namespace NKikimr { auto beg = dataMerger->GetHugeBlobMerger().SavedData().begin(); auto end = dataMerger->GetHugeBlobMerger().SavedData().end(); - Y_VERIFY_DEBUG(beg + 1 < end); + Y_VERIFY_DEBUG(beg + 1 < end); TMemRec newMemRec(memRec); ui32 idx = ui32(Outbound.size()); ui32 num = ui32(end - beg); @@ -547,7 +547,7 @@ namespace NKikimr { ItemsWithHugeData++; break; } - default: Y_FAIL("Impossible case"); + default: Y_FAIL("Impossible case"); } ++Items; @@ -714,7 +714,7 @@ namespace NKikimr { } void StartIndexChunk() { - Y_VERIFY(!Writer); + Y_VERIFY(!Writer); Y_VERIFY(!Finished); // obtain chunk index from reserved chunks list @@ -742,7 +742,7 @@ namespace NKikimr { } bool PackData(ui32 maxMsgs) { - Y_VERIFY(!Finished); + Y_VERIFY(!Finished); while (MsgQueue.size() < maxMsgs) { switch (PendingOp) { @@ -872,7 +872,7 @@ namespace NKikimr { } break; - default: Y_FAIL("Impossible case"); + default: Y_FAIL("Impossible case"); } IndexBuilder.Push(key, memRecToAdd, dataMerger); diff --git a/ydb/core/blobstorage/vdisk/hulldb/generic/blobstorage_hullwritesst_ut.cpp b/ydb/core/blobstorage/vdisk/hulldb/generic/blobstorage_hullwritesst_ut.cpp index 2bd6de3d43c..952169a9cb7 100644 --- a/ydb/core/blobstorage/vdisk/hulldb/generic/blobstorage_hullwritesst_ut.cpp +++ b/ydb/core/blobstorage/vdisk/hulldb/generic/blobstorage_hullwritesst_ut.cpp @@ -6,13 +6,13 @@ #include <ydb/core/blobstorage/vdisk/hulldb/base/hullbase_block.h> #include <library/cpp/testing/unittest/registar.h> -#include <util/stream/null.h> - +#include <util/stream/null.h> + #define STR Cnull namespace NKikimr { - Y_UNIT_TEST_SUITE(TBlobStorageHullWriteSst) { + Y_UNIT_TEST_SUITE(TBlobStorageHullWriteSst) { //////////////////////////////////////////////////////////////////////////////////////// // Definitions @@ -178,7 +178,7 @@ namespace NKikimr { WriterPtr = std::make_unique<TWriterLogoBlob>(TestCtx.GetVCtx(), EWriterDataType::Fresh, ChunksToUse, Owner, OwnerRound, ChunkSize, AppendBlockSize, WriteBlockSize, 0, false, ReservedChunks); pushRes = WriterPtr->Push(key, memRec, merger.GetDataMerger()); - Y_VERIFY(pushRes); + Y_VERIFY(pushRes); } while (auto msg = WriterPtr->GetPendingMessage()) { Apply(msg); @@ -220,7 +220,7 @@ namespace NKikimr { WriterPtr = std::make_unique<TWriterLogoBlob>(TestCtx.GetVCtx(), EWriterDataType::Fresh, ChunksToUse, Owner, OwnerRound, ChunkSize, AppendBlockSize, WriteBlockSize, 0, false, ReservedChunks); pushRes = WriterPtr->Push(key, merger.GetMemRec(), merger.GetDataMerger()); - Y_VERIFY(pushRes); + Y_VERIFY(pushRes); } while (auto msg = WriterPtr->GetPendingMessage()) { Apply(msg); @@ -249,7 +249,7 @@ namespace NKikimr { WriterPtr = std::make_unique<TWriterBlock>(TestCtx.GetVCtx(), EWriterDataType::Fresh, ChunksToUse, Owner, OwnerRound, ChunkSize, AppendBlockSize, WriteBlockSize, 0, false, ReservedChunks); pushRes = WriterPtr->Push(key, memRec, merger.GetDataMerger()); - Y_VERIFY(pushRes); + Y_VERIFY(pushRes); } while (auto msg = WriterPtr->GetPendingMessage()) { Apply(msg); @@ -264,7 +264,7 @@ namespace NKikimr { //////////////////////////////////////////////////////////////////////////////////////// // TESTS (LogoBlobs) //////////////////////////////////////////////////////////////////////////////////////// - Y_UNIT_TEST(LogoBlobOneSstOneIndex) { + Y_UNIT_TEST(LogoBlobOneSstOneIndex) { ui32 chunksToUse = 4; ui8 owner = 1; ui64 ownerRound = 1; @@ -312,7 +312,7 @@ namespace NKikimr { UNIT_ASSERT_VALUES_EQUAL(test.GetStat().ToString(), res); } - Y_UNIT_TEST(LogoBlobOneSstMultiIndex) { + Y_UNIT_TEST(LogoBlobOneSstMultiIndex) { ui32 chunksToUse = 4; ui8 owner = 1; ui64 ownerRound = 1; @@ -330,7 +330,7 @@ namespace NKikimr { UNIT_ASSERT_VALUES_EQUAL(test.GetStat().ToString(), res); } - Y_UNIT_TEST(LogoBlobMultiSstOneIndex) { + Y_UNIT_TEST(LogoBlobMultiSstOneIndex) { ui32 chunksToUse = 2; ui8 owner = 1; ui64 ownerRound = 1; @@ -351,7 +351,7 @@ namespace NKikimr { UNIT_ASSERT_VALUES_EQUAL(test.GetStat().ToString(), res); } - Y_UNIT_TEST(LogoBlobMultiSstMultiIndex) { + Y_UNIT_TEST(LogoBlobMultiSstMultiIndex) { ui32 chunksToUse = 4; ui8 owner = 1; ui64 ownerRound = 1; @@ -395,7 +395,7 @@ namespace NKikimr { //////////////////////////////////////////////////////////////////////////////////////// // TESTS (Outbound LogoBlobs) //////////////////////////////////////////////////////////////////////////////////////// - Y_UNIT_TEST(LogoBlobOneSstOneIndexPartOutbound) { + Y_UNIT_TEST(LogoBlobOneSstOneIndexPartOutbound) { ui32 chunksToUse = 4; ui8 owner = 1; ui64 ownerRound = 1; @@ -412,7 +412,7 @@ namespace NKikimr { UNIT_ASSERT_VALUES_EQUAL(test.GetStat().ToString(), res); } - Y_UNIT_TEST(LogoBlobOneSstMultiIndexPartOutbound) { + Y_UNIT_TEST(LogoBlobOneSstMultiIndexPartOutbound) { ui32 chunksToUse = 4; ui8 owner = 1; ui64 ownerRound = 1; @@ -430,7 +430,7 @@ namespace NKikimr { } - Y_UNIT_TEST(LogoBlobMultiSstOneIndexPartOutbound) { + Y_UNIT_TEST(LogoBlobMultiSstOneIndexPartOutbound) { ui32 chunksToUse = 1; ui8 owner = 1; ui64 ownerRound = 1; @@ -452,7 +452,7 @@ namespace NKikimr { //////////////////////////////////////////////////////////////////////////////////////// // TESTS (NoData) //////////////////////////////////////////////////////////////////////////////////////// - Y_UNIT_TEST(BlockOneSstOneIndex) { + Y_UNIT_TEST(BlockOneSstOneIndex) { ui32 chunksToUse = 2; ui8 owner = 1; ui64 ownerRound = 1; @@ -469,7 +469,7 @@ namespace NKikimr { UNIT_ASSERT_VALUES_EQUAL(test.GetStat().ToString(), res); } - Y_UNIT_TEST(BlockOneSstMultiIndex) { + Y_UNIT_TEST(BlockOneSstMultiIndex) { ui32 chunksToUse = 4; ui8 owner = 1; ui64 ownerRound = 1; @@ -486,7 +486,7 @@ namespace NKikimr { UNIT_ASSERT_VALUES_EQUAL(test.GetStat().ToString(), res); } - Y_UNIT_TEST(BlockMultiSstOneIndex) { + Y_UNIT_TEST(BlockMultiSstOneIndex) { ui32 chunksToUse = 1; ui8 owner = 1; ui64 ownerRound = 1; diff --git a/ydb/core/blobstorage/vdisk/hulldb/generic/hullds_leveledssts.h b/ydb/core/blobstorage/vdisk/hulldb/generic/hullds_leveledssts.h index b7de273a482..1a59bf6b13a 100644 --- a/ydb/core/blobstorage/vdisk/hulldb/generic/hullds_leveledssts.h +++ b/ydb/core/blobstorage/vdisk/hulldb/generic/hullds_leveledssts.h @@ -27,7 +27,7 @@ namespace NKikimr { { typename TOrderedLevelSegments::TSstIterator it(&s); it.SeekToFirst(); - Y_VERIFY_DEBUG(it.Valid()); + Y_VERIFY_DEBUG(it.Valid()); while (it.Valid()) { PushBack(TLevelSstPtr(level, it.Get())); it.Next(); @@ -87,12 +87,12 @@ namespace NKikimr { } void Next() { - Y_VERIFY_DEBUG(Valid()); + Y_VERIFY_DEBUG(Valid()); Pos++; } TLevelSstPtr Get() { - Y_VERIFY_DEBUG(Valid()); + Y_VERIFY_DEBUG(Valid()); return LeveledSsts->Vec[Pos]; } }; diff --git a/ydb/core/blobstorage/vdisk/hulldb/generic/hullds_sst_it.h b/ydb/core/blobstorage/vdisk/hulldb/generic/hullds_sst_it.h index b4fe82f2d34..7f07eb0a832 100644 --- a/ydb/core/blobstorage/vdisk/hulldb/generic/hullds_sst_it.h +++ b/ydb/core/blobstorage/vdisk/hulldb/generic/hullds_sst_it.h @@ -68,17 +68,17 @@ namespace NKikimr { } void Next() { - Y_VERIFY_DEBUG(Ptr && Ptr < End() && Ptr >= Begin()); + Y_VERIFY_DEBUG(Ptr && Ptr < End() && Ptr >= Begin()); ++Ptr; } void Prev() { - Y_VERIFY_DEBUG(Ptr && Ptr <= End() && Ptr >= Begin()); + Y_VERIFY_DEBUG(Ptr && Ptr <= End() && Ptr >= Begin()); --Ptr; } TKey GetCurKey() const { - Y_VERIFY_DEBUG(Valid()); + Y_VERIFY_DEBUG(Valid()); return Ptr->Key; } @@ -110,7 +110,7 @@ namespace NKikimr { } bool operator == (const TMemIterator &it) const { - Y_VERIFY(Segment == it.Segment); + Y_VERIFY(Segment == it.Segment); return Ptr == it.Ptr; } diff --git a/ydb/core/blobstorage/vdisk/hulldb/generic/hullds_sst_it_all_ut.cpp b/ydb/core/blobstorage/vdisk/hulldb/generic/hullds_sst_it_all_ut.cpp index f965e75f61f..5230c6ebc86 100644 --- a/ydb/core/blobstorage/vdisk/hulldb/generic/hullds_sst_it_all_ut.cpp +++ b/ydb/core/blobstorage/vdisk/hulldb/generic/hullds_sst_it_all_ut.cpp @@ -19,7 +19,7 @@ namespace NKikimr { TLogoBlobSstPtr GenerateSst(ui32 step, ui32 recs, ui32 plus, ui64 tabletId = 0, ui32 generation = 0, ui32 channel = 0, ui32 cookie = 0) { using TRec = TLogoBlobSst::TRec; - Y_UNUSED(step); + Y_UNUSED(step); TLogoBlobSstPtr ptr(new TLogoBlobSst(TTestContexts().GetVCtx())); for (ui32 i = 0; i < recs; i++) { TLogoBlobID id(tabletId, generation, step + i * plus, channel, 0, cookie); @@ -43,12 +43,12 @@ namespace NKikimr { } // NBlobStorageHullSstItHelpers - Y_UNIT_TEST_SUITE(TBlobStorageHullSstIt) { + Y_UNIT_TEST_SUITE(TBlobStorageHullSstIt) { using namespace NBlobStorageHullSstItHelpers; using TMemIterator = TLogoBlobSst::TMemIterator; - Y_UNIT_TEST(TestSeekToFirst) { + Y_UNIT_TEST(TestSeekToFirst) { TLogoBlobSstPtr ptr(GenerateSst(10, 10, 1)); TMemIterator it(ptr.Get()); it.SeekToFirst(); @@ -66,7 +66,7 @@ namespace NKikimr { UNIT_ASSERT(str.Str() == result); } - Y_UNIT_TEST(TestSeekToLast) { + Y_UNIT_TEST(TestSeekToLast) { TLogoBlobSstPtr ptr(GenerateSst(10, 10, 1)); TMemIterator it(ptr.Get()); it.SeekToLast(); @@ -84,7 +84,7 @@ namespace NKikimr { UNIT_ASSERT(str.Str() == result); } - Y_UNIT_TEST(TestSeekExactAndNext) { + Y_UNIT_TEST(TestSeekExactAndNext) { TLogoBlobSstPtr ptr(GenerateSst(10, 10, 1)); TMemIterator it(ptr.Get()); @@ -104,7 +104,7 @@ namespace NKikimr { UNIT_ASSERT(str.Str() == result); } - Y_UNIT_TEST(TestSeekExactAndPrev) { + Y_UNIT_TEST(TestSeekExactAndPrev) { TLogoBlobSstPtr ptr(GenerateSst(10, 10, 1)); TMemIterator it(ptr.Get()); @@ -124,7 +124,7 @@ namespace NKikimr { UNIT_ASSERT(str.Str() == result); } - Y_UNIT_TEST(TestSeekBefore) { + Y_UNIT_TEST(TestSeekBefore) { TLogoBlobSstPtr ptr(GenerateSst(10, 10, 1)); TMemIterator it(ptr.Get()); @@ -134,7 +134,7 @@ namespace NKikimr { UNIT_ASSERT(it.GetCurKey().ToString() == "[0:0:10:0:0:0:0]"); } - Y_UNIT_TEST(TestSeekAfterAndPrev) { + Y_UNIT_TEST(TestSeekAfterAndPrev) { TLogoBlobSstPtr ptr(GenerateSst(10, 10, 1)); TMemIterator it(ptr.Get()); @@ -147,7 +147,7 @@ namespace NKikimr { UNIT_ASSERT(it.GetCurKey().ToString() == "[0:0:19:0:0:0:0]"); } - Y_UNIT_TEST(TestSeekNotExactBefore) { + Y_UNIT_TEST(TestSeekNotExactBefore) { TLogoBlobSstPtr ptr(GenerateSst(10, 10, 2)); TMemIterator it(ptr.Get()); @@ -158,13 +158,13 @@ namespace NKikimr { } } // TBlobStorageHullSstIt - Y_UNIT_TEST_SUITE(TBlobStorageHullOrderedSstsIt) { + Y_UNIT_TEST_SUITE(TBlobStorageHullOrderedSstsIt) { using namespace NBlobStorageHullSstItHelpers; using TIterator = TLogoBlobOrderedSsts::TReadIterator; TTestContexts TestCtx(ChunkSize, CompWorthReadSize); - Y_UNIT_TEST(TestSeekToFirst) { + Y_UNIT_TEST(TestSeekToFirst) { TLogoBlobOrderedSstsPtr ptr(GenerateOrderedSsts(10, 5, 1, 3)); THullCtxPtr hullCtx = TestCtx.GetHullCtx(); TIterator it(hullCtx, ptr.Get()); @@ -186,7 +186,7 @@ namespace NKikimr { UNIT_ASSERT(str.Str() == result); } - Y_UNIT_TEST(TestSeekToLast) { + Y_UNIT_TEST(TestSeekToLast) { TLogoBlobOrderedSstsPtr ptr(GenerateOrderedSsts(10, 5, 1, 3)); THullCtxPtr hullCtx = TestCtx.GetHullCtx(); TIterator it(hullCtx, ptr.Get()); @@ -208,7 +208,7 @@ namespace NKikimr { UNIT_ASSERT(str.Str() == result); } - Y_UNIT_TEST(TestSeekAfterAndPrev) { + Y_UNIT_TEST(TestSeekAfterAndPrev) { TLogoBlobOrderedSstsPtr ptr(GenerateOrderedSsts(10, 5, 1, 3)); THullCtxPtr hullCtx = TestCtx.GetHullCtx(); TIterator it(hullCtx, ptr.Get()); diff --git a/ydb/core/blobstorage/vdisk/hulldb/generic/hullds_sstslice.h b/ydb/core/blobstorage/vdisk/hulldb/generic/hullds_sstslice.h index 83d7253d3bf..438d48c36d3 100644 --- a/ydb/core/blobstorage/vdisk/hulldb/generic/hullds_sstslice.h +++ b/ydb/core/blobstorage/vdisk/hulldb/generic/hullds_sstslice.h @@ -90,7 +90,7 @@ namespace NKikimr { return Segs->ObsoleteLastCompactedLsn(); } - void OutputHtml(ui32 &index, IOutputStream &str, TIdxDiskPlaceHolder::TInfo &sum) const { + void OutputHtml(ui32 &index, IOutputStream &str, TIdxDiskPlaceHolder::TInfo &sum) const { Segs->OutputHtml(index, str, sum); } @@ -163,7 +163,7 @@ namespace NKikimr { Segs->GetOwnedChunks(chunks); } - void OutputHtml(ui32 &index, ui32 level, IOutputStream &str, TIdxDiskPlaceHolder::TInfo &sum) const { + void OutputHtml(ui32 &index, ui32 level, IOutputStream &str, TIdxDiskPlaceHolder::TInfo &sum) const { Segs->OutputHtml(index, level, str, sum); } }; @@ -327,7 +327,7 @@ namespace NKikimr { return str.Str(); } - void OutputHtml(IOutputStream &str) const; + void OutputHtml(IOutputStream &str) const; ui32 GetLevelXNumber() const { return SortedLevels.size(); @@ -447,7 +447,7 @@ namespace NKikimr { return Level0SegsNum; } - void Output(IOutputStream &str) const { + void Output(IOutputStream &str) const { TSstIterator it(this); it.SeekToFirst(); unsigned curLevel = 0; diff --git a/ydb/core/blobstorage/vdisk/hulldb/generic/hullds_sstslice_it.h b/ydb/core/blobstorage/vdisk/hulldb/generic/hullds_sstslice_it.h index 9ad444a4297..1574aae0959 100644 --- a/ydb/core/blobstorage/vdisk/hulldb/generic/hullds_sstslice_it.h +++ b/ydb/core/blobstorage/vdisk/hulldb/generic/hullds_sstslice_it.h @@ -100,7 +100,7 @@ namespace NKikimr { } void Next() { - Y_VERIFY_DEBUG(Valid()); + Y_VERIFY_DEBUG(Valid()); IntraLevelIt.Next(); if (!IntraLevelIt.Valid()) { ++CurLevelIt; @@ -110,7 +110,7 @@ namespace NKikimr { } TLevelSstPtr Get() { - Y_VERIFY_DEBUG(Valid()); + Y_VERIFY_DEBUG(Valid()); return TLevelSstPtr(CurLevelNum, IntraLevelIt.Get()); } @@ -155,7 +155,7 @@ namespace NKikimr { } void Next() { - Y_VERIFY_DEBUG(Valid()); + Y_VERIFY_DEBUG(Valid()); if (Level0It.Valid()) Level0It.Next(); else @@ -163,7 +163,7 @@ namespace NKikimr { } TLevelSstPtr Get() { - Y_VERIFY_DEBUG(Valid()); + Y_VERIFY_DEBUG(Valid()); if (Level0It.Valid()) return TLevelSstPtr(0, Level0It.Get()); else diff --git a/ydb/core/blobstorage/vdisk/hulldb/generic/hullds_sstvec.h b/ydb/core/blobstorage/vdisk/hulldb/generic/hullds_sstvec.h index 0a30c1e20b0..6d93a96bd0a 100644 --- a/ydb/core/blobstorage/vdisk/hulldb/generic/hullds_sstvec.h +++ b/ydb/core/blobstorage/vdisk/hulldb/generic/hullds_sstvec.h @@ -62,7 +62,7 @@ namespace NKikimr { }; ui64 GetFirstLsn() const { - Y_VERIFY_DEBUG(!Empty()); + Y_VERIFY_DEBUG(!Empty()); ui64 firstLsn = ui64(-1); for (const auto &x : Segments) firstLsn = Min(firstLsn, x->Info.FirstLsn); @@ -70,7 +70,7 @@ namespace NKikimr { } ui64 GetLastLsn() const { - Y_VERIFY_DEBUG(!Empty()); + Y_VERIFY_DEBUG(!Empty()); ui64 lastLsn = 0; for (const auto &x : Segments) lastLsn = Max(lastLsn, x->Info.LastLsn); @@ -149,14 +149,14 @@ namespace NKikimr { return elements; } - void OutputHtml(ui32 &index, ui32 level, IOutputStream &str, TIdxDiskPlaceHolder::TInfo &sum) const { + void OutputHtml(ui32 &index, ui32 level, IOutputStream &str, TIdxDiskPlaceHolder::TInfo &sum) const { for (typename TSegments::const_iterator it = Segments.begin(), e = Segments.end(); it != e; ++it) { (*it)->OutputHtml(index, level, str, sum); } } // dump all accessible data - void DumpAll(IOutputStream &str) const { + void DumpAll(IOutputStream &str) const { for (const auto &x : Segments) x->DumpAll(str); } @@ -249,7 +249,7 @@ namespace NKikimr { return lastLsn; } - void OutputHtml(ui32 &index, IOutputStream &str, TIdxDiskPlaceHolder::TInfo &sum) const { + void OutputHtml(ui32 &index, IOutputStream &str, TIdxDiskPlaceHolder::TInfo &sum) const { for (const auto &x : Segments) { if (x) x->OutputHtml(index, 0, str, sum); diff --git a/ydb/core/blobstorage/vdisk/hulldb/generic/hullds_sstvec_it.h b/ydb/core/blobstorage/vdisk/hulldb/generic/hullds_sstvec_it.h index 702b0976d35..f7571657b56 100644 --- a/ydb/core/blobstorage/vdisk/hulldb/generic/hullds_sstvec_it.h +++ b/ydb/core/blobstorage/vdisk/hulldb/generic/hullds_sstvec_it.h @@ -40,7 +40,7 @@ namespace NKikimr { } void Next() { - Y_VERIFY_DEBUG(CrossSegIt != All->Segments.end()); + Y_VERIFY_DEBUG(CrossSegIt != All->Segments.end()); CurSegIt.Next(); if (!CurSegIt.Valid()) { ++CrossSegIt; @@ -69,31 +69,31 @@ namespace NKikimr { } void SeekToFirst() { - Y_VERIFY(!All->Segments.empty()); + Y_VERIFY(!All->Segments.empty()); CrossSegIt = All->Segments.begin(); CurSegIt = TSegIt((*CrossSegIt).Get()); CurSegIt.SeekToFirst(); } void SeekToLast() { - Y_VERIFY(!All->Segments.empty()); + Y_VERIFY(!All->Segments.empty()); CrossSegIt = All->Segments.end() - 1; CurSegIt = TSegIt((*CrossSegIt).Get()); CurSegIt.SeekToLast(); } void Seek(const TKey &key) { - Y_VERIFY(!All->Segments.empty()); + Y_VERIFY(!All->Segments.empty()); TCrossSegIt b = All->Segments.begin(); TCrossSegIt e = All->Segments.end(); CrossSegIt = ::LowerBound(b, e, key, TVectorLess()); if (CrossSegIt == e) { - Y_VERIFY_DEBUG(b != e); // we can't have empty vector + Y_VERIFY_DEBUG(b != e); // we can't have empty vector --CrossSegIt; } else { const TKey firstKey = (*CrossSegIt)->FirstKey(); - Y_VERIFY_DEBUG(firstKey >= key); + Y_VERIFY_DEBUG(firstKey >= key); if (firstKey > key) { if (CrossSegIt == b) { // good @@ -173,12 +173,12 @@ namespace NKikimr { {} void SeekToFirst() { - Y_VERIFY_DEBUG(S); + Y_VERIFY_DEBUG(S); Cur = S->Segments.begin(); } void SeekToLast() { - Y_VERIFY_DEBUG(S); + Y_VERIFY_DEBUG(S); Cur = S->Segments.end(); --Cur; } @@ -197,17 +197,17 @@ namespace NKikimr { } void Next() { - Y_VERIFY_DEBUG(Valid()); + Y_VERIFY_DEBUG(Valid()); ++Cur; } void Prev() { - Y_VERIFY_DEBUG(Valid()); + Y_VERIFY_DEBUG(Valid()); --Cur; } TLevelSegmentPtr Get() { - Y_VERIFY_DEBUG(Valid()); + Y_VERIFY_DEBUG(Valid()); return *Cur; } }; @@ -234,7 +234,7 @@ namespace NKikimr { {} void SeekToFirst() { - Y_VERIFY_DEBUG(S); + Y_VERIFY_DEBUG(S); if (NumLimit > 0) { // for zero NumLimit we have a race of adding element into // empty list and calling begin() on it @@ -262,7 +262,7 @@ namespace NKikimr { } TLevelSegmentPtr Get() { - Y_VERIFY_DEBUG(Valid()); + Y_VERIFY_DEBUG(Valid()); return *Cur; } }; diff --git a/ydb/core/blobstorage/vdisk/hullop/blobstorage_hullcompact.h b/ydb/core/blobstorage/vdisk/hullop/blobstorage_hullcompact.h index fca2f00daa9..3a02720d2df 100644 --- a/ydb/core/blobstorage/vdisk/hullop/blobstorage_hullcompact.h +++ b/ydb/core/blobstorage/vdisk/hullop/blobstorage_hullcompact.h @@ -284,7 +284,7 @@ namespace NKikimr { // chunks to commit msg->CommitChunks = IsAborting ? TVector<ui32>() : Worker.GetCommitChunks(); - Y_VERIFY(emptyWrite == msg->CommitChunks.empty()); // both empty or not + Y_VERIFY(emptyWrite == msg->CommitChunks.empty()); // both empty or not msg->SegVec = IsAborting ? nullptr : std::move(Result); msg->FreshSegment = IsAborting ? nullptr : FreshSegment; diff --git a/ydb/core/blobstorage/vdisk/hullop/blobstorage_hullcompactdeferredqueue_ut.cpp b/ydb/core/blobstorage/vdisk/hullop/blobstorage_hullcompactdeferredqueue_ut.cpp index 682e9f21c1c..8e210d17cd6 100644 --- a/ydb/core/blobstorage/vdisk/hullop/blobstorage_hullcompactdeferredqueue_ut.cpp +++ b/ydb/core/blobstorage/vdisk/hullop/blobstorage_hullcompactdeferredqueue_ut.cpp @@ -44,9 +44,9 @@ public: {} }; -Y_UNIT_TEST_SUITE(TBlobStorageHullCompactDeferredQueueTest) { +Y_UNIT_TEST_SUITE(TBlobStorageHullCompactDeferredQueueTest) { - Y_UNIT_TEST(Basic) { + Y_UNIT_TEST(Basic) { TRope parts[6] = { TRope(TString("AAAAAA")), TRope(TString("BBBBBB")), diff --git a/ydb/core/blobstorage/vdisk/hullop/blobstorage_hullload.h b/ydb/core/blobstorage/vdisk/hullop/blobstorage_hullload.h index d08b3a04d77..3f09d73babd 100644 --- a/ydb/core/blobstorage/vdisk/hullop/blobstorage_hullload.h +++ b/ydb/core/blobstorage/vdisk/hullop/blobstorage_hullload.h @@ -56,7 +56,7 @@ namespace NKikimr { {} void Add(ui32 chunkIdx) { - Y_VERIFY_DEBUG(chunkIdx); + Y_VERIFY_DEBUG(chunkIdx); if (chunkIdx != LastChunkIdx) { LastChunkIdx = chunkIdx; AllChunks.insert(chunkIdx); @@ -64,7 +64,7 @@ namespace NKikimr { } void FillInVector(TVector<ui32> &vec) { - Y_VERIFY_DEBUG(vec.empty()); + Y_VERIFY_DEBUG(vec.empty()); vec.reserve(AllChunks.size()); for (const auto &x : AllChunks) vec.push_back(x); @@ -158,7 +158,7 @@ namespace NKikimr { } void Finish(const TActorContext &ctx) { - Y_VERIFY(RestToReadIndex == 0 && RestToReadOutbound == 0); + Y_VERIFY(RestToReadIndex == 0 && RestToReadOutbound == 0); // add data chunks to ChunksBuilder typedef typename TLevelSegment::TMemIterator TMemIterator; @@ -190,14 +190,14 @@ namespace NKikimr { } void AppendIndexData(const char *data, size_t size) { - Y_VERIFY_DEBUG(data && size && RestToReadIndex >= size); + Y_VERIFY_DEBUG(data && size && RestToReadIndex >= size); RestToReadIndex -= size; memcpy(reinterpret_cast<char *>(LevelSegment->LoadedIndex.data()) + RestToReadIndex, data, size); } void AppendData(const char *data, size_t size) { - Y_VERIFY_DEBUG(data && size); + Y_VERIFY_DEBUG(data && size); if (RestToReadOutbound) { if (RestToReadOutbound >= size) { @@ -316,7 +316,7 @@ namespace NKikimr { , Chunks() { const TDiskPart& entry = levelSegment->GetEntryPoint(); - Y_VERIFY_DEBUG(!entry.Empty()); + Y_VERIFY_DEBUG(!entry.Empty()); } }; @@ -374,7 +374,7 @@ namespace NKikimr { ActiveActors.Insert(aid); ++Pos; } else { - Y_VERIFY_DEBUG(Pos == Size); + Y_VERIFY_DEBUG(Pos == Size); ctx.Send(Recipient, new THullSegmentsLoaded(Segs)); TThis::Die(ctx); } diff --git a/ydb/core/blobstorage/vdisk/hullop/blobstorage_readbatch_ut.cpp b/ydb/core/blobstorage/vdisk/hullop/blobstorage_readbatch_ut.cpp index 2ec3c228f07..9e3ffdfb6a2 100644 --- a/ydb/core/blobstorage/vdisk/hullop/blobstorage_readbatch_ut.cpp +++ b/ydb/core/blobstorage/vdisk/hullop/blobstorage_readbatch_ut.cpp @@ -8,8 +8,8 @@ using namespace NKikimr; #define STR Cnull -Y_UNIT_TEST_SUITE(ReadBatcher) { - Y_UNIT_TEST(Range) { +Y_UNIT_TEST_SUITE(ReadBatcher) { + Y_UNIT_TEST(Range) { TVector<std::pair<ui32, ui32>> ranges; const ui32 len = 8; for (ui32 start = 0; start <= len; ++start) { @@ -37,7 +37,7 @@ Y_UNIT_TEST_SUITE(ReadBatcher) { } } - Y_UNIT_TEST(ReadBatcher) { + Y_UNIT_TEST(ReadBatcher) { struct TPayload { TChunkIdx ChunkIdx; ui32 Offset; diff --git a/ydb/core/blobstorage/vdisk/ingress/blobstorage_ingress.cpp b/ydb/core/blobstorage/vdisk/ingress/blobstorage_ingress.cpp index 4e9f1f03c3a..003fa86950d 100644 --- a/ydb/core/blobstorage/vdisk/ingress/blobstorage_ingress.cpp +++ b/ydb/core/blobstorage/vdisk/ingress/blobstorage_ingress.cpp @@ -34,7 +34,7 @@ namespace NKikimr { // handoff ui32 handoff = top->GType.Handoff(); - Y_VERIFY(handoff < domainsNum); + Y_VERIFY(handoff < domainsNum); // barrierIngressValueMask ui32 barrierIngressValueMask = (1ull << totalVDisks) - 1; @@ -219,7 +219,7 @@ namespace NKikimr { Y_VERIFY(IngressMode(top->GType) == EMode::GENERIC); // FIXME: think how we merge ingress (especially for handoff replicas) (when we delete parts) - Y_VERIFY_DEBUG(id.PartId() == 0); + Y_VERIFY_DEBUG(id.PartId() == 0); SETUP_VECTORS(Data, top->GType); ui8 nodeId = top->GetIdxInSubgroup(vdisk, id.Hash()); @@ -228,7 +228,7 @@ namespace NKikimr { return TPairOfVectors(emptyVec, emptyVec); } else { ui8 handoffNodeId = nodeId - totalParts; - Y_VERIFY_DEBUG(handoffNodeId < handoffNum); + Y_VERIFY_DEBUG(handoffNodeId < handoffNum); TVectorType m = handoff[handoffNodeId].ToVector(); // map of handoff replicas on this node TVectorType mainVec = main.ToVector(); @@ -272,7 +272,7 @@ namespace NKikimr { TVDiskIdShort TIngress::GetMainReplica(const TBlobStorageGroupInfo::TTopology *top, const TLogoBlobID &id) { Y_VERIFY(IngressMode(top->GType) == EMode::GENERIC); - Y_VERIFY_DEBUG(id.PartId() != 0); + Y_VERIFY_DEBUG(id.PartId() != 0); ui8 partId = id.PartId(); return top->GetVDiskInSubgroup(partId - 1, id.Hash()); } @@ -282,15 +282,15 @@ namespace NKikimr { const TLogoBlobID &id) { Y_VERIFY(IngressMode(top->GType) == EMode::GENERIC); - Y_VERIFY_DEBUG(id.PartId() != 0); + Y_VERIFY_DEBUG(id.PartId() != 0); SETUP_VECTORS(Data, top->GType); ui8 nodeId = top->GetIdxInSubgroup(vdisk, id.Hash()); - Y_VERIFY(nodeId >= totalParts, "DeleteHandoff: can't delete main replica; nodeId# %u totalParts# %u vdisk# %s " + Y_VERIFY(nodeId >= totalParts, "DeleteHandoff: can't delete main replica; nodeId# %u totalParts# %u vdisk# %s " "id# %s", unsigned(nodeId), unsigned(totalParts), vdisk.ToString().data(), id.ToString().data()); ui8 handoffNodeId = nodeId - totalParts; - Y_VERIFY_DEBUG(handoffNodeId < handoffNum); + Y_VERIFY_DEBUG(handoffNodeId < handoffNum); ui8 i = id.PartId() - 1u; local.Clear(i); // delete local @@ -384,7 +384,7 @@ namespace NKikimr { } TString TIngress::PrintVDisksForLogoBlob(const TBlobStorageGroupInfo *info, const TLogoBlobID &id) { - Y_VERIFY_DEBUG(id.PartId() == 0); + Y_VERIFY_DEBUG(id.PartId() == 0); TBlobStorageGroupInfo::TVDiskIds outVDisks; info->PickSubgroup(id.Hash(), &outVDisks, nullptr); TStringStream str; diff --git a/ydb/core/blobstorage/vdisk/ingress/blobstorage_ingress_matrix.h b/ydb/core/blobstorage/vdisk/ingress/blobstorage_ingress_matrix.h index 29ef0150327..05b2fc3f9c8 100644 --- a/ydb/core/blobstorage/vdisk/ingress/blobstorage_ingress_matrix.h +++ b/ydb/core/blobstorage/vdisk/ingress/blobstorage_ingress_matrix.h @@ -47,7 +47,7 @@ namespace NKikimr { : Vec(vec & EmptyMask[size]) , Size(size) { - Y_VERIFY_DEBUG(size <= 8); + Y_VERIFY_DEBUG(size <= 8); } TVectorType(const TVectorType &v) @@ -56,13 +56,13 @@ namespace NKikimr { {} void Set(ui8 i) { - Y_VERIFY_DEBUG(i < Size); + Y_VERIFY_DEBUG(i < Size); ui8 mask = 0x80 >> i; Vec |= mask; } void Clear(ui8 i) { - Y_VERIFY_DEBUG(i < Size); + Y_VERIFY_DEBUG(i < Size); ui8 mask = 0x80 >> i; Vec &= ~mask; } @@ -72,7 +72,7 @@ namespace NKikimr { } bool Get(ui8 i) const { - Y_VERIFY_DEBUG(i < Size); + Y_VERIFY_DEBUG(i < Size); ui8 mask = 0x80 >> i; return Vec & mask; } @@ -89,7 +89,7 @@ namespace NKikimr { } ui8 NextPosition(ui8 i) const { - Y_VERIFY_DEBUG(i < 8); + Y_VERIFY_DEBUG(i < 8); unsigned shift = 8 - i - 1; unsigned mask = unsigned(-1) >> shift << shift; unsigned v = (unsigned)Vec & ~mask; @@ -122,7 +122,7 @@ namespace NKikimr { } TVectorType &operator |=(const TVectorType &v) { - Y_VERIFY_DEBUG(Size == v.Size); + Y_VERIFY_DEBUG(Size == v.Size); Vec |= v.Vec; return *this; } @@ -139,7 +139,7 @@ namespace NKikimr { } bool operator ==(const TVectorType &v) const { - Y_VERIFY_DEBUG(v.Size == Size); + Y_VERIFY_DEBUG(v.Size == Size); return Vec == v.Vec; } @@ -185,26 +185,26 @@ namespace NKikimr { friend TVectorType operator |(const TVectorType &v1, const TVectorType &v2); ui8 FirstSetBit(ui8 vec) const { - const static unsigned shift = std::numeric_limits<unsigned int>::digits - std::numeric_limits<ui8>::digits; + const static unsigned shift = std::numeric_limits<unsigned int>::digits - std::numeric_limits<ui8>::digits; unsigned mask = unsigned(-1) >> unsigned(Size); unsigned t = (unsigned(vec) << shift) | mask; - Y_VERIFY_DEBUG(t != 0); + Y_VERIFY_DEBUG(t != 0); return Clz(t); } }; inline TVectorType operator -(const TVectorType &v1, const TVectorType &v2) { - Y_VERIFY_DEBUG(v1.Size == v2.Size); + Y_VERIFY_DEBUG(v1.Size == v2.Size); return TVectorType(v1.Vec ^ (v1.Vec & v2.Vec), v1.Size); } inline TVectorType operator &(const TVectorType &v1, const TVectorType &v2) { - Y_VERIFY_DEBUG(v1.Size == v2.Size); + Y_VERIFY_DEBUG(v1.Size == v2.Size); return TVectorType(v1.Vec & v2.Vec, v1.Size); } inline TVectorType operator |(const TVectorType &v1, const TVectorType &v2) { - Y_VERIFY_DEBUG(v1.Size == v2.Size); + Y_VERIFY_DEBUG(v1.Size == v2.Size); return TVectorType(v1.Vec | v2.Vec, v1.Size); } @@ -226,7 +226,7 @@ namespace NKikimr { , Beg(b) , End(e) { - Y_VERIFY_DEBUG(End > Beg); + Y_VERIFY_DEBUG(End > Beg); } void Set(ui8 i) { @@ -267,7 +267,7 @@ namespace NKikimr { } void Next() { - Y_VERIFY_DEBUG(!IsEnd()); + Y_VERIFY_DEBUG(!IsEnd()); Pos++; Mask >>= 1; if (!Mask) { @@ -298,7 +298,7 @@ namespace NKikimr { ui8 End; void CalcPos(ui8 &byte, ui8 &mask, ui8 i) const { - Y_VERIFY_DEBUG(i < (End - Beg)); + Y_VERIFY_DEBUG(i < (End - Beg)); ui8 bitPos = Beg + i; byte = bitPos >> 3; ui8 bit = bitPos - (byte << 3); @@ -329,7 +329,7 @@ namespace NKikimr { } TVectorType ToVector() const { - Y_VERIFY_DEBUG(End - Beg <= 8); + Y_VERIFY_DEBUG(End - Beg <= 8); ui8 vec = 0; TIterator it = Begin(); while (!it.IsEnd()) { @@ -356,7 +356,7 @@ namespace NKikimr { TShiftedHandoffBitVec(ui8 *ptr, ui8 b, ui8 e) : TShiftedBitVecBase(ptr, b, e) { - Y_VERIFY_DEBUG(((End - Beg) >> 1 << 1) == (End - Beg)); + Y_VERIFY_DEBUG(((End - Beg) >> 1 << 1) == (End - Beg)); } // 00 -- not set @@ -390,14 +390,14 @@ namespace NKikimr { } TVectorType ToVector() const { - Y_VERIFY_DEBUG(End - Beg <= 2 * 8); + Y_VERIFY_DEBUG(End - Beg <= 2 * 8); ui8 vec = 0; TIterator it = Begin(); while (!it.IsEnd()) { vec <<= 1; bool firstBit = it.Get(); it.Next(); - Y_VERIFY_DEBUG(!it.IsEnd()); + Y_VERIFY_DEBUG(!it.IsEnd()); bool secondBit = it.Get(); it.Next(); vec |= ui8(!firstBit && secondBit); @@ -417,7 +417,7 @@ namespace NKikimr { , Rows(rows) , Columns(columns) { - Y_VERIFY_DEBUG(ptr && rows && columns); + Y_VERIFY_DEBUG(ptr && rows && columns); } void Zero() { @@ -502,7 +502,7 @@ namespace NKikimr { }; TPos CalcPos(ui8 row, ui8 column) const { - Y_VERIFY_DEBUG(row < Rows && column < Columns); + Y_VERIFY_DEBUG(row < Rows && column < Columns); ui32 bit = (ui32)Columns * (ui32)row + (ui32)column; ui32 byte = bit / BitsInByte; ui32 localBit = byte * BitsInByte + 7 - bit; diff --git a/ydb/core/blobstorage/vdisk/ingress/blobstorage_ingress_matrix_ut.cpp b/ydb/core/blobstorage/vdisk/ingress/blobstorage_ingress_matrix_ut.cpp index e3373f054c6..40d85c84cec 100644 --- a/ydb/core/blobstorage/vdisk/ingress/blobstorage_ingress_matrix_ut.cpp +++ b/ydb/core/blobstorage/vdisk/ingress/blobstorage_ingress_matrix_ut.cpp @@ -9,9 +9,9 @@ namespace NKikimr { using namespace NMatrix; - Y_UNIT_TEST_SUITE(TBlobStorageIngressMatrix) { + Y_UNIT_TEST_SUITE(TBlobStorageIngressMatrix) { - Y_UNIT_TEST(VectorTest) { + Y_UNIT_TEST(VectorTest) { TVectorType vec(0, 7); vec.Set(0); vec.Set(4); @@ -45,7 +45,7 @@ namespace NKikimr { UNIT_ASSERT(!TVectorType(0x37, 5).Empty()); } - Y_UNIT_TEST(VectorTestEmpty) { + Y_UNIT_TEST(VectorTestEmpty) { TVectorType vec(0, 7); UNIT_ASSERT(vec.Empty()); vec.Set(0); @@ -59,7 +59,7 @@ namespace NKikimr { UNIT_ASSERT(!vec.Empty()); } - Y_UNIT_TEST(VectorTestMinus) { + Y_UNIT_TEST(VectorTestMinus) { TVectorType vec1(0, 7); vec1.Set(0); vec1.Set(4); @@ -76,7 +76,7 @@ namespace NKikimr { UNIT_ASSERT(vec1 - vec2 == res); } - Y_UNIT_TEST(VectorTestBitwiseAnd) { + Y_UNIT_TEST(VectorTestBitwiseAnd) { TVectorType vec1(0, 7); vec1.Set(0); vec1.Set(4); @@ -92,7 +92,7 @@ namespace NKikimr { UNIT_ASSERT((vec1 & vec2) == res); } - Y_UNIT_TEST(VectorTestBitwiseComplement1) { + Y_UNIT_TEST(VectorTestBitwiseComplement1) { TVectorType vec1(0, 4); TVectorType vec2(~vec1); TVectorType vec3(0, 4); @@ -104,7 +104,7 @@ namespace NKikimr { UNIT_ASSERT(vec2 == vec3); } - Y_UNIT_TEST(VectorTestBitwiseComplement2) { + Y_UNIT_TEST(VectorTestBitwiseComplement2) { TVectorType vec1(0, 5); vec1.Set(2); vec1.Set(4); @@ -117,7 +117,7 @@ namespace NKikimr { UNIT_ASSERT(vec2 == vec3); } - Y_UNIT_TEST(VectorTestBitsBefore1) { + Y_UNIT_TEST(VectorTestBitsBefore1) { TVectorType vec1(0, 7); vec1.Set(0); vec1.Set(4); @@ -139,7 +139,7 @@ namespace NKikimr { UNIT_ASSERT(res == canon); } - Y_UNIT_TEST(VectorTestBitsBefore2) { + Y_UNIT_TEST(VectorTestBitsBefore2) { TVectorType vec1(0, 4); vec1.Set(1); vec1.Set(2); @@ -157,7 +157,7 @@ namespace NKikimr { UNIT_ASSERT(res == canon); } - Y_UNIT_TEST(VectorTestIterator1) { + Y_UNIT_TEST(VectorTestIterator1) { TVectorType vec1(0, 7); vec1.Set(1); vec1.Set(4); @@ -175,7 +175,7 @@ namespace NKikimr { UNIT_ASSERT(res == canon); } - Y_UNIT_TEST(VectorTestIterator2) { + Y_UNIT_TEST(VectorTestIterator2) { TVectorType vec1(0, 7); vec1.Set(0); vec1.Set(1); @@ -192,7 +192,7 @@ namespace NKikimr { UNIT_ASSERT(res == canon); } - Y_UNIT_TEST(VectorTestIterator3) { + Y_UNIT_TEST(VectorTestIterator3) { TVectorType vec1(0, 6); vec1.Set(0); @@ -206,7 +206,7 @@ namespace NKikimr { UNIT_ASSERT(res == canon); } - Y_UNIT_TEST(MatrixTest) { + Y_UNIT_TEST(MatrixTest) { ui8 data[7]; TMatrix m(data, 8, 7); m.Zero(); @@ -261,7 +261,7 @@ namespace NKikimr { } - Y_UNIT_TEST(ShiftedBitVecBase) { + Y_UNIT_TEST(ShiftedBitVecBase) { ui64 data = 0; TShiftedBitVecBase vec((ui8 *)&data, 3, 15); // i.e. size=12 // test set @@ -316,7 +316,7 @@ namespace NKikimr { UNIT_ASSERT(dd == 0x54A); } - Y_UNIT_TEST(ShiftedMainBitVec) { + Y_UNIT_TEST(ShiftedMainBitVec) { ui64 data = 0; TShiftedMainBitVec vec((ui8*)&data, 7, 14); vec.Set(0); @@ -326,7 +326,7 @@ namespace NKikimr { UNIT_ASSERT(vec.ToVector() == TVectorType(0xAC, 7)); } - Y_UNIT_TEST(ShiftedHandoffBitVec) { + Y_UNIT_TEST(ShiftedHandoffBitVec) { ui64 data = 0; TShiftedHandoffBitVec vec((ui8*)&data, 7, 21); vec.Set(0); diff --git a/ydb/core/blobstorage/vdisk/ingress/blobstorage_ingress_ut.cpp b/ydb/core/blobstorage/vdisk/ingress/blobstorage_ingress_ut.cpp index 82cf659f5ac..d12a1c42c79 100644 --- a/ydb/core/blobstorage/vdisk/ingress/blobstorage_ingress_ut.cpp +++ b/ydb/core/blobstorage/vdisk/ingress/blobstorage_ingress_ut.cpp @@ -2,17 +2,17 @@ #include <library/cpp/testing/unittest/registar.h> -#include <util/stream/null.h> - +#include <util/stream/null.h> + #define STR Cnull namespace NKikimr { using namespace NMatrix; - Y_UNIT_TEST_SUITE(TBlobStorageIngress) { + Y_UNIT_TEST_SUITE(TBlobStorageIngress) { - Y_UNIT_TEST(Ingress) { + Y_UNIT_TEST(Ingress) { TBlobStorageGroupInfo groupInfo(TBlobStorageGroupType::ErasureMirror3, 2, 4); TVDiskID vdisk01 = TVDiskID(0, 1, 0, 0, 1); @@ -55,7 +55,7 @@ namespace NKikimr { UNIT_ASSERT(parts == TVectorType(0x40, 3)); } - Y_UNIT_TEST(IngressPartsWeMustHaveLocally) { + Y_UNIT_TEST(IngressPartsWeMustHaveLocally) { TBlobStorageGroupInfo groupInfo(TBlobStorageGroupType::ErasureMirror3, 2, 4); TLogoBlobID lb1(78364, 2, 763, 0, 0, 0); STR << "INFO: " << TIngress::PrintVDisksForLogoBlob(&groupInfo, lb1) << "\n"; @@ -99,7 +99,7 @@ namespace NKikimr { UNIT_ASSERT(i6.PartsWeMustHaveLocally(&groupInfo.GetTopology(), vdisk30, lb1) == TVectorType(0b10100000, 3)); } - Y_UNIT_TEST(IngressLocalParts) { + Y_UNIT_TEST(IngressLocalParts) { TBlobStorageGroupInfo groupInfo(TBlobStorageGroupType::ErasureMirror3, 2, 4); TLogoBlobID lb1(0, 1, 0, 0, 0, 0); TBlobStorageGroupInfo::TVDiskIds vDisks; @@ -148,7 +148,7 @@ namespace NKikimr { } } - Y_UNIT_TEST(IngressCreateFromRepl) { + Y_UNIT_TEST(IngressCreateFromRepl) { TBlobStorageGroupInfo groupInfo(TBlobStorageGroupType::Erasure4Plus2Block, 1, 8); TLogoBlobID id(0, 1, 0, 0, 10, 0); const ui8 subgroup = groupInfo.Type.BlobSubgroupSize(); @@ -193,7 +193,7 @@ namespace NKikimr { } } - Y_UNIT_TEST(IngressGetMainReplica) { + Y_UNIT_TEST(IngressGetMainReplica) { TBlobStorageGroupInfo groupInfo(TBlobStorageGroupType::ErasureMirror3, 2, 4); TLogoBlobID lb1(0, 1, 0, 0, 0, 0); TBlobStorageGroupInfo::TVDiskIds vDisks; @@ -214,7 +214,7 @@ namespace NKikimr { UNIT_ASSERT(TVDiskIdShort(vdiskM3) == TIngress::GetMainReplica(&groupInfo.GetTopology(), TLogoBlobID(lb1, 3))); } - Y_UNIT_TEST(IngressHandoffPartsDelete) { + Y_UNIT_TEST(IngressHandoffPartsDelete) { TBlobStorageGroupInfo groupInfo(TBlobStorageGroupType::ErasureMirror3, 2, 4); TLogoBlobID lb1(0, 1, 0, 0, 0, 0); TBlobStorageGroupInfo::TVDiskIds vDisks; @@ -286,7 +286,7 @@ namespace NKikimr { } - Y_UNIT_TEST(IngressCacheMirror3) { + Y_UNIT_TEST(IngressCacheMirror3) { TBlobStorageGroupInfo info(TBlobStorageGroupType::ErasureMirror3, 2, 4); TVDiskID vdisk(0, 1, 0, 1 /*domain*/, 0 /*vdisk*/); TIngressCachePtr cache = TIngressCache::Create(info.PickTopology(), vdisk); @@ -301,7 +301,7 @@ namespace NKikimr { } - Y_UNIT_TEST(IngressCache4Plus2) { + Y_UNIT_TEST(IngressCache4Plus2) { TBlobStorageGroupInfo info(TBlobStorageGroupType::Erasure4Plus2Block, 2, 8); TVDiskID vdisk(0, 1, 0, 3 /*domain*/, 1 /*vdisk*/); TIngressCachePtr cache = TIngressCache::Create(info.PickTopology(), vdisk); @@ -315,7 +315,7 @@ namespace NKikimr { UNIT_ASSERT(cache->BarrierIngressDomainMask == 0x3); } - Y_UNIT_TEST(BarrierIngressQuorumBasicMirror3_4_2) { + Y_UNIT_TEST(BarrierIngressQuorumBasicMirror3_4_2) { TBlobStorageGroupInfo info(TBlobStorageGroupType::ErasureMirror3, 2, 4); TVDiskID vdisk(0, 1, 0, 1 /*domain*/, 0 /*vdisk*/); TIngressCachePtr cache = TIngressCache::Create(info.PickTopology(), vdisk); @@ -354,7 +354,7 @@ namespace NKikimr { } - Y_UNIT_TEST(BarrierIngressQuorumBasic4Plus2_8_1) { + Y_UNIT_TEST(BarrierIngressQuorumBasic4Plus2_8_1) { TBlobStorageGroupInfo info(TBlobStorageGroupType::Erasure4Plus2Block, 1, 8); TVDiskID vdisk(0, 1, 0, 4 /*domain*/, 0 /*vdisk*/); TIngressCachePtr cache = TIngressCache::Create(info.PickTopology(), vdisk); @@ -397,7 +397,7 @@ namespace NKikimr { } - Y_UNIT_TEST(BarrierIngressQuorumMirror3) { + Y_UNIT_TEST(BarrierIngressQuorumMirror3) { TBlobStorageGroupInfo info(TBlobStorageGroupType::ErasureMirror3, 2, 4); TVDiskID vdisk(0, 1, 0, 1 /*domain*/, 0 /*vdisk*/); TIngressCachePtr cache = TIngressCache::Create(info.PickTopology(), vdisk); @@ -451,7 +451,7 @@ namespace NKikimr { } - Y_UNIT_TEST(IngressPrintDistribution) { + Y_UNIT_TEST(IngressPrintDistribution) { TBlobStorageGroupInfo groupInfo(TBlobStorageGroupType::ErasureMirror3, 2, 4); for (ui32 i = 0; i < 3000; i++) { diff --git a/ydb/core/blobstorage/vdisk/localrecovery/localrecovery_defs.cpp b/ydb/core/blobstorage/vdisk/localrecovery/localrecovery_defs.cpp index f75654db66c..c57473f7562 100644 --- a/ydb/core/blobstorage/vdisk/localrecovery/localrecovery_defs.cpp +++ b/ydb/core/blobstorage/vdisk/localrecovery/localrecovery_defs.cpp @@ -71,7 +71,7 @@ namespace NKikimr { } - void TLocalRecoveryInfo::OutputCounters(IOutputStream &str, + void TLocalRecoveryInfo::OutputCounters(IOutputStream &str, const TString &prefix, const TString &suffix, const TString &hr) const { @@ -156,7 +156,7 @@ namespace NKikimr { } - void TLocalRecoveryInfo::Output(IOutputStream &str) const { + void TLocalRecoveryInfo::Output(IOutputStream &str) const { str << "{"; // border if (LocalRecoveryFinishTime.GetValue() == 0) { str << "RecoveryDuration# INPROGRESS"; @@ -179,7 +179,7 @@ namespace NKikimr { str << "}"; // border } - void TLocalRecoveryInfo::OutputHtml(IOutputStream &str) const { + void TLocalRecoveryInfo::OutputHtml(IOutputStream &str) const { str << "\n"; HTML(str) { DIV_CLASS("panel panel-default") { diff --git a/ydb/core/blobstorage/vdisk/localrecovery/localrecovery_defs.h b/ydb/core/blobstorage/vdisk/localrecovery/localrecovery_defs.h index 74149073478..e2ca9140561 100644 --- a/ydb/core/blobstorage/vdisk/localrecovery/localrecovery_defs.h +++ b/ydb/core/blobstorage/vdisk/localrecovery/localrecovery_defs.h @@ -22,7 +22,7 @@ namespace NKikimr { , LastLsn(lastLsn) {} - void Output(IOutputStream &str) const { + void Output(IOutputStream &str) const { str << "{RecsN# " << Records << " Lsns# [" << FirstLsn << " " << LastLsn << "]}"; } }; @@ -265,8 +265,8 @@ namespace NKikimr { /////////////////////////////////////////////////////////////////////////////// TLocalRecoveryInfo(const NMonGroup::TLocalRecoveryGroup &monGroup); void FillIn(NKikimrBlobStorage::TLocalRecoveryInfo *proto) const; - void Output(IOutputStream &str) const; - void OutputHtml(IOutputStream &str) const; + void Output(IOutputStream &str) const; + void OutputHtml(IOutputStream &str) const; TString ToString() const; void SetStartingPoint(TLogSignature signature, ui64 lsn); void HandleReadLogResult(const NPDisk::TEvReadLogResult::TResults &results); @@ -277,7 +277,7 @@ namespace NKikimr { private: void Disp(TRec r); - void OutputCounters(IOutputStream &str, + void OutputCounters(IOutputStream &str, const TString &prefix, const TString &suffix, const TString &hr) const; diff --git a/ydb/core/blobstorage/vdisk/localrecovery/localrecovery_public.cpp b/ydb/core/blobstorage/vdisk/localrecovery/localrecovery_public.cpp index b9bdafdbb13..7b2c8fdb972 100644 --- a/ydb/core/blobstorage/vdisk/localrecovery/localrecovery_public.cpp +++ b/ydb/core/blobstorage/vdisk/localrecovery/localrecovery_public.cpp @@ -390,7 +390,7 @@ namespace NKikimr { } bool InitHugeBlobKeeper(const TStartingPoints &startingPoints, const TActorContext &ctx) { - Y_UNUSED(ctx); + Y_UNUSED(ctx); const ui32 blocksInChunk = LocRecCtx->PDiskCtx->Dsk->ChunkSize / LocRecCtx->PDiskCtx->Dsk->AppendBlockSize; Y_VERIFY(LocRecCtx->PDiskCtx->Dsk->AppendBlockSize * blocksInChunk == LocRecCtx->PDiskCtx->Dsk->ChunkSize); @@ -398,7 +398,7 @@ namespace NKikimr { MaxLogoBlobDataSizeInBlocks += !!(Config->MaxLogoBlobDataSize - MaxLogoBlobDataSizeInBlocks * LocRecCtx->PDiskCtx->Dsk->AppendBlockSize); const ui32 slotsInChunk = blocksInChunk / MaxLogoBlobDataSizeInBlocks; - Y_VERIFY(slotsInChunk > 1); + Y_VERIFY(slotsInChunk > 1); auto logFunc = [&] (const TString &msg) { LOG_DEBUG(ctx, BS_HULLHUGE, msg); @@ -602,7 +602,7 @@ namespace NKikimr { HullBarriersDBInitialized = true; break; default: - Y_FAIL("Unexpected case"); + Y_FAIL("Unexpected case"); } if (DatabaseStateLoaded()) diff --git a/ydb/core/blobstorage/vdisk/query/query_extr.cpp b/ydb/core/blobstorage/vdisk/query/query_extr.cpp index 196b6d2054a..e21e7090edd 100644 --- a/ydb/core/blobstorage/vdisk/query/query_extr.cpp +++ b/ydb/core/blobstorage/vdisk/query/query_extr.cpp @@ -188,7 +188,7 @@ namespace NKikimr { for (rit.SeekToFirst(); rit.Valid(); rit.Next()) { const NReadBatcher::TDataItem *it = rit.Get(); const TQuery *query = static_cast<const TQuery*>(it->Cookie); - Y_VERIFY_DEBUG(query->LogoBlobID.PartId() == 0); + Y_VERIFY_DEBUG(query->LogoBlobID.PartId() == 0); const ui64 *cookiePtr = query->HasCookie ? &query->CookieVal : nullptr; ui64 ingr = it->Ingress.Raw(); diff --git a/ydb/core/blobstorage/vdisk/query/query_public.cpp b/ydb/core/blobstorage/vdisk/query/query_public.cpp index 25761b685eb..8aef8b85ee2 100644 --- a/ydb/core/blobstorage/vdisk/query/query_public.cpp +++ b/ydb/core/blobstorage/vdisk/query/query_public.cpp @@ -103,7 +103,7 @@ namespace NKikimr { return CreateLevelIndexExtremeQueryActor(queryCtx, parentId, std::move(fullSnap.LogoBlobsSnap), std::move(fullSnap.BarriersSnap), ev, std::move(result), replSchedulerId); } else { - Y_FAIL("Impossible case"); + Y_FAIL("Impossible case"); } } diff --git a/ydb/core/blobstorage/vdisk/query/query_range.cpp b/ydb/core/blobstorage/vdisk/query/query_range.cpp index 4513187b550..c6e3c72ae3e 100644 --- a/ydb/core/blobstorage/vdisk/query/query_range.cpp +++ b/ydb/core/blobstorage/vdisk/query/query_range.cpp @@ -88,7 +88,7 @@ namespace NKikimr { void Bootstrap(const TActorContext &ctx) { Prepare(); - Y_VERIFY_DEBUG(!Merger.HaveToMergeData()); + Y_VERIFY_DEBUG(!Merger.HaveToMergeData()); MainCycleIndexOnly(ctx); } diff --git a/ydb/core/blobstorage/vdisk/query/query_readbatch.cpp b/ydb/core/blobstorage/vdisk/query/query_readbatch.cpp index a883191f156..15bf190cf6d 100644 --- a/ydb/core/blobstorage/vdisk/query/query_readbatch.cpp +++ b/ydb/core/blobstorage/vdisk/query/query_readbatch.cpp @@ -159,7 +159,7 @@ namespace NKikimr { // sort read requests Sort(Result->DiskDataItemPtrs.begin(), Result->DiskDataItemPtrs.end(), TDataItem::DiskPartLess); - Y_VERIFY(CheckDiskDataItemsOrdering(true)); + Y_VERIFY(CheckDiskDataItemsOrdering(true)); // plan real requests TGlueRead *back = nullptr; @@ -175,7 +175,7 @@ namespace NKikimr { } else { ui32 prevEnd = back->Part.Offset + back->Part.Size; ui32 nextBeg = item->ActualRead.Offset; - Y_VERIFY(prevEnd <= nextBeg, "back: %s item: %s dataItems: %s", + Y_VERIFY(prevEnd <= nextBeg, "back: %s item: %s dataItems: %s", back->Part.ToString().data(), item->ActualRead.ToString().data(), DiskDataItemsToString().data()); if (nextBeg <= prevEnd + Ctx->PDiskCtx->Dsk->GlueRequestDistanceBytes) { diff --git a/ydb/core/blobstorage/vdisk/query/query_readbatch.h b/ydb/core/blobstorage/vdisk/query/query_readbatch.h index b0592a9a202..d51792b6081 100644 --- a/ydb/core/blobstorage/vdisk/query/query_readbatch.h +++ b/ydb/core/blobstorage/vdisk/query/query_readbatch.h @@ -150,12 +150,12 @@ namespace NKikimr { } bool ShouldUpdateWithDisk() const { - Y_VERIFY_DEBUG(Type == ET_CLEAN || Type == ET_SETDISK || Type == ET_SETMEM); + Y_VERIFY_DEBUG(Type == ET_CLEAN || Type == ET_SETDISK || Type == ET_SETMEM); return Type == ET_CLEAN || Type == ET_SETDISK; } bool ShouldUpdateWithMem() const { - Y_VERIFY_DEBUG(Type == ET_CLEAN || Type == ET_SETDISK || Type == ET_SETMEM); + Y_VERIFY_DEBUG(Type == ET_CLEAN || Type == ET_SETDISK || Type == ET_SETMEM); return Type == ET_CLEAN || Type == ET_SETDISK; } @@ -196,7 +196,7 @@ namespace NKikimr { } static bool DiskPartLess(const TDataItem *x, const TDataItem *y) { - Y_VERIFY_DEBUG(x->ActualRead.Size && y->ActualRead.Size); // compare items with non-null Part only + Y_VERIFY_DEBUG(x->ActualRead.Size && y->ActualRead.Size); // compare items with non-null Part only return x->ActualRead < y->ActualRead; } }; diff --git a/ydb/core/blobstorage/vdisk/query/query_statalgo.h b/ydb/core/blobstorage/vdisk/query/query_statalgo.h index e7c99e3fbdf..288a4ead287 100644 --- a/ydb/core/blobstorage/vdisk/query/query_statalgo.h +++ b/ydb/core/blobstorage/vdisk/query/query_statalgo.h @@ -91,7 +91,7 @@ namespace NKikimr { return true; } - void Output(IOutputStream &str) const { + void Output(IOutputStream &str) const { str << "{TabletId# " << TabletId << " Channel# " << Channel << "}"; } @@ -267,7 +267,7 @@ namespace NKikimr { // The method dumps database to str. // It can limit output size close to 'limitInBytes', to avoid // dumping too much. - EDumpRes Dump(IOutputStream &str) { + EDumpRes Dump(IOutputStream &str) { TCountingOutput countedStr(&str); DumpFresh(countedStr); DumpLevels(countedStr); diff --git a/ydb/core/blobstorage/vdisk/query/query_statdb.cpp b/ydb/core/blobstorage/vdisk/query/query_statdb.cpp index 65bded589f7..38c03875a3a 100644 --- a/ydb/core/blobstorage/vdisk/query/query_statdb.cpp +++ b/ydb/core/blobstorage/vdisk/query/query_statdb.cpp @@ -44,7 +44,7 @@ namespace NKikimr { MaxId = id; } - void Finish(IOutputStream &str, bool pretty) { + void Finish(IOutputStream &str, bool pretty) { HTML(str) { if (pretty) { @@ -80,8 +80,8 @@ namespace NKikimr { Channels[c].Update(id, m); } - void Finish(IOutputStream &str, ui64 tabletID, bool pretty) { - auto tabletIDOutputer = [tabletID] (IOutputStream &str) { + void Finish(IOutputStream &str, ui64 tabletID, bool pretty) { + auto tabletIDOutputer = [tabletID] (IOutputStream &str) { HTML(str) { TABLED() { SMALL() { @@ -95,16 +95,16 @@ namespace NKikimr { Finish(str, tabletIDOutputer, pretty); } - void Finish(IOutputStream &str, bool pretty) { - auto nothing = [] (IOutputStream &) {}; + void Finish(IOutputStream &str, bool pretty) { + auto nothing = [] (IOutputStream &) {}; Finish(str, nothing, pretty); } private: TVector<TChannelInfo> Channels; - void Finish(IOutputStream &str, - std::function<void (IOutputStream &)> t, + void Finish(IOutputStream &str, + std::function<void (IOutputStream &)> t, bool pretty) { HTML(str) { @@ -136,7 +136,7 @@ namespace NKikimr { AllChannels.Update(id, m); } - void Finish(IOutputStream &str, bool pretty) { + void Finish(IOutputStream &str, bool pretty) { AllChannels.Finish(str, TabletID, pretty); } @@ -170,7 +170,7 @@ namespace NKikimr { AllChannels.Update(id, m); } - void Finish(IOutputStream &str, bool pretty) { + void Finish(IOutputStream &str, bool pretty) { HTML(str) { DIV_CLASS("panel panel-info") { DIV_CLASS("panel-heading") { @@ -223,14 +223,14 @@ namespace NKikimr { } template <> - void TLevelIndexStatActor<TKeyLogoBlob, TMemRecLogoBlob>::CalculateStat(IOutputStream &str, + void TLevelIndexStatActor<TKeyLogoBlob, TMemRecLogoBlob>::CalculateStat(IOutputStream &str, bool pretty) { // aggregation class struct TAggr { using TLevelSegment = ::NKikimr::TLevelSegment<TKeyLogoBlob, TMemRecLogoBlob>; using TLevelSstPtr = typename TLevelSegment::TLevelSstPtr; - TAggr(IOutputStream &str, bool pretty) + TAggr(IOutputStream &str, bool pretty) : Str(str) , Pretty(pretty) {} @@ -254,7 +254,7 @@ namespace NKikimr { } TAllTablets Tablets; - IOutputStream &Str; + IOutputStream &Str; bool Pretty; }; @@ -264,14 +264,14 @@ namespace NKikimr { } template <> - void TLevelIndexStatActor<TKeyBlock, TMemRecBlock>::CalculateStat(IOutputStream &str, + void TLevelIndexStatActor<TKeyBlock, TMemRecBlock>::CalculateStat(IOutputStream &str, bool pretty) { // aggregation class struct TAggr { using TLevelSegment = ::NKikimr::TLevelSegment<TKeyBlock, TMemRecBlock>; using TLevelSstPtr = typename TLevelSegment::TLevelSstPtr; - TAggr(IOutputStream &str, bool pretty) + TAggr(IOutputStream &str, bool pretty) : Str(str) , Pretty(pretty) {} @@ -339,7 +339,7 @@ namespace NKikimr { using TMapType = TMap<ui64, TValue>; // TabletId -> TValue TMapType Map; - IOutputStream &Str; + IOutputStream &Str; bool Pretty; }; @@ -350,14 +350,14 @@ namespace NKikimr { } template <> - void TLevelIndexStatActor<TKeyBarrier, TMemRecBarrier>::CalculateStat(IOutputStream &str, + void TLevelIndexStatActor<TKeyBarrier, TMemRecBarrier>::CalculateStat(IOutputStream &str, bool pretty) { // aggregation class struct TAggr { using TLevelSegment = ::NKikimr::TLevelSegment<TKeyBarrier, TMemRecBarrier>; using TLevelSstPtr = typename TLevelSegment::TLevelSstPtr; - TAggr(IOutputStream &str, bool pretty) + TAggr(IOutputStream &str, bool pretty) : Str(str) , Pretty(pretty) {} @@ -440,7 +440,7 @@ namespace NKikimr { using TMapType = TMap<TKey, TValue>; // TKey -> TValue TMapType Map; - IOutputStream &Str; + IOutputStream &Str; bool Pretty; }; diff --git a/ydb/core/blobstorage/vdisk/query/query_statdb.h b/ydb/core/blobstorage/vdisk/query/query_statdb.h index 67aa2aeec54..a25331011fc 100644 --- a/ydb/core/blobstorage/vdisk/query/query_statdb.h +++ b/ydb/core/blobstorage/vdisk/query/query_statdb.h @@ -33,7 +33,7 @@ namespace NKikimr { TThis::Die(ctx); } - void CalculateStat(IOutputStream &str, bool pretty); + void CalculateStat(IOutputStream &str, bool pretty); public: static constexpr NKikimrServices::TActivity::EType ActorActivityType() { diff --git a/ydb/core/blobstorage/vdisk/query/query_stattablet.cpp b/ydb/core/blobstorage/vdisk/query/query_stattablet.cpp index 16e25fb1a65..8f200680884 100644 --- a/ydb/core/blobstorage/vdisk/query/query_stattablet.cpp +++ b/ydb/core/blobstorage/vdisk/query/query_stattablet.cpp @@ -29,9 +29,9 @@ namespace NKikimr { TThis::Die(ctx); } - void ProcessBarriers(IOutputStream &str, ui64 tabletId, bool pretty); - void ProcessBlocks(IOutputStream &str, ui64 tabletId, bool pretty); - void ProcessLogoBlobs(IOutputStream &str, ui64 tabletId, bool pretty); + void ProcessBarriers(IOutputStream &str, ui64 tabletId, bool pretty); + void ProcessBlocks(IOutputStream &str, ui64 tabletId, bool pretty); + void ProcessLogoBlobs(IOutputStream &str, ui64 tabletId, bool pretty); public: static constexpr NKikimrServices::TActivity::EType ActorActivityType() { @@ -102,7 +102,7 @@ namespace NKikimr { }; using TMapType = TMap<TChannelLevel, TValue>; - IOutputStream &Str; + IOutputStream &Str; ui64 TabletId; bool Pretty; TMapType Map; @@ -266,7 +266,7 @@ namespace NKikimr { //////////////////////////////////////////////////////////////////////////// // TTabletStatActor::ProcessBarriers //////////////////////////////////////////////////////////////////////////// - void TTabletStatActor::ProcessBarriers(IOutputStream &str, ui64 tabletId, bool pretty) { + void TTabletStatActor::ProcessBarriers(IOutputStream &str, ui64 tabletId, bool pretty) { Y_UNUSED(pretty); // build barriers @@ -318,7 +318,7 @@ namespace NKikimr { //////////////////////////////////////////////////////////////////////////// // TTabletStatActor::ProcessBlocks //////////////////////////////////////////////////////////////////////////// - void TTabletStatActor::ProcessBlocks(IOutputStream &str, ui64 tabletId, bool pretty) { + void TTabletStatActor::ProcessBlocks(IOutputStream &str, ui64 tabletId, bool pretty) { Y_UNUSED(pretty); using TIndexForwardIterator = TBlocksSnapshot::TIndexForwardIterator; @@ -353,7 +353,7 @@ namespace NKikimr { //////////////////////////////////////////////////////////////////////////// // TTabletStatActor::ProcessLogoBlobs //////////////////////////////////////////////////////////////////////////// - void TTabletStatActor::ProcessLogoBlobs(IOutputStream &str, ui64 tabletId, bool pretty) { + void TTabletStatActor::ProcessLogoBlobs(IOutputStream &str, ui64 tabletId, bool pretty) { TAggr aggr(str, tabletId, pretty, TIngress::IngressMode(HullCtx->VCtx->Top->GType)); TraverseDbWithoutMerge(HullCtx, &aggr, FullSnap.LogoBlobsSnap); } diff --git a/ydb/core/blobstorage/vdisk/repl/blobstorage_hullrepljob.cpp b/ydb/core/blobstorage/vdisk/repl/blobstorage_hullrepljob.cpp index 3a95c22022f..607d0dc0478 100644 --- a/ydb/core/blobstorage/vdisk/repl/blobstorage_hullrepljob.cpp +++ b/ydb/core/blobstorage/vdisk/repl/blobstorage_hullrepljob.cpp @@ -575,7 +575,7 @@ namespace NKikimr { case EProcessQueueAction::Exit: return false; default: - Y_FAIL("invalid EProcessQueueAction"); + Y_FAIL("invalid EProcessQueueAction"); } } } @@ -606,12 +606,12 @@ namespace NKikimr { } if (Writer.GetState() == TReplSstStreamWriter::EState::STOPPED) { - Y_VERIFY(RecoveryQueue.empty()); + Y_VERIFY(RecoveryQueue.empty()); Finish(); return false; } - Y_FAIL("incorrect merger state State# %" PRIu32, ui32(Writer.GetState())); + Y_FAIL("incorrect merger state State# %" PRIu32, ui32(Writer.GetState())); } void Handle(TEvBlobStorage::TEvGetResult::TPtr ev) { @@ -648,7 +648,7 @@ namespace NKikimr { // we are already at in flight limit, do not accept more messages return EProcessQueueAction::Exit; } - Y_VERIFY(HugeBlobsInFlight < HugeBlobsInFlightMax); + Y_VERIFY(HugeBlobsInFlight < HugeBlobsInFlightMax); ++HugeBlobsInFlight; ++ReplCtx->MonGroup.ReplHugeBlobsRecovered(); @@ -669,7 +669,7 @@ namespace NKikimr { case TReplSstStreamWriter::EState::COLLECT: break; default: - Y_FAIL("unexpected State# %" PRIu32, static_cast<ui32>(Writer.GetState())); + Y_FAIL("unexpected State# %" PRIu32, static_cast<ui32>(Writer.GetState())); } if (Writer.AddRecoveredBlob(front)) { @@ -717,7 +717,7 @@ namespace NKikimr { (VDiskId, msg->VDiskId.ToString())); --NumRunningProxies; } else { - Y_VERIFY(proxy->Valid()); + Y_VERIFY(proxy->Valid()); MergeHeap.push_back(proxy); PushHeap(MergeHeap.begin(), MergeHeap.end(), TVDiskProxy::TPtrGreater()); } @@ -741,7 +741,7 @@ namespace NKikimr { void Handle(TEvBlobStorage::TEvVPutResult::TPtr& /*ev*/) { // FIXME: Handle NotOK // this message is received when huge blob is written by Skeleton - Y_VERIFY(HugeBlobsInFlight != 0); + Y_VERIFY(HugeBlobsInFlight != 0); --HugeBlobsInFlight; Merge(); } diff --git a/ydb/core/blobstorage/vdisk/repl/blobstorage_hullreplwritesst.h b/ydb/core/blobstorage/vdisk/repl/blobstorage_hullreplwritesst.h index f4f0e49015f..2224803e04b 100644 --- a/ydb/core/blobstorage/vdisk/repl/blobstorage_hullreplwritesst.h +++ b/ydb/core/blobstorage/vdisk/repl/blobstorage_hullreplwritesst.h @@ -57,7 +57,7 @@ namespace NKikimr { {} void Begin() { - Y_VERIFY(State == EState::STOPPED); + Y_VERIFY(State == EState::STOPPED); // ensure that we have no pending message and create new one to allocate some chunks for replicated SST Y_VERIFY(!PendingPDiskMsg); @@ -144,8 +144,8 @@ namespace NKikimr { } bool AddRecoveredBlob(TRecoveredBlobInfo& record) { - Y_VERIFY(State == EState::COLLECT); - Y_VERIFY(record.Id > PrevID); + Y_VERIFY(State == EState::COLLECT); + Y_VERIFY(record.Id > PrevID); Y_VERIFY(!record.Id.PartId()); // generate merged ingress for all locally recovered parts @@ -209,21 +209,21 @@ namespace NKikimr { } void Finish() { - Y_VERIFY(State == EState::COLLECT, "unexpected State# %" PRIu32, static_cast<ui32>(State)); + Y_VERIFY(State == EState::COLLECT, "unexpected State# %" PRIu32, static_cast<ui32>(State)); FlushNextPart(); } std::unique_ptr<TEvAddBulkSst> GetPendingCommitMsg() { - Y_VERIFY(State == EState::COMMIT_PENDING); + Y_VERIFY(State == EState::COMMIT_PENDING); std::unique_ptr<TEvAddBulkSst> msg; msg.swap(PendingCommitMsg); - Y_VERIFY(msg); + Y_VERIFY(msg); State = EState::WAITING_FOR_COMMIT; return msg; } void ApplyCommit() { - Y_VERIFY(State == EState::WAITING_FOR_COMMIT); + Y_VERIFY(State == EState::WAITING_FOR_COMMIT); State = EState::STOPPED; } diff --git a/ydb/core/blobstorage/vdisk/repl/blobstorage_repl.cpp b/ydb/core/blobstorage/vdisk/repl/blobstorage_repl.cpp index 34be219abce..42410c41265 100644 --- a/ydb/core/blobstorage/vdisk/repl/blobstorage_repl.cpp +++ b/ydb/core/blobstorage/vdisk/repl/blobstorage_repl.cpp @@ -40,7 +40,7 @@ namespace NKikimr { ReplicaOk, RecoveryScheduled, DataRecoverySuccess, DataRecoveryFailure); } - void TEvReplFinished::TInfo::OutputHtml(IOutputStream &str) const { + void TEvReplFinished::TInfo::OutputHtml(IOutputStream &str) const { #define PARAM(NAME, VALUE) TABLER() { \ TABLED() { str << #NAME; } \ TABLED() { str << VALUE; } \ @@ -412,7 +412,7 @@ namespace NKikimr { } template<typename Iter> - void OutputRow(IOutputStream &str, Iter &it, Iter &e) { + void OutputRow(IOutputStream &str, Iter &it, Iter &e) { HTML(str) { TABLER() { for (unsigned i = 0; i < 3 && it != e; i++, ++it) { @@ -423,7 +423,7 @@ namespace NKikimr { } template<typename Iter> - void OutputQuantums(IOutputStream& str, Iter it, Iter e) { + void OutputQuantums(IOutputStream& str, Iter it, Iter e) { if (it != e) { OutputRow(str, it, e); if (it != e) { @@ -444,7 +444,7 @@ namespace NKikimr { } void Handle(NMon::TEvHttpInfo::TPtr &ev) { - Y_VERIFY_DEBUG(ev->Get()->SubRequestId == TDbMon::ReplId); + Y_VERIFY_DEBUG(ev->Get()->SubRequestId == TDbMon::ReplId); TStringStream str; unsigned historySize = HistorySize; diff --git a/ydb/core/blobstorage/vdisk/repl/blobstorage_repl.h b/ydb/core/blobstorage/vdisk/repl/blobstorage_repl.h index 629d65bea97..d21ae9e91fb 100644 --- a/ydb/core/blobstorage/vdisk/repl/blobstorage_repl.h +++ b/ydb/core/blobstorage/vdisk/repl/blobstorage_repl.h @@ -74,7 +74,7 @@ namespace NKikimr { } TString ToString() const; - void OutputHtml(IOutputStream &str) const; + void OutputHtml(IOutputStream &str) const; TInfo(); ~TInfo(); @@ -101,7 +101,7 @@ namespace NKikimr { : Id(id) , Data(std::move(data)) { - Y_VERIFY_DEBUG(Id.PartId() != 0); + Y_VERIFY_DEBUG(Id.PartId() != 0); } size_t ByteSize() const { diff --git a/ydb/core/blobstorage/vdisk/repl/blobstorage_replproxy.cpp b/ydb/core/blobstorage/vdisk/repl/blobstorage_replproxy.cpp index 1f82e552bac..b08fa1dafbc 100644 --- a/ydb/core/blobstorage/vdisk/repl/blobstorage_replproxy.cpp +++ b/ydb/core/blobstorage/vdisk/repl/blobstorage_replproxy.cpp @@ -34,7 +34,7 @@ namespace NKikimr { {} TActorId TVDiskProxy::Run(const TActorId& parentId) { - Y_VERIFY_DEBUG(State == Initial); + Y_VERIFY_DEBUG(State == Initial); State = RunProxy; STLOG(PRI_DEBUG, BS_REPL, BSVR19, VDISKP(ReplCtx->VCtx->VDiskLogPrefix, "TVDiskProxy::Run")); ParentId = parentId; @@ -51,7 +51,7 @@ namespace NKikimr { if (State == RunProxy) { State = Ok; } - Y_VERIFY(State == Ok); + Y_VERIFY(State == Ok); HandlePortion(ev->Get()->Portion); Stat = ev->Get()->Stat; HasTransientErrors = HasTransientErrors || ev->Get()->HasTransientErrors; @@ -61,7 +61,7 @@ namespace NKikimr { switch (portion.Status) { case TNextPortion::Ok: State = Ok; - Y_VERIFY(portion.DataPortion.Valid()); + Y_VERIFY(portion.DataPortion.Valid()); break; case TNextPortion::Eof: State = Eof; @@ -70,10 +70,10 @@ namespace NKikimr { State = Error; break; default: - Y_FAIL("Unexpected value: %d", portion.Status); + Y_FAIL("Unexpected value: %d", portion.Status); } - Y_VERIFY(!DataPortion.Valid()); + Y_VERIFY(!DataPortion.Valid()); DataPortion = std::move(portion.DataPortion); } @@ -141,7 +141,7 @@ namespace NKikimr { Recipient = parentId; // ensure we have LogoBlobs to fetch - Y_VERIFY(!Ids.empty()); + Y_VERIFY(!Ids.empty()); // send initial request Become(&TThis::StateFunc); @@ -165,7 +165,7 @@ namespace NKikimr { } // prepare a set of extreme queries - Y_VERIFY(SendIdx < Ids.size()); + Y_VERIFY(SendIdx < Ids.size()); ui32 numIDsRemain = Min<size_t>(Ids.size() - SendIdx, ReplCtx->VDiskCfg->ReplRequestElements); ui32 responseSize = 0; ui64 bytes = 0; @@ -210,7 +210,7 @@ namespace NKikimr { STLOG(PRI_DEBUG, BS_REPL, BSVR22, VDISKP(ReplCtx->VCtx->VDiskLogPrefix, "TVDiskProxyActor::Handle(TEvReplProxyNext)")); // increase number of unsatisfied TEvReplProxyNext requests by one more request - Y_VERIFY(!RequestFromVDiskProxyPending); + Y_VERIFY(!RequestFromVDiskProxyPending); RequestFromVDiskProxyPending = true; // try to resolve this request via prefetch @@ -243,7 +243,7 @@ namespace NKikimr { void PutResponseQueueItem(TNextPortion&& portion) { // we consider ourself finished when last status is either EOF or ERROR; such response must be ultimately last - Y_VERIFY(!Finished); + Y_VERIFY(!Finished); Finished = portion.Status != TNextPortion::Ok; // update prefetch cumulative data size @@ -326,7 +326,7 @@ namespace NKikimr { Y_VERIFY(cookie == NextReceiveCookie); ++NextReceiveCookie; - Y_VERIFY(RequestsInFlight > 0); + Y_VERIFY(RequestsInFlight > 0); --RequestsInFlight; // ignore any further results if already finished @@ -375,7 +375,7 @@ namespace NKikimr { const NKikimrBlobStorage::TQueryResult &q = rec.GetResult(i); ui64 cookie = q.GetCookie(); - Y_VERIFY(cookie == CurPosIdx || (CurPosIdx && cookie == CurPosIdx - 1), + Y_VERIFY(cookie == CurPosIdx || (CurPosIdx && cookie == CurPosIdx - 1), "i# %" PRIu32 " cookie# %" PRIu64 " CurPosIdx %" PRIu32, i, cookie, CurPosIdx); @@ -414,7 +414,7 @@ namespace NKikimr { } } } - Y_VERIFY(CurPosIdx <= Ids.size()); + Y_VERIFY(CurPosIdx <= Ids.size()); if (CurPosIdx == Ids.size()) portion.Status = TNextPortion::Eof; diff --git a/ydb/core/blobstorage/vdisk/repl/blobstorage_replproxy.h b/ydb/core/blobstorage/vdisk/repl/blobstorage_replproxy.h index e05f54cd079..854263b06f3 100644 --- a/ydb/core/blobstorage/vdisk/repl/blobstorage_replproxy.h +++ b/ydb/core/blobstorage/vdisk/repl/blobstorage_replproxy.h @@ -76,17 +76,17 @@ namespace NKikimr { //////////////////////////////////////////////////////////////////////////////// void Add(const TLogoBlobID& logoBlobId, TString&& data) { - Y_VERIFY_DEBUG(FrontPos == 0); + Y_VERIFY_DEBUG(FrontPos == 0); Items.emplace_back(TMemoryConsumer(Consumer), logoBlobId, NKikimrProto::OK, std::move(data)); } void AddError(const TLogoBlobID& logoBlobId, NKikimrProto::EReplyStatus status) { - Y_VERIFY_DEBUG(FrontPos == 0); + Y_VERIFY_DEBUG(FrontPos == 0); Items.emplace_back(TMemoryConsumer(Consumer), logoBlobId, status, TString()); } void Append(TDataPortion&& from) { - Y_VERIFY_DEBUG(FrontPos == 0); + Y_VERIFY_DEBUG(FrontPos == 0); if (Items.empty()) { Items = std::move(from.Items); } else { @@ -113,7 +113,7 @@ namespace NKikimr { } void GetFrontItem(TLogoBlobID *logoBlobId, NKikimrProto::EReplyStatus *status, TTrackableString *data) const { - Y_VERIFY_DEBUG(FrontPos < Items.size()); + Y_VERIFY_DEBUG(FrontPos < Items.size()); const TDataElement& elem = Items[FrontPos]; *logoBlobId = elem.LogoBlobId; *status = elem.Status; @@ -121,17 +121,17 @@ namespace NKikimr { } void GetFrontItem(TLogoBlobID *logoBlobId) const { - Y_VERIFY_DEBUG(FrontPos < Items.size()); + Y_VERIFY_DEBUG(FrontPos < Items.size()); *logoBlobId = Items[FrontPos].LogoBlobId; } bool Valid() const { - Y_VERIFY_DEBUG(FrontPos <= Items.size()); + Y_VERIFY_DEBUG(FrontPos <= Items.size()); return FrontPos != Items.size(); } void Next() { - Y_VERIFY_DEBUG(FrontPos < Items.size()); + Y_VERIFY_DEBUG(FrontPos < Items.size()); Items[FrontPos].Reset(); ++FrontPos; } @@ -272,7 +272,7 @@ namespace NKikimr { public: void Put(const TLogoBlobID &id, ui32 expectedReplySize) { - Y_VERIFY_DEBUG(State == Initial); + Y_VERIFY_DEBUG(State == Initial); Ids.emplace_back(id, expectedReplySize); } @@ -295,7 +295,7 @@ namespace NKikimr { // IsEof(): returns true on EOF condition, i.e. when there is no more data exists in buffer and // no more data is expected in future bool IsEof() const { - Y_VERIFY_DEBUG(State == Ok || State == Eof || State == Error); + Y_VERIFY_DEBUG(State == Ok || State == Eof || State == Error); return (State == Error || State == Eof) && !DataPortion.Valid(); } @@ -326,7 +326,7 @@ namespace NKikimr { public: struct TPtrGreater { bool operator() (const TVDiskProxyPtr &x, const TVDiskProxyPtr &y) const { - Y_VERIFY_DEBUG(x->Valid() && y->Valid()); + Y_VERIFY_DEBUG(x->Valid() && y->Valid()); return x->GenLogoBlobId() > y->GenLogoBlobId(); } }; diff --git a/ydb/core/blobstorage/vdisk/repl/blobstorage_replrecoverymachine_ut.cpp b/ydb/core/blobstorage/vdisk/repl/blobstorage_replrecoverymachine_ut.cpp index 3ff7efb53e2..178be426759 100644 --- a/ydb/core/blobstorage/vdisk/repl/blobstorage_replrecoverymachine_ut.cpp +++ b/ydb/core/blobstorage/vdisk/repl/blobstorage_replrecoverymachine_ut.cpp @@ -7,7 +7,7 @@ namespace NKikimr { - Y_UNIT_TEST_SUITE(TBlobStorageReplRecoveryMachine) { + Y_UNIT_TEST_SUITE(TBlobStorageReplRecoveryMachine) { TMap<TLogoBlobID, TVector<TString>> GenerateData(ui32 numBlobs, ui32 maxLen, diff --git a/ydb/core/blobstorage/vdisk/skeleton/blobstorage_monactors.cpp b/ydb/core/blobstorage/vdisk/skeleton/blobstorage_monactors.cpp index 44b3c58c9c4..2a30c02f058 100644 --- a/ydb/core/blobstorage/vdisk/skeleton/blobstorage_monactors.cpp +++ b/ydb/core/blobstorage/vdisk/skeleton/blobstorage_monactors.cpp @@ -137,7 +137,7 @@ namespace NKikimr { } } - void Output(const TString &html, IOutputStream &str, const char *name) { + void Output(const TString &html, IOutputStream &str, const char *name) { if (!html.empty()) str << html; else @@ -177,9 +177,9 @@ namespace NKikimr { } void Handle(NMon::TEvHttpInfoRes::TPtr &ev, const TActorContext &ctx) { - Y_VERIFY_DEBUG(Counter > 0); + Y_VERIFY_DEBUG(Counter > 0); NMon::TEvHttpInfoRes *ptr = dynamic_cast<NMon::TEvHttpInfoRes*>(ev->Get()); - Y_VERIFY_DEBUG(ptr); + Y_VERIFY_DEBUG(ptr); static const std::unordered_map<int, TString TThis::*> names{ {TDbMon::SkeletonStateId, &TThis::SkeletonState}, @@ -387,7 +387,7 @@ namespace NKikimr { req = TEvBlobStorage::TEvVGet::CreateRangeIndexQuery(SelfVDiskId, TInstant::Max(), NKikimrBlobStorage::EGetHandleClass::AsyncRead, flags, {}, From, To, 15); } else - Y_FAIL("Unknown button"); + Y_FAIL("Unknown button"); if (req) { req->SetIsLocalMon(); @@ -401,7 +401,7 @@ namespace NKikimr { Become(&TThis::StateFunc); } - void OutputOneQueryResult(IOutputStream &str, const NKikimrBlobStorage::TQueryResult &q) { + void OutputOneQueryResult(IOutputStream &str, const NKikimrBlobStorage::TQueryResult &q) { HTML(str) { DIV_CLASS("well well-small") { const TLogoBlobID id = LogoBlobIDFromLogoBlobID(q.GetBlobID()); @@ -590,7 +590,7 @@ namespace NKikimr { Become(&TThis::StateFunc); } - void OutputOneResult(IOutputStream &str, const NKikimrBlobStorage::TBarrierKey &k, + void OutputOneResult(IOutputStream &str, const NKikimrBlobStorage::TBarrierKey &k, const NKikimrBlobStorage::TBarrierVal &v) { TIngressCachePtr ingressCache = TIngressCache::Create(Top, SelfVDiskId); HTML(str) { @@ -685,7 +685,7 @@ namespace NKikimr { , IsRangeQuery(false) , ShowInternals(false) { - Y_UNUSED(ShowInternals); + Y_UNUSED(ShowInternals); } }; @@ -919,7 +919,7 @@ namespace NKikimr { } } - void Output(const TString &html, IOutputStream &str, const char *name) { + void Output(const TString &html, IOutputStream &str, const char *name) { if (!html.empty()) str << html; else @@ -944,8 +944,8 @@ namespace NKikimr { void Handle(NMon::TEvHttpInfoRes::TPtr &ev, const TActorContext &ctx) { NMon::TEvHttpInfoRes *ptr = dynamic_cast<NMon::TEvHttpInfoRes*>(ev->Get()); - Y_VERIFY_DEBUG(ptr); - Y_VERIFY_DEBUG(ptr->SubRequestId == 0); + Y_VERIFY_DEBUG(ptr); + Y_VERIFY_DEBUG(ptr->SubRequestId == 0); SkeletonAnswer = ptr->Answer; Finish(ctx); } diff --git a/ydb/core/blobstorage/vdisk/skeleton/blobstorage_skeleton.cpp b/ydb/core/blobstorage/vdisk/skeleton/blobstorage_skeleton.cpp index 96b813d3172..360f2560b4e 100644 --- a/ydb/core/blobstorage/vdisk/skeleton/blobstorage_skeleton.cpp +++ b/ydb/core/blobstorage/vdisk/skeleton/blobstorage_skeleton.cpp @@ -1544,7 +1544,7 @@ namespace NKikimr { } TString data; bool res = record.SerializeToString(&data); - Y_VERIFY(res); + Y_VERIFY(res); intptr_t loggedRecId = LoggedRecsVault.Put(new TLoggedRecPhantoms(seg, true, ev)); void *loggedRecCookie = reinterpret_cast<void *>(loggedRecId); @@ -1917,7 +1917,7 @@ namespace NKikimr { } } - void RenderState(IOutputStream &str, const TActorContext &ctx) { + void RenderState(IOutputStream &str, const TActorContext &ctx) { constexpr ui32 threshold = 10000u; std::pair<ui32, ui32> actorQueues = ctx.CountMailboxEvents(threshold); diff --git a/ydb/core/blobstorage/vdisk/skeleton/blobstorage_skeletonfront.cpp b/ydb/core/blobstorage/vdisk/skeleton/blobstorage_skeletonfront.cpp index 08c32a8921e..943bde26378 100644 --- a/ydb/core/blobstorage/vdisk/skeleton/blobstorage_skeletonfront.cpp +++ b/ydb/core/blobstorage/vdisk/skeleton/blobstorage_skeletonfront.cpp @@ -205,7 +205,7 @@ namespace NKikimr { const NBackpressure::TMessageId &msgId, ui64 cost, const TInstant &deadline, NKikimrBlobStorage::EVDiskQueueId extQueueId, TFront& front, const NBackpressure::TQueueClientId& clientId) { - Y_UNUSED(front); + Y_UNUSED(front); if (!Queue->Head() && CanSendToSkeleton(cost)) { // send to Skeleton for further processing ctx.ExecutorThread.Send(converted.release()); @@ -244,7 +244,7 @@ namespace NKikimr { const ui64 cost = rec->Cost; if (CanSendToSkeleton(cost) || forceError) { ui32 recByteSize = rec->ByteSize; - Y_VERIFY_DEBUG(DelayedCount > 0 && DelayedBytes >= recByteSize); + Y_VERIFY_DEBUG(DelayedCount > 0 && DelayedBytes >= recByteSize); --DelayedCount; DelayedBytes -= recByteSize; @@ -351,7 +351,7 @@ namespace NKikimr { // val -- current value // if val is greater than maxVal, output current record in 'light' color void OutputRecord(const char *name, - IOutputStream &str, + IOutputStream &str, ui64 val, NKikimrWhiteboard::EFlag light) const { if (light != NKikimrWhiteboard::EFlag::Green) { @@ -626,7 +626,7 @@ namespace NKikimr { template <class T> void NotifyIfNotReady(T &ev, const TActorContext &ctx) { - Y_UNUSED(ctx); + Y_UNUSED(ctx); if (ev->Get()->Record.GetNotifyIfNotReady()) { NotificationIDs.insert(ev->Sender); } @@ -929,7 +929,7 @@ namespace NKikimr { template <class TEventPtr> inline void CheckEvent(TEventPtr &ev, const char *msgName) { - Y_VERIFY_DEBUG(CostModel); + Y_VERIFY_DEBUG(CostModel); Y_VERIFY(ev->Get(), "Incoming message of type %s is null at the VDisk border. This MUST never happens, " "check VDisk clients: bufSize# %u", msgName, unsigned(ev->GetSize())); } @@ -1037,7 +1037,7 @@ namespace NKikimr { // we don't work if queues are incompatible bool compatible = Compatible(extQueueId, intQueueId); - Y_VERIFY(compatible, "%s: %s: extQueue is incompatible with intQueue; intQueue# %s extQueue# %s", + Y_VERIFY(compatible, "%s: %s: extQueue is incompatible with intQueue; intQueue# %s extQueue# %s", VCtx->VDiskLogPrefix.data(), msgName, NKikimrBlobStorage::EVDiskInternalQueueId_Name(intQueueId).data(), NKikimrBlobStorage::EVDiskQueueId_Name(extQueueId).data()); @@ -1506,7 +1506,7 @@ namespace NKikimr { case NKikimrBlobStorage::EVDiskInternalQueueId::IntPutHugeBackground: intQueue = IntQueueHugePutsBackground.get(); break; - default: Y_FAIL("Unexpected case"); + default: Y_FAIL("Unexpected case"); } return *intQueue; } @@ -1797,7 +1797,7 @@ namespace NKikimr { HFuncStatus(TEvBlobStorage::TEvVGetBlock, status, errorReason, now, wstatus); HFuncStatus(TEvBlobStorage::TEvVCollectGarbage, status, errorReason, now, wstatus); HFuncStatus(TEvBlobStorage::TEvVGetBarrier, status, errorReason, now, wstatus); - default: Y_VERIFY_DEBUG(false, "Unsupported message %d", ev->GetTypeRewrite()); + default: Y_VERIFY_DEBUG(false, "Unsupported message %d", ev->GetTypeRewrite()); } } diff --git a/ydb/core/blobstorage/vdisk/skeleton/blobstorage_syncfull.cpp b/ydb/core/blobstorage/vdisk/skeleton/blobstorage_syncfull.cpp index 5881368772c..fe498bdf1ad 100644 --- a/ydb/core/blobstorage/vdisk/skeleton/blobstorage_syncfull.cpp +++ b/ydb/core/blobstorage/vdisk/skeleton/blobstorage_syncfull.cpp @@ -56,7 +56,7 @@ namespace NKikimr { TString *buf, const TKeyLogoBlob &key, const TMemRecLogoBlob &memRec) { - Y_UNUSED(ctx); + Y_UNUSED(ctx); char tmpBuf[NSyncLog::MaxRecFullSize]; auto s = NSyncLog::TSerializeRoutines::SetLogoBlob; ui32 size = s(HullCtx->VCtx->Top->GType, tmpBuf, 0, key.LogoBlobID(), memRec.GetIngress()); @@ -67,7 +67,7 @@ namespace NKikimr { TString *buf, const TKeyBlock &key, const TMemRecBlock &memRec) { - Y_UNUSED(ctx); + Y_UNUSED(ctx); char tmpBuf[NSyncLog::MaxRecFullSize]; auto s = NSyncLog::TSerializeRoutines::SetBlock; ui32 size = s(tmpBuf, 0, key.TabletId, memRec.BlockedGeneration, 0); @@ -78,7 +78,7 @@ namespace NKikimr { TString *buf, const TKeyBarrier &key, const TMemRecBarrier &memRec) { - Y_UNUSED(ctx); + Y_UNUSED(ctx); char tmpBuf[NSyncLog::MaxRecFullSize]; auto s = NSyncLog::TSerializeRoutines::SetBarrier; ui32 size = s(tmpBuf, 0, key.TabletId, key.Channel, key.Gen, @@ -113,7 +113,7 @@ namespace NKikimr { Stage = NKikimrBlobStorage::Barriers; pres = Process(ctx, FullSnap.BarriersSnap, KeyBarrier, FakeFilter); break; - default: Y_FAIL("Unexpected case: stage=%d", Stage); + default: Y_FAIL("Unexpected case: stage=%d", Stage); } bool finished = (bool)(pres & EmptyFlag) && Stage == NKikimrBlobStorage::Barriers; diff --git a/ydb/core/blobstorage/vdisk/syncer/blobstorage_syncer.cpp b/ydb/core/blobstorage/vdisk/syncer/blobstorage_syncer.cpp index bf0179b4ed9..ee6a56501e3 100644 --- a/ydb/core/blobstorage/vdisk/syncer/blobstorage_syncer.cpp +++ b/ydb/core/blobstorage/vdisk/syncer/blobstorage_syncer.cpp @@ -417,7 +417,7 @@ namespace NKikimr { } } - void LogAndPhaseToHtml(IOutputStream &str) const { + void LogAndPhaseToHtml(IOutputStream &str) const { HTML(str) { DIV_CLASS("row") { str << "Phase: "; diff --git a/ydb/core/blobstorage/vdisk/syncer/blobstorage_syncer_data.cpp b/ydb/core/blobstorage/vdisk/syncer/blobstorage_syncer_data.cpp index 4de7b60fbe8..f65cfd67eee 100644 --- a/ydb/core/blobstorage/vdisk/syncer/blobstorage_syncer_data.cpp +++ b/ydb/core/blobstorage/vdisk/syncer/blobstorage_syncer_data.cpp @@ -18,7 +18,7 @@ namespace NKikimr { : SchTime(TAppData::TimeProvider->Now()) {} - void TPeerSyncState::Serialize(IOutputStream &s) const { + void TPeerSyncState::Serialize(IOutputStream &s) const { i32 status = (i32)LastSyncStatus; s.Write(&status, sizeof(status)); SyncState.Serialize(s); @@ -66,7 +66,7 @@ namespace NKikimr { return str.Str(); } - void TPeerSyncState::OutputHtml(IOutputStream &str) const { + void TPeerSyncState::OutputHtml(IOutputStream &str) const { HTML(str) { ESyncStatus state = LastSyncStatus; if (NSyncer::TPeerSyncState::Good(state)) { @@ -107,7 +107,7 @@ namespace NKikimr { return str.Str(); } - void TPeerGuidInfo::OutputHtml(IOutputStream &str) const { + void TPeerGuidInfo::OutputHtml(IOutputStream &str) const { HTML(str) { SMALL() { SMALL() { @@ -124,7 +124,7 @@ namespace NKikimr { // TPeer // We manage this structure for every disk in the group //////////////////////////////////////////////////////////////////////////// - void TPeer::Serialize(IOutputStream &s) const { + void TPeer::Serialize(IOutputStream &s) const { PeerSyncState.Serialize(s); // we don't serialize PeerGuidInfo because we can't do it in old format } @@ -151,7 +151,7 @@ namespace NKikimr { return str.Str(); } - void TPeer::OutputHtml(IOutputStream &str) const { + void TPeer::OutputHtml(IOutputStream &str) const { PeerSyncState.OutputHtml(str); PeerGuidInfo.OutputHtml(str); } @@ -171,12 +171,12 @@ namespace NKikimr { , QuorumTracker(self, top, false) {} - void TSyncNeighbors::OldSerialize(IOutputStream &str, const TBlobStorageGroupInfo *info) const { + void TSyncNeighbors::OldSerialize(IOutputStream &str, const TBlobStorageGroupInfo *info) const { TOldSer ser(str, info); Neighbors.GenericSerialize(ser); } - void TSyncNeighbors::Serialize(IOutputStream &str, const TBlobStorageGroupInfo *info) const { + void TSyncNeighbors::Serialize(IOutputStream &str, const TBlobStorageGroupInfo *info) const { TSer ser(str, info); Neighbors.GenericSerialize(ser); } @@ -186,7 +186,7 @@ namespace NKikimr { Neighbors.GenericSerialize(ser); } - void TSyncNeighbors::OldParse(IInputStream &str) { + void TSyncNeighbors::OldParse(IInputStream &str) { TOldDes des(str); Neighbors.GenericParse(des); } @@ -197,7 +197,7 @@ namespace NKikimr { OldParse(str); } - void TSyncNeighbors::Parse(IInputStream &str) { + void TSyncNeighbors::Parse(IInputStream &str) { TDes des(str); Neighbors.GenericParse(des); } diff --git a/ydb/core/blobstorage/vdisk/syncer/blobstorage_syncer_data.h b/ydb/core/blobstorage/vdisk/syncer/blobstorage_syncer_data.h index c623859a60c..791c09e5b58 100644 --- a/ydb/core/blobstorage/vdisk/syncer/blobstorage_syncer_data.h +++ b/ydb/core/blobstorage/vdisk/syncer/blobstorage_syncer_data.h @@ -50,12 +50,12 @@ namespace NKikimr { TInstant LastGood = {}; TPeerSyncState(); - void Serialize(IOutputStream &s) const; + void Serialize(IOutputStream &s) const; void ParseFromArcadiaStream(IInputStream &str); void Serialize(NKikimrVDiskData::TSyncerVDiskEntry &pb) const; void Parse(const NKikimrVDiskData::TSyncerVDiskEntry &pb); TString ToString() const; - void OutputHtml(IOutputStream &str) const; + void OutputHtml(IOutputStream &str) const; static bool Good(ESyncStatus status) { return status == TSyncStatusVal::SyncDone || @@ -74,7 +74,7 @@ namespace NKikimr { void Serialize(NKikimrVDiskData::TSyncerVDiskEntry &pb) const; void Parse(const NKikimrVDiskData::TSyncerVDiskEntry &pb); TString ToString() const; - void OutputHtml(IOutputStream &str) const; + void OutputHtml(IOutputStream &str) const; }; //////////////////////////////////////////////////////////////////////////// @@ -87,12 +87,12 @@ namespace NKikimr { TPeerSyncState PeerSyncState; TPeerGuidInfo PeerGuidInfo; - void Serialize(IOutputStream &s) const; + void Serialize(IOutputStream &s) const; void ParseFromArcadiaStream(IInputStream &str); void Serialize(NKikimrVDiskData::TSyncerVDiskEntry &pb) const; void Parse(const NKikimrVDiskData::TSyncerVDiskEntry &pb); TString ToString() const; - void OutputHtml(IOutputStream &str) const; + void OutputHtml(IOutputStream &str) const; }; } // NSyncer @@ -134,7 +134,7 @@ namespace NKikimr { const TValue &operator [](const TVDiskIdShort &vdisk) const { return Neighbors[vdisk]; } template <class TPrinter> - void OutputHtml(IOutputStream &str, + void OutputHtml(IOutputStream &str, TPrinter &printer, const TString &name, const TString &divClass) const { @@ -142,7 +142,7 @@ namespace NKikimr { } template <class TPrinter> - void OutputHtmlTable(IOutputStream &str, TPrinter &printer) const { + void OutputHtmlTable(IOutputStream &str, TPrinter &printer) const { Neighbors.OutputHtmlTable<TPrinter>(str, printer); } @@ -150,12 +150,12 @@ namespace NKikimr { class TOldDes; class TSer; class TDes; - void OldSerialize(IOutputStream &str, const TBlobStorageGroupInfo *info) const; - void OldParse(IInputStream &str); + void OldSerialize(IOutputStream &str, const TBlobStorageGroupInfo *info) const; + void OldParse(IInputStream &str); void OldParse(const TString &data); - void Serialize(IOutputStream &str, const TBlobStorageGroupInfo *info) const; + void Serialize(IOutputStream &str, const TBlobStorageGroupInfo *info) const; void Serialize(NKikimrVDiskData::TSyncerEntryPoint *pb, const TBlobStorageGroupInfo *info) const; - void Parse(IInputStream &str); + void Parse(IInputStream &str); void Parse(const TString &data); void Parse(const NKikimrVDiskData::TSyncerEntryPoint &pb); void ApplyChanges(const TActorContext &ctx, diff --git a/ydb/core/blobstorage/vdisk/syncer/blobstorage_syncer_data_ut.cpp b/ydb/core/blobstorage/vdisk/syncer/blobstorage_syncer_data_ut.cpp index 0da0c427ee3..f88eeb39056 100644 --- a/ydb/core/blobstorage/vdisk/syncer/blobstorage_syncer_data_ut.cpp +++ b/ydb/core/blobstorage/vdisk/syncer/blobstorage_syncer_data_ut.cpp @@ -6,7 +6,7 @@ using namespace NKikimr; using namespace NSync; -Y_UNIT_TEST_SUITE(TSyncNeighborsTests) { +Y_UNIT_TEST_SUITE(TSyncNeighborsTests) { template<typename... TArgs> void SerDes(TArgs&&... args) { @@ -48,15 +48,15 @@ Y_UNIT_TEST_SUITE(TSyncNeighborsTests) { } } - Y_UNIT_TEST(SerDes1) { + Y_UNIT_TEST(SerDes1) { SerDes(TBlobStorageGroupType::ErasureMirror3, 2U, 4U); } - Y_UNIT_TEST(SerDes2) { + Y_UNIT_TEST(SerDes2) { SerDes(TBlobStorageGroupType::Erasure4Plus2Block, 1U, 8U); } - Y_UNIT_TEST(SerDes3) { + Y_UNIT_TEST(SerDes3) { SerDes(TBlobStorageGroupType::Erasure4Plus2Block, 2U, 8U); } } diff --git a/ydb/core/blobstorage/vdisk/syncer/blobstorage_syncer_dataserdes.h b/ydb/core/blobstorage/vdisk/syncer/blobstorage_syncer_dataserdes.h index 0ba1623666b..56a020ff7bd 100644 --- a/ydb/core/blobstorage/vdisk/syncer/blobstorage_syncer_dataserdes.h +++ b/ydb/core/blobstorage/vdisk/syncer/blobstorage_syncer_dataserdes.h @@ -11,7 +11,7 @@ namespace NKikimr { // TODO: remove it after migration to the new format class TSyncNeighbors::TOldSer { public: - TOldSer(IOutputStream &str, const TBlobStorageGroupInfo *info) + TOldSer(IOutputStream &str, const TBlobStorageGroupInfo *info) : Str(str) , Info(info) {} @@ -25,7 +25,7 @@ namespace NKikimr { void Finish() {} private: - IOutputStream &Str; + IOutputStream &Str; const TBlobStorageGroupInfo *Info; }; @@ -34,7 +34,7 @@ namespace NKikimr { //////////////////////////////////////////////////////////////////////////// class TSyncNeighbors::TOldDes { public: - TOldDes(IInputStream &str) + TOldDes(IInputStream &str) : Str(str) {} @@ -57,7 +57,7 @@ namespace NKikimr { ui32 GetGroupGeneration() const { return GroupGeneration; } private: - IInputStream &Str; + IInputStream &Str; ui32 GroupId = 0; ui32 GroupGeneration = 0; }; @@ -68,7 +68,7 @@ namespace NKikimr { //////////////////////////////////////////////////////////////////////////// class TSyncNeighbors::TSer { public: - TSer(IOutputStream &str, const TBlobStorageGroupInfo *info) + TSer(IOutputStream &str, const TBlobStorageGroupInfo *info) : LocalProto() , Proto(&LocalProto) , Str(&str) @@ -76,7 +76,7 @@ namespace NKikimr { , GroupGeneration(info->GroupGeneration) {} - TSer(IOutputStream &str, ui32 groupId, ui32 groupGen) + TSer(IOutputStream &str, ui32 groupId, ui32 groupGen) : LocalProto() , Proto(&LocalProto) , Str(&str) @@ -107,7 +107,7 @@ namespace NKikimr { private: NKikimrVDiskData::TSyncerEntryPoint LocalProto; NKikimrVDiskData::TSyncerEntryPoint *Proto = nullptr; - IOutputStream *Str = nullptr; + IOutputStream *Str = nullptr; ui32 GroupId = 0; ui32 GroupGeneration = 0; }; @@ -118,7 +118,7 @@ namespace NKikimr { //////////////////////////////////////////////////////////////////////////// class TSyncNeighbors::TDes { public: - TDes(IInputStream &str) + TDes(IInputStream &str) : Proto(&LocalProto) { auto res = LocalProto.ParseFromArcadiaStream(&str); diff --git a/ydb/core/blobstorage/vdisk/syncer/blobstorage_syncer_defs.h b/ydb/core/blobstorage/vdisk/syncer/blobstorage_syncer_defs.h index 49f82ab9f72..f1f0892a123 100644 --- a/ydb/core/blobstorage/vdisk/syncer/blobstorage_syncer_defs.h +++ b/ydb/core/blobstorage/vdisk/syncer/blobstorage_syncer_defs.h @@ -32,7 +32,7 @@ namespace NKikimr { , DbBirthLsn(dbBirthLsn) {} - void Output(IOutputStream &str) const { + void Output(IOutputStream &str) const { str << "[State# " << State << " Guid# " << Guid << " DbBirthLsn# " << DbBirthLsn << "]"; diff --git a/ydb/core/blobstorage/vdisk/syncer/blobstorage_syncer_scheduler.cpp b/ydb/core/blobstorage/vdisk/syncer/blobstorage_syncer_scheduler.cpp index 92ae94e89f7..b17944a3bbd 100644 --- a/ydb/core/blobstorage/vdisk/syncer/blobstorage_syncer_scheduler.cpp +++ b/ydb/core/blobstorage/vdisk/syncer/blobstorage_syncer_scheduler.cpp @@ -41,7 +41,7 @@ namespace NKikimr { , NodesInfo(nodesInfo) {} - void operator() (IOutputStream &str, TSyncNeighbors::TConstIterator it) { + void operator() (IOutputStream &str, TSyncNeighbors::TConstIterator it) { HTML(str) { SMALL() { STRONG() { @@ -299,7 +299,7 @@ namespace NKikimr { } void Handle(NMon::TEvHttpInfo::TPtr &ev, const TActorContext &ctx) { - Y_VERIFY_DEBUG(ev->Get()->SubRequestId == TDbMon::SyncerInfoId); + Y_VERIFY_DEBUG(ev->Get()->SubRequestId == TDbMon::SyncerInfoId); // create an actor to handle request auto actor = std::make_unique<TSyncerSchedulerHttpActor>(SyncerContext, GInfo, SyncerData, ev, ctx.SelfID); auto aid = ctx.RegisterWithSameMailbox(actor.release()); diff --git a/ydb/core/blobstorage/vdisk/syncer/blobstorage_syncquorum.h b/ydb/core/blobstorage/vdisk/syncer/blobstorage_syncquorum.h index 5d53a289ce0..98381c6f6ad 100644 --- a/ydb/core/blobstorage/vdisk/syncer/blobstorage_syncquorum.h +++ b/ydb/core/blobstorage/vdisk/syncer/blobstorage_syncquorum.h @@ -64,7 +64,7 @@ namespace NKikimr { SyncedDisks = TBlobStorageGroupInfo::TGroupVDisks(Top.get()); } - void Output(IOutputStream &str) const { + void Output(IOutputStream &str) const { str << "{Debug# " << Debug.ToString() << "}"; } diff --git a/ydb/core/blobstorage/vdisk/syncer/blobstorage_syncquorum_ut.cpp b/ydb/core/blobstorage/vdisk/syncer/blobstorage_syncquorum_ut.cpp index 78e25633ab3..f98620723f9 100644 --- a/ydb/core/blobstorage/vdisk/syncer/blobstorage_syncquorum_ut.cpp +++ b/ydb/core/blobstorage/vdisk/syncer/blobstorage_syncquorum_ut.cpp @@ -1,7 +1,7 @@ #include "blobstorage_syncquorum.h" #include <library/cpp/testing/unittest/registar.h> #include <util/random/shuffle.h> -#include <util/stream/null.h> +#include <util/stream/null.h> #define STR Cnull @@ -9,7 +9,7 @@ using namespace NKikimr::NSync; namespace NKikimr { - Y_UNIT_TEST_SUITE(TQuorumTrackerTests) { + Y_UNIT_TEST_SUITE(TQuorumTrackerTests) { TVector<TVDiskID> GetDisks(TBlobStorageGroupInfo *groupInfo) { TVector<TVDiskID> vdisks; @@ -33,7 +33,7 @@ namespace NKikimr { UNIT_ASSERT(tracker.HasQuorum()); } - Y_UNIT_TEST(ErasureNoneNeverHasQuorum_4_1) { + Y_UNIT_TEST(ErasureNoneNeverHasQuorum_4_1) { TBlobStorageGroupInfo groupInfo(TBlobStorageGroupType::ErasureNone, 1, 4); auto vdisks = GetDisks(&groupInfo); @@ -49,7 +49,7 @@ namespace NKikimr { UNIT_ASSERT(!tracker.HasQuorum()); } - Y_UNIT_TEST(Erasure4Plus2BlockIncludingMyFailDomain_8_2) { + Y_UNIT_TEST(Erasure4Plus2BlockIncludingMyFailDomain_8_2) { TBlobStorageGroupInfo groupInfo(TBlobStorageGroupType::Erasure4Plus2Block, 2, 8); auto vdisks = GetDisks(&groupInfo); @@ -66,7 +66,7 @@ namespace NKikimr { } } - Y_UNIT_TEST(Erasure4Plus2BlockNotIncludingMyFailDomain_8_2) { + Y_UNIT_TEST(Erasure4Plus2BlockNotIncludingMyFailDomain_8_2) { TBlobStorageGroupInfo groupInfo(TBlobStorageGroupType::Erasure4Plus2Block, 2, 8); auto vdisks = GetDisks(&groupInfo); @@ -83,7 +83,7 @@ namespace NKikimr { } } - Y_UNIT_TEST(ErasureMirror3IncludingMyFailDomain_4_2) { + Y_UNIT_TEST(ErasureMirror3IncludingMyFailDomain_4_2) { TBlobStorageGroupInfo groupInfo(TBlobStorageGroupType::ErasureMirror3, 2, 4); auto vdisks = GetDisks(&groupInfo); const TVDiskID& self = vdisks[0]; @@ -93,7 +93,7 @@ namespace NKikimr { Check(tracker, vdisks, notYetQuorum, 6); } - Y_UNIT_TEST(ErasureMirror3IncludingMyFailDomain_5_2) { + Y_UNIT_TEST(ErasureMirror3IncludingMyFailDomain_5_2) { TBlobStorageGroupInfo groupInfo(TBlobStorageGroupType::ErasureMirror3, 2, 5); auto vdisks = GetDisks(&groupInfo); const TVDiskID& self = vdisks[0]; diff --git a/ydb/core/blobstorage/vdisk/syncer/guid_proxyobtain.h b/ydb/core/blobstorage/vdisk/syncer/guid_proxyobtain.h index 6ee396c2850..6e72a90fc73 100644 --- a/ydb/core/blobstorage/vdisk/syncer/guid_proxyobtain.h +++ b/ydb/core/blobstorage/vdisk/syncer/guid_proxyobtain.h @@ -39,7 +39,7 @@ namespace NKikimr { return str.Str(); } - void Output(IOutputStream &str) const { + void Output(IOutputStream &str) const { str << "{VDiskId# " << VDiskId << " Guid# " << Guid << " State# " << State << "}"; diff --git a/ydb/core/blobstorage/vdisk/syncer/guid_proxywrite.h b/ydb/core/blobstorage/vdisk/syncer/guid_proxywrite.h index 7396bcceb41..8b8df11332c 100644 --- a/ydb/core/blobstorage/vdisk/syncer/guid_proxywrite.h +++ b/ydb/core/blobstorage/vdisk/syncer/guid_proxywrite.h @@ -38,7 +38,7 @@ namespace NKikimr { return str.Str(); } - void Output(IOutputStream &str) const { + void Output(IOutputStream &str) const { str << "{VDiskId# " << VDiskId << " Guid# " << Guid << " State# " << State << "}"; diff --git a/ydb/core/blobstorage/vdisk/syncer/guid_recovery.cpp b/ydb/core/blobstorage/vdisk/syncer/guid_recovery.cpp index d4dc97f9aba..09c699e89c3 100644 --- a/ydb/core/blobstorage/vdisk/syncer/guid_recovery.cpp +++ b/ydb/core/blobstorage/vdisk/syncer/guid_recovery.cpp @@ -153,7 +153,7 @@ namespace NKikimr { return TDecision(EDecision::Good, step, guid, TString(), false); } - void TDecision::Output(IOutputStream &str) const { + void TDecision::Output(IOutputStream &str) const { str << "[Decision# " << Decision; switch (Decision) { case EDecision::FirstRun: @@ -187,7 +187,7 @@ namespace NKikimr { // TOutcome // Outcome of the final decision that we pass outside //////////////////////////////////////////////////////////////////////////// - void TOutcome::Output(IOutputStream &str) const { + void TOutcome::Output(IOutputStream &str) const { str << "[Decision# " << Decision; str << " Guid# " << Guid; if (!Explanation.empty()) @@ -283,7 +283,7 @@ namespace NKikimr { EFirstRunStep::STATE__Uninitialized, ""); } - void Output(IOutputStream &str) const { + void Output(IOutputStream &str) const { if (IsInconsistent) { str << "[Inconsistent Explanation: \"" << Explanation << "\"]"; } else { diff --git a/ydb/core/blobstorage/vdisk/syncer/guid_recovery.h b/ydb/core/blobstorage/vdisk/syncer/guid_recovery.h index 1b3be5a03a9..6ff885cff3d 100644 --- a/ydb/core/blobstorage/vdisk/syncer/guid_recovery.h +++ b/ydb/core/blobstorage/vdisk/syncer/guid_recovery.h @@ -76,7 +76,7 @@ namespace NKikimr { bool subsequentFailure); static TDecision Good(TVDiskEternalGuid guid); static TDecision Good(EFirstRunStep step, TVDiskEternalGuid guid); - void Output(IOutputStream &str) const; + void Output(IOutputStream &str) const; TString ToString() const; EDecision GetDecision() const { return Decision; } TVDiskEternalGuid GetGuid() const { return Guid; } @@ -113,7 +113,7 @@ namespace NKikimr { TOutcome &operator=(TOutcome &&) = default; ~TOutcome() = default; bool BadDecision() const { return IsBad(Decision); } - void Output(IOutputStream &str) const; + void Output(IOutputStream &str) const; TString ToString() const; }; diff --git a/ydb/core/blobstorage/vdisk/syncer/syncer_job_task.h b/ydb/core/blobstorage/vdisk/syncer/syncer_job_task.h index 9d6d0870092..d8e93542021 100644 --- a/ydb/core/blobstorage/vdisk/syncer/syncer_job_task.h +++ b/ydb/core/blobstorage/vdisk/syncer/syncer_job_task.h @@ -134,7 +134,7 @@ namespace NKikimr { const TActorId &service, const NSyncer::TPeerSyncState &peerState, const std::shared_ptr<TSjCtx> &ctx); - void Output(IOutputStream &str) const; + void Output(IOutputStream &str) const; TString ToString() const; TSjOutcome NextRequest(); TSjOutcome Handle(TEvBlobStorage::TEvVSyncResult::TPtr &ev, const TActorId &parentId); diff --git a/ydb/core/blobstorage/vdisk/synclog/blobstorage_synclog.cpp b/ydb/core/blobstorage/vdisk/synclog/blobstorage_synclog.cpp index 907b3873f86..d648ccdcc33 100644 --- a/ydb/core/blobstorage/vdisk/synclog/blobstorage_synclog.cpp +++ b/ydb/core/blobstorage/vdisk/synclog/blobstorage_synclog.cpp @@ -209,7 +209,7 @@ namespace NKikimr { } void Handle(TEvSyncLogReadFinished::TPtr &ev, const TActorContext &ctx) { - Y_UNUSED(ctx); + Y_UNUSED(ctx); NeighborsPtr->Unlock(ev->Get()->VDiskID); ActiveActors.Erase(ev->Sender); } @@ -245,7 +245,7 @@ namespace NKikimr { } void Handle(NMon::TEvHttpInfo::TPtr &ev, const TActorContext &ctx) { - Y_VERIFY_DEBUG(ev->Get()->SubRequestId == TDbMon::SyncLogId); + Y_VERIFY_DEBUG(ev->Get()->SubRequestId == TDbMon::SyncLogId); auto aid = ctx.RegisterWithSameMailbox(CreateGetHttpInfoActor(SlCtx->VCtx, GInfo, ev, SelfId(), KeeperId, NeighborsPtr)); ActiveActors.Insert(aid); diff --git a/ydb/core/blobstorage/vdisk/synclog/blobstorage_synclogdsk.cpp b/ydb/core/blobstorage/vdisk/synclog/blobstorage_synclogdsk.cpp index 1a2fb95e1c5..170856b1fee 100644 --- a/ydb/core/blobstorage/vdisk/synclog/blobstorage_synclogdsk.cpp +++ b/ydb/core/blobstorage/vdisk/synclog/blobstorage_synclogdsk.cpp @@ -62,19 +62,19 @@ namespace NKikimr { // TOneChunkIndex //////////////////////////////////////////////////////////////////////////// void TOneChunkIndex::UpdateIndex(const TVector<TSyncLogPageSnap> &pages, ui32 indexBulk) { - Y_VERIFY_DEBUG(!Index.empty() && !pages.empty()); + Y_VERIFY_DEBUG(!Index.empty() && !pages.empty()); TSyncLogPageSnap firstPage = pages.front(); ui64 firstPageFirstLsn = firstPage.GetFirstLsn(); ui64 firstPageLastLsn = firstPage.GetLastLsn(); - Y_VERIFY_DEBUG(LastRealLsn < firstPageFirstLsn || + Y_VERIFY_DEBUG(LastRealLsn < firstPageFirstLsn || (firstPageFirstLsn <= LastRealLsn && LastRealLsn < firstPageLastLsn)); // save freePagePos before updating index ui32 freePagePos = FreePagePos(); if (firstPageFirstLsn <= LastRealLsn) { // remove or update last index rec TDiskIndexRecord &lastRec = Index.back(); - Y_VERIFY_DEBUG(lastRec.PagesNum >= 1); + Y_VERIFY_DEBUG(lastRec.PagesNum >= 1); if (lastRec.PagesNum > 1) { lastRec.PagesNum--; } else { @@ -90,7 +90,7 @@ namespace NKikimr { ui32 indexBulk, ui32 freePagePos) { ui32 s = pages.size(); - Y_VERIFY_DEBUG(s > 0); + Y_VERIFY_DEBUG(s > 0); LastRealLsn = pages[s - 1].GetLastLsn(); for (ui32 i = 0; i < s; i += indexBulk) { ui64 firstLsn = pages[i].GetFirstLsn(); @@ -100,7 +100,7 @@ namespace NKikimr { } } - void TOneChunkIndex::OutputHtml(IOutputStream &str) const { + void TOneChunkIndex::OutputHtml(IOutputStream &str) const { str << "{LastRealLsn: " << LastRealLsn; if (!Index.empty()) { str << "IndexRecs:"; @@ -171,7 +171,7 @@ namespace NKikimr { //////////////////////////////////////////////////////////////////////////// // TIndexedChunk //////////////////////////////////////////////////////////////////////////// - void TIndexedChunk::OutputHtml(IOutputStream &str) const { + void TIndexedChunk::OutputHtml(IOutputStream &str) const { str << "{ChunkIdx: " << ChunkPtr->GetChunkIdx() << " "; IndexPtr->OutputHtml(str); str << "}"; @@ -213,7 +213,7 @@ namespace NKikimr { , IndexBulk(indexBulk) {} - void TDiskRecLogSnapshot::OutputHtml(IOutputStream &str) const { + void TDiskRecLogSnapshot::OutputHtml(IOutputStream &str) const { HTML(str) { DIV_CLASS("well well-sm") { STRONG() {str << "TDiskRecLog<br>";} @@ -415,7 +415,7 @@ namespace NKikimr { // ChunkDescription ::= [ChunkIdx=4b] [LastRealLsn=8b] // [DiskIndexRecsNum=4b] DiskIndexRec* // DiskIndexRec ::= [FirstLsn=8b] [OffsetInPages=2b] [PagesNum=2b] - Y_VERIFY_DEBUG(pos < end); + Y_VERIFY_DEBUG(pos < end); if (size_t(end - pos) < 4) return false; @@ -494,11 +494,11 @@ namespace NKikimr { ManyIdxChunks.push_back(c.first); pos = c.second; } - Y_VERIFY(ManyIdxChunks.size() == chunksNum); + Y_VERIFY(ManyIdxChunks.size() == chunksNum); } ui32 TDiskRecLog::PrivateLastChunkIdx() const { - Y_VERIFY_DEBUG(!PrivateEmpty()); + Y_VERIFY_DEBUG(!PrivateEmpty()); return ManyIdxChunks.back()->GetChunkIdx(); } diff --git a/ydb/core/blobstorage/vdisk/synclog/blobstorage_synclogdsk.h b/ydb/core/blobstorage/vdisk/synclog/blobstorage_synclogdsk.h index f6b8a3abaaf..ffa93757a02 100644 --- a/ydb/core/blobstorage/vdisk/synclog/blobstorage_synclogdsk.h +++ b/ydb/core/blobstorage/vdisk/synclog/blobstorage_synclogdsk.h @@ -192,7 +192,7 @@ namespace NKikimr { } void UpdateIndex(const TVector<TSyncLogPageSnap> &pages, ui32 indexBulk); - void OutputHtml(IOutputStream &str) const; + void OutputHtml(IOutputStream &str) const; // returns number of index records ui32 Serialize(IOutputStream &s) const; ui32 Serialize(IOutputStream &s, @@ -253,7 +253,7 @@ namespace NKikimr { } } else { // firstLsn >= lsn - Y_VERIFY_DEBUG(it->FirstLsn >= lsn); + Y_VERIFY_DEBUG(it->FirstLsn >= lsn); if (it->FirstLsn == lsn || it == begin) { // it is good } else { @@ -261,16 +261,16 @@ namespace NKikimr { } } It = it; - Y_VERIFY_DEBUG(Valid()); + Y_VERIFY_DEBUG(Valid()); } void Next() { - Y_VERIFY_DEBUG(Valid()); + Y_VERIFY_DEBUG(Valid()); ++It; } const TDiskIndexRecord *Get() const { - Y_VERIFY_DEBUG(Valid()); + Y_VERIFY_DEBUG(Valid()); return &*It; } @@ -344,7 +344,7 @@ namespace NKikimr { return new TIndexedChunk(ChunkPtr, IndexPtr->DeepCopy()); } - void OutputHtml(IOutputStream &str) const; + void OutputHtml(IOutputStream &str) const; static std::pair<TIndexedChunkPtr, const char *> Construct(const char *serialized); TString ToString() const { TStringStream s; @@ -377,16 +377,16 @@ namespace NKikimr { } ui64 GetFirstLsn() const { - Y_VERIFY_DEBUG(!Empty()); + Y_VERIFY_DEBUG(!Empty()); return ManyIdxChunks.front()->GetFirstLsn(); } ui64 GetLastLsn() const { - Y_VERIFY_DEBUG(!Empty()); + Y_VERIFY_DEBUG(!Empty()); return ManyIdxChunks.back()->GetLastLsn(); } - void OutputHtml(IOutputStream &str) const; + void OutputHtml(IOutputStream &str) const; TString BoundariesToString() const; ui32 Serialize(IOutputStream &s, const TDeltaToDiskRecLog &delta) const; ui32 LastChunkIdx() const; @@ -435,7 +435,7 @@ namespace NKikimr { ChunkIt = SnapPtr->ManyIdxChunks.begin(); if (ChunkIt != SnapPtr->ManyIdxChunks.end()) { IdxBulkIt = (*ChunkIt)->GetIndexIterator(); - Y_VERIFY_DEBUG(IdxBulkIt.Valid()); + Y_VERIFY_DEBUG(IdxBulkIt.Valid()); } } @@ -463,7 +463,7 @@ namespace NKikimr { } else { // firstLsn >= lsn ui64 firstLsn = (*it)->GetFirstLsn(); - Y_VERIFY_DEBUG(firstLsn >= lsn); + Y_VERIFY_DEBUG(firstLsn >= lsn); if (firstLsn == lsn || it == begin) { // it is good } else { @@ -479,25 +479,25 @@ namespace NKikimr { ChunkIt = it; IdxBulkIt = (*ChunkIt)->GetIndexIterator(); IdxBulkIt.Seek(lsn); - Y_VERIFY_DEBUG(IdxBulkIt.Valid()); - Y_VERIFY_DEBUG(Valid()); + Y_VERIFY_DEBUG(IdxBulkIt.Valid()); + Y_VERIFY_DEBUG(Valid()); } void Next() { - Y_VERIFY_DEBUG(Valid()); + Y_VERIFY_DEBUG(Valid()); IdxBulkIt.Next(); if (!IdxBulkIt.Valid()) { ++ChunkIt; if (ChunkIt != SnapPtr->ManyIdxChunks.end()) { IdxBulkIt = (*ChunkIt)->GetIndexIterator(); IdxBulkIt.SeekToFirst(); - Y_VERIFY_DEBUG(IdxBulkIt.Valid(), "ChunkIdx# %u", (*ChunkIt)->GetChunkIdx()); + Y_VERIFY_DEBUG(IdxBulkIt.Valid(), "ChunkIdx# %u", (*ChunkIt)->GetChunkIdx()); } } } std::pair<ui32, const TDiskIndexRecord *> Get() const { - Y_VERIFY_DEBUG(Valid()); + Y_VERIFY_DEBUG(Valid()); return std::pair<ui32, const TDiskIndexRecord *>((*ChunkIt)->GetChunkIdx(), IdxBulkIt.Get()); } @@ -599,11 +599,11 @@ namespace NKikimr { return ManyIdxChunks.empty(); } ui64 PrivateGetFirstLsn() const { - Y_VERIFY_DEBUG(!PrivateEmpty()); + Y_VERIFY_DEBUG(!PrivateEmpty()); return ManyIdxChunks.front()->GetFirstLsn(); } ui64 PrivateGetLastLsn() const { - Y_VERIFY_DEBUG(!PrivateEmpty()); + Y_VERIFY_DEBUG(!PrivateEmpty()); return ManyIdxChunks.back()->GetLastLsn(); } void PrivateUpdateIndex(ui32 chunkIdx, const TVector<TSyncLogPageSnap> &pages); diff --git a/ydb/core/blobstorage/vdisk/synclog/blobstorage_synclogdsk_ut.cpp b/ydb/core/blobstorage/vdisk/synclog/blobstorage_synclogdsk_ut.cpp index 59d02b15f5f..649d81272a0 100644 --- a/ydb/core/blobstorage/vdisk/synclog/blobstorage_synclogdsk_ut.cpp +++ b/ydb/core/blobstorage/vdisk/synclog/blobstorage_synclogdsk_ut.cpp @@ -7,7 +7,7 @@ namespace NKikimr { using namespace NSyncLog; - Y_UNIT_TEST_SUITE(TBlobStorageSyncLogDsk) { + Y_UNIT_TEST_SUITE(TBlobStorageSyncLogDsk) { struct TFillIn1Context { ui64 Lsn; @@ -102,7 +102,7 @@ namespace NKikimr { //////////////////////////////////////////////////////////////////////////// // TESTS BEGIN HERE //////////////////////////////////////////////////////////////////////////// - Y_UNIT_TEST(AddByOne) { + Y_UNIT_TEST(AddByOne) { ui32 chunkSize = 256u << 10u; ui32 pageSize = 16u << 10u; ui32 indexBulk = 4; @@ -146,7 +146,7 @@ namespace NKikimr { UNIT_ASSERT(dsk->HowManyChunksAdds(CreateSwapSnapForTest(pageSize, 28, ctx)) == 2); } - Y_UNIT_TEST(AddFive) { + Y_UNIT_TEST(AddFive) { ui32 chunkSize = 256u << 10u; ui32 pageSize = 16u << 10u; ui32 indexBulk = 4; @@ -203,7 +203,7 @@ namespace NKikimr { UNIT_ASSERT(dsk->LastChunkFreePagesNum() == 6); } - Y_UNIT_TEST(SeveralChunks) { + Y_UNIT_TEST(SeveralChunks) { ui32 chunkSize = 64u << 10u; ui32 pageSize = 16u << 10u; ui32 pagesInChunk = chunkSize / pageSize; @@ -237,7 +237,7 @@ namespace NKikimr { UNIT_ASSERT(dsk->LastChunkFreePagesNum() == 0); } - Y_UNIT_TEST(OverlappingPages_OnePageIndexed) { + Y_UNIT_TEST(OverlappingPages_OnePageIndexed) { ui32 chunkSize = 256u << 10u; ui32 pageSize = 16u << 10u; ui32 indexBulk = 4; @@ -303,7 +303,7 @@ namespace NKikimr { UNIT_ASSERT(dsk->LastChunkFreePagesNum() == 12); } - Y_UNIT_TEST(OverlappingPages_SeveralPagesIndexed) { + Y_UNIT_TEST(OverlappingPages_SeveralPagesIndexed) { ui32 chunkSize = 256u << 10u; ui32 pageSize = 16u << 10u; ui32 indexBulk = 4; @@ -371,7 +371,7 @@ namespace NKikimr { UNIT_ASSERT(dsk->LastChunkFreePagesNum() == 11); } - Y_UNIT_TEST(ComplicatedSerializeWithOverlapping) { + Y_UNIT_TEST(ComplicatedSerializeWithOverlapping) { ui32 chunkSize = 256u << 10u; ui32 pageSize = 16u << 10u; ui32 indexBulk = 4; @@ -415,7 +415,7 @@ namespace NKikimr { } } - Y_UNIT_TEST(TrimLog) { + Y_UNIT_TEST(TrimLog) { ui32 chunkSize = 64u << 10u; ui32 pageSize = 16u << 10u; ui32 pagesInChunk = chunkSize / pageSize; @@ -459,7 +459,7 @@ namespace NKikimr { UNIT_ASSERT(dsk->ToString() == "Empty"); } - Y_UNIT_TEST(DeleteChunks) { + Y_UNIT_TEST(DeleteChunks) { ui32 chunkSize = 64u << 10u; ui32 pageSize = 16u << 10u; ui32 pagesInChunk = chunkSize / pageSize; diff --git a/ydb/core/blobstorage/vdisk/synclog/blobstorage_synclogformat.cpp b/ydb/core/blobstorage/vdisk/synclog/blobstorage_synclogformat.cpp index 3648ac95b90..d7c8f1f147f 100644 --- a/ydb/core/blobstorage/vdisk/synclog/blobstorage_synclogformat.cpp +++ b/ydb/core/blobstorage/vdisk/synclog/blobstorage_synclogformat.cpp @@ -13,7 +13,7 @@ namespace NKikimr { ui64 lsn, const TLogoBlobID &id, const TIngress &ingress) { - //Y_VERIFY_DEBUG(id.PartId() == 0); + //Y_VERIFY_DEBUG(id.PartId() == 0); TRecordHdr *hdr = (TRecordHdr *)buf; TLogoBlobRec *rec = (TLogoBlobRec *)(hdr + 1); hdr->RecType = TRecordHdr::RecLogoBlob; @@ -220,7 +220,7 @@ namespace NKikimr { Size = NSyncLog::TSerializeRoutines::SetGC(gtype, HeapBuf.data(), lsn, phantoms); } - void TSequenceOfRecs::Output(IOutputStream &str) const { + void TSequenceOfRecs::Output(IOutputStream &str) const { TIterator it(this); it.SeekToFirst(); while (it.Valid()) { diff --git a/ydb/core/blobstorage/vdisk/synclog/blobstorage_synclogformat.h b/ydb/core/blobstorage/vdisk/synclog/blobstorage_synclogformat.h index 396c4e7a39a..c202ccab54f 100644 --- a/ydb/core/blobstorage/vdisk/synclog/blobstorage_synclogformat.h +++ b/ydb/core/blobstorage/vdisk/synclog/blobstorage_synclogformat.h @@ -140,17 +140,17 @@ namespace NKikimr { } const TLogoBlobRec *GetLogoBlob() const { - Y_VERIFY_DEBUG(RecType == RecLogoBlob); + Y_VERIFY_DEBUG(RecType == RecLogoBlob); return (const TLogoBlobRec *)(this + 1); } const TBlockRec *GetBlock() const { - Y_VERIFY_DEBUG(RecType == RecBlock); + Y_VERIFY_DEBUG(RecType == RecBlock); return (const TBlockRec *)(this + 1); } const TBarrierRec *GetBarrier() const { - Y_VERIFY_DEBUG(RecType == RecBarrier); + Y_VERIFY_DEBUG(RecType == RecBarrier); return (const TBarrierRec *)(this + 1); } @@ -248,7 +248,7 @@ namespace NKikimr { void SetGC(const TBlobStorageGroupType >ype, ui64 lsn, const TDeque<TLogoBlobID>& phantoms); - void Output(IOutputStream &str) const; + void Output(IOutputStream &str) const; TString ToString() const; const char *GetData() const { diff --git a/ydb/core/blobstorage/vdisk/synclog/blobstorage_syncloghttp.cpp b/ydb/core/blobstorage/vdisk/synclog/blobstorage_syncloghttp.cpp index cc10f0ceed6..8d9b59c6e76 100644 --- a/ydb/core/blobstorage/vdisk/synclog/blobstorage_syncloghttp.cpp +++ b/ydb/core/blobstorage/vdisk/synclog/blobstorage_syncloghttp.cpp @@ -118,7 +118,7 @@ namespace NKikimr { , KeeperId(keeperId) , NeighborsPtr(neighborsPtr) { - Y_VERIFY_DEBUG(Ev->Get()->SubRequestId == TDbMon::SyncLogId); + Y_VERIFY_DEBUG(Ev->Get()->SubRequestId == TDbMon::SyncLogId); } }; diff --git a/ydb/core/blobstorage/vdisk/synclog/blobstorage_synclogmem.cpp b/ydb/core/blobstorage/vdisk/synclog/blobstorage_synclogmem.cpp index 75d6349b824..a79d0a7d354 100644 --- a/ydb/core/blobstorage/vdisk/synclog/blobstorage_synclogmem.cpp +++ b/ydb/core/blobstorage/vdisk/synclog/blobstorage_synclogmem.cpp @@ -8,7 +8,7 @@ namespace NKikimr { // TSyncLogPage //////////////////////////////////////////////////////////////////////////// void TSyncLogPage::Put(ui32 pageSize, const TRecordHdr *rec, ui32 dataSize) { - Y_VERIFY(HaveRoom(pageSize, dataSize) && + Y_VERIFY(HaveRoom(pageSize, dataSize) && (Header.LastLsn == 0 || rec->Lsn > Header.LastLsn), "Header# %s rec# %s pageSize# %" PRIu32 " dataSize# %" PRIu32, Header.ToString().data(), rec->ToString().data(), pageSize, dataSize); @@ -60,7 +60,7 @@ namespace NKikimr { } } - void TMemRecLogSnapshot::OutputHtml(IOutputStream &str) const { + void TMemRecLogSnapshot::OutputHtml(IOutputStream &str) const { HTML(str) { DIV_CLASS("well well-sm") { STRONG() {str << "TMemRecLog<br>";} @@ -114,7 +114,7 @@ namespace NKikimr { if (first) { first = false; } else { - Y_VERIFY(hdr->Lsn > lsn, "lsn# %" PRIu64 " hdrLsn# %" PRIu64, lsn, hdr->Lsn); + Y_VERIFY(hdr->Lsn > lsn, "lsn# %" PRIu64 " hdrLsn# %" PRIu64, lsn, hdr->Lsn); } lsn = hdr->Lsn; @@ -158,7 +158,7 @@ namespace NKikimr { } else { // pageFirstLsn >= lsn ui64 pageFirstLsn = PagesIt.Get().GetFirstLsn(); - Y_VERIFY_DEBUG(pageFirstLsn >= lsn); + Y_VERIFY_DEBUG(pageFirstLsn >= lsn); TPageIterator firstIt(PagesIt.GetSnap()); firstIt.SeekToFirst(); if (pageFirstLsn == lsn || PagesIt == firstIt) { @@ -174,16 +174,16 @@ namespace NKikimr { } // we have found the required page and it is PagesIt - Y_VERIFY_DEBUG(PagesIt.Valid()); + Y_VERIFY_DEBUG(PagesIt.Valid()); // find exact position in the page SetupHdr(); while (Hdr->Lsn < lsn) { Hdr = Hdr->Next(); - Y_VERIFY_DEBUG(Hdr != HdrEnd); + Y_VERIFY_DEBUG(Hdr != HdrEnd); } - Y_VERIFY_DEBUG(Valid()); + Y_VERIFY_DEBUG(Valid()); } void TMemRecLogSnapshot::TIterator::Next() { @@ -229,7 +229,7 @@ namespace NKikimr { return str.Str(); }; - Y_VERIFY(Pages.empty() || Pages.back()->GetLastLsn() < rec->Lsn, + Y_VERIFY(Pages.empty() || Pages.back()->GetLastLsn() < rec->Lsn, "pagesSize# %" PRIu32 " lastLsn# %" PRIu64 " recLsn# %" PRIu64 " dump#\n %s", ui32(Pages.size()), Pages.back()->GetLastLsn(), rec->Lsn, errorReport().data()); @@ -245,12 +245,12 @@ namespace NKikimr { } void TMemRecLog::PutMany(const void *buf, ui32 size) { - Y_VERIFY_DEBUG(size); + Y_VERIFY_DEBUG(size); TRecordHdr *rec = (TRecordHdr*)buf; ui32 recSize = 0; do { recSize = rec->GetSize(); - Y_VERIFY_DEBUG(recSize <= size); + Y_VERIFY_DEBUG(recSize <= size); PutOne(rec, recSize); rec = rec->Next(); size -= recSize; @@ -288,7 +288,7 @@ namespace NKikimr { // void skip cache pages, i.e. find the first page that is not in cache TSyncLogPages::const_iterator it = ::LowerBound(Pages.begin(), Pages.end(), diskLastLsn, less); if (it == Pages.end()) { - Y_VERIFY(Pages.empty()); + Y_VERIFY(Pages.empty()); return TMemRecLogSnapshotPtr(); } @@ -326,7 +326,7 @@ namespace NKikimr { return Sprintf("{Mem: [%" PRIu64 ", %" PRIu64 "]}", GetFirstLsn(), GetLastLsn()); } - void TMemRecLog::Output(IOutputStream &s) const { + void TMemRecLog::Output(IOutputStream &s) const { TMemRecLogSnapshotPtr snap = GetSnapshot(); TMemRecLogSnapshot::TIterator it(snap); it.SeekToFirst(); diff --git a/ydb/core/blobstorage/vdisk/synclog/blobstorage_synclogmem.h b/ydb/core/blobstorage/vdisk/synclog/blobstorage_synclogmem.h index 4186dea1c6a..9dcc38cdb04 100644 --- a/ydb/core/blobstorage/vdisk/synclog/blobstorage_synclogmem.h +++ b/ydb/core/blobstorage/vdisk/synclog/blobstorage_synclogmem.h @@ -58,7 +58,7 @@ namespace NKikimr { } ui64 GetFirstLsn() const { - Y_VERIFY_DEBUG(!Empty()); + Y_VERIFY_DEBUG(!Empty()); return ((TRecordHdr *)Data())->Lsn; } @@ -137,7 +137,7 @@ namespace NKikimr { , Begin(nullptr) , End(nullptr) { - Y_VERIFY(pagePtr); + Y_VERIFY(pagePtr); Begin = (const TRecordHdr *)(PagePtr->Data()); End = (const TRecordHdr *)(PagePtr->FreeSpace()); } @@ -147,7 +147,7 @@ namespace NKikimr { } void Next() { - Y_VERIFY_DEBUG(Valid()); + Y_VERIFY_DEBUG(Valid()); Pos = Pos->Next(); } @@ -156,7 +156,7 @@ namespace NKikimr { } const TRecordHdr *Get() const { - Y_VERIFY_DEBUG(Valid()); + Y_VERIFY_DEBUG(Valid()); return Pos; } private: @@ -173,8 +173,8 @@ namespace NKikimr { total++; lastLsn = p->Lsn; } - Y_VERIFY(total > 0 && total == PagePtr->GetRecsNum()); - Y_VERIFY(lastLsn == PagePtr->GetLastLsn()); + Y_VERIFY(total > 0 && total == PagePtr->GetRecsNum()); + Y_VERIFY(lastLsn == PagePtr->GetLastLsn()); } }; @@ -377,12 +377,12 @@ namespace NKikimr { } ui64 GetFirstLsn() const { - Y_VERIFY_DEBUG(!Empty()); + Y_VERIFY_DEBUG(!Empty()); return Pages[0].GetFirstLsn(); } ui64 GetLastLsn() const { - Y_VERIFY_DEBUG(!Empty()); + Y_VERIFY_DEBUG(!Empty()); return Pages[Size() - 1].GetLastLsn(); } @@ -390,7 +390,7 @@ namespace NKikimr { return Pages[i]; } - void OutputHtml(IOutputStream &str) const; + void OutputHtml(IOutputStream &str) const; TString BoundariesToString() const; void CheckSnapshotConsistency() const; @@ -423,7 +423,7 @@ namespace NKikimr { {} void SeekToFirst() { - Y_VERIFY_DEBUG(Snap); + Y_VERIFY_DEBUG(Snap); It = Snap->Pages.begin(); } @@ -436,12 +436,12 @@ namespace NKikimr { } void Next() { - Y_VERIFY_DEBUG(Valid()); + Y_VERIFY_DEBUG(Valid()); ++It; } void Prev() { - Y_VERIFY_DEBUG(Snap && It > Snap->Pages.begin() && It <= Snap->Pages.end()); + Y_VERIFY_DEBUG(Snap && It > Snap->Pages.begin() && It <= Snap->Pages.end()); --It; } @@ -491,7 +491,7 @@ namespace NKikimr { void Next(); const TRecordHdr *Get() const { - Y_VERIFY_DEBUG(Valid()); + Y_VERIFY_DEBUG(Valid()); return Hdr; } @@ -519,12 +519,12 @@ namespace NKikimr { typedef TSyncLogPages::iterator TPageIterator; ui64 GetFirstLsn() const { - Y_VERIFY_DEBUG(!Empty()); + Y_VERIFY_DEBUG(!Empty()); return Pages.front()->GetFirstLsn(); } ui64 GetLastLsn() const { - Y_VERIFY_DEBUG(!Empty()); + Y_VERIFY_DEBUG(!Empty()); return Pages.back()->GetLastLsn(); } @@ -561,7 +561,7 @@ namespace NKikimr { ui64 freeUpToLsn, // excluding ui32 freeNPages); TString BoundariesToString() const; - void Output(IOutputStream &s) const; + void Output(IOutputStream &s) const; TString ToString() const; private: diff --git a/ydb/core/blobstorage/vdisk/synclog/blobstorage_synclogmem_ut.cpp b/ydb/core/blobstorage/vdisk/synclog/blobstorage_synclogmem_ut.cpp index 995a2156a66..965dbd53837 100644 --- a/ydb/core/blobstorage/vdisk/synclog/blobstorage_synclogmem_ut.cpp +++ b/ydb/core/blobstorage/vdisk/synclog/blobstorage_synclogmem_ut.cpp @@ -1,15 +1,15 @@ #include "blobstorage_synclogmem.h" #include <library/cpp/testing/unittest/registar.h> -#include <util/stream/null.h> +#include <util/stream/null.h> #define STR Cnull - + namespace NKikimr { using namespace NSyncLog; - Y_UNIT_TEST_SUITE(TBlobStorageSyncLogMem) { + Y_UNIT_TEST_SUITE(TBlobStorageSyncLogMem) { ///////////////////////////////////////////////////////////////////////////////////////// // Put Blocks @@ -141,14 +141,14 @@ namespace NKikimr { } - Y_UNIT_TEST(EmptyMemRecLog) { + Y_UNIT_TEST(EmptyMemRecLog) { const ui32 pageSize = 1024u; NSyncLog::TMemRecLog mem(pageSize); TMemRecLogSnapshotPtr snap = mem.GetSnapshot(); TestEmptySnapshot(snap); } - Y_UNIT_TEST(FilledIn1) { + Y_UNIT_TEST(FilledIn1) { const ui32 pageSize = 1024u; const ui32 elems = 1000u; NSyncLog::TMemRecLog mem(pageSize); @@ -160,7 +160,7 @@ namespace NKikimr { TestFilledIn1(snap, elems); } - Y_UNIT_TEST(EmptyMemRecLogPutAfterSnapshot) { + Y_UNIT_TEST(EmptyMemRecLogPutAfterSnapshot) { const ui32 pageSize = 1024u; const ui32 elems = 1000u; NSyncLog::TMemRecLog mem(pageSize); @@ -169,7 +169,7 @@ namespace NKikimr { TestEmptySnapshot(snap); } - Y_UNIT_TEST(FilledIn1PutAfterSnapshot) { + Y_UNIT_TEST(FilledIn1PutAfterSnapshot) { const ui32 pageSize = 1024u; const ui32 elems = 1000u; NSyncLog::TMemRecLog mem(pageSize); @@ -182,7 +182,7 @@ namespace NKikimr { TestFilledIn1(snap, elems); } - Y_UNIT_TEST(ManyLogoBlobsPerf) { + Y_UNIT_TEST(ManyLogoBlobsPerf) { // just put many records const ui32 pageSize = 1024u; const ui32 elems = 10000000u; diff --git a/ydb/core/blobstorage/vdisk/synclog/blobstorage_synclogmsgimpl.cpp b/ydb/core/blobstorage/vdisk/synclog/blobstorage_synclogmsgimpl.cpp index ec10a5c1e1b..a0a2b068f6b 100644 --- a/ydb/core/blobstorage/vdisk/synclog/blobstorage_synclogmsgimpl.cpp +++ b/ydb/core/blobstorage/vdisk/synclog/blobstorage_synclogmsgimpl.cpp @@ -30,7 +30,7 @@ namespace NKikimr { case Lz4Signature: return ECodec::Lz4; case OrderedLz4Signature: return ECodec::OrderedLz4; case CustomCodecSignature: return ECodec::CustomCodec; - default: Y_FAIL("Unknown codec; signature# %" PRIu64, signature); + default: Y_FAIL("Unknown codec; signature# %" PRIu64, signature); } } @@ -81,7 +81,7 @@ namespace NKikimr { Steps.push_back(id.Step()); Cookies.push_back(id.Cookie()); Sizes.push_back(id.BlobSize()); - Y_VERIFY_DEBUG(id.PartId() == 0); + Y_VERIFY_DEBUG(id.PartId() == 0); Ingresses.push_back(x.Ingress.Raw()); Counters.push_back(x.Counter); } @@ -106,7 +106,7 @@ namespace NKikimr { ui32 Size() const { const ui32 blobsSize = TabletIds.size(); - Y_VERIFY_DEBUG(blobsSize == Channels.size() && blobsSize == Generations.size() && + Y_VERIFY_DEBUG(blobsSize == Channels.size() && blobsSize == Generations.size() && blobsSize == Steps.size() && blobsSize == Cookies.size() && blobsSize == Sizes.size() && blobsSize == Ingresses.size() && blobsSize == Counters.size()); @@ -135,7 +135,7 @@ namespace NKikimr { Counters.resize(blobsSize); } - virtual void Encode(IOutputStream &str) = 0; + virtual void Encode(IOutputStream &str) = 0; virtual const char *Decode(const char *pos, const char *end) = 0; virtual size_t GetEncodedApproximationSize() const = 0; }; @@ -145,7 +145,7 @@ namespace NKikimr { //////////////////////////////////////////////////////////////////////////// class TLogoBlobColumnsTrivialCodec : public TLogoBlobColumns { public: - virtual void Encode(IOutputStream &str) override { + virtual void Encode(IOutputStream &str) override { const ui32 blobsSize = Size(); str.Write(&blobsSize, sizeof(ui32)); if (blobsSize) { @@ -245,7 +245,7 @@ namespace NKikimr { pos += bufSize; size_t decodedSize = decoded.Size(); - Y_VERIFY(decodedSize == blobsSize * sizeof(TNumber), + Y_VERIFY(decodedSize == blobsSize * sizeof(TNumber), "decodedSize# %zu blobSize# %" PRIu32 " sizeof(TNumber)=%zu", decodedSize, blobsSize, sizeof(TNumber)); v.clear(); @@ -266,7 +266,7 @@ namespace NKikimr { PFor64Codec.Reset(new TPForCodec<ui64, false>); } - virtual void Encode(IOutputStream &str) override { + virtual void Encode(IOutputStream &str) override { const ui32 blobsSize = Size(); str.Write(&blobsSize, sizeof(ui32)); if (blobsSize) { @@ -325,7 +325,7 @@ namespace NKikimr { LogoBlobsColumns.reset(new TLogoBlobColumnsCustomCodec); break; default: - Y_FAIL("Unexpected case"); + Y_FAIL("Unexpected case"); } } diff --git a/ydb/core/blobstorage/vdisk/synclog/blobstorage_synclogmsgimpl_ut.cpp b/ydb/core/blobstorage/vdisk/synclog/blobstorage_synclogmsgimpl_ut.cpp index 344377c9a30..62ca3bc9ed8 100644 --- a/ydb/core/blobstorage/vdisk/synclog/blobstorage_synclogmsgimpl_ut.cpp +++ b/ydb/core/blobstorage/vdisk/synclog/blobstorage_synclogmsgimpl_ut.cpp @@ -4,7 +4,7 @@ #include <util/random/shuffle.h> #include <util/random/random.h> -#include <util/stream/null.h> +#include <util/stream/null.h> using namespace NKikimr; using namespace NKikimr::NSyncLog; @@ -50,9 +50,9 @@ bool Equal(const TRecordsWithSerial& x, const TRecordsWithSerial& y) { Equal(x.BlocksV2, y.BlocksV2); } -Y_UNIT_TEST_SUITE(ReorderCodecTest) { +Y_UNIT_TEST_SUITE(ReorderCodecTest) { - Y_UNIT_TEST(Basic) { + Y_UNIT_TEST(Basic) { TRecordsWithSerial recsSrc; // logoblobs @@ -100,7 +100,7 @@ Y_UNIT_TEST_SUITE(ReorderCodecTest) { #include <library/cpp/codecs/huffman_codec.h> #include <library/cpp/codecs/solar_codec.h> -Y_UNIT_TEST_SUITE(CodecsTest) { +Y_UNIT_TEST_SUITE(CodecsTest) { using namespace NCodecs; @@ -135,7 +135,7 @@ Y_UNIT_TEST_SUITE(CodecsTest) { STR << "v size: " << sizeof(v1[0]) * v1.size() << "; encoded size: " << buf.Size() << "\n"; } - Y_UNIT_TEST(Basic) { + Y_UNIT_TEST(Basic) { // logoblobs TVector<ui32> v1 {20, 21, 22, 23, 24, 15, 19, 16, 17, 18, 20, 78, 89, 90, 91, 93, 74, 68, 69}; TVector<ui32> v2 {15, 16, 17, 19, 19, 20, 21, 22, 25, 26, 29, 25, 26, 45, 46, 47, 47, 49, 50}; @@ -159,7 +159,7 @@ Y_UNIT_TEST_SUITE(CodecsTest) { Delta(v4); } - Y_UNIT_TEST(NaturalNumbersAndZero) { + Y_UNIT_TEST(NaturalNumbersAndZero) { TVector<ui32> v; const ui32 n = 100000; v.reserve(n); @@ -176,7 +176,7 @@ Y_UNIT_TEST_SUITE(CodecsTest) { Delta(v); } - Y_UNIT_TEST(LargeAndRepeated) { + Y_UNIT_TEST(LargeAndRepeated) { TVector<ui32> v; for (ui32 t = 0; t < 100; t++) { diff --git a/ydb/core/blobstorage/vdisk/synclog/blobstorage_synclogmsgreader.cpp b/ydb/core/blobstorage/vdisk/synclog/blobstorage_synclogmsgreader.cpp index f4c59ec890f..aa227450e0f 100644 --- a/ydb/core/blobstorage/vdisk/synclog/blobstorage_synclogmsgreader.cpp +++ b/ydb/core/blobstorage/vdisk/synclog/blobstorage_synclogmsgreader.cpp @@ -117,7 +117,7 @@ namespace NKikimr { // TOrderedLz4FragmentReader //////////////////////////////////////////////////////////////////////////// bool TOrderedLz4FragmentReader::Check(TString &errorString) { - Y_UNUSED(errorString); + Y_UNUSED(errorString); return Decompress(); } @@ -141,7 +141,7 @@ namespace NKikimr { // TCustomCodecFragmentReader //////////////////////////////////////////////////////////////////////////// bool TCustomCodecFragmentReader::Check(TString &errorString) { - Y_UNUSED(errorString); + Y_UNUSED(errorString); return Decompress(); } @@ -177,7 +177,7 @@ namespace NKikimr { Impl.reset(new TCustomCodecFragmentReader(data)); break; default: - Y_FAIL("Unknwon codec"); + Y_FAIL("Unknwon codec"); } } diff --git a/ydb/core/blobstorage/vdisk/synclog/blobstorage_synclogmsgwriter.h b/ydb/core/blobstorage/vdisk/synclog/blobstorage_synclogmsgwriter.h index 70612240593..aa549a90f5c 100644 --- a/ydb/core/blobstorage/vdisk/synclog/blobstorage_synclogmsgwriter.h +++ b/ydb/core/blobstorage/vdisk/synclog/blobstorage_synclogmsgwriter.h @@ -32,7 +32,7 @@ namespace NKikimr { } void Push(const TRecordHdr *hdr, size_t size) { - Y_VERIFY((size & 3) == 0); // ensure that size is multiple of 4 + Y_VERIFY((size & 3) == 0); // ensure that size is multiple of 4 const char *d = (const char *)hdr; DataSize += size; while (size) { @@ -85,7 +85,7 @@ namespace NKikimr { } void Push(const TRecordHdr *hdr, size_t size) { - Y_VERIFY((size & 3) == 0); // ensure that size is multiple of 4 + Y_VERIFY((size & 3) == 0); // ensure that size is multiple of 4 switch (hdr->RecType) { case TRecordHdr::RecLogoBlob: Records.LogoBlobs.emplace_back(*hdr->GetLogoBlob(), Counter); diff --git a/ydb/core/blobstorage/vdisk/synclog/blobstorage_synclogmsgwriter_ut.cpp b/ydb/core/blobstorage/vdisk/synclog/blobstorage_synclogmsgwriter_ut.cpp index 9699c12a446..c8a55c1a24d 100644 --- a/ydb/core/blobstorage/vdisk/synclog/blobstorage_synclogmsgwriter_ut.cpp +++ b/ydb/core/blobstorage/vdisk/synclog/blobstorage_synclogmsgwriter_ut.cpp @@ -4,7 +4,7 @@ using namespace NKikimr; using namespace NKikimr::NSyncLog; -Y_UNIT_TEST_SUITE(NaiveFragmentWriterTest) { +Y_UNIT_TEST_SUITE(NaiveFragmentWriterTest) { void AppendBlock(TString &data, ui64 lsn, ui64 tabletId, ui32 gen) { char buf[MaxRecFullSize]; @@ -12,7 +12,7 @@ Y_UNIT_TEST_SUITE(NaiveFragmentWriterTest) { data.append(buf, len); } - Y_UNIT_TEST(Basic) { + Y_UNIT_TEST(Basic) { TString data; AppendBlock(data, 100, 66, 1); AppendBlock(data, 101, 66, 2); @@ -34,7 +34,7 @@ Y_UNIT_TEST_SUITE(NaiveFragmentWriterTest) { UNIT_ASSERT_STRINGS_EQUAL(temp, result); } - Y_UNIT_TEST(Long) { + Y_UNIT_TEST(Long) { TString data; AppendBlock(data, 100, 66, 1); const TRecordHdr *rec = (const TRecordHdr *)(data.data()); diff --git a/ydb/core/blobstorage/vdisk/synclog/blobstorage_synclogneighbors.cpp b/ydb/core/blobstorage/vdisk/synclog/blobstorage_synclogneighbors.cpp index b9cf5c78ee6..6a62be8d75c 100644 --- a/ydb/core/blobstorage/vdisk/synclog/blobstorage_synclogneighbors.cpp +++ b/ydb/core/blobstorage/vdisk/synclog/blobstorage_synclogneighbors.cpp @@ -21,7 +21,7 @@ namespace NKikimr { , NodesInfo(nodesInfo) {} - void operator() (IOutputStream &str, TNeighbors::TConstIterator it) { + void operator() (IOutputStream &str, TNeighbors::TConstIterator it) { HTML(str) { SMALL() { STRONG() { @@ -96,7 +96,7 @@ namespace NKikimr { return isLocked; } - void TSyncLogNeighbors::OutputHtml(IOutputStream &str, + void TSyncLogNeighbors::OutputHtml(IOutputStream &str, const TBlobStorageGroupInfo &ginfo, TEvInterconnect::TEvNodesInfo::TPtr nodesInfo) { TPrinter printer(ginfo, nodesInfo); diff --git a/ydb/core/blobstorage/vdisk/synclog/blobstorage_synclogneighbors.h b/ydb/core/blobstorage/vdisk/synclog/blobstorage_synclogneighbors.h index 72bb1c825d8..08a53d77b19 100644 --- a/ydb/core/blobstorage/vdisk/synclog/blobstorage_synclogneighbors.h +++ b/ydb/core/blobstorage/vdisk/synclog/blobstorage_synclogneighbors.h @@ -37,7 +37,7 @@ namespace NKikimr { return Sprintf("{SyncedLsn: %" PRIu64 " LockedLsn: %" PRIu64 "}", SyncedLsn, LockedLsn); } - TSyncPos(IInputStream &) { + TSyncPos(IInputStream &) { Y_FAIL("Not supported"); } }; @@ -68,7 +68,7 @@ namespace NKikimr { if (Neighbors.GetTotalDisks() == 1) { return (ui64)-1; } - Y_VERIFY_DEBUG(CheckSyncPosQueue()); + Y_VERIFY_DEBUG(CheckSyncPosQueue()); // TAvlTree doesn't have const Begin, se we have to remove 'const' qualifier ui64 result = (const_cast<TSyncLogNeighbors*>(this))->SyncPosQueue.Begin()->SyncedLsn; return result; @@ -77,7 +77,7 @@ namespace NKikimr { void Lock(const TVDiskID &vdisk, ui64 lsn); void Unlock(const TVDiskID &vdisk); bool IsLocked(const TVDiskID &vdisk); - void OutputHtml(IOutputStream &str, + void OutputHtml(IOutputStream &str, const TBlobStorageGroupInfo &ginfo, TEvInterconnect::TEvNodesInfo::TPtr nodesInfo); @@ -101,7 +101,7 @@ namespace NKikimr { ref.Unlink(); SyncPosQueue.Insert(&ref); - Y_VERIFY_DEBUG(CheckSyncPosQueue()); + Y_VERIFY_DEBUG(CheckSyncPosQueue()); } ui64 GetSyncedLsn(const TVDiskID &vdisk) { @@ -128,7 +128,7 @@ namespace NKikimr { SyncPosQueue.Insert(&(it->Get())); } } - Y_VERIFY_DEBUG(CheckSyncPosQueue()); + Y_VERIFY_DEBUG(CheckSyncPosQueue()); } private: diff --git a/ydb/core/blobstorage/vdisk/synclog/blobstorage_synclogreader.cpp b/ydb/core/blobstorage/vdisk/synclog/blobstorage_synclogreader.cpp index 2873bcb56c8..7eedc5c9ac6 100644 --- a/ydb/core/blobstorage/vdisk/synclog/blobstorage_synclogreader.cpp +++ b/ydb/core/blobstorage/vdisk/synclog/blobstorage_synclogreader.cpp @@ -339,13 +339,13 @@ namespace NKikimr { // FIXME: optimize, batch reads; use Db->RecommendedReadSize CHECK_PDISK_RESPONSE(SlCtx->VCtx, ev, ctx); - Y_VERIFY(DiskIt.Valid()); + Y_VERIFY(DiskIt.Valid()); std::pair<ui32, const TDiskIndexRecord *> p = DiskIt.Get(); ui32 chunkIdx = p.first; const TDiskIndexRecord *idxRec = p.second; auto msg = ev->Get(); const TBufferWithGaps &readData = ev->Get()->Data; - Y_VERIFY(chunkIdx == msg->ChunkIdx && + Y_VERIFY(chunkIdx == msg->ChunkIdx && idxRec->OffsetInPages * SnapPtr->AppendBlockSize == msg->Offset && idxRec->PagesNum * SnapPtr->AppendBlockSize == readData.Size(), "SyncLog read command failed: chunkIdx# %" PRIu32 diff --git a/ydb/core/blobstorage/vdisk/synclog/codecs.h b/ydb/core/blobstorage/vdisk/synclog/codecs.h index ed377c46b1e..379bcf27d92 100644 --- a/ydb/core/blobstorage/vdisk/synclog/codecs.h +++ b/ydb/core/blobstorage/vdisk/synclog/codecs.h @@ -49,7 +49,7 @@ namespace NCodecs { out.Append((const char *)&n, sizeof(n)); } - Y_ASSERT(pos == end); + Y_ASSERT(pos == end); } protected: diff --git a/ydb/core/blobstorage/vdisk/synclog/codecs_ut.cpp b/ydb/core/blobstorage/vdisk/synclog/codecs_ut.cpp index 94b29b860bc..1e7dcb8d80b 100644 --- a/ydb/core/blobstorage/vdisk/synclog/codecs_ut.cpp +++ b/ydb/core/blobstorage/vdisk/synclog/codecs_ut.cpp @@ -28,7 +28,7 @@ void CheckCodec(const TVector<TNumber> &v, TCodecPtr codec = new TCodec) { UNIT_ASSERT(memcmp(src.data(), res.data(), src.size()) == 0); } -Y_UNIT_TEST_SUITE(VarLengthIntCodec) { +Y_UNIT_TEST_SUITE(VarLengthIntCodec) { template <class TNumber> void VarLength(const TVector<TNumber> &v) { @@ -50,24 +50,24 @@ Y_UNIT_TEST_SUITE(VarLengthIntCodec) { VarLength<TNumber>(v); } - Y_UNIT_TEST(BasicTest32) { + Y_UNIT_TEST(BasicTest32) { BasicTest<ui32>(); } - Y_UNIT_TEST(BasicTest64) { + Y_UNIT_TEST(BasicTest64) { BasicTest<ui64>(); } - Y_UNIT_TEST(Random32) { + Y_UNIT_TEST(Random32) { Random<ui32>(); } - Y_UNIT_TEST(Random64) { + Y_UNIT_TEST(Random64) { Random<ui32>(); } } -Y_UNIT_TEST_SUITE(RunLengthCodec) { +Y_UNIT_TEST_SUITE(RunLengthCodec) { template <class TNumber> void RunLength(const TVector<TNumber> &v) { @@ -89,24 +89,24 @@ Y_UNIT_TEST_SUITE(RunLengthCodec) { RunLength<TNumber>(v); } - Y_UNIT_TEST(BasicTest32) { + Y_UNIT_TEST(BasicTest32) { BasicTest<ui32>(); } - Y_UNIT_TEST(BasicTest64) { + Y_UNIT_TEST(BasicTest64) { BasicTest<ui64>(); } - Y_UNIT_TEST(Random32) { + Y_UNIT_TEST(Random32) { Random<ui32>(); } - Y_UNIT_TEST(Random64) { + Y_UNIT_TEST(Random64) { Random<ui32>(); } } -Y_UNIT_TEST_SUITE(SemiSortedDeltaCodec) { +Y_UNIT_TEST_SUITE(SemiSortedDeltaCodec) { template <class TNumber> void SemiSortedDelta(const TVector<TNumber> &v) { @@ -128,24 +128,24 @@ Y_UNIT_TEST_SUITE(SemiSortedDeltaCodec) { SemiSortedDelta<TNumber>(v); } - Y_UNIT_TEST(BasicTest32) { + Y_UNIT_TEST(BasicTest32) { BasicTest<ui32>(); } - Y_UNIT_TEST(BasicTest64) { + Y_UNIT_TEST(BasicTest64) { BasicTest<ui64>(); } - Y_UNIT_TEST(Random32) { + Y_UNIT_TEST(Random32) { Random<ui32>(); } - Y_UNIT_TEST(Random64) { + Y_UNIT_TEST(Random64) { Random<ui32>(); } } -Y_UNIT_TEST_SUITE(SemiSortedDeltaAndVarLengthCodec) { +Y_UNIT_TEST_SUITE(SemiSortedDeltaAndVarLengthCodec) { template <class TNumber> void SemiSortedDeltaAndVarLength(const TVector<TNumber> &v) { @@ -170,19 +170,19 @@ Y_UNIT_TEST_SUITE(SemiSortedDeltaAndVarLengthCodec) { SemiSortedDeltaAndVarLength<TNumber>(v); } - Y_UNIT_TEST(BasicTest32) { + Y_UNIT_TEST(BasicTest32) { BasicTest<ui32>(); } - Y_UNIT_TEST(BasicTest64) { + Y_UNIT_TEST(BasicTest64) { BasicTest<ui64>(); } - Y_UNIT_TEST(Random32) { + Y_UNIT_TEST(Random32) { Random<ui32>(); } - Y_UNIT_TEST(Random64) { + Y_UNIT_TEST(Random64) { Random<ui32>(); } } diff --git a/ydb/core/client/client_ut.cpp b/ydb/core/client/client_ut.cpp index b94c722588b..9857c81e7ac 100644 --- a/ydb/core/client/client_ut.cpp +++ b/ydb/core/client/client_ut.cpp @@ -327,8 +327,8 @@ void ExtractResultInfo(const NKikimrMiniKQL::TResult& result, TVector<TTxInfo>& } // namelesspace -Y_UNIT_TEST_SUITE(TClientTest) { - Y_UNIT_TEST(TestInspectProxy) { +Y_UNIT_TEST_SUITE(TClientTest) { + Y_UNIT_TEST(TestInspectProxy) { TPortManager tp; ui16 port = tp.GetPort(2134); auto settings = TServerSettings(port); @@ -350,7 +350,7 @@ Y_UNIT_TEST_SUITE(TClientTest) { } } - Y_UNIT_TEST(NoAffectedProgram) { + Y_UNIT_TEST(NoAffectedProgram) { using namespace NScheme; TPortManager tp; ui16 port = tp.GetPort(2134); @@ -372,7 +372,7 @@ Y_UNIT_TEST_SUITE(TClientTest) { } } - Y_UNIT_TEST(ReadWriteMiniKQL) { + Y_UNIT_TEST(ReadWriteMiniKQL) { TPortManager tp; ui16 port = tp.GetPort(2134); @@ -486,7 +486,7 @@ Y_UNIT_TEST_SUITE(TClientTest) { } } - Y_UNIT_TEST(ReadWriteViaMiniKQL) { + Y_UNIT_TEST(ReadWriteViaMiniKQL) { TPortManager tp; ui16 port = tp.GetPort(2134); @@ -522,7 +522,7 @@ Y_UNIT_TEST_SUITE(TClientTest) { } } - Y_UNIT_TEST(ReadWrite_MiniKQL_AfterAlter) { + Y_UNIT_TEST(ReadWrite_MiniKQL_AfterAlter) { TPortManager tp; ui16 port = tp.GetPort(2134); @@ -581,7 +581,7 @@ Y_UNIT_TEST_SUITE(TClientTest) { } } - Y_UNIT_TEST(ReadWrite_MiniKQL_BeforeAndAfterAlter) { + Y_UNIT_TEST(ReadWrite_MiniKQL_BeforeAndAfterAlter) { TPortManager tp; ui16 port = tp.GetPort(2134); @@ -606,7 +606,7 @@ Y_UNIT_TEST_SUITE(TClientTest) { } } - Y_UNIT_TEST(ReadWriteViaMiniKQLRecreateDifferentTable) { + Y_UNIT_TEST(ReadWriteViaMiniKQLRecreateDifferentTable) { TPortManager tp; ui16 port = tp.GetPort(2134); @@ -654,7 +654,7 @@ Y_UNIT_TEST_SUITE(TClientTest) { UNIT_ASSERT(client.FlatQuery(writeQuery, writeRes)); } - Y_UNIT_TEST(ReadWriteViaMiniKQLRecreateSameTable) { + Y_UNIT_TEST(ReadWriteViaMiniKQLRecreateSameTable) { TPortManager tp; ui16 port = tp.GetPort(2134); @@ -675,7 +675,7 @@ Y_UNIT_TEST_SUITE(TClientTest) { } } - Y_UNIT_TEST(ReadWriteViaMiniKQLShardedHead) { + Y_UNIT_TEST(ReadWriteViaMiniKQLShardedHead) { TPortManager tp; ui16 port = tp.GetPort(2134); @@ -774,7 +774,7 @@ Y_UNIT_TEST_SUITE(TClientTest) { } } - Y_UNIT_TEST(GetStepTxId) { + Y_UNIT_TEST(GetStepTxId) { TPortManager tp; ui16 port = tp.GetPort(2134); @@ -788,7 +788,7 @@ Y_UNIT_TEST_SUITE(TClientTest) { GetStepTxIdBody(client, false); } - Y_UNIT_TEST(GetStepTxIdHead) { + Y_UNIT_TEST(GetStepTxIdHead) { TPortManager tp; ui16 port = tp.GetPort(2134); @@ -877,7 +877,7 @@ Y_UNIT_TEST_SUITE(TClientTest) { } } - Y_UNIT_TEST(CASViaMiniKQL) { + Y_UNIT_TEST(CASViaMiniKQL) { TPortManager tp; ui16 port = tp.GetPort(2134); @@ -985,7 +985,7 @@ Y_UNIT_TEST_SUITE(TClientTest) { } } - Y_UNIT_TEST(RowEraseViaMiniKQL) { + Y_UNIT_TEST(RowEraseViaMiniKQL) { TPortManager tp; ui16 port = tp.GetPort(2134); @@ -1081,7 +1081,7 @@ Y_UNIT_TEST_SUITE(TClientTest) { } } - Y_UNIT_TEST(ReadRangeViaMiniKQL) { + Y_UNIT_TEST(ReadRangeViaMiniKQL) { TPortManager tp; ui16 port = tp.GetPort(2134); @@ -1298,7 +1298,7 @@ Y_UNIT_TEST_SUITE(TClientTest) { } } - Y_UNIT_TEST(SelectRangeOptions) { + Y_UNIT_TEST(SelectRangeOptions) { TPortManager tp; ui16 port = tp.GetPort(2134); const auto settings = TServerSettings(port); @@ -1389,7 +1389,7 @@ Y_UNIT_TEST_SUITE(TClientTest) { } } - Y_UNIT_TEST(TestMultiSelect) { + Y_UNIT_TEST(TestMultiSelect) { TPortManager tp; ui16 port = tp.GetPort(2134); @@ -1440,7 +1440,7 @@ Y_UNIT_TEST_SUITE(TClientTest) { } } - Y_UNIT_TEST(TestMultiSelectFlat) { + Y_UNIT_TEST(TestMultiSelectFlat) { TPortManager tp; ui16 port = tp.GetPort(2134); @@ -1715,7 +1715,7 @@ Y_UNIT_TEST_SUITE(TClientTest) { } } - Y_UNIT_TEST(Diagnostics) { + Y_UNIT_TEST(Diagnostics) { TPortManager tp; ui16 port = tp.GetPort(2134); @@ -1784,7 +1784,7 @@ Y_UNIT_TEST_SUITE(TClientTest) { return str; } - Y_UNIT_TEST(LocalSchemeTxRead) { + Y_UNIT_TEST(LocalSchemeTxRead) { TPortManager tp; ui16 port = tp.GetPort(2134); @@ -1803,7 +1803,7 @@ Y_UNIT_TEST_SUITE(TClientTest) { UNIT_ASSERT_VALUES_EQUAL(ToString(scheme1), ToString(scheme2)); } - Y_UNIT_TEST(LocalSchemeTxModify) { + Y_UNIT_TEST(LocalSchemeTxModify) { TPortManager tp; ui16 port = tp.GetPort(2134); @@ -1853,7 +1853,7 @@ Y_UNIT_TEST_SUITE(TClientTest) { UNIT_ASSERT_C(!schemaDiff.empty(), "Schema not changed after update"); } - Y_UNIT_TEST(LocalSchemeDropTable) { + Y_UNIT_TEST(LocalSchemeDropTable) { TPortManager tp; ui16 port = tp.GetPort(2134); @@ -1889,7 +1889,7 @@ Y_UNIT_TEST_SUITE(TClientTest) { UNIT_ASSERT_C(!schemaDiff.empty(), "Schema not changed after update"); } - Y_UNIT_TEST(TestOldTypes) { + Y_UNIT_TEST(TestOldTypes) { TPortManager tp; ui16 port = tp.GetPort(2134); @@ -1969,7 +1969,7 @@ Y_UNIT_TEST_SUITE(TClientTest) { // TODO: check resluts } - Y_UNIT_TEST(TestOldTypeParams) { + Y_UNIT_TEST(TestOldTypeParams) { TPortManager tp; ui16 port = tp.GetPort(2134); diff --git a/ydb/core/client/flat_ut.cpp b/ydb/core/client/flat_ut.cpp index 362c052aa11..dc118173392 100644 --- a/ydb/core/client/flat_ut.cpp +++ b/ydb/core/client/flat_ut.cpp @@ -109,9 +109,9 @@ namespace { } -Y_UNIT_TEST_SUITE(TFlatTest) { +Y_UNIT_TEST_SUITE(TFlatTest) { - Y_UNIT_TEST(Init) { + Y_UNIT_TEST(Init) { TPortManager pm; ui16 port = pm.GetPort(2134); TServer cleverServer = TServer(TServerSettings(port)); @@ -252,7 +252,7 @@ Y_UNIT_TEST_SUITE(TFlatTest) { annoyingClient.DeleteTable("/dc-1/Berkanavt/tables", "Classes"); } - Y_UNIT_TEST(SelectBigRangePerf) { + Y_UNIT_TEST(SelectBigRangePerf) { // Scenario from https://st.yandex-team.ru/KIKIMR-2715 // Increase N_ROWS and N_REQS for profiling const int N_ROWS = 100; // 10000 @@ -327,7 +327,7 @@ Y_UNIT_TEST_SUITE(TFlatTest) { } } - Y_UNIT_TEST(SelectRowWithTargetParameter) { + Y_UNIT_TEST(SelectRowWithTargetParameter) { TPortManager pm; ui16 port = pm.GetPort(2134); TServer cleverServer = TServer(TServerSettings(port)); @@ -376,7 +376,7 @@ Y_UNIT_TEST_SUITE(TFlatTest) { UNIT_ASSERT_NO_DIFF(result.GetValue().GetStruct(0).GetOptional().GetOptional().GetBytes(), "test1"); } - Y_UNIT_TEST(ModifyMultipleRowsCrossShardAllToAll) { + Y_UNIT_TEST(ModifyMultipleRowsCrossShardAllToAll) { TPortManager pm; ui16 port = pm.GetPort(2134); TServer cleverServer = TServer(TServerSettings(port)); @@ -516,7 +516,7 @@ Y_UNIT_TEST_SUITE(TFlatTest) { annoyingClient.FlatQueryParams(query, params, false, result); } - Y_UNIT_TEST(CrossRW) { + Y_UNIT_TEST(CrossRW) { TPortManager pm; ui16 port = pm.GetPort(2134); TServer cleverServer = TServer(TServerSettings(port)); @@ -893,7 +893,7 @@ Y_UNIT_TEST_SUITE(TFlatTest) { } } - Y_UNIT_TEST(Mix_DML_DDL) { + Y_UNIT_TEST(Mix_DML_DDL) { TPortManager pm; ui16 port = pm.GetPort(2134); TServer cleverServer = TServer(TServerSettings(port)); @@ -1013,7 +1013,7 @@ Y_UNIT_TEST_SUITE(TFlatTest) { ))", NMsgBusProxy::MSTATUS_ERROR); } - Y_UNIT_TEST(MiniKQLRanges) { + Y_UNIT_TEST(MiniKQLRanges) { TPortManager pm; ui16 port = pm.GetPort(2134); TServer cleverServer = TServer(TServerSettings(port)); @@ -1078,7 +1078,7 @@ Y_UNIT_TEST_SUITE(TFlatTest) { void TestLsSuccess(TFlatMsgBusClient& annoyingClient, const TString& name, const TVector<TString>& children) { TString selfName = name; if (selfName != "/") { - selfName= name.substr(name.find_last_of('/')+1); + selfName= name.substr(name.find_last_of('/')+1); } TAutoPtr<NMsgBusProxy::TBusResponse> res = annoyingClient.Ls(name); UNIT_ASSERT_VALUES_EQUAL_C(res->Record.GetPathDescription().GetSelf().GetName(), selfName, "Self name doesn't match"); @@ -1111,7 +1111,7 @@ Y_UNIT_TEST_SUITE(TFlatTest) { "Unexpected status for " + name); } - Y_UNIT_TEST(Ls) { + Y_UNIT_TEST(Ls) { TPortManager pm; ui16 port = pm.GetPort(2134); TServer cleverServer = TServer(TServerSettings(port).SetEnableSystemViews(false)); @@ -1169,7 +1169,7 @@ Y_UNIT_TEST_SUITE(TFlatTest) { } } - Y_UNIT_TEST(ReadOnlyMode) { + Y_UNIT_TEST(ReadOnlyMode) { TPortManager pm; ui16 port = pm.GetPort(2134); TServer cleverServer = TServer(TServerSettings(port).SetEnableMockOnSingleNode(false)); @@ -1204,7 +1204,7 @@ Y_UNIT_TEST_SUITE(TFlatTest) { UNIT_ASSERT_VALUES_EQUAL(status, NMsgBusProxy::MSTATUS_OK); } - Y_UNIT_TEST(PathSorting) { + Y_UNIT_TEST(PathSorting) { TPortManager pm; ui16 port = pm.GetPort(2134); TServer cleverServer = TServer(TServerSettings(port).SetEnableSystemViews(false)); @@ -1250,7 +1250,7 @@ Y_UNIT_TEST_SUITE(TFlatTest) { "Unexpected status for pathId " + ToString(pathId)); } - Y_UNIT_TEST(LsPathId) { + Y_UNIT_TEST(LsPathId) { TPortManager pm; ui16 port = pm.GetPort(2134); TServer cleverServer = TServer(TServerSettings(port).SetEnableSystemViews(false)); @@ -1279,7 +1279,7 @@ Y_UNIT_TEST_SUITE(TFlatTest) { return res->Record.GetStatus(); } - Y_UNIT_TEST(InitRoot) { + Y_UNIT_TEST(InitRoot) { TPortManager pm; ui16 port = pm.GetPort(2134); TServer cleverServer = TServer(TServerSettings(port)); @@ -1299,7 +1299,7 @@ Y_UNIT_TEST_SUITE(TFlatTest) { UNIT_ASSERT_VALUES_EQUAL(TestInitRoot(annoyingClient, "dc-2"), NMsgBusProxy::MSTATUS_ERROR); } - Y_UNIT_TEST(CheckACL) { + Y_UNIT_TEST(CheckACL) { TPortManager pm; ui16 port = pm.GetPort(2134); TServer cleverServer = TServer(TServerSettings(port)); @@ -1432,7 +1432,7 @@ Y_UNIT_TEST_SUITE(TFlatTest) { #endif } - Y_UNIT_TEST(OutOfDiskSpace) { + Y_UNIT_TEST(OutOfDiskSpace) { return; // TODO https://st.yandex-team.ru/KIKIMR-2279 TPortManager pm; ui16 port = pm.GetPort(2134); @@ -1561,7 +1561,7 @@ Y_UNIT_TEST_SUITE(TFlatTest) { UNIT_ASSERT_VALUES_EQUAL_C((NMsgBusProxy::EResponseStatus)status, NMsgBusProxy::MSTATUS_ERROR, "Big read should fail"); } - Y_UNIT_TEST(RejectByPerShardReadSize) { + Y_UNIT_TEST(RejectByPerShardReadSize) { NKikimrConfig::TImmediateControlsConfig controls; controls.MutableTxLimitControls()->SetPerRequestDataSizeLimit(1000000000); controls.MutableTxLimitControls()->SetPerShardIncomingReadSetSizeLimit(1000000000); @@ -1575,7 +1575,7 @@ Y_UNIT_TEST_SUITE(TFlatTest) { TestRejectByPerShardReadSize(controls, ""); } - Y_UNIT_TEST(RejectByPerRequestSize) { + Y_UNIT_TEST(RejectByPerRequestSize) { TPortManager pm; ui16 port = pm.GetPort(2134); @@ -1648,7 +1648,7 @@ Y_UNIT_TEST_SUITE(TFlatTest) { UNIT_ASSERT_VALUES_EQUAL_C((NMsgBusProxy::EResponseStatus)status, NMsgBusProxy::MSTATUS_ERROR, "Big read should fail"); } - Y_UNIT_TEST(RejectByIncomingReadSetSize) { + Y_UNIT_TEST(RejectByIncomingReadSetSize) { TPortManager pm; ui16 port = pm.GetPort(2134); NKikimrConfig::TImmediateControlsConfig controls; @@ -1886,7 +1886,7 @@ Y_UNIT_TEST_SUITE(TFlatTest) { } - Y_UNIT_TEST(CopyTableAndRead) { + Y_UNIT_TEST(CopyTableAndRead) { TPortManager pm; ui16 port = pm.GetPort(2134); @@ -1918,7 +1918,7 @@ Y_UNIT_TEST_SUITE(TFlatTest) { UNIT_ASSERT_NO_DIFF(strResult, strResultOld); } - Y_UNIT_TEST(CopyTableAndCompareColumnsSchema) { + Y_UNIT_TEST(CopyTableAndCompareColumnsSchema) { TPortManager pm; ui16 port = pm.GetPort(2134); @@ -1973,7 +1973,7 @@ Y_UNIT_TEST_SUITE(TFlatTest) { } - Y_UNIT_TEST(CopyCopiedTableAndRead) { + Y_UNIT_TEST(CopyCopiedTableAndRead) { TPortManager pm; ui16 port = pm.GetPort(2134); TServer cleverServer = TServer(TServerSettings(port)); @@ -2048,7 +2048,7 @@ Y_UNIT_TEST_SUITE(TFlatTest) { UNIT_ASSERT_NO_DIFF(strResult, strResultOld); } - Y_UNIT_TEST(CopyTableAndDropCopy) { + Y_UNIT_TEST(CopyTableAndDropCopy) { TPortManager pm; ui16 port = pm.GetPort(2134); TServer cleverServer = TServer(TServerSettings(port)); @@ -2097,7 +2097,7 @@ Y_UNIT_TEST_SUITE(TFlatTest) { WaitForTabletsToBeDeletedInHive(annoyingClient, cleverServer.GetRuntime(), datashards); } - Y_UNIT_TEST(CopyTableAndDropOriginal) { + Y_UNIT_TEST(CopyTableAndDropOriginal) { TPortManager pm; ui16 port = pm.GetPort(2134); TServer cleverServer = TServer(TServerSettings(port)); @@ -2135,7 +2135,7 @@ Y_UNIT_TEST_SUITE(TFlatTest) { WaitForTabletsToBeDeletedInHive(annoyingClient, cleverServer.GetRuntime(), datashards); } - Y_UNIT_TEST(CopyTableAndReturnPartAfterCompaction) { + Y_UNIT_TEST(CopyTableAndReturnPartAfterCompaction) { TPortManager pm; ui16 port = pm.GetPort(2134); TServer cleverServer = TServer(TServerSettings(port)); @@ -2207,7 +2207,7 @@ Y_UNIT_TEST_SUITE(TFlatTest) { WaitForTabletsToBeDeletedInHive(annoyingClient, cleverServer.GetRuntime(), datashards); } - Y_UNIT_TEST(CopyTableDropOriginalAndReturnPartAfterCompaction) { + Y_UNIT_TEST(CopyTableDropOriginalAndReturnPartAfterCompaction) { TPortManager pm; ui16 port = pm.GetPort(2134); TServer cleverServer = TServer(TServerSettings(port)); @@ -2289,7 +2289,7 @@ Y_UNIT_TEST_SUITE(TFlatTest) { WaitForTabletsToBeDeletedInHive(annoyingClient, cleverServer.GetRuntime(), datashards); } - Y_UNIT_TEST(CopyCopiedTableAndDropFirstCopy) { + Y_UNIT_TEST(CopyCopiedTableAndDropFirstCopy) { TPortManager pm; ui16 port = pm.GetPort(2134); TServer cleverServer = TServer(TServerSettings(port)); @@ -2407,7 +2407,7 @@ Y_UNIT_TEST_SUITE(TFlatTest) { UNIT_ASSERT_VALUES_EQUAL(response.GetSchemeStatus(), NKikimrScheme::StatusNameConflict); } - Y_UNIT_TEST(SplitEmptyAndWrite) { + Y_UNIT_TEST(SplitEmptyAndWrite) { TPortManager pm; ui16 port = pm.GetPort(2134); TServer cleverServer = TServer(TServerSettings(port)); @@ -2468,7 +2468,7 @@ Y_UNIT_TEST_SUITE(TFlatTest) { annoyingClient.Ls("/dc-1/Dir/TableOld"); } - Y_UNIT_TEST(SplitEmptyTwice) { + Y_UNIT_TEST(SplitEmptyTwice) { TPortManager pm; ui16 port = pm.GetPort(2134); TServer cleverServer = TServer(TServerSettings(port)); @@ -2505,7 +2505,7 @@ Y_UNIT_TEST_SUITE(TFlatTest) { annoyingClient.Ls("/dc-1/Dir/TableOld"); } - Y_UNIT_TEST(MergeEmptyAndWrite) { + Y_UNIT_TEST(MergeEmptyAndWrite) { TPortManager pm; ui16 port = pm.GetPort(2134); TServer cleverServer = TServer(TServerSettings(port)); @@ -2541,7 +2541,7 @@ Y_UNIT_TEST_SUITE(TFlatTest) { annoyingClient.Ls("/dc-1/Dir/TableOld"); } - Y_UNIT_TEST(WriteMergeAndRead) { + Y_UNIT_TEST(WriteMergeAndRead) { TPortManager pm; ui16 port = pm.GetPort(2134); TServer cleverServer = TServer(TServerSettings(port)); @@ -2634,7 +2634,7 @@ Y_UNIT_TEST_SUITE(TFlatTest) { SplitTable(annoyingClient, "/dc-1/Dir/TableOld", 0, {splitKey}); } - Y_UNIT_TEST(SplitThenMerge) { + Y_UNIT_TEST(SplitThenMerge) { TPortManager pm; ui16 port = pm.GetPort(2134); TServer cleverServer = TServer(TServerSettings(port)); @@ -2672,7 +2672,7 @@ Y_UNIT_TEST_SUITE(TFlatTest) { annoyingClient.Ls("/dc-1/Dir/TableOld"); } - Y_UNIT_TEST(WriteSplitAndRead) { + Y_UNIT_TEST(WriteSplitAndRead) { TPortManager pm; ui16 port = pm.GetPort(2134); TServer cleverServer = TServer(TServerSettings(port)); @@ -2768,7 +2768,7 @@ Y_UNIT_TEST_SUITE(TFlatTest) { annoyingClient.Ls("/dc-1/Dir/TableOld"); } - Y_UNIT_TEST(WriteSplitKillRead) { + Y_UNIT_TEST(WriteSplitKillRead) { TPortManager pm; ui16 port = pm.GetPort(2134); TServer cleverServer = TServer(TServerSettings(port)); @@ -2816,7 +2816,7 @@ Y_UNIT_TEST_SUITE(TFlatTest) { annoyingClient.Ls("/dc-1/Dir/TableOld"); } - Y_UNIT_TEST(SplitBoundaryRead) { + Y_UNIT_TEST(SplitBoundaryRead) { TPortManager pm; ui16 port = pm.GetPort(2134); TServer cleverServer = TServer(TServerSettings(port)); @@ -2835,7 +2835,7 @@ Y_UNIT_TEST_SUITE(TFlatTest) { SplitTable(annoyingClient, "/dc-1/Dir/TableOld", 0, {11111}); } - Y_UNIT_TEST(WriteSplitWriteSplit) { + Y_UNIT_TEST(WriteSplitWriteSplit) { TPortManager pm; ui16 port = pm.GetPort(2134); TServer cleverServer = TServer(TServerSettings(port)); @@ -2883,7 +2883,7 @@ Y_UNIT_TEST_SUITE(TFlatTest) { annoyingClient.Ls("/dc-1/Dir/TableOld"); } - Y_UNIT_TEST(AutoSplitBySize) { + Y_UNIT_TEST(AutoSplitBySize) { TPortManager pm; ui16 port = pm.GetPort(2134); TServer cleverServer = TServer(TServerSettings(port)); @@ -3051,7 +3051,7 @@ Y_UNIT_TEST_SUITE(TFlatTest) { } } - Y_UNIT_TEST(AutoMergeBySize) { + Y_UNIT_TEST(AutoMergeBySize) { TPortManager pm; ui16 port = pm.GetPort(2134); TServer cleverServer = TServer(TServerSettings(port)); @@ -3158,7 +3158,7 @@ Y_UNIT_TEST_SUITE(TFlatTest) { UNIT_ASSERT_VALUES_EQUAL(partitions.size(), 6); } - Y_UNIT_TEST(AutoSplitMergeQueue) { + Y_UNIT_TEST(AutoSplitMergeQueue) { TPortManager pm; ui16 port = pm.GetPort(2134); TServer cleverServer = TServer(TServerSettings(port).SetEnableMvcc(false)); @@ -3234,7 +3234,7 @@ Y_UNIT_TEST_SUITE(TFlatTest) { UNIT_ASSERT_VALUES_UNEQUAL_C(finalPartitions[0], initialPartitions[0], "Partitions din't change"); } - Y_UNIT_TEST(GetTabletCounters) { + Y_UNIT_TEST(GetTabletCounters) { TPortManager pm; ui16 port = pm.GetPort(2134); TServer cleverServer = TServer(TServerSettings(port)); @@ -3334,7 +3334,7 @@ Y_UNIT_TEST_SUITE(TFlatTest) { LargeDatashardReplyRO(annoyingClient); } - Y_UNIT_TEST(LargeDatashardReplyRW) { + Y_UNIT_TEST(LargeDatashardReplyRW) { const ui32 TABLE_ROWS = 700; const ui32 BLOB_SIZE = 100 * 1024; // 100 Kb const ui32 KEY_TO_ERASE = 1; @@ -3393,7 +3393,7 @@ Y_UNIT_TEST_SUITE(TFlatTest) { UNIT_ASSERT(!res.GetValue().GetStruct(0).GetOptional().HasOptional()); } - Y_UNIT_TEST(LargeProxyReply) { + Y_UNIT_TEST(LargeProxyReply) { const ui32 TABLE_ROWS = 350; const ui32 BLOB_SIZE = 100 * 1024; // 100 Kb @@ -3436,7 +3436,7 @@ Y_UNIT_TEST_SUITE(TFlatTest) { ), NMsgBusProxy::MSTATUS_ERROR, TEvTxUserProxy::TResultStatus::ExecResultUnavailable); } - Y_UNIT_TEST(LargeProxyReplyRW) { + Y_UNIT_TEST(LargeProxyReplyRW) { const ui32 TABLE_ROWS = 350; const ui32 BLOB_SIZE = 100 * 1024; // 100 Kb const ui32 KEY_TO_ERASE = 1; @@ -3495,7 +3495,7 @@ Y_UNIT_TEST_SUITE(TFlatTest) { UNIT_ASSERT(!res.GetValue().GetStruct(0).GetOptional().HasOptional()); } - Y_UNIT_TEST(PartBloomFilter) { + Y_UNIT_TEST(PartBloomFilter) { TPortManager pm; ui16 port = pm.GetPort(2134); TServer cleverServer = TServer(TServerSettings(port)); diff --git a/ydb/core/client/locks_ut.cpp b/ydb/core/client/locks_ut.cpp index 47b7c3dfdd5..39f5c92d5c6 100644 --- a/ydb/core/client/locks_ut.cpp +++ b/ydb/core/client/locks_ut.cpp @@ -550,11 +550,11 @@ void TestLock(const TLocksTestOptions& testOpts) { } /// suite TLocksTest -Y_UNIT_TEST_SUITE(TLocksTest) { +Y_UNIT_TEST_SUITE(TLocksTest) { // Point locks -Y_UNIT_TEST(GoodLock) { +Y_UNIT_TEST(GoodLock) { TLocksTestOptions opts; TestLock<TLocksV1>(opts); TestLock<TLocksV2>(opts); @@ -567,7 +567,7 @@ Y_UNIT_TEST(GoodLock) { TestLock<TLocksV2>(opts); } -Y_UNIT_TEST(BrokenLockUpdate) { +Y_UNIT_TEST(BrokenLockUpdate) { TLocksTestOptions opts; opts.Break = true; TestLock<TLocksV1>(opts); @@ -581,7 +581,7 @@ Y_UNIT_TEST(BrokenLockUpdate) { TestLock<TLocksV2>(opts); } -Y_UNIT_TEST(BrokenLockErase) { +Y_UNIT_TEST(BrokenLockErase) { TLocksTestOptions opts; opts.Break = true; opts.TestErase = true; @@ -596,7 +596,7 @@ Y_UNIT_TEST(BrokenLockErase) { TestLock<TLocksV2>(opts); } -Y_UNIT_TEST(UpdateLockedKey) { +Y_UNIT_TEST(UpdateLockedKey) { TLocksTestOptions opts; opts.Break = false; opts.UpdateKey = opts.BreakKey; @@ -611,7 +611,7 @@ Y_UNIT_TEST(UpdateLockedKey) { TestLock<TLocksV2>(opts); } -Y_UNIT_TEST(NoLocksSet) { +Y_UNIT_TEST(NoLocksSet) { TLocksTestOptions opts; opts.Break = true; opts.NoLocks = true; @@ -628,7 +628,7 @@ Y_UNIT_TEST(NoLocksSet) { TestLock<TLocksV2>(opts); } -Y_UNIT_TEST(GoodSameKeyLock) { +Y_UNIT_TEST(GoodSameKeyLock) { TLocksTestOptions opts; opts.NoBreakKey1 = opts.NoBreakKey0; TestLock<TLocksV1>(opts); @@ -642,7 +642,7 @@ Y_UNIT_TEST(GoodSameKeyLock) { TestLock<TLocksV2>(opts); } -Y_UNIT_TEST(BrokenSameKeyLock) { +Y_UNIT_TEST(BrokenSameKeyLock) { TLocksTestOptions opts; opts.Break = true; opts.NoBreakKey0 = opts.BreakKey; @@ -657,7 +657,7 @@ Y_UNIT_TEST(BrokenSameKeyLock) { TestLock<TLocksV2>(opts); } -Y_UNIT_TEST(GoodSameShardLock) { +Y_UNIT_TEST(GoodSameShardLock) { TLocksTestOptions opts; opts.NoBreakKey0 = "'('key (Uint32 '40))"; TestLock<TLocksV1>(opts); @@ -671,7 +671,7 @@ Y_UNIT_TEST(GoodSameShardLock) { TestLock<TLocksV2>(opts); } -Y_UNIT_TEST(BrokenSameShardLock) { +Y_UNIT_TEST(BrokenSameShardLock) { TLocksTestOptions opts; opts.Break = true; opts.NoBreakKey0 = "'('key (Uint32 '40))"; @@ -686,7 +686,7 @@ Y_UNIT_TEST(BrokenSameShardLock) { TestLock<TLocksV2>(opts); } -Y_UNIT_TEST(GoodDupLock) { +Y_UNIT_TEST(GoodDupLock) { TLocksTestOptions opts; opts.Dup = true; TestLock<TLocksV1>(opts); @@ -700,7 +700,7 @@ Y_UNIT_TEST(GoodDupLock) { TestLock<TLocksV2>(opts); } -Y_UNIT_TEST(BrokenDupLock) { +Y_UNIT_TEST(BrokenDupLock) { TLocksTestOptions opts; opts.Break = true; opts.Dup = true; @@ -715,7 +715,7 @@ Y_UNIT_TEST(BrokenDupLock) { TestLock<TLocksV2>(opts); } -Y_UNIT_TEST(GoodNullLock) { +Y_UNIT_TEST(GoodNullLock) { TLocksTestOptions opts; opts.BreakKey = "'('key (Null))"; TestLock<TLocksV1>(opts); @@ -729,7 +729,7 @@ Y_UNIT_TEST(GoodNullLock) { TestLock<TLocksV2>(opts); } -Y_UNIT_TEST(BrokenNullLock) { +Y_UNIT_TEST(BrokenNullLock) { TLocksTestOptions opts; opts.Break = true; opts.BreakKey = "'('key (Null))"; @@ -747,7 +747,7 @@ Y_UNIT_TEST(BrokenNullLock) { // Range locks // (0, 42] (42, inf) -Y_UNIT_TEST(Range_GoodLock0) { +Y_UNIT_TEST(Range_GoodLock0) { TLocksTestOptions opts; opts.TestRange = true; TestLock<TLocksV1>(opts); @@ -762,7 +762,7 @@ Y_UNIT_TEST(Range_GoodLock0) { } // (Null, 42] (42*10^8, inf) -Y_UNIT_TEST(Range_GoodLock1) { +Y_UNIT_TEST(Range_GoodLock1) { TLocksTestOptions opts; opts.TestRange = true; opts.Range0Begin = "(Null)"; @@ -779,7 +779,7 @@ Y_UNIT_TEST(Range_GoodLock1) { } // (0, x] (x, inf) -Y_UNIT_TEST(Range_BrokenLock0) { +Y_UNIT_TEST(Range_BrokenLock0) { TLocksTestOptions opts; opts.TestRange = true; opts.Break = true; @@ -795,7 +795,7 @@ Y_UNIT_TEST(Range_BrokenLock0) { } // (0, x] (42*10^8, inf) -Y_UNIT_TEST(Range_BrokenLock1) { +Y_UNIT_TEST(Range_BrokenLock1) { TLocksTestOptions opts; opts.TestRange = true; opts.Range1Begin = "(Uint32 '4200000000)"; @@ -812,7 +812,7 @@ Y_UNIT_TEST(Range_BrokenLock1) { } // (0, x) [x, inf) -Y_UNIT_TEST(Range_BrokenLock2) { +Y_UNIT_TEST(Range_BrokenLock2) { TLocksTestOptions opts; opts.TestRange = true; opts.Range0Inc = "'ExcFrom 'ExcTo"; @@ -830,7 +830,7 @@ Y_UNIT_TEST(Range_BrokenLock2) { } // (0, x] [x, inf) -Y_UNIT_TEST(Range_BrokenLock3) { +Y_UNIT_TEST(Range_BrokenLock3) { TLocksTestOptions opts; opts.TestRange = true; opts.Range0Inc = "'ExcFrom 'IncTo"; @@ -848,7 +848,7 @@ Y_UNIT_TEST(Range_BrokenLock3) { } // (0, x] (x, inf) -Y_UNIT_TEST(Range_BrokenLockMax) { +Y_UNIT_TEST(Range_BrokenLockMax) { TLocksTestOptions opts; opts.TestRange = true; opts.BreakKey = "'('key (Uint32 '4294967295))"; @@ -866,7 +866,7 @@ Y_UNIT_TEST(Range_BrokenLockMax) { } // (0, x) (x, inf) -Y_UNIT_TEST(Range_Pinhole) { +Y_UNIT_TEST(Range_Pinhole) { TLocksTestOptions opts; opts.TestRange = true; opts.Range0Inc = "'ExcFrom 'ExcTo"; @@ -886,7 +886,7 @@ Y_UNIT_TEST(Range_Pinhole) { } // [x, x] (x, inf) -Y_UNIT_TEST(Range_CorrectDot) { +Y_UNIT_TEST(Range_CorrectDot) { TLocksTestOptions opts; opts.TestRange = true; opts.Range0Inc = "'IncFrom 'IncTo"; @@ -905,7 +905,7 @@ Y_UNIT_TEST(Range_CorrectDot) { } // (x, x] (x, inf) -Y_UNIT_TEST(Range_IncorrectDot1) { +Y_UNIT_TEST(Range_IncorrectDot1) { TLocksTestOptions opts; opts.TestRange = true; opts.Range0Inc = "'ExcFrom 'IncTo"; @@ -927,7 +927,7 @@ Y_UNIT_TEST(Range_IncorrectDot1) { } // [x, x) (x, inf) -Y_UNIT_TEST(Range_IncorrectDot2) { +Y_UNIT_TEST(Range_IncorrectDot2) { TLocksTestOptions opts; opts.TestRange = true; opts.Range0Inc = "'IncFrom 'ExcTo"; @@ -949,7 +949,7 @@ Y_UNIT_TEST(Range_IncorrectDot2) { } // [Null, Null] (x, inf) -Y_UNIT_TEST(Range_CorrectNullDot) { +Y_UNIT_TEST(Range_CorrectNullDot) { TLocksTestOptions opts; opts.TestRange = true; opts.Range0Inc = "'IncFrom 'IncTo"; @@ -969,7 +969,7 @@ Y_UNIT_TEST(Range_CorrectNullDot) { } // (Null, Null] (x, inf) -Y_UNIT_TEST(Range_IncorrectNullDot1) { +Y_UNIT_TEST(Range_IncorrectNullDot1) { TLocksTestOptions opts; opts.TestRange = true; opts.Range0Inc = "'ExcFrom 'IncTo"; @@ -992,7 +992,7 @@ Y_UNIT_TEST(Range_IncorrectNullDot1) { } // [Null, Null) (x, inf) -Y_UNIT_TEST(Range_IncorrectNullDot2) { +Y_UNIT_TEST(Range_IncorrectNullDot2) { TLocksTestOptions opts; opts.TestRange = true; opts.Range0Inc = "'IncFrom 'ExcTo"; @@ -1015,7 +1015,7 @@ Y_UNIT_TEST(Range_IncorrectNullDot2) { } // test empty key -Y_UNIT_TEST(Range_EmptyKey) { +Y_UNIT_TEST(Range_EmptyKey) { TLocksTestOptions opts; opts.SetTableC(); opts.SetOnly = true; @@ -1037,7 +1037,7 @@ Y_UNIT_TEST(Range_EmptyKey) { // Composite key -Y_UNIT_TEST(CK_GoodLock) { +Y_UNIT_TEST(CK_GoodLock) { TLocksTestOptions opts; opts.SetTableB(); TestLock<TLocksV1>(opts); @@ -1051,7 +1051,7 @@ Y_UNIT_TEST(CK_GoodLock) { TestLock<TLocksV2>(opts); } -Y_UNIT_TEST(CK_BrokenLock) { +Y_UNIT_TEST(CK_BrokenLock) { TLocksTestOptions opts; opts.SetTableB(); opts.Break = true; @@ -1066,7 +1066,7 @@ Y_UNIT_TEST(CK_BrokenLock) { TestLock<TLocksV2>(opts); } -Y_UNIT_TEST(CK_Range_GoodLock) { +Y_UNIT_TEST(CK_Range_GoodLock) { TLocksTestOptions opts; opts.SetTableB(); opts.TestRange = true; @@ -1081,7 +1081,7 @@ Y_UNIT_TEST(CK_Range_GoodLock) { TestLock<TLocksV2>(opts); } -Y_UNIT_TEST(CK_Range_BrokenLock) { +Y_UNIT_TEST(CK_Range_BrokenLock) { TLocksTestOptions opts; opts.SetTableB(); opts.TestRange = true; @@ -1099,7 +1099,7 @@ Y_UNIT_TEST(CK_Range_BrokenLock) { TestLock<TLocksV2>(opts); } -Y_UNIT_TEST(CK_Range_BrokenLockInf) { +Y_UNIT_TEST(CK_Range_BrokenLockInf) { TLocksTestOptions opts; opts.SetTableB(); opts.TestRange = true; @@ -1257,12 +1257,12 @@ static void MultipleLocks() { } } -Y_UNIT_TEST(MultipleLocks) { +Y_UNIT_TEST(MultipleLocks) { MultipleLocks<TLocksV1>(); MultipleLocks<TLocksV2>(); } -Y_UNIT_TEST(SetLockFail) { +Y_UNIT_TEST(SetLockFail) { TClientServer cs; NKikimrMiniKQL::TResult res; @@ -1320,7 +1320,7 @@ static void SetLockNothing() { } } -Y_UNIT_TEST(SetLockNothing) { +Y_UNIT_TEST(SetLockNothing) { SetLockNothing<TLocksV1>(); SetLockNothing<TLocksV2>(); } @@ -1405,7 +1405,7 @@ static void SetEraseSet() { } } -Y_UNIT_TEST(SetEraseSet) { +Y_UNIT_TEST(SetEraseSet) { SetEraseSet<TLocksV1>(); SetEraseSet<TLocksV2>(); } @@ -1576,7 +1576,7 @@ static void SetBreakSetEraseBreak() { } } -Y_UNIT_TEST(SetBreakSetEraseBreak) { +Y_UNIT_TEST(SetBreakSetEraseBreak) { SetBreakSetEraseBreak<TLocksV1>(); SetBreakSetEraseBreak<TLocksV2>(); } @@ -1585,11 +1585,11 @@ Y_UNIT_TEST(SetBreakSetEraseBreak) { /// suite TLocksFatTest -Y_UNIT_TEST_SUITE(TLocksFatTest) { +Y_UNIT_TEST_SUITE(TLocksFatTest) { const ui32 NUM_LOTS = 250; -Y_UNIT_TEST(PointSetBreak) { +Y_UNIT_TEST(PointSetBreak) { TClientServer cs; //NKikimrMiniKQL::TResult res; @@ -1624,7 +1624,7 @@ Y_UNIT_TEST(PointSetBreak) { } } -Y_UNIT_TEST(PointSetNotBreak) { +Y_UNIT_TEST(PointSetNotBreak) { TClientServer cs; //NKikimrMiniKQL::TResult res; @@ -1694,12 +1694,12 @@ static void PointSetRemove() { } } -Y_UNIT_TEST(PointSetRemove) { +Y_UNIT_TEST(PointSetRemove) { PointSetRemove<TLocksV1>(); PointSetRemove<TLocksV2>(); } -Y_UNIT_TEST(RangeSetBreak) { +Y_UNIT_TEST(RangeSetBreak) { TClientServer cs; NKikimrMiniKQL::TResult res; @@ -1731,7 +1731,7 @@ Y_UNIT_TEST(RangeSetBreak) { } } -Y_UNIT_TEST(RangeSetNotBreak) { +Y_UNIT_TEST(RangeSetNotBreak) { TClientServer cs; NKikimrMiniKQL::TResult res; @@ -1797,7 +1797,7 @@ static void RangeSetRemove() { } } -Y_UNIT_TEST(RangeSetRemove) { +Y_UNIT_TEST(RangeSetRemove) { RangeSetRemove<TLocksV1>(); RangeSetRemove<TLocksV2>(); } @@ -1905,7 +1905,7 @@ static void LocksLimit() { } } -Y_UNIT_TEST(LocksLimit) { +Y_UNIT_TEST(LocksLimit) { LocksLimit<TLocksV1>(); LocksLimit<TLocksV2>(); } diff --git a/ydb/core/client/metadata/ut/functions_metadata_ut.cpp b/ydb/core/client/metadata/ut/functions_metadata_ut.cpp index 0713c33e8dd..8409faa38d1 100644 --- a/ydb/core/client/metadata/ut/functions_metadata_ut.cpp +++ b/ydb/core/client/metadata/ut/functions_metadata_ut.cpp @@ -12,9 +12,9 @@ using namespace NMiniKQL; static const NScheme::TTypeId Uint32Id = NScheme::NTypeIds::Uint32; -Y_UNIT_TEST_SUITE(TFunctionsMetadataTest) +Y_UNIT_TEST_SUITE(TFunctionsMetadataTest) { - Y_UNIT_TEST(Serialization) { + Y_UNIT_TEST(Serialization) { static TFunctionParamMetadata AddUi32Metadata[] = { { Uint32Id, 0 }, // result { Uint32Id, 0 }, // first arg diff --git a/ydb/core/client/minikql_compile/mkql_compile_service.cpp b/ydb/core/client/minikql_compile/mkql_compile_service.cpp index e01d61a22cc..d0f470d31e4 100644 --- a/ydb/core/client/minikql_compile/mkql_compile_service.cpp +++ b/ydb/core/client/minikql_compile/mkql_compile_service.cpp @@ -93,7 +93,7 @@ public: HFunc(NYql::TMiniKQLCompileActorEvents::TEvCompileResult, Handle); cFunc(TEvents::TEvPoison::EventType, PassAway); default: - Y_FAIL(""); + Y_FAIL(""); } } @@ -111,7 +111,7 @@ private: void Handle(NYql::TMiniKQLCompileActorEvents::TEvCompileResult::TPtr& ev, const TActorContext& ctx) { auto *msg = ev->Get(); auto it = Compiling.find(ev->Sender); - Y_VERIFY(it != Compiling.end()); + Y_VERIFY(it != Compiling.end()); TCompileContext::TPtr cptr = it->second; Compiling.erase(it); diff --git a/ydb/core/client/minikql_compile/yql_expr_minikql.cpp b/ydb/core/client/minikql_compile/yql_expr_minikql.cpp index 76f38bf35cb..d059134c5dd 100644 --- a/ydb/core/client/minikql_compile/yql_expr_minikql.cpp +++ b/ydb/core/client/minikql_compile/yql_expr_minikql.cpp @@ -1351,11 +1351,11 @@ ConvertToMiniKQL(TExprContainer::TPtr expr, try { const auto& results = future.GetValue(); auto& tablesToResolve = ctx->GetTablesToResolve(); - Y_VERIFY_DEBUG(tablesToResolve.size() == results.size(), "tablesToResolve.size() != results.size()"); + Y_VERIFY_DEBUG(tablesToResolve.size() == results.size(), "tablesToResolve.size() != results.size()"); ui32 i = 0; for (auto& x : tablesToResolve) { const auto& response = results[i]; - Y_ENSURE_EX(response.Status == IDbSchemeResolver::TTableResult::Ok, + Y_ENSURE_EX(response.Status == IDbSchemeResolver::TTableResult::Ok, TNodeException() << "Failed to resolve table " << x.second.Request.TableName << ", error: " << response.Reason); x.second.Response = response; @@ -1498,7 +1498,7 @@ private: try { const auto& results = ev->Get()->Result; auto& tablesToResolve = CompileCtx->GetTablesToResolve(); - Y_VERIFY_DEBUG(tablesToResolve.size() == results.size(), "tablesToResolve.size() != results.size()"); + Y_VERIFY_DEBUG(tablesToResolve.size() == results.size(), "tablesToResolve.size() != results.size()"); TVector<NYql::TIssue> resolveErrors; ui32 i = 0; @@ -1577,7 +1577,7 @@ private: do { status = ExpandApply(Expr->Root, Expr->Root, Expr->Context); } while (status.Level == IGraphTransformer::TStatus::Repeat); - Y_VERIFY_DEBUG(status.Level == IGraphTransformer::TStatus::Ok || + Y_VERIFY_DEBUG(status.Level == IGraphTransformer::TStatus::Ok || status.Level == IGraphTransformer::TStatus::Error); if (status.Level != IGraphTransformer::TStatus::Ok) { errors = Expr->Context.IssueManager.GetIssues(); diff --git a/ydb/core/client/minikql_compile/yql_expr_minikql_compile_ut.cpp b/ydb/core/client/minikql_compile/yql_expr_minikql_compile_ut.cpp index 4fcdf735ba2..e0e130ea31d 100644 --- a/ydb/core/client/minikql_compile/yql_expr_minikql_compile_ut.cpp +++ b/ydb/core/client/minikql_compile/yql_expr_minikql_compile_ut.cpp @@ -87,8 +87,8 @@ namespace { } } -Y_UNIT_TEST_SUITE(TTestYqlToMiniKQLCompile) { - Y_UNIT_TEST(CheckResolve) { +Y_UNIT_TEST_SUITE(TTestYqlToMiniKQLCompile) { + Y_UNIT_TEST(CheckResolve) { TServices services; RegisterSampleTables(services); TVector<IDbSchemeResolver::TTable> tablesToResolve; @@ -110,7 +110,7 @@ Y_UNIT_TEST_SUITE(TTestYqlToMiniKQLCompile) { UNIT_ASSERT_VALUES_EQUAL(res[0].Columns["value"].Type, (ui32)NUdf::TDataType<char*>::Id); } - Y_UNIT_TEST(OnlyResult) { + Y_UNIT_TEST(OnlyResult) { auto programText = R"___( ( (let pgmReturn (AsList (SetResult 'myRes (String 'abc)))) @@ -124,7 +124,7 @@ Y_UNIT_TEST_SUITE(TTestYqlToMiniKQLCompile) { UNIT_ASSERT_VALUES_EQUAL(services.DescList.size(), 0); } - Y_UNIT_TEST(EraseRow) { + Y_UNIT_TEST(EraseRow) { auto programText = R"___( ( (let row1 '('('key (Uint32 '23)))) @@ -149,7 +149,7 @@ Y_UNIT_TEST_SUITE(TTestYqlToMiniKQLCompile) { } } - Y_UNIT_TEST(UpdateRow) { + Y_UNIT_TEST(UpdateRow) { auto programText = R"___( ( (let row '('('key (Uint32 '23)))) @@ -178,7 +178,7 @@ Y_UNIT_TEST_SUITE(TTestYqlToMiniKQLCompile) { } } - Y_UNIT_TEST(SelectRow) { + Y_UNIT_TEST(SelectRow) { auto programText = R"___( ( (let row '('('key (Uint32 '23)))) @@ -200,7 +200,7 @@ Y_UNIT_TEST_SUITE(TTestYqlToMiniKQLCompile) { } } - Y_UNIT_TEST(SelectRange) { + Y_UNIT_TEST(SelectRange) { auto programText = R"___( ( (let range '('IncFrom 'ExcTo '('key (Uint32 '23) (Void)))) @@ -223,7 +223,7 @@ Y_UNIT_TEST_SUITE(TTestYqlToMiniKQLCompile) { } } - Y_UNIT_TEST(SimpleCrossShardTx) { + Y_UNIT_TEST(SimpleCrossShardTx) { auto programText = R"___( ( (let row '('('key (Uint32 '2)))) @@ -256,7 +256,7 @@ Y_UNIT_TEST_SUITE(TTestYqlToMiniKQLCompile) { UNIT_ASSERT_VALUES_EQUAL(counters[TKeyDesc::ERowOperation::Update], 1); } - Y_UNIT_TEST(AcquireLocks) { + Y_UNIT_TEST(AcquireLocks) { auto programText = R"___( ( (let row '('('key (Uint32 '23)))) @@ -279,7 +279,7 @@ Y_UNIT_TEST_SUITE(TTestYqlToMiniKQLCompile) { } } - Y_UNIT_TEST(StaticMapTypeOf) { + Y_UNIT_TEST(StaticMapTypeOf) { auto programText = R"___( ( (return (AsList @@ -303,7 +303,7 @@ Y_UNIT_TEST_SUITE(TTestYqlToMiniKQLCompile) { UNIT_ASSERT_VALUES_EQUAL(services.DescList.size(), 0); } - Y_UNIT_TEST(SelectRangeAtomInRange) { + Y_UNIT_TEST(SelectRangeAtomInRange) { auto programText = R"___( ( (let range '('key (Void) 'Void)) @@ -320,7 +320,7 @@ Y_UNIT_TEST_SUITE(TTestYqlToMiniKQLCompile) { UNIT_ASSERT_NO_DIFF(result.Errors.begin()->Message, "At function: SelectRange"); } - Y_UNIT_TEST(Extract) { + Y_UNIT_TEST(Extract) { auto programText = R"___( ( (let range '('IncFrom 'ExcTo '('key (Uint32 '23) (Void)))) diff --git a/ydb/core/client/minikql_result_lib/converter_ut.cpp b/ydb/core/client/minikql_result_lib/converter_ut.cpp index 0fb5eff6211..383e56b6aa0 100644 --- a/ydb/core/client/minikql_result_lib/converter_ut.cpp +++ b/ydb/core/client/minikql_result_lib/converter_ut.cpp @@ -10,9 +10,9 @@ namespace NKikimr { using namespace NResultLib; -Y_UNIT_TEST_SUITE(TMiniKQLResultConverterTest) { +Y_UNIT_TEST_SUITE(TMiniKQLResultConverterTest) { -Y_UNIT_TEST(TTestWithSimpleProgram) { +Y_UNIT_TEST(TTestWithSimpleProgram) { TPortManager pm; ui16 port = pm.GetPort(2134); auto settings = Tests::TServerSettings(port); diff --git a/ydb/core/client/minikql_result_lib/data_funcs.inl b/ydb/core/client/minikql_result_lib/data_funcs.inl index a152c054a1a..0dc8193d953 100644 --- a/ydb/core/client/minikql_result_lib/data_funcs.inl +++ b/ydb/core/client/minikql_result_lib/data_funcs.inl @@ -62,7 +62,7 @@ inline bool HasData<TStringBuf>(const TProtoValue& value, NScheme::TTypeId schem #define ENSURE_HAS_DATA(type, value, schemeType) \ do { \ - Y_ENSURE(HasData<type>(value, schemeType), "No data of type " #type "."); \ + Y_ENSURE(HasData<type>(value, schemeType), "No data of type " #type "."); \ } while (0); template <> diff --git a/ydb/core/client/minikql_result_lib/objects.h b/ydb/core/client/minikql_result_lib/objects.h index 4b5ae0da451..abc66544412 100644 --- a/ydb/core/client/minikql_result_lib/objects.h +++ b/ydb/core/client/minikql_result_lib/objects.h @@ -27,16 +27,16 @@ namespace NPrivate { template <typename T> inline bool HasData(const TProtoValue& value, NScheme::TTypeId schemeType) { - Y_UNUSED(value); - Y_UNUSED(schemeType); - Y_FAIL("Not scpecified type."); + Y_UNUSED(value); + Y_UNUSED(schemeType); + Y_FAIL("Not scpecified type."); } template <typename T> inline T GetData(const TProtoValue& value, NScheme::TTypeId schemeType) { - Y_UNUSED(value); - Y_UNUSED(schemeType); - Y_FAIL("Not scpecified type."); + Y_UNUSED(value); + Y_UNUSED(schemeType); + Y_FAIL("Not scpecified type."); } #include "data_funcs.inl" @@ -47,9 +47,9 @@ inline T GetData(const TProtoValue& value, NScheme::TTypeId schemeType) { #define ENSURE_KIND(type, expectedKind) \ do { \ auto kind = (EProtoTypeKind) type.GetKind(); \ - Y_ENSURE(kind == EProtoTypeKind::expectedKind, \ + Y_ENSURE(kind == EProtoTypeKind::expectedKind, \ "Expected " #expectedKind " instead of " << NKikimrMiniKQL::ETypeKind_Name(kind)); \ - Y_ENSURE(type.Has ## expectedKind(), "No " #expectedKind " in type, seems like an error."); \ + Y_ENSURE(type.Has ## expectedKind(), "No " #expectedKind " in type, seems like an error."); \ } while (false); @@ -132,7 +132,7 @@ public: template <typename T> T GetItem(size_t index) { - Y_ENSURE(CheckIndex(index), "List item index" << index << " is out of bounds."); + Y_ENSURE(CheckIndex(index), "List item index" << index << " is out of bounds."); iterator<T> it(RootValue.GetList().begin() + index, RootType.GetList().GetItem()); return it.Get(); } @@ -161,7 +161,7 @@ public: , Size(RootValue.TupleSize()) { ENSURE_KIND(RootType, Tuple); - Y_ENSURE(RootType.GetTuple().ElementSize() == RootValue.TupleSize(), "Size mismatch."); + Y_ENSURE(RootType.GetTuple().ElementSize() == RootValue.TupleSize(), "Size mismatch."); } template <typename T> @@ -191,7 +191,7 @@ public: , Size(RootValue.StructSize()) { ENSURE_KIND(RootType, Struct); - Y_ENSURE(RootType.GetStruct().MemberSize() == RootValue.StructSize(), "Size mismatch."); + Y_ENSURE(RootType.GetStruct().MemberSize() == RootValue.StructSize(), "Size mismatch."); } template <typename T> @@ -249,7 +249,7 @@ private: // TOptional. template <typename T> T TOptional::GetItem() const { - Y_ENSURE(HasItem(), "Optional is empty!"); + Y_ENSURE(HasItem(), "Optional is empty!"); const auto& itemType = RootType.GetOptional().GetItem(); ENSURE_KIND(itemType, Data); auto schemeType = itemType.GetData().GetScheme(); @@ -266,7 +266,7 @@ T TOptional::GetItem() const { // TTuple. template <typename T> T TTuple::GetElement(size_t index) const { - Y_ENSURE(CheckIndex(index), "Tuple element index" << index << " is out of bounds."); + Y_ENSURE(CheckIndex(index), "Tuple element index" << index << " is out of bounds."); const auto& elementType = RootType.GetTuple().GetElement(index); const auto& element = RootValue.GetTuple(index); ENSURE_KIND(elementType, Data); @@ -286,7 +286,7 @@ T TStruct::GetMember(const TStringBuf& memberName) { template <typename T> T TStruct::GetMember(size_t memberIndex) { - Y_ENSURE(CheckIndex(memberIndex), "Struct member index" << memberIndex << " is out of bounds."); + Y_ENSURE(CheckIndex(memberIndex), "Struct member index" << memberIndex << " is out of bounds."); const auto& memberType = RootType.GetStruct().GetMember(memberIndex).GetType(); const auto& member = RootValue.GetStruct(memberIndex); ENSURE_KIND(memberType, Data); diff --git a/ydb/core/client/minikql_result_lib/objects_ut.cpp b/ydb/core/client/minikql_result_lib/objects_ut.cpp index 49b3d300dcb..110c052587f 100644 --- a/ydb/core/client/minikql_result_lib/objects_ut.cpp +++ b/ydb/core/client/minikql_result_lib/objects_ut.cpp @@ -10,9 +10,9 @@ namespace NKikimr { using namespace NKikimrMiniKQL; using namespace NResultLib; -Y_UNIT_TEST_SUITE(TMiniKQLResultTest) { +Y_UNIT_TEST_SUITE(TMiniKQLResultTest) { -Y_UNIT_TEST(TOptionalTest) { +Y_UNIT_TEST(TOptionalTest) { { // Optional of Bool. TType type; type.SetKind(ETypeKind::Optional); @@ -35,7 +35,7 @@ Y_UNIT_TEST(TOptionalTest) { } } -Y_UNIT_TEST(TListTest) { +Y_UNIT_TEST(TListTest) { { // List of Int32. TType type; type.SetKind(ETypeKind::List); @@ -86,7 +86,7 @@ Y_UNIT_TEST(TListTest) { } -Y_UNIT_TEST(TTupleTest) { +Y_UNIT_TEST(TTupleTest) { { // Tuple of (Optional of Int32, List of Uint64). TType type; type.SetKind(ETypeKind::Tuple); @@ -124,7 +124,7 @@ Y_UNIT_TEST(TTupleTest) { } } -Y_UNIT_TEST(TStructTest) { +Y_UNIT_TEST(TStructTest) { { // Struct of {"a" : Int64, "b" : Int32}. TType type; type.SetKind(ETypeKind::Struct); diff --git a/ydb/core/client/minikql_result_lib/optional_funcs.inl b/ydb/core/client/minikql_result_lib/optional_funcs.inl index 56cc00dcc79..f2e97008cb1 100644 --- a/ydb/core/client/minikql_result_lib/optional_funcs.inl +++ b/ydb/core/client/minikql_result_lib/optional_funcs.inl @@ -3,7 +3,7 @@ #define ENSURE_HAS_ITEM() \ do { \ - Y_ENSURE(HasItem(), "Optional is empty!"); \ + Y_ENSURE(HasItem(), "Optional is empty!"); \ } while (0); template <> diff --git a/ydb/core/client/minikql_result_lib/struct_funcs.inl b/ydb/core/client/minikql_result_lib/struct_funcs.inl index 4c953878424..64b697e76c0 100644 --- a/ydb/core/client/minikql_result_lib/struct_funcs.inl +++ b/ydb/core/client/minikql_result_lib/struct_funcs.inl @@ -3,13 +3,13 @@ template <> inline void TStruct::GetMember<void>(size_t memberIndex) { - Y_ENSURE(CheckIndex(memberIndex), "Struct member index" << memberIndex << " is out of bounds."); + Y_ENSURE(CheckIndex(memberIndex), "Struct member index" << memberIndex << " is out of bounds."); return; } template <> inline TOptional TStruct::GetMember<TOptional>(size_t memberIndex) { - Y_ENSURE(CheckIndex(memberIndex), "Struct member index" << memberIndex << " is out of bounds."); + Y_ENSURE(CheckIndex(memberIndex), "Struct member index" << memberIndex << " is out of bounds."); const auto& memberType = RootType.GetStruct().GetMember(memberIndex).GetType(); const auto& member = RootValue.GetStruct(memberIndex); return TOptional(member, memberType); @@ -17,7 +17,7 @@ inline TOptional TStruct::GetMember<TOptional>(size_t memberIndex) { template <> inline TListType TStruct::GetMember<TListType>(size_t memberIndex) { - Y_ENSURE(CheckIndex(memberIndex), "Struct member index" << memberIndex << " is out of bounds."); + Y_ENSURE(CheckIndex(memberIndex), "Struct member index" << memberIndex << " is out of bounds."); const auto& memberType = RootType.GetStruct().GetMember(memberIndex).GetType(); const auto& member = RootValue.GetStruct(memberIndex); return TListType(member, memberType); @@ -25,7 +25,7 @@ inline TListType TStruct::GetMember<TListType>(size_t memberIndex) { template <> inline TTuple TStruct::GetMember<TTuple>(size_t memberIndex) { - Y_ENSURE(CheckIndex(memberIndex), "Struct member index" << memberIndex << " is out of bounds."); + Y_ENSURE(CheckIndex(memberIndex), "Struct member index" << memberIndex << " is out of bounds."); const auto& memberType = RootType.GetStruct().GetMember(memberIndex).GetType(); const auto& member = RootValue.GetStruct(memberIndex); return TTuple(member, memberType); @@ -33,7 +33,7 @@ inline TTuple TStruct::GetMember<TTuple>(size_t memberIndex) { template <> inline TStruct TStruct::GetMember<TStruct>(size_t memberIndex) { - Y_ENSURE(CheckIndex(memberIndex), "Struct member index" << memberIndex << " is out of bounds."); + Y_ENSURE(CheckIndex(memberIndex), "Struct member index" << memberIndex << " is out of bounds."); const auto& memberType = RootType.GetStruct().GetMember(memberIndex).GetType(); const auto& member = RootValue.GetStruct(memberIndex); return TStruct(member, memberType); @@ -41,7 +41,7 @@ inline TStruct TStruct::GetMember<TStruct>(size_t memberIndex) { template <> inline TDict TStruct::GetMember<TDict>(size_t memberIndex) { - Y_ENSURE(CheckIndex(memberIndex), "Struct member index" << memberIndex << " is out of bounds."); + Y_ENSURE(CheckIndex(memberIndex), "Struct member index" << memberIndex << " is out of bounds."); const auto& memberType = RootType.GetStruct().GetMember(memberIndex).GetType(); const auto& member = RootValue.GetStruct(memberIndex); return TDict(member, memberType); diff --git a/ydb/core/client/minikql_result_lib/tuple_funcs.inl b/ydb/core/client/minikql_result_lib/tuple_funcs.inl index 9c11f2f61ff..e63b3ec0982 100644 --- a/ydb/core/client/minikql_result_lib/tuple_funcs.inl +++ b/ydb/core/client/minikql_result_lib/tuple_funcs.inl @@ -3,13 +3,13 @@ template <> inline void TTuple::GetElement<void>(size_t index) const { - Y_ENSURE(CheckIndex(index), "Tuple element index" << index << " is out of bounds."); + Y_ENSURE(CheckIndex(index), "Tuple element index" << index << " is out of bounds."); return; } template <> inline TOptional TTuple::GetElement<TOptional>(size_t index) const { - Y_ENSURE(CheckIndex(index), "Tuple element index" << index << " is out of bounds."); + Y_ENSURE(CheckIndex(index), "Tuple element index" << index << " is out of bounds."); const auto& elementType = RootType.GetTuple().GetElement(index); const auto& element = RootValue.GetTuple(index); return TOptional(element, elementType); @@ -17,7 +17,7 @@ inline TOptional TTuple::GetElement<TOptional>(size_t index) const { template <> inline TListType TTuple::GetElement<TListType>(size_t index) const { - Y_ENSURE(CheckIndex(index), "Tuple element index" << index << " is out of bounds."); + Y_ENSURE(CheckIndex(index), "Tuple element index" << index << " is out of bounds."); const auto& elementType = RootType.GetTuple().GetElement(index); const auto& element = RootValue.GetTuple(index); return TListType(element, elementType); @@ -25,7 +25,7 @@ inline TListType TTuple::GetElement<TListType>(size_t index) const { template <> inline TTuple TTuple::GetElement<TTuple>(size_t index) const { - Y_ENSURE(CheckIndex(index), "Tuple element index" << index << " is out of bounds."); + Y_ENSURE(CheckIndex(index), "Tuple element index" << index << " is out of bounds."); const auto& elementType = RootType.GetTuple().GetElement(index); const auto& element = RootValue.GetTuple(index); return TTuple(element, elementType); @@ -33,7 +33,7 @@ inline TTuple TTuple::GetElement<TTuple>(size_t index) const { template <> inline TStruct TTuple::GetElement<TStruct>(size_t index) const { - Y_ENSURE(CheckIndex(index), "Tuple element index" << index << " is out of bounds."); + Y_ENSURE(CheckIndex(index), "Tuple element index" << index << " is out of bounds."); const auto& elementType = RootType.GetTuple().GetElement(index); const auto& element = RootValue.GetTuple(index); return TStruct(element, elementType); @@ -41,7 +41,7 @@ inline TStruct TTuple::GetElement<TStruct>(size_t index) const { template <> inline TDict TTuple::GetElement<TDict>(size_t index) const { - Y_ENSURE(CheckIndex(index), "Tuple element index" << index << " is out of bounds."); + Y_ENSURE(CheckIndex(index), "Tuple element index" << index << " is out of bounds."); const auto& elementType = RootType.GetTuple().GetElement(index); const auto& element = RootValue.GetTuple(index); return TDict(element, elementType); diff --git a/ydb/core/client/s3_listing_ut.cpp b/ydb/core/client/s3_listing_ut.cpp index 919c45dc467..1cde1237740 100644 --- a/ydb/core/client/s3_listing_ut.cpp +++ b/ydb/core/client/s3_listing_ut.cpp @@ -8,7 +8,7 @@ namespace NFlatTests { using namespace Tests; using NClient::TValue; -Y_UNIT_TEST_SUITE(TS3ListingTest) { +Y_UNIT_TEST_SUITE(TS3ListingTest) { void S3WriteRow(TFlatMsgBusClient& annoyingClient, ui64 hash, TString name, TString path, ui64 version, ui64 ts, TString data, TString table) { TString insertRowQuery = R"( @@ -347,7 +347,7 @@ Y_UNIT_TEST_SUITE(TS3ListingTest) { } } - Y_UNIT_TEST(Listing) { + Y_UNIT_TEST(Listing) { TPortManager pm; ui16 port = pm.GetPort(2134); TServer cleverServer = TServer(TServerSettings(port)); @@ -478,7 +478,7 @@ Y_UNIT_TEST_SUITE(TS3ListingTest) { expectedStatus, expectedErrMessage); } - Y_UNIT_TEST(SchemaChecks) { + Y_UNIT_TEST(SchemaChecks) { TPortManager pm; ui16 port = pm.GetPort(2134); TServer cleverServer = TServer(TServerSettings(port)); @@ -584,7 +584,7 @@ Y_UNIT_TEST_SUITE(TS3ListingTest) { CompareS3Listing(annoyingClient, 100, "/", "/", "", 100500, {"Path"}); } - Y_UNIT_TEST(SuffixColumns) { + Y_UNIT_TEST(SuffixColumns) { TPortManager pm; ui16 port = pm.GetPort(2134); TServer cleverServer = TServer(TServerSettings(port)); diff --git a/ydb/core/client/scheme_cache_lib/yql_db_scheme_resolver.cpp b/ydb/core/client/scheme_cache_lib/yql_db_scheme_resolver.cpp index eb74fa36e94..9bb5d28aaa7 100644 --- a/ydb/core/client/scheme_cache_lib/yql_db_scheme_resolver.cpp +++ b/ydb/core/client/scheme_cache_lib/yql_db_scheme_resolver.cpp @@ -25,7 +25,7 @@ class TTableProxyActor : public TActorBootstrapped<TTableProxyActor> { void Handle(TEvTxProxySchemeCache::TEvNavigateKeySetResult::TPtr &ev, const TActorContext &ctx) { const NSchemeCache::TSchemeCacheNavigate &request = *ev->Get()->Request; - Y_VERIFY(request.ResultSet.size() == Tables.size()); + Y_VERIFY(request.ResultSet.size() == Tables.size()); TVector<TTableResult> results; results.reserve(Tables.size()); diff --git a/ydb/core/client/server/msgbus_server_hive_create_tablet.cpp b/ydb/core/client/server/msgbus_server_hive_create_tablet.cpp index 0c41e53f090..b46d7c94da5 100644 --- a/ydb/core/client/server/msgbus_server_hive_create_tablet.cpp +++ b/ydb/core/client/server/msgbus_server_hive_create_tablet.cpp @@ -212,7 +212,7 @@ public: } void Handle(TEvTabletPipe::TEvClientDestroyed::TPtr &ev, const TActorContext &ctx) { - Y_UNUSED(ev); + Y_UNUSED(ev); PipeClient = TActorId(); ErrorReason = Sprintf("Client pipe to Hive destroyed (connection lost), Marker# HC9"); SendReplyMove(CreateErrorReply(MSTATUS_ERROR, ctx)); @@ -233,7 +233,7 @@ public: } virtual NBus::TBusMessage* CreateErrorReply(EResponseStatus status, const TActorContext &ctx) { - Y_UNUSED(ctx); + Y_UNUSED(ctx); THolder<ResponseType> result(new ResponseType()); auto &rec = result->Record; rec.SetStatus(status); diff --git a/ydb/core/client/server/msgbus_server_keyvalue.cpp b/ydb/core/client/server/msgbus_server_keyvalue.cpp index ad644f4c269..80c8e78c6b3 100644 --- a/ydb/core/client/server/msgbus_server_keyvalue.cpp +++ b/ydb/core/client/server/msgbus_server_keyvalue.cpp @@ -31,7 +31,7 @@ public: } TEvKeyValue::TEvRequest* MakeReq(const TActorContext &ctx) { - Y_UNUSED(ctx); + Y_UNUSED(ctx); THolder<TEvKeyValue::TEvRequest> request(new TEvKeyValue::TEvRequest()); request->Record = RequestProto; return request.Release(); diff --git a/ydb/core/client/server/msgbus_server_local_enumerate_tablets.cpp b/ydb/core/client/server/msgbus_server_local_enumerate_tablets.cpp index 9f867dddc7c..c2311bff5df 100644 --- a/ydb/core/client/server/msgbus_server_local_enumerate_tablets.cpp +++ b/ydb/core/client/server/msgbus_server_local_enumerate_tablets.cpp @@ -44,7 +44,7 @@ public: void Handle(TEvLocal::TEvEnumerateTabletsResult::TPtr &ev, const TActorContext &ctx) { const NKikimrLocal::TEvEnumerateTabletsResult &record = ev->Get()->Record; - Y_VERIFY(record.HasStatus()); + Y_VERIFY(record.HasStatus()); THolder<ResponseType> response(new ResponseType()); if (record.GetStatus() != NKikimrProto::OK) { response->Record.SetStatus(MSTATUS_ERROR); @@ -82,7 +82,7 @@ public: } TEvLocal::TEvEnumerateTablets* MakeReq(const TActorContext &ctx) { - Y_UNUSED(ctx); + Y_UNUSED(ctx); if (IsFiltered) { return new TEvLocal::TEvEnumerateTablets(TabletType); } @@ -90,8 +90,8 @@ public: } NBus::TBusMessage* CreateErrorReply(EResponseStatus status, const TActorContext &ctx) { - Y_UNUSED(ctx); - Y_UNUSED(status); + Y_UNUSED(ctx); + Y_UNUSED(status); ui64 nodeId = IsNodeIdPresent ? NodeId : ctx.SelfID.NodeId(); THolder<ResponseType> response(new ResponseType()); response->Record.SetStatus(MSTATUS_ERROR); @@ -101,13 +101,13 @@ public: } void HandleTimeout(const TActorContext &ctx) { - Y_UNUSED(ctx); + Y_UNUSED(ctx); TAutoPtr<TBusResponse> response(new TBusResponseStatus(MSTATUS_TIMEOUT, "")); TBase::SendReplyAndDie(response.Release(), ctx); } void HandleUndelivered(TEvents::TEvUndelivered::TPtr& ev, const TActorContext& ctx) { - Y_UNUSED(ev); + Y_UNUSED(ev); THolder<ResponseType> response(new ResponseType()); ui64 nodeId = IsNodeIdPresent ? NodeId : ctx.SelfID.NodeId(); response->Record.SetStatus(MSTATUS_ERROR); diff --git a/ydb/core/client/server/msgbus_server_local_minikql.cpp b/ydb/core/client/server/msgbus_server_local_minikql.cpp index 42fa4ed9a83..fd3dc7f2afc 100644 --- a/ydb/core/client/server/msgbus_server_local_minikql.cpp +++ b/ydb/core/client/server/msgbus_server_local_minikql.cpp @@ -43,7 +43,7 @@ public: } TEvTablet::TEvLocalMKQL* MakeReq(const TActorContext &ctx) { - Y_UNUSED(ctx); + Y_UNUSED(ctx); TAutoPtr<TEvTablet::TEvLocalMKQL> req = new TEvTablet::TEvLocalMKQL(); auto *pgm = req->Record.MutableProgram(); diff --git a/ydb/core/client/server/msgbus_server_request.cpp b/ydb/core/client/server/msgbus_server_request.cpp index 9223bea9f1a..39be2baf576 100644 --- a/ydb/core/client/server/msgbus_server_request.cpp +++ b/ydb/core/client/server/msgbus_server_request.cpp @@ -271,7 +271,7 @@ bool TMessageBusServerRequest::AllRequestsCompletedMKQL(const TActorContext& ctx return true; } default: - Y_FAIL("Unknown mkqlTxMode."); + Y_FAIL("Unknown mkqlTxMode."); } } diff --git a/ydb/core/client/server/msgbus_server_tablet_kill.cpp b/ydb/core/client/server/msgbus_server_tablet_kill.cpp index 62da8569e2c..c2eb2493d55 100644 --- a/ydb/core/client/server/msgbus_server_tablet_kill.cpp +++ b/ydb/core/client/server/msgbus_server_tablet_kill.cpp @@ -11,7 +11,7 @@ public: {} TEvents::TEvPoisonPill* MakeReq(const TActorContext &ctx) { - Y_UNUSED(ctx); + Y_UNUSED(ctx); return new TEvents::TEvPoisonPill(); } diff --git a/ydb/core/client/server/msgbus_server_tracer.cpp b/ydb/core/client/server/msgbus_server_tracer.cpp index ff93f8d1cbe..a90b9d56ad4 100644 --- a/ydb/core/client/server/msgbus_server_tracer.cpp +++ b/ydb/core/client/server/msgbus_server_tracer.cpp @@ -114,7 +114,7 @@ void TMessageBusTracerService::HandleStartTrace(TEvMessageBusTracer::TEvStartTra void TMessageBusTracerService::HandleStopTrace(TEvMessageBusTracer::TEvStopTrace::TPtr &ev, const TActorContext &ctx) { const TEvMessageBusTracer::TEvStopTrace *event = ev->Get(); - Y_UNUSED(event); + Y_UNUSED(event); LOG_NOTICE_S(ctx, NKikimrServices::MSGBUS_TRACER, "MessageBus tracing stopped, file '" << Path << "' " << ctx.SelfID.ToString()); Path.clear(); @@ -167,24 +167,24 @@ public: } TActorId MakeServiceID(const TActorContext &ctx) { - Y_UNUSED(ctx); + Y_UNUSED(ctx); return MakeMessageBusTraceServiceID(); } NBus::TBusMessage* CreateErrorReply(NMsgBusProxy::EResponseStatus status, const TActorContext &ctx) { - Y_UNUSED(ctx); + Y_UNUSED(ctx); TAutoPtr<NMsgBusProxy::TBusResponse> response(new NMsgBusProxy::TBusResponseStatus(status, "Service not found")); return response.Release(); } void HandleTimeout(const TActorContext &ctx) { - Y_UNUSED(ctx); + Y_UNUSED(ctx); TAutoPtr<NMsgBusProxy::TBusResponse> response(new NMsgBusProxy::TBusResponseStatus(NMsgBusProxy::MSTATUS_TIMEOUT, "")); this->SendReplyAndDie(response.Release(), ctx); } void HandleUndelivered(TEvents::TEvUndelivered::TPtr& ev, const TActorContext& ctx) { - Y_UNUSED(ev); + Y_UNUSED(ev); TAutoPtr<NMsgBusProxy::TBusResponse> response(new NMsgBusProxy::TBusResponseStatus(NMsgBusProxy::MSTATUS_ERROR, "HandleUndelivered")); response->Record.SetErrorReason("Cannot deliver request to the service"); this->SendReplyAndDie(response.Release(), ctx); @@ -209,7 +209,7 @@ public: } TEvMessageBusTracer::TEvStartTrace* MakeReq(const TActorContext &ctx) { - Y_UNUSED(ctx); + Y_UNUSED(ctx); return new TEvMessageBusTracer::TEvStartTrace(Path); } }; @@ -225,7 +225,7 @@ public: {} TEvMessageBusTracer::TEvStopTrace* MakeReq(const TActorContext &ctx) { - Y_UNUSED(ctx); + Y_UNUSED(ctx); return new TEvMessageBusTracer::TEvStopTrace(); } }; diff --git a/ydb/core/client/server/msgbus_server_tracer.h b/ydb/core/client/server/msgbus_server_tracer.h index 57a3812f5d5..5e051a9db8d 100644 --- a/ydb/core/client/server/msgbus_server_tracer.h +++ b/ydb/core/client/server/msgbus_server_tracer.h @@ -94,7 +94,7 @@ private: void HandleStopTrace(TEvMessageBusTracer::TEvStopTrace::TPtr &ev, const TActorContext &ctx); void HandleTraceEvent(TEvMessageBusTracer::TEvTraceEvent::TPtr &ev, const TActorContext &); - TAutoPtr<IOutputStream> Stream; + TAutoPtr<IOutputStream> Stream; TString Path; }; diff --git a/ydb/core/client/server/msgbus_servicereq.h b/ydb/core/client/server/msgbus_servicereq.h index 704a231dd1d..fe2bc0853ea 100644 --- a/ydb/core/client/server/msgbus_servicereq.h +++ b/ydb/core/client/server/msgbus_servicereq.h @@ -29,7 +29,7 @@ protected: public: NBus::TBusMessage* CreateErrorReply(EResponseStatus status, const TActorContext &ctx) { - Y_UNUSED(ctx); + Y_UNUSED(ctx); return new TBusResponseStatus(status, "undocumented error 3"); } diff --git a/ydb/core/client/server/msgbus_tabletreq.h b/ydb/core/client/server/msgbus_tabletreq.h index f173ae90976..e2b54189dac 100644 --- a/ydb/core/client/server/msgbus_tabletreq.h +++ b/ydb/core/client/server/msgbus_tabletreq.h @@ -41,7 +41,7 @@ private: } void Handle(TEvTabletPipe::TEvClientDestroyed::TPtr &ev, const TActorContext &ctx) { - Y_UNUSED(ev); + Y_UNUSED(ev); PipeClient = TActorId(); SendReplyMove(CreateErrorReply(MSTATUS_ERROR, ctx, "Tablet pipe client destroyed Marker# MBT2")); return Die(ctx); diff --git a/ydb/core/cms/cluster_info_ut.cpp b/ydb/core/cms/cluster_info_ut.cpp index 8b9d3b3d653..a01fe58a073 100644 --- a/ydb/core/cms/cluster_info_ut.cpp +++ b/ydb/core/cms/cluster_info_ut.cpp @@ -235,8 +235,8 @@ void CheckScheduledLocks(const TLockableItem &item, Ts... locks) CheckScheduledLocks(item.ScheduledLocks.begin(), item.ScheduledLocks.end(), locks...); } -Y_UNIT_TEST_SUITE(TClusterInfoTest) { - Y_UNIT_TEST(DeviceId) { +Y_UNIT_TEST_SUITE(TClusterInfoTest) { + Y_UNIT_TEST(DeviceId) { UNIT_ASSERT(!TPDiskInfo::IsDeviceName("pdisk")); UNIT_ASSERT(!TPDiskInfo::IsDeviceName("disk-1")); UNIT_ASSERT(!TPDiskInfo::IsDeviceName("pdisk-")); @@ -253,7 +253,7 @@ Y_UNIT_TEST_SUITE(TClusterInfoTest) { UNIT_ASSERT_VALUES_EQUAL(TVDiskInfo::NameToId("vdisk-1-2-3-4-5"), TVDiskID(1, 2, 3, 4, 5)); } - Y_UNIT_TEST(FillInfo) { + Y_UNIT_TEST(FillInfo) { TEvInterconnect::TNodeInfo node1 = { 1, "::1", "test1", "test1", 1, TNodeLocation() }; TEvInterconnect::TNodeInfo node2 = diff --git a/ydb/core/cms/cms_ut.cpp b/ydb/core/cms/cms_ut.cpp index 9842fb71567..b2673ce23df 100644 --- a/ydb/core/cms/cms_ut.cpp +++ b/ydb/core/cms/cms_ut.cpp @@ -40,8 +40,8 @@ void CheckLoadLogRecord(const NKikimrCms::TLogRecord &rec, } // anonymous namespace -Y_UNIT_TEST_SUITE(TCmsTest) { - Y_UNIT_TEST(CollectInfo) +Y_UNIT_TEST_SUITE(TCmsTest) { + Y_UNIT_TEST(CollectInfo) { TCmsTestEnv env(8); @@ -99,7 +99,7 @@ Y_UNIT_TEST_SUITE(TCmsTest) { } } - Y_UNIT_TEST(StateRequest) + Y_UNIT_TEST(StateRequest) { TCmsTestEnv env(8); auto before = env.GetCurrentTime(); @@ -143,7 +143,7 @@ Y_UNIT_TEST_SUITE(TCmsTest) { } } - Y_UNIT_TEST(StateRequestNode) + Y_UNIT_TEST(StateRequestNode) { TCmsTestEnv env(8, TNodeTenantsMap{{1, {"user0"}}}); @@ -169,7 +169,7 @@ Y_UNIT_TEST_SUITE(TCmsTest) { } } - Y_UNIT_TEST(StateRequestUnknownNode) + Y_UNIT_TEST(StateRequestUnknownNode) { TCmsTestEnv env(8); @@ -178,7 +178,7 @@ Y_UNIT_TEST_SUITE(TCmsTest) { env.RequestState(request, TStatus::NO_SUCH_HOST); } - Y_UNIT_TEST(StateRequestUnknownMultipleNodes) + Y_UNIT_TEST(StateRequestUnknownMultipleNodes) { TCmsTestEnv env(8); @@ -187,7 +187,7 @@ Y_UNIT_TEST_SUITE(TCmsTest) { env.RequestState(request, TStatus::NO_SUCH_HOST); } - Y_UNIT_TEST(RequestRestartServicesOk) + Y_UNIT_TEST(RequestRestartServicesOk) { TCmsTestEnv env(8); @@ -204,7 +204,7 @@ Y_UNIT_TEST_SUITE(TCmsTest) { UNIT_ASSERT_VALUES_EQUAL(action1.GetDuration(), 60000000); } - Y_UNIT_TEST(RequestRestartServicesReject) + Y_UNIT_TEST(RequestRestartServicesReject) { TCmsTestEnv env(8); @@ -213,7 +213,7 @@ Y_UNIT_TEST_SUITE(TCmsTest) { MakeAction(TAction::RESTART_SERVICES, env.GetNodeId(1), 60000000, "storage")); } - Y_UNIT_TEST(RequestRestartServicesPartial) + Y_UNIT_TEST(RequestRestartServicesPartial) { TCmsTestEnv env(8); @@ -232,7 +232,7 @@ Y_UNIT_TEST_SUITE(TCmsTest) { UNIT_ASSERT_VALUES_EQUAL(action1.GetDuration(), 60000000); } - Y_UNIT_TEST(RequestRestartServicesRejectSecond) + Y_UNIT_TEST(RequestRestartServicesRejectSecond) { TCmsTestEnv env(8); @@ -242,7 +242,7 @@ Y_UNIT_TEST_SUITE(TCmsTest) { MakeAction(TAction::RESTART_SERVICES, env.GetNodeId(1), 60000000, "storage")); } - Y_UNIT_TEST(RequestRestartServicesWrongHost) + Y_UNIT_TEST(RequestRestartServicesWrongHost) { TCmsTestEnv env(8); @@ -250,7 +250,7 @@ Y_UNIT_TEST_SUITE(TCmsTest) { MakeAction(TAction::RESTART_SERVICES, "host", 60000000, "storage")); } - Y_UNIT_TEST(RequestRestartServicesMultipleNodes) + Y_UNIT_TEST(RequestRestartServicesMultipleNodes) { TCmsTestEnv env(8); @@ -258,7 +258,7 @@ Y_UNIT_TEST_SUITE(TCmsTest) { MakeAction(TAction::RESTART_SERVICES, "::1", 60000000, "storage")); } - Y_UNIT_TEST(RequestRestartServicesNoUser) + Y_UNIT_TEST(RequestRestartServicesNoUser) { TCmsTestEnv env(8); @@ -266,7 +266,7 @@ Y_UNIT_TEST_SUITE(TCmsTest) { MakeAction(TAction::RESTART_SERVICES, "::1", 60000000, "storage")); } - Y_UNIT_TEST(RequestRestartServicesDryRun) + Y_UNIT_TEST(RequestRestartServicesDryRun) { TCmsTestEnv env(8); @@ -282,7 +282,7 @@ Y_UNIT_TEST_SUITE(TCmsTest) { UNIT_ASSERT_VALUES_EQUAL(rec2.PermissionsSize(), 1); } - Y_UNIT_TEST(ManagePermissions) + Y_UNIT_TEST(ManagePermissions) { TCmsTestEnv env(8); @@ -351,7 +351,7 @@ Y_UNIT_TEST_SUITE(TCmsTest) { UNIT_ASSERT_VALUES_EQUAL(rec5.PermissionsSize(), 1); } - Y_UNIT_TEST(ManagePermissionWrongRequest) + Y_UNIT_TEST(ManagePermissionWrongRequest) { TCmsTestEnv env(8); @@ -382,7 +382,7 @@ Y_UNIT_TEST_SUITE(TCmsTest) { env.CheckRejectPermission("user", id + "-bad", false, TStatus::WRONG_REQUEST); } - Y_UNIT_TEST(RequestReplaceDevices) + Y_UNIT_TEST(RequestReplaceDevices) { TCmsTestEnv env(8); @@ -460,7 +460,7 @@ Y_UNIT_TEST_SUITE(TCmsTest) { "vdisk-3-1-0-1-0", "vdisk-3-1-0-5-0")); } - Y_UNIT_TEST(RequestReplaceBrokenDevices) + Y_UNIT_TEST(RequestReplaceBrokenDevices) { TCmsTestEnv env(8); @@ -477,7 +477,7 @@ Y_UNIT_TEST_SUITE(TCmsTest) { MakeAction(TAction::REPLACE_DEVICES, 1, 60000000, env.PDiskName(1))); } - Y_UNIT_TEST(ManageRequestsWrong) + Y_UNIT_TEST(ManageRequestsWrong) { TCmsTestEnv env(8); @@ -494,7 +494,7 @@ Y_UNIT_TEST_SUITE(TCmsTest) { env.CheckGetRequest("user1", id1, false, TStatus::WRONG_REQUEST); } - Y_UNIT_TEST(ManageRequestsDry) + Y_UNIT_TEST(ManageRequestsDry) { TCmsTestEnv env(8); @@ -516,7 +516,7 @@ Y_UNIT_TEST_SUITE(TCmsTest) { env.CheckGetRequest("user", rid1, false, TStatus::WRONG_REQUEST); } - Y_UNIT_TEST(ManageRequests) + Y_UNIT_TEST(ManageRequests) { TCmsTestEnv env(8, 4); @@ -619,7 +619,7 @@ Y_UNIT_TEST_SUITE(TCmsTest) { env.CheckListRequests( "user", 0); } - Y_UNIT_TEST(WalleTasks) + Y_UNIT_TEST(WalleTasks) { TCmsTestEnv env(24, 4); @@ -718,7 +718,7 @@ Y_UNIT_TEST_SUITE(TCmsTest) { env.CheckWalleCheckTask("task-2", TStatus::ALLOW, env.GetNodeId(1)); } - Y_UNIT_TEST(Notifications) + Y_UNIT_TEST(Notifications) { TCmsTestEnv env(8); env.AdvanceCurrentTime(TDuration::Minutes(20)); @@ -786,7 +786,7 @@ Y_UNIT_TEST_SUITE(TCmsTest) { env.CheckGetNotification("user", id1, TStatus::OK); } - Y_UNIT_TEST(PermissionDuration) { + Y_UNIT_TEST(PermissionDuration) { TCmsTestEnv env(8); // Store notification user-1. @@ -804,7 +804,7 @@ Y_UNIT_TEST_SUITE(TCmsTest) { MakeAction(TAction::REPLACE_DEVICES, env.GetNodeId(0), 60000000, env.PDiskName(1, 0))); } - Y_UNIT_TEST(ActionWithZeroDuration) { + Y_UNIT_TEST(ActionWithZeroDuration) { TCmsTestEnv env(8); env.CheckPermissionRequest("user", false, false, false, true, TStatus::ALLOW, @@ -816,7 +816,7 @@ Y_UNIT_TEST_SUITE(TCmsTest) { env.DispatchEvents(options); } - Y_UNIT_TEST(DynamicConfig) + Y_UNIT_TEST(DynamicConfig) { TCmsTestEnv env(1); diff --git a/ydb/core/cms/console/console_ut_configs.cpp b/ydb/core/cms/console/console_ut_configs.cpp index 0cb1655281d..525e2a56237 100644 --- a/ydb/core/cms/console/console_ut_configs.cpp +++ b/ydb/core/cms/console/console_ut_configs.cpp @@ -903,8 +903,8 @@ TVector<ui64> CheckConfigureLogAffected(TTenantTestRuntime &runtime, } // anonymous namespace -Y_UNIT_TEST_SUITE(TConsoleConfigTests) { - Y_UNIT_TEST(TestAddConfigItem) { +Y_UNIT_TEST_SUITE(TConsoleConfigTests) { + Y_UNIT_TEST(TestAddConfigItem) { TTenantTestRuntime runtime(DefaultConsoleTestConfig()); InitializeTestConfigItems(); @@ -960,7 +960,7 @@ Y_UNIT_TEST_SUITE(TConsoleConfigTests) { ITEM_DOMAIN_TENANT_POOL_2, ITEM_HOST12_LOG_1); } - Y_UNIT_TEST(TestModifyConfigItem) { + Y_UNIT_TEST(TestModifyConfigItem) { TTenantTestRuntime runtime(DefaultConsoleTestConfig()); InitializeTestConfigItems(); @@ -1075,7 +1075,7 @@ Y_UNIT_TEST_SUITE(TConsoleConfigTests) { ITEM_DOMAIN_TENANT_POOL_2); } - Y_UNIT_TEST(TestRemoveConfigItem) { + Y_UNIT_TEST(TestRemoveConfigItem) { TTenantTestRuntime runtime(DefaultConsoleTestConfig()); InitializeTestConfigItems(); @@ -1161,7 +1161,7 @@ Y_UNIT_TEST_SUITE(TConsoleConfigTests) { CheckGetItems(runtime, TVector<ui32>()); } - Y_UNIT_TEST(TestConfigureOrderConflicts) { + Y_UNIT_TEST(TestConfigureOrderConflicts) { TTenantTestRuntime runtime(DefaultConsoleTestConfig()); InitializeTestConfigItems(); @@ -1314,7 +1314,7 @@ Y_UNIT_TEST_SUITE(TConsoleConfigTests) { ITEM_TENANT2_TYPE1_LOG_1, ITEM_TENANT2_TYPE2_LOG_1); } - Y_UNIT_TEST(TestGetItems) { + Y_UNIT_TEST(TestGetItems) { TTenantTestRuntime runtime(DefaultConsoleTestConfig()); InitializeTestConfigItems(); @@ -1721,7 +1721,7 @@ Y_UNIT_TEST_SUITE(TConsoleConfigTests) { ITEM_TENANT2_TYPE2_LOG_1, ITEM_TENANT2_TYPE2_LOG_2); } - Y_UNIT_TEST(TestGetNodeItems) { + Y_UNIT_TEST(TestGetNodeItems) { TTenantTestRuntime runtime(DefaultConsoleTestConfig()); InitializeTestConfigItems(); @@ -1787,7 +1787,7 @@ Y_UNIT_TEST_SUITE(TConsoleConfigTests) { ITEM_DOMAIN_LOG_1, ITEM_DOMAIN_LOG_2); } - Y_UNIT_TEST(TestGetNodeConfig) { + Y_UNIT_TEST(TestGetNodeConfig) { TTenantTestRuntime runtime(DefaultConsoleTestConfig()); InitializeTestConfigItems(); @@ -1876,7 +1876,7 @@ Y_UNIT_TEST_SUITE(TConsoleConfigTests) { TVector<ui32>({(ui32)NKikimrConsole::TConfigItem::LogConfigItem})); } - Y_UNIT_TEST(TestAutoOrder) { + Y_UNIT_TEST(TestAutoOrder) { TTenantTestRuntime runtime(DefaultConsoleTestConfig()); InitializeTestConfigItems(); @@ -1935,7 +1935,7 @@ Y_UNIT_TEST_SUITE(TConsoleConfigTests) { ITEM_DOMAIN_LOG_1, ITEM_DOMAIN_LOG_2); } - Y_UNIT_TEST(TestAutoKind) { + Y_UNIT_TEST(TestAutoKind) { TTenantTestRuntime runtime(DefaultConsoleTestConfig()); InitializeTestConfigItems(); @@ -1959,7 +1959,7 @@ Y_UNIT_TEST_SUITE(TConsoleConfigTests) { MakeAddAction(ITEM_DOMAIN_LOG_2)); } - Y_UNIT_TEST(TestAutoSplit) { + Y_UNIT_TEST(TestAutoSplit) { TTenantTestRuntime runtime(DefaultConsoleTestConfig()); InitializeTestConfigItems(); diff --git a/ydb/core/cms/console/console_ut_tenants.cpp b/ydb/core/cms/console/console_ut_tenants.cpp index 57e4820af72..4c1b56dc91f 100644 --- a/ydb/core/cms/console/console_ut_tenants.cpp +++ b/ydb/core/cms/console/console_ut_tenants.cpp @@ -653,7 +653,7 @@ Y_UNIT_TEST_SUITE(TConsoleTxProcessorTests) { } -Y_UNIT_TEST_SUITE(TConsoleTests) { +Y_UNIT_TEST_SUITE(TConsoleTests) { void RunTestCreateTenant(TTenantTestRuntime& runtime, bool shared = false) { using EType = TCreateTenantRequest::EType; diff --git a/ydb/core/cms/downtime_ut.cpp b/ydb/core/cms/downtime_ut.cpp index 12a5bdbdde8..cb16029192a 100644 --- a/ydb/core/cms/downtime_ut.cpp +++ b/ydb/core/cms/downtime_ut.cpp @@ -53,8 +53,8 @@ void CheckDowntime(const TDowntime &downtime, Ts... intervals) intervals...); } -Y_UNIT_TEST_SUITE(TDowntimeTest) { - Y_UNIT_TEST(AddDowntime) +Y_UNIT_TEST_SUITE(TDowntimeTest) { + Y_UNIT_TEST(AddDowntime) { TDowntime downtime1(TDuration::Seconds(10)); TInstant t1 = Now(); @@ -148,7 +148,7 @@ Y_UNIT_TEST_SUITE(TDowntimeTest) { CheckDowntime(downtime2, t3, t4, "notification-2"); } - Y_UNIT_TEST(HasUpcomingDowntime) + Y_UNIT_TEST(HasUpcomingDowntime) { TDowntime downtime1(TDuration::Seconds(5)); TInstant t1 = Now(); @@ -176,7 +176,7 @@ Y_UNIT_TEST_SUITE(TDowntimeTest) { UNIT_ASSERT(!downtime1.HasUpcomingDowntime(t6, TDuration::Seconds(0), TDuration::Seconds(11))); } - Y_UNIT_TEST(SetIgnoredDowntimeGap) + Y_UNIT_TEST(SetIgnoredDowntimeGap) { TDowntime downtime1(TDuration::Seconds(5)); TInstant t1 = Now(); @@ -205,7 +205,7 @@ Y_UNIT_TEST_SUITE(TDowntimeTest) { CheckDowntime(downtime1, t1, t8, "s1, s2, s3, s4"); } - Y_UNIT_TEST(CleanupOldSegments) + Y_UNIT_TEST(CleanupOldSegments) { TDowntime downtime1(TDuration::Seconds(5)); TInstant t1 = Now(); diff --git a/ydb/core/control/immediate_control_board_actor_ut.cpp b/ydb/core/control/immediate_control_board_actor_ut.cpp index 2753077d936..181ff9d90f0 100644 --- a/ydb/core/control/immediate_control_board_actor_ut.cpp +++ b/ydb/core/control/immediate_control_board_actor_ut.cpp @@ -431,12 +431,12 @@ public: {} }; -Y_UNIT_TEST_SUITE(IcbAsActorTests) { - Y_UNIT_TEST(TestHttpGetResponse) { +Y_UNIT_TEST_SUITE(IcbAsActorTests) { + Y_UNIT_TEST(TestHttpGetResponse) { Run<TTestHttpGetResponse>(); } - Y_UNIT_TEST(TestHttpPostReaction) { + Y_UNIT_TEST(TestHttpPostReaction) { Run<TTestHttpPostReaction>(); } }; diff --git a/ydb/core/control/immediate_control_board_ut.cpp b/ydb/core/control/immediate_control_board_ut.cpp index dba6280ab5b..0e9c35aa35f 100644 --- a/ydb/core/control/immediate_control_board_ut.cpp +++ b/ydb/core/control/immediate_control_board_ut.cpp @@ -19,8 +19,8 @@ namespace NKikimr { Cout << Endl #endif -Y_UNIT_TEST_SUITE(ControlImplementationTests) { - Y_UNIT_TEST(TestTControl) { +Y_UNIT_TEST_SUITE(ControlImplementationTests) { + Y_UNIT_TEST(TestTControl) { NPrivate::TMersenne64 randGen(Seed()); std::array<i64, 3> bounds; for (ui64 i = 0; i < 3; ++i) { @@ -57,7 +57,7 @@ Y_UNIT_TEST_SUITE(ControlImplementationTests) { } } - Y_UNIT_TEST(TestControlWrapperAsI64) { + Y_UNIT_TEST(TestControlWrapperAsI64) { NPrivate::TMersenne64 randGen(Seed()); TControlWrapper wrapper1; for (ui64 i = 0; i < TEST_REPEATS; ++i) { @@ -69,7 +69,7 @@ Y_UNIT_TEST_SUITE(ControlImplementationTests) { } } - Y_UNIT_TEST(TestControlWrapperBounds) { + Y_UNIT_TEST(TestControlWrapperBounds) { NPrivate::TMersenne64 randGen(Seed()); std::array<i64, 3> bounds; for (ui64 i = 0; i < 3; ++i) { @@ -88,7 +88,7 @@ Y_UNIT_TEST_SUITE(ControlImplementationTests) { } } - Y_UNIT_TEST(TestRegisterLocalControl) { + Y_UNIT_TEST(TestRegisterLocalControl) { TIntrusivePtr<TControlBoard> Icb(new TControlBoard); TControlWrapper control1(1, 1, 1); TControlWrapper control2(2, 2, 2); @@ -97,7 +97,7 @@ Y_UNIT_TEST_SUITE(ControlImplementationTests) { UNIT_ASSERT_EQUAL(1, 1); } - Y_UNIT_TEST(TestRegisterSharedControl) { + Y_UNIT_TEST(TestRegisterSharedControl) { TIntrusivePtr<TControlBoard> Icb(new TControlBoard); TControlWrapper control1(1, 1, 1); TControlWrapper control1_origin(control1); @@ -109,7 +109,7 @@ Y_UNIT_TEST_SUITE(ControlImplementationTests) { UNIT_ASSERT(control2.IsTheSame(control1_origin)); } - Y_UNIT_TEST(TestParallelRegisterSharedControl) { + Y_UNIT_TEST(TestParallelRegisterSharedControl) { void* (*parallelJob)(void*) = [](void *controlBoard) -> void *{ TControlBoard *Icb = reinterpret_cast<TControlBoard *>(controlBoard); TControlWrapper control1(1, 1, 1); diff --git a/ydb/core/driver_lib/base_utils/format_info.cpp b/ydb/core/driver_lib/base_utils/format_info.cpp index e5d53a7b803..31745e1c97d 100644 --- a/ydb/core/driver_lib/base_utils/format_info.cpp +++ b/ydb/core/driver_lib/base_utils/format_info.cpp @@ -8,7 +8,7 @@ namespace NKikimr { int MainFormatInfo(const TCommandConfig &cmdConf, int argc, char** argv) { - Y_UNUSED(cmdConf); + Y_UNUSED(cmdConf); TCmdFormatInfoConfig formatInfoConfig; formatInfoConfig.Parse(argc, argv); diff --git a/ydb/core/driver_lib/base_utils/format_util.cpp b/ydb/core/driver_lib/base_utils/format_util.cpp index e6f99b16344..a9094bf8448 100644 --- a/ydb/core/driver_lib/base_utils/format_util.cpp +++ b/ydb/core/driver_lib/base_utils/format_util.cpp @@ -5,26 +5,26 @@ namespace NKikimr { int MainFormatUtil(const TCommandConfig &cmdConf, int argc, char** argv) { - Y_UNUSED(cmdConf); + Y_UNUSED(cmdConf); TCmdFormatUtilConfig config; config.Parse(argc, argv); - Y_VERIFY(config.NodeId != 0); + Y_VERIFY(config.NodeId != 0); TAutoPtr<NKikimrConfig::TBlobStorageFormatConfig> formatConfig; formatConfig.Reset(new NKikimrConfig::TBlobStorageFormatConfig()); - Y_VERIFY(ParsePBFromFile(config.FormatFile, formatConfig.Get())); + Y_VERIFY(ParsePBFromFile(config.FormatFile, formatConfig.Get())); size_t driveSize = formatConfig->DriveSize(); bool isFirst = true; for (size_t driveIdx = 0; driveIdx < driveSize; ++driveIdx) { const NKikimrConfig::TBlobStorageFormatConfig::TDrive& drive = formatConfig->GetDrive(driveIdx); - Y_VERIFY(drive.HasNodeId()); - Y_VERIFY(drive.HasType()); - Y_VERIFY(drive.HasPath()); - Y_VERIFY(drive.HasGuid()); - Y_VERIFY(drive.HasPDiskId()); + Y_VERIFY(drive.HasNodeId()); + Y_VERIFY(drive.HasType()); + Y_VERIFY(drive.HasPath()); + Y_VERIFY(drive.HasGuid()); + Y_VERIFY(drive.HasPDiskId()); if (drive.GetNodeId() == config.NodeId) { if (isFirst) { isFirst = false; diff --git a/ydb/core/driver_lib/base_utils/node_by_host.cpp b/ydb/core/driver_lib/base_utils/node_by_host.cpp index 81344f4dae2..2a4e1fe15cd 100644 --- a/ydb/core/driver_lib/base_utils/node_by_host.cpp +++ b/ydb/core/driver_lib/base_utils/node_by_host.cpp @@ -5,16 +5,16 @@ namespace NKikimr { int MainNodeByHost(const TCommandConfig &cmdConf, int argc, char** argv) { - Y_UNUSED(cmdConf); + Y_UNUSED(cmdConf); TCmdNodeByHostConfig nodeByHostConfig; nodeByHostConfig.Parse(argc, argv); - Y_VERIFY(nodeByHostConfig.Port == -1 || (nodeByHostConfig.Port >= 0 && nodeByHostConfig.Port <= 0xffff)); + Y_VERIFY(nodeByHostConfig.Port == -1 || (nodeByHostConfig.Port >= 0 && nodeByHostConfig.Port <= 0xffff)); TAutoPtr<NKikimrConfig::TStaticNameserviceConfig> nameserviceConfig; nameserviceConfig.Reset(new NKikimrConfig::TStaticNameserviceConfig()); - Y_VERIFY(ParsePBFromFile(nodeByHostConfig.NamingFile, nameserviceConfig.Get())); + Y_VERIFY(ParsePBFromFile(nodeByHostConfig.NamingFile, nameserviceConfig.Get())); size_t nodeSize = nameserviceConfig->NodeSize(); ui32 nodeId = 0; @@ -22,18 +22,18 @@ int MainNodeByHost(const TCommandConfig &cmdConf, int argc, char** argv) { bool isPortPresent = (nodeByHostConfig.Port != -1); for (size_t nodeIdx = 0; nodeIdx < nodeSize; ++nodeIdx) { const NKikimrConfig::TStaticNameserviceConfig::TNode& node = nameserviceConfig->GetNode(nodeIdx); - Y_VERIFY(node.HasPort()); - Y_VERIFY(node.HasHost()); - Y_VERIFY(node.HasNodeId()); + Y_VERIFY(node.HasPort()); + Y_VERIFY(node.HasHost()); + Y_VERIFY(node.HasNodeId()); if (node.GetHost() == nodeByHostConfig.Hostname) { if (!isPortPresent || (ui32)nodeByHostConfig.Port == node.GetPort()) { - Y_VERIFY(!isMatchingNodeFound); + Y_VERIFY(!isMatchingNodeFound); isMatchingNodeFound = true; nodeId = node.GetNodeId(); } } } - Y_VERIFY(isMatchingNodeFound); + Y_VERIFY(isMatchingNodeFound); Cout << nodeId; Cout.Flush(); diff --git a/ydb/core/driver_lib/cli_base/cli_cmds_db.cpp b/ydb/core/driver_lib/cli_base/cli_cmds_db.cpp index 450d4135c6c..295db342519 100644 --- a/ydb/core/driver_lib/cli_base/cli_cmds_db.cpp +++ b/ydb/core/driver_lib/cli_base/cli_cmds_db.cpp @@ -16,8 +16,8 @@ #include <util/generic/hash.h> #include <util/string/split.h> #include <util/string/join.h> -#include <util/string/printf.h> - +#include <util/string/printf.h> + namespace NKikimr { namespace NDriverClient { @@ -531,7 +531,7 @@ public: TClientCommand::Parse(config); Request = new NKikimrClient::TSchemeInitRoot(); Root = config.ParseResult->GetFreeArgs()[0]; - if (Root.StartsWith('/')) + if (Root.StartsWith('/')) Root = Root.substr(1); Request->SetTagName(Root); if (DefaultStoragePool) { diff --git a/ydb/core/driver_lib/cli_utils/cli.cpp b/ydb/core/driver_lib/cli_utils/cli.cpp index f84f6784df0..461724fc5ae 100644 --- a/ydb/core/driver_lib/cli_utils/cli.cpp +++ b/ydb/core/driver_lib/cli_utils/cli.cpp @@ -4,7 +4,7 @@ namespace NKikimr { namespace NDriverClient { -void DumpProxyErrorCodes(IOutputStream &o, const NKikimrClient::TResponse &response) { +void DumpProxyErrorCodes(IOutputStream &o, const NKikimrClient::TResponse &response) { o << "status: " << response.GetStatus() << Endl; o << "status transcript: " << static_cast<NMsgBusProxy::EResponseStatus>(response.GetStatus()) << Endl; if (response.HasProxyErrorCode()) { diff --git a/ydb/core/driver_lib/cli_utils/cli.h b/ydb/core/driver_lib/cli_utils/cli.h index 099664792ea..2dcb0c31f03 100644 --- a/ydb/core/driver_lib/cli_utils/cli.h +++ b/ydb/core/driver_lib/cli_utils/cli.h @@ -23,8 +23,8 @@ namespace NKikimr { namespace NDriverClient { - void DumpProxyErrorCodes(IOutputStream &o, const NKikimrClient::TResponse &response); - void DumpSchemeErrorCode(IOutputStream &o, const NKikimrClient::TResponse &response); + void DumpProxyErrorCodes(IOutputStream &o, const NKikimrClient::TResponse &response); + void DumpSchemeErrorCode(IOutputStream &o, const NKikimrClient::TResponse &response); int SchemeInitRoot(TCommandConfig &cmdConf, int argc, char** argv); int BSAdmCreateVSlots(TCommandConfig &cmdConf, int argc, char **argv); diff --git a/ydb/core/driver_lib/cli_utils/cli_keyvalue.cpp b/ydb/core/driver_lib/cli_utils/cli_keyvalue.cpp index a1756c0b11d..c9c492b5096 100644 --- a/ydb/core/driver_lib/cli_utils/cli_keyvalue.cpp +++ b/ydb/core/driver_lib/cli_utils/cli_keyvalue.cpp @@ -42,7 +42,7 @@ int ClientSyncCall(TAutoPtr<NBus::TBusMessage> request, const TCliCmdConfig &cli int KeyValueRequest(TCommandConfig &cmdConf, int argc, char **argv) { - Y_UNUSED(cmdConf); + Y_UNUSED(cmdConf); #ifdef _win32_ WSADATA dummy; @@ -134,11 +134,11 @@ int KeyValueRequest(TCommandConfig &cmdConf, int argc, char **argv) { } if (requestConfig.IsReadToFile) { - Y_VERIFY(status == NMsgBusProxy::MSTATUS_OK); - Y_VERIFY(response.ReadResultSize() == 1); - Y_VERIFY(response.GetReadResult(0).HasStatus()); - Y_VERIFY(response.GetReadResult(0).GetStatus() == NKikimrProto::OK); - Y_VERIFY(response.GetReadResult(0).HasValue()); + Y_VERIFY(status == NMsgBusProxy::MSTATUS_OK); + Y_VERIFY(response.ReadResultSize() == 1); + Y_VERIFY(response.GetReadResult(0).HasStatus()); + Y_VERIFY(response.GetReadResult(0).GetStatus() == NKikimrProto::OK); + Y_VERIFY(response.GetReadResult(0).HasValue()); TString data = response.GetReadResult(0).GetValue(); readBuffer += data; @@ -148,7 +148,7 @@ int KeyValueRequest(TCommandConfig &cmdConf, int argc, char **argv) { last.MutableCmdRead(0)->SetOffset(readBuffer.size()); } } else if (requestConfig.IsWriteFromFile) { - Y_VERIFY(status == NMsgBusProxy::MSTATUS_OK); + Y_VERIFY(status == NMsgBusProxy::MSTATUS_OK); if (response.WriteResultSize() == 1) { Y_VERIFY(response.GetWriteResult(0).HasStatus()); Y_VERIFY(response.GetWriteResult(0).GetStatus() == NKikimrProto::OK); diff --git a/ydb/core/driver_lib/cli_utils/cli_mb_trace.cpp b/ydb/core/driver_lib/cli_utils/cli_mb_trace.cpp index df1fa4a79f3..815c40daf26 100644 --- a/ydb/core/driver_lib/cli_utils/cli_mb_trace.cpp +++ b/ydb/core/driver_lib/cli_utils/cli_mb_trace.cpp @@ -15,7 +15,7 @@ struct TCmdMessageBusTraceConfig : public TCliCmdConfig { }; int MessageBusTrace(TCommandConfig &cmdConf, int argc, char** argv) { - Y_UNUSED(cmdConf); + Y_UNUSED(cmdConf); #ifdef _win32_ WSADATA dummy; diff --git a/ydb/core/driver_lib/cli_utils/cli_minikql_compile_and_exec.cpp b/ydb/core/driver_lib/cli_utils/cli_minikql_compile_and_exec.cpp index b4429d5721b..e21e4baadca 100644 --- a/ydb/core/driver_lib/cli_utils/cli_minikql_compile_and_exec.cpp +++ b/ydb/core/driver_lib/cli_utils/cli_minikql_compile_and_exec.cpp @@ -28,7 +28,7 @@ struct TCmdCompileAndExecMiniKQLConfig : public TCliCmdConfig { }; int CompileAndExecMiniKQL(TCommandConfig &cmdConf, int argc, char **argv) { - Y_UNUSED(cmdConf); + Y_UNUSED(cmdConf); #ifdef _win32_ WSADATA dummy; diff --git a/ydb/core/driver_lib/cli_utils/cli_scheme_initroot.cpp b/ydb/core/driver_lib/cli_utils/cli_scheme_initroot.cpp index ebca272cc4d..49448b3f14e 100644 --- a/ydb/core/driver_lib/cli_utils/cli_scheme_initroot.cpp +++ b/ydb/core/driver_lib/cli_utils/cli_scheme_initroot.cpp @@ -18,7 +18,7 @@ struct TCmdSchemeInitShardConfig : public TCliCmdConfig { }; int SchemeInitRoot(TCommandConfig &cmdConf, int argc, char** argv) { - Y_UNUSED(cmdConf); + Y_UNUSED(cmdConf); #ifdef _win32_ WSADATA dummy; @@ -80,10 +80,10 @@ void TCmdSchemeInitShardConfig::Parse(int argc, char **argv) { #if 0 if (!configPbFile.empty()) { GlobalConfig.Reset(new NKikimrTxScheme::TConfig); - Y_VERIFY(ParsePBFromFile(configPbFile, GlobalConfig.Get())); + Y_VERIFY(ParsePBFromFile(configPbFile, GlobalConfig.Get())); } else if (!configPb.empty()) { GlobalConfig.Reset(new NKikimrTxScheme::TConfig); - Y_VERIFY(::google::protobuf::TextFormat::ParseFromString(configPb, GlobalConfig.Get())); + Y_VERIFY(::google::protobuf::TextFormat::ParseFromString(configPb, GlobalConfig.Get())); } #else Cout << "config options for init-root are not used anymore (deprecated)" << Endl; diff --git a/ydb/core/driver_lib/run/config_parser.cpp b/ydb/core/driver_lib/run/config_parser.cpp index bb686562912..33f87bbd0ed 100644 --- a/ydb/core/driver_lib/run/config_parser.cpp +++ b/ydb/core/driver_lib/run/config_parser.cpp @@ -8,7 +8,7 @@ #include <util/stream/file.h> #include <util/stream/format.h> #include <util/system/hostname.h> -#include <util/string/printf.h> +#include <util/string/printf.h> #include <library/cpp/string_utils/parse_size/parse_size.h> @@ -79,42 +79,42 @@ void TRunCommandConfigParser::SetupLastGetOptForConfigFiles(NLastGetopt::TOpts& void TRunCommandConfigParser::ParseConfigFiles(const NLastGetopt::TOptsParseResult& res) { if (res.Has("sys-file")) { - Y_VERIFY(ParsePBFromFile(res.Get("sys-file"), Config.AppConfig.MutableActorSystemConfig())); + Y_VERIFY(ParsePBFromFile(res.Get("sys-file"), Config.AppConfig.MutableActorSystemConfig())); } else { auto sysConfig = DummyActorSystemConfig(); Config.AppConfig.MutableActorSystemConfig()->CopyFrom(*sysConfig); } if (res.Has("naming-file")) { - Y_VERIFY(ParsePBFromFile(res.Get("naming-file"), Config.AppConfig.MutableNameserviceConfig())); + Y_VERIFY(ParsePBFromFile(res.Get("naming-file"), Config.AppConfig.MutableNameserviceConfig())); } if (res.Has("domains-file")) { - Y_VERIFY(ParsePBFromFile(res.Get("domains-file"), Config.AppConfig.MutableDomainsConfig())); + Y_VERIFY(ParsePBFromFile(res.Get("domains-file"), Config.AppConfig.MutableDomainsConfig())); } if (res.Has("bs-file")) { - Y_VERIFY(ParsePBFromFile(res.Get("bs-file"), Config.AppConfig.MutableBlobStorageConfig())); + Y_VERIFY(ParsePBFromFile(res.Get("bs-file"), Config.AppConfig.MutableBlobStorageConfig())); } if (res.Has("log-file")) { - Y_VERIFY(ParsePBFromFile(res.Get("log-file"), Config.AppConfig.MutableLogConfig())); + Y_VERIFY(ParsePBFromFile(res.Get("log-file"), Config.AppConfig.MutableLogConfig())); } if (res.Has("ic-file")) { - Y_VERIFY(ParsePBFromFile(res.Get("ic-file"), Config.AppConfig.MutableInterconnectConfig())); + Y_VERIFY(ParsePBFromFile(res.Get("ic-file"), Config.AppConfig.MutableInterconnectConfig())); } if (res.Has("channels-file")) { - Y_VERIFY(ParsePBFromFile(res.Get("channels-file"), Config.AppConfig.MutableChannelProfileConfig())); + Y_VERIFY(ParsePBFromFile(res.Get("channels-file"), Config.AppConfig.MutableChannelProfileConfig())); } if (res.Has("bootstrap-file")) { - Y_VERIFY(ParsePBFromFile(res.Get("bootstrap-file"), Config.AppConfig.MutableBootstrapConfig())); + Y_VERIFY(ParsePBFromFile(res.Get("bootstrap-file"), Config.AppConfig.MutableBootstrapConfig())); } if (res.Has("vdisk-file")) { - Y_VERIFY(ParsePBFromFile(res.Get("vdisk-file"), Config.AppConfig.MutableVDiskConfig())); + Y_VERIFY(ParsePBFromFile(res.Get("vdisk-file"), Config.AppConfig.MutableVDiskConfig())); } if (res.Has("drivemodel-file")) { @@ -274,7 +274,7 @@ void TRunCommandConfigParser::ParseRunOpts(int argc, char **argv) { RunOpts.ProxyBusQueueConfig.ConfigureLastGetopt(msgBusOpts, ""); RunOpts.ProxyBusSessionConfig.ConfigureLastGetopt(msgBusOpts, ""); TOptsParseResult mbusRes(&msgBusOpts, argc, argv); - Y_UNUSED(mbusRes); + Y_UNUSED(mbusRes); RunOpts.StartTracingBusProxy = !RunOpts.TracePath.empty(); RunOpts.StartBusProxy = true; } diff --git a/ydb/core/driver_lib/run/kikimr_services_initializers.cpp b/ydb/core/driver_lib/run/kikimr_services_initializers.cpp index 819c1478d19..cd775887e51 100644 --- a/ydb/core/driver_lib/run/kikimr_services_initializers.cpp +++ b/ydb/core/driver_lib/run/kikimr_services_initializers.cpp @@ -289,7 +289,7 @@ void AddExecutorPool( break; } default: - Y_FAIL(); + Y_FAIL(); } } @@ -344,7 +344,7 @@ static TCpuManagerConfig CreateCpuManagerConfig(const NKikimrConfig::TActorSyste static TSchedulerConfig CreateSchedulerConfig(const NKikimrConfig::TActorSystemConfig::TScheduler &config) { const ui64 resolution = config.HasResolution() ? config.GetResolution() : 1024; - Y_VERIFY_DEBUG((resolution & (resolution - 1)) == 0); // resolution must be power of 2 + Y_VERIFY_DEBUG((resolution & (resolution - 1)) == 0); // resolution must be power of 2 const ui64 spinThreshold = config.HasSpinThreshold() ? config.GetSpinThreshold() : 0; const ui64 progressThreshold = config.HasProgressThreshold() ? config.GetProgressThreshold() : 10000; const bool useSchedulerActor = config.HasUseSchedulerActor() ? config.GetUseSchedulerActor() : false; @@ -506,7 +506,7 @@ static TInterconnectSettings GetInterconnectSettings(const NKikimrConfig::TInter void TBasicServicesInitializer::InitializeServices(NActors::TActorSystemSetup* setup, const NKikimr::TAppData* appData) { - Y_VERIFY(Config.HasActorSystemConfig()); + Y_VERIFY(Config.HasActorSystemConfig()); auto& systemConfig = Config.GetActorSystemConfig(); Y_VERIFY(systemConfig.HasScheduler()); @@ -851,7 +851,7 @@ void TStateStorageServiceInitializer::InitializeServices(NActors::TActorSystemSe bool knownss[maxssid + 1] = {}; for (const NKikimrConfig::TDomainsConfig::TStateStorage &ssconf : Config.GetDomainsConfig().GetStateStorage()) { const ui32 ssid = ssconf.GetSSId(); - Y_VERIFY(ssid <= maxssid); + Y_VERIFY(ssid <= maxssid); knownss[ssid] = true; TIntrusivePtr<TStateStorageInfo> ssrInfo; @@ -1132,7 +1132,7 @@ TRestartsCountPublisher::TRestartsCountPublisher(const TKikimrRunConfig& runConf void TRestartsCountPublisher::InitializeServices( NActors::TActorSystemSetup* setup, const NKikimr::TAppData* appData) { - Y_UNUSED(setup); + Y_UNUSED(setup); const TIntrusivePtr<NMonitoring::TDynamicCounters> utilsCounters = GetServiceCounters(appData->Counters, "utils"); if (Config.HasRestartsCountConfig()) { diff --git a/ydb/core/driver_lib/run/main.cpp b/ydb/core/driver_lib/run/main.cpp index f0a9315685b..73a052c5832 100644 --- a/ydb/core/driver_lib/run/main.cpp +++ b/ydb/core/driver_lib/run/main.cpp @@ -145,7 +145,7 @@ int MainRun(const TKikimrRunConfig& runConfig, std::shared_ptr<TModuleFactories> case EDM_ACTORSYS_PERFTEST: return NDriverClient::ActorsysPerfTest(cmdConf, argc, argv); default: - Y_FAIL("Not Happens"); + Y_FAIL("Not Happens"); } } } // NKikimr diff --git a/ydb/core/driver_lib/run/run.cpp b/ydb/core/driver_lib/run/run.cpp index a4f74aa4e0f..baf068b30d9 100644 --- a/ydb/core/driver_lib/run/run.cpp +++ b/ydb/core/driver_lib/run/run.cpp @@ -227,21 +227,21 @@ public: // setup channel profiles appData->ChannelProfiles = new TChannelProfiles(); ui32 idx = 0; - Y_VERIFY(Config.GetChannelProfileConfig().ProfileSize() > 0); + Y_VERIFY(Config.GetChannelProfileConfig().ProfileSize() > 0); for (const NKikimrConfig::TChannelProfileConfig::TProfile &profile : Config.GetChannelProfileConfig().GetProfile()) { const ui32 profileId = profile.GetProfileId(); - Y_VERIFY(profileId == idx, "Duplicate, missing or out of order profileId %" PRIu32 " (expected %" PRIu32 ")", + Y_VERIFY(profileId == idx, "Duplicate, missing or out of order profileId %" PRIu32 " (expected %" PRIu32 ")", profileId, idx); ++idx; const ui32 channels = profile.ChannelSize(); - Y_VERIFY(channels >= 2); + Y_VERIFY(channels >= 2); appData->ChannelProfiles->Profiles.emplace_back(); TChannelProfiles::TProfile &outProfile = appData->ChannelProfiles->Profiles.back(); ui32 channelIdx = 0; for (const NKikimrConfig::TChannelProfileConfig::TProfile::TChannel &channel : profile.GetChannel()) { - Y_VERIFY(channel.HasErasureSpecies()); - Y_VERIFY(channel.HasPDiskCategory()); + Y_VERIFY(channel.HasErasureSpecies()); + Y_VERIFY(channel.HasPDiskCategory()); TString name = channel.GetErasureSpecies(); TBlobStorageGroupType::EErasureSpecies erasure = TBlobStorageGroupType::ErasureSpeciesByName(name); if (erasure == TBlobStorageGroupType::ErasureSpeciesCount) { @@ -1010,7 +1010,7 @@ void TKikimrRunner::ApplyLogSettings(const TKikimrRunConfig& runConfig) component = NLog::InvalidComponent; } else { component = LogSettings->FindComponent(componentName); - Y_VERIFY(component != NLog::InvalidComponent, "Invalid component name in log configuration file: \"%s\"", + Y_VERIFY(component != NLog::InvalidComponent, "Invalid component name in log configuration file: \"%s\"", componentName.data()); } @@ -1019,10 +1019,10 @@ void TKikimrRunner::ApplyLogSettings(const TKikimrRunConfig& runConfig) Y_VERIFY(LogSettings->SetLevel((NLog::EPriority)entry.GetLevel(), component, explanation) == 0); } if (entry.HasSamplingLevel()) { - Y_VERIFY(LogSettings->SetSamplingLevel((NLog::EPriority)entry.GetSamplingLevel(), component, explanation) == 0); + Y_VERIFY(LogSettings->SetSamplingLevel((NLog::EPriority)entry.GetSamplingLevel(), component, explanation) == 0); } if (entry.HasSamplingRate()) { - Y_VERIFY(LogSettings->SetSamplingRate(entry.GetSamplingRate(), component, explanation) == 0); + Y_VERIFY(LogSettings->SetSamplingRate(entry.GetSamplingRate(), component, explanation) == 0); } } } @@ -1386,7 +1386,7 @@ void TKikimrRunner::KikimrStart() { } void TKikimrRunner::KikimrStop(bool graceful) { - Y_UNUSED(graceful); + Y_UNUSED(graceful); if (EnabledGrpcService) { ActorSystem->Send(new IEventHandle(NGRpcService::CreateGrpcPublisherServiceActorId(), {}, new TEvents::TEvPoisonPill)); diff --git a/ydb/core/engine/kikimr_program_builder_ut.cpp b/ydb/core/engine/kikimr_program_builder_ut.cpp index efa073ae2f8..40e34ca8b03 100644 --- a/ydb/core/engine/kikimr_program_builder_ut.cpp +++ b/ydb/core/engine/kikimr_program_builder_ut.cpp @@ -65,7 +65,7 @@ namespace NMiniKQL { IComputationPattern::TPtr Pattern; }; -Y_UNIT_TEST_SUITE(TMiniKQLProgramBuilderTest) { +Y_UNIT_TEST_SUITE(TMiniKQLProgramBuilderTest) { void VerifySerialization(TNode* pgm, const TTypeEnvironment& env) { TString s = PrintNode(pgm); @@ -80,7 +80,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLProgramBuilderTest) { VerifySerialization(pgm, env); } - Y_UNIT_TEST(TestEraseRowStaticKey) { + Y_UNIT_TEST(TestEraseRowStaticKey) { TScopedAlloc alloc; TTypeEnvironment env(alloc); auto functionRegistry = CreateFunctionRegistry(CreateBuiltinRegistry()); @@ -123,7 +123,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLProgramBuilderTest) { UNIT_ASSERT(tableKeys[0]->KeyColumnTypes[2] == NUdf::TDataType<char*>::Id); } - Y_UNIT_TEST(TestEraseRowPartialDynamicKey) { + Y_UNIT_TEST(TestEraseRowPartialDynamicKey) { TScopedAlloc alloc; TTypeEnvironment env(alloc); auto functionRegistry = CreateFunctionRegistry(CreateBuiltinRegistry()); @@ -165,7 +165,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLProgramBuilderTest) { UNIT_ASSERT(tableKeys[0]->KeyColumnTypes[2] == NUdf::TDataType<char*>::Id); } - Y_UNIT_TEST(TestEraseRowDynamicKey) { + Y_UNIT_TEST(TestEraseRowDynamicKey) { TScopedAlloc alloc; TTypeEnvironment env(alloc); auto functionRegistry = CreateFunctionRegistry(CreateBuiltinRegistry()); @@ -204,7 +204,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLProgramBuilderTest) { UNIT_ASSERT(tableKeys[0]->KeyColumnTypes[1] == NUdf::TDataType<char*>::Id); } - Y_UNIT_TEST(TestSelectRow) { + Y_UNIT_TEST(TestSelectRow) { TScopedAlloc alloc; TTypeEnvironment env(alloc); auto functionRegistry = CreateFunctionRegistry(CreateBuiltinRegistry()); @@ -257,7 +257,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLProgramBuilderTest) { UNIT_ASSERT(tableKeys[0]->KeyColumnTypes[2] == NUdf::TDataType<char*>::Id); } - Y_UNIT_TEST(TestUpdateRowStaticKey) { + Y_UNIT_TEST(TestUpdateRowStaticKey) { TScopedAlloc alloc; TTypeEnvironment env(alloc); auto functionRegistry = CreateFunctionRegistry(CreateBuiltinRegistry()); @@ -315,7 +315,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLProgramBuilderTest) { UNIT_ASSERT(tableKeys[0]->KeyColumnTypes[2] == NUdf::TDataType<char*>::Id); } - Y_UNIT_TEST(TestUpdateRowDynamicKey) { + Y_UNIT_TEST(TestUpdateRowDynamicKey) { TScopedAlloc alloc; TTypeEnvironment env(alloc); auto functionRegistry = CreateFunctionRegistry(CreateBuiltinRegistry()); @@ -373,7 +373,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLProgramBuilderTest) { UNIT_ASSERT(tableKeys[0]->KeyColumnTypes[2] == NUdf::TDataType<char*>::Id); } - Y_UNIT_TEST(TestSelectFromInclusiveRange) { + Y_UNIT_TEST(TestSelectFromInclusiveRange) { TScopedAlloc alloc; TTypeEnvironment env(alloc); auto functionRegistry = CreateFunctionRegistry(CreateBuiltinRegistry()); @@ -422,7 +422,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLProgramBuilderTest) { UNIT_ASSERT(tableKeys[0]->Columns[1].ExpectedType == NUdf::TDataType<ui64>::Id); } - Y_UNIT_TEST(TestSelectFromExclusiveRange) { + Y_UNIT_TEST(TestSelectFromExclusiveRange) { TScopedAlloc alloc; TTypeEnvironment env(alloc); auto functionRegistry = CreateFunctionRegistry(CreateBuiltinRegistry()); @@ -472,7 +472,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLProgramBuilderTest) { UNIT_ASSERT(tableKeys[0]->Columns[1].ExpectedType == NUdf::TDataType<ui64>::Id); } - Y_UNIT_TEST(TestSelectToInclusiveRange) { + Y_UNIT_TEST(TestSelectToInclusiveRange) { TScopedAlloc alloc; TTypeEnvironment env(alloc); auto functionRegistry = CreateFunctionRegistry(CreateBuiltinRegistry()); @@ -526,7 +526,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLProgramBuilderTest) { UNIT_ASSERT(tableKeys[0]->Columns[1].ExpectedType == NUdf::TDataType<ui64>::Id); } - Y_UNIT_TEST(TestSelectToExclusiveRange) { + Y_UNIT_TEST(TestSelectToExclusiveRange) { TScopedAlloc alloc; TTypeEnvironment env(alloc); auto functionRegistry = CreateFunctionRegistry(CreateBuiltinRegistry()); @@ -581,7 +581,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLProgramBuilderTest) { UNIT_ASSERT(tableKeys[0]->Columns[1].ExpectedType == NUdf::TDataType<ui64>::Id); } - Y_UNIT_TEST(TestSelectBothFromInclusiveToInclusiveRange) { + Y_UNIT_TEST(TestSelectBothFromInclusiveToInclusiveRange) { TScopedAlloc alloc; TTypeEnvironment env(alloc); auto functionRegistry = CreateFunctionRegistry(CreateBuiltinRegistry()); @@ -631,7 +631,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLProgramBuilderTest) { UNIT_ASSERT(tableKeys[0]->Columns[1].ExpectedType == NUdf::TDataType<ui64>::Id); } - Y_UNIT_TEST(TestSelectBothFromExclusiveToExclusiveRange) { + Y_UNIT_TEST(TestSelectBothFromExclusiveToExclusiveRange) { TScopedAlloc alloc; TTypeEnvironment env(alloc); auto functionRegistry = CreateFunctionRegistry(CreateBuiltinRegistry()); @@ -683,7 +683,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLProgramBuilderTest) { UNIT_ASSERT(tableKeys[0]->Columns[1].ExpectedType == NUdf::TDataType<ui64>::Id); } - Y_UNIT_TEST(TestAcquireLocks) { + Y_UNIT_TEST(TestAcquireLocks) { TScopedAlloc alloc; TTypeEnvironment env(alloc); auto functionRegistry = CreateFunctionRegistry(CreateBuiltinRegistry()); @@ -696,7 +696,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLProgramBuilderTest) { VerifyProgram(pgm, env); } - Y_UNIT_TEST(TestDiagnostics) { + Y_UNIT_TEST(TestDiagnostics) { TScopedAlloc alloc; TTypeEnvironment env(alloc); auto functionRegistry = CreateFunctionRegistry(CreateBuiltinRegistry()); @@ -708,7 +708,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLProgramBuilderTest) { VerifyProgram(pgm, env); } - Y_UNIT_TEST(TestInvalidParameterName) { + Y_UNIT_TEST(TestInvalidParameterName) { TScopedAlloc alloc; TTypeEnvironment env(alloc); auto functionRegistry = CreateFunctionRegistry(CreateBuiltinRegistry()); @@ -729,7 +729,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLProgramBuilderTest) { UNIT_FAIL("Expected exception."); } - Y_UNIT_TEST(TestInvalidParameterType) { + Y_UNIT_TEST(TestInvalidParameterType) { TScopedAlloc alloc; TTypeEnvironment env(alloc); auto functionRegistry = CreateFunctionRegistry(CreateBuiltinRegistry()); diff --git a/ydb/core/engine/minikql/flat_local_tx_minikql.h b/ydb/core/engine/minikql/flat_local_tx_minikql.h index 0feabf20e68..efaa3b11309 100644 --- a/ydb/core/engine/minikql/flat_local_tx_minikql.h +++ b/ydb/core/engine/minikql/flat_local_tx_minikql.h @@ -103,7 +103,7 @@ class TFlatLocalMiniKQL : public NTabletFlatExecutor::ITransaction { } bool PrepareParams(TTransactionContext &txc, const TAppData *appData) { - Y_UNUSED(txc); + Y_UNUSED(txc); if (SourceProgram.Params.Binary) { SerializedMiniKQLParams = SourceProgram.Program.Binary; return true; @@ -277,7 +277,7 @@ class TFlatLocalMiniKQL : public NTabletFlatExecutor::ITransaction { if (affectedShardCount == 0) { proxyEngine->AfterShardProgramsExtracted(); } else { - Y_VERIFY(affectedShardCount == 1); + Y_VERIFY(affectedShardCount == 1); IEngineFlat::TShardData shardData; EngineResultStatusCode = proxyEngine->GetAffectedShard(0, shardData); @@ -313,14 +313,14 @@ class TFlatLocalMiniKQL : public NTabletFlatExecutor::ITransaction { if (EngineResultStatusCode != IEngineFlat::EResult::Ok) return MakeResponse(engine.Get(), ctx); - Y_VERIFY(engine->GetOutgoingReadsetsCount() == 0); + Y_VERIFY(engine->GetOutgoingReadsetsCount() == 0); engine->AfterOutgoingReadsetsExtracted(); EngineResultStatusCode = engine->PrepareIncomingReadsets(); if (EngineResultStatusCode != IEngineFlat::EResult::Ok) return MakeResponse(engine.Get(), ctx); - Y_VERIFY(engine->GetExpectedIncomingReadsetsCount() == 0); + Y_VERIFY(engine->GetExpectedIncomingReadsetsCount() == 0); EngineResultStatusCode = engine->Execute(); if (EngineResultStatusCode != IEngineFlat::EResult::Ok) @@ -342,11 +342,11 @@ class TFlatLocalMiniKQL : public NTabletFlatExecutor::ITransaction { return true; } catch (const TNotReadyTabletException& ex) { - Y_UNUSED(ex); + Y_UNUSED(ex); ++PageFaultCount; return false; } catch (...) { - Y_FAIL("there must be no leaked exceptions"); + Y_FAIL("there must be no leaked exceptions"); } } diff --git a/ydb/core/engine/minikql/minikql_engine_host.cpp b/ydb/core/engine/minikql/minikql_engine_host.cpp index 36c35f32cc4..288e88b5bb3 100644 --- a/ydb/core/engine/minikql/minikql_engine_host.cpp +++ b/ydb/core/engine/minikql/minikql_engine_host.cpp @@ -56,7 +56,7 @@ bool TEngineHost::IsReadonly() const { bool TEngineHost::IsValidKey(TKeyDesc& key, std::pair<ui64, ui64>& maxSnapshotTime) const { - Y_UNUSED(maxSnapshotTime); + Y_UNUSED(maxSnapshotTime); auto* tableInfo = Scheme.GetTableInfo(LocalTableId(key.TableId)); @@ -270,10 +270,10 @@ NUdf::TUnboxedValue TEngineHost::SelectRow(const TTableId& tableId, const TArray // And that struct type has column tags stored inside it's member names as numbers Y_UNUSED(returnType); - Y_UNUSED(readTarget); + Y_UNUSED(readTarget); ui64 localTid = LocalTableId(tableId); - Y_VERIFY(localTid, "table not exist"); + Y_VERIFY(localTid, "table not exist"); const TScheme::TTableInfo* tableInfo = Scheme.GetTableInfo(localTid); TSmallVec<TRawTypeValue> key; ConvertKeys(tableInfo, row, key); @@ -799,13 +799,13 @@ NUdf::TUnboxedValue TEngineHost::SelectRange(const TTableId& tableId, const TTab // > // And that struct type has column tags stored inside it's member names (ugly hack) - Y_UNUSED(readTarget); + Y_UNUSED(readTarget); // TODO[serxa]: support for Point in SelectRange() Y_VERIFY(!range.Point, "point request in TEngineHost::SelectRange"); ui64 localTid = LocalTableId(tableId); - Y_VERIFY(localTid, "table not exist"); + Y_VERIFY(localTid, "table not exist"); // Analyze resultType TStructType* outerStructType = AS_TYPE(TStructType, returnType); @@ -852,7 +852,7 @@ NUdf::TUnboxedValue TEngineHost::SelectRange(const TTableId& tableId, const TTab // Updates the single row. Column in commands must be unique. void TEngineHost::UpdateRow(const TTableId& tableId, const TArrayRef<const TCell>& row, const TArrayRef<const TUpdateCommand>& commands) { ui64 localTid = LocalTableId(tableId); - Y_VERIFY(localTid, "table not exist"); + Y_VERIFY(localTid, "table not exist"); const TScheme::TTableInfo* tableInfo = Scheme.GetTableInfo(localTid); TSmallVec<TRawTypeValue> key; ui64 keyBytes = 0; @@ -862,7 +862,7 @@ void TEngineHost::UpdateRow(const TTableId& tableId, const TArrayRef<const TCell TSmallVec<NTable::TUpdateOp> ops; for (size_t i = 0; i < commands.size(); i++) { const TUpdateCommand& upd = commands[i]; - Y_VERIFY(upd.Operation == TKeyDesc::EColumnOperation::Set); // TODO[serxa]: support inplace update in update row + Y_VERIFY(upd.Operation == TKeyDesc::EColumnOperation::Set); // TODO[serxa]: support inplace update in update row NScheme::TTypeId vtype = Scheme.GetColumnInfo(tableInfo, upd.Column)->PType; ops.emplace_back(upd.Column, NTable::ECellOp::Set, upd.Value.IsNull() ? TRawTypeValue() : TRawTypeValue(upd.Value.Data(), upd.Value.Size(), vtype)); @@ -891,7 +891,7 @@ void TEngineHost::UpdateRow(const TTableId& tableId, const TArrayRef<const TCell // Erases the single row. void TEngineHost::EraseRow(const TTableId& tableId, const TArrayRef<const TCell>& row) { ui64 localTid = LocalTableId(tableId); - Y_VERIFY(localTid, "table not exist"); + Y_VERIFY(localTid, "table not exist"); const TScheme::TTableInfo* tableInfo = Scheme.GetTableInfo(localTid); TSmallVec<TRawTypeValue> key; ui64 keyBytes = 0; @@ -924,7 +924,7 @@ bool TEngineHost::IsPathErased(const TTableId& tableId) const { // Returns whether row belong this shard. bool TEngineHost::IsMyKey(const TTableId& tableId, const TArrayRef<const TCell>& row) const { - Y_UNUSED(tableId); Y_UNUSED(row); + Y_UNUSED(tableId); Y_UNUSED(row); return true; } diff --git a/ydb/core/engine/mkql_engine_flat.cpp b/ydb/core/engine/mkql_engine_flat.cpp index c7fe388eef8..092cd8c42f8 100644 --- a/ydb/core/engine/mkql_engine_flat.cpp +++ b/ydb/core/engine/mkql_engine_flat.cpp @@ -155,7 +155,7 @@ private: }; TRuntimeNode ReplaceAsVoid(TCallable& callable, const TTypeEnvironment& env) { - Y_UNUSED(callable); + Y_UNUSED(callable); return TRuntimeNode(env.GetVoid(), true); }; @@ -291,7 +291,7 @@ public: } EResult SetProgram(TStringBuf program, TStringBuf params) noexcept override { - Y_VERIFY(!Program.GetNode(), "Program is already set"); + Y_VERIFY(!Program.GetNode(), "Program is already set"); TGuard<TScopedAlloc> allocGuard(Alloc); TRuntimeNode programNode; try { @@ -376,12 +376,12 @@ public: } TVector<THolder<TKeyDesc>>& GetDbKeys() noexcept override { - Y_VERIFY(Program.GetNode(), "Program is not set"); + Y_VERIFY(Program.GetNode(), "Program is not set"); return DbKeys; } EResult PrepareShardPrograms(const TShardLimits& limits) noexcept override { - Y_VERIFY(!AreAffectedShardsPrepared, "PrepareShardPrograms is already called"); + Y_VERIFY(!AreAffectedShardsPrepared, "PrepareShardPrograms is already called"); TGuard<TScopedAlloc> allocGuard(Alloc); AffectedShards.clear(); TSet<ui64> affectedShardSet; @@ -389,7 +389,7 @@ public: TSet<ui64> onlineReadSet; for (ui32 keyIndex = 0; keyIndex < DbKeys.size(); ++keyIndex) { auto& key = DbKeys[keyIndex]; - Y_VERIFY(key->Status == TKeyDesc::EStatus::Ok, "Some DB keys are not resolved correctly"); + Y_VERIFY(key->Status == TKeyDesc::EStatus::Ok, "Some DB keys are not resolved correctly"); AddShards(affectedShardSet, *key); if (affectedShardSet.size() > limits.ShardCount) { AddError("PrepareShardPrograms", __LINE__, @@ -508,15 +508,15 @@ public: } ui32 GetAffectedShardCount() const noexcept override { - Y_VERIFY(AreAffectedShardsPrepared, "PrepareShardPrograms must be called first"); - Y_VERIFY(!AreShardProgramsExtracted, "AfterShardProgramsExtracted is already called"); + Y_VERIFY(AreAffectedShardsPrepared, "PrepareShardPrograms must be called first"); + Y_VERIFY(!AreShardProgramsExtracted, "AfterShardProgramsExtracted is already called"); return static_cast<ui32>(AffectedShards.size()); } EResult GetAffectedShard(ui32 index, TShardData& data) const noexcept override { - Y_VERIFY(AreAffectedShardsPrepared, "PrepareShardPrograms must be called first"); - Y_VERIFY(!AreShardProgramsExtracted, "AfterShardProgramsExtracted is already called"); - Y_VERIFY(index < AffectedShards.size(), "Bad index"); + Y_VERIFY(AreAffectedShardsPrepared, "PrepareShardPrograms must be called first"); + Y_VERIFY(!AreShardProgramsExtracted, "AfterShardProgramsExtracted is already called"); + Y_VERIFY(index < AffectedShards.size(), "Bad index"); TGuard<TScopedAlloc> allocGuard(Alloc); data = AffectedShards[index]; data.Program = SerializeRuntimeNode(SpecializedParts[index].Program, Env); @@ -524,8 +524,8 @@ public: } void AfterShardProgramsExtracted() noexcept override { - Y_VERIFY(AreAffectedShardsPrepared, "PrepareShardPrograms must be called first"); - Y_VERIFY(!AreShardProgramsExtracted, "AfterShardProgramsExtracted is already called"); + Y_VERIFY(AreAffectedShardsPrepared, "PrepareShardPrograms must be called first"); + Y_VERIFY(!AreShardProgramsExtracted, "AfterShardProgramsExtracted is already called"); TGuard<TScopedAlloc> allocGuard(Alloc); TVector<THolder<TKeyDesc>>().swap(DbKeys); TVector<TProgramParts>().swap(SpecializedParts); @@ -533,7 +533,7 @@ public: } void AddShardReply(ui64 origin, const TStringBuf& reply) noexcept override { - Y_VERIFY(!IsResultBuilt, "BuildResult is already called"); + Y_VERIFY(!IsResultBuilt, "BuildResult is already called"); TGuard<TScopedAlloc> allocGuard(Alloc); if (reply.empty()) { Status = EStatus::Error; @@ -546,7 +546,7 @@ public: } void FinalizeOriginReplies(ui64 origin) noexcept override { - Y_VERIFY(!IsResultBuilt, "BuildResult is already called"); + Y_VERIFY(!IsResultBuilt, "BuildResult is already called"); TGuard<TScopedAlloc> allocGuard(Alloc); for (const auto& shardData : AffectedShards) { if (shardData.ShardId == origin) { @@ -587,8 +587,8 @@ public: } void BuildResult() noexcept override { - Y_VERIFY(AreShardProgramsExtracted, "AfterShardProgramsExtracted must be called first"); - Y_VERIFY(!IsResultBuilt, "BuildResult is already called"); + Y_VERIFY(AreShardProgramsExtracted, "AfterShardProgramsExtracted must be called first"); + Y_VERIFY(!IsResultBuilt, "BuildResult is already called"); TGuard<TScopedAlloc> allocGuard(Alloc); if (Status == EStatus::Error) return; @@ -685,7 +685,7 @@ public: return EResult::Cancelled; } - Y_VERIFY(IsResultBuilt, "BuildResult is not called yet"); + Y_VERIFY(IsResultBuilt, "BuildResult is not called yet"); TGuard<TScopedAlloc> allocGuard(Alloc); if (Settings.EvaluateResultType) { ExportTypeToProto(ResultType, *result.MutableType()); @@ -735,7 +735,7 @@ public: } EResult AddProgram(ui64 origin, const TStringBuf& program, bool readOnly) noexcept override { - Y_VERIFY(ProgramPerOrigin.find(origin) == ProgramPerOrigin.end(), "Program for that origin is already added"); + Y_VERIFY(ProgramPerOrigin.find(origin) == ProgramPerOrigin.end(), "Program for that origin is already added"); TGuard<TScopedAlloc> allocGuard(Alloc); TRuntimeNode node; try { @@ -796,9 +796,9 @@ public: } EResult Validate(TValidationInfo& validationInfo) override { - Y_VERIFY(!IsProgramValidated, "Validate is already called"); - Y_VERIFY(ProgramPerOrigin.size() == 1, "One program must be added to engine"); - Y_VERIFY(Settings.Host, "Host is not set"); + Y_VERIFY(!IsProgramValidated, "Validate is already called"); + Y_VERIFY(ProgramPerOrigin.size() == 1, "One program must be added to engine"); + Y_VERIFY(Settings.Host, "Host is not set"); TGuard<TScopedAlloc> allocGuard(Alloc); if (ProgramPerOrigin.begin()->first != Settings.Host->GetShardId()) @@ -938,7 +938,7 @@ public: } THolder<TKeyDesc> desc = ExtractTableKey(*static_cast<TCallable*>(item.GetNode()), Strings, Env); - Y_VERIFY(desc); + Y_VERIFY(desc); Y_VERIFY(desc->RowOperation == TKeyDesc::ERowOperation::Read); TValidatedKey validKey(std::move(desc), false); @@ -971,7 +971,7 @@ public: } THolder<TKeyDesc> desc = ExtractTableKey(*static_cast<TCallable*>(item.GetNode()), Strings, Env); - Y_VERIFY(desc); + Y_VERIFY(desc); Y_VERIFY(desc->RowOperation == TKeyDesc::ERowOperation::Update || desc->RowOperation == TKeyDesc::ERowOperation::Erase); if (!desc->Range.Point) { @@ -1090,9 +1090,9 @@ public: } EResult PrepareOutgoingReadsets() override { - Y_VERIFY(!AreOutgoingReadSetsPrepared, "PrepareOutgoingReadsets is already called"); - Y_VERIFY(Settings.Host, "Host is not set"); - Y_VERIFY(ProgramPerOrigin.size() > 0, "At least one program must be added to engine"); + Y_VERIFY(!AreOutgoingReadSetsPrepared, "PrepareOutgoingReadsets is already called"); + Y_VERIFY(Settings.Host, "Host is not set"); + Y_VERIFY(ProgramPerOrigin.size() > 0, "At least one program must be added to engine"); TGuard<TScopedAlloc> allocGuard(Alloc); try { OutgoingReadsets.clear(); @@ -1200,20 +1200,20 @@ public: } ui32 GetOutgoingReadsetsCount() const noexcept override { - Y_VERIFY(AreOutgoingReadSetsPrepared, "PrepareOutgoingReadsets is not called yet"); - Y_VERIFY(!AreOutgoingReadSetsExtracted, "AfterOutgoingReadsetsExtracted is already called"); + Y_VERIFY(AreOutgoingReadSetsPrepared, "PrepareOutgoingReadsets is not called yet"); + Y_VERIFY(!AreOutgoingReadSetsExtracted, "AfterOutgoingReadsetsExtracted is already called"); return static_cast<ui32>(OutgoingReadsets.size()); } TReadSet GetOutgoingReadset(ui32 index) const override { - Y_VERIFY(AreOutgoingReadSetsPrepared, "PrepareOutgoingReadsets is not called yet"); - Y_VERIFY(!AreOutgoingReadSetsExtracted, "AfterOutgoingReadsetsExtracted is already called"); - Y_VERIFY(index < OutgoingReadsets.size(), "Bad index"); + Y_VERIFY(AreOutgoingReadSetsPrepared, "PrepareOutgoingReadsets is not called yet"); + Y_VERIFY(!AreOutgoingReadSetsExtracted, "AfterOutgoingReadsetsExtracted is already called"); + Y_VERIFY(index < OutgoingReadsets.size(), "Bad index"); return OutgoingReadsets[index]; } void AfterOutgoingReadsetsExtracted() noexcept override { - Y_VERIFY(!AreOutgoingReadSetsExtracted, "AfterOutgoingReadsetsExtracted is already called"); + Y_VERIFY(!AreOutgoingReadSetsExtracted, "AfterOutgoingReadsetsExtracted is already called"); TGuard<TScopedAlloc> allocGuard(Alloc); TVector<TReadSet>().swap(OutgoingReadsets); AreOutgoingReadSetsExtracted = true; @@ -1224,9 +1224,9 @@ public: } EResult PrepareIncomingReadsets() override { - Y_VERIFY(!AreIncomingReadsetsPrepared, "PrepareIncomingReadsets is already called"); - Y_VERIFY(Settings.Host, "Host is not set"); - Y_VERIFY(ProgramPerOrigin.size() > 0, "At least one program must be added to engine"); + Y_VERIFY(!AreIncomingReadsetsPrepared, "PrepareIncomingReadsets is already called"); + Y_VERIFY(Settings.Host, "Host is not set"); + Y_VERIFY(ProgramPerOrigin.size() > 0, "At least one program must be added to engine"); TGuard<TScopedAlloc> allocGuard(Alloc); IncomingReadsetsShards.clear(); try { @@ -1265,13 +1265,13 @@ public: } ui32 GetExpectedIncomingReadsetsCount() const noexcept override { - Y_VERIFY(AreIncomingReadsetsPrepared, "PrepareIncomingReadsets is not called yet"); + Y_VERIFY(AreIncomingReadsetsPrepared, "PrepareIncomingReadsets is not called yet"); return static_cast<ui32>(IncomingReadsetsShards.size()); } ui64 GetExpectedIncomingReadsetOriginShard(ui32 index) const noexcept override { - Y_VERIFY(AreIncomingReadsetsPrepared, "PrepareIncomingReadsets is not called yet"); - Y_VERIFY(index < IncomingReadsetsShards.size(), "Bad index"); + Y_VERIFY(AreIncomingReadsetsPrepared, "PrepareIncomingReadsets is not called yet"); + Y_VERIFY(index < IncomingReadsetsShards.size(), "Bad index"); return IncomingReadsetsShards[index]; } @@ -1286,8 +1286,8 @@ public: } EResult Execute() override { - Y_VERIFY(!IsExecuted, "Execute is already called"); - Y_VERIFY(Settings.Host, "Host is not set"); + Y_VERIFY(!IsExecuted, "Execute is already called"); + Y_VERIFY(Settings.Host, "Host is not set"); TGuard<TScopedAlloc> allocGuard(Alloc); if (IsCancelled) { @@ -1419,7 +1419,7 @@ public: return EResult::ProgramError; } - Y_VERIFY(ExecutionReplies.size() == ProgramPerOrigin.size()); + Y_VERIFY(ExecutionReplies.size() == ProgramPerOrigin.size()); ProgramPerOrigin.clear(); ProgramSizes.clear(); IsExecuted = true; @@ -1427,9 +1427,9 @@ public: } TString GetShardReply(ui64 origin) const noexcept override { - Y_VERIFY(IsExecuted, "Execute is not called yet"); + Y_VERIFY(IsExecuted, "Execute is not called yet"); auto it = ExecutionReplies.find(origin); - Y_VERIFY(it != ExecutionReplies.end(), "Bad origin: %" PRIu64, origin); + Y_VERIFY(it != ExecutionReplies.end(), "Bad origin: %" PRIu64, origin); return it->second; } @@ -1510,7 +1510,7 @@ private: auto name = callable->GetType()->GetNameStr(); if (name == Strings.SelectRow || name == Strings.SelectRange) { auto ctxIt = ProxyCallables.find(callable->GetUniqueId()); - Y_VERIFY(ctxIt != ProxyCallables.end()); + Y_VERIFY(ctxIt != ProxyCallables.end()); ctxIt->second.ShardsToWrite.insert(shard); } } @@ -1567,7 +1567,7 @@ private: if (name == Strings.SelectRow || name == Strings.SelectRange) { auto ctxIt = ProxyCallables.find(callable->GetUniqueId()); - Y_VERIFY(ctxIt != ProxyCallables.end()); + Y_VERIFY(ctxIt != ProxyCallables.end()); auto& ctx = ctxIt->second; auto uniqueName = ToString(callable->GetUniqueId()); shardsForReadBuilder.Add(uniqueName, ctx.ShardsForRead); @@ -1908,7 +1908,7 @@ private: if (name == Strings.SelectRow || name == Strings.SelectRange) { auto ctxIt = ProxyCallables.find(callable->GetUniqueId()); - Y_VERIFY(ctxIt != ProxyCallables.end()); + Y_VERIFY(ctxIt != ProxyCallables.end()); ProxyRepliesCallables[callable->GetUniqueId()] = callable; } else if (name == Strings.Builtins.Filter || name == Strings.Builtins.FilterNullMembers || @@ -2032,7 +2032,7 @@ private: auto name = ctx.Node->GetType()->GetNameStr(); if (name == Strings.SelectRow || name == Strings.SelectRange) { auto key = ctx.Key; - Y_VERIFY(key); + Y_VERIFY(key); TListLiteralBuilder listOfShards(Env, Ui64Type); for (auto& partition : key->Partitions) { @@ -2141,7 +2141,7 @@ TAutoPtr<IEngineFlat> CreateEngineFlat(const TEngineFlatSettings& settings) { } // namespace NKikimr template<> -void Out<NKikimr::NMiniKQL::IEngineFlat::EStatus>(IOutputStream& o, NKikimr::NMiniKQL::IEngineFlat::EStatus status) { +void Out<NKikimr::NMiniKQL::IEngineFlat::EStatus>(IOutputStream& o, NKikimr::NMiniKQL::IEngineFlat::EStatus status) { using namespace NKikimr::NMiniKQL; switch (status) { case IEngineFlat::EStatus::Unknown: o << "Unknown"; break; diff --git a/ydb/core/engine/mkql_engine_flat.h b/ydb/core/engine/mkql_engine_flat.h index 7bee67584b9..984b3146acf 100644 --- a/ydb/core/engine/mkql_engine_flat.h +++ b/ydb/core/engine/mkql_engine_flat.h @@ -279,7 +279,7 @@ namespace NMiniKQL { , AllocCounters(allocCounters) , ForceOnline(false) { - Y_VERIFY(FunctionRegistry); + Y_VERIFY(FunctionRegistry); } }; diff --git a/ydb/core/engine/mkql_engine_flat_extfunc.cpp b/ydb/core/engine/mkql_engine_flat_extfunc.cpp index 414d3aeeb45..a720507fe95 100644 --- a/ydb/core/engine/mkql_engine_flat_extfunc.cpp +++ b/ydb/core/engine/mkql_engine_flat_extfunc.cpp @@ -205,7 +205,7 @@ namespace { {} NUdf::TUnboxedValuePod DoCalculate(TComputationContext&) const { - Y_FAIL("Failed to build value for dummy node"); + Y_FAIL("Failed to build value for dummy node"); } private: void RegisterDependencies() const final {} diff --git a/ydb/core/engine/mkql_engine_flat_host_ut.cpp b/ydb/core/engine/mkql_engine_flat_host_ut.cpp index 68679f168df..ad1245e452d 100644 --- a/ydb/core/engine/mkql_engine_flat_host_ut.cpp +++ b/ydb/core/engine/mkql_engine_flat_host_ut.cpp @@ -14,7 +14,7 @@ namespace NMiniKQL { using namespace NTabletFlatExecutor; -Y_UNIT_TEST_SUITE(TMiniKQLEngineFlatHostTest) { +Y_UNIT_TEST_SUITE(TMiniKQLEngineFlatHostTest) { struct Schema : NIceDb::Schema { struct TestTable : Table<1> { @@ -39,14 +39,14 @@ Y_UNIT_TEST_SUITE(TMiniKQLEngineFlatHostTest) { }; - Y_UNIT_TEST(ShardId) { + Y_UNIT_TEST(ShardId) { NTable::TDatabase DB; TEngineHostCounters hostCounters; TUnversionedEngineHost host(DB, hostCounters, TEngineHostSettings(100)); UNIT_ASSERT_VALUES_EQUAL(host.GetShardId(), 100); } - Y_UNIT_TEST(Basic) { + Y_UNIT_TEST(Basic) { NTable::TDatabase DB; NIceDb::TNiceDb db(DB); @@ -76,7 +76,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLEngineFlatHostTest) { // TODO: ... MINIKQL ... - Y_UNUSED(host); + Y_UNUSED(host); DB.Commit(3, true); } diff --git a/ydb/core/engine/mkql_engine_flat_ut.cpp b/ydb/core/engine/mkql_engine_flat_ut.cpp index e2b12e2d7a5..252306f0ea5 100644 --- a/ydb/core/engine/mkql_engine_flat_ut.cpp +++ b/ydb/core/engine/mkql_engine_flat_ut.cpp @@ -289,7 +289,7 @@ namespace { }; } -Y_UNIT_TEST_SUITE(TMiniKQLEngineFlatTest) { +Y_UNIT_TEST_SUITE(TMiniKQLEngineFlatTest) { template<NUdf::TDataTypeId TKey, NUdf::TDataTypeId TValue> NKikimrMiniKQL::TResult WriteSomething( @@ -338,7 +338,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLEngineFlatTest) { return res; } - Y_UNIT_TEST(TestEmptyProgram) { + Y_UNIT_TEST(TestEmptyProgram) { TDriver driver; auto& pgmBuilder = driver.PgmBuilder; auto pgm = pgmBuilder.Build(pgmBuilder.NewEmptyListOfVoid()); @@ -353,7 +353,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLEngineFlatTest) { UNIT_ASSERT_STRINGS_EQUAL(resStr, expectedStr); } - Y_UNIT_TEST(TestPureProgram) { + Y_UNIT_TEST(TestPureProgram) { TDriver driver; auto& pgmBuilder = driver.PgmBuilder; auto value = pgmBuilder.TProgramBuilder::TProgramBuilder::NewDataLiteral<ui32>(42); @@ -392,7 +392,7 @@ Value { UNIT_ASSERT_STRINGS_EQUAL(resStr, expectedStr); } - Y_UNIT_TEST(TestAbort) { + Y_UNIT_TEST(TestAbort) { TDriver driver; auto& pgmBuilder = driver.PgmBuilder; auto pgm = pgmBuilder.Build(pgmBuilder.AsList(pgmBuilder.Abort())); @@ -407,7 +407,7 @@ Value { UNIT_ASSERT_STRINGS_EQUAL(resStr, expectedStr); } - Y_UNIT_TEST(TestSelectRowWithoutColumnsNotExists) { + Y_UNIT_TEST(TestSelectRowWithoutColumnsNotExists) { TDriver driver; driver.ShardDbState.AddShard<Schema1>(Shard1); auto& pgmBuilder = driver.PgmBuilder; @@ -453,7 +453,7 @@ Value { UNIT_ASSERT_STRINGS_EQUAL(resStr, expectedStr); } - Y_UNIT_TEST(TestSelectRowWithoutColumnsExists) { + Y_UNIT_TEST(TestSelectRowWithoutColumnsExists) { TDriver driver; driver.ShardDbState.AddShard<Schema1>(Shard1); @@ -512,7 +512,7 @@ Value { UNIT_ASSERT_STRINGS_EQUAL(resStr, expectedStr); } - Y_UNIT_TEST(TestSelectRowPayload) { + Y_UNIT_TEST(TestSelectRowPayload) { TDriver driver; driver.ShardDbState.AddShard<Schema1>(Shard1); @@ -593,7 +593,7 @@ Value { UNIT_ASSERT_STRINGS_EQUAL(resStr, expectedStr); } - Y_UNIT_TEST(TestSelectRowPayloadNullKey) { + Y_UNIT_TEST(TestSelectRowPayloadNullKey) { TDriver driver; driver.ShardDbState.AddShard<Schema1>(Shard1); @@ -660,7 +660,7 @@ Value { } - Y_UNIT_TEST(TestEraseRow) { + Y_UNIT_TEST(TestEraseRow) { TDriver driver; driver.ShardDbState.AddShard<Schema1>(Shard1); @@ -705,7 +705,7 @@ Value { } } - Y_UNIT_TEST(TestEraseRowNullKey) { + Y_UNIT_TEST(TestEraseRowNullKey) { TDriver driver; driver.ShardDbState.AddShard<Schema1>(Shard1); @@ -785,7 +785,7 @@ Value { } } - Y_UNIT_TEST(TestUpdateRowNotExistWithoutColumns) { + Y_UNIT_TEST(TestUpdateRowNotExistWithoutColumns) { TDriver driver; driver.ShardDbState.AddShard<Schema1>(Shard1); @@ -823,7 +823,7 @@ Value { } } - Y_UNIT_TEST(TestUpdateRowNotExistSetPayload) { + Y_UNIT_TEST(TestUpdateRowNotExistSetPayload) { TDriver driver; driver.ShardDbState.AddShard<Schema1>(Shard1); @@ -866,7 +866,7 @@ Value { } } - Y_UNIT_TEST(TestUpdateRowNotExistSetPayloadNullValue) { + Y_UNIT_TEST(TestUpdateRowNotExistSetPayloadNullValue) { TDriver driver; driver.ShardDbState.AddShard<Schema1>(Shard1); @@ -895,7 +895,7 @@ Value { } } - Y_UNIT_TEST(TestUpdateRowNotExistErasePayload) { + Y_UNIT_TEST(TestUpdateRowNotExistErasePayload) { TDriver driver; driver.ShardDbState.AddShard<Schema1>(Shard1); @@ -935,7 +935,7 @@ Value { } } - Y_UNIT_TEST(TestUpdateRowExistChangePayload) { + Y_UNIT_TEST(TestUpdateRowExistChangePayload) { TDriver driver; driver.ShardDbState.AddShard<Schema1>(Shard1); @@ -988,7 +988,7 @@ Value { } } - Y_UNIT_TEST(TestUpdateRowExistErasePayload) { + Y_UNIT_TEST(TestUpdateRowExistErasePayload) { TDriver driver; driver.ShardDbState.AddShard<Schema1>(Shard1); @@ -1038,7 +1038,7 @@ Value { } } - Y_UNIT_TEST(TestSelectRangeFullWithoutColumnsNotExists) { + Y_UNIT_TEST(TestSelectRangeFullWithoutColumnsNotExists) { TDriver driver; driver.ShardDbState.AddShard<Schema1>(Shard1); auto& pgmBuilder = driver.PgmBuilder; @@ -1109,7 +1109,7 @@ Value { UNIT_ASSERT_STRINGS_EQUAL(resStr, expectedStr); } - Y_UNIT_TEST(TestSelectRangeFullWithoutColumnsNotExistsNullKey) { + Y_UNIT_TEST(TestSelectRangeFullWithoutColumnsNotExistsNullKey) { TDriver driver; driver.ShardDbState.AddShard<Schema1>(Shard1); auto& pgmBuilder = driver.PgmBuilder; @@ -1181,7 +1181,7 @@ Value { } - Y_UNIT_TEST(TestSelectRangeFullExists) { + Y_UNIT_TEST(TestSelectRangeFullExists) { TDriver driver; driver.ShardDbState.AddShard<Schema1>(Shard1); @@ -1299,7 +1299,7 @@ Value { UNIT_ASSERT_STRINGS_EQUAL(resStr, expectedStr); } - Y_UNIT_TEST(TestSelectRangeFullExistsTruncatedByItems) { + Y_UNIT_TEST(TestSelectRangeFullExistsTruncatedByItems) { TDriver driver; driver.ShardDbState.AddShard<Schema1>(Shard1); @@ -1409,7 +1409,7 @@ Value { UNIT_ASSERT_STRINGS_EQUAL(resStr, expectedStr); } - Y_UNIT_TEST(TestSelectRangeFullExistsTruncatedByItemsFromNull) { + Y_UNIT_TEST(TestSelectRangeFullExistsTruncatedByItemsFromNull) { TDriver driver; driver.ShardDbState.AddShard<Schema1>(Shard1); @@ -1519,7 +1519,7 @@ Value { UNIT_ASSERT_STRINGS_EQUAL(resStr, expectedStr); } - Y_UNIT_TEST(TestSelectRangeFullExistsTruncatedByBytes) { + Y_UNIT_TEST(TestSelectRangeFullExistsTruncatedByBytes) { TDriver driver; driver.ShardDbState.AddShard<Schema1>(Shard1); @@ -1640,7 +1640,7 @@ Value { UNIT_ASSERT_STRINGS_EQUAL(resStr, expectedStr); } - Y_UNIT_TEST(TestSelectRangeFromInclusive) { + Y_UNIT_TEST(TestSelectRangeFromInclusive) { TDriver driver; driver.ShardDbState.AddShard<Schema1>(Shard1); @@ -1761,7 +1761,7 @@ Value { UNIT_ASSERT_STRINGS_EQUAL(resStr, expectedStr); } - Y_UNIT_TEST(TestSelectRangeFromExclusive) { + Y_UNIT_TEST(TestSelectRangeFromExclusive) { TDriver driver; driver.ShardDbState.AddShard<Schema1>(Shard1); @@ -1877,7 +1877,7 @@ Value { UNIT_ASSERT_STRINGS_EQUAL(resStr, expectedStr); } - Y_UNIT_TEST(TestSelectRangeToInclusive) { + Y_UNIT_TEST(TestSelectRangeToInclusive) { TDriver driver; driver.ShardDbState.AddShard<Schema1>(Shard1); @@ -2001,7 +2001,7 @@ Value { UNIT_ASSERT_STRINGS_EQUAL(resStr, expectedStr); } - Y_UNIT_TEST(TestSelectRangeNullNull) { + Y_UNIT_TEST(TestSelectRangeNullNull) { TDriver driver; driver.ShardDbState.AddShard<Schema1>(Shard1); @@ -2111,7 +2111,7 @@ Value { UNIT_ASSERT_STRINGS_EQUAL(resStr, expectedStr); } - Y_UNIT_TEST(TestSelectRangeToExclusive) { + Y_UNIT_TEST(TestSelectRangeToExclusive) { TDriver driver; driver.ShardDbState.AddShard<Schema1>(Shard1); @@ -2228,7 +2228,7 @@ Value { UNIT_ASSERT_STRINGS_EQUAL(resStr, expectedStr); } - Y_UNIT_TEST(TestSelectRangeBothIncFromIncTo) { + Y_UNIT_TEST(TestSelectRangeBothIncFromIncTo) { TDriver driver; driver.ShardDbState.AddShard<Schema1>(Shard1); @@ -2357,7 +2357,7 @@ Value { UNIT_ASSERT_STRINGS_EQUAL(resStr, expectedStr); } - Y_UNIT_TEST(TestSelectRangeBothExcFromIncTo) { + Y_UNIT_TEST(TestSelectRangeBothExcFromIncTo) { TDriver driver; driver.ShardDbState.AddShard<Schema1>(Shard1); @@ -2479,7 +2479,7 @@ Value { UNIT_ASSERT_STRINGS_EQUAL(resStr, expectedStr); } - Y_UNIT_TEST(TestSelectRangeBothIncFromExcTo) { + Y_UNIT_TEST(TestSelectRangeBothIncFromExcTo) { TDriver driver; driver.ShardDbState.AddShard<Schema1>(Shard1); @@ -2601,7 +2601,7 @@ Value { UNIT_ASSERT_STRINGS_EQUAL(resStr, expectedStr); } - Y_UNIT_TEST(TestSelectRangeBothExcFromExcTo) { + Y_UNIT_TEST(TestSelectRangeBothExcFromExcTo) { TDriver driver; driver.ShardDbState.AddShard<Schema1>(Shard1); @@ -2716,7 +2716,7 @@ Value { UNIT_ASSERT_STRINGS_EQUAL(resStr, expectedStr); } - Y_UNIT_TEST(TestSelectRowManyShards) { + Y_UNIT_TEST(TestSelectRowManyShards) { TDriver driver; driver.ShardDbState.AddShard<Schema1>(Shard1); driver.ShardDbState.AddShard<Schema2>(Shard2); @@ -2865,7 +2865,7 @@ Value { UNIT_ASSERT_STRINGS_EQUAL(resStr, expectedStr); } - Y_UNIT_TEST(TestEraseRowManyShards) { + Y_UNIT_TEST(TestEraseRowManyShards) { TDriver driver; driver.ShardDbState.AddShard<Schema1>(Shard1); driver.ShardDbState.AddShard<Schema2>(Shard2); @@ -2941,7 +2941,7 @@ Value { } } - Y_UNIT_TEST(TestUpdateRowManyShards) { + Y_UNIT_TEST(TestUpdateRowManyShards) { TDriver driver; driver.ShardDbState.AddShard<Schema1>(Shard1); driver.ShardDbState.AddShard<Schema2>(Shard2); @@ -3131,23 +3131,23 @@ Value { } } - Y_UNIT_TEST(TestCASBoth2Success) { + Y_UNIT_TEST(TestCASBoth2Success) { TestCASBoth2Impl(false, false); } - Y_UNIT_TEST(TestCASBoth2Fail1) { + Y_UNIT_TEST(TestCASBoth2Fail1) { TestCASBoth2Impl(true, false); } - Y_UNIT_TEST(TestCASBoth2Fail2) { + Y_UNIT_TEST(TestCASBoth2Fail2) { TestCASBoth2Impl(false, true); } - Y_UNIT_TEST(TestCASBoth2Fail12) { + Y_UNIT_TEST(TestCASBoth2Fail12) { TestCASBoth2Impl(true, true); } - Y_UNIT_TEST(TestSelectRowNoShards) { + Y_UNIT_TEST(TestSelectRowNoShards) { TDriver driver; driver.ShardDbState.AddShard<Schema1>(Shard1); @@ -3221,7 +3221,7 @@ Value { UNIT_ASSERT_STRINGS_EQUAL(resStr, expectedStr); } - Y_UNIT_TEST(TestSelectRangeNoShards) { + Y_UNIT_TEST(TestSelectRangeNoShards) { TDriver driver; driver.ShardDbState.AddShard<Schema1>(Shard1); @@ -3324,7 +3324,7 @@ Value { UNIT_ASSERT_STRINGS_EQUAL(resStr, expectedStr); } - Y_UNIT_TEST(TestUpdateRowNoShards) { + Y_UNIT_TEST(TestUpdateRowNoShards) { TDriver driver; driver.ShardDbState.AddShard<Schema1>(Shard1); @@ -3365,7 +3365,7 @@ Value { } } - Y_UNIT_TEST(TestEraseRowNoShards) { + Y_UNIT_TEST(TestEraseRowNoShards) { TDriver driver; driver.ShardDbState.AddShard<Schema1>(Shard1); @@ -3410,7 +3410,7 @@ Value { } } - Y_UNIT_TEST(TestSelectRangeWithPartitions) { + Y_UNIT_TEST(TestSelectRangeWithPartitions) { TDriver driver; driver.ShardDbState.AddShard<Schema1>(Shard1); driver.ShardDbState.AddShard<Schema1>(Shard2); @@ -3535,7 +3535,7 @@ Value { UNIT_ASSERT_STRINGS_EQUAL(resStr, expectedStr); } - Y_UNIT_TEST(TestSelectRangeWithPartitionsTruncatedByItems) { + Y_UNIT_TEST(TestSelectRangeWithPartitionsTruncatedByItems) { TDriver driver; driver.ShardDbState.AddShard<Schema1>(Shard1); driver.ShardDbState.AddShard<Schema1>(Shard2); @@ -3654,7 +3654,7 @@ Value { UNIT_ASSERT_STRINGS_EQUAL(resStr, expectedStr); } - Y_UNIT_TEST(TestSelectRangeWithPartitionsTruncatedByBytes) { + Y_UNIT_TEST(TestSelectRangeWithPartitionsTruncatedByBytes) { TDriver driver; driver.ShardDbState.AddShard<Schema1>(Shard1); driver.ShardDbState.AddShard<Schema1>(Shard2); @@ -4336,7 +4336,7 @@ Value { UNIT_ASSERT_STRINGS_EQUAL(resStr, expectedStr); } - Y_UNIT_TEST(TestBug998) { + Y_UNIT_TEST(TestBug998) { TDriver driver; auto& pgmBuilder = driver.PgmBuilder; auto value1 = pgmBuilder.TProgramBuilder::NewDataLiteral<ui32>(4294967172); @@ -4377,7 +4377,7 @@ Value { UNIT_ASSERT_STRINGS_EQUAL(resStr, expectedStr); } - Y_UNIT_TEST(TestAcquireLocks) { + Y_UNIT_TEST(TestAcquireLocks) { TDriver driver; driver.ShardDbState.AddShard<Schema1>(Shard1); auto& pgmBuilder = driver.PgmBuilder; @@ -4534,7 +4534,7 @@ Value { UNIT_ASSERT_STRINGS_EQUAL(resStr, expectedStr); } - Y_UNIT_TEST(TestDiagnostics) { + Y_UNIT_TEST(TestDiagnostics) { TDriver driver; driver.ShardDbState.AddShard<Schema1>(Shard1); auto& pgmBuilder = driver.PgmBuilder; @@ -4687,7 +4687,7 @@ Value { UNIT_ASSERT_STRINGS_EQUAL(resStr, expectedStr); } - Y_UNIT_TEST(TestMapsPushdown) { + Y_UNIT_TEST(TestMapsPushdown) { const TString okValue = "Ok"; TDriver driver; @@ -4783,7 +4783,7 @@ Value { ]]])___", res); } - Y_UNIT_TEST(NoMapPushdownMultipleConsumers) { + Y_UNIT_TEST(NoMapPushdownMultipleConsumers) { TDriver driver; driver.ShardDbState.AddShard<Schema1>(Shard1); @@ -4851,7 +4851,7 @@ Value { ])___", res); } - Y_UNIT_TEST(NoMapPushdownNonPureLambda) { + Y_UNIT_TEST(NoMapPushdownNonPureLambda) { TDriver driver; driver.ShardDbState.AddShard<Schema1>(Shard1); @@ -4912,7 +4912,7 @@ Value { ]]])___", res); } - Y_UNIT_TEST(NoOrderedMapPushdown) { + Y_UNIT_TEST(NoOrderedMapPushdown) { TDriver driver; driver.ShardDbState.AddShard<Schema1>(Shard1); @@ -4988,7 +4988,7 @@ Value { ]]])___", res); } - Y_UNIT_TEST(NoMapPushdownWriteToTable) { + Y_UNIT_TEST(NoMapPushdownWriteToTable) { TDriver driver; driver.ShardDbState.AddShard<Schema1>(Shard1); driver.ShardDbState.AddShard<Schema2>(Shard2); @@ -5091,7 +5091,7 @@ Value { } } - Y_UNIT_TEST(NoMapPushdownArgClosure) { + Y_UNIT_TEST(NoMapPushdownArgClosure) { TDriver driver; driver.ShardDbState.AddShard<Schema1>(Shard1); driver.ShardDbState.AddShard<Schema2>(Shard2); @@ -5181,7 +5181,7 @@ Value { ]]])___", res); } - Y_UNIT_TEST(TestSomePushDown) { + Y_UNIT_TEST(TestSomePushDown) { TDriver driver; driver.ShardDbState.AddShard<Schema1>(Shard1); driver.ShardDbState.AddShard<Schema2>(Shard2); @@ -5279,7 +5279,7 @@ Value { ]]])___", res); } - Y_UNIT_TEST(TestCombineByKeyPushdown) { + Y_UNIT_TEST(TestCombineByKeyPushdown) { TDriver driver; driver.ShardDbState.AddShard<Schema1>(Shard1); driver.ShardDbState.AddShard<Schema1>(Shard2); @@ -5393,7 +5393,7 @@ Value { ]]])___", res); } - Y_UNIT_TEST(TestCombineByKeyNoPushdown) { + Y_UNIT_TEST(TestCombineByKeyNoPushdown) { TDriver driver; driver.ShardDbState.AddShard<Schema1>(Shard1); driver.ShardDbState.AddShard<Schema1>(Shard2); @@ -5502,7 +5502,7 @@ Value { ]]])___", res); } - Y_UNIT_TEST(TestTakePushdown) { + Y_UNIT_TEST(TestTakePushdown) { TDriver driver; driver.ShardDbState.AddShard<Schema1>(Shard1); driver.ShardDbState.AddShard<Schema1>(Shard2); @@ -5584,7 +5584,7 @@ Value { ]]])___", res); } - Y_UNIT_TEST(TestNoOrderedTakePushdown) { + Y_UNIT_TEST(TestNoOrderedTakePushdown) { TDriver driver; driver.ShardDbState.AddShard<Schema1>(Shard1); driver.ShardDbState.AddShard<Schema1>(Shard2); @@ -5660,7 +5660,7 @@ Value { ]]])___", res); } - Y_UNIT_TEST(TestLengthPushdown) { + Y_UNIT_TEST(TestLengthPushdown) { TDriver driver; driver.ShardDbState.AddShard<Schema1>(Shard1); driver.ShardDbState.AddShard<Schema1>(Shard2); @@ -5739,7 +5739,7 @@ Value { NKqp::CompareYson(R"___([["3"]])___", res); } - Y_UNIT_TEST(TestNoAggregatedPushdown) { + Y_UNIT_TEST(TestNoAggregatedPushdown) { TDriver driver; driver.ShardDbState.AddShard<Schema1>(Shard1); driver.ShardDbState.AddShard<Schema1>(Shard2); @@ -5826,7 +5826,7 @@ Value { NKqp::CompareYson(R"___([["1"]])___", res); } - Y_UNIT_TEST(TestTopSortPushdownPk) { + Y_UNIT_TEST(TestTopSortPushdownPk) { TDriver driver; driver.ShardDbState.AddShard<Schema1>(Shard1); driver.ShardDbState.AddShard<Schema1>(Shard2); @@ -5911,7 +5911,7 @@ Value { NKqp::CompareYson(R"___([[[[["2"];["Value2"]];[["3"];["Value3"]]]]])___", res); } - Y_UNIT_TEST(TestTopSortPushdown) { + Y_UNIT_TEST(TestTopSortPushdown) { TDriver driver; driver.ShardDbState.AddShard<Schema1>(Shard1); driver.ShardDbState.AddShard<Schema1>(Shard2); @@ -6184,7 +6184,7 @@ Value { NKqp::CompareYson(R"___([[[[["4"];["Value4"]];[["3"];["Value3"]]]]])___", res); } - Y_UNIT_TEST(TestSelectRangeNoColumns) { + Y_UNIT_TEST(TestSelectRangeNoColumns) { TDriver driver; driver.ShardDbState.AddShard<Schema1>(Shard1); @@ -6230,7 +6230,7 @@ Value { NKqp::CompareYson(R"___([["3"]])___", res); } - Y_UNIT_TEST(TestInternalResult) { + Y_UNIT_TEST(TestInternalResult) { TDriver driver; auto& pgmBuilder = driver.PgmBuilder; auto value = pgmBuilder.TProgramBuilder::TProgramBuilder::NewDataLiteral<ui32>(42); @@ -6242,7 +6242,7 @@ Value { Cout << res.DebugString() << Endl; } - Y_UNIT_TEST(TestIndependentSelects) { + Y_UNIT_TEST(TestIndependentSelects) { TDriver driver; driver.ShardDbState.AddShard<Schema1>(Shard1); driver.ShardDbState.AddShard<Schema2>(Shard2); diff --git a/ydb/core/engine/mkql_keys.h b/ydb/core/engine/mkql_keys.h index 635ad3ce147..1c9e44c83df 100644 --- a/ydb/core/engine/mkql_keys.h +++ b/ydb/core/engine/mkql_keys.h @@ -6,7 +6,7 @@ #include <ydb/library/yql/minikql/mkql_node_visitor.h> #include <ydb/core/scheme_types/scheme_types.h> -#include <util/stream/output.h> // for IOutputStream +#include <util/stream/output.h> // for IOutputStream #include <library/cpp/deprecated/enum_codegen/enum_codegen.h> diff --git a/ydb/core/engine/mkql_proto_ut.cpp b/ydb/core/engine/mkql_proto_ut.cpp index c6e00e947c5..b268cd39aa3 100644 --- a/ydb/core/engine/mkql_proto_ut.cpp +++ b/ydb/core/engine/mkql_proto_ut.cpp @@ -17,14 +17,14 @@ namespace NKikimr { namespace NMiniKQL { Y_UNIT_TEST_SUITE(TMiniKQLProtoTestYdb) { - Y_UNIT_TEST(TestExportVoidTypeYdb) { + Y_UNIT_TEST(TestExportVoidTypeYdb) { TestExportType<Ydb::Type>([](TProgramBuilder& pgmBuilder) { auto pgmReturn = pgmBuilder.NewVoid(); return pgmReturn; }, "void_type: NULL_VALUE\n"); } - Y_UNIT_TEST(TestExportDataTypeYdb) { + Y_UNIT_TEST(TestExportDataTypeYdb) { TestExportType<Ydb::Type>([](TProgramBuilder& pgmBuilder) { auto pgmReturn = pgmBuilder.NewDataLiteral<i32>(42); return pgmReturn; @@ -55,7 +55,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLProtoTestYdb) { "type_id: UUID\n"); } - Y_UNIT_TEST(TestExportOptionalTypeYdb) { + Y_UNIT_TEST(TestExportOptionalTypeYdb) { TestExportType<Ydb::Type>([](TProgramBuilder& pgmBuilder) { auto pgmReturn = pgmBuilder.NewOptional(pgmBuilder.NewDataLiteral<i32>(42)); return pgmReturn; @@ -67,7 +67,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLProtoTestYdb) { "}\n"); } - Y_UNIT_TEST(TestExportListTypeYdb) { + Y_UNIT_TEST(TestExportListTypeYdb) { TestExportType<Ydb::Type>([](TProgramBuilder& pgmBuilder) { auto pgmReturn = pgmBuilder.AsList(pgmBuilder.NewDataLiteral<i32>(42)); return pgmReturn; @@ -79,7 +79,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLProtoTestYdb) { "}\n"); } - Y_UNIT_TEST(TestExportTupleTypeYdb) { + Y_UNIT_TEST(TestExportTupleTypeYdb) { TestExportType<Ydb::Type>([](TProgramBuilder& pgmBuilder) { TRuntimeNode::TList items; items.push_back(pgmBuilder.NewDataLiteral<i32>(42)); @@ -97,7 +97,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLProtoTestYdb) { "}\n"); } - Y_UNIT_TEST(TestExportStructTypeYdb) { + Y_UNIT_TEST(TestExportStructTypeYdb) { TestExportType<Ydb::Type>([](TProgramBuilder& pgmBuilder) { std::vector<std::pair<std::string_view, TRuntimeNode>> items; items.push_back({ "x", pgmBuilder.NewDataLiteral<i32>(42) }); @@ -121,7 +121,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLProtoTestYdb) { "}\n"); } - Y_UNIT_TEST(TestExportDictTypeYdb) { + Y_UNIT_TEST(TestExportDictTypeYdb) { TestExportType<Ydb::Type>([](TProgramBuilder& pgmBuilder) { auto dictType = pgmBuilder.NewDictType(pgmBuilder.NewDataType(NUdf::TDataType<i32>::Id), pgmBuilder.NewDataType(NUdf::TDataType<char*>::Id), false); @@ -199,28 +199,28 @@ Y_UNIT_TEST(TestExportVariantStructTypeYdb) { expected); } - Y_UNIT_TEST(TestExportVoidYdb) { + Y_UNIT_TEST(TestExportVoidYdb) { TestExportValue<Ydb::Value>([](TProgramBuilder& pgmBuilder) { auto pgmReturn = pgmBuilder.NewVoid(); return pgmReturn; }, ""); } - Y_UNIT_TEST(TestExportBoolYdb) { + Y_UNIT_TEST(TestExportBoolYdb) { TestExportValue<Ydb::Value>([](TProgramBuilder& pgmBuilder) { auto pgmReturn = pgmBuilder.NewDataLiteral(true); return pgmReturn; }, "bool_value: true\n"); } - Y_UNIT_TEST(TestExportIntegralYdb) { + Y_UNIT_TEST(TestExportIntegralYdb) { TestExportValue<Ydb::Value>([](TProgramBuilder& pgmBuilder) { auto pgmReturn = pgmBuilder.NewDataLiteral<i32>(42); return pgmReturn; }, "int32_value: 42\n"); } - Y_UNIT_TEST(TestExportDoubleYdb) { + Y_UNIT_TEST(TestExportDoubleYdb) { TestExportValue<Ydb::Value>([](TProgramBuilder& pgmBuilder) { auto pgmReturn = pgmBuilder.NewDataLiteral(3.5); return pgmReturn; @@ -277,14 +277,14 @@ Y_UNIT_TEST(TestExportVariantStructTypeYdb) { "high_128: 1\n"); } - Y_UNIT_TEST(TestExportEmptyOptionalYdb) { + Y_UNIT_TEST(TestExportEmptyOptionalYdb) { TestExportValue<Ydb::Value>([](TProgramBuilder& pgmBuilder) { auto pgmReturn = pgmBuilder.NewEmptyOptionalDataLiteral(NUdf::TDataType<char*>::Id); return pgmReturn; }, "null_flag_value: NULL_VALUE\n"); } - Y_UNIT_TEST(TestExportEmptyOptionalOptionalYdb) { + Y_UNIT_TEST(TestExportEmptyOptionalOptionalYdb) { TestExportValue<Ydb::Value>([](TProgramBuilder& pgmBuilder) { auto pgmReturn = pgmBuilder.NewOptional( pgmBuilder.NewEmptyOptionalDataLiteral(NUdf::TDataType<char*>::Id)); @@ -295,7 +295,7 @@ Y_UNIT_TEST(TestExportVariantStructTypeYdb) { "}\n"); } - Y_UNIT_TEST(TestExportMultipleOptionalNotEmptyYdb) { + Y_UNIT_TEST(TestExportMultipleOptionalNotEmptyYdb) { TestExportValue<Ydb::Value>([](TProgramBuilder& pgmBuilder) { auto pgmReturn = pgmBuilder.NewOptional( pgmBuilder.NewOptional(pgmBuilder.NewDataLiteral<NUdf::EDataSlot::String>("abc"))); @@ -303,14 +303,14 @@ Y_UNIT_TEST(TestExportVariantStructTypeYdb) { }, "bytes_value: \"abc\"\n"); } - Y_UNIT_TEST(TestExportOptionalYdb) { + Y_UNIT_TEST(TestExportOptionalYdb) { TestExportValue<Ydb::Value>([](TProgramBuilder& pgmBuilder) { auto pgmReturn = pgmBuilder.NewOptional(pgmBuilder.NewDataLiteral<NUdf::EDataSlot::String>("abc")); return pgmReturn; }, "bytes_value: \"abc\"\n"); } - Y_UNIT_TEST(TestExportListYdb) { + Y_UNIT_TEST(TestExportListYdb) { TestExportValue<Ydb::Value>([](TProgramBuilder& pgmBuilder) { auto pgmReturn = pgmBuilder.AsList(pgmBuilder.NewDataLiteral<NUdf::EDataSlot::String>("abc")); return pgmReturn; @@ -320,7 +320,7 @@ Y_UNIT_TEST(TestExportVariantStructTypeYdb) { "}\n"); } - Y_UNIT_TEST(TestExportTupleYdb) { + Y_UNIT_TEST(TestExportTupleYdb) { TestExportValue<Ydb::Value>([](TProgramBuilder& pgmBuilder) { TRuntimeNode::TList items; items.push_back(pgmBuilder.NewDataLiteral<i32>(42)); @@ -336,7 +336,7 @@ Y_UNIT_TEST(TestExportVariantStructTypeYdb) { "}\n"); } - Y_UNIT_TEST(TestExportStructYdb) { + Y_UNIT_TEST(TestExportStructYdb) { TestExportValue<Ydb::Value>([](TProgramBuilder& pgmBuilder) { std::vector<std::pair<std::string_view, TRuntimeNode>> items; items.push_back({ "x", pgmBuilder.NewDataLiteral<i32>(42) }); @@ -352,7 +352,7 @@ Y_UNIT_TEST(TestExportVariantStructTypeYdb) { "}\n"); } - Y_UNIT_TEST(TestExportDictYdb) { + Y_UNIT_TEST(TestExportDictYdb) { TestExportValue<Ydb::Value>([](TProgramBuilder& pgmBuilder) { auto dictType = pgmBuilder.NewDictType(pgmBuilder.NewDataType(NUdf::TDataType<i32>::Id), pgmBuilder.NewDataType(NUdf::TDataType<char*>::Id), false); @@ -372,7 +372,7 @@ Y_UNIT_TEST(TestExportVariantStructTypeYdb) { "}\n"); } - Y_UNIT_TEST(TestExportVariantYdb) { + Y_UNIT_TEST(TestExportVariantYdb) { TestExportValue<Ydb::Value>([](TProgramBuilder& pgmBuilder) { std::vector<TType*> tupleElemenTypes; tupleElemenTypes.push_back(pgmBuilder.NewDataType(NUdf::TDataType<ui64>::Id)); @@ -402,7 +402,7 @@ Y_UNIT_TEST(TestExportVariantStructTypeYdb) { return errStr; } - Y_UNIT_TEST(TestCellsFromTuple) { + Y_UNIT_TEST(TestCellsFromTuple) { UNIT_ASSERT_VALUES_EQUAL("", DoTestCellsFromTuple( { NScheme::NTypeIds::Int32 diff --git a/ydb/core/erasure/erasure.cpp b/ydb/core/erasure/erasure.cpp index a41b0279328..07d896c91e3 100644 --- a/ydb/core/erasure/erasure.cpp +++ b/ydb/core/erasure/erasure.cpp @@ -1466,7 +1466,7 @@ void EoBlockRestore(TErasureType::ECrcMode crcMode, const TErasureType &type, TD ++missingDataPartCount; break; } else { - Y_VERIFY(partSet.Parts[i].size() == expectedPartSize, "partSet.Parts[%" PRIu32 "].size(): %" PRIu64 + Y_VERIFY(partSet.Parts[i].size() == expectedPartSize, "partSet.Parts[%" PRIu32 "].size(): %" PRIu64 " expectedPartSize: %" PRIu64 " erasure: %s partSet.FullDataSize: %" PRIu64, (ui32)i, (ui64)partSet.Parts[i].size(), expectedPartSize, type.ErasureName[type.GetErasure()].data(), (ui64)partSet.FullDataSize); @@ -1478,13 +1478,13 @@ void EoBlockRestore(TErasureType::ECrcMode crcMode, const TErasureType &type, TD missingDataPartIdxB = i; ++missingDataPartCount; } else { - Y_VERIFY(partSet.Parts[i].size() == expectedPartSize, "partSet.Parts[%" PRIu32 "].size()# %" PRIu32 + Y_VERIFY(partSet.Parts[i].size() == expectedPartSize, "partSet.Parts[%" PRIu32 "].size()# %" PRIu32 " != expectedPartSize# %" PRIu32 " erasure: %s partSet.FullDataSize: %" PRIu64, (ui32)i, (ui32)partSet.Parts[i].size(), (ui32)expectedPartSize, type.ErasureName[type.GetErasure()].data(), (ui64)partSet.FullDataSize); } } - Y_VERIFY(missingDataPartCount <= 2); + Y_VERIFY(missingDataPartCount <= 2); ui64 dataSize = partSet.FullDataSize; if (restoreParts) { @@ -1638,7 +1638,7 @@ void EoBlockRestore(TErasureType::ECrcMode crcMode, const TErasureType &type, TD // the main case :( TRACE("case# g" << Endl); VERBOSE_COUT(__LINE__ << " of " << __FILE__ << Endl); - Y_VERIFY(missingDataPartIdxA < p.DataParts && missingDataPartIdxB < p.DataParts); + Y_VERIFY(missingDataPartIdxA < p.DataParts && missingDataPartIdxB < p.DataParts); p.EoMainRestoreParts<isStripe, restoreParts, restoreFullData, false, restoreParityParts>(partSet, missingDataPartIdxA, missingDataPartIdxB); if (restoreParts) { @@ -1894,13 +1894,13 @@ void XorBlockRestore(TErasureType::ECrcMode crcMode, const TErasureType &type, T missingDataPartIdx = i; ++missingDataPartCount; } else { - Y_VERIFY(partSet.Parts[i].size() == expectedPartSize, "partSet.Parts[%" PRIu32 "].size(): %" PRIu64 + Y_VERIFY(partSet.Parts[i].size() == expectedPartSize, "partSet.Parts[%" PRIu32 "].size(): %" PRIu64 " expectedPartSize: %" PRIu64 " erasure: %s partSet.FullDataSize: %" PRIu64, (ui32)i, (ui64)partSet.Parts[i].size(), expectedPartSize, type.ErasureName[type.GetErasure()].data(), (ui64)partSet.FullDataSize); } } - Y_VERIFY(missingDataPartCount <= 1); + Y_VERIFY(missingDataPartCount <= 1); ui64 dataSize = partSet.FullDataSize; if (restoreParts && missingDataPartIdx != totalParts) { @@ -2986,7 +2986,7 @@ void TErasureType::RestoreData(ECrcMode crcMode, TDataPartSet& partSet, bool res ythrow TWithBackTrace<yexception>() << "Incorrect partSet size, received " << partSet.Parts.size() << " while expected " << (erasure.DataParts + erasure.ParityParts); } - Y_VERIFY_DEBUG(restoreFullData || restoreParts); + Y_VERIFY_DEBUG(restoreFullData || restoreParts); Y_VERIFY_DEBUG(erasure.Prime <= MAX_LINES_IN_BLOCK); switch (erasure.ErasureFamily) { case TErasureType::ErasureMirror: diff --git a/ydb/core/erasure/erasure.h b/ydb/core/erasure/erasure.h index 35bd68c2d2f..a24b885e304 100644 --- a/ydb/core/erasure/erasure.h +++ b/ydb/core/erasure/erasure.h @@ -282,7 +282,7 @@ struct TErasureType { } TString ToString() const { - Y_VERIFY((ui64)ErasureSpecies < ErasureSpeciesCount); + Y_VERIFY((ui64)ErasureSpecies < ErasureSpeciesCount); return ErasureName[ErasureSpecies]; } diff --git a/ydb/core/erasure/erasure_perf_test.cpp b/ydb/core/erasure/erasure_perf_test.cpp index 2aaee893345..8631ac3bc03 100644 --- a/ydb/core/erasure/erasure_perf_test.cpp +++ b/ydb/core/erasure/erasure_perf_test.cpp @@ -210,13 +210,13 @@ void MeasureSplitTime(TErasureType &type) { } } -Y_UNIT_TEST_SUITE(TErasurePerfTest) { - Y_UNIT_TEST(Split) { +Y_UNIT_TEST_SUITE(TErasurePerfTest) { + Y_UNIT_TEST(Split) { TErasureType type(TErasureType::EErasureSpecies::Erasure4Plus2Block); MeasureSplitTime(type); } - Y_UNIT_TEST(Restore) { + Y_UNIT_TEST(Restore) { TErasureType type(TErasureType::EErasureSpecies::Erasure4Plus2Block); MeasureRestoreTime(type); } diff --git a/ydb/core/erasure/erasure_ut.cpp b/ydb/core/erasure/erasure_ut.cpp index 2473bd16506..42ea679a5d2 100644 --- a/ydb/core/erasure/erasure_ut.cpp +++ b/ydb/core/erasure/erasure_ut.cpp @@ -228,9 +228,9 @@ TVector<TDiff> GenerateRandomDiff(NPrivate::TMersenne64 &randGen, ui32 dataSize, return diffs; } -Y_UNIT_TEST_SUITE(TErasureTypeTest) { +Y_UNIT_TEST_SUITE(TErasureTypeTest) { // Test if new version is capable to restore data splited by current version (which is right by definition) - Y_UNIT_TEST(isSplittedDataEqualsToOldVerion) { + Y_UNIT_TEST(isSplittedDataEqualsToOldVerion) { TVector<TVector<ui8>> dataPool { {49,184,130,19,181,231,130}, @@ -305,7 +305,7 @@ Y_UNIT_TEST_SUITE(TErasureTypeTest) { } - Y_UNIT_TEST(TestEo) { + Y_UNIT_TEST(TestEo) { ui32 species = (ui32)TErasureType::Erasure4Plus2Block; { TErasureType groupType((TErasureType::EErasureSpecies)species); @@ -376,7 +376,7 @@ Y_UNIT_TEST_SUITE(TErasureTypeTest) { isRestoreParts = true; break; default: - Y_FAIL(); + Y_FAIL(); } partSet = originalPartSet; @@ -495,7 +495,7 @@ Y_UNIT_TEST_SUITE(TErasureTypeTest) { } // Mirror tests - Y_UNIT_TEST(TestMirror3LossOfAllPossible3) { + Y_UNIT_TEST(TestMirror3LossOfAllPossible3) { // Set up the erasure TErasureType groupType(TErasureType::EErasureSpecies::ErasureMirror3); constexpr ui32 maxMissingParts = 2; @@ -504,7 +504,7 @@ Y_UNIT_TEST_SUITE(TErasureTypeTest) { } // Block tests - Y_UNIT_TEST(TestBlock31LossOfAllPossible1) { + Y_UNIT_TEST(TestBlock31LossOfAllPossible1) { // Set up the erasure TErasureType groupType(TErasureType::EErasureSpecies::Erasure3Plus1Block); constexpr ui32 maxMissingParts = 1; @@ -512,7 +512,7 @@ Y_UNIT_TEST_SUITE(TErasureTypeTest) { TestAllLossesDifferentSizes<maxMissingParts>(groupType, maxParts); } - Y_UNIT_TEST(TestBlock42LossOfAllPossible2) { + Y_UNIT_TEST(TestBlock42LossOfAllPossible2) { // Set up the erasure TErasureType groupType(TErasureType::EErasureSpecies::Erasure4Plus2Block); // Specify @@ -521,7 +521,7 @@ Y_UNIT_TEST_SUITE(TErasureTypeTest) { TestAllLossesDifferentSizes<maxMissingParts>(groupType, maxParts); } - Y_UNIT_TEST(TestBlock32LossOfAllPossible2) { + Y_UNIT_TEST(TestBlock32LossOfAllPossible2) { // Set up the erasure TErasureType groupType(TErasureType::EErasureSpecies::Erasure3Plus2Block); constexpr ui32 maxMissingParts = 2; @@ -529,7 +529,7 @@ Y_UNIT_TEST_SUITE(TErasureTypeTest) { TestAllLossesDifferentSizes<maxMissingParts>(groupType, maxParts); } - Y_UNIT_TEST(TestBlock43LossOfAllPossible3) { + Y_UNIT_TEST(TestBlock43LossOfAllPossible3) { // Set up the erasure TErasureType groupType(TErasureType::EErasureSpecies::Erasure4Plus3Block); constexpr ui32 maxMissingParts = 3; @@ -537,7 +537,7 @@ Y_UNIT_TEST_SUITE(TErasureTypeTest) { TestAllLossesDifferentSizes<maxMissingParts>(groupType, maxParts); } - Y_UNIT_TEST(TestBlock33LossOfAllPossible3) { + Y_UNIT_TEST(TestBlock33LossOfAllPossible3) { // Set up the erasure TErasureType groupType(TErasureType::EErasureSpecies::Erasure3Plus3Block); constexpr ui32 maxMissingParts = 3; @@ -545,7 +545,7 @@ Y_UNIT_TEST_SUITE(TErasureTypeTest) { TestAllLossesDifferentSizes<maxMissingParts>(groupType, maxParts); } - Y_UNIT_TEST(TestBlock23LossOfAllPossible3) { + Y_UNIT_TEST(TestBlock23LossOfAllPossible3) { // Set up the erasure TErasureType groupType(TErasureType::EErasureSpecies::Erasure2Plus3Block); constexpr ui32 maxMissingParts = 3; @@ -553,7 +553,7 @@ Y_UNIT_TEST_SUITE(TErasureTypeTest) { TestAllLossesDifferentSizes<maxMissingParts>(groupType, maxParts); } - Y_UNIT_TEST(TestBlock22LossOfAllPossible2) { + Y_UNIT_TEST(TestBlock22LossOfAllPossible2) { // Set up the erasure TErasureType groupType(TErasureType::EErasureSpecies::Erasure2Plus2Block); constexpr ui32 maxMissingParts = 2; @@ -563,7 +563,7 @@ Y_UNIT_TEST_SUITE(TErasureTypeTest) { // Stripe tests - Y_UNIT_TEST(TestStripe31LossOfAllPossible1) { + Y_UNIT_TEST(TestStripe31LossOfAllPossible1) { // Set up the erasure TErasureType groupType(TErasureType::EErasureSpecies::Erasure3Plus1Stripe); constexpr ui32 maxMissingParts = 1; @@ -571,7 +571,7 @@ Y_UNIT_TEST_SUITE(TErasureTypeTest) { TestAllLossesDifferentSizes<maxMissingParts>(groupType, maxParts); } - Y_UNIT_TEST(TestStripe42LossOfAllPossible2) { + Y_UNIT_TEST(TestStripe42LossOfAllPossible2) { // Set up the erasure TErasureType groupType(TErasureType::EErasureSpecies::Erasure4Plus2Stripe); // Specify @@ -580,7 +580,7 @@ Y_UNIT_TEST_SUITE(TErasureTypeTest) { TestAllLossesDifferentSizes<maxMissingParts>(groupType, maxParts); } - Y_UNIT_TEST(TestStripe32LossOfAllPossible2) { + Y_UNIT_TEST(TestStripe32LossOfAllPossible2) { // Set up the erasure TErasureType groupType(TErasureType::EErasureSpecies::Erasure3Plus2Stripe); constexpr ui32 maxMissingParts = 2; @@ -588,7 +588,7 @@ Y_UNIT_TEST_SUITE(TErasureTypeTest) { TestAllLossesDifferentSizes<maxMissingParts>(groupType, maxParts); } - Y_UNIT_TEST(TestStripe43LossOfAllPossible3) { + Y_UNIT_TEST(TestStripe43LossOfAllPossible3) { // Set up the erasure TErasureType groupType(TErasureType::EErasureSpecies::Erasure4Plus3Stripe); constexpr ui32 maxMissingParts = 3; @@ -596,7 +596,7 @@ Y_UNIT_TEST_SUITE(TErasureTypeTest) { TestAllLossesDifferentSizes<maxMissingParts>(groupType, maxParts); } - Y_UNIT_TEST(TestStripe33LossOfAllPossible3) { + Y_UNIT_TEST(TestStripe33LossOfAllPossible3) { // Set up the erasure TErasureType groupType(TErasureType::EErasureSpecies::Erasure3Plus3Stripe); constexpr ui32 maxMissingParts = 3; @@ -604,7 +604,7 @@ Y_UNIT_TEST_SUITE(TErasureTypeTest) { TestAllLossesDifferentSizes<maxMissingParts>(groupType, maxParts); } - Y_UNIT_TEST(TestStripe23LossOfAllPossible3) { + Y_UNIT_TEST(TestStripe23LossOfAllPossible3) { // Set up the erasure TErasureType groupType(TErasureType::EErasureSpecies::Erasure2Plus3Stripe); constexpr ui32 maxMissingParts = 3; @@ -612,7 +612,7 @@ Y_UNIT_TEST_SUITE(TErasureTypeTest) { TestAllLossesDifferentSizes<maxMissingParts>(groupType, maxParts); } - Y_UNIT_TEST(TestStripe22LossOfAllPossible2) { + Y_UNIT_TEST(TestStripe22LossOfAllPossible2) { // Set up the erasure TErasureType groupType(TErasureType::EErasureSpecies::Erasure2Plus2Stripe); constexpr ui32 maxMissingParts = 2; @@ -852,7 +852,7 @@ Y_UNIT_TEST_SUITE(TErasureTypeTest) { } /* - Y_UNIT_TEST(TestBlock42PartialRestoreSizeBug1Regression) { + Y_UNIT_TEST(TestBlock42PartialRestoreSizeBug1Regression) { // Set up the erasure TErasureType groupType(TErasureType::Erasure4Plus2Block); @@ -898,7 +898,7 @@ Y_UNIT_TEST_SUITE(TErasureTypeTest) { UNIT_ASSERT_STRINGS_EQUAL(expectedString.data(), restoredString.data()); } - Y_UNIT_TEST(TestBlock42PartialRestoreSizeBug2Regression) { + Y_UNIT_TEST(TestBlock42PartialRestoreSizeBug2Regression) { // Set up the erasure TErasureType groupType(TErasureType::Erasure4Plus2Block); diff --git a/ydb/core/kesus/proxy/proxy_actor_ut.cpp b/ydb/core/kesus/proxy/proxy_actor_ut.cpp index 98c8a955743..9a0365b6808 100644 --- a/ydb/core/kesus/proxy/proxy_actor_ut.cpp +++ b/ydb/core/kesus/proxy/proxy_actor_ut.cpp @@ -3,8 +3,8 @@ namespace NKikimr { namespace NKesus { -Y_UNIT_TEST_SUITE(TProxyActorTest) { - Y_UNIT_TEST(TestCreateSemaphore) { +Y_UNIT_TEST_SUITE(TProxyActorTest) { + Y_UNIT_TEST(TestCreateSemaphore) { TTestContext ctx; ctx.Setup(); ctx.CreateSemaphore(42, "Sem1", 1); @@ -13,7 +13,7 @@ Y_UNIT_TEST_SUITE(TProxyActorTest) { ctx.VerifySemaphoreParams(42, "Sem2", 2, "\x81\x82\x83\x84"); } - Y_UNIT_TEST(TestCreateSemaphoreInterrupted) { + Y_UNIT_TEST(TestCreateSemaphoreInterrupted) { TTestContext ctx; ctx.Setup(); ctx.CreateSemaphore(42, "Sem1", 1); @@ -25,7 +25,7 @@ Y_UNIT_TEST_SUITE(TProxyActorTest) { ctx.ExpectProxyError(edge, cookie, Ydb::StatusIds::UNAVAILABLE); } - Y_UNIT_TEST(TestAttachSession) { + Y_UNIT_TEST(TestAttachSession) { TTestContext ctx; ctx.Setup(); diff --git a/ydb/core/kesus/tablet/tablet_ut.cpp b/ydb/core/kesus/tablet/tablet_ut.cpp index 1cf1a80ca8e..e4ebd54f34a 100644 --- a/ydb/core/kesus/tablet/tablet_ut.cpp +++ b/ydb/core/kesus/tablet/tablet_ut.cpp @@ -34,8 +34,8 @@ namespace { } } -Y_UNIT_TEST_SUITE(TKesusTest) { - Y_UNIT_TEST(TestKesusConfig) { +Y_UNIT_TEST_SUITE(TKesusTest) { + Y_UNIT_TEST(TestKesusConfig) { TTestContext ctx; ctx.Setup(); @@ -79,7 +79,7 @@ Y_UNIT_TEST_SUITE(TKesusTest) { ctx.SetConfig(12345, MakeConfig("/foo/bar/baz"), 41, Ydb::StatusIds::PRECONDITION_FAILED); } - Y_UNIT_TEST(TestRegisterProxy) { + Y_UNIT_TEST(TestRegisterProxy) { TTestContext ctx; ctx.Setup(); auto proxy = ctx.Runtime->AllocateEdgeActor(); @@ -87,7 +87,7 @@ Y_UNIT_TEST_SUITE(TKesusTest) { ctx.VerifyProxyRegistered(proxy, 1); } - Y_UNIT_TEST(TestRegisterProxyBadGeneration) { + Y_UNIT_TEST(TestRegisterProxyBadGeneration) { TTestContext ctx; ctx.Setup(); auto proxy = ctx.Runtime->AllocateEdgeActor(); @@ -98,7 +98,7 @@ Y_UNIT_TEST_SUITE(TKesusTest) { ctx.MustRegisterProxy(proxy, 2, Ydb::StatusIds::BAD_REQUEST); } - Y_UNIT_TEST(TestRegisterProxyFromDeadActor) { + Y_UNIT_TEST(TestRegisterProxyFromDeadActor) { TTestContext ctx; ctx.Setup(); auto proxy = ctx.Runtime->Register(new TDyingActor()); @@ -111,7 +111,7 @@ Y_UNIT_TEST_SUITE(TKesusTest) { ctx.VerifyProxyNotRegistered(proxy); } - Y_UNIT_TEST(TestRegisterProxyLinkFailure) { + Y_UNIT_TEST(TestRegisterProxyLinkFailure) { TTestContext ctx; ctx.Setup(2); // register proxy from the second node @@ -133,7 +133,7 @@ Y_UNIT_TEST_SUITE(TKesusTest) { ctx.VerifyProxyNotRegistered(proxy); } - Y_UNIT_TEST(TestUnregisterProxy) { + Y_UNIT_TEST(TestUnregisterProxy) { TTestContext ctx; ctx.Setup(); auto proxy = ctx.Runtime->AllocateEdgeActor(); @@ -142,7 +142,7 @@ Y_UNIT_TEST_SUITE(TKesusTest) { ctx.VerifyProxyNotRegistered(proxy); } - Y_UNIT_TEST(TestUnregisterProxyBadGeneration) { + Y_UNIT_TEST(TestUnregisterProxyBadGeneration) { TTestContext ctx; ctx.Setup(); auto proxy = ctx.Runtime->AllocateEdgeActor(); @@ -151,7 +151,7 @@ Y_UNIT_TEST_SUITE(TKesusTest) { ctx.MustUnregisterProxy(proxy, 1, Ydb::StatusIds::BAD_SESSION); } - Y_UNIT_TEST(TestAttachNewSessions) { + Y_UNIT_TEST(TestAttachNewSessions) { TTestContext ctx; ctx.Setup(); auto proxy = ctx.Runtime->AllocateEdgeActor(); @@ -161,7 +161,7 @@ Y_UNIT_TEST_SUITE(TKesusTest) { ctx.VerifyProxyHasSessions(proxy, 1, {1, 2}); } - Y_UNIT_TEST(TestAttachMissingSession) { + Y_UNIT_TEST(TestAttachMissingSession) { TTestContext ctx; ctx.Setup(); auto proxy = ctx.Runtime->AllocateEdgeActor(); @@ -170,7 +170,7 @@ Y_UNIT_TEST_SUITE(TKesusTest) { UNIT_ASSERT_VALUES_EQUAL(result.GetError().GetStatus(), Ydb::StatusIds::SESSION_EXPIRED); } - Y_UNIT_TEST(TestAttachOldGeneration) { + Y_UNIT_TEST(TestAttachOldGeneration) { TTestContext ctx; ctx.Setup(); auto proxy = ctx.Runtime->AllocateEdgeActor(); @@ -182,7 +182,7 @@ Y_UNIT_TEST_SUITE(TKesusTest) { ctx.VerifyProxyHasSessions(proxy, 2, {1}); } - Y_UNIT_TEST(TestAttachOutOfSequence) { + Y_UNIT_TEST(TestAttachOutOfSequence) { TTestContext ctx; ctx.Setup(); auto proxy1 = ctx.Runtime->AllocateEdgeActor(); @@ -197,7 +197,7 @@ Y_UNIT_TEST_SUITE(TKesusTest) { ctx.VerifyProxyHasSessions(proxy1, 1, {1}); } - Y_UNIT_TEST(TestAttachOutOfSequenceInTx) { + Y_UNIT_TEST(TestAttachOutOfSequenceInTx) { TTestContext ctx; ctx.Setup(); auto proxy = ctx.Runtime->AllocateEdgeActor(); @@ -209,7 +209,7 @@ Y_UNIT_TEST_SUITE(TKesusTest) { ctx.VerifyProxyHasSessions(proxy, 1, {1}); } - Y_UNIT_TEST(TestAttachThenReRegister) { + Y_UNIT_TEST(TestAttachThenReRegister) { TTestContext ctx; ctx.Setup(); auto proxy = ctx.Runtime->AllocateEdgeActor(); @@ -222,7 +222,7 @@ Y_UNIT_TEST_SUITE(TKesusTest) { ctx.VerifySessionExists(1); } - Y_UNIT_TEST(TestAttachFastPath) { + Y_UNIT_TEST(TestAttachFastPath) { TTestContext ctx; ctx.Setup(); EnableRelaxedAttach(ctx); @@ -241,7 +241,7 @@ Y_UNIT_TEST_SUITE(TKesusTest) { UNIT_ASSERT_VALUES_EQUAL(ctx.ExpectAttachSessionResult(111, proxy2, 1), 2); } - Y_UNIT_TEST(TestAttachFastPathBlocked) { + Y_UNIT_TEST(TestAttachFastPathBlocked) { TTestContext ctx; ctx.Setup(); EnableRelaxedAttach(ctx); @@ -263,7 +263,7 @@ Y_UNIT_TEST_SUITE(TKesusTest) { UNIT_ASSERT_VALUES_EQUAL(ctx.ExpectAttachSessionResult(222, proxy2, 1), 1); } - Y_UNIT_TEST(TestSessionDetach) { + Y_UNIT_TEST(TestSessionDetach) { TTestContext ctx; ctx.Setup(); auto proxy1 = ctx.Runtime->AllocateEdgeActor(); @@ -292,7 +292,7 @@ Y_UNIT_TEST_SUITE(TKesusTest) { ctx.MustDetachSession(proxy1, 1, 1); } - Y_UNIT_TEST(TestSessionDetachFutureId) { + Y_UNIT_TEST(TestSessionDetachFutureId) { TTestContext ctx; ctx.Setup(); EnableRelaxedAttach(ctx); @@ -306,7 +306,7 @@ Y_UNIT_TEST_SUITE(TKesusTest) { UNIT_ASSERT_VALUES_EQUAL(ctx.ExpectAttachSessionResult(111, proxy, 1), 1); } - Y_UNIT_TEST(TestSessionDestroy) { + Y_UNIT_TEST(TestSessionDestroy) { TTestContext ctx; ctx.Setup(); auto proxy1 = ctx.Runtime->AllocateEdgeActor(); @@ -330,7 +330,7 @@ Y_UNIT_TEST_SUITE(TKesusTest) { UNIT_ASSERT_VALUES_EQUAL(event->Record.GetSessionId(), 2); } - Y_UNIT_TEST(TestAttachTimeoutTooBig) { + Y_UNIT_TEST(TestAttachTimeoutTooBig) { TTestContext ctx; ctx.Setup(); auto proxy = ctx.Runtime->AllocateEdgeActor(); @@ -339,7 +339,7 @@ Y_UNIT_TEST_SUITE(TKesusTest) { UNIT_ASSERT_VALUES_EQUAL(result.GetError().GetStatus(), Ydb::StatusIds::BAD_REQUEST); } - Y_UNIT_TEST(TestSessionTimeoutAfterDetach) { + Y_UNIT_TEST(TestSessionTimeoutAfterDetach) { TTestContext ctx; ctx.Setup(); auto proxy = ctx.Runtime->AllocateEdgeActor(); @@ -354,7 +354,7 @@ Y_UNIT_TEST_SUITE(TKesusTest) { ctx.VerifyProxyHasSessions(proxy, 1, {}); } - Y_UNIT_TEST(TestSessionTimeoutAfterReboot) { + Y_UNIT_TEST(TestSessionTimeoutAfterReboot) { TTestContext ctx; ctx.Setup(); auto proxy = ctx.Runtime->AllocateEdgeActor(); @@ -368,7 +368,7 @@ Y_UNIT_TEST_SUITE(TKesusTest) { ctx.VerifySessionNotFound(1); } - Y_UNIT_TEST(TestSessionTimeoutAfterUnregister) { + Y_UNIT_TEST(TestSessionTimeoutAfterUnregister) { TTestContext ctx; ctx.Setup(); auto proxy = ctx.Runtime->AllocateEdgeActor(); @@ -383,7 +383,7 @@ Y_UNIT_TEST_SUITE(TKesusTest) { UNIT_ASSERT_VALUES_EQUAL(event->Record.GetSessionId(), 1); } - Y_UNIT_TEST(TestSessionStealing) { + Y_UNIT_TEST(TestSessionStealing) { TTestContext ctx; ctx.Setup(); auto proxy1 = ctx.Runtime->AllocateEdgeActor(); @@ -456,13 +456,13 @@ Y_UNIT_TEST_SUITE(TKesusTest) { ctx.VerifyProxyHasSessions(proxy2, 222, {}); } - Y_UNIT_TEST(TestLockNotFound) { + Y_UNIT_TEST(TestLockNotFound) { TTestContext ctx; ctx.Setup(); ctx.VerifyLockNotFound("Lock1"); } - Y_UNIT_TEST(TestAcquireLocks) { + Y_UNIT_TEST(TestAcquireLocks) { TTestContext ctx; ctx.Setup(); auto proxy = ctx.Runtime->AllocateEdgeActor(); @@ -501,7 +501,7 @@ Y_UNIT_TEST_SUITE(TKesusTest) { ctx.VerifySessionNotFound(2); } - Y_UNIT_TEST(TestAcquireRepeat) { + Y_UNIT_TEST(TestAcquireRepeat) { TTestContext ctx; ctx.Setup(); auto proxy = ctx.Runtime->AllocateEdgeActor(); @@ -519,7 +519,7 @@ Y_UNIT_TEST_SUITE(TKesusTest) { ctx.VerifyLockExclusive("Lock1", 1); } - Y_UNIT_TEST(TestAcquireDowngrade) { + Y_UNIT_TEST(TestAcquireDowngrade) { TTestContext ctx; ctx.Setup(); auto proxy = ctx.Runtime->AllocateEdgeActor(); @@ -537,7 +537,7 @@ Y_UNIT_TEST_SUITE(TKesusTest) { ctx.VerifyLockShared("Lock1", {1}); } - Y_UNIT_TEST(TestAcquireUpgrade) { + Y_UNIT_TEST(TestAcquireUpgrade) { TTestContext ctx; ctx.Setup(); auto proxy = ctx.Runtime->AllocateEdgeActor(); @@ -551,7 +551,7 @@ Y_UNIT_TEST_SUITE(TKesusTest) { ctx.VerifyLockShared("Lock1", {1}); // still locked in shared mode } - Y_UNIT_TEST(TestAcquireTimeout) { + Y_UNIT_TEST(TestAcquireTimeout) { TTestContext ctx; ctx.Setup(); auto proxy1 = ctx.Runtime->AllocateEdgeActor(); @@ -588,7 +588,7 @@ Y_UNIT_TEST_SUITE(TKesusTest) { ctx.VerifyLockShared("Lock2", {1}); } - Y_UNIT_TEST(TestAcquireBeforeTimeoutViaRelease) { + Y_UNIT_TEST(TestAcquireBeforeTimeoutViaRelease) { TTestContext ctx; ctx.Setup(); auto proxy1 = ctx.Runtime->AllocateEdgeActor(); @@ -623,7 +623,7 @@ Y_UNIT_TEST_SUITE(TKesusTest) { ctx.VerifyLockExclusive("Lock2", 2); } - Y_UNIT_TEST(TestAcquireBeforeTimeoutViaSessionTimeout) { + Y_UNIT_TEST(TestAcquireBeforeTimeoutViaSessionTimeout) { TTestContext ctx; ctx.Setup(); auto proxy1 = ctx.Runtime->AllocateEdgeActor(); @@ -662,7 +662,7 @@ Y_UNIT_TEST_SUITE(TKesusTest) { ctx.VerifyLockExclusive("Lock2", 2); } - Y_UNIT_TEST(TestAcquireBeforeTimeoutViaModeChange) { + Y_UNIT_TEST(TestAcquireBeforeTimeoutViaModeChange) { TTestContext ctx; ctx.Setup(); auto proxy1 = ctx.Runtime->AllocateEdgeActor(); @@ -702,7 +702,7 @@ Y_UNIT_TEST_SUITE(TKesusTest) { ctx.VerifyLockShared("Lock2", {1, 2}); } - Y_UNIT_TEST(TestAcquireSharedBlocked) { + Y_UNIT_TEST(TestAcquireSharedBlocked) { TTestContext ctx; ctx.Setup(); auto proxy = ctx.Runtime->AllocateEdgeActor(); @@ -729,7 +729,7 @@ Y_UNIT_TEST_SUITE(TKesusTest) { ctx.VerifyLockWaiters("Lock1", {}); } - Y_UNIT_TEST(TestAcquireTimeoutAfterReboot) { + Y_UNIT_TEST(TestAcquireTimeoutAfterReboot) { TTestContext ctx; ctx.Setup(); auto proxy = ctx.Runtime->AllocateEdgeActor(); @@ -760,7 +760,7 @@ Y_UNIT_TEST_SUITE(TKesusTest) { ctx.VerifyLockWaiters("Lock1", {}); } - Y_UNIT_TEST(TestAcquireWaiterDowngrade) { + Y_UNIT_TEST(TestAcquireWaiterDowngrade) { TTestContext ctx; ctx.Setup(); auto proxy = ctx.Runtime->AllocateEdgeActor(); @@ -780,7 +780,7 @@ Y_UNIT_TEST_SUITE(TKesusTest) { ctx.VerifyLockShared("Lock1", {1, 2}); } - Y_UNIT_TEST(TestAcquireWaiterUpgrade) { + Y_UNIT_TEST(TestAcquireWaiterUpgrade) { TTestContext ctx; ctx.Setup(); auto proxy = ctx.Runtime->AllocateEdgeActor(); @@ -800,7 +800,7 @@ Y_UNIT_TEST_SUITE(TKesusTest) { ctx.VerifyLockWaiters("Lock1", {2}); } - Y_UNIT_TEST(TestAcquireWaiterChangeTimeoutToZero) { + Y_UNIT_TEST(TestAcquireWaiterChangeTimeoutToZero) { TTestContext ctx; ctx.Setup(); auto proxy = ctx.Runtime->AllocateEdgeActor(); @@ -829,7 +829,7 @@ Y_UNIT_TEST_SUITE(TKesusTest) { ctx.VerifyLockWaiters("Lock1", {}); } - Y_UNIT_TEST(TestAcquireWaiterRelease) { + Y_UNIT_TEST(TestAcquireWaiterRelease) { TTestContext ctx; ctx.Setup(); auto proxy = ctx.Runtime->AllocateEdgeActor(); @@ -846,7 +846,7 @@ Y_UNIT_TEST_SUITE(TKesusTest) { ctx.ExpectAcquireLockResult(222, proxy, 1, Ydb::StatusIds::ABORTED); } - Y_UNIT_TEST(TestReleaseLockFailure) { + Y_UNIT_TEST(TestReleaseLockFailure) { TTestContext ctx; ctx.Setup(); auto proxy = ctx.Runtime->AllocateEdgeActor(); @@ -862,7 +862,7 @@ Y_UNIT_TEST_SUITE(TKesusTest) { ctx.MustReleaseLock(333, proxy, 1, 2, "Lock1", false); } - Y_UNIT_TEST(TestCreateSemaphore) { + Y_UNIT_TEST(TestCreateSemaphore) { TTestContext ctx; ctx.Setup(); auto proxy = ctx.Runtime->AllocateEdgeActor(); @@ -885,7 +885,7 @@ Y_UNIT_TEST_SUITE(TKesusTest) { ctx.VerifySemaphoreNotFound("Sem2"); } - Y_UNIT_TEST(TestDeleteSemaphore) { + Y_UNIT_TEST(TestDeleteSemaphore) { TTestContext ctx; ctx.Setup(); auto proxy = ctx.Runtime->AllocateEdgeActor(); @@ -901,7 +901,7 @@ Y_UNIT_TEST_SUITE(TKesusTest) { ctx.DeleteSemaphore("Sem1", Ydb::StatusIds::NOT_FOUND); } - Y_UNIT_TEST(TestAcquireSemaphore) { + Y_UNIT_TEST(TestAcquireSemaphore) { TTestContext ctx; ctx.Setup(); auto proxy = ctx.Runtime->AllocateEdgeActor(); @@ -937,7 +937,7 @@ Y_UNIT_TEST_SUITE(TKesusTest) { ctx.ExpectAcquireSemaphoreResult(333, proxy, 1, Ydb::StatusIds::ABORTED); } - Y_UNIT_TEST(TestReleaseSemaphore) { + Y_UNIT_TEST(TestReleaseSemaphore) { TTestContext ctx; ctx.Setup(); auto proxy = ctx.Runtime->AllocateEdgeActor(); @@ -963,7 +963,7 @@ Y_UNIT_TEST_SUITE(TKesusTest) { ctx.VerifySemaphoreWaiters("Sem1", {}); } - Y_UNIT_TEST(TestAcquireSemaphoreTimeout) { + Y_UNIT_TEST(TestAcquireSemaphoreTimeout) { TTestContext ctx; ctx.Setup(); auto proxy = ctx.Runtime->AllocateEdgeActor(); @@ -985,7 +985,7 @@ Y_UNIT_TEST_SUITE(TKesusTest) { ctx.VerifySemaphoreWaiters("Sem1", {}); } - Y_UNIT_TEST(TestAcquireSemaphoreTimeoutTooBig) { + Y_UNIT_TEST(TestAcquireSemaphoreTimeoutTooBig) { TTestContext ctx; ctx.Setup(); auto proxy = ctx.Runtime->AllocateEdgeActor(); @@ -997,7 +997,7 @@ Y_UNIT_TEST_SUITE(TKesusTest) { ctx.ExpectAcquireSemaphoreResult(111, proxy, 1, Ydb::StatusIds::BAD_REQUEST); } - Y_UNIT_TEST(TestAcquireSemaphoreTimeoutInfinite) { + Y_UNIT_TEST(TestAcquireSemaphoreTimeoutInfinite) { TTestContext ctx; ctx.Setup(); auto proxy = ctx.Runtime->AllocateEdgeActor(); @@ -1016,7 +1016,7 @@ Y_UNIT_TEST_SUITE(TKesusTest) { ctx.VerifySemaphoreWaiters("Sem1", {2}); } - Y_UNIT_TEST(TestAcquireSemaphoreRebootTimeout) { + Y_UNIT_TEST(TestAcquireSemaphoreRebootTimeout) { TTestContext ctx; ctx.Setup(); auto proxy = ctx.Runtime->AllocateEdgeActor(); @@ -1033,7 +1033,7 @@ Y_UNIT_TEST_SUITE(TKesusTest) { ctx.VerifySemaphoreOwners("Sem1", {}); } - Y_UNIT_TEST(TestAcquireSemaphoreViaDecrease) { + Y_UNIT_TEST(TestAcquireSemaphoreViaDecrease) { TTestContext ctx; ctx.Setup(); auto proxy = ctx.Runtime->AllocateEdgeActor(); @@ -1065,7 +1065,7 @@ Y_UNIT_TEST_SUITE(TKesusTest) { ctx.VerifySemaphoreWaiters("Sem1", {}); } - Y_UNIT_TEST(TestAcquireSemaphoreViaRelease) { + Y_UNIT_TEST(TestAcquireSemaphoreViaRelease) { TTestContext ctx; ctx.Setup(); auto proxy = ctx.Runtime->AllocateEdgeActor(); @@ -1091,7 +1091,7 @@ Y_UNIT_TEST_SUITE(TKesusTest) { ctx.VerifySemaphoreWaiters("Sem1", {}); } - Y_UNIT_TEST(TestSemaphoreData) { + Y_UNIT_TEST(TestSemaphoreData) { TTestContext ctx; ctx.Setup(); @@ -1125,7 +1125,7 @@ Y_UNIT_TEST_SUITE(TKesusTest) { ctx.VerifySemaphoreNotFound("Sem3"); } - Y_UNIT_TEST(TestDescribeSemaphoreWatches) { + Y_UNIT_TEST(TestDescribeSemaphoreWatches) { TTestContext ctx; ctx.Setup(); auto proxy = ctx.Runtime->AllocateEdgeActor(); @@ -1279,7 +1279,7 @@ Y_UNIT_TEST_SUITE(TKesusTest) { } } - Y_UNIT_TEST(TestSemaphoreSessionFailures) { + Y_UNIT_TEST(TestSemaphoreSessionFailures) { TTestContext ctx; ctx.Setup(); auto proxy = ctx.Runtime->AllocateEdgeActor(); diff --git a/ydb/core/keyvalue/keyvalue_collector.cpp b/ydb/core/keyvalue/keyvalue_collector.cpp index 8b7696bcb25..c4ffc911556 100644 --- a/ydb/core/keyvalue/keyvalue_collector.cpp +++ b/ydb/core/keyvalue/keyvalue_collector.cpp @@ -42,7 +42,7 @@ public: , CollectorErrors(0) , IsSpringCleanup(isSpringCleanup) { - Y_VERIFY(CollectOperation.Get()); + Y_VERIFY(CollectOperation.Get()); } void Bootstrap(const TActorContext &ctx) { @@ -162,7 +162,7 @@ public: (*out)[outIdx] = blob; ++outIdx; } - Y_VERIFY(outIdx == size); + Y_VERIFY(outIdx == size); } } diff --git a/ydb/core/keyvalue/keyvalue_collector_ut.cpp b/ydb/core/keyvalue/keyvalue_collector_ut.cpp index 4456a823803..55a1b5ee71f 100644 --- a/ydb/core/keyvalue/keyvalue_collector_ut.cpp +++ b/ydb/core/keyvalue/keyvalue_collector_ut.cpp @@ -7,7 +7,7 @@ namespace NKikimr { -Y_UNIT_TEST_SUITE(TKeyValueCollectorTest) { +Y_UNIT_TEST_SUITE(TKeyValueCollectorTest) { //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // SETUP @@ -107,7 +107,7 @@ public: // TEST CASES //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -Y_UNIT_TEST(TestKeyValueCollectorEmpty) { +Y_UNIT_TEST(TestKeyValueCollectorEmpty) { TContext context; context.Setup(); @@ -133,7 +133,7 @@ Y_UNIT_TEST(TestKeyValueCollectorEmpty) { UNIT_ASSERT(eraseCollect); } -Y_UNIT_TEST(TestKeyValueCollectorSingle) { +Y_UNIT_TEST(TestKeyValueCollectorSingle) { TContext context; context.Setup(); @@ -169,7 +169,7 @@ Y_UNIT_TEST(TestKeyValueCollectorSingle) { UNIT_ASSERT(eraseCollect); } -Y_UNIT_TEST(TestKeyValueCollectorMultiple) { +Y_UNIT_TEST(TestKeyValueCollectorMultiple) { TContext context; context.Setup(); diff --git a/ydb/core/keyvalue/keyvalue_flat_impl.h b/ydb/core/keyvalue/keyvalue_flat_impl.h index 292f2feff93..26259e5dcc3 100644 --- a/ydb/core/keyvalue/keyvalue_flat_impl.h +++ b/ydb/core/keyvalue/keyvalue_flat_impl.h @@ -159,7 +159,7 @@ protected: txc.DB.NoMoreReadsForTx(); return true; #else - Y_UNUSED(txc); + Y_UNUSED(txc); return true; #endif } @@ -177,7 +177,7 @@ protected: {} bool Execute(NTabletFlatExecutor::TTransactionContext &txc, const TActorContext &ctx) override { - Y_UNUSED(txc); + Y_UNUSED(txc); TStringStream str; THolder<IEventBase> response; TCgiParameters params(Event->Cgi()); @@ -200,7 +200,7 @@ protected: } void Complete(const TActorContext &ctx) override { - Y_UNUSED(ctx); + Y_UNUSED(ctx); } }; @@ -406,7 +406,7 @@ protected: void Handle(TEvents::TEvPoisonPill::TPtr &ev, const TActorContext &ctx) { LOG_DEBUG_S(ctx, NKikimrServices::KEYVALUE, "KeyValue# " << TabletID() << " Handle TEvents::TEvPoisonPill"); - Y_UNUSED(ev); + Y_UNUSED(ev); Become(&TThis::StateBroken); ctx.Send(Tablet(), new TEvents::TEvPoisonPill); } diff --git a/ydb/core/keyvalue/keyvalue_simple_db_flat.cpp b/ydb/core/keyvalue/keyvalue_simple_db_flat.cpp index 0e2cc43559b..0f03ceac56a 100644 --- a/ydb/core/keyvalue/keyvalue_simple_db_flat.cpp +++ b/ydb/core/keyvalue/keyvalue_simple_db_flat.cpp @@ -13,14 +13,14 @@ TSimpleDbFlat::TSimpleDbFlat(NTable::TDatabase &db) {} void TSimpleDbFlat::Erase(const TString &key, const TActorContext &ctx) { - Y_UNUSED(ctx); + Y_UNUSED(ctx); const auto keyStr = NScheme::TSmallBoundedString::TInstance(key); const TRawTypeValue rawTypeValue = (TRawTypeValue)keyStr; Db.Update(TABLE_ID, NTable::ERowOp::Erase, {&rawTypeValue, 1}, { }); } void TSimpleDbFlat::Update(const TString &key, const TString &value, const TActorContext &ctx) { - Y_UNUSED(ctx); + Y_UNUSED(ctx); const auto keyStr = NScheme::TSmallBoundedString::TInstance(key); const TRawTypeValue rawTypeValue = (TRawTypeValue)keyStr; const auto valueStr = NScheme::TString::TInstance(value); diff --git a/ydb/core/keyvalue/keyvalue_state.cpp b/ydb/core/keyvalue/keyvalue_state.cpp index 6b31c463f83..3e1ea0605db 100644 --- a/ydb/core/keyvalue/keyvalue_state.cpp +++ b/ydb/core/keyvalue/keyvalue_state.cpp @@ -386,11 +386,11 @@ void TKeyValueState::Load(const TString &key, const TString& value) { TString arbitraryPart; TKeyHeader header; bool isOk = THelpers::ExtractKeyParts(key, arbitraryPart, header); - Y_VERIFY(isOk); + Y_VERIFY(isOk); switch (header.ItemType) { case EIT_UNKNOWN: { - Y_VERIFY(false, "Unexpected EIT_UNKNOWN key header."); + Y_VERIFY(false, "Unexpected EIT_UNKNOWN key header."); break; } case EIT_KEYVALUE_1: @@ -430,7 +430,7 @@ void TKeyValueState::Load(const TString &key, const TString& value) { break; } case EIT_TRASH: { - Y_VERIFY(value.size() == 0); + Y_VERIFY(value.size() == 0); Y_VERIFY(arbitraryPart.size() == sizeof(TTrashKeyArbitrary)); const TTrashKeyArbitrary *trashKey = (const TTrashKeyArbitrary *) arbitraryPart.data(); Trash.insert(trashKey->LogoBlobId); @@ -438,14 +438,14 @@ void TKeyValueState::Load(const TString &key, const TString& value) { break; } case EIT_COLLECT: { - Y_VERIFY(arbitraryPart.size() == 0); - Y_VERIFY(!CollectOperation.Get()); - Y_VERIFY(value.size() >= sizeof(TCollectOperationHeader)); + Y_VERIFY(arbitraryPart.size() == 0); + Y_VERIFY(!CollectOperation.Get()); + Y_VERIFY(value.size() >= sizeof(TCollectOperationHeader)); const TCollectOperationHeader *header = (const TCollectOperationHeader*)value.data(); - Y_VERIFY(header->DataHeader.ItemType == EIT_COLLECT); + Y_VERIFY(header->DataHeader.ItemType == EIT_COLLECT); ui64 totalSize = sizeof(TCollectOperationHeader) + sizeof(TLogoBlobID) * (header->KeepCount + header->DoNotKeepCount); - Y_VERIFY(value.size() == totalSize); + Y_VERIFY(value.size() == totalSize); TVector<TLogoBlobID> keep; TVector<TLogoBlobID> doNotKeep; keep.resize(header->KeepCount); @@ -463,18 +463,18 @@ void TKeyValueState::Load(const TString &key, const TString& value) { break; } case EIT_STATE: { - Y_VERIFY(!IsStatePresent); + Y_VERIFY(!IsStatePresent); IsStatePresent = true; - Y_VERIFY(arbitraryPart.size() == 0); - Y_VERIFY(value.size() >= sizeof(TKeyValueStoredStateData)); + Y_VERIFY(arbitraryPart.size() == 0); + Y_VERIFY(value.size() >= sizeof(TKeyValueStoredStateData)); const TKeyValueStoredStateData *data = (const TKeyValueStoredStateData *) value.data(); - Y_VERIFY(data->CheckChecksum()); - Y_VERIFY(data->DataHeader.ItemType == EIT_STATE); + Y_VERIFY(data->CheckChecksum()); + Y_VERIFY(data->DataHeader.ItemType == EIT_STATE); StoredState = *data; break; } default: { - Y_VERIFY(false, "Unexcpected header.ItemType# %" PRIu32, (ui32)header.ItemType); + Y_VERIFY(false, "Unexcpected header.ItemType# %" PRIu32, (ui32)header.ItemType); break; } } @@ -483,7 +483,7 @@ void TKeyValueState::Load(const TString &key, const TString& value) { void TKeyValueState::InitExecute(ui64 tabletId, TActorId keyValueActorId, ui32 executorGeneration, ISimpleDb &db, const TActorContext &ctx, const TTabletStorageInfo *info) { Y_UNUSED(info); - Y_VERIFY(IsEmptyDbStart || IsStatePresent); + Y_VERIFY(IsEmptyDbStart || IsStatePresent); TabletId = tabletId; KeyValueActorId = keyValueActorId; ExecutorGeneration = executorGeneration; @@ -741,12 +741,12 @@ void TKeyValueState::SendCutHistory(const TActorContext &ctx) { } void TKeyValueState::OnInitQueueEmpty(const TActorContext &ctx) { - Y_UNUSED(ctx); + Y_UNUSED(ctx); CountOnline(); } void TKeyValueState::OnStateWork(const TActorContext &ctx) { - Y_UNUSED(ctx); + Y_UNUSED(ctx); CountProcessingInitQueue(); } @@ -760,7 +760,7 @@ void TKeyValueState::Step() { NextLogoBlobCookie = 1; ++NextLogoBlobStep; } else { - Y_FAIL("Max step reached!"); + Y_FAIL("Max step reached!"); } } @@ -1702,7 +1702,7 @@ void TKeyValueState::OnRequestComplete(ui64 requestUid, ui64 generation, ui64 st if (StoredState.GetChannelGeneration() == generation) { auto it = InFlightForStep.find(step); - Y_VERIFY(it != InFlightForStep.end(), "Unexpected step# %" PRIu64, (ui64)step); + Y_VERIFY(it != InFlightForStep.end(), "Unexpected step# %" PRIu64, (ui64)step); it->second--; if (it->second == 0) { InFlightForStep.erase(it); @@ -2977,7 +2977,7 @@ void TKeyValueState::OnEvObtainLock(TEvKeyValue::TEvObtainLock::TPtr &ev, const } void TKeyValueState::OnEvIntermediate(TIntermediate &intermediate, const TActorContext &ctx) { - Y_UNUSED(ctx); + Y_UNUSED(ctx); CountLatencyBsOps(intermediate.Stat); intermediate.Stat.LocalBaseTxCreatedAt = TAppData::TimeProvider->Now(); } @@ -3212,7 +3212,7 @@ void TKeyValueState::VerifyEqualIndex(const TKeyValueState& state) const { Y_VERIFY(i2 == e2, "index length differs. Dump:\n%s\n%s\n", Dump().data(), state.Dump().data()); } -void TKeyValueState::RenderHTMLPage(IOutputStream &out) const { +void TKeyValueState::RenderHTMLPage(IOutputStream &out) const { HTML(out) { H2() {out << "KeyValue Tablet";} UL_CLASS("nav nav-tabs") { diff --git a/ydb/core/keyvalue/keyvalue_state.h b/ydb/core/keyvalue/keyvalue_state.h index f57a69d35d3..98411157c50 100644 --- a/ydb/core/keyvalue/keyvalue_state.h +++ b/ydb/core/keyvalue/keyvalue_state.h @@ -98,7 +98,7 @@ public: } else if (AddedKeysIterator != KeySet.AddedKeys.end()) { return *AddedKeysIterator; } else { - Y_FAIL("operator*() called on invalid iterator"); + Y_FAIL("operator*() called on invalid iterator"); } } @@ -145,7 +145,7 @@ public: } else if (AddedKeysIterator != KeySet.AddedKeys.end()) { ++AddedKeysIterator; } else { - Y_FAIL("operator++() called on invalid iterator"); + Y_FAIL("operator++() called on invalid iterator"); } } @@ -438,7 +438,7 @@ public: void OnEvRequest(TEvKeyValue::TEvRequest::TPtr &ev, const TActorContext &ctx, const TTabletStorageInfo *info); bool PrepareIntermediate(TEvKeyValue::TEvRequest::TPtr &ev, THolder<TIntermediate> &intermediate, TRequestType::EType &inOutRequestType, const TActorContext &ctx, const TTabletStorageInfo *info); - void RenderHTMLPage(IOutputStream &out) const; + void RenderHTMLPage(IOutputStream &out) const; void MonChannelStat(NJson::TJsonValue& out) const; bool CheckDeadline(const TActorContext &ctx, NKikimrClient::TKeyValueRequest &kvRequest, diff --git a/ydb/core/keyvalue/keyvalue_storage_request.cpp b/ydb/core/keyvalue/keyvalue_storage_request.cpp index e9032d2ed3d..149184a235b 100644 --- a/ydb/core/keyvalue/keyvalue_storage_request.cpp +++ b/ydb/core/keyvalue/keyvalue_storage_request.cpp @@ -218,11 +218,11 @@ public: } void Handle(TEvBlobStorage::TEvGetResult::TPtr &ev, const TActorContext &ctx) { - Y_VERIFY(!InFlightBatchByCookie.empty()); + Y_VERIFY(!InFlightBatchByCookie.empty()); // Find the corresponding request (as replies come in random order) auto foundIt = InFlightBatchByCookie.find(ev->Cookie); - Y_VERIFY(foundIt != InFlightBatchByCookie.end(), "Cookie# %" PRIu64 " not found!", ev->Cookie); + Y_VERIFY(foundIt != InFlightBatchByCookie.end(), "Cookie# %" PRIu64 " not found!", ev->Cookie); TInFlightBatch &request = foundIt->second; InFlightQueries -= request.ReadQueue.size(); @@ -274,7 +274,7 @@ public: return; } - Y_VERIFY(ev->Get()->ResponseSz == request.ReadQueue.size()); + Y_VERIFY(ev->Get()->ResponseSz == request.ReadQueue.size()); auto groupId = ev->Get()->GroupId; decltype(request.ReadQueue)::iterator it = request.ReadQueue.begin(); for (ui32 i = 0, num = ev->Get()->ResponseSz; i < num; ++i, ++it) { @@ -287,7 +287,7 @@ public: read.Value.resize(read.ValueSize); } Y_VERIFY(response.Buffer.size() == readItem.BlobSize); - Y_VERIFY(readItem.ValueOffset + readItem.BlobSize <= read.ValueSize); + Y_VERIFY(readItem.ValueOffset + readItem.BlobSize <= read.ValueSize); memcpy(const_cast<char *>(read.Value.data()) + readItem.ValueOffset, response.Buffer.data(), response.Buffer.size()); IntermediateResults->Stat.GroupReadBytes[std::make_pair(response.Id.Channel(), groupId)] += response.Buffer.size(); IntermediateResults->Stat.GroupReadIops[std::make_pair(response.Id.Channel(), groupId)] += 1; // FIXME: count distinct blobs? @@ -572,7 +572,7 @@ public: Y_VERIFY(group != Max<ui32>(), "Get Blob# %s is mapped to an invalid group (-1)!", readItem.LogoBlobId.ToString().c_str()); if (prevGroup != Max<ui32>()) { - Y_VERIFY(prevGroup == group); + Y_VERIFY(prevGroup == group); } else { prevGroup = group; } @@ -585,7 +585,7 @@ public: ++NextInFlightBatchCookie; InFlightBatchByCookie[cookie] = std::move(request); - Y_VERIFY(queryIdx == readQueryCount); + Y_VERIFY(queryIdx == readQueryCount); SendToBSProxy( ctx, prevGroup, new TEvBlobStorage::TEvGet(readQueries, readQueryCount, IntermediateResults->Deadline, diff --git a/ydb/core/keyvalue/keyvalue_ut.cpp b/ydb/core/keyvalue/keyvalue_ut.cpp index 4ae1fcf56a6..ffbf0483010 100644 --- a/ydb/core/keyvalue/keyvalue_ut.cpp +++ b/ydb/core/keyvalue/keyvalue_ut.cpp @@ -45,15 +45,15 @@ public: } bool operator()(TTestActorRuntimeBase& runtime, TAutoPtr<IEventHandle>& event) { - Y_UNUSED(runtime); - Y_UNUSED(event); + Y_UNUSED(runtime); + Y_UNUSED(event); return false; } }; } // anonymous namespace -Y_UNIT_TEST_SUITE(TKeyValueTest) { +Y_UNIT_TEST_SUITE(TKeyValueTest) { //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // SETUP @@ -74,7 +74,7 @@ struct TTestContext { } void Prepare(const TString &dispatchName, std::function<void(TTestActorRuntime&)> setup, bool &outActiveZone) { - Y_UNUSED(dispatchName); + Y_UNUSED(dispatchName); outActiveZone = false; Runtime.Reset(new TTestBasicRuntime); Runtime->SetScheduledLimit(100); @@ -130,7 +130,7 @@ void DoWithRetry(std::function<bool(void)> action, i32 retryCount = 2) { void CmdWrite(const TDeque<TString> &keys, const TDeque<TString> &values, const NKikimrClient::TKeyValueRequest::EStorageChannel storageChannel, const NKikimrClient::TKeyValueRequest::EPriority priority, TTestContext &tc) { - Y_VERIFY(keys.size() == values.size()); + Y_VERIFY(keys.size() == values.size()); TAutoPtr<IEventHandle> handle; TEvKeyValue::TEvResponse *result; THolder<TEvKeyValue::TEvRequest> request; @@ -174,8 +174,8 @@ void CmdWrite(const TString &key, const TString &value, void CmdRead(const TDeque<TString> &keys, const NKikimrClient::TKeyValueRequest::EPriority priority, const TDeque<TString> &expectedValues, const TDeque<bool> expectedNodatas, TTestContext &tc) { - Y_VERIFY(keys.size() == expectedValues.size()); - Y_VERIFY(expectedNodatas.size() == 0 || expectedNodatas.size() == keys.size()); + Y_VERIFY(keys.size() == expectedValues.size()); + Y_VERIFY(expectedNodatas.size() == 0 || expectedNodatas.size() == keys.size()); TAutoPtr<IEventHandle> handle; TEvKeyValue::TEvResponse *result; THolder<TEvKeyValue::TEvRequest> request; @@ -211,7 +211,7 @@ void CmdRead(const TDeque<TString> &keys, void CmdRename(const TDeque<TString> &oldKeys, const TDeque<TString> &newKeys, TTestContext &tc, bool expectOk = true) { - Y_VERIFY(oldKeys.size() == newKeys.size()); + Y_VERIFY(oldKeys.size() == newKeys.size()); TAutoPtr<IEventHandle> handle; TEvKeyValue::TEvResponse *result; THolder<TEvKeyValue::TEvRequest> request; @@ -1137,7 +1137,7 @@ Y_UNIT_TEST(TestWrite200KDeleteThenResponseErrorNewApi) { } */ -Y_UNIT_TEST(TestWriteReadWithRestartsThenResponseOk) { +Y_UNIT_TEST(TestWriteReadWithRestartsThenResponseOk) { TTestContext tc; RunTestWithReboots(tc.TabletIds, [&]() { return tc.InitialEventsFilter.Prepare(); @@ -1216,7 +1216,7 @@ Y_UNIT_TEST(TestWriteReadWithRestartsThenResponseOkNewApi) { } -Y_UNIT_TEST(TestInlineWriteReadWithRestartsThenResponseOk) { +Y_UNIT_TEST(TestInlineWriteReadWithRestartsThenResponseOk) { TTestContext tc; RunTestWithReboots(tc.TabletIds, [&]() { return tc.InitialEventsFilter.Prepare(); @@ -1424,7 +1424,7 @@ TString PrepareData(ui32 size, ui32 flavor) { } -Y_UNIT_TEST(TestWriteReadRangeLimitThenLimitWorks) { +Y_UNIT_TEST(TestWriteReadRangeLimitThenLimitWorks) { TTestContext tc; RunTestWithReboots(tc.TabletIds, [&]() { return tc.InitialEventsFilter.Prepare(); @@ -1606,7 +1606,7 @@ Y_UNIT_TEST(TestWriteReadRangeDataLimitThenLimitWorksNewApi) { } -Y_UNIT_TEST(TestInlineWriteReadRangeLimitThenLimitWorks) { +Y_UNIT_TEST(TestInlineWriteReadRangeLimitThenLimitWorks) { TTestContext tc; RunTestWithReboots(tc.TabletIds, [&]() { return tc.InitialEventsFilter.Prepare(); @@ -1660,7 +1660,7 @@ Y_UNIT_TEST(TestInlineWriteReadRangeLimitThenLimitWorksNewApi) { } -Y_UNIT_TEST(TestCopyRangeWorks) { +Y_UNIT_TEST(TestCopyRangeWorks) { TTestContext tc; RunTestWithReboots(tc.TabletIds, [&]() { return tc.InitialEventsFilter.Prepare(); @@ -1730,7 +1730,7 @@ Y_UNIT_TEST(TestCopyRangeWorksNewApi) { } -Y_UNIT_TEST(TestInlineCopyRangeWorks) { +Y_UNIT_TEST(TestInlineCopyRangeWorks) { TTestContext tc; RunTestWithReboots(tc.TabletIds, [&]() { return tc.InitialEventsFilter.Prepare(); @@ -1776,7 +1776,7 @@ Y_UNIT_TEST(TestInlineCopyRangeWorksNewApi) { } -Y_UNIT_TEST(TestConcatWorks) { +Y_UNIT_TEST(TestConcatWorks) { TTestContext tc; RunTestWithReboots(tc.TabletIds, [&]() { return tc.InitialEventsFilter.Prepare(); @@ -1826,7 +1826,7 @@ Y_UNIT_TEST(TestConcatWorksNewApi) { } -Y_UNIT_TEST(TestRenameWorks) { +Y_UNIT_TEST(TestRenameWorks) { TTestContext tc; RunTestWithReboots(tc.TabletIds, [&]() { return tc.InitialEventsFilter.Prepare(); @@ -1868,7 +1868,7 @@ Y_UNIT_TEST(TestRenameWorksewApi) { } -Y_UNIT_TEST(TestWriteToExtraChannelThenReadMixedChannelsReturnsOk) { +Y_UNIT_TEST(TestWriteToExtraChannelThenReadMixedChannelsReturnsOk) { TTestContext tc; RunTestWithReboots(tc.TabletIds, [&]() { return tc.InitialEventsFilter.Prepare(); @@ -1910,7 +1910,7 @@ Y_UNIT_TEST(TestWriteToExtraChannelThenReadMixedChannelsReturnsOkNewApi) { } -Y_UNIT_TEST(TestIncrementalKeySet) { +Y_UNIT_TEST(TestIncrementalKeySet) { // generate initial key set TSet<TString> keys; for (ui32 i = 0; i < 100; ++i) { @@ -1989,7 +1989,7 @@ Y_UNIT_TEST(TestIncrementalKeySet) { } } -Y_UNIT_TEST(TestGetStatusWorks) { +Y_UNIT_TEST(TestGetStatusWorks) { TTestContext tc; RunTestWithReboots(tc.TabletIds, [&]() { return tc.InitialEventsFilter.Prepare(); @@ -2014,7 +2014,7 @@ Y_UNIT_TEST(TestGetStatusWorksNewApi) { }); } -Y_UNIT_TEST(TestWriteReadWhileWriteWorks) { +Y_UNIT_TEST(TestWriteReadWhileWriteWorks) { TTestContext tc; RunTestWithReboots(tc.TabletIds, [&]() { return tc.InitialEventsFilter.Prepare(); @@ -2051,7 +2051,7 @@ Y_UNIT_TEST(TestWriteReadWhileWriteWorks) { }); } -Y_UNIT_TEST(TestSetExecutorFastLogPolicy) { +Y_UNIT_TEST(TestSetExecutorFastLogPolicy) { TTestContext tc; RunTestWithReboots(tc.TabletIds, [&]() { return tc.InitialEventsFilter.Prepare(); diff --git a/ydb/core/kqp/provider/yql_kikimr_datasink.cpp b/ydb/core/kqp/provider/yql_kikimr_datasink.cpp index 035d6b77012..6193152ef46 100644 --- a/ydb/core/kqp/provider/yql_kikimr_datasink.cpp +++ b/ydb/core/kqp/provider/yql_kikimr_datasink.cpp @@ -227,8 +227,8 @@ private: } TStatus HandleCommit(TCoCommit node, TExprContext& ctx) override { - Y_UNUSED(node); - Y_UNUSED(ctx); + Y_UNUSED(node); + Y_UNUSED(ctx); return TStatus::Ok; } @@ -256,7 +256,7 @@ private: } TStatus HandleKql(TCallable node, TExprContext& ctx) override { - Y_UNUSED(ctx); + Y_UNUSED(ctx); if (auto call = node.Maybe<TKiSelectRow>()) { auto cluster = call.Cast().Cluster().Value(); @@ -318,10 +318,10 @@ public: , CallableExecutionTransformer(CreateKiSinkCallableExecutionTransformer(gateway, sessionCtx, queryExecutor)) , PlanInfoTransformer(CreateKiSinkPlanInfoTransformer(queryExecutor)) { - Y_UNUSED(FunctionRegistry); - Y_UNUSED(Types); + Y_UNUSED(FunctionRegistry); + Y_UNUSED(Types); - Y_VERIFY_DEBUG(gateway); + Y_VERIFY_DEBUG(gateway); Y_VERIFY_DEBUG(sessionCtx); Y_VERIFY_DEBUG(queryExecutor); } diff --git a/ydb/core/kqp/provider/yql_kikimr_datasource.cpp b/ydb/core/kqp/provider/yql_kikimr_datasource.cpp index 65ef7eb932a..f133fac1055 100644 --- a/ydb/core/kqp/provider/yql_kikimr_datasource.cpp +++ b/ydb/core/kqp/provider/yql_kikimr_datasource.cpp @@ -39,14 +39,14 @@ private: } TStatus HandleLength(TExprBase node, TExprContext& ctx) override { - Y_UNUSED(node); - Y_UNUSED(ctx); + Y_UNUSED(node); + Y_UNUSED(ctx); return TStatus::Ok; } TStatus HandleConfigure(TExprBase node, TExprContext& ctx) override { - Y_UNUSED(node); - Y_UNUSED(ctx); + Y_UNUSED(node); + Y_UNUSED(ctx); return TStatus::Ok; } @@ -148,7 +148,7 @@ public: } NThreading::TFuture<void> DoGetAsyncFuture(const TExprNode& input) final { - Y_UNUSED(input); + Y_UNUSED(input); return AsyncFuture; } @@ -285,10 +285,10 @@ public: , CallableExecutionTransformer(CreateKiSourceCallableExecutionTransformer(gateway, sessionCtx)) { - Y_UNUSED(FunctionRegistry); - Y_UNUSED(Types); + Y_UNUSED(FunctionRegistry); + Y_UNUSED(Types); - Y_VERIFY_DEBUG(gateway); + Y_VERIFY_DEBUG(gateway); Y_VERIFY_DEBUG(sessionCtx); } @@ -578,7 +578,7 @@ public: } TString GetProviderPath(const TExprNode& node) override { - Y_UNUSED(node); + Y_UNUSED(node); return TString(KikimrProviderName); } diff --git a/ydb/core/kqp/provider/yql_kikimr_exec.cpp b/ydb/core/kqp/provider/yql_kikimr_exec.cpp index ad360fcaebe..1e56f6e905b 100644 --- a/ydb/core/kqp/provider/yql_kikimr_exec.cpp +++ b/ydb/core/kqp/provider/yql_kikimr_exec.cpp @@ -234,8 +234,8 @@ public: MakeFuture(TAsyncTransformCallback([resultNode](const TExprNode::TPtr& input, TExprNode::TPtr& output, TExprContext& ctx) { - Y_UNUSED(output); - Y_UNUSED(ctx); + Y_UNUSED(output); + Y_UNUSED(ctx); input->SetState(TExprNode::EState::ExecutionComplete); input->SetResult(TExprNode::TPtr(resultNode)); diff --git a/ydb/core/kqp/provider/yql_kikimr_gateway_ut.cpp b/ydb/core/kqp/provider/yql_kikimr_gateway_ut.cpp index 791a617c083..926ab64a9cb 100644 --- a/ydb/core/kqp/provider/yql_kikimr_gateway_ut.cpp +++ b/ydb/core/kqp/provider/yql_kikimr_gateway_ut.cpp @@ -307,26 +307,26 @@ void TestDropTableCommon(TIntrusivePtr<IKikimrGateway> gateway) { } // namespace -Y_UNIT_TEST_SUITE(KikimrIcGateway) { - Y_UNIT_TEST(TestListPath) { +Y_UNIT_TEST_SUITE(KikimrIcGateway) { + Y_UNIT_TEST(TestListPath) { TKikimrRunner kikimr(NKqp::TKikimrSettings().SetWithSampleTables(false)); CreateSampleTables(kikimr); TestListPathCommon(GetIcGateway(kikimr.GetTestServer())); } - Y_UNIT_TEST(TestLoadTableMetadata) { + Y_UNIT_TEST(TestLoadTableMetadata) { TKikimrRunner kikimr(NKqp::TKikimrSettings().SetWithSampleTables(false)); CreateSampleTables(kikimr); TestLoadTableMetadataCommon(GetIcGateway(kikimr.GetTestServer())); } - Y_UNIT_TEST(TestRunSimple) { + Y_UNIT_TEST(TestRunSimple) { TKikimrRunner kikimr(NKqp::TKikimrSettings().SetWithSampleTables(false)); CreateSampleTables(kikimr); TestRunSimpleCommon(GetIcGateway(kikimr.GetTestServer())); } - Y_UNIT_TEST(TestCreateTable) { + Y_UNIT_TEST(TestCreateTable) { TKikimrRunner kikimr(NKqp::TKikimrSettings().SetWithSampleTables(false)); CreateSampleTables(kikimr); TestCreateTableCommon(GetIcGateway(kikimr.GetTestServer()), kikimr.GetTestClient()); @@ -346,14 +346,14 @@ Y_UNIT_TEST_SUITE(KikimrIcGateway) { TTestIndexSettings{true}); } - Y_UNIT_TEST(TestCreateTableNoFolder) { + Y_UNIT_TEST(TestCreateTableNoFolder) { TKikimrRunner kikimr(NKqp::TKikimrSettings().SetWithSampleTables(false)); CreateSampleTables(kikimr); TestCreateTableCommon(GetIcGateway(kikimr.GetTestServer()), kikimr.GetTestClient(), false, Nothing(), false, true); } - Y_UNIT_TEST(TestCreateSameTable) { + Y_UNIT_TEST(TestCreateSameTable) { TKikimrRunner kikimr(NKqp::TKikimrSettings().SetWithSampleTables(false)); CreateSampleTables(kikimr); TestCreateTableCommon(GetIcGateway(kikimr.GetTestServer()), kikimr.GetTestClient()); @@ -366,7 +366,7 @@ Y_UNIT_TEST_SUITE(KikimrIcGateway) { TTestIndexSettings{false}); } - Y_UNIT_TEST(TestDropTable) { + Y_UNIT_TEST(TestDropTable) { TKikimrRunner kikimr(NKqp::TKikimrSettings().SetWithSampleTables(false)); CreateSampleTables(kikimr); TestDropTableCommon(GetIcGateway(kikimr.GetTestServer())); diff --git a/ydb/core/kqp/provider/yql_kikimr_provider_impl.h b/ydb/core/kqp/provider/yql_kikimr_provider_impl.h index e1aa3cda2b4..6ff3d27f524 100644 --- a/ydb/core/kqp/provider/yql_kikimr_provider_impl.h +++ b/ydb/core/kqp/provider/yql_kikimr_provider_impl.h @@ -62,19 +62,19 @@ public: : Ctx(ctx) {} Type GetKeyType() const { - Y_VERIFY_DEBUG(KeyType.Defined()); + Y_VERIFY_DEBUG(KeyType.Defined()); return *KeyType; } TString GetTablePath() const { - Y_VERIFY_DEBUG(KeyType.Defined()); - Y_VERIFY_DEBUG(KeyType == Type::Table || KeyType == Type::TableScheme); + Y_VERIFY_DEBUG(KeyType.Defined()); + Y_VERIFY_DEBUG(KeyType == Type::Table || KeyType == Type::TableScheme); return Target; } TString GetFolderPath() const { - Y_VERIFY_DEBUG(KeyType.Defined()); - Y_VERIFY_DEBUG(KeyType == Type::TableList); + Y_VERIFY_DEBUG(KeyType.Defined()); + Y_VERIFY_DEBUG(KeyType == Type::TableList); return Target; } diff --git a/ydb/core/kqp/provider/yql_kikimr_type_ann.cpp b/ydb/core/kqp/provider/yql_kikimr_type_ann.cpp index 692165204ae..7ac52b4fc02 100644 --- a/ydb/core/kqp/provider/yql_kikimr_type_ann.cpp +++ b/ydb/core/kqp/provider/yql_kikimr_type_ann.cpp @@ -206,8 +206,8 @@ private: } TStatus HandleLength(TExprBase node, TExprContext& ctx) override { - Y_UNUSED(node); - Y_UNUSED(ctx); + Y_UNUSED(node); + Y_UNUSED(ctx); return TStatus::Error; } diff --git a/ydb/core/mind/bscontroller/grouper_ut.cpp b/ydb/core/mind/bscontroller/grouper_ut.cpp index a119ff665ae..ce594b84f1d 100644 --- a/ydb/core/mind/bscontroller/grouper_ut.cpp +++ b/ydb/core/mind/bscontroller/grouper_ut.cpp @@ -16,7 +16,7 @@ enum ELevel { LevelDrive = 200 }; -Y_UNIT_TEST_SUITE(TBlobStorageControllerGrouperTest) { +Y_UNIT_TEST_SUITE(TBlobStorageControllerGrouperTest) { static void construct_group_and_assert_it_is_valid( TVector<NBsController::TCandidate> candidates, @@ -40,12 +40,12 @@ Y_UNIT_TEST_SUITE(TBlobStorageControllerGrouperTest) { UNIT_ASSERT(!isOk); } - Y_UNIT_TEST(TestGroupFromCandidatesEmpty) { + Y_UNIT_TEST(TestGroupFromCandidatesEmpty) { TVector<NBsController::TCandidate> candidates; construct_group_and_assert_it_is_NOT_valid(candidates, 4, 1); } - Y_UNIT_TEST(TestGroupFromCandidatesTrivial) { + Y_UNIT_TEST(TestGroupFromCandidatesTrivial) { ui32 nodeId = 0; ui32 pDiskId = 0; ui32 badness = 0; @@ -65,7 +65,7 @@ Y_UNIT_TEST_SUITE(TBlobStorageControllerGrouperTest) { construct_group_and_assert_it_is_valid(candidates, 4); } - Y_UNIT_TEST(TestGroupFromCandidatesHuge) { + Y_UNIT_TEST(TestGroupFromCandidatesHuge) { ui32 nodeId = 0; const ui32 vDiskSlotId = 1; @@ -126,7 +126,7 @@ Y_UNIT_TEST_SUITE(TBlobStorageControllerGrouperTest) { return candidates; } - Y_UNIT_TEST(when_one_server_per_rack_in_4_racks_then_can_construct_group_with_4_domains) { + Y_UNIT_TEST(when_one_server_per_rack_in_4_racks_then_can_construct_group_with_4_domains) { TVector<NBsController::TCandidate> candidates; for (ui32 rackIdx = 0; rackIdx < 4; ++rackIdx) { @@ -140,7 +140,7 @@ Y_UNIT_TEST_SUITE(TBlobStorageControllerGrouperTest) { construct_group_and_assert_it_is_NOT_valid(candidates, 4, 3); } - Y_UNIT_TEST(when_one_server_per_rack_in_4_racks_then_can_construct_group_with_4_domains_and_one_small_node) { + Y_UNIT_TEST(when_one_server_per_rack_in_4_racks_then_can_construct_group_with_4_domains_and_one_small_node) { const ui32 domainIdx = 1; const ui32 roomIdx = 0; diff --git a/ydb/core/mind/hive/hive_impl.cpp b/ydb/core/mind/hive/hive_impl.cpp index 58ca2ac3e43..0bcdfe597f5 100644 --- a/ydb/core/mind/hive/hive_impl.cpp +++ b/ydb/core/mind/hive/hive_impl.cpp @@ -298,7 +298,7 @@ void THive::Handle(TEvPrivate::TEvProcessPendingOperations::TPtr&) { void THive::Handle(TEvHive::TEvBootTablet::TPtr& ev) { TTabletId tabletId = ev->Get()->Record.GetTabletID(); TTabletInfo* tablet = FindTablet(tabletId); - Y_VERIFY(tablet != nullptr); + Y_VERIFY(tablet != nullptr); if (tablet->IsReadyToBoot()) { tablet->InitiateBoot(); } @@ -831,7 +831,7 @@ void THive::OnActivateExecutor(const TActorContext&) { HiveDomain = domainsInfo->GetHiveDomainUid(HiveUid); const TDomainsInfo::TDomain& domain = domainsInfo->GetDomain(HiveDomain); RootHiveId = domainsInfo->GetHive(domain.DefaultHiveUid); - Y_VERIFY(HiveUid != Max<ui32>() && HiveDomain != TDomainsInfo::BadDomainId); + Y_VERIFY(HiveUid != Max<ui32>() && HiveDomain != TDomainsInfo::BadDomainId); HiveId = TabletID(); HiveGeneration = Executor()->Generation(); RootDomainKey = TSubDomainKey(domain.SchemeRoot, 1); @@ -850,7 +850,7 @@ void THive::OnActivateExecutor(const TActorContext&) { } void THive::DefaultSignalTabletActive(const TActorContext& ctx) { - Y_UNUSED(ctx); + Y_UNUSED(ctx); } diff --git a/ydb/core/mind/hive/hive_ut.cpp b/ydb/core/mind/hive/hive_ut.cpp index 0383d49a123..9d5cd2d3868 100644 --- a/ydb/core/mind/hive/hive_ut.cpp +++ b/ydb/core/mind/hive/hive_ut.cpp @@ -26,7 +26,7 @@ #include <util/random/entropy.h> #include <util/stream/null.h> #include <util/string/printf.h> -#include <util/string/subst.h> +#include <util/string/subst.h> #include <util/system/sanitizers.h> #include <google/protobuf/text_format.h> @@ -374,7 +374,7 @@ namespace { } bool operator()(TTestActorRuntimeBase& runtime, TAutoPtr<IEventHandle>& event) { - Y_UNUSED(runtime); + Y_UNUSED(runtime); if (event->GetTypeRewrite() == TEvHive::EvCreateTablet) { IsDone = true; return true; @@ -454,7 +454,7 @@ void InitSchemeRoot(TTestBasicRuntime& runtime, const TActorId& sender) { // } } -Y_UNIT_TEST_SUITE(THiveTest) { +Y_UNIT_TEST_SUITE(THiveTest) { template <typename KeyType, typename ValueType> static double GetStDev(const THashMap<KeyType, ValueType>& values) { double sum = double(); @@ -794,7 +794,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { runtime.DispatchEvents(options); } - Y_UNIT_TEST(TestCreateTablet) { + Y_UNIT_TEST(TestCreateTablet) { TTestBasicRuntime runtime(1, false); Setup(runtime, true); const ui64 hiveTablet = MakeDefaultHiveID(0); @@ -1639,7 +1639,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { }); } - Y_UNIT_TEST(TestCreateAndDeleteTabletWithStoragePoolsReboots) { + Y_UNIT_TEST(TestCreateAndDeleteTabletWithStoragePoolsReboots) { const ui64 hiveTablet = MakeDefaultHiveID(0); const ui64 bsControllerTablet = MakeBSControllerID(0); const ui64 testerTablet = MakeDefaultHiveID(1); @@ -1681,7 +1681,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { }); } - Y_UNIT_TEST(TestCreateAndDeleteTabletWithStoragePools) { + Y_UNIT_TEST(TestCreateAndDeleteTabletWithStoragePools) { TTestBasicRuntime runtime(1, false); Setup(runtime); @@ -1882,7 +1882,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { } } - Y_UNIT_TEST(TestDeleteTablet) { + Y_UNIT_TEST(TestDeleteTablet) { TTestBasicRuntime runtime(1, false); Setup(runtime, true); TActorId sender = runtime.AllocateEdgeActor(); @@ -1999,7 +1999,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { WaitForEvServerDisconnected(runtime); } - Y_UNIT_TEST(PipeAlivenessOfDeadTablet) { + Y_UNIT_TEST(PipeAlivenessOfDeadTablet) { TTestBasicRuntime runtime(1, false); Setup(runtime, true); TActorId sender = runtime.AllocateEdgeActor(); @@ -2024,7 +2024,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { UNIT_ASSERT(connectResult->Dead == true); } - Y_UNIT_TEST(TestCreateTabletBeforeLocal) { + Y_UNIT_TEST(TestCreateTabletBeforeLocal) { TTestBasicRuntime runtime(1, false); Setup(runtime, false); TActorId sender = runtime.AllocateEdgeActor(); @@ -2066,7 +2066,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { MakeSureTabletIsUp(runtime, tabletId, 0); } - Y_UNIT_TEST(TestReCreateTablet) { + Y_UNIT_TEST(TestReCreateTablet) { TTestBasicRuntime runtime; Setup(runtime, true); TActorId sender = runtime.AllocateEdgeActor(); @@ -2105,7 +2105,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { } } - Y_UNIT_TEST(TestReCreateTabletError) { + Y_UNIT_TEST(TestReCreateTabletError) { TTestBasicRuntime runtime; Setup(runtime, true); TActorId sender = runtime.AllocateEdgeActor(); @@ -2130,7 +2130,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { } } - Y_UNIT_TEST(TestCreateTabletReboots) { + Y_UNIT_TEST(TestCreateTabletReboots) { const ui64 hiveTablet = MakeDefaultHiveID(0); const ui64 bsControllerTablet = MakeBSControllerID(0); const ui64 testerTablet = MakeDefaultHiveID(1); @@ -2185,7 +2185,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { }); } - Y_UNIT_TEST(TestLocalDisconnect) { + Y_UNIT_TEST(TestLocalDisconnect) { TTestBasicRuntime runtime(1, false); Setup(runtime, true); TVector<ui64> tabletIds; @@ -2204,7 +2204,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { MakeSureTabletIsUp(runtime, tabletId, nodeIndex); } - Y_UNIT_TEST(TestNodeDisconnect) { + Y_UNIT_TEST(TestNodeDisconnect) { TTestBasicRuntime runtime(1, false); Setup(runtime, true); TVector<ui64> tabletIds; @@ -2239,7 +2239,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { WaitForTabletIsUp(runtime, tabletId, 0, &pipeConfig); } - Y_UNIT_TEST(TestLocalReplacement) { + Y_UNIT_TEST(TestLocalReplacement) { TTestBasicRuntime runtime(2, false); Setup(runtime, true); TVector<ui64> tabletIds; @@ -2317,7 +2317,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { UNIT_ASSERT_VALUES_EQUAL(tabletInfo2.GetGeneration(), tabletInfo1.GetGeneration()); } - Y_UNIT_TEST(TestLimitedNodeList) { + Y_UNIT_TEST(TestLimitedNodeList) { TTestBasicRuntime runtime(3, false); Setup(runtime, true); TVector<ui64> tabletIds; @@ -2340,7 +2340,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { MakeSureTabletIsUp(runtime, tabletId, 1); } - Y_UNIT_TEST(TestCreateTabletAndReassignGroups) { + Y_UNIT_TEST(TestCreateTabletAndReassignGroups) { TTestBasicRuntime runtime(1, false); Setup(runtime, true); const ui64 hiveTablet = MakeDefaultHiveID(0); @@ -2385,7 +2385,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { MakeSureTheTabletIsDeleted(runtime, hiveTablet, tabletId); } - Y_UNIT_TEST(TestCreateTabletAndReassignGroups3) { + Y_UNIT_TEST(TestCreateTabletAndReassignGroups3) { TTestBasicRuntime runtime(1, false); Setup(runtime, true, 3); const ui64 hiveTablet = MakeDefaultHiveID(0); @@ -2441,7 +2441,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { MakeSureTabletIsUp(runtime, tabletId, 0); } - Y_UNIT_TEST(TestReassignGroupsWithRecreateTablet) { + Y_UNIT_TEST(TestReassignGroupsWithRecreateTablet) { TTestBasicRuntime runtime(1, false); Setup(runtime, true, 3); TActorId sender = runtime.AllocateEdgeActor(); @@ -2498,7 +2498,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { } } - Y_UNIT_TEST(TestCreateTabletAndReassignGroupsWithReboots) { + Y_UNIT_TEST(TestCreateTabletAndReassignGroupsWithReboots) { const ui64 hiveTablet = MakeDefaultHiveID(0); const ui64 bsControllerTablet = MakeBSControllerID(0); const ui64 testerTablet = MakeDefaultHiveID(1); @@ -2557,7 +2557,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { }); } -// Y_UNIT_TEST(TestCreateTabletAndChangeProfiles) { +// Y_UNIT_TEST(TestCreateTabletAndChangeProfiles) { // TTestBasicRuntime runtime(1, false); // Setup(runtime, true); // TActorId sender = runtime.AllocateEdgeActor(); @@ -2589,7 +2589,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { // FIXME: Hive does not pass this test. // Commented to remove noise from the unit-test logs /* - Y_UNIT_TEST(topTablet) { + Y_UNIT_TEST(topTablet) { TTestBasicRuntime runtime(1, false); Setup(runtime, true); TActorId sender = runtime.AllocateEdgeActor(); @@ -2609,7 +2609,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { // FIXME: Hive does not pass this test. // Commented to remove noise from the unit-test logs /* - Y_UNIT_TEST(TestStopAndRestartTablet) { + Y_UNIT_TEST(TestStopAndRestartTablet) { TTestBasicRuntime runtime(1, false); Setup(runtime, true); TActorId sender = runtime.AllocateEdgeActor(); @@ -2633,7 +2633,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { */ /* - Y_UNIT_TEST(TestFailureNotification) { + Y_UNIT_TEST(TestFailureNotification) { TTestBasicRuntime runtime(3, false); Setup(runtime, true); TVector<ui64> tabletIds; @@ -2847,7 +2847,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { } } - Y_UNIT_TEST(TestStartTabletTwiceInARow) { + Y_UNIT_TEST(TestStartTabletTwiceInARow) { TTestBasicRuntime runtime(1, false); Setup(runtime, true); const ui64 hiveTablet = MakeDefaultHiveID(0); @@ -2873,7 +2873,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { Y_UNUSED(tabletId); } - Y_UNIT_TEST(TestHiveBalancer) { + Y_UNIT_TEST(TestHiveBalancer) { static const int NUM_NODES = 3; static const int NUM_TABLETS = NUM_NODES * 3; TTestBasicRuntime runtime(NUM_NODES, false); @@ -3373,7 +3373,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { } } - Y_UNIT_TEST(TestRestartTablets) { + Y_UNIT_TEST(TestRestartTablets) { TTestBasicRuntime runtime(3, false); Setup(runtime, true); TVector<ui64> tabletIds; @@ -3844,7 +3844,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { } } - Y_UNIT_TEST(TestCreateExternalTablet) { + Y_UNIT_TEST(TestCreateExternalTablet) { TTestBasicRuntime runtime(1, false); Setup(runtime, true); const ui64 hiveTablet = MakeDefaultHiveID(0); @@ -3858,7 +3858,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { MakeSureTabletIsDown(runtime, tabletId, 0); } - Y_UNIT_TEST(TestCreateTabletChangeToExternal) { + Y_UNIT_TEST(TestCreateTabletChangeToExternal) { TTestBasicRuntime runtime(1, false); Setup(runtime, true); const ui64 hiveTablet = MakeDefaultHiveID(0); @@ -3881,7 +3881,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { runtime.SendToPipe(hiveTablet, senderB, new TEvHive::TEvGetTabletStorageInfo(tabletId), nodeIndex, GetPipeConfigWithRetries()); } - Y_UNIT_TEST(TestGetStorageInfo) { + Y_UNIT_TEST(TestGetStorageInfo) { TTestBasicRuntime runtime(1, false); Setup(runtime, true); const ui64 hiveTablet = MakeDefaultHiveID(0); @@ -3901,7 +3901,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { UNIT_ASSERT_VALUES_EQUAL(getTabletStorageResult->Record.GetTabletID(), tabletId); } - Y_UNIT_TEST(TestGetStorageInfoDeleteTabletBeforeAssigned) { + Y_UNIT_TEST(TestGetStorageInfoDeleteTabletBeforeAssigned) { TTestBasicRuntime runtime(1, false); Setup(runtime, true); const ui64 hiveTablet = MakeDefaultHiveID(0); @@ -3978,7 +3978,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { UNIT_ASSERT_VALUES_EQUAL(result->Record.GetTabletID(), tabletId); } - Y_UNIT_TEST(TestLockTabletExecution) { + Y_UNIT_TEST(TestLockTabletExecution) { TTestBasicRuntime runtime(2, false); Setup(runtime, false); CreateLocal(runtime, 0); // only the 1st node has local running @@ -4002,7 +4002,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { WaitForTabletIsUp(runtime, tabletId, 0); } - Y_UNIT_TEST(TestLockTabletExecutionBadOwner) { + Y_UNIT_TEST(TestLockTabletExecutionBadOwner) { TTestBasicRuntime runtime(2, false); Setup(runtime, false); CreateLocal(runtime, 0); // only the 1st node has local running @@ -4021,7 +4021,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { MakeSureTabletIsUp(runtime, tabletId, 0); } - Y_UNIT_TEST(TestLockTabletExecutionTimeout) { + Y_UNIT_TEST(TestLockTabletExecutionTimeout) { TTestBasicRuntime runtime(2, false); Setup(runtime, false); CreateLocal(runtime, 0); // only the 1st node has local running @@ -4050,7 +4050,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { VerifyLockTabletExecutionLost(runtime, tabletId, owner); } - Y_UNIT_TEST(TestLockTabletExecutionRebootTimeout) { + Y_UNIT_TEST(TestLockTabletExecutionRebootTimeout) { TTestBasicRuntime runtime(2, false); Setup(runtime, false); CreateLocal(runtime, 0); // only the 1st node has local running @@ -4079,7 +4079,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { VerifyLockTabletExecutionLost(runtime, tabletId, owner); } - Y_UNIT_TEST(TestLockTabletExecutionDelete) { + Y_UNIT_TEST(TestLockTabletExecutionDelete) { TTestBasicRuntime runtime(2, false); Setup(runtime, false); CreateLocal(runtime, 0); // only the 1st node has local running @@ -4183,7 +4183,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { UNIT_ASSERT_C(!res, "Unexpected successful tablet connection"); } - Y_UNIT_TEST(TestLockTabletExecutionReconnect) { + Y_UNIT_TEST(TestLockTabletExecutionReconnect) { TTestBasicRuntime runtime(2, false); Setup(runtime, false); CreateLocal(runtime, 0); // only the 1st node has local running @@ -4212,7 +4212,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { MakeSureTabletStaysDown(runtime, tabletId, TDuration::MilliSeconds(1000)); } - Y_UNIT_TEST(TestLockTabletExecutionRebootReconnect) { + Y_UNIT_TEST(TestLockTabletExecutionRebootReconnect) { TTestBasicRuntime runtime(2, false); Setup(runtime, false); CreateLocal(runtime, 0); // only the 1st node has local running @@ -4238,7 +4238,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { SendLockTabletExecution(runtime, hiveTablet, tabletId, 1, NKikimrProto::OK, owner, 40000, true); } - Y_UNIT_TEST(TestLockTabletExecutionReconnectExpire) { + Y_UNIT_TEST(TestLockTabletExecutionReconnectExpire) { TTestBasicRuntime runtime(2, false); Setup(runtime, false); CreateLocal(runtime, 0); // only the 1st node has local running @@ -4287,7 +4287,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { UNIT_ASSERT_VALUES_EQUAL(result->Record.GetStatus(), expectedStatus); } - Y_UNIT_TEST(TestLockTabletExecutionBadUnlock) { + Y_UNIT_TEST(TestLockTabletExecutionBadUnlock) { TTestBasicRuntime runtime(2, false); Setup(runtime, false); CreateLocal(runtime, 0); // only the 1st node has local running @@ -4308,7 +4308,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { MakeSureTabletIsDown(runtime, tabletId, 0); } - Y_UNIT_TEST(TestLockTabletExecutionGoodUnlock) { + Y_UNIT_TEST(TestLockTabletExecutionGoodUnlock) { TTestBasicRuntime runtime(2, false); Setup(runtime, false); CreateLocal(runtime, 0); // only the 1st node has local running @@ -4333,7 +4333,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { VerifyLockTabletExecutionLost(runtime, tabletId, owner); } - Y_UNIT_TEST(TestLockTabletExecutionStealLock) { + Y_UNIT_TEST(TestLockTabletExecutionStealLock) { TTestBasicRuntime runtime(2, false); Setup(runtime, false); CreateLocal(runtime, 0); // only the 1st node has local running @@ -4358,7 +4358,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { VerifyLockTabletExecutionLost(runtime, tabletId, owner); } - Y_UNIT_TEST(TestExternalBoot) { + Y_UNIT_TEST(TestExternalBoot) { TTestBasicRuntime runtime(1, false); Setup(runtime, true); CreateLocal(runtime, 0); // only the 1st node has local running diff --git a/ydb/core/mind/hive/monitoring.cpp b/ydb/core/mind/hive/monitoring.cpp index 7e9a83b354e..4e3410865cb 100644 --- a/ydb/core/mind/hive/monitoring.cpp +++ b/ydb/core/mind/hive/monitoring.cpp @@ -88,10 +88,10 @@ public: } void Complete(const TActorContext& ctx) override { - Y_UNUSED(ctx); + Y_UNUSED(ctx); } - void RenderHTMLPage(IOutputStream &out) { + void RenderHTMLPage(IOutputStream &out) { HTML(out) { UL_CLASS("nav nav-tabs") { LI_CLASS("active") { @@ -206,7 +206,7 @@ public: if (params.contains("sort")) { Sort = params.Get("sort"); } - Y_UNUSED(txc); + Y_UNUSED(txc); TStringStream str; RenderHTMLPage(str); ctx.Send(Source, new NMon::TEvRemoteHttpInfoRes(str.Str())); @@ -214,7 +214,7 @@ public: } void Complete(const TActorContext& ctx) override { - Y_UNUSED(ctx); + Y_UNUSED(ctx); } void RenderHTMLPage(IOutputStream &out) { @@ -878,7 +878,7 @@ public: } } - void RenderHTMLPage(IOutputStream& out, const TActorContext&/* ctx*/) { + void RenderHTMLPage(IOutputStream& out, const TActorContext&/* ctx*/) { out << "<head></head><body>"; out << "<script>$('.container > h2').html('Settings');</script>"; out << "<div class='form-group'>"; @@ -1046,7 +1046,7 @@ public: TTxType GetTxType() const override { return NHive::TXTYPE_MON_LANDING; } bool Execute(TTransactionContext &txc, const TActorContext& ctx) override { - Y_UNUSED(txc); + Y_UNUSED(txc); TStringStream str; RenderHTMLPage(str); ctx.Send(Source, new NMon::TEvRemoteHttpInfoRes(str.Str())); @@ -1054,7 +1054,7 @@ public: } void Complete(const TActorContext& ctx) override { - Y_UNUSED(ctx); + Y_UNUSED(ctx); } static TString GetTabletType(TTabletTypes::EType type) { @@ -1099,7 +1099,7 @@ public: } } - void RenderHTMLPage(IOutputStream &out) { + void RenderHTMLPage(IOutputStream &out) { ui64 nodes = 0; ui64 tablets = 0; ui64 runningTablets = 0; @@ -1732,7 +1732,7 @@ public: TTxType GetTxType() const override { return NHive::TXTYPE_MON_LANDING_DATA; } bool Execute(TTransactionContext &txc, const TActorContext& ctx) override { - Y_UNUSED(txc); + Y_UNUSED(txc); TStringStream str; RenderJSONPage(str); ctx.Send(Source, new NMon::TEvRemoteJsonInfoRes(str.Str())); @@ -1740,10 +1740,10 @@ public: } void Complete(const TActorContext& ctx) override { - Y_UNUSED(ctx); + Y_UNUSED(ctx); } - void RenderJSONPage(IOutputStream &out) { + void RenderJSONPage(IOutputStream &out) { ui64 nodes = 0; ui64 tablets = 0; ui64 runningTablets = 0; diff --git a/ydb/core/mind/local.cpp b/ydb/core/mind/local.cpp index 09fc15f76dd..f4de6081c6b 100644 --- a/ydb/core/mind/local.cpp +++ b/ydb/core/mind/local.cpp @@ -20,7 +20,7 @@ #include <unordered_set> template <> -void Out<std::pair<ui64, ui32>>(IOutputStream& out, const std::pair<ui64, ui32>& p) { +void Out<std::pair<ui64, ui32>>(IOutputStream& out, const std::pair<ui64, ui32>& p) { out << '(' << p.first << ',' << p.second << ')'; } @@ -170,7 +170,7 @@ class TLocalNodeRegistrar : public TActorBootstrapped<TLocalNodeRegistrar> { void TryToRegister(const TActorContext &ctx) { LOG_DEBUG(ctx, NKikimrServices::LOCAL, "TLocalNodeRegistrar::TryToRegister"); - Y_VERIFY_DEBUG(!HivePipeClient); + Y_VERIFY_DEBUG(!HivePipeClient); // pipe client is in use for convenience, real info update come from EvPing NTabletPipe::TClientConfig pipeConfig; @@ -311,7 +311,7 @@ class TLocalNodeRegistrar : public TActorBootstrapped<TLocalNodeRegistrar> { LOG_DEBUG(ctx, NKikimrServices::LOCAL, "TLocalNodeRegistrar::Handle TEvLocal::TEvPing"); const TActorId &sender = ev->Sender; const NKikimrLocal::TEvPing &record = ev->Get()->Record; - Y_VERIFY(HiveId == record.GetHiveId()); + Y_VERIFY(HiveId == record.GetHiveId()); const ui32 hiveGen = record.GetHiveGeneration(); if (hiveGen < HiveGeneration) { @@ -470,7 +470,7 @@ class TLocalNodeRegistrar : public TActorBootstrapped<TLocalNodeRegistrar> { void Handle(TEvLocal::TEvStopTablet::TPtr &ev, const TActorContext &ctx) { const NKikimrLocal::TEvStopTablet &record = ev->Get()->Record; - Y_VERIFY(record.HasTabletId()); + Y_VERIFY(record.HasTabletId()); TTabletId tabletId(record.GetTabletId(), record.GetFollowerId()); LOG_DEBUG_S(ctx, NKikimrServices::LOCAL, "TLocalNodeRegistrar: Handle TEvStopTablet TabletId:" << tabletId); diff --git a/ydb/core/mind/node_broker_ut.cpp b/ydb/core/mind/node_broker_ut.cpp index 0d9498ddcdd..d186e97e435 100644 --- a/ydb/core/mind/node_broker_ut.cpp +++ b/ydb/core/mind/node_broker_ut.cpp @@ -642,8 +642,8 @@ void RestartNodeBroker(TTestActorRuntime &runtime) } // anonymous namespace -Y_UNIT_TEST_SUITE(TNodeBrokerTest) { - Y_UNIT_TEST(BasicFunctionality) +Y_UNIT_TEST_SUITE(TNodeBrokerTest) { + Y_UNIT_TEST(BasicFunctionality) { TTestBasicRuntime runtime(8, false); Setup(runtime, 4); @@ -1076,8 +1076,8 @@ Y_UNIT_TEST_SUITE(TNodeBrokerTest) { } } -Y_UNIT_TEST_SUITE(TDynamicNameserverTest) { - Y_UNIT_TEST(BasicFunctionality) +Y_UNIT_TEST_SUITE(TDynamicNameserverTest) { + Y_UNIT_TEST(BasicFunctionality) { TTestBasicRuntime runtime(8, false); Setup(runtime); diff --git a/ydb/core/mind/tenant_ut_broker.cpp b/ydb/core/mind/tenant_ut_broker.cpp index 4c124b3d83b..77d0d4e348c 100644 --- a/ydb/core/mind/tenant_ut_broker.cpp +++ b/ydb/core/mind/tenant_ut_broker.cpp @@ -538,8 +538,8 @@ void RestartTenantSlotBroker(TTenantTestRuntime &runtime) } // anonymous namespace -Y_UNIT_TEST_SUITE(TTenantSlotBrokerTests) { - Y_UNIT_TEST(TestAllocateExactSlots) { +Y_UNIT_TEST_SUITE(TTenantSlotBrokerTests) { + Y_UNIT_TEST(TestAllocateExactSlots) { TTenantTestRuntime runtime(TenantTestConfig3DC()); CheckAlterTenant(runtime, TENANT1_1_NAME, SLOT1_TYPE, DATA_CENTER1, 3, 3, 0, @@ -553,7 +553,7 @@ Y_UNIT_TEST_SUITE(TTenantSlotBrokerTests) { SLOT3_TYPE, DATA_CENTER3, 1, 0, 0); } - Y_UNIT_TEST(TestAllocateExactSlotsMissing) { + Y_UNIT_TEST(TestAllocateExactSlotsMissing) { TTenantTestRuntime runtime(TenantTestConfig3DC()); CheckAlterTenant(runtime, TENANT1_1_NAME, SLOT1_TYPE, DATA_CENTER1, 4, 3, 1, @@ -567,7 +567,7 @@ Y_UNIT_TEST_SUITE(TTenantSlotBrokerTests) { SLOT3_TYPE, DATA_CENTER3, 6, 0, 3); } - Y_UNIT_TEST(TestAllocateTypedSlots) { + Y_UNIT_TEST(TestAllocateTypedSlots) { TTenantTestRuntime runtime(TenantTestConfig3DC()); CheckAlterTenant(runtime, TENANT1_1_NAME, SLOT1_TYPE, ANY_DATA_CENTER, 3, 3, 0, @@ -581,7 +581,7 @@ Y_UNIT_TEST_SUITE(TTenantSlotBrokerTests) { SLOT3_TYPE, ANY_DATA_CENTER, 1, 0, 0); } - Y_UNIT_TEST(TestAllocateTypedSlotsAll) { + Y_UNIT_TEST(TestAllocateTypedSlotsAll) { TTenantTestRuntime runtime(TenantTestConfig3DC()); CheckAlterTenant(runtime, TENANT1_1_NAME, SLOT1_TYPE, ANY_DATA_CENTER, 9, 9, 0); @@ -591,7 +591,7 @@ Y_UNIT_TEST_SUITE(TTenantSlotBrokerTests) { SLOT1_TYPE, ANY_DATA_CENTER, 9, 0, 0); } - Y_UNIT_TEST(TestAllocateTypedSlotsMissing) { + Y_UNIT_TEST(TestAllocateTypedSlotsMissing) { TTenantTestRuntime runtime(TenantTestConfig3DC()); CheckAlterTenant(runtime, TENANT1_1_NAME, SLOT1_TYPE, ANY_DATA_CENTER, 10, 9, 1); @@ -601,7 +601,7 @@ Y_UNIT_TEST_SUITE(TTenantSlotBrokerTests) { SLOT1_TYPE, ANY_DATA_CENTER, 10, 0, 1); } - Y_UNIT_TEST(TestAllocateLocatedSlots) { + Y_UNIT_TEST(TestAllocateLocatedSlots) { TTenantTestRuntime runtime(TenantTestConfig3DC()); CheckAlterTenant(runtime, TENANT1_1_NAME, ANY_SLOT_TYPE, DATA_CENTER1, 3, 3, 0, @@ -616,7 +616,7 @@ Y_UNIT_TEST_SUITE(TTenantSlotBrokerTests) { ANY_SLOT_TYPE, DATA_CENTER3, 3, 0, 0); } - Y_UNIT_TEST(TestAllocateLocatedSlotsAll) { + Y_UNIT_TEST(TestAllocateLocatedSlotsAll) { TTenantTestRuntime runtime(TenantTestConfig3DC()); CheckAlterTenant(runtime, TENANT1_1_NAME, ANY_SLOT_TYPE, DATA_CENTER1, 9, 9, 0); @@ -626,7 +626,7 @@ Y_UNIT_TEST_SUITE(TTenantSlotBrokerTests) { ANY_SLOT_TYPE, DATA_CENTER1, 9, 0, 0); } - Y_UNIT_TEST(TestAllocateLocatedSlotsMissing) { + Y_UNIT_TEST(TestAllocateLocatedSlotsMissing) { TTenantTestRuntime runtime(TenantTestConfig3DC()); CheckAlterTenant(runtime, TENANT1_1_NAME, ANY_SLOT_TYPE, DATA_CENTER1, 10, 9, 1); @@ -636,7 +636,7 @@ Y_UNIT_TEST_SUITE(TTenantSlotBrokerTests) { ANY_SLOT_TYPE, DATA_CENTER1, 10, 0, 1); } - Y_UNIT_TEST(TestAlterMoreStrictAndKeep) { + Y_UNIT_TEST(TestAlterMoreStrictAndKeep) { TTenantTestRuntime runtime(TenantTestConfig3DC()); CheckAlterTenant(runtime, TENANT1_1_NAME, SLOT1_TYPE, DATA_CENTER1, 3, 3, 0); @@ -650,7 +650,7 @@ Y_UNIT_TEST_SUITE(TTenantSlotBrokerTests) { ANY_SLOT_TYPE, ANY_DATA_CENTER, 1, 0, 0); } - Y_UNIT_TEST(TestAlterLessStrictDataCenterAndKeep) { + Y_UNIT_TEST(TestAlterLessStrictDataCenterAndKeep) { TTenantTestRuntime runtime(TenantTestConfig3DC()); CheckAlterTenant(runtime, TENANT1_1_NAME, SLOT1_TYPE, ANY_DATA_CENTER, 3, 3, 0); @@ -665,7 +665,7 @@ Y_UNIT_TEST_SUITE(TTenantSlotBrokerTests) { SLOT1_TYPE, DATA_CENTER3, 1, 0, 0); } - Y_UNIT_TEST(TestAlterLessStrictTypeAndKeep) { + Y_UNIT_TEST(TestAlterLessStrictTypeAndKeep) { TTenantTestRuntime runtime(TenantTestConfig3DC()); CheckAlterTenant(runtime, TENANT1_1_NAME, ANY_SLOT_TYPE, DATA_CENTER1, 3, 3, 0); @@ -680,7 +680,7 @@ Y_UNIT_TEST_SUITE(TTenantSlotBrokerTests) { SLOT3_TYPE, DATA_CENTER1, 1, 0, 0); } - Y_UNIT_TEST(TestAlterLessStrictTypeAndDataCenterAndKeep) { + Y_UNIT_TEST(TestAlterLessStrictTypeAndDataCenterAndKeep) { TTenantTestRuntime runtime(TenantTestConfig3DC()); CheckAlterTenant(runtime, TENANT1_1_NAME, ANY_SLOT_TYPE, ANY_DATA_CENTER, 9, 9, 0); @@ -701,7 +701,7 @@ Y_UNIT_TEST_SUITE(TTenantSlotBrokerTests) { SLOT3_TYPE, DATA_CENTER3, 1, 0, 0); } - Y_UNIT_TEST(TestAlterAndDontKeep) { + Y_UNIT_TEST(TestAlterAndDontKeep) { TTenantTestRuntime runtime(TenantTestConfig3DC()); CheckAlterTenant(runtime, TENANT1_1_NAME, SLOT1_TYPE, DATA_CENTER1, 3, 3, 0); @@ -723,7 +723,7 @@ Y_UNIT_TEST_SUITE(TTenantSlotBrokerTests) { SLOT2_TYPE, DATA_CENTER2, 1, 0, 0); } - Y_UNIT_TEST(TestAlterIncrease) { + Y_UNIT_TEST(TestAlterIncrease) { TTenantTestRuntime runtime(TenantTestConfig3DC()); CheckAlterTenant(runtime, TENANT1_1_NAME, SLOT1_TYPE, DATA_CENTER1, 1, 1, 0); @@ -741,7 +741,7 @@ Y_UNIT_TEST_SUITE(TTenantSlotBrokerTests) { SLOT2_TYPE, DATA_CENTER1, 1, 0, 0); } - Y_UNIT_TEST(TestAlterDecrease) { + Y_UNIT_TEST(TestAlterDecrease) { TTenantTestRuntime runtime(TenantTestConfig3DC()); CheckAlterTenant(runtime, TENANT1_1_NAME, SLOT1_TYPE, DATA_CENTER1, 3, 3, 0); @@ -759,7 +759,7 @@ Y_UNIT_TEST_SUITE(TTenantSlotBrokerTests) { SLOT2_TYPE, DATA_CENTER1, 1, 0, 0); } - Y_UNIT_TEST(TestAlterRemove) { + Y_UNIT_TEST(TestAlterRemove) { TTenantTestRuntime runtime(TenantTestConfig3DC()); CheckAlterTenant(runtime, TENANT1_1_NAME, SLOT1_TYPE, DATA_CENTER1, 3, 3, 0); @@ -780,7 +780,7 @@ Y_UNIT_TEST_SUITE(TTenantSlotBrokerTests) { SLOT2_TYPE, DATA_CENTER1, 3, 0, 0); } - Y_UNIT_TEST(TestMoveSlotToAnotherTenant) { + Y_UNIT_TEST(TestMoveSlotToAnotherTenant) { TTenantTestRuntime runtime(TenantTestConfig3DC()); CheckAlterTenant(runtime, TENANT1_1_NAME, SLOT1_TYPE, DATA_CENTER1, 2, 2, 0); @@ -804,7 +804,7 @@ Y_UNIT_TEST_SUITE(TTenantSlotBrokerTests) { SLOT1_TYPE, DATA_CENTER1, 2, 0, 0); } - Y_UNIT_TEST(TestMoveSlotWithFairShare) { + Y_UNIT_TEST(TestMoveSlotWithFairShare) { TTenantTestRuntime runtime(TenantTestConfig3DC()); CheckAlterTenant(runtime, TENANT1_1_NAME, SLOT1_TYPE, ANY_DATA_CENTER, 9, 9, 0); @@ -841,7 +841,7 @@ Y_UNIT_TEST_SUITE(TTenantSlotBrokerTests) { SLOT1_TYPE, ANY_DATA_CENTER, 4, 0, 2); } - Y_UNIT_TEST(TestDisconnectAndReconnect) { + Y_UNIT_TEST(TestDisconnectAndReconnect) { TTenantTestRuntime runtime(TenantTestConfig3DC()); CheckAlterTenant(runtime, TENANT1_1_NAME, SLOT1_TYPE, ANY_DATA_CENTER, 9, 9, 0); @@ -909,7 +909,7 @@ Y_UNIT_TEST_SUITE(TTenantSlotBrokerTests) { } } - Y_UNIT_TEST(TestAddSlotToPool) { + Y_UNIT_TEST(TestAddSlotToPool) { TTenantTestRuntime runtime(TenantTestConfig3DC()); CheckAlterTenant(runtime, TENANT1_1_NAME, SLOT1_TYPE, DATA_CENTER1, 3, 3, 0); @@ -941,7 +941,7 @@ Y_UNIT_TEST_SUITE(TTenantSlotBrokerTests) { SLOT1_TYPE, ANY_DATA_CENTER, 7, 0, 0); } - Y_UNIT_TEST(TestRemoveSlotFromPool) { + Y_UNIT_TEST(TestRemoveSlotFromPool) { TTenantTestRuntime runtime(TenantTestConfig3DC()); CheckAlterTenant(runtime, TENANT1_1_NAME, SLOT1_TYPE, DATA_CENTER1, 3, 3, 0); @@ -963,7 +963,7 @@ Y_UNIT_TEST_SUITE(TTenantSlotBrokerTests) { SLOT1_TYPE, DATA_CENTER1, 3, 0, 1); } - Y_UNIT_TEST(TestChangeSlotType) { + Y_UNIT_TEST(TestChangeSlotType) { TTenantTestRuntime runtime(TenantTestConfig3DC()); CheckAlterTenant(runtime, TENANT1_1_NAME, SLOT1_TYPE, DATA_CENTER1, 3, 3, 0); @@ -994,7 +994,7 @@ Y_UNIT_TEST_SUITE(TTenantSlotBrokerTests) { SLOT2_TYPE, DATA_CENTER1, 4, 0, 0); } - Y_UNIT_TEST(TestChangeSlotOwner) { + Y_UNIT_TEST(TestChangeSlotOwner) { TTenantTestRuntime runtime(TenantTestConfig3DC()); CheckAlterTenant(runtime, TENANT1_1_NAME, SLOT2_TYPE, DATA_CENTER1, 3, 3, 0); @@ -1046,7 +1046,7 @@ Y_UNIT_TEST_SUITE(TTenantSlotBrokerTests) { SLOT1_TYPE, DATA_CENTER1, 3, 0, 0); } - Y_UNIT_TEST(TestRestartTablet) { + Y_UNIT_TEST(TestRestartTablet) { TTenantTestRuntime runtime(TenantTestConfig3DC()); CheckAlterTenant(runtime, TENANT1_1_NAME, SLOT1_TYPE, DATA_CENTER1, 3, 3, 0); @@ -1102,7 +1102,7 @@ Y_UNIT_TEST_SUITE(TTenantSlotBrokerTests) { SLOT2_TYPE, DATA_CENTER3, 3, 0, 0); } - Y_UNIT_TEST(TestListTenants) { + Y_UNIT_TEST(TestListTenants) { TTenantTestRuntime runtime(TenantTestConfig3DC()); CheckAlterTenant(runtime, TENANT1_1_NAME, SLOT1_TYPE, DATA_CENTER1, 3, 3, 0); @@ -1141,7 +1141,7 @@ Y_UNIT_TEST_SUITE(TTenantSlotBrokerTests) { {SLOT2_TYPE, DATA_CENTER3, 3, 0, 0} }}} }}); } - Y_UNIT_TEST(TestRandom) { + Y_UNIT_TEST(TestRandom) { TTenantTestRuntime runtime(TenantTestConfig3DC()); constexpr int NITERS = 10; @@ -1231,7 +1231,7 @@ Y_UNIT_TEST_SUITE(TTenantSlotBrokerTests) { } } - Y_UNIT_TEST(TestSlotLabels) { + Y_UNIT_TEST(TestSlotLabels) { TTenantTestRuntime runtime(TenantTestConfigSingleSlot()); CheckAlterTenant(runtime, TENANT1_1_NAME, SLOT1_TYPE, DATA_CENTER1, 1, 1, 0); diff --git a/ydb/core/mind/tenant_ut_local.cpp b/ydb/core/mind/tenant_ut_local.cpp index 5aab98212de..786e2b2cfee 100644 --- a/ydb/core/mind/tenant_ut_local.cpp +++ b/ydb/core/mind/tenant_ut_local.cpp @@ -57,8 +57,8 @@ void CheckAlterTenant(TTenantTestRuntime &runtime, const TString &tenant, TEvLoc } -Y_UNIT_TEST_SUITE(TLocalTests) { - Y_UNIT_TEST(TestAddTenant) { +Y_UNIT_TEST_SUITE(TLocalTests) { + Y_UNIT_TEST(TestAddTenant) { TTenantTestRuntime runtime(DefaultTenantTestConfig); CheckAddTenant(runtime, TENANT1_1_NAME, TEvLocal::TEvTenantStatus::STARTED, 5); @@ -72,7 +72,7 @@ Y_UNIT_TEST_SUITE(TLocalTests) { {TENANT1_2_NAME, 1, 1, 1}}}); } - Y_UNIT_TEST(TestAlterTenant) { + Y_UNIT_TEST(TestAlterTenant) { TTenantTestRuntime runtime(DefaultTenantTestConfig); CheckAddTenant(runtime, TENANT1_1_NAME, TEvLocal::TEvTenantStatus::STARTED, 5, 5, 5); @@ -84,7 +84,7 @@ Y_UNIT_TEST_SUITE(TLocalTests) { {TENANT1_1_NAME, 10, 10, 10}}}); } - Y_UNIT_TEST(TestAddTenantWhileResolving) { + Y_UNIT_TEST(TestAddTenantWhileResolving) { TTenantTestRuntime runtime(DefaultTenantTestConfig); TAutoPtr<IEventHandle> handle; @@ -128,7 +128,7 @@ Y_UNIT_TEST_SUITE(TLocalTests) { {TENANT1_2_NAME, 1, 1, 1}}}); } - Y_UNIT_TEST(TestRemoveTenantWhileResolving) { + Y_UNIT_TEST(TestRemoveTenantWhileResolving) { TTenantTestRuntime runtime(DefaultTenantTestConfig); TAutoPtr<IEventHandle> handle; diff --git a/ydb/core/mind/tenant_ut_pool.cpp b/ydb/core/mind/tenant_ut_pool.cpp index 9ac6b6843c3..023d04204fd 100644 --- a/ydb/core/mind/tenant_ut_pool.cpp +++ b/ydb/core/mind/tenant_ut_pool.cpp @@ -271,8 +271,8 @@ void ChangeMonitoringConfig(TTenantTestRuntime &runtime, } // anonymous namesapce -Y_UNIT_TEST_SUITE(TTenantPoolTests) { - Y_UNIT_TEST(TestAssignTenantSimple) { +Y_UNIT_TEST_SUITE(TTenantPoolTests) { + Y_UNIT_TEST(TestAssignTenantSimple) { TTenantTestRuntime runtime(DefaultTenantTestConfig); CheckConfigureSlot(runtime, 0, @@ -287,7 +287,7 @@ Y_UNIT_TEST_SUITE(TTenantPoolTests) { CheckTenantPoolStatus(runtime, TENANT1_1_NAME, TENANT1_2_NAME, ""); } - Y_UNIT_TEST(TestAssignTenantStatic) { + Y_UNIT_TEST(TestAssignTenantStatic) { TTenantTestRuntime runtime(DefaultTenantTestConfig); CheckConfigureSlot(runtime, 0, @@ -299,7 +299,7 @@ Y_UNIT_TEST_SUITE(TTenantPoolTests) { DOMAIN1_NAME, "", ""); } - Y_UNIT_TEST(TestAssignTenantMultiple) { + Y_UNIT_TEST(TestAssignTenantMultiple) { TTenantTestRuntime runtime(DefaultTenantTestConfig); CheckConfigureSlot(runtime, 0, @@ -316,7 +316,7 @@ Y_UNIT_TEST_SUITE(TTenantPoolTests) { TENANT1_1_NAME, TENANT1_1_NAME, TENANT1_1_NAME); } - Y_UNIT_TEST(TestAssignTenantWithReassigns) { + Y_UNIT_TEST(TestAssignTenantWithReassigns) { TTenantTestRuntime runtime(DefaultTenantTestConfig); CheckConfigureSlot(runtime, 0, @@ -338,7 +338,7 @@ Y_UNIT_TEST_SUITE(TTenantPoolTests) { TENANT1_1_NAME, TENANT1_2_NAME, DOMAIN1_NAME); } - Y_UNIT_TEST(TestAssignTenantWithDetach) { + Y_UNIT_TEST(TestAssignTenantWithDetach) { TTenantTestRuntime runtime(DefaultTenantTestConfig); CheckConfigureSlot(runtime, 0, @@ -363,7 +363,7 @@ Y_UNIT_TEST_SUITE(TTenantPoolTests) { TENANT1_1_NAME, "", ""); } - Y_UNIT_TEST(TestAssignTenantUnknownTenant) { + Y_UNIT_TEST(TestAssignTenantUnknownTenant) { TTenantTestRuntime runtime(DefaultTenantTestConfig); CheckConfigureSlot(runtime, 0, @@ -374,7 +374,7 @@ Y_UNIT_TEST_SUITE(TTenantPoolTests) { CheckTenantPoolStatus(runtime); } - Y_UNIT_TEST(TestAssignTenantPostponed) { + Y_UNIT_TEST(TestAssignTenantPostponed) { TTenantTestRuntime runtime(DefaultTenantTestConfig); CheckConfigureSlot(runtime, 0, @@ -396,7 +396,7 @@ Y_UNIT_TEST_SUITE(TTenantPoolTests) { TENANT1_1_NAME, TENANT1_2_NAME, ""); } - Y_UNIT_TEST(TestOwnership) { + Y_UNIT_TEST(TestOwnership) { TTenantTestRuntime runtime(DefaultTenantTestConfig); TAutoPtr<IEventHandle> handle; @@ -453,7 +453,7 @@ Y_UNIT_TEST_SUITE(TTenantPoolTests) { TENANT1_2_NAME, TENANT1_2_NAME, ""); } - Y_UNIT_TEST(TestSensorLabels) { + Y_UNIT_TEST(TestSensorLabels) { const TTenantTestConfig config = { // Domains {name, schemeshard {{ subdomain_names }}} {{ {DOMAIN1_NAME, SCHEME_SHARD1_ID, {{ TENANT1_1_NAME, TENANT1_2_NAME }}} }}, @@ -646,7 +646,7 @@ Y_UNIT_TEST_SUITE(TTenantPoolTests) { } - Y_UNIT_TEST(TestSensorLabelsForStaticConfig) { + Y_UNIT_TEST(TestSensorLabelsForStaticConfig) { const TTenantTestConfig config = { // Domains {name, schemeshard {{ subdomain_names }}} {{ {DOMAIN1_NAME, SCHEME_SHARD1_ID, {{ TENANT1_1_NAME, TENANT1_2_NAME }}} }}, diff --git a/ydb/core/mind/ut_fat/blobstorage_node_warden_ut_fat.cpp b/ydb/core/mind/ut_fat/blobstorage_node_warden_ut_fat.cpp index 011f03d93cd..c9cfcb33d20 100644 --- a/ydb/core/mind/ut_fat/blobstorage_node_warden_ut_fat.cpp +++ b/ydb/core/mind/ut_fat/blobstorage_node_warden_ut_fat.cpp @@ -19,7 +19,7 @@ #include <util/random/entropy.h> #include <util/stream/file.h> #include <util/string/printf.h> -#include <util/string/subst.h> +#include <util/string/subst.h> #include <google/protobuf/text_format.h> #include <library/cpp/testing/unittest/registar.h> @@ -39,7 +39,7 @@ namespace NBlobStorageNodeWardenTest{ #if ENABLE_FORKED_TESTS # define CUSTOM_UNIT_TEST(a) SIMPLE_UNIT_FORKED_TEST(a) #else -#define CUSTOM_UNIT_TEST(a) Y_UNIT_TEST(a) +#define CUSTOM_UNIT_TEST(a) Y_UNIT_TEST(a) #endif //ENABLE_FORKED_TESTS #define VERBOSE_COUT(str) \ @@ -245,7 +245,7 @@ void Setup(TTestActorRuntime& runtime) { } -Y_UNIT_TEST_SUITE(TBlobStorageWardenTest) { +Y_UNIT_TEST_SUITE(TBlobStorageWardenTest) { ui64 GetBsc(TTestActorRuntime &runtime) { ui64 defaultStateStorageGroup = runtime.GetAppData(0).DomainsInfo->GetDefaultStateStorageGroup(DOMAIN_ID); ui64 bsController = MakeBSControllerID(defaultStateStorageGroup); diff --git a/ydb/core/mon/mon.cpp b/ydb/core/mon/mon.cpp index d4722266f34..4a2ff148f6a 100644 --- a/ydb/core/mon/mon.cpp +++ b/ydb/core/mon/mon.cpp @@ -211,7 +211,7 @@ namespace NActors { } virtual TAutoPtr<NActors::IEventHandle> AfterRegister(const NActors::TActorId &self, const TActorId& parentId) override { - Y_UNUSED(parentId); + Y_UNUSED(parentId); return new NActors::IEventHandle(self, self, new TEvents::TEvBootstrap(), 0); } diff --git a/ydb/core/persqueue/blob.cpp b/ydb/core/persqueue/blob.cpp index 7727f12a130..fb922956d7f 100644 --- a/ydb/core/persqueue/blob.cpp +++ b/ydb/core/persqueue/blob.cpp @@ -639,7 +639,7 @@ ui32 THead::GetCount() const return Batches.back().GetOffset() - Offset + Batches.back().GetCount(); } -IOutputStream& operator <<(IOutputStream& out, const THead& value) +IOutputStream& operator <<(IOutputStream& out, const THead& value) { out << "Offset " << value.Offset << " PartNo " << value.PartNo << " PackedSize " << value.PackedSize << " count " << value.GetCount() << " nextOffset " << value.GetNextOffset() << " batches " << value.Batches.size(); diff --git a/ydb/core/persqueue/blob.h b/ydb/core/persqueue/blob.h index 633ec2499a3..c9f0209782d 100644 --- a/ydb/core/persqueue/blob.h +++ b/ydb/core/persqueue/blob.h @@ -247,7 +247,7 @@ struct THead { ui32 FindPos(const ui64 offset, const ui16 partNo) const; }; -IOutputStream& operator <<(IOutputStream& out, const THead& value); +IOutputStream& operator <<(IOutputStream& out, const THead& value); //stucture for tracking written KV-blobs, stored in memory parts of one partitioned blob diff --git a/ydb/core/persqueue/internals_ut.cpp b/ydb/core/persqueue/internals_ut.cpp index d72ffe5e11e..2390dd5d893 100644 --- a/ydb/core/persqueue/internals_ut.cpp +++ b/ydb/core/persqueue/internals_ut.cpp @@ -5,14 +5,14 @@ namespace NKikimr { namespace NPQ { namespace { -Y_UNIT_TEST_SUITE(TPQTestInternal) { +Y_UNIT_TEST_SUITE(TPQTestInternal) { //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // TEST CASES //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -Y_UNIT_TEST(TestPartitionedBlobSimpleTest) { +Y_UNIT_TEST(TestPartitionedBlobSimpleTest) { THead head; THead newHead; @@ -157,7 +157,7 @@ void Test(bool headCompacted, ui32 parts, ui32 partSize, ui32 leftInHead) } } -Y_UNIT_TEST(TestPartitionedBigTest) { +Y_UNIT_TEST(TestPartitionedBigTest) { Test(true, 100, 400*1024, 3); Test(false, 100, 512*1024 - 9 - sizeof(ui64) - sizeof(ui16) - 100, 16); //serialized size of client blob is 512*1024 - 100 @@ -167,7 +167,7 @@ Y_UNIT_TEST(TestPartitionedBigTest) { Test(true, 101, 512*1024 - 9 - sizeof(ui64) - sizeof(ui16) - 100, 7); //serialized size of client blob is 512*1024 - 100 } -Y_UNIT_TEST(TestBatchPacking) { +Y_UNIT_TEST(TestBatchPacking) { TString value(10, 'a'); TBatch batch; for (ui32 i = 0; i < 100; ++i) { @@ -200,7 +200,7 @@ Y_UNIT_TEST(TestBatchPacking) { } -} //Y_UNIT_TEST_SUITE +} //Y_UNIT_TEST_SUITE } // TInternalsTest diff --git a/ydb/core/persqueue/partition.cpp b/ydb/core/persqueue/partition.cpp index cc8e2419cf2..2ba6d0c0dcb 100644 --- a/ydb/core/persqueue/partition.cpp +++ b/ydb/core/persqueue/partition.cpp @@ -70,7 +70,7 @@ struct TPartition::THasDataDeadline { class TKeyLevel { public: - friend IOutputStream& operator <<(IOutputStream& out, const TKeyLevel& value); + friend IOutputStream& operator <<(IOutputStream& out, const TKeyLevel& value); TKeyLevel(ui32 border) : Border_(border) @@ -173,7 +173,7 @@ private: }; -void HtmlOutput(IOutputStream& out, const TString& line, const std::deque<std::pair<TKey, ui32>>& keys) +void HtmlOutput(IOutputStream& out, const TString& line, const std::deque<std::pair<TKey, ui32>>& keys) { HTML(out) { TABLE() { @@ -207,7 +207,7 @@ void HtmlOutput(IOutputStream& out, const TString& line, const std::deque<std::p } -IOutputStream& operator <<(IOutputStream& out, const TKeyLevel& value) { +IOutputStream& operator <<(IOutputStream& out, const TKeyLevel& value) { TStringStream str; str << "count=" << value.Keys_.size() << " sum=" << value.Sum_ << " border=" << value.Border_ << " recs= " << value.RecsCount_ << ":"; HtmlOutput(out, str.Str(), value.Keys_); @@ -330,7 +330,7 @@ static void RequestRange(const TActorContext& ctx, const TActorId& dst, ui32 par auto range = read->MutableRange(); TKeyPrefix from(c, partition); if (!key.empty()) { - Y_VERIFY(key.StartsWith(TStringBuf(from.Data(), from.Size()))); + Y_VERIFY(key.StartsWith(TStringBuf(from.Data(), from.Size()))); from.Clear(); from.Append(key.data(), key.size()); } diff --git a/ydb/core/persqueue/pq_ut.cpp b/ydb/core/persqueue/pq_ut.cpp index 13a61229105..80c8e9d9f5f 100644 --- a/ydb/core/persqueue/pq_ut.cpp +++ b/ydb/core/persqueue/pq_ut.cpp @@ -21,14 +21,14 @@ namespace NKikimr { -Y_UNIT_TEST_SUITE(TPQTest) { +Y_UNIT_TEST_SUITE(TPQTest) { //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // SINGLE COMMAND TEST FUNCTIONS //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -Y_UNIT_TEST(TestGroupsBalancer) { +Y_UNIT_TEST(TestGroupsBalancer) { TTestContext tc; TFinalizer finalizer(tc); tc.Prepare(); @@ -76,7 +76,7 @@ Y_UNIT_TEST(TestGroupsBalancer) { } -Y_UNIT_TEST(TestGroupsBalancer2) { +Y_UNIT_TEST(TestGroupsBalancer2) { TTestContext tc; TFinalizer finalizer(tc); tc.Prepare(); @@ -137,7 +137,7 @@ Y_UNIT_TEST(TestGroupsBalancer3) { } -Y_UNIT_TEST(TestUserInfoCompatibility) { +Y_UNIT_TEST(TestUserInfoCompatibility) { TTestContext tc; RunTestWithReboots(tc.TabletIds, [&]() { return tc.InitialEventsFilter.Prepare(); @@ -223,7 +223,7 @@ Y_UNIT_TEST(TestReadRuleVersions) { }); } -Y_UNIT_TEST(TestCreateBalancer) { +Y_UNIT_TEST(TestCreateBalancer) { TTestContext tc; RunTestWithReboots(tc.TabletIds, [&]() { return tc.InitialEventsFilter.Prepare(); @@ -272,7 +272,7 @@ Y_UNIT_TEST(TestCreateBalancer) { }); } -Y_UNIT_TEST(TestDescribeBalancer) { +Y_UNIT_TEST(TestDescribeBalancer) { TTestContext tc; RunTestWithReboots(tc.TabletIds, [&]() { return tc.InitialEventsFilter.Prepare(); @@ -302,7 +302,7 @@ Y_UNIT_TEST(TestDescribeBalancer) { }); } -Y_UNIT_TEST(TestCheckACL) { +Y_UNIT_TEST(TestCheckACL) { TTestContext tc; RunTestWithReboots(tc.TabletIds, [&]() { return tc.InitialEventsFilter.Prepare(); @@ -452,7 +452,7 @@ void CheckLabeledCountersResponse(ui32 count, TTestContext& tc, TVector<TString> } } -Y_UNIT_TEST(TestSwitchOffImportantFlag) { +Y_UNIT_TEST(TestSwitchOffImportantFlag) { TTestContext tc; RunTestWithReboots(tc.TabletIds, [&]() { return tc.InitialEventsFilter.Prepare(); @@ -551,7 +551,7 @@ Y_UNIT_TEST(TestSwitchOffImportantFlag) { } -Y_UNIT_TEST(TestSeveralOwners) { +Y_UNIT_TEST(TestSeveralOwners) { TTestContext tc; RunTestWithReboots(tc.TabletIds, [&]() { return tc.InitialEventsFilter.Prepare(); @@ -583,7 +583,7 @@ Y_UNIT_TEST(TestSeveralOwners) { } -Y_UNIT_TEST(TestWaitInOwners) { +Y_UNIT_TEST(TestWaitInOwners) { TTestContext tc; RunTestWithReboots(tc.TabletIds, [&]() { return tc.InitialEventsFilter.Prepare(); @@ -679,7 +679,7 @@ Y_UNIT_TEST(TestWaitInOwners) { -Y_UNIT_TEST(TestReserveBytes) { +Y_UNIT_TEST(TestReserveBytes) { TTestContext tc; RunTestWithReboots(tc.TabletIds, [&]() { return tc.InitialEventsFilter.Prepare(); @@ -740,7 +740,7 @@ Y_UNIT_TEST(TestReserveBytes) { -Y_UNIT_TEST(TestMessageNo) { +Y_UNIT_TEST(TestMessageNo) { TTestContext tc; RunTestWithReboots(tc.TabletIds, [&]() { return tc.InitialEventsFilter.Prepare(); @@ -792,7 +792,7 @@ Y_UNIT_TEST(TestMessageNo) { } -Y_UNIT_TEST(TestPartitionedBlobFails) { +Y_UNIT_TEST(TestPartitionedBlobFails) { TTestContext tc; RunTestWithReboots(tc.TabletIds, [&]() { return tc.InitialEventsFilter.Prepare(); @@ -952,7 +952,7 @@ Y_UNIT_TEST(TestPartitionedBlobFails) { }); } -Y_UNIT_TEST(TestAlreadyWritten) { +Y_UNIT_TEST(TestAlreadyWritten) { TTestContext tc; RunTestWithReboots(tc.TabletIds, [&]() { return tc.InitialEventsFilter.Prepare(); @@ -979,7 +979,7 @@ Y_UNIT_TEST(TestAlreadyWritten) { } -Y_UNIT_TEST(TestAlreadyWrittenWithoutDeduplication) { +Y_UNIT_TEST(TestAlreadyWrittenWithoutDeduplication) { TTestContext tc; RunTestWithReboots(tc.TabletIds, [&]() { return tc.InitialEventsFilter.Prepare(); @@ -1004,7 +1004,7 @@ Y_UNIT_TEST(TestAlreadyWrittenWithoutDeduplication) { } -Y_UNIT_TEST(TestWritePQCompact) { +Y_UNIT_TEST(TestWritePQCompact) { TTestContext tc; RunTestWithReboots(tc.TabletIds, [&]() { return tc.InitialEventsFilter.Prepare(); @@ -1061,7 +1061,7 @@ Y_UNIT_TEST(TestWritePQCompact) { } -Y_UNIT_TEST(TestWritePQBigMessage) { +Y_UNIT_TEST(TestWritePQBigMessage) { TTestContext tc; RunTestWithReboots(tc.TabletIds, [&]() { return tc.InitialEventsFilter.Prepare(); @@ -1114,7 +1114,7 @@ Y_UNIT_TEST(TestWritePQBigMessage) { } -Y_UNIT_TEST(TestWritePQ) { +Y_UNIT_TEST(TestWritePQ) { TTestContext tc; RunTestWithReboots(tc.TabletIds, [&]() { return tc.InitialEventsFilter.Prepare(); @@ -1285,7 +1285,7 @@ Y_UNIT_TEST(TestSourceIdDropBySourceIdCount) { } -Y_UNIT_TEST(TestWriteOffsetWithBigMessage) { +Y_UNIT_TEST(TestWriteOffsetWithBigMessage) { TTestContext tc; RunTestWithReboots(tc.TabletIds, [&]() { return tc.InitialEventsFilter.Prepare(); @@ -1320,7 +1320,7 @@ Y_UNIT_TEST(TestWriteOffsetWithBigMessage) { } -Y_UNIT_TEST(TestWriteSplit) { +Y_UNIT_TEST(TestWriteSplit) { TTestContext tc; RunTestWithReboots(tc.TabletIds, [&]() { return tc.InitialEventsFilter.Prepare(); @@ -1345,7 +1345,7 @@ Y_UNIT_TEST(TestWriteSplit) { } -Y_UNIT_TEST(TestLowWatermark) { +Y_UNIT_TEST(TestLowWatermark) { TTestContext tc; RunTestWithReboots(tc.TabletIds, [&]() { return tc.InitialEventsFilter.Prepare(); @@ -1381,7 +1381,7 @@ Y_UNIT_TEST(TestLowWatermark) { -Y_UNIT_TEST(TestWriteToFullPartition) { +Y_UNIT_TEST(TestWriteToFullPartition) { TTestContext tc; RunTestWithReboots(tc.TabletIds, [&]() { return tc.InitialEventsFilter.Prepare(); @@ -1416,7 +1416,7 @@ Y_UNIT_TEST(TestWriteToFullPartition) { -Y_UNIT_TEST(TestPQPartialRead) { +Y_UNIT_TEST(TestPQPartialRead) { TTestContext tc; RunTestWithReboots(tc.TabletIds, [&]() { return tc.InitialEventsFilter.Prepare(); @@ -1449,7 +1449,7 @@ Y_UNIT_TEST(TestPQPartialRead) { } -Y_UNIT_TEST(TestPQRead) { +Y_UNIT_TEST(TestPQRead) { TTestContext tc; RunTestWithReboots(tc.TabletIds, [&]() { return tc.InitialEventsFilter.Prepare(); @@ -1501,7 +1501,7 @@ Y_UNIT_TEST(TestPQRead) { } -Y_UNIT_TEST(TestPQSmallRead) { +Y_UNIT_TEST(TestPQSmallRead) { TTestContext tc; RunTestWithReboots(tc.TabletIds, [&]() { return tc.InitialEventsFilter.Prepare(); @@ -1542,7 +1542,7 @@ Y_UNIT_TEST(TestPQSmallRead) { }); } -Y_UNIT_TEST(TestPQReadAhead) { +Y_UNIT_TEST(TestPQReadAhead) { TTestContext tc; RunTestWithReboots(tc.TabletIds, [&]() { return tc.InitialEventsFilter.Prepare(); @@ -1589,7 +1589,7 @@ Y_UNIT_TEST(TestPQReadAhead) { }); } -Y_UNIT_TEST(TestOwnership) { +Y_UNIT_TEST(TestOwnership) { TTestContext tc; RunTestWithReboots(tc.TabletIds, [&]() { return tc.InitialEventsFilter.Prepare(); @@ -1610,7 +1610,7 @@ Y_UNIT_TEST(TestOwnership) { }); } -Y_UNIT_TEST(TestSetClientOffset) { +Y_UNIT_TEST(TestSetClientOffset) { TTestContext tc; RunTestWithReboots(tc.TabletIds, [&]() { return tc.InitialEventsFilter.Prepare(); @@ -1640,7 +1640,7 @@ Y_UNIT_TEST(TestSetClientOffset) { }); } -Y_UNIT_TEST(TestReadSessions) { +Y_UNIT_TEST(TestReadSessions) { TTestContext tc; RunTestWithReboots(tc.TabletIds, [&]() { return tc.InitialEventsFilter.Prepare(); @@ -1679,7 +1679,7 @@ Y_UNIT_TEST(TestReadSessions) { -Y_UNIT_TEST(TestGetTimestamps) { +Y_UNIT_TEST(TestGetTimestamps) { TTestContext tc; RunTestWithReboots(tc.TabletIds, [&]() { return tc.InitialEventsFilter.Prepare(); @@ -1732,7 +1732,7 @@ Y_UNIT_TEST(TestGetTimestamps) { } -Y_UNIT_TEST(TestChangeConfig) { +Y_UNIT_TEST(TestChangeConfig) { TTestContext tc; RunTestWithReboots(tc.TabletIds, [&]() { return tc.InitialEventsFilter.Prepare(); @@ -1767,7 +1767,7 @@ Y_UNIT_TEST(TestChangeConfig) { }); } -Y_UNIT_TEST(TestReadSubscription) { +Y_UNIT_TEST(TestReadSubscription) { TTestContext tc; RunTestWithReboots(tc.TabletIds, [&]() { return tc.InitialEventsFilter.Prepare(); @@ -1865,7 +1865,7 @@ Y_UNIT_TEST(TestReadSubscription) { // -Y_UNIT_TEST(TestPQCacheSizeManagement) { +Y_UNIT_TEST(TestPQCacheSizeManagement) { TTestContext tc; RunTestWithReboots(tc.TabletIds, [&]() { return tc.InitialEventsFilter.Prepare(); @@ -1903,7 +1903,7 @@ Y_UNIT_TEST(TestPQCacheSizeManagement) { }); } -Y_UNIT_TEST(TestOffsetEstimation) { +Y_UNIT_TEST(TestOffsetEstimation) { std::deque<NPQ::TDataKey> container = { {NPQ::TKey(NPQ::TKeyPrefix::EType::TypeNone, 0, 1, 0, 0, 0), 0, TInstant::Seconds(1), 10}, {NPQ::TKey(NPQ::TKeyPrefix::EType::TypeNone, 0, 2, 0, 0, 0), 0, TInstant::Seconds(1), 10}, @@ -1923,7 +1923,7 @@ Y_UNIT_TEST(TestOffsetEstimation) { UNIT_ASSERT_EQUAL(NPQ::GetOffsetEstimate(container, TInstant::MilliSeconds(3500), 9999), 9999); } -Y_UNIT_TEST(TestMaxTimeLagRewind) { +Y_UNIT_TEST(TestMaxTimeLagRewind) { TTestContext tc; RunTestWithReboots(tc.TabletIds, [&]() { @@ -1963,7 +1963,7 @@ Y_UNIT_TEST(TestMaxTimeLagRewind) { } -Y_UNIT_TEST(TestWriteTimeStampEstimate) { +Y_UNIT_TEST(TestWriteTimeStampEstimate) { TTestContext tc; TFinalizer finalizer(tc); tc.Prepare(); diff --git a/ydb/core/persqueue/type_codecs.h b/ydb/core/persqueue/type_codecs.h index 788e0fce0e1..f7171c4b9d3 100644 --- a/ydb/core/persqueue/type_codecs.h +++ b/ydb/core/persqueue/type_codecs.h @@ -16,12 +16,12 @@ public: public: TCodecImpl() { - Y_VERIFY(TCoder::Sig() == TDecoder::Sig(), "Codecs signatures mismatch (cd: %u, dc: %u).", + Y_VERIFY(TCoder::Sig() == TDecoder::Sig(), "Codecs signatures mismatch (cd: %u, dc: %u).", ui16(TCoder::Sig()), ui16(TDecoder::Sig())); } TCodecSig Signature() const override { - Y_VERIFY_DEBUG(TCoder::Sig() == TDecoder::Sig()); + Y_VERIFY_DEBUG(TCoder::Sig() == TDecoder::Sig()); return TCoder::Sig(); } diff --git a/ydb/core/persqueue/type_codecs_defs.h b/ydb/core/persqueue/type_codecs_defs.h index 90c55d4b892..50e0d46c720 100644 --- a/ydb/core/persqueue/type_codecs_defs.h +++ b/ydb/core/persqueue/type_codecs_defs.h @@ -222,7 +222,7 @@ public: : ShortSize_(size) , IsNull_(0) { - Y_VERIFY_DEBUG(size <= INTRUSIVE_SIZE); + Y_VERIFY_DEBUG(size <= INTRUSIVE_SIZE); if (size) { ::memcpy(IntrusiveData_, data, size); } @@ -325,13 +325,13 @@ public: template <bool IsNullable> const ICodec* GetDefaultCodec() const { const ICodec* codec = IsNullable ? DefaultNullable : DefaultNonNullable; - Y_VERIFY(codec, "No default codec."); + Y_VERIFY(codec, "No default codec."); return codec; } const ICodec* GetCodec(TCodecSig sig) const { auto iter = Codecs.find(sig); - Y_VERIFY(iter != Codecs.end(), "Unregistered codec (%u).", ui16(sig)); + Y_VERIFY(iter != Codecs.end(), "Unregistered codec (%u).", ui16(sig)); return iter->second; } @@ -343,20 +343,20 @@ public: const ICodec* AddCodec() { auto codec = Singleton<TCodec>(); auto inserted = Codecs.insert(std::make_pair(TCodec::Sig(), codec)); - Y_VERIFY(inserted.second, "Codec signature collision (%u).", ui16(TCodec::Sig())); + Y_VERIFY(inserted.second, "Codec signature collision (%u).", ui16(TCodec::Sig())); return codec; } const ICodec* AddAlias(TCodecSig from, TCodecSig to, bool force = false) { auto iter = Codecs.find(to); - Y_VERIFY(iter != Codecs.end(), "Aliasing an unregistered codec (%u -> %u).", ui16(from), ui16(to)); + Y_VERIFY(iter != Codecs.end(), "Aliasing an unregistered codec (%u -> %u).", ui16(from), ui16(to)); return AddAlias(from, iter->second, force); } const ICodec* AddAlias(TCodecSig from, const ICodec* to, bool force = false) { - Y_VERIFY(to, "Aliasing an unregistered codec (%u -> nullptr).", ui16(from)); + Y_VERIFY(to, "Aliasing an unregistered codec (%u -> nullptr).", ui16(from)); auto& alias = Codecs[from]; - Y_VERIFY(force || !alias, "Codec signature collision (%u).", ui16(from)); + Y_VERIFY(force || !alias, "Codec signature collision (%u).", ui16(from)); alias = to; // Cache the default codecs. @@ -380,10 +380,10 @@ private: //////////////////////////////////////////////////////////////////////////////// inline IChunkDecoder::TPtr IChunkDecoder::ReadChunk(const TDataRef& data, const TTypeCodecs* codecs) { - Y_VERIFY_DEBUG(data.Size() >= sizeof(TCodecSig)); + Y_VERIFY_DEBUG(data.Size() >= sizeof(TCodecSig)); const TCodecSig sig = ReadUnaligned<TCodecSig>(data.Data()); auto codec = codecs->GetCodec(sig); - Y_VERIFY(codec, "Unregistered codec (%u).", ui16(sig)); + Y_VERIFY(codec, "Unregistered codec (%u).", ui16(sig)); return codec->ReadChunk(data); } diff --git a/ydb/core/persqueue/type_codecs_ut.cpp b/ydb/core/persqueue/type_codecs_ut.cpp index d9f0b647557..43ec2f3e764 100644 --- a/ydb/core/persqueue/type_codecs_ut.cpp +++ b/ydb/core/persqueue/type_codecs_ut.cpp @@ -16,7 +16,7 @@ using TCodecSig = NScheme::TCodecSig; using TCodecType = NScheme::TCodecType; using TDataRef = NScheme::TDataRef; -Y_UNIT_TEST_SUITE(TTypeCodecsTest) { +Y_UNIT_TEST_SUITE(TTypeCodecsTest) { void Metrics(const TVector<TDataRef>& values, const ICodec* codec) { TAutoPtr<TFlatBlobDataOutputStream> output(new TFlatBlobDataOutputStream()); @@ -41,7 +41,7 @@ Y_UNIT_TEST_SUITE(TTypeCodecsTest) { start = TInstant::Now(); for (size_t i = 0, size = values.size(); i != size; ++i) { auto value = reading->GetValue(i); - Y_UNUSED(value); + Y_UNUSED(value); } Cerr << "Read by index: " << TInstant::Now() - start << Endl; @@ -49,7 +49,7 @@ Y_UNIT_TEST_SUITE(TTypeCodecsTest) { start = TInstant::Now(); for (size_t i = 0; i != values.size(); ++i) { auto value = iter->Next(); - Y_UNUSED(value); + Y_UNUSED(value); } Cerr << "Iterate: " << TInstant::Now() - start << Endl; } @@ -83,7 +83,7 @@ Y_UNIT_TEST_SUITE(TTypeCodecsTest) { Metrics(values, codec); }; - Y_UNIT_TEST(TestBoolCodec) { + Y_UNIT_TEST(TestBoolCodec) { static const bool VALUE_FALSE = false; static const bool VALUE_TRUE = true; @@ -106,7 +106,7 @@ Y_UNIT_TEST_SUITE(TTypeCodecsTest) { TestImpl(values, codec); } - Y_UNIT_TEST(TestFixedLenCodec) { + Y_UNIT_TEST(TestFixedLenCodec) { THolder<TTypeCodecs> codecs(new TTypeCodecs(NScheme::TInt32::TypeId)); TVector<TDataRef> values; @@ -128,7 +128,7 @@ Y_UNIT_TEST_SUITE(TTypeCodecsTest) { TestImpl(values, codec); } - Y_UNIT_TEST(TestVarLenCodec) { + Y_UNIT_TEST(TestVarLenCodec) { THolder<TTypeCodecs> codecs(new TTypeCodecs(NScheme::TString::TypeId)); TReallyFastRng32 rand(100500); @@ -152,7 +152,7 @@ Y_UNIT_TEST_SUITE(TTypeCodecsTest) { TestImpl(values, codec); } - Y_UNIT_TEST(TestVarIntCodec) { + Y_UNIT_TEST(TestVarIntCodec) { THolder<TTypeCodecs> codecs(new TTypeCodecs(NScheme::TUint32::TypeId)); TReallyFastRng32 rand(100500); @@ -174,7 +174,7 @@ Y_UNIT_TEST_SUITE(TTypeCodecsTest) { TestImpl(values, codec); } - Y_UNIT_TEST(TestZigZagCodec) { + Y_UNIT_TEST(TestZigZagCodec) { THolder<TTypeCodecs> codecs(new TTypeCodecs(NScheme::TUint32::TypeId)); TReallyFastRng32 rand(100500); @@ -224,12 +224,12 @@ Y_UNIT_TEST_SUITE(TTypeCodecsTest) { TestImpl(values, codec); } - Y_UNIT_TEST(TestDeltaVarIntCodecAndRev) { + Y_UNIT_TEST(TestDeltaVarIntCodecAndRev) { TestDeltaVarIntCodecImpl(TCodecType::DeltaVarInt, false); TestDeltaVarIntCodecImpl(TCodecType::DeltaRevVarInt, true); } - Y_UNIT_TEST(TestDeltaZigZagCodec) { + Y_UNIT_TEST(TestDeltaZigZagCodec) { THolder<TTypeCodecs> codecs(new TTypeCodecs(NScheme::TInt32::TypeId)); TReallyFastRng32 rand(100500); diff --git a/ydb/core/persqueue/type_coders.h b/ydb/core/persqueue/type_coders.h index 26c2566d32e..cec256dcbf8 100644 --- a/ydb/core/persqueue/type_coders.h +++ b/ydb/core/persqueue/type_coders.h @@ -54,7 +54,7 @@ template <> class TCoderMask<false> { public: inline size_t MaxSize() const { return 0; } - inline void AddNull() { Y_FAIL("Null values are not supported."); } + inline void AddNull() { Y_FAIL("Null values are not supported."); } inline void AddNonNull() { } inline void Seal(TFlatBlobDataOutputStream*) { } }; @@ -81,7 +81,7 @@ public: protected: void DoAddData(const char* data, size_t size) override { - Y_VERIFY(size == Size, "Size mismatch."); + Y_VERIFY(size == Size, "Size mismatch."); Mask.AddNonNull(); DataSize += Size; Output->Write(data, size); @@ -210,7 +210,7 @@ public: protected: void DoAddData(const char* data, size_t size) override { - Y_VERIFY(size == sizeof(TType)); + Y_VERIFY(size == sizeof(TType)); Mask.AddNonNull(); DataSize += ValueCoder.Save(Output, ReadUnaligned<TType>(data)); } @@ -287,14 +287,14 @@ public: protected: void DoAddData(const char* data, size_t size) override { - Y_VERIFY_DEBUG(size == sizeof(bool)); + Y_VERIFY_DEBUG(size == sizeof(bool)); if (IsNullable) Mask.Append(1, 1); Mask.Append(*(const bool*)data, 1); } void DoAddNull() override { - Y_VERIFY(IsNullable, "Null values are not supported."); + Y_VERIFY(IsNullable, "Null values are not supported."); Mask.Append(0, 2); } diff --git a/ydb/core/persqueue/type_decoders.h b/ydb/core/persqueue/type_decoders.h index 30a8846923c..0eaa587c761 100644 --- a/ydb/core/persqueue/type_decoders.h +++ b/ydb/core/persqueue/type_decoders.h @@ -60,7 +60,7 @@ private: { } void Back() override { - Y_VERIFY_DEBUG(Index > 0); + Y_VERIFY_DEBUG(Index > 0); --Index; } }; @@ -80,20 +80,20 @@ public: } static inline IChunkDecoder::TPtr ReadNextImpl(const TDataRef& data, const TTypeCodecs* codecs) { - Y_VERIFY_DEBUG(data.Size() >= sizeof(TCodecSig)); + Y_VERIFY_DEBUG(data.Size() >= sizeof(TCodecSig)); const TCodecSig sig = ReadUnaligned<TCodecSig>(data.Data()); - if (Y_LIKELY(sig == Sig())) { + if (Y_LIKELY(sig == Sig())) { return new TDerived(data); } else { auto codec = codecs->GetCodec(sig); - Y_VERIFY(codec, "Unknown codec signature."); + Y_VERIFY(codec, "Unknown codec signature."); return codec->ReadChunk(data); } } protected: static inline void VerifySignature(const TDataRef& data) { - Y_VERIFY(data.Size() >= sizeof(TCodecSig)); + Y_VERIFY(data.Size() >= sizeof(TCodecSig)); Y_VERIFY(ReadUnaligned<TCodecSig>(data.Data()) == Sig()); } }; @@ -406,7 +406,7 @@ private: } inline TDataRef GetFromCache(size_t index) const { - Y_VERIFY_DEBUG(index < Cache.size()); + Y_VERIFY_DEBUG(index < Cache.size()); return TDataRef((const char*)&Cache[index], sizeof(TType)); } diff --git a/ydb/core/scheme/scheme_tablecell.h b/ydb/core/scheme/scheme_tablecell.h index bccfdca97db..e7e0a90a95c 100644 --- a/ydb/core/scheme/scheme_tablecell.h +++ b/ydb/core/scheme/scheme_tablecell.h @@ -49,7 +49,7 @@ public: , IsNull_(ptr == nullptr) , Ptr(ptr) { - Y_VERIFY_DEBUG(ptr || sz == 0); + Y_VERIFY_DEBUG(ptr || sz == 0); if (CanInline(sz)) { IsInline_ = 1; IntVal = 0; @@ -101,20 +101,20 @@ public: // Optimization to store small values (<= 8 bytes) inplace static constexpr bool CanInline(ui32 sz) { return sz <= 8; } static constexpr size_t MaxInlineSize() { return 8; } - const char* InlineData() const { Y_VERIFY_DEBUG(IsInline_); return IsNull_ ? nullptr : (char*)&IntVal; } + const char* InlineData() const { Y_VERIFY_DEBUG(IsInline_); return IsNull_ ? nullptr : (char*)&IntVal; } const char* Data() const { return IsNull_ ? nullptr : (IsInline_ ? (char*)&IntVal : Ptr); } #else // Non-inlinable version for perf comparisons static bool CanInline(ui32) { return false; } - const char* InlineData() const { Y_VERIFY_DEBUG(!IsInline_); return Ptr; } - const char* Data() const { Y_VERIFY_DEBUG(!IsInline_); return Ptr; } + const char* InlineData() const { Y_VERIFY_DEBUG(!IsInline_); return Ptr; } + const char* Data() const { Y_VERIFY_DEBUG(!IsInline_); return Ptr; } #endif }; #pragma pack(pop) static_assert(sizeof(TCell) == 12, "TCell must be 12 bytes"); -using TCellsRef = TConstArrayRef<const TCell>; +using TCellsRef = TConstArrayRef<const TCell>; // NULL is considered equal to another NULL and less than non-NULL @@ -131,8 +131,8 @@ inline int CompareTypedCells(const TCell& a, const TCell& b, NScheme::TTypeIdOrd #define SIMPLE_TYPE_SWITCH(typeEnum, castType) \ case NKikimr::NScheme::NTypeIds::typeEnum: \ { \ - Y_VERIFY_DEBUG(a.IsInline()); \ - Y_VERIFY_DEBUG(b.IsInline()); \ + Y_VERIFY_DEBUG(a.IsInline()); \ + Y_VERIFY_DEBUG(b.IsInline()); \ castType va = ReadUnaligned<castType>((const castType*)a.InlineData()); \ castType vb = ReadUnaligned<castType>((const castType*)b.InlineData()); \ return va == vb ? 0 : ((va < vb) != type.IsDescending() ? -1 : 1); \ @@ -189,7 +189,7 @@ inline int CompareTypedCells(const TCell& a, const TCell& b, NScheme::TTypeIdOrd } default: - Y_VERIFY_DEBUG(false, "Unknown type"); + Y_VERIFY_DEBUG(false, "Unknown type"); }; return 0; @@ -210,7 +210,7 @@ inline int CompareTypedCellVectors(const TCell* a, const TCell* b, const TTypeCl // ATTENTION!!! return value is int!! (NOT just -1,0,1) template<class TTypeClass> inline int CompareTypedCellVectors(const TCell* a, const TCell* b, const TTypeClass* type, const ui32 cnt_a, const ui32 cnt_b) { - Y_VERIFY_DEBUG(cnt_b <= cnt_a); + Y_VERIFY_DEBUG(cnt_b <= cnt_a); ui32 i = 0; for (; i < cnt_b; ++i) { int cmpRes = CompareTypedCells(a[i], b[i], type[i]); @@ -448,11 +448,11 @@ public: Y_VERIFY(TryParse(buf, *this)); } - TConstArrayRef<TCell> GetCells() const { + TConstArrayRef<TCell> GetCells() const { return Cells; } - static TString Serialize(const TConstArrayRef<TCell>& cells) { + static TString Serialize(const TConstArrayRef<TCell>& cells) { if (cells.empty()) return TString(); diff --git a/ydb/core/scheme/scheme_tabledefs.cpp b/ydb/core/scheme/scheme_tabledefs.cpp index 8c91e03d0e4..ba2e245f764 100644 --- a/ydb/core/scheme/scheme_tabledefs.cpp +++ b/ydb/core/scheme/scheme_tabledefs.cpp @@ -16,7 +16,7 @@ bool TSerializedTableRange::IsEmpty(TConstArrayRef<NScheme::TTypeId> type) const return (cmp < 0); } -void TKeyDesc::Out(IOutputStream& o, TKeyDesc::EStatus x) { +void TKeyDesc::Out(IOutputStream& o, TKeyDesc::EStatus x) { #define KEYDESCRIPTION_STATUS_TO_STRING_IMPL(name, ...) \ case EStatus::name: \ o << #name; \ diff --git a/ydb/core/scheme/scheme_tabledefs.h b/ydb/core/scheme/scheme_tabledefs.h index 190233fdeee..97d4423fdc9 100644 --- a/ydb/core/scheme/scheme_tabledefs.h +++ b/ydb/core/scheme/scheme_tabledefs.h @@ -617,7 +617,7 @@ public: SCHEME_KEY_DESCRIPTION_STATUS_MAP(ENUM_VALUE_GEN) }; - static void Out(IOutputStream& out, EStatus x); + static void Out(IOutputStream& out, EStatus x); // one column operation (in) struct TColumnOp { diff --git a/ydb/core/scheme_types/scheme_type_metadata.h b/ydb/core/scheme_types/scheme_type_metadata.h index 9c55fcc0a27..1a9d85dd8db 100644 --- a/ydb/core/scheme_types/scheme_type_metadata.h +++ b/ydb/core/scheme_types/scheme_type_metadata.h @@ -39,8 +39,8 @@ public: typedef THashMap<::TString, const ITypeMetadata*> TMapByName; void Register(const ITypeMetadata* metadata) { - Y_VERIFY(MapById.insert({ metadata->GetTypeId(), metadata }).second); - Y_VERIFY(MapByName.insert({ metadata->GetName(), metadata }).second); + Y_VERIFY(MapById.insert({ metadata->GetTypeId(), metadata }).second); + Y_VERIFY(MapByName.insert({ metadata->GetName(), metadata }).second); } const ITypeMetadata* GetType(TTypeId typeId) const { diff --git a/ydb/core/scheme_types/scheme_type_registry.h b/ydb/core/scheme_types/scheme_type_registry.h index a82af192675..c9e619c882f 100644 --- a/ydb/core/scheme_types/scheme_type_registry.h +++ b/ydb/core/scheme_types/scheme_type_registry.h @@ -30,10 +30,10 @@ public: void RegisterType(const IType *type) { const TTypeId typeId = type->GetTypeId(); - Y_VERIFY(typeId <= Max<TTypeId>()); + Y_VERIFY(typeId <= Max<TTypeId>()); - Y_VERIFY(TypeByIdMap.insert({ typeId, type }).second); - Y_VERIFY(TypeByNameMap.insert({ type->GetName(), type }).second); + Y_VERIFY(TypeByIdMap.insert({ typeId, type }).second); + Y_VERIFY(TypeByNameMap.insert({ type->GetName(), type }).second); TypeMetadataRegistry.Register(type); } @@ -43,7 +43,7 @@ public: if (typeId) { auto iter = TypeByIdMap.find(typeId); if (iter != TypeByIdMap.end()) { - Y_VERIFY_DEBUG(iter->second); + Y_VERIFY_DEBUG(iter->second); return iter->second; } } @@ -63,7 +63,7 @@ public: ythrow yexception() << "Type id must be non zero"; auto type = GetType(typeId); - if (Y_LIKELY(type)) + if (Y_LIKELY(type)) return type; ythrow yexception() << "Unknown type: " << typeId; } @@ -75,7 +75,7 @@ public: const IType* GetKnownType(const TStringBuf& name) const { auto type = GetType(name); - if (Y_LIKELY(type)) + if (Y_LIKELY(type)) return type; ythrow yexception() << "Unknown type: " << name; } diff --git a/ydb/core/scheme_types/scheme_types_defs.cpp b/ydb/core/scheme_types/scheme_types_defs.cpp index eeaba2e9af0..59650dc0ff8 100644 --- a/ydb/core/scheme_types/scheme_types_defs.cpp +++ b/ydb/core/scheme_types/scheme_types_defs.cpp @@ -35,7 +35,7 @@ namespace NNames { DECLARE_TYPED_TYPE_NAME(DyNumber); } -void WriteEscapedValue(IOutputStream &out, const char *data, size_t size) { +void WriteEscapedValue(IOutputStream &out, const char *data, size_t size) { static const size_t BUFFER_SIZE = 32; char buffer[BUFFER_SIZE]; size_t bufPos = 0; diff --git a/ydb/core/scheme_types/scheme_types_defs.h b/ydb/core/scheme_types/scheme_types_defs.h index bb06b097023..9bf67384f9e 100644 --- a/ydb/core/scheme_types/scheme_types_defs.h +++ b/ydb/core/scheme_types/scheme_types_defs.h @@ -5,7 +5,7 @@ #include <util/charset/utf8.h> #include <util/generic/hash.h> -#include <util/stream/output.h> // for IOutputStream +#include <util/stream/output.h> // for IOutputStream #include <util/string/ascii.h> #define DECLARE_TYPED_TYPE_NAME(x)\ @@ -164,7 +164,7 @@ namespace NNames { extern const char DyNumber[9]; } -void WriteEscapedValue(IOutputStream &out, const char *data, size_t size); +void WriteEscapedValue(IOutputStream &out, const char *data, size_t size); class TString : public TStringBase<TString, NTypeIds::String, NNames::String> {}; @@ -197,7 +197,7 @@ public: } static TRawTypeValue ToRawTypeValue(const ::TString& value) { - Y_VERIFY(value.size() <= MaxSize); + Y_VERIFY(value.size() <= MaxSize); return TRawTypeValue((const void*)value.data(), value.size(), TypeId); } }; diff --git a/ydb/core/security/ticket_parser_ut.cpp b/ydb/core/security/ticket_parser_ut.cpp index 2b624efefe3..3bc599b50c0 100644 --- a/ydb/core/security/ticket_parser_ut.cpp +++ b/ydb/core/security/ticket_parser_ut.cpp @@ -9,7 +9,7 @@ namespace NKikimr { -Y_UNIT_TEST_SUITE(TTicketParserTest) { +Y_UNIT_TEST_SUITE(TTicketParserTest) { Y_UNIT_TEST(LoginGood) { using namespace Tests; diff --git a/ydb/core/tablet/bootstrapper.cpp b/ydb/core/tablet/bootstrapper.cpp index d2e5dd8b7f3..eb078719ee7 100644 --- a/ydb/core/tablet/bootstrapper.cpp +++ b/ydb/core/tablet/bootstrapper.cpp @@ -210,7 +210,7 @@ class TBootstrapper : public TActor<TBootstrapper> { } void Boot(const TActorContext &ctx) { - Y_VERIFY(!LookOnActorID); + Y_VERIFY(!LookOnActorID); LOG_NOTICE(ctx, NKikimrServices::BOOTSTRAPPER, "tablet: %" PRIu64 ", type: %s, boot", TabletInfo->TabletID, GetTabletTypeName()); @@ -224,7 +224,7 @@ class TBootstrapper : public TActor<TBootstrapper> { LookOnActorID = x->Tablet(TabletInfo.Get(), ctx.SelfID, ctx, 0, AppData(ctx)->ResourceProfiles); } - Y_VERIFY(LookOnActorID); + Y_VERIFY(LookOnActorID); Watched.Reset(new TWatched()); @@ -269,7 +269,7 @@ class TBootstrapper : public TActor<TBootstrapper> { } void BecomeWatch(const TActorId &watchOn, bool owner, const TActorContext &ctx) { - Y_UNUSED(ctx); + Y_UNUSED(ctx); BootDelayedUntil = { }; Round.Destroy(); @@ -325,7 +325,7 @@ class TBootstrapper : public TActor<TBootstrapper> { Round->Aliens[alienNodeIdx] = TRound::TAlien(TRound::EAlienState::Disconnected, Max<ui64>()); return false; default: - Y_FAIL("unhandled case"); + Y_FAIL("unhandled case"); } } @@ -439,7 +439,7 @@ class TBootstrapper : public TActor<TBootstrapper> { void HandleFree(TEvBootstrapper::TEvWatchResult::TPtr &ev, const TActorContext &ctx) { const NKikimrBootstrapper::TEvWatchResult &record = ev->Get()->Record; - Y_VERIFY(record.GetTabletID() == TabletInfo->TabletID); + Y_VERIFY(record.GetTabletID() == TabletInfo->TabletID); if (record.GetRound() != RoundCounter) return; @@ -477,7 +477,7 @@ class TBootstrapper : public TActor<TBootstrapper> { void HandleFree(TEvBootstrapper::TEvWatch::TPtr &ev, const TActorContext &ctx) { const NKikimrBootstrapper::TEvWatch &record = ev->Get()->Record; - Y_VERIFY(record.GetTabletID() == TabletInfo->TabletID); + Y_VERIFY(record.GetTabletID() == TabletInfo->TabletID); ctx.Send(ev->Sender, new TEvBootstrapper::TEvWatchResult(record.GetTabletID(), NKikimrBootstrapper::TEvWatchResult::FREE, SelfSeed, record.GetRound())); } @@ -501,7 +501,7 @@ class TBootstrapper : public TActor<TBootstrapper> { void HandleOwner(TEvBootstrapper::TEvWatch::TPtr &ev, const TActorContext &ctx) { const NKikimrBootstrapper::TEvWatch &record = ev->Get()->Record; - Y_VERIFY(record.GetTabletID() == TabletInfo->TabletID); + Y_VERIFY(record.GetTabletID() == TabletInfo->TabletID); // add to watchers list (if node not already there) Watched->AddWatcher(ev->Sender, record.GetRound()); @@ -510,7 +510,7 @@ class TBootstrapper : public TActor<TBootstrapper> { void HandleWatch(TEvBootstrapper::TEvWatch::TPtr &ev, const TActorContext &ctx) { const NKikimrBootstrapper::TEvWatch &record = ev->Get()->Record; - Y_VERIFY(record.GetTabletID() == TabletInfo->TabletID); + Y_VERIFY(record.GetTabletID() == TabletInfo->TabletID); if (Watches->CheckWatch(ev->Sender.NodeId())) { ctx.Send(ev->Sender, new TEvBootstrapper::TEvWatchResult(record.GetTabletID(), NKikimrBootstrapper::TEvWatchResult::UNKNOWN, 0, record.GetRound())); @@ -534,7 +534,7 @@ class TBootstrapper : public TActor<TBootstrapper> { void HandleStandBy(TEvBootstrapper::TEvWatch::TPtr &ev, const TActorContext &ctx) { const NKikimrBootstrapper::TEvWatch &record = ev->Get()->Record; - Y_VERIFY(record.GetTabletID() == TabletInfo->TabletID); + Y_VERIFY(record.GetTabletID() == TabletInfo->TabletID); ctx.Send(ev->Sender, new TEvBootstrapper::TEvWatchResult(record.GetTabletID(), NKikimrBootstrapper::TEvWatchResult::UNKNOWN, Max<ui64>(), record.GetRound())); } @@ -563,11 +563,11 @@ public: , RoundCounter(0xdeadbeefdeadbeefull) , SelfSeed(0xdeadbeefdeadbeefull) { - Y_VERIFY(TTabletTypes::TYPE_INVALID != TabletInfo->TabletType); + Y_VERIFY(TTabletTypes::TYPE_INVALID != TabletInfo->TabletType); } TAutoPtr<IEventHandle> AfterRegister(const TActorId &selfId, const TActorId &parentId) override { - Y_UNUSED(parentId); + Y_UNUSED(parentId); return new IEventHandle(selfId, selfId, new TEvents::TEvBootstrap()); } diff --git a/ydb/core/tablet/pipe_tracker.cpp b/ydb/core/tablet/pipe_tracker.cpp index cf6e41a97f9..8bde6bf5352 100644 --- a/ydb/core/tablet/pipe_tracker.cpp +++ b/ydb/core/tablet/pipe_tracker.cpp @@ -33,22 +33,22 @@ bool TPipeTrackerBase::DetachTablet(ui64 txid, ui64 tabletid, ui64 cookie) { tabletSet.erase(tabIt); auto multiIt = TxTablets.find(txid); - Y_VERIFY(multiIt != TxTablets.end()); + Y_VERIFY(multiIt != TxTablets.end()); auto& tablets = multiIt->second; auto currIt = tablets.find(tabletid); - Y_VERIFY(currIt != tablets.end()); + Y_VERIFY(currIt != tablets.end()); auto nextIt = currIt; ++nextIt; tablets.erase(currIt); if (nextIt == tablets.end() || *nextIt != tabletid) { if (tabletSet.empty()) { TxToTablet.erase(txIt); - Y_VERIFY(tablets.empty()); + Y_VERIFY(tablets.empty()); TxTablets.erase(multiIt); } auto it = TabletToTx.find(tabletid); - Y_VERIFY(it != TabletToTx.end()); + Y_VERIFY(it != TabletToTx.end()); it->second.erase(txid); if (it->second.empty()) { TabletToTx.erase(it); diff --git a/ydb/core/tablet/pipe_tracker_ut.cpp b/ydb/core/tablet/pipe_tracker_ut.cpp index 2a67c756d5b..72f69683d57 100644 --- a/ydb/core/tablet/pipe_tracker_ut.cpp +++ b/ydb/core/tablet/pipe_tracker_ut.cpp @@ -3,14 +3,14 @@ namespace NKikimr { -Y_UNIT_TEST_SUITE(TPipeTrackerTest) { +Y_UNIT_TEST_SUITE(TPipeTrackerTest) { const ui64 txid1 = 1; const ui64 txid2 = 2; const ui64 txid3 = 3; const ui64 tablet1 = 100; const ui64 tablet2 = 101; - Y_UNIT_TEST(TestSimpleAdd) { + Y_UNIT_TEST(TestSimpleAdd) { TPipeTrackerBase tracker; UNIT_ASSERT(!tracker.IsTxAlive(txid1)); UNIT_ASSERT(tracker.FindTx(tablet1).size() == 0); @@ -27,7 +27,7 @@ Y_UNIT_TEST_SUITE(TPipeTrackerTest) { UNIT_ASSERT(tracker.FindTablets(txid1).size() == 0); } - Y_UNIT_TEST(TestAddSameTabletTwice) { + Y_UNIT_TEST(TestAddSameTabletTwice) { TPipeTrackerBase tracker; UNIT_ASSERT(!tracker.IsTxAlive(txid1)); UNIT_ASSERT(tracker.FindTx(tablet1).size() == 0); @@ -48,7 +48,7 @@ Y_UNIT_TEST_SUITE(TPipeTrackerTest) { UNIT_ASSERT(tracker.FindTx(tablet1).size() == 0); } - Y_UNIT_TEST(TestAddTwoTablets) { + Y_UNIT_TEST(TestAddTwoTablets) { TPipeTrackerBase tracker; UNIT_ASSERT(tracker.FindTx(tablet1).size() == 0); UNIT_ASSERT(tracker.FindTx(tablet2).size() == 0); @@ -70,7 +70,7 @@ Y_UNIT_TEST_SUITE(TPipeTrackerTest) { UNIT_ASSERT(tracker.FindTx(tablet2).size() == 0); } - Y_UNIT_TEST(TestShareTablet) { + Y_UNIT_TEST(TestShareTablet) { TPipeTrackerBase tracker; UNIT_ASSERT(tracker.FindTx(tablet1).size() == 0); tracker.AttachTablet(txid1, tablet1); @@ -105,7 +105,7 @@ Y_UNIT_TEST_SUITE(TPipeTrackerTest) { UNIT_ASSERT(tracker.FindTx(tablet1).size() == 0); } - Y_UNIT_TEST(TestIdempotentAttachDetach) { + Y_UNIT_TEST(TestIdempotentAttachDetach) { TPipeTrackerBase tracker; UNIT_ASSERT(tracker.FindTablets(txid1).size() == 0); tracker.AttachTablet(txid1, tablet1, 5); diff --git a/ydb/core/tablet/resource_broker_ut.cpp b/ydb/core/tablet/resource_broker_ut.cpp index 5948509025b..c1a23f78934 100644 --- a/ydb/core/tablet/resource_broker_ut.cpp +++ b/ydb/core/tablet/resource_broker_ut.cpp @@ -192,8 +192,8 @@ TIntrusivePtr<IResourceBroker> GetInstantResourceBroker(TTestActorRuntime &runti return answer->Get()->ResourceBroker; } -Y_UNIT_TEST_SUITE(TResourceBroker) { - Y_UNIT_TEST(TestErrors) { +Y_UNIT_TEST_SUITE(TResourceBroker) { + Y_UNIT_TEST(TestErrors) { TTestBasicRuntime runtime; SetupTabletServices(runtime); SetupLogging(runtime); @@ -274,7 +274,7 @@ Y_UNIT_TEST_SUITE(TResourceBroker) { WaitForResourceAllocation(runtime, 3, cookie2); }; - Y_UNIT_TEST(TestOverusage) { + Y_UNIT_TEST(TestOverusage) { TTestBasicRuntime runtime; SetupTabletServices(runtime); SetupLogging(runtime); @@ -312,7 +312,7 @@ Y_UNIT_TEST_SUITE(TResourceBroker) { WaitForResourceAllocation(runtime, 2); } - Y_UNIT_TEST(TestExecutionStat) { + Y_UNIT_TEST(TestExecutionStat) { TTestBasicRuntime runtime; SetupTabletServices(runtime); SetupLogging(runtime); @@ -402,7 +402,7 @@ Y_UNIT_TEST_SUITE(TResourceBroker) { WaitForResourceAllocation(runtime, 7); } - Y_UNIT_TEST(TestRealUsage) { + Y_UNIT_TEST(TestRealUsage) { TTestBasicRuntime runtime; SetupTabletServices(runtime); SetupLogging(runtime); @@ -451,7 +451,7 @@ Y_UNIT_TEST_SUITE(TResourceBroker) { WaitForResourceAllocation(runtime, 6); } - Y_UNIT_TEST(TestCounters) { + Y_UNIT_TEST(TestCounters) { TTestBasicRuntime runtime; SetupTabletServices(runtime); SetupLogging(runtime); @@ -546,7 +546,7 @@ Y_UNIT_TEST_SUITE(TResourceBroker) { FinishTask(runtime, brokerId, sender, i); } - Y_UNIT_TEST(TestQueueWithConfigure) { + Y_UNIT_TEST(TestQueueWithConfigure) { TTestBasicRuntime runtime; SetupTabletServices(runtime); SetupLogging(runtime); @@ -604,7 +604,7 @@ Y_UNIT_TEST_SUITE(TResourceBroker) { CheckConfigure(runtime, brokerId, sender, config, true); } - Y_UNIT_TEST(TestRandomQueue) { + Y_UNIT_TEST(TestRandomQueue) { TTestBasicRuntime runtime; SetupTabletServices(runtime); SetupLogging(runtime); @@ -640,7 +640,7 @@ Y_UNIT_TEST_SUITE(TResourceBroker) { CheckCounters(counters, "queue", "total", 0, 0, 1000, 0, 0); } - Y_UNIT_TEST(TestNotifyActorDied) { + Y_UNIT_TEST(TestNotifyActorDied) { TTestBasicRuntime runtime; SetupTabletServices(runtime); SetupLogging(runtime); @@ -679,7 +679,7 @@ Y_UNIT_TEST_SUITE(TResourceBroker) { WaitForResourceAllocation(runtime, 3); } - Y_UNIT_TEST(TestAutoTaskId) { + Y_UNIT_TEST(TestAutoTaskId) { TTestBasicRuntime runtime; SetupTabletServices(runtime); SetupLogging(runtime); @@ -716,7 +716,7 @@ Y_UNIT_TEST_SUITE(TResourceBroker) { WaitForResourceAllocation(runtime, id + 1); } - Y_UNIT_TEST(TestChangeTaskType) { + Y_UNIT_TEST(TestChangeTaskType) { TTestBasicRuntime runtime; SetupTabletServices(runtime); SetupLogging(runtime); @@ -753,7 +753,7 @@ Y_UNIT_TEST_SUITE(TResourceBroker) { WaitForResourceAllocation(runtime, 3); } - Y_UNIT_TEST(TestResubmitTask) { + Y_UNIT_TEST(TestResubmitTask) { TTestBasicRuntime runtime; SetupTabletServices(runtime); SetupLogging(runtime); @@ -799,7 +799,7 @@ Y_UNIT_TEST_SUITE(TResourceBroker) { WaitForResourceAllocation(runtime, 3); } - Y_UNIT_TEST(TestUpdateCookie) { + Y_UNIT_TEST(TestUpdateCookie) { TTestBasicRuntime runtime; SetupTabletServices(runtime); SetupLogging(runtime); diff --git a/ydb/core/tablet/tablet_counters.cpp b/ydb/core/tablet/tablet_counters.cpp index b2ef0d4ad7e..08d76479cba 100644 --- a/ydb/core/tablet/tablet_counters.cpp +++ b/ydb/core/tablet/tablet_counters.cpp @@ -10,13 +10,13 @@ TAutoPtr<TTabletCountersBase> TTabletCountersBase::MakeDiffForAggr(const TTabletCountersBase& baseLine) const { TAutoPtr<TTabletCountersBase> retVal = new TTabletCountersBase(*this); if (baseLine.HasCounters()) { - Y_VERIFY_DEBUG(baseLine.SimpleCounters.Size() == SimpleCounters.Size()); - Y_VERIFY_DEBUG(baseLine.CumulativeCounters.Size() == CumulativeCounters.Size()); - Y_VERIFY_DEBUG(baseLine.PercentileCounters.Size() == PercentileCounters.Size()); + Y_VERIFY_DEBUG(baseLine.SimpleCounters.Size() == SimpleCounters.Size()); + Y_VERIFY_DEBUG(baseLine.CumulativeCounters.Size() == CumulativeCounters.Size()); + Y_VERIFY_DEBUG(baseLine.PercentileCounters.Size() == PercentileCounters.Size()); - Y_VERIFY_DEBUG(baseLine.SimpleCountersMetaInfo == SimpleCountersMetaInfo); - Y_VERIFY_DEBUG(baseLine.CumulativeCountersMetaInfo == CumulativeCountersMetaInfo); - Y_VERIFY_DEBUG(baseLine.PercentileCountersMetaInfo == PercentileCountersMetaInfo); + Y_VERIFY_DEBUG(baseLine.SimpleCountersMetaInfo == SimpleCountersMetaInfo); + Y_VERIFY_DEBUG(baseLine.CumulativeCountersMetaInfo == CumulativeCountersMetaInfo); + Y_VERIFY_DEBUG(baseLine.PercentileCountersMetaInfo == PercentileCountersMetaInfo); retVal->SimpleCounters.AdjustToBaseLine(baseLine.SimpleCounters); retVal->CumulativeCounters.AdjustToBaseLine(baseLine.CumulativeCounters); @@ -63,11 +63,11 @@ TTabletCountersBase::operator = (const TTabletCountersBase& rp) { return *this; } -void TTabletSimpleCounterBase::OutputHtml(IOutputStream &os, const char* name) const { +void TTabletSimpleCounterBase::OutputHtml(IOutputStream &os, const char* name) const { HTML(os) {PRE() {os << name << ": " << Value;}} } -void TTabletPercentileCounter::OutputHtml(IOutputStream &os, const char* name) const { +void TTabletPercentileCounter::OutputHtml(IOutputStream &os, const char* name) const { HTML(os) { DIV_CLASS("row") { DIV_CLASS("col-md-12") {H4() {os << name;}} @@ -85,7 +85,7 @@ void TTabletPercentileCounter::OutputHtml(IOutputStream &os, const char* name) c } } -void TTabletCountersBase::OutputHtml(IOutputStream &os) const { +void TTabletCountersBase::OutputHtml(IOutputStream &os) const { HTML(os) { DIV_CLASS("row") { DIV_CLASS("col-md-12") {OutputHtml(os, "Simple", SimpleCountersMetaInfo, "col-md-3", SimpleCounters);} @@ -98,7 +98,7 @@ void TTabletCountersBase::OutputHtml(IOutputStream &os) const { //////////////////////////////////////////// template<typename T> -void TTabletCountersBase::OutputHtml(IOutputStream &os, const char* sectionName, const char* const* counterNames, const char* counterClass, const TCountersArray<T>& counters) const { +void TTabletCountersBase::OutputHtml(IOutputStream &os, const char* sectionName, const char* const* counterNames, const char* counterClass, const TCountersArray<T>& counters) const { HTML(os) { DIV_CLASS("row") { DIV_CLASS("col-md-12") {H3() {os << sectionName; }} @@ -178,7 +178,7 @@ TTabletLabeledCountersBase::operator = (const TTabletLabeledCountersBase& rp) { return *this; } -void TTabletLabeledCountersBase::OutputHtml(IOutputStream &os) const { +void TTabletLabeledCountersBase::OutputHtml(IOutputStream &os) const { HTML(os) { DIV_CLASS("row") { DIV_CLASS("col-md-12") {H3() {os << Group; }} @@ -229,7 +229,7 @@ void TTabletLabeledCountersBase::AggregateWith(const TTabletLabeledCountersBase& Drop = Drop || rp.Drop; } -IOutputStream& operator <<(IOutputStream& out, const TTabletLabeledCountersBase::EAggregateFunc& func) { +IOutputStream& operator <<(IOutputStream& out, const TTabletLabeledCountersBase::EAggregateFunc& func) { switch(func) { case TTabletLabeledCountersBase::EAF_MIN: out << "EAF_MIN"; diff --git a/ydb/core/tablet/tablet_counters.h b/ydb/core/tablet/tablet_counters.h index a8cc27e9eda..5f9c77f718a 100644 --- a/ydb/core/tablet/tablet_counters.h +++ b/ydb/core/tablet/tablet_counters.h @@ -34,7 +34,7 @@ public: return Value; } - void OutputHtml(IOutputStream &os, const char* name) const; + void OutputHtml(IOutputStream &os, const char* name) const; protected: // @@ -123,7 +123,7 @@ private: SetTo(rp); } void AdjustToBaseLine(const TTabletCumulativeCounter& baseLine) { - Y_VERIFY_DEBUG(Value >= baseLine.Value); + Y_VERIFY_DEBUG(Value >= baseLine.Value); Value -= baseLine.Value; } void SetTo(const TTabletCumulativeCounter& rp) { @@ -202,19 +202,19 @@ public: Populate(rp); } - void OutputHtml(IOutputStream &os, const char* name) const; + void OutputHtml(IOutputStream &os, const char* name) const; private: // void AdjustToBaseLine(const TTabletPercentileCounter& baseLine) { // - Y_VERIFY_DEBUG(RangeCount == baseLine.RangeCount); + Y_VERIFY_DEBUG(RangeCount == baseLine.RangeCount); if (Integral) { return; } for (ui32 i = 0; i < RangeCount; ++i) { - Y_VERIFY_DEBUG(Values[i] >= baseLine.Values[i]); + Y_VERIFY_DEBUG(Values[i] >= baseLine.Values[i]); Values[i] -= baseLine.Values[i]; } } @@ -230,7 +230,7 @@ private: // void SetTo(const TTabletPercentileCounter& rp) { // - Y_VERIFY_DEBUG(RangeCount == rp.RangeCount); + Y_VERIFY_DEBUG(RangeCount == rp.RangeCount); for (ui32 i = 0; i < RangeCount; ++i) { Values[i] = rp.Values[i]; } @@ -238,16 +238,16 @@ private: public: void Initialize(ui32 rangeCount, const TRangeDef* ranges, bool integral) { - Y_VERIFY_DEBUG(!Ranges); - Y_VERIFY_DEBUG(!Values); - Y_VERIFY_DEBUG(rangeCount > 0); - Y_VERIFY_DEBUG(ranges[0].RangeVal == 0); + Y_VERIFY_DEBUG(!Ranges); + Y_VERIFY_DEBUG(!Values); + Y_VERIFY_DEBUG(rangeCount > 0); + Y_VERIFY_DEBUG(ranges[0].RangeVal == 0); RangeCount = rangeCount; Ranges = ranges; Integral = integral; - Y_VERIFY_DEBUG(IsSorted()); + Y_VERIFY_DEBUG(IsSorted()); Values = TArrayHolder<ui64>(new ui64[RangeCount]()); } @@ -331,12 +331,12 @@ public: // T& operator[] (ui32 index) { - Y_ASSERT(index < CountersQnt); + Y_ASSERT(index < CountersQnt); return Counters[index]; } const T& operator[] (ui32 index) const { - Y_ASSERT(index < CountersQnt); + Y_ASSERT(index < CountersQnt); return Counters[index]; } @@ -347,7 +347,7 @@ public: private: // void Reset(const TCountersArray<T>& rp) { - Y_VERIFY(!CountersQnt); + Y_VERIFY(!CountersQnt); CountersHolder.reset(); Counters = nullptr; @@ -364,14 +364,14 @@ private: // void AdjustToBaseLine(const TCountersArray<T>& baseLine) { - Y_VERIFY_DEBUG(baseLine.CountersQnt == CountersQnt); + Y_VERIFY_DEBUG(baseLine.CountersQnt == CountersQnt); for (ui32 i = 0, e = CountersQnt; i < e; ++i) { Counters[i].AdjustToBaseLine(baseLine.Counters[i]); } } void SetTo(const TCountersArray<T>& rp) { - Y_VERIFY_DEBUG(rp.CountersQnt == CountersQnt); + Y_VERIFY_DEBUG(rp.CountersQnt == CountersQnt); for (ui32 i = 0, e = CountersQnt; i < e; ++i) { Counters[i].SetTo(rp.Counters[i]); } @@ -474,7 +474,7 @@ public: void RememberCurrentStateAsBaseline(/*out*/ TTabletCountersBase& baseLine) const; // - void OutputHtml(IOutputStream &os) const; + void OutputHtml(IOutputStream &os) const; void OutputProto(NKikimrTabletBase::TTabletCountersBase& op) const; // @@ -514,7 +514,7 @@ private: // template<typename T> - void OutputHtml(IOutputStream &os, const char* sectionName, const char* const* counterNames, const char* counterClass, const TCountersArray<T>& counters) const; + void OutputHtml(IOutputStream &os, const char* sectionName, const char* const* counterNames, const char* counterClass, const TCountersArray<T>& counters) const; // TCountersArray<TTabletSimpleCounter> SimpleCounters; @@ -627,7 +627,7 @@ public: return AggregateFunc; } - void OutputHtml(IOutputStream &os) const; + void OutputHtml(IOutputStream &os) const; // const char* GetCounterName(ui32 index) const { @@ -665,7 +665,7 @@ private: }; -IOutputStream& operator <<(IOutputStream& out, const TTabletLabeledCountersBase::EAggregateFunc& func); +IOutputStream& operator <<(IOutputStream& out, const TTabletLabeledCountersBase::EAggregateFunc& func); } // end of NKikimr diff --git a/ydb/core/tablet/tablet_counters_aggregator.cpp b/ydb/core/tablet/tablet_counters_aggregator.cpp index 1885b26e09c..ae7cbedfdba 100644 --- a/ydb/core/tablet/tablet_counters_aggregator.cpp +++ b/ydb/core/tablet/tablet_counters_aggregator.cpp @@ -717,7 +717,7 @@ private: TTabletTypes::EType tabletType, const TTabletCountersBase* limitedAppCounters = {}) { - Y_VERIFY(executorCounters); + Y_VERIFY(executorCounters); if (executorCounters) { if (!TabletExecutorCounters.IsInitialized) { @@ -811,7 +811,7 @@ private: {} void Initialize(const TTabletCountersBase* counters) { - Y_VERIFY(!IsInitialized); + Y_VERIFY(!IsInitialized); if (counters) { THashMap<TString, THolder<THistogramCounter>> histogramAggregates; @@ -906,7 +906,7 @@ private: } void Apply(ui64 tabletID, const TTabletCountersBase* counters, TTabletTypes::EType tabletType) { - Y_VERIFY(counters); + Y_VERIFY(counters); TInstant now = TInstant::Now(); auto it = LastAggregateUpdateTime.find(tabletID); @@ -1609,7 +1609,7 @@ TTabletCountersAggregatorActor::Bootstrap(const TActorContext &ctx) { Become(&TThis::StateWork); TAppData* appData = AppData(ctx); - Y_VERIFY(!TabletMon); + Y_VERIFY(!TabletMon); if (AppData(ctx)->FeatureFlags.GetEnableDbCounters() && !Follower) { auto callback = MakeIntrusive<TTabletMon::TTabletsDbWatcherCallback>(ctx.ActorSystem()); @@ -1632,7 +1632,7 @@ TTabletCountersAggregatorActor::Bootstrap(const TActorContext &ctx) { //////////////////////////////////////////// void TTabletCountersAggregatorActor::HandleWork(TEvTabletCounters::TEvTabletAddCounters::TPtr &ev, const TActorContext &ctx) { - Y_UNUSED(ctx); + Y_UNUSED(ctx); TEvTabletCounters::TEvTabletAddCounters* msg = ev->Get(); TabletMon->Apply(msg->TabletID, msg->TabletType, msg->TenantPathId, msg->ExecutorCounters.Get(), msg->AppCounters.Get(), ctx); } @@ -1650,7 +1650,7 @@ TTabletCountersAggregatorActor::HandleWork(TEvTabletCounters::TEvTabletAddLabele //////////////////////////////////////////// void TTabletCountersAggregatorActor::HandleWork(TEvTabletCounters::TEvTabletCountersForgetTablet::TPtr &ev, const TActorContext &ctx) { - Y_UNUSED(ctx); + Y_UNUSED(ctx); TEvTabletCounters::TEvTabletCountersForgetTablet* msg = ev->Get(); TabletMon->ForgetTablet(msg->TabletID, msg->TabletType, msg->TenantPathId); } @@ -1831,7 +1831,7 @@ TTabletCountersAggregatorActor::HandleWakeup(const TActorContext &ctx) { /// public state functions //////////////////////////////////////////// STFUNC(TTabletCountersAggregatorActor::StateWork) { - Y_UNUSED(ctx); + Y_UNUSED(ctx); switch (ev->GetTypeRewrite()) { HFunc(TEvTabletCounters::TEvTabletAddCounters, HandleWork); HFunc(TEvTabletCounters::TEvTabletCountersForgetTablet, HandleWork); diff --git a/ydb/core/tablet/tablet_counters_aggregator_ut.cpp b/ydb/core/tablet/tablet_counters_aggregator_ut.cpp index 707ffb977ee..e8e2452e035 100644 --- a/ydb/core/tablet/tablet_counters_aggregator_ut.cpp +++ b/ydb/core/tablet/tablet_counters_aggregator_ut.cpp @@ -85,8 +85,8 @@ void TestHeavy(const ui32 v, ui32 numWorkers) { } -Y_UNIT_TEST_SUITE(TTabletCountersAggregator) { - Y_UNIT_TEST(SimpleAggregation) { +Y_UNIT_TEST_SUITE(TTabletCountersAggregator) { + Y_UNIT_TEST(SimpleAggregation) { TVector<TActorId> cc; TActorId aggregatorId; @@ -177,7 +177,7 @@ Y_UNIT_TEST_SUITE(TTabletCountersAggregator) { } - Y_UNIT_TEST(HeavyAggregation) { + Y_UNIT_TEST(HeavyAggregation) { TestHeavy(2, 10); TestHeavy(2, 20); TestHeavy(2, 1); diff --git a/ydb/core/tablet/tablet_counters_protobuf.h b/ydb/core/tablet/tablet_counters_protobuf.h index 11d3a334def..12c20e608b1 100644 --- a/ydb/core/tablet/tablet_counters_protobuf.h +++ b/ydb/core/tablet/tablet_counters_protobuf.h @@ -33,7 +33,7 @@ public: // Parse protobuf options for enum values for app counters for (int i = 0; i < appDesc->value_count(); i++) { const NProtoBuf::EnumValueDescriptor* vdesc = appDesc->value(i); - Y_VERIFY(vdesc->number() == vdesc->index(), "counter '%s' number (%d) != index (%d)", + Y_VERIFY(vdesc->number() == vdesc->index(), "counter '%s' number (%d) != index (%d)", vdesc->full_name().c_str(), vdesc->number(), vdesc->index()); if (!vdesc->options().HasExtension(CounterOpts)) { NamesStrings.emplace_back(); // empty name @@ -141,7 +141,7 @@ public: for (int j = 0; j < typesDesc->value_count(); j++) { const NProtoBuf::EnumValueDescriptor* tt = typesDesc->value(j); TTxType txType = tt->number(); - Y_VERIFY((int)txType == tt->index(), "tx type '%s' number (%d) != index (%d)", + Y_VERIFY((int)txType == tt->index(), "tx type '%s' number (%d) != index (%d)", tt->full_name().c_str(), txType, tt->index()); Y_VERIFY(tt->options().HasExtension(TxTypeOpts), "tx type '%s' number (%d) is missing TxTypeOpts", tt->full_name().c_str(), txType); @@ -149,7 +149,7 @@ public: TString txPrefix = tto.GetName() + "/"; for (int i = 0; i < txDesc->value_count(); i++) { const NProtoBuf::EnumValueDescriptor* v = txDesc->value(i); - Y_VERIFY(v->number() == v->index(), "counter '%s' number (%d) != index (%d)", + Y_VERIFY(v->number() == v->index(), "counter '%s' number (%d) != index (%d)", v->full_name().c_str(), v->number(), v->index()); if (!v->options().HasExtension(CounterOpts)) { NamesStrings.emplace_back(); // empty name @@ -181,7 +181,7 @@ public: virtual const TVector<TTabletPercentileCounter::TRangeDef>& GetRanges(size_t idx) const { - Y_VERIFY(idx < Size); + Y_VERIFY(idx < Size); if (!Ranges[idx].empty()) { return Ranges[idx]; } else { @@ -408,9 +408,9 @@ protected: size_t IndexOf(TTxType txType, ui32 txCounter) const { // Note that enum values are used only inside a process, not on disc/messages // so there are no backward compatibility issues - Y_VERIFY(txCounter < TxCountersSize[counterType]); + Y_VERIFY(txCounter < TxCountersSize[counterType]); size_t ret = TxOffset[counterType] + txType * TxCountersSize[counterType] + txCounter; - Y_VERIFY(ret < Size[counterType]); + Y_VERIFY(ret < Size[counterType]); return ret; } }; diff --git a/ydb/core/tablet/tablet_impl.h b/ydb/core/tablet/tablet_impl.h index b47b1f10971..29db4dfbee5 100644 --- a/ydb/core/tablet/tablet_impl.h +++ b/ydb/core/tablet/tablet_impl.h @@ -93,7 +93,7 @@ struct TEvTabletBase { , BlockedGeneration(0) , ErrorReason(reason) { - Y_VERIFY_DEBUG(status != NKikimrProto::OK); + Y_VERIFY_DEBUG(status != NKikimrProto::OK); } TEvFindLatestLogEntryResult(const TLogoBlobID &latest, ui32 blockedGeneration, const TString &buffer) diff --git a/ydb/core/tablet/tablet_list_renderer.cpp b/ydb/core/tablet/tablet_list_renderer.cpp index ad36f12a291..ae221bfc812 100644 --- a/ydb/core/tablet/tablet_list_renderer.cpp +++ b/ydb/core/tablet/tablet_list_renderer.cpp @@ -61,7 +61,7 @@ void TTabletListRenderer::RenderHeader(TStringStream& str, const TTabletFilterInfo& filterInfo) { Y_UNUSED(tabletsToRender); - IOutputStream &__stream(str); + IOutputStream &__stream(str); H3() { str << listName; if (filterInfo.FilterNodeId != 0) { @@ -79,7 +79,7 @@ void TTabletListRenderer::RenderTableHeader(TStringStream& str, { Y_UNUSED(listName); Y_UNUSED(tabletsToRender); - IOutputStream &__stream(str); + IOutputStream &__stream(str); TABLEHEAD() { TABLER() { if (filterInfo.FilterNodeId == 0) { @@ -123,7 +123,7 @@ void TTabletListRenderer::RenderTableBody(TStringStream& str, const TTabletFilterInfo& filterInfo) { Y_UNUSED(listName); - IOutputStream &__stream(str); + IOutputStream &__stream(str); TABLEBODY() { for (const auto& elem : tabletsToRender) { const auto& ti = *elem.TabletStateInfo; @@ -181,7 +181,7 @@ void TTabletListRenderer::RenderTabletList(TStringStream& str, const TVector<TTabletListElement>& tabletsToRender, const TTabletFilterInfo& filterInfo) { - IOutputStream &__stream(str); + IOutputStream &__stream(str); RenderHeader(str, listName, tabletsToRender, filterInfo); TABLE_SORTABLE_CLASS("table") { diff --git a/ydb/core/tablet/tablet_metrics_ut.cpp b/ydb/core/tablet/tablet_metrics_ut.cpp index 57cab15a5d6..bb82d8ad71a 100644 --- a/ydb/core/tablet/tablet_metrics_ut.cpp +++ b/ydb/core/tablet/tablet_metrics_ut.cpp @@ -5,8 +5,8 @@ namespace NKikimr { namespace NMetrics { -Y_UNIT_TEST_SUITE(TFlatMetrics) { - Y_UNIT_TEST(TimeSeriesAvg4) { +Y_UNIT_TEST_SUITE(TFlatMetrics) { + Y_UNIT_TEST(TimeSeriesAvg4) { TTimeSeriesValue<ui64, TDuration::Minutes(1).GetValue(), 4> value; TInstant time = TInstant::Now(); @@ -32,7 +32,7 @@ Y_UNIT_TEST_SUITE(TFlatMetrics) { UNIT_ASSERT_C(avg >= 60 && avg <= 80, avg); } - Y_UNIT_TEST(TimeSeriesAvg16) { + Y_UNIT_TEST(TimeSeriesAvg16) { TTimeSeriesValue<ui64, TDuration::Minutes(1).GetValue(), 16> value; TInstant time = TInstant::Now(); @@ -58,7 +58,7 @@ Y_UNIT_TEST_SUITE(TFlatMetrics) { UNIT_ASSERT_C(avg >= 60 && avg <= 65, avg); } - Y_UNIT_TEST(TimeSeriesAvg16x60) { + Y_UNIT_TEST(TimeSeriesAvg16x60) { TTimeSeriesValue<ui64, TDuration::Minutes(1).GetValue(), 16> value; TInstant time = TInstant::Now(); @@ -70,7 +70,7 @@ Y_UNIT_TEST_SUITE(TFlatMetrics) { UNIT_ASSERT_C(avg >= 55 && avg <= 65, avg); } - Y_UNIT_TEST(TimeSeriesAvg16Signed) { + Y_UNIT_TEST(TimeSeriesAvg16Signed) { TTimeSeriesValue<i64, TDuration::Minutes(1).GetValue(), 16> value; TInstant time = TInstant::Now(); @@ -96,7 +96,7 @@ Y_UNIT_TEST_SUITE(TFlatMetrics) { UNIT_ASSERT_C(avg >= 0 && avg <= 15, avg); } - Y_UNIT_TEST(TimeSeriesKV) { + Y_UNIT_TEST(TimeSeriesKV) { TTimeSeriesValue<i64> value; TInstant time = TInstant::Now(); TVector<i64> values = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,7476717,0,529363,-1065564}; @@ -109,7 +109,7 @@ Y_UNIT_TEST_SUITE(TFlatMetrics) { UNIT_ASSERT_C(avg >= 112 && avg <= 114, avg); } - Y_UNIT_TEST(TimeSeriesKV2) { + Y_UNIT_TEST(TimeSeriesKV2) { TTimeSeriesValue<i64> value; TInstant time = TInstant::Now(); TVector<i64> values = {0,0,0,0,1502,0,-64006,-100840,-151185,-4088398,-169038,-167227,-74841,-111563,-107191,-146359,-107399,-195925,-140440,-173191,-30211,-128287,-185191,-140449}; @@ -122,7 +122,7 @@ Y_UNIT_TEST_SUITE(TFlatMetrics) { UNIT_ASSERT_C(avg < 0, avg); } - Y_UNIT_TEST(TimeSeriesAVG) { + Y_UNIT_TEST(TimeSeriesAVG) { TTimeSeriesValue<i64, 1000000ull * 60 * 5, 20> value; TInstant time = TInstant::Now(); time -= TDuration::Seconds(2); @@ -133,7 +133,7 @@ Y_UNIT_TEST_SUITE(TFlatMetrics) { UNIT_ASSERT_C(avg == 400, avg); } - Y_UNIT_TEST(DecayingAverageAvg) { + Y_UNIT_TEST(DecayingAverageAvg) { TDecayingAverageValue<ui64, NMetrics::DurationPerMinute> value; TInstant time = TInstant::Now(); diff --git a/ydb/core/tablet/tablet_monitoring_proxy.cpp b/ydb/core/tablet/tablet_monitoring_proxy.cpp index a61a43b7e5c..f6832ab34e5 100644 --- a/ydb/core/tablet/tablet_monitoring_proxy.cpp +++ b/ydb/core/tablet/tablet_monitoring_proxy.cpp @@ -75,7 +75,7 @@ public: } void Handle(TEvTabletPipe::TEvClientDestroyed::TPtr &ev, const TActorContext &ctx) { - Y_UNUSED(ev); + Y_UNUSED(ev); Notify(ctx, "Tablet pipe is reset"); Die(ctx); } diff --git a/ydb/core/tablet/tablet_pipe_client.cpp b/ydb/core/tablet/tablet_pipe_client.cpp index 2fa35af9a0e..10d846b9bf3 100644 --- a/ydb/core/tablet/tablet_pipe_client.cpp +++ b/ydb/core/tablet/tablet_pipe_client.cpp @@ -40,7 +40,7 @@ namespace NTabletPipe { , PayloadQueue(new TPayloadQueue()) , Leader(true) { - Y_VERIFY(tabletId != 0); + Y_VERIFY(tabletId != 0); } void Bootstrap(const TActorContext& ctx) { @@ -143,7 +143,7 @@ namespace NTabletPipe { void HandleSend(TAutoPtr<IEventHandle>& ev, const TActorContext& ctx) { BLOG_D("send"); - Y_VERIFY(!IsShutdown); + Y_VERIFY(!IsShutdown); Push(ctx, ev); } @@ -324,7 +324,7 @@ namespace NTabletPipe { } void Handle(TEvents::TEvUndelivered::TPtr& ev, const TActorContext& ctx) { - Y_UNUSED(ev); + Y_UNUSED(ev); BLOG_D("pipe event not delivered, drop pipe"); return NotifyDisconnect(ctx); } @@ -336,7 +336,7 @@ namespace NTabletPipe { return; } - Y_VERIFY(ev->Get()->Record.GetTabletId() == TabletId); + Y_VERIFY(ev->Get()->Record.GetTabletId() == TabletId); BLOG_D("peer closed"); return NotifyDisconnect(ctx); } @@ -352,7 +352,7 @@ namespace NTabletPipe { void HandleConnect(TEvents::TEvPoisonPill::TPtr& ev, const TActorContext& ctx) { BLOG_D("poison pill while connecting"); - Y_UNUSED(ev); + Y_UNUSED(ev); if (ServerId) ctx.Send(ServerId, new TEvTabletPipe::TEvPeerClosed(TabletId, ctx.SelfID, ServerId)); @@ -360,7 +360,7 @@ namespace NTabletPipe { } void Handle(TEvents::TEvPoisonPill::TPtr& ev, const TActorContext& ctx) { - Y_UNUSED(ev); + Y_UNUSED(ev); BLOG_D("received poison pill"); ctx.Send(ServerId, new TEvTabletPipe::TEvPeerClosed(TabletId, ctx.SelfID, ServerId)); return NotifyDisconnect(ctx); diff --git a/ydb/core/tablet/tablet_pipe_client_cache.cpp b/ydb/core/tablet/tablet_pipe_client_cache.cpp index 47b81e45681..6e3eefb9335 100644 --- a/ydb/core/tablet/tablet_pipe_client_cache.cpp +++ b/ydb/core/tablet/tablet_pipe_client_cache.cpp @@ -61,8 +61,8 @@ namespace NTabletPipe { } void EvictionCallback(const ui64& key, TClientCacheEntry& value, ui64 size) { - Y_UNUSED(key); - Y_UNUSED(size); + Y_UNUSED(key); + Y_UNUSED(size); if (!value.Client) return; @@ -111,7 +111,7 @@ namespace NTabletPipe { } void Detach(const TActorContext& ctx) override { - Y_UNUSED(ctx); + Y_UNUSED(ctx); Container->Clear(); if (PoolContainer) { PoolContainer->Clear(); @@ -141,7 +141,7 @@ namespace NTabletPipe { } void Close(const TActorContext& ctx, ui64 tabletId) override { - Y_UNUSED(ctx); + Y_UNUSED(ctx); Container->Erase(tabletId); if (PoolContainer) PoolContainer->Erase(tabletId); @@ -184,7 +184,7 @@ namespace NTabletPipe { void MoveToPool(ui64 tabletId, const TClientCacheEntry& currentClient) { TClientCacheEntry* insertedClient; if (!PoolContainer->Insert(tabletId, currentClient, insertedClient)) { - Y_VERIFY_DEBUG(!insertedClient->Client); + Y_VERIFY_DEBUG(!insertedClient->Client); *insertedClient = currentClient; } @@ -194,7 +194,7 @@ namespace NTabletPipe { void Erase(ui64 tabletId, const TActorId& clientId) { TClientCacheEntry* currentClient; if (Container->Find(tabletId, currentClient)) { - Y_VERIFY_DEBUG(!!currentClient->Client); + Y_VERIFY_DEBUG(!!currentClient->Client); if (!clientId || (currentClient->Client == clientId)) Container->Erase(tabletId); } diff --git a/ydb/core/tablet/tablet_pipe_server.cpp b/ydb/core/tablet/tablet_pipe_server.cpp index b7c669e72cc..f07ff786366 100644 --- a/ydb/core/tablet/tablet_pipe_server.cpp +++ b/ydb/core/tablet/tablet_pipe_server.cpp @@ -26,7 +26,7 @@ namespace NTabletPipe { , Leader(true) , Connected(false) { - Y_VERIFY(tabletId != 0); + Y_VERIFY(tabletId != 0); } private: @@ -62,7 +62,7 @@ namespace NTabletPipe { } void Handle(TEvTabletPipe::TEvPush::TPtr& ev, const TActorContext& ctx) { - Y_VERIFY(ev->Get()->Record.GetTabletId() == TabletId); + Y_VERIFY(ev->Get()->Record.GetTabletId() == TabletId); const auto& record = ev->Get()->Record; const TActorId sender = ActorIdFromProto(record.GetSender()); LOG_DEBUG_S(ctx, NKikimrServices::PIPE_SERVER, "[" << TabletId << "]" @@ -161,13 +161,13 @@ namespace NTabletPipe { } void Handle(TEvents::TEvPoisonPill::TPtr& ev, const TActorContext& ctx) { - Y_UNUSED(ev); + Y_UNUSED(ev); SendToClient(ctx, new TEvTabletPipe::TEvPeerClosed(TabletId, ClientId, ctx.SelfID)); Reset(ctx); } void Handle(TEvTabletPipe::TEvPeerClosed::TPtr& ev, const TActorContext& ctx) { - Y_VERIFY(ev->Get()->Record.GetTabletId() == TabletId); + Y_VERIFY(ev->Get()->Record.GetTabletId() == TabletId); LOG_DEBUG_S(ctx, NKikimrServices::PIPE_SERVER, "[" << TabletId << "]" << " Got PeerClosed from# " << ev->Sender); Reset(ctx); @@ -204,7 +204,7 @@ namespace NTabletPipe { } void Handle(TEvInterconnect::TEvNodeConnected::TPtr& ev, const TActorContext& ctx) { - Y_UNUSED(ev); + Y_UNUSED(ev); OnConnected(ctx); } @@ -264,7 +264,7 @@ namespace NTabletPipe { } TActorId Accept(TEvTabletPipe::TEvConnect::TPtr &ev, TActorIdentity owner, TActorId recipientId, bool leader) override { - Y_VERIFY(ev->Get()->Record.GetTabletId() == TabletId); + Y_VERIFY(ev->Get()->Record.GetTabletId() == TabletId); const TActorId clientId = ActorIdFromProto(ev->Get()->Record.GetClientId()); IActor* server = CreateServer(TabletId, clientId, ev->InterconnectSession, ev->Get()->Record.GetFeatures(), ev->Cookie); TActorId serverId = TActivationContext::Register(server); @@ -276,7 +276,7 @@ namespace NTabletPipe { } void Reject(TEvTabletPipe::TEvConnect::TPtr &ev, TActorIdentity owner, NKikimrProto::EReplyStatus status, bool leader) override { - Y_VERIFY(ev->Get()->Record.GetTabletId() == TabletId); + Y_VERIFY(ev->Get()->Record.GetTabletId() == TabletId); const TActorId clientId = ActorIdFromProto(ev->Get()->Record.GetClientId()); LOG_DEBUG_S(*TlsActivationContext, NKikimrServices::PIPE_SERVER, "[" << TabletId << "]" << " Reject Connect Originator# " << ev->Sender); @@ -304,7 +304,7 @@ namespace NTabletPipe { TActorId Enqueue(TEvTabletPipe::TEvConnect::TPtr &ev, TActorIdentity owner) override { Y_UNUSED(owner); - Y_VERIFY(ev->Get()->Record.GetTabletId() == TabletId); + Y_VERIFY(ev->Get()->Record.GetTabletId() == TabletId); const TActorId clientId = ActorIdFromProto(ev->Get()->Record.GetClientId()); IActor* server = CreateServer(TabletId, clientId, ev->InterconnectSession, ev->Get()->Record.GetFeatures(), ev->Cookie); TActorId serverId = TActivationContext::Register(server); diff --git a/ydb/core/tablet/tablet_pipe_ut.cpp b/ydb/core/tablet/tablet_pipe_ut.cpp index 2a528070fb6..d35a4b9c3ab 100644 --- a/ydb/core/tablet/tablet_pipe_ut.cpp +++ b/ydb/core/tablet/tablet_pipe_ut.cpp @@ -119,7 +119,7 @@ namespace NKikimr { } void Handle(TEvTabletPipe::TEvClientConnected::TPtr &ev, const TActorContext &ctx) { - Y_UNUSED(ctx); + Y_UNUSED(ctx); Cout << "Open " << ((ev->Get()->Status == NKikimrProto::OK) ? "ok" : "ERROR") << "\n"; if (ev->Get()->Status == NKikimrProto::OK) { IsOpened = true; @@ -142,13 +142,13 @@ namespace NKikimr { } void Handle(TEvents::TEvPong::TPtr &ev, const TActorContext &ctx) { - Y_UNUSED(ev); - Y_UNUSED(ctx); + Y_UNUSED(ev); + Y_UNUSED(ctx); Cout << "Got pong\n"; } void Handle(TEvents::TEvPoisonPill::TPtr &ev, const TActorContext &ctx) { - Y_UNUSED(ev); + Y_UNUSED(ev); ctx.Send(Tablet(), new TEvents::TEvPoisonPill); } @@ -164,14 +164,14 @@ namespace NKikimr { } void OnTabletDead(TEvTablet::TEvTabletDead::TPtr &ev, const TActorContext &ctx) override { - Y_UNUSED(ev); + Y_UNUSED(ev); Cout << "Producer dead\n"; NTabletPipe::CloseClient(ctx, ClientId); return Die(ctx); } void OnActivateExecutor(const TActorContext &ctx) override { - Y_UNUSED(ctx); + Y_UNUSED(ctx); Become(&TThis::StateWork); Cout << "Producer loaded\n"; } @@ -271,32 +271,32 @@ namespace NKikimr { } void Handle(TEvents::TEvPoisonPill::TPtr &ev, const TActorContext &ctx) { - Y_UNUSED(ev); + Y_UNUSED(ev); ctx.Send(Tablet(), new TEvents::TEvPoisonPill); } void Handle(TEvTabletPipe::TEvServerConnected::TPtr &ev, const TActorContext &ctx) { - Y_UNUSED(ev); - Y_UNUSED(ctx); + Y_UNUSED(ev); + Y_UNUSED(ctx); Cout << "Server pipe is opened\n"; ++ServerPipesOpened; } void Handle(TEvTabletPipe::TEvServerDisconnected::TPtr &ev, const TActorContext &ctx) { - Y_UNUSED(ev); - Y_UNUSED(ctx); + Y_UNUSED(ev); + Y_UNUSED(ctx); Cout << "Pipe reset on server\n"; ++ServerPipesClosed; } void Handle(TEvTabletPipe::TEvServerDestroyed::TPtr &ev, const TActorContext &ctx) { - Y_UNUSED(ctx); + Y_UNUSED(ctx); PipeConnectAcceptor->Erase(ev); Cout << "Cleanup of pipe reset on server\n"; } void Handle(TEvConsumerTablet::TEvReject::TPtr &ev, const TActorContext &) { - Y_UNUSED(ev); + Y_UNUSED(ev); Cout << "Drop & reject all connects\n"; PipeConnectAcceptor->Detach(SelfId()); RejectAll = true; @@ -315,7 +315,7 @@ namespace NKikimr { void OnTabletDead(TEvTablet::TEvTabletDead::TPtr &ev, const TActorContext &ctx) override { Cout << "Consumer dead\n"; - Y_UNUSED(ev); + Y_UNUSED(ev); PipeConnectAcceptor->Detach(SelfId()); return Die(ctx); } @@ -343,7 +343,7 @@ namespace NKikimr { private: void OnActivateExecutor(const TActorContext& ctx) override { - Y_UNUSED(ctx); + Y_UNUSED(ctx); Become(&TThis::StateWork); Cout << "Consumer loaded\n"; } @@ -371,19 +371,19 @@ namespace NKikimr { } void Handle(TEvents::TEvPoisonPill::TPtr &ev, const TActorContext &ctx) { - Y_UNUSED(ev); + Y_UNUSED(ev); ctx.Send(Tablet(), new TEvents::TEvPoisonPill); } void Handle(TEvTabletPipe::TEvServerConnected::TPtr &ev, const TActorContext &ctx) { - Y_UNUSED(ev); - Y_UNUSED(ctx); + Y_UNUSED(ev); + Y_UNUSED(ctx); Cout << "Server pipe is opened\n"; } void Handle(TEvTabletPipe::TEvServerDisconnected::TPtr &ev, const TActorContext &ctx) { - Y_UNUSED(ev); - Y_UNUSED(ctx); + Y_UNUSED(ev); + Y_UNUSED(ctx); Cout << "Pipe reset on server\n"; } @@ -394,13 +394,13 @@ namespace NKikimr { void OnTabletDead(TEvTablet::TEvTabletDead::TPtr &ev, const TActorContext &ctx) override { Cout << "Consumer dead\n"; - Y_UNUSED(ev); + Y_UNUSED(ev); return Die(ctx); } }; -Y_UNIT_TEST_SUITE(TTabletPipeTest) { - Y_UNIT_TEST(TestOpen) { +Y_UNIT_TEST_SUITE(TTabletPipeTest) { + Y_UNIT_TEST(TestOpen) { TTestBasicRuntime runtime; SetupTabletServices(runtime); @@ -440,7 +440,7 @@ Y_UNIT_TEST_SUITE(TTabletPipeTest) { } } - Y_UNIT_TEST(TestSendWithoutWaitOpen) { + Y_UNIT_TEST(TestSendWithoutWaitOpen) { TTestBasicRuntime runtime; SetupTabletServices(runtime); @@ -467,7 +467,7 @@ Y_UNIT_TEST_SUITE(TTabletPipeTest) { } } - Y_UNIT_TEST(TestKillClientBeforServerIdKnown) { + Y_UNIT_TEST(TestKillClientBeforServerIdKnown) { TTestBasicRuntime runtime; SetupTabletServices(runtime); runtime.SetLogPriority(NKikimrServices::PIPE_SERVER, NActors::NLog::PRI_DEBUG); @@ -511,7 +511,7 @@ Y_UNIT_TEST_SUITE(TTabletPipeTest) { } } - Y_UNIT_TEST(TestSendWithoutWaitOpenToWrongTablet) { + Y_UNIT_TEST(TestSendWithoutWaitOpenToWrongTablet) { TTestBasicRuntime runtime; SetupTabletServices(runtime); @@ -538,7 +538,7 @@ Y_UNIT_TEST_SUITE(TTabletPipeTest) { } } - Y_UNIT_TEST(TestSendAfterOpen) { + Y_UNIT_TEST(TestSendAfterOpen) { TTestBasicRuntime runtime; SetupTabletServices(runtime); @@ -571,7 +571,7 @@ Y_UNIT_TEST_SUITE(TTabletPipeTest) { } } - Y_UNIT_TEST(TestSendAfterReboot) { + Y_UNIT_TEST(TestSendAfterReboot) { TTestBasicRuntime runtime; SetupTabletServices(runtime); @@ -621,7 +621,7 @@ Y_UNIT_TEST_SUITE(TTabletPipeTest) { } } - Y_UNIT_TEST(TestConsumerSidePipeReset) { + Y_UNIT_TEST(TestConsumerSidePipeReset) { TTestBasicRuntime runtime; SetupTabletServices(runtime); @@ -655,7 +655,7 @@ Y_UNIT_TEST_SUITE(TTabletPipeTest) { } } - Y_UNIT_TEST(TestConnectReject) { + Y_UNIT_TEST(TestConnectReject) { TTestBasicRuntime runtime; SetupTabletServices(runtime); @@ -682,7 +682,7 @@ Y_UNIT_TEST_SUITE(TTabletPipeTest) { } } - Y_UNIT_TEST(TestSendAfterOpenUsingTabletWithoutAcceptor) { + Y_UNIT_TEST(TestSendAfterOpenUsingTabletWithoutAcceptor) { TTestBasicRuntime runtime; SetupTabletServices(runtime); @@ -715,7 +715,7 @@ Y_UNIT_TEST_SUITE(TTabletPipeTest) { } } - Y_UNIT_TEST(TestRebootUsingTabletWithoutAcceptor) { + Y_UNIT_TEST(TestRebootUsingTabletWithoutAcceptor) { TTestBasicRuntime runtime; SetupTabletServices(runtime); @@ -766,7 +766,7 @@ Y_UNIT_TEST_SUITE(TTabletPipeTest) { } } - Y_UNIT_TEST(TestShutdown) { + Y_UNIT_TEST(TestShutdown) { TTestBasicRuntime runtime; SetupTabletServices(runtime); @@ -793,7 +793,7 @@ Y_UNIT_TEST_SUITE(TTabletPipeTest) { } } - Y_UNIT_TEST(TestTwoNodes) { + Y_UNIT_TEST(TestTwoNodes) { TTestBasicRuntime runtime(2); SetupTabletServices(runtime); @@ -826,7 +826,7 @@ Y_UNIT_TEST_SUITE(TTabletPipeTest) { } } - Y_UNIT_TEST(TestClientDisconnectAfterPipeOpen) { + Y_UNIT_TEST(TestClientDisconnectAfterPipeOpen) { TTestBasicRuntime runtime(2); SetupTabletServices(runtime); @@ -852,7 +852,7 @@ Y_UNIT_TEST_SUITE(TTabletPipeTest) { } TActorId proxy = runtime.GetInterconnectProxy(0, 1); - Y_VERIFY(proxy); + Y_VERIFY(proxy); runtime.Send(new IEventHandle(proxy, sender1, new TEvInterconnect::TEvConnectNode), 0); TAutoPtr<IEventHandle> handle; runtime.GrabEdgeEvent<TEvInterconnect::TEvNodeConnected>(handle); @@ -874,7 +874,7 @@ Y_UNIT_TEST_SUITE(TTabletPipeTest) { } } - Y_UNIT_TEST(TestSendBeforeBootTarget) { + Y_UNIT_TEST(TestSendBeforeBootTarget) { TTestBasicRuntime runtime; SetupTabletServices(runtime); TActorId sender = runtime.AllocateEdgeActor(); @@ -931,7 +931,7 @@ Y_UNIT_TEST_SUITE(TTabletPipeTest) { } } - Y_UNIT_TEST(TestTwoNodesAndRebootOfProducer) { + Y_UNIT_TEST(TestTwoNodesAndRebootOfProducer) { TTestBasicRuntime runtime(2); SetupTabletServices(runtime); @@ -980,7 +980,7 @@ Y_UNIT_TEST_SUITE(TTabletPipeTest) { } } - Y_UNIT_TEST(TestTwoNodesAndRebootOfConsumer) { + Y_UNIT_TEST(TestTwoNodesAndRebootOfConsumer) { TTestBasicRuntime runtime(2); SetupTabletServices(runtime); runtime.SetLogPriority(NActorsServices::INTERCONNECT, NActors::NLog::PRI_DEBUG); diff --git a/ydb/core/tablet/tablet_req_findlatest.cpp b/ydb/core/tablet/tablet_req_findlatest.cpp index ca3d09aa432..87cdd59825b 100644 --- a/ydb/core/tablet/tablet_req_findlatest.cpp +++ b/ydb/core/tablet/tablet_req_findlatest.cpp @@ -80,7 +80,7 @@ public: , ChannelInfo(Info->ChannelInfo(0)) , CurrentHistoryIndex(ChannelInfo->History.size()) { - Y_VERIFY(CurrentHistoryIndex > 0); + Y_VERIFY(CurrentHistoryIndex > 0); } void Bootstrap() { diff --git a/ydb/core/tablet/tablet_req_rebuildhistory.cpp b/ydb/core/tablet/tablet_req_rebuildhistory.cpp index c0b4c0c2bc1..06fac1f2d97 100644 --- a/ydb/core/tablet/tablet_req_rebuildhistory.cpp +++ b/ydb/core/tablet/tablet_req_rebuildhistory.cpp @@ -67,7 +67,7 @@ class TTabletReqRebuildHistoryGraph : public TActorBootstrapped<TTabletReqRebuil Status = StatusOk; break; default: - Y_FAIL(); + Y_FAIL(); } } @@ -87,7 +87,7 @@ class TTabletReqRebuildHistoryGraph : public TActorBootstrapped<TTabletReqRebuil case StatusMustBeIgnoredBody: break; default: - Y_FAIL(); + Y_FAIL(); } } @@ -108,8 +108,8 @@ class TTabletReqRebuildHistoryGraph : public TActorBootstrapped<TTabletReqRebuil IsSnapshot = x.GetIsSnapshot(); if (x.HasEmbeddedLogBody()) { - Y_VERIFY(References.empty(), "must not mix embedded and referenced log bodies"); - Y_VERIFY(IsSnapshot == false, "log snapshot could not be embedded"); + Y_VERIFY(References.empty(), "must not mix embedded and referenced log bodies"); + Y_VERIFY(IsSnapshot == false, "log snapshot could not be embedded"); EmbeddedLogBody = x.GetEmbeddedLogBody(); } @@ -130,7 +130,7 @@ class TTabletReqRebuildHistoryGraph : public TActorBootstrapped<TTabletReqRebuil Status = StatusBody; break; case StatusOk: - Y_VERIFY_DEBUG(false); + Y_VERIFY_DEBUG(false); break; case StatusBody: break; @@ -143,7 +143,7 @@ class TTabletReqRebuildHistoryGraph : public TActorBootstrapped<TTabletReqRebuil case StatusMustBeIgnoredBody: break; default: - Y_FAIL(); + Y_FAIL(); } } @@ -171,14 +171,14 @@ class TTabletReqRebuildHistoryGraph : public TActorBootstrapped<TTabletReqRebuil {} TLogEntry& Entry(ui32 step) { - Y_VERIFY(step >= Base); + Y_VERIFY(step >= Base); const ui32 idx = step - Base; - Y_VERIFY(idx < Body.size()); + Y_VERIFY(idx < Body.size()); return Body[idx]; } void Ensure(ui32 step) { - Y_VERIFY(step >= Base); + Y_VERIFY(step >= Base); const ui32 idx = step - Base; if (idx >= Body.size()) Body.resize(idx + 1); @@ -224,7 +224,7 @@ class TTabletReqRebuildHistoryGraph : public TActorBootstrapped<TTabletReqRebuil IntrospectionTrace->Attach(MakeHolder<NTracing::TOnProcessZeroEntry>(gen, Snapshot, Confirmed)); } - Y_VERIFY(logEntry.HasZeroConfirmed() && logEntry.HasZeroTailSz()); + Y_VERIFY(logEntry.HasZeroConfirmed() && logEntry.HasZeroTailSz()); TGenerationEntry ¤t = GenerationInfo(gen); @@ -284,7 +284,7 @@ class TTabletReqRebuildHistoryGraph : public TActorBootstrapped<TTabletReqRebuil prev.Base = Snapshot.second; const ui32 tailsz = logEntry.GetZeroTailSz(); - Y_VERIFY(logEntry.ZeroTailBitmaskSize() == ((tailsz + 63) / 64)); + Y_VERIFY(logEntry.ZeroTailBitmaskSize() == ((tailsz + 63) / 64)); const ui32 gensz = confirmed.second + tailsz; prev.Ensure(gensz); @@ -329,7 +329,7 @@ class TTabletReqRebuildHistoryGraph : public TActorBootstrapped<TTabletReqRebuil if (IntrospectionTrace) { IntrospectionTrace->Attach(MakeHolder<NTracing::TOnProcessLogEntry>(id, Snapshot, Confirmed, logEntry)); } - Y_VERIFY(logEntry.HasSnapshot() && logEntry.HasConfirmed()); + Y_VERIFY(logEntry.HasSnapshot() && logEntry.HasConfirmed()); LOG_DEBUG(*TlsActivationContext, NKikimrServices::TABLET_MAIN, [&](){ TStringBuilder sb; @@ -449,7 +449,7 @@ class TTabletReqRebuildHistoryGraph : public TActorBootstrapped<TTabletReqRebuil if (IntrospectionTrace) { IntrospectionTrace->Attach(MakeHolder<NTracing::TOnApplyDiscoveryRange>(msg->GroupId, msg->From, msg->To)); } - Y_VERIFY(RangesToDiscover.erase(msg->To)); + Y_VERIFY(RangesToDiscover.erase(msg->To)); for (TVector<TEvBlobStorage::TEvRangeResult::TResponse>::iterator it = msg->Responses.begin(), end = msg->Responses.end(); it != end; ++it) { const TLogoBlobID &id = it->Id; @@ -520,7 +520,7 @@ class TTabletReqRebuildHistoryGraph : public TActorBootstrapped<TTabletReqRebuil } ui64 count = endRequestIdx - firstRequestIdx; - Y_VERIFY(count > 0); + Y_VERIFY(count > 0); TArrayHolder<TEvBlobStorage::TEvGet::TQuery> q(new TEvBlobStorage::TEvGet::TQuery[count]); for (ui64 i = 0; i < count; ++i) { @@ -570,13 +570,13 @@ class TTabletReqRebuildHistoryGraph : public TActorBootstrapped<TTabletReqRebuil if (IntrospectionTrace) { IntrospectionTrace->Attach(MakeHolder<NTracing::TOnCheckRefsGetResult>(msg->ResponseSz)); } - Y_VERIFY_DEBUG(msg->Status == NKikimrProto::OK); + Y_VERIFY_DEBUG(msg->Status == NKikimrProto::OK); for (ui32 i = 0, e = msg->ResponseSz; i != e; ++i) { const TEvBlobStorage::TEvGetResult::TResponse &response = msg->Responses[i]; switch (response.Status) { case NKikimrProto::OK: - Y_VERIFY(1 == RefsToCheck.erase(response.Id)); + Y_VERIFY(1 == RefsToCheck.erase(response.Id)); GroupReadBytes[std::make_pair(response.Id.Channel(), msg->GroupId)] += response.Buffer.size(); GroupReadOps[std::make_pair(response.Id.Channel(), msg->GroupId)] += 1; break; @@ -630,7 +630,7 @@ class TTabletReqRebuildHistoryGraph : public TActorBootstrapped<TTabletReqRebuil case TLogEntry::StatusUnknown: break; case TLogEntry::StatusOk: - Y_FAIL(); + Y_FAIL(); case TLogEntry::StatusBody: { bool dependsOk = true; @@ -696,7 +696,7 @@ class TTabletReqRebuildHistoryGraph : public TActorBootstrapped<TTabletReqRebuil } break; default: - Y_FAIL(); + Y_FAIL(); } } else { if (step <= gx.Cutoff) { @@ -750,7 +750,7 @@ class TTabletReqRebuildHistoryGraph : public TActorBootstrapped<TTabletReqRebuil invalidLogEntry = std::make_pair(generation, Max<ui32>()); } else { gen = LogInfo.find(gx.NextGeneration); - Y_VERIFY(gen != egen); + Y_VERIFY(gen != egen); } } diff --git a/ydb/core/tablet/tablet_req_writelog.cpp b/ydb/core/tablet/tablet_req_writelog.cpp index 7c4d02c405c..26328f03c4f 100644 --- a/ydb/core/tablet/tablet_req_writelog.cpp +++ b/ydb/core/tablet/tablet_req_writelog.cpp @@ -87,11 +87,11 @@ class TTabletReqWriteLog : public TActorBootstrapped<TTabletReqWriteLog> { void SendToBS(const TLogoBlobID &id, const TString &buffer, const TActorContext &ctx, const NKikimrBlobStorage::EPutHandleClass handleClass) { - Y_VERIFY(id.TabletID() == Info->TabletID); + Y_VERIFY(id.TabletID() == Info->TabletID); const TTabletChannelInfo *channelInfo = Info->ChannelInfo(id.Channel()); - Y_VERIFY(channelInfo); + Y_VERIFY(channelInfo); const TTabletChannelInfo::THistoryEntry *x = channelInfo->LatestEntry(); - Y_VERIFY(x->FromGeneration <= id.Generation()); + Y_VERIFY(x->FromGeneration <= id.Generation()); ui64 cookie = RandomNumber<ui64>(); RequestCookies ^= cookie; @@ -113,7 +113,7 @@ public: , RepliesToWait(Max<ui32>()) { References.swap(refs); - Y_VERIFY(Info); + Y_VERIFY(Info); } void Bootstrap(const TActorContext &ctx) { diff --git a/ydb/core/tablet/tablet_resolver.cpp b/ydb/core/tablet/tablet_resolver.cpp index c0a39a2216b..fd69b392d4d 100644 --- a/ydb/core/tablet/tablet_resolver.cpp +++ b/ydb/core/tablet/tablet_resolver.cpp @@ -401,8 +401,8 @@ class TTabletResolver : public TActorBootstrapped<TTabletResolver> { void MoveEntryToUnresolved(ui64 tabletId, TAutoPtr<TEntry>& entry) { TAutoPtr<TEntry>* unresolvedEntryPtr; - Y_VERIFY(UnresolvedTablets.Insert(tabletId, entry, unresolvedEntryPtr)); - Y_VERIFY(ResolvedTablets.Erase(tabletId)); + Y_VERIFY(UnresolvedTablets.Insert(tabletId, entry, unresolvedEntryPtr)); + Y_VERIFY(ResolvedTablets.Erase(tabletId)); } void CheckDelayedNodeProblem(ui64 tabletId, const TActorContext &ctx) { @@ -513,7 +513,7 @@ class TTabletResolver : public TActorBootstrapped<TTabletResolver> { PushQueue(ev, entry, ctx); break; default: - Y_FAIL(); + Y_FAIL(); } } @@ -565,7 +565,7 @@ class TTabletResolver : public TActorBootstrapped<TTabletResolver> { } break; default: - Y_FAIL(); + Y_FAIL(); } } @@ -608,7 +608,7 @@ class TTabletResolver : public TActorBootstrapped<TTabletResolver> { switch (entry.State) { case TEntry::StInit: - Y_FAIL("must not happens"); + Y_FAIL("must not happens"); case TEntry::StInitResolve: if (success) { if (msg->CurrentLeaderTablet) { @@ -668,7 +668,7 @@ class TTabletResolver : public TActorBootstrapped<TTabletResolver> { case TEntry::StNormal: break; default: - Y_FAIL(); + Y_FAIL(); } } @@ -702,7 +702,7 @@ class TTabletResolver : public TActorBootstrapped<TTabletResolver> { } break; default: - Y_FAIL(); + Y_FAIL(); } } @@ -765,7 +765,7 @@ class TTabletResolver : public TActorBootstrapped<TTabletResolver> { } break; default: - Y_FAIL(); + Y_FAIL(); } } @@ -814,7 +814,7 @@ public: }); ResolvedTablets.SetEvictionCallback([&](const ui64& key, TAutoPtr<TEntry>& value, ui64 size) { - Y_UNUSED(size); + Y_UNUSED(size); if (!value) return; diff --git a/ydb/core/tablet_flat/defs.h b/ydb/core/tablet_flat/defs.h index 166674c3ff5..892d8a42e08 100644 --- a/ydb/core/tablet_flat/defs.h +++ b/ydb/core/tablet_flat/defs.h @@ -25,7 +25,7 @@ namespace NScheme { namespace NTable { - using TRawVals = TArrayRef<const TRawTypeValue>; + using TRawVals = TArrayRef<const TRawTypeValue>; class TEpoch : public TTypeSafeAlias<TEpoch, i64> { public: diff --git a/ydb/core/tablet_flat/flat_cxx_database.h b/ydb/core/tablet_flat/flat_cxx_database.h index 27a260bcb27..2b6d3db8a00 100644 --- a/ydb/core/tablet_flat/flat_cxx_database.h +++ b/ydb/core/tablet_flat/flat_cxx_database.h @@ -191,7 +191,7 @@ public: operator TVector<ElementType>() const { static_assert(std::is_pod<ElementType>::value, "ElementType should be a POD type"); Y_VERIFY(Type() == NScheme::NTypeIds::String || Type() == NScheme::NTypeIds::String4k || Type() == NScheme::NTypeIds::String2m); - Y_VERIFY(Size() % sizeof(ElementType) == 0); + Y_VERIFY(Size() % sizeof(ElementType) == 0); std::size_t count = Size() / sizeof(ElementType); const ElementType *begin = reinterpret_cast<const ElementType*>(Data()); const ElementType *end = begin + count; @@ -202,7 +202,7 @@ public: void ExtractArray(THashSet<ElementType> &container) const { static_assert(std::is_pod<ElementType>::value, "ElementType should be a POD type"); Y_VERIFY(Type() == NScheme::NTypeIds::String || Type() == NScheme::NTypeIds::String4k || Type() == NScheme::NTypeIds::String2m); - Y_VERIFY(Size() % sizeof(ElementType) == 0); + Y_VERIFY(Size() % sizeof(ElementType) == 0); const ElementType *begin = reinterpret_cast<const ElementType*>(Data()); const ElementType *end = begin + Size() / sizeof(ElementType); container.resize(Size() / sizeof(ElementType)); diff --git a/ydb/core/tablet_flat/flat_cxx_database_ut.cpp b/ydb/core/tablet_flat/flat_cxx_database_ut.cpp index 0423d82e624..963c6fb5adb 100644 --- a/ydb/core/tablet_flat/flat_cxx_database_ut.cpp +++ b/ydb/core/tablet_flat/flat_cxx_database_ut.cpp @@ -10,7 +10,7 @@ namespace NKikimr { namespace NTable { -Y_UNIT_TEST_SUITE(TFlatCxxDatabaseTest) { +Y_UNIT_TEST_SUITE(TFlatCxxDatabaseTest) { using TDummyEnv = NTable::TDummyEnv; enum ESomeEnum : ui8 { @@ -66,7 +66,7 @@ Y_UNIT_TEST_SUITE(TFlatCxxDatabaseTest) { using TTables = SchemaTables<TestTable, TestTable2, TestTable3, TestTable4>; }; - Y_UNIT_TEST(BasicSchemaTest) { + Y_UNIT_TEST(BasicSchemaTest) { TDatabase DB; NIceDb::TNiceDb db(DB); ui64 stamp = 0; @@ -585,7 +585,7 @@ Y_UNIT_TEST_SUITE(TFlatCxxDatabaseTest) { } } - Y_UNIT_TEST(RenameColumnSchemaTest) { + Y_UNIT_TEST(RenameColumnSchemaTest) { TScheme scheme; TSchemeModifier applier(scheme); TAlter delta; diff --git a/ydb/core/tablet_flat/flat_database.cpp b/ydb/core/tablet_flat/flat_database.cpp index c4591195155..263db312909 100644 --- a/ydb/core/tablet_flat/flat_database.cpp +++ b/ydb/core/tablet_flat/flat_database.cpp @@ -411,7 +411,7 @@ void TDatabase::DebugDumpTable(ui32 table, IOutputStream& str, const NScheme::TT str << "unknown" << Endl; } -void TDatabase::DebugDump(IOutputStream& str, const NScheme::TTypeRegistry& typeRegistry) const { +void TDatabase::DebugDump(IOutputStream& str, const NScheme::TTypeRegistry& typeRegistry) const { for (const auto& it: DatabaseImpl->Scheme->Tables) { if (DatabaseImpl->Get(it.first, false)) { str << "======= " << it.second.Name << " ======\n"; diff --git a/ydb/core/tablet_flat/flat_database.h b/ydb/core/tablet_flat/flat_database.h index 98baa8f4383..fb2e13776a0 100644 --- a/ydb/core/tablet_flat/flat_database.h +++ b/ydb/core/tablet_flat/flat_database.h @@ -153,7 +153,7 @@ public: void Merge(ui32 table, TIntrusiveConstPtr<TTxStatusPart>); void DebugDumpTable(ui32 table, IOutputStream& str, const NScheme::TTypeRegistry& typeRegistry) const; - void DebugDump(IOutputStream& str, const NScheme::TTypeRegistry& typeRegistry) const; + void DebugDump(IOutputStream& str, const NScheme::TTypeRegistry& typeRegistry) const; TKeyRangeCache* DebugGetTableErasedKeysCache(ui32 table) const; diff --git a/ydb/core/tablet_flat/flat_executor.cpp b/ydb/core/tablet_flat/flat_executor.cpp index 59afc462158..08a0789d43b 100644 --- a/ydb/core/tablet_flat/flat_executor.cpp +++ b/ydb/core/tablet_flat/flat_executor.cpp @@ -440,7 +440,7 @@ void TExecutor::TranscriptBootOpResult(ui32 res, const TActorContext &ctx) { return Broken(); default: - Y_FAIL("unknown boot result"); + Y_FAIL("unknown boot result"); } } @@ -686,10 +686,10 @@ void TExecutor::FollowerBoot(TEvTablet::TEvFBoot::TPtr &ev, const TActorContext } void TExecutor::Restored(TEvTablet::TEvRestored::TPtr &ev, const TActorContext &ctx) { - Y_VERIFY(CurrentStateFunc() == &TThis::StateBoot && BootLogic); + Y_VERIFY(CurrentStateFunc() == &TThis::StateBoot && BootLogic); TEvTablet::TEvRestored *msg = ev->Get(); - Y_VERIFY(Generation() == msg->Generation); + Y_VERIFY(Generation() == msg->Generation); const TExecutorBootLogic::EOpResult res = BootLogic->ReceiveRestored(ev); return TranscriptBootOpResult(res, ctx); @@ -1400,7 +1400,7 @@ bool TExecutor::CanExecuteTransaction() const { } void TExecutor::Execute(TAutoPtr<ITransaction> self, const TActorContext &ctx) { - Y_VERIFY(ActivationQueue, "attempt to execute transaction before activation"); + Y_VERIFY(ActivationQueue, "attempt to execute transaction before activation"); TAutoPtr<TSeat> seat = new TSeat(++TransactionUniqCounter, self); @@ -1456,7 +1456,7 @@ void TExecutor::Execute(TAutoPtr<ITransaction> self, const TActorContext &ctx) { } void TExecutor::ExecuteTransaction(TAutoPtr<TSeat> seat, const TActorContext &ctx) { - Y_VERIFY_DEBUG(!ActiveTransaction); + Y_VERIFY_DEBUG(!ActiveTransaction); ActiveTransaction = true; ++seat->Retries; @@ -2398,7 +2398,7 @@ void TExecutor::MakeLogSnapshot() { } void TExecutor::Handle(TEvPrivate::TEvActivateExecution::TPtr &ev, const TActorContext &ctx) { - Y_UNUSED(ev); + Y_UNUSED(ev); Y_VERIFY(ActivateTransactionInFlight > 0); ActivateTransactionInFlight--; @@ -2615,7 +2615,7 @@ void TExecutor::Handle(TEvTablet::TEvCommitResult::TPtr &ev, const TActorContext return Broken(); } - Y_VERIFY(msg->Generation == Generation()); + Y_VERIFY(msg->Generation == Generation()); const ui32 step = msg->Step; ActiveTransaction = true; @@ -2656,7 +2656,7 @@ void TExecutor::Handle(TEvTablet::TEvCommitResult::TPtr &ev, const TActorContext case ECommit::Data: { auto it = InFlyCompactionGcBarriers.find(step); - Y_VERIFY(it != InFlyCompactionGcBarriers.end()); + Y_VERIFY(it != InFlyCompactionGcBarriers.end()); // just check, real barrier release on follower gc ack } @@ -2665,7 +2665,7 @@ void TExecutor::Handle(TEvTablet::TEvCommitResult::TPtr &ev, const TActorContext case ECommit::Misc: break; default: - Y_FAIL("unknown event cookie"); + Y_FAIL("unknown event cookie"); } CheckYellow(std::move(msg->YellowMoveChannels), std::move(msg->YellowStopChannels)); @@ -3535,13 +3535,13 @@ bool TExecutor::CompactTables() { } STFUNC(TExecutor::StateInit) { - Y_UNUSED(ev); - Y_UNUSED(ctx); - Y_FAIL("must be no events before boot processing"); + Y_UNUSED(ev); + Y_UNUSED(ctx); + Y_FAIL("must be no events before boot processing"); } STFUNC(TExecutor::StateBoot) { - Y_VERIFY(BootLogic); + Y_VERIFY(BootLogic); switch (ev->GetTypeRewrite()) { // N.B. must work during follower promotion to leader HFunc(TEvPrivate::TEvActivateExecution, Handle); diff --git a/ydb/core/tablet_flat/flat_executor_bootlogic.cpp b/ydb/core/tablet_flat/flat_executor_bootlogic.cpp index cf72960f9c4..40eaa2e2794 100644 --- a/ydb/core/tablet_flat/flat_executor_bootlogic.cpp +++ b/ydb/core/tablet_flat/flat_executor_bootlogic.cpp @@ -228,7 +228,7 @@ TExecutorBootLogic::EOpResult TExecutorBootLogic::CheckCompletion() } TExecutorBootLogic::EOpResult TExecutorBootLogic::ReceiveRestored(TEvTablet::TEvRestored::TPtr &ev) { - Y_UNUSED(ev); + Y_UNUSED(ev); Restored = true; return CheckCompletion(); } diff --git a/ydb/core/tablet_flat/flat_executor_borrowlogic.cpp b/ydb/core/tablet_flat/flat_executor_borrowlogic.cpp index bd52264b10e..1a23c343387 100644 --- a/ydb/core/tablet_flat/flat_executor_borrowlogic.cpp +++ b/ydb/core/tablet_flat/flat_executor_borrowlogic.cpp @@ -525,7 +525,7 @@ void TExecutorBorrowLogic::RestoreBorrowedInfo(const TLogoBlobID &blobId, const HasFlag = !BorrowedInfo.empty(); } -void TExecutorBorrowLogic::OutputHtml(IOutputStream &out) { +void TExecutorBorrowLogic::OutputHtml(IOutputStream &out) { HTML(out) { H4() {out << "Borrowed parts";} PRE() { diff --git a/ydb/core/tablet_flat/flat_executor_borrowlogic.h b/ydb/core/tablet_flat/flat_executor_borrowlogic.h index 5d990b49dc0..cccf2555a94 100644 --- a/ydb/core/tablet_flat/flat_executor_borrowlogic.h +++ b/ydb/core/tablet_flat/flat_executor_borrowlogic.h @@ -163,7 +163,7 @@ public: void RestoreFollowerBorrowedInfo(const TLogoBlobID &blobId, const NKikimrExecutorFlat::TBorrowedPart &proto); // for monitoring - void OutputHtml(IOutputStream &out); + void OutputHtml(IOutputStream &out); TString DebugCheckBorrowConsistency(THashSet<TLogoBlobID> &knownBundles); // for cleanup diff --git a/ydb/core/tablet_flat/flat_executor_database_ut.cpp b/ydb/core/tablet_flat/flat_executor_database_ut.cpp index 0168615c55b..0d77a211339 100644 --- a/ydb/core/tablet_flat/flat_executor_database_ut.cpp +++ b/ydb/core/tablet_flat/flat_executor_database_ut.cpp @@ -378,28 +378,28 @@ void RunTest(IActor *test) env.Finalize(); } -Y_UNIT_TEST_SUITE(TExecutorDb) { - Y_UNIT_TEST(RandomOps) +Y_UNIT_TEST_SUITE(TExecutorDb) { + Y_UNIT_TEST(RandomOps) { RunTest(new TFuzzyActor(5, MaxActionCount)); } - Y_UNIT_TEST(FullScan) + Y_UNIT_TEST(FullScan) { RunTest(new TFullScan(MultiPageMaxActionCount)); } - Y_UNIT_TEST(CoordinatorSimulation) + Y_UNIT_TEST(CoordinatorSimulation) { RunTest(new THeThing(MaxActionCount, 42)); } - Y_UNIT_TEST(RandomCoordinatorSimulation) + Y_UNIT_TEST(RandomCoordinatorSimulation) { RunTest(new THeThing(MaxActionCount, TInstant::Now().Seconds())); } - Y_UNIT_TEST(MultiPage) + Y_UNIT_TEST(MultiPage) { NFake::TFuzzySet fuzzy(false /* no compression */); @@ -413,7 +413,7 @@ Y_UNIT_TEST_SUITE(TExecutorDb) { RunTest(new TDbTestPlayerActor(tx)); } - Y_UNIT_TEST(EncodedPage) + Y_UNIT_TEST(EncodedPage) { NFake::TFuzzySet fuzzy(true /* compress */); diff --git a/ydb/core/tablet_flat/flat_executor_gclogic.cpp b/ydb/core/tablet_flat/flat_executor_gclogic.cpp index bded66353ec..f03e65474d4 100644 --- a/ydb/core/tablet_flat/flat_executor_gclogic.cpp +++ b/ydb/core/tablet_flat/flat_executor_gclogic.cpp @@ -66,7 +66,7 @@ TGCLogEntry TExecutorGCLogic::SnapshotLog(ui32 step) { TGCLogEntry snapshot(snapshotTime); for (const auto& chIt : ChannelInfo) { for (const auto& le : chIt.second.CommittedDelta) { - Y_VERIFY(le.first <= snapshotTime); + Y_VERIFY(le.first <= snapshotTime); TExecutorGCLogic::MergeVectors(snapshot.Delta.Created, le.second.Created); TExecutorGCLogic::MergeVectors(snapshot.Delta.Deleted, le.second.Deleted); } @@ -164,7 +164,7 @@ void TExecutorGCLogic::ApplyDelta(TGCTime time, TGCBlobDelta &delta) { for (const TLogoBlobID &blobId : delta.Created) { auto &channel = ChannelInfo[blobId.Channel()]; TGCTime gcTime(blobId.Generation(), blobId.Step()); - Y_VERIFY(channel.KnownGcBarrier < gcTime); + Y_VERIFY(channel.KnownGcBarrier < gcTime); channel.CommittedDelta[gcTime].Created.push_back(blobId); } @@ -388,7 +388,7 @@ void TExecutorGCLogic::TChannelInfo::SendCollectGarbage(TGCTime uncommittedTime, KnownGcBarrier = collectBarrier; const auto *channelInfo = tabletStorageInfo->ChannelInfo(channel); - Y_VERIFY(channelInfo); + Y_VERIFY(channelInfo); const ui32 lastCommitedGcBarrier = CommitedGcBarrier.Generation; diff --git a/ydb/core/tablet_flat/flat_executor_gclogic.h b/ydb/core/tablet_flat/flat_executor_gclogic.h index 9c1fa568a23..7ad52c05411 100644 --- a/ydb/core/tablet_flat/flat_executor_gclogic.h +++ b/ydb/core/tablet_flat/flat_executor_gclogic.h @@ -21,7 +21,7 @@ struct TGCTime { inline bool operator <=(const TGCTime& another) const { return Generation < another.Generation || (Generation == another.Generation && Step <= another.Step); } inline bool Valid() const { return Generation != 0 || Step != 0; } inline void Clear() { Generation = Step = 0; } - static TGCTime Infinity() { return TGCTime(std::numeric_limits<ui32>::max(), std::numeric_limits<ui32>::max()); } + static TGCTime Infinity() { return TGCTime(std::numeric_limits<ui32>::max(), std::numeric_limits<ui32>::max()); } explicit operator bool() const noexcept { return Valid(); } }; diff --git a/ydb/core/tablet_flat/flat_executor_gclogic_ut.cpp b/ydb/core/tablet_flat/flat_executor_gclogic_ut.cpp index 8c0c5ac6f01..5c67e835b1f 100644 --- a/ydb/core/tablet_flat/flat_executor_gclogic_ut.cpp +++ b/ydb/core/tablet_flat/flat_executor_gclogic_ut.cpp @@ -4,13 +4,13 @@ namespace NKikimr { namespace NTabletFlatExecutor { -Y_UNIT_TEST_SUITE(TFlatTableExecutorGC) { +Y_UNIT_TEST_SUITE(TFlatTableExecutorGC) { bool TestDeduplication(TVector<TLogoBlobID> keep, TVector<TLogoBlobID> dontkeep, ui32 gen, ui32 step, TVector<TLogoBlobID> expectKeep, TVector<TLogoBlobID> expectnot) { DeduplicateGCKeepVectors(&keep, &dontkeep, gen, step); return (keep == expectKeep) && (dontkeep == expectnot); } - Y_UNIT_TEST(TestGCVectorDeduplicaton) { + Y_UNIT_TEST(TestGCVectorDeduplicaton) { UNIT_ASSERT(TestDeduplication( { TLogoBlobID(1, 1, 1, 1, 0, 0), diff --git a/ydb/core/tablet_flat/flat_executor_ut.cpp b/ydb/core/tablet_flat/flat_executor_ut.cpp index c9cf5289711..8d8ad67ebeb 100644 --- a/ydb/core/tablet_flat/flat_executor_ut.cpp +++ b/ydb/core/tablet_flat/flat_executor_ut.cpp @@ -546,8 +546,8 @@ public: * 4. Resume scan. * 5. Check number of scanned rows. */ -Y_UNIT_TEST_SUITE(TFlatTableCompactionScan) { - Y_UNIT_TEST(TestCompactionScan) { +Y_UNIT_TEST_SUITE(TFlatTableCompactionScan) { + Y_UNIT_TEST(TestCompactionScan) { TMyEnvBase env; TRowsModel data; @@ -594,7 +594,7 @@ Y_UNIT_TEST_SUITE(TFlatTableCompactionScan) { } -Y_UNIT_TEST_SUITE(TFlatTableExecutorTxLimit) { +Y_UNIT_TEST_SUITE(TFlatTableExecutorTxLimit) { struct TTxSchema : public ITransaction { TTxSchema(TActorId owner) : Owner(owner) { } @@ -773,7 +773,7 @@ Y_UNIT_TEST_SUITE(TFlatTableBackgroundCompactions) { TRowsModel Rows; }; - Y_UNIT_TEST(TestRunBackgroundSnapshot) { + Y_UNIT_TEST(TestRunBackgroundSnapshot) { TMyEnvCompaction env; env.SendAsync(env.Rows.MakeRows(5)); @@ -782,7 +782,7 @@ Y_UNIT_TEST_SUITE(TFlatTableBackgroundCompactions) { env->DispatchEvents(options); } - Y_UNIT_TEST(TestChangeBackgroundSnapshotToRegular) { + Y_UNIT_TEST(TestChangeBackgroundSnapshotToRegular) { TMyEnvCompaction env; env.BlockBackgroundQueue(); @@ -798,7 +798,7 @@ Y_UNIT_TEST_SUITE(TFlatTableBackgroundCompactions) { env->DispatchEvents(options2); } - Y_UNIT_TEST(TestRunBackgroundCompactionGen1) { + Y_UNIT_TEST(TestRunBackgroundCompactionGen1) { TMyEnvCompaction env; env.BlockBackgroundQueue(); @@ -808,7 +808,7 @@ Y_UNIT_TEST_SUITE(TFlatTableBackgroundCompactions) { env->DispatchEvents(options); } - Y_UNIT_TEST(TestChangeBackgroundCompactionToRegular) { + Y_UNIT_TEST(TestChangeBackgroundCompactionToRegular) { TMyEnvCompaction env; env.BlockBackgroundQueue(); @@ -825,7 +825,7 @@ Y_UNIT_TEST_SUITE(TFlatTableBackgroundCompactions) { env->DispatchEvents(options2); } - Y_UNIT_TEST(TestRunBackgroundCompactionGen2) { + Y_UNIT_TEST(TestRunBackgroundCompactionGen2) { TMyEnvCompaction env; env.BlockBackgroundQueue(); @@ -836,7 +836,7 @@ Y_UNIT_TEST_SUITE(TFlatTableBackgroundCompactions) { env->DispatchEvents(options); } - Y_UNIT_TEST(TestChangeBackgroundSnapshotPriorityByTime) { + Y_UNIT_TEST(TestChangeBackgroundSnapshotPriorityByTime) { TMyEnvCompaction env; env.BlockBackgroundQueue(); @@ -852,7 +852,7 @@ Y_UNIT_TEST_SUITE(TFlatTableBackgroundCompactions) { env->DispatchEvents(options2); } - Y_UNIT_TEST(TestChangeBackgroundCompactionPriorityByTime) { + Y_UNIT_TEST(TestChangeBackgroundCompactionPriorityByTime) { TMyEnvCompaction env; env.BlockBackgroundQueue(); @@ -885,7 +885,7 @@ Y_UNIT_TEST_SUITE(TFlatTableBackgroundCompactions) { } -Y_UNIT_TEST_SUITE(TFlatTablePostponedScan) { +Y_UNIT_TEST_SUITE(TFlatTablePostponedScan) { using namespace NKikimrResourceBroker; using namespace NResourceBroker; @@ -929,7 +929,7 @@ Y_UNIT_TEST_SUITE(TFlatTablePostponedScan) { TRowsModel Rows; }; - Y_UNIT_TEST(TestPostponedScan) { + Y_UNIT_TEST(TestPostponedScan) { TMyEnvScans env; TAutoPtr<IEventHandle> handle; @@ -952,7 +952,7 @@ Y_UNIT_TEST_SUITE(TFlatTablePostponedScan) { env.SendSync(new TEvTestFlatTablet::TEvCancelScan); } - Y_UNIT_TEST(TestCancelRunningPostponedScan) { + Y_UNIT_TEST(TestCancelRunningPostponedScan) { TMyEnvScans env; TAutoPtr<IEventHandle> handle; @@ -975,7 +975,7 @@ Y_UNIT_TEST_SUITE(TFlatTablePostponedScan) { } -Y_UNIT_TEST_SUITE(TFlatTableExecutorResourceProfile) { +Y_UNIT_TEST_SUITE(TFlatTableExecutorResourceProfile) { struct TTaskSequence { struct TEvent { @@ -1393,7 +1393,7 @@ Y_UNIT_TEST_SUITE(TFlatTableExecutorResourceProfile) { }; - Y_UNIT_TEST(TestExecutorSetResourceProfile) { + Y_UNIT_TEST(TestExecutorSetResourceProfile) { TMyEnvProfiles env; env.SendSync(new NFake::TEvExecute{ new TTxCheckResourceProfile("profile1") }); @@ -1402,7 +1402,7 @@ Y_UNIT_TEST_SUITE(TFlatTableExecutorResourceProfile) { env.SendSync(new NFake::TEvExecute{ new TTxCheckResourceProfile("profile1") }, true); } - Y_UNIT_TEST(TestExecutorRequestTxData) { + Y_UNIT_TEST(TestExecutorRequestTxData) { TMyEnvProfiles env; // Request static memory. @@ -1425,7 +1425,7 @@ Y_UNIT_TEST_SUITE(TFlatTableExecutorResourceProfile) { {110 << 10, {"", "large_transaction"}}}); } - Y_UNIT_TEST(TestExecutorStaticMemoryLimits) { + Y_UNIT_TEST(TestExecutorStaticMemoryLimits) { TMyEnvProfiles env; const ui64 limit = env.Profile->GetStaticTabletTxMemoryLimit(); @@ -1444,7 +1444,7 @@ Y_UNIT_TEST_SUITE(TFlatTableExecutorResourceProfile) { env.CheckMemoryRequest({{limit * 2 + 1, {}, true}}); } - Y_UNIT_TEST(TestExecutorReuseStaticMemory) { + Y_UNIT_TEST(TestExecutorReuseStaticMemory) { TMyEnvProfiles env; env.Profile->SetStaticTxMemoryLimit(100 << 20); @@ -1461,11 +1461,11 @@ Y_UNIT_TEST_SUITE(TFlatTableExecutorResourceProfile) { } } - Y_UNIT_TEST(TestExecutorTxDataLimitExceeded) { + Y_UNIT_TEST(TestExecutorTxDataLimitExceeded) { TMyEnvProfiles().CheckMemoryRequest({{500 << 20, {}, false, true}}); } - Y_UNIT_TEST(TestExecutorRequestPages) { + Y_UNIT_TEST(TestExecutorRequestPages) { TMyEnvProfiles env; env.SendSync(env.Rows.MakeRows(100, 2 << 10)); @@ -1495,7 +1495,7 @@ Y_UNIT_TEST_SUITE(TFlatTableExecutorResourceProfile) { 0, {"large_transaction"}}}); } - Y_UNIT_TEST(TestExecutorPageLimitExceeded) { + Y_UNIT_TEST(TestExecutorPageLimitExceeded) { TMyEnvProfiles env; env.Profile->SetTxMemoryLimit(50 << 10); @@ -1506,7 +1506,7 @@ Y_UNIT_TEST_SUITE(TFlatTableExecutorResourceProfile) { {{{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}, 0, {}, false, true}}); } - Y_UNIT_TEST(TestExecutorRequestMemory) { + Y_UNIT_TEST(TestExecutorRequestMemory) { TMyEnvProfiles env; env.SendSync(env.Rows.MakeRows(100, 2 << 10)); @@ -1546,7 +1546,7 @@ Y_UNIT_TEST_SUITE(TFlatTableExecutorResourceProfile) { {{{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}, 95 << 10, {"large_transaction"}}}); } - Y_UNIT_TEST(TestExecutorMemoryLimitExceeded) { + Y_UNIT_TEST(TestExecutorMemoryLimitExceeded) { TMyEnvProfiles env; env.Profile->SetTxMemoryLimit(50 << 10); @@ -1556,7 +1556,7 @@ Y_UNIT_TEST_SUITE(TFlatTableExecutorResourceProfile) { env.CheckMemoryRequest({{{1, 2, 3, 4, 5}, 45 << 10, {}, false, true}}); } - Y_UNIT_TEST(TestExecutorPreserveTxData) { + Y_UNIT_TEST(TestExecutorPreserveTxData) { TMyEnvProfiles env; // Preserved static replaces static. @@ -1635,7 +1635,7 @@ Y_UNIT_TEST_SUITE(TFlatTableExecutorResourceProfile) { {false, true, 500 << 20, {}, false, true}}); } - Y_UNIT_TEST(TestExecutorTxDataGC) { + Y_UNIT_TEST(TestExecutorTxDataGC) { TMyEnvProfiles env; // Preserve dynamic and drop it. @@ -1644,7 +1644,7 @@ Y_UNIT_TEST_SUITE(TFlatTableExecutorResourceProfile) { {true, 0, {}}}); } - Y_UNIT_TEST(TestExecutorTxPartialDataHold) { + Y_UNIT_TEST(TestExecutorTxPartialDataHold) { TMyEnvProfiles env; // Hold part of static data. @@ -1659,7 +1659,7 @@ Y_UNIT_TEST_SUITE(TFlatTableExecutorResourceProfile) { {false, true, 0, {}}}); } - Y_UNIT_TEST(TestExecutorTxHoldAndUse) { + Y_UNIT_TEST(TestExecutorTxHoldAndUse) { TMyEnvProfiles env; // Hold part of static data. @@ -1677,7 +1677,7 @@ Y_UNIT_TEST_SUITE(TFlatTableExecutorResourceProfile) { {false, true, 0, {"", "", "medium_transaction"}}}); } - Y_UNIT_TEST(TestExecutorTxHoldOnRelease) { + Y_UNIT_TEST(TestExecutorTxHoldOnRelease) { TMyEnvProfiles env; // Hold dynamic data on task extend. Merge two small tasks into one medium. @@ -1689,7 +1689,7 @@ Y_UNIT_TEST_SUITE(TFlatTableExecutorResourceProfile) { { false /* static */, true /* dynamic */ }); } - Y_UNIT_TEST(TestUpdateConfig) { + Y_UNIT_TEST(TestUpdateConfig) { TMyEnvProfiles env; // Request dynamic memory (large task). diff --git a/ydb/core/tablet_flat/flat_row_misc.h b/ydb/core/tablet_flat/flat_row_misc.h index d7730ff06d7..2591cec57d7 100644 --- a/ydb/core/tablet_flat/flat_row_misc.h +++ b/ydb/core/tablet_flat/flat_row_misc.h @@ -8,7 +8,7 @@ namespace NKikimr { namespace NFmt { - using TOut = IOutputStream; + using TOut = IOutputStream; struct TCells { using TReg = NScheme::TTypeRegistry; diff --git a/ydb/core/tablet_flat/flat_sausage_align.h b/ydb/core/tablet_flat/flat_sausage_align.h index 04c7992ef44..da1bd874921 100644 --- a/ydb/core/tablet_flat/flat_sausage_align.h +++ b/ydb/core/tablet_flat/flat_sausage_align.h @@ -8,7 +8,7 @@ namespace NPageCollection { class TAlign { public: - TAlign(TArrayRef<const ui64> steps) : Steps(steps) { } + TAlign(TArrayRef<const ui64> steps) : Steps(steps) { } TBorder Lookup(ui64 offset, const ui64 sz) const noexcept { @@ -35,7 +35,7 @@ namespace NPageCollection { }; } - const TArrayRef<const ui64> Steps; + const TArrayRef<const ui64> Steps; }; } diff --git a/ydb/core/tablet_flat/flat_sausage_meta.cpp b/ydb/core/tablet_flat/flat_sausage_meta.cpp index 6f708945a06..0b1635233cd 100644 --- a/ydb/core/tablet_flat/flat_sausage_meta.cpp +++ b/ydb/core/tablet_flat/flat_sausage_meta.cpp @@ -89,7 +89,7 @@ TStringBuf TMeta::GetPageInplaceData(ui32 pageId) const noexcept return TStringBuf(InboundData + begin, InboundData + end); } -ui32 Checksum(TArrayRef<const char> body) noexcept +ui32 Checksum(TArrayRef<const char> body) noexcept { return Crc32c(body.data(), body.size()); } diff --git a/ydb/core/tablet_flat/flat_sausage_misc.h b/ydb/core/tablet_flat/flat_sausage_misc.h index 591273bced3..e4cebcd3957 100644 --- a/ydb/core/tablet_flat/flat_sausage_misc.h +++ b/ydb/core/tablet_flat/flat_sausage_misc.h @@ -6,7 +6,7 @@ namespace NKikimr { namespace NPageCollection { - ui32 Checksum(TArrayRef<const char> body) noexcept; + ui32 Checksum(TArrayRef<const char> body) noexcept; struct TBorder { struct TOn { diff --git a/ydb/core/tablet_flat/flat_sausagecache.cpp b/ydb/core/tablet_flat/flat_sausagecache.cpp index 4d396e8f758..468c83dbbae 100644 --- a/ydb/core/tablet_flat/flat_sausagecache.cpp +++ b/ydb/core/tablet_flat/flat_sausagecache.cpp @@ -267,7 +267,7 @@ std::pair<ui32, ui64> TPrivatePageCache::Load(TVector<ui32> &pages, TPrivatePage page->LoadState = TPage::LoadStateRequested; bytesToRequest += page->Size; - Y_VERIFY(!page->WaitQueue); + Y_VERIFY(!page->WaitQueue); page->WaitQueue = new TPage::TWaitQueue(); page->WaitQueue->Push(waitPad); waitPad->Inc(); @@ -276,7 +276,7 @@ std::pair<ui32, ui64> TPrivatePageCache::Load(TVector<ui32> &pages, TPrivatePage ++it; break; case TPage::LoadStateLoaded: - Y_FAIL("must not request already loaded pages"); + Y_FAIL("must not request already loaded pages"); case TPage::LoadStateRequested: if (!page->WaitQueue) page->WaitQueue = new TPage::TWaitQueue(); @@ -447,7 +447,7 @@ void TPrivatePageCache::Evict(TPage *pages) { break; default: - Y_FAIL("unknown load state"); + Y_FAIL("unknown load state"); } TPage *next = page->Next()->Node(); diff --git a/ydb/core/tablet_flat/flat_stat_table.cpp b/ydb/core/tablet_flat/flat_stat_table.cpp index dfbaab9da75..a931761eef9 100644 --- a/ydb/core/tablet_flat/flat_stat_table.cpp +++ b/ydb/core/tablet_flat/flat_stat_table.cpp @@ -34,7 +34,7 @@ void BuildStats(const TSubset& subset, TStats& stats, ui64 rowCountResolution, u continue; TDbTupleRef currentKey = stIter.GetCurrentKey(); - TString serializedKey = TSerializedCellVec::Serialize(TConstArrayRef<TCell>(currentKey.Columns, currentKey.ColumnCount)); + TString serializedKey = TSerializedCellVec::Serialize(TConstArrayRef<TCell>(currentKey.Columns, currentKey.ColumnCount)); if (nextRowsBucket) { stats.RowCountHistogram.push_back({serializedKey, stats.RowCount}); diff --git a/ydb/core/tablet_flat/flat_table.h b/ydb/core/tablet_flat/flat_table.h index a1fdeb97093..c15e24333d4 100644 --- a/ydb/core/tablet_flat/flat_table.h +++ b/ydb/core/tablet_flat/flat_table.h @@ -253,7 +253,7 @@ public: return rows ? (size / rows) : 0; } - void DebugDump(IOutputStream& str, IPages *env, const NScheme::TTypeRegistry& typeRegistry) const; + void DebugDump(IOutputStream& str, IPages *env, const NScheme::TTypeRegistry& typeRegistry) const; TKeyRangeCache* GetErasedKeysCache() const; diff --git a/ydb/core/tablet_flat/flat_table_part_ut.cpp b/ydb/core/tablet_flat/flat_table_part_ut.cpp index 185265a95ef..9c94af743fd 100644 --- a/ydb/core/tablet_flat/flat_table_part_ut.cpp +++ b/ydb/core/tablet_flat/flat_table_part_ut.cpp @@ -9,14 +9,14 @@ #include <library/cpp/testing/unittest/registar.h> -#include <util/stream/null.h> +#include <util/stream/null.h> #include <util/random/mersenne.h> - + namespace NKikimr { namespace NTable { namespace NTest { -Y_UNIT_TEST_SUITE(TLegacy) { +Y_UNIT_TEST_SUITE(TLegacy) { /* This is legacy place for UT, do not put here more tests */ @@ -36,9 +36,9 @@ Y_UNIT_TEST_SUITE(TLegacy) { return new NPage::TFrames(writer.Make()); } - Y_UNIT_TEST(IndexIter) { + Y_UNIT_TEST(IndexIter) { TNullOutput devNull; - IOutputStream& dbgOut = devNull; //*/ Cerr; + IOutputStream& dbgOut = devNull; //*/ Cerr; NScheme::TTypeRegistry typeRegistry; @@ -89,9 +89,9 @@ Y_UNIT_TEST_SUITE(TLegacy) { fnIterate(eggs.At(0), newLay.RowScheme()); } - Y_UNIT_TEST(ScreenedIndexIter) { + Y_UNIT_TEST(ScreenedIndexIter) { TNullOutput devNull; - IOutputStream& dbgOut = devNull; //*/ Cerr; + IOutputStream& dbgOut = devNull; //*/ Cerr; NScheme::TTypeRegistry typeRegistry; @@ -216,9 +216,9 @@ Y_UNIT_TEST_SUITE(TLegacy) { } } - Y_UNIT_TEST(StatsIter) { + Y_UNIT_TEST(StatsIter) { TNullOutput devNull; - IOutputStream& dbgOut = devNull; //*/ Cerr; + IOutputStream& dbgOut = devNull; //*/ Cerr; NScheme::TTypeRegistry typeRegistry; @@ -305,7 +305,7 @@ Y_UNIT_TEST_SUITE(TLegacy) { dbgOut << DbgPrintTuple(key, typeRegistry) << " " << stIter.GetCurrentRowCount() << " " << stIter.GetCurrentDataSize() << Endl; - prevKey = TSerializedCellVec(TSerializedCellVec::Serialize(TConstArrayRef<TCell>(key.Columns, key.ColumnCount))); + prevKey = TSerializedCellVec(TSerializedCellVec::Serialize(TConstArrayRef<TCell>(key.Columns, key.ColumnCount))); prevRowCount = stIter.GetCurrentRowCount(); prevDataSize = stIter.GetCurrentDataSize(); stIter.Next(); diff --git a/ydb/core/tablet_flat/flat_table_subset.h b/ydb/core/tablet_flat/flat_table_subset.h index bffbf5a1271..25538512f59 100644 --- a/ydb/core/tablet_flat/flat_table_subset.h +++ b/ydb/core/tablet_flat/flat_table_subset.h @@ -45,7 +45,7 @@ namespace NTable { return Head == TEpoch::Zero() || Head == Epoch() + 1; } - void Describe(IOutputStream &out) const noexcept + void Describe(IOutputStream &out) const noexcept { out << "TSubset{" << "head " << Head diff --git a/ydb/core/tablet_flat/tablet_flat_executed.cpp b/ydb/core/tablet_flat/tablet_flat_executed.cpp index 4b3c15490c5..3aff3c3321c 100644 --- a/ydb/core/tablet_flat/tablet_flat_executed.cpp +++ b/ydb/core/tablet_flat/tablet_flat_executed.cpp @@ -143,8 +143,8 @@ void TTabletExecutedFlat::DefaultSignalTabletActive(const TActorContext &ctx) { } void TTabletExecutedFlat::Enqueue(STFUNC_SIG) { - Y_UNUSED(ev); - Y_UNUSED(ctx); + Y_UNUSED(ev); + Y_UNUSED(ctx); } void TTabletExecutedFlat::ActivateExecutor(const TActorContext &ctx) { diff --git a/ydb/core/tablet_flat/tablet_flat_executor.h b/ydb/core/tablet_flat/tablet_flat_executor.h index 075ebce354b..ecd49157633 100644 --- a/ydb/core/tablet_flat/tablet_flat_executor.h +++ b/ydb/core/tablet_flat/tablet_flat_executor.h @@ -458,7 +458,7 @@ namespace NFlatExecutorSetup { : TabletActorID(tablet) , TabletInfo(info) { - Y_VERIFY(TTabletTypes::TYPE_INVALID != TabletInfo->TabletType); + Y_VERIFY(TTabletTypes::TYPE_INVALID != TabletInfo->TabletType); } TActorId ExecutorActorID; diff --git a/ydb/core/tablet_flat/test/libs/rows/mass.h b/ydb/core/tablet_flat/test/libs/rows/mass.h index 3997a46ee05..acf6a5464d7 100644 --- a/ydb/core/tablet_flat/test/libs/rows/mass.h +++ b/ydb/core/tablet_flat/test/libs/rows/mass.h @@ -20,7 +20,7 @@ namespace NTest { virtual TRow Make(ui64 seq, bool hole) noexcept = 0; virtual ui64 Base(const TRow &row) const noexcept = 0; virtual void Check(TArrayRef<const ui64>) const = 0; - virtual void Describe(IOutputStream&) const noexcept = 0; + virtual void Describe(IOutputStream&) const noexcept = 0; const TIntrusiveConstPtr<TRowScheme> Scheme; }; @@ -54,7 +54,7 @@ namespace NTest { } } - void Describe(IOutputStream &out) const noexcept + void Describe(IOutputStream &out) const noexcept { out << "Mass{" diff --git a/ydb/core/tablet_flat/test/libs/table/model/large.h b/ydb/core/tablet_flat/test/libs/table/model/large.h index 6dfb4d6af98..58d9058a79f 100644 --- a/ydb/core/tablet_flat/test/libs/table/model/large.h +++ b/ydb/core/tablet_flat/test/libs/table/model/large.h @@ -52,7 +52,7 @@ namespace NTest { return Seq++, *row; } - void Describe(IOutputStream &out) const noexcept override + void Describe(IOutputStream &out) const noexcept override { out << "Std{" diff --git a/ydb/core/tablet_flat/test/libs/table/model/small.h b/ydb/core/tablet_flat/test/libs/table/model/small.h index d1b0cdfca25..28fb2a07e45 100644 --- a/ydb/core/tablet_flat/test/libs/table/model/small.h +++ b/ydb/core/tablet_flat/test/libs/table/model/small.h @@ -30,7 +30,7 @@ namespace NTest { return *row; } - void Describe(IOutputStream &out) const noexcept override + void Describe(IOutputStream &out) const noexcept override { out << "Model2Cols"; } diff --git a/ydb/core/tablet_flat/test/libs/table/test_steps.h b/ydb/core/tablet_flat/test/libs/table/test_steps.h index d4972ec94f8..526c775f0ed 100644 --- a/ydb/core/tablet_flat/test/libs/table/test_steps.h +++ b/ydb/core/tablet_flat/test/libs/table/test_steps.h @@ -19,7 +19,7 @@ namespace NTest { return static_cast<TImpl&>(*this); } - IOutputStream& Log() const noexcept + IOutputStream& Log() const noexcept { Cerr << "On " << Seq << ": "; diff --git a/ydb/core/tablet_flat/test/tool/perf/logger.h b/ydb/core/tablet_flat/test/tool/perf/logger.h index 979b5fead45..1931245a5f5 100644 --- a/ydb/core/tablet_flat/test/tool/perf/logger.h +++ b/ydb/core/tablet_flat/test/tool/perf/logger.h @@ -22,7 +22,7 @@ namespace NPerf { , public NKikiSched::ILogger { public: - TLogger(int level = 0, int relev = -1, IOutputStream *redir = nullptr) + TLogger(int level = 0, int relev = -1, IOutputStream *redir = nullptr) : Start(Now()) , Level(level) , Relev(redir ? relev : -1) @@ -71,7 +71,7 @@ namespace NPerf { const TInstant Start; const int Level = 0; const int Relev = 0; - IOutputStream *Redir = nullptr; + IOutputStream *Redir = nullptr; }; } } diff --git a/ydb/core/tablet_flat/test/tool/perf/sponge.h b/ydb/core/tablet_flat/test/tool/perf/sponge.h index 4fcce7a6bdc..8b79b4153e8 100644 --- a/ydb/core/tablet_flat/test/tool/perf/sponge.h +++ b/ydb/core/tablet_flat/test/tool/perf/sponge.h @@ -17,7 +17,7 @@ namespace NTest { struct TSponge { TSponge(ESponge kind) : Kind(kind) { } - void Describe(IOutputStream &out) const noexcept + void Describe(IOutputStream &out) const noexcept { out << "Sponge{" diff --git a/ydb/core/tablet_flat/ut/flat_test_db.cpp b/ydb/core/tablet_flat/ut/flat_test_db.cpp index b65757d4bbd..4483bf45c85 100644 --- a/ydb/core/tablet_flat/ut/flat_test_db.cpp +++ b/ydb/core/tablet_flat/ut/flat_test_db.cpp @@ -17,7 +17,7 @@ struct TFakeKey { struct TFakeKeyComparator { bool operator () (const TFakeKey& a, const TFakeKey& b) const { - Y_ASSERT(a.Columns.size() == b.Columns.size()); + Y_ASSERT(a.Columns.size() == b.Columns.size()); for (ui32 i = 0; i < a.Columns.size(); ++i) { const TRawTypeValue& av = a.Columns[i].Get(); const TRawTypeValue& bv = b.Columns[i].Get(); @@ -25,7 +25,7 @@ struct TFakeKeyComparator { return true; if (bv.IsEmpty()) return false; - Y_ASSERT(av.Type() == bv.Type()); + Y_ASSERT(av.Type() == bv.Type()); int res = CompareTypedCells(TCell(&av), TCell(&bv), av.Type()); if (res) return res < 0; @@ -136,7 +136,7 @@ public: } bool IsRowDeleted() override { - Y_ASSERT(IsValid()); + Y_ASSERT(IsValid()); return RowIt->second.IsDeleted; } diff --git a/ydb/core/tablet_flat/ut/flat_test_db.h b/ydb/core/tablet_flat/ut/flat_test_db.h index ed0af81c68a..622be3eca4b 100644 --- a/ydb/core/tablet_flat/ut/flat_test_db.h +++ b/ydb/core/tablet_flat/ut/flat_test_db.h @@ -107,8 +107,8 @@ public: } void Init(const TScheme& scheme) override { - Y_UNUSED(scheme); - Y_VERIFY("Not supported by flat db wrapper"); + Y_UNUSED(scheme); + Y_VERIFY("Not supported by flat db wrapper"); } const TScheme& GetScheme() const override { @@ -116,8 +116,8 @@ public: } TString FinishTransaction(bool commit) override { - Y_UNUSED(commit); - Y_VERIFY("Not supported by flat db wrapper"); + Y_UNUSED(commit); + Y_VERIFY("Not supported by flat db wrapper"); return "42"; } diff --git a/ydb/core/tablet_flat/ut/flat_test_db_helpers.h b/ydb/core/tablet_flat/ut/flat_test_db_helpers.h index ffc9a36daac..d07e2c30009 100644 --- a/ydb/core/tablet_flat/ut/flat_test_db_helpers.h +++ b/ydb/core/tablet_flat/ut/flat_test_db_helpers.h @@ -141,11 +141,11 @@ public: template<typename T> TDbRowUpdate& Set(TString tagName, const T& val) { const TScheme::TTableInfo* tableInfo = Scheme.GetTableInfo(GetRoot()); - Y_VERIFY(tableInfo, "Unknown table id %u", GetRoot()); + Y_VERIFY(tableInfo, "Unknown table id %u", GetRoot()); const ui32* tagId = tableInfo->ColumnNames.FindPtr(tagName); Y_VERIFY(tagId, "Unknown column \"%s\" in table %u", tagName.data(), GetRoot()); const auto *colInfo = Scheme.GetColumnInfo(GetRoot(), *tagId); - Y_VERIFY(colInfo, "Column info not found for table id %u, column id %u", GetRoot(), *tagId); + Y_VERIFY(colInfo, "Column info not found for table id %u, column id %u", GetRoot(), *tagId); NScheme::TTypeId type = colInfo->PType; TagOps[*tagId] = FromVal(type, val); return *this; @@ -153,11 +153,11 @@ public: TDbRowUpdate& Erase(TString tagName) { const TScheme::TTableInfo* tableInfo = Scheme.GetTableInfo(GetRoot()); - Y_VERIFY(tableInfo, "Unknown table id %u", GetRoot()); + Y_VERIFY(tableInfo, "Unknown table id %u", GetRoot()); const ui32* tagId = tableInfo->ColumnNames.FindPtr(tagName); Y_VERIFY(tagId, "Unknown column \"%s\" in table %u", tagName.data(), GetRoot()); const auto * colInfo = Scheme.GetColumnInfo(GetRoot(), *tagId); - Y_VERIFY(colInfo, "Column info not found for table id %u, column id %u", GetRoot(), *tagId); + Y_VERIFY(colInfo, "Column info not found for table id %u, column id %u", GetRoot(), *tagId); TagOps[*tagId] = MakeNull(ECellOp::Null); return *this; } @@ -217,7 +217,7 @@ public: void Apply(const TDbRowUpdate& update) { TVector<TRawTypeValue> key; - Y_VERIFY(!update.GetKey().empty()); + Y_VERIFY(!update.GetKey().empty()); for (const auto& col : update.GetKey()) { key.push_back(col.Get()); } @@ -232,7 +232,7 @@ public: void Apply(const TDbRowErase& erase) { TVector<TRawTypeValue> key; - Y_VERIFY(!erase.GetKey().empty()); + Y_VERIFY(!erase.GetKey().empty()); for (const auto& col : erase.GetKey()) { key.push_back(col.Get()); } diff --git a/ydb/core/tablet_flat/ut/ut_bloom.cpp b/ydb/core/tablet_flat/ut/ut_bloom.cpp index 0ba3f5b6629..e7fe90c74c6 100644 --- a/ydb/core/tablet_flat/ut/ut_bloom.cpp +++ b/ydb/core/tablet_flat/ut/ut_bloom.cpp @@ -10,7 +10,7 @@ namespace NKikimr { namespace NTable { -Y_UNIT_TEST_SUITE(Bloom) { +Y_UNIT_TEST_SUITE(Bloom) { using namespace NTest; static const NTest::TMass Mass0(new NTest::TModelS3Hash, 24000, 42, 0.5); @@ -104,14 +104,14 @@ Y_UNIT_TEST_SUITE(Bloom) { return alter; } - Y_UNIT_TEST(Conf) + Y_UNIT_TEST(Conf) { NBloom::TEstimator estimator(0.001); UNIT_ASSERT(estimator.Hashes() > 0); UNIT_ASSERT(estimator.Bits(0) > 0); } - Y_UNIT_TEST(Hashes) + Y_UNIT_TEST(Hashes) { const NTest::TRowTool tool(*Mass0.Model->Scheme); @@ -129,7 +129,7 @@ Y_UNIT_TEST_SUITE(Bloom) { UNIT_ASSERT_C(0x3841f2f07c20fc07 == salt, "Hash is broken"); } - Y_UNIT_TEST(Rater) + Y_UNIT_TEST(Rater) { const auto filter = TCooker::Make(Mass0, 0.001); @@ -138,7 +138,7 @@ Y_UNIT_TEST_SUITE(Bloom) { UNIT_ASSERT_C(rate < 0.001 * 1.3, "Bloom filter error " << rate); } - Y_UNIT_TEST(Dipping) + Y_UNIT_TEST(Dipping) { double edge = 0.13, error = 0.1; @@ -153,7 +153,7 @@ Y_UNIT_TEST_SUITE(Bloom) { } } - Y_UNIT_TEST(Basics) + Y_UNIT_TEST(Basics) { TDbExec me; @@ -243,7 +243,7 @@ Y_UNIT_TEST_SUITE(Bloom) { } } - Y_UNIT_TEST(Stairs) + Y_UNIT_TEST(Stairs) { const ui32 Height = 99; diff --git a/ydb/core/tablet_flat/ut/ut_charge.cpp b/ydb/core/tablet_flat/ut/ut_charge.cpp index 17717c26f15..761850b8712 100644 --- a/ydb/core/tablet_flat/ut/ut_charge.cpp +++ b/ydb/core/tablet_flat/ut/ut_charge.cpp @@ -176,11 +176,11 @@ namespace { } -Y_UNIT_TEST_SUITE(Charge) { +Y_UNIT_TEST_SUITE(Charge) { using namespace NTest; - Y_UNIT_TEST(Lookups) + Y_UNIT_TEST(Lookups) { TLayoutCook lay; @@ -206,7 +206,7 @@ Y_UNIT_TEST_SUITE(Charge) { Thus, need to test TIndex::Lookup () for that cases only. */ } - Y_UNIT_TEST(Basics) + Y_UNIT_TEST(Basics) { using TArr = TTouchEnv::TArr; @@ -253,7 +253,7 @@ Y_UNIT_TEST_SUITE(Charge) { } } - Y_UNIT_TEST(Limits) + Y_UNIT_TEST(Limits) { /* XXX: Precharger is conservative about row limits, because it cannot know how many rows will really be consumed on the diff --git a/ydb/core/tablet_flat/ut/ut_compaction.cpp b/ydb/core/tablet_flat/ut/ut_compaction.cpp index ef0d9bbf152..e10246de237 100644 --- a/ydb/core/tablet_flat/ut/ut_compaction.cpp +++ b/ydb/core/tablet_flat/ut/ut_compaction.cpp @@ -12,9 +12,9 @@ namespace NKikimr { namespace NTable { -Y_UNIT_TEST_SUITE(TCompaction) { +Y_UNIT_TEST_SUITE(TCompaction) { - Y_UNIT_TEST(OneMemtable) + Y_UNIT_TEST(OneMemtable) { using namespace NTest; @@ -25,7 +25,7 @@ Y_UNIT_TEST_SUITE(TCompaction) { TCheckIt(eggs, { }).IsTheSame(mass.Saved); } - Y_UNIT_TEST(ManyParts) + Y_UNIT_TEST(ManyParts) { using namespace NTest; @@ -37,7 +37,7 @@ Y_UNIT_TEST_SUITE(TCompaction) { TCheckIt(eggs, { }).IsTheSame(mass.Saved); } - Y_UNIT_TEST(BootAbort) + Y_UNIT_TEST(BootAbort) { using namespace NTest; @@ -53,7 +53,7 @@ Y_UNIT_TEST_SUITE(TCompaction) { UNIT_ASSERT(!eggs.Parts && eggs.NoResult()); } - Y_UNIT_TEST(Defaults) + Y_UNIT_TEST(Defaults) { using namespace NTest; @@ -97,7 +97,7 @@ Y_UNIT_TEST_SUITE(TCompaction) { } } - Y_UNIT_TEST(Merges) + Y_UNIT_TEST(Merges) { using namespace NTest; diff --git a/ydb/core/tablet_flat/ut/ut_db_iface.cpp b/ydb/core/tablet_flat/ut/ut_db_iface.cpp index 9843e5a6033..2a4d2296d74 100644 --- a/ydb/core/tablet_flat/ut/ut_db_iface.cpp +++ b/ydb/core/tablet_flat/ut/ut_db_iface.cpp @@ -8,7 +8,7 @@ namespace NKikimr { namespace NTable { -Y_UNIT_TEST_SUITE(DBase) { +Y_UNIT_TEST_SUITE(DBase) { using namespace NTest; TAlter MakeAlter(const ui32 table = 1) @@ -25,7 +25,7 @@ Y_UNIT_TEST_SUITE(DBase) { return alter; } - Y_UNIT_TEST(Basics) + Y_UNIT_TEST(Basics) { TDbExec me; @@ -95,7 +95,7 @@ Y_UNIT_TEST_SUITE(DBase) { UNIT_ASSERT(me.GetLog().size() == 10); } - Y_UNIT_TEST(Select) + Y_UNIT_TEST(Select) { TDbExec me; @@ -129,7 +129,7 @@ Y_UNIT_TEST_SUITE(DBase) { UNIT_ASSERT(subset->Flatten.size() == 3 && subset->Frozen.size() == 3); } - Y_UNIT_TEST(Defaults) + Y_UNIT_TEST(Defaults) { TDbExec me; @@ -174,7 +174,7 @@ Y_UNIT_TEST_SUITE(DBase) { .To(24).HasN("bar", 11_u32, 33_u64, "me", "you", large35); } - Y_UNIT_TEST(Subsets) + Y_UNIT_TEST(Subsets) { TDbExec me; @@ -217,7 +217,7 @@ Y_UNIT_TEST_SUITE(DBase) { } } - Y_UNIT_TEST(Garbage) + Y_UNIT_TEST(Garbage) { TDbExec me; @@ -281,7 +281,7 @@ Y_UNIT_TEST_SUITE(DBase) { UNIT_ASSERT(me->Counters().Parts.OtherBytes == 0); } - Y_UNIT_TEST(Affects) + Y_UNIT_TEST(Affects) { TDbExec me; @@ -321,7 +321,7 @@ Y_UNIT_TEST_SUITE(DBase) { me.To(40).Replay(EPlay::Boot).Replay(EPlay::Redo); } - Y_UNIT_TEST(WideKey) + Y_UNIT_TEST(WideKey) { const TIntrusivePtr<TGrowHeap> heap = new TGrowHeap(128 * 1024); @@ -349,7 +349,7 @@ Y_UNIT_TEST_SUITE(DBase) { } } - Y_UNIT_TEST(Annex) + Y_UNIT_TEST(Annex) { auto alter = MakeAlter(1); @@ -439,7 +439,7 @@ Y_UNIT_TEST_SUITE(DBase) { UNIT_ASSERT(closed->Frozen.at(0)->GetBlobs()->Head == 3); } - Y_UNIT_TEST(Outer) + Y_UNIT_TEST(Outer) { auto alter = MakeAlter(1); diff --git a/ydb/core/tablet_flat/ut/ut_db_scheme.cpp b/ydb/core/tablet_flat/ut/ut_db_scheme.cpp index ee12efa9032..dff5b746fad 100644 --- a/ydb/core/tablet_flat/ut/ut_db_scheme.cpp +++ b/ydb/core/tablet_flat/ut/ut_db_scheme.cpp @@ -128,8 +128,8 @@ namespace { }; } -Y_UNIT_TEST_SUITE(TScheme) { - Y_UNIT_TEST(Shapshot) +Y_UNIT_TEST_SUITE(TScheme) { + Y_UNIT_TEST(Shapshot) { const TModel model; @@ -150,7 +150,7 @@ Y_UNIT_TEST_SUITE(TScheme) { UNIT_ASSERT(TCompare().Do(TModel::TableId, origin, restored)); } - Y_UNIT_TEST(Delta) + Y_UNIT_TEST(Delta) { const TModel model; @@ -163,7 +163,7 @@ Y_UNIT_TEST_SUITE(TScheme) { model.Check(restored); } - Y_UNIT_TEST(Policy) + Y_UNIT_TEST(Policy) { auto delta = TModel().Build(); diff --git a/ydb/core/tablet_flat/ut/ut_forward.cpp b/ydb/core/tablet_flat/ut/ut_forward.cpp index 246d3c70b37..8a32cfbb272 100644 --- a/ydb/core/tablet_flat/ut/ut_forward.cpp +++ b/ydb/core/tablet_flat/ut/ut_forward.cpp @@ -128,7 +128,7 @@ namespace { }; } -Y_UNIT_TEST_SUITE(NFwd) { +Y_UNIT_TEST_SUITE(NFwd) { static TIntrusiveConstPtr<NPage::TFrames> Cook() { @@ -180,7 +180,7 @@ Y_UNIT_TEST_SUITE(NFwd) { } } - Y_UNIT_TEST(Lower) + Y_UNIT_TEST(Lower) { const auto frames = Cook(); @@ -197,7 +197,7 @@ Y_UNIT_TEST_SUITE(NFwd) { UNIT_ASSERT(frames->Lower(15, Max<ui32>(), Max<ui32>()) == 10); } - Y_UNIT_TEST(Sieve) + Y_UNIT_TEST(Sieve) { NPage::TExtBlobsWriter out; @@ -286,7 +286,7 @@ Y_UNIT_TEST_SUITE(NFwd) { UNIT_ASSERT(logo[1] == globs[5].Logo); } - Y_UNIT_TEST(Basics) + Y_UNIT_TEST(Basics) { /*_ Check unorderd access over the same frame */ TWrap(Cook(), 61).Get(1, false, true, true).Get(0, false, true, true); @@ -304,7 +304,7 @@ Y_UNIT_TEST_SUITE(NFwd) { TWrap(Cook(), 61).Get(3, false, true, true).Get(7, false, true, true); } - Y_UNIT_TEST(Simple) + Y_UNIT_TEST(Simple) { TWrap(Cook(), 61, 999, 999) /*_ Get, load and reread the same blob */ @@ -317,7 +317,7 @@ Y_UNIT_TEST_SUITE(NFwd) { .To(14).Get(6, true, false, true); } - Y_UNIT_TEST(Shuffle) + Y_UNIT_TEST(Shuffle) { TWrap(Cook(), 61, 999, 999) /*_ Touch two columns on the same frame */ @@ -332,7 +332,7 @@ Y_UNIT_TEST_SUITE(NFwd) { .To(21).Fill(2, 3, { 1 }); } - Y_UNIT_TEST(Grow) + Y_UNIT_TEST(Grow) { TWrap(Cook(), 55, 15, 30) .To(10).Get(1, false, true, true).Fill(2, 3, { 2 }) @@ -342,7 +342,7 @@ Y_UNIT_TEST_SUITE(NFwd) { .To(17).Get(9, true, false, true).Fill(0, 1, { 2 }); } - Y_UNIT_TEST(Trace) + Y_UNIT_TEST(Trace) { TWrap wrap(Cook(), 15, 999, 999); diff --git a/ydb/core/tablet_flat/ut/ut_iterator.cpp b/ydb/core/tablet_flat/ut/ut_iterator.cpp index c14bad7cb44..fe41c1cabf3 100644 --- a/ydb/core/tablet_flat/ut/ut_iterator.cpp +++ b/ydb/core/tablet_flat/ut/ut_iterator.cpp @@ -54,10 +54,10 @@ namespace { using TCheckIt = NTest::TChecker<NTest::TWrapIter, TSubset>; using TCheckReverseIt = NTest::TChecker<NTest::TWrapReverseIter, TSubset>; -Y_UNIT_TEST_SUITE(TIterator) { +Y_UNIT_TEST_SUITE(TIterator) { using namespace NTest; - Y_UNIT_TEST(Basics) + Y_UNIT_TEST(Basics) { TCheckIt wrap(*TMake(Mass0).Mixed(0, 1, TMixerOne{ }), { }); @@ -77,7 +77,7 @@ Y_UNIT_TEST_SUITE(TIterator) { } } - Y_UNIT_TEST(External) + Y_UNIT_TEST(External) { TCheckIt wrap(*TMake(Mass0, Conf()).Mixed(0, 1, TMixerOne{ }), { }); @@ -104,7 +104,7 @@ Y_UNIT_TEST_SUITE(TIterator) { wrap.To(8).Next().Is(Mass0.Saved[on]); } - Y_UNIT_TEST(Single) + Y_UNIT_TEST(Single) { auto subset = TMake(Mass0, Conf()).Mixed(0, 1, TMixerOne{ }); @@ -118,7 +118,7 @@ Y_UNIT_TEST_SUITE(TIterator) { TWreck<TCheckReverseIt, TSubset, EDirection::Reverse>(Mass0, 666).Do(EWreck::Cached, *subset); } - Y_UNIT_TEST(Mixed) + Y_UNIT_TEST(Mixed) { auto subset = TMake(Mass0, Conf(384)).Mixed(2, 2, TMixerRnd(4)); diff --git a/ydb/core/tablet_flat/ut/ut_memtable.cpp b/ydb/core/tablet_flat/ut/ut_memtable.cpp index d5b6c328648..59b6ec04157 100644 --- a/ydb/core/tablet_flat/ut/ut_memtable.cpp +++ b/ydb/core/tablet_flat/ut/ut_memtable.cpp @@ -18,7 +18,7 @@ namespace { using TCheckIt = NTest::TChecker<NTest::TWrapMemtable, TIntrusiveConstPtr<TMemTable>>; using TCheckReverseIt = NTest::TChecker<NTest::TWrapReverseMemtable, TIntrusiveConstPtr<TMemTable>>; -Y_UNIT_TEST_SUITE(Memtable) +Y_UNIT_TEST_SUITE(Memtable) { using namespace NTest; @@ -34,7 +34,7 @@ Y_UNIT_TEST_SUITE(Memtable) .RowScheme(); } - Y_UNIT_TEST(Basics) + Y_UNIT_TEST(Basics) { const auto lay = BasicRowLayout(); @@ -113,7 +113,7 @@ Y_UNIT_TEST_SUITE(Memtable) wrap.To(41).Is(bar).Next().Is(foo).Next().Is(EReady::Gone); } - Y_UNIT_TEST(Markers) + Y_UNIT_TEST(Markers) { const auto lay = BasicRowLayout(); @@ -126,7 +126,7 @@ Y_UNIT_TEST_SUITE(Memtable) TCheckIt(*cooker.Add(null, ERowOp::Upsert), { }).To(11).Has(null); } - Y_UNIT_TEST(Overlap) + Y_UNIT_TEST(Overlap) { const auto lay = BasicRowLayout(); @@ -148,14 +148,14 @@ Y_UNIT_TEST_SUITE(Memtable) TCheckIt(*cooker.Add(r0W, ERowOp::Erase), { }).To(19).NoKey(r0W, false); } - Y_UNIT_TEST(Wreck) + Y_UNIT_TEST(Wreck) { auto egg = *TCooker(Mass.Model->Scheme).Add(Mass.Saved, ERowOp::Upsert); TWreck<TCheckIt, TIntrusiveConstPtr<TMemTable>>(Mass, 666).Do(EWreck::Cached, egg); } - Y_UNIT_TEST(Erased) + Y_UNIT_TEST(Erased) { auto egg = *TCooker(Mass.Model->Scheme) diff --git a/ydb/core/tablet_flat/ut/ut_other.cpp b/ydb/core/tablet_flat/ut/ut_other.cpp index ea1c287283e..21e10915d3e 100644 --- a/ydb/core/tablet_flat/ut/ut_other.cpp +++ b/ydb/core/tablet_flat/ut/ut_other.cpp @@ -9,8 +9,8 @@ namespace NKikimr { namespace NTabletFlatExecutor { -Y_UNIT_TEST_SUITE(NOther) { - Y_UNIT_TEST(Blocks) +Y_UNIT_TEST_SUITE(NOther) { + Y_UNIT_TEST(Blocks) { NWriter::TConf conf; diff --git a/ydb/core/tablet_flat/ut/ut_pages.cpp b/ydb/core/tablet_flat/ut/ut_pages.cpp index b9e417861a5..9b88204c786 100644 --- a/ydb/core/tablet_flat/ut/ut_pages.cpp +++ b/ydb/core/tablet_flat/ut/ut_pages.cpp @@ -22,9 +22,9 @@ namespace { const NTest::TMass MassZ(new NTest::TModelStd(false), 128); } -Y_UNIT_TEST_SUITE(NPage) { +Y_UNIT_TEST_SUITE(NPage) { - Y_UNIT_TEST(Encoded) + Y_UNIT_TEST(Encoded) { using namespace NTable::NTest; @@ -61,7 +61,7 @@ Y_UNIT_TEST_SUITE(NPage) { } } - Y_UNIT_TEST(ABI_002) + Y_UNIT_TEST(ABI_002) { const auto raw = NResource::Find("abi/002_full_part.pages"); diff --git a/ydb/core/tablet_flat/ut/ut_part.cpp b/ydb/core/tablet_flat/ut/ut_part.cpp index 0c336e95aca..8c7e3186a1f 100644 --- a/ydb/core/tablet_flat/ut/ut_part.cpp +++ b/ydb/core/tablet_flat/ut/ut_part.cpp @@ -54,10 +54,10 @@ namespace { } } -Y_UNIT_TEST_SUITE(TPart) { +Y_UNIT_TEST_SUITE(TPart) { using namespace NTest; - Y_UNIT_TEST(State) + Y_UNIT_TEST(State) { TRowState row(2); @@ -69,7 +69,7 @@ Y_UNIT_TEST_SUITE(TPart) { UNIT_ASSERT(row.Need() == 1 && row.Left() == 0); } - Y_UNIT_TEST(Trivials) + Y_UNIT_TEST(Trivials) { TLayoutCook lay; @@ -90,7 +90,7 @@ Y_UNIT_TEST_SUITE(TPart) { } } - Y_UNIT_TEST(Basics) + Y_UNIT_TEST(Basics) { TLayoutCook lay; @@ -165,7 +165,7 @@ Y_UNIT_TEST_SUITE(TPart) { wrap.To(10).Has(foo).Has(bar); } - Y_UNIT_TEST(Nulls) + Y_UNIT_TEST(Nulls) { TLayoutCook lay, fake; @@ -218,7 +218,7 @@ Y_UNIT_TEST_SUITE(TPart) { wrap.To(29).Seek(upp, ESeek::Exact).Is(EReady::Gone); } - Y_UNIT_TEST(Matter) + Y_UNIT_TEST(Matter) { TLayoutCook lay; @@ -270,7 +270,7 @@ Y_UNIT_TEST_SUITE(TPart) { DumpPart(*(*wrap).Eggs.Lone(), 10); } - Y_UNIT_TEST(External) + Y_UNIT_TEST(External) { TLayoutCook lay; @@ -297,7 +297,7 @@ Y_UNIT_TEST_SUITE(TPart) { DumpPart(*(*wrap).Eggs.Lone(), 10); } - Y_UNIT_TEST(Outer) + Y_UNIT_TEST(Outer) { using namespace NTable::NTest; @@ -324,7 +324,7 @@ Y_UNIT_TEST_SUITE(TPart) { DumpPart(*(*wrap).Eggs.Lone(), 10); } - Y_UNIT_TEST(MassCheck) + Y_UNIT_TEST(MassCheck) { UNIT_ASSERT_C(Eggs0().Parts.size() == 1, "Eggs0 has " << Eggs0().Parts.size() << "p"); @@ -389,17 +389,17 @@ Y_UNIT_TEST_SUITE(TPart) { DumpPart(*Eggs0().Lone(), 1); } - Y_UNIT_TEST(WreckPart) + Y_UNIT_TEST(WreckPart) { TWreck<TCheckIt, TPartEggs>(Mass0(), 666).Do(EWreck::Cached, Eggs0()); } - Y_UNIT_TEST(PageFailEnv) + Y_UNIT_TEST(PageFailEnv) { TWreck<TCheckIt, TPartEggs>(Mass0(), 666).Do(EWreck::Evicted, Eggs0()); } - Y_UNIT_TEST(ForwardEnv) + Y_UNIT_TEST(ForwardEnv) { TWreck<TCheckIt, TPartEggs>(Mass0(), 666).Do(EWreck::Forward, Eggs0()); } diff --git a/ydb/core/tablet_flat/ut/ut_proto.cpp b/ydb/core/tablet_flat/ut/ut_proto.cpp index aa1dac4328d..ab7f4b172c0 100644 --- a/ydb/core/tablet_flat/ut/ut_proto.cpp +++ b/ydb/core/tablet_flat/ut/ut_proto.cpp @@ -5,7 +5,7 @@ namespace NKikimr { namespace NTabletFlatExecutor { -Y_UNIT_TEST_SUITE(NProto /* executor binary units */) { +Y_UNIT_TEST_SUITE(NProto /* executor binary units */) { Y_UNIT_TEST(LargeGlobId) { NKikimrExecutorFlat::TPageCollection pageCollection; diff --git a/ydb/core/tablet_flat/ut/ut_redo.cpp b/ydb/core/tablet_flat/ut/ut_redo.cpp index 73271b44036..f2d42796784 100644 --- a/ydb/core/tablet_flat/ut/ut_redo.cpp +++ b/ydb/core/tablet_flat/ut/ut_redo.cpp @@ -9,12 +9,12 @@ namespace NKikimr { namespace NTable { -Y_UNIT_TEST_SUITE(Redo) { +Y_UNIT_TEST_SUITE(Redo) { namespace ETypes = NScheme::NTypeIds; using namespace NTest; - Y_UNIT_TEST(ABI_008) + Y_UNIT_TEST(ABI_008) { /* Redo log taken from DBase::Basics test that cover all events */ diff --git a/ydb/core/tablet_flat/ut/ut_sausage.cpp b/ydb/core/tablet_flat/ut/ut_sausage.cpp index 9fed2caacc8..ec0a43b20fd 100644 --- a/ydb/core/tablet_flat/ut/ut_sausage.cpp +++ b/ydb/core/tablet_flat/ut/ut_sausage.cpp @@ -65,7 +65,7 @@ Y_UNIT_TEST_SUITE(NPageCollection) { return meta.Finish(); } - Y_UNIT_TEST(Align) + Y_UNIT_TEST(Align) { const std::array<ui64, 3> steps = {{ 200, 500, 1000 }}; @@ -89,7 +89,7 @@ Y_UNIT_TEST_SUITE(NPageCollection) { && lookup5.Up.Blob == 1 && lookup5.Up.Skip == 20); } - Y_UNIT_TEST(Meta) + Y_UNIT_TEST(Meta) { TString chunk1(5000000, '1'); TString chunk2(15000000, '2'); @@ -212,7 +212,7 @@ Y_UNIT_TEST_SUITE(NPageCollection) { } } - Y_UNIT_TEST(Grow) + Y_UNIT_TEST(Grow) { const TMeta meta(MakeMeta(), 0); const std::array<ui32, 9> nums = {{ 0, 1, 2, 3, 4, 5, 6, 7, 8 }}; @@ -236,7 +236,7 @@ Y_UNIT_TEST_SUITE(NPageCollection) { UNIT_ASSERT((grow(200) == 10)); } - Y_UNIT_TEST(Groups) + Y_UNIT_TEST(Groups) { const std::array<TGlobId, 6> globs = {{ { TLogoBlobID(1, 2, 3, 1, 10, 0), 7 }, @@ -303,7 +303,7 @@ Y_UNIT_TEST_SUITE(NPageCollection) { } } - Y_UNIT_TEST(Chop) + Y_UNIT_TEST(Chop) { static const std::array<TLogoBlobID, 6> dash = {{ TLogoBlobID(10, 20, 30, 1, 25, 0), diff --git a/ydb/core/tablet_flat/ut/ut_screen.cpp b/ydb/core/tablet_flat/ut/ut_screen.cpp index b2d04bc6cf0..ab7973ebc7c 100644 --- a/ydb/core/tablet_flat/ut/ut_screen.cpp +++ b/ydb/core/tablet_flat/ut/ut_screen.cpp @@ -28,9 +28,9 @@ namespace { } } -Y_UNIT_TEST_SUITE(TScreen) { +Y_UNIT_TEST_SUITE(TScreen) { - Y_UNIT_TEST(Cuts) + Y_UNIT_TEST(Cuts) { using namespace NTable::NTest; using THole = TScreen::THole; @@ -52,7 +52,7 @@ Y_UNIT_TEST_SUITE(TScreen) { TScreen({ {7, 10 }, { 40, 70 }, { 80, 91 } }))); } - Y_UNIT_TEST(Join) + Y_UNIT_TEST(Join) { using namespace NTable::NTest; using THole = TScreen::THole; @@ -85,7 +85,7 @@ Y_UNIT_TEST_SUITE(TScreen) { } } - Y_UNIT_TEST(Sequential) + Y_UNIT_TEST(Sequential) { using namespace NTable::NTest; @@ -133,7 +133,7 @@ Y_UNIT_TEST_SUITE(TScreen) { } } - Y_UNIT_TEST(Random) + Y_UNIT_TEST(Random) { using namespace NTable::NTest; @@ -172,7 +172,7 @@ Y_UNIT_TEST_SUITE(TScreen) { } } - Y_UNIT_TEST(Shrink) + Y_UNIT_TEST(Shrink) { using namespace NTable::NTest; diff --git a/ydb/core/tablet_flat/ut/ut_self.cpp b/ydb/core/tablet_flat/ut/ut_self.cpp index 5cf8efb163c..8b4b8766188 100644 --- a/ydb/core/tablet_flat/ut/ut_self.cpp +++ b/ydb/core/tablet_flat/ut/ut_self.cpp @@ -7,9 +7,9 @@ namespace NKikimr { namespace NTable { -Y_UNIT_TEST_SUITE(Self) { +Y_UNIT_TEST_SUITE(Self) { - Y_UNIT_TEST(Literals) + Y_UNIT_TEST(Literals) { using namespace NTest; using TPut = NTest::TCookRow; diff --git a/ydb/core/testlib/actors/test_runtime_ut.cpp b/ydb/core/testlib/actors/test_runtime_ut.cpp index fce7f192934..8c75df428dd 100644 --- a/ydb/core/testlib/actors/test_runtime_ut.cpp +++ b/ydb/core/testlib/actors/test_runtime_ut.cpp @@ -8,14 +8,14 @@ namespace NKikimr { using namespace NActors; -Y_UNIT_TEST_SUITE(TActorTest) { +Y_UNIT_TEST_SUITE(TActorTest) { TTestActorRuntime::TEgg MakeEgg() { return { new TAppData(0, 0, 0, 0, { }, nullptr, nullptr, nullptr, nullptr), nullptr, nullptr }; } - Y_UNIT_TEST(TestHandleEvent) { + Y_UNIT_TEST(TestHandleEvent) { class TMyActor : public TActor<TMyActor> { public: TMyActor(const TActorId& sender) @@ -26,7 +26,7 @@ Y_UNIT_TEST_SUITE(TActorTest) { STFUNC(StateFunc) { - Y_UNUSED(ctx); + Y_UNUSED(ctx); UNIT_ASSERT_EQUAL_C(ev->Sender, Sender, "sender check"); UNIT_ASSERT_EQUAL_C(ev->Type, TEvents::TSystem::Wakeup, "ev. type check"); } @@ -42,7 +42,7 @@ Y_UNIT_TEST_SUITE(TActorTest) { runtime.Send(new IEventHandle(actorId, sender, new TEvents::TEvWakeup)); } - Y_UNIT_TEST(TestDie) { + Y_UNIT_TEST(TestDie) { class TMyActor : public TActor<TMyActor> { public: TMyActor() @@ -64,7 +64,7 @@ Y_UNIT_TEST_SUITE(TActorTest) { runtime.Send(new IEventHandle(actorId, sender, new TEvents::TEvPoisonPill)); } - Y_UNIT_TEST(TestStateSwitch) { + Y_UNIT_TEST(TestStateSwitch) { class TMyActor : public TActor<TMyActor> { public: TMyActor() @@ -75,14 +75,14 @@ Y_UNIT_TEST_SUITE(TActorTest) { STFUNC(OldStateFunc) { - Y_UNUSED(ctx); + Y_UNUSED(ctx); UNIT_ASSERT_EQUAL_C(ev->Type, TEvents::THelloWorld::Ping, "ev. type check"); Become(&TMyActor::NewStateFunc); } STFUNC(NewStateFunc) { - Y_UNUSED(ctx); + Y_UNUSED(ctx); UNIT_ASSERT_EQUAL_C(ev->Type, TEvents::THelloWorld::Pong, "ev. type check"); StateChanged = true; } @@ -106,7 +106,7 @@ Y_UNIT_TEST_SUITE(TActorTest) { UNIT_ASSERT_EQUAL(actor->IsStateChanged(), true); } - Y_UNIT_TEST(TestSendEvent) { + Y_UNIT_TEST(TestSendEvent) { class TMyActor : public TActor<TMyActor> { public: TMyActor() @@ -138,7 +138,7 @@ Y_UNIT_TEST_SUITE(TActorTest) { runtime.PushEventsFront(events); } - Y_UNIT_TEST(TestScheduleEvent) { + Y_UNIT_TEST(TestScheduleEvent) { class TMyActor : public TActor<TMyActor> { public: TMyActor() @@ -148,7 +148,7 @@ Y_UNIT_TEST_SUITE(TActorTest) { STFUNC(StateFunc) { - Y_UNUSED(ev); + Y_UNUSED(ev); ctx.Schedule(TDuration::Seconds(1), new TEvents::TEvWakeup); } }; @@ -156,7 +156,7 @@ Y_UNIT_TEST_SUITE(TActorTest) { TTestActorRuntime runtime; runtime.Initialize(MakeEgg()); runtime.SetScheduledEventFilter([](TTestActorRuntimeBase& runtime, TAutoPtr<IEventHandle>& event, TDuration delay, TInstant& deadline) { - Y_UNUSED(event); + Y_UNUSED(event); deadline = runtime.GetCurrentTime() + delay; return false; }); @@ -170,7 +170,7 @@ Y_UNIT_TEST_SUITE(TActorTest) { UNIT_ASSERT_EQUAL_C(scheduledEvents.begin()->Event->Type, TEvents::TSystem::Wakeup, "scheduled ev. type check"); } - Y_UNIT_TEST(TestCreateChildActor) { + Y_UNIT_TEST(TestCreateChildActor) { class TChildActor : public TActor<TChildActor> { public: TChildActor() @@ -180,8 +180,8 @@ Y_UNIT_TEST_SUITE(TActorTest) { STFUNC(StateFunc) { - Y_UNUSED(ctx); - Y_UNUSED(ev); + Y_UNUSED(ctx); + Y_UNUSED(ev); } }; @@ -194,7 +194,7 @@ Y_UNIT_TEST_SUITE(TActorTest) { STFUNC(StateFunc) { - Y_UNUSED(ev); + Y_UNUSED(ev); ChildId = ctx.RegisterWithSameMailbox(new TChildActor()); ctx.Send(ChildId, new TEvents::TEvPing()); } @@ -226,7 +226,7 @@ Y_UNIT_TEST_SUITE(TActorTest) { runtime.PushEventsFront(events); } - Y_UNIT_TEST(TestSendAfterDelay) { + Y_UNIT_TEST(TestSendAfterDelay) { TMutex syncMutex; class TMyActor : public TActor<TMyActor> { @@ -291,7 +291,7 @@ Y_UNIT_TEST_SUITE(TActorTest) { with_lock(syncMutex) {} } - Y_UNIT_TEST(TestGetCtxTime) { + Y_UNIT_TEST(TestGetCtxTime) { class TMyActor : public TActor<TMyActor> { public: TMyActor() @@ -346,7 +346,7 @@ Y_UNIT_TEST_SUITE(TActorTest) { runtime.PushEventsFront(events); } - Y_UNIT_TEST(TestSendFromAnotherThread) { + Y_UNIT_TEST(TestSendFromAnotherThread) { enum { EvCounter = EventSpaceBegin(TEvents::ES_PRIVATE) }; @@ -374,7 +374,7 @@ Y_UNIT_TEST_SUITE(TActorTest) { STFUNC(StateFunc) { - Y_UNUSED(ctx); + Y_UNUSED(ctx); switch (ev->GetTypeRewrite()) { case EvCounter: ui32 eventCounter = reinterpret_cast<TEvCounter*>(ev->GetBase())->Counter; @@ -405,7 +405,7 @@ Y_UNIT_TEST_SUITE(TActorTest) { STFUNC(StateFunc) { - Y_UNUSED(ev); + Y_UNUSED(ev); SelfId = ctx.SelfID; ActorSystem = ctx.ExecutorThread.ActorSystem; Thread.Reset(new TThread(&TProducerActor::ThreadProc, this)); @@ -454,8 +454,8 @@ Y_UNIT_TEST_SUITE(TActorTest) { TActorId producerId = runtime.Register(producerActor); runtime.Send(new IEventHandle(producerId, sender, new TEvents::TEvPing)); runtime.SetObserverFunc([](TTestActorRuntimeBase& runtime, TAutoPtr<IEventHandle>& event) { - Y_UNUSED(runtime); - Y_UNUSED(event); + Y_UNUSED(runtime); + Y_UNUSED(event); return TTestActorRuntime::EEventAction::PROCESS; }); @@ -478,7 +478,7 @@ Y_UNIT_TEST_SUITE(TActorTest) { } } - Y_UNIT_TEST(TestScheduleReaction) { + Y_UNIT_TEST(TestScheduleReaction) { class TMyActor : public TActor<TMyActor> { public: TMyActor() @@ -533,7 +533,7 @@ Y_UNIT_TEST_SUITE(TActorTest) { UNIT_ASSERT(myActor->CompletedReceived); } - Y_UNIT_TEST(TestFilteredGrab) { + Y_UNIT_TEST(TestFilteredGrab) { enum EEv { EvCounter = EventSpaceBegin(TEvents::ES_PRIVATE) }; diff --git a/ydb/core/testlib/minikql_compile.h b/ydb/core/testlib/minikql_compile.h index 4d76ca8d735..41208cd556c 100644 --- a/ydb/core/testlib/minikql_compile.h +++ b/ydb/core/testlib/minikql_compile.h @@ -57,13 +57,13 @@ public: } virtual void ResolveTables(const TVector<TTable>& tables, NActors::TActorId responseTo) override { - Y_UNUSED(tables); - Y_UNUSED(responseTo); + Y_UNUSED(tables); + Y_UNUSED(responseTo); ythrow yexception() << "Not implemented"; } void AddTable(const IDbSchemeResolver::TTableResult& table) { - Y_ENSURE(!!table.TableId, "TableId must be defined"); + Y_ENSURE(!!table.TableId, "TableId must be defined"); if (!Tables.insert({ table.Table.TableName, table }).second) { ythrow yexception() << "Table " << table.Table.TableName << " is already registered"; } diff --git a/ydb/core/testlib/tablet_flat_dummy.cpp b/ydb/core/testlib/tablet_flat_dummy.cpp index 1a9dca04a52..e03b953e854 100644 --- a/ydb/core/testlib/tablet_flat_dummy.cpp +++ b/ydb/core/testlib/tablet_flat_dummy.cpp @@ -70,7 +70,7 @@ class TDummyFlatTablet : public TActor<TDummyFlatTablet>, public NTabletFlatExec bool Execute(TTransactionContext &txc, const TActorContext &ctx) override { Y_UNUSED(txc); - Y_UNUSED(ctx); + Y_UNUSED(ctx); return true; } @@ -83,7 +83,7 @@ class TDummyFlatTablet : public TActor<TDummyFlatTablet>, public NTabletFlatExec friend struct TTxInit; void Handle(TEvents::TEvPoisonPill::TPtr &ev, const TActorContext &ctx) { - Y_UNUSED(ev); + Y_UNUSED(ev); Become(&TThis::StateBroken); ctx.Send(Tablet(), new TEvents::TEvPoisonPill); } @@ -101,12 +101,12 @@ class TDummyFlatTablet : public TActor<TDummyFlatTablet>, public NTabletFlatExec } void OnTabletDead(TEvTablet::TEvTabletDead::TPtr &ev, const TActorContext &ctx) override { - Y_UNUSED(ev); + Y_UNUSED(ev); Die(ctx); } void DefaultSignalTabletActive(const TActorContext &ctx) override { - Y_UNUSED(ctx); + Y_UNUSED(ctx); } public: diff --git a/ydb/core/testlib/tablet_helpers.cpp b/ydb/core/testlib/tablet_helpers.cpp index a853040b932..754661b9969 100644 --- a/ydb/core/testlib/tablet_helpers.cpp +++ b/ydb/core/testlib/tablet_helpers.cpp @@ -33,7 +33,7 @@ #include <util/random/mersenne.h> #include <library/cpp/regex/pcre/regexp.h> #include <util/string/printf.h> -#include <util/string/subst.h> +#include <util/string/subst.h> #include <util/system/env.h> #include <util/system/sanitizers.h> #include <library/cpp/actors/interconnect/interconnect.h> @@ -165,7 +165,7 @@ namespace NKikimr { {} void OnEvent(TTestActorRuntimeBase& runtime, TAutoPtr<IEventHandle>& event) { - Y_UNUSED(runtime); + Y_UNUSED(runtime); if (event->GetTypeRewrite() == TEvStateStorage::EvInfo) { auto info = static_cast<TEvStateStorage::TEvInfo*>(event->GetBase()); if (info->Status == NKikimrProto::OK && (Find(TabletIds.begin(), TabletIds.end(), info->TabletID) != TabletIds.end())) { @@ -192,7 +192,7 @@ namespace NKikimr { } void OnRegistration(TTestActorRuntime& runtime, const TActorId& parentId, const TActorId& actorId) { - Y_UNUSED(runtime); + Y_UNUSED(runtime); auto it = TabletRelatedActors.find(parentId); if (it != TabletRelatedActors.end()) { TabletRelatedActors.insert(std::make_pair(actorId, it->second)); @@ -467,7 +467,7 @@ namespace NKikimr { if (currentItem->DelayedExecution) { if (TRACE_DELAY_TIMING) Cout << "= "; - Y_VERIFY(currentItem->DelayedExecution->Complete); + Y_VERIFY(currentItem->DelayedExecution->Complete); } else { if (TRACE_DELAY_TIMING) Cout << "+ "; @@ -486,7 +486,7 @@ namespace NKikimr { CurrentItems.push_back(currentItem->DelayedExecution.Get()); return TTestActorRuntime::EEventAction::RESCHEDULE; } else { - Y_FAIL(); + Y_FAIL(); } } @@ -1078,7 +1078,7 @@ namespace NKikimr { class TFakeHive : public TActor<TFakeHive>, public NTabletFlatExecutor::TTabletExecutedFlat { public: static std::function<IActor* (const TActorId &, TTabletStorageInfo*)> DefaultGetTabletCreationFunc(ui32 type) { - Y_UNUSED(type); + Y_UNUSED(type); return nullptr; } @@ -1113,7 +1113,7 @@ namespace NKikimr { } void OnTabletDead(TEvTablet::TEvTabletDead::TPtr &ev, const TActorContext &ctx) override { - Y_UNUSED(ev); + Y_UNUSED(ev); Die(ctx); } @@ -1400,7 +1400,7 @@ namespace NKikimr { } void Handle(TEvents::TEvPoisonPill::TPtr &ev, const TActorContext &ctx) { - Y_UNUSED(ev); + Y_UNUSED(ev); Become(&TThis::BrokenState); ctx.Send(Tablet(), new TEvents::TEvPoisonPill); } diff --git a/ydb/core/tx/balance_coverage/balance_coverage_builder.cpp b/ydb/core/tx/balance_coverage/balance_coverage_builder.cpp index abec7fc8afc..47ba94baf33 100644 --- a/ydb/core/tx/balance_coverage/balance_coverage_builder.cpp +++ b/ydb/core/tx/balance_coverage/balance_coverage_builder.cpp @@ -22,7 +22,7 @@ namespace NKikimr { bool hasAdded = false; for (const auto& track : tracks.GetTrack()) { - Y_VERIFY_DEBUG(track.HopSize() > 0); + Y_VERIFY_DEBUG(track.HopSize() > 0); bool result = AddToTree(track); hasAdded = hasAdded || result; } @@ -39,7 +39,7 @@ namespace NKikimr { } bool TBalanceCoverageBuilder::AddNode(TAutoPtr<TNode>& node, const NKikimrTx::TBalanceTrack& track, ui32 index) { - Y_VERIFY(node->Tablet == track.GetHop(index).GetShard()); + Y_VERIFY(node->Tablet == track.GetHop(index).GetShard()); ++index; if (index == track.HopSize()) { bool oldResult = node->HasResult; diff --git a/ydb/core/tx/balance_coverage/balance_coverage_builder_ut.cpp b/ydb/core/tx/balance_coverage/balance_coverage_builder_ut.cpp index 89a3b011ff9..ab7ebdedb31 100644 --- a/ydb/core/tx/balance_coverage/balance_coverage_builder_ut.cpp +++ b/ydb/core/tx/balance_coverage/balance_coverage_builder_ut.cpp @@ -5,8 +5,8 @@ namespace NKikimr { namespace NTxDataShard { -Y_UNIT_TEST_SUITE(TBalanceCoverageBuilderTest) { - Y_UNIT_TEST(TestZeroTracks) { +Y_UNIT_TEST_SUITE(TBalanceCoverageBuilderTest) { + Y_UNIT_TEST(TestZeroTracks) { TBalanceCoverageBuilder builder; UNIT_ASSERT(!builder.IsComplete()); NKikimrTx::TBalanceTrackList tracks; @@ -15,7 +15,7 @@ Y_UNIT_TEST_SUITE(TBalanceCoverageBuilderTest) { UNIT_ASSERT(builder.IsComplete()); } - Y_UNIT_TEST(TestEmpty) { + Y_UNIT_TEST(TestEmpty) { TBalanceCoverageBuilder builder; UNIT_ASSERT(!builder.IsComplete()); NKikimrTx::TBalanceTrackList tracks; @@ -26,7 +26,7 @@ Y_UNIT_TEST_SUITE(TBalanceCoverageBuilderTest) { UNIT_ASSERT(builder.IsComplete()); } - Y_UNIT_TEST(TestOneSplit) { + Y_UNIT_TEST(TestOneSplit) { TBalanceCoverageBuilder builder; UNIT_ASSERT(!builder.IsComplete()); NKikimrTx::TBalanceTrackList tracks; @@ -38,7 +38,7 @@ Y_UNIT_TEST_SUITE(TBalanceCoverageBuilderTest) { UNIT_ASSERT(builder.IsComplete()); } - Y_UNIT_TEST(TestSimpleSplit) { + Y_UNIT_TEST(TestSimpleSplit) { TBalanceCoverageBuilder builder; UNIT_ASSERT(!builder.IsComplete()); NKikimrTx::TBalanceTrackList tracks1; @@ -59,7 +59,7 @@ Y_UNIT_TEST_SUITE(TBalanceCoverageBuilderTest) { UNIT_ASSERT(builder.IsComplete()); } - Y_UNIT_TEST(TestComplexSplit) { + Y_UNIT_TEST(TestComplexSplit) { TBalanceCoverageBuilder builder; UNIT_ASSERT(!builder.IsComplete()); NKikimrTx::TBalanceTrackList tracks1; @@ -90,7 +90,7 @@ Y_UNIT_TEST_SUITE(TBalanceCoverageBuilderTest) { UNIT_ASSERT(builder.IsComplete()); } - Y_UNIT_TEST(TestComplexSplitWithDuplicates) { + Y_UNIT_TEST(TestComplexSplitWithDuplicates) { TBalanceCoverageBuilder builder; UNIT_ASSERT(!builder.IsComplete()); NKikimrTx::TBalanceTrackList tracks1; @@ -127,7 +127,7 @@ Y_UNIT_TEST_SUITE(TBalanceCoverageBuilderTest) { UNIT_ASSERT(!res); } - Y_UNIT_TEST(TestSplitWithPartialMergeOne) { + Y_UNIT_TEST(TestSplitWithPartialMergeOne) { TBalanceCoverageBuilder builder; UNIT_ASSERT(!builder.IsComplete()); NKikimrTx::TBalanceTrackList tracks1; @@ -153,7 +153,7 @@ Y_UNIT_TEST_SUITE(TBalanceCoverageBuilderTest) { UNIT_ASSERT(builder.IsComplete()); } - Y_UNIT_TEST(TestSplitWithPartialMergeAll) { + Y_UNIT_TEST(TestSplitWithPartialMergeAll) { TBalanceCoverageBuilder builder; UNIT_ASSERT(!builder.IsComplete()); NKikimrTx::TBalanceTrackList tracks1; @@ -194,7 +194,7 @@ Y_UNIT_TEST_SUITE(TBalanceCoverageBuilderTest) { UNIT_ASSERT(builder.IsComplete()); } - Y_UNIT_TEST(TestSplitWithMergeBack) { + Y_UNIT_TEST(TestSplitWithMergeBack) { TBalanceCoverageBuilder builder; UNIT_ASSERT(!builder.IsComplete()); NKikimrTx::TBalanceTrackList tracks1; diff --git a/ydb/core/tx/coordinator/coordinator.h b/ydb/core/tx/coordinator/coordinator.h index e7a76df3cee..b802ff86bc0 100644 --- a/ydb/core/tx/coordinator/coordinator.h +++ b/ydb/core/tx/coordinator/coordinator.h @@ -112,7 +112,7 @@ struct TEvTxCoordinator { } template<> -inline void Out<NKikimrTx::TEvCoordinatorStepResult::EStatus>(IOutputStream& o, NKikimrTx::TEvCoordinatorStepResult::EStatus x) { +inline void Out<NKikimrTx::TEvCoordinatorStepResult::EStatus>(IOutputStream& o, NKikimrTx::TEvCoordinatorStepResult::EStatus x) { o << NKikimrTx::TEvCoordinatorStepResult::EStatus_Name(x).data(); return; } diff --git a/ydb/core/tx/coordinator/coordinator__check.h b/ydb/core/tx/coordinator/coordinator__check.h index 8277b0200be..4b8ce6a9655 100644 --- a/ydb/core/tx/coordinator/coordinator__check.h +++ b/ydb/core/tx/coordinator/coordinator__check.h @@ -40,7 +40,7 @@ struct TTxCoordinator::TTxConsistencyCheck : public TTransactionBase<TTxCoordina TTabletId medId = rowset.GetValue<Schema::AffectedSet::MediatorID>(); TTxId txId = rowset.GetValue<Schema::AffectedSet::TransactionID>(); auto itTransaction = transactions.find(txId); - Y_ENSURE(itTransaction != transactions.end(), "Could not find mediator's transaction"); + Y_ENSURE(itTransaction != transactions.end(), "Could not find mediator's transaction"); THashSet<TTabletId>& unconfirmedAffectedSet = itTransaction->second.UnconfirmedAffectedSet[medId]; unconfirmedAffectedSet.insert(rowset.GetValue<Schema::AffectedSet::DataShardID>()); if (!rowset.Next()) @@ -48,17 +48,17 @@ struct TTxCoordinator::TTxConsistencyCheck : public TTransactionBase<TTxCoordina } } { - Y_ENSURE(transactions.size() == Self->Transactions.size(), "Size of in memory and stored transactions mismatch"); + Y_ENSURE(transactions.size() == Self->Transactions.size(), "Size of in memory and stored transactions mismatch"); for (auto it = transactions.begin(); it != transactions.end(); ++it) { auto jt = Self->Transactions.find(it->first); - Y_ENSURE(jt != Self->Transactions.end(), "Stored transaction hasn't been found in memory"); - Y_ENSURE(it->second.PlanOnStep == jt->second.PlanOnStep, "Plan step mismatch"); - Y_ENSURE(it->second.AffectedSet == jt->second.AffectedSet, "Affected set mismatch"); - Y_ENSURE(it->second.UnconfirmedAffectedSet.size() == jt->second.UnconfirmedAffectedSet.size(), "Unconfirmed affected set size mismatch"); + Y_ENSURE(jt != Self->Transactions.end(), "Stored transaction hasn't been found in memory"); + Y_ENSURE(it->second.PlanOnStep == jt->second.PlanOnStep, "Plan step mismatch"); + Y_ENSURE(it->second.AffectedSet == jt->second.AffectedSet, "Affected set mismatch"); + Y_ENSURE(it->second.UnconfirmedAffectedSet.size() == jt->second.UnconfirmedAffectedSet.size(), "Unconfirmed affected set size mismatch"); for (auto kt = it->second.UnconfirmedAffectedSet.begin(); kt != it->second.UnconfirmedAffectedSet.end(); ++kt) { auto lt = jt->second.UnconfirmedAffectedSet.find(kt->first); - Y_ENSURE(lt != jt->second.UnconfirmedAffectedSet.end(), "Mediator hasn't' been found in memory"); - Y_ENSURE(lt->second == kt->second, "Unconfirmed affected set doesn't match"); + Y_ENSURE(lt != jt->second.UnconfirmedAffectedSet.end(), "Mediator hasn't' been found in memory"); + Y_ENSURE(lt->second == kt->second, "Unconfirmed affected set doesn't match"); } } } diff --git a/ydb/core/tx/coordinator/coordinator__mediators_confirmations.cpp b/ydb/core/tx/coordinator/coordinator__mediators_confirmations.cpp index 28a644503d9..6af0e52132b 100644 --- a/ydb/core/tx/coordinator/coordinator__mediators_confirmations.cpp +++ b/ydb/core/tx/coordinator/coordinator__mediators_confirmations.cpp @@ -21,7 +21,7 @@ struct TTxCoordinator::TTxMediatorConfirmations : public TTransactionBase<TTxCoo bool Execute(TTransactionContext &txc, const TActorContext &ctx) override { const TTabletId mediatorId = Confirmations->MediatorId; - Y_UNUSED(ctx); + Y_UNUSED(ctx); CompleteTransactions = 0; NIceDb::TNiceDb db(txc.DB); @@ -78,7 +78,7 @@ struct TTxCoordinator::TTxMediatorConfirmations : public TTransactionBase<TTxCoo *Self->MonCounters.TxInFly -= CompleteTransactions; Self->MonCounters.CurrentTxInFly -= CompleteTransactions; - Y_UNUSED(ctx); + Y_UNUSED(ctx); } }; diff --git a/ydb/core/tx/coordinator/coordinator__plan_step.cpp b/ydb/core/tx/coordinator/coordinator__plan_step.cpp index c1fac2ffa58..fda56f1bfd6 100644 --- a/ydb/core/tx/coordinator/coordinator__plan_step.cpp +++ b/ydb/core/tx/coordinator/coordinator__plan_step.cpp @@ -42,7 +42,7 @@ struct TTxCoordinator::TTxPlanStep : public TTransactionBase<TTxCoordinator> { } void Plan(TTransactionContext &txc, const TActorContext &ctx) { - Y_UNUSED(txc); + Y_UNUSED(txc); NIceDb::TNiceDb db(txc.DB); ExecStartMoment = ctx.Now(); const bool lowDiskSpace = Self->Executor()->GetStats().IsAnyChannelYellowStop; @@ -69,7 +69,7 @@ struct TTxCoordinator::TTxPlanStep : public TTransactionBase<TTxCoordinator> { } const TTxId txId = proposal->TxId; - Y_VERIFY(txId); + Y_VERIFY(txId); Self->MonCounters.StepConsideredTx->Inc(); auto durationMs = (ExecStartMoment - proposal->AcceptMoment).MilliSeconds(); @@ -131,7 +131,7 @@ struct TTxCoordinator::TTxPlanStep : public TTransactionBase<TTxCoordinator> { TTransaction& transaction = Self->Transactions[txId]; transaction.PlanOnStep = PlanOnStep; - Y_VERIFY(!proposal->AffectedSet.empty()); + Y_VERIFY(!proposal->AffectedSet.empty()); for (const auto &txprop : proposal->AffectedSet) { const TTabletId affectedTablet = txprop.TabletId; const TTabletId mediatorId = Self->Config.Mediators->Select(affectedTablet); diff --git a/ydb/core/tx/coordinator/coordinator__restart_mediator.cpp b/ydb/core/tx/coordinator/coordinator__restart_mediator.cpp index 673115d22b0..b2476efd0b7 100644 --- a/ydb/core/tx/coordinator/coordinator__restart_mediator.cpp +++ b/ydb/core/tx/coordinator/coordinator__restart_mediator.cpp @@ -80,7 +80,7 @@ bool TTxCoordinator::RestoreMediatorInfo(TTabletId mediatorId, TVector<TAutoPtr< while (!rowset.EndOfSet()) { const TTxId txId = rowset.GetValue<Schema::AffectedSet::TransactionID>(); auto itTransaction = Transactions.find(txId); - Y_VERIFY(itTransaction != Transactions.end()); + Y_VERIFY(itTransaction != Transactions.end()); TStepId step = itTransaction->second.PlanOnStep; auto itStep = mediatorSteps.find(step); diff --git a/ydb/core/tx/coordinator/coordinator__restore_transaction.cpp b/ydb/core/tx/coordinator/coordinator__restore_transaction.cpp index 26a916bdff9..78dbf1695b3 100644 --- a/ydb/core/tx/coordinator/coordinator__restore_transaction.cpp +++ b/ydb/core/tx/coordinator/coordinator__restore_transaction.cpp @@ -14,7 +14,7 @@ struct TTxCoordinator::TTxRestoreTransactions : public TTransactionBase<TTxCoord {} bool Restore(TTransactions &transactions, TTransactionContext &txc, const TActorContext &ctx) { - Y_UNUSED(ctx); + Y_UNUSED(ctx); NIceDb::TNiceDb db(txc.DB); { @@ -67,7 +67,7 @@ struct TTxCoordinator::TTxRestoreTransactions : public TTransactionBase<TTxCoord out.Finish(); Cerr << "Coordinator DB dumped to " << dbDumpFile; Sleep(TDuration::Seconds(10)); - Y_FAIL("Transaction(s) not found!"); + Y_FAIL("Transaction(s) not found!"); } } @@ -92,7 +92,7 @@ struct TTxCoordinator::TTxRestoreTransactions : public TTransactionBase<TTxCoord // start mediator queues for (ui64 mediatorId: Self->Config.Mediators->List()) { TMediator &mediator = Self->Mediator(mediatorId, ctx); - Y_UNUSED(mediator); + Y_UNUSED(mediator); } // start plan process. diff --git a/ydb/core/tx/coordinator/coordinator_impl.cpp b/ydb/core/tx/coordinator/coordinator_impl.cpp index b4eeb184e29..7d5490b46c3 100644 --- a/ydb/core/tx/coordinator/coordinator_impl.cpp +++ b/ydb/core/tx/coordinator/coordinator_impl.cpp @@ -37,7 +37,7 @@ static TAutoPtr<TTransactionProposal> MakeTransactionProposal(TEvTxProxy::TEvPro auto &s = proposal->AffectedSet[i]; s.TabletId = x.GetTabletId(); - Y_ASSERT(x.GetFlags() > 0 && x.GetFlags() <= 3); + Y_ASSERT(x.GetFlags() > 0 && x.GetFlags() <= 3); s.AffectedFlags = x.GetFlags(); } @@ -167,7 +167,7 @@ void TTxCoordinator::HandleEnqueue(TEvTxProxy::TEvProposeTransaction::TPtr &ev, } void TTxCoordinator::Handle(TEvPrivate::TEvPlanTick::TPtr &ev, const TActorContext &ctx) { - Y_UNUSED(ev); + Y_UNUSED(ev); //LOG_DEBUG_S(ctx, NKikimrServices::TX_COORDINATOR, "tablet# " << TabletID() << " HANDLE EvPlanTick LastPlanned " << VolatileState.LastPlanned); if (VolatileState.Queue.Unsorted) { diff --git a/ydb/core/tx/coordinator/coordinator_impl.h b/ydb/core/tx/coordinator/coordinator_impl.h index 39018aff1e7..63c19464d6e 100644 --- a/ydb/core/tx/coordinator/coordinator_impl.h +++ b/ydb/core/tx/coordinator/coordinator_impl.h @@ -449,7 +449,7 @@ private: } void OnTabletDead(TEvTablet::TEvTabletDead::TPtr &ev, const TActorContext &ctx) override { - Y_UNUSED(ev); + Y_UNUSED(ev); return Die(ctx); } diff --git a/ydb/core/tx/datashard/datashard.cpp b/ydb/core/tx/datashard/datashard.cpp index d86568b4a15..28b38c61ede 100644 --- a/ydb/core/tx/datashard/datashard.cpp +++ b/ydb/core/tx/datashard/datashard.cpp @@ -1331,7 +1331,7 @@ void TDataShard::Handle(TEvents::TEvGone::TPtr &ev) { void TDataShard::Handle(TEvents::TEvPoisonPill::TPtr &ev, const TActorContext &ctx) { LOG_DEBUG(ctx, NKikimrServices::TX_DATASHARD, "Handle TEvents::TEvPoisonPill"); - Y_UNUSED(ev); + Y_UNUSED(ev); BecomeBroken(ctx); } @@ -1660,7 +1660,7 @@ void TDataShard::Handle(TEvTxProcessing::TEvReadSetAck::TPtr &ev, const TActorCo } void TDataShard::Handle(TEvPrivate::TEvProgressTransaction::TPtr &ev, const TActorContext &ctx) { - Y_UNUSED(ev); + Y_UNUSED(ev); IncCounter(COUNTER_TX_PROGRESS_EV); ExecuteProgressTx(ctx); } @@ -1885,22 +1885,22 @@ void TDataShard::AckRSToDeletedTablet(ui64 tabletId, const TActorContext& ctx) { } void TDataShard::Handle(TEvTabletPipe::TEvServerConnected::TPtr &ev, const TActorContext &ctx) { - Y_UNUSED(ev); Y_UNUSED(ctx); + Y_UNUSED(ev); Y_UNUSED(ctx); LOG_DEBUG(ctx, NKikimrServices::TX_DATASHARD, "Server connected at tablet %s %" PRIu64 , Executor()->GetStats().IsFollower ? "follower" : "leader", ev->Get()->TabletId); } void TDataShard::Handle(TEvTabletPipe::TEvServerDisconnected::TPtr &ev, const TActorContext &ctx) { - Y_UNUSED(ev); Y_UNUSED(ctx); + Y_UNUSED(ev); Y_UNUSED(ctx); } void TDataShard::Handle(TEvMediatorTimecast::TEvRegisterTabletResult::TPtr& ev, const TActorContext& ctx) { LOG_DEBUG_S(ctx, NKikimrServices::TX_DATASHARD, "Got TEvMediatorTimecast::TEvRegisterTabletResult at " << TabletID() << " time " << ev->Get()->Entry->Get(TabletID())); - Y_VERIFY(ev->Get()->TabletId == TabletID()); + Y_VERIFY(ev->Get()->TabletId == TabletID()); MediatorTimeCastEntry = ev->Get()->Entry; - Y_VERIFY(MediatorTimeCastEntry); + Y_VERIFY(MediatorTimeCastEntry); Pipeline.ActivateWaitingTxOps(ctx); } @@ -2010,8 +2010,8 @@ void TDataShard::UpdateLagCounters(const TActorContext &ctx) { } void TDataShard::FillSplitTrajectory(ui64 origin, NKikimrTx::TBalanceTrackList& tracks) { - Y_UNUSED(origin); - Y_UNUSED(tracks); + Y_UNUSED(origin); + Y_UNUSED(tracks); } THolder<TEvTxProcessing::TEvReadSet> diff --git a/ydb/core/tx/datashard/datashard__get_state_tx.cpp b/ydb/core/tx/datashard/datashard__get_state_tx.cpp index 552d27fd64c..64aed70ca8b 100644 --- a/ydb/core/tx/datashard/datashard__get_state_tx.cpp +++ b/ydb/core/tx/datashard/datashard__get_state_tx.cpp @@ -12,7 +12,7 @@ TDataShard::TTxGetShardState::TTxGetShardState(TDataShard* ds, TEvDataShard::TEv bool TDataShard::TTxGetShardState::Execute(TTransactionContext& txc, const TActorContext& ctx) { Y_UNUSED(txc); - Y_UNUSED(ctx); + Y_UNUSED(ctx); Result = MakeHolder<TEvDataShard::TEvGetShardStateResult>(Self->TabletID(), Self->State); if (Self->Pipeline.HasDrop()) diff --git a/ydb/core/tx/datashard/datashard__init.cpp b/ydb/core/tx/datashard/datashard__init.cpp index dc12c49959b..d1b455f9b13 100644 --- a/ydb/core/tx/datashard/datashard__init.cpp +++ b/ydb/core/tx/datashard/datashard__init.cpp @@ -44,10 +44,10 @@ bool TDataShard::TTxInit::Execute(TTransactionContext& txc, const TActorContext& } catch (const TNotReadyTabletException &) { return false; } catch (const TSchemeErrorTabletException &ex) { - Y_UNUSED(ex); - Y_FAIL(); + Y_UNUSED(ex); + Y_FAIL(); } catch (...) { - Y_FAIL("there must be no leaked exceptions"); + Y_FAIL("there must be no leaked exceptions"); } } diff --git a/ydb/core/tx/datashard/datashard__progress_resend_rs.cpp b/ydb/core/tx/datashard/datashard__progress_resend_rs.cpp index 6a96ceee8fb..1e0baa23ac2 100644 --- a/ydb/core/tx/datashard/datashard__progress_resend_rs.cpp +++ b/ydb/core/tx/datashard/datashard__progress_resend_rs.cpp @@ -16,7 +16,7 @@ namespace NDataShard { } void TDataShard::TTxProgressResendRS::Complete(const TActorContext &ctx) { - Y_UNUSED(ctx); + Y_UNUSED(ctx); /* no-op */ } } diff --git a/ydb/core/tx/datashard/datashard__progress_tx.cpp b/ydb/core/tx/datashard/datashard__progress_tx.cpp index 3f1fab6b46e..c0b2d53ac5d 100644 --- a/ydb/core/tx/datashard/datashard__progress_tx.cpp +++ b/ydb/core/tx/datashard/datashard__progress_tx.cpp @@ -102,7 +102,7 @@ bool TDataShard::TTxProgressTransaction::Execute(TTransactionContext &txc, const // Commit all side effects return true; } catch (...) { - Y_FAIL("there must be no leaked exceptions"); + Y_FAIL("there must be no leaked exceptions"); } } diff --git a/ydb/core/tx/datashard/datashard__propose_tx_base.cpp b/ydb/core/tx/datashard/datashard__propose_tx_base.cpp index 7dfb1a294e6..ee09fd264e9 100644 --- a/ydb/core/tx/datashard/datashard__propose_tx_base.cpp +++ b/ydb/core/tx/datashard/datashard__propose_tx_base.cpp @@ -143,14 +143,14 @@ bool TDataShard::TTxProposeTransactionBase::Execute(NTabletFlatExecutor::TTransa "TX [" << 0 << " : " << TxId << "] can't prepare (tablet's not ready) at tablet " << Self->TabletID()); return false; } catch (const TSchemeErrorTabletException &ex) { - Y_UNUSED(ex); - Y_FAIL(); + Y_UNUSED(ex); + Y_FAIL(); } catch (const TMemoryLimitExceededException &ex) { Y_FAIL("there must be no leaked exceptions: TMemoryLimitExceededException"); } catch (const std::exception &e) { Y_FAIL("there must be no leaked exceptions: %s", e.what()); } catch (...) { - Y_FAIL("there must be no leaked exceptions"); + Y_FAIL("there must be no leaked exceptions"); } } diff --git a/ydb/core/tx/datashard/datashard_impl.h b/ydb/core/tx/datashard/datashard_impl.h index 11313474f80..4f939113e73 100644 --- a/ydb/core/tx/datashard/datashard_impl.h +++ b/ydb/core/tx/datashard/datashard_impl.h @@ -1028,7 +1028,7 @@ class TDataShard void DefaultSignalTabletActive(const TActorContext &ctx) override { // This overriden in order to pospone SignalTabletActive until TxInit completes - Y_UNUSED(ctx); + Y_UNUSED(ctx); } void PersistSys(NIceDb::TNiceDb& db, ui64 key, const TString& value) const; diff --git a/ydb/core/tx/datashard/datashard_ut_common.cpp b/ydb/core/tx/datashard/datashard_ut_common.cpp index d754f7ad0e2..97fc2ab5d76 100644 --- a/ydb/core/tx/datashard/datashard_ut_common.cpp +++ b/ydb/core/tx/datashard/datashard_ut_common.cpp @@ -150,7 +150,7 @@ TTester::TKeyResolver TTester::GetKeyResolver() const { void TTester::CreateDataShard(TFakeMiniKQLProxy& proxy, ui64 tabletId, const TString& schemeText, bool withRegister) { TActorId actorId = CreateTestBootstrapper(Runtime, CreateTestTabletInfo(tabletId, TTabletTypes::FLAT_DATASHARD), &::NKikimr::CreateDataShard); - Y_UNUSED(actorId); + Y_UNUSED(actorId); TDispatchOptions options; options.FinalEvents.push_back(TDispatchOptions::TFinalEventCondition(TEvTablet::EvBoot)); @@ -1016,7 +1016,7 @@ TTestActorRuntime::TEventFilter TDatashardInitialEventsFilter::Prepare() { } bool TDatashardInitialEventsFilter::operator()(TTestActorRuntimeBase& runtime, TAutoPtr<IEventHandle>& event) { - Y_UNUSED(runtime); + Y_UNUSED(runtime); if (event->GetTypeRewrite() == TEvTxProcessing::EvPlanStepAck) { ui64 tabletId = reinterpret_cast<TEvTxProcessing::TEvPlanStepAck::TPtr&>(event)->Get()->Record.GetTabletId(); auto it = Find(RemainTablets.begin(), RemainTablets.end(), tabletId); diff --git a/ydb/core/tx/datashard/datashard_ut_init.cpp b/ydb/core/tx/datashard/datashard_ut_init.cpp index 818e30ab0cb..996d361d0bc 100644 --- a/ydb/core/tx/datashard/datashard_ut_init.cpp +++ b/ydb/core/tx/datashard/datashard_ut_init.cpp @@ -50,7 +50,7 @@ TString GetTablePath(TTestActorRuntime &runtime, } -Y_UNIT_TEST_SUITE(TTxDataShardTestInit) { +Y_UNIT_TEST_SUITE(TTxDataShardTestInit) { Y_UNIT_TEST(TestMvccStateSwitch) { TPortManager pm; TServerSettings serverSettings(pm.GetPort(2134)); @@ -94,7 +94,7 @@ Y_UNIT_TEST_SUITE(TTxDataShardTestInit) { waitFor([&]{ return datashard->GetSnapshotManager().GetMvccState() == NDataShard::EMvccState::MvccDisabled; }, "mvcc disabled"); } - Y_UNIT_TEST(TestGetShardStateAfterInitialization) { + Y_UNIT_TEST(TestGetShardStateAfterInitialization) { TTestBasicRuntime runtime; TTester::Setup(runtime); @@ -105,7 +105,7 @@ Y_UNIT_TEST_SUITE(TTxDataShardTestInit) { options.FinalEvents.push_back(TDispatchOptions::TFinalEventCondition(TEvTablet::EvBoot)); runtime.DispatchEvents(options); - Y_UNUSED(sender); + Y_UNUSED(sender); ForwardToTablet(runtime, TTestTxConfig::TxTablet0, sender, new TEvDataShard::TEvGetShardState(sender)); TAutoPtr<IEventHandle> handle; auto event = runtime.GrabEdgeEvent<TEvDataShard::TEvGetShardStateResult>(handle); diff --git a/ydb/core/tx/datashard/datashard_ut_keys.cpp b/ydb/core/tx/datashard/datashard_ut_keys.cpp index bb36ace63b7..f3808b84fa1 100644 --- a/ydb/core/tx/datashard/datashard_ut_keys.cpp +++ b/ydb/core/tx/datashard/datashard_ut_keys.cpp @@ -7,7 +7,7 @@ namespace NKikimr { using namespace NKikimr::NDataShard; -Y_UNIT_TEST_SUITE(TxKeys) { +Y_UNIT_TEST_SUITE(TxKeys) { static TString ProgSelectRow(TString key) { return Sprintf(R"(( @@ -83,7 +83,7 @@ static void ComparePointAndRange(TTester& t, std::pair<ui32, TString> point, TSt // -Y_UNIT_TEST(ComparePointKeys) { +Y_UNIT_TEST(ComparePointKeys) { TTester t(TTester::ESchema_DoubleKV, TTester::TOptions()); ComparePoints(t, {0, ""}, {0, ""}, 0); @@ -108,7 +108,7 @@ Y_UNIT_TEST(ComparePointKeys) { ComparePoints(t, {1, "a"}, {0, "ba"}, 1); } -Y_UNIT_TEST(ComparePointKeysWithNull) { +Y_UNIT_TEST(ComparePointKeysWithNull) { TTester t(TTester::ESchema_DoubleKV, TTester::TOptions()); const char * nullNull = "'('key1 (Null)) '('key2 (Null))"; @@ -130,7 +130,7 @@ Y_UNIT_TEST(ComparePointKeysWithNull) { ComparePointsStr(t, ToPointKey({0, ""}), Sprintf(null, 0), 1); } -Y_UNIT_TEST(ComparePointAndRange) { +Y_UNIT_TEST(ComparePointAndRange) { TTester t(TTester::ESchema_DoubleKV, TTester::TOptions()); ComparePointAndRange(t, {0, ""}, {0, ""}, {0, ""}, "'IncFrom 'IncTo", 0); @@ -207,7 +207,7 @@ Y_UNIT_TEST(ComparePointAndRange) { ComparePointAndRange(t, {0, "c"}, {0, "a"}, {0, "b"}, "'ExcFrom 'ExcTo", 1); } -Y_UNIT_TEST(ComparePointAndRangeWithNull) { +Y_UNIT_TEST(ComparePointAndRangeWithNull) { TTester t(TTester::ESchema_DoubleKV, TTester::TOptions()); const char * nullNull = "'('key1 (Null)) '('key2 (Null))"; @@ -233,7 +233,7 @@ Y_UNIT_TEST(ComparePointAndRangeWithNull) { ComparePointAndRangeStr(t, Sprintf(null, 0), "'ExcFrom 'ExcTo '('key1 (Null) (Uint32 '0)) '('key2 (Null) (Utf8 'a))", 0); } -Y_UNIT_TEST(ComparePointAndRangeWithInf) { +Y_UNIT_TEST(ComparePointAndRangeWithInf) { TTester t(TTester::ESchema_DoubleKV, TTester::TOptions()); const char * nullNull = "'('key1 (Null)) '('key2 (Null))"; diff --git a/ydb/core/tx/datashard/datashard_ut_locks.cpp b/ydb/core/tx/datashard/datashard_ut_locks.cpp index 1d25c39f99d..3844d67dba1 100644 --- a/ydb/core/tx/datashard/datashard_ut_locks.cpp +++ b/ydb/core/tx/datashard/datashard_ut_locks.cpp @@ -294,7 +294,7 @@ namespace NTest { } // TODO: correctness, times -Y_UNIT_TEST_SUITE(TDataShardLocksTest) { +Y_UNIT_TEST_SUITE(TDataShardLocksTest) { Y_UNIT_TEST(MvccTestOooTxDoesntBreakPrecedingReadersLocks) { NTest::TLockTester tester; @@ -471,7 +471,7 @@ Y_UNIT_TEST(MvccTestAlreadyBrokenLocks) { } } -Y_UNIT_TEST(Points_OneTx) { +Y_UNIT_TEST(Points_OneTx) { NTest::TLockTester tester; ui32 numVals = 100 * 1000; @@ -486,7 +486,7 @@ Y_UNIT_TEST(Points_OneTx) { } // 100000 tx, 1 points per tx -Y_UNIT_TEST(Points_ManyTx) { +Y_UNIT_TEST(Points_ManyTx) { NTest::TLockTester tester; ui32 numVals = 100 * 1000; @@ -505,7 +505,7 @@ Y_UNIT_TEST(Points_ManyTx) { // TODO: 1000 tx, 100 points per tx // TODO: 10000 tx, 10 points per tx -Y_UNIT_TEST(Points_ManyTx_BreakAll) { +Y_UNIT_TEST(Points_ManyTx_BreakAll) { NTest::TLockTester tester; ui32 numVals = 100 * 1000; @@ -529,7 +529,7 @@ Y_UNIT_TEST(Points_ManyTx_BreakAll) { } } -Y_UNIT_TEST(Points_ManyTx_RemoveAll) { +Y_UNIT_TEST(Points_ManyTx_RemoveAll) { NTest::TLockTester tester; ui32 numVals = 100 * 1000; @@ -552,7 +552,7 @@ Y_UNIT_TEST(Points_ManyTx_RemoveAll) { } } -Y_UNIT_TEST(Points_ManyTx_BreakHalf_RemoveHalf) { +Y_UNIT_TEST(Points_ManyTx_BreakHalf_RemoveHalf) { NTest::TLockTester tester; ui32 numVals = 100 * 1000; diff --git a/ydb/core/tx/datashard/datashard_ut_minikql.cpp b/ydb/core/tx/datashard/datashard_ut_minikql.cpp index 7974e474861..776935dda1f 100644 --- a/ydb/core/tx/datashard/datashard_ut_minikql.cpp +++ b/ydb/core/tx/datashard/datashard_ut_minikql.cpp @@ -9,9 +9,9 @@ using NClient::TValue; using IEngineFlat = NMiniKQL::IEngineFlat; -Y_UNIT_TEST_SUITE(TTxDataShardMiniKQL) { +Y_UNIT_TEST_SUITE(TTxDataShardMiniKQL) { -Y_UNIT_TEST(ReadConstant) { +Y_UNIT_TEST(ReadConstant) { TTester t(TTester::ESchema_KV); TFakeMiniKQLProxy proxy(t); @@ -24,7 +24,7 @@ Y_UNIT_TEST(ReadConstant) { // -Y_UNIT_TEST(Write) { +Y_UNIT_TEST(Write) { TTester t(TTester::ESchema_KV); TFakeMiniKQLProxy proxy(t); @@ -43,7 +43,7 @@ Y_UNIT_TEST(Write) { // -Y_UNIT_TEST(ReadAfterWrite) { +Y_UNIT_TEST(ReadAfterWrite) { TTester t(TTester::ESchema_KV); TFakeMiniKQLProxy proxy(t); @@ -158,7 +158,7 @@ Y_UNIT_TEST(ReadSpecialColumns) { // -Y_UNIT_TEST(ReadNonExisting) { +Y_UNIT_TEST(ReadNonExisting) { TTester t(TTester::ESchema_KV); TFakeMiniKQLProxy proxy(t); @@ -181,7 +181,7 @@ Y_UNIT_TEST(ReadNonExisting) { } } -Y_UNIT_TEST(WriteEraseRead) { +Y_UNIT_TEST(WriteEraseRead) { TTester t(TTester::ESchema_KV); TFakeMiniKQLProxy proxy(t); @@ -232,7 +232,7 @@ Y_UNIT_TEST(WriteEraseRead) { // -Y_UNIT_TEST(SelectRange) { +Y_UNIT_TEST(SelectRange) { TTester t(TTester::ESchema_KV); TFakeMiniKQLProxy proxy(t); @@ -447,7 +447,7 @@ Y_UNIT_TEST(SelectRange) { // -Y_UNIT_TEST(SelectRangeWithNotFullKey) { +Y_UNIT_TEST(SelectRangeWithNotFullKey) { TTester t(TTester::ESchema_DoubleKV); TFakeMiniKQLProxy proxy(t); @@ -661,7 +661,7 @@ Y_UNIT_TEST(SelectRangeWithNotFullKey) { // -Y_UNIT_TEST(WriteAndReadMultipleShards) { +Y_UNIT_TEST(WriteAndReadMultipleShards) { TTester t(TTester::ESchema_MultiShardKV); TFakeMiniKQLProxy proxy(t); @@ -729,7 +729,7 @@ void GetTableStats(TTestActorRuntime &runtime, ui64 tabletId, ui64 tableId, NKik stats.Swap(response->Record.MutableTableStats()); } -Y_UNIT_TEST(TableStats) { +Y_UNIT_TEST(TableStats) { TTester t(TTester::ESchema_MultiShardKV); TFakeMiniKQLProxy proxy(t); @@ -811,7 +811,7 @@ Y_UNIT_TEST(TableStats) { "LastAccessTime should change after read"); } -Y_UNIT_TEST(TableStatsHistograms) { +Y_UNIT_TEST(TableStatsHistograms) { TTester t(TTester::ESchema_MultiShardKV); TFakeMiniKQLProxy proxy(t); @@ -932,7 +932,7 @@ void CrossShard_1_Cycle_Impl(const TString& dispatchName, std::function<void (TT } } -Y_UNIT_TEST(CrossShard_1_Cycle) { +Y_UNIT_TEST(CrossShard_1_Cycle) { TVector<ui64> tabletIds; tabletIds.push_back((ui64)TTestTxConfig::TxTablet0); tabletIds.push_back((ui64)TTestTxConfig::TxTablet1); @@ -1009,7 +1009,7 @@ void CrossShard_2_SwapAndCopy_Impl(const TString& dispatchName, std::function<vo } } -Y_UNIT_TEST(CrossShard_2_SwapAndCopy) { +Y_UNIT_TEST(CrossShard_2_SwapAndCopy) { TVector<ui64> tabletIds; tabletIds.push_back((ui64)TTestTxConfig::TxTablet0); tabletIds.push_back((ui64)TTestTxConfig::TxTablet1); @@ -1087,7 +1087,7 @@ void CrossShard_3_AllToOne_Impl(const TString& dispatchName, std::function<void } } -Y_UNIT_TEST(CrossShard_3_AllToOne) { +Y_UNIT_TEST(CrossShard_3_AllToOne) { TVector<ui64> tabletIds; tabletIds.push_back((ui64)TTestTxConfig::TxTablet0); tabletIds.push_back((ui64)TTestTxConfig::TxTablet1); @@ -1163,7 +1163,7 @@ void CrossShard_4_OneToAll_Impl(const TString& dispatchName, std::function<void } } -Y_UNIT_TEST(CrossShard_4_OneToAll) { +Y_UNIT_TEST(CrossShard_4_OneToAll) { TVector<ui64> tabletIds; tabletIds.push_back((ui64)TTestTxConfig::TxTablet0); tabletIds.push_back((ui64)TTestTxConfig::TxTablet1); @@ -1275,7 +1275,7 @@ void CrossShard_5_AllToAll_Impl(const TString& dispatchName, std::function<void } } -Y_UNIT_TEST(CrossShard_5_AllToAll) { +Y_UNIT_TEST(CrossShard_5_AllToAll) { TVector<ui64> tabletIds; tabletIds.push_back((ui64)TTestTxConfig::TxTablet0); tabletIds.push_back((ui64)TTestTxConfig::TxTablet1); @@ -1351,7 +1351,7 @@ void CrossShard_6_Local_Impl(const TString& dispatchName, std::function<void (TT } } -Y_UNIT_TEST(CrossShard_6_Local) { +Y_UNIT_TEST(CrossShard_6_Local) { TVector<ui64> tabletIds; tabletIds.push_back((ui64)TTestTxConfig::TxTablet0); tabletIds.push_back((ui64)TTestTxConfig::TxTablet1); @@ -1362,7 +1362,7 @@ Y_UNIT_TEST(CrossShard_6_Local) { }, &CrossShard_6_Local_Impl); } -Y_UNIT_TEST(WriteAndReadMany) { +Y_UNIT_TEST(WriteAndReadMany) { TTester t(TTester::ESchema_DoubleKV); TFakeMiniKQLProxy proxy(t); @@ -1536,7 +1536,7 @@ void CheckCounters(const std::tuple<ui64, ui64, ui64> &newCnt, const std::tuple< UNIT_ASSERT_VALUES_EQUAL(std::get<2>(newCnt) - std::get<2>(oldCnt), d3); } -Y_UNIT_TEST(MemoryUsageImmediateSmallTx) { +Y_UNIT_TEST(MemoryUsageImmediateSmallTx) { bool activeZone = false; TTester t(TTester::ESchema_KV, "dispatch_name", [&](TTestActorRuntime &runtime) { SetupProfiles(runtime); @@ -1583,7 +1583,7 @@ Y_UNIT_TEST(MemoryUsageImmediateSmallTx) { CheckCounters(counters3, counters2, 1, 0, 0); } -Y_UNIT_TEST(MemoryUsageImmediateMediumTx) { +Y_UNIT_TEST(MemoryUsageImmediateMediumTx) { bool activeZone = false; TTester t(TTester::ESchema_KV, "dispatch_name", [&](TTestActorRuntime &runtime) { SetupProfiles(runtime); @@ -1615,7 +1615,7 @@ Y_UNIT_TEST(MemoryUsageImmediateMediumTx) { CheckCounters(counters2, counters1, TCounterRange{2, 3}, 0, 0); } -Y_UNIT_TEST(MemoryUsageImmediateHugeTx) { +Y_UNIT_TEST(MemoryUsageImmediateHugeTx) { bool activeZone = false; TTester t(TTester::ESchema_KV, "dispatch_name", [&](TTestActorRuntime &runtime) { SetupProfiles(runtime); @@ -1647,7 +1647,7 @@ Y_UNIT_TEST(MemoryUsageImmediateHugeTx) { CheckCounters(counters2, counters1, 4, 0, 0); } -Y_UNIT_TEST(MemoryUsageMultiShard) { +Y_UNIT_TEST(MemoryUsageMultiShard) { bool activeZone = false; TTester t(TTester::ESchema_MultiShardKV, "dispatch_name", [&](TTestActorRuntime &runtime) { SetupProfiles(runtime); @@ -1709,6 +1709,6 @@ Y_UNIT_TEST(MemoryUsageMultiShard) { } } -} // Y_UNIT_TEST_SUITE(TTxDataShardMiniKQL) +} // Y_UNIT_TEST_SUITE(TTxDataShardMiniKQL) } // namespace NKikimr diff --git a/ydb/core/tx/datashard/datashard_ut_order.cpp b/ydb/core/tx/datashard/datashard_ut_order.cpp index 32472dce59e..55b35f02652 100644 --- a/ydb/core/tx/datashard/datashard_ut_order.cpp +++ b/ydb/core/tx/datashard/datashard_ut_order.cpp @@ -77,9 +77,9 @@ private: /// -Y_UNIT_TEST_SUITE(TxOrderInternals) { +Y_UNIT_TEST_SUITE(TxOrderInternals) { -Y_UNIT_TEST(OperationOrder) { +Y_UNIT_TEST(OperationOrder) { using TTester = TDatashardTester; TActiveTxPtr tx0_100 = TTester::MakeEmptyTx(0, 100); @@ -126,7 +126,7 @@ static void InitCrossShard_ABC(TFakeMiniKQLProxy& proxy, TVector<ui32> uintVal) } /// -Y_UNIT_TEST_SUITE(DataShardTxOrder) { +Y_UNIT_TEST_SUITE(DataShardTxOrder) { static void ZigZag(TFakeMiniKQLProxy& proxy, bool symmetric, ui32 limit = 40) { InitCrossShard_ABC(proxy, {0, 0, 0}); @@ -1154,7 +1154,7 @@ Y_UNIT_TEST_WITH_MVCC(RandomPointsAndRanges) { } /// -Y_UNIT_TEST_SUITE(DataShardScan) { +Y_UNIT_TEST_SUITE(DataShardScan) { Y_UNIT_TEST_WITH_MVCC(ScanFollowedByUpdate) { TTester::TOptions opts; diff --git a/ydb/core/tx/datashard/progress_queue.h b/ydb/core/tx/datashard/progress_queue.h index 116ed333728..ba38f0b02d8 100644 --- a/ydb/core/tx/datashard/progress_queue.h +++ b/ydb/core/tx/datashard/progress_queue.h @@ -20,7 +20,7 @@ public: void Progress(T x, const TActorContext &ctx) { if (!HasInFly) { - Y_VERIFY_DEBUG(!Queue.Head()); + Y_VERIFY_DEBUG(!Queue.Head()); ctx.Send(ctx.SelfID, new TEvent(x)); HasInFly = true; } else { @@ -29,7 +29,7 @@ public: } void Reset(const TActorContext &ctx) { - Y_VERIFY_DEBUG(HasInFly); + Y_VERIFY_DEBUG(HasInFly); if (T x = Queue.Pop()) ctx.Send(ctx.SelfID, new TEvent(x)); else @@ -52,7 +52,7 @@ public: } void Reset(const TActorContext &ctx) { - Y_VERIFY_DEBUG(InFly); + Y_VERIFY_DEBUG(InFly); if (--InFly) { ctx.Send(ctx.SelfID, new TEvent()); } @@ -75,8 +75,8 @@ public: } void Reset(const TActorContext &ctx) { - Y_UNUSED(ctx); - Y_VERIFY_DEBUG(HasInFly); + Y_UNUSED(ctx); + Y_VERIFY_DEBUG(HasInFly); HasInFly = false; } }; @@ -97,8 +97,8 @@ public: } void Reset(const TActorContext &ctx) { - Y_UNUSED(ctx); - Y_VERIFY_DEBUG(HasSchedule); + Y_UNUSED(ctx); + Y_VERIFY_DEBUG(HasSchedule); HasSchedule = false; } }; diff --git a/ydb/core/tx/mediator/execute_queue.cpp b/ydb/core/tx/mediator/execute_queue.cpp index 07740e9f826..88f1f5f60ed 100644 --- a/ydb/core/tx/mediator/execute_queue.cpp +++ b/ydb/core/tx/mediator/execute_queue.cpp @@ -25,7 +25,7 @@ namespace NTxMediator { TBucket& SelectBucket(TTabletId tablet) { const ui32 bucketIdx = BucketSelector.Select(tablet); - Y_VERIFY_DEBUG(bucketIdx < Buckets.size()); + Y_VERIFY_DEBUG(bucketIdx < Buckets.size()); return Buckets[bucketIdx]; } @@ -183,11 +183,11 @@ namespace NTxMediator { , HashRange(hashRange) , BucketSelector(timecastBuckets) { - Y_UNUSED(HashRange); + Y_UNUSED(HashRange); } TAutoPtr<IEventHandle> AfterRegister(const TActorId &self, const TActorId& parentId) override { - Y_UNUSED(parentId); + Y_UNUSED(parentId); return new IEventHandle(self, self, new TEvents::TEvBootstrap()); } diff --git a/ydb/core/tx/mediator/tablet_queue.cpp b/ydb/core/tx/mediator/tablet_queue.cpp index b28179517ca..d87fb80d2e7 100644 --- a/ydb/core/tx/mediator/tablet_queue.cpp +++ b/ydb/core/tx/mediator/tablet_queue.cpp @@ -97,7 +97,7 @@ class TTxMediatorTabletQueue : public TActor<TTxMediatorTabletQueue> { } void CheckStepHead(const TActorContext &ctx) { - Y_UNUSED(ctx); + Y_UNUSED(ctx); bool updateTimecast = false; while (TStepEntry *sx = StepCommitQueue->Head()) { @@ -147,7 +147,7 @@ class TTxMediatorTabletQueue : public TActor<TTxMediatorTabletQueue> { StepCommitQueue->Push(ActiveStep); } - Y_VERIFY(ActiveStep->Step == step); + Y_VERIFY(ActiveStep->Step == step); ++ActiveStep->RefCounter; TTabletEntry::TStep *tabletStep = new TTabletEntry::TStep(ActiveStep); @@ -190,7 +190,7 @@ class TTxMediatorTabletQueue : public TActor<TTxMediatorTabletQueue> { << " Mediator# " << Mediator << " HANDLE " << msg->ToString()); TTabletEntry &tabletEntry = PerTabletPlanQueue[tablet]; - Y_VERIFY(tabletEntry.State == TTabletEntry::StateConnect); + Y_VERIFY(tabletEntry.State == TTabletEntry::StateConnect); if (!Pipes->OnConnect(ev)) { if (msg->Dead) { @@ -228,7 +228,7 @@ class TTxMediatorTabletQueue : public TActor<TTxMediatorTabletQueue> { Pipes->OnDisconnect(ev); TTabletEntry &tabletEntry = PerTabletPlanQueue[tablet]; - Y_VERIFY(tabletEntry.State == TTabletEntry::StateConnected); + Y_VERIFY(tabletEntry.State == TTabletEntry::StateConnected); // if connect to tablet lost and tablet is in no use - just forget connection if (tabletEntry.Queue->Head() == nullptr) { @@ -352,7 +352,7 @@ public: , CommitedStep(0) , ActiveStep(nullptr) { - Y_UNUSED(HashRange); + Y_UNUSED(HashRange); } STFUNC(StateFunc) { diff --git a/ydb/core/tx/schemeshard/schemeshard__init.cpp b/ydb/core/tx/schemeshard/schemeshard__init.cpp index 650506549e0..26b03be4530 100644 --- a/ydb/core/tx/schemeshard/schemeshard__init.cpp +++ b/ydb/core/tx/schemeshard/schemeshard__init.cpp @@ -4558,7 +4558,7 @@ struct TSchemeShard::TTxInit : public TTransactionBase<TSchemeShard> { } catch (const std::exception& ex) { Y_FAIL("there must be no leaked exceptions: %s", ex.what()); } catch (...) { - Y_FAIL("there must be no leaked exceptions"); + Y_FAIL("there must be no leaked exceptions"); } } diff --git a/ydb/core/tx/schemeshard/schemeshard__notify.cpp b/ydb/core/tx/schemeshard/schemeshard__notify.cpp index d390367947a..2f58fd69992 100644 --- a/ydb/core/tx/schemeshard/schemeshard__notify.cpp +++ b/ydb/core/tx/schemeshard/schemeshard__notify.cpp @@ -17,8 +17,8 @@ struct TSchemeShard::TTxNotifyCompletion : public TSchemeShard::TRwTxBase { {} void DoExecute(TTransactionContext &txc, const TActorContext &ctx) override { - Y_UNUSED(txc); - Y_UNUSED(ctx); + Y_UNUSED(txc); + Y_UNUSED(ctx); auto rawTxId = Ev->Get()->Record.GetTxId(); if (Self->Operations.contains(TTxId(rawTxId))) { diff --git a/ydb/core/tx/schemeshard/schemeshard_impl.cpp b/ydb/core/tx/schemeshard/schemeshard_impl.cpp index 0715543a229..0fc7edc23cf 100644 --- a/ydb/core/tx/schemeshard/schemeshard_impl.cpp +++ b/ydb/core/tx/schemeshard/schemeshard_impl.cpp @@ -3717,7 +3717,7 @@ void TSchemeShard::OnDetach(const TActorContext &ctx) { } void TSchemeShard::OnTabletDead(TEvTablet::TEvTabletDead::TPtr &ev, const TActorContext &ctx) { - Y_UNUSED(ev); + Y_UNUSED(ev); Die(ctx); } @@ -3786,15 +3786,15 @@ void TSchemeShard::OnActivateExecutor(const TActorContext &ctx) { // This is overriden as noop in order to activate the table only at the end of Init transaction // when all the in-mem state has been populated void TSchemeShard::DefaultSignalTabletActive(const TActorContext &ctx) { - Y_UNUSED(ctx); + Y_UNUSED(ctx); } void TSchemeShard::Cleanup(const TActorContext &ctx) { - Y_UNUSED(ctx); + Y_UNUSED(ctx); } void TSchemeShard::Enqueue(STFUNC_SIG) { - Y_UNUSED(ctx); + Y_UNUSED(ctx); Y_FAIL_S("No enqueue method emplemented." << " unhandled event type: " << ev->GetTypeRewrite() << " event: " << (ev->HasEvent() ? ev->GetBase()->ToString().data() : "serialized?")); @@ -4571,8 +4571,8 @@ void TSchemeShard::Handle(TEvTabletPipe::TEvClientConnected::TPtr &ev, const TAc } void TSchemeShard::Handle(TEvTabletPipe::TEvServerConnected::TPtr &ev, const TActorContext &ctx) { - Y_UNUSED(ev); - Y_UNUSED(ctx); + Y_UNUSED(ev); + Y_UNUSED(ctx); LOG_TRACE_S(ctx, NKikimrServices::FLAT_TX_SCHEMESHARD, "Pipe server connected" << ", at tablet: " << ev->Get()->TabletId); @@ -4608,7 +4608,7 @@ void TSchemeShard::Handle(TEvTabletPipe::TEvClientDestroyed::TPtr &ev, const TAc } void TSchemeShard::Handle(TEvTabletPipe::TEvServerDisconnected::TPtr &ev, const TActorContext &ctx) { - Y_UNUSED(ev); + Y_UNUSED(ev); LOG_TRACE_S(ctx, NKikimrServices::FLAT_TX_SCHEMESHARD, "Server pipe is reset" << ", at schemeshard: " << TabletID()); @@ -5259,7 +5259,7 @@ void TSchemeShard::RestartPipeTx(TTabletId tabletId, const TActorContext& ctx) { } void TSchemeShard::Handle(TEvents::TEvPoisonPill::TPtr &ev, const TActorContext &ctx) { - Y_UNUSED(ev); + Y_UNUSED(ev); BreakTabletAndRestart(ctx); } diff --git a/ydb/core/tx/schemeshard/ut_base.cpp b/ydb/core/tx/schemeshard/ut_base.cpp index a76dcf9d5bb..cb8322b7cfd 100644 --- a/ydb/core/tx/schemeshard/ut_base.cpp +++ b/ydb/core/tx/schemeshard/ut_base.cpp @@ -10,8 +10,8 @@ using namespace NKikimr; using namespace NSchemeShard; using namespace NSchemeShardUT_Private; -Y_UNIT_TEST_SUITE(TSchemeShardTest) { - Y_UNIT_TEST(Boot) { +Y_UNIT_TEST_SUITE(TSchemeShardTest) { + Y_UNIT_TEST(Boot) { TTestBasicRuntime runtime; TTestEnv env(runtime); } @@ -2426,7 +2426,7 @@ Y_UNIT_TEST_SUITE(TSchemeShardTest) { } #if 0 // KIKIMR-1452 - Y_UNIT_TEST(CreateSameTable) { + Y_UNIT_TEST(CreateSameTable) { TTestBasicRuntime runtime; TTestEnv env(runtime); ui64 txId = 100; @@ -3969,7 +3969,7 @@ Y_UNIT_TEST_SUITE(TSchemeShardTest) { env.TestWaitNotification(runtime, txId); } - Y_UNIT_TEST(AlterTableKeyColumns) { + Y_UNIT_TEST(AlterTableKeyColumns) { TTestBasicRuntime runtime; TTestEnv env(runtime); ui64 txId = 100; @@ -4216,7 +4216,7 @@ Y_UNIT_TEST_SUITE(TSchemeShardTest) { NLs::PathVersionEqual(11)}); } - Y_UNIT_TEST(ConfigColumnFamily) { + Y_UNIT_TEST(ConfigColumnFamily) { using NKikimrSchemeOp::EColumnCodec; using NKikimrSchemeOp::EColumnCache; using NKikimrSchemeOp::EColumnStorage; @@ -7030,7 +7030,7 @@ Y_UNIT_TEST_SUITE(TSchemeShardTest) { } void TestSerializedCellVec(TVector<TCell>& cells) { - TString serialized = TSerializedCellVec::Serialize(TArrayRef<const TCell>(cells)); + TString serialized = TSerializedCellVec::Serialize(TArrayRef<const TCell>(cells)); UNIT_ASSERT_VALUES_EQUAL_C(cells.empty(), serialized.empty(), "Empty/non-empty mismatch"); TSerializedCellVec deserialized(serialized); UNIT_ASSERT_VALUES_EQUAL_C(cells.size(), deserialized.GetCells().size(), "Sizes don't match"); @@ -7846,7 +7846,7 @@ Y_UNIT_TEST_SUITE(TSchemeShardTest) { TestDropBlockStoreVolume(runtime, ++txId, "/MyRoot", "BSVolume"); } - Y_UNIT_TEST(AssignBlockStoreVolumeDuringAlter) { + Y_UNIT_TEST(AssignBlockStoreVolumeDuringAlter) { TTestBasicRuntime runtime; TTestEnv env(runtime); ui64 txId = 100; diff --git a/ydb/core/tx/schemeshard/ut_subdomain.cpp b/ydb/core/tx/schemeshard/ut_subdomain.cpp index d0d30bf7da8..900d7ee485e 100644 --- a/ydb/core/tx/schemeshard/ut_subdomain.cpp +++ b/ydb/core/tx/schemeshard/ut_subdomain.cpp @@ -77,8 +77,8 @@ NLs::TCheckFunc LsCheckDiskQuotaExceeded(bool value = true) { }; } -Y_UNIT_TEST_SUITE(TSchemeShardSubDomainTest) { - Y_UNIT_TEST(Create) { +Y_UNIT_TEST_SUITE(TSchemeShardSubDomainTest) { + Y_UNIT_TEST(Create) { TTestBasicRuntime runtime; TTestEnv env(runtime); ui64 txId = 100; @@ -144,7 +144,7 @@ Y_UNIT_TEST_SUITE(TSchemeShardSubDomainTest) { NLs::ShardsInsideDomain(0)}); } - Y_UNIT_TEST(LS) { + Y_UNIT_TEST(LS) { TTestBasicRuntime runtime; TTestEnv env(runtime); ui64 txId = 100; @@ -169,7 +169,7 @@ Y_UNIT_TEST_SUITE(TSchemeShardSubDomainTest) { NLs::ShardsInsideDomain(0)}); } - Y_UNIT_TEST(ConcurrentCreateSubDomainAndDescribe) { + Y_UNIT_TEST(ConcurrentCreateSubDomainAndDescribe) { TTestBasicRuntime runtime; TTestEnv env(runtime); ui64 txId = 100; @@ -198,7 +198,7 @@ Y_UNIT_TEST_SUITE(TSchemeShardSubDomainTest) { } - Y_UNIT_TEST(CreataWithoutPlanResolution) { + Y_UNIT_TEST(CreataWithoutPlanResolution) { TTestBasicRuntime runtime; TTestEnv env(runtime); ui64 txId = 100; @@ -216,7 +216,7 @@ Y_UNIT_TEST_SUITE(TSchemeShardSubDomainTest) { {NLs::PathNotExist}); } - Y_UNIT_TEST(CreataWithoutTimeCastBuckets) { + Y_UNIT_TEST(CreataWithoutTimeCastBuckets) { TTestBasicRuntime runtime; TTestEnv env(runtime); ui64 txId = 100; @@ -234,7 +234,7 @@ Y_UNIT_TEST_SUITE(TSchemeShardSubDomainTest) { {NLs::PathNotExist}); } - Y_UNIT_TEST(CreateWithNoEqualName) { + Y_UNIT_TEST(CreateWithNoEqualName) { TTestBasicRuntime runtime; TTestEnv env(runtime); ui64 txId = 100; @@ -312,7 +312,7 @@ Y_UNIT_TEST_SUITE(TSchemeShardSubDomainTest) { {NLs::IsSubDomain("USER_3")}); } - Y_UNIT_TEST(CreateItemsInsideSubdomain) { + Y_UNIT_TEST(CreateItemsInsideSubdomain) { TTestBasicRuntime runtime; TTestEnv env(runtime); ui64 txId = 100; @@ -358,7 +358,7 @@ Y_UNIT_TEST_SUITE(TSchemeShardSubDomainTest) { NLs::PathVersionEqual(3)}); } - Y_UNIT_TEST(CreateItemsInsideSubdomainWithStoragePools) { + Y_UNIT_TEST(CreateItemsInsideSubdomainWithStoragePools) { TTestBasicRuntime runtime; TTestEnv env(runtime); ui64 txId = 100; @@ -409,7 +409,7 @@ Y_UNIT_TEST_SUITE(TSchemeShardSubDomainTest) { {NLs::InSubdomain}); } - Y_UNIT_TEST(CreateSubDomainWithoutTablets) { + Y_UNIT_TEST(CreateSubDomainWithoutTablets) { TTestBasicRuntime runtime; TTestEnv env(runtime); ui64 txId = 100; @@ -427,7 +427,7 @@ Y_UNIT_TEST_SUITE(TSchemeShardSubDomainTest) { {NLs::PathExist, NLs::PathsInsideDomain(1), NLs::ShardsInsideDomain(0)}); } - Y_UNIT_TEST(CreateSubDomainWithoutSomeTablets) { + Y_UNIT_TEST(CreateSubDomainWithoutSomeTablets) { TTestBasicRuntime runtime; TTestEnv env(runtime); ui64 txId = 100; @@ -454,7 +454,7 @@ Y_UNIT_TEST_SUITE(TSchemeShardSubDomainTest) { {NLs::PathExist, NLs::PathsInsideDomain(0), NLs::ShardsInsideDomain(0)}); } - Y_UNIT_TEST(CreateSubDomainWithoutTabletsThenMkDir) { + Y_UNIT_TEST(CreateSubDomainWithoutTabletsThenMkDir) { TTestBasicRuntime runtime; TTestEnv env(runtime); ui64 txId = 100; @@ -478,7 +478,7 @@ Y_UNIT_TEST_SUITE(TSchemeShardSubDomainTest) { } - Y_UNIT_TEST(CreateSubDomainWithoutTabletsThenDrop) { + Y_UNIT_TEST(CreateSubDomainWithoutTabletsThenDrop) { TTestBasicRuntime runtime; TTestEnv env(runtime); ui64 txId = 100; @@ -528,7 +528,7 @@ Y_UNIT_TEST_SUITE(TSchemeShardSubDomainTest) { UNIT_ASSERT(!CheckLocalRowExists(runtime, TTestTxConfig::SchemeShard, "Paths", "Id", 2)); } - Y_UNIT_TEST(CreateSubDomainsInSeparateDir) { + Y_UNIT_TEST(CreateSubDomainsInSeparateDir) { TTestBasicRuntime runtime; TTestEnv env(runtime); ui64 txId = 100; @@ -567,7 +567,7 @@ Y_UNIT_TEST_SUITE(TSchemeShardSubDomainTest) { NLs::ShardsInsideDomain(0)}); } - Y_UNIT_TEST(SimultaneousCreateDelete) { + Y_UNIT_TEST(SimultaneousCreateDelete) { TTestBasicRuntime runtime; TTestEnv env(runtime); ui64 txId = 100; @@ -935,7 +935,7 @@ Y_UNIT_TEST_SUITE(TSchemeShardSubDomainTest) { UNIT_ASSERT(!CheckLocalRowExists(runtime, TTestTxConfig::SchemeShard, "Paths", "Id", 2)); } - Y_UNIT_TEST(SimultaneousCreateTenantTable) { + Y_UNIT_TEST(SimultaneousCreateTenantTable) { TTestBasicRuntime runtime; TTestEnv env(runtime); ui64 txId = 100; @@ -1029,7 +1029,7 @@ Y_UNIT_TEST_SUITE(TSchemeShardSubDomainTest) { {NLs::PathExist}); } - Y_UNIT_TEST(SimultaneousCreateTenantDirTable) { + Y_UNIT_TEST(SimultaneousCreateTenantDirTable) { TTestBasicRuntime runtime; TTestEnv env(runtime); ui64 txId = 100; @@ -1328,7 +1328,7 @@ Y_UNIT_TEST_SUITE(TSchemeShardSubDomainTest) { TestLs(runtime, "/MyRoot/USER_0", false, NLs::PathNotExist); } - Y_UNIT_TEST(Restart) { + Y_UNIT_TEST(Restart) { TTestBasicRuntime runtime; TTestEnv env(runtime); ui64 txId = 100; @@ -1366,7 +1366,7 @@ Y_UNIT_TEST_SUITE(TSchemeShardSubDomainTest) { NLs::ShardsInsideDomain(0)}); } - Y_UNIT_TEST(RestartAtInFly) { + Y_UNIT_TEST(RestartAtInFly) { TTestBasicRuntime runtime; TTestEnv env(runtime); ui64 txId = 100; @@ -1394,7 +1394,7 @@ Y_UNIT_TEST_SUITE(TSchemeShardSubDomainTest) { NLs::ShardsInsideDomain(0)}); } - Y_UNIT_TEST(Delete) { + Y_UNIT_TEST(Delete) { TTestBasicRuntime runtime; TTestEnv env(runtime); ui64 txId = 100; @@ -1429,7 +1429,7 @@ Y_UNIT_TEST_SUITE(TSchemeShardSubDomainTest) { } - Y_UNIT_TEST(DeleteAdd) { + Y_UNIT_TEST(DeleteAdd) { TTestBasicRuntime runtime; TTestEnv env(runtime); ui64 txId = 100; @@ -1467,7 +1467,7 @@ Y_UNIT_TEST_SUITE(TSchemeShardSubDomainTest) { NLs::ShardsInsideDomain(0)}); } - Y_UNIT_TEST(DeleteAndRestart) { + Y_UNIT_TEST(DeleteAndRestart) { TTestBasicRuntime runtime; TTestEnv env(runtime); ui64 txId = 100; diff --git a/ydb/core/tx/time_cast/time_cast.cpp b/ydb/core/tx/time_cast/time_cast.cpp index 08042194fc5..f02539d3c3e 100644 --- a/ydb/core/tx/time_cast/time_cast.cpp +++ b/ydb/core/tx/time_cast/time_cast.cpp @@ -16,14 +16,14 @@ namespace NKikimr { ui64 TMediatorTimecastEntry::Get(ui64 tabletId) const { - Y_UNUSED(tabletId); + Y_UNUSED(tabletId); return AtomicGet(Step); } void TMediatorTimecastEntry::Update(ui64 step, ui64 *exemption, ui64 exsz) { - Y_VERIFY(exsz == 0, "exemption lists not supported yet"); - Y_UNUSED(exemption); - Y_UNUSED(exsz); + Y_VERIFY(exsz == 0, "exemption lists not supported yet"); + Y_UNUSED(exemption); + Y_UNUSED(exsz); AtomicSet(Step, step); } @@ -123,7 +123,7 @@ class TMediatorTimecastProxy : public TActor<TMediatorTimecastProxy> { TMediator &mediator = xpair.second; if (mediator.PipeClient == pipeClient) { - Y_VERIFY(tabletId == mediatorTabletId); + Y_VERIFY(tabletId == mediatorTabletId); mediator.PipeClient = TActorId(); RegisterMediator(mediatorTabletId, mediator, ctx); return; @@ -181,7 +181,7 @@ void TMediatorTimecastProxy::Handle(TEvMediatorTimecast::TEvRegisterTablet::TPtr TMediator &mediator = MediatorInfo(mediatorTabletId, processingParams); tabletInfo.Mediator = &mediator; - Y_VERIFY(bucketId < mediator.BucketsSz); + Y_VERIFY(bucketId < mediator.BucketsSz); auto &bucket = mediator.Buckets[bucketId]; if (!bucket.Entry) bucket.Entry = new TMediatorTimecastEntry(); @@ -262,7 +262,7 @@ void TMediatorTimecastProxy::Handle(TEvMediatorTimecast::TEvUpdate::TPtr &ev, co << " HANDLE "<< ev->Get()->ToString()); const NKikimrTxMediatorTimecast::TEvUpdate &record = ev->Get()->Record; - Y_VERIFY(record.ExemptionSize() == 0, "exemption lists are not supported yet"); + Y_VERIFY(record.ExemptionSize() == 0, "exemption lists are not supported yet"); const ui64 mediatorTabletId = record.GetMediator(); auto it = Mediators.find(mediatorTabletId); diff --git a/ydb/core/tx/tx.h b/ydb/core/tx/tx.h index bacde442371..82decb0cfe2 100644 --- a/ydb/core/tx/tx.h +++ b/ydb/core/tx/tx.h @@ -49,7 +49,7 @@ struct TEvTxProxy { TEvProposeTransactionStatus(EStatus status, ui64 txid, ui64 stepId); EStatus GetStatus() const { - Y_VERIFY_DEBUG(Record.HasStatus()); + Y_VERIFY_DEBUG(Record.HasStatus()); return static_cast<EStatus>(Record.GetStatus()); } }; @@ -157,7 +157,7 @@ TAutoPtr<TEvSubDomain::TEvConfigure> CreateDomainConfigurationFromStatic(const T } template<> -inline void Out<NKikimr::TEvTxProxy::TEvProposeTransactionStatus::EStatus>(IOutputStream& o, +inline void Out<NKikimr::TEvTxProxy::TEvProposeTransactionStatus::EStatus>(IOutputStream& o, NKikimr::TEvTxProxy::TEvProposeTransactionStatus::EStatus x) { o << (ui32)x; } diff --git a/ydb/core/tx/tx_allocator/txallocator_ut.cpp b/ydb/core/tx/tx_allocator/txallocator_ut.cpp index 11efd70cbc7..a6762ff4706 100644 --- a/ydb/core/tx/tx_allocator/txallocator_ut.cpp +++ b/ydb/core/tx/tx_allocator/txallocator_ut.cpp @@ -7,19 +7,19 @@ using namespace NKikimr; using namespace NTxAllocatorUT_Private; -Y_UNIT_TEST_SUITE(TTxLocatorTest) { - Y_UNIT_TEST(Boot) { +Y_UNIT_TEST_SUITE(TTxLocatorTest) { + Y_UNIT_TEST(Boot) { TTestBasicRuntime runtime; TTestEnv env(runtime); } - Y_UNIT_TEST(TestZeroRange) { + Y_UNIT_TEST(TestZeroRange) { TTestBasicRuntime runtime; TTestEnv env(runtime); AllocateAndCheck(runtime, 0, NKikimrTx::TEvTxAllocateResult::SUCCESS); } - Y_UNIT_TEST(TestImposibleSize) { + Y_UNIT_TEST(TestImposibleSize) { TTestBasicRuntime runtime; TTestEnv env(runtime); const ui64 capacity = NTxAllocator::TTxAllocator::MaxCapacity; @@ -32,7 +32,7 @@ Y_UNIT_TEST_SUITE(TTxLocatorTest) { AllocateAndCheck(runtime, capacity - 3*requestSize + 1, NKikimrTx::TEvTxAllocateResult::IMPOSIBLE); } - Y_UNIT_TEST(TestAllocateAll) { + Y_UNIT_TEST(TestAllocateAll) { TTestBasicRuntime runtime; TTestEnv env(runtime); const ui64 capacity = NTxAllocator::TTxAllocator::MaxCapacity; @@ -40,7 +40,7 @@ Y_UNIT_TEST_SUITE(TTxLocatorTest) { AllocateAndCheck(runtime, 1, NKikimrTx::TEvTxAllocateResult::IMPOSIBLE); } - Y_UNIT_TEST(TestAllocateAllByPieces) { + Y_UNIT_TEST(TestAllocateAllByPieces) { TTestBasicRuntime runtime; TTestEnv env(runtime); const ui64 capacity = NTxAllocator::TTxAllocator::MaxCapacity; @@ -92,12 +92,12 @@ Y_UNIT_TEST_SUITE(TTxLocatorTest) { inersections.AssertIntersection(continuesRange); } - Y_UNIT_TEST(TestSignificantRequestWhenRunReserveTx) { + Y_UNIT_TEST(TestSignificantRequestWhenRunReserveTx) { const bool restartsEnable = false; DoSignificantRequests(restartsEnable); } - Y_UNIT_TEST(TestWithReboot) { + Y_UNIT_TEST(TestWithReboot) { const bool restartsEnable = true; DoSignificantRequests(restartsEnable); } diff --git a/ydb/core/tx/tx_proxy/datareq.cpp b/ydb/core/tx/tx_proxy/datareq.cpp index af48b42d60f..2c54e6a136e 100644 --- a/ydb/core/tx/tx_proxy/datareq.cpp +++ b/ydb/core/tx/tx_proxy/datareq.cpp @@ -977,7 +977,7 @@ void TDataReq::ProcessFlatMKQLResolve(NSchemeCache::TSchemeCacheRequest *cacheRe for (ui32 shx = 0, affectedShards = engine.GetAffectedShardCount(); shx != affectedShards; ++shx) { NMiniKQL::IEngineFlat::TShardData shardData; const auto shardDataRes = engine.GetAffectedShard(shx, shardData); - Y_VERIFY(shardDataRes == NMiniKQL::IEngineFlat::EResult::Ok); + Y_VERIFY(shardDataRes == NMiniKQL::IEngineFlat::EResult::Ok); NKikimrTxDataShard::TDataTransaction dataTransaction; dataTransaction.SetMiniKQL(shardData.Program); @@ -1136,7 +1136,7 @@ void TDataReq::ProcessReadTableResolve(NSchemeCache::TSchemeCacheRequest *cacheR } TAutoPtr<TEvTxProxySchemeCache::TEvResolveKeySet> TDataReq::PrepareFlatMKQLRequest(TStringBuf miniKQLProgram, TStringBuf miniKQLParams, const TActorContext &ctx) { - Y_UNUSED(ctx); + Y_UNUSED(ctx); TAutoPtr<NSchemeCache::TSchemeCacheRequest> request(new NSchemeCache::TSchemeCacheRequest()); @@ -1185,7 +1185,7 @@ void TDataReq::MarkShardError(ui64 shardId, TDataReq::TPerTablet &perTablet, boo if (invalidateDistCache) TryToInvalidateTable(perTablet.TableId, ctx); - Y_UNUSED(shardId); + Y_UNUSED(shardId); if (++TabletErrors == TabletsLeft) { LOG_ERROR_S_SAMPLED_BY(ctx, NKikimrServices::TX_PROXY, TxId, @@ -1202,7 +1202,7 @@ void TDataReq::Handle(TEvTxProxyReq::TEvMakeRequest::TPtr &ev, const TActorConte TEvTxProxyReq::TEvMakeRequest *msg = ev->Get(); const NKikimrTxUserProxy::TEvProposeTransaction &record = msg->Ev->Get()->Record; - Y_VERIFY(record.HasTransaction()); + Y_VERIFY(record.HasTransaction()); ProxyFlags = record.HasProxyFlags() ? record.GetProxyFlags() : 0; ExecTimeoutPeriod = record.HasExecTimeoutPeriod() @@ -1771,7 +1771,7 @@ void TDataReq::HandlePrepare(TEvDataShard::TEvProposeTransactionResult::TPtr &ev const ui64 tabletId = msg->GetOrigin(); TPerTablet *perTablet = PerTablet.FindPtr(tabletId); - Y_VERIFY(perTablet); + Y_VERIFY(perTablet); LOG_LOG_S_SAMPLED_BY(ctx, (msg->GetStatus() != NKikimrTxDataShard::TEvProposeTransactionResult::ERROR ? NActors::NLog::PRI_DEBUG : NActors::NLog::PRI_ERROR), @@ -1973,7 +1973,7 @@ void TDataReq::HandlePrepareErrors(TEvDataShard::TEvProposeTransactionResult::TP const ui64 tabletId = msg->GetOrigin(); TPerTablet *perTablet = PerTablet.FindPtr(tabletId); - Y_VERIFY(perTablet); + Y_VERIFY(perTablet); LOG_LOG_S_SAMPLED_BY(ctx, (msg->GetStatus() != NKikimrTxDataShard::TEvProposeTransactionResult::ERROR ? NActors::NLog::PRI_DEBUG : NActors::NLog::PRI_ERROR), @@ -2642,7 +2642,7 @@ void TDataReq::MakeFlatMKQLResponse(const TActorContext &ctx, const NCpuTime::TC return Die(ctx); } default: - Y_FAIL("unknown engine status# %" PRIu32 " txid# %" PRIu64, (ui32)FlatMKQLRequest->EngineResponseStatus, (ui64)TxId); + Y_FAIL("unknown engine status# %" PRIu32 " txid# %" PRIu64, (ui32)FlatMKQLRequest->EngineResponseStatus, (ui64)TxId); } } @@ -2778,13 +2778,13 @@ bool TDataReq::CheckDomainLocality(NSchemeCache::TSchemeCacheRequest &cacheReque void TDataReq::RegisterPlan(const TActorContext &ctx) { WallClockPrepared = Now(); TDomainsInfo *domainsInfo = AppData(ctx)->DomainsInfo.Get(); - Y_VERIFY(domainsInfo); + Y_VERIFY(domainsInfo); ui64 totalReadSize = 0; TSet<ui32> affectedDomains; for (const auto &xp : PerTablet) { const ui32 tabletDomain = domainsInfo->GetDomainUidByTabletId(xp.first); - Y_VERIFY(tabletDomain != Max<ui32>()); + Y_VERIFY(tabletDomain != Max<ui32>()); affectedDomains.insert(tabletDomain); totalReadSize += xp.second.ReadSize; } @@ -2990,7 +2990,7 @@ IActor* CreateTxProxyDataReq(const TTxProxyServices &services, const ui64 txid, return; template<> -inline void Out<NKikimr::NTxProxy::TDataReq::TPerTablet::ETabletStatus>(IOutputStream& o, +inline void Out<NKikimr::NTxProxy::TDataReq::TPerTablet::ETabletStatus>(IOutputStream& o, NKikimr::NTxProxy::TDataReq::TPerTablet::ETabletStatus x) { switch (x) { DATA_REQ_PER_TABLET_STATUS_MAP(STATUS_TO_STRING_IMPL_ITEM) diff --git a/ydb/core/tx/tx_proxy/proxy_ut.cpp b/ydb/core/tx/tx_proxy/proxy_ut.cpp index eba78928c5a..4e3a2119925 100644 --- a/ydb/core/tx/tx_proxy/proxy_ut.cpp +++ b/ydb/core/tx/tx_proxy/proxy_ut.cpp @@ -7,7 +7,7 @@ using namespace NKikimr; using namespace NTxProxyUT; using namespace NHelpers; -Y_UNIT_TEST_SUITE(TSubDomainTest) { +Y_UNIT_TEST_SUITE(TSubDomainTest) { NKikimrSchemeOp::TTableDescription GetTableSimpleDescription(const TString &name) { NKikimrSchemeOp::TTableDescription tableDescr; tableDescr.SetName(name); @@ -43,7 +43,7 @@ Y_UNIT_TEST_SUITE(TSubDomainTest) { env.GetClient().FlatQuery(query, res); } - Y_UNIT_TEST(Boot) { + Y_UNIT_TEST(Boot) { TTestEnv env; auto lsroot = env.GetClient().Ls("/"); Print(lsroot); @@ -58,7 +58,7 @@ Y_UNIT_TEST_SUITE(TSubDomainTest) { } } - Y_UNIT_TEST(LsLs) { + Y_UNIT_TEST(LsLs) { TTestEnv env; { @@ -111,7 +111,7 @@ Y_UNIT_TEST_SUITE(TSubDomainTest) { } } - Y_UNIT_TEST(CreateTablet) { + Y_UNIT_TEST(CreateTablet) { TTestEnv env(3,2); ui64 owner = THash<TString>()("CreateTablet"); @@ -134,7 +134,7 @@ Y_UNIT_TEST_SUITE(TSubDomainTest) { env.GetClient().WaitForTabletAlive(&env.GetRuntime(), result.GetTabletId(), true, WaitTimeOut)); } - Y_UNIT_TEST(CreateTabletForUnknownDomain) { + Y_UNIT_TEST(CreateTabletForUnknownDomain) { TTestEnv env; ui64 owner = THash<TString>()("CreateTabletForUnknownDomain"); @@ -164,7 +164,7 @@ Y_UNIT_TEST_SUITE(TSubDomainTest) { env.GetClient().GetLeaderNode(&env.GetRuntime(), result.GetTabletId())); } - Y_UNIT_TEST(CreateDummyTabletsInDifferentDomains) { + Y_UNIT_TEST(CreateDummyTabletsInDifferentDomains) { TTestEnv env(1, 2); ui64 tablet_in_first_domain = CreateSubDomainAndTabletInside(env, "USER_0", 1); @@ -196,7 +196,7 @@ Y_UNIT_TEST_SUITE(TSubDomainTest) { CheckTableRunOnProperTenantNode(env, "/dc-1/USER_1", tablet_in_second_domain); } - Y_UNIT_TEST(StartAndStopTenanNode) { + Y_UNIT_TEST(StartAndStopTenanNode) { TTestEnv env(1, 1); auto subdomain_0 = GetSubDomainDeclareSetting("USER_0", env.GetPools()); @@ -326,7 +326,7 @@ Y_UNIT_TEST_SUITE(TSubDomainTest) { UNIT_ASSERT_VALUES_EQUAL(NMsgBusProxy::MSTATUS_OK, env.GetClient().ForceDeleteSubdomain("/dc-1", "USER_0")); } - Y_UNIT_TEST(StartTenanNodeAndStopAtDestructor) { + Y_UNIT_TEST(StartTenanNodeAndStopAtDestructor) { TTestEnv env(1, 1); auto subdomain_0 = GetSubDomainDeclareSetting("USER_0", env.GetPools()); @@ -335,7 +335,7 @@ Y_UNIT_TEST_SUITE(TSubDomainTest) { env.GetTenants().Run("/dc-1/USER_0"); } - Y_UNIT_TEST(CreateTableInsideSubDomain) { + Y_UNIT_TEST(CreateTableInsideSubDomain) { TTestEnv env(1, 1); UNIT_ASSERT_VALUES_EQUAL("/dc-1", env.GetRoot()); @@ -378,7 +378,7 @@ Y_UNIT_TEST_SUITE(TSubDomainTest) { } } - Y_UNIT_TEST(FailIfAffectedSetNotInterior) { + Y_UNIT_TEST(FailIfAffectedSetNotInterior) { TTestEnv env(1, 2); UNIT_ASSERT_VALUES_EQUAL("/dc-1", env.GetRoot()); @@ -468,7 +468,7 @@ Y_UNIT_TEST_SUITE(TSubDomainTest) { } - Y_UNIT_TEST(GenericCases) { + Y_UNIT_TEST(GenericCases) { TTestEnv env(1, 1); UNIT_ASSERT_VALUES_EQUAL("/dc-1", env.GetRoot()); @@ -547,7 +547,7 @@ Y_UNIT_TEST_SUITE(TSubDomainTest) { } } - Y_UNIT_TEST(DatashardNotRunAtAllWhenSubDomainNodesIsStopped) { + Y_UNIT_TEST(DatashardNotRunAtAllWhenSubDomainNodesIsStopped) { TTestEnv env(1, 1); UNIT_ASSERT_VALUES_EQUAL("/dc-1", env.GetRoot()); @@ -587,7 +587,7 @@ Y_UNIT_TEST_SUITE(TSubDomainTest) { UNIT_ASSERT(!env.GetClient().WaitForTabletAlive(&env.GetRuntime(), somedatashard, true, WaitTimeOut)); } - Y_UNIT_TEST(DatashardRunAtOtherNodeWhenOneNodeIsStopped) { + Y_UNIT_TEST(DatashardRunAtOtherNodeWhenOneNodeIsStopped) { TTestEnv env(1, 2); UNIT_ASSERT_VALUES_EQUAL("/dc-1", env.GetRoot()); diff --git a/ydb/core/tx/tx_proxy/storage_tenant_ut.cpp b/ydb/core/tx/tx_proxy/storage_tenant_ut.cpp index c3b8e9921a8..69fd89f4cd6 100644 --- a/ydb/core/tx/tx_proxy/storage_tenant_ut.cpp +++ b/ydb/core/tx/tx_proxy/storage_tenant_ut.cpp @@ -14,8 +14,8 @@ using namespace NKikimr; using namespace NTxProxyUT; using namespace NHelpers; -Y_UNIT_TEST_SUITE(TStorageTenantTest) { - Y_UNIT_TEST(Boot) { +Y_UNIT_TEST_SUITE(TStorageTenantTest) { + Y_UNIT_TEST(Boot) { TTestEnvWithPoolsSupport env; auto lsroot = env.GetClient().Ls("/"); Print(lsroot); @@ -25,7 +25,7 @@ Y_UNIT_TEST_SUITE(TStorageTenantTest) { NTestLs::Finished(lsdomain); } - Y_UNIT_TEST(LsLs) { + Y_UNIT_TEST(LsLs) { TTestEnvWithPoolsSupport env(2, 2); auto storagePool = env.CreatePoolsForTenant("USER_0"); @@ -46,7 +46,7 @@ Y_UNIT_TEST_SUITE(TStorageTenantTest) { } } - Y_UNIT_TEST(CreateDummyTabletsInDifferentDomains) { + Y_UNIT_TEST(CreateDummyTabletsInDifferentDomains) { TTestEnvWithPoolsSupport env(2, 2); auto first_storage_pools = env.CreatePoolsForTenant("USER_0"); @@ -90,7 +90,7 @@ Y_UNIT_TEST_SUITE(TStorageTenantTest) { CheckThatAllChannelsIsRightStoragePools(secondStorageInfo, second_storage_pools); } - Y_UNIT_TEST(CreateTableInsideSubDomain) { + Y_UNIT_TEST(CreateTableInsideSubDomain) { TTestEnvWithPoolsSupport env(1, 2); auto storagePool = env.CreatePoolsForTenant("USER_0"); @@ -246,7 +246,7 @@ Y_UNIT_TEST_SUITE(TStorageTenantTest) { } } - Y_UNIT_TEST(GenericCases) { + Y_UNIT_TEST(GenericCases) { TTestEnvWithPoolsSupport env(1, 1); auto storagePool = env.CreatePoolsForTenant("USER_0"); diff --git a/ydb/core/util/bits.h b/ydb/core/util/bits.h index 00319418413..4af42fa02cd 100644 --- a/ydb/core/util/bits.h +++ b/ydb/core/util/bits.h @@ -8,9 +8,9 @@ namespace NKikimr { // naive implementation of clz inline unsigned int NaiveClz(unsigned int v) { - Y_ASSERT(v); + Y_ASSERT(v); unsigned int cntr = 0; - const static unsigned mask = 1u << (std::numeric_limits<unsigned int>::digits - 1); + const static unsigned mask = 1u << (std::numeric_limits<unsigned int>::digits - 1); while ((v & mask) == 0) { v <<= 1; cntr++; diff --git a/ydb/core/util/bits_ut.cpp b/ydb/core/util/bits_ut.cpp index 2dc25234fe9..e2450dd4b49 100644 --- a/ydb/core/util/bits_ut.cpp +++ b/ydb/core/util/bits_ut.cpp @@ -3,8 +3,8 @@ namespace NKikimr { - Y_UNIT_TEST_SUITE(TBitsTest) { - Y_UNIT_TEST(TestNaiveClz) { + Y_UNIT_TEST_SUITE(TBitsTest) { + Y_UNIT_TEST(TestNaiveClz) { UNIT_ASSERT(sizeof(unsigned) == sizeof(ui32)); UNIT_ASSERT_EQUAL(NaiveClz(58649), 16); UNIT_ASSERT_EQUAL(NaiveClz(0xF0000000), 0); diff --git a/ydb/core/util/blob_data_stream.h b/ydb/core/util/blob_data_stream.h index dac5c0234bd..11c19f2da1c 100644 --- a/ydb/core/util/blob_data_stream.h +++ b/ydb/core/util/blob_data_stream.h @@ -20,7 +20,7 @@ public: // const void* ReadAt(ui32 offset, ui32 size) const { Y_VERIFY_DEBUG(Buffer.size() >= offset + size); - Y_UNUSED(size); + Y_UNUSED(size); return Buffer.data() + offset; } @@ -114,7 +114,7 @@ public: // template<typename T> void SetValue(const T& value) { - Y_VERIFY(sizeof(T) == Size); + Y_VERIFY(sizeof(T) == Size); DataStream->WriteAtPosition(Position, (const char*)&value, sizeof(T)); } }; @@ -131,7 +131,7 @@ public: // void SetValue(const T& value) { - Y_VERIFY(sizeof(T) == Size); + Y_VERIFY(sizeof(T) == Size); DataStream->WriteAtPosition(Position, (const char*)&value, sizeof(T)); } }; diff --git a/ydb/core/util/cache.h b/ydb/core/util/cache.h index 916701ebc71..f2bcdfeee80 100644 --- a/ydb/core/util/cache.h +++ b/ydb/core/util/cache.h @@ -130,23 +130,23 @@ public: virtual ui64 UpdateUsedSize(const TKey& key, const TValue& newValue, ui64 oldSize) = 0; static ui64 DefaultMeasureCallback(const TKey& key, const TValue& value) { - Y_UNUSED(key); - Y_UNUSED(value); + Y_UNUSED(key); + Y_UNUSED(value); return 1; } static void DefaultEvictionCallback(const TKey& key, TValue& value, ui64 size) { - Y_UNUSED(key); - Y_UNUSED(value); - Y_UNUSED(size); + Y_UNUSED(key); + Y_UNUSED(value); + Y_UNUSED(size); } static void DefaultKeyEvictionCallback(const TKey& key) { - Y_UNUSED(key); + Y_UNUSED(key); } static bool DefaultOverflowCallback(const TSelf& cache) { - Y_UNUSED(cache); + Y_UNUSED(cache); return false; } }; @@ -260,8 +260,8 @@ public: } void OnInsert(const TKey& key, const TValue& value, ui64 size) override { - Y_UNUSED(key); - Y_UNUSED(value); + Y_UNUSED(key); + Y_UNUSED(value); UsedSize += size; ++Count; } @@ -308,7 +308,7 @@ public: ui64 UpdateUsedSize(const TKey& key, const TValue& newValue, ui64 oldSize) override final { ui64 newSize = MeasureCallback(key, newValue); - Y_VERIFY(UsedSize >= oldSize); + Y_VERIFY(UsedSize >= oldSize); UsedSize -= oldSize; UsedSize += newSize; return newSize; @@ -525,7 +525,7 @@ public: ui64 size = TSelf::Measure(item->Key, item->Value); this->OnEvict(item->Key, item->Value, size); auto itemIt = Index.find(*item); - Y_VERIFY_DEBUG(itemIt != Index.end()); + Y_VERIFY_DEBUG(itemIt != Index.end()); Index.erase(itemIt); return true; } @@ -683,14 +683,14 @@ public: ui64 size = TSelf::Measure(inItem->Key, inItem->Value); this->OnEvict(inItem->Key, inItem->Value, size); auto inItemIt = InIndex.find(*inItem); - Y_VERIFY_DEBUG(inItemIt != InIndex.end()); + Y_VERIFY_DEBUG(inItemIt != InIndex.end()); InIndex.erase(inItemIt); InSize -= size; if (OutIndex.size() > Config->OutKeyRatio * TSelf::GetCount()) { auto outItem = OutList.PopBack(); auto outItemIt = OutIndex.find(*outItem); - Y_VERIFY_DEBUG(outItemIt != OutIndex.end()); + Y_VERIFY_DEBUG(outItemIt != OutIndex.end()); this->OnKeyEvict(outItemIt->Key); OutIndex.erase(outItemIt); } @@ -703,7 +703,7 @@ public: ui64 size = TSelf::Measure(item->Key, item->Value); this->OnEvict(item->Key, item->Value, size); auto mainIndexIt = MainIndex.find(*item); - Y_VERIFY_DEBUG(mainIndexIt != MainIndex.end()); + Y_VERIFY_DEBUG(mainIndexIt != MainIndex.end()); MainIndex.erase(mainIndexIt); return true; } diff --git a/ydb/core/util/cache_cache.h b/ydb/core/util/cache_cache.h index a8ab10977dd..99e57e0027a 100644 --- a/ydb/core/util/cache_cache.h +++ b/ydb/core/util/cache_cache.h @@ -99,7 +99,7 @@ public: WarmList.PushFront(xitem); return nullptr; default: - Y_VERIFY_DEBUG(false, "unknown/broken cache generation"); + Y_VERIFY_DEBUG(false, "unknown/broken cache generation"); return nullptr; } } @@ -127,7 +127,7 @@ public: *Config.ReportedWarm = WarmWeight; break; default: - Y_VERIFY_DEBUG(false, "unknown cache generaton"); + Y_VERIFY_DEBUG(false, "unknown cache generaton"); } } @@ -156,7 +156,7 @@ public: *Config.ReportedWarm = WarmWeight; break; default: - Y_VERIFY_DEBUG(false, "unknown cache generaton"); + Y_VERIFY_DEBUG(false, "unknown cache generaton"); } } @@ -171,16 +171,16 @@ private: item->Unlink(); const ui64 elementWeight = WeightOp.Get(item); - Y_VERIFY_DEBUG(elementWeight <= weight); + Y_VERIFY_DEBUG(elementWeight <= weight); weight -= elementWeight; } TItem* AddToFresh(TItem *item) { TItem *ret = nullptr; while (FreshWeight > Config.FreshLimit) { - Y_VERIFY_DEBUG(!FreshList.Empty()); + Y_VERIFY_DEBUG(!FreshList.Empty()); TItem *x = FreshList.PopBack(); - Y_VERIFY(GenerationOp.Get(x) == TCacheCacheConfig::CacheGenFresh, "malformed entry in fresh cache. %" PRIu32, (ui32)GenerationOp.Get(x)); + Y_VERIFY(GenerationOp.Get(x) == TCacheCacheConfig::CacheGenFresh, "malformed entry in fresh cache. %" PRIu32, (ui32)GenerationOp.Get(x)); Unlink(x, FreshWeight); ret = AddToStaging(x, ret); } @@ -201,9 +201,9 @@ private: TItem *ret = nullptr; Unlink(item, StagingWeight); while (WarmWeight > Config.WarmLimit) { - Y_VERIFY_DEBUG(!WarmList.Empty()); + Y_VERIFY_DEBUG(!WarmList.Empty()); TItem *x = WarmList.PopBack(); - Y_VERIFY(GenerationOp.Get(x) == TCacheCacheConfig::CacheGenWarm, "malformed entry in warm cache. %" PRIu32, (ui32)GenerationOp.Get(x)); + Y_VERIFY(GenerationOp.Get(x) == TCacheCacheConfig::CacheGenWarm, "malformed entry in warm cache. %" PRIu32, (ui32)GenerationOp.Get(x)); Unlink(x, WarmWeight); ret = AddToStaging(x, ret); } @@ -221,9 +221,9 @@ private: TItem* AddToStaging(TItem *item, TItem *ret) { while (StagingWeight > Config.StagingLimit) { - Y_VERIFY_DEBUG(!StagingList.Empty()); + Y_VERIFY_DEBUG(!StagingList.Empty()); TItem *evicted = StagingList.PopBack(); - Y_VERIFY(GenerationOp.Get(evicted) == TCacheCacheConfig::CacheGenStaging, "malformed entry in staging cache %" PRIu32, (ui32)GenerationOp.Get(evicted)); + Y_VERIFY(GenerationOp.Get(evicted) == TCacheCacheConfig::CacheGenStaging, "malformed entry in staging cache %" PRIu32, (ui32)GenerationOp.Get(evicted)); Unlink(evicted, StagingWeight); GenerationOp.Set(evicted, TCacheCacheConfig::CacheGenEvicted); if (ret == nullptr) diff --git a/ydb/core/util/cache_ut.cpp b/ydb/core/util/cache_ut.cpp index 1cc902e089e..0088006cc7d 100644 --- a/ydb/core/util/cache_ut.cpp +++ b/ydb/core/util/cache_ut.cpp @@ -23,8 +23,8 @@ struct TDtorTracer { ui64 TDtorTracer::InstanceCount = 0; -Y_UNIT_TEST_SUITE(TCacheTest) { - Y_UNIT_TEST(TestUnboundedMapCache) { +Y_UNIT_TEST_SUITE(TCacheTest) { + Y_UNIT_TEST(TestUnboundedMapCache) { TUnboundedCacheOnMap<ui32, TString> cache; TString* tmp; UNIT_ASSERT_EQUAL(cache.GetCount(), 0); @@ -67,7 +67,7 @@ Y_UNIT_TEST_SUITE(TCacheTest) { UNIT_ASSERT(!cache.IsOverflow()); } - Y_UNIT_TEST(EnsureNoLeakAfterUnboundedCacheOnMapDtor) { + Y_UNIT_TEST(EnsureNoLeakAfterUnboundedCacheOnMapDtor) { { TUnboundedCacheOnMap<ui32, TDtorTracer> cache; TDtorTracer* tmp; @@ -78,7 +78,7 @@ Y_UNIT_TEST_SUITE(TCacheTest) { UNIT_ASSERT_EQUAL(TDtorTracer::InstanceCount, 0); } - Y_UNIT_TEST(TestSizeBasedOverflowCallback) { + Y_UNIT_TEST(TestSizeBasedOverflowCallback) { TUnboundedCacheOnMap<ui32, TString> cache; TSizeBasedOverflowCallback<ui32, TString> overflowCallback(2); cache.SetOverflowCallback([&](const ICache<ui32, TString>& cache) { return overflowCallback(cache); }); @@ -95,7 +95,7 @@ Y_UNIT_TEST_SUITE(TCacheTest) { UNIT_ASSERT(!cache.IsOverflow()); } - Y_UNIT_TEST(TestLruCache) { + Y_UNIT_TEST(TestLruCache) { TLruCache<ui32, TString> cache; TString* tmp; TSizeBasedOverflowCallback<ui32, TString> overflowCallback(2); @@ -133,7 +133,7 @@ Y_UNIT_TEST_SUITE(TCacheTest) { UNIT_ASSERT_EQUAL(cache.GetUsedSize(), 0); } - Y_UNIT_TEST(EnsureNoLeakAfterLruCacheDtor) { + Y_UNIT_TEST(EnsureNoLeakAfterLruCacheDtor) { { TLruCache<ui32, TDtorTracer> cache; TDtorTracer* tmp; @@ -144,13 +144,13 @@ Y_UNIT_TEST_SUITE(TCacheTest) { UNIT_ASSERT_EQUAL(TDtorTracer::InstanceCount, 0); } - Y_UNIT_TEST(Test2QCache) { + Y_UNIT_TEST(Test2QCache) { TIntrusivePtr<T2QCacheConfig> config(new T2QCacheConfig); T2QCache<ui32, TString> cache(config); TString lastEvicted; cache.SetEvictionCallback([&](const ui32& key, TString& value, ui64 size){ - Y_UNUSED(key); - Y_UNUSED(size); + Y_UNUSED(key); + Y_UNUSED(size); lastEvicted = value; }); @@ -225,7 +225,7 @@ Y_UNIT_TEST_SUITE(TCacheTest) { UNIT_ASSERT_EQUAL(lastEvictedKey, 8); } - Y_UNIT_TEST(EnsureNoLeakAfterQ2CacheDtor) { + Y_UNIT_TEST(EnsureNoLeakAfterQ2CacheDtor) { { TIntrusivePtr<T2QCacheConfig> config(new T2QCacheConfig); T2QCache<ui32, TDtorTracer> cache(config); @@ -250,9 +250,9 @@ Y_UNIT_TEST_SUITE(TCacheTest) { UNIT_ASSERT_EQUAL(TDtorTracer::InstanceCount, 0); } - Y_UNIT_TEST(TestUpdateItemSize) { + Y_UNIT_TEST(TestUpdateItemSize) { TUnboundedCacheOnMap<ui32, TString> cache([](const ui32& key, const TString& value) { - Y_UNUSED(key); + Y_UNUSED(key); return value.size(); }); diff --git a/ydb/core/util/console.cpp b/ydb/core/util/console.cpp index 547f010a40e..8e0d7b492e6 100644 --- a/ydb/core/util/console.cpp +++ b/ydb/core/util/console.cpp @@ -1,6 +1,6 @@ #include "console.h" -IOutputStream& PrintToConsoleStream(IOutputStream& stream, const TStringBuf& data) { +IOutputStream& PrintToConsoleStream(IOutputStream& stream, const TStringBuf& data) { #ifdef _win_ TStringBuf current = data; while (current.size() > 0) { diff --git a/ydb/core/util/console.h b/ydb/core/util/console.h index 73cc3f21f84..9e932f9ae8d 100644 --- a/ydb/core/util/console.h +++ b/ydb/core/util/console.h @@ -1,4 +1,4 @@ #pragma once #include "defs.h" -IOutputStream& PrintToConsoleStream(IOutputStream& stream, const TStringBuf& data); +IOutputStream& PrintToConsoleStream(IOutputStream& stream, const TStringBuf& data); diff --git a/ydb/core/util/failure_injection.cpp b/ydb/core/util/failure_injection.cpp index 9eeaaa968ba..12005b3b2ea 100644 --- a/ydb/core/util/failure_injection.cpp +++ b/ydb/core/util/failure_injection.cpp @@ -53,7 +53,7 @@ namespace NKikimr { Committed = true; } - void DumpQueue(IOutputStream& str) { + void DumpQueue(IOutputStream& str) { HTML(str) { TABLE() { TABLEHEAD() { @@ -251,7 +251,7 @@ namespace NKikimr { ctx.Send(ev->Sender, new NMon::TEvHttpInfoRes(str.Str(), ev->Get()->SubRequestId)); } - void ProcessQueue(IOutputStream& str, const TString& queue) { + void ProcessQueue(IOutputStream& str, const TString& queue) { TVector<std::tuple<TString, TMaybe<TParams>, ui32>> items; HTML(str) { diff --git a/ydb/core/util/fragmented_buffer_ut.cpp b/ydb/core/util/fragmented_buffer_ut.cpp index 7e7dee86df5..ee882239360 100644 --- a/ydb/core/util/fragmented_buffer_ut.cpp +++ b/ydb/core/util/fragmented_buffer_ut.cpp @@ -4,8 +4,8 @@ namespace NKikimr { -Y_UNIT_TEST_SUITE(TFragmentedBufferTest) { - Y_UNIT_TEST(TestWriteRead) { +Y_UNIT_TEST_SUITE(TFragmentedBufferTest) { + Y_UNIT_TEST(TestWriteRead) { const char *data2 = "234"; TFragmentedBuffer fb; fb.Write(1, data2, 3); @@ -15,7 +15,7 @@ Y_UNIT_TEST_SUITE(TFragmentedBufferTest) { UNIT_ASSERT_VALUES_EQUAL(buffer, data2); } - Y_UNIT_TEST(TestOverwriteRead) { + Y_UNIT_TEST(TestOverwriteRead) { const char *data2 = "234"; const char *data3 = "456"; TFragmentedBuffer fb; @@ -27,7 +27,7 @@ Y_UNIT_TEST_SUITE(TFragmentedBufferTest) { UNIT_ASSERT_VALUES_EQUAL(buffer, data3); } - Y_UNIT_TEST(TestIntersectedWriteRead) { + Y_UNIT_TEST(TestIntersectedWriteRead) { const char *data2 = "234"; const char *data3 = "456"; TFragmentedBuffer fb; @@ -39,7 +39,7 @@ Y_UNIT_TEST_SUITE(TFragmentedBufferTest) { UNIT_ASSERT_VALUES_EQUAL(buffer, "23456"); } - Y_UNIT_TEST(TestIntersectedWriteRead2) { + Y_UNIT_TEST(TestIntersectedWriteRead2) { const char *data2 = "234"; const char *data3 = "456"; TFragmentedBuffer fb; @@ -51,7 +51,7 @@ Y_UNIT_TEST_SUITE(TFragmentedBufferTest) { UNIT_ASSERT_VALUES_EQUAL(buffer, "23456"); } - Y_UNIT_TEST(TestIntersectedWriteRead3) { + Y_UNIT_TEST(TestIntersectedWriteRead3) { const char *data2 = "234"; const char *data3 = "456"; const char *data4 = "678"; @@ -65,7 +65,7 @@ Y_UNIT_TEST_SUITE(TFragmentedBufferTest) { UNIT_ASSERT_VALUES_EQUAL(buffer, "2345678"); } - Y_UNIT_TEST(Test3WriteRead) { + Y_UNIT_TEST(Test3WriteRead) { const char *data2 = "234"; const char *data3v2 = "5"; const char *data4 = "678"; @@ -79,7 +79,7 @@ Y_UNIT_TEST_SUITE(TFragmentedBufferTest) { UNIT_ASSERT_VALUES_EQUAL(buffer, "2345678"); } - Y_UNIT_TEST(Test5WriteRead) { + Y_UNIT_TEST(Test5WriteRead) { const char *data1 = "1"; const char *data2 = "234"; const char *data3 = "456"; diff --git a/ydb/core/util/hyperlog_counter.cpp b/ydb/core/util/hyperlog_counter.cpp index f86891571fa..f57eaa0c1f2 100644 --- a/ydb/core/util/hyperlog_counter.cpp +++ b/ydb/core/util/hyperlog_counter.cpp @@ -9,7 +9,7 @@ THyperLogCounter::THyperLogCounter() THyperLogCounter::THyperLogCounter(ui8 value) : Value(value) { - Y_VERIFY(value < 64); + Y_VERIFY(value < 64); } ui8 THyperLogCounter::GetValue() const { @@ -30,7 +30,7 @@ bool THyperLogCounter::Increment(IRandomProvider& randomProvider) { return false; ++Value; - Y_VERIFY_DEBUG(Value < 64); + Y_VERIFY_DEBUG(Value < 64); return true; } @@ -76,7 +76,7 @@ bool THyperLogCounter::Add(ui64 addend, IRandomProvider& randomProvider) { remain >>= 1; } - Y_VERIFY_DEBUG(Value < 64); + Y_VERIFY_DEBUG(Value < 64); return (oldValue != Value); } @@ -92,7 +92,7 @@ THybridLogCounter::THybridLogCounter(ui8 value) : Value(value) { if (Value & IsHyperLog) { - Y_VERIFY((value & DataMask) < 64); + Y_VERIFY((value & DataMask) < 64); } } diff --git a/ydb/core/util/hyperlog_counter_ut.cpp b/ydb/core/util/hyperlog_counter_ut.cpp index 25703265b00..10e6fea9756 100644 --- a/ydb/core/util/hyperlog_counter_ut.cpp +++ b/ydb/core/util/hyperlog_counter_ut.cpp @@ -5,8 +5,8 @@ namespace NKikimr { -Y_UNIT_TEST_SUITE(THyperLogCounterTest) { - Y_UNIT_TEST(TestGetSet) { +Y_UNIT_TEST_SUITE(THyperLogCounterTest) { + Y_UNIT_TEST(TestGetSet) { THyperLogCounter c1; THyperLogCounter c2(17); THyperLogCounter c3(63); @@ -18,7 +18,7 @@ Y_UNIT_TEST_SUITE(THyperLogCounterTest) { UNIT_ASSERT_EQUAL(c3.GetEstimatedCounter(), ui64(-2)); } - Y_UNIT_TEST(TestIncrement) { + Y_UNIT_TEST(TestIncrement) { THyperLogCounter c; auto randomProvider = CreateDefaultRandomProvider(); const ui32 n = 1000000; @@ -50,7 +50,7 @@ Y_UNIT_TEST_SUITE(THyperLogCounterTest) { Cout << "min. delta: " << minDelta << ", max. delta: " << maxDelta << ", avg. : " << avg << ", dev. : " << dev << "\n"; } - Y_UNIT_TEST(TestAddRandom) { + Y_UNIT_TEST(TestAddRandom) { THyperLogCounter c; auto randomProvider = CreateDefaultRandomProvider(); const ui32 n = 1000000; @@ -85,7 +85,7 @@ Y_UNIT_TEST_SUITE(THyperLogCounterTest) { Cout << "min. delta: " << minDelta << ", max. delta: " << maxDelta << ", avg. : " << avg << ", dev. : " << dev << "\n"; } - Y_UNIT_TEST(TestAddFixed) { + Y_UNIT_TEST(TestAddFixed) { auto randomProvider = CreateDefaultRandomProvider(); THyperLogCounter c; const ui32 n = 1000000; @@ -120,7 +120,7 @@ Y_UNIT_TEST_SUITE(THyperLogCounterTest) { Cout << "min. delta: " << minDelta << ", max. delta: " << maxDelta << ", avg. : " << avg << ", dev. : " << dev << "\n"; } - Y_UNIT_TEST(TestHybridIncrement) { + Y_UNIT_TEST(TestHybridIncrement) { auto randomProvider = CreateDefaultRandomProvider(); THybridLogCounter c1; UNIT_ASSERT_EQUAL(c1.GetValue(), 0); @@ -139,7 +139,7 @@ Y_UNIT_TEST_SUITE(THyperLogCounterTest) { } } - Y_UNIT_TEST(TestHybridAdd) { + Y_UNIT_TEST(TestHybridAdd) { auto randomProvider = CreateDefaultRandomProvider(); THybridLogCounter c1; UNIT_ASSERT(c1.Add(23, *randomProvider)); diff --git a/ydb/core/util/interval_set_ut.cpp b/ydb/core/util/interval_set_ut.cpp index c1df7015fd1..a0d3f825e4b 100644 --- a/ydb/core/util/interval_set_ut.cpp +++ b/ydb/core/util/interval_set_ut.cpp @@ -176,7 +176,7 @@ TIntervals MakeIntervalSet(ui64 n, ui32 len) { template <class TIntervals, const char* type_name> \ void TTestCase##N<TIntervals, type_name>::Execute_(NUnitTest::TTestContext& ut_context Y_DECLARE_UNUSED) -Y_UNIT_TEST_SUITE(TIntervalSetTest) { +Y_UNIT_TEST_SUITE(TIntervalSetTest) { MY_UNIT_TEST(TestEmpty) { TIntervals a; UNIT_ASSERT_EQUAL(a.IsEmpty(), true); diff --git a/ydb/core/util/intrusive_fixed_hash_set_ut.cpp b/ydb/core/util/intrusive_fixed_hash_set_ut.cpp index 434aca6b9b6..52faf7ccc50 100644 --- a/ydb/core/util/intrusive_fixed_hash_set_ut.cpp +++ b/ydb/core/util/intrusive_fixed_hash_set_ut.cpp @@ -6,7 +6,7 @@ namespace NKikimr { -Y_UNIT_TEST_SUITE(TIntrusiveFixedHashSetTest) { +Y_UNIT_TEST_SUITE(TIntrusiveFixedHashSetTest) { struct TSimpleItem { TSimpleItem *Next = nullptr; ui64 X = 0; @@ -28,14 +28,14 @@ Y_UNIT_TEST_SUITE(TIntrusiveFixedHashSetTest) { {} }; - Y_UNIT_TEST(TestEmptyFind) { + Y_UNIT_TEST(TestEmptyFind) { TIntrusiveFixedHashSet<TSimpleItem, &TSimpleItem::Next, &TSimpleItem::Hash, &TSimpleItem::Equals> set(100); TSimpleItem item; TSimpleItem *res = set.Find(&item); UNIT_ASSERT_EQUAL(res, nullptr); } - Y_UNIT_TEST(TestPushFindClear) { + Y_UNIT_TEST(TestPushFindClear) { TIntrusiveFixedHashSet<TSimpleItem, &TSimpleItem::Next, &TSimpleItem::Hash, &TSimpleItem::Equals> set(100); TDeque<TSimpleItem> items; for (ui64 i = 0; i < 100; ++i) { diff --git a/ydb/core/util/intrusive_stack_ut.cpp b/ydb/core/util/intrusive_stack_ut.cpp index 61e544b4adf..42e9d3af917 100644 --- a/ydb/core/util/intrusive_stack_ut.cpp +++ b/ydb/core/util/intrusive_stack_ut.cpp @@ -5,12 +5,12 @@ namespace NKikimr { -Y_UNIT_TEST_SUITE(TIntrusiveStackTest) { +Y_UNIT_TEST_SUITE(TIntrusiveStackTest) { struct TSimpleItem { TSimpleItem *Next = nullptr; }; - Y_UNIT_TEST(TestEmptyPop) { + Y_UNIT_TEST(TestEmptyPop) { TIntrusiveStack<TSimpleItem, &TSimpleItem::Next> stack; TSimpleItem *res = stack.Pop(); UNIT_ASSERT_EQUAL(res, nullptr); @@ -18,7 +18,7 @@ Y_UNIT_TEST_SUITE(TIntrusiveStackTest) { UNIT_ASSERT_EQUAL(size, 0); } - Y_UNIT_TEST(TestPushPop) { + Y_UNIT_TEST(TestPushPop) { TIntrusiveStack<TSimpleItem, &TSimpleItem::Next> stack; TVector<TSimpleItem> items; items.resize(100); diff --git a/ydb/core/util/metrics.h b/ydb/core/util/metrics.h index cae931733fa..d64cfe03827 100644 --- a/ydb/core/util/metrics.h +++ b/ydb/core/util/metrics.h @@ -1,7 +1,7 @@ #pragma once #include <array> #include <util/datetime/base.h> -#include <util/stream/buffer.h> +#include <util/stream/buffer.h> #include <cmath> #include <ydb/core/protos/metrics.pb.h> diff --git a/ydb/core/util/queue_inplace.h b/ydb/core/util/queue_inplace.h index e0a5803e1e7..5db6cb16145 100644 --- a/ydb/core/util/queue_inplace.h +++ b/ydb/core/util/queue_inplace.h @@ -33,7 +33,7 @@ public: {} ~TQueueInplace() { - Y_VERIFY_DEBUG(Head() == nullptr && Size == 0); + Y_VERIFY_DEBUG(Head() == nullptr && Size == 0); delete ReadFrom; } diff --git a/ydb/core/util/queue_inplace_ut.cpp b/ydb/core/util/queue_inplace_ut.cpp index fb2d511d048..6bb10122f3b 100644 --- a/ydb/core/util/queue_inplace_ut.cpp +++ b/ydb/core/util/queue_inplace_ut.cpp @@ -6,7 +6,7 @@ #include "queue_inplace.h" -Y_UNIT_TEST_SUITE(TQueueInplaceTests) { +Y_UNIT_TEST_SUITE(TQueueInplaceTests) { struct TStruct { ui32 X; @@ -27,7 +27,7 @@ Y_UNIT_TEST_SUITE(TQueueInplaceTests) { } }; - Y_UNIT_TEST(TestSimpleInplace) { + Y_UNIT_TEST(TestSimpleInplace) { using TQueueType = TQueueInplace<TStruct, 32>; // 3 values per chunk TQueueType queue; @@ -53,7 +53,7 @@ Y_UNIT_TEST_SUITE(TQueueInplaceTests) { UNIT_ASSERT(queue.Head() == nullptr); } - Y_UNIT_TEST(CleanInDestructor) { + Y_UNIT_TEST(CleanInDestructor) { using TQueueType = TQueueInplace<std::shared_ptr<bool> *, 32>; std::shared_ptr<bool> p(new bool(true)); diff --git a/ydb/core/util/queue_oneone_inplace_ut.cpp b/ydb/core/util/queue_oneone_inplace_ut.cpp index ac60a69f3dd..ffa5c98adcc 100644 --- a/ydb/core/util/queue_oneone_inplace_ut.cpp +++ b/ydb/core/util/queue_oneone_inplace_ut.cpp @@ -6,9 +6,9 @@ #include "queue_oneone_inplace.h" -Y_UNIT_TEST_SUITE(TOneOneQueueTests) { +Y_UNIT_TEST_SUITE(TOneOneQueueTests) { - Y_UNIT_TEST(TestSimpleEnqueueDequeue) { + Y_UNIT_TEST(TestSimpleEnqueueDequeue) { using TQueueType = TOneOneQueueInplace<ui64, 32>; // 3 values per chunk TQueueType queue; @@ -35,7 +35,7 @@ Y_UNIT_TEST_SUITE(TOneOneQueueTests) { UNIT_ASSERT(queue.Pop() == 0); } - Y_UNIT_TEST(CleanInDestructor) { + Y_UNIT_TEST(CleanInDestructor) { using TQueueType = TOneOneQueueInplace<std::shared_ptr<bool> *, 32>; @@ -55,7 +55,7 @@ Y_UNIT_TEST_SUITE(TOneOneQueueTests) { UNIT_ASSERT_VALUES_EQUAL(1, p.use_count()); } - Y_UNIT_TEST(ReadIterator) { + Y_UNIT_TEST(ReadIterator) { using TQueueType = TOneOneQueueInplace<int, 32>; TQueueType queue; diff --git a/ydb/core/util/tracking_alloc.h b/ydb/core/util/tracking_alloc.h index 96855506ac2..e63c3a01d15 100644 --- a/ydb/core/util/tracking_alloc.h +++ b/ydb/core/util/tracking_alloc.h @@ -81,7 +81,7 @@ public: } void deallocate(pointer p, size_type n) { - Y_ASSERT(*Allocated >= n * sizeof(T)); + Y_ASSERT(*Allocated >= n * sizeof(T)); *Allocated -= n * sizeof(T); std::allocator<T>::deallocate(p, n); } diff --git a/ydb/core/util/tuples.h b/ydb/core/util/tuples.h index 0ca06891984..8a200704997 100644 --- a/ydb/core/util/tuples.h +++ b/ydb/core/util/tuples.h @@ -58,7 +58,7 @@ struct hash<pair<TFirst, TSecond>> { // output for tuples template <typename TupleType, std::size_t N> struct OutTuple : OutTuple<TupleType, N - 1> { - static void Out(IOutputStream& stream, const TupleType& t) { + static void Out(IOutputStream& stream, const TupleType& t) { OutTuple<TupleType, N - 1>::Out(stream, t); stream << "," << std::get<N>(t); } @@ -66,13 +66,13 @@ struct OutTuple : OutTuple<TupleType, N - 1> { template <typename TupleType> struct OutTuple<TupleType, 0> { - static void Out(IOutputStream& stream, const TupleType& t) { + static void Out(IOutputStream& stream, const TupleType& t) { stream << std::get<0>(t); } }; template <typename... Types> -IOutputStream& operator <<(IOutputStream& stream, const std::tuple<Types...>& t) { +IOutputStream& operator <<(IOutputStream& stream, const std::tuple<Types...>& t) { stream << "("; OutTuple<std::tuple<Types...>, sizeof...(Types) - 1>::Out(stream, t); stream << ")"; diff --git a/ydb/core/util/wildcard_ut.cpp b/ydb/core/util/wildcard_ut.cpp index ad818a54f11..69b8caf4940 100644 --- a/ydb/core/util/wildcard_ut.cpp +++ b/ydb/core/util/wildcard_ut.cpp @@ -2,8 +2,8 @@ #include <library/cpp/testing/unittest/registar.h> namespace NKikimr { -Y_UNIT_TEST_SUITE(TWildcardTest) { - Y_UNIT_TEST(TestWildcard) { +Y_UNIT_TEST_SUITE(TWildcardTest) { + Y_UNIT_TEST(TestWildcard) { UNIT_ASSERT(NKikimr::IsMatchesWildcard("some/test/string", "*")); UNIT_ASSERT(NKikimr::IsMatchesWildcard("some/test/string", "*/*")); UNIT_ASSERT(NKikimr::IsMatchesWildcard("some/test/string", "some/test/string")); @@ -19,7 +19,7 @@ Y_UNIT_TEST_SUITE(TWildcardTest) { UNIT_ASSERT(!NKikimr::IsMatchesWildcard("", "*/test/*")); } - Y_UNIT_TEST(TestWildcards) { + Y_UNIT_TEST(TestWildcards) { UNIT_ASSERT(NKikimr::IsMatchesWildcards("some/test/string", "ssome*,*strring,*")); UNIT_ASSERT(NKikimr::IsMatchesWildcards("some/test/string", "ssome*,*,*strring")); UNIT_ASSERT(NKikimr::IsMatchesWildcards("some/test/string", "*,ssome*,*strring")); diff --git a/ydb/core/viewer/json/json.h b/ydb/core/viewer/json/json.h index 01e3b85e2d9..e9f90ef6a9f 100644 --- a/ydb/core/viewer/json/json.h +++ b/ydb/core/viewer/json/json.h @@ -2,11 +2,11 @@ #include <unordered_map> #include <unordered_set> #include <google/protobuf/message.h> -#include <util/stream/output.h> +#include <util/stream/output.h> struct TJsonSettings { using TMapperKey = const ::google::protobuf::FieldDescriptor*; - using TMapperValue = std::function<void(IOutputStream&, const ::google::protobuf::Message&, const TJsonSettings&)>; + using TMapperValue = std::function<void(IOutputStream&, const ::google::protobuf::Message&, const TJsonSettings&)>; using TNameGenerator = std::function<TString(const google::protobuf::FieldDescriptor&)>; bool UI64AsString = true; // JavaScript could not handle large numbers (bigger than 2^53) bool EnumAsNumbers = true; diff --git a/ydb/core/viewer/json_storage.h b/ydb/core/viewer/json_storage.h index 76e5d2f5e8b..30b2e3543e6 100644 --- a/ydb/core/viewer/json_storage.h +++ b/ydb/core/viewer/json_storage.h @@ -332,7 +332,7 @@ public: } } - void RemapVDisks(IOutputStream& json, + void RemapVDisks(IOutputStream& json, const ::google::protobuf::Message& protoFrom, const TJsonSettings& jsonSettings) { NKikimrWhiteboard::EFlag diskSpace = NKikimrWhiteboard::Grey; @@ -367,7 +367,7 @@ public: } } - void RemapPDisk(IOutputStream& json, + void RemapPDisk(IOutputStream& json, const ::google::protobuf::Message& protoFrom, const TJsonSettings& jsonSettings) { json << "\"PDisk\":"; diff --git a/ydb/core/viewer/viewer.cpp b/ydb/core/viewer/viewer.cpp index f1124115bf7..47140e506eb 100644 --- a/ydb/core/viewer/viewer.cpp +++ b/ydb/core/viewer/viewer.cpp @@ -259,7 +259,7 @@ private: if (basepath.empty()) { basepath = "/viewer"; } else { - if (basepath.EndsWith("/api/")) { + if (basepath.EndsWith("/api/")) { basepath = basepath.substr(0, basepath.size() - 5); } } diff --git a/ydb/core/viewer/wb_filter.h b/ydb/core/viewer/wb_filter.h index 99c279b4fa1..1f55fb16524 100644 --- a/ydb/core/viewer/wb_filter.h +++ b/ydb/core/viewer/wb_filter.h @@ -273,7 +273,7 @@ public: const Descriptor& descriptor = *TElementType::descriptor(); TVector<TString> requestedFilters; TVector<THolder<IFieldProtoFilter>> foundFilters; - if (filters.StartsWith('(') && filters.EndsWith(')')) { + if (filters.StartsWith('(') && filters.EndsWith(')')) { filters = filters.substr(1, filters.size() - 2); } StringSplitter(filters).Split(';').SkipEmpty().Collect(&requestedFilters); diff --git a/ydb/core/ydb_convert/ydb_convert_ut.cpp b/ydb/core/ydb_convert/ydb_convert_ut.cpp index cb802069264..4fbead7a3e4 100644 --- a/ydb/core/ydb_convert/ydb_convert_ut.cpp +++ b/ydb/core/ydb_convert/ydb_convert_ut.cpp @@ -51,8 +51,8 @@ static void TestConvertValueFromYdb(const TString& inputType, const TString& inp UNIT_ASSERT_NO_DIFF(result, expected); } -Y_UNIT_TEST_SUITE(ConvertMiniKQLTypeToYdbTypeTest) { - Y_UNIT_TEST(SimpleType) { +Y_UNIT_TEST_SUITE(ConvertMiniKQLTypeToYdbTypeTest) { + Y_UNIT_TEST(SimpleType) { const TString input = "Kind: Data\n" "Data {\n" @@ -214,14 +214,14 @@ Variant { } - Y_UNIT_TEST(Void) { + Y_UNIT_TEST(Void) { const TString input = "Kind: Void\n"; const TString expected = "void_type: NULL_VALUE\n"; TestConvertTypeToYdb(input, expected); TestConvertTypeFromYdb(expected, input); } - Y_UNIT_TEST(Optional) { + Y_UNIT_TEST(Optional) { const TString input = "Kind: Optional\n" "Optional {\n" @@ -242,7 +242,7 @@ Variant { TestConvertTypeFromYdb(expected, input); } - Y_UNIT_TEST(List) { + Y_UNIT_TEST(List) { const TString input = "Kind: List\n" "List {\n" @@ -262,7 +262,7 @@ Variant { TestConvertTypeFromYdb(expected, input); } - Y_UNIT_TEST(Tuple) { + Y_UNIT_TEST(Tuple) { const TString input = "Kind: Tuple\n" "Tuple {\n" @@ -292,7 +292,7 @@ Variant { TestConvertTypeFromYdb(expected, input); } - Y_UNIT_TEST(Struct) { + Y_UNIT_TEST(Struct) { const TString input = "Kind: Struct\n" "Struct {\n" @@ -334,7 +334,7 @@ Variant { TestConvertTypeFromYdb(expected, input); } - Y_UNIT_TEST(Dict) { + Y_UNIT_TEST(Dict) { const TString input = "Kind: Dict\n" "Dict {\n" @@ -365,12 +365,12 @@ Variant { } } -Y_UNIT_TEST_SUITE(ConvertMiniKQLValueToYdbValueTest) { - Y_UNIT_TEST(Void) { +Y_UNIT_TEST_SUITE(ConvertMiniKQLValueToYdbValueTest) { + Y_UNIT_TEST(Void) { TestConvertValueToYdb("Kind: Void\n", "", ""); } - Y_UNIT_TEST(SimpleBool) { + Y_UNIT_TEST(SimpleBool) { const TString inputType = "Kind: Data\n" "Data {\n" @@ -379,7 +379,7 @@ Y_UNIT_TEST_SUITE(ConvertMiniKQLValueToYdbValueTest) { TestConvertValueToYdb(inputType, "Bool: true\n", "bool_value: true\n"); } - Y_UNIT_TEST(SimpleInt32) { + Y_UNIT_TEST(SimpleInt32) { const TString inputType = "Kind: Data\n" "Data {\n" @@ -388,7 +388,7 @@ Y_UNIT_TEST_SUITE(ConvertMiniKQLValueToYdbValueTest) { TestConvertValueToYdb(inputType, "Int32: -42\n", "int32_value: -42\n"); } - Y_UNIT_TEST(SimpleInt64) { + Y_UNIT_TEST(SimpleInt64) { const TString inputType = "Kind: Data\n" "Data {\n" @@ -451,7 +451,7 @@ Hi128: 2 TestConvertValueToYdb(inputType, uuidStr, "low_128: 1\nhigh_128: 2\n"); } - Y_UNIT_TEST(OptionalString) { + Y_UNIT_TEST(OptionalString) { const TString inputType = "Kind: Optional\n" "Optional {\n" @@ -469,7 +469,7 @@ Hi128: 2 TestConvertValueToYdb(inputType, inputValue, "bytes_value: \"abc\"\n"); } - Y_UNIT_TEST(OptionalEmpty) { + Y_UNIT_TEST(OptionalEmpty) { const TString inputType = "Kind: Optional\n" "Optional {\n" @@ -484,7 +484,7 @@ Hi128: 2 TestConvertValueToYdb(inputType, inputValue, "null_flag_value: NULL_VALUE\n"); } - Y_UNIT_TEST(OptionalOptionalEmpty) { + Y_UNIT_TEST(OptionalOptionalEmpty) { const TString inputType = "Kind: Optional\n" "Optional {\n" @@ -509,7 +509,7 @@ Hi128: 2 "}\n"); } - Y_UNIT_TEST(OptionalOptionalEmpty2) { + Y_UNIT_TEST(OptionalOptionalEmpty2) { const TString inputType = "Kind: Optional\n" "Optional {\n" @@ -530,7 +530,7 @@ Hi128: 2 "null_flag_value: NULL_VALUE\n"); } - Y_UNIT_TEST(List) { + Y_UNIT_TEST(List) { const TString inputType = "Kind: List\n" "List {\n" @@ -557,7 +557,7 @@ Hi128: 2 "}\n"); } - Y_UNIT_TEST(Struct) { + Y_UNIT_TEST(Struct) { const TString inputType = "Kind: Struct\n" "Struct {\n" @@ -596,7 +596,7 @@ Hi128: 2 "}\n"); } - Y_UNIT_TEST(Dict) { + Y_UNIT_TEST(Dict) { const TString inputType = "Kind: Dict\n" "Dict {\n" @@ -633,7 +633,7 @@ Hi128: 2 "}\n"); } - Y_UNIT_TEST(Tuple) { + Y_UNIT_TEST(Tuple) { const TString inputType = "Kind: Tuple\n" "Tuple {\n" @@ -705,12 +705,12 @@ variant_index: 1 } -Y_UNIT_TEST_SUITE(ConvertYdbValueToMiniKQLValueTest) { - Y_UNIT_TEST(Void) { +Y_UNIT_TEST_SUITE(ConvertYdbValueToMiniKQLValueTest) { + Y_UNIT_TEST(Void) { TestConvertValueFromYdb("void_type: NULL_VALUE\n", "", ""); } - Y_UNIT_TEST(SimpleBool) { + Y_UNIT_TEST(SimpleBool) { const TString inputType = "type_id: BOOL\n"; TestConvertValueFromYdb(inputType, "bool_value: true\n", "Bool: true\n"); @@ -722,7 +722,7 @@ Y_UNIT_TEST_SUITE(ConvertYdbValueToMiniKQLValueTest) { UNIT_ASSERT_EXCEPTION(TestConvertValueFromYdb(inputType, "int32_value: -42\n", "Bool: true\n"), yexception); } - Y_UNIT_TEST(SimpleInt32) { + Y_UNIT_TEST(SimpleInt32) { const TString inputType = "type_id: INT32\n"; TestConvertValueFromYdb(inputType, "int32_value: -42\n", "Int32: -42\n"); @@ -789,7 +789,7 @@ Hi128: 2 UNIT_ASSERT_EXCEPTION(TestConvertValueFromYdb(inputType, "bytes_value: \"abc\"\n", "Low128: 123\nHi128: 456\n"), yexception); } - Y_UNIT_TEST(OptionalString) { + Y_UNIT_TEST(OptionalString) { const TString inputType = "optional_type {\n" " item {\n" @@ -803,7 +803,7 @@ Hi128: 2 "}\n"); } - Y_UNIT_TEST(OptionalEmpty) { + Y_UNIT_TEST(OptionalEmpty) { const TString inputType = "optional_type {\n" " item {\n" @@ -814,7 +814,7 @@ Hi128: 2 TestConvertValueFromYdb(inputType, inputValue, ""); } - Y_UNIT_TEST(OptionalOptionalEmpty) { + Y_UNIT_TEST(OptionalOptionalEmpty) { const TString inputType = "optional_type {\n" " item {\n" @@ -834,7 +834,7 @@ Hi128: 2 "}\n"); } - Y_UNIT_TEST(OptionalOptionalEmpty2) { + Y_UNIT_TEST(OptionalOptionalEmpty2) { const TString inputType = "optional_type {\n" " item {\n" @@ -849,7 +849,7 @@ Hi128: 2 TestConvertValueFromYdb(inputType, inputValue, ""); } - Y_UNIT_TEST(List) { + Y_UNIT_TEST(List) { const TString inputType = "list_type {\n" " item {\n" @@ -872,7 +872,7 @@ Hi128: 2 "}\n"); } - Y_UNIT_TEST(Struct) { + Y_UNIT_TEST(Struct) { const TString inputType = "struct_type {\n" " members {\n" @@ -904,7 +904,7 @@ Hi128: 2 "}\n"); } - Y_UNIT_TEST(Dict) { + Y_UNIT_TEST(Dict) { const TString inputType = "dict_type {\n" " key {\n" @@ -936,7 +936,7 @@ Hi128: 2 } - Y_UNIT_TEST(Tuple) { + Y_UNIT_TEST(Tuple) { const TString inputType = "tuple_type {\n" " elements {\n" diff --git a/ydb/core/ymq/actor/ut/attributes_md5_ut.cpp b/ydb/core/ymq/actor/ut/attributes_md5_ut.cpp index a6b00f7030d..ea9fb2533eb 100644 --- a/ydb/core/ymq/actor/ut/attributes_md5_ut.cpp +++ b/ydb/core/ymq/actor/ut/attributes_md5_ut.cpp @@ -18,15 +18,15 @@ void AddBinaryAttr(google::protobuf::RepeatedPtrField<TMessageAttribute>& attrs, a->SetDataType("Binary"); } -Y_UNIT_TEST_SUITE(AttributesMD5Test) { - Y_UNIT_TEST(AmazonSampleWithString) { +Y_UNIT_TEST_SUITE(AttributesMD5Test) { + Y_UNIT_TEST(AmazonSampleWithString) { google::protobuf::RepeatedPtrField<TMessageAttribute> attrs; AddStringAttr(attrs, "test_attribute_name_2", "test_attribute_value_2"); AddStringAttr(attrs, "test_attribute_name_1", "test_attribute_value_1"); UNIT_ASSERT_STRINGS_EQUAL(CalcMD5OfMessageAttributes(attrs), "d53f3b558fe951154770f25cb63dbba9"); } - Y_UNIT_TEST(AmazonSampleWithBinary) { + Y_UNIT_TEST(AmazonSampleWithBinary) { google::protobuf::RepeatedPtrField<TMessageAttribute> attrs; AddBinaryAttr(attrs, "test_attribute_name", "test_attribute_value"); UNIT_ASSERT_STRINGS_EQUAL(CalcMD5OfMessageAttributes(attrs), "23f6bd27ea87aab7dfeadcc9aebee495"); diff --git a/ydb/core/ymq/ut/params_ut.cpp b/ydb/core/ymq/ut/params_ut.cpp index 8cc3aae9efe..f2acb1601d0 100644 --- a/ydb/core/ymq/ut/params_ut.cpp +++ b/ydb/core/ymq/ut/params_ut.cpp @@ -4,8 +4,8 @@ using namespace NKikimr::NSQS; -Y_UNIT_TEST_SUITE(TParseParamsTests) { - Y_UNIT_TEST(CreateUser) { +Y_UNIT_TEST_SUITE(TParseParamsTests) { + Y_UNIT_TEST(CreateUser) { TParameters params; TParametersParser parser(¶ms); parser.Append("Action", "CreateUser"); @@ -20,7 +20,7 @@ Y_UNIT_TEST_SUITE(TParseParamsTests) { UNIT_ASSERT_EQUAL(params.Attributes[1].GetValue(), "1"); } - Y_UNIT_TEST(ChangeMessageVisibilityBatchRequest) { + Y_UNIT_TEST(ChangeMessageVisibilityBatchRequest) { TParameters params; TParametersParser parser(¶ms); parser.Append("ChangeMessageVisibilityBatchRequestEntry.2.ReceiptHandle", "batch message 2"); @@ -39,7 +39,7 @@ Y_UNIT_TEST_SUITE(TParseParamsTests) { UNIT_ASSERT_EQUAL(params.BatchEntries[2].Id, "Y"); } - Y_UNIT_TEST(DeleteMessageBatchRequest) { + Y_UNIT_TEST(DeleteMessageBatchRequest) { TParameters params; TParametersParser parser(¶ms); parser.Append("DeleteMessageBatchRequestEntry.2.ReceiptHandle", "batch message 2"); @@ -54,7 +54,7 @@ Y_UNIT_TEST_SUITE(TParseParamsTests) { UNIT_ASSERT_EQUAL(params.BatchEntries[2].Id, "Y"); } - Y_UNIT_TEST(MessageBody) { + Y_UNIT_TEST(MessageBody) { TParameters params; TParametersParser parser(¶ms); parser.Append("Action", "SendMessage"); @@ -83,7 +83,7 @@ Y_UNIT_TEST_SUITE(TParseParamsTests) { UNIT_ASSERT_STRINGS_EQUAL(params.MessageAttributes[5].GetDataType(), "Binary"); } - Y_UNIT_TEST(SendMessageBatchRequest) { + Y_UNIT_TEST(SendMessageBatchRequest) { TParameters params; TParametersParser parser(¶ms); parser.Append("SendMessageBatchRequestEntry.2.MessageBody", "batch message 2"); @@ -140,7 +140,7 @@ Y_UNIT_TEST_SUITE(TParseParamsTests) { UNIT_ASSERT_STRINGS_EQUAL(*params.BatchEntries[2].QueueUrl, "url"); } - Y_UNIT_TEST(UnnumberedAttribute) { + Y_UNIT_TEST(UnnumberedAttribute) { TParameters params; TParametersParser parser(¶ms); parser.Append("Attribute.Name", "DelaySeconds"); @@ -151,7 +151,7 @@ Y_UNIT_TEST_SUITE(TParseParamsTests) { UNIT_ASSERT_EQUAL(params.Attributes[1].GetValue(), "1"); } - Y_UNIT_TEST(UnnumberedAttributeName) { + Y_UNIT_TEST(UnnumberedAttributeName) { TParameters params; TParametersParser parser(¶ms); parser.Append("AttributeName", "All"); diff --git a/ydb/library/aclib/aclib_ut.cpp b/ydb/library/aclib/aclib_ut.cpp index c5828f86244..491512fdcf9 100644 --- a/ydb/library/aclib/aclib_ut.cpp +++ b/ydb/library/aclib/aclib_ut.cpp @@ -4,7 +4,7 @@ using namespace NACLib; -Y_UNIT_TEST_SUITE(ACLib) { +Y_UNIT_TEST_SUITE(ACLib) { static const TString James = "james@bookstore"; static const TVector<TString> JamesGroups = {"Humans", "Administrators"}; static const TString Cat = "cat@bookstore"; @@ -12,7 +12,7 @@ Y_UNIT_TEST_SUITE(ACLib) { static const TString Dog = "dog@bookstore"; static const TVector<TString> DogGroups = {"Animals", "Dogs", "Writers"}; - Y_UNIT_TEST(TestUsers) { + Y_UNIT_TEST(TestUsers) { TSecurityObject rootACL(James, true); rootACL.AddAccess(EAccessType::Allow, EAccessRights::GenericRead, Cat, EInheritanceType::InheritContainer); @@ -66,7 +66,7 @@ Y_UNIT_TEST_SUITE(ACLib) { UNIT_ASSERT(effectiveCatFileACL.CheckAccess(EAccessRights::UpdateRow, dogToken) == false); } - Y_UNIT_TEST(TestGroups) { + Y_UNIT_TEST(TestGroups) { TSecurityObject rootACL(James, true); rootACL.AddAccess(EAccessType::Allow, EAccessRights::GenericRead, "Readers", EInheritanceType::InheritContainer | EInheritanceType::InheritObject); diff --git a/ydb/library/schlab/ut/schlab_ut.cpp b/ydb/library/schlab/ut/schlab_ut.cpp index 6ca075471a8..993bd2d4ba4 100644 --- a/ydb/library/schlab/ut/schlab_ut.cpp +++ b/ydb/library/schlab/ut/schlab_ut.cpp @@ -3,8 +3,8 @@ #include <library/cpp/testing/unittest/registar.h> -Y_UNIT_TEST_SUITE(SchLab) { - Y_UNIT_TEST(TestSchootGenCfgSet1) { +Y_UNIT_TEST_SUITE(SchLab) { + Y_UNIT_TEST(TestSchootGenCfgSet1) { TString json = R"__EOF__({ "cfg":[{ "label": "mygen1", @@ -30,14 +30,14 @@ Y_UNIT_TEST_SUITE(SchLab) { UNIT_ASSERT_C(cfg.IsValid, "ErrorDetails# " << cfg.ErrorDetails); } - Y_UNIT_TEST(TestSchootGenCfgSet2) { + Y_UNIT_TEST(TestSchootGenCfgSet2) { TString json = R"__EOF__({"cfg":[{"label":"gen0","startTime":0,"period":100,"periodCount":1, "reqSizeBytes":1024,"reqCount":1,"reqInterval":10,"user":"vdisk0","desc":"write"}]})__EOF__"; NKikimr::NSchLab::TSchOotGenCfgSet cfg(json); UNIT_ASSERT_C(cfg.IsValid, "ErrorDetails# " << cfg.ErrorDetails); } - Y_UNIT_TEST(TestSchootGenCfgSetInvalid1) { + Y_UNIT_TEST(TestSchootGenCfgSetInvalid1) { TString json = R"__EOF__({ "cfg":[{ "label": "mygen1i", @@ -53,7 +53,7 @@ Y_UNIT_TEST_SUITE(SchLab) { UNIT_ASSERT(!cfg.IsValid); } - Y_UNIT_TEST(TestSchootGenCfgSetInvalid2) { + Y_UNIT_TEST(TestSchootGenCfgSetInvalid2) { TString json = R"__EOF__({ "cfg":[{ "label": "mygen2i", @@ -70,7 +70,7 @@ Y_UNIT_TEST_SUITE(SchLab) { UNIT_ASSERT(!cfg.IsValid); } - Y_UNIT_TEST(TestSchootGen1) { + Y_UNIT_TEST(TestSchootGen1) { TString json = R"__EOF__({ "cfg":[{ "label": "mygen1", diff --git a/ydb/library/wilson/ya.make b/ydb/library/wilson/ya.make index e4daf898c7e..0926b942a6a 100644 --- a/ydb/library/wilson/ya.make +++ b/ydb/library/wilson/ya.make @@ -1,5 +1,5 @@ LIBRARY() - PEERDIR( + PEERDIR( library/cpp/actors/wilson ) diff --git a/ydb/library/yql/ast/yql_ast.cpp b/ydb/library/yql/ast/yql_ast.cpp index 16e521d9010..03e4f7bc6ea 100644 --- a/ydb/library/yql/ast/yql_ast.cpp +++ b/ydb/library/yql/ast/yql_ast.cpp @@ -435,13 +435,13 @@ namespace { && node.GetChild(0)->GetContent() == TStringBuf("block"); } - Y_NO_INLINE void Indent(IOutputStream& out, ui32 indentation) { + Y_NO_INLINE void Indent(IOutputStream& out, ui32 indentation) { char* whitespaces = reinterpret_cast<char*>(alloca(indentation)); memset(whitespaces, ' ', indentation); out.Write(whitespaces, indentation); } - void MultilineAtomPrint(IOutputStream& out, const TStringBuf& str) { + void MultilineAtomPrint(IOutputStream& out, const TStringBuf& str) { out << TStringBuf("@@"); size_t idx = str.find('@'); if (idx == TString::npos) { @@ -469,7 +469,7 @@ namespace { out << TStringBuf("@@"); } - void PrintNode(IOutputStream& out, const TAstNode& node) { + void PrintNode(IOutputStream& out, const TAstNode& node) { if (node.GetType() == TAstNode::Atom) { if (node.GetFlags() & TNodeFlags::ArbitraryContent) { EscapeArbitraryAtom(node.GetContent(), '"', &out); @@ -503,7 +503,7 @@ namespace { } void PrettyPrintNode( - IOutputStream& out, const TAstNode& node, + IOutputStream& out, const TAstNode& node, i32 indent, i32 blockLevel, i32 localIndent, ui32 flags) { if (!(flags & TAstPrintFlags::PerLine)) { @@ -633,11 +633,11 @@ TAstParseResult ParseAst(const TStringBuf& str, TMemoryPool* externalPool, const return parser.Parse(); } -void TAstNode::PrintTo(IOutputStream& out) const { +void TAstNode::PrintTo(IOutputStream& out) const { PrintNode(out, *this); } -void TAstNode::PrettyPrintTo(IOutputStream& out, ui32 flags) const { +void TAstNode::PrettyPrintTo(IOutputStream& out, ui32 flags) const { PrettyPrintNode(out, *this, 0, 0, 0, flags); } @@ -646,7 +646,7 @@ TAstNode TAstNode::QuoteAtom(TPosition(0, 0), TStringBuf("quote"), TNodeFlags::D } // namespace NYql template<> -void Out<NYql::TAstNode::EType>(class IOutputStream &o, NYql::TAstNode::EType x) { +void Out<NYql::TAstNode::EType>(class IOutputStream &o, NYql::TAstNode::EType x) { #define YQL_AST_NODE_TYPE_MAP_TO_STRING_IMPL(name, ...) \ case ::NYql::TAstNode::name: \ o << #name; \ diff --git a/ydb/library/yql/ast/yql_ast.h b/ydb/library/yql/ast/yql_ast.h index 887b53dbc5d..b956871afe6 100644 --- a/ydb/library/yql/ast/yql_ast.h +++ b/ydb/library/yql/ast/yql_ast.h @@ -36,8 +36,8 @@ struct TAstNode { static const ui32 SmallListCount = 2; - void PrintTo(IOutputStream& out) const; - void PrettyPrintTo(IOutputStream& out, ui32 prettyFlags) const; + void PrintTo(IOutputStream& out) const; + void PrettyPrintTo(IOutputStream& out, ui32 prettyFlags) const; inline TString ToString() const { TStringStream str; @@ -268,4 +268,4 @@ TAstParseResult ParseAst(const TStringBuf& str, TMemoryPool* externalPool = null } // namespace NYql template<> -void Out<NYql::TAstNode::EType>(class IOutputStream &o, NYql::TAstNode::EType x); +void Out<NYql::TAstNode::EType>(class IOutputStream &o, NYql::TAstNode::EType x); diff --git a/ydb/library/yql/ast/yql_ast_escaping.cpp b/ydb/library/yql/ast/yql_ast_escaping.cpp index 56aee8f5964..6c0ca4e3c4d 100644 --- a/ydb/library/yql/ast/yql_ast_escaping.cpp +++ b/ydb/library/yql/ast/yql_ast_escaping.cpp @@ -12,7 +12,7 @@ static char HexDigit(char c) return (c < 10 ? '0' + c : 'A' + (c - 10)); } -static void EscapedPrintChar(ui8 c, IOutputStream* out) +static void EscapedPrintChar(ui8 c, IOutputStream* out) { switch (c) { case '\\': out->Write("\\\\", 2); break; @@ -36,7 +36,7 @@ static void EscapedPrintChar(ui8 c, IOutputStream* out) } } -static void EscapedPrintUnicode(wchar32 rune, IOutputStream* out) +static void EscapedPrintUnicode(wchar32 rune, IOutputStream* out) { static const int MAX_ESCAPE_LEN = 10; @@ -132,7 +132,7 @@ TStringBuf UnescapeResultToString(EUnescapeResult result) return "Unknown unescape error"; } -void EscapeArbitraryAtom(TStringBuf atom, char quoteChar, IOutputStream* out) +void EscapeArbitraryAtom(TStringBuf atom, char quoteChar, IOutputStream* out) { out->Write(quoteChar); const ui8 *p = reinterpret_cast<const ui8*>(atom.begin()), @@ -152,7 +152,7 @@ void EscapeArbitraryAtom(TStringBuf atom, char quoteChar, IOutputStream* out) } EUnescapeResult UnescapeArbitraryAtom( - TStringBuf atom, char endChar, IOutputStream* out, size_t* readBytes) + TStringBuf atom, char endChar, IOutputStream* out, size_t* readBytes) { const char *p = atom.begin(), *e = atom.end(); @@ -238,7 +238,7 @@ EUnescapeResult UnescapeArbitraryAtom( return EUnescapeResult::INVALID_END; } -void EscapeBinaryAtom(TStringBuf atom, char quoteChar, IOutputStream* out) +void EscapeBinaryAtom(TStringBuf atom, char quoteChar, IOutputStream* out) { char prefix[] = { 'x', quoteChar }; out->Write(prefix, 2); @@ -247,7 +247,7 @@ void EscapeBinaryAtom(TStringBuf atom, char quoteChar, IOutputStream* out) } EUnescapeResult UnescapeBinaryAtom( - TStringBuf atom, char endChar, IOutputStream* out, size_t* readBytes) + TStringBuf atom, char endChar, IOutputStream* out, size_t* readBytes) { const char *p = atom.begin(), *e = atom.end(); diff --git a/ydb/library/yql/ast/yql_ast_escaping.h b/ydb/library/yql/ast/yql_ast_escaping.h index 744ab985161..f241ae147e4 100644 --- a/ydb/library/yql/ast/yql_ast_escaping.h +++ b/ydb/library/yql/ast/yql_ast_escaping.h @@ -5,7 +5,7 @@ #include <util/generic/strbuf.h> -class IOutputStream; +class IOutputStream; namespace NYql { @@ -22,14 +22,14 @@ enum class EUnescapeResult TStringBuf UnescapeResultToString(EUnescapeResult result); -void EscapeArbitraryAtom(TStringBuf atom, char quoteChar, IOutputStream* out); +void EscapeArbitraryAtom(TStringBuf atom, char quoteChar, IOutputStream* out); EUnescapeResult UnescapeArbitraryAtom( - TStringBuf atom, char endChar, IOutputStream* out, size_t* readBytes); + TStringBuf atom, char endChar, IOutputStream* out, size_t* readBytes); -void EscapeBinaryAtom(TStringBuf atom, char quoteChar, IOutputStream* out); +void EscapeBinaryAtom(TStringBuf atom, char quoteChar, IOutputStream* out); EUnescapeResult UnescapeBinaryAtom( - TStringBuf atom, char endChar, IOutputStream* out, size_t* readBytes); + TStringBuf atom, char endChar, IOutputStream* out, size_t* readBytes); } // namspace NYql diff --git a/ydb/library/yql/ast/yql_ast_ut.cpp b/ydb/library/yql/ast/yql_ast_ut.cpp index 23e140653d7..d05458bcae5 100644 --- a/ydb/library/yql/ast/yql_ast_ut.cpp +++ b/ydb/library/yql/ast/yql_ast_ut.cpp @@ -8,7 +8,7 @@ namespace NYql { -Y_UNIT_TEST_SUITE(TParseYqlAst) { +Y_UNIT_TEST_SUITE(TParseYqlAst) { constexpr TStringBuf TEST_PROGRAM = "(\n" "#comment\n" @@ -24,14 +24,14 @@ Y_UNIT_TEST_SUITE(TParseYqlAst) { "(return world)\n" ")"; - Y_UNIT_TEST(ParseAstTest) { + Y_UNIT_TEST(ParseAstTest) { TAstParseResult res = ParseAst(TEST_PROGRAM); UNIT_ASSERT(res.IsOk()); UNIT_ASSERT(res.Root->IsList()); UNIT_ASSERT(res.Issues.Empty()); } - Y_UNIT_TEST(ParseAstTestPerf) { + Y_UNIT_TEST(ParseAstTestPerf) { #ifdef WITH_VALGRIND const ui32 n = 1000; #else @@ -48,7 +48,7 @@ Y_UNIT_TEST_SUITE(TParseYqlAst) { Cout << t2 - t1 << Endl; } - Y_UNIT_TEST(PrintAstTest) { + Y_UNIT_TEST(PrintAstTest) { TAstParseResult ast = ParseAst(TEST_PROGRAM); UNIT_ASSERT(ast.IsOk()); @@ -59,7 +59,7 @@ Y_UNIT_TEST_SUITE(TParseYqlAst) { UNIT_ASSERT(parsedAst.IsOk()); } - Y_UNIT_TEST(PrettyPrintAst) { + Y_UNIT_TEST(PrettyPrintAst) { const ui32 testFlags[] = { TAstPrintFlags::Default, TAstPrintFlags::PerLine, @@ -70,7 +70,7 @@ Y_UNIT_TEST_SUITE(TParseYqlAst) { TAstParseResult ast = ParseAst(TEST_PROGRAM); UNIT_ASSERT(ast.IsOk()); - for (ui32 i = 0; i < Y_ARRAY_SIZE(testFlags); ++i) { + for (ui32 i = 0; i < Y_ARRAY_SIZE(testFlags); ++i) { ui32 prettyFlags = testFlags[i]; TString printedProgram1 = ast.Root->ToString(prettyFlags); @@ -82,7 +82,7 @@ Y_UNIT_TEST_SUITE(TParseYqlAst) { } } - Y_UNIT_TEST(AnnotatedAstPrint) { + Y_UNIT_TEST(AnnotatedAstPrint) { TMemoryPool pool(4096); TAstParseResult ast = ParseAst(TEST_PROGRAM, &pool); UNIT_ASSERT(ast.IsOk()); @@ -134,7 +134,7 @@ Y_UNIT_TEST_SUITE(TParseYqlAst) { program); } - Y_UNIT_TEST(GoodArbitraryAtom) { + Y_UNIT_TEST(GoodArbitraryAtom) { TestGoodArbitraryAtom("(\"\")", TStringBuf()); TestGoodArbitraryAtom("(\" 1 a 3 b \")", TStringBuf(" 1 a 3 b ")); @@ -188,7 +188,7 @@ Y_UNIT_TEST_SUITE(TParseYqlAst) { UNIT_ASSERT_STRINGS_EQUAL(ast.Issues.begin()->Message, expectedError); } - Y_UNIT_TEST(BadArbitraryAtom) { + Y_UNIT_TEST(BadArbitraryAtom) { TestBadArbitraryAtom("(a\")", "Unexpected \""); TestBadArbitraryAtom("(\"++++\"11111)", "Unexpected end of \""); TestBadArbitraryAtom("(\"\\", "Expected escape sequence"); @@ -238,7 +238,7 @@ Y_UNIT_TEST_SUITE(TParseYqlAst) { UNIT_ASSERT_STRINGS_EQUAL_C(result, expected, program); } - Y_UNIT_TEST(ArbitraryAtomEscaping) { + Y_UNIT_TEST(ArbitraryAtomEscaping) { ParseAndPrint( "(\"\\t\\n\\r\\b\\a\\f\\v\")", "(\"\\t\\n\\r\\b\\a\\f\\v\")"); @@ -256,7 +256,7 @@ Y_UNIT_TEST_SUITE(TParseYqlAst) { ParseAndPrint("(\"\")", "(\"\")"); } - Y_UNIT_TEST(BinaryAtom) { + Y_UNIT_TEST(BinaryAtom) { ParseAndPrint("(x\"abcdef\")", "(x\"ABCDEF\")"); ParseAndPrint("(x\"aBcDeF\")", "(x\"ABCDEF\")"); ParseAndPrint("(x)", "(x)"); @@ -277,7 +277,7 @@ Y_UNIT_TEST_SUITE(TParseYqlAst) { UNIT_ASSERT_STRINGS_EQUAL_C(result, expected, program); } - Y_UNIT_TEST(AdaptArbitraryAtom) { + Y_UNIT_TEST(AdaptArbitraryAtom) { ParseAndAdaptPrint("(\"test\")", "(test)"); ParseAndAdaptPrint("(\"another test\")", "(\"another test\")"); ParseAndAdaptPrint("(\"braces(in)test\")", "(\"braces(in)test\")"); @@ -291,7 +291,7 @@ Y_UNIT_TEST_SUITE(TParseYqlAst) { UNIT_ASSERT_C(!ast.IsOk(), program); } - Y_UNIT_TEST(MultilineAtomTrivial) { + Y_UNIT_TEST(MultilineAtomTrivial) { TStringStream s; for (ui32 i = 4; i < 13; ++i) { TStringStream prog; @@ -328,7 +328,7 @@ Y_UNIT_TEST_SUITE(TParseYqlAst) { ); } - Y_UNIT_TEST(MultilineAtom) { + Y_UNIT_TEST(MultilineAtom) { TString s1 = "(@@multi \n" "line \n" "string@@)"; @@ -377,7 +377,7 @@ Y_UNIT_TEST_SUITE(TParseYqlAst) { UNIT_ASSERT_STRINGS_EQUAL(s5, printResult); } - Y_UNIT_TEST(UnicodePrettyPrint) { + Y_UNIT_TEST(UnicodePrettyPrint) { ParseAndAdaptPrint("(\"абв αβγ ﬡ\")", "(\"\\u0430\\u0431\\u0432 \\u03B1\\u03B2\\u03B3 \\uFB21\")"); } diff --git a/ydb/library/yql/ast/yql_expr.cpp b/ydb/library/yql/ast/yql_expr.cpp index 82f6c5812ac..b044046d053 100644 --- a/ydb/library/yql/ast/yql_expr.cpp +++ b/ydb/library/yql/ast/yql_expr.cpp @@ -40,7 +40,7 @@ namespace { return static_cast<const T*>(*ins.first); } - void DumpNode(const TExprNode& node, IOutputStream& out, ui32 level, TNodeSet& visited) { + void DumpNode(const TExprNode& node, IOutputStream& out, ui32 level, TNodeSet& visited) { for (ui32 i = 0; i < level; ++i) { out.Write(' '); } @@ -3199,7 +3199,7 @@ void CheckCounts(const TExprNode& root) { } // namespace NYql template<> -void Out<NYql::TExprNode::EType>(class IOutputStream &o, NYql::TExprNode::EType x) { +void Out<NYql::TExprNode::EType>(class IOutputStream &o, NYql::TExprNode::EType x) { #define YQL_EXPR_NODE_TYPE_MAP_TO_STRING_IMPL(name, ...) \ case NYql::TExprNode::name: \ o << #name; \ @@ -3214,7 +3214,7 @@ void Out<NYql::TExprNode::EType>(class IOutputStream &o, NYql::TExprNode::EType } template<> -void Out<NYql::TExprNode::EState>(class IOutputStream &o, NYql::TExprNode::EState x) { +void Out<NYql::TExprNode::EState>(class IOutputStream &o, NYql::TExprNode::EState x) { #define YQL_EXPR_NODE_STATE_MAP_TO_STRING_IMPL(name, ...) \ case NYql::TExprNode::EState::name: \ o << #name; \ diff --git a/ydb/library/yql/ast/yql_expr.h b/ydb/library/yql/ast/yql_expr.h index d6eb544f9af..47c43d6d1f2 100644 --- a/ydb/library/yql/ast/yql_expr.h +++ b/ydb/library/yql/ast/yql_expr.h @@ -237,7 +237,7 @@ public: bool Equals(const TTypeAnnotationNode& node) const; void Accept(TTypeAnnotationVisitor& visitor) const; - void Out(IOutputStream& out) const { + void Out(IOutputStream& out) const { out << FormatType(this); } @@ -287,7 +287,7 @@ public: } bool operator==(const TUnitExprType& other) const { - Y_UNUSED(other); + Y_UNUSED(other); return true; } }; @@ -710,7 +710,7 @@ public: } bool operator==(const TWorldExprType& other) const { - Y_UNUSED(other); + Y_UNUSED(other); return true; } }; @@ -862,7 +862,7 @@ public: } bool operator==(const TVoidExprType& other) const { - Y_UNUSED(other); + Y_UNUSED(other); return true; } }; @@ -1027,7 +1027,7 @@ public: } bool operator==(const TGenericExprType& other) const { - Y_UNUSED(other); + Y_UNUSED(other); return true; } }; @@ -2569,7 +2569,7 @@ TExprNode::TListType GetLambdaBody(const TExprNode& lambda); template<> inline void Out<NYql::TTypeAnnotationNode>( - IOutputStream &out, const NYql::TTypeAnnotationNode& type) + IOutputStream &out, const NYql::TTypeAnnotationNode& type) { type.Out(out); } diff --git a/ydb/library/yql/ast/yql_expr_builder.cpp b/ydb/library/yql/ast/yql_expr_builder.cpp index 4b22308b997..bbee5ebab96 100644 --- a/ydb/library/yql/ast/yql_expr_builder.cpp +++ b/ydb/library/yql/ast/yql_expr_builder.cpp @@ -46,8 +46,8 @@ TExprNodeBuilder::TExprNodeBuilder(TPositionHandle pos, TExprNodeReplaceBuilder* } TExprNode::TPtr TExprNodeBuilder::Build() { - Y_ENSURE(CurrentNode, "No current node"); - Y_ENSURE(!Parent, "Build is allowed only on top level"); + Y_ENSURE(CurrentNode, "No current node"); + Y_ENSURE(!Parent, "Build is allowed only on top level"); if (CurrentNode->Type() == TExprNode::Lambda) { Y_ENSURE(CurrentNode->ChildrenSize() > 0U, "Lambda is not complete"); } @@ -56,7 +56,7 @@ TExprNode::TPtr TExprNodeBuilder::Build() { } TExprNodeBuilder& TExprNodeBuilder::Seal() { - Y_ENSURE(Parent, "Seal is allowed only on non-top level"); + Y_ENSURE(Parent, "Seal is allowed only on non-top level"); if (Container->Type() == TExprNode::Lambda) { if (CurrentNode) { Y_ENSURE(Container->ChildrenSize() == 1, "Lambda is already complete."); @@ -70,8 +70,8 @@ TExprNodeBuilder& TExprNodeBuilder::Seal() { } TExprNodeReplaceBuilder& TExprNodeBuilder::Done() { - Y_ENSURE(ParentReplacer, "Done is allowed only if parent is a replacer"); - Y_ENSURE(CurrentNode, "No current node"); + Y_ENSURE(ParentReplacer, "Done is allowed only if parent is a replacer"); + Y_ENSURE(CurrentNode, "No current node"); for (auto& body : ParentReplacer->Body) body = Ctx.ReplaceNode(std::move(body), ParentReplacer->CurrentNode ? *ParentReplacer->CurrentNode : *ParentReplacer->Args->Child(ParentReplacer->CurrentIndex), CurrentNode); return *ParentReplacer; @@ -89,7 +89,7 @@ TExprNodeBuilder& TExprNodeBuilder::Atom(ui32 index, TPositionHandle pos, const TExprNodeBuilder& TExprNodeBuilder::Atom(TPositionHandle pos, const TStringBuf& content, ui32 flags) { Y_ENSURE(!Container || Container->IsLambda(), "No container expected"); - Y_ENSURE(!CurrentNode, "Node is already build"); + Y_ENSURE(!CurrentNode, "Node is already build"); CurrentNode = Ctx.NewAtom(pos, content, flags); return *this; } @@ -103,7 +103,7 @@ TExprNodeBuilder& TExprNodeBuilder::Atom(const TStringBuf& content, ui32 flags) } TExprNodeBuilder TExprNodeBuilder::List(ui32 index, TPositionHandle pos) { - Y_ENSURE(Container, "Container expected"); + Y_ENSURE(Container, "Container expected"); Y_ENSURE(Container->ChildrenSize() == index + (Container->IsLambda() ? 1U : 0U), "Container position mismatch, expected: " << Container->ChildrenSize() << ", actual: " << index); @@ -114,7 +114,7 @@ TExprNodeBuilder TExprNodeBuilder::List(ui32 index, TPositionHandle pos) { TExprNodeBuilder TExprNodeBuilder::List(TPositionHandle pos) { Y_ENSURE(!Container || Container->Type() == TExprNode::Lambda, "No container expected"); - Y_ENSURE(!CurrentNode, "Node is already build"); + Y_ENSURE(!CurrentNode, "Node is already build"); CurrentNode = Ctx.NewList(pos, {}); return TExprNodeBuilder(pos, this, CurrentNode); } @@ -156,7 +156,7 @@ TExprNodeBuilder& TExprNodeBuilder::Add(TExprNode::TListType&& children) { TExprNodeBuilder& TExprNodeBuilder::Set(TExprNode::TPtr&& body) { Y_ENSURE(Container && Container->Type() == TExprNode::Lambda, "Lambda expected"); - Y_ENSURE(!CurrentNode, "Lambda already has a body"); + Y_ENSURE(!CurrentNode, "Lambda already has a body"); CurrentNode = std::move(body); return *this; } @@ -169,7 +169,7 @@ TExprNodeBuilder& TExprNodeBuilder::Set(const TExprNode::TPtr& body) { } TExprNodeBuilder TExprNodeBuilder::Callable(ui32 index, TPositionHandle pos, const TStringBuf& content) { - Y_ENSURE(Container, "Container expected"); + Y_ENSURE(Container, "Container expected"); Y_ENSURE(Container->ChildrenSize() == index + (Container->IsLambda() ? 1U : 0U), "Container position mismatch, expected: " << Container->ChildrenSize() << ", actual: " << index); @@ -180,7 +180,7 @@ TExprNodeBuilder TExprNodeBuilder::Callable(ui32 index, TPositionHandle pos, con TExprNodeBuilder TExprNodeBuilder::Callable(TPositionHandle pos, const TStringBuf& content) { Y_ENSURE(!Container || Container->Type() == TExprNode::Lambda, "No container expected"); - Y_ENSURE(!CurrentNode, "Node is already build"); + Y_ENSURE(!CurrentNode, "Node is already build"); CurrentNode = Ctx.NewCallable(pos, content, {}); return TExprNodeBuilder(pos, this, CurrentNode); } @@ -194,7 +194,7 @@ TExprNodeBuilder TExprNodeBuilder::Callable(const TStringBuf& content) { } TExprNodeBuilder& TExprNodeBuilder::World(ui32 index, TPositionHandle pos) { - Y_ENSURE(Container, "Container expected"); + Y_ENSURE(Container, "Container expected"); Y_ENSURE(Container->ChildrenSize() == index + (Container->IsLambda() ? 1U : 0U), "Container position mismatch, expected: " << Container->ChildrenSize() << ", actual: " << index); @@ -204,8 +204,8 @@ TExprNodeBuilder& TExprNodeBuilder::World(ui32 index, TPositionHandle pos) { } TExprNodeBuilder& TExprNodeBuilder::World(TPositionHandle pos) { - Y_ENSURE(!Container, "No container expected"); - Y_ENSURE(!CurrentNode, "Node is already build"); + Y_ENSURE(!Container, "No container expected"); + Y_ENSURE(!CurrentNode, "Node is already build"); CurrentNode = Ctx.NewWorld(pos); return *this; } @@ -219,7 +219,7 @@ TExprNodeBuilder& TExprNodeBuilder::World() { } TExprNodeBuilder TExprNodeBuilder::Lambda(ui32 index, TPositionHandle pos) { - Y_ENSURE(Container, "Container expected"); + Y_ENSURE(Container, "Container expected"); Y_ENSURE(Container->ChildrenSize() == index + (Container->IsLambda() ? 1U : 0U), "Container position mismatch, expected: " << Container->ChildrenSize() << ", actual: " << index); @@ -230,7 +230,7 @@ TExprNodeBuilder TExprNodeBuilder::Lambda(ui32 index, TPositionHandle pos) { TExprNodeBuilder TExprNodeBuilder::Lambda(TPositionHandle pos) { Y_ENSURE(!Container || Container->Type() == TExprNode::Lambda, "No container expected"); - Y_ENSURE(!CurrentNode, "Node is already build"); + Y_ENSURE(!CurrentNode, "Node is already build"); CurrentNode = Ctx.NewLambda(pos, Ctx.NewArguments(pos, {}), nullptr); return TExprNodeBuilder(pos, this, CurrentNode); } @@ -245,9 +245,9 @@ TExprNodeBuilder TExprNodeBuilder::Lambda() { TExprNodeBuilder& TExprNodeBuilder::Param(TPositionHandle pos, const TStringBuf& name) { Y_ENSURE(!name.empty(), "Empty parameter name is not allowed"); - Y_ENSURE(Container, "Container expected"); + Y_ENSURE(Container, "Container expected"); Y_ENSURE(Container->Type() == TExprNode::Lambda, "Container must be a lambda"); - Y_ENSURE(!CurrentNode, "Lambda already has a body"); + Y_ENSURE(!CurrentNode, "Lambda already has a body"); for (auto arg : Container->Head().Children()) { Y_ENSURE(arg->Content() != name, "Duplicate of lambda param name: " << name); } @@ -269,7 +269,7 @@ TExprNodeBuilder& TExprNodeBuilder::Params(const TStringBuf& name, ui32 width) { TExprNodeBuilder& TExprNodeBuilder::Arg(ui32 index, const TStringBuf& name) { Y_ENSURE(!name.empty(), "Empty parameter name is not allowed"); - Y_ENSURE(Container, "Container expected"); + Y_ENSURE(Container, "Container expected"); Y_ENSURE(Container->ChildrenSize() == index + (Container->IsLambda() ? 1U : 0U), "Container position mismatch, expected: " << Container->ChildrenSize() << ", actual: " << index); @@ -280,7 +280,7 @@ TExprNodeBuilder& TExprNodeBuilder::Arg(ui32 index, const TStringBuf& name) { TExprNodeBuilder& TExprNodeBuilder::Arg(const TStringBuf& name) { Y_ENSURE(!Container || Container->Type() == TExprNode::Lambda, "No container expected"); - Y_ENSURE(!CurrentNode, "Node is already build"); + Y_ENSURE(!CurrentNode, "Node is already build"); CurrentNode = FindArgument(name); return *this; } @@ -342,7 +342,7 @@ TExprNode::TPtr TExprNodeBuilder::FindArgument(const TStringBuf& name) { } TExprNodeReplaceBuilder TExprNodeBuilder::Apply(ui32 index, const TExprNode& lambda) { - Y_ENSURE(Container, "Container expected"); + Y_ENSURE(Container, "Container expected"); Y_ENSURE(Container->ChildrenSize() == index + (Container->IsLambda() ? 1U : 0U), "Container position mismatch, expected: " << Container->ChildrenSize() << ", actual: " << index); @@ -351,7 +351,7 @@ TExprNodeReplaceBuilder TExprNodeBuilder::Apply(ui32 index, const TExprNode& lam TExprNodeReplaceBuilder TExprNodeBuilder::Apply(const TExprNode& lambda) { Y_ENSURE(!Container || Container->Type() == TExprNode::Lambda, "No container expected"); - Y_ENSURE(!CurrentNode, "Node is already build"); + Y_ENSURE(!CurrentNode, "Node is already build"); return TExprNodeReplaceBuilder(this, Container, lambda.HeadPtr(), GetLambdaBody(lambda)); } @@ -364,7 +364,7 @@ TExprNodeReplaceBuilder TExprNodeBuilder::Apply(const TExprNode::TPtr& lambda) { } TExprNodeReplaceBuilder TExprNodeBuilder::ApplyPartial(ui32 index, TExprNode::TPtr args, TExprNode::TPtr body) { - Y_ENSURE(Container, "Container expected"); + Y_ENSURE(Container, "Container expected"); Y_ENSURE(Container->ChildrenSize() == index + (Container->IsLambda() ? 1U : 0U), "Container position mismatch, expected: " << Container->ChildrenSize() << ", actual: " << index); @@ -381,7 +381,7 @@ TExprNodeReplaceBuilder TExprNodeBuilder::ApplyPartial(ui32 index, TExprNode::TP TExprNodeReplaceBuilder TExprNodeBuilder::ApplyPartial(TExprNode::TPtr args, TExprNode::TPtr body) { Y_ENSURE(!Container || Container->Type() == TExprNode::Lambda, "No container expected"); - Y_ENSURE(!CurrentNode, "Node is already build"); + Y_ENSURE(!CurrentNode, "Node is already build"); return TExprNodeReplaceBuilder(this, Container, std::move(args), std::move(body)); } diff --git a/ydb/library/yql/ast/yql_expr_builder_ut.cpp b/ydb/library/yql/ast/yql_expr_builder_ut.cpp index eb0f2a0bf16..bbbf755f156 100644 --- a/ydb/library/yql/ast/yql_expr_builder_ut.cpp +++ b/ydb/library/yql/ast/yql_expr_builder_ut.cpp @@ -3,21 +3,21 @@ namespace NYql { -Y_UNIT_TEST_SUITE(TExprBuilder) { - Y_UNIT_TEST(TestEmpty) { +Y_UNIT_TEST_SUITE(TExprBuilder) { + Y_UNIT_TEST(TestEmpty) { TExprContext ctx; UNIT_ASSERT_EXCEPTION(ctx.Builder(TPositionHandle()) .Build(), yexception); } - Y_UNIT_TEST(TestRootAtom) { + Y_UNIT_TEST(TestRootAtom) { TExprContext ctx; auto res = ctx.Builder(TPositionHandle()).Atom("ABC").Build(); UNIT_ASSERT_VALUES_EQUAL(res->Type(), TExprNode::Atom); UNIT_ASSERT_VALUES_EQUAL(res->Content(), "ABC"); } - Y_UNIT_TEST(TestRootAtomTwice) { + Y_UNIT_TEST(TestRootAtomTwice) { TExprContext ctx; UNIT_ASSERT_EXCEPTION(ctx.Builder(TPositionHandle()) .Atom("ABC") @@ -25,14 +25,14 @@ Y_UNIT_TEST_SUITE(TExprBuilder) { .Build(), yexception); } - Y_UNIT_TEST(TestRootEmptyList) { + Y_UNIT_TEST(TestRootEmptyList) { TExprContext ctx; auto res = ctx.Builder(TPositionHandle()).List().Seal().Build(); UNIT_ASSERT_VALUES_EQUAL(res->Type(), TExprNode::List); UNIT_ASSERT_VALUES_EQUAL(res->ChildrenSize(), 0); } - Y_UNIT_TEST(TestRootEmptyListTwice) { + Y_UNIT_TEST(TestRootEmptyListTwice) { TExprContext ctx; UNIT_ASSERT_EXCEPTION(ctx.Builder(TPositionHandle()) .List() @@ -40,7 +40,7 @@ Y_UNIT_TEST_SUITE(TExprBuilder) { .Build(), yexception); } - Y_UNIT_TEST(TestListWithAtoms) { + Y_UNIT_TEST(TestListWithAtoms) { TExprContext ctx; auto res = ctx.Builder(TPositionHandle()) .List() @@ -57,7 +57,7 @@ Y_UNIT_TEST_SUITE(TExprBuilder) { UNIT_ASSERT_VALUES_EQUAL(res->Child(1)->Content(), "XYZ"); } - Y_UNIT_TEST(TestMismatchChildIndex) { + Y_UNIT_TEST(TestMismatchChildIndex) { TExprContext ctx; UNIT_ASSERT_EXCEPTION(ctx.Builder(TPositionHandle()) .List() @@ -65,7 +65,7 @@ Y_UNIT_TEST_SUITE(TExprBuilder) { .Build(), yexception); } - Y_UNIT_TEST(TestListWithAdd) { + Y_UNIT_TEST(TestListWithAdd) { TExprContext ctx; auto res = ctx.Builder(TPositionHandle()) .List() @@ -82,7 +82,7 @@ Y_UNIT_TEST_SUITE(TExprBuilder) { UNIT_ASSERT_VALUES_EQUAL(res->Child(1)->Content(), "XYZ"); } - Y_UNIT_TEST(TestNestedListWithAtoms) { + Y_UNIT_TEST(TestNestedListWithAtoms) { TExprContext ctx; auto res = ctx.Builder(TPositionHandle()) .List() @@ -106,20 +106,20 @@ Y_UNIT_TEST_SUITE(TExprBuilder) { UNIT_ASSERT_VALUES_EQUAL(res->Child(1)->Content(), "XYZ"); } - Y_UNIT_TEST(TestWrongLevelBuild) { + Y_UNIT_TEST(TestWrongLevelBuild) { TExprContext ctx; UNIT_ASSERT_EXCEPTION(ctx.Builder(TPositionHandle()) .List() .Build(), yexception); } - Y_UNIT_TEST(TestWrongLevelSeal) { + Y_UNIT_TEST(TestWrongLevelSeal) { TExprContext ctx; UNIT_ASSERT_EXCEPTION(ctx.Builder(TPositionHandle()) .Seal(), yexception); } - Y_UNIT_TEST(TestCallableWithAtoms) { + Y_UNIT_TEST(TestCallableWithAtoms) { TExprContext ctx; auto res = ctx.Builder(TPositionHandle()) .Callable("Func") @@ -137,7 +137,7 @@ Y_UNIT_TEST_SUITE(TExprBuilder) { UNIT_ASSERT_VALUES_EQUAL(res->Child(1)->Content(), "XYZ"); } - Y_UNIT_TEST(TestNestedCallableWithAtoms) { + Y_UNIT_TEST(TestNestedCallableWithAtoms) { TExprContext ctx; auto res = ctx.Builder(TPositionHandle()) .Callable("Func1") @@ -163,13 +163,13 @@ Y_UNIT_TEST_SUITE(TExprBuilder) { UNIT_ASSERT_VALUES_EQUAL(res->Child(1)->Content(), "XYZ"); } - Y_UNIT_TEST(TestRootWorld) { + Y_UNIT_TEST(TestRootWorld) { TExprContext ctx; auto res = ctx.Builder(TPositionHandle()).World().Build(); UNIT_ASSERT_VALUES_EQUAL(res->Type(), TExprNode::World); } - Y_UNIT_TEST(TestCallableWithWorld) { + Y_UNIT_TEST(TestCallableWithWorld) { TExprContext ctx; auto res = ctx.Builder(TPositionHandle()) .Callable("Func") @@ -183,14 +183,14 @@ Y_UNIT_TEST_SUITE(TExprBuilder) { UNIT_ASSERT_VALUES_EQUAL(res->Head().Type(), TExprNode::World); } - Y_UNIT_TEST(TestIncompleteRootLambda) { + Y_UNIT_TEST(TestIncompleteRootLambda) { TExprContext ctx; UNIT_ASSERT_EXCEPTION(ctx.Builder(TPositionHandle()) .Lambda() .Build(), yexception); } - Y_UNIT_TEST(TestIncompleteInnerLambda) { + Y_UNIT_TEST(TestIncompleteInnerLambda) { TExprContext ctx; UNIT_ASSERT_EXCEPTION(ctx.Builder(TPositionHandle()) .List() @@ -199,7 +199,7 @@ Y_UNIT_TEST_SUITE(TExprBuilder) { .Build(), yexception); } - Y_UNIT_TEST(TestRootLambda) { + Y_UNIT_TEST(TestRootLambda) { TExprContext ctx; auto res = ctx.Builder(TPositionHandle()).Lambda().Atom("ABC").Seal().Build(); UNIT_ASSERT_VALUES_EQUAL(res->Type(), TExprNode::Lambda); @@ -210,7 +210,7 @@ Y_UNIT_TEST_SUITE(TExprBuilder) { UNIT_ASSERT_VALUES_EQUAL(res->Child(1)->Content(), "ABC"); } - Y_UNIT_TEST(TestRootLambdaWithBodyAsSet) { + Y_UNIT_TEST(TestRootLambdaWithBodyAsSet) { TExprContext ctx; auto res = ctx.Builder(TPositionHandle()) .Lambda() @@ -226,7 +226,7 @@ Y_UNIT_TEST_SUITE(TExprBuilder) { UNIT_ASSERT_VALUES_EQUAL(res->Child(1)->Content(), "ABC"); } - Y_UNIT_TEST(TestInnerLambdaWithParam) { + Y_UNIT_TEST(TestInnerLambdaWithParam) { TExprContext ctx; auto res = ctx.Builder(TPositionHandle()) .List() @@ -249,7 +249,7 @@ Y_UNIT_TEST_SUITE(TExprBuilder) { UNIT_ASSERT_VALUES_EQUAL(res->Head().Child(1)->Content(), "ABC"); } - Y_UNIT_TEST(TestDuplicateLambdaParamNames) { + Y_UNIT_TEST(TestDuplicateLambdaParamNames) { TExprContext ctx; UNIT_ASSERT_EXCEPTION(ctx.Builder(TPositionHandle()) .Lambda() @@ -260,14 +260,14 @@ Y_UNIT_TEST_SUITE(TExprBuilder) { .Build(), yexception); } - Y_UNIT_TEST(TestParamAtRoot) { + Y_UNIT_TEST(TestParamAtRoot) { TExprContext ctx; UNIT_ASSERT_EXCEPTION(ctx.Builder(TPositionHandle()) .Param("aaa") .Build(), yexception); } - Y_UNIT_TEST(TestParamInList) { + Y_UNIT_TEST(TestParamInList) { TExprContext ctx; UNIT_ASSERT_EXCEPTION(ctx.Builder(TPositionHandle()) .List() @@ -276,7 +276,7 @@ Y_UNIT_TEST_SUITE(TExprBuilder) { .Build(), yexception); } - Y_UNIT_TEST(TestParamInCallable) { + Y_UNIT_TEST(TestParamInCallable) { TExprContext ctx; UNIT_ASSERT_EXCEPTION(ctx.Builder(TPositionHandle()) .Callable("Func") @@ -285,7 +285,7 @@ Y_UNIT_TEST_SUITE(TExprBuilder) { .Build(), yexception); } - Y_UNIT_TEST(TestParamAfterLambdaBody) { + Y_UNIT_TEST(TestParamAfterLambdaBody) { TExprContext ctx; UNIT_ASSERT_EXCEPTION(ctx.Builder(TPositionHandle()) .Lambda() @@ -296,14 +296,14 @@ Y_UNIT_TEST_SUITE(TExprBuilder) { .Build(), yexception); } - Y_UNIT_TEST(TestIndexedAtomAtRoot) { + Y_UNIT_TEST(TestIndexedAtomAtRoot) { TExprContext ctx; UNIT_ASSERT_EXCEPTION(ctx.Builder(TPositionHandle()) .Atom(0, "ABC") .Build(), yexception); } - Y_UNIT_TEST(TestIndexedListAtRoot) { + Y_UNIT_TEST(TestIndexedListAtRoot) { TExprContext ctx; UNIT_ASSERT_EXCEPTION(ctx.Builder(TPositionHandle()) .List(0) @@ -311,14 +311,14 @@ Y_UNIT_TEST_SUITE(TExprBuilder) { .Build(), yexception); } - Y_UNIT_TEST(TestIndexedWorldAtRoot) { + Y_UNIT_TEST(TestIndexedWorldAtRoot) { TExprContext ctx; UNIT_ASSERT_EXCEPTION(ctx.Builder(TPositionHandle()) .World(0) .Build(), yexception); } - Y_UNIT_TEST(TestIndexedCallableAtRoot) { + Y_UNIT_TEST(TestIndexedCallableAtRoot) { TExprContext ctx; UNIT_ASSERT_EXCEPTION(ctx.Builder(TPositionHandle()) .Callable(0, "Func") @@ -326,7 +326,7 @@ Y_UNIT_TEST_SUITE(TExprBuilder) { .Build(), yexception); } - Y_UNIT_TEST(TestIndexedLambdaAtRoot) { + Y_UNIT_TEST(TestIndexedLambdaAtRoot) { TExprContext ctx; UNIT_ASSERT_EXCEPTION(ctx.Builder(TPositionHandle()) .Lambda(0) @@ -384,7 +384,7 @@ Y_UNIT_TEST_SUITE(TExprBuilder) { .Build(), yexception); } - Y_UNIT_TEST(TestAddAtLambda) { + Y_UNIT_TEST(TestAddAtLambda) { TExprContext ctx; UNIT_ASSERT_EXCEPTION(ctx.Builder(TPositionHandle()) .Lambda() @@ -393,7 +393,7 @@ Y_UNIT_TEST_SUITE(TExprBuilder) { .Build(), yexception); } - Y_UNIT_TEST(TestLambdaWithArgAsBody) { + Y_UNIT_TEST(TestLambdaWithArgAsBody) { TExprContext ctx; auto res = ctx.Builder(TPositionHandle()) .Lambda() @@ -414,7 +414,7 @@ Y_UNIT_TEST_SUITE(TExprBuilder) { UNIT_ASSERT_EQUAL(res->Child(1), res->Head().Child(0)); } - Y_UNIT_TEST(TestIndexedArgAsLambdaBody) { + Y_UNIT_TEST(TestIndexedArgAsLambdaBody) { TExprContext ctx; UNIT_ASSERT_EXCEPTION(ctx.Builder(TPositionHandle()).Lambda() .Param("x") @@ -423,7 +423,7 @@ Y_UNIT_TEST_SUITE(TExprBuilder) { .Build(), yexception); } - Y_UNIT_TEST(TestWrongArgName) { + Y_UNIT_TEST(TestWrongArgName) { TExprContext ctx; UNIT_ASSERT_EXCEPTION(ctx.Builder(TPositionHandle()).Lambda() .Param("x") @@ -432,7 +432,7 @@ Y_UNIT_TEST_SUITE(TExprBuilder) { .Build(), yexception); } - Y_UNIT_TEST(TestLambdaWithArgInCallables) { + Y_UNIT_TEST(TestLambdaWithArgInCallables) { TExprContext ctx; auto res = ctx.Builder(TPositionHandle()) .Lambda() @@ -460,7 +460,7 @@ Y_UNIT_TEST_SUITE(TExprBuilder) { UNIT_ASSERT_EQUAL(res->Child(1)->Child(1), res->Head().Child(0)); } - Y_UNIT_TEST(TestNestedScopeInLambda) { + Y_UNIT_TEST(TestNestedScopeInLambda) { TExprContext ctx; auto res = ctx.Builder(TPositionHandle()) .Lambda() @@ -504,7 +504,7 @@ Y_UNIT_TEST_SUITE(TExprBuilder) { res->Head().Child(1)); } - Y_UNIT_TEST(TestNonIndexedArg) { + Y_UNIT_TEST(TestNonIndexedArg) { TExprContext ctx; UNIT_ASSERT_EXCEPTION(ctx.Builder(TPositionHandle()).Lambda() .Param("x") @@ -515,7 +515,7 @@ Y_UNIT_TEST_SUITE(TExprBuilder) { .Build(), yexception); } - Y_UNIT_TEST(TestApplyLambdaArgAsRoot) { + Y_UNIT_TEST(TestApplyLambdaArgAsRoot) { TExprContext ctx; auto lambda = ctx.Builder(TPositionHandle()) .Lambda() @@ -540,7 +540,7 @@ Y_UNIT_TEST_SUITE(TExprBuilder) { UNIT_ASSERT_EQUAL(res->Child(1), res->Head().Child(0)); } - Y_UNIT_TEST(TestApplyLambdaArgInContainer) { + Y_UNIT_TEST(TestApplyLambdaArgInContainer) { TExprContext ctx; auto lambda = ctx.Builder(TPositionHandle()) .Lambda() @@ -569,7 +569,7 @@ Y_UNIT_TEST_SUITE(TExprBuilder) { UNIT_ASSERT_EQUAL(res->Child(1)->Child(0), res->Head().Child(0)); } - Y_UNIT_TEST(TestApplyPartialLambdaArgAsRoot) { + Y_UNIT_TEST(TestApplyPartialLambdaArgAsRoot) { TExprContext ctx; auto lambda = ctx.Builder(TPositionHandle()) .Lambda() @@ -599,7 +599,7 @@ Y_UNIT_TEST_SUITE(TExprBuilder) { UNIT_ASSERT_EQUAL(res->Child(1)->Child(1), res->Head().Child(0)); } - Y_UNIT_TEST(TestApplyPartialLambdaArgInContainer) { + Y_UNIT_TEST(TestApplyPartialLambdaArgInContainer) { TExprContext ctx; auto lambda = ctx.Builder(TPositionHandle()) .Lambda() @@ -631,7 +631,7 @@ Y_UNIT_TEST_SUITE(TExprBuilder) { UNIT_ASSERT_EQUAL(res->Child(1)->Head().Child(1), res->Head().Child(0)); } - Y_UNIT_TEST(TestApplyOuterArg) { + Y_UNIT_TEST(TestApplyOuterArg) { TExprContext ctx; auto ast = ctx.Builder(TPositionHandle()) .Lambda() diff --git a/ydb/library/yql/ast/yql_expr_types.cpp b/ydb/library/yql/ast/yql_expr_types.cpp index 0e44a620f31..4a09c02b3a9 100644 --- a/ydb/library/yql/ast/yql_expr_types.cpp +++ b/ydb/library/yql/ast/yql_expr_types.cpp @@ -4,7 +4,7 @@ namespace NYql { } template<> -void Out<NYql::ETypeAnnotationKind>(class IOutputStream &o, NYql::ETypeAnnotationKind x) { +void Out<NYql::ETypeAnnotationKind>(class IOutputStream &o, NYql::ETypeAnnotationKind x) { #define YQL_TYPE_ANN_KIND_MAP_TO_STRING_IMPL(name, ...) \ case NYql::ETypeAnnotationKind::name: \ o << #name; \ diff --git a/ydb/library/yql/ast/yql_expr_types.h b/ydb/library/yql/ast/yql_expr_types.h index 391fa1ca979..c0e38140313 100644 --- a/ydb/library/yql/ast/yql_expr_types.h +++ b/ydb/library/yql/ast/yql_expr_types.h @@ -37,4 +37,4 @@ enum class ETypeAnnotationKind : ui64 { } template<> -void Out<NYql::ETypeAnnotationKind>(class IOutputStream &o, NYql::ETypeAnnotationKind x); +void Out<NYql::ETypeAnnotationKind>(class IOutputStream &o, NYql::ETypeAnnotationKind x); diff --git a/ydb/library/yql/ast/yql_expr_ut.cpp b/ydb/library/yql/ast/yql_expr_ut.cpp index 06550f2507d..31bba11a5c6 100644 --- a/ydb/library/yql/ast/yql_expr_ut.cpp +++ b/ydb/library/yql/ast/yql_expr_ut.cpp @@ -5,7 +5,7 @@ namespace NYql { -Y_UNIT_TEST_SUITE(TCompileYqlExpr) { +Y_UNIT_TEST_SUITE(TCompileYqlExpr) { static TAstParseResult ParseAstWithCheck(const TStringBuf& s) { TAstParseResult res = ParseAst(s); @@ -38,20 +38,20 @@ Y_UNIT_TEST_SUITE(TCompileYqlExpr) { return result; } - Y_UNIT_TEST(TestNoReturn1) { + Y_UNIT_TEST(TestNoReturn1) { auto s = "(\n" ")\n"; UNIT_ASSERT(false == ParseAndCompile(s)); } - Y_UNIT_TEST(TestNoReturn2) { + Y_UNIT_TEST(TestNoReturn2) { auto s = "(\n" "(let x 'y)\n" ")\n"; UNIT_ASSERT(false == ParseAndCompile(s)); } - Y_UNIT_TEST(TestExportInsteadOfReturn) { + Y_UNIT_TEST(TestExportInsteadOfReturn) { const auto s = "# library\n" "(\n" @@ -62,7 +62,7 @@ Y_UNIT_TEST_SUITE(TCompileYqlExpr) { UNIT_ASSERT(false == ParseAndCompile(s)); } - Y_UNIT_TEST(TestLeftAfterReturn) { + Y_UNIT_TEST(TestLeftAfterReturn) { auto s = "(\n" "(return 'x)\n" "(let x 'y)\n" @@ -70,7 +70,7 @@ Y_UNIT_TEST_SUITE(TCompileYqlExpr) { UNIT_ASSERT(false == ParseAndCompile(s)); } - Y_UNIT_TEST(TestReturn) { + Y_UNIT_TEST(TestReturn) { auto s = "(\n" "(return world)\n" ")\n"; @@ -82,7 +82,7 @@ Y_UNIT_TEST_SUITE(TCompileYqlExpr) { UNIT_ASSERT_VALUES_EQUAL(exprRoot->Type(), TExprNode::World); } - Y_UNIT_TEST(TestExport) { + Y_UNIT_TEST(TestExport) { auto s = "(\n" "(let X 'Y)\n" "(let ex '42)\n" @@ -100,7 +100,7 @@ Y_UNIT_TEST_SUITE(TCompileYqlExpr) { UNIT_ASSERT_VALUES_EQUAL("Y", exports["X"]->Content()); } - Y_UNIT_TEST(TestEmptyLib) { + Y_UNIT_TEST(TestEmptyLib) { auto s = "(\n" "(let X 'Y)\n" "(let ex '42)\n" @@ -114,7 +114,7 @@ Y_UNIT_TEST_SUITE(TCompileYqlExpr) { UNIT_ASSERT(cohesion.Imports.empty()); } - Y_UNIT_TEST(TestArbitraryAtom) { + Y_UNIT_TEST(TestArbitraryAtom) { auto s = "(\n" "(let x '\"\\x01\\x23\\x45\\x67\\x89\\xAB\\xCD\\xEF\")" "(return x)\n" @@ -134,7 +134,7 @@ Y_UNIT_TEST_SUITE(TCompileYqlExpr) { UNIT_ASSERT(xValue->GetFlags() & TNodeFlags::ArbitraryContent); } - Y_UNIT_TEST(TestBinaryAtom) { + Y_UNIT_TEST(TestBinaryAtom) { auto s = "(\n" "(let x 'x\"FEDCBA9876543210\")" "(return x)\n" @@ -154,7 +154,7 @@ Y_UNIT_TEST_SUITE(TCompileYqlExpr) { UNIT_ASSERT(xValue->GetFlags() & TNodeFlags::BinaryContent); } - Y_UNIT_TEST(TestLet) { + Y_UNIT_TEST(TestLet) { auto s = "(\n" "(let x 'y)\n" "(return x)\n" @@ -168,7 +168,7 @@ Y_UNIT_TEST_SUITE(TCompileYqlExpr) { UNIT_ASSERT_VALUES_EQUAL(exprRoot->Content(), "y"); } - Y_UNIT_TEST(TestComplexQuote) { + Y_UNIT_TEST(TestComplexQuote) { auto s = "(\n" "(let x 'a)\n" "(let y 'b)\n" @@ -188,21 +188,21 @@ Y_UNIT_TEST_SUITE(TCompileYqlExpr) { UNIT_ASSERT_VALUES_EQUAL(exprRoot->Child(1)->Content(), "b"); } - Y_UNIT_TEST(TestEmptyReturn) { + Y_UNIT_TEST(TestEmptyReturn) { auto s = "(\n" "(return)\n" ")\n"; UNIT_ASSERT(false == ParseAndCompile(s)); } - Y_UNIT_TEST(TestManyReturn) { + Y_UNIT_TEST(TestManyReturn) { auto s = "(\n" "(return world world)\n" ")\n"; UNIT_ASSERT(false == ParseAndCompile(s)); } - Y_UNIT_TEST(TestUnknownFunction) { + Y_UNIT_TEST(TestUnknownFunction) { auto s = "(\n" "(let a '2)\n" "(let x (+ a '3))\n" @@ -222,7 +222,7 @@ Y_UNIT_TEST_SUITE(TCompileYqlExpr) { UNIT_ASSERT_VALUES_EQUAL(exprRoot->Child(1)->Content(), "3"); } - Y_UNIT_TEST(TestReturnTwice) { + Y_UNIT_TEST(TestReturnTwice) { auto s = "(\n" "(return)\n" "(return)\n" @@ -230,7 +230,7 @@ Y_UNIT_TEST_SUITE(TCompileYqlExpr) { UNIT_ASSERT(false == ParseAndCompile(s)); } - Y_UNIT_TEST(TestDeclareNonTop) { + Y_UNIT_TEST(TestDeclareNonTop) { const auto s = R"( ( (let $1 (block '( @@ -243,7 +243,7 @@ Y_UNIT_TEST_SUITE(TCompileYqlExpr) { UNIT_ASSERT(false == ParseAndCompile(s)); } - Y_UNIT_TEST(TestDeclareHideLet) { + Y_UNIT_TEST(TestDeclareHideLet) { const auto s = R"( ( (let $name (Uint32 '10)) @@ -254,7 +254,7 @@ Y_UNIT_TEST_SUITE(TCompileYqlExpr) { UNIT_ASSERT(false == ParseAndCompile(s)); } - Y_UNIT_TEST(TestDeclareBadName) { + Y_UNIT_TEST(TestDeclareBadName) { const auto s = R"( ( (declare $15 (DataType 'Uint32)) @@ -264,7 +264,7 @@ Y_UNIT_TEST_SUITE(TCompileYqlExpr) { UNIT_ASSERT(false == ParseAndCompile(s)); } - Y_UNIT_TEST(TestLetHideDeclare) { + Y_UNIT_TEST(TestLetHideDeclare) { const auto s = R"( ( (declare $name (DataType 'Uint32)) @@ -284,7 +284,7 @@ Y_UNIT_TEST_SUITE(TCompileYqlExpr) { UNIT_ASSERT_VALUES_EQUAL(exprRoot->Child(0)->Content(), "10"); } - Y_UNIT_TEST(TestDeclare) { + Y_UNIT_TEST(TestDeclare) { const auto s = R"( ( (declare $param (DataType 'Uint32)) @@ -305,7 +305,7 @@ Y_UNIT_TEST_SUITE(TCompileYqlExpr) { } } -Y_UNIT_TEST_SUITE(TCompareExprTrees) { +Y_UNIT_TEST_SUITE(TCompareExprTrees) { void CompileAndCompare(const TString& one, const TString& two, const std::pair<TPosition, TPosition> *const diffPositions = nullptr) { const auto progOne(ParseAst(one)), progTwo(ParseAst(two)); UNIT_ASSERT(progOne.IsOk() && progTwo.IsOk()); @@ -327,7 +327,7 @@ Y_UNIT_TEST_SUITE(TCompareExprTrees) { UNIT_ASSERT(CompareExprTrees(diffOne, diffTwo)); } - Y_UNIT_TEST(BigGoodCompare) { + Y_UNIT_TEST(BigGoodCompare) { const auto one = R"( ( (let $1 world) @@ -854,7 +854,7 @@ Y_UNIT_TEST_SUITE(TCompareExprTrees) { CompileAndCompare(one, two); } - Y_UNIT_TEST(DiffrentAtoms) { + Y_UNIT_TEST(DiffrentAtoms) { const auto one = "((return (+ '4 (- '3 '2))))"; const auto two = "((let x '3)\n(let y '1)\n(let z (- x y))\n(let r (+ '4 z))\n(return r))"; @@ -862,7 +862,7 @@ Y_UNIT_TEST_SUITE(TCompareExprTrees) { CompileAndCompare(one, two, &diff); } - Y_UNIT_TEST(DiffrentLists) { + Y_UNIT_TEST(DiffrentLists) { const auto one = "((return '('7 '4 '('1 '3 '2))))"; const auto two = "((let x '('1 '3))\n(let y '('7 '4 x))\n(return y))"; @@ -870,7 +870,7 @@ Y_UNIT_TEST_SUITE(TCompareExprTrees) { CompileAndCompare(one, two, &diff); } - Y_UNIT_TEST(DiffrentCallables) { + Y_UNIT_TEST(DiffrentCallables) { const auto one = "((return (- '4 (- '3 '2))))"; const auto two = "((let x '3)\n(let y '2)\n(let z (- x y))\n(let r (+ '4 z))\n(return r))"; @@ -878,7 +878,7 @@ Y_UNIT_TEST_SUITE(TCompareExprTrees) { CompileAndCompare(one, two, &diff); } - Y_UNIT_TEST(SwapArguments) { + Y_UNIT_TEST(SwapArguments) { const auto one = "((let l (lambda '(x y) (+ x y)))\n(return (Apply l '7 '9)))"; const auto two = "((return (Apply (lambda '(x y) (+ y x)) '7 '9)))"; @@ -887,7 +887,7 @@ Y_UNIT_TEST_SUITE(TCompareExprTrees) { } } -Y_UNIT_TEST_SUITE(TConvertToAst) { +Y_UNIT_TEST_SUITE(TConvertToAst) { static TString CompileAndDisassemble(const TString& program, bool expectEqualExprs = true) { const auto astRes = ParseAst(program); UNIT_ASSERT(astRes.IsOk()); @@ -913,7 +913,7 @@ Y_UNIT_TEST_SUITE(TConvertToAst) { return convRes.Root->ToString(TAstPrintFlags::PerLine | TAstPrintFlags::ShortQuote); } - Y_UNIT_TEST(ManyLambdaWithCaptures) { + Y_UNIT_TEST(ManyLambdaWithCaptures) { const auto program = R"( ( #comment @@ -948,7 +948,7 @@ Y_UNIT_TEST_SUITE(TConvertToAst) { CompileAndDisassemble(program); } - Y_UNIT_TEST(LambdaWithCaptureArgumentOfTopLambda) { + Y_UNIT_TEST(LambdaWithCaptureArgumentOfTopLambda) { const auto program = R"( ( (let mr_source (DataSource 'yt 'plato)) @@ -972,7 +972,7 @@ Y_UNIT_TEST_SUITE(TConvertToAst) { CompileAndDisassemble(program); } - Y_UNIT_TEST(LambdaWithCapture) { + Y_UNIT_TEST(LambdaWithCapture) { const auto program = R"( ( (let conf (Configure! world (DataSource 'yt '"$all") '"Attr" '"mapjoinlimit" '"1")) @@ -1012,7 +1012,7 @@ Y_UNIT_TEST_SUITE(TConvertToAst) { UNIT_ASSERT_EQUAL(disassembled.find("'('key 'subkey 'value)"), disassembled.rfind("'('key 'subkey 'value)")); } - Y_UNIT_TEST(ManyLambdasWithCommonCapture) { + Y_UNIT_TEST(ManyLambdasWithCommonCapture) { const auto program = R"( ( (let c42 (+ (Int64 '40) (Int64 '2))) @@ -1029,7 +1029,7 @@ Y_UNIT_TEST_SUITE(TConvertToAst) { UNIT_ASSERT_EQUAL(disassembled.find("(+ (Int64 '40) (Int64 '2))"), disassembled.rfind("(+ (Int64 '40) (Int64 '2))")); } - Y_UNIT_TEST(CapturedUseInTopLevelAfrerLambda) { + Y_UNIT_TEST(CapturedUseInTopLevelAfrerLambda) { const auto program = R"( ( (let $1 (DataSink 'result)) @@ -1057,7 +1057,7 @@ Y_UNIT_TEST_SUITE(TConvertToAst) { CompileAndDisassemble(program); } - Y_UNIT_TEST(SelectCommonAncestor) { + Y_UNIT_TEST(SelectCommonAncestor) { const auto program = R"( ( (let $1 (DataSink 'result)) @@ -1157,7 +1157,7 @@ Y_UNIT_TEST_SUITE(TConvertToAst) { CompileAndDisassemble(program); } - Y_UNIT_TEST(Parameters) { + Y_UNIT_TEST(Parameters) { const auto program = R"( ( (let $nameType (OptionalType (DataType 'String))) @@ -1186,7 +1186,7 @@ Y_UNIT_TEST_SUITE(TConvertToAst) { UNIT_ASSERT(TString::npos != disassembled.find("(declare $Name (OptionalType (DataType 'String)))")); } - Y_UNIT_TEST(ParametersDifferentTypes) { + Y_UNIT_TEST(ParametersDifferentTypes) { const auto program = R"( ( (let $1 (Read! world (DataSource '"kikimr" '"local_ut") (Key '('table (String '"tmp/table"))) (Void) '())) diff --git a/ydb/library/yql/ast/yql_type_string.cpp b/ydb/library/yql/ast/yql_type_string.cpp index af9af93259d..b1bad9804c0 100644 --- a/ydb/library/yql/ast/yql_type_string.cpp +++ b/ydb/library/yql/ast/yql_type_string.cpp @@ -847,7 +847,7 @@ private: MakeLiteralAtom(TStringBuf("ListType")), itemType, }; - return MakeList(items, Y_ARRAY_SIZE(items)); + return MakeList(items, Y_ARRAY_SIZE(items)); } TAstNode* MakeStreamType(TAstNode* itemType) { @@ -880,7 +880,7 @@ private: keyType, valueType, }; - return MakeList(items, Y_ARRAY_SIZE(items)); + return MakeList(items, Y_ARRAY_SIZE(items)); } TAstNode* MakeTupleType(TSmallVec<TAstNode*>& items) { @@ -897,7 +897,7 @@ private: MakeQuotedAtom(member.first, TNodeFlags::ArbitraryContent), // name member.second, // type }; - items.push_back(MakeQuote(MakeList(memberType, Y_ARRAY_SIZE(memberType)))); + items.push_back(MakeQuote(MakeList(memberType, Y_ARRAY_SIZE(memberType)))); } return MakeList(items.data(), items.size()); @@ -949,7 +949,7 @@ private: MakeLiteralAtom(TStringBuf("ResourceType")), MakeQuotedAtom(tag), }; - return MakeList(items, Y_ARRAY_SIZE(items)); + return MakeList(items, Y_ARRAY_SIZE(items)); } TAstNode* MakeVoidType() { @@ -1009,7 +1009,7 @@ private: MakeLiteralAtom(TStringBuf("DataType")), MakeQuotedAtom(type), }; - return MakeList(items, Y_ARRAY_SIZE(items)); + return MakeList(items, Y_ARRAY_SIZE(items)); } TAstNode* MakeDecimalType(TStringBuf precision, TStringBuf scale) { @@ -1027,7 +1027,7 @@ private: MakeLiteralAtom(TStringBuf("OptionalType")), type, }; - return MakeList(items, Y_ARRAY_SIZE(items)); + return MakeList(items, Y_ARRAY_SIZE(items)); } TAstNode* MakeAtom(TStringBuf content, ui32 flags = TNodeFlags::Default) { @@ -1043,7 +1043,7 @@ private: &TAstNode::QuoteAtom, node, }; - return MakeList(items, Y_ARRAY_SIZE(items)); + return MakeList(items, Y_ARRAY_SIZE(items)); } TAstNode* MakeQuotedAtom(TStringBuf content, ui32 flags = TNodeFlags::Default) { @@ -1100,14 +1100,14 @@ private: class TTypePrinter: public TTypeAnnotationVisitor { public: - TTypePrinter(IOutputStream& out) + TTypePrinter(IOutputStream& out) : Out_(out) { } private: void Visit(const TUnitExprType& type) final { - Y_UNUSED(type); + Y_UNUSED(type); Out_ << TStringBuf("Unit"); } @@ -1179,7 +1179,7 @@ private: } void Visit(const TWorldExprType& type) final { - Y_UNUSED(type); + Y_UNUSED(type); Out_ << TStringBuf("World"); } @@ -1263,7 +1263,7 @@ private: } void Visit(const TVoidExprType& type) final { - Y_UNUSED(type); + Y_UNUSED(type); Out_ << TStringBuf("Void"); } @@ -1283,7 +1283,7 @@ private: } void Visit(const TGenericExprType& type) final { - Y_UNUSED(type); + Y_UNUSED(type); Out_ << TStringBuf("Generic"); } @@ -1346,7 +1346,7 @@ private: } private: - IOutputStream& Out_; + IOutputStream& Out_; }; } // namespace diff --git a/ydb/library/yql/ast/yql_type_string_ut.cpp b/ydb/library/yql/ast/yql_type_string_ut.cpp index 2f22c42258a..30760310667 100644 --- a/ydb/library/yql/ast/yql_type_string_ut.cpp +++ b/ydb/library/yql/ast/yql_type_string_ut.cpp @@ -6,7 +6,7 @@ using namespace NYql; -Y_UNIT_TEST_SUITE(TTypeString) +Y_UNIT_TEST_SUITE(TTypeString) { void TestFail(const TStringBuf& prog, ui32 column, const TStringBuf& expectedError) { TMemoryPool pool(4096); @@ -30,11 +30,11 @@ Y_UNIT_TEST_SUITE(TTypeString) UNIT_ASSERT_STRINGS_EQUAL(res->ToString(), expectedType); } - Y_UNIT_TEST(ParseEmpty) { + Y_UNIT_TEST(ParseEmpty) { TestFail("", 1, "Expected type"); } - Y_UNIT_TEST(ParseDataTypes) { + Y_UNIT_TEST(ParseDataTypes) { TestOk("String", "(DataType 'String)"); TestOk("Bool", "(DataType 'Bool)"); TestOk("Uint8", "(DataType 'Uint8)"); @@ -61,7 +61,7 @@ Y_UNIT_TEST_SUITE(TTypeString) TestOk("Decimal(10,2)", "(DataType 'Decimal '10 '2)"); } - Y_UNIT_TEST(Multiline) { + Y_UNIT_TEST(Multiline) { TestOk(R"(Struct < name : String @@ -72,19 +72,19 @@ Y_UNIT_TEST_SUITE(TTypeString) "'('\"name\" (DataType 'String)))"); } - Y_UNIT_TEST(ParseNoArgsWithStringResult) { + Y_UNIT_TEST(ParseNoArgsWithStringResult) { TestOk("()->String", "(CallableType '() '((DataType 'String)))"); TestOk("()->Utf8", "(CallableType '() '((DataType 'Utf8)))"); } - Y_UNIT_TEST(ParseNoArgsWithOptionalStringResult) { + Y_UNIT_TEST(ParseNoArgsWithOptionalStringResult) { TestOk("()->String?", "(CallableType '() '((OptionalType (DataType 'String))))"); TestOk("()->Yson?", "(CallableType '() '((OptionalType (DataType 'Yson))))"); } - Y_UNIT_TEST(ParseOneArgWithDoubleResult) { + Y_UNIT_TEST(ParseOneArgWithDoubleResult) { TestOk("(Int32)->Double", "(CallableType '() '((DataType 'Double)) " "'((DataType 'Int32))" @@ -99,7 +99,7 @@ Y_UNIT_TEST_SUITE(TTypeString) ")"); } - Y_UNIT_TEST(ParseTwoArgsWithOptionalByteResult) { + Y_UNIT_TEST(ParseTwoArgsWithOptionalByteResult) { TestOk("(Int32?, String)->Uint8?", "(CallableType '() '((OptionalType (DataType 'Uint8))) " "'((OptionalType (DataType 'Int32))) " @@ -107,18 +107,18 @@ Y_UNIT_TEST_SUITE(TTypeString) ")"); } - Y_UNIT_TEST(ParseWithEmptyOptionalArgsStringResult) { + Y_UNIT_TEST(ParseWithEmptyOptionalArgsStringResult) { TestOk("([])->String", "(CallableType '() '((DataType 'String)))"); } - Y_UNIT_TEST(ParseWithOneOptionalArgDoubleResult) { + Y_UNIT_TEST(ParseWithOneOptionalArgDoubleResult) { TestOk("([Int32?])->Double", "(CallableType '('1) '((DataType 'Double)) " "'((OptionalType (DataType 'Int32)))" ")"); } - Y_UNIT_TEST(ParseOneReqAndOneOptionalArgsWithDoubleResult) { + Y_UNIT_TEST(ParseOneReqAndOneOptionalArgsWithDoubleResult) { TestOk("(String,[Int32?])->Double", "(CallableType '('1) '((DataType 'Double)) " "'((DataType 'String)) " @@ -126,7 +126,7 @@ Y_UNIT_TEST_SUITE(TTypeString) ")"); } - Y_UNIT_TEST(ParseOneReqAndTwoOptionalArgsWithDoubleResult) { + Y_UNIT_TEST(ParseOneReqAndTwoOptionalArgsWithDoubleResult) { TestOk("(String,[Int32?, Uint8?])->Double", "(CallableType '('2) '((DataType 'Double)) " "'((DataType 'String)) " @@ -135,28 +135,28 @@ Y_UNIT_TEST_SUITE(TTypeString) ")"); } - Y_UNIT_TEST(ParseCallableArgWithDoubleResult) { + Y_UNIT_TEST(ParseCallableArgWithDoubleResult) { TestOk("(()->Uint8)->Double", "(CallableType '() '((DataType 'Double)) " "'((CallableType '() '((DataType 'Uint8))))" ")"); } - Y_UNIT_TEST(ParseCallableOptionalArgWithDoubleResult) { + Y_UNIT_TEST(ParseCallableOptionalArgWithDoubleResult) { TestOk("([Optional<()->Uint8>])->Double", "(CallableType '('1) '((DataType 'Double)) " "'((OptionalType (CallableType '() '((DataType 'Uint8)))))" ")"); } - Y_UNIT_TEST(ParseOptionalCallableArgWithDoubleResult) { + Y_UNIT_TEST(ParseOptionalCallableArgWithDoubleResult) { TestOk("(Optional<()->Uint8>)->Double", "(CallableType '() '((DataType 'Double)) " "'((OptionalType (CallableType '() '((DataType 'Uint8)))))" ")"); } - Y_UNIT_TEST(ParseCallableWithNamedArgs) { + Y_UNIT_TEST(ParseCallableWithNamedArgs) { TestOk("(a:Uint8)->Double", "(CallableType '() '((DataType 'Double)) " "'((DataType 'Uint8) 'a)" @@ -181,7 +181,7 @@ Y_UNIT_TEST_SUITE(TTypeString) ")"); } - Y_UNIT_TEST(ParseCallableWithArgFlags) { + Y_UNIT_TEST(ParseCallableWithArgFlags) { TestOk("(Int32{Flags:AutoMap})->Double", "(CallableType '() '((DataType 'Double)) " "'((DataType 'Int32) '\"\" '1)" @@ -205,14 +205,14 @@ Y_UNIT_TEST_SUITE(TTypeString) ")"); } - Y_UNIT_TEST(ParseCallableWithPayload) { + Y_UNIT_TEST(ParseCallableWithPayload) { TestOk("(Int32)->Double{Payload:MyFunction}", "(CallableType '('0 '\"MyFunction\") '((DataType 'Double)) " "'((DataType 'Int32))" ")"); } - Y_UNIT_TEST(ParseOptional) { + Y_UNIT_TEST(ParseOptional) { TestOk("Uint32?", "(OptionalType (DataType 'Uint32))"); TestOk("Optional<Uint32>", "(OptionalType (DataType 'Uint32))"); TestOk("Uint32??", "(OptionalType (OptionalType (DataType 'Uint32)))"); @@ -221,7 +221,7 @@ Y_UNIT_TEST_SUITE(TTypeString) TestOk("Optional<Optional<Uint32>>", "(OptionalType (OptionalType (DataType 'Uint32)))"); } - Y_UNIT_TEST(ParseCallableComplete) { + Y_UNIT_TEST(ParseCallableComplete) { TestFail("(Uint32)->", 11, "Expected type"); TestFail("(,)->", 2, "Expected type or argument name"); TestFail("(Int32 Int32)->Int32", 8, "Expected ','"); @@ -256,21 +256,21 @@ Y_UNIT_TEST_SUITE(TTypeString) TestFail("(Uint32)->Uint32{Payload:}", 26, "Expected payload data"); } - Y_UNIT_TEST(ParseCallableWithKeyword) { + Y_UNIT_TEST(ParseCallableWithKeyword) { TestOk("(Callable<()->String>) -> Callable<()->Uint32>", "(CallableType '() '((CallableType '() '((DataType 'Uint32)))) " "'((CallableType '() '((DataType 'String))))" ")"); } - Y_UNIT_TEST(ParseListOfDataType) { + Y_UNIT_TEST(ParseListOfDataType) { TestOk("(List<String>)->String", "(CallableType '() '((DataType 'String)) " "'((ListType (DataType 'String)))" ")"); } - Y_UNIT_TEST(ParseStreamOfDataType) { + Y_UNIT_TEST(ParseStreamOfDataType) { TestOk("(Stream<String>)->String", "(CallableType '() '((DataType 'String)) " "'((StreamType (DataType 'String)))" @@ -284,7 +284,7 @@ Y_UNIT_TEST_SUITE(TTypeString) ")"); } - Y_UNIT_TEST(ParseVariantType) { + Y_UNIT_TEST(ParseVariantType) { TestOk("Variant<String>", "(VariantType (TupleType " "(DataType 'String)" @@ -319,7 +319,7 @@ Y_UNIT_TEST_SUITE(TTypeString) "))"); } - Y_UNIT_TEST(ParseListAsReturnType) { + Y_UNIT_TEST(ParseListAsReturnType) { TestOk("(String, String)->List<String>", "(CallableType '() '((ListType (DataType 'String))) " "'((DataType 'String)) " @@ -327,7 +327,7 @@ Y_UNIT_TEST_SUITE(TTypeString) ")"); } - Y_UNIT_TEST(ParseListOfOptionalDataType) { + Y_UNIT_TEST(ParseListOfOptionalDataType) { TestOk("(List<String?>)->String", "(CallableType '() '((DataType 'String)) " "'((ListType " @@ -336,7 +336,7 @@ Y_UNIT_TEST_SUITE(TTypeString) ")"); } - Y_UNIT_TEST(ParseOptionalListOfDataType) { + Y_UNIT_TEST(ParseOptionalListOfDataType) { TestOk("(List<String>?)->String", "(CallableType '() '((DataType 'String)) " "'((OptionalType " @@ -345,7 +345,7 @@ Y_UNIT_TEST_SUITE(TTypeString) ")"); } - Y_UNIT_TEST(ParseListOfListType) { + Y_UNIT_TEST(ParseListOfListType) { TestOk("(List<List<Uint32>>)->Uint32", "(CallableType '() '((DataType 'Uint32)) " "'((ListType " @@ -354,7 +354,7 @@ Y_UNIT_TEST_SUITE(TTypeString) ")"); } - Y_UNIT_TEST(ParseDictOfDataTypes) { + Y_UNIT_TEST(ParseDictOfDataTypes) { TestOk("(Dict<String, Uint32>)->Uint32", "(CallableType '() '((DataType 'Uint32)) " "'((DictType " @@ -374,12 +374,12 @@ Y_UNIT_TEST_SUITE(TTypeString) ")"); } - Y_UNIT_TEST(ParseListComplete) { + Y_UNIT_TEST(ParseListComplete) { TestFail("(List<>)->Uint32", 7, "Expected type"); TestFail("(List<Uint32,>)->Uint32", 13, "Expected '>'"); } - Y_UNIT_TEST(ParseVariantComplete) { + Y_UNIT_TEST(ParseVariantComplete) { TestFail("Variant<>", 9, "Expected type"); TestFail("Variant<Uint32,>", 16, "Expected type"); TestFail("Variant<Uint32", 15, "Expected '>' or ','"); @@ -389,7 +389,7 @@ Y_UNIT_TEST_SUITE(TTypeString) TestFail("Variant<name:String", 20, "Expected '>' or ','"); } - Y_UNIT_TEST(ParseDictOfDictTypes) { + Y_UNIT_TEST(ParseDictOfDictTypes) { TestOk("(Dict<String, Dict<Uint32, Uint32>>)->Uint32", "(CallableType '() '((DataType 'Uint32)) " "'((DictType " @@ -399,14 +399,14 @@ Y_UNIT_TEST_SUITE(TTypeString) ")"); } - Y_UNIT_TEST(ParseDictComplete) { + Y_UNIT_TEST(ParseDictComplete) { TestFail("(Dict<>)->Uint32", 7, "Expected type"); TestFail("(Dict<Uint32>)->Uint32", 13, "Expected ','"); TestFail("(Dict<Uint32,>)->Uint32", 14, "Expected type"); TestFail("(Dict<Uint32, String)->Uint32", 21, "Expected '>'"); } - Y_UNIT_TEST(ParseTupleOfDataTypes) { + Y_UNIT_TEST(ParseTupleOfDataTypes) { TestOk("(Tuple<String, Uint32, Uint8>)->Uint32", "(CallableType '() '((DataType 'Uint32)) " "'((TupleType " @@ -417,12 +417,12 @@ Y_UNIT_TEST_SUITE(TTypeString) ")"); } - Y_UNIT_TEST(ParseTupleComplete) { + Y_UNIT_TEST(ParseTupleComplete) { TestFail("(Tuple<Uint32,>)->Uint32", 15, "Expected type"); TestFail("(Tuple<Uint32)->Uint32", 14, "Expected '>' or ','"); } - Y_UNIT_TEST(ParseStructOfDataTypes) { + Y_UNIT_TEST(ParseStructOfDataTypes) { TestOk("(Struct<Name: String, Age: Uint32, Male: Bool>)->Uint32", "(CallableType '() '((DataType 'Uint32)) " "'((StructType " @@ -433,7 +433,7 @@ Y_UNIT_TEST_SUITE(TTypeString) ")"); } - Y_UNIT_TEST(ParseStructWithEscaping) { + Y_UNIT_TEST(ParseStructWithEscaping) { TestOk("Struct<'My\\tName': String, 'My Age': Uint32>", "(StructType " "'('\"My\\tName\" (DataType 'String)) " @@ -441,14 +441,14 @@ Y_UNIT_TEST_SUITE(TTypeString) ")"); } - Y_UNIT_TEST(ParseStructComplete) { + Y_UNIT_TEST(ParseStructComplete) { TestFail("(Struct<name>)->Uint32", 13, "Expected ':'"); TestFail("(Struct<name:>)->Uint32", 14, "Expected type"); TestFail("(Struct<name:String,>)->Uint32", 21, "Expected struct member name"); TestFail("(Struct<name:String)->Uint32", 20, "Expected '>' or ','"); } - Y_UNIT_TEST(ParseResource) { + Y_UNIT_TEST(ParseResource) { TestOk("Resource<aaa>", "(ResourceType 'aaa)"); TestOk("(Resource<aaa>?)->Resource<bbb>", "(CallableType '() '((ResourceType 'bbb)) " @@ -456,7 +456,7 @@ Y_UNIT_TEST_SUITE(TTypeString) ")"); } - Y_UNIT_TEST(ParseVoid) { + Y_UNIT_TEST(ParseVoid) { TestOk("Void", "(VoidType)"); TestOk("Void?", "(OptionalType (VoidType))"); TestOk("(Void?)->Void", @@ -465,7 +465,7 @@ Y_UNIT_TEST_SUITE(TTypeString) ")"); } - Y_UNIT_TEST(ParseNull) { + Y_UNIT_TEST(ParseNull) { TestOk("Null", "(NullType)"); TestOk("Null?", "(OptionalType (NullType))"); TestOk("(Null?)->Null", @@ -492,12 +492,12 @@ Y_UNIT_TEST_SUITE(TTypeString) ")"); } - Y_UNIT_TEST(UnknownType) { + Y_UNIT_TEST(UnknownType) { TestFail("(Yson2)->String", 2, "Unknown type: 'Yson2'"); TestFail("()->", 5, "Expected type"); } - Y_UNIT_TEST(ParseTagged) { + Y_UNIT_TEST(ParseTagged) { TestOk("Tagged<Uint32, IdTag>", "(TaggedType (DataType 'Uint32) 'IdTag)"); } @@ -529,11 +529,11 @@ Y_UNIT_TEST_SUITE(TTypeString) UNIT_ASSERT_STRINGS_EQUAL(typeStr, expectedTypeStr); } - Y_UNIT_TEST(FormatUnit) { + Y_UNIT_TEST(FormatUnit) { TestFormat("(Unit)", "Unit"); } - Y_UNIT_TEST(FormatTuple) { + Y_UNIT_TEST(FormatTuple) { TestFormat("((Tuple " " (Data Int32) " " (Data Bool) " @@ -542,7 +542,7 @@ Y_UNIT_TEST_SUITE(TTypeString) "Tuple<Int32,Bool,String>"); } - Y_UNIT_TEST(FormatDataStruct) { + Y_UNIT_TEST(FormatDataStruct) { TestFormat("((Struct " " (Item Name (Data String))" " (Item Age (Data Uint32))" @@ -555,11 +555,11 @@ Y_UNIT_TEST_SUITE(TTypeString) TestFormat("((Data Decimal 10 3))", "Decimal(10,3)"); } - Y_UNIT_TEST(FormatList) { + Y_UNIT_TEST(FormatList) { TestFormat("((List (Data String)))", "List<String>"); } - Y_UNIT_TEST(FormatStream) { + Y_UNIT_TEST(FormatStream) { TestFormat("((Stream (Data String)))", "Stream<String>"); } @@ -567,12 +567,12 @@ Y_UNIT_TEST_SUITE(TTypeString) TestFormat("((Flow (Data String)))", "Flow<String>"); } - Y_UNIT_TEST(FormatOptional) { + Y_UNIT_TEST(FormatOptional) { TestFormat("((Optional (Data Uint32)))", "Uint32?"); TestFormat("((List (Optional (Data Uint32))))", "List<Uint32?>"); } - Y_UNIT_TEST(FormatVariant) { + Y_UNIT_TEST(FormatVariant) { TestFormat("((Variant (Tuple (Data String))))", "Variant<String>"); } @@ -580,7 +580,7 @@ Y_UNIT_TEST_SUITE(TTypeString) TestFormat("((Variant (Struct (Item a Void) (Item b Void) )))", "Enum<'a','b'>"); } - Y_UNIT_TEST(FormatDict) { + Y_UNIT_TEST(FormatDict) { TestFormat("((Dict " " (Data String)" " (Data Uint32)" @@ -596,7 +596,7 @@ Y_UNIT_TEST_SUITE(TTypeString) "Set<String>"); } - Y_UNIT_TEST(FormatCallable) { + Y_UNIT_TEST(FormatCallable) { TestFormat("((Callable () " " ((Data String))" " ((Data Uint32))" @@ -617,7 +617,7 @@ Y_UNIT_TEST_SUITE(TTypeString) "Callable<([Uint32?,Uint8?])->String>"); } - Y_UNIT_TEST(FormatOptionalCallable) { + Y_UNIT_TEST(FormatOptionalCallable) { TestFormat("((Optional (Callable () " " ((Data String))" " ((Optional (Data Uint8)))" @@ -631,7 +631,7 @@ Y_UNIT_TEST_SUITE(TTypeString) "Optional<Callable<(Uint8?)->String>>?"); } - Y_UNIT_TEST(FormatCallableWithNamedArgs) { + Y_UNIT_TEST(FormatCallableWithNamedArgs) { TestFormat("((Callable () " " ((Data String))" " ((Data Uint32) x)" @@ -645,7 +645,7 @@ Y_UNIT_TEST_SUITE(TTypeString) "Callable<('a':Uint8?{Flags:AutoMap})->String>"); } - Y_UNIT_TEST(FormatCallableWithPayload) { + Y_UNIT_TEST(FormatCallableWithPayload) { TestFormat("((Callable (0 MyFunction) " " ((Data String))" " ((Optional (Data Uint8)))" @@ -653,14 +653,14 @@ Y_UNIT_TEST_SUITE(TTypeString) "Callable<(Uint8?)->String{Payload:MyFunction}>"); } - Y_UNIT_TEST(FormatResource) { + Y_UNIT_TEST(FormatResource) { TestFormat("((Resource aaa))", "Resource<'aaa'>"); TestFormat("((Resource \"a b\"))", "Resource<'a b'>"); TestFormat("((Resource \"a\\t\\n\\x01b\"))", "Resource<'a\\t\\n\\x01b'>"); TestFormat("((Optional (Resource aaa)))", "Resource<'aaa'>?"); } - Y_UNIT_TEST(FormatTagged) { + Y_UNIT_TEST(FormatTagged) { TestFormat("((Tagged (Data String) aaa))", "Tagged<String,'aaa'>"); TestFormat("((Tagged (Data String) \"a b\"))", "Tagged<String,'a b'>"); TestFormat("((Tagged (Data String) \"a\\t\\n\\x01b\"))", "Tagged<String,'a\\t\\n\\x01b'>"); diff --git a/ydb/library/yql/core/expr_nodes/yql_expr_nodes.h b/ydb/library/yql/core/expr_nodes/yql_expr_nodes.h index 01cc7771185..c5e2a63bca1 100644 --- a/ydb/library/yql/core/expr_nodes/yql_expr_nodes.h +++ b/ydb/library/yql/core/expr_nodes/yql_expr_nodes.h @@ -155,7 +155,7 @@ public: } TNodeBuilder<TParent, TCoLambda>& Args(const TCoArguments& node) { - Y_VERIFY_DEBUG(!this->ArgsHolder.IsValid()); + Y_VERIFY_DEBUG(!this->ArgsHolder.IsValid()); this->ArgsHolder = node; return *this; @@ -163,7 +163,7 @@ public: TNodeBuilder<TParent, TCoLambda>& Args(std::initializer_list<TStringBuf> list) { - Y_VERIFY_DEBUG(!this->ArgsHolder.IsValid()); + Y_VERIFY_DEBUG(!this->ArgsHolder.IsValid()); TExprNode::TListType argNodes; for (auto name : list) { diff --git a/ydb/library/yql/core/facade/yql_facade.cpp b/ydb/library/yql/core/facade/yql_facade.cpp index b74abc1c34c..4744f63dac3 100644 --- a/ydb/library/yql/core/facade/yql_facade.cpp +++ b/ydb/library/yql/core/facade/yql_facade.cpp @@ -420,7 +420,7 @@ bool TProgram::ParseSql(const NSQLTranslation::TTranslationSettings& settings) bool TProgram::Compile(const TString& username) { YQL_PROFILE_FUNC(TRACE); - Y_ENSURE(AstRoot_, "Program not parsed yet"); + Y_ENSURE(AstRoot_, "Program not parsed yet"); if (!ExprCtx_) { ExprCtx_.Reset(new TExprContext(NextUniqueId_)); } @@ -599,9 +599,9 @@ TProgram::TFutureStatus TProgram::ValidateAsync(const TString& username, IOutput TProgram::TStatus TProgram::Optimize( const TString& username, - IOutputStream* traceOut, - IOutputStream* tracePlan, - IOutputStream* exprOut, + IOutputStream* traceOut, + IOutputStream* tracePlan, + IOutputStream* exprOut, bool withTypes) { YQL_PROFILE_FUNC(TRACE); @@ -611,9 +611,9 @@ TProgram::TStatus TProgram::Optimize( TProgram::TFutureStatus TProgram::OptimizeAsync( const TString& username, - IOutputStream* traceOut, - IOutputStream* tracePlan, - IOutputStream* exprOut, + IOutputStream* traceOut, + IOutputStream* tracePlan, + IOutputStream* exprOut, bool withTypes) { if (!ProvideAnnotationContext(username)->Initialize(*ExprCtx_) || !CollectUsedClusters()) { @@ -740,9 +740,9 @@ TProgram::TFutureStatus TProgram::OptimizeAsyncWithConfig( TProgram::TStatus TProgram::Run( const TString& username, - IOutputStream* traceOut, - IOutputStream* tracePlan, - IOutputStream* exprOut, + IOutputStream* traceOut, + IOutputStream* tracePlan, + IOutputStream* exprOut, bool withTypes) { YQL_PROFILE_FUNC(TRACE); @@ -752,9 +752,9 @@ TProgram::TStatus TProgram::Run( TProgram::TFutureStatus TProgram::RunAsync( const TString& username, - IOutputStream* traceOut, - IOutputStream* tracePlan, - IOutputStream* exprOut, + IOutputStream* traceOut, + IOutputStream* tracePlan, + IOutputStream* exprOut, bool withTypes) { if (!ProvideAnnotationContext(username)->Initialize(*ExprCtx_) || !CollectUsedClusters()) { diff --git a/ydb/library/yql/core/facade/yql_facade.h b/ydb/library/yql/core/facade/yql_facade.h index 1f8f47681da..1c307619fae 100644 --- a/ydb/library/yql/core/facade/yql_facade.h +++ b/ydb/library/yql/core/facade/yql_facade.h @@ -112,30 +112,30 @@ public: TStatus Optimize( const TString& username, - IOutputStream* traceOut = nullptr, - IOutputStream* tracePlan = nullptr, - IOutputStream* exprOut = nullptr, + IOutputStream* traceOut = nullptr, + IOutputStream* tracePlan = nullptr, + IOutputStream* exprOut = nullptr, bool withTypes = false); TFutureStatus OptimizeAsync( const TString& username, - IOutputStream* traceOut = nullptr, - IOutputStream* tracePlan = nullptr, - IOutputStream* exprOut = nullptr, + IOutputStream* traceOut = nullptr, + IOutputStream* tracePlan = nullptr, + IOutputStream* exprOut = nullptr, bool withTypes = false); TStatus Run( const TString& username, - IOutputStream* traceOut = nullptr, - IOutputStream* tracePlan = nullptr, - IOutputStream* exprOut = nullptr, + IOutputStream* traceOut = nullptr, + IOutputStream* tracePlan = nullptr, + IOutputStream* exprOut = nullptr, bool withTypes = false); TFutureStatus RunAsync( const TString& username, - IOutputStream* traceOut = nullptr, - IOutputStream* tracePlan = nullptr, - IOutputStream* exprOut = nullptr, + IOutputStream* traceOut = nullptr, + IOutputStream* tracePlan = nullptr, + IOutputStream* exprOut = nullptr, bool withTypes = false); TStatus OptimizeWithConfig( @@ -178,7 +178,7 @@ public: void Print(IOutputStream* exprOut, IOutputStream* planOut, bool cleanPlan = false); - inline void PrintErrorsTo(IOutputStream& out) const { + inline void PrintErrorsTo(IOutputStream& out) const { if (ExprCtx_) { ExprCtx_->IssueManager.GetIssues().PrintWithProgramTo(out, Filename_, SourceCode_); } @@ -224,8 +224,8 @@ public: TString ResultsAsString() const; void ConfigureYsonResultFormat(NYson::EYsonFormat format); - inline IOutputStream* ExprStream() const { return ExprStream_; } - inline IOutputStream* PlanStream() const { return PlanStream_; } + inline IOutputStream* ExprStream() const { return ExprStream_; } + inline IOutputStream* PlanStream() const { return PlanStream_; } NYson::EYsonFormat GetResultFormat() const { return ResultFormat_; } NYson::EYsonFormat GetOutputFormat() const { return OutputFormat_; } @@ -380,8 +380,8 @@ private: TMaybe<TString> ExternalQueryPlan_; TMaybe<TString> ExternalDiagnostics_; - IOutputStream* ExprStream_ = nullptr; - IOutputStream* PlanStream_ = nullptr; + IOutputStream* ExprStream_ = nullptr; + IOutputStream* PlanStream_ = nullptr; TOperationProgressWriter ProgressWriter_ = [](const TOperationProgress&) {}; TString ExtractedQueryParametersMetadataYson_; const bool EnableRangeComputeFor_; diff --git a/ydb/library/yql/core/file_storage/file_storage_ut.cpp b/ydb/library/yql/core/file_storage/file_storage_ut.cpp index 5103fdd31dc..dab468c9ce0 100644 --- a/ydb/library/yql/core/file_storage/file_storage_ut.cpp +++ b/ydb/library/yql/core/file_storage/file_storage_ut.cpp @@ -16,7 +16,7 @@ using namespace NYql; using namespace NThreading; -Y_UNIT_TEST_SUITE(TFileStorageTests) { +Y_UNIT_TEST_SUITE(TFileStorageTests) { static TString ReadFileContent(const TString& path) { return TIFStream(path).ReadAll(); @@ -53,7 +53,7 @@ Y_UNIT_TEST_SUITE(TFileStorageTests) { return "W/" + strongETag; } - Y_UNIT_TEST(PutUrlNoTokenNoETag) { + Y_UNIT_TEST(PutUrlNoTokenNoETag) { auto server = CreateTestHttpServer(); int downloadCount = 0; @@ -82,7 +82,7 @@ Y_UNIT_TEST_SUITE(TFileStorageTests) { UNIT_ASSERT_VALUES_EQUAL("ABC", ReadFileContent(link2->GetPath())); } - Y_UNIT_TEST(PutUrlNoAccessForBadToken) { + Y_UNIT_TEST(PutUrlNoAccessForBadToken) { auto server = CreateTestHttpServer(); TString okToken = "TOKEN_1"; @@ -110,7 +110,7 @@ Y_UNIT_TEST_SUITE(TFileStorageTests) { UNIT_ASSERT_EXCEPTION_CONTAINS(fs->PutUrl(url, badToken), std::exception, "Failed to fetch url"); } - Y_UNIT_TEST(PutUrlETagChange) { + Y_UNIT_TEST(PutUrlETagChange) { auto server = CreateTestHttpServer(); TString currentETag = "TAG_1"; @@ -196,7 +196,7 @@ Y_UNIT_TEST_SUITE(TFileStorageTests) { UNIT_ASSERT_VALUES_EQUAL(link3->GetMd5(), link4->GetMd5()); } - Y_UNIT_TEST(PutUrlETagChangeButNoSupportForIfNoneMatch) { + Y_UNIT_TEST(PutUrlETagChangeButNoSupportForIfNoneMatch) { auto server = CreateTestHttpServer(); TString currentETag = "TAG_1"; @@ -236,7 +236,7 @@ Y_UNIT_TEST_SUITE(TFileStorageTests) { UNIT_ASSERT_VALUES_EQUAL(link3->GetMd5(), link4->GetMd5()); } - Y_UNIT_TEST(PutUrlWeakETagChange) { + Y_UNIT_TEST(PutUrlWeakETagChange) { auto server = CreateTestHttpServer(); TString currentETag = "TAG_1"; @@ -277,7 +277,7 @@ Y_UNIT_TEST_SUITE(TFileStorageTests) { UNIT_ASSERT_VALUES_EQUAL("XYZPQAZWSXEDC", ReadFileContent(link4->GetPath())); } - Y_UNIT_TEST(SecondPutUrlNoETagButFileRemoved) { + Y_UNIT_TEST(SecondPutUrlNoETagButFileRemoved) { auto server = CreateTestHttpServer(); int downloadCount = 0; @@ -306,7 +306,7 @@ Y_UNIT_TEST_SUITE(TFileStorageTests) { UNIT_ASSERT_VALUES_EQUAL("ABC", ReadFileContent(link2->GetPath())); } - Y_UNIT_TEST(SecondPutUrlETagButFileRemoved) { + Y_UNIT_TEST(SecondPutUrlETagButFileRemoved) { auto server = CreateTestHttpServer(); int downloadCount = 0; @@ -336,7 +336,7 @@ Y_UNIT_TEST_SUITE(TFileStorageTests) { UNIT_ASSERT_VALUES_EQUAL("ABC", ReadFileContent(link2->GetPath())); } - Y_UNIT_TEST(SecondPutUrlETagButMetaRemoved) { + Y_UNIT_TEST(SecondPutUrlETagButMetaRemoved) { auto server = CreateTestHttpServer(); int downloadCount = 0; @@ -366,7 +366,7 @@ Y_UNIT_TEST_SUITE(TFileStorageTests) { UNIT_ASSERT_VALUES_EQUAL("ABC", ReadFileContent(link2->GetPath())); } - Y_UNIT_TEST(Md5ForPutFiles) { + Y_UNIT_TEST(Md5ForPutFiles) { TString currentContent = "ABC"; TFileStoragePtr fs = CreateTestFS(); @@ -396,7 +396,7 @@ Y_UNIT_TEST_SUITE(TFileStorageTests) { UNIT_ASSERT_VALUES_UNEQUAL(link3->GetMd5(), link4->GetMd5()); } - Y_UNIT_TEST(NoUrlDownloadRetryOnBadCode) { + Y_UNIT_TEST(NoUrlDownloadRetryOnBadCode) { auto server = CreateTestHttpServer(); int downloadCount = 0; diff --git a/ydb/library/yql/core/file_storage/sized_cache.cpp b/ydb/library/yql/core/file_storage/sized_cache.cpp index fe17d895d05..18a9f5fd887 100644 --- a/ydb/library/yql/core/file_storage/sized_cache.cpp +++ b/ydb/library/yql/core/file_storage/sized_cache.cpp @@ -9,8 +9,8 @@ TSizedCache::TSizedCache(size_t maxEntries, ui64 maxSize) , MaxEntries(maxEntries) , MaxSize(maxSize) { - Y_ASSERT(MaxEntries > 0); - Y_ASSERT(MaxSize > 0); + Y_ASSERT(MaxEntries > 0); + Y_ASSERT(MaxSize > 0); } void TSizedCache::Put(const TIntrusivePtr<ICacheObj>& obj, bool lock) { @@ -38,9 +38,9 @@ void TSizedCache::Release(const TString& name, bool remove) { auto guard = Guard(Lock); auto it = Cache.FindWithoutPromote(name); if (it == Cache.End()) { - Y_ASSERT(false); + Y_ASSERT(false); } else { - Y_ASSERT(it->Locks); + Y_ASSERT(it->Locks); if (it->Locks) { --it->Locks; } @@ -66,7 +66,7 @@ TIntrusivePtr<TSizedCache::ICacheObj> TSizedCache::Revoke(const TString& name) { TIntrusivePtr<TSizedCache::ICacheObj> res; if (it != Cache.End()) { res = it->Obj; - Y_ASSERT(CurrentSize >= res->GetSize()); + Y_ASSERT(CurrentSize >= res->GetSize()); CurrentSize -= res->GetSize(); Cache.Erase(it); } @@ -85,7 +85,7 @@ TMaybe<ui32> TSizedCache::GetLocks(const TString& name) const { void TSizedCache::Remove(TCache::TIterator it) { TIntrusivePtr<TSizedCache::ICacheObj> obj = it->Obj; - Y_ASSERT(CurrentSize >= obj->GetSize()); + Y_ASSERT(CurrentSize >= obj->GetSize()); CurrentSize -= obj->GetSize(); Cache.Erase(it); // Dismissing may take a long time. Unlock temporary diff --git a/ydb/library/yql/core/file_storage/sized_cache_ut.cpp b/ydb/library/yql/core/file_storage/sized_cache_ut.cpp index b0e41e5c62b..028d850b0ce 100644 --- a/ydb/library/yql/core/file_storage/sized_cache_ut.cpp +++ b/ydb/library/yql/core/file_storage/sized_cache_ut.cpp @@ -27,8 +27,8 @@ struct TTestCacheObj: public TSizedCache::ICacheObj { bool Dismissed; }; -Y_UNIT_TEST_SUITE(TSizedCacheTests) { - Y_UNIT_TEST(Count) { +Y_UNIT_TEST_SUITE(TSizedCacheTests) { + Y_UNIT_TEST(Count) { TSizedCache cache(100, 100); TIntrusivePtr<TTestCacheObj> o1 = MakeIntrusive<TTestCacheObj>("o1", 10ull); TIntrusivePtr<TTestCacheObj> o2 = MakeIntrusive<TTestCacheObj>("o2", 20ull); @@ -47,7 +47,7 @@ Y_UNIT_TEST_SUITE(TSizedCacheTests) { UNIT_ASSERT_VALUES_EQUAL(cache.GetCount(), 3); } - Y_UNIT_TEST(GetOccupiedSize) { + Y_UNIT_TEST(GetOccupiedSize) { TSizedCache cache(100, 100); TIntrusivePtr<TTestCacheObj> o1 = MakeIntrusive<TTestCacheObj>("o1", 10ull); TIntrusivePtr<TTestCacheObj> o2 = MakeIntrusive<TTestCacheObj>("o2", 20ull); @@ -66,7 +66,7 @@ Y_UNIT_TEST_SUITE(TSizedCacheTests) { UNIT_ASSERT_VALUES_EQUAL(cache.GetOccupiedSize(), 45); } - Y_UNIT_TEST(DisplaceByCount) { + Y_UNIT_TEST(DisplaceByCount) { TSizedCache cache(2, 100); TIntrusivePtr<TTestCacheObj> o1 = MakeIntrusive<TTestCacheObj>("o1", 10ull); TIntrusivePtr<TTestCacheObj> o2 = MakeIntrusive<TTestCacheObj>("o2", 20ull); @@ -82,7 +82,7 @@ Y_UNIT_TEST_SUITE(TSizedCacheTests) { UNIT_ASSERT(!o3->Dismissed); } - Y_UNIT_TEST(DisplaceBySize) { + Y_UNIT_TEST(DisplaceBySize) { TSizedCache cache(100, 35); TIntrusivePtr<TTestCacheObj> o1 = MakeIntrusive<TTestCacheObj>("o1", 10ull); TIntrusivePtr<TTestCacheObj> o2 = MakeIntrusive<TTestCacheObj>("o2", 20ull); @@ -98,7 +98,7 @@ Y_UNIT_TEST_SUITE(TSizedCacheTests) { UNIT_ASSERT(!o3->Dismissed); } - Y_UNIT_TEST(Lock) { + Y_UNIT_TEST(Lock) { TSizedCache cache(2, 30); TIntrusivePtr<TTestCacheObj> o1 = MakeIntrusive<TTestCacheObj>("o1", 10ull); TIntrusivePtr<TTestCacheObj> o2 = MakeIntrusive<TTestCacheObj>("o2", 20ull); @@ -122,7 +122,7 @@ Y_UNIT_TEST_SUITE(TSizedCacheTests) { UNIT_ASSERT(!o3->Dismissed); } - Y_UNIT_TEST(MultiLock) { + Y_UNIT_TEST(MultiLock) { TSizedCache cache(2, 30); TIntrusivePtr<TTestCacheObj> o1 = MakeIntrusive<TTestCacheObj>("o1", 10ull); TIntrusivePtr<TTestCacheObj> o2 = MakeIntrusive<TTestCacheObj>("o2", 20ull); diff --git a/ydb/library/yql/core/file_storage/storage_ut.cpp b/ydb/library/yql/core/file_storage/storage_ut.cpp index 4229abd2199..3c069ff468d 100644 --- a/ydb/library/yql/core/file_storage/storage_ut.cpp +++ b/ydb/library/yql/core/file_storage/storage_ut.cpp @@ -17,7 +17,7 @@ using namespace NThreading; static TString DATA = "1234567890"; static TString DATA_MD5 = "e807f1fcf82d132f9bb018ca6738a19f"; -Y_UNIT_TEST_SUITE(TStorageTests) { +Y_UNIT_TEST_SUITE(TStorageTests) { class TTestDir { private: @@ -56,7 +56,7 @@ Y_UNIT_TEST_SUITE(TStorageTests) { return PutFile(name, storage, {}, 1); } - Y_UNIT_TEST(Put) { + Y_UNIT_TEST(Put) { THolder<TStorage> storage = MakeHolder<TStorage>(10, 100); TFileLinkPtr fileInStorage = PutFile("test.file", *storage, "somename"); TFsPath rootPath(fileInStorage->GetPath()); @@ -71,7 +71,7 @@ Y_UNIT_TEST_SUITE(TStorageTests) { UNIT_ASSERT(false == rootPath.Exists()); } - Y_UNIT_TEST(ParallelPut) { + Y_UNIT_TEST(ParallelPut) { THolder<TStorage> storage = MakeHolder<TStorage>(10, 100); TThreadPool queue; queue.Start(10); @@ -95,7 +95,7 @@ Y_UNIT_TEST_SUITE(TStorageTests) { } } - Y_UNIT_TEST(CleanUp) { + Y_UNIT_TEST(CleanUp) { THolder<TStorage> storage = MakeHolder<TStorage>(10, 100); TFileLinkPtr fileInStorage = PutFile("test.file", *storage); UNIT_ASSERT(fileInStorage->GetPath().Exists()); @@ -106,7 +106,7 @@ Y_UNIT_TEST_SUITE(TStorageTests) { UNIT_ASSERT(!rootPath.Exists()); } - Y_UNIT_TEST(DisplaceByCount) { + Y_UNIT_TEST(DisplaceByCount) { ui64 maxCount = 2; THolder<TStorage> storage = MakeHolder<TStorage>(maxCount, 100); @@ -143,7 +143,7 @@ Y_UNIT_TEST_SUITE(TStorageTests) { UNIT_ASSERT(Find(beg, end, file3->GetStorageFileName()) != end); } - Y_UNIT_TEST(DisplaceBySize) { + Y_UNIT_TEST(DisplaceBySize) { ui64 maxSize = 25; THolder<TStorage> storage = MakeHolder<TStorage>(10, maxSize); @@ -180,7 +180,7 @@ Y_UNIT_TEST_SUITE(TStorageTests) { UNIT_ASSERT(Find(beg, end, file3->GetStorageFileName()) != end); } - Y_UNIT_TEST(PersistStorage) { + Y_UNIT_TEST(PersistStorage) { TTestDir dir("PersistStorage"); THolder<TStorage> storage = MakeHolder<TStorage>(100, 100, dir.GetFsPath()); auto rootPath = storage->GetRoot(); diff --git a/ydb/library/yql/core/file_storage/url_mapper_ut.cpp b/ydb/library/yql/core/file_storage/url_mapper_ut.cpp index 287caf054c9..725d6dbdbd8 100644 --- a/ydb/library/yql/core/file_storage/url_mapper_ut.cpp +++ b/ydb/library/yql/core/file_storage/url_mapper_ut.cpp @@ -11,8 +11,8 @@ void RemapAndCheck(const TUrlMapper& m, const TString& input, const TString& exp } } -Y_UNIT_TEST_SUITE(TUrlMapperTests) { - Y_UNIT_TEST(All) { +Y_UNIT_TEST_SUITE(TUrlMapperTests) { + Y_UNIT_TEST(All) { TUrlMapper m; m.AddMapping("sbr:(?://)?(\\d+)", "http://proxy.sandbox.yandex-team.ru/$1"); diff --git a/ydb/library/yql/core/issue/yql_issue_ut.cpp b/ydb/library/yql/core/issue/yql_issue_ut.cpp index fa8f97e63a3..eb51c9624b7 100644 --- a/ydb/library/yql/core/issue/yql_issue_ut.cpp +++ b/ydb/library/yql/core/issue/yql_issue_ut.cpp @@ -4,8 +4,8 @@ using namespace NYql; -Y_UNIT_TEST_SUITE(TIssuesDataTest) { - Y_UNIT_TEST(SeverityMapTest) { +Y_UNIT_TEST_SUITE(TIssuesDataTest) { + Y_UNIT_TEST(SeverityMapTest) { auto severity = GetSeverity(TIssuesIds::UNEXPECTED); auto severityName = SeverityToString(severity); UNIT_ASSERT_VALUES_EQUAL(static_cast<ui32>(severity), @@ -13,17 +13,17 @@ Y_UNIT_TEST_SUITE(TIssuesDataTest) { UNIT_ASSERT_VALUES_EQUAL(severityName, "Fatal"); } - Y_UNIT_TEST(UnknownSeverityNameTest) { + Y_UNIT_TEST(UnknownSeverityNameTest) { auto severityName = SeverityToString(static_cast<ESeverity>(999)); UNIT_ASSERT_VALUES_EQUAL(severityName, "Unknown"); } - Y_UNIT_TEST(IssueNameTest) { + Y_UNIT_TEST(IssueNameTest) { auto issueName = IssueCodeToString(TIssuesIds::DEFAULT_ERROR); UNIT_ASSERT_VALUES_EQUAL(issueName, "Default error"); } - Y_UNIT_TEST(IssueDefaultErrorNumber) { + Y_UNIT_TEST(IssueDefaultErrorNumber) { UNIT_ASSERT_VALUES_EQUAL((ui32)TIssuesIds::DEFAULT_ERROR, 0); } diff --git a/ydb/library/yql/core/type_ann/type_ann_core.cpp b/ydb/library/yql/core/type_ann/type_ann_core.cpp index 5846e6cb108..c16becbaaa9 100644 --- a/ydb/library/yql/core/type_ann/type_ann_core.cpp +++ b/ydb/library/yql/core/type_ann/type_ann_core.cpp @@ -10915,7 +10915,7 @@ template <NKikimr::NUdf::EDataSlot DataSlot> const auto resourceType = resourceArg->GetTypeAnn()->Cast<TResourceExprType>(); const auto resourceTag = resourceType->GetTag(); using NKikimr::NMiniKQL::ResourceQueuePrefix; - if (!resourceTag.StartsWith(ResourceQueuePrefix)) { + if (!resourceTag.StartsWith(ResourceQueuePrefix)) { ctx.Expr.AddError(TIssue(ctx.Expr.GetPosition(resourceArg->Pos()), "You should use resource from QueueCreate")); return false; } diff --git a/ydb/library/yql/core/yql_csv.cpp b/ydb/library/yql/core/yql_csv.cpp index 259b6144f1b..7d1b20e920b 100644 --- a/ydb/library/yql/core/yql_csv.cpp +++ b/ydb/library/yql/core/yql_csv.cpp @@ -76,7 +76,7 @@ namespace NUtils { /////////////////////////////////////////////////////////////////////////////// // TCsvInputStream /////////////////////////////////////////////////////////////////////////////// -TCsvInputStream::TCsvInputStream(IInputStream& slave, char delimiter) +TCsvInputStream::TCsvInputStream(IInputStream& slave, char delimiter) : Slave_(slave) , Delim_(delimiter) { @@ -159,7 +159,7 @@ TVector<TString> TCsvInputBuffer::ReadLineWithEscaping() /////////////////////////////////////////////////////////////////////////////// // TCsvOutputStream /////////////////////////////////////////////////////////////////////////////// -TCsvOutputStream::TCsvOutputStream(IOutputStream& slave, char delimiter, bool quoteItems) +TCsvOutputStream::TCsvOutputStream(IOutputStream& slave, char delimiter, bool quoteItems) : Slave_(slave) , WasNL_(true) , Delim_(delimiter) diff --git a/ydb/library/yql/core/yql_csv.h b/ydb/library/yql/core/yql_csv.h index 6e3e48b816f..b6ed3552976 100644 --- a/ydb/library/yql/core/yql_csv.h +++ b/ydb/library/yql/core/yql_csv.h @@ -12,13 +12,13 @@ namespace NUtils { /////////////////////////////////////////////////////////////////////////////// class TCsvInputStream { public: - TCsvInputStream(IInputStream& slave, char delimiter = ';'); + TCsvInputStream(IInputStream& slave, char delimiter = ';'); TVector<TString> ReadLine(); TVector<TString> ReadLineWithEscaping(); private: - IInputStream& Slave_; + IInputStream& Slave_; const char Delim_; }; @@ -42,9 +42,9 @@ private: /////////////////////////////////////////////////////////////////////////////// // TCsvOutputStream /////////////////////////////////////////////////////////////////////////////// -class TCsvOutputStream: public IOutputStream { +class TCsvOutputStream: public IOutputStream { public: - TCsvOutputStream(IOutputStream& slave, char delimiter = ';', bool quoteItems = true); + TCsvOutputStream(IOutputStream& slave, char delimiter = ';', bool quoteItems = true); // hack for output empty values inline TCsvOutputStream& operator<<(const TString& value) { @@ -71,7 +71,7 @@ private: void DoFlush() override; private: - IOutputStream& Slave_; + IOutputStream& Slave_; bool WasNL_; const char Delim_; const bool QuoteItems_; diff --git a/ydb/library/yql/core/yql_execution.cpp b/ydb/library/yql/core/yql_execution.cpp index eb138b1b4f3..5f4f8fc1904 100644 --- a/ydb/library/yql/core/yql_execution.cpp +++ b/ydb/library/yql/core/yql_execution.cpp @@ -884,7 +884,7 @@ IGraphTransformer::TStatus RequireChild(const TExprNode& node, ui32 index) { } template<> -void Out<NYql::TOperationProgress::EState>(class IOutputStream &o, NYql::TOperationProgress::EState x) { +void Out<NYql::TOperationProgress::EState>(class IOutputStream &o, NYql::TOperationProgress::EState x) { #define YQL_OPERATION_PROGRESS_STATE_MAP_TO_STRING_IMPL(name, ...) \ case NYql::TOperationProgress::EState::name: \ o << #name; \ diff --git a/ydb/library/yql/core/yql_graph_transformer.cpp b/ydb/library/yql/core/yql_graph_transformer.cpp index 26193c4c400..841395ee4d5 100644 --- a/ydb/library/yql/core/yql_graph_transformer.cpp +++ b/ydb/library/yql/core/yql_graph_transformer.cpp @@ -389,7 +389,7 @@ void AsyncTransform(IGraphTransformer& transformer, TExprNode::TPtr& root, TExpr } template<> -void Out<NYql::IGraphTransformer::TStatus::ELevel>(class IOutputStream &o, NYql::IGraphTransformer::TStatus::ELevel x) { +void Out<NYql::IGraphTransformer::TStatus::ELevel>(class IOutputStream &o, NYql::IGraphTransformer::TStatus::ELevel x) { #define YQL_GT_STATUS_MAP_TO_STRING_IMPL(name, ...) \ case NYql::IGraphTransformer::TStatus::name: \ o << #name; \ diff --git a/ydb/library/yql/core/yql_graph_transformer.h b/ydb/library/yql/core/yql_graph_transformer.h index 60d87727dd8..a35ad3f6cdb 100644 --- a/ydb/library/yql/core/yql_graph_transformer.h +++ b/ydb/library/yql/core/yql_graph_transformer.h @@ -62,7 +62,7 @@ public: return TStatus((TStatus::ELevel)Max(Level, other.Level), hasRestart); } - void Out(IOutputStream &out) const { + void Out(IOutputStream &out) const { out << (TStatus::ELevel)Level; if (HasRestart) { out << ", with restart"; @@ -236,14 +236,14 @@ void AsyncTransform(IGraphTransformer& transformer, TExprNode::TPtr& root, TExpr class TSyncTransformerBase : public TGraphTransformerBase { public: NThreading::TFuture<void> DoGetAsyncFuture(const TExprNode& input) final { - Y_UNUSED(input); + Y_UNUSED(input); YQL_ENSURE(false, "Not supported"); } TStatus DoApplyAsyncChanges(TExprNode::TPtr input, TExprNode::TPtr& output, TExprContext& ctx) final { - Y_UNUSED(input); - Y_UNUSED(output); - Y_UNUSED(ctx); + Y_UNUSED(input); + Y_UNUSED(output); + Y_UNUSED(ctx); YQL_ENSURE(false, "Not supported"); } }; @@ -396,7 +396,7 @@ typedef std::unordered_map<TExprNode::TPtr, ui64, TExprNode::TPtrHash> TSyncMap; template<> inline void Out<NYql::IGraphTransformer::TStatus>( - IOutputStream &out, const NYql::IGraphTransformer::TStatus& status) + IOutputStream &out, const NYql::IGraphTransformer::TStatus& status) { status.Out(out); } diff --git a/ydb/library/yql/minikql/aligned_page_pool.cpp b/ydb/library/yql/minikql/aligned_page_pool.cpp index e015c255c81..0c6b34f10b5 100644 --- a/ydb/library/yql/minikql/aligned_page_pool.cpp +++ b/ydb/library/yql/minikql/aligned_page_pool.cpp @@ -211,7 +211,7 @@ void* TAlignedPagePool::GetPage() { } if (const auto ptr = TGlobalPools::Instance().Get(0).GetPage()) { - TotalAllocated += POOL_PAGE_SIZE; + TotalAllocated += POOL_PAGE_SIZE; if (AllocNotifyCallback) { AllocNotifyCurrentBytes += POOL_PAGE_SIZE; } @@ -409,10 +409,10 @@ ui64 TAlignedPagePool::GetGlobalPagePoolSize() { return size; } -void TAlignedPagePool::PrintStat(size_t usedPages, IOutputStream& out) const { +void TAlignedPagePool::PrintStat(size_t usedPages, IOutputStream& out) const { usedPages += GetFreePageCount(); out << "Count of free pages: " << GetFreePageCount() << Endl; - out << "Allocated for blocks: " << (GetAllocated() - usedPages * TAlignedPagePool::POOL_PAGE_SIZE) << Endl; + out << "Allocated for blocks: " << (GetAllocated() - usedPages * TAlignedPagePool::POOL_PAGE_SIZE) << Endl; out << "Total allocated by lists: " << GetAllocated() << Endl; } diff --git a/ydb/library/yql/minikql/aligned_page_pool.h b/ydb/library/yql/minikql/aligned_page_pool.h index 2ef28786554..92e35c8ef2b 100644 --- a/ydb/library/yql/minikql/aligned_page_pool.h +++ b/ydb/library/yql/minikql/aligned_page_pool.h @@ -37,8 +37,8 @@ class TMemoryLimitExceededException {}; class TAlignedPagePool { public: - static constexpr ui64 POOL_PAGE_SIZE = 1ULL << 16; // 64k - static constexpr ui64 PAGE_ADDR_MASK = ~(POOL_PAGE_SIZE - 1); + static constexpr ui64 POOL_PAGE_SIZE = 1ULL << 16; // 64k + static constexpr ui64 PAGE_ADDR_MASK = ~(POOL_PAGE_SIZE - 1); explicit TAlignedPagePool(const TAlignedPagePoolCounters& counters = TAlignedPagePoolCounters()) : Counters(counters) @@ -61,7 +61,7 @@ public: } inline size_t GetUsed() const noexcept { - return TotalAllocated - GetFreePageCount() * POOL_PAGE_SIZE; + return TotalAllocated - GetFreePageCount() * POOL_PAGE_SIZE; } inline size_t GetFreePageCount() const noexcept { @@ -102,7 +102,7 @@ public: DoSwap(IncreaseMemoryLimitCallback, other.IncreaseMemoryLimitCallback); } - void PrintStat(size_t usedPages, IOutputStream& out) const; + void PrintStat(size_t usedPages, IOutputStream& out) const; void* GetBlock(size_t size); diff --git a/ydb/library/yql/minikql/codegen/codegen_ut.cpp b/ydb/library/yql/minikql/codegen/codegen_ut.cpp index 332e3fdcdc7..1db3bc290a3 100644 --- a/ydb/library/yql/minikql/codegen/codegen_ut.cpp +++ b/ydb/library/yql/minikql/codegen/codegen_ut.cpp @@ -244,9 +244,9 @@ Function *CreateUseExternalFromGeneratedFunction128(const ICodegen::TPtr& codege } #if !defined(_ubsan_enabled_) && !defined(HAVE_VALGRIND) -Y_UNIT_TEST_SUITE(TCodegenTests) { +Y_UNIT_TEST_SUITE(TCodegenTests) { - Y_UNIT_TEST(FibNative) { + Y_UNIT_TEST(FibNative) { auto codegen = ICodegen::Make(ETarget::Native); auto func = CreateFibFunction(codegen->GetModule(), codegen->GetContext()); codegen->Verify(); @@ -256,7 +256,7 @@ Y_UNIT_TEST_SUITE(TCodegenTests) { UNIT_ASSERT_VALUES_EQUAL(funcPtr(24), 46368); } - Y_UNIT_TEST(FibCurrentOS) { + Y_UNIT_TEST(FibCurrentOS) { auto codegen = ICodegen::Make(ETarget::CurrentOS); auto func = CreateFibFunction(codegen->GetModule(), codegen->GetContext()); codegen->Verify(); @@ -266,13 +266,13 @@ Y_UNIT_TEST_SUITE(TCodegenTests) { UNIT_ASSERT_VALUES_EQUAL(funcPtr(24), 46368); } - Y_UNIT_TEST(BadFib) { + Y_UNIT_TEST(BadFib) { auto codegen = ICodegen::Make(ETarget::Native); auto func = CreateBadFibFunction(codegen->GetModule(), codegen->GetContext()); UNIT_ASSERT_EXCEPTION(codegen->Verify(), yexception); } - Y_UNIT_TEST(FibFromBitCode) { + Y_UNIT_TEST(FibFromBitCode) { auto codegen = ICodegen::Make(ETarget::Native); auto bitcode = NResource::Find("/llvm_bc/Funcs"); codegen->LoadBitCode(bitcode, "Funcs"); @@ -285,7 +285,7 @@ Y_UNIT_TEST_SUITE(TCodegenTests) { UNIT_ASSERT_VALUES_EQUAL(funcPtr(24), 46368); } - Y_UNIT_TEST(LinkWithNativeFunction) { + Y_UNIT_TEST(LinkWithNativeFunction) { auto codegen = ICodegen::Make(ETarget::Native); auto bitcode = NResource::Find("/llvm_bc/Funcs"); codegen->LoadBitCode(bitcode, "Funcs"); @@ -299,7 +299,7 @@ Y_UNIT_TEST_SUITE(TCodegenTests) { UNIT_ASSERT_VALUES_EQUAL(funcPtr(3, 4), 14); } - Y_UNIT_TEST(LinkWithGeneratedFunction) { + Y_UNIT_TEST(LinkWithGeneratedFunction) { auto codegen = ICodegen::Make(ETarget::Native); auto mulFunc = CreateMulFunction(codegen->GetModule(), codegen->GetContext()); auto bitcode = NResource::Find("/llvm_bc/Funcs"); @@ -313,7 +313,7 @@ Y_UNIT_TEST_SUITE(TCodegenTests) { UNIT_ASSERT_VALUES_EQUAL(funcPtr(3, 4), 25); } - Y_UNIT_TEST(ReuseExternalCode) { + Y_UNIT_TEST(ReuseExternalCode) { auto codegen = ICodegen::Make(ETarget::Native); auto bitcode = NResource::Find("/llvm_bc/Funcs"); codegen->LoadBitCode(bitcode, "Funcs"); @@ -326,7 +326,7 @@ Y_UNIT_TEST_SUITE(TCodegenTests) { UNIT_ASSERT_VALUES_EQUAL(funcPtr(3, 4), 25); } - Y_UNIT_TEST(UseObjectReference) { + Y_UNIT_TEST(UseObjectReference) { auto codegen = ICodegen::Make(ETarget::Native); auto bitcode = NResource::Find("/llvm_bc/Funcs"); codegen->LoadBitCode(bitcode, "Funcs"); @@ -340,7 +340,7 @@ Y_UNIT_TEST_SUITE(TCodegenTests) { UNIT_ASSERT_VALUES_EQUAL(funcPtr(hw), 12); } - Y_UNIT_TEST(UseNativeFromGeneratedFunction) { + Y_UNIT_TEST(UseNativeFromGeneratedFunction) { auto codegen = ICodegen::Make(ETarget::Native); auto func = CreateUseNativeFunction(codegen->GetModule(), codegen->GetContext()); codegen->AddGlobalMapping("mul", (void*)&mul); @@ -352,7 +352,7 @@ Y_UNIT_TEST_SUITE(TCodegenTests) { UNIT_ASSERT_VALUES_EQUAL(funcPtr(3, 4), 12); } - Y_UNIT_TEST(UseExternalFromGeneratedFunction) { + Y_UNIT_TEST(UseExternalFromGeneratedFunction) { auto codegen = ICodegen::Make(ETarget::Native); auto bitcode = NResource::Find("/llvm_bc/Funcs"); codegen->LoadBitCode(bitcode, "Funcs"); @@ -366,7 +366,7 @@ Y_UNIT_TEST_SUITE(TCodegenTests) { UNIT_ASSERT_VALUES_EQUAL(funcPtr(7, 4, 8), 4289); } - Y_UNIT_TEST(UseExternalFromGeneratedFunction_128bit_Compiled) { + Y_UNIT_TEST(UseExternalFromGeneratedFunction_128bit_Compiled) { auto codegen = ICodegen::Make(ETarget::Native); auto bitcode = NResource::Find("/llvm_bc/Funcs"); codegen->LoadBitCode(bitcode, "Funcs"); @@ -392,7 +392,7 @@ Y_UNIT_TEST_SUITE(TCodegenTests) { #endif } - Y_UNIT_TEST(UseExternalFromGeneratedFunction_128bit_Bitcode) { + Y_UNIT_TEST(UseExternalFromGeneratedFunction_128bit_Bitcode) { auto codegen = ICodegen::Make(ETarget::Native); auto bitcode = NResource::Find("/llvm_bc/Funcs"); codegen->LoadBitCode(bitcode, "Funcs"); diff --git a/ydb/library/yql/minikql/comp_nodes/ut/mkql_computation_node_ut.cpp b/ydb/library/yql/minikql/comp_nodes/ut/mkql_computation_node_ut.cpp index 19f82aae4ed..7d178dfd8da 100644 --- a/ydb/library/yql/minikql/comp_nodes/ut/mkql_computation_node_ut.cpp +++ b/ydb/library/yql/minikql/comp_nodes/ut/mkql_computation_node_ut.cpp @@ -209,8 +209,8 @@ TComputationNodeFactory GetTestFactory() { }; } -Y_UNIT_TEST_SUITE(TMiniKQLComputationNodeTest) { - Y_UNIT_TEST_LLVM(TestEmbeddedByteAt) { +Y_UNIT_TEST_SUITE(TMiniKQLComputationNodeTest) { + Y_UNIT_TEST_LLVM(TestEmbeddedByteAt) { TSetup<LLVM> setup; TProgramBuilder& pb = *setup.PgmBuilder; @@ -246,7 +246,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLComputationNodeTest) { UNIT_ASSERT(!iterator.Next(item)); } - Y_UNIT_TEST_LLVM(TestStringByteAt) { + Y_UNIT_TEST_LLVM(TestStringByteAt) { TSetup<LLVM> setup; TProgramBuilder& pb = *setup.PgmBuilder; @@ -282,7 +282,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLComputationNodeTest) { UNIT_ASSERT(!iterator.Next(item)); } - Y_UNIT_TEST_LLVM(TestCountBitsUI8) { + Y_UNIT_TEST_LLVM(TestCountBitsUI8) { TSetup<LLVM> setup; TProgramBuilder& pb = *setup.PgmBuilder; @@ -331,7 +331,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLComputationNodeTest) { UNIT_ASSERT(!iterator.Next(item)); } - Y_UNIT_TEST_LLVM(TestCountBitsUI16) { + Y_UNIT_TEST_LLVM(TestCountBitsUI16) { TSetup<LLVM> setup; TProgramBuilder& pb = *setup.PgmBuilder; @@ -380,7 +380,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLComputationNodeTest) { UNIT_ASSERT(!iterator.Next(item)); } - Y_UNIT_TEST_LLVM(TestShiftLeft) { + Y_UNIT_TEST_LLVM(TestShiftLeft) { TSetup<LLVM> setup; TProgramBuilder& pb = *setup.PgmBuilder; @@ -429,7 +429,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLComputationNodeTest) { UNIT_ASSERT(!iterator.Next(item)); } - Y_UNIT_TEST_LLVM(TestShiftRight) { + Y_UNIT_TEST_LLVM(TestShiftRight) { TSetup<LLVM> setup; TProgramBuilder& pb = *setup.PgmBuilder; @@ -478,7 +478,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLComputationNodeTest) { UNIT_ASSERT(!iterator.Next(item)); } - Y_UNIT_TEST_LLVM(TestRotLeft) { + Y_UNIT_TEST_LLVM(TestRotLeft) { TSetup<LLVM> setup; TProgramBuilder& pb = *setup.PgmBuilder; @@ -527,7 +527,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLComputationNodeTest) { UNIT_ASSERT(!iterator.Next(item)); } - Y_UNIT_TEST_LLVM(TestRotRight) { + Y_UNIT_TEST_LLVM(TestRotRight) { TSetup<LLVM> setup; TProgramBuilder& pb = *setup.PgmBuilder; @@ -576,7 +576,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLComputationNodeTest) { UNIT_ASSERT(!iterator.Next(item)); } - Y_UNIT_TEST_LLVM(TestConvertIntToBool) { + Y_UNIT_TEST_LLVM(TestConvertIntToBool) { TSetup<LLVM> setup; TProgramBuilder& pb = *setup.PgmBuilder; @@ -610,7 +610,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLComputationNodeTest) { UNIT_ASSERT(!iterator.Next(item)); } - Y_UNIT_TEST_LLVM(TestFloatAbs) { + Y_UNIT_TEST_LLVM(TestFloatAbs) { TSetup<LLVM> setup; TProgramBuilder& pb = *setup.PgmBuilder; @@ -641,7 +641,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLComputationNodeTest) { UNIT_ASSERT(!iterator.Next(item)); } - Y_UNIT_TEST_LLVM(TestIntegerAbs) { + Y_UNIT_TEST_LLVM(TestIntegerAbs) { TSetup<LLVM> setup; TProgramBuilder& pb = *setup.PgmBuilder; @@ -672,7 +672,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLComputationNodeTest) { UNIT_ASSERT(!iterator.Next(item)); } - Y_UNIT_TEST_LLVM(TestToIntegral) { + Y_UNIT_TEST_LLVM(TestToIntegral) { TSetup<LLVM> setup; TProgramBuilder& pb = *setup.PgmBuilder; @@ -685,7 +685,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLComputationNodeTest) { UNIT_ASSERT_VALUES_EQUAL(graph->GetValue().GetElement(1).template Get<ui32>(), 2U); } - Y_UNIT_TEST_LLVM(TestFloatToI16) { + Y_UNIT_TEST_LLVM(TestFloatToI16) { TSetup<LLVM> setup; TProgramBuilder& pb = *setup.PgmBuilder; @@ -734,7 +734,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLComputationNodeTest) { UNIT_ASSERT(!iterator.Next(item)); } - Y_UNIT_TEST_LLVM(TestDoubleToBool) { + Y_UNIT_TEST_LLVM(TestDoubleToBool) { TSetup<LLVM> setup; TProgramBuilder& pb = *setup.PgmBuilder; @@ -783,7 +783,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLComputationNodeTest) { UNIT_ASSERT(!iterator.Next(item)); } - Y_UNIT_TEST_LLVM(TestDoubleToUI32) { + Y_UNIT_TEST_LLVM(TestDoubleToUI32) { TSetup<LLVM> setup; TProgramBuilder& pb = *setup.PgmBuilder; @@ -1433,7 +1433,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLComputationNodeTest) { UNIT_ASSERT(!iterator.Next(item)); } - Y_UNIT_TEST_LLVM(TestNanvl) { + Y_UNIT_TEST_LLVM(TestNanvl) { TSetup<LLVM> setup; TProgramBuilder& pb = *setup.PgmBuilder; @@ -1472,7 +1472,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLComputationNodeTest) { UNIT_ASSERT(!iterator.Next(item)); } - Y_UNIT_TEST_LLVM(TestConvertToFloat) { + Y_UNIT_TEST_LLVM(TestConvertToFloat) { TSetup<LLVM> setup; TProgramBuilder& pb = *setup.PgmBuilder; @@ -1482,7 +1482,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLComputationNodeTest) { UNIT_ASSERT_VALUES_EQUAL(graph->GetValue().template Get<float>(), 7.0f); } - Y_UNIT_TEST_LLVM(TestAppend) { + Y_UNIT_TEST_LLVM(TestAppend) { TSetup<LLVM> setup; TProgramBuilder& pb = *setup.PgmBuilder; auto pgmReturn = pb.NewEmptyList(pb.NewDataType(NUdf::TDataType<ui32>::Id)); @@ -1502,7 +1502,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLComputationNodeTest) { UNIT_ASSERT(!iterator.Next(item)); } - Y_UNIT_TEST_LLVM(TestForkedAppend) { + Y_UNIT_TEST_LLVM(TestForkedAppend) { TSetup<LLVM> setup; TProgramBuilder& pb = *setup.PgmBuilder; const auto list1 = pb.NewList(pb.NewDataType(NUdf::TDataType<ui32>::Id), {pb.NewDataLiteral<ui32>(34)}); @@ -1529,7 +1529,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLComputationNodeTest) { UNIT_ASSERT(!iterator2.Next(item)); } - Y_UNIT_TEST_LLVM(TestPrepend) { + Y_UNIT_TEST_LLVM(TestPrepend) { TSetup<LLVM> setup; TProgramBuilder& pb = *setup.PgmBuilder; auto pgmReturn = pb.NewEmptyList(pb.NewDataType(NUdf::TDataType<ui32>::Id)); @@ -1549,7 +1549,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLComputationNodeTest) { UNIT_ASSERT(!iterator.Next(item)); } - Y_UNIT_TEST_LLVM(TestPrependOfVoid) { + Y_UNIT_TEST_LLVM(TestPrependOfVoid) { TSetup<LLVM> setup; TProgramBuilder& pb = *setup.PgmBuilder; auto pgmReturn = pb.NewEmptyListOfVoid(); @@ -1564,7 +1564,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLComputationNodeTest) { UNIT_ASSERT(!iterator.Skip()); } - Y_UNIT_TEST_LLVM(TestForkedPrepend) { + Y_UNIT_TEST_LLVM(TestForkedPrepend) { TSetup<LLVM> setup; TProgramBuilder& pb = *setup.PgmBuilder; const auto list = pb.NewEmptyList(pb.NewDataType(NUdf::TDataType<ui32>::Id)); @@ -1592,7 +1592,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLComputationNodeTest) { UNIT_ASSERT(!iterator2.Next(item)); } - Y_UNIT_TEST_LLVM(TestAppendOfVoid) { + Y_UNIT_TEST_LLVM(TestAppendOfVoid) { TSetup<LLVM> setup; TProgramBuilder& pb = *setup.PgmBuilder; auto pgmReturn = pb.NewEmptyListOfVoid(); @@ -1607,7 +1607,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLComputationNodeTest) { UNIT_ASSERT(!iterator.Skip()); } - Y_UNIT_TEST_LLVM(TestExtend) { + Y_UNIT_TEST_LLVM(TestExtend) { TSetup<LLVM> setup; TProgramBuilder& pb = *setup.PgmBuilder; const auto emptyList = pb.NewEmptyList(pb.NewDataType(NUdf::TDataType<ui32>::Id)); @@ -1628,7 +1628,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLComputationNodeTest) { UNIT_ASSERT(!iterator.Next(item)); } - Y_UNIT_TEST_LLVM(TestExtend3) { + Y_UNIT_TEST_LLVM(TestExtend3) { TSetup<LLVM> setup; TProgramBuilder& pb = *setup.PgmBuilder; const auto emptyList = pb.NewEmptyList(pb.NewDataType(NUdf::TDataType<ui32>::Id)); @@ -1795,7 +1795,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLComputationNodeTest) { UNIT_ASSERT_VALUES_EQUAL(list.GetElement(4).template Get<double>(), -7898.8); } - Y_UNIT_TEST_LLVM(TestAdd) { + Y_UNIT_TEST_LLVM(TestAdd) { TSetup<LLVM> setup; TProgramBuilder& pb = *setup.PgmBuilder; @@ -1808,7 +1808,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLComputationNodeTest) { UNIT_ASSERT_VALUES_EQUAL(res, 3); } - Y_UNIT_TEST_LLVM(TestSub) { + Y_UNIT_TEST_LLVM(TestSub) { TSetup<LLVM> setup; TProgramBuilder& pb = *setup.PgmBuilder; @@ -1821,7 +1821,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLComputationNodeTest) { UNIT_ASSERT_VALUES_EQUAL(res, 5); } - Y_UNIT_TEST_LLVM(TestMul) { + Y_UNIT_TEST_LLVM(TestMul) { TSetup<LLVM> setup; TProgramBuilder& pb = *setup.PgmBuilder; @@ -1834,7 +1834,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLComputationNodeTest) { UNIT_ASSERT_VALUES_EQUAL(res, 6); } - Y_UNIT_TEST_LLVM(TestDiv) { + Y_UNIT_TEST_LLVM(TestDiv) { TSetup<LLVM> setup; TProgramBuilder& pb = *setup.PgmBuilder; @@ -1848,7 +1848,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLComputationNodeTest) { UNIT_ASSERT_VALUES_EQUAL(value.template Get<ui32>(), 5); } - Y_UNIT_TEST_LLVM(TestDivZero) { + Y_UNIT_TEST_LLVM(TestDivZero) { TSetup<LLVM> setup; TProgramBuilder& pb = *setup.PgmBuilder; @@ -1861,7 +1861,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLComputationNodeTest) { UNIT_ASSERT(!value); } - Y_UNIT_TEST_LLVM(TestIDivOverflow) { + Y_UNIT_TEST_LLVM(TestIDivOverflow) { TSetup<LLVM> setup; TProgramBuilder& pb = *setup.PgmBuilder; @@ -1874,7 +1874,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLComputationNodeTest) { UNIT_ASSERT(!value); } - Y_UNIT_TEST_LLVM(TestMod) { + Y_UNIT_TEST_LLVM(TestMod) { TSetup<LLVM> setup; TProgramBuilder& pb = *setup.PgmBuilder; @@ -1888,7 +1888,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLComputationNodeTest) { UNIT_ASSERT_VALUES_EQUAL(value.template Get<ui32>(), 2); } - Y_UNIT_TEST_LLVM(TestModZero) { + Y_UNIT_TEST_LLVM(TestModZero) { TSetup<LLVM> setup; TProgramBuilder& pb = *setup.PgmBuilder; @@ -1901,7 +1901,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLComputationNodeTest) { UNIT_ASSERT(!value); } - Y_UNIT_TEST_LLVM(TestIModOverflow) { + Y_UNIT_TEST_LLVM(TestIModOverflow) { TSetup<LLVM> setup; TProgramBuilder& pb = *setup.PgmBuilder; @@ -1914,7 +1914,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLComputationNodeTest) { UNIT_ASSERT(!value); } - Y_UNIT_TEST_LLVM(TestStruct) { + Y_UNIT_TEST_LLVM(TestStruct) { TSetup<LLVM> setup; TProgramBuilder& pb = *setup.PgmBuilder; @@ -1945,7 +1945,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLComputationNodeTest) { UNIT_ASSERT(!iterator.Next(item)); } - Y_UNIT_TEST_LLVM(TestMapOverList) { + Y_UNIT_TEST_LLVM(TestMapOverList) { TSetup<LLVM> setup; TProgramBuilder& pb = *setup.PgmBuilder; @@ -1976,7 +1976,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLComputationNodeTest) { UNIT_ASSERT(!iterator.Next(item)); } - Y_UNIT_TEST_LLVM(TestMapOverStream) { + Y_UNIT_TEST_LLVM(TestMapOverStream) { TSetup<LLVM> setup; TProgramBuilder& pb = *setup.PgmBuilder; @@ -2043,7 +2043,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLComputationNodeTest) { } #ifndef _win_ - Y_UNIT_TEST_LLVM(TestMapUnwrapThrow) { + Y_UNIT_TEST_LLVM(TestMapUnwrapThrow) { TSetup<LLVM> setup; TProgramBuilder& pb = *setup.PgmBuilder; @@ -2066,7 +2066,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLComputationNodeTest) { UNIT_ASSERT_EXCEPTION(iterator.Next(item), yexception); } - Y_UNIT_TEST_LLVM(TestMapUnwrapThrowMessage) { + Y_UNIT_TEST_LLVM(TestMapUnwrapThrowMessage) { TSetup<LLVM> setup; TProgramBuilder& pb = *setup.PgmBuilder; @@ -2092,7 +2092,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLComputationNodeTest) { UNIT_ASSERT_EXCEPTION(iterator.Next(item), yexception); } - Y_UNIT_TEST_LLVM(TestMapEnsureThrowMessage) { + Y_UNIT_TEST_LLVM(TestMapEnsureThrowMessage) { TSetup<LLVM> setup; TProgramBuilder& pb = *setup.PgmBuilder; @@ -2115,7 +2115,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLComputationNodeTest) { UNIT_ASSERT_EXCEPTION(iterator.Next(item), yexception); } #endif - Y_UNIT_TEST_LLVM(TestMapWithCoalesce) { + Y_UNIT_TEST_LLVM(TestMapWithCoalesce) { TSetup<LLVM> setup; TProgramBuilder& pb = *setup.PgmBuilder; @@ -2146,7 +2146,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLComputationNodeTest) { UNIT_ASSERT(!iterator.Next(item)); } - Y_UNIT_TEST_LLVM(TestSizeOfOptional) { + Y_UNIT_TEST_LLVM(TestSizeOfOptional) { TSetup<LLVM> setup; TProgramBuilder& pb = *setup.PgmBuilder; @@ -2174,7 +2174,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLComputationNodeTest) { UNIT_ASSERT(!iterator.Next(item)); } - Y_UNIT_TEST_LLVM(TestSizeOfOptionalString) { + Y_UNIT_TEST_LLVM(TestSizeOfOptionalString) { TSetup<LLVM> setup; TProgramBuilder& pb = *setup.PgmBuilder; @@ -2208,7 +2208,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLComputationNodeTest) { UNIT_ASSERT(!iterator.Next(item)); } - Y_UNIT_TEST_LLVM(TestMapWithIfExists) { + Y_UNIT_TEST_LLVM(TestMapWithIfExists) { TSetup<LLVM> setup; TProgramBuilder& pb = *setup.PgmBuilder; @@ -2239,7 +2239,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLComputationNodeTest) { UNIT_ASSERT(!iterator.Next(item)); } - Y_UNIT_TEST_LLVM(TestMapOverListLazy) { + Y_UNIT_TEST_LLVM(TestMapOverListLazy) { TSetup<LLVM> setup; TProgramBuilder& pb = *setup.PgmBuilder; @@ -2269,7 +2269,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLComputationNodeTest) { UNIT_ASSERT(!iterator.Next(item)); } - Y_UNIT_TEST_LLVM(TestMapOverOptional) { + Y_UNIT_TEST_LLVM(TestMapOverOptional) { TSetup<LLVM> setup; TProgramBuilder& pb = *setup.PgmBuilder; @@ -2287,7 +2287,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLComputationNodeTest) { UNIT_ASSERT_VALUES_EQUAL(value.template Get<ui32>(), 3); } - Y_UNIT_TEST_LLVM(TestFloatMinMax) { + Y_UNIT_TEST_LLVM(TestFloatMinMax) { TSetup<LLVM> setup; TProgramBuilder& pb = *setup.PgmBuilder; @@ -2414,7 +2414,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLComputationNodeTest) { UNIT_ASSERT(!iterator.Next(item)); } - Y_UNIT_TEST_LLVM(TestFloatMod) { + Y_UNIT_TEST_LLVM(TestFloatMod) { TSetup<LLVM> setup; TProgramBuilder& pb = *setup.PgmBuilder; @@ -2444,7 +2444,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLComputationNodeTest) { UNIT_ASSERT(!iterator.Next(item)); } - Y_UNIT_TEST_LLVM(TestDoubleMod) { + Y_UNIT_TEST_LLVM(TestDoubleMod) { TSetup<LLVM> setup; TProgramBuilder& pb = *setup.PgmBuilder; @@ -2567,7 +2567,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLComputationNodeTest) { UNIT_ASSERT(!iterator.Next(item)); } - Y_UNIT_TEST_LLVM(TestCoalesce) { + Y_UNIT_TEST_LLVM(TestCoalesce) { TSetup<LLVM> setup; TProgramBuilder& pb = *setup.PgmBuilder; @@ -2597,7 +2597,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLComputationNodeTest) { UNIT_ASSERT(!value.GetElement(4)); } - Y_UNIT_TEST_LLVM(TestExists) { + Y_UNIT_TEST_LLVM(TestExists) { TSetup<LLVM> setup; TProgramBuilder& pb = *setup.PgmBuilder; @@ -2621,7 +2621,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLComputationNodeTest) { UNIT_ASSERT(!iterator.Next(item)); } - Y_UNIT_TEST_LLVM(TestIf) { + Y_UNIT_TEST_LLVM(TestIf) { TSetup<LLVM> setup; TProgramBuilder& pb = *setup.PgmBuilder; @@ -2646,7 +2646,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLComputationNodeTest) { UNIT_ASSERT(!iterator.Next(item)); } - Y_UNIT_TEST_LLVM(TestIfPresent) { + Y_UNIT_TEST_LLVM(TestIfPresent) { TSetup<LLVM> setup; TProgramBuilder& pb = *setup.PgmBuilder; @@ -2817,7 +2817,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLComputationNodeTest) { UNIT_ASSERT(!iterator.Next(item)); } - Y_UNIT_TEST_LLVM(TestIncDec) { + Y_UNIT_TEST_LLVM(TestIncDec) { TSetup<LLVM> setup; TProgramBuilder& pb = *setup.PgmBuilder; @@ -2837,7 +2837,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLComputationNodeTest) { UNIT_ASSERT(!iterator.Next(item)); } - Y_UNIT_TEST_LLVM(TestLogical) { + Y_UNIT_TEST_LLVM(TestLogical) { TSetup<LLVM> setup; TProgramBuilder& pb = *setup.PgmBuilder; @@ -2908,7 +2908,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLComputationNodeTest) { UNIT_ASSERT(!iterator.Next(item)); } - Y_UNIT_TEST_LLVM(TestZip) { + Y_UNIT_TEST_LLVM(TestZip) { TSetup<LLVM> setup; TProgramBuilder& pb = *setup.PgmBuilder; @@ -2934,7 +2934,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLComputationNodeTest) { UNBOXED_VALUE_STR_EQUAL(list.GetElement(1).GetElement(1), "E"); } - Y_UNIT_TEST_LLVM(TestZipLazy) { + Y_UNIT_TEST_LLVM(TestZipLazy) { TSetup<LLVM> setup; TProgramBuilder& pb = *setup.PgmBuilder; @@ -2964,7 +2964,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLComputationNodeTest) { UNIT_ASSERT(!iterator.Next(item)); } - Y_UNIT_TEST_LLVM(TestZipAll) { + Y_UNIT_TEST_LLVM(TestZipAll) { TSetup<LLVM> setup; TProgramBuilder& pb = *setup.PgmBuilder; @@ -2992,7 +2992,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLComputationNodeTest) { UNBOXED_VALUE_STR_EQUAL(list.GetElement(2).GetElement(1), "W"); } - Y_UNIT_TEST_LLVM(TestZipAllLazy) { + Y_UNIT_TEST_LLVM(TestZipAllLazy) { TSetup<LLVM> setup; TProgramBuilder& pb = *setup.PgmBuilder; @@ -3026,7 +3026,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLComputationNodeTest) { UNIT_ASSERT(!iterator.Next(item)); } - Y_UNIT_TEST_LLVM(TestReduce) { + Y_UNIT_TEST_LLVM(TestReduce) { TSetup<LLVM> setup; TProgramBuilder& pb = *setup.PgmBuilder; @@ -3061,7 +3061,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLComputationNodeTest) { UNIT_ASSERT_VALUES_EQUAL(value.GetElement(0).template Get<ui32>(), 3); } - Y_UNIT_TEST_LLVM(TestReduceOverStream) { + Y_UNIT_TEST_LLVM(TestReduceOverStream) { TSetup<LLVM> setup; TProgramBuilder& pb = *setup.PgmBuilder; @@ -3096,7 +3096,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLComputationNodeTest) { UNIT_ASSERT_VALUES_EQUAL(value.GetElement(0).template Get<ui32>(), 3); } - Y_UNIT_TEST_LLVM(TestListLength) { + Y_UNIT_TEST_LLVM(TestListLength) { TSetup<LLVM> setup; TProgramBuilder& pb = *setup.PgmBuilder; @@ -3108,7 +3108,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLComputationNodeTest) { UNIT_ASSERT_VALUES_EQUAL(graph->GetValue().template Get<ui64>(), 2); } - Y_UNIT_TEST_LLVM(TestReverse) { + Y_UNIT_TEST_LLVM(TestReverse) { TSetup<LLVM> setup; TProgramBuilder& pb = *setup.PgmBuilder; @@ -3128,7 +3128,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLComputationNodeTest) { UNIT_ASSERT(!iterator.Next(item)); } - Y_UNIT_TEST_LLVM(TestSkipForAppend) { + Y_UNIT_TEST_LLVM(TestSkipForAppend) { const ui32 n = 100; TSetup<LLVM> setup; TProgramBuilder& pb = *setup.PgmBuilder; @@ -3193,7 +3193,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLComputationNodeTest) { } } - Y_UNIT_TEST_LLVM(TestSkipForPrepend) { + Y_UNIT_TEST_LLVM(TestSkipForPrepend) { const ui32 n = 100; TSetup<LLVM> setup; TProgramBuilder& pb = *setup.PgmBuilder; @@ -3255,7 +3255,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLComputationNodeTest) { } } - Y_UNIT_TEST_LLVM(TestTakeForAppend) { + Y_UNIT_TEST_LLVM(TestTakeForAppend) { const ui32 n = 100; TSetup<LLVM> setup; TProgramBuilder& pb = *setup.PgmBuilder; @@ -3317,7 +3317,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLComputationNodeTest) { } } - Y_UNIT_TEST_LLVM(TestTakeForPrepend) { + Y_UNIT_TEST_LLVM(TestTakeForPrepend) { const ui32 n = 100; TSetup<LLVM> setup; TProgramBuilder& pb = *setup.PgmBuilder; @@ -3379,7 +3379,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLComputationNodeTest) { } } - Y_UNIT_TEST_LLVM(TestReplicate) { + Y_UNIT_TEST_LLVM(TestReplicate) { TSetup<LLVM> setup; TProgramBuilder& pb = *setup.PgmBuilder; @@ -3399,7 +3399,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLComputationNodeTest) { UNIT_ASSERT(!iterator.Next(item)); } - Y_UNIT_TEST_LLVM(TestIntegralCasts) { + Y_UNIT_TEST_LLVM(TestIntegralCasts) { TSetup<LLVM> setup; TProgramBuilder& pb = *setup.PgmBuilder; @@ -3411,7 +3411,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLComputationNodeTest) { UNIT_ASSERT_VALUES_EQUAL(res, 2); } - Y_UNIT_TEST_LLVM(TestCastFourIntoTrue) { + Y_UNIT_TEST_LLVM(TestCastFourIntoTrue) { TSetup<LLVM> setup; TProgramBuilder& pb = *setup.PgmBuilder; @@ -3423,7 +3423,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLComputationNodeTest) { UNIT_ASSERT(res); } - Y_UNIT_TEST_LLVM(TestSubstring) { + Y_UNIT_TEST_LLVM(TestSubstring) { TSetup<LLVM> setup; TProgramBuilder& pb = *setup.PgmBuilder; @@ -3772,7 +3772,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLComputationNodeTest) { UNIT_ASSERT(!iterator.Next(item)); } - Y_UNIT_TEST_LLVM(TestSize) { + Y_UNIT_TEST_LLVM(TestSize) { TSetup<LLVM> setup; TProgramBuilder& pb = *setup.PgmBuilder; @@ -3799,7 +3799,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLComputationNodeTest) { UNIT_ASSERT(!iterator.Next(item)); } - Y_UNIT_TEST_LLVM(TestEnumerate) { + Y_UNIT_TEST_LLVM(TestEnumerate) { TSetup<LLVM> setup; TProgramBuilder& pb = *setup.PgmBuilder; @@ -3821,7 +3821,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLComputationNodeTest) { UNIT_ASSERT(!iterator.Next(item)); } - Y_UNIT_TEST_LLVM(TestEnumerateLazy) { + Y_UNIT_TEST_LLVM(TestEnumerateLazy) { TSetup<LLVM> setup; TProgramBuilder& pb = *setup.PgmBuilder; @@ -3844,7 +3844,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLComputationNodeTest) { UNIT_ASSERT(!iterator.Next(item)); } - Y_UNIT_TEST_LLVM(TestEnumerateLazyThenReverse) { + Y_UNIT_TEST_LLVM(TestEnumerateLazyThenReverse) { TSetup<LLVM> setup; TProgramBuilder& pb = *setup.PgmBuilder; @@ -3867,7 +3867,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLComputationNodeTest) { UNIT_ASSERT(!iterator.Next(item)); } - Y_UNIT_TEST_LLVM(TestEnumerateLazyThenSkip) { + Y_UNIT_TEST_LLVM(TestEnumerateLazyThenSkip) { TSetup<LLVM> setup; TProgramBuilder& pb = *setup.PgmBuilder; @@ -3892,7 +3892,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLComputationNodeTest) { UNIT_ASSERT_VALUES_EQUAL(graph->GetValue().GetElement(2).template Get<ui64>(), 1); } - Y_UNIT_TEST_LLVM(TestEnumerateLazyThenTake) { + Y_UNIT_TEST_LLVM(TestEnumerateLazyThenTake) { TSetup<LLVM> setup; TProgramBuilder& pb = *setup.PgmBuilder; @@ -4001,7 +4001,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLComputationNodeTest) { } } - Y_UNIT_TEST_LLVM(TestSort) { + Y_UNIT_TEST_LLVM(TestSort) { TestSortImpl<LLVM>(true); TestSortImpl<LLVM>(false); } @@ -4041,7 +4041,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLComputationNodeTest) { return result; } - Y_UNIT_TEST_LLVM(TestSortTuples) { + Y_UNIT_TEST_LLVM(TestSortTuples) { TSetup<LLVM> setup; TProgramBuilder& pb = *setup.PgmBuilder; @@ -4057,7 +4057,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLComputationNodeTest) { }; TVector<TRuntimeNode> tuplesList; - for (ui32 i = 0; i < Y_ARRAY_SIZE(testData); i++) { + for (ui32 i = 0; i < Y_ARRAY_SIZE(testData); i++) { TVector<TRuntimeNode> elements(3); elements[0] = pb.NewDataLiteral(std::get<0>(testData[i])); elements[1] = pb.NewDataLiteral(std::get<1>(testData[i])); @@ -4134,7 +4134,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLComputationNodeTest) { } } - Y_UNIT_TEST_LLVM(TestAsList) { + Y_UNIT_TEST_LLVM(TestAsList) { TSetup<LLVM> setup; TProgramBuilder& pb = *setup.PgmBuilder; const auto pgmReturn = pb.AsList(pb.NewDataLiteral<ui32>(34)); @@ -4149,7 +4149,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLComputationNodeTest) { UNIT_ASSERT(!iterator.Next(item)); } - Y_UNIT_TEST_LLVM(TestListIfTrue) { + Y_UNIT_TEST_LLVM(TestListIfTrue) { TSetup<LLVM> setup; TProgramBuilder& pb = *setup.PgmBuilder; const auto pgmReturn = pb.ListIf(pb.NewDataLiteral(true), @@ -4165,7 +4165,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLComputationNodeTest) { UNIT_ASSERT(!iterator.Next(item)); } - Y_UNIT_TEST_LLVM(TestListIfFalse) { + Y_UNIT_TEST_LLVM(TestListIfFalse) { TSetup<LLVM> setup; TProgramBuilder& pb = *setup.PgmBuilder; const auto pgmReturn = pb.ListIf(pb.NewDataLiteral(false), @@ -4177,7 +4177,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLComputationNodeTest) { UNIT_ASSERT(!iterator.Skip()); } - Y_UNIT_TEST_LLVM(TestNth) { + Y_UNIT_TEST_LLVM(TestNth) { TSetup<LLVM> setup; TProgramBuilder& pb = *setup.PgmBuilder; const auto element0 = pb.NewDataLiteral<ui32>(34); @@ -4190,7 +4190,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLComputationNodeTest) { UNIT_ASSERT_VALUES_EQUAL(res, 56); } - Y_UNIT_TEST_LLVM(NonDeterministicEnv) { + Y_UNIT_TEST_LLVM(NonDeterministicEnv) { TSetup<LLVM> setup; TProgramBuilder& pb = *setup.PgmBuilder; @@ -4217,7 +4217,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLComputationNodeTest) { UNIT_ASSERT(false == iterator.Next(item)); } - Y_UNIT_TEST_LLVM(TestIndexDictContains) { + Y_UNIT_TEST_LLVM(TestIndexDictContains) { TSetup<LLVM> setup; TProgramBuilder& pb = *setup.PgmBuilder; @@ -4248,7 +4248,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLComputationNodeTest) { UNIT_ASSERT(!iterator.Next(item)); } - Y_UNIT_TEST_LLVM(TestIndexDictLookup) { + Y_UNIT_TEST_LLVM(TestIndexDictLookup) { TSetup<LLVM> setup; TProgramBuilder& pb = *setup.PgmBuilder; @@ -4281,7 +4281,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLComputationNodeTest) { UNIT_ASSERT(!iterator.Next(item)); } - Y_UNIT_TEST_LLVM(TestIndexDictContainsLazy) { + Y_UNIT_TEST_LLVM(TestIndexDictContainsLazy) { TSetup<LLVM> setup; TProgramBuilder& pb = *setup.PgmBuilder; @@ -4313,7 +4313,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLComputationNodeTest) { UNIT_ASSERT(!iterator.Next(item)); } - Y_UNIT_TEST_LLVM(TestIndexDictLookupLazy) { + Y_UNIT_TEST_LLVM(TestIndexDictLookupLazy) { TSetup<LLVM> setup; TProgramBuilder& pb = *setup.PgmBuilder; @@ -4438,7 +4438,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLComputationNodeTest) { UNIT_ASSERT(!iterator.Next(item)); } - Y_UNIT_TEST_LLVM(TestFromString) { + Y_UNIT_TEST_LLVM(TestFromString) { TSetup<LLVM> setup; TProgramBuilder& pb = *setup.PgmBuilder; @@ -4463,7 +4463,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLComputationNodeTest) { UNIT_ASSERT(!iterator.Next(item)); } - Y_UNIT_TEST_LLVM(TestStrictFromString) { + Y_UNIT_TEST_LLVM(TestStrictFromString) { TSetup<LLVM> setup; TProgramBuilder& pb = *setup.PgmBuilder; @@ -4499,7 +4499,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLComputationNodeTest) { } } - Y_UNIT_TEST_LLVM(TestFromBytes) { + Y_UNIT_TEST_LLVM(TestFromBytes) { TSetup<LLVM> setup; TProgramBuilder& pb = *setup.PgmBuilder; @@ -4517,7 +4517,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLComputationNodeTest) { UNIT_ASSERT(!res.GetElement(1)); } - Y_UNIT_TEST_LLVM(TestMTRand) { + Y_UNIT_TEST_LLVM(TestMTRand) { TSetup<LLVM> setup; TProgramBuilder& pb = *setup.PgmBuilder; @@ -4553,7 +4553,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLComputationNodeTest) { UNIT_ASSERT(!iterator.Next(item)); } - Y_UNIT_TEST_LLVM(TestRandom) { + Y_UNIT_TEST_LLVM(TestRandom) { TSetup<LLVM> setup; TProgramBuilder& pb = *setup.PgmBuilder; @@ -4573,7 +4573,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLComputationNodeTest) { UNIT_ASSERT_VALUES_EQUAL(tuple.GetElement(1).template Get<ui64>(), expectedValue2); } - Y_UNIT_TEST_LLVM(TestNow) { + Y_UNIT_TEST_LLVM(TestNow) { TSetup<LLVM> setup; TProgramBuilder& pb = *setup.PgmBuilder; @@ -4810,7 +4810,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLComputationNodeTest) { UNIT_ASSERT_VALUES_EQUAL(full.GetElement(2U).template Get<float>(), -3.14f); } #endif - Y_UNIT_TEST_LLVM(TestPerfHolders) { + Y_UNIT_TEST_LLVM(TestPerfHolders) { TSetup<LLVM> setup; TProgramBuilder& pb = *setup.PgmBuilder; @@ -4861,7 +4861,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLComputationNodeTest) { Cout << t2 - t1 << Endl; } - Y_UNIT_TEST_LLVM(TestPerfGrep) { + Y_UNIT_TEST_LLVM(TestPerfGrep) { TSetup<LLVM> setup; TProgramBuilder& pb = *setup.PgmBuilder; @@ -4905,7 +4905,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLComputationNodeTest) { return NUdf::TUnboxedValuePod(stringRef.Size() == 5 && std::memcmp(stringRef.Data(), "ABCDE", 5) == 0); } - Y_UNIT_TEST_LLVM(TestPerfGrepSpecialFunc) { + Y_UNIT_TEST_LLVM(TestPerfGrepSpecialFunc) { const auto t1 = TInstant::Now(); { NUdf::TUnboxedValuePod items[2]; diff --git a/ydb/library/yql/minikql/comp_nodes/ut/mkql_computation_node_ut.h b/ydb/library/yql/minikql/comp_nodes/ut/mkql_computation_node_ut.h index db79fc7ab85..f5c33968bf4 100644 --- a/ydb/library/yql/minikql/comp_nodes/ut/mkql_computation_node_ut.h +++ b/ydb/library/yql/minikql/comp_nodes/ut/mkql_computation_node_ut.h @@ -22,7 +22,7 @@ #if defined(_msan_enabled_) || defined(_ubsan_enabled_) || defined(WITH_VALGRIND) -#define Y_UNIT_TEST_TWIN_IMPL_REGISTER(N, OPT) \ +#define Y_UNIT_TEST_TWIN_IMPL_REGISTER(N, OPT) \ template<bool OPT> void N(NUnitTest::TTestContext&); \ struct TTestRegistration##N { \ TTestRegistration##N() { \ @@ -31,7 +31,7 @@ }; \ static TTestRegistration##N testRegistration##N; #else -#define Y_UNIT_TEST_TWIN_IMPL_REGISTER(N, OPT) \ +#define Y_UNIT_TEST_TWIN_IMPL_REGISTER(N, OPT) \ template<bool OPT> void N(NUnitTest::TTestContext&); \ struct TTestRegistration##N { \ TTestRegistration##N() { \ @@ -42,12 +42,12 @@ static TTestRegistration##N testRegistration##N; #endif -#define Y_UNIT_TEST_TWIN(N, OPT) \ - Y_UNIT_TEST_TWIN_IMPL_REGISTER(N, OPT) \ +#define Y_UNIT_TEST_TWIN(N, OPT) \ + Y_UNIT_TEST_TWIN_IMPL_REGISTER(N, OPT) \ template<bool OPT> \ void N(NUnitTest::TTestContext&) -#define Y_UNIT_TEST_LLVM(N) Y_UNIT_TEST_TWIN(N, LLVM) +#define Y_UNIT_TEST_LLVM(N) Y_UNIT_TEST_TWIN(N, LLVM) namespace NKikimr { namespace NMiniKQL { diff --git a/ydb/library/yql/minikql/comp_nodes/ut/mkql_condense_ut.cpp b/ydb/library/yql/minikql/comp_nodes/ut/mkql_condense_ut.cpp index 653d6c0cc08..74d0d2202b0 100644 --- a/ydb/library/yql/minikql/comp_nodes/ut/mkql_condense_ut.cpp +++ b/ydb/library/yql/minikql/comp_nodes/ut/mkql_condense_ut.cpp @@ -7,7 +7,7 @@ namespace NKikimr { namespace NMiniKQL { Y_UNIT_TEST_SUITE(TMiniKQLCondenseNodeTest) { - Y_UNIT_TEST_LLVM(TestSqueeze) { + Y_UNIT_TEST_LLVM(TestSqueeze) { TSetup<LLVM> setup; TProgramBuilder& pb = *setup.PgmBuilder; @@ -34,7 +34,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLCondenseNodeTest) { UNIT_ASSERT_VALUES_EQUAL(NUdf::EFetchStatus::Finish, iterator.Fetch(item)); } - Y_UNIT_TEST_LLVM(TestSqueezeOnEmpty) { + Y_UNIT_TEST_LLVM(TestSqueezeOnEmpty) { TSetup<LLVM> setup; TProgramBuilder& pb = *setup.PgmBuilder; @@ -57,7 +57,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLCondenseNodeTest) { UNIT_ASSERT_VALUES_EQUAL(NUdf::EFetchStatus::Finish, iterator.Fetch(item)); } - Y_UNIT_TEST_LLVM(TestSqueeze1OverEmpty) { + Y_UNIT_TEST_LLVM(TestSqueeze1OverEmpty) { TSetup<LLVM> setup; TProgramBuilder& pb = *setup.PgmBuilder; @@ -79,7 +79,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLCondenseNodeTest) { UNIT_ASSERT_VALUES_EQUAL(NUdf::EFetchStatus::Finish, iterator.Fetch(item)); } - Y_UNIT_TEST_LLVM(TestSqueeze1OverSingle) { + Y_UNIT_TEST_LLVM(TestSqueeze1OverSingle) { TSetup<LLVM> setup; TProgramBuilder& pb = *setup.PgmBuilder; @@ -105,7 +105,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLCondenseNodeTest) { UNIT_ASSERT_VALUES_EQUAL(NUdf::EFetchStatus::Finish, iterator.Fetch(item)); } - Y_UNIT_TEST_LLVM(TestSqueeze1OverMany) { + Y_UNIT_TEST_LLVM(TestSqueeze1OverMany) { TSetup<LLVM> setup; TProgramBuilder& pb = *setup.PgmBuilder; diff --git a/ydb/library/yql/minikql/comp_nodes/ut/mkql_decimal_ut.cpp b/ydb/library/yql/minikql/comp_nodes/ut/mkql_decimal_ut.cpp index eb5ff4df71b..0c80336eac7 100644 --- a/ydb/library/yql/minikql/comp_nodes/ut/mkql_decimal_ut.cpp +++ b/ydb/library/yql/minikql/comp_nodes/ut/mkql_decimal_ut.cpp @@ -7,7 +7,7 @@ namespace NKikimr { namespace NMiniKQL { Y_UNIT_TEST_SUITE(TMiniKQLDecimalTest) { - Y_UNIT_TEST_LLVM(TestNanvl) { + Y_UNIT_TEST_LLVM(TestNanvl) { TSetup<LLVM> setup; TProgramBuilder& pb = *setup.PgmBuilder; diff --git a/ydb/library/yql/minikql/comp_nodes/ut/mkql_dict_ut.cpp b/ydb/library/yql/minikql/comp_nodes/ut/mkql_dict_ut.cpp index ac6d4c356b2..d15479fc6b2 100644 --- a/ydb/library/yql/minikql/comp_nodes/ut/mkql_dict_ut.cpp +++ b/ydb/library/yql/minikql/comp_nodes/ut/mkql_dict_ut.cpp @@ -7,7 +7,7 @@ namespace NKikimr { namespace NMiniKQL { Y_UNIT_TEST_SUITE(TMiniKQLDictRelatedNodesTest) { - Y_UNIT_TEST_LLVM(TestDictLength) { + Y_UNIT_TEST_LLVM(TestDictLength) { TSetup<LLVM> setup; TProgramBuilder& pgmBuilder = *setup.PgmBuilder; @@ -30,7 +30,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLDictRelatedNodesTest) { UNIT_ASSERT_VALUES_EQUAL(graph->GetValue().template Get<ui64>(), 2); } - Y_UNIT_TEST_LLVM(TestDictContains) { + Y_UNIT_TEST_LLVM(TestDictContains) { TSetup<LLVM> setup; TProgramBuilder& pgmBuilder = *setup.PgmBuilder; @@ -68,7 +68,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLDictRelatedNodesTest) { UNIT_ASSERT(!iterator.Next(item)); } - Y_UNIT_TEST_LLVM(TestDictLookup) { + Y_UNIT_TEST_LLVM(TestDictLookup) { TSetup<LLVM> setup; TProgramBuilder& pgmBuilder = *setup.PgmBuilder; @@ -207,19 +207,19 @@ Y_UNIT_TEST_SUITE(TMiniKQLDictRelatedNodesTest) { UNIT_ASSERT(!iterator.Next(item)); } - Y_UNIT_TEST_LLVM(TestSortedDictContains) { + Y_UNIT_TEST_LLVM(TestSortedDictContains) { TestConvertedDictContains<LLVM>(&TProgramBuilder::ToSortedDict); } - Y_UNIT_TEST_LLVM(TestSortedDictLookup) { + Y_UNIT_TEST_LLVM(TestSortedDictLookup) { TestConvertedDictLookup<LLVM>(&TProgramBuilder::ToSortedDict); } - Y_UNIT_TEST_LLVM(TestHashedDictContains) { + Y_UNIT_TEST_LLVM(TestHashedDictContains) { TestConvertedDictContains<LLVM>(&TProgramBuilder::ToHashedDict); } - Y_UNIT_TEST_LLVM(TestHashedDictLookup) { + Y_UNIT_TEST_LLVM(TestHashedDictLookup) { TestConvertedDictLookup<LLVM>(&TProgramBuilder::ToHashedDict); } @@ -311,11 +311,11 @@ Y_UNIT_TEST_SUITE(TMiniKQLDictRelatedNodesTest) { UNIT_ASSERT_VALUES_EQUAL(items[3], "E"); } - Y_UNIT_TEST_LLVM(TestSortedDictItems) { + Y_UNIT_TEST_LLVM(TestSortedDictItems) { TestDictItemsImpl<LLVM, false>(&TProgramBuilder::ToSortedDict); } - Y_UNIT_TEST_LLVM(TestHashedDictItems) { + Y_UNIT_TEST_LLVM(TestHashedDictItems) { TestDictItemsImpl<LLVM, true>(&TProgramBuilder::ToHashedDict); } @@ -380,11 +380,11 @@ Y_UNIT_TEST_SUITE(TMiniKQLDictRelatedNodesTest) { UNIT_ASSERT(!iterator.Next(item)); } - Y_UNIT_TEST_LLVM(TestSortedMultiDictLookup) { + Y_UNIT_TEST_LLVM(TestSortedMultiDictLookup) { TestConvertedMultiDictLookup<LLVM>(&TProgramBuilder::ToSortedDict); } - Y_UNIT_TEST_LLVM(TestHashedMultiDictLookup) { + Y_UNIT_TEST_LLVM(TestHashedMultiDictLookup) { TestConvertedMultiDictLookup<LLVM>(&TProgramBuilder::ToHashedDict); } } diff --git a/ydb/library/yql/minikql/comp_nodes/ut/mkql_filters_ut.cpp b/ydb/library/yql/minikql/comp_nodes/ut/mkql_filters_ut.cpp index e2c1c4dc690..ad756075599 100644 --- a/ydb/library/yql/minikql/comp_nodes/ut/mkql_filters_ut.cpp +++ b/ydb/library/yql/minikql/comp_nodes/ut/mkql_filters_ut.cpp @@ -8,7 +8,7 @@ namespace NKikimr { namespace NMiniKQL { Y_UNIT_TEST_SUITE(TMiniKQLFiltersTest) { - Y_UNIT_TEST_LLVM(TestSkipNullMembers) { + Y_UNIT_TEST_LLVM(TestSkipNullMembers) { TSetup<LLVM> setup; TProgramBuilder& pb = *setup.PgmBuilder; @@ -338,7 +338,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLFiltersTest) { UNIT_ASSERT_VALUES_EQUAL(NUdf::EFetchStatus::Finish, iterator.Fetch(item)); } - Y_UNIT_TEST_LLVM(TestFilterOverList) { + Y_UNIT_TEST_LLVM(TestFilterOverList) { TSetup<LLVM> setup; TProgramBuilder& pb = *setup.PgmBuilder; @@ -362,7 +362,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLFiltersTest) { UNIT_ASSERT(!iterator.Next(item)); } - Y_UNIT_TEST_LLVM(TestFilterOverStream) { + Y_UNIT_TEST_LLVM(TestFilterOverStream) { TSetup<LLVM> setup; TProgramBuilder& pb = *setup.PgmBuilder; @@ -418,7 +418,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLFiltersTest) { UNIT_ASSERT_VALUES_EQUAL(NUdf::EFetchStatus::Finish, iterator.Fetch(item)); } - Y_UNIT_TEST_LLVM(TestFilterOverListLazy) { + Y_UNIT_TEST_LLVM(TestFilterOverListLazy) { TSetup<LLVM> setup; TProgramBuilder& pb = *setup.PgmBuilder; @@ -442,7 +442,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLFiltersTest) { UNIT_ASSERT(!iterator.Next(item)); } - Y_UNIT_TEST_LLVM(TestFilterByString) { + Y_UNIT_TEST_LLVM(TestFilterByString) { TSetup<LLVM> setup; TProgramBuilder& pb = *setup.PgmBuilder; @@ -466,7 +466,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLFiltersTest) { UNBOXED_VALUE_STR_EQUAL(result.GetElement(1U), "100"); } - Y_UNIT_TEST_LLVM(TestSkipWhile) { + Y_UNIT_TEST_LLVM(TestSkipWhile) { TSetup<LLVM> setup; TProgramBuilder& pb = *setup.PgmBuilder; @@ -493,7 +493,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLFiltersTest) { UNIT_ASSERT(!iterator.Next(item)); } - Y_UNIT_TEST_LLVM(TestTakeWhile) { + Y_UNIT_TEST_LLVM(TestTakeWhile) { TSetup<LLVM> setup; TProgramBuilder& pb = *setup.PgmBuilder; diff --git a/ydb/library/yql/minikql/comp_nodes/ut/mkql_fold_ut.cpp b/ydb/library/yql/minikql/comp_nodes/ut/mkql_fold_ut.cpp index 87c596e094c..7f9885f4f35 100644 --- a/ydb/library/yql/minikql/comp_nodes/ut/mkql_fold_ut.cpp +++ b/ydb/library/yql/minikql/comp_nodes/ut/mkql_fold_ut.cpp @@ -12,7 +12,7 @@ namespace NKikimr { namespace NMiniKQL { Y_UNIT_TEST_SUITE(TMiniKQLFoldNodeTest) { - Y_UNIT_TEST_LLVM(TestFoldOverList) { + Y_UNIT_TEST_LLVM(TestFoldOverList) { TSetup<LLVM> setup; TProgramBuilder& pb = *setup.PgmBuilder; @@ -31,7 +31,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLFoldNodeTest) { UNIT_ASSERT_VALUES_EQUAL(res, 6); } - Y_UNIT_TEST_LLVM(TestFold1OverEmptyList) { + Y_UNIT_TEST_LLVM(TestFold1OverEmptyList) { TSetup<LLVM> setup; TProgramBuilder& pb = *setup.PgmBuilder; @@ -50,7 +50,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLFoldNodeTest) { UNIT_ASSERT(!value); } - Y_UNIT_TEST_LLVM(TestFold1OverSingleElementList) { + Y_UNIT_TEST_LLVM(TestFold1OverSingleElementList) { TSetup<LLVM> setup; TProgramBuilder& pb = *setup.PgmBuilder; @@ -72,7 +72,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLFoldNodeTest) { UNIT_ASSERT_VALUES_EQUAL(value.template Get<ui32>(), 2); } - Y_UNIT_TEST_LLVM(TestFold1OverManyElementList) { + Y_UNIT_TEST_LLVM(TestFold1OverManyElementList) { TSetup<LLVM> setup; TProgramBuilder& pb = *setup.PgmBuilder; @@ -94,7 +94,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLFoldNodeTest) { UNIT_ASSERT_VALUES_EQUAL(value.template Get<ui32>(), 4); } - Y_UNIT_TEST_LLVM(TestFoldWithAggrAdd) { + Y_UNIT_TEST_LLVM(TestFoldWithAggrAdd) { TSetup<LLVM> setup; TProgramBuilder& pb = *setup.PgmBuilder; @@ -116,7 +116,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLFoldNodeTest) { UNIT_ASSERT_VALUES_EQUAL(res, 47); } - Y_UNIT_TEST_LLVM(TestNestedApply) { + Y_UNIT_TEST_LLVM(TestNestedApply) { TSetup<LLVM> setup; TProgramBuilder& pb = *setup.PgmBuilder; @@ -131,7 +131,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLFoldNodeTest) { auto pgmReturn = pb.Fold(list, pb.NewDataLiteral<i32>(100), [&](TRuntimeNode item, TRuntimeNode state) { return pb.Apply(pb.Callable(callType, - [&](const TArrayRef<const TRuntimeNode>& args) { + [&](const TArrayRef<const TRuntimeNode>& args) { return pb.Sub(args[1], args[0]); }), {item, state}); }); @@ -141,7 +141,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLFoldNodeTest) { UNIT_ASSERT_VALUES_EQUAL(res, 94); } - Y_UNIT_TEST_LLVM(TestLogicalOpts) { + Y_UNIT_TEST_LLVM(TestLogicalOpts) { TSetup<LLVM> setup; TProgramBuilder& pb = *setup.PgmBuilder; @@ -426,7 +426,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLFoldNodeTest) { UNIT_ASSERT(!iterator.Next(item)); } - Y_UNIT_TEST_LLVM(TestFoldWithListInState) { + Y_UNIT_TEST_LLVM(TestFoldWithListInState) { TSetup<LLVM> setup; TProgramBuilder& pb = *setup.PgmBuilder; @@ -467,7 +467,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLFoldNodeTest) { UNIT_ASSERT_VALUES_EQUAL(graph->GetValue().GetElement(1).template Get<ui32>(), 3); } - Y_UNIT_TEST_LLVM(TestManyAppend) { + Y_UNIT_TEST_LLVM(TestManyAppend) { TSetup<LLVM> setup; TProgramBuilder& pb = *setup.PgmBuilder; @@ -483,7 +483,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLFoldNodeTest) { auto fold = pb.Fold(zeroList, state, [&](TRuntimeNode item, TRuntimeNode state) { - Y_UNUSED(item); + Y_UNUSED(item); auto oldList = pb.Member(state, "NewList"); auto oldCounter = pb.Member(state, "Counter"); return pb.AddMember(pb.AddMember(pb.NewEmptyStruct(), "Counter", @@ -505,7 +505,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLFoldNodeTest) { UNIT_ASSERT_VALUES_EQUAL(i, 1 << n); } - Y_UNIT_TEST_LLVM(TestManyPrepend) { + Y_UNIT_TEST_LLVM(TestManyPrepend) { TSetup<LLVM> setup; TProgramBuilder& pb = *setup.PgmBuilder; @@ -521,7 +521,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLFoldNodeTest) { auto fold = pb.Fold(zeroList, state, [&](TRuntimeNode item, TRuntimeNode state) { - Y_UNUSED(item); + Y_UNUSED(item); auto oldList = pb.Member(state, "NewList"); auto oldCounter = pb.Member(state, "Counter"); return pb.AddMember(pb.AddMember(pb.NewEmptyStruct(), "Counter", @@ -543,7 +543,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLFoldNodeTest) { UNIT_ASSERT_VALUES_EQUAL(i, 0); } - Y_UNIT_TEST_LLVM(TestManyExtend) { + Y_UNIT_TEST_LLVM(TestManyExtend) { TSetup<LLVM> setup; TProgramBuilder& pb = *setup.PgmBuilder; @@ -559,7 +559,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLFoldNodeTest) { auto fold = pb.Fold(zeroList, state, [&](TRuntimeNode item, TRuntimeNode state) { - Y_UNUSED(item); + Y_UNUSED(item); auto oldList = pb.Member(state, "NewList"); auto oldCounter = pb.Member(state, "Counter"); auto oldCounterMul2 = pb.Mul(oldCounter, pb.NewDataLiteral<ui32>(2)); @@ -585,7 +585,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLFoldNodeTest) { UNIT_ASSERT_VALUES_EQUAL(i, 1 << (n + 1)); } - Y_UNIT_TEST_LLVM(TestFoldSingular) { + Y_UNIT_TEST_LLVM(TestFoldSingular) { TSetup<LLVM> setup; TProgramBuilder& pb = *setup.PgmBuilder; @@ -596,13 +596,13 @@ Y_UNIT_TEST_SUITE(TMiniKQLFoldNodeTest) { auto list = pb.NewList(dataType, {data1, data2, data3}); auto fold1 = pb.Fold(list, pb.NewDataLiteral<ui32>(0), [&](TRuntimeNode item, TRuntimeNode state) { - Y_UNUSED(state); + Y_UNUSED(state); return item; }); auto fold2 = pb.Fold(list, pb.NewDataLiteral<ui32>(0), [&](TRuntimeNode item, TRuntimeNode state) { - Y_UNUSED(item); + Y_UNUSED(item); return state; }); @@ -668,7 +668,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLFoldNodeTest) { UNIT_ASSERT(graph->GetValue().template Get<bool>()); } - Y_UNIT_TEST_LLVM(TestConcat) { + Y_UNIT_TEST_LLVM(TestConcat) { TSetup<LLVM> setup; TProgramBuilder& pb = *setup.PgmBuilder; @@ -688,7 +688,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLFoldNodeTest) { UNBOXED_VALUE_STR_EQUAL(res, "Xaabbbzzzz"); } - Y_UNIT_TEST_LLVM(TestConcatOpt) { + Y_UNIT_TEST_LLVM(TestConcatOpt) { TSetup<LLVM> setup; TProgramBuilder& pb = *setup.PgmBuilder; @@ -729,7 +729,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLFoldNodeTest) { UNBOXED_VALUE_STR_EQUAL(str, "PREFIX:very large string:SUFFIX"); } - Y_UNIT_TEST_LLVM(TestLongFold) { + Y_UNIT_TEST_LLVM(TestLongFold) { for (ui32 i = 0; i < 10; ++i) { TSetup<LLVM> setup; TProgramBuilder& pb = *setup.PgmBuilder; diff --git a/ydb/library/yql/minikql/comp_nodes/ut/mkql_group_ut.cpp b/ydb/library/yql/minikql/comp_nodes/ut/mkql_group_ut.cpp index 1833bbf5095..009b1a55943 100644 --- a/ydb/library/yql/minikql/comp_nodes/ut/mkql_group_ut.cpp +++ b/ydb/library/yql/minikql/comp_nodes/ut/mkql_group_ut.cpp @@ -73,7 +73,7 @@ TRuntimeNode StreamToString(TSetup<UseLLVM>& setup, TRuntimeNode stream) { } // unnamed -Y_UNIT_TEST_SUITE(TMiniKQLGroupingTest) { +Y_UNIT_TEST_SUITE(TMiniKQLGroupingTest) { Y_UNIT_TEST_LLVM(TestGrouping) { TSetup<LLVM> setup; TProgramBuilder& pgmBuilder = *setup.PgmBuilder; diff --git a/ydb/library/yql/minikql/comp_nodes/ut/mkql_safe_circular_buffer_ut.cpp b/ydb/library/yql/minikql/comp_nodes/ut/mkql_safe_circular_buffer_ut.cpp index 9df6d01d4ec..b4da703c625 100644 --- a/ydb/library/yql/minikql/comp_nodes/ut/mkql_safe_circular_buffer_ut.cpp +++ b/ydb/library/yql/minikql/comp_nodes/ut/mkql_safe_circular_buffer_ut.cpp @@ -8,10 +8,10 @@ namespace NKikimr { using namespace NUdf; namespace NMiniKQL { -Y_UNIT_TEST_SUITE(TMiniKQLSafeCircularBuffer) { +Y_UNIT_TEST_SUITE(TMiniKQLSafeCircularBuffer) { typedef TSafeCircularBuffer<TUnboxedValue> TBufUnboxed; - Y_UNIT_TEST(TestUnboxedNoFailOnEmpty) { + Y_UNIT_TEST(TestUnboxedNoFailOnEmpty) { TBufUnboxed bufferOptional(1, TUnboxedValuePod()); TBufUnboxed buffer(1, TUnboxedValue::Void()); UNIT_ASSERT(buffer.Get(0)); @@ -23,7 +23,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLSafeCircularBuffer) { } } - Y_UNIT_TEST(TestUnboxedNormalUsage) { + Y_UNIT_TEST(TestUnboxedNormalUsage) { TBufUnboxed buffer(5, TUnboxedValuePod()); buffer.PushBack(TUnboxedValue::Embedded("It")); UNIT_ASSERT_EQUAL(buffer.Get(0).AsStringRef(), "It"); @@ -110,7 +110,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLSafeCircularBuffer) { UNIT_ASSERT_EQUAL(buffer.Size(), 103); } - Y_UNIT_TEST(TestUnboxedFewCycles) { + Y_UNIT_TEST(TestUnboxedFewCycles) { const auto multFillLevel = 0.6; const auto multPopLevel = 0.5; const auto initSize = 10; diff --git a/ydb/library/yql/minikql/compact_hash.cpp b/ydb/library/yql/minikql/compact_hash.cpp index 17810ccacbf..78e62a85161 100644 --- a/ydb/library/yql/minikql/compact_hash.cpp +++ b/ydb/library/yql/minikql/compact_hash.cpp @@ -14,7 +14,7 @@ void TListPoolBase::FreeListPage(TListHeader* p) { PagePool_.ReturnPage(p); } -size_t TListPoolBase::TUsedPages::PrintStat(const TStringBuf& header, IOutputStream& out) const { +size_t TListPoolBase::TUsedPages::PrintStat(const TStringBuf& header, IOutputStream& out) const { TMap<ui32, ui64> counts; size_t pages = 0; for (auto& p: FullPages) { diff --git a/ydb/library/yql/minikql/compact_hash.h b/ydb/library/yql/minikql/compact_hash.h index a9586db4640..04873239490 100644 --- a/ydb/library/yql/minikql/compact_hash.h +++ b/ydb/library/yql/minikql/compact_hash.h @@ -17,7 +17,7 @@ #include <util/system/defaults.h> #include <util/system/unaligned_mem.h> #include <util/system/align.h> -#include <util/stream/output.h> +#include <util/stream/output.h> #include <type_traits> #include <cmath> @@ -222,17 +222,17 @@ public: template <typename T> static inline constexpr ui16 GetMediumPageCapacity(size_t listSize) { - return static_cast<ui16>((TAlignedPagePool::POOL_PAGE_SIZE - sizeof(TListHeader)) / (FastClp2(listSize) * sizeof(T) + sizeof(ui16))) & 0x7FFF; + return static_cast<ui16>((TAlignedPagePool::POOL_PAGE_SIZE - sizeof(TListHeader)) / (FastClp2(listSize) * sizeof(T) + sizeof(ui16))) & 0x7FFF; } template <typename T> static inline constexpr ui32 GetLargePageCapacity() { - return static_cast<ui32>((TAlignedPagePool::POOL_PAGE_SIZE - sizeof(TLargeListHeader)) / sizeof(T)); + return static_cast<ui32>((TAlignedPagePool::POOL_PAGE_SIZE - sizeof(TLargeListHeader)) / sizeof(T)); } template <typename T> static inline constexpr size_t GetMaxListSize() { -#define NCHASH_RAW_SIZE ((((TAlignedPagePool::POOL_PAGE_SIZE - sizeof(TListHeader)) / 2) - sizeof(ui16)) / sizeof(T)) +#define NCHASH_RAW_SIZE ((((TAlignedPagePool::POOL_PAGE_SIZE - sizeof(TListHeader)) / 2) - sizeof(ui16)) / sizeof(T)) // For medium lists get downward pow2 num return NCHASH_RAW_SIZE > 16 ? 1ULL << MostSignificantBitCT(NCHASH_RAW_SIZE) : NCHASH_RAW_SIZE; #undef NCHASH_RAW_SIZE @@ -263,7 +263,7 @@ protected: } // Returns count of used pages - size_t PrintStat(const TStringBuf& header, IOutputStream& out) const; + size_t PrintStat(const TStringBuf& header, IOutputStream& out) const; TString DebugInfo() const; std::array<TListType, MAX_SMALL_LIST_SIZE - 1> SmallPages; // 2-16 sizes @@ -525,7 +525,7 @@ public: DoSwap(Pools, other.Pools); } - void PrintStat(IOutputStream& out) const { + void PrintStat(IOutputStream& out) const { size_t usedPages = 0; if (std::is_same<TPrimary, TSecondary>::value) { usedPages = Pools[0].PrintStat(TStringBuf(""), out); @@ -652,7 +652,7 @@ private: const size_t byteListSize = AlignUp<size_t>(sizeof(T) * listHeader->ListSize, sizeof(ui16)); Y_ASSERT((reinterpret_cast<ui8*>(list) - reinterpret_cast<ui8*>(listHeader + 1)) % byteListSize == 0); const ui64 offset = (reinterpret_cast<ui8*>(list) - reinterpret_cast<ui8*>(listHeader + 1)) / byteListSize; - Y_ASSERT(offset < TAlignedPagePool::POOL_PAGE_SIZE); + Y_ASSERT(offset < TAlignedPagePool::POOL_PAGE_SIZE); *reinterpret_cast<ui16*>(list) = listHeader->FreeListOffset | 0x8000u; listHeader->FreeListOffset = offset; ++listHeader->FreeLists; @@ -671,7 +671,7 @@ private: DestroyRange(list, list + *l); Y_ASSERT((reinterpret_cast<ui8*>(l) - reinterpret_cast<ui8*>(listHeader + 1)) % (listHeader->ListSize * sizeof(T) + sizeof(ui16)) == 0); ui64 offset = (reinterpret_cast<ui8*>(l) - reinterpret_cast<ui8*>(listHeader + 1)) / (listHeader->ListSize * sizeof(T) + sizeof(ui16)); - Y_ASSERT(offset < TAlignedPagePool::POOL_PAGE_SIZE); + Y_ASSERT(offset < TAlignedPagePool::POOL_PAGE_SIZE); *l = listHeader->FreeListOffset | 0x8000u; listHeader->FreeListOffset = offset; ++listHeader->FreeLists; @@ -1285,7 +1285,7 @@ public: return true; } - void PrintStat(IOutputStream& out) const { + void PrintStat(IOutputStream& out) const { size_t empty = 0; size_t single = 0; size_t list = 0; @@ -1323,7 +1323,7 @@ protected: } void AllocateBuckets(size_t count) { - auto bucketsMemory = Max(sizeof(TItemNode) * count, (size_t)TAlignedPagePool::POOL_PAGE_SIZE); + auto bucketsMemory = Max(sizeof(TItemNode) * count, (size_t)TAlignedPagePool::POOL_PAGE_SIZE); Buckets_ = (TItemNode*)GetPagePool().GetBlock(bucketsMemory); BucketsCount_ = count; BucketsMemory_ = bucketsMemory; diff --git a/ydb/library/yql/minikql/compact_hash_ut.cpp b/ydb/library/yql/minikql/compact_hash_ut.cpp index 02278f64cb7..5addfef0ea9 100644 --- a/ydb/library/yql/minikql/compact_hash_ut.cpp +++ b/ydb/library/yql/minikql/compact_hash_ut.cpp @@ -12,7 +12,7 @@ using namespace NKikimr; using namespace NKikimr::NCHash; -Y_UNIT_TEST_SUITE(TCompactHashTest) { +Y_UNIT_TEST_SUITE(TCompactHashTest) { template <typename TItem> void TestListPoolPagesImpl(size_t listSize, ui16 countOfLists, size_t expectedListCapacity, ui32 expectedMark) { @@ -92,33 +92,33 @@ Y_UNIT_TEST_SUITE(TCompactHashTest) { pool.ReturnList(l); } - Y_UNIT_TEST(TestListPoolSmallPagesByte) { + Y_UNIT_TEST(TestListPoolSmallPagesByte) { ui16 count = TListPoolBase::GetSmallPageCapacity<ui8>(2); TestListPoolPagesImpl<ui8>(2, count, 2, TListPoolBase::SMALL_MARK); } - Y_UNIT_TEST(TestListPoolMediumPagesByte) { + Y_UNIT_TEST(TestListPoolMediumPagesByte) { size_t listSize = TListPoolBase::MAX_SMALL_LIST_SIZE + 1; ui16 count = TListPoolBase::GetMediumPageCapacity<ui8>(listSize); TestListPoolPagesImpl<ui8>(listSize, count, FastClp2(listSize), TListPoolBase::MEDIUM_MARK); } - Y_UNIT_TEST(TestListPoolLargPagesByte) { + Y_UNIT_TEST(TestListPoolLargPagesByte) { TestListPoolLargeImpl<ui8>(); } - Y_UNIT_TEST(TestListPoolSmallPagesUi64) { + Y_UNIT_TEST(TestListPoolSmallPagesUi64) { ui16 count = TListPoolBase::GetSmallPageCapacity<ui64>(2); TestListPoolPagesImpl<ui64>(2, count, 2, TListPoolBase::SMALL_MARK); } - Y_UNIT_TEST(TestListPoolMediumPagesUi64) { + Y_UNIT_TEST(TestListPoolMediumPagesUi64) { size_t listSize = TListPoolBase::MAX_SMALL_LIST_SIZE + 1; ui16 count = TListPoolBase::GetMediumPageCapacity<ui64>(listSize); TestListPoolPagesImpl<ui64>(listSize, count, FastClp2(listSize), TListPoolBase::MEDIUM_MARK); } - Y_UNIT_TEST(TestListPoolLargPagesUi64) { + Y_UNIT_TEST(TestListPoolLargPagesUi64) { TestListPoolLargeImpl<ui64>(); } @@ -126,18 +126,18 @@ Y_UNIT_TEST_SUITE(TCompactHashTest) { ui8 A[256]; }; - Y_UNIT_TEST(TestListPoolSmallPagesObj) { + Y_UNIT_TEST(TestListPoolSmallPagesObj) { ui16 count = TListPoolBase::GetSmallPageCapacity<TItem>(2); TestListPoolPagesImpl<TItem>(2, count, 2, TListPoolBase::SMALL_MARK); } - Y_UNIT_TEST(TestListPoolMediumPagesObj) { + Y_UNIT_TEST(TestListPoolMediumPagesObj) { size_t listSize = TListPoolBase::MAX_SMALL_LIST_SIZE + 1; ui16 count = TListPoolBase::GetMediumPageCapacity<TItem>(listSize); TestListPoolPagesImpl<TItem>(listSize, count, FastClp2(listSize), TListPoolBase::MEDIUM_MARK); } - Y_UNIT_TEST(TestListPoolLargPagesObj) { + Y_UNIT_TEST(TestListPoolLargPagesObj) { TestListPoolLargeImpl<TItem>(); } @@ -335,39 +335,39 @@ Y_UNIT_TEST_SUITE(TCompactHashTest) { UNIT_ASSERT_VALUES_EQUAL(sumKeys, sumKeysTarget); } - Y_UNIT_TEST(TestHashByte) { + Y_UNIT_TEST(TestHashByte) { TestHashImpl<ui8>(); } - Y_UNIT_TEST(TestMultiHashByte) { + Y_UNIT_TEST(TestMultiHashByte) { TestMultiHashImpl<ui8>(); } - Y_UNIT_TEST(TestSetByte) { + Y_UNIT_TEST(TestSetByte) { TestSetImpl<ui8>(); } - Y_UNIT_TEST(TestHashUi16) { + Y_UNIT_TEST(TestHashUi16) { TestHashImpl<ui16>(); } - Y_UNIT_TEST(TestMultiHashUi16) { + Y_UNIT_TEST(TestMultiHashUi16) { TestMultiHashImpl<ui16>(); } - Y_UNIT_TEST(TestSetUi16) { + Y_UNIT_TEST(TestSetUi16) { TestSetImpl<ui16>(); } - Y_UNIT_TEST(TestHashUi64) { + Y_UNIT_TEST(TestHashUi64) { TestHashImpl<ui64>(); } - Y_UNIT_TEST(TestMultiHashUi64) { + Y_UNIT_TEST(TestMultiHashUi64) { TestMultiHashImpl<ui64>(); } - Y_UNIT_TEST(TestSetUi64) { + Y_UNIT_TEST(TestSetUi64) { TestSetImpl<ui64>(); } diff --git a/ydb/library/yql/minikql/computation/mkql_computation_list_adapter.h b/ydb/library/yql/minikql/computation/mkql_computation_list_adapter.h index 2b3b7fb8865..a8e2d5fdb00 100644 --- a/ydb/library/yql/minikql/computation/mkql_computation_list_adapter.h +++ b/ydb/library/yql/minikql/computation/mkql_computation_list_adapter.h @@ -110,7 +110,7 @@ public: , Finish(finish) , Reversed(reversed) { - Y_VERIFY(Start <= Finish && Finish <= List.size()); + Y_VERIFY(Start <= Finish && Finish <= List.size()); } private: @@ -131,7 +131,7 @@ private: } NUdf::IBoxedValuePtr ReverseListImpl(const NUdf::IValueBuilder& builder) const override { - Y_UNUSED(builder); + Y_UNUSED(builder); return new TSelf(this->GetMemInfo(), List, ItemFactory, Start, Finish, !Reversed); } @@ -156,7 +156,7 @@ private: } NUdf::IBoxedValuePtr ToIndexDictImpl(const NUdf::IValueBuilder& builder) const override { - Y_UNUSED(builder); + Y_UNUSED(builder); return const_cast<TVectorListAdapter*>(this); } diff --git a/ydb/library/yql/minikql/computation/mkql_computation_node_graph.cpp b/ydb/library/yql/minikql/computation/mkql_computation_node_graph.cpp index f2b188ae47c..928a864aea2 100644 --- a/ydb/library/yql/minikql/computation/mkql_computation_node_graph.cpp +++ b/ydb/library/yql/minikql/computation/mkql_computation_node_graph.cpp @@ -813,7 +813,7 @@ TIntrusivePtr<TComputationPatternImpl> MakeComputationPatternImpl(TExploringNode auto builder = MakeHolder<TComputationGraphBuildingVisitor>(opts); for (const auto& node : explorer.GetNodes()) { - Y_VERIFY(node->GetCookie() <= IS_NODE_REACHABLE, "TNode graph should not be reused"); + Y_VERIFY(node->GetCookie() <= IS_NODE_REACHABLE, "TNode graph should not be reused"); if (node->GetCookie() == IS_NODE_REACHABLE) { node->Accept(*builder); } diff --git a/ydb/library/yql/minikql/computation/mkql_computation_node_graph_saveload_ut.cpp b/ydb/library/yql/minikql/computation/mkql_computation_node_graph_saveload_ut.cpp index cc734e11d60..852449ca992 100644 --- a/ydb/library/yql/minikql/computation/mkql_computation_node_graph_saveload_ut.cpp +++ b/ydb/library/yql/minikql/computation/mkql_computation_node_graph_saveload_ut.cpp @@ -103,8 +103,8 @@ namespace { }; } -Y_UNIT_TEST_SUITE(TMiniKQLSaveLoadTest) { - Y_UNIT_TEST(TestSqueezeSaveLoad) { +Y_UNIT_TEST_SUITE(TMiniKQLSaveLoadTest) { + Y_UNIT_TEST(TestSqueezeSaveLoad) { TScopedAlloc alloc; const std::vector<ui32> items = {2, 3, 4, 5, 6, 7, 8}; @@ -169,7 +169,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLSaveLoadTest) { } } - Y_UNIT_TEST(TestSqueeze1SaveLoad) { + Y_UNIT_TEST(TestSqueeze1SaveLoad) { TScopedAlloc alloc; const std::vector<ui32> items = {1, 2, 3, 4, 5, 6, 7, 8}; @@ -237,7 +237,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLSaveLoadTest) { } } - Y_UNIT_TEST(TestHoppingSaveLoad) { + Y_UNIT_TEST(TestHoppingSaveLoad) { TScopedAlloc alloc; const std::vector<std::pair<i64, ui32>> items = { diff --git a/ydb/library/yql/minikql/computation/mkql_computation_node_holders.cpp b/ydb/library/yql/minikql/computation/mkql_computation_node_holders.cpp index 67a7cfb3028..e18305a3f88 100644 --- a/ydb/library/yql/minikql/computation/mkql_computation_node_holders.cpp +++ b/ydb/library/yql/minikql/computation/mkql_computation_node_holders.cpp @@ -204,7 +204,7 @@ private: } NUdf::IBoxedValuePtr ToIndexDictImpl(const NUdf::IValueBuilder& builder) const override { - Y_UNUSED(builder); + Y_UNUSED(builder); return const_cast<TDirectListHolder*>(this); } @@ -1111,10 +1111,10 @@ private: Reverse(Items.begin(), Items.end()); break; default: - Y_FAIL(); + Y_FAIL(); } - Y_VERIFY_DEBUG(IsSortedUnique()); + Y_VERIFY_DEBUG(IsSortedUnique()); IsBuilt = true; if (!Items.empty()) { diff --git a/ydb/library/yql/minikql/computation/mkql_computation_node_impl.h b/ydb/library/yql/minikql/computation/mkql_computation_node_impl.h index 0a63ca9d349..f0cfa61887d 100644 --- a/ydb/library/yql/minikql/computation/mkql_computation_node_impl.h +++ b/ydb/library/yql/minikql/computation/mkql_computation_node_impl.h @@ -832,24 +832,24 @@ private: } NUdf::IBoxedValuePtr ReverseListImpl(const NUdf::IValueBuilder& builder) const override { - Y_UNUSED(builder); + Y_UNUSED(builder); return nullptr; } NUdf::IBoxedValuePtr SkipListImpl(const NUdf::IValueBuilder& builder, ui64 count) const override { - Y_UNUSED(builder); - Y_UNUSED(count); + Y_UNUSED(builder); + Y_UNUSED(count); return nullptr; } NUdf::IBoxedValuePtr TakeListImpl(const NUdf::IValueBuilder& builder, ui64 count) const override { - Y_UNUSED(builder); - Y_UNUSED(count); + Y_UNUSED(builder); + Y_UNUSED(count); return nullptr; } NUdf::IBoxedValuePtr ToIndexDictImpl(const NUdf::IValueBuilder& builder) const override { - Y_UNUSED(builder); + Y_UNUSED(builder); return nullptr; } @@ -923,8 +923,8 @@ private: const NUdf::IValueBuilder* valueBuilder, const NUdf::TUnboxedValuePod* args) const override { - Y_UNUSED(valueBuilder); - Y_UNUSED(args); + Y_UNUSED(valueBuilder); + Y_UNUSED(args); ThrowNotSupported(__func__); return {}; } diff --git a/ydb/library/yql/minikql/computation/mkql_computation_node_pack.h b/ydb/library/yql/minikql/computation/mkql_computation_node_pack.h index c69f4467a3a..0475b68a280 100644 --- a/ydb/library/yql/minikql/computation/mkql_computation_node_pack.h +++ b/ydb/library/yql/minikql/computation/mkql_computation_node_pack.h @@ -8,7 +8,7 @@ #include <library/cpp/enumbitset/enumbitset.h> -#include <util/stream/output.h> +#include <util/stream/output.h> #include <util/generic/buffer.h> #include <util/generic/strbuf.h> diff --git a/ydb/library/yql/minikql/computation/mkql_validate_ut.cpp b/ydb/library/yql/minikql/computation/mkql_validate_ut.cpp index ed2f12303a1..a7e9d525e73 100644 --- a/ydb/library/yql/minikql/computation/mkql_validate_ut.cpp +++ b/ydb/library/yql/minikql/computation/mkql_validate_ut.cpp @@ -394,26 +394,26 @@ namespace { long TThrowerValue::Count = 0L; SIMPLE_UDF(TVoid, void()) { - Y_UNUSED(valueBuilder); - Y_UNUSED(args); + Y_UNUSED(valueBuilder); + Y_UNUSED(args); return NUdf::TUnboxedValuePod::Void(); } SIMPLE_UDF_RUN(TNonEmpty, ui32(), NUdf::TOptional<void>) { - Y_UNUSED(valueBuilder); - Y_UNUSED(args); + Y_UNUSED(valueBuilder); + Y_UNUSED(args); return NUdf::TUnboxedValuePod(42); } SIMPLE_UDF(TOptionalNonEmpty, NUdf::TOptional<ui32>()) { - Y_UNUSED(valueBuilder); - Y_UNUSED(args); + Y_UNUSED(valueBuilder); + Y_UNUSED(args); return NUdf::TUnboxedValuePod(42); } SIMPLE_UDF_RUN(TOptionalEmpty, NUdf::TOptional<ui32>(), NUdf::TOptional<void>) { - Y_UNUSED(valueBuilder); - Y_UNUSED(args); + Y_UNUSED(valueBuilder); + Y_UNUSED(args); return NUdf::TUnboxedValuePod(); } @@ -449,7 +449,7 @@ namespace { } SIMPLE_UDF_RUN(TSeqListWithHole, NUdf::TListType<ui32>(ui32, ui32), NUdf::TOptional<void>) { - Y_UNUSED(valueBuilder); + Y_UNUSED(valueBuilder); const ui32 size = args[0].Get<ui32>(); const ui32 hole = args[1].Get<ui32>(); NUdf::IBoxedValuePtr boxed(new TBrokenSeqListBoxedValue(size, hole)); @@ -594,7 +594,7 @@ namespace { } SIMPLE_UDF(TDictOfPerson, NUdfDictDigPerson()) { - Y_UNUSED(args); + Y_UNUSED(args); Y_UNUSED(valueBuilder); NUdf::IBoxedValuePtr boxed(new TBrokenDictBoxedValue<ui32, NUdf::IBoxedValuePtr>( MAKE_DICT_DIGIT2PERSON(), std::make_pair(RAW_INDEX_NO_HOLE, RAW_INDEX_NO_HOLE))); @@ -602,7 +602,7 @@ namespace { } SIMPLE_UDF_RUN(TDictOfPersonBroken, NUdfDictDigPerson(), NUdf::TOptional<void>) { - Y_UNUSED(args); + Y_UNUSED(args); Y_UNUSED(valueBuilder); NUdf::IBoxedValuePtr boxed(new TBrokenDictBoxedValue<ui32, NUdf::IBoxedValuePtr>( MAKE_DICT_DIGIT2PERSON_BROKEN(), std::make_pair(RAW_INDEX_NO_HOLE, RAW_INDEX_NO_HOLE))); @@ -639,7 +639,7 @@ TIntrusivePtr<IFunctionRegistry> CreateFunctionRegistryWithUDFs() { return freg; } -Y_UNIT_TEST_SUITE(TMiniKQLValidateTest) { +Y_UNIT_TEST_SUITE(TMiniKQLValidateTest) { typedef std::function<std::vector<TRuntimeNode>(TProgramBuilder&)> BuildArgsFunc; typedef std::function<void(const NUdf::TUnboxedValuePod&, const NUdf::IValueBuilder*)> ValidateValueFunc; typedef std::function<void(const NUdf::TUnboxedValuePod&, const NUdf::IValueBuilder*, const TType* type)> FullValidateValueFunc; @@ -690,7 +690,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLValidateTest) { } } - Y_UNIT_TEST(TestUdfException) { + Y_UNIT_TEST(TestUdfException) { ValidateValueFunc validateFunc = [](const NUdf::TUnboxedValuePod& value, const NUdf::IValueBuilder* valueBuilder) { valueBuilder->NewStringNotFilled(0xBAD).AsStringValue().Ref(); // Leak string. NUdf::TBoxedValueAccessor::Skip(*value.GetListIterator().AsBoxed().Release()); // Leak value and throw exception. @@ -699,11 +699,11 @@ Y_UNIT_TEST_SUITE(TMiniKQLValidateTest) { UNIT_ASSERT_VALUES_EQUAL(TThrowerValue::Count, 0L); } - Y_UNIT_TEST(TestUdfResultCheckVoid) { + Y_UNIT_TEST(TestUdfResultCheckVoid) { ProcessSimpleUdfFunc("UtUDF.Void"); } - Y_UNIT_TEST(TestUdfResultCheckExceptionOnEmpty) { + Y_UNIT_TEST(TestUdfResultCheckExceptionOnEmpty) { TScopedAlloc alloc; TTypeEnvironment env(alloc); bool wrapped = false; @@ -712,15 +712,15 @@ Y_UNIT_TEST_SUITE(TMiniKQLValidateTest) { UNIT_ASSERT(!wrapped); } - Y_UNIT_TEST(TestUdfResultCheckNonEmpty) { + Y_UNIT_TEST(TestUdfResultCheckNonEmpty) { ProcessSimpleUdfFunc("UtUDF.NonEmpty"); } - Y_UNIT_TEST(TestUdfResultCheckOptionalNonEmpty) { + Y_UNIT_TEST(TestUdfResultCheckOptionalNonEmpty) { ProcessSimpleUdfFunc("UtUDF.OptionalNonEmpty"); } - Y_UNIT_TEST(TestUdfResultCheckOptionalEmpty) { + Y_UNIT_TEST(TestUdfResultCheckOptionalEmpty) { ProcessSimpleUdfFunc("UtUDF.OptionalEmpty"); } @@ -740,7 +740,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLValidateTest) { return std::vector<TRuntimeNode>{callable, pgmBuilder.NewDataLiteral(testVal)}; }; - Y_UNIT_TEST(TestVerifyArgsCallableCorrect) { + Y_UNIT_TEST(TestVerifyArgsCallableCorrect) { ui32 testVal = 44; BuildArgsFunc argsFunc = [testVal](TProgramBuilder& pgmBuilder) { return MakeCallableInArgs(testVal, pgmBuilder); @@ -752,7 +752,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLValidateTest) { ProcessSimpleUdfFunc("UtUDF.BackSub2Mul2", argsFunc, validateFunc); } - Y_UNIT_TEST(TestVerifyArgsCallableBrokenOnArgument) { + Y_UNIT_TEST(TestVerifyArgsCallableBrokenOnArgument) { ui32 testVal = 101; BuildArgsFunc argsFunc = [testVal](TProgramBuilder& pgmBuilder) { return MakeCallableInArgs(testVal, pgmBuilder); @@ -760,7 +760,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLValidateTest) { UNIT_ASSERT_EXCEPTION(ProcessSimpleUdfFunc("UtUDF.BackSub2Mul2", argsFunc), TUdfValidateException); } - Y_UNIT_TEST(TestVerifyArgsCallableBrokenOnReturn) { + Y_UNIT_TEST(TestVerifyArgsCallableBrokenOnReturn) { ui32 testVal = 1; BuildArgsFunc argsFunc = [testVal](TProgramBuilder& pgmBuilder) { return MakeCallableInArgs(testVal, pgmBuilder); @@ -768,7 +768,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLValidateTest) { UNIT_ASSERT_EXCEPTION(ProcessSimpleUdfFunc("UtUDF.BackSub2Mul2", argsFunc), TUdfValidateException); } - Y_UNIT_TEST(TestUdfResultCheckEmptySeqList) { + Y_UNIT_TEST(TestUdfResultCheckEmptySeqList) { BuildArgsFunc argsFunc = [](TProgramBuilder& pgmBuilder) { return std::vector<TRuntimeNode>{pgmBuilder.NewDataLiteral<ui32>(0)}; }; @@ -780,7 +780,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLValidateTest) { ProcessSimpleUdfFunc("UtUDF.SeqList", argsFunc, validateFunc); } - Y_UNIT_TEST(TestUdfResultCheckSeqList) { + Y_UNIT_TEST(TestUdfResultCheckSeqList) { static constexpr ui32 listSize = 31; BuildArgsFunc argsFunc = [](TProgramBuilder& pgmBuilder) { return std::vector<TRuntimeNode>{pgmBuilder.NewDataLiteral(listSize)}; @@ -797,7 +797,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLValidateTest) { ProcessSimpleUdfFunc("UtUDF.SeqList", argsFunc, validateFunc); } - Y_UNIT_TEST(TestUdfResultCheckSeqListWithHoleFirst) { + Y_UNIT_TEST(TestUdfResultCheckSeqListWithHoleFirst) { BuildArgsFunc argsFunc = [](TProgramBuilder& pgmBuilder) { const ui32 listSize = 31; return std::vector<TRuntimeNode>{pgmBuilder.NewDataLiteral(listSize), @@ -816,7 +816,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLValidateTest) { UNIT_ASSERT_EXCEPTION(ProcessSimpleUdfFunc("UtUDF.SeqListWithHole", argsFunc, validateFunc, {}, NUdf::EValidateMode::Greedy), TUdfValidateException); } - Y_UNIT_TEST(TestUdfResultCheckSeqListWithHoleMiddle) { + Y_UNIT_TEST(TestUdfResultCheckSeqListWithHoleMiddle) { static constexpr ui32 listSize = 31; BuildArgsFunc argsFunc = [](TProgramBuilder& pgmBuilder) { return std::vector<TRuntimeNode>{pgmBuilder.NewDataLiteral(listSize), @@ -841,7 +841,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLValidateTest) { UNIT_ASSERT_EXCEPTION(ProcessSimpleUdfFunc("UtUDF.SeqListWithHole", argsFunc, validateFunc, {}, NUdf::EValidateMode::Greedy), TUdfValidateException); } - Y_UNIT_TEST(TestUdfResultCheckSeqListWithHoleLast) { + Y_UNIT_TEST(TestUdfResultCheckSeqListWithHoleLast) { static constexpr ui32 listSize = 31; BuildArgsFunc argsFunc = [](TProgramBuilder& pgmBuilder) { return std::vector<TRuntimeNode>{pgmBuilder.NewDataLiteral(listSize), @@ -863,35 +863,35 @@ Y_UNIT_TEST_SUITE(TMiniKQLValidateTest) { UNIT_ASSERT_EXCEPTION(ProcessSimpleUdfFunc("UtUDF.SeqListWithHole", argsFunc, validateFunc, {}, NUdf::EValidateMode::Greedy), TUdfValidateException); } - Y_UNIT_TEST(TestUdfResultCheckTuple) { + Y_UNIT_TEST(TestUdfResultCheckTuple) { BuildArgsFunc argsFunc = [](TProgramBuilder& pgmBuilder) { return std::vector<TRuntimeNode>{pgmBuilder.NewDataLiteral(RAW_INDEX_NO_HOLE)}; }; ProcessSimpleUdfFunc("UtUDF.Tuple", argsFunc); } - Y_UNIT_TEST(TestUdfResultCheckTupleWithHoleFirst) { + Y_UNIT_TEST(TestUdfResultCheckTupleWithHoleFirst) { BuildArgsFunc argsFunc = [](TProgramBuilder& pgmBuilder) { return std::vector<TRuntimeNode>{pgmBuilder.NewDataLiteral<ui32>(0)}; }; UNIT_ASSERT_EXCEPTION(ProcessSimpleUdfFunc("UtUDF.Tuple", argsFunc), TUdfValidateException); } - Y_UNIT_TEST(TestUdfResultCheckTupleWithHoleMiddle) { + Y_UNIT_TEST(TestUdfResultCheckTupleWithHoleMiddle) { BuildArgsFunc argsFunc = [](TProgramBuilder& pgmBuilder) { return std::vector<TRuntimeNode>{pgmBuilder.NewDataLiteral<ui32>(std::tuple_size<decltype(TUPLE)>::value / 2)}; }; UNIT_ASSERT_EXCEPTION(ProcessSimpleUdfFunc("UtUDF.Tuple", argsFunc), TUdfValidateException); } - Y_UNIT_TEST(TestUdfResultCheckTupleWithHoleLast) { + Y_UNIT_TEST(TestUdfResultCheckTupleWithHoleLast) { BuildArgsFunc argsFunc = [](TProgramBuilder& pgmBuilder) { return std::vector<TRuntimeNode>{pgmBuilder.NewDataLiteral<ui32>(std::tuple_size<decltype(TUPLE)>::value - 1)}; }; UNIT_ASSERT_EXCEPTION(ProcessSimpleUdfFunc("UtUDF.Tuple", argsFunc), TUdfValidateException); } - Y_UNIT_TEST(TestUdfResultCheckDictDigitDigitFull) { + Y_UNIT_TEST(TestUdfResultCheckDictDigitDigitFull) { BuildArgsFunc argsFunc = [](TProgramBuilder& pgmBuilder) { return std::vector<TRuntimeNode>{pgmBuilder.NewDataLiteral(RAW_INDEX_NO_HOLE), pgmBuilder.NewDataLiteral(RAW_INDEX_NO_HOLE)}; @@ -909,7 +909,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLValidateTest) { ProcessSimpleUdfFunc("UtUDF.DictDigDig", argsFunc, validateFunc); } - Y_UNIT_TEST(TestUdfResultCheckDictDigitDigitKeyHole) { + Y_UNIT_TEST(TestUdfResultCheckDictDigitDigitKeyHole) { BuildArgsFunc argsFunc = [](TProgramBuilder& pgmBuilder) { return std::vector<TRuntimeNode>{pgmBuilder.NewDataLiteral<ui32>(0), pgmBuilder.NewDataLiteral(RAW_INDEX_NO_HOLE)}; @@ -927,7 +927,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLValidateTest) { ProcessSimpleUdfFunc("UtUDF.DictDigDig", argsFunc, validateFunc); } - Y_UNIT_TEST(TestUdfResultCheckDictDigitDigitValueHole) { + Y_UNIT_TEST(TestUdfResultCheckDictDigitDigitValueHole) { BuildArgsFunc argsFunc = [](TProgramBuilder& pgmBuilder) { return std::vector<TRuntimeNode>{pgmBuilder.NewDataLiteral(RAW_INDEX_NO_HOLE), pgmBuilder.NewDataLiteral<ui32>(DICT_DIGIT2DIGIT.size() - 1)}; @@ -944,7 +944,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLValidateTest) { }; ProcessSimpleUdfFunc("UtUDF.DictDigDig", argsFunc, validateFunc); } - Y_UNIT_TEST(TestUdfResultCheckDictDigitDigitHoleAsOptKeyHole) { + Y_UNIT_TEST(TestUdfResultCheckDictDigitDigitHoleAsOptKeyHole) { BuildArgsFunc argsFunc = [](TProgramBuilder& pgmBuilder) { return std::vector<TRuntimeNode>{pgmBuilder.NewDataLiteral(RAW_INDEX_NO_HOLE), pgmBuilder.NewDataLiteral<ui32>(0)}; @@ -962,7 +962,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLValidateTest) { ProcessSimpleUdfFunc("UtUDF.DictDigDig", argsFunc, validateFunc); } - Y_UNIT_TEST(TestUdfResultCheckDictDigitDigitHoleAsOptValueHole) { + Y_UNIT_TEST(TestUdfResultCheckDictDigitDigitHoleAsOptValueHole) { BuildArgsFunc argsFunc = [](TProgramBuilder& pgmBuilder) { return std::vector<TRuntimeNode>{pgmBuilder.NewDataLiteral<ui32>(DICT_DIGIT2DIGIT.size() - 1), pgmBuilder.NewDataLiteral(RAW_INDEX_NO_HOLE)}; @@ -980,35 +980,35 @@ Y_UNIT_TEST_SUITE(TMiniKQLValidateTest) { ProcessSimpleUdfFunc("UtUDF.DictDigDig", argsFunc, validateFunc); } - Y_UNIT_TEST(TestUdfResultCheckPersonStruct) { + Y_UNIT_TEST(TestUdfResultCheckPersonStruct) { BuildArgsFunc argsFunc = [](TProgramBuilder& pgmBuilder) { return std::vector<TRuntimeNode>{pgmBuilder.NewDataLiteral(RAW_INDEX_NO_HOLE)}; }; ProcessSimpleUdfFunc("UtUDF.PersonStruct", argsFunc); } - Y_UNIT_TEST(TestUdfResultCheckPersonStructWithHoleFirst) { + Y_UNIT_TEST(TestUdfResultCheckPersonStructWithHoleFirst) { BuildArgsFunc argsFunc = [](TProgramBuilder& pgmBuilder) { return std::vector<TRuntimeNode>{pgmBuilder.NewDataLiteral<ui32>(0)}; }; UNIT_ASSERT_EXCEPTION(ProcessSimpleUdfFunc("UtUDF.PersonStruct", argsFunc), TUdfValidateException); } - Y_UNIT_TEST(TestUdfResultCheckPersonStructWithHoleMiddle) { + Y_UNIT_TEST(TestUdfResultCheckPersonStructWithHoleMiddle) { BuildArgsFunc argsFunc = [](TProgramBuilder& pgmBuilder) { return std::vector<TRuntimeNode>{pgmBuilder.NewDataLiteral<ui32>(1)}; }; UNIT_ASSERT_EXCEPTION(ProcessSimpleUdfFunc("UtUDF.PersonStruct", argsFunc), TUdfValidateException); } - Y_UNIT_TEST(TestUdfResultCheckPersonStructWithHoleLast) { + Y_UNIT_TEST(TestUdfResultCheckPersonStructWithHoleLast) { BuildArgsFunc argsFunc = [](TProgramBuilder& pgmBuilder) { return std::vector<TRuntimeNode>{pgmBuilder.NewDataLiteral<ui32>(2)}; }; UNIT_ASSERT_EXCEPTION(ProcessSimpleUdfFunc("UtUDF.PersonStruct", argsFunc), TUdfValidateException); } - Y_UNIT_TEST(TestUdfResultCheckTupleOfPersonStruct) { + Y_UNIT_TEST(TestUdfResultCheckTupleOfPersonStruct) { BuildArgsFunc argsFunc = [](TProgramBuilder& pgmBuilder) { return std::vector<TRuntimeNode>{pgmBuilder.NewDataLiteral(RAW_INDEX_NO_HOLE)}; }; @@ -1024,7 +1024,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLValidateTest) { ProcessSimpleUdfFunc("UtUDF.TupleOfPersonStruct", argsFunc, {}, fullValidateFunc, NUdf::EValidateMode::Greedy); } - Y_UNIT_TEST(TestUdfResultCheckTupleOfPersonStructNoList) { + Y_UNIT_TEST(TestUdfResultCheckTupleOfPersonStructNoList) { BuildArgsFunc argsFunc = [](TProgramBuilder& pgmBuilder) { return std::vector<TRuntimeNode>{pgmBuilder.NewDataLiteral(RAW_INDEX_NO_HOLE)}; }; @@ -1075,7 +1075,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLValidateTest) { UNIT_ASSERT_EXCEPTION(dictIter.NextPair(key, payload), TUdfValidateException); } - Y_UNIT_TEST(TestUdfResultCheckListOfPersonStructToIndexDict) { + Y_UNIT_TEST(TestUdfResultCheckListOfPersonStructToIndexDict) { BuildArgsFunc argsFunc = [](TProgramBuilder& pgmBuilder) { return std::vector<TRuntimeNode>{pgmBuilder.NewDataLiteral(RAW_INDEX_NO_HOLE)}; }; @@ -1086,7 +1086,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLValidateTest) { ProcessSimpleUdfFunc("UtUDF.ListOfPersonStructToIndexDict", argsFunc, validateFunc); } - Y_UNIT_TEST(TestUdfResultCheckListOfPersonStruct) { + Y_UNIT_TEST(TestUdfResultCheckListOfPersonStruct) { BuildArgsFunc argsFunc = [](TProgramBuilder& pgmBuilder) { return std::vector<TRuntimeNode>{pgmBuilder.NewDataLiteral(RAW_INDEX_NO_HOLE)}; }; @@ -1099,7 +1099,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLValidateTest) { ProcessSimpleUdfFunc("UtUDF.ListOfPersonStruct", argsFunc, {}, fullValidateFunc); } - Y_UNIT_TEST(TestUdfResultCheckListOfPersonStructWithBrokenIndexToDict) { + Y_UNIT_TEST(TestUdfResultCheckListOfPersonStructWithBrokenIndexToDict) { FullValidateValueFunc fullValidateFunc = [](const NUdf::TUnboxedValuePod& value, const NUdf::IValueBuilder* valueBuilder, const TType* type) { Y_UNUSED(type); @@ -1113,7 +1113,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLValidateTest) { ProcessSimpleUdfFunc("UtUDF.ListOfPersonStructWithBrokenIndexToDict", {}, {}, fullValidateFunc); } - Y_UNIT_TEST(TestUdfResultCheckDictOfPerson) { + Y_UNIT_TEST(TestUdfResultCheckDictOfPerson) { ValidateValueFunc validateFunc = [](const NUdf::TUnboxedValuePod& value, const NUdf::IValueBuilder*) { auto dictIter = value.GetDictIterator(); NUdf::TUnboxedValue key, payload; @@ -1130,7 +1130,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLValidateTest) { ProcessSimpleUdfFunc("UtUDF.DictOfPerson", {}, validateFunc); } - Y_UNIT_TEST(TestUdfResultCheckDictOfPersonBroken) { + Y_UNIT_TEST(TestUdfResultCheckDictOfPersonBroken) { ValidateValueFunc validateFunc = [](const NUdf::TUnboxedValuePod& value, const NUdf::IValueBuilder*) { auto dictIter = value.GetDictIterator(); NUdf::TUnboxedValue key, payload; diff --git a/ydb/library/yql/minikql/computation/presort_ut.cpp b/ydb/library/yql/minikql/computation/presort_ut.cpp index 4adf957ca1b..f5c325183e3 100644 --- a/ydb/library/yql/minikql/computation/presort_ut.cpp +++ b/ydb/library/yql/minikql/computation/presort_ut.cpp @@ -184,9 +184,9 @@ struct TPresortTest { } -Y_UNIT_TEST_SUITE(TPresortCodecTest) { +Y_UNIT_TEST_SUITE(TPresortCodecTest) { -Y_UNIT_TEST(SimpleTypes) { +Y_UNIT_TEST(SimpleTypes) { TPresortTest test; TSimpleTypes values = {false, 1u, 2u, 3u, 4u, 5, 6, 7, 8, 9.f, 10.0}; @@ -209,7 +209,7 @@ Y_UNIT_TEST(SimpleTypes) { } -Y_UNIT_TEST(Bool) { +Y_UNIT_TEST(Bool) { const TVector<std::tuple<bool, TString, TString>> values = { {false, "00", "FF"}, {true, "01", "FE"} @@ -217,7 +217,7 @@ Y_UNIT_TEST(Bool) { TPresortTest().ValidateEncoding(values); } -Y_UNIT_TEST(Int8) { +Y_UNIT_TEST(Int8) { const TVector<std::tuple<i8, TString, TString>> values = { {-0x80, "00", "FF"}, {-1, "7F", "80"}, @@ -228,7 +228,7 @@ Y_UNIT_TEST(Int8) { TPresortTest().ValidateEncoding(values); } -Y_UNIT_TEST(Uint8) { +Y_UNIT_TEST(Uint8) { const TVector<std::tuple<ui8, TString, TString>> values = { {0u, "00", "FF"}, {0x80u, "80", "7F"}, @@ -237,7 +237,7 @@ Y_UNIT_TEST(Uint8) { TPresortTest().ValidateEncoding(values); } -Y_UNIT_TEST(Int16) { +Y_UNIT_TEST(Int16) { const TVector<std::tuple<i16, TString, TString>> values = { {-0x8000, "0000", "FFFF"}, {-1, "7FFF", "8000"}, @@ -248,7 +248,7 @@ Y_UNIT_TEST(Int16) { TPresortTest().ValidateEncoding(values); } -Y_UNIT_TEST(Uint16) { +Y_UNIT_TEST(Uint16) { const TVector<std::tuple<ui16, TString, TString>> values = { {0, "0000", "FFFF"}, {0x8000u, "8000", "7FFF"}, @@ -257,7 +257,7 @@ Y_UNIT_TEST(Uint16) { TPresortTest().ValidateEncoding(values); } -Y_UNIT_TEST(Int32) { +Y_UNIT_TEST(Int32) { const TVector<std::tuple<i32, TString, TString>> values = { {-0x80000000, "00000000", "FFFFFFFF"}, {-1, "7FFFFFFF", "80000000"}, @@ -268,7 +268,7 @@ Y_UNIT_TEST(Int32) { TPresortTest().ValidateEncoding(values); } -Y_UNIT_TEST(Uint32) { +Y_UNIT_TEST(Uint32) { const TVector<std::tuple<ui32, TString, TString>> values = { {0u, "00000000", "FFFFFFFF"}, {0x80000000u, "80000000", "7FFFFFFF"}, @@ -277,7 +277,7 @@ Y_UNIT_TEST(Uint32) { TPresortTest().ValidateEncoding(values); } -Y_UNIT_TEST(Int64) { +Y_UNIT_TEST(Int64) { const TVector<std::tuple<i64, TString, TString>> values = { {-0x8000000000000000, "0000000000000000", "FFFFFFFFFFFFFFFF"}, {-1, "7FFFFFFFFFFFFFFF", "8000000000000000"}, @@ -288,7 +288,7 @@ Y_UNIT_TEST(Int64) { TPresortTest().ValidateEncoding(values); } -Y_UNIT_TEST(Uint64) { +Y_UNIT_TEST(Uint64) { const TVector<std::tuple<ui64, TString, TString>> values = { {0u, "0000000000000000", "FFFFFFFFFFFFFFFF"}, {0x8000000000000000u, "8000000000000000", "7FFFFFFFFFFFFFFF"}, @@ -297,7 +297,7 @@ Y_UNIT_TEST(Uint64) { TPresortTest().ValidateEncoding(values); } -Y_UNIT_TEST(Float) { +Y_UNIT_TEST(Float) { using TLimits = std::numeric_limits<float>; const TVector<std::tuple<float, TString, TString>> values = { @@ -316,7 +316,7 @@ Y_UNIT_TEST(Float) { TPresortTest().ValidateEncoding(values); } -Y_UNIT_TEST(Double) { +Y_UNIT_TEST(Double) { using TLimits = std::numeric_limits<double>; const TVector<std::tuple<double, TString, TString>> values = { @@ -335,7 +335,7 @@ Y_UNIT_TEST(Double) { TPresortTest().ValidateEncoding(values); } -Y_UNIT_TEST(String) { +Y_UNIT_TEST(String) { const TVector<std::tuple<TStringBuf, TString, TString>> values = { {TStringBuf(""), "00", "FF"}, {"\x00"sv, "1F00000000000000000000000000000001", diff --git a/ydb/library/yql/minikql/invoke_builtins/mkql_builtins.cpp b/ydb/library/yql/minikql/invoke_builtins/mkql_builtins.cpp index ab991842f1a..d84f22cf7ac 100644 --- a/ydb/library/yql/minikql/invoke_builtins/mkql_builtins.cpp +++ b/ydb/library/yql/minikql/invoke_builtins/mkql_builtins.cpp @@ -67,7 +67,7 @@ void PrintType(NUdf::TDataTypeId schemeType, bool isOptional, IOutputStream& out void PrintFunctionSignature( const std::string_view& funcName, const TFunctionDescriptor& desc, - IOutputStream& out) + IOutputStream& out) { const auto* param = desc.ResultAndArgs; out << '\t'; @@ -262,7 +262,7 @@ ui64 TBuiltinFunctionRegistry::GetMetadataEtag() const return *MetadataEtag; } -void TBuiltinFunctionRegistry::PrintInfoTo(IOutputStream& out) const +void TBuiltinFunctionRegistry::PrintInfoTo(IOutputStream& out) const { for (const auto& f: Functions) { out << f.first << ": [\n"; diff --git a/ydb/library/yql/minikql/invoke_builtins/mkql_builtins_ut.cpp b/ydb/library/yql/minikql/invoke_builtins/mkql_builtins_ut.cpp index 9420223b74e..c929489256c 100644 --- a/ydb/library/yql/minikql/invoke_builtins/mkql_builtins_ut.cpp +++ b/ydb/library/yql/minikql/invoke_builtins/mkql_builtins_ut.cpp @@ -23,8 +23,8 @@ static NUdf::TUnboxedValuePod AddUi32(const NUdf::TUnboxedValuePod* args) return NUdf::TUnboxedValuePod(first + second); } -Y_UNIT_TEST_SUITE(TFunctionRegistryTest) { - Y_UNIT_TEST(TestRegistration) { +Y_UNIT_TEST_SUITE(TFunctionRegistryTest) { + Y_UNIT_TEST(TestRegistration) { const auto functionRegistry = CreateBuiltinRegistry(); functionRegistry->Register("MyAdd", TFunctionDescriptor(AddUi32Metadata, &AddUi32)); diff --git a/ydb/library/yql/minikql/mkql_alloc.cpp b/ydb/library/yql/minikql/mkql_alloc.cpp index 9b77147a26c..1ff7cee07a5 100644 --- a/ydb/library/yql/minikql/mkql_alloc.cpp +++ b/ydb/library/yql/minikql/mkql_alloc.cpp @@ -75,7 +75,7 @@ size_t TAllocState::GetDeallocatedInPages() const { void* MKQLAllocSlow(size_t sz, TAllocState* state) { auto roundedSize = AlignUp(sz + sizeof(TAllocPageHeader), MKQL_ALIGNMENT); - auto capacity = Max(ui64(TAlignedPagePool::POOL_PAGE_SIZE), roundedSize); + auto capacity = Max(ui64(TAlignedPagePool::POOL_PAGE_SIZE), roundedSize); auto currPage = (TAllocPageHeader*)state->GetBlock(capacity); currPage->Deallocated = 0; currPage->Capacity = capacity; @@ -106,7 +106,7 @@ void MKQLFreeSlow(TAllocPageHeader* header) noexcept { void* TPagedArena::AllocSlow(size_t sz) { auto prevLink = CurrentPage_; auto roundedSize = AlignUp(sz + sizeof(TAllocPageHeader), MKQL_ALIGNMENT); - auto capacity = Max(ui64(TAlignedPagePool::POOL_PAGE_SIZE), roundedSize); + auto capacity = Max(ui64(TAlignedPagePool::POOL_PAGE_SIZE), roundedSize); CurrentPage_ = (TAllocPageHeader*)PagePool_->GetBlock(capacity); CurrentPage_->Capacity = capacity; void* ret = (char*)CurrentPage_ + sizeof(TAllocPageHeader); diff --git a/ydb/library/yql/minikql/mkql_alloc.h b/ydb/library/yql/minikql/mkql_alloc.h index 5e864cdc4c8..b72f4af7905 100644 --- a/ydb/library/yql/minikql/mkql_alloc.h +++ b/ydb/library/yql/minikql/mkql_alloc.h @@ -391,8 +391,8 @@ template <typename T> class TPagedList { public: - static_assert(sizeof(T) <= TAlignedPagePool::POOL_PAGE_SIZE, "Too big object"); - static constexpr size_t OBJECTS_PER_PAGE = TAlignedPagePool::POOL_PAGE_SIZE / sizeof(T); + static_assert(sizeof(T) <= TAlignedPagePool::POOL_PAGE_SIZE, "Too big object"); + static constexpr size_t OBJECTS_PER_PAGE = TAlignedPagePool::POOL_PAGE_SIZE / sizeof(T); class TIterator; class TConstIterator; diff --git a/ydb/library/yql/minikql/mkql_alloc_ut.cpp b/ydb/library/yql/minikql/mkql_alloc_ut.cpp index 72d8f696afc..d32c380ab21 100644 --- a/ydb/library/yql/minikql/mkql_alloc_ut.cpp +++ b/ydb/library/yql/minikql/mkql_alloc_ut.cpp @@ -5,8 +5,8 @@ namespace NKikimr { namespace NMiniKQL { -Y_UNIT_TEST_SUITE(TMiniKQLAllocTest) { - Y_UNIT_TEST(TestPagedArena) { +Y_UNIT_TEST_SUITE(TMiniKQLAllocTest) { + Y_UNIT_TEST(TestPagedArena) { TAlignedPagePool pagePool; { diff --git a/ydb/library/yql/minikql/mkql_function_registry.cpp b/ydb/library/yql/minikql/mkql_function_registry.cpp index d3545ad138d..f09ba408390 100644 --- a/ydb/library/yql/minikql/mkql_function_registry.cpp +++ b/ydb/library/yql/minikql/mkql_function_registry.cpp @@ -63,7 +63,7 @@ class TMutableFunctionRegistry: public IMutableFunctionRegistry const NUdf::TStringRef& name, NUdf::TUniquePtr<NUdf::IUdfModule> module) override { - Y_VERIFY_DEBUG(module, "Module is empty"); + Y_VERIFY_DEBUG(module, "Module is empty"); if (!HasError()) { TUdfModule m; @@ -78,7 +78,7 @@ class TMutableFunctionRegistry: public IMutableFunctionRegistry auto i = ModulesMap.insert({ newName, std::move(m) }); if (!i.second) { TUdfModule* oldModule = ModulesMap.FindPtr(newName); - Y_VERIFY_DEBUG(oldModule != nullptr); + Y_VERIFY_DEBUG(oldModule != nullptr); Error = (TStringBuilder() << "UDF module duplication: name " << TStringBuf(name) << ", already loaded from " << oldModule->LibraryPath @@ -183,7 +183,7 @@ public: TUdfModuleLoader loader( UdfModules_, libraryPath, remmapings, lib->AbiVersion); registerFunc(loader, flags); - Y_ENSURE(!loader.HasError(), loader.GetError()); + Y_ENSURE(!loader.HasError(), loader.GetError()); } void AddModule( @@ -203,7 +203,7 @@ public: remappings, NUdf::CurrentAbiVersion()); loader.AddModule(moduleName, std::move(module)); - Y_ENSURE(!loader.HasError(), loader.GetError()); + Y_ENSURE(!loader.HasError(), loader.GetError()); } void SetSystemModulePaths(const TUdfModulePathsMap& paths) override { @@ -338,7 +338,7 @@ public: return SupportsSizedAllocators_; } - void PrintInfoTo(IOutputStream& out) const override { + void PrintInfoTo(IOutputStream& out) const override { Builtins_->PrintInfoTo(out); } @@ -432,7 +432,7 @@ public: return true; } - void PrintInfoTo(IOutputStream& out) const override { + void PrintInfoTo(IOutputStream& out) const override { Builtins_->PrintInfoTo(out); } diff --git a/ydb/library/yql/minikql/mkql_function_registry.h b/ydb/library/yql/minikql/mkql_function_registry.h index f18152cb24e..860b37f332b 100644 --- a/ydb/library/yql/minikql/mkql_function_registry.h +++ b/ydb/library/yql/minikql/mkql_function_registry.h @@ -27,7 +27,7 @@ ////////////////////////////////////////////////////////////////////////////// // forward declarations ////////////////////////////////////////////////////////////////////////////// -class IOutputStream; +class IOutputStream; namespace NKikimr { namespace NMiniKQL { @@ -77,7 +77,7 @@ public: virtual THashSet<TString> GetAllModuleNames() const = 0; - virtual void PrintInfoTo(IOutputStream& out) const = 0; + virtual void PrintInfoTo(IOutputStream& out) const = 0; virtual void CleanupModulesOnTerminate() const = 0; diff --git a/ydb/library/yql/minikql/mkql_mem_info.h b/ydb/library/yql/minikql/mkql_mem_info.h index 8e880d1db30..3912d52e8f8 100644 --- a/ydb/library/yql/minikql/mkql_mem_info.h +++ b/ydb/library/yql/minikql/mkql_mem_info.h @@ -143,7 +143,7 @@ public: inline ui64 GetFreed() const { return Freed_; } inline ui64 GetPeak() const { return Peak_; } - inline void PrintTo(IOutputStream& out) const { + inline void PrintTo(IOutputStream& out) const { out << Title_ << TStringBuf(": usage=") << GetUsage() << TStringBuf(" (allocated=") << GetAllocated() << TStringBuf(", freed=") << GetFreed() @@ -224,7 +224,7 @@ inline void Return(TMemoryUsageInfo* memInfo, const void* mem) template <> inline void Out<NKikimr::NMiniKQL::TMemoryUsageInfo>( - IOutputStream& out, + IOutputStream& out, const NKikimr::NMiniKQL::TMemoryUsageInfo& memInfo) { memInfo.PrintTo(out); diff --git a/ydb/library/yql/minikql/mkql_node.cpp b/ydb/library/yql/minikql/mkql_node.cpp index 4c6f3e45ad4..2d91a975988 100644 --- a/ydb/library/yql/minikql/mkql_node.cpp +++ b/ydb/library/yql/minikql/mkql_node.cpp @@ -88,7 +88,7 @@ void TNode::Accept(INodeVisitor& visitor) { #undef APPLY default: - Y_FAIL(); + Y_FAIL(); } } @@ -112,7 +112,7 @@ bool TNode::Equals(const TNode& nodeToCompare) const { #undef APPLY default: - Y_FAIL(); + Y_FAIL(); } } @@ -130,7 +130,7 @@ void TNode::UpdateLinks(const THashMap<TNode*, TNode*>& links) { #undef APPLY default: - Y_FAIL(); + Y_FAIL(); } } @@ -148,7 +148,7 @@ TNode* TNode::CloneOnCallableWrite(const TTypeEnvironment& env) const { #undef APPLY default: - Y_FAIL(); + Y_FAIL(); } } @@ -166,7 +166,7 @@ void TNode::Freeze(const TTypeEnvironment& env) { #undef APPLY default: - Y_FAIL(); + Y_FAIL(); } } @@ -222,7 +222,7 @@ void TType::Accept(INodeVisitor& visitor) { #undef APPLY default: - Y_FAIL(); + Y_FAIL(); } } @@ -237,7 +237,7 @@ void TType::UpdateLinks(const THashMap<TNode*, TNode*>& links) { #undef APPLY default: - Y_FAIL(); + Y_FAIL(); } } @@ -252,7 +252,7 @@ TNode* TType::CloneOnCallableWrite(const TTypeEnvironment& env) const { #undef APPLY default: - Y_FAIL(); + Y_FAIL(); } } @@ -267,7 +267,7 @@ void TType::Freeze(const TTypeEnvironment& env) { #undef APPLY default: - Y_FAIL(); + Y_FAIL(); } } @@ -285,7 +285,7 @@ bool TType::IsSameType(const TType& typeToCompare) const { #undef APPLY default: - Y_FAIL(); + Y_FAIL(); } } @@ -315,7 +315,7 @@ bool TType::IsConvertableTo(const TType& typeToCompare, bool ignoreTagged) const #undef APPLY default: - Y_FAIL(); + Y_FAIL(); } } @@ -324,7 +324,7 @@ TTypeType* TTypeType::Create(const TTypeEnvironment& env) { } bool TTypeType::IsSameType(const TTypeType& typeToCompare) const { - Y_UNUSED(typeToCompare); + Y_UNUSED(typeToCompare); return true; } @@ -334,16 +334,16 @@ bool TTypeType::IsConvertableTo(const TTypeType& typeToCompare, bool ignoreTagge } void TTypeType::DoUpdateLinks(const THashMap<TNode*, TNode*>& links) { - Y_UNUSED(links); + Y_UNUSED(links); } TNode* TTypeType::DoCloneOnCallableWrite(const TTypeEnvironment& env) const { - Y_UNUSED(env); + Y_UNUSED(env); return const_cast<TTypeType*>(this); } void TTypeType::DoFreeze(const TTypeEnvironment& env) { - Y_UNUSED(env); + Y_UNUSED(env); } TDataType::TDataType(NUdf::TDataTypeId schemeType, const TTypeEnvironment& env) @@ -373,16 +373,16 @@ bool TDataType::IsConvertableTo(const TDataType& typeToCompare, bool ignoreTagge } void TDataType::DoUpdateLinks(const THashMap<TNode*, TNode*>& links) { - Y_UNUSED(links); + Y_UNUSED(links); } TNode* TDataType::DoCloneOnCallableWrite(const TTypeEnvironment& env) const { - Y_UNUSED(env); + Y_UNUSED(env); return const_cast<TDataType*>(this); } void TDataType::DoFreeze(const TTypeEnvironment& env) { - Y_UNUSED(env); + Y_UNUSED(env); } TDataDecimalType::TDataDecimalType(ui8 precision, ui8 scale, const TTypeEnvironment& env) @@ -421,18 +421,18 @@ void TDataLiteral::DoUpdateLinks(const THashMap<TNode*, TNode*>& links) { auto typeIt = links.find(Type); if (typeIt != links.end()) { TNode* newNode = typeIt->second; - Y_VERIFY_DEBUG(Type->Equals(*newNode)); + Y_VERIFY_DEBUG(Type->Equals(*newNode)); Type = static_cast<TType*>(newNode); } } TNode* TDataLiteral::DoCloneOnCallableWrite(const TTypeEnvironment& env) const { - Y_UNUSED(env); + Y_UNUSED(env); return const_cast<TDataLiteral*>(this); } void TDataLiteral::DoFreeze(const TTypeEnvironment& env) { - Y_UNUSED(env); + Y_UNUSED(env); } bool TDataLiteral::Equals(const TDataLiteral& nodeToCompare) const { @@ -547,7 +547,7 @@ void TStructType::DoUpdateLinks(const THashMap<TNode*, TNode*>& links) { auto memberIt = links.find(member.second); if (memberIt != links.end()) { TNode* newNode = memberIt->second; - Y_VERIFY_DEBUG(member.second->Equals(*newNode)); + Y_VERIFY_DEBUG(member.second->Equals(*newNode)); member.second = static_cast<TType*>(newNode); } } @@ -583,7 +583,7 @@ TNode* TStructType::DoCloneOnCallableWrite(const TTypeEnvironment& env) const { } void TStructType::DoFreeze(const TTypeEnvironment& env) { - Y_UNUSED(env); + Y_UNUSED(env); } ui32 TStructType::GetMemberIndex(const TStringBuf& name) const { @@ -652,7 +652,7 @@ void TStructLiteral::DoUpdateLinks(const THashMap<TNode*, TNode*>& links) { auto typeIt = links.find(Type); if (typeIt != links.end()) { TNode* newNode = typeIt->second; - Y_VERIFY_DEBUG(Type->Equals(*newNode)); + Y_VERIFY_DEBUG(Type->Equals(*newNode)); Type = static_cast<TType*>(newNode); } @@ -661,7 +661,7 @@ void TStructLiteral::DoUpdateLinks(const THashMap<TNode*, TNode*>& links) { auto valueIt = links.find(value.GetNode()); if (valueIt != links.end()) { TNode* newNode = valueIt->second; - Y_VERIFY_DEBUG(value.GetNode()->Equals(*newNode)); + Y_VERIFY_DEBUG(value.GetNode()->Equals(*newNode)); value = TRuntimeNode(newNode, value.IsImmediate()); } } @@ -701,7 +701,7 @@ TNode* TStructLiteral::DoCloneOnCallableWrite(const TTypeEnvironment& env) const } void TStructLiteral::DoFreeze(const TTypeEnvironment& env) { - Y_UNUSED(env); + Y_UNUSED(env); for (ui32 i = 0; i < GetValuesCount(); ++i) { Values[i].Freeze(); } @@ -724,7 +724,7 @@ TListType::TListType(TType* itemType, const TTypeEnvironment& env, bool validate , Data(itemType) , IndexDictKey(env.GetUi64()) { - Y_UNUSED(validate); + Y_UNUSED(validate); } TListType* TListType::Create(TType* itemType, const TTypeEnvironment& env) { @@ -743,7 +743,7 @@ void TListType::DoUpdateLinks(const THashMap<TNode*, TNode*>& links) { auto itemTypeIt = links.find(GetItemType()); if (itemTypeIt != links.end()) { TNode* newNode = itemTypeIt->second; - Y_VERIFY_DEBUG(GetItemType()->Equals(*newNode)); + Y_VERIFY_DEBUG(GetItemType()->Equals(*newNode)); Data = static_cast<TType*>(newNode); } } @@ -757,7 +757,7 @@ TNode* TListType::DoCloneOnCallableWrite(const TTypeEnvironment& env) const { } void TListType::DoFreeze(const TTypeEnvironment& env) { - Y_UNUSED(env); + Y_UNUSED(env); } TListLiteral::TListLiteral(TRuntimeNode* items, ui32 count, TListType* type, const TTypeEnvironment& env, bool validate) @@ -798,7 +798,7 @@ void TListLiteral::DoUpdateLinks(const THashMap<TNode*, TNode*>& links) { auto typeIt = links.find(Type); if (typeIt != links.end()) { TNode* newNode = typeIt->second; - Y_VERIFY_DEBUG(Type->Equals(*newNode)); + Y_VERIFY_DEBUG(Type->Equals(*newNode)); Type = static_cast<TType*>(newNode); } @@ -807,7 +807,7 @@ void TListLiteral::DoUpdateLinks(const THashMap<TNode*, TNode*>& links) { auto itemIt = links.find(item.GetNode()); if (itemIt != links.end()) { TNode* newNode = itemIt->second; - Y_VERIFY_DEBUG(item.GetNode()->Equals(*newNode)); + Y_VERIFY_DEBUG(item.GetNode()->Equals(*newNode)); item = TRuntimeNode(newNode, item.IsImmediate()); } } @@ -975,7 +975,7 @@ TOptionalType::TOptionalType(TType* itemType, const TTypeEnvironment& env, bool : TType(EKind::Optional, env.GetTypeOfType()) , Data(itemType) { - Y_UNUSED(validate); + Y_UNUSED(validate); } TOptionalType* TOptionalType::Create(TType* itemType, const TTypeEnvironment& env) { @@ -994,7 +994,7 @@ void TOptionalType::DoUpdateLinks(const THashMap<TNode*, TNode*>& links) { auto itemTypeIt = links.find(GetItemType()); if (itemTypeIt != links.end()) { TNode* newNode = itemTypeIt->second; - Y_VERIFY_DEBUG(GetItemType()->Equals(*newNode)); + Y_VERIFY_DEBUG(GetItemType()->Equals(*newNode)); Data = static_cast<TType*>(newNode); } } @@ -1008,7 +1008,7 @@ TNode* TOptionalType::DoCloneOnCallableWrite(const TTypeEnvironment& env) const } void TOptionalType::DoFreeze(const TTypeEnvironment& env) { - Y_UNUSED(env); + Y_UNUSED(env); } TTaggedType::TTaggedType(TType* baseType, TInternName tag, const TTypeEnvironment& env) @@ -1054,7 +1054,7 @@ void TTaggedType::DoFreeze(const TTypeEnvironment& env) { TOptionalLiteral::TOptionalLiteral(TOptionalType* type, bool validate) : TNode(type) { - Y_UNUSED(validate); + Y_UNUSED(validate); } TOptionalLiteral::TOptionalLiteral(TRuntimeNode item, TOptionalType* type, bool validate) @@ -1066,7 +1066,7 @@ TOptionalLiteral::TOptionalLiteral(TRuntimeNode item, TOptionalType* type, bool return; } - Y_VERIFY_DEBUG(Item.GetNode()); + Y_VERIFY_DEBUG(Item.GetNode()); MKQL_ENSURE(Item.GetStaticType()->IsSameType(*type->GetItemType()), "Wrong type of item"); @@ -1085,7 +1085,7 @@ void TOptionalLiteral::DoUpdateLinks(const THashMap<TNode*, TNode*>& links) { auto typeIt = links.find(Type); if (typeIt != links.end()) { TNode* newNode = typeIt->second; - Y_VERIFY_DEBUG(Type->Equals(*newNode)); + Y_VERIFY_DEBUG(Type->Equals(*newNode)); Type = static_cast<TType*>(newNode); } @@ -1093,7 +1093,7 @@ void TOptionalLiteral::DoUpdateLinks(const THashMap<TNode*, TNode*>& links) { auto itemIt = links.find(Item.GetNode()); if (itemIt != links.end()) { TNode* newNode = itemIt->second; - Y_VERIFY_DEBUG(Item.GetNode()->Equals(*newNode)); + Y_VERIFY_DEBUG(Item.GetNode()->Equals(*newNode)); Item = TRuntimeNode(newNode, Item.IsImmediate()); } } @@ -1117,7 +1117,7 @@ TNode* TOptionalLiteral::DoCloneOnCallableWrite(const TTypeEnvironment& env) con } void TOptionalLiteral::DoFreeze(const TTypeEnvironment& env) { - Y_UNUSED(env); + Y_UNUSED(env); if (Item.GetNode()) { Item.Freeze(); } @@ -1148,14 +1148,14 @@ void TDictType::DoUpdateLinks(const THashMap<TNode*, TNode*>& links) { auto keyTypeIt = links.find(KeyType); if (keyTypeIt != links.end()) { TNode* newNode = keyTypeIt->second; - Y_VERIFY_DEBUG(KeyType->Equals(*newNode)); + Y_VERIFY_DEBUG(KeyType->Equals(*newNode)); KeyType = static_cast<TType*>(newNode); } auto payloadTypeIt = links.find(PayloadType); if (payloadTypeIt != links.end()) { TNode* newNode = payloadTypeIt->second; - Y_VERIFY_DEBUG(PayloadType->Equals(*newNode)); + Y_VERIFY_DEBUG(PayloadType->Equals(*newNode)); PayloadType = static_cast<TType*>(newNode); } } @@ -1173,7 +1173,7 @@ TNode* TDictType::DoCloneOnCallableWrite(const TTypeEnvironment& env) const { } void TDictType::DoFreeze(const TTypeEnvironment& env) { - Y_UNUSED(env); + Y_UNUSED(env); } TDictType::TDictType(TType* keyType, TType* payloadType, const TTypeEnvironment& env, bool validate) @@ -1234,7 +1234,7 @@ void TDictLiteral::DoUpdateLinks(const THashMap<TNode*, TNode*>& links) { auto typeIt = links.find(Type); if (typeIt != links.end()) { TNode* newNode = typeIt->second; - Y_VERIFY_DEBUG(Type->Equals(*newNode)); + Y_VERIFY_DEBUG(Type->Equals(*newNode)); Type = static_cast<TType*>(newNode); } @@ -1243,14 +1243,14 @@ void TDictLiteral::DoUpdateLinks(const THashMap<TNode*, TNode*>& links) { auto itemKeyIt = links.find(item.first.GetNode()); if (itemKeyIt != links.end()) { TNode* newNode = itemKeyIt->second; - Y_VERIFY_DEBUG(item.first.GetNode()->Equals(*newNode)); + Y_VERIFY_DEBUG(item.first.GetNode()->Equals(*newNode)); item.first = TRuntimeNode(newNode, item.first.IsImmediate()); } auto itemPayloadIt = links.find(item.second.GetNode()); if (itemPayloadIt != links.end()) { TNode* newNode = itemPayloadIt->second; - Y_VERIFY_DEBUG(item.second.GetNode()->Equals(*newNode)); + Y_VERIFY_DEBUG(item.second.GetNode()->Equals(*newNode)); item.second = TRuntimeNode(newNode, item.second.IsImmediate()); } } @@ -1300,7 +1300,7 @@ TNode* TDictLiteral::DoCloneOnCallableWrite(const TTypeEnvironment& env) const { } void TDictLiteral::DoFreeze(const TTypeEnvironment& env) { - Y_UNUSED(env); + Y_UNUSED(env); for (ui32 i = 0; i < ItemsCount; ++i) { Items[i].first.Freeze(); Items[i].second.Freeze(); @@ -1434,7 +1434,7 @@ void TCallableType::DoUpdateLinks(const THashMap<TNode*, TNode*>& links) { auto returnTypeIt = links.find(ReturnType); if (returnTypeIt != links.end()) { TNode* newNode = returnTypeIt->second; - Y_VERIFY_DEBUG(ReturnType->Equals(*newNode)); + Y_VERIFY_DEBUG(ReturnType->Equals(*newNode)); ReturnType = static_cast<TType*>(newNode); } @@ -1443,7 +1443,7 @@ void TCallableType::DoUpdateLinks(const THashMap<TNode*, TNode*>& links) { auto argIt = links.find(arg); if (argIt != links.end()) { TNode* newNode = argIt->second; - Y_VERIFY_DEBUG(arg->Equals(*newNode)); + Y_VERIFY_DEBUG(arg->Equals(*newNode)); arg = static_cast<TType*>(newNode); } } @@ -1452,7 +1452,7 @@ void TCallableType::DoUpdateLinks(const THashMap<TNode*, TNode*>& links) { auto payloadIt = links.find(Payload); if (payloadIt != links.end()) { TNode* newNode = payloadIt->second; - Y_VERIFY_DEBUG(Payload->Equals(*newNode)); + Y_VERIFY_DEBUG(Payload->Equals(*newNode)); Payload = newNode; } } @@ -1494,7 +1494,7 @@ TNode* TCallableType::DoCloneOnCallableWrite(const TTypeEnvironment& env) const } void TCallableType::DoFreeze(const TTypeEnvironment& env) { - Y_UNUSED(env); + Y_UNUSED(env); } TCallable::TCallable(ui32 inputsCount, TRuntimeNode* inputs, TCallableType* type, bool validate) @@ -1560,7 +1560,7 @@ void TCallable::DoUpdateLinks(const THashMap<TNode*, TNode*>& links) { auto typeIt = links.find(Type); if (typeIt != links.end()) { TNode* newNode = typeIt->second; - Y_VERIFY_DEBUG(Type->Equals(*newNode)); + Y_VERIFY_DEBUG(Type->Equals(*newNode)); Type = static_cast<TType*>(newNode); } @@ -1569,7 +1569,7 @@ void TCallable::DoUpdateLinks(const THashMap<TNode*, TNode*>& links) { auto inputIt = links.find(input.GetNode()); if (inputIt != links.end()) { TNode* newNode = inputIt->second; - Y_VERIFY_DEBUG(input.GetNode()->Equals(*newNode)); + Y_VERIFY_DEBUG(input.GetNode()->Equals(*newNode)); input = TRuntimeNode(newNode, input.IsImmediate()); } } @@ -1578,7 +1578,7 @@ void TCallable::DoUpdateLinks(const THashMap<TNode*, TNode*>& links) { auto resultIt = links.find(Result.GetNode()); if (resultIt != links.end()) { TNode* newNode = resultIt->second; - Y_VERIFY_DEBUG(Result.GetNode()->Equals(*newNode)); + Y_VERIFY_DEBUG(Result.GetNode()->Equals(*newNode)); Result = TRuntimeNode(newNode, Result.IsImmediate()); } } @@ -1631,7 +1631,7 @@ TNode* TCallable::DoCloneOnCallableWrite(const TTypeEnvironment& env) const { } void TCallable::DoFreeze(const TTypeEnvironment& env) { - Y_UNUSED(env); + Y_UNUSED(env); for (ui32 i = 0; i < InputsCount; ++i) { Inputs[i].Freeze(); } @@ -1715,7 +1715,7 @@ void TRuntimeNode::Freeze() { } bool TAnyType::IsSameType(const TAnyType& typeToCompare) const { - Y_UNUSED(typeToCompare); + Y_UNUSED(typeToCompare); return true; } @@ -1725,16 +1725,16 @@ bool TAnyType::IsConvertableTo(const TAnyType& typeToCompare, bool ignoreTagged) } void TAnyType::DoUpdateLinks(const THashMap<TNode*, TNode*>& links) { - Y_UNUSED(links); + Y_UNUSED(links); } TNode* TAnyType::DoCloneOnCallableWrite(const TTypeEnvironment& env) const { - Y_UNUSED(env); + Y_UNUSED(env); return const_cast<TAnyType*>(this); } void TAnyType::DoFreeze(const TTypeEnvironment& env) { - Y_UNUSED(env); + Y_UNUSED(env); } TAnyType* TAnyType::Create(TTypeType* type, const TTypeEnvironment& env) { @@ -1851,7 +1851,7 @@ void TTupleType::DoUpdateLinks(const THashMap<TNode*, TNode*>& links) { auto elementIt = links.find(element); if (elementIt != links.end()) { TNode* newNode = elementIt->second; - Y_VERIFY_DEBUG(element->Equals(*newNode)); + Y_VERIFY_DEBUG(element->Equals(*newNode)); element = static_cast<TType*>(newNode); } } @@ -1885,7 +1885,7 @@ TNode* TTupleType::DoCloneOnCallableWrite(const TTypeEnvironment& env) const { } void TTupleType::DoFreeze(const TTypeEnvironment& env) { - Y_UNUSED(env); + Y_UNUSED(env); } TTupleLiteral::TTupleLiteral(TRuntimeNode* values, TTupleType* type, bool validate) @@ -1929,7 +1929,7 @@ void TTupleLiteral::DoUpdateLinks(const THashMap<TNode*, TNode*>& links) { auto typeIt = links.find(Type); if (typeIt != links.end()) { TNode* newNode = typeIt->second; - Y_VERIFY_DEBUG(Type->Equals(*newNode)); + Y_VERIFY_DEBUG(Type->Equals(*newNode)); Type = static_cast<TType*>(newNode); } @@ -1938,7 +1938,7 @@ void TTupleLiteral::DoUpdateLinks(const THashMap<TNode*, TNode*>& links) { auto valueIt = links.find(value.GetNode()); if (valueIt != links.end()) { TNode* newNode = valueIt->second; - Y_VERIFY_DEBUG(value.GetNode()->Equals(*newNode)); + Y_VERIFY_DEBUG(value.GetNode()->Equals(*newNode)); value = TRuntimeNode(newNode, value.IsImmediate()); } } @@ -1978,7 +1978,7 @@ TNode* TTupleLiteral::DoCloneOnCallableWrite(const TTypeEnvironment& env) const } void TTupleLiteral::DoFreeze(const TTypeEnvironment& env) { - Y_UNUSED(env); + Y_UNUSED(env); for (ui32 i = 0; i < GetValuesCount(); ++i) { Values[i].Freeze(); } @@ -2006,16 +2006,16 @@ bool TResourceType::IsConvertableTo(const TResourceType& typeToCompare, bool ign } void TResourceType::DoUpdateLinks(const THashMap<TNode*, TNode*>& links) { - Y_UNUSED(links); + Y_UNUSED(links); } TNode* TResourceType::DoCloneOnCallableWrite(const TTypeEnvironment& env) const { - Y_UNUSED(env); + Y_UNUSED(env); return const_cast<TResourceType*>(this); } void TResourceType::DoFreeze(const TTypeEnvironment& env) { - Y_UNUSED(env); + Y_UNUSED(env); } TResourceType* TResourceType::Create(const TStringBuf& tag, const TTypeEnvironment& env) { diff --git a/ydb/library/yql/minikql/mkql_node.h b/ydb/library/yql/minikql/mkql_node.h index ee74455ea69..c0df55c0c50 100644 --- a/ydb/library/yql/minikql/mkql_node.h +++ b/ydb/library/yql/minikql/mkql_node.h @@ -25,7 +25,7 @@ class TTaggedPointer { public: TTaggedPointer() {} TTaggedPointer(T* ptr, bool mark) { - Y_VERIFY_DEBUG((uintptr_t(ptr) & 1) == 0); + Y_VERIFY_DEBUG((uintptr_t(ptr) & 1) == 0); Raw = (void*)(uintptr_t(ptr) | (mark ? 1 : 0)); } @@ -624,17 +624,17 @@ public: } TStringBuf GetMemberName(ui32 index) const { - Y_VERIFY_DEBUG(index < MembersCount); + Y_VERIFY_DEBUG(index < MembersCount); return Members[index].first.Str(); } TInternName GetMemberNameStr(ui32 index) const { - Y_VERIFY_DEBUG(index < MembersCount); + Y_VERIFY_DEBUG(index < MembersCount); return Members[index].first; } TType* GetMemberType(ui32 index) const { - Y_VERIFY_DEBUG(index < MembersCount); + Y_VERIFY_DEBUG(index < MembersCount); return Members[index].second; } @@ -666,7 +666,7 @@ public: } TRuntimeNode GetValue(ui32 index) const { - Y_VERIFY_DEBUG(index < GetValuesCount()); + Y_VERIFY_DEBUG(index < GetValuesCount()); return Values[index]; } @@ -838,7 +838,7 @@ public: } TRuntimeNode GetItem() const { - Y_VERIFY_DEBUG(Item.GetNode()); + Y_VERIFY_DEBUG(Item.GetNode()); return Item; } @@ -902,7 +902,7 @@ public: } std::pair<TRuntimeNode, TRuntimeNode> GetItem(ui32 index) const { - Y_VERIFY_DEBUG(index < ItemsCount); + Y_VERIFY_DEBUG(index < ItemsCount); return Items[index]; } @@ -955,7 +955,7 @@ public: } TType* GetArgumentType(ui32 index) const { - Y_VERIFY_DEBUG(index < ArgumentsCount); + Y_VERIFY_DEBUG(index < ArgumentsCount); return Arguments[index]; } @@ -1003,7 +1003,7 @@ public: } TRuntimeNode GetInput(ui32 index) const { - Y_VERIFY_DEBUG(index < InputsCount); + Y_VERIFY_DEBUG(index < InputsCount); return Inputs[index]; } @@ -1012,7 +1012,7 @@ public: } TRuntimeNode GetResult() const { - Y_VERIFY_DEBUG(!!Result.GetNode()); + Y_VERIFY_DEBUG(!!Result.GetNode()); return Result; } @@ -1046,7 +1046,7 @@ inline TType::TType(EKind kind, TTypeType* type) : TNode(type) , Kind(kind) { - Y_VERIFY_DEBUG(kind != EKind::Type); + Y_VERIFY_DEBUG(kind != EKind::Type); } @@ -1132,7 +1132,7 @@ public: } TType* GetElementType(ui32 index) const { - Y_VERIFY_DEBUG(index < ElementsCount); + Y_VERIFY_DEBUG(index < ElementsCount); return Elements[index]; } @@ -1161,7 +1161,7 @@ public: } TRuntimeNode GetValue(ui32 index) const { - Y_VERIFY_DEBUG(index < GetValuesCount()); + Y_VERIFY_DEBUG(index < GetValuesCount()); return Values[index]; } diff --git a/ydb/library/yql/minikql/mkql_node_builder.cpp b/ydb/library/yql/minikql/mkql_node_builder.cpp index 34466b89446..0d189caf864 100644 --- a/ydb/library/yql/minikql/mkql_node_builder.cpp +++ b/ydb/library/yql/minikql/mkql_node_builder.cpp @@ -147,7 +147,7 @@ TStructLiteralBuilder& TStructLiteralBuilder::Add(const TStringBuf& name, TRunti } TStructLiteral* TStructLiteralBuilder::Build() { - Y_VERIFY_DEBUG(Members.size() == Values.size()); + Y_VERIFY_DEBUG(Members.size() == Values.size()); if (Members.empty()) return Env->GetEmptyStruct(); diff --git a/ydb/library/yql/minikql/mkql_node_builder_ut.cpp b/ydb/library/yql/minikql/mkql_node_builder_ut.cpp index df310d00b90..977a2e48c3f 100644 --- a/ydb/library/yql/minikql/mkql_node_builder_ut.cpp +++ b/ydb/library/yql/minikql/mkql_node_builder_ut.cpp @@ -8,15 +8,15 @@ namespace NKikimr { namespace NMiniKQL { -Y_UNIT_TEST_SUITE(TMiniKQLNodeBuilderTest) { - Y_UNIT_TEST(TestDataBuild) { +Y_UNIT_TEST_SUITE(TMiniKQLNodeBuilderTest) { + Y_UNIT_TEST(TestDataBuild) { TScopedAlloc alloc; TTypeEnvironment env(alloc); auto d2 = BuildDataLiteral(NUdf::TUnboxedValuePod((ui32)456), NUdf::EDataSlot::Uint32, env); UNIT_ASSERT_EQUAL(d2->GetType()->GetSchemeType(), NUdf::TDataType<ui32>::Id); } - Y_UNIT_TEST(TestStructTypeBuilder) { + Y_UNIT_TEST(TestStructTypeBuilder) { TScopedAlloc alloc; TTypeEnvironment env(alloc); auto type = TStructTypeBuilder(env) @@ -26,7 +26,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLNodeBuilderTest) { UNIT_ASSERT_EQUAL(type->GetKind(), TType::EKind::Struct); } - Y_UNIT_TEST(TestStructLiteralBuilder) { + Y_UNIT_TEST(TestStructLiteralBuilder) { TScopedAlloc alloc; TTypeEnvironment env(alloc); auto structObj = TStructLiteralBuilder(env) @@ -42,7 +42,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLNodeBuilderTest) { UNIT_ASSERT(structObj->GetType()->IsSameType(*structObj2->GetType())); } - Y_UNIT_TEST(TestListLiteralBuilder) { + Y_UNIT_TEST(TestListLiteralBuilder) { TScopedAlloc alloc; TTypeEnvironment env(alloc); auto list = TListLiteralBuilder(env, TDataType::Create(NUdf::TDataType<ui32>::Id, env)) @@ -53,7 +53,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLNodeBuilderTest) { UNIT_ASSERT_EQUAL(list->GetItemsCount(), 2); } - Y_UNIT_TEST(TestCallableTypeBuilder) { + Y_UNIT_TEST(TestCallableTypeBuilder) { TScopedAlloc alloc; TTypeEnvironment env(alloc); auto callableType = TCallableTypeBuilder(env, "func", TDataType::Create(NUdf::TDataType<ui32>::Id, env)) @@ -66,7 +66,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLNodeBuilderTest) { UNIT_ASSERT_EQUAL(callableType->GetArgumentsCount(), 2); } - Y_UNIT_TEST(TestCallableTypeBuilderWithNamesAndFlags) { + Y_UNIT_TEST(TestCallableTypeBuilderWithNamesAndFlags) { TScopedAlloc alloc; TTypeEnvironment env(alloc); auto callableType = TCallableTypeBuilder(env, "func", TDataType::Create(NUdf::TDataType<ui32>::Id, env)) @@ -95,7 +95,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLNodeBuilderTest) { UNIT_ASSERT_EQUAL(callableInspector.GetArgumentFlags(2), 0); } - Y_UNIT_TEST(TestCallableTypeBuilderBadOrderArgNames) { + Y_UNIT_TEST(TestCallableTypeBuilderBadOrderArgNames) { TScopedAlloc alloc; TTypeEnvironment env(alloc); UNIT_ASSERT_EXCEPTION(TCallableTypeBuilder(env, "func", TDataType::Create(NUdf::TDataType<ui32>::Id, env)) @@ -107,7 +107,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLNodeBuilderTest) { .Build(), yexception); } - Y_UNIT_TEST(TestCallableTypeBuilderDuplicateArgNames) { + Y_UNIT_TEST(TestCallableTypeBuilderDuplicateArgNames) { TScopedAlloc alloc; TTypeEnvironment env(alloc); UNIT_ASSERT_EXCEPTION(TCallableTypeBuilder(env, "func", TDataType::Create(NUdf::TDataType<ui32>::Id, env)) @@ -120,7 +120,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLNodeBuilderTest) { .Build(), yexception); } - Y_UNIT_TEST(TestDictLiteralBuilder) { + Y_UNIT_TEST(TestDictLiteralBuilder) { TScopedAlloc alloc; TTypeEnvironment env(alloc); auto dict = TDictLiteralBuilder(env, TDataType::Create(NUdf::TDataType<ui32>::Id, env), @@ -136,7 +136,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLNodeBuilderTest) { UNIT_ASSERT_EQUAL(dict->GetItemsCount(), 2); } - Y_UNIT_TEST(TestCallableBuilder) { + Y_UNIT_TEST(TestCallableBuilder) { TScopedAlloc alloc; TTypeEnvironment env(alloc); auto callable1 = TCallableBuilder(env, "func1", TDataType::Create(NUdf::TDataType<ui32>::Id, env)) @@ -159,7 +159,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLNodeBuilderTest) { UNIT_ASSERT_EQUAL(callable2->GetInputsCount(), 2); } - Y_UNIT_TEST(TestCallableBuilderWithNamesAndFlags) { + Y_UNIT_TEST(TestCallableBuilderWithNamesAndFlags) { TScopedAlloc alloc; TTypeEnvironment env(alloc); auto callable1 = TCallableBuilder(env, "func1", TDataType::Create(NUdf::TDataType<ui32>::Id, env)) diff --git a/ydb/library/yql/minikql/mkql_node_cast_ut.cpp b/ydb/library/yql/minikql/mkql_node_cast_ut.cpp index 0ae19fa5e45..d9b65048a92 100644 --- a/ydb/library/yql/minikql/mkql_node_cast_ut.cpp +++ b/ydb/library/yql/minikql/mkql_node_cast_ut.cpp @@ -27,7 +27,7 @@ class TMiniKQLNodeCast: public TTestBase void BadAsTypeTest() { TRuntimeNode node = Uint32AsNode(123); TCallableType* type = AS_TYPE(TCallableType, node); - Y_UNUSED(type); + Y_UNUSED(type); } void AsValueTest() { @@ -49,7 +49,7 @@ class TMiniKQLNodeCast: public TTestBase void BadAsValueTest() { TRuntimeNode node = Uint32AsNode(123); TListLiteral* list = AS_VALUE(TListLiteral, node); - Y_UNUSED(list); + Y_UNUSED(list); } TMiniKQLNodeCast() diff --git a/ydb/library/yql/minikql/mkql_node_printer.cpp b/ydb/library/yql/minikql/mkql_node_printer.cpp index f7515a30050..4649e62554d 100644 --- a/ydb/library/yql/minikql/mkql_node_printer.cpp +++ b/ydb/library/yql/minikql/mkql_node_printer.cpp @@ -30,14 +30,14 @@ namespace { {} void Visit(TTypeType& node) override { - Y_UNUSED(node); + Y_UNUSED(node); WriteIndentation(); Out << "Type (Type)"; WriteNewline(); } void Visit(TVoidType& node) override { - Y_UNUSED(node); + Y_UNUSED(node); WriteIndentation(); Out << "Type (Void) "; WriteNewline(); @@ -346,7 +346,7 @@ namespace { } void Visit(TAnyType& node) override { - Y_UNUSED(node); + Y_UNUSED(node); WriteIndentation(); Out << "Type (Any) "; WriteNewline(); @@ -381,7 +381,7 @@ namespace { } void Visit(TResourceType& node) override { - Y_UNUSED(node); + Y_UNUSED(node); WriteIndentation(); Out << "Type (Resource) (" << node.GetTag() << ")"; WriteNewline(); @@ -833,7 +833,7 @@ TString PrintNode(const TNode* node, bool singleLine) { template <> void Out<NKikimr::NMiniKQL::TType>( - IOutputStream& os, + IOutputStream& os, TTypeTraits<NKikimr::NMiniKQL::TType>::TFuncParam t ) { diff --git a/ydb/library/yql/minikql/mkql_node_printer_ut.cpp b/ydb/library/yql/minikql/mkql_node_printer_ut.cpp index ec8c5d1afe7..820d0f80c57 100644 --- a/ydb/library/yql/minikql/mkql_node_printer_ut.cpp +++ b/ydb/library/yql/minikql/mkql_node_printer_ut.cpp @@ -82,8 +82,8 @@ namespace { } } -Y_UNIT_TEST_SUITE(TMiniKQLNodePrinterTest) { - Y_UNIT_TEST(TestPrintWithoutSchema) { +Y_UNIT_TEST_SUITE(TMiniKQLNodePrinterTest) { + Y_UNIT_TEST(TestPrintWithoutSchema) { TScopedAlloc alloc; TTypeEnvironment env(alloc); auto node = BuildGraph(env); @@ -96,7 +96,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLNodePrinterTest) { UNIT_ASSERT_EQUAL(s2, s); } - Y_UNIT_TEST(RuntimeNodeSerialization) { + Y_UNIT_TEST(RuntimeNodeSerialization) { TScopedAlloc alloc; TTypeEnvironment env(alloc); TDataType* dtype1 = TDataType::Create(NUdf::TDataType<ui32>::Id, env); diff --git a/ydb/library/yql/minikql/mkql_node_serialization.cpp b/ydb/library/yql/minikql/mkql_node_serialization.cpp index e314f38cd61..7a8dd3f0ebb 100644 --- a/ydb/library/yql/minikql/mkql_node_serialization.cpp +++ b/ydb/library/yql/minikql/mkql_node_serialization.cpp @@ -108,13 +108,13 @@ namespace { } void Visit(TTypeType& node) override { - Y_UNUSED(node); + Y_UNUSED(node); Owner.Write(TypeMarker | (char)TType::EKind::Type); IsProcessed0 = true; } void Visit(TVoidType& node) override { - Y_UNUSED(node); + Y_UNUSED(node); Owner.Write(TypeMarker | (char)TType::EKind::Void); IsProcessed0 = true; } @@ -289,7 +289,7 @@ namespace { } void Visit(TAnyType& node) override { - Y_UNUSED(node); + Y_UNUSED(node); Owner.Write(TypeMarker | (char)TType::EKind::Any); IsProcessed0 = true; } @@ -338,7 +338,7 @@ namespace { } void Visit(TVoid& node) override { - Y_UNUSED(node); + Y_UNUSED(node); Owner.Write((char)TType::EKind::Void); IsProcessed0 = true; } @@ -383,7 +383,7 @@ namespace { Owner.Write((char)TType::EKind::Struct); auto type = node.GetType(); - Y_VERIFY_DEBUG(node.GetValuesCount() == type->GetMembersCount()); + Y_VERIFY_DEBUG(node.GetValuesCount() == type->GetMembersCount()); for (ui32 i = node.GetValuesCount(); i-- > 0; ) { auto value = node.GetValue(i); Owner.AddChildNode(*value.GetNode()); @@ -469,7 +469,7 @@ namespace { auto result = node.GetResult(); Owner.AddChildNode(*result.GetNode()); } else { - Y_VERIFY_DEBUG(node.GetInputsCount() == type->GetArgumentsCount()); + Y_VERIFY_DEBUG(node.GetInputsCount() == type->GetArgumentsCount()); for (ui32 i = node.GetInputsCount(); i-- > 0;) { auto input = node.GetInput(i); Owner.AddChildNode(*input.GetNode()); @@ -508,7 +508,7 @@ namespace { Owner.Write((char)TType::EKind::Tuple); auto type = node.GetType(); - Y_VERIFY_DEBUG(node.GetValuesCount() == type->GetElementsCount()); + Y_VERIFY_DEBUG(node.GetValuesCount() == type->GetElementsCount()); for (ui32 i = node.GetValuesCount(); i-- > 0;) { auto value = node.GetValue(i); Owner.AddChildNode(*value.GetNode()); @@ -552,11 +552,11 @@ namespace { } void Visit(TTypeType& node) override { - Y_UNUSED(node); + Y_UNUSED(node); } void Visit(TVoidType& node) override { - Y_UNUSED(node); + Y_UNUSED(node); } void Visit(TNullType& node) override { @@ -623,7 +623,7 @@ namespace { } void Visit(TAnyType& node) override { - Y_UNUSED(node); + Y_UNUSED(node); } void Visit(TTupleType& node) override { @@ -639,7 +639,7 @@ namespace { } void Visit(TVoid& node) override { - Y_UNUSED(node); + Y_UNUSED(node); } void Visit(TNull& node) override { @@ -744,7 +744,7 @@ namespace { void Visit(TStructLiteral& node) override { auto type = node.GetType(); - Y_VERIFY_DEBUG(node.GetValuesCount() == type->GetMembersCount()); + Y_VERIFY_DEBUG(node.GetValuesCount() == type->GetMembersCount()); TStackVec<char> immediateFlags(GetBitmapBytes(node.GetValuesCount())); for (ui32 i = 0, e = node.GetValuesCount(); i < e; ++i) { auto value = node.GetValue(i); @@ -796,7 +796,7 @@ namespace { Owner.Write(node.GetResult().IsImmediate() ? 1 : 0); } else { auto type = node.GetType(); - Y_VERIFY_DEBUG(node.GetInputsCount() == type->GetArgumentsCount()); + Y_VERIFY_DEBUG(node.GetInputsCount() == type->GetArgumentsCount()); TStackVec<char> immediateFlags(GetBitmapBytes(node.GetInputsCount())); for (ui32 i = 0, e = node.GetInputsCount(); i < e; ++i) { auto input = node.GetInput(i); @@ -820,7 +820,7 @@ namespace { void Visit(TTupleLiteral& node) override { auto type = node.GetType(); - Y_VERIFY_DEBUG(node.GetValuesCount() == type->GetElementsCount()); + Y_VERIFY_DEBUG(node.GetValuesCount() == type->GetElementsCount()); TStackVec<char> immediateFlags(GetBitmapBytes(node.GetValuesCount())); for (ui32 i = 0, e = node.GetValuesCount(); i < e; ++i) { auto value = node.GetValue(i); @@ -860,16 +860,16 @@ namespace { auto prevSize = Stack.size(); nodeAndFlag.first->Accept(preVisitor); if (preVisitor.IsProcessed()) { // ref or small node, some nodes have been added - Y_VERIFY_DEBUG(prevSize == Stack.size()); + Y_VERIFY_DEBUG(prevSize == Stack.size()); Stack.pop_back(); continue; } - Y_VERIFY_DEBUG(prevSize <= Stack.size()); + Y_VERIFY_DEBUG(prevSize <= Stack.size()); } else { auto prevSize = Stack.size(); nodeAndFlag.first->Accept(postVisitor); - Y_VERIFY_DEBUG(prevSize == Stack.size()); + Y_VERIFY_DEBUG(prevSize == Stack.size()); Stack.pop_back(); } } @@ -905,7 +905,7 @@ namespace { it->second = nameIndex++; } - Y_VERIFY_DEBUG(nameIndex == Names.size()); + Y_VERIFY_DEBUG(nameIndex == Names.size()); } void End() { @@ -917,14 +917,14 @@ namespace { } void RegisterReference(TNode& node) { - Y_VERIFY_DEBUG(node.GetCookie() == 0); + Y_VERIFY_DEBUG(node.GetCookie() == 0); node.SetCookie(++ReferenceCount); } void WriteReference(TNode& node) { Write(SystemMask | (char)ESystemCommand::Ref); - Y_VERIFY_DEBUG(node.GetCookie() != 0); - Y_VERIFY_DEBUG(node.GetCookie() <= ReferenceCount); + Y_VERIFY_DEBUG(node.GetCookie() != 0); + Y_VERIFY_DEBUG(node.GetCookie() <= ReferenceCount); WriteVar32(node.GetCookie() - 1); } @@ -999,7 +999,7 @@ namespace { } if (last.NextPass == AllPassesDone) { - Y_VERIFY_DEBUG(last.ChildCount <= NodeStack.size()); + Y_VERIFY_DEBUG(last.ChildCount <= NodeStack.size()); Reverse(NodeStack.end() - last.ChildCount, NodeStack.end()); auto newNode = ReadNode(); if (Current > lastPos) { @@ -1023,7 +1023,7 @@ namespace { if (childCount != 0) { CtxStack.insert(CtxStack.end(), childCount, TNodeContext()); } else { - Y_VERIFY_DEBUG(res == 0); + Y_VERIFY_DEBUG(res == 0); } } @@ -2047,7 +2047,7 @@ TString SerializeNode(TNode* node, const TTypeEnvironment& env) noexcept{ } TString SerializeRuntimeNode(TExploringNodeVisitor& explorer, TRuntimeNode node, const TTypeEnvironment& env) noexcept{ - Y_UNUSED(env); + Y_UNUSED(env); TPrepareWriteNodeVisitor preparer; for (auto node : explorer.GetNodes()) { node->Accept(preparer); diff --git a/ydb/library/yql/minikql/mkql_node_ut.cpp b/ydb/library/yql/minikql/mkql_node_ut.cpp index 16126272462..baf328d1721 100644 --- a/ydb/library/yql/minikql/mkql_node_ut.cpp +++ b/ydb/library/yql/minikql/mkql_node_ut.cpp @@ -9,8 +9,8 @@ namespace NKikimr { namespace NMiniKQL { -Y_UNIT_TEST_SUITE(TMiniKQLNodeTest) { - Y_UNIT_TEST(TestTypeOfType) { +Y_UNIT_TEST_SUITE(TMiniKQLNodeTest) { + Y_UNIT_TEST(TestTypeOfType) { TScopedAlloc alloc; TTypeEnvironment env(alloc); { @@ -21,7 +21,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLNodeTest) { } } - Y_UNIT_TEST(TestTypeOfVoid) { + Y_UNIT_TEST(TestTypeOfVoid) { TScopedAlloc alloc; TTypeEnvironment env(alloc); { @@ -32,7 +32,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLNodeTest) { } } - Y_UNIT_TEST(TestVoid) { + Y_UNIT_TEST(TestVoid) { TScopedAlloc alloc; TTypeEnvironment env(alloc); TVoid* voidObj = env.GetVoid(); @@ -40,7 +40,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLNodeTest) { UNIT_ASSERT(voidObj->GetType() == env.GetTypeOfVoid()); } - Y_UNIT_TEST(TestTypeOfData) { + Y_UNIT_TEST(TestTypeOfData) { TScopedAlloc alloc; TTypeEnvironment env(alloc); TDataType* dtype1 = TDataType::Create(NUdf::TDataType<ui32>::Id, env); @@ -54,7 +54,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLNodeTest) { UNIT_ASSERT(dtype1Cloned->IsSameType(*dtype1)); } - Y_UNIT_TEST(TestData) { + Y_UNIT_TEST(TestData) { TScopedAlloc alloc; TTypeEnvironment env(alloc); TDataType* dtype1 = TDataType::Create(NUdf::TDataType<ui32>::Id, env); @@ -65,7 +65,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLNodeTest) { UNIT_ASSERT(d1->GetType() == dtype1); } - Y_UNIT_TEST(TestStructType) { + Y_UNIT_TEST(TestStructType) { TScopedAlloc alloc; TTypeEnvironment env(alloc); TStructType* sempty = env.GetEmptyStruct()->GetType(); @@ -107,7 +107,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLNodeTest) { UNIT_ASSERT_EXCEPTION(TStructType::Create(duplicatedMembers.data(), duplicatedMembers.size(), env), yexception); } - Y_UNIT_TEST(TestStructLiteral) { + Y_UNIT_TEST(TestStructLiteral) { TScopedAlloc alloc; TTypeEnvironment env(alloc); TStructType* semptyType = env.GetEmptyStruct()->GetType(); @@ -140,7 +140,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLNodeTest) { UNIT_ASSERT_NO_EXCEPTION(TStructLiteral::Create(s1values.size(), s1values.data(), s1typeDyn, env)); } - Y_UNIT_TEST(TestListType) { + Y_UNIT_TEST(TestListType) { TScopedAlloc alloc; TTypeEnvironment env(alloc); TListType* list1type = TListType::Create(env.GetVoid()->GetGenericType(), env); @@ -151,7 +151,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLNodeTest) { UNIT_ASSERT(!list1type->IsSameType(*list2type)); } - Y_UNIT_TEST(TestStreamType) { + Y_UNIT_TEST(TestStreamType) { TScopedAlloc alloc; TTypeEnvironment env(alloc); TStreamType* stream1type = TStreamType::Create(env.GetVoid()->GetGenericType(), env); @@ -162,7 +162,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLNodeTest) { UNIT_ASSERT(!stream1type->IsSameType(*stream2type)); } - Y_UNIT_TEST(TestListLiteral) { + Y_UNIT_TEST(TestListLiteral) { TScopedAlloc alloc; TTypeEnvironment env(alloc); TDataType* dtype1 = TDataType::Create(NUdf::TDataType<char*>::Id, env); @@ -197,7 +197,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLNodeTest) { UNIT_ASSERT_NO_EXCEPTION(TListLiteral::Create(someDynItems.data(), someDynItems.size(), list2typeDyn, env)); } - Y_UNIT_TEST(TestOptionalType) { + Y_UNIT_TEST(TestOptionalType) { TScopedAlloc alloc; TTypeEnvironment env(alloc); TOptionalType* opt1type = TOptionalType::Create(env.GetVoid()->GetGenericType(), env); @@ -208,7 +208,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLNodeTest) { UNIT_ASSERT(!opt1type->IsSameType(*opt2type)); } - Y_UNIT_TEST(TestOptionalLiteral) { + Y_UNIT_TEST(TestOptionalLiteral) { TScopedAlloc alloc; TTypeEnvironment env(alloc); TDataType* dtype1 = TDataType::Create(NUdf::TDataType<char*>::Id, env); @@ -238,7 +238,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLNodeTest) { UNIT_ASSERT_NO_EXCEPTION(TOptionalLiteral::Create(dynItem, opt2typeDyn, env)); } - Y_UNIT_TEST(TestDictType) { + Y_UNIT_TEST(TestDictType) { TScopedAlloc alloc; TTypeEnvironment env(alloc); TDataType* dtype1 = TDataType::Create(NUdf::TDataType<ui32>::Id, env); @@ -250,7 +250,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLNodeTest) { UNIT_ASSERT(!dictType1->IsSameType(*dictType2)); } - Y_UNIT_TEST(TestCallableType) { + Y_UNIT_TEST(TestCallableType) { TScopedAlloc alloc; TTypeEnvironment env(alloc); TCallableType* ctype1 = TCallableType::Create("c1", env.GetTypeOfVoid(), @@ -303,7 +303,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLNodeTest) { UNIT_ASSERT_EXCEPTION(ctype2optArg->SetOptionalArgumentsCount(3), yexception); } - Y_UNIT_TEST(TestDictLiteral) { + Y_UNIT_TEST(TestDictLiteral) { TScopedAlloc alloc; TTypeEnvironment env(alloc); TDataType* dtype1 = TDataType::Create(NUdf::TDataType<char*>::Id, env); @@ -349,7 +349,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLNodeTest) { UNIT_ASSERT_NO_EXCEPTION(TDictLiteral::Create(someDynItems.size(), someDynItems.data(), dict2TypeDyn, env)); } - Y_UNIT_TEST(TestCallable) { + Y_UNIT_TEST(TestCallable) { TScopedAlloc alloc; TTypeEnvironment env(alloc); TCallableType* ctype1 = TCallableType::Create("c1", env.GetTypeOfVoid(), @@ -389,7 +389,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLNodeTest) { UNIT_ASSERT_EQUAL(c2->GetResult().GetStaticType()->GetKind(), TType::EKind::Void); } - Y_UNIT_TEST(TestThrowingVisitor) { + Y_UNIT_TEST(TestThrowingVisitor) { TScopedAlloc alloc; TTypeEnvironment env(alloc); TThrowingNodeVisitor visitor; @@ -397,7 +397,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLNodeTest) { UNIT_ASSERT_EXCEPTION(visitor.Visit(*env.GetTypeOfType()), yexception); } - Y_UNIT_TEST(TestEmptyVisitor) { + Y_UNIT_TEST(TestEmptyVisitor) { TScopedAlloc alloc; TTypeEnvironment env(alloc); TEmptyNodeVisitor visitor; @@ -438,7 +438,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLNodeTest) { UNIT_ASSERT(any1->TNode::Equals(*any2)); } - Y_UNIT_TEST(TestTupleType) { + Y_UNIT_TEST(TestTupleType) { TScopedAlloc alloc; TTypeEnvironment env(alloc); TTupleType* tempty = env.GetEmptyTuple()->GetType(); @@ -465,7 +465,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLNodeTest) { UNIT_ASSERT(!t2cloned->IsSameType(*t1)); } - Y_UNIT_TEST(TestTupleLiteral) { + Y_UNIT_TEST(TestTupleLiteral) { TScopedAlloc alloc; TTypeEnvironment env(alloc); TTupleType* temptyType = env.GetEmptyTuple()->GetType(); @@ -498,7 +498,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLNodeTest) { UNIT_ASSERT_NO_EXCEPTION(TTupleLiteral::Create(t1values.size(), t1values.data(), t1typeDyn, env)); } - Y_UNIT_TEST(TestVariantType) { + Y_UNIT_TEST(TestVariantType) { TScopedAlloc alloc; TTypeEnvironment env(alloc); auto emptyStructType = env.GetEmptyStruct()->GetType(); @@ -540,7 +540,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLNodeTest) { UNIT_ASSERT(var2struct->GetUnderlyingType() == struct2type); } - Y_UNIT_TEST(TestVariantLiteral) { + Y_UNIT_TEST(TestVariantLiteral) { TScopedAlloc alloc; TTypeEnvironment env(alloc); auto emptyStructType = env.GetEmptyStruct()->GetType(); diff --git a/ydb/library/yql/minikql/mkql_node_visitor.cpp b/ydb/library/yql/minikql/mkql_node_visitor.cpp index 5a4ac8e4798..a2f9f8f6c84 100644 --- a/ydb/library/yql/minikql/mkql_node_visitor.cpp +++ b/ydb/library/yql/minikql/mkql_node_visitor.cpp @@ -12,12 +12,12 @@ const ui64 IS_NODE_ENTERED = 1; const ui64 IS_NODE_EXITED = 2; void TThrowingNodeVisitor::Visit(TTypeType& node) { - Y_UNUSED(node); + Y_UNUSED(node); ThrowUnexpectedNodeType(); } void TThrowingNodeVisitor::Visit(TVoidType& node) { - Y_UNUSED(node); + Y_UNUSED(node); ThrowUnexpectedNodeType(); } @@ -37,47 +37,47 @@ void TThrowingNodeVisitor::Visit(TEmptyDictType& node) { } void TThrowingNodeVisitor::Visit(TDataType& node) { - Y_UNUSED(node); + Y_UNUSED(node); ThrowUnexpectedNodeType(); } void TThrowingNodeVisitor::Visit(TStructType& node) { - Y_UNUSED(node); + Y_UNUSED(node); ThrowUnexpectedNodeType(); } void TThrowingNodeVisitor::Visit(TListType& node) { - Y_UNUSED(node); + Y_UNUSED(node); ThrowUnexpectedNodeType(); } void TThrowingNodeVisitor::Visit(TOptionalType& node) { - Y_UNUSED(node); + Y_UNUSED(node); ThrowUnexpectedNodeType(); } void TThrowingNodeVisitor::Visit(TDictType& node) { - Y_UNUSED(node); + Y_UNUSED(node); ThrowUnexpectedNodeType(); } void TThrowingNodeVisitor::Visit(TCallableType& node) { - Y_UNUSED(node); + Y_UNUSED(node); ThrowUnexpectedNodeType(); } void TThrowingNodeVisitor::Visit(TAnyType& node) { - Y_UNUSED(node); + Y_UNUSED(node); ThrowUnexpectedNodeType(); } void TThrowingNodeVisitor::Visit(TTupleType& node) { - Y_UNUSED(node); + Y_UNUSED(node); ThrowUnexpectedNodeType(); } void TThrowingNodeVisitor::Visit(TResourceType& node) { - Y_UNUSED(node); + Y_UNUSED(node); ThrowUnexpectedNodeType(); } @@ -87,7 +87,7 @@ void TThrowingNodeVisitor::Visit(TVariantType& node) { } void TThrowingNodeVisitor::Visit(TVoid& node) { - Y_UNUSED(node); + Y_UNUSED(node); ThrowUnexpectedNodeType(); } @@ -107,42 +107,42 @@ void TThrowingNodeVisitor::Visit(TEmptyDict& node) { } void TThrowingNodeVisitor::Visit(TDataLiteral& node) { - Y_UNUSED(node); + Y_UNUSED(node); ThrowUnexpectedNodeType(); } void TThrowingNodeVisitor::Visit(TStructLiteral& node) { - Y_UNUSED(node); + Y_UNUSED(node); ThrowUnexpectedNodeType(); } void TThrowingNodeVisitor::Visit(TListLiteral& node) { - Y_UNUSED(node); + Y_UNUSED(node); ThrowUnexpectedNodeType(); } void TThrowingNodeVisitor::Visit(TOptionalLiteral& node) { - Y_UNUSED(node); + Y_UNUSED(node); ThrowUnexpectedNodeType(); } void TThrowingNodeVisitor::Visit(TDictLiteral& node) { - Y_UNUSED(node); + Y_UNUSED(node); ThrowUnexpectedNodeType(); } void TThrowingNodeVisitor::Visit(TCallable& node) { - Y_UNUSED(node); + Y_UNUSED(node); ThrowUnexpectedNodeType(); } void TThrowingNodeVisitor::Visit(TAny& node) { - Y_UNUSED(node); + Y_UNUSED(node); ThrowUnexpectedNodeType(); } void TThrowingNodeVisitor::Visit(TTupleLiteral& node) { - Y_UNUSED(node); + Y_UNUSED(node); ThrowUnexpectedNodeType(); } @@ -176,11 +176,11 @@ void TThrowingNodeVisitor::ThrowUnexpectedNodeType() { } void TEmptyNodeVisitor::Visit(TTypeType& node) { - Y_UNUSED(node); + Y_UNUSED(node); } void TEmptyNodeVisitor::Visit(TVoidType& node) { - Y_UNUSED(node); + Y_UNUSED(node); } void TEmptyNodeVisitor::Visit(TNullType& node) { @@ -196,39 +196,39 @@ void TEmptyNodeVisitor::Visit(TEmptyDictType& node) { } void TEmptyNodeVisitor::Visit(TDataType& node) { - Y_UNUSED(node); + Y_UNUSED(node); } void TEmptyNodeVisitor::Visit(TStructType& node) { - Y_UNUSED(node); + Y_UNUSED(node); } void TEmptyNodeVisitor::Visit(TListType& node) { - Y_UNUSED(node); + Y_UNUSED(node); } void TEmptyNodeVisitor::Visit(TOptionalType& node) { - Y_UNUSED(node); + Y_UNUSED(node); } void TEmptyNodeVisitor::Visit(TDictType& node) { - Y_UNUSED(node); + Y_UNUSED(node); } void TEmptyNodeVisitor::Visit(TCallableType& node) { - Y_UNUSED(node); + Y_UNUSED(node); } void TEmptyNodeVisitor::Visit(TAnyType& node) { - Y_UNUSED(node); + Y_UNUSED(node); } void TEmptyNodeVisitor::Visit(TTupleType& node) { - Y_UNUSED(node); + Y_UNUSED(node); } void TEmptyNodeVisitor::Visit(TResourceType& node) { - Y_UNUSED(node); + Y_UNUSED(node); } void TEmptyNodeVisitor::Visit(TVariantType& node) { @@ -236,7 +236,7 @@ void TEmptyNodeVisitor::Visit(TVariantType& node) { } void TEmptyNodeVisitor::Visit(TVoid& node) { - Y_UNUSED(node); + Y_UNUSED(node); } void TEmptyNodeVisitor::Visit(TNull& node) { @@ -252,35 +252,35 @@ void TEmptyNodeVisitor::Visit(TEmptyDict& node) { } void TEmptyNodeVisitor::Visit(TDataLiteral& node) { - Y_UNUSED(node); + Y_UNUSED(node); } void TEmptyNodeVisitor::Visit(TStructLiteral& node) { - Y_UNUSED(node); + Y_UNUSED(node); } void TEmptyNodeVisitor::Visit(TListLiteral& node) { - Y_UNUSED(node); + Y_UNUSED(node); } void TEmptyNodeVisitor::Visit(TOptionalLiteral& node) { - Y_UNUSED(node); + Y_UNUSED(node); } void TEmptyNodeVisitor::Visit(TDictLiteral& node) { - Y_UNUSED(node); + Y_UNUSED(node); } void TEmptyNodeVisitor::Visit(TCallable& node) { - Y_UNUSED(node); + Y_UNUSED(node); } void TEmptyNodeVisitor::Visit(TAny& node) { - Y_UNUSED(node); + Y_UNUSED(node); } void TEmptyNodeVisitor::Visit(TTupleLiteral& node) { - Y_UNUSED(node); + Y_UNUSED(node); } void TEmptyNodeVisitor::Visit(TVariantLiteral& node) { @@ -304,7 +304,7 @@ void TEmptyNodeVisitor::Visit(TBlockType& node) { } void TExploringNodeVisitor::Visit(TTypeType& node) { - Y_VERIFY_DEBUG(node.GetType() == &node); + Y_VERIFY_DEBUG(node.GetType() == &node); } void TExploringNodeVisitor::Visit(TVoidType& node) { @@ -527,7 +527,7 @@ void TExploringNodeVisitor::Walk(TNode* root, const TTypeEnvironment& env, const NodeList.push_back(node); node->SetCookie(IS_NODE_EXITED); } else { - Y_VERIFY(node->GetCookie() <= IS_NODE_EXITED, "TNode graph should not be reused"); + Y_VERIFY(node->GetCookie() <= IS_NODE_EXITED, "TNode graph should not be reused"); } Stack->pop_back(); diff --git a/ydb/library/yql/minikql/mkql_opt_literal.cpp b/ydb/library/yql/minikql/mkql_opt_literal.cpp index 832a87ea80c..4c7bf5948a3 100644 --- a/ydb/library/yql/minikql/mkql_opt_literal.cpp +++ b/ydb/library/yql/minikql/mkql_opt_literal.cpp @@ -65,7 +65,7 @@ TNode* LiteralRemoveMember( } TRuntimeNode OptimizeIf(TCallable& callable, const TTypeEnvironment& env) { - Y_UNUSED(env); + Y_UNUSED(env); MKQL_ENSURE(callable.GetInputsCount() == 3, "Expected 3 arguments"); auto predicateInput = callable.GetInput(0); @@ -141,7 +141,7 @@ TRuntimeNode OptimizeRemoveMember(TCallable& callable, const TTypeEnvironment& e } TRuntimeNode OptimizeMember(TCallable& callable, const TTypeEnvironment& env) { - Y_UNUSED(env); + Y_UNUSED(env); MKQL_ENSURE(callable.GetInputsCount() == 2, "Expected 2 arguments"); auto structInput = callable.GetInput(0); @@ -230,7 +230,7 @@ TRuntimeNode OptimizeFlatMap(TCallable& callable, const TTypeEnvironment& env) { } TRuntimeNode OptimizeCoalesce(TCallable& callable, const TTypeEnvironment& env) { - Y_UNUSED(env); + Y_UNUSED(env); MKQL_ENSURE(callable.GetInputsCount() == 2, "Expected 2 arguments"); auto optionalInput = callable.GetInput(0); @@ -262,7 +262,7 @@ TRuntimeNode OptimizeExists(TCallable& callable, const TTypeEnvironment& env) { } TRuntimeNode OptimizeNth(TCallable& callable, const TTypeEnvironment& env) { - Y_UNUSED(env); + Y_UNUSED(env); MKQL_ENSURE(callable.GetInputsCount() == 2, "Expected 2 arguments"); auto tupleInput = callable.GetInput(0); diff --git a/ydb/library/yql/minikql/mkql_opt_literal_ut.cpp b/ydb/library/yql/minikql/mkql_opt_literal_ut.cpp index c1c0a5b79da..27d1a0a903d 100644 --- a/ydb/library/yql/minikql/mkql_opt_literal_ut.cpp +++ b/ydb/library/yql/minikql/mkql_opt_literal_ut.cpp @@ -13,8 +13,8 @@ TRuntimeNode MakeVoidCallable(TProgramBuilder& pgmBuilder) { return TRuntimeNode(callableBuilder.Build(), false); } -Y_UNIT_TEST_SUITE(TMiniKQLLPOTest) { - Y_UNIT_TEST(TestIfPredicateTrue) { +Y_UNIT_TEST_SUITE(TMiniKQLLPOTest) { + Y_UNIT_TEST(TestIfPredicateTrue) { auto functionRegistry = CreateFunctionRegistry(IBuiltinFunctionRegistry::TPtr()); TScopedAlloc alloc; TTypeEnvironment env(alloc); @@ -32,7 +32,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLLPOTest) { UNIT_ASSERT_EQUAL(static_cast<TCallableType&>(*item.GetNode()->GetType()).GetName(), "Effect"); } - Y_UNIT_TEST(TestIfPredicateSame) { + Y_UNIT_TEST(TestIfPredicateSame) { auto functionRegistry = CreateFunctionRegistry(IBuiltinFunctionRegistry::TPtr()); TScopedAlloc alloc; TTypeEnvironment env(alloc); @@ -50,7 +50,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLLPOTest) { UNIT_ASSERT_EQUAL(static_cast<TCallableType&>(*item.GetNode()->GetType()).GetName(), "Effect"); } - Y_UNIT_TEST(TestIfPredicateFalse) { + Y_UNIT_TEST(TestIfPredicateFalse) { auto functionRegistry = CreateFunctionRegistry(IBuiltinFunctionRegistry::TPtr()); TScopedAlloc alloc; TTypeEnvironment env(alloc); @@ -68,7 +68,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLLPOTest) { UNIT_ASSERT_EQUAL(static_cast<TCallableType&>(*item.GetNode()->GetType()).GetName(), "Effect"); } - Y_UNIT_TEST(TestSize) { + Y_UNIT_TEST(TestSize) { auto functionRegistry = CreateFunctionRegistry(IBuiltinFunctionRegistry::TPtr()); TScopedAlloc alloc; TTypeEnvironment env(alloc); @@ -81,7 +81,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLLPOTest) { UNIT_ASSERT_EQUAL(static_cast<TDataLiteral&>(*pgm).AsValue().Get<ui32>(), 3); } - Y_UNIT_TEST(TestLength) { + Y_UNIT_TEST(TestLength) { auto functionRegistry = CreateFunctionRegistry(IBuiltinFunctionRegistry::TPtr()); TScopedAlloc alloc; TTypeEnvironment env(alloc); @@ -95,7 +95,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLLPOTest) { UNIT_ASSERT_EQUAL(static_cast<TDataLiteral&>(*pgm).AsValue().Get<ui64>(), 1); } - Y_UNIT_TEST(TestAddMember) { + Y_UNIT_TEST(TestAddMember) { auto functionRegistry = CreateFunctionRegistry(IBuiltinFunctionRegistry::TPtr()); TScopedAlloc alloc; TTypeEnvironment env(alloc); @@ -123,7 +123,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLLPOTest) { UNIT_ASSERT_EQUAL(static_cast<TStructLiteral&>(*pgm).GetValuesCount(), 3); } - Y_UNIT_TEST(TestMember) { + Y_UNIT_TEST(TestMember) { auto functionRegistry = CreateFunctionRegistry(IBuiltinFunctionRegistry::TPtr()); TScopedAlloc alloc; TTypeEnvironment env(alloc); @@ -137,7 +137,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLLPOTest) { UNIT_ASSERT_EQUAL(pgm->GetType()->GetKind(), TType::EKind::Void); } - Y_UNIT_TEST(TestFilterPredicateTrue) { + Y_UNIT_TEST(TestFilterPredicateTrue) { auto functionRegistry = CreateFunctionRegistry(IBuiltinFunctionRegistry::TPtr()); TScopedAlloc alloc; TTypeEnvironment env(alloc); @@ -159,7 +159,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLLPOTest) { UNIT_ASSERT_EQUAL(static_cast<TListLiteral&>(*pgm).GetItemsCount(), 2); } - Y_UNIT_TEST(TestFilterPredicateFalse) { + Y_UNIT_TEST(TestFilterPredicateFalse) { auto functionRegistry = CreateFunctionRegistry(IBuiltinFunctionRegistry::TPtr()); TScopedAlloc alloc; TTypeEnvironment env(alloc); @@ -181,7 +181,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLLPOTest) { UNIT_ASSERT_EQUAL(static_cast<TListLiteral&>(*pgm).GetItemsCount(), 0); } - Y_UNIT_TEST(TestMapToVoid) { + Y_UNIT_TEST(TestMapToVoid) { auto functionRegistry = CreateFunctionRegistry(IBuiltinFunctionRegistry::TPtr()); TScopedAlloc alloc; TTypeEnvironment env(alloc); @@ -203,7 +203,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLLPOTest) { UNIT_ASSERT_EQUAL(static_cast<TListLiteral&>(*pgm).GetItemsCount(), 0); } - Y_UNIT_TEST(TestFlatMapToLiteralListOfVoid) { + Y_UNIT_TEST(TestFlatMapToLiteralListOfVoid) { auto functionRegistry = CreateFunctionRegistry(IBuiltinFunctionRegistry::TPtr()); TScopedAlloc alloc; TTypeEnvironment env(alloc); @@ -225,7 +225,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLLPOTest) { UNIT_ASSERT_EQUAL(static_cast<TListLiteral&>(*pgm).GetItemsCount(), 0); } - Y_UNIT_TEST(TestFlatMapToLiteralListOfVoid_Optional) { + Y_UNIT_TEST(TestFlatMapToLiteralListOfVoid_Optional) { auto functionRegistry = CreateFunctionRegistry(IBuiltinFunctionRegistry::TPtr()); TScopedAlloc alloc; TTypeEnvironment env(alloc); @@ -247,7 +247,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLLPOTest) { UNIT_ASSERT_EQUAL(static_cast<TListLiteral&>(*pgm).GetItemsCount(), 0); } - Y_UNIT_TEST(TestLiteralCoalesceExist) { + Y_UNIT_TEST(TestLiteralCoalesceExist) { auto functionRegistry = CreateFunctionRegistry(IBuiltinFunctionRegistry::TPtr()); TScopedAlloc alloc; TTypeEnvironment env(alloc); @@ -260,7 +260,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLLPOTest) { UNIT_ASSERT_EQUAL(static_cast<TDataLiteral&>(*pgm).AsValue().Get<ui32>(), 1); } - Y_UNIT_TEST(TestLiteralCoalesceNotExist) { + Y_UNIT_TEST(TestLiteralCoalesceNotExist) { auto functionRegistry = CreateFunctionRegistry(IBuiltinFunctionRegistry::TPtr()); TScopedAlloc alloc; TTypeEnvironment env(alloc); @@ -273,7 +273,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLLPOTest) { UNIT_ASSERT_EQUAL(static_cast<TDataLiteral&>(*pgm).AsValue().Get<ui32>(), 2); } - Y_UNIT_TEST(TestLiteralExists) { + Y_UNIT_TEST(TestLiteralExists) { auto functionRegistry = CreateFunctionRegistry(IBuiltinFunctionRegistry::TPtr()); TScopedAlloc alloc; TTypeEnvironment env(alloc); @@ -285,7 +285,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLLPOTest) { UNIT_ASSERT_EQUAL(static_cast<TDataLiteral&>(*pgm).AsValue().Get<bool>(), true); } - Y_UNIT_TEST(TestNth) { + Y_UNIT_TEST(TestNth) { auto functionRegistry = CreateFunctionRegistry(IBuiltinFunctionRegistry::TPtr()); TScopedAlloc alloc; TTypeEnvironment env(alloc); diff --git a/ydb/library/yql/minikql/mkql_program_builder.cpp b/ydb/library/yql/minikql/mkql_program_builder.cpp index 47ae6e4c8fc..cebfe5821e9 100644 --- a/ydb/library/yql/minikql/mkql_program_builder.cpp +++ b/ydb/library/yql/minikql/mkql_program_builder.cpp @@ -41,7 +41,7 @@ struct TDataFunctionFlags { #define MKQL_BAD_TYPE_VISIT(NodeType, ScriptName) \ void Visit(NodeType& node) override { \ - Y_UNUSED(node); \ + Y_UNUSED(node); \ MKQL_ENSURE(false, "Can't convert " #NodeType " to " ScriptName " object"); \ } @@ -386,7 +386,7 @@ TRuntimeNode TProgramBuilder::AddMember(TRuntimeNode structObj, const std::strin } } - Y_FAIL(); + Y_FAIL(); } TRuntimeNode TProgramBuilder::RemoveMember(TRuntimeNode structObj, const std::string_view& memberName, bool forced) { @@ -421,7 +421,7 @@ TRuntimeNode TProgramBuilder::RemoveMember(TRuntimeNode structObj, const std::st return TRuntimeNode(callableBuilder.Build(), false); } -TRuntimeNode TProgramBuilder::Zip(const TArrayRef<const TRuntimeNode>& lists) { +TRuntimeNode TProgramBuilder::Zip(const TArrayRef<const TRuntimeNode>& lists) { if (lists.empty()) { return NewEmptyList(Env.GetEmptyTuple()->GetGenericType()); } @@ -448,7 +448,7 @@ TRuntimeNode TProgramBuilder::Zip(const TArrayRef<const TRuntimeNode>& lists) { return TRuntimeNode(callableBuilder.Build(), false); } -TRuntimeNode TProgramBuilder::ZipAll(const TArrayRef<const TRuntimeNode>& lists) { +TRuntimeNode TProgramBuilder::ZipAll(const TArrayRef<const TRuntimeNode>& lists) { if (lists.empty()) { return NewEmptyList(Env.GetEmptyTuple()->GetGenericType()); } @@ -1278,7 +1278,7 @@ TRuntimeNode TProgramBuilder::Length(TRuntimeNode listOrDict) { return BuildContainerProperty<ui64>(__func__, listOrDict); } -TRuntimeNode TProgramBuilder::Iterator(TRuntimeNode list, const TArrayRef<const TRuntimeNode>& dependentNodes) { +TRuntimeNode TProgramBuilder::Iterator(TRuntimeNode list, const TArrayRef<const TRuntimeNode>& dependentNodes) { const auto streamType = NewStreamType(AS_TYPE(TListType, list.GetStaticType())->GetItemType()); TCallableBuilder callableBuilder(Env, __func__, streamType); callableBuilder.Add(list); @@ -1458,7 +1458,7 @@ TRuntimeNode TProgramBuilder::ListFromRange(TRuntimeNode start, TRuntimeNode end } TRuntimeNode TProgramBuilder::Switch(TRuntimeNode stream, - const TArrayRef<const TSwitchInput>& handlerInputs, + const TArrayRef<const TSwitchInput>& handlerInputs, std::function<TRuntimeNode(ui32 index, TRuntimeNode item)> handler, ui64 memoryLimitBytes, TType* returnType) { MKQL_ENSURE(stream.GetStaticType()->IsStream() || stream.GetStaticType()->IsFlow(), "Expected stream or flow."); @@ -1819,7 +1819,7 @@ TRuntimeNode TProgramBuilder::Extend(TRuntimeNode list1, TRuntimeNode list2) { return Extend(lists); } -TRuntimeNode TProgramBuilder::Extend(const TArrayRef<const TRuntimeNode>& lists) { +TRuntimeNode TProgramBuilder::Extend(const TArrayRef<const TRuntimeNode>& lists) { MKQL_ENSURE(lists.size() > 0, "Expected at least 1 list/stream"); if (lists.size() == 1) { return lists.front(); @@ -2001,7 +2001,7 @@ TRuntimeNode TProgramBuilder::NewEmptyList(TType* itemType) { return TRuntimeNode(builder.Build(), true); } -TRuntimeNode TProgramBuilder::NewList(TType* itemType, const TArrayRef<const TRuntimeNode>& items) { +TRuntimeNode TProgramBuilder::NewList(TType* itemType, const TArrayRef<const TRuntimeNode>& items) { TListLiteralBuilder builder(Env, itemType); for (auto item : items) { builder.Add(item); @@ -2050,7 +2050,7 @@ TType* TProgramBuilder::NewDictType(TType* keyType, TType* payloadType, bool mul return TDictType::Create(keyType, multi ? NewListType(payloadType) : payloadType, Env); } -TRuntimeNode TProgramBuilder::NewDict(TType* dictType, const TArrayRef<const std::pair<TRuntimeNode, TRuntimeNode>>& items) { +TRuntimeNode TProgramBuilder::NewDict(TType* dictType, const TArrayRef<const std::pair<TRuntimeNode, TRuntimeNode>>& items) { MKQL_ENSURE(dictType->IsDict(), "Expected dict type"); return TRuntimeNode(TDictLiteral::Create(items.size(), items.data(), static_cast<TDictType*>(dictType), Env), true); @@ -2064,7 +2064,7 @@ TType* TProgramBuilder::NewEmptyTupleType() { return Env.GetEmptyTuple()->GetGenericType(); } -TType* TProgramBuilder::NewTupleType(const TArrayRef<TType* const>& elements) { +TType* TProgramBuilder::NewTupleType(const TArrayRef<TType* const>& elements) { return TTupleType::Create(elements.size(), elements.data(), Env); } @@ -2072,13 +2072,13 @@ TType* TProgramBuilder::NewArrayType(const TArrayRef<TType* const>& elements) { return NewTupleType(elements); } -TRuntimeNode TProgramBuilder::NewTuple(TType* tupleType, const TArrayRef<const TRuntimeNode>& elements) { +TRuntimeNode TProgramBuilder::NewTuple(TType* tupleType, const TArrayRef<const TRuntimeNode>& elements) { MKQL_ENSURE(tupleType->IsTuple(), "Expected tuple type"); return TRuntimeNode(TTupleLiteral::Create(elements.size(), elements.data(), static_cast<TTupleType*>(tupleType), Env), true); } -TRuntimeNode TProgramBuilder::NewTuple(const TArrayRef<const TRuntimeNode>& elements) { +TRuntimeNode TProgramBuilder::NewTuple(const TArrayRef<const TRuntimeNode>& elements) { std::vector<TType*> types; types.reserve(elements.size()); for (auto elem : elements) { @@ -2721,7 +2721,7 @@ TRuntimeNode TProgramBuilder::AggrAdd(TRuntimeNode data1, TRuntimeNode data2) { return Invoke(TString("AggrAdd_") += ::ToString(decimalType->GetParams().first), data1.GetStaticType(), args); } -TRuntimeNode TProgramBuilder::QueueCreate(TRuntimeNode initCapacity, TRuntimeNode initSize, const TArrayRef<const TRuntimeNode>& dependentNodes, TType* returnType) { +TRuntimeNode TProgramBuilder::QueueCreate(TRuntimeNode initCapacity, TRuntimeNode initSize, const TArrayRef<const TRuntimeNode>& dependentNodes, TType* returnType) { auto resType = AS_TYPE(TResourceType, returnType); const auto tag = resType->GetTag(); @@ -2748,7 +2748,7 @@ TRuntimeNode TProgramBuilder::QueueCreate(TRuntimeNode initCapacity, TRuntimeNod TRuntimeNode TProgramBuilder::QueuePush(TRuntimeNode resource, TRuntimeNode value) { auto resType = AS_TYPE(TResourceType, resource); const auto tag = resType->GetTag(); - MKQL_ENSURE(tag.StartsWith(ResourceQueuePrefix), "Expected Queue resource"); + MKQL_ENSURE(tag.StartsWith(ResourceQueuePrefix), "Expected Queue resource"); TCallableBuilder callableBuilder(Env, __func__, resource.GetStaticType()); callableBuilder.Add(resource); callableBuilder.Add(value); @@ -2758,19 +2758,19 @@ TRuntimeNode TProgramBuilder::QueuePush(TRuntimeNode resource, TRuntimeNode valu TRuntimeNode TProgramBuilder::QueuePop(TRuntimeNode resource) { auto resType = AS_TYPE(TResourceType, resource); const auto tag = resType->GetTag(); - MKQL_ENSURE(tag.StartsWith(ResourceQueuePrefix), "Expected Queue resource"); + MKQL_ENSURE(tag.StartsWith(ResourceQueuePrefix), "Expected Queue resource"); TCallableBuilder callableBuilder(Env, __func__, resource.GetStaticType()); callableBuilder.Add(resource); return TRuntimeNode(callableBuilder.Build(), false); } -TRuntimeNode TProgramBuilder::QueuePeek(TRuntimeNode resource, TRuntimeNode index, const TArrayRef<const TRuntimeNode>& dependentNodes, TType* returnType) { +TRuntimeNode TProgramBuilder::QueuePeek(TRuntimeNode resource, TRuntimeNode index, const TArrayRef<const TRuntimeNode>& dependentNodes, TType* returnType) { MKQL_ENSURE(returnType->IsOptional(), "Expected optional type as result of QueuePeek"); auto resType = AS_TYPE(TResourceType, resource); auto indexType = AS_TYPE(TDataType, index); MKQL_ENSURE(indexType->GetSchemeType() == NUdf::TDataType<ui64>::Id, "index size must be ui64"); const auto tag = resType->GetTag(); - MKQL_ENSURE(tag.StartsWith(ResourceQueuePrefix), "Expected Queue resource"); + MKQL_ENSURE(tag.StartsWith(ResourceQueuePrefix), "Expected Queue resource"); TCallableBuilder callableBuilder(Env, __func__, returnType); callableBuilder.Add(resource); callableBuilder.Add(index); @@ -4000,7 +4000,7 @@ TRuntimeNode TProgramBuilder::InverseString(TRuntimeNode data) { return Invoke(__func__, NewDataType(NUdf::TDataType<char*>::Id), args); } -TRuntimeNode TProgramBuilder::Random(const TArrayRef<const TRuntimeNode>& dependentNodes) { +TRuntimeNode TProgramBuilder::Random(const TArrayRef<const TRuntimeNode>& dependentNodes) { TCallableBuilder callableBuilder(Env, __func__, NewDataType(NUdf::TDataType<double>::Id)); for (auto& x : dependentNodes) { callableBuilder.Add(x); @@ -4009,7 +4009,7 @@ TRuntimeNode TProgramBuilder::Random(const TArrayRef<const TRuntimeNode>& depend return TRuntimeNode(callableBuilder.Build(), false); } -TRuntimeNode TProgramBuilder::RandomNumber(const TArrayRef<const TRuntimeNode>& dependentNodes) { +TRuntimeNode TProgramBuilder::RandomNumber(const TArrayRef<const TRuntimeNode>& dependentNodes) { TCallableBuilder callableBuilder(Env, __func__, NewDataType(NUdf::TDataType<ui64>::Id)); for (auto& x : dependentNodes) { callableBuilder.Add(x); @@ -4162,7 +4162,7 @@ TRuntimeNode TProgramBuilder::AsList(TRuntimeNode item) { return TRuntimeNode(builder.Build(), true); } -TRuntimeNode TProgramBuilder::AsList(const TArrayRef<const TRuntimeNode>& items) { +TRuntimeNode TProgramBuilder::AsList(const TArrayRef<const TRuntimeNode>& items) { MKQL_ENSURE(!items.empty(), "required not empty list of items"); TListLiteralBuilder builder(Env, items[0].GetStaticType()); for (auto item : items) { diff --git a/ydb/library/yql/minikql/mkql_program_builder.h b/ydb/library/yql/minikql/mkql_program_builder.h index 10f1ad7ccf1..f113b358a74 100644 --- a/ydb/library/yql/minikql/mkql_program_builder.h +++ b/ydb/library/yql/minikql/mkql_program_builder.h @@ -171,10 +171,10 @@ public: TType* NewListType(TType* itemType); TRuntimeNode NewEmptyList(TType* itemType); TRuntimeNode NewEmptyListOfVoid(); - TRuntimeNode NewList(TType* itemType, const TArrayRef<const TRuntimeNode>& items); + TRuntimeNode NewList(TType* itemType, const TArrayRef<const TRuntimeNode>& items); TType* NewDictType(TType* keyType, TType* payloadType, bool multi); - TRuntimeNode NewDict(TType* dictType, const TArrayRef<const std::pair<TRuntimeNode, TRuntimeNode>>& items); + TRuntimeNode NewDict(TType* dictType, const TArrayRef<const std::pair<TRuntimeNode, TRuntimeNode>>& items); TType* NewStreamType(TType* itemType); TType* NewFlowType(TType* itemType); @@ -182,11 +182,11 @@ public: TType* NewBlockType(TType* itemType, TBlockType::EShape shape); TType* NewEmptyTupleType(); - TType* NewTupleType(const TArrayRef<TType* const>& elements); + TType* NewTupleType(const TArrayRef<TType* const>& elements); TType* NewArrayType(const TArrayRef<TType* const>& elements); TRuntimeNode NewEmptyTuple(); - TRuntimeNode NewTuple(TType* tupleType, const TArrayRef<const TRuntimeNode>& elements); - TRuntimeNode NewTuple(const TArrayRef<const TRuntimeNode>& elements); + TRuntimeNode NewTuple(TType* tupleType, const TArrayRef<const TRuntimeNode>& elements); + TRuntimeNode NewTuple(const TArrayRef<const TRuntimeNode>& elements); TType* NewResourceType(const std::string_view& tag); TType* NewVariantType(TType* underlyingType); TRuntimeNode NewVariant(TRuntimeNode item, ui32 tupleIndex, TType* variantType); @@ -213,11 +213,11 @@ public: TRuntimeNode FromBytes(TRuntimeNode data, NUdf::TDataTypeId schemeType); TRuntimeNode InversePresortString(TRuntimeNode data); TRuntimeNode InverseString(TRuntimeNode data); - TRuntimeNode Random(const TArrayRef<const TRuntimeNode>& dependentNodes); - TRuntimeNode RandomNumber(const TArrayRef<const TRuntimeNode>& dependentNodes); + TRuntimeNode Random(const TArrayRef<const TRuntimeNode>& dependentNodes); + TRuntimeNode RandomNumber(const TArrayRef<const TRuntimeNode>& dependentNodes); TRuntimeNode RandomUuid(const TArrayRef<const TRuntimeNode>& dependentNodes); - TRuntimeNode Now(const TArrayRef<const TRuntimeNode>& dependentNodes); + TRuntimeNode Now(const TArrayRef<const TRuntimeNode>& dependentNodes); TRuntimeNode CurrentUtcDate(const TArrayRef<const TRuntimeNode>& dependentNodes); TRuntimeNode CurrentUtcDatetime(const TArrayRef<const TRuntimeNode>& dependentNodes); TRuntimeNode CurrentUtcTimestamp(const TArrayRef<const TRuntimeNode>& dependentNodes); @@ -294,11 +294,11 @@ public: TRuntimeNode Append(TRuntimeNode list, TRuntimeNode item); TRuntimeNode Prepend(TRuntimeNode item, TRuntimeNode list); TRuntimeNode Extend(TRuntimeNode list1, TRuntimeNode list2); - TRuntimeNode Extend(const TArrayRef<const TRuntimeNode>& lists); + TRuntimeNode Extend(const TArrayRef<const TRuntimeNode>& lists); // returns list of tuples with items, stops at the shortest list - TRuntimeNode Zip(const TArrayRef<const TRuntimeNode>& lists); + TRuntimeNode Zip(const TArrayRef<const TRuntimeNode>& lists); // returns list of tuples with optional of items, has length of the longest list - TRuntimeNode ZipAll(const TArrayRef<const TRuntimeNode>& lists); + TRuntimeNode ZipAll(const TArrayRef<const TRuntimeNode>& lists); TRuntimeNode Enumerate(TRuntimeNode list); TRuntimeNode Enumerate(TRuntimeNode list, TRuntimeNode start, TRuntimeNode step); TRuntimeNode Fold(TRuntimeNode list, TRuntimeNode state, const TBinaryLambda& handler); @@ -373,14 +373,14 @@ public: TRuntimeNode WideCondense1(TRuntimeNode stream, const TWideLambda& init, const TWideSwitchLambda& switcher, const TBinaryWideLambda& handler); TRuntimeNode Length(TRuntimeNode listOrDict); - TRuntimeNode Iterator(TRuntimeNode list, const TArrayRef<const TRuntimeNode>& dependentNodes); + TRuntimeNode Iterator(TRuntimeNode list, const TArrayRef<const TRuntimeNode>& dependentNodes); TRuntimeNode EmptyIterator(TType* streamType); TRuntimeNode Collect(TRuntimeNode listOrStream); TRuntimeNode LazyList(TRuntimeNode list); TRuntimeNode ListFromRange(TRuntimeNode start, TRuntimeNode end, TRuntimeNode step); TRuntimeNode ForwardList(TRuntimeNode stream); TRuntimeNode Switch(TRuntimeNode stream, - const TArrayRef<const TSwitchInput>& handlerInputs, + const TArrayRef<const TSwitchInput>& handlerInputs, std::function<TRuntimeNode(ui32 index, TRuntimeNode item)> handler, ui64 memoryLimitBytes, TType* returnType); TRuntimeNode HasItems(TRuntimeNode listOrDict); @@ -396,7 +396,7 @@ public: TRuntimeNode ListIf(TRuntimeNode predicate, TRuntimeNode item); TRuntimeNode AsList(TRuntimeNode item); - TRuntimeNode AsList(const TArrayRef<const TRuntimeNode>& items); + TRuntimeNode AsList(const TArrayRef<const TRuntimeNode>& items); TRuntimeNode MapJoinCore(TRuntimeNode flow, TRuntimeNode dict, EJoinKind joinKind, const TArrayRef<const ui32>& leftKeyColumns, const TArrayRef<const ui32>& leftRenames, const TArrayRef<const ui32>& rightRenames, TType* returnType); @@ -580,10 +580,10 @@ public: TRuntimeNode AggrAdd(TRuntimeNode data1, TRuntimeNode data2); //-- queue functions - TRuntimeNode QueueCreate(TRuntimeNode initCapacity, TRuntimeNode initCreate, const TArrayRef<const TRuntimeNode>& dependentNodes, TType* returnType); + TRuntimeNode QueueCreate(TRuntimeNode initCapacity, TRuntimeNode initCreate, const TArrayRef<const TRuntimeNode>& dependentNodes, TType* returnType); TRuntimeNode QueuePush(TRuntimeNode resource, TRuntimeNode value); TRuntimeNode QueuePop(TRuntimeNode resource); - TRuntimeNode QueuePeek(TRuntimeNode resource, TRuntimeNode index, const TArrayRef<const TRuntimeNode>& dependentNodes, TType* returnType); + TRuntimeNode QueuePeek(TRuntimeNode resource, TRuntimeNode index, const TArrayRef<const TRuntimeNode>& dependentNodes, TType* returnType); TRuntimeNode QueueRange(TRuntimeNode resource, TRuntimeNode begin, TRuntimeNode end, const TArrayRef<const TRuntimeNode>& dependentNodes, TType* returnType); TRuntimeNode PreserveStream(TRuntimeNode stream, TRuntimeNode preserve, TRuntimeNode outpace); diff --git a/ydb/library/yql/minikql/mkql_stats_registry_ut.cpp b/ydb/library/yql/minikql/mkql_stats_registry_ut.cpp index 0504fb2986b..8040b196d3d 100644 --- a/ydb/library/yql/minikql/mkql_stats_registry_ut.cpp +++ b/ydb/library/yql/minikql/mkql_stats_registry_ut.cpp @@ -6,9 +6,9 @@ using namespace NKikimr; using namespace NMiniKQL; -Y_UNIT_TEST_SUITE(TStatsRegistryTest) { +Y_UNIT_TEST_SUITE(TStatsRegistryTest) { - Y_UNIT_TEST(Stats) { + Y_UNIT_TEST(Stats) { static TStatKey key("key", false); auto stats = CreateDefaultStatsRegistry(); @@ -37,7 +37,7 @@ Y_UNIT_TEST_SUITE(TStatsRegistryTest) { UNIT_ASSERT_EQUAL(stats->GetStat(key), 34); } - Y_UNIT_TEST(ForEach) { + Y_UNIT_TEST(ForEach) { static TStatKey key1("key1", false), key2("key2", true); UNIT_ASSERT(!key1.IsDeriv()); UNIT_ASSERT(key2.IsDeriv()); @@ -58,7 +58,7 @@ Y_UNIT_TEST_SUITE(TStatsRegistryTest) { }); } - Y_UNIT_TEST(DuplicateKeys) { + Y_UNIT_TEST(DuplicateKeys) { TString error; try { static TStatKey key("my_key", false), sameKey("my_key", false); diff --git a/ydb/library/yql/minikql/mkql_type_builder.cpp b/ydb/library/yql/minikql/mkql_type_builder.cpp index 4aecb564bf7..507f80d4b63 100644 --- a/ydb/library/yql/minikql/mkql_type_builder.cpp +++ b/ydb/library/yql/minikql/mkql_type_builder.cpp @@ -526,7 +526,7 @@ public: } NUdf::TType* Build() const override { - Y_VERIFY(ReturnType_, "callable returns type is not configured"); + Y_VERIFY(ReturnType_, "callable returns type is not configured"); NMiniKQL::TNode* payload = nullptr; diff --git a/ydb/library/yql/minikql/mkql_type_ops_ut.cpp b/ydb/library/yql/minikql/mkql_type_ops_ut.cpp index 01828a9a525..dac61ffb378 100644 --- a/ydb/library/yql/minikql/mkql_type_ops_ut.cpp +++ b/ydb/library/yql/minikql/mkql_type_ops_ut.cpp @@ -10,8 +10,8 @@ using namespace NYql; using namespace NKikimr; using namespace NKikimr::NMiniKQL; -Y_UNIT_TEST_SUITE(TMiniKQLTypeOps) { - Y_UNIT_TEST(DateInOut) { +Y_UNIT_TEST_SUITE(TMiniKQLTypeOps) { + Y_UNIT_TEST(DateInOut) { ui32 year = 1970; ui32 month = 1; ui32 day = 1; diff --git a/ydb/library/yql/minikql/mkql_unboxed_value_stream.h b/ydb/library/yql/minikql/mkql_unboxed_value_stream.h index 43005db571d..1aabe0bf2b5 100644 --- a/ydb/library/yql/minikql/mkql_unboxed_value_stream.h +++ b/ydb/library/yql/minikql/mkql_unboxed_value_stream.h @@ -4,7 +4,7 @@ namespace NKikimr { namespace NMiniKQL { -struct TUnboxedValueStream : public IOutputStream { +struct TUnboxedValueStream : public IOutputStream { NUdf::TUnboxedValue Value_; TUnboxedValueStream(); diff --git a/ydb/library/yql/minikql/pack_num_ut.cpp b/ydb/library/yql/minikql/pack_num_ut.cpp index bfc9c793095..a98b6d12e0b 100644 --- a/ydb/library/yql/minikql/pack_num_ut.cpp +++ b/ydb/library/yql/minikql/pack_num_ut.cpp @@ -4,7 +4,7 @@ #include <util/generic/ylimits.h> -Y_UNIT_TEST_SUITE(TPackNumTest) { +Y_UNIT_TEST_SUITE(TPackNumTest) { static ui32 TEST_DATA_UI32[] = { 0, 0x80, @@ -35,7 +35,7 @@ Y_UNIT_TEST_SUITE(TPackNumTest) { static size_t DELTA = 10; - Y_UNIT_TEST(PackUnpack32) { + Y_UNIT_TEST(PackUnpack32) { char buf[10]; for (ui32 num: TEST_DATA_UI32) { for (ui32 i = num - Min<ui32>(num, DELTA); i < num + Min<ui32>(DELTA, Max<ui32>() - num); ++i) { @@ -51,7 +51,7 @@ Y_UNIT_TEST_SUITE(TPackNumTest) { } } - Y_UNIT_TEST(PackUnpack64) { + Y_UNIT_TEST(PackUnpack64) { char buf[10]; for (ui64 num: TEST_DATA_UI64) { for (ui64 i = num - Min<ui64>(num, DELTA); i < num + Min<ui64>(DELTA, Max<ui64>() - num); ++i) { diff --git a/ydb/library/yql/parser/proto_ast/proto_ast.cpp b/ydb/library/yql/parser/proto_ast/proto_ast.cpp index 097ba08c854..1a0a3f0bbd4 100644 --- a/ydb/library/yql/parser/proto_ast/proto_ast.cpp +++ b/ydb/library/yql/parser/proto_ast/proto_ast.cpp @@ -26,7 +26,7 @@ void IErrorCollector::Error(ui32 line, ui32 col, const TString& message) { ++NumErrors; } -TErrorOutput::TErrorOutput(IOutputStream& err, const TString& name, size_t maxErrors) +TErrorOutput::TErrorOutput(IOutputStream& err, const TString& name, size_t maxErrors) : IErrorCollector(maxErrors) , Err(err) , Name(name) diff --git a/ydb/library/yql/parser/proto_ast/proto_ast.h b/ydb/library/yql/parser/proto_ast/proto_ast.h index 5bb8a9f5f9c..b9644fe7592 100644 --- a/ydb/library/yql/parser/proto_ast/proto_ast.h +++ b/ydb/library/yql/parser/proto_ast/proto_ast.h @@ -11,7 +11,7 @@ namespace NProtoAST { template <typename InputType> - void InvalidCharacter(IOutputStream& err, const InputType* input) { + void InvalidCharacter(IOutputStream& err, const InputType* input) { wchar32 rune = 0; size_t runeLen = 0; auto begin = input->get_nextChar(); @@ -22,7 +22,7 @@ namespace NProtoAST { } template <typename TokenType> - void InvalidToken(IOutputStream& err, const TokenType* token) { + void InvalidToken(IOutputStream& err, const TokenType* token) { if (token) { if (token->get_input()) { err << " '" << token->getText() << "'"; @@ -53,14 +53,14 @@ namespace NProtoAST { class TErrorOutput: public IErrorCollector { public: - TErrorOutput(IOutputStream& err, const TString& name, size_t maxErrors); + TErrorOutput(IOutputStream& err, const TString& name, size_t maxErrors); virtual ~TErrorOutput(); private: void AddError(ui32 line, ui32 col, const TString& message) override; public: - IOutputStream& Err; + IOutputStream& Err; TString Name; }; diff --git a/ydb/library/yql/providers/common/codec/yql_codec.h b/ydb/library/yql/providers/common/codec/yql_codec.h index 512e01224c4..ac824d4f3a9 100644 --- a/ydb/library/yql/providers/common/codec/yql_codec.h +++ b/ydb/library/yql/providers/common/codec/yql_codec.h @@ -10,7 +10,7 @@ #include <util/generic/strbuf.h> #include <util/generic/maybe.h> -#include <util/stream/output.h> +#include <util/stream/output.h> #include <library/cpp/yson/public.h> diff --git a/ydb/library/yql/providers/common/provider/yql_table_lookup.cpp b/ydb/library/yql/providers/common/provider/yql_table_lookup.cpp index 93b84f6db00..11696a0e176 100644 --- a/ydb/library/yql/providers/common/provider/yql_table_lookup.cpp +++ b/ydb/library/yql/providers/common/provider/yql_table_lookup.cpp @@ -894,7 +894,7 @@ TKeyRange::TKeyRange(TExprContext& ctx, const TVector<TColumnRange>& columnRange ToTuple = TKeyTuple(Ctx, toValues, false, toInclusive); } -void TTableLookup::Print(IOutputStream& output) const { +void TTableLookup::Print(IOutputStream& output) const { output << Endl << "[" << Endl; for (auto& keyRange : KeyRanges) { keyRange.Print(output); @@ -902,7 +902,7 @@ void TTableLookup::Print(IOutputStream& output) const { output << "]" << Endl; } -void TKeyRange::Print(IOutputStream& output) const { +void TKeyRange::Print(IOutputStream& output) const { auto printExpr = [ctx = Ctx] (TExprBase node, IOutputStream& output) { auto ast = ConvertToAst(node.Ref(), *ctx, TExprAnnotationFlags::None, true); ast.Root->PrintTo(output); @@ -959,7 +959,7 @@ void TKeyRange::Print(IOutputStream& output) const { output << Endl << "}" << Endl; } -void TKeyTuple::Print(IOutputStream& output) const { +void TKeyTuple::Print(IOutputStream& output) const { auto printExpr = [] (TExprContext& ctx, TExprBase node, IOutputStream& output) { auto ast = ConvertToAst(node.Ref(), ctx, TExprAnnotationFlags::None, true); ast.Root->PrintTo(output); diff --git a/ydb/library/yql/providers/common/provider/yql_table_lookup.h b/ydb/library/yql/providers/common/provider/yql_table_lookup.h index 988fb5b4baa..9b32faaae19 100644 --- a/ydb/library/yql/providers/common/provider/yql_table_lookup.h +++ b/ydb/library/yql/providers/common/provider/yql_table_lookup.h @@ -111,7 +111,7 @@ public: bool IsInclusive() const { return Inclusive; } NNodes::TMaybeNode<NNodes::TExprBase> GetValue(size_t index) const { return Values[index]; } - void Print(IOutputStream& output) const; + void Print(IOutputStream& output) const; private: TExprContext* Ctx; @@ -167,7 +167,7 @@ public: return ToTuple; } - void Print(IOutputStream& output) const; + void Print(IOutputStream& output) const; private: TExprContext* Ctx; @@ -226,7 +226,7 @@ public: return IsSingleRange() && KeyRanges.front().IsFullScan(); } - void Print(IOutputStream& output) const; + void Print(IOutputStream& output) const; private: TVector<TString> KeyColumns; diff --git a/ydb/library/yql/providers/common/schema/mkql/yql_mkql_schema.cpp b/ydb/library/yql/providers/common/schema/mkql/yql_mkql_schema.cpp index 0a341057146..097a5a95a7f 100644 --- a/ydb/library/yql/providers/common/schema/mkql/yql_mkql_schema.cpp +++ b/ydb/library/yql/providers/common/schema/mkql/yql_mkql_schema.cpp @@ -166,9 +166,9 @@ struct TRuntimeTypeLoader { typedef NKikimr::NMiniKQL::TType* TType; NKikimr::NMiniKQL::TProgramBuilder& Builder; - IOutputStream& Err; + IOutputStream& Err; - TRuntimeTypeLoader(NKikimr::NMiniKQL::TProgramBuilder& builder, IOutputStream& err) + TRuntimeTypeLoader(NKikimr::NMiniKQL::TProgramBuilder& builder, IOutputStream& err) : Builder(builder) , Err(err) { @@ -302,7 +302,7 @@ NKikimr::NMiniKQL::TType* ParseTypeFromYson(const TStringBuf yson, NKikimr::NMin return DoLoadTypeFromYson(loader, node, 0).GetOrElse(nullptr); } -NKikimr::NMiniKQL::TType* ParseTypeFromYson(const NYT::TNode& node, NKikimr::NMiniKQL::TProgramBuilder& builder, IOutputStream& err) { +NKikimr::NMiniKQL::TType* ParseTypeFromYson(const NYT::TNode& node, NKikimr::NMiniKQL::TProgramBuilder& builder, IOutputStream& err) { TRuntimeTypeLoader loader(builder, err); return DoLoadTypeFromYson(loader, node, 0).GetOrElse(nullptr); } diff --git a/ydb/library/yql/providers/common/schema/mkql/yql_mkql_schema.h b/ydb/library/yql/providers/common/schema/mkql/yql_mkql_schema.h index 9a21a1f3889..634537fc8cd 100644 --- a/ydb/library/yql/providers/common/schema/mkql/yql_mkql_schema.h +++ b/ydb/library/yql/providers/common/schema/mkql/yql_mkql_schema.h @@ -28,7 +28,7 @@ NYT::TNode TypeToYsonNode(const NKikimr::NMiniKQL::TType* type); TString WriteTypeToYson(const NKikimr::NMiniKQL::TType* type, NYT::NYson::EYsonFormat format = NYT::NYson::EYsonFormat::Binary); NKikimr::NMiniKQL::TType* ParseTypeFromYson(const TStringBuf yson, NKikimr::NMiniKQL::TProgramBuilder& builder, IOutputStream& err); -NKikimr::NMiniKQL::TType* ParseTypeFromYson(const NYT::TNode& node, NKikimr::NMiniKQL::TProgramBuilder& builder, IOutputStream& err); +NKikimr::NMiniKQL::TType* ParseTypeFromYson(const NYT::TNode& node, NKikimr::NMiniKQL::TProgramBuilder& builder, IOutputStream& err); NKikimr::NMiniKQL::TType* ParseOrderAwareTypeFromYson(const NYT::TNode& node, TCodecContext& ctx, IOutputStream& err); } // namespace NCommon diff --git a/ydb/library/yql/providers/config/yql_config_provider.cpp b/ydb/library/yql/providers/config/yql_config_provider.cpp index 6952e96cf07..d05f6389528 100644 --- a/ydb/library/yql/providers/config/yql_config_provider.cpp +++ b/ydb/library/yql/providers/config/yql_config_provider.cpp @@ -407,7 +407,7 @@ namespace { } TString GetProviderPath(const TExprNode& node) override { - Y_UNUSED(node); + Y_UNUSED(node); return "config"; } diff --git a/ydb/library/yql/providers/result/provider/yql_result_provider.cpp b/ydb/library/yql/providers/result/provider/yql_result_provider.cpp index 13bfd5e0f74..58044adb1ec 100644 --- a/ydb/library/yql/providers/result/provider/yql_result_provider.cpp +++ b/ydb/library/yql/providers/result/provider/yql_result_provider.cpp @@ -250,7 +250,7 @@ namespace { } NThreading::TFuture<void> DoGetAsyncFuture(const TExprNode& input) final { - Y_UNUSED(input); + Y_UNUSED(input); return DelegatedProvider->GetCallableExecutionTransformer() .GetAsyncFuture(*DelegatedNode); } @@ -1423,7 +1423,7 @@ namespace { } TString GetProviderPath(const TExprNode& node) override { - Y_UNUSED(node); + Y_UNUSED(node); return "result"; } diff --git a/ydb/library/yql/public/issue/yql_issue.cpp b/ydb/library/yql/public/issue/yql_issue.cpp index 3b89156874b..15aa3da272a 100644 --- a/ydb/library/yql/public/issue/yql_issue.cpp +++ b/ydb/library/yql/public/issue/yql_issue.cpp @@ -105,7 +105,7 @@ void WalkThroughIssues(const TIssue& topIssue, bool leafOnly, std::function<void namespace { -Y_NO_INLINE void Indent(IOutputStream& out, ui32 indentation) { +Y_NO_INLINE void Indent(IOutputStream& out, ui32 indentation) { char* whitespaces = reinterpret_cast<char*>(alloca(indentation)); memset(whitespaces, ' ', indentation); out.Write(whitespaces, indentation); @@ -179,7 +179,7 @@ void TIssues::PrintTo(IOutputStream& out, bool oneLine) const } void TIssues::PrintWithProgramTo( - IOutputStream& out, + IOutputStream& out, const TString& programFilename, const TString& programText) const { @@ -265,7 +265,7 @@ TMaybe<TPosition> TryParseTerminationMessage(TStringBuf& message) { } // namspace NYql template <> -void Out<NYql::TPosition>(IOutputStream& out, const NYql::TPosition& pos) { +void Out<NYql::TPosition>(IOutputStream& out, const NYql::TPosition& pos) { out << (pos.File ? pos.File : "<main>"); if (pos) { out << ":" << pos.Row << ':' << pos.Column; @@ -273,7 +273,7 @@ void Out<NYql::TPosition>(IOutputStream& out, const NYql::TPosition& pos) { } template<> -void Out<NYql::TRange>(IOutputStream & out, const NYql::TRange & range) { +void Out<NYql::TRange>(IOutputStream & out, const NYql::TRange & range) { if (range.IsRange()) { out << '[' << range.Position << '-' << range.EndPosition << ']'; } else { @@ -282,6 +282,6 @@ void Out<NYql::TRange>(IOutputStream & out, const NYql::TRange & range) { } template <> -void Out<NYql::TIssue>(IOutputStream& out, const NYql::TIssue& error) { +void Out<NYql::TIssue>(IOutputStream& out, const NYql::TIssue& error) { error.PrintTo(out); } diff --git a/ydb/library/yql/public/issue/yql_issue.h b/ydb/library/yql/public/issue/yql_issue.h index 7b97674c9df..840ccc8b468 100644 --- a/ydb/library/yql/public/issue/yql_issue.h +++ b/ydb/library/yql/public/issue/yql_issue.h @@ -280,7 +280,7 @@ public: void PrintTo(IOutputStream& out, bool oneLine = false) const; void PrintWithProgramTo( - IOutputStream& out, + IOutputStream& out, const TString& programFilename, const TString& programText) const; @@ -323,13 +323,13 @@ TMaybe<TPosition> TryParseTerminationMessage(TStringBuf& message); } // namespace NYql template <> -void Out<NYql::TPosition>(IOutputStream& out, const NYql::TPosition& pos); +void Out<NYql::TPosition>(IOutputStream& out, const NYql::TPosition& pos); template <> -void Out<NYql::TRange>(IOutputStream& out, const NYql::TRange& pos); +void Out<NYql::TRange>(IOutputStream& out, const NYql::TRange& pos); template <> -void Out<NYql::TIssue>(IOutputStream& out, const NYql::TIssue& error); +void Out<NYql::TIssue>(IOutputStream& out, const NYql::TIssue& error); template <> struct THash<NYql::TIssue> { diff --git a/ydb/library/yql/public/issue/yql_issue_manager_ut.cpp b/ydb/library/yql/public/issue/yql_issue_manager_ut.cpp index 287f63fedd6..81fa25aba62 100644 --- a/ydb/library/yql/public/issue/yql_issue_manager_ut.cpp +++ b/ydb/library/yql/public/issue/yql_issue_manager_ut.cpp @@ -10,8 +10,8 @@ static std::function<TIssuePtr()> CreateScopeIssueFunction(TString name, ui32 co }; } -Y_UNIT_TEST_SUITE(TIssueManagerTest) { - Y_UNIT_TEST(NoErrorNoLevelTest) { +Y_UNIT_TEST_SUITE(TIssueManagerTest) { + Y_UNIT_TEST(NoErrorNoLevelTest) { TIssueManager issueManager; auto completedIssues = issueManager.GetCompletedIssues(); UNIT_ASSERT_VALUES_EQUAL(completedIssues.Size(), 0); @@ -19,7 +19,7 @@ Y_UNIT_TEST_SUITE(TIssueManagerTest) { UNIT_ASSERT_VALUES_EQUAL(issues.Size(), 0); } - Y_UNIT_TEST(NoErrorOneLevelTest) { + Y_UNIT_TEST(NoErrorOneLevelTest) { TIssueManager issueManager; issueManager.AddScope(CreateScopeIssueFunction("A", 0, 0)); auto completedIssues = issueManager.GetCompletedIssues(); @@ -29,7 +29,7 @@ Y_UNIT_TEST_SUITE(TIssueManagerTest) { UNIT_ASSERT_VALUES_EQUAL(issues.Size(), 0); } - Y_UNIT_TEST(NoErrorTwoLevelsTest) { + Y_UNIT_TEST(NoErrorTwoLevelsTest) { TIssueManager issueManager; issueManager.AddScope(CreateScopeIssueFunction("A", 0, 0)); issueManager.AddScope(CreateScopeIssueFunction("B", 1, 1)); @@ -41,7 +41,7 @@ Y_UNIT_TEST_SUITE(TIssueManagerTest) { UNIT_ASSERT_VALUES_EQUAL(issues.Size(), 0); } - Y_UNIT_TEST(OneErrorOneLevelTest) { + Y_UNIT_TEST(OneErrorOneLevelTest) { TIssueManager issueManager; issueManager.AddScope(CreateScopeIssueFunction("A", 0, 0)); auto completedIssues1 = issueManager.GetCompletedIssues(); @@ -62,7 +62,7 @@ Y_UNIT_TEST_SUITE(TIssueManagerTest) { UNIT_ASSERT_VALUES_EQUAL(subIssues[0]->Message, "IssueOne"); } - Y_UNIT_TEST(OneErrorTwoLevelsTest) { + Y_UNIT_TEST(OneErrorTwoLevelsTest) { TIssueManager issueManager; issueManager.AddScope(CreateScopeIssueFunction("A", 0, 0)); issueManager.AddScope(CreateScopeIssueFunction("B", 1, 1)); @@ -81,7 +81,7 @@ Y_UNIT_TEST_SUITE(TIssueManagerTest) { UNIT_ASSERT_VALUES_EQUAL(subIssues[0]->GetSubIssues()[0]->Message, "IssueOne"); } - Y_UNIT_TEST(MultiErrorsMultiLevelsTest) { + Y_UNIT_TEST(MultiErrorsMultiLevelsTest) { TIssueManager issueManager; issueManager.AddScope(CreateScopeIssueFunction("A", 0, 0)); issueManager.RaiseIssue(TIssue(TPosition(), "WarningScope1")); @@ -113,7 +113,7 @@ Y_UNIT_TEST_SUITE(TIssueManagerTest) { UNIT_ASSERT_VALUES_EQUAL(issues.ToString(), ref); } - Y_UNIT_TEST(TIssueScopeGuardSimpleTest) { + Y_UNIT_TEST(TIssueScopeGuardSimpleTest) { TIssueManager issueManager; { TIssueScopeGuard guard(issueManager, CreateScopeIssueFunction("A", 0, 0)); diff --git a/ydb/library/yql/public/udf/udf_helpers.h b/ydb/library/yql/public/udf/udf_helpers.h index 2be9443559b..4a2daddfd25 100644 --- a/ydb/library/yql/public/udf/udf_helpers.h +++ b/ydb/library/yql/public/udf/udf_helpers.h @@ -44,7 +44,7 @@ namespace NUdf { #define UDF_IMPL_EX(udfName, typeBody, members, init, irResourceId, irFunctionName, create_impl) \ class udfName: public ::NYql::NUdf::TBoxedValue { \ - public: \ + public: \ explicit udfName(::NYql::NUdf::IFunctionTypeInfoBuilder& builder) \ : Pos_(GetSourcePosition(builder)) \ { \ @@ -52,44 +52,44 @@ namespace NUdf { } \ static const ::NYql::NUdf::TStringRef& Name() { \ static auto name = ::NYql::NUdf::TStringRef::Of(#udfName).Substring(1, 256); \ - return name; \ - } \ + return name; \ + } \ inline ::NYql::NUdf::TUnboxedValue RunImpl( \ const ::NYql::NUdf::IValueBuilder* valueBuilder, \ const ::NYql::NUdf::TUnboxedValuePod* args) const; \ ::NYql::NUdf::TUnboxedValue Run( \ const ::NYql::NUdf::IValueBuilder* valueBuilder, \ const ::NYql::NUdf::TUnboxedValuePod* args) const override { \ - try { \ - return RunImpl(valueBuilder, args); \ + try { \ + return RunImpl(valueBuilder, args); \ } catch (const std::exception&) { \ TStringBuilder sb; \ sb << Pos_ << " "; \ sb << CurrentExceptionMessage(); \ sb << Endl << "[" << TStringBuf(Name()) << "]" ; \ UdfTerminate(sb.c_str()); \ - } \ - } \ - static bool DeclareSignature( \ + } \ + } \ + static bool DeclareSignature( \ const ::NYql::NUdf::TStringRef& name, \ ::NYql::NUdf::TType* userType, \ ::NYql::NUdf::IFunctionTypeInfoBuilder& builder, \ - bool typesOnly) { \ - Y_UNUSED(userType); \ - if (Name() == name) { \ - typeBody if (!typesOnly) { \ + bool typesOnly) { \ + Y_UNUSED(userType); \ + if (Name() == name) { \ + typeBody if (!typesOnly) { \ create_impl \ SetIRImplementation(builder, irResourceId, irFunctionName); \ - } \ - return true; \ - } else { \ - return false; \ - } \ - } \ + } \ + return true; \ + } else { \ + return false; \ + } \ + } \ private: \ ::NYql::NUdf::TSourcePosition Pos_; \ members \ - }; \ + }; \ ::NYql::NUdf::TUnboxedValue udfName::RunImpl( \ const ::NYql::NUdf::IValueBuilder* valueBuilder, \ const ::NYql::NUdf::TUnboxedValuePod* args) const @@ -105,7 +105,7 @@ namespace NUdf { }; \ \ class udfName: public ::NYql::NUdf::TBoxedValue, public udfName##Members { \ - public: \ + public: \ explicit udfName(::NYql::NUdf::IFunctionTypeInfoBuilder& builder) \ : Pos_(GetSourcePosition(builder)) \ { \ @@ -113,10 +113,10 @@ namespace NUdf { } \ static const ::NYql::NUdf::TStringRef& Name() { \ static auto name = ::NYql::NUdf::TStringRef::Of(#udfName).Substring(1, 256); \ - return name; \ - } \ + return name; \ + } \ class TImpl: public TBoxedValue, public udfName##Members { \ - public: \ + public: \ TImpl(const udfName##Members& parent, \ const ::NYql::NUdf::TUnboxedValuePod& runConfig, \ ::NYql::NUdf::TSourcePosition pos) \ @@ -130,54 +130,54 @@ namespace NUdf { ::NYql::NUdf::TUnboxedValue Run( \ const ::NYql::NUdf::IValueBuilder* valueBuilder, \ const ::NYql::NUdf::TUnboxedValuePod* args) const override { \ - try { \ - return RunImpl(valueBuilder, args); \ + try { \ + return RunImpl(valueBuilder, args); \ } catch (const std::exception&) { \ TStringBuilder sb; \ sb << Pos_ << " "; \ sb << CurrentExceptionMessage(); \ sb << Endl << "[" << TStringBuf(Name()) << "]" ; \ UdfTerminate(sb.c_str()); \ - } \ - } \ - \ - private: \ + } \ + } \ + \ + private: \ ::NYql::NUdf::TUnboxedValue RunConfig; \ ::NYql::NUdf::TSourcePosition Pos_; \ - }; \ + }; \ ::NYql::NUdf::TUnboxedValue Run( \ const ::NYql::NUdf::IValueBuilder* valueBuilder, \ const ::NYql::NUdf::TUnboxedValuePod* args) const override { \ - Y_UNUSED(valueBuilder); \ + Y_UNUSED(valueBuilder); \ return ::NYql::NUdf::TUnboxedValuePod(new TImpl(*this, args[0], Pos_)); \ - } \ - static bool DeclareSignature( \ + } \ + static bool DeclareSignature( \ const ::NYql::NUdf::TStringRef& name, \ ::NYql::NUdf::TType* userType, \ ::NYql::NUdf::IFunctionTypeInfoBuilder& builder, \ - bool typesOnly) { \ - Y_UNUSED(userType); \ - if (Name() == name) { \ - typeBody if (!typesOnly) { \ + bool typesOnly) { \ + Y_UNUSED(userType); \ + if (Name() == name) { \ + typeBody if (!typesOnly) { \ builder.Implementation(new udfName(builder)); \ SetIRImplementation(builder, irResourceId, irFunctionName); \ - } \ - return true; \ - } else { \ - return false; \ - } \ - } \ + } \ + return true; \ + } else { \ + return false; \ + } \ + } \ private: \ ::NYql::NUdf::TSourcePosition Pos_; \ - }; \ + }; \ ::NYql::NUdf::TUnboxedValue udfName::TImpl::RunImpl( \ const ::NYql::NUdf::IValueBuilder* valueBuilder, \ const ::NYql::NUdf::TUnboxedValuePod* args) const #define UDF_RUN(udfName, typeBody) UDF_RUN_IMPL(udfName, typeBody, ;, ;, "", "") -#define SIMPLE_UDF(udfName, signature) \ - UDF(udfName, builder.SimpleSignature<signature>();) +#define SIMPLE_UDF(udfName, signature) \ + UDF(udfName, builder.SimpleSignature<signature>();) #define SIMPLE_UDF_WITH_IR(udfName, signature, irResourceId, irFunctionName) \ UDF_IMPL(udfName, builder.SimpleSignature<signature>();, ;, ;, irResourceId, irFunctionName) @@ -185,28 +185,28 @@ namespace NUdf { #define SIMPLE_UDF_WITH_CREATE_IMPL(udfName, signature, create_impl) \ UDF_IMPL_EX(udfName, builder.SimpleSignature<signature>();, ;, ;, "", "", create_impl) -#define SIMPLE_UDF_OPTIONS(udfName, signature, options) \ - UDF(udfName, builder.SimpleSignature<signature>(); options;) +#define SIMPLE_UDF_OPTIONS(udfName, signature, options) \ + UDF(udfName, builder.SimpleSignature<signature>(); options;) -#define SIMPLE_UDF_RUN_OPTIONS(udfName, signature, options) \ - UDF_RUN(udfName, builder.SimpleSignature<signature>(); options;) +#define SIMPLE_UDF_RUN_OPTIONS(udfName, signature, options) \ + UDF_RUN(udfName, builder.SimpleSignature<signature>(); options;) -#define SIMPLE_UDF_RUN(udfName, signature, runConfigSignature) \ - SIMPLE_UDF_RUN_OPTIONS(udfName, signature, builder.RunConfig<runConfigSignature>()) +#define SIMPLE_UDF_RUN(udfName, signature, runConfigSignature) \ + SIMPLE_UDF_RUN_OPTIONS(udfName, signature, builder.RunConfig<runConfigSignature>()) -#define SIMPLE_MODULE(moduleName, ...) \ +#define SIMPLE_MODULE(moduleName, ...) \ class moduleName: public ::NYql::NUdf::TSimpleUdfModuleHelper<__VA_ARGS__> { \ - public: \ + public: \ ::NYql::NUdf::TStringRef Name() const { \ auto name = ::NYql::NUdf::TStringRef::Of(#moduleName); \ - return name.Substring(1, name.Size() - 7); \ - } \ - }; + return name.Substring(1, name.Size() - 7); \ + } \ + }; #define EMPTY_RESULT_ON_EMPTY_ARG(n) \ if (!args[n]) { \ return ::NYql::NUdf::TUnboxedValue(); \ - } + } namespace NYql { namespace NUdf { @@ -336,7 +336,7 @@ public: ui32 flags, IFunctionTypeInfoBuilder& builder) const { - Y_UNUSED(typeConfig); + Y_UNUSED(typeConfig); bool typesOnly = (flags & TFlags::TypesOnly); return TUdfType::DeclareSignature(name, userType, builder, typesOnly); } diff --git a/ydb/library/yql/public/udf/udf_ptr.h b/ydb/library/yql/public/udf/udf_ptr.h index 44debb7856f..1cc8d00de47 100644 --- a/ydb/library/yql/public/udf/udf_ptr.h +++ b/ydb/library/yql/public/udf/udf_ptr.h @@ -1,6 +1,6 @@ #pragma once -#include <util/system/yassert.h> // Y_ASSERT +#include <util/system/yassert.h> // Y_ASSERT namespace NYql { @@ -89,17 +89,17 @@ class TDefaultRefCountedPtrOps { public: static inline void Ref(T* t) { - Y_ASSERT(t); + Y_ASSERT(t); t->Ref(); } static inline void UnRef(T* t) { - Y_ASSERT(t); + Y_ASSERT(t); t->UnRef(); } static inline ui32 RefCount(const T* t) { - Y_ASSERT(t); + Y_ASSERT(t); return t->RefCount(); } }; diff --git a/ydb/library/yql/public/udf/udf_registrator.h b/ydb/library/yql/public/udf/udf_registrator.h index 4d195d7eda6..a017b86c40a 100644 --- a/ydb/library/yql/public/udf/udf_registrator.h +++ b/ydb/library/yql/public/udf/udf_registrator.h @@ -24,7 +24,7 @@ #define REGISTER_MODULES(...) \ extern "C" UDF_API void Register( \ ::NYql::NUdf::IRegistrator& registrator, ui32 flags) { \ - Y_UNUSED(flags); \ + Y_UNUSED(flags); \ ::NYql::NUdf::RegisterHelper<__VA_ARGS__>(registrator); \ } \ extern "C" UDF_API ui32 AbiVersion() { \ diff --git a/ydb/library/yql/public/udf/udf_type_builder.h b/ydb/library/yql/public/udf/udf_type_builder.h index 8bfc73a449d..c2446024842 100644 --- a/ydb/library/yql/public/udf/udf_type_builder.h +++ b/ydb/library/yql/public/udf/udf_type_builder.h @@ -815,7 +815,7 @@ struct TCallableArgsHelper<> { ICallableTypeBuilder& callableBuilder, const IFunctionTypeInfoBuilder& builder) { - Y_UNUSED(callableBuilder); Y_UNUSED(builder); + Y_UNUSED(callableBuilder); Y_UNUSED(builder); } }; @@ -857,7 +857,7 @@ struct TTupleHelper<> { ITupleTypeBuilder& tupleBuilder, const IFunctionTypeInfoBuilder& builder) { - Y_UNUSED(tupleBuilder); Y_UNUSED(builder); + Y_UNUSED(tupleBuilder); Y_UNUSED(builder); } }; @@ -882,7 +882,7 @@ struct TTypeBuilderHelper<NUdf::TVariant<TArgs...>> { template <> struct TArgsHelper<> { static void Add(IFunctionArgTypesBuilder& builder, const char* name = nullptr, ui64 flags = 0) { - Y_UNUSED(builder); + Y_UNUSED(builder); Y_UNUSED(name); Y_UNUSED(flags); } diff --git a/ydb/library/yql/public/udf/udf_value.h b/ydb/library/yql/public/udf/udf_value.h index 705ac411333..db277bbe861 100644 --- a/ydb/library/yql/public/udf/udf_value.h +++ b/ydb/library/yql/public/udf/udf_value.h @@ -9,7 +9,7 @@ #include <util/system/yassert.h> // FAIL, VERIFY_DEBUG #include <util/generic/utility.h> // Min, Max -#include <util/generic/yexception.h> // Y_ENSURE +#include <util/generic/yexception.h> // Y_ENSURE #include <util/system/compiler.h> // Y_FORCE_INLINE #include <algorithm> diff --git a/ydb/library/yql/public/udf/udf_value_builder_ut.cpp b/ydb/library/yql/public/udf/udf_value_builder_ut.cpp index 1b55e948227..ddb4459589c 100644 --- a/ydb/library/yql/public/udf/udf_value_builder_ut.cpp +++ b/ydb/library/yql/public/udf/udf_value_builder_ut.cpp @@ -5,8 +5,8 @@ using namespace NYql::NUdf; -Y_UNIT_TEST_SUITE(TUdfValueBuilder) { - Y_UNIT_TEST(LockMethodsTable) { +Y_UNIT_TEST_SUITE(TUdfValueBuilder) { + Y_UNIT_TEST(LockMethodsTable) { UNIT_ASSERT_VALUES_EQUAL(2, GetMethodIndex(&IValueBuilder::NewStringNotFilled)); UNIT_ASSERT_VALUES_EQUAL(3, GetMethodIndex(&IValueBuilder::NewString)); UNIT_ASSERT_VALUES_EQUAL(4, GetMethodIndex(&IValueBuilder::ConcatStrings)); diff --git a/ydb/library/yql/public/udf/udf_value_inl.h b/ydb/library/yql/public/udf/udf_value_inl.h index eb2db28e18a..ca7da825b4a 100644 --- a/ydb/library/yql/public/udf/udf_value_inl.h +++ b/ydb/library/yql/public/udf/udf_value_inl.h @@ -18,7 +18,7 @@ #else -#define UDF_VERIFY Y_VERIFY_DEBUG +#define UDF_VERIFY Y_VERIFY_DEBUG #define UDF_ALWAYS_INLINE Y_FORCE_INLINE #endif @@ -41,7 +41,7 @@ inline void IBoxedValue1::UnRef() noexcept if (Refs_ < 0) return; #endif - Y_VERIFY_DEBUG(Refs_ > 0); + Y_VERIFY_DEBUG(Refs_ > 0); if (!--Refs_) delete this; } diff --git a/ydb/library/yql/public/udf/udf_value_ut.cpp b/ydb/library/yql/public/udf/udf_value_ut.cpp index 8d9708c7b19..53d9b81ad11 100644 --- a/ydb/library/yql/public/udf/udf_value_ut.cpp +++ b/ydb/library/yql/public/udf/udf_value_ut.cpp @@ -6,9 +6,9 @@ using namespace NYql::NUdf; -Y_UNIT_TEST_SUITE(TUdfValue) { +Y_UNIT_TEST_SUITE(TUdfValue) { - Y_UNIT_TEST(TestOptional) { + Y_UNIT_TEST(TestOptional) { TUnboxedValuePod foo((ui32) 42); UNIT_ASSERT(foo); UNIT_ASSERT(42 == foo.Get<ui32>()); @@ -21,7 +21,7 @@ Y_UNIT_TEST_SUITE(TUdfValue) { UNIT_ASSERT(42 == bar.Get<ui32>()); } - Y_UNIT_TEST(TestOptional2) { + Y_UNIT_TEST(TestOptional2) { auto valueOpt = TUnboxedValuePod((ui32) 42); UNIT_ASSERT(valueOpt); UNIT_ASSERT(valueOpt.HasValue()); @@ -30,7 +30,7 @@ Y_UNIT_TEST_SUITE(TUdfValue) { UNIT_ASSERT(42 == value.Get<ui32>()); } - Y_UNIT_TEST(TestEmptyOptional) { + Y_UNIT_TEST(TestEmptyOptional) { auto optEmpty = TUnboxedValuePod(); UNIT_ASSERT(!optEmpty); UNIT_ASSERT(!optEmpty.HasValue()); @@ -47,7 +47,7 @@ Y_UNIT_TEST_SUITE(TUdfValue) { UNIT_ASSERT(!v); } - Y_UNIT_TEST(TestVariant) { + Y_UNIT_TEST(TestVariant) { TUnboxedValuePod foo((ui64) 42); UNIT_ASSERT(foo); @@ -61,7 +61,7 @@ Y_UNIT_TEST_SUITE(TUdfValue) { UNIT_ASSERT(42 == foo.Get<ui64>()); } - Y_UNIT_TEST(TestEmptyInVariant) { + Y_UNIT_TEST(TestEmptyInVariant) { TUnboxedValuePod foo; UNIT_ASSERT(!foo); UNIT_ASSERT(!foo.HasValue()); @@ -79,7 +79,7 @@ Y_UNIT_TEST_SUITE(TUdfValue) { UNIT_ASSERT(!std::memcmp(&opt, &bar, sizeof(bar))); } - Y_UNIT_TEST(TestInvalid) { + Y_UNIT_TEST(TestInvalid) { TUnboxedValuePod foo; UNIT_ASSERT(!foo.IsInvalid()); @@ -91,7 +91,7 @@ Y_UNIT_TEST_SUITE(TUdfValue) { UNIT_ASSERT(bad.IsInvalid()); } - Y_UNIT_TEST(TestDump) { + Y_UNIT_TEST(TestDump) { NKikimr::NMiniKQL::TScopedAlloc alloc; UNIT_ASSERT_STRINGS_EQUAL(TStringBuilder() << TUnboxedValuePod(), "Empty, count: 0"); UNIT_ASSERT_STRINGS_EQUAL((TStringBuilder() << TUnboxedValuePod().MakeOptional()), "Empty, count: 1"); @@ -113,7 +113,7 @@ Y_UNIT_TEST_SUITE(TUdfValue) { UNIT_ASSERT(objStr.StartsWith("Boxed, pointer:")); } - Y_UNIT_TEST(LockMethodsTable) { + Y_UNIT_TEST(LockMethodsTable) { #define METHOD_INDEX(name) GetMethodPtrIndex(TBoxedValueAccessor::GetMethodPtr(TBoxedValueAccessor::EMethod::name)) UNIT_ASSERT_VALUES_EQUAL(2, METHOD_INDEX(HasFastListLength)); UNIT_ASSERT_VALUES_EQUAL(3, METHOD_INDEX(GetListLength)); diff --git a/ydb/library/yql/sql/v0/builtin.cpp b/ydb/library/yql/sql/v0/builtin.cpp index a0945f9d05e..35542c45f94 100644 --- a/ydb/library/yql/sql/v0/builtin.cpp +++ b/ydb/library/yql/sql/v0/builtin.cpp @@ -1431,7 +1431,7 @@ public: } TAstNode* Translate(TContext& ctx) const override { - Y_VERIFY_DEBUG(Node); + Y_VERIFY_DEBUG(Node); return Node->Translate(ctx); } @@ -1533,8 +1533,8 @@ public: } TAstNode* Translate(TContext& ctx) const override { - Y_UNUSED(ctx); - Y_VERIFY_DEBUG(Node); + Y_UNUSED(ctx); + Y_VERIFY_DEBUG(Node); return Node->Translate(ctx); } diff --git a/ydb/library/yql/sql/v0/context.cpp b/ydb/library/yql/sql/v0/context.cpp index a3a9013f2b7..ea6341c61d3 100644 --- a/ydb/library/yql/sql/v0/context.cpp +++ b/ydb/library/yql/sql/v0/context.cpp @@ -92,11 +92,11 @@ TString TContext::MakeName(const TString& name) { return str; } -IOutputStream& TContext::Error() { +IOutputStream& TContext::Error() { return Error(Pos()); } -IOutputStream& TContext::Error(NYql::TPosition pos) { +IOutputStream& TContext::Error(NYql::TPosition pos) { HasPendingErrors = true; return MakeIssue(TSeverityIds::S_ERROR, TIssuesIds::DEFAULT_ERROR, pos); } @@ -346,7 +346,7 @@ TContext& TTranslation::Context() { return Ctx; } -IOutputStream& TTranslation::Error() { +IOutputStream& TTranslation::Error() { return Ctx.Error(); } @@ -361,11 +361,11 @@ TNodePtr TTranslation::GetNamedNode(const TString& name) { } void TTranslation::PushNamedNode(const TString& name, TNodePtr node) { - Y_VERIFY_DEBUG(node); + Y_VERIFY_DEBUG(node); auto mapIt = Ctx.NamedNodes.find(name); if (mapIt == Ctx.NamedNodes.end()) { auto result = Ctx.NamedNodes.insert(std::make_pair(name, TStack<TNodePtr>())); - Y_VERIFY_DEBUG(result.second); + Y_VERIFY_DEBUG(result.second); mapIt = result.first; } @@ -374,8 +374,8 @@ void TTranslation::PushNamedNode(const TString& name, TNodePtr node) { void TTranslation::PopNamedNode(const TString& name) { auto mapIt = Ctx.NamedNodes.find(name); - Y_VERIFY_DEBUG(mapIt != Ctx.NamedNodes.end()); - Y_VERIFY_DEBUG(mapIt->second.size() > 0); + Y_VERIFY_DEBUG(mapIt != Ctx.NamedNodes.end()); + Y_VERIFY_DEBUG(mapIt->second.size() > 0); mapIt->second.pop(); if (mapIt->second.empty()) { Ctx.NamedNodes.erase(mapIt); diff --git a/ydb/library/yql/sql/v0/context.h b/ydb/library/yql/sql/v0/context.h index 45f40fae61c..838e17474ab 100644 --- a/ydb/library/yql/sql/v0/context.h +++ b/ydb/library/yql/sql/v0/context.h @@ -32,8 +32,8 @@ namespace NSQLTranslationV0 { void ClearBlockScope(); TString MakeName(const TString& name); - IOutputStream& Error(); - IOutputStream& Error(NYql::TPosition pos); + IOutputStream& Error(); + IOutputStream& Error(NYql::TPosition pos); IOutputStream& Warning(NYql::TPosition pos, NYql::TIssueCode code); IOutputStream& Info(NYql::TPosition pos); @@ -177,7 +177,7 @@ namespace NSQLTranslationV0 { public: TContext& Context(); - IOutputStream& Error(); + IOutputStream& Error(); template <typename TToken> const TString& Token(const TToken& token) { diff --git a/ydb/library/yql/sql/v0/insert.cpp b/ydb/library/yql/sql/v0/insert.cpp index 1d8aec71349..6d7036bf448 100644 --- a/ydb/library/yql/sql/v0/insert.cpp +++ b/ydb/library/yql/sql/v0/insert.cpp @@ -28,32 +28,32 @@ public: } bool AddFilter(TContext& ctx, TNodePtr filter) override { - Y_UNUSED(filter); + Y_UNUSED(filter); ctx.Error(Pos) << "Source does not allow filtering"; return false; } bool AddGroupKey(TContext& ctx, const TString& column) override { - Y_UNUSED(column); + Y_UNUSED(column); ctx.Error(Pos) << "Source does not allow grouping"; return false; } bool AddAggregation(TContext& ctx, TAggregationPtr aggr) override { - Y_UNUSED(aggr); + Y_UNUSED(aggr); ctx.Error(Pos) << "Source does not allow aggregation"; return false; } TNodePtr BuildFilter(TContext& ctx, const TString& label, const TNodePtr& groundNode) override { Y_UNUSED(ctx); - Y_UNUSED(label); + Y_UNUSED(label); Y_UNUSED(groundNode); return nullptr; } TNodePtr BuildAggregation(const TString& label) override { - Y_UNUSED(label); + Y_UNUSED(label); return nullptr; } diff --git a/ydb/library/yql/sql/v0/node.cpp b/ydb/library/yql/sql/v0/node.cpp index 57f0c6a561f..adcd4332424 100644 --- a/ydb/library/yql/sql/v0/node.cpp +++ b/ydb/library/yql/sql/v0/node.cpp @@ -42,7 +42,7 @@ TTableRef::TTableRef(const TTableRef& tr) } TString TTableRef::ShortName() const { - Y_VERIFY_DEBUG(Keys); + Y_VERIFY_DEBUG(Keys); if (Keys->GetTableKeys()->GetTableName()) { return *Keys->GetTableKeys()->GetTableName(); } @@ -150,7 +150,7 @@ TString INode::GetOpName() const { } const TString* INode::GetLiteral(const TString& type) const { - Y_UNUSED(type); + Y_UNUSED(type); return nullptr; } @@ -206,8 +206,8 @@ bool INode::Init(TContext& ctx, ISource* src) { } bool INode::DoInit(TContext& ctx, ISource* src) { - Y_UNUSED(ctx); - Y_UNUSED(src); + Y_UNUSED(ctx); + Y_UNUSED(src); return true; } @@ -260,7 +260,7 @@ bool INode::IsSelect() const { } TNodePtr INode::ShallowCopy() const { - Y_VERIFY_DEBUG(false, "Node is not copyable"); + Y_VERIFY_DEBUG(false, "Node is not copyable"); return nullptr; } @@ -283,8 +283,8 @@ void INode::PrecacheState() const { } void INode::DoAdd(TNodePtr node) { - Y_UNUSED(node); - Y_VERIFY_DEBUG(false, "Node is not expandable"); + Y_UNUSED(node); + Y_VERIFY_DEBUG(false, "Node is not expandable"); } TAstAtomNode::TAstAtomNode(TPosition pos, const TString& content, ui32 flags) @@ -317,7 +317,7 @@ TAstDirectNode::TAstDirectNode(TAstNode* node) } TAstNode* TAstDirectNode::Translate(TContext& ctx) const { - Y_UNUSED(ctx); + Y_UNUSED(ctx); return Node; } @@ -411,8 +411,8 @@ TNodePtr TAstListNode::ShallowCopy() const { } void TAstListNode::DoAdd(TNodePtr node) { - Y_VERIFY_DEBUG(node); - Y_VERIFY_DEBUG(node.Get() != this); + Y_VERIFY_DEBUG(node); + Y_VERIFY_DEBUG(node.Get() != this); Nodes.push_back(node); } @@ -972,8 +972,8 @@ ITableKeys* ITableKeys::GetTableKeys() { } TAstNode* ITableKeys::Translate(TContext& ctx) const { - Y_VERIFY_DEBUG(false); - Y_UNUSED(ctx); + Y_VERIFY_DEBUG(false); + Y_UNUSED(ctx); return nullptr; } @@ -1003,8 +1003,8 @@ IAggregation::IAggregation(TPosition pos, const TString& name, const TString& fu {} TAstNode* IAggregation::Translate(TContext& ctx) const { - Y_VERIFY_DEBUG(false); - Y_UNUSED(ctx); + Y_VERIFY_DEBUG(false); + Y_UNUSED(ctx); return nullptr; } @@ -1080,7 +1080,7 @@ void ISource::FinishColumns() { bool ISource::AddFilter(TContext& ctx, TNodePtr filter) { - Y_UNUSED(ctx); + Y_UNUSED(ctx); Filters.push_back(filter); return true; } @@ -1697,8 +1697,8 @@ bool ISource::InitFilters(TContext& ctx) { } TAstNode* ISource::Translate(TContext& ctx) const { - Y_VERIFY_DEBUG(false); - Y_UNUSED(ctx); + Y_VERIFY_DEBUG(false); + Y_UNUSED(ctx); return nullptr; } @@ -1756,8 +1756,8 @@ bool TryStringContent(const TString& str, TString& result, ui32& flags, TString& error.clear(); result.clear(); - bool doubleQuoted = (str.StartsWith('"') && str.EndsWith('"')); - bool singleQuoted = !doubleQuoted && (str.StartsWith('\'') && str.EndsWith('\'')); + bool doubleQuoted = (str.StartsWith('"') && str.EndsWith('"')); + bool singleQuoted = !doubleQuoted && (str.StartsWith('\'') && str.EndsWith('\'')); if (str.size() >= 2 && (doubleQuoted || singleQuoted)) { flags = TNodeFlags::ArbitraryContent; @@ -1775,7 +1775,7 @@ bool TryStringContent(const TString& str, TString& result, ui32& flags, TString& error = UnescapeResultToString(unescapeResult); return false; } - } else if (str.size() >= 4 && str.StartsWith("@@") && str.EndsWith("@@")) { + } else if (str.size() >= 4 && str.StartsWith("@@") && str.EndsWith("@@")) { flags = TNodeFlags::MultilineContent; TString s = str.substr(2, str.length() - 4); SubstGlobal(s, "@@@@", "@@"); @@ -2163,8 +2163,8 @@ public: , ColumnOnly(false) , IsColumnRequired(false) { - Y_VERIFY_DEBUG(Ids.size() > 1); - Y_VERIFY_DEBUG(Ids[0].Expr); + Y_VERIFY_DEBUG(Ids.size() > 1); + Y_VERIFY_DEBUG(Ids[0].Expr); auto column = dynamic_cast<TColumnNode*>(Ids[0].Expr.Get()); if (column) { ui32 idx = 1; @@ -2322,7 +2322,7 @@ public: } TAstNode* Translate(TContext& ctx) const override { - Y_VERIFY_DEBUG(Node); + Y_VERIFY_DEBUG(Node); return Node->Translate(ctx); } @@ -2515,7 +2515,7 @@ TNodePtr BuildBitCast(TContext& ctx, TPosition pos, TNodePtr expr, const TString TString TypeByAlias(const TString& alias, bool normalize) { TString type(alias); TCiString typeAlias(alias); - if (typeAlias.StartsWith("varchar")) { + if (typeAlias.StartsWith("varchar")) { type = "String"; } else if (typeAlias == "tinyint") { type = "Int8"; diff --git a/ydb/library/yql/sql/v0/node.h b/ydb/library/yql/sql/v0/node.h index 4c7cfc273b6..3171fd3789c 100644 --- a/ydb/library/yql/sql/v0/node.h +++ b/ydb/library/yql/sql/v0/node.h @@ -186,7 +186,7 @@ namespace NSQLTranslationV0 { template <typename... TVals> TPtr L(TPtr list, TVals... vals) const { - Y_VERIFY_DEBUG(list); + Y_VERIFY_DEBUG(list); auto copy = list->ShallowCopy(); copy->Add(vals...); return copy; diff --git a/ydb/library/yql/sql/v0/query.cpp b/ydb/library/yql/sql/v0/query.cpp index 7752b28b017..773301c9025 100644 --- a/ydb/library/yql/sql/v0/query.cpp +++ b/ydb/library/yql/sql/v0/query.cpp @@ -474,10 +474,10 @@ public: if (!type) { return false; } - Y_ASSERT(type->IsList()); - Y_ASSERT(type->GetChildrenCount() > 1); + Y_ASSERT(type->IsList()); + Y_ASSERT(type->GetChildrenCount() > 1); auto typeName = type->GetChild(0); - Y_ASSERT(typeName->IsAtom()); + Y_ASSERT(typeName->IsAtom()); if (typeName->GetContent() == "OptionalType") { ctx.Error(col.Pos) << "CREATE TABLE clause requires non-optional column types in scheme"; return false; diff --git a/ydb/library/yql/sql/v0/select.cpp b/ydb/library/yql/sql/v0/select.cpp index ef47023be15..d66ca9a53f3 100644 --- a/ydb/library/yql/sql/v0/select.cpp +++ b/ydb/library/yql/sql/v0/select.cpp @@ -136,7 +136,7 @@ public: } TAstNode* Translate(TContext& ctx) const override { - Y_VERIFY_DEBUG(Node); + Y_VERIFY_DEBUG(Node); return Node->Translate(ctx); } @@ -164,24 +164,24 @@ public: } bool AddFilter(TContext& ctx, TNodePtr filter) override { - Y_UNUSED(filter); + Y_UNUSED(filter); ctx.Error(Pos) << "Source does not allow filtering"; return false; } TNodePtr Build(TContext& ctx) override { - Y_UNUSED(ctx); + Y_UNUSED(ctx); return Y("AsList", Y("Uint32", Q("0"))); } bool AddGroupKey(TContext& ctx, const TString& column) override { - Y_UNUSED(column); + Y_UNUSED(column); ctx.Error(Pos) << "Source does not allow grouping"; return false; } bool AddAggregation(TContext& ctx, TAggregationPtr aggr) override { - Y_UNUSED(aggr); + Y_UNUSED(aggr); ctx.Error(Pos) << "Source does not allow aggregation"; return false; } @@ -193,13 +193,13 @@ public: TNodePtr BuildFilter(TContext& ctx, const TString& label, const TNodePtr& groundNode) override { Y_UNUSED(ctx); - Y_UNUSED(label); + Y_UNUSED(label); Y_UNUSED(groundNode); return nullptr; } TNodePtr BuildAggregation(const TString& label) override { - Y_UNUSED(label); + Y_UNUSED(label); return nullptr; } @@ -285,12 +285,12 @@ protected: {} void AllColumns() override { - Y_VERIFY_DEBUG(Source); + Y_VERIFY_DEBUG(Source); return Source->AllColumns(); } const TColumns* GetColumns() const override { - Y_VERIFY_DEBUG(Source); + Y_VERIFY_DEBUG(Source); return Source->GetColumns(); } @@ -300,7 +300,7 @@ protected: } TMaybe<bool> AddColumn(TContext& ctx, TColumnNode& column) override { - Y_VERIFY_DEBUG(Source); + Y_VERIFY_DEBUG(Source); const TString label(Source->GetLabel()); Source->SetLabel(Label); const auto ret = Source->AddColumn(ctx, column); @@ -707,7 +707,7 @@ public: } TNodePtr Build(TContext& ctx) override { - Y_UNUSED(ctx); + Y_UNUSED(ctx); return NewSource ? NewSource->Build(ctx) : Node; } @@ -1524,7 +1524,7 @@ private: terms = L(terms, (Y("let", "res", Y("AsList", "row")))); } } else if (!Columns.List.empty()) { - Y_VERIFY_DEBUG(Columns.List.size() == Terms.size()); + Y_VERIFY_DEBUG(Columns.List.size() == Terms.size()); const bool isJoin = Source->GetJoin(); terms = TermsGround ? TermsGround : Y(); diff --git a/ydb/library/yql/sql/v0/sql.cpp b/ydb/library/yql/sql/v0/sql.cpp index b028fc04398..dd1f2b5f5f9 100644 --- a/ydb/library/yql/sql/v0/sql.cpp +++ b/ydb/library/yql/sql/v0/sql.cpp @@ -1440,8 +1440,8 @@ TNodePtr TSqlExpression::UnaryExpr(const TUnarySubExprType& node) { Ctx.IncrementMonCounter("sql_errors", "CollateUnarySubexpr"); Error() << "unary_subexpr: COLLATE is not implemented yet"; } - Y_VERIFY_DEBUG(!ids.empty()); - Y_VERIFY_DEBUG(ids.front().Expr); + Y_VERIFY_DEBUG(!ids.empty()); + Y_VERIFY_DEBUG(ids.front().Expr); return ids.size() > 1 ? BuildAccess(pos, ids, isLookup) : ids.back().Expr; } @@ -2421,7 +2421,7 @@ bool TSqlSelect::JoinOp(ISource* join, const TRule_join_source::TBlock2& block) } } - Y_VERIFY_DEBUG(join->GetJoin()); + Y_VERIFY_DEBUG(join->GetJoin()); join->GetJoin()->SetupJoin(joinOp, joinKeyExpr); break; } @@ -2450,7 +2450,7 @@ TNodePtr TSqlSelect::JoinExpr(ISource* join, const TRule_join_constraint& node) return nullptr; } - Y_VERIFY_DEBUG(join->GetJoin()); + Y_VERIFY_DEBUG(join->GetJoin()); return join->GetJoin()->BuildJoinKeys(Ctx, names); } default: @@ -3738,7 +3738,7 @@ TString TGroupByClause::GenerateGroupByExprName() { } bool TGroupByClause::IsAutogenerated(const TString* name) const { - return name && name->StartsWith(AutogenerateNamePrefix); + return name && name->StartsWith(AutogenerateNamePrefix); } TSourcePtr TSqlSelect::SelectKind(const TRule_select_kind_partial& node, TPosition& selectPos) { diff --git a/ydb/library/yql/sql/v0/sql_ut.cpp b/ydb/library/yql/sql/v0/sql_ut.cpp index 3a70aef93cc..27a13c7f5ae 100644 --- a/ydb/library/yql/sql/v0/sql_ut.cpp +++ b/ydb/library/yql/sql/v0/sql_ut.cpp @@ -90,7 +90,7 @@ TString VerifyProgram(const NYql::TAstParseResult& res, TWordCountHive& wordCoun return programm; } -Y_UNIT_TEST_SUITE(SqlParsingOnly) { +Y_UNIT_TEST_SUITE(SqlParsingOnly) { Y_UNIT_TEST(V0) { NYql::TAstParseResult res = SqlToYql("select null;"); UNIT_ASSERT(res.Root); @@ -98,7 +98,7 @@ Y_UNIT_TEST_SUITE(SqlParsingOnly) { UNIT_ASSERT(TString::npos != programm.find("(Configure! world (DataSource '\"config\") '\"SQL\" '\"0\"))")); } - Y_UNIT_TEST(TableHints) { + Y_UNIT_TEST(TableHints) { UNIT_ASSERT(SqlToYql("SELECT * FROM plato.Input WITH INFER_SCHEME").IsOk()); UNIT_ASSERT(SqlToYql("SELECT * FROM plato.Input WITH (INFER_SCHEME)").IsOk()); } @@ -158,12 +158,12 @@ Y_UNIT_TEST_SUITE(SqlParsingOnly) { UNIT_ASSERT(SqlToYql("USE plato; SELECT * FROM COMPACT").IsOk()); } - Y_UNIT_TEST(Jubilee) { + Y_UNIT_TEST(Jubilee) { NYql::TAstParseResult res = SqlToYql("USE plato; INSERT INTO Arcadia (r2000000) VALUES (\"2M GET!!!\");"); UNIT_ASSERT(res.Root); } - Y_UNIT_TEST(QualifiedAsteriskBefore) { + Y_UNIT_TEST(QualifiedAsteriskBefore) { NYql::TAstParseResult res = SqlToYql("select interested_table.*, LENGTH(value) AS megahelpful_len from plato.Input as interested_table;"); UNIT_ASSERT(res.Root); @@ -186,7 +186,7 @@ Y_UNIT_TEST_SUITE(SqlParsingOnly) { UNIT_ASSERT_VALUES_EQUAL(1, elementStat["AsStruct"]); } - Y_UNIT_TEST(QualifiedAsteriskAfter) { + Y_UNIT_TEST(QualifiedAsteriskAfter) { NYql::TAstParseResult res = SqlToYql("select LENGTH(value) AS megahelpful_len, interested_table.* from plato.Input as interested_table;"); UNIT_ASSERT(res.Root); @@ -209,7 +209,7 @@ Y_UNIT_TEST_SUITE(SqlParsingOnly) { UNIT_ASSERT_VALUES_EQUAL(1, elementStat["AsStruct"]); } - Y_UNIT_TEST(QualifiedMembers) { + Y_UNIT_TEST(QualifiedMembers) { NYql::TAstParseResult res = SqlToYql("select interested_table.key, interested_table.value from plato.Input as interested_table;"); UNIT_ASSERT(res.Root); @@ -231,7 +231,7 @@ Y_UNIT_TEST_SUITE(SqlParsingOnly) { UNIT_ASSERT_VALUES_EQUAL(1, elementStat["Write!"]); } - Y_UNIT_TEST(JoinParseCorrect) { + Y_UNIT_TEST(JoinParseCorrect) { NYql::TAstParseResult res = SqlToYql( " SELECT table_bb.*, table_aa.key as megakey" " FROM plato.Input AS table_aa" @@ -258,7 +258,7 @@ Y_UNIT_TEST_SUITE(SqlParsingOnly) { UNIT_ASSERT_VALUES_EQUAL(1, elementStat["AsStruct"]); } - Y_UNIT_TEST(Join3Table) { + Y_UNIT_TEST(Join3Table) { NYql::TAstParseResult res = SqlToYql( " SELECT table_bb.*, table_aa.key as gigakey, table_cc.* " " FROM plato.Input AS table_aa" @@ -289,7 +289,7 @@ Y_UNIT_TEST_SUITE(SqlParsingOnly) { UNIT_ASSERT_VALUES_EQUAL(1, elementStat["AsStruct"]); } - Y_UNIT_TEST(JoinWithoutConcreteColumns) { + Y_UNIT_TEST(JoinWithoutConcreteColumns) { NYql::TAstParseResult res = SqlToYql( " use plato;" " SELECT a.v, b.value" @@ -318,7 +318,7 @@ Y_UNIT_TEST_SUITE(SqlParsingOnly) { UNIT_ASSERT_VALUES_EQUAL(1, elementStat["AsStruct"]); } - Y_UNIT_TEST(JoinWithSameValues) { + Y_UNIT_TEST(JoinWithSameValues) { NYql::TAstParseResult res = SqlToYql("SELECT a.value, b.value FROM plato.Input AS a JOIN plato.Input as b ON a.key == b.key;"); UNIT_ASSERT(res.Root); @@ -340,37 +340,37 @@ Y_UNIT_TEST_SUITE(SqlParsingOnly) { UNIT_ASSERT_VALUES_EQUAL(1, elementStat["Write!"]); } - Y_UNIT_TEST(SameColumnsForDifferentTables) { + Y_UNIT_TEST(SameColumnsForDifferentTables) { NYql::TAstParseResult res = SqlToYql("SELECT a.key, b.key FROM plato.Input as a JOIN plato.Input as b on a.key==b.key;"); UNIT_ASSERT(res.Root); } - Y_UNIT_TEST(SameColumnsForDifferentTablesFullJoin) { + Y_UNIT_TEST(SameColumnsForDifferentTablesFullJoin) { NYql::TAstParseResult res = SqlToYql("SELECT a.key, b.key, a.value, b.value FROM plato.Input AS a FULL JOIN plato.Input AS b USING(key);"); UNIT_ASSERT(res.Root); } - Y_UNIT_TEST(ReverseLabels) { + Y_UNIT_TEST(ReverseLabels) { NYql::TAstParseResult res = SqlToYql("select in.key as subkey, subkey as key from plato.Input as in;"); UNIT_ASSERT(res.Root); } - Y_UNIT_TEST(AutogenerationAliasWithoutCollisionConflict1) { + Y_UNIT_TEST(AutogenerationAliasWithoutCollisionConflict1) { NYql::TAstParseResult res = SqlToYql("select LENGTH(Value), key as column1 from plato.Input;"); UNIT_ASSERT(res.Root); } - Y_UNIT_TEST(AutogenerationAliasWithoutCollision2Conflict2) { + Y_UNIT_TEST(AutogenerationAliasWithoutCollision2Conflict2) { NYql::TAstParseResult res = SqlToYql("select key as column0, LENGTH(Value) from plato.Input;"); UNIT_ASSERT(res.Root); } - Y_UNIT_TEST(InputAliasForQualifiedAsterisk) { + Y_UNIT_TEST(InputAliasForQualifiedAsterisk) { NYql::TAstParseResult res = SqlToYql("use plato; select zyuzya.*, key from plato.Input as zyuzya;"); UNIT_ASSERT(res.Root); } - Y_UNIT_TEST(SelectOrderByLabeledColumn) { + Y_UNIT_TEST(SelectOrderByLabeledColumn) { NYql::TAstParseResult res = SqlToYql("select key as goal from plato.Input order by goal"); UNIT_ASSERT(res.Root); TVerifyLineFunc verifyLine = [](const TString& word, const TString& line) { @@ -391,17 +391,17 @@ Y_UNIT_TEST_SUITE(SqlParsingOnly) { UNIT_ASSERT_VALUES_EQUAL(1, elementStat["Sort"]); } - Y_UNIT_TEST(SelectOrderBySimpleExpr) { + Y_UNIT_TEST(SelectOrderBySimpleExpr) { NYql::TAstParseResult res = SqlToYql("select a from plato.Input order by a + a"); UNIT_ASSERT(res.Root); } - Y_UNIT_TEST(SelectOrderByDuplicateLabels) { + Y_UNIT_TEST(SelectOrderByDuplicateLabels) { NYql::TAstParseResult res = SqlToYql("select a from plato.Input order by a, a"); UNIT_ASSERT(res.Root); } - Y_UNIT_TEST(SelectOrderByExpression) { + Y_UNIT_TEST(SelectOrderByExpression) { NYql::TAstParseResult res = SqlToYql("select * from plato.Input as i order by cast(key as uint32) + cast(subkey as uint32)"); UNIT_ASSERT(res.Root); TVerifyLineFunc verifyLine = [](const TString& word, const TString& line) { @@ -420,7 +420,7 @@ Y_UNIT_TEST_SUITE(SqlParsingOnly) { UNIT_ASSERT_VALUES_EQUAL(1, elementStat["Sort"]); } - Y_UNIT_TEST(SelectOrderByExpressionDesc) { + Y_UNIT_TEST(SelectOrderByExpressionDesc) { NYql::TAstParseResult res = SqlToYql("select i.*, key, subkey from plato.Input as i order by cast(i.key as uint32) - cast(i.subkey as uint32) desc"); UNIT_ASSERT(res.Root); TVerifyLineFunc verifyLine = [](const TString& word, const TString& line) { @@ -443,7 +443,7 @@ Y_UNIT_TEST_SUITE(SqlParsingOnly) { UNIT_ASSERT_VALUES_EQUAL(1, elementStat["Write!"]); } - Y_UNIT_TEST(SelectOrderByExpressionAsc) { + Y_UNIT_TEST(SelectOrderByExpressionAsc) { NYql::TAstParseResult res = SqlToYql("select i.key, i.subkey from plato.Input as i order by cast(key as uint32) % cast(i.subkey as uint32) asc"); UNIT_ASSERT(res.Root); TVerifyLineFunc verifyLine = [](const TString& word, const TString& line) { @@ -465,32 +465,32 @@ Y_UNIT_TEST_SUITE(SqlParsingOnly) { UNIT_ASSERT_VALUES_EQUAL(1, elementStat["Write!"]); } - Y_UNIT_TEST(ReferenceToKeyInSubselect) { + Y_UNIT_TEST(ReferenceToKeyInSubselect) { NYql::TAstParseResult res = SqlToYql("select b.key from (select a.key from plato.Input as a) as b;"); UNIT_ASSERT(res.Root); } - Y_UNIT_TEST(OrderByCastValue) { + Y_UNIT_TEST(OrderByCastValue) { NYql::TAstParseResult res = SqlToYql("select i.key, i.subkey from plato.Input as i order by cast(key as uint32) desc;"); UNIT_ASSERT(res.Root); } - Y_UNIT_TEST(GroupByCastValue) { + Y_UNIT_TEST(GroupByCastValue) { NYql::TAstParseResult res = SqlToYql("select count(1) from plato.Input as i group by cast(key as uint8);"); UNIT_ASSERT(res.Root); } - Y_UNIT_TEST(KeywordInSelectColumns) { + Y_UNIT_TEST(KeywordInSelectColumns) { NYql::TAstParseResult res = SqlToYql("select in, s.check from (select 1 as in, \"test\" as check) as s;"); UNIT_ASSERT(res.Root); } - Y_UNIT_TEST(SelectAllGroupBy) { + Y_UNIT_TEST(SelectAllGroupBy) { NYql::TAstParseResult res = SqlToYql("select * from plato.Input group by subkey;"); UNIT_ASSERT(res.Root); } - Y_UNIT_TEST(PrimaryKeyParseCorrect) { + Y_UNIT_TEST(PrimaryKeyParseCorrect) { NYql::TAstParseResult res = SqlToYql("USE plato; CREATE TABLE tableName (Key Uint32, Subkey Int64, Value String, PRIMARY KEY (Key, Subkey));"); UNIT_ASSERT(res.Root); @@ -508,7 +508,7 @@ Y_UNIT_TEST_SUITE(SqlParsingOnly) { UNIT_ASSERT_VALUES_EQUAL(1, elementStat["primarykey"]); } - Y_UNIT_TEST(DeleteFromTableByKey) { + Y_UNIT_TEST(DeleteFromTableByKey) { NYql::TAstParseResult res = SqlToYql("delete from plato.Input where key = 200;", 10, "kikimr"); UNIT_ASSERT(res.Root); @@ -524,7 +524,7 @@ Y_UNIT_TEST_SUITE(SqlParsingOnly) { UNIT_ASSERT_VALUES_EQUAL(1, elementStat["Write"]); } - Y_UNIT_TEST(DeleteFromTable) { + Y_UNIT_TEST(DeleteFromTable) { NYql::TAstParseResult res = SqlToYql("delete from plato.Input;", 10, "kikimr"); UNIT_ASSERT(res.Root); @@ -540,7 +540,7 @@ Y_UNIT_TEST_SUITE(SqlParsingOnly) { UNIT_ASSERT_VALUES_EQUAL(1, elementStat["Write"]); } - Y_UNIT_TEST(DeleteFromTableOnValues) { + Y_UNIT_TEST(DeleteFromTableOnValues) { NYql::TAstParseResult res = SqlToYql("delete from plato.Input on (key) values (1);", 10, "kikimr"); UNIT_ASSERT(res.Root); @@ -557,7 +557,7 @@ Y_UNIT_TEST_SUITE(SqlParsingOnly) { UNIT_ASSERT_VALUES_EQUAL(1, elementStat["Write"]); } - Y_UNIT_TEST(DeleteFromTableOnSelect) { + Y_UNIT_TEST(DeleteFromTableOnSelect) { NYql::TAstParseResult res = SqlToYql( "delete from plato.Input on select key from plato.Input where value > 0;", 10, "kikimr"); UNIT_ASSERT(res.Root); @@ -574,7 +574,7 @@ Y_UNIT_TEST_SUITE(SqlParsingOnly) { UNIT_ASSERT_VALUES_EQUAL(1, elementStat["Write"]); } - Y_UNIT_TEST(UpdateByValues) { + Y_UNIT_TEST(UpdateByValues) { NYql::TAstParseResult res = SqlToYql("update plato.Input set key = 777, value = 'cool' where key = 200;", 10, "kikimr"); UNIT_ASSERT(res.Root); @@ -600,7 +600,7 @@ Y_UNIT_TEST_SUITE(SqlParsingOnly) { UNIT_ASSERT_VALUES_EQUAL(1, elementStat["AsStruct"]); } - Y_UNIT_TEST(UpdateByMultiValues) { + Y_UNIT_TEST(UpdateByMultiValues) { NYql::TAstParseResult res = SqlToYql("update plato.Input set (key, value, subkey) = ('2','ddd',':') where key = 200;", 10, "kikimr"); UNIT_ASSERT(res.Root); @@ -629,7 +629,7 @@ Y_UNIT_TEST_SUITE(SqlParsingOnly) { UNIT_ASSERT_VALUES_EQUAL(1, elementStat["AsStruct"]); } - Y_UNIT_TEST(UpdateBySelect) { + Y_UNIT_TEST(UpdateBySelect) { NYql::TAstParseResult res = SqlToYql("update plato.Input set (key, value, subkey) = (select key, value, subkey from plato.Input where key = 911) where key = 200;", 10, "kikimr"); UNIT_ASSERT(res.Root); @@ -655,7 +655,7 @@ Y_UNIT_TEST_SUITE(SqlParsingOnly) { UNIT_ASSERT_VALUES_EQUAL(1, elementStat["Write"]); } - Y_UNIT_TEST(UpdateSelfModifyAll) { + Y_UNIT_TEST(UpdateSelfModifyAll) { NYql::TAstParseResult res = SqlToYql("update plato.Input set subkey = subkey + 's';", 10, "kikimr"); UNIT_ASSERT(res.Root); @@ -677,7 +677,7 @@ Y_UNIT_TEST_SUITE(SqlParsingOnly) { UNIT_ASSERT_VALUES_EQUAL(1, elementStat["AsStruct"]); } - Y_UNIT_TEST(UpdateOnValues) { + Y_UNIT_TEST(UpdateOnValues) { NYql::TAstParseResult res = SqlToYql("update plato.Input on (key, value) values (5, 'cool')", 10, "kikimr"); UNIT_ASSERT(res.Root); @@ -693,7 +693,7 @@ Y_UNIT_TEST_SUITE(SqlParsingOnly) { UNIT_ASSERT_VALUES_EQUAL(1, elementStat["Write"]); } - Y_UNIT_TEST(UpdateOnSelect) { + Y_UNIT_TEST(UpdateOnSelect) { NYql::TAstParseResult res = SqlToYql( "update plato.Input on select key, value + 1 as value from plato.Input", 10, "kikimr"); UNIT_ASSERT(res.Root); @@ -710,7 +710,7 @@ Y_UNIT_TEST_SUITE(SqlParsingOnly) { UNIT_ASSERT_VALUES_EQUAL(1, elementStat["Write"]); } - Y_UNIT_TEST(UnionAllTest) { + Y_UNIT_TEST(UnionAllTest) { NYql::TAstParseResult res = SqlToYql("SELECT key FROM plato.Input UNION ALL select subkey FROM plato.Input;"); UNIT_ASSERT(res.Root); @@ -724,19 +724,19 @@ Y_UNIT_TEST_SUITE(SqlParsingOnly) { UNIT_ASSERT(res.Root); } - Y_UNIT_TEST(SimpleGroupBy) { + Y_UNIT_TEST(SimpleGroupBy) { NYql::TAstParseResult res = SqlToYql("select count(1),z from plato.Input group by key as z order by z;"); UNIT_ASSERT(res.Root); } - Y_UNIT_TEST(EmptyColumnName0) { + Y_UNIT_TEST(EmptyColumnName0) { /// Now it's parsed well and error occur on validate step like "4:31:Empty struct member name is not allowed" in "4:31:Function: AddMember" NYql::TAstParseResult res = SqlToYql("insert into plato.Output ([], list1) values (0, AsList(0, 1, 2));"); /// Verify that parsed well without crash UNIT_ASSERT(res.Root); } - Y_UNIT_TEST(KikimrRollback) { + Y_UNIT_TEST(KikimrRollback) { NYql::TAstParseResult res = SqlToYql("use plato; rollback;", 10, "kikimr"); UNIT_ASSERT(res.Root); @@ -745,7 +745,7 @@ Y_UNIT_TEST_SUITE(SqlParsingOnly) { UNIT_ASSERT_VALUES_EQUAL(1, elementStat["rollback"]); } - Y_UNIT_TEST(PragmaFile) { + Y_UNIT_TEST(PragmaFile) { NYql::TAstParseResult res = SqlToYql(R"(pragma file("HW", "sbr:181041334");)"); UNIT_ASSERT(res.Root); @@ -754,12 +754,12 @@ Y_UNIT_TEST_SUITE(SqlParsingOnly) { UNIT_ASSERT_VALUES_EQUAL(1, elementStat.cbegin()->second); } - Y_UNIT_TEST(DoNotCrashOnNamedInFilter) { + Y_UNIT_TEST(DoNotCrashOnNamedInFilter) { NYql::TAstParseResult res = SqlToYql("USE plato; $all = YQL::@@(lambda '(table_name) (Bool 'true))@@; SELECT * FROM FILTER(Input, $all)"); UNIT_ASSERT(res.Root); } - Y_UNIT_TEST(PragmasFileAndUdfOrder) { + Y_UNIT_TEST(PragmasFileAndUdfOrder) { NYql::TAstParseResult res = SqlToYql(R"( PRAGMA file("libvideoplayers_udf.so", "https://proxy.sandbox.yandex-team.ru/235185290"); PRAGMA udf("libvideoplayers_udf.so"); @@ -772,7 +772,7 @@ Y_UNIT_TEST_SUITE(SqlParsingOnly) { UNIT_ASSERT(file < udfs); } - Y_UNIT_TEST(ProcessUserType) { + Y_UNIT_TEST(ProcessUserType) { NYql::TAstParseResult res = SqlToYql("process plato.Input using Kikimr::PushData($ROWS);", 1, TString(NYql::KikimrProviderName)); UNIT_ASSERT(res.Root); @@ -807,14 +807,14 @@ Y_UNIT_TEST_SUITE(SqlParsingOnly) { UNIT_ASSERT_VALUES_EQUAL(1, elementStat["YDB.PushData"]); } - Y_UNIT_TEST(SelectStreamRtmr) { + Y_UNIT_TEST(SelectStreamRtmr) { NYql::TAstParseResult res = SqlToYql( "USE plato; INSERT INTO Output SELECT STREAM key FROM Input;", 10, TString(NYql::RtmrProviderName)); UNIT_ASSERT(res.Root); } - Y_UNIT_TEST(GroupByHopRtmr) { + Y_UNIT_TEST(GroupByHopRtmr) { NYql::TAstParseResult res = SqlToYql(R"( USE plato; INSERT INTO Output SELECT STREAM key, SUM(value) AS value FROM Input GROUP BY key, HOP(subkey, "PT10S", "PT30S", "PT20S"); @@ -822,7 +822,7 @@ Y_UNIT_TEST_SUITE(SqlParsingOnly) { UNIT_ASSERT(res.Root); } - Y_UNIT_TEST(KikimrInserts) { + Y_UNIT_TEST(KikimrInserts) { NYql::TAstParseResult res = SqlToYql(R"( USE plato; INSERT INTO Output SELECT key, value FROM Input; @@ -899,8 +899,8 @@ Y_UNIT_TEST_SUITE(SqlParsingOnly) { } -Y_UNIT_TEST_SUITE(SqlToYQLErrors) { - Y_UNIT_TEST(StrayUTF8) { +Y_UNIT_TEST_SUITE(SqlToYQLErrors) { + Y_UNIT_TEST(StrayUTF8) { /// 'c' in plato is russian here NYql::TAstParseResult res = SqlToYql("select * from сedar.Input"); UNIT_ASSERT(!res.Root); @@ -958,13 +958,13 @@ Y_UNIT_TEST_SUITE(SqlToYQLErrors) { UNIT_ASSERT_NO_DIFF(a1, a2); } - Y_UNIT_TEST(WrongTokenTrivial) { + Y_UNIT_TEST(WrongTokenTrivial) { NYql::TAstParseResult res = SqlToYql("foo"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:0: Error: Unexpected token 'foo' : cannot match to any predicted input...\n\n"); } - Y_UNIT_TEST(InvalidDoubleAtString) { + Y_UNIT_TEST(InvalidDoubleAtString) { NYql::TAstParseResult res = SqlToYql("select @@@@@@"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:13: Error: Unexpected character : syntax error...\n\n" @@ -977,44 +977,44 @@ Y_UNIT_TEST_SUITE(SqlToYQLErrors) { UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:7: Error: Unexpected token '@@foo@@' : cannot match to any predicted input...\n\n"); } - Y_UNIT_TEST(InvalidStringFromTable) { + Y_UNIT_TEST(InvalidStringFromTable) { NYql::TAstParseResult res = SqlToYql("select \"FOO\"\"BAR from plato.foo"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:31: Error: Unexpected character : syntax error...\n\n"); } - Y_UNIT_TEST(InvalidDoubleAtStringFromTable) { + Y_UNIT_TEST(InvalidDoubleAtStringFromTable) { NYql::TAstParseResult res = SqlToYql("select @@@@@@ from plato.foo"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:28: Error: Unexpected character : syntax error...\n\n" "<main>:1:0: Error: Unexpected token absence : cannot match to any predicted input...\n\n"); } - Y_UNIT_TEST(SelectInvalidSyntax) { + Y_UNIT_TEST(SelectInvalidSyntax) { NYql::TAstParseResult res = SqlToYql("select 1 form Wat"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:9: Error: Unexpected token 'form' : syntax error...\n\n"); } - Y_UNIT_TEST(SelectNoCluster) { + Y_UNIT_TEST(SelectNoCluster) { NYql::TAstParseResult res = SqlToYql("select foo from bar"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:1: Error: No cluster name given and no default cluster is selected\n"); } - Y_UNIT_TEST(SelectDuplicateColumns) { + Y_UNIT_TEST(SelectDuplicateColumns) { NYql::TAstParseResult res = SqlToYql("select a, a from plato.Input"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:11: Error: Unable to use duplicate column names. Collision in name: a\n"); } - Y_UNIT_TEST(SelectDuplicateLabels) { + Y_UNIT_TEST(SelectDuplicateLabels) { NYql::TAstParseResult res = SqlToYql("select a as foo, b as foo from plato.Input"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:18: Error: Unable to use duplicate column names. Collision in name: foo\n"); } - Y_UNIT_TEST(SelectCaseWithoutThen) { + Y_UNIT_TEST(SelectCaseWithoutThen) { NYql::TAstParseResult res = SqlToYql("select case when true 1;"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), @@ -1023,7 +1023,7 @@ Y_UNIT_TEST_SUITE(SqlToYQLErrors) { ); } - Y_UNIT_TEST(SelectComplexCaseWithoutThen) { + Y_UNIT_TEST(SelectComplexCaseWithoutThen) { NYql::TAstParseResult res = SqlToYql( "SELECT *\n" "FROM plato.Input AS a\n" @@ -1035,13 +1035,13 @@ Y_UNIT_TEST_SUITE(SqlToYQLErrors) { ); } - Y_UNIT_TEST(SelectCaseWithoutEnd) { + Y_UNIT_TEST(SelectCaseWithoutEnd) { NYql::TAstParseResult res = SqlToYql("select case a when b then c end from plato.Input"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:8: Error: ELSE is required\n"); } - Y_UNIT_TEST(SelectWithBadAggregationNoInput) { + Y_UNIT_TEST(SelectWithBadAggregationNoInput) { NYql::TAstParseResult res = SqlToYql("select a, Min(b), c"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:1: Error: Source does not allow column references\n" @@ -1049,31 +1049,31 @@ Y_UNIT_TEST_SUITE(SqlToYQLErrors) { "<main>:1:1: Error: Source does not allow column references\n"); } - Y_UNIT_TEST(SelectWithBadAggregation) { + Y_UNIT_TEST(SelectWithBadAggregation) { NYql::TAstParseResult res = SqlToYql("select count(*), key from plato.Input"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:18: Error: Expression has to be an aggregation function or key column, because aggregation is used elsewhere in this subquery\n"); } - Y_UNIT_TEST(SelectWithBadAggregatedTerms) { + Y_UNIT_TEST(SelectWithBadAggregatedTerms) { NYql::TAstParseResult res = SqlToYql("select key, subkey from plato.Input group by key"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:13: Error: Expression has to be an aggregation function or key column, because aggregation is used elsewhere in this subquery\n"); } - Y_UNIT_TEST(SelectWithBadAggregationInHaving) { + Y_UNIT_TEST(SelectWithBadAggregationInHaving) { NYql::TAstParseResult res = SqlToYql("select key from plato.Input group by key having value == \"foo\""); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:55: Error: Expression has to be an aggregation function or key column, because aggregation is used elsewhere in this subquery\n"); } - Y_UNIT_TEST(SelectWithDuplicateGroupingColumns) { + Y_UNIT_TEST(SelectWithDuplicateGroupingColumns) { NYql::TAstParseResult res = SqlToYql("select c from plato.Input group by c, c"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:8: Error: Duplicate grouping column: c\n"); } - Y_UNIT_TEST(SelectWithBadAggregationInGrouping) { + Y_UNIT_TEST(SelectWithBadAggregationInGrouping) { NYql::TAstParseResult res = SqlToYql("select a, Min(b), c group by c"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:1: Error: Source does not allow column references\n" @@ -1083,61 +1083,61 @@ Y_UNIT_TEST_SUITE(SqlToYQLErrors) { "<main>:1:1: Error: No aggregations were specified\n"); } - Y_UNIT_TEST(SelectWithOpOnBadAggregation) { + Y_UNIT_TEST(SelectWithOpOnBadAggregation) { NYql::TAstParseResult res = SqlToYql("select a + Min(b) from plato.Input"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:10: Error: Expression has to be an aggregation function or key column, because aggregation is used elsewhere in this subquery\n"); } - Y_UNIT_TEST(SelectOrderByConstantNum) { + Y_UNIT_TEST(SelectOrderByConstantNum) { NYql::TAstParseResult res = SqlToYql("select a from plato.Input order by 1"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:36: Error: Unable to ORDER BY constant expression\n"); } - Y_UNIT_TEST(SelectOrderByConstantExpr) { + Y_UNIT_TEST(SelectOrderByConstantExpr) { NYql::TAstParseResult res = SqlToYql("select a from plato.Input order by 1 * 42"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:38: Error: Unable to ORDER BY constant expression\n"); } - Y_UNIT_TEST(SelectOrderByConstantString) { + Y_UNIT_TEST(SelectOrderByConstantString) { NYql::TAstParseResult res = SqlToYql("select a from plato.Input order by \"nest\""); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:36: Error: Unable to ORDER BY constant expression\n"); } - Y_UNIT_TEST(SelectOrderByAggregated) { + Y_UNIT_TEST(SelectOrderByAggregated) { NYql::TAstParseResult res = SqlToYql("select a from plato.Input order by min(a)"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:36: Error: Unable to ORDER BY aggregated values\n"); } - Y_UNIT_TEST(ErrorInOrderByExpresison) { + Y_UNIT_TEST(ErrorInOrderByExpresison) { NYql::TAstParseResult res = SqlToYql("select key, value from plato.Input order by (key as zey)"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:45: Error: You should use in ORDER BY column name, qualified field, callable function or expression\n"); } - Y_UNIT_TEST(SelectAggregatedWhere) { + Y_UNIT_TEST(SelectAggregatedWhere) { NYql::TAstParseResult res = SqlToYql("select * from plato.Input where count(key)"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:33: Error: Can not use aggregated values in filtering\n"); } - Y_UNIT_TEST(DoubleFrom) { + Y_UNIT_TEST(DoubleFrom) { NYql::TAstParseResult res = SqlToYql("from plato.Input select * from plato.Input"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:27: Error: Only one FROM clause is allowed\n"); } - Y_UNIT_TEST(SelectJoinMissingCorrName) { + Y_UNIT_TEST(SelectJoinMissingCorrName) { NYql::TAstParseResult res = SqlToYql("select * from plato.Input1 as a join plato.Input2 as b on a.key == key"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:65: Error: JOIN: column requires correlation name\n"); } - Y_UNIT_TEST(SelectJoinEmptyCorrNames) { + Y_UNIT_TEST(SelectJoinEmptyCorrNames) { NYql::TAstParseResult res = SqlToYql( "$left = (SELECT * FROM plato.Input1 LIMIT 2);\n" "$right = (SELECT * FROM plato.Input2 LIMIT 2);\n" @@ -1147,25 +1147,25 @@ Y_UNIT_TEST_SUITE(SqlToYQLErrors) { UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:3:45: Error: At least one correlation name is required in join\n"); } - Y_UNIT_TEST(SelectJoinSameCorrNames) { + Y_UNIT_TEST(SelectJoinSameCorrNames) { NYql::TAstParseResult res = SqlToYql("SELECT Input.key FROM plato.Input JOIN plato.Input1 ON Input.key == Input.subkey\n"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:66: Error: JOIN: different correlation names are required for joined tables\n"); } - Y_UNIT_TEST(SelectJoinConstPredicateArg) { + Y_UNIT_TEST(SelectJoinConstPredicateArg) { NYql::TAstParseResult res = SqlToYql("SELECT * FROM plato.Input1 as A JOIN plato.Input2 as B ON A.key == B.key AND A.subkey == \"wtf\"\n"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:87: Error: JOIN: equality predicate arguments must not be constant\n"); } - Y_UNIT_TEST(SelectJoinNonEqualityPredicate) { + Y_UNIT_TEST(SelectJoinNonEqualityPredicate) { NYql::TAstParseResult res = SqlToYql("SELECT * FROM plato.Input1 as A JOIN plato.Input2 as B ON A.key == B.key AND A.subkey > B.subkey\n"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:87: Error: JOIN ON expression must be a conjunction of equality predicates\n"); } - Y_UNIT_TEST(SelectEquiJoinCorrNameOutOfScope) { + Y_UNIT_TEST(SelectEquiJoinCorrNameOutOfScope) { NYql::TAstParseResult res = SqlToYql( "PRAGMA equijoin;\n" "SELECT * FROM plato.A JOIN plato.B ON A.key == C.key JOIN plato.C ON A.subkey == C.subkey;\n" @@ -1174,7 +1174,7 @@ Y_UNIT_TEST_SUITE(SqlToYQLErrors) { UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:2:45: Error: JOIN: can not use source: C in equality predicate, it is out of current join scope\n"); } - Y_UNIT_TEST(SelectEquiJoinNoRightSource) { + Y_UNIT_TEST(SelectEquiJoinNoRightSource) { NYql::TAstParseResult res = SqlToYql( "PRAGMA equijoin;\n" "SELECT * FROM plato.A JOIN plato.B ON A.key == B.key JOIN plato.C ON A.subkey == B.subkey;\n" @@ -1183,91 +1183,91 @@ Y_UNIT_TEST_SUITE(SqlToYQLErrors) { UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:2:79: Error: JOIN ON equality predicate must have one of its arguments from the rightmost source\n"); } - Y_UNIT_TEST(InsertNoCluster) { + Y_UNIT_TEST(InsertNoCluster) { NYql::TAstParseResult res = SqlToYql("insert into Output (foo) values (1)"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:34: Error: No cluster name given and no default cluster is selected\n"); } - Y_UNIT_TEST(InsertValuesNoLabels) { + Y_UNIT_TEST(InsertValuesNoLabels) { NYql::TAstParseResult res = SqlToYql("insert into plato.Output values (1)"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:19: Error: INSERT INTO ... VALUES requires specification of table columns\n"); } - Y_UNIT_TEST(UpsertValuesNoLabelsKikimr) { + Y_UNIT_TEST(UpsertValuesNoLabelsKikimr) { NYql::TAstParseResult res = SqlToYql("upsert into plato.Output values (1)", 10, TString(NYql::KikimrProviderName)); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:19: Error: UPSERT INTO ... VALUES requires specification of table columns\n"); } - Y_UNIT_TEST(ReplaceValuesNoLabelsKikimr) { + Y_UNIT_TEST(ReplaceValuesNoLabelsKikimr) { NYql::TAstParseResult res = SqlToYql("replace into plato.Output values (1)", 10, TString(NYql::KikimrProviderName)); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:20: Error: REPLACE INTO ... VALUES requires specification of table columns\n"); } - Y_UNIT_TEST(InsertValuesInvalidLabels) { + Y_UNIT_TEST(InsertValuesInvalidLabels) { NYql::TAstParseResult res = SqlToYql("insert into plato.Output (foo) values (1, 2)"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:27: Error: VALUES have 2 columns, INSERT INTO expects: 1\n"); } - Y_UNIT_TEST(BuiltinFileOpNoArgs) { + Y_UNIT_TEST(BuiltinFileOpNoArgs) { NYql::TAstParseResult res = SqlToYql("select FilePath()"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:8: Error: FilePath() requires exactly 1 arguments, given: 0\n"); } - Y_UNIT_TEST(ProcessWithHaving) { + Y_UNIT_TEST(ProcessWithHaving) { NYql::TAstParseResult res = SqlToYql("process plato.Input using some::udf(value) having value == 1"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:15: Error: PROCESS does not allow HAVING yet! You may request it on yql@ maillist.\n"); } - Y_UNIT_TEST(ReduceNoBy) { + Y_UNIT_TEST(ReduceNoBy) { NYql::TAstParseResult res = SqlToYql("reduce plato.Input using some::udf(value)"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:19: Error: Unexpected token absence : Missing ON \n\n<main>:1:25: Error: Unexpected token absence : Missing USING \n\n"); } - Y_UNIT_TEST(ReduceDistinct) { + Y_UNIT_TEST(ReduceDistinct) { NYql::TAstParseResult res = SqlToYql("reduce plato.Input on key using some::udf(distinct value)"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:52: Error: REDUCE does not allow DISTINCT arguments\n"); } - Y_UNIT_TEST(ProcessMultipleRowsPlaceholders) { + Y_UNIT_TEST(ProcessMultipleRowsPlaceholders) { NYql::TAstParseResult res = SqlToYql("process plato.Input using some::udf($ROWS, $ROWS)"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:15: Error: Only single instance of $ROWS is allowed.\n"); } - Y_UNIT_TEST(ProcessRowInExpression) { + Y_UNIT_TEST(ProcessRowInExpression) { NYql::TAstParseResult res = SqlToYql("process plato.Input using some::udf($ROW + 1)"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:15: Error: $ROW can't be used as a part of expression.\n"); } - Y_UNIT_TEST(ProcessRowsInExpression) { + Y_UNIT_TEST(ProcessRowsInExpression) { NYql::TAstParseResult res = SqlToYql("process plato.Input using some::udf($ROWS + 1)"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:15: Error: $ROWS can't be used as a part of expression.\n"); } - Y_UNIT_TEST(ProcessRowsWithColumnAccess) { + Y_UNIT_TEST(ProcessRowsWithColumnAccess) { NYql::TAstParseResult res = SqlToYql("process plato.Input using some::udf(key, $ROWS)"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:15: Error: Source does not allow column references\n"); } - Y_UNIT_TEST(ProcessRowsWithRowAccess) { + Y_UNIT_TEST(ProcessRowsWithRowAccess) { NYql::TAstParseResult res = SqlToYql("process plato.Input using some::udf($ROWS, $ROW)"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:15: Error: Source does not allow column references\n"); } - Y_UNIT_TEST(ProcessRowsPlaceholderOutOfScope) { + Y_UNIT_TEST(ProcessRowsPlaceholderOutOfScope) { NYql::TAstParseResult res = SqlToYql( "$data = (process plato.Input using some::udf($ROWS));\n" "SELECT * FROM $ROWS;\n" @@ -1276,157 +1276,157 @@ Y_UNIT_TEST_SUITE(SqlToYQLErrors) { UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:2:15: Error: Unknown name: $ROWS\n"); } - Y_UNIT_TEST(ProcessWithInvalidSource) { + Y_UNIT_TEST(ProcessWithInvalidSource) { NYql::TAstParseResult res = SqlToYql("PROCESS $input USING YQL::AsList($ROWS);"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:9: Error: Unknown name: $input\n"); } - Y_UNIT_TEST(SelectWithUnknownBind) { + Y_UNIT_TEST(SelectWithUnknownBind) { NYql::TAstParseResult res = SqlToYql("select * from plato.Input where $value like 'Hell!';"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:33: Error: Unknown name: $value\n"); } - Y_UNIT_TEST(CreateTableWithView) { + Y_UNIT_TEST(CreateTableWithView) { NYql::TAstParseResult res = SqlToYql("CREATE TABLE plato.foo:bar (key INT);"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:22: Error: Unexpected token ':' : syntax error...\n\n"); } - Y_UNIT_TEST(CreateTableWithOptColumn) { + Y_UNIT_TEST(CreateTableWithOptColumn) { NYql::TAstParseResult res = SqlToYql("CREATE TABLE plato.foo (key \"Int32?\");"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:25: Error: CREATE TABLE clause requires non-optional column types in scheme\n"); } - Y_UNIT_TEST(AsteriskWithSomethingAfter) { + Y_UNIT_TEST(AsteriskWithSomethingAfter) { NYql::TAstParseResult res = SqlToYql("select *, LENGTH(value) from plato.Input;"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:8: Error: Unable to use general '*' with other columns, either specify concrete table like '<table>.*', either specify concrete columns.\n"); } - Y_UNIT_TEST(AsteriskWithSomethingBefore) { + Y_UNIT_TEST(AsteriskWithSomethingBefore) { NYql::TAstParseResult res = SqlToYql("select LENGTH(value), * from plato.Input;"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:23: Error: Unable to use general '*' with other columns, either specify concrete table like '<table>.*', either specify concrete columns.\n"); } - Y_UNIT_TEST(DuplicatedQualifiedAsterisk) { + Y_UNIT_TEST(DuplicatedQualifiedAsterisk) { NYql::TAstParseResult res = SqlToYql("select in.*, key, in.* from plato.Input as in;"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:19: Error: Unable to use twice same quialified asterisk. Invalid source: in\n"); } - Y_UNIT_TEST(BrokenLabel) { + Y_UNIT_TEST(BrokenLabel) { NYql::TAstParseResult res = SqlToYql("select in.*, key as [funny.label] from plato.Input as in;"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:14: Error: Unable to use '.' in column name. Invalid column name: funny.label\n"); } - Y_UNIT_TEST(KeyConflictDetect0) { + Y_UNIT_TEST(KeyConflictDetect0) { NYql::TAstParseResult res = SqlToYql("select key, in.key as key from plato.Input as in;"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:13: Error: Unable to use duplicate column names. Collision in name: key\n"); } - Y_UNIT_TEST(KeyConflictDetect1) { + Y_UNIT_TEST(KeyConflictDetect1) { NYql::TAstParseResult res = SqlToYql("select length(key) as key, key from plato.Input;"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:28: Error: Unable to use duplicate column names. Collision in name: key\n"); } - Y_UNIT_TEST(KeyConflictDetect2) { + Y_UNIT_TEST(KeyConflictDetect2) { NYql::TAstParseResult res = SqlToYql("select key, in.key from plato.Input as in;"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:1: Error: Duplicate column: key\n"); } - Y_UNIT_TEST(AutogenerationAliasWithCollisionConflict1) { + Y_UNIT_TEST(AutogenerationAliasWithCollisionConflict1) { NYql::TAstParseResult res = SqlToYql("select LENGTH(Value), key as column0 from plato.Input;"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:1: Error: Duplicate column: column0\n"); } - Y_UNIT_TEST(AutogenerationAliasWithCollisionConflict2) { + Y_UNIT_TEST(AutogenerationAliasWithCollisionConflict2) { NYql::TAstParseResult res = SqlToYql("select key as column1, LENGTH(Value) from plato.Input;"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:1: Error: Duplicate column: column1\n"); } - Y_UNIT_TEST(MissedSourceTableForQualifiedAsteriskOnSimpleSelect) { + Y_UNIT_TEST(MissedSourceTableForQualifiedAsteriskOnSimpleSelect) { NYql::TAstParseResult res = SqlToYql("use plato; select Intop.*, Input.key from plato.Input;"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:19: Error: Unknown correlation name: Intop\n"); } - Y_UNIT_TEST(MissedSourceTableForQualifiedAsteriskOnJoin) { + Y_UNIT_TEST(MissedSourceTableForQualifiedAsteriskOnJoin) { NYql::TAstParseResult res = SqlToYql("use plato; select tmissed.*, t2.*, t1.key from plato.Input as t1 join plato.Input as t2 on t1.key==t2.key;"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:19: Error: Unknown correlation name for asterisk: tmissed\n"); } - Y_UNIT_TEST(UnableToReferenceOnNotExistSubcolumn) { + Y_UNIT_TEST(UnableToReferenceOnNotExistSubcolumn) { NYql::TAstParseResult res = SqlToYql("select b.subkey from (select key from plato.Input as a) as b;"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:8: Error: Column subkey is not in source column set\n"); } - Y_UNIT_TEST(ConflictOnSameNameWithQualify0) { + Y_UNIT_TEST(ConflictOnSameNameWithQualify0) { NYql::TAstParseResult res = SqlToYql("select in.key, in.key as key from plato.Input as in;"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:1: Error: Duplicate column: key\n"); } - Y_UNIT_TEST(ConflictOnSameNameWithQualify1) { + Y_UNIT_TEST(ConflictOnSameNameWithQualify1) { NYql::TAstParseResult res = SqlToYql("select in.key, length(key) as key from plato.Input as in;"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:1: Error: Duplicate column: key\n"); } - Y_UNIT_TEST(ConflictOnSameNameWithQualify2) { + Y_UNIT_TEST(ConflictOnSameNameWithQualify2) { NYql::TAstParseResult res = SqlToYql("select key, in.key from plato.Input as in;"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:1: Error: Duplicate column: key\n"); } - Y_UNIT_TEST(ConflictOnSameNameWithQualify3) { + Y_UNIT_TEST(ConflictOnSameNameWithQualify3) { NYql::TAstParseResult res = SqlToYql("select in.key, subkey as key from plato.Input as in;"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:1: Error: Duplicate column: key\n"); } - Y_UNIT_TEST(SelectOrderByUnknownLabel) { + Y_UNIT_TEST(SelectOrderByUnknownLabel) { NYql::TAstParseResult res = SqlToYql("select a from plato.Input order by b"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:36: Error: Column b is not in source column set. Did you mean a?\n"); } - Y_UNIT_TEST(SelectFlattenBySameColumns) { + Y_UNIT_TEST(SelectFlattenBySameColumns) { NYql::TAstParseResult res = SqlToYql("select key from plato.Input flatten by (key, key as kk)"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:46: Error: Duplicate column name found: key in FlattenBy section\n"); } - Y_UNIT_TEST(SelectFlattenBySameAliases) { + Y_UNIT_TEST(SelectFlattenBySameAliases) { NYql::TAstParseResult res = SqlToYql("select key from plato.Input flatten by (key as kk, subkey as kk);"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:52: Error: Duplicate alias found: kk in FlattenBy section\n"); } - Y_UNIT_TEST(SelectFlattenByConflictNameAndAlias0) { + Y_UNIT_TEST(SelectFlattenByConflictNameAndAlias0) { NYql::TAstParseResult res = SqlToYql("select key from plato.Input flatten by (key, subkey as key);"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:46: Error: Collision between alias and column name: key in FlattenBy section\n"); } - Y_UNIT_TEST(SelectFlattenByConflictNameAndAlias1) { + Y_UNIT_TEST(SelectFlattenByConflictNameAndAlias1) { NYql::TAstParseResult res = SqlToYql("select key from plato.Input flatten by (key as kk, subkey as key);"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:52: Error: Collision between alias and column name: key in FlattenBy section\n"); } - Y_UNIT_TEST(UseInOnStrings) { + Y_UNIT_TEST(UseInOnStrings) { NYql::TAstParseResult res = SqlToYql("select * from plato.Input where \"foo\" in \"foovalue\";"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:42: Error: Unable to use IN predicate with string argument, it won't search substring - " @@ -1446,7 +1446,7 @@ Y_UNIT_TEST_SUITE(SqlToYQLErrors) { UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:58: Error: Unknown builtin: COMPACT, to use YQL functions, try YQL::COMPACT\n"); } - Y_UNIT_TEST(ErrorColumnPosition) { + Y_UNIT_TEST(ErrorColumnPosition) { NYql::TAstParseResult res = SqlToYql( "USE plato;\n" "SELECT \n" @@ -1458,121 +1458,121 @@ Y_UNIT_TEST_SUITE(SqlToYQLErrors) { UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:3:1: Error: Column value is not in source column set\n"); } - Y_UNIT_TEST(InsertAbortMapReduce) { + Y_UNIT_TEST(InsertAbortMapReduce) { NYql::TAstParseResult res = SqlToYql("INSERT OR ABORT INTO plato.Output SELECT key FROM plato.Input"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:0: Error: INSERT OR ABORT INTO is not supported for yt tables\n"); } - Y_UNIT_TEST(ReplaceIntoMapReduce) { + Y_UNIT_TEST(ReplaceIntoMapReduce) { NYql::TAstParseResult res = SqlToYql("REPLACE INTO plato.Output SELECT key FROM plato.Input"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:0: Error: Meaning of REPLACE INTO has been changed, now you should use INSERT INTO <table> WITH TRUNCATE ... for yt\n"); } - Y_UNIT_TEST(UpsertIntoMapReduce) { + Y_UNIT_TEST(UpsertIntoMapReduce) { NYql::TAstParseResult res = SqlToYql("UPSERT INTO plato.Output SELECT key FROM plato.Input"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:0: Error: UPSERT INTO is not supported for yt tables\n"); } - Y_UNIT_TEST(UpdateMapReduce) { + Y_UNIT_TEST(UpdateMapReduce) { NYql::TAstParseResult res = SqlToYql("UPDATE plato.Output SET value = value + 1 WHERE key < 1"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:0: Error: UPDATE is unsupported for yt\n"); } - Y_UNIT_TEST(DeleteMapReduce) { + Y_UNIT_TEST(DeleteMapReduce) { NYql::TAstParseResult res = SqlToYql("DELETE FROM plato.Output WHERE key < 1"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:0: Error: DELETE is unsupported for yt\n"); } - Y_UNIT_TEST(ReplaceIntoWithTruncate) { + Y_UNIT_TEST(ReplaceIntoWithTruncate) { NYql::TAstParseResult res = SqlToYql("REPLACE INTO plato.Output WITH TRUNCATE SELECT key FROM plato.Input"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:32: Error: Unable REPLACE INTO with truncate mode\n"); } - Y_UNIT_TEST(UpsertIntoWithTruncate) { + Y_UNIT_TEST(UpsertIntoWithTruncate) { NYql::TAstParseResult res = SqlToYql("UPSERT INTO plato.Output WITH TRUNCATE SELECT key FROM plato.Input"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:31: Error: Unable UPSERT INTO with truncate mode\n"); } - Y_UNIT_TEST(InsertIntoWithTruncateKikimr) { + Y_UNIT_TEST(InsertIntoWithTruncateKikimr) { NYql::TAstParseResult res = SqlToYql("INSERT INTO plato.Output WITH TRUNCATE SELECT key FROM plato.Input", 10, TString(NYql::KikimrProviderName)); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:0: Error: INSERT INTO WITH TRUNCATE is not supported for kikimr tables\n"); } - Y_UNIT_TEST(InsertIntoWithWrongArgumentCount) { + Y_UNIT_TEST(InsertIntoWithWrongArgumentCount) { NYql::TAstParseResult res = SqlToYql("insert into plato.Output with truncate (key, value, subkey) values (5, '1', '2', '3');"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:53: Error: VALUES have 4 columns, INSERT INTO ... WITH TRUNCATE expects: 3\n"); } - Y_UNIT_TEST(UpsertWithWrongArgumentCount) { + Y_UNIT_TEST(UpsertWithWrongArgumentCount) { NYql::TAstParseResult res = SqlToYql("upsert into plato.Output (key, value, subkey) values (2, '3');", 10, TString(NYql::KikimrProviderName)); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:39: Error: VALUES have 2 columns, UPSERT INTO expects: 3\n"); } - Y_UNIT_TEST(UnionNotSupported) { + Y_UNIT_TEST(UnionNotSupported) { NYql::TAstParseResult res = SqlToYql("SELECT key FROM plato.Input UNION select subkey FROM plato.Input;"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:29: Error: UNION without quantifier ALL is not supported yet. Did you mean UNION ALL?\n"); } - Y_UNIT_TEST(GroupingSetByExprWithoutAlias) { + Y_UNIT_TEST(GroupingSetByExprWithoutAlias) { NYql::TAstParseResult res = SqlToYql("SELECT key FROM plato.Input GROUP BY GROUPING SETS (cast(key as uint32), subkey);"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:74: Error: You should use in GROUPING SETS either expression with required alias either column name or used alias.\n"); } - Y_UNIT_TEST(CubeByExprWithoutAlias) { + Y_UNIT_TEST(CubeByExprWithoutAlias) { NYql::TAstParseResult res = SqlToYql("SELECT key FROM plato.Input GROUP BY CUBE (key, subkey / key);"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:58: Error: You should use in CUBE either expression with required alias either column name or used alias.\n"); } - Y_UNIT_TEST(RollupByExprWithoutAlias) { + Y_UNIT_TEST(RollupByExprWithoutAlias) { NYql::TAstParseResult res = SqlToYql("SELECT key FROM plato.Input GROUP BY ROLLUP (subkey / key);"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:55: Error: You should use in ROLLUP either expression with required alias either column name or used alias.\n"); } - Y_UNIT_TEST(GroupByHugeCubeDeniedNoPragma) { + Y_UNIT_TEST(GroupByHugeCubeDeniedNoPragma) { NYql::TAstParseResult res = SqlToYql("SELECT key FROM plato.Input GROUP BY CUBE (key, subkey, value, key + subkey as sum, key - subkey as sub, key + val as keyval);"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:119: Error: GROUP BY CUBE is allowed only for 5 columns, but you use 6\n"); } - Y_UNIT_TEST(GroupByInvalidPragma) { + Y_UNIT_TEST(GroupByInvalidPragma) { NYql::TAstParseResult res = SqlToYql("PRAGMA GroupByCubeLimit = '-4';"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:8: Error: Expected single unsigned integer argument for: GroupByCubeLimit\n"); } - Y_UNIT_TEST(GroupByHugeCubeDeniedPragme) { + Y_UNIT_TEST(GroupByHugeCubeDeniedPragme) { NYql::TAstParseResult res = SqlToYql("PRAGMA GroupByCubeLimit = '4'; SELECT key FROM plato.Input GROUP BY CUBE (key, subkey, value, key + subkey as sum, key - subkey as sub);"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:132: Error: GROUP BY CUBE is allowed only for 4 columns, but you use 5\n"); } - Y_UNIT_TEST(GroupByFewBigCubes) { + Y_UNIT_TEST(GroupByFewBigCubes) { NYql::TAstParseResult res = SqlToYql("SELECT key FROM plato.Input GROUP BY CUBE(key, subkey, key + subkey as sum), CUBE(value, value + key + subkey as total);"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:1: Error: Unable to GROUP BY more than 32 groups, you try use 80 groups\n"); } - Y_UNIT_TEST(GroupByFewBigCubesWithPragmaLimit) { + Y_UNIT_TEST(GroupByFewBigCubesWithPragmaLimit) { NYql::TAstParseResult res = SqlToYql("PRAGMA GroupByLimit = '16'; SELECT key FROM plato.Input GROUP BY GROUPING SETS(key, subkey, key + subkey as sum), ROLLUP(value, value + key + subkey as total);"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:29: Error: Unable to GROUP BY more than 16 groups, you try use 18 groups\n"); } - Y_UNIT_TEST(NoGroupingColumn0) { + Y_UNIT_TEST(NoGroupingColumn0) { NYql::TAstParseResult res = SqlToYql( "select count(1), key_first, val_first, grouping(key_first, val_first, nomind) as group\n" "from plato.Input group by grouping sets (cast(key as uint32) /100 as key_first, Substring(value, 1, 1) as val_first);"); @@ -1580,37 +1580,37 @@ Y_UNIT_TEST_SUITE(SqlToYQLErrors) { UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:71: Error: Column 'nomind' not used as grouping column\n"); } - Y_UNIT_TEST(NoGroupingColumn1) { + Y_UNIT_TEST(NoGroupingColumn1) { NYql::TAstParseResult res = SqlToYql("select count(1), grouping(key, value) as group_duo from plato.Input group by cube (key, subkey);"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:32: Error: Column 'value' not used as grouping column\n"); } - Y_UNIT_TEST(EmptyAccess0) { + Y_UNIT_TEST(EmptyAccess0) { NYql::TAstParseResult res = SqlToYql("insert into plato.Output (list0, list1) values (AsList(0, 1, 2), AsList([]));"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:34: Error: Source does not allow column references\n"); } - Y_UNIT_TEST(EmptyAccess1) { + Y_UNIT_TEST(EmptyAccess1) { NYql::TAstParseResult res = SqlToYql("insert into plato.Output (list0, list1) values (AsList(0, 1, 2), []);"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:34: Error: Source does not allow column references\n"); } - Y_UNIT_TEST(UseUnknownColumnInInsert) { + Y_UNIT_TEST(UseUnknownColumnInInsert) { NYql::TAstParseResult res = SqlToYql("insert into plato.Output (list0, list1) values (AsList(0, 1, 2), AsList([test]));"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:34: Error: Source does not allow column references\n"); } - Y_UNIT_TEST(GroupByEmptyColumn) { + Y_UNIT_TEST(GroupByEmptyColumn) { NYql::TAstParseResult res = SqlToYql("select count(1) from plato.Input group by [];"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:43: Error: Column name can not be empty\n"); } - Y_UNIT_TEST(RollbackUnsupported) { + Y_UNIT_TEST(RollbackUnsupported) { NYql::TAstParseResult res = SqlToYql("insert into plato.Output (v0, v1) values (0, 1); rollback;"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:50: Error: ROLLBACK isn't supported for provider: yt\n"); @@ -1625,49 +1625,49 @@ Y_UNIT_TEST_SUITE(SqlToYQLErrors) { ); } - Y_UNIT_TEST(ConvertNumberFailed0) { + Y_UNIT_TEST(ConvertNumberFailed0) { NYql::TAstParseResult res = SqlToYql("select 0o80l;"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:8: Error: Failed to parse number from string: 0o80l, char: '8' is out of base: 8\n"); } - Y_UNIT_TEST(ConvertNumberFailed1) { + Y_UNIT_TEST(ConvertNumberFailed1) { NYql::TAstParseResult res = SqlToYql("select 0xc000000000000000l;"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:8: Error: Failed to convert string: 13835058055282163712 to Int64 value\n"); } - Y_UNIT_TEST(ConvertNumberFailed2) { + Y_UNIT_TEST(ConvertNumberFailed2) { NYql::TAstParseResult res = SqlToYql("select 0xc0000000000000000l;"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:8: Error: Failed to parse number from string: 0xc0000000000000000l, number limit overflow\n"); } - Y_UNIT_TEST(InvaildUsageReal0) { + Y_UNIT_TEST(InvaildUsageReal0) { NYql::TAstParseResult res = SqlToYql("select .0;"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:7: Error: Unexpected token '.' : cannot match to any predicted input...\n\n"); } - Y_UNIT_TEST(InvaildUsageReal1) { + Y_UNIT_TEST(InvaildUsageReal1) { NYql::TAstParseResult res = SqlToYql("select .0f;"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:7: Error: Unexpected token '.' : cannot match to any predicted input...\n\n"); } - Y_UNIT_TEST(InvaildUsageWinFunctionWithoutWindow) { + Y_UNIT_TEST(InvaildUsageWinFunctionWithoutWindow) { NYql::TAstParseResult res = SqlToYql("select lead(key, 2) from plato.Input;"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:8: Error: Failed to use window function: Lead without window specification\n"); } - Y_UNIT_TEST(DropTableWithIfExists) { + Y_UNIT_TEST(DropTableWithIfExists) { NYql::TAstParseResult res = SqlToYql("DROP TABLE IF EXISTS plato.foo;"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:0: Error: IF EXISTS in DROP TABLE is not supported.\n"); } - Y_UNIT_TEST(TooManyErrors) { + Y_UNIT_TEST(TooManyErrors) { const char* q = R"( USE plato; $a1 = A; @@ -1696,7 +1696,7 @@ Y_UNIT_TEST_SUITE(SqlToYQLErrors) { )"); } - Y_UNIT_TEST(ShouldCloneBindingForNamedParameter) { + Y_UNIT_TEST(ShouldCloneBindingForNamedParameter) { NYql::TAstParseResult res = SqlToYql(R"( $f = () -> { $value_type = TypeOf(1); diff --git a/ydb/library/yql/sql/v1/builtin.cpp b/ydb/library/yql/sql/v1/builtin.cpp index 43ef1243f10..4fe932b4f75 100644 --- a/ydb/library/yql/sql/v1/builtin.cpp +++ b/ydb/library/yql/sql/v1/builtin.cpp @@ -2060,7 +2060,7 @@ public: } TAstNode* Translate(TContext& ctx) const override { - Y_VERIFY_DEBUG(Node); + Y_VERIFY_DEBUG(Node); return Node->Translate(ctx); } @@ -2167,8 +2167,8 @@ public: } TAstNode* Translate(TContext& ctx) const override { - Y_UNUSED(ctx); - Y_VERIFY_DEBUG(Node); + Y_UNUSED(ctx); + Y_VERIFY_DEBUG(Node); return Node->Translate(ctx); } diff --git a/ydb/library/yql/sql/v1/context.cpp b/ydb/library/yql/sql/v1/context.cpp index c08fe96caeb..618ee9f126d 100644 --- a/ydb/library/yql/sql/v1/context.cpp +++ b/ydb/library/yql/sql/v1/context.cpp @@ -466,7 +466,7 @@ TContext& TTranslation::Context() { return Ctx; } -IOutputStream& TTranslation::Error() { +IOutputStream& TTranslation::Error() { return Ctx.Error(); } @@ -489,11 +489,11 @@ TString TTranslation::PushNamedNode(TPosition namePos, const TString& name, cons YQL_ENSURE(Ctx.Scoped->NamedNodes.find(resultName) == Ctx.Scoped->NamedNodes.end()); } auto node = builder(resultName); - Y_VERIFY_DEBUG(node); + Y_VERIFY_DEBUG(node); auto mapIt = Ctx.Scoped->NamedNodes.find(resultName); if (mapIt == Ctx.Scoped->NamedNodes.end()) { auto result = Ctx.Scoped->NamedNodes.insert(std::make_pair(resultName, TDeque<TNodeWithUsageInfoPtr>())); - Y_VERIFY_DEBUG(result.second); + Y_VERIFY_DEBUG(result.second); mapIt = result.first; } @@ -515,7 +515,7 @@ TString TTranslation::PushNamedAtom(TPosition namePos, const TString& name) { void TTranslation::PopNamedNode(const TString& name) { auto mapIt = Ctx.Scoped->NamedNodes.find(name); Y_VERIFY_DEBUG(mapIt != Ctx.Scoped->NamedNodes.end()); - Y_VERIFY_DEBUG(mapIt->second.size() > 0); + Y_VERIFY_DEBUG(mapIt->second.size() > 0); auto& top = mapIt->second.front(); if (!top->IsUsed && !Ctx.HasPendingErrors && !name.StartsWith("$_")) { Ctx.Warning(top->NamePos, TIssuesIds::YQL_UNUSED_SYMBOL) << "Symbol " << name << " is not used"; diff --git a/ydb/library/yql/sql/v1/context.h b/ydb/library/yql/sql/v1/context.h index 89517574862..5dee76c655f 100644 --- a/ydb/library/yql/sql/v1/context.h +++ b/ydb/library/yql/sql/v1/context.h @@ -302,7 +302,7 @@ namespace NSQLTranslationV1 { public: TContext& Context(); - IOutputStream& Error(); + IOutputStream& Error(); template <typename TToken> const TString& Token(const TToken& token) { diff --git a/ydb/library/yql/sql/v1/insert.cpp b/ydb/library/yql/sql/v1/insert.cpp index 4f4c8630181..11cef4c383a 100644 --- a/ydb/library/yql/sql/v1/insert.cpp +++ b/ydb/library/yql/sql/v1/insert.cpp @@ -28,13 +28,13 @@ public: } bool AddFilter(TContext& ctx, TNodePtr filter) override { - Y_UNUSED(filter); + Y_UNUSED(filter); ctx.Error(Pos) << "Source does not allow filtering"; return false; } bool AddGroupKey(TContext& ctx, const TString& column) override { - Y_UNUSED(column); + Y_UNUSED(column); ctx.Error(Pos) << "Source does not allow grouping"; return false; } @@ -47,12 +47,12 @@ public: TNodePtr BuildFilter(TContext& ctx, const TString& label) override { Y_UNUSED(ctx); - Y_UNUSED(label); + Y_UNUSED(label); return nullptr; } TNodePtr BuildAggregation(const TString& label) override { - Y_UNUSED(label); + Y_UNUSED(label); return nullptr; } diff --git a/ydb/library/yql/sql/v1/node.cpp b/ydb/library/yql/sql/v1/node.cpp index 870bbd9cc7f..351f6070108 100644 --- a/ydb/library/yql/sql/v1/node.cpp +++ b/ydb/library/yql/sql/v1/node.cpp @@ -37,7 +37,7 @@ TTableRef::TTableRef(const TString& refName, const TString& service, const TDefe } TString TTableRef::ShortName() const { - Y_VERIFY_DEBUG(Keys); + Y_VERIFY_DEBUG(Keys); if (Keys->GetTableKeys()->GetTableName()) { return *Keys->GetTableKeys()->GetTableName(); } @@ -157,7 +157,7 @@ TString INode::GetOpName() const { } const TString* INode::GetLiteral(const TString& type) const { - Y_UNUSED(type); + Y_UNUSED(type); return nullptr; } @@ -217,8 +217,8 @@ bool INode::Init(TContext& ctx, ISource* src) { } bool INode::DoInit(TContext& ctx, ISource* src) { - Y_UNUSED(ctx); - Y_UNUSED(src); + Y_UNUSED(ctx); + Y_UNUSED(src); return true; } @@ -304,7 +304,7 @@ void INode::VisitTree(const TVisitFunc& func, TVisitNodeSet& visited) const { } TNodePtr INode::ShallowCopy() const { - Y_VERIFY_DEBUG(false, "Node is not copyable"); + Y_VERIFY_DEBUG(false, "Node is not copyable"); return nullptr; } @@ -332,8 +332,8 @@ void INode::DoVisitChildren(const TVisitFunc& func, TVisitNodeSet& visited) cons } void INode::DoAdd(TNodePtr node) { - Y_UNUSED(node); - Y_VERIFY_DEBUG(false, "Node is not expandable"); + Y_UNUSED(node); + Y_VERIFY_DEBUG(false, "Node is not expandable"); } void MergeHints(TTableHints& base, const TTableHints& overrides) { @@ -377,7 +377,7 @@ TAstDirectNode::TAstDirectNode(TAstNode* node) } TAstNode* TAstDirectNode::Translate(TContext& ctx) const { - Y_UNUSED(ctx); + Y_UNUSED(ctx); return Node; } @@ -485,8 +485,8 @@ TNodePtr TAstListNode::ShallowCopy() const { } void TAstListNode::DoAdd(TNodePtr node) { - Y_VERIFY_DEBUG(node); - Y_VERIFY_DEBUG(node.Get() != this); + Y_VERIFY_DEBUG(node); + Y_VERIFY_DEBUG(node.Get() != this); Nodes.push_back(node); } @@ -1193,8 +1193,8 @@ ITableKeys* ITableKeys::GetTableKeys() { } TAstNode* ITableKeys::Translate(TContext& ctx) const { - Y_VERIFY_DEBUG(false); - Y_UNUSED(ctx); + Y_VERIFY_DEBUG(false); + Y_UNUSED(ctx); return nullptr; } @@ -1232,8 +1232,8 @@ IAggregation::IAggregation(TPosition pos, const TString& name, const TString& fu {} TAstNode* IAggregation::Translate(TContext& ctx) const { - Y_VERIFY_DEBUG(false); - Y_UNUSED(ctx); + Y_VERIFY_DEBUG(false); + Y_UNUSED(ctx); return nullptr; } @@ -1312,7 +1312,7 @@ void ISource::FinishColumns() { bool ISource::AddFilter(TContext& ctx, TNodePtr filter) { - Y_UNUSED(ctx); + Y_UNUSED(ctx); Filters.push_back(filter); return true; } @@ -2046,8 +2046,8 @@ bool ISource::InitFilters(TContext& ctx) { } TAstNode* ISource::Translate(TContext& ctx) const { - Y_VERIFY_DEBUG(false); - Y_UNUSED(ctx); + Y_VERIFY_DEBUG(false); + Y_UNUSED(ctx); return nullptr; } @@ -2174,8 +2174,8 @@ StringContentInternal(TContext& ctx, TPosition pos, const TString& input, EStrin return {}; } - bool doubleQuoted = (str.StartsWith('"') && str.EndsWith('"')); - bool singleQuoted = !doubleQuoted && (str.StartsWith('\'') && str.EndsWith('\'')); + bool doubleQuoted = (str.StartsWith('"') && str.EndsWith('"')); + bool singleQuoted = !doubleQuoted && (str.StartsWith('\'') && str.EndsWith('\'')); if (str.size() >= 2 && (doubleQuoted || singleQuoted)) { result.Flags = NYql::TNodeFlags::ArbitraryContent; @@ -2189,7 +2189,7 @@ StringContentInternal(TContext& ctx, TPosition pos, const TString& input, EStrin return {}; } } - } else if (str.size() >= 4 && str.StartsWith("@@") && str.EndsWith("@@")) { + } else if (str.size() >= 4 && str.StartsWith("@@") && str.EndsWith("@@")) { result.Flags = TNodeFlags::MultilineContent; TString s = str.substr(2, str.length() - 4); SubstGlobal(s, "@@@@", "@@"); @@ -2733,8 +2733,8 @@ public: , IsColumnRequired(false) , AccessOpName("AccessNode") { - Y_VERIFY_DEBUG(Ids.size() > 1); - Y_VERIFY_DEBUG(Ids[0].Expr); + Y_VERIFY_DEBUG(Ids.size() > 1); + Y_VERIFY_DEBUG(Ids[0].Expr); auto column = dynamic_cast<TColumnNode*>(Ids[0].Expr.Get()); if (column) { ui32 idx = 1; @@ -2847,7 +2847,7 @@ public: } TAstNode* Translate(TContext& ctx) const override { - Y_VERIFY_DEBUG(Node); + Y_VERIFY_DEBUG(Node); return Node->Translate(ctx); } @@ -3116,7 +3116,7 @@ TNodePtr BuildSimpleType(TContext& ctx, TPosition pos, const TString& typeName, TString TypeByAlias(const TString& alias, bool normalize) { TString type(alias); TCiString typeAlias(alias); - if (typeAlias.StartsWith("varchar")) { + if (typeAlias.StartsWith("varchar")) { type = "String"; } else if (typeAlias == "tinyint") { type = "Int8"; diff --git a/ydb/library/yql/sql/v1/node.h b/ydb/library/yql/sql/v1/node.h index de82b45a238..47b735fbaee 100644 --- a/ydb/library/yql/sql/v1/node.h +++ b/ydb/library/yql/sql/v1/node.h @@ -208,7 +208,7 @@ namespace NSQLTranslationV1 { template <typename... TVals> TPtr L(TPtr list, TVals... vals) const { - Y_VERIFY_DEBUG(list); + Y_VERIFY_DEBUG(list); auto copy = list->ShallowCopy(); copy->Add(vals...); return copy; diff --git a/ydb/library/yql/sql/v1/select.cpp b/ydb/library/yql/sql/v1/select.cpp index 2841f05a5b5..4119ccc9921 100644 --- a/ydb/library/yql/sql/v1/select.cpp +++ b/ydb/library/yql/sql/v1/select.cpp @@ -142,7 +142,7 @@ public: } TAstNode* Translate(TContext& ctx) const override { - Y_VERIFY_DEBUG(Node); + Y_VERIFY_DEBUG(Node); return Node->Translate(ctx); } @@ -182,19 +182,19 @@ public: } bool AddFilter(TContext& ctx, TNodePtr filter) override { - Y_UNUSED(filter); + Y_UNUSED(filter); auto pos = filter ? filter->GetPos() : Pos; ctx.Error(pos) << (MissingFrom ? "Filtering is not allowed without FROM" : "Source does not allow filtering"); return false; } TNodePtr Build(TContext& ctx) override { - Y_UNUSED(ctx); + Y_UNUSED(ctx); return Y("AsList", Y("AsStruct")); } bool AddGroupKey(TContext& ctx, const TString& column) override { - Y_UNUSED(column); + Y_UNUSED(column); ctx.Error(Pos) << "Grouping is not allowed " << (MissingFrom ? "without FROM" : "in this context"); return false; } @@ -232,12 +232,12 @@ public: TNodePtr BuildFilter(TContext& ctx, const TString& label) override { Y_UNUSED(ctx); - Y_UNUSED(label); + Y_UNUSED(label); return nullptr; } TNodePtr BuildAggregation(const TString& label) override { - Y_UNUSED(label); + Y_UNUSED(label); return nullptr; } @@ -339,12 +339,12 @@ protected: {} void AllColumns() override { - Y_VERIFY_DEBUG(Source); + Y_VERIFY_DEBUG(Source); return Source->AllColumns(); } const TColumns* GetColumns() const override { - Y_VERIFY_DEBUG(Source); + Y_VERIFY_DEBUG(Source); return Source->GetColumns(); } @@ -354,7 +354,7 @@ protected: } TMaybe<bool> AddColumn(TContext& ctx, TColumnNode& column) override { - Y_VERIFY_DEBUG(Source); + Y_VERIFY_DEBUG(Source); const TString label(Source->GetLabel()); Source->SetLabel(Label); const auto ret = Source->AddColumn(ctx, column); @@ -856,7 +856,7 @@ public: } TNodePtr Build(TContext& ctx) override { - Y_UNUSED(ctx); + Y_UNUSED(ctx); return NewSource ? NewSource->Build(ctx) : Node; } diff --git a/ydb/library/yql/sql/v1/sql.cpp b/ydb/library/yql/sql/v1/sql.cpp index ab5a8647885..566fbcae6a9 100644 --- a/ydb/library/yql/sql/v1/sql.cpp +++ b/ydb/library/yql/sql/v1/sql.cpp @@ -5657,7 +5657,7 @@ bool TSqlSelect::JoinOp(ISource* join, const TRule_join_source::TBlock3& block, return false; } - Y_VERIFY_DEBUG(join->GetJoin()); + Y_VERIFY_DEBUG(join->GetJoin()); join->GetJoin()->SetupJoin(joinOp, joinKeyExpr, linkSettings); break; } @@ -5687,7 +5687,7 @@ TNodePtr TSqlSelect::JoinExpr(ISource* join, const TRule_join_constraint& node) return nullptr; } - Y_VERIFY_DEBUG(join->GetJoin()); + Y_VERIFY_DEBUG(join->GetJoin()); return join->GetJoin()->BuildJoinKeys(Ctx, names); } default: diff --git a/ydb/library/yql/sql/v1/sql_ut.cpp b/ydb/library/yql/sql/v1/sql_ut.cpp index 85b6e0dfcd3..b0cb875309d 100644 --- a/ydb/library/yql/sql/v1/sql_ut.cpp +++ b/ydb/library/yql/sql/v1/sql_ut.cpp @@ -153,12 +153,12 @@ Y_UNIT_TEST_SUITE(AnsiMode) { } } -Y_UNIT_TEST_SUITE(SqlParsingOnly) { +Y_UNIT_TEST_SUITE(SqlParsingOnly) { Y_UNIT_TEST(CoverColumnName) { UNIT_ASSERT(SqlToYql("SELECT cover FROM plato.Input").IsOk()); } - Y_UNIT_TEST(TableHints) { + Y_UNIT_TEST(TableHints) { UNIT_ASSERT(SqlToYql("SELECT * FROM plato.Input WITH INFER_SCHEMA").IsOk()); UNIT_ASSERT(SqlToYql("SELECT * FROM plato.Input WITH (INFER_SCHEMA)").IsOk()); } @@ -218,12 +218,12 @@ Y_UNIT_TEST_SUITE(SqlParsingOnly) { UNIT_ASSERT(SqlToYql("USE plato; SELECT ASYNC FROM ASYNC").IsOk()); } - Y_UNIT_TEST(Jubilee) { + Y_UNIT_TEST(Jubilee) { NYql::TAstParseResult res = SqlToYql("USE plato; INSERT INTO Arcadia (r2000000) VALUES (\"2M GET!!!\");"); UNIT_ASSERT(res.Root); } - Y_UNIT_TEST(QualifiedAsteriskBefore) { + Y_UNIT_TEST(QualifiedAsteriskBefore) { NYql::TAstParseResult res = SqlToYql( "PRAGMA DisableSimpleColumns;" "select interested_table.*, LENGTH(value) AS megahelpful_len from plato.Input as interested_table;" @@ -248,7 +248,7 @@ Y_UNIT_TEST_SUITE(SqlParsingOnly) { UNIT_ASSERT_VALUES_EQUAL(1, elementStat["SqlProjectStarItem"]); } - Y_UNIT_TEST(QualifiedAsteriskAfter) { + Y_UNIT_TEST(QualifiedAsteriskAfter) { NYql::TAstParseResult res = SqlToYql( "PRAGMA DisableSimpleColumns;" "select LENGTH(value) AS megahelpful_len, interested_table.* from plato.Input as interested_table;" @@ -273,7 +273,7 @@ Y_UNIT_TEST_SUITE(SqlParsingOnly) { UNIT_ASSERT_VALUES_EQUAL(1, elementStat["SqlProjectStarItem"]); } - Y_UNIT_TEST(QualifiedMembers) { + Y_UNIT_TEST(QualifiedMembers) { NYql::TAstParseResult res = SqlToYql("select interested_table.key, interested_table.value from plato.Input as interested_table;"); UNIT_ASSERT(res.Root); @@ -295,7 +295,7 @@ Y_UNIT_TEST_SUITE(SqlParsingOnly) { UNIT_ASSERT_VALUES_EQUAL(1, elementStat["Write!"]); } - Y_UNIT_TEST(JoinParseCorrect) { + Y_UNIT_TEST(JoinParseCorrect) { NYql::TAstParseResult res = SqlToYql( "PRAGMA DisableSimpleColumns;" " SELECT table_bb.*, table_aa.key as megakey" @@ -324,7 +324,7 @@ Y_UNIT_TEST_SUITE(SqlParsingOnly) { UNIT_ASSERT_VALUES_EQUAL(1, elementStat["SqlColumn"]); } - Y_UNIT_TEST(Join3Table) { + Y_UNIT_TEST(Join3Table) { NYql::TAstParseResult res = SqlToYql( " PRAGMA DisableSimpleColumns;" " SELECT table_bb.*, table_aa.key as gigakey, table_cc.* " @@ -356,7 +356,7 @@ Y_UNIT_TEST_SUITE(SqlParsingOnly) { UNIT_ASSERT_VALUES_EQUAL(1, elementStat["SqlColumn"]); } - Y_UNIT_TEST(JoinWithoutConcreteColumns) { + Y_UNIT_TEST(JoinWithoutConcreteColumns) { NYql::TAstParseResult res = SqlToYql( " use plato;" " SELECT a.v, b.value" @@ -387,7 +387,7 @@ Y_UNIT_TEST_SUITE(SqlParsingOnly) { UNIT_ASSERT_VALUES_EQUAL(2, elementStat["SqlColumn"]); } - Y_UNIT_TEST(JoinWithSameValues) { + Y_UNIT_TEST(JoinWithSameValues) { NYql::TAstParseResult res = SqlToYql("SELECT a.value, b.value FROM plato.Input AS a JOIN plato.Input as b ON a.key == b.key;"); UNIT_ASSERT(res.Root); @@ -408,32 +408,32 @@ Y_UNIT_TEST_SUITE(SqlParsingOnly) { UNIT_ASSERT_VALUES_EQUAL(1, elementStat["Write!"]); } - Y_UNIT_TEST(SameColumnsForDifferentTables) { + Y_UNIT_TEST(SameColumnsForDifferentTables) { NYql::TAstParseResult res = SqlToYql("SELECT a.key, b.key FROM plato.Input as a JOIN plato.Input as b on a.key==b.key;"); UNIT_ASSERT(res.Root); } - Y_UNIT_TEST(SameColumnsForDifferentTablesFullJoin) { + Y_UNIT_TEST(SameColumnsForDifferentTablesFullJoin) { NYql::TAstParseResult res = SqlToYql("SELECT a.key, b.key, a.value, b.value FROM plato.Input AS a FULL JOIN plato.Input AS b USING(key);"); UNIT_ASSERT(res.Root); } - Y_UNIT_TEST(ReverseLabels) { + Y_UNIT_TEST(ReverseLabels) { NYql::TAstParseResult res = SqlToYql("select in.key as subkey, subkey as key from plato.Input as in;"); UNIT_ASSERT(res.Root); } - Y_UNIT_TEST(AutogenerationAliasWithoutCollisionConflict1) { + Y_UNIT_TEST(AutogenerationAliasWithoutCollisionConflict1) { NYql::TAstParseResult res = SqlToYql("select LENGTH(Value), key as column1 from plato.Input;"); UNIT_ASSERT(res.Root); } - Y_UNIT_TEST(AutogenerationAliasWithoutCollision2Conflict2) { + Y_UNIT_TEST(AutogenerationAliasWithoutCollision2Conflict2) { NYql::TAstParseResult res = SqlToYql("select key as column0, LENGTH(Value) from plato.Input;"); UNIT_ASSERT(res.Root); } - Y_UNIT_TEST(InputAliasForQualifiedAsterisk) { + Y_UNIT_TEST(InputAliasForQualifiedAsterisk) { NYql::TAstParseResult res = SqlToYql("use plato; select zyuzya.*, key from plato.Input as zyuzya;"); UNIT_ASSERT(res.Root); } @@ -443,7 +443,7 @@ Y_UNIT_TEST_SUITE(SqlParsingOnly) { UNIT_ASSERT(res.Root); } - Y_UNIT_TEST(SelectOrderByLabeledColumn) { + Y_UNIT_TEST(SelectOrderByLabeledColumn) { NYql::TAstParseResult res = SqlToYql("pragma DisableOrderedColumns; select key as goal from plato.Input order by goal"); UNIT_ASSERT(res.Root); TVerifyLineFunc verifyLine = [](const TString& word, const TString& line) { @@ -464,17 +464,17 @@ Y_UNIT_TEST_SUITE(SqlParsingOnly) { UNIT_ASSERT_VALUES_EQUAL(1, elementStat["Sort"]); } - Y_UNIT_TEST(SelectOrderBySimpleExpr) { + Y_UNIT_TEST(SelectOrderBySimpleExpr) { NYql::TAstParseResult res = SqlToYql("select a from plato.Input order by a + a"); UNIT_ASSERT(res.Root); } - Y_UNIT_TEST(SelectOrderByDuplicateLabels) { + Y_UNIT_TEST(SelectOrderByDuplicateLabels) { NYql::TAstParseResult res = SqlToYql("select a from plato.Input order by a, a"); UNIT_ASSERT(res.Root); } - Y_UNIT_TEST(SelectOrderByExpression) { + Y_UNIT_TEST(SelectOrderByExpression) { NYql::TAstParseResult res = SqlToYql("select * from plato.Input as i order by cast(key as uint32) + cast(subkey as uint32)"); UNIT_ASSERT(res.Root); TVerifyLineFunc verifyLine = [](const TString& word, const TString& line) { @@ -493,7 +493,7 @@ Y_UNIT_TEST_SUITE(SqlParsingOnly) { UNIT_ASSERT_VALUES_EQUAL(1, elementStat["Sort"]); } - Y_UNIT_TEST(SelectOrderByExpressionDesc) { + Y_UNIT_TEST(SelectOrderByExpressionDesc) { NYql::TAstParseResult res = SqlToYql("pragma disablesimplecolumns; select i.*, key, subkey from plato.Input as i order by cast(i.key as uint32) - cast(i.subkey as uint32) desc"); UNIT_ASSERT(res.Root); TVerifyLineFunc verifyLine = [](const TString& word, const TString& line) { @@ -516,7 +516,7 @@ Y_UNIT_TEST_SUITE(SqlParsingOnly) { UNIT_ASSERT_VALUES_EQUAL(1, elementStat["Write!"]); } - Y_UNIT_TEST(SelectOrderByExpressionAsc) { + Y_UNIT_TEST(SelectOrderByExpressionAsc) { NYql::TAstParseResult res = SqlToYql("select i.key, i.subkey from plato.Input as i order by cast(key as uint32) % cast(i.subkey as uint32) asc"); UNIT_ASSERT(res.Root); TVerifyLineFunc verifyLine = [](const TString& word, const TString& line) { @@ -538,32 +538,32 @@ Y_UNIT_TEST_SUITE(SqlParsingOnly) { UNIT_ASSERT_VALUES_EQUAL(1, elementStat["Write!"]); } - Y_UNIT_TEST(ReferenceToKeyInSubselect) { + Y_UNIT_TEST(ReferenceToKeyInSubselect) { NYql::TAstParseResult res = SqlToYql("select b.key from (select a.key from plato.Input as a) as b;"); UNIT_ASSERT(res.Root); } - Y_UNIT_TEST(OrderByCastValue) { + Y_UNIT_TEST(OrderByCastValue) { NYql::TAstParseResult res = SqlToYql("select i.key, i.subkey from plato.Input as i order by cast(key as uint32) desc;"); UNIT_ASSERT(res.Root); } - Y_UNIT_TEST(GroupByCastValue) { + Y_UNIT_TEST(GroupByCastValue) { NYql::TAstParseResult res = SqlToYql("select count(1) from plato.Input as i group by cast(key as uint8);"); UNIT_ASSERT(res.Root); } - Y_UNIT_TEST(KeywordInSelectColumns) { + Y_UNIT_TEST(KeywordInSelectColumns) { NYql::TAstParseResult res = SqlToYql("select in, s.check from (select 1 as in, \"test\" as check) as s;"); UNIT_ASSERT(res.Root); } - Y_UNIT_TEST(SelectAllGroupBy) { + Y_UNIT_TEST(SelectAllGroupBy) { NYql::TAstParseResult res = SqlToYql("select * from plato.Input group by subkey;"); UNIT_ASSERT(res.Root); } - Y_UNIT_TEST(PrimaryKeyParseCorrect) { + Y_UNIT_TEST(PrimaryKeyParseCorrect) { NYql::TAstParseResult res = SqlToYql("USE plato; CREATE TABLE tableName (Key Uint32, Subkey Int64, Value String, PRIMARY KEY (Key, Subkey));"); UNIT_ASSERT(res.Root); @@ -581,7 +581,7 @@ Y_UNIT_TEST_SUITE(SqlParsingOnly) { UNIT_ASSERT_VALUES_EQUAL(1, elementStat["primarykey"]); } - Y_UNIT_TEST(DeleteFromTableByKey) { + Y_UNIT_TEST(DeleteFromTableByKey) { NYql::TAstParseResult res = SqlToYql("delete from plato.Input where key = 200;", 10, "kikimr"); UNIT_ASSERT(res.Root); @@ -597,7 +597,7 @@ Y_UNIT_TEST_SUITE(SqlParsingOnly) { UNIT_ASSERT_VALUES_EQUAL(1, elementStat["Write"]); } - Y_UNIT_TEST(DeleteFromTable) { + Y_UNIT_TEST(DeleteFromTable) { NYql::TAstParseResult res = SqlToYql("delete from plato.Input;", 10, "kikimr"); UNIT_ASSERT(res.Root); @@ -613,7 +613,7 @@ Y_UNIT_TEST_SUITE(SqlParsingOnly) { UNIT_ASSERT_VALUES_EQUAL(1, elementStat["Write"]); } - Y_UNIT_TEST(DeleteFromTableOnValues) { + Y_UNIT_TEST(DeleteFromTableOnValues) { NYql::TAstParseResult res = SqlToYql("delete from plato.Input on (key) values (1);", 10, "kikimr"); UNIT_ASSERT(res.Root); @@ -630,7 +630,7 @@ Y_UNIT_TEST_SUITE(SqlParsingOnly) { UNIT_ASSERT_VALUES_EQUAL(1, elementStat["Write"]); } - Y_UNIT_TEST(DeleteFromTableOnSelect) { + Y_UNIT_TEST(DeleteFromTableOnSelect) { NYql::TAstParseResult res = SqlToYql( "delete from plato.Input on select key from plato.Input where value > 0;", 10, "kikimr"); UNIT_ASSERT(res.Root); @@ -647,7 +647,7 @@ Y_UNIT_TEST_SUITE(SqlParsingOnly) { UNIT_ASSERT_VALUES_EQUAL(1, elementStat["Write"]); } - Y_UNIT_TEST(UpdateByValues) { + Y_UNIT_TEST(UpdateByValues) { NYql::TAstParseResult res = SqlToYql("update plato.Input set key = 777, value = 'cool' where key = 200;", 10, "kikimr"); UNIT_ASSERT(res.Root); @@ -673,7 +673,7 @@ Y_UNIT_TEST_SUITE(SqlParsingOnly) { UNIT_ASSERT_VALUES_EQUAL(1, elementStat["AsStruct"]); } - Y_UNIT_TEST(UpdateByMultiValues) { + Y_UNIT_TEST(UpdateByMultiValues) { NYql::TAstParseResult res = SqlToYql("update plato.Input set (key, value, subkey) = ('2','ddd',':') where key = 200;", 10, "kikimr"); UNIT_ASSERT(res.Root); @@ -702,7 +702,7 @@ Y_UNIT_TEST_SUITE(SqlParsingOnly) { UNIT_ASSERT_VALUES_EQUAL(1, elementStat["AsStruct"]); } - Y_UNIT_TEST(UpdateBySelect) { + Y_UNIT_TEST(UpdateBySelect) { NYql::TAstParseResult res = SqlToYql("update plato.Input set (key, value, subkey) = (select key, value, subkey from plato.Input where key = 911) where key = 200;", 10, "kikimr"); UNIT_ASSERT(res.Root); @@ -728,7 +728,7 @@ Y_UNIT_TEST_SUITE(SqlParsingOnly) { UNIT_ASSERT_VALUES_EQUAL(1, elementStat["Write"]); } - Y_UNIT_TEST(UpdateSelfModifyAll) { + Y_UNIT_TEST(UpdateSelfModifyAll) { NYql::TAstParseResult res = SqlToYql("update plato.Input set subkey = subkey + 's';", 10, "kikimr"); UNIT_ASSERT(res.Root); @@ -750,7 +750,7 @@ Y_UNIT_TEST_SUITE(SqlParsingOnly) { UNIT_ASSERT_VALUES_EQUAL(1, elementStat["AsStruct"]); } - Y_UNIT_TEST(UpdateOnValues) { + Y_UNIT_TEST(UpdateOnValues) { NYql::TAstParseResult res = SqlToYql("update plato.Input on (key, value) values (5, 'cool')", 10, "kikimr"); UNIT_ASSERT(res.Root); @@ -766,7 +766,7 @@ Y_UNIT_TEST_SUITE(SqlParsingOnly) { UNIT_ASSERT_VALUES_EQUAL(1, elementStat["Write"]); } - Y_UNIT_TEST(UpdateOnSelect) { + Y_UNIT_TEST(UpdateOnSelect) { NYql::TAstParseResult res = SqlToYql( "update plato.Input on select key, value + 1 as value from plato.Input", 10, "kikimr"); UNIT_ASSERT(res.Root); @@ -783,7 +783,7 @@ Y_UNIT_TEST_SUITE(SqlParsingOnly) { UNIT_ASSERT_VALUES_EQUAL(1, elementStat["Write"]); } - Y_UNIT_TEST(UnionAllTest) { + Y_UNIT_TEST(UnionAllTest) { NYql::TAstParseResult res = SqlToYql("SELECT key FROM plato.Input UNION ALL select subkey FROM plato.Input;"); UNIT_ASSERT(res.Root); @@ -797,19 +797,19 @@ Y_UNIT_TEST_SUITE(SqlParsingOnly) { UNIT_ASSERT(res.Root); } - Y_UNIT_TEST(SimpleGroupBy) { + Y_UNIT_TEST(SimpleGroupBy) { NYql::TAstParseResult res = SqlToYql("select count(1),z from plato.Input group by key as z order by z;"); UNIT_ASSERT(res.Root); } - Y_UNIT_TEST(EmptyColumnName0) { + Y_UNIT_TEST(EmptyColumnName0) { /// Now it's parsed well and error occur on validate step like "4:31:Empty struct member name is not allowed" in "4:31:Function: AddMember" NYql::TAstParseResult res = SqlToYql("insert into plato.Output (``, list1) values (0, AsList(0, 1, 2));"); /// Verify that parsed well without crash UNIT_ASSERT(res.Root); } - Y_UNIT_TEST(KikimrRollback) { + Y_UNIT_TEST(KikimrRollback) { NYql::TAstParseResult res = SqlToYql("use plato; select * from Input; rollback;", 10, "kikimr"); UNIT_ASSERT(res.Root); @@ -818,7 +818,7 @@ Y_UNIT_TEST_SUITE(SqlParsingOnly) { UNIT_ASSERT_VALUES_EQUAL(1, elementStat["rollback"]); } - Y_UNIT_TEST(PragmaFile) { + Y_UNIT_TEST(PragmaFile) { NYql::TAstParseResult res = SqlToYql(R"(pragma file("HW", "sbr:181041334");)"); UNIT_ASSERT(res.Root); @@ -827,12 +827,12 @@ Y_UNIT_TEST_SUITE(SqlParsingOnly) { UNIT_ASSERT_VALUES_EQUAL(1, elementStat.cbegin()->second); } - Y_UNIT_TEST(DoNotCrashOnNamedInFilter) { + Y_UNIT_TEST(DoNotCrashOnNamedInFilter) { NYql::TAstParseResult res = SqlToYql("USE plato; $all = ($table_name) -> { return true; }; SELECT * FROM FILTER(Input, $all)"); UNIT_ASSERT(res.Root); } - Y_UNIT_TEST(PragmasFileAndUdfOrder) { + Y_UNIT_TEST(PragmasFileAndUdfOrder) { NYql::TAstParseResult res = SqlToYql(R"( PRAGMA file("libvideoplayers_udf.so", "https://proxy.sandbox.yandex-team.ru/235185290"); PRAGMA udf("libvideoplayers_udf.so"); @@ -845,7 +845,7 @@ Y_UNIT_TEST_SUITE(SqlParsingOnly) { UNIT_ASSERT(file < udfs); } - Y_UNIT_TEST(ProcessUserType) { + Y_UNIT_TEST(ProcessUserType) { NYql::TAstParseResult res = SqlToYql("process plato.Input using Kikimr::PushData(TableRows());", 1, TString(NYql::KikimrProviderName)); UNIT_ASSERT(res.Root); @@ -878,7 +878,7 @@ Y_UNIT_TEST_SUITE(SqlParsingOnly) { UNIT_ASSERT_VALUES_EQUAL(1, elementStat["YDB.PushData"]); } - Y_UNIT_TEST(SelectStreamRtmr) { + Y_UNIT_TEST(SelectStreamRtmr) { NYql::TAstParseResult res = SqlToYql( "USE plato; INSERT INTO Output SELECT STREAM key FROM Input;", 10, TString(NYql::RtmrProviderName)); @@ -905,7 +905,7 @@ Y_UNIT_TEST_SUITE(SqlParsingOnly) { UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:31: Error: SELECT STREAM is unsupported for non-streaming sources\n"); } - Y_UNIT_TEST(GroupByHopRtmr) { + Y_UNIT_TEST(GroupByHopRtmr) { NYql::TAstParseResult res = SqlToYql(R"( USE plato; INSERT INTO Output SELECT key, SUM(value) AS value FROM Input GROUP BY key, HOP(subkey, "PT10S", "PT30S", "PT20S"); @@ -943,7 +943,7 @@ Y_UNIT_TEST_SUITE(SqlParsingOnly) { UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:3:22: Error: Streaming group by query must have a hopping window specification.\n"); } - Y_UNIT_TEST(KikimrInserts) { + Y_UNIT_TEST(KikimrInserts) { NYql::TAstParseResult res = SqlToYql(R"( USE plato; INSERT INTO Output SELECT key, value FROM Input; @@ -1664,8 +1664,8 @@ Y_UNIT_TEST_SUITE(ExternalFunction) { } } -Y_UNIT_TEST_SUITE(SqlToYQLErrors) { - Y_UNIT_TEST(StrayUTF8) { +Y_UNIT_TEST_SUITE(SqlToYQLErrors) { + Y_UNIT_TEST(StrayUTF8) { /// 'c' in plato is russian here NYql::TAstParseResult res = SqlToYql("select * from сedar.Input"); UNIT_ASSERT(!res.Root); @@ -1712,7 +1712,7 @@ Y_UNIT_TEST_SUITE(SqlToYQLErrors) { UNIT_ASSERT_NO_DIFF(a1, a2); } - Y_UNIT_TEST(InvalidDoubleAtString) { + Y_UNIT_TEST(InvalidDoubleAtString) { NYql::TAstParseResult res = SqlToYql("select @@@@@@"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:13: Error: Unexpected character : syntax error...\n\n" @@ -1725,44 +1725,44 @@ Y_UNIT_TEST_SUITE(SqlToYQLErrors) { UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:7: Error: Unexpected token '@@foo@@' : cannot match to any predicted input...\n\n"); } - Y_UNIT_TEST(InvalidStringFromTable) { + Y_UNIT_TEST(InvalidStringFromTable) { NYql::TAstParseResult res = SqlToYql("select \"FOO\"\"BAR from plato.foo"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:31: Error: Unexpected character : syntax error...\n\n"); } - Y_UNIT_TEST(InvalidDoubleAtStringFromTable) { + Y_UNIT_TEST(InvalidDoubleAtStringFromTable) { NYql::TAstParseResult res = SqlToYql("select @@@@@@ from plato.foo"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:28: Error: Unexpected character : syntax error...\n\n" "<main>:1:0: Error: Unexpected token absence : cannot match to any predicted input...\n\n"); } - Y_UNIT_TEST(SelectInvalidSyntax) { + Y_UNIT_TEST(SelectInvalidSyntax) { NYql::TAstParseResult res = SqlToYql("select 1 form Wat"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:14: Error: Unexpected token 'Wat' : cannot match to any predicted input...\n\n"); } - Y_UNIT_TEST(SelectNoCluster) { + Y_UNIT_TEST(SelectNoCluster) { NYql::TAstParseResult res = SqlToYql("select foo from bar"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:1: Error: No cluster name given and no default cluster is selected\n"); } - Y_UNIT_TEST(SelectDuplicateColumns) { + Y_UNIT_TEST(SelectDuplicateColumns) { NYql::TAstParseResult res = SqlToYql("select a, a from plato.Input"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:11: Error: Unable to use duplicate column names. Collision in name: a\n"); } - Y_UNIT_TEST(SelectDuplicateLabels) { + Y_UNIT_TEST(SelectDuplicateLabels) { NYql::TAstParseResult res = SqlToYql("select a as foo, b as foo from plato.Input"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:18: Error: Unable to use duplicate column names. Collision in name: foo\n"); } - Y_UNIT_TEST(SelectCaseWithoutThen) { + Y_UNIT_TEST(SelectCaseWithoutThen) { NYql::TAstParseResult res = SqlToYql("select case when true 1;"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), @@ -1771,7 +1771,7 @@ Y_UNIT_TEST_SUITE(SqlToYQLErrors) { ); } - Y_UNIT_TEST(SelectComplexCaseWithoutThen) { + Y_UNIT_TEST(SelectComplexCaseWithoutThen) { NYql::TAstParseResult res = SqlToYql( "SELECT *\n" "FROM plato.Input AS a\n" @@ -1780,13 +1780,13 @@ Y_UNIT_TEST_SUITE(SqlToYQLErrors) { UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:3:30: Error: Unexpected token absence : Missing THEN \n\n"); } - Y_UNIT_TEST(SelectCaseWithoutEnd) { + Y_UNIT_TEST(SelectCaseWithoutEnd) { NYql::TAstParseResult res = SqlToYql("select case a when b then c end from plato.Input"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:8: Error: ELSE is required\n"); } - Y_UNIT_TEST(SelectWithBadAggregationNoInput) { + Y_UNIT_TEST(SelectWithBadAggregationNoInput) { NYql::TAstParseResult res = SqlToYql("select a, Min(b), c"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), @@ -1799,17 +1799,17 @@ Y_UNIT_TEST_SUITE(SqlToYQLErrors) { ); } - Y_UNIT_TEST(SelectWithBadAggregation) { + Y_UNIT_TEST(SelectWithBadAggregation) { ExpectFailWithError("select count(*), 1 + key from plato.Input", "<main>:1:22: Error: Column `key` must either be a key column in GROUP BY or it should be used in aggregation function\n"); } - Y_UNIT_TEST(SelectWithBadAggregatedTerms) { + Y_UNIT_TEST(SelectWithBadAggregatedTerms) { ExpectFailWithError("select key, 2 * subkey from plato.Input group by key", "<main>:1:17: Error: Column `subkey` must either be a key column in GROUP BY or it should be used in aggregation function\n"); } - Y_UNIT_TEST(SelectWithBadAggregationInHaving) { + Y_UNIT_TEST(SelectWithBadAggregationInHaving) { ExpectFailWithError("select key from plato.Input group by key\n" "having \"f\" || value == \"foo\"", "<main>:2:15: Error: Column `value` must either be a key column in GROUP BY or it should be used in aggregation function\n"); @@ -1928,67 +1928,67 @@ Y_UNIT_TEST_SUITE(SqlToYQLErrors) { "<main>:1:8: Error: Column `c` must either be a key column in GROUP BY or it should be used in aggregation function\n"); } - Y_UNIT_TEST(SelectWithDuplicateGroupingColumns) { + Y_UNIT_TEST(SelectWithDuplicateGroupingColumns) { NYql::TAstParseResult res = SqlToYql("select c from plato.Input group by c, c"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:8: Error: Duplicate grouping column: c\n"); } - Y_UNIT_TEST(SelectWithBadAggregationInGrouping) { + Y_UNIT_TEST(SelectWithBadAggregationInGrouping) { NYql::TAstParseResult res = SqlToYql("select a, Min(b), c group by c"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:1: Error: Column references are not allowed without FROM\n" "<main>:1:30: Error: Column reference 'c'\n"); } - Y_UNIT_TEST(SelectWithOpOnBadAggregation) { + Y_UNIT_TEST(SelectWithOpOnBadAggregation) { ExpectFailWithError("select 1 + a + Min(b) from plato.Input", "<main>:1:12: Error: Column `a` must either be a key column in GROUP BY or it should be used in aggregation function\n"); } - Y_UNIT_TEST(SelectOrderByConstantNum) { + Y_UNIT_TEST(SelectOrderByConstantNum) { NYql::TAstParseResult res = SqlToYql("select a from plato.Input order by 1"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:36: Error: Unable to ORDER BY constant expression\n"); } - Y_UNIT_TEST(SelectOrderByConstantExpr) { + Y_UNIT_TEST(SelectOrderByConstantExpr) { NYql::TAstParseResult res = SqlToYql("select a from plato.Input order by 1 * 42"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:38: Error: Unable to ORDER BY constant expression\n"); } - Y_UNIT_TEST(SelectOrderByConstantString) { + Y_UNIT_TEST(SelectOrderByConstantString) { NYql::TAstParseResult res = SqlToYql("select a from plato.Input order by \"nest\""); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:36: Error: Unable to ORDER BY constant expression\n"); } - Y_UNIT_TEST(SelectOrderByAggregated) { + Y_UNIT_TEST(SelectOrderByAggregated) { NYql::TAstParseResult res = SqlToYql("select a from plato.Input order by min(a)"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:36: Error: Unable to ORDER BY aggregated values\n"); } - Y_UNIT_TEST(ErrorInOrderByExpresison) { + Y_UNIT_TEST(ErrorInOrderByExpresison) { NYql::TAstParseResult res = SqlToYql("select key, value from plato.Input order by (key as zey)"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:45: Error: You should use in ORDER BY column name, qualified field, callable function or expression\n"); } - Y_UNIT_TEST(SelectAggregatedWhere) { + Y_UNIT_TEST(SelectAggregatedWhere) { NYql::TAstParseResult res = SqlToYql("select * from plato.Input where count(key)"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:33: Error: Can not use aggregated values in filtering\n"); } - Y_UNIT_TEST(DoubleFrom) { + Y_UNIT_TEST(DoubleFrom) { NYql::TAstParseResult res = SqlToYql("from plato.Input select * from plato.Input"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:27: Error: Only one FROM clause is allowed\n"); } - Y_UNIT_TEST(SelectJoinMissingCorrName) { + Y_UNIT_TEST(SelectJoinMissingCorrName) { NYql::TAstParseResult res = SqlToYql("select * from plato.Input1 as a join plato.Input2 as b on a.key == key"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:65: Error: JOIN: column requires correlation name\n"); @@ -2014,7 +2014,7 @@ Y_UNIT_TEST_SUITE(SqlToYQLErrors) { UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:3:33: Error: JOIN: missing correlation name for source\n"); } - Y_UNIT_TEST(SelectJoinEmptyCorrNames) { + Y_UNIT_TEST(SelectJoinEmptyCorrNames) { NYql::TAstParseResult res = SqlToYql( "$left = (SELECT * FROM plato.Input1 LIMIT 2);\n" "$right = (SELECT * FROM plato.Input2 LIMIT 2);\n" @@ -2024,25 +2024,25 @@ Y_UNIT_TEST_SUITE(SqlToYQLErrors) { UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:3:45: Error: At least one correlation name is required in join\n"); } - Y_UNIT_TEST(SelectJoinSameCorrNames) { + Y_UNIT_TEST(SelectJoinSameCorrNames) { NYql::TAstParseResult res = SqlToYql("SELECT Input.key FROM plato.Input JOIN plato.Input1 ON Input.key == Input.subkey\n"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:66: Error: JOIN: different correlation names are required for joined tables\n"); } - Y_UNIT_TEST(SelectJoinConstPredicateArg) { + Y_UNIT_TEST(SelectJoinConstPredicateArg) { NYql::TAstParseResult res = SqlToYql("SELECT * FROM plato.Input1 as A JOIN plato.Input2 as B ON A.key == B.key AND A.subkey == \"wtf\"\n"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:87: Error: JOIN: each equality predicate argument must depend on exactly one JOIN input\n"); } - Y_UNIT_TEST(SelectJoinNonEqualityPredicate) { + Y_UNIT_TEST(SelectJoinNonEqualityPredicate) { NYql::TAstParseResult res = SqlToYql("SELECT * FROM plato.Input1 as A JOIN plato.Input2 as B ON A.key == B.key AND A.subkey > B.subkey\n"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:87: Error: JOIN ON expression must be a conjunction of equality predicates\n"); } - Y_UNIT_TEST(SelectEquiJoinCorrNameOutOfScope) { + Y_UNIT_TEST(SelectEquiJoinCorrNameOutOfScope) { NYql::TAstParseResult res = SqlToYql( "PRAGMA equijoin;\n" "SELECT * FROM plato.A JOIN plato.B ON A.key == C.key JOIN plato.C ON A.subkey == C.subkey;\n" @@ -2051,7 +2051,7 @@ Y_UNIT_TEST_SUITE(SqlToYQLErrors) { UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:2:45: Error: JOIN: can not use source: C in equality predicate, it is out of current join scope\n"); } - Y_UNIT_TEST(SelectEquiJoinNoRightSource) { + Y_UNIT_TEST(SelectEquiJoinNoRightSource) { NYql::TAstParseResult res = SqlToYql( "PRAGMA equijoin;\n" "SELECT * FROM plato.A JOIN plato.B ON A.key == B.key JOIN plato.C ON A.subkey == B.subkey;\n" @@ -2076,175 +2076,175 @@ Y_UNIT_TEST_SUITE(SqlToYQLErrors) { UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:33: Error: Invalid join type: LEFT SEMI OUTER JOIN. OUTER keyword is optional and can only be used after LEFT, RIGHT or FULL\n"); } - Y_UNIT_TEST(InsertNoCluster) { + Y_UNIT_TEST(InsertNoCluster) { NYql::TAstParseResult res = SqlToYql("insert into Output (foo) values (1)"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:1: Error: No cluster name given and no default cluster is selected\n"); } - Y_UNIT_TEST(InsertValuesNoLabels) { + Y_UNIT_TEST(InsertValuesNoLabels) { NYql::TAstParseResult res = SqlToYql("insert into plato.Output values (1)"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:19: Error: INSERT INTO ... VALUES requires specification of table columns\n"); } - Y_UNIT_TEST(UpsertValuesNoLabelsKikimr) { + Y_UNIT_TEST(UpsertValuesNoLabelsKikimr) { NYql::TAstParseResult res = SqlToYql("upsert into plato.Output values (1)", 10, TString(NYql::KikimrProviderName)); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:19: Error: UPSERT INTO ... VALUES requires specification of table columns\n"); } - Y_UNIT_TEST(ReplaceValuesNoLabelsKikimr) { + Y_UNIT_TEST(ReplaceValuesNoLabelsKikimr) { NYql::TAstParseResult res = SqlToYql("replace into plato.Output values (1)", 10, TString(NYql::KikimrProviderName)); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:20: Error: REPLACE INTO ... VALUES requires specification of table columns\n"); } - Y_UNIT_TEST(InsertValuesInvalidLabels) { + Y_UNIT_TEST(InsertValuesInvalidLabels) { NYql::TAstParseResult res = SqlToYql("insert into plato.Output (foo) values (1, 2)"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:27: Error: VALUES have 2 columns, INSERT INTO expects: 1\n"); } - Y_UNIT_TEST(BuiltinFileOpNoArgs) { + Y_UNIT_TEST(BuiltinFileOpNoArgs) { NYql::TAstParseResult res = SqlToYql("select FilePath()"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:8: Error: FilePath() requires exactly 1 arguments, given: 0\n"); } - Y_UNIT_TEST(ProcessWithHaving) { + Y_UNIT_TEST(ProcessWithHaving) { NYql::TAstParseResult res = SqlToYql("process plato.Input using some::udf(value) having value == 1"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:15: Error: PROCESS does not allow HAVING yet! You may request it on yql@ maillist.\n"); } - Y_UNIT_TEST(ReduceNoBy) { + Y_UNIT_TEST(ReduceNoBy) { NYql::TAstParseResult res = SqlToYql("reduce plato.Input using some::udf(value)"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:19: Error: Unexpected token absence : Missing ON \n\n<main>:1:25: Error: Unexpected token absence : Missing USING \n\n"); } - Y_UNIT_TEST(ReduceDistinct) { + Y_UNIT_TEST(ReduceDistinct) { NYql::TAstParseResult res = SqlToYql("reduce plato.Input on key using some::udf(distinct value)"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:43: Error: DISTINCT can not be used in PROCESS/REDUCE\n"); } - Y_UNIT_TEST(CreateTableWithView) { + Y_UNIT_TEST(CreateTableWithView) { NYql::TAstParseResult res = SqlToYql("CREATE TABLE plato.foo:bar (key INT);"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:22: Error: Unexpected token ':' : syntax error...\n\n"); } - Y_UNIT_TEST(AsteriskWithSomethingAfter) { + Y_UNIT_TEST(AsteriskWithSomethingAfter) { NYql::TAstParseResult res = SqlToYql("select *, LENGTH(value) from plato.Input;"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:8: Error: Unable to use plain '*' with other projection items. Please use qualified asterisk instead: '<table>.*' (<table> can be either table name or table alias).\n"); } - Y_UNIT_TEST(AsteriskWithSomethingBefore) { + Y_UNIT_TEST(AsteriskWithSomethingBefore) { NYql::TAstParseResult res = SqlToYql("select LENGTH(value), * from plato.Input;"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:23: Error: Unable to use plain '*' with other projection items. Please use qualified asterisk instead: '<table>.*' (<table> can be either table name or table alias).\n"); } - Y_UNIT_TEST(DuplicatedQualifiedAsterisk) { + Y_UNIT_TEST(DuplicatedQualifiedAsterisk) { NYql::TAstParseResult res = SqlToYql("select in.*, key, in.* from plato.Input as in;"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:19: Error: Unable to use twice same quialified asterisk. Invalid source: in\n"); } - Y_UNIT_TEST(BrokenLabel) { + Y_UNIT_TEST(BrokenLabel) { NYql::TAstParseResult res = SqlToYql("select in.*, key as `funny.label` from plato.Input as in;"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:14: Error: Unable to use '.' in column name. Invalid column name: funny.label\n"); } - Y_UNIT_TEST(KeyConflictDetect0) { + Y_UNIT_TEST(KeyConflictDetect0) { NYql::TAstParseResult res = SqlToYql("select key, in.key as key from plato.Input as in;"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:13: Error: Unable to use duplicate column names. Collision in name: key\n"); } - Y_UNIT_TEST(KeyConflictDetect1) { + Y_UNIT_TEST(KeyConflictDetect1) { NYql::TAstParseResult res = SqlToYql("select length(key) as key, key from plato.Input;"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:28: Error: Unable to use duplicate column names. Collision in name: key\n"); } - Y_UNIT_TEST(KeyConflictDetect2) { + Y_UNIT_TEST(KeyConflictDetect2) { NYql::TAstParseResult res = SqlToYql("select key, in.key from plato.Input as in;"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:1: Error: Duplicate column: key\n"); } - Y_UNIT_TEST(AutogenerationAliasWithCollisionConflict1) { + Y_UNIT_TEST(AutogenerationAliasWithCollisionConflict1) { NYql::TAstParseResult res = SqlToYql("select LENGTH(Value), key as column0 from plato.Input;"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:1: Error: Duplicate column: column0\n"); } - Y_UNIT_TEST(AutogenerationAliasWithCollisionConflict2) { + Y_UNIT_TEST(AutogenerationAliasWithCollisionConflict2) { NYql::TAstParseResult res = SqlToYql("select key as column1, LENGTH(Value) from plato.Input;"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:1: Error: Duplicate column: column1\n"); } - Y_UNIT_TEST(MissedSourceTableForQualifiedAsteriskOnSimpleSelect) { + Y_UNIT_TEST(MissedSourceTableForQualifiedAsteriskOnSimpleSelect) { NYql::TAstParseResult res = SqlToYql("use plato; select Intop.*, Input.key from plato.Input;"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:19: Error: Unknown correlation name: Intop\n"); } - Y_UNIT_TEST(MissedSourceTableForQualifiedAsteriskOnJoin) { + Y_UNIT_TEST(MissedSourceTableForQualifiedAsteriskOnJoin) { NYql::TAstParseResult res = SqlToYql("use plato; select tmissed.*, t2.*, t1.key from plato.Input as t1 join plato.Input as t2 on t1.key==t2.key;"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:19: Error: Unknown correlation name for asterisk: tmissed\n"); } - Y_UNIT_TEST(UnableToReferenceOnNotExistSubcolumn) { + Y_UNIT_TEST(UnableToReferenceOnNotExistSubcolumn) { NYql::TAstParseResult res = SqlToYql("select b.subkey from (select key from plato.Input as a) as b;"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:8: Error: Column subkey is not in source column set\n"); } - Y_UNIT_TEST(ConflictOnSameNameWithQualify0) { + Y_UNIT_TEST(ConflictOnSameNameWithQualify0) { NYql::TAstParseResult res = SqlToYql("select in.key, in.key as key from plato.Input as in;"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:1: Error: Duplicate column: key\n"); } - Y_UNIT_TEST(ConflictOnSameNameWithQualify1) { + Y_UNIT_TEST(ConflictOnSameNameWithQualify1) { NYql::TAstParseResult res = SqlToYql("select in.key, length(key) as key from plato.Input as in;"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:1: Error: Duplicate column: key\n"); } - Y_UNIT_TEST(ConflictOnSameNameWithQualify2) { + Y_UNIT_TEST(ConflictOnSameNameWithQualify2) { NYql::TAstParseResult res = SqlToYql("select key, in.key from plato.Input as in;"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:1: Error: Duplicate column: key\n"); } - Y_UNIT_TEST(ConflictOnSameNameWithQualify3) { + Y_UNIT_TEST(ConflictOnSameNameWithQualify3) { NYql::TAstParseResult res = SqlToYql("select in.key, subkey as key from plato.Input as in;"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:1: Error: Duplicate column: key\n"); } - Y_UNIT_TEST(SelectOrderByUnknownLabel) { + Y_UNIT_TEST(SelectOrderByUnknownLabel) { NYql::TAstParseResult res = SqlToYql("select a from plato.Input order by b"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:36: Error: Column b is not in source column set. Did you mean a?\n"); } - Y_UNIT_TEST(SelectFlattenBySameColumns) { + Y_UNIT_TEST(SelectFlattenBySameColumns) { NYql::TAstParseResult res = SqlToYql("select key from plato.Input flatten by (key, key as kk)"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:46: Error: Duplicate column name found: key in FlattenBy section\n"); } - Y_UNIT_TEST(SelectFlattenBySameAliases) { + Y_UNIT_TEST(SelectFlattenBySameAliases) { NYql::TAstParseResult res = SqlToYql("select key from plato.Input flatten by (key as kk, subkey as kk);"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:52: Error: Duplicate alias found: kk in FlattenBy section\n"); @@ -2256,13 +2256,13 @@ Y_UNIT_TEST_SUITE(SqlToYQLErrors) { UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:52: Error: Collision between alias and column name: kk in FlattenBy section\n"); } - Y_UNIT_TEST(SelectFlattenByConflictNameAndAlias0) { + Y_UNIT_TEST(SelectFlattenByConflictNameAndAlias0) { NYql::TAstParseResult res = SqlToYql("select key from plato.Input flatten by (key, subkey as key);"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:46: Error: Collision between alias and column name: key in FlattenBy section\n"); } - Y_UNIT_TEST(SelectFlattenByConflictNameAndAlias1) { + Y_UNIT_TEST(SelectFlattenByConflictNameAndAlias1) { NYql::TAstParseResult res = SqlToYql("select key from plato.Input flatten by (key as kk, subkey as key);"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:52: Error: Collision between alias and column name: key in FlattenBy section\n"); @@ -2280,7 +2280,7 @@ Y_UNIT_TEST_SUITE(SqlToYQLErrors) { UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:46: Error: Unnamed expression after FLATTEN BY is not allowed\n"); } - Y_UNIT_TEST(UseInOnStrings) { + Y_UNIT_TEST(UseInOnStrings) { NYql::TAstParseResult res = SqlToYql("select * from plato.Input where \"foo\" in \"foovalue\";"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:42: Error: Unable to use IN predicate with string argument, it won't search substring - " @@ -2301,7 +2301,7 @@ Y_UNIT_TEST_SUITE(SqlToYQLErrors) { UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:58: Error: Unknown builtin: COMPACT\n"); } - Y_UNIT_TEST(ErrorColumnPosition) { + Y_UNIT_TEST(ErrorColumnPosition) { NYql::TAstParseResult res = SqlToYql( "USE plato;\n" "SELECT \n" @@ -2313,73 +2313,73 @@ Y_UNIT_TEST_SUITE(SqlToYQLErrors) { UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:3:1: Error: Column value is not in source column set\n"); } - Y_UNIT_TEST(InsertAbortMapReduce) { + Y_UNIT_TEST(InsertAbortMapReduce) { NYql::TAstParseResult res = SqlToYql("INSERT OR ABORT INTO plato.Output SELECT key FROM plato.Input"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:0: Error: INSERT OR ABORT INTO is not supported for yt tables\n"); } - Y_UNIT_TEST(ReplaceIntoMapReduce) { + Y_UNIT_TEST(ReplaceIntoMapReduce) { NYql::TAstParseResult res = SqlToYql("REPLACE INTO plato.Output SELECT key FROM plato.Input"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:0: Error: Meaning of REPLACE INTO has been changed, now you should use INSERT INTO <table> WITH TRUNCATE ... for yt\n"); } - Y_UNIT_TEST(UpsertIntoMapReduce) { + Y_UNIT_TEST(UpsertIntoMapReduce) { NYql::TAstParseResult res = SqlToYql("UPSERT INTO plato.Output SELECT key FROM plato.Input"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:0: Error: UPSERT INTO is not supported for yt tables\n"); } - Y_UNIT_TEST(UpdateMapReduce) { + Y_UNIT_TEST(UpdateMapReduce) { NYql::TAstParseResult res = SqlToYql("UPDATE plato.Output SET value = value + 1 WHERE key < 1"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:0: Error: UPDATE is unsupported for yt\n"); } - Y_UNIT_TEST(DeleteMapReduce) { + Y_UNIT_TEST(DeleteMapReduce) { NYql::TAstParseResult res = SqlToYql("DELETE FROM plato.Output WHERE key < 1"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:0: Error: DELETE is unsupported for yt\n"); } - Y_UNIT_TEST(ReplaceIntoWithTruncate) { + Y_UNIT_TEST(ReplaceIntoWithTruncate) { NYql::TAstParseResult res = SqlToYql("REPLACE INTO plato.Output WITH TRUNCATE SELECT key FROM plato.Input"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:32: Error: Unable REPLACE INTO with truncate mode\n"); } - Y_UNIT_TEST(UpsertIntoWithTruncate) { + Y_UNIT_TEST(UpsertIntoWithTruncate) { NYql::TAstParseResult res = SqlToYql("UPSERT INTO plato.Output WITH TRUNCATE SELECT key FROM plato.Input"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:31: Error: Unable UPSERT INTO with truncate mode\n"); } - Y_UNIT_TEST(InsertIntoWithTruncateKikimr) { + Y_UNIT_TEST(InsertIntoWithTruncateKikimr) { NYql::TAstParseResult res = SqlToYql("INSERT INTO plato.Output WITH TRUNCATE SELECT key FROM plato.Input", 10, TString(NYql::KikimrProviderName)); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:0: Error: INSERT INTO WITH TRUNCATE is not supported for kikimr tables\n"); } - Y_UNIT_TEST(InsertIntoWithWrongArgumentCount) { + Y_UNIT_TEST(InsertIntoWithWrongArgumentCount) { NYql::TAstParseResult res = SqlToYql("insert into plato.Output with truncate (key, value, subkey) values (5, '1', '2', '3');"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:53: Error: VALUES have 4 columns, INSERT INTO ... WITH TRUNCATE expects: 3\n"); } - Y_UNIT_TEST(UpsertWithWrongArgumentCount) { + Y_UNIT_TEST(UpsertWithWrongArgumentCount) { NYql::TAstParseResult res = SqlToYql("upsert into plato.Output (key, value, subkey) values (2, '3');", 10, TString(NYql::KikimrProviderName)); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:39: Error: VALUES have 2 columns, UPSERT INTO expects: 3\n"); } - Y_UNIT_TEST(UnionNotSupported) { + Y_UNIT_TEST(UnionNotSupported) { NYql::TAstParseResult res = SqlToYql("SELECT key FROM plato.Input UNION select subkey FROM plato.Input;"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:29: Error: UNION without quantifier ALL is not supported yet. Did you mean UNION ALL?\n"); } - Y_UNIT_TEST(GroupingSetByExprWithoutAlias) { + Y_UNIT_TEST(GroupingSetByExprWithoutAlias) { NYql::TAstParseResult res = SqlToYql("SELECT key FROM plato.Input GROUP BY GROUPING SETS (cast(key as uint32), subkey);"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:53: Error: Unnamed expressions are not supported in GROUPING SETS. Please use '<expr> AS <name>'.\n"); @@ -2392,49 +2392,49 @@ Y_UNIT_TEST_SUITE(SqlToYQLErrors) { UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:2:1: Error: Unnamed expressions are not supported in GROUPING SETS. Please use '<expr> AS <name>'.\n"); } - Y_UNIT_TEST(CubeByExprWithoutAlias) { + Y_UNIT_TEST(CubeByExprWithoutAlias) { NYql::TAstParseResult res = SqlToYql("SELECT key FROM plato.Input GROUP BY CUBE (key, subkey / key);"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:56: Error: Unnamed expressions are not supported in CUBE. Please use '<expr> AS <name>'.\n"); } - Y_UNIT_TEST(RollupByExprWithoutAlias) { + Y_UNIT_TEST(RollupByExprWithoutAlias) { NYql::TAstParseResult res = SqlToYql("SELECT key FROM plato.Input GROUP BY ROLLUP (subkey / key);"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:53: Error: Unnamed expressions are not supported in ROLLUP. Please use '<expr> AS <name>'.\n"); } - Y_UNIT_TEST(GroupByHugeCubeDeniedNoPragma) { + Y_UNIT_TEST(GroupByHugeCubeDeniedNoPragma) { NYql::TAstParseResult res = SqlToYql("SELECT key FROM plato.Input GROUP BY CUBE (key, subkey, value, key + subkey as sum, key - subkey as sub, key + val as keyval);"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:119: Error: GROUP BY CUBE is allowed only for 5 columns, but you use 6\n"); } - Y_UNIT_TEST(GroupByInvalidPragma) { + Y_UNIT_TEST(GroupByInvalidPragma) { NYql::TAstParseResult res = SqlToYql("PRAGMA GroupByCubeLimit = '-4';"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:27: Error: Expected unsigned integer literal as a single argument for: GroupByCubeLimit\n"); } - Y_UNIT_TEST(GroupByHugeCubeDeniedPragme) { + Y_UNIT_TEST(GroupByHugeCubeDeniedPragme) { NYql::TAstParseResult res = SqlToYql("PRAGMA GroupByCubeLimit = '4'; SELECT key FROM plato.Input GROUP BY CUBE (key, subkey, value, key + subkey as sum, key - subkey as sub);"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:132: Error: GROUP BY CUBE is allowed only for 4 columns, but you use 5\n"); } - Y_UNIT_TEST(GroupByFewBigCubes) { + Y_UNIT_TEST(GroupByFewBigCubes) { NYql::TAstParseResult res = SqlToYql("SELECT key FROM plato.Input GROUP BY CUBE(key, subkey, key + subkey as sum), CUBE(value, value + key + subkey as total);"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:1: Error: Unable to GROUP BY more than 32 groups, you try use 80 groups\n"); } - Y_UNIT_TEST(GroupByFewBigCubesWithPragmaLimit) { + Y_UNIT_TEST(GroupByFewBigCubesWithPragmaLimit) { NYql::TAstParseResult res = SqlToYql("PRAGMA GroupByLimit = '16'; SELECT key FROM plato.Input GROUP BY GROUPING SETS(key, subkey, key + subkey as sum), ROLLUP(value, value + key + subkey as total);"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:29: Error: Unable to GROUP BY more than 16 groups, you try use 18 groups\n"); } - Y_UNIT_TEST(NoGroupingColumn0) { + Y_UNIT_TEST(NoGroupingColumn0) { NYql::TAstParseResult res = SqlToYql( "select count(1), key_first, val_first, grouping(key_first, val_first, nomind) as group\n" "from plato.Input group by grouping sets (cast(key as uint32) /100 as key_first, Substring(value, 1, 1) as val_first);"); @@ -2442,31 +2442,31 @@ Y_UNIT_TEST_SUITE(SqlToYQLErrors) { UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:71: Error: Column 'nomind' is not a grouping column\n"); } - Y_UNIT_TEST(NoGroupingColumn1) { + Y_UNIT_TEST(NoGroupingColumn1) { NYql::TAstParseResult res = SqlToYql("select count(1), grouping(key, value) as group_duo from plato.Input group by cube (key, subkey);"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:32: Error: Column 'value' is not a grouping column\n"); } - Y_UNIT_TEST(EmptyAccess0) { + Y_UNIT_TEST(EmptyAccess0) { NYql::TAstParseResult res = SqlToYql("insert into plato.Output (list0, list1) values (AsList(0, 1, 2), AsList(``));"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:73: Error: Column reference \"\" is not allowed in current scope\n"); } - Y_UNIT_TEST(EmptyAccess1) { + Y_UNIT_TEST(EmptyAccess1) { NYql::TAstParseResult res = SqlToYql("insert into plato.Output (list0, list1) values (AsList(0, 1, 2), ``);"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:66: Error: Column reference \"\" is not allowed in current scope\n"); } - Y_UNIT_TEST(UseUnknownColumnInInsert) { + Y_UNIT_TEST(UseUnknownColumnInInsert) { NYql::TAstParseResult res = SqlToYql("insert into plato.Output (list0, list1) values (AsList(0, 1, 2), AsList(`test`));"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:73: Error: Column reference \"test\" is not allowed in current scope\n"); } - Y_UNIT_TEST(GroupByEmptyColumn) { + Y_UNIT_TEST(GroupByEmptyColumn) { NYql::TAstParseResult res = SqlToYql("select count(1) from plato.Input group by ``;"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:43: Error: Column name can not be empty\n"); @@ -2501,31 +2501,31 @@ Y_UNIT_TEST_SUITE(SqlToYQLErrors) { UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:2:8: Error: Failed to parse negative integer: -9223372036854775809, number limit overflow\n"); } - Y_UNIT_TEST(InvaildUsageReal0) { + Y_UNIT_TEST(InvaildUsageReal0) { NYql::TAstParseResult res = SqlToYql("select .0;"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:7: Error: Unexpected token '.' : cannot match to any predicted input...\n\n"); } - Y_UNIT_TEST(InvaildUsageReal1) { + Y_UNIT_TEST(InvaildUsageReal1) { NYql::TAstParseResult res = SqlToYql("select .0f;"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:7: Error: Unexpected token '.' : cannot match to any predicted input...\n\n"); } - Y_UNIT_TEST(InvaildUsageWinFunctionWithoutWindow) { + Y_UNIT_TEST(InvaildUsageWinFunctionWithoutWindow) { NYql::TAstParseResult res = SqlToYql("select lead(key, 2) from plato.Input;"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:8: Error: Failed to use window function Lead without window specification\n"); } - Y_UNIT_TEST(DropTableWithIfExists) { + Y_UNIT_TEST(DropTableWithIfExists) { NYql::TAstParseResult res = SqlToYql("DROP TABLE IF EXISTS plato.foo;"); UNIT_ASSERT(!res.Root); UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:0: Error: IF EXISTS in DROP TABLE is not supported.\n"); } - Y_UNIT_TEST(TooManyErrors) { + Y_UNIT_TEST(TooManyErrors) { const char* q = R"( USE plato; select A, B, C, D, E, F, G, H, I, J, K, L, M, N from (select b from `abc`); @@ -2547,7 +2547,7 @@ Y_UNIT_TEST_SUITE(SqlToYQLErrors) { )"); }; - Y_UNIT_TEST(ShouldCloneBindingForNamedParameter) { + Y_UNIT_TEST(ShouldCloneBindingForNamedParameter) { NYql::TAstParseResult res = SqlToYql(R"($f = () -> { $value_type = TypeOf(1); $pair_type = StructType( diff --git a/ydb/library/yql/udfs/common/re2/re2_udf.cpp b/ydb/library/yql/udfs/common/re2/re2_udf.cpp index b478675fb60..17ff4cb5601 100644 --- a/ydb/library/yql/udfs/common/re2/re2_udf.cpp +++ b/ydb/library/yql/udfs/common/re2/re2_udf.cpp @@ -58,8 +58,8 @@ namespace { GREP, CAPTURE, REPLACE, - COUNT, - FIND_AND_CONSUME, + COUNT, + FIND_AND_CONSUME, }; template <bool posix> @@ -104,7 +104,7 @@ namespace { static auto capture = TStringRef::Of("Capture"); static auto replace = TStringRef::Of("Replace"); static auto count = TStringRef::Of("Count"); - static auto findAndconsume = TStringRef::Of("FindAndConsume"); + static auto findAndconsume = TStringRef::Of("FindAndConsume"); switch (mode) { case EMode::MATCH: @@ -117,10 +117,10 @@ namespace { return replace; case EMode::COUNT: return count; - case EMode::FIND_AND_CONSUME: - return findAndconsume; + case EMode::FIND_AND_CONSUME: + return findAndconsume; } - Y_FAIL("Unexpected mode"); + Y_FAIL("Unexpected mode"); } TRe2Udf( diff --git a/ydb/library/yql/udfs/common/stat/static/tdigest.cpp b/ydb/library/yql/udfs/common/stat/static/tdigest.cpp index b8668eb27b0..f8a89d62611 100644 --- a/ydb/library/yql/udfs/common/stat/static/tdigest.cpp +++ b/ydb/library/yql/udfs/common/stat/static/tdigest.cpp @@ -21,7 +21,7 @@ TDigest::TDigest(const TString& serializedDigest) : N(0) { NTDigest::TDigest digest; - Y_VERIFY(digest.ParseFromString(serializedDigest)); + Y_VERIFY(digest.ParseFromString(serializedDigest)); Delta = digest.GetDelta(); K = digest.GetK(); for (int i = 0; i < digest.centroids_size(); ++i) { diff --git a/ydb/library/yql/udfs/common/string/string_udf.cpp b/ydb/library/yql/udfs/common/string/string_udf.cpp index c468215090b..32f88523102 100644 --- a/ydb/library/yql/udfs/common/string/string_udf.cpp +++ b/ydb/library/yql/udfs/common/string/string_udf.cpp @@ -157,7 +157,7 @@ namespace { XX(StartsWith, StartsWith) \ XX(EndsWith, EndsWith) \ XX(HasPrefix, StartsWith) \ - XX(HasSuffix, EndsWith) + XX(HasSuffix, EndsWith) #define STRING_TWO_ARGS_UDF_MAP(XX) \ XX(StartsWithIgnoreCase, AsciiHasPrefixIgnoreCase) \ diff --git a/ydb/library/yql/utils/backtrace/backtrace.h b/ydb/library/yql/utils/backtrace/backtrace.h index 487547e63b8..bdf5991a797 100644 --- a/ydb/library/yql/utils/backtrace/backtrace.h +++ b/ydb/library/yql/utils/backtrace/backtrace.h @@ -2,9 +2,9 @@ #include <util/system/types.h> -class IOutputStream; +class IOutputStream; -void KikimrBacktraceFormatImpl(IOutputStream* out); +void KikimrBacktraceFormatImpl(IOutputStream* out); void KikimrBacktraceFormatImpl(IOutputStream* out, void* const* stack, size_t stackSize); void KikimrBackTrace(); void EnableKikimrBacktraceFormat(); diff --git a/ydb/library/yql/utils/fetch/fetch.cpp b/ydb/library/yql/utils/fetch/fetch.cpp index 100c88c3858..3e365cb4ce2 100644 --- a/ydb/library/yql/utils/fetch/fetch.cpp +++ b/ydb/library/yql/utils/fetch/fetch.cpp @@ -46,18 +46,18 @@ public: TStringOutput rqs(req); TStringBuf userAgent = "User-Agent: Mozilla/5.0 (compatible; YQL/1.0)"; - IOutputStream::TPart request[] = { - IOutputStream::TPart("GET ", 4), + IOutputStream::TPart request[] = { + IOutputStream::TPart("GET ", 4), IOutputStream::TPart(path.data(), path.size()), - IOutputStream::TPart(" HTTP/1.1", 9), - IOutputStream::TPart::CrLf(), - IOutputStream::TPart("Host: ", 6), + IOutputStream::TPart(" HTTP/1.1", 9), + IOutputStream::TPart::CrLf(), + IOutputStream::TPart("Host: ", 6), IOutputStream::TPart(host.data(), host.size()), - IOutputStream::TPart::CrLf(), + IOutputStream::TPart::CrLf(), IOutputStream::TPart(userAgent.data(), userAgent.size()), - IOutputStream::TPart::CrLf(), + IOutputStream::TPart::CrLf(), }; - rqs.Write(request, Y_ARRAY_SIZE(request)); + rqs.Write(request, Y_ARRAY_SIZE(request)); if (!additionalHeaders.Empty()) { additionalHeaders.OutTo(&rqs); } @@ -75,10 +75,10 @@ public: } { - THttpOutput ho(Ssl ? (IOutputStream*)Ssl.Get() : (IOutputStream*)SocketOutput.Get()); + THttpOutput ho(Ssl ? (IOutputStream*)Ssl.Get() : (IOutputStream*)SocketOutput.Get()); (ho << req).Finish(); } - HttpInput.Reset(new THttpInput(Ssl ? (IInputStream*)Ssl.Get() : (IInputStream*)SocketInput.Get())); + HttpInput.Reset(new THttpInput(Ssl ? (IInputStream*)Ssl.Get() : (IInputStream*)SocketInput.Get())); } THttpInput& GetStream() override { diff --git a/ydb/library/yql/utils/fp_bits_ut.cpp b/ydb/library/yql/utils/fp_bits_ut.cpp index c93e848a66b..bb8673a4173 100644 --- a/ydb/library/yql/utils/fp_bits_ut.cpp +++ b/ydb/library/yql/utils/fp_bits_ut.cpp @@ -85,16 +85,16 @@ void CanonizeFpBitsTest() { } } -Y_UNIT_TEST_SUITE(TFpBits) { - Y_UNIT_TEST(CanonizeFloat) { +Y_UNIT_TEST_SUITE(TFpBits) { + Y_UNIT_TEST(CanonizeFloat) { CanonizeFpBitsTest<float>(); } - Y_UNIT_TEST(CanonizeDouble) { + Y_UNIT_TEST(CanonizeDouble) { CanonizeFpBitsTest<double>(); } - Y_UNIT_TEST(CanonizeLongDouble) { + Y_UNIT_TEST(CanonizeLongDouble) { if (NValgrind::ValgrindIsOn()) { return; // TODO https://st.yandex-team.ru/KIKIMR-3431 } diff --git a/ydb/library/yql/utils/log/context.cpp b/ydb/library/yql/utils/log/context.cpp index b591c42a779..118684dbf43 100644 --- a/ydb/library/yql/utils/log/context.cpp +++ b/ydb/library/yql/utils/log/context.cpp @@ -14,7 +14,7 @@ struct TThrowedLogContext { } // namspace -void OutputLogCtx(IOutputStream* out, bool withBraces) { +void OutputLogCtx(IOutputStream* out, bool withBraces) { const NImpl::TLogContextListItem* ctxList = NImpl::GetLogContextList(); if (ctxList->HasNext()) { diff --git a/ydb/library/yql/utils/log/log.cpp b/ydb/library/yql/utils/log/log.cpp index b62bfeb907a..8a2cea886ae 100644 --- a/ydb/library/yql/utils/log/log.cpp +++ b/ydb/library/yql/utils/log/log.cpp @@ -19,7 +19,7 @@ static int g_LoggerInitialized = 0; namespace { -void WriteLocalTime(IOutputStream* out) { +void WriteLocalTime(IOutputStream* out) { struct timeval now; gettimeofday(&now, nullptr); @@ -206,7 +206,7 @@ void InitLogger(TAutoPtr<TLogBackend> backend) { } } -void InitLogger(IOutputStream* out) { +void InitLogger(IOutputStream* out) { InitLogger(new TStreamLogBackend(out)); } diff --git a/ydb/library/yql/utils/log/log.h b/ydb/library/yql/utils/log/log.h index 8095fdd4952..74d86a21a15 100644 --- a/ydb/library/yql/utils/log/log.h +++ b/ydb/library/yql/utils/log/log.h @@ -161,7 +161,7 @@ void InitLogger(TAutoPtr<TLogBackend> backend); * * @param out - output stream */ -void InitLogger(IOutputStream* out); +void InitLogger(IOutputStream* out); void CleanupLogger(); diff --git a/ydb/library/yql/utils/log/log_ut.cpp b/ydb/library/yql/utils/log/log_ut.cpp index bf8b71476c0..5e77c8544c1 100644 --- a/ydb/library/yql/utils/log/log_ut.cpp +++ b/ydb/library/yql/utils/log/log_ut.cpp @@ -19,9 +19,9 @@ using namespace NYql; using namespace NLog; -Y_UNIT_TEST_SUITE(TLogTest) +Y_UNIT_TEST_SUITE(TLogTest) { - Y_UNIT_TEST(Format) { + Y_UNIT_TEST(Format) { TStringStream out; YqlLoggerScope logger(&out); YqlLogger().UpdateProcInfo("my_proc"); @@ -45,7 +45,7 @@ Y_UNIT_TEST_SUITE(TLogTest) UNIT_ASSERT_STRINGS_EQUAL(logRow.Message, message); } - Y_UNIT_TEST(Levels) { + Y_UNIT_TEST(Levels) { TStringStream out; YqlLoggerScope logger(&out); // default log level INFO @@ -85,7 +85,7 @@ Y_UNIT_TEST_SUITE(TLogTest) } } - Y_UNIT_TEST(Components) { + Y_UNIT_TEST(Components) { TStringStream out; YqlLoggerScope logger(&out); @@ -164,7 +164,7 @@ Y_UNIT_TEST_SUITE(TLogTest) } } - Y_UNIT_TEST(Conditional) { + Y_UNIT_TEST(Conditional) { TStringStream out; YqlLoggerScope logger(&out); @@ -191,7 +191,7 @@ Y_UNIT_TEST_SUITE(TLogTest) } } - Y_UNIT_TEST(Contexts) { + Y_UNIT_TEST(Contexts) { TStringStream out; YqlLoggerScope logger(&out); @@ -248,7 +248,7 @@ Y_UNIT_TEST_SUITE(TLogTest) } } - Y_UNIT_TEST(ThrowWithContext) { + Y_UNIT_TEST(ThrowWithContext) { bool isThrown = false; YQL_LOG_CTX_SCOPE("first"); try { @@ -280,7 +280,7 @@ Y_UNIT_TEST_SUITE(TLogTest) UNIT_ASSERT_C(isThrown, "exception was not thrown"); } - Y_UNIT_TEST(ContextOverride) { + Y_UNIT_TEST(ContextOverride) { TStringStream out; YqlLoggerScope logger(&out); @@ -344,7 +344,7 @@ Y_UNIT_TEST_SUITE(TLogTest) } } - Y_UNIT_TEST(Profiling) { + Y_UNIT_TEST(Profiling) { TStringStream out; YqlLoggerScope logger(&out); @@ -409,7 +409,7 @@ Y_UNIT_TEST_SUITE(TLogTest) return a + b; } - Y_UNIT_TEST(ProfilingFuncs) { + Y_UNIT_TEST(ProfilingFuncs) { TStringStream out; YqlLoggerScope logger(&out); diff --git a/ydb/library/yql/utils/log/tls_backend_ut.cpp b/ydb/library/yql/utils/log/tls_backend_ut.cpp index 6f4147fed6b..8a711f71f1e 100644 --- a/ydb/library/yql/utils/log/tls_backend_ut.cpp +++ b/ydb/library/yql/utils/log/tls_backend_ut.cpp @@ -48,9 +48,9 @@ private: TStringStream Logs_; }; -Y_UNIT_TEST_SUITE(TTlsLogBackendTest) +Y_UNIT_TEST_SUITE(TTlsLogBackendTest) { - Y_UNIT_TEST(CaptureOutputs) { + Y_UNIT_TEST(CaptureOutputs) { YqlLoggerScope logger(new TTlsLogBackend(new TNullLogBackend)); YQL_LOG(INFO) << "this message will be missed"; diff --git a/ydb/library/yql/utils/md5_stream_ut.cpp b/ydb/library/yql/utils/md5_stream_ut.cpp index 1d04c632d49..06e46fbd5ba 100644 --- a/ydb/library/yql/utils/md5_stream_ut.cpp +++ b/ydb/library/yql/utils/md5_stream_ut.cpp @@ -19,20 +19,20 @@ TString Consume(const TString& input) { } } -Y_UNIT_TEST_SUITE(TStreamMd5Tests) { - Y_UNIT_TEST(Empty) { +Y_UNIT_TEST_SUITE(TStreamMd5Tests) { + Y_UNIT_TEST(Empty) { const auto md5 = Consume(""); const TString emptyStringMd5 = "d41d8cd98f00b204e9800998ecf8427e"; UNIT_ASSERT_VALUES_EQUAL(md5, emptyStringMd5); } - Y_UNIT_TEST(ShortText) { + Y_UNIT_TEST(ShortText) { const auto md5 = Consume("hello from Y!"); const TString expectedMd5 = "abf59ed7b0daa71085e76e461a737cc2"; UNIT_ASSERT_VALUES_EQUAL(md5, expectedMd5); } - Y_UNIT_TEST(BigText) { + Y_UNIT_TEST(BigText) { // TransferData uses TempBuf of 64K const TString s(1000000, 'A'); const auto md5 = Consume(s.c_str()); diff --git a/ydb/library/yql/utils/multi_resource_lock_ut.cpp b/ydb/library/yql/utils/multi_resource_lock_ut.cpp index 0af9cea3fff..42f98915b15 100644 --- a/ydb/library/yql/utils/multi_resource_lock_ut.cpp +++ b/ydb/library/yql/utils/multi_resource_lock_ut.cpp @@ -6,8 +6,8 @@ namespace NYql { using namespace NThreading; -Y_UNIT_TEST_SUITE(TMultiResourceLock) { - Y_UNIT_TEST(ManyResources) { +Y_UNIT_TEST_SUITE(TMultiResourceLock) { + Y_UNIT_TEST(ManyResources) { TMultiResourceLock multiLock; const int workersCount = 3; TVector<TVector<int>> workersData; diff --git a/ydb/library/yql/utils/range_walker_ut.cpp b/ydb/library/yql/utils/range_walker_ut.cpp index d6a86cc8048..cb702aa39cc 100644 --- a/ydb/library/yql/utils/range_walker_ut.cpp +++ b/ydb/library/yql/utils/range_walker_ut.cpp @@ -4,12 +4,12 @@ using namespace NYql; -Y_UNIT_TEST_SUITE(TRangeWalkerTests) { - Y_UNIT_TEST(InvalidRange) { +Y_UNIT_TEST_SUITE(TRangeWalkerTests) { + Y_UNIT_TEST(InvalidRange) { UNIT_ASSERT_EXCEPTION_CONTAINS(TRangeWalker<int>(2, 1), yexception, "Invalid range for walker"); } - Y_UNIT_TEST(SingleValueRange) { + Y_UNIT_TEST(SingleValueRange) { TRangeWalker<int> w(5, 5); UNIT_ASSERT_EQUAL(5, w.GetStart()); UNIT_ASSERT_EQUAL(5, w.GetFinish()); @@ -20,7 +20,7 @@ Y_UNIT_TEST_SUITE(TRangeWalkerTests) { } } - Y_UNIT_TEST(ManyValuesRange) { + Y_UNIT_TEST(ManyValuesRange) { TRangeWalker<int> w(5, 7); UNIT_ASSERT_EQUAL(5, w.GetStart()); UNIT_ASSERT_EQUAL(7, w.GetFinish()); diff --git a/ydb/library/yql/utils/retry_ut.cpp b/ydb/library/yql/utils/retry_ut.cpp index 47cb35fd739..9e1e58c46d6 100644 --- a/ydb/library/yql/utils/retry_ut.cpp +++ b/ydb/library/yql/utils/retry_ut.cpp @@ -11,8 +11,8 @@ class TMyError : public yexception { } -Y_UNIT_TEST_SUITE(TRetryTests) { - Y_UNIT_TEST(ZeroAttempts) { +Y_UNIT_TEST_SUITE(TRetryTests) { + Y_UNIT_TEST(ZeroAttempts) { auto r = WithRetry<TMyError>(0, []() { return TString("abc"); }, [](auto, auto, auto) { UNIT_FAIL("Exception handler invoked"); }); @@ -20,7 +20,7 @@ Y_UNIT_TEST_SUITE(TRetryTests) { UNIT_ASSERT_VALUES_EQUAL("abc", r); } - Y_UNIT_TEST(NoRetries) { + Y_UNIT_TEST(NoRetries) { auto r = WithRetry<TMyError>(5, []() { return TString("abc"); }, [](auto, auto, auto) { UNIT_FAIL("Exception handler invoked"); }); @@ -28,13 +28,13 @@ Y_UNIT_TEST_SUITE(TRetryTests) { UNIT_ASSERT_VALUES_EQUAL("abc", r); } - Y_UNIT_TEST(NoRetriesButException) { + Y_UNIT_TEST(NoRetriesButException) { UNIT_ASSERT_EXCEPTION_CONTAINS(WithRetry<TMyError>(5, []() { throw yexception() << "xxxx"; }, [](auto, auto, auto) { UNIT_FAIL("Exception handler invoked"); }), yexception, "xxxx"); } - Y_UNIT_TEST(FewRetries) { + Y_UNIT_TEST(FewRetries) { int counter = 0; int exceptions = 0; auto r = WithRetry<TMyError>(3, [&]() { @@ -55,7 +55,7 @@ Y_UNIT_TEST_SUITE(TRetryTests) { UNIT_ASSERT_VALUES_EQUAL(3, counter); } - Y_UNIT_TEST(ManyRetries) { + Y_UNIT_TEST(ManyRetries) { int counter = 0; int exceptions = 0; UNIT_ASSERT_EXCEPTION_CONTAINS(WithRetry<TMyError>(3, [&]() { diff --git a/ydb/public/lib/deprecated/client/grpc_client.cpp b/ydb/public/lib/deprecated/client/grpc_client.cpp index dbf808ef752..45ae0f452f3 100644 --- a/ydb/public/lib/deprecated/client/grpc_client.cpp +++ b/ydb/public/lib/deprecated/client/grpc_client.cpp @@ -12,7 +12,7 @@ namespace NKikimr { namespace NGRpcProxy { - class TGRpcClient::TImpl : ISimpleThread { + class TGRpcClient::TImpl : ISimpleThread { struct IProcessorBase { virtual ~IProcessorBase() = default; virtual void Start() = 0; @@ -195,7 +195,7 @@ namespace NKikimr { if (config.Timeout != TDuration::Max()) { Timeout = config.Timeout; } - ISimpleThread::Start(); + ISimpleThread::Start(); } ~TImpl() { diff --git a/ydb/public/lib/deprecated/client/msgbus_client.cpp b/ydb/public/lib/deprecated/client/msgbus_client.cpp index 4d5f2427ebd..8a06ce24190 100644 --- a/ydb/public/lib/deprecated/client/msgbus_client.cpp +++ b/ydb/public/lib/deprecated/client/msgbus_client.cpp @@ -22,7 +22,7 @@ void TMsgBusClientConfig::CrackAddress(const TString& address, TString& hostname port = FromString<ui32>(address.substr(last_colon_pos + 1)); hostname = address.substr(0, last_colon_pos); } - if (hostname.StartsWith('[') && hostname.EndsWith(']')) { + if (hostname.StartsWith('[') && hostname.EndsWith(']')) { hostname = hostname.substr(1, hostname.size() - 2); } } @@ -129,7 +129,7 @@ void TMsgBusClient::Shutdown() { } NBus::EMessageStatus TMsgBusClient::SyncCall(TAutoPtr<NBus::TBusMessage> msg, TAutoPtr<NBus::TBusMessage> &reply) { - Y_VERIFY(!msg->Data); + Y_VERIFY(!msg->Data); TAutoPtr<TSyncMessageCookie> cookie(new TSyncMessageCookie()); msg->Data = cookie.Get(); diff --git a/ydb/public/lib/deprecated/client/msgbus_player.cpp b/ydb/public/lib/deprecated/client/msgbus_player.cpp index befa19f73a1..572b96f41c4 100644 --- a/ydb/public/lib/deprecated/client/msgbus_player.cpp +++ b/ydb/public/lib/deprecated/client/msgbus_player.cpp @@ -3,7 +3,7 @@ #include <util/system/fstat.h> #include <util/stream/file.h> #include <util/random/random.h> -#include <util/string/printf.h> +#include <util/string/printf.h> #include <util/system/condvar.h> namespace NKikimr { @@ -46,13 +46,13 @@ public: : MaxInFlight(maxInFlight) , ComputedMaxInFlight(0) { - Y_VERIFY(maxInFlight > 0); + Y_VERIFY(maxInFlight > 0); } void Start(TType item) { MaxInFlight.Acquire(); auto guard = Guard(InFlightLock); - Y_UNUSED(guard); + Y_UNUSED(guard); InFlight.insert(item); ComputedMaxInFlight = std::max(ComputedMaxInFlight, static_cast<ui32>(InFlight.size())); } @@ -60,7 +60,7 @@ public: void Finish(TType item) { { auto guard = Guard(InFlightLock); - Y_UNUSED(guard); + Y_UNUSED(guard); InFlight.erase(item); InFlightFinished.Signal(); } @@ -69,7 +69,7 @@ public: bool WaitForFinish(TType item) { auto guard = Guard(InFlightLock); - Y_UNUSED(guard); + Y_UNUSED(guard); while(InFlight.count(item) != 0) { InFlightFinished.WaitI(InFlightLock); } diff --git a/ydb/public/lib/deprecated/kicli/cpp_ut.cpp b/ydb/public/lib/deprecated/kicli/cpp_ut.cpp index cb7dc3ed6d9..6b386827ad7 100644 --- a/ydb/public/lib/deprecated/kicli/cpp_ut.cpp +++ b/ydb/public/lib/deprecated/kicli/cpp_ut.cpp @@ -86,7 +86,7 @@ bool HasChild(const NKikimr::NClient::TSchemaObject& obj, const char * path) { } // namespace -Y_UNIT_TEST_SUITE(ClientLibSchema) { +Y_UNIT_TEST_SUITE(ClientLibSchema) { static void RootExists(NClient::TKikimr& kikimr) { auto root = kikimr.GetSchemaRoot(); auto children = root.GetChildren(); @@ -94,7 +94,7 @@ Y_UNIT_TEST_SUITE(ClientLibSchema) { //UNIT_ASSERT(children.empty()); } - Y_UNIT_TEST(RootExists) { + Y_UNIT_TEST(RootExists) { NMsgBusProxy::TMsgBusClientConfig clientConfig; Tests::TServer server = StartupKikimr(clientConfig); NClient::TKikimr kikimr(clientConfig); @@ -102,7 +102,7 @@ Y_UNIT_TEST_SUITE(ClientLibSchema) { RootExists(kikimr); } - Y_UNIT_TEST(RootExists_GRpc) { + Y_UNIT_TEST(RootExists_GRpc) { NGRpcProxy::TGRpcClientConfig clientConfig; Tests::TServer server = StartupKikimr(clientConfig); NClient::TKikimr kikimr(clientConfig); @@ -116,7 +116,7 @@ Y_UNIT_TEST_SUITE(ClientLibSchema) { UNIT_ASSERT(std::find_if(children.begin(), children.end(), [](const NClient::TSchemaObject& s) -> bool { return s.GetPath() == "/dc-1"; }) != children.end()); } - Y_UNIT_TEST(RootDcExists) { + Y_UNIT_TEST(RootDcExists) { NMsgBusProxy::TMsgBusClientConfig clientConfig; Tests::TServer server = StartupKikimr(clientConfig); NClient::TKikimr kikimr(clientConfig); @@ -124,7 +124,7 @@ Y_UNIT_TEST_SUITE(ClientLibSchema) { RootDcExists(kikimr); } - Y_UNIT_TEST(RootDcExists_GRpc) { + Y_UNIT_TEST(RootDcExists_GRpc) { NGRpcProxy::TGRpcClientConfig clientConfig; Tests::TServer server = StartupKikimr(clientConfig); NClient::TKikimr kikimr(clientConfig); @@ -141,7 +141,7 @@ Y_UNIT_TEST_SUITE(ClientLibSchema) { UNIT_ASSERT(dc.GetChildren().empty()); } - Y_UNIT_TEST(RootDcStartsEmpty) { + Y_UNIT_TEST(RootDcStartsEmpty) { NMsgBusProxy::TMsgBusClientConfig clientConfig; Tests::TServer server = StartupKikimr(clientConfig); NClient::TKikimr kikimr(clientConfig); @@ -149,7 +149,7 @@ Y_UNIT_TEST_SUITE(ClientLibSchema) { RootDcStartsEmpty(kikimr); } - Y_UNIT_TEST(RootDcStartsEmpty_GRpc) { + Y_UNIT_TEST(RootDcStartsEmpty_GRpc) { NGRpcProxy::TGRpcClientConfig clientConfig; Tests::TServer server = StartupKikimr(clientConfig); NClient::TKikimr kikimr(clientConfig); @@ -206,7 +206,7 @@ Y_UNIT_TEST_SUITE(ClientLibSchema) { #endif } - Y_UNIT_TEST(CreateTable) { + Y_UNIT_TEST(CreateTable) { NMsgBusProxy::TMsgBusClientConfig clientConfig; Tests::TServer server = StartupKikimr(clientConfig); NClient::TKikimr kikimr(clientConfig); @@ -214,7 +214,7 @@ Y_UNIT_TEST_SUITE(ClientLibSchema) { CreateTable(kikimr); } - Y_UNIT_TEST(CreateTable_GRpc) { + Y_UNIT_TEST(CreateTable_GRpc) { NGRpcProxy::TGRpcClientConfig clientConfig; Tests::TServer server = StartupKikimr(clientConfig); NClient::TKikimr kikimr(clientConfig); @@ -253,7 +253,7 @@ Y_UNIT_TEST_SUITE(ClientLibSchema) { } } - Y_UNIT_TEST(MkDir) { + Y_UNIT_TEST(MkDir) { NMsgBusProxy::TMsgBusClientConfig clientConfig; Tests::TServer server = StartupKikimr(clientConfig); NClient::TKikimr kikimr(clientConfig); @@ -261,7 +261,7 @@ Y_UNIT_TEST_SUITE(ClientLibSchema) { MkDir(kikimr); } - Y_UNIT_TEST(MkDir_GRpc) { + Y_UNIT_TEST(MkDir_GRpc) { NGRpcProxy::TGRpcClientConfig clientConfig; Tests::TServer server = StartupKikimr(clientConfig); NClient::TKikimr kikimr(clientConfig); @@ -284,7 +284,7 @@ Y_UNIT_TEST_SUITE(ClientLibSchema) { UNIT_ASSERT_VALUES_EQUAL(zoo.GetChild("Animals").GetStats().PartitionsCount, 4); } - Y_UNIT_TEST(CreatePartitionedTable) { + Y_UNIT_TEST(CreatePartitionedTable) { NMsgBusProxy::TMsgBusClientConfig clientConfig; Tests::TServer server = StartupKikimr(clientConfig); NClient::TKikimr kikimr(clientConfig); @@ -292,7 +292,7 @@ Y_UNIT_TEST_SUITE(ClientLibSchema) { CreatePartitionedTable(kikimr); } - Y_UNIT_TEST(CreatePartitionedTable_GRpc) { + Y_UNIT_TEST(CreatePartitionedTable_GRpc) { NGRpcProxy::TGRpcClientConfig clientConfig; Tests::TServer server = StartupKikimr(clientConfig); NClient::TKikimr kikimr(clientConfig); @@ -315,7 +315,7 @@ Y_UNIT_TEST_SUITE(ClientLibSchema) { UNIT_ASSERT_VALUES_EQUAL(zoo.GetChild("Animals").GetStats().PartitionsCount, numParts); } - Y_UNIT_TEST(CreateVeryPartitionedTable) { + Y_UNIT_TEST(CreateVeryPartitionedTable) { NMsgBusProxy::TMsgBusClientConfig clientConfig; Tests::TServer server = StartupKikimr(clientConfig); NClient::TKikimr kikimr(clientConfig); @@ -323,7 +323,7 @@ Y_UNIT_TEST_SUITE(ClientLibSchema) { CreateVeryPartitionedTable(kikimr); } - Y_UNIT_TEST(CreateVeryPartitionedTable_GRpc) { + Y_UNIT_TEST(CreateVeryPartitionedTable_GRpc) { NGRpcProxy::TGRpcClientConfig clientConfig; Tests::TServer server = StartupKikimr(clientConfig); NClient::TKikimr kikimr(clientConfig); @@ -376,7 +376,7 @@ Y_UNIT_TEST_SUITE(ClientLibSchema) { UNIT_ASSERT_EQUAL(dc.GetChildren().size(), 0); } - Y_UNIT_TEST(Drop) { + Y_UNIT_TEST(Drop) { NMsgBusProxy::TMsgBusClientConfig clientConfig; Tests::TServer server = StartupKikimr(clientConfig); NClient::TKikimr kikimr(clientConfig); @@ -384,7 +384,7 @@ Y_UNIT_TEST_SUITE(ClientLibSchema) { Drop(kikimr); } - Y_UNIT_TEST(Drop_GRpc) { + Y_UNIT_TEST(Drop_GRpc) { NGRpcProxy::TGRpcClientConfig clientConfig; Tests::TServer server = StartupKikimr(clientConfig); NClient::TKikimr kikimr(clientConfig); @@ -407,7 +407,7 @@ Y_UNIT_TEST_SUITE(ClientLibSchema) { } } - Y_UNIT_TEST(MaxPath) { + Y_UNIT_TEST(MaxPath) { NMsgBusProxy::TMsgBusClientConfig clientConfig; Tests::TServer server = StartupKikimr(clientConfig); NClient::TKikimr kikimr(clientConfig); @@ -415,7 +415,7 @@ Y_UNIT_TEST_SUITE(ClientLibSchema) { MaxPath(kikimr); } - Y_UNIT_TEST(MaxPath_GRpc) { + Y_UNIT_TEST(MaxPath_GRpc) { NGRpcProxy::TGRpcClientConfig clientConfig; Tests::TServer server = StartupKikimr(clientConfig); NClient::TKikimr kikimr(clientConfig); @@ -425,8 +425,8 @@ Y_UNIT_TEST_SUITE(ClientLibSchema) { #endif } -Y_UNIT_TEST_SUITE(ClientLib) { - Y_UNIT_TEST(Test6) { +Y_UNIT_TEST_SUITE(ClientLib) { + Y_UNIT_TEST(Test6) { TTestEnvironment env; NClient::TKikimr& kikimr = env.Kikimr; @@ -447,7 +447,7 @@ Y_UNIT_TEST_SUITE(ClientLib) { UNIT_ASSERT(value.IsNull()); } - Y_UNIT_TEST(Test7) { + Y_UNIT_TEST(Test7) { TTestEnvironment env; NClient::TKikimr& kikimr = env.Kikimr; @@ -485,7 +485,7 @@ Y_UNIT_TEST_SUITE(ClientLib) { } } - Y_UNIT_TEST(Test8) { + Y_UNIT_TEST(Test8) { TTestEnvironment env; NClient::TKikimr& kikimr = env.Kikimr; @@ -523,7 +523,7 @@ Y_UNIT_TEST_SUITE(ClientLib) { } } - Y_UNIT_TEST(Test9) { + Y_UNIT_TEST(Test9) { TTestEnvironment env; NClient::TKikimr& kikimr = env.Kikimr; @@ -578,7 +578,7 @@ Y_UNIT_TEST_SUITE(ClientLib) { UNIT_ASSERT_VALUES_EQUAL((i64)readResult["myRes"][1]["Weight"], 500); } - Y_UNIT_TEST(Test10) { + Y_UNIT_TEST(Test10) { using namespace NClient; TTestEnvironment env({ NClient::TKeyColumn("Id", NClient::TType::Uint64), @@ -652,7 +652,7 @@ Y_UNIT_TEST_SUITE(ClientLib) { UNIT_ASSERT_VALUES_EQUAL((i64)value["myRes"][1]["Weight"], 500); } - Y_UNIT_TEST(Test11) { + Y_UNIT_TEST(Test11) { using namespace NClient; TTestEnvironment env; NClient::TKikimr& kikimr = env.Kikimr; @@ -711,7 +711,7 @@ Y_UNIT_TEST_SUITE(ClientLib) { "Korzhik\tRat\t500\n\n"); } - Y_UNIT_TEST(Test12) { + Y_UNIT_TEST(Test12) { TTestEnvironment env; NClient::TKikimr& kikimr = env.Kikimr; @@ -736,7 +736,7 @@ Y_UNIT_TEST_SUITE(ClientLib) { UNIT_ASSERT_STRING_CONTAINS(error.GetMessage(), "<main>:1:34: Error: expected either let, return or import"); } - Y_UNIT_TEST(Test13) { + Y_UNIT_TEST(Test13) { TTestEnvironment env; NClient::TKikimr& kikimr = env.Kikimr; @@ -761,7 +761,7 @@ Y_UNIT_TEST_SUITE(ClientLib) { UNIT_ASSERT_STRING_CONTAINS(error.GetMessage(), "Mismatch of column type expectedType = 3 actual type = 4608"); } - Y_UNIT_TEST(Test14) { + Y_UNIT_TEST(Test14) { TTestEnvironment env; NClient::TKikimr& kikimr = env.Kikimr; @@ -789,7 +789,7 @@ Y_UNIT_TEST_SUITE(ClientLib) { " <main>:1:91: Error: Bad atom format for type: Int64, value: \"Dobby\"\n"); } - Y_UNIT_TEST(Test15) { + Y_UNIT_TEST(Test15) { TTestEnvironment env({ NClient::TKeyPartitioningColumn("Id", NClient::TType::Uint64, 4), NClient::TColumn("Species", NClient::TType::Utf8), @@ -854,7 +854,7 @@ Y_UNIT_TEST_SUITE(ClientLib) { UNIT_ASSERT_VALUES_EQUAL((i64)value["myRes"][1]["Weight"], 500); } - Y_UNIT_TEST(Test16) { + Y_UNIT_TEST(Test16) { using namespace NClient; TTestEnvironment env({ TKeyPartitioningColumn("Id", NClient::TType::Uint64, 4), @@ -977,7 +977,7 @@ Y_UNIT_TEST_SUITE(ClientLib) { return shardRange; } - Y_UNIT_TEST(Test17) { + Y_UNIT_TEST(Test17) { using namespace NClient; TTestEnvironment env({ TKeyPartitioningColumn("Id", NClient::TType::Uint64, 4), @@ -1009,7 +1009,7 @@ Y_UNIT_TEST_SUITE(ClientLib) { } } - Y_UNIT_TEST(Test18) { + Y_UNIT_TEST(Test18) { using namespace NClient; TTestEnvironment env; NClient::TKikimr& kikimr = env.Kikimr; @@ -1070,7 +1070,7 @@ Y_UNIT_TEST_SUITE(ClientLib) { "{\"myRes\": [{\"Name\": \"Dobby\", \"Species\": \"Rat\", \"Weight\": 350}, {\"Name\": \"Korzhik\", \"Species\": \"Rat\", \"Weight\": 500}]}"); } - Y_UNIT_TEST(Test19) { + Y_UNIT_TEST(Test19) { using namespace NClient; TTestEnvironment env; NClient::TKikimr& kikimr = env.Kikimr; @@ -1127,7 +1127,7 @@ Y_UNIT_TEST_SUITE(ClientLib) { "{\"myRes\": [{\"Name\": \"Dobby\", \"Species\": \"Rat\", \"Weight\": 350}, {\"Name\": \"Korzhik\", \"Species\": \"Rat\", \"Weight\": 500}]}"); } - Y_UNIT_TEST(Test20) { + Y_UNIT_TEST(Test20) { using namespace NClient; TTestEnvironment env; NClient::TKikimr& kikimr = env.Kikimr; @@ -1211,7 +1211,7 @@ Y_UNIT_TEST_SUITE(ClientLib) { "{\"myRes\": [{\"Name\": \"Dobby\", \"Species\": \"Rat\", \"Weight\": 350}, {\"Name\": \"Korzhik\", \"Species\": \"Rat\", \"Weight\": 500}]}"); } - Y_UNIT_TEST(Test21) { + Y_UNIT_TEST(Test21) { using namespace NClient; TTestEnvironment env; NClient::TKikimr& kikimr = env.Kikimr; @@ -1281,7 +1281,7 @@ Y_UNIT_TEST_SUITE(ClientLib) { "{\"myRes\": [{\"Name\": \"Dobby\", \"Species\": \"Rat\", \"Weight\": 350}, {\"Name\": \"Korzhik\", \"Species\": \"Rat\", \"Weight\": 500}]}"); } - Y_UNIT_TEST(Test22) { + Y_UNIT_TEST(Test22) { using namespace NClient; TTestEnvironment env; NClient::TKikimr& kikimr = env.Kikimr; @@ -1353,7 +1353,7 @@ Y_UNIT_TEST_SUITE(ClientLib) { "{\"myRes\": [{\"Name\": \"Dobby\", \"Species\": \"Rat\", \"Weight\": 350}, {\"Name\": \"Korzhik\", \"Species\": \"Rat\", \"Weight\": 500}]}"); } - Y_UNIT_TEST(Test24) { + Y_UNIT_TEST(Test24) { TTestEnvironment env; NClient::TKikimr& kikimr = env.Kikimr; @@ -1374,7 +1374,7 @@ Y_UNIT_TEST_SUITE(ClientLib) { UNIT_ASSERT(value.IsNull()); } - Y_UNIT_TEST(Test25) { + Y_UNIT_TEST(Test25) { TTestEnvironment env; NClient::TKikimr& kikimr = env.Kikimr; @@ -1396,7 +1396,7 @@ Y_UNIT_TEST_SUITE(ClientLib) { UNIT_ASSERT(value.IsNull()); } - Y_UNIT_TEST(SameTableDifferentColumns) { + Y_UNIT_TEST(SameTableDifferentColumns) { using namespace NClient; NMsgBusProxy::TMsgBusClientConfig clientConfig; Tests::TServer server = StartupKikimr(clientConfig); @@ -1549,7 +1549,7 @@ Y_UNIT_TEST_SUITE(ClientLib) { } } - Y_UNIT_TEST(SelectRangeWithInf) { + Y_UNIT_TEST(SelectRangeWithInf) { using namespace NClient; NMsgBusProxy::TMsgBusClientConfig clientConfig; Tests::TServer server = StartupKikimr(clientConfig); @@ -1617,7 +1617,7 @@ Y_UNIT_TEST_SUITE(ClientLib) { } - Y_UNIT_TEST(TypicalCase1) { + Y_UNIT_TEST(TypicalCase1) { using namespace NClient; NMsgBusProxy::TMsgBusClientConfig clientConfig; Tests::TServer server = StartupKikimr(clientConfig); @@ -1692,7 +1692,7 @@ Y_UNIT_TEST_SUITE(ClientLib) { } } - Y_UNIT_TEST(TypicalCase2) { + Y_UNIT_TEST(TypicalCase2) { using namespace NClient; NMsgBusProxy::TMsgBusClientConfig clientConfig; Tests::TServer server = StartupKikimr(clientConfig); @@ -1837,7 +1837,7 @@ Y_UNIT_TEST_SUITE(ClientLib) { } } - Y_UNIT_TEST(TypicalCase2A) { + Y_UNIT_TEST(TypicalCase2A) { using namespace NClient; NMsgBusProxy::TMsgBusClientConfig clientConfig; Tests::TServer server = StartupKikimr(clientConfig); @@ -1983,7 +1983,7 @@ Y_UNIT_TEST_SUITE(ClientLib) { } } - Y_UNIT_TEST(TestParameterTypes) { + Y_UNIT_TEST(TestParameterTypes) { using namespace NClient; NMsgBusProxy::TMsgBusClientConfig clientConfig; Tests::TServer server = StartupKikimr(clientConfig); @@ -2044,7 +2044,7 @@ Y_UNIT_TEST_SUITE(ClientLib) { UNIT_ASSERT_EQUAL((TString)value["ru"], "Str2"); } -// Y_UNIT_TEST(Wrongdoing1) { +// Y_UNIT_TEST(Wrongdoing1) { // using namespace NClient; // TString type = R"___( // Kind: 6 diff --git a/ydb/public/lib/deprecated/kicli/query.cpp b/ydb/public/lib/deprecated/kicli/query.cpp index c614b5b3fdb..813d608bafe 100644 --- a/ydb/public/lib/deprecated/kicli/query.cpp +++ b/ydb/public/lib/deprecated/kicli/query.cpp @@ -10,7 +10,7 @@ TQuery::TQuery(TKikimr& kikimr) void TQuery::ParseTextParameters(NKikimrMiniKQL::TParams& params, const TString& parameters) { if (!parameters.empty()) { bool ok = ::google::protobuf::TextFormat::ParseFromString(parameters, ¶ms); - Y_VERIFY(ok); + Y_VERIFY(ok); } } diff --git a/ydb/public/lib/deprecated/kicli/result.cpp b/ydb/public/lib/deprecated/kicli/result.cpp index 0f86ba4340a..4adc61d9de9 100644 --- a/ydb/public/lib/deprecated/kicli/result.cpp +++ b/ydb/public/lib/deprecated/kicli/result.cpp @@ -80,7 +80,7 @@ TQueryResult::TQueryResult(const TResult& result) TValue TQueryResult::GetValue() const { const NKikimrClient::TResponse& response = GetResult<NKikimrClient::TResponse>(); - Y_VERIFY(response.HasExecutionEngineEvaluatedResponse()); + Y_VERIFY(response.HasExecutionEngineEvaluatedResponse()); const auto& result = response.GetExecutionEngineEvaluatedResponse(); // TODO: type caching return TValue::Create(result.GetValue(), result.GetType()); diff --git a/ydb/public/lib/deprecated/kicli/schema.cpp b/ydb/public/lib/deprecated/kicli/schema.cpp index d1ee0384f8b..086679e07b1 100644 --- a/ydb/public/lib/deprecated/kicli/schema.cpp +++ b/ydb/public/lib/deprecated/kicli/schema.cpp @@ -66,7 +66,7 @@ ui16 TType::GetId() const { TSchemaObject::TSchemaObject(TKikimr& kikimr, const TString& path, const TString& name, ui64 pathId, EPathType pathType) : Kikimr(kikimr) - , Path(path.EndsWith('/') ? path + name : path + "/" + name) + , Path(path.EndsWith('/') ? path + name : path + "/" + name) , Name(name) , PathId(pathId) , PathType(pathType) diff --git a/ydb/public/lib/operation_id/operation_id_ut.cpp b/ydb/public/lib/operation_id/operation_id_ut.cpp index 64fbedce4bf..d6b51e1ee2f 100644 --- a/ydb/public/lib/operation_id/operation_id_ut.cpp +++ b/ydb/public/lib/operation_id/operation_id_ut.cpp @@ -6,8 +6,8 @@ namespace NKikimr { namespace NOperationId { -Y_UNIT_TEST_SUITE(OperationIdTest) { - Y_UNIT_TEST(ConvertKindOnly) { +Y_UNIT_TEST_SUITE(OperationIdTest) { + Y_UNIT_TEST(ConvertKindOnly) { Ydb::TOperationId proto; proto.SetKind(Ydb::TOperationId::OPERATION_DDL); auto str = ProtoToString(proto); @@ -17,7 +17,7 @@ Y_UNIT_TEST_SUITE(OperationIdTest) { UNIT_ASSERT_EQUAL(newProto.DataSize(), 0); } - Y_UNIT_TEST(ConvertKindAndValues) { + Y_UNIT_TEST(ConvertKindAndValues) { Ydb::TOperationId proto; proto.SetKind(Ydb::TOperationId::OPERATION_DDL); { diff --git a/ydb/services/persqueue_v1/persqueue_ut.cpp b/ydb/services/persqueue_v1/persqueue_ut.cpp index 3bc9b217285..5f8bfd4268d 100644 --- a/ydb/services/persqueue_v1/persqueue_ut.cpp +++ b/ydb/services/persqueue_v1/persqueue_ut.cpp @@ -461,7 +461,7 @@ namespace { writer.Write(SHORT_TOPIC_NAME, {"valuevaluevalue1"}, true); } - Y_UNIT_TEST(CloseActiveWriteSessionOnClusterDisable) { + Y_UNIT_TEST(CloseActiveWriteSessionOnClusterDisable) { NPersQueue::TTestServer server; server.AnnoyingClient->CreateTopic(DEFAULT_TOPIC_NAME, 10); @@ -517,7 +517,7 @@ namespace { UNIT_ASSERT(writer->Close()); } - Y_UNIT_TEST(ReadFromSeveralPartitions) { + Y_UNIT_TEST(ReadFromSeveralPartitions) { NPersQueue::TTestServer server; server.EnableLogs({ NKikimrServices::PQ_READ_PROXY, NKikimrServices::PQ_METACACHE }); @@ -625,7 +625,7 @@ namespace { } - Y_UNIT_TEST(WriteExisting) { + Y_UNIT_TEST(WriteExisting) { NPersQueue::TTestServer server; server.EnableLogs({ NKikimrServices::FLAT_TX_SCHEMESHARD, NKikimrServices::PERSQUEUE }); @@ -648,7 +648,7 @@ namespace { server.AnnoyingClient->WriteToPQ(DEFAULT_TOPIC_NAME, 1, "abacaba", 2, "valuevaluevalue1", "", ETransport::GRpc); } - Y_UNIT_TEST(WriteExistingBigValue) { + Y_UNIT_TEST(WriteExistingBigValue) { NPersQueue::TTestServer server(PQSettings(0).SetDomainName("Root").SetNodeCount(2)); server.EnableLogs({ NKikimrServices::FLAT_TX_SCHEMESHARD, NKikimrServices::PERSQUEUE }); server.AnnoyingClient->CreateTopic(DEFAULT_TOPIC_NAME, 2, 8*1024*1024, 86400, 100000); @@ -661,7 +661,7 @@ namespace { UNIT_ASSERT(TInstant::Now() - now > TDuration::MilliSeconds(5990)); //speed limit is 200kb/s and burst is 200kb, so to write 1mb it will take at least 4 seconds } - Y_UNIT_TEST(WriteEmptyData) { + Y_UNIT_TEST(WriteEmptyData) { NPersQueue::TTestServer server{PQSettings(0).SetDomainName("Root").SetNodeCount(2)}; server.AnnoyingClient->CreateTopic(DEFAULT_TOPIC_NAME, 2); @@ -676,7 +676,7 @@ namespace { } - Y_UNIT_TEST(WriteNonExistingPartition) { + Y_UNIT_TEST(WriteNonExistingPartition) { NPersQueue::TTestServer server{PQSettings(0).SetDomainName("Root").SetNodeCount(2)}; server.AnnoyingClient->CreateTopic(DEFAULT_TOPIC_NAME, 2); @@ -688,7 +688,7 @@ namespace { ); } - Y_UNIT_TEST(WriteNonExistingTopic) { + Y_UNIT_TEST(WriteNonExistingTopic) { NPersQueue::TTestServer server(PQSettings(0).SetDomainName("Root").SetNodeCount(2)); server.AnnoyingClient->CreateTopic(DEFAULT_TOPIC_NAME, 2); server.EnableLogs({ NKikimrServices::FLAT_TX_SCHEMESHARD, NKikimrServices::PERSQUEUE }); @@ -699,7 +699,7 @@ namespace { ); } - Y_UNIT_TEST(SchemeshardRestart) { + Y_UNIT_TEST(SchemeshardRestart) { NPersQueue::TTestServer server(PQSettings(0).SetDomainName("Root").SetNodeCount(1)); server.AnnoyingClient->CreateTopic(DEFAULT_TOPIC_NAME, 2); TString secondTopic = "rt3.dc1--topic2"; @@ -717,7 +717,7 @@ namespace { server.AnnoyingClient->WriteToPQ(secondTopic, 1, "abacaba", 1, "valuevaluevalue1"); } - Y_UNIT_TEST(WriteAfterAlter) { + Y_UNIT_TEST(WriteAfterAlter) { NPersQueue::TTestServer server(PQSettings(0).SetDomainName("Root").SetNodeCount(2)); server.AnnoyingClient->CreateTopic(DEFAULT_TOPIC_NAME, 2); @@ -745,7 +745,7 @@ namespace { server.AnnoyingClient->WriteToPQ(DEFAULT_TOPIC_NAME, 15, "abacaba", 1, "valuevaluevalue1"); } - Y_UNIT_TEST(Delete) { + Y_UNIT_TEST(Delete) { NPersQueue::TTestServer server(PQSettings(0).SetDomainName("Root").SetNodeCount(2)); server.EnableLogs({ NKikimrServices::FLAT_TX_SCHEMESHARD, NKikimrServices::PERSQUEUE}); @@ -767,7 +767,7 @@ namespace { } - Y_UNIT_TEST(BigRead) { + Y_UNIT_TEST(BigRead) { NPersQueue::TTestServer server(PQSettings(0).SetDomainName("Root")); server.AnnoyingClient->CreateTopic(DEFAULT_TOPIC_NAME, 1, 8*1024*1024, 86400, 20000000, "user1", 2000000); @@ -793,7 +793,7 @@ namespace { // expects that L2 size is 32Mb - Y_UNIT_TEST(Cache) { + Y_UNIT_TEST(Cache) { NPersQueue::TTestServer server(PQSettings(0).SetDomainName("Root")); server.AnnoyingClient->CreateTopic(DEFAULT_TOPIC_NAME, 1, 8*1024*1024, 86400); @@ -824,7 +824,7 @@ namespace { UNIT_ASSERT(fromCache < 5); } - Y_UNIT_TEST(CacheHead) { + Y_UNIT_TEST(CacheHead) { NPersQueue::TTestServer server(PQSettings(0).SetDomainName("Root")); server.AnnoyingClient->CreateTopic(DEFAULT_TOPIC_NAME, 1, 6*1024*1024, 86400); @@ -853,7 +853,7 @@ namespace { } } - Y_UNIT_TEST(SameOffset) { + Y_UNIT_TEST(SameOffset) { NPersQueue::TTestServer server(PQSettings(0).SetDomainName("Root")); server.AnnoyingClient->CreateTopic(DEFAULT_TOPIC_NAME, 1, 6*1024*1024, 86400); TString secondTopic = DEFAULT_TOPIC_NAME + "2"; @@ -888,7 +888,7 @@ namespace { } - Y_UNIT_TEST(FetchRequest) { + Y_UNIT_TEST(FetchRequest) { NPersQueue::TTestServer server(PQSettings(0).SetDomainName("Root")); TString secondTopic = DEFAULT_TOPIC_NAME + "2"; @@ -913,7 +913,7 @@ namespace { server.AnnoyingClient->FetchRequestPQ({{secondTopic, 5, 500, 400},{secondTopic, 4, 0, 400},{DEFAULT_TOPIC_NAME, 1, 0, 400}}, 400, 1000000); } - Y_UNIT_TEST(Init) { + Y_UNIT_TEST(Init) { NPersQueue::TTestServer server(PQSettings(0).SetDomainName("Root").SetNodeCount(2)); if (!true) { server.EnableLogs( { @@ -984,7 +984,7 @@ namespace { } } - Y_UNIT_TEST(WhenDisableNodeAndCreateTopic_ThenAllPartitionsAreOnOtherNode) { + Y_UNIT_TEST(WhenDisableNodeAndCreateTopic_ThenAllPartitionsAreOnOtherNode) { NPersQueue::TTestServer server(PQSettings(0).SetDomainName("Root").SetNodeCount(2)); server.EnableLogs({ NKikimrServices::PERSQUEUE, NKikimrServices::HIVE }); TString unusedTopic = "rt3.dc1--unusedtopic"; @@ -1063,7 +1063,7 @@ namespace { }; - Y_UNIT_TEST(CheckACLForGrpcWrite) { + Y_UNIT_TEST(CheckACLForGrpcWrite) { NPersQueue::TTestServer server(PQSettings(0, 1)); server.EnableLogs({ NKikimrServices::PQ_WRITE_PROXY }); PrepareForGrpc(server); @@ -1135,7 +1135,7 @@ namespace { } - Y_UNIT_TEST(CheckACLForGrpcRead) { + Y_UNIT_TEST(CheckACLForGrpcRead) { NPersQueue::TTestServer server(PQSettings(0, 1)); server.EnableLogs({ NKikimrServices::PQ_READ_PROXY }); server.EnableLogs({ NKikimrServices::PERSQUEUE }, NActors::NLog::PRI_INFO); @@ -1258,7 +1258,7 @@ namespace { } } - Y_UNIT_TEST(CheckKillBalancer) { + Y_UNIT_TEST(CheckKillBalancer) { NPersQueue::TTestServer server; server.EnableLogs({ NKikimrServices::PQ_WRITE_PROXY, NKikimrServices::PQ_READ_PROXY}); PrepareForGrpc(server); @@ -1315,7 +1315,7 @@ namespace { } - Y_UNIT_TEST(TestWriteStat) { + Y_UNIT_TEST(TestWriteStat) { NPersQueue::TTestServer server(PQSettings(0, 1, true, "10"), false); auto netDataUpdated = server.PrepareNetDataFile(FormNetData()); UNIT_ASSERT(netDataUpdated); @@ -1430,7 +1430,7 @@ namespace { } /* - Y_UNIT_TEST(TestLockErrors) { + Y_UNIT_TEST(TestLockErrors) { return; // Test is ignored. FIX: KIKIMR-7881 NPersQueue::TTestServer server; diff --git a/ydb/services/ydb/ydb_ut.cpp b/ydb/services/ydb/ydb_ut.cpp index 2d370630799..1a8bd06ba24 100644 --- a/ydb/services/ydb/ydb_ut.cpp +++ b/ydb/services/ydb/ydb_ut.cpp @@ -115,8 +115,8 @@ struct TKikimrTestSettings { static constexpr bool PrecreatePools = true; }; -Y_UNIT_TEST_SUITE(TGRpcClientLowTest) { - Y_UNIT_TEST(SimpleRequest) { +Y_UNIT_TEST_SUITE(TGRpcClientLowTest) { + Y_UNIT_TEST(SimpleRequest) { TKikimrWithGrpcAndRootSchema server; ui16 grpc = server.GetPort(); TString location = TStringBuilder() << "localhost:" << grpc; @@ -352,7 +352,7 @@ Y_UNIT_TEST_SUITE(TGRpcClientLowTest) { } } - Y_UNIT_TEST(MultipleSimpleRequests) { + Y_UNIT_TEST(MultipleSimpleRequests) { TKikimrWithGrpcAndRootSchema server; ui16 grpc = server.GetPort(); TString location = TStringBuilder() << "localhost:" << grpc; @@ -472,8 +472,8 @@ Y_UNIT_TEST_SUITE(TGRpcClientLowTest) { } } -Y_UNIT_TEST_SUITE(TGRpcNewClient) { - Y_UNIT_TEST(SimpleYqlQuery) { +Y_UNIT_TEST_SUITE(TGRpcNewClient) { + Y_UNIT_TEST(SimpleYqlQuery) { TKikimrWithGrpcAndRootSchema server; ui16 grpc = server.GetPort(); TString location = TStringBuilder() << "localhost:" << grpc; @@ -557,7 +557,7 @@ Y_UNIT_TEST_SUITE(TGRpcNewClient) { connection.Stop(true); } - Y_UNIT_TEST(YqlQueryWithParams) { + Y_UNIT_TEST(YqlQueryWithParams) { TKikimrWithGrpcAndRootSchema server; ui16 grpc = server.GetPort(); TString location = TStringBuilder() << "localhost:" << grpc; @@ -617,7 +617,7 @@ Y_UNIT_TEST_SUITE(TGRpcNewClient) { client.CreateSession().Apply(createSessionHandler).Wait(); } - Y_UNIT_TEST(YqlExplainDataQuery) { + Y_UNIT_TEST(YqlExplainDataQuery) { TKikimrWithGrpcAndRootSchema server; ui16 grpc = server.GetPort(); TString location = TStringBuilder() << "localhost:" << grpc; @@ -859,8 +859,8 @@ Y_UNIT_TEST_SUITE(GrpcConnectionStringParserTest) { } } -Y_UNIT_TEST_SUITE(TGRpcYdbTest) { - Y_UNIT_TEST(RemoveNotExistedDirecroty) { +Y_UNIT_TEST_SUITE(TGRpcYdbTest) { + Y_UNIT_TEST(RemoveNotExistedDirecroty) { TKikimrWithGrpcAndRootSchema server; ui16 grpc = server.GetPort(); @@ -890,7 +890,7 @@ Y_UNIT_TEST_SUITE(TGRpcYdbTest) { } } - Y_UNIT_TEST(MakeListRemoveDirectory) { + Y_UNIT_TEST(MakeListRemoveDirectory) { TKikimrWithGrpcAndRootSchemaNoSystemViews server; ui16 grpc = server.GetPort(); @@ -988,7 +988,7 @@ Y_UNIT_TEST_SUITE(TGRpcYdbTest) { */ } - Y_UNIT_TEST(GetOperationBadRequest) { + Y_UNIT_TEST(GetOperationBadRequest) { TKikimrWithGrpcAndRootSchema server; ui16 grpc = server.GetPort(); @@ -1017,7 +1017,7 @@ Y_UNIT_TEST_SUITE(TGRpcYdbTest) { } /* - Y_UNIT_TEST(GetOperationUnknownId) { + Y_UNIT_TEST(GetOperationUnknownId) { TKikimrWithGrpcAndRootSchema server; ui16 grpc = server.GetPort(); @@ -1029,7 +1029,7 @@ Y_UNIT_TEST_SUITE(TGRpcYdbTest) { } } */ - Y_UNIT_TEST(CreateTableBadRequest) { + Y_UNIT_TEST(CreateTableBadRequest) { TKikimrWithGrpcAndRootSchema server; ui16 grpc = server.GetPort(); @@ -1102,7 +1102,7 @@ Y_UNIT_TEST_SUITE(TGRpcYdbTest) { CreateTableBadRequest(scheme, expected, Ydb::StatusIds::BAD_REQUEST); } - Y_UNIT_TEST(DropTableBadRequest) { + Y_UNIT_TEST(DropTableBadRequest) { TKikimrWithGrpcAndRootSchema server; ui16 grpc = server.GetPort(); @@ -1189,7 +1189,7 @@ Y_UNIT_TEST_SUITE(TGRpcYdbTest) { } } - Y_UNIT_TEST(CreateAlterCopyAndDropTable) { + Y_UNIT_TEST(CreateAlterCopyAndDropTable) { TKikimrWithGrpcAndRootSchema server; ui16 grpc = server.GetPort(); @@ -1632,7 +1632,7 @@ partitioning_settings { } - Y_UNIT_TEST(CreateYqlSession) { + Y_UNIT_TEST(CreateYqlSession) { TKikimrWithGrpcAndRootSchema server; ui16 grpc = server.GetPort(); @@ -1652,7 +1652,7 @@ partitioning_settings { } } - Y_UNIT_TEST(CreateDeleteYqlSession) { + Y_UNIT_TEST(CreateDeleteYqlSession) { TKikimrWithGrpcAndRootSchema server; ui16 grpc = server.GetPort(); @@ -1691,7 +1691,7 @@ partitioning_settings { } - Y_UNIT_TEST(ExecuteQueryBadRequest) { + Y_UNIT_TEST(ExecuteQueryBadRequest) { TKikimrWithGrpcAndRootSchema server; ui16 grpc = server.GetPort(); @@ -1731,7 +1731,7 @@ partitioning_settings { } } - Y_UNIT_TEST(ExecuteQueryImplicitSession) { + Y_UNIT_TEST(ExecuteQueryImplicitSession) { TKikimrWithGrpcAndRootSchema server; ui16 grpc = server.GetPort(); @@ -1752,7 +1752,7 @@ partitioning_settings { } } - Y_UNIT_TEST(ExecuteQueryExplicitSession) { + Y_UNIT_TEST(ExecuteQueryExplicitSession) { TKikimrWithGrpcAndRootSchema server; ui16 grpc = server.GetPort(); @@ -1961,7 +1961,7 @@ tx_meta { } } - Y_UNIT_TEST(ExecuteQueryWithParametersBadRequest) { + Y_UNIT_TEST(ExecuteQueryWithParametersBadRequest) { TKikimrWithGrpcAndRootSchema server; ui16 grpc = server.GetPort(); @@ -2055,7 +2055,7 @@ tx_meta { } } - Y_UNIT_TEST(ExecuteQueryWithParametersExplicitSession) { + Y_UNIT_TEST(ExecuteQueryWithParametersExplicitSession) { TKikimrWithGrpcAndRootSchema server; ui16 grpc = server.GetPort(); @@ -2213,7 +2213,7 @@ tx_meta { } - Y_UNIT_TEST(ExecuteDmlQuery) { + Y_UNIT_TEST(ExecuteDmlQuery) { TKikimrWithGrpcAndRootSchema server; ui16 grpc = server.GetPort(); @@ -2406,7 +2406,7 @@ tx_meta { } } - Y_UNIT_TEST(CreateYqlSessionExecuteQuery) { + Y_UNIT_TEST(CreateYqlSessionExecuteQuery) { TKikimrWithGrpcAndRootSchema server; ui16 grpc = server.GetPort(); @@ -2466,7 +2466,7 @@ tx_meta { } - Y_UNIT_TEST(ExecutePreparedQuery) { + Y_UNIT_TEST(ExecutePreparedQuery) { TKikimrWithGrpcAndRootSchema server; ui16 grpc = server.GetPort(); std::shared_ptr<grpc::Channel> Channel_; @@ -2646,7 +2646,7 @@ tx_meta { } } - Y_UNIT_TEST(ExplainQuery) { + Y_UNIT_TEST(ExplainQuery) { TKikimrWithGrpcAndRootSchema server; ui16 grpc = server.GetPort(); @@ -2737,7 +2737,7 @@ tx_meta { } } - Y_UNIT_TEST(DeleteFromAfterCreate) { + Y_UNIT_TEST(DeleteFromAfterCreate) { TKikimrWithGrpcAndRootSchema server; ui16 grpc = server.GetPort(); @@ -2863,7 +2863,7 @@ tx_meta { } } - Y_UNIT_TEST(ReadTable) { + Y_UNIT_TEST(ReadTable) { TKikimrWithGrpcAndRootSchema server; server.Server_->GetRuntime()->SetLogPriority(NKikimrServices::GRPC_SERVER, NLog::PRI_TRACE); server.Server_->GetRuntime()->SetLogPriority(NKikimrServices::READ_TABLE_API, NLog::PRI_TRACE); |