exiv2/unitTests/test_helper_functions.cpp
Luis Díaz Más b17828b454
Use SPDX for licenses (#2122)
* Use SPDX identifier in header files

* Use SPDX identifier in rest of source files

* Fix usage of SPDX for files with 2 licenses

* Add global license file

* Fix compilation
2022-03-04 11:44:39 +01:00

23 lines
575 B
C++

// SPDX-License-Identifier: GPL-2.0-or-later
#include "helper_functions.hpp"
#include <gtest/gtest.h>
TEST(string_from_unterminated, terminatedArray)
{
const char data[5] = {'a', 'b', 'c', 0, 'd'};
const std::string res = string_from_unterminated(data, 5);
ASSERT_EQ(res.size(), 3U);
ASSERT_STREQ(res.c_str(), "abc");
}
TEST(string_from_unterminated, unterminatedArray)
{
const char data[4] = {'a', 'b', 'c', 'd'};
const std::string res = string_from_unterminated(data, 4);
ASSERT_EQ(res.size(), 4U);
ASSERT_STREQ(res.c_str(), "abcd");
}