* Copyright (c) 2024 Huawei Device Co., Ltd.
* 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
*
* http://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.
*/
#include "gtest/gtest.h"
#include "PublicMethods.h"
namespace {
TEST(CppTimerTest, CopyConstructorDeletedTest)
{
EXPECT_TRUE(std::is_copy_constructible<PublicMethods>::value == false);
}
TEST(CppTimerTest, AssignmentOperatorDeletedTest)
{
EXPECT_TRUE(std::is_copy_assignable<PublicMethods>::value == false);
}
bool CompareInt8Arrays(const int8_t* arr1, const int8_t* arr2, size_t size)
{
for (size_t i = 0; i < size; ++i) {
if (arr1[i] != arr2[i]) {
return false;
}
}
return true;
}
TEST(PublicMethodsTest, UlltoaTest)
{
const int testValue = 123456789;
const int8_t expectedOutput[] = "75bcd15";
int8_t outputBuffer[PublicMethods::MAX_ITOA_BIT] = {0};
uint32_t resultLength = PublicMethods::Ulltoa(testValue, outputBuffer);
ASSERT_EQ(std::size(expectedOutput) - 1, resultLength);
ASSERT_TRUE(CompareInt8Arrays(expectedOutput, outputBuffer, resultLength));
}
}