Skip to content
This repository has been archived by the owner on Aug 13, 2020. It is now read-only.

Added Chinese #14

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions Numsense.UnitTests.CSharp/NumeralConverterProperties.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,22 @@ public static Arbitrary<ConverterPropertyGroup> Converter()
new RussianNumeralConverter(),
NumeralModule.toRussian,
NumeralModule.tryParseRussian),
new ConverterPropertyGroup(
new TraditionalChineseNumeralConverter(),
NumeralModule.toTraditionalChinese,
NumeralModule.tryParseTraditionalChinese),
new ConverterPropertyGroup(
new TraditionalFinancialChineseNumeralConverter(),
NumeralModule.toTraditionalFinancialChinese,
NumeralModule.tryParseTraditionalFinancialChinese),
new ConverterPropertyGroup(
new SimplifiedChineseNumeralConverter(),
NumeralModule.toSimplifiedChinese,
NumeralModule.tryParseSimplifiedChinese),
new ConverterPropertyGroup(
new SimplifiedFinancialChineseNumeralConverter(),
NumeralModule.toSimplifiedFinancialChinese,
NumeralModule.tryParseSimplifiedFinancialChinese),
new ConverterPropertyGroup(
new CatalanNumeralConverter(),
NumeralModule.toCatalan,
Expand Down
62 changes: 62 additions & 0 deletions Numsense.UnitTests.CSharp/NumeralTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,68 @@ public void RussianIsSingleton()
Assert.Same(expected, actual);
}

[Fact]
public void TraditionalChineseIsCorrect()
{
var actual = Numeral.TraditionalChinese;
Assert.IsAssignableFrom<TraditionalChineseNumeralConverter>(actual);
}

[Fact]
public void TraditionalChineseIsSingleton()
{
var expected = Numeral.TraditionalChinese;
var actual = Numeral.TraditionalChinese;
Assert.Same(expected, actual);
}

[Fact]
public void TraditionalFinancialChineseIsCorrect()
{
var actual = Numeral.TraditionalFinancialChinese;
Assert.IsAssignableFrom
<TraditionalFinancialChineseNumeralConverter>(actual);
}

[Fact]
public void TraditionalFinancialChineseIsSingleton()
{
var expected = Numeral.TraditionalFinancialChinese;
var actual = Numeral.TraditionalFinancialChinese;
Assert.Same(expected, actual);
}

[Fact]
public void SimplifiedChineseIsCorrect()
{
var actual = Numeral.SimplifiedChinese;
Assert.IsAssignableFrom<SimplifiedChineseNumeralConverter>(actual);
}

[Fact]
public void SimplifiedChineseIsSingleton()
{
var expected = Numeral.SimplifiedChinese;
var actual = Numeral.SimplifiedChinese;
Assert.Same(expected, actual);
}

[Fact]
public void SimplifiedFinancialChineseIsCorrect()
{
var actual = Numeral.SimplifiedFinancialChinese;
Assert.IsAssignableFrom
<SimplifiedFinancialChineseNumeralConverter>(actual);
}

[Fact]
public void SimplifiedFinancialChineseIsSingleton()
{
var expected = Numeral.SimplifiedFinancialChinese;
var actual = Numeral.SimplifiedFinancialChinese;
Assert.Same(expected, actual);
}

[Fact]
public void CatalanIsCorrect()
{
Expand Down
65 changes: 65 additions & 0 deletions Numsense.UnitTests/NumeralProperties.fs
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,71 @@ let ``negative Russian is the inverse of positive Russian`` x =
sprintf "минус %s" (Numeral.toRussian x) =! actualRussian
Some -x =! actualInteger


[<Property(QuietOnSuccess = true)>]
let ``tryParseTraditionalChinese is the inverse of toTraditionalChinese`` x =
test <@ Some x = (x |> Numeral.toTraditionalChinese
|> Numeral.tryParseTraditionalChinese) @>

[<Property(QuietOnSuccess = true)>]
let ``negative TraditionalChinese is the inverse of positive TraditionalChinese`` x =
x <> 0 ==> lazy
let x = abs x

let actualChinese = Numeral.toTraditionalChinese -x
let actualInteger = Numeral.tryParseTraditionalChinese actualChinese

sprintf "負%s" (Numeral.toTraditionalChinese x) =! actualChinese
Some -x =! actualInteger

[<Property(QuietOnSuccess = true)>]
let ``tryParseTraditionalFinancialChinese is the inverse of toTraditionalFinancialChinese`` x =
test <@ Some x = (x |> Numeral.toTraditionalFinancialChinese
|> Numeral.tryParseTraditionalFinancialChinese) @>

[<Property(QuietOnSuccess = true)>]
let ``negative TraditionalFinancialChinese is the inverse of positive TraditionalFinancialChinese`` x =
x <> 0 ==> lazy
let x = abs x

let actualChinese = Numeral.toTraditionalFinancialChinese -x
let actualInteger = Numeral.tryParseTraditionalFinancialChinese actualChinese

sprintf "負%s" (Numeral.toTraditionalFinancialChinese x) =! actualChinese
Some -x =! actualInteger

[<Property(QuietOnSuccess = true)>]
let ``tryParseSimplifiedChinese is the inverse of toSimplifiedChinese`` x =
test <@ Some x = (x |> Numeral.toSimplifiedChinese
|> Numeral.tryParseSimplifiedChinese) @>

[<Property(QuietOnSuccess = true)>]
let ``negative SimplifiedChinese is the inverse of positive SimplifiedChinese`` x =
x <> 0 ==> lazy
let x = abs x

let actualChinese = Numeral.toSimplifiedChinese -x
let actualInteger = Numeral.tryParseSimplifiedChinese actualChinese

sprintf "负%s" (Numeral.toSimplifiedChinese x) =! actualChinese
Some -x =! actualInteger

[<Property(QuietOnSuccess = true)>]
let ``tryParseSimplifiedFinancialChinese is the inverse of toSimplifiedFinancialChinese`` x =
test <@ Some x = (x |> Numeral.toSimplifiedFinancialChinese
|> Numeral.tryParseSimplifiedFinancialChinese) @>

[<Property(QuietOnSuccess = true)>]
let ``negative SimplifiedFinancialChinese is the inverse of positive SimplifiedFinancialChinese`` x =
x <> 0 ==> lazy
let x = abs x

let actualChinese = Numeral.toSimplifiedFinancialChinese -x
let actualInteger = Numeral.tryParseSimplifiedFinancialChinese actualChinese

sprintf "负%s" (Numeral.toSimplifiedFinancialChinese x) =! actualChinese
Some -x =! actualInteger

[<Property(QuietOnSuccess = true)>]
let ``tryParseCatalan is the inverse of toCatalan`` x =
test <@ Some x = (x |> Numeral.toCatalan |> Numeral.tryParseCatalan) @>
Expand Down
4 changes: 4 additions & 0 deletions Numsense.UnitTests/Numsense.UnitTests.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@
<Compile Include="PolishExamples.fs" />
<Compile Include="DutchExamples.fs" />
<Compile Include="RussianExamples.fs" />
<Compile Include="TraditionalChineseExamples.fs" />
<Compile Include="TraditionalFinancialChineseExamples.fs" />
<Compile Include="SimplifiedChineseExamples.fs" />
<Compile Include="SimplifiedFinancialChineseExamples.fs" />
<Compile Include="CatalanExamples.fs" />
<Compile Include="Demo.fs" />
<Content Include="packages.config" />
Expand Down
Loading