1 /*
2 * Copyright (C) 2018 The Android Open Source Project
3 *
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
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
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.
15 */
16
17 #include "minikin/AndroidLineBreakerHelper.h"
18
19 #include <gtest/gtest.h>
20
21 namespace minikin {
22 namespace android {
23
TEST(AndroidLineWidth,negativeWidthTest)24 TEST(AndroidLineWidth, negativeWidthTest) {
25 const int LINE_COUNT = 10;
26 const std::vector<float> EMPTY;
27 {
28 AndroidLineWidth lineWidth(-10 /* first width */, 1 /* first count */, 0 /* rest width */,
29 EMPTY, 0);
30
31 EXPECT_LE(0.0f, lineWidth.getMin());
32 for (int i = 0; i < LINE_COUNT; ++i) {
33 EXPECT_LE(0.0f, lineWidth.getAt(i));
34 }
35 }
36 {
37 AndroidLineWidth lineWidth(0 /* first width */, 0 /* first count */, -10 /* rest width */,
38 EMPTY, 0);
39
40 EXPECT_LE(0.0f, lineWidth.getMin());
41 for (int i = 0; i < LINE_COUNT; ++i) {
42 EXPECT_LE(0.0f, lineWidth.getAt(i));
43 }
44 }
45 {
46 std::vector<float> indents = {10};
47 AndroidLineWidth lineWidth(0 /* first width */, 0 /* first count */, 0 /* rest width */,
48 indents, 0);
49
50 EXPECT_LE(0.0f, lineWidth.getMin());
51 for (int i = 0; i < LINE_COUNT; ++i) {
52 EXPECT_LE(0.0f, lineWidth.getAt(i));
53 }
54 }
55 }
56
57 } // namespace android
58 } // namespace minikin
59