| 1 |
// SPDX-License-Identifier: MIT OR MPL-2.0 OR LGPL-2.1-or-later OR GPL-2.0-or-later |
| 2 |
// Copyright (C) 2012 SIL International |
| 3 |
using System; |
| 4 |
using NUnit.Framework; |
| 5 |
using NGraphite; |
| 6 |
|
| 7 |
namespace NGraphiteTests |
| 8 |
{ |
| 9 |
[TestFixture()] |
| 10 |
public class SegmentTests |
| 11 |
{ |
| 12 |
Face _face; |
| 13 |
Font _font; |
| 14 |
Featureval _featureval; |
| 15 |
Segment _segment; |
| 16 |
|
| 17 |
[SetUp] |
| 18 |
public void PerTestSetup() |
| 19 |
{ |
| 20 |
_face = new Face(TestConstants.PaduakFontLocation, FaceOptions.face_default); |
| 21 |
_font = new Font(20.0f, _face); |
| 22 |
_featureval = _face.FeaturevalForLang("en"); |
| 23 |
_segment = _font.MakeSeg(0, _featureval, "hello world", Bidirtl.Nobidi); |
| 24 |
} |
| 25 |
|
| 26 |
[TearDown] |
| 27 |
public void PerTestTearDown() |
| 28 |
{ |
| 29 |
_face.Dispose(); |
| 30 |
_font.Dispose(); |
| 31 |
_featureval.Dispose(); |
| 32 |
_segment.Dispose(); |
| 33 |
} |
| 34 |
|
| 35 |
[Test()] |
| 36 |
public void AdvanceX_OnTestSegment_ReturnsExpectedAdvance() |
| 37 |
{ |
| 38 |
Assert.AreEqual(90.234375f, _segment.AdvanceX); |
| 39 |
} |
| 40 |
|
| 41 |
[Test()] |
| 42 |
public void AdvanceY_OnTestSegment_ReturnsExpectedAdvance() |
| 43 |
{ |
| 44 |
Assert.AreEqual(0.0f, _segment.AdvanceY); |
| 45 |
} |
| 46 |
|
| 47 |
[Test()] |
| 48 |
public void NCinfo_OnTestSegment_ReturnsExpectedNumber() |
| 49 |
{ |
| 50 |
Assert.AreEqual(11, _segment.NCinfo); |
| 51 |
} |
| 52 |
|
| 53 |
[Test()] |
| 54 |
public void Cinfo_OnTestSegment_ReturnsNonNullCharInfo() |
| 55 |
{ |
| 56 |
CharInfo charInfo = _segment.Cinfo(0); |
| 57 |
Assert.IsNotNull(charInfo); |
| 58 |
} |
| 59 |
|
| 60 |
[Test()] |
| 61 |
public void FirstSlot_OnTestSegment_ReturnsNonNullSlot() |
| 62 |
{ |
| 63 |
Slot slot = _segment.FirstSlot; |
| 64 |
Assert.NotNull(slot); |
| 65 |
} |
| 66 |
|
| 67 |
[Test()] |
| 68 |
public void LastSlot_OnTestSegment_ReturnsNonNullSlot() |
| 69 |
{ |
| 70 |
Slot slot = _segment.LastSlot; |
| 71 |
Assert.NotNull(slot); |
| 72 |
} |
| 73 |
|
| 74 |
[Test()] |
| 75 |
public void Justify_SpecifyNullForFirstAndLast_DoesNotThrowException() |
| 76 |
{ |
| 77 |
Slot firstSlot = _segment.FirstSlot; |
| 78 |
_segment.Justify(firstSlot, _font, 100, JustFlags.JustEndInline, null, null); |
| 79 |
} |
| 80 |
|
| 81 |
[Test()] |
| 82 |
public void Justify_SpecifyNonNullFirstAndLast_DoesNotThrowException() |
| 83 |
{ |
| 84 |
Slot firstSlot = _segment.FirstSlot; |
| 85 |
Slot lastSlot = _segment.LastSlot; |
| 86 |
_segment.Justify(firstSlot, _font, 100, JustFlags.JustEndInline, firstSlot, lastSlot); |
| 87 |
} |
| 88 |
} |
| 89 |
} |
| 90 |
|