| 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 CharInfoTests |
| 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 UnicodeChar_OnFirstCharInfoInTestSegment_ReturnsExpectedChar() |
| 37 |
{ |
| 38 |
Assert.AreEqual(104, CreateTestCharInfo(0).UnicodeChar); |
| 39 |
} |
| 40 |
|
| 41 |
[Test()] |
| 42 |
public void BreakWeight_OnFirstCharInfoInTestSegment_ReturnsExpectedValue() |
| 43 |
{ |
| 44 |
Assert.AreEqual(-30, CreateTestCharInfo(0).BreakWeight); |
| 45 |
} |
| 46 |
|
| 47 |
[Test()] |
| 48 |
public void After_OnFirstCharInfoInTestSegment_ReturnsZero() |
| 49 |
{ |
| 50 |
Assert.AreEqual(0, CreateTestCharInfo(0).After); |
| 51 |
} |
| 52 |
|
| 53 |
[Test()] |
| 54 |
public void Before_OnFirstCharInfoInTestSegment_ReturnsZero() |
| 55 |
{ |
| 56 |
Assert.AreEqual(0, CreateTestCharInfo(0).Before); |
| 57 |
} |
| 58 |
|
| 59 |
[Test()] |
| 60 |
public void Base_OnFirstCharInfoInTestSegment_ExpectedIndex() |
| 61 |
{ |
| 62 |
Assert.AreEqual(0, CreateTestCharInfo(0).Base); |
| 63 |
} |
| 64 |
|
| 65 |
#region Test Helpers |
| 66 |
|
| 67 |
protected CharInfo CreateTestCharInfo(uint index) |
| 68 |
{ |
| 69 |
return _segment.Cinfo(index); |
| 70 |
} |
| 71 |
|
| 72 |
#endregion |
| 73 |
|
| 74 |
} |
| 75 |
} |
| 76 |
|