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

Commit

Permalink
Added Chinese
Browse files Browse the repository at this point in the history
  • Loading branch information
kfazi committed Jan 11, 2016
1 parent b957daf commit 10c772e
Show file tree
Hide file tree
Showing 12 changed files with 1,299 additions and 2 deletions.
18 changes: 17 additions & 1 deletion Numsense.UnitTests.CSharp/NumeralConverterProperties.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,23 @@ public static Arbitrary<ConverterPropertyGroup> Converter()
new ConverterPropertyGroup(
new PolishNumeralConverter(),
NumeralModule.toPolish,
NumeralModule.tryParsePolish)
NumeralModule.tryParsePolish),
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)
)
.ToArbitrary();
}
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 @@ -49,5 +49,67 @@ public void PolishIsSingleton()
var actual = Numeral.Polish;
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);
}
}
}
64 changes: 64 additions & 0 deletions Numsense.UnitTests/NumeralProperties.fs
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,68 @@ let ``negative Polish is the inverse of positive Polish`` x =
let actualInteger = Numeral.tryParsePolish actualPolish

sprintf "minus %s" (Numeral.toPolish x) =! actualPolish
Some -x =! actualInteger

[<Property(QuietOnSuccess = true)>]
let ``tryOfTraditionalChinese 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 ``tryOfTraditionalFinancialChinese 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 ``tryOfSimplifiedChinese 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 ``tryOfSimplifiedFinancialChinese 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
4 changes: 4 additions & 0 deletions Numsense.UnitTests/Numsense.UnitTests.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@
<Compile Include="DanishExamples.fs" />
<Compile Include="EnglishExamples.fs" />
<Compile Include="PolishExamples.fs" />
<Compile Include="TraditionalChineseExamples.fs" />
<Compile Include="TraditionalFinancialChineseExamples.fs" />
<Compile Include="SimplifiedChineseExamples.fs" />
<Compile Include="SimplifiedFinancialChineseExamples.fs" />
<Compile Include="Demo.fs" />
<Content Include="packages.config" />
<Content Include="App.config" />
Expand Down
Loading

0 comments on commit 10c772e

Please sign in to comment.