blob: 3f8fa8b358ad28ea0e36767e2bb644e9964ce742 [file] [edit]
// Copyright 2026 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#ifndef THIRD_PARTY_CREDENTIO_TESTING_TEST_STRING_UTILS_H_
#define THIRD_PARTY_CREDENTIO_TESTING_TEST_STRING_UTILS_H_
#include <cstdint>
#include <string>
#include "riegeli/endian/endian_writing.h"
namespace credentio_testing {
inline std::string Uint8Str(uint8_t value) {
std::string s;
s.resize(sizeof(value));
s[0] = value;
return s;
}
inline std::string Uint16Str(uint16_t value) {
std::string s;
s.resize(sizeof(value));
riegeli::WriteBigEndian<uint16_t>(value, s.data());
return s;
}
inline std::string Uint32Str(uint32_t value) {
std::string s;
s.resize(sizeof(value));
riegeli::WriteBigEndian<uint32_t>(value, s.data());
return s;
}
inline std::string Uint64Str(uint64_t value) {
std::string s;
s.resize(sizeof(value));
riegeli::WriteBigEndian<uint64_t>(value, s.data());
return s;
}
} // namespace credentio_testing
#endif // THIRD_PARTY_CREDENTIO_TESTING_TEST_STRING_UTILS_H_