2 * Copyright (c) 2020 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 // Enable debug log for test coverage
19 #define DEBUG_ENABLED 1
21 #include "dali-scene3d/public-api/loader/utils.h"
22 #include <dali-test-suite-utils.h>
23 #include <string_view>
26 using namespace Dali::Scene3D::Loader;
30 constexpr std::string_view TEST_STRING = "The quick brown fox jumped over a lazy dog.1337true";
34 void HelpTestStreamBuffer()
37 StreamBuffer streamBuffer(buffer, N); // note we aren't leaving space for a terminating 0 as we're using strNcmp.
38 std::ostream stream(&streamBuffer);
40 stream << "The quick brown fox jumped over a lazy dog.";
42 stream << std::boolalpha << true;
44 const size_t checkLen = std::min(N, TEST_STRING.size());
45 DALI_TEST_EQUAL(0, strncmp(buffer, TEST_STRING.data(), checkLen));
48 int UtcDaliUtilsStreamBuffer(void)
50 HelpTestStreamBuffer<16>();
51 HelpTestStreamBuffer<32>();
52 HelpTestStreamBuffer<64>();
56 int UtcDaliUtilsFormatString(void)
58 DALI_TEST_EQUAL(FormatString("%s", "hello"), "hello");
59 DALI_TEST_EQUAL(FormatString("%d", 1667), "1667");
61 DALI_TEST_EQUAL(FormatString("%s %d", "hello", 2778), "hello 2778");
62 DALI_TEST_EQUAL(FormatString("%d %s", 3889, "hello"), "3889 hello");